Grok: support first-party Grok Bot weekly usage alongside Credits via xAI bot.usage

Aperta
#4,633 2 commenti 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
swift

Direzione di ricerca

Start by reading Sources/CodexBarCore/Providers/Grok/GrokStatusProbe.swift and the existing Grok credits flow, then compare its session handling and usage model with CursorSandUsage.swift. Implementing the first-party bot.usage request requires Grok authentication, bounded WebSocket handling, response parsing, and menu-bar and JSON presentation. Done means the Grok card and JSON expose an active allowance or trial while failures and inactive meters leave the Credits bar unchanged.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

clawsweeper:needs-maintainer-review clawsweeper:needs-product-decision clawsweeper:no-new-fix-pr issue-rating: 🌊 off-meta tidepool P3

Summary

CodexBar's Grok provider (Sources/CodexBarCore/Providers/Grok/) currently surfaces only the weekly Credits pool (cli-chat-proxy.grok.com/v1/billing?format=credits / GetGrokCreditsConfig, with GrokBuild and GrokChat shares under Usage breakdown). Its secondary, tertiary, and extraRateWindows remain empty (GrokStatusProbe.swift:95-118).

Meanwhile, Grok Bot weekly usage is only surfaced under the Cursor provider (CursorSandUsage.swift), and PR #4426 was rightly closed because it read Cursor's cursor.com/api/dashboard/get-sand-usage-status account data and displayed it under the Grok provider.

However, xAI exposes a first-party Grok Bot usage RPC (bot.usage) directly under the Grok / xAI account via its Computer Hub (bot_relay) protocol, where SuperGrok subscriptions fund the meter (fundingPlan: "supergrok-heavy" / "supergrok-plus"). Supporting bot.usage inside the Grok provider lets Grok users see their Grok Credits and Grok Bot weekly allowance together using 100% first-party Grok credentials—without touching Cursor's session or crossing provider boundaries.

First-Party xAI Protocol Evidence (xai-org/grok-build)

  1. Endpoint:
    PROD_COMPUTER_HUB_WS_URL = "wss://computer-hub.grok.com/v1/tools"
    (crates/codegen/xai-grok-shell-base/src/env.rs#L14)

  2. Handshake (ConnectionKind::BotClient):
    Send HelloMsg:

    {
      "protocol_version": "1.0.0",
      "kind": "bot_client"
    }
    

    The hub replies with HelloAckMsg advertising "bot.usage" in capabilities (BOT_RELAY_CAPABILITIES).
    (crates/common/xai-tool-protocol/src/connection.rs#L11-L26, handshake.rs#L19-L56)

  3. RPC Method (bot.usage):
    Documented as "Caller-scoped weekly Grok Bot usage summary. Cold — never wakes the box."
    (crates/common/xai-tool-protocol/src/methods.rs#L162-L164)

    {
      "jsonrpc": "2.0",
      "id": 1,
      "method": "bot.usage",
      "params": {}
    }
    
  4. Response Schema (BotUsageResult):
    Defined in crates/common/xai-tool-protocol/src/bot_relay.rs#L377-L420 (with round-trip fixture at bot_relay.rs#L1545-L1596):

    {
      "usagePercent": 12.8,
      "currentPeriodStartMs": 1756000000000,
      "nextResetAtMs": 1756604800000,
      "hasAvailableUsage": true,
      "hasNonZeroIncludedLimit": true,
      "includedLimitZero": false,
      "trial": false,
      "isTeamSeat": false,
      "fundingPlan": "supergrok-heavy",
      "planLabel": "SuperGrok Heavy",
      "manageUrl": "https://example.com/usage",
      "onDemandEligible": true,
      "onDemandEnabled": false
    }
    

Expected Behavior

  • Query bot.usage using Grok's own authenticated session (~/.grok/auth.json bearer or grok.com web cookies—never Cursor's session) under a short bounded timeout.
  • Fail soft: if bot.usage times out, errors, or reports no active personal meter (includedLimitZero == true && !trial, or missing usagePercent), preserve the primary Grok Credits bar unchanged.
  • When an active Grok Bot allowance or unexpired trial is present, surface it alongside the Weekly Credits bar on the Grok card and codexbar usage --provider grok --json (as extraRateWindows or secondary, with a selectable Grok Bot / GB menu-bar metric token, matching the paid 7-day pace vs unpaced trial semantics in CursorSandUsageStatus).

Related (Not Duplicates)

  • #4426 (closed PR): Attempted to show Cursor's cursor.com/api/dashboard/get-sand-usage-status data under the Grok provider. Closed because a provider must never display data sourced from a different provider's account. This issue uses xAI's own first-party bot.usage surface on the Grok account.
  • #4432 (open): Tracks POST https://grok.com/rest/rate-limits per-model consumer chat caps (Fast / Expert / Heavy query & token counters), which is separate from the weekly Grok Bot (bot.usage) allowance.
  • #3309 / #4207 / #4269 / #4340 (closed): Cover Grok Bot under the Cursor provider only.

Environment

  • CodexBar 0.77.0 (macOS)
  • Grok CLI 1.0.63 (SuperGrok Heavy)
Lingua principale
Swift
Stelle
22.9k
Fork
2.2k
Merge medio
1g 1h
PR unite (30g)
399

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di steipete/CodexBar

Tutte le issue di steipete/CodexBar

Issue simili

Altre issue su Swift

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.