@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.js CHANGED
@@ -28,10 +28,10 @@ module.exports = __toCommonJS(index_exports);
28
28
 
29
29
  // src/anthropic-provider.ts
30
30
  var import_provider4 = require("@ai-sdk/provider");
31
- var import_provider_utils20 = require("@ai-sdk/provider-utils");
31
+ var import_provider_utils21 = require("@ai-sdk/provider-utils");
32
32
 
33
33
  // src/version.ts
34
- var VERSION = true ? "2.0.71" : "0.0.0-test";
34
+ var VERSION = true ? "2.0.73" : "0.0.0-test";
35
35
 
36
36
  // src/anthropic-messages-language-model.ts
37
37
  var import_provider3 = require("@ai-sdk/provider");
@@ -1008,6 +1008,13 @@ async function prepareTools({
1008
1008
  });
1009
1009
  break;
1010
1010
  }
1011
+ case "anthropic.code_execution_20260120": {
1012
+ anthropicTools2.push({
1013
+ type: "code_execution_20260120",
1014
+ name: "code_execution"
1015
+ });
1016
+ break;
1017
+ }
1011
1018
  case "anthropic.computer_20250124": {
1012
1019
  betas.add("computer-use-2025-01-24");
1013
1020
  anthropicTools2.push({
@@ -2192,7 +2199,7 @@ var AnthropicMessagesLanguageModel = class {
2192
2199
  betas.add("skills-2025-10-02");
2193
2200
  betas.add("files-api-2025-04-14");
2194
2201
  if (!(tools == null ? void 0 : tools.some(
2195
- (tool) => tool.type === "provider-defined" && tool.id === "anthropic.code_execution_20250825"
2202
+ (tool) => tool.type === "provider-defined" && (tool.id === "anthropic.code_execution_20250825" || tool.id === "anthropic.code_execution_20260120")
2196
2203
  ))) {
2197
2204
  warnings.push({
2198
2205
  type: "other",
@@ -3216,7 +3223,7 @@ function getModelCapabilities(modelId) {
3216
3223
  supportsStructuredOutput: true,
3217
3224
  isKnownModel: true
3218
3225
  };
3219
- } else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5")) {
3226
+ } else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5") || modelId.includes("claude-haiku-4-5")) {
3220
3227
  return {
3221
3228
  maxOutputTokens: 64e3,
3222
3229
  supportsStructuredOutput: true,
@@ -3228,7 +3235,7 @@ function getModelCapabilities(modelId) {
3228
3235
  supportsStructuredOutput: true,
3229
3236
  isKnownModel: true
3230
3237
  };
3231
- } else if (modelId.includes("claude-sonnet-4-") || modelId.includes("claude-3-7-sonnet") || modelId.includes("claude-haiku-4-5")) {
3238
+ } else if (modelId.includes("claude-sonnet-4-") || modelId.includes("claude-3-7-sonnet")) {
3232
3239
  return {
3233
3240
  maxOutputTokens: 64e3,
3234
3241
  supportsStructuredOutput: false,
@@ -3295,13 +3302,118 @@ var bash_20250124 = (0, import_provider_utils13.createProviderDefinedToolFactory
3295
3302
  inputSchema: bash_20250124InputSchema
3296
3303
  });
3297
3304
 
3298
- // src/tool/computer_20241022.ts
3305
+ // src/tool/code-execution_20260120.ts
3299
3306
  var import_provider_utils14 = require("@ai-sdk/provider-utils");
3300
3307
  var import_v411 = require("zod/v4");
3301
- var computer_20241022InputSchema = (0, import_provider_utils14.lazySchema)(
3308
+ var codeExecution_20260120OutputSchema = (0, import_provider_utils14.lazySchema)(
3309
+ () => (0, import_provider_utils14.zodSchema)(
3310
+ import_v411.z.discriminatedUnion("type", [
3311
+ import_v411.z.object({
3312
+ type: import_v411.z.literal("code_execution_result"),
3313
+ stdout: import_v411.z.string(),
3314
+ stderr: import_v411.z.string(),
3315
+ return_code: import_v411.z.number(),
3316
+ content: import_v411.z.array(
3317
+ import_v411.z.object({
3318
+ type: import_v411.z.literal("code_execution_output"),
3319
+ file_id: import_v411.z.string()
3320
+ })
3321
+ ).optional().default([])
3322
+ }),
3323
+ import_v411.z.object({
3324
+ type: import_v411.z.literal("bash_code_execution_result"),
3325
+ content: import_v411.z.array(
3326
+ import_v411.z.object({
3327
+ type: import_v411.z.literal("bash_code_execution_output"),
3328
+ file_id: import_v411.z.string()
3329
+ })
3330
+ ),
3331
+ stdout: import_v411.z.string(),
3332
+ stderr: import_v411.z.string(),
3333
+ return_code: import_v411.z.number()
3334
+ }),
3335
+ import_v411.z.object({
3336
+ type: import_v411.z.literal("bash_code_execution_tool_result_error"),
3337
+ error_code: import_v411.z.string()
3338
+ }),
3339
+ import_v411.z.object({
3340
+ type: import_v411.z.literal("text_editor_code_execution_tool_result_error"),
3341
+ error_code: import_v411.z.string()
3342
+ }),
3343
+ import_v411.z.object({
3344
+ type: import_v411.z.literal("text_editor_code_execution_view_result"),
3345
+ content: import_v411.z.string(),
3346
+ file_type: import_v411.z.string(),
3347
+ num_lines: import_v411.z.number().nullable(),
3348
+ start_line: import_v411.z.number().nullable(),
3349
+ total_lines: import_v411.z.number().nullable()
3350
+ }),
3351
+ import_v411.z.object({
3352
+ type: import_v411.z.literal("text_editor_code_execution_create_result"),
3353
+ is_file_update: import_v411.z.boolean()
3354
+ }),
3355
+ import_v411.z.object({
3356
+ type: import_v411.z.literal("text_editor_code_execution_str_replace_result"),
3357
+ lines: import_v411.z.array(import_v411.z.string()).nullable(),
3358
+ new_lines: import_v411.z.number().nullable(),
3359
+ new_start: import_v411.z.number().nullable(),
3360
+ old_lines: import_v411.z.number().nullable(),
3361
+ old_start: import_v411.z.number().nullable()
3362
+ })
3363
+ ])
3364
+ )
3365
+ );
3366
+ var codeExecution_20260120InputSchema = (0, import_provider_utils14.lazySchema)(
3302
3367
  () => (0, import_provider_utils14.zodSchema)(
3303
- import_v411.z.object({
3304
- action: import_v411.z.enum([
3368
+ import_v411.z.discriminatedUnion("type", [
3369
+ import_v411.z.object({
3370
+ type: import_v411.z.literal("programmatic-tool-call"),
3371
+ code: import_v411.z.string()
3372
+ }),
3373
+ import_v411.z.object({
3374
+ type: import_v411.z.literal("bash_code_execution"),
3375
+ command: import_v411.z.string()
3376
+ }),
3377
+ import_v411.z.discriminatedUnion("command", [
3378
+ import_v411.z.object({
3379
+ type: import_v411.z.literal("text_editor_code_execution"),
3380
+ command: import_v411.z.literal("view"),
3381
+ path: import_v411.z.string()
3382
+ }),
3383
+ import_v411.z.object({
3384
+ type: import_v411.z.literal("text_editor_code_execution"),
3385
+ command: import_v411.z.literal("create"),
3386
+ path: import_v411.z.string(),
3387
+ file_text: import_v411.z.string().nullish()
3388
+ }),
3389
+ import_v411.z.object({
3390
+ type: import_v411.z.literal("text_editor_code_execution"),
3391
+ command: import_v411.z.literal("str_replace"),
3392
+ path: import_v411.z.string(),
3393
+ old_str: import_v411.z.string(),
3394
+ new_str: import_v411.z.string()
3395
+ })
3396
+ ])
3397
+ ])
3398
+ )
3399
+ );
3400
+ var factory6 = (0, import_provider_utils14.createProviderDefinedToolFactoryWithOutputSchema)({
3401
+ id: "anthropic.code_execution_20260120",
3402
+ name: "code_execution",
3403
+ inputSchema: codeExecution_20260120InputSchema,
3404
+ outputSchema: codeExecution_20260120OutputSchema
3405
+ });
3406
+ var codeExecution_20260120 = (args = {}) => {
3407
+ return factory6(args);
3408
+ };
3409
+
3410
+ // src/tool/computer_20241022.ts
3411
+ var import_provider_utils15 = require("@ai-sdk/provider-utils");
3412
+ var import_v412 = require("zod/v4");
3413
+ var computer_20241022InputSchema = (0, import_provider_utils15.lazySchema)(
3414
+ () => (0, import_provider_utils15.zodSchema)(
3415
+ import_v412.z.object({
3416
+ action: import_v412.z.enum([
3305
3417
  "key",
3306
3418
  "type",
3307
3419
  "mouse_move",
@@ -3313,24 +3425,24 @@ var computer_20241022InputSchema = (0, import_provider_utils14.lazySchema)(
3313
3425
  "screenshot",
3314
3426
  "cursor_position"
3315
3427
  ]),
3316
- coordinate: import_v411.z.array(import_v411.z.number().int()).optional(),
3317
- text: import_v411.z.string().optional()
3428
+ coordinate: import_v412.z.array(import_v412.z.number().int()).optional(),
3429
+ text: import_v412.z.string().optional()
3318
3430
  })
3319
3431
  )
3320
3432
  );
3321
- var computer_20241022 = (0, import_provider_utils14.createProviderDefinedToolFactory)({
3433
+ var computer_20241022 = (0, import_provider_utils15.createProviderDefinedToolFactory)({
3322
3434
  id: "anthropic.computer_20241022",
3323
3435
  name: "computer",
3324
3436
  inputSchema: computer_20241022InputSchema
3325
3437
  });
3326
3438
 
3327
3439
  // src/tool/computer_20250124.ts
3328
- var import_provider_utils15 = require("@ai-sdk/provider-utils");
3329
- var import_v412 = require("zod/v4");
3330
- var computer_20250124InputSchema = (0, import_provider_utils15.lazySchema)(
3331
- () => (0, import_provider_utils15.zodSchema)(
3332
- import_v412.z.object({
3333
- action: import_v412.z.enum([
3440
+ var import_provider_utils16 = require("@ai-sdk/provider-utils");
3441
+ var import_v413 = require("zod/v4");
3442
+ var computer_20250124InputSchema = (0, import_provider_utils16.lazySchema)(
3443
+ () => (0, import_provider_utils16.zodSchema)(
3444
+ import_v413.z.object({
3445
+ action: import_v413.z.enum([
3334
3446
  "key",
3335
3447
  "hold_key",
3336
3448
  "type",
@@ -3348,93 +3460,71 @@ var computer_20250124InputSchema = (0, import_provider_utils15.lazySchema)(
3348
3460
  "wait",
3349
3461
  "screenshot"
3350
3462
  ]),
3351
- coordinate: import_v412.z.tuple([import_v412.z.number().int(), import_v412.z.number().int()]).optional(),
3352
- duration: import_v412.z.number().optional(),
3353
- scroll_amount: import_v412.z.number().optional(),
3354
- scroll_direction: import_v412.z.enum(["up", "down", "left", "right"]).optional(),
3355
- start_coordinate: import_v412.z.tuple([import_v412.z.number().int(), import_v412.z.number().int()]).optional(),
3356
- text: import_v412.z.string().optional()
3463
+ coordinate: import_v413.z.tuple([import_v413.z.number().int(), import_v413.z.number().int()]).optional(),
3464
+ duration: import_v413.z.number().optional(),
3465
+ scroll_amount: import_v413.z.number().optional(),
3466
+ scroll_direction: import_v413.z.enum(["up", "down", "left", "right"]).optional(),
3467
+ start_coordinate: import_v413.z.tuple([import_v413.z.number().int(), import_v413.z.number().int()]).optional(),
3468
+ text: import_v413.z.string().optional()
3357
3469
  })
3358
3470
  )
3359
3471
  );
3360
- var computer_20250124 = (0, import_provider_utils15.createProviderDefinedToolFactory)({
3472
+ var computer_20250124 = (0, import_provider_utils16.createProviderDefinedToolFactory)({
3361
3473
  id: "anthropic.computer_20250124",
3362
3474
  name: "computer",
3363
3475
  inputSchema: computer_20250124InputSchema
3364
3476
  });
3365
3477
 
3366
3478
  // src/tool/memory_20250818.ts
3367
- var import_provider_utils16 = require("@ai-sdk/provider-utils");
3368
- var import_v413 = require("zod/v4");
3369
- var memory_20250818InputSchema = (0, import_provider_utils16.lazySchema)(
3370
- () => (0, import_provider_utils16.zodSchema)(
3371
- import_v413.z.discriminatedUnion("command", [
3372
- import_v413.z.object({
3373
- command: import_v413.z.literal("view"),
3374
- path: import_v413.z.string(),
3375
- view_range: import_v413.z.tuple([import_v413.z.number(), import_v413.z.number()]).optional()
3479
+ var import_provider_utils17 = require("@ai-sdk/provider-utils");
3480
+ var import_v414 = require("zod/v4");
3481
+ var memory_20250818InputSchema = (0, import_provider_utils17.lazySchema)(
3482
+ () => (0, import_provider_utils17.zodSchema)(
3483
+ import_v414.z.discriminatedUnion("command", [
3484
+ import_v414.z.object({
3485
+ command: import_v414.z.literal("view"),
3486
+ path: import_v414.z.string(),
3487
+ view_range: import_v414.z.tuple([import_v414.z.number(), import_v414.z.number()]).optional()
3376
3488
  }),
3377
- import_v413.z.object({
3378
- command: import_v413.z.literal("create"),
3379
- path: import_v413.z.string(),
3380
- file_text: import_v413.z.string()
3489
+ import_v414.z.object({
3490
+ command: import_v414.z.literal("create"),
3491
+ path: import_v414.z.string(),
3492
+ file_text: import_v414.z.string()
3381
3493
  }),
3382
- import_v413.z.object({
3383
- command: import_v413.z.literal("str_replace"),
3384
- path: import_v413.z.string(),
3385
- old_str: import_v413.z.string(),
3386
- new_str: import_v413.z.string()
3494
+ import_v414.z.object({
3495
+ command: import_v414.z.literal("str_replace"),
3496
+ path: import_v414.z.string(),
3497
+ old_str: import_v414.z.string(),
3498
+ new_str: import_v414.z.string()
3387
3499
  }),
3388
- import_v413.z.object({
3389
- command: import_v413.z.literal("insert"),
3390
- path: import_v413.z.string(),
3391
- insert_line: import_v413.z.number(),
3392
- insert_text: import_v413.z.string()
3500
+ import_v414.z.object({
3501
+ command: import_v414.z.literal("insert"),
3502
+ path: import_v414.z.string(),
3503
+ insert_line: import_v414.z.number(),
3504
+ insert_text: import_v414.z.string()
3393
3505
  }),
3394
- import_v413.z.object({
3395
- command: import_v413.z.literal("delete"),
3396
- path: import_v413.z.string()
3506
+ import_v414.z.object({
3507
+ command: import_v414.z.literal("delete"),
3508
+ path: import_v414.z.string()
3397
3509
  }),
3398
- import_v413.z.object({
3399
- command: import_v413.z.literal("rename"),
3400
- old_path: import_v413.z.string(),
3401
- new_path: import_v413.z.string()
3510
+ import_v414.z.object({
3511
+ command: import_v414.z.literal("rename"),
3512
+ old_path: import_v414.z.string(),
3513
+ new_path: import_v414.z.string()
3402
3514
  })
3403
3515
  ])
3404
3516
  )
3405
3517
  );
3406
- var memory_20250818 = (0, import_provider_utils16.createProviderDefinedToolFactory)({
3518
+ var memory_20250818 = (0, import_provider_utils17.createProviderDefinedToolFactory)({
3407
3519
  id: "anthropic.memory_20250818",
3408
3520
  name: "memory",
3409
3521
  inputSchema: memory_20250818InputSchema
3410
3522
  });
3411
3523
 
3412
3524
  // src/tool/text-editor_20241022.ts
3413
- var import_provider_utils17 = require("@ai-sdk/provider-utils");
3414
- var import_v414 = require("zod/v4");
3415
- var textEditor_20241022InputSchema = (0, import_provider_utils17.lazySchema)(
3416
- () => (0, import_provider_utils17.zodSchema)(
3417
- import_v414.z.object({
3418
- command: import_v414.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
3419
- path: import_v414.z.string(),
3420
- file_text: import_v414.z.string().optional(),
3421
- insert_line: import_v414.z.number().int().optional(),
3422
- new_str: import_v414.z.string().optional(),
3423
- old_str: import_v414.z.string().optional(),
3424
- view_range: import_v414.z.array(import_v414.z.number().int()).optional()
3425
- })
3426
- )
3427
- );
3428
- var textEditor_20241022 = (0, import_provider_utils17.createProviderDefinedToolFactory)({
3429
- id: "anthropic.text_editor_20241022",
3430
- name: "str_replace_editor",
3431
- inputSchema: textEditor_20241022InputSchema
3432
- });
3433
-
3434
- // src/tool/text-editor_20250124.ts
3435
3525
  var import_provider_utils18 = require("@ai-sdk/provider-utils");
3436
3526
  var import_v415 = require("zod/v4");
3437
- var textEditor_20250124InputSchema = (0, import_provider_utils18.lazySchema)(
3527
+ var textEditor_20241022InputSchema = (0, import_provider_utils18.lazySchema)(
3438
3528
  () => (0, import_provider_utils18.zodSchema)(
3439
3529
  import_v415.z.object({
3440
3530
  command: import_v415.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
@@ -3447,19 +3537,19 @@ var textEditor_20250124InputSchema = (0, import_provider_utils18.lazySchema)(
3447
3537
  })
3448
3538
  )
3449
3539
  );
3450
- var textEditor_20250124 = (0, import_provider_utils18.createProviderDefinedToolFactory)({
3451
- id: "anthropic.text_editor_20250124",
3540
+ var textEditor_20241022 = (0, import_provider_utils18.createProviderDefinedToolFactory)({
3541
+ id: "anthropic.text_editor_20241022",
3452
3542
  name: "str_replace_editor",
3453
- inputSchema: textEditor_20250124InputSchema
3543
+ inputSchema: textEditor_20241022InputSchema
3454
3544
  });
3455
3545
 
3456
- // src/tool/text-editor_20250429.ts
3546
+ // src/tool/text-editor_20250124.ts
3457
3547
  var import_provider_utils19 = require("@ai-sdk/provider-utils");
3458
3548
  var import_v416 = require("zod/v4");
3459
- var textEditor_20250429InputSchema = (0, import_provider_utils19.lazySchema)(
3549
+ var textEditor_20250124InputSchema = (0, import_provider_utils19.lazySchema)(
3460
3550
  () => (0, import_provider_utils19.zodSchema)(
3461
3551
  import_v416.z.object({
3462
- command: import_v416.z.enum(["view", "create", "str_replace", "insert"]),
3552
+ command: import_v416.z.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
3463
3553
  path: import_v416.z.string(),
3464
3554
  file_text: import_v416.z.string().optional(),
3465
3555
  insert_line: import_v416.z.number().int().optional(),
@@ -3469,7 +3559,29 @@ var textEditor_20250429InputSchema = (0, import_provider_utils19.lazySchema)(
3469
3559
  })
3470
3560
  )
3471
3561
  );
3472
- var textEditor_20250429 = (0, import_provider_utils19.createProviderDefinedToolFactory)({
3562
+ var textEditor_20250124 = (0, import_provider_utils19.createProviderDefinedToolFactory)({
3563
+ id: "anthropic.text_editor_20250124",
3564
+ name: "str_replace_editor",
3565
+ inputSchema: textEditor_20250124InputSchema
3566
+ });
3567
+
3568
+ // src/tool/text-editor_20250429.ts
3569
+ var import_provider_utils20 = require("@ai-sdk/provider-utils");
3570
+ var import_v417 = require("zod/v4");
3571
+ var textEditor_20250429InputSchema = (0, import_provider_utils20.lazySchema)(
3572
+ () => (0, import_provider_utils20.zodSchema)(
3573
+ import_v417.z.object({
3574
+ command: import_v417.z.enum(["view", "create", "str_replace", "insert"]),
3575
+ path: import_v417.z.string(),
3576
+ file_text: import_v417.z.string().optional(),
3577
+ insert_line: import_v417.z.number().int().optional(),
3578
+ new_str: import_v417.z.string().optional(),
3579
+ old_str: import_v417.z.string().optional(),
3580
+ view_range: import_v417.z.array(import_v417.z.number().int()).optional()
3581
+ })
3582
+ )
3583
+ );
3584
+ var textEditor_20250429 = (0, import_provider_utils20.createProviderDefinedToolFactory)({
3473
3585
  id: "anthropic.text_editor_20250429",
3474
3586
  name: "str_replace_based_edit_tool",
3475
3587
  inputSchema: textEditor_20250429InputSchema
@@ -3519,6 +3631,19 @@ var anthropicTools = {
3519
3631
  * Tool name must be `code_execution`.
3520
3632
  */
3521
3633
  codeExecution_20250825,
3634
+ /**
3635
+ * Claude can analyze data, create visualizations, perform complex calculations,
3636
+ * run system commands, create and edit files, and process uploaded files directly within
3637
+ * the API conversation.
3638
+ *
3639
+ * The code execution tool allows Claude to run both Python and Bash commands and manipulate files,
3640
+ * including writing code, in a secure, sandboxed environment.
3641
+ *
3642
+ * This is the recommended version. Does not require a beta header.
3643
+ *
3644
+ * Supported models: Claude Opus 4.6, Sonnet 4.6, Sonnet 4.5, Opus 4.5
3645
+ */
3646
+ codeExecution_20260120,
3522
3647
  /**
3523
3648
  * Claude can interact with computer environments through the computer use tool, which
3524
3649
  * provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
@@ -3630,17 +3755,17 @@ var anthropicTools = {
3630
3755
  // src/anthropic-provider.ts
3631
3756
  function createAnthropic(options = {}) {
3632
3757
  var _a, _b;
3633
- const baseURL = (_a = (0, import_provider_utils20.withoutTrailingSlash)(
3634
- (0, import_provider_utils20.loadOptionalSetting)({
3758
+ const baseURL = (_a = (0, import_provider_utils21.withoutTrailingSlash)(
3759
+ (0, import_provider_utils21.loadOptionalSetting)({
3635
3760
  settingValue: options.baseURL,
3636
3761
  environmentVariableName: "ANTHROPIC_BASE_URL"
3637
3762
  })
3638
3763
  )) != null ? _a : "https://api.anthropic.com/v1";
3639
3764
  const providerName = (_b = options.name) != null ? _b : "anthropic.messages";
3640
- const getHeaders = () => (0, import_provider_utils20.withUserAgentSuffix)(
3765
+ const getHeaders = () => (0, import_provider_utils21.withUserAgentSuffix)(
3641
3766
  {
3642
3767
  "anthropic-version": "2023-06-01",
3643
- "x-api-key": (0, import_provider_utils20.loadApiKey)({
3768
+ "x-api-key": (0, import_provider_utils21.loadApiKey)({
3644
3769
  apiKey: options.apiKey,
3645
3770
  environmentVariableName: "ANTHROPIC_API_KEY",
3646
3771
  description: "Anthropic"
@@ -3656,7 +3781,7 @@ function createAnthropic(options = {}) {
3656
3781
  baseURL,
3657
3782
  headers: getHeaders,
3658
3783
  fetch: options.fetch,
3659
- generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils20.generateId,
3784
+ generateId: (_a2 = options.generateId) != null ? _a2 : import_provider_utils21.generateId,
3660
3785
  supportedUrls: () => ({
3661
3786
  "image/*": [/^https?:\/\/.*$/]
3662
3787
  })