feat(core): add pinned Code Mode tools

This commit is contained in:
Aiden Cline 2026-07-24 16:14:15 -05:00
commit 2342683aa5
9 changed files with 140 additions and 25 deletions

View file

@ -129,6 +129,8 @@ export interface RegisterOptions {
readonly namespace?: string
/** Defaults to true. False exposes the tool directly to the provider. */
readonly codemode?: boolean
/** Keeps the complete signature visible when the Code Mode catalog is compact. */
readonly pinned?: boolean
/** Permission action used for whole-tool visibility filtering. */
readonly permission?: string
}
@ -138,6 +140,7 @@ export interface Registration {
readonly name: string
readonly namespace?: string
readonly permission: string
readonly pinned?: boolean
}
export const validateName = (name: string) =>
@ -159,6 +162,7 @@ export const registrationEntries = (
namespace: options?.namespace,
tool,
permission: options?.permission ?? key,
...(options?.pinned === true ? { pinned: true } : {}),
}
})

View file

@ -125,3 +125,16 @@ test("raw JSON schemas are render-only and omitted output means model-only", asy
})
expect(await Effect.runPromise(Tool.decodeInput(tool.input, { value: 1 }))).toEqual({ value: 1 })
})
test("registration metadata omits disabled pinning", () => {
const tool = Tool.make({
description: "Echo text",
input: Schema.Struct({ text: Schema.String }),
output: Schema.String,
execute: ({ text }) => Effect.succeed({ output: text }),
})
const registration = Tool.registrationEntries({ echo: tool })
expect(Tool.registrationEntries({ echo: tool }, { pinned: false })).toEqual(registration)
expect(Tool.registrationEntries({ echo: tool }, { pinned: true })).toEqual([{ ...registration[0], pinned: true }])
})