import { type WebDaemonInfo } from './web-protocol.js'; /** The token's directory: readable only by its owner, same reasoning as above. */ export declare const DAEMON_DIR_MODE = 448; export declare function writeDaemonInfo(projectRoot: string, sessionId: string, info: WebDaemonInfo): void; /** * Read + validate `daemon.json`. `null` when absent, malformed, a stale * protocol, or — R6 — when the file claims to describe a DIFFERENT * `(projectRoot, sessionId)` than the caller's. * * The ownership comparison belongs here rather than in `parseDaemonInfo`, * because only the caller knows what the record is supposed to describe. A * planted `daemon.json` naming someone else's session would otherwise redirect * every op (page URL, selectors, bearer token) to a port of the attacker's * choosing, and — via `stopDaemon` — aim `process.kill` at an unrelated pid. */ export declare function readDaemonInfo(projectRoot: string, sessionId: string): WebDaemonInfo | null; /** Remove `daemon.json`. Idempotent: a missing file is not an error. */ export declare function removeDaemonInfo(projectRoot: string, sessionId: string): void; /** * `process.kill(pid, 0)` is the cross-platform existence probe: it throws * `ESRCH` when no such process exists and `EPERM` when one exists but belongs * to another user and so may not be signalled. Only `ESRCH` means dead — an * alive-but-unsignalable pid must not be reported as dead, or `stopDaemon` * skips the kill and `acquireSpawnLock` reclaims a lock whose owner still * holds it. */ export declare function isProcessAlive(pid: number): boolean; /** * Take the cold-start lock. Returns `false` when another process holds a live * lock; reclaims a STALE one by renaming it to a per-call quarantine. Unlink- * then-create is not atomic (two callers could both return true), so the * replacement is created and identity-verified, and a moved fresh lock is * restored rather than replaced. */ export declare function acquireSpawnLock(projectRoot: string, sessionId: string): boolean; /** Release the spawn lock, but only when this process provably owns it. */ export declare function releaseSpawnLock(projectRoot: string, sessionId: string): void; /** * The daemon instances for a session. There is one daemon per * `(projectRoot, sessionId)` (design §10.2), so this list holds at most one * entry; it is an array because the S2 status report folds it together with the * lock and `/health` classification of each instance. */ export declare function listSessionDaemons(projectRoot: string, sessionId: string): WebDaemonInfo[];