@prestyj/ai 4.14.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1094,7 +1094,13 @@ async function prewarmAnthropicCache(options) {
1094
1094
  },
1095
1095
  {
1096
1096
  signal: options.signal ?? void 0,
1097
- ...isOAuth ? { headers: { "anthropic-beta": "claude-code-20250219,oauth-2025-04-20" } } : {}
1097
+ ...(() => {
1098
+ const betas = [
1099
+ ...isOAuth ? ["claude-code-20250219", "oauth-2025-04-20"] : [],
1100
+ ...cacheControl?.ttl === "1h" ? ["extended-cache-ttl-2025-04-11"] : []
1101
+ ];
1102
+ return betas.length ? { headers: { "anthropic-beta": betas.join(",") } } : {};
1103
+ })()
1098
1104
  }
1099
1105
  );
1100
1106
  } catch {
@@ -1178,7 +1184,12 @@ async function* runStream(options) {
1178
1184
  ...options.compaction ? ["compact-2026-01-12"] : [],
1179
1185
  ...options.clearToolUses ? ["context-management-2025-06-27"] : [],
1180
1186
  "fine-grained-tool-streaming-2025-05-14",
1181
- ...!hasAdaptiveThinking ? ["interleaved-thinking-2025-05-14"] : []
1187
+ ...!hasAdaptiveThinking ? ["interleaved-thinking-2025-05-14"] : [],
1188
+ // The 1-h cache TTL (cacheRetention "long") is gated behind this beta. Without
1189
+ // it Anthropic silently ignores ttl:"1h" and falls back to the 5-min default,
1190
+ // so a pre-warmed cache expires before the user's first turn. cacheControl.ttl
1191
+ // is only "1h" on the first-party endpoint (see toAnthropicCacheControl).
1192
+ ...cacheControl?.ttl === "1h" ? ["extended-cache-ttl-2025-04-11"] : []
1182
1193
  ];
1183
1194
  const requestOptions = {
1184
1195
  signal: options.signal ?? void 0,