@sema-agent/core
Version:
Stateless, task-oriented AI agent core
40 lines (39 loc) • 3 kB
TypeScript
/**
* The resume ladder's INTERNALS-AND-CONFIG rung (E7), verbatim from `Runner.resumeStream`:
* the inherited constraints' retired-member door, the principal, placement and composition-leg identity-continuity rungs,
* the own-lists continuity rung (the definition a delegated leg's name resolves to now against the one it was parked under),
* and the governance-window ENTRANCE check for a row that still owes a delivery.
*
* Synchronous by construction: the window verdict is handed back as a closure and NOT started here. The driver
* asserts it as the entrance once the resume holds the session's lock, so the wait for the lock is never spent
* between the verdict and the claim; an `async` wrapper would add a suspension point on the path where no window
* is armed most of all. Same reason the forwarding drain is a synchronous predicate plus a Promise factory
* (prepare-run-refs.ts).
*/
import { type Checkpoint, type ResumeOutcome } from "../checkpoint-store.js";
import type { ResumeTaskConfig, RunInternals, RunnerDepsSeat } from "./contracts.js";
export interface ResumeInternalsAndConfigInput {
/** borrowed-readonly — the pending row (recorded principal, placement root, parked steers, background tasks). */
cp: Checkpoint;
/** borrowed-readonly — the config snapshot (`principal`). */
config: ResumeTaskConfig;
/** borrowed-readonly — the internals snapshot (`placementRoot`, `compositionLeg`, `ownToolLists`). */
internals: RunInternals | undefined;
/** borrowed-readonly — the ONE read of the outcome discriminant (a bare resource_limit continue owes nothing). */
outcomeGate: ResumeOutcome["gate"];
/** borrowed-readonly — the Runner's deployment deps, read LIVE through the Runner (reads `usageWindowStore`, `usageWindows`); the one home of why it is a
* seat and not a captured object is {@link RunnerDepsSeat}. */
runner: RunnerDepsSeat;
/** borrowed-readonly — the resume's cancellation. The ledger read takes no signal, so the verdict races it: every assertion runs
* while the resume holds the session's lock, and an abort must end the wait (and so the hold) whether or not the ledger answers. */
resumeSignal: AbortSignal | undefined;
/** borrowed-readonly — the checkpoint screen's chain rungs refused the chain (`chainRung`): that refusal answers for it, thrown after
* the identity rungs here, so the chain is not read again. */
chainRefused: boolean;
}
export interface ResumeInternalsAndConfigResult {
/** The window verdict as a re-assertable closure (armed only when governance is active; absent otherwise). Not started here: the driver
* asserts it first as the entrance under the session's lock, and the rungs whose awaits sit inside the read→CAS window assert it again. */
recheckGovernanceWindow: (() => Promise<void>) | undefined;
}
export declare function resumeInternalsAndConfig(input: ResumeInternalsAndConfigInput): ResumeInternalsAndConfigResult;