/**
 * Registry tracking active WebSocket observers per execution run.
 *
 * Multiple CLI clients can subscribe to observe the same run.
 * The registry handles:
 * - Per-run observer sets with subscribe/unsubscribe
 * - Broadcast of messages (log, step, status, complete) to all observers
 * - Message buffering with monotonic sequence numbers for reconnection backfill
 * - Automatic cleanup of closed/errored connections during broadcast
 * - TTL-based buffer cleanup after run completion
 */
import type { WsLike } from '@kici-dev/engine';
export type ObserverWsLike = WsLike;
export declare class ObserverRegistry {
    /** Per-run observer sets. */
    private readonly observers;
    /** Per-run message buffers for reconnection backfill. */
    private readonly buffers;
    /** Monotonic sequence counter per run. */
    private readonly sequenceCounters;
    /** Scheduled buffer cleanup timers (for cancellation on new subscribe). */
    private readonly cleanupTimers;
    /**
     * Subscribe an observer to a run.
     *
     * If `lastSeenSequence` is provided, buffered messages with sequence > lastSeenSequence
     * are replayed to the observer immediately.
     */
    subscribe(runId: string, ws: ObserverWsLike, lastSeenSequence?: number): void;
    /**
     * Unsubscribe an observer from a run.
     *
     * If the observer set becomes empty, the buffer is kept alive
     * for potential reconnection (TTL-based cleanup happens later).
     */
    unsubscribe(runId: string, ws: ObserverWsLike): void;
    /**
     * Broadcast a message object to all observers of a run.
     *
     * The message is serialized once, sent to all observers, and added to the
     * run's buffer with a monotonic sequence number. Closed/errored connections
     * are removed during broadcast.
     */
    broadcast(runId: string, message: object): void;
    /**
     * Convenience: broadcast a log chunk message.
     */
    broadcastLog(runId: string, jobId: string, jobName: string, stepIndex: number, stepName: string, lines: string[]): void;
    /**
     * Convenience: broadcast a step lifecycle event.
     */
    broadcastStep(runId: string, jobId: string, jobName: string, stepName: string, state: string, durationMs?: number): void;
    /**
     * Convenience: broadcast a run status change.
     */
    broadcastStatus(runId: string, status: string, jobName?: string): void;
    /**
     * Convenience: broadcast run completion with summary.
     *
     * After broadcasting, schedules buffer cleanup after COMPLETION_BUFFER_TTL_MS
     * to allow brief reconnection windows.
     */
    broadcastComplete(runId: string, status: string, summary: object): void;
    /**
     * Get the number of active observers for a run.
     */
    getObserverCount(runId: string): number;
    /**
     * Check if a run has any active observers.
     */
    hasObservers(runId: string): boolean;
    /**
     * Remove all buffers for completed runs.
     * Call periodically or on shutdown to reclaim memory.
     */
    cleanup(): void;
    /**
     * Get the current sequence number for a run (for testing).
     */
    getCurrentSequence(runId: string): number;
    /**
     * Get the buffer size for a run (for testing).
     */
    getBufferSize(runId: string): number;
    private nextSequence;
    private addToBuffer;
}
//# sourceMappingURL=observer-registry.d.ts.map