Skip to content

feat: add provider usage center - #11611

Merged
kirillk merged 69 commits into
mainfrom
feat/provider-usage-center
Aug 21, 2026
Merged

feat: add provider usage center#11611
kirillk merged 69 commits into
mainfrom
feat/provider-usage-center

Conversation

@lambertjosh

@lambertjosh lambertjosh commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

What changed

Add a secret-free Provider Usage Center shared by the CLI, TUI, SDK, and VS Code profile. Core owns provider detection, normalization, source-scoped caching, in-flight coalescing, stale fallback, and failure isolation.

The provider-plan sources cover Kilo-managed MiniMax subscriptions through Cloud tRPC and direct MiniMax Token Plan credentials configured locally. Kilo Pass remains on the existing profile transport and is presented first in Plans & usage with its paid and free-bonus credits. Kilo-managed plans are labeled KILO GATEWAY; locally configured provider credentials are labeled DIRECT.

Managed MiniMax supports Plus, Max, and Ultra, preserves the unified text/image quota returned by MiniMax, and omits unsupported video-only quota rows. A managed card is detected only when the subscription has an enabled, read-only coding_plan BYOK entry; absent, disabled, user-managed, or unavailable routing metadata produces no managed card or quota request. Personal top-up state appears directly below Balance rather than among provider plans.

Architecture

flowchart LR
  subgraph Sources[Usage sources]
    Config["Local config and auth<br/>MiniMax Global / China credentials"]
    Cloud["Kilo Cloud tRPC<br/>plans, BYOK routing, managed quota"]
    Pass["Existing profile transport<br/>Kilo Pass, balance, top-ups"]
  end

  subgraph Gateway[packages/kilo-gateway]
    Trpc["Cloud tRPC client<br/>safe envelope parsing and projection"]
    Format["Shared window formatting<br/>localized label inputs"]
  end

  subgraph Core[packages/core]
    Detect["provider-usage.ts<br/>source detection and credential resolution"]
    Direct["minimax/usage.ts<br/>independent regional plan queries"]
    Managed["cloud.ts<br/>managed quota normalization"]
    Cache["Location-scoped ProviderUsage service<br/>TTL cache, coalescing, stale fallback,
    failure isolation"]
  end

  subgraph Contract[Public contract]
    Schema["packages/schema<br/>secret-free ProviderUsage schema"]
    Http["packages/opencode HTTP API<br/>GET usage / POST refresh"]
    SDK["packages/sdk<br/>generated typed client"]
  end

  subgraph Clients[User interfaces]
    TUI["CLI TUI Plans & usage<br/>load on open, Ctrl-R refresh"]
    VSCode["VS Code Profile<br/>load on open, Refresh button"]
  end

  Config --> Detect --> Direct --> Cache
  Cloud --> Trpc --> Detect --> Managed --> Cache
  Cache --> Schema --> Http --> SDK
  SDK --> TUI
  SDK --> VSCode
  Format --> TUI
  Format --> VSCode
  Pass -. "unchanged profile path" .-> VSCode
Loading
  • packages/core is the source of truth for plan discovery, provider-specific normalization, and cache behavior.
  • packages/schema is the client boundary: it contains normalized usage and structured periods, never credentials or provider-native payloads.
  • packages/opencode exposes location-scoped read and refresh endpoints; packages/sdk generates the typed transport used by both clients.
  • packages/kilo-vscode invalidates displayed usage on auth, organization, or workspace changes, then reloads only when the profile is open or the user refreshes.
  • Direct MiniMax Global and China configurations remain independent plans and cache cells, even when they use the same credential.

Why

Users need one current-state view of provider plan quota without exposing credentials or coupling clients to provider-specific payloads. Billing history and subscription lifecycle remain in Cloud, organization-scoped Kilo data is skipped, and existing session/model accounting remains separate.

Dependency

Requires Kilo-Org/cloud#4220 for owner-scoped managed MiniMax quota.

@lambertjosh

lambertjosh commented Jun 28, 2026

Copy link
Copy Markdown
Contributor Author

Minimax direct plan:

image

Note was not able to test subscription plan through Cloud, since my accounts don't have one.

lambertjosh and others added 24 commits July 9, 2026 10:28
…enter

# Conflicts:
#	packages/kilo-vscode/src/KiloProvider.ts
#	packages/kilo-vscode/webview-ui/src/components/profile/ProfileView.tsx
#	packages/kilo-vscode/webview-ui/src/types/messages/webview-messages.ts
#	packages/opencode/src/kilocode/server/httpapi/groups/kilocode.ts
#	packages/opencode/src/kilocode/server/httpapi/handlers/kilocode.ts
#	packages/opencode/src/kilocode/server/httpapi/server.ts
#	packages/opencode/test/kilocode/server/httpapi-public.test.ts
#	packages/sdk/js/src/v2/gen/sdk.gen.ts
#	packages/sdk/js/src/v2/gen/types.gen.ts
#	packages/sdk/openapi.json
@lambertjosh

Copy link
Copy Markdown
Contributor Author

New version:
image

@lambertjosh

Copy link
Copy Markdown
Contributor Author

When you don't have a kilo pass subscription:

image

@lambertjosh

Copy link
Copy Markdown
Contributor Author

TUI:
image

Comment thread packages/core/src/kilocode/provider-usage.ts
Comment thread packages/core/test/kilocode-provider-usage-cloud.test.ts
Comment thread packages/kilo-vscode/webview-ui/src/components/profile/ProfileView.tsx Outdated
Comment thread packages/kilo-vscode/webview-ui/src/context/server.tsx Outdated
Comment thread packages/core/src/kilocode/provider-usage.ts
Comment thread packages/core/src/kilocode/provider-usage/minimax/usage.ts Outdated
@kirillk
kirillk merged commit ff74e2e into main Aug 21, 2026
47 of 52 checks passed
@kirillk
kirillk deleted the feat/provider-usage-center branch August 21, 2026 18:29
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.

3 participants