@ai-sdk/anthropic 2.0.26 → 2.0.28

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 ? "2.0.26" : "0.0.0-test";
34
+ var VERSION = true ? "2.0.28" : "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 },
@@ -1010,6 +1221,18 @@ async function convertToAnthropicMessagesPrompt({
1010
1221
  cache_control: void 0
1011
1222
  };
1012
1223
  }
1224
+ if (contentPart.mediaType === "application/pdf") {
1225
+ betas.add("pdfs-2024-09-25");
1226
+ return {
1227
+ type: "document",
1228
+ source: {
1229
+ type: "base64",
1230
+ media_type: contentPart.mediaType,
1231
+ data: contentPart.data
1232
+ },
1233
+ cache_control: void 0
1234
+ };
1235
+ }
1013
1236
  throw new import_provider2.UnsupportedFunctionalityError({
1014
1237
  functionality: `media type: ${contentPart.mediaType}`
1015
1238
  });
@@ -1072,7 +1295,7 @@ async function convertToAnthropicMessagesPrompt({
1072
1295
  }
1073
1296
  case "reasoning": {
1074
1297
  if (sendReasoning) {
1075
- const reasoningMetadata = await (0, import_provider_utils9.parseProviderOptions)({
1298
+ const reasoningMetadata = await (0, import_provider_utils10.parseProviderOptions)({
1076
1299
  provider: "anthropic",
1077
1300
  providerOptions: part.providerOptions,
1078
1301
  schema: anthropicReasoningMetadataSchema
@@ -1113,7 +1336,17 @@ async function convertToAnthropicMessagesPrompt({
1113
1336
  }
1114
1337
  case "tool-call": {
1115
1338
  if (part.providerExecuted) {
1116
- if (part.toolName === "code_execution" || part.toolName === "web_fetch" || part.toolName === "web_search") {
1339
+ 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")) {
1340
+ anthropicContent.push({
1341
+ type: "server_tool_use",
1342
+ id: part.toolCallId,
1343
+ name: part.input.type,
1344
+ // map back to subtool name
1345
+ input: part.input,
1346
+ cache_control: cacheControl
1347
+ });
1348
+ } else if (part.toolName === "code_execution" || // code execution 20250522
1349
+ part.toolName === "web_fetch" || part.toolName === "web_search") {
1117
1350
  anthropicContent.push({
1118
1351
  type: "server_tool_use",
1119
1352
  id: part.toolCallId,
@@ -1148,21 +1381,48 @@ async function convertToAnthropicMessagesPrompt({
1148
1381
  });
1149
1382
  break;
1150
1383
  }
1151
- const codeExecutionOutput = await (0, import_provider_utils9.validateTypes)({
1152
- value: output.value,
1153
- schema: codeExecution_20250522OutputSchema
1154
- });
1155
- anthropicContent.push({
1156
- type: "code_execution_tool_result",
1157
- tool_use_id: part.toolCallId,
1158
- content: {
1159
- type: codeExecutionOutput.type,
1160
- stdout: codeExecutionOutput.stdout,
1161
- stderr: codeExecutionOutput.stderr,
1162
- return_code: codeExecutionOutput.return_code
1163
- },
1164
- cache_control: cacheControl
1165
- });
1384
+ if (output.value == null || typeof output.value !== "object" || !("type" in output.value) || typeof output.value.type !== "string") {
1385
+ warnings.push({
1386
+ type: "other",
1387
+ message: `provider executed tool result output value is not a valid code execution result for tool ${part.toolName}`
1388
+ });
1389
+ break;
1390
+ }
1391
+ if (output.value.type === "code_execution_result") {
1392
+ const codeExecutionOutput = await (0, import_provider_utils10.validateTypes)({
1393
+ value: output.value,
1394
+ schema: codeExecution_20250522OutputSchema
1395
+ });
1396
+ anthropicContent.push({
1397
+ type: "code_execution_tool_result",
1398
+ tool_use_id: part.toolCallId,
1399
+ content: {
1400
+ type: codeExecutionOutput.type,
1401
+ stdout: codeExecutionOutput.stdout,
1402
+ stderr: codeExecutionOutput.stderr,
1403
+ return_code: codeExecutionOutput.return_code
1404
+ },
1405
+ cache_control: cacheControl
1406
+ });
1407
+ } else {
1408
+ const codeExecutionOutput = await (0, import_provider_utils10.validateTypes)({
1409
+ value: output.value,
1410
+ schema: codeExecution_20250825OutputSchema
1411
+ });
1412
+ anthropicContent.push(
1413
+ codeExecutionOutput.type === "bash_code_execution_result" || codeExecutionOutput.type === "bash_code_execution_tool_result_error" ? {
1414
+ type: "bash_code_execution_tool_result",
1415
+ tool_use_id: part.toolCallId,
1416
+ cache_control: cacheControl,
1417
+ content: codeExecutionOutput
1418
+ } : {
1419
+ type: "text_editor_code_execution_tool_result",
1420
+ tool_use_id: part.toolCallId,
1421
+ cache_control: cacheControl,
1422
+ content: codeExecutionOutput
1423
+ }
1424
+ );
1425
+ }
1166
1426
  break;
1167
1427
  }
1168
1428
  if (part.toolName === "web_fetch") {
@@ -1174,7 +1434,7 @@ async function convertToAnthropicMessagesPrompt({
1174
1434
  });
1175
1435
  break;
1176
1436
  }
1177
- const webFetchOutput = await (0, import_provider_utils9.validateTypes)({
1437
+ const webFetchOutput = await (0, import_provider_utils10.validateTypes)({
1178
1438
  value: output.value,
1179
1439
  schema: webFetch_20250910OutputSchema
1180
1440
  });
@@ -1209,7 +1469,7 @@ async function convertToAnthropicMessagesPrompt({
1209
1469
  });
1210
1470
  break;
1211
1471
  }
1212
- const webSearchOutput = await (0, import_provider_utils9.validateTypes)({
1472
+ const webSearchOutput = await (0, import_provider_utils10.validateTypes)({
1213
1473
  value: output.value,
1214
1474
  schema: webSearch_20250305OutputSchema
1215
1475
  });
@@ -1354,7 +1614,7 @@ var AnthropicMessagesLanguageModel = class {
1354
1614
  var _a;
1355
1615
  this.modelId = modelId;
1356
1616
  this.config = config;
1357
- this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils10.generateId;
1617
+ this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils11.generateId;
1358
1618
  }
1359
1619
  supportsUrl(url) {
1360
1620
  return url.protocol === "https:";
@@ -1423,7 +1683,7 @@ var AnthropicMessagesLanguageModel = class {
1423
1683
  description: "Respond with a JSON object.",
1424
1684
  inputSchema: responseFormat.schema
1425
1685
  } : void 0;
1426
- const anthropicOptions = await (0, import_provider_utils10.parseProviderOptions)({
1686
+ const anthropicOptions = await (0, import_provider_utils11.parseProviderOptions)({
1427
1687
  provider: "anthropic",
1428
1688
  providerOptions,
1429
1689
  schema: anthropicProviderOptions
@@ -1515,8 +1775,8 @@ var AnthropicMessagesLanguageModel = class {
1515
1775
  betas,
1516
1776
  headers
1517
1777
  }) {
1518
- return (0, import_provider_utils10.combineHeaders)(
1519
- await (0, import_provider_utils10.resolve)(this.config.headers),
1778
+ return (0, import_provider_utils11.combineHeaders)(
1779
+ await (0, import_provider_utils11.resolve)(this.config.headers),
1520
1780
  betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {},
1521
1781
  headers
1522
1782
  );
@@ -1560,12 +1820,12 @@ var AnthropicMessagesLanguageModel = class {
1560
1820
  responseHeaders,
1561
1821
  value: response,
1562
1822
  rawValue: rawResponse
1563
- } = await (0, import_provider_utils10.postJsonToApi)({
1823
+ } = await (0, import_provider_utils11.postJsonToApi)({
1564
1824
  url: this.buildRequestUrl(false),
1565
1825
  headers: await this.getHeaders({ betas, headers: options.headers }),
1566
1826
  body: this.transformRequestBody(args),
1567
1827
  failedResponseHandler: anthropicFailedResponseHandler,
1568
- successfulResponseHandler: (0, import_provider_utils10.createJsonResponseHandler)(
1828
+ successfulResponseHandler: (0, import_provider_utils11.createJsonResponseHandler)(
1569
1829
  anthropicMessagesResponseSchema
1570
1830
  ),
1571
1831
  abortSignal: options.abortSignal,
@@ -1632,7 +1892,15 @@ var AnthropicMessagesLanguageModel = class {
1632
1892
  break;
1633
1893
  }
1634
1894
  case "server_tool_use": {
1635
- if (part.name === "web_search" || part.name === "code_execution" || part.name === "web_fetch") {
1895
+ if (part.name === "text_editor_code_execution" || part.name === "bash_code_execution") {
1896
+ content.push({
1897
+ type: "tool-call",
1898
+ toolCallId: part.id,
1899
+ toolName: "code_execution",
1900
+ input: JSON.stringify({ type: part.name, ...part.input }),
1901
+ providerExecuted: true
1902
+ });
1903
+ } else if (part.name === "web_search" || part.name === "code_execution" || part.name === "web_fetch") {
1636
1904
  content.push({
1637
1905
  type: "tool-call",
1638
1906
  toolCallId: part.id,
@@ -1728,6 +1996,7 @@ var AnthropicMessagesLanguageModel = class {
1728
1996
  }
1729
1997
  break;
1730
1998
  }
1999
+ // code execution 20250522:
1731
2000
  case "code_execution_tool_result": {
1732
2001
  if (part.content.type === "code_execution_result") {
1733
2002
  content.push({
@@ -1757,6 +2026,18 @@ var AnthropicMessagesLanguageModel = class {
1757
2026
  }
1758
2027
  break;
1759
2028
  }
2029
+ // code execution 20250825:
2030
+ case "bash_code_execution_tool_result":
2031
+ case "text_editor_code_execution_tool_result": {
2032
+ content.push({
2033
+ type: "tool-result",
2034
+ toolCallId: part.tool_use_id,
2035
+ toolName: "code_execution",
2036
+ result: part.content,
2037
+ providerExecuted: true
2038
+ });
2039
+ break;
2040
+ }
1760
2041
  }
1761
2042
  }
1762
2043
  return {
@@ -1792,12 +2073,12 @@ var AnthropicMessagesLanguageModel = class {
1792
2073
  const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
1793
2074
  const citationDocuments = this.extractCitationDocuments(options.prompt);
1794
2075
  const body = { ...args, stream: true };
1795
- const { responseHeaders, value: response } = await (0, import_provider_utils10.postJsonToApi)({
2076
+ const { responseHeaders, value: response } = await (0, import_provider_utils11.postJsonToApi)({
1796
2077
  url: this.buildRequestUrl(true),
1797
2078
  headers: await this.getHeaders({ betas, headers: options.headers }),
1798
2079
  body: this.transformRequestBody(body),
1799
2080
  failedResponseHandler: anthropicFailedResponseHandler,
1800
- successfulResponseHandler: (0, import_provider_utils10.createEventSourceResponseHandler)(
2081
+ successfulResponseHandler: (0, import_provider_utils11.createEventSourceResponseHandler)(
1801
2082
  anthropicMessagesChunkSchema
1802
2083
  ),
1803
2084
  abortSignal: options.abortSignal,
@@ -1873,7 +2154,8 @@ var AnthropicMessagesLanguageModel = class {
1873
2154
  type: "tool-call",
1874
2155
  toolCallId: value.content_block.id,
1875
2156
  toolName: value.content_block.name,
1876
- input: ""
2157
+ input: "",
2158
+ firstDelta: true
1877
2159
  };
1878
2160
  controller.enqueue(
1879
2161
  usesJsonResponseTool ? { type: "text-start", id: String(value.index) } : {
@@ -1885,18 +2167,29 @@ var AnthropicMessagesLanguageModel = class {
1885
2167
  return;
1886
2168
  }
1887
2169
  case "server_tool_use": {
1888
- if (value.content_block.name === "web_fetch" || value.content_block.name === "web_search" || value.content_block.name === "code_execution") {
2170
+ if ([
2171
+ "web_fetch",
2172
+ "web_search",
2173
+ // code execution 20250825:
2174
+ "code_execution",
2175
+ // code execution 20250825 text editor:
2176
+ "text_editor_code_execution",
2177
+ // code execution 20250825 bash:
2178
+ "bash_code_execution"
2179
+ ].includes(value.content_block.name)) {
1889
2180
  contentBlocks[value.index] = {
1890
2181
  type: "tool-call",
1891
2182
  toolCallId: value.content_block.id,
1892
2183
  toolName: value.content_block.name,
1893
2184
  input: "",
1894
- providerExecuted: true
2185
+ providerExecuted: true,
2186
+ firstDelta: true
1895
2187
  };
2188
+ const mappedToolName = value.content_block.name === "text_editor_code_execution" || value.content_block.name === "bash_code_execution" ? "code_execution" : value.content_block.name;
1896
2189
  controller.enqueue({
1897
2190
  type: "tool-input-start",
1898
2191
  id: value.content_block.id,
1899
- toolName: value.content_block.name,
2192
+ toolName: mappedToolName,
1900
2193
  providerExecuted: true
1901
2194
  });
1902
2195
  }
@@ -1988,6 +2281,7 @@ var AnthropicMessagesLanguageModel = class {
1988
2281
  }
1989
2282
  return;
1990
2283
  }
2284
+ // code execution 20250522:
1991
2285
  case "code_execution_tool_result": {
1992
2286
  const part = value.content_block;
1993
2287
  if (part.content.type === "code_execution_result") {
@@ -2018,6 +2312,19 @@ var AnthropicMessagesLanguageModel = class {
2018
2312
  }
2019
2313
  return;
2020
2314
  }
2315
+ // code execution 20250825:
2316
+ case "bash_code_execution_tool_result":
2317
+ case "text_editor_code_execution_tool_result": {
2318
+ const part = value.content_block;
2319
+ controller.enqueue({
2320
+ type: "tool-result",
2321
+ toolCallId: part.tool_use_id,
2322
+ toolName: "code_execution",
2323
+ result: part.content,
2324
+ providerExecuted: true
2325
+ });
2326
+ return;
2327
+ }
2021
2328
  default: {
2022
2329
  const _exhaustiveCheck = contentBlockType;
2023
2330
  throw new Error(
@@ -2050,7 +2357,14 @@ var AnthropicMessagesLanguageModel = class {
2050
2357
  type: "tool-input-end",
2051
2358
  id: contentBlock.toolCallId
2052
2359
  });
2053
- controller.enqueue(contentBlock);
2360
+ const toolName = contentBlock.toolName === "text_editor_code_execution" || contentBlock.toolName === "bash_code_execution" ? "code_execution" : contentBlock.toolName;
2361
+ controller.enqueue({
2362
+ type: "tool-call",
2363
+ toolCallId: contentBlock.toolCallId,
2364
+ toolName,
2365
+ input: contentBlock.input,
2366
+ providerExecuted: contentBlock.providerExecuted
2367
+ });
2054
2368
  }
2055
2369
  break;
2056
2370
  }
@@ -2098,7 +2412,10 @@ var AnthropicMessagesLanguageModel = class {
2098
2412
  }
2099
2413
  case "input_json_delta": {
2100
2414
  const contentBlock = contentBlocks[value.index];
2101
- const delta = value.delta.partial_json;
2415
+ let delta = value.delta.partial_json;
2416
+ if (delta.length === 0) {
2417
+ return;
2418
+ }
2102
2419
  if (usesJsonResponseTool) {
2103
2420
  if ((contentBlock == null ? void 0 : contentBlock.type) !== "text") {
2104
2421
  return;
@@ -2112,12 +2429,16 @@ var AnthropicMessagesLanguageModel = class {
2112
2429
  if ((contentBlock == null ? void 0 : contentBlock.type) !== "tool-call") {
2113
2430
  return;
2114
2431
  }
2432
+ if (contentBlock.firstDelta && (contentBlock.toolName === "bash_code_execution" || contentBlock.toolName === "text_editor_code_execution")) {
2433
+ delta = `{"type": "${contentBlock.toolName}",${delta.substring(1)}`;
2434
+ }
2115
2435
  controller.enqueue({
2116
2436
  type: "tool-input-delta",
2117
2437
  id: contentBlock.toolCallId,
2118
2438
  delta
2119
2439
  });
2120
2440
  contentBlock.input += delta;
2441
+ contentBlock.firstDelta = false;
2121
2442
  }
2122
2443
  return;
2123
2444
  }
@@ -2203,46 +2524,46 @@ var AnthropicMessagesLanguageModel = class {
2203
2524
  };
2204
2525
 
2205
2526
  // src/tool/bash_20241022.ts
2206
- var import_provider_utils11 = require("@ai-sdk/provider-utils");
2207
- var import_v48 = require("zod/v4");
2208
- var bash_20241022InputSchema = (0, import_provider_utils11.lazySchema)(
2209
- () => (0, import_provider_utils11.zodSchema)(
2210
- import_v48.z.object({
2211
- command: import_v48.z.string(),
2212
- restart: import_v48.z.boolean().optional()
2527
+ var import_provider_utils12 = require("@ai-sdk/provider-utils");
2528
+ var import_v49 = require("zod/v4");
2529
+ var bash_20241022InputSchema = (0, import_provider_utils12.lazySchema)(
2530
+ () => (0, import_provider_utils12.zodSchema)(
2531
+ import_v49.z.object({
2532
+ command: import_v49.z.string(),
2533
+ restart: import_v49.z.boolean().optional()
2213
2534
  })
2214
2535
  )
2215
2536
  );
2216
- var bash_20241022 = (0, import_provider_utils11.createProviderDefinedToolFactory)({
2537
+ var bash_20241022 = (0, import_provider_utils12.createProviderDefinedToolFactory)({
2217
2538
  id: "anthropic.bash_20241022",
2218
2539
  name: "bash",
2219
2540
  inputSchema: bash_20241022InputSchema
2220
2541
  });
2221
2542
 
2222
2543
  // src/tool/bash_20250124.ts
2223
- var import_provider_utils12 = require("@ai-sdk/provider-utils");
2224
- var import_v49 = require("zod/v4");
2225
- var bash_20250124InputSchema = (0, import_provider_utils12.lazySchema)(
2226
- () => (0, import_provider_utils12.zodSchema)(
2227
- import_v49.z.object({
2228
- command: import_v49.z.string(),
2229
- restart: import_v49.z.boolean().optional()
2544
+ var import_provider_utils13 = require("@ai-sdk/provider-utils");
2545
+ var import_v410 = require("zod/v4");
2546
+ var bash_20250124InputSchema = (0, import_provider_utils13.lazySchema)(
2547
+ () => (0, import_provider_utils13.zodSchema)(
2548
+ import_v410.z.object({
2549
+ command: import_v410.z.string(),
2550
+ restart: import_v410.z.boolean().optional()
2230
2551
  })
2231
2552
  )
2232
2553
  );
2233
- var bash_20250124 = (0, import_provider_utils12.createProviderDefinedToolFactory)({
2554
+ var bash_20250124 = (0, import_provider_utils13.createProviderDefinedToolFactory)({
2234
2555
  id: "anthropic.bash_20250124",
2235
2556
  name: "bash",
2236
2557
  inputSchema: bash_20250124InputSchema
2237
2558
  });
2238
2559
 
2239
2560
  // src/tool/computer_20241022.ts
2240
- var import_provider_utils13 = require("@ai-sdk/provider-utils");
2241
- var import_v410 = require("zod/v4");
2242
- var computer_20241022InputSchema = (0, import_provider_utils13.lazySchema)(
2243
- () => (0, import_provider_utils13.zodSchema)(
2244
- import_v410.z.object({
2245
- action: import_v410.z.enum([
2561
+ var import_provider_utils14 = require("@ai-sdk/provider-utils");
2562
+ var import_v411 = require("zod/v4");
2563
+ var computer_20241022InputSchema = (0, import_provider_utils14.lazySchema)(
2564
+ () => (0, import_provider_utils14.zodSchema)(
2565
+ import_v411.z.object({
2566
+ action: import_v411.z.enum([
2246
2567
  "key",
2247
2568
  "type",
2248
2569
  "mouse_move",
@@ -2254,24 +2575,24 @@ var computer_20241022InputSchema = (0, import_provider_utils13.lazySchema)(
2254
2575
  "screenshot",
2255
2576
  "cursor_position"
2256
2577
  ]),
2257
- coordinate: import_v410.z.array(import_v410.z.number().int()).optional(),
2258
- text: import_v410.z.string().optional()
2578
+ coordinate: import_v411.z.array(import_v411.z.number().int()).optional(),
2579
+ text: import_v411.z.string().optional()
2259
2580
  })
2260
2581
  )
2261
2582
  );
2262
- var computer_20241022 = (0, import_provider_utils13.createProviderDefinedToolFactory)({
2583
+ var computer_20241022 = (0, import_provider_utils14.createProviderDefinedToolFactory)({
2263
2584
  id: "anthropic.computer_20241022",
2264
2585
  name: "computer",
2265
2586
  inputSchema: computer_20241022InputSchema
2266
2587
  });
2267
2588
 
2268
2589
  // src/tool/computer_20250124.ts
2269
- var import_provider_utils14 = require("@ai-sdk/provider-utils");
2270
- var import_v411 = require("zod/v4");
2271
- var computer_20250124InputSchema = (0, import_provider_utils14.lazySchema)(
2272
- () => (0, import_provider_utils14.zodSchema)(
2273
- import_v411.z.object({
2274
- action: import_v411.z.enum([
2590
+ var import_provider_utils15 = require("@ai-sdk/provider-utils");
2591
+ var import_v412 = require("zod/v4");
2592
+ var computer_20250124InputSchema = (0, import_provider_utils15.lazySchema)(
2593
+ () => (0, import_provider_utils15.zodSchema)(
2594
+ import_v412.z.object({
2595
+ action: import_v412.z.enum([
2275
2596
  "key",
2276
2597
  "hold_key",
2277
2598
  "type",
@@ -2289,47 +2610,25 @@ var computer_20250124InputSchema = (0, import_provider_utils14.lazySchema)(
2289
2610
  "wait",
2290
2611
  "screenshot"
2291
2612
  ]),
2292
- coordinate: import_v411.z.tuple([import_v411.z.number().int(), import_v411.z.number().int()]).optional(),
2293
- duration: import_v411.z.number().optional(),
2294
- scroll_amount: import_v411.z.number().optional(),
2295
- scroll_direction: import_v411.z.enum(["up", "down", "left", "right"]).optional(),
2296
- start_coordinate: import_v411.z.tuple([import_v411.z.number().int(), import_v411.z.number().int()]).optional(),
2297
- text: import_v411.z.string().optional()
2613
+ coordinate: import_v412.z.tuple([import_v412.z.number().int(), import_v412.z.number().int()]).optional(),
2614
+ duration: import_v412.z.number().optional(),
2615
+ scroll_amount: import_v412.z.number().optional(),
2616
+ scroll_direction: import_v412.z.enum(["up", "down", "left", "right"]).optional(),
2617
+ start_coordinate: import_v412.z.tuple([import_v412.z.number().int(), import_v412.z.number().int()]).optional(),
2618
+ text: import_v412.z.string().optional()
2298
2619
  })
2299
2620
  )
2300
2621
  );
2301
- var computer_20250124 = (0, import_provider_utils14.createProviderDefinedToolFactory)({
2622
+ var computer_20250124 = (0, import_provider_utils15.createProviderDefinedToolFactory)({
2302
2623
  id: "anthropic.computer_20250124",
2303
2624
  name: "computer",
2304
2625
  inputSchema: computer_20250124InputSchema
2305
2626
  });
2306
2627
 
2307
2628
  // src/tool/text-editor_20241022.ts
2308
- var import_provider_utils15 = require("@ai-sdk/provider-utils");
2309
- var import_v412 = require("zod/v4");
2310
- var textEditor_20241022InputSchema = (0, import_provider_utils15.lazySchema)(
2311
- () => (0, import_provider_utils15.zodSchema)(
2312
- import_v412.z.object({
2313
- command: import_v412.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
2314
- path: import_v412.z.string(),
2315
- file_text: import_v412.z.string().optional(),
2316
- insert_line: import_v412.z.number().int().optional(),
2317
- new_str: import_v412.z.string().optional(),
2318
- old_str: import_v412.z.string().optional(),
2319
- view_range: import_v412.z.array(import_v412.z.number().int()).optional()
2320
- })
2321
- )
2322
- );
2323
- var textEditor_20241022 = (0, import_provider_utils15.createProviderDefinedToolFactory)({
2324
- id: "anthropic.text_editor_20241022",
2325
- name: "str_replace_editor",
2326
- inputSchema: textEditor_20241022InputSchema
2327
- });
2328
-
2329
- // src/tool/text-editor_20250124.ts
2330
2629
  var import_provider_utils16 = require("@ai-sdk/provider-utils");
2331
2630
  var import_v413 = require("zod/v4");
2332
- var textEditor_20250124InputSchema = (0, import_provider_utils16.lazySchema)(
2631
+ var textEditor_20241022InputSchema = (0, import_provider_utils16.lazySchema)(
2333
2632
  () => (0, import_provider_utils16.zodSchema)(
2334
2633
  import_v413.z.object({
2335
2634
  command: import_v413.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
@@ -2342,19 +2641,19 @@ var textEditor_20250124InputSchema = (0, import_provider_utils16.lazySchema)(
2342
2641
  })
2343
2642
  )
2344
2643
  );
2345
- var textEditor_20250124 = (0, import_provider_utils16.createProviderDefinedToolFactory)({
2346
- id: "anthropic.text_editor_20250124",
2644
+ var textEditor_20241022 = (0, import_provider_utils16.createProviderDefinedToolFactory)({
2645
+ id: "anthropic.text_editor_20241022",
2347
2646
  name: "str_replace_editor",
2348
- inputSchema: textEditor_20250124InputSchema
2647
+ inputSchema: textEditor_20241022InputSchema
2349
2648
  });
2350
2649
 
2351
- // src/tool/text-editor_20250429.ts
2650
+ // src/tool/text-editor_20250124.ts
2352
2651
  var import_provider_utils17 = require("@ai-sdk/provider-utils");
2353
2652
  var import_v414 = require("zod/v4");
2354
- var textEditor_20250429InputSchema = (0, import_provider_utils17.lazySchema)(
2653
+ var textEditor_20250124InputSchema = (0, import_provider_utils17.lazySchema)(
2355
2654
  () => (0, import_provider_utils17.zodSchema)(
2356
2655
  import_v414.z.object({
2357
- command: import_v414.z.enum(["view", "create", "str_replace", "insert"]),
2656
+ command: import_v414.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
2358
2657
  path: import_v414.z.string(),
2359
2658
  file_text: import_v414.z.string().optional(),
2360
2659
  insert_line: import_v414.z.number().int().optional(),
@@ -2364,7 +2663,29 @@ var textEditor_20250429InputSchema = (0, import_provider_utils17.lazySchema)(
2364
2663
  })
2365
2664
  )
2366
2665
  );
2367
- var textEditor_20250429 = (0, import_provider_utils17.createProviderDefinedToolFactory)({
2666
+ var textEditor_20250124 = (0, import_provider_utils17.createProviderDefinedToolFactory)({
2667
+ id: "anthropic.text_editor_20250124",
2668
+ name: "str_replace_editor",
2669
+ inputSchema: textEditor_20250124InputSchema
2670
+ });
2671
+
2672
+ // src/tool/text-editor_20250429.ts
2673
+ var import_provider_utils18 = require("@ai-sdk/provider-utils");
2674
+ var import_v415 = require("zod/v4");
2675
+ var textEditor_20250429InputSchema = (0, import_provider_utils18.lazySchema)(
2676
+ () => (0, import_provider_utils18.zodSchema)(
2677
+ import_v415.z.object({
2678
+ command: import_v415.z.enum(["view", "create", "str_replace", "insert"]),
2679
+ path: import_v415.z.string(),
2680
+ file_text: import_v415.z.string().optional(),
2681
+ insert_line: import_v415.z.number().int().optional(),
2682
+ new_str: import_v415.z.string().optional(),
2683
+ old_str: import_v415.z.string().optional(),
2684
+ view_range: import_v415.z.array(import_v415.z.number().int()).optional()
2685
+ })
2686
+ )
2687
+ );
2688
+ var textEditor_20250429 = (0, import_provider_utils18.createProviderDefinedToolFactory)({
2368
2689
  id: "anthropic.text_editor_20250429",
2369
2690
  name: "str_replace_based_edit_tool",
2370
2691
  inputSchema: textEditor_20250429InputSchema
@@ -2401,6 +2722,19 @@ var anthropicTools = {
2401
2722
  * Tool name must be `code_execution`.
2402
2723
  */
2403
2724
  codeExecution_20250522,
2725
+ /**
2726
+ * Claude can analyze data, create visualizations, perform complex calculations,
2727
+ * run system commands, create and edit files, and process uploaded files directly within
2728
+ * the API conversation.
2729
+ *
2730
+ * The code execution tool allows Claude to run both Python and Bash commands and manipulate files,
2731
+ * including writing code, in a secure, sandboxed environment.
2732
+ *
2733
+ * This is the latest version with enhanced Bash support and file operations.
2734
+ *
2735
+ * Tool name must be `code_execution`.
2736
+ */
2737
+ codeExecution_20250825,
2404
2738
  /**
2405
2739
  * Claude can interact with computer environments through the computer use tool, which
2406
2740
  * provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
@@ -2501,11 +2835,11 @@ var anthropicTools = {
2501
2835
  // src/anthropic-provider.ts
2502
2836
  function createAnthropic(options = {}) {
2503
2837
  var _a;
2504
- const baseURL = (_a = (0, import_provider_utils18.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://api.anthropic.com/v1";
2505
- const getHeaders = () => (0, import_provider_utils18.withUserAgentSuffix)(
2838
+ const baseURL = (_a = (0, import_provider_utils19.withoutTrailingSlash)(options.baseURL)) != null ? _a : "https://api.anthropic.com/v1";
2839
+ const getHeaders = () => (0, import_provider_utils19.withUserAgentSuffix)(
2506
2840
  {
2507
2841
  "anthropic-version": "2023-06-01",
2508
- "x-api-key": (0, import_provider_utils18.loadApiKey)({
2842
+ "x-api-key": (0, import_provider_utils19.loadApiKey)({
2509
2843
  apiKey: options.apiKey,
2510
2844
  environmentVariableName: "ANTHROPIC_API_KEY",
2511
2845
  description: "Anthropic"
@@ -2521,7 +2855,7 @@ function createAnthropic(options = {}) {
2521
2855
  baseURL,
2522
2856
  headers: getHeaders,
2523
2857
  fetch: options.fetch,
2524
- generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils18.generateId,
2858
+ generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils19.generateId,
2525
2859
  supportedUrls: () => ({
2526
2860
  "image/*": [/^https?:\/\/.*$/]
2527
2861
  })