9router/open-sse/services
Janu Yoga 8321032e36 feat(codebuddy-cn): add API key auth + credit quota tracker
Two additions on top of the merged CodeBuddy CN OAuth provider:

1. API key auth — connect with a direct API key (sent as
   Authorization: Bearer), not only via OAuth device-code flow.
   - registry: add authModes ["oauth","apikey"] + hasOAuth; combined Bearer
     auth already forwards the key, token-refresh skips key connections.
   - providers POST: accept dual-auth providers (authModes includes
     "apikey") that live under category "oauth" — previously rejected as
     "Invalid provider". Also fixes the same latent gap for xai.

2. Quota tracker — surface CodeBuddy CN credit balance on the usage
   dashboard for both OAuth and API-key connections.
   - registry: add transport.usage.url (Tencent billing endpoint) +
     features.usage/usageApikey so the connection is quota-eligible.
   - new CN-scoped handler services/usage/codebuddy-cn.js: POST the billing
     meter endpoint, unwrap data.Response.Data.Accounts[]. The payload mixes
     two credit types that must not be merged:
       * refill/base ("基础体验包") — recurring allowance; cycle resets well
         before the resource expires (CycleEndTime << DeductionEndTime).
         Reads the *Cycle* balance, resetAt = next refresh. Cadence-labelled.
       * bonus ("活动赠送包") — one-shot credits that expire at CycleEndTime.
         Reads the plain Capacity balance. Labelled "Bonus Pack N".
     One quota row per package, soonest-expiring first.
   - register handler under "codebuddy-cn" in USAGE_HANDLERS.

Frontend needs no change — USAGE_SUPPORTED_PROVIDERS/USAGE_APIKEY_PROVIDERS
and the generic parseQuotaData branch already cover this shape.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-21 16:12:20 +07:00
..
tokenRefresh feat(provider): add CodeBuddy CN provider (copilot.tencent.com) 2026-06-19 15:33:26 +07:00
usage feat(codebuddy-cn): add API key auth + credit quota tracker 2026-06-21 16:12:20 +07:00
accountFallback.js fix: update backoff configuration and improve CLI detection messages 2026-04-17 12:54:50 +07:00
combo.js fix(combo/fusion): flatten Anthropic-style tool messages in panel calls 2026-06-20 15:19:31 +07:00
compact.js Feat : Auto restart after crash 2026-03-14 09:37:29 +07:00
kiroModels.js https://github.com/decolua/9router/pull/1167 2026-05-16 11:20:08 +07:00
model.js refactor(open-sse): registry consolidation + DRY media/oauth/adhoc cleanup 2026-06-14 13:15:48 +07:00
oauthCredentialManager.js refactor(open-sse): registry consolidation + DRY media/oauth/adhoc cleanup 2026-06-14 13:15:48 +07:00
projectId.js Add proactive token refresh lead times for providers and implement Codex proxy management 2026-04-14 11:41:06 +07:00
provider.js feat(headroom): add proxy lifecycle management + dashboard UI 2026-06-20 10:09:50 +07:00
qoderModels.js refactor(open-sse): registry consolidation + DRY media/oauth/adhoc cleanup 2026-06-14 13:15:48 +07:00
tokenRefresh.js feat(provider): add CodeBuddy CN provider (copilot.tencent.com) 2026-06-19 15:33:26 +07:00
usage.js feat(codebuddy-cn): add API key auth + credit quota tracker 2026-06-21 16:12:20 +07:00