@ai-sdk/anthropic 2.0.2 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -38,8 +38,8 @@ module.exports = __toCommonJS(internal_exports);
38
38
 
39
39
  // src/anthropic-messages-language-model.ts
40
40
  var import_provider3 = require("@ai-sdk/provider");
41
- var import_provider_utils4 = require("@ai-sdk/provider-utils");
42
- var import_v44 = require("zod/v4");
41
+ var import_provider_utils5 = require("@ai-sdk/provider-utils");
42
+ var import_v45 = require("zod/v4");
43
43
 
44
44
  // src/anthropic-error.ts
45
45
  var import_provider_utils = require("@ai-sdk/provider-utils");
@@ -253,6 +253,14 @@ function prepareTools({
253
253
  });
254
254
  break;
255
255
  }
256
+ case "anthropic.code_execution_20250522": {
257
+ betas.add("code-execution-2025-05-22");
258
+ anthropicTools2.push({
259
+ type: "code_execution_20250522",
260
+ name: "code_execution"
261
+ });
262
+ break;
263
+ }
256
264
  default:
257
265
  toolWarnings.push({ type: "unsupported-tool", tool });
258
266
  break;
@@ -317,7 +325,30 @@ function prepareTools({
317
325
 
318
326
  // src/convert-to-anthropic-messages-prompt.ts
319
327
  var import_provider2 = require("@ai-sdk/provider");
328
+ var import_provider_utils4 = require("@ai-sdk/provider-utils");
329
+
330
+ // src/tool/code-execution_20250522.ts
320
331
  var import_provider_utils3 = require("@ai-sdk/provider-utils");
332
+ var import_v44 = require("zod/v4");
333
+ var codeExecution_20250522OutputSchema = import_v44.z.object({
334
+ type: import_v44.z.literal("code_execution_result"),
335
+ stdout: import_v44.z.string(),
336
+ stderr: import_v44.z.string(),
337
+ return_code: import_v44.z.number()
338
+ });
339
+ var factory2 = (0, import_provider_utils3.createProviderDefinedToolFactoryWithOutputSchema)({
340
+ id: "anthropic.code_execution_20250522",
341
+ name: "code_execution",
342
+ inputSchema: import_v44.z.object({
343
+ code: import_v44.z.string()
344
+ }),
345
+ outputSchema: codeExecution_20250522OutputSchema
346
+ });
347
+ var codeExecution_20250522 = (args = {}) => {
348
+ return factory2(args);
349
+ };
350
+
351
+ // src/convert-to-anthropic-messages-prompt.ts
321
352
  function convertToString(data) {
322
353
  if (typeof data === "string") {
323
354
  return Buffer.from(data, "base64").toString("utf-8");
@@ -346,7 +377,7 @@ async function convertToAnthropicMessagesPrompt({
346
377
  const messages = [];
347
378
  async function shouldEnableCitations(providerMetadata) {
348
379
  var _a2, _b2;
349
- const anthropicOptions = await (0, import_provider_utils3.parseProviderOptions)({
380
+ const anthropicOptions = await (0, import_provider_utils4.parseProviderOptions)({
350
381
  provider: "anthropic",
351
382
  providerOptions: providerMetadata,
352
383
  schema: anthropicFilePartProviderOptions
@@ -354,7 +385,7 @@ async function convertToAnthropicMessagesPrompt({
354
385
  return (_b2 = (_a2 = anthropicOptions == null ? void 0 : anthropicOptions.citations) == null ? void 0 : _a2.enabled) != null ? _b2 : false;
355
386
  }
356
387
  async function getDocumentMetadata(providerMetadata) {
357
- const anthropicOptions = await (0, import_provider_utils3.parseProviderOptions)({
388
+ const anthropicOptions = await (0, import_provider_utils4.parseProviderOptions)({
358
389
  provider: "anthropic",
359
390
  providerOptions: providerMetadata,
360
391
  schema: anthropicFilePartProviderOptions
@@ -411,7 +442,7 @@ async function convertToAnthropicMessagesPrompt({
411
442
  } : {
412
443
  type: "base64",
413
444
  media_type: part.mediaType === "image/*" ? "image/jpeg" : part.mediaType,
414
- data: (0, import_provider_utils3.convertToBase64)(part.data)
445
+ data: (0, import_provider_utils4.convertToBase64)(part.data)
415
446
  },
416
447
  cache_control: cacheControl
417
448
  });
@@ -431,7 +462,7 @@ async function convertToAnthropicMessagesPrompt({
431
462
  } : {
432
463
  type: "base64",
433
464
  media_type: "application/pdf",
434
- data: (0, import_provider_utils3.convertToBase64)(part.data)
465
+ data: (0, import_provider_utils4.convertToBase64)(part.data)
435
466
  },
436
467
  title: (_b = metadata.title) != null ? _b : part.filename,
437
468
  ...metadata.context && { context: metadata.context },
@@ -566,7 +597,7 @@ async function convertToAnthropicMessagesPrompt({
566
597
  }
567
598
  case "reasoning": {
568
599
  if (sendReasoning) {
569
- const reasoningMetadata = await (0, import_provider_utils3.parseProviderOptions)({
600
+ const reasoningMetadata = await (0, import_provider_utils4.parseProviderOptions)({
570
601
  provider: "anthropic",
571
602
  providerOptions: part.providerOptions,
572
603
  schema: anthropicReasoningMetadataSchema
@@ -617,6 +648,16 @@ async function convertToAnthropicMessagesPrompt({
617
648
  });
618
649
  break;
619
650
  }
651
+ if (part.toolName === "code_execution") {
652
+ anthropicContent.push({
653
+ type: "server_tool_use",
654
+ id: part.toolCallId,
655
+ name: "code_execution",
656
+ input: part.input,
657
+ cache_control: cacheControl
658
+ });
659
+ break;
660
+ }
620
661
  warnings.push({
621
662
  type: "other",
622
663
  message: `provider executed tool call for tool ${part.toolName} is not supported`
@@ -659,6 +700,29 @@ async function convertToAnthropicMessagesPrompt({
659
700
  });
660
701
  break;
661
702
  }
703
+ if (part.toolName === "code_execution") {
704
+ const output = part.output;
705
+ if (output.type !== "json") {
706
+ warnings.push({
707
+ type: "other",
708
+ message: `provider executed tool result output type ${output.type} for tool ${part.toolName} is not supported`
709
+ });
710
+ break;
711
+ }
712
+ const codeExecutionOutput = codeExecution_20250522OutputSchema.parse(output.value);
713
+ anthropicContent.push({
714
+ type: "code_execution_tool_result",
715
+ tool_use_id: part.toolCallId,
716
+ content: {
717
+ type: codeExecutionOutput.type,
718
+ stdout: codeExecutionOutput.stdout,
719
+ stderr: codeExecutionOutput.stderr,
720
+ return_code: codeExecutionOutput.return_code
721
+ },
722
+ cache_control: cacheControl
723
+ });
724
+ break;
725
+ }
662
726
  warnings.push({
663
727
  type: "other",
664
728
  message: `provider executed tool result for tool ${part.toolName} is not supported`
@@ -749,36 +813,36 @@ function mapAnthropicStopReason({
749
813
 
750
814
  // src/anthropic-messages-language-model.ts
751
815
  var citationSchemas = {
752
- webSearchResult: import_v44.z.object({
753
- type: import_v44.z.literal("web_search_result_location"),
754
- cited_text: import_v44.z.string(),
755
- url: import_v44.z.string(),
756
- title: import_v44.z.string(),
757
- encrypted_index: import_v44.z.string()
816
+ webSearchResult: import_v45.z.object({
817
+ type: import_v45.z.literal("web_search_result_location"),
818
+ cited_text: import_v45.z.string(),
819
+ url: import_v45.z.string(),
820
+ title: import_v45.z.string(),
821
+ encrypted_index: import_v45.z.string()
758
822
  }),
759
- pageLocation: import_v44.z.object({
760
- type: import_v44.z.literal("page_location"),
761
- cited_text: import_v44.z.string(),
762
- document_index: import_v44.z.number(),
763
- document_title: import_v44.z.string().nullable(),
764
- start_page_number: import_v44.z.number(),
765
- end_page_number: import_v44.z.number()
823
+ pageLocation: import_v45.z.object({
824
+ type: import_v45.z.literal("page_location"),
825
+ cited_text: import_v45.z.string(),
826
+ document_index: import_v45.z.number(),
827
+ document_title: import_v45.z.string().nullable(),
828
+ start_page_number: import_v45.z.number(),
829
+ end_page_number: import_v45.z.number()
766
830
  }),
767
- charLocation: import_v44.z.object({
768
- type: import_v44.z.literal("char_location"),
769
- cited_text: import_v44.z.string(),
770
- document_index: import_v44.z.number(),
771
- document_title: import_v44.z.string().nullable(),
772
- start_char_index: import_v44.z.number(),
773
- end_char_index: import_v44.z.number()
831
+ charLocation: import_v45.z.object({
832
+ type: import_v45.z.literal("char_location"),
833
+ cited_text: import_v45.z.string(),
834
+ document_index: import_v45.z.number(),
835
+ document_title: import_v45.z.string().nullable(),
836
+ start_char_index: import_v45.z.number(),
837
+ end_char_index: import_v45.z.number()
774
838
  })
775
839
  };
776
- var citationSchema = import_v44.z.discriminatedUnion("type", [
840
+ var citationSchema = import_v45.z.discriminatedUnion("type", [
777
841
  citationSchemas.webSearchResult,
778
842
  citationSchemas.pageLocation,
779
843
  citationSchemas.charLocation
780
844
  ]);
781
- var documentCitationSchema = import_v44.z.discriminatedUnion("type", [
845
+ var documentCitationSchema = import_v45.z.discriminatedUnion("type", [
782
846
  citationSchemas.pageLocation,
783
847
  citationSchemas.charLocation
784
848
  ]);
@@ -827,7 +891,7 @@ var AnthropicMessagesLanguageModel = class {
827
891
  var _a;
828
892
  this.modelId = modelId;
829
893
  this.config = config;
830
- this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils4.generateId;
894
+ this.generateId = (_a = config.generateId) != null ? _a : import_provider_utils5.generateId;
831
895
  }
832
896
  supportsUrl(url) {
833
897
  return url.protocol === "https:";
@@ -896,7 +960,7 @@ var AnthropicMessagesLanguageModel = class {
896
960
  description: "Respond with a JSON object.",
897
961
  inputSchema: responseFormat.schema
898
962
  } : void 0;
899
- const anthropicOptions = await (0, import_provider_utils4.parseProviderOptions)({
963
+ const anthropicOptions = await (0, import_provider_utils5.parseProviderOptions)({
900
964
  provider: "anthropic",
901
965
  providerOptions,
902
966
  schema: anthropicProviderOptions
@@ -988,8 +1052,8 @@ var AnthropicMessagesLanguageModel = class {
988
1052
  betas,
989
1053
  headers
990
1054
  }) {
991
- return (0, import_provider_utils4.combineHeaders)(
992
- await (0, import_provider_utils4.resolve)(this.config.headers),
1055
+ return (0, import_provider_utils5.combineHeaders)(
1056
+ await (0, import_provider_utils5.resolve)(this.config.headers),
993
1057
  betas.size > 0 ? { "anthropic-beta": Array.from(betas).join(",") } : {},
994
1058
  headers
995
1059
  );
@@ -1033,12 +1097,12 @@ var AnthropicMessagesLanguageModel = class {
1033
1097
  responseHeaders,
1034
1098
  value: response,
1035
1099
  rawValue: rawResponse
1036
- } = await (0, import_provider_utils4.postJsonToApi)({
1100
+ } = await (0, import_provider_utils5.postJsonToApi)({
1037
1101
  url: this.buildRequestUrl(false),
1038
1102
  headers: await this.getHeaders({ betas, headers: options.headers }),
1039
1103
  body: this.transformRequestBody(args),
1040
1104
  failedResponseHandler: anthropicFailedResponseHandler,
1041
- successfulResponseHandler: (0, import_provider_utils4.createJsonResponseHandler)(
1105
+ successfulResponseHandler: (0, import_provider_utils5.createJsonResponseHandler)(
1042
1106
  anthropicMessagesResponseSchema
1043
1107
  ),
1044
1108
  abortSignal: options.abortSignal,
@@ -1103,7 +1167,7 @@ var AnthropicMessagesLanguageModel = class {
1103
1167
  break;
1104
1168
  }
1105
1169
  case "server_tool_use": {
1106
- if (part.name === "web_search") {
1170
+ if (part.name === "web_search" || part.name === "code_execution") {
1107
1171
  content.push({
1108
1172
  type: "tool-call",
1109
1173
  toolCallId: part.id,
@@ -1161,6 +1225,35 @@ var AnthropicMessagesLanguageModel = class {
1161
1225
  }
1162
1226
  break;
1163
1227
  }
1228
+ case "code_execution_tool_result": {
1229
+ if (part.content.type === "code_execution_result") {
1230
+ content.push({
1231
+ type: "tool-result",
1232
+ toolCallId: part.tool_use_id,
1233
+ toolName: "code_execution",
1234
+ result: {
1235
+ type: part.content.type,
1236
+ stdout: part.content.stdout,
1237
+ stderr: part.content.stderr,
1238
+ return_code: part.content.return_code
1239
+ },
1240
+ providerExecuted: true
1241
+ });
1242
+ } else if (part.content.type === "code_execution_tool_result_error") {
1243
+ content.push({
1244
+ type: "tool-result",
1245
+ toolCallId: part.tool_use_id,
1246
+ toolName: "code_execution",
1247
+ isError: true,
1248
+ result: {
1249
+ type: "code_execution_tool_result_error",
1250
+ errorCode: part.content.error_code
1251
+ },
1252
+ providerExecuted: true
1253
+ });
1254
+ }
1255
+ break;
1256
+ }
1164
1257
  }
1165
1258
  }
1166
1259
  return {
@@ -1195,12 +1288,12 @@ var AnthropicMessagesLanguageModel = class {
1195
1288
  const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
1196
1289
  const citationDocuments = this.extractCitationDocuments(options.prompt);
1197
1290
  const body = { ...args, stream: true };
1198
- const { responseHeaders, value: response } = await (0, import_provider_utils4.postJsonToApi)({
1291
+ const { responseHeaders, value: response } = await (0, import_provider_utils5.postJsonToApi)({
1199
1292
  url: this.buildRequestUrl(true),
1200
1293
  headers: await this.getHeaders({ betas, headers: options.headers }),
1201
1294
  body: this.transformRequestBody(body),
1202
1295
  failedResponseHandler: anthropicFailedResponseHandler,
1203
- successfulResponseHandler: (0, import_provider_utils4.createEventSourceResponseHandler)(
1296
+ successfulResponseHandler: (0, import_provider_utils5.createEventSourceResponseHandler)(
1204
1297
  anthropicMessagesChunkSchema
1205
1298
  ),
1206
1299
  abortSignal: options.abortSignal,
@@ -1286,7 +1379,7 @@ var AnthropicMessagesLanguageModel = class {
1286
1379
  return;
1287
1380
  }
1288
1381
  case "server_tool_use": {
1289
- if (value.content_block.name === "web_search") {
1382
+ if (value.content_block.name === "web_search" || value.content_block.name === "code_execution") {
1290
1383
  contentBlocks[value.index] = {
1291
1384
  type: "tool-call",
1292
1385
  toolCallId: value.content_block.id,
@@ -1351,6 +1444,36 @@ var AnthropicMessagesLanguageModel = class {
1351
1444
  }
1352
1445
  return;
1353
1446
  }
1447
+ case "code_execution_tool_result": {
1448
+ const part = value.content_block;
1449
+ if (part.content.type === "code_execution_result") {
1450
+ controller.enqueue({
1451
+ type: "tool-result",
1452
+ toolCallId: part.tool_use_id,
1453
+ toolName: "code_execution",
1454
+ result: {
1455
+ type: part.content.type,
1456
+ stdout: part.content.stdout,
1457
+ stderr: part.content.stderr,
1458
+ return_code: part.content.return_code
1459
+ },
1460
+ providerExecuted: true
1461
+ });
1462
+ } else if (part.content.type === "code_execution_tool_result_error") {
1463
+ controller.enqueue({
1464
+ type: "tool-result",
1465
+ toolCallId: part.tool_use_id,
1466
+ toolName: "code_execution",
1467
+ isError: true,
1468
+ result: {
1469
+ type: "code_execution_tool_result_error",
1470
+ errorCode: part.content.error_code
1471
+ },
1472
+ providerExecuted: true
1473
+ });
1474
+ }
1475
+ return;
1476
+ }
1354
1477
  default: {
1355
1478
  const _exhaustiveCheck = contentBlockType;
1356
1479
  throw new Error(
@@ -1523,215 +1646,247 @@ var AnthropicMessagesLanguageModel = class {
1523
1646
  };
1524
1647
  }
1525
1648
  };
1526
- var anthropicMessagesResponseSchema = import_v44.z.object({
1527
- type: import_v44.z.literal("message"),
1528
- id: import_v44.z.string().nullish(),
1529
- model: import_v44.z.string().nullish(),
1530
- content: import_v44.z.array(
1531
- import_v44.z.discriminatedUnion("type", [
1532
- import_v44.z.object({
1533
- type: import_v44.z.literal("text"),
1534
- text: import_v44.z.string(),
1535
- citations: import_v44.z.array(citationSchema).optional()
1649
+ var anthropicMessagesResponseSchema = import_v45.z.object({
1650
+ type: import_v45.z.literal("message"),
1651
+ id: import_v45.z.string().nullish(),
1652
+ model: import_v45.z.string().nullish(),
1653
+ content: import_v45.z.array(
1654
+ import_v45.z.discriminatedUnion("type", [
1655
+ import_v45.z.object({
1656
+ type: import_v45.z.literal("text"),
1657
+ text: import_v45.z.string(),
1658
+ citations: import_v45.z.array(citationSchema).optional()
1536
1659
  }),
1537
- import_v44.z.object({
1538
- type: import_v44.z.literal("thinking"),
1539
- thinking: import_v44.z.string(),
1540
- signature: import_v44.z.string()
1660
+ import_v45.z.object({
1661
+ type: import_v45.z.literal("thinking"),
1662
+ thinking: import_v45.z.string(),
1663
+ signature: import_v45.z.string()
1541
1664
  }),
1542
- import_v44.z.object({
1543
- type: import_v44.z.literal("redacted_thinking"),
1544
- data: import_v44.z.string()
1665
+ import_v45.z.object({
1666
+ type: import_v45.z.literal("redacted_thinking"),
1667
+ data: import_v45.z.string()
1545
1668
  }),
1546
- import_v44.z.object({
1547
- type: import_v44.z.literal("tool_use"),
1548
- id: import_v44.z.string(),
1549
- name: import_v44.z.string(),
1550
- input: import_v44.z.unknown()
1669
+ import_v45.z.object({
1670
+ type: import_v45.z.literal("tool_use"),
1671
+ id: import_v45.z.string(),
1672
+ name: import_v45.z.string(),
1673
+ input: import_v45.z.unknown()
1551
1674
  }),
1552
- import_v44.z.object({
1553
- type: import_v44.z.literal("server_tool_use"),
1554
- id: import_v44.z.string(),
1555
- name: import_v44.z.string(),
1556
- input: import_v44.z.record(import_v44.z.string(), import_v44.z.unknown()).nullish()
1675
+ import_v45.z.object({
1676
+ type: import_v45.z.literal("server_tool_use"),
1677
+ id: import_v45.z.string(),
1678
+ name: import_v45.z.string(),
1679
+ input: import_v45.z.record(import_v45.z.string(), import_v45.z.unknown()).nullish()
1557
1680
  }),
1558
- import_v44.z.object({
1559
- type: import_v44.z.literal("web_search_tool_result"),
1560
- tool_use_id: import_v44.z.string(),
1561
- content: import_v44.z.union([
1562
- import_v44.z.array(
1563
- import_v44.z.object({
1564
- type: import_v44.z.literal("web_search_result"),
1565
- url: import_v44.z.string(),
1566
- title: import_v44.z.string(),
1567
- encrypted_content: import_v44.z.string(),
1568
- page_age: import_v44.z.string().nullish()
1681
+ import_v45.z.object({
1682
+ type: import_v45.z.literal("web_search_tool_result"),
1683
+ tool_use_id: import_v45.z.string(),
1684
+ content: import_v45.z.union([
1685
+ import_v45.z.array(
1686
+ import_v45.z.object({
1687
+ type: import_v45.z.literal("web_search_result"),
1688
+ url: import_v45.z.string(),
1689
+ title: import_v45.z.string(),
1690
+ encrypted_content: import_v45.z.string(),
1691
+ page_age: import_v45.z.string().nullish()
1569
1692
  })
1570
1693
  ),
1571
- import_v44.z.object({
1572
- type: import_v44.z.literal("web_search_tool_result_error"),
1573
- error_code: import_v44.z.string()
1694
+ import_v45.z.object({
1695
+ type: import_v45.z.literal("web_search_tool_result_error"),
1696
+ error_code: import_v45.z.string()
1697
+ })
1698
+ ])
1699
+ }),
1700
+ import_v45.z.object({
1701
+ type: import_v45.z.literal("code_execution_tool_result"),
1702
+ tool_use_id: import_v45.z.string(),
1703
+ content: import_v45.z.union([
1704
+ import_v45.z.object({
1705
+ type: import_v45.z.literal("code_execution_result"),
1706
+ stdout: import_v45.z.string(),
1707
+ stderr: import_v45.z.string(),
1708
+ return_code: import_v45.z.number()
1709
+ }),
1710
+ import_v45.z.object({
1711
+ type: import_v45.z.literal("code_execution_tool_result_error"),
1712
+ error_code: import_v45.z.string()
1574
1713
  })
1575
1714
  ])
1576
1715
  })
1577
1716
  ])
1578
1717
  ),
1579
- stop_reason: import_v44.z.string().nullish(),
1580
- usage: import_v44.z.looseObject({
1581
- input_tokens: import_v44.z.number(),
1582
- output_tokens: import_v44.z.number(),
1583
- cache_creation_input_tokens: import_v44.z.number().nullish(),
1584
- cache_read_input_tokens: import_v44.z.number().nullish()
1718
+ stop_reason: import_v45.z.string().nullish(),
1719
+ usage: import_v45.z.looseObject({
1720
+ input_tokens: import_v45.z.number(),
1721
+ output_tokens: import_v45.z.number(),
1722
+ cache_creation_input_tokens: import_v45.z.number().nullish(),
1723
+ cache_read_input_tokens: import_v45.z.number().nullish()
1585
1724
  })
1586
1725
  });
1587
- var anthropicMessagesChunkSchema = import_v44.z.discriminatedUnion("type", [
1588
- import_v44.z.object({
1589
- type: import_v44.z.literal("message_start"),
1590
- message: import_v44.z.object({
1591
- id: import_v44.z.string().nullish(),
1592
- model: import_v44.z.string().nullish(),
1593
- usage: import_v44.z.looseObject({
1594
- input_tokens: import_v44.z.number(),
1595
- output_tokens: import_v44.z.number(),
1596
- cache_creation_input_tokens: import_v44.z.number().nullish(),
1597
- cache_read_input_tokens: import_v44.z.number().nullish()
1726
+ var anthropicMessagesChunkSchema = import_v45.z.discriminatedUnion("type", [
1727
+ import_v45.z.object({
1728
+ type: import_v45.z.literal("message_start"),
1729
+ message: import_v45.z.object({
1730
+ id: import_v45.z.string().nullish(),
1731
+ model: import_v45.z.string().nullish(),
1732
+ usage: import_v45.z.looseObject({
1733
+ input_tokens: import_v45.z.number(),
1734
+ output_tokens: import_v45.z.number(),
1735
+ cache_creation_input_tokens: import_v45.z.number().nullish(),
1736
+ cache_read_input_tokens: import_v45.z.number().nullish()
1598
1737
  })
1599
1738
  })
1600
1739
  }),
1601
- import_v44.z.object({
1602
- type: import_v44.z.literal("content_block_start"),
1603
- index: import_v44.z.number(),
1604
- content_block: import_v44.z.discriminatedUnion("type", [
1605
- import_v44.z.object({
1606
- type: import_v44.z.literal("text"),
1607
- text: import_v44.z.string()
1740
+ import_v45.z.object({
1741
+ type: import_v45.z.literal("content_block_start"),
1742
+ index: import_v45.z.number(),
1743
+ content_block: import_v45.z.discriminatedUnion("type", [
1744
+ import_v45.z.object({
1745
+ type: import_v45.z.literal("text"),
1746
+ text: import_v45.z.string()
1608
1747
  }),
1609
- import_v44.z.object({
1610
- type: import_v44.z.literal("thinking"),
1611
- thinking: import_v44.z.string()
1748
+ import_v45.z.object({
1749
+ type: import_v45.z.literal("thinking"),
1750
+ thinking: import_v45.z.string()
1612
1751
  }),
1613
- import_v44.z.object({
1614
- type: import_v44.z.literal("tool_use"),
1615
- id: import_v44.z.string(),
1616
- name: import_v44.z.string()
1752
+ import_v45.z.object({
1753
+ type: import_v45.z.literal("tool_use"),
1754
+ id: import_v45.z.string(),
1755
+ name: import_v45.z.string()
1617
1756
  }),
1618
- import_v44.z.object({
1619
- type: import_v44.z.literal("redacted_thinking"),
1620
- data: import_v44.z.string()
1757
+ import_v45.z.object({
1758
+ type: import_v45.z.literal("redacted_thinking"),
1759
+ data: import_v45.z.string()
1621
1760
  }),
1622
- import_v44.z.object({
1623
- type: import_v44.z.literal("server_tool_use"),
1624
- id: import_v44.z.string(),
1625
- name: import_v44.z.string(),
1626
- input: import_v44.z.record(import_v44.z.string(), import_v44.z.unknown()).nullish()
1761
+ import_v45.z.object({
1762
+ type: import_v45.z.literal("server_tool_use"),
1763
+ id: import_v45.z.string(),
1764
+ name: import_v45.z.string(),
1765
+ input: import_v45.z.record(import_v45.z.string(), import_v45.z.unknown()).nullish()
1627
1766
  }),
1628
- import_v44.z.object({
1629
- type: import_v44.z.literal("web_search_tool_result"),
1630
- tool_use_id: import_v44.z.string(),
1631
- content: import_v44.z.union([
1632
- import_v44.z.array(
1633
- import_v44.z.object({
1634
- type: import_v44.z.literal("web_search_result"),
1635
- url: import_v44.z.string(),
1636
- title: import_v44.z.string(),
1637
- encrypted_content: import_v44.z.string(),
1638
- page_age: import_v44.z.string().nullish()
1767
+ import_v45.z.object({
1768
+ type: import_v45.z.literal("web_search_tool_result"),
1769
+ tool_use_id: import_v45.z.string(),
1770
+ content: import_v45.z.union([
1771
+ import_v45.z.array(
1772
+ import_v45.z.object({
1773
+ type: import_v45.z.literal("web_search_result"),
1774
+ url: import_v45.z.string(),
1775
+ title: import_v45.z.string(),
1776
+ encrypted_content: import_v45.z.string(),
1777
+ page_age: import_v45.z.string().nullish()
1639
1778
  })
1640
1779
  ),
1641
- import_v44.z.object({
1642
- type: import_v44.z.literal("web_search_tool_result_error"),
1643
- error_code: import_v44.z.string()
1780
+ import_v45.z.object({
1781
+ type: import_v45.z.literal("web_search_tool_result_error"),
1782
+ error_code: import_v45.z.string()
1783
+ })
1784
+ ])
1785
+ }),
1786
+ import_v45.z.object({
1787
+ type: import_v45.z.literal("code_execution_tool_result"),
1788
+ tool_use_id: import_v45.z.string(),
1789
+ content: import_v45.z.union([
1790
+ import_v45.z.object({
1791
+ type: import_v45.z.literal("code_execution_result"),
1792
+ stdout: import_v45.z.string(),
1793
+ stderr: import_v45.z.string(),
1794
+ return_code: import_v45.z.number()
1795
+ }),
1796
+ import_v45.z.object({
1797
+ type: import_v45.z.literal("code_execution_tool_result_error"),
1798
+ error_code: import_v45.z.string()
1644
1799
  })
1645
1800
  ])
1646
1801
  })
1647
1802
  ])
1648
1803
  }),
1649
- import_v44.z.object({
1650
- type: import_v44.z.literal("content_block_delta"),
1651
- index: import_v44.z.number(),
1652
- delta: import_v44.z.discriminatedUnion("type", [
1653
- import_v44.z.object({
1654
- type: import_v44.z.literal("input_json_delta"),
1655
- partial_json: import_v44.z.string()
1804
+ import_v45.z.object({
1805
+ type: import_v45.z.literal("content_block_delta"),
1806
+ index: import_v45.z.number(),
1807
+ delta: import_v45.z.discriminatedUnion("type", [
1808
+ import_v45.z.object({
1809
+ type: import_v45.z.literal("input_json_delta"),
1810
+ partial_json: import_v45.z.string()
1656
1811
  }),
1657
- import_v44.z.object({
1658
- type: import_v44.z.literal("text_delta"),
1659
- text: import_v44.z.string()
1812
+ import_v45.z.object({
1813
+ type: import_v45.z.literal("text_delta"),
1814
+ text: import_v45.z.string()
1660
1815
  }),
1661
- import_v44.z.object({
1662
- type: import_v44.z.literal("thinking_delta"),
1663
- thinking: import_v44.z.string()
1816
+ import_v45.z.object({
1817
+ type: import_v45.z.literal("thinking_delta"),
1818
+ thinking: import_v45.z.string()
1664
1819
  }),
1665
- import_v44.z.object({
1666
- type: import_v44.z.literal("signature_delta"),
1667
- signature: import_v44.z.string()
1820
+ import_v45.z.object({
1821
+ type: import_v45.z.literal("signature_delta"),
1822
+ signature: import_v45.z.string()
1668
1823
  }),
1669
- import_v44.z.object({
1670
- type: import_v44.z.literal("citations_delta"),
1824
+ import_v45.z.object({
1825
+ type: import_v45.z.literal("citations_delta"),
1671
1826
  citation: citationSchema
1672
1827
  })
1673
1828
  ])
1674
1829
  }),
1675
- import_v44.z.object({
1676
- type: import_v44.z.literal("content_block_stop"),
1677
- index: import_v44.z.number()
1830
+ import_v45.z.object({
1831
+ type: import_v45.z.literal("content_block_stop"),
1832
+ index: import_v45.z.number()
1678
1833
  }),
1679
- import_v44.z.object({
1680
- type: import_v44.z.literal("error"),
1681
- error: import_v44.z.object({
1682
- type: import_v44.z.string(),
1683
- message: import_v44.z.string()
1834
+ import_v45.z.object({
1835
+ type: import_v45.z.literal("error"),
1836
+ error: import_v45.z.object({
1837
+ type: import_v45.z.string(),
1838
+ message: import_v45.z.string()
1684
1839
  })
1685
1840
  }),
1686
- import_v44.z.object({
1687
- type: import_v44.z.literal("message_delta"),
1688
- delta: import_v44.z.object({ stop_reason: import_v44.z.string().nullish() }),
1689
- usage: import_v44.z.object({ output_tokens: import_v44.z.number() })
1841
+ import_v45.z.object({
1842
+ type: import_v45.z.literal("message_delta"),
1843
+ delta: import_v45.z.object({ stop_reason: import_v45.z.string().nullish() }),
1844
+ usage: import_v45.z.object({ output_tokens: import_v45.z.number() })
1690
1845
  }),
1691
- import_v44.z.object({
1692
- type: import_v44.z.literal("message_stop")
1846
+ import_v45.z.object({
1847
+ type: import_v45.z.literal("message_stop")
1693
1848
  }),
1694
- import_v44.z.object({
1695
- type: import_v44.z.literal("ping")
1849
+ import_v45.z.object({
1850
+ type: import_v45.z.literal("ping")
1696
1851
  })
1697
1852
  ]);
1698
- var anthropicReasoningMetadataSchema = import_v44.z.object({
1699
- signature: import_v44.z.string().optional(),
1700
- redactedData: import_v44.z.string().optional()
1853
+ var anthropicReasoningMetadataSchema = import_v45.z.object({
1854
+ signature: import_v45.z.string().optional(),
1855
+ redactedData: import_v45.z.string().optional()
1701
1856
  });
1702
1857
 
1703
1858
  // src/tool/bash_20241022.ts
1704
- var import_provider_utils5 = require("@ai-sdk/provider-utils");
1705
- var import_v45 = __toESM(require("zod/v4"));
1706
- var bash_20241022 = (0, import_provider_utils5.createProviderDefinedToolFactory)({
1859
+ var import_provider_utils6 = require("@ai-sdk/provider-utils");
1860
+ var import_v46 = __toESM(require("zod/v4"));
1861
+ var bash_20241022 = (0, import_provider_utils6.createProviderDefinedToolFactory)({
1707
1862
  id: "anthropic.bash_20241022",
1708
1863
  name: "bash",
1709
- inputSchema: import_v45.default.object({
1710
- command: import_v45.default.string(),
1711
- restart: import_v45.default.boolean().optional()
1864
+ inputSchema: import_v46.default.object({
1865
+ command: import_v46.default.string(),
1866
+ restart: import_v46.default.boolean().optional()
1712
1867
  })
1713
1868
  });
1714
1869
 
1715
1870
  // src/tool/bash_20250124.ts
1716
- var import_provider_utils6 = require("@ai-sdk/provider-utils");
1717
- var import_v46 = __toESM(require("zod/v4"));
1718
- var bash_20250124 = (0, import_provider_utils6.createProviderDefinedToolFactory)({
1871
+ var import_provider_utils7 = require("@ai-sdk/provider-utils");
1872
+ var import_v47 = __toESM(require("zod/v4"));
1873
+ var bash_20250124 = (0, import_provider_utils7.createProviderDefinedToolFactory)({
1719
1874
  id: "anthropic.bash_20250124",
1720
1875
  name: "bash",
1721
- inputSchema: import_v46.default.object({
1722
- command: import_v46.default.string(),
1723
- restart: import_v46.default.boolean().optional()
1876
+ inputSchema: import_v47.default.object({
1877
+ command: import_v47.default.string(),
1878
+ restart: import_v47.default.boolean().optional()
1724
1879
  })
1725
1880
  });
1726
1881
 
1727
1882
  // src/tool/computer_20241022.ts
1728
- var import_provider_utils7 = require("@ai-sdk/provider-utils");
1729
- var import_v47 = require("zod/v4");
1730
- var computer_20241022 = (0, import_provider_utils7.createProviderDefinedToolFactory)({
1883
+ var import_provider_utils8 = require("@ai-sdk/provider-utils");
1884
+ var import_v48 = require("zod/v4");
1885
+ var computer_20241022 = (0, import_provider_utils8.createProviderDefinedToolFactory)({
1731
1886
  id: "anthropic.computer_20241022",
1732
1887
  name: "computer",
1733
- inputSchema: import_v47.z.object({
1734
- action: import_v47.z.enum([
1888
+ inputSchema: import_v48.z.object({
1889
+ action: import_v48.z.enum([
1735
1890
  "key",
1736
1891
  "type",
1737
1892
  "mouse_move",
@@ -1743,19 +1898,19 @@ var computer_20241022 = (0, import_provider_utils7.createProviderDefinedToolFact
1743
1898
  "screenshot",
1744
1899
  "cursor_position"
1745
1900
  ]),
1746
- coordinate: import_v47.z.array(import_v47.z.number().int()).optional(),
1747
- text: import_v47.z.string().optional()
1901
+ coordinate: import_v48.z.array(import_v48.z.number().int()).optional(),
1902
+ text: import_v48.z.string().optional()
1748
1903
  })
1749
1904
  });
1750
1905
 
1751
1906
  // src/tool/computer_20250124.ts
1752
- var import_provider_utils8 = require("@ai-sdk/provider-utils");
1753
- var import_v48 = require("zod/v4");
1754
- var computer_20250124 = (0, import_provider_utils8.createProviderDefinedToolFactory)({
1907
+ var import_provider_utils9 = require("@ai-sdk/provider-utils");
1908
+ var import_v49 = require("zod/v4");
1909
+ var computer_20250124 = (0, import_provider_utils9.createProviderDefinedToolFactory)({
1755
1910
  id: "anthropic.computer_20250124",
1756
1911
  name: "computer",
1757
- inputSchema: import_v48.z.object({
1758
- action: import_v48.z.enum([
1912
+ inputSchema: import_v49.z.object({
1913
+ action: import_v49.z.enum([
1759
1914
  "key",
1760
1915
  "hold_key",
1761
1916
  "type",
@@ -1773,37 +1928,20 @@ var computer_20250124 = (0, import_provider_utils8.createProviderDefinedToolFact
1773
1928
  "wait",
1774
1929
  "screenshot"
1775
1930
  ]),
1776
- coordinate: import_v48.z.tuple([import_v48.z.number().int(), import_v48.z.number().int()]).optional(),
1777
- duration: import_v48.z.number().optional(),
1778
- scroll_amount: import_v48.z.number().optional(),
1779
- scroll_direction: import_v48.z.enum(["up", "down", "left", "right"]).optional(),
1780
- start_coordinate: import_v48.z.tuple([import_v48.z.number().int(), import_v48.z.number().int()]).optional(),
1781
- text: import_v48.z.string().optional()
1931
+ coordinate: import_v49.z.tuple([import_v49.z.number().int(), import_v49.z.number().int()]).optional(),
1932
+ duration: import_v49.z.number().optional(),
1933
+ scroll_amount: import_v49.z.number().optional(),
1934
+ scroll_direction: import_v49.z.enum(["up", "down", "left", "right"]).optional(),
1935
+ start_coordinate: import_v49.z.tuple([import_v49.z.number().int(), import_v49.z.number().int()]).optional(),
1936
+ text: import_v49.z.string().optional()
1782
1937
  })
1783
1938
  });
1784
1939
 
1785
1940
  // src/tool/text-editor_20241022.ts
1786
- var import_provider_utils9 = require("@ai-sdk/provider-utils");
1787
- var import_v49 = require("zod/v4");
1788
- var textEditor_20241022 = (0, import_provider_utils9.createProviderDefinedToolFactory)({
1789
- id: "anthropic.text_editor_20241022",
1790
- name: "str_replace_editor",
1791
- inputSchema: import_v49.z.object({
1792
- command: import_v49.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
1793
- path: import_v49.z.string(),
1794
- file_text: import_v49.z.string().optional(),
1795
- insert_line: import_v49.z.number().int().optional(),
1796
- new_str: import_v49.z.string().optional(),
1797
- old_str: import_v49.z.string().optional(),
1798
- view_range: import_v49.z.array(import_v49.z.number().int()).optional()
1799
- })
1800
- });
1801
-
1802
- // src/tool/text-editor_20250124.ts
1803
1941
  var import_provider_utils10 = require("@ai-sdk/provider-utils");
1804
1942
  var import_v410 = require("zod/v4");
1805
- var textEditor_20250124 = (0, import_provider_utils10.createProviderDefinedToolFactory)({
1806
- id: "anthropic.text_editor_20250124",
1943
+ var textEditor_20241022 = (0, import_provider_utils10.createProviderDefinedToolFactory)({
1944
+ id: "anthropic.text_editor_20241022",
1807
1945
  name: "str_replace_editor",
1808
1946
  inputSchema: import_v410.z.object({
1809
1947
  command: import_v410.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
@@ -1816,14 +1954,14 @@ var textEditor_20250124 = (0, import_provider_utils10.createProviderDefinedToolF
1816
1954
  })
1817
1955
  });
1818
1956
 
1819
- // src/tool/text-editor_20250429.ts
1957
+ // src/tool/text-editor_20250124.ts
1820
1958
  var import_provider_utils11 = require("@ai-sdk/provider-utils");
1821
1959
  var import_v411 = require("zod/v4");
1822
- var textEditor_20250429 = (0, import_provider_utils11.createProviderDefinedToolFactory)({
1823
- id: "anthropic.text_editor_20250429",
1824
- name: "str_replace_based_edit_tool",
1960
+ var textEditor_20250124 = (0, import_provider_utils11.createProviderDefinedToolFactory)({
1961
+ id: "anthropic.text_editor_20250124",
1962
+ name: "str_replace_editor",
1825
1963
  inputSchema: import_v411.z.object({
1826
- command: import_v411.z.enum(["view", "create", "str_replace", "insert"]),
1964
+ command: import_v411.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
1827
1965
  path: import_v411.z.string(),
1828
1966
  file_text: import_v411.z.string().optional(),
1829
1967
  insert_line: import_v411.z.number().int().optional(),
@@ -1833,6 +1971,23 @@ var textEditor_20250429 = (0, import_provider_utils11.createProviderDefinedToolF
1833
1971
  })
1834
1972
  });
1835
1973
 
1974
+ // src/tool/text-editor_20250429.ts
1975
+ var import_provider_utils12 = require("@ai-sdk/provider-utils");
1976
+ var import_v412 = require("zod/v4");
1977
+ var textEditor_20250429 = (0, import_provider_utils12.createProviderDefinedToolFactory)({
1978
+ id: "anthropic.text_editor_20250429",
1979
+ name: "str_replace_based_edit_tool",
1980
+ inputSchema: import_v412.z.object({
1981
+ command: import_v412.z.enum(["view", "create", "str_replace", "insert"]),
1982
+ path: import_v412.z.string(),
1983
+ file_text: import_v412.z.string().optional(),
1984
+ insert_line: import_v412.z.number().int().optional(),
1985
+ new_str: import_v412.z.string().optional(),
1986
+ old_str: import_v412.z.string().optional(),
1987
+ view_range: import_v412.z.array(import_v412.z.number().int()).optional()
1988
+ })
1989
+ });
1990
+
1836
1991
  // src/anthropic-tools.ts
1837
1992
  var anthropicTools = {
1838
1993
  /**
@@ -1894,7 +2049,11 @@ var anthropicTools = {
1894
2049
  * @param blockedDomains - Optional list of domains that Claude should avoid when searching.
1895
2050
  * @param userLocation - Optional user location information to provide geographically relevant search results.
1896
2051
  */
1897
- webSearch_20250305
2052
+ webSearch_20250305,
2053
+ /**
2054
+ * Creates a tool for executing Python code. Must have name "code_execution".
2055
+ */
2056
+ codeExecution_20250522
1898
2057
  };
1899
2058
  // Annotate the CommonJS export names for ESM import in node:
1900
2059
  0 && (module.exports = {