feat(core): add pluggable web search (#35558)

Co-authored-by: Dax Raad <d@ironbay.co>
This commit is contained in:
Shoubhit Dash 2026-07-26 09:25:05 +05:30 committed by GitHub
commit efb629a33a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
57 changed files with 1700 additions and 587 deletions

View file

@ -27,6 +27,7 @@ import type {
ShellInfo,
SkillInfo,
OpenCodeEvent,
WebSearchProvider,
} from "@opencode-ai/client"
import type { Plugin } from "@opencode-ai/plugin/v2/tui"
import { createStore, produce, reconcile } from "solid-js/store"
@ -56,6 +57,7 @@ type LocationData = {
model?: ModelInfo[]
provider?: ProviderV2Info[]
reference?: ReferenceInfo[]
websearch?: WebSearchProvider[]
// Currently running shell commands for this location, keyed by shell id. Entries are removed
// once the command exits or is deleted, so this only ever holds in-flight shells.
shell?: Record<string, ShellInfo>
@ -875,6 +877,10 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
result.location.provider.sync(event.location),
])
break
case "config.updated":
case "websearch.updated":
void result.location.websearch.refresh(event.location)
break
// Authenticating an MCP integration reconnects its server, which emits mcp.status.changed,
// so the mcp list syncs here rather than off integration.updated.
case "mcp.status.changed":
@ -1251,6 +1257,20 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
sync.invalidate(`location.reference:${locationKey(ref ?? defaultLocation())}`)
},
},
websearch: {
list(location?: LocationRef) {
return store.location[locationKey(location ?? defaultLocation())]?.websearch
},
async refresh(ref?: LocationRef) {
const input = { location: locationQuery(ref ?? defaultLocation()) }
const providers = await client.api.websearch.providers(input)
const key = locationKey(providers.location)
setStore("location", key, {
...store.location[key],
websearch: providers.data,
})
},
},
skill: {
list(location?: LocationRef) {
return store.location[locationKey(location ?? defaultLocation())]?.skill