refactor: standardize InstanceState variable name to state (#20267)

This commit is contained in:
Kit Langton 2026-04-01 10:39:43 -04:00 committed by GitHub
commit 5fd833aa18
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 74 additions and 74 deletions

View file

@ -46,7 +46,7 @@ export namespace Bus {
export const layer = Layer.effect( export const layer = Layer.effect(
Service, Service,
Effect.gen(function* () { Effect.gen(function* () {
const cache = yield* InstanceState.make<State>( const state = yield* InstanceState.make<State>(
Effect.fn("Bus.state")(function* (ctx) { Effect.fn("Bus.state")(function* (ctx) {
const wildcard = yield* PubSub.unbounded<Payload>() const wildcard = yield* PubSub.unbounded<Payload>()
const typed = new Map<string, PubSub.PubSub<Payload>>() const typed = new Map<string, PubSub.PubSub<Payload>>()
@ -82,13 +82,13 @@ export namespace Bus {
function publish<D extends BusEvent.Definition>(def: D, properties: z.output<D["properties"]>) { function publish<D extends BusEvent.Definition>(def: D, properties: z.output<D["properties"]>) {
return Effect.gen(function* () { return Effect.gen(function* () {
const state = yield* InstanceState.get(cache) const s = yield* InstanceState.get(state)
const payload: Payload = { type: def.type, properties } const payload: Payload = { type: def.type, properties }
log.info("publishing", { type: def.type }) log.info("publishing", { type: def.type })
const ps = state.typed.get(def.type) const ps = s.typed.get(def.type)
if (ps) yield* PubSub.publish(ps, payload) if (ps) yield* PubSub.publish(ps, payload)
yield* PubSub.publish(state.wildcard, payload) yield* PubSub.publish(s.wildcard, payload)
const dir = yield* InstanceState.directory const dir = yield* InstanceState.directory
GlobalBus.emit("event", { GlobalBus.emit("event", {
@ -102,8 +102,8 @@ export namespace Bus {
log.info("subscribing", { type: def.type }) log.info("subscribing", { type: def.type })
return Stream.unwrap( return Stream.unwrap(
Effect.gen(function* () { Effect.gen(function* () {
const state = yield* InstanceState.get(cache) const s = yield* InstanceState.get(state)
const ps = yield* getOrCreate(state, def) const ps = yield* getOrCreate(s, def)
return Stream.fromPubSub(ps) return Stream.fromPubSub(ps)
}), }),
).pipe(Stream.ensuring(Effect.sync(() => log.info("unsubscribing", { type: def.type })))) ).pipe(Stream.ensuring(Effect.sync(() => log.info("unsubscribing", { type: def.type }))))
@ -113,8 +113,8 @@ export namespace Bus {
log.info("subscribing", { type: "*" }) log.info("subscribing", { type: "*" })
return Stream.unwrap( return Stream.unwrap(
Effect.gen(function* () { Effect.gen(function* () {
const state = yield* InstanceState.get(cache) const s = yield* InstanceState.get(state)
return Stream.fromPubSub(state.wildcard) return Stream.fromPubSub(s.wildcard)
}), }),
).pipe(Stream.ensuring(Effect.sync(() => log.info("unsubscribing", { type: "*" })))) ).pipe(Stream.ensuring(Effect.sync(() => log.info("unsubscribing", { type: "*" }))))
} }
@ -150,14 +150,14 @@ export namespace Bus {
def: D, def: D,
callback: (event: Payload<D>) => unknown, callback: (event: Payload<D>) => unknown,
) { ) {
const state = yield* InstanceState.get(cache) const s = yield* InstanceState.get(state)
const ps = yield* getOrCreate(state, def) const ps = yield* getOrCreate(s, def)
return yield* on(ps, def.type, callback) return yield* on(ps, def.type, callback)
}) })
const subscribeAllCallback = Effect.fn("Bus.subscribeAllCallback")(function* (callback: (event: any) => unknown) { const subscribeAllCallback = Effect.fn("Bus.subscribeAllCallback")(function* (callback: (event: any) => unknown) {
const state = yield* InstanceState.get(cache) const s = yield* InstanceState.get(state)
return yield* on(state.wildcard, "*", callback) return yield* on(s.wildcard, "*", callback)
}) })
return Service.of({ publish, subscribe, subscribeAll, subscribeCallback, subscribeAllCallback }) return Service.of({ publish, subscribe, subscribeAll, subscribeCallback, subscribeAllCallback })

View file

@ -161,16 +161,16 @@ export namespace Command {
} }
}) })
const cache = yield* InstanceState.make<State>((ctx) => init(ctx)) const state = yield* InstanceState.make<State>((ctx) => init(ctx))
const get = Effect.fn("Command.get")(function* (name: string) { const get = Effect.fn("Command.get")(function* (name: string) {
const state = yield* InstanceState.get(cache) const s = yield* InstanceState.get(state)
return state.commands[name] return s.commands[name]
}) })
const list = Effect.fn("Command.list")(function* () { const list = Effect.fn("Command.list")(function* () {
const state = yield* InstanceState.get(cache) const s = yield* InstanceState.get(state)
return Object.values(state.commands) return Object.values(s.commands)
}) })
return Service.of({ get, list }) return Service.of({ get, list })

View file

@ -477,7 +477,7 @@ export namespace MCP {
}) })
} }
const cache = yield* InstanceState.make<State>( const state = yield* InstanceState.make<State>(
Effect.fn("MCP.state")(function* () { Effect.fn("MCP.state")(function* () {
const cfg = yield* cfgSvc.get() const cfg = yield* cfgSvc.get()
const config = cfg.mcp ?? {} const config = cfg.mcp ?? {}
@ -549,7 +549,7 @@ export namespace MCP {
} }
const status = Effect.fn("MCP.status")(function* () { const status = Effect.fn("MCP.status")(function* () {
const s = yield* InstanceState.get(cache) const s = yield* InstanceState.get(state)
const cfg = yield* cfgSvc.get() const cfg = yield* cfgSvc.get()
const config = cfg.mcp ?? {} const config = cfg.mcp ?? {}
@ -564,12 +564,12 @@ export namespace MCP {
}) })
const clients = Effect.fn("MCP.clients")(function* () { const clients = Effect.fn("MCP.clients")(function* () {
const s = yield* InstanceState.get(cache) const s = yield* InstanceState.get(state)
return s.clients return s.clients
}) })
const createAndStore = Effect.fn("MCP.createAndStore")(function* (name: string, mcp: Config.Mcp) { const createAndStore = Effect.fn("MCP.createAndStore")(function* (name: string, mcp: Config.Mcp) {
const s = yield* InstanceState.get(cache) const s = yield* InstanceState.get(state)
const result = yield* create(name, mcp) const result = yield* create(name, mcp)
s.status[name] = result.status s.status[name] = result.status
@ -588,7 +588,7 @@ export namespace MCP {
const add = Effect.fn("MCP.add")(function* (name: string, mcp: Config.Mcp) { const add = Effect.fn("MCP.add")(function* (name: string, mcp: Config.Mcp) {
yield* createAndStore(name, mcp) yield* createAndStore(name, mcp)
const s = yield* InstanceState.get(cache) const s = yield* InstanceState.get(state)
return { status: s.status } return { status: s.status }
}) })
@ -602,7 +602,7 @@ export namespace MCP {
}) })
const disconnect = Effect.fn("MCP.disconnect")(function* (name: string) { const disconnect = Effect.fn("MCP.disconnect")(function* (name: string) {
const s = yield* InstanceState.get(cache) const s = yield* InstanceState.get(state)
yield* closeClient(s, name) yield* closeClient(s, name)
delete s.clients[name] delete s.clients[name]
s.status[name] = { status: "disabled" } s.status[name] = { status: "disabled" }
@ -610,7 +610,7 @@ export namespace MCP {
const tools = Effect.fn("MCP.tools")(function* () { const tools = Effect.fn("MCP.tools")(function* () {
const result: Record<string, Tool> = {} const result: Record<string, Tool> = {}
const s = yield* InstanceState.get(cache) const s = yield* InstanceState.get(state)
const cfg = yield* cfgSvc.get() const cfg = yield* cfgSvc.get()
const config = cfg.mcp ?? {} const config = cfg.mcp ?? {}
@ -657,12 +657,12 @@ export namespace MCP {
} }
const prompts = Effect.fn("MCP.prompts")(function* () { const prompts = Effect.fn("MCP.prompts")(function* () {
const s = yield* InstanceState.get(cache) const s = yield* InstanceState.get(state)
return yield* collectFromConnected(s, (c) => c.listPrompts().then((r) => r.prompts), "prompts") return yield* collectFromConnected(s, (c) => c.listPrompts().then((r) => r.prompts), "prompts")
}) })
const resources = Effect.fn("MCP.resources")(function* () { const resources = Effect.fn("MCP.resources")(function* () {
const s = yield* InstanceState.get(cache) const s = yield* InstanceState.get(state)
return yield* collectFromConnected(s, (c) => c.listResources().then((r) => r.resources), "resources") return yield* collectFromConnected(s, (c) => c.listResources().then((r) => r.resources), "resources")
}) })
@ -672,7 +672,7 @@ export namespace MCP {
label: string, label: string,
meta?: Record<string, unknown>, meta?: Record<string, unknown>,
) { ) {
const s = yield* InstanceState.get(cache) const s = yield* InstanceState.get(state)
const client = s.clients[clientName] const client = s.clients[clientName]
if (!client) { if (!client) {
log.warn(`client not found for ${label}`, { clientName }) log.warn(`client not found for ${label}`, { clientName })

View file

@ -103,7 +103,7 @@ export namespace Plugin {
const bus = yield* Bus.Service const bus = yield* Bus.Service
const config = yield* Config.Service const config = yield* Config.Service
const cache = yield* InstanceState.make<State>( const state = yield* InstanceState.make<State>(
Effect.fn("Plugin.state")(function* (ctx) { Effect.fn("Plugin.state")(function* (ctx) {
const hooks: Hooks[] = [] const hooks: Hooks[] = []
@ -279,8 +279,8 @@ export namespace Plugin {
Output = Parameters<Required<Hooks>[Name]>[1], Output = Parameters<Required<Hooks>[Name]>[1],
>(name: Name, input: Input, output: Output) { >(name: Name, input: Input, output: Output) {
if (!name) return output if (!name) return output
const state = yield* InstanceState.get(cache) const s = yield* InstanceState.get(state)
for (const hook of state.hooks) { for (const hook of s.hooks) {
const fn = hook[name] as any const fn = hook[name] as any
if (!fn) continue if (!fn) continue
yield* Effect.promise(async () => fn(input, output)) yield* Effect.promise(async () => fn(input, output))
@ -289,12 +289,12 @@ export namespace Plugin {
}) })
const list = Effect.fn("Plugin.list")(function* () { const list = Effect.fn("Plugin.list")(function* () {
const state = yield* InstanceState.get(cache) const s = yield* InstanceState.get(state)
return state.hooks return s.hooks
}) })
const init = Effect.fn("Plugin.init")(function* () { const init = Effect.fn("Plugin.init")(function* () {
yield* InstanceState.get(cache) yield* InstanceState.get(state)
}) })
return Service.of({ trigger, list, init }) return Service.of({ trigger, list, init })

View file

@ -967,7 +967,7 @@ export namespace Provider {
const config = yield* Config.Service const config = yield* Config.Service
const auth = yield* Auth.Service const auth = yield* Auth.Service
const cache = yield* InstanceState.make<State>(() => const state = yield* InstanceState.make<State>(() =>
Effect.gen(function* () { Effect.gen(function* () {
using _ = log.time("state") using _ = log.time("state")
const cfg = yield* config.get() const cfg = yield* config.get()
@ -1247,7 +1247,7 @@ export namespace Provider {
}), }),
) )
const list = Effect.fn("Provider.list")(() => InstanceState.use(cache, (s) => s.providers)) const list = Effect.fn("Provider.list")(() => InstanceState.use(state, (s) => s.providers))
async function resolveSDK(model: Model, s: State) { async function resolveSDK(model: Model, s: State) {
try { try {
@ -1385,11 +1385,11 @@ export namespace Provider {
} }
const getProvider = Effect.fn("Provider.getProvider")((providerID: ProviderID) => const getProvider = Effect.fn("Provider.getProvider")((providerID: ProviderID) =>
InstanceState.use(cache, (s) => s.providers[providerID]), InstanceState.use(state, (s) => s.providers[providerID]),
) )
const getModel = Effect.fn("Provider.getModel")(function* (providerID: ProviderID, modelID: ModelID) { const getModel = Effect.fn("Provider.getModel")(function* (providerID: ProviderID, modelID: ModelID) {
const s = yield* InstanceState.get(cache) const s = yield* InstanceState.get(state)
const provider = s.providers[providerID] const provider = s.providers[providerID]
if (!provider) { if (!provider) {
const available = Object.keys(s.providers) const available = Object.keys(s.providers)
@ -1407,7 +1407,7 @@ export namespace Provider {
}) })
const getLanguage = Effect.fn("Provider.getLanguage")(function* (model: Model) { const getLanguage = Effect.fn("Provider.getLanguage")(function* (model: Model) {
const s = yield* InstanceState.get(cache) const s = yield* InstanceState.get(state)
const key = `${model.providerID}/${model.id}` const key = `${model.providerID}/${model.id}`
if (s.models.has(key)) return s.models.get(key)! if (s.models.has(key)) return s.models.get(key)!
@ -1439,7 +1439,7 @@ export namespace Provider {
}) })
const closest = Effect.fn("Provider.closest")(function* (providerID: ProviderID, query: string[]) { const closest = Effect.fn("Provider.closest")(function* (providerID: ProviderID, query: string[]) {
const s = yield* InstanceState.get(cache) const s = yield* InstanceState.get(state)
const provider = s.providers[providerID] const provider = s.providers[providerID]
if (!provider) return undefined if (!provider) return undefined
for (const item of query) { for (const item of query) {
@ -1458,7 +1458,7 @@ export namespace Provider {
return yield* getModel(parsed.providerID, parsed.modelID) return yield* getModel(parsed.providerID, parsed.modelID)
} }
const s = yield* InstanceState.get(cache) const s = yield* InstanceState.get(state)
const provider = s.providers[providerID] const provider = s.providers[providerID]
if (!provider) return undefined if (!provider) return undefined
@ -1510,7 +1510,7 @@ export namespace Provider {
const cfg = yield* config.get() const cfg = yield* config.get()
if (cfg.model) return parseModel(cfg.model) if (cfg.model) return parseModel(cfg.model)
const s = yield* InstanceState.get(cache) const s = yield* InstanceState.get(state)
const recent = yield* Effect.promise(() => const recent = yield* Effect.promise(() =>
Filesystem.readJson<{ Filesystem.readJson<{
recent?: { providerID: ProviderID; modelID: ModelID }[] recent?: { providerID: ProviderID; modelID: ModelID }[]

View file

@ -130,7 +130,7 @@ export namespace Pty {
session.subscribers.clear() session.subscribers.clear()
} }
const cache = yield* InstanceState.make<State>( const state = yield* InstanceState.make<State>(
Effect.fn("Pty.state")(function* (ctx) { Effect.fn("Pty.state")(function* (ctx) {
const state = { const state = {
dir: ctx.directory, dir: ctx.directory,
@ -151,27 +151,27 @@ export namespace Pty {
) )
const remove = Effect.fn("Pty.remove")(function* (id: PtyID) { const remove = Effect.fn("Pty.remove")(function* (id: PtyID) {
const state = yield* InstanceState.get(cache) const s = yield* InstanceState.get(state)
const session = state.sessions.get(id) const session = s.sessions.get(id)
if (!session) return if (!session) return
state.sessions.delete(id) s.sessions.delete(id)
log.info("removing session", { id }) log.info("removing session", { id })
teardown(session) teardown(session)
void Bus.publish(Event.Deleted, { id: session.info.id }) void Bus.publish(Event.Deleted, { id: session.info.id })
}) })
const list = Effect.fn("Pty.list")(function* () { const list = Effect.fn("Pty.list")(function* () {
const state = yield* InstanceState.get(cache) const s = yield* InstanceState.get(state)
return Array.from(state.sessions.values()).map((session) => session.info) return Array.from(s.sessions.values()).map((session) => session.info)
}) })
const get = Effect.fn("Pty.get")(function* (id: PtyID) { const get = Effect.fn("Pty.get")(function* (id: PtyID) {
const state = yield* InstanceState.get(cache) const s = yield* InstanceState.get(state)
return state.sessions.get(id)?.info return s.sessions.get(id)?.info
}) })
const create = Effect.fn("Pty.create")(function* (input: CreateInput) { const create = Effect.fn("Pty.create")(function* (input: CreateInput) {
const state = yield* InstanceState.get(cache) const s = yield* InstanceState.get(state)
return yield* Effect.promise(async () => { return yield* Effect.promise(async () => {
const id = PtyID.ascending() const id = PtyID.ascending()
const command = input.command || Shell.preferred() const command = input.command || Shell.preferred()
@ -180,7 +180,7 @@ export namespace Pty {
args.push("-l") args.push("-l")
} }
const cwd = input.cwd || state.dir const cwd = input.cwd || s.dir
const shellEnv = await Plugin.trigger("shell.env", { cwd }, { env: {} }) const shellEnv = await Plugin.trigger("shell.env", { cwd }, { env: {} })
const env = { const env = {
...process.env, ...process.env,
@ -221,7 +221,7 @@ export namespace Pty {
cursor: 0, cursor: 0,
subscribers: new Map(), subscribers: new Map(),
} }
state.sessions.set(id, session) s.sessions.set(id, session)
proc.onData( proc.onData(
Instance.bind((chunk) => { Instance.bind((chunk) => {
session.cursor += chunk.length session.cursor += chunk.length
@ -264,8 +264,8 @@ export namespace Pty {
}) })
const update = Effect.fn("Pty.update")(function* (id: PtyID, input: UpdateInput) { const update = Effect.fn("Pty.update")(function* (id: PtyID, input: UpdateInput) {
const state = yield* InstanceState.get(cache) const s = yield* InstanceState.get(state)
const session = state.sessions.get(id) const session = s.sessions.get(id)
if (!session) return if (!session) return
if (input.title) { if (input.title) {
session.info.title = input.title session.info.title = input.title
@ -278,24 +278,24 @@ export namespace Pty {
}) })
const resize = Effect.fn("Pty.resize")(function* (id: PtyID, cols: number, rows: number) { const resize = Effect.fn("Pty.resize")(function* (id: PtyID, cols: number, rows: number) {
const state = yield* InstanceState.get(cache) const s = yield* InstanceState.get(state)
const session = state.sessions.get(id) const session = s.sessions.get(id)
if (session && session.info.status === "running") { if (session && session.info.status === "running") {
session.process.resize(cols, rows) session.process.resize(cols, rows)
} }
}) })
const write = Effect.fn("Pty.write")(function* (id: PtyID, data: string) { const write = Effect.fn("Pty.write")(function* (id: PtyID, data: string) {
const state = yield* InstanceState.get(cache) const s = yield* InstanceState.get(state)
const session = state.sessions.get(id) const session = s.sessions.get(id)
if (session && session.info.status === "running") { if (session && session.info.status === "running") {
session.process.write(data) session.process.write(data)
} }
}) })
const connect = Effect.fn("Pty.connect")(function* (id: PtyID, ws: Socket, cursor?: number) { const connect = Effect.fn("Pty.connect")(function* (id: PtyID, ws: Socket, cursor?: number) {
const state = yield* InstanceState.get(cache) const s = yield* InstanceState.get(state)
const session = state.sessions.get(id) const session = s.sessions.get(id)
if (!session) { if (!session) {
ws.close() ws.close()
return return

View file

@ -98,7 +98,7 @@ export namespace SessionPrompt {
const truncate = yield* Truncate.Service const truncate = yield* Truncate.Service
const scope = yield* Scope.Scope const scope = yield* Scope.Scope
const cache = yield* InstanceState.make( const state = yield* InstanceState.make(
Effect.fn("SessionPrompt.state")(function* () { Effect.fn("SessionPrompt.state")(function* () {
const runners = new Map<string, Runner<MessageV2.WithParts>>() const runners = new Map<string, Runner<MessageV2.WithParts>>()
yield* Effect.addFinalizer( yield* Effect.addFinalizer(
@ -132,14 +132,14 @@ export namespace SessionPrompt {
const assertNotBusy: (sessionID: SessionID) => Effect.Effect<void, Session.BusyError> = Effect.fn( const assertNotBusy: (sessionID: SessionID) => Effect.Effect<void, Session.BusyError> = Effect.fn(
"SessionPrompt.assertNotBusy", "SessionPrompt.assertNotBusy",
)(function* (sessionID: SessionID) { )(function* (sessionID: SessionID) {
const s = yield* InstanceState.get(cache) const s = yield* InstanceState.get(state)
const runner = s.runners.get(sessionID) const runner = s.runners.get(sessionID)
if (runner?.busy) throw new Session.BusyError(sessionID) if (runner?.busy) throw new Session.BusyError(sessionID)
}) })
const cancel = Effect.fn("SessionPrompt.cancel")(function* (sessionID: SessionID) { const cancel = Effect.fn("SessionPrompt.cancel")(function* (sessionID: SessionID) {
log.info("cancel", { sessionID }) log.info("cancel", { sessionID })
const s = yield* InstanceState.get(cache) const s = yield* InstanceState.get(state)
const runner = s.runners.get(sessionID) const runner = s.runners.get(sessionID)
if (!runner || !runner.busy) { if (!runner || !runner.busy) {
yield* status.set(sessionID, { type: "idle" }) yield* status.set(sessionID, { type: "idle" })
@ -1575,14 +1575,14 @@ NOTE: At any point in time through this workflow you should feel free to ask the
const loop: (input: z.infer<typeof LoopInput>) => Effect.Effect<MessageV2.WithParts> = Effect.fn( const loop: (input: z.infer<typeof LoopInput>) => Effect.Effect<MessageV2.WithParts> = Effect.fn(
"SessionPrompt.loop", "SessionPrompt.loop",
)(function* (input: z.infer<typeof LoopInput>) { )(function* (input: z.infer<typeof LoopInput>) {
const s = yield* InstanceState.get(cache) const s = yield* InstanceState.get(state)
const runner = getRunner(s.runners, input.sessionID) const runner = getRunner(s.runners, input.sessionID)
return yield* runner.ensureRunning(runLoop(input.sessionID)) return yield* runner.ensureRunning(runLoop(input.sessionID))
}) })
const shell: (input: ShellInput) => Effect.Effect<MessageV2.WithParts> = Effect.fn("SessionPrompt.shell")( const shell: (input: ShellInput) => Effect.Effect<MessageV2.WithParts> = Effect.fn("SessionPrompt.shell")(
function* (input: ShellInput) { function* (input: ShellInput) {
const s = yield* InstanceState.get(cache) const s = yield* InstanceState.get(state)
const runner = getRunner(s.runners, input.sessionID) const runner = getRunner(s.runners, input.sessionID)
return yield* runner.startShell((signal) => shellImpl(input, signal)) return yield* runner.startShell((signal) => shellImpl(input, signal))
}, },

View file

@ -57,7 +57,7 @@ export namespace ToolRegistry {
const config = yield* Config.Service const config = yield* Config.Service
const plugin = yield* Plugin.Service const plugin = yield* Plugin.Service
const cache = yield* InstanceState.make<State>( const state = yield* InstanceState.make<State>(
Effect.fn("ToolRegistry.state")(function* (ctx) { Effect.fn("ToolRegistry.state")(function* (ctx) {
const custom: Tool.Info[] = [] const custom: Tool.Info[] = []
@ -139,18 +139,18 @@ export namespace ToolRegistry {
}) })
const register = Effect.fn("ToolRegistry.register")(function* (tool: Tool.Info) { const register = Effect.fn("ToolRegistry.register")(function* (tool: Tool.Info) {
const state = yield* InstanceState.get(cache) const s = yield* InstanceState.get(state)
const idx = state.custom.findIndex((t) => t.id === tool.id) const idx = s.custom.findIndex((t) => t.id === tool.id)
if (idx >= 0) { if (idx >= 0) {
state.custom.splice(idx, 1, tool) s.custom.splice(idx, 1, tool)
return return
} }
state.custom.push(tool) s.custom.push(tool)
}) })
const ids = Effect.fn("ToolRegistry.ids")(function* () { const ids = Effect.fn("ToolRegistry.ids")(function* () {
const state = yield* InstanceState.get(cache) const s = yield* InstanceState.get(state)
const tools = yield* all(state.custom) const tools = yield* all(s.custom)
return tools.map((t) => t.id) return tools.map((t) => t.id)
}) })
@ -158,8 +158,8 @@ export namespace ToolRegistry {
model: { providerID: ProviderID; modelID: ModelID }, model: { providerID: ProviderID; modelID: ModelID },
agent?: Agent.Info, agent?: Agent.Info,
) { ) {
const state = yield* InstanceState.get(cache) const s = yield* InstanceState.get(state)
const allTools = yield* all(state.custom) const allTools = yield* all(s.custom)
const filtered = allTools.filter((tool) => { const filtered = allTools.filter((tool) => {
if (tool.id === "codesearch" || tool.id === "websearch") { if (tool.id === "codesearch" || tool.id === "websearch") {
return model.providerID === ProviderID.opencode || Flag.OPENCODE_ENABLE_EXA return model.providerID === ProviderID.opencode || Flag.OPENCODE_ENABLE_EXA