import type { EventBus } from '../kernel/events.js'; export interface ProviderCacheEntry { provider: string; input: number; cacheRead: number; cacheWrite: number; /** cacheRead / (cacheRead + input); 0 when nothing cached. */ hitRatio: number; } /** * Per-provider prompt-cache accounting for a session. `TokenCounter.cacheStats()` * blends every provider into one figure; this splits it so a session that * switched providers (fallback, `/model`) can show each provider's real * cache-hit ratio. * * New counters provide an exact per-call `deltaUsage`; older event producers * remain compatible through cumulative-snapshot differencing. The explicit * delta keeps attribution correct even when asynchronous price lookups settle * out of order after a provider switch. * * **LIFECYCLE WARNING:** The constructor subscribes to `events.on('token.accounted', …)`, * creating a permanent listener on the shared EventBus. The **caller MUST invoke * `dispose()` on session teardown** (e.g. via the `detachTodosCheckpoint` chain * in `packages/cli/src/wiring/session.ts`). Failure to do so leaks the listener * across session restarts/resumes — every constructor invocation after the first * adds a permanent listener that accumulates unboundedly. */ export declare class ProviderCacheLedger { private readonly byProvider; private last; private readonly off; constructor(events: EventBus); private record; /** Distinct providers seen this session. */ providers(): string[]; /** Per-provider cache stats, most-cached first. */ perProvider(): ProviderCacheEntry[]; /** * Unsubscribe from the event bus and release the per-session listener. * * **The caller MUST invoke `dispose()` on session teardown** — see the * constructor's lifecycle warning. Failure to call this method leaves a * permanent `token.accounted` listener on the shared EventBus that * accumulates unboundedly across session restarts/resumes. */ dispose(): void; } //# sourceMappingURL=provider-cache-ledger.d.ts.map