@kjerneverk/execution-anthropic 1.0.12-dev.20260302165854.a3b0454 → 1.0.12

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/dist/index.js CHANGED
@@ -3,11 +3,52 @@ import { getRedactor } from "@utilarium/offrecord";
3
3
  import { ProxyAgent, fetch } from "undici";
4
4
  import { configureErrorSanitizer, configureSecretGuard, createSafeError } from "@utilarium/spotclean";
5
5
  function getProxyUrl() {
6
- return process.env.https_proxy || process.env.HTTPS_PROXY;
6
+ return process.env.HTTPS_PROXY || process.env.https_proxy || process.env.HTTP_PROXY || process.env.http_proxy || void 0;
7
+ }
8
+ function getStrictSSL() {
9
+ return process.env.NODE_TLS_REJECT_UNAUTHORIZED !== "0";
10
+ }
11
+ function isProxyBypassed(targetUrl) {
12
+ const noProxy = process.env.NO_PROXY || process.env.no_proxy;
13
+ if (!noProxy) {
14
+ return false;
15
+ }
16
+ let hostname;
17
+ try {
18
+ hostname = new URL(targetUrl).hostname.toLowerCase();
19
+ } catch {
20
+ return false;
21
+ }
22
+ const entries = noProxy.split(",").map((e) => e.trim().toLowerCase());
23
+ for (const entry of entries) {
24
+ if (!entry) {
25
+ continue;
26
+ }
27
+ if (entry === "*") {
28
+ return true;
29
+ }
30
+ if (hostname === entry) {
31
+ return true;
32
+ }
33
+ const suffix = entry.startsWith(".") ? entry : `.${entry}`;
34
+ if (hostname.endsWith(suffix)) {
35
+ return true;
36
+ }
37
+ }
38
+ return false;
7
39
  }
8
40
  function createProxyFetch(proxyUrl) {
9
- const proxyAgent = new ProxyAgent(proxyUrl);
10
- return (input, init) => fetch(input, { ...init, dispatcher: proxyAgent });
41
+ const proxyAgent = new ProxyAgent({
42
+ uri: proxyUrl,
43
+ requestTls: { rejectUnauthorized: getStrictSSL() }
44
+ });
45
+ return ((input, init) => {
46
+ const targetUrl = typeof input === "string" ? input : input instanceof URL ? input.toString() : input.url;
47
+ if (isProxyBypassed(targetUrl)) {
48
+ return fetch(input, init);
49
+ }
50
+ return fetch(input, { ...init, dispatcher: proxyAgent });
51
+ });
11
52
  }
12
53
  const redactor = getRedactor();
13
54
  redactor.register({
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 HTTPS_PROXY or https_proxy is set, routes requests through the proxy\n * using undici's ProxyAgent. Required for environments behind corporate\n * firewalls that require proxy access to reach Anthropic API.\n */\n\nimport { ProxyAgent, fetch as undiciFetch } from 'undici';\n\n/**\n * Get the proxy URL from environment variables.\n * Checks HTTPS_PROXY and https_proxy (lowercase takes precedence per convention).\n */\nexport function getProxyUrl(): string | undefined {\n return process.env.https_proxy || process.env.HTTPS_PROXY;\n}\n\n/**\n * Create a fetch implementation that routes requests through an HTTP(S) proxy.\n * Use when initializing Anthropic SDK client in proxied environments.\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(proxyUrl);\n return (input: string | URL | Request, init?: RequestInit) =>\n undiciFetch(input, { ...init, dispatcher: proxyAgent });\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,SAAO,QAAQ,IAAI,eAAe,QAAQ,IAAI;AAClD;AASO,SAAS,iBAAiB,UAAgC;AAC7D,QAAM,aAAa,IAAI,WAAW,QAAQ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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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AI,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.12-dev.20260302165854.a3b0454",
3
+ "version": "1.0.12",
4
4
  "description": "Anthropic Claude provider for execution interface",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",