UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

39 lines (38 loc) • 2.58 kB
import { type ModelPricing } from "../pricing.js"; import type { SessionStore } from "../session.js"; import type { RunnerDeps, TaskSpec } from "../types.js"; import type { Stats } from "./assemble-result.js"; import type { Prepared, ResumeRun, RunnerDepsSeat, RunState, TaskIdRef } from "./contracts.js"; export interface RunTelemetryAndBudgetSeatsInput { /** borrowed-readonly — the task spec: limits, degrade, tracer, output retries, the resource-suspend totals. */ spec: TaskSpec; /** borrowed-mutable — the leg's prepared seat: `liveSpendRef.get` is installed, `humanReviewRef` is written and the * mode seat steered on a resume; the model, the ledger, the session id and the usage governance are read. */ prepared: Prepared; /** borrowed-readonly — the resume plan when this leg resumes a checkpoint (the human-review latency, the plan re-arm). */ resume: ResumeRun | undefined; /** borrowed-readonly — the run's usage counters (this leg's own spend), read by the live-spend and budget closures. */ stats: Stats; /** borrowed-mutable — the stream layer's backstop carrier: the effective task id and session id are published here. */ taskIdRef: TaskIdRef | undefined; /** borrowed-readonly — the invocation's frozen tracer, absence included; undefined when the seat was omitted. */ entryTracer: { tracer: TaskSpec["tracer"]; } | undefined; /** borrowed-readonly — the model catalog generation this task resolved against (pinned before prepare for swapDeps). */ modelCatalog: RunnerDeps["models"]; /** borrowed-readonly — the run's canonical task id (`spec.taskId ?? sessionId`), shared with the identity mint. */ runSourceTaskId: string; /** borrowed-mutable — the run's mutable state: this lane is the WRITER of the `telemetry`, `degrade`, `limits` and * `budget` groups' initial values and function members. */ rs: RunState; /** borrowed-readonly — the Runner's deployment deps, read LIVE (`pricing`, `onError`, `tracer`). */ runner: RunnerDepsSeat; /** borrowed-readonly — the Runner's session store: the run is recorded on it (`noteTaskRun`, best-effort, loud). */ sessions: SessionStore; } export interface RunTelemetryAndBudgetSeatsResult { /** The price-table door — a table adopted MID-RUN that cannot price marks the spend unpriced. */ noteUnevaluablePriceTable: (p: ModelPricing) => void; } export declare function runTelemetryAndBudgetSeats(input: RunTelemetryAndBudgetSeatsInput): RunTelemetryAndBudgetSeatsResult;