@sema-agent/core
Version:
Stateless, task-oriented AI agent core
82 lines (81 loc) • 6.83 kB
TypeScript
/**
* The words a person reads on an approval card that the engine owns: the headline — the line read first: why they are being
* asked, and whether a saved allow rule could ever stop the question — and the reference implementation's outside-the-sandbox
* sentence, which also opens the card's `message`. Both are read off the ask's class word ({@link AskClass}) and, for the
* sentence, its class set, so each face — the live card, the parked row, the inbox listing (which echoes the row) — says the
* words of the class pair it carries; the card's `message` stays the detailed account beside the headline.
*
* The headline is two halves, one row each, joined by the catalog's joiner in the run's locale:
* · WHY — one catalog row per class ({@link ASK_HEADLINE_WHY}, fenced to the class set); a call that leaves the run's sandbox by
* its own escape (`sandbox_override` in the set) under another class's word says so first ({@link saysOutside});
* · REMEDY — whether saving an allow rule would stop it being asked again: the ONE answer, {@link standingRuleClearance} over the
* ask's class SET — the allow layer's own reading of the call, not a class word's row, and said by no reason sentence (a class
* whose question is cleared elsewhere has its own row instead, {@link OWN_REMEDY}).
*
* Display words, never an input: no gate, settlement, CAS or resume path reads them, and a reader branches on the class
* words. The headline is ABSENT when the ask carries no class word (a request a host built itself, the shared-artifact read
* confirmation, a row an earlier engine parked) or a class with nothing to say beyond the card's own header
* ({@link NO_HEADLINE_CLASSES}) — the engine gave no headline, the reader shows `message`. No row only repeats the card.
*/
import { type AskClass, type AssertAllKeysHandled } from "./ask-origin.js";
import { type EngineText } from "../prompt-assembly/engine-text.js";
import type { AskRequest } from "./tool-policy.js";
/** The classes whose card has nothing to say first beyond its own header, so they carry no headline (the reader shows
* `message`) rather than a line that only repeats the card: the agent's own question is the question itself. Module-private:
* a reader learns it from the member's absence, not from a list. */
declare const NO_HEADLINE_CLASSES: readonly ["content_question"];
type NoHeadlineClass = (typeof NO_HEADLINE_CLASSES)[number];
/** The WHY row of each class that has one: `core/engine.ask-headline.<class>`. */
export declare const ASK_HEADLINE_WHY: Readonly<{
readonly mode: "core/engine.ask-headline.mode";
readonly hook: "core/engine.ask-headline.hook";
readonly org_rule: "core/engine.ask-headline.org_rule";
readonly ancestor: "core/engine.ask-headline.ancestor";
readonly write_protection: "core/engine.ask-headline.write_protection";
readonly target_unresolved: "core/engine.ask-headline.target_unresolved";
readonly ask_rule: "core/engine.ask-headline.ask_rule";
readonly denial_limit_fallback: "core/engine.ask-headline.denial_limit_fallback";
readonly dangerous_delete: "core/engine.ask-headline.dangerous_delete";
readonly transcript_write: "core/engine.ask-headline.transcript_write";
readonly org_unreadable: "core/engine.ask-headline.org_unreadable";
readonly rule_unreadable: "core/engine.ask-headline.rule_unreadable";
readonly call_unreadable: "core/engine.ask-headline.call_unreadable";
readonly classifier_no_ruling: "core/engine.ask-headline.classifier_no_ruling";
readonly requires_user_interaction: "core/engine.ask-headline.requires_user_interaction";
readonly cross_boundary: "core/engine.ask-headline.cross_boundary";
readonly operator_forced: "core/engine.ask-headline.operator_forced";
readonly shell_floor: "core/engine.ask-headline.shell_floor";
readonly probe: "core/engine.ask-headline.probe";
readonly write_protection_on_disk: "core/engine.ask-headline.write_protection_on_disk";
readonly tool_marks_mcp: "core/engine.ask-headline.tool_marks_mcp";
readonly tool_marks_a2a: "core/engine.ask-headline.tool_marks_a2a";
readonly unfinished_check: "core/engine.ask-headline.unfinished_check";
readonly policy_rra: "core/engine.ask-headline.policy_rra";
readonly artifact_shared_read: "core/engine.ask-headline.artifact_shared_read";
readonly a2a_inside: "core/engine.ask-headline.a2a_inside";
readonly unverifiable_delete: "core/engine.ask-headline.unverifiable_delete";
readonly unverifiable_shell_text: "core/engine.ask-headline.unverifiable_shell_text";
readonly sandbox_override: "core/engine.ask-headline.sandbox_override";
readonly sandbox_network: "core/engine.ask-headline.sandbox_network";
readonly unstated: "core/engine.ask-headline.unstated";
readonly ordinary: "core/engine.ask-headline.ordinary";
}>;
/** The fence over the WHY rows: `never` while every class has a row or is named in {@link NO_HEADLINE_CLASSES}. */
export type HeadlineTableCoversEveryClass = AssertAllKeysHandled<Exclude<AskClass, keyof typeof ASK_HEADLINE_WHY | NoHeadlineClass>>;
/** The headline of an ask whose class word is `askClass` and class set `classes` (absent ⇒ the word alone), in `say`'s locale
* (absent ⇒ the canonical text); `undefined` when `askClass` is not a word of the class set or is one of {@link NO_HEADLINE_CLASSES}. */
export declare function askHeadlineOf(askClass: unknown, say?: EngineText, classes?: unknown): string | undefined;
/** The member as a request, a parked row and a listing carry it: present exactly when the class word mints one. */
export declare function askHeadlineMember(askClass: unknown, say?: EngineText, classes?: unknown): {
headline?: string;
};
/** The card's question as a person reads it: the station's `message`, opened with the outside sentence where the class pair says
* so ({@link saysOutside}) — in the canonical text, the language every `message` is written in (the headline beside it speaks the
* run's locale). The live card and the parked row read it, and a person's no quotes it in its refusal; the `dontAsk` refusal and
* the classifier read the station's message without it (the reference puts it on the question handed to the person). */
export declare function askCardMessageOf(message: string, askClass: unknown, classes: unknown): string;
/** The request with the engine's card words for its class pair — {@link AskRequest.headline} (a value the caller put there is not
* kept) and the outside sentence opening {@link AskRequest.message} — what the resolver's chokepoint hands on; the same object
* when there is nothing to mint and nothing to drop. */
export declare function withEngineCardWords(req: AskRequest, say: EngineText | undefined): AskRequest;
export {};