import { NotificationEventType } from "./types.ts"; import type { ThrottleConfig } from "./types.ts"; /** Sensible defaults for the notification throttle. */ export declare const DEFAULT_THROTTLE_CONFIG: Readonly; /** * Rate-limits and deduplicates notifications per session+event-type key. * * Tracks a rolling window of timestamps and checks two thresholds: * 1. **Rate limit** — max N notifications per window (configurable per * event type via `perEventType` overrides). * 2. **Hard minimum interval** — at least 1000ms between identical * session+event-type pairs (rapid duplicate suppression). * * Auto-prunes expired entries on every `allow()` call to prevent * unbounded memory growth. A periodic full-prune (every 5 minutes) * removes entries older than the largest configured window. * * Callers MUST call `dispose()` when shutting down to clean up the * periodic prune timer. */ export declare class NotificationThrottle { private config; /** Map keyed by `${sessionID}:${eventType}` → chronological timestamps. */ private timestamps; /** Periodic full-prune interval handle (5-minute interval). */ private pruneIntervalId; constructor(config: ThrottleConfig); /** * The main gate function. Returns `true` if the notification should be * allowed through, `false` if it should be suppressed (throttled). */ allow(sessionID: string, eventType: NotificationEventType): boolean; /** Clear all tracked state (timestamps map). */ reset(): void; /** * Remove expired entries from all keys. * Also removes keys whose arrays have become empty. */ prune(): void; /** * Remove all throttle entries for a given session. * Scans all keys matching `${sessionID}:*` and deletes them. */ removeSession(sessionID: string): void; /** * Dispose the throttle: clear the periodic prune timer and all tracked * state. Safe to call multiple times. */ dispose(): void; /** * Return basic stats for debugging / logging. * * - `totalTracked`: sum of all timestamp entries across all keys. * - `keys`: number of distinct `${sessionID}:${eventType}` keys. */ stats(): { totalTracked: number; keys: number; }; /** * Compute the maximum window across the top-level config and all * per-event-type overrides. Used by the periodic prune timer. */ private computeMaxWindowMs; /** * Prune entries older than the given window from the end of now. */ private pruneByWindow; } //# sourceMappingURL=throttle.d.ts.map