UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

54 lines (53 loc) • 4.04 kB
/** The file-history REQUEST door and its bad-value doors — the pre-acquire half of the file-history phase (`prepare-file-history.ts`). */ import { type FileHistoryRestoreOptions, type FileHistoryStore } from "../file-history-store.js"; import type { RunnerDeps, TaskSpec } from "../types.js"; /** * The file-history REQUEST door: every refusal the request (`TaskSpec`) and the deployment's own seats decide * without the session, the env or the store's contents — the three bad-value doors (`RunnerDeps.onTrackFailure`, * `RunnerDeps.fileHistoryStore` / `fileHistoryCapture`, `TaskSpec.fileHistory`), the restoreFiles / resumeAt / * rewindFilesTo contradictions, and a restore asked of a run that holds no * history (`rewind.capture_disabled` / `rewind.store_unconfigured`). SYNCHRONOUS and side-effect free; the driver * calls it BEFORE the session is acquired, so a request refused here leaves the session — its leaf included — * exactly as it was. What it resolves rides into the file-history phase (`prepareFileHistory`) unchanged. */ export declare function resolveFileHistoryRequest(spec: Pick<TaskSpec, "resumeAt" | "resumeAtMode" | "restoreFiles" | "rewindFilesTo" | "fileHistory" | "unplacedHistoryRecordedUnder">, deps: Pick<RunnerDeps, "onTrackFailure" | "fileHistoryStore" | "fileHistoryCapture">): FileHistoryRequest; /** * THE reading of `unplacedHistoryRecordedUnder` (`TaskSpec` and `RewindFilesRequest` name it alike): a non-empty absolute path * (in either path family), or the word {@link UNPLACED_AT_REWIND_ROOT} (the rewind's own root, resolved by the engine where the * restore runs — {@link restoreOptionsAt}), on a request that restores files, else refused by name (`rewind.invalid_spec`) — on a * request that restores nothing it would be read by no one, and a value that is neither is not a directory anything was recorded under. */ export declare function readRestoreOptions(value: unknown, restores: boolean, seat: "TaskSpec" | "Runner.rewindFiles"): FileHistoryRestoreOptions | undefined; /** * The DEPLOYMENT's file-history door — the three seats a deployment sets once (`RunnerDeps.onTrackFailure`, * `RunnerDeps.fileHistoryStore`, `RunnerDeps.fileHistoryCapture`), each refused by name on a bad value. Read by * every seat that touches file history: the run's request door above and the out-of-run `Runner.rewindFiles`, so a * misconfigured deployment is refused the same way at both. `fileHistoryStore` is the store after the declared * `"disabled"` word; `captureStore` additionally drops it when capture is `"off"` (recording stops, restore stays). */ export declare function resolveDeploymentFileHistory(deps: Pick<RunnerDeps, "onTrackFailure" | "fileHistoryStore" | "fileHistoryCapture">): { onTrackFailure: "refuse" | "proceed-unprotected"; wiredSeat: FileHistoryStore | "disabled" | undefined; captureOff: boolean; fileHistoryStore: FileHistoryStore | undefined; captureStore: FileHistoryStore | undefined; }; /** A restore asked of a deployment that holds no history backend (none wired, or declared `"disabled"`). */ export declare function storeUnconfiguredRefusal(wiredSeat: FileHistoryStore | "disabled" | undefined, target: string): Error & { code?: string; }; /** What {@link resolveFileHistoryRequest} resolved: the validated seats and words, the run's store (after every off * switch) and its capture store, and the restore target (`undefined` = no restore asked). */ export interface FileHistoryRequest { onTrackFailure: "refuse" | "proceed-unprotected"; wiredSeat: FileHistoryStore | "disabled" | undefined; runDeclaredOff: boolean; captureOff: boolean; declaredOff: boolean; fileHistoryStore: FileHistoryStore | undefined; captureStore: FileHistoryStore | undefined; rewindTarget: string | undefined; rewindBefore: boolean; /** The restore's options ({@link readRestoreOptions}); `undefined` when the request names none. */ restoreOptions: FileHistoryRestoreOptions | undefined; }