@opencode/ai 0.0.0-dev-21920 → 0.0.0-dev-21922

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.
Files changed (56) hide show
  1. package/README.md +22 -2
  2. package/dist/cache-policy.d.ts +4 -0
  3. package/dist/cache-policy.js +20 -6
  4. package/dist/protocols/alibaba-chat.d.ts +4 -0
  5. package/dist/protocols/alibaba-messages.d.ts +19 -19
  6. package/dist/protocols/anthropic-messages.d.ts +59 -59
  7. package/dist/protocols/anthropic-messages.js +3 -5
  8. package/dist/protocols/bedrock-converse.d.ts +12 -12
  9. package/dist/protocols/meta-messages.d.ts +19 -19
  10. package/dist/protocols/meta-messages.js +2 -1
  11. package/dist/protocols/openai-chat.d.ts +585 -1
  12. package/dist/protocols/openai-chat.js +7 -2
  13. package/dist/protocols/openai-compatible-chat.d.ts +4 -0
  14. package/dist/protocols/openai-responses.d.ts +24 -0
  15. package/dist/protocols/openai-responses.js +5 -0
  16. package/dist/protocols/utils/bedrock-cache.d.ts +2 -2
  17. package/dist/protocols/utils/bedrock-cache.js +7 -6
  18. package/dist/protocols/utils/cache.d.ts +14 -3
  19. package/dist/protocols/utils/cache.js +11 -4
  20. package/dist/protocols/venice-chat.d.ts +3 -0
  21. package/dist/protocols/venice-chat.js +1 -1
  22. package/dist/protocols/zai-chat.d.ts +4 -0
  23. package/dist/protocols/zai-messages.d.ts +19 -19
  24. package/dist/providers/alibaba.d.ts +23 -19
  25. package/dist/providers/amazon-bedrock-mantle.d.ts +23 -19
  26. package/dist/providers/amazon-bedrock.d.ts +4 -4
  27. package/dist/providers/anthropic-compatible.d.ts +19 -19
  28. package/dist/providers/anthropic.d.ts +19 -19
  29. package/dist/providers/azure.d.ts +12 -0
  30. package/dist/providers/baseten.d.ts +8 -0
  31. package/dist/providers/cerebras.d.ts +8 -0
  32. package/dist/providers/cloudflare-ai-gateway.d.ts +54 -38
  33. package/dist/providers/cloudflare-workers-ai.d.ts +8 -0
  34. package/dist/providers/cohere.d.ts +8 -0
  35. package/dist/providers/deepinfra.d.ts +8 -0
  36. package/dist/providers/deepseek.d.ts +8 -0
  37. package/dist/providers/digitalocean.d.ts +12 -0
  38. package/dist/providers/fireworks.d.ts +8 -0
  39. package/dist/providers/google-vertex-chat.d.ts +4 -0
  40. package/dist/providers/google-vertex-messages.d.ts +19 -19
  41. package/dist/providers/groq.d.ts +8 -0
  42. package/dist/providers/meta.d.ts +23 -19
  43. package/dist/providers/minimax.d.ts +23 -19
  44. package/dist/providers/moonshot.d.ts +23 -19
  45. package/dist/providers/openai-compatible.d.ts +4 -0
  46. package/dist/providers/openai.d.ts +8 -0
  47. package/dist/providers/openrouter.d.ts +16 -0
  48. package/dist/providers/togetherai.d.ts +8 -0
  49. package/dist/providers/venice.d.ts +3 -0
  50. package/dist/providers/xai.d.ts +4 -0
  51. package/dist/providers/zai-coding-plan.d.ts +23 -19
  52. package/dist/providers/zai.d.ts +4 -0
  53. package/dist/schema/messages.d.ts +2 -2
  54. package/dist/schema/options.d.ts +5 -3
  55. package/dist/schema/options.js +8 -3
  56. package/package.json +3 -3
