@sema-agent/core
Version:
Stateless, task-oriented AI agent core
45 lines (44 loc) • 3.98 kB
TypeScript
/**
* The placement fence's two engine readings (the seat and its contract: `ExecutionEnvFactoryContext.placementTarget`,
* remote-env.ts): the MINT folds a leg's fence once, and the SETTLE POINT reads the leg's own target once — which is
* also every fenced leg's receipt (a restore takes the same receipt earlier as well, against the env before and the
* handle after `resumeVM`, in prepare-workspace-restore.ts).
*/
import { type PlacementTarget, type WorkspaceHandle } from "../remote-env.js";
import type { ExecutionEnv } from "../../internal/harness.js";
/**
* The fence a leg is minted under, from its two sources: the target its checkpoint row recorded (a durable resume leg)
* and the one its trusted internals carry (the leg that handed it work). Member by member — a member the row states
* wins, a member it does not state is the internals' (a row recorded before `deviceId` existed takes the waking leg's
* device) — so neither source replaces the other whole. `undefined` when neither names a provider. A handed value the
* engine cannot read as a target (no non-empty string `provider`, a `deviceId` that is not a string) is refused loudly
* rather than read as "no fence", which would place the leg wherever the current binding points.
*/
export declare function mintPlacementFence(row: WorkspaceHandle | undefined, handedValue: unknown): PlacementTarget | undefined;
/**
* The leg's OWN target, read once at its settle point (what its env reports, {@link reportedPlacementTarget}) — the fence
* of every leg it hands work to — and every fenced leg's receipt on that same reading: an env that does not name the
* device its fence names is refused before anything reports the workspace or runs on it. A leg that restored a
* checkpointed workspace (its restore took the receipt already, against the restored handle) is refused
* `resume.env_failed` here too — its env may have moved after the restore (re-initialization reconnecting elsewhere) —
* any other leg `config.placement_not_honored`. `restoredRow` is that leg's row's workspace (absent on every other leg): a
* refusal whose one reading of the env's device {@link devicesDisprove} the row's is marked `envDisowned` (the env is not the
* row's workspace, so the leg's exit destroys it at once).
*/
export declare function settleOwnTarget(env: ExecutionEnv | undefined, fence: PlacementTarget | undefined, restoredRow: Pick<WorkspaceHandle, "deviceId"> | undefined): PlacementTarget | undefined;
/** Whether a device receipt disproves that a resume leg's env stands at its row's workspace: the row and the env each name a
* device and they differ (an absent one, or the waking leg's, proves nothing). The one reading of both receipts a resume leg
* meets — the restore's identity check before anything is connected, and the settle point after. */
export declare function devicesDisprove(rowDevice: string | undefined, envDevice: string | undefined): boolean;
/** The codes a device move is refused with: a fresh fenced leg, and a leg that restores or resumes a checkpointed workspace. */
export type DeviceMoveRefusalCode = "config.placement_not_honored" | "resume.env_failed";
/**
* THE refusal every device receipt throws — the settle point's two arms and the resume restore's identity check — so the
* three speak one sentence. A delegating model reads it as the child's `error:` line, which the report bounds at 300
* characters and which sits beside no code line of its own: the code, the two devices (each held to a budget, so an id of
* any length leaves room) and the way on come first, the host's part of the contract last, where a cut costs the least.
* The way on is the model's to act on: bring the workspace back to the fenced device, or start the work in a new workspace.
*/
export declare function deviceMoveRefusal(code: DeviceMoveRefusalCode, fenceDevice: string | undefined, reportedDevice: string | undefined): Error & {
code: string;
};