This commit is contained in:
bracesproul
2025-02-27 15:41:47 -08:00
parent c7b61071a1
commit 3f4aad48e6
14 changed files with 254 additions and 104 deletions

14
agent/find-tool-call.ts Normal file
View File

@@ -0,0 +1,14 @@
import { z, ZodTypeAny } from "zod";
interface ToolCall {
name: string;
args: Record<string, any>;
id?: string;
type?: "tool_call";
}
export function findToolCall<Name extends string>(name: Name) {
return <Args extends ZodTypeAny>(
x: ToolCall,
): x is { name: Name; args: z.infer<Args> } => x.name === name;
}