@ai-sdk/anthropic 3.0.0-beta.30 → 3.0.0-beta.32

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.
@@ -1,4 +1,4 @@
1
- import { LanguageModelV3, JSONSchema7, LanguageModelV3CallOptions, LanguageModelV3CallWarning } from '@ai-sdk/provider';
1
+ import { LanguageModelV3, JSONSchema7, SharedV3ProviderMetadata, LanguageModelV3CallWarning, LanguageModelV3CallOptions } from '@ai-sdk/provider';
2
2
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
3
3
  import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
4
4
 
@@ -463,6 +463,7 @@ declare const anthropicTools: {
463
463
 
464
464
  type AnthropicCacheControl = {
465
465
  type: 'ephemeral';
466
+ ttl?: '5m' | '1h';
466
467
  };
467
468
  type AnthropicTool = {
468
469
  name: string;
@@ -472,6 +473,7 @@ type AnthropicTool = {
472
473
  } | {
473
474
  type: 'code_execution_20250522';
474
475
  name: string;
476
+ cache_control: AnthropicCacheControl | undefined;
475
477
  } | {
476
478
  type: 'code_execution_20250825';
477
479
  name: string;
@@ -481,16 +483,20 @@ type AnthropicTool = {
481
483
  display_width_px: number;
482
484
  display_height_px: number;
483
485
  display_number: number;
486
+ cache_control: AnthropicCacheControl | undefined;
484
487
  } | {
485
488
  name: string;
486
489
  type: 'text_editor_20250124' | 'text_editor_20241022' | 'text_editor_20250429';
490
+ cache_control: AnthropicCacheControl | undefined;
487
491
  } | {
488
492
  name: string;
489
493
  type: 'text_editor_20250728';
490
494
  max_characters?: number;
495
+ cache_control: AnthropicCacheControl | undefined;
491
496
  } | {
492
497
  name: string;
493
498
  type: 'bash_20250124' | 'bash_20241022';
499
+ cache_control: AnthropicCacheControl | undefined;
494
500
  } | {
495
501
  name: string;
496
502
  type: 'memory_20250818';
@@ -504,6 +510,7 @@ type AnthropicTool = {
504
510
  enabled: boolean;
505
511
  };
506
512
  max_content_tokens?: number;
513
+ cache_control: AnthropicCacheControl | undefined;
507
514
  } | {
508
515
  type: 'web_search_20250305';
509
516
  name: string;
@@ -517,6 +524,7 @@ type AnthropicTool = {
517
524
  country?: string;
518
525
  timezone?: string;
519
526
  };
527
+ cache_control: AnthropicCacheControl | undefined;
520
528
  };
521
529
  type AnthropicToolChoice = {
522
530
  type: 'auto' | 'any';
@@ -527,10 +535,21 @@ type AnthropicToolChoice = {
527
535
  disable_parallel_tool_use?: boolean;
528
536
  };
529
537
 
530
- declare function prepareTools({ tools, toolChoice, disableParallelToolUse, }: {
538
+ declare class CacheControlValidator {
539
+ private breakpointCount;
540
+ private warnings;
541
+ getCacheControl(providerMetadata: SharedV3ProviderMetadata | undefined, context: {
542
+ type: string;
543
+ canCache: boolean;
544
+ }): AnthropicCacheControl | undefined;
545
+ getWarnings(): LanguageModelV3CallWarning[];
546
+ }
547
+
548
+ declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheControlValidator, }: {
531
549
  tools: LanguageModelV3CallOptions['tools'];
532
550
  toolChoice?: LanguageModelV3CallOptions['toolChoice'];
533
551
  disableParallelToolUse?: boolean;
552
+ cacheControlValidator?: CacheControlValidator;
534
553
  }): Promise<{
535
554
  tools: Array<AnthropicTool> | undefined;
536
555
  toolChoice: AnthropicToolChoice | undefined;
@@ -1,4 +1,4 @@
1
- import { LanguageModelV3, JSONSchema7, LanguageModelV3CallOptions, LanguageModelV3CallWarning } from '@ai-sdk/provider';
1
+ import { LanguageModelV3, JSONSchema7, SharedV3ProviderMetadata, LanguageModelV3CallWarning, LanguageModelV3CallOptions } from '@ai-sdk/provider';
2
2
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
3
3
  import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
4
4
 
@@ -463,6 +463,7 @@ declare const anthropicTools: {
463
463
 
464
464
  type AnthropicCacheControl = {
465
465
  type: 'ephemeral';
466
+ ttl?: '5m' | '1h';
466
467
  };
467
468
  type AnthropicTool = {
468
469
  name: string;
@@ -472,6 +473,7 @@ type AnthropicTool = {
472
473
  } | {
473
474
  type: 'code_execution_20250522';
474
475
  name: string;
476
+ cache_control: AnthropicCacheControl | undefined;
475
477
  } | {
476
478
  type: 'code_execution_20250825';
477
479
  name: string;
@@ -481,16 +483,20 @@ type AnthropicTool = {
481
483
  display_width_px: number;
482
484
  display_height_px: number;
483
485
  display_number: number;
486
+ cache_control: AnthropicCacheControl | undefined;
484
487
  } | {
485
488
  name: string;
486
489
  type: 'text_editor_20250124' | 'text_editor_20241022' | 'text_editor_20250429';
490
+ cache_control: AnthropicCacheControl | undefined;
487
491
  } | {
488
492
  name: string;
489
493
  type: 'text_editor_20250728';
490
494
  max_characters?: number;
495
+ cache_control: AnthropicCacheControl | undefined;
491
496
  } | {
492
497
  name: string;
493
498
  type: 'bash_20250124' | 'bash_20241022';
499
+ cache_control: AnthropicCacheControl | undefined;
494
500
  } | {
495
501
  name: string;
496
502
  type: 'memory_20250818';
@@ -504,6 +510,7 @@ type AnthropicTool = {
504
510
  enabled: boolean;
505
511
  };
506
512
  max_content_tokens?: number;
513
+ cache_control: AnthropicCacheControl | undefined;
507
514
  } | {
508
515
  type: 'web_search_20250305';
509
516
  name: string;
@@ -517,6 +524,7 @@ type AnthropicTool = {
517
524
  country?: string;
518
525
  timezone?: string;
519
526
  };
527
+ cache_control: AnthropicCacheControl | undefined;
520
528
  };
521
529
  type AnthropicToolChoice = {
522
530
  type: 'auto' | 'any';
@@ -527,10 +535,21 @@ type AnthropicToolChoice = {
527
535
  disable_parallel_tool_use?: boolean;
528
536
  };
529
537
 
530
- declare function prepareTools({ tools, toolChoice, disableParallelToolUse, }: {
538
+ declare class CacheControlValidator {
539
+ private breakpointCount;
540
+ private warnings;
541
+ getCacheControl(providerMetadata: SharedV3ProviderMetadata | undefined, context: {
542
+ type: string;
543
+ canCache: boolean;
544
+ }): AnthropicCacheControl | undefined;
545
+ getWarnings(): LanguageModelV3CallWarning[];
546
+ }
547
+
548
+ declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheControlValidator, }: {
531
549
  tools: LanguageModelV3CallOptions['tools'];
532
550
  toolChoice?: LanguageModelV3CallOptions['toolChoice'];
533
551
  disableParallelToolUse?: boolean;
552
+ cacheControlValidator?: CacheControlValidator;
534
553
  }): Promise<{
535
554
  tools: Array<AnthropicTool> | undefined;
536
555
  toolChoice: AnthropicToolChoice | undefined;
@@ -256,7 +256,18 @@ var anthropicMessagesResponseSchema = (0, import_provider_utils2.lazySchema)(
256
256
  output_tokens: import_v42.z.number(),
257
257
  cache_creation_input_tokens: import_v42.z.number().nullish(),
258
258
  cache_read_input_tokens: import_v42.z.number().nullish()
259
- })
259
+ }),
260
+ container: import_v42.z.object({
261
+ expires_at: import_v42.z.string(),
262
+ id: import_v42.z.string(),
263
+ skills: import_v42.z.array(
264
+ import_v42.z.object({
265
+ type: import_v42.z.union([import_v42.z.literal("anthropic"), import_v42.z.literal("custom")]),
266
+ skill_id: import_v42.z.string(),
267
+ version: import_v42.z.string()
268
+ })
269
+ ).nullish()
270
+ }).nullish()
260
271
  })
261
272
  )
262
273
  );
@@ -504,7 +515,21 @@ var anthropicMessagesChunkSchema = (0, import_provider_utils2.lazySchema)(
504
515
  type: import_v42.z.literal("message_delta"),
505
516
  delta: import_v42.z.object({
506
517
  stop_reason: import_v42.z.string().nullish(),
507
- stop_sequence: import_v42.z.string().nullish()
518
+ stop_sequence: import_v42.z.string().nullish(),
519
+ container: import_v42.z.object({
520
+ expires_at: import_v42.z.string(),
521
+ id: import_v42.z.string(),
522
+ skills: import_v42.z.array(
523
+ import_v42.z.object({
524
+ type: import_v42.z.union([
525
+ import_v42.z.literal("anthropic"),
526
+ import_v42.z.literal("custom")
527
+ ]),
528
+ skill_id: import_v42.z.string(),
529
+ version: import_v42.z.string()
530
+ })
531
+ ).nullish()
532
+ }).nullish()
508
533
  }),
509
534
  usage: import_v42.z.looseObject({
510
535
  output_tokens: import_v42.z.number(),
@@ -606,12 +631,46 @@ var anthropicProviderOptions = import_v43.z.object({
606
631
  var import_provider = require("@ai-sdk/provider");
607
632
 
608
633
  // src/get-cache-control.ts
634
+ var MAX_CACHE_BREAKPOINTS = 4;
609
635
  function getCacheControl(providerMetadata) {
610
636
  var _a;
611
637
  const anthropic = providerMetadata == null ? void 0 : providerMetadata.anthropic;
612
638
  const cacheControlValue = (_a = anthropic == null ? void 0 : anthropic.cacheControl) != null ? _a : anthropic == null ? void 0 : anthropic.cache_control;
613
639
  return cacheControlValue;
614
640
  }
641
+ var CacheControlValidator = class {
642
+ constructor() {
643
+ this.breakpointCount = 0;
644
+ this.warnings = [];
645
+ }
646
+ getCacheControl(providerMetadata, context) {
647
+ const cacheControlValue = getCacheControl(providerMetadata);
648
+ if (!cacheControlValue) {
649
+ return void 0;
650
+ }
651
+ if (!context.canCache) {
652
+ this.warnings.push({
653
+ type: "unsupported-setting",
654
+ setting: "cacheControl",
655
+ details: `cache_control cannot be set on ${context.type}. It will be ignored.`
656
+ });
657
+ return void 0;
658
+ }
659
+ this.breakpointCount++;
660
+ if (this.breakpointCount > MAX_CACHE_BREAKPOINTS) {
661
+ this.warnings.push({
662
+ type: "unsupported-setting",
663
+ setting: "cacheControl",
664
+ details: `Maximum ${MAX_CACHE_BREAKPOINTS} cache breakpoints exceeded (found ${this.breakpointCount}). This breakpoint will be ignored.`
665
+ });
666
+ return void 0;
667
+ }
668
+ return cacheControlValue;
669
+ }
670
+ getWarnings() {
671
+ return this.warnings;
672
+ }
673
+ };
615
674
 
616
675
  // src/tool/text-editor_20250728.ts
617
676
  var import_provider_utils3 = require("@ai-sdk/provider-utils");
@@ -757,11 +816,13 @@ var import_provider_utils7 = require("@ai-sdk/provider-utils");
757
816
  async function prepareTools({
758
817
  tools,
759
818
  toolChoice,
760
- disableParallelToolUse
819
+ disableParallelToolUse,
820
+ cacheControlValidator
761
821
  }) {
762
822
  tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
763
823
  const toolWarnings = [];
764
824
  const betas = /* @__PURE__ */ new Set();
825
+ const validator = cacheControlValidator || new CacheControlValidator();
765
826
  if (tools == null) {
766
827
  return { tools: void 0, toolChoice: void 0, toolWarnings, betas };
767
828
  }
@@ -769,7 +830,10 @@ async function prepareTools({
769
830
  for (const tool of tools) {
770
831
  switch (tool.type) {
771
832
  case "function": {
772
- const cacheControl = getCacheControl(tool.providerOptions);
833
+ const cacheControl = validator.getCacheControl(tool.providerOptions, {
834
+ type: "tool definition",
835
+ canCache: true
836
+ });
773
837
  anthropicTools2.push({
774
838
  name: tool.name,
775
839
  description: tool.description,
@@ -784,7 +848,8 @@ async function prepareTools({
784
848
  betas.add("code-execution-2025-05-22");
785
849
  anthropicTools2.push({
786
850
  type: "code_execution_20250522",
787
- name: "code_execution"
851
+ name: "code_execution",
852
+ cache_control: void 0
788
853
  });
789
854
  break;
790
855
  }
@@ -803,7 +868,8 @@ async function prepareTools({
803
868
  type: "computer_20250124",
804
869
  display_width_px: tool.args.displayWidthPx,
805
870
  display_height_px: tool.args.displayHeightPx,
806
- display_number: tool.args.displayNumber
871
+ display_number: tool.args.displayNumber,
872
+ cache_control: void 0
807
873
  });
808
874
  break;
809
875
  }
@@ -814,7 +880,8 @@ async function prepareTools({
814
880
  type: "computer_20241022",
815
881
  display_width_px: tool.args.displayWidthPx,
816
882
  display_height_px: tool.args.displayHeightPx,
817
- display_number: tool.args.displayNumber
883
+ display_number: tool.args.displayNumber,
884
+ cache_control: void 0
818
885
  });
819
886
  break;
820
887
  }
@@ -822,7 +889,8 @@ async function prepareTools({
822
889
  betas.add("computer-use-2025-01-24");
823
890
  anthropicTools2.push({
824
891
  name: "str_replace_editor",
825
- type: "text_editor_20250124"
892
+ type: "text_editor_20250124",
893
+ cache_control: void 0
826
894
  });
827
895
  break;
828
896
  }
@@ -830,7 +898,8 @@ async function prepareTools({
830
898
  betas.add("computer-use-2024-10-22");
831
899
  anthropicTools2.push({
832
900
  name: "str_replace_editor",
833
- type: "text_editor_20241022"
901
+ type: "text_editor_20241022",
902
+ cache_control: void 0
834
903
  });
835
904
  break;
836
905
  }
@@ -838,7 +907,8 @@ async function prepareTools({
838
907
  betas.add("computer-use-2025-01-24");
839
908
  anthropicTools2.push({
840
909
  name: "str_replace_based_edit_tool",
841
- type: "text_editor_20250429"
910
+ type: "text_editor_20250429",
911
+ cache_control: void 0
842
912
  });
843
913
  break;
844
914
  }
@@ -850,7 +920,8 @@ async function prepareTools({
850
920
  anthropicTools2.push({
851
921
  name: "str_replace_based_edit_tool",
852
922
  type: "text_editor_20250728",
853
- max_characters: args.maxCharacters
923
+ max_characters: args.maxCharacters,
924
+ cache_control: void 0
854
925
  });
855
926
  break;
856
927
  }
@@ -858,7 +929,8 @@ async function prepareTools({
858
929
  betas.add("computer-use-2025-01-24");
859
930
  anthropicTools2.push({
860
931
  name: "bash",
861
- type: "bash_20250124"
932
+ type: "bash_20250124",
933
+ cache_control: void 0
862
934
  });
863
935
  break;
864
936
  }
@@ -866,7 +938,8 @@ async function prepareTools({
866
938
  betas.add("computer-use-2024-10-22");
867
939
  anthropicTools2.push({
868
940
  name: "bash",
869
- type: "bash_20241022"
941
+ type: "bash_20241022",
942
+ cache_control: void 0
870
943
  });
871
944
  break;
872
945
  }
@@ -891,7 +964,8 @@ async function prepareTools({
891
964
  allowed_domains: args.allowedDomains,
892
965
  blocked_domains: args.blockedDomains,
893
966
  citations: args.citations,
894
- max_content_tokens: args.maxContentTokens
967
+ max_content_tokens: args.maxContentTokens,
968
+ cache_control: void 0
895
969
  });
896
970
  break;
897
971
  }
@@ -906,7 +980,8 @@ async function prepareTools({
906
980
  max_uses: args.maxUses,
907
981
  allowed_domains: args.allowedDomains,
908
982
  blocked_domains: args.blockedDomains,
909
- user_location: args.userLocation
983
+ user_location: args.userLocation,
984
+ cache_control: void 0
910
985
  });
911
986
  break;
912
987
  }
@@ -1118,11 +1193,13 @@ function convertToString(data) {
1118
1193
  async function convertToAnthropicMessagesPrompt({
1119
1194
  prompt,
1120
1195
  sendReasoning,
1121
- warnings
1196
+ warnings,
1197
+ cacheControlValidator
1122
1198
  }) {
1123
1199
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
1124
1200
  const betas = /* @__PURE__ */ new Set();
1125
1201
  const blocks = groupIntoBlocks(prompt);
1202
+ const validator = cacheControlValidator || new CacheControlValidator();
1126
1203
  let system = void 0;
1127
1204
  const messages = [];
1128
1205
  async function shouldEnableCitations(providerMetadata) {
@@ -1159,7 +1236,10 @@ async function convertToAnthropicMessagesPrompt({
1159
1236
  system = block.messages.map(({ content, providerOptions }) => ({
1160
1237
  type: "text",
1161
1238
  text: content,
1162
- cache_control: getCacheControl(providerOptions)
1239
+ cache_control: validator.getCacheControl(providerOptions, {
1240
+ type: "system message",
1241
+ canCache: true
1242
+ })
1163
1243
  }));
1164
1244
  break;
1165
1245
  }
@@ -1172,7 +1252,13 @@ async function convertToAnthropicMessagesPrompt({
1172
1252
  for (let j = 0; j < content.length; j++) {
1173
1253
  const part = content[j];
1174
1254
  const isLastPart = j === content.length - 1;
1175
- const cacheControl = (_a = getCacheControl(part.providerOptions)) != null ? _a : isLastPart ? getCacheControl(message.providerOptions) : void 0;
1255
+ const cacheControl = (_a = validator.getCacheControl(part.providerOptions, {
1256
+ type: "user message part",
1257
+ canCache: true
1258
+ })) != null ? _a : isLastPart ? validator.getCacheControl(message.providerOptions, {
1259
+ type: "user message",
1260
+ canCache: true
1261
+ }) : void 0;
1176
1262
  switch (part.type) {
1177
1263
  case "text": {
1178
1264
  anthropicContent.push({
@@ -1260,7 +1346,13 @@ async function convertToAnthropicMessagesPrompt({
1260
1346
  for (let i2 = 0; i2 < content.length; i2++) {
1261
1347
  const part = content[i2];
1262
1348
  const isLastPart = i2 === content.length - 1;
1263
- const cacheControl = (_d = getCacheControl(part.providerOptions)) != null ? _d : isLastPart ? getCacheControl(message.providerOptions) : void 0;
1349
+ const cacheControl = (_d = validator.getCacheControl(part.providerOptions, {
1350
+ type: "tool result part",
1351
+ canCache: true
1352
+ })) != null ? _d : isLastPart ? validator.getCacheControl(message.providerOptions, {
1353
+ type: "tool result message",
1354
+ canCache: true
1355
+ }) : void 0;
1264
1356
  const output = part.output;
1265
1357
  let contentValue;
1266
1358
  switch (output.type) {
@@ -1270,8 +1362,7 @@ async function convertToAnthropicMessagesPrompt({
1270
1362
  case "text":
1271
1363
  return {
1272
1364
  type: "text",
1273
- text: contentPart.text,
1274
- cache_control: cacheControl
1365
+ text: contentPart.text
1275
1366
  };
1276
1367
  case "image-data": {
1277
1368
  return {
@@ -1280,8 +1371,7 @@ async function convertToAnthropicMessagesPrompt({
1280
1371
  type: "base64",
1281
1372
  media_type: contentPart.mediaType,
1282
1373
  data: contentPart.data
1283
- },
1284
- cache_control: cacheControl
1374
+ }
1285
1375
  };
1286
1376
  }
1287
1377
  case "file-data": {
@@ -1293,8 +1383,7 @@ async function convertToAnthropicMessagesPrompt({
1293
1383
  type: "base64",
1294
1384
  media_type: contentPart.mediaType,
1295
1385
  data: contentPart.data
1296
- },
1297
- cache_control: cacheControl
1386
+ }
1298
1387
  };
1299
1388
  }
1300
1389
  warnings.push({
@@ -1355,7 +1444,13 @@ async function convertToAnthropicMessagesPrompt({
1355
1444
  for (let k = 0; k < content.length; k++) {
1356
1445
  const part = content[k];
1357
1446
  const isLastContentPart = k === content.length - 1;
1358
- const cacheControl = (_f = getCacheControl(part.providerOptions)) != null ? _f : isLastContentPart ? getCacheControl(message.providerOptions) : void 0;
1447
+ const cacheControl = (_f = validator.getCacheControl(part.providerOptions, {
1448
+ type: "assistant message part",
1449
+ canCache: true
1450
+ })) != null ? _f : isLastContentPart ? validator.getCacheControl(message.providerOptions, {
1451
+ type: "assistant message",
1452
+ canCache: true
1453
+ }) : void 0;
1359
1454
  switch (part.type) {
1360
1455
  case "text": {
1361
1456
  anthropicContent.push({
@@ -1379,17 +1474,23 @@ async function convertToAnthropicMessagesPrompt({
1379
1474
  });
1380
1475
  if (reasoningMetadata != null) {
1381
1476
  if (reasoningMetadata.signature != null) {
1477
+ validator.getCacheControl(part.providerOptions, {
1478
+ type: "thinking block",
1479
+ canCache: false
1480
+ });
1382
1481
  anthropicContent.push({
1383
1482
  type: "thinking",
1384
1483
  thinking: part.text,
1385
- signature: reasoningMetadata.signature,
1386
- cache_control: cacheControl
1484
+ signature: reasoningMetadata.signature
1387
1485
  });
1388
1486
  } else if (reasoningMetadata.redactedData != null) {
1487
+ validator.getCacheControl(part.providerOptions, {
1488
+ type: "redacted thinking block",
1489
+ canCache: false
1490
+ });
1389
1491
  anthropicContent.push({
1390
1492
  type: "redacted_thinking",
1391
- data: reasoningMetadata.redactedData,
1392
- cache_control: cacheControl
1493
+ data: reasoningMetadata.redactedData
1393
1494
  });
1394
1495
  } else {
1395
1496
  warnings.push({
@@ -1802,10 +1903,12 @@ var AnthropicMessagesLanguageModel = class {
1802
1903
  providerOptions,
1803
1904
  schema: anthropicProviderOptions
1804
1905
  });
1906
+ const cacheControlValidator = new CacheControlValidator();
1805
1907
  const { prompt: messagesPrompt, betas } = await convertToAnthropicMessagesPrompt({
1806
1908
  prompt,
1807
1909
  sendReasoning: (_a = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _a : true,
1808
- warnings
1910
+ warnings,
1911
+ cacheControlValidator
1809
1912
  });
1810
1913
  const isThinking = ((_b = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _b.type) === "enabled";
1811
1914
  const thinkingBudget = (_c = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _c.budgetTokens;
@@ -1919,20 +2022,23 @@ var AnthropicMessagesLanguageModel = class {
1919
2022
  jsonResponseTool != null ? {
1920
2023
  tools: [jsonResponseTool],
1921
2024
  toolChoice: { type: "tool", toolName: jsonResponseTool.name },
1922
- disableParallelToolUse: true
2025
+ disableParallelToolUse: true,
2026
+ cacheControlValidator
1923
2027
  } : {
1924
2028
  tools: tools != null ? tools : [],
1925
2029
  toolChoice,
1926
- disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse
2030
+ disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse,
2031
+ cacheControlValidator
1927
2032
  }
1928
2033
  );
2034
+ const cacheWarnings = cacheControlValidator.getWarnings();
1929
2035
  return {
1930
2036
  args: {
1931
2037
  ...baseArgs,
1932
2038
  tools: anthropicTools2,
1933
2039
  tool_choice: anthropicToolChoice
1934
2040
  },
1935
- warnings: [...warnings, ...toolWarnings],
2041
+ warnings: [...warnings, ...toolWarnings, ...cacheWarnings],
1936
2042
  betas: /* @__PURE__ */ new Set([...betas, ...toolsBetas]),
1937
2043
  usesJsonResponseTool: jsonResponseTool != null
1938
2044
  };
@@ -1979,7 +2085,7 @@ var AnthropicMessagesLanguageModel = class {
1979
2085
  });
1980
2086
  }
1981
2087
  async doGenerate(options) {
1982
- var _a, _b, _c, _d, _e, _f;
2088
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1983
2089
  const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
1984
2090
  const citationDocuments = this.extractCitationDocuments(options.prompt);
1985
2091
  const {
@@ -2262,7 +2368,16 @@ var AnthropicMessagesLanguageModel = class {
2262
2368
  anthropic: {
2263
2369
  usage: response.usage,
2264
2370
  cacheCreationInputTokens: (_e = response.usage.cache_creation_input_tokens) != null ? _e : null,
2265
- stopSequence: (_f = response.stop_sequence) != null ? _f : null
2371
+ stopSequence: (_f = response.stop_sequence) != null ? _f : null,
2372
+ container: response.container ? {
2373
+ expiresAt: response.container.expires_at,
2374
+ id: response.container.id,
2375
+ skills: (_h = (_g = response.container.skills) == null ? void 0 : _g.map((skill) => ({
2376
+ type: skill.type,
2377
+ skillId: skill.skill_id,
2378
+ version: skill.version
2379
+ }))) != null ? _h : null
2380
+ } : null
2266
2381
  }
2267
2382
  }
2268
2383
  };
@@ -2293,6 +2408,7 @@ var AnthropicMessagesLanguageModel = class {
2293
2408
  let rawUsage = void 0;
2294
2409
  let cacheCreationInputTokens = null;
2295
2410
  let stopSequence = null;
2411
+ let container = null;
2296
2412
  let blockType = void 0;
2297
2413
  const generateId2 = this.generateId;
2298
2414
  return {
@@ -2302,7 +2418,7 @@ var AnthropicMessagesLanguageModel = class {
2302
2418
  controller.enqueue({ type: "stream-start", warnings });
2303
2419
  },
2304
2420
  transform(chunk, controller) {
2305
- var _a, _b, _c, _d, _e, _f, _g, _h;
2421
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
2306
2422
  if (options.includeRawChunks) {
2307
2423
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
2308
2424
  }
@@ -2711,6 +2827,15 @@ var AnthropicMessagesLanguageModel = class {
2711
2827
  isJsonResponseFromTool: usesJsonResponseTool
2712
2828
  });
2713
2829
  stopSequence = (_h = value.delta.stop_sequence) != null ? _h : null;
2830
+ container = value.delta.container != null ? {
2831
+ expiresAt: value.delta.container.expires_at,
2832
+ id: value.delta.container.id,
2833
+ skills: (_j = (_i = value.delta.container.skills) == null ? void 0 : _i.map((skill) => ({
2834
+ type: skill.type,
2835
+ skillId: skill.skill_id,
2836
+ version: skill.version
2837
+ }))) != null ? _j : null
2838
+ } : null;
2714
2839
  rawUsage = {
2715
2840
  ...rawUsage,
2716
2841
  ...value.usage
@@ -2726,7 +2851,8 @@ var AnthropicMessagesLanguageModel = class {
2726
2851
  anthropic: {
2727
2852
  usage: rawUsage != null ? rawUsage : null,
2728
2853
  cacheCreationInputTokens,
2729
- stopSequence
2854
+ stopSequence,
2855
+ container
2730
2856
  }
2731
2857
  }
2732
2858
  });