UNPKG

@tanstack/ai

Version:

Core TanStack AI library - Open source AI SDK

45 lines (44 loc) 1.38 kB
import { ContentPart, UIMessage } from '../types.js'; type AGUITextInputContent = { type: 'text'; text: string; }; type AGUIInputContent = AGUITextInputContent | (ContentPart & { type: 'image' | 'audio' | 'video' | 'document'; }); type AGUIToolCallMirror = { id: string; type: 'function'; function: { name: string; arguments: string; }; }; type AGUIToolMessage = { role: 'tool'; id: string; toolCallId: string; content: string; error?: string; }; type AGUIReasoningMessage = { role: 'reasoning'; id: string; content: string; }; type WireAnchorMessage = UIMessage & { content?: string | Array<AGUIInputContent>; toolCalls?: Array<AGUIToolCallMirror>; }; export type WireMessage = WireAnchorMessage | AGUIToolMessage | AGUIReasoningMessage; /** * Serialize TanStack `UIMessage`s into the AG-UI `RunAgentInput.messages` * wire shape. Each anchor (system/user/assistant) carries the canonical * `parts` array verbatim plus AG-UI mirror fields (`content`, `toolCalls`) * so AG-UI Zod parsing succeeds. Tool results and thinking parts on * assistant messages are additionally emitted as fan-out * `{role:'tool',...}` and `{role:'reasoning',...}` entries for strict * AG-UI server consumers. */ export declare function uiMessagesToWire(messages: Array<UIMessage>): Array<WireMessage>; export {};