rework custom tools

This commit is contained in:
Dax Raad
2025-09-18 05:42:59 -04:00
parent 5f2945ae71
commit 1ffc8be2b6
5 changed files with 70 additions and 49 deletions

View File

@@ -7,14 +7,13 @@ export type ToolContext = {
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 function tool<Args extends z.ZodRawShape>(input: {
description: string
args: Args
execute(args: z.infer<z.ZodObject<Args>>, context: ToolContext): Promise<string>
}) {
return input
}
tool.schema = z
export type ToolDefinition = ReturnType<typeof tool>