UNPKG

@tanstack/ai

Version:

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

26 lines (25 loc) • 1.16 kB
import { ToolCallEndEvent } from '../types.js'; /** * Keep `raw` when it is the same JSON value as `input`. When they differ, * write `input` again and keep the raw tokens of the values that did not * change. Empty or missing raw arguments use the input. */ export declare function reconcileToolCallArguments(raw: string | undefined, input: unknown): string; /** * The input of a tool call from its raw arguments: `{}` for an empty string, * `undefined` when the arguments are not complete JSON (for example cut off) * or are `null`. */ export declare function parseToolArguments(args: string): unknown; /** * The final arguments and input of a tool call at TOOL_CALL_END. `streamed` * is the text of its TOOL_CALL_ARGS deltas. The END's raw `args` (the * provider's own string) win over it, and stay as they are when they are the * same JSON value as the END's `input`. Malformed arguments also stay, so the * tool reports the error and the model can repair them. `input` is always * the parse of `args`. */ export declare function finishToolCallArguments(streamed: string, end: ToolCallEndEvent): { args: string; input: unknown; };