UNPKG

@sema-agent/core

Version:

Stateless, task-oriented AI agent core

27 lines (26 loc) • 1.54 kB
/** * The leg's budget facts a policy judges every request of the leg under (`ToolCallRequest.budget`) — one reading for a run's prepare and * for a preview of that leg (`Runner.previewInstructions`), so a policy that judges the budget judges the preview's reads as the run's. */ import { type ResourceLedger } from "./checkpoint-store.js"; import type { ToolCallRequest } from "./tool-policy.js"; /** The resource totals a task configures (`TaskSpec.resourceSuspend`), $ in micro-USD — seeded on the first slice only (later slices * read the frozen total off the ledger); `undefined` when the task configures no resource suspend. */ export declare function resourceTotalOf(spec: { readonly resourceSuspend?: { readonly totalBudgetUsd?: number; readonly totalTokens?: number; }; }): { totalBudgetMicroUsd?: number; totalTokens?: number; } | undefined; /** THE leg's budget snapshot, read once per leg from the durable state and frozen onto every request the leg hands a policy. A resumed * leg reads its ledger's remaining and spend; a first leg (a preview resumes nothing) its configured total and nothing spent; the count * is the durable suspend chain's. Never falsy-test the remaining (`0` = exhausted, not unlimited). */ export declare function legBudgetSnapshot(resourceTotal: { readonly totalBudgetMicroUsd?: number; } | undefined, resume: { readonly priorLedger?: ResourceLedger; readonly priorSuspendCount?: number; } | undefined): NonNullable<ToolCallRequest["budget"]>;