UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

42 lines (41 loc) • 2.7 kB
import type { Model } from "../../internal/llm.js"; import { type MaybeCompactOptions } from "../auto-compaction.js"; import type { PushQueue } from "../push-queue.js"; import type { Brain, TaskEvent, TaskSpec } from "../types.js"; import type { InstallingPhaseResult, Prepared, RunnerDepsSeat, RunState } from "./contracts.js"; export interface RunRecoveryLanesInput { /** borrowed-readonly — the task spec: the compaction settings / instructions and the key-and-headers seat. */ spec: TaskSpec; /** borrowed-mutable — the leg's prepared seat: the loop recovery chain is installed on its harness, the arm-B seat * on `microCompact.inTurnCompactionRef`, the MC-R clears on `microCompact.ledger`; the abort signal, the pause * holder, the session, the compaction model and the cache-break detector are read. */ prepared: Prepared; /** borrowed-mutable — the run's event queue: the `compacted` and `compaction_outcome` frames of both arms. */ queue: PushQueue<TaskEvent>; /** borrowed-mutable — the run's mutable state: the anti-thrash floor (`counters.compactionFloor`) is raised and * consulted, the post-compact announce latch armed and the cadence windows rebased on `attach.attachState`. */ rs: RunState; /** borrowed-readonly — the run's event-identity mint. */ ident: () => { eventId: string; parentToolCallId?: string; sourceTaskId?: string; }; /** borrowed-readonly — the ACCOUNTED compaction brain (the compaction-machinery lane's), handed to every pass. */ compactionBrain: Brain; /** borrowed-mutable — the shared consecutive-failure breaker: read by the gates, zeroed on a landing (and on a * noop), bumped on a burned pass. */ compactionBreaker: { failures: number; }; /** borrowed-readonly — the window-safety option builder (the compaction-machinery lane's), per pass. */ windowSafetyOptions: (mainModel: Model) => Pick<MaybeCompactOptions, "fallbackBudget" | "onWindowSafety">; /** borrowed-readonly — the Runner's deployment deps, read LIVE (`onError`; the compaction seams the pass reaches down * for — compaction-seams.ts — read the summary provider and the hooks slot through it on every pass). */ runner: RunnerDepsSeat; } /** Nothing comes back: the lane's products are INSTALLED on the seats it borrowed — the harness's loop recovery * chain and the microCompact arm-B seat — and the shared pass is read by those two installations alone. */ export interface RunRecoveryLanesResult extends InstallingPhaseResult { } export declare function runRecoveryLanes(input: RunRecoveryLanesInput): RunRecoveryLanesResult;