@@ -114,11 +114,11 @@ declare const Options: Schema.Struct<{
114
114
  readonly inferenceGeo: Schema.optional<Schema.NullOr<Schema.String>>;
115
115
  readonly cache_control: Schema.optional<Schema.Struct<{
116
116
  readonly type: Schema.tag<"ephemeral">;
117
- readonly ttl: Schema.optional<Schema.Literals<readonly ["5m", "1h"]>>;
117
+ readonly ttl: Schema.optional<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>;
118
118
  }>>;
119
119
  readonly cacheControl: Schema.optional<Schema.Struct<{
120
120
  readonly type: Schema.tag<"ephemeral">;
121
- readonly ttl: Schema.optional<Schema.Literals<readonly ["5m", "1h"]>>;
121
+ readonly ttl: Schema.optional<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>;
122
122
  }>>;
123
123
  readonly output_config: Schema.optional<Schema.Struct<{
124
124
  readonly effort: Schema.optional<Schema.NullOr<Schema.String>>;
@@ -153,7 +153,7 @@ export declare const AnthropicMessagesBody: Schema.Struct<{
153
153
  readonly text: Schema.String;
154
154
  readonly cache_control: Schema.optional<Schema.Struct<{
155
155
  readonly type: Schema.tag<"ephemeral">;
156
- readonly ttl: Schema.optional<Schema.Literals<readonly ["5m", "1h"]>>;
156
+ readonly ttl: Schema.optional<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>;
157
157
  }>>;
158
158
  }>>>;
159
159
  messages: Schema.$Array<Schema.toTaggedUnion<"role", readonly [Schema.Struct<{
@@ -163,7 +163,7 @@ export declare const AnthropicMessagesBody: Schema.Struct<{
163
163
  readonly text: Schema.String;
164
164
  readonly cache_control: Schema.optional<Schema.Struct<{
165
165
  readonly type: Schema.tag<"ephemeral">;
166
- readonly ttl: Schema.optional<Schema.Literals<readonly ["5m", "1h"]>>;
166
+ readonly ttl: Schema.optional<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>;
167
167
  }>>;
168
168
  }>, Schema.Struct<{
169
169
  readonly type: Schema.tag<"image">;
@@ -180,7 +180,7 @@ export declare const AnthropicMessagesBody: Schema.Struct<{
180
180
  }>]>;
181
181
  readonly cache_control: Schema.optional<Schema.Struct<{
182
182
  readonly type: Schema.tag<"ephemeral">;
183
- readonly ttl: Schema.optional<Schema.Literals<readonly ["5m", "1h"]>>;
183
+ readonly ttl: Schema.optional<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>;
184
184
  }>>;
185
185
  readonly transformations: Schema.optional<Schema.Struct<{
186
186
  readonly oversized_image: Schema.optional<Schema.Literals<readonly ["downsize", "error"]>>;
@@ -204,7 +204,7 @@ export declare const AnthropicMessagesBody: Schema.Struct<{
204
204
  }>]>;
205
205
  readonly cache_control: Schema.optional<Schema.Struct<{
206
206
  readonly type: Schema.tag<"ephemeral">;
207
- readonly ttl: Schema.optional<Schema.Literals<readonly ["5m", "1h"]>>;
207
+ readonly ttl: Schema.optional<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>;
208
208
  }>>;
209
209
  readonly title: Schema.optional<Schema.String>;
210
210
  readonly context: Schema.optional<Schema.String>;
@@ -226,7 +226,7 @@ export declare const AnthropicMessagesBody: Schema.Struct<{
226
226
  }>]>;
227
227
  readonly cache_control: Schema.optional<Schema.Struct<{
228
228
  readonly type: Schema.tag<"ephemeral">;
229
- readonly ttl: Schema.optional<Schema.Literals<readonly ["5m", "1h"]>>;
229
+ readonly ttl: Schema.optional<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>;
230
230
  }>>;
231
231
  }>, Schema.Struct<{
232
232
  readonly type: Schema.tag<"tool_result">;
@@ -236,7 +236,7 @@ export declare const AnthropicMessagesBody: Schema.Struct<{
236
236
  readonly text: Schema.String;
237
237
  readonly cache_control: Schema.optional<Schema.Struct<{
238
238
  readonly type: Schema.tag<"ephemeral">;
239
- readonly ttl: Schema.optional<Schema.Literals<readonly ["5m", "1h"]>>;
239
+ readonly ttl: Schema.optional<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>;
240
240
  }>>;
241
241
  }>, Schema.Struct<{
242
242
  readonly type: Schema.tag<"image">;
@@ -253,7 +253,7 @@ export declare const AnthropicMessagesBody: Schema.Struct<{
253
253
  }>]>;
254
254
  readonly cache_control: Schema.optional<Schema.Struct<{
255
255
  readonly type: Schema.tag<"ephemeral">;
256
- readonly ttl: Schema.optional<Schema.Literals<readonly ["5m", "1h"]>>;
256
+ readonly ttl: Schema.optional<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>;
257
257
  }>>;
258
258
  readonly transformations: Schema.optional<Schema.Struct<{
259
259
  readonly oversized_image: Schema.optional<Schema.Literals<readonly ["downsize", "error"]>>;
@@ -277,7 +277,7 @@ export declare const AnthropicMessagesBody: Schema.Struct<{
277
277
  }>]>;
278
278
  readonly cache_control: Schema.optional<Schema.Struct<{
279
279
  readonly type: Schema.tag<"ephemeral">;
280
- readonly ttl: Schema.optional<Schema.Literals<readonly ["5m", "1h"]>>;
280
+ readonly ttl: Schema.optional<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>;
281
281
  }>>;
282
282
  readonly title: Schema.optional<Schema.String>;
283
283
  readonly context: Schema.optional<Schema.String>;
@@ -299,13 +299,13 @@ export declare const AnthropicMessagesBody: Schema.Struct<{
299
299
  }>]>;
300
300
  readonly cache_control: Schema.optional<Schema.Struct<{
301
301
  readonly type: Schema.tag<"ephemeral">;
302
- readonly ttl: Schema.optional<Schema.Literals<readonly ["5m", "1h"]>>;
302
+ readonly ttl: Schema.optional<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>;
303
303
  }>>;
304
304
  }>]>>]>;
