@ai-sdk/anthropic 3.0.0-beta.22 → 3.0.0-beta.23

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_utils18 = require("@ai-sdk/provider-utils");
31
+ var import_provider_utils19 = require("@ai-sdk/provider-utils");
32
32
 
33
33
  // src/version.ts
34
- var VERSION = true ? "3.0.0-beta.22" : "0.0.0-test";
34
+ var VERSION = true ? "3.0.0-beta.23" : "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_utils10 = require("@ai-sdk/provider-utils");
38
+ var import_provider_utils11 = require("@ai-sdk/provider-utils");
39
39
 
40
40
  // src/anthropic-error.ts
41
41
  var import_provider_utils = require("@ai-sdk/provider-utils");
@@ -163,6 +163,7 @@ var anthropicMessagesResponseSchema = (0, import_provider_utils2.lazySchema)(
163
163
  })
164
164
  ])
165
165
  }),
166
+ // code execution results for code_execution_20250522 tool:
166
167
  import_v42.z.object({
167
168
  type: import_v42.z.literal("code_execution_tool_result"),
168
169
  tool_use_id: import_v42.z.string(),
@@ -178,6 +179,62 @@ var anthropicMessagesResponseSchema = (0, import_provider_utils2.lazySchema)(
178
179
  error_code: import_v42.z.string()
179
180
  })
180
181
  ])
182
+ }),
183
+ // bash code execution results for code_execution_20250825 tool:
184
+ import_v42.z.object({
185
+ type: import_v42.z.literal("bash_code_execution_tool_result"),
186
+ tool_use_id: import_v42.z.string(),
187
+ content: import_v42.z.discriminatedUnion("type", [
188
+ import_v42.z.object({
189
+ type: import_v42.z.literal("bash_code_execution_result"),
190
+ content: import_v42.z.array(
191
+ import_v42.z.object({
192
+ type: import_v42.z.literal("bash_code_execution_output"),
193
+ file_id: import_v42.z.string()
194
+ })
195
+ ),
196
+ stdout: import_v42.z.string(),
197
+ stderr: import_v42.z.string(),
198
+ return_code: import_v42.z.number()
199
+ }),
200
+ import_v42.z.object({
201
+ type: import_v42.z.literal("bash_code_execution_tool_result_error"),
202
+ error_code: import_v42.z.string()
203
+ })
204
+ ])
205
+ }),
206
+ // text editor code execution results for code_execution_20250825 tool:
207
+ import_v42.z.object({
208
+ type: import_v42.z.literal("text_editor_code_execution_tool_result"),
209
+ tool_use_id: import_v42.z.string(),
210
+ content: import_v42.z.discriminatedUnion("type", [
211
+ import_v42.z.object({
212
+ type: import_v42.z.literal("text_editor_code_execution_tool_result_error"),
213
+ error_code: import_v42.z.string()
214
+ }),
215
+ import_v42.z.object({
216
+ type: import_v42.z.literal("text_editor_code_execution_view_result"),
217
+ content: import_v42.z.string(),
218
+ file_type: import_v42.z.string(),
219
+ num_lines: import_v42.z.number().nullable(),
220
+ start_line: import_v42.z.number().nullable(),
221
+ total_lines: import_v42.z.number().nullable()
222
+ }),
223
+ import_v42.z.object({
224
+ type: import_v42.z.literal("text_editor_code_execution_create_result"),
225
+ is_file_update: import_v42.z.boolean()
226
+ }),
227
+ import_v42.z.object({
228
+ type: import_v42.z.literal(
229
+ "text_editor_code_execution_str_replace_result"
230
+ ),
231
+ lines: import_v42.z.array(import_v42.z.string()).nullable(),
232
+ new_lines: import_v42.z.number().nullable(),
233
+ new_start: import_v42.z.number().nullable(),
234
+ old_lines: import_v42.z.number().nullable(),
235
+ old_start: import_v42.z.number().nullable()
236
+ })
237
+ ])
181
238
  })
182
239
  ])
183
240
  ),
@@ -278,6 +335,7 @@ var anthropicMessagesChunkSchema = (0, import_provider_utils2.lazySchema)(
278
335
  })
279
336
  ])
280
337
  }),
338
+ // code execution results for code_execution_20250522 tool:
281
339
  import_v42.z.object({
282
340
  type: import_v42.z.literal("code_execution_tool_result"),
283
341
  tool_use_id: import_v42.z.string(),
@@ -293,6 +351,62 @@ var anthropicMessagesChunkSchema = (0, import_provider_utils2.lazySchema)(
293
351
  error_code: import_v42.z.string()
294
352
  })
295
353
  ])
