55 Commits
Author SHA1 Message Date
Bohdan Triapitsyn a8f0f99c3d fix(quota): normalize OpenCode Go reset timestamps
Go returns ISO reset dates, but the shared usage contract requires numeric timestamps. Convert dates to milliseconds before building usage windows.

Verified all three windows against the live Go API. Added numeric timestamp and partial-window regressions; 14 focused tests, web type-check, lint, and syntax checks pass.
2026-09-09 23:23:22 +03:00
Bohdan Triapitsyn 9ac78eaa9c feat(usage): integrate ClinePass quota provider (#3431)
Add ClinePass across server and VS Code quota paths. Reject malformed windows, preserve valid sibling limits, align credential fallback, and report timeout failures accurately.

Validated 30 server quota tests, 129 VS Code quota tests and VS Code type-check. Oxlint findings are confined to pre-existing VS Code code.
2026-09-09 17:51:39 +03:00
Aleksei Ilin c9bcae5b04 feat(usage): add ClinePass quota provider 2026-09-08 17:02:56 +02:00
Pablo Gonzalez cf02d405c6 fix(quota): drop NeuralWatt key-name valueLabel so allowance windows render percent (#3385) 2026-09-07 20:26:33 +03:00
Maxime Leduc 0e836e7b75 fix(quota): read OpenRouter usage from /api/v1/key (#3411)
The OpenRouter provider called GET /api/v1/credits, which OpenRouter
documents as requiring a management key. Called with a normal inference
key it returns HTTP 200 and {"total_credits":0,"total_usage":0} instead
of an error, so the provider rendered "$0.00 left - $0.00 spent" for a
funded key and the !response.ok guard could never catch it.

Read GET /api/v1/key instead, which is documented as callable with any
valid API key. A key with a spending limit reports its own usage against
that limit in the window named by limit_reset, and a key without one
reports usage_monthly. Window usage is limit - limit_remaining rather
than usage, because usage is all-time and limit_remaining tracks the
current reset window. limit_remaining is also server-computed and
already honors include_byok_in_limit.

Bring the provider up to the deepseek.js standard while here: a 15s
timeout, 401 and 403 mapped to a session-expired message, parse failures
mapped to an invalid-response message, an explicit no-quota-data result,
and the aliases export that quota/DOCUMENTATION.md requires. Add the
missing openrouter.test.js and keep packages/vscode in sync.

Refs #3060
2026-09-07 20:25:11 +03:00
Pablo Gonzalez b238cd7fbc fix: parse ollama cloud cost-based usage windows and credits balance (#3381)
Ollama Cloud's /settings page switched shapes for cost-based plans: parse
the 'Monthly usage $X of $Y used' row as a monthly window with a symmetric
'$X / $Y' money label that reads correctly in both used/remaining display
modes, and surface the Extra usage credits balance as a balance-only
credits_balance window matching the Codex/DeepSeek credits treatment
('Credits Balance' in the UI), omitted when the balance is $0. The VS Code
credential validation accepts the new page shape and the Settings cookie
placeholder shows the two-cookie format. Web and VS Code parsers kept in
sync per quota DOCUMENTATION.md.
2026-09-07 19:25:52 +03:00
Bohdan Triapitsyn b0282b2720 fix(quota): validate Hyper credentials and clean up balance labels
Reject invalid credentials while preserving valid token fallback, parse balances with existing boundary helpers, and keep credit values free of untranslated unit text. Inject auth and HTTP dependencies for focused tests in both runtimes.

Validated web quota and registry tests (35 passed), VS Code quota tests (70 passed), both package type checks and lint, extension build, and changed-line anti-slop checks. Reviewed dead-code output. Live Hyper validation was not run because no API key is available.
2026-09-05 23:26:35 +03:00
Howon Lee 5e7c147785 feat: add Charm Hyper quota provider (#3368) 2026-09-05 23:16:13 +03:00
Bohdan Triapitsyn 85bf0a99de fix: identify OpenCode Go requests by session 2026-09-03 11:49:35 +03:00
Bohdan Triapitsyn da6ab52a65 feat: add exe.dev usage tracking 2026-09-03 11:49:34 +03:00
Jakub Syty 22bd738180 Merge branch 'openchamber:main' into github-usage-rework 2026-08-27 10:06:53 +02:00
Bohdan Triapitsyn c4df01f707 chore(quota): drop the Command Code usage provider
Command Code's official API has no usage endpoints; the old usage source
was the unofficial studio API reached through a now-archived plugin, so
the tile could only ever fail for officially configured users. Removed
across server, shared UI, and the VS Code extension; the provider logo
fallback stays — it serves the model picker, not usage.
2026-08-26 19:29:04 +03:00
Jakub Syty c3cb9ca157 Merge remote-tracking branch 'origin/github-usage-rework' into github-usage-rework 2026-08-26 14:00:20 +02:00
Jakub Syty 06a72fed3b Merge branch 'openchamber:main' into github-usage-rework 2026-08-26 13:58:58 +02:00
Jakub Syty 1459b4b360 Adjust for unlimited plan option 2026-08-26 13:58:31 +02:00
Bohdan Triapitsyn 0d50253efa refactor(integrations): retire unavailable options
Remove retired Command Code, Discord, and Telegram integration entries, search targets, and documentation. Keep Command Code provider usage and logo support available through normalized provider ID aliases.
2026-08-22 01:10:19 +03:00
Jakub Syty a3d20512a0 Refactor application architecture and shared functionality 2026-08-21 10:59:47 +02:00
Bohdan Triapitsyn 3613127e2d fix(quota): support z.ai credit limits 2026-08-20 19:09:13 +03:00
Bohdan Triapitsyn 3326ad0ea8 fix(quota): coalesce provider usage refreshes 2026-08-18 19:13:58 +03:00
Bohdan Triapitsyn 17d08c0395 feat(quota): add Command Code usage tracking 2026-08-18 16:24:02 +03:00
Bohdan Triapitsyn 72cd861eb8 fix(quota): match the Claude Code integration provider to Claude quota
The opencode-claude integration registers its provider as `claude-code`, which
never matched the `claude` quota provider, so the collapsed Usage section in
the work status panel showed no limit for a model from that integration.

Claude windows also reported no duration, leaving the headline to fall back to
whichever row came first instead of the limit that runs out soonest. The
session and weekly windows now carry their length; extra usage stays without
one because it is a monthly spend cap.
2026-08-14 21:07:55 +03:00
Bohdan Triapitsyn b77a30cd88 feat(quota): read Claude plan limits from the Claude Code login
Claude quota only worked when the user had signed into Anthropic through
OpenCode. Credentials are now discovered from Claude Code itself first: the
macOS Keychain entry, then the Linux/WSL credentials file (honouring
CLAUDE_CONFIG_DIR), then OpenCode auth.json, then CLAUDE_CODE_OAUTH_TOKEN.

All sources stay read-only and the OAuth token is never refreshed: Anthropic
allows one live refresh token per client_id, so refreshing here would sign the
user out of Claude Code. Credentials are re-read per request instead, and an
expired token reports that Claude Code needs a sign-in rather than a bare 401.

Usage is now read from the limits[] array, so model-scoped weekly limits work
again after Anthropic stopped populating seven_day_sonnet/seven_day_opus, and
new limit kinds no longer need a code change. Adds extra-usage spend and the
plan name, and holds the last good values through Anthropic's 429s with a
cooldown and an account-keyed cache.
2026-08-14 20:49:59 +03:00
Jakub Syty dcf02f13a1 Align GitHub Copilot quota usage with AI credits 2026-08-14 15:59:33 +02:00
Bohdan Triapitsyn 5917325d49 feat: switch OpenCode Go usage to API
OpenCode Go now reads quota usage with a bearer API key from OpenCode auth.json
Removes the old workspace ID and browser cookie credential flow
Deletes legacy OpenCode Go credential files during upgrade
2026-08-12 01:49:22 +03:00
Henry Moran 543b2a2dd1 feat(usage): add xAI quota reporting
packages/ui/src/components/sections/usage/UsagePage.tsx\n  - What: Show selected configured-provider errors in Usage settings.\n  - Why: Preserve provider-specific failures when another provider succeeds.\n\npackages/ui/src/lib/quota/providers/index.ts\n  - What: Register xAI in shared quota metadata.\n  - Why: Expose xAI across shared usage surfaces.\n\npackages/ui/src/types/quota.ts\n  - What: Add xAI to the quota provider contract.\n  - Why: Allow typed xAI results across runtimes.\n\npackages/vscode/src/opencodeAuth.ts\n  - What: Preserve secure auth-file persistence for refreshed xAI credentials.\n  - Why: Reuse the VS Code auth boundary safely.\n\npackages/vscode/src/quotaProviders.ts\n  - What: Add xAI SuperGrok quota fetching, refresh, parsing, and failure isolation.\n  - Why: Provide VS Code usage parity.\n\npackages/web/server/lib/opencode/auth.js\n  - What: Enforce secure auth directory, auth file, and backup permissions.\n  - Why: Protect refreshed OAuth credentials.\n\npackages/web/server/lib/quota/DOCUMENTATION.md\n  - What: Document the xAI quota provider.\n  - Why: Keep provider ownership documentation current.\n\npackages/web/server/lib/quota/providers/index.js\n  - What: Register the xAI web quota adapter.\n  - Why: Expose xAI through the existing quota route.\n\npackages/web/server/lib/quota/providers/xai.js\n  - What: Add SuperGrok usage fetching, inherited OAuth refresh, strict parsing, and zero/error semantics.\n  - Why: Report xAI billing-period usage without new auth architecture or credentials.
2026-08-04 14:40:44 -07:00
Bohdan Triapitsyn e4fddabb19 fix(quota): normalize DeepSeek timeout errors 2026-08-03 18:42:31 +03:00
Bohdan Triapitsyn 1cc5cfedbb feat: add DeepSeek quota provider #2594 2026-08-03 18:37:31 +03:00
Serhii Dziupin 635a70b24f fix: compute Kimi quota usage from used or remaining field 2026-08-03 16:39:14 +03:00
Howon Lee 2dd3bbfe8e feat: add DeepSeek quota provider 2026-08-03 20:46:32 +09:00
Bohdan Triapitsyn 34aefb731b fix(quota): show all Z.ai usage windows 2026-07-30 00:05:52 +03:00
Joshua 7bfe902089 feat(quota): support OpenAI business-account spend_control in codex quota display (#2403)
* fix(quota): support OpenAI business-account spend_control in codex

Business/enterprise OpenAI accounts return a usage payload with
spend_control.individual_limit instead of rate-limit windows. Keep the
existing primary/secondary/credits blocks unchanged and add a new
spend_limit window that surfaces used_percent and a "used / limit credits"
value label. additional_rate_limits is intentionally ignored.
2026-07-29 18:00:39 +03:00
pablogonzalez e2b0a113b8 feat(quota): add Crof and NeuralWatt quota providers (#2415) 2026-07-26 17:57:53 +03:00
Bohdan Triapitsyn e247343423 fix(quota): derive Codex windows from duration 2026-07-12 23:54:07 +03:00
Bohdan Triapitsyn b09614fd68 refactor(quota): secure managed provider credentials (#2160)
- add shared owner-only credential storage for OpenCode Go, Ollama Cloud, and Cursor
- validate credentials before atomic writes using 0700 directories and 0600 files
- replace provider-specific credential routes with an allowlisted lifecycle API
- stop automatically reading Ollama's legacy cookie file
- stop reading or modifying Cursor's database during regular quota requests
- add explicit one-time Cursor credential import without mutating Cursor storage
- persist refreshed Cursor credentials only in OpenChamber-managed storage
- add Ollama Cloud and Cursor credential controls to provider settings
- preserve OpenCode Go tracking through the shared credential flow
- add VS Code credential management and Cursor quota parity
- reject authentication redirects, enforce request timeouts, and fail on unparseable usage pages
- mask stored secrets in API responses and extend quota security coverage
- update quota provider documentation
2026-07-12 16:21:38 +03:00
Bohdan Triapitsyn 3d90eddcaf feat(quota): add OpenCode Go usage tracking (#2155)
* feat(quota): add OpenCode Go usage tracking

* fix(quota): align OpenCode Go VS Code parsing
2026-07-12 14:48:50 +03:00
Bohdan Triapitsyn 38c9ff77c9 fix: restore CLI and quota provider startup (#1857)
Export ngrok tunnel capabilities for CLI startup
Import Clack spinner/progress helpers used in interactive CLI paths
Restore Google quota provider registry exports
2026-06-27 09:19:24 +03:00
00821700de chore: remove dead code (59 unused files + ~125 unused exports) (#1835)
* 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>
2026-06-26 19:27:53 +03:00
Baruch Vitorino eab8862268 fix(quota): handle MiniMax M3/Token Plan API changes (#1589)
Extract shared MiniMax provider logic into minimax-shared.js factory
module used by both minimax-coding-plan and minimax-cn-coding-plan
as thin wrappers.

Endpoint fallback:
- Try /v1/token_plan/remains (M3/Token Plan) first
- Fall back to legacy /v1/api/openplatform/coding_plan/remains
- fetchEndpoint wrapped in try/catch so network/parse errors
  return null instead of throwing, ensuring fallback always runs

Model selection (pickChatModel):
- Prefer MiniMax-M* entries with non-zero total_count (Token Plan M3)
- Fall back to general/chat/text model names (legacy Coding Plan)
- Fall back to any entry with current_interval_remaining_percent
- Ultimate fallback to model_remains[0]

Usage calculation:
- token_plan endpoint: usage_count = remaining, so used = total - remaining
- coding_plan endpoint: usage_count = consumed (legacy behavior)
- Prefer current_interval_remaining_percent when count fields are zero
  (legacy Coding Plan accounts with percentage-based quotas)
- remains_time used as fallback for window duration (in milliseconds,
  confirmed via live API: 9664502ms = 2.68h in 5h window)

Window status:
- Respect current_weekly_status field: status 3 means the window is
  not applicable for the current plan tier (e.g. legacy plans without
  weekly limits). These windows are omitted from the result.
- Default to active when status field is absent (backward compatible).

Fixes #759 (percentage showing empty/null for legacy Coding Plan
accounts and incorrect percentages for M3/Token Plan accounts).
2026-06-23 11:31:17 +03:00
Bohdan Triapitsyn 3e7d3f85c7 fix: show Cursor plan limit progress
Calculates plan limit usage from remaining balance
Restores the Cursor plan limit progress bar
2026-06-11 02:01:53 +03:00
Bohdan Triapitsyn b46153801b feat: add Cursor usage quota tracking
Adds Cursor as a supported quota provider
Reads Cursor auth from env, token files, or local app data
Improves Cursor usage labels in the UI
2026-06-11 00:16:48 +03:00
Bohdan Triapitsyn eff6f46ad9 feat: improve mobile UX (#1591)
Added a mobile MCP overlay so MCP tools can be opened and managed from the mobile UI without relying on desktop-only dropdown behavior.
Improved mobile session panel touch handling so tapping the status/session area opens the right panel reliably on phones and tablets.
Cleaned up mobile usage provider metadata by removing duplicate rows, hiding unset providers, and showing provider logos consistently.
Added eager loading for provider logos used in mobile usage views to avoid delayed or missing icons when the panel opens.
Refined the mobile update and about flows in OpenChamber settings so release/update information is easier to read on small screens.
Adjusted related layout, header, VS Code layout, command palette, and settings text/localization details needed for the mobile polish.
2026-06-10 12:00:10 +03:00
Lam NguyenandBohdan Triapitsyn 4cfe7c80a3 feat(quota): add Wafer.ai quota provider (#1312)
* feat(quota): add Wafer.ai quota provider

- New provider: wafer.js fetches from https://pass.wafer.ai/v1/inference/quota
- Auth: reads wafer/wafer-ai/wafer_ai keys from auth file
- Timeout: AbortSignal.timeout(15_000) with timeoutSignal.aborted detection
- Response: parses remaining/limit/overage/usedPercent/window_end/plan_tier
- valueLabel: planTier + remaining/limit + overage suffix
- Window: 5h (18000s) via resolveWindowLabel
- Cross-runtime: added to web registry, UI types, VS Code dispatcher

* fix(quota): wafer provider fixes — auth alias, decompression, logo

- Add 'wafer.ai' auth alias to match actual auth key format
- Use 'Accept-Encoding: identity' header to fix Bun fetch
  decompression issue with Cloudflare-backed responses
- Match copilot valueLabel format: 'planTier · X / Y left'
- Add wafer logo alias so Providers and Usage pages resolve
  to the same wafer.ai logo from models.dev

* style(quota): fix indentation of timeoutSignal declaration

* fix(quota): derive window duration from API instead of hardcoding

Compute windowSeconds from window_end - window_start timestamps,
with WAFER_WINDOW_SECONDS (5h) as fallback if timestamps are missing.

---------

Co-authored-by: Bohdan Triapitsyn <artmore@protonmail.com>
2026-05-19 17:29:36 +03:00
Bohdan Triapitsyn 3ac697adc7 fix: remove duplicate Zhipu usage provider
Keeps one Zhipu AI Coding Plan entry in usage settings
Preserves existing Zhipu aliases and config lookup
Removes duplicate backend quota registration
2026-05-19 14:49:03 +03:00
zerone0xandBohdan Triapitsyn 3fbcdbc3dc fix(quota): stop showing misleading OpenRouter percentages (#1127)
* fix(quota): stop showing misleading OpenRouter percentages

Fixes #1085

* fix(quota): clean up OpenRouter credit labels

---------
Co-authored-by: Bohdan Triapitsyn <artmore@protonmail.com>
2026-05-07 23:39:53 +03:00
Xiangfang Chen a3d73a8b67 feat(quota): add Zhipu AI Coding Plan usage tracking (#756)
- Add zhipuai-coding-plan provider for quota monitoring
- Support TOKENS_LIMIT (5-hour window) and TIME_LIMIT (MCP tools monthly)
- Update UI provider list and TypeScript types
- Register provider in server quota registry
2026-04-11 22:15:19 +03:00
nzlov 2af782b4da Update minimax-cn-coding-plan.js (#864)
* Update minimax-cn-coding-plan.js

Signed-off-by: nzlov <wfhtqp@gmail.com>

* Update minimax-cn-coding-plan.js

Signed-off-by: nzlov <wfhtqp@gmail.com>

---------

Signed-off-by: nzlov <wfhtqp@gmail.com>
2026-04-07 14:05:22 +03:00
kalac2232 086cf26cd7 feat: add ZhipuAI provider to quota tracking system (#793) 2026-04-01 09:46:19 +03:00
Baruch Vitorino 060b37777c fix(quota): correct minimax coding plan URL and usage calculation (#796)
* fix(quota): correct minimax coding plan URL and usage calculation

Fixes #759

- Change endpoint from www.minimax.io to api.minimax.io (fixes 403 error)
- Fix usage calculation: use intervalUsage/weeklyUsage directly instead of
  computing remaining (total - usage), which was showing inverted percentage
- Remove minimax-shared.js - providers are now completely independent
- minimax-coding-plan.js: complete provider for minimax.io
- minimax-cn-coding-plan.js: complete provider for minimaxi.com

* Update packages/web/server/lib/quota/providers/minimax-coding-plan.js

Signed-off-by: Baruch Vitorino <9778282+baruchvitorino@users.noreply.github.com>

* Update packages/web/server/lib/quota/providers/minimax-cn-coding-plan.js

Signed-off-by: Baruch Vitorino <9778282+baruchvitorino@users.noreply.github.com>

---------

Signed-off-by: Baruch Vitorino <9778282+baruchvitorino@users.noreply.github.com>
2026-04-01 09:44:58 +03:00
Ariel SandorandAriel Sandor 1f21ab0886 fix(quota): show actual overusage percentage for GitHub Copilot (#805)
Remove the Math.min(100, ...) clamp on usedPercent in the Copilot quota
provider so overusage flows through as the real value (e.g. 353%).
Update formatPercent to display values above 100% instead of clamping,
matching what the GitHub Copilot settings page reports.

The progress bar remains capped at 100% width via its own independent
clampPercent call, so only the label text is affected.

Co-authored-by: Ariel Sandor <39200214+arielsandor@users.noreply.github.com>
2026-04-01 09:39:16 +03:00
nzlovandnzlov a346d3f3da feat: minimax weekly (#719)
* feat: minimax weekly limit

* feat: unify MiniMax quota providers and add weekly usage window

---------

Co-authored-by: nzlov <me@nzlov.com>
2026-03-20 12:37:53 +02:00