import type { IncomingMessage } from 'http';
import type { Duplex } from 'stream';
export declare const wsClients: Set<Duplex>;
/**
 * WebSocket message types for Loop monitoring
 */
export type LoopMessageType = 'LOOP_STATE_UPDATE' | 'LOOP_STEP_COMPLETED' | 'LOOP_COMPLETED' | 'LOOP_LOG_ENTRY';
/**
 * Loop State Update - fired when loop status changes
 */
export interface LoopStateUpdateMessage {
    type: 'LOOP_STATE_UPDATE';
    loop_id: string;
    status: 'created' | 'running' | 'paused' | 'completed' | 'failed';
    current_iteration: number;
    current_cli_step: number;
    updated_at: string;
    timestamp: string;
}
/**
 * Loop Step Completed - fired when a CLI step finishes
 */
export interface LoopStepCompletedMessage {
    type: 'LOOP_STEP_COMPLETED';
    loop_id: string;
    step_id: string;
    exit_code: number;
    duration_ms: number;
    output: string;
    timestamp: string;
}
/**
 * Loop Completed - fired when entire loop finishes
 */
export interface LoopCompletedMessage {
    type: 'LOOP_COMPLETED';
    loop_id: string;
    final_status: 'completed' | 'failed';
    total_iterations: number;
    reason?: string;
    timestamp: string;
}
/**
 * Loop Log Entry - fired for streaming log lines
 */
export interface LoopLogEntryMessage {
    type: 'LOOP_LOG_ENTRY';
    loop_id: string;
    step_id: string;
    line: string;
    timestamp: string;
}
export declare function handleWebSocketUpgrade(req: IncomingMessage, socket: Duplex, _head: Buffer): void;
/**
 * Parse WebSocket frame (simplified)
 * Returns { opcode, payload } or null
 */
export declare function parseWebSocketFrame(buffer: Buffer): {
    opcode: number;
    payload: string;
} | null;
/**
 * Create WebSocket frame
 */
export declare function createWebSocketFrame(data: unknown): Buffer;
/**
 * Broadcast message to all connected WebSocket clients
 */
export declare function broadcastToClients(data: unknown): void;
/**
 * Extract session ID from file path
 */
export declare function extractSessionIdFromPath(filePath: string): string | null;
export type LoopMessage = Omit<LoopStateUpdateMessage, 'timestamp'> | Omit<LoopStepCompletedMessage, 'timestamp'> | Omit<LoopCompletedMessage, 'timestamp'> | Omit<LoopLogEntryMessage, 'timestamp'>;
/**
 * Broadcast loop state update with throttling
 */
export declare function broadcastLoopUpdate(message: LoopMessage): void;
/**
 * Broadcast loop log entry (no throttling)
 * Used for streaming real-time logs to Dashboard
 */
export declare function broadcastLoopLog(loop_id: string, step_id: string, line: string): void;
//# sourceMappingURL=websocket.d.ts.map