@sema-agent/core
Version:
Stateless, task-oriented AI agent core
57 lines (56 loc) • 3.92 kB
TypeScript
import type { SessionTreeEntry } from "../../internal/harness-types.js";
import type { MaybeCompactOptions } from "../auto-compaction.js";
import { type CommandSandboxLeg, type CommandSandboxRun } from "../command-sandbox.js";
import type { Prepared } from "./contracts.js";
import { type ToldSeat } from "./conversation-segment.js";
/** The record's value: the digest of the text the model was told, or `null` — told the sandbox is gone. */
export type SandboxFrameValue = string | null;
/**
* The frame's text for a run, or `undefined` when the run keeps no sandbox the model can be told of (off, unavailable — the
* notice is the person's; a lapsed run says so on the refusal that lapsed it). The reference's section: the head, the
* restrictions as JSON lists (read: denied, re-allowed; write: allowed, denied within; network: allowed and denied hosts;
* the ignored violations), then the rules for leaving the sandbox — or, when the requirement does not let a call leave it,
* the reference's sentence that the parameter does nothing.
*/
export declare function renderSandboxInstructions(run: CommandSandboxRun, leg: CommandSandboxLeg): string | undefined;
/** The frame a leg owes, from what the model was told in this segment (a digest; `null` = told the sandbox is gone; `undefined` =
* nothing told) and the text the run's sandbox reads as now (`undefined` = none). */
export declare function sandboxFrame(told: SandboxFrameValue | undefined, text: string | undefined): {
body: string;
value: SandboxFrameValue;
} | undefined;
/** What the run's sandbox reads as NOW, for a restatement: its instructions while it keeps them, the sentence its lapse told once it
* lapsed (recorded as gone), nothing when the run keeps no sandbox. */
export declare function sandboxFrameNow(run: CommandSandboxRun, leg: CommandSandboxLeg): {
body: string;
value: SandboxFrameValue;
} | undefined;
/** A leg's sandbox frame seat: the told seat and what a compaction restates (read when it lands). */
export interface SandboxFrameSeat extends ToldSeat<SandboxFrameValue> {
readonly now: () => {
body: string;
value: SandboxFrameValue;
} | undefined;
}
/** The leg's seat, or `undefined` when there is nothing to tell and nothing told. An unreadable branch never withholds: the text is
* told (a duplicate at worst) and, with none now, a recorded one is said gone; such a leg records nothing. */
export declare function prepareSandboxFrameSeat(input: {
text: string | undefined;
now: SandboxFrameSeat["now"];
told: {
value: SandboxFrameValue;
segment: string | null;
} | undefined;
session: {
getBranch(): Promise<ReadonlyArray<SessionTreeEntry>>;
};
}): Promise<SandboxFrameSeat | undefined>;
/** The owed sandbox frame as one engine-marked reminder, carried as the language frame's is (`languageFrameText`, `language-frame.ts`). */
export declare function sandboxFrameText(prepared: Pick<Prepared, "sandboxFrameSeat" | "reminderMark">): string | undefined;
type RecordSeats = Pick<Prepared, "sandboxFrameSeat" | "announcedListingsRef" | "frameReceipts">;
/** The sandbox frame's receipt on its carrying message, under the language frame's law (`registerLanguageReceipt`, `language-frame.ts`). */
export declare function registerSandboxFrameReceipt(prepared: RecordSeats, text: string): void;
/** The seat's COMPACTION arm, on a leg whose run keeps a sandbox: the told seat's one restate of what the sandbox reads as when the
* compaction lands — nothing is appended while the leg's own pending frame is that very text, and the record moves to the new segment. */
export declare function sandboxFrameRestateOption(prepared: RecordSeats & Pick<Prepared, "reminderMark" | "session" | "admitRows" | "batchHaltRef" | "postureFrameRef" | "announcedSnapshotRecovered">): Pick<MaybeCompactOptions, "sandboxFrameRestate">;
export {};