/**
 * TUI WebSocket Server
 * Auto-starts when CLI launches with TUI mode
 * Provides bidirectional communication between MK3 TUI (Rust) and Node.js backend
 */
import { WebSocket } from 'ws';
import { EventEmitter } from 'events';
/** WebSocket response body sent to MK3 TUI (shared with handlers). */
export interface ResponsePayload {
    success: boolean;
    data?: unknown;
    error?: string;
}
export declare class TUIServer extends EventEmitter {
    private wss;
    private clients;
    private port;
    private isRunning;
    constructor(port?: number);
    getListenPort(): number;
    /**
     * Start the WebSocket server
     */
    start(): Promise<void>;
    /**
     * Stop the WebSocket server
     */
    stop(): Promise<void>;
    /**
     * Handle incoming message from TUI
     */
    private handleMessage;
    /**
     * Send response back to TUI
     */
    sendResponse(ws: WebSocket, requestId: string, payload: ResponsePayload): void;
    /**
     * Send error response back to TUI
     */
    sendError(ws: WebSocket, requestId: string, errorMessage: string): void;
    /**
     * Broadcast event to all connected clients
     */
    broadcastEvent(event: string, data: unknown): void;
    /**
     * Send event to specific client
     */
    sendEvent(ws: WebSocket, event: string, data: unknown): void;
    /**
     * Send message to client
     */
    private sendMessage;
    /**
     * Get number of connected clients
     */
    getClientCount(): number;
    /**
     * Check if server is running
     */
    isServerRunning(): boolean;
}
/**
 * Get or create TUI server instance
 */
export declare function getTUIServer(port?: number): TUIServer;
/**
 * Start TUI server if not already running
 */
export declare function startTUIServer(port?: number): Promise<TUIServer>;
/**
 * Stop TUI server
 */
export declare function stopTUIServer(): Promise<void>;
//# sourceMappingURL=tui-server.d.ts.map