UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

40 lines (39 loc) • 3.61 kB
/** * `notExecuted` and `gate` — what the engine writes onto a persisted `toolResult` row for a call it has positive evidence never ran, in ONE place. * * The fact has one reading ({@link refusedBeforeRelease}, over the call's occurrence) and one return (`emitSettled`'s, beside the * `tool_end` frame); every face that repeats it reads that return: the frame, the resumed leg's `toolResult` rows * ({@link withRowNotExecuted}) and the live leg's ({@link stampRowNotExecuted}). `details.notExecuted` and `details.gate` on a * persisted row are the ENGINE's keys: set from the settlement (`gate` as a structural copy of the end frame's verdict when * `notExecuted` holds and the frame carried one) and dropped from whatever a tool wrote under either name ({@link rowDetailsOf}). * * A leaf: it reads the occurrence's type, the gate-outcome type and the guarded member readers, and writes nothing but the one result it is handed. */ import type { GateOutcome } from "../gate-outcome.js"; import type { ToolOccurrence } from "./tool-occurrence.js"; /** The end projection's row-facing settlement facts (`SettledOccurrence`'s `notExecuted` and `gate`). */ export interface RowEndFacts { readonly notExecuted?: true; readonly gate?: GateOutcome; } /** The engine's own judgment refused this call and it was never let go to an executor: the latest gate record is a * refusal and the life never left `announced` — positive evidence the call did not run (a refusal recorded AFTER the * release, by a station inside the execution, is not). A call whose start this stream never carried (a recovered * one, closed by a station that knows only its own class) is not read here. */ export declare function refusedBeforeRelease(occ: Pick<ToolOccurrence, "life" | "gateRounds" | "startEmitted">): boolean; /** The one reading of the engine's positive evidence that a call never ran: refused before it was let go * ({@link refusedBeforeRelease}), or answered in place of its body by an extension at `tool.call` (the body was never called). */ export declare function neverExecuted(occ: Pick<ToolOccurrence, "life" | "gateRounds" | "startEmitted" | "answeredInPlaceBy">): boolean; /** `details` as a persisted `toolResult` row carries it: `notExecuted` and `gate` are the ENGINE's keys — * `notExecuted: true` when the settlement's fact holds, `gate` a structural copy of the end frame's verdict * when both `notExecuted` and `gate` hold, and both absent otherwise, whatever a tool wrote under either name. * Returns `details` itself unless a key has to move; never mutates it. */ export declare function rowDetailsOf(details: unknown, settled: RowEndFacts | undefined): unknown; /** The persisted row's mark: the call this `toolResult` row closes never ran (the key {@link rowDetailsOf} writes). */ export declare function rowNotExecuted(details: unknown): boolean; /** A row the resumed leg mints (`toolResultMsg`) with the settlement's facts (`notExecuted`, `gate`) on it. */ export declare function withRowNotExecuted<T extends object>(row: T, settled: RowEndFacts | undefined): T; /** Write the end projection's `notExecuted` and `gate` onto the result the live loop persists as the call's row: the loop builds that message * from this very result right after the end event. The frame's card was projected from the previous `details` first and keeps its * members (row marks are never part of a card). `Reflect.set`: a result that refuses the write keeps its row as it was. */ export declare function stampRowNotExecuted(result: unknown, settled: RowEndFacts | undefined): void;