support custom tools (#2668)

This commit is contained in:
Dax
2025-09-18 03:58:21 -04:00
committed by GitHub
parent e9d902d844
commit 3b6c0ec0b3
12 changed files with 140 additions and 488 deletions

View File

@@ -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>