/**
 * A2UI WebSocket Server
 *
 * Real-time communication between AI agents and UI clients.
 * Implements the A2UI protocol over WebSocket.
 */
import { EventEmitter } from 'events';
import { WebSocket } from 'ws';
import type { A2UIMessage, UserActionMessage } from './a2ui-types.js';
import { A2UIManager } from './a2ui-manager.js';
export interface A2UIServerConfig {
    /** Server port */
    port: number;
    /** Server host */
    host: string;
    /** Enable HTTP endpoints for static HTML */
    enableHTTP: boolean;
    /** Heartbeat interval in ms */
    heartbeatInterval: number;
    /** Max clients per surface */
    maxClientsPerSurface: number;
}
export declare const DEFAULT_A2UI_SERVER_CONFIG: A2UIServerConfig;
export interface A2UIClient {
    id: string;
    socket: WebSocket;
    subscribedSurfaces: Set<string>;
    lastHeartbeat: number;
    metadata?: Record<string, unknown>;
}
export interface A2UIServerEvents {
    'client:connected': (clientId: string) => void;
    'client:disconnected': (clientId: string) => void;
    'client:subscribed': (clientId: string, surfaceId: string) => void;
    'client:unsubscribed': (clientId: string, surfaceId: string) => void;
    'user:action': (action: UserActionMessage, clientId: string) => void;
    'error': (error: Error, clientId?: string) => void;
    'started': (port: number) => void;
    'stopped': () => void;
}
export declare class A2UIServer extends EventEmitter {
    private config;
    private manager;
    private httpServer;
    private wss;
    private clients;
    private surfaceClients;
    private heartbeatTimer;
    private clientIdCounter;
    constructor(config?: Partial<A2UIServerConfig>, manager?: A2UIManager);
    /**
     * Start the A2UI server
     */
    start(): Promise<void>;
    /**
     * Stop the A2UI server
     */
    stop(): Promise<void>;
    /**
     * Check if server is running
     */
    isRunning(): boolean;
    /**
     * Handle new WebSocket connection
     */
    private handleConnection;
    /**
     * Handle client disconnection
     */
    private handleDisconnection;
    /**
     * Handle message from client
     */
    private handleClientMessage;
    /**
     * Handle surface subscription
     */
    private handleSubscribe;
    /**
     * Handle surface unsubscription
     */
    private handleUnsubscribe;
    /**
     * Handle user action from client
     */
    private handleUserAction;
    /**
     * Handle get surfaces request
     */
    private handleGetSurfaces;
    /**
     * Handle get surface request
     */
    private handleGetSurface;
    /**
     * Setup listeners for manager events
     */
    private setupManagerListeners;
    /**
     * Get nested value from object
     */
    private getNestedValue;
    /**
     * Send message to specific client
     */
    sendToClient(clientId: string, message: A2UIMessage | Record<string, unknown>): boolean;
    /**
     * Broadcast message to all clients subscribed to a surface
     */
    broadcastToSurface(surfaceId: string, message: A2UIMessage): number;
    /**
     * Broadcast message to all connected clients
     */
    broadcastToAll(message: Record<string, unknown>): number;
    /**
     * Send A2UI messages (for agent use)
     */
    sendMessages(messages: A2UIMessage[]): void;
    /**
     * Handle HTTP requests
     */
    private handleHTTPRequest;
    /**
     * Handle index page
     */
    private handleIndex;
    /**
     * Handle surfaces list (JSON)
     */
    private handleSurfacesList;
    /**
     * Handle surface view (rendered HTML)
     */
    private handleSurfaceView;
    /**
     * Handle health check
     */
    private handleHealth;
    /**
     * Start heartbeat timer
     */
    private startHeartbeat;
    /**
     * Get server statistics
     */
    getStats(): {
        clients: number;
        surfaces: number;
        subscriptions: number;
        uptime: number;
    };
    /**
     * Get connected client IDs
     */
    getClientIds(): string[];
    /**
     * Get A2UI Manager instance
     */
    getManager(): A2UIManager;
}
/**
 * Get singleton A2UI Server instance
 */
export declare function getA2UIServer(config?: Partial<A2UIServerConfig>): A2UIServer;
/**
 * Reset A2UI Server (for testing)
 */
export declare function resetA2UIServer(): Promise<void>;
export default A2UIServer;
