/** * Eval cost transparency — make what a real-model run SPENT impossible to miss. * vigiles's whole affordability pitch is "runs on your Claude subscription, not a * metered API," so every real-model run should say — out loud — how many tokens it * spent, the API-equivalent dollar cost, and (loudly) if it was billed to a * METERED API key instead of your subscription. * * HONEST SCOPE: we surface tokens + the API-equivalent `$` (`total_cost_usd` from * the `claude` CLI) + a running session tally. We deliberately do NOT show a * "% of your subscription" — Anthropic does not expose a subscription's quota or * limit programmatically (and the real limits are rolling rate windows, not a * dollar bucket), so any percentage would be fiction. See research/eval-architecture.md. * * Pure + injectable (env + an output sink), so the whole thing is unit-tested * without a model or a real key. */ import type { EvalUsage, ArmUsage, EvalReport } from "./eval.js"; /** A normalized cost/token snapshot — the common shape a report renders from. */ export interface CostSummary { /** API-equivalent cost (`total_cost_usd`) — the number that matters. */ readonly costUsd: number; readonly inputTokens: number; readonly outputTokens: number; readonly cacheCreationTokens: number; readonly cacheReadTokens: number; } /** Total tokens across all four billing buckets. */ export declare function totalTokens(c: CostSummary): number; /** A per-run {@link EvalUsage} → the common snapshot. */ export declare function costFromRun(u: EvalUsage): CostSummary; /** An aggregated per-arm {@link ArmUsage} → the common snapshot. */ export declare function costFromArm(u: ArmUsage): CostSummary; /** Sum any number of snapshots (e.g. every arm of an A/B). */ export declare function sumCosts(costs: readonly CostSummary[]): CostSummary; /** The whole-{@link EvalReport} cost — every arm summed. */ export declare function costFromEvalReport(report: EvalReport): CostSummary; /** * How the run was billed. `metered` is true when a real Anthropic API key is in * the environment — the `claude` CLI bills those PER TOKEN, whereas a * subscription run (auth via `~/.claude`, no key var) costs $0 beyond the sub. * The mock/deterministic tier never reaches here (it has no real cost), so a * present key means a real metered run. */ export interface Billing { readonly metered: boolean; /** Which env var carried the key (for the actionable "unset X" message). */ readonly keyVar: string | null; } export declare function detectBilling(env?: NodeJS.ProcessEnv): Billing; /** Add a run to the running session total and return the new total. */ export declare function recordSessionCost(c: CostSummary): CostSummary; /** The session total so far. */ export declare function sessionCost(): CostSummary; /** Reset the session tally (test seam). */ export declare function resetSessionCost(): void; /** * The human-readable cost block for a run. Shows tokens + API-equivalent `$`, the * billed-to line (a LOUD warning + an actionable fix when metered, a green ✅ when * on the subscription), and the session tally when it exceeds this run. */ export declare function formatCostSummary(c: CostSummary, opts: { billing: Billing; session?: CostSummary | null; }): string; /** * Record `c` into the session tally and emit its cost block. The default sink is * stderr (so a run's cost never pollutes `--json` stdout). Injectable env + sink * keep it fully testable. Returns the emitted text (also handy for a skill to * relay to the user). */ export declare function emitCostSummary(c: CostSummary, opts?: { env?: NodeJS.ProcessEnv; out?: (s: string) => void; }): string; //# sourceMappingURL=eval-cost.d.ts.map