/** * Coordinates the two directions of the driver-swap / prompt-turn race: * * - swap-during-turn: a swap {@link awaitActiveTurn}s so the outgoing driver is * never killed while a turn is still awaiting its `prompt()`. * - prompt-during-swap: a prompt {@link awaitSwap}s so it binds to the fresh * driver instead of one being disposed. * * A single instance is scoped to one agent server. All methods are safe to call * even when nothing is in flight (they resolve immediately). */ export declare class DriverSwapGate { /** Resolves when the in-flight driver recreate settles (resolve or reject). */ private activeDriverSwap; /** FIFO chain; resolves once every started turn has settled. */ private turnTail; /** * Mark a turn as in flight. Call at the real `driver.prompt()` dispatch — not * earlier — so a same-handler restart (e.g. restaging skills before the turn) * cannot self-deadlock by awaiting the very turn that spawned it. Returns an * idempotent `endTurn`; call it in a `finally` around the dispatch. */ beginTurn(): () => void; /** * Await any in-flight turn before tearing a driver down. Awaits the FIFO tail * (not a single "latest turn" field) so an earlier turn that outlives a later * one still holds the swap off — the tail resolves only once every started * turn has settled. Never throws: a rejected turn is still a settled turn, and * the swap may proceed (the driver is idle either way). */ awaitActiveTurn(): Promise; /** * Register the in-flight recreate promise so concurrent prompts defer to it. * Auto-clears when `recreate` settles (resolve OR reject) so a failed recreate * never blocks prompts forever. */ beginSwap(recreate: Promise): void; /** * Await the in-flight swap before reading the live driver. Re-checks in a loop * so a second swap starting during the wait is also awaited. */ awaitSwap(): Promise; } //# sourceMappingURL=driver-swap-gate.d.ts.map