/**
 * WebSocket 客户端模块
 * 负责与调度中心建立和维护 WebSocket 连接
 */
import WebSocket from 'ws';
import { EventEmitter } from 'node:events';
import type { ServerConfig } from './types.js';
export declare class WebSocketClient extends EventEmitter {
    private ws;
    private config;
    private agentId;
    private heartbeatTimer;
    private heartbeatTimeoutTimer;
    private reconnectAttempts;
    private reconnectTimer;
    private isManualClose;
    private websocketFactory;
    constructor(config: ServerConfig, websocketFactory?: (url: string) => WebSocket);
    /**
       * 建立 WebSocket 连接
       * 主流程：准备连接 -> 创建连接 -> 设置事件监听
       */
    connect(agentId: string): Promise<void>;
    /**
     * 准备连接前的状态清理
     */
    private prepareConnection;
    /**
     * 构建 WebSocket URL
     */
    private buildWebSocketUrl;
    private maskRuntimeTokenInUrl;
    /**
     * 创建一次性 resolve/reject 处理器
     */
    private createSettledHandlers;
    /**
     * 设置 WebSocket 事件监听器
     */
    private setupWebSocketEventHandlers;
    /**
     * 处理 WebSocket 打开事件
     */
    private handleWebSocketOpen;
    /**
     * 处理 WebSocket 消息
     */
    private handleWebSocketMessage;
    private acknowledgeReliableMessage;
    /**
     * 处理 WebSocket 关闭事件
     */
    private handleWebSocketClose;
    /**
     * 处理 WebSocket 错误事件
     */
    private handleWebSocketError;
    /**
     * 断开 WebSocket 连接
     */
    disconnect(): void;
    /**
     * 发送消息
     */
    send(message: unknown): boolean;
    /**
     * 上报 MCP Node.js 进程启动后的运行日志。
     */
    sendMcpNodeLog(data: {
        level: string;
        message: string;
        timestamp: string;
    }): boolean;
    /**
     * 是否已连接
     */
    isConnected(): boolean;
    /**
     * 处理接收到的消息
     */
    private handleMessage;
    /**
     * 启动心跳
     */
    private startHeartbeat;
    /**
     * 停止心跳
     */
    private stopHeartbeat;
    private sendProtocolPing;
    private markHeartbeatReceived;
    private ensureHeartbeatTimeout;
    private clearHeartbeatTimeout;
    private resolveHeartbeatTimeout;
    /**
     * 安排重连
     */
    private scheduleReconnect;
    /**
     * 清除重连定时器
     */
    private clearReconnectTimer;
}
//# sourceMappingURL=websocket-client.d.ts.map