UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

56 lines (55 loc) • 3.98 kB
/** * The advisor tool's instructions to the model — the reference's text, verbatim — its two short forms (a re-attach after a * withdrawal, and the withdrawal), the one transition that says which a leg owes, and the leg's seat for them. The frame is * the `advisor_tool` attachment kind: it rides a fresh leg's first request, and a compaction inside a leg that mounts the * tool restates the full text right after it lands. Model lane only: no `steering_injected` echo. The three texts are * catalog messages (`core/event.advisor-tool*`, the `event-mechanism` band), read in the run's reading where the frame is * minted. */ import type { AnnouncedAdvisorState, AnnouncedListingSnapshotInput } from "../../internal/harness.js"; import type { EngineText } from "../../prompt-assembly/engine-text.js"; import { type ToldSeat } from "./conversation-segment.js"; import type { FrameReceiptLedger, Prepared } from "./contracts.js"; /** What the model has been told about the advisor in the conversation's current segment (since the latest compaction): the session record's own word. */ export type AdvisorInstructionState = AnnouncedAdvisorState["state"]; /** * The advisor instructions a leg owes, from what the model was told and whether the tool is mounted now, worded by `say`: * nothing told and mounted ⇒ the full text; told and not mounted ⇒ the withdrawal; withdrawn and mounted again ⇒ the short * re-attach; every other pair owes nothing. `value` is what the model has been told once the frame is delivered. */ export declare function advisorInstructionFrame(told: AdvisorInstructionState | undefined, mounted: boolean, say: EngineText): { body: string; value: AdvisorInstructionState; } | undefined; /** A leg's advisor-instructions seat: the told seat (the frame its first request owes, the segment that was judged in) and whether the tool is mounted. */ export interface AdvisorInstructionSeat extends ToldSeat<AdvisorInstructionState> { readonly mounted: boolean; } /** The owed frame as one engine-marked reminder — what a fresh leg's first message and a resumed leg's continuation both * carry — or `undefined` when nothing is owed. */ export declare function advisorFrameText(prepared: { readonly advisorInstruction?: AdvisorInstructionSeat; readonly reminderMark: string; }): string | undefined; /** Register the owed frame's receipt on the message that carries it (`text`, the exact first text block): its commit * records what the model was told only once that message is in the transcript. Nothing owed ⇒ nothing registered. */ export declare function registerAdvisorReceipt(prepared: { readonly advisorInstruction?: AdvisorInstructionSeat; readonly announcedListingsRef: AnnouncedListingSnapshotInput; readonly frameReceipts: FrameReceiptLedger; }, text: string): void; /** The owed frame was delivered (its carrying message is in the transcript): what the model was told is recorded for the * segment it was told in, and the snapshot write is parked like every listing commit's. */ export declare function settleAdvisorInstruction(prepared: { readonly advisorInstruction?: AdvisorInstructionSeat; readonly announcedListingsRef: AnnouncedListingSnapshotInput; readonly frameReceipts: { listingSnapshotOwed: boolean; }; }): void; /** * A compaction landed on a leg that mounts the advisor: the full instructions it summarized away are restated in the run's * reading (the told seat's one compaction arm), and the record moves to the new segment — so a leg that no longer mounts the * tool withdraws what the model now holds, and a leg that still does tells nothing twice. Never throws. */ export declare function appendAdvisorRestate(prepared: Pick<Prepared, "advisorInstruction" | "reminderMark" | "session" | "admitRows" | "batchHaltRef" | "postureFrameRef" | "announcedListingsRef" | "frameReceipts" | "announcedSnapshotRecovered" | "engineText">): Promise<void>;