/** * Port Scanner — Utility for scanning ports 9223-9232 to find available * WebSocket bridge endpoints. * * Extracted from bridge/ws-server so port logic can be unit-tested and * reused without instantiating a full server. */ /** Default port range for Mémoire bridge instances. */ export declare const BRIDGE_PORT_START = 9223; export declare const BRIDGE_PORT_END = 9232; /** * Check whether a given TCP port is already bound by another process. * * Opens a one-shot TCP server on `port`. If binding succeeds the port is * free (server is immediately closed and we return `false`). If binding * fails with `EADDRINUSE` the port is in use and we return `true`. Any * other error propagates so callers can distinguish "in use" from "broken". */ export declare function isPortInUse(port: number): Promise; /** * Scan ports from `start` to `end` (inclusive) and return the first one * that is not currently in use. * * @throws {Error} If no port in the range is available. */ export declare function findAvailablePort(start?: number, end?: number): Promise; /** * Try to find the PID that is currently listening on `port`. * * Uses `lsof` on macOS/Linux and `netstat` on Windows. Returns `null` * when the PID cannot be determined (missing tool, permission error, * or no listener found). Never throws — failures are silently swallowed * so callers can always fall back to a generic "port in use" message. */ export declare function getPortOwnerPid(port: number): number | null; /** * Returns `true` when `pid` belongs to a known Mémoire / Node.js process * that is likely part of the same npm package. * * Heuristic: checks whether the process command line contains the string * "memoire" or "memi" (the CLI binary name). This is not foolproof but is * sufficient to distinguish a stale Mémoire instance from a genuinely * foreign process. */ export declare function isMemoireProcess(pid: number): boolean;