@ai-sdk/anthropic 3.0.0-beta.73 → 3.0.0-beta.75

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -28,14 +28,14 @@ module.exports = __toCommonJS(src_exports);
28
28
 
29
29
  // src/anthropic-provider.ts
30
30
  var import_provider4 = require("@ai-sdk/provider");
31
- var import_provider_utils20 = require("@ai-sdk/provider-utils");
31
+ var import_provider_utils22 = require("@ai-sdk/provider-utils");
32
32
 
33
33
  // src/version.ts
34
- var VERSION = true ? "3.0.0-beta.73" : "0.0.0-test";
34
+ var VERSION = true ? "3.0.0-beta.75" : "0.0.0-test";
35
35
 
36
36
  // src/anthropic-messages-language-model.ts
37
37
  var import_provider3 = require("@ai-sdk/provider");
38
- var import_provider_utils11 = require("@ai-sdk/provider-utils");
38
+ var import_provider_utils12 = require("@ai-sdk/provider-utils");
39
39
 
40
40
  // src/anthropic-error.ts
41
41
  var import_provider_utils = require("@ai-sdk/provider-utils");
@@ -253,6 +253,26 @@ var anthropicMessagesResponseSchema = (0, import_provider_utils2.lazySchema)(
253
253
  old_start: import_v42.z.number().nullable()
254
254
  })
255
255
  ])
256
+ }),
257
+ // tool search tool results for tool_search_tool_regex_20251119 and tool_search_tool_bm25_20251119:
258
+ import_v42.z.object({
259
+ type: import_v42.z.literal("tool_search_tool_result"),
260
+ tool_use_id: import_v42.z.string(),
261
+ content: import_v42.z.union([
262
+ import_v42.z.object({
263
+ type: import_v42.z.literal("tool_search_tool_search_result"),
264
+ tool_references: import_v42.z.array(
265
+ import_v42.z.object({
266
+ type: import_v42.z.literal("tool_reference"),
267
+ tool_name: import_v42.z.string()
268
+ })
269
+ )
270
+ }),
271
+ import_v42.z.object({
272
+ type: import_v42.z.literal("tool_search_tool_result_error"),
273
+ error_code: import_v42.z.string()
274
+ })
275
+ ])
256
276
  })
257
277
  ])
258
278
  ),
@@ -454,6 +474,26 @@ var anthropicMessagesChunkSchema = (0, import_provider_utils2.lazySchema)(
454
474
  old_start: import_v42.z.number().nullable()
455
475
  })
456
476
  ])
477
+ }),
478
+ // tool search tool results for tool_search_tool_regex_20251119 and tool_search_tool_bm25_20251119:
479
+ import_v42.z.object({
480
+ type: import_v42.z.literal("tool_search_tool_result"),
481
+ tool_use_id: import_v42.z.string(),
482
+ content: import_v42.z.union([
483
+ import_v42.z.object({
484
+ type: import_v42.z.literal("tool_search_tool_search_result"),
485
+ tool_references: import_v42.z.array(
486
+ import_v42.z.object({
487
+ type: import_v42.z.literal("tool_reference"),
488
+ tool_name: import_v42.z.string()
489
+ })
490
+ )
491
+ }),
492
+ import_v42.z.object({
493
+ type: import_v42.z.literal("tool_search_tool_result_error"),
494
+ error_code: import_v42.z.string()
495
+ })
496
+ ])
457
497
  })
458
498
  ])
459
499
  }),
@@ -859,6 +899,7 @@ async function prepareTools({
859
899
  cacheControlValidator,
860
900
  supportsStructuredOutput
861
901
  }) {
902
+ var _a;
862
903
  tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
863
904
  const toolWarnings = [];
864
905
  const betas = /* @__PURE__ */ new Set();
@@ -874,13 +915,24 @@ async function prepareTools({
874
915
  type: "tool definition",
875
916
  canCache: true
876
917
  });
918
+ const anthropicOptions = (_a = tool.providerOptions) == null ? void 0 : _a.anthropic;
919
+ const deferLoading = anthropicOptions == null ? void 0 : anthropicOptions.deferLoading;
877
920
  anthropicTools2.push({
878
921
  name: tool.name,
879
922
  description: tool.description,
880
923
  input_schema: tool.inputSchema,
881
924
  cache_control: cacheControl,
882
- ...supportsStructuredOutput === true && tool.strict != null ? { strict: tool.strict } : {}
925
+ ...supportsStructuredOutput === true && tool.strict != null ? { strict: tool.strict } : {},
926
+ ...deferLoading != null ? { defer_loading: deferLoading } : {},
927
+ ...tool.inputExamples != null ? {
928
+ input_examples: tool.inputExamples.map(
929
+ (example) => example.input
930
+ )
931
+ } : {}
883
932
  });
933
+ if (tool.inputExamples != null) {
934
+ betas.add("advanced-tool-use-2025-11-20");
935
+ }
884
936
  break;
885
937
  }
886
938
  case "provider": {
@@ -1026,6 +1078,22 @@ async function prepareTools({
1026
1078
  });
1027
1079
  break;
1028
1080
  }
1081
+ case "anthropic.tool_search_regex_20251119": {
1082
+ betas.add("advanced-tool-use-2025-11-20");
1083
+ anthropicTools2.push({
1084
+ type: "tool_search_tool_regex_20251119",
1085
+ name: "tool_search_tool_regex"
1086
+ });
1087
+ break;
1088
+ }
1089
+ case "anthropic.tool_search_bm25_20251119": {
1090
+ betas.add("advanced-tool-use-2025-11-20");
1091
+ anthropicTools2.push({
1092
+ type: "tool_search_tool_bm25_20251119",
1093
+ name: "tool_search_tool_bm25"
1094
+ });
1095
+ break;
1096
+ }
1029
1097
  default: {
1030
1098
  toolWarnings.push({
1031
1099
  type: "unsupported",
@@ -1099,7 +1167,7 @@ async function prepareTools({
1099
1167
 
1100
1168
  // src/convert-to-anthropic-messages-prompt.ts
1101
1169
  var import_provider2 = require("@ai-sdk/provider");
1102
- var import_provider_utils10 = require("@ai-sdk/provider-utils");
1170
+ var import_provider_utils11 = require("@ai-sdk/provider-utils");
1103
1171
 
1104
1172
  // src/tool/code-execution_20250522.ts
1105
1173
  var import_provider_utils8 = require("@ai-sdk/provider-utils");
@@ -1218,6 +1286,49 @@ var codeExecution_20250825 = (args = {}) => {
1218
1286
  return factory5(args);
1219
1287
  };
1220
1288
 
1289
+ // src/tool/tool-search-regex_20251119.ts
1290
+ var import_provider_utils10 = require("@ai-sdk/provider-utils");
1291
+ var import_v49 = require("zod/v4");
1292
+ var toolSearchRegex_20251119OutputSchema = (0, import_provider_utils10.lazySchema)(
1293
+ () => (0, import_provider_utils10.zodSchema)(
1294
+ import_v49.z.array(
1295
+ import_v49.z.object({
1296
+ type: import_v49.z.literal("tool_reference"),
1297
+ toolName: import_v49.z.string()
1298
+ })
1299
+ )
1300
+ )
1301
+ );
1302
+ var toolSearchRegex_20251119InputSchema = (0, import_provider_utils10.lazySchema)(
1303
+ () => (0, import_provider_utils10.zodSchema)(
1304
+ import_v49.z.object({
1305
+ /**
1306
+ * A regex pattern to search for tools.
1307
+ * Uses Python re.search() syntax. Maximum 200 characters.
1308
+ *
1309
+ * Examples:
1310
+ * - "weather" - matches tool names/descriptions containing "weather"
1311
+ * - "get_.*_data" - matches tools like get_user_data, get_weather_data
1312
+ * - "database.*query|query.*database" - OR patterns for flexibility
1313
+ * - "(?i)slack" - case-insensitive search
1314
+ */
1315
+ pattern: import_v49.z.string(),
1316
+ /**
1317
+ * Maximum number of tools to return. Optional.
1318
+ */
1319
+ limit: import_v49.z.number().optional()
1320
+ })
1321
+ )
1322
+ );
1323
+ var factory6 = (0, import_provider_utils10.createProviderToolFactoryWithOutputSchema)({
1324
+ id: "anthropic.tool_search_regex_20251119",
1325
+ inputSchema: toolSearchRegex_20251119InputSchema,
1326
+ outputSchema: toolSearchRegex_20251119OutputSchema
1327
+ });
1328
+ var toolSearchRegex_20251119 = (args = {}) => {
1329
+ return factory6(args);
1330
+ };
1331
+
1221
1332
  // src/convert-to-anthropic-messages-prompt.ts
1222
1333
  function convertToString(data) {
1223
1334
  if (typeof data === "string") {
@@ -1250,7 +1361,7 @@ async function convertToAnthropicMessagesPrompt({
1250
1361
  const messages = [];
1251
1362
  async function shouldEnableCitations(providerMetadata) {
1252
1363
  var _a2, _b2;
1253
- const anthropicOptions = await (0, import_provider_utils10.parseProviderOptions)({
1364
+ const anthropicOptions = await (0, import_provider_utils11.parseProviderOptions)({
1254
1365
  provider: "anthropic",
1255
1366
  providerOptions: providerMetadata,
1256
1367
  schema: anthropicFilePartProviderOptions
@@ -1258,7 +1369,7 @@ async function convertToAnthropicMessagesPrompt({
1258
1369
  return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
1259
1370
  }
1260
1371
  async function getDocumentMetadata(providerMetadata) {
1261
- const anthropicOptions = await (0, import_provider_utils10.parseProviderOptions)({
1372
+ const anthropicOptions = await (0, import_provider_utils11.parseProviderOptions)({
1262
1373
  provider: "anthropic",
1263
1374
  providerOptions: providerMetadata,
1264
1375
  schema: anthropicFilePartProviderOptions
@@ -1324,7 +1435,7 @@ async function convertToAnthropicMessagesPrompt({
1324
1435
  } : {
1325
1436
  type: "base64",
1326
1437
  media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
1327
- data: (0, import_provider_utils10.convertToBase64)(part.data)
1438
+ data: (0, import_provider_utils11.convertToBase64)(part.data)
1328
1439
  },
1329
1440
  cache_control: cacheControl
1330
1441
  });
@@ -1344,7 +1455,7 @@ async function convertToAnthropicMessagesPrompt({
1344
1455
  } : {
1345
1456
  type: "base64",
1346
1457
  media_type: "application/pdf",
1347
- data: (0, import_provider_utils10.convertToBase64)(part.data)
1458
+ data: (0, import_provider_utils11.convertToBase64)(part.data)
1348
1459
  },
1349
1460
  title: (_b = metadata.title) != null ? _b : part.filename,
1350
1461
  ...metadata.context && { context: metadata.context },
@@ -1464,7 +1575,7 @@ async function convertToAnthropicMessagesPrompt({
1464
1575
  return void 0;
1465
1576
  }
1466
1577
  }
1467
- }).filter(import_provider_utils10.isNonNullable);
1578
+ }).filter(import_provider_utils11.isNonNullable);
1468
1579
  break;
1469
1580
  case "text":
1470
1581
  case "error-text":
@@ -1531,7 +1642,7 @@ async function convertToAnthropicMessagesPrompt({
1531
1642
  }
1532
1643
  case "reasoning": {
1533
1644
  if (sendReasoning) {
1534
- const reasoningMetadata = await (0, import_provider_utils10.parseProviderOptions)({
1645
+ const reasoningMetadata = await (0, import_provider_utils11.parseProviderOptions)({
1535
1646
  provider: "anthropic",
1536
1647
  providerOptions: part.providerOptions,
1537
1648
  schema: anthropicReasoningMetadataSchema
@@ -1622,6 +1733,14 @@ async function convertToAnthropicMessagesPrompt({
1622
1733
  input: part.input,
1623
1734
  cache_control: cacheControl
1624
1735
  });
1736
+ } else if (providerToolName === "tool_search_tool_regex" || providerToolName === "tool_search_tool_bm25") {
1737
+ anthropicContent.push({
1738
+ type: "server_tool_use",
1739
+ id: part.toolCallId,
1740
+ name: providerToolName,
1741
+ input: part.input,
1742
+ cache_control: cacheControl
1743
+ });
1625
1744
  } else {
1626
1745
  warnings.push({
1627
1746
  type: "other",
@@ -1677,7 +1796,7 @@ async function convertToAnthropicMessagesPrompt({
1677
1796
  break;
1678
1797
  }
1679
1798
  if (output.value.type === "code_execution_result") {
1680
- const codeExecutionOutput = await (0, import_provider_utils10.validateTypes)({
1799
+ const codeExecutionOutput = await (0, import_provider_utils11.validateTypes)({
1681
1800
  value: output.value,
1682
1801
  schema: codeExecution_20250522OutputSchema
1683
1802
  });
@@ -1693,7 +1812,7 @@ async function convertToAnthropicMessagesPrompt({
1693
1812
  cache_control: cacheControl
1694
1813
  });
1695
1814
  } else {
1696
- const codeExecutionOutput = await (0, import_provider_utils10.validateTypes)({
1815
+ const codeExecutionOutput = await (0, import_provider_utils11.validateTypes)({
1697
1816
  value: output.value,
1698
1817
  schema: codeExecution_20250825OutputSchema
1699
1818
  });
@@ -1722,7 +1841,7 @@ async function convertToAnthropicMessagesPrompt({
1722
1841
  });
1723
1842
  break;
1724
1843
  }
1725
- const webFetchOutput = await (0, import_provider_utils10.validateTypes)({
1844
+ const webFetchOutput = await (0, import_provider_utils11.validateTypes)({
1726
1845
  value: output.value,
1727
1846
  schema: webFetch_20250910OutputSchema
1728
1847
  });
@@ -1757,7 +1876,7 @@ async function convertToAnthropicMessagesPrompt({
1757
1876
  });
1758
1877
  break;
1759
1878
  }
1760
- const webSearchOutput = await (0, import_provider_utils10.validateTypes)({
1879
+ const webSearchOutput = await (0, import_provider_utils11.validateTypes)({
1761
1880
  value: output.value,
1762
1881
  schema: webSearch_20250305OutputSchema
1763
1882
  });
@@ -1775,6 +1894,34 @@ async function convertToAnthropicMessagesPrompt({
1775
1894
  });
1776
1895
  break;
1777
1896
  }
1897
+ if (providerToolName === "tool_search_tool_regex" || providerToolName === "tool_search_tool_bm25") {
1898
+ const output = part.output;
1899
+ if (output.type !== "json") {
1900
+ warnings.push({
1901
+ type: "other",
1902
+ message: `provider executed tool result output type ${output.type} for tool ${part.toolName} is not supported`
1903
+ });
1904
+ break;
1905
+ }
1906
+ const toolSearchOutput = await (0, import_provider_utils11.validateTypes)({
1907
+ value: output.value,
1908
+ schema: toolSearchRegex_20251119OutputSchema
1909
+ });
1910
+ const toolReferences = toolSearchOutput.map((ref) => ({
1911
+ type: "tool_reference",
1912
+ tool_name: ref.toolName
1913
+ }));
1914
+ anthropicContent.push({
1915
+ type: "tool_search_tool_result",
1916
+ tool_use_id: part.toolCallId,
1917
+ content: {
1918
+ type: "tool_search_tool_search_result",
1919
+ tool_references: toolReferences
1920
+ },
1921
+ cache_control: cacheControl
1922
+ });
1923
+ break;
1924
+ }
1778
1925
  warnings.push({
1779
1926
  type: "other",
1780
1927
  message: `provider executed tool result for tool ${part.toolName} is not supported`
@@ -1902,7 +2049,7 @@ var AnthropicMessagesLanguageModel = class {
1902
2049
  var _a;
1903
2050
  this.modelId = modelId;
1904
2051
  this.config = config;
1905
- this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils11.generateId;
2052
+ this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils12.generateId;
1906
2053
  }
1907
2054
  supportsUrl(url) {
1908
2055
  return url.protocol === "https:";
@@ -1966,7 +2113,7 @@ var AnthropicMessagesLanguageModel = class {
1966
2113
  });
1967
2114
  }
1968
2115
  }
1969
- const anthropicOptions = await (0, import_provider_utils11.parseProviderOptions)({
2116
+ const anthropicOptions = await (0, import_provider_utils12.parseProviderOptions)({
1970
2117
  provider: "anthropic",
1971
2118
  providerOptions,
1972
2119
  schema: anthropicProviderOptions
@@ -1985,7 +2132,7 @@ var AnthropicMessagesLanguageModel = class {
1985
2132
  inputSchema: responseFormat.schema
1986
2133
  } : void 0;
1987
2134
  const cacheControlValidator = new CacheControlValidator();
1988
- const toolNameMapping = (0, import_provider_utils11.createToolNameMapping)({
2135
+ const toolNameMapping = (0, import_provider_utils12.createToolNameMapping)({
1989
2136
  tools,
1990
2137
  providerToolNames: {
1991
2138
  "anthropic.code_execution_20250522": "code_execution",
@@ -2000,7 +2147,9 @@ var AnthropicMessagesLanguageModel = class {
2000
2147
  "anthropic.bash_20250124": "bash",
2001
2148
  "anthropic.memory_20250818": "memory",
2002
2149
  "anthropic.web_search_20250305": "web_search",
2003
- "anthropic.web_fetch_20250910": "web_fetch"
2150
+ "anthropic.web_fetch_20250910": "web_fetch",
2151
+ "anthropic.tool_search_regex_20251119": "tool_search_tool_regex",
2152
+ "anthropic.tool_search_bm25_20251119": "tool_search_tool_bm25"
2004
2153
  }
2005
2154
  });
2006
2155
  const { prompt: messagesPrompt, betas } = await convertToAnthropicMessagesPrompt({
@@ -2170,15 +2319,15 @@ var AnthropicMessagesLanguageModel = class {
2170
2319
  betas,
2171
2320
  headers
2172
2321
  }) {
2173
- return (0, import_provider_utils11.combineHeaders)(
2174
- await (0, import_provider_utils11.resolve)(this.config.headers),
2322
+ return (0, import_provider_utils12.combineHeaders)(
2323
+ await (0, import_provider_utils12.resolve)(this.config.headers),
2175
2324
  headers,
2176
2325
  betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {}
2177
2326
  );
2178
2327
  }
2179
2328
  async getBetasFromHeaders(requestHeaders) {
2180
2329
  var _a, _b;
2181
- const configHeaders = await (0, import_provider_utils11.resolve)(this.config.headers);
2330
+ const configHeaders = await (0, import_provider_utils12.resolve)(this.config.headers);
2182
2331
  const configBetaHeader = (_a = configHeaders["anthropic-beta"]) != null ? _a : "";
2183
2332
  const requestBetaHeader = (_b = requestHeaders == null ? void 0 : requestHeaders["anthropic-beta"]) != null ? _b : "";
2184
2333
  return new Set(
@@ -2231,12 +2380,12 @@ var AnthropicMessagesLanguageModel = class {
2231
2380
  responseHeaders,
2232
2381
  value: response,
2233
2382
  rawValue: rawResponse
2234
- } = await (0, import_provider_utils11.postJsonToApi)({
2383
+ } = await (0, import_provider_utils12.postJsonToApi)({
2235
2384
  url: this.buildRequestUrl(false),
2236
2385
  headers: await this.getHeaders({ betas, headers: options.headers }),
2237
2386
  body: this.transformRequestBody(args),
2238
2387
  failedResponseHandler: anthropicFailedResponseHandler,
2239
- successfulResponseHandler: (0, import_provider_utils11.createJsonResponseHandler)(
2388
+ successfulResponseHandler: (0, import_provider_utils12.createJsonResponseHandler)(
2240
2389
  anthropicMessagesResponseSchema
2241
2390
  ),
2242
2391
  abortSignal: options.abortSignal,
@@ -2324,6 +2473,14 @@ var AnthropicMessagesLanguageModel = class {
2324
2473
  input: JSON.stringify(part.input),
2325
2474
  providerExecuted: true
2326
2475
  });
2476
+ } else if (part.name === "tool_search_tool_regex" || part.name === "tool_search_tool_bm25") {
2477
+ content.push({
2478
+ type: "tool-call",
2479
+ toolCallId: part.id,
2480
+ toolName: toolNameMapping.toCustomToolName(part.name),
2481
+ input: JSON.stringify(part.input),
2482
+ providerExecuted: true
2483
+ });
2327
2484
  }
2328
2485
  break;
2329
2486
  }
@@ -2477,6 +2634,32 @@ var AnthropicMessagesLanguageModel = class {
2477
2634
  });
2478
2635
  break;
2479
2636
  }
2637
+ // tool search tool results:
2638
+ case "tool_search_tool_result": {
2639
+ if (part.content.type === "tool_search_tool_search_result") {
2640
+ content.push({
2641
+ type: "tool-result",
2642
+ toolCallId: part.tool_use_id,
2643
+ toolName: toolNameMapping.toCustomToolName("tool_search"),
2644
+ result: part.content.tool_references.map((ref) => ({
2645
+ type: ref.type,
2646
+ toolName: ref.tool_name
2647
+ }))
2648
+ });
2649
+ } else {
2650
+ content.push({
2651
+ type: "tool-result",
2652
+ toolCallId: part.tool_use_id,
2653
+ toolName: toolNameMapping.toCustomToolName("tool_search"),
2654
+ isError: true,
2655
+ result: {
2656
+ type: "tool_search_tool_result_error",
2657
+ errorCode: part.content.error_code
2658
+ }
2659
+ });
2660
+ }
2661
+ break;
2662
+ }
2480
2663
  }
2481
2664
  }
2482
2665
  return {
@@ -2532,12 +2715,12 @@ var AnthropicMessagesLanguageModel = class {
2532
2715
  });
2533
2716
  const citationDocuments = this.extractCitationDocuments(options.prompt);
2534
2717
  const url = this.buildRequestUrl(true);
2535
- const { responseHeaders, value: response } = await (0, import_provider_utils11.postJsonToApi)({
2718
+ const { responseHeaders, value: response } = await (0, import_provider_utils12.postJsonToApi)({
2536
2719
  url,
2537
2720
  headers: await this.getHeaders({ betas, headers: options.headers }),
2538
2721
  body: this.transformRequestBody(body),
2539
2722
  failedResponseHandler: anthropicFailedResponseHandler,
2540
- successfulResponseHandler: (0, import_provider_utils11.createEventSourceResponseHandler)(
2723
+ successfulResponseHandler: (0, import_provider_utils12.createEventSourceResponseHandler)(
2541
2724
  anthropicMessagesChunkSchema
2542
2725
  ),
2543
2726
  abortSignal: options.abortSignal,
@@ -2667,6 +2850,25 @@ var AnthropicMessagesLanguageModel = class {
2667
2850
  toolName: customToolName,
2668
2851
  providerExecuted: true
2669
2852
  });
2853
+ } else if (part.name === "tool_search_tool_regex" || part.name === "tool_search_tool_bm25") {
2854
+ const customToolName = toolNameMapping.toCustomToolName(
2855
+ part.name
2856
+ );
2857
+ contentBlocks[value.index] = {
2858
+ type: "tool-call",
2859
+ toolCallId: part.id,
2860
+ toolName: customToolName,
2861
+ input: "",
2862
+ providerExecuted: true,
2863
+ firstDelta: true,
2864
+ providerToolName: part.name
2865
+ };
2866
+ controller.enqueue({
2867
+ type: "tool-input-start",
2868
+ id: part.id,
2869
+ toolName: customToolName,
2870
+ providerExecuted: true
2871
+ });
2670
2872
  }
2671
2873
  return;
2672
2874
  }
@@ -2790,6 +2992,32 @@ var AnthropicMessagesLanguageModel = class {
2790
2992
  });
2791
2993
  return;
2792
2994
  }
2995
+ // tool search tool results:
2996
+ case "tool_search_tool_result": {
2997
+ if (part.content.type === "tool_search_tool_search_result") {
2998
+ controller.enqueue({
2999
+ type: "tool-result",
3000
+ toolCallId: part.tool_use_id,
3001
+ toolName: toolNameMapping.toCustomToolName("tool_search"),
3002
+ result: part.content.tool_references.map((ref) => ({
3003
+ type: ref.type,
3004
+ toolName: ref.tool_name
3005
+ }))
3006
+ });
3007
+ } else {
3008
+ controller.enqueue({
3009
+ type: "tool-result",
3010
+ toolCallId: part.tool_use_id,
3011
+ toolName: toolNameMapping.toCustomToolName("tool_search"),
3012
+ isError: true,
3013
+ result: {
3014
+ type: "tool_search_tool_result_error",
3015
+ errorCode: part.content.error_code
3016
+ }
3017
+ });
3018
+ }
3019
+ return;
3020
+ }
2793
3021
  case "mcp_tool_use": {
2794
3022
  mcpToolCalls[part.id] = {
2795
3023
  type: "tool-call",
@@ -3101,44 +3329,44 @@ function getModelCapabilities(modelId) {
3101
3329
  }
3102
3330
 
3103
3331
  // src/tool/bash_20241022.ts
3104
- var import_provider_utils12 = require("@ai-sdk/provider-utils");
3105
- var import_v49 = require("zod/v4");
3106
- var bash_20241022InputSchema = (0, import_provider_utils12.lazySchema)(
3107
- () => (0, import_provider_utils12.zodSchema)(
3108
- import_v49.z.object({
3109
- command: import_v49.z.string(),
3110
- restart: import_v49.z.boolean().optional()
3332
+ var import_provider_utils13 = require("@ai-sdk/provider-utils");
3333
+ var import_v410 = require("zod/v4");
3334
+ var bash_20241022InputSchema = (0, import_provider_utils13.lazySchema)(
3335
+ () => (0, import_provider_utils13.zodSchema)(
3336
+ import_v410.z.object({
3337
+ command: import_v410.z.string(),
3338
+ restart: import_v410.z.boolean().optional()
3111
3339
  })
3112
3340
  )
3113
3341
  );
3114
- var bash_20241022 = (0, import_provider_utils12.createProviderToolFactory)({
3342
+ var bash_20241022 = (0, import_provider_utils13.createProviderToolFactory)({
3115
3343
  id: "anthropic.bash_20241022",
3116
3344
  inputSchema: bash_20241022InputSchema
3117
3345
  });
3118
3346
 
3119
3347
  // src/tool/bash_20250124.ts
3120
- var import_provider_utils13 = require("@ai-sdk/provider-utils");
3121
- var import_v410 = require("zod/v4");
3122
- var bash_20250124InputSchema = (0, import_provider_utils13.lazySchema)(
3123
- () => (0, import_provider_utils13.zodSchema)(
3124
- import_v410.z.object({
3125
- command: import_v410.z.string(),
3126
- restart: import_v410.z.boolean().optional()
3348
+ var import_provider_utils14 = require("@ai-sdk/provider-utils");
3349
+ var import_v411 = require("zod/v4");
3350
+ var bash_20250124InputSchema = (0, import_provider_utils14.lazySchema)(
3351
+ () => (0, import_provider_utils14.zodSchema)(
3352
+ import_v411.z.object({
3353
+ command: import_v411.z.string(),
3354
+ restart: import_v411.z.boolean().optional()
3127
3355
  })
3128
3356
  )
3129
3357
  );
3130
- var bash_20250124 = (0, import_provider_utils13.createProviderToolFactory)({
3358
+ var bash_20250124 = (0, import_provider_utils14.createProviderToolFactory)({
3131
3359
  id: "anthropic.bash_20250124",
3132
3360
  inputSchema: bash_20250124InputSchema
3133
3361
  });
3134
3362
 
3135
3363
  // src/tool/computer_20241022.ts
3136
- var import_provider_utils14 = require("@ai-sdk/provider-utils");
3137
- var import_v411 = require("zod/v4");
3138
- var computer_20241022InputSchema = (0, import_provider_utils14.lazySchema)(
3139
- () => (0, import_provider_utils14.zodSchema)(
3140
- import_v411.z.object({
3141
- action: import_v411.z.enum([
3364
+ var import_provider_utils15 = require("@ai-sdk/provider-utils");
3365
+ var import_v412 = require("zod/v4");
3366
+ var computer_20241022InputSchema = (0, import_provider_utils15.lazySchema)(
3367
+ () => (0, import_provider_utils15.zodSchema)(
3368
+ import_v412.z.object({
3369
+ action: import_v412.z.enum([
3142
3370
  "key",
3143
3371
  "type",
3144
3372
  "mouse_move",
@@ -3150,23 +3378,23 @@ var computer_20241022InputSchema = (0, import_provider_utils14.lazySchema)(
3150
3378
  "screenshot",
3151
3379
  "cursor_position"
3152
3380
  ]),
3153
- coordinate: import_v411.z.array(import_v411.z.number().int()).optional(),
3154
- text: import_v411.z.string().optional()
3381
+ coordinate: import_v412.z.array(import_v412.z.number().int()).optional(),
3382
+ text: import_v412.z.string().optional()
3155
3383
  })
3156
3384
  )
3157
3385
  );
3158
- var computer_20241022 = (0, import_provider_utils14.createProviderToolFactory)({
3386
+ var computer_20241022 = (0, import_provider_utils15.createProviderToolFactory)({
3159
3387
  id: "anthropic.computer_20241022",
3160
3388
  inputSchema: computer_20241022InputSchema
3161
3389
  });
3162
3390
 
3163
3391
  // src/tool/computer_20250124.ts
3164
- var import_provider_utils15 = require("@ai-sdk/provider-utils");
3165
- var import_v412 = require("zod/v4");
3166
- var computer_20250124InputSchema = (0, import_provider_utils15.lazySchema)(
3167
- () => (0, import_provider_utils15.zodSchema)(
3168
- import_v412.z.object({
3169
- action: import_v412.z.enum([
3392
+ var import_provider_utils16 = require("@ai-sdk/provider-utils");
3393
+ var import_v413 = require("zod/v4");
3394
+ var computer_20250124InputSchema = (0, import_provider_utils16.lazySchema)(
3395
+ () => (0, import_provider_utils16.zodSchema)(
3396
+ import_v413.z.object({
3397
+ action: import_v413.z.enum([
3170
3398
  "key",
3171
3399
  "hold_key",
3172
3400
  "type",
@@ -3184,90 +3412,69 @@ var computer_20250124InputSchema = (0, import_provider_utils15.lazySchema)(
3184
3412
  "wait",
3185
3413
  "screenshot"
3186
3414
  ]),
3187
- coordinate: import_v412.z.tuple([import_v412.z.number().int(), import_v412.z.number().int()]).optional(),
3188
- duration: import_v412.z.number().optional(),
3189
- scroll_amount: import_v412.z.number().optional(),
3190
- scroll_direction: import_v412.z.enum(["up", "down", "left", "right"]).optional(),
3191
- start_coordinate: import_v412.z.tuple([import_v412.z.number().int(), import_v412.z.number().int()]).optional(),
3192
- text: import_v412.z.string().optional()
3415
+ coordinate: import_v413.z.tuple([import_v413.z.number().int(), import_v413.z.number().int()]).optional(),
3416
+ duration: import_v413.z.number().optional(),
3417
+ scroll_amount: import_v413.z.number().optional(),
3418
+ scroll_direction: import_v413.z.enum(["up", "down", "left", "right"]).optional(),
3419
+ start_coordinate: import_v413.z.tuple([import_v413.z.number().int(), import_v413.z.number().int()]).optional(),
3420
+ text: import_v413.z.string().optional()
3193
3421
  })
3194
3422
  )
3195
3423
  );
3196
- var computer_20250124 = (0, import_provider_utils15.createProviderToolFactory)({
3424
+ var computer_20250124 = (0, import_provider_utils16.createProviderToolFactory)({
3197
3425
  id: "anthropic.computer_20250124",
3198
3426
  inputSchema: computer_20250124InputSchema
3199
3427
  });
3200
3428
 
3201
3429
  // src/tool/memory_20250818.ts
3202
- var import_provider_utils16 = require("@ai-sdk/provider-utils");
3203
- var import_v413 = require("zod/v4");
3204
- var memory_20250818InputSchema = (0, import_provider_utils16.lazySchema)(
3205
- () => (0, import_provider_utils16.zodSchema)(
3206
- import_v413.z.discriminatedUnion("command", [
3207
- import_v413.z.object({
3208
- command: import_v413.z.literal("view"),
3209
- path: import_v413.z.string(),
3210
- view_range: import_v413.z.tuple([import_v413.z.number(), import_v413.z.number()]).optional()
3430
+ var import_provider_utils17 = require("@ai-sdk/provider-utils");
3431
+ var import_v414 = require("zod/v4");
3432
+ var memory_20250818InputSchema = (0, import_provider_utils17.lazySchema)(
3433
+ () => (0, import_provider_utils17.zodSchema)(
3434
+ import_v414.z.discriminatedUnion("command", [
3435
+ import_v414.z.object({
3436
+ command: import_v414.z.literal("view"),
3437
+ path: import_v414.z.string(),
3438
+ view_range: import_v414.z.tuple([import_v414.z.number(), import_v414.z.number()]).optional()
3211
3439
  }),
3212
- import_v413.z.object({
3213
- command: import_v413.z.literal("create"),
3214
- path: import_v413.z.string(),
3215
- file_text: import_v413.z.string()
3440
+ import_v414.z.object({
3441
+ command: import_v414.z.literal("create"),
3442
+ path: import_v414.z.string(),
3443
+ file_text: import_v414.z.string()
3216
3444
  }),
3217
- import_v413.z.object({
3218
- command: import_v413.z.literal("str_replace"),
3219
- path: import_v413.z.string(),
3220
- old_str: import_v413.z.string(),
3221
- new_str: import_v413.z.string()
3445
+ import_v414.z.object({
3446
+ command: import_v414.z.literal("str_replace"),
3447
+ path: import_v414.z.string(),
3448
+ old_str: import_v414.z.string(),
3449
+ new_str: import_v414.z.string()
3222
3450
  }),
3223
- import_v413.z.object({
3224
- command: import_v413.z.literal("insert"),
3225
- path: import_v413.z.string(),
3226
- insert_line: import_v413.z.number(),
3227
- insert_text: import_v413.z.string()
3451
+ import_v414.z.object({
3452
+ command: import_v414.z.literal("insert"),
3453
+ path: import_v414.z.string(),
3454
+ insert_line: import_v414.z.number(),
3455
+ insert_text: import_v414.z.string()
3228
3456
  }),
3229
- import_v413.z.object({
3230
- command: import_v413.z.literal("delete"),
3231
- path: import_v413.z.string()
3457
+ import_v414.z.object({
3458
+ command: import_v414.z.literal("delete"),
3459
+ path: import_v414.z.string()
3232
3460
  }),
3233
- import_v413.z.object({
3234
- command: import_v413.z.literal("rename"),
3235
- old_path: import_v413.z.string(),
3236
- new_path: import_v413.z.string()
3461
+ import_v414.z.object({
3462
+ command: import_v414.z.literal("rename"),
3463
+ old_path: import_v414.z.string(),
3464
+ new_path: import_v414.z.string()
3237
3465
  })
3238
3466
  ])
3239
3467
  )
3240
3468
  );
3241
- var memory_20250818 = (0, import_provider_utils16.createProviderToolFactory)({
3469
+ var memory_20250818 = (0, import_provider_utils17.createProviderToolFactory)({
3242
3470
  id: "anthropic.memory_20250818",
3243
3471
  inputSchema: memory_20250818InputSchema
3244
3472
  });
3245
3473
 
3246
3474
  // src/tool/text-editor_20241022.ts
3247
- var import_provider_utils17 = require("@ai-sdk/provider-utils");
3248
- var import_v414 = require("zod/v4");
3249
- var textEditor_20241022InputSchema = (0, import_provider_utils17.lazySchema)(
3250
- () => (0, import_provider_utils17.zodSchema)(
3251
- import_v414.z.object({
3252
- command: import_v414.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
3253
- path: import_v414.z.string(),
3254
- file_text: import_v414.z.string().optional(),
3255
- insert_line: import_v414.z.number().int().optional(),
3256
- new_str: import_v414.z.string().optional(),
3257
- old_str: import_v414.z.string().optional(),
3258
- view_range: import_v414.z.array(import_v414.z.number().int()).optional()
3259
- })
3260
- )
3261
- );
3262
- var textEditor_20241022 = (0, import_provider_utils17.createProviderToolFactory)({
3263
- id: "anthropic.text_editor_20241022",
3264
- inputSchema: textEditor_20241022InputSchema
3265
- });
3266
-
3267
- // src/tool/text-editor_20250124.ts
3268
3475
  var import_provider_utils18 = require("@ai-sdk/provider-utils");
3269
3476
  var import_v415 = require("zod/v4");
3270
- var textEditor_20250124InputSchema = (0, import_provider_utils18.lazySchema)(
3477
+ var textEditor_20241022InputSchema = (0, import_provider_utils18.lazySchema)(
3271
3478
  () => (0, import_provider_utils18.zodSchema)(
3272
3479
  import_v415.z.object({
3273
3480
  command: import_v415.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
@@ -3280,18 +3487,18 @@ var textEditor_20250124InputSchema = (0, import_provider_utils18.lazySchema)(
3280
3487
  })
3281
3488
  )
3282
3489
  );
3283
- var textEditor_20250124 = (0, import_provider_utils18.createProviderToolFactory)({
3284
- id: "anthropic.text_editor_20250124",
3285
- inputSchema: textEditor_20250124InputSchema
3490
+ var textEditor_20241022 = (0, import_provider_utils18.createProviderToolFactory)({
3491
+ id: "anthropic.text_editor_20241022",
3492
+ inputSchema: textEditor_20241022InputSchema
3286
3493
  });
3287
3494
 
3288
- // src/tool/text-editor_20250429.ts
3495
+ // src/tool/text-editor_20250124.ts
3289
3496
  var import_provider_utils19 = require("@ai-sdk/provider-utils");
3290
3497
  var import_v416 = require("zod/v4");
3291
- var textEditor_20250429InputSchema = (0, import_provider_utils19.lazySchema)(
3498
+ var textEditor_20250124InputSchema = (0, import_provider_utils19.lazySchema)(
3292
3499
  () => (0, import_provider_utils19.zodSchema)(
3293
3500
  import_v416.z.object({
3294
- command: import_v416.z.enum(["view", "create", "str_replace", "insert"]),
3501
+ command: import_v416.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
3295
3502
  path: import_v416.z.string(),
3296
3503
  file_text: import_v416.z.string().optional(),
3297
3504
  insert_line: import_v416.z.number().int().optional(),
@@ -3301,11 +3508,69 @@ var textEditor_20250429InputSchema = (0, import_provider_utils19.lazySchema)(
3301
3508
  })
3302
3509
  )
3303
3510
  );
3304
- var textEditor_20250429 = (0, import_provider_utils19.createProviderToolFactory)({
3511
+ var textEditor_20250124 = (0, import_provider_utils19.createProviderToolFactory)({
3512
+ id: "anthropic.text_editor_20250124",
3513
+ inputSchema: textEditor_20250124InputSchema
3514
+ });
3515
+
3516
+ // src/tool/text-editor_20250429.ts
3517
+ var import_provider_utils20 = require("@ai-sdk/provider-utils");
3518
+ var import_v417 = require("zod/v4");
3519
+ var textEditor_20250429InputSchema = (0, import_provider_utils20.lazySchema)(
3520
+ () => (0, import_provider_utils20.zodSchema)(
3521
+ import_v417.z.object({
3522
+ command: import_v417.z.enum(["view", "create", "str_replace", "insert"]),
3523
+ path: import_v417.z.string(),
3524
+ file_text: import_v417.z.string().optional(),
3525
+ insert_line: import_v417.z.number().int().optional(),
3526
+ new_str: import_v417.z.string().optional(),
3527
+ old_str: import_v417.z.string().optional(),
3528
+ view_range: import_v417.z.array(import_v417.z.number().int()).optional()
3529
+ })
3530
+ )
3531
+ );
3532
+ var textEditor_20250429 = (0, import_provider_utils20.createProviderToolFactory)({
3305
3533
  id: "anthropic.text_editor_20250429",
3306
3534
  inputSchema: textEditor_20250429InputSchema
3307
3535
  });
3308
3536
 
3537
+ // src/tool/tool-search-bm25_20251119.ts
3538
+ var import_provider_utils21 = require("@ai-sdk/provider-utils");
3539
+ var import_v418 = require("zod/v4");
3540
+ var toolSearchBm25_20251119OutputSchema = (0, import_provider_utils21.lazySchema)(
3541
+ () => (0, import_provider_utils21.zodSchema)(
3542
+ import_v418.z.array(
3543
+ import_v418.z.object({
3544
+ type: import_v418.z.literal("tool_reference"),
3545
+ toolName: import_v418.z.string()
3546
+ })
3547
+ )
3548
+ )
3549
+ );
3550
+ var toolSearchBm25_20251119InputSchema = (0, import_provider_utils21.lazySchema)(
3551
+ () => (0, import_provider_utils21.zodSchema)(
3552
+ import_v418.z.object({
3553
+ /**
3554
+ * A natural language query to search for tools.
3555
+ * Claude will use BM25 text search to find relevant tools.
3556
+ */
3557
+ query: import_v418.z.string(),
3558
+ /**
3559
+ * Maximum number of tools to return. Optional.
3560
+ */
3561
+ limit: import_v418.z.number().optional()
3562
+ })
3563
+ )
3564
+ );
3565
+ var factory7 = (0, import_provider_utils21.createProviderToolFactoryWithOutputSchema)({
3566
+ id: "anthropic.tool_search_bm25_20251119",
3567
+ inputSchema: toolSearchBm25_20251119InputSchema,
3568
+ outputSchema: toolSearchBm25_20251119OutputSchema
3569
+ });
3570
+ var toolSearchBm25_20251119 = (args = {}) => {
3571
+ return factory7(args);
3572
+ };
3573
+
3309
3574
  // src/anthropic-tools.ts
3310
3575
  var anthropicTools = {
3311
3576
  /**
@@ -3429,23 +3694,51 @@ var anthropicTools = {
3429
3694
  * @param blockedDomains - Optional list of domains that Claude should avoid when searching.
3430
3695
  * @param userLocation - Optional user location information to provide geographically relevant search results.
3431
3696
  */
3432
- webSearch_20250305
3697
+ webSearch_20250305,
3698
+ /**
3699
+ * Creates a tool search tool that uses regex patterns to find tools.
3700
+ *
3701
+ * The tool search tool enables Claude to work with hundreds or thousands of tools
3702
+ * by dynamically discovering and loading them on-demand. Instead of loading all
3703
+ * tool definitions into the context window upfront, Claude searches your tool
3704
+ * catalog and loads only the tools it needs.
3705
+ *
3706
+ * Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools
3707
+ * to mark them for deferred loading.
3708
+ *
3709
+ * Supported models: Claude Opus 4.5, Claude Sonnet 4.5
3710
+ */
3711
+ toolSearchRegex_20251119,
3712
+ /**
3713
+ * Creates a tool search tool that uses BM25 (natural language) to find tools.
3714
+ *
3715
+ * The tool search tool enables Claude to work with hundreds or thousands of tools
3716
+ * by dynamically discovering and loading them on-demand. Instead of loading all
3717
+ * tool definitions into the context window upfront, Claude searches your tool
3718
+ * catalog and loads only the tools it needs.
3719
+ *
3720
+ * Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools
3721
+ * to mark them for deferred loading.
3722
+ *
3723
+ * Supported models: Claude Opus 4.5, Claude Sonnet 4.5
3724
+ */
3725
+ toolSearchBm25_20251119
3433
3726
  };
3434
3727
 
3435
3728
  // src/anthropic-provider.ts
3436
3729
  function createAnthropic(options = {}) {
3437
3730
  var _a, _b;
3438
- const baseURL = (_a = (0, import_provider_utils20.withoutTrailingSlash)(
3439
- (0, import_provider_utils20.loadOptionalSetting)({
3731
+ const baseURL = (_a = (0, import_provider_utils22.withoutTrailingSlash)(
3732
+ (0, import_provider_utils22.loadOptionalSetting)({
3440
3733
  settingValue: options.baseURL,
3441
3734
  environmentVariableName: "ANTHROPIC_BASE_URL"
3442
3735
  })
3443
3736
  )) != null ? _a : "https://api.anthropic.com/v1";
3444
3737
  const providerName = (_b = options.name) != null ? _b : "anthropic.messages";
3445
- const getHeaders = () => (0, import_provider_utils20.withUserAgentSuffix)(
3738
+ const getHeaders = () => (0, import_provider_utils22.withUserAgentSuffix)(
3446
3739
  {
3447
3740
  "anthropic-version": "2023-06-01",
3448
- "x-api-key": (0, import_provider_utils20.loadApiKey)({
3741
+ "x-api-key": (0, import_provider_utils22.loadApiKey)({
3449
3742
  apiKey: options.apiKey,
3450
3743
  environmentVariableName: "ANTHROPIC_API_KEY",
3451
3744
  description: "Anthropic"
@@ -3461,7 +3754,7 @@ function createAnthropic(options = {}) {
3461
3754
  baseURL,
3462
3755
  headers: getHeaders,
3463
3756
  fetch: options.fetch,
3464
- generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils20.generateId,
3757
+ generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils22.generateId,
3465
3758
  supportedUrls: () => ({
3466
3759
  "image/*": [/^https?:\/\/.*$/]
3467
3760
  })