From d8d1134545491c2fa02745fdaff55ba93ce708f9 Mon Sep 17 00:00:00 2001 From: rune-oai <157205701+rune-gh@users.noreply.github.com> Date: Wed, 2 Dec 2026 16:17:09 -0800 Subject: [PATCH 1/4] feat(quota-history): record Qoder credit usage A Qoder account is an auth file holding a personal access token ({"type":"qoder","personal_access_token":"..."}). The recorder exchanges it for a session token at api.qoder.sh/api/v1/jobToken/exchange, the exchange Qoder CLI makes for QODER_PERSONAL_ACCESS_TOKEN, and caches the session until shortly before it expires. It then reads /sash/api/v2/me/usage (the figures Qoder CLI's /usage shows), falling back to /api/v2/quota/usage, and the plan tier from /api/v2/user/plan. None of these requests spend credits, and the global endpoints answer in plain JSON. Plan credits become a "monthly" window that resets at the plan refresh time; bought add-on credits become a non-renewing "add_on" window. Qoder is not routed through the hub, so like Mistral its readings stay out of routing. Built-in plan weights: Pro 1, Pro+ 3, Ultra 10. Co-Authored-By: Claude Opus 5.5 --- config.example.yaml | 7 +- internal/api/handlers/management/api_tools.go | 8 + .../api/handlers/management/quota_history.go | 5 + .../quota_history_transport_test.go | 8 + internal/quotahistory/providers.go | 1 + internal/quotahistory/qoder.go | 216 ++++++++++++++++++ internal/quotahistory/qoder_test.go | 213 +++++++++++++++++ internal/quotahistory/recorder.go | 18 +- internal/quotahistory/restore.go | 2 +- sdk/cliproxy/auth/plan_weight.go | 9 + 10 files changed, 480 insertions(+), 7 deletions(-) create mode 100644 internal/quotahistory/qoder.go create mode 100644 internal/quotahistory/qoder_test.go diff --git a/config.example.yaml b/config.example.yaml index 94238925d69..85e5c8568f3 100644 --- a/config.example.yaml +++ b/config.example.yaml @@ -259,7 +259,8 @@ routing: # Plan capacity weights relative to each provider's base paid plan (1.0), used by # soonest-reset-first. Built-in: claude pro/team 1, max 5, max_5x 5, max_20x 20 (any max_x # tier weighs N); codex plus/team/business/enterprise/edu 1, prolite 5, pro 20, promax 50; - # xai supergrok 1, supergrok_heavy 10. The Codex ratios are approximate and change over time. + # xai supergrok 1, supergrok_heavy 10; qoder pro 1, pro+ 3, ultra 10. The Codex ratios are + # approximate and change over time. # Entries here replace the built-in value for that plan; names are case-insensitive and # "Max 20x" equals "max_20x". # Each weight must be > 0 and <= 1000. @@ -1388,7 +1389,9 @@ observability: quota-history: enabled: false # Provider IDs to poll. Empty enables all supported providers and quota plugins. - # Built-in IDs: claude, codex, xai, antigravity, kimi, kimi-ai, meta, devin, mistral. + # Built-in IDs: claude, codex, xai, antigravity, kimi, kimi-ai, meta, devin, mistral, qoder. + # A Qoder account is an auth file holding a personal access token: + # {"type": "qoder", "personal_access_token": "", "email": "