t3code icon indicating copy to clipboard operation
t3code copied to clipboard

[Feature]: Support Kimi (ACP Registry / Kimi Code CLI) in Usage -> Limits, 5-hour quota banners, and local usage scanning

Open jamesdchen opened this issue 1 month ago • 0 comments

Before submitting

  • [x] I searched existing issues and did not find a duplicate (checked closed unmerged PRs #7936, #8485, and #13587, as well as #26381 and #28658).
  • [x] I included enough detail to reproduce or investigate the problem.

Area

apps/server, apps/web, apps/mobile (Usage & Subscription Limits / ACP Registry Kimi provider)

Problem

When using Kimi (acpRegistry_kimi_cli / Kimi Code CLI 2.4.1 or ACP Registry kimi 1.52.0), T3 Code 0.1.6 has no Usage Limit UI and no Kimi usage integration across three surfaces:

  1. Usage -> Limits (mod+u -> l) completely omits Kimi: Even when acpRegistry_kimi_cli is enabled, installed, and status: "ready", Kimi does not appear in Subscription Limits at all — neither live rolling quota bars (5-hour window, 7-day window, monthly code/total quota, and Booster extra-usage wallet) nor even an external Manage usage fallback link (https://www.kimi.com/membership/subscription?tab=quota, compare #26381 for Devin).
  2. 5-hour quota exhaustion (HTTP 429) has no usage-limit banner / reset timer / snooze integration: When a Kimi Coding subscription hits its 5-hour rolling window, kimi returns:
    provider.api_error: 429 You've reached your 5-hour usage limit. Your quota will reset when the current 5-hour window ends. To continue now, purchase extra usage or upgrade your plan: https://www.kimi.com/membership/subscription?tab=quota
    
    T3 Code lacks Kimi quota-window awareness for snoozeLimitedThreads / autoResumeLimitedThreads and model-picker out-of-quota indicators.
  3. Usage -> Tokens / Cost omits Kimi local session transcripts: usage-scan-cache-v10.json scans ~/.claude, ~/.codex, ~/.grok, and ~/.pi, but does not scan Kimi Code's ~/.kimi-code/sessions (agents/*/wire.jsonl usage.record events) or legacy ~/.kimi/sessions. (Previous PRs #7936 and #13587 were closed unmerged, and #13587 only targeted claudeAgent relay instances rather than acpRegistry Kimi instances.)

Expected behavior

  1. Usage -> Limits shows Kimi subscription quotas for enabled acpRegistry Kimi instances (supporting both ~/.kimi-code/ for Kimi Code CLI 2.x and ~/.kimi/ for legacy kimi-cli 1.x, plus KIMI_CODE_HOME and both api.kimi.com / api.kimi.ai regions):
    • Kimi Code CLI (packages/oauth/src/managed-usage.ts) queries GET <base_url>/usages (default https://api.kimi.com/coding/v1/usages or https://api.kimi.ai/coding/v1/usages per config.toml [providers."managed:kimi-code"].base_url) with Authorization: Bearer <access_token> (refreshing via refresh_token in credentials/kimi-code.json when expires_at has passed).
    • That endpoint returns structured quota ratios and ISO/string reset timestamps:
      • usages.limit_5h: { used_ratio, reset_time } (5-hour rolling quota)
      • usages.limit_7d: { used_ratio, reset_time } (7-day rolling quota)
      • usages.limit_month_code & usages.limit_month_total: { used_ratio, reset_time }
      • boosterWallet: { balance: { type: "BOOSTER", amount, amountLeft }, monthlyChargeLimit, monthlyUsed, monthlyChargeLimitEnabled }
    • If the OAuth token cannot be read or refreshed, fall back to a Manage usage link pointing to https://www.kimi.com/membership/subscription?tab=quota (or kimi.ai equivalent).
  2. In-thread usage-limit state & auto-resume: Recognize Kimi 429 quota-exhaustion responses and pair them with the limit_5h.reset_time / limit_7d.reset_time window so snoozeLimitedThreads and autoResumeLimitedThreads work cleanly as they do for Claude and Codex.
  3. Token/cost usage scanning: Include ~/.kimi-code/sessions (and ~/.kimi/sessions) in usage transcript scanning.

Version or commit

T3 Code server/desktop 0.1.6

Environment

  • Server: Debian 13 Linux x64 (0.1.6), acpRegistry_kimi_cli pointing to Kimi Code CLI 2.4.1 (~/.kimi-code/bin/kimi)
  • Client: Windows 11 x64 T3 Code Desktop (0.1.6) & mobile

jamesdchen avatar Nov 01 '26 23:11 jamesdchen