UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

58 lines (57 loc) • 4.27 kB
import type { ShellReadVerdict } from "../tools/fs/shell-read-check.js"; import { type ShellReadDisposition } from "../tools/fs/shell-read-judge.js"; import type { GatePass } from "./runner/gate-exit.js"; import type { AskGuard } from "./tool-policy.js"; /** One station answer, received and read: what a reader acts on (`kind`) and the answer it acts on (`verdict` — the engine's own * copy, received once). `unbelieved`: the station's answer was not received or contradicted its own finding, and `verdict` is the * engine's refusal of it (its sentence names the station's words only where they are words of the closed sets — nothing a station * spelled reaches the model), reported once on the call's lane ({@link StationAnswerCall.report}). */ export interface StationAnswerReading { readonly kind: ShellReadDisposition | "silence"; readonly verdict: ShellReadVerdict; readonly unbelieved?: true; } /** The call a reader reads an answer for: its name (the refusal names it), its id, and the lane a station's failure is reported on * (absent ⇒ unreported — the resumed leg reads the engine's own stations). */ export interface StationAnswerCall { readonly toolName: string; readonly toolCallId?: string; readonly report?: (err: Error) => void; } /** * Receive and read a station's answer — the ONE reading for every reader. The answer is received whole ({@link receivedAnswer}: * the engine's one receipt for a caller's object, then each member by its kind — none of the caller's code runs) into the engine's * copy every later read is of; an answer that is not received (an accessor, a member its prototype or a non-enumerable property * supplies, a Proxy anywhere in it, a word that is no string, a mark that is not `true`, not an object) is not believed. Then, in order: * · `refuse` stands, whatever beside it: no reading is stricter; * · the station's SILENCE — the finding `unanswered`, or nothing found (`none`) beside a silence mark (`environmentSilent`, * `rowsUnread`): the station made no finding, whatever disposition it spelled beside it (the engine's own station spells a * vouch beside unread rows as `unanswered`); * · a disposition the decision table does not give the finding on any seat, under any form of the question * ({@link dispositionsOfRow}) — a `vouch` beside a deny hit, an ask beside one, a word outside the closed sets — is NOT believed: * the station's answer contradicts its own finding, and the reader refuses the call; * · otherwise the disposition, as the table gives it. * A silence mark beside a finding the station DID make is not the silence: it classes that finding's question * ({@link silencedBy}). */ export declare function readStationAnswer(answer: ShellReadVerdict, call: StationAnswerCall): StationAnswerReading; /** Whose silence a station's answer carries, each its own class on the question it keeps or mints: unread rows are a rule that could * not be read (the rule lane's class); the finding `unanswered` is, unless rows are unread, the environment's silence — shell text the * engine cannot read (a guard) — and the marks only pick whose. Either is a question only a person answers; `probe` follows the finding. */ export declare function silencedBy(verdict: ShellReadVerdict, d: { readonly guards?: readonly AskGuard[]; readonly ruleUnreadable?: unknown; }): { ruleUnreadable?: "persisted_rows"; guards?: readonly AskGuard[]; requiresRealApproval?: true; }; /** The station's SILENCE ({@link readStationAnswer}), applied once, before any disposition arm: a station — a host-mounted one * included — may spell `vouch`, `mandated` or `ordinary` beside it, and no word vouches for what nobody judged. A deny stands; an * ask keeps its words and gains the silence's class; an allow becomes the silence's question (`ask.message`), one only a person * answers. Nothing is admitted, no `probe` is stamped and no grant is offered — the station made no finding. */ export declare function applyUnansweredSilence(pass: GatePass, verdict: ShellReadVerdict, ask: { readonly message: string; readonly account: string | undefined; readonly tightenedBy: "shell_gate" | "safety"; }): void;