@tanstack/ai-anthropic 0.16.5 → 0.16.7
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/esm/adapters/text.js +4 -3
- package/dist/esm/adapters/text.js.map +1 -1
- package/dist/esm/model-meta.d.ts +45 -1
- package/dist/esm/model-meta.js +47 -1
- package/dist/esm/model-meta.js.map +1 -1
- package/dist/esm/tools/anthropic-provider-tool.d.ts +24 -0
- package/dist/esm/tools/anthropic-provider-tool.js +50 -0
- package/dist/esm/tools/anthropic-provider-tool.js.map +1 -0
- package/dist/esm/tools/bash-tool.js +4 -4
- package/dist/esm/tools/bash-tool.js.map +1 -1
- package/dist/esm/tools/code-execution-tool.js +10 -9
- package/dist/esm/tools/code-execution-tool.js.map +1 -1
- package/dist/esm/tools/computer-use-tool.js +4 -4
- package/dist/esm/tools/computer-use-tool.js.map +1 -1
- package/dist/esm/tools/memory-tool.js +4 -4
- package/dist/esm/tools/memory-tool.js.map +1 -1
- package/dist/esm/tools/text-editor-tool.js +4 -4
- package/dist/esm/tools/text-editor-tool.js.map +1 -1
- package/dist/esm/tools/tool-converter.js +7 -4
- package/dist/esm/tools/tool-converter.js.map +1 -1
- package/dist/esm/tools/web-fetch-tool.js +4 -4
- package/dist/esm/tools/web-fetch-tool.js.map +1 -1
- package/dist/esm/tools/web-search-tool.js +9 -9
- package/dist/esm/tools/web-search-tool.js.map +1 -1
- package/package.json +4 -4
- package/src/adapters/text.ts +8 -5
- package/src/model-meta.ts +82 -0
- package/src/tools/anthropic-provider-tool.ts +68 -0
- package/src/tools/bash-tool.ts +13 -7
- package/src/tools/code-execution-tool.ts +22 -8
- package/src/tools/computer-use-tool.ts +15 -7
- package/src/tools/memory-tool.ts +16 -7
- package/src/tools/text-editor-tool.ts +15 -7
- package/src/tools/tool-converter.ts +7 -6
- package/src/tools/web-fetch-tool.ts +16 -7
- package/src/tools/web-search-tool.ts +27 -31
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-meta.js","names":[],"sources":["../../src/model-meta.ts"],"sourcesContent":["import type {\n AnthropicAdaptiveOnlyThinkingOptions,\n AnthropicAdaptiveOrDisabledThinkingOptions,\n AnthropicAdaptiveThinkingOptions,\n AnthropicCacheControlOptions,\n AnthropicContainerOptions,\n AnthropicContextManagementOptions,\n AnthropicMCPOptions,\n AnthropicMaxTokensOptions,\n AnthropicOutputConfigOptions,\n AnthropicSamplingOptions,\n AnthropicServiceTierOptions,\n AnthropicStopSequencesOptions,\n AnthropicThinkingOptions,\n AnthropicToolChoiceOptions,\n} from './text/text-provider-options'\n\ninterface ModelMeta<\n TProviderOptions = unknown,\n TToolCapabilities = unknown,\n TMessageCapabilities = unknown,\n> {\n name: string\n id: string\n supports: {\n input: Array<'text' | 'image' | 'audio' | 'video' | 'document'>\n extended_thinking?: boolean\n adaptive_thinking?: boolean\n priority_tier?: boolean\n tools?: Array<\n | 'web_search'\n | 'web_fetch'\n | 'code_execution'\n | 'computer_use'\n | 'bash'\n | 'text_editor'\n | 'memory'\n >\n }\n context_window?: number\n max_output_tokens?: number\n knowledge_cutoff?: string\n pricing: {\n input: {\n normal: number\n cached?: number\n }\n output: {\n normal: number\n }\n }\n /**\n * Type-level description of which provider options this model supports.\n */\n providerOptions?: TProviderOptions\n /**\n * Type-level description of which tool capabilities this model supports.\n */\n toolCapabilities?: TToolCapabilities\n /**\n * Type-level description of which message/input capabilities this model supports.\n */\n messageCapabilities?: TMessageCapabilities\n}\n\n// Claude Opus 4.6 accepts adaptive thinking alongside the deprecated\n// budget-based extended thinking, and still accepts sampling parameters.\nconst CLAUDE_OPUS_4_6 = {\n name: 'claude-opus-4-6',\n id: 'claude-opus-4-6',\n context_window: 200_000,\n max_output_tokens: 128_000,\n knowledge_cutoff: '2025-05-01',\n pricing: {\n input: {\n normal: 5,\n },\n output: {\n normal: 25,\n },\n },\n supports: {\n input: ['text', 'image', 'document'],\n extended_thinking: true,\n adaptive_thinking: true,\n priority_tier: true,\n tools: [\n 'web_search',\n 'web_fetch',\n 'code_execution',\n 'computer_use',\n 'bash',\n 'text_editor',\n 'memory',\n ],\n },\n} as const satisfies ModelMeta<\n AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicAdaptiveThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n>\n\nconst CLAUDE_OPUS_4_5 = {\n name: 'claude-opus-4-5',\n id: 'claude-opus-4-5',\n context_window: 200_000,\n max_output_tokens: 32_000,\n knowledge_cutoff: '2025-11-01',\n pricing: {\n input: {\n normal: 15,\n },\n output: {\n normal: 75,\n },\n },\n supports: {\n input: ['text', 'image', 'document'],\n extended_thinking: true,\n priority_tier: true,\n tools: [\n 'web_search',\n 'web_fetch',\n 'code_execution',\n 'computer_use',\n 'bash',\n 'text_editor',\n 'memory',\n ],\n },\n} as const satisfies ModelMeta<\n AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n>\n\n// Claude Sonnet 4.6 accepts adaptive thinking alongside the deprecated\n// budget-based extended thinking, and still accepts sampling parameters.\nconst CLAUDE_SONNET_4_6 = {\n name: 'claude-sonnet-4-6',\n id: 'claude-sonnet-4-6',\n context_window: 1_000_000,\n max_output_tokens: 64_000,\n knowledge_cutoff: '2025-08-01',\n pricing: {\n input: {\n normal: 3,\n },\n output: {\n normal: 15,\n },\n },\n supports: {\n input: ['text', 'image', 'document'],\n extended_thinking: true,\n adaptive_thinking: true,\n priority_tier: true,\n tools: [\n 'web_search',\n 'web_fetch',\n 'code_execution',\n 'computer_use',\n 'bash',\n 'text_editor',\n 'memory',\n ],\n },\n} as const satisfies ModelMeta<\n AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicAdaptiveThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n>\n\nconst CLAUDE_SONNET_4_5 = {\n name: 'claude-sonnet-4-5',\n id: 'claude-sonnet-4-5',\n context_window: 200_000,\n max_output_tokens: 64_000,\n knowledge_cutoff: '2025-09-29',\n pricing: {\n input: {\n normal: 3,\n },\n output: {\n normal: 15,\n },\n },\n supports: {\n input: ['text', 'image', 'document'],\n extended_thinking: true,\n priority_tier: true,\n tools: [\n 'web_search',\n 'web_fetch',\n 'code_execution',\n 'computer_use',\n 'bash',\n 'text_editor',\n 'memory',\n ],\n },\n} as const satisfies ModelMeta<\n AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n>\n\nconst CLAUDE_HAIKU_4_5 = {\n name: 'claude-haiku-4-5',\n id: 'claude-haiku-4-5',\n context_window: 200_000,\n max_output_tokens: 64_000,\n knowledge_cutoff: '2025-10-01',\n pricing: {\n input: {\n normal: 1,\n },\n output: {\n normal: 5,\n },\n },\n supports: {\n input: ['text', 'image', 'document'],\n extended_thinking: true,\n priority_tier: true,\n tools: [\n 'web_search',\n 'web_fetch',\n 'code_execution',\n 'computer_use',\n 'bash',\n 'text_editor',\n 'memory',\n ],\n },\n} as const satisfies ModelMeta<\n AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n>\n\nconst CLAUDE_OPUS_4_1 = {\n name: 'claude-opus-4-1',\n id: 'claude-opus-4-1',\n context_window: 200_000,\n max_output_tokens: 64_000,\n knowledge_cutoff: '2025-08-05',\n pricing: {\n input: {\n normal: 15,\n },\n output: {\n normal: 75,\n },\n },\n supports: {\n input: ['text', 'image', 'document'],\n extended_thinking: true,\n priority_tier: true,\n tools: [\n 'web_search',\n 'web_fetch',\n 'code_execution',\n 'computer_use',\n 'bash',\n 'text_editor',\n 'memory',\n ],\n },\n} as const satisfies ModelMeta<\n AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n>\n\n// Claude Opus 4.7 removed budget-based extended thinking and the sampling\n// parameters (`temperature`, `top_p`, `top_k`) — sending either returns a\n// 400. Use adaptive thinking with `output_config.effort` instead.\nconst CLAUDE_OPUS_4_7 = {\n name: 'claude-opus-4-7',\n id: 'claude-opus-4-7',\n context_window: 1_000_000,\n max_output_tokens: 128_000,\n supports: {\n input: ['text', 'image', 'document'],\n extended_thinking: false,\n adaptive_thinking: true,\n priority_tier: true,\n tools: [\n 'web_search',\n 'web_fetch',\n 'code_execution',\n 'computer_use',\n 'bash',\n 'text_editor',\n 'memory',\n ],\n },\n pricing: {\n input: {\n normal: 5,\n cached: 0.5,\n },\n output: {\n normal: 25,\n },\n },\n} as const satisfies ModelMeta<\n AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicAdaptiveOrDisabledThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicMaxTokensOptions &\n AnthropicOutputConfigOptions\n>\n\n// Claude Opus 4.8 keeps the same request surface as Opus 4.7: adaptive\n// thinking only (budget_tokens 400s), no sampling parameters.\nconst CLAUDE_OPUS_4_8 = {\n name: 'claude-opus-4-8',\n id: 'claude-opus-4-8',\n context_window: 1_000_000,\n max_output_tokens: 128_000,\n supports: {\n input: ['text', 'image', 'document'],\n extended_thinking: false,\n adaptive_thinking: true,\n priority_tier: true,\n tools: [\n 'web_search',\n 'web_fetch',\n 'code_execution',\n 'computer_use',\n 'bash',\n 'text_editor',\n 'memory',\n ],\n },\n pricing: {\n input: {\n normal: 5,\n cached: 0.5,\n },\n output: {\n normal: 25,\n },\n },\n} as const satisfies ModelMeta<\n AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicAdaptiveOrDisabledThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicMaxTokensOptions &\n AnthropicOutputConfigOptions\n>\n\n// Claude Fable 5: thinking is always on — the only accepted explicit\n// `thinking` config is `{type: 'adaptive'}` (disabled/budget_tokens 400),\n// and the sampling parameters (`temperature`, `top_p`, `top_k`) are\n// rejected. Its provider options therefore use the adaptive-only thinking\n// shape and `max_tokens` without the sampling knobs.\nconst CLAUDE_FABLE_5 = {\n name: 'claude-fable-5',\n id: 'claude-fable-5',\n context_window: 1_000_000,\n max_output_tokens: 128_000,\n supports: {\n input: ['text', 'image', 'document'],\n extended_thinking: false,\n adaptive_thinking: true,\n priority_tier: true,\n tools: [\n 'web_search',\n 'web_fetch',\n 'code_execution',\n 'computer_use',\n 'bash',\n 'text_editor',\n 'memory',\n ],\n },\n pricing: {\n input: {\n normal: 10,\n cached: 1,\n },\n output: {\n normal: 50,\n },\n },\n} as const satisfies ModelMeta<\n AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicAdaptiveOnlyThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicMaxTokensOptions &\n AnthropicOutputConfigOptions\n>\n\n// Claude Sonnet 5: adaptive thinking is the default (omitting `thinking`\n// runs adaptive); `{type: 'disabled'}` opts out, but the manual\n// `{type: 'enabled', budget_tokens}` shape and non-default sampling\n// parameters (`temperature`, `top_p`, `top_k`) are rejected with a 400.\n// Pricing below is the sticker $3/$15 per MTok (an introductory $2/$10\n// applies through 2026-08-31).\nconst CLAUDE_SONNET_5 = {\n name: 'claude-sonnet-5',\n id: 'claude-sonnet-5',\n context_window: 1_000_000,\n max_output_tokens: 128_000,\n supports: {\n input: ['text', 'image', 'document'],\n extended_thinking: false,\n adaptive_thinking: true,\n priority_tier: true,\n tools: [\n 'web_search',\n 'web_fetch',\n 'code_execution',\n 'computer_use',\n 'bash',\n 'text_editor',\n 'memory',\n ],\n },\n pricing: {\n input: {\n normal: 3,\n cached: 0.3,\n },\n output: {\n normal: 15,\n },\n },\n} as const satisfies ModelMeta<\n AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicAdaptiveOrDisabledThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicMaxTokensOptions &\n AnthropicOutputConfigOptions\n>\n\n/**\n * Model ids accepted by the Anthropic text adapter.\n *\n * Every id here resolves against the first-party Anthropic API\n * (`GET /v1/models/{id}`). Retired models (Claude 3.x, Sonnet 3.7,\n * Opus 4 / Sonnet 4) and the `-fast` variant ids (fast mode is requested\n * via the `speed` parameter, not a model id) were removed after Anthropic\n * turned them off.\n */\nexport const ANTHROPIC_MODELS = [\n CLAUDE_OPUS_4_6.id,\n CLAUDE_OPUS_4_5.id,\n CLAUDE_SONNET_4_6.id,\n CLAUDE_SONNET_4_5.id,\n CLAUDE_HAIKU_4_5.id,\n CLAUDE_OPUS_4_1.id,\n\n CLAUDE_OPUS_4_7.id,\n CLAUDE_OPUS_4_8.id,\n\n CLAUDE_FABLE_5.id,\n CLAUDE_SONNET_5.id,\n] as const\n\n/**\n * Fallback `max_tokens` ceiling for a model whose metadata carries no\n * `max_output_tokens` (e.g. an unrecognized model id). Anthropic's Messages\n * API *requires* `max_tokens`, so the adapter must always send a value. 64K is\n * the output ceiling of the current mainstream Claude tier (Sonnet/Haiku 4.5),\n * so it's a sane default for an unknown — almost certainly modern — model and\n * avoids silently truncating long generations (issue #849). Recognized models\n * use their exact `max_output_tokens` from {@link ANTHROPIC_MODEL_MAX_OUTPUT_TOKENS}\n * (e.g. 128K for Opus), so this fallback only ever applies to ids not in the\n * map.\n */\nexport const ANTHROPIC_DEFAULT_MAX_OUTPUT_TOKENS = 64_000\n\n/**\n * Runtime lookup of each model's maximum output-token ceiling, keyed by model\n * id. Lets the text adapter default the required `max_tokens` request field to\n * the model's real ceiling when the caller doesn't specify one, rather than a\n * low constant that truncates responses mid-stream (issue #849).\n *\n * Kept in sync with {@link ANTHROPIC_MODELS} by `scripts/sync-provider-models.ts`\n * — when that script adds a model it also inserts the model's `max_output_tokens`\n * here, so a freshly-synced model resolves to its real ceiling rather than the\n * fallback above.\n */\nconst ANTHROPIC_MODEL_MAX_OUTPUT_TOKENS: Record<string, number> = {\n [CLAUDE_OPUS_4_6.id]: CLAUDE_OPUS_4_6.max_output_tokens,\n [CLAUDE_OPUS_4_5.id]: CLAUDE_OPUS_4_5.max_output_tokens,\n [CLAUDE_SONNET_4_6.id]: CLAUDE_SONNET_4_6.max_output_tokens,\n [CLAUDE_SONNET_4_5.id]: CLAUDE_SONNET_4_5.max_output_tokens,\n [CLAUDE_HAIKU_4_5.id]: CLAUDE_HAIKU_4_5.max_output_tokens,\n [CLAUDE_OPUS_4_1.id]: CLAUDE_OPUS_4_1.max_output_tokens,\n [CLAUDE_OPUS_4_7.id]: CLAUDE_OPUS_4_7.max_output_tokens,\n [CLAUDE_OPUS_4_8.id]: CLAUDE_OPUS_4_8.max_output_tokens,\n [CLAUDE_FABLE_5.id]: CLAUDE_FABLE_5.max_output_tokens,\n [CLAUDE_SONNET_5.id]: CLAUDE_SONNET_5.max_output_tokens,\n}\n\n/**\n * Largest `max_tokens` the Anthropic SDK permits on a **non-streaming**\n * request. The SDK refuses to make a non-streaming call it estimates could\n * exceed its 10-minute timeout, computed as\n * `(60min * max_tokens) / 128_000 > 10min` — i.e. it throws\n * `\"Streaming is required for operations that may take longer than 10 minutes\"`\n * once `max_tokens > 128_000 * 10 / 60 ≈ 21_333`\n * (`@anthropic-ai/sdk`'s `calculateNonstreamingTimeout`). The text adapter's\n * only non-streaming call is the forced-tool `structuredOutput()` request, so\n * its defaulted ceiling must stay at or below this; the streaming chat path\n * keeps the model's full {@link getAnthropicDefaultMaxTokens} ceiling. We sit\n * just under the boundary (`21_333` would round-trip to exactly 10min). This\n * caps only the *default* — an explicit oversized `max_tokens` from the caller\n * still surfaces the SDK's \"use streaming\" error, which is the correct signal.\n */\nexport const ANTHROPIC_MAX_NONSTREAMING_TOKENS = 21_000\n\n/**\n * Resolve the default `max_tokens` for a model: its known `max_output_tokens`\n * ceiling, or {@link ANTHROPIC_DEFAULT_MAX_OUTPUT_TOKENS} for unknown models.\n * Callers that pass an explicit `max_tokens` bypass this entirely.\n *\n * Pass `stream: false` for non-streaming requests (the `structuredOutput()`\n * path): the result is then clamped to {@link ANTHROPIC_MAX_NONSTREAMING_TOKENS}\n * so the defaulted ceiling doesn't trip the SDK's non-streaming 10-minute guard\n * (issue #849). Streaming requests (the default) are unaffected and get the\n * model's full ceiling.\n */\nexport function getAnthropicDefaultMaxTokens(\n model: string,\n { stream = true }: { stream?: boolean } = {},\n): number {\n const ceiling =\n ANTHROPIC_MODEL_MAX_OUTPUT_TOKENS[model] ??\n ANTHROPIC_DEFAULT_MAX_OUTPUT_TOKENS\n return stream ? ceiling : Math.min(ceiling, ANTHROPIC_MAX_NONSTREAMING_TOKENS)\n}\n\n/**\n * Anthropic models that support combining `tools` + JSON-Schema-constrained\n * output in a single streaming Messages request (per issue #605). GA'd\n * 2026-01-29 for Claude 4.5+ via `output_format` on the beta messages\n * endpoint. Older Claude models still need the forced-tool-use workaround\n * in `structuredOutput`.\n */\nexport const ANTHROPIC_COMBINED_TOOLS_AND_SCHEMA_MODELS = new Set<string>([\n CLAUDE_OPUS_4_5.id,\n CLAUDE_OPUS_4_6.id,\n CLAUDE_OPUS_4_7.id,\n CLAUDE_OPUS_4_8.id,\n CLAUDE_FABLE_5.id,\n CLAUDE_SONNET_5.id,\n CLAUDE_SONNET_4_5.id,\n CLAUDE_SONNET_4_6.id,\n CLAUDE_HAIKU_4_5.id,\n])\n\n// const ANTHROPIC_IMAGE_MODELS = [] as const\n// const ANTHROPIC_EMBEDDING_MODELS = [] as const\n// const ANTHROPIC_AUDIO_MODELS = [] as const\n// const ANTHROPIC_VIDEO_MODELS = [] as const\n\nexport type AnthropicChatModel = (typeof ANTHROPIC_MODELS)[number]\n// Manual type map for per-model provider options\n// Models are differentiated by which thinking shapes and sampling\n// parameters the API accepts.\nexport type AnthropicChatModelProviderOptionsByName = {\n // 4.6 generation: adaptive thinking plus the deprecated budget-based\n // shape; sampling parameters still accepted.\n [CLAUDE_OPUS_4_6.id]: AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicAdaptiveThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n [CLAUDE_SONNET_4_6.id]: AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicAdaptiveThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n\n // Pre-4.6 models: budget-based extended thinking and sampling parameters.\n [CLAUDE_OPUS_4_5.id]: AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n [CLAUDE_SONNET_4_5.id]: AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n [CLAUDE_HAIKU_4_5.id]: AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n [CLAUDE_OPUS_4_1.id]: AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n\n // Opus 4.7/4.8: adaptive thinking (or explicit disable), no\n // budget_tokens, no sampling parameters — see the constants above.\n [CLAUDE_OPUS_4_7.id]: AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicAdaptiveOrDisabledThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicMaxTokensOptions &\n AnthropicOutputConfigOptions\n [CLAUDE_OPUS_4_8.id]: AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicAdaptiveOrDisabledThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicMaxTokensOptions &\n AnthropicOutputConfigOptions\n\n // Claude Fable 5: thinking always on (adaptive-only config); sampling\n // parameters removed — see the CLAUDE_FABLE_5 constant above.\n [CLAUDE_FABLE_5.id]: AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicAdaptiveOnlyThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicMaxTokensOptions &\n AnthropicOutputConfigOptions\n // Claude Sonnet 5: adaptive thinking by default, explicit disable\n // allowed; no budget_tokens, no sampling parameters — see the\n // CLAUDE_SONNET_5 constant above.\n [CLAUDE_SONNET_5.id]: AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicAdaptiveOrDisabledThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicMaxTokensOptions &\n AnthropicOutputConfigOptions\n}\n\nexport type AnthropicChatModelToolCapabilitiesByName = {\n [CLAUDE_OPUS_4_6.id]: typeof CLAUDE_OPUS_4_6.supports.tools\n [CLAUDE_OPUS_4_5.id]: typeof CLAUDE_OPUS_4_5.supports.tools\n [CLAUDE_SONNET_4_6.id]: typeof CLAUDE_SONNET_4_6.supports.tools\n [CLAUDE_SONNET_4_5.id]: typeof CLAUDE_SONNET_4_5.supports.tools\n [CLAUDE_HAIKU_4_5.id]: typeof CLAUDE_HAIKU_4_5.supports.tools\n [CLAUDE_OPUS_4_1.id]: typeof CLAUDE_OPUS_4_1.supports.tools\n [CLAUDE_OPUS_4_7.id]: typeof CLAUDE_OPUS_4_7.supports.tools\n [CLAUDE_OPUS_4_8.id]: typeof CLAUDE_OPUS_4_8.supports.tools\n [CLAUDE_FABLE_5.id]: typeof CLAUDE_FABLE_5.supports.tools\n [CLAUDE_SONNET_5.id]: typeof CLAUDE_SONNET_5.supports.tools\n}\n\n/**\n * Type-only map from chat model name to its supported input modalities.\n * All Anthropic Claude models support text, image, and document (PDF) input.\n * Used by the core AI types to constrain ContentPart types based on the selected model.\n * Note: These must be inlined as readonly arrays (not typeof) because the model\n * constants are not exported and typeof references don't work in .d.ts files\n * when consumed by external packages.\n *\n * @see https://docs.anthropic.com/claude/docs/vision\n * @see https://docs.anthropic.com/claude/docs/pdf-support\n */\nexport type AnthropicModelInputModalitiesByName = {\n [CLAUDE_OPUS_4_6.id]: typeof CLAUDE_OPUS_4_6.supports.input\n [CLAUDE_OPUS_4_5.id]: typeof CLAUDE_OPUS_4_5.supports.input\n [CLAUDE_SONNET_4_6.id]: typeof CLAUDE_SONNET_4_6.supports.input\n [CLAUDE_SONNET_4_5.id]: typeof CLAUDE_SONNET_4_5.supports.input\n [CLAUDE_HAIKU_4_5.id]: typeof CLAUDE_HAIKU_4_5.supports.input\n [CLAUDE_OPUS_4_1.id]: typeof CLAUDE_OPUS_4_1.supports.input\n [CLAUDE_OPUS_4_7.id]: typeof CLAUDE_OPUS_4_7.supports.input\n [CLAUDE_OPUS_4_8.id]: typeof CLAUDE_OPUS_4_8.supports.input\n [CLAUDE_FABLE_5.id]: typeof CLAUDE_FABLE_5.supports.input\n [CLAUDE_SONNET_5.id]: typeof CLAUDE_SONNET_5.supports.input\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"model-meta.js","names":[],"sources":["../../src/model-meta.ts"],"sourcesContent":["import type {\n AnthropicAdaptiveOnlyThinkingOptions,\n AnthropicAdaptiveOrDisabledThinkingOptions,\n AnthropicAdaptiveThinkingOptions,\n AnthropicCacheControlOptions,\n AnthropicContainerOptions,\n AnthropicContextManagementOptions,\n AnthropicMCPOptions,\n AnthropicMaxTokensOptions,\n AnthropicOutputConfigOptions,\n AnthropicSamplingOptions,\n AnthropicServiceTierOptions,\n AnthropicStopSequencesOptions,\n AnthropicThinkingOptions,\n AnthropicToolChoiceOptions,\n} from './text/text-provider-options'\n\ninterface ModelMeta<\n TProviderOptions = unknown,\n TToolCapabilities = unknown,\n TMessageCapabilities = unknown,\n> {\n name: string\n id: string\n supports: {\n input: Array<'text' | 'image' | 'audio' | 'video' | 'document'>\n extended_thinking?: boolean\n adaptive_thinking?: boolean\n priority_tier?: boolean\n tools?: Array<\n | 'web_search'\n | 'web_fetch'\n | 'code_execution'\n | 'computer_use'\n | 'bash'\n | 'text_editor'\n | 'memory'\n >\n }\n context_window?: number\n max_output_tokens?: number\n knowledge_cutoff?: string\n pricing: {\n input: {\n normal: number\n cached?: number\n }\n output: {\n normal: number\n }\n }\n /**\n * Type-level description of which provider options this model supports.\n */\n providerOptions?: TProviderOptions\n /**\n * Type-level description of which tool capabilities this model supports.\n */\n toolCapabilities?: TToolCapabilities\n /**\n * Type-level description of which message/input capabilities this model supports.\n */\n messageCapabilities?: TMessageCapabilities\n}\n\n// Claude Opus 4.6 accepts adaptive thinking alongside the deprecated\n// budget-based extended thinking, and still accepts sampling parameters.\nconst CLAUDE_OPUS_4_6 = {\n name: 'claude-opus-4-6',\n id: 'claude-opus-4-6',\n context_window: 200_000,\n max_output_tokens: 128_000,\n knowledge_cutoff: '2025-05-01',\n pricing: {\n input: {\n normal: 5,\n },\n output: {\n normal: 25,\n },\n },\n supports: {\n input: ['text', 'image', 'document'],\n extended_thinking: true,\n adaptive_thinking: true,\n priority_tier: true,\n tools: [\n 'web_search',\n 'web_fetch',\n 'code_execution',\n 'computer_use',\n 'bash',\n 'text_editor',\n 'memory',\n ],\n },\n} as const satisfies ModelMeta<\n AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicAdaptiveThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n>\n\nconst CLAUDE_OPUS_4_5 = {\n name: 'claude-opus-4-5',\n id: 'claude-opus-4-5',\n context_window: 200_000,\n max_output_tokens: 32_000,\n knowledge_cutoff: '2025-11-01',\n pricing: {\n input: {\n normal: 15,\n },\n output: {\n normal: 75,\n },\n },\n supports: {\n input: ['text', 'image', 'document'],\n extended_thinking: true,\n priority_tier: true,\n tools: [\n 'web_search',\n 'web_fetch',\n 'code_execution',\n 'computer_use',\n 'bash',\n 'text_editor',\n 'memory',\n ],\n },\n} as const satisfies ModelMeta<\n AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n>\n\n// Claude Sonnet 4.6 accepts adaptive thinking alongside the deprecated\n// budget-based extended thinking, and still accepts sampling parameters.\nconst CLAUDE_SONNET_4_6 = {\n name: 'claude-sonnet-4-6',\n id: 'claude-sonnet-4-6',\n context_window: 1_000_000,\n max_output_tokens: 64_000,\n knowledge_cutoff: '2025-08-01',\n pricing: {\n input: {\n normal: 3,\n },\n output: {\n normal: 15,\n },\n },\n supports: {\n input: ['text', 'image', 'document'],\n extended_thinking: true,\n adaptive_thinking: true,\n priority_tier: true,\n tools: [\n 'web_search',\n 'web_fetch',\n 'code_execution',\n 'computer_use',\n 'bash',\n 'text_editor',\n 'memory',\n ],\n },\n} as const satisfies ModelMeta<\n AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicAdaptiveThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n>\n\nconst CLAUDE_SONNET_4_5 = {\n name: 'claude-sonnet-4-5',\n id: 'claude-sonnet-4-5',\n context_window: 200_000,\n max_output_tokens: 64_000,\n knowledge_cutoff: '2025-09-29',\n pricing: {\n input: {\n normal: 3,\n },\n output: {\n normal: 15,\n },\n },\n supports: {\n input: ['text', 'image', 'document'],\n extended_thinking: true,\n priority_tier: true,\n tools: [\n 'web_search',\n 'web_fetch',\n 'code_execution',\n 'computer_use',\n 'bash',\n 'text_editor',\n 'memory',\n ],\n },\n} as const satisfies ModelMeta<\n AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n>\n\nconst CLAUDE_HAIKU_4_5 = {\n name: 'claude-haiku-4-5',\n id: 'claude-haiku-4-5',\n context_window: 200_000,\n max_output_tokens: 64_000,\n knowledge_cutoff: '2025-10-01',\n pricing: {\n input: {\n normal: 1,\n },\n output: {\n normal: 5,\n },\n },\n supports: {\n input: ['text', 'image', 'document'],\n extended_thinking: true,\n priority_tier: true,\n tools: [\n 'web_search',\n 'web_fetch',\n 'code_execution',\n 'computer_use',\n 'bash',\n 'text_editor',\n 'memory',\n ],\n },\n} as const satisfies ModelMeta<\n AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n>\n\nconst CLAUDE_OPUS_4_1 = {\n name: 'claude-opus-4-1',\n id: 'claude-opus-4-1',\n context_window: 200_000,\n max_output_tokens: 64_000,\n knowledge_cutoff: '2025-08-05',\n pricing: {\n input: {\n normal: 15,\n },\n output: {\n normal: 75,\n },\n },\n supports: {\n input: ['text', 'image', 'document'],\n extended_thinking: true,\n priority_tier: true,\n tools: [\n 'web_search',\n 'web_fetch',\n 'code_execution',\n 'computer_use',\n 'bash',\n 'text_editor',\n 'memory',\n ],\n },\n} as const satisfies ModelMeta<\n AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n>\n\n// Claude Opus 4.7 removed budget-based extended thinking and the sampling\n// parameters (`temperature`, `top_p`, `top_k`) — sending either returns a\n// 400. Use adaptive thinking with `output_config.effort` instead.\nconst CLAUDE_OPUS_4_7 = {\n name: 'claude-opus-4-7',\n id: 'claude-opus-4-7',\n context_window: 1_000_000,\n max_output_tokens: 128_000,\n supports: {\n input: ['text', 'image', 'document'],\n extended_thinking: false,\n adaptive_thinking: true,\n priority_tier: true,\n tools: [\n 'web_search',\n 'web_fetch',\n 'code_execution',\n 'computer_use',\n 'bash',\n 'text_editor',\n 'memory',\n ],\n },\n pricing: {\n input: {\n normal: 5,\n cached: 0.5,\n },\n output: {\n normal: 25,\n },\n },\n} as const satisfies ModelMeta<\n AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicAdaptiveOrDisabledThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicMaxTokensOptions &\n AnthropicOutputConfigOptions\n>\n\n// Claude Opus 4.8 keeps the same request surface as Opus 4.7: adaptive\n// thinking only (budget_tokens 400s), no sampling parameters.\nconst CLAUDE_OPUS_4_8 = {\n name: 'claude-opus-4-8',\n id: 'claude-opus-4-8',\n context_window: 1_000_000,\n max_output_tokens: 128_000,\n supports: {\n input: ['text', 'image', 'document'],\n extended_thinking: false,\n adaptive_thinking: true,\n priority_tier: true,\n tools: [\n 'web_search',\n 'web_fetch',\n 'code_execution',\n 'computer_use',\n 'bash',\n 'text_editor',\n 'memory',\n ],\n },\n pricing: {\n input: {\n normal: 5,\n cached: 0.5,\n },\n output: {\n normal: 25,\n },\n },\n} as const satisfies ModelMeta<\n AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicAdaptiveOrDisabledThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicMaxTokensOptions &\n AnthropicOutputConfigOptions\n>\n\n// Claude Fable 5: thinking is always on — the only accepted explicit\n// `thinking` config is `{type: 'adaptive'}` (disabled/budget_tokens 400),\n// and the sampling parameters (`temperature`, `top_p`, `top_k`) are\n// rejected. Its provider options therefore use the adaptive-only thinking\n// shape and `max_tokens` without the sampling knobs.\nconst CLAUDE_FABLE_5 = {\n name: 'claude-fable-5',\n id: 'claude-fable-5',\n context_window: 1_000_000,\n max_output_tokens: 128_000,\n supports: {\n input: ['text', 'image', 'document'],\n extended_thinking: false,\n adaptive_thinking: true,\n priority_tier: true,\n tools: [\n 'web_search',\n 'web_fetch',\n 'code_execution',\n 'computer_use',\n 'bash',\n 'text_editor',\n 'memory',\n ],\n },\n pricing: {\n input: {\n normal: 10,\n cached: 1,\n },\n output: {\n normal: 50,\n },\n },\n} as const satisfies ModelMeta<\n AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicAdaptiveOnlyThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicMaxTokensOptions &\n AnthropicOutputConfigOptions\n>\n\n// Claude Sonnet 5: adaptive thinking is the default (omitting `thinking`\n// runs adaptive); `{type: 'disabled'}` opts out, but the manual\n// `{type: 'enabled', budget_tokens}` shape and non-default sampling\n// parameters (`temperature`, `top_p`, `top_k`) are rejected with a 400.\n// Pricing below is the sticker $3/$15 per MTok (an introductory $2/$10\n// applies through 2026-08-31).\nconst CLAUDE_SONNET_5 = {\n name: 'claude-sonnet-5',\n id: 'claude-sonnet-5',\n context_window: 1_000_000,\n max_output_tokens: 128_000,\n supports: {\n input: ['text', 'image', 'document'],\n extended_thinking: false,\n adaptive_thinking: true,\n priority_tier: true,\n tools: [\n 'web_search',\n 'web_fetch',\n 'code_execution',\n 'computer_use',\n 'bash',\n 'text_editor',\n 'memory',\n ],\n },\n pricing: {\n input: {\n normal: 3,\n cached: 0.3,\n },\n output: {\n normal: 15,\n },\n },\n} as const satisfies ModelMeta<\n AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicAdaptiveOrDisabledThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicMaxTokensOptions &\n AnthropicOutputConfigOptions\n>\n\n/**\n * Model ids accepted by the Anthropic text adapter.\n *\n * Every id here resolves against the first-party Anthropic API\n * (`GET /v1/models/{id}`). Retired models (Claude 3.x, Sonnet 3.7,\n * Opus 4 / Sonnet 4) and the `-fast` variant ids (fast mode is requested\n * via the `speed` parameter, not a model id) were removed after Anthropic\n * turned them off.\n */\nconst CLAUDE_OPUS_5 = {\n name: 'claude-opus-5',\n id: 'claude-opus-5',\n context_window: 1_000_000,\n max_output_tokens: 128_000,\n supports: {\n input: ['text', 'image', 'document'],\n tools: [],\n },\n pricing: {\n input: {\n normal: 5,\n cached: 0.5,\n },\n output: {\n normal: 25,\n },\n },\n} as const satisfies ModelMeta<\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n>\n\nconst CLAUDE_OPUS_5_FAST = {\n name: 'claude-opus-5-fast',\n id: 'claude-opus-5-fast',\n context_window: 1_000_000,\n max_output_tokens: 128_000,\n supports: {\n input: ['text', 'image', 'document'],\n tools: [],\n },\n pricing: {\n input: {\n normal: 10,\n cached: 1,\n },\n output: {\n normal: 50,\n },\n },\n} as const satisfies ModelMeta<\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n>\n\nexport const ANTHROPIC_MODELS = [\n CLAUDE_OPUS_5.id,\n CLAUDE_OPUS_5_FAST.id,\n CLAUDE_OPUS_4_6.id,\n CLAUDE_OPUS_4_5.id,\n CLAUDE_SONNET_4_6.id,\n CLAUDE_SONNET_4_5.id,\n CLAUDE_HAIKU_4_5.id,\n CLAUDE_OPUS_4_1.id,\n\n CLAUDE_OPUS_4_7.id,\n CLAUDE_OPUS_4_8.id,\n\n CLAUDE_FABLE_5.id,\n CLAUDE_SONNET_5.id,\n] as const\n\n/**\n * Fallback `max_tokens` ceiling for a model whose metadata carries no\n * `max_output_tokens` (e.g. an unrecognized model id). Anthropic's Messages\n * API *requires* `max_tokens`, so the adapter must always send a value. 64K is\n * the output ceiling of the current mainstream Claude tier (Sonnet/Haiku 4.5),\n * so it's a sane default for an unknown — almost certainly modern — model and\n * avoids silently truncating long generations (issue #849). Recognized models\n * use their exact `max_output_tokens` from {@link ANTHROPIC_MODEL_MAX_OUTPUT_TOKENS}\n * (e.g. 128K for Opus), so this fallback only ever applies to ids not in the\n * map.\n */\nexport const ANTHROPIC_DEFAULT_MAX_OUTPUT_TOKENS = 64_000\n\n/**\n * Runtime lookup of each model's maximum output-token ceiling, keyed by model\n * id. Lets the text adapter default the required `max_tokens` request field to\n * the model's real ceiling when the caller doesn't specify one, rather than a\n * low constant that truncates responses mid-stream (issue #849).\n *\n * Kept in sync with {@link ANTHROPIC_MODELS} by `scripts/sync-provider-models.ts`\n * — when that script adds a model it also inserts the model's `max_output_tokens`\n * here, so a freshly-synced model resolves to its real ceiling rather than the\n * fallback above.\n */\nconst ANTHROPIC_MODEL_MAX_OUTPUT_TOKENS: Record<string, number> = {\n [CLAUDE_OPUS_4_6.id]: CLAUDE_OPUS_4_6.max_output_tokens,\n [CLAUDE_OPUS_4_5.id]: CLAUDE_OPUS_4_5.max_output_tokens,\n [CLAUDE_SONNET_4_6.id]: CLAUDE_SONNET_4_6.max_output_tokens,\n [CLAUDE_SONNET_4_5.id]: CLAUDE_SONNET_4_5.max_output_tokens,\n [CLAUDE_HAIKU_4_5.id]: CLAUDE_HAIKU_4_5.max_output_tokens,\n [CLAUDE_OPUS_4_1.id]: CLAUDE_OPUS_4_1.max_output_tokens,\n [CLAUDE_OPUS_4_7.id]: CLAUDE_OPUS_4_7.max_output_tokens,\n [CLAUDE_OPUS_4_8.id]: CLAUDE_OPUS_4_8.max_output_tokens,\n [CLAUDE_FABLE_5.id]: CLAUDE_FABLE_5.max_output_tokens,\n [CLAUDE_SONNET_5.id]: CLAUDE_SONNET_5.max_output_tokens,\n [CLAUDE_OPUS_5.id]: CLAUDE_OPUS_5.max_output_tokens,\n [CLAUDE_OPUS_5_FAST.id]: CLAUDE_OPUS_5_FAST.max_output_tokens,\n}\n\n/**\n * Largest `max_tokens` the Anthropic SDK permits on a **non-streaming**\n * request. The SDK refuses to make a non-streaming call it estimates could\n * exceed its 10-minute timeout, computed as\n * `(60min * max_tokens) / 128_000 > 10min` — i.e. it throws\n * `\"Streaming is required for operations that may take longer than 10 minutes\"`\n * once `max_tokens > 128_000 * 10 / 60 ≈ 21_333`\n * (`@anthropic-ai/sdk`'s `calculateNonstreamingTimeout`). The text adapter's\n * only non-streaming call is the forced-tool `structuredOutput()` request, so\n * its defaulted ceiling must stay at or below this; the streaming chat path\n * keeps the model's full {@link getAnthropicDefaultMaxTokens} ceiling. We sit\n * just under the boundary (`21_333` would round-trip to exactly 10min). This\n * caps only the *default* — an explicit oversized `max_tokens` from the caller\n * still surfaces the SDK's \"use streaming\" error, which is the correct signal.\n */\nexport const ANTHROPIC_MAX_NONSTREAMING_TOKENS = 21_000\n\n/**\n * Resolve the default `max_tokens` for a model: its known `max_output_tokens`\n * ceiling, or {@link ANTHROPIC_DEFAULT_MAX_OUTPUT_TOKENS} for unknown models.\n * Callers that pass an explicit `max_tokens` bypass this entirely.\n *\n * Pass `stream: false` for non-streaming requests (the `structuredOutput()`\n * path): the result is then clamped to {@link ANTHROPIC_MAX_NONSTREAMING_TOKENS}\n * so the defaulted ceiling doesn't trip the SDK's non-streaming 10-minute guard\n * (issue #849). Streaming requests (the default) are unaffected and get the\n * model's full ceiling.\n */\nexport function getAnthropicDefaultMaxTokens(\n model: string,\n { stream = true }: { stream?: boolean } = {},\n): number {\n const ceiling =\n ANTHROPIC_MODEL_MAX_OUTPUT_TOKENS[model] ??\n ANTHROPIC_DEFAULT_MAX_OUTPUT_TOKENS\n return stream ? ceiling : Math.min(ceiling, ANTHROPIC_MAX_NONSTREAMING_TOKENS)\n}\n\n/**\n * Anthropic models that support combining `tools` + JSON-Schema-constrained\n * output in a single streaming Messages request (per issue #605). GA'd\n * 2026-01-29 for Claude 4.5+ via `output_format` on the beta messages\n * endpoint. Older Claude models still need the forced-tool-use workaround\n * in `structuredOutput`.\n */\nexport const ANTHROPIC_COMBINED_TOOLS_AND_SCHEMA_MODELS = new Set<string>([\n CLAUDE_OPUS_4_5.id,\n CLAUDE_OPUS_4_6.id,\n CLAUDE_OPUS_4_7.id,\n CLAUDE_OPUS_4_8.id,\n CLAUDE_FABLE_5.id,\n CLAUDE_SONNET_5.id,\n CLAUDE_SONNET_4_5.id,\n CLAUDE_SONNET_4_6.id,\n CLAUDE_HAIKU_4_5.id,\n])\n\n// const ANTHROPIC_IMAGE_MODELS = [] as const\n// const ANTHROPIC_EMBEDDING_MODELS = [] as const\n// const ANTHROPIC_AUDIO_MODELS = [] as const\n// const ANTHROPIC_VIDEO_MODELS = [] as const\n\nexport type AnthropicChatModel = (typeof ANTHROPIC_MODELS)[number]\n// Manual type map for per-model provider options\n// Models are differentiated by which thinking shapes and sampling\n// parameters the API accepts.\nexport type AnthropicChatModelProviderOptionsByName = {\n // 4.6 generation: adaptive thinking plus the deprecated budget-based\n // shape; sampling parameters still accepted.\n [CLAUDE_OPUS_4_6.id]: AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicAdaptiveThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n [CLAUDE_SONNET_4_6.id]: AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicAdaptiveThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n\n // Pre-4.6 models: budget-based extended thinking and sampling parameters.\n [CLAUDE_OPUS_4_5.id]: AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n [CLAUDE_SONNET_4_5.id]: AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n [CLAUDE_HAIKU_4_5.id]: AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n [CLAUDE_OPUS_4_1.id]: AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n\n // Opus 4.7/4.8: adaptive thinking (or explicit disable), no\n // budget_tokens, no sampling parameters — see the constants above.\n [CLAUDE_OPUS_4_7.id]: AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicAdaptiveOrDisabledThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicMaxTokensOptions &\n AnthropicOutputConfigOptions\n [CLAUDE_OPUS_4_8.id]: AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicAdaptiveOrDisabledThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicMaxTokensOptions &\n AnthropicOutputConfigOptions\n\n // Claude Fable 5: thinking always on (adaptive-only config); sampling\n // parameters removed — see the CLAUDE_FABLE_5 constant above.\n [CLAUDE_FABLE_5.id]: AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicAdaptiveOnlyThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicMaxTokensOptions &\n AnthropicOutputConfigOptions\n // Claude Sonnet 5: adaptive thinking by default, explicit disable\n // allowed; no budget_tokens, no sampling parameters — see the\n // CLAUDE_SONNET_5 constant above.\n [CLAUDE_SONNET_5.id]: AnthropicCacheControlOptions &\n AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicAdaptiveOrDisabledThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicMaxTokensOptions &\n AnthropicOutputConfigOptions\n [CLAUDE_OPUS_5.id]: AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n [CLAUDE_OPUS_5_FAST.id]: AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions\n}\n\nexport type AnthropicChatModelToolCapabilitiesByName = {\n [CLAUDE_OPUS_4_6.id]: typeof CLAUDE_OPUS_4_6.supports.tools\n [CLAUDE_OPUS_4_5.id]: typeof CLAUDE_OPUS_4_5.supports.tools\n [CLAUDE_SONNET_4_6.id]: typeof CLAUDE_SONNET_4_6.supports.tools\n [CLAUDE_SONNET_4_5.id]: typeof CLAUDE_SONNET_4_5.supports.tools\n [CLAUDE_HAIKU_4_5.id]: typeof CLAUDE_HAIKU_4_5.supports.tools\n [CLAUDE_OPUS_4_1.id]: typeof CLAUDE_OPUS_4_1.supports.tools\n [CLAUDE_OPUS_4_7.id]: typeof CLAUDE_OPUS_4_7.supports.tools\n [CLAUDE_OPUS_4_8.id]: typeof CLAUDE_OPUS_4_8.supports.tools\n [CLAUDE_FABLE_5.id]: typeof CLAUDE_FABLE_5.supports.tools\n [CLAUDE_SONNET_5.id]: typeof CLAUDE_SONNET_5.supports.tools\n [CLAUDE_OPUS_5.id]: typeof CLAUDE_OPUS_5.supports.tools\n [CLAUDE_OPUS_5_FAST.id]: typeof CLAUDE_OPUS_5_FAST.supports.tools\n}\n\n/**\n * Type-only map from chat model name to its supported input modalities.\n * All Anthropic Claude models support text, image, and document (PDF) input.\n * Used by the core AI types to constrain ContentPart types based on the selected model.\n * Note: These must be inlined as readonly arrays (not typeof) because the model\n * constants are not exported and typeof references don't work in .d.ts files\n * when consumed by external packages.\n *\n * @see https://docs.anthropic.com/claude/docs/vision\n * @see https://docs.anthropic.com/claude/docs/pdf-support\n */\nexport type AnthropicModelInputModalitiesByName = {\n [CLAUDE_OPUS_4_6.id]: typeof CLAUDE_OPUS_4_6.supports.input\n [CLAUDE_OPUS_4_5.id]: typeof CLAUDE_OPUS_4_5.supports.input\n [CLAUDE_SONNET_4_6.id]: typeof CLAUDE_SONNET_4_6.supports.input\n [CLAUDE_SONNET_4_5.id]: typeof CLAUDE_SONNET_4_5.supports.input\n [CLAUDE_HAIKU_4_5.id]: typeof CLAUDE_HAIKU_4_5.supports.input\n [CLAUDE_OPUS_4_1.id]: typeof CLAUDE_OPUS_4_1.supports.input\n [CLAUDE_OPUS_4_7.id]: typeof CLAUDE_OPUS_4_7.supports.input\n [CLAUDE_OPUS_4_8.id]: typeof CLAUDE_OPUS_4_8.supports.input\n [CLAUDE_FABLE_5.id]: typeof CLAUDE_FABLE_5.supports.input\n [CLAUDE_SONNET_5.id]: typeof CLAUDE_SONNET_5.supports.input\n [CLAUDE_OPUS_5.id]: typeof CLAUDE_OPUS_5.supports.input\n [CLAUDE_OPUS_5_FAST.id]: typeof CLAUDE_OPUS_5_FAST.supports.input\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ProviderTool, Tool } from '@tanstack/ai';
|
|
2
|
+
declare const ANTHROPIC_PROVIDER_TOOL_KINDS: {
|
|
3
|
+
readonly bash: "anthropic.bash";
|
|
4
|
+
readonly code_execution: "anthropic.code_execution";
|
|
5
|
+
readonly computer_use: "anthropic.computer_use";
|
|
6
|
+
readonly memory: "anthropic.memory";
|
|
7
|
+
readonly text_editor: "anthropic.text_editor";
|
|
8
|
+
readonly web_fetch: "anthropic.web_fetch";
|
|
9
|
+
readonly web_search: "anthropic.web_search";
|
|
10
|
+
};
|
|
11
|
+
type AnthropicProviderToolKind = keyof typeof ANTHROPIC_PROVIDER_TOOL_KINDS;
|
|
12
|
+
/**
|
|
13
|
+
* Adds a stable runtime discriminator to an Anthropic-native tool.
|
|
14
|
+
*
|
|
15
|
+
* The core ProviderTool brand is intentionally type-only. Anthropic also needs
|
|
16
|
+
* a runtime discriminator because custom functions may use the same public
|
|
17
|
+
* names as native tools. Adapter metadata is the repository-wide extension
|
|
18
|
+
* point for this plain-data marker; converters remove it from the wire shape.
|
|
19
|
+
*/
|
|
20
|
+
export declare function brandAnthropicProviderTool<T extends ProviderTool<'anthropic', AnthropicProviderToolKind>>(tool: Omit<T, '~provider' | '~toolKind'>, toolKind: T['~toolKind']): T;
|
|
21
|
+
export declare function getAnthropicProviderToolKind(tool: Tool): AnthropicProviderToolKind | undefined;
|
|
22
|
+
/** Returns adapter metadata without the internal runtime discriminator. */
|
|
23
|
+
export declare function getAnthropicProviderToolMetadata(tool: Tool): Tool['metadata'];
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { brandProviderTool } from "@tanstack/ai";
|
|
2
|
+
//#region src/tools/anthropic-provider-tool.ts
|
|
3
|
+
var ANTHROPIC_PROVIDER_TOOL_KINDS = {
|
|
4
|
+
bash: "anthropic.bash",
|
|
5
|
+
code_execution: "anthropic.code_execution",
|
|
6
|
+
computer_use: "anthropic.computer_use",
|
|
7
|
+
memory: "anthropic.memory",
|
|
8
|
+
text_editor: "anthropic.text_editor",
|
|
9
|
+
web_fetch: "anthropic.web_fetch",
|
|
10
|
+
web_search: "anthropic.web_search"
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Adds a stable runtime discriminator to an Anthropic-native tool.
|
|
14
|
+
*
|
|
15
|
+
* The core ProviderTool brand is intentionally type-only. Anthropic also needs
|
|
16
|
+
* a runtime discriminator because custom functions may use the same public
|
|
17
|
+
* names as native tools. Adapter metadata is the repository-wide extension
|
|
18
|
+
* point for this plain-data marker; converters remove it from the wire shape.
|
|
19
|
+
*/
|
|
20
|
+
function brandAnthropicProviderTool(tool, toolKind) {
|
|
21
|
+
return brandProviderTool({
|
|
22
|
+
...tool,
|
|
23
|
+
metadata: {
|
|
24
|
+
...tool.metadata,
|
|
25
|
+
__kind: ANTHROPIC_PROVIDER_TOOL_KINDS[toolKind]
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function getAnthropicProviderToolKind(tool) {
|
|
30
|
+
switch (tool.metadata?.["__kind"]) {
|
|
31
|
+
case "anthropic.bash": return "bash";
|
|
32
|
+
case "anthropic.code_execution": return "code_execution";
|
|
33
|
+
case "anthropic.computer_use": return "computer_use";
|
|
34
|
+
case "anthropic.memory": return "memory";
|
|
35
|
+
case "anthropic.text_editor": return "text_editor";
|
|
36
|
+
case "anthropic.web_fetch": return "web_fetch";
|
|
37
|
+
case "anthropic.web_search": return "web_search";
|
|
38
|
+
default: return;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/** Returns adapter metadata without the internal runtime discriminator. */
|
|
42
|
+
function getAnthropicProviderToolMetadata(tool) {
|
|
43
|
+
if (!tool.metadata) return;
|
|
44
|
+
const { __kind: _kind, ...metadata } = tool.metadata;
|
|
45
|
+
return metadata;
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
export { brandAnthropicProviderTool, getAnthropicProviderToolKind, getAnthropicProviderToolMetadata };
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=anthropic-provider-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"anthropic-provider-tool.js","names":[],"sources":["../../../src/tools/anthropic-provider-tool.ts"],"sourcesContent":["import { brandProviderTool } from '@tanstack/ai'\nimport type { ProviderTool, Tool } from '@tanstack/ai'\n\nconst ANTHROPIC_PROVIDER_TOOL_KINDS = {\n bash: 'anthropic.bash',\n code_execution: 'anthropic.code_execution',\n computer_use: 'anthropic.computer_use',\n memory: 'anthropic.memory',\n text_editor: 'anthropic.text_editor',\n web_fetch: 'anthropic.web_fetch',\n web_search: 'anthropic.web_search',\n} as const\n\ntype AnthropicProviderToolKind = keyof typeof ANTHROPIC_PROVIDER_TOOL_KINDS\n\n/**\n * Adds a stable runtime discriminator to an Anthropic-native tool.\n *\n * The core ProviderTool brand is intentionally type-only. Anthropic also needs\n * a runtime discriminator because custom functions may use the same public\n * names as native tools. Adapter metadata is the repository-wide extension\n * point for this plain-data marker; converters remove it from the wire shape.\n */\nexport function brandAnthropicProviderTool<\n T extends ProviderTool<'anthropic', AnthropicProviderToolKind>,\n>(tool: Omit<T, '~provider' | '~toolKind'>, toolKind: T['~toolKind']): T {\n return brandProviderTool<T>({\n ...tool,\n metadata: {\n ...tool.metadata,\n __kind: ANTHROPIC_PROVIDER_TOOL_KINDS[toolKind],\n },\n })\n}\n\nexport function getAnthropicProviderToolKind(\n tool: Tool,\n): AnthropicProviderToolKind | undefined {\n const toolKind = tool.metadata?.['__kind']\n switch (toolKind) {\n case 'anthropic.bash':\n return 'bash'\n case 'anthropic.code_execution':\n return 'code_execution'\n case 'anthropic.computer_use':\n return 'computer_use'\n case 'anthropic.memory':\n return 'memory'\n case 'anthropic.text_editor':\n return 'text_editor'\n case 'anthropic.web_fetch':\n return 'web_fetch'\n case 'anthropic.web_search':\n return 'web_search'\n default:\n return undefined\n }\n}\n\n/** Returns adapter metadata without the internal runtime discriminator. */\nexport function getAnthropicProviderToolMetadata(tool: Tool): Tool['metadata'] {\n if (!tool.metadata) {\n return undefined\n }\n const { __kind: _kind, ...metadata } = tool.metadata\n void _kind\n return metadata\n}\n"],"mappings":";;AAGA,IAAM,gCAAgC;CACpC,MAAM;CACN,gBAAgB;CAChB,cAAc;CACd,QAAQ;CACR,aAAa;CACb,WAAW;CACX,YAAY;AACd;;;;;;;;;AAYA,SAAgB,2BAEd,MAA0C,UAA6B;CACvE,OAAO,kBAAqB;EAC1B,GAAG;EACH,UAAU;GACR,GAAG,KAAK;GACR,QAAQ,8BAA8B;EACxC;CACF,CAAC;AACH;AAEA,SAAgB,6BACd,MACuC;CAEvC,QADiB,KAAK,WAAW,WACjC;EACE,KAAK,kBACH,OAAO;EACT,KAAK,4BACH,OAAO;EACT,KAAK,0BACH,OAAO;EACT,KAAK,oBACH,OAAO;EACT,KAAK,yBACH,OAAO;EACT,KAAK,uBACH,OAAO;EACT,KAAK,wBACH,OAAO;EACT,SACE;CACJ;AACF;;AAGA,SAAgB,iCAAiC,MAA8B;CAC7E,IAAI,CAAC,KAAK,UACR;CAEF,MAAM,EAAE,QAAQ,OAAO,GAAG,aAAa,KAAK;CAE5C,OAAO;AACT"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { brandAnthropicProviderTool, getAnthropicProviderToolMetadata } from "./anthropic-provider-tool.js";
|
|
2
2
|
//#region src/tools/bash-tool.ts
|
|
3
3
|
function convertBashToolToAdapterFormat(tool) {
|
|
4
|
-
return tool
|
|
4
|
+
return getAnthropicProviderToolMetadata(tool);
|
|
5
5
|
}
|
|
6
6
|
function bashTool(config) {
|
|
7
|
-
return
|
|
7
|
+
return brandAnthropicProviderTool({
|
|
8
8
|
name: "bash",
|
|
9
9
|
description: "",
|
|
10
10
|
metadata: config
|
|
11
|
-
});
|
|
11
|
+
}, "bash");
|
|
12
12
|
}
|
|
13
13
|
//#endregion
|
|
14
14
|
export { bashTool, convertBashToolToAdapterFormat };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bash-tool.js","names":[],"sources":["../../../src/tools/bash-tool.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"bash-tool.js","names":[],"sources":["../../../src/tools/bash-tool.ts"],"sourcesContent":["import {\n brandAnthropicProviderTool,\n getAnthropicProviderToolMetadata,\n} from './anthropic-provider-tool'\nimport type {\n BetaToolBash20241022,\n BetaToolBash20250124,\n} from '@anthropic-ai/sdk/resources/beta'\nimport type { ProviderTool, Tool } from '@tanstack/ai'\n\nexport type BashToolConfig = BetaToolBash20241022 | BetaToolBash20250124\n\n/** @deprecated Renamed to `BashToolConfig`. Will be removed in a future release. */\nexport type BashTool = BashToolConfig\n\nexport type AnthropicBashTool = ProviderTool<'anthropic', 'bash'>\n\nexport function convertBashToolToAdapterFormat(tool: Tool): BashToolConfig {\n const metadata = getAnthropicProviderToolMetadata(tool) as BashToolConfig\n return metadata\n}\n\nexport function bashTool(config: BashToolConfig): AnthropicBashTool {\n return brandAnthropicProviderTool<AnthropicBashTool>(\n {\n name: 'bash',\n description: '',\n metadata: config,\n },\n 'bash',\n )\n}\n"],"mappings":";;AAiBA,SAAgB,+BAA+B,MAA4B;CAEzE,OADiB,iCAAiC,IAC3C;AACT;AAEA,SAAgB,SAAS,QAA2C;CAClE,OAAO,2BACL;EACE,MAAM;EACN,aAAa;EACb,UAAU;CACZ,GACA,MACF;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { brandAnthropicProviderTool, getAnthropicProviderToolMetadata } from "./anthropic-provider-tool.js";
|
|
2
2
|
//#region src/tools/code-execution-tool.ts
|
|
3
3
|
function convertCodeExecutionToolToAdapterFormat(tool) {
|
|
4
4
|
return readCodeExecutionConfig(tool);
|
|
@@ -8,14 +8,14 @@ function convertCodeExecutionToolToAdapterFormat(tool) {
|
|
|
8
8
|
* Used by the text adapter to select the version-aware code-execution beta.
|
|
9
9
|
*/
|
|
10
10
|
function readCodeExecutionConfig(tool) {
|
|
11
|
-
return tool
|
|
11
|
+
return getAnthropicProviderToolMetadata(tool)?.config;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* Reads the hosted skills attached to a `code_execution` tool, if any.
|
|
15
15
|
* Used by the text adapter to build the top-level `container.skills` param.
|
|
16
16
|
*/
|
|
17
17
|
function readCodeExecutionSkills(tool) {
|
|
18
|
-
return tool
|
|
18
|
+
return getAnthropicProviderToolMetadata(tool)?.skills;
|
|
19
19
|
}
|
|
20
20
|
function codeExecutionTool(config, options = {}) {
|
|
21
21
|
const { skills } = options;
|
|
@@ -23,14 +23,15 @@ function codeExecutionTool(config, options = {}) {
|
|
|
23
23
|
if (skills.length > 8) throw new Error("code_execution supports at most 8 skills per request.");
|
|
24
24
|
for (const skill of skills) if (skill.skill_id.length < 1 || skill.skill_id.length > 64) throw new Error("skill_id must be between 1 and 64 characters.");
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
const metadata = {
|
|
27
|
+
config,
|
|
28
|
+
...skills && { skills }
|
|
29
|
+
};
|
|
30
|
+
return brandAnthropicProviderTool({
|
|
27
31
|
name: "code_execution",
|
|
28
32
|
description: "",
|
|
29
|
-
metadata
|
|
30
|
-
|
|
31
|
-
...skills && { skills }
|
|
32
|
-
}
|
|
33
|
-
});
|
|
33
|
+
metadata
|
|
34
|
+
}, "code_execution");
|
|
34
35
|
}
|
|
35
36
|
//#endregion
|
|
36
37
|
export { codeExecutionTool, convertCodeExecutionToolToAdapterFormat, readCodeExecutionConfig, readCodeExecutionSkills };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-execution-tool.js","names":[],"sources":["../../../src/tools/code-execution-tool.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"code-execution-tool.js","names":[],"sources":["../../../src/tools/code-execution-tool.ts"],"sourcesContent":["import {\n brandAnthropicProviderTool,\n getAnthropicProviderToolMetadata,\n} from './anthropic-provider-tool'\nimport type {\n BetaCodeExecutionTool20250522,\n BetaCodeExecutionTool20250825,\n} from '@anthropic-ai/sdk/resources/beta'\nimport type { ProviderTool, Tool } from '@tanstack/ai'\n\nexport type CodeExecutionToolConfig =\n | BetaCodeExecutionTool20250522\n | BetaCodeExecutionTool20250825\n\n/** @deprecated Renamed to `CodeExecutionToolConfig`. Will be removed in a future release. */\nexport type CodeExecutionTool = CodeExecutionToolConfig\n\n/**\n * A hosted/managed Anthropic Skill reference. Lifted by the text adapter into\n * the top-level `container.skills` request param (NOT serialized into the\n * `tools[]` entry). Requires the `code_execution` tool to be enabled.\n */\nexport interface AnthropicContainerSkill {\n /** 1–64 characters. */\n skill_id: string\n type: 'anthropic' | 'custom'\n /** Skill version, or `'latest'` (default) when omitted. */\n version?: string\n}\n\nexport interface CodeExecutionToolOptions {\n /** Hosted skills to load into the code-execution container (max 8). */\n skills?: Array<AnthropicContainerSkill>\n}\n\ninterface CodeExecutionToolMetadata {\n config: CodeExecutionToolConfig\n skills?: Array<AnthropicContainerSkill>\n}\n\nexport type AnthropicCodeExecutionTool = ProviderTool<\n 'anthropic',\n 'code_execution'\n>\n\nexport function convertCodeExecutionToolToAdapterFormat(\n tool: Tool,\n): CodeExecutionToolConfig {\n // The converter is only called for real `code_execution` tools, so a\n // non-undefined config is expected — but read via optional chaining so an\n // absent metadata object doesn't throw.\n return readCodeExecutionConfig(tool) as CodeExecutionToolConfig\n}\n\n/**\n * Reads the SDK tool config attached to a `code_execution` tool, if any.\n * Used by the text adapter to select the version-aware code-execution beta.\n */\nexport function readCodeExecutionConfig(\n tool: Tool,\n): CodeExecutionToolConfig | undefined {\n return (\n getAnthropicProviderToolMetadata(tool) as\n | CodeExecutionToolMetadata\n | undefined\n )?.config\n}\n\n/**\n * Reads the hosted skills attached to a `code_execution` tool, if any.\n * Used by the text adapter to build the top-level `container.skills` param.\n */\nexport function readCodeExecutionSkills(\n tool: Tool,\n): Array<AnthropicContainerSkill> | undefined {\n return (\n getAnthropicProviderToolMetadata(tool) as\n | CodeExecutionToolMetadata\n | undefined\n )?.skills\n}\n\nexport function codeExecutionTool(\n config: CodeExecutionToolConfig,\n options: CodeExecutionToolOptions = {},\n): AnthropicCodeExecutionTool {\n const { skills } = options\n if (skills) {\n if (skills.length > 8) {\n throw new Error('code_execution supports at most 8 skills per request.')\n }\n for (const skill of skills) {\n if (skill.skill_id.length < 1 || skill.skill_id.length > 64) {\n throw new Error('skill_id must be between 1 and 64 characters.')\n }\n }\n }\n const metadata: CodeExecutionToolMetadata = {\n config,\n ...(skills && { skills }),\n }\n return brandAnthropicProviderTool<AnthropicCodeExecutionTool>(\n {\n name: 'code_execution',\n description: '',\n metadata,\n },\n 'code_execution',\n )\n}\n"],"mappings":";;AA6CA,SAAgB,wCACd,MACyB;CAIzB,OAAO,wBAAwB,IAAI;AACrC;;;;;AAMA,SAAgB,wBACd,MACqC;CACrC,OACE,iCAAiC,IAAI,CAAC,EAGrC;AACL;;;;;AAMA,SAAgB,wBACd,MAC4C;CAC5C,OACE,iCAAiC,IAAI,CAAC,EAGrC;AACL;AAEA,SAAgB,kBACd,QACA,UAAoC,CAAC,GACT;CAC5B,MAAM,EAAE,WAAW;CACnB,IAAI,QAAQ;EACV,IAAI,OAAO,SAAS,GAClB,MAAM,IAAI,MAAM,uDAAuD;EAEzE,KAAK,MAAM,SAAS,QAClB,IAAI,MAAM,SAAS,SAAS,KAAK,MAAM,SAAS,SAAS,IACvD,MAAM,IAAI,MAAM,+CAA+C;CAGrE;CACA,MAAM,WAAsC;EAC1C;EACA,GAAI,UAAU,EAAE,OAAO;CACzB;CACA,OAAO,2BACL;EACE,MAAM;EACN,aAAa;EACb;CACF,GACA,gBACF;AACF"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { brandAnthropicProviderTool, getAnthropicProviderToolMetadata } from "./anthropic-provider-tool.js";
|
|
2
2
|
//#region src/tools/computer-use-tool.ts
|
|
3
3
|
function convertComputerUseToolToAdapterFormat(tool) {
|
|
4
|
-
return tool
|
|
4
|
+
return getAnthropicProviderToolMetadata(tool);
|
|
5
5
|
}
|
|
6
6
|
function computerUseTool(config) {
|
|
7
|
-
return
|
|
7
|
+
return brandAnthropicProviderTool({
|
|
8
8
|
name: "computer",
|
|
9
9
|
description: "",
|
|
10
10
|
metadata: config
|
|
11
|
-
});
|
|
11
|
+
}, "computer_use");
|
|
12
12
|
}
|
|
13
13
|
//#endregion
|
|
14
14
|
export { computerUseTool, convertComputerUseToolToAdapterFormat };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computer-use-tool.js","names":[],"sources":["../../../src/tools/computer-use-tool.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"computer-use-tool.js","names":[],"sources":["../../../src/tools/computer-use-tool.ts"],"sourcesContent":["import {\n brandAnthropicProviderTool,\n getAnthropicProviderToolMetadata,\n} from './anthropic-provider-tool'\nimport type {\n BetaToolComputerUse20241022,\n BetaToolComputerUse20250124,\n} from '@anthropic-ai/sdk/resources/beta'\nimport type { ProviderTool, Tool } from '@tanstack/ai'\n\nexport type ComputerUseToolConfig =\n | BetaToolComputerUse20241022\n | BetaToolComputerUse20250124\n\n/** @deprecated Renamed to `ComputerUseToolConfig`. Will be removed in a future release. */\nexport type ComputerUseTool = ComputerUseToolConfig\n\nexport type AnthropicComputerUseTool = ProviderTool<'anthropic', 'computer_use'>\n\nexport function convertComputerUseToolToAdapterFormat(\n tool: Tool,\n): ComputerUseToolConfig {\n const metadata = getAnthropicProviderToolMetadata(\n tool,\n ) as ComputerUseToolConfig\n return metadata\n}\n\nexport function computerUseTool(\n config: ComputerUseToolConfig,\n): AnthropicComputerUseTool {\n return brandAnthropicProviderTool<AnthropicComputerUseTool>(\n {\n name: 'computer',\n description: '',\n metadata: config,\n },\n 'computer_use',\n )\n}\n"],"mappings":";;AAmBA,SAAgB,sCACd,MACuB;CAIvB,OAHiB,iCACf,IAEK;AACT;AAEA,SAAgB,gBACd,QAC0B;CAC1B,OAAO,2BACL;EACE,MAAM;EACN,aAAa;EACb,UAAU;CACZ,GACA,cACF;AACF"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { brandAnthropicProviderTool, getAnthropicProviderToolMetadata } from "./anthropic-provider-tool.js";
|
|
2
2
|
//#region src/tools/memory-tool.ts
|
|
3
3
|
function convertMemoryToolToAdapterFormat(tool) {
|
|
4
4
|
return {
|
|
5
5
|
type: "memory_20250818",
|
|
6
|
-
...tool
|
|
6
|
+
...getAnthropicProviderToolMetadata(tool)
|
|
7
7
|
};
|
|
8
8
|
}
|
|
9
9
|
function memoryTool(config) {
|
|
10
|
-
return
|
|
10
|
+
return brandAnthropicProviderTool({
|
|
11
11
|
name: "memory",
|
|
12
12
|
description: "",
|
|
13
13
|
metadata: config
|
|
14
|
-
});
|
|
14
|
+
}, "memory");
|
|
15
15
|
}
|
|
16
16
|
//#endregion
|
|
17
17
|
export { convertMemoryToolToAdapterFormat, memoryTool };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory-tool.js","names":[],"sources":["../../../src/tools/memory-tool.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"memory-tool.js","names":[],"sources":["../../../src/tools/memory-tool.ts"],"sourcesContent":["import {\n brandAnthropicProviderTool,\n getAnthropicProviderToolMetadata,\n} from './anthropic-provider-tool'\nimport type { BetaMemoryTool20250818 } from '@anthropic-ai/sdk/resources/beta'\nimport type { ProviderTool, Tool } from '@tanstack/ai'\n\nexport type MemoryToolConfig = BetaMemoryTool20250818\n\n/** @deprecated Renamed to `MemoryToolConfig`. Will be removed in a future release. */\nexport type MemoryTool = MemoryToolConfig\n\nexport type AnthropicMemoryTool = ProviderTool<'anthropic', 'memory'>\n\nexport function convertMemoryToolToAdapterFormat(tool: Tool): MemoryToolConfig {\n const metadata = getAnthropicProviderToolMetadata(tool) as Omit<\n MemoryToolConfig,\n 'type'\n >\n return {\n type: 'memory_20250818',\n ...metadata,\n }\n}\n\nexport function memoryTool(config?: MemoryToolConfig): AnthropicMemoryTool {\n return brandAnthropicProviderTool<AnthropicMemoryTool>(\n {\n name: 'memory',\n description: '',\n metadata: config,\n },\n 'memory',\n )\n}\n"],"mappings":";;AAcA,SAAgB,iCAAiC,MAA8B;CAK7E,OAAO;EACL,MAAM;EACN,GANe,iCAAiC,IAM7C;CACL;AACF;AAEA,SAAgB,WAAW,QAAgD;CACzE,OAAO,2BACL;EACE,MAAM;EACN,aAAa;EACb,UAAU;CACZ,GACA,QACF;AACF"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { brandAnthropicProviderTool, getAnthropicProviderToolMetadata } from "./anthropic-provider-tool.js";
|
|
2
2
|
//#region src/tools/text-editor-tool.ts
|
|
3
3
|
function convertTextEditorToolToAdapterFormat(tool) {
|
|
4
|
-
return { ...tool
|
|
4
|
+
return { ...getAnthropicProviderToolMetadata(tool) };
|
|
5
5
|
}
|
|
6
6
|
function textEditorTool(config) {
|
|
7
|
-
return
|
|
7
|
+
return brandAnthropicProviderTool({
|
|
8
8
|
name: "str_replace_editor",
|
|
9
9
|
description: "",
|
|
10
10
|
metadata: config
|
|
11
|
-
});
|
|
11
|
+
}, "text_editor");
|
|
12
12
|
}
|
|
13
13
|
//#endregion
|
|
14
14
|
export { convertTextEditorToolToAdapterFormat, textEditorTool };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-editor-tool.js","names":[],"sources":["../../../src/tools/text-editor-tool.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"text-editor-tool.js","names":[],"sources":["../../../src/tools/text-editor-tool.ts"],"sourcesContent":["import {\n brandAnthropicProviderTool,\n getAnthropicProviderToolMetadata,\n} from './anthropic-provider-tool'\nimport type {\n ToolTextEditor20250124,\n ToolTextEditor20250429,\n ToolTextEditor20250728,\n} from '@anthropic-ai/sdk/resources/messages'\nimport type { ProviderTool, Tool } from '@tanstack/ai'\n\nexport type TextEditorToolConfig =\n | ToolTextEditor20250124\n | ToolTextEditor20250429\n | ToolTextEditor20250728\n\n/** @deprecated Renamed to `TextEditorToolConfig`. Will be removed in a future release. */\nexport type TextEditorTool = TextEditorToolConfig\n\nexport type AnthropicTextEditorTool = ProviderTool<'anthropic', 'text_editor'>\n\nexport function convertTextEditorToolToAdapterFormat(\n tool: Tool,\n): TextEditorToolConfig {\n const metadata = getAnthropicProviderToolMetadata(\n tool,\n ) as TextEditorToolConfig\n return {\n ...metadata,\n }\n}\n\nexport function textEditorTool<T extends TextEditorToolConfig>(\n config: T,\n): AnthropicTextEditorTool {\n return brandAnthropicProviderTool<AnthropicTextEditorTool>(\n {\n name: 'str_replace_editor',\n description: '',\n metadata: config,\n },\n 'text_editor',\n )\n}\n"],"mappings":";;AAqBA,SAAgB,qCACd,MACsB;CAItB,OAAO,EACL,GAJe,iCACf,IAGG,EACL;AACF;AAEA,SAAgB,eACd,QACyB;CACzB,OAAO,2BACL;EACE,MAAM;EACN,aAAa;EACb,UAAU;CACZ,GACA,aACF;AACF"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getAnthropicProviderToolKind } from "./anthropic-provider-tool.js";
|
|
1
2
|
import { convertBashToolToAdapterFormat } from "./bash-tool.js";
|
|
2
3
|
import { convertCodeExecutionToolToAdapterFormat } from "./code-execution-tool.js";
|
|
3
4
|
import { convertComputerUseToolToAdapterFormat } from "./computer-use-tool.js";
|
|
@@ -6,6 +7,7 @@ import { convertMemoryToolToAdapterFormat } from "./memory-tool.js";
|
|
|
6
7
|
import { convertTextEditorToolToAdapterFormat } from "./text-editor-tool.js";
|
|
7
8
|
import { convertWebFetchToolToAdapterFormat } from "./web-fetch-tool.js";
|
|
8
9
|
import { convertWebSearchToolToAdapterFormat } from "./web-search-tool.js";
|
|
10
|
+
import { assertUniqueToolNames } from "@tanstack/ai/adapter-internals";
|
|
9
11
|
//#region src/tools/tool-converter.ts
|
|
10
12
|
/**
|
|
11
13
|
* Converts standard Tool format to Anthropic-specific tool format
|
|
@@ -32,16 +34,17 @@ import { convertWebSearchToolToAdapterFormat } from "./web-search-tool.js";
|
|
|
32
34
|
* ```
|
|
33
35
|
*/
|
|
34
36
|
function convertToolsToProviderFormat(tools) {
|
|
37
|
+
assertUniqueToolNames(tools);
|
|
35
38
|
return tools.map((tool) => {
|
|
36
|
-
switch (tool
|
|
39
|
+
switch (getAnthropicProviderToolKind(tool)) {
|
|
37
40
|
case "bash": return convertBashToolToAdapterFormat(tool);
|
|
38
41
|
case "code_execution": return convertCodeExecutionToolToAdapterFormat(tool);
|
|
39
|
-
case "
|
|
42
|
+
case "computer_use": return convertComputerUseToolToAdapterFormat(tool);
|
|
40
43
|
case "memory": return convertMemoryToolToAdapterFormat(tool);
|
|
41
|
-
case "
|
|
44
|
+
case "text_editor": return convertTextEditorToolToAdapterFormat(tool);
|
|
42
45
|
case "web_fetch": return convertWebFetchToolToAdapterFormat(tool);
|
|
43
46
|
case "web_search": return convertWebSearchToolToAdapterFormat(tool);
|
|
44
|
-
|
|
47
|
+
case void 0: return convertCustomToolToAdapterFormat(tool);
|
|
45
48
|
}
|
|
46
49
|
});
|
|
47
50
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-converter.js","names":[],"sources":["../../../src/tools/tool-converter.ts"],"sourcesContent":["import { convertBashToolToAdapterFormat } from './bash-tool'\nimport { convertCodeExecutionToolToAdapterFormat } from './code-execution-tool'\nimport { convertComputerUseToolToAdapterFormat } from './computer-use-tool'\nimport { convertCustomToolToAdapterFormat } from './custom-tool'\nimport { convertMemoryToolToAdapterFormat } from './memory-tool'\nimport { convertTextEditorToolToAdapterFormat } from './text-editor-tool'\nimport { convertWebFetchToolToAdapterFormat } from './web-fetch-tool'\nimport { convertWebSearchToolToAdapterFormat } from './web-search-tool'\nimport type { AnthropicTool } from './index'\nimport type { Tool } from '@tanstack/ai'\n\n/**\n * Converts standard Tool format to Anthropic-specific tool format\n *\n * @param tools - Array of standard Tool objects\n * @returns Array of Anthropic-specific tool definitions\n *\n * @example\n * ```typescript\n * const tools: Tool[] = [{\n * type: \"function\",\n * function: {\n * name: \"get_weather\",\n * description: \"Get weather for a location\",\n * parameters: {\n * type: \"object\",\n * properties: { location: { type: \"string\" } },\n * required: [\"location\"]\n * }\n * }\n * }];\n *\n * const anthropicTools = convertToolsToProviderFormat(tools);\n * ```\n */\nexport function convertToolsToProviderFormat<TTool extends Tool>(\n tools: Array<TTool>,\n): Array<AnthropicTool> {\n return tools.map((tool) => {\n
|
|
1
|
+
{"version":3,"file":"tool-converter.js","names":[],"sources":["../../../src/tools/tool-converter.ts"],"sourcesContent":["import { assertUniqueToolNames } from '@tanstack/ai/adapter-internals'\nimport { getAnthropicProviderToolKind } from './anthropic-provider-tool'\nimport { convertBashToolToAdapterFormat } from './bash-tool'\nimport { convertCodeExecutionToolToAdapterFormat } from './code-execution-tool'\nimport { convertComputerUseToolToAdapterFormat } from './computer-use-tool'\nimport { convertCustomToolToAdapterFormat } from './custom-tool'\nimport { convertMemoryToolToAdapterFormat } from './memory-tool'\nimport { convertTextEditorToolToAdapterFormat } from './text-editor-tool'\nimport { convertWebFetchToolToAdapterFormat } from './web-fetch-tool'\nimport { convertWebSearchToolToAdapterFormat } from './web-search-tool'\nimport type { AnthropicTool } from './index'\nimport type { Tool } from '@tanstack/ai'\n\n/**\n * Converts standard Tool format to Anthropic-specific tool format\n *\n * @param tools - Array of standard Tool objects\n * @returns Array of Anthropic-specific tool definitions\n *\n * @example\n * ```typescript\n * const tools: Tool[] = [{\n * type: \"function\",\n * function: {\n * name: \"get_weather\",\n * description: \"Get weather for a location\",\n * parameters: {\n * type: \"object\",\n * properties: { location: { type: \"string\" } },\n * required: [\"location\"]\n * }\n * }\n * }];\n *\n * const anthropicTools = convertToolsToProviderFormat(tools);\n * ```\n */\nexport function convertToolsToProviderFormat<TTool extends Tool>(\n tools: Array<TTool>,\n): Array<AnthropicTool> {\n assertUniqueToolNames(tools)\n return tools.map((tool) => {\n switch (getAnthropicProviderToolKind(tool)) {\n case 'bash':\n return convertBashToolToAdapterFormat(tool)\n case 'code_execution':\n return convertCodeExecutionToolToAdapterFormat(tool)\n case 'computer_use':\n return convertComputerUseToolToAdapterFormat(tool)\n case 'memory':\n return convertMemoryToolToAdapterFormat(tool)\n case 'text_editor':\n return convertTextEditorToolToAdapterFormat(tool)\n case 'web_fetch':\n return convertWebFetchToolToAdapterFormat(tool)\n case 'web_search':\n return convertWebSearchToolToAdapterFormat(tool)\n case undefined:\n return convertCustomToolToAdapterFormat(tool)\n }\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,SAAgB,6BACd,OACsB;CACtB,sBAAsB,KAAK;CAC3B,OAAO,MAAM,KAAK,SAAS;EACzB,QAAQ,6BAA6B,IAAI,GAAzC;GACE,KAAK,QACH,OAAO,+BAA+B,IAAI;GAC5C,KAAK,kBACH,OAAO,wCAAwC,IAAI;GACrD,KAAK,gBACH,OAAO,sCAAsC,IAAI;GACnD,KAAK,UACH,OAAO,iCAAiC,IAAI;GAC9C,KAAK,eACH,OAAO,qCAAqC,IAAI;GAClD,KAAK,aACH,OAAO,mCAAmC,IAAI;GAChD,KAAK,cACH,OAAO,oCAAoC,IAAI;GACjD,KAAK,KAAA,GACH,OAAO,iCAAiC,IAAI;EAChD;CACF,CAAC;AACH"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { brandAnthropicProviderTool, getAnthropicProviderToolMetadata } from "./anthropic-provider-tool.js";
|
|
2
2
|
//#region src/tools/web-fetch-tool.ts
|
|
3
3
|
function convertWebFetchToolToAdapterFormat(tool) {
|
|
4
4
|
return {
|
|
5
5
|
name: "web_fetch",
|
|
6
6
|
type: "web_fetch_20250910",
|
|
7
|
-
...tool
|
|
7
|
+
...getAnthropicProviderToolMetadata(tool)
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
10
|
function webFetchTool(config) {
|
|
11
|
-
return
|
|
11
|
+
return brandAnthropicProviderTool({
|
|
12
12
|
name: "web_fetch",
|
|
13
13
|
description: "",
|
|
14
14
|
metadata: config
|
|
15
|
-
});
|
|
15
|
+
}, "web_fetch");
|
|
16
16
|
}
|
|
17
17
|
//#endregion
|
|
18
18
|
export { convertWebFetchToolToAdapterFormat, webFetchTool };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-fetch-tool.js","names":[],"sources":["../../../src/tools/web-fetch-tool.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"web-fetch-tool.js","names":[],"sources":["../../../src/tools/web-fetch-tool.ts"],"sourcesContent":["import {\n brandAnthropicProviderTool,\n getAnthropicProviderToolMetadata,\n} from './anthropic-provider-tool'\nimport type { BetaWebFetchTool20250910 } from '@anthropic-ai/sdk/resources/beta'\nimport type { ProviderTool, Tool } from '@tanstack/ai'\n\nexport type WebFetchToolConfig = BetaWebFetchTool20250910\n\n/** @deprecated Renamed to `WebFetchToolConfig`. Will be removed in a future release. */\nexport type WebFetchTool = WebFetchToolConfig\n\nexport type AnthropicWebFetchTool = ProviderTool<'anthropic', 'web_fetch'>\n\nexport function convertWebFetchToolToAdapterFormat(\n tool: Tool,\n): WebFetchToolConfig {\n const metadata = getAnthropicProviderToolMetadata(tool) as Omit<\n WebFetchToolConfig,\n 'type' | 'name'\n >\n return {\n name: 'web_fetch',\n type: 'web_fetch_20250910',\n ...metadata,\n }\n}\n\nexport function webFetchTool(\n config?: Omit<WebFetchToolConfig, 'type' | 'name'>,\n): AnthropicWebFetchTool {\n return brandAnthropicProviderTool<AnthropicWebFetchTool>(\n {\n name: 'web_fetch',\n description: '',\n metadata: config,\n },\n 'web_fetch',\n )\n}\n"],"mappings":";;AAcA,SAAgB,mCACd,MACoB;CAKpB,OAAO;EACL,MAAM;EACN,MAAM;EACN,GAPe,iCAAiC,IAO7C;CACL;AACF;AAEA,SAAgB,aACd,QACuB;CACvB,OAAO,2BACL;EACE,MAAM;EACN,aAAa;EACb,UAAU;CACZ,GACA,WACF;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { brandAnthropicProviderTool, getAnthropicProviderToolMetadata } from "./anthropic-provider-tool.js";
|
|
2
2
|
//#region src/tools/web-search-tool.ts
|
|
3
3
|
var validateDomains = (tool) => {
|
|
4
4
|
if (tool.allowed_domains && tool.blocked_domains) throw new Error("allowed_domains and blocked_domains cannot be used together.");
|
|
@@ -13,25 +13,25 @@ var validateUserLocation = (tool) => {
|
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
15
|
function convertWebSearchToolToAdapterFormat(tool) {
|
|
16
|
-
const metadata = tool
|
|
16
|
+
const metadata = getAnthropicProviderToolMetadata(tool);
|
|
17
17
|
return {
|
|
18
18
|
name: "web_search",
|
|
19
19
|
type: "web_search_20250305",
|
|
20
|
-
...metadata
|
|
21
|
-
...metadata
|
|
22
|
-
...metadata
|
|
23
|
-
...metadata
|
|
24
|
-
cache_control: metadata.
|
|
20
|
+
...metadata?.allowed_domains !== void 0 && { allowed_domains: metadata.allowed_domains },
|
|
21
|
+
...metadata?.blocked_domains !== void 0 && { blocked_domains: metadata.blocked_domains },
|
|
22
|
+
...metadata?.max_uses !== void 0 && { max_uses: metadata.max_uses },
|
|
23
|
+
...metadata?.user_location !== void 0 && { user_location: metadata.user_location },
|
|
24
|
+
...metadata?.cache_control !== void 0 && { cache_control: metadata.cache_control }
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
function webSearchTool(config) {
|
|
28
28
|
validateDomains(config);
|
|
29
29
|
validateUserLocation(config);
|
|
30
|
-
return
|
|
30
|
+
return brandAnthropicProviderTool({
|
|
31
31
|
name: "web_search",
|
|
32
32
|
description: "",
|
|
33
33
|
metadata: config
|
|
34
|
-
});
|
|
34
|
+
}, "web_search");
|
|
35
35
|
}
|
|
36
36
|
//#endregion
|
|
37
37
|
export { convertWebSearchToolToAdapterFormat, webSearchTool };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-search-tool.js","names":[],"sources":["../../../src/tools/web-search-tool.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"web-search-tool.js","names":[],"sources":["../../../src/tools/web-search-tool.ts"],"sourcesContent":["import {\n brandAnthropicProviderTool,\n getAnthropicProviderToolMetadata,\n} from './anthropic-provider-tool'\nimport type { WebSearchTool20250305 } from '@anthropic-ai/sdk/resources/messages'\nimport type { ProviderTool, Tool } from '@tanstack/ai'\n\nexport type WebSearchToolConfig = WebSearchTool20250305\n\n/** @deprecated Renamed to `WebSearchToolConfig`. Will be removed in a future release. */\nexport type WebSearchTool = WebSearchToolConfig\n\nexport type AnthropicWebSearchTool = ProviderTool<'anthropic', 'web_search'>\n\nconst validateDomains = (tool: WebSearchToolConfig) => {\n if (tool.allowed_domains && tool.blocked_domains) {\n throw new Error(\n 'allowed_domains and blocked_domains cannot be used together.',\n )\n }\n}\n\nconst validateUserLocation = (tool: WebSearchToolConfig) => {\n const userLocation = tool.user_location\n if (userLocation) {\n if (\n userLocation.city &&\n (userLocation.city.length < 1 || userLocation.city.length > 255)\n ) {\n throw new Error(\n 'user_location.city must be between 1 and 255 characters.',\n )\n }\n if (userLocation.country && userLocation.country.length !== 2) {\n throw new Error('user_location.country must be exactly 2 characters.')\n }\n if (\n userLocation.region &&\n (userLocation.region.length < 1 || userLocation.region.length > 255)\n ) {\n throw new Error(\n 'user_location.region must be between 1 and 255 characters.',\n )\n }\n if (\n userLocation.timezone &&\n (userLocation.timezone.length < 1 || userLocation.timezone.length > 255)\n ) {\n throw new Error(\n 'user_location.timezone must be between 1 and 255 characters.',\n )\n }\n }\n}\n\nexport function convertWebSearchToolToAdapterFormat(\n tool: Tool,\n): WebSearchToolConfig {\n // The factory stores the SDK config (`allowed_domains`, `max_uses`, …)\n // on `metadata`. Vendor `WebSearchTool20250305` declares those fields as\n // `T | null` (no `| undefined`) under exactOptionalPropertyTypes, so\n // spread them only when present rather than passing explicit `undefined`.\n const metadata = getAnthropicProviderToolMetadata(tool)\n return {\n name: 'web_search',\n type: 'web_search_20250305',\n ...(metadata?.allowed_domains !== undefined && {\n allowed_domains: metadata.allowed_domains,\n }),\n ...(metadata?.blocked_domains !== undefined && {\n blocked_domains: metadata.blocked_domains,\n }),\n ...(metadata?.max_uses !== undefined && { max_uses: metadata.max_uses }),\n ...(metadata?.user_location !== undefined && {\n user_location: metadata.user_location,\n }),\n ...(metadata?.cache_control !== undefined && {\n cache_control: metadata.cache_control,\n }),\n }\n}\n\nexport function webSearchTool(\n config: WebSearchToolConfig,\n): AnthropicWebSearchTool {\n validateDomains(config)\n validateUserLocation(config)\n return brandAnthropicProviderTool<AnthropicWebSearchTool>(\n {\n name: 'web_search',\n description: '',\n metadata: config,\n },\n 'web_search',\n )\n}\n"],"mappings":";;AAcA,IAAM,mBAAmB,SAA8B;CACrD,IAAI,KAAK,mBAAmB,KAAK,iBAC/B,MAAM,IAAI,MACR,8DACF;AAEJ;AAEA,IAAM,wBAAwB,SAA8B;CAC1D,MAAM,eAAe,KAAK;CAC1B,IAAI,cAAc;EAChB,IACE,aAAa,SACZ,aAAa,KAAK,SAAS,KAAK,aAAa,KAAK,SAAS,MAE5D,MAAM,IAAI,MACR,0DACF;EAEF,IAAI,aAAa,WAAW,aAAa,QAAQ,WAAW,GAC1D,MAAM,IAAI,MAAM,qDAAqD;EAEvE,IACE,aAAa,WACZ,aAAa,OAAO,SAAS,KAAK,aAAa,OAAO,SAAS,MAEhE,MAAM,IAAI,MACR,4DACF;EAEF,IACE,aAAa,aACZ,aAAa,SAAS,SAAS,KAAK,aAAa,SAAS,SAAS,MAEpE,MAAM,IAAI,MACR,8DACF;CAEJ;AACF;AAEA,SAAgB,oCACd,MACqB;CAKrB,MAAM,WAAW,iCAAiC,IAAI;CACtD,OAAO;EACL,MAAM;EACN,MAAM;EACN,GAAI,UAAU,oBAAoB,KAAA,KAAa,EAC7C,iBAAiB,SAAS,gBAC5B;EACA,GAAI,UAAU,oBAAoB,KAAA,KAAa,EAC7C,iBAAiB,SAAS,gBAC5B;EACA,GAAI,UAAU,aAAa,KAAA,KAAa,EAAE,UAAU,SAAS,SAAS;EACtE,GAAI,UAAU,kBAAkB,KAAA,KAAa,EAC3C,eAAe,SAAS,cAC1B;EACA,GAAI,UAAU,kBAAkB,KAAA,KAAa,EAC3C,eAAe,SAAS,cAC1B;CACF;AACF;AAEA,SAAgB,cACd,QACwB;CACxB,gBAAgB,MAAM;CACtB,qBAAqB,MAAM;CAC3B,OAAO,2BACL;EACE,MAAM;EACN,aAAa;EACb,UAAU;CACZ,GACA,YACF;AACF"}
|