@kjerneverk/execution-anthropic 1.0.13 → 1.0.14-dev.20260320165141.9296346

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.
package/README.md CHANGED
@@ -11,7 +11,12 @@ npm install execution-anthropic @anthropic-ai/sdk
11
11
  ## Usage
12
12
 
13
13
  ```typescript
14
- import { AnthropicProvider, createAnthropicProvider } from 'execution-anthropic';
14
+ import {
15
+ AnthropicProvider,
16
+ createAnthropicProvider,
17
+ CLAUDE_SONNET_LATEST,
18
+ DEFAULT_ANTHROPIC_MODEL,
19
+ } from 'execution-anthropic';
15
20
 
16
21
  // Create provider
17
22
  const provider = createAnthropicProvider();
@@ -19,7 +24,7 @@ const provider = createAnthropicProvider();
19
24
  // Execute a request
20
25
  const response = await provider.execute(
21
26
  {
22
- model: 'claude-3-opus-20240229',
27
+ model: CLAUDE_SONNET_LATEST, // or omit to use DEFAULT_ANTHROPIC_MODEL
23
28
  messages: [
24
29
  { role: 'system', content: 'You are helpful.' },
25
30
  { role: 'user', content: 'Hello!' }
@@ -39,11 +44,14 @@ console.log(response.usage); // { inputTokens: X, outputTokens: Y }
39
44
 
40
45
  ## Supported Models
41
46
 
42
- The provider supports all Claude models:
43
- - Claude 3 Opus
44
- - Claude 3 Sonnet
45
- - Claude 3 Haiku
46
- - Claude 3.5 family
47
+ Any model string the Anthropic API accepts is supported (`supportsModel` checks the `claude` prefix). This package depends on a current `@anthropic-ai/sdk`, whose typings include IDs such as:
48
+
49
+ - **Claude 4.6** — `claude-opus-4-6`, `claude-sonnet-4-6`
50
+ - **Claude 4.5** — `claude-opus-4-5`, `claude-opus-4-5-20251101`, `claude-sonnet-4-5`, `claude-sonnet-4-5-20250929`, `claude-haiku-4-5`, `claude-haiku-4-5-20251001`
51
+ - **Claude 4.0 / 4.1** — e.g. `claude-opus-4-20250514`, `claude-sonnet-4-20250514`, `claude-opus-4-1-20250805`
52
+ - **Claude 3.x** — legacy dated IDs (e.g. `claude-3-opus-20240229`) remain valid where the API still serves them
53
+
54
+ Exported helpers: `DEFAULT_ANTHROPIC_MODEL`, `CLAUDE_OPUS_LATEST`, `CLAUDE_SONNET_LATEST`, `CLAUDE_HAIKU_LATEST`, and TypeScript type `AnthropicModel` (re-exported from the SDK).
47
55
 
48
56
  ## API Key
49
57
 
package/dist/index.d.ts CHANGED
@@ -6,6 +6,10 @@
6
6
  * @packageDocumentation
7
7
  */
8
8
 
9
+ import { Model as AnthropicModel } from '@anthropic-ai/sdk/resources/messages/messages.js';
10
+
11
+ export { AnthropicModel }
12
+
9
13
  /**
10
14
  * Anthropic Provider implementation
11
15
  */
@@ -27,11 +31,24 @@ declare class AnthropicProvider implements Provider {
27
31
  export { AnthropicProvider }
28
32
  export default AnthropicProvider;
29
33
 
34
+ export declare const CLAUDE_HAIKU_LATEST: "claude-haiku-4-5";
35
+
36
+ /** Stable API identifiers for the latest generation (see Anthropic models documentation). */
37
+ export declare const CLAUDE_OPUS_LATEST: "claude-opus-4-6";
38
+
39
+ export declare const CLAUDE_SONNET_LATEST: "claude-sonnet-4-6";
40
+
30
41
  /**
31
42
  * Create a new Anthropic provider instance
32
43
  */
33
44
  export declare function createAnthropicProvider(): AnthropicProvider;
34
45
 
46
+ /**
47
+ * Default model when the request and options omit `model`.
48
+ * Uses the current flagship Sonnet; override with `ExecutionOptions.model` or `Request.model`.
49
+ */
50
+ export declare const DEFAULT_ANTHROPIC_MODEL: "claude-sonnet-4-6";
51
+
35
52
  export declare interface ExecutionOptions {
36
53
  apiKey?: string;
37
54
  model?: string;
package/dist/index.js CHANGED
@@ -78,6 +78,10 @@ configureSecretGuard({
78
78
  { name: "anthropic-api", pattern: /sk-ant-api\d+-[a-zA-Z0-9_-]+/g, description: "Anthropic API key" }
79
79
  ]
80
80
  });
81
+ const DEFAULT_ANTHROPIC_MODEL = "claude-sonnet-4-6";
82
+ const CLAUDE_OPUS_LATEST = "claude-opus-4-6";
83
+ const CLAUDE_SONNET_LATEST = "claude-sonnet-4-6";
84
+ const CLAUDE_HAIKU_LATEST = "claude-haiku-4-5";
81
85
  class AnthropicProvider {
82
86
  name = "anthropic";
83
87
  /**
@@ -106,7 +110,7 @@ class AnthropicProvider {
106
110
  clientOptions.fetch = createProxyFetch(proxyUrl);
107
111
  }
108
112
  const client = new Anthropic(clientOptions);
109
- const model = options.model || request.model || "claude-3-opus-20240229";
113
+ const model = options.model || request.model || DEFAULT_ANTHROPIC_MODEL;
110
114
  let systemPrompt = "";
111
115
  const messages = [];
112
116
  for (const msg of request.messages) {
@@ -263,7 +267,7 @@ class AnthropicProvider {
263
267
  clientOptions.fetch = createProxyFetch(proxyUrl);
264
268
  }
265
269
  const client = new Anthropic(clientOptions);
266
- const model = options.model || request.model || "claude-3-opus-20240229";
270
+ const model = options.model || request.model || DEFAULT_ANTHROPIC_MODEL;
267
271
  let systemPrompt = "";
268
272
  const messages = [];
269
273
  for (const msg of request.messages) {
@@ -448,6 +452,10 @@ function createAnthropicProvider() {
448
452
  const VERSION = "0.0.1";
449
453
  export {
450
454
  AnthropicProvider,
455
+ CLAUDE_HAIKU_LATEST,
456
+ CLAUDE_OPUS_LATEST,
457
+ CLAUDE_SONNET_LATEST,
458
+ DEFAULT_ANTHROPIC_MODEL,
451
459
  VERSION,
452
460
  createAnthropicProvider,
453
461
  AnthropicProvider as default
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/proxy.ts","../src/index.ts"],"sourcesContent":["/**\n * Proxy support for Anthropic API requests.\n *\n * When proxy environment variables are set, routes requests through the proxy\n * using undici's ProxyAgent. Respects NO_PROXY/no_proxy for bypass lists and\n * NODE_TLS_REJECT_UNAUTHORIZED for TLS verification.\n */\n\nimport { ProxyAgent, fetch as undiciFetch } from 'undici';\n\n/**\n * Get the proxy URL from environment variables.\n * Checks HTTPS_PROXY, https_proxy, HTTP_PROXY, http_proxy.\n */\nexport function getProxyUrl(): string | undefined {\n return (\n process.env.HTTPS_PROXY ||\n process.env.https_proxy ||\n process.env.HTTP_PROXY ||\n process.env.http_proxy ||\n undefined\n );\n}\n\n/**\n * Read TLS strict mode. Returns false only when NODE_TLS_REJECT_UNAUTHORIZED\n * is explicitly set to '0'.\n */\nexport function getStrictSSL(): boolean {\n return process.env.NODE_TLS_REJECT_UNAUTHORIZED !== '0';\n}\n\n/**\n * Check whether a target URL should bypass the proxy based on NO_PROXY / no_proxy.\n */\nexport function isProxyBypassed(targetUrl: string): boolean {\n const noProxy = process.env.NO_PROXY || process.env.no_proxy;\n if (!noProxy) {\n return false;\n }\n\n let hostname: string;\n try {\n hostname = new URL(targetUrl).hostname.toLowerCase();\n } catch {\n return false;\n }\n\n const entries = noProxy.split(',').map((e) => e.trim().toLowerCase());\n for (const entry of entries) {\n if (!entry) {\n continue;\n }\n if (entry === '*') {\n return true;\n }\n if (hostname === entry) {\n return true;\n }\n const suffix = entry.startsWith('.') ? entry : `.${entry}`;\n if (hostname.endsWith(suffix)) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Create a fetch implementation that routes requests through an HTTP(S) proxy.\n * Respects TLS verification settings and NO_PROXY bypass lists.\n *\n * @param proxyUrl - The proxy URL (e.g. https://proxy.example.com:8080)\n * @returns A fetch function that uses ProxyAgent as the dispatcher\n */\nexport function createProxyFetch(proxyUrl: string): typeof fetch {\n const proxyAgent = new ProxyAgent({\n uri: proxyUrl,\n requestTls: { rejectUnauthorized: getStrictSSL() },\n });\n return ((input: any, init?: any) => {\n const targetUrl = typeof input === 'string'\n ? input\n : input instanceof URL\n ? input.toString()\n : input.url;\n if (isProxyBypassed(targetUrl)) {\n return undiciFetch(input, init);\n }\n return undiciFetch(input, { ...init, dispatcher: proxyAgent });\n }) as any;\n}\n","/**\n * Execution Anthropic Package\n *\n * Anthropic provider implementation for LLM execution.\n *\n * @packageDocumentation\n */\n\nimport Anthropic from '@anthropic-ai/sdk';\nimport { getRedactor } from '@utilarium/offrecord';\nimport { getProxyUrl, createProxyFetch } from './proxy.js';\nimport { \n createSafeError, \n configureErrorSanitizer,\n configureSecretGuard,\n} from '@utilarium/spotclean';\n\n// Register Anthropic API key patterns on module load\nconst redactor = getRedactor();\nredactor.register({\n name: 'anthropic',\n patterns: [\n /sk-ant-[a-zA-Z0-9_-]+/g,\n /sk-ant-api\\d+-[a-zA-Z0-9_-]+/g,\n ],\n validator: (key: string) => /^sk-ant(-api\\d+)?-[a-zA-Z0-9_-]+$/.test(key),\n envVar: 'ANTHROPIC_API_KEY',\n description: 'Anthropic API keys',\n});\n\n// Configure spotclean for error sanitization\nconfigureErrorSanitizer({\n enabled: true,\n environment: process.env.NODE_ENV === 'production' ? 'production' : 'development',\n includeCorrelationId: true,\n sanitizeStackTraces: process.env.NODE_ENV === 'production',\n maxMessageLength: 500,\n});\n\nconfigureSecretGuard({\n enabled: true,\n redactionText: '[REDACTED]',\n preservePartial: false,\n preserveLength: 0,\n customPatterns: [\n { name: 'anthropic', pattern: /sk-ant-[a-zA-Z0-9_-]+/g, description: 'Anthropic API key' },\n { name: 'anthropic-api', pattern: /sk-ant-api\\d+-[a-zA-Z0-9_-]+/g, description: 'Anthropic API key' },\n ],\n});\n\n// ===== INLINE TYPES (from 'execution' package) =====\n\nexport type Model = string;\n\nexport interface Message {\n role: 'user' | 'assistant' | 'system' | 'developer' | 'tool';\n content: string | string[] | null;\n name?: string;\n}\n\nexport interface ToolParameterSchema {\n type: 'object';\n properties: Record<string, {\n type: string;\n description?: string;\n enum?: string[];\n items?: { type: string };\n default?: any;\n }>;\n required?: string[];\n additionalProperties?: boolean;\n}\n\nexport interface ToolDefinition {\n name: string;\n description: string;\n parameters: ToolParameterSchema;\n}\n\nexport type StreamChunkType = 'text' | 'tool_call_start' | 'tool_call_delta' | 'tool_call_end' | 'usage' | 'done';\n\nexport interface StreamChunk {\n type: StreamChunkType;\n text?: string;\n toolCall?: {\n id?: string;\n index?: number;\n name?: string;\n argumentsDelta?: string;\n };\n usage?: {\n inputTokens: number;\n outputTokens: number;\n cacheCreationInputTokens?: number;\n cacheReadInputTokens?: number;\n };\n}\n\nexport interface Request {\n messages: Message[];\n model: Model;\n responseFormat?: any;\n validator?: any;\n tools?: ToolDefinition[];\n addMessage(message: Message): void;\n}\n\nexport interface ProviderResponse {\n content: string;\n model: string;\n usage?: {\n inputTokens: number;\n outputTokens: number;\n };\n toolCalls?: Array<{\n id: string;\n type: 'function';\n function: {\n name: string;\n arguments: string;\n };\n }>;\n}\n\nexport interface ExecutionOptions {\n apiKey?: string;\n model?: string;\n temperature?: number;\n maxTokens?: number;\n timeout?: number;\n retries?: number;\n}\n\nexport interface Provider {\n readonly name: string;\n execute(request: Request, options?: ExecutionOptions): Promise<ProviderResponse>;\n executeStream?(request: Request, options?: ExecutionOptions): AsyncIterable<StreamChunk>;\n supportsModel?(model: Model): boolean;\n}\n\n/**\n * Anthropic Provider implementation\n */\nexport class AnthropicProvider implements Provider {\n readonly name = 'anthropic';\n\n /**\n * Check if this provider supports a given model\n */\n supportsModel(model: Model): boolean {\n if (!model) return false;\n return model.startsWith('claude');\n }\n\n /**\n * Execute a request against Anthropic\n */\n async execute(\n request: Request,\n options: ExecutionOptions = {}\n ): Promise<ProviderResponse> {\n const apiKey = options.apiKey || process.env.ANTHROPIC_API_KEY;\n \n if (!apiKey) {\n throw new Error('Anthropic API key is required. Set ANTHROPIC_API_KEY environment variable.');\n }\n\n // Validate key format\n const validation = redactor.validateKey(apiKey, 'anthropic');\n if (!validation.valid) {\n throw new Error('Invalid Anthropic API key format');\n }\n\n try {\n const clientOptions: ConstructorParameters<typeof Anthropic>[0] = { apiKey };\n const proxyUrl = getProxyUrl();\n if (proxyUrl) {\n clientOptions.fetch = createProxyFetch(proxyUrl);\n }\n const client = new Anthropic(clientOptions);\n\n const model = options.model || request.model || 'claude-3-opus-20240229';\n\n // Anthropic separates system prompt from messages\n let systemPrompt = '';\n const messages: Anthropic.MessageParam[] = [];\n\n for (const msg of request.messages) {\n if (msg.role === 'system' || msg.role === 'developer') {\n systemPrompt +=\n (typeof msg.content === 'string'\n ? msg.content\n : JSON.stringify(msg.content)) + '\\n\\n';\n } else if (msg.role === 'tool') {\n // Handle tool result messages - Anthropic expects these as user messages with tool_result content\n messages.push({\n role: 'user',\n content: [\n {\n type: 'tool_result',\n tool_use_id: (msg as any).tool_call_id || '',\n content: typeof msg.content === 'string' \n ? msg.content \n : JSON.stringify(msg.content),\n },\n ],\n });\n } else if (msg.role === 'assistant' && (msg as any).tool_calls) {\n // Handle assistant messages with tool calls\n const toolCalls = (msg as any).tool_calls;\n const content: Anthropic.ContentBlockParam[] = [];\n \n if (msg.content) {\n content.push({\n type: 'text',\n text: typeof msg.content === 'string' ? msg.content : JSON.stringify(msg.content),\n });\n }\n \n for (const tc of toolCalls) {\n // Parse arguments, defaulting to empty object if empty or invalid\n let input: Record<string, unknown> = {};\n if (tc.function.arguments && tc.function.arguments.trim()) {\n try {\n input = JSON.parse(tc.function.arguments);\n } catch {\n // If arguments can't be parsed, use empty object\n input = {};\n }\n }\n content.push({\n type: 'tool_use',\n id: tc.id,\n name: tc.function.name,\n input,\n });\n }\n \n messages.push({ role: 'assistant', content });\n } else {\n messages.push({\n role: msg.role as 'user' | 'assistant',\n content:\n typeof msg.content === 'string'\n ? msg.content\n : JSON.stringify(msg.content),\n });\n }\n }\n\n // Build tools array for the request\n let anthropicTools: Anthropic.Tool[] | undefined;\n let toolChoice: Anthropic.ToolChoice | undefined;\n\n if (request.responseFormat?.type === 'json_schema') {\n // JSON schema mode - use tool for structured output\n anthropicTools = [\n {\n name: request.responseFormat.json_schema.name,\n description:\n request.responseFormat.json_schema.description ||\n 'Output data in this structured format',\n input_schema:\n request.responseFormat.json_schema.schema,\n },\n ];\n toolChoice = {\n type: 'tool' as const,\n name: request.responseFormat.json_schema.name,\n };\n } else if (request.tools && request.tools.length > 0) {\n // Function calling mode - pass tools from request\n anthropicTools = request.tools.map((tool) => ({\n name: tool.name,\n description: tool.description,\n input_schema: tool.parameters as Anthropic.Tool.InputSchema,\n }));\n // Let the model decide when to use tools\n toolChoice = { type: 'auto' as const };\n }\n\n const response = await client.messages.create({\n model: model,\n system: systemPrompt.trim() || undefined,\n messages: messages,\n max_tokens: options.maxTokens || 50000,\n temperature: options.temperature,\n ...(anthropicTools ? { tools: anthropicTools } : {}),\n ...(toolChoice ? { tool_choice: toolChoice } : {}),\n });\n\n // Handle ContentBlock - extract text and tool calls\n let text = '';\n const toolCalls: Array<{\n id: string;\n type: 'function';\n function: { name: string; arguments: string };\n }> = [];\n\n for (const block of response.content) {\n if (block.type === 'text') {\n text += block.text;\n } else if (block.type === 'tool_use') {\n if (request.responseFormat?.type === 'json_schema') {\n // For JSON schema mode, return the tool input as text\n text = JSON.stringify(block.input, null, 2);\n } else {\n // For function calling mode, add to toolCalls array\n toolCalls.push({\n id: block.id,\n type: 'function',\n function: {\n name: block.name,\n arguments: JSON.stringify(block.input),\n },\n });\n }\n }\n }\n\n return {\n content: text,\n model: response.model,\n usage: {\n inputTokens: response.usage.input_tokens,\n outputTokens: response.usage.output_tokens,\n },\n ...(toolCalls.length > 0 ? { toolCalls } : {}),\n };\n } catch (error) {\n // Sanitize error to remove any API keys from error messages\n // Use spotclean for comprehensive error sanitization\n throw createSafeError(error as Error, { provider: 'anthropic' });\n }\n }\n\n /**\n * Execute a request with streaming response\n */\n async *executeStream(\n request: Request,\n options: ExecutionOptions = {}\n ): AsyncIterable<StreamChunk> {\n const apiKey = options.apiKey || process.env.ANTHROPIC_API_KEY;\n \n if (!apiKey) {\n throw new Error('Anthropic API key is required. Set ANTHROPIC_API_KEY environment variable.');\n }\n\n // Validate key format\n const validation = redactor.validateKey(apiKey, 'anthropic');\n if (!validation.valid) {\n throw new Error('Invalid Anthropic API key format');\n }\n\n // Idle timeout configuration (default 5 minutes)\n // This detects when the stream stops sending data mid-response\n // Set high because the model can take a long time to process large inputs\n // and decide on tool calls between streaming text chunks\n const idleTimeoutMs = options.timeout || 300000;\n let idleTimer: ReturnType<typeof setTimeout> | null = null;\n let abortController: AbortController | null = null;\n\n const resetIdleTimer = () => {\n if (idleTimer) {\n clearTimeout(idleTimer);\n }\n idleTimer = setTimeout(() => {\n if (abortController) {\n abortController.abort();\n }\n }, idleTimeoutMs);\n };\n\n const clearIdleTimer = () => {\n if (idleTimer) {\n clearTimeout(idleTimer);\n idleTimer = null;\n }\n };\n\n try {\n abortController = new AbortController();\n const clientOptions: ConstructorParameters<typeof Anthropic>[0] = { \n apiKey,\n // Set overall timeout (10 minutes default, or user-specified)\n timeout: options.timeout || 600000,\n };\n const proxyUrl = getProxyUrl();\n if (proxyUrl) {\n clientOptions.fetch = createProxyFetch(proxyUrl);\n }\n const client = new Anthropic(clientOptions);\n\n const model = options.model || request.model || 'claude-3-opus-20240229';\n\n // Anthropic separates system prompt from messages\n let systemPrompt = '';\n const messages: Anthropic.MessageParam[] = [];\n\n for (const msg of request.messages) {\n if (msg.role === 'system' || msg.role === 'developer') {\n systemPrompt +=\n (typeof msg.content === 'string'\n ? msg.content\n : JSON.stringify(msg.content)) + '\\n\\n';\n } else if (msg.role === 'tool') {\n // Handle tool result messages\n messages.push({\n role: 'user',\n content: [\n {\n type: 'tool_result',\n tool_use_id: (msg as any).tool_call_id || '',\n content: typeof msg.content === 'string' \n ? msg.content \n : JSON.stringify(msg.content),\n },\n ],\n });\n } else if (msg.role === 'assistant' && (msg as any).tool_calls) {\n // Handle assistant messages with tool calls\n const toolCalls = (msg as any).tool_calls;\n const content: Anthropic.ContentBlockParam[] = [];\n \n if (msg.content) {\n content.push({\n type: 'text',\n text: typeof msg.content === 'string' ? msg.content : JSON.stringify(msg.content),\n });\n }\n \n for (const tc of toolCalls) {\n // Parse arguments, defaulting to empty object if empty or invalid\n let input: Record<string, unknown> = {};\n if (tc.function.arguments && tc.function.arguments.trim()) {\n try {\n input = JSON.parse(tc.function.arguments);\n } catch {\n // If arguments can't be parsed, use empty object\n input = {};\n }\n }\n content.push({\n type: 'tool_use',\n id: tc.id,\n name: tc.function.name,\n input,\n });\n }\n \n messages.push({ role: 'assistant', content });\n } else {\n messages.push({\n role: msg.role as 'user' | 'assistant',\n content:\n typeof msg.content === 'string'\n ? msg.content\n : JSON.stringify(msg.content),\n });\n }\n }\n\n // Build tools array\n let anthropicTools: Anthropic.Tool[] | undefined;\n if (request.tools && request.tools.length > 0) {\n anthropicTools = request.tools.map((tool) => ({\n name: tool.name,\n description: tool.description,\n input_schema: tool.parameters as Anthropic.Tool.InputSchema,\n }));\n }\n\n // Build system prompt with cache control for prompt caching\n // Cache the system prompt since it's the same across turns\n const systemBlocks: Anthropic.TextBlockParam[] = systemPrompt.trim() \n ? [{\n type: 'text' as const,\n text: systemPrompt.trim(),\n cache_control: { type: 'ephemeral' as const },\n }]\n : [];\n\n const stream = client.messages.stream({\n model: model,\n system: systemBlocks.length > 0 ? systemBlocks : undefined,\n messages: messages,\n max_tokens: options.maxTokens || 50000, // High default for tool calls with large content\n temperature: options.temperature,\n ...(anthropicTools ? { tools: anthropicTools, tool_choice: { type: 'auto' as const } } : {}),\n }, {\n signal: abortController.signal,\n });\n\n // Track tool calls being built\n const toolCallsInProgress: Map<number, { id: string; name: string; arguments: string }> = new Map();\n\n // Don't start idle timer until first event - initial processing can take a while for large inputs\n let idleTimerStarted = false;\n\n for await (const event of stream) {\n // Start idle timer after first event (initial \"thinking\" time can be long)\n if (!idleTimerStarted) {\n idleTimerStarted = true;\n resetIdleTimer();\n } else {\n // Reset idle timer on subsequent events\n resetIdleTimer();\n }\n\n if (event.type === 'content_block_start') {\n if (event.content_block.type === 'tool_use') {\n const index = event.index;\n toolCallsInProgress.set(index, {\n id: event.content_block.id,\n name: event.content_block.name,\n arguments: '',\n });\n yield {\n type: 'tool_call_start',\n toolCall: {\n id: event.content_block.id,\n index,\n name: event.content_block.name,\n },\n };\n }\n } else if (event.type === 'content_block_delta') {\n if (event.delta.type === 'text_delta') {\n yield { type: 'text', text: event.delta.text };\n } else if (event.delta.type === 'input_json_delta') {\n const index = event.index;\n const toolCall = toolCallsInProgress.get(index);\n if (toolCall) {\n toolCall.arguments += event.delta.partial_json;\n yield {\n type: 'tool_call_delta',\n toolCall: {\n index,\n argumentsDelta: event.delta.partial_json,\n },\n };\n }\n }\n } else if (event.type === 'content_block_stop') {\n const index = event.index;\n const toolCall = toolCallsInProgress.get(index);\n if (toolCall) {\n yield {\n type: 'tool_call_end',\n toolCall: {\n id: toolCall.id,\n index,\n name: toolCall.name,\n },\n };\n }\n } else if (event.type === 'message_delta') {\n if (event.usage) {\n yield {\n type: 'usage',\n usage: {\n inputTokens: 0, // Input tokens come from message_start\n outputTokens: event.usage.output_tokens,\n },\n };\n }\n } else if (event.type === 'message_start') {\n // Capture input tokens from message_start, including cache stats\n if (event.message.usage) {\n const usage = event.message.usage as any; // Cache fields may not be in types yet\n yield {\n type: 'usage',\n usage: {\n inputTokens: usage.input_tokens,\n outputTokens: 0,\n cacheCreationInputTokens: usage.cache_creation_input_tokens || 0,\n cacheReadInputTokens: usage.cache_read_input_tokens || 0,\n },\n };\n }\n }\n }\n\n // Clear idle timer on successful completion\n clearIdleTimer();\n yield { type: 'done' };\n } catch (error) {\n // Clear idle timer on error\n clearIdleTimer();\n \n // Check if this was an abort due to idle timeout\n if (error instanceof Error && error.name === 'AbortError') {\n throw new Error(`Stream idle timeout: no data received for ${idleTimeoutMs / 1000} seconds. The API may be unresponsive.`);\n }\n \n // Check for common abort/connection errors and provide better messages\n if (error instanceof Error) {\n const msg = error.message.toLowerCase();\n if (msg.includes('aborted') || msg.includes('abort')) {\n throw new Error(`Request aborted: The connection to Anthropic was interrupted. This may be due to network issues or server-side timeout. Try again.`);\n }\n if (msg.includes('timeout')) {\n throw new Error(`Request timeout: The Anthropic API took too long to respond. Try with a smaller input or try again later.`);\n }\n if (msg.includes('econnreset') || msg.includes('socket hang up')) {\n throw new Error(`Connection reset: Lost connection to Anthropic API. Check your network and try again.`);\n }\n }\n \n throw createSafeError(error as Error, { provider: 'anthropic' });\n }\n }\n}\n\n/**\n * Create a new Anthropic provider instance\n */\nexport function createAnthropicProvider(): AnthropicProvider {\n return new AnthropicProvider();\n}\n\n/**\n * Package version\n */\nexport const VERSION = '0.0.1';\n\nexport default AnthropicProvider;\n"],"names":["undiciFetch","toolCalls"],"mappings":";;;;AAcO,SAAS,cAAkC;AAC9C,SACI,QAAQ,IAAI,eACZ,QAAQ,IAAI,eACZ,QAAQ,IAAI,cACZ,QAAQ,IAAI,cACZ;AAER;AAMO,SAAS,eAAwB;AACpC,SAAO,QAAQ,IAAI,iCAAiC;AACxD;AAKO,SAAS,gBAAgB,WAA4B;AACxD,QAAM,UAAU,QAAQ,IAAI,YAAY,QAAQ,IAAI;AACpD,MAAI,CAAC,SAAS;AACV,WAAO;AAAA,EACX;AAEA,MAAI;AACJ,MAAI;AACA,eAAW,IAAI,IAAI,SAAS,EAAE,SAAS,YAAA;AAAA,EAC3C,QAAQ;AACJ,WAAO;AAAA,EACX;AAEA,QAAM,UAAU,QAAQ,MAAM,GAAG,EAAE,IAAI,CAAC,MAAM,EAAE,KAAA,EAAO,YAAA,CAAa;AACpE,aAAW,SAAS,SAAS;AACzB,QAAI,CAAC,OAAO;AACR;AAAA,IACJ;AACA,QAAI,UAAU,KAAK;AACf,aAAO;AAAA,IACX;AACA,QAAI,aAAa,OAAO;AACpB,aAAO;AAAA,IACX;AACA,UAAM,SAAS,MAAM,WAAW,GAAG,IAAI,QAAQ,IAAI,KAAK;AACxD,QAAI,SAAS,SAAS,MAAM,GAAG;AAC3B,aAAO;AAAA,IACX;AAAA,EACJ;AACA,SAAO;AACX;AASO,SAAS,iBAAiB,UAAgC;AAC7D,QAAM,aAAa,IAAI,WAAW;AAAA,IAC9B,KAAK;AAAA,IACL,YAAY,EAAE,oBAAoB,aAAA,EAAa;AAAA,EAAE,CACpD;AACD,UAAQ,CAAC,OAAY,SAAe;AAChC,UAAM,YAAY,OAAO,UAAU,WAC7B,QACA,iBAAiB,MACb,MAAM,SAAA,IACN,MAAM;AAChB,QAAI,gBAAgB,SAAS,GAAG;AAC5B,aAAO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"],"sourcesContent":["/**\n * Proxy support for Anthropic API requests.\n *\n * When proxy environment variables are set, routes requests through the proxy\n * using undici's ProxyAgent. Respects NO_PROXY/no_proxy for bypass lists and\n * NODE_TLS_REJECT_UNAUTHORIZED for TLS verification.\n */\n\nimport { ProxyAgent, fetch as undiciFetch } from 'undici';\n\n/**\n * Get the proxy URL from environment variables.\n * Checks HTTPS_PROXY, https_proxy, HTTP_PROXY, http_proxy.\n */\nexport function getProxyUrl(): string | undefined {\n return (\n process.env.HTTPS_PROXY ||\n process.env.https_proxy ||\n process.env.HTTP_PROXY ||\n process.env.http_proxy ||\n undefined\n );\n}\n\n/**\n * Read TLS strict mode. Returns false only when NODE_TLS_REJECT_UNAUTHORIZED\n * is explicitly set to '0'.\n */\nexport function getStrictSSL(): boolean {\n return process.env.NODE_TLS_REJECT_UNAUTHORIZED !== '0';\n}\n\n/**\n * Check whether a target URL should bypass the proxy based on NO_PROXY / no_proxy.\n */\nexport function isProxyBypassed(targetUrl: string): boolean {\n const noProxy = process.env.NO_PROXY || process.env.no_proxy;\n if (!noProxy) {\n return false;\n }\n\n let hostname: string;\n try {\n hostname = new URL(targetUrl).hostname.toLowerCase();\n } catch {\n return false;\n }\n\n const entries = noProxy.split(',').map((e) => e.trim().toLowerCase());\n for (const entry of entries) {\n if (!entry) {\n continue;\n }\n if (entry === '*') {\n return true;\n }\n if (hostname === entry) {\n return true;\n }\n const suffix = entry.startsWith('.') ? entry : `.${entry}`;\n if (hostname.endsWith(suffix)) {\n return true;\n }\n }\n return false;\n}\n\n/**\n * Create a fetch implementation that routes requests through an HTTP(S) proxy.\n * Respects TLS verification settings and NO_PROXY bypass lists.\n *\n * @param proxyUrl - The proxy URL (e.g. https://proxy.example.com:8080)\n * @returns A fetch function that uses ProxyAgent as the dispatcher\n */\nexport function createProxyFetch(proxyUrl: string): typeof fetch {\n const proxyAgent = new ProxyAgent({\n uri: proxyUrl,\n requestTls: { rejectUnauthorized: getStrictSSL() },\n });\n return ((input: any, init?: any) => {\n const targetUrl = typeof input === 'string'\n ? input\n : input instanceof URL\n ? input.toString()\n : input.url;\n if (isProxyBypassed(targetUrl)) {\n return undiciFetch(input, init);\n }\n return undiciFetch(input, { ...init, dispatcher: proxyAgent });\n }) as any;\n}\n","/**\n * Execution Anthropic Package\n *\n * Anthropic provider implementation for LLM execution.\n *\n * @packageDocumentation\n */\n\nimport Anthropic from '@anthropic-ai/sdk';\nimport { getRedactor } from '@utilarium/offrecord';\nimport { getProxyUrl, createProxyFetch } from './proxy.js';\nimport { \n createSafeError, \n configureErrorSanitizer,\n configureSecretGuard,\n} from '@utilarium/spotclean';\n\n// Register Anthropic API key patterns on module load\nconst redactor = getRedactor();\nredactor.register({\n name: 'anthropic',\n patterns: [\n /sk-ant-[a-zA-Z0-9_-]+/g,\n /sk-ant-api\\d+-[a-zA-Z0-9_-]+/g,\n ],\n validator: (key: string) => /^sk-ant(-api\\d+)?-[a-zA-Z0-9_-]+$/.test(key),\n envVar: 'ANTHROPIC_API_KEY',\n description: 'Anthropic API keys',\n});\n\n// Configure spotclean for error sanitization\nconfigureErrorSanitizer({\n enabled: true,\n environment: process.env.NODE_ENV === 'production' ? 'production' : 'development',\n includeCorrelationId: true,\n sanitizeStackTraces: process.env.NODE_ENV === 'production',\n maxMessageLength: 500,\n});\n\nconfigureSecretGuard({\n enabled: true,\n redactionText: '[REDACTED]',\n preservePartial: false,\n preserveLength: 0,\n customPatterns: [\n { name: 'anthropic', pattern: /sk-ant-[a-zA-Z0-9_-]+/g, description: 'Anthropic API key' },\n { name: 'anthropic-api', pattern: /sk-ant-api\\d+-[a-zA-Z0-9_-]+/g, description: 'Anthropic API key' },\n ],\n});\n\n/**\n * Default model when the request and options omit `model`.\n * Uses the current flagship Sonnet; override with `ExecutionOptions.model` or `Request.model`.\n */\nexport const DEFAULT_ANTHROPIC_MODEL = 'claude-sonnet-4-6' as const;\n\n/** Stable API identifiers for the latest generation (see Anthropic models documentation). */\nexport const CLAUDE_OPUS_LATEST = 'claude-opus-4-6' as const;\nexport const CLAUDE_SONNET_LATEST = 'claude-sonnet-4-6' as const;\nexport const CLAUDE_HAIKU_LATEST = 'claude-haiku-4-5' as const;\n\nexport type { Model as AnthropicModel } from '@anthropic-ai/sdk/resources/messages/messages.js';\n\n// ===== INLINE TYPES (from 'execution' package) =====\n\nexport type Model = string;\n\nexport interface Message {\n role: 'user' | 'assistant' | 'system' | 'developer' | 'tool';\n content: string | string[] | null;\n name?: string;\n}\n\nexport interface ToolParameterSchema {\n type: 'object';\n properties: Record<string, {\n type: string;\n description?: string;\n enum?: string[];\n items?: { type: string };\n default?: any;\n }>;\n required?: string[];\n additionalProperties?: boolean;\n}\n\nexport interface ToolDefinition {\n name: string;\n description: string;\n parameters: ToolParameterSchema;\n}\n\nexport type StreamChunkType = 'text' | 'tool_call_start' | 'tool_call_delta' | 'tool_call_end' | 'usage' | 'done';\n\nexport interface StreamChunk {\n type: StreamChunkType;\n text?: string;\n toolCall?: {\n id?: string;\n index?: number;\n name?: string;\n argumentsDelta?: string;\n };\n usage?: {\n inputTokens: number;\n outputTokens: number;\n cacheCreationInputTokens?: number;\n cacheReadInputTokens?: number;\n };\n}\n\nexport interface Request {\n messages: Message[];\n model: Model;\n responseFormat?: any;\n validator?: any;\n tools?: ToolDefinition[];\n addMessage(message: Message): void;\n}\n\nexport interface ProviderResponse {\n content: string;\n model: string;\n usage?: {\n inputTokens: number;\n outputTokens: number;\n };\n toolCalls?: Array<{\n id: string;\n type: 'function';\n function: {\n name: string;\n arguments: string;\n };\n }>;\n}\n\nexport interface ExecutionOptions {\n apiKey?: string;\n model?: string;\n temperature?: number;\n maxTokens?: number;\n timeout?: number;\n retries?: number;\n}\n\nexport interface Provider {\n readonly name: string;\n execute(request: Request, options?: ExecutionOptions): Promise<ProviderResponse>;\n executeStream?(request: Request, options?: ExecutionOptions): AsyncIterable<StreamChunk>;\n supportsModel?(model: Model): boolean;\n}\n\n/**\n * Anthropic Provider implementation\n */\nexport class AnthropicProvider implements Provider {\n readonly name = 'anthropic';\n\n /**\n * Check if this provider supports a given model\n */\n supportsModel(model: Model): boolean {\n if (!model) return false;\n return model.startsWith('claude');\n }\n\n /**\n * Execute a request against Anthropic\n */\n async execute(\n request: Request,\n options: ExecutionOptions = {}\n ): Promise<ProviderResponse> {\n const apiKey = options.apiKey || process.env.ANTHROPIC_API_KEY;\n \n if (!apiKey) {\n throw new Error('Anthropic API key is required. Set ANTHROPIC_API_KEY environment variable.');\n }\n\n // Validate key format\n const validation = redactor.validateKey(apiKey, 'anthropic');\n if (!validation.valid) {\n throw new Error('Invalid Anthropic API key format');\n }\n\n try {\n const clientOptions: ConstructorParameters<typeof Anthropic>[0] = { apiKey };\n const proxyUrl = getProxyUrl();\n if (proxyUrl) {\n clientOptions.fetch = createProxyFetch(proxyUrl);\n }\n const client = new Anthropic(clientOptions);\n\n const model = options.model || request.model || DEFAULT_ANTHROPIC_MODEL;\n\n // Anthropic separates system prompt from messages\n let systemPrompt = '';\n const messages: Anthropic.MessageParam[] = [];\n\n for (const msg of request.messages) {\n if (msg.role === 'system' || msg.role === 'developer') {\n systemPrompt +=\n (typeof msg.content === 'string'\n ? msg.content\n : JSON.stringify(msg.content)) + '\\n\\n';\n } else if (msg.role === 'tool') {\n // Handle tool result messages - Anthropic expects these as user messages with tool_result content\n messages.push({\n role: 'user',\n content: [\n {\n type: 'tool_result',\n tool_use_id: (msg as any).tool_call_id || '',\n content: typeof msg.content === 'string' \n ? msg.content \n : JSON.stringify(msg.content),\n },\n ],\n });\n } else if (msg.role === 'assistant' && (msg as any).tool_calls) {\n // Handle assistant messages with tool calls\n const toolCalls = (msg as any).tool_calls;\n const content: Anthropic.ContentBlockParam[] = [];\n \n if (msg.content) {\n content.push({\n type: 'text',\n text: typeof msg.content === 'string' ? msg.content : JSON.stringify(msg.content),\n });\n }\n \n for (const tc of toolCalls) {\n // Parse arguments, defaulting to empty object if empty or invalid\n let input: Record<string, unknown> = {};\n if (tc.function.arguments && tc.function.arguments.trim()) {\n try {\n input = JSON.parse(tc.function.arguments);\n } catch {\n // If arguments can't be parsed, use empty object\n input = {};\n }\n }\n content.push({\n type: 'tool_use',\n id: tc.id,\n name: tc.function.name,\n input,\n });\n }\n \n messages.push({ role: 'assistant', content });\n } else {\n messages.push({\n role: msg.role as 'user' | 'assistant',\n content:\n typeof msg.content === 'string'\n ? msg.content\n : JSON.stringify(msg.content),\n });\n }\n }\n\n // Build tools array for the request\n let anthropicTools: Anthropic.Tool[] | undefined;\n let toolChoice: Anthropic.ToolChoice | undefined;\n\n if (request.responseFormat?.type === 'json_schema') {\n // JSON schema mode - use tool for structured output\n anthropicTools = [\n {\n name: request.responseFormat.json_schema.name,\n description:\n request.responseFormat.json_schema.description ||\n 'Output data in this structured format',\n input_schema:\n request.responseFormat.json_schema.schema,\n },\n ];\n toolChoice = {\n type: 'tool' as const,\n name: request.responseFormat.json_schema.name,\n };\n } else if (request.tools && request.tools.length > 0) {\n // Function calling mode - pass tools from request\n anthropicTools = request.tools.map((tool) => ({\n name: tool.name,\n description: tool.description,\n input_schema: tool.parameters as Anthropic.Tool.InputSchema,\n }));\n // Let the model decide when to use tools\n toolChoice = { type: 'auto' as const };\n }\n\n const response = await client.messages.create({\n model: model,\n system: systemPrompt.trim() || undefined,\n messages: messages,\n max_tokens: options.maxTokens || 50000,\n temperature: options.temperature,\n ...(anthropicTools ? { tools: anthropicTools } : {}),\n ...(toolChoice ? { tool_choice: toolChoice } : {}),\n });\n\n // Handle ContentBlock - extract text and tool calls\n let text = '';\n const toolCalls: Array<{\n id: string;\n type: 'function';\n function: { name: string; arguments: string };\n }> = [];\n\n for (const block of response.content) {\n if (block.type === 'text') {\n text += block.text;\n } else if (block.type === 'tool_use') {\n if (request.responseFormat?.type === 'json_schema') {\n // For JSON schema mode, return the tool input as text\n text = JSON.stringify(block.input, null, 2);\n } else {\n // For function calling mode, add to toolCalls array\n toolCalls.push({\n id: block.id,\n type: 'function',\n function: {\n name: block.name,\n arguments: JSON.stringify(block.input),\n },\n });\n }\n }\n }\n\n return {\n content: text,\n model: response.model,\n usage: {\n inputTokens: response.usage.input_tokens,\n outputTokens: response.usage.output_tokens,\n },\n ...(toolCalls.length > 0 ? { toolCalls } : {}),\n };\n } catch (error) {\n // Sanitize error to remove any API keys from error messages\n // Use spotclean for comprehensive error sanitization\n throw createSafeError(error as Error, { provider: 'anthropic' });\n }\n }\n\n /**\n * Execute a request with streaming response\n */\n async *executeStream(\n request: Request,\n options: ExecutionOptions = {}\n ): AsyncIterable<StreamChunk> {\n const apiKey = options.apiKey || process.env.ANTHROPIC_API_KEY;\n \n if (!apiKey) {\n throw new Error('Anthropic API key is required. Set ANTHROPIC_API_KEY environment variable.');\n }\n\n // Validate key format\n const validation = redactor.validateKey(apiKey, 'anthropic');\n if (!validation.valid) {\n throw new Error('Invalid Anthropic API key format');\n }\n\n // Idle timeout configuration (default 5 minutes)\n // This detects when the stream stops sending data mid-response\n // Set high because the model can take a long time to process large inputs\n // and decide on tool calls between streaming text chunks\n const idleTimeoutMs = options.timeout || 300000;\n let idleTimer: ReturnType<typeof setTimeout> | null = null;\n let abortController: AbortController | null = null;\n\n const resetIdleTimer = () => {\n if (idleTimer) {\n clearTimeout(idleTimer);\n }\n idleTimer = setTimeout(() => {\n if (abortController) {\n abortController.abort();\n }\n }, idleTimeoutMs);\n };\n\n const clearIdleTimer = () => {\n if (idleTimer) {\n clearTimeout(idleTimer);\n idleTimer = null;\n }\n };\n\n try {\n abortController = new AbortController();\n const clientOptions: ConstructorParameters<typeof Anthropic>[0] = { \n apiKey,\n // Set overall timeout (10 minutes default, or user-specified)\n timeout: options.timeout || 600000,\n };\n const proxyUrl = getProxyUrl();\n if (proxyUrl) {\n clientOptions.fetch = createProxyFetch(proxyUrl);\n }\n const client = new Anthropic(clientOptions);\n\n const model = options.model || request.model || DEFAULT_ANTHROPIC_MODEL;\n\n // Anthropic separates system prompt from messages\n let systemPrompt = '';\n const messages: Anthropic.MessageParam[] = [];\n\n for (const msg of request.messages) {\n if (msg.role === 'system' || msg.role === 'developer') {\n systemPrompt +=\n (typeof msg.content === 'string'\n ? msg.content\n : JSON.stringify(msg.content)) + '\\n\\n';\n } else if (msg.role === 'tool') {\n // Handle tool result messages\n messages.push({\n role: 'user',\n content: [\n {\n type: 'tool_result',\n tool_use_id: (msg as any).tool_call_id || '',\n content: typeof msg.content === 'string' \n ? msg.content \n : JSON.stringify(msg.content),\n },\n ],\n });\n } else if (msg.role === 'assistant' && (msg as any).tool_calls) {\n // Handle assistant messages with tool calls\n const toolCalls = (msg as any).tool_calls;\n const content: Anthropic.ContentBlockParam[] = [];\n \n if (msg.content) {\n content.push({\n type: 'text',\n text: typeof msg.content === 'string' ? msg.content : JSON.stringify(msg.content),\n });\n }\n \n for (const tc of toolCalls) {\n // Parse arguments, defaulting to empty object if empty or invalid\n let input: Record<string, unknown> = {};\n if (tc.function.arguments && tc.function.arguments.trim()) {\n try {\n input = JSON.parse(tc.function.arguments);\n } catch {\n // If arguments can't be parsed, use empty object\n input = {};\n }\n }\n content.push({\n type: 'tool_use',\n id: tc.id,\n name: tc.function.name,\n input,\n });\n }\n \n messages.push({ role: 'assistant', content });\n } else {\n messages.push({\n role: msg.role as 'user' | 'assistant',\n content:\n typeof msg.content === 'string'\n ? msg.content\n : JSON.stringify(msg.content),\n });\n }\n }\n\n // Build tools array\n let anthropicTools: Anthropic.Tool[] | undefined;\n if (request.tools && request.tools.length > 0) {\n anthropicTools = request.tools.map((tool) => ({\n name: tool.name,\n description: tool.description,\n input_schema: tool.parameters as Anthropic.Tool.InputSchema,\n }));\n }\n\n // Build system prompt with cache control for prompt caching\n // Cache the system prompt since it's the same across turns\n const systemBlocks: Anthropic.TextBlockParam[] = systemPrompt.trim() \n ? [{\n type: 'text' as const,\n text: systemPrompt.trim(),\n cache_control: { type: 'ephemeral' as const },\n }]\n : [];\n\n const stream = client.messages.stream({\n model: model,\n system: systemBlocks.length > 0 ? systemBlocks : undefined,\n messages: messages,\n max_tokens: options.maxTokens || 50000, // High default for tool calls with large content\n temperature: options.temperature,\n ...(anthropicTools ? { tools: anthropicTools, tool_choice: { type: 'auto' as const } } : {}),\n }, {\n signal: abortController.signal,\n });\n\n // Track tool calls being built\n const toolCallsInProgress: Map<number, { id: string; name: string; arguments: string }> = new Map();\n\n // Don't start idle timer until first event - initial processing can take a while for large inputs\n let idleTimerStarted = false;\n\n for await (const event of stream) {\n // Start idle timer after first event (initial \"thinking\" time can be long)\n if (!idleTimerStarted) {\n idleTimerStarted = true;\n resetIdleTimer();\n } else {\n // Reset idle timer on subsequent events\n resetIdleTimer();\n }\n\n if (event.type === 'content_block_start') {\n if (event.content_block.type === 'tool_use') {\n const index = event.index;\n toolCallsInProgress.set(index, {\n id: event.content_block.id,\n name: event.content_block.name,\n arguments: '',\n });\n yield {\n type: 'tool_call_start',\n toolCall: {\n id: event.content_block.id,\n index,\n name: event.content_block.name,\n },\n };\n }\n } else if (event.type === 'content_block_delta') {\n if (event.delta.type === 'text_delta') {\n yield { type: 'text', text: event.delta.text };\n } else if (event.delta.type === 'input_json_delta') {\n const index = event.index;\n const toolCall = toolCallsInProgress.get(index);\n if (toolCall) {\n toolCall.arguments += event.delta.partial_json;\n yield {\n type: 'tool_call_delta',\n toolCall: {\n index,\n argumentsDelta: event.delta.partial_json,\n },\n };\n }\n }\n } else if (event.type === 'content_block_stop') {\n const index = event.index;\n const toolCall = toolCallsInProgress.get(index);\n if (toolCall) {\n yield {\n type: 'tool_call_end',\n toolCall: {\n id: toolCall.id,\n index,\n name: toolCall.name,\n },\n };\n }\n } else if (event.type === 'message_delta') {\n if (event.usage) {\n yield {\n type: 'usage',\n usage: {\n inputTokens: 0, // Input tokens come from message_start\n outputTokens: event.usage.output_tokens,\n },\n };\n }\n } else if (event.type === 'message_start') {\n // Capture input tokens from message_start, including cache stats\n if (event.message.usage) {\n const usage = event.message.usage as any; // Cache fields may not be in types yet\n yield {\n type: 'usage',\n usage: {\n inputTokens: usage.input_tokens,\n outputTokens: 0,\n cacheCreationInputTokens: usage.cache_creation_input_tokens || 0,\n cacheReadInputTokens: usage.cache_read_input_tokens || 0,\n },\n };\n }\n }\n }\n\n // Clear idle timer on successful completion\n clearIdleTimer();\n yield { type: 'done' };\n } catch (error) {\n // Clear idle timer on error\n clearIdleTimer();\n \n // Check if this was an abort due to idle timeout\n if (error instanceof Error && error.name === 'AbortError') {\n throw new Error(`Stream idle timeout: no data received for ${idleTimeoutMs / 1000} seconds. The API may be unresponsive.`);\n }\n \n // Check for common abort/connection errors and provide better messages\n if (error instanceof Error) {\n const msg = error.message.toLowerCase();\n if (msg.includes('aborted') || msg.includes('abort')) {\n throw new Error(`Request aborted: The connection to Anthropic was interrupted. This may be due to network issues or server-side timeout. Try again.`);\n }\n if (msg.includes('timeout')) {\n throw new Error(`Request timeout: The Anthropic API took too long to respond. Try with a smaller input or try again later.`);\n }\n if (msg.includes('econnreset') || msg.includes('socket hang up')) {\n throw new Error(`Connection reset: Lost connection to Anthropic API. Check your network and try again.`);\n }\n }\n \n throw createSafeError(error as Error, { provider: 'anthropic' });\n }\n }\n}\n\n/**\n * Create a new Anthropic provider instance\n */\nexport function createAnthropicProvider(): AnthropicProvider {\n return new AnthropicProvider();\n}\n\n/**\n * Package version\n */\nexport const VERSION = '0.0.1';\n\nexport default AnthropicProvider;\n"],"names":["undiciFetch","toolCalls"],"mappings":";;;;AAcO,SAAS,cAAkC;AAC9C,SACI,QAAQ,IAAI,eACZ,QAAQ,IAAI,eACZ,QAAQ,IAAI,cACZ,QAAQ,IAAI,cACZ;AAER;AAMO,SAAS,eAAwB;AACpC,SAAO,QAAQ,IAAI,iCAAiC;AACxD;AAKO,SAAS,gBAAgB,WAA4B;AACxD,QAAM,UAAU,QAAQ,IAAI,YAAY,QAAQ,IAAI;AACpD,MAAI,CAAC,SAAS;AACV,WAAO;AAAA,EACX;AAEA,MAAI;AACJ,MAAI;AACA,eAAW,IAAI,IAAI,SAAS,EAAE,SAAS,YAAA;AAAA,EAC3C,QAAQ;AACJ,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;AAAA,QACJ;AAAA,MACJ;AAGA,qBAAA;AACA,YAAM,EAAE,MAAM,OAAA;AAAA,IAClB,SAAS,OAAO;AAEZ,qBAAA;AAGA,UAAI,iBAAiB,SAAS,MAAM,SAAS,cAAc;AACvD,cAAM,IAAI,MAAM,6CAA6C,gBAAgB,GAAI,wCAAwC;AAAA,MAC7H;AAGA,UAAI,iBAAiB,OAAO;AACxB,cAAM,MAAM,MAAM,QAAQ,YAAA;AAC1B,YAAI,IAAI,SAAS,SAAS,KAAK,IAAI,SAAS,OAAO,GAAG;AAClD,gBAAM,IAAI,MAAM,oIAAoI;AAAA,QACxJ;AACA,YAAI,IAAI,SAAS,SAAS,GAAG;AACzB,gBAAM,IAAI,MAAM,2GAA2G;AAAA,QAC/H;AACA,YAAI,IAAI,SAAS,YAAY,KAAK,IAAI,SAAS,gBAAgB,GAAG;AAC9D,gBAAM,IAAI,MAAM,uFAAuF;AAAA,QAC3G;AAAA,MACJ;AAEA,YAAM,gBAAgB,OAAgB,EAAE,UAAU,aAAa;AAAA,IACnE;AAAA,EACJ;AACJ;AAKO,SAAS,0BAA6C;AACzD,SAAO,IAAI,kBAAA;AACf;AAKO,MAAM,UAAU;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kjerneverk/execution-anthropic",
3
- "version": "1.0.13",
3
+ "version": "1.0.14-dev.20260320165141.9296346",
4
4
  "description": "Anthropic Claude provider for execution interface",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -37,7 +37,7 @@
37
37
  "url": "https://github.com/kjerneverk/execution-anthropic"
38
38
  },
39
39
  "dependencies": {
40
- "@anthropic-ai/sdk": "^0.74.0",
40
+ "@anthropic-ai/sdk": "^0.80.0",
41
41
  "@utilarium/offrecord": "^0.0.3",
42
42
  "@utilarium/spotclean": "^0.0.4",
43
43
  "undici": "^7.21.0"