feat(report): API cost estimation overlay (Phase 3 M6)#9
Merged
Conversation
Token usage parsed from MCP events.message_json (Anthropic-shaped usage block) plus a length-based heuristic estimate for non-MCP agents. Static pricing table covers Claude (Opus 4.7 / Sonnet 4.6 / Haiku 4.5), OpenAI (GPT-4-Turbo / GPT-4o), Google (Gemini 2.5 Pro / Flash). Source URLs cited per entry; quarterly refresh tracked in docs/PRICING_SOURCES.md. CostSummary lands on every output surface — text today/week reports get a `## Cost` section, the Phase 2 weekly HTML card shows a cost row, and studio /api/today + /api/week JSON gain a `cost: CostSummary` field. The estimate_share fraction lights up a "estimate" footnote on the studio Today + Week pages so guessed figures never silently masquerade as exact. Heuristic agents (Gemini / Qwen) compute tokens as len(detail) * 1.3 / 4 with output ≈ 2 * input — flagged via AgentCost.estimate / ModelCost.estimate. Capture binary unchanged.
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.
Summary
Closes the README "Usage tracker" 🟡 → ✅ by adding a cost overlay across every report surface.
crates/fluxmirror-core/src/cost/mod.rs): Claude Opus 4.7 / Sonnet 4.6 / Haiku 4.5, OpenAI GPT-4-Turbo / GPT-4o, Google Gemini 2.5 Pro / Flash. Source URLs cited per entry.Files
12 modified + 4 new (cost module, pricing-sources doc, CostBlock component, CLI cost.rs).
Test plan