diff options
| author | Dax <[email protected]> | 2025-09-18 03:58:21 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-09-18 03:58:21 -0400 |
| commit | 3b6c0ec0b3b4f2224311888d8f7be178ed2335da (patch) | |
| tree | 33d2de1a0f3860add12f1211d23b75565eba3e9e /packages/plugin/src/tool.ts | |
| parent | e9d902d84471faff3daf62455d6bc97750e4dc15 (diff) | |
| download | opencode-3b6c0ec0b3b4f2224311888d8f7be178ed2335da.tar.gz opencode-3b6c0ec0b3b4f2224311888d8f7be178ed2335da.zip | |
support custom tools (#2668)
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> |
