diff --git a/packages/core/src/session/generate-node.ts b/packages/core/src/session/generate-node.ts index f26e2847c2..b078d667e3 100644 --- a/packages/core/src/session/generate-node.ts +++ b/packages/core/src/session/generate-node.ts @@ -36,8 +36,8 @@ export const layer = Layer.effect( const promptCacheKey = /^ses_[0-9a-f]{64}$/.test(selection.session.id) ? selection.session.id.slice(4) : selection.session.id - const executableTools = yield* registry.materialize(selection.agent.info.permissions) - const toolDefinitions = executableTools.definitions + const toolSet = yield* registry.snapshot(selection.agent.info.permissions) + const toolDefinitions = toolSet.definitions const toolsByName = new Map(toolDefinitions.map((tool) => [tool.name, tool])) const contextEvent = yield* hooks.trigger("session", "context", { sessionID: selection.session.id, @@ -52,7 +52,10 @@ export const layer = Layer.effect( Message.user(input.prompt), ], tools: Object.fromEntries( - toolDefinitions.map((tool) => [tool.name, { description: tool.description, input: { ...tool.inputSchema } }]), + toolDefinitions.map((tool) => [ + tool.name, + { description: tool.description, input: { ...tool.inputSchema } }, + ]), ), }) const hookedTools = Object.entries(contextEvent.tools).flatMap(([name, tool]) => { diff --git a/packages/core/src/tool/glob.ts b/packages/core/src/tool/glob.ts index 27a7d26a01..adf2a8f4d8 100644 --- a/packages/core/src/tool/glob.ts +++ b/packages/core/src/tool/glob.ts @@ -25,9 +25,6 @@ export const Input = Schema.Struct({ }) export const Output = Schema.Array(FileSystem.Entry) -const StructuredOutput = Schema.Struct({ - count: NonNegativeInt, -}) type ModelOutput = typeof Output.Encoded /** Format raw search results into the concise line-oriented output models expect. */ @@ -54,8 +51,7 @@ export const Plugin = { "Find files by glob pattern within the active Location. Returns concise relative file resources. Use a relative path to narrow the search and limit to bound the result count.", input: Input, output: Output, - structured: StructuredOutput, - toStructuredOutput: ({ output }) => ({ count: output.length }), + toMetadata: ({ output }) => ({ count: output.length }), toModelOutput: ({ output }) => [ { type: "text", diff --git a/packages/core/src/tool/grep.ts b/packages/core/src/tool/grep.ts index 56cb004ddf..0c4b793dc4 100644 --- a/packages/core/src/tool/grep.ts +++ b/packages/core/src/tool/grep.ts @@ -30,9 +30,6 @@ export const Input = Schema.Struct({ }) export const Output = Schema.Array(FileSystem.Match) -const StructuredOutput = Schema.Struct({ - matches: NonNegativeInt, -}) type ModelOutput = typeof Output.Encoded /** Format raw search matches into the familiar concise model output. */ @@ -68,8 +65,7 @@ export const Plugin = { "Search file contents by regular expression within the active Location or an absolute managed tool-output file. Use a path to narrow the search, include to filter files by glob, and limit to bound the match count. Returns concise file resources, line numbers, and bounded line previews.", input: Input, output: Output, - structured: StructuredOutput, - toStructuredOutput: ({ output }) => ({ matches: output.length }), + toMetadata: ({ output }) => ({ matches: output.length }), toModelOutput: ({ output }) => [ { type: "text", diff --git a/packages/core/src/tool/skill.ts b/packages/core/src/tool/skill.ts index dcf0e8bf70..73eb1e135d 100644 --- a/packages/core/src/tool/skill.ts +++ b/packages/core/src/tool/skill.ts @@ -21,11 +21,6 @@ export const Output = Schema.Struct({ directory: Schema.String, output: Schema.String, }) -const StructuredOutput = Schema.Struct({ - name: Output.fields.name, - directory: Output.fields.directory, -}) - export const description = [ "Load a specialized skill when the task at hand matches one of the available skills in the instructions.", "", @@ -70,8 +65,7 @@ export const Plugin = { description, input: Input, output: Output, - structured: StructuredOutput, - toStructuredOutput: ({ output }) => ({ name: output.name, directory: output.directory }), + toMetadata: ({ output }) => ({ name: output.name, directory: output.directory }), toModelOutput: ({ output }) => [{ type: "text", text: output.output }], execute: (input, context) => Effect.gen(function* () { diff --git a/packages/core/src/tool/subagent.ts b/packages/core/src/tool/subagent.ts index 37cd317c12..da62da5660 100644 --- a/packages/core/src/tool/subagent.ts +++ b/packages/core/src/tool/subagent.ts @@ -31,11 +31,6 @@ export const Output = Schema.Struct({ status: Schema.Literals(["completed", "running"]), output: Schema.String, }) -const StructuredOutput = Schema.Struct({ - sessionID: Output.fields.sessionID, - status: Output.fields.status, -}) - export const description = [ "Spawn a subagent: a child session running a configured agent with fresh context.", "Foreground (default) runs the subagent to completion and returns its final response.", @@ -119,8 +114,7 @@ export const Plugin = { description, input: Input, output: Output, - structured: StructuredOutput, - toStructuredOutput: ({ output }) => ({ sessionID: output.sessionID, status: output.status }), + toMetadata: ({ output }) => ({ sessionID: output.sessionID, status: output.status }), toModelOutput: ({ output }) => [{ type: "text", text: output.output }], execute: (input, context) => Effect.gen(function* () { diff --git a/packages/core/src/tool/webfetch.ts b/packages/core/src/tool/webfetch.ts index 0ce3250995..8ab4e11122 100644 --- a/packages/core/src/tool/webfetch.ts +++ b/packages/core/src/tool/webfetch.ts @@ -37,10 +37,6 @@ const Output = Schema.Struct({ format: Input.fields.format, output: Schema.String, }) -const StructuredOutput = Schema.Struct({ - contentType: Output.fields.contentType, -}) - type Format = (typeof Input.Type)["format"] const acceptHeader = (format: Format) => { @@ -129,8 +125,7 @@ export const Plugin = { description, input: Input, output: Output, - structured: StructuredOutput, - toStructuredOutput: ({ output }) => ({ contentType: output.contentType }), + toMetadata: ({ output }) => ({ contentType: output.contentType }), toModelOutput: ({ output }) => [{ type: "text", text: output.output }], execute: (input, context) => Effect.gen(function* () { diff --git a/packages/core/src/tool/websearch.ts b/packages/core/src/tool/websearch.ts index 49b059c9df..0eb758ba67 100644 --- a/packages/core/src/tool/websearch.ts +++ b/packages/core/src/tool/websearch.ts @@ -190,10 +190,6 @@ const Output = Schema.Struct({ provider: Provider, text: Schema.String, }) -const StructuredOutput = Schema.Struct({ - provider: Output.fields.provider, -}) - export const Plugin = { id: "opencode.tool.websearch", effect: Effect.fn("WebSearchTool.Plugin")(function* (ctx: PluginContext) { @@ -209,8 +205,7 @@ export const Plugin = { description, input: Input, output: Output, - structured: StructuredOutput, - toStructuredOutput: ({ output }) => ({ provider: output.provider }), + toMetadata: ({ output }) => ({ provider: output.provider }), toModelOutput: ({ output }) => [{ type: "text", text: output.text }], execute: (input, context) => { const provider = selectProvider(context.sessionID, config, config.provider)