feat(cli): add Hermes usage reporting - #2892
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs real behavior proof before merge. Reviewed August 12, 2026, 4:23 PM ET / 20:23 UTC. ClawSweeper reviewWhat this changesThis PR adds Merge readiness⛔ Blocked until real behavior proof is added - 5 items remain Keep open for maintainer product-direction review and real behavior proof. The implementation is a substantial new supported CLI surface, not a fix for an established bug; its source isolation is careful, but Hermes schema ownership needs explicit sponsorship. Priority: P3 Review scores
Verification
How this fits togetherCodexBar’s CLI reports usage and local cost information for terminal users and automation. This new path reads Hermes Agent state databases, maps explicit billing routes to CodexBar providers, and emits a standalone report without changing existing provider billing totals. flowchart LR
A[Hermes state databases] --> B[Read-only database discovery]
B --> C[Usage scanner]
C --> D[Route and model mapping]
D --> E[Cost classification]
E --> F[CLI text or JSON report]
F --> G[Terminal and automation users]
Decision needed
Why: This is a new, sizeable integration with a third-party persisted schema and no linked maintainer sign-off; implementation quality cannot establish the intended long-term ownership boundary. Before merge
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: If sponsored, retain the standalone read-only CLI boundary and land only after a redacted real-profile WAL scan proves the reported buckets and source-safety behavior. Do we have a high-confidence way to reproduce the issue? Not applicable to an existing bug: the branch introduces a new capability. Its claimed live validation is not independently inspectable because no runtime transcript or artifact is attached. Is this the best way to solve the issue? Unclear: keeping Hermes attribution separate from native billing is a narrow technical boundary, but maintainers must first decide whether CodexBar should own this external database-schema integration. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against ee29794b9a1b. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 21498e9adf
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| !raw.isEmpty, | ||
| raw.lowercased() != "all" | ||
| else { return nil } | ||
| guard let provider = UsageProvider(rawValue: raw.lowercased()) else { |
There was a problem hiding this comment.
Parse Hermes provider filters through CLI names
When users pass the documented CodexBar provider names for mapped Hermes routes, such as --provider opencode-go, --provider qwen-cloud, --provider vertex-ai, or --provider alibaba-coding-plan, this raw-value lookup rejects them even though the rest of the CLI resolves provider names and aliases through ProviderDescriptorRegistry.cliNameMap. That makes the new --provider filter unusable for several supported Hermes mappings unless users know the internal enum raw values like opencodego/qwencloud instead of the normal CLI names.
Useful? React with 👍 / 👎.
| let input = Double(row.tokens.input) * pricing.inputCostPerToken | ||
| let output = Double(row.tokens.output) * pricing.outputCostPerToken | ||
| let cacheRead = Double(row.tokens.cacheRead) | ||
| * (pricing.cacheReadInputCostPerToken ?? pricing.inputCostPerToken) | ||
| let cacheWrite = Double(row.tokens.cacheWrite) | ||
| * (pricing.cacheCreationInputCostPerToken ?? pricing.inputCostPerToken) |
There was a problem hiding this comment.
Apply models.dev long-context rates
For Hermes rows whose matched models.dev pricing has a long-context threshold, this calculation always uses the base input/output/cache rates and ignores the *AboveThreshold rates, so large Claude/OpenAI/etc. sessions over the threshold are reported with understated API-equivalent costs. The existing cost estimator switches rates when the token count crosses thresholdTokens; this path should make the same choice before multiplying the row tokens.
Useful? React with 👍 / 👎.
Summary
state.dbscanner and expose it ascodexbar hermes-usageWhy
Hermes Agent records token attribution in SQLite rather than Codex/Claude session JSONL, so CodexBar cannot currently report that local usage. This adds a narrow local import path without introducing another scanner framework or merging Hermes data into native provider billing totals, where the same API calls could be double-counted.
The scanner uses the persisted
session_model_usageprovider/model/task dimensions, includes auxiliary calls such as compression and title generation, and reconciles only positive legacy main-loop residuals fromsessions. It does not infer daily history from cumulative rows.Linked issue or maintainer sign-off
No linked issue: this is a distinct local-telemetry feature rather than a Nous Portal provider implementation.
#1367 requested Nous Portal quota support and was closed because no public portal API was available. This PR intentionally does not implement portal quota, OAuth, cookies, or remote account access; it reads only local Hermes attribution databases and requires no credentials.
Validation
make checkmake test— 843 selections, 71/71 groups, 0 failed groups, 0 retriesUI proof
CLI-only change; no app UI changed.
Example:
--jsonprovides a versioned report for automation. No screenshot is applicable.Provider and privacy impact
state.dbfiles with SQLite read-only flags andPRAGMA query_only=ONbilling_providerroutes;auto,custom,moa,azure-foundry, and other ambiguous routes remain unmappedinput + output + cache_read + cache_write;reasoning_tokensremains an output sub-breakdown and is not added twiceChecklist