Add Grok Build / SuperGrok usage monitoring - #72
Open
reloadlife wants to merge 2 commits into
Open
Conversation
Monitor SuperGrok/Grok Build weekly quota, monthly included allowance, and credits via the same billing API used by the Grok CLI. Accounts can be imported from ~/.grok/auth.json or signed in with OIDC device-code flow. Grok appears as a third provider in the menu bar and detail window.
Cover productUsage preference, creditUsagePercent fallback, monthly edge cases, percentage clamping, ISO8601 date parsing, and credits enabled/percentage rules.
Author
|
Hey @f-is-h as a Grok user, i'd appreciate if you accept this PR. |
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
Adds optional Grok Build / SuperGrok usage monitoring as a third provider alongside Claude and Codex, addressing #69.
Closes #69
What users get
?format=creditsbilling response)Auth (Settings → Authentication)
~/.grok/auth.json(recommended if you already rungrok login)auth.x.ai(public Grok CLI client id)Technical approach
Mirrors the existing Codex provider integration:
ProviderType.grok,GrokUsageData+ billing response parsersGrokAPIService— refresh_token → access_token → concurrent credits + monthly billing GETsGrokOAuthService— token refresh, device code, auth.json importaccounts_grokKeychain list +AccountStoreCRUDGrokColumnView, multi-column detail width, menu-bar compositiongrok_weekly/grok_monthly/grok_creditscolors, notifications, custom displayBilling endpoints (same surface used by official Grok CLI
/usage):GET https://cli-chat-proxy.grok.com/v1/billing?format=creditsGET https://cli-chat-proxy.grok.com/v1/billingTests
Repo already has a SwiftPM pure-function test target. Added:
Tests/Usage4ClaudeCoreTests/GrokUsageResponseTests.swiftproductUsage/creditUsagePercentfallbackGrokCreditsDataenabled / percentage rulesProviderType.grokdisplay nameRun (on a machine with Swift toolchain):
swift testFull macOS app still builds via Xcode /
./scripts/build.sh.Notes for reviewers
Test plan
swift testpasses (Grok parser suite + existing suites)~/.grok/auth.json→ Grok column appears with weekly/monthly data