UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

65 lines (64 loc) • 3.87 kB
/** * The run body's GIT LANE (R12), verbatim from `Runner.runLocked`: the git-status re-assert closure * installed on `prepared.gitStatusRef` (compaction landing hook + owed-frame retry — an engine-minted standalone * append with the receipt in hand, the announced mirror written only then), the parked mirror flush (F4), the * owed-frame retry subscription registered BEFORE the boundary handler, the boundary subscription itself and the * harness event subscription that dispatches to the five handler closures. The three subscriptions are taken in the * order the driver took them, and the four closures come back for the driver to await and release where it did. */ import type { AgentHarnessEvent } from "../../internal/harness.js"; import type { Model } from "../../internal/llm.js"; import type { PushQueue } from "../push-queue.js"; import type { TaskEvent } from "../types.js"; import type { Prepared, RunnerDepsSeat, RunState } from "./contracts.js"; export interface RunGitLaneInput { /** borrowed-mutable — the leg's prepared seat: `gitStatusRef.reassert` is installed here and the ref's announced / * mirror / protection slots are written by the closures; the harness is subscribed to, the session appended to. */ prepared: Prepared; /** borrowed-mutable — the run's event queue: the re-assert pushes its `steering_injected` echo frame. */ queue: PushQueue<TaskEvent>; /** borrowed-mutable — the run's mutable state: the re-assert counts itself on `attach.attachmentsInjected`. */ rs: RunState; /** borrowed-readonly — the run's event-identity mint (stamped on the echo frame). */ ident: () => { eventId: string; parentToolCallId?: string; sourceTaskId?: string; }; /** borrowed-readonly — the harness-handlers lane's message_update closure, dispatched to by identity. */ onMessageUpdate: (event: Extract<AgentHarnessEvent, { type: "message_update"; }>) => void; /** borrowed-readonly — the harness-handlers lane's message_end closure. */ onMessageEnd: (event: Extract<AgentHarnessEvent, { type: "message_end"; }>) => void; /** borrowed-readonly — the harness-handlers lane's tool_execution_start closure. */ onToolStart: (event: Extract<AgentHarnessEvent, { type: "tool_execution_start"; }>) => void; /** borrowed-readonly — the harness-handlers lane's tool_execution_end closure. */ onToolEnd: (event: Extract<AgentHarnessEvent, { type: "tool_execution_end"; }>) => void; /** borrowed-readonly — the harness-handlers lane's turn_end closure. */ onTurnEnd: () => void; /** borrowed-readonly — the turn-boundary lane's handler, registered on `turn_boundary` AFTER the owed-frame retry * so a pending announcement is re-asserted into the session ahead of the boundary's own context work. */ onTurnBoundary: (event: { model: Model; }) => Promise<undefined>; /** borrowed-readonly — the Runner's deployment deps, read LIVE inside the closures (`onError`). */ runner: RunnerDepsSeat; } export interface RunGitLaneResult { /** The parked-mirror flush — awaited at the serialization points: the `turn_boundary` subscription here is the regular station (the final boundary of a gracefully ending run included); the leg's post-prompt call is the fallback for a terminal that skipped it. */ flushGitMirror: () => Promise<void>; /** The owed-frame retry's `turn_boundary` subscription; the driver's teardown releases it first. */ unsubGitRetry: () => void; /** The boundary handler's `turn_boundary` subscription; released second. */ unsubBoundary: () => void; /** The harness event subscription; released third. */ unsub: () => void; } export declare function runGitLane(input: RunGitLaneInput): RunGitLaneResult;