UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

31 lines (30 loc) • 2.05 kB
/** * What a leg's classic stations did on its bus: per event, how many times the station raised it (a raise is a dispatch the * station started because a handler hangs on the event) and how many chain handlers those raises skipped on a failure (the * `skipped` of the dispatch outcomes; an `observe` handler's failure is reported to `onError` only and is not among them). * Kept per bus object (one bus per leg); a station records one raise per raise of its event, however many seat passes the * raise takes. */ import type { ModDispatchOutcome } from "./kernel/index.js"; import type { ClassicEventName } from "./classic-events.js"; import type { DelegationLifecycleEvent } from "../delegation-frames.js"; import { parentLegIds } from "../engine-notice.js"; /** One station's count on one leg. */ export interface StationCount { /** Times the station raised its event on the leg. */ readonly raised: number; /** Chain handlers those raises skipped on a failure (threw, past its budget, an answer the station cannot take, re-entry). */ readonly handlerFailures: number; } /** Record one raise of `event` on `bus` from the outcomes of its passes (`undefined` = a pass with no handler, not dispatched). * A raise none of whose passes was dispatched is no raise. */ export declare function recordStationRaise(bus: object, event: ClassicEventName, outcomes: readonly (ModDispatchOutcome | undefined)[]): void; /** The count of `event` on `bus`. */ export declare function stationCountOf(bus: object, event: ClassicEventName): StationCount; type TerminalFrame = Extract<DelegationLifecycleEvent, { phase: "terminal"; }>; /** The two members a delegated leg's terminal frame reads off the leg itself, at the moment it is sent: its two lifecycle * stations' counts on its bus, and the run that spawned it — `parentLegIds`, the one reading of a leg's parent. */ export declare function delegationTerminalReceipt(bus: object, internals: Parameters<typeof parentLegIds>[0]): Pick<TerminalFrame, "stations" | "origin">; export {};