-
Notifications
You must be signed in to change notification settings - Fork 2k
feat(claude): expose saved usage-limit resets in CLI JSON #3895
Copy link
Copy link
Open
Labels
P2Normal priority bug or improvement with limited blast radius.Normal priority bug or improvement with limited blast radius.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.This issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🌊 off-meta tidepoolIssue quality rating does not apply to this item.Issue quality rating does not apply to this item.
Description
Activity
Metadata
Metadata
Assignees
Labels
P2Normal priority bug or improvement with limited blast radius.Normal priority bug or improvement with limited blast radius.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.ClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.This issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🌊 off-meta tidepoolIssue quality rating does not apply to this item.Issue quality rating does not apply to this item.
Request
Expose Claude Code's saved usage-limit reset grants in
codexbar usage --provider claude --source oauth --json, analogous to the existing Codexusage.codexResetCreditsoutput. This would let CLI consumers display the remaining resets and earliest expiration without making a second authenticated request.Data source and observed response
Claude Code 2.1.280 requests
GET https://api.anthropic.com/api/oauth/usage?cedar_ember=1&skip_spend=1with its OAuth bearer token,anthropic-beta: oauth-2025-04-20, and a Claude Code CLI User-Agent. The regular/api/oauth/usageresponse hadcedar_ember: nullfor the account tested. The opt-in query returned acedar_emberobject. Requests with a generic/claude-code/<version>User-Agent returnedeligible: false,ineligible_reason: "surface", and no grants;claude-cli/2.1.280 (external, cli)returned an eligible grant. Please check the appropriate supported client identity rather than assuming the normal usage fetch is enough.Relevant fields, with account-specific values omitted:
{ "cedar_ember": { "eligible": true, "grants": [ { "id": "<grant id>", "label": "<description>", "resets_total": 1, "resets_left": 1, "starts_at": "<ISO timestamp>", "ends_at": "<ISO timestamp>", "clears": ["five_hour", "seven_day"], "paused": false, "usable_now": true, "use_requires_limit": false } ], "next_grant_id": "<grant id>" } }The grant count is
resets_left(not simply the number of grants); ignore paused, not-yet-started, expired, and exhausted grants for an available count.usable_now/use_requires_limitdescribe whether redemption is currently allowed and should not be conflated with saved credits remaining. Expose expiry and the applicableclearswindows where possible. Absent/ineligible grants should not be reported as available. This is a read-only request; no redemption action is needed.Current gap
In CodexBar CLI 0.64.1, Claude OAuth JSON contains usage windows but no saved-reset grants, while Codex already includes
codexResetCredits. The upstream OAuth response decoder currently omitscedar_ember:Sources/CodexBarCore/Providers/Claude/ClaudeOAuth/ClaudeOAuthUsageFetcher.swift. A KDE CLI consumer currently has to make this extra request itself to show Claude's saved resets. Reusing the existing OAuth credential and rate-limit handling in CodexBar would avoid duplicating authentication and HTTP behavior in each client.