UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

54 lines (53 loc) • 3.97 kB
/** * Halt attribution, the consumer half: the ONE predicate that turns the harness's * consumption statement ({@link HaltConsumption}) into the result's `haltedByUser` / `turnAbortedBy` seats, and the * disclosure for an ending request (the halt's, an extension's cut) that was accepted but never consumed. Both readers of * the statement live here so the law has one spelling: signed ⇔ consumed; unconsumed ⇔ absent + `task.halt_unconsumed`. */ import type { HaltConsumption } from "../../internal/harness.js"; import { type RunnerDeps } from "../types.js"; /** * The attribution law: `haltedByUser` ⇔ the halt was CONSUMED by the machinery — its cut settled a turn (the * loop's report, stamped `"halt"` at the seat's abort) OR its stop request was among the sources a boundary * consult stopped the loop for. A halt merely ACCEPTED (latched, receipt answered) while the run ended for its * own reason is not consumed and never signs (fail-closed: rather absent than guessed). */ export declare function haltConsumed(c: HaltConsumption | undefined): boolean; /** * The run's last turn settled as a cut that ENDS a turn by request — the halt's, or an extension's `$.turn.abort` * (the loop's report, stamped at the seat's abort). A steer-now cut never qualifies: that run went on with the steer, and * a later turn's opening clears the statement anyway. The result reads its `final` as that cut's artifact, not an abort. */ export declare function endingCutConsumed(c: HaltConsumption | undefined): boolean; /** The registration whose `$.turn.abort` ended the run's last turn (`TaskResult.turnAbortedBy`) — present only when that * cut was consumed, the same law as `haltedByUser`: signed ⇔ consumed. */ export declare function turnAbortedByOf(c: HaltConsumption | undefined): string | undefined; export interface UnconsumedEndingDisclosureInput { /** The verb's acceptance fact (`loopLatch.userHalted`): a halt was latched on this run. */ accepted: boolean; /** The harness's statement, read after the prompt settled. */ consumption: HaltConsumption | undefined; onNotice: RunnerDeps["onNotice"]; sessionId: string; runId: string; /** The leg's own task id (`Prepared.taskId`) — always present. */ taskId: string; } /** * The ACCEPTED-but-UNCONSUMED ending request — one law for the two sources that ask to END a turn (the ones * {@link endingCutConsumed} reads): a request the run accepted whose ending the machinery never took up gets one * `task.halt_unconsumed` notice, `detail.source` naming whose request it was, and the result's seat for that source stays * absent. What consumes each: * · the halt (`source: "halt"`) — its cut settled a turn OR a boundary consult stopped the loop for it * ({@link haltConsumed}). Accepted (the verb latched the stop, and may have cut a seat) and neither: the run ended for * its own reason (a brain minting its own `aborted` final, a natural completion past the final commit point, an * approval park whose commit won the race). One per such run. The verb mints the same code on its own arm (a halt * refused by an already-owned ending), one fact with one spelling, the two mint points disjoint: the verb arm mints * only while NO halt has been accepted on the run; once one was, this arm alone speaks. * · an extension's `$.turn.abort` (`source: "extension"`, with `extension` and `turn`) — a settlement took ITS cut as its * turn's cause. Each accepted cut that none did gets one: the turn had already settled as its own outcome (the * request's end was delivered before the cut, so the turn ended as an answer), or the run's own ending won. * A steer-now's cut asks to redirect, not to end — its steer rides the next boundary either way — and has no arm here. * Returns whether anything was minted. */ export declare function discloseUnconsumedEndings(input: UnconsumedEndingDisclosureInput): boolean;