UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

39 lines (38 loc) • 2.54 kB
/** * The TaskStream façade's HALT verbs (T7), verbatim from `Runner.runTaskStream`: `halt` (the bare * user interrupt — the finished-task refusal, the fresh liveness test on the resolved handle, `apply` with its * pre-abort ownership snapshot, the conjunctive attribution seat, the unconsumed-halt and turn-cut notices, and * the birth-window poll; never on the steer FIFO chain) and `destroy` (the once-memoized reap: abort, await the * run's settle bounded, then the reap lane's step). Two Runner reads, both the deployment's notice sink. * * Both closures are the ones the one-file façade returned, installed by the driver under their old names — no * await inside either moved off its tick. `destroyOnce` (the verb's memo) moved with the verb: it is written and * read by `destroy` alone. */ import { type TaskSpec, type TaskStream } from "../types.js"; import type { LiveHandle, RunnerDepsSeat, TaskStreamLiveSeat } from "./contracts.js"; export interface StreamHaltVerbsInput { /** borrowed-readonly — the task spec (`taskId` on the notices' detail). */ spec: TaskSpec; /** borrowed-readonly — the stream's live state: `resultValue` (the finished-task refusal, the liveness tests) and `handle`. */ live: TaskStreamLiveSeat; /** borrowed-readonly — the readiness promise; halt and destroy resolve the handle through it while the run body has not published one. */ ready: Promise<LiveHandle | undefined>; /** borrowed-readonly — the driver's timeout race, used for the readiness wait and for destroy's wait on the run's settle. */ orTimeout: <T>(p: Promise<T>) => Promise<T | undefined>; /** borrowed-readonly — the readiness bound in ms; the halt's birth-window poll reads it. */ readyTimeoutMs: number; /** borrowed-readonly — the run promise: `destroy` awaits its settle (bounded) before reaping. */ run: Promise<void>; /** borrowed-readonly — the reap lane's step, run after the run settled (the suspended-run env + checkpoint reap). */ reapSuspended: () => Promise<void>; /** borrowed-readonly — the Runner's deployment deps, read LIVE (`onNotice`, after the readiness await). */ runner: RunnerDepsSeat; } export interface StreamHaltVerbsResult { /** The stream's `halt` verb. */ halt: TaskStream["halt"]; /** The stream's `destroy` verb (idempotent at the promise level; never throws). */ destroy: TaskStream["destroy"]; } export declare function streamHaltVerbs(input: StreamHaltVerbsInput): StreamHaltVerbsResult;