/**
 * The leg's RESTORE SEAT reading — the one place a leg's own remote environment answers whether the run may start.
 * The workspace-restore phase establishes the env its factory minted for the leg, before anything else reads it
 * (`resumeVM` on a leg that restores a snapshot, `connect` on every other leg), and hands the call to
 * {@link establishAtRestoreSeat}, which reads the answer in three steps: the run's own cancel stops the leg with the
 * cancelled run's terminal; `ok` answers back; a failure is read through `RETRYABLE_REMOTE_ERROR_CODES` — the run starts
 * past a code the table holds, `unknown` and an `aborted` the run did not cause, and any other code is the environment's
 * standing refusal, which ends the leg here with that code. Past a `connect` code the table holds, the seat makes the
 * reconnect the run's first operation would make itself, where a deployment's `env.` code ends the leg the same way
 * ({@link connectAtRestoreSeat}). Below it, the same refusal read
 * after the restore seat (the model shell's readiness, a command of the model's shell) and its one terminal. Machinery the
 * phases reach DOWN for; it imports no runner module but the contracts floor's types.
 */
import { RemoteExecutionError } from "../remote-env.js";
import type { RemoteExecutionEnv, WorkspaceHandle } from "../remote-env.js";
import type { ModelShellReading } from "../model-shell.js";
/** What an establishment call answers (`connect` and `resumeVM` share the shape). */
export type EstablishAnswer = {
    ok: true;
    value: WorkspaceHandle;
} | {
    ok: false;
    error: RemoteExecutionError;
};
/**
 * THE restore seat's reading of one establishment call, in three steps:
 *  ① the run's own cancel — read before the call (a cancelled run establishes nothing) and again once it settled — stops
 *    the leg with the run's one cancellation value, the terminal every cancelled run reports;
 *  ② `ok` answers back;
 *  ③ a failure is read through `RETRYABLE_REMOTE_ERROR_CODES`: a code it holds, `unknown` (it names no fact of the
 *    environment, and neither does a code the answer leaves empty or blank) or `aborted` (a cancel the run's own did not
 *    cause — ① read that one) answers back to the verb's own
 *    reading; any other code is this environment's standing refusal — starting the run past it would only retry it at the
 *    first operation — and fails the leg here: the thrown value states no code of its own, so the terminal reads the
 *    adapter's through the cause, and it carries no failure note (the terminal IS the code).
 * A call that throws is not read here: the throw passes through as it is (the `connect` arm reads its own throw below).
 */
export declare function establishAtRestoreSeat<A extends EstablishAnswer>(verb: "connect" | "resumeVM", signal: AbortSignal, call: () => Promise<A>): Promise<A>;
/**
 * `connect` at the restore seat. The seat reads its first answer (above). Starting the run past a code the retryable
 * table holds means the run's first operation connects again — on a fresh leg the first that can connect is the leg's
 * bounded reading of its start for model text, which a slow reconnect would run out — so the seat makes that reconnect
 * itself, at once and once, and reads its answer as every face after the first answer reads the environment: the run's own
 * cancel first, then a deployment's own `env.` code — the environment refusing itself — is the same standing refusal a first
 * answer with that code is (the same error as the cause, so the same terminal); any other answer (ok, a table code, another
 * closed-set word, `unknown`, `aborted`) lets the run start, as it would have. `unknown` and an `aborted` the run did not
 * cause are started past without it. An answer outside the contract — a throw (an adapter without the method, or one that
 * broke the never-throw contract), or a value that is neither `{ ok: true }` nor `{ ok: false, error }` with a string
 * `error.code` — is no code at all: `unknown`. The handle an answer carries is not read (the settle point reads the
 * env's own `workspaceHandle()`).
 */
export declare function connectAtRestoreSeat(env: RemoteExecutionEnv, signal: AbortSignal): Promise<void>;
/** THE terminal of an environment's standing refusal: `<verb> refused (<code>): <its sentence>`, the adapter's error as the cause. The
 *  value states no code of its own, so the terminal reads the adapter's through the cause. */
export declare function standingRefusal(verb: string, failure: {
    readonly code: string;
    readonly message: string;
}): Error;
/** A leg's seat for the environment refusing itself after the run started (`Prepared.envRefusal`): `arm` once the leg's own first model
 *  response began, `note` a command's refusal (kept only once armed; the first one wins), `read` the terminal of the one kept. */
export type EnvRefusalSeat = import("./contracts.js").Prepared["envRefusal"];
export declare function createEnvRefusalSeat(): EnvRefusalSeat;
/** What the turn's end reads and writes to stop the leg: the leg's seat, its pause and cancel, its stop latch, and the run's terminal. */
export interface RefusalStopLeg {
    readonly envRefusal: EnvRefusalSeat;
    readonly pausedRef: {
        readonly current?: unknown;
    };
    readonly abortController: AbortController;
    readonly stopRequestedRef: {
        current: boolean;
    };
    readonly harness: {
        requestStopAfterTurn(): void;
    };
}
/**
 * The turn's end, first: a command of this turn met the environment refusing itself ⇒ the run's terminal is that refusal and the leg
 * stops CLEANLY after this turn (the batch settled; nothing is cut, nothing is attributed to a person's stop). Answers whether it did.
 * A terminal already decided, a committed pause and the run's own cancel keep theirs. Read ahead of the turn cap and the budget gate:
 * their codes would hide the one cause the caller can act on (a different environment).
 */
export declare function stopOnEnvRefusal(leg: RefusalStopLeg, run: {
    platformTerminal: Error | undefined;
}): boolean;
/** A leg's model-shell reading, settled: a `ready` that answered the environment's own refusal ends the leg here
 *  (`modelShell.ready refused (<code>): …`) — after the run's own cancel (`signals`), which a cancel that landed while `ready` was pending
 *  is (the cancelled run's terminal). Any other reading answers back. */
export declare function settledReadiness(reading: ModelShellReading, ...signals: readonly (AbortSignal | undefined)[]): ModelShellReading;
