Repository navigation
feat(oauth): switch the managed usage payload to the quota model - #3787
Conversation
The platform /usages payload now serves per-window used ratios (goods_version, a usages map of limit5h/limit7d/monthTotal/monthCode entries with used_ratio/reset_time, and boosterWallet) instead of absolute used/limit rows. - oauth: parse and fetch the quota model; keep the platform helpers - toolkit / agent-core-v2 / node-sdk: getManagedUsage returns the quota - kap-server: /oauth/usage passes the camelCase quota shape through (the legacy snake_case wire is gone) - TUI /usage: plan rows are presence-driven from the quota payload; the monthly row carries a kimi/code breakdown line - docs: server-api reference updated for the new response shape
|
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: efa77d07d0
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Step 5 of the incremental sync to 2.1.1: 14 upstream commits over 230 files. The bulk is the pi-tui re-baseline onto upstream v0.85.1. Upstream's changes in this step, all absorbed: - pi-tui re-baselined on upstream v0.85.1 (MoonshotAI#3780): the native platform modules were consolidated and renamed (darwin-modifiers -> darwin-platform, win32-console-mode -> win32-platform), a Linux/X11 clipboard backend with prebuilds was added, and alt-screen search, autocomplete, editor, input, markdown and the render path were reworked; the native-asset copy scripts and flake.nix follow - the session event bus is sharded by agent id (MoonshotAI#3775) - disposed agent scopes are released from the DI dependency graph (MoonshotAI#3776) - swarm cancellation no longer crashes the CLI (MoonshotAI#3779) - tower mode no longer mistakes newly spawned agents for the previous name (MoonshotAI#3752) - [secondary_model].default_effort fails fast when unsupported (MoonshotAI#3785) - the managed usage payload switched to the quota model (MoonshotAI#3787) - kap-server verifies indexed search results against session sources (MoonshotAI#3631) - web dist synced from code-app (MoonshotAI#3792); docs for the web slash-command table and flat-form skill naming (MoonshotAI#3772, MoonshotAI#3774) Fork behaviour preserved through the re-baseline (pi-tui/UPSTREAM.md): - every `keep` intent card still has a matching per-file diff: the width/grapheme clamps, editor history hooks, multi-root @-completion, inline slash autocomplete, CJK autolink, fullscreen nav fall-through, mouse dispatch (cropped rows, prompt-width clicks, search-field forwarding), and sixel graphics with the startup probe - the fork's image/terminal-image, latex and layout extensions ride on upstream's v0.85.1 baseline - the fork's i18n layer covers the new user-facing strings Verification and the follow-up fixes are recorded in the next commit: the fork's auth-facade test still asserted the pre-quota managed-usage shape, and the node-sdk dts build had lost its i18n specifier rewriting in the 0.42.0 merge (found by this step's root typecheck).
Related Issue
N/A — internal change (no linked issue).
Problem
Plans now come in two generations: the legacy plan (5h + weekly quotas) and the new plan (5h + monthly quotas, split into kimi and code types). The platform
/usagespayload switched from absoluteused/limitrows to a quota model — ausagesmap of per-windowused_ratio/reset_timeentries plusgoods_versionand the booster wallet — so the whole consumption chain needs to speak the new shape, and the UIs need to render monthly quotas with the kimi/code split.What changed
/usages(ManagedQuotawith per-windowusedRatio/resetAtentries and the booster wallet);managed-usage.tskeeps the platform URL/provider helpers;toolkit.getManagedUsagereturns the quota model. Parsing stays lenient — unknown windows andgoods_versionpass through unmodeled.IOAuthService.getManagedUsageand the SDK facade return the quota model;oauthProtocolre-exports the camelCasemanagedUsageResultSchema.GET /oauth/usagekeeps its path but passes the camelCase quota shape through; the legacy snake_case wire mapping is removed./usageand/statuspanels: plan rows are presence-driven — whatever windows the server sends (5h / Weekly / Monthly) get rendered with progress bars and reset hints; the monthly row carries akimi X% · code Y%breakdown line. Rendering no longer branches ongoods_version.server-api.md(en/zh) updated for the new response shape.Tests: oauth parse/fetch/toolkit suites, agent-core-v2 auth suite, kap-server
/oauth/usagecontract tests, TUI usage-format and panel suites — all green; typecheck and lint clean.Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.