@ai-sdk/anthropic 3.0.0-beta.74 → 3.0.0-beta.76

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.74" : "0.0.0-test";
34
+ var VERSION = true ? "3.0.0-beta.76" : "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,12 +915,15 @@ 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
925
  ...supportsStructuredOutput === true && tool.strict != null ? { strict: tool.strict } : {},
926
+ ...deferLoading != null ? { defer_loading: deferLoading } : {},
883
927
  ...tool.inputExamples != null ? {
884
928
  input_examples: tool.inputExamples.map(
885
929
  (example) => example.input
@@ -1034,6 +1078,22 @@ async function prepareTools({
1034
1078
  });
1035
1079
  break;
1036
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
+ }
1037
1097
  default: {
1038
1098
  toolWarnings.push({
1039
1099
  type: "unsupported",
@@ -1107,7 +1167,7 @@ async function prepareTools({
1107
1167
 
1108
1168
  // src/convert-to-anthropic-messages-prompt.ts
1109
1169
  var import_provider2 = require("@ai-sdk/provider");
1110
- var import_provider_utils10 = require("@ai-sdk/provider-utils");
1170
+ var import_provider_utils11 = require("@ai-sdk/provider-utils");
1111
1171
 
1112
1172
  // src/tool/code-execution_20250522.ts
1113
1173
  var import_provider_utils8 = require("@ai-sdk/provider-utils");
@@ -1226,6 +1286,49 @@ var codeExecution_20250825 = (args = {}) => {
1226
1286
  return factory5(args);
1227
1287
  };
1228
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
+
1229
1332
  // src/convert-to-anthropic-messages-prompt.ts
1230
1333
  function convertToString(data) {
1231
1334
  if (typeof data === "string") {
@@ -1258,7 +1361,7 @@ async function convertToAnthropicMessagesPrompt({
1258
1361
  const messages = [];
1259
1362
  async function shouldEnableCitations(providerMetadata) {
1260
1363
  var _a2, _b2;
1261
- const anthropicOptions = await (0, import_provider_utils10.parseProviderOptions)({
1364
+ const anthropicOptions = await (0, import_provider_utils11.parseProviderOptions)({
1262
1365
  provider: "anthropic",
1263
1366
  providerOptions: providerMetadata,
1264
1367
  schema: anthropicFilePartProviderOptions
@@ -1266,7 +1369,7 @@ async function convertToAnthropicMessagesPrompt({
1266
1369
  return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
1267
1370
  }
1268
1371
  async function getDocumentMetadata(providerMetadata) {
1269
- const anthropicOptions = await (0, import_provider_utils10.parseProviderOptions)({
1372
+ const anthropicOptions = await (0, import_provider_utils11.parseProviderOptions)({
1270
1373
  provider: "anthropic",
1271
1374
  providerOptions: providerMetadata,
1272
1375
  schema: anthropicFilePartProviderOptions
@@ -1332,7 +1435,7 @@ async function convertToAnthropicMessagesPrompt({
1332
1435
  } : {
1333
1436
  type: "base64",
1334
1437
  media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
1335
- data: (0, import_provider_utils10.convertToBase64)(part.data)
1438
+ data: (0, import_provider_utils11.convertToBase64)(part.data)
1336
1439
  },
1337
1440
  cache_control: cacheControl
1338
1441
  });
@@ -1352,7 +1455,7 @@ async function convertToAnthropicMessagesPrompt({
1352
1455
  } : {
1353
1456
  type: "base64",
1354
1457
  media_type: "application/pdf",
1355
- data: (0, import_provider_utils10.convertToBase64)(part.data)
1458
+ data: (0, import_provider_utils11.convertToBase64)(part.data)
1356
1459
  },
1357
1460
  title: (_b = metadata.title) != null ? _b : part.filename,
1358
1461
  ...metadata.context && { context: metadata.context },
@@ -1472,7 +1575,7 @@ async function convertToAnthropicMessagesPrompt({
1472
1575
  return void 0;
1473
1576
  }
1474
1577
  }
1475
- }).filter(import_provider_utils10.isNonNullable);
1578
+ }).filter(import_provider_utils11.isNonNullable);
1476
1579
  break;
1477
1580
  case "text":
1478
1581
  case "error-text":
@@ -1539,7 +1642,7 @@ async function convertToAnthropicMessagesPrompt({
1539
1642
  }
1540
1643
  case "reasoning": {
1541
1644
  if (sendReasoning) {
1542
- const reasoningMetadata = await (0, import_provider_utils10.parseProviderOptions)({
1645
+ const reasoningMetadata = await (0, import_provider_utils11.parseProviderOptions)({
1543
1646
  provider: "anthropic",
1544
1647
  providerOptions: part.providerOptions,
1545
1648
  schema: anthropicReasoningMetadataSchema
@@ -1630,6 +1733,14 @@ async function convertToAnthropicMessagesPrompt({
1630
1733
  input: part.input,
1631
1734
  cache_control: cacheControl
1632
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
+ });
1633
1744
  } else {
1634
1745
  warnings.push({
1635
1746
  type: "other",
@@ -1685,7 +1796,7 @@ async function convertToAnthropicMessagesPrompt({
1685
1796
  break;
1686
1797
  }
1687
1798
  if (output.value.type === "code_execution_result") {
1688
- const codeExecutionOutput = await (0, import_provider_utils10.validateTypes)({
1799
+ const codeExecutionOutput = await (0, import_provider_utils11.validateTypes)({
1689
1800
  value: output.value,
1690
1801
  schema: codeExecution_20250522OutputSchema
1691
1802
  });
@@ -1701,7 +1812,7 @@ async function convertToAnthropicMessagesPrompt({
1701
1812
  cache_control: cacheControl
1702
1813
  });
1703
1814
  } else {
1704
- const codeExecutionOutput = await (0, import_provider_utils10.validateTypes)({
1815
+ const codeExecutionOutput = await (0, import_provider_utils11.validateTypes)({
1705
1816
  value: output.value,
1706
1817
  schema: codeExecution_20250825OutputSchema
1707
1818
  });
@@ -1730,7 +1841,7 @@ async function convertToAnthropicMessagesPrompt({
1730
1841
  });
1731
1842
  break;
1732
1843
  }
1733
- const webFetchOutput = await (0, import_provider_utils10.validateTypes)({
1844
+ const webFetchOutput = await (0, import_provider_utils11.validateTypes)({
1734
1845
  value: output.value,
1735
1846
  schema: webFetch_20250910OutputSchema
1736
1847
  });
@@ -1765,7 +1876,7 @@ async function convertToAnthropicMessagesPrompt({
1765
1876
  });
1766
1877
  break;
1767
1878
  }
1768
- const webSearchOutput = await (0, import_provider_utils10.validateTypes)({
1879
+ const webSearchOutput = await (0, import_provider_utils11.validateTypes)({
1769
1880
  value: output.value,
1770
1881
  schema: webSearch_20250305OutputSchema
1771
1882
  });
@@ -1783,6 +1894,34 @@ async function convertToAnthropicMessagesPrompt({
1783
1894
  });
1784
1895
  break;
1785
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
+ }
1786
1925
  warnings.push({
1787
1926
  type: "other",
1788
1927
  message: `provider executed tool result for tool ${part.toolName} is not supported`
@@ -1910,7 +2049,7 @@ var AnthropicMessagesLanguageModel = class {
1910
2049
  var _a;
1911
2050
  this.modelId = modelId;
1912
2051
  this.config = config;
1913
- this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils11.generateId;
2052
+ this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils12.generateId;
1914
2053
  }
1915
2054
  supportsUrl(url) {
1916
2055
  return url.protocol === "https:";
@@ -1974,7 +2113,7 @@ var AnthropicMessagesLanguageModel = class {
1974
2113
  });
1975
2114
  }
1976
2115
  }
1977
- const anthropicOptions = await (0, import_provider_utils11.parseProviderOptions)({
2116
+ const anthropicOptions = await (0, import_provider_utils12.parseProviderOptions)({
1978
2117
  provider: "anthropic",
1979
2118
  providerOptions,
1980
2119
  schema: anthropicProviderOptions
@@ -1993,7 +2132,7 @@ var AnthropicMessagesLanguageModel = class {
1993
2132
  inputSchema: responseFormat.schema
1994
2133
  } : void 0;
1995
2134
  const cacheControlValidator = new CacheControlValidator();
1996
- const toolNameMapping = (0, import_provider_utils11.createToolNameMapping)({
2135
+ const toolNameMapping = (0, import_provider_utils12.createToolNameMapping)({
1997
2136
  tools,
1998
2137
  providerToolNames: {
1999
2138
  "anthropic.code_execution_20250522": "code_execution",
@@ -2008,7 +2147,9 @@ var AnthropicMessagesLanguageModel = class {
2008
2147
  "anthropic.bash_20250124": "bash",
2009
2148
  "anthropic.memory_20250818": "memory",
2010
2149
  "anthropic.web_search_20250305": "web_search",
2011
- "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"
2012
2153
  }
2013
2154
  });
2014
2155
  const { prompt: messagesPrompt, betas } = await convertToAnthropicMessagesPrompt({
@@ -2178,15 +2319,15 @@ var AnthropicMessagesLanguageModel = class {
2178
2319
  betas,
2179
2320
  headers
2180
2321
  }) {
2181
- return (0, import_provider_utils11.combineHeaders)(
2182
- 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),
2183
2324
  headers,
2184
2325
  betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {}
2185
2326
  );
2186
2327
  }
2187
2328
  async getBetasFromHeaders(requestHeaders) {
2188
2329
  var _a, _b;
2189
- const configHeaders = await (0, import_provider_utils11.resolve)(this.config.headers);
2330
+ const configHeaders = await (0, import_provider_utils12.resolve)(this.config.headers);
2190
2331
  const configBetaHeader = (_a = configHeaders["anthropic-beta"]) != null ? _a : "";
2191
2332
  const requestBetaHeader = (_b = requestHeaders == null ? void 0 : requestHeaders["anthropic-beta"]) != null ? _b : "";
2192
2333
  return new Set(
@@ -2239,12 +2380,12 @@ var AnthropicMessagesLanguageModel = class {
2239
2380
  responseHeaders,
2240
2381
  value: response,
2241
2382
  rawValue: rawResponse
2242
- } = await (0, import_provider_utils11.postJsonToApi)({
2383
+ } = await (0, import_provider_utils12.postJsonToApi)({
2243
2384
  url: this.buildRequestUrl(false),
2244
2385
  headers: await this.getHeaders({ betas, headers: options.headers }),
2245
2386
  body: this.transformRequestBody(args),
2246
2387
  failedResponseHandler: anthropicFailedResponseHandler,
2247
- successfulResponseHandler: (0, import_provider_utils11.createJsonResponseHandler)(
2388
+ successfulResponseHandler: (0, import_provider_utils12.createJsonResponseHandler)(
2248
2389
  anthropicMessagesResponseSchema
2249
2390
  ),
2250
2391
  abortSignal: options.abortSignal,
@@ -2332,6 +2473,14 @@ var AnthropicMessagesLanguageModel = class {
2332
2473
  input: JSON.stringify(part.input),
2333
2474
  providerExecuted: true
2334
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
+ });
2335
2484
  }
2336
2485
  break;
2337
2486
  }
@@ -2485,6 +2634,32 @@ var AnthropicMessagesLanguageModel = class {
2485
2634
  });
2486
2635
  break;
2487
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
+ }
2488
2663
  }
2489
2664
  }
2490
2665
  return {
@@ -2540,12 +2715,12 @@ var AnthropicMessagesLanguageModel = class {
2540
2715
  });
2541
2716
  const citationDocuments = this.extractCitationDocuments(options.prompt);
2542
2717
  const url = this.buildRequestUrl(true);
2543
- const { responseHeaders, value: response } = await (0, import_provider_utils11.postJsonToApi)({
2718
+ const { responseHeaders, value: response } = await (0, import_provider_utils12.postJsonToApi)({
2544
2719
  url,
2545
2720
  headers: await this.getHeaders({ betas, headers: options.headers }),
2546
2721
  body: this.transformRequestBody(body),
2547
2722
  failedResponseHandler: anthropicFailedResponseHandler,
2548
- successfulResponseHandler: (0, import_provider_utils11.createEventSourceResponseHandler)(
2723
+ successfulResponseHandler: (0, import_provider_utils12.createEventSourceResponseHandler)(
2549
2724
  anthropicMessagesChunkSchema
2550
2725
  ),
2551
2726
  abortSignal: options.abortSignal,
@@ -2675,6 +2850,25 @@ var AnthropicMessagesLanguageModel = class {
2675
2850
  toolName: customToolName,
2676
2851
  providerExecuted: true
2677
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
+ });
2678
2872
  }
2679
2873
  return;
2680
2874
  }
@@ -2798,6 +2992,32 @@ var AnthropicMessagesLanguageModel = class {
2798
2992
  });
2799
2993
  return;
2800
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
+ }
2801
3021
  case "mcp_tool_use": {
2802
3022
  mcpToolCalls[part.id] = {
2803
3023
  type: "tool-call",
@@ -3109,44 +3329,44 @@ function getModelCapabilities(modelId) {
3109
3329
  }
3110
3330
 
3111
3331
  // src/tool/bash_20241022.ts
3112
- var import_provider_utils12 = require("@ai-sdk/provider-utils");
3113
- var import_v49 = require("zod/v4");
3114
- var bash_20241022InputSchema = (0, import_provider_utils12.lazySchema)(
3115
- () => (0, import_provider_utils12.zodSchema)(
3116
- import_v49.z.object({
3117
- command: import_v49.z.string(),
3118
- 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()
3119
3339
  })
3120
3340
  )
3121
3341
  );
3122
- var bash_20241022 = (0, import_provider_utils12.createProviderToolFactory)({
3342
+ var bash_20241022 = (0, import_provider_utils13.createProviderToolFactory)({
3123
3343
  id: "anthropic.bash_20241022",
3124
3344
  inputSchema: bash_20241022InputSchema
3125
3345
  });
3126
3346
 
3127
3347
  // src/tool/bash_20250124.ts
3128
- var import_provider_utils13 = require("@ai-sdk/provider-utils");
3129
- var import_v410 = require("zod/v4");
3130
- var bash_20250124InputSchema = (0, import_provider_utils13.lazySchema)(
3131
- () => (0, import_provider_utils13.zodSchema)(
3132
- import_v410.z.object({
3133
- command: import_v410.z.string(),
3134
- 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()
3135
3355
  })
3136
3356
  )
3137
3357
  );
3138
- var bash_20250124 = (0, import_provider_utils13.createProviderToolFactory)({
3358
+ var bash_20250124 = (0, import_provider_utils14.createProviderToolFactory)({
3139
3359
  id: "anthropic.bash_20250124",
3140
3360
  inputSchema: bash_20250124InputSchema
3141
3361
  });
3142
3362
 
3143
3363
  // src/tool/computer_20241022.ts
3144
- var import_provider_utils14 = require("@ai-sdk/provider-utils");
3145
- var import_v411 = require("zod/v4");
3146
- var computer_20241022InputSchema = (0, import_provider_utils14.lazySchema)(
3147
- () => (0, import_provider_utils14.zodSchema)(
3148
- import_v411.z.object({
3149
- 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([
3150
3370
  "key",
3151
3371
  "type",
3152
3372
  "mouse_move",
@@ -3158,23 +3378,23 @@ var computer_20241022InputSchema = (0, import_provider_utils14.lazySchema)(
3158
3378
  "screenshot",
3159
3379
  "cursor_position"
3160
3380
  ]),
3161
- coordinate: import_v411.z.array(import_v411.z.number().int()).optional(),
3162
- 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()
3163
3383
  })
3164
3384
  )
3165
3385
  );
3166
- var computer_20241022 = (0, import_provider_utils14.createProviderToolFactory)({
3386
+ var computer_20241022 = (0, import_provider_utils15.createProviderToolFactory)({
3167
3387
  id: "anthropic.computer_20241022",
3168
3388
  inputSchema: computer_20241022InputSchema
3169
3389
  });
3170
3390
 
3171
3391
  // src/tool/computer_20250124.ts
3172
- var import_provider_utils15 = require("@ai-sdk/provider-utils");
3173
- var import_v412 = require("zod/v4");
3174
- var computer_20250124InputSchema = (0, import_provider_utils15.lazySchema)(
3175
- () => (0, import_provider_utils15.zodSchema)(
3176
- import_v412.z.object({
3177
- 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([
3178
3398
  "key",
3179
3399
  "hold_key",
3180
3400
  "type",
@@ -3192,90 +3412,69 @@ var computer_20250124InputSchema = (0, import_provider_utils15.lazySchema)(
3192
3412
  "wait",
3193
3413
  "screenshot"
3194
3414
  ]),
3195
- coordinate: import_v412.z.tuple([import_v412.z.number().int(), import_v412.z.number().int()]).optional(),
3196
- duration: import_v412.z.number().optional(),
3197
- scroll_amount: import_v412.z.number().optional(),
3198
- scroll_direction: import_v412.z.enum(["up", "down", "left", "right"]).optional(),
3199
- start_coordinate: import_v412.z.tuple([import_v412.z.number().int(), import_v412.z.number().int()]).optional(),
3200
- 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()
3201
3421
  })
3202
3422
  )
3203
3423
  );
3204
- var computer_20250124 = (0, import_provider_utils15.createProviderToolFactory)({
3424
+ var computer_20250124 = (0, import_provider_utils16.createProviderToolFactory)({
3205
3425
  id: "anthropic.computer_20250124",
3206
3426
  inputSchema: computer_20250124InputSchema
3207
3427
  });
3208
3428
 
3209
3429
  // src/tool/memory_20250818.ts
3210
- var import_provider_utils16 = require("@ai-sdk/provider-utils");
3211
- var import_v413 = require("zod/v4");
3212
- var memory_20250818InputSchema = (0, import_provider_utils16.lazySchema)(
3213
- () => (0, import_provider_utils16.zodSchema)(
3214
- import_v413.z.discriminatedUnion("command", [
3215
- import_v413.z.object({
3216
- command: import_v413.z.literal("view"),
3217
- path: import_v413.z.string(),
3218
- 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()
3219
3439
  }),
3220
- import_v413.z.object({
3221
- command: import_v413.z.literal("create"),
3222
- path: import_v413.z.string(),
3223
- 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()
3224
3444
  }),
3225
- import_v413.z.object({
3226
- command: import_v413.z.literal("str_replace"),
3227
- path: import_v413.z.string(),
3228
- old_str: import_v413.z.string(),
3229
- 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()
3230
3450
  }),
3231
- import_v413.z.object({
3232
- command: import_v413.z.literal("insert"),
3233
- path: import_v413.z.string(),
3234
- insert_line: import_v413.z.number(),
3235
- 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()
3236
3456
  }),
3237
- import_v413.z.object({
3238
- command: import_v413.z.literal("delete"),
3239
- path: import_v413.z.string()
3457
+ import_v414.z.object({
3458
+ command: import_v414.z.literal("delete"),
3459
+ path: import_v414.z.string()
3240
3460
  }),
3241
- import_v413.z.object({
3242
- command: import_v413.z.literal("rename"),
3243
- old_path: import_v413.z.string(),
3244
- 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()
3245
3465
  })
3246
3466
  ])
3247
3467
  )
3248
3468
  );
3249
- var memory_20250818 = (0, import_provider_utils16.createProviderToolFactory)({
3469
+ var memory_20250818 = (0, import_provider_utils17.createProviderToolFactory)({
3250
3470
  id: "anthropic.memory_20250818",
3251
3471
  inputSchema: memory_20250818InputSchema
3252
3472
  });
3253
3473
 
3254
3474
  // src/tool/text-editor_20241022.ts
3255
- var import_provider_utils17 = require("@ai-sdk/provider-utils");
3256
- var import_v414 = require("zod/v4");
3257
- var textEditor_20241022InputSchema = (0, import_provider_utils17.lazySchema)(
3258
- () => (0, import_provider_utils17.zodSchema)(
3259
- import_v414.z.object({
3260
- command: import_v414.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
3261
- path: import_v414.z.string(),
3262
- file_text: import_v414.z.string().optional(),
3263
- insert_line: import_v414.z.number().int().optional(),
3264
- new_str: import_v414.z.string().optional(),
3265
- old_str: import_v414.z.string().optional(),
3266
- view_range: import_v414.z.array(import_v414.z.number().int()).optional()
3267
- })
3268
- )
3269
- );
3270
- var textEditor_20241022 = (0, import_provider_utils17.createProviderToolFactory)({
3271
- id: "anthropic.text_editor_20241022",
3272
- inputSchema: textEditor_20241022InputSchema
3273
- });
3274
-
3275
- // src/tool/text-editor_20250124.ts
3276
3475
  var import_provider_utils18 = require("@ai-sdk/provider-utils");
3277
3476
  var import_v415 = require("zod/v4");
3278
- var textEditor_20250124InputSchema = (0, import_provider_utils18.lazySchema)(
3477
+ var textEditor_20241022InputSchema = (0, import_provider_utils18.lazySchema)(
3279
3478
  () => (0, import_provider_utils18.zodSchema)(
3280
3479
  import_v415.z.object({
3281
3480
  command: import_v415.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
@@ -3288,18 +3487,18 @@ var textEditor_20250124InputSchema = (0, import_provider_utils18.lazySchema)(
3288
3487
  })
3289
3488
  )
3290
3489
  );
3291
- var textEditor_20250124 = (0, import_provider_utils18.createProviderToolFactory)({
3292
- id: "anthropic.text_editor_20250124",
3293
- inputSchema: textEditor_20250124InputSchema
3490
+ var textEditor_20241022 = (0, import_provider_utils18.createProviderToolFactory)({
3491
+ id: "anthropic.text_editor_20241022",
3492
+ inputSchema: textEditor_20241022InputSchema
3294
3493
  });
3295
3494
 
3296
- // src/tool/text-editor_20250429.ts
3495
+ // src/tool/text-editor_20250124.ts
3297
3496
  var import_provider_utils19 = require("@ai-sdk/provider-utils");
3298
3497
  var import_v416 = require("zod/v4");
3299
- var textEditor_20250429InputSchema = (0, import_provider_utils19.lazySchema)(
3498
+ var textEditor_20250124InputSchema = (0, import_provider_utils19.lazySchema)(
3300
3499
  () => (0, import_provider_utils19.zodSchema)(
3301
3500
  import_v416.z.object({
3302
- command: import_v416.z.enum(["view", "create", "str_replace", "insert"]),
3501
+ command: import_v416.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
3303
3502
  path: import_v416.z.string(),
3304
3503
  file_text: import_v416.z.string().optional(),
3305
3504
  insert_line: import_v416.z.number().int().optional(),
@@ -3309,11 +3508,69 @@ var textEditor_20250429InputSchema = (0, import_provider_utils19.lazySchema)(
3309
3508
  })
3310
3509
  )
3311
3510
  );
3312
- 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)({
3313
3533
  id: "anthropic.text_editor_20250429",
3314
3534
  inputSchema: textEditor_20250429InputSchema
3315
3535
  });
3316
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
+
3317
3574
  // src/anthropic-tools.ts
3318
3575
  var anthropicTools = {
3319
3576
  /**
@@ -3437,23 +3694,51 @@ var anthropicTools = {
3437
3694
  * @param blockedDomains - Optional list of domains that Claude should avoid when searching.
3438
3695
  * @param userLocation - Optional user location information to provide geographically relevant search results.
3439
3696
  */
3440
- 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
3441
3726
  };
3442
3727
 
3443
3728
  // src/anthropic-provider.ts
3444
3729
  function createAnthropic(options = {}) {
3445
3730
  var _a, _b;
3446
- const baseURL = (_a = (0, import_provider_utils20.withoutTrailingSlash)(
3447
- (0, import_provider_utils20.loadOptionalSetting)({
3731
+ const baseURL = (_a = (0, import_provider_utils22.withoutTrailingSlash)(
3732
+ (0, import_provider_utils22.loadOptionalSetting)({
3448
3733
  settingValue: options.baseURL,
3449
3734
  environmentVariableName: "ANTHROPIC_BASE_URL"
3450
3735
  })
3451
3736
  )) != null ? _a : "https://api.anthropic.com/v1";
3452
3737
  const providerName = (_b = options.name) != null ? _b : "anthropic.messages";
3453
- const getHeaders = () => (0, import_provider_utils20.withUserAgentSuffix)(
3738
+ const getHeaders = () => (0, import_provider_utils22.withUserAgentSuffix)(
3454
3739
  {
3455
3740
  "anthropic-version": "2023-06-01",
3456
- "x-api-key": (0, import_provider_utils20.loadApiKey)({
3741
+ "x-api-key": (0, import_provider_utils22.loadApiKey)({
3457
3742
  apiKey: options.apiKey,
3458
3743
  environmentVariableName: "ANTHROPIC_API_KEY",
3459
3744
  description: "Anthropic"
@@ -3469,7 +3754,7 @@ function createAnthropic(options = {}) {
3469
3754
  baseURL,
3470
3755
  headers: getHeaders,
3471
3756
  fetch: options.fetch,
3472
- generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils20.generateId,
3757
+ generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils22.generateId,
3473
3758
  supportedUrls: () => ({
3474
3759
  "image/*": [/^https?:\/\/.*$/]
3475
3760
  })