/** * Create a `NotificationScheduler` with defaults pulled from constants. * All fields are optional — omitted fields use the project-level defaults. */ export declare function createScheduler(config?: Partial<{ idleDelayMs: number; activityGracePeriodMs: number; maxTrackedSessions: number; }>): NotificationScheduler; export declare class NotificationScheduler { private readonly idleDelayMs; private readonly activityGracePeriodMs; private readonly maxTrackedSessions; /** Sessions that have already been notified (prevents re-notification). */ private notifiedSessions; /** Pending idle timers keyed by session ID. */ private pendingTimers; /** Sessions that had activity since being scheduled for idle notification. */ private sessionActivitySinceIdle; /** Per-session version counter to prevent stale timer execution. */ private notificationVersions; /** Sessions currently executing a notification (prevents overlap). */ private executingNotifications; /** Timestamp (ms) when the timer was scheduled — used for grace period. */ private scheduledAt; constructor(config: { idleDelayMs: number; activityGracePeriodMs: number; maxTrackedSessions: number; }); /** * Record that a session had activity. Cancels any pending idle timer for * this session (subject to the grace period) and increments the version * counter to invalidate any in-flight timer callback. * * Grace period: if `activityGracePeriodMs > 0` and the timer was scheduled * within the last `activityGracePeriodMs` ms, cancellation is skipped — * the activity is treated as a late-arriving event that coincided with the * scheduling. */ markSessionActivity(sessionID: string): void; /** * Schedule an idle notification for a session. The notification fires after * `idleDelayMs` of inactivity. Multiple guards prevent duplicate scheduling, * re-notification, and overlap with an executing notification. */ scheduleIdleNotification(sessionID: string, onFire: () => void): void; /** * Internal callback invoked when the idle timer fires. Guards check for * stale version, race conditions, and duplicate notification before * calling the user-supplied `onFire` function. */ executeNotification(sessionID: string, version: number, onFire: () => void): Promise; /** * Cancel a pending timer for a session and remove all associated state. */ cancelSession(sessionID: string): void; /** Alias for {@link cancelSession}. */ deleteSession(sessionID: string): void; /** * Clear all timers and reset all internal state. Safe to call multiple * times. After disposal the scheduler can still be used (state is reset, * not frozen). */ dispose(): void; /** * Evict the oldest tracked sessions when the total exceeds * `maxTrackedSessions`. Eviction is LRU-style: the insertion order of * `notifiedSessions` (which tracks the order sessions were first notified) * is used as the eviction queue. Sessions that are currently executing a * notification are never evicted. * * Called automatically on every `scheduleIdleNotification`. */ private cleanupOldSessions; } //# sourceMappingURL=scheduler.d.ts.map