/** * types.ts — Type definitions for Anthropic ↔ OpenAI format conversion. */ export interface AnthropicContentBlock { type: string; text?: string; id?: string; name?: string; input?: unknown; tool_use_id?: string; content?: string | AnthropicContentBlock[]; is_error?: boolean; source?: unknown; cache_control?: unknown; } export interface AnthropicMessage { role: string; content: string | AnthropicContentBlock[]; } export interface AnthropicRequest { model?: string; stream?: boolean; system?: string | Array<{ type: string; text?: string; }>; messages?: AnthropicMessage[]; max_tokens?: number; temperature?: number; top_p?: number; tools?: Array<{ name: string; description?: string; input_schema?: Record; }>; tool_choice?: { type: string; name?: string; }; } export interface OpenAIToolCall { id: string; type: 'function'; function: { name: string; arguments: string; }; } /** OpenAI vision content part (text or image_url). */ export type OpenAIContentPart = { type: 'text'; text: string; } | { type: 'image_url'; image_url: { url: string; }; }; export interface OpenAIMessage { role: string; content?: string | OpenAIContentPart[] | null; tool_calls?: OpenAIToolCall[]; tool_call_id?: string; name?: string; } export interface OpenAIChatCompletion { id: string; choices: Array<{ index: number; message: { role: string; content?: string | null; tool_calls?: OpenAIToolCall[]; }; finish_reason: string; }>; usage?: { prompt_tokens: number; completion_tokens: number; total_tokens: number; }; } /** A single chunk in the OpenAI streaming response */ export interface OpenAIStreamChunk { id?: string; choices?: Array<{ index: number; delta: { role?: string; content?: string; tool_calls?: Array<{ index: number; id?: string; type?: string; function?: { name?: string; arguments?: string; }; }>; }; finish_reason?: string | null; }>; usage?: { prompt_tokens?: number; completion_tokens?: number; total_tokens?: number; }; }