Skip to content

feat(oauth): switch the managed usage payload to the quota model - #3787

Merged
liruifengv merged 1 commit into
mainfrom
feat/new-plan-usage
Sep 15, 2026
Merged

liruifengv merged 1 commit into
mainfrom
feat/new-plan-usage

Conversation

@liruifengv

Copy link
Copy Markdown
Collaborator

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 /usages payload switched from absolute used/limit rows to a quota model — a usages map of per-window used_ratio/reset_time entries plus goods_version and 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

  • oauth: parse and fetch the quota model from /usages (ManagedQuota with per-window usedRatio/resetAt entries and the booster wallet); managed-usage.ts keeps the platform URL/provider helpers; toolkit.getManagedUsage returns the quota model. Parsing stays lenient — unknown windows and goods_version pass through unmodeled.
  • agent-core-v2 / node-sdk: IOAuthService.getManagedUsage and the SDK facade return the quota model; oauthProtocol re-exports the camelCase managedUsageResultSchema.
  • kap-server: GET /oauth/usage keeps its path but passes the camelCase quota shape through; the legacy snake_case wire mapping is removed.
  • TUI /usage and /status panels: 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 a kimi X% · code Y% breakdown line. Rendering no longer branches on goods_version.
  • docs: 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/usage contract tests, TUI usage-format and panel suites — all green; typecheck and lint clean.

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: the issue must have a maintainer's /approve).
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

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
@changeset-bot

changeset-bot Bot commented Sep 15, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: efa77d0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Sep 15, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@efa77d0
npx https://pkg.pr.new/@moonshot-ai/kimi-code@efa77d0

commit: efa77d0

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread packages/kap-server/src/routes/oauth.ts Resolved
Comment thread apps/kimi-code/src/tui/commands/info.ts Resolved
@liruifengv
liruifengv merged commit bb0c66a into main Sep 15, 2026
16 checks passed
@liruifengv
liruifengv deleted the feat/new-plan-usage branch September 15, 2026 05:33
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Oct 5, 2026
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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant