@sema-agent/core
Version:
Stateless, task-oriented AI agent core
34 lines (33 loc) • 2.43 kB
TypeScript
/**
* The resume ladder's INTERNALS-AND-CONFIG rung (E7), verbatim from `Runner.resumeStream`:
* the locked-policy guard on the resume-edit seat, the principal and placement identity-continuity rungs,
* and the governance-window ENTRANCE check for a row that still owes a delivery.
*
* Synchronous by construction, with the ladder's ONE await at this rung handed back instead of taken: the
* window read is STARTED here (the same expression, on the same tick) and returned as `windowEntrance` for the
* driver to await exactly where the ladder always awaited it — an `async` wrapper would add a suspension point
* the ladder never had, 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 (`basePolicyForResumeEdit`, `principal`). */
config: ResumeTaskConfig;
/** borrowed-readonly — the internals snapshot (`placementRoot`). */
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 `lockedConfig`, `usageWindowStore`, `usageWindows`); the one home of why it is a
* seat and not a captured object is {@link RunnerDepsSeat}. */
runner: RunnerDepsSeat;
}
export interface ResumeInternalsAndConfigResult {
/** The window verdict as a re-assertable closure (armed only when governance is active), for the rungs whose awaits sit inside the read→CAS window. */
recheckGovernanceWindow: (() => Promise<void>) | undefined;
/** The entrance check already in flight (started on this tick) — the driver awaits it where the ladder did; absent when governance is unarmed. */
windowEntrance: Promise<void> | undefined;
}
export declare function resumeInternalsAndConfig(input: ResumeInternalsAndConfigInput): ResumeInternalsAndConfigResult;