/** * Stateful foreground cost-guard owner. * * The controller brackets each ordinary foreground turn, projects the exact provider request once * routing and context shaping are complete, and retains only the latest UI decision. AgentSession * coordinates the turn; it does not own cost accounting or request-reasoning policy. */ import type { Api, Context, Model, SimpleStreamOptions } from "@caupulican/pi-ai"; import { type CostGuardDecision, type CostGuardSettings } from "./cost-guard.ts"; export interface CostGuardControllerDeps { getSettings(): CostGuardSettings; getCompactionReserveTokens(): number; getSpawnedUsageCost(): number; isUnmeteredSubscription(model: Model): boolean; } export declare class CostGuardController { private readonly deps; private lastDecision; private turnBaselineUsd; constructor(deps: CostGuardControllerDeps); /** Snapshot cumulative spawned spend before any work in a new foreground turn begins. */ beginForegroundTurn(): void; /** Latest decision for the host UI. Disabled settings hide and invalidate prior projections. */ getLastDecision(): CostGuardDecision | undefined; /** A settings transition invalidates the prior decision before another request is projected. */ invalidateDecision(): void; /** Active threshold projected into the foreground capability envelope. */ getEnabledMaxTurnUsd(): number | undefined; /** * Resolve cost policy after routing/context conversion reveals the real request. This projection * is not an output cap; warning mode preserves capability and downgrade changes only this request. * Background spend is turn-local: cumulative spawned usage minus the baseline captured by * {@link beginForegroundTurn}. Per-lane dollar caps remain independent. Best-effort: never throws. */ resolveRequestReasoning(model: Model, context: Context, reasoning: SimpleStreamOptions["reasoning"], requestMaxTokens: number | undefined): SimpleStreamOptions["reasoning"]; } //# sourceMappingURL=cost-guard-controller.d.ts.map