export interface BashJobPaths { jobId: string; dir: string; cmdSh: string; jobLog: string; jobExit: string; jobBg: string; } export declare function bashJobsDir(contextDir: string): string; export declare function bashJobPaths(contextDir: string, jobId: string): BashJobPaths; /** Mint a fresh job id — `${Date.now()}-${hex}`. The sole minting site; the * valve calls this instead of building the literal inline so the epoch-ms * prefix is a real contract shared with its parser (jobStartedAtMs), not an * incidental string format. */ export declare function newBashJobId(): string; /** Parse the start epoch (ms) out of a job id's prefix. undefined unless the * id is exactly `-` — defensive against a * hand-created directory that doesn't follow the newBashJobId contract, * including one with no separator at all (`indexOf('-') === -1` must not * silently parse as a truncated prefix). */ export declare function jobStartedAtMs(jobId: string): number | undefined; /** Render an elapsed duration the way every bash-handoff surface (the valve's * notice, the `node bash background` result/toast, and the attach cockpit) * shows it: `<60s -> "12s"`; `60s-59m -> "3m 40s"`; `>=60m -> "1h 04m"`. */ export declare function formatBashElapsed(ms: number): string; export interface BashJobStatus { jobId: string; /** Full text of cmd.sh. */ command: string; startedAtMs: number; logPath: string; } /** Every live backgrounded bash job for this node — job.bg present, job.exit * absent — whether handed off by the menu or auto-backgrounded at the valve's * deadline. Read-only; never mutates. Distinct from (and shares no code path * with) the foreground-only `runningBashJobs` above: that scanner deliberately * EXCLUDES job.bg, this one REQUIRES it, so reusing one for the other would * corrupt foreground-admission semantics. Skips malformed/partially-written * directories. Returns oldest-first by startedAtMs. */ export declare function activeBackgroundBashJobs(contextDir: string): BashJobStatus[]; /** The start time (ms epoch) of the OLDEST still-foreground bash command for * this node, or undefined when none is running. This is the authoritative * source for the attach viewer's R4 "background it" footer hint: it reads the * exact same on-disk contract the valve writes (a job directory exists with * no job.bg and no job.exit while the command is running in the foreground, * and the valve deletes the directory the moment the command finishes or is * aborted — see canvas-bash-valve.ts), so a fresh or reconnected attach (which * has no memory of a broker-relayed tool-execution event) sees exactly what's * really running, and a viewer never needs its own call-id tracking that could * go stale across a broker/session replacement. */ export declare function oldestRunningBashJobStartedAtMs(contextDir: string): number | undefined; /** Request immediate handoff for every bash command still waiting on pi. The * valve observes job.bg within one poll, resolves the tool call, and leaves its * detached supervisor to notify the node when the real command exits. */ export declare function backgroundRunningBashJobs(contextDir: string): BashJobPaths[];