/**
 * @fileoverview Session event listener wiring — creates, attaches, and detaches session listeners.
 *
 * Extracted from server.ts for modularity. Provides:
 * - `SessionListenerRefs` interface (named listener references for leak-free cleanup)
 * - `createSessionListeners()` — builds all 25 listener handlers via dependency injection
 * - `attachSessionListeners()` / `detachSessionListeners()` — symmetric attach/detach
 *
 * The detach function deduplicates a pattern that was previously copy-pasted 3 times
 * in server.ts (_doCleanupSession, exit handler, stop()).
 *
 * @dependencies session.ts (Session, event types), sse-events.ts, types.ts
 * @consumedby web/server.ts (WebServer delegates listener lifecycle here)
 *
 * @module web/session-listener-wiring
 */
import type { Session, ClaudeMessage, BackgroundTask, RalphTrackerState, RalphTodoItem, ActiveBashTool } from '../session.js';
import type { RalphStatusBlock, CircuitBreakerStatus } from '../types.js';
/** Stored listener references for session cleanup (prevents memory leaks) */
export interface SessionListenerRefs {
    terminal: (data: string) => void;
    clearTerminal: () => void;
    needsRefresh: () => void;
    message: (msg: ClaudeMessage) => void;
    error: (error: string) => void;
    completion: (result: string, cost: number) => void;
    exit: (code: number | null) => void;
    working: () => void;
    idle: () => void;
    taskCreated: (task: BackgroundTask) => void;
    taskUpdated: (task: BackgroundTask) => void;
    taskCompleted: (task: BackgroundTask) => void;
    taskFailed: (task: BackgroundTask, error: string) => void;
    autoClear: (data: {
        tokens: number;
        threshold: number;
    }) => void;
    autoCompact: (data: {
        tokens: number;
        threshold: number;
        prompt?: string;
    }) => void;
    limitPauseScheduled: (data: {
        resetAt: number;
        resumeAt: number;
        matched: string;
    }) => void;
    limitResume: (data: {
        attempt: number;
    }) => void;
    limitResumeCancelled: (data: {
        reason: string;
    }) => void;
    cliInfoUpdated: (data: {
        version?: string;
        model?: string;
        accountType?: string;
        latestVersion?: string;
    }) => void;
    ralphLoopUpdate: (state: RalphTrackerState) => void;
    ralphTodoUpdate: (todos: RalphTodoItem[]) => void;
    ralphCompletionDetected: (phrase: string) => void;
    ralphStatusBlockDetected: (block: RalphStatusBlock) => void;
    ralphCircuitBreakerUpdate: (status: CircuitBreakerStatus) => void;
    ralphExitGateMet: (data: {
        completionIndicators: number;
        exitSignal: boolean;
    }) => void;
    bashToolStart: (tool: ActiveBashTool) => void;
    bashToolEnd: (tool: ActiveBashTool) => void;
    bashToolsUpdate: (tools: ActiveBashTool[]) => void;
    attachmentRequested: (event: {
        path: string;
    }) => void;
}
/** Dependencies injected by WebServer — keeps listener creation decoupled from server internals. */
interface SessionListenerDeps {
    broadcast(event: string, data: unknown): void;
    batchTerminalData(sessionId: string, data: string): void;
    batchTaskUpdate(sessionId: string, task: BackgroundTask): void;
    broadcastSessionStateDebounced(sessionId: string): void;
    sendPushNotifications(event: string, data: Record<string, unknown>): void;
    persistSessionState(session: Session): void;
    getSessionStateWithRespawn(session: Session): unknown;
    getRunSummaryTracker(sessionId: string): import('../run-summary.js').RunSummaryTracker | undefined;
    stopTranscriptWatcher(sessionId: string): void;
    cleanupSessionBatches(sessionId: string): void;
    cancelPersistDebounce(sessionId: string): void;
    removeRunSummaryTracker(sessionId: string): void;
    removeSessionListenerRefs(sessionId: string): void;
    cleanupRespawnOnExit(sessionId: string): void;
    getStore(): import('../state-store.js').StateStore;
    registerAttachment(sessionId: string, filePath: string): Promise<void>;
}
/**
 * Creates all 26 session listener handlers, capturing dependencies via closure.
 * Call `attachSessionListeners()` after to wire them to the session.
 */
export declare function createSessionListeners(session: Session, deps: SessionListenerDeps): SessionListenerRefs;
/** Attach all listeners to a session. */
export declare function attachSessionListeners(session: Session, refs: SessionListenerRefs): void;
/** Detach all listeners from a session (prevents memory leaks from closure references). */
export declare function detachSessionListeners(session: Session, refs: SessionListenerRefs): void;
export {};
//# sourceMappingURL=session-listener-wiring.d.ts.map