Skip to main content

usage/
lib.rs

1//! Session usage (`ultron/usage-cli.ts`): a session file read into its usage log ([`log`]), the session report built
2//! from it ([`report`], with the cell statistics of [`stats`]) and the report as text ([`text`]). `ultron usage`,
3//! the TUI's `/usage` and `ultron mcp`'s `usage.report` inspection all show this report.
4
5pub mod log;
6pub mod report;
7pub mod stats;
8pub mod text;
9
10use std::path::Path;
11
12/// The session report of the session file `path` as `/usage` builds it: `providers` (those on a subscription login,
13/// `subscriptionProviders`) are priced as notional.
14pub fn session_report(path: &Path, providers: &[String]) -> Result<serde_json::Value, String> {
15    let log = log::read_session_log(path).map_err(|e| e.message().to_string())?;
16    Ok(report::build_session_report(&log, providers))
17}