@tanstack/ai-anthropic 0.16.3 → 0.16.4
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/summarize.js +39 -12
- package/dist/esm/adapters/summarize.js.map +1 -1
- package/dist/esm/adapters/text.js +841 -940
- package/dist/esm/adapters/text.js.map +1 -1
- package/dist/esm/index.js +3 -13
- package/dist/esm/model-meta.js +399 -74
- package/dist/esm/model-meta.js.map +1 -1
- package/dist/esm/text/text-provider-options.js +19 -26
- package/dist/esm/text/text-provider-options.js.map +1 -1
- package/dist/esm/tools/bash-tool.js +11 -12
- package/dist/esm/tools/bash-tool.js.map +1 -1
- package/dist/esm/tools/code-execution-tool.js +29 -30
- package/dist/esm/tools/code-execution-tool.js.map +1 -1
- package/dist/esm/tools/computer-use-tool.js +11 -12
- package/dist/esm/tools/computer-use-tool.js.map +1 -1
- package/dist/esm/tools/custom-tool.js +29 -30
- package/dist/esm/tools/custom-tool.js.map +1 -1
- package/dist/esm/tools/index.js +1 -14
- package/dist/esm/tools/memory-tool.js +14 -15
- package/dist/esm/tools/memory-tool.js.map +1 -1
- package/dist/esm/tools/text-editor-tool.js +11 -14
- package/dist/esm/tools/text-editor-tool.js.map +1 -1
- package/dist/esm/tools/tool-converter.js +41 -25
- package/dist/esm/tools/tool-converter.js.map +1 -1
- package/dist/esm/tools/web-fetch-tool.js +15 -16
- package/dist/esm/tools/web-fetch-tool.js.map +1 -1
- package/dist/esm/tools/web-search-tool.js +32 -56
- package/dist/esm/tools/web-search-tool.js.map +1 -1
- package/dist/esm/usage.js +33 -32
- package/dist/esm/usage.js.map +1 -1
- package/dist/esm/utils/client.js +23 -14
- package/dist/esm/utils/client.js.map +1 -1
- package/package.json +6 -6
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/tools/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-provider-options.js","sources":["../../../src/text/text-provider-options.ts"],"sourcesContent":["import type {\n BetaContextManagementConfig,\n BetaToolChoiceAny,\n BetaToolChoiceAuto,\n BetaToolChoiceTool,\n} from '@anthropic-ai/sdk/resources/beta/messages/messages'\nimport type { CacheControlEphemeral } from '@anthropic-ai/sdk/resources'\nimport type { AnthropicContainerSkill, AnthropicTool } from '../tools/index'\nimport type {\n MessageParam,\n TextBlockParam,\n} from '@anthropic-ai/sdk/resources/messages'\n\n/**\n * Per-prompt metadata Anthropic understands on `systemPrompts` entries.\n *\n * Used via the structured form of `systemPrompts`:\n *\n * @example\n * import type { AnthropicSystemPromptMetadata } from '@tanstack/ai-anthropic'\n *\n * chat({\n * adapter: anthropicText(),\n * model: 'claude-sonnet-4-6',\n * systemPrompts: [\n * {\n * content: 'Stable instructions — cache me.',\n * metadata: { cache_control: { type: 'ephemeral' } } satisfies AnthropicSystemPromptMetadata,\n * },\n * 'Volatile per-request instruction.',\n * ],\n * })\n */\nexport interface AnthropicSystemPromptMetadata {\n /**\n * Anthropic prompt-caching control applied to this system prompt's\n * `TextBlockParam`.\n *\n * @see https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching\n */\n cache_control?: CacheControlEphemeral\n}\n\nexport interface AnthropicContainerOptions {\n /**\n * Container identifier for reuse across requests.\n * Container parameters with skills to be loaded.\n */\n container?: {\n id: string | null\n /**\n * List of skills to load into the container.\n *\n * @deprecated Configure skills on the `code_execution` tool instead:\n * `codeExecutionTool(config, { skills })`. The adapter lifts those into\n * `container.skills` and attaches the required beta headers. Setting\n * skills here bypasses the beta-header wiring and may stop working.\n */\n skills: Array<AnthropicContainerSkill> | null\n } | null\n}\n\nexport interface AnthropicContextManagementOptions {\n /**\n * Context management configuration.\n\nThis allows you to control how Claude manages context across multiple requests, such as whether to clear function results or not.\n */\n context_management?: BetaContextManagementConfig | null\n}\n\nexport interface AnthropicMCPOptions {\n /**\n * MCP servers to be utilized in this request\n * Maximum of 20 servers\n */\n mcp_servers?: Array<MCPServer>\n}\n\nexport interface AnthropicServiceTierOptions {\n /**\n * Determines whether to use priority capacity (if available) or standard capacity for this request.\n */\n service_tier?: 'auto' | 'standard_only'\n}\n\nexport interface AnthropicStopSequencesOptions {\n /**\n * Custom text sequences that will cause the model to stop generating.\n\nAnthropic models will normally stop when they have naturally completed their turn, which will result in a response stop_reason of \"end_turn\".\n\nIf you want the model to stop generating when it encounters custom strings of text, you can use the stop_sequences parameter. If the model encounters one of the custom sequences, the response stop_reason value will be \"stop_sequence\" and the response stop_sequence value will contain the matched stop sequence.\n */\n stop_sequences?: Array<string>\n}\n\nexport interface AnthropicThinkingOptions {\n /**\n * Configuration for enabling Claude's extended thinking.\n\nWhen enabled, responses include thinking content blocks showing Claude's thinking process before the final answer. Requires a minimum budget of 1,024 tokens and counts towards your max_tokens limit.\n */\n thinking?:\n | {\n /**\n* Determines how many tokens Claude can use for its internal reasoning process. Larger budgets can enable more thorough analysis for complex problems, improving response quality.\n\nMust be ≥1024 and less than max_tokens\n*/\n budget_tokens: number\n\n type: 'enabled'\n }\n | {\n type: 'disabled'\n }\n}\n\nexport interface AnthropicAdaptiveThinkingOptions {\n /**\n * Configuration for Claude's adaptive thinking (Opus 4.6+).\n *\n * In adaptive mode, Claude dynamically decides when and how much to think.\n * Use the effort parameter to control thinking depth.\n * `thinking: {type: \"enabled\"}` with `budget_tokens` is deprecated on Opus 4.6.\n */\n thinking?:\n | {\n type: 'adaptive'\n /**\n * Controls what (if any) thinking content is streamed back.\n *\n * - `'summarized'`: stream summarized thinking via `thinking_delta`\n * events (the user-visible reasoning text).\n * - `'omitted'`: stream the thinking block's `signature_delta` only\n * (no reasoning text reaches the client).\n *\n * On Claude Opus 4.6 the default is `'summarized'`. On\n * Claude Opus 4.7 the default flipped to `'omitted'` — callers\n * must set `'summarized'` explicitly to get the reasoning text.\n */\n display?: 'summarized' | 'omitted'\n }\n | {\n /**\n * @deprecated Use `type: 'adaptive'` with the effort parameter on Opus 4.6+.\n */\n budget_tokens: number\n type: 'enabled'\n }\n | {\n type: 'disabled'\n }\n}\n\n/**\n * Thinking configuration for models where thinking is always on\n * (e.g. Claude Fable 5).\n *\n * On these models the only accepted explicit configuration is\n * `{type: 'adaptive'}` — both `{type: 'disabled'}` and\n * `{type: 'enabled', budget_tokens}` are rejected with a 400. Omitting the\n * `thinking` field entirely also runs adaptive thinking.\n */\nexport interface AnthropicAdaptiveOnlyThinkingOptions {\n thinking?: {\n type: 'adaptive'\n /**\n * Controls what (if any) thinking content is streamed back.\n *\n * - `'summarized'`: stream summarized thinking via `thinking_delta`\n * events (the user-visible reasoning text).\n * - `'omitted'` (default): stream the thinking block's\n * `signature_delta` only (no reasoning text reaches the client).\n */\n display?: 'summarized' | 'omitted'\n }\n}\n\n/**\n * Thinking configuration for models that accept adaptive thinking or an\n * explicit opt-out, but no manual token budget (e.g. Claude Sonnet 5,\n * Claude Opus 4.7/4.8).\n *\n * `{type: 'enabled', budget_tokens}` is rejected with a 400 on these\n * models. On Claude Sonnet 5, omitting the `thinking` field runs adaptive\n * thinking by default; on Opus 4.7/4.8 it runs without thinking — set\n * `{type: 'adaptive'}` explicitly there.\n */\nexport interface AnthropicAdaptiveOrDisabledThinkingOptions {\n thinking?:\n | {\n type: 'adaptive'\n /**\n * Controls what (if any) thinking content is streamed back.\n * Defaults to `'omitted'` — set `'summarized'` to receive the\n * reasoning text.\n */\n display?: 'summarized' | 'omitted'\n }\n | {\n type: 'disabled'\n }\n}\n\n/**\n * `max_tokens` on its own, for models that reject the sampling parameters\n * (`temperature`, `top_p`, `top_k`) — e.g. Claude Fable 5 and Claude Opus\n * 4.7/4.8 reject them outright, and Claude Sonnet 5 returns a 400 when a\n * non-default sampling value is sent.\n */\nexport interface AnthropicMaxTokensOptions {\n /**\n * The maximum number of tokens to generate before stopping. This parameter only specifies the absolute maximum number of tokens to generate. Required by the API; the adapter defaults to 1024 when omitted.\n * Range x >= 1.\n */\n max_tokens?: number\n}\n\nexport interface AnthropicEffortOptions {\n /**\n * Controls the thinking depth for adaptive thinking mode (Opus 4.6+).\n *\n * - `max`: Absolute highest capability\n * - `high`: Default - Claude will almost always think\n * - `medium`: Balanced cost-quality\n * - `low`: May skip thinking for simpler problems\n */\n effort?: 'max' | 'high' | 'medium' | 'low'\n}\n\nexport interface AnthropicOutputConfigOptions {\n /**\n * Output configuration for the model's response.\n *\n * On Claude 4.7+ the top-level `effort` field was relocated under\n * `output_config.effort`, and `thinking: { type: 'enabled', budget_tokens }`\n * was replaced by `thinking: { type: 'adaptive' }` paired with\n * `output_config.effort`. Earlier models continue to accept the legacy\n * top-level `effort` / `thinking.type: 'enabled'` shape.\n *\n * The engine also writes `output_config.format` here when the caller\n * passes `outputSchema` to a Claude 4.5+ adapter (issue #605 native\n * combined mode). Both fields coexist: user-supplied `effort` is\n * preserved when the engine adds `format`.\n */\n output_config?: {\n /**\n * `'xhigh'` is accepted on Claude Opus 4.7+, Claude Sonnet 5, and\n * Claude Fable 5; older models support `'low'`–`'max'` only.\n */\n effort?: 'low' | 'medium' | 'high' | 'xhigh' | 'max' | null\n }\n}\n\nexport interface AnthropicToolChoiceOptions {\n tool_choice?: BetaToolChoiceAny | BetaToolChoiceTool | BetaToolChoiceAuto\n}\n\nexport interface AnthropicSamplingOptions {\n /**\n * Only sample from the top K options for each subsequent token.\n\nUsed to remove \"long tail\" low probability responses.\nRecommended for advanced use cases only. You usually only need to use temperature.\n\nRequired range: x >= 0\n */\n top_k?: number\n /**\n * Amount of randomness injected into the response.\n * Either use this or top_p, but not both.\n * Defaults to 1.0. Ranges from 0.0 to 1.0. Use temperature closer to 0.0 for analytical / multiple choice, and closer to 1.0 for creative and generative tasks.\n * @default 1.0\n */\n temperature?: number\n /**\n * Use nucleus sampling.\n *\n * In nucleus sampling, we compute the cumulative distribution over all the options for each subsequent token in decreasing probability order and cut it off once it reaches a particular probability specified by top_p. You should either alter temperature or top_p, but not both.\n */\n top_p?: number\n /**\n * The maximum number of tokens to generate before stopping. This parameter only specifies the absolute maximum number of tokens to generate. Required by the API; the adapter defaults to 1024 when omitted.\n * Range x >= 1.\n */\n max_tokens?: number\n}\n\nexport type ExternalTextProviderOptions = AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions &\n Partial<AnthropicAdaptiveThinkingOptions> &\n Partial<AnthropicEffortOptions> &\n Partial<AnthropicOutputConfigOptions>\n\nexport interface InternalTextProviderOptions extends ExternalTextProviderOptions {\n model: string\n\n messages: Array<MessageParam>\n\n /**\n * The maximum number of tokens to generate before stopping. This parameter only specifies the absolute maximum number of tokens to generate.\n * Range x >= 1.\n */\n max_tokens: number\n /**\n * Whether to incrementally stream the response using server-sent events.\n */\n stream?: boolean\n /**\n * System prompt — built by the adapter from the user-facing\n * `systemPrompts: Array<string>` on the chat call. This field is internal:\n * users should pass system prompts via `systemPrompts`, not via\n * `modelOptions`.\n *\n * A system prompt is a way of providing context and instructions to Claude,\n * such as specifying a particular goal or role.\n */\n system?: string | Array<TextBlockParam>\n\n tools?: Array<AnthropicTool>\n\n /**\n * Schema-constrained final answer in a single Messages request (issue\n * #605). Set by the engine when the adapter declared\n * `supportsCombinedToolsAndSchema` and a caller passed `outputSchema`\n * to `chat()`. The model emits tool calls during the agent loop and a\n * schema-matching JSON message on the natural final turn — no separate\n * finalization round-trip needed.\n *\n * The SDK type (`BetaOutputConfig`) currently exposes only `effort`;\n * `format` is accepted at runtime per the deprecation notice on the\n * older `output_format` field\n * (https://platform.claude.com/docs/en/build-with-claude/structured-outputs).\n * We type it explicitly here so the adapter call site doesn't need a\n * cast.\n */\n output_config?: {\n effort?: 'low' | 'medium' | 'high' | 'xhigh' | 'max' | null\n format?: {\n type: 'json_schema'\n schema: Record<string, unknown>\n }\n }\n}\n\nconst validateTopPandTemperature = (options: InternalTextProviderOptions) => {\n if (options.top_p !== undefined && options.temperature !== undefined) {\n throw new Error('You should either set top_p or temperature, but not both.')\n }\n}\n\nexport interface CacheControl {\n type: 'ephemeral'\n ttl: '5m' | '1h'\n}\n\nconst validateThinking = (options: InternalTextProviderOptions) => {\n const thinking = options.thinking\n if (thinking && thinking.type === 'enabled') {\n if (thinking.budget_tokens < 1024) {\n throw new Error('thinking.budget_tokens must be at least 1024.')\n }\n if (thinking.budget_tokens >= options.max_tokens) {\n throw new Error('thinking.budget_tokens must be less than max_tokens.')\n }\n }\n}\n\ninterface MCPServer {\n name: string\n url: string\n type: 'url'\n authorization_token?: string | null\n tool_configuration: {\n allowed_tools?: Array<string> | null\n enabled?: boolean | null\n } | null\n}\n\nconst validateMaxTokens = (options: InternalTextProviderOptions) => {\n if (options.max_tokens < 1) {\n throw new Error('max_tokens must be at least 1.')\n }\n}\n\nexport const validateTextProviderOptions = (\n options: InternalTextProviderOptions,\n) => {\n validateTopPandTemperature(options)\n validateThinking(options)\n validateMaxTokens(options)\n}\n"],"names":[],"mappings":"AAiWA,MAAM,6BAA6B,CAAC,YAAyC;AAC3E,MAAI,QAAQ,UAAU,UAAa,QAAQ,gBAAgB,QAAW;AACpE,UAAM,IAAI,MAAM,2DAA2D;AAAA,EAC7E;AACF;AAOA,MAAM,mBAAmB,CAAC,YAAyC;AACjE,QAAM,WAAW,QAAQ;AACzB,MAAI,YAAY,SAAS,SAAS,WAAW;AAC3C,QAAI,SAAS,gBAAgB,MAAM;AACjC,YAAM,IAAI,MAAM,+CAA+C;AAAA,IACjE;AACA,QAAI,SAAS,iBAAiB,QAAQ,YAAY;AAChD,YAAM,IAAI,MAAM,sDAAsD;AAAA,IACxE;AAAA,EACF;AACF;AAaA,MAAM,oBAAoB,CAAC,YAAyC;AAClE,MAAI,QAAQ,aAAa,GAAG;AAC1B,UAAM,IAAI,MAAM,gCAAgC;AAAA,EAClD;AACF;AAEO,MAAM,8BAA8B,CACzC,YACG;AACH,6BAA2B,OAAO;AAClC,mBAAiB,OAAO;AACxB,oBAAkB,OAAO;AAC3B;"}
|
|
1
|
+
{"version":3,"file":"text-provider-options.js","names":[],"sources":["../../../src/text/text-provider-options.ts"],"sourcesContent":["import type {\n BetaContextManagementConfig,\n BetaToolChoiceAny,\n BetaToolChoiceAuto,\n BetaToolChoiceTool,\n} from '@anthropic-ai/sdk/resources/beta/messages/messages'\nimport type { CacheControlEphemeral } from '@anthropic-ai/sdk/resources'\nimport type { AnthropicContainerSkill, AnthropicTool } from '../tools/index'\nimport type {\n MessageParam,\n TextBlockParam,\n} from '@anthropic-ai/sdk/resources/messages'\n\n/**\n * Per-prompt metadata Anthropic understands on `systemPrompts` entries.\n *\n * Used via the structured form of `systemPrompts`:\n *\n * @example\n * import type { AnthropicSystemPromptMetadata } from '@tanstack/ai-anthropic'\n *\n * chat({\n * adapter: anthropicText(),\n * model: 'claude-sonnet-4-6',\n * systemPrompts: [\n * {\n * content: 'Stable instructions — cache me.',\n * metadata: { cache_control: { type: 'ephemeral' } } satisfies AnthropicSystemPromptMetadata,\n * },\n * 'Volatile per-request instruction.',\n * ],\n * })\n */\nexport interface AnthropicSystemPromptMetadata {\n /**\n * Anthropic prompt-caching control applied to this system prompt's\n * `TextBlockParam`.\n *\n * @see https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching\n */\n cache_control?: CacheControlEphemeral\n}\n\nexport interface AnthropicContainerOptions {\n /**\n * Container identifier for reuse across requests.\n * Container parameters with skills to be loaded.\n */\n container?: {\n id: string | null\n /**\n * List of skills to load into the container.\n *\n * @deprecated Configure skills on the `code_execution` tool instead:\n * `codeExecutionTool(config, { skills })`. The adapter lifts those into\n * `container.skills` and attaches the required beta headers. Setting\n * skills here bypasses the beta-header wiring and may stop working.\n */\n skills: Array<AnthropicContainerSkill> | null\n } | null\n}\n\nexport interface AnthropicContextManagementOptions {\n /**\n * Context management configuration.\n\nThis allows you to control how Claude manages context across multiple requests, such as whether to clear function results or not.\n */\n context_management?: BetaContextManagementConfig | null\n}\n\nexport interface AnthropicMCPOptions {\n /**\n * MCP servers to be utilized in this request\n * Maximum of 20 servers\n */\n mcp_servers?: Array<MCPServer>\n}\n\nexport interface AnthropicServiceTierOptions {\n /**\n * Determines whether to use priority capacity (if available) or standard capacity for this request.\n */\n service_tier?: 'auto' | 'standard_only'\n}\n\nexport interface AnthropicStopSequencesOptions {\n /**\n * Custom text sequences that will cause the model to stop generating.\n\nAnthropic models will normally stop when they have naturally completed their turn, which will result in a response stop_reason of \"end_turn\".\n\nIf you want the model to stop generating when it encounters custom strings of text, you can use the stop_sequences parameter. If the model encounters one of the custom sequences, the response stop_reason value will be \"stop_sequence\" and the response stop_sequence value will contain the matched stop sequence.\n */\n stop_sequences?: Array<string>\n}\n\nexport interface AnthropicThinkingOptions {\n /**\n * Configuration for enabling Claude's extended thinking.\n\nWhen enabled, responses include thinking content blocks showing Claude's thinking process before the final answer. Requires a minimum budget of 1,024 tokens and counts towards your max_tokens limit.\n */\n thinking?:\n | {\n /**\n* Determines how many tokens Claude can use for its internal reasoning process. Larger budgets can enable more thorough analysis for complex problems, improving response quality.\n\nMust be ≥1024 and less than max_tokens\n*/\n budget_tokens: number\n\n type: 'enabled'\n }\n | {\n type: 'disabled'\n }\n}\n\nexport interface AnthropicAdaptiveThinkingOptions {\n /**\n * Configuration for Claude's adaptive thinking (Opus 4.6+).\n *\n * In adaptive mode, Claude dynamically decides when and how much to think.\n * Use the effort parameter to control thinking depth.\n * `thinking: {type: \"enabled\"}` with `budget_tokens` is deprecated on Opus 4.6.\n */\n thinking?:\n | {\n type: 'adaptive'\n /**\n * Controls what (if any) thinking content is streamed back.\n *\n * - `'summarized'`: stream summarized thinking via `thinking_delta`\n * events (the user-visible reasoning text).\n * - `'omitted'`: stream the thinking block's `signature_delta` only\n * (no reasoning text reaches the client).\n *\n * On Claude Opus 4.6 the default is `'summarized'`. On\n * Claude Opus 4.7 the default flipped to `'omitted'` — callers\n * must set `'summarized'` explicitly to get the reasoning text.\n */\n display?: 'summarized' | 'omitted'\n }\n | {\n /**\n * @deprecated Use `type: 'adaptive'` with the effort parameter on Opus 4.6+.\n */\n budget_tokens: number\n type: 'enabled'\n }\n | {\n type: 'disabled'\n }\n}\n\n/**\n * Thinking configuration for models where thinking is always on\n * (e.g. Claude Fable 5).\n *\n * On these models the only accepted explicit configuration is\n * `{type: 'adaptive'}` — both `{type: 'disabled'}` and\n * `{type: 'enabled', budget_tokens}` are rejected with a 400. Omitting the\n * `thinking` field entirely also runs adaptive thinking.\n */\nexport interface AnthropicAdaptiveOnlyThinkingOptions {\n thinking?: {\n type: 'adaptive'\n /**\n * Controls what (if any) thinking content is streamed back.\n *\n * - `'summarized'`: stream summarized thinking via `thinking_delta`\n * events (the user-visible reasoning text).\n * - `'omitted'` (default): stream the thinking block's\n * `signature_delta` only (no reasoning text reaches the client).\n */\n display?: 'summarized' | 'omitted'\n }\n}\n\n/**\n * Thinking configuration for models that accept adaptive thinking or an\n * explicit opt-out, but no manual token budget (e.g. Claude Sonnet 5,\n * Claude Opus 4.7/4.8).\n *\n * `{type: 'enabled', budget_tokens}` is rejected with a 400 on these\n * models. On Claude Sonnet 5, omitting the `thinking` field runs adaptive\n * thinking by default; on Opus 4.7/4.8 it runs without thinking — set\n * `{type: 'adaptive'}` explicitly there.\n */\nexport interface AnthropicAdaptiveOrDisabledThinkingOptions {\n thinking?:\n | {\n type: 'adaptive'\n /**\n * Controls what (if any) thinking content is streamed back.\n * Defaults to `'omitted'` — set `'summarized'` to receive the\n * reasoning text.\n */\n display?: 'summarized' | 'omitted'\n }\n | {\n type: 'disabled'\n }\n}\n\n/**\n * `max_tokens` on its own, for models that reject the sampling parameters\n * (`temperature`, `top_p`, `top_k`) — e.g. Claude Fable 5 and Claude Opus\n * 4.7/4.8 reject them outright, and Claude Sonnet 5 returns a 400 when a\n * non-default sampling value is sent.\n */\nexport interface AnthropicMaxTokensOptions {\n /**\n * The maximum number of tokens to generate before stopping. This parameter only specifies the absolute maximum number of tokens to generate. Required by the API; the adapter defaults to 1024 when omitted.\n * Range x >= 1.\n */\n max_tokens?: number\n}\n\nexport interface AnthropicEffortOptions {\n /**\n * Controls the thinking depth for adaptive thinking mode (Opus 4.6+).\n *\n * - `max`: Absolute highest capability\n * - `high`: Default - Claude will almost always think\n * - `medium`: Balanced cost-quality\n * - `low`: May skip thinking for simpler problems\n */\n effort?: 'max' | 'high' | 'medium' | 'low'\n}\n\nexport interface AnthropicOutputConfigOptions {\n /**\n * Output configuration for the model's response.\n *\n * On Claude 4.7+ the top-level `effort` field was relocated under\n * `output_config.effort`, and `thinking: { type: 'enabled', budget_tokens }`\n * was replaced by `thinking: { type: 'adaptive' }` paired with\n * `output_config.effort`. Earlier models continue to accept the legacy\n * top-level `effort` / `thinking.type: 'enabled'` shape.\n *\n * The engine also writes `output_config.format` here when the caller\n * passes `outputSchema` to a Claude 4.5+ adapter (issue #605 native\n * combined mode). Both fields coexist: user-supplied `effort` is\n * preserved when the engine adds `format`.\n */\n output_config?: {\n /**\n * `'xhigh'` is accepted on Claude Opus 4.7+, Claude Sonnet 5, and\n * Claude Fable 5; older models support `'low'`–`'max'` only.\n */\n effort?: 'low' | 'medium' | 'high' | 'xhigh' | 'max' | null\n }\n}\n\nexport interface AnthropicToolChoiceOptions {\n tool_choice?: BetaToolChoiceAny | BetaToolChoiceTool | BetaToolChoiceAuto\n}\n\nexport interface AnthropicSamplingOptions {\n /**\n * Only sample from the top K options for each subsequent token.\n\nUsed to remove \"long tail\" low probability responses.\nRecommended for advanced use cases only. You usually only need to use temperature.\n\nRequired range: x >= 0\n */\n top_k?: number\n /**\n * Amount of randomness injected into the response.\n * Either use this or top_p, but not both.\n * Defaults to 1.0. Ranges from 0.0 to 1.0. Use temperature closer to 0.0 for analytical / multiple choice, and closer to 1.0 for creative and generative tasks.\n * @default 1.0\n */\n temperature?: number\n /**\n * Use nucleus sampling.\n *\n * In nucleus sampling, we compute the cumulative distribution over all the options for each subsequent token in decreasing probability order and cut it off once it reaches a particular probability specified by top_p. You should either alter temperature or top_p, but not both.\n */\n top_p?: number\n /**\n * The maximum number of tokens to generate before stopping. This parameter only specifies the absolute maximum number of tokens to generate. Required by the API; the adapter defaults to 1024 when omitted.\n * Range x >= 1.\n */\n max_tokens?: number\n}\n\nexport type ExternalTextProviderOptions = AnthropicContainerOptions &\n AnthropicContextManagementOptions &\n AnthropicMCPOptions &\n AnthropicServiceTierOptions &\n AnthropicStopSequencesOptions &\n AnthropicThinkingOptions &\n AnthropicToolChoiceOptions &\n AnthropicSamplingOptions &\n Partial<AnthropicAdaptiveThinkingOptions> &\n Partial<AnthropicEffortOptions> &\n Partial<AnthropicOutputConfigOptions>\n\nexport interface InternalTextProviderOptions extends ExternalTextProviderOptions {\n model: string\n\n messages: Array<MessageParam>\n\n /**\n * The maximum number of tokens to generate before stopping. This parameter only specifies the absolute maximum number of tokens to generate.\n * Range x >= 1.\n */\n max_tokens: number\n /**\n * Whether to incrementally stream the response using server-sent events.\n */\n stream?: boolean\n /**\n * System prompt — built by the adapter from the user-facing\n * `systemPrompts: Array<string>` on the chat call. This field is internal:\n * users should pass system prompts via `systemPrompts`, not via\n * `modelOptions`.\n *\n * A system prompt is a way of providing context and instructions to Claude,\n * such as specifying a particular goal or role.\n */\n system?: string | Array<TextBlockParam>\n\n tools?: Array<AnthropicTool>\n\n /**\n * Schema-constrained final answer in a single Messages request (issue\n * #605). Set by the engine when the adapter declared\n * `supportsCombinedToolsAndSchema` and a caller passed `outputSchema`\n * to `chat()`. The model emits tool calls during the agent loop and a\n * schema-matching JSON message on the natural final turn — no separate\n * finalization round-trip needed.\n *\n * The SDK type (`BetaOutputConfig`) currently exposes only `effort`;\n * `format` is accepted at runtime per the deprecation notice on the\n * older `output_format` field\n * (https://platform.claude.com/docs/en/build-with-claude/structured-outputs).\n * We type it explicitly here so the adapter call site doesn't need a\n * cast.\n */\n output_config?: {\n effort?: 'low' | 'medium' | 'high' | 'xhigh' | 'max' | null\n format?: {\n type: 'json_schema'\n schema: Record<string, unknown>\n }\n }\n}\n\nconst validateTopPandTemperature = (options: InternalTextProviderOptions) => {\n if (options.top_p !== undefined && options.temperature !== undefined) {\n throw new Error('You should either set top_p or temperature, but not both.')\n }\n}\n\nexport interface CacheControl {\n type: 'ephemeral'\n ttl: '5m' | '1h'\n}\n\nconst validateThinking = (options: InternalTextProviderOptions) => {\n const thinking = options.thinking\n if (thinking && thinking.type === 'enabled') {\n if (thinking.budget_tokens < 1024) {\n throw new Error('thinking.budget_tokens must be at least 1024.')\n }\n if (thinking.budget_tokens >= options.max_tokens) {\n throw new Error('thinking.budget_tokens must be less than max_tokens.')\n }\n }\n}\n\ninterface MCPServer {\n name: string\n url: string\n type: 'url'\n authorization_token?: string | null\n tool_configuration: {\n allowed_tools?: Array<string> | null\n enabled?: boolean | null\n } | null\n}\n\nconst validateMaxTokens = (options: InternalTextProviderOptions) => {\n if (options.max_tokens < 1) {\n throw new Error('max_tokens must be at least 1.')\n }\n}\n\nexport const validateTextProviderOptions = (\n options: InternalTextProviderOptions,\n) => {\n validateTopPandTemperature(options)\n validateThinking(options)\n validateMaxTokens(options)\n}\n"],"mappings":";AAiWA,IAAM,8BAA8B,YAAyC;CAC3E,IAAI,QAAQ,UAAU,KAAA,KAAa,QAAQ,gBAAgB,KAAA,GACzD,MAAM,IAAI,MAAM,2DAA2D;AAE/E;AAOA,IAAM,oBAAoB,YAAyC;CACjE,MAAM,WAAW,QAAQ;CACzB,IAAI,YAAY,SAAS,SAAS,WAAW;EAC3C,IAAI,SAAS,gBAAgB,MAC3B,MAAM,IAAI,MAAM,+CAA+C;EAEjE,IAAI,SAAS,iBAAiB,QAAQ,YACpC,MAAM,IAAI,MAAM,sDAAsD;CAE1E;AACF;AAaA,IAAM,qBAAqB,YAAyC;CAClE,IAAI,QAAQ,aAAa,GACvB,MAAM,IAAI,MAAM,gCAAgC;AAEpD;AAEA,IAAa,+BACX,YACG;CACH,2BAA2B,OAAO;CAClC,iBAAiB,OAAO;CACxB,kBAAkB,OAAO;AAC3B"}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { brandProviderTool } from "@tanstack/ai";
|
|
2
|
+
//#region src/tools/bash-tool.ts
|
|
2
3
|
function convertBashToolToAdapterFormat(tool) {
|
|
3
|
-
|
|
4
|
-
return metadata;
|
|
4
|
+
return tool.metadata;
|
|
5
5
|
}
|
|
6
6
|
function bashTool(config) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
return brandProviderTool({
|
|
8
|
+
name: "bash",
|
|
9
|
+
description: "",
|
|
10
|
+
metadata: config
|
|
11
|
+
});
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
//# sourceMappingURL=bash-tool.js.map
|
|
13
|
+
//#endregion
|
|
14
|
+
export { bashTool, convertBashToolToAdapterFormat };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=bash-tool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bash-tool.js","sources":["../../../src/tools/bash-tool.ts"],"sourcesContent":["import { brandProviderTool } from '@tanstack/ai'\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 = tool.metadata as BashToolConfig\n return metadata\n}\n\nexport function bashTool(config: BashToolConfig): AnthropicBashTool {\n return brandProviderTool<AnthropicBashTool>({\n name: 'bash',\n description: '',\n metadata: config,\n })\n}\n"],"
|
|
1
|
+
{"version":3,"file":"bash-tool.js","names":[],"sources":["../../../src/tools/bash-tool.ts"],"sourcesContent":["import { brandProviderTool } from '@tanstack/ai'\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 = tool.metadata as BashToolConfig\n return metadata\n}\n\nexport function bashTool(config: BashToolConfig): AnthropicBashTool {\n return brandProviderTool<AnthropicBashTool>({\n name: 'bash',\n description: '',\n metadata: config,\n })\n}\n"],"mappings":";;AAcA,SAAgB,+BAA+B,MAA4B;CAEzE,OADiB,KAAK;AAExB;AAEA,SAAgB,SAAS,QAA2C;CAClE,OAAO,kBAAqC;EAC1C,MAAM;EACN,aAAa;EACb,UAAU;CACZ,CAAC;AACH"}
|
|
@@ -1,39 +1,38 @@
|
|
|
1
1
|
import { brandProviderTool } from "@tanstack/ai";
|
|
2
|
+
//#region src/tools/code-execution-tool.ts
|
|
2
3
|
function convertCodeExecutionToolToAdapterFormat(tool) {
|
|
3
|
-
|
|
4
|
+
return readCodeExecutionConfig(tool);
|
|
4
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* Reads the SDK tool config attached to a `code_execution` tool, if any.
|
|
8
|
+
* Used by the text adapter to select the version-aware code-execution beta.
|
|
9
|
+
*/
|
|
5
10
|
function readCodeExecutionConfig(tool) {
|
|
6
|
-
|
|
11
|
+
return tool.metadata?.config;
|
|
7
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Reads the hosted skills attached to a `code_execution` tool, if any.
|
|
15
|
+
* Used by the text adapter to build the top-level `container.skills` param.
|
|
16
|
+
*/
|
|
8
17
|
function readCodeExecutionSkills(tool) {
|
|
9
|
-
|
|
18
|
+
return tool.metadata?.skills;
|
|
10
19
|
}
|
|
11
20
|
function codeExecutionTool(config, options = {}) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
...skills && { skills }
|
|
26
|
-
};
|
|
27
|
-
return brandProviderTool({
|
|
28
|
-
name: "code_execution",
|
|
29
|
-
description: "",
|
|
30
|
-
metadata
|
|
31
|
-
});
|
|
21
|
+
const { skills } = options;
|
|
22
|
+
if (skills) {
|
|
23
|
+
if (skills.length > 8) throw new Error("code_execution supports at most 8 skills per request.");
|
|
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
|
+
}
|
|
26
|
+
return brandProviderTool({
|
|
27
|
+
name: "code_execution",
|
|
28
|
+
description: "",
|
|
29
|
+
metadata: {
|
|
30
|
+
config,
|
|
31
|
+
...skills && { skills }
|
|
32
|
+
}
|
|
33
|
+
});
|
|
32
34
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
readCodeExecutionSkills
|
|
38
|
-
};
|
|
39
|
-
//# sourceMappingURL=code-execution-tool.js.map
|
|
35
|
+
//#endregion
|
|
36
|
+
export { codeExecutionTool, convertCodeExecutionToolToAdapterFormat, readCodeExecutionConfig, readCodeExecutionSkills };
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=code-execution-tool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"code-execution-tool.js","sources":["../../../src/tools/code-execution-tool.ts"],"sourcesContent":["import { brandProviderTool } from '@tanstack/ai'\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 (tool.metadata as CodeExecutionToolMetadata | undefined)?.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 (tool.metadata as CodeExecutionToolMetadata | undefined)?.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 brandProviderTool<AnthropicCodeExecutionTool>({\n name: 'code_execution',\n description: '',\n metadata,\n })\n}\n"],"
|
|
1
|
+
{"version":3,"file":"code-execution-tool.js","names":[],"sources":["../../../src/tools/code-execution-tool.ts"],"sourcesContent":["import { brandProviderTool } from '@tanstack/ai'\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 (tool.metadata as CodeExecutionToolMetadata | undefined)?.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 (tool.metadata as CodeExecutionToolMetadata | undefined)?.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 brandProviderTool<AnthropicCodeExecutionTool>({\n name: 'code_execution',\n description: '',\n metadata,\n })\n}\n"],"mappings":";;AA0CA,SAAgB,wCACd,MACyB;CAIzB,OAAO,wBAAwB,IAAI;AACrC;;;;;AAMA,SAAgB,wBACd,MACqC;CACrC,OAAQ,KAAK,UAAoD;AACnE;;;;;AAMA,SAAgB,wBACd,MAC4C;CAC5C,OAAQ,KAAK,UAAoD;AACnE;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;CAKA,OAAO,kBAA8C;EACnD,MAAM;EACN,aAAa;EACb,UAAA;GANA;GACA,GAAI,UAAU,EAAE,OAAO;EAKvB;CACF,CAAC;AACH"}
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { brandProviderTool } from "@tanstack/ai";
|
|
2
|
+
//#region src/tools/computer-use-tool.ts
|
|
2
3
|
function convertComputerUseToolToAdapterFormat(tool) {
|
|
3
|
-
|
|
4
|
-
return metadata;
|
|
4
|
+
return tool.metadata;
|
|
5
5
|
}
|
|
6
6
|
function computerUseTool(config) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
return brandProviderTool({
|
|
8
|
+
name: "computer",
|
|
9
|
+
description: "",
|
|
10
|
+
metadata: config
|
|
11
|
+
});
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
//# sourceMappingURL=computer-use-tool.js.map
|
|
13
|
+
//#endregion
|
|
14
|
+
export { computerUseTool, convertComputerUseToolToAdapterFormat };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=computer-use-tool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computer-use-tool.js","sources":["../../../src/tools/computer-use-tool.ts"],"sourcesContent":["import { brandProviderTool } from '@tanstack/ai'\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 = tool.metadata as ComputerUseToolConfig\n return metadata\n}\n\nexport function computerUseTool(\n config: ComputerUseToolConfig,\n): AnthropicComputerUseTool {\n return brandProviderTool<AnthropicComputerUseTool>({\n name: 'computer',\n description: '',\n metadata: config,\n })\n}\n"],"
|
|
1
|
+
{"version":3,"file":"computer-use-tool.js","names":[],"sources":["../../../src/tools/computer-use-tool.ts"],"sourcesContent":["import { brandProviderTool } from '@tanstack/ai'\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 = tool.metadata as ComputerUseToolConfig\n return metadata\n}\n\nexport function computerUseTool(\n config: ComputerUseToolConfig,\n): AnthropicComputerUseTool {\n return brandProviderTool<AnthropicComputerUseTool>({\n name: 'computer',\n description: '',\n metadata: config,\n })\n}\n"],"mappings":";;AAgBA,SAAgB,sCACd,MACuB;CAEvB,OADiB,KAAK;AAExB;AAEA,SAAgB,gBACd,QAC0B;CAC1B,OAAO,kBAA4C;EACjD,MAAM;EACN,aAAa;EACb,UAAU;CACZ,CAAC;AACH"}
|
|
@@ -1,34 +1,33 @@
|
|
|
1
|
+
//#region src/tools/custom-tool.ts
|
|
1
2
|
function convertCustomToolToAdapterFormat(tool) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
3
|
+
const metadata = tool.metadata || {};
|
|
4
|
+
const jsonSchema = tool.inputSchema ?? {
|
|
5
|
+
type: "object",
|
|
6
|
+
properties: {},
|
|
7
|
+
required: []
|
|
8
|
+
};
|
|
9
|
+
const inputSchema = {
|
|
10
|
+
type: "object",
|
|
11
|
+
properties: jsonSchema.properties || null,
|
|
12
|
+
required: jsonSchema.required || null
|
|
13
|
+
};
|
|
14
|
+
return {
|
|
15
|
+
name: tool.name,
|
|
16
|
+
type: "custom",
|
|
17
|
+
description: tool.description,
|
|
18
|
+
input_schema: inputSchema,
|
|
19
|
+
cache_control: metadata.cacheControl || null
|
|
20
|
+
};
|
|
19
21
|
}
|
|
20
22
|
function customTool(name, description, inputSchema, cacheControl) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
};
|
|
23
|
+
return {
|
|
24
|
+
name,
|
|
25
|
+
description,
|
|
26
|
+
inputSchema,
|
|
27
|
+
metadata: { cacheControl }
|
|
28
|
+
};
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
//# sourceMappingURL=custom-tool.js.map
|
|
30
|
+
//#endregion
|
|
31
|
+
export { convertCustomToolToAdapterFormat, customTool };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=custom-tool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom-tool.js","sources":["../../../src/tools/custom-tool.ts"],"sourcesContent":["import type { JSONSchema, SchemaInput, Tool } from '@tanstack/ai'\nimport type { CacheControl } from '../text/text-provider-options'\n\nexport interface CustomToolConfig {\n /**\n * The name of the tool.\n */\n name: string\n type: 'custom'\n /**\n * A brief description of what the tool does. Tool descriptions should be as detailed as possible. The more information that the model has about what the tool is and how to use it, the better it will perform. You can use natural language descriptions to reinforce important aspects of the tool input JSON schema.\n */\n description: string\n /**\n * This defines the shape of the input that your tool accepts and that the model will produce.\n */\n input_schema: {\n type: 'object'\n properties: Record<string, any> | null\n required?: Array<string> | null\n }\n\n cache_control?: CacheControl | null\n}\n\n/** @deprecated Renamed to `CustomToolConfig`. Will be removed in a future release. */\nexport type CustomTool = CustomToolConfig\n\nexport function convertCustomToolToAdapterFormat(tool: Tool): CustomToolConfig {\n const metadata =\n (tool.metadata as { cacheControl?: CacheControl | null } | undefined) || {}\n\n const jsonSchema = (tool.inputSchema ?? {\n type: 'object',\n properties: {},\n required: [],\n }) as JSONSchema\n\n const inputSchema = {\n type: 'object' as const,\n properties: jsonSchema.properties || null,\n required: jsonSchema.required || null,\n }\n\n return {\n name: tool.name,\n type: 'custom',\n description: tool.description,\n input_schema: inputSchema,\n cache_control: metadata.cacheControl || null,\n }\n}\n\nexport function customTool(\n name: string,\n description: string,\n inputSchema: SchemaInput,\n cacheControl?: CacheControl | null,\n): Tool {\n return {\n name,\n description,\n inputSchema,\n metadata: {\n cacheControl,\n },\n }\n}\n"],"
|
|
1
|
+
{"version":3,"file":"custom-tool.js","names":[],"sources":["../../../src/tools/custom-tool.ts"],"sourcesContent":["import type { JSONSchema, SchemaInput, Tool } from '@tanstack/ai'\nimport type { CacheControl } from '../text/text-provider-options'\n\nexport interface CustomToolConfig {\n /**\n * The name of the tool.\n */\n name: string\n type: 'custom'\n /**\n * A brief description of what the tool does. Tool descriptions should be as detailed as possible. The more information that the model has about what the tool is and how to use it, the better it will perform. You can use natural language descriptions to reinforce important aspects of the tool input JSON schema.\n */\n description: string\n /**\n * This defines the shape of the input that your tool accepts and that the model will produce.\n */\n input_schema: {\n type: 'object'\n properties: Record<string, any> | null\n required?: Array<string> | null\n }\n\n cache_control?: CacheControl | null\n}\n\n/** @deprecated Renamed to `CustomToolConfig`. Will be removed in a future release. */\nexport type CustomTool = CustomToolConfig\n\nexport function convertCustomToolToAdapterFormat(tool: Tool): CustomToolConfig {\n const metadata =\n (tool.metadata as { cacheControl?: CacheControl | null } | undefined) || {}\n\n const jsonSchema = (tool.inputSchema ?? {\n type: 'object',\n properties: {},\n required: [],\n }) as JSONSchema\n\n const inputSchema = {\n type: 'object' as const,\n properties: jsonSchema.properties || null,\n required: jsonSchema.required || null,\n }\n\n return {\n name: tool.name,\n type: 'custom',\n description: tool.description,\n input_schema: inputSchema,\n cache_control: metadata.cacheControl || null,\n }\n}\n\nexport function customTool(\n name: string,\n description: string,\n inputSchema: SchemaInput,\n cacheControl?: CacheControl | null,\n): Tool {\n return {\n name,\n description,\n inputSchema,\n metadata: {\n cacheControl,\n },\n }\n}\n"],"mappings":";AA4BA,SAAgB,iCAAiC,MAA8B;CAC7E,MAAM,WACH,KAAK,YAAmE,CAAC;CAE5E,MAAM,aAAc,KAAK,eAAe;EACtC,MAAM;EACN,YAAY,CAAC;EACb,UAAU,CAAC;CACb;CAEA,MAAM,cAAc;EAClB,MAAM;EACN,YAAY,WAAW,cAAc;EACrC,UAAU,WAAW,YAAY;CACnC;CAEA,OAAO;EACL,MAAM,KAAK;EACX,MAAM;EACN,aAAa,KAAK;EAClB,cAAc;EACd,eAAe,SAAS,gBAAgB;CAC1C;AACF;AAEA,SAAgB,WACd,MACA,aACA,aACA,cACM;CACN,OAAO;EACL;EACA;EACA;EACA,UAAU,EACR,aACF;CACF;AACF"}
|
package/dist/esm/tools/index.js
CHANGED
|
@@ -6,17 +6,4 @@ import { memoryTool } from "./memory-tool.js";
|
|
|
6
6
|
import { textEditorTool } from "./text-editor-tool.js";
|
|
7
7
|
import { webFetchTool } from "./web-fetch-tool.js";
|
|
8
8
|
import { webSearchTool } from "./web-search-tool.js";
|
|
9
|
-
export {
|
|
10
|
-
bashTool,
|
|
11
|
-
codeExecutionTool,
|
|
12
|
-
computerUseTool,
|
|
13
|
-
convertCodeExecutionToolToAdapterFormat,
|
|
14
|
-
customTool,
|
|
15
|
-
memoryTool,
|
|
16
|
-
readCodeExecutionConfig,
|
|
17
|
-
readCodeExecutionSkills,
|
|
18
|
-
textEditorTool,
|
|
19
|
-
webFetchTool,
|
|
20
|
-
webSearchTool
|
|
21
|
-
};
|
|
22
|
-
//# sourceMappingURL=index.js.map
|
|
9
|
+
export { bashTool, codeExecutionTool, computerUseTool, convertCodeExecutionToolToAdapterFormat, customTool, memoryTool, readCodeExecutionConfig, readCodeExecutionSkills, textEditorTool, webFetchTool, webSearchTool };
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import { brandProviderTool } from "@tanstack/ai";
|
|
2
|
+
//#region src/tools/memory-tool.ts
|
|
2
3
|
function convertMemoryToolToAdapterFormat(tool) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
};
|
|
4
|
+
return {
|
|
5
|
+
type: "memory_20250818",
|
|
6
|
+
...tool.metadata
|
|
7
|
+
};
|
|
8
8
|
}
|
|
9
9
|
function memoryTool(config) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
return brandProviderTool({
|
|
11
|
+
name: "memory",
|
|
12
|
+
description: "",
|
|
13
|
+
metadata: config
|
|
14
|
+
});
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
//# sourceMappingURL=memory-tool.js.map
|
|
16
|
+
//#endregion
|
|
17
|
+
export { convertMemoryToolToAdapterFormat, memoryTool };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=memory-tool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory-tool.js","sources":["../../../src/tools/memory-tool.ts"],"sourcesContent":["import { brandProviderTool } from '@tanstack/ai'\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 = tool.metadata as Omit<MemoryToolConfig, 'type'>\n return {\n type: 'memory_20250818',\n ...metadata,\n }\n}\n\nexport function memoryTool(config?: MemoryToolConfig): AnthropicMemoryTool {\n return brandProviderTool<AnthropicMemoryTool>({\n name: 'memory',\n description: '',\n metadata: config,\n })\n}\n"],"
|
|
1
|
+
{"version":3,"file":"memory-tool.js","names":[],"sources":["../../../src/tools/memory-tool.ts"],"sourcesContent":["import { brandProviderTool } from '@tanstack/ai'\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 = tool.metadata as Omit<MemoryToolConfig, 'type'>\n return {\n type: 'memory_20250818',\n ...metadata,\n }\n}\n\nexport function memoryTool(config?: MemoryToolConfig): AnthropicMemoryTool {\n return brandProviderTool<AnthropicMemoryTool>({\n name: 'memory',\n description: '',\n metadata: config,\n })\n}\n"],"mappings":";;AAWA,SAAgB,iCAAiC,MAA8B;CAE7E,OAAO;EACL,MAAM;EACN,GAHe,KAAK;CAItB;AACF;AAEA,SAAgB,WAAW,QAAgD;CACzE,OAAO,kBAAuC;EAC5C,MAAM;EACN,aAAa;EACb,UAAU;CACZ,CAAC;AACH"}
|
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
import { brandProviderTool } from "@tanstack/ai";
|
|
2
|
+
//#region src/tools/text-editor-tool.ts
|
|
2
3
|
function convertTextEditorToolToAdapterFormat(tool) {
|
|
3
|
-
|
|
4
|
-
return {
|
|
5
|
-
...metadata
|
|
6
|
-
};
|
|
4
|
+
return { ...tool.metadata };
|
|
7
5
|
}
|
|
8
6
|
function textEditorTool(config) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
return brandProviderTool({
|
|
8
|
+
name: "str_replace_editor",
|
|
9
|
+
description: "",
|
|
10
|
+
metadata: config
|
|
11
|
+
});
|
|
14
12
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
//# sourceMappingURL=text-editor-tool.js.map
|
|
13
|
+
//#endregion
|
|
14
|
+
export { convertTextEditorToolToAdapterFormat, textEditorTool };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=text-editor-tool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-editor-tool.js","sources":["../../../src/tools/text-editor-tool.ts"],"sourcesContent":["import { brandProviderTool } from '@tanstack/ai'\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 = tool.metadata as TextEditorToolConfig\n return {\n ...metadata,\n }\n}\n\nexport function textEditorTool<T extends TextEditorToolConfig>(\n config: T,\n): AnthropicTextEditorTool {\n return brandProviderTool<AnthropicTextEditorTool>({\n name: 'str_replace_editor',\n description: '',\n metadata: config,\n })\n}\n"],"
|
|
1
|
+
{"version":3,"file":"text-editor-tool.js","names":[],"sources":["../../../src/tools/text-editor-tool.ts"],"sourcesContent":["import { brandProviderTool } from '@tanstack/ai'\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 = tool.metadata as TextEditorToolConfig\n return {\n ...metadata,\n }\n}\n\nexport function textEditorTool<T extends TextEditorToolConfig>(\n config: T,\n): AnthropicTextEditorTool {\n return brandProviderTool<AnthropicTextEditorTool>({\n name: 'str_replace_editor',\n description: '',\n metadata: config,\n })\n}\n"],"mappings":";;AAkBA,SAAgB,qCACd,MACsB;CAEtB,OAAO,EACL,GAFe,KAAK,SAGtB;AACF;AAEA,SAAgB,eACd,QACyB;CACzB,OAAO,kBAA2C;EAChD,MAAM;EACN,aAAa;EACb,UAAU;CACZ,CAAC;AACH"}
|
|
@@ -6,30 +6,46 @@ import { convertMemoryToolToAdapterFormat } from "./memory-tool.js";
|
|
|
6
6
|
import { convertTextEditorToolToAdapterFormat } from "./text-editor-tool.js";
|
|
7
7
|
import { convertWebFetchToolToAdapterFormat } from "./web-fetch-tool.js";
|
|
8
8
|
import { convertWebSearchToolToAdapterFormat } from "./web-search-tool.js";
|
|
9
|
+
//#region src/tools/tool-converter.ts
|
|
10
|
+
/**
|
|
11
|
+
* Converts standard Tool format to Anthropic-specific tool format
|
|
12
|
+
*
|
|
13
|
+
* @param tools - Array of standard Tool objects
|
|
14
|
+
* @returns Array of Anthropic-specific tool definitions
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const tools: Tool[] = [{
|
|
19
|
+
* type: "function",
|
|
20
|
+
* function: {
|
|
21
|
+
* name: "get_weather",
|
|
22
|
+
* description: "Get weather for a location",
|
|
23
|
+
* parameters: {
|
|
24
|
+
* type: "object",
|
|
25
|
+
* properties: { location: { type: "string" } },
|
|
26
|
+
* required: ["location"]
|
|
27
|
+
* }
|
|
28
|
+
* }
|
|
29
|
+
* }];
|
|
30
|
+
*
|
|
31
|
+
* const anthropicTools = convertToolsToProviderFormat(tools);
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
9
34
|
function convertToolsToProviderFormat(tools) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return convertTextEditorToolToAdapterFormat(tool);
|
|
23
|
-
case "web_fetch":
|
|
24
|
-
return convertWebFetchToolToAdapterFormat(tool);
|
|
25
|
-
case "web_search":
|
|
26
|
-
return convertWebSearchToolToAdapterFormat(tool);
|
|
27
|
-
default:
|
|
28
|
-
return convertCustomToolToAdapterFormat(tool);
|
|
29
|
-
}
|
|
30
|
-
});
|
|
35
|
+
return tools.map((tool) => {
|
|
36
|
+
switch (tool.name) {
|
|
37
|
+
case "bash": return convertBashToolToAdapterFormat(tool);
|
|
38
|
+
case "code_execution": return convertCodeExecutionToolToAdapterFormat(tool);
|
|
39
|
+
case "computer": return convertComputerUseToolToAdapterFormat(tool);
|
|
40
|
+
case "memory": return convertMemoryToolToAdapterFormat(tool);
|
|
41
|
+
case "str_replace_editor": return convertTextEditorToolToAdapterFormat(tool);
|
|
42
|
+
case "web_fetch": return convertWebFetchToolToAdapterFormat(tool);
|
|
43
|
+
case "web_search": return convertWebSearchToolToAdapterFormat(tool);
|
|
44
|
+
default: return convertCustomToolToAdapterFormat(tool);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
31
47
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
//# sourceMappingURL=tool-converter.js.map
|
|
48
|
+
//#endregion
|
|
49
|
+
export { convertToolsToProviderFormat };
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=tool-converter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-converter.js","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 const name = tool.name\n\n switch (name) {\n case 'bash':\n return convertBashToolToAdapterFormat(tool)\n case 'code_execution':\n return convertCodeExecutionToolToAdapterFormat(tool)\n case 'computer':\n return convertComputerUseToolToAdapterFormat(tool)\n case 'memory':\n return convertMemoryToolToAdapterFormat(tool)\n case 'str_replace_editor':\n return convertTextEditorToolToAdapterFormat(tool)\n case 'web_fetch':\n return convertWebFetchToolToAdapterFormat(tool)\n case 'web_search':\n return convertWebSearchToolToAdapterFormat(tool)\n default:\n return convertCustomToolToAdapterFormat(tool)\n }\n })\n}\n"],"
|
|
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 const name = tool.name\n\n switch (name) {\n case 'bash':\n return convertBashToolToAdapterFormat(tool)\n case 'code_execution':\n return convertCodeExecutionToolToAdapterFormat(tool)\n case 'computer':\n return convertComputerUseToolToAdapterFormat(tool)\n case 'memory':\n return convertMemoryToolToAdapterFormat(tool)\n case 'str_replace_editor':\n return convertTextEditorToolToAdapterFormat(tool)\n case 'web_fetch':\n return convertWebFetchToolToAdapterFormat(tool)\n case 'web_search':\n return convertWebSearchToolToAdapterFormat(tool)\n default:\n return convertCustomToolToAdapterFormat(tool)\n }\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,SAAgB,6BACd,OACsB;CACtB,OAAO,MAAM,KAAK,SAAS;EAGzB,QAFa,KAAK,MAElB;GACE,KAAK,QACH,OAAO,+BAA+B,IAAI;GAC5C,KAAK,kBACH,OAAO,wCAAwC,IAAI;GACrD,KAAK,YACH,OAAO,sCAAsC,IAAI;GACnD,KAAK,UACH,OAAO,iCAAiC,IAAI;GAC9C,KAAK,sBACH,OAAO,qCAAqC,IAAI;GAClD,KAAK,aACH,OAAO,mCAAmC,IAAI;GAChD,KAAK,cACH,OAAO,oCAAoC,IAAI;GACjD,SACE,OAAO,iCAAiC,IAAI;EAChD;CACF,CAAC;AACH"}
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import { brandProviderTool } from "@tanstack/ai";
|
|
2
|
+
//#region src/tools/web-fetch-tool.ts
|
|
2
3
|
function convertWebFetchToolToAdapterFormat(tool) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
4
|
+
return {
|
|
5
|
+
name: "web_fetch",
|
|
6
|
+
type: "web_fetch_20250910",
|
|
7
|
+
...tool.metadata
|
|
8
|
+
};
|
|
9
9
|
}
|
|
10
10
|
function webFetchTool(config) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
return brandProviderTool({
|
|
12
|
+
name: "web_fetch",
|
|
13
|
+
description: "",
|
|
14
|
+
metadata: config
|
|
15
|
+
});
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
//# sourceMappingURL=web-fetch-tool.js.map
|
|
17
|
+
//#endregion
|
|
18
|
+
export { convertWebFetchToolToAdapterFormat, webFetchTool };
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=web-fetch-tool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-fetch-tool.js","sources":["../../../src/tools/web-fetch-tool.ts"],"sourcesContent":["import { brandProviderTool } from '@tanstack/ai'\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 = tool.metadata as Omit<WebFetchToolConfig, 'type' | 'name'>\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 brandProviderTool<AnthropicWebFetchTool>({\n name: 'web_fetch',\n description: '',\n metadata: config,\n })\n}\n"],"
|
|
1
|
+
{"version":3,"file":"web-fetch-tool.js","names":[],"sources":["../../../src/tools/web-fetch-tool.ts"],"sourcesContent":["import { brandProviderTool } from '@tanstack/ai'\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 = tool.metadata as Omit<WebFetchToolConfig, 'type' | 'name'>\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 brandProviderTool<AnthropicWebFetchTool>({\n name: 'web_fetch',\n description: '',\n metadata: config,\n })\n}\n"],"mappings":";;AAWA,SAAgB,mCACd,MACoB;CAEpB,OAAO;EACL,MAAM;EACN,MAAM;EACN,GAJe,KAAK;CAKtB;AACF;AAEA,SAAgB,aACd,QACuB;CACvB,OAAO,kBAAyC;EAC9C,MAAM;EACN,aAAa;EACb,UAAU;CACZ,CAAC;AACH"}
|