@better-agent/providers 0.1.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/anthropic/index.d.mts +1196 -0
- package/dist/anthropic/index.d.mts.map +1 -0
- package/dist/anthropic/index.mjs +1909 -0
- package/dist/anthropic/index.mjs.map +1 -0
- package/dist/fetch-CW0dWlVC.mjs +84 -0
- package/dist/fetch-CW0dWlVC.mjs.map +1 -0
- package/dist/openai/index.d.mts +1629 -0
- package/dist/openai/index.d.mts.map +1 -0
- package/dist/openai/index.mjs +6690 -0
- package/dist/openai/index.mjs.map +1 -0
- package/dist/xai/index.d.mts +382 -0
- package/dist/xai/index.d.mts.map +1 -0
- package/dist/xai/index.mjs +1277 -0
- package/dist/xai/index.mjs.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["createAnthropicHttpClient"],"sources":["../../src/anthropic/client/auth.ts","../../src/anthropic/client/errors.ts","../../src/anthropic/responses/schemas.ts","../../src/anthropic/client/stream.ts","../../src/anthropic/client/create-client.ts","../../src/anthropic/tools/index.ts","../../src/anthropic/responses/mappers.ts","../../src/anthropic/responses/model.ts","../../src/anthropic/provider.ts"],"sourcesContent":["import type { AnthropicConfig } from \"../types\";\n\ntype BuildAnthropicHeadersOptions = {\n beta?: string[];\n headers?: Record<string, string>;\n};\n\nexport const buildAnthropicHeaders = (\n config: AnthropicConfig,\n options: BuildAnthropicHeadersOptions = {},\n): Record<string, string> => {\n const headers: Record<string, string> = {\n \"anthropic-version\": config.anthropicVersion ?? \"2023-06-01\",\n ...(config.headers ?? {}),\n ...(options.headers ?? {}),\n };\n\n if (config.authToken) {\n headers.Authorization = `Bearer ${config.authToken}`;\n } else if (config.apiKey) {\n headers[\"x-api-key\"] = config.apiKey;\n }\n\n if (options.beta?.length) {\n headers[\"anthropic-beta\"] = options.beta.join(\",\");\n }\n\n return headers;\n};\n","import { BetterAgentError } from \"@better-agent/shared/errors\";\n\nimport type { AnthropicError } from \"../types\";\n\nexport type AnthropicHttpError = {\n status: number;\n statusText: string;\n error?: AnthropicError[\"error\"];\n};\n\nexport const mapAnthropicHttpError = (\n httpError: AnthropicHttpError | undefined,\n ctx: {\n at: string;\n path: string;\n },\n): BetterAgentError => {\n if (!httpError) {\n return BetterAgentError.fromCode(\"UPSTREAM_FAILED\", \"Anthropic request failed\", {\n context: {\n provider: \"anthropic\",\n },\n }).at({\n at: ctx.at,\n data: {\n path: ctx.path,\n },\n });\n }\n\n const { status, statusText, error } = httpError;\n const message = error?.message ?? statusText ?? \"Anthropic request failed\";\n const code = String(error?.type ?? status);\n\n return BetterAgentError.fromCode(\"UPSTREAM_FAILED\", message, {\n status,\n context: {\n provider: \"anthropic\",\n upstreamCode: code,\n raw: error,\n },\n }).at({\n at: ctx.at,\n data: {\n path: ctx.path,\n status,\n },\n });\n};\n","import { z } from \"zod\";\n\nexport const ANTHROPIC_KNOWN_RESPONSE_MODELS = [\n \"claude-3-haiku-20240307\",\n \"claude-haiku-4-5-20251001\",\n \"claude-haiku-4-5\",\n \"claude-opus-4-0\",\n \"claude-opus-4-20250514\",\n \"claude-opus-4-1-20250805\",\n \"claude-opus-4-1\",\n \"claude-opus-4-5\",\n \"claude-opus-4-5-20251101\",\n \"claude-sonnet-4-0\",\n \"claude-sonnet-4-20250514\",\n \"claude-sonnet-4-5-20250929\",\n \"claude-sonnet-4-5\",\n \"claude-sonnet-4-6\",\n \"claude-opus-4-6\",\n] as const;\n\nexport type AnthropicMessagesRequestSchema = z.input<typeof AnthropicMessagesRequestSchema>;\nexport type AnthropicMessagesResponseSchema = z.infer<typeof AnthropicMessagesResponseSchema>;\nexport type AnthropicMessagesResponse = z.infer<typeof AnthropicMessagesResponseSchema>;\nexport type AnthropicResponseStreamEvent = z.infer<typeof AnthropicResponseStreamEventSchema>;\nexport type AnthropicResponseModels = (typeof ANTHROPIC_KNOWN_RESPONSE_MODELS)[number];\n\nexport const AnthropicKnownResponseModelsSchema = z.enum(ANTHROPIC_KNOWN_RESPONSE_MODELS);\nexport const AnthropicResponseModelIdSchema = z.string();\n\nexport const AnthropicCacheControlSchema = z.object({\n type: z.literal(\"ephemeral\"),\n ttl: z.enum([\"5m\", \"1h\"]).optional(),\n});\n\nconst AnthropicTextContentSchema = z.object({\n type: z.literal(\"text\"),\n text: z.string(),\n citations: z.array(z.unknown()).optional(),\n cache_control: AnthropicCacheControlSchema.optional(),\n});\n\nconst AnthropicThinkingContentSchema = z.object({\n type: z.literal(\"thinking\"),\n thinking: z.string(),\n signature: z.string(),\n});\n\nconst AnthropicRedactedThinkingContentSchema = z.object({\n type: z.literal(\"redacted_thinking\"),\n data: z.string(),\n});\n\nconst AnthropicContentSourceSchema = z.discriminatedUnion(\"type\", [\n z.object({\n type: z.literal(\"base64\"),\n media_type: z.string(),\n data: z.string(),\n }),\n z.object({\n type: z.literal(\"url\"),\n url: z.string(),\n }),\n z.object({\n type: z.literal(\"text\"),\n media_type: z.literal(\"text/plain\"),\n data: z.string(),\n }),\n]);\n\nconst AnthropicImageContentSchema = z.object({\n type: z.literal(\"image\"),\n source: AnthropicContentSourceSchema,\n cache_control: AnthropicCacheControlSchema.optional(),\n});\n\nconst AnthropicDocumentContentSchema = z.object({\n type: z.literal(\"document\"),\n source: AnthropicContentSourceSchema,\n title: z.string().optional(),\n context: z.string().optional(),\n citations: z.object({ enabled: z.boolean() }).optional(),\n cache_control: AnthropicCacheControlSchema.optional(),\n});\n\nconst AnthropicToolResultContentSchema = z.object({\n type: z.literal(\"tool_result\"),\n tool_use_id: z.string(),\n content: z.union([z.string(), z.array(z.unknown())]),\n is_error: z.boolean().optional(),\n cache_control: AnthropicCacheControlSchema.optional(),\n});\n\nconst AnthropicToolCallContentSchema = z.object({\n type: z.literal(\"tool_use\"),\n id: z.string(),\n name: z.string(),\n input: z.unknown(),\n cache_control: AnthropicCacheControlSchema.optional(),\n});\n\nconst AnthropicServerToolUseContentSchema = z.object({\n type: z.literal(\"server_tool_use\"),\n id: z.string(),\n name: z.enum([\n \"web_fetch\",\n \"web_search\",\n \"code_execution\",\n \"bash_code_execution\",\n \"text_editor_code_execution\",\n \"tool_search_tool_regex\",\n \"tool_search_tool_bm25\",\n ]),\n input: z.unknown(),\n cache_control: AnthropicCacheControlSchema.optional(),\n});\n\nconst AnthropicProviderToolResultSchema = z\n .object({\n tool_use_id: z.string(),\n cache_control: AnthropicCacheControlSchema.optional(),\n })\n .passthrough();\n\nconst AnthropicWebSearchToolResultContentSchema = AnthropicProviderToolResultSchema.extend({\n type: z.literal(\"web_search_tool_result\"),\n content: z.array(\n z.object({\n url: z.string(),\n title: z.string().nullable(),\n page_age: z.string().nullable(),\n encrypted_content: z.string(),\n type: z.string(),\n }),\n ),\n});\n\nconst AnthropicWebFetchToolResultContentSchema = AnthropicProviderToolResultSchema.extend({\n type: z.literal(\"web_fetch_tool_result\"),\n content: z.unknown(),\n});\n\nconst AnthropicToolSearchToolResultContentSchema = AnthropicProviderToolResultSchema.extend({\n type: z.literal(\"tool_search_tool_result\"),\n content: z.unknown(),\n});\n\nconst AnthropicCodeExecutionToolResultContentSchema = AnthropicProviderToolResultSchema.extend({\n type: z.literal(\"code_execution_tool_result\"),\n content: z.unknown(),\n});\n\nconst AnthropicBashCodeExecutionToolResultContentSchema = AnthropicProviderToolResultSchema.extend({\n type: z.literal(\"bash_code_execution_tool_result\"),\n content: z.unknown(),\n});\n\nconst AnthropicTextEditorCodeExecutionToolResultContentSchema =\n AnthropicProviderToolResultSchema.extend({\n type: z.literal(\"text_editor_code_execution_tool_result\"),\n content: z.unknown(),\n });\n\nconst AnthropicMcpToolUseContentSchema = z\n .object({\n type: z.literal(\"mcp_tool_use\"),\n id: z.string(),\n name: z.string(),\n server_name: z.string().optional(),\n input: z.unknown(),\n cache_control: AnthropicCacheControlSchema.optional(),\n })\n .passthrough();\n\nconst AnthropicMcpToolResultContentSchema = z\n .object({\n type: z.literal(\"mcp_tool_result\"),\n tool_use_id: z.string(),\n content: z.unknown(),\n is_error: z.boolean().optional(),\n cache_control: AnthropicCacheControlSchema.optional(),\n })\n .passthrough();\n\nconst AnthropicCompactionContentSchema = z.object({\n type: z.literal(\"compaction\"),\n content: z.string(),\n cache_control: AnthropicCacheControlSchema.optional(),\n});\n\nexport const AnthropicResponseContentBlockSchema = z.discriminatedUnion(\"type\", [\n AnthropicTextContentSchema,\n AnthropicThinkingContentSchema,\n AnthropicRedactedThinkingContentSchema,\n AnthropicImageContentSchema,\n AnthropicDocumentContentSchema,\n AnthropicToolResultContentSchema,\n AnthropicToolCallContentSchema,\n AnthropicServerToolUseContentSchema,\n AnthropicWebSearchToolResultContentSchema,\n AnthropicWebFetchToolResultContentSchema,\n AnthropicToolSearchToolResultContentSchema,\n AnthropicCodeExecutionToolResultContentSchema,\n AnthropicBashCodeExecutionToolResultContentSchema,\n AnthropicTextEditorCodeExecutionToolResultContentSchema,\n AnthropicMcpToolUseContentSchema,\n AnthropicMcpToolResultContentSchema,\n AnthropicCompactionContentSchema,\n]);\n\nconst AnthropicMessageSchema = z.object({\n role: z.enum([\"user\", \"assistant\"]),\n content: z.array(\n z.union([\n AnthropicTextContentSchema,\n AnthropicImageContentSchema,\n AnthropicDocumentContentSchema,\n AnthropicToolResultContentSchema,\n AnthropicThinkingContentSchema,\n AnthropicRedactedThinkingContentSchema,\n AnthropicToolCallContentSchema,\n AnthropicServerToolUseContentSchema,\n AnthropicWebSearchToolResultContentSchema,\n AnthropicWebFetchToolResultContentSchema,\n AnthropicToolSearchToolResultContentSchema,\n AnthropicCodeExecutionToolResultContentSchema,\n AnthropicBashCodeExecutionToolResultContentSchema,\n AnthropicTextEditorCodeExecutionToolResultContentSchema,\n AnthropicMcpToolUseContentSchema,\n AnthropicMcpToolResultContentSchema,\n AnthropicCompactionContentSchema,\n ]),\n ),\n});\n\nconst AnthropicMetadataSchema = z.object({\n user_id: z.string().optional(),\n});\n\nconst AnthropicThinkingConfigSchema = z.discriminatedUnion(\"type\", [\n z.object({\n type: z.literal(\"adaptive\"),\n }),\n z.object({\n type: z.literal(\"enabled\"),\n budget_tokens: z.number().optional(),\n }),\n z.object({\n type: z.literal(\"disabled\"),\n }),\n]);\n\nconst AnthropicToolChoiceSchema = z.discriminatedUnion(\"type\", [\n z.object({\n type: z.literal(\"auto\"),\n disable_parallel_tool_use: z.boolean().optional(),\n }),\n z.object({\n type: z.literal(\"any\"),\n disable_parallel_tool_use: z.boolean().optional(),\n }),\n z.object({\n type: z.literal(\"tool\"),\n name: z.string(),\n disable_parallel_tool_use: z.boolean().optional(),\n }),\n]);\n\nconst AnthropicFunctionToolSchema = z.object({\n name: z.string(),\n description: z.string().optional(),\n input_schema: z.record(z.string(), z.unknown()),\n cache_control: AnthropicCacheControlSchema.optional(),\n strict: z.boolean().optional(),\n eager_input_streaming: z.boolean().optional(),\n defer_loading: z.boolean().optional(),\n allowed_callers: z\n .array(z.enum([\"direct\", \"code_execution_20250825\", \"code_execution_20260120\"]))\n .optional(),\n input_examples: z.array(z.unknown()).optional(),\n});\n\nconst AnthropicCodeExecution20250522ToolSchema = z.object({\n type: z.literal(\"code_execution_20250522\"),\n name: z.literal(\"code_execution\"),\n cache_control: AnthropicCacheControlSchema.optional(),\n});\n\nconst AnthropicCodeExecution20250825ToolSchema = z.object({\n type: z.literal(\"code_execution_20250825\"),\n name: z.literal(\"code_execution\"),\n});\n\nconst AnthropicCodeExecution20260120ToolSchema = z.object({\n type: z.literal(\"code_execution_20260120\"),\n name: z.literal(\"code_execution\"),\n});\n\nconst AnthropicComputerBaseToolSchema = z.object({\n display_width_px: z.number().int(),\n display_height_px: z.number().int(),\n display_number: z.number().int().optional(),\n cache_control: AnthropicCacheControlSchema.optional(),\n});\n\nconst AnthropicComputer20241022ToolSchema = AnthropicComputerBaseToolSchema.extend({\n type: z.literal(\"computer_20241022\"),\n name: z.literal(\"computer\"),\n});\n\nconst AnthropicComputer20250124ToolSchema = AnthropicComputerBaseToolSchema.extend({\n type: z.literal(\"computer_20250124\"),\n name: z.literal(\"computer\"),\n});\n\nconst AnthropicComputer20251124ToolSchema = AnthropicComputerBaseToolSchema.extend({\n type: z.literal(\"computer_20251124\"),\n name: z.literal(\"computer\"),\n enable_zoom: z.boolean().optional(),\n});\n\nconst AnthropicTextEditor20241022ToolSchema = z.object({\n type: z.literal(\"text_editor_20241022\"),\n name: z.literal(\"str_replace_editor\"),\n cache_control: AnthropicCacheControlSchema.optional(),\n});\n\nconst AnthropicTextEditor20250124ToolSchema = z.object({\n type: z.literal(\"text_editor_20250124\"),\n name: z.literal(\"str_replace_editor\"),\n cache_control: AnthropicCacheControlSchema.optional(),\n});\n\nconst AnthropicTextEditor20250429ToolSchema = z.object({\n type: z.literal(\"text_editor_20250429\"),\n name: z.literal(\"str_replace_based_edit_tool\"),\n cache_control: AnthropicCacheControlSchema.optional(),\n});\n\nconst AnthropicTextEditor20250728ToolSchema = z.object({\n type: z.literal(\"text_editor_20250728\"),\n name: z.literal(\"str_replace_based_edit_tool\"),\n max_characters: z.number().optional(),\n cache_control: AnthropicCacheControlSchema.optional(),\n});\n\nconst AnthropicBash20241022ToolSchema = z.object({\n type: z.literal(\"bash_20241022\"),\n name: z.literal(\"bash\"),\n cache_control: AnthropicCacheControlSchema.optional(),\n});\n\nconst AnthropicBash20250124ToolSchema = z.object({\n type: z.literal(\"bash_20250124\"),\n name: z.literal(\"bash\"),\n cache_control: AnthropicCacheControlSchema.optional(),\n});\n\nconst AnthropicMemory20250818ToolSchema = z.object({\n type: z.literal(\"memory_20250818\"),\n name: z.literal(\"memory\"),\n});\n\nconst AnthropicWebSearchUserLocationSchema = z.object({\n type: z.literal(\"approximate\"),\n city: z.string().optional(),\n region: z.string().optional(),\n country: z.string().optional(),\n timezone: z.string().optional(),\n});\n\nconst AnthropicWebSearch20250305ToolSchema = z.object({\n type: z.literal(\"web_search_20250305\"),\n name: z.literal(\"web_search\"),\n max_uses: z.number().optional(),\n allowed_domains: z.array(z.string()).optional(),\n blocked_domains: z.array(z.string()).optional(),\n user_location: AnthropicWebSearchUserLocationSchema.optional(),\n cache_control: AnthropicCacheControlSchema.optional(),\n});\n\nconst AnthropicWebSearch20260209ToolSchema = z.object({\n type: z.literal(\"web_search_20260209\"),\n name: z.literal(\"web_search\"),\n max_uses: z.number().optional(),\n allowed_domains: z.array(z.string()).optional(),\n blocked_domains: z.array(z.string()).optional(),\n user_location: AnthropicWebSearchUserLocationSchema.optional(),\n cache_control: AnthropicCacheControlSchema.optional(),\n});\n\nconst AnthropicWebFetchBaseToolSchema = z.object({\n max_uses: z.number().optional(),\n allowed_domains: z.array(z.string()).optional(),\n blocked_domains: z.array(z.string()).optional(),\n citations: z.object({ enabled: z.boolean() }).optional(),\n max_content_tokens: z.number().optional(),\n cache_control: AnthropicCacheControlSchema.optional(),\n});\n\nconst AnthropicWebFetch20250910ToolSchema = AnthropicWebFetchBaseToolSchema.extend({\n type: z.literal(\"web_fetch_20250910\"),\n name: z.literal(\"web_fetch\"),\n});\n\nconst AnthropicWebFetch20260209ToolSchema = AnthropicWebFetchBaseToolSchema.extend({\n type: z.literal(\"web_fetch_20260209\"),\n name: z.literal(\"web_fetch\"),\n});\n\nconst AnthropicToolSearchRegex20251119ToolSchema = z.object({\n type: z.literal(\"tool_search_tool_regex_20251119\"),\n name: z.literal(\"tool_search_tool_regex\"),\n});\n\nconst AnthropicToolSearchBm2520251119ToolSchema = z.object({\n type: z.literal(\"tool_search_tool_bm25_20251119\"),\n name: z.literal(\"tool_search_tool_bm25\"),\n});\n\nexport const AnthropicHostedToolRequestSchema = z.union([\n AnthropicCodeExecution20250522ToolSchema,\n AnthropicCodeExecution20250825ToolSchema,\n AnthropicCodeExecution20260120ToolSchema,\n AnthropicComputer20241022ToolSchema,\n AnthropicComputer20250124ToolSchema,\n AnthropicComputer20251124ToolSchema,\n AnthropicTextEditor20241022ToolSchema,\n AnthropicTextEditor20250124ToolSchema,\n AnthropicTextEditor20250429ToolSchema,\n AnthropicTextEditor20250728ToolSchema,\n AnthropicBash20241022ToolSchema,\n AnthropicBash20250124ToolSchema,\n AnthropicMemory20250818ToolSchema,\n AnthropicWebSearch20250305ToolSchema,\n AnthropicWebSearch20260209ToolSchema,\n AnthropicWebFetch20250910ToolSchema,\n AnthropicWebFetch20260209ToolSchema,\n AnthropicToolSearchRegex20251119ToolSchema,\n AnthropicToolSearchBm2520251119ToolSchema,\n]);\n\nexport const AnthropicMessagesToolSchema = z.union([\n AnthropicFunctionToolSchema,\n AnthropicHostedToolRequestSchema,\n]);\n\nexport const AnthropicMessagesRequestSchema = z\n .object({\n model: AnthropicResponseModelIdSchema,\n max_tokens: z.number().int().positive(),\n messages: z.array(AnthropicMessageSchema),\n system: z.union([z.string(), z.array(AnthropicTextContentSchema)]).optional(),\n cache_control: AnthropicCacheControlSchema.optional(),\n metadata: AnthropicMetadataSchema.optional(),\n output_config: z\n .object({\n effort: z.enum([\"low\", \"medium\", \"high\", \"max\"]).optional(),\n format: z\n .object({\n type: z.literal(\"json_schema\"),\n schema: z.record(z.string(), z.unknown()),\n })\n .optional(),\n })\n .optional(),\n stop_sequences: z.array(z.string()).optional(),\n stream: z.boolean().optional(),\n speed: z.enum([\"fast\", \"standard\"]).optional(),\n temperature: z.number().optional(),\n thinking: AnthropicThinkingConfigSchema.optional(),\n tool_choice: AnthropicToolChoiceSchema.optional(),\n tools: z.array(AnthropicMessagesToolSchema).optional(),\n top_k: z.number().optional(),\n top_p: z.number().optional(),\n mcp_servers: z\n .array(\n z.object({\n type: z.literal(\"url\"),\n name: z.string(),\n url: z.string(),\n authorization_token: z.string().nullish(),\n tool_configuration: z\n .object({\n enabled: z.boolean().nullish(),\n allowed_tools: z.array(z.string()).nullish(),\n })\n .nullish(),\n }),\n )\n .optional(),\n container: z\n .object({\n id: z.string().optional(),\n skills: z\n .array(\n z.object({\n type: z.enum([\"anthropic\", \"custom\"]),\n skill_id: z.string(),\n version: z.string().optional(),\n }),\n )\n .optional(),\n })\n .optional(),\n context_management: z\n .object({\n edits: z.array(z.unknown()),\n })\n .optional(),\n })\n .passthrough();\n\nconst AnthropicUsageSchema = z.object({\n input_tokens: z.number().int().optional(),\n output_tokens: z.number().int().optional(),\n cache_creation_input_tokens: z.number().int().optional(),\n cache_read_input_tokens: z.number().int().optional(),\n iterations: z\n .array(\n z.object({\n type: z.enum([\"compaction\", \"message\"]),\n input_tokens: z.number().int(),\n output_tokens: z.number().int(),\n }),\n )\n .optional(),\n});\n\nexport const AnthropicMessagesResponseSchema = z\n .object({\n id: z.string(),\n type: z.literal(\"message\"),\n role: z.literal(\"assistant\"),\n model: AnthropicResponseModelIdSchema,\n content: z.array(AnthropicResponseContentBlockSchema),\n stop_reason: z.string().nullable().optional(),\n stop_sequence: z.string().nullable().optional(),\n usage: AnthropicUsageSchema.default({}),\n })\n .passthrough();\n\nconst AnthropicContentBlockDeltaSchema = z.discriminatedUnion(\"type\", [\n z.object({\n type: z.literal(\"text_delta\"),\n text: z.string(),\n }),\n z.object({\n type: z.literal(\"thinking_delta\"),\n thinking: z.string(),\n }),\n z.object({\n type: z.literal(\"input_json_delta\"),\n partial_json: z.string(),\n }),\n z.object({\n type: z.literal(\"signature_delta\"),\n signature: z.string(),\n }),\n z.object({\n type: z.literal(\"citations_delta\"),\n citation: z.unknown(),\n }),\n z.object({\n type: z.literal(\"compaction_delta\"),\n content: z.string().optional(),\n }),\n]);\n\nexport const AnthropicResponseStreamEventSchema = z.discriminatedUnion(\"type\", [\n z.object({\n type: z.literal(\"ping\"),\n }),\n z.object({\n type: z.literal(\"message_start\"),\n message: AnthropicMessagesResponseSchema,\n }),\n z.object({\n type: z.literal(\"message_delta\"),\n delta: z\n .object({\n stop_reason: z.string().nullable().optional(),\n stop_sequence: z.string().nullable().optional(),\n })\n .passthrough(),\n usage: z\n .object({\n input_tokens: z.number().int().optional(),\n output_tokens: z.number().int().optional(),\n cache_creation_input_tokens: z.number().int().optional(),\n cache_read_input_tokens: z.number().int().optional(),\n iterations: z\n .array(\n z.object({\n type: z.enum([\"compaction\", \"message\"]),\n input_tokens: z.number().int(),\n output_tokens: z.number().int(),\n }),\n )\n .optional(),\n })\n .passthrough()\n .optional(),\n }),\n z.object({\n type: z.literal(\"message_stop\"),\n }),\n z.object({\n type: z.literal(\"content_block_start\"),\n index: z.number().int(),\n content_block: AnthropicResponseContentBlockSchema,\n }),\n z.object({\n type: z.literal(\"content_block_delta\"),\n index: z.number().int(),\n delta: AnthropicContentBlockDeltaSchema,\n }),\n z.object({\n type: z.literal(\"content_block_stop\"),\n index: z.number().int(),\n }),\n z.object({\n type: z.literal(\"error\"),\n error: z\n .object({\n type: z.string().optional(),\n message: z.string().optional(),\n })\n .passthrough(),\n }),\n]);\n","import { BetterAgentError } from \"@better-agent/shared/errors\";\nimport { type Result, err, ok } from \"@better-agent/shared/neverthrow\";\nimport { safeJsonParse } from \"@better-agent/shared/utils\";\nimport {\n type AnthropicResponseStreamEvent,\n AnthropicResponseStreamEventSchema,\n} from \"../responses/schemas\";\n\nconst parseSSERecord = (\n record: string,\n): Result<AnthropicResponseStreamEvent | null, BetterAgentError> => {\n const lines = record\n .split(/\\r?\\n/)\n .map((line) => line.trimEnd())\n .filter(Boolean);\n\n if (!lines.length) return ok(null);\n\n const data = lines\n .filter((line) => line.startsWith(\"data:\"))\n .map((line) => line.slice(5).trimStart())\n .join(\"\\n\");\n\n if (!data) return ok(null);\n if (data === \"[DONE]\") return ok(null);\n\n const parsed = safeJsonParse(data);\n if (parsed.isErr()) {\n return err(\n BetterAgentError.wrap({\n err: parsed.error,\n message: \"Anthropic stream returned invalid JSON\",\n opts: {\n code: \"UPSTREAM_FAILED\",\n context: {\n provider: \"anthropic\",\n raw: data,\n },\n },\n }).at({\n at: \"anthropic.stream.parse\",\n }),\n );\n }\n\n const event = AnthropicResponseStreamEventSchema.safeParse(parsed.value);\n if (!event.success) {\n return err(\n BetterAgentError.fromCode(\n \"UPSTREAM_FAILED\",\n \"Anthropic stream returned an unknown event payload\",\n {\n context: {\n provider: \"anthropic\",\n issues: event.error.issues,\n },\n },\n ).at({\n at: \"anthropic.stream.validate\",\n }),\n );\n }\n\n return ok(event.data);\n};\n\nexport async function* parseAnthropicSSEStream(\n stream: ReadableStream<Uint8Array>,\n): AsyncGenerator<Result<AnthropicResponseStreamEvent, BetterAgentError>> {\n const reader = stream.getReader();\n const decoder = new TextDecoder();\n let buffer = \"\";\n\n try {\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n\n buffer += decoder.decode(value, { stream: true });\n\n while (true) {\n const recordBoundary = buffer.indexOf(\"\\n\\n\");\n if (recordBoundary === -1) break;\n\n const record = buffer.slice(0, recordBoundary);\n buffer = buffer.slice(recordBoundary + 2);\n\n const parsed = parseSSERecord(record);\n if (parsed.isErr()) {\n yield err(parsed.error);\n return;\n }\n\n if (parsed.value) {\n yield ok(parsed.value);\n }\n }\n }\n\n buffer += decoder.decode();\n const remaining = buffer.trim();\n if (!remaining) return;\n\n const parsed = parseSSERecord(remaining);\n if (parsed.isErr()) {\n yield err(parsed.error);\n return;\n }\n\n if (parsed.value) {\n yield ok(parsed.value);\n }\n } finally {\n reader.releaseLock();\n }\n}\n","import { BetterAgentError } from \"@better-agent/shared/errors\";\nimport { type Result, err, ok } from \"@better-agent/shared/neverthrow\";\nimport { safeJsonParse } from \"@better-agent/shared/utils\";\nimport { baFetch } from \"../../utils/fetch\";\nimport type {\n AnthropicMessagesRequestSchema,\n AnthropicMessagesResponse,\n AnthropicResponseStreamEvent,\n} from \"../responses/schemas\";\nimport type { AnthropicConfig, AnthropicError } from \"../types\";\nimport { buildAnthropicHeaders } from \"./auth\";\nimport { mapAnthropicHttpError } from \"./errors\";\nimport { parseAnthropicSSEStream } from \"./stream\";\n\ntype RequestOptions = {\n signal?: AbortSignal | null;\n beta?: string[];\n headers?: Record<string, string>;\n};\n\nexport const createAnthropicClient = (config: AnthropicConfig = {}) => {\n const baseUrl = (config.baseURL ?? \"https://api.anthropic.com/v1\").replace(/\\/+$/, \"\");\n\n const post = async <TOutput>(\n path: string,\n body: unknown,\n at: string,\n options?: RequestOptions,\n ): Promise<Result<TOutput, BetterAgentError>> => {\n try {\n const result = await baFetch<TOutput, AnthropicError>(`${baseUrl}${path}`, {\n method: \"POST\",\n body: JSON.stringify(body),\n headers: {\n ...buildAnthropicHeaders(config, options),\n \"Content-Type\": \"application/json\",\n },\n signal: options?.signal ?? null,\n throw: false,\n });\n\n if (result.error) {\n return err(\n mapAnthropicHttpError(result.error, {\n at,\n path,\n }),\n );\n }\n\n if (!result.data) {\n return err(\n BetterAgentError.fromCode(\"UPSTREAM_FAILED\", \"Anthropic returned no data\", {\n context: {\n provider: \"anthropic\",\n },\n }).at({\n at,\n data: {\n path,\n },\n }),\n );\n }\n\n return ok(result.data);\n } catch (e) {\n return err(\n BetterAgentError.wrap({\n err: e,\n message: \"Anthropic request failed\",\n opts: {\n code: \"UPSTREAM_FAILED\",\n context: {\n provider: \"anthropic\",\n },\n },\n }).at({\n at,\n data: {\n path,\n },\n }),\n );\n }\n };\n\n const stream = async (\n path: string,\n body: unknown,\n at: string,\n options?: RequestOptions,\n ): Promise<\n Result<\n AsyncGenerator<Result<AnthropicResponseStreamEvent, BetterAgentError>>,\n BetterAgentError\n >\n > => {\n try {\n const response = await fetch(`${baseUrl}${path}`, {\n method: \"POST\",\n body: JSON.stringify(body),\n headers: {\n ...buildAnthropicHeaders(config, options),\n Accept: \"text/event-stream\",\n \"Content-Type\": \"application/json\",\n },\n signal: options?.signal ?? null,\n });\n\n if (!response.ok) {\n const text = await response.text();\n const parsed = safeJsonParse(text);\n const error =\n parsed.isOk() && parsed.value && typeof parsed.value === \"object\"\n ? (parsed.value as AnthropicError).error\n ? (parsed.value as AnthropicError)\n : { error: parsed.value as AnthropicError[\"error\"] }\n : undefined;\n\n return err(\n mapAnthropicHttpError(\n {\n status: response.status,\n statusText: response.statusText,\n error: error?.error,\n },\n {\n at,\n path,\n },\n ),\n );\n }\n\n if (!response.body) {\n return err(\n BetterAgentError.fromCode(\n \"UPSTREAM_FAILED\",\n \"Anthropic stream response did not include a body\",\n {\n context: {\n provider: \"anthropic\",\n },\n },\n ).at({\n at,\n data: {\n path,\n },\n }),\n );\n }\n\n return ok(parseAnthropicSSEStream(response.body));\n } catch (e) {\n return err(\n BetterAgentError.wrap({\n err: e,\n message: \"Anthropic streaming request failed\",\n opts: {\n code: \"UPSTREAM_FAILED\",\n context: {\n provider: \"anthropic\",\n },\n },\n }).at({\n at,\n data: {\n path,\n },\n }),\n );\n }\n };\n\n return {\n messages: {\n create: (\n body: AnthropicMessagesRequestSchema,\n options?: RequestOptions,\n ): Promise<Result<AnthropicMessagesResponse, BetterAgentError>> =>\n post(\"/messages\", body, \"anthropic.messages.create\", options),\n stream: (\n body: AnthropicMessagesRequestSchema,\n options?: RequestOptions,\n ): Promise<\n Result<\n AsyncGenerator<Result<AnthropicResponseStreamEvent, BetterAgentError>>,\n BetterAgentError\n >\n > => stream(\"/messages\", body, \"anthropic.messages.stream\", options),\n },\n };\n};\n","import type { HostedToolDefinition } from \"@better-agent/core\";\nimport type { AnthropicMessagesRequestSchema } from \"../responses/schemas\";\n\ntype AnthropicNativeToolByType<TType extends string> = NonNullable<\n AnthropicMessagesRequestSchema[\"tools\"]\n>[number] extends infer TTool\n ? TTool extends { type: infer ToolType extends string }\n ? TType extends ToolType\n ? TTool\n : never\n : never\n : never;\n\nexport type AnthropicNativeToolConfig<TType extends string> = Omit<\n AnthropicNativeToolByType<TType>,\n \"type\" | \"name\" | \"cache_control\"\n>;\n\nexport type AnthropicNativeToolType =\n | \"code_execution_20250522\"\n | \"code_execution_20250825\"\n | \"code_execution_20260120\"\n | \"computer_20241022\"\n | \"computer_20250124\"\n | \"computer_20251124\"\n | \"text_editor_20241022\"\n | \"text_editor_20250124\"\n | \"text_editor_20250429\"\n | \"text_editor_20250728\"\n | \"bash_20241022\"\n | \"bash_20250124\"\n | \"memory_20250818\"\n | \"web_search_20250305\"\n | \"web_search_20260209\"\n | \"web_fetch_20250910\"\n | \"web_fetch_20260209\"\n | \"tool_search_tool_regex_20251119\"\n | \"tool_search_tool_bm25_20251119\";\n\nexport type AnthropicNativeToolDefinition<\n TType extends AnthropicNativeToolType = AnthropicNativeToolType,\n> = HostedToolDefinition<\"anthropic\", TType, AnthropicNativeToolConfig<TType>>;\n\nexport type AnthropicNativeToolBuilders = ReturnType<typeof createAnthropicNativeToolBuilders>;\ntype AnyAnthropicNativeToolDefinition = {\n [K in AnthropicNativeToolType]: AnthropicNativeToolDefinition<K>;\n}[AnthropicNativeToolType];\n\nexport function createAnthropicNativeToolBuilders() {\n return {\n codeExecution_20250522: (\n config: AnthropicNativeToolConfig<\"code_execution_20250522\"> = {},\n ) => createNativeTool(\"code_execution_20250522\", config),\n codeExecution_20250825: (\n config: AnthropicNativeToolConfig<\"code_execution_20250825\"> = {},\n ) => createNativeTool(\"code_execution_20250825\", config),\n codeExecution_20260120: (\n config: AnthropicNativeToolConfig<\"code_execution_20260120\"> = {},\n ) => createNativeTool(\"code_execution_20260120\", config),\n computer_20241022: (config: AnthropicNativeToolConfig<\"computer_20241022\">) =>\n createNativeTool(\"computer_20241022\", config),\n computer_20250124: (config: AnthropicNativeToolConfig<\"computer_20250124\">) =>\n createNativeTool(\"computer_20250124\", config),\n computer_20251124: (config: AnthropicNativeToolConfig<\"computer_20251124\">) =>\n createNativeTool(\"computer_20251124\", config),\n textEditor_20241022: (config: AnthropicNativeToolConfig<\"text_editor_20241022\"> = {}) =>\n createNativeTool(\"text_editor_20241022\", config),\n textEditor_20250124: (config: AnthropicNativeToolConfig<\"text_editor_20250124\"> = {}) =>\n createNativeTool(\"text_editor_20250124\", config),\n textEditor_20250429: (config: AnthropicNativeToolConfig<\"text_editor_20250429\"> = {}) =>\n createNativeTool(\"text_editor_20250429\", config),\n textEditor_20250728: (config: AnthropicNativeToolConfig<\"text_editor_20250728\"> = {}) =>\n createNativeTool(\"text_editor_20250728\", config),\n bash_20241022: (config: AnthropicNativeToolConfig<\"bash_20241022\"> = {}) =>\n createNativeTool(\"bash_20241022\", config),\n bash_20250124: (config: AnthropicNativeToolConfig<\"bash_20250124\"> = {}) =>\n createNativeTool(\"bash_20250124\", config),\n memory_20250818: (config: AnthropicNativeToolConfig<\"memory_20250818\"> = {}) =>\n createNativeTool(\"memory_20250818\", config),\n webSearch_20250305: (config: AnthropicNativeToolConfig<\"web_search_20250305\"> = {}) =>\n createNativeTool(\"web_search_20250305\", config),\n webSearch_20260209: (config: AnthropicNativeToolConfig<\"web_search_20260209\"> = {}) =>\n createNativeTool(\"web_search_20260209\", config),\n webFetch_20250910: (config: AnthropicNativeToolConfig<\"web_fetch_20250910\"> = {}) =>\n createNativeTool(\"web_fetch_20250910\", config),\n webFetch_20260209: (config: AnthropicNativeToolConfig<\"web_fetch_20260209\"> = {}) =>\n createNativeTool(\"web_fetch_20260209\", config),\n toolSearchRegex_20251119: (\n config: AnthropicNativeToolConfig<\"tool_search_tool_regex_20251119\"> = {},\n ) => createNativeTool(\"tool_search_tool_regex_20251119\", config),\n toolSearchBm25_20251119: (\n config: AnthropicNativeToolConfig<\"tool_search_tool_bm25_20251119\"> = {},\n ) => createNativeTool(\"tool_search_tool_bm25_20251119\", config),\n };\n}\n\nfunction createNativeTool<TType extends AnthropicNativeToolType>(\n type: TType,\n config: AnthropicNativeToolConfig<TType>,\n): AnthropicNativeToolDefinition<TType> {\n return {\n kind: \"hosted\",\n provider: \"anthropic\",\n type,\n config,\n };\n}\n\nexport function isAnthropicNativeToolDefinition(\n tool: unknown,\n): tool is AnyAnthropicNativeToolDefinition {\n if (!tool || typeof tool !== \"object\") return false;\n const t = tool as Record<string, unknown>;\n return t.kind === \"hosted\" && t.provider === \"anthropic\" && typeof t.type === \"string\";\n}\n\nexport function mapAnthropicNativeToolToRequest(\n tool: AnyAnthropicNativeToolDefinition,\n): NonNullable<AnthropicMessagesRequestSchema[\"tools\"]>[number] {\n switch (tool.type) {\n case \"code_execution_20250522\":\n return { type: \"code_execution_20250522\", name: \"code_execution\", ...tool.config };\n case \"code_execution_20250825\":\n return { type: \"code_execution_20250825\", name: \"code_execution\", ...tool.config };\n case \"code_execution_20260120\":\n return { type: \"code_execution_20260120\", name: \"code_execution\", ...tool.config };\n case \"computer_20241022\":\n return { type: \"computer_20241022\", name: \"computer\", ...tool.config };\n case \"computer_20250124\":\n return { type: \"computer_20250124\", name: \"computer\", ...tool.config };\n case \"computer_20251124\":\n return { type: \"computer_20251124\", name: \"computer\", ...tool.config };\n case \"text_editor_20241022\":\n return { type: \"text_editor_20241022\", name: \"str_replace_editor\", ...tool.config };\n case \"text_editor_20250124\":\n return { type: \"text_editor_20250124\", name: \"str_replace_editor\", ...tool.config };\n case \"text_editor_20250429\":\n return {\n type: \"text_editor_20250429\",\n name: \"str_replace_based_edit_tool\",\n ...tool.config,\n };\n case \"text_editor_20250728\":\n return {\n type: \"text_editor_20250728\",\n name: \"str_replace_based_edit_tool\",\n ...tool.config,\n };\n case \"bash_20241022\":\n return { type: \"bash_20241022\", name: \"bash\", ...tool.config };\n case \"bash_20250124\":\n return { type: \"bash_20250124\", name: \"bash\", ...tool.config };\n case \"memory_20250818\":\n return { type: \"memory_20250818\", name: \"memory\", ...tool.config };\n case \"web_search_20250305\":\n return { type: \"web_search_20250305\", name: \"web_search\", ...tool.config };\n case \"web_search_20260209\":\n return { type: \"web_search_20260209\", name: \"web_search\", ...tool.config };\n case \"web_fetch_20250910\":\n return { type: \"web_fetch_20250910\", name: \"web_fetch\", ...tool.config };\n case \"web_fetch_20260209\":\n return { type: \"web_fetch_20260209\", name: \"web_fetch\", ...tool.config };\n case \"tool_search_tool_regex_20251119\":\n return {\n type: \"tool_search_tool_regex_20251119\",\n name: \"tool_search_tool_regex\",\n ...tool.config,\n };\n case \"tool_search_tool_bm25_20251119\":\n return {\n type: \"tool_search_tool_bm25_20251119\",\n name: \"tool_search_tool_bm25\",\n ...tool.config,\n };\n }\n}\n","import { TOOL_JSON_SCHEMA, isCallableToolDefinition } from \"@better-agent/core\";\nimport { Events } from \"@better-agent/core/events\";\nimport type { Event } from \"@better-agent/core/events\";\nimport type {\n GenerativeModelCallOptions,\n GenerativeModelFinishReason,\n GenerativeModelOutputItem,\n GenerativeModelOutputMessagePart,\n GenerativeModelProviderToolResult,\n GenerativeModelResponse,\n GenerativeModelToolCallRequest,\n GenerativeModelUsage,\n ModalitiesParam,\n} from \"@better-agent/core/providers\";\nimport { BetterAgentError } from \"@better-agent/shared/errors\";\nimport type { Result } from \"@better-agent/shared/neverthrow\";\nimport { err, ok } from \"@better-agent/shared/neverthrow\";\nimport { safeJsonParse } from \"@better-agent/shared/utils\";\nimport { extractPassthroughOptions, omitNullish } from \"../../utils/object-utils\";\nimport { isAnthropicNativeToolDefinition, mapAnthropicNativeToolToRequest } from \"../tools\";\nimport type {\n AnthropicMessagesRequestSchema,\n AnthropicMessagesResponse,\n AnthropicResponseStreamEvent,\n} from \"./schemas\";\nimport type {\n AnthropicResponseCaps,\n AnthropicResponseEndpointOptions,\n AnthropicResponseModelId,\n} from \"./types\";\n\n/**\n * Keys explicitly handled by the Anthropic responses mapper.\n */\nconst ANTHROPIC_RESPONSE_KNOWN_KEYS: ReadonlySet<string> = new Set([\n // Framework-managed\n \"input\",\n \"tools\",\n \"toolChoice\",\n \"modalities\",\n \"structured_output\",\n // Explicitly mapped\n \"anthropicBeta\",\n \"cacheControl\",\n \"container\",\n \"contextManagement\",\n \"disableParallelToolUse\",\n \"effort\",\n \"max_tokens\",\n \"mcpServers\",\n \"metadata\",\n \"speed\",\n \"stop_sequences\",\n \"structuredOutputMode\",\n \"temperature\",\n \"thinking\",\n \"toolStreaming\",\n \"top_k\",\n \"top_p\",\n]);\n\n// TODO: Replace this fallback with model-aware Anthropic defaults.\nconst DEFAULT_MAX_TOKENS = 4096;\nconst PDF_INPUT_BETA = \"pdfs-2024-09-25\";\nconst FINE_GRAINED_TOOL_STREAMING_BETA = \"fine-grained-tool-streaming-2025-05-14\";\n\nconst normalizeProviderToolName = (name: string): string => {\n if (name === \"bash_code_execution\" || name === \"text_editor_code_execution\") {\n return \"code_execution\";\n }\n\n return name;\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst decodeBase64Text = (data: string): string => Buffer.from(data, \"base64\").toString(\"utf8\");\n\nconst isUrlSource = (source: unknown): source is { kind: \"url\"; url: string } =>\n isRecord(source) && source.kind === \"url\" && typeof source.url === \"string\";\n\nconst isBase64Source = (\n source: unknown,\n): source is { kind: \"base64\"; data: string; mimeType: string } =>\n isRecord(source) &&\n source.kind === \"base64\" &&\n typeof source.data === \"string\" &&\n typeof source.mimeType === \"string\";\n\nconst buildBinarySource = (source: unknown) => {\n if (isUrlSource(source)) {\n return {\n type: \"url\" as const,\n url: source.url,\n };\n }\n\n if (isBase64Source(source)) {\n return {\n type: \"base64\" as const,\n media_type: source.mimeType,\n data: source.data,\n };\n }\n\n return null;\n};\n\nconst serializeToolResultContent = (result: unknown): string =>\n typeof result === \"string\" ? result : JSON.stringify(result);\n\nconst parseMaybeJson = (value: string): unknown => {\n if (!value.trim()) return {};\n const parsed = safeJsonParse(value);\n return parsed.isOk() ? parsed.value : value;\n};\n\nconst getAnthropicModelCapabilities = (modelId: string) => {\n if (modelId.includes(\"claude-sonnet-4-6\") || modelId.includes(\"claude-opus-4-6\")) {\n return {\n supportsStructuredOutput: true,\n };\n }\n\n if (\n modelId.includes(\"claude-sonnet-4-5\") ||\n modelId.includes(\"claude-opus-4-5\") ||\n modelId.includes(\"claude-haiku-4-5\")\n ) {\n return {\n supportsStructuredOutput: true,\n };\n }\n\n if (modelId.includes(\"claude-opus-4-1\")) {\n return {\n supportsStructuredOutput: true,\n };\n }\n\n return {\n supportsStructuredOutput: false,\n };\n};\n\ntype AnthropicPartProviderOptions = {\n cacheControl?: {\n type: \"ephemeral\";\n ttl?: \"5m\" | \"1h\";\n };\n citations?: {\n enabled: boolean;\n };\n context?: string;\n title?: string;\n};\n\nconst getAnthropicPartProviderMetadata = (\n part: Record<string, unknown>,\n): AnthropicPartProviderOptions | undefined => {\n const providerMetadata = part.providerMetadata;\n if (!isRecord(providerMetadata)) return undefined;\n const anthropic = providerMetadata.anthropic;\n if (!isRecord(anthropic)) return undefined;\n\n return {\n cacheControl:\n isRecord(anthropic.cacheControl) &&\n anthropic.cacheControl.type === \"ephemeral\" &&\n (anthropic.cacheControl.ttl == null ||\n anthropic.cacheControl.ttl === \"5m\" ||\n anthropic.cacheControl.ttl === \"1h\")\n ? {\n type: \"ephemeral\",\n ...(anthropic.cacheControl.ttl != null\n ? { ttl: anthropic.cacheControl.ttl }\n : {}),\n }\n : undefined,\n citations:\n isRecord(anthropic.citations) && typeof anthropic.citations.enabled === \"boolean\"\n ? { enabled: anthropic.citations.enabled }\n : undefined,\n context: typeof anthropic.context === \"string\" ? anthropic.context : undefined,\n title: typeof anthropic.title === \"string\" ? anthropic.title : undefined,\n };\n};\n\nconst getAnthropicTextProviderMetadata = (citations?: unknown[]) =>\n citations?.length\n ? ({\n anthropic: {\n citations,\n },\n } satisfies Record<string, unknown>)\n : undefined;\n\nconst mapAnthropicStopReason = (\n stopReason: string | null | undefined,\n isJsonResponseFromTool: boolean,\n): GenerativeModelFinishReason => {\n switch (stopReason) {\n case \"pause_turn\":\n case \"end_turn\":\n case \"stop_sequence\":\n return \"stop\";\n case \"refusal\":\n return \"content-filter\";\n case \"tool_use\":\n return isJsonResponseFromTool ? \"stop\" : \"tool-calls\";\n case \"max_tokens\":\n case \"model_context_window_exceeded\":\n return \"length\";\n case \"compaction\":\n return \"other\";\n default:\n return \"other\";\n }\n};\n\nconst mapAnthropicUsage = (\n usage:\n | {\n input_tokens?: number;\n output_tokens?: number;\n cache_creation_input_tokens?: number;\n cache_read_input_tokens?: number;\n iterations?: Array<{\n type: \"compaction\" | \"message\";\n input_tokens: number;\n output_tokens: number;\n }>;\n }\n | undefined,\n): GenerativeModelUsage => {\n const cacheCreation = usage?.cache_creation_input_tokens ?? 0;\n const cacheRead = usage?.cache_read_input_tokens ?? 0;\n\n const iteratedInput =\n usage?.iterations?.reduce((sum, item) => sum + item.input_tokens, 0) ?? usage?.input_tokens;\n const iteratedOutput =\n usage?.iterations?.reduce((sum, item) => sum + item.output_tokens, 0) ??\n usage?.output_tokens;\n\n const inputTokens =\n typeof iteratedInput === \"number\" ? iteratedInput + cacheCreation + cacheRead : undefined;\n const outputTokens = typeof iteratedOutput === \"number\" ? iteratedOutput : undefined;\n const totalTokens =\n typeof inputTokens === \"number\" && typeof outputTokens === \"number\"\n ? inputTokens + outputTokens\n : undefined;\n\n return omitNullish({\n inputTokens,\n outputTokens,\n totalTokens,\n cachedInputTokens: cacheRead || undefined,\n });\n};\n\nconst mapContextManagementEdit = (edit: unknown): unknown => {\n if (!isRecord(edit) || typeof edit.type !== \"string\") return edit;\n\n switch (edit.type) {\n case \"clear_tool_uses_20250919\":\n return omitNullish({\n type: edit.type,\n trigger: edit.trigger,\n keep: edit.keep,\n clear_at_least: edit.clearAtLeast,\n clear_tool_inputs: edit.clearToolInputs,\n exclude_tools: edit.excludeTools,\n });\n case \"clear_thinking_20251015\":\n return omitNullish({\n type: edit.type,\n keep: edit.keep,\n });\n case \"compact_20260112\":\n return omitNullish({\n type: edit.type,\n trigger: edit.trigger,\n pause_after_compaction: edit.pauseAfterCompaction,\n instructions: edit.instructions,\n });\n default:\n return edit;\n }\n};\n\nconst mapHostedToolBeta = (type: string): string | null => {\n switch (type) {\n case \"code_execution_20250522\":\n return \"code-execution-2025-05-22\";\n case \"code_execution_20250825\":\n return \"code-execution-2025-08-25\";\n case \"computer_20241022\":\n case \"text_editor_20241022\":\n case \"bash_20241022\":\n return \"computer-use-2024-10-22\";\n case \"computer_20250124\":\n case \"text_editor_20250124\":\n case \"text_editor_20250429\":\n case \"bash_20250124\":\n return \"computer-use-2025-01-24\";\n case \"computer_20251124\":\n return \"computer-use-2025-11-24\";\n case \"memory_20250818\":\n return \"context-management-2025-06-27\";\n case \"web_fetch_20250910\":\n return \"web-fetch-2025-09-10\";\n case \"web_fetch_20260209\":\n case \"web_search_20260209\":\n return \"code-execution-web-tools-2026-02-09\";\n default:\n return null;\n }\n};\n\nconst mapMessagePartsToAnthropicContent = (\n content: unknown,\n role: \"system\" | \"developer\" | \"user\" | \"assistant\",\n modelId: string,\n betas: Set<string>,\n): Result<AnthropicMessagesRequestSchema[\"messages\"][number][\"content\"], BetterAgentError> => {\n const toValidationError = (message: string, at: string, context?: Record<string, unknown>) =>\n BetterAgentError.fromCode(\"VALIDATION_FAILED\", message, {\n context: {\n provider: \"anthropic\",\n model: modelId,\n role,\n ...(context ?? {}),\n },\n }).at({ at });\n\n const parts = typeof content === \"string\" ? [{ type: \"text\", text: content }] : content;\n if (!Array.isArray(parts)) {\n return err(\n toValidationError(\n \"Message content must be a string or array.\",\n \"anthropic.map.input.content\",\n ),\n );\n }\n\n const anthropicContent: AnthropicMessagesRequestSchema[\"messages\"][number][\"content\"] = [];\n\n for (const part of parts) {\n if (!isRecord(part) || typeof part.type !== \"string\") {\n return err(\n toValidationError(\n \"Message part must be an object with a type.\",\n \"anthropic.map.input.part\",\n ),\n );\n }\n\n if (part.type === \"text\") {\n if (typeof part.text !== \"string\") {\n return err(\n toValidationError(\n \"Text message parts require a text string.\",\n \"anthropic.map.input.text\",\n ),\n );\n }\n\n const anthropicProviderOptions = getAnthropicPartProviderMetadata(part);\n anthropicContent.push({\n type: \"text\",\n text: part.text,\n ...(anthropicProviderOptions?.cacheControl != null\n ? { cache_control: anthropicProviderOptions.cacheControl }\n : {}),\n });\n continue;\n }\n\n if (role === \"assistant\" || role === \"system\" || role === \"developer\") {\n return err(\n toValidationError(\n `Role '${role}' only supports text content for Anthropic.`,\n \"anthropic.map.input.roleContent\",\n {\n partType: part.type,\n },\n ),\n );\n }\n\n if (part.type === \"image\") {\n if (!isRecord(part.source) || typeof part.source.kind !== \"string\") {\n return err(\n toValidationError(\n \"Image parts require a valid source.\",\n \"anthropic.map.input.imageSource\",\n ),\n );\n }\n\n if (part.source.kind === \"provider-file\") {\n return err(\n toValidationError(\n \"Anthropic Messages API does not support provider-file image inputs in this adapter.\",\n \"anthropic.map.input.imageProviderFile\",\n ),\n );\n }\n\n const anthropicProviderOptions = getAnthropicPartProviderMetadata(part);\n const imageSource =\n isUrlSource(part.source) || isBase64Source(part.source)\n ? buildBinarySource(part.source)\n : null;\n if (imageSource == null) {\n return err(\n toValidationError(\n \"Image parts require a URL or base64 source.\",\n \"anthropic.map.input.imageSourceKind\",\n ),\n );\n }\n\n anthropicContent.push({\n type: \"image\",\n source: imageSource,\n ...(anthropicProviderOptions?.cacheControl != null\n ? { cache_control: anthropicProviderOptions.cacheControl }\n : {}),\n });\n continue;\n }\n\n if (part.type === \"file\") {\n if (!isRecord(part.source) || typeof part.source.kind !== \"string\") {\n return err(\n toValidationError(\n \"File parts require a valid source.\",\n \"anthropic.map.input.fileSource\",\n ),\n );\n }\n\n if (part.source.kind === \"provider-file\") {\n return err(\n toValidationError(\n \"Anthropic Messages API does not support provider-file document inputs in this adapter.\",\n \"anthropic.map.input.fileProviderFile\",\n ),\n );\n }\n\n const mimeType =\n typeof part.source.mimeType === \"string\" ? part.source.mimeType : undefined;\n const filename =\n typeof part.source.filename === \"string\" ? part.source.filename : undefined;\n const anthropicProviderOptions = getAnthropicPartProviderMetadata(part);\n const citationsEnabled = anthropicProviderOptions?.citations?.enabled;\n const documentContext = anthropicProviderOptions?.context;\n const documentTitle = anthropicProviderOptions?.title ?? filename;\n const cacheControl = anthropicProviderOptions?.cacheControl;\n\n if (typeof mimeType === \"string\" && mimeType.startsWith(\"image/\")) {\n const imageSource = buildBinarySource(part.source);\n if (imageSource == null) {\n return err(\n toValidationError(\n \"Image file inputs require a URL or base64 source.\",\n \"anthropic.map.input.fileImageSource\",\n ),\n );\n }\n anthropicContent.push({\n type: \"image\",\n source: imageSource,\n ...(cacheControl != null ? { cache_control: cacheControl } : {}),\n });\n continue;\n }\n\n if (mimeType === \"application/pdf\") {\n betas.add(PDF_INPUT_BETA);\n const documentSource = buildBinarySource(part.source);\n if (documentSource == null) {\n return err(\n toValidationError(\n \"PDF inputs require a URL or base64 source.\",\n \"anthropic.map.input.filePdfSource\",\n ),\n );\n }\n anthropicContent.push({\n type: \"document\",\n source: documentSource,\n ...(documentTitle != null ? { title: documentTitle } : {}),\n ...(documentContext != null ? { context: documentContext } : {}),\n ...(citationsEnabled != null\n ? { citations: { enabled: citationsEnabled } }\n : {}),\n ...(cacheControl != null ? { cache_control: cacheControl } : {}),\n });\n continue;\n }\n\n if (mimeType === \"text/plain\") {\n const documentSource = isUrlSource(part.source)\n ? {\n type: \"url\" as const,\n url: part.source.url,\n }\n : isBase64Source(part.source)\n ? {\n type: \"text\" as const,\n media_type: \"text/plain\" as const,\n data: decodeBase64Text(part.source.data),\n }\n : null;\n if (documentSource == null) {\n return err(\n toValidationError(\n \"Text document inputs require a URL or base64 source.\",\n \"anthropic.map.input.fileTextSource\",\n ),\n );\n }\n anthropicContent.push({\n type: \"document\",\n source: documentSource,\n ...(documentTitle != null ? { title: documentTitle } : {}),\n ...(documentContext != null ? { context: documentContext } : {}),\n ...(citationsEnabled != null\n ? { citations: { enabled: citationsEnabled } }\n : {}),\n ...(cacheControl != null ? { cache_control: cacheControl } : {}),\n });\n continue;\n }\n\n return err(\n toValidationError(\n \"Anthropic file inputs currently support image/*, application/pdf, and text/plain only.\",\n \"anthropic.map.input.fileUnsupported\",\n {\n mimeType,\n },\n ),\n );\n }\n\n return err(\n toValidationError(\n `Unsupported Anthropic input part type '${part.type}'.`,\n \"anthropic.map.input.unsupportedPart\",\n ),\n );\n }\n\n return ok(anthropicContent);\n};\n\nexport function mapToAnthropicMessagesRequest<\n M extends AnthropicResponseModelId,\n TModalities extends ModalitiesParam<AnthropicResponseCaps> = undefined,\n>(args: {\n modelId: M;\n options: GenerativeModelCallOptions<\n AnthropicResponseCaps,\n AnthropicResponseEndpointOptions,\n TModalities\n >;\n stream?: boolean;\n}): Result<\n {\n request: AnthropicMessagesRequestSchema;\n betas: string[];\n usesJsonResponseTool: boolean;\n },\n BetterAgentError\n> {\n try {\n const { modelId } = args;\n const o = args.options;\n const stream = args.stream === true;\n const betas = new Set<string>(o.anthropicBeta ?? []);\n const systemParts: Array<{ type: \"text\"; text: string }> = [];\n const messages: AnthropicMessagesRequestSchema[\"messages\"] = [];\n\n const inputItems: readonly unknown[] =\n typeof o.input === \"string\"\n ? [{ type: \"message\", role: \"user\", content: o.input }]\n : (o.input as readonly unknown[]);\n\n if (Array.isArray(inputItems)) {\n for (const item of inputItems) {\n if (typeof item === \"string\") {\n messages.push({\n role: \"user\",\n content: [{ type: \"text\", text: item }],\n });\n continue;\n }\n\n if (!isRecord(item) || typeof item.type !== \"string\") {\n return err(\n BetterAgentError.fromCode(\n \"VALIDATION_FAILED\",\n \"Anthropic input items must be messages or tool-call results.\",\n {\n context: {\n provider: \"anthropic\",\n model: modelId,\n },\n },\n ).at({ at: \"anthropic.map.input.item\" }),\n );\n }\n\n if (item.type === \"message\") {\n const role = typeof item.role === \"string\" ? item.role : (\"user\" as const);\n\n const content = mapMessagePartsToAnthropicContent(\n item.content,\n role as \"system\" | \"developer\" | \"user\" | \"assistant\",\n String(modelId),\n betas,\n );\n if (content.isErr()) return err(content.error);\n\n if (role === \"system\" || role === \"developer\") {\n for (const part of content.value) {\n if (part.type === \"text\") {\n systemParts.push({ type: \"text\", text: part.text });\n }\n }\n } else if (role === \"assistant\" || role === \"user\") {\n messages.push({\n role,\n content: content.value,\n });\n } else {\n return err(\n BetterAgentError.fromCode(\n \"VALIDATION_FAILED\",\n `Anthropic does not support role '${role}'.`,\n {\n context: {\n provider: \"anthropic\",\n model: modelId,\n role,\n },\n },\n ).at({ at: \"anthropic.map.input.role\" }),\n );\n }\n\n continue;\n }\n\n if (item.type === \"tool-call\" && \"result\" in item) {\n const toolResult = item as {\n type: \"tool-call\";\n name: string;\n callId: string;\n arguments?: string;\n result: unknown;\n isError?: boolean;\n };\n messages.push({\n role: \"assistant\",\n content: [\n {\n type: \"tool_use\",\n id: toolResult.callId,\n name: toolResult.name,\n input: parseMaybeJson(toolResult.arguments ?? \"{}\"),\n },\n ],\n });\n messages.push({\n role: \"user\",\n content: [\n {\n type: \"tool_result\",\n tool_use_id: toolResult.callId,\n content: serializeToolResultContent(toolResult.result),\n is_error: toolResult.isError,\n },\n ],\n });\n continue;\n }\n\n return err(\n BetterAgentError.fromCode(\n \"VALIDATION_FAILED\",\n \"Anthropic input items must be messages or completed tool-call results.\",\n {\n context: {\n provider: \"anthropic\",\n model: modelId,\n },\n },\n ).at({ at: \"anthropic.map.input.unsupportedItem\" }),\n );\n }\n }\n\n const anthropicTools: NonNullable<AnthropicMessagesRequestSchema[\"tools\"]> = [];\n const tools = (\"tools\" in o ? o.tools : []) ?? [];\n const modelSupportsStructuredOutput = getAnthropicModelCapabilities(\n String(modelId),\n ).supportsStructuredOutput;\n\n for (const tool of tools) {\n if (isAnthropicNativeToolDefinition(tool)) {\n anthropicTools.push(mapAnthropicNativeToolToRequest(tool));\n const beta = mapHostedToolBeta(tool.type);\n if (beta) betas.add(beta);\n continue;\n }\n\n const callableTool = tool as\n | ({ [TOOL_JSON_SCHEMA]?: unknown } & Record<string, unknown>)\n | undefined;\n\n if (!callableTool || !isCallableToolDefinition(callableTool as never)) continue;\n\n const inputSchema = callableTool[TOOL_JSON_SCHEMA];\n if (!isRecord(inputSchema) || inputSchema.type !== \"object\") {\n return err(\n BetterAgentError.fromCode(\n \"VALIDATION_FAILED\",\n \"Anthropic custom tools require an object JSON schema.\",\n {\n context: {\n provider: \"anthropic\",\n model: modelId,\n toolName: callableTool.name,\n },\n },\n ).at({ at: \"anthropic.map.tools.schema\" }),\n );\n }\n\n anthropicTools.push(\n omitNullish({\n name: String(callableTool.name ?? \"\"),\n description:\n typeof callableTool.description === \"string\"\n ? callableTool.description\n : undefined,\n input_schema: inputSchema,\n strict:\n modelSupportsStructuredOutput && typeof callableTool.strict === \"boolean\"\n ? callableTool.strict\n : undefined,\n }) as NonNullable<AnthropicMessagesRequestSchema[\"tools\"]>[number],\n );\n if (modelSupportsStructuredOutput) {\n betas.add(\"structured-outputs-2025-11-13\");\n }\n }\n\n const structuredOutput = \"structured_output\" in o ? o.structured_output : undefined;\n const structuredOutputMode = o.structuredOutputMode ?? \"auto\";\n const useStructuredOutput =\n structuredOutputMode === \"outputFormat\" ||\n (structuredOutputMode === \"auto\" && modelSupportsStructuredOutput);\n let usesJsonResponseTool = false;\n let outputConfig: AnthropicMessagesRequestSchema[\"output_config\"] | undefined =\n o.effort != null ? { effort: o.effort } : undefined;\n\n if (structuredOutput) {\n if (!isRecord(structuredOutput.schema) || structuredOutput.schema.type !== \"object\") {\n return err(\n BetterAgentError.fromCode(\n \"VALIDATION_FAILED\",\n \"Anthropic structured output schema must be a JSON object schema.\",\n {\n context: {\n provider: \"anthropic\",\n model: modelId,\n },\n },\n ).at({ at: \"anthropic.map.structuredOutput.schema\" }),\n );\n }\n\n if (!useStructuredOutput) {\n usesJsonResponseTool = true;\n anthropicTools.push({\n name: \"json\",\n description: \"Respond with a JSON object.\",\n input_schema: structuredOutput.schema,\n });\n } else {\n outputConfig = {\n ...(outputConfig ?? {}),\n format: {\n type: \"json_schema\",\n schema: structuredOutput.schema,\n },\n };\n }\n }\n\n let toolChoice: AnthropicMessagesRequestSchema[\"tool_choice\"] | undefined;\n if (usesJsonResponseTool) {\n toolChoice = {\n type: \"tool\",\n name: \"json\",\n disable_parallel_tool_use: true,\n };\n } else if (\"toolChoice\" in o && o.toolChoice) {\n switch (o.toolChoice.type) {\n case \"auto\":\n toolChoice = o.disableParallelToolUse\n ? {\n type: \"auto\",\n disable_parallel_tool_use: true,\n }\n : { type: \"auto\" };\n break;\n case \"required\":\n toolChoice = {\n type: \"any\",\n ...(o.disableParallelToolUse ? { disable_parallel_tool_use: true } : {}),\n };\n break;\n case \"tool\":\n toolChoice = {\n type: \"tool\",\n name: o.toolChoice.name,\n ...(o.disableParallelToolUse ? { disable_parallel_tool_use: true } : {}),\n };\n break;\n case \"none\":\n break;\n }\n } else if (o.disableParallelToolUse) {\n toolChoice = {\n type: \"auto\",\n disable_parallel_tool_use: true,\n };\n }\n\n if (o.mcpServers?.length) {\n betas.add(\"mcp-client-2025-04-04\");\n }\n if (o.contextManagement) {\n betas.add(\"context-management-2025-06-27\");\n if (\n o.contextManagement.edits.some(\n (edit) => isRecord(edit) && edit.type === \"compact_20260112\",\n )\n ) {\n betas.add(\"compact-2026-01-12\");\n }\n }\n if (o.container?.skills?.length) {\n betas.add(\"code-execution-2025-08-25\");\n betas.add(\"skills-2025-10-02\");\n betas.add(\"files-api-2025-04-14\");\n }\n if (o.effort) {\n betas.add(\"effort-2025-11-24\");\n }\n if (o.speed === \"fast\") {\n betas.add(\"fast-mode-2026-02-01\");\n }\n if (stream && (o.toolStreaming ?? true)) {\n betas.add(FINE_GRAINED_TOOL_STREAMING_BETA);\n }\n\n const request: AnthropicMessagesRequestSchema = {\n ...extractPassthroughOptions(\n o as Record<string, unknown>,\n ANTHROPIC_RESPONSE_KNOWN_KEYS,\n ),\n model: modelId,\n max_tokens: o.max_tokens ?? DEFAULT_MAX_TOKENS,\n messages,\n ...omitNullish({\n system: systemParts.length ? systemParts : undefined,\n cache_control: o.cacheControl,\n metadata: o.metadata?.userId ? { user_id: o.metadata.userId } : undefined,\n output_config: outputConfig,\n stop_sequences: o.stop_sequences,\n temperature: o.temperature,\n stream: false,\n speed: o.speed,\n thinking:\n o.thinking == null\n ? undefined\n : o.thinking.type === \"enabled\"\n ? {\n type: \"enabled\",\n budget_tokens: o.thinking.budgetTokens,\n }\n : o.thinking,\n tool_choice:\n o.toolChoice?.type === \"none\" && !usesJsonResponseTool ? undefined : toolChoice,\n tools:\n o.toolChoice?.type === \"none\" && !usesJsonResponseTool\n ? undefined\n : anthropicTools.length\n ? anthropicTools\n : undefined,\n top_k: o.top_k,\n top_p: o.top_p,\n mcp_servers: o.mcpServers?.map((server) => ({\n type: server.type,\n name: server.name,\n url: server.url,\n authorization_token: server.authorizationToken,\n tool_configuration: server.toolConfiguration\n ? {\n enabled: server.toolConfiguration.enabled,\n allowed_tools: server.toolConfiguration.allowedTools,\n }\n : undefined,\n })),\n container: o.container\n ? {\n ...(o.container.id != null ? { id: o.container.id } : {}),\n ...(o.container.skills?.length\n ? {\n skills: o.container.skills.map((skill) => ({\n type: skill.type,\n skill_id: skill.skillId,\n ...(skill.version != null\n ? { version: skill.version }\n : {}),\n })),\n }\n : {}),\n }\n : undefined,\n context_management: o.contextManagement\n ? {\n edits: o.contextManagement.edits.map(mapContextManagementEdit),\n }\n : undefined,\n }),\n };\n\n return ok({\n request,\n betas: [...betas],\n usesJsonResponseTool,\n });\n } catch (e) {\n return err(\n BetterAgentError.wrap({\n err: e,\n message: \"Failed to map Anthropic Messages request\",\n opts: {\n code: \"INTERNAL\",\n context: {\n provider: \"anthropic\",\n model: args.modelId,\n },\n },\n }).at({ at: \"anthropic.messages.mapToRequest\" }),\n );\n }\n}\n\nconst mapProviderToolResultName = (\n part: {\n type: string;\n tool_use_id?: string;\n name?: string;\n },\n serverToolCalls: Record<string, string>,\n mcpToolCalls: Record<string, string>,\n): string => {\n if (part.type === \"server_tool_use\" && typeof part.name === \"string\") {\n return normalizeProviderToolName(part.name);\n }\n\n if (part.type === \"mcp_tool_use\") {\n return typeof part.name === \"string\" ? part.name : \"mcp\";\n }\n\n if (part.type === \"mcp_tool_result\") {\n return mcpToolCalls[part.tool_use_id ?? \"\"] ?? \"mcp\";\n }\n\n const resolvedServerName = serverToolCalls[part.tool_use_id ?? \"\"];\n if (resolvedServerName) {\n return normalizeProviderToolName(resolvedServerName);\n }\n\n switch (part.type) {\n case \"web_fetch_tool_result\":\n return \"web_fetch\";\n case \"web_search_tool_result\":\n return \"web_search\";\n case \"code_execution_tool_result\":\n case \"bash_code_execution_tool_result\":\n case \"text_editor_code_execution_tool_result\":\n return \"code_execution\";\n case \"tool_search_tool_result\":\n return \"tool_search_tool_regex\";\n default:\n return part.type;\n }\n};\n\nexport function mapFromAnthropicMessagesResponse(args: {\n response: AnthropicMessagesResponse;\n usesJsonResponseTool?: boolean;\n}): GenerativeModelResponse {\n const assistantParts: GenerativeModelOutputMessagePart[] = [];\n const outputItems: Array<GenerativeModelOutputItem> = [];\n const serverToolCalls: Record<string, string> = {};\n const mcpToolCalls: Record<string, string> = {};\n let isJsonResponseFromTool = false;\n\n for (const part of args.response.content) {\n switch (part.type) {\n case \"text\":\n assistantParts.push({\n type: \"text\",\n text: part.text,\n ...(part.citations?.length\n ? {\n providerMetadata: getAnthropicTextProviderMetadata(part.citations),\n }\n : {}),\n });\n break;\n case \"compaction\":\n assistantParts.push({ type: \"text\", text: part.content });\n break;\n case \"tool_use\":\n if (args.usesJsonResponseTool && part.name === \"json\") {\n isJsonResponseFromTool = true;\n assistantParts.push({\n type: \"text\",\n text: JSON.stringify(part.input),\n });\n } else {\n outputItems.push({\n type: \"tool-call\",\n name: part.name,\n arguments: JSON.stringify(part.input ?? {}),\n callId: part.id,\n } satisfies GenerativeModelToolCallRequest);\n }\n break;\n case \"server_tool_use\":\n serverToolCalls[part.id] = part.name;\n outputItems.push({\n type: \"provider-tool-result\",\n name: normalizeProviderToolName(part.name),\n callId: part.id,\n result: part,\n } satisfies GenerativeModelProviderToolResult);\n break;\n case \"mcp_tool_use\":\n mcpToolCalls[part.id] = part.name;\n outputItems.push({\n type: \"provider-tool-result\",\n name: part.name,\n callId: part.id,\n result: part,\n } satisfies GenerativeModelProviderToolResult);\n break;\n case \"mcp_tool_result\":\n case \"web_fetch_tool_result\":\n case \"web_search_tool_result\":\n case \"code_execution_tool_result\":\n case \"bash_code_execution_tool_result\":\n case \"text_editor_code_execution_tool_result\":\n case \"tool_search_tool_result\":\n outputItems.push({\n type: \"provider-tool-result\",\n name: mapProviderToolResultName(part, serverToolCalls, mcpToolCalls),\n callId: part.tool_use_id,\n result: part,\n isError:\n \"is_error\" in part && typeof part.is_error === \"boolean\"\n ? part.is_error\n : undefined,\n } satisfies GenerativeModelProviderToolResult);\n break;\n case \"thinking\":\n case \"redacted_thinking\":\n break;\n }\n }\n\n if (assistantParts.length) {\n outputItems.unshift({\n type: \"message\",\n role: \"assistant\",\n content: assistantParts,\n });\n }\n\n return {\n output: outputItems,\n finishReason: mapAnthropicStopReason(args.response.stop_reason, isJsonResponseFromTool),\n usage: mapAnthropicUsage(args.response.usage),\n response: {\n body: args.response,\n },\n };\n}\n\ntype AnthropicStreamUsage = {\n input_tokens?: number;\n output_tokens?: number;\n cache_creation_input_tokens?: number;\n cache_read_input_tokens?: number;\n iterations?: Array<{\n type: \"compaction\" | \"message\";\n input_tokens: number;\n output_tokens: number;\n }>;\n};\n\ntype TextBlockState = {\n kind: \"text\";\n messageId: string;\n text: string;\n citations?: unknown[];\n};\n\ntype ReasoningBlockState = {\n kind: \"reasoning\";\n messageId: string;\n};\n\ntype ToolBlockState = {\n kind: \"tool\";\n callId: string;\n toolName: string;\n rawToolName: string;\n rawType: \"tool_use\" | \"server_tool_use\" | \"mcp_tool_use\";\n input: string;\n outputAsText: boolean;\n providerExecuted: boolean;\n extra?: Record<string, unknown>;\n};\n\ntype AnthropicStreamBlockState = TextBlockState | ReasoningBlockState | ToolBlockState;\n\nexport type AnthropicStreamState = {\n messageId: string;\n outputItems: Array<GenerativeModelOutputItem>;\n assistantParts: GenerativeModelOutputMessagePart[];\n blocks: Record<number, AnthropicStreamBlockState>;\n serverToolCalls: Record<string, string>;\n mcpToolCalls: Record<string, string>;\n finishReasonRaw?: string | null;\n usage: AnthropicStreamUsage;\n usesJsonResponseTool: boolean;\n};\n\nexport const createAnthropicStreamState = (\n messageId: string,\n usesJsonResponseTool = false,\n): AnthropicStreamState => ({\n messageId,\n outputItems: [],\n assistantParts: [],\n blocks: {},\n serverToolCalls: {},\n mcpToolCalls: {},\n finishReasonRaw: undefined,\n usage: {},\n usesJsonResponseTool,\n});\n\nconst createToolStartEvent = (\n parentMessageId: string,\n toolCallId: string,\n toolCallName: string,\n): Event =>\n ({\n type: Events.TOOL_CALL_START,\n parentMessageId,\n toolCallId,\n toolCallName,\n timestamp: Date.now(),\n }) as Event;\n\nconst createToolArgsEvent = (\n parentMessageId: string,\n toolCallId: string,\n toolCallName: string,\n delta: string,\n): Event =>\n ({\n type: Events.TOOL_CALL_ARGS,\n parentMessageId,\n toolCallId,\n toolCallName,\n delta,\n timestamp: Date.now(),\n }) as Event;\n\nconst createToolEndEvent = (\n parentMessageId: string,\n toolCallId: string,\n toolCallName: string,\n): Event =>\n ({\n type: Events.TOOL_CALL_END,\n parentMessageId,\n toolCallId,\n toolCallName,\n timestamp: Date.now(),\n }) as Event;\n\nconst createToolResultEvent = (\n parentMessageId: string,\n toolCallId: string,\n toolCallName: string,\n result: unknown,\n isError?: boolean,\n): Event =>\n ({\n type: Events.TOOL_CALL_RESULT,\n parentMessageId,\n toolCallId,\n toolCallName,\n result,\n isError,\n timestamp: Date.now(),\n }) as Event;\n\nconst finalizeStreamResponse = (state: AnthropicStreamState): GenerativeModelResponse => {\n const output = [...state.outputItems];\n\n if (state.assistantParts.length) {\n output.unshift({\n type: \"message\",\n role: \"assistant\",\n content: state.assistantParts,\n });\n }\n\n const hasToolCalls = output.some((item) => item.type === \"tool-call\" && \"arguments\" in item);\n\n return {\n output,\n finishReason:\n state.finishReasonRaw == null && hasToolCalls\n ? \"tool-calls\"\n : mapAnthropicStopReason(state.finishReasonRaw, state.usesJsonResponseTool),\n usage: mapAnthropicUsage(state.usage),\n };\n};\n\nexport function mapFromAnthropicStreamEvent(\n event: AnthropicResponseStreamEvent,\n state: AnthropicStreamState,\n): Result<\n { kind: \"event\"; event: Event } | { kind: \"final\"; response: GenerativeModelResponse } | null,\n BetterAgentError\n> {\n switch (event.type) {\n case \"ping\":\n return ok(null);\n case \"message_start\":\n state.usage = {\n ...state.usage,\n ...event.message.usage,\n };\n state.finishReasonRaw = event.message.stop_reason;\n return ok(null);\n case \"message_delta\":\n if (event.delta.stop_reason != null) {\n state.finishReasonRaw = event.delta.stop_reason;\n }\n state.usage = {\n ...state.usage,\n ...(event.usage ?? {}),\n };\n return ok(null);\n case \"content_block_start\": {\n const { index, content_block: part } = event;\n switch (part.type) {\n case \"text\":\n case \"compaction\": {\n const textMessageId = `${state.messageId}:text:${index}`;\n state.blocks[index] = {\n kind: \"text\",\n messageId: textMessageId,\n text: part.type === \"compaction\" ? part.content : \"\",\n ...(part.type === \"text\" && part.citations?.length\n ? { citations: [...part.citations] }\n : {}),\n };\n return ok({\n kind: \"event\",\n event: {\n type: Events.TEXT_MESSAGE_START,\n messageId: textMessageId,\n role: \"assistant\",\n timestamp: Date.now(),\n },\n });\n }\n case \"thinking\":\n case \"redacted_thinking\": {\n const reasoningMessageId = `${state.messageId}:reasoning:${index}`;\n state.blocks[index] = {\n kind: \"reasoning\",\n messageId: reasoningMessageId,\n };\n return ok({\n kind: \"event\",\n event: {\n type: Events.REASONING_MESSAGE_START,\n messageId: reasoningMessageId,\n role: \"assistant\",\n visibility: \"full\",\n timestamp: Date.now(),\n },\n });\n }\n case \"tool_use\": {\n const outputAsText = state.usesJsonResponseTool && part.name === \"json\";\n const initialInput = JSON.stringify(part.input ?? {});\n state.blocks[index] = {\n kind: \"tool\",\n callId: part.id,\n toolName: part.name,\n rawToolName: part.name,\n rawType: \"tool_use\",\n input: initialInput === \"{}\" ? \"\" : initialInput,\n outputAsText,\n providerExecuted: false,\n };\n\n if (outputAsText) {\n const textMessageId = `${state.messageId}:text:${index}`;\n state.blocks[index] = {\n ...(state.blocks[index] as ToolBlockState),\n kind: \"tool\",\n };\n return ok({\n kind: \"event\",\n event: {\n type: Events.TEXT_MESSAGE_START,\n messageId: textMessageId,\n role: \"assistant\",\n timestamp: Date.now(),\n },\n });\n }\n\n return ok({\n kind: \"event\",\n event: createToolStartEvent(state.messageId, part.id, part.name),\n });\n }\n case \"server_tool_use\": {\n state.serverToolCalls[part.id] = part.name;\n state.blocks[index] = {\n kind: \"tool\",\n callId: part.id,\n toolName: normalizeProviderToolName(part.name),\n rawToolName: part.name,\n rawType: \"server_tool_use\",\n input:\n JSON.stringify(part.input ?? {}) === \"{}\"\n ? \"\"\n : JSON.stringify(part.input ?? {}),\n outputAsText: false,\n providerExecuted: true,\n };\n\n return ok({\n kind: \"event\",\n event: createToolStartEvent(\n state.messageId,\n part.id,\n normalizeProviderToolName(part.name),\n ),\n });\n }\n case \"mcp_tool_use\": {\n state.mcpToolCalls[part.id] = part.name;\n state.blocks[index] = {\n kind: \"tool\",\n callId: part.id,\n toolName: part.name,\n rawToolName: part.name,\n rawType: \"mcp_tool_use\",\n input:\n JSON.stringify(part.input ?? {}) === \"{}\"\n ? \"\"\n : JSON.stringify(part.input ?? {}),\n outputAsText: false,\n providerExecuted: true,\n extra:\n part.server_name != null\n ? { server_name: part.server_name }\n : undefined,\n };\n\n return ok({\n kind: \"event\",\n event: createToolStartEvent(state.messageId, part.id, part.name),\n });\n }\n case \"mcp_tool_result\":\n case \"web_fetch_tool_result\":\n case \"web_search_tool_result\":\n case \"code_execution_tool_result\":\n case \"bash_code_execution_tool_result\":\n case \"text_editor_code_execution_tool_result\":\n case \"tool_search_tool_result\": {\n const toolName = mapProviderToolResultName(\n part,\n state.serverToolCalls,\n state.mcpToolCalls,\n );\n state.outputItems.push({\n type: \"provider-tool-result\",\n name: toolName,\n callId: part.tool_use_id,\n result: part,\n isError:\n \"is_error\" in part && typeof part.is_error === \"boolean\"\n ? part.is_error\n : undefined,\n });\n return ok({\n kind: \"event\",\n event: createToolResultEvent(\n state.messageId,\n part.tool_use_id,\n toolName,\n part,\n \"is_error\" in part && typeof part.is_error === \"boolean\"\n ? part.is_error\n : undefined,\n ),\n });\n }\n }\n\n return ok(null);\n }\n case \"content_block_delta\": {\n const block = state.blocks[event.index];\n if (!block) return ok(null);\n\n switch (event.delta.type) {\n case \"text_delta\":\n if (block.kind !== \"text\") return ok(null);\n block.text += event.delta.text;\n return ok({\n kind: \"event\",\n event: {\n type: Events.TEXT_MESSAGE_CONTENT,\n messageId: block.messageId,\n delta: event.delta.text,\n timestamp: Date.now(),\n },\n });\n case \"compaction_delta\":\n if (block.kind !== \"text\") return ok(null);\n if (event.delta.content) {\n block.text += event.delta.content;\n return ok({\n kind: \"event\",\n event: {\n type: Events.TEXT_MESSAGE_CONTENT,\n messageId: block.messageId,\n delta: event.delta.content,\n timestamp: Date.now(),\n },\n });\n }\n return ok(null);\n case \"thinking_delta\":\n if (block.kind !== \"reasoning\") return ok(null);\n return ok({\n kind: \"event\",\n event: {\n type: Events.REASONING_MESSAGE_CONTENT,\n messageId: block.messageId,\n visibility: \"full\",\n delta: event.delta.thinking,\n timestamp: Date.now(),\n },\n });\n case \"signature_delta\":\n return ok(null);\n case \"input_json_delta\":\n if (block.kind !== \"tool\") return ok(null);\n block.input += event.delta.partial_json;\n if (block.outputAsText) {\n return ok({\n kind: \"event\",\n event: {\n type: Events.TEXT_MESSAGE_CONTENT,\n messageId: `${state.messageId}:text:${event.index}`,\n delta: event.delta.partial_json,\n timestamp: Date.now(),\n },\n });\n }\n return ok({\n kind: \"event\",\n event: createToolArgsEvent(\n state.messageId,\n block.callId,\n block.toolName,\n event.delta.partial_json,\n ),\n });\n case \"citations_delta\":\n if (block.kind !== \"text\") return ok(null);\n block.citations = [...(block.citations ?? []), event.delta.citation];\n return ok(null);\n }\n return ok(null);\n }\n case \"content_block_stop\": {\n const block = state.blocks[event.index];\n if (!block) return ok(null);\n delete state.blocks[event.index];\n\n if (block.kind === \"text\") {\n if (block.text.length > 0) {\n state.assistantParts.push({\n type: \"text\",\n text: block.text,\n ...(block.citations?.length\n ? {\n providerMetadata: getAnthropicTextProviderMetadata(\n block.citations,\n ),\n }\n : {}),\n });\n }\n return ok({\n kind: \"event\",\n event: {\n type: Events.TEXT_MESSAGE_END,\n messageId: block.messageId,\n timestamp: Date.now(),\n },\n });\n }\n\n if (block.kind === \"reasoning\") {\n return ok({\n kind: \"event\",\n event: {\n type: Events.REASONING_MESSAGE_END,\n messageId: block.messageId,\n visibility: \"full\",\n timestamp: Date.now(),\n },\n });\n }\n\n if (block.outputAsText) {\n const finalText = block.input.trim() ? block.input : \"{}\";\n state.assistantParts.push({\n type: \"text\",\n text: finalText,\n });\n state.usesJsonResponseTool = true;\n return ok({\n kind: \"event\",\n event: {\n type: Events.TEXT_MESSAGE_END,\n messageId: `${state.messageId}:text:${event.index}`,\n timestamp: Date.now(),\n },\n });\n }\n\n if (block.rawType === \"tool_use\") {\n state.outputItems.push({\n type: \"tool-call\",\n name: block.toolName,\n arguments: block.input.trim() ? block.input : \"{}\",\n callId: block.callId,\n });\n } else {\n state.outputItems.push({\n type: \"provider-tool-result\",\n name: block.toolName,\n callId: block.callId,\n result: omitNullish({\n type: block.rawType,\n id: block.callId,\n name: block.rawToolName,\n input: parseMaybeJson(block.input),\n ...(block.extra ?? {}),\n }),\n });\n }\n\n return ok({\n kind: \"event\",\n event: createToolEndEvent(state.messageId, block.callId, block.toolName),\n });\n }\n case \"message_stop\":\n return ok({\n kind: \"final\",\n response: finalizeStreamResponse(state),\n });\n case \"error\":\n return err(\n BetterAgentError.fromCode(\n \"UPSTREAM_FAILED\",\n event.error.message ?? \"Anthropic streaming error\",\n {\n context: {\n provider: \"anthropic\",\n upstreamCode: event.error.type ?? \"STREAM_ERROR\",\n raw: event,\n },\n },\n ).at({ at: \"anthropic.messages.stream.event\" }),\n );\n }\n}\n","import type { RunContext } from \"@better-agent/core\";\nimport type { Event } from \"@better-agent/core/events\";\nimport type {\n GenerativeModelCallOptions,\n GenerativeModelGenerateResult,\n GenerativeModelResponse,\n ModalitiesParam,\n} from \"@better-agent/core/providers\";\nimport { BetterAgentError } from \"@better-agent/shared/errors\";\nimport type { Result } from \"@better-agent/shared/neverthrow\";\nimport { err, ok } from \"@better-agent/shared/neverthrow\";\n\nimport type { createAnthropicClient } from \"../client/create-client\";\nimport {\n createAnthropicStreamState,\n mapFromAnthropicMessagesResponse,\n mapFromAnthropicStreamEvent,\n mapToAnthropicMessagesRequest,\n} from \"./mappers\";\nimport type { AnthropicResponseStreamEvent } from \"./schemas\";\nimport type {\n AnthropicResponseCaps,\n AnthropicResponseEndpointOptions,\n AnthropicResponseGenerativeModel,\n AnthropicResponseModelId,\n} from \"./types\";\n\nexport const ANTHROPIC_RESPONSE_CAPS = {\n inputModalities: { text: true, image: true, file: true },\n inputShape: \"chat\",\n replayMode: \"multi_turn\",\n supportsInstruction: true,\n outputModalities: {\n text: {\n options: {},\n },\n },\n tools: true,\n structured_output: true,\n additionalSupportedRoles: [\"developer\"],\n} as const satisfies AnthropicResponseCaps;\n\nconst createDeferred = <T>() => {\n let resolve!: (value: T | PromiseLike<T>) => void;\n let reject!: (reason?: unknown) => void;\n const promise = new Promise<T>((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return { promise, resolve, reject };\n};\n\nexport const createAnthropicResponsesModel = <M extends AnthropicResponseModelId>(\n modelId: M,\n client: ReturnType<typeof createAnthropicClient>,\n): AnthropicResponseGenerativeModel<M> => {\n const doGenerate: NonNullable<AnthropicResponseGenerativeModel<M>[\"doGenerate\"]> = async <\n const TModalities extends ModalitiesParam<AnthropicResponseCaps>,\n >(\n options: GenerativeModelCallOptions<\n AnthropicResponseCaps,\n AnthropicResponseEndpointOptions,\n TModalities\n >,\n ctx: RunContext,\n ) => {\n const mappedRequest = mapToAnthropicMessagesRequest({\n modelId,\n options,\n stream: false,\n });\n if (mappedRequest.isErr()) {\n return err(mappedRequest.error.at({ at: \"anthropic.generate.mapRequest\" }));\n }\n\n const raw = await client.messages.create(mappedRequest.value.request, {\n signal: ctx.signal ?? null,\n beta: mappedRequest.value.betas,\n });\n if (raw.isErr()) {\n return err(raw.error.at({ at: \"anthropic.generate.http\" }));\n }\n\n const response = mapFromAnthropicMessagesResponse({\n response: raw.value,\n usesJsonResponseTool: mappedRequest.value.usesJsonResponseTool,\n });\n\n return ok({\n response: {\n ...response,\n request: {\n body: mappedRequest.value.request,\n },\n } satisfies GenerativeModelResponse,\n } satisfies GenerativeModelGenerateResult<AnthropicResponseCaps>);\n };\n\n const doGenerateStream: NonNullable<\n AnthropicResponseGenerativeModel<M>[\"doGenerateStream\"]\n > = async <const TModalities extends ModalitiesParam<AnthropicResponseCaps>>(\n options: GenerativeModelCallOptions<\n AnthropicResponseCaps,\n AnthropicResponseEndpointOptions,\n TModalities\n >,\n ctx: RunContext,\n ) => {\n const mappedRequest = mapToAnthropicMessagesRequest({\n modelId,\n options,\n stream: true,\n });\n if (mappedRequest.isErr()) {\n return err(mappedRequest.error.at({ at: \"anthropic.generateStream.mapRequest\" }));\n }\n\n const streamResult = await client.messages.stream(\n {\n ...mappedRequest.value.request,\n stream: true,\n },\n {\n signal: ctx.signal ?? null,\n beta: mappedRequest.value.betas,\n },\n );\n if (streamResult.isErr()) {\n return err(streamResult.error.at({ at: \"anthropic.generateStream.http\" }));\n }\n\n const {\n promise: final,\n resolve: resolveFinal,\n reject: rejectFinal,\n } = createDeferred<GenerativeModelResponse>();\n\n const events = (async function* (): AsyncGenerator<Result<Event, BetterAgentError>> {\n const responseMessageId = ctx.generateMessageId();\n const state = createAnthropicStreamState(\n responseMessageId,\n mappedRequest.value.usesJsonResponseTool,\n );\n let sawFinal = false;\n\n try {\n for await (const raw of streamResult.value) {\n if (raw.isErr()) {\n rejectFinal(raw.error);\n yield err(raw.error);\n return;\n }\n\n const mapped = mapFromAnthropicStreamEvent(\n raw.value as AnthropicResponseStreamEvent,\n state,\n );\n if (mapped.isErr()) {\n const error = mapped.error.at({ at: \"anthropic.generateStream.mapEvent\" });\n rejectFinal(error);\n yield err(error);\n return;\n }\n\n if (!mapped.value) continue;\n\n if (mapped.value.kind === \"final\") {\n sawFinal = true;\n resolveFinal({\n ...mapped.value.response,\n request: {\n body: mappedRequest.value.request,\n },\n });\n continue;\n }\n\n yield ok(mapped.value.event);\n }\n } finally {\n if (!sawFinal) {\n rejectFinal(\n BetterAgentError.fromCode(\n \"UPSTREAM_FAILED\",\n \"Anthropic stream ended without a final response event.\",\n {\n context: {\n provider: \"anthropic\",\n model: String(modelId),\n },\n },\n ).at({\n at: \"anthropic.generateStream.final\",\n }),\n );\n }\n }\n })();\n\n return ok({ events, final });\n };\n\n return {\n providerId: \"anthropic\",\n modelId,\n caps: ANTHROPIC_RESPONSE_CAPS,\n doGenerate,\n doGenerateStream,\n };\n};\n","import { createAnthropicClient as createAnthropicHttpClient } from \"./client\";\nimport { createAnthropicResponsesModel } from \"./responses/model\";\nimport { createAnthropicNativeToolBuilders } from \"./tools\";\nimport type {\n AnthropicConfig,\n AnthropicGenerativeModel,\n AnthropicModelId,\n AnthropicProvider,\n AnthropicResponseModelId,\n} from \"./types\";\n\nexport const createAnthropic = (config: AnthropicConfig): AnthropicProvider => {\n const httpClient = createAnthropicHttpClient(config);\n const tools = createAnthropicNativeToolBuilders();\n\n const provider: AnthropicProvider = {\n id: \"anthropic\",\n tools,\n\n model<M extends AnthropicModelId>(modelId: M) {\n return createAnthropicResponsesModel(\n modelId,\n httpClient,\n ) as AnthropicGenerativeModel<M>;\n },\n\n text<M extends AnthropicResponseModelId>(modelId: M) {\n return createAnthropicResponsesModel(modelId, httpClient);\n },\n };\n\n return provider;\n};\n"],"mappings":";;;;;;;;;AAOA,MAAa,yBACT,QACA,UAAwC,EAAE,KACjB;CACzB,MAAM,UAAkC;EACpC,qBAAqB,OAAO,oBAAoB;EAChD,GAAI,OAAO,WAAW,EAAE;EACxB,GAAI,QAAQ,WAAW,EAAE;EAC5B;AAED,KAAI,OAAO,UACP,SAAQ,gBAAgB,UAAU,OAAO;UAClC,OAAO,OACd,SAAQ,eAAe,OAAO;AAGlC,KAAI,QAAQ,MAAM,OACd,SAAQ,oBAAoB,QAAQ,KAAK,KAAK,IAAI;AAGtD,QAAO;;;;;ACjBX,MAAa,yBACT,WACA,QAImB;AACnB,KAAI,CAAC,UACD,QAAO,iBAAiB,SAAS,mBAAmB,4BAA4B,EAC5E,SAAS,EACL,UAAU,aACb,EACJ,CAAC,CAAC,GAAG;EACF,IAAI,IAAI;EACR,MAAM,EACF,MAAM,IAAI,MACb;EACJ,CAAC;CAGN,MAAM,E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,CAAC,CACL;;OAGT;GAEgB;GAAO,CAAC;;AAGhC,QAAO;EACH,YAAY;EACZ;EACA,MAAM;EACN;EACA;EACH;;;;;ACrML,MAAa,mBAAmB,WAA+C;CAC3E,MAAM,aAAaA,sBAA0B,OAAO;AAmBpD,QAhBoC;EAChC,IAAI;EACJ,OAJU,mCAAmC;EAM7C,MAAkC,SAAY;AAC1C,UAAO,8BACH,SACA,WACH;;EAGL,KAAyC,SAAY;AACjD,UAAO,8BAA8B,SAAS,WAAW;;EAEhE"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
//#region src/utils/object-utils.ts
|
|
2
|
+
const omitNullish = (input) => {
|
|
3
|
+
const out = {};
|
|
4
|
+
for (const key in input) {
|
|
5
|
+
const typedKey = key;
|
|
6
|
+
const value = input[typedKey];
|
|
7
|
+
if (value != null) out[typedKey] = value;
|
|
8
|
+
}
|
|
9
|
+
return out;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Extracts keys from `options` that are not in the `knownKeys` set.
|
|
13
|
+
*/
|
|
14
|
+
const extractPassthroughOptions = (options, knownKeys) => {
|
|
15
|
+
const out = {};
|
|
16
|
+
for (const key of Object.keys(options)) if (!knownKeys.has(key)) {
|
|
17
|
+
const value = options[key];
|
|
18
|
+
if (value !== void 0) out[key] = value;
|
|
19
|
+
}
|
|
20
|
+
return out;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/utils/fetch.ts
|
|
25
|
+
const RETRY_ATTEMPTS = 3;
|
|
26
|
+
const RETRY_BASE_DELAY_MS = 1e3;
|
|
27
|
+
const RETRY_MAX_DELAY_MS = 8e3;
|
|
28
|
+
const REQUEST_TIMEOUT_MS = 6e4;
|
|
29
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
30
|
+
const parseJsonBody = async (response) => {
|
|
31
|
+
const text = await response.text();
|
|
32
|
+
if (!text) return void 0;
|
|
33
|
+
try {
|
|
34
|
+
return JSON.parse(text);
|
|
35
|
+
} catch {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const extractErrorField = (body) => {
|
|
40
|
+
if (!body || typeof body !== "object" || !("error" in body)) return void 0;
|
|
41
|
+
return body.error;
|
|
42
|
+
};
|
|
43
|
+
const baFetch = async (input, options = {}) => {
|
|
44
|
+
let lastError;
|
|
45
|
+
for (let attempt = 0; attempt < RETRY_ATTEMPTS; attempt += 1) {
|
|
46
|
+
const ctrl = new AbortController();
|
|
47
|
+
const timeoutId = setTimeout(() => ctrl.abort(), REQUEST_TIMEOUT_MS);
|
|
48
|
+
const abort = () => ctrl.abort();
|
|
49
|
+
options.signal?.addEventListener("abort", abort, { once: true });
|
|
50
|
+
try {
|
|
51
|
+
const response = await fetch(input, {
|
|
52
|
+
method: options.method,
|
|
53
|
+
body: options.body,
|
|
54
|
+
headers: options.headers,
|
|
55
|
+
signal: ctrl.signal
|
|
56
|
+
});
|
|
57
|
+
const body = await parseJsonBody(response);
|
|
58
|
+
if (!response.ok) return {
|
|
59
|
+
error: {
|
|
60
|
+
status: response.status,
|
|
61
|
+
statusText: response.statusText,
|
|
62
|
+
error: extractErrorField(body)
|
|
63
|
+
},
|
|
64
|
+
response
|
|
65
|
+
};
|
|
66
|
+
return {
|
|
67
|
+
data: body,
|
|
68
|
+
response
|
|
69
|
+
};
|
|
70
|
+
} catch (error) {
|
|
71
|
+
lastError = error;
|
|
72
|
+
if (attempt === RETRY_ATTEMPTS - 1 || options.signal?.aborted) throw error;
|
|
73
|
+
await sleep(Math.min(RETRY_BASE_DELAY_MS * 2 ** attempt, RETRY_MAX_DELAY_MS));
|
|
74
|
+
} finally {
|
|
75
|
+
clearTimeout(timeoutId);
|
|
76
|
+
options.signal?.removeEventListener("abort", abort);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
throw lastError instanceof Error ? lastError : new Error(String(lastError));
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
//#endregion
|
|
83
|
+
export { extractPassthroughOptions as n, omitNullish as r, baFetch as t };
|
|
84
|
+
//# sourceMappingURL=fetch-CW0dWlVC.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-CW0dWlVC.mjs","names":[],"sources":["../src/utils/object-utils.ts","../src/utils/fetch.ts"],"sourcesContent":["export const omitNullish = <T extends Record<string, unknown>>(input: T): Partial<T> => {\n const out: Partial<T> = {};\n\n for (const key in input) {\n const typedKey = key as keyof T;\n const value = input[typedKey];\n\n if (value != null) {\n out[typedKey] = value;\n }\n }\n\n return out;\n};\n\n/**\n * Extracts keys from `options` that are not in the `knownKeys` set.\n */\nexport const extractPassthroughOptions = (\n options: Record<string, unknown>,\n knownKeys: ReadonlySet<string>,\n): Record<string, unknown> => {\n const out: Record<string, unknown> = {};\n for (const key of Object.keys(options)) {\n if (!knownKeys.has(key)) {\n const value = options[key];\n if (value !== undefined) {\n out[key] = value;\n }\n }\n }\n return out;\n};\n","type FetchErrorPayload<TError> = {\n status: number;\n statusText: string;\n error?: TError extends { error?: infer TInner } ? TInner : unknown;\n};\n\ntype FetchResult<TData, TError> = {\n data?: TData;\n error?: FetchErrorPayload<TError>;\n response: Response;\n};\n\ntype FetchOptions = {\n method?: string;\n body?: BodyInit | null;\n headers?: HeadersInit;\n signal?: AbortSignal | null;\n throw?: boolean;\n};\n\nconst RETRY_ATTEMPTS = 3;\nconst RETRY_BASE_DELAY_MS = 1_000;\nconst RETRY_MAX_DELAY_MS = 8_000;\nconst REQUEST_TIMEOUT_MS = 60_000;\n\nconst sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));\n\nconst parseJsonBody = async (response: Response): Promise<unknown> => {\n const text = await response.text();\n if (!text) return undefined;\n\n try {\n return JSON.parse(text);\n } catch {\n return undefined;\n }\n};\n\nconst extractErrorField = <TError>(body: unknown): FetchErrorPayload<TError>[\"error\"] => {\n if (!body || typeof body !== \"object\" || !(\"error\" in body)) return undefined;\n return (body as { error?: FetchErrorPayload<TError>[\"error\"] }).error;\n};\n\nexport const baFetch = async <TData, TError>(\n input: string,\n options: FetchOptions = {},\n): Promise<FetchResult<TData, TError>> => {\n let lastError: unknown;\n\n for (let attempt = 0; attempt < RETRY_ATTEMPTS; attempt += 1) {\n const ctrl = new AbortController();\n const timeoutId = setTimeout(() => ctrl.abort(), REQUEST_TIMEOUT_MS);\n const abort = () => ctrl.abort();\n options.signal?.addEventListener(\"abort\", abort, { once: true });\n\n try {\n const response = await fetch(input, {\n method: options.method,\n body: options.body,\n headers: options.headers,\n signal: ctrl.signal,\n });\n\n const body = await parseJsonBody(response);\n if (!response.ok) {\n return {\n error: {\n status: response.status,\n statusText: response.statusText,\n error: extractErrorField<TError>(body),\n },\n response,\n };\n }\n\n return {\n data: body as TData | undefined,\n response,\n };\n } catch (error) {\n lastError = error;\n if (attempt === RETRY_ATTEMPTS - 1 || options.signal?.aborted) {\n throw error;\n }\n\n const delay = Math.min(RETRY_BASE_DELAY_MS * 2 ** attempt, RETRY_MAX_DELAY_MS);\n await sleep(delay);\n } finally {\n clearTimeout(timeoutId);\n options.signal?.removeEventListener(\"abort\", abort);\n }\n }\n\n throw lastError instanceof Error ? lastError : new Error(String(lastError));\n};\n"],"mappings":";AAAA,MAAa,eAAkD,UAAyB;CACpF,MAAM,MAAkB,EAAE;AAE1B,MAAK,MAAM,OAAO,OAAO;EACrB,MAAM,WAAW;EACjB,MAAM,QAAQ,MAAM;AAEpB,MAAI,SAAS,KACT,KAAI,YAAY;;AAIxB,QAAO;;;;;AAMX,MAAa,6BACT,SACA,cAC0B;CAC1B,MAAM,MAA+B,EAAE;AACvC,MAAK,MAAM,OAAO,OAAO,KAAK,QAAQ,CAClC,KAAI,CAAC,UAAU,IAAI,IAAI,EAAE;EACrB,MAAM,QAAQ,QAAQ;AACtB,MAAI,UAAU,OACV,KAAI,OAAO;;AAIvB,QAAO;;;;;ACXX,MAAM,iBAAiB;AACvB,MAAM,sBAAsB;AA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