import { z } from 'zod'; /** The registry filename for a daemon on `port` (sibling of daemon-.pid /.log). */ export declare function daemonRegistryFileName(port: number): string; /** Extract the port from a registry filename, or null when the name isn't a registry entry. */ export declare function daemonRegistryPort(fileName: string): number | null; /** One daemon's registry entry: enough to match it to a project and prove it's still alive. */ export declare const DaemonRegistryEntrySchema: z.ZodObject<{ port: z.ZodNumber; pid: z.ZodNumber; cwd: z.ZodString; projectId: z.ZodOptional; startedAt: z.ZodNumber; }, "strip", z.ZodTypeAny, { port: number; pid: number; cwd: string; startedAt: number; projectId?: string | undefined; }, { port: number; pid: number; cwd: string; startedAt: number; projectId?: string | undefined; }>; export type DaemonRegistryEntry = z.infer; /** * Pick the daemon port an app should connect to, given the registry entries, the app's projectId, and * a liveness probe. Pure so both the vite and next plugins share one rule and it's unit-testable: * 1. the port the project CONFIGURED wins whenever a live daemon is registered on it that is not * another project's (a daemon naming no project counts; one naming a different project never does); * 2. otherwise drop dead daemons (crashed, stale entry); * 3. among the living, prefer the one whose projectId matches the app's — lowest port wins on a tie; * 4. return null when nothing matches, so the caller falls back to the default port (never guesses a * mismatched daemon — a wrong auto-connect is worse than the honest default). * * The first rule exists because `init --port ` starts a daemon on the new port while the old one * for the same project is still alive. Discovery by projectId then found both, took the lower, and * the page dialled the OLD daemon: init waited on the new one and exited with "connected to a * DIFFERENT Reticle daemon". `.reticle.json` is what the daemon and the CLI follow, so when a daemon * answers there it is the answer; the registry only speaks when nothing does. Another project's * daemon squatting that port is not an answer: the pairing token is per machine, so taking it would * pair this page with that project's bridge while this project's own daemon sat live elsewhere. */ export declare function pickDaemonPort(entries: readonly DaemonRegistryEntry[], projectId: string | undefined, isAlive: (pid: number) => boolean, configuredPort?: number): number | null;