UNPKG

@tanstack/ai

Version:

Type-safe TypeScript AI SDK for streaming chat, tool calling, agents, structured outputs, and multimodal generation.

17 lines (16 loc) • 1 kB
import { SchemaInput } from '../../../types.js'; /** * How a failed tool input is repaired. `undefined`: the built-in repair. * `false`: no repair. A function: called instead of the built-in repair. It * returns the input to check again, or `undefined` to keep the error. */ export type ToolInputRepair = false | ((input: unknown, error: Error) => unknown | Promise<unknown>); /** * The final check of a tool input, just before the tool runs or the client * gets the call. A Standard Schema runs here (an async validator too), and * its output is the input, so transforms apply once. A JSON Schema (an MCP * tool, a plain JSON Schema tool) is checked with `@cfworker/json-schema`. * A failed input is repaired as `repair` says, then checked again. The error * of the first check goes back to the model as the tool result. */ export declare function validateToolInput(schema: SchemaInput | boolean | undefined, received: unknown, toolName: string, repair?: ToolInputRepair): Promise<unknown>;