/** A single retained chunk and the offset it was assigned. */ export interface ReplayEntry { readonly offset: number; readonly chunk: string; } export interface ReplayRingOptions { /** Maximum number of retained chunks. Must be a positive integer. */ readonly capacity: number; } /** The result of a {@link ReplayRing.since} query. */ export interface ReplaySlice { /** The retained entries with `offset >= from`, in offset order. */ readonly entries: readonly ReplayEntry[]; /** * `true` when `from` predates the oldest retained offset: some chunks the * consumer asked for were already evicted, so the replay is not gap-free. The * consumer should treat the returned tail as a best-effort resume, not a * continuous stream from `from`. */ readonly gap: boolean; } export declare class ReplayRing { #private; readonly capacity: number; constructor(options: ReplayRingOptions); /** Number of chunks currently retained. */ get size(): number; /** The offset the next {@link append} will assign (also the total ever appended). */ get nextOffset(): number; /** The oldest retained offset, or `undefined` when nothing is retained. */ get firstOffset(): number | undefined; /** * Append a chunk, assigning it the next offset. When the ring is at capacity * the oldest retained chunk is evicted first (the offset counter still * advances, so offsets stay monotonic and gap-free across eviction). */ append(chunk: string): ReplayEntry; /** * Return the retained tail from offset `from` (inclusive), for resume. `from` * is clamped to what is retained: * - `from <= firstOffset` → the whole retained window; `gap` is `true` when * `from` is strictly before the oldest retained offset (evicted chunks). * - `firstOffset < from <= nextOffset` → the exact suffix from `from`; no gap. * - `from > nextOffset` → empty (the consumer is ahead of the stream); no gap. */ since(from: number): ReplaySlice; /** Drop every retained chunk. The offset counter is NOT reset (offsets stay monotonic). */ clear(): void; }