@ai-sdk/anthropic 2.0.70 → 2.0.72

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.70" : "0.0.0-test";
14
+ var VERSION = true ? "2.0.72" : "0.0.0-test";
15
15
 
16
16
  // src/anthropic-messages-language-model.ts
17
17
  import {
@@ -668,6 +668,20 @@ var anthropicProviderOptions = z3.object({
668
668
  type: z3.literal("ephemeral"),
669
669
  ttl: z3.union([z3.literal("5m"), z3.literal("1h")]).optional()
670
670
  }).optional(),
671
+ /**
672
+ * Metadata to include with the request.
673
+ *
674
+ * See https://platform.claude.com/docs/en/api/messages/create for details.
675
+ */
676
+ metadata: z3.object({
677
+ /**
678
+ * An external identifier for the user associated with the request.
679
+ *
680
+ * Should be a UUID, hash value, or other opaque identifier.
681
+ * Must not contain PII (name, email, phone number, etc.).
682
+ */
683
+ userId: z3.string().optional()
684
+ }).optional(),
671
685
  /**
672
686
  * Agent Skills configuration. Skills enable Claude to perform specialized tasks
673
687
  * like document processing (PPTX, DOCX, PDF, XLSX) and data analysis.
@@ -999,6 +1013,13 @@ async function prepareTools({
999
1013
  });
1000
1014
  break;
1001
1015
  }
1016
+ case "anthropic.code_execution_20260120": {
1017
+ anthropicTools2.push({
1018
+ type: "code_execution_20260120",
1019
+ name: "code_execution"
1020
+ });
1021
+ break;
1022
+ }
1002
1023
  case "anthropic.computer_20250124": {
1003
1024
  betas.add("computer-use-2025-01-24");
1004
1025
  anthropicTools2.push({
@@ -1970,7 +1991,7 @@ var AnthropicMessagesLanguageModel = class {
1970
1991
  toolChoice,
1971
1992
  providerOptions
1972
1993
  }) {
1973
- var _a, _b, _c, _d, _e, _f;
1994
+ var _a, _b, _c, _d, _e, _f, _g;
1974
1995
  const warnings = [];
1975
1996
  if (frequencyPenalty != null) {
1976
1997
  warnings.push({
@@ -2074,6 +2095,9 @@ var AnthropicMessagesLanguageModel = class {
2074
2095
  ...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
2075
2096
  cache_control: anthropicOptions.cacheControl
2076
2097
  },
2098
+ ...((_e = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _e.userId) != null && {
2099
+ metadata: { user_id: anthropicOptions.metadata.userId }
2100
+ },
2077
2101
  // structured output:
2078
2102
  ...useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && {
2079
2103
  output_format: {
@@ -2085,7 +2109,7 @@ var AnthropicMessagesLanguageModel = class {
2085
2109
  ...(anthropicOptions == null ? void 0 : anthropicOptions.container) && {
2086
2110
  container: {
2087
2111
  id: anthropicOptions.container.id,
2088
- skills: (_e = anthropicOptions.container.skills) == null ? void 0 : _e.map((skill) => ({
2112
+ skills: (_f = anthropicOptions.container.skills) == null ? void 0 : _f.map((skill) => ({
2089
2113
  type: skill.type,
2090
2114
  skill_id: skill.skillId,
2091
2115
  version: skill.version
@@ -2194,7 +2218,7 @@ var AnthropicMessagesLanguageModel = class {
2194
2218
  betas.add("skills-2025-10-02");
2195
2219
  betas.add("files-api-2025-04-14");
2196
2220
  if (!(tools == null ? void 0 : tools.some(
2197
- (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")
2198
2222
  ))) {
2199
2223
  warnings.push({
2200
2224
  type: "other",
@@ -2248,7 +2272,7 @@ var AnthropicMessagesLanguageModel = class {
2248
2272
  ...betas,
2249
2273
  ...toolsBetas,
2250
2274
  ...userSuppliedBetas,
2251
- ...(_f = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _f : []
2275
+ ...(_g = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _g : []
2252
2276
  ]),
2253
2277
  usesJsonResponseTool: jsonResponseTool != null
2254
2278
  };
@@ -3305,17 +3329,126 @@ var bash_20250124 = createProviderDefinedToolFactory3({
3305
3329
  inputSchema: bash_20250124InputSchema
3306
3330
  });
3307
3331
 
3308
- // src/tool/computer_20241022.ts
3332
+ // src/tool/code-execution_20260120.ts
3309
3333
  import {
3310
- createProviderDefinedToolFactory as createProviderDefinedToolFactory4,
3334
+ createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema5,
3311
3335
  lazySchema as lazySchema10,
3312
3336
  zodSchema as zodSchema10
3313
3337
  } from "@ai-sdk/provider-utils";
3314
3338
  import { z as z11 } from "zod/v4";
3315
- var computer_20241022InputSchema = lazySchema10(
3339
+ var codeExecution_20260120OutputSchema = lazySchema10(
3316
3340
  () => zodSchema10(
3317
- z11.object({
3318
- 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([
3319
3452
  "key",
3320
3453
  "type",
3321
3454
  "mouse_move",
@@ -3327,8 +3460,8 @@ var computer_20241022InputSchema = lazySchema10(
3327
3460
  "screenshot",
3328
3461
  "cursor_position"
3329
3462
  ]),
3330
- coordinate: z11.array(z11.number().int()).optional(),
3331
- text: z11.string().optional()
3463
+ coordinate: z12.array(z12.number().int()).optional(),
3464
+ text: z12.string().optional()
3332
3465
  })
3333
3466
  )
3334
3467
  );
@@ -3341,14 +3474,14 @@ var computer_20241022 = createProviderDefinedToolFactory4({
3341
3474
  // src/tool/computer_20250124.ts
3342
3475
  import {
3343
3476
  createProviderDefinedToolFactory as createProviderDefinedToolFactory5,
3344
- lazySchema as lazySchema11,
3345
- zodSchema as zodSchema11
3477
+ lazySchema as lazySchema12,
3478
+ zodSchema as zodSchema12
3346
3479
  } from "@ai-sdk/provider-utils";
3347
- import { z as z12 } from "zod/v4";
3348
- var computer_20250124InputSchema = lazySchema11(
3349
- () => zodSchema11(
3350
- z12.object({
3351
- 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([
3352
3485
  "key",
3353
3486
  "hold_key",
3354
3487
  "type",
@@ -3366,12 +3499,12 @@ var computer_20250124InputSchema = lazySchema11(
3366
3499
  "wait",
3367
3500
  "screenshot"
3368
3501
  ]),
3369
- coordinate: z12.tuple([z12.number().int(), z12.number().int()]).optional(),
3370
- duration: z12.number().optional(),
3371
- scroll_amount: z12.number().optional(),
3372
- scroll_direction: z12.enum(["up", "down", "left", "right"]).optional(),
3373
- start_coordinate: z12.tuple([z12.number().int(), z12.number().int()]).optional(),
3374
- 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()
3375
3508
  })
3376
3509
  )
3377
3510
  );
@@ -3384,43 +3517,43 @@ var computer_20250124 = createProviderDefinedToolFactory5({
3384
3517
  // src/tool/memory_20250818.ts
3385
3518
  import {
3386
3519
  createProviderDefinedToolFactory as createProviderDefinedToolFactory6,
3387
- lazySchema as lazySchema12,
3388
- zodSchema as zodSchema12
3520
+ lazySchema as lazySchema13,
3521
+ zodSchema as zodSchema13
3389
3522
  } from "@ai-sdk/provider-utils";
3390
- import { z as z13 } from "zod/v4";
3391
- var memory_20250818InputSchema = lazySchema12(
3392
- () => zodSchema12(
3393
- z13.discriminatedUnion("command", [
3394
- z13.object({
3395
- command: z13.literal("view"),
3396
- path: z13.string(),
3397
- 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()
3398
3531
  }),
3399
- z13.object({
3400
- command: z13.literal("create"),
3401
- path: z13.string(),
3402
- file_text: z13.string()
3532
+ z14.object({
3533
+ command: z14.literal("create"),
3534
+ path: z14.string(),
3535
+ file_text: z14.string()
3403
3536
  }),
3404
- z13.object({
3405
- command: z13.literal("str_replace"),
3406
- path: z13.string(),
3407
- old_str: z13.string(),
3408
- 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()
3409
3542
  }),
3410
- z13.object({
3411
- command: z13.literal("insert"),
3412
- path: z13.string(),
3413
- insert_line: z13.number(),
3414
- 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()
3415
3548
  }),
3416
- z13.object({
3417
- command: z13.literal("delete"),
3418
- path: z13.string()
3549
+ z14.object({
3550
+ command: z14.literal("delete"),
3551
+ path: z14.string()
3419
3552
  }),
3420
- z13.object({
3421
- command: z13.literal("rename"),
3422
- old_path: z13.string(),
3423
- new_path: z13.string()
3553
+ z14.object({
3554
+ command: z14.literal("rename"),
3555
+ old_path: z14.string(),
3556
+ new_path: z14.string()
3424
3557
  })
3425
3558
  ])
3426
3559
  )
@@ -3434,37 +3567,11 @@ var memory_20250818 = createProviderDefinedToolFactory6({
3434
3567
  // src/tool/text-editor_20241022.ts
3435
3568
  import {
3436
3569
  createProviderDefinedToolFactory as createProviderDefinedToolFactory7,
3437
- lazySchema as lazySchema13,
3438
- zodSchema as zodSchema13
3439
- } from "@ai-sdk/provider-utils";
3440
- import { z as z14 } from "zod/v4";
3441
- var textEditor_20241022InputSchema = lazySchema13(
3442
- () => zodSchema13(
3443
- z14.object({
3444
- command: z14.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
3445
- path: z14.string(),
3446
- file_text: z14.string().optional(),
3447
- insert_line: z14.number().int().optional(),
3448
- new_str: z14.string().optional(),
3449
- old_str: z14.string().optional(),
3450
- view_range: z14.array(z14.number().int()).optional()
3451
- })
3452
- )
3453
- );
3454
- var textEditor_20241022 = createProviderDefinedToolFactory7({
3455
- id: "anthropic.text_editor_20241022",
3456
- name: "str_replace_editor",
3457
- inputSchema: textEditor_20241022InputSchema
3458
- });
3459
-
3460
- // src/tool/text-editor_20250124.ts
3461
- import {
3462
- createProviderDefinedToolFactory as createProviderDefinedToolFactory8,
3463
3570
  lazySchema as lazySchema14,
3464
3571
  zodSchema as zodSchema14
3465
3572
  } from "@ai-sdk/provider-utils";
3466
3573
  import { z as z15 } from "zod/v4";
3467
- var textEditor_20250124InputSchema = lazySchema14(
3574
+ var textEditor_20241022InputSchema = lazySchema14(
3468
3575
  () => zodSchema14(
3469
3576
  z15.object({
3470
3577
  command: z15.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
@@ -3477,23 +3584,23 @@ var textEditor_20250124InputSchema = lazySchema14(
3477
3584
  })
3478
3585
  )
3479
3586
  );
3480
- var textEditor_20250124 = createProviderDefinedToolFactory8({
3481
- id: "anthropic.text_editor_20250124",
3587
+ var textEditor_20241022 = createProviderDefinedToolFactory7({
3588
+ id: "anthropic.text_editor_20241022",
3482
3589
  name: "str_replace_editor",
3483
- inputSchema: textEditor_20250124InputSchema
3590
+ inputSchema: textEditor_20241022InputSchema
3484
3591
  });
3485
3592
 
3486
- // src/tool/text-editor_20250429.ts
3593
+ // src/tool/text-editor_20250124.ts
3487
3594
  import {
3488
- createProviderDefinedToolFactory as createProviderDefinedToolFactory9,
3595
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory8,
3489
3596
  lazySchema as lazySchema15,
3490
3597
  zodSchema as zodSchema15
3491
3598
  } from "@ai-sdk/provider-utils";
3492
3599
  import { z as z16 } from "zod/v4";
3493
- var textEditor_20250429InputSchema = lazySchema15(
3600
+ var textEditor_20250124InputSchema = lazySchema15(
3494
3601
  () => zodSchema15(
3495
3602
  z16.object({
3496
- command: z16.enum(["view", "create", "str_replace", "insert"]),
3603
+ command: z16.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
3497
3604
  path: z16.string(),
3498
3605
  file_text: z16.string().optional(),
3499
3606
  insert_line: z16.number().int().optional(),
@@ -3503,6 +3610,32 @@ var textEditor_20250429InputSchema = lazySchema15(
3503
3610
  })
3504
3611
  )
3505
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
+ );
3506
3639
  var textEditor_20250429 = createProviderDefinedToolFactory9({
3507
3640
  id: "anthropic.text_editor_20250429",
3508
3641
  name: "str_replace_based_edit_tool",
@@ -3553,6 +3686,19 @@ var anthropicTools = {
3553
3686
  * Tool name must be `code_execution`.
3554
3687
  */
3555
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,
3556
3702
  /**
3557
3703
  * Claude can interact with computer environments through the computer use tool, which
3558
3704
  * provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.