import type { NodeInvokeResult } from "../node-registry.js"; import type { PeerRegistry } from "./peer-registry.js"; import type { RemoteNodeInfo } from "./mesh-node-registry.js"; export type PeerManagerOptions = { localGatewayId: string; localDisplayName: string; token: string; registry: PeerRegistry; getLocalNodes: () => RemoteNodeInfo[]; log: { info: (msg: string) => void; warn: (msg: string) => void; error: (msg: string) => void; }; }; /** * Manages WebSocket connections to all peer gateways. * Uses GatewayClient instances to connect to each peer as an operator. */ export declare class PeerManager { private connections; private opts; private onPeerAdded; private onPeerRemoved; constructor(opts: PeerManagerOptions); /** Connect to a peer gateway. */ private connectToPeer; /** * When a peer doesn't support mesh.announce, poll node.list to discover its nodes. */ private startNodeListPolling; /** Disconnect from a peer gateway. */ private disconnectPeer; /** List all remote nodes across all connected peers. */ listRemoteNodes(): (RemoteNodeInfo & { gatewayId: string; })[]; /** Find which peer gateway owns a given node. */ findNodeOwner(nodeId: string): string | undefined; /** Forward a node.invoke to a remote peer gateway. */ invokeRemote(gatewayId: string, params: { nodeId: string; command: string; params?: unknown; timeoutMs?: number; idempotencyKey?: string; }): Promise; /** Send a generic request to a specific peer gateway. */ requestFromPeer(gatewayId: string, method: string, params: unknown): Promise; /** Broadcast a local node change to all connected peers. */ broadcastNodesChanged(nodes: RemoteNodeInfo[]): void; /** Connect to all known peers (used during startup). */ connectToAll(): void; /** Stop all peer connections. */ stop(): void; }