@amux.ai/adapter-anthropic 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/inbound/request-parser.ts","../src/inbound/response-parser.ts","../src/inbound/stream-parser.ts","../src/inbound/error-parser.ts","../src/outbound/request-builder.ts","../src/outbound/response-builder.ts","../src/outbound/stream-builder.ts","../src/adapter.ts"],"names":["parseContentPart","mapStopReason","buildContentPart","mapFinishReason"],"mappings":";;;AAOO,SAAS,aAAa,OAAA,EAAgC;AAC3D,EAAA,MAAM,GAAA,GAAM,OAAA;AAGZ,EAAA,MAAM,WAAsB,EAAC;AAC7B,EAAA,KAAA,MAAW,GAAA,IAAO,IAAI,QAAA,EAAU;AAC9B,IAAA,MAAM,MAAA,GAAS,aAAa,GAAG,CAAA;AAC/B,IAAA,QAAA,CAAS,IAAA,CAAK,GAAG,MAAM,CAAA;AAAA,EACzB;AAEA,EAAA,OAAO;AAAA,IACL,QAAA;AAAA,IACA,OAAO,GAAA,CAAI,KAAA;AAAA;AAAA,IAEX,QAAQ,GAAA,CAAI,MAAA;AAAA,IACZ,KAAA,EAAO,GAAA,CAAI,KAAA,EAAO,GAAA,CAAI,CAAC,IAAA,MAAU;AAAA,MAC/B,IAAA,EAAM,UAAA;AAAA,MACN,QAAA,EAAU;AAAA,QACR,MAAM,IAAA,CAAK,IAAA;AAAA,QACX,aAAa,IAAA,CAAK,WAAA;AAAA,QAClB,YAAY,IAAA,CAAK;AAAA;AACnB,KACF,CAAE,CAAA;AAAA,IACF,UAAA,EAAY,GAAA,CAAI,WAAA,GACZ,GAAA,CAAI,WAAA,CAAY,IAAA,KAAS,KAAA,GACvB,UAAA,GACA,GAAA,CAAI,WAAA,CAAY,IAAA,KAAS,MAAA,GACzB,MAAA,GACA,GAAA,CAAI,WAAA,CAAY,IAAA,GAChB,EAAE,IAAA,EAAM,UAAA,EAAY,QAAA,EAAU,EAAE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, ToolCall } from '@amux.ai/llm-bridge'\n\nimport type { AnthropicRequest, AnthropicMessage, AnthropicContent } from '../types'\n\n/**\n * Parse Anthropic request to IR\n */\nexport function parseRequest(request: unknown): LLMRequestIR {\n const req = request as AnthropicRequest\n\n // Parse messages - need to handle tool_use and tool_result specially\n const messages: Message[] = []\n for (const msg of req.messages) {\n const parsed = parseMessage(msg)\n messages.push(...parsed)\n }\n\n return {\n messages,\n model: req.model,\n // Set system directly in IR instead of adding to messages\n system: req.system,\n tools: req.tools?.map((tool) => ({\n type: 'function',\n function: {\n name: tool.name,\n description: tool.description,\n parameters: tool.input_schema,\n },\n })),\n toolChoice: req.tool_choice\n ? req.tool_choice.type === 'any'\n ? 'required'\n : req.tool_choice.type === 'auto'\n ? 'auto'\n : req.tool_choice.name\n ? { type: 'function', function: { name: req.tool_choice.name } }\n : undefined\n : undefined,\n stream: req.stream,\n generation: {\n maxTokens: req.max_tokens,\n temperature: req.temperature,\n topP: req.top_p,\n topK: req.top_k,\n stopSequences: req.stop_sequences,\n },\n metadata: {\n userId: req.metadata?.user_id,\n },\n raw: request,\n }\n}\n\n/**\n * Parse Anthropic message to IR messages\n * May return multiple messages if tool_result is present (each tool_result becomes a separate tool message)\n */\nfunction parseMessage(msg: AnthropicMessage): Message[] {\n if (typeof msg.content === 'string') {\n return [{\n role: msg.role,\n content: msg.content,\n }]\n }\n\n // Separate content into regular content, tool_use, and tool_result\n const contentParts: ContentPart[] = []\n const toolCalls: ToolCall[] = []\n const toolResults: Message[] = []\n\n for (const part of msg.content) {\n if (part.type === 'tool_use') {\n // Convert tool_use to OpenAI-style toolCalls\n toolCalls.push({\n id: part.id,\n type: 'function',\n function: {\n name: part.name,\n arguments: JSON.stringify(part.input),\n },\n })\n } else if (part.type === 'tool_result') {\n // Convert tool_result to tool role message\n toolResults.push({\n role: 'tool',\n content: typeof part.content === 'string' ? part.content : JSON.stringify(part.content),\n toolCallId: part.tool_use_id,\n })\n } else {\n // Regular content (text, image)\n contentParts.push(parseContentPart(part))\n }\n }\n\n const messages: Message[] = []\n\n // Create main message with content and toolCalls\n if (contentParts.length > 0 || toolCalls.length > 0) {\n const message: Message = {\n role: msg.role,\n content: contentParts.length === 1 && contentParts[0]?.type === 'text'\n ? contentParts[0].text\n : contentParts.length > 0\n ? contentParts\n : '',\n }\n\n if (toolCalls.length > 0) {\n message.toolCalls = toolCalls\n }\n\n messages.push(message)\n }\n\n // Add tool result messages\n messages.push(...toolResults)\n\n return messages\n}\n\nfunction parseContentPart(part: AnthropicContent): ContentPart {\n switch (part.type) {\n case 'text':\n return {\n type: 'text',\n text: part.text,\n }\n case 'image':\n return {\n type: 'image',\n source: part.source.data\n ? {\n type: 'base64',\n mediaType: part.source.media_type ?? 'image/jpeg',\n data: part.source.data,\n }\n : {\n type: 'url',\n url: part.source.url ?? '',\n },\n }\n default:\n return {\n type: 'text',\n text: JSON.stringify(part),\n }\n }\n}\n","import type { LLMResponseIR, Choice, Message, ContentPart, ToolCall } from '@amux.ai/llm-bridge'\n\nimport type { AnthropicResponse, AnthropicContent } from '../types'\n\n/**\n * Parse Anthropic response to IR\n */\nexport function parseResponse(response: unknown): LLMResponseIR {\n const res = response as AnthropicResponse\n\n // Parse content - separate text/image from tool_use\n const contentParts: ContentPart[] = []\n const toolCalls: ToolCall[] = []\n\n for (const part of res.content) {\n if (part.type === 'tool_use') {\n // Convert tool_use to OpenAI-style toolCalls\n toolCalls.push({\n id: part.id,\n type: 'function',\n function: {\n name: part.name,\n arguments: JSON.stringify(part.input),\n },\n })\n } else {\n contentParts.push(parseContentPart(part))\n }\n }\n\n const message: Message = {\n role: 'assistant',\n content: contentParts.length === 1 && contentParts[0]?.type === 'text'\n ? contentParts[0].text\n : contentParts.length > 0\n ? contentParts\n : '',\n }\n\n // Add toolCalls if present\n if (toolCalls.length > 0) {\n message.toolCalls = toolCalls\n }\n\n const choice: Choice = {\n index: 0,\n message,\n finishReason: mapStopReason(res.stop_reason),\n }\n\n return {\n id: res.id,\n model: res.model,\n choices: [choice],\n usage: {\n promptTokens: res.usage.input_tokens,\n completionTokens: res.usage.output_tokens,\n totalTokens: res.usage.input_tokens + res.usage.output_tokens,\n },\n raw: response,\n }\n}\n\nfunction parseContentPart(part: AnthropicContent): ContentPart {\n switch (part.type) {\n case 'text':\n return {\n type: 'text',\n text: part.text,\n }\n default:\n return {\n type: 'text',\n text: JSON.stringify(part),\n }\n }\n}\n\nfunction mapStopReason(reason: string | null): Choice['finishReason'] {\n if (!reason) return 'stop'\n\n const reasonMap: Record<string, Choice['finishReason']> = {\n 'end_turn': 'stop',\n 'max_tokens': 'length',\n 'stop_sequence': 'stop',\n 'tool_use': 'tool_calls',\n }\n\n return reasonMap[reason] ?? 'stop'\n}\n","import type { LLMStreamEvent } from '@amux.ai/llm-bridge'\n\nimport type { AnthropicStreamEvent } from '../types'\n\n/**\n * Parse Anthropic stream event to IR stream event\n */\nexport function parseStream(\n chunk: unknown\n): LLMStreamEvent | LLMStreamEvent[] | null {\n const event = chunk as AnthropicStreamEvent\n\n switch (event.type) {\n case 'message_start':\n return {\n type: 'start',\n id: event.message?.id,\n model: event.message?.model,\n raw: chunk,\n }\n\n case 'content_block_start':\n if (event.content_block?.type === 'text') {\n return {\n type: 'content',\n content: {\n type: 'content',\n delta: '',\n index: event.index,\n },\n raw: chunk,\n }\n }\n if (event.content_block?.type === 'tool_use') {\n return {\n type: 'tool_call',\n toolCall: {\n type: 'tool_call',\n id: event.content_block.id,\n name: event.content_block.name,\n index: event.index,\n },\n raw: chunk,\n }\n }\n return null\n\n case 'content_block_delta':\n if (event.delta?.type === 'text_delta' && event.delta.text !== undefined) {\n return {\n type: 'content',\n content: {\n type: 'content',\n delta: event.delta.text,\n index: event.index,\n },\n raw: chunk,\n }\n }\n if (event.delta?.type === 'input_json_delta' && event.delta.partial_json !== undefined) {\n return {\n type: 'tool_call',\n toolCall: {\n type: 'tool_call',\n arguments: event.delta.partial_json,\n index: event.index,\n },\n raw: chunk,\n }\n }\n return null\n\n case 'content_block_stop':\n return null\n\n case 'message_delta':\n if (event.delta?.stop_reason) {\n return {\n type: 'end',\n finishReason: mapStopReason(event.delta.stop_reason),\n raw: chunk,\n }\n }\n return null\n\n case 'message_stop':\n return {\n type: 'end',\n raw: chunk,\n }\n\n default:\n return null\n }\n}\n\nfunction mapStopReason(reason: string): LLMStreamEvent['finishReason'] {\n const reasonMap: Record<string, LLMStreamEvent['finishReason']> = {\n 'end_turn': 'stop',\n 'max_tokens': 'length',\n 'stop_sequence': 'stop',\n 'tool_use': 'tool_calls',\n }\n return reasonMap[reason] ?? 'stop'\n}\n","import type { LLMErrorIR, ErrorType } from '@amux.ai/llm-bridge'\n\n/**\n * Anthropic error format\n */\ninterface AnthropicError {\n type: 'error'\n error: {\n type: string\n message: string\n }\n}\n\n/**\n * Parse Anthropic error to IR\n */\nexport function parseError(error: unknown): LLMErrorIR {\n if (error && typeof error === 'object') {\n // Check for Anthropic error format\n if ('type' in error && (error as AnthropicError).type === 'error' && 'error' in error) {\n const err = (error as AnthropicError).error\n\n return {\n type: mapErrorType(err.type),\n message: err.message,\n code: err.type,\n raw: error,\n }\n }\n\n // Check for standard error format\n if ('error' in error) {\n const err = (error as { error: { type?: string; message: string } }).error\n\n return {\n type: mapErrorType(err.type),\n message: err.message,\n code: err.type,\n raw: error,\n }\n }\n }\n\n return {\n type: 'unknown',\n message: String(error),\n raw: error,\n }\n}\n\nfunction mapErrorType(type?: string): ErrorType {\n if (!type) return 'unknown'\n\n const typeMap: Record<string, ErrorType> = {\n invalid_request_error: 'validation',\n authentication_error: 'authentication',\n permission_error: 'permission',\n not_found_error: 'not_found',\n rate_limit_error: 'rate_limit',\n api_error: 'api',\n overloaded_error: 'server',\n }\n\n return typeMap[type] ?? 'unknown'\n}\n","import type { LLMRequestIR, Message, ContentPart } from '@amux.ai/llm-bridge'\n\nimport type { AnthropicRequest, AnthropicMessage, AnthropicContent } from '../types'\n\n/**\n * Build Anthropic request from IR\n */\nexport function buildRequest(ir: LLMRequestIR): AnthropicRequest {\n // Use ir.system first, then extract from messages as fallback\n let system: string | undefined = ir.system\n const messages: Message[] = []\n\n for (const msg of ir.messages) {\n if (msg.role === 'system') {\n // Fallback: extract system from messages if ir.system is not set\n if (!system) {\n system = typeof msg.content === 'string' ? msg.content : JSON.stringify(msg.content)\n }\n } else {\n messages.push(msg)\n }\n }\n\n return {\n model: ir.model ?? 'claude-3-5-sonnet-20241022',\n messages: messages.map((msg) => buildMessage(msg)),\n system,\n tools: ir.tools?.map((tool) => ({\n name: tool.function.name,\n description: tool.function.description,\n input_schema: tool.function.parameters ?? { type: 'object', properties: {} },\n })),\n tool_choice: ir.toolChoice\n ? typeof ir.toolChoice === 'string'\n ? ir.toolChoice === 'required'\n ? { type: 'any' }\n : { type: ir.toolChoice }\n : { type: 'tool', name: ir.toolChoice.function.name }\n : undefined,\n max_tokens: ir.generation?.maxTokens ?? 4096,\n temperature: ir.generation?.temperature,\n top_p: ir.generation?.topP,\n top_k: ir.generation?.topK,\n stop_sequences: ir.generation?.stopSequences,\n stream: ir.stream,\n metadata: ir.metadata?.userId\n ? {\n user_id: ir.metadata.userId as string,\n }\n : undefined,\n }\n}\n\nfunction buildMessage(msg: Message): AnthropicMessage {\n const content: AnthropicContent[] = []\n\n // Build content from message content\n if (typeof msg.content === 'string') {\n if (msg.content) {\n content.push({ type: 'text', text: msg.content })\n }\n } else if (Array.isArray(msg.content)) {\n for (const part of msg.content) {\n content.push(buildContentPart(part))\n }\n }\n\n // Handle tool role messages (tool results)\n if (msg.role === 'tool' && msg.toolCallId) {\n const resultContent = typeof msg.content === 'string' ? msg.content : JSON.stringify(msg.content)\n return {\n role: 'user',\n content: [{\n type: 'tool_result',\n tool_use_id: msg.toolCallId,\n content: resultContent,\n }],\n }\n }\n\n // Handle toolCalls (OpenAI-style) - convert to Anthropic tool_use content\n if (msg.toolCalls && msg.toolCalls.length > 0) {\n for (const toolCall of msg.toolCalls) {\n content.push({\n type: 'tool_use',\n id: toolCall.id,\n name: toolCall.function.name,\n input: JSON.parse(toolCall.function.arguments),\n })\n }\n }\n\n // If no content, add empty text to avoid empty content array\n if (content.length === 0) {\n content.push({ type: 'text', text: '' })\n }\n\n // Simplify to string if only one text content\n const firstContent = content[0]\n const simplifiedContent = content.length === 1 && firstContent?.type === 'text'\n ? firstContent.text\n : content\n\n return {\n role: msg.role === 'user' ? 'user' : 'assistant',\n content: simplifiedContent,\n }\n}\n\nfunction buildContentPart(part: ContentPart): AnthropicContent {\n switch (part.type) {\n case 'text':\n return {\n type: 'text',\n text: part.text,\n }\n case 'image':\n return {\n type: 'image',\n source:\n part.source.type === 'base64'\n ? {\n type: 'base64',\n media_type: part.source.mediaType,\n data: part.source.data,\n }\n : {\n type: 'url',\n url: part.source.url,\n },\n }\n default:\n return {\n type: 'text',\n text: JSON.stringify(part),\n }\n }\n}\n","import type { LLMResponseIR, Message, ContentPart } from '@amux.ai/llm-bridge'\n\nimport type { AnthropicResponse, AnthropicContent } from '../types'\n\n/**\n * Build Anthropic response from IR\n */\nexport function buildResponse(ir: LLMResponseIR): AnthropicResponse {\n const choice = ir.choices[0]\n if (!choice) {\n throw new Error('No choices in response')\n }\n\n // Build content\n const content: AnthropicContent[] = buildContent(choice.message)\n\n return {\n id: ir.id,\n type: 'message',\n role: 'assistant',\n content,\n model: ir.model,\n stop_reason: mapFinishReason(choice.finishReason),\n stop_sequence: null,\n usage: {\n input_tokens: ir.usage?.promptTokens ?? 0,\n output_tokens: ir.usage?.completionTokens ?? 0,\n },\n }\n}\n\nfunction buildContent(message: Message): AnthropicContent[] {\n const content: AnthropicContent[] = []\n\n // Build content from message content\n if (typeof message.content === 'string') {\n if (message.content) {\n content.push({ type: 'text', text: message.content })\n }\n } else if (Array.isArray(message.content)) {\n for (const part of message.content) {\n content.push(buildContentPart(part))\n }\n }\n\n // Convert toolCalls to tool_use content\n if (message.toolCalls && message.toolCalls.length > 0) {\n for (const toolCall of message.toolCalls) {\n content.push({\n type: 'tool_use',\n id: toolCall.id,\n name: toolCall.function.name,\n input: JSON.parse(toolCall.function.arguments),\n })\n }\n }\n\n // If no content, add empty text\n if (content.length === 0) {\n content.push({ type: 'text', text: '' })\n }\n\n return content\n}\n\nfunction buildContentPart(part: ContentPart): AnthropicContent {\n switch (part.type) {\n case 'text':\n return {\n type: 'text',\n text: part.text,\n }\n default:\n return {\n type: 'text',\n text: JSON.stringify(part),\n }\n }\n}\n\nfunction mapFinishReason(reason?: string): string {\n if (!reason) return 'end_turn'\n\n const reasonMap: Record<string, string> = {\n 'stop': 'end_turn',\n 'length': 'max_tokens',\n 'tool_calls': 'tool_use',\n }\n\n return reasonMap[reason] ?? 'end_turn'\n}\n","import type { LLMStreamEvent, SSEEvent, StreamEventBuilder } from '@amux.ai/llm-bridge'\n\n/**\n * Anthropic stream event builder\n * Converts IR stream events to Anthropic SSE format\n */\nexport function createStreamBuilder(): StreamEventBuilder {\n let hasStarted = false\n let messageId = `msg_${Date.now()}`\n let model = ''\n let contentIndex = 0\n let currentBlockType: 'text' | 'tool_use' | 'thinking' | null = null\n let outputTokens = 0\n\n return {\n process(event: LLMStreamEvent): SSEEvent[] {\n const events: SSEEvent[] = []\n\n // Helper to emit message_start if not started\n const ensureStarted = () => {\n if (!hasStarted) {\n hasStarted = true\n if (event.id) messageId = event.id\n if (event.model) model = event.model\n\n events.push({\n event: 'message_start',\n data: {\n type: 'message_start',\n message: {\n id: messageId,\n type: 'message',\n role: 'assistant',\n content: [],\n model,\n stop_reason: null,\n stop_sequence: null,\n usage: { input_tokens: 0, output_tokens: 0 },\n },\n },\n })\n }\n }\n\n // Handle start event\n if (event.type === 'start') {\n ensureStarted()\n }\n\n // Handle reasoning delta (DeepSeek reasoning / Anthropic extended thinking)\n if (event.type === 'reasoning' && event.reasoning?.delta) {\n ensureStarted()\n\n // If we need to start a thinking block\n if (currentBlockType !== 'thinking') {\n // Close previous block if exists\n if (currentBlockType !== null) {\n events.push({\n event: 'content_block_stop',\n data: { type: 'content_block_stop', index: contentIndex },\n })\n contentIndex++\n }\n\n // Start thinking block\n events.push({\n event: 'content_block_start',\n data: {\n type: 'content_block_start',\n index: contentIndex,\n content_block: { type: 'thinking', thinking: '' },\n },\n })\n currentBlockType = 'thinking'\n }\n\n events.push({\n event: 'content_block_delta',\n data: {\n type: 'content_block_delta',\n index: contentIndex,\n delta: { type: 'thinking_delta', thinking: event.reasoning.delta },\n },\n })\n }\n\n // Handle content delta\n if (event.type === 'content' && event.content?.delta) {\n ensureStarted()\n\n // If we need to start a text block (or switch from thinking/tool_use)\n if (currentBlockType !== 'text') {\n // Close previous block if exists\n if (currentBlockType !== null) {\n events.push({\n event: 'content_block_stop',\n data: { type: 'content_block_stop', index: contentIndex },\n })\n contentIndex++\n }\n\n // Start text block\n events.push({\n event: 'content_block_start',\n data: {\n type: 'content_block_start',\n index: contentIndex,\n content_block: { type: 'text', text: '' },\n },\n })\n currentBlockType = 'text'\n }\n\n events.push({\n event: 'content_block_delta',\n data: {\n type: 'content_block_delta',\n index: contentIndex,\n delta: { type: 'text_delta', text: event.content.delta },\n },\n })\n }\n\n // Handle tool call\n if (event.type === 'tool_call' && event.toolCall) {\n ensureStarted()\n\n // If starting a new tool call (has name)\n if (event.toolCall.name) {\n // Close previous block if exists\n if (currentBlockType !== null) {\n events.push({\n event: 'content_block_stop',\n data: { type: 'content_block_stop', index: contentIndex },\n })\n contentIndex++\n }\n\n // Start tool_use block\n events.push({\n event: 'content_block_start',\n data: {\n type: 'content_block_start',\n index: contentIndex,\n content_block: {\n type: 'tool_use',\n id: event.toolCall.id || `toolu_${Date.now()}`,\n name: event.toolCall.name,\n input: {},\n },\n },\n })\n currentBlockType = 'tool_use'\n }\n\n // Tool call arguments delta\n if (event.toolCall.arguments) {\n events.push({\n event: 'content_block_delta',\n data: {\n type: 'content_block_delta',\n index: contentIndex,\n delta: { type: 'input_json_delta', partial_json: event.toolCall.arguments },\n },\n })\n }\n }\n\n // Handle end event\n if (event.type === 'end') {\n // Update usage\n if (event.usage) {\n if (event.usage.completionTokens) outputTokens = event.usage.completionTokens\n }\n\n // Close current content block\n if (currentBlockType !== null) {\n events.push({\n event: 'content_block_stop',\n data: { type: 'content_block_stop', index: contentIndex },\n })\n }\n\n // Map finish reason to Anthropic stop reason\n const stopReason = mapFinishReason(event.finishReason)\n\n // Emit message_delta with stop reason\n events.push({\n event: 'message_delta',\n data: {\n type: 'message_delta',\n delta: { stop_reason: stopReason, stop_sequence: null },\n usage: { output_tokens: outputTokens },\n },\n })\n\n // Emit message_stop\n events.push({\n event: 'message_stop',\n data: { type: 'message_stop' },\n })\n }\n\n // Handle error event\n if (event.type === 'error' && event.error) {\n events.push({\n event: 'error',\n data: {\n type: 'error',\n error: {\n type: 'api_error',\n message: event.error.message,\n },\n },\n })\n }\n\n return events\n },\n }\n}\n\n/**\n * Map IR finish reason to Anthropic stop reason\n */\nfunction mapFinishReason(reason?: string): string {\n if (!reason) return 'end_turn'\n\n const reasonMap: Record<string, string> = {\n stop: 'end_turn',\n length: 'max_tokens',\n tool_calls: 'tool_use',\n content_filter: 'end_turn',\n }\n\n return reasonMap[reason] ?? 'end_turn'\n}\n","import type {\n LLMAdapter,\n LLMRequestIR,\n LLMResponseIR,\n LLMStreamEvent,\n LLMErrorIR,\n AdapterInfo,\n} from '@amux.ai/llm-bridge'\n\nimport { parseRequest } from './inbound/request-parser'\nimport { parseResponse } from './inbound/response-parser'\nimport { parseStream } from './inbound/stream-parser'\nimport { parseError } from './inbound/error-parser'\nimport { buildRequest } from './outbound/request-builder'\nimport { buildResponse } from './outbound/response-builder'\nimport { createStreamBuilder } from './outbound/stream-builder'\n\n/**\n * Anthropic adapter implementation\n * Handles Anthropic Claude API format\n */\nexport const anthropicAdapter: LLMAdapter = {\n name: 'anthropic',\n version: '1.0.0',\n capabilities: {\n streaming: true,\n tools: true,\n vision: true,\n multimodal: true,\n systemPrompt: true,\n toolChoice: true,\n reasoning: true, // Extended thinking\n webSearch: false,\n jsonMode: false, // Anthropic doesn't have native JSON mode\n logprobs: false,\n seed: false,\n },\n\n inbound: {\n parseRequest: (request: unknown): LLMRequestIR => {\n return parseRequest(request)\n },\n\n parseResponse: (response: unknown): LLMResponseIR => {\n return parseResponse(response)\n },\n\n parseStream: (chunk: unknown): LLMStreamEvent | LLMStreamEvent[] | null => {\n return parseStream(chunk)\n },\n\n parseError: (error: unknown): LLMErrorIR => {\n return parseError(error)\n },\n },\n\n outbound: {\n buildRequest: (ir: LLMRequestIR): unknown => {\n return buildRequest(ir)\n },\n\n buildResponse: (ir: LLMResponseIR): unknown => {\n return buildResponse(ir)\n },\n\n createStreamBuilder,\n },\n\n getInfo(): AdapterInfo {\n return {\n name: this.name,\n version: this.version,\n capabilities: this.capabilities,\n endpoint: {\n baseUrl: 'https://api.anthropic.com',\n chatPath: '/v1/messages',\n modelsPath: '/v1/models',\n },\n }\n },\n}\n"]}
@@ -0,0 +1,107 @@
1
+ import { LLMAdapter, JSONSchema } from '@amux.ai/llm-bridge';
2
+
3
+ /**
4
+ * Anthropic adapter implementation
5
+ * Handles Anthropic Claude API format
6
+ */
7
+ declare const anthropicAdapter: LLMAdapter;
8
+
9
+ /**
10
+ * Anthropic request format
11
+ */
12
+ interface AnthropicRequest {
13
+ model: string;
14
+ messages: AnthropicMessage[];
15
+ system?: string;
16
+ tools?: AnthropicTool[];
17
+ tool_choice?: {
18
+ type: string;
19
+ name?: string;
20
+ };
21
+ max_tokens: number;
22
+ temperature?: number;
23
+ top_p?: number;
24
+ top_k?: number;
25
+ stop_sequences?: string[];
26
+ stream?: boolean;
27
+ metadata?: {
28
+ user_id?: string;
29
+ };
30
+ }
31
+ /**
32
+ * Anthropic message format
33
+ */
34
+ interface AnthropicMessage {
35
+ role: 'user' | 'assistant';
36
+ content: string | AnthropicContent[];
37
+ }
38
+ /**
39
+ * Anthropic content types
40
+ */
41
+ type AnthropicContent = {
42
+ type: 'text';
43
+ text: string;
44
+ } | {
45
+ type: 'image';
46
+ source: {
47
+ type: string;
48
+ media_type?: string;
49
+ data?: string;
50
+ url?: string;
51
+ };
52
+ } | {
53
+ type: 'tool_use';
54
+ id: string;
55
+ name: string;
56
+ input: unknown;
57
+ } | {
58
+ type: 'tool_result';
59
+ tool_use_id: string;
60
+ content: string | unknown[];
61
+ is_error?: boolean;
62
+ };
63
+ /**
64
+ * Anthropic tool format
65
+ */
66
+ interface AnthropicTool {
67
+ name: string;
68
+ description?: string;
69
+ input_schema: JSONSchema;
70
+ }
71
+ /**
72
+ * Anthropic response format
73
+ */
74
+ interface AnthropicResponse {
75
+ id: string;
76
+ type: 'message';
77
+ role: 'assistant';
78
+ content: AnthropicContent[];
79
+ model: string;
80
+ stop_reason: string | null;
81
+ stop_sequence: string | null;
82
+ usage: {
83
+ input_tokens: number;
84
+ output_tokens: number;
85
+ };
86
+ }
87
+ /**
88
+ * Anthropic stream event
89
+ */
90
+ interface AnthropicStreamEvent {
91
+ type: string;
92
+ index?: number;
93
+ delta?: {
94
+ type?: string;
95
+ text?: string;
96
+ stop_reason?: string;
97
+ partial_json?: string;
98
+ };
99
+ content_block?: AnthropicContent;
100
+ message?: Partial<AnthropicResponse>;
101
+ usage?: {
102
+ input_tokens?: number;
103
+ output_tokens?: number;
104
+ };
105
+ }
106
+
107
+ export { type AnthropicContent, type AnthropicMessage, type AnthropicRequest, type AnthropicResponse, type AnthropicStreamEvent, type AnthropicTool, anthropicAdapter };
@@ -0,0 +1,107 @@
1
+ import { LLMAdapter, JSONSchema } from '@amux.ai/llm-bridge';
2
+
3
+ /**
4
+ * Anthropic adapter implementation
5
+ * Handles Anthropic Claude API format
6
+ */
7
+ declare const anthropicAdapter: LLMAdapter;
8
+
9
+ /**
10
+ * Anthropic request format
11
+ */
12
+ interface AnthropicRequest {
13
+ model: string;
14
+ messages: AnthropicMessage[];
15
+ system?: string;
16
+ tools?: AnthropicTool[];
17
+ tool_choice?: {
18
+ type: string;
19
+ name?: string;
20
+ };
21
+ max_tokens: number;
22
+ temperature?: number;
23
+ top_p?: number;
24
+ top_k?: number;
25
+ stop_sequences?: string[];
26
+ stream?: boolean;
27
+ metadata?: {
28
+ user_id?: string;
29
+ };
30
+ }
31
+ /**
32
+ * Anthropic message format
33
+ */
34
+ interface AnthropicMessage {
35
+ role: 'user' | 'assistant';
36
+ content: string | AnthropicContent[];
37
+ }
38
+ /**
39
+ * Anthropic content types
40
+ */
41
+ type AnthropicContent = {
42
+ type: 'text';
43
+ text: string;
44
+ } | {
45
+ type: 'image';
46
+ source: {
47
+ type: string;
48
+ media_type?: string;
49
+ data?: string;
50
+ url?: string;
51
+ };
52
+ } | {
53
+ type: 'tool_use';
54
+ id: string;
55
+ name: string;
56
+ input: unknown;
57
+ } | {
58
+ type: 'tool_result';
59
+ tool_use_id: string;
60
+ content: string | unknown[];
61
+ is_error?: boolean;
62
+ };
63
+ /**
64
+ * Anthropic tool format
65
+ */
66
+ interface AnthropicTool {
67
+ name: string;
68
+ description?: string;
69
+ input_schema: JSONSchema;
70
+ }
71
+ /**
72
+ * Anthropic response format
73
+ */
74
+ interface AnthropicResponse {
75
+ id: string;
76
+ type: 'message';
77
+ role: 'assistant';
78
+ content: AnthropicContent[];
79
+ model: string;
80
+ stop_reason: string | null;
81
+ stop_sequence: string | null;
82
+ usage: {
83
+ input_tokens: number;
84
+ output_tokens: number;
85
+ };
86
+ }
87
+ /**
88
+ * Anthropic stream event
89
+ */
90
+ interface AnthropicStreamEvent {
91
+ type: string;
92
+ index?: number;
93
+ delta?: {
94
+ type?: string;
95
+ text?: string;
96
+ stop_reason?: string;
97
+ partial_json?: string;
98
+ };
99
+ content_block?: AnthropicContent;
100
+ message?: Partial<AnthropicResponse>;
101
+ usage?: {
102
+ input_tokens?: number;
103
+ output_tokens?: number;
104
+ };
105
+ }
106
+
107
+ export { type AnthropicContent, type AnthropicMessage, type AnthropicRequest, type AnthropicResponse, type AnthropicStreamEvent, type AnthropicTool, anthropicAdapter };