feat(api): expose managed-session usage and pricing - #1
Open
vlad-thenvoi wants to merge 3 commits into
Open
Conversation
Preserve provider-supplied reasoning/output-thinking totals on the all-provider session facade as an optional field. Missing metadata remains unknown rather than being coerced to zero, allowing Jam's canonical reconciliation importer to retain Codex token categories without parsing provider files itself.
Allow embedders to add managed Codex provider-state homes to the ordinary CODEX_HOME/default discovery set without mutating global environment variables. The all-provider pipeline reuses the existing Codex parser, archived-session dedupe, date filtering, pricing, and reasoning metadata.
Expose a scan-free, network-free pricing quote for one canonical token vector. Persistable quote metadata includes requested/resolved model, USD currency, a content-derived embedded catalog version, and formula version. Unknown model pricing is explicit and returns no estimated cost, preventing downstream consumers from treating missing pricing as zero. Tests cover known and unknown model behavior; the full 364-test library suite and warnings-denied Clippy pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Extends the all-provider embedding API in three narrowly scoped ways needed by Jam's managed-runtime usage importer and canonical pricing projection:
reasoning_tokensonAgentSessionUsage, preservingNonewhen the provider supplied no fact;CODEX_HOME/default discovery;The additional homes reuse ccusage's existing Codex parser, archived-session dedupe, date filtering, pricing, and session aggregation. Embedders do not need to mutate process-global environment variables or duplicate provider-file parsing. Pricing quotes include requested/resolved model, USD currency, a content-derived catalog version, and formula version. Unknown models explicitly return
missing_pricingwith no estimated amount rather than a misleading zero.Why
Jam's Plan 74 runtime stores sandboxed Codex state under UUID-owned provider-state roots. Its canonical usage ledger must import those sessions while continuing to see ordinary host Codex sessions, preserving reasoning-token totals, and deriving a separately versioned cost projection from accepted raw facts.
Verification
cargo test --manifest-path rust/Cargo.toml -p ccusage --lib— 364 passedcargo clippy --manifest-path rust/Cargo.toml -p ccusage --lib -- -D warningscargo fmt --manifest-path rust/Cargo.toml --all