/** * Who is holding a Codex rollout JSONL open right now. * * Codex enforces a single-writer rule per rollout and only reports it *after* * `codex resume` has started ("already has an active writer (code -32600)"), * by which point the streamer has already spawned a PTY and answered 201. The * heuristic pre-flight in conversationBusy.ts cannot see that owner: a Codex * process need not carry the rollout UUID in its argv, and a quiet-but-owned * rollout has an mtime well outside the busy window (the 2026-08-09 incident: * pid 9935 held the file open with an mtime older than 120 s). * * An open file handle on the exact rollout is direct evidence of the condition * Codex itself rejects, so it is the one pre-spawn signal worth paying for. * * It is an OPTIMISATION, never a proof of the negative: `lsof` is POSIX-only, * may be absent, may be denied, and cannot see another user's process. A null * result means "no evidence", and the caller must still rely on the * authoritative post-spawn handshake. */ /** Hard cap on the probe. Resume is latency-sensitive — a slow lsof is a miss. */ export declare const ROLLOUT_OWNER_TIMEOUT_MS = 800; /** * How the owning process is best described to a client. * * Only a process whose command is exactly `codex` is classified, and even then * only as "terminal". A VS Code / desktop `codex app-server` can host several * unrelated threads, so mis-labelling one as a standalone TUI is what would * make a destructive recovery action look safe. Everything else stays * "unknown", and no takeover is ever offered from this signal. */ export type CodexOwnerSource = "terminal" | "unknown"; export interface CodexRolloutOwner { pid: number; command: string; source: CodexOwnerSource; } export interface FindRolloutOwnerOptions { platform?: NodeJS.Platform; timeoutMs?: number; /** Our own pid — the streamer's handles on the file are not a collision. */ selfPid?: number; /** Injection point for tests; defaults to a bounded `lsof` call. */ run?: (rolloutPath: string, timeoutMs: number) => Promise; } /** Parse `lsof -F pc` output into (pid, command) pairs, in file order. */ export declare function parseLsofFieldOutput(stdout: string): Array<{ pid: number; command: string; }>; /** * First foreign process holding `rolloutPath` open, or null when there is no * evidence of one (no match, unsupported platform, missing/denied/slow lsof). */ export declare function findRolloutOwner(rolloutPath: string, options?: FindRolloutOwnerOptions): Promise; //# sourceMappingURL=codexRolloutOwner.d.ts.map