import type { BudgetCaps, StopReason, UsageSnapshot } from "./types.js"; /** * Tracks per-session usage against `BudgetCaps`. Consumed by the runner's * step boundary: after every LLM step + tool batch, we record the usage and * ask `nextStopReason()` whether to terminate. * * Wall time is measured from `start()`. Cost is estimated using the existing * `estimateCostUsd` table; for unknown providers/models, cost defaults to 0 * which means USD caps don't fire — caller is responsible for ensuring * provider/model are recognized when USD enforcement matters. */ export declare class BudgetTracker { private readonly caps; private readonly providerId; private readonly modelId; private inputTokens; private outputTokens; private toolCallCount; private externalUsd; private startedAt; /** Largest observed input-token count for any single step. Drives the projection. */ private maxStepInputTokens; private maxStepOutputTokens; private stepCount; constructor(caps: BudgetCaps, providerId: string, modelId: string); start(): void; recordStepUsage(usage: { inputTokens?: number; outputTokens?: number; }): number; recordToolCalls(n: number): void; /** * Record a non-LLM external API cost (SerpAPI calls, AI-engine probes, * etc.) so the session budget accurately reflects total spend, not just * orchestrator-LLM tokens. */ recordExternalCost(usd: number): void; estimatedUsd(): number; snapshot(): UsageSnapshot; /** * Returns the StopReason that fires now, or null when no cap is breached. * Order matters — earlier checks take priority when multiple caps exceed * simultaneously (most informative reason wins). */ nextStopReason(): StopReason | null; /** * Pre-flight projection: would executing one more step at the worst-case * (max observed) per-step cost push us over the USD or input-token cap? * Used by `stopWhen` to refuse the next step before it overshoots, rather * than reactively after. * * Returns null until at least one step has completed — we have nothing * to project from before that. */ projectedNextStopReason(): StopReason | null; } //# sourceMappingURL=budget.d.ts.map