354
+ }),
355
+ // bash code execution results for code_execution_20250825 tool:
356
+ import_v42.z.object({
357
+ type: import_v42.z.literal("bash_code_execution_tool_result"),
358
+ tool_use_id: import_v42.z.string(),
359
+ content: import_v42.z.discriminatedUnion("type", [
360
+ import_v42.z.object({
361
+ type: import_v42.z.literal("bash_code_execution_result"),
362
+ content: import_v42.z.array(
363
+ import_v42.z.object({
364
+ type: import_v42.z.literal("bash_code_execution_output"),
365
+ file_id: import_v42.z.string()
366
+ })
367
+ ),
368
+ stdout: import_v42.z.string(),
369
+ stderr: import_v42.z.string(),
370
+ return_code: import_v42.z.number()
371
+ }),
372
+ import_v42.z.object({
373
+ type: import_v42.z.literal("bash_code_execution_tool_result_error"),
374
+ error_code: import_v42.z.string()
375
+ })
376
+ ])
377
+ }),
378
+ // text editor code execution results for code_execution_20250825 tool:
379
+ import_v42.z.object({
380
+ type: import_v42.z.literal("text_editor_code_execution_tool_result"),
381
+ tool_use_id: import_v42.z.string(),
382
+ content: import_v42.z.discriminatedUnion("type", [
383
+ import_v42.z.object({
384
+ type: import_v42.z.literal("text_editor_code_execution_tool_result_error"),
385
+ error_code: import_v42.z.string()
386
+ }),
387
+ import_v42.z.object({
388
+ type: import_v42.z.literal("text_editor_code_execution_view_result"),
389
+ content: import_v42.z.string(),
390
+ file_type: import_v42.z.string(),
391
+ num_lines: import_v42.z.number().nullable(),
392
+ start_line: import_v42.z.number().nullable(),
393
+ total_lines: import_v42.z.number().nullable()
394
+ }),
395
+ import_v42.z.object({
396
+ type: import_v42.z.literal("text_editor_code_execution_create_result"),
397
+ is_file_update: import_v42.z.boolean()
398
+ }),
399
+ import_v42.z.object({
400
+ type: import_v42.z.literal(
401
+ "text_editor_code_execution_str_replace_result"
402
+ ),
403
+ lines: import_v42.z.array(import_v42.z.string()).nullable(),
404
+ new_lines: import_v42.z.number().nullable(),
405
+ new_start: import_v42.z.number().nullable(),
406
+ old_lines: import_v42.z.number().nullable(),
407
+ old_start: import_v42.z.number().nullable()
408
+ })
409
+ ])
296
410
  })
297
411
  ])
298
412
  }),
@@ -618,6 +732,14 @@ async function prepareTools({
618
732
  });
619
733
  break;
620
734
  }
