/** * Project-Local Server Discovery * * The WebSocket server writes `/.sweetlink/server.json` on * startup and removes it on shutdown. The CLI walks up from its cwd to find * the file, so it connects to THIS project's server instead of guessing a * port — with several projects running sweetlink at once, the default-port * fallback (ws://localhost:9223) can land on a different project's server. * * Stale files happen (crashes, SIGKILL), so consumers must validate liveness * against the server's HTTP info endpoint (pid/appPort) before trusting one. * `.sweetlink/` should be gitignored (the file is machine- and run-specific). */ export declare const SWEETLINK_DIR = ".sweetlink"; export declare const SERVER_INFO_FILENAME = "server.json"; export interface ServerInfoFile { /** Port the WebSocket server is listening on. */ wsPort: number; /** Associated dev-server port, when known. */ appPort: number | null; /** Declared public/proxy URL (PORTLESS_URL etc.), when set. */ publicUrl?: string; /** Process id of the server — used to detect stale files. */ pid: number; startedAt: string; version: string; } /** Absolute path of the server info file for a project root. */ export declare function serverInfoFilePath(projectRoot: string): string; /** * Write the server info file. Never throws — discovery is an optimization, * and a read-only filesystem must not take the server down. */ export declare function writeServerInfoFile(projectRoot: string, info: ServerInfoFile): void; /** * Remove the server info file — but only when it still belongs to `pid`. * A slow shutdown must not delete the file a freshly restarted server (a * different pid) has already written. Never throws. */ export declare function removeServerInfoFile(projectRoot: string, pid?: number): void; /** Parse and shape-validate a server info file. Returns null when invalid. */ export declare function parseServerInfoFile(raw: string): ServerInfoFile | null; /** * Walk up from `startDir` looking for `.sweetlink/server.json`. * Returns the parsed info plus the project root it was found in, or null. */ export declare function findServerInfoFile(startDir: string): { info: ServerInfoFile; projectRoot: string; filePath: string; } | null; //# sourceMappingURL=discovery.d.ts.map