import type { CheckpointToken } from "../checkpoint-store.js";
import type { PushQueue } from "../push-queue.js";
import type { SessionStore } from "../session.js";
import { type TaskEvent, type TaskSpec } from "../types.js";
import type { InheritedGate, ResumeRun, RunnerDepsSeat, SuspendReap, TaskIdRef, TaskStreamLiveSeat } from "./contracts.js";
export interface StreamSettleBackstopInput {
    /** borrowed-readonly — the task spec (read for the subagent-forwarding predicate the terminal push drains under). */
    spec: TaskSpec;
    /** borrowed-readonly — the resume plan when this leg is a resume: its token, the reopen compensation, the delivered-decision facts. */
    resume: ResumeRun | undefined;
    /** borrowed-mutable — the stream's event queue: the backstop pushes the `done` frame and closes it. */
    queue: PushQueue<TaskEvent>;
    /** borrowed-mutable — the run body's backstop carrier (effective ids + post-prepare observations); the owed delegation terminal is cleared here once delivered. */
    taskIdRef: TaskIdRef;
    /** borrowed-readonly — the invocation's frozen tracer (one sink for the start↔end pair). */
    entryTracer: {
        tracer: TaskSpec["tracer"];
    };
    /** borrowed-readonly — the stream's construction instant, for the backstop `task.end`'s durationMs. */
    runStartedAt: number;
    /** borrowed-mutable — the stream's live state: `resultValue` is read (an already-minted terminal is kept) and written (the failed terminal is minted onto it). */
    live: TaskStreamLiveSeat;
    /** borrowed-readonly — the Runner's deployment deps, read LIVE (`onError`, `onDelegationLifecycle`, after awaits too). */
    runner: RunnerDepsSeat;
    /** borrowed-readonly — the Runner's session store (the terminal resume-failure arm's `unpin`). */
    sessions: SessionStore;
    /** borrowed-mutable — the Runner's same-Runner claim marks: every failure leg releases the resume token's claim. */
    locallyClaimedTokens: Set<CheckpointToken>;
    /** borrowed-mutable — the Runner's parked-constraint registry: the reopen-failure and terminal-failure arms evict the consumed resume token's entry. */
    parentConstraintRegistry: Map<CheckpointToken, NonNullable<InheritedGate["parentConstraints"]>>;
    /** borrowed-mutable — the Runner's suspended-env reap handles: the terminal resume-failure arm takes and destroys this token's. */
    suspendedEnvReaps: Map<CheckpointToken, SuspendReap>;
}
export interface StreamSettleBackstopResult {
    /** The rejection handler for `run.catch(…)` — the driver installs it; awaiting `run.catch(onRunRejected)` is awaiting the settled result. */
    onRunRejected: (err: unknown) => Promise<void>;
}
export declare function streamSettleBackstop(input: StreamSettleBackstopInput): StreamSettleBackstopResult;
