@sema-agent/core
Version:
Stateless, task-oriented AI agent core
28 lines (27 loc) • 2.39 kB
TypeScript
/**
* The leg's ONE record of what its rewind did — the files (`moved`, and the accepted restore's own ledger) and the conversation's
* leaf (`branch`) — minted where each happens and read by the two exits that mint a result: the run's assembly (`assemble-result.ts`)
* and the settle backstop of a leg whose prepare threw (`stream-settle-backstop.ts`). Each writer states the fact it is the one to
* know: the restore (`settleFileHistoryRestore`, off the witness of what it asked of the env), the acquire that branched
* (`prepare-acquire-reconcile.ts`), the cleanup that puts the branch back (`writeBranchBack`), the file-history phase that accepted
* the restore. Nothing re-derives a fact from a sentence or a code.
*/
import type { RewindBranch, RewindMoved, TaskRewindSettlement } from "../terminal-cause.js";
import type { TaskResult, TaskSpec } from "../types.js";
/** The record ({@link rewindOutcomeOf} mints it; the writers above fill it). `branch: undefined` = not known (see
* {@link TaskRewindSettlement.branch}). `restore` = the restore the leg accepted (complete, or partial under `acceptPartialRestore`). */
export interface RewindOutcome {
moved: RewindMoved;
branch: RewindBranch | undefined;
restore?: NonNullable<TaskResult["fileRestore"]>;
}
/** The record for a leg whose request asks for a rewind (`resumeAt`, `rewindFilesTo` or `restoreFiles` stated) — nothing moved yet,
* the leaf where the request found it; `undefined` for any other leg (it states no `rewind`). Read off the members as stated, before
* any of them is judged: a request whose rewind is then refused still asked for one. */
export declare function rewindOutcomeOf(spec: Pick<TaskSpec, "resumeAt" | "rewindFilesTo" | "restoreFiles">): RewindOutcome | undefined;
/** The settlement a failed terminal states ({@link TaskRewindSettlement}): a copy of the record as it stands (`branch` left out when
* not known). */
export declare function rewindSettlementOf(outcome: RewindOutcome): TaskRewindSettlement;
/** A result's two rewind members off the leg's record: `terminal.rewind` on a terminal that did not do the work (`failed`, `blocked`),
* `fileRestore` on any terminal whose leg accepted its restore. The one reading both result exits apply. */
export declare function withRewindOutcome(result: TaskResult, outcome: RewindOutcome | undefined): TaskResult;