@ai-sdk/anthropic 2.0.71 → 2.0.73

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.mjs CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  } from "@ai-sdk/provider-utils";
12
12
 
13
13
  // src/version.ts
14
- var VERSION = true ? "2.0.71" : "0.0.0-test";
14
+ var VERSION = true ? "2.0.73" : "0.0.0-test";
15
15
 
16
16
  // src/anthropic-messages-language-model.ts
17
17
  import {
@@ -1013,6 +1013,13 @@ async function prepareTools({
1013
1013
  });
1014
1014
  break;
1015
1015
  }
1016
+ case "anthropic.code_execution_20260120": {
1017
+ anthropicTools2.push({
1018
+ type: "code_execution_20260120",
1019
+ name: "code_execution"
1020
+ });
1021
+ break;
1022
+ }
1016
1023
  case "anthropic.computer_20250124": {
1017
1024
  betas.add("computer-use-2025-01-24");
1018
1025
  anthropicTools2.push({
@@ -2211,7 +2218,7 @@ var AnthropicMessagesLanguageModel = class {
2211
2218
  betas.add("skills-2025-10-02");
2212
2219
  betas.add("files-api-2025-04-14");
2213
2220
  if (!(tools == null ? void 0 : tools.some(
2214
- (tool) => tool.type === "provider-defined" && tool.id === "anthropic.code_execution_20250825"
2221
+ (tool) => tool.type === "provider-defined" && (tool.id === "anthropic.code_execution_20250825" || tool.id === "anthropic.code_execution_20260120")
2215
2222
  ))) {
2216
2223
  warnings.push({
2217
2224
  type: "other",
@@ -3235,7 +3242,7 @@ function getModelCapabilities(modelId) {
3235
3242
  supportsStructuredOutput: true,
3236
3243
  isKnownModel: true
3237
3244
  };
3238
- } else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5")) {
3245
+ } else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5") || modelId.includes("claude-haiku-4-5")) {
3239
3246
  return {
3240
3247
  maxOutputTokens: 64e3,
3241
3248
  supportsStructuredOutput: true,
@@ -3247,7 +3254,7 @@ function getModelCapabilities(modelId) {
3247
3254
  supportsStructuredOutput: true,
3248
3255
  isKnownModel: true
3249
3256
  };
3250
- } else if (modelId.includes("claude-sonnet-4-") || modelId.includes("claude-3-7-sonnet") || modelId.includes("claude-haiku-4-5")) {
3257
+ } else if (modelId.includes("claude-sonnet-4-") || modelId.includes("claude-3-7-sonnet")) {
3251
3258
  return {
3252
3259
  maxOutputTokens: 64e3,
3253
3260
  supportsStructuredOutput: false,
@@ -3322,17 +3329,126 @@ var bash_20250124 = createProviderDefinedToolFactory3({
3322
3329
  inputSchema: bash_20250124InputSchema
3323
3330
  });
3324
3331
 
3325
- // src/tool/computer_20241022.ts
3332
+ // src/tool/code-execution_20260120.ts
3326
3333
  import {
3327
- createProviderDefinedToolFactory as createProviderDefinedToolFactory4,
3334
+ createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema5,
3328
3335
  lazySchema as lazySchema10,
3329
3336
  zodSchema as zodSchema10
3330
3337
  } from "@ai-sdk/provider-utils";
3331
3338
  import { z as z11 } from "zod/v4";
3332
- var computer_20241022InputSchema = lazySchema10(
3339
+ var codeExecution_20260120OutputSchema = lazySchema10(
3333
3340
  () => zodSchema10(
3334
- z11.object({
3335
- action: z11.enum([
3341
+ z11.discriminatedUnion("type", [
3342
+ z11.object({
3343
+ type: z11.literal("code_execution_result"),
3344
+ stdout: z11.string(),
3345
+ stderr: z11.string(),
3346
+ return_code: z11.number(),
3347
+ content: z11.array(
3348
+ z11.object({
3349
+ type: z11.literal("code_execution_output"),
3350
+ file_id: z11.string()
3351
+ })
3352
+ ).optional().default([])
3353
+ }),
3354
+ z11.object({
3355
+ type: z11.literal("bash_code_execution_result"),
3356
+ content: z11.array(
3357
+ z11.object({
3358
+ type: z11.literal("bash_code_execution_output"),
3359
+ file_id: z11.string()
3360
+ })
3361
+ ),
3362
+ stdout: z11.string(),
3363
+ stderr: z11.string(),
3364
+ return_code: z11.number()
3365
+ }),
3366
+ z11.object({
3367
+ type: z11.literal("bash_code_execution_tool_result_error"),
3368
+ error_code: z11.string()
3369
+ }),
3370
+ z11.object({
3371
+ type: z11.literal("text_editor_code_execution_tool_result_error"),
3372
+ error_code: z11.string()
3373
+ }),
3374
+ z11.object({
3375
+ type: z11.literal("text_editor_code_execution_view_result"),
3376
+ content: z11.string(),
3377
+ file_type: z11.string(),
3378
+ num_lines: z11.number().nullable(),
3379
+ start_line: z11.number().nullable(),
3380
+ total_lines: z11.number().nullable()
3381
+ }),
3382
+ z11.object({
3383
+ type: z11.literal("text_editor_code_execution_create_result"),
3384
+ is_file_update: z11.boolean()
3385
+ }),
3386
+ z11.object({
3387
+ type: z11.literal("text_editor_code_execution_str_replace_result"),
3388
+ lines: z11.array(z11.string()).nullable(),
3389
+ new_lines: z11.number().nullable(),
3390
+ new_start: z11.number().nullable(),
3391
+ old_lines: z11.number().nullable(),
3392
+ old_start: z11.number().nullable()
3393
+ })
3394
+ ])
3395
+ )
3396
+ );
3397
+ var codeExecution_20260120InputSchema = lazySchema10(
3398
+ () => zodSchema10(
3399
+ z11.discriminatedUnion("type", [
3400
+ z11.object({
3401
+ type: z11.literal("programmatic-tool-call"),
3402
+ code: z11.string()
3403
+ }),
3404
+ z11.object({
3405
+ type: z11.literal("bash_code_execution"),
3406
+ command: z11.string()
3407
+ }),
3408
+ z11.discriminatedUnion("command", [
3409
+ z11.object({
3410
+ type: z11.literal("text_editor_code_execution"),
3411
+ command: z11.literal("view"),
3412
+ path: z11.string()
3413
+ }),
3414
+ z11.object({
3415
+ type: z11.literal("text_editor_code_execution"),
3416
+ command: z11.literal("create"),
3417
+ path: z11.string(),
3418
+ file_text: z11.string().nullish()
3419
+ }),
3420
+ z11.object({
3421
+ type: z11.literal("text_editor_code_execution"),
3422
+ command: z11.literal("str_replace"),
3423
+ path: z11.string(),
3424
+ old_str: z11.string(),
3425
+ new_str: z11.string()
3426
+ })
3427
+ ])
3428
+ ])
3429
+ )
3430
+ );
3431
+ var factory6 = createProviderDefinedToolFactoryWithOutputSchema5({
3432
+ id: "anthropic.code_execution_20260120",
3433
+ name: "code_execution",
3434
+ inputSchema: codeExecution_20260120InputSchema,
3435
+ outputSchema: codeExecution_20260120OutputSchema
3436
+ });
3437
+ var codeExecution_20260120 = (args = {}) => {
3438
+ return factory6(args);
3439
+ };
3440
+
3441
+ // src/tool/computer_20241022.ts
3442
+ import {
3443
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory4,
3444
+ lazySchema as lazySchema11,
3445
+ zodSchema as zodSchema11
3446
+ } from "@ai-sdk/provider-utils";
3447
+ import { z as z12 } from "zod/v4";
3448
+ var computer_20241022InputSchema = lazySchema11(
3449
+ () => zodSchema11(
3450
+ z12.object({
3451
+ action: z12.enum([
3336
3452
  "key",
3337
3453
  "type",
3338
3454
  "mouse_move",
@@ -3344,8 +3460,8 @@ var computer_20241022InputSchema = lazySchema10(
3344
3460
  "screenshot",
3345
3461
  "cursor_position"
3346
3462
  ]),
3347
- coordinate: z11.array(z11.number().int()).optional(),
3348
- text: z11.string().optional()
3463
+ coordinate: z12.array(z12.number().int()).optional(),
3464
+ text: z12.string().optional()
3349
3465
  })
3350
3466
  )
3351
3467
  );
@@ -3358,14 +3474,14 @@ var computer_20241022 = createProviderDefinedToolFactory4({
3358
3474
  // src/tool/computer_20250124.ts
3359
3475
  import {
3360
3476
  createProviderDefinedToolFactory as createProviderDefinedToolFactory5,
3361
- lazySchema as lazySchema11,
3362
- zodSchema as zodSchema11
3477
+ lazySchema as lazySchema12,
3478
+ zodSchema as zodSchema12
3363
3479
  } from "@ai-sdk/provider-utils";
3364
- import { z as z12 } from "zod/v4";
3365
- var computer_20250124InputSchema = lazySchema11(
3366
- () => zodSchema11(
3367
- z12.object({
3368
- action: z12.enum([
3480
+ import { z as z13 } from "zod/v4";
3481
+ var computer_20250124InputSchema = lazySchema12(
3482
+ () => zodSchema12(
3483
+ z13.object({
3484
+ action: z13.enum([
3369
3485
  "key",
3370
3486
  "hold_key",
3371
3487
  "type",
@@ -3383,12 +3499,12 @@ var computer_20250124InputSchema = lazySchema11(
3383
3499
  "wait",
3384
3500
  "screenshot"
3385
3501
  ]),
3386
- coordinate: z12.tuple([z12.number().int(), z12.number().int()]).optional(),
3387
- duration: z12.number().optional(),
3388
- scroll_amount: z12.number().optional(),
3389
- scroll_direction: z12.enum(["up", "down", "left", "right"]).optional(),
3390
- start_coordinate: z12.tuple([z12.number().int(), z12.number().int()]).optional(),
3391
- text: z12.string().optional()
3502
+ coordinate: z13.tuple([z13.number().int(), z13.number().int()]).optional(),
3503
+ duration: z13.number().optional(),
3504
+ scroll_amount: z13.number().optional(),
3505
+ scroll_direction: z13.enum(["up", "down", "left", "right"]).optional(),
3506
+ start_coordinate: z13.tuple([z13.number().int(), z13.number().int()]).optional(),
3507
+ text: z13.string().optional()
3392
3508
  })
3393
3509
  )
3394
3510
  );
@@ -3401,43 +3517,43 @@ var computer_20250124 = createProviderDefinedToolFactory5({
3401
3517
  // src/tool/memory_20250818.ts
3402
3518
  import {
3403
3519
  createProviderDefinedToolFactory as createProviderDefinedToolFactory6,
3404
- lazySchema as lazySchema12,
3405
- zodSchema as zodSchema12
3520
+ lazySchema as lazySchema13,
3521
+ zodSchema as zodSchema13
3406
3522
  } from "@ai-sdk/provider-utils";
3407
- import { z as z13 } from "zod/v4";
3408
- var memory_20250818InputSchema = lazySchema12(
3409
- () => zodSchema12(
3410
- z13.discriminatedUnion("command", [
3411
- z13.object({
3412
- command: z13.literal("view"),
3413
- path: z13.string(),
3414
- view_range: z13.tuple([z13.number(), z13.number()]).optional()
3523
+ import { z as z14 } from "zod/v4";
3524
+ var memory_20250818InputSchema = lazySchema13(
3525
+ () => zodSchema13(
3526
+ z14.discriminatedUnion("command", [
3527
+ z14.object({
3528
+ command: z14.literal("view"),
3529
+ path: z14.string(),
3530
+ view_range: z14.tuple([z14.number(), z14.number()]).optional()
3415
3531
  }),
3416
- z13.object({
3417
- command: z13.literal("create"),
3418
- path: z13.string(),
3419
- file_text: z13.string()
3532
+ z14.object({
3533
+ command: z14.literal("create"),
3534
+ path: z14.string(),
3535
+ file_text: z14.string()
3420
3536
  }),
3421
- z13.object({
3422
- command: z13.literal("str_replace"),
3423
- path: z13.string(),
3424
- old_str: z13.string(),
3425
- new_str: z13.string()
3537
+ z14.object({
3538
+ command: z14.literal("str_replace"),
3539
+ path: z14.string(),
3540
+ old_str: z14.string(),
3541
+ new_str: z14.string()
3426
3542
  }),
3427
- z13.object({
3428
- command: z13.literal("insert"),
3429
- path: z13.string(),
3430
- insert_line: z13.number(),
3431
- insert_text: z13.string()
3543
+ z14.object({
3544
+ command: z14.literal("insert"),
3545
+ path: z14.string(),
3546
+ insert_line: z14.number(),
3547
+ insert_text: z14.string()
3432
3548
  }),
3433
- z13.object({
3434
- command: z13.literal("delete"),
3435
- path: z13.string()
3549
+ z14.object({
3550
+ command: z14.literal("delete"),
3551
+ path: z14.string()
3436
3552
  }),
3437
- z13.object({
3438
- command: z13.literal("rename"),
3439
- old_path: z13.string(),
3440
- new_path: z13.string()
3553
+ z14.object({
3554
+ command: z14.literal("rename"),
3555
+ old_path: z14.string(),
3556
+ new_path: z14.string()
3441
3557
  })
3442
3558
  ])
3443
3559
  )
@@ -3451,37 +3567,11 @@ var memory_20250818 = createProviderDefinedToolFactory6({
3451
3567
  // src/tool/text-editor_20241022.ts
3452
3568
  import {
3453
3569
  createProviderDefinedToolFactory as createProviderDefinedToolFactory7,
3454
- lazySchema as lazySchema13,
3455
- zodSchema as zodSchema13
3456
- } from "@ai-sdk/provider-utils";
3457
- import { z as z14 } from "zod/v4";
3458
- var textEditor_20241022InputSchema = lazySchema13(
3459
- () => zodSchema13(
3460
- z14.object({
3461
- command: z14.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
3462
- path: z14.string(),
3463
- file_text: z14.string().optional(),
3464
- insert_line: z14.number().int().optional(),
3465
- new_str: z14.string().optional(),
3466
- old_str: z14.string().optional(),
3467
- view_range: z14.array(z14.number().int()).optional()
3468
- })
3469
- )
3470
- );
3471
- var textEditor_20241022 = createProviderDefinedToolFactory7({
3472
- id: "anthropic.text_editor_20241022",
3473
- name: "str_replace_editor",
3474
- inputSchema: textEditor_20241022InputSchema
3475
- });
3476
-
3477
- // src/tool/text-editor_20250124.ts
3478
- import {
3479
- createProviderDefinedToolFactory as createProviderDefinedToolFactory8,
3480
3570
  lazySchema as lazySchema14,
3481
3571
  zodSchema as zodSchema14
3482
3572
  } from "@ai-sdk/provider-utils";
3483
3573
  import { z as z15 } from "zod/v4";
3484
- var textEditor_20250124InputSchema = lazySchema14(
3574
+ var textEditor_20241022InputSchema = lazySchema14(
3485
3575
  () => zodSchema14(
3486
3576
  z15.object({
3487
3577
  command: z15.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
@@ -3494,23 +3584,23 @@ var textEditor_20250124InputSchema = lazySchema14(
3494
3584
  })
3495
3585
  )
3496
3586
  );
3497
- var textEditor_20250124 = createProviderDefinedToolFactory8({
3498
- id: "anthropic.text_editor_20250124",
3587
+ var textEditor_20241022 = createProviderDefinedToolFactory7({
3588
+ id: "anthropic.text_editor_20241022",
3499
3589
  name: "str_replace_editor",
3500
- inputSchema: textEditor_20250124InputSchema
3590
+ inputSchema: textEditor_20241022InputSchema
3501
3591
  });
3502
3592
 
3503
- // src/tool/text-editor_20250429.ts
3593
+ // src/tool/text-editor_20250124.ts
3504
3594
  import {
3505
- createProviderDefinedToolFactory as createProviderDefinedToolFactory9,
3595
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory8,
3506
3596
  lazySchema as lazySchema15,
3507
3597
  zodSchema as zodSchema15
3508
3598
  } from "@ai-sdk/provider-utils";
3509
3599
  import { z as z16 } from "zod/v4";
3510
- var textEditor_20250429InputSchema = lazySchema15(
3600
+ var textEditor_20250124InputSchema = lazySchema15(
3511
3601
  () => zodSchema15(
3512
3602
  z16.object({
3513
- command: z16.enum(["view", "create", "str_replace", "insert"]),
3603
+ command: z16.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
3514
3604
  path: z16.string(),
3515
3605
  file_text: z16.string().optional(),
3516
3606
  insert_line: z16.number().int().optional(),
@@ -3520,6 +3610,32 @@ var textEditor_20250429InputSchema = lazySchema15(
3520
3610
  })
3521
3611
  )
3522
3612
  );
3613
+ var textEditor_20250124 = createProviderDefinedToolFactory8({
3614
+ id: "anthropic.text_editor_20250124",
3615
+ name: "str_replace_editor",
3616
+ inputSchema: textEditor_20250124InputSchema
3617
+ });
3618
+
3619
+ // src/tool/text-editor_20250429.ts
3620
+ import {
3621
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory9,
3622
+ lazySchema as lazySchema16,
3623
+ zodSchema as zodSchema16
3624
+ } from "@ai-sdk/provider-utils";
3625
+ import { z as z17 } from "zod/v4";
3626
+ var textEditor_20250429InputSchema = lazySchema16(
3627
+ () => zodSchema16(
3628
+ z17.object({
3629
+ command: z17.enum(["view", "create", "str_replace", "insert"]),
3630
+ path: z17.string(),
3631
+ file_text: z17.string().optional(),
3632
+ insert_line: z17.number().int().optional(),
3633
+ new_str: z17.string().optional(),
3634
+ old_str: z17.string().optional(),
3635
+ view_range: z17.array(z17.number().int()).optional()
3636
+ })
3637
+ )
3638
+ );
3523
3639
  var textEditor_20250429 = createProviderDefinedToolFactory9({
3524
3640
  id: "anthropic.text_editor_20250429",
3525
3641
  name: "str_replace_based_edit_tool",
@@ -3570,6 +3686,19 @@ var anthropicTools = {
3570
3686
  * Tool name must be `code_execution`.
3571
3687
  */
3572
3688
  codeExecution_20250825,
3689
+ /**
3690
+ * Claude can analyze data, create visualizations, perform complex calculations,
3691
+ * run system commands, create and edit files, and process uploaded files directly within
3692
+ * the API conversation.
3693
+ *
3694
+ * The code execution tool allows Claude to run both Python and Bash commands and manipulate files,
3695
+ * including writing code, in a secure, sandboxed environment.
3696
+ *
3697
+ * This is the recommended version. Does not require a beta header.
3698
+ *
3699
+ * Supported models: Claude Opus 4.6, Sonnet 4.6, Sonnet 4.5, Opus 4.5
3700
+ */
3701
+ codeExecution_20260120,
3573
3702
  /**
3574
3703
  * Claude can interact with computer environments through the computer use tool, which
3575
3704
  * provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.