305
305
  readonly is_error: Schema.optional<Schema.Boolean>;
306
306
  readonly cache_control: Schema.optional<Schema.Struct<{
307
307
  readonly type: Schema.tag<"ephemeral">;
308
- readonly ttl: Schema.optional<Schema.Literals<readonly ["5m", "1h"]>>;
308
+ readonly ttl: Schema.optional<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>;
309
309
  }>>;
310
310
  }>]>>;
311
311
  }>, Schema.Struct<{
@@ -318,7 +318,7 @@ export declare const AnthropicMessagesBody: Schema.Struct<{
318
318
  readonly text: Schema.String;
319
319
  readonly cache_control: Schema.optional<Schema.Struct<{
320
320
  readonly type: Schema.tag<"ephemeral">;
321
- readonly ttl: Schema.optional<Schema.Literals<readonly ["5m", "1h"]>>;
321
+ readonly ttl: Schema.optional<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>;
322
322
  }>>;
323
323
  }>, Schema.Struct<{
324
324
  readonly type: Schema.tag<"thinking">;
@@ -326,14 +326,14 @@ export declare const AnthropicMessagesBody: Schema.Struct<{
326
326
  readonly signature: Schema.String;
327
327
  readonly cache_control: Schema.optional<Schema.Struct<{
328
328
  readonly type: Schema.tag<"ephemeral">;
329
- readonly ttl: Schema.optional<Schema.Literals<readonly ["5m", "1h"]>>;
329
+ readonly ttl: Schema.optional<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>;
330
330
  }>>;
331
331
  }>, Schema.Struct<{
332
332
  readonly type: Schema.tag<"redacted_thinking">;
333
333
  readonly data: Schema.String;
334
334
  readonly cache_control: Schema.optional<Schema.Struct<{
335
335
  readonly type: Schema.tag<"ephemeral">;
336
- readonly ttl: Schema.optional<Schema.Literals<readonly ["5m", "1h"]>>;
336
+ readonly ttl: Schema.optional<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>;
337
337
  }>>;
338
338
  }>, Schema.Struct<{
339
339
  readonly type: Schema.tag<"tool_use">;
@@ -342,7 +342,7 @@ export declare const AnthropicMessagesBody: Schema.Struct<{
342
342
  readonly input: Schema.Unknown;
343
343
  readonly cache_control: Schema.optional<Schema.Struct<{
344
344
  readonly type: Schema.tag<"ephemeral">;
345
- readonly ttl: Schema.optional<Schema.Literals<readonly ["5m", "1h"]>>;
345
+ readonly ttl: Schema.optional<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>;
346
346
  }>>;
347
347
  }>, Schema.Struct<{
348
348
  readonly type: Schema.tag<"server_tool_use">;
@@ -351,7 +351,7 @@ export declare const AnthropicMessagesBody: Schema.Struct<{
351
351
  readonly input: Schema.Unknown;
352
352
  readonly cache_control: Schema.optional<Schema.Struct<{
353
353
  readonly type: Schema.tag<"ephemeral">;
354
- readonly ttl: Schema.optional<Schema.Literals<readonly ["5m", "1h"]>>;
354
+ readonly ttl: Schema.optional<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>;
355
355
  }>>;
356
356
  }>, Schema.Struct<{
357
357
  readonly type: Schema.Literals<readonly ["web_search_tool_result", "code_execution_tool_result", "web_fetch_tool_result"]>;
@@ -359,7 +359,7 @@ export declare const AnthropicMessagesBody: Schema.Struct<{
359
359
  readonly content: Schema.Unknown;
360
360
  readonly cache_control: Schema.optional<Schema.Struct<{
361
361
  readonly type: Schema.tag<"ephemeral">;
362
- readonly ttl: Schema.optional<Schema.Literals<readonly ["5m", "1h"]>>;
362
+ readonly ttl: Schema.optional<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>;
363
363
  }>>;
364
364
  }>]>>;
365
365
  }>, Schema.Struct<{
@@ -369,7 +369,7 @@ export declare const AnthropicMessagesBody: Schema.Struct<{
369
369
  readonly text: Schema.String;
370
370
  readonly cache_control: Schema.optional<Schema.Struct<{
371
371
  readonly type: Schema.tag<"ephemeral">;
372
- readonly ttl: Schema.optional<Schema.Literals<readonly ["5m", "1h"]>>;
372
+ readonly ttl: Schema.optional<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>;
373
373
  }>>;
374
374
  }>>;
375
375
  readonly output_config: Schema.optional<Schema.Struct<{
@@ -382,7 +382,7 @@ export declare const AnthropicMessagesBody: Schema.Struct<{
382
382
  readonly input_schema: Schema.$Record<Schema.String, Schema.Unknown>;
383
383
  readonly cache_control: Schema.optional<Schema.Struct<{
384
384
  readonly type: Schema.tag<"ephemeral">;
385
- readonly ttl: Schema.optional<Schema.Literals<readonly ["5m", "1h"]>>;
385
+ readonly ttl: Schema.optional<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>;
386
386
  }>>;
387
387
  }>>>;
388
388
  tool_choice: Schema.optional<Schema.Union<readonly [Schema.Struct<{
@@ -424,7 +424,7 @@ export declare const AnthropicMessagesBody: Schema.Struct<{
424
424
  }>>;
425
425
  cache_control: Schema.optional<Schema.Struct<{
426
426
  readonly type: Schema.tag<"ephemeral">;
427
- readonly ttl: Schema.optional<Schema.Literals<readonly ["5m", "1h"]>>;
427
+ readonly ttl: Schema.optional<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>;
428
428
  }>>;
429
429
  container: Schema.optional<Schema.NullOr<Schema.Union<readonly [Schema.String, Schema.Struct<{
430
430
  readonly id: Schema.optional<Schema.NullOr<Schema.String>>;
@@ -461,7 +461,7 @@ export declare const protocol: Protocol<{
461
461
  readonly text: string;
462
462
  readonly cache_control?: {
463
463
  readonly type: "ephemeral";
464
- readonly ttl?: "1h" | "5m" | undefined;
464
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
465
465
  } | undefined;
466
466
  }[] | undefined;
467
467
  readonly messages: readonly ({
@@ -471,7 +471,7 @@ export declare const protocol: Protocol<{
471
471
  readonly text: string;
472
472
  readonly cache_control?: {
473
473
  readonly type: "ephemeral";
474
- readonly ttl?: "1h" | "5m" | undefined;
474
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
475
475
  } | undefined;
476
476
  } | {
477
477
  readonly type: "image";
@@ -488,7 +488,7 @@ export declare const protocol: Protocol<{
488
488
  };
489
489
  readonly cache_control?: {
490
490
  readonly type: "ephemeral";
491
- readonly ttl?: "1h" | "5m" | undefined;
491
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
492
492
  } | undefined;
493
493
  readonly transformations?: {
494
494
  readonly oversized_image?: "downsize" | "error" | undefined;
@@ -508,7 +508,7 @@ export declare const protocol: Protocol<{
508
508
  };
509
509
  readonly cache_control?: {
510
510
  readonly type: "ephemeral";
511
- readonly ttl?: "1h" | "5m" | undefined;
511
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
512
512
  } | undefined;
513
513
  } | {
514
514
  readonly type: "document";
@@ -529,7 +529,7 @@ export declare const protocol: Protocol<{
529
529
  };
530
530
  readonly cache_control?: {
531
531
  readonly type: "ephemeral";
532
- readonly ttl?: "1h" | "5m" | undefined;
532
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
533
533
  } | undefined;
534
534
  readonly title?: string | undefined;
535
535
  readonly context?: string | undefined;
@@ -544,7 +544,7 @@ export declare const protocol: Protocol<{
544
544
  readonly text: string;
545
545
  readonly cache_control?: {
546
546
  readonly type: "ephemeral";
547
- readonly ttl?: "1h" | "5m" | undefined;
547
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
548
548
  } | undefined;
549
549
  } | {
550
550
  readonly type: "image";
@@ -561,7 +561,7 @@ export declare const protocol: Protocol<{
561
561
  };
562
562
  readonly cache_control?: {
563
563
  readonly type: "ephemeral";
564
- readonly ttl?: "1h" | "5m" | undefined;
564
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
565
565
  } | undefined;
566
566
  readonly transformations?: {
567
567
  readonly oversized_image?: "downsize" | "error" | undefined;
@@ -581,7 +581,7 @@ export declare const protocol: Protocol<{
581
581
  };
582
582
  readonly cache_control?: {
583
583
  readonly type: "ephemeral";
584
- readonly ttl?: "1h" | "5m" | undefined;
584
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
585
585
  } | undefined;
586
586
  } | {
587
587
  readonly type: "document";
@@ -602,7 +602,7 @@ export declare const protocol: Protocol<{
602
602
  };
603
603
  readonly cache_control?: {
604
604
  readonly type: "ephemeral";
605
- readonly ttl?: "1h" | "5m" | undefined;
605
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
606
606
  } | undefined;
607
607
  readonly title?: string | undefined;
608
608
  readonly context?: string | undefined;
@@ -613,7 +613,7 @@ export declare const protocol: Protocol<{
613
613
  readonly is_error?: boolean | undefined;
614
614
  readonly cache_control?: {
615
615
  readonly type: "ephemeral";
616
- readonly ttl?: "1h" | "5m" | undefined;
616
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
617
617
  } | undefined;
618
618
  })[];
619
619
  } | {
@@ -626,7 +626,7 @@ export declare const protocol: Protocol<{
626
626
  readonly text: string;
627
627
  readonly cache_control?: {
628
628
  readonly type: "ephemeral";
629
- readonly ttl?: "1h" | "5m" | undefined;
629
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
630
630
  } | undefined;
631
631
  } | {
632
632
  readonly type: "thinking";
@@ -634,14 +634,14 @@ export declare const protocol: Protocol<{
634
634
  readonly signature: string;
635
635
  readonly cache_control?: {
636
636
  readonly type: "ephemeral";
637
- readonly ttl?: "1h" | "5m" | undefined;
637
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
638
638
  } | undefined;
639
639
  } | {
640
640
  readonly type: "redacted_thinking";
641
641
  readonly data: string;
642
642
  readonly cache_control?: {
643
643
  readonly type: "ephemeral";
644
- readonly ttl?: "1h" | "5m" | undefined;
644
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
645
645
  } | undefined;
646
646
  } | {
647
647
  readonly type: "tool_use";
@@ -650,7 +650,7 @@ export declare const protocol: Protocol<{
650
650
  readonly input: unknown;
651
651
  readonly cache_control?: {
652
652
  readonly type: "ephemeral";
653
- readonly ttl?: "1h" | "5m" | undefined;
653
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
654
654
  } | undefined;
655
655
  } | {
656
656
  readonly type: "server_tool_use";
@@ -659,7 +659,7 @@ export declare const protocol: Protocol<{
659
659
  readonly input: unknown;
660
660
  readonly cache_control?: {
661
661
  readonly type: "ephemeral";
662
- readonly ttl?: "1h" | "5m" | undefined;
662
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
663
663
  } | undefined;
664
664
  } | {
665
665
  readonly type: "code_execution_tool_result" | "web_fetch_tool_result" | "web_search_tool_result";
@@ -667,7 +667,7 @@ export declare const protocol: Protocol<{
667
667
  readonly content: unknown;
668
668
  readonly cache_control?: {
669
669
  readonly type: "ephemeral";
670
- readonly ttl?: "1h" | "5m" | undefined;
670
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
671
671
  } | undefined;
672
672
  })[];
673
673
  } | {
@@ -677,7 +677,7 @@ export declare const protocol: Protocol<{
677
677
  readonly text: string;
678
678
  readonly cache_control?: {
679
679
  readonly type: "ephemeral";
680
- readonly ttl?: "1h" | "5m" | undefined;
680
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
681
681
  } | undefined;
682
682
  }[];
683
683
  readonly output_config?: {
@@ -692,7 +692,7 @@ export declare const protocol: Protocol<{
692
692
  };
693
693
  readonly cache_control?: {
694
694
  readonly type: "ephemeral";
695
- readonly ttl?: "1h" | "5m" | undefined;
695
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
696
696
  } | undefined;
697
697
  }[] | undefined;
698
698
  readonly tool_choice?: {
@@ -736,7 +736,7 @@ export declare const protocol: Protocol<{
736
736
  } | undefined;
737
737
  readonly cache_control?: {
738
738
  readonly type: "ephemeral";
739
- readonly ttl?: "1h" | "5m" | undefined;
739
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
740
740
  } | undefined;
741
741
  readonly container?: string | {
742
742
  readonly id?: string | null | undefined;
@@ -856,7 +856,7 @@ export declare const route: Route<{
856
856
  readonly text: string;
857
857
  readonly cache_control?: {
858
858
  readonly type: "ephemeral";
859
- readonly ttl?: "1h" | "5m" | undefined;
859
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
860
860
  } | undefined;
861
861
  }[] | undefined;
862
862
  readonly messages: readonly ({
@@ -866,7 +866,7 @@ export declare const route: Route<{
866
866
  readonly text: string;
867
867
  readonly cache_control?: {
868
868
  readonly type: "ephemeral";
869
- readonly ttl?: "1h" | "5m" | undefined;
869
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
870
870
  } | undefined;
871
871
  } | {
872
872
  readonly type: "image";
@@ -883,7 +883,7 @@ export declare const route: Route<{
883
883
  };
884
884
  readonly cache_control?: {
885
885
  readonly type: "ephemeral";
886
- readonly ttl?: "1h" | "5m" | undefined;
886
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
887
887
  } | undefined;
888
888
  readonly transformations?: {
889
889
  readonly oversized_image?: "downsize" | "error" | undefined;
@@ -903,7 +903,7 @@ export declare const route: Route<{
903
903
  };
904
904
  readonly cache_control?: {
905
905
  readonly type: "ephemeral";
906
- readonly ttl?: "1h" | "5m" | undefined;
906
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
907
907
  } | undefined;
908
908
  } | {
909
909
  readonly type: "document";
@@ -924,7 +924,7 @@ export declare const route: Route<{
924
924
  };
925
925
  readonly cache_control?: {
926
926
  readonly type: "ephemeral";
927
- readonly ttl?: "1h" | "5m" | undefined;
927
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
928
928
  } | undefined;
929
929
  readonly title?: string | undefined;
930
930
  readonly context?: string | undefined;
@@ -939,7 +939,7 @@ export declare const route: Route<{
939
939
  readonly text: string;
940
940
  readonly cache_control?: {
941
941
  readonly type: "ephemeral";
942
- readonly ttl?: "1h" | "5m" | undefined;
942
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
943
943
  } | undefined;
944
944
  } | {
945
945
  readonly type: "image";
@@ -956,7 +956,7 @@ export declare const route: Route<{
956
956
  };
957
957
  readonly cache_control?: {
958
958
  readonly type: "ephemeral";
959
- readonly ttl?: "1h" | "5m" | undefined;
959
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
960
960
  } | undefined;
961
961
  readonly transformations?: {
962
962
  readonly oversized_image?: "downsize" | "error" | undefined;
@@ -976,7 +976,7 @@ export declare const route: Route<{
976
976
  };
977
977
  readonly cache_control?: {
978
978
  readonly type: "ephemeral";
979
- readonly ttl?: "1h" | "5m" | undefined;
979
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
980
980
  } | undefined;
981
981
  } | {
982
982
  readonly type: "document";
@@ -997,7 +997,7 @@ export declare const route: Route<{
997
997
  };
998
998
  readonly cache_control?: {
999
999
  readonly type: "ephemeral";
1000
- readonly ttl?: "1h" | "5m" | undefined;
1000
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
1001
1001
  } | undefined;
1002
1002
  readonly title?: string | undefined;
1003
1003
  readonly context?: string | undefined;
@@ -1008,7 +1008,7 @@ export declare const route: Route<{
1008
1008
  readonly is_error?: boolean | undefined;
1009
1009
  readonly cache_control?: {
1010
1010
  readonly type: "ephemeral";
1011
- readonly ttl?: "1h" | "5m" | undefined;
1011
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
1012
1012
  } | undefined;
1013
1013
  })[];
1014
1014
  } | {
@@ -1021,7 +1021,7 @@ export declare const route: Route<{
1021
1021
  readonly text: string;
1022
1022
  readonly cache_control?: {
1023
1023
  readonly type: "ephemeral";
1024
- readonly ttl?: "1h" | "5m" | undefined;
1024
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
1025
1025
  } | undefined;
1026
1026
  } | {
1027
1027
  readonly type: "thinking";
@@ -1029,14 +1029,14 @@ export declare const route: Route<{
1029
1029
  readonly signature: string;
1030
1030
  readonly cache_control?: {
1031
1031
  readonly type: "ephemeral";
1032
- readonly ttl?: "1h" | "5m" | undefined;
1032
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
1033
1033
  } | undefined;
1034
1034
  } | {
1035
1035
  readonly type: "redacted_thinking";
1036
1036
  readonly data: string;
1037
1037
  readonly cache_control?: {
1038
1038
  readonly type: "ephemeral";
1039
- readonly ttl?: "1h" | "5m" | undefined;
1039
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
1040
1040
  } | undefined;
1041
1041
  } | {
1042
1042
  readonly type: "tool_use";
@@ -1045,7 +1045,7 @@ export declare const route: Route<{
1045
1045
  readonly input: unknown;
1046
1046
  readonly cache_control?: {
1047
1047
  readonly type: "ephemeral";
1048
- readonly ttl?: "1h" | "5m" | undefined;
1048
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
1049
1049
  } | undefined;
1050
1050
  } | {
1051
1051
  readonly type: "server_tool_use";
@@ -1054,7 +1054,7 @@ export declare const route: Route<{
1054
1054
  readonly input: unknown;
1055
1055
  readonly cache_control?: {
1056
1056
  readonly type: "ephemeral";
1057
- readonly ttl?: "1h" | "5m" | undefined;
1057
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
1058
1058
  } | undefined;
1059
1059
  } | {
1060
1060
  readonly type: "code_execution_tool_result" | "web_fetch_tool_result" | "web_search_tool_result";
@@ -1062,7 +1062,7 @@ export declare const route: Route<{
1062
1062
  readonly content: unknown;
1063
1063
  readonly cache_control?: {
1064
1064
  readonly type: "ephemeral";
1065
- readonly ttl?: "1h" | "5m" | undefined;
1065
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
1066
1066
  } | undefined;
1067
1067
  })[];
1068
1068
  } | {
@@ -1072,7 +1072,7 @@ export declare const route: Route<{
1072
1072
  readonly text: string;
1073
1073
  readonly cache_control?: {
1074
1074
  readonly type: "ephemeral";
1075
- readonly ttl?: "1h" | "5m" | undefined;
1075
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
1076
1076
  } | undefined;
1077
1077
  }[];
1078
1078
  readonly output_config?: {
@@ -1087,7 +1087,7 @@ export declare const route: Route<{
1087
1087
  };
1088
1088
  readonly cache_control?: {
1089
1089
  readonly type: "ephemeral";
1090
- readonly ttl?: "1h" | "5m" | undefined;
1090
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
1091
1091
  } | undefined;
1092
1092
  }[] | undefined;
1093
1093
  readonly tool_choice?: {
@@ -1131,7 +1131,7 @@ export declare const route: Route<{
1131
1131
  } | undefined;
1132
1132
  readonly cache_control?: {
1133
1133
  readonly type: "ephemeral";
1134
- readonly ttl?: "1h" | "5m" | undefined;
1134
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
1135
1135
  } | undefined;
1136
1136
  readonly container?: string | {
1137
1137
  readonly id?: string | null | undefined;
@@ -8,7 +8,7 @@ import { Framing } from "../route/framing.js";
8
8
  import { Protocol } from "../route/protocol.js";
9
9
  import { Headers } from "effect/http";
10
10
  import { HttpTransport } from "../route/transport/index.js";
11
- import { AIError, HttpOptions, LLMRequest, LLMEvent, mergeJsonRecords, Usage, } from "../schema/index.js";
11
+ import { AIError, CacheTTL, HttpOptions, LLMRequest, LLMEvent, mergeJsonRecords, Usage, } from "../schema/index.js";
12
12
  import { JsonObject, knownString, optionalArray, optionalNull, ProviderShared, withUntypedFrames } from "./shared.js";
13
13
  import { classifyProviderFailure } from "../provider-error.js";
14
14
  import { effortUpdate, resolveEffortUpdates } from "../effort-updates.js";
@@ -50,7 +50,7 @@ export const ContextManagement = Schema.Struct({
50
50
  // =============================================================================
51
51
  const AnthropicCacheControl = Schema.Struct({
52
52
  type: Schema.tag("ephemeral"),
53
- ttl: Schema.optional(Schema.Literals(["5m", "1h"])),
53
+ ttl: Schema.optional(CacheTTL),
54
54
  });
55
55
  const AnthropicServiceTier = knownString();
56
56
  const AnthropicSpeed = knownString();
@@ -399,8 +399,6 @@ const invalid = ProviderShared.invalidRequest;
399
399
  // 400 — so the lowering layer counts emitted markers and silently drops any
400
400
  // that exceed it.
401
401
  const ANTHROPIC_BREAKPOINT_CAP = 4;
402
- const EPHEMERAL_5M = { type: "ephemeral" };
403
- const EPHEMERAL_1H = { type: "ephemeral", ttl: "1h" };
404
402
  const cacheControl = (breakpoints, cache) => {
405
403
  if (cache?.type !== "ephemeral" && cache?.type !== "persistent")
406
404
  return undefined;
@@ -409,7 +407,7 @@ const cacheControl = (breakpoints, cache) => {
409
407
  return undefined;
410
408
  }
411
409
  breakpoints.remaining -= 1;
412
- return Cache.ttlBucket(cache.ttlSeconds) === "1h" ? EPHEMERAL_1H : EPHEMERAL_5M;
410
+ return { type: "ephemeral", ...(cache.ttl === undefined ? {} : { ttl: cache.ttl }) };
413
411
  };
414
412
  const providerMetadata = (key, metadata) => ({ [key]: metadata });
415
413
  const signatureFromMetadata = (metadata, key) => {
@@ -54,7 +54,7 @@ declare const BedrockConverseBody: Schema.Struct<{
54
54
  }>, Schema.Struct<{
55
55
  readonly cachePoint: Schema.Struct<{
56
56
  readonly type: Schema.tag<"default">;
57
- readonly ttl: Schema.optional<Schema.Literals<readonly ["5m", "1h"]>>;
57
+ readonly ttl: Schema.optional<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>;
58
58
  }>;
59
59
  }>]>>;
60
60
  }>, Schema.Struct<{
@@ -79,7 +79,7 @@ declare const BedrockConverseBody: Schema.Struct<{
79
79
  }>, Schema.Struct<{
80
80
  readonly cachePoint: Schema.Struct<{
81
81
  readonly type: Schema.tag<"default">;
82
- readonly ttl: Schema.optional<Schema.Literals<readonly ["5m", "1h"]>>;
82
+ readonly ttl: Schema.optional<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>;
83
83
  }>;
84
84
  }>]>>;
85
85
  }>]>>;
@@ -88,7 +88,7 @@ declare const BedrockConverseBody: Schema.Struct<{
88
88
  }>, Schema.Struct<{
89
89
  readonly cachePoint: Schema.Struct<{
90
90
  readonly type: Schema.tag<"default">;
91
- readonly ttl: Schema.optional<Schema.Literals<readonly ["5m", "1h"]>>;
91
+ readonly ttl: Schema.optional<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>;
92
92
  }>;
93
93
  }>]>>>;
94
94
  inferenceConfig: Schema.optional<Schema.Struct<{
@@ -109,7 +109,7 @@ declare const BedrockConverseBody: Schema.Struct<{
109
109
  }>, Schema.Struct<{
110
110
  readonly cachePoint: Schema.Struct<{
111
111
  readonly type: Schema.tag<"default">;
112
- readonly ttl: Schema.optional<Schema.Literals<readonly ["5m", "1h"]>>;
112
+ readonly ttl: Schema.optional<Schema.TemplateLiteral<readonly [Schema.Number, Schema.Literals<readonly ["ms", "s", "m", "h", "d"]>]>>;
113
113
  }>;
114
114
  }>]>>;
115
115
  readonly toolChoice: Schema.optional<Schema.Union<readonly [Schema.Struct<{
@@ -143,7 +143,7 @@ export declare const protocol: Protocol<{
143
143
  readonly content: readonly ({
144
144
  readonly cachePoint: {
145
145
  readonly type: "default";
146
- readonly ttl?: "1h" | "5m" | undefined;
146
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
147
147
  };
148
148
  } | {
149
149
  readonly image: {
@@ -193,7 +193,7 @@ export declare const protocol: Protocol<{
193
193
  readonly content: readonly ({
194
194
  readonly cachePoint: {
195
195
  readonly type: "default";
196
- readonly ttl?: "1h" | "5m" | undefined;
196
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
197
197
  };
198
198
  } | {
199
199
  readonly text: string;
@@ -217,7 +217,7 @@ export declare const protocol: Protocol<{
217
217
  readonly system?: readonly ({
218
218
  readonly cachePoint: {
219
219
  readonly type: "default";
220
- readonly ttl?: "1h" | "5m" | undefined;
220
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
221
221
  };
222
222
  } | {
223
223
  readonly text: string;
@@ -232,7 +232,7 @@ export declare const protocol: Protocol<{
232
232
  readonly tools: readonly ({
233
233
  readonly cachePoint: {
234
234
  readonly type: "default";
235
- readonly ttl?: "1h" | "5m" | undefined;
235
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
236
236
  };
237
237
  } | {
238
238
  readonly toolSpec: {
@@ -331,7 +331,7 @@ export declare const route: Route<{
331
331
  readonly content: readonly ({
332
332
  readonly cachePoint: {
333
333
  readonly type: "default";
334
- readonly ttl?: "1h" | "5m" | undefined;
334
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
335
335
  };
336
336
  } | {
337
337
  readonly image: {
@@ -381,7 +381,7 @@ export declare const route: Route<{
381
381
  readonly content: readonly ({
382
382
  readonly cachePoint: {
383
383
  readonly type: "default";
384
- readonly ttl?: "1h" | "5m" | undefined;
384
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
385
385
  };
386
386
  } | {
387
387
  readonly text: string;
@@ -405,7 +405,7 @@ export declare const route: Route<{
405
405
  readonly system?: readonly ({
406
406
  readonly cachePoint: {
407
407
  readonly type: "default";
408
- readonly ttl?: "1h" | "5m" | undefined;
408
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
409
409
  };
410
410
  } | {
411
411
  readonly text: string;
@@ -420,7 +420,7 @@ export declare const route: Route<{
420
420
  readonly tools: readonly ({
421
421
  readonly cachePoint: {
422
422
  readonly type: "default";
423
- readonly ttl?: "1h" | "5m" | undefined;
423
+ readonly ttl?: `${number}d` | `${number}h` | `${number}m` | `${number}ms` | `${number}s` | undefined;
424
424
  };
425
425
  } | {
426
426
  readonly toolSpec: {