@sema-agent/core
Version:
Stateless, task-oriented AI agent core
51 lines (50 loc) • 4.72 kB
TypeScript
import type { MaybeCompactOptions } from "../auto-compaction.js";
import { type PostureFacts } from "../auto-mode-directive.js";
import type { Prepared } from "./contracts.js";
/**
* The facts the posture composition reads, as the leg IS now: the live effective mode and ask answer, the plan-exit
* tool's presence on the minted roster, and the minted delegation identity. The one place a leg's facts are assembled —
* the leg's first turn, a resumed continuation, a continuing boundary and a landed compaction all ask through it.
*/
export declare function postureFactsOf(prepared: Pick<Prepared, "approvalPosture" | "toolRoster" | "hookIdentity">): PostureFacts;
/**
* The posture question, asked of the ACTIVE context: the frames the leg's mode facts owe now (exits of retired
* families, the owed frame or its cadence's restatement — `composePostureFrames`), minted as one carrier text —
* one marked reminder per frame — that takes the context lane's protection slot. `undefined` when the context
* already states the posture.
*
* `"on_change"` (a continuing turn boundary): asks nothing of the context when the facts still call for the row the
* last composition answered for and that row keeps no cadence — the context only changes posture through this
* function's own carriers and a landed compaction (which asks with `"always"`). A context that cannot be read
* answers "nothing standing": the owed frame is restated rather than withheld.
*/
export declare function owedPostureText(prepared: Pick<Prepared, "approvalPosture" | "toolRoster" | "hookIdentity" | "session" | "reminderMark" | "postureFrameRef">, ask: "always" | "on_change"): Promise<string | undefined>;
/** The posture's COMPACTION arm: after a landed compaction the runner asks the posture question of the compacted
* context and appends what it owes as one engine-minted message, before any reader of the new baseline (the next
* model request included). A leg that owes no posture registers nothing: a compaction only REMOVES frames, and a
* retired frame that survives it in the kept tail is answered by the next composition (the next continuing
* boundary, or the next leg's first turn). */
export declare function postureRestateOption(prepared: Prepared): Pick<MaybeCompactOptions, "postureRestate">;
/**
* The posture's MID-RUN write (a turn boundary, a landed compaction): what the active context owes is appended to
* the transcript as one engine-minted message, awaited — the next request's context is rebuilt from the session after
* the boundary, so the frames reach that very request, ahead of every queued steer. Two cases do not write, and take
* one path — the frames ride each request's view (never persisted) and the composition stays dirty, so the next
* boundary that can write does: a boundary that HOLDS engine injections (a person's bare rejection halted the batch —
* nothing the engine says may enter the transcript ahead of that person's next words), and a failed append (the rule
* of every engine frame written at a boundary, the git frame's re-assert and the compaction itself: the run continues
* and the failure is reported, `onError` phase `degraded`). Never throws.
*/
export declare function appendOwedPosture(prepared: Pick<Prepared, "approvalPosture" | "toolRoster" | "hookIdentity" | "session" | "reminderMark" | "postureFrameRef" | "batchHaltRef">, ask: "always" | "on_change"): Promise<void>;
/** The declared output style's frame as one engine-marked reminder — the one spelling every site that states it directly
* (a resumed leg's continuation, a boundary a queued input continues) mints. */
export declare function mintOutputStyleReminder(prepared: Pick<Prepared, "outputStyleFrame" | "reminderMark">): string | undefined;
/**
* The turn boundary's direct writes, for a boundary a request can follow: the owed posture, and the output style when
* the turn was text-final and queued work already guarantees the next request (`pendingInjectionCount`, both lanes). The
* guarantee is read synchronously, at the call, before any await — a boundary with nothing queued returns the posture's own
* promise, so it reaches no await the posture did not already have.
*/
export declare function appendBoundaryFrames(prepared: Pick<Prepared, "approvalPosture" | "toolRoster" | "hookIdentity" | "session" | "reminderMark" | "postureFrameRef" | "batchHaltRef" | "outputStyleFrame" | "harness">, turnHadToolCalls: boolean): Promise<void>;
/** Every post-compaction restatement the turn boundary registers, at one spread site. */
export declare function compactionRestateOptions(prepared: Prepared): Pick<MaybeCompactOptions, "gitRestate" | "postureRestate">;