/** * AnthropicCacheStrategy — translates agnostic CacheMarker[] to * Anthropic API's `cache_control: { type: 'ephemeral' }` markers. * * Anthropic-specific behaviors honored: * - **4-marker limit**: Anthropic allows ≤4 cache breakpoints per * request. Strategy clamps oversize candidate sets, keeping the * first 4 in slot order. * - **TTL mapping**: 'short' → default 5min ephemeral; 'long' → * `ttl: '1h'` (1-hour beta). * - **Provider-side hashing**: this strategy doesn't hash — Anthropic * keys cache by exact byte prefix server-side. We don't need * content hashes for the v2.6 surface; reserved for v2.7+ if a * pre-flight cache-warm-check API ships. * * What this strategy DOES vs DOESN'T do: * - DOES: clamp markers, attach to LLMRequest.cacheMarkers, * extract metrics from response.usage * - DOES NOT: rewrite the wire body. The provider * (BrowserAnthropicProvider) reads `cacheMarkers` and applies * `cache_control` blocks during body construction. Separation of * concerns: strategy decides WHAT to cache; provider knows HOW * to encode on its specific wire. * * Auto-registers in the strategy registry on module import for * provider names: 'anthropic', 'browser-anthropic'. */ import type { CacheCapabilities, CacheMarker, CacheMetrics, CacheStrategy, CacheStrategyContext } from '../types.js'; import type { LLMRequest } from '../../adapters/types.js'; export declare class AnthropicCacheStrategy implements CacheStrategy { readonly providerName = "anthropic"; readonly capabilities: CacheCapabilities; prepareRequest(req: LLMRequest, candidates: readonly CacheMarker[], ctx: CacheStrategyContext): Promise<{ readonly request: LLMRequest; readonly markersApplied: readonly CacheMarker[]; }>; extractMetrics(usage: unknown): CacheMetrics | undefined; }