@happyvertical/ai 0.102.1 → 0.102.2

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.
Files changed (64) hide show
  1. package/AGENT.md +1 -1
  2. package/README.md +123 -2
  3. package/dist/chunks/{anthropic-6ZDF32jo.js → anthropic-CxOrttgj.js} +3 -4
  4. package/dist/chunks/{anthropic-6ZDF32jo.js.map → anthropic-CxOrttgj.js.map} +1 -1
  5. package/dist/chunks/{bedrock-BQi3Z9jR.js → bedrock-B0cNEXFa.js} +3 -4
  6. package/dist/chunks/{bedrock-BQi3Z9jR.js.map → bedrock-B0cNEXFa.js.map} +1 -1
  7. package/dist/chunks/{bifrost-DsI2I4ka.js → bifrost-CyO3-hBv.js} +4 -4
  8. package/dist/chunks/{bifrost-DsI2I4ka.js.map → bifrost-CyO3-hBv.js.map} +1 -1
  9. package/dist/chunks/{byteplus-modelark-Dq8AgCQD.js → byteplus-modelark-DZ0YL2vl.js} +3 -4
  10. package/dist/chunks/{byteplus-modelark-Dq8AgCQD.js.map → byteplus-modelark-DZ0YL2vl.js.map} +1 -1
  11. package/dist/chunks/{claude-cli-DIFxvG3c.js → claude-cli-CtBp-Uk-.js} +3 -4
  12. package/dist/chunks/{claude-cli-DIFxvG3c.js.map → claude-cli-CtBp-Uk-.js.map} +1 -1
  13. package/dist/chunks/{continuation-D0NisZA1.js → continuation-7o7400bp.js} +3 -3
  14. package/dist/chunks/continuation-7o7400bp.js.map +1 -0
  15. package/dist/chunks/{gateway-audio-models-Dn7Wrc6P.js → gateway-audio-models-BSZGgjd8.js} +2 -2
  16. package/dist/chunks/{gateway-audio-models-Dn7Wrc6P.js.map → gateway-audio-models-BSZGgjd8.js.map} +1 -1
  17. package/dist/chunks/{gemini-BLFwWN90.js → gemini-DUk4ssth.js} +3 -4
  18. package/dist/chunks/{gemini-BLFwWN90.js.map → gemini-DUk4ssth.js.map} +1 -1
  19. package/dist/chunks/{huggingface-BuRwlABZ.js → huggingface-C41BZOoI.js} +3 -4
  20. package/dist/chunks/{huggingface-BuRwlABZ.js.map → huggingface-C41BZOoI.js.map} +1 -1
  21. package/dist/chunks/{litellm-CpfCT6jN.js → litellm-BLR5cs8B.js} +4 -4
  22. package/dist/chunks/{litellm-CpfCT6jN.js.map → litellm-BLR5cs8B.js.map} +1 -1
  23. package/dist/chunks/{ollama-CnrskTUg.js → ollama--y88p8Bz.js} +4 -5
  24. package/dist/chunks/{ollama-CnrskTUg.js.map → ollama--y88p8Bz.js.map} +1 -1
  25. package/dist/chunks/{openai-compat-video-CJIDdkUO.js → openai-compat-video-erarPEz-.js} +3 -4
  26. package/dist/chunks/{openai-compat-video-CJIDdkUO.js.map → openai-compat-video-erarPEz-.js.map} +1 -1
  27. package/dist/chunks/{qwen-tts-PzEkWcEb.js → qwen-tts-C9w7teY6.js} +2 -2
  28. package/dist/chunks/{qwen-tts-PzEkWcEb.js.map → qwen-tts-C9w7teY6.js.map} +1 -1
  29. package/dist/chunks/{rate-limit-BzWfHA0e.js → rate-limit-Bln_w0rH.js} +3 -280
  30. package/dist/chunks/rate-limit-Bln_w0rH.js.map +1 -0
  31. package/dist/chunks/rolldown-runtime-D7D4PA-g.js +13 -0
  32. package/dist/chunks/{seevio-D2y5Io7C.js → seevio-CosohVa0.js} +3 -4
  33. package/dist/chunks/{seevio-D2y5Io7C.js.map → seevio-CosohVa0.js.map} +1 -1
  34. package/dist/chunks/{src-CLT6r1W0.js → src-DDEz_uOe.js} +25 -30
  35. package/dist/chunks/{src-CLT6r1W0.js.map → src-DDEz_uOe.js.map} +1 -1
  36. package/dist/chunks/{typesafe-CVUqQ8N1.js → typesafe-BNM-QAJ2.js} +3 -4
  37. package/dist/chunks/{typesafe-CVUqQ8N1.js.map → typesafe-BNM-QAJ2.js.map} +1 -1
  38. package/dist/chunks/usage-BaQKo8bc.js +484 -0
  39. package/dist/chunks/usage-BaQKo8bc.js.map +1 -0
  40. package/dist/chunks/webllm-CWgY5nnP.js +584 -0
  41. package/dist/chunks/webllm-CWgY5nnP.js.map +1 -0
  42. package/dist/index.js +3 -4
  43. package/dist/local.d.ts +33 -0
  44. package/dist/local.d.ts.map +1 -0
  45. package/dist/local.js +3 -0
  46. package/dist/node.js +4 -5
  47. package/dist/node.js.map +1 -1
  48. package/dist/shared/continuation.d.ts +1 -1
  49. package/dist/shared/continuation.d.ts.map +1 -1
  50. package/dist/shared/factory.d.ts.map +1 -1
  51. package/dist/shared/providers/webllm-shim.d.ts +9 -0
  52. package/dist/shared/providers/webllm-shim.d.ts.map +1 -0
  53. package/dist/shared/providers/webllm.d.ts +115 -0
  54. package/dist/shared/providers/webllm.d.ts.map +1 -0
  55. package/dist/shared/types.d.ts +73 -2
  56. package/dist/shared/types.d.ts.map +1 -1
  57. package/metadata.json +1 -0
  58. package/package.json +15 -2
  59. package/dist/chunks/continuation-D0NisZA1.js.map +0 -1
  60. package/dist/chunks/rate-limit-BzWfHA0e.js.map +0 -1
  61. package/dist/chunks/types-DB5W6_F-.js +0 -153
  62. package/dist/chunks/types-DB5W6_F-.js.map +0 -1
  63. package/dist/chunks/usage-C1Y1Nlg4.js +0 -35
  64. package/dist/chunks/usage-C1Y1Nlg4.js.map +0 -1
package/AGENT.md CHANGED
@@ -27,6 +27,6 @@ pnpm --filter @happyvertical/ai clean
27
27
  ## Ecosystem Relationships
28
28
  - Provides: Standardized AI interface supporting chat, embeddings, media, and TypeSafe/Jev typed decisions
29
29
  - Implements: none
30
- - Requires: @happyvertical/utils, @anthropic-ai/sdk, @aws-sdk/client-bedrock-runtime, @google/genai, openai
30
+ - Requires: @happyvertical/utils, @anthropic-ai/sdk, @aws-sdk/client-bedrock-runtime, @google/genai, @mlc-ai/web-llm, openai
31
31
  - Stability: stable (Primary package surface is described as implemented and production-oriented.)
32
32
  <!-- END AGENT:GENERATED -->
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @happyvertical/ai
2
2
 
3
- Unified interface for AI model interactions across multiple providers. Supports OpenAI, LiteLLM, Bifrost, Ollama, Anthropic Claude, Google Gemini, AWS Bedrock, Hugging Face, Claude CLI, Qwen3-TTS, and video-generation providers (Gemini Veo, BytePlus ModelArk/Seedance, Seevio/Seedance 2.5, OpenAI-compatible `/v1/videos` gateways) with a consistent API for chat, completions, embeddings, streaming, function calling, image operations, asynchronous video generation, text-to-speech, and gateway admin provisioning where available.
3
+ Unified interface for AI model interactions across multiple providers. Supports OpenAI, LiteLLM, Bifrost, Ollama, Anthropic Claude, Google Gemini, AWS Bedrock, Hugging Face, Claude CLI, in-browser WebLLM (WebGPU), Qwen3-TTS, and video-generation providers (Gemini Veo, BytePlus ModelArk/Seedance, Seevio/Seedance 2.5, OpenAI-compatible `/v1/videos` gateways) with a consistent API for chat, completions, embeddings, streaming, function calling, image operations, asynchronous video generation, text-to-speech, and gateway admin provisioning where available.
4
4
 
5
5
  ## Installation
6
6
 
@@ -136,8 +136,129 @@ const typesafe = await getAI({
136
136
  apiKey: process.env.TYPESAFE_API_KEY!,
137
137
  defaultModel: 'jev-latest',
138
138
  });
