diff options
Diffstat (limited to 'packages/plugin/src/tool.ts')
| -rw-r--r-- | packages/plugin/src/tool.ts | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/packages/plugin/src/tool.ts b/packages/plugin/src/tool.ts new file mode 100644 index 000000000..7c1d3d7c5 --- /dev/null +++ b/packages/plugin/src/tool.ts @@ -0,0 +1,20 @@ +import { z } from "zod/v4" + +export type ToolContext = { + sessionID: string + messageID: string + agent: string + abort: AbortSignal +} + +export function tool<Args extends z.ZodRawShape>( + input: (zod: typeof z) => { + description: string + args: Args + execute: (args: z.infer<z.ZodObject<Args>>, ctx: ToolContext) => Promise<string> + }, +) { + return input(z) +} + +export type ToolDefinition = ReturnType<typeof tool> |
