export type SupervisorPhase = 'ready' | 'restarting' | 'idle-gave-up' | 'suspending' | 'suspended'; export interface RestartCoordinatorDeps { writeToChild: (line: string) => void; writeToHost: (line: string) => void; killChild: () => Promise; /** * Ask the child to release everything it holds and exit - a deeper teardown * than killChild(), which leaves managed dev servers running. */ suspendChild?: () => Promise; spawnChild: () => void; logStderr: (message: string) => void; } export interface RestartCoordinatorOptions { maxCrashAttempts?: number; crashBackoffBaseMs?: number; crashBackoffCapMs?: number; stabilityThresholdMs?: number; } export declare class RestartCoordinator { private readonly deps; private phase; private hasSeenFirstInit; private initRequestLine; private initRequestId; private initializedLine; private awaitingReplayResponseId; private initAnswered; private inFlight; private abandonedIds; /** Host lines that arrived while the suspending child was still exiting. */ private suspendQueue; private expectingExit; private crashAttempt; private crashBackoffTimer; private stabilityTimer; private readonly maxCrashAttempts; private readonly crashBackoffBaseMs; private readonly crashBackoffCapMs; private readonly stabilityThresholdMs; constructor(deps: RestartCoordinatorDeps, options?: RestartCoordinatorOptions); getPhase(): SupervisorPhase; /** A raw NDJSON line arrived from the host, headed for the child. */ handleHostLine(line: string): void; /** A raw NDJSON line arrived from the (current) child, headed for the host. */ handleChildLine(line: string): void; /** The current child's stdout stream closed - no more late responses possible from it. */ onChildStdoutClosed(): void; /** * Call before deliberately killing the child as part of supervisor shutdown * (not a restart - no respawn follows). Without this, the child's resulting * 'exit' event would be indistinguishable from a real crash. */ prepareForShutdown(): void; /** The current child process exited (fires for both deliberate kills and crashes). */ onChildExit(): void; /** Explicit restart trigger (SIGUSR2, wired to a postbuild hook or sent manually). */ requestRestart(reason: string): void; /** * Idle timeout reached: drop the child and everything it holds, and stay * resident on the host's stdio so the connection itself survives. The next * host line respawns via handleHostLine(). * * Only ever suspends from a settled 'ready' state - suspending mid-restart * or while the crash backoff is deciding what to do would race with it. */ suspend(reason: string): void; private spawnAndReplay; private synthesizeErrorsForAllInFlight; private sendSynthesizedError; private clearStabilityTimer; } //# sourceMappingURL=restart-coordinator.d.ts.map