@sema-agent/core
Version:
Stateless, task-oriented AI agent core
56 lines (55 loc) • 4.34 kB
TypeScript
/**
* What the approving person wrote on the card ({@link ResumeOutcome} `policy_ask` `allow` `feedback`) — which decide may carry it,
* and how it joins the resume continuation; and the live leg's carrier for the same words ({@link approvalWordsSeat}).
*
* ONE READING of "did the person write anything" ({@link writtenFeedback}, in approval-words.ts beside the judge of which words
* may be delivered): the text with the whitespace the card's input does not keep removed, or nothing when that leaves nothing. The
* pre-CAS checks and the continuation both ask it, as does the live answer's reading, so they cannot disagree about a blank value.
* (A deny's `reason` keeps its own rule, `decidersNote`: only `""` is blank there.)
*
* The words ride the resume continuation user message — the first message after the batch's tool results, once the batch's
* unanswered siblings have settled — as a user-lane range of their own: outside every engine segment, so a derived view reads
* them as user speech; verbatim, no fence, no wrapper sentence, no length bound. They are owed with the rest of the
* continuation: when the batch parks again before the prompt lands they ride the new row as its last parked steer.
*/
import type { AgentHarness } from "../../internal/harness.js";
import { type ApprovalWordsSeat } from "../approval-words.js";
import { type PendingSteerEntry, type ResumeOutcome } from "../checkpoint-store.js";
type PolicyAsk = Extract<ResumeOutcome, {
gate: "policy_ask";
}>;
/**
* Pre-CAS: a WRITTEN feedback is the allow arm's, a person's, and free of the `<system-reminder>` tag (opening or closing — the one
* judge `sanitizeUntrustedText`; why a tag is refused at this door and not defused is the one reading in `docs/CLOSED-SETS.md`). Each is refused
* (`checkpoint.invalid_outcome`, the row stays pending for a well-formed decide) rather than dropped or delivered as something it
* is not: a deny's words are `reason`, and a machine's text must never reach the model as the user's. The twin is the captured
* plain data (its text already held to the string domain by the capture), never the caller's object.
*/
export declare function refuseUnfitFeedback(twin: PolicyAsk): void;
/** The words this resume is to deliver: a person's `allow` carrying a written feedback (the pre-CAS checks have run), else `undefined`. */
export declare function approvalWordsOf(outcome: ResumeOutcome): string | undefined;
/**
* The continuation with the words as its last range. The separator glue before them is engine bytes (its own segment), so the
* stored message's user-lane range is exactly the words. Appends to `engineSegments` in place; the caller owns both.
*/
export declare function withApprovalWords(continuation: string, engineSegments: Array<{
start: number;
end: number;
}>, words: string): string;
/**
* The live leg's carrier ({@link ApprovalWordsSeat}): the words queue on the harness's steer lane as a plain user message — verbatim,
* no fence, no wrapper sentence, no provenance mark, so a derived view reads them as the person's speech, exactly as the resume
* continuation's user-lane range is read. The lane drains at the turn boundary after the batch's tool results, which is where a
* durable leg's continuation also lands. A queue that refuses them (the run is no longer taking input) is reported through `report`,
* never thrown into the gate; words still queued when the run ends are the steer lane's own undrained account.
*/
export declare function approvalWordsSeat(harness: Pick<AgentHarness, "steer">, report: (error: Error) => void): ApprovalWordsSeat;
/**
* The words as the continuation's owed content: the last parked steer, an untrusted one (the carrier that exists for an owed instruction).
* The frame is remembered by identity ({@link isApprovalWordsFrame}) — never by a member, which the steer store would refuse as an unknown
* key — so the owed account can count it as what it is (`detail.kind: "approval_feedback"`) and tell a recoverable retry from a loss.
*/
export declare function owedApprovalWords(words: string | undefined, inputId: string): Array<Omit<PendingSteerEntry, "seq">>;
/** Whether `frame` is one {@link owedApprovalWords} minted. */
export declare function isApprovalWordsFrame(frame: object): boolean;
export {};