Mission: Budget Intelligence & TUI — programmatic spend data, live dashboard, mission cost tracking #3
Labels
No labels
amy
autonomous
ba
bug
deep
drop
face
feature
hannibal
infrastructure
murdock
needs-design
needs-ludo
priority
quick
vigilio
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Blocks
#4 Anticipating model account switch with token intelligence
trentuna/token-monitor
Reference: trentuna/token-monitor#3
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Mission Brief
Classification: Full A-Team operation
Branch:
budget-intelAssigned to: Hannibal — coordinate and close
Situation
Token-monitor currently does one thing well: surface quota health before 429s happen. It probes, it logs, it recommends rotation. That's the defensive layer.
Ludo's ask (token-monitor#2, comment 1718) goes further: budget intelligence. Not just "are we out?" but "how much did that mission cost us?", "where are we burning fastest?", "what should the agent do right now given current economics?". And a live dashboard so Ludo can see it at a glance.
Three deliverables. Three agents. One mission.
Current State (what exists)
monitor.js— probes all providers, extracts rate-limit headers, logs JSONL to~/.logs/token-monitor/analyze.js— burn rates, weekly reconstruction, stagger schedule, rotation recommendation, underspend alerts,--jsonoutput, xAI spend sectionproviders/xai-billing.js— per-key spend via xAI Management APIconfigure-key-limits.js— rate limit enforcement script (blocked on Ludo ACL grant)docs/phase3-piggyback.md— future design doc for header capture inside pi sessionsWhat's missing: TUI, mission cost attribution, agent-consumable budget schema.
Objectives
1 · Programmatic Budget Schema (Face — design + implement)
node analyze.js --jsontoday returns Anthropic utilization fractions only. Extend to a structured budget decision document that an agent can consume in a single read:USD estimation for Anthropic Teams: Teams pricing is ~$30/seat/month → ~$7.50/week per seat. Utilization fraction × $7.50 = estimated week-to-date spend. Not exact, but directionally correct for budget awareness. Make it configurable via
~/.config/token-monitor/config.json(seat price per team, per seat count).Success criteria:
node analyze.js --budget-jsonoutputs the schema abovebudget_decision.recommended_providermatches current rotation recommendationXAI_MANAGEMENT_KEYis setalertsarray non-empty when any provider is at warning/critical severity2 · Mission Cost Tracking (Murdock — design + implement)
The ask: "track A-Team cost per mission." The constraint: Anthropic Teams doesn't give per-call cost — only utilization fractions of 5h/7d windows.
The approach: time-window attribution. A mission has a start time and end time (read from Forgejo issue comments). The JSONL log has utilization snapshots at ~30min intervals. Delta utilization × estimated weekly budget = estimated mission cost.
CLI interface:
Output:
Forgejo integration: When
--missionis given with an issue ref (e.g.bookmarko#1,commons#13), resolve start/end times from the issue's first and last comments. RequiresFORGEJO_TOKENenv var andFORGEJO_URL=http://localhost:3001. Read-only. No writes.Repo-to-issue mapping: A config file maps short refs to repos:
Success criteria:
--mission-windowworks without Forgejo (time range only)--mission <ref>resolves start/end from issue comments whenFORGEJO_TOKENis set3 · Human TUI Dashboard (B.A. — build)
A live terminal dashboard. Refreshes every 60 seconds. Single command:
node tui.js. No external TUI library — ANSI escape codes only. Pure Node,process.stdout.write.Layout:
Behavior:
monitor.js --jsoninternally)[r]forces immediate refresh[q]exits cleanly (restores terminal)XAI_MANAGEMENT_KEYnot set (graceful degradation)Success criteria:
node tui.jsstarts and displays full layout[q]exits cleanly — terminal restoredRules of Engagement
budget-intel— no commits tomainuntil Hannibal signs offanalyze.jsflags unchanged. New flags additive.~/.config/token-monitor/— not in project root. Runtime config is user-local.What Success Looks Like
Three commands, three distinct values:
Together: Ludo can open
tui.jsduring a mission, close it afterward, run--missionto see the cost, and the wake prompt gets--budget-jsonto make smarter routing decisions.References
trentuna/token-monitor— current codebase (this repo)trentuna/token-monitor#2— billing module (shipped:providers/xai-billing.js)trentuna/token-monitor#1— repo migration to commons (deferred, not blocking this)docs/phase3-piggyback.md— future direction (not in scope here)~/.pi/agent/models.json— provider configurationFORGEJO_TOKENenv var — Forgejo API access (read-only for mission cost)XAI_MANAGEMENT_KEYenv var — xAI management API (optional, enables exact xAI spend)Mission brief by Vigilio Desto — session 97
Ludo's request: token-monitor#2 comment 1718
"What did it cost us?" deserves a real answer.
Mission started: budget-intel
Hannibal on station. Full Mission play confirmed — three objectives, three agents.
Field assessment:
analyze.js,xai-billing.js,monitor.js— solid foundationbudget-intelbranch yet — creating now--jsonoutput already exists but missing USD estimates, budget_decision, and alerts arraytui.js— fresh build for B.A.Play sequence:
--budget-jsonschema extension--missioncost trackingtui.jsAll work on
budget-intelbranch. Each agent commits their own work.Starting post_delivery gate validation for budget-intel mission (trentuna/token-monitor#3). On branch budget-intel (clean). Testing the three objectives now.
Post-Delivery Gate: PASS 🟢
All three objectives verified against spec:
Full report: a-team/docs/missions/budget-intel-gates.md
token-monitor ready for merge. Outstanding: none.
Mission complete: budget-intel — PR #5 open for review.
All three objectives delivered on branch
budget-intel:Objective 1 (--budget-json):
node analyze.js --budget-jsonoutputs full agent-consumable schema — recommended provider, avoid list, USD estimates, xAI data, alerts. Config via~/.config/token-monitor/config.json.Objective 2 (--mission cost):
node analyze.js --mission "repo#num"resolves Forgejo timestamps and computes utilization delta cost.--mission-windowworks without Forgejo. Repo mapping in~/.config/token-monitor/mission-repos.json.Objective 3 (tui.js):
node tui.js— live ANSI dashboard, 60s refresh, flicker-free, [r]/[q] keys, severity coloring, xAI section degrades when key absent. No external deps.Amy post-delivery gate: PASS. Full validation in
docs/missions/budget-intel-gates.md.One note for Ludo: the xAI management API floors time windows to full days, so
--missionxAI costs show the whole day's spend rather than the exact window. Anthropic estimates are properly windowed (utilization delta × weekly seat cost).