/** * Child-mode lifecycle wiring. * Spec: §4.5, §5.6, §5.7, §5.8 — when a Pi process is itself a spawned * agent (RPC or tmux isolation), it must self-identify on session_start * and stand up its own heartbeat writer, terminal-flush handlers, and * parent self-rescue monitor. Parent mode keeps doing what it does today. * * Detection happens in `index.ts` via `detectChildMode(entries)`; this * module owns the wiring that follows once the child identity is in hand. */ import { type Heartbeat } from "@pi-orca/core"; import { type ChildIdentity } from "./child-mode.js"; export interface ChildBootstrapDeps { /** Pi extension handle (for pi.on subscriptions and pi.events). */ pi: any; /** Active session ctx (for ctx.isIdle / ctx.shutdown). */ ctx: any; /** Identity read from the orca:agent-instance entry. */ identity: ChildIdentity; /** Heartbeat write interval (ms). */ heartbeatIntervalMs: number; /** Layer 2 parent self-rescue config (spec §5.2 + DEFAULT_CONFIG). */ parentLiveness: { childSelfRescue: boolean; /** Parent-liveness poll cadence (ms). Typically polling.idleIntervalSeconds × 1000. */ pollIntervalMs: number; /** Wait this long after first detecting dead parent before orphaning (ms). */ orphanGracePeriodMs: number; }; } export interface ChildBootstrapHandle { /** Trigger terminal flush with the given exit reason. Idempotent. */ shutdown(exitReason: "completed" | "aborted" | "orphaned" | "failed", result?: string): Promise; /** For tests: expose the live heartbeat. */ getHeartbeat(): Heartbeat; /** For tests/teardown: detach handlers and stop the heartbeat without writing. */ dispose(): Promise; } /** * Stand up the child-side lifecycle: heartbeat writer to the parent's * `agents/.yaml`, turn_end drain, session_shutdown finalization, * Layer 2 parent self-rescue, and best-effort notify pings. * * Returns a handle whose `shutdown(reason, result)` may be called from * any path (turn_end drain, abort, session_shutdown, orphan monitor). * The first caller wins; subsequent calls are no-ops (terminalFlush guard). */ export declare function setupChildMode(deps: ChildBootstrapDeps): Promise; //# sourceMappingURL=child-bootstrap.d.ts.map