feat(core): add pinned Code Mode tools
This commit is contained in:
parent
13b6845e7e
commit
2342683aa5
9 changed files with 140 additions and 25 deletions
|
|
@ -10,14 +10,17 @@ describe("CodeMode", () => {
|
|||
Effect.gen(function* () {
|
||||
const codeMode = yield* CodeMode.Service
|
||||
yield* codeMode.register(
|
||||
Tool.registrationEntries({
|
||||
echo: Tool.make({
|
||||
description: "Echo text",
|
||||
input: Schema.Struct({ text: Schema.String }),
|
||||
output: Schema.String,
|
||||
execute: ({ text }) => Effect.succeed({ output: text }),
|
||||
}),
|
||||
}),
|
||||
Tool.registrationEntries(
|
||||
{
|
||||
echo: Tool.make({
|
||||
description: "Echo text",
|
||||
input: Schema.Struct({ text: Schema.String }),
|
||||
output: Schema.String,
|
||||
execute: ({ text }) => Effect.succeed({ output: text }),
|
||||
}),
|
||||
},
|
||||
{ pinned: true },
|
||||
),
|
||||
)
|
||||
|
||||
const materialized = yield* codeMode.materialize()
|
||||
|
|
@ -27,6 +30,46 @@ describe("CodeMode", () => {
|
|||
path: "echo",
|
||||
description: "Echo text",
|
||||
signature: "tools.echo(input: {\n text: string,\n}): Promise<string>",
|
||||
pinned: true,
|
||||
},
|
||||
])
|
||||
}).pipe(Effect.scoped, Effect.provide(AppNodeBuilder.build(CodeMode.node))),
|
||||
)
|
||||
|
||||
it.effect("omits denied pinned registrations from the catalog", () =>
|
||||
Effect.gen(function* () {
|
||||
const codeMode = yield* CodeMode.Service
|
||||
yield* codeMode.register(
|
||||
Tool.registrationEntries({
|
||||
visible: Tool.make({
|
||||
description: "Visible tool",
|
||||
input: Schema.Struct({}),
|
||||
output: Schema.String,
|
||||
execute: () => Effect.succeed({ output: "visible" }),
|
||||
}),
|
||||
}),
|
||||
)
|
||||
yield* codeMode.register(
|
||||
Tool.registrationEntries(
|
||||
{
|
||||
hidden: Tool.make({
|
||||
description: "Hidden tool",
|
||||
input: Schema.Struct({}),
|
||||
output: Schema.String,
|
||||
execute: () => Effect.succeed({ output: "hidden" }),
|
||||
}),
|
||||
},
|
||||
{ permission: "hidden", pinned: true },
|
||||
),
|
||||
)
|
||||
|
||||
const materialized = yield* codeMode.materialize([{ action: "hidden", resource: "*", effect: "deny" }])
|
||||
expect(materialized.tool).toBeDefined()
|
||||
expect(materialized.catalog).toEqual([
|
||||
{
|
||||
path: "visible",
|
||||
description: "Visible tool",
|
||||
signature: "tools.visible(input: {}): Promise<string>",
|
||||
},
|
||||
])
|
||||
}).pipe(Effect.scoped, Effect.provide(AppNodeBuilder.build(CodeMode.node))),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue