@ai-sdk/anthropic 2.0.32 → 2.0.34

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 { LanguageModelV2, JSONSchema7, LanguageModelV2CallOptions, LanguageModelV2CallWarning } from '@ai-sdk/provider';
1
+ import { LanguageModelV2, JSONSchema7, SharedV2ProviderMetadata, LanguageModelV2CallWarning, LanguageModelV2CallOptions } 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: SharedV2ProviderMetadata | undefined, context: {
542
+ type: string;
543
+ canCache: boolean;
544
+ }): AnthropicCacheControl | undefined;
545
+ getWarnings(): LanguageModelV2CallWarning[];
546
+ }
547
+
548
+ declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheControlValidator, }: {
531
549
  tools: LanguageModelV2CallOptions['tools'];
532
550
  toolChoice?: LanguageModelV2CallOptions['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 { LanguageModelV2, JSONSchema7, LanguageModelV2CallOptions, LanguageModelV2CallWarning } from '@ai-sdk/provider';
1
+ import { LanguageModelV2, JSONSchema7, SharedV2ProviderMetadata, LanguageModelV2CallWarning, LanguageModelV2CallOptions } 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: SharedV2ProviderMetadata | undefined, context: {
542
+ type: string;
543
+ canCache: boolean;
544
+ }): AnthropicCacheControl | undefined;
545
+ getWarnings(): LanguageModelV2CallWarning[];
546
+ }
547
+
548
+ declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheControlValidator, }: {
531
549
  tools: LanguageModelV2CallOptions['tools'];
532
550
  toolChoice?: LanguageModelV2CallOptions['toolChoice'];
533
551
  disableParallelToolUse?: boolean;
552
+ cacheControlValidator?: CacheControlValidator;
534
553
  }): Promise<{
535
554
  tools: Array<AnthropicTool> | undefined;
536
555
  toolChoice: AnthropicToolChoice | undefined;
@@ -238,7 +238,18 @@ var anthropicMessagesResponseSchema = (0, import_provider_utils2.lazySchema)(
238
238
  output_tokens: import_v42.z.number(),
239
239
  cache_creation_input_tokens: import_v42.z.number().nullish(),
240
240
  cache_read_input_tokens: import_v42.z.number().nullish()
241
- })
241
+ }),
242
+ container: import_v42.z.object({
243
+ expires_at: import_v42.z.string(),
244
+ id: import_v42.z.string(),
245
+ skills: import_v42.z.array(
246
+ import_v42.z.object({
247
+ type: import_v42.z.union([import_v42.z.literal("anthropic"), import_v42.z.literal("custom")]),
248
+ skill_id: import_v42.z.string(),
249
+ version: import_v42.z.string()
250
+ })
251
+ ).nullish()
252
+ }).nullish()
242
253
  })
243
254
  )
244
255
  );
@@ -468,7 +479,21 @@ var anthropicMessagesChunkSchema = (0, import_provider_utils2.lazySchema)(
468
479
  type: import_v42.z.literal("message_delta"),
469
480
  delta: import_v42.z.object({
470
481
  stop_reason: import_v42.z.string().nullish(),
471
- stop_sequence: import_v42.z.string().nullish()
482
+ stop_sequence: import_v42.z.string().nullish(),
483
+ container: import_v42.z.object({
484
+ expires_at: import_v42.z.string(),
485
+ id: import_v42.z.string(),
486
+ skills: import_v42.z.array(
487
+ import_v42.z.object({
488
+ type: import_v42.z.union([
489
+ import_v42.z.literal("anthropic"),
490
+ import_v42.z.literal("custom")
491
+ ]),
492
+ skill_id: import_v42.z.string(),
493
+ version: import_v42.z.string()
494
+ })
495
+ ).nullish()
496
+ }).nullish()
472
497
  }),
473
498
  usage: import_v42.z.looseObject({
474
499
  output_tokens: import_v42.z.number(),
@@ -558,12 +583,46 @@ var anthropicProviderOptions = import_v43.z.object({
558
583
  var import_provider = require("@ai-sdk/provider");
559
584
 
560
585
  // src/get-cache-control.ts
586
+ var MAX_CACHE_BREAKPOINTS = 4;
561
587
  function getCacheControl(providerMetadata) {
562
588
  var _a;
563
589
  const anthropic = providerMetadata == null ? void 0 : providerMetadata.anthropic;
564
590
  const cacheControlValue = (_a = anthropic == null ? void 0 : anthropic.cacheControl) != null ? _a : anthropic == null ? void 0 : anthropic.cache_control;
565
591
  return cacheControlValue;
566
592
  }
593
+ var CacheControlValidator = class {
594
+ constructor() {
595
+ this.breakpointCount = 0;
596
+ this.warnings = [];
597
+ }
598
+ getCacheControl(providerMetadata, context) {
599
+ const cacheControlValue = getCacheControl(providerMetadata);
600
+ if (!cacheControlValue) {
601
+ return void 0;
602
+ }
603
+ if (!context.canCache) {
604
+ this.warnings.push({
605
+ type: "unsupported-setting",
606
+ setting: "cacheControl",
607
+ details: `cache_control cannot be set on ${context.type}. It will be ignored.`
608
+ });
609
+ return void 0;
610
+ }
611
+ this.breakpointCount++;
612
+ if (this.breakpointCount > MAX_CACHE_BREAKPOINTS) {
613
+ this.warnings.push({
614
+ type: "unsupported-setting",
615
+ setting: "cacheControl",
616
+ details: `Maximum ${MAX_CACHE_BREAKPOINTS} cache breakpoints exceeded (found ${this.breakpointCount}). This breakpoint will be ignored.`
617
+ });
618
+ return void 0;
619
+ }
620
+ return cacheControlValue;
621
+ }
622
+ getWarnings() {
623
+ return this.warnings;
624
+ }
625
+ };
567
626
 
568
627
  // src/tool/text-editor_20250728.ts
569
628
  var import_provider_utils3 = require("@ai-sdk/provider-utils");
@@ -709,11 +768,13 @@ var import_provider_utils7 = require("@ai-sdk/provider-utils");
709
768
  async function prepareTools({
710
769
  tools,
711
770
  toolChoice,
712
- disableParallelToolUse
771
+ disableParallelToolUse,
772
+ cacheControlValidator
713
773
  }) {
714
774
  tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
715
775
  const toolWarnings = [];
716
776
  const betas = /* @__PURE__ */ new Set();
777
+ const validator = cacheControlValidator || new CacheControlValidator();
717
778
  if (tools == null) {
718
779
  return { tools: void 0, toolChoice: void 0, toolWarnings, betas };
719
780
  }
@@ -721,7 +782,10 @@ async function prepareTools({
721
782
  for (const tool of tools) {
722
783
  switch (tool.type) {
723
784
  case "function": {
724
- const cacheControl = getCacheControl(tool.providerOptions);
785
+ const cacheControl = validator.getCacheControl(tool.providerOptions, {
786
+ type: "tool definition",
787
+ canCache: true
788
+ });
725
789
  anthropicTools2.push({
726
790
  name: tool.name,
727
791
  description: tool.description,
@@ -736,7 +800,8 @@ async function prepareTools({
736
800
  betas.add("code-execution-2025-05-22");
737
801
  anthropicTools2.push({
738
802
  type: "code_execution_20250522",
739
- name: "code_execution"
803
+ name: "code_execution",
804
+ cache_control: void 0
740
805
  });
741
806
  break;
742
807
  }
@@ -755,7 +820,8 @@ async function prepareTools({
755
820
  type: "computer_20250124",
756
821
  display_width_px: tool.args.displayWidthPx,
757
822
  display_height_px: tool.args.displayHeightPx,
758
- display_number: tool.args.displayNumber
823
+ display_number: tool.args.displayNumber,
824
+ cache_control: void 0
759
825
  });
760
826
  break;
761
827
  }
@@ -766,7 +832,8 @@ async function prepareTools({
766
832
  type: "computer_20241022",
767
833
  display_width_px: tool.args.displayWidthPx,
768
834
  display_height_px: tool.args.displayHeightPx,
769
- display_number: tool.args.displayNumber
835
+ display_number: tool.args.displayNumber,
836
+ cache_control: void 0
770
837
  });
771
838
  break;
772
839
  }
@@ -774,7 +841,8 @@ async function prepareTools({
774
841
  betas.add("computer-use-2025-01-24");
775
842
  anthropicTools2.push({
776
843
  name: "str_replace_editor",
777
- type: "text_editor_20250124"
844
+ type: "text_editor_20250124",
845
+ cache_control: void 0
778
846
  });
779
847
  break;
780
848
  }
@@ -782,7 +850,8 @@ async function prepareTools({
782
850
  betas.add("computer-use-2024-10-22");
783
851
  anthropicTools2.push({
784
852
  name: "str_replace_editor",
785
- type: "text_editor_20241022"
853
+ type: "text_editor_20241022",
854
+ cache_control: void 0
786
855
  });
787
856
  break;
788
857
  }
@@ -790,7 +859,8 @@ async function prepareTools({
790
859
  betas.add("computer-use-2025-01-24");
791
860
  anthropicTools2.push({
792
861
  name: "str_replace_based_edit_tool",
793
- type: "text_editor_20250429"
862
+ type: "text_editor_20250429",
863
+ cache_control: void 0
794
864
  });
795
865
  break;
796
866
  }
@@ -802,7 +872,8 @@ async function prepareTools({
802
872
  anthropicTools2.push({
803
873
  name: "str_replace_based_edit_tool",
804
874
  type: "text_editor_20250728",
805
- max_characters: args.maxCharacters
875
+ max_characters: args.maxCharacters,
876
+ cache_control: void 0
806
877
  });
807
878
  break;
808
879
  }
@@ -810,7 +881,8 @@ async function prepareTools({
810
881
  betas.add("computer-use-2025-01-24");
811
882
  anthropicTools2.push({
812
883
  name: "bash",
813
- type: "bash_20250124"
884
+ type: "bash_20250124",
885
+ cache_control: void 0
814
886
  });
815
887
  break;
816
888
  }
@@ -818,7 +890,8 @@ async function prepareTools({
818
890
  betas.add("computer-use-2024-10-22");
819
891
  anthropicTools2.push({
820
892
  name: "bash",
821
- type: "bash_20241022"
893
+ type: "bash_20241022",
894
+ cache_control: void 0
822
895
  });
823
896
  break;
824
897
  }
@@ -843,7 +916,8 @@ async function prepareTools({
843
916
  allowed_domains: args.allowedDomains,
844
917
  blocked_domains: args.blockedDomains,
845
918
  citations: args.citations,
846
- max_content_tokens: args.maxContentTokens
919
+ max_content_tokens: args.maxContentTokens,
920
+ cache_control: void 0
847
921
  });
848
922
  break;
849
923
  }
@@ -858,7 +932,8 @@ async function prepareTools({
858
932
  max_uses: args.maxUses,
859
933
  allowed_domains: args.allowedDomains,
860
934
  blocked_domains: args.blockedDomains,
861
- user_location: args.userLocation
935
+ user_location: args.userLocation,
936
+ cache_control: void 0
862
937
  });
863
938
  break;
864
939
  }
@@ -1070,11 +1145,13 @@ function convertToString(data) {
1070
1145
  async function convertToAnthropicMessagesPrompt({
1071
1146
  prompt,
1072
1147
  sendReasoning,
1073
- warnings
1148
+ warnings,
1149
+ cacheControlValidator
1074
1150
  }) {
1075
1151
  var _a, _b, _c, _d, _e;
1076
1152
  const betas = /* @__PURE__ */ new Set();
1077
1153
  const blocks = groupIntoBlocks(prompt);
1154
+ const validator = cacheControlValidator || new CacheControlValidator();
1078
1155
  let system = void 0;
1079
1156
  const messages = [];
1080
1157
  async function shouldEnableCitations(providerMetadata) {
@@ -1111,7 +1188,10 @@ async function convertToAnthropicMessagesPrompt({
1111
1188
  system = block.messages.map(({ content, providerOptions }) => ({
1112
1189
  type: "text",
1113
1190
  text: content,
1114
- cache_control: getCacheControl(providerOptions)
1191
+ cache_control: validator.getCacheControl(providerOptions, {
1192
+ type: "system message",
1193
+ canCache: true
1194
+ })
1115
1195
  }));
1116
1196
  break;
1117
1197
  }
@@ -1124,7 +1204,13 @@ async function convertToAnthropicMessagesPrompt({
1124
1204
  for (let j = 0; j < content.length; j++) {
1125
1205
  const part = content[j];
1126
1206
  const isLastPart = j === content.length - 1;
1127
- const cacheControl = (_a = getCacheControl(part.providerOptions)) != null ? _a : isLastPart ? getCacheControl(message.providerOptions) : void 0;
1207
+ const cacheControl = (_a = validator.getCacheControl(part.providerOptions, {
1208
+ type: "user message part",
1209
+ canCache: true
1210
+ })) != null ? _a : isLastPart ? validator.getCacheControl(message.providerOptions, {
1211
+ type: "user message",
1212
+ canCache: true
1213
+ }) : void 0;
1128
1214
  switch (part.type) {
1129
1215
  case "text": {
1130
1216
  anthropicContent.push({
@@ -1212,7 +1298,13 @@ async function convertToAnthropicMessagesPrompt({
1212
1298
  for (let i2 = 0; i2 < content.length; i2++) {
1213
1299
  const part = content[i2];
1214
1300
  const isLastPart = i2 === content.length - 1;
1215
- const cacheControl = (_d = getCacheControl(part.providerOptions)) != null ? _d : isLastPart ? getCacheControl(message.providerOptions) : void 0;
1301
+ const cacheControl = (_d = validator.getCacheControl(part.providerOptions, {
1302
+ type: "tool result part",
1303
+ canCache: true
1304
+ })) != null ? _d : isLastPart ? validator.getCacheControl(message.providerOptions, {
1305
+ type: "tool result message",
1306
+ canCache: true
1307
+ }) : void 0;
1216
1308
  const output = part.output;
1217
1309
  let contentValue;
1218
1310
  switch (output.type) {
@@ -1222,8 +1314,7 @@ async function convertToAnthropicMessagesPrompt({
1222
1314
  case "text":
1223
1315
  return {
1224
1316
  type: "text",
1225
- text: contentPart.text,
1226
- cache_control: void 0
1317
+ text: contentPart.text
1227
1318
  };
1228
1319
  case "media": {
1229
1320
  if (contentPart.mediaType.startsWith("image/")) {
@@ -1233,8 +1324,7 @@ async function convertToAnthropicMessagesPrompt({
1233
1324
  type: "base64",
1234
1325
  media_type: contentPart.mediaType,
1235
1326
  data: contentPart.data
1236
- },
1237
- cache_control: void 0
1327
+ }
1238
1328
  };
1239
1329
  }
1240
1330
  if (contentPart.mediaType === "application/pdf") {
@@ -1245,8 +1335,7 @@ async function convertToAnthropicMessagesPrompt({
1245
1335
  type: "base64",
1246
1336
  media_type: contentPart.mediaType,
1247
1337
  data: contentPart.data
1248
- },
1249
- cache_control: void 0
1338
+ }
1250
1339
  };
1251
1340
  }
1252
1341
  throw new import_provider2.UnsupportedFunctionalityError({
@@ -1294,7 +1383,13 @@ async function convertToAnthropicMessagesPrompt({
1294
1383
  for (let k = 0; k < content.length; k++) {
1295
1384
  const part = content[k];
1296
1385
  const isLastContentPart = k === content.length - 1;
1297
- const cacheControl = (_e = getCacheControl(part.providerOptions)) != null ? _e : isLastContentPart ? getCacheControl(message.providerOptions) : void 0;
1386
+ const cacheControl = (_e = validator.getCacheControl(part.providerOptions, {
1387
+ type: "assistant message part",
1388
+ canCache: true
1389
+ })) != null ? _e : isLastContentPart ? validator.getCacheControl(message.providerOptions, {
1390
+ type: "assistant message",
1391
+ canCache: true
1392
+ }) : void 0;
1298
1393
  switch (part.type) {
1299
1394
  case "text": {
1300
1395
  anthropicContent.push({
@@ -1318,17 +1413,23 @@ async function convertToAnthropicMessagesPrompt({
1318
1413
  });
1319
1414
  if (reasoningMetadata != null) {
1320
1415
  if (reasoningMetadata.signature != null) {
1416
+ validator.getCacheControl(part.providerOptions, {
1417
+ type: "thinking block",
1418
+ canCache: false
1419
+ });
1321
1420
  anthropicContent.push({
1322
1421
  type: "thinking",
1323
1422
  thinking: part.text,
1324
- signature: reasoningMetadata.signature,
1325
- cache_control: cacheControl
1423
+ signature: reasoningMetadata.signature
1326
1424
  });
1327
1425
  } else if (reasoningMetadata.redactedData != null) {
1426
+ validator.getCacheControl(part.providerOptions, {
1427
+ type: "redacted thinking block",
1428
+ canCache: false
1429
+ });
1328
1430
  anthropicContent.push({
1329
1431
  type: "redacted_thinking",
1330
- data: reasoningMetadata.redactedData,
1331
- cache_control: cacheControl
1432
+ data: reasoningMetadata.redactedData
1332
1433
  });
1333
1434
  } else {
1334
1435
  warnings.push({
@@ -1703,10 +1804,12 @@ var AnthropicMessagesLanguageModel = class {
1703
1804
  providerOptions,
1704
1805
  schema: anthropicProviderOptions
1705
1806
  });
1807
+ const cacheControlValidator = new CacheControlValidator();
1706
1808
  const { prompt: messagesPrompt, betas } = await convertToAnthropicMessagesPrompt({
1707
1809
  prompt,
1708
1810
  sendReasoning: (_a = anthropicOptions == null ? void 0 : anthropicOptions.sendReasoning) != null ? _a : true,
1709
- warnings
1811
+ warnings,
1812
+ cacheControlValidator
1710
1813
  });
1711
1814
  const isThinking = ((_b = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _b.type) === "enabled";
1712
1815
  const thinkingBudget = (_c = anthropicOptions == null ? void 0 : anthropicOptions.thinking) == null ? void 0 : _c.budgetTokens;
@@ -1804,20 +1907,23 @@ var AnthropicMessagesLanguageModel = class {
1804
1907
  jsonResponseTool != null ? {
1805
1908
  tools: [jsonResponseTool],
1806
1909
  toolChoice: { type: "tool", toolName: jsonResponseTool.name },
1807
- disableParallelToolUse: true
1910
+ disableParallelToolUse: true,
1911
+ cacheControlValidator
1808
1912
  } : {
1809
1913
  tools: tools != null ? tools : [],
1810
1914
  toolChoice,
1811
- disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse
1915
+ disableParallelToolUse: anthropicOptions == null ? void 0 : anthropicOptions.disableParallelToolUse,
1916
+ cacheControlValidator
1812
1917
  }
1813
1918
  );
1919
+ const cacheWarnings = cacheControlValidator.getWarnings();
1814
1920
  return {
1815
1921
  args: {
1816
1922
  ...baseArgs,
1817
1923
  tools: anthropicTools2,
1818
1924
  tool_choice: anthropicToolChoice
1819
1925
  },
1820
- warnings: [...warnings, ...toolWarnings],
1926
+ warnings: [...warnings, ...toolWarnings, ...cacheWarnings],
1821
1927
  betas: /* @__PURE__ */ new Set([...betas, ...toolsBetas]),
1822
1928
  usesJsonResponseTool: jsonResponseTool != null
1823
1929
  };
@@ -1864,7 +1970,7 @@ var AnthropicMessagesLanguageModel = class {
1864
1970
  });
1865
1971
  }
1866
1972
  async doGenerate(options) {
1867
- var _a, _b, _c, _d, _e, _f;
1973
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1868
1974
  const { args, warnings, betas, usesJsonResponseTool } = await this.getArgs(options);
1869
1975
  const citationDocuments = this.extractCitationDocuments(options.prompt);
1870
1976
  const {
@@ -2115,7 +2221,16 @@ var AnthropicMessagesLanguageModel = class {
2115
2221
  anthropic: {
2116
2222
  usage: response.usage,
2117
2223
  cacheCreationInputTokens: (_e = response.usage.cache_creation_input_tokens) != null ? _e : null,
2118
- stopSequence: (_f = response.stop_sequence) != null ? _f : null
2224
+ stopSequence: (_f = response.stop_sequence) != null ? _f : null,
2225
+ container: response.container ? {
2226
+ expiresAt: response.container.expires_at,
2227
+ id: response.container.id,
2228
+ skills: (_h = (_g = response.container.skills) == null ? void 0 : _g.map((skill) => ({
2229
+ type: skill.type,
2230
+ skillId: skill.skill_id,
2231
+ version: skill.version
2232
+ }))) != null ? _h : null
2233
+ } : null
2119
2234
  }
2120
2235
  }
2121
2236
  };
@@ -2145,6 +2260,7 @@ var AnthropicMessagesLanguageModel = class {
2145
2260
  let rawUsage = void 0;
2146
2261
  let cacheCreationInputTokens = null;
2147
2262
  let stopSequence = null;
2263
+ let container = null;
2148
2264
  let blockType = void 0;
2149
2265
  const generateId2 = this.generateId;
2150
2266
  return {
@@ -2154,7 +2270,7 @@ var AnthropicMessagesLanguageModel = class {
2154
2270
  controller.enqueue({ type: "stream-start", warnings });
2155
2271
  },
2156
2272
  transform(chunk, controller) {
2157
- var _a, _b, _c, _d, _e, _f, _g, _h;
2273
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
2158
2274
  if (options.includeRawChunks) {
2159
2275
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
2160
2276
  }
@@ -2535,6 +2651,15 @@ var AnthropicMessagesLanguageModel = class {
2535
2651
  isJsonResponseFromTool: usesJsonResponseTool
2536
2652
  });
2537
2653
  stopSequence = (_h = value.delta.stop_sequence) != null ? _h : null;
2654
+ container = value.delta.container != null ? {
2655
+ expiresAt: value.delta.container.expires_at,
2656
+ id: value.delta.container.id,
2657
+ skills: (_j = (_i = value.delta.container.skills) == null ? void 0 : _i.map((skill) => ({
2658
+ type: skill.type,
2659
+ skillId: skill.skill_id,
2660
+ version: skill.version
2661
+ }))) != null ? _j : null
2662
+ } : null;
2538
2663
  rawUsage = {
2539
2664
  ...rawUsage,
2540
2665
  ...value.usage
@@ -2550,7 +2675,8 @@ var AnthropicMessagesLanguageModel = class {
2550
2675
  anthropic: {
2551
2676
  usage: rawUsage != null ? rawUsage : null,
2552
2677
  cacheCreationInputTokens,
2553
- stopSequence
2678
+ stopSequence,
2679
+ container
2554
2680
  }
2555
2681
  }
2556
2682
  });