UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

47 lines (46 loc) • 4.44 kB
/** The three inputs (see the module note). A CLOSED SET with one home, registered in `docs/CLOSED-SETS.md`. */ export declare const CONFIG_REFUSAL_INPUTS: readonly ["taskConfig", "deps", "inheritedGate"]; export type ConfigRefusalInput = (typeof CONFIG_REFUSAL_INPUTS)[number]; export declare const isConfigRefusalInput: (word: unknown) => word is ConfigRefusalInput; /** Is `code` a word of the configuration refusal family (`CONFIG_REFUSAL_CODES`)? The one test of the word's domain: an entrance records only * such a refusal, a terminal of such a code is the one whose `coded` account reserves `input` (a thrower's own member of that name is not * carried there, and is carried as it was on every other code), and the reader answers `input` only on such a terminal. */ export declare const isConfigRefusalCode: (code: unknown) => boolean; /** Record `input` for a refusal the engine has just minted (a door that decides its word where it decides the refusal). */ export declare function stampConfigInput(refusal: unknown, input: ConfigRefusalInput): void; /** {@link stampConfigInput} at a throw: the refusal, recorded as about `input`, handed back to be thrown (`throw refusalAbout(input, e)`). */ export declare function refusalAbout<E>(input: ConfigRefusalInput, refusal: E): E; /** * Enter a configuration door with the word of the input that carries the value it judges: `door` runs as it stands (its value returned, * its throw rethrown unchanged), and a refusal of the configuration family (its own `code` a word of `CONFIG_REFUSAL_CODES`) that * leaves it is recorded under `input` — unless a nearer entrance inside this one, or the door itself, recorded it already. A record * taken before this entrance (an error object a host keeps and throws again, a refusal another entrance recorded) is replaced: the * entrance it leaves now is the one that knows where it came from. A door that answers a promise has its rejection recorded the same * way; a door that answers anything else is not awaited and nothing is read of its value. */ export declare function enterConfigDoor<T>(input: ConfigRefusalInput, door: () => T): T; /** The input the engine recorded for this thrown value, or `undefined` (not a refusal of a door entered with a word, or not this * engine's object: a copy, a wrapper, a value from elsewhere). Reads nothing of the value itself. */ export declare function configInputOfRefusal(refusal: unknown): ConfigRefusalInput | undefined; /** * The input a refusal is about, for a host's one `switch` (see the module note) — total over what it is handed: * - an error object (a refusal a stream entry threw at the call, the `checkpoint.config_refused` a resume rejects with, a resume's * pre-claim refusal of a row record): the engine's own record of it; a copy (`structuredClone`, another * realm's), a wrapper or an object the engine did not record answers `undefined`, never a word read off the object's own members; * - a terminal: on a `failed` `checkpoint.config_refused` (a resume refused before its claim), its `coded` account's `field`; on any * other `failed` terminal, its `coded` account's `input` (present on the `config.*` / `resume_at.*` refusals of a leg's prepare); * - anything else — another terminal kind, a failure of another family, a refusal met while the run runs — `undefined`. */ export declare function configRefusalInputOf(failure: unknown): ConfigRefusalInput | undefined; /** {@link resolveSeatValue}'s inputs for a trusted live seat read over what a resumed row recorded (`internals.x ?? seed.x`). */ export declare const LIVE_OVER_ROW: readonly ["deps", "inheritedGate"]; /** * A seat that takes one input's value over another's (`first ?? second` — by default the task's over the deployment's), resolved ONCE * with the input its value came from: the first's when it holds a value (`undefined` and `null` are none — the `??` reads past both), * else the second's — read only then (`second` is the read, as the `??` would make it). The value a door judges and the word its * refusal carries are this one reading. `inputs` names the two inputs when they are not the task and the deployment ({@link LIVE_OVER_ROW}). */ export declare function resolveSeatValue<T, D>(first: T, second: () => D, inputs?: readonly [ConfigRefusalInput, ConfigRefusalInput]): { readonly value: NonNullable<T> | D; readonly input: ConfigRefusalInput; };