/** Internal gateway config for WebSocket connections (not exported). */ export interface GatewayConfig { id: string; name: string; url: string; token: string; enabled: boolean; role: 'operator'; scopes: string[]; productName?: string; } interface PendingRequest { resolve: (payload: unknown) => void; reject: (err: Error) => void; timer: ReturnType; /** When true, skip resolution on intermediate { status: "accepted" } responses. */ expectFinal?: boolean; } export interface GatewayConnection { gatewayId: string; ws: WebSocket | null; config: GatewayConfig; connected: boolean; authenticated: boolean; /** Granted scopes and role from the hello-ok response */ grantedAuth?: { role: string; scopes: string[]; deviceToken?: string; }; pendingRequests: Map; eventListeners: Map void>>; lastTick: number; tickIntervalMs: number; tickTimer: ReturnType | null; reconnectTimer: ReturnType | null; reconnectAttempts: number; /** Set to true when disconnect() is called explicitly — suppresses auto-reconnect */ intentionalClose: boolean; } /** Enable or disable OpenClaw + SSH tunnel debug logging. */ export declare function setOpenClawDebug(enabled: boolean): void; /** * Connect to an OpenClaw gateway. Resolves once the auth handshake completes. * * Protocol (from https://docs.openclaw.ai/gateway/protocol): * 1. Client opens WebSocket * 2. Server sends {type:"event", event:"connect.challenge", payload:{nonce,ts}} * 3. Client sends {type:"req", id, method:"connect", params:{auth:{token}, role, scopes, ...}} * 4. Server sends {type:"res", id, ok:true, payload:{type:"hello-ok", policy:{tickIntervalMs}, auth:{...}}} */ export declare function connect(config: GatewayConfig): Promise; /** * Disconnect from a gateway. */ export declare function disconnect(gatewayId: string): void; /** * Get an existing connection (connects on demand if not yet connected). */ export declare function getConnection(config: GatewayConfig): Promise; /** * Get connection status without connecting. */ export declare function getConnectionStatus(gatewayId: string): { connected: boolean; authenticated: boolean; }; /** * Send an RPC request to the gateway and wait for the correlated response. */ export declare function request(conn: GatewayConnection, method: string, params?: unknown, opts?: { expectFinal?: boolean; }): Promise; /** * Subscribe to gateway events by event type. */ export declare function onEvent(conn: GatewayConnection, eventType: string, listener: (data: unknown) => void): void; /** * Remove a specific event listener. */ export declare function offEvent(conn: GatewayConnection, eventType: string, listener: (data: unknown) => void): void; /** * Connect an OpenClaw agent via WebSocket. * Converts the agent's HTTP URL to a WS URL and uses default operator role/scopes. */ export declare function connectAgent(agent: { id: string; name: string; url: string; token: string; sshTunnel?: { enabled: boolean; command: string; password: string; }; productName?: string; }): Promise; /** * Disconnect an agent's WebSocket connection. */ export declare function disconnectAgent(agentId: string): void; /** * Get an agent's WebSocket connection status without connecting. */ export declare function getAgentStatus(agentId: string): { connected: boolean; authenticated: boolean; }; /** * Convert a ws:// or wss:// URL to http:// or https:// for the HTTP API. * Also passes through http/https URLs unchanged. */ export declare function httpBaseUrl(config: { url: string; }): string; export {}; //# sourceMappingURL=gatewayManager.d.ts.map