* chore: remove dead/unreferenced files across ui, vscode Remove 59 unused source files (components, hooks, lib utils, stores, barrels, and orphaned vscode github modules) that are not imported by any entry-reachable code. Also drop a stale test mock for the removed execCommands module. Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com> * refactor: remove unused exported symbols (types, functions, consts, hooks) Remove exported symbols whose identifier is referenced nowhere in the repository (verified via repo-wide search), across ui types/contracts, lib utilities, sync layer, stores, and components. Also drop the few imports/private helpers orphaned by these removals. Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com> * refactor: remove more unused exports (desktop, shortcuts, worktree, vscode) Continue removing repo-wide unreferenced exported functions, consts and types across lib/desktop, shortcuts, worktreeSessionCreator, sync, and vscode gitService, with cascading orphaned helpers/imports cleaned up. Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com> * chore: add dead-code cleanup tooling * refactor: checkpoint dead-code cleanup * refactor: remove dead-code suppressions --------- Co-authored-by: Serhii Dziupin <makeittech@users.noreply.github.com> Co-authored-by: Bohdan Triapitsyn <artmore@protonmail.com>
5.9 KiB
5.9 KiB
Quota Module Documentation
Purpose
This module fetches quota and usage signals for supported providers in the web server runtime.
Entrypoints and structure
packages/web/server/lib/quota/index.js: public entrypoint imported bypackages/web/server/index.js.packages/web/server/lib/quota/routes.js: Express route registration for quota endpoints.packages/web/server/lib/quota/providers/index.js: provider registry, configured-provider list, and provider dispatcher.packages/web/server/lib/quota/providers/google/: Google-specific auth, API, and transform modules.packages/web/server/lib/quota/utils/: shared auth, transform, and formatting helpers.
Supported provider IDs (dispatcher)
These provider IDs are currently dispatchable via fetchQuotaForProvider(providerId) in packages/web/server/lib/quota/providers/index.js.
| Provider ID | Display name | Module | Auth aliases/keys |
|---|---|---|---|
claude |
Claude | providers/claude.js |
anthropic, claude |
codex |
Codex | providers/codex.js |
openai, codex, chatgpt |
cursor |
Cursor | providers/cursor.js |
CURSOR_TOKEN / CURSOR_ACCESS_TOKEN, CURSOR_REFRESH_TOKEN, optional token files, or Cursor desktop SQLite DB |
google |
providers/google/index.js |
google, google.oauth, Antigravity accounts file |
|
github-copilot |
GitHub Copilot | providers/copilot.js |
github-copilot, copilot |
github-copilot-addon |
GitHub Copilot Add-on | providers/copilot.js |
github-copilot, copilot |
kimi-for-coding |
Kimi for Coding | providers/kimi.js |
kimi-for-coding, kimi |
nano-gpt |
NanoGPT | providers/nanogpt.js |
nano-gpt, nanogpt, nano_gpt |
openrouter |
OpenRouter | providers/openrouter.js |
openrouter |
zai-coding-plan |
z.ai | providers/zai.js |
zai-coding-plan, zai, z.ai |
zhipuai-coding-plan |
Zhipu AI Coding Plan | providers/zhipuai-coding-plan.js |
zhipuai-coding-plan, zhipuai, zhipu |
minimax-coding-plan |
MiniMax Coding Plan (minimax.io) | providers/minimax-coding-plan.js / providers/minimax-shared.js |
minimax-coding-plan |
minimax-cn-coding-plan |
MiniMax Coding Plan (minimaxi.com) | providers/minimax-cn-coding-plan.js / providers/minimax-shared.js |
minimax-cn-coding-plan |
ollama-cloud |
Ollama Cloud | providers/ollama-cloud.js |
Cookie file at ~/.config/ollama-quota/cookie (raw session cookie string) |
wafer |
Wafer.ai | providers/wafer.js |
wafer, wafer-ai, wafer_ai, wafer.ai |
Internal-only provider module
providers/openai.jsexists for logic parity/reuse but is intentionally not registered for dispatcher ID routing.
Response contract
All providers should return results via shared helpers to preserve API shape:
- Required fields:
providerId,providerName,ok,configured,usage,fetchedAt - Optional field:
error - Unsupported provider requests should return
ok: false,configured: false,error: Unsupported provider
Provider modules must export providerId, providerName, aliases, isConfigured(auth?), and fetchQuota().
fetchQuota() should return a quota result with usage.windows keyed by window name (for example 5h, 7d, daily) and optional provider-specific usage.models data.
Add a new provider (quick steps)
- Choose module shape based on complexity:
- Simple providers: create
packages/web/server/lib/quota/providers/<provider>.js. - Complex providers (multi-source auth, multiple API calls, non-trivial transforms): create
packages/web/server/lib/quota/providers/<provider>/with split modules like Google (index.js,auth.js,api.js,transforms.js).
- Simple providers: create
- Export
providerId,providerName,aliases,isConfigured, andfetchQuota. - Use shared helpers from
packages/web/server/lib/quota/utils/index.js(buildResult,toUsageWindow, auth/conversion helpers) to keep payload shape consistent. - Register the provider in
packages/web/server/lib/quota/providers/index.js. - If needed for direct use, export a named fetcher from
packages/web/server/lib/quota/providers/index.jsandpackages/web/server/lib/quota/index.js. - Update this file with the new provider ID, module path, and alias/auth details.
- Validate with
bun run type-check,bun run lint, andbun run build.
MiniMax M3 / Token Plan migration
In 2025/2026 MiniMax rebranded "Coding Plan" to "Token Plan" alongside the M3 model release. The API underwent breaking changes:
- Endpoint fallback: The provider tries
/v1/token_plan/remains(M3) first, falling back to legacy/v1/api/openplatform/coding_plan/remains. - Field semantics: On the
token_plan/remainsendpoint,current_interval_usage_countreturns remaining quota (not consumed). The provider computesused = total - remainingfor this endpoint. The legacycoding_plan/remainsendpoint retains the old semantics (usage_count = consumed). - Percentage-based plans: Legacy Coding Plan accounts return
current_interval_total_count: 0but includecurrent_interval_remaining_percent. The provider prefers this field when count fields are absent. - model_remains array: Now contains entries for multiple model categories (chat, speech, video, image). The provider selects the chat-model entry by matching
MiniMax-M*, thengeneral/chat/textby name, then any entry with a remaining percent. - Window status: The
current_interval_statusandcurrent_weekly_statusfields indicate whether a window is active. Status3means the window is not applicable for the current plan tier (e.g. legacy plans without weekly limits). The provider omits inactive windows.
Notes for contributors
- Keep provider IDs stable; clients use them directly.
- Avoid adding alias-based dispatch in
fetchQuotaForProvider; dispatch currently expects exact provider IDs. - Keep Google behavior changes isolated and review
providers/google/*together.