UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

27 lines (26 loc) • 1.87 kB
/** * Admission bookkeeping for HUMAN INPUTS accepted mid-run: the per-leg ordinal an * accepted input is stamped with, and the field-for-field "is this repeat the same instruction" test the * live steer verb applies under an already-used `inputId`. Two accepting arms share both — the stream's * `steer` verb and the run body — which is why the ordinal 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. * * 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 { AcceptedSteerInput } from "./contracts.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 two frames of one input are never stamped * by two computations. */ export type AcceptanceIdentity = { parentToolCallId?: string; sourceTaskId?: string; }; export declare function armAcceptance(record: object, publish: () => AcceptanceIdentity): void; export declare function announceAcceptance(record: object): AcceptanceIdentity | undefined; /** Is a repeat under an already-accepted `inputId` the SAME * instruction (an idempotent retry) or a different one wearing a used key? Compared field for field, * exactly like the parked leg's replay check: the key alone is never evidence of a replay, and two * callers colliding on one id must not silently lose the second instruction. */ export declare function sameAcceptedSteerInput(a: AcceptedSteerInput, b: AcceptedSteerInput): boolean;