import { Server as HttpServer } from 'node:http'; export interface ElectionOpts { host: string; port: number; /** * FP-B3: max time to wait for `server.listen()` to emit either * `listening` or `error`. A port stuck in a bad state can leave * `listen()` hanging forever — neither event fires — which wedges the * first verb's `ensureConnected` indefinitely. When the timer fires * first we reject with a clear error so the caller can surface it * instead of hanging. Defaults to 5000ms. The fast EADDRINUSE path is * unaffected (it fires `error` synchronously-ish, well inside the * window). Set to `0` to disable the timeout. */ bindTimeoutMs?: number; } export type ElectionResult = { role: 'host'; server: HttpServer; } | { role: 'peer'; }; /** * Try to bind the WS port. If it succeeds, we're the concentrator (host). * If EADDRINUSE, someone else won — we'll dial them as a peer instead. * * The HTTP server is returned because @fetchproxy/server's WS server attaches * to it directly (no second bind). The caller closes the server on shutdown. */ export declare function electRole(opts: ElectionOpts): Promise;