735
+ case "anthropic.code_execution_20250825": {
736
+ betas.add("code-execution-2025-08-25");
737
+ anthropicTools2.push({
738
+ type: "code_execution_20250825",
739
+ name: "code_execution"
740
+ });
741
+ break;
742
+ }
621
743
  case "anthropic.computer_20250124": {
622
744
  betas.add("computer-use-2025-01-24");
623
745
  anthropicTools2.push({
@@ -791,7 +913,7 @@ async function prepareTools({
791
913
 
792
914
  // src/convert-to-anthropic-messages-prompt.ts
793
915
  var import_provider2 = require("@ai-sdk/provider");
794
- var import_provider_utils9 = require("@ai-sdk/provider-utils");
916
+ var import_provider_utils10 = require("@ai-sdk/provider-utils");
795
917
 
796
918
  // src/tool/code-execution_20250522.ts
797
919
  var import_provider_utils8 = require("@ai-sdk/provider-utils");
@@ -823,6 +945,95 @@ var codeExecution_20250522 = (args = {}) => {
823
945
  return factory4(args);
824
946
  };
825
947
 
948
+ // src/tool/code-execution_20250825.ts
949
+ var import_provider_utils9 = require("@ai-sdk/provider-utils");
950
+ var import_v48 = require("zod/v4");
951
+ var codeExecution_20250825OutputSchema = (0, import_provider_utils9.lazySchema)(
952
+ () => (0, import_provider_utils9.zodSchema)(
953
+ import_v48.z.discriminatedUnion("type", [
954
+ import_v48.z.object({
955
+ type: import_v48.z.literal("bash_code_execution_result"),
956
+ content: import_v48.z.array(
957
+ import_v48.z.object({
958
+ type: import_v48.z.literal("bash_code_execution_output"),
959
+ file_id: import_v48.z.string()
960
+ })
961
+ ),
962
+ stdout: import_v48.z.string(),
963
+ stderr: import_v48.z.string(),
964
+ return_code: import_v48.z.number()
965
+ }),
966
+ import_v48.z.object({
967
+ type: import_v48.z.literal("bash_code_execution_tool_result_error"),
968
+ error_code: import_v48.z.string()
969
+ }),
970
+ import_v48.z.object({
971
+ type: import_v48.z.literal("text_editor_code_execution_tool_result_error"),
972
+ error_code: import_v48.z.string()
973
+ }),
974
+ import_v48.z.object({
975
+ type: import_v48.z.literal("text_editor_code_execution_view_result"),
976
+ content: import_v48.z.string(),
977
+ file_type: import_v48.z.string(),
978
+ num_lines: import_v48.z.number().nullable(),
979
+ start_line: import_v48.z.number().nullable(),
980
+ total_lines: import_v48.z.number().nullable()
981
+ }),
982
+ import_v48.z.object({
983
+ type: import_v48.z.literal("text_editor_code_execution_create_result"),
984
+ is_file_update: import_v48.z.boolean()
985
+ }),
986
+ import_v48.z.object({
987
+ type: import_v48.z.literal("text_editor_code_execution_str_replace_result"),
988
+ lines: import_v48.z.array(import_v48.z.string()).nullable(),
989
+ new_lines: import_v48.z.number().nullable(),
990
+ new_start: import_v48.z.number().nullable(),
991
+ old_lines: import_v48.z.number().nullable(),
992
+ old_start: import_v48.z.number().nullable()
993
+ })
994
+ ])
995
+ )
996
+ );
997
+ var codeExecution_20250825InputSchema = (0, import_provider_utils9.lazySchema)(
998
+ () => (0, import_provider_utils9.zodSchema)(
999
+ import_v48.z.discriminatedUnion("type", [
1000
+ import_v48.z.object({
1001
+ type: import_v48.z.literal("bash_code_execution"),
1002
+ command: import_v48.z.string()
1003
+ }),
1004
+ import_v48.z.discriminatedUnion("command", [
1005
+ import_v48.z.object({
1006
+ type: import_v48.z.literal("text_editor_code_execution"),
1007
+ command: import_v48.z.literal("view"),
1008
+ path: import_v48.z.string()
1009
+ }),
1010
+ import_v48.z.object({
1011
+ type: import_v48.z.literal("text_editor_code_execution"),
1012
+ command: import_v48.z.literal("create"),
1013
+ path: import_v48.z.string(),
1014
+ file_text: import_v48.z.string().nullish()
1015
+ }),
1016
+ import_v48.z.object({
1017
+ type: import_v48.z.literal("text_editor_code_execution"),
1018
+ command: import_v48.z.literal("str_replace"),
1019
+ path: import_v48.z.string(),
1020
+ old_str: import_v48.z.string(),
1021
+ new_str: import_v48.z.string()
1022
+ })
1023
+ ])
1024
+ ])
1025
+ )
1026
+ );
1027
+ var factory5 = (0, import_provider_utils9.createProviderDefinedToolFactoryWithOutputSchema)({
1028
+ id: "anthropic.code_execution_20250825",
1029
+ name: "code_execution",
1030
+ inputSchema: codeExecution_20250825InputSchema,
1031
+ outputSchema: codeExecution_20250825OutputSchema
1032
+ });
1033
+ var codeExecution_20250825 = (args = {}) => {
1034
+ return factory5(args);
1035
+ };
1036
+
826
1037
  // src/convert-to-anthropic-messages-prompt.ts
827
1038
  function convertToString(data) {
828
1039
  if (typeof data === "string") {
@@ -852,7 +1063,7 @@ async function convertToAnthropicMessagesPrompt({
852
1063
  const messages = [];
853
1064
  async function shouldEnableCitations(providerMetadata) {
854
1065
  var _a2, _b2;
855
- const anthropicOptions = await (0, import_provider_utils9.parseProviderOptions)({
1066
+ const anthropicOptions = await (0, import_provider_utils10.parseProviderOptions)({
856
1067
  provider: "anthropic",
857
1068
  providerOptions: providerMetadata,
858
1069
  schema: anthropicFilePartProviderOptions
@@ -860,7 +1071,7 @@ async function convertToAnthropicMessagesPrompt({
860
1071
  return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
861
1072
  }
862
1073
  async function getDocumentMetadata(providerMetadata) {
863
- const anthropicOptions = await (0, import_provider_utils9.parseProviderOptions)({
1074
+ const anthropicOptions = await (0, import_provider_utils10.parseProviderOptions)({
864
1075
  provider: "anthropic",
865
1076
  providerOptions: providerMetadata,
866
1077
  schema: anthropicFilePartProviderOptions
@@ -917,7 +1128,7 @@ async function convertToAnthropicMessagesPrompt({
917
1128
  } : {
918
1129
  type: "base64",
919
1130
  media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
920
- data: (0, import_provider_utils9.convertToBase64)(part.data)
1131
+ data: (0, import_provider_utils10.convertToBase64)(part.data)
921
1132
  },
922
1133
  cache_control: cacheControl
923
1134
  });
@@ -937,7 +1148,7 @@ async function convertToAnthropicMessagesPrompt({
937
1148
  } : {
938
1149
  type: "base64",
939
1150
  media_type: "application/pdf",
940
- data: (0, import_provider_utils9.convertToBase64)(part.data)
1151
+ data: (0, import_provider_utils10.convertToBase64)(part.data)
941
1152
  },
942
1153
  title: (_b = metadata.title) != null ? _b : part.filename,
943
1154
  ...metadata.context && { context: metadata.context },
@@ -1087,7 +1298,7 @@ async function convertToAnthropicMessagesPrompt({
1087
1298
  }
1088
1299
  case "reasoning": {
1089
1300
  if (sendReasoning) {
1090
- const reasoningMetadata = await (0, import_provider_utils9.parseProviderOptions)({
1301
+ const reasoningMetadata = await (0, import_provider_utils10.parseProviderOptions)({
1091
1302
  provider: "anthropic",
1092
1303
  providerOptions: part.providerOptions,
1093
1304
  schema: anthropicReasoningMetadataSchema
@@ -1128,7 +1339,17 @@ async function convertToAnthropicMessagesPrompt({
1128
1339
  }
1129
1340
  case "tool-call": {
1130
1341
  if (part.providerExecuted) {
1131
- if (part.toolName === "code_execution" || part.toolName === "web_fetch" || part.toolName === "web_search") {
1342
+ if (part.toolName === "code_execution" && part.input != null && typeof part.input === "object" && "type" in part.input && typeof part.input.type === "string" && (part.input.type === "bash_code_execution" || part.input.type === "text_editor_code_execution")) {
1343
+ anthropicContent.push({
1344
+ type: "server_tool_use",
1345
+ id: part.toolCallId,
1346
+ name: part.input.type,
1347
+ // map back to subtool name
1348
+ input: part.input,
1349
+ cache_control: cacheControl
1350
+ });
1351
+ } else if (part.toolName === "code_execution" || // code execution 20250522
1352
+ part.toolName === "web_fetch" || part.toolName === "web_search") {
1132
1353
  anthropicContent.push({
1133
1354
  type: "server_tool_use",
1134
1355
  id: part.toolCallId,
@@ -1163,21 +1384,48 @@ async function convertToAnthropicMessagesPrompt({
1163
1384
  });
1164
1385
  break;
1165
1386
  }
1166
- const codeExecutionOutput = await (0, import_provider_utils9.validateTypes)({
1167
- value: output.value,
1168
- schema: codeExecution_20250522OutputSchema
1169
- });
1170
- anthropicContent.push({
1171
- type: "code_execution_tool_result",
1172
- tool_use_id: part.toolCallId,
1173
- content: {
1174
- type: codeExecutionOutput.type,
1175
- stdout: codeExecutionOutput.stdout,
1176
- stderr: codeExecutionOutput.stderr,
1177
- return_code: codeExecutionOutput.return_code
1178
- },
1179
- cache_control: cacheControl
1180
- });
1387
+ if (output.value == null || typeof output.value !== "object" || !("type" in output.value) || typeof output.value.type !== "string") {
1388
+ warnings.push({
1389
+ type: "other",
1390
+ message: `provider executed tool result output value is not a valid code execution result for tool ${part.toolName}`
1391
+ });
1392
+ break;
1393
+ }
1394
+ if (output.value.type === "code_execution_result") {
1395
+ const codeExecutionOutput = await (0, import_provider_utils10.validateTypes)({
1396
+ value: output.value,
1397
+ schema: codeExecution_20250522OutputSchema
1398
+ });
1399
+ anthropicContent.push({
1400
+ type: "code_execution_tool_result",
1401
+ tool_use_id: part.toolCallId,
1402
+ content: {
1403
+ type: codeExecutionOutput.type,
1404
+ stdout: codeExecutionOutput.stdout,
1405
+ stderr: codeExecutionOutput.stderr,
1406
+ return_code: codeExecutionOutput.return_code
1407
+ },
1408
+ cache_control: cacheControl
1409
+ });
1410
+ } else {
1411
+ const codeExecutionOutput = await (0, import_provider_utils10.validateTypes)({
1412
+ value: output.value,
1413
+ schema: codeExecution_20250825OutputSchema
1414
+ });
1415
+ anthropicContent.push(
1416
+ codeExecutionOutput.type === "bash_code_execution_result" || codeExecutionOutput.type === "bash_code_execution_tool_result_error" ? {
1417
+ type: "bash_code_execution_tool_result",
1418
+ tool_use_id: part.toolCallId,
1419
+ cache_control: cacheControl,
1420
+ content: codeExecutionOutput
1421
+ } : {
1422
+ type: "text_editor_code_execution_tool_result",
1423
+ tool_use_id: part.toolCallId,
1424
+ cache_control: cacheControl,
1425
+ content: codeExecutionOutput
1426
+ }
1427
+ );
1428
+ }
1181
1429
  break;
1182
1430
  }
1183
1431
  if (part.toolName === "web_fetch") {
@@ -1189,7 +1437,7 @@ async function convertToAnthropicMessagesPrompt({
1189
1437
  });
1190
1438
  break;
1191
1439
  }
1192
- const webFetchOutput = await (0, import_provider_utils9.validateTypes)({
1440
+ const webFetchOutput = await (0, import_provider_utils10.validateTypes)({
1193
1441
  value: output.value,
1194
1442
  schema: webFetch_20250910OutputSchema
1195
1443
  });
@@ -1224,7 +1472,7 @@ async function convertToAnthropicMessagesPrompt({
1224
1472
  });
1225
1473
  break;
1226
1474
  }
1227
- const webSearchOutput = await (0, import_provider_utils9.validateTypes)({
1475
+ const webSearchOutput = await (0, import_provider_utils10.validateTypes)({
1228
1476
  value: output.value,
1229
1477
  schema: webSearch_20250305OutputSchema
1230
1478
  });
@@ -1369,7 +1617,7 @@ var AnthropicMessagesLanguageModel = class {
1369
1617
  var _a;
1370
1618
  this.modelId = modelId;
1371
1619
  this.config = config;
1372
- this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils10.generateId;
1620
+ this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils11.generateId;
1373
1621
  }
1374
1622
  supportsUrl(url) {
1375
1623
  return url.protocol === "https:";
@@ -1438,7 +1686,7 @@ var AnthropicMessagesLanguageModel = class {
1438
1686
  description: "Respond with a JSON object.",
1439
1687
  inputSchema: responseFormat.schema
1440
1688
  } : void 0;
1441
- const anthropicOptions = await (0, import_provider_utils10.parseProviderOptions)({
1689
+ const anthropicOptions = await (0, import_provider_utils11.parseProviderOptions)({
1442
1690
  provider: "anthropic",
1443
1691
  providerOptions,
1444
1692
  schema: anthropicProviderOptions
@@ -1530,8 +1778,8 @@ var AnthropicMessagesLanguageModel = class {
1530
1778
  betas,
1531
1779
  headers
1532
1780
  }) {
1533
- return (0, import_provider_utils10.combineHeaders)(
1534
- await (0, import_provider_utils10.resolve)(this.config.headers),
1781
+ return (0, import_provider_utils11.combineHeaders)(
1782
+ await (0, import_provider_utils11.resolve)(this.config.headers),
1535
1783
  betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {},
1536
1784
  headers
1537
1785
  );
@@ -1575,12 +1823,12 @@ var AnthropicMessagesLanguageModel = class {
1575
1823
  responseHeaders,
1576
1824
  value: response,
1577
1825
  rawValue: rawResponse
1578
- } = await (0, import_provider_utils10.postJsonToApi)({
1826
+ } = await (0, import_provider_utils11.postJsonToApi)({
1579
1827
  url: this.buildRequestUrl(false),
1580
1828
  headers: await this.getHeaders({ betas, headers: options.headers }),
1581
1829
  body: this.transformRequestBody(args),
1582
1830
  failedResponseHandler: anthropicFailedResponseHandler,
1583
- successfulResponseHandler: (0, import_provider_utils10.createJsonResponseHandler)(
1831
+ successfulResponseHandler: (0, import_provider_utils11.createJsonResponseHandler)(
1584
1832
  anthropicMessagesResponseSchema
1585
1833
  ),
1586
1834
  abortSignal: options.abortSignal,
@@ -1647,7 +1895,15 @@ var AnthropicMessagesLanguageModel = class {
1647
1895
  break;
1648
1896
  }
1649
1897
  case "server_tool_use": {
1650
- if (part.name === "web_search" || part.name === "code_execution" || part.name === "web_fetch") {
1898
+ if (part.name === "text_editor_code_execution" || part.name === "bash_code_execution") {
1899
+ content.push({
1900
+ type: "tool-call",
1901
+ toolCallId: part.id,
1902
+ toolName: "code_execution",
1903
+ input: JSON.stringify({ type: part.name, ...part.input }),
1904
+ providerExecuted: true
1905
+ });
1906
+ } else if (part.name === "web_search" || part.name === "code_execution" || part.name === "web_fetch") {
1651
1907
  content.push({
1652
1908
  type: "tool-call",
1653
1909
  toolCallId: part.id,
@@ -1743,6 +1999,7 @@ var AnthropicMessagesLanguageModel = class {
1743
1999
  }
1744
2000
  break;
1745
2001
  }
2002
+ // code execution 20250522:
1746
2003
  case "code_execution_tool_result": {
1747
2004
  if (part.content.type === "code_execution_result") {
1748
2005
  content.push({
@@ -1772,6 +2029,18 @@ var AnthropicMessagesLanguageModel = class {
1772
2029
  }
1773
2030
  break;
1774
2031
  }
2032
+ // code execution 20250825:
2033
+ case "bash_code_execution_tool_result":
2034
+ case "text_editor_code_execution_tool_result": {
2035
+ content.push({
2036
+ type: "tool-result",
2037
+ toolCallId: part.tool_use_id,
2038
+ toolName: "code_execution",
2039
+ result: part.content,
2040
+ providerExecuted: true
2041
+ });
2042
+ break;
2043
+ }
1775
2044
  }
1776
2045
  }
1777
2046
  return {
@@ -1807,12 +2076,12 @@ var AnthropicMessagesLanguageModel = class {
1807
2076
  const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
1808
2077
  const citationDocuments = this.extractCitationDocuments(options.prompt);
1809
2078
  const body = { ...args, stream: true };
1810
- const { responseHeaders, value: response } = await (0, import_provider_utils10.postJsonToApi)({
2079
+ const { responseHeaders, value: response } = await (0, import_provider_utils11.postJsonToApi)({
1811
2080
  url: this.buildRequestUrl(true),
1812
2081
  headers: await this.getHeaders({ betas, headers: options.headers }),
1813
2082
  body: this.transformRequestBody(body),
1814
2083
  failedResponseHandler: anthropicFailedResponseHandler,
1815
- successfulResponseHandler: (0, import_provider_utils10.createEventSourceResponseHandler)(
2084
+ successfulResponseHandler: (0, import_provider_utils11.createEventSourceResponseHandler)(
1816
2085
  anthropicMessagesChunkSchema
1817
2086
  ),
1818
2087
  abortSignal: options.abortSignal,
@@ -1888,7 +2157,8 @@ var AnthropicMessagesLanguageModel = class {
1888
2157
  type: "tool-call",
1889
2158
  toolCallId: value.content_block.id,
1890
2159
  toolName: value.content_block.name,
1891
- input: ""
2160
+ input: "",
2161
+ firstDelta: true
1892
2162
  };
1893
2163
  controller.enqueue(
1894
2164
  usesJsonResponseTool ? { type: "text-start", id: String(value.index) } : {
@@ -1900,18 +2170,29 @@ var AnthropicMessagesLanguageModel = class {
1900
2170
  return;
1901
2171
  }
1902
2172
  case "server_tool_use": {
1903
- if (value.content_block.name === "web_fetch" || value.content_block.name === "web_search" || value.content_block.name === "code_execution") {
2173
+ if ([
2174
+ "web_fetch",
2175
+ "web_search",
2176
+ // code execution 20250825:
2177
+ "code_execution",
2178
+ // code execution 20250825 text editor:
2179
+ "text_editor_code_execution",
2180
+ // code execution 20250825 bash:
2181
+ "bash_code_execution"
2182
+ ].includes(value.content_block.name)) {
1904
2183
  contentBlocks[value.index] = {
1905
2184
  type: "tool-call",
1906
2185
  toolCallId: value.content_block.id,
1907
2186
  toolName: value.content_block.name,
1908
2187
  input: "",
1909
- providerExecuted: true
2188
+ providerExecuted: true,
2189
+ firstDelta: true
1910
2190
  };
2191
+ const mappedToolName = value.content_block.name === "text_editor_code_execution" || value.content_block.name === "bash_code_execution" ? "code_execution" : value.content_block.name;
1911
2192
  controller.enqueue({
1912
2193
  type: "tool-input-start",
1913
2194
  id: value.content_block.id,
1914
- toolName: value.content_block.name,
2195
+ toolName: mappedToolName,
1915
2196
  providerExecuted: true
1916
2197
  });
1917
2198
  }
@@ -2003,6 +2284,7 @@ var AnthropicMessagesLanguageModel = class {
2003
2284
  }
2004
2285
  return;
2005
2286
  }
2287
+ // code execution 20250522:
2006
2288
  case "code_execution_tool_result": {
2007
2289
  const part = value.content_block;
2008
2290
  if (part.content.type === "code_execution_result") {
@@ -2033,6 +2315,19 @@ var AnthropicMessagesLanguageModel = class {
2033
2315
  }
2034
2316
  return;
2035
2317
  }
2318
+ // code execution 20250825:
2319
+ case "bash_code_execution_tool_result":
2320
+ case "text_editor_code_execution_tool_result": {
2321
+ const part = value.content_block;
2322
+ controller.enqueue({
2323
+ type: "tool-result",
2324
+ toolCallId: part.tool_use_id,
2325
+ toolName: "code_execution",
2326
+ result: part.content,
2327
+ providerExecuted: true
2328
+ });
2329
+ return;
2330
+ }
2036
2331
  default: {
2037
2332
  const _exhaustiveCheck = contentBlockType;
2038
2333
  throw new Error(
@@ -2065,7 +2360,14 @@ var AnthropicMessagesLanguageModel = class {
2065
2360
  type: "tool-input-end",
2066
2361
  id: contentBlock.toolCallId
2067
2362
  });
2068
- controller.enqueue(contentBlock);
2363
+ const toolName = contentBlock.toolName === "text_editor_code_execution" || contentBlock.toolName === "bash_code_execution" ? "code_execution" : contentBlock.toolName;
2364
+ controller.enqueue({
2365
+ type: "tool-call",
2366
+ toolCallId: contentBlock.toolCallId,
2367
+ toolName,
2368
+ input: contentBlock.input,
2369
+ providerExecuted: contentBlock.providerExecuted
2370
+ });
2069
2371
  }
2070
2372
  break;
2071
2373
  }
@@ -2113,7 +2415,10 @@ var AnthropicMessagesLanguageModel = class {
2113
2415
  }
2114
2416
  case "input_json_delta": {
2115
2417
  const contentBlock = contentBlocks[value.index];
2116
- const delta = value.delta.partial_json;
2418
+ let delta = value.delta.partial_json;
2419
+ if (delta.length === 0) {
2420
+ return;
2421
+ }
2117
2422
  if (usesJsonResponseTool) {
2118
2423
  if ((contentBlock == null ? void 0 : contentBlock.type) !== "text") {
2119
2424
  return;
@@ -2127,12 +2432,16 @@ var AnthropicMessagesLanguageModel = class {
2127
2432
  if ((contentBlock == null ? void 0 : contentBlock.type) !== "tool-call") {
2128
2433
  return;
2129
2434
  }
2435
+ if (contentBlock.firstDelta && (contentBlock.toolName === "bash_code_execution" || contentBlock.toolName === "text_editor_code_execution")) {
2436
+ delta = `{"type": "${contentBlock.toolName}",${delta.substring(1)}`;
2437
+ }
2130
2438
  controller.enqueue({
2131
2439
  type: "tool-input-delta",
2132
2440
  id: contentBlock.toolCallId,
2133
2441
  delta
2134
2442
  });
2135
2443
  contentBlock.input += delta;
2444
+ contentBlock.firstDelta = false;
2136
2445
  }
2137
2446
  return;
2138
2447
  }
@@ -2218,46 +2527,46 @@ var AnthropicMessagesLanguageModel = class {
2218
2527
  };
2219
2528
 
2220
2529
  // src/tool/bash_20241022.ts
2221
- var import_provider_utils11 = require("@ai-sdk/provider-utils");
2222
- var import_v48 = require("zod/v4");
2223
- var bash_20241022InputSchema = (0, import_provider_utils11.lazySchema)(
2224
- () => (0, import_provider_utils11.zodSchema)(
2225
- import_v48.z.object({
2226
- command: import_v48.z.string(),
2227
- restart: import_v48.z.boolean().optional()
2530
+ var import_provider_utils12 = require("@ai-sdk/provider-utils");
2531
+ var import_v49 = require("zod/v4");
2532
+ var bash_20241022InputSchema = (0, import_provider_utils12.lazySchema)(
2533
+ () => (0, import_provider_utils12.zodSchema)(
2534
+ import_v49.z.object({
2535
+ command: import_v49.z.string(),
2536
+ restart: import_v49.z.boolean().optional()
2228
2537
  })
2229
2538
  )
2230
2539
  );
2231
- var bash_20241022 = (0, import_provider_utils11.createProviderDefinedToolFactory)({
2540
+ var bash_20241022 = (0, import_provider_utils12.createProviderDefinedToolFactory)({
2232
2541
  id: "anthropic.bash_20241022",
2233
2542
  name: "bash",
2234
2543
  inputSchema: bash_20241022InputSchema
2235
2544
  });
2236
2545
 
2237
2546
  // src/tool/bash_20250124.ts
2238
- var import_provider_utils12 = require("@ai-sdk/provider-utils");
2239
- var import_v49 = require("zod/v4");
2240
- var bash_20250124InputSchema = (0, import_provider_utils12.lazySchema)(
2241
- () => (0, import_provider_utils12.zodSchema)(
2242
- import_v49.z.object({
2243
- command: import_v49.z.string(),
2244
- restart: import_v49.z.boolean().optional()
2547
+ var import_provider_utils13 = require("@ai-sdk/provider-utils");
2548
+ var import_v410 = require("zod/v4");
2549
+ var bash_20250124InputSchema = (0, import_provider_utils13.lazySchema)(
2550
+ () => (0, import_provider_utils13.zodSchema)(
2551
+ import_v410.z.object({
2552
+ command: import_v410.z.string(),
2553
+ restart: import_v410.z.boolean().optional()
2245
2554
  })
2246
2555
  )
2247
2556
  );
2248
- var bash_20250124 = (0, import_provider_utils12.createProviderDefinedToolFactory)({
2557
+ var bash_20250124 = (0, import_provider_utils13.createProviderDefinedToolFactory)({
2249
2558
  id: "anthropic.bash_20250124",
2250
2559
  name: "bash",
2251
2560
  inputSchema: bash_20250124InputSchema
2252
2561
  });
2253
2562
 
2254
2563
  // src/tool/computer_20241022.ts
2255
- var import_provider_utils13 = require("@ai-sdk/provider-utils");
2256
- var import_v410 = require("zod/v4");
2257
- var computer_20241022InputSchema = (0, import_provider_utils13.lazySchema)(
2258
- () => (0, import_provider_utils13.zodSchema)(
2259
- import_v410.z.object({
2260
- action: import_v410.z.enum([
2564
+ var import_provider_utils14 = require("@ai-sdk/provider-utils");
2565
+ var import_v411 = require("zod/v4");
2566
+ var computer_20241022InputSchema = (0, import_provider_utils14.lazySchema)(
2567
+ () => (0, import_provider_utils14.zodSchema)(
2568
+ import_v411.z.object({
2569
+ action: import_v411.z.enum([
2261
2570
  "key",
2262
2571
  "type",
2263
2572
  "mouse_move",
@@ -2269,24 +2578,24 @@ var computer_20241022InputSchema = (0, import_provider_utils13.lazySchema)(
2269
2578
  "screenshot",
2270
2579
  "cursor_position"
2271
2580
  ]),
2272
- coordinate: import_v410.z.array(import_v410.z.number().int()).optional(),
2273
- text: import_v410.z.string().optional()
2581
+ coordinate: import_v411.z.array(import_v411.z.number().int()).optional(),
2582
+ text: import_v411.z.string().optional()
2274
2583
  })
2275
2584
  )
2276
2585
  );
2277
- var computer_20241022 = (0, import_provider_utils13.createProviderDefinedToolFactory)({
2586
+ var computer_20241022 = (0, import_provider_utils14.createProviderDefinedToolFactory)({
2278
2587
  id: "anthropic.computer_20241022",
2279
2588
  name: "computer",
2280
2589
  inputSchema: computer_20241022InputSchema
2281
2590
  });
2282
2591
 
2283
2592
  // src/tool/computer_20250124.ts
2284
- var import_provider_utils14 = require("@ai-sdk/provider-utils");
2285
- var import_v411 = require("zod/v4");
2286
- var computer_20250124InputSchema = (0, import_provider_utils14.lazySchema)(
2287
- () => (0, import_provider_utils14.zodSchema)(
2288
- import_v411.z.object({
2289
- action: import_v411.z.enum([
2593
+ var import_provider_utils15 = require("@ai-sdk/provider-utils");
2594
+ var import_v412 = require("zod/v4");
2595
+ var computer_20250124InputSchema = (0, import_provider_utils15.lazySchema)(
2596
+ () => (0, import_provider_utils15.zodSchema)(
2597
+ import_v412.z.object({
2598
+ action: import_v412.z.enum([
2290
2599
  "key",
2291
2600
  "hold_key",
2292
2601
  "type",
@@ -2304,47 +2613,25 @@ var computer_20250124InputSchema = (0, import_provider_utils14.lazySchema)(
2304
2613
  "wait",
2305
2614
  "screenshot"
2306
2615
  ]),
2307
- coordinate: import_v411.z.tuple([import_v411.z.number().int(), import_v411.z.number().int()]).optional(),
2308
- duration: import_v411.z.number().optional(),
2309
- scroll_amount: import_v411.z.number().optional(),
2310
- scroll_direction: import_v411.z.enum(["up", "down", "left", "right"]).optional(),
2311
- start_coordinate: import_v411.z.tuple([import_v411.z.number().int(), import_v411.z.number().int()]).optional(),
2312
- text: import_v411.z.string().optional()
2616
+ coordinate: import_v412.z.tuple([import_v412.z.number().int(), import_v412.z.number().int()]).optional(),
2617
+ duration: import_v412.z.number().optional(),
2618
+ scroll_amount: import_v412.z.number().optional(),
2619
+ scroll_direction: import_v412.z.enum(["up", "down", "left", "right"]).optional(),
2620
+ start_coordinate: import_v412.z.tuple([import_v412.z.number().int(), import_v412.z.number().int()]).optional(),
2621
+ text: import_v412.z.string().optional()
2313
2622
  })
2314
2623
  )
2315
2624
  );
2316
- var computer_20250124 = (0, import_provider_utils14.createProviderDefinedToolFactory)({
2625
+ var computer_20250124 = (0, import_provider_utils15.createProviderDefinedToolFactory)({
2317
2626
  id: "anthropic.computer_20250124",
2318
2627
  name: "computer",
2319
2628
  inputSchema: computer_20250124InputSchema
2320
2629
  });
2321
2630
 
2322
2631
  // src/tool/text-editor_20241022.ts
2323
- var import_provider_utils15 = require("@ai-sdk/provider-utils");
2324
- var import_v412 = require("zod/v4");
2325
- var textEditor_20241022InputSchema = (0, import_provider_utils15.lazySchema)(
2326
- () => (0, import_provider_utils15.zodSchema)(
2327
- import_v412.z.object({
2328
- command: import_v412.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
2329
- path: import_v412.z.string(),
2330
- file_text: import_v412.z.string().optional(),
2331
- insert_line: import_v412.z.number().int().optional(),
2332
- new_str: import_v412.z.string().optional(),
2333
- old_str: import_v412.z.string().optional(),
2334
- view_range: import_v412.z.array(import_v412.z.number().int()).optional()
2335
- })
2336
- )
2337
- );
2338
- var textEditor_20241022 = (0, import_provider_utils15.createProviderDefinedToolFactory)({
2339
- id: "anthropic.text_editor_20241022",
2340
- name: "str_replace_editor",
2341
- inputSchema: textEditor_20241022InputSchema
2342
- });
2343
-
2344
- // src/tool/text-editor_20250124.ts
2345
2632
  var import_provider_utils16 = require("@ai-sdk/provider-utils");
2346
2633
  var import_v413 = require("zod/v4");
2347
- var textEditor_20250124InputSchema = (0, import_provider_utils16.lazySchema)(
2634
+ var textEditor_20241022InputSchema = (0, import_provider_utils16.lazySchema)(
2348
2635
  () => (0, import_provider_utils16.zodSchema)(
2349
2636
  import_v413.z.object({
2350
2637
  command: import_v413.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
@@ -2357,19 +2644,19 @@ var textEditor_20250124InputSchema = (0, import_provider_utils16.lazySchema)(
2357
2644
  })
2358
2645
  )
2359
2646
  );
2360
- var textEditor_20250124 = (0, import_provider_utils16.createProviderDefinedToolFactory)({
2361
- id: "anthropic.text_editor_20250124",
2647
+ var textEditor_20241022 = (0, import_provider_utils16.createProviderDefinedToolFactory)({
2648
+ id: "anthropic.text_editor_20241022",
2362
2649
  name: "str_replace_editor",
2363
- inputSchema: textEditor_20250124InputSchema
2650
+ inputSchema: textEditor_20241022InputSchema
2364
2651
  });
2365
2652
 
2366
- // src/tool/text-editor_20250429.ts
2653
+ // src/tool/text-editor_20250124.ts
2367
2654
  var import_provider_utils17 = require("@ai-sdk/provider-utils");
2368
2655
  var import_v414 = require("zod/v4");
2369
- var textEditor_20250429InputSchema = (0, import_provider_utils17.lazySchema)(
2656
+ var textEditor_20250124InputSchema = (0, import_provider_utils17.lazySchema)(
2370
2657
  () => (0, import_provider_utils17.zodSchema)(
2371
2658
  import_v414.z.object({
2372
- command: import_v414.z.enum(["view", "create", "str_replace", "insert"]),
2659
+ command: import_v414.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
2373
2660
  path: import_v414.z.string(),
2374
2661
  file_text: import_v414.z.string().optional(),
2375
2662
  insert_line: import_v414.z.number().int().optional(),
@@ -2379,7 +2666,29 @@ var textEditor_20250429InputSchema = (0, import_provider_utils17.lazySchema)(
2379
2666
  })
2380
2667
  )
2381
2668
  );
2382
- var textEditor_20250429 = (0, import_provider_utils17.createProviderDefinedToolFactory)({
2669
+ var textEditor_20250124 = (0, import_provider_utils17.createProviderDefinedToolFactory)({
2670
+ id: "anthropic.text_editor_20250124",
2671
+ name: "str_replace_editor",
2672
+ inputSchema: textEditor_20250124InputSchema
2673
+ });
2674
+
2675
+ // src/tool/text-editor_20250429.ts
2676
+ var import_provider_utils18 = require("@ai-sdk/provider-utils");
2677
+ var import_v415 = require("zod/v4");
2678
+ var textEditor_20250429InputSchema = (0, import_provider_utils18.lazySchema)(
2679
+ () => (0, import_provider_utils18.zodSchema)(
2680
+ import_v415.z.object({
2681
+ command: import_v415.z.enum(["view", "create", "str_replace", "insert"]),
2682
+ path: import_v415.z.string(),
2683
+ file_text: import_v415.z.string().optional(),
2684
+ insert_line: import_v415.z.number().int().optional(),
2685
+ new_str: import_v415.z.string().optional(),
2686
+ old_str: import_v415.z.string().optional(),
2687
+ view_range: import_v415.z.array(import_v415.z.number().int()).optional()
2688
+ })
2689
+ )
2690
+ );
2691
+ var textEditor_20250429 = (0, import_provider_utils18.createProviderDefinedToolFactory)({
2383
2692
  id: "anthropic.text_editor_20250429",
2384
2693
  name: "str_replace_based_edit_tool",
2385
2694
  inputSchema: textEditor_20250429InputSchema
@@ -2416,6 +2725,19 @@ var anthropicTools = {
2416
2725
  * Tool name must be `code_execution`.
2417
2726
  */
2418
2727
  codeExecution_20250522,
2728
+ /**
2729
+ * Claude can analyze data, create visualizations, perform complex calculations,
2730
+ * run system commands, create and edit files, and process uploaded files directly within
2731
+ * the API conversation.
2732
+ *
2733
+ * The code execution tool allows Claude to run both Python and Bash commands and manipulate files,
2734
+ * including writing code, in a secure, sandboxed environment.
2735
+ *
2736
+ * This is the latest version with enhanced Bash support and file operations.
2737
+ *
2738
+ * Tool name must be `code_execution`.
2739
+ */
2740
+ codeExecution_20250825,
2419
2741
  /**
2420
2742
  * Claude can interact with computer environments through the computer use tool, which
2421
2743
  * provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
@@ -2516,11 +2838,11 @@ var anthropicTools = {
2516
2838
  // src/anthropic-provider.ts
2517
2839
  function createAnthropic(options = {}) {
2518
2840
  var _a;
2519
- const baseURL = (_a = (0, import_provider_utils18.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://api.anthropic.com/v1";
2520
- const getHeaders = () => (0, import_provider_utils18.withUserAgentSuffix)(
2841
+ const baseURL = (_a = (0, import_provider_utils19.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://api.anthropic.com/v1";
2842
+ const getHeaders = () => (0, import_provider_utils19.withUserAgentSuffix)(
2521
2843
  {
2522
2844
  "anthropic-version": "2023-06-01",
2523
- "x-api-key": (0, import_provider_utils18.loadApiKey)({
2845
+ "x-api-key": (0, import_provider_utils19.loadApiKey)({
2524
2846
  apiKey: options.apiKey,
2525
2847
  environmentVariableName: "ANTHROPIC_API_KEY",
2526
2848
  description: "Anthropic"
@@ -2536,7 +2858,7 @@ function createAnthropic(options = {}) {
2536
2858
  baseURL,
2537
2859
  headers: getHeaders,
2538
2860
  fetch: options.fetch,
2539
- generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils18.generateId,
2861
+ generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils19.generateId,
2540
2862
  supportedUrls: () => ({
2541
2863
  "image/*": [/^https?:\/\/.*$/]
2542
2864
  })