Skip to main content

Module token_usage

Module token_usage 

Source
Expand description

Token/cost accounting shapes for the usage subject.

Distinct from crate::usage (Anthropic plan/subscription utilization): these describe per-model and per-project token counts plus a notional API-equivalent cost, rolled up from the session JSONL pool. The scanner lives in forge-agent::env::token_usage, the redb cache in forge-workspace::store::token_usage.

Re-exports§

use serde::Deserialize; 🔒
use serde::Deserialize; 🔒
use serde::Serialize; 🔒
use serde::Serialize; 🔒

Structs§

ModelPricing
Per-token USD pricing for one model, sourced from the LiteLLM table. Cache-write splits by TTL tier to match the JSONL’s cache_creation.ephemeral_{1h,5m} breakdown.
UsageReport
The four rolling windows the /usage overlay drew. lifetime is a static sum; the other three are recomputed relative to now.
UsageRow
One row of the usage table: label is a model id, a folded project name, or "TOTAL" for the aggregate row. Token counts are split; cost_usd is notional (at API pricing, not a bill).
WindowUsage
One time window’s usage: the same data grouped two ways plus the aggregate total row. Each Vec is sorted by cost descending.