UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

52 lines (51 loc) • 4.01 kB
import type { AgentMessage } from "../internal/harness.js"; /** The Read tool's names, as recorded on its results and calls (the catalog name, and the two spellings older transcripts * carry). The kept-tail scan of a compaction reads the same table. */ export declare const READ_TOOL_NAMES: ReadonlySet<string>; /** What the request builder knows beyond the view itself. */ export interface CopyProjectionInput { /** The identities whose chain heads the request carries as pointers (the lane's budget arm, {@link chooseDegraded}). */ readonly degraded?: ReadonlySet<string>; /** This leg's startup seed: canonical key → the whole-file content hash its system prompt holds. */ readonly seeded?: ReadonlyMap<string, string>; /** The session's reminder mark, for the marked sentences a frame carries. */ readonly mark?: string; /** The results the tool-turn law folded, and the recorded results each folds, in order. */ readonly folds?: ReadonlyMap<object, readonly object[]>; } /** * Is this recorded delivery a de-duplication sentence an earlier engine wrote in place of the file's contents? Three * forms: an attachment frame whose record says `unchanged` (it carries no data); a Read result marked * `details.type: "file_unchanged"`; a Read result from before that marker existed — no structured details, and its whole * text is one of the two sentences (anchored at both ends, so a file whose text merely quotes a sentence is contents). * Such a delivery has no contents to stand for anything: a request carries it as the pointer sentence, and a reader * asking "is the file's content visible here" reads it as absent. */ export declare function isRetiredDedupStub(m: unknown): boolean; /** * The view as the request sends it, position-aligned with the input: every delivery rendered by its chain, every notice by * what the view already told (module header); `undefined` at a message the request does not send. The array itself when * nothing renders differently. */ export declare function projectRequestView<T extends AgentMessage>(view: readonly T[], input?: CopyProjectionInput): ReadonlyArray<T | undefined>; /** The messages the request sends ({@link projectRequestView} without the ones it leaves out); the array itself when * nothing renders differently. */ export declare function projectRequestCopies<T extends AgentMessage>(view: readonly T[], input?: CopyProjectionInput): T[]; /** * Does the request this view ends in tell the model something its last message's changed-files notices add? The same walk * that cuts the request answers: a notice with a file no earlier notice of the view told is carried (whole or with the told * lines cut); one whose every file was told is carried only when the request would send the message as written anyway (a * message left with nothing to say is not sent, unless that would end the request on an assistant row). A last message * with no notice record is carried as written. The engine's `steering_injected` echo for the notice asks this. */ export declare function lastNoticeCarried(view: readonly AgentMessage[]): boolean; /** The identity of a delivery that can carry contents (the lane's budget arm names identities), or `undefined`. */ export declare function copyIdentityOf(m: unknown): string | undefined; /** * The budget arm: over the rows the request must hold (its irreducible core, in view order), the identities whose copies * the request carries as pointers. Every copy's contents start as a pointer; then from the newest identity to the oldest, * one is given its contents when the core still `fits` with it (and the ones already given theirs) — so the oldest lose * their contents first, and a large newest copy that cannot fit never costs an older one that can. `fits` measures the * core rendered with the identities it is handed as pointers. */ export declare function chooseDegraded(core: readonly unknown[], fits: (degraded: ReadonlySet<string>) => boolean): Set<string>;