/** * InterruptManager - Manages user interruptions with priority queuing * Handles interrupt prioritization, deferred execution, and smooth transitions */ import { EventEmitter } from 'events'; export declare enum InterruptPriority { CRITICAL = 100,// System errors, critical failures HIGH = 75,// User cancellation requests, important alerts NORMAL = 50,// Standard user input, questions LOW = 25,// Hints, suggestions BACKGROUND = 0 } export type InterruptType = 'user-cancel' | 'user-input' | 'system-error' | 'confirmation' | 'hint' | 'alert' | 'question' | 'menu-selection'; export interface InterruptConfig { id: string; type: InterruptType; priority: InterruptPriority; message: string; metadata?: Record; timestamp: number; ttl?: number; deferrable?: boolean; blocking?: boolean; handler?: (interrupt: Interrupt) => void | Promise; } export interface Interrupt extends InterruptConfig { status: 'pending' | 'active' | 'deferred' | 'completed' | 'expired' | 'cancelled'; activatedAt?: number; completedAt?: number; deferredCount: number; } export interface InterruptPolicy { maxQueueSize: number; maxDeferrals: number; defaultTTL: number; allowConcurrent: boolean; transitionDuration: number; } export declare class InterruptManager extends EventEmitter { private pendingQueue; private activeInterrupts; private deferredInterrupts; private policy; private isProcessing; private transitionTimer; private expiryTimers; private completionPollers; private disposed; constructor(policy?: Partial); /** * Queue a new interrupt */ queue(config: Omit): string; /** * Process the interrupt queue */ private processQueue; /** * Check if interrupt can be activated */ private canActivate; /** * Activate an interrupt */ private activateInterrupt; /** * Complete an interrupt */ completeInterrupt(id: string): void; /** * Cancel an interrupt */ cancelInterrupt(id: string): void; /** * Defer an interrupt */ private deferInterrupt; /** * Restore deferred interrupts to queue */ private restoreDeferredInterrupts; /** * Expire an interrupt */ private expireInterrupt; /** * Check if interrupt has expired */ private isExpired; /** * Schedule interrupt expiry */ private scheduleExpiry; /** * Clear expiry timer for an interrupt */ private clearExpiryTimer; /** * Wait for interrupt completion with timeout */ private waitForCompletion; /** * Clear completion poller for an interrupt */ private clearCompletionPoller; /** * Handle smooth transitions */ private smoothTransition; /** * Find insertion index based on priority */ private findInsertIndex; /** * Prune expired and low-priority interrupts from queue */ private pruneQueue; /** * Generate unique interrupt ID */ private generateId; /** * Get interrupt by ID */ getInterrupt(id: string): Interrupt | undefined; /** * Get all interrupts with a specific status */ getInterruptsByStatus(status: Interrupt['status']): Interrupt[]; /** * Get queue statistics */ getStatistics(): { queueLength: number; activeCount: number; deferredCount: number; averagePriority: number; oldestTimestamp: number | null; }; /** * Clear all interrupts */ clearAll(): void; /** * Update interrupt policy */ updatePolicy(policy: Partial): void; /** * Dispose of the manager */ dispose(): void; /** * Check if the manager has been disposed */ isDisposed(): boolean; } //# sourceMappingURL=InterruptManager.d.ts.map