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

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.
@@ -28,7 +28,7 @@ module.exports = __toCommonJS(internal_exports);
28
28
 
29
29
  // src/anthropic-messages-language-model.ts
30
30
  var import_provider3 = require("@ai-sdk/provider");
31
- var import_provider_utils10 = require("@ai-sdk/provider-utils");
31
+ var import_provider_utils11 = require("@ai-sdk/provider-utils");
32
32
 
33
33
  // src/anthropic-error.ts
34
34
  var import_provider_utils = require("@ai-sdk/provider-utils");
@@ -156,6 +156,7 @@ var anthropicMessagesResponseSchema = (0, import_provider_utils2.lazySchema)(
156
156
  })
157
157
  ])
158
158
  }),
159
+ // code execution results for code_execution_20250522 tool:
159
160
  import_v42.z.object({
160
161
  type: import_v42.z.literal("code_execution_tool_result"),
161
162
  tool_use_id: import_v42.z.string(),
@@ -171,6 +172,62 @@ var anthropicMessagesResponseSchema = (0, import_provider_utils2.lazySchema)(
171
172
  error_code: import_v42.z.string()
172
173
  })
173
174
  ])
175
+ }),
176
+ // bash code execution results for code_execution_20250825 tool:
177
+ import_v42.z.object({
178
+ type: import_v42.z.literal("bash_code_execution_tool_result"),
179
+ tool_use_id: import_v42.z.string(),
180
+ content: import_v42.z.discriminatedUnion("type", [
181
+ import_v42.z.object({
182
+ type: import_v42.z.literal("bash_code_execution_result"),
183
+ content: import_v42.z.array(
184
+ import_v42.z.object({
185
+ type: import_v42.z.literal("bash_code_execution_output"),
186
+ file_id: import_v42.z.string()
187
+ })
188
+ ),
189
+ stdout: import_v42.z.string(),
190
+ stderr: import_v42.z.string(),
191
+ return_code: import_v42.z.number()
192
+ }),
193
+ import_v42.z.object({
194
+ type: import_v42.z.literal("bash_code_execution_tool_result_error"),
195
+ error_code: import_v42.z.string()
196
+ })
197
+ ])
198
+ }),
199
+ // text editor code execution results for code_execution_20250825 tool:
200
+ import_v42.z.object({
201
+ type: import_v42.z.literal("text_editor_code_execution_tool_result"),
202
+ tool_use_id: import_v42.z.string(),
203
+ content: import_v42.z.discriminatedUnion("type", [
204
+ import_v42.z.object({
205
+ type: import_v42.z.literal("text_editor_code_execution_tool_result_error"),
206
+ error_code: import_v42.z.string()
207
+ }),
208
+ import_v42.z.object({
209
+ type: import_v42.z.literal("text_editor_code_execution_view_result"),
210
+ content: import_v42.z.string(),
211
+ file_type: import_v42.z.string(),
212
+ num_lines: import_v42.z.number().nullable(),
213
+ start_line: import_v42.z.number().nullable(),
214
+ total_lines: import_v42.z.number().nullable()
215
+ }),
216
+ import_v42.z.object({
217
+ type: import_v42.z.literal("text_editor_code_execution_create_result"),
218
+ is_file_update: import_v42.z.boolean()
219
+ }),
220
+ import_v42.z.object({
221
+ type: import_v42.z.literal(
222
+ "text_editor_code_execution_str_replace_result"
223
+ ),
224
+ lines: import_v42.z.array(import_v42.z.string()).nullable(),
225
+ new_lines: import_v42.z.number().nullable(),
226
+ new_start: import_v42.z.number().nullable(),
227
+ old_lines: import_v42.z.number().nullable(),
228
+ old_start: import_v42.z.number().nullable()
229
+ })
230
+ ])
174
231
  })
175
232
  ])
176
233
  ),
@@ -271,6 +328,7 @@ var anthropicMessagesChunkSchema = (0, import_provider_utils2.lazySchema)(
271
328
  })
272
329
  ])
273
330
  }),
331
+ // code execution results for code_execution_20250522 tool:
274
332
  import_v42.z.object({
275
333
  type: import_v42.z.literal("code_execution_tool_result"),
276
334
  tool_use_id: import_v42.z.string(),
@@ -286,6 +344,62 @@ var anthropicMessagesChunkSchema = (0, import_provider_utils2.lazySchema)(
286
344
  error_code: import_v42.z.string()
287
345
  })
288
346
  ])
347
+ }),
348
+ // bash code execution results for code_execution_20250825 tool:
349
+ import_v42.z.object({
350
+ type: import_v42.z.literal("bash_code_execution_tool_result"),
351
+ tool_use_id: import_v42.z.string(),
352
+ content: import_v42.z.discriminatedUnion("type", [
353
+ import_v42.z.object({
354
+ type: import_v42.z.literal("bash_code_execution_result"),
355
+ content: import_v42.z.array(
356
+ import_v42.z.object({
357
+ type: import_v42.z.literal("bash_code_execution_output"),
358
+ file_id: import_v42.z.string()
359
+ })
360
+ ),
361
+ stdout: import_v42.z.string(),
362
+ stderr: import_v42.z.string(),
363
+ return_code: import_v42.z.number()
364
+ }),
365
+ import_v42.z.object({
366
+ type: import_v42.z.literal("bash_code_execution_tool_result_error"),
367
+ error_code: import_v42.z.string()
368
+ })
369
+ ])
370
+ }),
371
+ // text editor code execution results for code_execution_20250825 tool:
372
+ import_v42.z.object({
373
+ type: import_v42.z.literal("text_editor_code_execution_tool_result"),
374
+ tool_use_id: import_v42.z.string(),
375
+ content: import_v42.z.discriminatedUnion("type", [
376
+ import_v42.z.object({
377
+ type: import_v42.z.literal("text_editor_code_execution_tool_result_error"),
378
+ error_code: import_v42.z.string()
379
+ }),
380
+ import_v42.z.object({
381
+ type: import_v42.z.literal("text_editor_code_execution_view_result"),
382
+ content: import_v42.z.string(),
383
+ file_type: import_v42.z.string(),
384
+ num_lines: import_v42.z.number().nullable(),
385
+ start_line: import_v42.z.number().nullable(),
386
+ total_lines: import_v42.z.number().nullable()
387
+ }),
388
+ import_v42.z.object({
389
+ type: import_v42.z.literal("text_editor_code_execution_create_result"),
390
+ is_file_update: import_v42.z.boolean()
391
+ }),
392
+ import_v42.z.object({
393
+ type: import_v42.z.literal(
394
+ "text_editor_code_execution_str_replace_result"
395
+ ),
396
+ lines: import_v42.z.array(import_v42.z.string()).nullable(),
397
+ new_lines: import_v42.z.number().nullable(),
398
+ new_start: import_v42.z.number().nullable(),
399
+ old_lines: import_v42.z.number().nullable(),
400
+ old_start: import_v42.z.number().nullable()
401
+ })
402
+ ])
289
403
  })
