/** * Debouncer (SH-deb) — coalesce rapid messages per conversation. * * People send "hi" / "quick q" / "..." as three messages in a row. Without * debouncing the agent answers three times. This buffers items per key for a * quiet period; a new item resets the timer; a `maxWaitMs` cap keeps a chatty * user from being delayed forever. `bump()` extends the window on a typing * signal. Learned from omni's message-debouncer. */ export interface DebouncerOptions { /** Quiet period (ms) with no new item before the batch flushes. */ readonly debounceMs: number; /** Hard cap (ms) on total buffering, so a chatty user still gets answered. */ readonly maxWaitMs?: number; /** Injectable clock (tests without fake timers). Default Date.now. */ readonly now?: () => number; } export declare class Debouncer { private readonly onFlush; private readonly buffers; private readonly debounceMs; private readonly maxWaitMs; private readonly now; constructor(opts: DebouncerOptions, onFlush: (key: string, items: T[]) => void | Promise); /** Add an item to `key`'s buffer, (re)starting the quiet timer. */ push(key: string, item: T): void; /** Extend the quiet window (e.g. the platform signalled the user is typing). */ bump(key: string): void; /** Flush `key`'s buffer now, delivering the batch to `onFlush`. */ flush(key: string): void; /** Number of items currently buffered for a key. */ pendingCount(key: string): number; } //# sourceMappingURL=debouncer.d.ts.map