import { type NodeMeta } from '../canvas/index.js'; import type { WakeOrigin } from './bearings.js'; /** A true session resume normally needs no prompt. A broker-certified runtime * abort is the one exception: continue the persisted transcript with a factual * warning rather than creating a fresh cycle. */ export type ReviveWakeReason = WakeOrigin | 'runtime-restart-abort'; import { headlessBrokerHost } from './host.js'; /** Pick the `--session` source for a revive. Both resume=true (a true resume) * and resume=false (a refresh-yield) resume by the absolute session-file path * (immune to cwd; pi opens it directly) — but ONLY when that file actually * exists on disk. A node's `pi_session_file` can be recorded in meta with * nothing ever written there (e.g. its first-boot engine died before * session_start ever ran), and `headlessBrokerHost.launch`'s preflight * (host.ts) fatally rejects handing pi a `--session` for a missing path OR a * bare id — either would crash the revive and strand the node dead with * nothing to recover it. So when there is no real `.jsonl` to resume, this * selects NEITHER source regardless of `resume`: the caller then falls * through to a truly fresh (`--fresh`-equivalent) launch, which is always * safe. The only difference between the two `resume` values (when the file * DOES exist) is `newCycle`: resume=false additionally roots a fresh cycle * branch (`--crtr-new-cycle`) rather than continuing the existing leaf. Pure * so the decision is unit-testable without tmux or a real filesystem fixture * beyond a temp file. */ export declare function resumeArgs(meta: NodeMeta, resume: boolean): { resumeSessionPath?: string; newCycle?: boolean; }; export interface ReviveResult { /** Always null — the broker engine is never placed in a tmux window. Kept on * the result for caller back-compat. */ window: string | null; /** The node's last live LOCATION session, or null — the broker engine has no * tmux session of its own (it opens no viewer). Kept for caller back-compat. */ session: string | null; /** True only for a TRUE resume — pi replays the saved conversation history * from its absolute session-file path. False for a fresh launch AND for an * in-place cycle (which also passes `--session `, but to open a new * branch rather than replay the old one). */ resumed: boolean; /** Launch handle for the detached broker, so callers can fail fast on its real * exit before the socket appears. */ launch?: ReturnType; /** Reads a fatal launch fault recorded by THIS revive attempt, scoped via * `beginBootFaultAttempt` at the exact clear-then-launch boundary below. * Present only when a fresh launch actually happened (absent on the * double-revive no-op, where nothing was cleared or relaunched). */ faultExplanation?: () => string | null; } /** Relaunch `nodeId`'s broker engine from its persisted recipe and update canvas * meta. Opens no viewer (engine-only). * * Throws if the node does not exist. All other failures propagate as-is — * callers (daemon, command) decide how to handle. */ export declare function reviveNode(nodeId: string, opts: { resume: boolean; wakeReason?: ReviveWakeReason; }): ReviveResult;