@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.
@@ -653,6 +653,20 @@ var anthropicProviderOptions = z3.object({
653
653
  type: z3.literal("ephemeral"),
654
654
  ttl: z3.union([z3.literal("5m"), z3.literal("1h")]).optional()
655
655
  }).optional(),
656
+ /**
657
+ * Metadata to include with the request.
658
+ *
659
+ * See https://platform.claude.com/docs/en/api/messages/create for details.
660
+ */
661
+ metadata: z3.object({
662
+ /**
663
+ * An external identifier for the user associated with the request.
664
+ *
665
+ * Should be a UUID, hash value, or other opaque identifier.
666
+ * Must not contain PII (name, email, phone number, etc.).
667
+ */
668
+ userId: z3.string().optional()
669
+ }).optional(),
656
670
  /**
657
671
  * Agent Skills configuration. Skills enable Claude to perform specialized tasks
658
672
  * like document processing (PPTX, DOCX, PDF, XLSX) and data analysis.
@@ -984,6 +998,13 @@ async function prepareTools({
984
998
  });
985
999
  break;
986
1000
  }
1001
+ case "anthropic.code_execution_20260120": {
1002
+ anthropicTools2.push({
1003
+ type: "code_execution_20260120",
1004
+ name: "code_execution"
1005
+ });
1006
+ break;
1007
+ }
987
1008
  case "anthropic.computer_20250124": {
988
1009
  betas.add("computer-use-2025-01-24");
989
1010
  anthropicTools2.push({
@@ -1955,7 +1976,7 @@ var AnthropicMessagesLanguageModel = class {
1955
1976
  toolChoice,
1956
1977
  providerOptions
1957
1978
  }) {
1958
- var _a, _b, _c, _d, _e, _f;
1979
+ var _a, _b, _c, _d, _e, _f, _g;
1959
1980
  const warnings = [];
1960
1981
  if (frequencyPenalty != null) {
1961
1982
  warnings.push({
@@ -2059,6 +2080,9 @@ var AnthropicMessagesLanguageModel = class {
2059
2080
  ...(anthropicOptions == null ? void 0 : anthropicOptions.cacheControl) && {
2060
2081
  cache_control: anthropicOptions.cacheControl
2061
2082
  },
2083
+ ...((_e = anthropicOptions == null ? void 0 : anthropicOptions.metadata) == null ? void 0 : _e.userId) != null && {
2084
+ metadata: { user_id: anthropicOptions.metadata.userId }
2085
+ },
2062
2086
  // structured output:
2063
2087
  ...useStructuredOutput && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && {
2064
2088
  output_format: {
@@ -2070,7 +2094,7 @@ var AnthropicMessagesLanguageModel = class {
2070
2094
  ...(anthropicOptions == null ? void 0 : anthropicOptions.container) && {
2071
2095
  container: {
2072
2096
  id: anthropicOptions.container.id,
2073
- skills: (_e = anthropicOptions.container.skills) == null ? void 0 : _e.map((skill) => ({
2097
+ skills: (_f = anthropicOptions.container.skills) == null ? void 0 : _f.map((skill) => ({
2074
2098
  type: skill.type,
2075
2099
  skill_id: skill.skillId,
2076
2100
  version: skill.version
@@ -2179,7 +2203,7 @@ var AnthropicMessagesLanguageModel = class {
2179
2203
  betas.add("skills-2025-10-02");
2180
2204
  betas.add("files-api-2025-04-14");
2181
2205
  if (!(tools == null ? void 0 : tools.some(
2182
- (tool) => tool.type === "provider-defined" && tool.id === "anthropic.code_execution_20250825"
2206
+ (tool) => tool.type === "provider-defined" && (tool.id === "anthropic.code_execution_20250825" || tool.id === "anthropic.code_execution_20260120")
2183
2207
  ))) {
2184
2208
  warnings.push({
2185
2209
  type: "other",
@@ -2233,7 +2257,7 @@ var AnthropicMessagesLanguageModel = class {
2233
2257
  ...betas,
2234
2258
  ...toolsBetas,
2235
2259
  ...userSuppliedBetas,
2236
- ...(_f = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _f : []
2260
+ ...(_g = anthropicOptions == null ? void 0 : anthropicOptions.anthropicBeta) != null ? _g : []
2237
2261
  ]),
2238
2262
  usesJsonResponseTool: jsonResponseTool != null
2239
2263
  };
@@ -3290,17 +3314,126 @@ var bash_20250124 = createProviderDefinedToolFactory3({
3290
3314
  inputSchema: bash_20250124InputSchema
3291
3315
  });
3292
3316
 
3293
- // src/tool/computer_20241022.ts
3317
+ // src/tool/code-execution_20260120.ts
3294
3318
  import {
3295
- createProviderDefinedToolFactory as createProviderDefinedToolFactory4,
3319
+ createProviderDefinedToolFactoryWithOutputSchema as createProviderDefinedToolFactoryWithOutputSchema5,
3296
3320
  lazySchema as lazySchema10,
3297
3321
  zodSchema as zodSchema10
3298
3322
  } from "@ai-sdk/provider-utils";
3299
3323
  import { z as z11 } from "zod/v4";
3300
- var computer_20241022InputSchema = lazySchema10(
3324
+ var codeExecution_20260120OutputSchema = lazySchema10(
3301
3325
  () => zodSchema10(
3302
- z11.object({
3303
- action: z11.enum([
3326
+ z11.discriminatedUnion("type", [
3327
+ z11.object({
3328
+ type: z11.literal("code_execution_result"),
3329
+ stdout: z11.string(),
3330
+ stderr: z11.string(),
3331
+ return_code: z11.number(),
3332
+ content: z11.array(
3333
+ z11.object({
3334
+ type: z11.literal("code_execution_output"),
3335
+ file_id: z11.string()
3336
+ })
3337
+ ).optional().default([])
3338
+ }),
3339
+ z11.object({
3340
+ type: z11.literal("bash_code_execution_result"),
3341
+ content: z11.array(
3342
+ z11.object({
3343
+ type: z11.literal("bash_code_execution_output"),
3344
+ file_id: z11.string()
3345
+ })
3346
+ ),
3347
+ stdout: z11.string(),
3348
+ stderr: z11.string(),
3349
+ return_code: z11.number()
3350
+ }),
3351
+ z11.object({
3352
+ type: z11.literal("bash_code_execution_tool_result_error"),
3353
+ error_code: z11.string()
3354
+ }),
3355
+ z11.object({
3356
+ type: z11.literal("text_editor_code_execution_tool_result_error"),
3357
+ error_code: z11.string()
3358
+ }),
3359
+ z11.object({
3360
+ type: z11.literal("text_editor_code_execution_view_result"),
3361
+ content: z11.string(),
3362
+ file_type: z11.string(),
3363
+ num_lines: z11.number().nullable(),
3364
+ start_line: z11.number().nullable(),
3365
+ total_lines: z11.number().nullable()
3366
+ }),
3367
+ z11.object({
3368
+ type: z11.literal("text_editor_code_execution_create_result"),
3369
+ is_file_update: z11.boolean()
3370
+ }),
3371
+ z11.object({
3372
+ type: z11.literal("text_editor_code_execution_str_replace_result"),
3373
+ lines: z11.array(z11.string()).nullable(),
3374
+ new_lines: z11.number().nullable(),
3375
+ new_start: z11.number().nullable(),
3376
+ old_lines: z11.number().nullable(),
3377
+ old_start: z11.number().nullable()
3378
+ })
3379
+ ])
3380
+ )
3381
+ );
3382
+ var codeExecution_20260120InputSchema = lazySchema10(
3383
+ () => zodSchema10(
3384
+ z11.discriminatedUnion("type", [
3385
+ z11.object({
3386
+ type: z11.literal("programmatic-tool-call"),
3387
+ code: z11.string()
3388
+ }),
3389
+ z11.object({
3390
+ type: z11.literal("bash_code_execution"),
3391
+ command: z11.string()
3392
+ }),
3393
+ z11.discriminatedUnion("command", [
3394
+ z11.object({
3395
+ type: z11.literal("text_editor_code_execution"),
3396
+ command: z11.literal("view"),
3397
+ path: z11.string()
3398
+ }),
3399
+ z11.object({
3400
+ type: z11.literal("text_editor_code_execution"),
3401
+ command: z11.literal("create"),
3402
+ path: z11.string(),
3403
+ file_text: z11.string().nullish()
3404
+ }),
3405
+ z11.object({
3406
+ type: z11.literal("text_editor_code_execution"),
3407
+ command: z11.literal("str_replace"),
3408
+ path: z11.string(),
3409
+ old_str: z11.string(),
3410
+ new_str: z11.string()
3411
+ })
3412
+ ])
3413
+ ])
3414
+ )
3415
+ );
3416
+ var factory6 = createProviderDefinedToolFactoryWithOutputSchema5({
3417
+ id: "anthropic.code_execution_20260120",
3418
+ name: "code_execution",
3419
+ inputSchema: codeExecution_20260120InputSchema,
3420
+ outputSchema: codeExecution_20260120OutputSchema
3421
+ });
3422
+ var codeExecution_20260120 = (args = {}) => {
3423
+ return factory6(args);
3424
+ };
3425
+
3426
+ // src/tool/computer_20241022.ts
3427
+ import {
3428
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory4,
3429
+ lazySchema as lazySchema11,
3430
+ zodSchema as zodSchema11
3431
+ } from "@ai-sdk/provider-utils";
3432
+ import { z as z12 } from "zod/v4";
3433
+ var computer_20241022InputSchema = lazySchema11(
3434
+ () => zodSchema11(
3435
+ z12.object({
3436
+ action: z12.enum([
3304
3437
  "key",
3305
3438
  "type",
3306
3439
  "mouse_move",
@@ -3312,8 +3445,8 @@ var computer_20241022InputSchema = lazySchema10(
3312
3445
  "screenshot",
3313
3446
  "cursor_position"
3314
3447
  ]),
3315
- coordinate: z11.array(z11.number().int()).optional(),
3316
- text: z11.string().optional()
3448
+ coordinate: z12.array(z12.number().int()).optional(),
3449
+ text: z12.string().optional()
3317
3450
  })
3318
3451
  )
3319
3452
  );
@@ -3326,14 +3459,14 @@ var computer_20241022 = createProviderDefinedToolFactory4({
3326
3459
  // src/tool/computer_20250124.ts
3327
3460
  import {
3328
3461
  createProviderDefinedToolFactory as createProviderDefinedToolFactory5,
3329
- lazySchema as lazySchema11,
3330
- zodSchema as zodSchema11
3462
+ lazySchema as lazySchema12,
3463
+ zodSchema as zodSchema12
3331
3464
  } from "@ai-sdk/provider-utils";
3332
- import { z as z12 } from "zod/v4";
3333
- var computer_20250124InputSchema = lazySchema11(
3334
- () => zodSchema11(
3335
- z12.object({
3336
- action: z12.enum([
3465
+ import { z as z13 } from "zod/v4";
3466
+ var computer_20250124InputSchema = lazySchema12(
3467
+ () => zodSchema12(
3468
+ z13.object({
3469
+ action: z13.enum([
3337
3470
  "key",
3338
3471
  "hold_key",
3339
3472
  "type",
@@ -3351,12 +3484,12 @@ var computer_20250124InputSchema = lazySchema11(
3351
3484
  "wait",
3352
3485
  "screenshot"
3353
3486
  ]),
3354
- coordinate: z12.tuple([z12.number().int(), z12.number().int()]).optional(),
3355
- duration: z12.number().optional(),
3356
- scroll_amount: z12.number().optional(),
3357
- scroll_direction: z12.enum(["up", "down", "left", "right"]).optional(),
3358
- start_coordinate: z12.tuple([z12.number().int(), z12.number().int()]).optional(),
3359
- text: z12.string().optional()
3487
+ coordinate: z13.tuple([z13.number().int(), z13.number().int()]).optional(),
3488
+ duration: z13.number().optional(),
3489
+ scroll_amount: z13.number().optional(),
3490
+ scroll_direction: z13.enum(["up", "down", "left", "right"]).optional(),
3491
+ start_coordinate: z13.tuple([z13.number().int(), z13.number().int()]).optional(),
3492
+ text: z13.string().optional()
3360
3493
  })
3361
3494
  )
3362
3495
  );
@@ -3369,43 +3502,43 @@ var computer_20250124 = createProviderDefinedToolFactory5({
3369
3502
  // src/tool/memory_20250818.ts
3370
3503
  import {
3371
3504
  createProviderDefinedToolFactory as createProviderDefinedToolFactory6,
3372
- lazySchema as lazySchema12,
3373
- zodSchema as zodSchema12
3505
+ lazySchema as lazySchema13,
3506
+ zodSchema as zodSchema13
3374
3507
  } from "@ai-sdk/provider-utils";
3375
- import { z as z13 } from "zod/v4";
3376
- var memory_20250818InputSchema = lazySchema12(
3377
- () => zodSchema12(
3378
- z13.discriminatedUnion("command", [
3379
- z13.object({
3380
- command: z13.literal("view"),
3381
- path: z13.string(),
3382
- view_range: z13.tuple([z13.number(), z13.number()]).optional()
3508
+ import { z as z14 } from "zod/v4";
3509
+ var memory_20250818InputSchema = lazySchema13(
3510
+ () => zodSchema13(
3511
+ z14.discriminatedUnion("command", [
3512
+ z14.object({
3513
+ command: z14.literal("view"),
3514
+ path: z14.string(),
3515
+ view_range: z14.tuple([z14.number(), z14.number()]).optional()
3383
3516
  }),
3384
- z13.object({
3385
- command: z13.literal("create"),
3386
- path: z13.string(),
3387
- file_text: z13.string()
3517
+ z14.object({
3518
+ command: z14.literal("create"),
3519
+ path: z14.string(),
3520
+ file_text: z14.string()
3388
3521
  }),
3389
- z13.object({
3390
- command: z13.literal("str_replace"),
3391
- path: z13.string(),
3392
- old_str: z13.string(),
3393
- new_str: z13.string()
3522
+ z14.object({
3523
+ command: z14.literal("str_replace"),
3524
+ path: z14.string(),
3525
+ old_str: z14.string(),
3526
+ new_str: z14.string()
3394
3527
  }),
3395
- z13.object({
3396
- command: z13.literal("insert"),
3397
- path: z13.string(),
3398
- insert_line: z13.number(),
3399
- insert_text: z13.string()
3528
+ z14.object({
3529
+ command: z14.literal("insert"),
3530
+ path: z14.string(),
3531
+ insert_line: z14.number(),
3532
+ insert_text: z14.string()
3400
3533
  }),
3401
- z13.object({
3402
- command: z13.literal("delete"),
3403
- path: z13.string()
3534
+ z14.object({
3535
+ command: z14.literal("delete"),
3536
+ path: z14.string()
3404
3537
  }),
3405
- z13.object({
3406
- command: z13.literal("rename"),
3407
- old_path: z13.string(),
3408
- new_path: z13.string()
3538
+ z14.object({
3539
+ command: z14.literal("rename"),
3540
+ old_path: z14.string(),
3541
+ new_path: z14.string()
3409
3542
  })
3410
3543
  ])
3411
3544
  )
@@ -3419,37 +3552,11 @@ var memory_20250818 = createProviderDefinedToolFactory6({
3419
3552
  // src/tool/text-editor_20241022.ts
3420
3553
  import {
3421
3554
  createProviderDefinedToolFactory as createProviderDefinedToolFactory7,
3422
- lazySchema as lazySchema13,
3423
- zodSchema as zodSchema13
3424
- } from "@ai-sdk/provider-utils";
3425
- import { z as z14 } from "zod/v4";
3426
- var textEditor_20241022InputSchema = lazySchema13(
3427
- () => zodSchema13(
3428
- z14.object({
3429
- command: z14.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
3430
- path: z14.string(),
3431
- file_text: z14.string().optional(),
3432
- insert_line: z14.number().int().optional(),
3433
- new_str: z14.string().optional(),
3434
- old_str: z14.string().optional(),
3435
- view_range: z14.array(z14.number().int()).optional()
3436
- })
3437
- )
3438
- );
3439
- var textEditor_20241022 = createProviderDefinedToolFactory7({
3440
- id: "anthropic.text_editor_20241022",
3441
- name: "str_replace_editor",
3442
- inputSchema: textEditor_20241022InputSchema
3443
- });
3444
-
3445
- // src/tool/text-editor_20250124.ts
3446
- import {
3447
- createProviderDefinedToolFactory as createProviderDefinedToolFactory8,
3448
3555
  lazySchema as lazySchema14,
3449
3556
  zodSchema as zodSchema14
3450
3557
  } from "@ai-sdk/provider-utils";
3451
3558
  import { z as z15 } from "zod/v4";
3452
- var textEditor_20250124InputSchema = lazySchema14(
3559
+ var textEditor_20241022InputSchema = lazySchema14(
3453
3560
  () => zodSchema14(
3454
3561
  z15.object({
3455
3562
  command: z15.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
@@ -3462,23 +3569,23 @@ var textEditor_20250124InputSchema = lazySchema14(
3462
3569
  })
3463
3570
  )
3464
3571
  );
3465
- var textEditor_20250124 = createProviderDefinedToolFactory8({
3466
- id: "anthropic.text_editor_20250124",
3572
+ var textEditor_20241022 = createProviderDefinedToolFactory7({
3573
+ id: "anthropic.text_editor_20241022",
3467
3574
  name: "str_replace_editor",
3468
- inputSchema: textEditor_20250124InputSchema
3575
+ inputSchema: textEditor_20241022InputSchema
3469
3576
  });
3470
3577
 
3471
- // src/tool/text-editor_20250429.ts
3578
+ // src/tool/text-editor_20250124.ts
3472
3579
  import {
3473
- createProviderDefinedToolFactory as createProviderDefinedToolFactory9,
3580
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory8,
3474
3581
  lazySchema as lazySchema15,
3475
3582
  zodSchema as zodSchema15
3476
3583
  } from "@ai-sdk/provider-utils";
3477
3584
  import { z as z16 } from "zod/v4";
3478
- var textEditor_20250429InputSchema = lazySchema15(
3585
+ var textEditor_20250124InputSchema = lazySchema15(
3479
3586
  () => zodSchema15(
3480
3587
  z16.object({
3481
- command: z16.enum(["view", "create", "str_replace", "insert"]),
3588
+ command: z16.enum(["view", "create", "str_replace", "insert", "undo_edit"]),
3482
3589
  path: z16.string(),
3483
3590
  file_text: z16.string().optional(),
3484
3591
  insert_line: z16.number().int().optional(),
@@ -3488,6 +3595,32 @@ var textEditor_20250429InputSchema = lazySchema15(
3488
3595
  })
3489
3596
  )
3490
3597
  );
3598
+ var textEditor_20250124 = createProviderDefinedToolFactory8({
3599
+ id: "anthropic.text_editor_20250124",
3600
+ name: "str_replace_editor",
3601
+ inputSchema: textEditor_20250124InputSchema
3602
+ });
3603
+
3604
+ // src/tool/text-editor_20250429.ts
3605
+ import {
3606
+ createProviderDefinedToolFactory as createProviderDefinedToolFactory9,
3607
+ lazySchema as lazySchema16,
3608
+ zodSchema as zodSchema16
3609
+ } from "@ai-sdk/provider-utils";
3610
+ import { z as z17 } from "zod/v4";
3611
+ var textEditor_20250429InputSchema = lazySchema16(
3612
+ () => zodSchema16(
3613
+ z17.object({
3614
+ command: z17.enum(["view", "create", "str_replace", "insert"]),
3615
+ path: z17.string(),
3616
+ file_text: z17.string().optional(),
3617
+ insert_line: z17.number().int().optional(),
3618
+ new_str: z17.string().optional(),
3619
+ old_str: z17.string().optional(),
3620
+ view_range: z17.array(z17.number().int()).optional()
3621
+ })
3622
+ )
3623
+ );
3491
3624
  var textEditor_20250429 = createProviderDefinedToolFactory9({
3492
3625
  id: "anthropic.text_editor_20250429",
3493
3626
  name: "str_replace_based_edit_tool",
@@ -3538,6 +3671,19 @@ var anthropicTools = {
3538
3671
  * Tool name must be `code_execution`.
3539
3672
  */
3540
3673
  codeExecution_20250825,
3674
+ /**
3675
+ * Claude can analyze data, create visualizations, perform complex calculations,
3676
+ * run system commands, create and edit files, and process uploaded files directly within
3677
+ * the API conversation.
3678
+ *
3679
+ * The code execution tool allows Claude to run both Python and Bash commands and manipulate files,
3680
+ * including writing code, in a secure, sandboxed environment.
3681
+ *
3682
+ * This is the recommended version. Does not require a beta header.
3683
+ *
3684
+ * Supported models: Claude Opus 4.6, Sonnet 4.6, Sonnet 4.5, Opus 4.5
3685
+ */
3686
+ codeExecution_20260120,
3541
3687
  /**
3542
3688
  * Claude can interact with computer environments through the computer use tool, which
3543
3689
  * provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.