UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

65 lines (64 loc) • 4.09 kB
/** * Is a repeat under an already-used steer `inputId` the same instruction? ONE answer for both seats that hold a * steer under its key — the parked queue (`appendPendingSteer`) and the live verb's accepted-input domain — and that * one answer feeds the replay decision, the refusal's machine-readable `detail.differs` and its sentence. * * Both seats compare the record the CALLER sent (text, trusted, tier, actor, run origin, source) — never the delivered bytes: the live * delivery folds `trusted` (the framing) and the actor (the speaker label) into its payload, so comparing payloads * would report one changed facet as two. */ import type { ActorAssertion } from "../internal/llm.js"; import { type SystemInjectionPriority } from "./task-notification.js"; import type { RunOrigin } from "./run-origin.js"; import type { HumanInputSource } from "./task-event.js"; /** The facets a steer's replay identity is made of, in the order a refusal lists them. Closed. */ export declare const STEER_REPLAY_FACETS: readonly ["text", "trusted", "priority", "actor", "runOrigin", "source"]; export type SteerReplayFacet = (typeof STEER_REPLAY_FACETS)[number]; /** Who a steer's sender says wrote it: `"steer"` — a person's words — or `"system"` — text its sender produced itself (a * shell's own plan outcome, a wake notice), which no face reads as a person's speech. Two of {@link HumanInputSource}'s own * words; the steer verb's option ({@link import("./task-stream.js").TaskStream.steer}, `steer.source`) is this domain. */ export type SteerSource = Extract<HumanInputSource, "steer" | "system">; /** The ONE reading of a steer's source: absent reads as `"steer"` (the default every caller had before the option). */ export declare function steerSourceOf(x: { readonly source?: SteerSource; }): SteerSource; /** The source an input reports on every face that names one — its delivered frame, its `human_input` frame, its screen's * `e.source`: `"system"` when its sender said so, else the name of the carrier or entrance it arrived on. */ export declare function inputSourceOf<C extends string>(x: { readonly source?: SteerSource; }, carrier: C): C | "system"; /** What a seat remembers a steer by: the caller's own statement, as validated. The parked entry and the live park * record both are this shape. An absent `priority` reads as `"next"` ({@link steerPriorityOf}), an absent `source` as * `"steer"` ({@link steerSourceOf}). */ export interface SteerReplayRecord { readonly text: string; readonly trusted: boolean; readonly priority?: SystemInjectionPriority; readonly actor?: ActorAssertion; readonly runOrigin?: RunOrigin; readonly source?: SteerSource; } /** The facets `repeat` differs from `held` in, in {@link STEER_REPLAY_FACETS} order. Empty = the idempotent replay. */ export declare function steerReplayDiffers(held: SteerReplayRecord, repeat: SteerReplayRecord): SteerReplayFacet[]; /** `steering.duplicate_input_id`'s machine-readable half: the facets, by name only (never the values). Always * present on that code, never empty. */ export interface SteerReplayRefusalDetail { readonly differs: readonly SteerReplayFacet[]; } /** Which seat refuses: the parked queue names the key it holds; the live verb answers about the caller's own key. */ export type SteerReplaySeat = { readonly seat: "parked"; readonly inputId: string; } | { readonly seat: "accepted"; }; /** * The refusal for a repeat that is not a replay, or `undefined` for one that is. When `text` differs the repeat is * another instruction and the caller is told to take a fresh key. When only the tier / trust / attribution differ it * is the SAME instruction, already accepted, whose standing receipt those facets do not change — a fresh key would * queue it a second time, so the sentence says so instead of advising one. */ export declare function steerReplayRefusal(held: SteerReplayRecord, repeat: SteerReplayRecord, where: SteerReplaySeat): { message: string; detail: SteerReplayRefusalDetail; } | undefined;