UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

51 lines (50 loc) • 3.27 kB
import { type Checkpoint, type PendingSteerEntry, type ResumeOutcome } from "../checkpoint-store.js"; import type { ResumeRun, ResumeTaskConfig, RunInternals, RunnerDepsSeat } from "./contracts.js"; export interface ResumeApplyInput<R> { /** borrowed-readonly — the pending row (session id, pending call, inherited chain, ledger, hands cwd). */ cp: Checkpoint; /** borrowed-readonly — the config snapshot (`hooks`, `taskId`, `signal`, the policy seats). */ config: ResumeTaskConfig; /** borrowed-readonly — the internals snapshot (delegation identity facts for the screen's envelope). */ internals: RunInternals | undefined; /** borrowed-readonly — the ONE read of the outcome discriminant. */ outcomeGate: ResumeOutcome["gate"]; /** borrowed-readonly — the validated wake message the screen judges. */ wakeMessage: Omit<PendingSteerEntry, "seq"> | undefined; /** borrowed-readonly — the ONE signal read from admission; the screen and the edit legs are bounded by it. */ resumeSignal: AbortSignal | undefined; /** borrowed-readonly — the window verdict to re-assert after the screen's await (undefined when unarmed). */ recheckGovernanceWindow: (() => Promise<void>) | undefined; /** borrowed-readonly — the approval lane's twin (its edit is what the rechecks judge; the settlement is minted onto a copy). */ plainPolicyOutcome: Extract<ResumeOutcome, { gate: "policy_ask"; }> | undefined; /** borrowed-readonly — the review lane's twin. */ plainReviewOutcome: Extract<ResumeOutcome, { gate: "plan_review" | "dry_run_review"; }> | undefined; /** borrowed-readonly — the tool-less park lanes' twin. */ plainParkOutcome: Extract<ResumeOutcome, { gate: "wake" | "resource_limit"; }> | undefined; /** borrowed-readonly — the Runner's deployment deps, read LIVE through the Runner (reads `hooks`, `onError`, `lockedConfig`, `basePolicyForResumeEdit`, `toolPolicy` — the last three AFTER this rung's awaits); the one home of why it is a * seat and not a captured object is {@link RunnerDepsSeat}. */ runner: RunnerDepsSeat; /** borrowed-readonly — the orchestrator's delegation-facts fold (a lane may not name the orchestrator; the driver hands it in). */ effectiveDelegationFacts: (internals: Pick<RunInternals, "isDelegatedChild" | "insideFork"> | undefined, seedIsDelegatedChild: boolean | undefined) => { isDelegatedChild: boolean; }; /** borrowed-readonly — the rung after apply, entered in this rung's last continuation. */ next: (applied: ResumeApplyResult) => Promise<R>; } export interface ResumeApplyResult { /** The screen's `additionalContext` for the wake message, when a screen ran and supplied one. */ wakeHookContext: string | undefined; /** The approval lane's twin WITH its minted settlement record (undefined on every other lane). */ plainPolicyOutcome: Extract<ResumeOutcome, { gate: "policy_ask"; }> | undefined; /** The twin the store persists and the resumed leg reads — exactly one lane captured it. */ outcomeForStore: ResumeRun["outcome"]; } export declare function resumeApply<R>(input: ResumeApplyInput<R>): Promise<R>;