/** * NotificationRouter, routes incoming notifications to the appropriate * surface (conversation, status_bar, panel_only) based on level, per-domain * verbosity, quiet-while-typing state, mode-context, burst detection, and * batch policy. * * Policy stack (applied in order): * 1. Default policy , level + domain verbosity → base target * 2. Quiet-typing policy , suppresses non-critical above panel_only while typing * 3. Mode-context policy , HITL-mode-aware suppression (quiet/balanced/operator) * 4. Burst policy , collapses rapid domain:level event floods * 5. Batch policy , collapses repeated events within rolling time window * * The notifications.adaptiveSuppression setting gates policies 3 and 4. * When the flag is disabled, only the original policies 1, 2, and 5 are applied. */ import type { DomainVerbosity, Notification, RoutingDecision } from './types.js'; /** * NotificationRouter applies a layered policy stack to each notification: * * 1. **Default policy**, maps level + domain verbosity to a base target. * 2. **Quiet-typing policy**, suppresses non-critical above panel_only while typing. * 3. **Batch policy**, collapses repeated domain:level pairs within a time window. * * @example * ```ts * const router = createNotificationRouter(); * router.setDomainVerbosity('tools', 'minimal'); * router.setQuietWhileTyping(true); * * const decision = router.route(notification); * if (decision.reasonCode === 'allowed') { * deliver(notification, decision.target); * } * ``` */ export declare class NotificationRouter { /** Per-domain configuration (verbosity + optional panel overrides). */ private readonly domains; /** Whether quiet-while-typing suppression is active. */ private quietWhileTyping; /** Default domain verbosity applied to domains with no explicit config. */ private defaultDomainVerbosity; /** Batch deduplication policy instance. */ private batchPolicy; /** Burst detection policy instance. */ private readonly burstPolicy; /** * Whether adaptive suppression (the notifications.adaptiveSuppression * setting) is active. Controls policies 3 (mode-context) and 4 (burst). */ private adaptiveSuppression; constructor(batchWindowMs?: number, adaptiveSuppression?: boolean, burstConfig?: { windowMs?: number | undefined; threshold?: number | undefined; cooldownMs?: number | undefined; } | undefined); /** * Route a notification through the full policy stack. * * Returns a RoutingDecision describing where the notification should be * delivered and whether it was suppressed or batched. * * @param notification - The notification to route. * @returns A RoutingDecision with target, reasonCode, optional batchKey, * and optional suppression reason text. */ route(notification: Notification): RoutingDecision; /** * Set the verbosity level for a specific domain. * * @param domain - Domain name (e.g. 'tools', 'agents', 'git'). * @param verbosity - Desired verbosity level. */ setDomainVerbosity(domain: string, verbosity: DomainVerbosity): void; /** * Enable or disable quiet-while-typing suppression. * * When enabled, `info` and `warning` notifications that would surface above * `panel_only` are suppressed with reason `'quiet_while_typing'`. * `critical` notifications are never suppressed. * * @param enabled - Whether to activate quiet-while-typing mode. */ setQuietWhileTyping(enabled: boolean): void; /** * Set the batch window duration in milliseconds. * * Replaces the current BatchPolicy instance with a fresh one using the * new window. Pending batches from the previous instance are discarded. * * @param ms - Batch window duration in milliseconds. */ setBatchWindowMs(ms: number): void; /** * Set the default domain verbosity applied to domains with no explicit config. * * This verbosity is used by `getDomainVerbosity` when a domain has no * per-domain override set via `setDomainVerbosity`. * * @param verbosity - The default verbosity level. */ setDefaultDomainVerbosity(verbosity: DomainVerbosity): void; /** * Enable or disable adaptive notification suppression (mode-context + burst policies). * * This corresponds to the notifications.adaptiveSuppression setting. * When disabled, only the base default + quiet-typing + batch policies apply. * * @param enabled - Whether to activate adaptive suppression. */ setAdaptiveSuppression(enabled: boolean): void; /** * Whether adaptive suppression is currently enabled. */ isAdaptiveSuppressionEnabled(): boolean; /** * Flush all pending batched notifications. * * Call this when a batch window expires (e.g. on a periodic timer) or when * quiet-typing mode deactivates, to surface any held notifications. * * @returns Array of notifications (with batch count) that were held in batch groups and are now ready for delivery. */ flush(): Array<{ notification: Notification; batchCount: number; }>; /** * Returns the active burst group keys from the burst policy. * * Useful at flush time to surface burst summaries. */ getActiveBurstGroups(): string[]; /** * Resolve the effective domain verbosity, falling back to the default. * * @param domain - Domain name to look up. * @returns Effective DomainVerbosity for the domain. */ private getDomainVerbosity; } //# sourceMappingURL=router.d.ts.map