139
+
140
+ // WebLLM (in-browser, WebGPU, no server or API key; see "In-Browser Chat")
141
+ const local = await getAI({ type: 'webllm', model: 'Llama-3.2-1B-Instruct-q4f16_1-MLC' });
142
+ ```
143
+
144
+ ## In-Browser Chat
145
+
146
+ `type: 'webllm'` runs a chat model entirely on the visitor's GPU through
147
+ [`@mlc-ai/web-llm`](https://github.com/mlc-ai/web-llm) (WebGPU). A static site
148
+ can use `getAI()` with no server and no API key.
149
+
150
+ ```bash
151
+ pnpm add @happyvertical/ai @mlc-ai/web-llm # web-llm is an optional peer
139
152
  ```
140
153
 
154
+ `@mlc-ai/web-llm` is imported lazily on the first request, so the root entry and
155
+ every other provider never load it. `getAI({ type: 'webllm' })` and the
156
+ `@happyvertical/ai/local` subpath reach the same provider; the subpath also
157
+ exports `WebLLMProvider`, `isWebGPUAvailable()`, `disposeWebLLMEngines()`, and the
158
+ error classes.
159
+
160
+ ### Structured output
161
+
162
+ `responseSchema` takes a JSON Schema (object or string) and maps to WebLLM's
163
+ grammar-constrained `response_format`. Decoding is masked to the schema, so a
164
+ 1-2B model cannot emit a value outside an enum:
165
+
166
+ ```typescript
167
+ import { getAI, WebGPUUnavailableError } from '@happyvertical/ai';
168
+
169
+ try {
170
+ const ai = await getAI({
171
+ type: 'webllm',
172
+ model: 'Llama-3.2-1B-Instruct-q4f16_1-MLC', // default
173
+ onLoadProgress: ({ progress, text }) => {
174
+ progressBar.value = progress; // 0..1 while the model downloads and compiles
175
+ status.textContent = text;
176
+ },
177
+ });
178
+
179
+ const controller = new AbortController(); // stop button -> controller.abort()
180
+ const reply = await ai.message('I want to run a small bakery with online orders.', {
181
+ signal: controller.signal,
182
+ temperature: 0,
183
+ history: [
184
+ {
185
+ role: 'system',
186
+ content: 'Choose the one package that fits. Reply as JSON.',
187
+ },
188
+ ],
189
+ responseSchema: {
190
+ type: 'object',
191
+ properties: {
192
+ package: { enum: ['smrt-commerce', 'smrt-content', 'smrt-events'] },
193
+ reason: { type: 'string' },
194
+ },
195
+ required: ['package', 'reason'],
196
+ },
197
+ });
198
+ const { package: chosen } = JSON.parse(reply); // always one of the three
199
+ } catch (error) {
200
+ if (error instanceof WebGPUUnavailableError) showFallback(); // no navigator.gpu
201
+ else throw error;
202
+ }
203
+ ```
204
+
205
+ `responseSchema` is honored only by providers that constrain decoding with a
206
+ grammar (today, `webllm`); other providers ignore it. It implies JSON output and
207
+ turns off `continueOnLength`. Pass `responseFormat: { type: 'json_object' }` for
208
+ unconstrained JSON mode.
209
+
210
+ ### Model lifecycle
211
+
212
+ - **Progress**: `onLoadProgress` receives `{ progress, text, timeElapsed }` while
213
+ the engine downloads and compiles the model. Loading happens before the
214
+ request timeout starts, so a multi-GB download does not eat the generation
215
+ budget.
216
+ - **Reuse**: one engine is cached per model id and shared by every provider
217
+ instance, including loads still in flight. A failed load is retried on the
218
+ next call. `disposeWebLLMEngines()` unloads them.
219
+ - **Bring your own engine**: pass `engine` (an instance, or an async factory) to
220
+ keep inference off the UI thread, for example with a Web Worker:
221
+
222
+ ```typescript
223
+ import { CreateWebWorkerMLCEngine } from '@mlc-ai/web-llm';
224
+
225
+ const ai = await getAI({
226
+ type: 'webllm',
227
+ engine: () =>
228
+ CreateWebWorkerMLCEngine(
229
+ new Worker(new URL('./llm-worker.ts', import.meta.url), { type: 'module' }),
230
+ 'Llama-3.2-1B-Instruct-q4f16_1-MLC',
231
+ ),
232
+ });
233
+ ```
234
+
235
+ A supplied engine is never loaded, cached, or unloaded by this package and the
236
+ WebGPU check is skipped; `model` is sent only when you set it.
237
+ - **Cancel**: `signal` and `timeout` call `engine.interruptGenerate()` and throw
238
+ `AIError` with code `AI_ABORTED` / `AI_TIMEOUT`. WebLLM generates one request
239
+ at a time per engine and `interruptGenerate()` stops whatever is running, so
240
+ requests to one engine are queued by this package: `timeout` and `signal`
241
+ cover the wait too, and an aborted or timed-out request never interrupts
242
+ another's generation. If something outside this package interrupts a supplied
243
+ engine mid-request, the call throws `AI_INTERRUPTED` instead of returning a
244
+ truncated reply as a normal stop.
245
+
246
+ ### Capabilities and limits
247
+
248
+ `chat`, `stream`, `complete`, `message`, tool calls (only on models WebLLM lists
249
+ for function calling, e.g. Hermes; see `getModels()` and `supportsFunctions`),
250
+ usage events through `onUsage`, and the shared request controls are supported.
251
+ `getModels()` returns WebLLM's prebuilt chat model list without network calls.
252
+ Embeddings, image embedding/description/generation, video, and TTS/voice methods
253
+ throw `AIError` with code `NOT_SUPPORTED`, and `getCapabilities()` reports them as
254
+ `false`. Without WebGPU, requests throw `WebGPUUnavailableError`
255
+ (`code: 'WEBGPU_UNAVAILABLE'`); a missing peer throws `WebLLMPeerMissingError`
256
+ (`code: 'WEBLLM_PEER_MISSING'`).
257
+
258
+ The root entry still statically imports Node-oriented providers (for example the
259
+ Gemini and Claude CLI modules), so bundling it for a browser may need those
260
+ excluded; a browser-safe root entry is tracked separately.
261
+
141
262
  ## Typed Decisions
142
263
 
143
264
  TypeSafe's optional decision provider evaluates a shared state against a batch
@@ -585,7 +706,7 @@ All providers implement `AIInterface`:
585
706
 
586
707
  ### Error Types
587
708
 
588
- All extend `AIError`: `AuthenticationError`, `RateLimitError`, `ModelNotFoundError`, `ContextLengthError`, `ContentFilterError`.
709
+ All extend `AIError`: `AuthenticationError`, `RateLimitError`, `ModelNotFoundError`, `ContextLengthError`, `ContentFilterError`, `WebGPUUnavailableError`, `WebLLMPeerMissingError`.
589
710
 
590
711
  - `AIError.retryable` distinguishes retryable failures from terminal ones
591
712
  - `RateLimitError.retryAfter` exposes provider retry hints in seconds when available
@@ -1,6 +1,5 @@
1
- import { a as ContextLengthError, l as extractTextContent, r as AuthenticationError, s as ModelNotFoundError, t as AIError } from "./types-DB5W6_F-.js";
2
- import { c as normalizeChatOptions, n as rateLimitErrorFrom, s as normalizeBaseAIOptions, u as prepareRequestControls } from "./rate-limit-BzWfHA0e.js";
3
- import { t as emitUsage } from "./usage-C1Y1Nlg4.js";
1
+ import { b as extractTextContent, f as AuthenticationError, g as ModelNotFoundError, l as prepareRequestControls, m as ContextLengthError, o as normalizeBaseAIOptions, s as normalizeChatOptions, t as emitUsage, u as AIError } from "./usage-BaQKo8bc.js";
2
+ import { n as rateLimitErrorFrom } from "./rate-limit-Bln_w0rH.js";
4
3
  import { r as parseToolArguments } from "./tool-messages-0ND35mYX.js";
5
4
  //#region src/shared/providers/anthropic.ts
6
5
  /**
@@ -605,4 +604,4 @@ function extractThinkingBlocks(content) {
605
604
  //#endregion
606
605
  export { AnthropicProvider };
607
606
 
608
- //# sourceMappingURL=anthropic-6ZDF32jo.js.map
607
+ //# sourceMappingURL=anthropic-CxOrttgj.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"anthropic-6ZDF32jo.js","names":[],"sources":["../../src/shared/providers/anthropic.ts"],"sourcesContent":["/**\n * Anthropic Claude provider implementation\n *\n * Provides a standardized interface for interacting with Anthropic's Claude models,\n * including chat completions, streaming responses, and vision capabilities.\n * Note: Claude models do not support embeddings - use OpenAI or another provider for that.\n */\n\nimport { rateLimitErrorFrom } from '../rate-limit';\nimport {\n normalizeBaseAIOptions,\n normalizeChatOptions,\n type PreparedRequestControls,\n prepareRequestControls,\n} from '../safety';\nimport { parseToolArguments } from '../tool-messages';\nimport type {\n AICapabilities,\n AIInterface,\n AIMessage,\n AIModel,\n AIResponse,\n AIThinkingBlock,\n AIToolCall,\n AnthropicOptions,\n ChatOptions,\n CompletionOptions,\n EmbeddingOptions,\n EmbeddingResponse,\n ImageDescriptionOptions,\n ImageEmbeddingOptions,\n ImageGenerationOptions,\n ImageGenerationResponse,\n MessageOptions,\n TokenUsage,\n TTSOptions,\n TTSResponse,\n VideoGenerationJob,\n VideoGenerationOptions,\n VideoGenerationResult,\n VideoGenerationStatusResult,\n Voice,\n VoiceCloneOptions,\n VoiceDesignOptions,\n VoiceListOptions,\n} from '../types';\nimport {\n AIError,\n AuthenticationError,\n ContextLengthError,\n extractTextContent,\n ModelNotFoundError,\n} from '../types';\nimport { emitUsage } from './usage';\n\ntype AnthropicContentBlock =\n | AIThinkingBlock\n | { type: 'text'; text: string }\n | {\n type: 'tool_use';\n id: string;\n name: string;\n input: Record<string, unknown>;\n }\n | { type: 'tool_result'; tool_use_id: string; content: string };\n\ninterface AnthropicMessage {\n role: 'user' | 'assistant';\n content: string | AnthropicContentBlock[];\n}\n\n// Note: This implementation will require @anthropic-ai/sdk package\n// For now, this is a placeholder that defines the interface\n\n/**\n * Anthropic Claude provider implementation that handles all interactions with Anthropic's API.\n * Supports Claude models, streaming, vision capabilities, and function calling.\n * Does not support embeddings (use OpenAI or another provider for embeddings).\n */\nexport class AnthropicProvider implements AIInterface {\n private options: AnthropicOptions;\n private client: any; // Will be Anthropic instance from @anthropic-ai/sdk\n\n /**\n * Creates a new Anthropic provider instance\n * @param options - Configuration options for the Anthropic provider\n */\n constructor(options: AnthropicOptions) {\n this.options = normalizeBaseAIOptions({\n defaultModel: 'claude-3-5-sonnet-20241022',\n anthropicVersion: '2023-06-01',\n ...options,\n });\n\n // Initialize Anthropic client\n this.initializeClientSync();\n }\n\n private initializeClientSync() {\n try {\n // Dynamic import in constructor - this will work if the package is installed\n import('@anthropic-ai/sdk')\n .then(({ Anthropic }) => {\n this.client = new Anthropic({\n apiKey: this.options.apiKey,\n baseURL: this.options.baseUrl,\n timeout: this.options.timeout,\n maxRetries: this.options.maxRetries,\n defaultHeaders: {\n 'anthropic-version': this.options.anthropicVersion,\n ...this.options.headers,\n },\n });\n })\n .catch(() => {\n // Client will be null and we'll handle it in methods\n });\n } catch (_error) {\n // Client will be null and we'll handle it in methods\n }\n }\n\n /**\n * Ensures the Anthropic client is initialized by dynamically importing the SDK\n * @throws {AIError} When the Anthropic SDK cannot be loaded\n * @private\n */\n private async ensureClient() {\n if (!this.client) {\n try {\n const { Anthropic } = await import('@anthropic-ai/sdk');\n this.client = new Anthropic({\n apiKey: this.options.apiKey,\n baseURL: this.options.baseUrl,\n timeout: this.options.timeout,\n maxRetries: this.options.maxRetries,\n defaultHeaders: {\n 'anthropic-version': this.options.anthropicVersion,\n ...this.options.headers,\n },\n });\n } catch (_error) {\n throw new AIError(\n 'Failed to initialize Anthropic client. Make sure @anthropic-ai/sdk is installed.',\n 'INITIALIZATION_ERROR',\n 'anthropic',\n );\n }\n }\n }\n\n /**\n * Generate a chat completion using Claude models\n * @param messages - Array of conversation messages\n * @param options - Optional configuration for the chat completion\n * @returns Promise resolving to the AI response with content and metadata\n * @throws {AIError} When the API request fails or SDK is not available\n *\n * @example\n * ```typescript\n * const response = await provider.chat([\n * { role: 'system', content: 'You are a helpful assistant.' },\n * { role: 'user', content: 'Explain quantum computing' }\n * ], {\n * model: 'claude-3-5-sonnet-20241022',\n * maxTokens: 1000\n * });\n * ```\n */\n async chat(\n messages: AIMessage[],\n options: ChatOptions = {},\n ): Promise<AIResponse> {\n const startTime = Date.now();\n let controls: PreparedRequestControls | undefined;\n try {\n await this.ensureClient();\n\n const { system, anthropicMessages } =\n this.mapMessagesToAnthropic(messages);\n\n const model = options.model || this.options.defaultModel;\n options = normalizeChatOptions(this.options, options, 'anthropic', model);\n controls = prepareRequestControls(this.options, options);\n\n // Build request parameters\n const requestParams: Record<string, any> = {\n model,\n messages: anthropicMessages,\n max_tokens: options.maxTokens,\n temperature: options.temperature,\n top_p: options.topP,\n stop_sequences: Array.isArray(options.stop)\n ? options.stop\n : options.stop\n ? [options.stop]\n : undefined,\n system: system || undefined,\n ...this.mapToolParams(options, anthropicMessages),\n stream: false,\n };\n const thinking = this.mapThinking(options, anthropicMessages);\n if (thinking) {\n requestParams.thinking = thinking;\n }\n\n // Add response format if specified\n if (options.responseFormat?.type === 'json_object') {\n const jsonInstruction =\n '\\n\\nIMPORTANT: You must respond with valid JSON only. Do not include any explanatory text outside the JSON object.';\n requestParams.system = requestParams.system\n ? requestParams.system + jsonInstruction\n : jsonInstruction.trim();\n }\n\n const response = await this.client.messages.create(requestParams, {\n signal: controls.signal,\n timeout: controls.timeout,\n });\n\n // Extract text content and tool calls from response\n const textContent = response.content\n .filter((block: any) => block.type === 'text')\n .map((block: any) => block.text)\n .join('');\n\n const toolCalls: AIToolCall[] = response.content\n .filter((block: any) => block.type === 'tool_use')\n .map((block: any) => ({\n id: block.id,\n type: 'function' as const,\n function: {\n name: block.name,\n arguments: JSON.stringify(block.input),\n },\n }));\n\n // Extended thinking: the replayed tool_use turn must start with these\n // blocks (signatures intact), so they ride on the first tool call.\n const thinkingBlocks = extractThinkingBlocks(response.content);\n if (toolCalls.length > 0 && thinkingBlocks.length > 0) {\n toolCalls[0].thinkingBlocks = thinkingBlocks;\n }\n\n const usage: TokenUsage = {\n promptTokens: response.usage.input_tokens,\n completionTokens: response.usage.output_tokens,\n totalTokens: response.usage.input_tokens + response.usage.output_tokens,\n };\n emitUsage(\n this.options,\n 'anthropic',\n 'chat',\n response.model || model,\n usage,\n startTime,\n options.usageTags,\n );\n\n return {\n content: textContent,\n model: response.model,\n finishReason: this.mapFinishReason(response.stop_reason),\n usage,\n toolCalls: toolCalls.length > 0 ? toolCalls : undefined,\n };\n } catch (error) {\n if (controls?.didTimeout()) {\n throw new AIError(\n `AI request timed out after ${controls.timeout}ms`,\n 'AI_TIMEOUT',\n 'anthropic',\n options.model,\n );\n }\n if (options.signal?.aborted) {\n throw new AIError(\n 'AI request aborted by caller',\n 'AI_ABORTED',\n 'anthropic',\n options.model,\n );\n }\n throw this.mapError(error);\n } finally {\n controls?.cleanup();\n }\n }\n\n async complete(\n prompt: string,\n options: CompletionOptions = {},\n ): Promise<AIResponse> {\n return this.chat([{ role: 'user', content: prompt }], {\n model: options.model,\n maxTokens: options.maxTokens,\n temperature: options.temperature,\n topP: options.topP,\n n: options.n,\n stop: options.stop,\n stream: options.stream,\n onProgress: options.onProgress,\n signal: options.signal,\n timeout: options.timeout,\n reasoning: options.reasoning,\n usageTags: options.usageTags,\n continueOnLength: options.continueOnLength,\n });\n }\n\n /**\n * Simple message interface for single-turn interactions with optional history\n *\n * @param text - The message text to send\n * @param options - Configuration options including history, model, etc.\n * @returns Promise resolving to the response content string\n *\n * @example\n * ```typescript\n * // Simple usage\n * const response = await provider.message('Hello!');\n *\n * // With history\n * const response = await provider.message('What was my question?', {\n * history: [\n * { role: 'user', content: 'What is 2+2?' },\n * { role: 'assistant', content: '4' }\n * ]\n * });\n * ```\n */\n async message(text: string, options: MessageOptions = {}): Promise<string> {\n // Build messages array from history + current message\n const messages: AIMessage[] = [\n ...(options.history || []),\n { role: options.role || 'user', content: text },\n ];\n\n const response = await this.chat(messages, {\n model: options.model,\n maxTokens: options.maxTokens,\n temperature: options.temperature,\n topP: options.topP,\n stop: options.stop,\n stream: options.stream,\n frequencyPenalty: options.frequencyPenalty,\n presencePenalty: options.presencePenalty,\n responseFormat: options.responseFormat,\n seed: options.seed,\n tools: options.tools,\n toolChoice: options.toolChoice,\n onProgress: options.onProgress,\n signal: options.signal,\n timeout: options.timeout,\n reasoning: options.reasoning,\n usageTags: options.usageTags,\n continueOnLength: options.continueOnLength,\n });\n\n return response.content;\n }\n\n async embed(\n _text: string | string[],\n _options: EmbeddingOptions = {},\n ): Promise<EmbeddingResponse> {\n // Anthropic Claude doesn't provide embeddings API\n throw new AIError(\n 'Anthropic Claude does not support embeddings. Use OpenAI or another provider for embeddings.',\n 'NOT_SUPPORTED',\n 'anthropic',\n );\n }\n\n async embedImage(\n _image: string | Buffer,\n _options: ImageEmbeddingOptions = {},\n ): Promise<EmbeddingResponse> {\n throw new AIError(\n 'Anthropic Claude does not support image embeddings. Use OpenAI or Gemini.',\n 'NOT_SUPPORTED',\n 'anthropic',\n );\n }\n\n async describeImage(\n _image: string | Buffer,\n _prompt?: string,\n _options: ImageDescriptionOptions = {},\n ): Promise<string> {\n // Note: Claude does support vision, but we're keeping this as a stub for now\n // A full implementation could use the chat API with image content\n throw new AIError(\n 'Image description is not yet implemented for Anthropic. Use OpenAI or Gemini.',\n 'NOT_IMPLEMENTED',\n 'anthropic',\n );\n }\n\n async generateImage(\n _prompt: string,\n _options: ImageGenerationOptions = {},\n ): Promise<ImageGenerationResponse> {\n throw new AIError(\n 'Anthropic Claude does not support image generation. Use OpenAI or Gemini.',\n 'NOT_SUPPORTED',\n 'anthropic',\n );\n }\n\n /**\n * Streams a chat completion as text chunks.\n *\n * Streams yield text only and never surface tool calls, so `options.tools`\n * and `options.toolChoice` are ignored: tools are declared only when the\n * replayed history contains `tool_use` blocks (Anthropic requires it), with\n * `tool_choice: { type: 'none' }`. Use `chat()` for rounds that may call\n * tools.\n */\n async *stream(\n messages: AIMessage[],\n options: ChatOptions = {},\n ): AsyncIterable<string> {\n const startTime = Date.now();\n let controls: PreparedRequestControls | undefined;\n try {\n await this.ensureClient();\n\n const { system, anthropicMessages } =\n this.mapMessagesToAnthropic(messages);\n\n const model = options.model || this.options.defaultModel;\n options = normalizeChatOptions(this.options, options, 'anthropic', model);\n controls = prepareRequestControls(this.options, options);\n\n const requestParams: Record<string, any> = {\n model,\n messages: anthropicMessages,\n max_tokens: options.maxTokens,\n temperature: options.temperature,\n top_p: options.topP,\n stop_sequences: Array.isArray(options.stop)\n ? options.stop\n : options.stop\n ? [options.stop]\n : undefined,\n system: system || undefined,\n // stream() yields text only, so a tool call would be lost: declare\n // tools only when the replayed history requires it, with\n // tool_choice none.\n ...this.mapHistoryToolParams(anthropicMessages),\n stream: true,\n };\n const thinking = this.mapThinking(options, anthropicMessages);\n if (thinking) {\n requestParams.thinking = thinking;\n }\n const stream = await this.client.messages.create(requestParams, {\n signal: controls.signal,\n timeout: controls.timeout,\n });\n\n let streamStopReason: string | null = null;\n for await (const chunk of stream) {\n if (chunk.type === 'message_delta' && chunk.delta?.stop_reason) {\n streamStopReason = chunk.delta.stop_reason;\n }\n if (\n chunk.type === 'content_block_delta' &&\n chunk.delta.type === 'text_delta'\n ) {\n if (options.onProgress) {\n options.onProgress(chunk.delta.text);\n }\n yield chunk.delta.text;\n }\n }\n options.onFinishReason?.(\n this.mapFinishReason(streamStopReason) ?? 'stop',\n );\n\n emitUsage(\n this.options,\n 'anthropic',\n 'stream',\n model!,\n undefined,\n startTime,\n options.usageTags,\n );\n } catch (error) {\n if (controls?.didTimeout()) {\n throw new AIError(\n `AI request timed out after ${controls.timeout}ms`,\n 'AI_TIMEOUT',\n 'anthropic',\n options.model,\n );\n }\n if (options.signal?.aborted) {\n throw new AIError(\n 'AI request aborted by caller',\n 'AI_ABORTED',\n 'anthropic',\n options.model,\n );\n }\n throw this.mapError(error);\n } finally {\n controls?.cleanup();\n }\n }\n\n async countTokens(text: string): Promise<number> {\n // Anthropic doesn't provide a direct token counting API\n // This is an approximation - Claude uses a different tokenizer than OpenAI\n return Math.ceil(text.length / 3.5); // Slightly different ratio for Claude\n }\n\n async getModels(): Promise<AIModel[]> {\n // Return static list of known Claude models\n return [\n {\n id: 'claude-3-5-sonnet-20241022',\n name: 'Claude 3.5 Sonnet',\n description: 'Most intelligent Claude model with balanced performance',\n contextLength: 200000,\n capabilities: ['text', 'chat', 'vision', 'functions'],\n supportsFunctions: true,\n supportsVision: true,\n },\n {\n id: 'claude-3-5-haiku-20241022',\n name: 'Claude 3.5 Haiku',\n description: 'Fastest Claude model for simple tasks',\n contextLength: 200000,\n capabilities: ['text', 'chat', 'vision'],\n supportsFunctions: true,\n supportsVision: true,\n },\n {\n id: 'claude-3-opus-20240229',\n name: 'Claude 3 Opus',\n description: 'Most powerful Claude model for complex tasks',\n contextLength: 200000,\n capabilities: ['text', 'chat', 'vision', 'functions'],\n supportsFunctions: true,\n supportsVision: true,\n },\n {\n id: 'claude-3-sonnet-20240229',\n name: 'Claude 3 Sonnet',\n description: 'Balanced Claude model for most tasks',\n contextLength: 200000,\n capabilities: ['text', 'chat', 'vision'],\n supportsFunctions: true,\n supportsVision: true,\n },\n {\n id: 'claude-3-haiku-20240307',\n name: 'Claude 3 Haiku',\n description: 'Fast Claude model for simple tasks',\n contextLength: 200000,\n capabilities: ['text', 'chat', 'vision'],\n supportsFunctions: false,\n supportsVision: true,\n },\n ];\n }\n\n async getCapabilities(): Promise<AICapabilities> {\n return {\n chat: true,\n completion: true,\n embeddings: false, // Claude doesn't support embeddings\n streaming: true,\n functions: true,\n vision: true,\n fineTuning: false,\n imageEmbeddings: false,\n imageGeneration: false,\n videoGeneration: false,\n tts: false,\n voiceCloning: false,\n voiceDesign: false,\n maxContextLength: 200000,\n supportedOperations: [\n 'chat',\n 'completion',\n 'streaming',\n 'functions',\n 'vision',\n ],\n };\n }\n\n // ============================================================================\n // Video Generation Methods (Not supported - use gemini, byteplus-modelark,\n // or openai-compat-video provider)\n // ============================================================================\n\n async submitVideoGenerationJob(\n _options: VideoGenerationOptions,\n ): Promise<VideoGenerationJob> {\n throw new AIError(\n 'Video generation is not supported by Anthropic provider. Use gemini, byteplus-modelark, or openai-compat-video provider.',\n 'NOT_IMPLEMENTED',\n 'anthropic',\n );\n }\n\n async getVideoGenerationJob(\n _handle: VideoGenerationJob,\n ): Promise<VideoGenerationStatusResult> {\n throw new AIError(\n 'Video generation is not supported by Anthropic provider. Use gemini, byteplus-modelark, or openai-compat-video provider.',\n 'NOT_IMPLEMENTED',\n 'anthropic',\n );\n }\n\n async fetchVideoGenerationResult(\n _handle: VideoGenerationJob,\n ): Promise<VideoGenerationResult> {\n throw new AIError(\n 'Video generation is not supported by Anthropic provider. Use gemini, byteplus-modelark, or openai-compat-video provider.',\n 'NOT_IMPLEMENTED',\n 'anthropic',\n );\n }\n\n async cancelVideoGenerationJob(_handle: VideoGenerationJob): Promise<void> {\n throw new AIError(\n 'Video generation is not supported by Anthropic provider. Use gemini, byteplus-modelark, or openai-compat-video provider.',\n 'NOT_IMPLEMENTED',\n 'anthropic',\n );\n }\n\n async validateVideoGenerationAccess(): Promise<boolean> {\n throw new AIError(\n 'Video generation is not supported by Anthropic provider. Use gemini, byteplus-modelark, or openai-compat-video provider.',\n 'NOT_IMPLEMENTED',\n 'anthropic',\n );\n }\n\n // ============================================================================\n // TTS Methods (Not supported - use Qwen3-TTS provider)\n // ============================================================================\n\n async synthesizeSpeech(\n _text: string,\n _options?: TTSOptions,\n ): Promise<TTSResponse> {\n throw new AIError(\n 'TTS is not supported by Anthropic provider. Use Qwen3-TTS provider.',\n 'NOT_IMPLEMENTED',\n 'anthropic',\n );\n }\n\n streamSpeech(_text: string, _options?: TTSOptions): AsyncIterable<Buffer> {\n const error = new AIError(\n 'TTS streaming is not supported by Anthropic provider. Use Qwen3-TTS provider.',\n 'NOT_IMPLEMENTED',\n 'anthropic',\n );\n return {\n [Symbol.asyncIterator]: () => ({\n next: () => Promise.reject(error),\n }),\n };\n }\n\n async cloneVoice(_options: VoiceCloneOptions): Promise<Voice> {\n throw new AIError(\n 'Voice cloning is not supported by Anthropic provider. Use Qwen3-TTS provider.',\n 'NOT_IMPLEMENTED',\n 'anthropic',\n );\n }\n\n async designVoice(_options: VoiceDesignOptions): Promise<Voice> {\n throw new AIError(\n 'Voice design is not supported by Anthropic provider. Use Qwen3-TTS provider.',\n 'NOT_IMPLEMENTED',\n 'anthropic',\n );\n }\n\n async getVoices(_options?: VoiceListOptions): Promise<Voice[]> {\n throw new AIError(\n 'Voice listing is not supported by Anthropic provider. Use Qwen3-TTS provider.',\n 'NOT_IMPLEMENTED',\n 'anthropic',\n );\n }\n\n /**\n * Maps internal messages to Anthropic Messages API turns.\n *\n * Assistant `tool_calls` become `tool_use` blocks and `role: 'tool'`\n * results become `tool_result` blocks paired by `tool_call_id`\n * (`tool_use_id`). Consecutive tool results are grouped into one user turn,\n * as Anthropic requires every result for a turn to follow it directly.\n * Only answered calls are replayed as `tool_use`, and only results whose\n * `tool_call_id` matches a replayed call become `tool_result`. A result\n * without `tool_call_id`, or one answering no replayed call, falls back to\n * plain text (and a call left unanswered keeps only its text).\n */\n private mapMessagesToAnthropic(messages: AIMessage[]): {\n system?: string;\n anthropicMessages: AnthropicMessage[];\n } {\n // Anthropic handles system messages separately\n let system: string | undefined;\n const anthropicMessages: AnthropicMessage[] = [];\n const answeredToolCallIds = new Set(\n messages\n .filter((message) => message.role === 'tool' && message.tool_call_id)\n .map((message) => message.tool_call_id as string),\n );\n // Calls replayed as tool_use: those with an answer. Only results for\n // these ids become tool_result blocks; any other result is an orphan\n // Anthropic would reject, so it falls back to plain text.\n const replayedToolUseIds = new Set<string>();\n for (const message of messages) {\n if (message.role !== 'assistant') continue;\n for (const toolCall of message.tool_calls || []) {\n if (answeredToolCallIds.has(toolCall.id)) {\n replayedToolUseIds.add(toolCall.id);\n }\n }\n }\n\n for (const message of messages) {\n const textContent = extractTextContent(message.content);\n if (message.role === 'system') {\n // Combine multiple system messages\n system = system ? `${system}\\n\\n${textContent}` : textContent;\n continue;\n }\n\n if (\n message.role === 'tool' &&\n message.tool_call_id &&\n replayedToolUseIds.has(message.tool_call_id)\n ) {\n const block: AnthropicContentBlock = {\n type: 'tool_result',\n tool_use_id: message.tool_call_id,\n content: textContent,\n };\n const previous = anthropicMessages[anthropicMessages.length - 1];\n if (\n previous?.role === 'user' &&\n Array.isArray(previous.content) &&\n previous.content.every((part) => part.type === 'tool_result')\n ) {\n previous.content.push(block);\n } else {\n anthropicMessages.push({ role: 'user', content: [block] });\n }\n continue;\n }\n\n const toolCalls =\n message.role === 'assistant'\n ? (message.tool_calls || []).filter((toolCall) =>\n answeredToolCallIds.has(toolCall.id),\n )\n : [];\n if (toolCalls.length > 0) {\n const content: AnthropicContentBlock[] = [];\n for (const toolCall of toolCalls) {\n for (const block of toolCall.thinkingBlocks || []) {\n content.push({ ...block });\n }\n }\n if (textContent) {\n content.push({ type: 'text', text: textContent });\n }\n for (const toolCall of toolCalls) {\n content.push({\n type: 'tool_use',\n id: toolCall.id,\n name: toolCall.function.name,\n input: parseToolArguments(toolCall.function.arguments),\n });\n }\n anthropicMessages.push({ role: 'assistant', content });\n continue;\n }\n\n anthropicMessages.push({\n role: message.role === 'assistant' ? 'assistant' : 'user',\n content: textContent,\n });\n }\n\n return { system, anthropicMessages };\n }\n\n /**\n * Builds the `tools` / `tool_choice` request fields.\n *\n * Anthropic rejects a request whose history contains `tool_use` or\n * `tool_result` blocks unless `tools` is declared. A tool loop's final,\n * tool-less round (no `tools`, typically `toolChoice: 'none'`) still\n * replays that history, so when the caller declares no tools but the\n * history uses some, this declares a minimal definition for each tool the\n * history references and sets `tool_choice: { type: 'none' }` so the model\n * answers in text instead of calling them.\n */\n private mapToolParams(\n options: ChatOptions,\n anthropicMessages: AnthropicMessage[],\n ): { tools?: Record<string, any>[]; tool_choice?: Record<string, any> } {\n const tools = this.mapTools(options);\n if (tools) {\n return { tools, tool_choice: this.mapToolChoice(options.toolChoice) };\n }\n return this.mapHistoryToolParams(anthropicMessages);\n }\n\n /**\n * Declares a minimal definition for each tool the replayed history\n * references, with `tool_choice: { type: 'none' }`, or nothing when the\n * history has no `tool_use` blocks. Used for tool-less rounds and for\n * every stream (streams never yield tool calls).\n */\n private mapHistoryToolParams(anthropicMessages: AnthropicMessage[]): {\n tools?: Record<string, any>[];\n tool_choice?: Record<string, any>;\n } {\n // mapMessagesToAnthropic emits tool_result only for ids it replayed as\n // tool_use (orphan results become text), so tool_use names cover every\n // tool the history references.\n const historyToolNames = new Set<string>();\n for (const message of anthropicMessages) {\n if (!Array.isArray(message.content)) continue;\n for (const block of message.content) {\n if (block.type === 'tool_use') historyToolNames.add(block.name);\n }\n }\n if (historyToolNames.size === 0) {\n return {};\n }\n\n return {\n tools: [...historyToolNames].map((name) => ({\n name,\n description:\n 'Used earlier in this conversation; not available for this turn.',\n input_schema: { type: 'object' },\n })),\n tool_choice: { type: 'none' },\n };\n }\n\n /**\n * Builds the `thinking` request field for `options.reasoning.maxTokens`.\n *\n * While thinking is enabled, Anthropic requires the assistant turn of an\n * in-progress tool loop (the last assistant turn, when it holds `tool_use`)\n * to start with its thinking blocks. They are replayed from\n * `AIToolCall.thinkingBlocks`; when that turn has none (the history came\n * from another provider, a store that dropped the field, or a call made\n * without thinking), thinking is left off for this request rather than\n * sending a request Anthropic would reject.\n */\n private mapThinking(\n options: ChatOptions,\n anthropicMessages: AnthropicMessage[],\n ): { type: 'enabled'; budget_tokens: number } | undefined {\n const budget = options.reasoning?.maxTokens || 0;\n if (budget <= 0) return undefined;\n\n const lastAssistant = [...anthropicMessages]\n .reverse()\n .find((message) => message.role === 'assistant');\n if (\n lastAssistant &&\n Array.isArray(lastAssistant.content) &&\n lastAssistant.content.some((block) => block.type === 'tool_use')\n ) {\n const firstType = lastAssistant.content[0]?.type;\n if (firstType !== 'thinking' && firstType !== 'redacted_thinking') {\n return undefined;\n }\n }\n\n return { type: 'enabled', budget_tokens: budget };\n }\n\n private mapTools(options: ChatOptions): Record<string, any>[] | undefined {\n return options.tools && options.tools.length > 0\n ? options.tools.map((tool) => ({\n name: tool.function.name,\n description: tool.function.description || '',\n input_schema: tool.function.parameters || { type: 'object' },\n }))\n : undefined;\n }\n\n private mapToolChoice(\n toolChoice?:\n | 'auto'\n | 'none'\n | { type: 'function'; function: { name: string } },\n ): any {\n if (!toolChoice || toolChoice === 'auto') {\n return { type: 'auto' };\n }\n\n if (toolChoice === 'none') {\n return { type: 'none' };\n }\n\n if (typeof toolChoice === 'object' && toolChoice.type === 'function') {\n return {\n type: 'tool',\n name: toolChoice.function.name,\n };\n }\n\n return { type: 'auto' };\n }\n\n private mapFinishReason(reason: string | null): AIResponse['finishReason'] {\n switch (reason) {\n case 'end_turn':\n return 'stop';\n case 'max_tokens':\n return 'length';\n case 'stop_sequence':\n return 'stop';\n case 'tool_use':\n return 'tool_calls';\n default:\n return 'stop';\n }\n }\n\n private mapError(error: unknown): AIError {\n if (error instanceof AIError) {\n return error;\n }\n\n // Map common HTTP status codes from Anthropic API\n if (typeof error === 'object' && error !== null && 'status' in error) {\n const apiError = error as { status: number; message?: string };\n switch (apiError.status) {\n case 401:\n return new AuthenticationError('anthropic');\n case 429:\n return rateLimitErrorFrom('anthropic', error);\n case 404:\n return new ModelNotFoundError(\n apiError.message || 'Model not found',\n 'anthropic',\n );\n case 413:\n return new ContextLengthError('anthropic');\n }\n }\n\n const errorMessage =\n error instanceof Error\n ? error.message\n : 'Unknown Anthropic error occurred';\n return new AIError(errorMessage, 'UNKNOWN_ERROR', 'anthropic');\n }\n}\n\n/**\n * Thinking and redacted-thinking blocks from an Anthropic response, copied\n * with only the fields the API accepts back.\n */\nfunction extractThinkingBlocks(content: any[]): AIThinkingBlock[] {\n const blocks: AIThinkingBlock[] = [];\n for (const block of content || []) {\n if (block?.type === 'thinking') {\n blocks.push({\n type: 'thinking',\n thinking: block.thinking,\n signature: block.signature,\n });\n } else if (block?.type === 'redacted_thinking') {\n blocks.push({ type: 'redacted_thinking', data: block.data });\n }\n }\n return blocks;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA+EA,IAAa,oBAAb,MAAsD;CACpD;CACA;;;;;CAMA,YAAY,SAA2B;EACrC,KAAK,UAAU,uBAAuB;GACpC,cAAc;GACd,kBAAkB;GAClB,GAAG;EACL,CAAC;EAGD,KAAK,qBAAqB;CAC5B;CAEA,uBAA+B;EAC7B,IAAI;GAEF,OAAO,oBAAoB,CACxB,MAAM,EAAE,gBAAgB;IACv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AC9B,IAAI,OAAO,SAAS,YAClB,OAAO,KAAK;EACV,MAAM;EACN,UAAU,MAAM;EAChB,WAAW,MAAM;CACnB,CAAC;MACI,IAAI,OAAO,SAAS,qBACzB,OAAO,KAAK;EAAE,MAAM;EAAqB,MAAM,MAAM;CAAK,CAAC;CAG/D,OAAO;AACT"}
1
+ {"version":3,"file":"anthropic-CxOrttgj.js","names":[],"sources":["../../src/shared/providers/anthropic.ts"],"sourcesContent":["/**\n * Anthropic Claude provider implementation\n *\n * Provides a standardized interface for interacting with Anthropic's Claude models,\n * including chat completions, streaming responses, and vision capabilities.\n * Note: Claude models do not support embeddings - use OpenAI or another provider for that.\n */\n\nimport { rateLimitErrorFrom } from '../rate-limit';\nimport {\n normalizeBaseAIOptions,\n normalizeChatOptions,\n type PreparedRequestControls,\n prepareRequestControls,\n} from '../safety';\nimport { parseToolArguments } from '../tool-messages';\nimport type {\n AICapabilities,\n AIInterface,\n AIMessage,\n AIModel,\n AIResponse,\n AIThinkingBlock,\n AIToolCall,\n AnthropicOptions,\n ChatOptions,\n CompletionOptions,\n EmbeddingOptions,\n EmbeddingResponse,\n ImageDescriptionOptions,\n ImageEmbeddingOptions,\n ImageGenerationOptions,\n ImageGenerationResponse,\n MessageOptions,\n TokenUsage,\n TTSOptions,\n TTSResponse,\n VideoGenerationJob,\n VideoGenerationOptions,\n VideoGenerationResult,\n VideoGenerationStatusResult,\n Voice,\n VoiceCloneOptions,\n VoiceDesignOptions,\n VoiceListOptions,\n} from '../types';\nimport {\n AIError,\n AuthenticationError,\n ContextLengthError,\n extractTextContent,\n ModelNotFoundError,\n} from '../types';\nimport { emitUsage } from './usage';\n\ntype AnthropicContentBlock =\n | AIThinkingBlock\n | { type: 'text'; text: string }\n | {\n type: 'tool_use';\n id: string;\n name: string;\n input: Record<string, unknown>;\n }\n | { type: 'tool_result'; tool_use_id: string; content: string };\n\ninterface AnthropicMessage {\n role: 'user' | 'assistant';\n content: string | AnthropicContentBlock[];\n}\n\n// Note: This implementation will require @anthropic-ai/sdk package\n// For now, this is a placeholder that defines the interface\n\n/**\n * Anthropic Claude provider implementation that handles all interactions with Anthropic's API.\n * Supports Claude models, streaming, vision capabilities, and function calling.\n * Does not support embeddings (use OpenAI or another provider for embeddings).\n */\nexport class AnthropicProvider implements AIInterface {\n private options: AnthropicOptions;\n private client: any; // Will be Anthropic instance from @anthropic-ai/sdk\n\n /**\n * Creates a new Anthropic provider instance\n * @param options - Configuration options for the Anthropic provider\n */\n constructor(options: AnthropicOptions) {\n this.options = normalizeBaseAIOptions({\n defaultModel: 'claude-3-5-sonnet-20241022',\n anthropicVersion: '2023-06-01',\n ...options,\n });\n\n // Initialize Anthropic client\n this.initializeClientSync();\n }\n\n private initializeClientSync() {\n try {\n // Dynamic import in constructor - this will work if the package is installed\n import('@anthropic-ai/sdk')\n .then(({ Anthropic }) => {\n this.client = new Anthropic({\n apiKey: this.options.apiKey,\n baseURL: this.options.baseUrl,\n timeout: this.options.timeout,\n maxRetries: this.options.maxRetries,\n defaultHeaders: {\n 'anthropic-version': this.options.anthropicVersion,\n ...this.options.headers,\n },\n });\n })\n .catch(() => {\n // Client will be null and we'll handle it in methods\n });\n } catch (_error) {\n // Client will be null and we'll handle it in methods\n }\n }\n\n /**\n * Ensures the Anthropic client is initialized by dynamically importing the SDK\n * @throws {AIError} When the Anthropic SDK cannot be loaded\n * @private\n */\n private async ensureClient() {\n if (!this.client) {\n try {\n const { Anthropic } = await import('@anthropic-ai/sdk');\n this.client = new Anthropic({\n apiKey: this.options.apiKey,\n baseURL: this.options.baseUrl,\n timeout: this.options.timeout,\n maxRetries: this.options.maxRetries,\n defaultHeaders: {\n 'anthropic-version': this.options.anthropicVersion,\n ...this.options.headers,\n },\n });\n } catch (_error) {\n throw new AIError(\n 'Failed to initialize Anthropic client. Make sure @anthropic-ai/sdk is installed.',\n 'INITIALIZATION_ERROR',\n 'anthropic',\n );\n }\n }\n }\n\n /**\n * Generate a chat completion using Claude models\n * @param messages - Array of conversation messages\n * @param options - Optional configuration for the chat completion\n * @returns Promise resolving to the AI response with content and metadata\n * @throws {AIError} When the API request fails or SDK is not available\n *\n * @example\n * ```typescript\n * const response = await provider.chat([\n * { role: 'system', content: 'You are a helpful assistant.' },\n * { role: 'user', content: 'Explain quantum computing' }\n * ], {\n * model: 'claude-3-5-sonnet-20241022',\n * maxTokens: 1000\n * });\n * ```\n */\n async chat(\n messages: AIMessage[],\n options: ChatOptions = {},\n ): Promise<AIResponse> {\n const startTime = Date.now();\n let controls: PreparedRequestControls | undefined;\n try {\n await this.ensureClient();\n\n const { system, anthropicMessages } =\n this.mapMessagesToAnthropic(messages);\n\n const model = options.model || this.options.defaultModel;\n options = normalizeChatOptions(this.options, options, 'anthropic', model);\n controls = prepareRequestControls(this.options, options);\n\n // Build request parameters\n const requestParams: Record<string, any> = {\n model,\n messages: anthropicMessages,\n max_tokens: options.maxTokens,\n temperature: options.temperature,\n top_p: options.topP,\n stop_sequences: Array.isArray(options.stop)\n ? options.stop\n : options.stop\n ? [options.stop]\n : undefined,\n system: system || undefined,\n ...this.mapToolParams(options, anthropicMessages),\n stream: false,\n };\n const thinking = this.mapThinking(options, anthropicMessages);\n if (thinking) {\n requestParams.thinking = thinking;\n }\n\n // Add response format if specified\n if (options.responseFormat?.type === 'json_object') {\n const jsonInstruction =\n '\\n\\nIMPORTANT: You must respond with valid JSON only. Do not include any explanatory text outside the JSON object.';\n requestParams.system = requestParams.system\n ? requestParams.system + jsonInstruction\n : jsonInstruction.trim();\n }\n\n const response = await this.client.messages.create(requestParams, {\n signal: controls.signal,\n timeout: controls.timeout,\n });\n\n // Extract text content and tool calls from response\n const textContent = response.content\n .filter((block: any) => block.type === 'text')\n .map((block: any) => block.text)\n .join('');\n\n const toolCalls: AIToolCall[] = response.content\n .filter((block: any) => block.type === 'tool_use')\n .map((block: any) => ({\n id: block.id,\n type: 'function' as const,\n function: {\n name: block.name,\n arguments: JSON.stringify(block.input),\n },\n }));\n\n // Extended thinking: the replayed tool_use turn must start with these\n // blocks (signatures intact), so they ride on the first tool call.\n const thinkingBlocks = extractThinkingBlocks(response.content);\n if (toolCalls.length > 0 && thinkingBlocks.length > 0) {\n toolCalls[0].thinkingBlocks = thinkingBlocks;\n }\n\n const usage: TokenUsage = {\n promptTokens: response.usage.input_tokens,\n completionTokens: response.usage.output_tokens,\n totalTokens: response.usage.input_tokens + response.usage.output_tokens,\n };\n emitUsage(\n this.options,\n 'anthropic',\n 'chat',\n response.model || model,\n usage,\n startTime,\n options.usageTags,\n );\n\n return {\n content: textContent,\n model: response.model,\n finishReason: this.mapFinishReason(response.stop_reason),\n usage,\n toolCalls: toolCalls.length > 0 ? toolCalls : undefined,\n };\n } catch (error) {\n if (controls?.didTimeout()) {\n throw new AIError(\n `AI request timed out after ${controls.timeout}ms`,\n 'AI_TIMEOUT',\n 'anthropic',\n options.model,\n );\n }\n if (options.signal?.aborted) {\n throw new AIError(\n 'AI request aborted by caller',\n 'AI_ABORTED',\n 'anthropic',\n options.model,\n );\n }\n throw this.mapError(error);\n } finally {\n controls?.cleanup();\n }\n }\n\n async complete(\n prompt: string,\n options: CompletionOptions = {},\n ): Promise<AIResponse> {\n return this.chat([{ role: 'user', content: prompt }], {\n model: options.model,\n maxTokens: options.maxTokens,\n temperature: options.temperature,\n topP: options.topP,\n n: options.n,\n stop: options.stop,\n stream: options.stream,\n onProgress: options.onProgress,\n signal: options.signal,\n timeout: options.timeout,\n reasoning: options.reasoning,\n usageTags: options.usageTags,\n continueOnLength: options.continueOnLength,\n });\n }\n\n /**\n * Simple message interface for single-turn interactions with optional history\n *\n * @param text - The message text to send\n * @param options - Configuration options including history, model, etc.\n * @returns Promise resolving to the response content string\n *\n * @example\n * ```typescript\n * // Simple usage\n * const response = await provider.message('Hello!');\n *\n * // With history\n * const response = await provider.message('What was my question?', {\n * history: [\n * { role: 'user', content: 'What is 2+2?' },\n * { role: 'assistant', content: '4' }\n * ]\n * });\n * ```\n */\n async message(text: string, options: MessageOptions = {}): Promise<string> {\n // Build messages array from history + current message\n const messages: AIMessage[] = [\n ...(options.history || []),\n { role: options.role || 'user', content: text },\n ];\n\n const response = await this.chat(messages, {\n model: options.model,\n maxTokens: options.maxTokens,\n temperature: options.temperature,\n topP: options.topP,\n stop: options.stop,\n stream: options.stream,\n frequencyPenalty: options.frequencyPenalty,\n presencePenalty: options.presencePenalty,\n responseFormat: options.responseFormat,\n seed: options.seed,\n tools: options.tools,\n toolChoice: options.toolChoice,\n onProgress: options.onProgress,\n signal: options.signal,\n timeout: options.timeout,\n reasoning: options.reasoning,\n usageTags: options.usageTags,\n continueOnLength: options.continueOnLength,\n });\n\n return response.content;\n }\n\n async embed(\n _text: string | string[],\n _options: EmbeddingOptions = {},\n ): Promise<EmbeddingResponse> {\n // Anthropic Claude doesn't provide embeddings API\n throw new AIError(\n 'Anthropic Claude does not support embeddings. Use OpenAI or another provider for embeddings.',\n 'NOT_SUPPORTED',\n 'anthropic',\n );\n }\n\n async embedImage(\n _image: string | Buffer,\n _options: ImageEmbeddingOptions = {},\n ): Promise<EmbeddingResponse> {\n throw new AIError(\n 'Anthropic Claude does not support image embeddings. Use OpenAI or Gemini.',\n 'NOT_SUPPORTED',\n 'anthropic',\n );\n }\n\n async describeImage(\n _image: string | Buffer,\n _prompt?: string,\n _options: ImageDescriptionOptions = {},\n ): Promise<string> {\n // Note: Claude does support vision, but we're keeping this as a stub for now\n // A full implementation could use the chat API with image content\n throw new AIError(\n 'Image description is not yet implemented for Anthropic. Use OpenAI or Gemini.',\n 'NOT_IMPLEMENTED',\n 'anthropic',\n );\n }\n\n async generateImage(\n _prompt: string,\n _options: ImageGenerationOptions = {},\n ): Promise<ImageGenerationResponse> {\n throw new AIError(\n 'Anthropic Claude does not support image generation. Use OpenAI or Gemini.',\n 'NOT_SUPPORTED',\n 'anthropic',\n );\n }\n\n /**\n * Streams a chat completion as text chunks.\n *\n * Streams yield text only and never surface tool calls, so `options.tools`\n * and `options.toolChoice` are ignored: tools are declared only when the\n * replayed history contains `tool_use` blocks (Anthropic requires it), with\n * `tool_choice: { type: 'none' }`. Use `chat()` for rounds that may call\n * tools.\n */\n async *stream(\n messages: AIMessage[],\n options: ChatOptions = {},\n ): AsyncIterable<string> {\n const startTime = Date.now();\n let controls: PreparedRequestControls | undefined;\n try {\n await this.ensureClient();\n\n const { system, anthropicMessages } =\n this.mapMessagesToAnthropic(messages);\n\n const model = options.model || this.options.defaultModel;\n options = normalizeChatOptions(this.options, options, 'anthropic', model);\n controls = prepareRequestControls(this.options, options);\n\n const requestParams: Record<string, any> = {\n model,\n messages: anthropicMessages,\n max_tokens: options.maxTokens,\n temperature: options.temperature,\n top_p: options.topP,\n stop_sequences: Array.isArray(options.stop)\n ? options.stop\n : options.stop\n ? [options.stop]\n : undefined,\n system: system || undefined,\n // stream() yields text only, so a tool call would be lost: declare\n // tools only when the replayed history requires it, with\n // tool_choice none.\n ...this.mapHistoryToolParams(anthropicMessages),\n stream: true,\n };\n const thinking = this.mapThinking(options, anthropicMessages);\n if (thinking) {\n requestParams.thinking = thinking;\n }\n const stream = await this.client.messages.create(requestParams, {\n signal: controls.signal,\n timeout: controls.timeout,\n });\n\n let streamStopReason: string | null = null;\n for await (const chunk of stream) {\n if (chunk.type === 'message_delta' && chunk.delta?.stop_reason) {\n streamStopReason = chunk.delta.stop_reason;\n }\n if (\n chunk.type === 'content_block_delta' &&\n chunk.delta.type === 'text_delta'\n ) {\n if (options.onProgress) {\n options.onProgress(chunk.delta.text);\n }\n yield chunk.delta.text;\n }\n }\n options.onFinishReason?.(\n this.mapFinishReason(streamStopReason) ?? 'stop',\n );\n\n emitUsage(\n this.options,\n 'anthropic',\n 'stream',\n model!,\n undefined,\n startTime,\n options.usageTags,\n );\n } catch (error) {\n if (controls?.didTimeout()) {\n throw new AIError(\n `AI request timed out after ${controls.timeout}ms`,\n 'AI_TIMEOUT',\n 'anthropic',\n options.model,\n );\n }\n if (options.signal?.aborted) {\n throw new AIError(\n 'AI request aborted by caller',\n 'AI_ABORTED',\n 'anthropic',\n options.model,\n );\n }\n throw this.mapError(error);\n } finally {\n controls?.cleanup();\n }\n }\n\n async countTokens(text: string): Promise<number> {\n // Anthropic doesn't provide a direct token counting API\n // This is an approximation - Claude uses a different tokenizer than OpenAI\n return Math.ceil(text.length / 3.5); // Slightly different ratio for Claude\n }\n\n async getModels(): Promise<AIModel[]> {\n // Return static list of known Claude models\n return [\n {\n id: 'claude-3-5-sonnet-20241022',\n name: 'Claude 3.5 Sonnet',\n description: 'Most intelligent Claude model with balanced performance',\n contextLength: 200000,\n capabilities: ['text', 'chat', 'vision', 'functions'],\n supportsFunctions: true,\n supportsVision: true,\n },\n {\n id: 'claude-3-5-haiku-20241022',\n name: 'Claude 3.5 Haiku',\n description: 'Fastest Claude model for simple tasks',\n contextLength: 200000,\n capabilities: ['text', 'chat', 'vision'],\n supportsFunctions: true,\n supportsVision: true,\n },\n {\n id: 'claude-3-opus-20240229',\n name: 'Claude 3 Opus',\n description: 'Most powerful Claude model for complex tasks',\n contextLength: 200000,\n capabilities: ['text', 'chat', 'vision', 'functions'],\n supportsFunctions: true,\n supportsVision: true,\n },\n {\n id: 'claude-3-sonnet-20240229',\n name: 'Claude 3 Sonnet',\n description: 'Balanced Claude model for most tasks',\n contextLength: 200000,\n capabilities: ['text', 'chat', 'vision'],\n supportsFunctions: true,\n supportsVision: true,\n },\n {\n id: 'claude-3-haiku-20240307',\n name: 'Claude 3 Haiku',\n description: 'Fast Claude model for simple tasks',\n contextLength: 200000,\n capabilities: ['text', 'chat', 'vision'],\n supportsFunctions: false,\n supportsVision: true,\n },\n ];\n }\n\n async getCapabilities(): Promise<AICapabilities> {\n return {\n chat: true,\n completion: true,\n embeddings: false, // Claude doesn't support embeddings\n streaming: true,\n functions: true,\n vision: true,\n fineTuning: false,\n imageEmbeddings: false,\n imageGeneration: false,\n videoGeneration: false,\n tts: false,\n voiceCloning: false,\n voiceDesign: false,\n maxContextLength: 200000,\n supportedOperations: [\n 'chat',\n 'completion',\n 'streaming',\n 'functions',\n 'vision',\n ],\n };\n }\n\n // ============================================================================\n // Video Generation Methods (Not supported - use gemini, byteplus-modelark,\n // or openai-compat-video provider)\n // ============================================================================\n\n async submitVideoGenerationJob(\n _options: VideoGenerationOptions,\n ): Promise<VideoGenerationJob> {\n throw new AIError(\n 'Video generation is not supported by Anthropic provider. Use gemini, byteplus-modelark, or openai-compat-video provider.',\n 'NOT_IMPLEMENTED',\n 'anthropic',\n );\n }\n\n async getVideoGenerationJob(\n _handle: VideoGenerationJob,\n ): Promise<VideoGenerationStatusResult> {\n throw new AIError(\n 'Video generation is not supported by Anthropic provider. Use gemini, byteplus-modelark, or openai-compat-video provider.',\n 'NOT_IMPLEMENTED',\n 'anthropic',\n );\n }\n\n async fetchVideoGenerationResult(\n _handle: VideoGenerationJob,\n ): Promise<VideoGenerationResult> {\n throw new AIError(\n 'Video generation is not supported by Anthropic provider. Use gemini, byteplus-modelark, or openai-compat-video provider.',\n 'NOT_IMPLEMENTED',\n 'anthropic',\n );\n }\n\n async cancelVideoGenerationJob(_handle: VideoGenerationJob): Promise<void> {\n throw new AIError(\n 'Video generation is not supported by Anthropic provider. Use gemini, byteplus-modelark, or openai-compat-video provider.',\n 'NOT_IMPLEMENTED',\n 'anthropic',\n );\n }\n\n async validateVideoGenerationAccess(): Promise<boolean> {\n throw new AIError(\n 'Video generation is not supported by Anthropic provider. Use gemini, byteplus-modelark, or openai-compat-video provider.',\n 'NOT_IMPLEMENTED',\n 'anthropic',\n );\n }\n\n // ============================================================================\n // TTS Methods (Not supported - use Qwen3-TTS provider)\n // ============================================================================\n\n async synthesizeSpeech(\n _text: string,\n _options?: TTSOptions,\n ): Promise<TTSResponse> {\n throw new AIError(\n 'TTS is not supported by Anthropic provider. Use Qwen3-TTS provider.',\n 'NOT_IMPLEMENTED',\n 'anthropic',\n );\n }\n\n streamSpeech(_text: string, _options?: TTSOptions): AsyncIterable<Buffer> {\n const error = new AIError(\n 'TTS streaming is not supported by Anthropic provider. Use Qwen3-TTS provider.',\n 'NOT_IMPLEMENTED',\n 'anthropic',\n );\n return {\n [Symbol.asyncIterator]: () => ({\n next: () => Promise.reject(error),\n }),\n };\n }\n\n async cloneVoice(_options: VoiceCloneOptions): Promise<Voice> {\n throw new AIError(\n 'Voice cloning is not supported by Anthropic provider. Use Qwen3-TTS provider.',\n 'NOT_IMPLEMENTED',\n 'anthropic',\n );\n }\n\n async designVoice(_options: VoiceDesignOptions): Promise<Voice> {\n throw new AIError(\n 'Voice design is not supported by Anthropic provider. Use Qwen3-TTS provider.',\n 'NOT_IMPLEMENTED',\n 'anthropic',\n );\n }\n\n async getVoices(_options?: VoiceListOptions): Promise<Voice[]> {\n throw new AIError(\n 'Voice listing is not supported by Anthropic provider. Use Qwen3-TTS provider.',\n 'NOT_IMPLEMENTED',\n 'anthropic',\n );\n }\n\n /**\n * Maps internal messages to Anthropic Messages API turns.\n *\n * Assistant `tool_calls` become `tool_use` blocks and `role: 'tool'`\n * results become `tool_result` blocks paired by `tool_call_id`\n * (`tool_use_id`). Consecutive tool results are grouped into one user turn,\n * as Anthropic requires every result for a turn to follow it directly.\n * Only answered calls are replayed as `tool_use`, and only results whose\n * `tool_call_id` matches a replayed call become `tool_result`. A result\n * without `tool_call_id`, or one answering no replayed call, falls back to\n * plain text (and a call left unanswered keeps only its text).\n */\n private mapMessagesToAnthropic(messages: AIMessage[]): {\n system?: string;\n anthropicMessages: AnthropicMessage[];\n } {\n // Anthropic handles system messages separately\n let system: string | undefined;\n const anthropicMessages: AnthropicMessage[] = [];\n const answeredToolCallIds = new Set(\n messages\n .filter((message) => message.role === 'tool' && message.tool_call_id)\n .map((message) => message.tool_call_id as string),\n );\n // Calls replayed as tool_use: those with an answer. Only results for\n // these ids become tool_result blocks; any other result is an orphan\n // Anthropic would reject, so it falls back to plain text.\n const replayedToolUseIds = new Set<string>();\n for (const message of messages) {\n if (message.role !== 'assistant') continue;\n for (const toolCall of message.tool_calls || []) {\n if (answeredToolCallIds.has(toolCall.id)) {\n replayedToolUseIds.add(toolCall.id);\n }\n }\n }\n\n for (const message of messages) {\n const textContent = extractTextContent(message.content);\n if (message.role === 'system') {\n // Combine multiple system messages\n system = system ? `${system}\\n\\n${textContent}` : textContent;\n continue;\n }\n\n if (\n message.role === 'tool' &&\n message.tool_call_id &&\n replayedToolUseIds.has(message.tool_call_id)\n ) {\n const block: AnthropicContentBlock = {\n type: 'tool_result',\n tool_use_id: message.tool_call_id,\n content: textContent,\n };\n const previous = anthropicMessages[anthropicMessages.length - 1];\n if (\n previous?.role === 'user' &&\n Array.isArray(previous.content) &&\n previous.content.every((part) => part.type === 'tool_result')\n ) {\n previous.content.push(block);\n } else {\n anthropicMessages.push({ role: 'user', content: [block] });\n }\n continue;\n }\n\n const toolCalls =\n message.role === 'assistant'\n ? (message.tool_calls || []).filter((toolCall) =>\n answeredToolCallIds.has(toolCall.id),\n )\n : [];\n if (toolCalls.length > 0) {\n const content: AnthropicContentBlock[] = [];\n for (const toolCall of toolCalls) {\n for (const block of toolCall.thinkingBlocks || []) {\n content.push({ ...block });\n }\n }\n if (textContent) {\n content.push({ type: 'text', text: textContent });\n }\n for (const toolCall of toolCalls) {\n content.push({\n type: 'tool_use',\n id: toolCall.id,\n name: toolCall.function.name,\n input: parseToolArguments(toolCall.function.arguments),\n });\n }\n anthropicMessages.push({ role: 'assistant', content });\n continue;\n }\n\n anthropicMessages.push({\n role: message.role === 'assistant' ? 'assistant' : 'user',\n content: textContent,\n });\n }\n\n return { system, anthropicMessages };\n }\n\n /**\n * Builds the `tools` / `tool_choice` request fields.\n *\n * Anthropic rejects a request whose history contains `tool_use` or\n * `tool_result` blocks unless `tools` is declared. A tool loop's final,\n * tool-less round (no `tools`, typically `toolChoice: 'none'`) still\n * replays that history, so when the caller declares no tools but the\n * history uses some, this declares a minimal definition for each tool the\n * history references and sets `tool_choice: { type: 'none' }` so the model\n * answers in text instead of calling them.\n */\n private mapToolParams(\n options: ChatOptions,\n anthropicMessages: AnthropicMessage[],\n ): { tools?: Record<string, any>[]; tool_choice?: Record<string, any> } {\n const tools = this.mapTools(options);\n if (tools) {\n return { tools, tool_choice: this.mapToolChoice(options.toolChoice) };\n }\n return this.mapHistoryToolParams(anthropicMessages);\n }\n\n /**\n * Declares a minimal definition for each tool the replayed history\n * references, with `tool_choice: { type: 'none' }`, or nothing when the\n * history has no `tool_use` blocks. Used for tool-less rounds and for\n * every stream (streams never yield tool calls).\n */\n private mapHistoryToolParams(anthropicMessages: AnthropicMessage[]): {\n tools?: Record<string, any>[];\n tool_choice?: Record<string, any>;\n } {\n // mapMessagesToAnthropic emits tool_result only for ids it replayed as\n // tool_use (orphan results become text), so tool_use names cover every\n // tool the history references.\n const historyToolNames = new Set<string>();\n for (const message of anthropicMessages) {\n if (!Array.isArray(message.content)) continue;\n for (const block of message.content) {\n if (block.type === 'tool_use') historyToolNames.add(block.name);\n }\n }\n if (historyToolNames.size === 0) {\n return {};\n }\n\n return {\n tools: [...historyToolNames].map((name) => ({\n name,\n description:\n 'Used earlier in this conversation; not available for this turn.',\n input_schema: { type: 'object' },\n })),\n tool_choice: { type: 'none' },\n };\n }\n\n /**\n * Builds the `thinking` request field for `options.reasoning.maxTokens`.\n *\n * While thinking is enabled, Anthropic requires the assistant turn of an\n * in-progress tool loop (the last assistant turn, when it holds `tool_use`)\n * to start with its thinking blocks. They are replayed from\n * `AIToolCall.thinkingBlocks`; when that turn has none (the history came\n * from another provider, a store that dropped the field, or a call made\n * without thinking), thinking is left off for this request rather than\n * sending a request Anthropic would reject.\n */\n private mapThinking(\n options: ChatOptions,\n anthropicMessages: AnthropicMessage[],\n ): { type: 'enabled'; budget_tokens: number } | undefined {\n const budget = options.reasoning?.maxTokens || 0;\n if (budget <= 0) return undefined;\n\n const lastAssistant = [...anthropicMessages]\n .reverse()\n .find((message) => message.role === 'assistant');\n if (\n lastAssistant &&\n Array.isArray(lastAssistant.content) &&\n lastAssistant.content.some((block) => block.type === 'tool_use')\n ) {\n const firstType = lastAssistant.content[0]?.type;\n if (firstType !== 'thinking' && firstType !== 'redacted_thinking') {\n return undefined;\n }\n }\n\n return { type: 'enabled', budget_tokens: budget };\n }\n\n private mapTools(options: ChatOptions): Record<string, any>[] | undefined {\n return options.tools && options.tools.length > 0\n ? options.tools.map((tool) => ({\n name: tool.function.name,\n description: tool.function.description || '',\n input_schema: tool.function.parameters || { type: 'object' },\n }))\n : undefined;\n }\n\n private mapToolChoice(\n toolChoice?:\n | 'auto'\n | 'none'\n | { type: 'function'; function: { name: string } },\n ): any {\n if (!toolChoice || toolChoice === 'auto') {\n return { type: 'auto' };\n }\n\n if (toolChoice === 'none') {\n return { type: 'none' };\n }\n\n if (typeof toolChoice === 'object' && toolChoice.type === 'function') {\n return {\n type: 'tool',\n name: toolChoice.function.name,\n };\n }\n\n return { type: 'auto' };\n }\n\n private mapFinishReason(reason: string | null): AIResponse['finishReason'] {\n switch (reason) {\n case 'end_turn':\n return 'stop';\n case 'max_tokens':\n return 'length';\n case 'stop_sequence':\n return 'stop';\n case 'tool_use':\n return 'tool_calls';\n default:\n return 'stop';\n }\n }\n\n private mapError(error: unknown): AIError {\n if (error instanceof AIError) {\n return error;\n }\n\n // Map common HTTP status codes from Anthropic API\n if (typeof error === 'object' && error !== null && 'status' in error) {\n const apiError = error as { status: number; message?: string };\n switch (apiError.status) {\n case 401:\n return new AuthenticationError('anthropic');\n case 429:\n return rateLimitErrorFrom('anthropic', error);\n case 404:\n return new ModelNotFoundError(\n apiError.message || 'Model not found',\n 'anthropic',\n );\n case 413:\n return new ContextLengthError('anthropic');\n }\n }\n\n const errorMessage =\n error instanceof Error\n ? error.message\n : 'Unknown Anthropic error occurred';\n return new AIError(errorMessage, 'UNKNOWN_ERROR', 'anthropic');\n }\n}\n\n/**\n * Thinking and redacted-thinking blocks from an Anthropic response, copied\n * with only the fields the API accepts back.\n */\nfunction extractThinkingBlocks(content: any[]): AIThinkingBlock[] {\n const blocks: AIThinkingBlock[] = [];\n for (const block of content || []) {\n if (block?.type === 'thinking') {\n blocks.push({\n type: 'thinking',\n thinking: block.thinking,\n signature: block.signature,\n });\n } else if (block?.type === 'redacted_thinking') {\n blocks.push({ type: 'redacted_thinking', data: block.data });\n }\n }\n return blocks;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA+EA,IAAa,oBAAb,MAAsD;CACpD;CACA;;;;;CAMA,YAAY,SAA2B;EACrC,KAAK,UAAU,uBAAuB;GACpC,cAAc;GACd,kBAAkB;GAClB,GAAG;EACL,CAAC;EAGD,KAAK,qBAAqB;CAC5B;CAEA,uBAA+B;EAC7B,IAAI;GAEF,OAAO,oBAAoB,CACxB,MAAM,EAAE,gBAAgB;IACvB,KAAK,SAAS,IAAI,UAAU;KAC1B,QAAQ,KAAK,QAAQ;KACrB,SAAS,KAAK,QAAQ;KACtB,SAAS,KAAK,QAAQ;KACtB,YAAY,KAAK,QAAQ;KACzB,gBAAgB;MACd,qBAAqB,KAAK,QAAQ;MAClC,GAAG,KAAK,QAAQ;KAClB;IACF,CAAC;GACH,CAAC,CAAC,CACD,YAAY,CAEb,CAAC;EACL,SAAS,QAAQ,CAEjB;CACF;;;;;;CAOA,MAAc,eAAe;EAC3B,IAAI,CAAC,KAAK,QACR,IAAI;GACF,MAAM,EAAE,cAAc,MAAM,OAAO;GACnC,KAAK,SAAS,IAAI,UAAU;IAC1B,QAAQ,KAAK,QAAQ;IACrB,SAAS,KAAK,QAAQ;IACtB,SAAS,KAAK,QAAQ;IACtB,YAAY,KAAK,QAAQ;IACzB,gBAAgB;KACd,qBAAqB,KAAK,QAAQ;KAClC,GAAG,KAAK,QAAQ;IAClB;GACF,CAAC;EACH,SAAS,QAAQ;GACf,MAAM,IAAI,QACR,oFACA,wBACA,WACF;EACF;CAEJ;;;;;;;;;;;;;;;;;;;CAoBA,MAAM,KACJ,UACA,UAAuB,CAAC,GACH;EACrB,MAAM,YAAY,KAAK,IAAI;EAC3B,IAAI;EACJ,IAAI;GACF,MAAM,KAAK,aAAa;GAExB,MAAM,EAAE,QAAQ,sBACd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AQ,SAAS,QAAjB;IACE,KAAK,KACH,OAAO,IAAI,oBAAoB,WAAW;IAC5C,KAAK,KACH,OAAO,mBAAmB,aAAa,KAAK;IAC9C,KAAK,KACH,OAAO,IAAI,mBACT,SAAS,WAAW,mBACpB,WACF;IACF,KAAK,KACH,OAAO,IAAI,mBAAmB,WAAW;GAC7C;EACF;EAMA,OAAO,IAAI,QAHT,iBAAiB,QACb,MAAM,UACN,oCAC2B,iBAAiB,WAAW;CAC/D;AACF;;;;;AAMA,SAAS,sBAAsB,SAAmC;CAChE,MAAM,SAA4B,CAAC;CACnC,KAAK,MAAM,SAAS,WAAW,CAAC,GAC9B,IAAI,OAAO,SAAS,YAClB,OAAO,KAAK;EACV,MAAM;EACN,UAAU,MAAM;EAChB,WAAW,MAAM;CACnB,CAAC;MACI,IAAI,OAAO,SAAS,qBACzB,OAAO,KAAK;EAAE,MAAM;EAAqB,MAAM,MAAM;CAAK,CAAC;CAG/D,OAAO;AACT"}
@@ -1,6 +1,5 @@
1
- import { a as ContextLengthError, l as extractTextContent, r as AuthenticationError, s as ModelNotFoundError, t as AIError } from "./types-DB5W6_F-.js";
2
- import { c as normalizeChatOptions, l as normalizeImageGenerationOptions, n as rateLimitErrorFrom, s as normalizeBaseAIOptions, u as prepareRequestControls } from "./rate-limit-BzWfHA0e.js";
3
- import { t as emitUsage } from "./usage-C1Y1Nlg4.js";
1
+ import { b as extractTextContent, c as normalizeImageGenerationOptions, f as AuthenticationError, g as ModelNotFoundError, l as prepareRequestControls, m as ContextLengthError, o as normalizeBaseAIOptions, s as normalizeChatOptions, t as emitUsage, u as AIError } from "./usage-BaQKo8bc.js";
2
+ import { n as rateLimitErrorFrom } from "./rate-limit-Bln_w0rH.js";
4
3
  //#region src/shared/providers/bedrock.ts
5
4
  /**
6
5
  * AWS Bedrock provider implementation
@@ -762,4 +761,4 @@ var BedrockProvider = class {
762
761
  //#endregion
763
762
  export { BedrockProvider };
764
763
 
765
- //# sourceMappingURL=bedrock-BQi3Z9jR.js.map
764
+ //# sourceMappingURL=bedrock-B0cNEXFa.js.map