UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

35 lines (34 loc) • 1.98 kB
import type { Model } from "../../internal/llm.js"; import type { Stats } from "./assemble-result.js"; import type { Prepared, RunState, TurnBoundaryDeps } from "./contracts.js"; /** * What the driver hands the turn-boundary lane, once per leg. The four seats are the four positional * parameters the factory used to take; the Input is a carrier of REFERENCES, not a snapshot — the handler * reads `prepared` / `rs` / `stats` / `deps` live on every boundary, exactly as the closure did. */ export interface RunTurnBoundaryInput { /** borrowed-mutable — the leg's prepared seat. Read throughout; written only into its per-run ref cells * (`reviewRequestRef.pending`, `announcedListingsRef.*`, `trimPressureRef.droppedMessages`), the * same cells the closure wrote inside the driver. */ prepared: Prepared; /** borrowed-readonly — the run's usage counters; the boundary reads them (the governance commit, the * budget pass, the degrade record) and never writes them. The harness-handlers lane is their writer. */ stats: Stats; /** borrowed-mutable — the run's mutable state (counters, attach, turn, limits, budget, compaction, * telemetry); the boundary is one of its writers, per the writer table on the type. */ rs: RunState; /** borrowed-readonly — the driver-declared const seats + the hook seat over the runner's methods * (see {@link TurnBoundaryDeps}). `loopLatch.userHalted` is read LIVE on every boundary. */ deps: TurnBoundaryDeps; } /** * The handler the driver registers on the harness's `turn_boundary` hook. It resolves to `undefined` * explicitly — the hook's result type is `undefined` (a pure timing signal) and `on()` requires the * handler's Promise to match it exactly. */ export interface RunTurnBoundaryResult { (event: { model: Model; }): Promise<undefined>; } export declare function createTurnBoundary(input: RunTurnBoundaryInput): RunTurnBoundaryResult;