/** * Batch policy, collapses repeated notifications from the same domain + * level within a rolling time window to prevent UI flooding from high- * frequency operational events (e.g. tool progress ticks, agent heartbeats). */ import type { Notification } from '../types.js'; /** * BatchPolicy tracks repeated notifications and decides whether a new * arrival should be collapsed into an existing batch group. * * A batch group key is `{domain}:{level}`. Two notifications sharing the * same key within `batchWindowMs` are considered duplicates. */ export declare class BatchPolicy { /** Active batch groups keyed by `{domain}:{level}`. */ private readonly groups; /** Pending flushed notifications paired with their batch count. */ private readonly pending; /** Rolling window in ms within which repeated notifications are batched. */ private readonly batchWindowMs; constructor(batchWindowMs?: number); /** * Builds the batch group key for a notification. * * @param notification - The notification to key. * @returns A string key in the form `{domain}:{level}`. */ private buildKey; /** * Evaluates a notification against the batch policy. * * @param notification - Incoming notification to evaluate. * @returns The batch group key if this notification is being batched, * or undefined if it should be routed immediately. */ evaluate(notification: Notification): string | undefined; /** * Flushes all pending batched notifications. * * Call this at the end of a batch cycle (e.g. on a timer tick or when * quiet-typing mode ends) to surface collapsed notifications. * * @param now - Optional timestamp override for expiry checks (defaults to Date.now()). * @returns Array of the most-recent notification from each expired batch group, paired with batch count. */ flush(now?: number): Array<{ notification: Notification; batchCount: number; }>; } //# sourceMappingURL=batch-policy.d.ts.map