/** * Message format conversion utilities for Braintrust. * * Converts AI SDK message format (v4/v5) to OpenAI Chat Completion format, * which Braintrust requires for proper rendering of threads. */ /** * Remove null and undefined values from an object (shallow) */ export declare function removeNullish>(obj: T): Partial; /** * AI SDK content part types (both v4 and v5) */ interface AISDKTextPart { type: 'text'; text: string; } interface AISDKImagePart { type: 'image'; image?: string | Uint8Array | URL; mimeType?: string; } interface AISDKFilePart { type: 'file'; data?: string | Uint8Array | URL; filename?: string; name?: string; mimeType?: string; } interface AISDKReasoningPart { type: 'reasoning'; text?: string; } interface AISDKToolCallPart { type: 'tool-call'; toolCallId: string; toolName: string; args?: unknown; input?: unknown; } interface AISDKToolResultPart { type: 'tool-result'; toolCallId: string; result?: unknown; output?: unknown; } type AISDKContentPart = AISDKTextPart | AISDKImagePart | AISDKFilePart | AISDKReasoningPart | AISDKToolCallPart | AISDKToolResultPart | { type: string; [key: string]: unknown; }; /** * AI SDK message format (input format for conversion) */ interface AISDKMessage { role: 'user' | 'assistant' | 'system' | 'tool'; content: string | AISDKContentPart[]; [key: string]: unknown; } /** * OpenAI Chat Completion tool call format */ export interface OpenAIToolCall { id: string; type: 'function'; function: { name: string; arguments: string; }; } /** * OpenAI Chat Completion message format (output format) */ export interface OpenAIMessage { role: 'user' | 'assistant' | 'system' | 'tool'; content: string; tool_calls?: OpenAIToolCall[]; tool_call_id?: string; [key: string]: unknown; } /** * Converts AI SDK message format to OpenAI Chat Completion format for Braintrust. * * Supports both AI SDK v4 and v5 formats: * - v4 uses 'args' for tool calls and 'result' for tool results * - v5 uses 'input' for tool calls and 'output' for tool results * * AI SDK format: * { role: "user", content: [{ type: "text", text: "hello" }] } * { role: "assistant", content: [{ type: "text", text: "..." }, { type: "tool-call", toolCallId: "...", toolName: "...", args: {...} }] } * { role: "tool", content: [{ type: "tool-result", toolCallId: "...", result: {...} }] } * * OpenAI format (what Braintrust expects): * { role: "user", content: "hello" } * { role: "assistant", content: "...", tool_calls: [{ id: "...", type: "function", function: { name: "...", arguments: "..." } }] } * { role: "tool", content: "result", tool_call_id: "..." } */ export declare function convertAISDKMessage(message: AISDKMessage | OpenAIMessage | unknown): OpenAIMessage | unknown; export {}; //# sourceMappingURL=formatter.d.ts.map