/** * [ref] b (item 3) — the INFRA cost axes the SERVICE owns, composed with core's LLM-family `costBreakdown` * for the supervisor cost surface. * * ([ref] N24: moved here from the single-file `src/finance/` directory — lens4 §4.4 flagged the "cost" * concept as split across `finance/cost-taxonomy.ts` + `observability/cost-quota.ts` + `budget.ts`. Chose * "dissolve finance/, fold into observability/" over "collect all three into finance/": this module + the * quota tracker are both cost REPORT/GUARD layers that feed metrics/decisions (observability's existing * job), and budget.ts stays put — it has ~19 import sites and was already the N18 move target this same * batch; stacking a second wide-fanout move on it in one session was the higher-risk option for no added * clarity.) * * The engine prices ONLY LLM tokens (core's `Stats.costBreakdown` = llmRoot / nestedSubagent / memoryConsolidation * / compaction). It has NO $ for tool calls, sandbox wall-clock, or network egress — those are INFRA/service costs * the service owns the data + rates for. This module is the thin report layer: it turns a * per-run infra USAGE + the deployment's RATES into an infra breakdown, then composes it with the core LLM * breakdown into one supervisor-facing total. Pure + rate-driven (rates default 0 ⇒ infra reads $0, exactly like * MODEL_COST_* — opt-in pricing). The per-run usage extraction (sandbox wall-clock from the run's remote-env * spans, tool-call count from the trace) is the data-source wiring fed in by the caller; this layer is the math. */ /** Deployment infra pricing (config; default 0 = not priced, mirrors MODEL_COST_*). */ export interface InfraCostRates { /** $ (micro-USD) per tool invocation. */ toolCallMicroUsd: number; /** $ (micro-USD) per sandbox wall-clock SECOND (the run's remote-env connected lifetime). */ sandboxSecMicroUsd: number; /** $ (micro-USD) per GB of network egress. */ egressGbMicroUsd: number; } /** Per-run infra USAGE (fed by the caller from the run's trace / remote-env spans). */ export interface InfraUsage { toolCalls: number; sandboxWalltimeMs: number; egressBytes: number; } /** The service's infra cost axes (micro-USD), the complement to core's LLM-family breakdown. */ export interface InfraCostBreakdown { toolCallMicroUsd: number; sandboxWalltimeMicroUsd: number; egressMicroUsd: number; totalMicroUsd: number; } /** Core's LLM-family breakdown (mirror of core `Stats.costBreakdown`), accepted read-only for composition. */ export interface LlmCostBreakdown { llmRootMicroUsd: number; nestedSubagentMicroUsd: number; memoryConsolidationMicroUsd: number; compactionMicroUsd: number; } /** The combined supervisor cost surface: core's LLM axes + the service's infra axes + a reconciled grand total. */ export interface SupervisorCostBreakdown { llm: LlmCostBreakdown | null; infra: InfraCostBreakdown; /** llm.total (the engine's priced LLM $) + infra.total. `llmTotalMicroUsd` is supplied explicitly (core's * authoritative `stats.costMicroUsd`) rather than re-summed from the breakdown, so a category drift in the * breakdown can never silently inflate/deflate the grand total. */ totalMicroUsd: number; } /** Price a run's infra usage. Every term clamps negatives to 0 (a bad usage/rate never produces a negative cost). */ export declare function infraCost(usage: InfraUsage, rates: InfraCostRates): InfraCostBreakdown; /** * Compose the supervisor cost surface from core's LLM breakdown + total and the service's infra breakdown. * `llmTotalMicroUsd` is core's authoritative priced-LLM total (`stats.costMicroUsd`) — the grand total is that + * infra, NOT a re-sum of the LLM sub-categories (so a breakdown category bug can't move the grand total). */ export declare function composeSupervisorCost(llm: LlmCostBreakdown | null, llmTotalMicroUsd: number, infra: InfraCostBreakdown): SupervisorCostBreakdown; /** True iff ANY infra axis is priced — the gate for surfacing the composed supervisor cost (when all rates are 0 * the infra contribution is always $0, so the client just reads core's `stats.costBreakdown` directly). */ export declare function hasInfraPricing(r: InfraCostRates): boolean; /** * Extract a run's infra USAGE from its event log + wall-clock span. `toolCalls` = the `tool_start` events (one per * tool invocation). `sandboxWalltimeMs` ≈ the run's wall-clock duration (the remote-env is connected for ~the * run's active life; the precise per-span sum lives in logs, not the event trace — the run duration is the * faithful per-run proxy). `egressBytes` = 0 (not yet metered per run). */ export declare function infraUsageFromEvents(events: ReadonlyArray<{ type?: string; }>, runDurationMs: number): InfraUsage; //# sourceMappingURL=cost-taxonomy.d.ts.map