UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

35 lines (34 loc) • 2.56 kB
/** * Admission bookkeeping for HUMAN INPUTS accepted mid-run: the per-leg ordinal an accepted input is stamped * with, and the acceptance frame's once-only seat. Two accepting arms share the ordinal — the stream's `steer` * verb and the run body — which is why it is keyed on the leg's harness in a module-level WeakMap rather than * held by either arm: one counter per leg, one ascending sequence across both. Also the stream verbs' typed * refusal. (Whether a repeat under a used `inputId` is the same instruction is steer-replay.ts's one judgement, * shared with the parked queue.) * * Run-loop machinery (layer 1), not a driven lane: nothing here takes an Input or hands back a Result, and * nothing here reads host state. Named without the `run-` family prefix for that reason. */ import type { SteerReplayRefusalDetail } from "../steer-replay.js"; import type { HumanInputEvent } from "../task-event.js"; export declare function nextHumanInputSeq(key: object): number; /** The identity keys a published `queued` frame carried beyond its own `eventId` (`parentToolCallId`, `sourceTaskId`): one fact, stated once * by the frame's publisher and handed to whoever mints that input's other frames, so its two frames are never stamped by two computations. */ export type AcceptanceIdentity = { parentToolCallId?: string; sourceTaskId?: string; }; /** Who wrote the input, as its `queued` frame said it (`author` absent ⇒ the operator; `extension` beside an extension's), repeated by its `applied` frame. */ export type AcceptanceAttribution = Pick<HumanInputEvent, "author" | "extension">; /** What the accepting verb states once for the input's frames: the `queued` frame's identity and attribution, and who rewrote the text at * the verb's screen (`rewrittenBy`, absent ⇒ nobody) — named only by the frame that delivers the input, as at every other entrance. */ export interface Acceptance { readonly identity: AcceptanceIdentity; readonly attribution: AcceptanceAttribution; readonly rewrittenBy?: readonly string[]; } export declare function armAcceptance(record: object, publish: () => Acceptance): void; export declare function announceAcceptance(record: object): Acceptance | undefined; /** The stream verbs' typed refusal: `cannot steer: <msg>`, `code` (`steering.not_running` by default), and the * refusal's `detail` when the code carries one (`steering.duplicate_input_id` always does). */ export declare function steeringError(msg: string, code?: string, detail?: SteerReplayRefusalDetail): Error;