@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.
@@ -1001,6 +1001,13 @@ async function prepareTools({
1001
1001
  });
1002
1002
  break;
1003
1003
  }
1004
+ case "anthropic.code_execution_20260120": {
1005
+ anthropicTools2.push({
1006
+ type: "code_execution_20260120",
1007
+ name: "code_execution"
1008
+ });
1009
+ break;
1010
+ }
1004
1011
  case "anthropic.computer_20250124": {
1005
1012
  betas.add("computer-use-2025-01-24");
1006
1013
  anthropicTools2.push({
@@ -2185,7 +2192,7 @@ var AnthropicMessagesLanguageModel = class {
2185
2192
  betas.add("skills-2025-10-02");
2186
2193
  betas.add("files-api-2025-04-14");
2187
2194
  if (!(tools == null ? void 0 : tools.some(
2188
- (tool) => tool.type === "provider-defined" && tool.id === "anthropic.code_execution_20250825"
2195
+ (tool) => tool.type === "provider-defined" && (tool.id === "anthropic.code_execution_20250825" || tool.id === "anthropic.code_execution_20260120")
2189
2196
  ))) {
2190
2197
  warnings.push({
2191
2198
  type: "other",
@@ -3209,7 +3216,7 @@ function getModelCapabilities(modelId) {
3209
3216
  supportsStructuredOutput: true,
3210
3217
  isKnownModel: true
3211
3218
  };
3212
- } else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5")) {
3219
+ } else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5") || modelId.includes("claude-haiku-4-5")) {
3213
3220
  return {
3214
3221
  maxOutputTokens: 64e3,
3215
3222
  supportsStructuredOutput: true,
@@ -3221,7 +3228,7 @@ function getModelCapabilities(modelId) {
3221
3228
  supportsStructuredOutput: true,
3222
3229
  isKnownModel: true
3223
3230
  };
3224
- } else if (modelId.includes("claude-sonnet-4-") || modelId.includes("claude-3-7-sonnet") || modelId.includes("claude-haiku-4-5")) {
3231
+ } else if (modelId.includes("claude-sonnet-4-") || modelId.includes("claude-3-7-sonnet")) {
3225
3232
  return {
3226
3233
  maxOutputTokens: 64e3,
3227
3234
  supportsStructuredOutput: false,
@@ -3288,13 +3295,118 @@ var bash_20250124 = (0, import_provider_utils13.createProviderDefinedToolFactory
3288
3295
  inputSchema: bash_20250124InputSchema
3289
3296
  });
3290
3297
 
3291
- // src/tool/computer_20241022.ts
3298
+ // src/tool/code-execution_20260120.ts
3292
3299
  var import_provider_utils14 = require("@ai-sdk/provider-utils");
3293
3300
  var import_v411 = require("zod/v4");
3294
- var computer_20241022InputSchema = (0, import_provider_utils14.lazySchema)(
3301
+ var codeExecution_20260120OutputSchema = (0, import_provider_utils14.lazySchema)(
3295
3302
  () => (0, import_provider_utils14.zodSchema)(
3296
- import_v411.z.object({
3297
- action: import_v411.z.enum([
3303
+ import_v411.z.discriminatedUnion("type", [
3304
+ import_v411.z.object({
3305
+ type: import_v411.z.literal("code_execution_result"),
3306
+ stdout: import_v411.z.string(),
3307
+ stderr: import_v411.z.string(),
3308
+ return_code: import_v411.z.number(),
3309
+ content: import_v411.z.array(
3310
+ import_v411.z.object({
3311
+ type: import_v411.z.literal("code_execution_output"),
3312
+ file_id: import_v411.z.string()
3313
+ })
3314
+ ).optional().default([])
3315
+ }),
3316
+ import_v411.z.object({
3317
+ type: import_v411.z.literal("bash_code_execution_result"),
3318
+ content: import_v411.z.array(
3319
+ import_v411.z.object({
3320
+ type: import_v411.z.literal("bash_code_execution_output"),
3321
+ file_id: import_v411.z.string()
3322
+ })
3323
+ ),
3324
+ stdout: import_v411.z.string(),
3325
+ stderr: import_v411.z.string(),
3326
+ return_code: import_v411.z.number()
3327
+ }),
3328
+ import_v411.z.object({
3329
+ type: import_v411.z.literal("bash_code_execution_tool_result_error"),
3330
+ error_code: import_v411.z.string()
3331
+ }),
3332
+ import_v411.z.object({
3333
+ type: import_v411.z.literal("text_editor_code_execution_tool_result_error"),
3334
+ error_code: import_v411.z.string()
3335
+ }),
3336
+ import_v411.z.object({
3337
+ type: import_v411.z.literal("text_editor_code_execution_view_result"),
3338
+ content: import_v411.z.string(),
3339
+ file_type: import_v411.z.string(),
3340
+ num_lines: import_v411.z.number().nullable(),
3341
+ start_line: import_v411.z.number().nullable(),
3342
+ total_lines: import_v411.z.number().nullable()
3343
+ }),
3344
+ import_v411.z.object({
3345
+ type: import_v411.z.literal("text_editor_code_execution_create_result"),
3346
+ is_file_update: import_v411.z.boolean()
3347
+ }),
3348
+ import_v411.z.object({
3349
+ type: import_v411.z.literal("text_editor_code_execution_str_replace_result"),
3350
+ lines: import_v411.z.array(import_v411.z.string()).nullable(),
3351
+ new_lines: import_v411.z.number().nullable(),
3352
+ new_start: import_v411.z.number().nullable(),
3353
+ old_lines: import_v411.z.number().nullable(),
3354
+ old_start: import_v411.z.number().nullable()
3355
+ })
3356
+ ])
3357
+ )
3358
+ );
3359
+ var codeExecution_20260120InputSchema = (0, import_provider_utils14.lazySchema)(
3360
+ () => (0, import_provider_utils14.zodSchema)(
3361
+ import_v411.z.discriminatedUnion("type", [
3362
+ import_v411.z.object({
3363
+ type: import_v411.z.literal("programmatic-tool-call"),
3364
+ code: import_v411.z.string()
3365
+ }),
3366
+ import_v411.z.object({
3367
+ type: import_v411.z.literal("bash_code_execution"),
3368
+ command: import_v411.z.string()
3369
+ }),
3370
+ import_v411.z.discriminatedUnion("command", [
3371
+ import_v411.z.object({
3372
+ type: import_v411.z.literal("text_editor_code_execution"),
3373
+ command: import_v411.z.literal("view"),
3374
+ path: import_v411.z.string()
3375
+ }),
3376
+ import_v411.z.object({
3377
+ type: import_v411.z.literal("text_editor_code_execution"),
3378
+ command: import_v411.z.literal("create"),
3379
+ path: import_v411.z.string(),
3380
+ file_text: import_v411.z.string().nullish()
3381
+ }),
3382
+ import_v411.z.object({
3383
+ type: import_v411.z.literal("text_editor_code_execution"),
3384
+ command: import_v411.z.literal("str_replace"),
3385
+ path: import_v411.z.string(),
3386
+ old_str: import_v411.z.string(),
3387
+ new_str: import_v411.z.string()
3388
+ })
3389
+ ])
3390
+ ])
3391
+ )
3392
+ );
3393
+ var factory6 = (0, import_provider_utils14.createProviderDefinedToolFactoryWithOutputSchema)({
3394
+ id: "anthropic.code_execution_20260120",
3395
+ name: "code_execution",
3396
+ inputSchema: codeExecution_20260120InputSchema,
3397
+ outputSchema: codeExecution_20260120OutputSchema
3398
+ });
3399
+ var codeExecution_20260120 = (args = {}) => {
3400
+ return factory6(args);
3401
+ };
3402
+
3403
+ // src/tool/computer_20241022.ts
3404
+ var import_provider_utils15 = require("@ai-sdk/provider-utils");
3405
+ var import_v412 = require("zod/v4");
3406
+ var computer_20241022InputSchema = (0, import_provider_utils15.lazySchema)(
3407
+ () => (0, import_provider_utils15.zodSchema)(
3408
+ import_v412.z.object({
3409
+ action: import_v412.z.enum([
3298
3410
  "key",
3299
3411
  "type",
3300
3412
  "mouse_move",
@@ -3306,24 +3418,24 @@ var computer_20241022InputSchema = (0, import_provider_utils14.lazySchema)(
3306
3418
  "screenshot",
3307
3419
  "cursor_position"
3308
3420
  ]),
3309
- coordinate: import_v411.z.array(import_v411.z.number().int()).optional(),
3310
- text: import_v411.z.string().optional()
3421
+ coordinate: import_v412.z.array(import_v412.z.number().int()).optional(),
3422
+ text: import_v412.z.string().optional()
3311
3423
  })
3312
3424
  )
3313
3425
  );
3314
- var computer_20241022 = (0, import_provider_utils14.createProviderDefinedToolFactory)({
3426
+ var computer_20241022 = (0, import_provider_utils15.createProviderDefinedToolFactory)({
3315
3427
  id: "anthropic.computer_20241022",
3316
3428
  name: "computer",
3317
3429
  inputSchema: computer_20241022InputSchema
3318
3430
  });
3319
3431
 
3320
3432
  // src/tool/computer_20250124.ts
3321
- var import_provider_utils15 = require("@ai-sdk/provider-utils");
3322
- var import_v412 = require("zod/v4");
3323
- var computer_20250124InputSchema = (0, import_provider_utils15.lazySchema)(
3324
- () => (0, import_provider_utils15.zodSchema)(
3325
- import_v412.z.object({
3326
- action: import_v412.z.enum([
3433
+ var import_provider_utils16 = require("@ai-sdk/provider-utils");
3434
+ var import_v413 = require("zod/v4");
3435
+ var computer_20250124InputSchema = (0, import_provider_utils16.lazySchema)(
3436
+ () => (0, import_provider_utils16.zodSchema)(
3437
+ import_v413.z.object({
3438
+ action: import_v413.z.enum([
3327
3439
  "key",
3328
3440
  "hold_key",
3329
3441
  "type",
@@ -3341,93 +3453,71 @@ var computer_20250124InputSchema = (0, import_provider_utils15.lazySchema)(
3341
3453
  "wait",
3342
3454
  "screenshot"
3343
3455
  ]),
3344
- coordinate: import_v412.z.tuple([import_v412.z.number().int(), import_v412.z.number().int()]).optional(),
3345
- duration: import_v412.z.number().optional(),
3346
- scroll_amount: import_v412.z.number().optional(),
3347
- scroll_direction: import_v412.z.enum(["up", "down", "left", "right"]).optional(),
3348
- start_coordinate: import_v412.z.tuple([import_v412.z.number().int(), import_v412.z.number().int()]).optional(),
3349
- text: import_v412.z.string().optional()
3456
+ coordinate: import_v413.z.tuple([import_v413.z.number().int(), import_v413.z.number().int()]).optional(),
3457
+ duration: import_v413.z.number().optional(),
3458
+ scroll_amount: import_v413.z.number().optional(),
3459
+ scroll_direction: import_v413.z.enum(["up", "down", "left", "right"]).optional(),
3460
+ start_coordinate: import_v413.z.tuple([import_v413.z.number().int(), import_v413.z.number().int()]).optional(),
3461
+ text: import_v413.z.string().optional()
3350
3462
  })
3351
3463
  )
3352
3464
  );
3353
- var computer_20250124 = (0, import_provider_utils15.createProviderDefinedToolFactory)({
3465
+ var computer_20250124 = (0, import_provider_utils16.createProviderDefinedToolFactory)({
3354
3466
  id: "anthropic.computer_20250124",
3355
3467
  name: "computer",
3356
3468
  inputSchema: computer_20250124InputSchema
3357
3469
  });
3358
3470
 
3359
3471
  // src/tool/memory_20250818.ts
3360
- var import_provider_utils16 = require("@ai-sdk/provider-utils");
3361
- var import_v413 = require("zod/v4");
3362
- var memory_20250818InputSchema = (0, import_provider_utils16.lazySchema)(
3363
- () => (0, import_provider_utils16.zodSchema)(
3364
- import_v413.z.discriminatedUnion("command", [
3365
- import_v413.z.object({
3366
- command: import_v413.z.literal("view"),
3367
- path: import_v413.z.string(),
3368
- view_range: import_v413.z.tuple([import_v413.z.number(), import_v413.z.number()]).optional()
3472
+ var import_provider_utils17 = require("@ai-sdk/provider-utils");
3473
+ var import_v414 = require("zod/v4");
3474
+ var memory_20250818InputSchema = (0, import_provider_utils17.lazySchema)(
3475
+ () => (0, import_provider_utils17.zodSchema)(
3476
+ import_v414.z.discriminatedUnion("command", [
3477
+ import_v414.z.object({
3478
+ command: import_v414.z.literal("view"),
3479
+ path: import_v414.z.string(),
3480
+ view_range: import_v414.z.tuple([import_v414.z.number(), import_v414.z.number()]).optional()
3369
3481
  }),
3370
- import_v413.z.object({
3371
- command: import_v413.z.literal("create"),
3372
- path: import_v413.z.string(),
3373
- file_text: import_v413.z.string()
3482
+ import_v414.z.object({
3483
+ command: import_v414.z.literal("create"),
3484
+ path: import_v414.z.string(),
3485
+ file_text: import_v414.z.string()
3374
3486
  }),
3375
- import_v413.z.object({
3376
- command: import_v413.z.literal("str_replace"),
3377
- path: import_v413.z.string(),
3378
- old_str: import_v413.z.string(),
3379
- new_str: import_v413.z.string()
3487
+ import_v414.z.object({
3488
+ command: import_v414.z.literal("str_replace"),
3489
+ path: import_v414.z.string(),
3490
+ old_str: import_v414.z.string(),
3491
+ new_str: import_v414.z.string()
3380
3492
  }),
3381
- import_v413.z.object({
3382
- command: import_v413.z.literal("insert"),
3383
- path: import_v413.z.string(),
3384
- insert_line: import_v413.z.number(),
3385
- insert_text: import_v413.z.string()
3493
+ import_v414.z.object({
3494
+ command: import_v414.z.literal("insert"),
3495
+ path: import_v414.z.string(),
3496
+ insert_line: import_v414.z.number(),
3497
+ insert_text: import_v414.z.string()
3386
3498
  }),
3387
- import_v413.z.object({
3388
- command: import_v413.z.literal("delete"),
3389
- path: import_v413.z.string()
3499
+ import_v414.z.object({
3500
+ command: import_v414.z.literal("delete"),
3501
+ path: import_v414.z.string()
3390
3502
  }),
3391
- import_v413.z.object({
3392
- command: import_v413.z.literal("rename"),
3393
- old_path: import_v413.z.string(),
3394
- new_path: import_v413.z.string()
3503
+ import_v414.z.object({
3504
+ command: import_v414.z.literal("rename"),
3505
+ old_path: import_v414.z.string(),
3506
+ new_path: import_v414.z.string()
3395
3507
  })
3396
3508
  ])
3397
3509
  )
3398
3510
  );
3399
- var memory_20250818 = (0, import_provider_utils16.createProviderDefinedToolFactory)({
3511
+ var memory_20250818 = (0, import_provider_utils17.createProviderDefinedToolFactory)({
3400
3512
  id: "anthropic.memory_20250818",
3401
3513
  name: "memory",
3402
3514
  inputSchema: memory_20250818InputSchema
3403
3515
  });
3404
3516
 
3405
3517
  // src/tool/text-editor_20241022.ts
3406
- var import_provider_utils17 = require("@ai-sdk/provider-utils");
3407
- var import_v414 = require("zod/v4");
3408
- var textEditor_20241022InputSchema = (0, import_provider_utils17.lazySchema)(
3409
- () => (0, import_provider_utils17.zodSchema)(
3410
- import_v414.z.object({
3411
- command: import_v414.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
3412
- path: import_v414.z.string(),
3413
- file_text: import_v414.z.string().optional(),
3414
- insert_line: import_v414.z.number().int().optional(),
3415
- new_str: import_v414.z.string().optional(),
3416
- old_str: import_v414.z.string().optional(),
3417
- view_range: import_v414.z.array(import_v414.z.number().int()).optional()
3418
- })
3419
- )
3420
- );
3421
- var textEditor_20241022 = (0, import_provider_utils17.createProviderDefinedToolFactory)({
3422
- id: "anthropic.text_editor_20241022",
3423
- name: "str_replace_editor",
3424
- inputSchema: textEditor_20241022InputSchema
3425
- });
3426
-
3427
- // src/tool/text-editor_20250124.ts
3428
3518
  var import_provider_utils18 = require("@ai-sdk/provider-utils");
3429
3519
  var import_v415 = require("zod/v4");
3430
- var textEditor_20250124InputSchema = (0, import_provider_utils18.lazySchema)(
3520
+ var textEditor_20241022InputSchema = (0, import_provider_utils18.lazySchema)(
3431
3521
  () => (0, import_provider_utils18.zodSchema)(
3432
3522
  import_v415.z.object({
3433
3523
  command: import_v415.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
@@ -3440,19 +3530,19 @@ var textEditor_20250124InputSchema = (0, import_provider_utils18.lazySchema)(
3440
3530
  })
3441
3531
  )
3442
3532
  );
3443
- var textEditor_20250124 = (0, import_provider_utils18.createProviderDefinedToolFactory)({
3444
- id: "anthropic.text_editor_20250124",
3533
+ var textEditor_20241022 = (0, import_provider_utils18.createProviderDefinedToolFactory)({
3534
+ id: "anthropic.text_editor_20241022",
3445
3535
  name: "str_replace_editor",
3446
- inputSchema: textEditor_20250124InputSchema
3536
+ inputSchema: textEditor_20241022InputSchema
3447
3537
  });
3448
3538
 
3449
- // src/tool/text-editor_20250429.ts
3539
+ // src/tool/text-editor_20250124.ts
3450
3540
  var import_provider_utils19 = require("@ai-sdk/provider-utils");
3451
3541
  var import_v416 = require("zod/v4");
3452
- var textEditor_20250429InputSchema = (0, import_provider_utils19.lazySchema)(
3542
+ var textEditor_20250124InputSchema = (0, import_provider_utils19.lazySchema)(
3453
3543
  () => (0, import_provider_utils19.zodSchema)(
3454
3544
  import_v416.z.object({
3455
- command: import_v416.z.enum(["view", "create", "str_replace", "insert"]),
3545
+ command: import_v416.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
3456
3546
  path: import_v416.z.string(),
3457
3547
  file_text: import_v416.z.string().optional(),
3458
3548
  insert_line: import_v416.z.number().int().optional(),
@@ -3462,7 +3552,29 @@ var textEditor_20250429InputSchema = (0, import_provider_utils19.lazySchema)(
3462
3552
  })
3463
3553
  )
3464
3554
  );
3465
- var textEditor_20250429 = (0, import_provider_utils19.createProviderDefinedToolFactory)({
3555
+ var textEditor_20250124 = (0, import_provider_utils19.createProviderDefinedToolFactory)({
3556
+ id: "anthropic.text_editor_20250124",
3557
+ name: "str_replace_editor",
3558
+ inputSchema: textEditor_20250124InputSchema
3559
+ });
3560
+
3561
+ // src/tool/text-editor_20250429.ts
3562
+ var import_provider_utils20 = require("@ai-sdk/provider-utils");
3563
+ var import_v417 = require("zod/v4");
3564
+ var textEditor_20250429InputSchema = (0, import_provider_utils20.lazySchema)(
3565
+ () => (0, import_provider_utils20.zodSchema)(
3566
+ import_v417.z.object({
3567
+ command: import_v417.z.enum(["view", "create", "str_replace", "insert"]),
3568
+ path: import_v417.z.string(),
3569
+ file_text: import_v417.z.string().optional(),
3570
+ insert_line: import_v417.z.number().int().optional(),
3571
+ new_str: import_v417.z.string().optional(),
3572
+ old_str: import_v417.z.string().optional(),
3573
+ view_range: import_v417.z.array(import_v417.z.number().int()).optional()
3574
+ })
3575
+ )
3576
+ );
3577
+ var textEditor_20250429 = (0, import_provider_utils20.createProviderDefinedToolFactory)({
3466
3578
  id: "anthropic.text_editor_20250429",
3467
3579
  name: "str_replace_based_edit_tool",
3468
3580
  inputSchema: textEditor_20250429InputSchema
@@ -3512,6 +3624,19 @@ var anthropicTools = {
3512
3624
  * Tool name must be `code_execution`.
3513
3625
  */
3514
3626
  codeExecution_20250825,
3627
+ /**
3628
+ * Claude can analyze data, create visualizations, perform complex calculations,
3629
+ * run system commands, create and edit files, and process uploaded files directly within
3630
+ * the API conversation.
3631
+ *
3632
+ * The code execution tool allows Claude to run both Python and Bash commands and manipulate files,
3633
+ * including writing code, in a secure, sandboxed environment.
3634
+ *
3635
+ * This is the recommended version. Does not require a beta header.
3636
+ *
3637
+ * Supported models: Claude Opus 4.6, Sonnet 4.6, Sonnet 4.5, Opus 4.5
3638
+ */
3639
+ codeExecution_20260120,
3515
3640
  /**
3516
3641
  * Claude can interact with computer environments through the computer use tool, which
3517
3642
  * provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.