@ai-sdk/anthropic 2.0.0-beta.1 → 2.0.0-beta.11

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.
@@ -38,16 +38,16 @@ module.exports = __toCommonJS(internal_exports);
38
38
  // src/anthropic-messages-language-model.ts
39
39
  var import_provider3 = require("@ai-sdk/provider");
40
40
  var import_provider_utils4 = require("@ai-sdk/provider-utils");
41
- var import_zod3 = require("zod");
41
+ var import_v44 = require("zod/v4");
42
42
 
43
43
  // src/anthropic-error.ts
44
44
  var import_provider_utils = require("@ai-sdk/provider-utils");
45
- var import_zod = require("zod");
46
- var anthropicErrorDataSchema = import_zod.z.object({
47
- type: import_zod.z.literal("error"),
48
- error: import_zod.z.object({
49
- type: import_zod.z.string(),
50
- message: import_zod.z.string()
45
+ var import_v4 = require("zod/v4");
46
+ var anthropicErrorDataSchema = import_v4.z.object({
47
+ type: import_v4.z.literal("error"),
48
+ error: import_v4.z.object({
49
+ type: import_v4.z.string(),
50
+ message: import_v4.z.string()
51
51
  })
52
52
  });
53
53
  var anthropicFailedResponseHandler = (0, import_provider_utils.createJsonErrorResponseHandler)({
@@ -56,82 +56,95 @@ var anthropicFailedResponseHandler = (0, import_provider_utils.createJsonErrorRe
56
56
  });
57
57
 
58
58
  // src/anthropic-messages-options.ts
59
- var import_zod2 = require("zod");
60
- var anthropicFilePartProviderOptions = import_zod2.z.object({
59
+ var import_v42 = require("zod/v4");
60
+ var anthropicFilePartProviderOptions = import_v42.z.object({
61
61
  /**
62
62
  * Citation configuration for this document.
63
63
  * When enabled, this document will generate citations in the response.
64
64
  */
65
- citations: import_zod2.z.object({
65
+ citations: import_v42.z.object({
66
66
  /**
67
67
  * Enable citations for this document
68
68
  */
69
- enabled: import_zod2.z.boolean()
69
+ enabled: import_v42.z.boolean()
70
70
  }).optional(),
71
71
  /**
72
72
  * Custom title for the document.
73
73
  * If not provided, the filename will be used.
74
74
  */
75
- title: import_zod2.z.string().optional(),
75
+ title: import_v42.z.string().optional(),
76
76
  /**
77
77
  * Context about the document that will be passed to the model
78
78
  * but not used towards cited content.
79
79
  * Useful for storing document metadata as text or stringified JSON.
80
80
  */
81
- context: import_zod2.z.string().optional()
81
+ context: import_v42.z.string().optional()
82
82
  });
83
- var anthropicProviderOptions = import_zod2.z.object({
84
- sendReasoning: import_zod2.z.boolean().optional(),
85
- thinking: import_zod2.z.object({
86
- type: import_zod2.z.union([import_zod2.z.literal("enabled"), import_zod2.z.literal("disabled")]),
87
- budgetTokens: import_zod2.z.number().optional()
88
- }).optional()
83
+ var anthropicProviderOptions = import_v42.z.object({
84
+ sendReasoning: import_v42.z.boolean().optional(),
85
+ thinking: import_v42.z.object({
86
+ type: import_v42.z.union([import_v42.z.literal("enabled"), import_v42.z.literal("disabled")]),
87
+ budgetTokens: import_v42.z.number().optional()
88
+ }).optional(),
89
+ /**
90
+ * Whether to disable parallel function calling during tool use. Default is false.
91
+ * When set to true, Claude will use at most one tool per response.
92
+ */
93
+ disableParallelToolUse: import_v42.z.boolean().optional()
89
94
  });
90
95
 
91
96
  // src/anthropic-prepare-tools.ts
92
97
  var import_provider = require("@ai-sdk/provider");
93
98
 
99
+ // src/get-cache-control.ts
100
+ function getCacheControl(providerMetadata) {
101
+ var _a;
102
+ const anthropic = providerMetadata == null ? void 0 : providerMetadata.anthropic;
103
+ const cacheControlValue = (_a = anthropic == null ? void 0 : anthropic.cacheControl) != null ? _a : anthropic == null ? void 0 : anthropic.cache_control;
104
+ return cacheControlValue;
105
+ }
106
+
94
107
  // src/tool/web-search_20250305.ts
95
108
  var import_provider_utils2 = require("@ai-sdk/provider-utils");
96
- var import_v4 = require("zod/v4");
97
- var webSearch_20250305ArgsSchema = import_v4.z.object({
109
+ var import_v43 = require("zod/v4");
110
+ var webSearch_20250305ArgsSchema = import_v43.z.object({
98
111
  /**
99
112
  * Maximum number of web searches Claude can perform during the conversation.
100
113
  */
101
- maxUses: import_v4.z.number().optional(),
114
+ maxUses: import_v43.z.number().optional(),
102
115
  /**
103
116
  * Optional list of domains that Claude is allowed to search.
104
117
  */
105
- allowedDomains: import_v4.z.array(import_v4.z.string()).optional(),
118
+ allowedDomains: import_v43.z.array(import_v43.z.string()).optional(),
106
119
  /**
107
120
  * Optional list of domains that Claude should avoid when searching.
108
121
  */
109
- blockedDomains: import_v4.z.array(import_v4.z.string()).optional(),
122
+ blockedDomains: import_v43.z.array(import_v43.z.string()).optional(),
110
123
  /**
111
124
  * Optional user location information to provide geographically relevant search results.
112
125
  */
113
- userLocation: import_v4.z.object({
114
- type: import_v4.z.literal("approximate"),
115
- city: import_v4.z.string().optional(),
116
- region: import_v4.z.string().optional(),
117
- country: import_v4.z.string().optional(),
118
- timezone: import_v4.z.string().optional()
126
+ userLocation: import_v43.z.object({
127
+ type: import_v43.z.literal("approximate"),
128
+ city: import_v43.z.string().optional(),
129
+ region: import_v43.z.string().optional(),
130
+ country: import_v43.z.string().optional(),
131
+ timezone: import_v43.z.string().optional()
119
132
  }).optional()
120
133
  });
121
- var webSearch_20250305OutputSchema = import_v4.z.array(
122
- import_v4.z.object({
123
- url: import_v4.z.string(),
124
- title: import_v4.z.string(),
125
- pageAge: import_v4.z.string().nullable(),
126
- encryptedContent: import_v4.z.string(),
127
- type: import_v4.z.string()
134
+ var webSearch_20250305OutputSchema = import_v43.z.array(
135
+ import_v43.z.object({
136
+ url: import_v43.z.string(),
137
+ title: import_v43.z.string(),
138
+ pageAge: import_v43.z.string().nullable(),
139
+ encryptedContent: import_v43.z.string(),
140
+ type: import_v43.z.string()
128
141
  })
129
142
  );
130
143
  var factory = (0, import_provider_utils2.createProviderDefinedToolFactoryWithOutputSchema)({
131
144
  id: "anthropic.web_search_20250305",
132
145
  name: "web_search",
133
- inputSchema: import_v4.z.object({
134
- query: import_v4.z.string()
146
+ inputSchema: import_v43.z.object({
147
+ query: import_v43.z.string()
135
148
  }),
136
149
  outputSchema: webSearch_20250305OutputSchema
137
150
  });
@@ -145,7 +158,8 @@ function isWebSearchTool(tool) {
145
158
  }
146
159
  function prepareTools({
147
160
  tools,
148
- toolChoice
161
+ toolChoice,
162
+ disableParallelToolUse
149
163
  }) {
150
164
  tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
151
165
  const toolWarnings = [];
@@ -161,10 +175,12 @@ function prepareTools({
161
175
  }
162
176
  switch (tool.type) {
163
177
  case "function":
178
+ const cacheControl = getCacheControl(tool.providerOptions);
164
179
  anthropicTools2.push({
165
180
  name: tool.name,
166
181
  description: tool.description,
167
- input_schema: tool.inputSchema
182
+ input_schema: tool.inputSchema,
183
+ cache_control: cacheControl
168
184
  });
169
185
  break;
170
186
  case "provider-defined":
@@ -203,6 +219,13 @@ function prepareTools({
203
219
  type: "text_editor_20241022"
204
220
  });
205
221
  break;
222
+ case "anthropic.text_editor_20250429":
223
+ betas.add("computer-use-2025-01-24");
224
+ anthropicTools2.push({
225
+ name: "str_replace_based_edit_tool",
226
+ type: "text_editor_20250429"
227
+ });
228
+ break;
206
229
  case "anthropic.bash_20250124":
207
230
  betas.add("computer-use-2025-01-24");
208
231
  anthropicTools2.push({
@@ -242,7 +265,7 @@ function prepareTools({
242
265
  if (toolChoice == null) {
243
266
  return {
244
267
  tools: anthropicTools2,
245
- toolChoice: void 0,
268
+ toolChoice: disableParallelToolUse ? { type: "auto", disable_parallel_tool_use: disableParallelToolUse } : void 0,
246
269
  toolWarnings,
247
270
  betas
248
271
  };
@@ -252,14 +275,20 @@ function prepareTools({
252
275
  case "auto":
253
276
  return {
254
277
  tools: anthropicTools2,
255
- toolChoice: { type: "auto" },
278
+ toolChoice: {
279
+ type: "auto",
280
+ disable_parallel_tool_use: disableParallelToolUse
281
+ },
256
282
  toolWarnings,
257
283
  betas
258
284
  };
259
285
  case "required":
260
286
  return {
261
287
  tools: anthropicTools2,
262
- toolChoice: { type: "any" },
288
+ toolChoice: {
289
+ type: "any",
290
+ disable_parallel_tool_use: disableParallelToolUse
291
+ },
263
292
  toolWarnings,
264
293
  betas
265
294
  };
@@ -268,7 +297,11 @@ function prepareTools({
268
297
  case "tool":
269
298
  return {
270
299
  tools: anthropicTools2,
271
- toolChoice: { type: "tool", name: toolChoice.toolName },
300
+ toolChoice: {
301
+ type: "tool",
302
+ name: toolChoice.toolName,
303
+ disable_parallel_tool_use: disableParallelToolUse
304
+ },
272
305
  toolWarnings,
273
306
  betas
274
307
  };
@@ -310,12 +343,6 @@ async function convertToAnthropicMessagesPrompt({
310
343
  const blocks = groupIntoBlocks(prompt);
311
344
  let system = void 0;
312
345
  const messages = [];
313
- function getCacheControl(providerMetadata) {
314
- var _a2;
315
- const anthropic = providerMetadata == null ? void 0 : providerMetadata.anthropic;
316
- const cacheControlValue = (_a2 = anthropic == null ? void 0 : anthropic.cacheControl) != null ? _a2 : anthropic == null ? void 0 : anthropic.cache_control;
317
- return cacheControlValue;
318
- }
319
346
  async function shouldEnableCitations(providerMetadata) {
320
347
  var _a2, _b2;
321
348
  const anthropicOptions = await (0, import_provider_utils3.parseProviderOptions)({
@@ -721,36 +748,36 @@ function mapAnthropicStopReason({
721
748
 
722
749
  // src/anthropic-messages-language-model.ts
723
750
  var citationSchemas = {
724
- webSearchResult: import_zod3.z.object({
725
- type: import_zod3.z.literal("web_search_result_location"),
726
- cited_text: import_zod3.z.string(),
727
- url: import_zod3.z.string(),
728
- title: import_zod3.z.string(),
729
- encrypted_index: import_zod3.z.string()
751
+ webSearchResult: import_v44.z.object({
752
+ type: import_v44.z.literal("web_search_result_location"),
753
+ cited_text: import_v44.z.string(),
754
+ url: import_v44.z.string(),
755
+ title: import_v44.z.string(),
756
+ encrypted_index: import_v44.z.string()
730
757
  }),
731
- pageLocation: import_zod3.z.object({
732
- type: import_zod3.z.literal("page_location"),
733
- cited_text: import_zod3.z.string(),
734
- document_index: import_zod3.z.number(),
735
- document_title: import_zod3.z.string().nullable(),
736
- start_page_number: import_zod3.z.number(),
737
- end_page_number: import_zod3.z.number()
758
+ pageLocation: import_v44.z.object({
759
+ type: import_v44.z.literal("page_location"),
760
+ cited_text: import_v44.z.string(),
761
+ document_index: import_v44.z.number(),
762
+ document_title: import_v44.z.string().nullable(),
763
+ start_page_number: import_v44.z.number(),
764
+ end_page_number: import_v44.z.number()
738
765
  }),
739
- charLocation: import_zod3.z.object({
740
- type: import_zod3.z.literal("char_location"),
741
- cited_text: import_zod3.z.string(),
742
- document_index: import_zod3.z.number(),
743
- document_title: import_zod3.z.string().nullable(),
744
- start_char_index: import_zod3.z.number(),
745
- end_char_index: import_zod3.z.number()
766
+ charLocation: import_v44.z.object({
767
+ type: import_v44.z.literal("char_location"),
768
+ cited_text: import_v44.z.string(),
769
+ document_index: import_v44.z.number(),
770
+ document_title: import_v44.z.string().nullable(),
771
+ start_char_index: import_v44.z.number(),
772
+ end_char_index: import_v44.z.number()
746
773
  })
747
774
  };
748
- var citationSchema = import_zod3.z.discriminatedUnion("type", [
775
+ var citationSchema = import_v44.z.discriminatedUnion("type", [
749
776
  citationSchemas.webSearchResult,
750
777
  citationSchemas.pageLocation,
751
778
  citationSchemas.charLocation
752
779
  ]);
753
- var documentCitationSchema = import_zod3.z.discriminatedUnion("type", [
780
+ var documentCitationSchema = import_v44.z.discriminatedUnion("type", [
754
781
  citationSchemas.pageLocation,
755
782
  citationSchemas.charLocation
756
783
  ]);
@@ -937,8 +964,13 @@ var AnthropicMessagesLanguageModel = class {
937
964
  } = prepareTools(
938
965
  jsonResponseTool != null ? {
939
966
  tools: [jsonResponseTool],
940
- toolChoice: { type: "tool", toolName: jsonResponseTool.name }
941
- } : { tools: tools != null ? tools : [], toolChoice }
967
+ toolChoice: { type: "tool", toolName: jsonResponseTool.name },
968
+ disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse
969
+ } : {
970
+ tools: tools != null ? tools : [],
971
+ toolChoice,
972
+ disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse
973
+ }
942
974
  );
943
975
  return {
944
976
  args: {
@@ -948,7 +980,7 @@ var AnthropicMessagesLanguageModel = class {
948
980
  },
949
981
  warnings: [...warnings, ...toolWarnings],
950
982
  betas: /* @__PURE__ */ new Set([...messagesBetas, ...toolsBetas]),
951
- jsonResponseTool
983
+ usesJsonResponseTool: jsonResponseTool != null
952
984
  };
953
985
  }
954
986
  async getHeaders({
@@ -994,7 +1026,7 @@ var AnthropicMessagesLanguageModel = class {
994
1026
  }
995
1027
  async doGenerate(options) {
996
1028
  var _a, _b, _c, _d, _e;
997
- const { args, warnings, betas, jsonResponseTool } = await this.getArgs(options);
1029
+ const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
998
1030
  const citationDocuments = this.extractCitationDocuments(options.prompt);
999
1031
  const {
1000
1032
  responseHeaders,
@@ -1015,7 +1047,7 @@ var AnthropicMessagesLanguageModel = class {
1015
1047
  for (const part of response.content) {
1016
1048
  switch (part.type) {
1017
1049
  case "text": {
1018
- if (jsonResponseTool == null) {
1050
+ if (!usesJsonResponseTool) {
1019
1051
  content.push({ type: "text", text: part.text });
1020
1052
  if (part.citations) {
1021
1053
  for (const citation of part.citations) {
@@ -1057,7 +1089,7 @@ var AnthropicMessagesLanguageModel = class {
1057
1089
  case "tool_use": {
1058
1090
  content.push(
1059
1091
  // when a json response tool is used, the tool call becomes the text:
1060
- jsonResponseTool != null ? {
1092
+ usesJsonResponseTool ? {
1061
1093
  type: "text",
1062
1094
  text: JSON.stringify(part.input)
1063
1095
  } : {
@@ -1134,7 +1166,7 @@ var AnthropicMessagesLanguageModel = class {
1134
1166
  content,
1135
1167
  finishReason: mapAnthropicStopReason({
1136
1168
  finishReason: response.stop_reason,
1137
- isJsonResponseFromTool: jsonResponseTool != null
1169
+ isJsonResponseFromTool: usesJsonResponseTool
1138
1170
  }),
1139
1171
  usage: {
1140
1172
  inputTokens: response.usage.input_tokens,
@@ -1152,13 +1184,14 @@ var AnthropicMessagesLanguageModel = class {
1152
1184
  warnings,
1153
1185
  providerMetadata: {
1154
1186
  anthropic: {
1187
+ usage: response.usage,
1155
1188
  cacheCreationInputTokens: (_e = response.usage.cache_creation_input_tokens) != null ? _e : null
1156
1189
  }
1157
1190
  }
1158
1191
  };
1159
1192
  }
1160
1193
  async doStream(options) {
1161
- const { args, warnings, betas, jsonResponseTool } = await this.getArgs(options);
1194
+ const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
1162
1195
  const citationDocuments = this.extractCitationDocuments(options.prompt);
1163
1196
  const body = { ...args, stream: true };
1164
1197
  const { responseHeaders, value: response } = await (0, import_provider_utils4.postJsonToApi)({
@@ -1236,16 +1269,16 @@ var AnthropicMessagesLanguageModel = class {
1236
1269
  return;
1237
1270
  }
1238
1271
  case "tool_use": {
1239
- contentBlocks[value.index] = jsonResponseTool != null ? { type: "text" } : {
1272
+ contentBlocks[value.index] = usesJsonResponseTool ? { type: "text" } : {
1240
1273
  type: "tool-call",
1241
1274
  toolCallId: value.content_block.id,
1242
1275
  toolName: value.content_block.name,
1243
1276
  input: ""
1244
1277
  };
1245
1278
  controller.enqueue(
1246
- jsonResponseTool != null ? { type: "text-start", id: String(value.index) } : {
1279
+ usesJsonResponseTool ? { type: "text-start", id: String(value.index) } : {
1247
1280
  type: "tool-input-start",
1248
- id: String(value.index),
1281
+ id: value.content_block.id,
1249
1282
  toolName: value.content_block.name
1250
1283
  }
1251
1284
  );
@@ -1344,7 +1377,7 @@ var AnthropicMessagesLanguageModel = class {
1344
1377
  break;
1345
1378
  }
1346
1379
  case "tool-call":
1347
- if (jsonResponseTool == null) {
1380
+ if (!usesJsonResponseTool) {
1348
1381
  controller.enqueue({
1349
1382
  type: "tool-input-end",
1350
1383
  id: contentBlock.toolCallId
@@ -1362,7 +1395,7 @@ var AnthropicMessagesLanguageModel = class {
1362
1395
  const deltaType = value.delta.type;
1363
1396
  switch (deltaType) {
1364
1397
  case "text_delta": {
1365
- if (jsonResponseTool != null) {
1398
+ if (usesJsonResponseTool) {
1366
1399
  return;
1367
1400
  }
1368
1401
  controller.enqueue({
@@ -1398,16 +1431,15 @@ var AnthropicMessagesLanguageModel = class {
1398
1431
  case "input_json_delta": {
1399
1432
  const contentBlock = contentBlocks[value.index];
1400
1433
  const delta = value.delta.partial_json;
1401
- if (jsonResponseTool == null) {
1402
- if ((contentBlock == null ? void 0 : contentBlock.type) !== "tool-call") {
1434
+ if (usesJsonResponseTool) {
1435
+ if ((contentBlock == null ? void 0 : contentBlock.type) !== "text") {
1403
1436
  return;
1404
1437
  }
1405
1438
  controller.enqueue({
1406
- type: "tool-input-delta",
1407
- id: contentBlock.toolCallId,
1439
+ type: "text-delta",
1440
+ id: String(value.index),
1408
1441
  delta
1409
1442
  });
1410
- contentBlock.input += delta;
1411
1443
  } else {
1412
1444
  if ((contentBlock == null ? void 0 : contentBlock.type) !== "tool-call") {
1413
1445
  return;
@@ -1417,6 +1449,7 @@ var AnthropicMessagesLanguageModel = class {
1417
1449
  id: contentBlock.toolCallId,
1418
1450
  delta
1419
1451
  });
1452
+ contentBlock.input += delta;
1420
1453
  }
1421
1454
  return;
1422
1455
  }
@@ -1443,6 +1476,7 @@ var AnthropicMessagesLanguageModel = class {
1443
1476
  usage.cachedInputTokens = (_b = value.message.usage.cache_read_input_tokens) != null ? _b : void 0;
1444
1477
  providerMetadata = {
1445
1478
  anthropic: {
1479
+ usage: value.message.usage,
1446
1480
  cacheCreationInputTokens: (_c = value.message.usage.cache_creation_input_tokens) != null ? _c : null
1447
1481
  }
1448
1482
  };
@@ -1458,7 +1492,7 @@ var AnthropicMessagesLanguageModel = class {
1458
1492
  usage.totalTokens = ((_f = usage.inputTokens) != null ? _f : 0) + ((_g = value.usage.output_tokens) != null ? _g : 0);
1459
1493
  finishReason = mapAnthropicStopReason({
1460
1494
  finishReason: value.delta.stop_reason,
1461
- isJsonResponseFromTool: jsonResponseTool != null
1495
+ isJsonResponseFromTool: usesJsonResponseTool
1462
1496
  });
1463
1497
  return;
1464
1498
  }
@@ -1488,218 +1522,215 @@ var AnthropicMessagesLanguageModel = class {
1488
1522
  };
1489
1523
  }
1490
1524
  };
1491
- var anthropicMessagesResponseSchema = import_zod3.z.object({
1492
- type: import_zod3.z.literal("message"),
1493
- id: import_zod3.z.string().nullish(),
1494
- model: import_zod3.z.string().nullish(),
1495
- content: import_zod3.z.array(
1496
- import_zod3.z.discriminatedUnion("type", [
1497
- import_zod3.z.object({
1498
- type: import_zod3.z.literal("text"),
1499
- text: import_zod3.z.string(),
1500
- citations: import_zod3.z.array(citationSchema).optional()
1525
+ var anthropicMessagesResponseSchema = import_v44.z.object({
1526
+ type: import_v44.z.literal("message"),
1527
+ id: import_v44.z.string().nullish(),
1528
+ model: import_v44.z.string().nullish(),
1529
+ content: import_v44.z.array(
1530
+ import_v44.z.discriminatedUnion("type", [
1531
+ import_v44.z.object({
1532
+ type: import_v44.z.literal("text"),
1533
+ text: import_v44.z.string(),
1534
+ citations: import_v44.z.array(citationSchema).optional()
1501
1535
  }),
1502
- import_zod3.z.object({
1503
- type: import_zod3.z.literal("thinking"),
1504
- thinking: import_zod3.z.string(),
1505
- signature: import_zod3.z.string()
1536
+ import_v44.z.object({
1537
+ type: import_v44.z.literal("thinking"),
1538
+ thinking: import_v44.z.string(),
1539
+ signature: import_v44.z.string()
1506
1540
  }),
1507
- import_zod3.z.object({
1508
- type: import_zod3.z.literal("redacted_thinking"),
1509
- data: import_zod3.z.string()
1541
+ import_v44.z.object({
1542
+ type: import_v44.z.literal("redacted_thinking"),
1543
+ data: import_v44.z.string()
1510
1544
  }),
1511
- import_zod3.z.object({
1512
- type: import_zod3.z.literal("tool_use"),
1513
- id: import_zod3.z.string(),
1514
- name: import_zod3.z.string(),
1515
- input: import_zod3.z.unknown()
1545
+ import_v44.z.object({
1546
+ type: import_v44.z.literal("tool_use"),
1547
+ id: import_v44.z.string(),
1548
+ name: import_v44.z.string(),
1549
+ input: import_v44.z.unknown()
1516
1550
  }),
1517
- import_zod3.z.object({
1518
- type: import_zod3.z.literal("server_tool_use"),
1519
- id: import_zod3.z.string(),
1520
- name: import_zod3.z.string(),
1521
- input: import_zod3.z.record(import_zod3.z.unknown()).nullish()
1551
+ import_v44.z.object({
1552
+ type: import_v44.z.literal("server_tool_use"),
1553
+ id: import_v44.z.string(),
1554
+ name: import_v44.z.string(),
1555
+ input: import_v44.z.record(import_v44.z.string(), import_v44.z.unknown()).nullish()
1522
1556
  }),
1523
- import_zod3.z.object({
1524
- type: import_zod3.z.literal("web_search_tool_result"),
1525
- tool_use_id: import_zod3.z.string(),
1526
- content: import_zod3.z.union([
1527
- import_zod3.z.array(
1528
- import_zod3.z.object({
1529
- type: import_zod3.z.literal("web_search_result"),
1530
- url: import_zod3.z.string(),
1531
- title: import_zod3.z.string(),
1532
- encrypted_content: import_zod3.z.string(),
1533
- page_age: import_zod3.z.string().nullish()
1557
+ import_v44.z.object({
1558
+ type: import_v44.z.literal("web_search_tool_result"),
1559
+ tool_use_id: import_v44.z.string(),
1560
+ content: import_v44.z.union([
1561
+ import_v44.z.array(
1562
+ import_v44.z.object({
1563
+ type: import_v44.z.literal("web_search_result"),
1564
+ url: import_v44.z.string(),
1565
+ title: import_v44.z.string(),
1566
+ encrypted_content: import_v44.z.string(),
1567
+ page_age: import_v44.z.string().nullish()
1534
1568
  })
1535
1569
  ),
1536
- import_zod3.z.object({
1537
- type: import_zod3.z.literal("web_search_tool_result_error"),
1538
- error_code: import_zod3.z.string()
1570
+ import_v44.z.object({
1571
+ type: import_v44.z.literal("web_search_tool_result_error"),
1572
+ error_code: import_v44.z.string()
1539
1573
  })
1540
1574
  ])
1541
1575
  })
1542
1576
  ])
1543
1577
  ),
1544
- stop_reason: import_zod3.z.string().nullish(),
1545
- usage: import_zod3.z.object({
1546
- input_tokens: import_zod3.z.number(),
1547
- output_tokens: import_zod3.z.number(),
1548
- cache_creation_input_tokens: import_zod3.z.number().nullish(),
1549
- cache_read_input_tokens: import_zod3.z.number().nullish(),
1550
- server_tool_use: import_zod3.z.object({
1551
- web_search_requests: import_zod3.z.number()
1552
- }).nullish()
1578
+ stop_reason: import_v44.z.string().nullish(),
1579
+ usage: import_v44.z.looseObject({
1580
+ input_tokens: import_v44.z.number(),
1581
+ output_tokens: import_v44.z.number(),
1582
+ cache_creation_input_tokens: import_v44.z.number().nullish(),
1583
+ cache_read_input_tokens: import_v44.z.number().nullish()
1553
1584
  })
1554
1585
  });
1555
- var anthropicMessagesChunkSchema = import_zod3.z.discriminatedUnion("type", [
1556
- import_zod3.z.object({
1557
- type: import_zod3.z.literal("message_start"),
1558
- message: import_zod3.z.object({
1559
- id: import_zod3.z.string().nullish(),
1560
- model: import_zod3.z.string().nullish(),
1561
- usage: import_zod3.z.object({
1562
- input_tokens: import_zod3.z.number(),
1563
- output_tokens: import_zod3.z.number(),
1564
- cache_creation_input_tokens: import_zod3.z.number().nullish(),
1565
- cache_read_input_tokens: import_zod3.z.number().nullish()
1586
+ var anthropicMessagesChunkSchema = import_v44.z.discriminatedUnion("type", [
1587
+ import_v44.z.object({
1588
+ type: import_v44.z.literal("message_start"),
1589
+ message: import_v44.z.object({
1590
+ id: import_v44.z.string().nullish(),
1591
+ model: import_v44.z.string().nullish(),
1592
+ usage: import_v44.z.looseObject({
1593
+ input_tokens: import_v44.z.number(),
1594
+ output_tokens: import_v44.z.number(),
1595
+ cache_creation_input_tokens: import_v44.z.number().nullish(),
1596
+ cache_read_input_tokens: import_v44.z.number().nullish()
1566
1597
  })
1567
1598
  })
1568
1599
  }),
1569
- import_zod3.z.object({
1570
- type: import_zod3.z.literal("content_block_start"),
1571
- index: import_zod3.z.number(),
1572
- content_block: import_zod3.z.discriminatedUnion("type", [
1573
- import_zod3.z.object({
1574
- type: import_zod3.z.literal("text"),
1575
- text: import_zod3.z.string()
1600
+ import_v44.z.object({
1601
+ type: import_v44.z.literal("content_block_start"),
1602
+ index: import_v44.z.number(),
1603
+ content_block: import_v44.z.discriminatedUnion("type", [
1604
+ import_v44.z.object({
1605
+ type: import_v44.z.literal("text"),
1606
+ text: import_v44.z.string()
1576
1607
  }),
1577
- import_zod3.z.object({
1578
- type: import_zod3.z.literal("thinking"),
1579
- thinking: import_zod3.z.string()
1608
+ import_v44.z.object({
1609
+ type: import_v44.z.literal("thinking"),
1610
+ thinking: import_v44.z.string()
1580
1611
  }),
1581
- import_zod3.z.object({
1582
- type: import_zod3.z.literal("tool_use"),
1583
- id: import_zod3.z.string(),
1584
- name: import_zod3.z.string()
1612
+ import_v44.z.object({
1613
+ type: import_v44.z.literal("tool_use"),
1614
+ id: import_v44.z.string(),
1615
+ name: import_v44.z.string()
1585
1616
  }),
1586
- import_zod3.z.object({
1587
- type: import_zod3.z.literal("redacted_thinking"),
1588
- data: import_zod3.z.string()
1617
+ import_v44.z.object({
1618
+ type: import_v44.z.literal("redacted_thinking"),
1619
+ data: import_v44.z.string()
1589
1620
  }),
1590
- import_zod3.z.object({
1591
- type: import_zod3.z.literal("server_tool_use"),
1592
- id: import_zod3.z.string(),
1593
- name: import_zod3.z.string(),
1594
- input: import_zod3.z.record(import_zod3.z.unknown()).nullish()
1621
+ import_v44.z.object({
1622
+ type: import_v44.z.literal("server_tool_use"),
1623
+ id: import_v44.z.string(),
1624
+ name: import_v44.z.string(),
1625
+ input: import_v44.z.record(import_v44.z.string(), import_v44.z.unknown()).nullish()
1595
1626
  }),
1596
- import_zod3.z.object({
1597
- type: import_zod3.z.literal("web_search_tool_result"),
1598
- tool_use_id: import_zod3.z.string(),
1599
- content: import_zod3.z.union([
1600
- import_zod3.z.array(
1601
- import_zod3.z.object({
1602
- type: import_zod3.z.literal("web_search_result"),
1603
- url: import_zod3.z.string(),
1604
- title: import_zod3.z.string(),
1605
- encrypted_content: import_zod3.z.string(),
1606
- page_age: import_zod3.z.string().nullish()
1627
+ import_v44.z.object({
1628
+ type: import_v44.z.literal("web_search_tool_result"),
1629
+ tool_use_id: import_v44.z.string(),
1630
+ content: import_v44.z.union([
1631
+ import_v44.z.array(
1632
+ import_v44.z.object({
1633
+ type: import_v44.z.literal("web_search_result"),
1634
+ url: import_v44.z.string(),
1635
+ title: import_v44.z.string(),
1636
+ encrypted_content: import_v44.z.string(),
1637
+ page_age: import_v44.z.string().nullish()
1607
1638
  })
1608
1639
  ),
1609
- import_zod3.z.object({
1610
- type: import_zod3.z.literal("web_search_tool_result_error"),
1611
- error_code: import_zod3.z.string()
1640
+ import_v44.z.object({
1641
+ type: import_v44.z.literal("web_search_tool_result_error"),
1642
+ error_code: import_v44.z.string()
1612
1643
  })
1613
1644
  ])
1614
1645
  })
1615
1646
  ])
1616
1647
  }),
1617
- import_zod3.z.object({
1618
- type: import_zod3.z.literal("content_block_delta"),
1619
- index: import_zod3.z.number(),
1620
- delta: import_zod3.z.discriminatedUnion("type", [
1621
- import_zod3.z.object({
1622
- type: import_zod3.z.literal("input_json_delta"),
1623
- partial_json: import_zod3.z.string()
1648
+ import_v44.z.object({
1649
+ type: import_v44.z.literal("content_block_delta"),
1650
+ index: import_v44.z.number(),
1651
+ delta: import_v44.z.discriminatedUnion("type", [
1652
+ import_v44.z.object({
1653
+ type: import_v44.z.literal("input_json_delta"),
1654
+ partial_json: import_v44.z.string()
1624
1655
  }),
1625
- import_zod3.z.object({
1626
- type: import_zod3.z.literal("text_delta"),
1627
- text: import_zod3.z.string()
1656
+ import_v44.z.object({
1657
+ type: import_v44.z.literal("text_delta"),
1658
+ text: import_v44.z.string()
1628
1659
  }),
1629
- import_zod3.z.object({
1630
- type: import_zod3.z.literal("thinking_delta"),
1631
- thinking: import_zod3.z.string()
1660
+ import_v44.z.object({
1661
+ type: import_v44.z.literal("thinking_delta"),
1662
+ thinking: import_v44.z.string()
1632
1663
  }),
1633
- import_zod3.z.object({
1634
- type: import_zod3.z.literal("signature_delta"),
1635
- signature: import_zod3.z.string()
1664
+ import_v44.z.object({
1665
+ type: import_v44.z.literal("signature_delta"),
1666
+ signature: import_v44.z.string()
1636
1667
  }),
1637
- import_zod3.z.object({
1638
- type: import_zod3.z.literal("citations_delta"),
1668
+ import_v44.z.object({
1669
+ type: import_v44.z.literal("citations_delta"),
1639
1670
  citation: citationSchema
1640
1671
  })
1641
1672
  ])
1642
1673
  }),
1643
- import_zod3.z.object({
1644
- type: import_zod3.z.literal("content_block_stop"),
1645
- index: import_zod3.z.number()
1674
+ import_v44.z.object({
1675
+ type: import_v44.z.literal("content_block_stop"),
1676
+ index: import_v44.z.number()
1646
1677
  }),
1647
- import_zod3.z.object({
1648
- type: import_zod3.z.literal("error"),
1649
- error: import_zod3.z.object({
1650
- type: import_zod3.z.string(),
1651
- message: import_zod3.z.string()
1678
+ import_v44.z.object({
1679
+ type: import_v44.z.literal("error"),
1680
+ error: import_v44.z.object({
1681
+ type: import_v44.z.string(),
1682
+ message: import_v44.z.string()
1652
1683
  })
1653
1684
  }),
1654
- import_zod3.z.object({
1655
- type: import_zod3.z.literal("message_delta"),
1656
- delta: import_zod3.z.object({ stop_reason: import_zod3.z.string().nullish() }),
1657
- usage: import_zod3.z.object({ output_tokens: import_zod3.z.number() })
1685
+ import_v44.z.object({
1686
+ type: import_v44.z.literal("message_delta"),
1687
+ delta: import_v44.z.object({ stop_reason: import_v44.z.string().nullish() }),
1688
+ usage: import_v44.z.object({ output_tokens: import_v44.z.number() })
1658
1689
  }),
1659
- import_zod3.z.object({
1660
- type: import_zod3.z.literal("message_stop")
1690
+ import_v44.z.object({
1691
+ type: import_v44.z.literal("message_stop")
1661
1692
  }),
1662
- import_zod3.z.object({
1663
- type: import_zod3.z.literal("ping")
1693
+ import_v44.z.object({
1694
+ type: import_v44.z.literal("ping")
1664
1695
  })
1665
1696
  ]);
1666
- var anthropicReasoningMetadataSchema = import_zod3.z.object({
1667
- signature: import_zod3.z.string().optional(),
1668
- redactedData: import_zod3.z.string().optional()
1697
+ var anthropicReasoningMetadataSchema = import_v44.z.object({
1698
+ signature: import_v44.z.string().optional(),
1699
+ redactedData: import_v44.z.string().optional()
1669
1700
  });
1670
1701
 
1671
1702
  // src/tool/bash_20241022.ts
1672
1703
  var import_provider_utils5 = require("@ai-sdk/provider-utils");
1673
- var import_v42 = __toESM(require("zod/v4"));
1704
+ var import_v45 = __toESM(require("zod/v4"));
1674
1705
  var bash_20241022 = (0, import_provider_utils5.createProviderDefinedToolFactory)({
1675
1706
  id: "anthropic.bash_20241022",
1676
1707
  name: "bash",
1677
- inputSchema: import_v42.default.object({
1678
- command: import_v42.default.string(),
1679
- restart: import_v42.default.boolean().optional()
1708
+ inputSchema: import_v45.default.object({
1709
+ command: import_v45.default.string(),
1710
+ restart: import_v45.default.boolean().optional()
1680
1711
  })
1681
1712
  });
1682
1713
 
1683
1714
  // src/tool/bash_20250124.ts
1684
1715
  var import_provider_utils6 = require("@ai-sdk/provider-utils");
1685
- var import_v43 = __toESM(require("zod/v4"));
1716
+ var import_v46 = __toESM(require("zod/v4"));
1686
1717
  var bash_20250124 = (0, import_provider_utils6.createProviderDefinedToolFactory)({
1687
1718
  id: "anthropic.bashTool_20250124",
1688
1719
  name: "bash",
1689
- inputSchema: import_v43.default.object({
1690
- command: import_v43.default.string(),
1691
- restart: import_v43.default.boolean().optional()
1720
+ inputSchema: import_v46.default.object({
1721
+ command: import_v46.default.string(),
1722
+ restart: import_v46.default.boolean().optional()
1692
1723
  })
1693
1724
  });
1694
1725
 
1695
1726
  // src/tool/computer_20241022.ts
1696
1727
  var import_provider_utils7 = require("@ai-sdk/provider-utils");
1697
- var import_v44 = require("zod/v4");
1728
+ var import_v47 = require("zod/v4");
1698
1729
  var computer_20241022 = (0, import_provider_utils7.createProviderDefinedToolFactory)({
1699
1730
  id: "anthropic.computer_20241022",
1700
1731
  name: "computer",
1701
- inputSchema: import_v44.z.object({
1702
- action: import_v44.z.enum([
1732
+ inputSchema: import_v47.z.object({
1733
+ action: import_v47.z.enum([
1703
1734
  "key",
1704
1735
  "type",
1705
1736
  "mouse_move",
@@ -1711,19 +1742,19 @@ var computer_20241022 = (0, import_provider_utils7.createProviderDefinedToolFact
1711
1742
  "screenshot",
1712
1743
  "cursor_position"
1713
1744
  ]),
1714
- coordinate: import_v44.z.array(import_v44.z.number().int()).optional(),
1715
- text: import_v44.z.string().optional()
1745
+ coordinate: import_v47.z.array(import_v47.z.number().int()).optional(),
1746
+ text: import_v47.z.string().optional()
1716
1747
  })
1717
1748
  });
1718
1749
 
1719
1750
  // src/tool/computer_20250124.ts
1720
1751
  var import_provider_utils8 = require("@ai-sdk/provider-utils");
1721
- var import_v45 = require("zod/v4");
1752
+ var import_v48 = require("zod/v4");
1722
1753
  var computer_20250124 = (0, import_provider_utils8.createProviderDefinedToolFactory)({
1723
1754
  id: "anthropic.computer_20250124",
1724
1755
  name: "computer",
1725
- inputSchema: import_v45.z.object({
1726
- action: import_v45.z.enum([
1756
+ inputSchema: import_v48.z.object({
1757
+ action: import_v48.z.enum([
1727
1758
  "key",
1728
1759
  "hold_key",
1729
1760
  "type",
@@ -1741,46 +1772,63 @@ var computer_20250124 = (0, import_provider_utils8.createProviderDefinedToolFact
1741
1772
  "wait",
1742
1773
  "screenshot"
1743
1774
  ]),
1744
- coordinate: import_v45.z.tuple([import_v45.z.number().int(), import_v45.z.number().int()]).optional(),
1745
- duration: import_v45.z.number().optional(),
1746
- scroll_amount: import_v45.z.number().optional(),
1747
- scroll_direction: import_v45.z.enum(["up", "down", "left", "right"]).optional(),
1748
- start_coordinate: import_v45.z.tuple([import_v45.z.number().int(), import_v45.z.number().int()]).optional(),
1749
- text: import_v45.z.string().optional()
1775
+ coordinate: import_v48.z.tuple([import_v48.z.number().int(), import_v48.z.number().int()]).optional(),
1776
+ duration: import_v48.z.number().optional(),
1777
+ scroll_amount: import_v48.z.number().optional(),
1778
+ scroll_direction: import_v48.z.enum(["up", "down", "left", "right"]).optional(),
1779
+ start_coordinate: import_v48.z.tuple([import_v48.z.number().int(), import_v48.z.number().int()]).optional(),
1780
+ text: import_v48.z.string().optional()
1750
1781
  })
1751
1782
  });
1752
1783
 
1753
1784
  // src/tool/text-editor_20241022.ts
1754
1785
  var import_provider_utils9 = require("@ai-sdk/provider-utils");
1755
- var import_v46 = require("zod/v4");
1786
+ var import_v49 = require("zod/v4");
1756
1787
  var textEditor_20241022 = (0, import_provider_utils9.createProviderDefinedToolFactory)({
1757
1788
  id: "anthropic.text_editor_20241022",
1758
1789
  name: "str_replace_editor",
1759
- inputSchema: import_v46.z.object({
1760
- command: import_v46.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
1761
- path: import_v46.z.string(),
1762
- file_text: import_v46.z.string().optional(),
1763
- insert_line: import_v46.z.number().int().optional(),
1764
- new_str: import_v46.z.string().optional(),
1765
- old_str: import_v46.z.string().optional(),
1766
- view_range: import_v46.z.array(import_v46.z.number().int()).optional()
1790
+ inputSchema: import_v49.z.object({
1791
+ command: import_v49.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
1792
+ path: import_v49.z.string(),
1793
+ file_text: import_v49.z.string().optional(),
1794
+ insert_line: import_v49.z.number().int().optional(),
1795
+ new_str: import_v49.z.string().optional(),
1796
+ old_str: import_v49.z.string().optional(),
1797
+ view_range: import_v49.z.array(import_v49.z.number().int()).optional()
1767
1798
  })
1768
1799
  });
1769
1800
 
1770
1801
  // src/tool/text-editor_20250124.ts
1771
1802
  var import_provider_utils10 = require("@ai-sdk/provider-utils");
1772
- var import_v47 = require("zod/v4");
1803
+ var import_v410 = require("zod/v4");
1773
1804
  var textEditor_20250124 = (0, import_provider_utils10.createProviderDefinedToolFactory)({
1774
1805
  id: "anthropic.text_editor_20250124",
1775
1806
  name: "str_replace_editor",
1776
- inputSchema: import_v47.z.object({
1777
- command: import_v47.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
1778
- path: import_v47.z.string(),
1779
- file_text: import_v47.z.string().optional(),
1780
- insert_line: import_v47.z.number().int().optional(),
1781
- new_str: import_v47.z.string().optional(),
1782
- old_str: import_v47.z.string().optional(),
1783
- view_range: import_v47.z.array(import_v47.z.number().int()).optional()
1807
+ inputSchema: import_v410.z.object({
1808
+ command: import_v410.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
1809
+ path: import_v410.z.string(),
1810
+ file_text: import_v410.z.string().optional(),
1811
+ insert_line: import_v410.z.number().int().optional(),
1812
+ new_str: import_v410.z.string().optional(),
1813
+ old_str: import_v410.z.string().optional(),
1814
+ view_range: import_v410.z.array(import_v410.z.number().int()).optional()
1815
+ })
1816
+ });
1817
+
1818
+ // src/tool/text-editor_20250429.ts
1819
+ var import_provider_utils11 = require("@ai-sdk/provider-utils");
1820
+ var import_v411 = require("zod/v4");
1821
+ var textEditor_20250429 = (0, import_provider_utils11.createProviderDefinedToolFactory)({
1822
+ id: "anthropic.text_editor_20250429",
1823
+ name: "str_replace_based_edit_tool",
1824
+ inputSchema: import_v411.z.object({
1825
+ command: import_v411.z.enum(["view", "create", "str_replace", "insert"]),
1826
+ path: import_v411.z.string(),
1827
+ file_text: import_v411.z.string().optional(),
1828
+ insert_line: import_v411.z.number().int().optional(),
1829
+ new_str: import_v411.z.string().optional(),
1830
+ old_str: import_v411.z.string().optional(),
1831
+ view_range: import_v411.z.array(import_v411.z.number().int()).optional()
1784
1832
  })
1785
1833
  });
1786
1834
 
@@ -1810,6 +1858,11 @@ var anthropicTools = {
1810
1858
  * Creates a tool for editing text. Must have name "str_replace_editor".
1811
1859
  */
1812
1860
  textEditor_20250124,
1861
+ /**
1862
+ * Creates a tool for editing text. Must have name "str_replace_based_edit_tool".
1863
+ * Note: This version does not support the "undo_edit" command.
1864
+ */
1865
+ textEditor_20250429,
1813
1866
  /**
1814
1867
  * Creates a tool for executing actions on a computer. Must have name "computer".
1815
1868
  *