|
6305 | 6305 | }, |
6306 | 6306 | { |
6307 | 6307 | "name": "handler", |
6308 | | - "type": "(args: any) => unknown", |
| 6308 | + "type": "(args: any, context: FunctionToolHandlerContext) => unknown", |
6309 | 6309 | "description": "", |
6310 | 6310 | "optional": false |
6311 | 6311 | }, |
|
6976 | 6976 | }, |
6977 | 6977 | { |
6978 | 6978 | "name": "handler", |
6979 | | - "type": "(args: StandardSchemaInferOutput<S>) => R | Promise<R>", |
| 6979 | + "type": "(args: StandardSchemaInferOutput<S>, context: FunctionToolHandlerContext) => R | Promise<R>", |
6980 | 6980 | "description": "", |
6981 | 6981 | "optional": false |
6982 | 6982 | }, |
|
6995 | 6995 | ], |
6996 | 6996 | "examples": [] |
6997 | 6997 | }, |
| 6998 | + { |
| 6999 | + "name": "FunctionToolHandlerContext", |
| 7000 | + "kind": "interface", |
| 7001 | + "description": "Runtime context passed to browser-executed function tool handlers.", |
| 7002 | + "properties": [ |
| 7003 | + { |
| 7004 | + "name": "signal", |
| 7005 | + "type": "AbortSignal", |
| 7006 | + "description": "Aborts when the client tool execution should stop without resolving.", |
| 7007 | + "optional": false |
| 7008 | + } |
| 7009 | + ], |
| 7010 | + "examples": [] |
| 7011 | + }, |
6998 | 7012 | { |
6999 | 7013 | "name": "Message", |
7000 | 7014 | "kind": "interface", |
|
8144 | 8158 | "name": "action", |
8145 | 8159 | "kind": "function", |
8146 | 8160 | "description": "Declare an async function tool the model can call; its resolved return value\nbecomes the tool result shipped back to the model.", |
8147 | | - "signature": "action(description: string, schema: S, handler: (args: StandardSchemaInferOutput<S>) => R | Promise<R>): FunctionToolDef<S, R>", |
| 8161 | + "signature": "action(description: string, schema: S, handler: (args: StandardSchemaInferOutput<S>, context: FunctionToolHandlerContext) => R | Promise<R>): FunctionToolDef<S, R>", |
8148 | 8162 | "params": [ |
8149 | 8163 | { |
8150 | 8164 | "name": "description", |
|
8160 | 8174 | }, |
8161 | 8175 | { |
8162 | 8176 | "name": "handler", |
8163 | | - "type": "(args: StandardSchemaInferOutput<S>) => R | Promise<R>", |
8164 | | - "description": "Runs in the browser when the model calls the tool; its return\n type `R` is carried on the resulting FunctionToolDef.", |
| 8177 | + "type": "(args: StandardSchemaInferOutput<S>, context: FunctionToolHandlerContext) => R | Promise<R>", |
| 8178 | + "description": "Runs in the browser when the model calls the tool. The second\n argument carries an `AbortSignal`; its return type `R` is carried on the\n resulting FunctionToolDef.", |
8165 | 8179 | "optional": false |
8166 | 8180 | } |
8167 | 8181 | ], |
|
8500 | 8514 | "name": "executeFunctionTool", |
8501 | 8515 | "kind": "function", |
8502 | 8516 | "description": "Validate args, run the handler, and normalize the outcome to a ClientToolResult.", |
8503 | | - "signature": "executeFunctionTool(def: AnyFunctionToolDef, rawArgs: unknown): Promise<ClientToolResult>", |
| 8517 | + "signature": "executeFunctionTool(def: AnyFunctionToolDef, rawArgs: unknown, context: FunctionToolHandlerContext): Promise<ClientToolResult>", |
8504 | 8518 | "params": [ |
8505 | 8519 | { |
8506 | 8520 | "name": "def", |
|
8513 | 8527 | "type": "unknown", |
8514 | 8528 | "description": "", |
8515 | 8529 | "optional": false |
| 8530 | + }, |
| 8531 | + { |
| 8532 | + "name": "context", |
| 8533 | + "type": "FunctionToolHandlerContext", |
| 8534 | + "description": "", |
| 8535 | + "optional": true |
8516 | 8536 | } |
8517 | 8537 | ], |
8518 | 8538 | "returns": { |
|
0 commit comments