/** * Running autopilot on demand: one background process per request, no scheduler * (autopilot-on-demand/AC-1..AC-9). * * `startRun` checks, clears STOP, and spawns `aidlc autopilot run --foreground` * detached; that process loops `tick` until its budget is spent, the backlog is * empty, or STOP appears, then removes its run record. * * @module */ import { type DriverCtx } from './driver.js'; import type { Notice } from './notify.js'; import { type AutopilotPaths, type RunRecord } from './state.js'; import { type StopOverrides } from './stops.js'; export declare function isAlive(pid: number): boolean; /** * Whether `cmd` names a program a spawn with this `PATH` would find * (start-failure-leaves-branch/AC-8). Only stats files; runs nothing. A relative path * with a separator resolves against the item's worktree, which does not exist yet, so * it reads as found and the spawn-failure park still covers it. */ export declare function commandFound(cmd: string, path: string, platform?: NodeJS.Platform): boolean; /** At most `max` bytes of `file` from `offset`; empty when it cannot be read. */ export declare function readRange(file: string, offset: number, max: number): Buffer; /** The run record, or null when there is none or its process is gone. */ export declare function activeRun(p: AutopilotPaths): RunRecord | null; /** * The run record while its process lives, else null — without clearing a dead * one, which `activeRun` does. For the watch view, which writes nothing * (autopilot-live-progress/AC-6). */ export declare function liveRun(p: AutopilotPaths, alive?: (pid: number) => boolean): RunRecord | null; /** The run half of `status`: whether a run is active and what it has left (autopilot-on-demand/AC-9). */ export declare function runStatusLines(run: RunRecord | null): string[]; /** The argv prefix that runs this same CLI. */ export declare function selfCli(): string[]; /** * @param notifier - only the background loop passes one, and it is used only when * the config does not say `notify: false` (autopilot-live-progress/AC-20, AC-23). */ export declare function realCtx(repo: string, p: AutopilotPaths, dryRun: boolean, say: (l: string) => void, notifier?: (notice: Notice) => void): DriverCtx; export type StartOutcome = { ok: true; pid: number; log: string; resumed: string[]; } | { ok: false; reason: string; }; export interface StartDeps { spawnLoop(args: string[], log: string): number; now(): number; } /** * Check, clear STOP, spawn the loop. Returns at once (AC-3). * * @param limit - item count, or null for `--all`. * @param stops - the run's own stops, handed to the loop on its argv. */ export declare function startRun(p: AutopilotPaths, limit: number | null, intervalSec: number, deps: StartDeps, stops?: StopOverrides): StartOutcome; export declare function spawnLoopDetached(args: string[], log: string, cwd: string): number; /** Is a run finished? (AC-1, AC-2) */ export declare function runDone(run: RunRecord, inFlight: number, nothingReady: boolean): boolean; /** * Lay a run's flags over the config. They reach only the items a pass starts: the * driver holds an item in flight to the stops recorded on it (autopilot-stop-controls/AC-4, AC-6). * A null config stays null — flags do not make a machine set up. */ export declare function withRunStops(ctx: DriverCtx, stops?: StopOverrides): DriverCtx; export interface LoopDeps { ctx(): DriverCtx; sleep(ms: number): Promise; } /** * The background loop (`aidlc autopilot run --foreground`). Returns when done or * stopped; always removes the run record on the way out. */ export declare function runLoop(p: AutopilotPaths, opts: { limit: number | null; intervalSec: number; log: string; pid: number; startedAt: string; /** This process's identity, so `pause` can tell it from a later process with its pid. */ identity?: { key: number; boot: string | null; ns: string | null; } | null; /** The run's `--stop-at` / `--pause-after`, over both config files. */ stops?: StopOverrides; }, deps: LoopDeps): Promise<'done' | 'stopped' | 'already-running'>; //# sourceMappingURL=run.d.ts.map