/**
 * Continuation Event Emitter Service
 *
 * Centralized event emission for continuation detection.
 * Collects events from PTY sessions, activity monitoring, and heartbeat services,
 * normalizes them, and emits them for processing.
 *
 * @module services/continuation/continuation-events.service
 */
import { EventEmitter } from 'events';
import { ContinuationEvent, ContinuationEventMetadata, IContinuationEventEmitter } from '../../types/continuation.types.js';
/**
 * Interface for PTY session (minimal for event registration)
 */
interface PtySessionLike {
    name: string;
    onExit(callback: (exitCode: number) => void): void;
}
/**
 * Service that emits continuation events from various sources
 *
 * Features:
 * - Event debouncing to prevent rapid-fire events
 * - Event deduplication within a time window
 * - Integration with PTY sessions, activity monitor, and heartbeat service
 *
 * @example
 * ```typescript
 * const emitter = ContinuationEventEmitter.getInstance();
 *
 * emitter.on('continuation', (event) => {
 *   console.log(`Continuation event: ${event.trigger} for ${event.sessionName}`);
 * });
 *
 * // Register a PTY session
 * emitter.registerPtySession(ptySession, 'agent-001', '/path/to/project');
 * ```
 */
export declare class ContinuationEventEmitter extends EventEmitter implements IContinuationEventEmitter {
    private static instance;
    private readonly logger;
    private readonly pendingEvents;
    private readonly recentEvents;
    private readonly registeredSessions;
    private readonly DEBOUNCE_MS;
    private readonly DEDUP_WINDOW_MS;
    /**
     * Creates a new ContinuationEventEmitter
     */
    private constructor();
    /**
     * Gets the singleton instance
     *
     * @returns The ContinuationEventEmitter instance
     */
    static getInstance(): ContinuationEventEmitter;
    /**
     * Clears the singleton instance (for testing)
     */
    static clearInstance(): void;
    /**
     * Register a PTY session for exit event tracking
     *
     * @param session - PTY session to monitor
     * @param agentId - Agent identifier
     * @param projectPath - Project path
     */
    registerPtySession(session: PtySessionLike, agentId: string, projectPath: string): void;
    /**
     * Unregister a session (call when session is destroyed)
     *
     * @param sessionName - Session name to unregister
     */
    unregisterSession(sessionName: string): void;
    /**
     * Emit an activity idle event
     *
     * @param sessionName - Session that is idle
     * @param agentId - Agent identifier
     * @param projectPath - Project path
     * @param metadata - Additional metadata
     */
    emitActivityIdle(sessionName: string, agentId: string, projectPath: string, metadata: Pick<ContinuationEventMetadata, 'lastOutput' | 'idleDuration' | 'idleCycles'>): void;
    /**
     * Emit a heartbeat stale event
     *
     * @param sessionName - Session with stale heartbeat
     * @param agentId - Agent identifier
     * @param projectPath - Project path
     * @param lastHeartbeat - ISO timestamp of last heartbeat
     */
    emitHeartbeatStale(sessionName: string, agentId: string, projectPath: string, lastHeartbeat: string): void;
    /**
     * Emit an explicit continuation request event
     *
     * @param sessionName - Session requesting continuation
     * @param agentId - Agent identifier
     * @param projectPath - Project path
     * @param reason - Reason for the request
     */
    emitExplicitRequest(sessionName: string, agentId: string, projectPath: string, reason?: string): void;
    /**
     * Manually trigger a continuation event (bypasses debouncing)
     *
     * @param event - The continuation event to emit
     */
    trigger(event: ContinuationEvent): void;
    /**
     * Emit an event with debouncing
     *
     * @param event - The continuation event to emit
     */
    private emitDebounced;
    /**
     * Get a unique key for an event (for debouncing)
     *
     * @param event - The continuation event
     * @returns Unique key string
     */
    private getEventKey;
    /**
     * Check if an event is a duplicate (sent recently)
     *
     * @param event - The continuation event
     * @returns True if duplicate
     */
    private isDuplicate;
    /**
     * Mark an event as sent (for deduplication)
     *
     * @param event - The continuation event
     */
    private markEventSent;
    /**
     * Clean up old entries from recent events map
     */
    private cleanupRecentEvents;
    /**
     * Get number of pending events (for testing)
     *
     * @returns Number of pending events
     */
    getPendingEventCount(): number;
    /**
     * Get registered session names (for testing)
     *
     * @returns Set of registered session names
     */
    getRegisteredSessions(): Set<string>;
}
export {};
//# sourceMappingURL=continuation-events.service.d.ts.map