feat(plugin): support dynamic Effect tools
This commit is contained in:
parent
5e2e0d6965
commit
7832a677fb
4 changed files with 49 additions and 1 deletions
|
|
@ -274,6 +274,42 @@ describe("PluginV2", () => {
|
|||
}),
|
||||
)
|
||||
|
||||
it.effect("registers dynamic Effect tools through the host context", () =>
|
||||
Effect.gen(function* () {
|
||||
const plugins = yield* PluginV2.Service
|
||||
const registry = yield* ToolRegistry.Service
|
||||
const plugin = EffectPlugin.define({
|
||||
id: "dynamic-tool-plugin",
|
||||
effect: (ctx) =>
|
||||
ctx.tool
|
||||
.transform((draft) =>
|
||||
draft.addDynamic(
|
||||
"dynamic_tool",
|
||||
{
|
||||
description: "Dynamic plugin tool",
|
||||
jsonSchema: {
|
||||
type: "object",
|
||||
properties: { value: { type: "string" } },
|
||||
required: ["value"],
|
||||
additionalProperties: false,
|
||||
},
|
||||
execute: (input) =>
|
||||
Effect.succeed({
|
||||
structured: input,
|
||||
content: [{ type: "text", text: "dynamic output" }],
|
||||
}),
|
||||
},
|
||||
{ codemode: false },
|
||||
),
|
||||
)
|
||||
.pipe(Effect.orDie),
|
||||
})
|
||||
|
||||
yield* plugins.activate([versioned(plugin)])
|
||||
expect((yield* registry.materialize()).definitions.map((tool) => tool.name)).toContain("dynamic_tool")
|
||||
}),
|
||||
)
|
||||
|
||||
it.effect("groups tool names and routes codemode registrations through execute", () =>
|
||||
Effect.gen(function* () {
|
||||
const plugins = yield* PluginV2.Service
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue