Repository navigation
Add a Grok usage collector - #7393
fuziontech wants to merge 1 commit into
Conversation
omarchy-agent-usage-grok prints the shared agents-panel record from ~/.grok/sessions turn_completed usage and the cli-chat-proxy billing endpoint grok's /usage command already calls. SuperGrok weekly allowance is a limit; a zero prepaid ledger is omitted rather than shown as $0.00. The panel needs no QML change.
There was a problem hiding this comment.
Pull request overview
This PR adds a new omarchy-agent-usage-grok collector so the existing omarchy.agents bar panel grows a Grok tab, matching how Claude, Codex, and Fireworks already work. No QML changes are needed because the panel renders any record dropped into ~/.local/state/omarchy/agents/usage/ by omarchy-agent-usage-update (which globs omarchy-agent-usage-*). Local token stats are scanned from turn_completed events in $GROK_HOME/sessions/*/updates.jsonl, while plan/limits/balance come from Grok's cli-chat-proxy billing and user endpoints using the OIDC token in ~/.grok/auth.json (read-only). Subagent-fork sessions are skipped to avoid double counting, and a SuperGrok weekly pool with a zero prepaid ledger is surfaced as a limit rather than a $0.00 balance.
Changes:
- New Python collector
bin/omarchy-agent-usage-grok(local scan + cache/lock, auth token read, weekly limit and prepaid/on-demand balance mapping, plan labeling, error/expiry handling). - Panel wiring: enables
grokby default inmanifest.json, shipsassets/grok.svgand light twin, and documents the provider in the plugin README and user manual. - Extensive shell test
test/shell.d/agent-usage-grok-scanner-test.shcovering token math, dedupe, fork skip,GROK_HOME, auth selection, expiry, cache reuse, and HTTP/transport error handling.
Tip
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.
Reviewed changes
Copilot reviewed 4 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
bin/omarchy-agent-usage-grok |
New collector that scans local Grok sessions and probes billing/user endpoints to emit one display-ready JSON usage record. |
test/shell.d/agent-usage-grok-scanner-test.sh |
New test suite validating token accounting, dedupe/fork handling, auth, caching, and limit/error paths. |
shell/plugins/agents/manifest.json |
Enables grok as a default provider and updates the panel description. |
shell/plugins/agents/README.md |
Documents the Grok source, GROK_HOME/auth.json behavior, and default provider config. |
shell/plugins/agents/assets/grok.svg |
Grok brand mark for dark surfaces. |
shell/plugins/agents/assets/grok-light.svg |
Grok brand mark for light surfaces. |
manual/17-ai.md |
Lists Grok among the out-of-the-box supported agents. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Omarchy ships collectors for Claude, Codex, and Fireworks only, and the seven upstream PRs adding Grok are all still open. Vendor the collector from omacom/omarchy#7393 — the one variant that touches no QML — and drive it from a systemd user timer, since omarchy-agent-usage-update only globs the package-owned $OMARCHY_PATH/bin and cannot pick it up.
What
Adds
omarchy-agent-usage-grokso the existingomarchy.agentspanel grows a Grok tab the same way it already does for Claude, Codex, and Fireworks. No QML change: the panel draws any record that lands in~/.local/state/omarchy/agents/usage/.How
$GROK_HOME(default~/.grok). Eachturn_completedevent inupdates.jsonlis one prompt. Cache reads are split out ofinputTokensso the four panel buckets stay mutually exclusive.session_kind: subagent_forksessions are skipped so parent totals are not counted twice./usagecommand uses (/v1/billing?format=creditsand/v1/user?include=subscription). The collector only reads the OIDC token already stored in~/.grok/auth.json. It never writes credentials and does not refresh them — that stays withgrok login.$0.00remaining. Prepaid / leftover on-demand credits still become abalancewhen the billing payload actually has them.assets/grok.svgplus a light-surface twin, and enablesgrokin the widget defaults.Verified on a live SuperGrok Plus login (Grok 1.0.5): the panel gained a Grok tab with SuperGrok Plus, a Weekly 31% meter, tokens by day, and tokens by model (
grok-4.6-build).creditUsagePercentis present on this version.Related collectors already in review: #6902, #6485, #7200, #6477. Happy to close this in favor of whichever lands.
Tests
Covers empty/unauthenticated records, per-turn summing and dedupe, subagent fork skip,
GROK_HOME, weekly/on-demand/balance mapping, SuperGrok Plus labeling, a zero SuperGrok prepaid ledger, expired tokens,--limits-onlycache reuse, and transport vs HTTP error handling.