290
404
  ])
291
405
  }),
@@ -611,6 +725,14 @@ async function prepareTools({
611
725
  });
612
726
  break;
613
727
  }
728
+ case "anthropic.code_execution_20250825": {
729
+ betas.add("code-execution-2025-08-25");
730
+ anthropicTools2.push({
731
+ type: "code_execution_20250825",
732
+ name: "code_execution"
733
+ });
734
+ break;
735
+ }
614
736
  case "anthropic.computer_20250124": {
615
737
  betas.add("computer-use-2025-01-24");
616
738
  anthropicTools2.push({
@@ -685,6 +807,14 @@ async function prepareTools({
685
807
  });
686
808
  break;
687
809
  }
810
+ case "anthropic.memory_20250818": {
811
+ betas.add("context-management-2025-06-27");
812
+ anthropicTools2.push({
813
+ name: "memory",
814
+ type: "memory_20250818"
815
+ });
816
+ break;
817
+ }
688
818
  case "anthropic.web_fetch_20250910": {
689
819
  betas.add("web-fetch-2025-09-10");
690
820
  const args = await (0, import_provider_utils7.validateTypes)({
@@ -784,7 +914,7 @@ async function prepareTools({
784
914
 
785
915
  // src/convert-to-anthropic-messages-prompt.ts
786
916
  var import_provider2 = require("@ai-sdk/provider");
787
- var import_provider_utils9 = require("@ai-sdk/provider-utils");
917
+ var import_provider_utils10 = require("@ai-sdk/provider-utils");
788
918
 
789
919
  // src/tool/code-execution_20250522.ts
790
920
  var import_provider_utils8 = require("@ai-sdk/provider-utils");
@@ -816,6 +946,95 @@ var codeExecution_20250522 = (args = {}) => {
816
946
  return factory4(args);
817
947
  };
818
948
 
949
+ // src/tool/code-execution_20250825.ts
950
+ var import_provider_utils9 = require("@ai-sdk/provider-utils");
951
+ var import_v48 = require("zod/v4");
952
+ var codeExecution_20250825OutputSchema = (0, import_provider_utils9.lazySchema)(
953
+ () => (0, import_provider_utils9.zodSchema)(
954
+ import_v48.z.discriminatedUnion("type", [
955
+ import_v48.z.object({
956
+ type: import_v48.z.literal("bash_code_execution_result"),
957
+ content: import_v48.z.array(
958
+ import_v48.z.object({
959
+ type: import_v48.z.literal("bash_code_execution_output"),
960
+ file_id: import_v48.z.string()
961
+ })
962
+ ),
963
+ stdout: import_v48.z.string(),
964
+ stderr: import_v48.z.string(),
965
+ return_code: import_v48.z.number()
966
+ }),
967
+ import_v48.z.object({
968
+ type: import_v48.z.literal("bash_code_execution_tool_result_error"),
969
+ error_code: import_v48.z.string()
970
+ }),
971
+ import_v48.z.object({
972
+ type: import_v48.z.literal("text_editor_code_execution_tool_result_error"),
973
+ error_code: import_v48.z.string()
974
+ }),
975
+ import_v48.z.object({
976
+ type: import_v48.z.literal("text_editor_code_execution_view_result"),
977
+ content: import_v48.z.string(),
978
+ file_type: import_v48.z.string(),
979
+ num_lines: import_v48.z.number().nullable(),
980
+ start_line: import_v48.z.number().nullable(),
981
+ total_lines: import_v48.z.number().nullable()
982
+ }),
983
+ import_v48.z.object({
984
+ type: import_v48.z.literal("text_editor_code_execution_create_result"),
985
+ is_file_update: import_v48.z.boolean()
986
+ }),
987
+ import_v48.z.object({
988
+ type: import_v48.z.literal("text_editor_code_execution_str_replace_result"),
989
+ lines: import_v48.z.array(import_v48.z.string()).nullable(),
990
+ new_lines: import_v48.z.number().nullable(),
991
+ new_start: import_v48.z.number().nullable(),
992
+ old_lines: import_v48.z.number().nullable(),
993
+ old_start: import_v48.z.number().nullable()
994
+ })
995
+ ])
996
+ )
997
+ );
998
+ var codeExecution_20250825InputSchema = (0, import_provider_utils9.lazySchema)(
999
+ () => (0, import_provider_utils9.zodSchema)(
1000
+ import_v48.z.discriminatedUnion("type", [
1001
+ import_v48.z.object({
1002
+ type: import_v48.z.literal("bash_code_execution"),
1003
+ command: import_v48.z.string()
1004
+ }),
1005
+ import_v48.z.discriminatedUnion("command", [
1006
+ import_v48.z.object({
1007
+ type: import_v48.z.literal("text_editor_code_execution"),
1008
+ command: import_v48.z.literal("view"),
1009
+ path: import_v48.z.string()
1010
+ }),
1011
+ import_v48.z.object({
1012
+ type: import_v48.z.literal("text_editor_code_execution"),
1013
+ command: import_v48.z.literal("create"),
1014
+ path: import_v48.z.string(),
1015
+ file_text: import_v48.z.string().nullish()
1016
+ }),
1017
+ import_v48.z.object({
1018
+ type: import_v48.z.literal("text_editor_code_execution"),
1019
+ command: import_v48.z.literal("str_replace"),
1020
+ path: import_v48.z.string(),
1021
+ old_str: import_v48.z.string(),
1022
+ new_str: import_v48.z.string()
1023
+ })
1024
+ ])
1025
+ ])
1026
+ )
1027
+ );
1028
+ var factory5 = (0, import_provider_utils9.createProviderDefinedToolFactoryWithOutputSchema)({
1029
+ id: "anthropic.code_execution_20250825",
1030
+ name: "code_execution",
1031
+ inputSchema: codeExecution_20250825InputSchema,
1032
+ outputSchema: codeExecution_20250825OutputSchema
1033
+ });
1034
+ var codeExecution_20250825 = (args = {}) => {
1035
+ return factory5(args);
1036
+ };
1037
+
819
1038
  // src/convert-to-anthropic-messages-prompt.ts
820
1039
  function convertToString(data) {
821
1040
  if (typeof data === "string") {
@@ -845,7 +1064,7 @@ async function convertToAnthropicMessagesPrompt({
845
1064
  const messages = [];
846
1065
  async function shouldEnableCitations(providerMetadata) {
847
1066
  var _a2, _b2;
848
- const anthropicOptions = await (0, import_provider_utils9.parseProviderOptions)({
1067
+ const anthropicOptions = await (0, import_provider_utils10.parseProviderOptions)({
849
1068
  provider: "anthropic",
850
1069
  providerOptions: providerMetadata,
851
1070
  schema: anthropicFilePartProviderOptions
@@ -853,7 +1072,7 @@ async function convertToAnthropicMessagesPrompt({
853
1072
  return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
854
1073
  }
855
1074
  async function getDocumentMetadata(providerMetadata) {
856
- const anthropicOptions = await (0, import_provider_utils9.parseProviderOptions)({
1075
+ const anthropicOptions = await (0, import_provider_utils10.parseProviderOptions)({
857
1076
  provider: "anthropic",
858
1077
  providerOptions: providerMetadata,
859
1078
  schema: anthropicFilePartProviderOptions
@@ -910,7 +1129,7 @@ async function convertToAnthropicMessagesPrompt({
910
1129
  } : {
911
1130
  type: "base64",
912
1131
  media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
913
- data: (0, import_provider_utils9.convertToBase64)(part.data)
1132
+ data: (0, import_provider_utils10.convertToBase64)(part.data)
914
1133
  },
915
1134
  cache_control: cacheControl
916
1135
  });
@@ -930,7 +1149,7 @@ async function convertToAnthropicMessagesPrompt({
930
1149
  } : {
931
1150
  type: "base64",
932
1151
  media_type: "application/pdf",
933
- data: (0, import_provider_utils9.convertToBase64)(part.data)
1152
+ data: (0, import_provider_utils10.convertToBase64)(part.data)
934
1153
  },
935
1154
  title: (_b = metadata.title) != null ? _b : part.filename,
936
1155
  ...metadata.context && { context: metadata.context },
@@ -1080,7 +1299,7 @@ async function convertToAnthropicMessagesPrompt({
1080
1299
  }
1081
1300
  case "reasoning": {
1082
1301
  if (sendReasoning) {
1083
- const reasoningMetadata = await (0, import_provider_utils9.parseProviderOptions)({
1302
+ const reasoningMetadata = await (0, import_provider_utils10.parseProviderOptions)({
1084
1303
  provider: "anthropic",
1085
1304
  providerOptions: part.providerOptions,
1086
1305
  schema: anthropicReasoningMetadataSchema
@@ -1121,7 +1340,17 @@ async function convertToAnthropicMessagesPrompt({
1121
1340
  }
1122
1341
  case "tool-call": {
1123
1342
  if (part.providerExecuted) {
1124
- if (part.toolName === "code_execution" || part.toolName === "web_fetch" || part.toolName === "web_search") {
1343
+ 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")) {
1344
+ anthropicContent.push({
1345
+ type: "server_tool_use",
1346
+ id: part.toolCallId,
1347
+ name: part.input.type,
1348
+ // map back to subtool name
1349
+ input: part.input,
1350
+ cache_control: cacheControl
1351
+ });
1352
+ } else if (part.toolName === "code_execution" || // code execution 20250522
1353
+ part.toolName === "web_fetch" || part.toolName === "web_search") {
1125
1354
  anthropicContent.push({
1126
1355
  type: "server_tool_use",
1127
1356
  id: part.toolCallId,
@@ -1156,21 +1385,48 @@ async function convertToAnthropicMessagesPrompt({
1156
1385
  });
1157
1386
  break;
1158
1387
  }
1159
- const codeExecutionOutput = await (0, import_provider_utils9.validateTypes)({
1160
- value: output.value,
1161
- schema: codeExecution_20250522OutputSchema
1162
- });
1163
- anthropicContent.push({
1164
- type: "code_execution_tool_result",
1165
- tool_use_id: part.toolCallId,
1166
- content: {
1167
- type: codeExecutionOutput.type,
1168
- stdout: codeExecutionOutput.stdout,
1169
- stderr: codeExecutionOutput.stderr,
1170
- return_code: codeExecutionOutput.return_code
1171
- },
1172
- cache_control: cacheControl
1173
- });
1388
+ if (output.value == null || typeof output.value !== "object" || !("type" in output.value) || typeof output.value.type !== "string") {
1389
+ warnings.push({
1390
+ type: "other",
1391
+ message: `provider executed tool result output value is not a valid code execution result for tool ${part.toolName}`
1392
+ });
1393
+ break;
1394
+ }
1395
+ if (output.value.type === "code_execution_result") {
1396
+ const codeExecutionOutput = await (0, import_provider_utils10.validateTypes)({
1397
+ value: output.value,
1398
+ schema: codeExecution_20250522OutputSchema
1399
+ });
1400
+ anthropicContent.push({
1401
+ type: "code_execution_tool_result",
1402
+ tool_use_id: part.toolCallId,
1403
+ content: {
1404
+ type: codeExecutionOutput.type,
1405
+ stdout: codeExecutionOutput.stdout,
1406
+ stderr: codeExecutionOutput.stderr,
1407
+ return_code: codeExecutionOutput.return_code
1408
+ },
1409
+ cache_control: cacheControl
1410
+ });
1411
+ } else {
1412
+ const codeExecutionOutput = await (0, import_provider_utils10.validateTypes)({
1413
+ value: output.value,
1414
+ schema: codeExecution_20250825OutputSchema
1415
+ });
1416
+ anthropicContent.push(
1417
+ codeExecutionOutput.type === "bash_code_execution_result" || codeExecutionOutput.type === "bash_code_execution_tool_result_error" ? {
1418
+ type: "bash_code_execution_tool_result",
1419
+ tool_use_id: part.toolCallId,
1420
+ cache_control: cacheControl,
1421
+ content: codeExecutionOutput
1422
+ } : {
1423
+ type: "text_editor_code_execution_tool_result",
1424
+ tool_use_id: part.toolCallId,
1425
+ cache_control: cacheControl,
1426
+ content: codeExecutionOutput
1427
+ }
1428
+ );
1429
+ }
1174
1430
  break;
1175
1431
  }
1176
1432
  if (part.toolName === "web_fetch") {
@@ -1182,7 +1438,7 @@ async function convertToAnthropicMessagesPrompt({
1182
1438
  });
1183
1439
  break;
1184
1440
  }
1185
- const webFetchOutput = await (0, import_provider_utils9.validateTypes)({
1441
+ const webFetchOutput = await (0, import_provider_utils10.validateTypes)({
1186
1442
  value: output.value,
1187
1443
  schema: webFetch_20250910OutputSchema
1188
1444
  });
@@ -1217,7 +1473,7 @@ async function convertToAnthropicMessagesPrompt({
1217
1473
  });
1218
1474
  break;
1219
1475
  }
1220
- const webSearchOutput = await (0, import_provider_utils9.validateTypes)({
1476
+ const webSearchOutput = await (0, import_provider_utils10.validateTypes)({
1221
1477
  value: output.value,
1222
1478
  schema: webSearch_20250305OutputSchema
1223
1479
  });
@@ -1362,7 +1618,7 @@ var AnthropicMessagesLanguageModel = class {
1362
1618
  var _a;
1363
1619
  this.modelId = modelId;
1364
1620
  this.config = config;
1365
- this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils10.generateId;
1621
+ this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils11.generateId;
1366
1622
  }
1367
1623
  supportsUrl(url) {
1368
1624
  return url.protocol === "https:";
@@ -1431,7 +1687,7 @@ var AnthropicMessagesLanguageModel = class {
1431
1687
  description: "Respond with a JSON object.",
1432
1688
  inputSchema: responseFormat.schema
1433
1689
  } : void 0;
1434
- const anthropicOptions = await (0, import_provider_utils10.parseProviderOptions)({
1690
+ const anthropicOptions = await (0, import_provider_utils11.parseProviderOptions)({
1435
1691
  provider: "anthropic",
1436
1692
  providerOptions,
1437
1693
  schema: anthropicProviderOptions
@@ -1523,8 +1779,8 @@ var AnthropicMessagesLanguageModel = class {
1523
1779
  betas,
1524
1780
  headers
1525
1781
  }) {
1526
- return (0, import_provider_utils10.combineHeaders)(
1527
- await (0, import_provider_utils10.resolve)(this.config.headers),
1782
+ return (0, import_provider_utils11.combineHeaders)(
1783
+ await (0, import_provider_utils11.resolve)(this.config.headers),
1528
1784
  betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {},
1529
1785
  headers
1530
1786
  );
@@ -1568,12 +1824,12 @@ var AnthropicMessagesLanguageModel = class {
1568
1824
  responseHeaders,
1569
1825
  value: response,
1570
1826
  rawValue: rawResponse
1571
- } = await (0, import_provider_utils10.postJsonToApi)({
1827
+ } = await (0, import_provider_utils11.postJsonToApi)({
1572
1828
  url: this.buildRequestUrl(false),
1573
1829
  headers: await this.getHeaders({ betas, headers: options.headers }),
1574
1830
  body: this.transformRequestBody(args),
1575
1831
  failedResponseHandler: anthropicFailedResponseHandler,
1576
- successfulResponseHandler: (0, import_provider_utils10.createJsonResponseHandler)(
1832
+ successfulResponseHandler: (0, import_provider_utils11.createJsonResponseHandler)(
1577
1833
  anthropicMessagesResponseSchema
1578
1834
  ),
1579
1835
  abortSignal: options.abortSignal,
@@ -1640,7 +1896,15 @@ var AnthropicMessagesLanguageModel = class {
1640
1896
  break;
1641
1897
  }
1642
1898
  case "server_tool_use": {
1643
- if (part.name === "web_search" || part.name === "code_execution" || part.name === "web_fetch") {
1899
+ if (part.name === "text_editor_code_execution" || part.name === "bash_code_execution") {
1900
+ content.push({
1901
+ type: "tool-call",
1902
+ toolCallId: part.id,
1903
+ toolName: "code_execution",
1904
+ input: JSON.stringify({ type: part.name, ...part.input }),
1905
+ providerExecuted: true
1906
+ });
1907
+ } else if (part.name === "web_search" || part.name === "code_execution" || part.name === "web_fetch") {
1644
1908
  content.push({
1645
1909
  type: "tool-call",
1646
1910
  toolCallId: part.id,
@@ -1736,6 +2000,7 @@ var AnthropicMessagesLanguageModel = class {
1736
2000
  }
1737
2001
  break;
1738
2002
  }
2003
+ // code execution 20250522:
1739
2004
  case "code_execution_tool_result": {
1740
2005
  if (part.content.type === "code_execution_result") {
1741
2006
  content.push({
@@ -1765,6 +2030,18 @@ var AnthropicMessagesLanguageModel = class {
1765
2030
  }
1766
2031
  break;
1767
2032
  }
2033
+ // code execution 20250825:
2034
+ case "bash_code_execution_tool_result":
2035
+ case "text_editor_code_execution_tool_result": {
2036
+ content.push({
2037
+ type: "tool-result",
2038
+ toolCallId: part.tool_use_id,
2039
+ toolName: "code_execution",
2040
+ result: part.content,
2041
+ providerExecuted: true
2042
+ });
2043
+ break;
2044
+ }
1768
2045
  }
1769
2046
  }
1770
2047
  return {
@@ -1800,12 +2077,12 @@ var AnthropicMessagesLanguageModel = class {
1800
2077
  const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
1801
2078
  const citationDocuments = this.extractCitationDocuments(options.prompt);
1802
2079
  const body = { ...args, stream: true };
1803
- const { responseHeaders, value: response } = await (0, import_provider_utils10.postJsonToApi)({
2080
+ const { responseHeaders, value: response } = await (0, import_provider_utils11.postJsonToApi)({
1804
2081
  url: this.buildRequestUrl(true),
1805
2082
  headers: await this.getHeaders({ betas, headers: options.headers }),
1806
2083
  body: this.transformRequestBody(body),
1807
2084
  failedResponseHandler: anthropicFailedResponseHandler,
1808
- successfulResponseHandler: (0, import_provider_utils10.createEventSourceResponseHandler)(
2085
+ successfulResponseHandler: (0, import_provider_utils11.createEventSourceResponseHandler)(
1809
2086
  anthropicMessagesChunkSchema
1810
2087
  ),
1811
2088
  abortSignal: options.abortSignal,
@@ -1881,7 +2158,8 @@ var AnthropicMessagesLanguageModel = class {
1881
2158
  type: "tool-call",
1882
2159
  toolCallId: value.content_block.id,
1883
2160
  toolName: value.content_block.name,
1884
- input: ""
2161
+ input: "",
2162
+ firstDelta: true
1885
2163
  };
1886
2164
  controller.enqueue(
1887
2165
  usesJsonResponseTool ? { type: "text-start", id: String(value.index) } : {
@@ -1893,18 +2171,29 @@ var AnthropicMessagesLanguageModel = class {
1893
2171
  return;
1894
2172
  }
1895
2173
  case "server_tool_use": {
1896
- if (value.content_block.name === "web_fetch" || value.content_block.name === "web_search" || value.content_block.name === "code_execution") {
2174
+ if ([
2175
+ "web_fetch",
2176
+ "web_search",
2177
+ // code execution 20250825:
2178
+ "code_execution",
2179
+ // code execution 20250825 text editor:
2180
+ "text_editor_code_execution",
2181
+ // code execution 20250825 bash:
2182
+ "bash_code_execution"
2183
+ ].includes(value.content_block.name)) {
1897
2184
  contentBlocks[value.index] = {
1898
2185
  type: "tool-call",
1899
2186
  toolCallId: value.content_block.id,
1900
2187
  toolName: value.content_block.name,
1901
2188
  input: "",
1902
- providerExecuted: true
2189
+ providerExecuted: true,
2190
+ firstDelta: true
1903
2191
  };
2192
+ const mappedToolName = value.content_block.name === "text_editor_code_execution" || value.content_block.name === "bash_code_execution" ? "code_execution" : value.content_block.name;
1904
2193
  controller.enqueue({
1905
2194
  type: "tool-input-start",
1906
2195
  id: value.content_block.id,
1907
- toolName: value.content_block.name,
2196
+ toolName: mappedToolName,
1908
2197
  providerExecuted: true
1909
2198
  });
1910
2199
  }
@@ -1996,6 +2285,7 @@ var AnthropicMessagesLanguageModel = class {
1996
2285
  }
1997
2286
  return;
1998
2287
  }
2288
+ // code execution 20250522:
1999
2289
  case "code_execution_tool_result": {
2000
2290
  const part = value.content_block;
2001
2291
  if (part.content.type === "code_execution_result") {
@@ -2026,6 +2316,19 @@ var AnthropicMessagesLanguageModel = class {
2026
2316
  }
2027
2317
  return;
2028
2318
  }
2319
+ // code execution 20250825:
2320
+ case "bash_code_execution_tool_result":
2321
+ case "text_editor_code_execution_tool_result": {
2322
+ const part = value.content_block;
2323
+ controller.enqueue({
2324
+ type: "tool-result",
2325
+ toolCallId: part.tool_use_id,
2326
+ toolName: "code_execution",
2327
+ result: part.content,
2328
+ providerExecuted: true
2329
+ });
2330
+ return;
2331
+ }
2029
2332
  default: {
2030
2333
  const _exhaustiveCheck = contentBlockType;
2031
2334
  throw new Error(
@@ -2058,7 +2361,14 @@ var AnthropicMessagesLanguageModel = class {
2058
2361
  type: "tool-input-end",
2059
2362
  id: contentBlock.toolCallId
2060
2363
  });
2061
- controller.enqueue(contentBlock);
2364
+ const toolName = contentBlock.toolName === "text_editor_code_execution" || contentBlock.toolName === "bash_code_execution" ? "code_execution" : contentBlock.toolName;
2365
+ controller.enqueue({
2366
+ type: "tool-call",
2367
+ toolCallId: contentBlock.toolCallId,
2368
+ toolName,
2369
+ input: contentBlock.input,
2370
+ providerExecuted: contentBlock.providerExecuted
2371
+ });
2062
2372
  }
2063
2373
  break;
2064
2374
  }
@@ -2106,7 +2416,10 @@ var AnthropicMessagesLanguageModel = class {
2106
2416
  }
2107
2417
  case "input_json_delta": {
2108
2418
  const contentBlock = contentBlocks[value.index];
2109
- const delta = value.delta.partial_json;
2419
+ let delta = value.delta.partial_json;
2420
+ if (delta.length === 0) {
2421
+ return;
2422
+ }
2110
2423
  if (usesJsonResponseTool) {
2111
2424
  if ((contentBlock == null ? void 0 : contentBlock.type) !== "text") {
2112
2425
  return;
@@ -2120,12 +2433,16 @@ var AnthropicMessagesLanguageModel = class {
2120
2433
  if ((contentBlock == null ? void 0 : contentBlock.type) !== "tool-call") {
2121
2434
  return;
2122
2435
  }
2436
+ if (contentBlock.firstDelta && (contentBlock.toolName === "bash_code_execution" || contentBlock.toolName === "text_editor_code_execution")) {
2437
+ delta = `{"type": "${contentBlock.toolName}",${delta.substring(1)}`;
2438
+ }
2123
2439
  controller.enqueue({
2124
2440
  type: "tool-input-delta",
2125
2441
  id: contentBlock.toolCallId,
2126
2442
  delta
2127
2443
  });
2128
2444
  contentBlock.input += delta;
2445
+ contentBlock.firstDelta = false;
2129
2446
  }
2130
2447
  return;
2131
2448
  }
@@ -2211,46 +2528,46 @@ var AnthropicMessagesLanguageModel = class {
2211
2528
  };
2212
2529
 
2213
2530
  // src/tool/bash_20241022.ts
2214
- var import_provider_utils11 = require("@ai-sdk/provider-utils");
2215
- var import_v48 = require("zod/v4");
2216
- var bash_20241022InputSchema = (0, import_provider_utils11.lazySchema)(
2217
- () => (0, import_provider_utils11.zodSchema)(
2218
- import_v48.z.object({
2219
- command: import_v48.z.string(),
2220
- restart: import_v48.z.boolean().optional()
2531
+ var import_provider_utils12 = require("@ai-sdk/provider-utils");
2532
+ var import_v49 = require("zod/v4");
2533
+ var bash_20241022InputSchema = (0, import_provider_utils12.lazySchema)(
2534
+ () => (0, import_provider_utils12.zodSchema)(
2535
+ import_v49.z.object({
2536
+ command: import_v49.z.string(),
2537
+ restart: import_v49.z.boolean().optional()
2221
2538
  })
2222
2539
  )
2223
2540
  );
2224
- var bash_20241022 = (0, import_provider_utils11.createProviderDefinedToolFactory)({
2541
+ var bash_20241022 = (0, import_provider_utils12.createProviderDefinedToolFactory)({
2225
2542
  id: "anthropic.bash_20241022",
2226
2543
  name: "bash",
2227
2544
  inputSchema: bash_20241022InputSchema
2228
2545
  });
2229
2546
 
2230
2547
  // src/tool/bash_20250124.ts
2231
- var import_provider_utils12 = require("@ai-sdk/provider-utils");
2232
- var import_v49 = require("zod/v4");
2233
- var bash_20250124InputSchema = (0, import_provider_utils12.lazySchema)(
2234
- () => (0, import_provider_utils12.zodSchema)(
2235
- import_v49.z.object({
2236
- command: import_v49.z.string(),
2237
- restart: import_v49.z.boolean().optional()
2548
+ var import_provider_utils13 = require("@ai-sdk/provider-utils");
2549
+ var import_v410 = require("zod/v4");
2550
+ var bash_20250124InputSchema = (0, import_provider_utils13.lazySchema)(
2551
+ () => (0, import_provider_utils13.zodSchema)(
2552
+ import_v410.z.object({
2553
+ command: import_v410.z.string(),
2554
+ restart: import_v410.z.boolean().optional()
2238
2555
  })
2239
2556
  )
2240
2557
  );
2241
- var bash_20250124 = (0, import_provider_utils12.createProviderDefinedToolFactory)({
2558
+ var bash_20250124 = (0, import_provider_utils13.createProviderDefinedToolFactory)({
2242
2559
  id: "anthropic.bash_20250124",
2243
2560
  name: "bash",
2244
2561
  inputSchema: bash_20250124InputSchema
2245
2562
  });
2246
2563
 
2247
2564
  // src/tool/computer_20241022.ts
2248
- var import_provider_utils13 = require("@ai-sdk/provider-utils");
2249
- var import_v410 = require("zod/v4");
2250
- var computer_20241022InputSchema = (0, import_provider_utils13.lazySchema)(
2251
- () => (0, import_provider_utils13.zodSchema)(
2252
- import_v410.z.object({
2253
- action: import_v410.z.enum([
2565
+ var import_provider_utils14 = require("@ai-sdk/provider-utils");
2566
+ var import_v411 = require("zod/v4");
2567
+ var computer_20241022InputSchema = (0, import_provider_utils14.lazySchema)(
2568
+ () => (0, import_provider_utils14.zodSchema)(
2569
+ import_v411.z.object({
2570
+ action: import_v411.z.enum([
2254
2571
  "key",
2255
2572
  "type",
2256
2573
  "mouse_move",
@@ -2262,24 +2579,24 @@ var computer_20241022InputSchema = (0, import_provider_utils13.lazySchema)(
2262
2579
  "screenshot",
2263
2580
  "cursor_position"
2264
2581
  ]),
2265
- coordinate: import_v410.z.array(import_v410.z.number().int()).optional(),
2266
- text: import_v410.z.string().optional()
2582
+ coordinate: import_v411.z.array(import_v411.z.number().int()).optional(),
2583
+ text: import_v411.z.string().optional()
2267
2584
  })
2268
2585
  )
2269
2586
  );
2270
- var computer_20241022 = (0, import_provider_utils13.createProviderDefinedToolFactory)({
2587
+ var computer_20241022 = (0, import_provider_utils14.createProviderDefinedToolFactory)({
2271
2588
  id: "anthropic.computer_20241022",
2272
2589
  name: "computer",
2273
2590
  inputSchema: computer_20241022InputSchema
2274
2591
  });
2275
2592
 
2276
2593
  // src/tool/computer_20250124.ts
2277
- var import_provider_utils14 = require("@ai-sdk/provider-utils");
2278
- var import_v411 = require("zod/v4");
2279
- var computer_20250124InputSchema = (0, import_provider_utils14.lazySchema)(
2280
- () => (0, import_provider_utils14.zodSchema)(
2281
- import_v411.z.object({
2282
- action: import_v411.z.enum([
2594
+ var import_provider_utils15 = require("@ai-sdk/provider-utils");
2595
+ var import_v412 = require("zod/v4");
2596
+ var computer_20250124InputSchema = (0, import_provider_utils15.lazySchema)(
2597
+ () => (0, import_provider_utils15.zodSchema)(
2598
+ import_v412.z.object({
2599
+ action: import_v412.z.enum([
2283
2600
  "key",
2284
2601
  "hold_key",
2285
2602
  "type",
@@ -2297,82 +2614,128 @@ var computer_20250124InputSchema = (0, import_provider_utils14.lazySchema)(
2297
2614
  "wait",
2298
2615
  "screenshot"
2299
2616
  ]),
2300
- coordinate: import_v411.z.tuple([import_v411.z.number().int(), import_v411.z.number().int()]).optional(),
2301
- duration: import_v411.z.number().optional(),
2302
- scroll_amount: import_v411.z.number().optional(),
2303
- scroll_direction: import_v411.z.enum(["up", "down", "left", "right"]).optional(),
2304
- start_coordinate: import_v411.z.tuple([import_v411.z.number().int(), import_v411.z.number().int()]).optional(),
2305
- text: import_v411.z.string().optional()
2617
+ coordinate: import_v412.z.tuple([import_v412.z.number().int(), import_v412.z.number().int()]).optional(),
2618
+ duration: import_v412.z.number().optional(),
2619
+ scroll_amount: import_v412.z.number().optional(),
2620
+ scroll_direction: import_v412.z.enum(["up", "down", "left", "right"]).optional(),
2621
+ start_coordinate: import_v412.z.tuple([import_v412.z.number().int(), import_v412.z.number().int()]).optional(),
2622
+ text: import_v412.z.string().optional()
2306
2623
  })
2307
2624
  )
2308
2625
  );
2309
- var computer_20250124 = (0, import_provider_utils14.createProviderDefinedToolFactory)({
2626
+ var computer_20250124 = (0, import_provider_utils15.createProviderDefinedToolFactory)({
2310
2627
  id: "anthropic.computer_20250124",
2311
2628
  name: "computer",
2312
2629
  inputSchema: computer_20250124InputSchema
2313
2630
  });
2314
2631
 
2632
+ // src/tool/memory_20250818.ts
2633
+ var import_provider_utils16 = require("@ai-sdk/provider-utils");
2634
+ var import_v413 = require("zod/v4");
2635
+ var memory_20250818InputSchema = (0, import_provider_utils16.lazySchema)(
2636
+ () => (0, import_provider_utils16.zodSchema)(
2637
+ import_v413.z.discriminatedUnion("command", [
2638
+ import_v413.z.object({
2639
+ command: import_v413.z.literal("view"),
2640
+ path: import_v413.z.string(),
2641
+ view_range: import_v413.z.tuple([import_v413.z.number(), import_v413.z.number()]).optional()
2642
+ }),
2643
+ import_v413.z.object({
2644
+ command: import_v413.z.literal("create"),
2645
+ path: import_v413.z.string(),
2646
+ file_text: import_v413.z.string()
2647
+ }),
2648
+ import_v413.z.object({
2649
+ command: import_v413.z.literal("str_replace"),
2650
+ path: import_v413.z.string(),
2651
+ old_str: import_v413.z.string(),
2652
+ new_str: import_v413.z.string()
2653
+ }),
2654
+ import_v413.z.object({
2655
+ command: import_v413.z.literal("insert"),
2656
+ path: import_v413.z.string(),
2657
+ insert_line: import_v413.z.number(),
2658
+ insert_text: import_v413.z.string()
2659
+ }),
2660
+ import_v413.z.object({
2661
+ command: import_v413.z.literal("delete"),
2662
+ path: import_v413.z.string()
2663
+ }),
2664
+ import_v413.z.object({
2665
+ command: import_v413.z.literal("rename"),
2666
+ old_path: import_v413.z.string(),
2667
+ new_path: import_v413.z.string()
2668
+ })
2669
+ ])
2670
+ )
2671
+ );
2672
+ var memory_20250818 = (0, import_provider_utils16.createProviderDefinedToolFactory)({
2673
+ id: "anthropic.memory_20250818",
2674
+ name: "memory",
2675
+ inputSchema: memory_20250818InputSchema
2676
+ });
2677
+
2315
2678
  // src/tool/text-editor_20241022.ts
2316
- var import_provider_utils15 = require("@ai-sdk/provider-utils");
2317
- var import_v412 = require("zod/v4");
2318
- var textEditor_20241022InputSchema = (0, import_provider_utils15.lazySchema)(
2319
- () => (0, import_provider_utils15.zodSchema)(
2320
- import_v412.z.object({
2321
- command: import_v412.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
2322
- path: import_v412.z.string(),
2323
- file_text: import_v412.z.string().optional(),
2324
- insert_line: import_v412.z.number().int().optional(),
2325
- new_str: import_v412.z.string().optional(),
2326
- old_str: import_v412.z.string().optional(),
2327
- view_range: import_v412.z.array(import_v412.z.number().int()).optional()
2679
+ var import_provider_utils17 = require("@ai-sdk/provider-utils");
2680
+ var import_v414 = require("zod/v4");
2681
+ var textEditor_20241022InputSchema = (0, import_provider_utils17.lazySchema)(
2682
+ () => (0, import_provider_utils17.zodSchema)(
2683
+ import_v414.z.object({
2684
+ command: import_v414.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
2685
+ path: import_v414.z.string(),
2686
+ file_text: import_v414.z.string().optional(),
2687
+ insert_line: import_v414.z.number().int().optional(),
2688
+ new_str: import_v414.z.string().optional(),
2689
+ old_str: import_v414.z.string().optional(),
2690
+ view_range: import_v414.z.array(import_v414.z.number().int()).optional()
2328
2691
  })
2329
2692
  )
2330
2693
  );
2331
- var textEditor_20241022 = (0, import_provider_utils15.createProviderDefinedToolFactory)({
2694
+ var textEditor_20241022 = (0, import_provider_utils17.createProviderDefinedToolFactory)({
2332
2695
  id: "anthropic.text_editor_20241022",
2333
2696
  name: "str_replace_editor",
2334
2697
  inputSchema: textEditor_20241022InputSchema
2335
2698
  });
2336
2699
 
2337
2700
  // src/tool/text-editor_20250124.ts
2338
- var import_provider_utils16 = require("@ai-sdk/provider-utils");
2339
- var import_v413 = require("zod/v4");
2340
- var textEditor_20250124InputSchema = (0, import_provider_utils16.lazySchema)(
2341
- () => (0, import_provider_utils16.zodSchema)(
2342
- import_v413.z.object({
2343
- command: import_v413.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
2344
- path: import_v413.z.string(),
2345
- file_text: import_v413.z.string().optional(),
2346
- insert_line: import_v413.z.number().int().optional(),
2347
- new_str: import_v413.z.string().optional(),
2348
- old_str: import_v413.z.string().optional(),
2349
- view_range: import_v413.z.array(import_v413.z.number().int()).optional()
2701
+ var import_provider_utils18 = require("@ai-sdk/provider-utils");
2702
+ var import_v415 = require("zod/v4");
2703
+ var textEditor_20250124InputSchema = (0, import_provider_utils18.lazySchema)(
2704
+ () => (0, import_provider_utils18.zodSchema)(
2705
+ import_v415.z.object({
2706
+ command: import_v415.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
2707
+ path: import_v415.z.string(),
2708
+ file_text: import_v415.z.string().optional(),
2709
+ insert_line: import_v415.z.number().int().optional(),
2710
+ new_str: import_v415.z.string().optional(),
2711
+ old_str: import_v415.z.string().optional(),
2712
+ view_range: import_v415.z.array(import_v415.z.number().int()).optional()
2350
2713
  })
2351
2714
  )
2352
2715
  );
2353
- var textEditor_20250124 = (0, import_provider_utils16.createProviderDefinedToolFactory)({
2716
+ var textEditor_20250124 = (0, import_provider_utils18.createProviderDefinedToolFactory)({
2354
2717
  id: "anthropic.text_editor_20250124",
2355
2718
  name: "str_replace_editor",
2356
2719
  inputSchema: textEditor_20250124InputSchema
2357
2720
  });
2358
2721
 
2359
2722
  // src/tool/text-editor_20250429.ts
2360
- var import_provider_utils17 = require("@ai-sdk/provider-utils");
2361
- var import_v414 = require("zod/v4");
2362
- var textEditor_20250429InputSchema = (0, import_provider_utils17.lazySchema)(
2363
- () => (0, import_provider_utils17.zodSchema)(
2364
- import_v414.z.object({
2365
- command: import_v414.z.enum(["view", "create", "str_replace", "insert"]),
2366
- path: import_v414.z.string(),
2367
- file_text: import_v414.z.string().optional(),
2368
- insert_line: import_v414.z.number().int().optional(),
2369
- new_str: import_v414.z.string().optional(),
2370
- old_str: import_v414.z.string().optional(),
2371
- view_range: import_v414.z.array(import_v414.z.number().int()).optional()
2723
+ var import_provider_utils19 = require("@ai-sdk/provider-utils");
2724
+ var import_v416 = require("zod/v4");
2725
+ var textEditor_20250429InputSchema = (0, import_provider_utils19.lazySchema)(
2726
+ () => (0, import_provider_utils19.zodSchema)(
2727
+ import_v416.z.object({
2728
+ command: import_v416.z.enum(["view", "create", "str_replace", "insert"]),
2729
+ path: import_v416.z.string(),
2730
+ file_text: import_v416.z.string().optional(),
2731
+ insert_line: import_v416.z.number().int().optional(),
2732
+ new_str: import_v416.z.string().optional(),
2733
+ old_str: import_v416.z.string().optional(),
2734
+ view_range: import_v416.z.array(import_v416.z.number().int()).optional()
2372
2735
  })
2373
2736
  )
2374
2737
  );
2375
- var textEditor_20250429 = (0, import_provider_utils17.createProviderDefinedToolFactory)({
2738
+ var textEditor_20250429 = (0, import_provider_utils19.createProviderDefinedToolFactory)({
2376
2739
  id: "anthropic.text_editor_20250429",
2377
2740
  name: "str_replace_based_edit_tool",
2378
2741
  inputSchema: textEditor_20250429InputSchema
@@ -2409,6 +2772,19 @@ var anthropicTools = {
2409
2772
  * Tool name must be `code_execution`.
2410
2773
  */
2411
2774
  codeExecution_20250522,
2775
+ /**
2776
+ * Claude can analyze data, create visualizations, perform complex calculations,
2777
+ * run system commands, create and edit files, and process uploaded files directly within
2778
+ * the API conversation.
2779
+ *
2780
+ * The code execution tool allows Claude to run both Python and Bash commands and manipulate files,
2781
+ * including writing code, in a secure, sandboxed environment.
2782
+ *
2783
+ * This is the latest version with enhanced Bash support and file operations.
2784
+ *
2785
+ * Tool name must be `code_execution`.
2786
+ */
2787
+ codeExecution_20250825,
2412
2788
  /**
2413
2789
  * Claude can interact with computer environments through the computer use tool, which
2414
2790
  * provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
@@ -2435,6 +2811,17 @@ var anthropicTools = {
2435
2811
  * @param displayNumber - The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.
2436
2812
  */
2437
2813
  computer_20250124,
2814
+ /**
2815
+ * The memory tool enables Claude to store and retrieve information across conversations through a memory file directory.
2816
+ * Claude can create, read, update, and delete files that persist between sessions,
2817
+ * allowing it to build knowledge over time without keeping everything in the context window.
2818
+ * The memory tool operates client-side—you control where and how the data is stored through your own infrastructure.
2819
+ *
2820
+ * Supported models: Claude Sonnet 4.5, Claude Sonnet 4, Claude Opus 4.1, Claude Opus 4.
2821
+ *
2822
+ * Tool name must be `memory`.
2823
+ */
2824
+ memory_20250818,
2438
2825
  /**
2439
2826
  * Claude can use an Anthropic-defined text editor tool to view and modify text files,
2440
2827
  * helping you debug, fix, and improve your code or other text documents. This allows Claude