Skip to content

AutopilotService

Defined in: src/autopilot.ts:120

new AutopilotService(deps): AutopilotService

Defined in: src/autopilot.ts:135

AutopilotDeps

AutopilotService

onBlock(id, block): Promise<void>

Defined in: src/autopilot.ts:256

session:block handler. Only steerable shapes are eligible; menu/stall surface as-is.

string

BlockReason | null

Promise<void>


onDone(id): Promise<void>

Defined in: src/autopilot.ts:263

session:status “done” handler — agent exited / idled. Read its tail and classify; a finished verdict drives it to a PR (resuming the pane if needed).

string

Promise<void>


onGit(id, git): void

Defined in: src/autopilot.ts:325

session:git handler. Two jobs, both keyed off the PR’s live state:

  1. PR-open transition (none/closed → open): hand off to the critic loop once (onPrOpen).
  2. Open PR with FAILING CI: the dead zone — the critic only reviews a green PR and pre-PR autopilot has stood down (a PR exists), so nobody steers a red PR. Drive the task agent to fix its own CI. Replaces the old if (open) onPrOpen wiring in index.ts.

string

GitState

void


onPrOpen(id): void

Defined in: src/autopilot.ts:308

The critic handoff: clear pause + complete + reset the step budget. Invoked once per PR-open by onGit (for a non-red PR) — the single place this transition is applied.

string

void


onStatus(id, status): void

Defined in: src/autopilot.ts:292

session:status “running” handler. A paused→running or complete→running transition is the operator re-engaging the session: clear the hand-back and refresh the step budget. Running while neither paused nor complete is a no-op (autopilot’s OWN gate-steers resume the agent — those must not reset the cap). Known limitation: a manual operator steer while the loop is active-but-NOT-paused also produces “running” and is indistinguishable from autopilot’s own steer here, so it does NOT refresh the budget — a slight deviation from the design’s “reset on manual intervene”. The cap still resets on PR-open (onPrOpen) and on answering a pause, which covers the cases that matter; conflating the two would let the cap never bite.

string

string

void


tick(): Promise<void>

Defined in: src/autopilot.ts:431

Recurring re-engagement sweep (driven by a ~30s setInterval in index.ts). Iterates all sessions and re-engages the idle ones stuck on a red PR. A timer fires regardless of events, so it is the one trigger that reliably re-fires while an agent idles on an UNCHANGED red head — the case onGit/considerCi provably cannot reach. Only the idle filter lives here (status done/idle, i.e. NOT running/blocked — mirrors the active grouping at poller.ts:314); all eligibility/red/full-auto checks live inside reEngageCi.

Promise<void>