/**
 * WebSocket Client for Test Server
 *
 * Connects to the test server WebSocket and handles message routing.
 */
import type { ClientMessage, ServerMessage, TraceEventWithId, AgentState, AgentDetails, ConstructAction, SessionInfo } from '../types.js';
export type MessageHandler = (message: ServerMessage) => void;
export interface ConnectionOptions {
    url?: string;
    reconnect?: boolean;
    reconnectInterval?: number;
    maxReconnectAttempts?: number;
    connectionTimeoutMs?: number;
}
export declare class WebSocketClient {
    private ws;
    private url;
    private messageHandlers;
    private reconnect;
    private reconnectInterval;
    private maxReconnectAttempts;
    private connectionTimeoutMs;
    private reconnectAttempts;
    private isConnecting;
    private connectionPromise;
    onTraceEvent?: (sessionId: string, event: TraceEventWithId) => void;
    onStateUpdate?: (sessionId: string, state: AgentState) => void;
    onAgentLoaded?: (sessionId: string, agent: AgentDetails) => void;
    onAgentLoadError?: (error: string) => void;
    onResponseStart?: (sessionId: string, messageId: string) => void;
    onResponseChunk?: (sessionId: string, messageId: string, chunk: string) => void;
    onResponseEnd?: (sessionId: string, messageId: string, fullText: string) => void;
    onActionTaken?: (sessionId: string, action: ConstructAction) => void;
    onError?: (message: string) => void;
    onInfo?: (message: string, configured: boolean) => void;
    onConnected?: () => void;
    onDisconnected?: () => void;
    onTraceReplay?: (sessionId: string, events: TraceEventWithId[], totalBuffered: number) => void;
    onSubscribed?: (sessionId: string, eventCount: number) => void;
    onUnsubscribed?: (sessionId: string) => void;
    onSessionList?: (sessions: SessionInfo[]) => void;
    onSessionEnded?: (sessionId: string) => void;
    onSessionExpired?: (sessionId: string, reason: string) => void;
    private authToken;
    constructor(options?: ConnectionOptions);
    /**
     * Set auth token for authenticated connections
     */
    setAuthToken(token: string): void;
    /**
     * Connect to the WebSocket server
     */
    connect(): Promise<void>;
    /**
     * Disconnect from the WebSocket server
     */
    disconnect(): void;
    /**
     * Check if connected
     */
    isConnected(): boolean;
    /**
     * Send a message to the server
     */
    send(message: ClientMessage): void;
    /**
     * Load an agent
     */
    loadAgent(agentPath: string, projectId: string): void;
    /**
     * Send a message to the agent
     */
    sendMessage(sessionId: string, text: string): void;
    /**
     * Get current state
     */
    getState(sessionId: string): void;
    /**
     * Run a test
     */
    runTest(sessionId: string, testId: string): void;
    /**
     * Subscribe to a session's traces (for external observation)
     * Will receive trace_replay with buffered events, then live trace_event messages
     */
    subscribeSession(sessionId: string): void;
    /**
     * Unsubscribe from a session
     */
    unsubscribeSession(sessionId: string): void;
    /**
     * List all active sessions available for subscription
     */
    listSessions(): void;
    /**
     * Add a generic message handler
     */
    addMessageHandler(handler: MessageHandler): void;
    /**
     * Remove a message handler
     */
    removeMessageHandler(handler: MessageHandler): void;
    /**
     * Handle incoming message
     */
    private handleMessage;
    /**
     * Set WebSocket URL
     */
    setUrl(url: string): void;
    /**
     * Get WebSocket URL
     */
    getUrl(): string;
}
//# sourceMappingURL=websocket-client.d.ts.map