opencode-quota-gui 1.2.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +104 -34
- package/dist/contracts/analytics-entity.d.ts +6 -1
- package/dist/contracts/analytics-entity.js +27 -10
- package/dist/contracts/build-identity.js +1 -1
- package/dist/contracts/card-visibility.d.ts +21 -0
- package/dist/contracts/card-visibility.js +19 -0
- package/dist/contracts/dashboard.d.ts +35 -1
- package/dist/contracts/dashboard.js +2 -0
- package/dist/contracts/dto-guards.d.ts +24 -0
- package/dist/contracts/dto-guards.js +594 -0
- package/dist/contracts/openai-quota.d.ts +3 -0
- package/dist/contracts/openai-quota.js +3 -0
- package/dist/contracts/provider-failure.d.ts +18 -0
- package/dist/contracts/provider-failure.js +25 -0
- package/dist/data/modelsdev-temporal.min.json +57 -0
- package/dist/gui/config.d.ts +20 -3
- package/dist/gui/config.js +72 -4
- package/dist/gui/dashboard-errors.d.ts +32 -0
- package/dist/gui/dashboard-errors.js +97 -0
- package/dist/gui/lifecycle.d.ts +47 -12
- package/dist/gui/lifecycle.js +215 -37
- package/dist/gui/primary-quota-windows.d.ts +28 -0
- package/dist/gui/primary-quota-windows.js +149 -0
- package/dist/gui/provider-cards.d.ts +11 -3
- package/dist/gui/provider-cards.js +85 -33
- package/dist/gui/quota-notification-detector.d.ts +151 -0
- package/dist/gui/quota-notification-detector.js +318 -0
- package/dist/gui/quota-notification-observer.d.ts +54 -0
- package/dist/gui/quota-notification-observer.js +412 -0
- package/dist/gui/rpc.d.ts +61 -0
- package/dist/gui/rpc.js +310 -0
- package/dist/gui/server.d.ts +15 -27
- package/dist/gui/server.js +34 -123
- package/dist/gui/snapshot-service.d.ts +34 -5
- package/dist/gui/snapshot-service.js +301 -70
- package/dist/gui/sources.d.ts +1 -1
- package/dist/gui/sources.js +98 -56
- package/dist/gui-experimental.cjs +1761 -0
- package/dist/lib/accounting-format.js +8 -0
- package/dist/lib/alibaba-coding-plan-cli.d.ts +79 -0
- package/dist/lib/alibaba-coding-plan-cli.js +539 -0
- package/dist/lib/anthropic-auth.d.ts +2 -3
- package/dist/lib/anthropic-auth.js +2 -3
- package/dist/lib/anthropic.d.ts +53 -12
- package/dist/lib/anthropic.js +622 -270
- package/dist/lib/api-key-retry-after.d.ts +7 -0
- package/dist/lib/api-key-retry-after.js +62 -0
- package/dist/lib/atomic-json.d.ts +2 -0
- package/dist/lib/atomic-json.js +1 -0
- package/dist/lib/cache-observer-ingestion.d.ts +90 -0
- package/dist/lib/cache-observer-ingestion.js +981 -0
- package/dist/lib/cache-observer.d.ts +138 -0
- package/dist/lib/cache-observer.js +317 -0
- package/dist/lib/canonical-config-lock.d.ts +9 -0
- package/dist/lib/canonical-config-lock.js +36 -0
- package/dist/lib/chutes.js +63 -35
- package/dist/lib/claude-agent-transcript-ttl.d.ts +48 -0
- package/dist/lib/claude-agent-transcript-ttl.js +154 -0
- package/dist/lib/claude-agent-ttl-tracker.d.ts +21 -0
- package/dist/lib/claude-agent-ttl-tracker.js +152 -0
- package/dist/lib/cli-show.js +5 -3
- package/dist/lib/config-write-target.d.ts +1 -1
- package/dist/lib/config-write-target.js +5 -2
- package/dist/lib/config.d.ts +6 -1
- package/dist/lib/config.js +241 -2
- package/dist/lib/copilot.js +198 -85
- package/dist/lib/dashboard-web-policy.d.ts +35 -0
- package/dist/lib/dashboard-web-policy.js +24 -0
- package/dist/lib/deepseek.js +34 -11
- package/dist/lib/display-sanitize.js +3 -0
- package/dist/lib/entries.d.ts +26 -0
- package/dist/lib/entries.js +2 -0
- package/dist/lib/format-utils.d.ts +1 -1
- package/dist/lib/format-utils.js +2 -2
- package/dist/lib/glm-coding-plan.js +102 -68
- package/dist/lib/google-agy.js +147 -24
- package/dist/lib/google-gemini-cli.js +140 -23
- package/dist/lib/http.d.ts +4 -0
- package/dist/lib/http.js +16 -2
- package/dist/lib/init-installer.js +30 -7
- package/dist/lib/kilo.js +63 -55
- package/dist/lib/kimi.js +43 -14
- package/dist/lib/mimo.d.ts +4 -0
- package/dist/lib/mimo.js +45 -1
- package/dist/lib/nanogpt.d.ts +3 -0
- package/dist/lib/nanogpt.js +50 -6
- package/dist/lib/ollama-cloud.d.ts +1 -1
- package/dist/lib/ollama-cloud.js +51 -29
- package/dist/lib/openai.js +90 -40
- package/dist/lib/opencode-auth-sqlite.d.ts +2 -2
- package/dist/lib/opencode-auth-sqlite.js +2 -2
- package/dist/lib/opencode-auth.d.ts +3 -2
- package/dist/lib/opencode-auth.js +8 -1
- package/dist/lib/opencode-config-editor.d.ts +1 -0
- package/dist/lib/opencode-config-editor.js +6 -1
- package/dist/lib/opencode-go.js +53 -5
- package/dist/lib/opencode-version-core.d.ts +23 -0
- package/dist/lib/opencode-version-core.js +49 -0
- package/dist/lib/opencode-version.d.ts +4 -3
- package/dist/lib/opencode-version.js +15 -11
- package/dist/lib/opencode-zen.d.ts +12 -1
- package/dist/lib/opencode-zen.js +98 -12
- package/dist/lib/provider-add.js +5 -2
- package/dist/lib/provider-registration.d.ts +19 -9
- package/dist/lib/provider-registration.js +17 -6
- package/dist/lib/quota-command-format.js +1 -1
- package/dist/lib/quota-exhaustion-projection.d.ts +11 -0
- package/dist/lib/quota-exhaustion-projection.js +25 -0
- package/dist/lib/quota-providers-remote.d.ts +4 -1
- package/dist/lib/quota-providers-remote.js +137 -22
- package/dist/lib/quota-providers.d.ts +1 -1
- package/dist/lib/quota-providers.js +12 -35
- package/dist/lib/quota-render-data.d.ts +6 -0
- package/dist/lib/quota-render-data.js +43 -17
- package/dist/lib/quota-reset-notifications.d.ts +17 -0
- package/dist/lib/quota-reset-notifications.js +11 -2
- package/dist/lib/quota-state-codec.js +19 -1
- package/dist/lib/quota-state.d.ts +7 -1
- package/dist/lib/quota-state.js +208 -34
- package/dist/lib/quota-stats.js +21 -0
- package/dist/lib/quota-status.js +3 -51
- package/dist/lib/scoped-update.d.ts +1 -1
- package/dist/lib/synthetic.js +67 -48
- package/dist/lib/types.d.ts +49 -1
- package/dist/lib/types.js +16 -0
- package/dist/lib/xai.js +64 -24
- package/dist/plugin.d.ts +4 -3
- package/dist/plugin.js +293 -16
- package/dist/provider-logos/NOTICE.md +1 -1
- package/dist/provider-logos/OPENCODE-NOTICE.md +4 -3
- package/dist/providers/alibaba-coding-plan.js +107 -102
- package/dist/providers/alibaba-token-plan.js +17 -0
- package/dist/providers/anthropic.d.ts +12 -3
- package/dist/providers/anthropic.js +71 -219
- package/dist/providers/cache-policies.d.ts +11 -4
- package/dist/providers/cache-policies.js +19 -13
- package/dist/providers/claude-agent.d.ts +19 -0
- package/dist/providers/claude-agent.js +196 -0
- package/dist/providers/copilot.js +12 -2
- package/dist/providers/glm-coding-plan-provider.d.ts +3 -0
- package/dist/providers/glm-coding-plan-provider.js +5 -1
- package/dist/providers/google-account-format.js +2 -0
- package/dist/providers/google-agy.d.ts +6 -5
- package/dist/providers/google-agy.js +55 -17
- package/dist/providers/google-gemini-cli.js +13 -2
- package/dist/providers/kilo.js +10 -1
- package/dist/providers/kimi-code.js +13 -6
- package/dist/providers/mimo.js +9 -2
- package/dist/providers/minimax-coding-plan.js +28 -5
- package/dist/providers/nanogpt.js +4 -0
- package/dist/providers/ollama-cloud.js +3 -0
- package/dist/providers/openai.js +1 -0
- package/dist/providers/opencode-go.js +11 -1
- package/dist/providers/opencode-zen.js +32 -3
- package/dist/providers/openrouter.js +4 -0
- package/dist/providers/quota-providers.js +46 -9
- package/dist/providers/registry.js +2 -0
- package/dist/providers/result-helpers.d.ts +6 -0
- package/dist/providers/result-helpers.js +18 -2
- package/dist/rpc.d.ts +440 -4
- package/dist/rpc.js +507 -2
- package/dist/ui/assets/{index-Cs-nrywz.css → index-BcueIm3Z.css} +1 -1
- package/dist/ui/assets/index-C6qRSoh8.js +10 -0
- package/dist/ui/assets/{popover-DKRrwr_K.js → popover-4bFSvRZ7.js} +1 -1
- package/dist/ui/assets/providers/claude-agent.svg +3 -0
- package/dist/ui/index.html +2 -2
- package/package.json +15 -7
- package/dist/bin/opencode-quota-gui.d.ts.map +0 -1
- package/dist/bin/opencode-quota-gui.js.map +0 -1
- package/dist/contracts/analytics-entity.d.ts.map +0 -1
- package/dist/contracts/analytics-entity.js.map +0 -1
- package/dist/contracts/analytics-temporal.d.ts.map +0 -1
- package/dist/contracts/analytics-temporal.js.map +0 -1
- package/dist/contracts/build-identity.d.ts.map +0 -1
- package/dist/contracts/card-order.d.ts.map +0 -1
- package/dist/contracts/card-order.js.map +0 -1
- package/dist/contracts/collision-safe-key.d.ts.map +0 -1
- package/dist/contracts/collision-safe-key.js.map +0 -1
- package/dist/contracts/dashboard.d.ts.map +0 -1
- package/dist/contracts/dashboard.js.map +0 -1
- package/dist/contracts/guards.d.ts.map +0 -1
- package/dist/contracts/guards.js.map +0 -1
- package/dist/contracts/identity.d.ts.map +0 -1
- package/dist/contracts/identity.js.map +0 -1
- package/dist/contracts/openai-quota.d.ts.map +0 -1
- package/dist/contracts/openai-quota.js.map +0 -1
- package/dist/contracts/ranges.d.ts.map +0 -1
- package/dist/contracts/ranges.js.map +0 -1
- package/dist/contracts/settings.d.ts.map +0 -1
- package/dist/contracts/settings.js.map +0 -1
- package/dist/contracts/temporal.d.ts.map +0 -1
- package/dist/contracts/temporal.js.map +0 -1
- package/dist/contracts/time-zone.d.ts.map +0 -1
- package/dist/contracts/time-zone.js.map +0 -1
- package/dist/gui/aggregation.d.ts.map +0 -1
- package/dist/gui/aggregation.js.map +0 -1
- package/dist/gui/analytics-bridge.d.ts.map +0 -1
- package/dist/gui/analytics-bridge.js.map +0 -1
- package/dist/gui/analytics-engine.d.ts.map +0 -1
- package/dist/gui/analytics-engine.js.map +0 -1
- package/dist/gui/analytics-indexes.d.ts.map +0 -1
- package/dist/gui/analytics-indexes.js.map +0 -1
- package/dist/gui/analytics-model.d.ts.map +0 -1
- package/dist/gui/analytics-model.js.map +0 -1
- package/dist/gui/analytics-pricing-revision.d.ts.map +0 -1
- package/dist/gui/analytics-pricing-revision.js.map +0 -1
- package/dist/gui/analytics-protocol.d.ts.map +0 -1
- package/dist/gui/analytics-protocol.js.map +0 -1
- package/dist/gui/analytics-reader.d.ts.map +0 -1
- package/dist/gui/analytics-reader.js.map +0 -1
- package/dist/gui/analytics-service.d.ts.map +0 -1
- package/dist/gui/analytics-service.js.map +0 -1
- package/dist/gui/analytics-state.d.ts.map +0 -1
- package/dist/gui/analytics-state.js.map +0 -1
- package/dist/gui/analytics-worker-runtime.d.ts.map +0 -1
- package/dist/gui/analytics-worker-runtime.js.map +0 -1
- package/dist/gui/analytics-worker.d.ts.map +0 -1
- package/dist/gui/analytics-worker.js.map +0 -1
- package/dist/gui/config.d.ts.map +0 -1
- package/dist/gui/config.js.map +0 -1
- package/dist/gui/identity.d.ts.map +0 -1
- package/dist/gui/identity.js.map +0 -1
- package/dist/gui/lifecycle.d.ts.map +0 -1
- package/dist/gui/lifecycle.js.map +0 -1
- package/dist/gui/log.d.ts.map +0 -1
- package/dist/gui/log.js.map +0 -1
- package/dist/gui/provider-cards.d.ts.map +0 -1
- package/dist/gui/provider-cards.js.map +0 -1
- package/dist/gui/server.d.ts.map +0 -1
- package/dist/gui/server.js.map +0 -1
- package/dist/gui/settings-file-opener.d.ts.map +0 -1
- package/dist/gui/settings-file-opener.js.map +0 -1
- package/dist/gui/snapshot-service.d.ts.map +0 -1
- package/dist/gui/snapshot-service.js.map +0 -1
- package/dist/gui/sources.d.ts.map +0 -1
- package/dist/gui/sources.js.map +0 -1
- package/dist/gui/sse.d.ts.map +0 -1
- package/dist/gui/sse.js.map +0 -1
- package/dist/gui/temporal-quota-policy-data.d.ts.map +0 -1
- package/dist/gui/temporal-quota-policy-data.js.map +0 -1
- package/dist/gui/temporal-quota-policy.d.ts.map +0 -1
- package/dist/gui/temporal-quota-policy.js.map +0 -1
- package/dist/gui/temporal-status.d.ts.map +0 -1
- package/dist/gui/temporal-status.js.map +0 -1
- package/dist/gui/time-zone.d.ts.map +0 -1
- package/dist/gui/time-zone.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/accounting-format.d.ts.map +0 -1
- package/dist/lib/accounting-format.js.map +0 -1
- package/dist/lib/alibaba-auth.d.ts.map +0 -1
- package/dist/lib/alibaba-auth.js.map +0 -1
- package/dist/lib/alibaba-coding-plan-local-quota.d.ts +0 -47
- package/dist/lib/alibaba-coding-plan-local-quota.d.ts.map +0 -1
- package/dist/lib/alibaba-coding-plan-local-quota.js +0 -146
- package/dist/lib/alibaba-coding-plan-local-quota.js.map +0 -1
- package/dist/lib/alibaba-token-plan.d.ts.map +0 -1
- package/dist/lib/alibaba-token-plan.js.map +0 -1
- package/dist/lib/anthropic-auth.d.ts.map +0 -1
- package/dist/lib/anthropic-auth.js.map +0 -1
- package/dist/lib/anthropic.d.ts.map +0 -1
- package/dist/lib/anthropic.js.map +0 -1
- package/dist/lib/api-key-resolver.d.ts.map +0 -1
- package/dist/lib/api-key-resolver.js.map +0 -1
- package/dist/lib/atomic-json.d.ts.map +0 -1
- package/dist/lib/atomic-json.js.map +0 -1
- package/dist/lib/chutes-config.d.ts.map +0 -1
- package/dist/lib/chutes-config.js.map +0 -1
- package/dist/lib/chutes.d.ts.map +0 -1
- package/dist/lib/chutes.js.map +0 -1
- package/dist/lib/cli-reports.d.ts.map +0 -1
- package/dist/lib/cli-reports.js.map +0 -1
- package/dist/lib/cli-show.d.ts.map +0 -1
- package/dist/lib/cli-show.js.map +0 -1
- package/dist/lib/cli-status.d.ts.map +0 -1
- package/dist/lib/cli-status.js.map +0 -1
- package/dist/lib/command-parsing.d.ts.map +0 -1
- package/dist/lib/command-parsing.js.map +0 -1
- package/dist/lib/config-file-utils.d.ts.map +0 -1
- package/dist/lib/config-file-utils.js.map +0 -1
- package/dist/lib/config-write-target.d.ts.map +0 -1
- package/dist/lib/config-write-target.js.map +0 -1
- package/dist/lib/config.d.ts.map +0 -1
- package/dist/lib/config.js.map +0 -1
- package/dist/lib/copilot.d.ts.map +0 -1
- package/dist/lib/copilot.js.map +0 -1
- package/dist/lib/cursor-detection.d.ts.map +0 -1
- package/dist/lib/cursor-detection.js.map +0 -1
- package/dist/lib/cursor-pricing.d.ts.map +0 -1
- package/dist/lib/cursor-pricing.js.map +0 -1
- package/dist/lib/cursor-usage.d.ts.map +0 -1
- package/dist/lib/cursor-usage.js.map +0 -1
- package/dist/lib/dashboard-visibility.d.ts.map +0 -1
- package/dist/lib/dashboard-visibility.js.map +0 -1
- package/dist/lib/deepseek-auth.d.ts.map +0 -1
- package/dist/lib/deepseek-auth.js.map +0 -1
- package/dist/lib/deepseek.d.ts.map +0 -1
- package/dist/lib/deepseek.js.map +0 -1
- package/dist/lib/display-sanitize.d.ts.map +0 -1
- package/dist/lib/display-sanitize.js.map +0 -1
- package/dist/lib/entries.d.ts.map +0 -1
- package/dist/lib/entries.js.map +0 -1
- package/dist/lib/env-template.d.ts.map +0 -1
- package/dist/lib/env-template.js.map +0 -1
- package/dist/lib/format-utils.d.ts.map +0 -1
- package/dist/lib/format-utils.js.map +0 -1
- package/dist/lib/format.d.ts.map +0 -1
- package/dist/lib/format.js.map +0 -1
- package/dist/lib/glm-coding-plan.d.ts.map +0 -1
- package/dist/lib/glm-coding-plan.js.map +0 -1
- package/dist/lib/google-agy-companion.d.ts.map +0 -1
- package/dist/lib/google-agy-companion.js.map +0 -1
- package/dist/lib/google-agy.d.ts.map +0 -1
- package/dist/lib/google-agy.js.map +0 -1
- package/dist/lib/google-companion-credentials.d.ts.map +0 -1
- package/dist/lib/google-companion-credentials.js.map +0 -1
- package/dist/lib/google-gemini-cli-companion.d.ts.map +0 -1
- package/dist/lib/google-gemini-cli-companion.js.map +0 -1
- package/dist/lib/google-gemini-cli.d.ts.map +0 -1
- package/dist/lib/google-gemini-cli.js.map +0 -1
- package/dist/lib/google-token-cache.d.ts.map +0 -1
- package/dist/lib/google-token-cache.js.map +0 -1
- package/dist/lib/grouped-entry-normalization.d.ts.map +0 -1
- package/dist/lib/grouped-entry-normalization.js.map +0 -1
- package/dist/lib/grouped-header-format.d.ts.map +0 -1
- package/dist/lib/grouped-header-format.js.map +0 -1
- package/dist/lib/gui-config-target.d.ts.map +0 -1
- package/dist/lib/gui-config-target.js.map +0 -1
- package/dist/lib/home-dir-display.d.ts.map +0 -1
- package/dist/lib/home-dir-display.js.map +0 -1
- package/dist/lib/http.d.ts.map +0 -1
- package/dist/lib/http.js.map +0 -1
- package/dist/lib/init-installer.d.ts.map +0 -1
- package/dist/lib/init-installer.js.map +0 -1
- package/dist/lib/jsonc.d.ts.map +0 -1
- package/dist/lib/jsonc.js.map +0 -1
- package/dist/lib/kilo-config.d.ts.map +0 -1
- package/dist/lib/kilo-config.js.map +0 -1
- package/dist/lib/kilo.d.ts.map +0 -1
- package/dist/lib/kilo.js.map +0 -1
- package/dist/lib/kimi-auth.d.ts.map +0 -1
- package/dist/lib/kimi-auth.js.map +0 -1
- package/dist/lib/kimi-endpoints.d.ts.map +0 -1
- package/dist/lib/kimi-endpoints.js.map +0 -1
- package/dist/lib/kimi.d.ts.map +0 -1
- package/dist/lib/kimi.js.map +0 -1
- package/dist/lib/maintainer-announcements.d.ts.map +0 -1
- package/dist/lib/maintainer-announcements.js.map +0 -1
- package/dist/lib/map-with-concurrency.d.ts.map +0 -1
- package/dist/lib/map-with-concurrency.js.map +0 -1
- package/dist/lib/markdown-table.d.ts.map +0 -1
- package/dist/lib/markdown-table.js.map +0 -1
- package/dist/lib/mimo-config.d.ts.map +0 -1
- package/dist/lib/mimo-config.js.map +0 -1
- package/dist/lib/mimo.d.ts.map +0 -1
- package/dist/lib/mimo.js.map +0 -1
- package/dist/lib/minimax-auth.d.ts.map +0 -1
- package/dist/lib/minimax-auth.js.map +0 -1
- package/dist/lib/minimax-endpoints.d.ts.map +0 -1
- package/dist/lib/minimax-endpoints.js.map +0 -1
- package/dist/lib/modelsdev-pricing.d.ts.map +0 -1
- package/dist/lib/modelsdev-pricing.js.map +0 -1
- package/dist/lib/modelsdev-temporal.d.ts.map +0 -1
- package/dist/lib/modelsdev-temporal.js.map +0 -1
- package/dist/lib/nanogpt-config.d.ts.map +0 -1
- package/dist/lib/nanogpt-config.js.map +0 -1
- package/dist/lib/nanogpt.d.ts.map +0 -1
- package/dist/lib/nanogpt.js.map +0 -1
- package/dist/lib/ollama-cloud-config.d.ts.map +0 -1
- package/dist/lib/ollama-cloud-config.js.map +0 -1
- package/dist/lib/ollama-cloud.d.ts.map +0 -1
- package/dist/lib/ollama-cloud.js.map +0 -1
- package/dist/lib/openai.d.ts.map +0 -1
- package/dist/lib/openai.js.map +0 -1
- package/dist/lib/opencode-auth-sqlite.d.ts.map +0 -1
- package/dist/lib/opencode-auth-sqlite.js.map +0 -1
- package/dist/lib/opencode-auth.d.ts.map +0 -1
- package/dist/lib/opencode-auth.js.map +0 -1
- package/dist/lib/opencode-config-editor.d.ts.map +0 -1
- package/dist/lib/opencode-config-editor.js.map +0 -1
- package/dist/lib/opencode-config-providers.d.ts.map +0 -1
- package/dist/lib/opencode-config-providers.js.map +0 -1
- package/dist/lib/opencode-config-read.d.ts.map +0 -1
- package/dist/lib/opencode-config-read.js.map +0 -1
- package/dist/lib/opencode-console-auth.d.ts.map +0 -1
- package/dist/lib/opencode-console-auth.js.map +0 -1
- package/dist/lib/opencode-db-path.d.ts.map +0 -1
- package/dist/lib/opencode-db-path.js.map +0 -1
- package/dist/lib/opencode-go-auth.d.ts.map +0 -1
- package/dist/lib/opencode-go-auth.js.map +0 -1
- package/dist/lib/opencode-go.d.ts.map +0 -1
- package/dist/lib/opencode-go.js.map +0 -1
- package/dist/lib/opencode-runtime-paths.d.ts.map +0 -1
- package/dist/lib/opencode-runtime-paths.js.map +0 -1
- package/dist/lib/opencode-sqlite.d.ts.map +0 -1
- package/dist/lib/opencode-sqlite.js.map +0 -1
- package/dist/lib/opencode-storage.d.ts.map +0 -1
- package/dist/lib/opencode-storage.js.map +0 -1
- package/dist/lib/opencode-version.d.ts.map +0 -1
- package/dist/lib/opencode-version.js.map +0 -1
- package/dist/lib/opencode-zen.d.ts.map +0 -1
- package/dist/lib/opencode-zen.js.map +0 -1
- package/dist/lib/openrouter.d.ts.map +0 -1
- package/dist/lib/openrouter.js.map +0 -1
- package/dist/lib/private-state-paths.d.ts.map +0 -1
- package/dist/lib/private-state-paths.js.map +0 -1
- package/dist/lib/provider-add-command.d.ts.map +0 -1
- package/dist/lib/provider-add-command.js.map +0 -1
- package/dist/lib/provider-add-json-v1-questionnaire.d.ts.map +0 -1
- package/dist/lib/provider-add-json-v1-questionnaire.js.map +0 -1
- package/dist/lib/provider-add.d.ts.map +0 -1
- package/dist/lib/provider-add.js.map +0 -1
- package/dist/lib/provider-availability.d.ts.map +0 -1
- package/dist/lib/provider-availability.js.map +0 -1
- package/dist/lib/provider-metadata.d.ts.map +0 -1
- package/dist/lib/provider-metadata.js.map +0 -1
- package/dist/lib/provider-model-matching.d.ts.map +0 -1
- package/dist/lib/provider-model-matching.js.map +0 -1
- package/dist/lib/provider-registration.d.ts.map +0 -1
- package/dist/lib/provider-registration.js.map +0 -1
- package/dist/lib/quota-accounting-projection.d.ts.map +0 -1
- package/dist/lib/quota-accounting-projection.js.map +0 -1
- package/dist/lib/quota-columns.d.ts.map +0 -1
- package/dist/lib/quota-columns.js.map +0 -1
- package/dist/lib/quota-command-format.d.ts.map +0 -1
- package/dist/lib/quota-command-format.js.map +0 -1
- package/dist/lib/quota-dialog-command-specs.d.ts.map +0 -1
- package/dist/lib/quota-dialog-command-specs.js.map +0 -1
- package/dist/lib/quota-dialog-commands.d.ts.map +0 -1
- package/dist/lib/quota-dialog-commands.js.map +0 -1
- package/dist/lib/quota-entry-display.d.ts.map +0 -1
- package/dist/lib/quota-entry-display.js.map +0 -1
- package/dist/lib/quota-exhaustion-projection.d.ts.map +0 -1
- package/dist/lib/quota-exhaustion-projection.js.map +0 -1
- package/dist/lib/quota-export-types.d.ts.map +0 -1
- package/dist/lib/quota-export-types.js.map +0 -1
- package/dist/lib/quota-export.d.ts.map +0 -1
- package/dist/lib/quota-export.js.map +0 -1
- package/dist/lib/quota-format-style.d.ts.map +0 -1
- package/dist/lib/quota-format-style.js.map +0 -1
- package/dist/lib/quota-providers-local.d.ts.map +0 -1
- package/dist/lib/quota-providers-local.js.map +0 -1
- package/dist/lib/quota-providers-remote.d.ts.map +0 -1
- package/dist/lib/quota-providers-remote.js.map +0 -1
- package/dist/lib/quota-providers.d.ts.map +0 -1
- package/dist/lib/quota-providers.js.map +0 -1
- package/dist/lib/quota-render-data.d.ts.map +0 -1
- package/dist/lib/quota-render-data.js.map +0 -1
- package/dist/lib/quota-report-message.d.ts.map +0 -1
- package/dist/lib/quota-report-message.js.map +0 -1
- package/dist/lib/quota-reset-notifications.d.ts.map +0 -1
- package/dist/lib/quota-reset-notifications.js.map +0 -1
- package/dist/lib/quota-retry-wait.d.ts.map +0 -1
- package/dist/lib/quota-retry-wait.js.map +0 -1
- package/dist/lib/quota-runtime-context.d.ts.map +0 -1
- package/dist/lib/quota-runtime-context.js.map +0 -1
- package/dist/lib/quota-state-codec.d.ts.map +0 -1
- package/dist/lib/quota-state-codec.js.map +0 -1
- package/dist/lib/quota-state.d.ts.map +0 -1
- package/dist/lib/quota-state.js.map +0 -1
- package/dist/lib/quota-stats-format.d.ts.map +0 -1
- package/dist/lib/quota-stats-format.js.map +0 -1
- package/dist/lib/quota-stats.d.ts.map +0 -1
- package/dist/lib/quota-stats.js.map +0 -1
- package/dist/lib/quota-status.d.ts.map +0 -1
- package/dist/lib/quota-status.js.map +0 -1
- package/dist/lib/quota-surface-data.d.ts.map +0 -1
- package/dist/lib/quota-surface-data.js.map +0 -1
- package/dist/lib/quota-telemetry.d.ts.map +0 -1
- package/dist/lib/quota-telemetry.js.map +0 -1
- package/dist/lib/report-document.d.ts.map +0 -1
- package/dist/lib/report-document.js.map +0 -1
- package/dist/lib/resolved-auth-identity.d.ts.map +0 -1
- package/dist/lib/resolved-auth-identity.js.map +0 -1
- package/dist/lib/runtime-provider-ids.d.ts.map +0 -1
- package/dist/lib/runtime-provider-ids.js.map +0 -1
- package/dist/lib/scoped-query-chunks.d.ts.map +0 -1
- package/dist/lib/scoped-query-chunks.js.map +0 -1
- package/dist/lib/scoped-update-migration.d.ts.map +0 -1
- package/dist/lib/scoped-update-migration.js.map +0 -1
- package/dist/lib/scoped-update.d.ts.map +0 -1
- package/dist/lib/scoped-update.js.map +0 -1
- package/dist/lib/session-tokens-format.d.ts.map +0 -1
- package/dist/lib/session-tokens-format.js.map +0 -1
- package/dist/lib/session-tokens.d.ts.map +0 -1
- package/dist/lib/session-tokens.js.map +0 -1
- package/dist/lib/synthetic-config.d.ts.map +0 -1
- package/dist/lib/synthetic-config.js.map +0 -1
- package/dist/lib/synthetic.d.ts.map +0 -1
- package/dist/lib/synthetic.js.map +0 -1
- package/dist/lib/toast-format-grouped.d.ts.map +0 -1
- package/dist/lib/toast-format-grouped.js.map +0 -1
- package/dist/lib/token-buckets.d.ts.map +0 -1
- package/dist/lib/token-buckets.js.map +0 -1
- package/dist/lib/token-cost.d.ts.map +0 -1
- package/dist/lib/token-cost.js.map +0 -1
- package/dist/lib/tui-compact-format.d.ts.map +0 -1
- package/dist/lib/tui-compact-format.js.map +0 -1
- package/dist/lib/tui-panel-state.d.ts.map +0 -1
- package/dist/lib/tui-panel-state.js.map +0 -1
- package/dist/lib/tui-prompt-bar-format.d.ts.map +0 -1
- package/dist/lib/tui-prompt-bar-format.js.map +0 -1
- package/dist/lib/tui-sidebar-format.d.ts.map +0 -1
- package/dist/lib/tui-sidebar-format.js.map +0 -1
- package/dist/lib/types.d.ts.map +0 -1
- package/dist/lib/types.js.map +0 -1
- package/dist/lib/usage-ownership.d.ts.map +0 -1
- package/dist/lib/usage-ownership.js.map +0 -1
- package/dist/lib/version.d.ts.map +0 -1
- package/dist/lib/version.js.map +0 -1
- package/dist/lib/xai.d.ts.map +0 -1
- package/dist/lib/xai.js.map +0 -1
- package/dist/lib/zai-auth.d.ts.map +0 -1
- package/dist/lib/zai-auth.js.map +0 -1
- package/dist/lib/zai.d.ts.map +0 -1
- package/dist/lib/zai.js.map +0 -1
- package/dist/lib/zhipu-auth.d.ts.map +0 -1
- package/dist/lib/zhipu-auth.js.map +0 -1
- package/dist/lib/zhipu.d.ts.map +0 -1
- package/dist/lib/zhipu.js.map +0 -1
- package/dist/plugin.d.ts.map +0 -1
- package/dist/plugin.js.map +0 -1
- package/dist/providers/accounting-decimal.d.ts.map +0 -1
- package/dist/providers/accounting-decimal.js.map +0 -1
- package/dist/providers/alibaba-coding-plan.d.ts.map +0 -1
- package/dist/providers/alibaba-coding-plan.js.map +0 -1
- package/dist/providers/alibaba-token-plan.d.ts.map +0 -1
- package/dist/providers/alibaba-token-plan.js.map +0 -1
- package/dist/providers/anthropic.d.ts.map +0 -1
- package/dist/providers/anthropic.js.map +0 -1
- package/dist/providers/cache-policies.d.ts.map +0 -1
- package/dist/providers/cache-policies.js.map +0 -1
- package/dist/providers/chutes.d.ts.map +0 -1
- package/dist/providers/chutes.js.map +0 -1
- package/dist/providers/copilot.d.ts.map +0 -1
- package/dist/providers/copilot.js.map +0 -1
- package/dist/providers/cursor.d.ts.map +0 -1
- package/dist/providers/cursor.js.map +0 -1
- package/dist/providers/deepseek.d.ts.map +0 -1
- package/dist/providers/deepseek.js.map +0 -1
- package/dist/providers/glm-coding-plan-provider.d.ts.map +0 -1
- package/dist/providers/glm-coding-plan-provider.js.map +0 -1
- package/dist/providers/google-account-format.d.ts.map +0 -1
- package/dist/providers/google-account-format.js.map +0 -1
- package/dist/providers/google-agy.d.ts.map +0 -1
- package/dist/providers/google-agy.js.map +0 -1
- package/dist/providers/google-gemini-cli.d.ts.map +0 -1
- package/dist/providers/google-gemini-cli.js.map +0 -1
- package/dist/providers/kilo.d.ts.map +0 -1
- package/dist/providers/kilo.js.map +0 -1
- package/dist/providers/kimi-code.d.ts.map +0 -1
- package/dist/providers/kimi-code.js.map +0 -1
- package/dist/providers/mimo.d.ts.map +0 -1
- package/dist/providers/mimo.js.map +0 -1
- package/dist/providers/minimax-coding-plan.d.ts.map +0 -1
- package/dist/providers/minimax-coding-plan.js.map +0 -1
- package/dist/providers/nanogpt.d.ts.map +0 -1
- package/dist/providers/nanogpt.js.map +0 -1
- package/dist/providers/ollama-cloud.d.ts.map +0 -1
- package/dist/providers/ollama-cloud.js.map +0 -1
- package/dist/providers/openai.d.ts.map +0 -1
- package/dist/providers/openai.js.map +0 -1
- package/dist/providers/opencode-go.d.ts.map +0 -1
- package/dist/providers/opencode-go.js.map +0 -1
- package/dist/providers/opencode-zen.d.ts.map +0 -1
- package/dist/providers/opencode-zen.js.map +0 -1
- package/dist/providers/openrouter.d.ts.map +0 -1
- package/dist/providers/openrouter.js.map +0 -1
- package/dist/providers/quota-providers.d.ts.map +0 -1
- package/dist/providers/quota-providers.js.map +0 -1
- package/dist/providers/registry.d.ts.map +0 -1
- package/dist/providers/registry.js.map +0 -1
- package/dist/providers/result-helpers.d.ts.map +0 -1
- package/dist/providers/result-helpers.js.map +0 -1
- package/dist/providers/synthetic.d.ts.map +0 -1
- package/dist/providers/synthetic.js.map +0 -1
- package/dist/providers/xai.d.ts.map +0 -1
- package/dist/providers/xai.js.map +0 -1
- package/dist/providers/zai.d.ts.map +0 -1
- package/dist/providers/zai.js.map +0 -1
- package/dist/providers/zhipu.d.ts.map +0 -1
- package/dist/providers/zhipu.js.map +0 -1
- package/dist/rpc.d.ts.map +0 -1
- package/dist/rpc.js.map +0 -1
- package/dist/ui/assets/index-D9lFKhSN.js +0 -9
package/dist/lib/quota-state.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import { readdir, readFile, rm, stat } from "node:fs/promises";
|
|
3
3
|
import { join } from "node:path";
|
|
4
|
+
import { CLAUDE_AGENT_RESETS_ROW_KEY } from "../contracts/openai-quota.js";
|
|
4
5
|
import { writeJsonAtomic } from "./atomic-json.js";
|
|
6
|
+
import { QUOTA_FORCE_REFRESH } from "./entries.js";
|
|
7
|
+
export { QUOTA_FORCE_REFRESH } from "./entries.js";
|
|
5
8
|
import { getGuiPrivateCacheDir } from "./private-state-paths.js";
|
|
6
9
|
import { getQuotaProviderDisplayLabel, isLiveLocalUsageProviderId } from "./provider-metadata.js";
|
|
7
10
|
import { QUOTA_PROVIDERS_AGGREGATE_ID, selectEligibleQuotaProviderDefinitions, } from "./quota-providers.js";
|
|
@@ -12,8 +15,41 @@ const QUOTA_PROVIDER_CACHE_PACKAGE_VERSION_FALLBACK = "unknown";
|
|
|
12
15
|
const QUOTA_PROVIDER_CACHE_DIRNAME = "quota-provider-state";
|
|
13
16
|
const QUOTA_PROVIDER_CACHE_RETENTION_MS = 24 * 60 * 60 * 1000;
|
|
14
17
|
const QUOTA_PROVIDER_CACHE_PRUNE_INTERVAL_MS = 60 * 60 * 1000;
|
|
18
|
+
function isClaudeResetsEntry(entry) {
|
|
19
|
+
return "rowKey" in entry && entry.rowKey === CLAUDE_AGENT_RESETS_ROW_KEY;
|
|
20
|
+
}
|
|
21
|
+
/** Retained (not freshly measured) entries must never carry Claude Agent saved resets. */
|
|
22
|
+
export function withoutClaudeAgentSavedResets(entries) {
|
|
23
|
+
return entries.filter((entry) => !isClaudeResetsEntry(entry));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Cached reads must not show a saved reset past its expiry. Unknown (absent) and explicit-null
|
|
27
|
+
* expiries are kept; once no reset remains the row is dropped.
|
|
28
|
+
*/
|
|
29
|
+
function withoutExpiredClaudeResets(result) {
|
|
30
|
+
if (!result.entries.some(isClaudeResetsEntry))
|
|
31
|
+
return result;
|
|
32
|
+
const nowMs = Date.now();
|
|
33
|
+
const entries = result.entries.flatMap((entry) => {
|
|
34
|
+
if (!isClaudeResetsEntry(entry) || entry.kind !== "value" || !entry.bankedResets)
|
|
35
|
+
return [entry];
|
|
36
|
+
const credits = entry.bankedResets.credits.filter((credit) => typeof credit.expiresAtIso !== "string" || Date.parse(credit.expiresAtIso) > nowMs);
|
|
37
|
+
const availableCount = entry.bankedResets.availableCount - (entry.bankedResets.credits.length - credits.length);
|
|
38
|
+
return availableCount > 0
|
|
39
|
+
? [
|
|
40
|
+
{
|
|
41
|
+
...entry,
|
|
42
|
+
value: `${availableCount} available`,
|
|
43
|
+
bankedResets: { availableCount, credits },
|
|
44
|
+
},
|
|
45
|
+
]
|
|
46
|
+
: [];
|
|
47
|
+
});
|
|
48
|
+
return { ...result, entries };
|
|
49
|
+
}
|
|
15
50
|
const inMemoryCache = new Map();
|
|
16
51
|
const inFlightByKey = new Map();
|
|
52
|
+
const refreshByKey = new Map();
|
|
17
53
|
let processLocalLatestByRuntime = new WeakMap();
|
|
18
54
|
let lastPruneAtMs = 0;
|
|
19
55
|
export function buildQuotaProviderStateCacheKey(providerId, ctx, options = {}) {
|
|
@@ -187,6 +223,19 @@ async function resolveProviderCacheScope(provider, ctx, cacheContext) {
|
|
|
187
223
|
return null;
|
|
188
224
|
}
|
|
189
225
|
}
|
|
226
|
+
/** Private, opaque identity for server-side last-good matching; never a DTO field. */
|
|
227
|
+
export async function getQuotaProviderResultScope(provider, ctx) {
|
|
228
|
+
const runtimeEligibleQuotaProviders = await resolveRuntimeEligibleQuotaProviders(provider.id, ctx);
|
|
229
|
+
if (runtimeEligibleQuotaProviders === null)
|
|
230
|
+
return undefined;
|
|
231
|
+
const scope = await resolveProviderCacheScope(provider, ctx, { runtimeEligibleQuotaProviders });
|
|
232
|
+
if (!scope)
|
|
233
|
+
return undefined;
|
|
234
|
+
return getQuotaProviderStateCacheLocator(buildQuotaProviderStateCacheKey(provider.id, ctx, {
|
|
235
|
+
runtimeEligibleQuotaProviders,
|
|
236
|
+
resolvedAuthIdentity: scope.resolvedAuthIdentity,
|
|
237
|
+
}));
|
|
238
|
+
}
|
|
190
239
|
async function isProviderCacheScopeCurrent(provider, ctx, scope) {
|
|
191
240
|
if (provider.cachePolicy?.kind === "account-neutral")
|
|
192
241
|
return true;
|
|
@@ -196,8 +245,7 @@ async function isProviderCacheScopeCurrent(provider, ctx, scope) {
|
|
|
196
245
|
const runtimeEligibleQuotaProviders = await resolveRuntimeEligibleQuotaProviders(provider.id, ctx);
|
|
197
246
|
if (runtimeEligibleQuotaProviders === null)
|
|
198
247
|
return false;
|
|
199
|
-
return ((await provider.cachePolicy.resolveIdentity(ctx, { runtimeEligibleQuotaProviders })) ===
|
|
200
|
-
scope.resolvedAuthIdentity);
|
|
248
|
+
return ((await provider.cachePolicy.resolveIdentity(provider.cachePolicy.revalidateWithCycleCache ? ctx : { ...ctx, operationCache: undefined }, { runtimeEligibleQuotaProviders })) === scope.resolvedAuthIdentity);
|
|
201
249
|
}
|
|
202
250
|
catch {
|
|
203
251
|
return false;
|
|
@@ -207,32 +255,41 @@ function getProcessLocalRuntimeOwner(ctx) {
|
|
|
207
255
|
const owner = ctx.client;
|
|
208
256
|
return owner && (typeof owner === "object" || typeof owner === "function") ? owner : null;
|
|
209
257
|
}
|
|
258
|
+
function buildProcessLocalRouteKey(params) {
|
|
259
|
+
return buildQuotaProviderStateCacheKey(params.provider.id, params.ctx, {
|
|
260
|
+
runtimeEligibleQuotaProviders: params.runtimeEligibleQuotaProviders,
|
|
261
|
+
});
|
|
262
|
+
}
|
|
210
263
|
function rememberProcessLocalLatest(params) {
|
|
211
|
-
const
|
|
212
|
-
if (!
|
|
264
|
+
const owner = getProcessLocalRuntimeOwner(params.ctx);
|
|
265
|
+
if (!owner)
|
|
213
266
|
return;
|
|
214
|
-
let
|
|
215
|
-
if (!
|
|
216
|
-
|
|
217
|
-
processLocalLatestByRuntime.set(
|
|
267
|
+
let runtime = processLocalLatestByRuntime.get(owner);
|
|
268
|
+
if (!runtime) {
|
|
269
|
+
runtime = new WeakMap();
|
|
270
|
+
processLocalLatestByRuntime.set(owner, runtime);
|
|
271
|
+
}
|
|
272
|
+
let routes = runtime.get(params.provider);
|
|
273
|
+
if (!routes) {
|
|
274
|
+
routes = new Map();
|
|
275
|
+
runtime.set(params.provider, routes);
|
|
218
276
|
}
|
|
219
|
-
|
|
277
|
+
routes.set(buildProcessLocalRouteKey(params), {
|
|
220
278
|
result: cloneQuotaProviderResult(params.result),
|
|
221
279
|
timestamp: Date.now(),
|
|
222
280
|
});
|
|
223
281
|
}
|
|
224
282
|
function readProcessLocalLatest(params) {
|
|
225
|
-
const
|
|
226
|
-
if (!
|
|
283
|
+
const owner = getProcessLocalRuntimeOwner(params.ctx);
|
|
284
|
+
if (!owner)
|
|
227
285
|
return { hit: false };
|
|
228
|
-
const entry = processLocalLatestByRuntime
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
result: cloneQuotaProviderResult(entry.result),
|
|
234
|
-
|
|
235
|
-
};
|
|
286
|
+
const entry = processLocalLatestByRuntime
|
|
287
|
+
.get(owner)
|
|
288
|
+
?.get(params.provider)
|
|
289
|
+
?.get(buildProcessLocalRouteKey(params));
|
|
290
|
+
return entry
|
|
291
|
+
? { hit: true, result: cloneQuotaProviderResult(entry.result), timestamp: entry.timestamp }
|
|
292
|
+
: { hit: false };
|
|
236
293
|
}
|
|
237
294
|
function publishQuotaTelemetry(params) {
|
|
238
295
|
if (!params.ctx.config.telemetryToken)
|
|
@@ -250,10 +307,20 @@ function publishQuotaTelemetry(params) {
|
|
|
250
307
|
});
|
|
251
308
|
}
|
|
252
309
|
export async function fetchQuotaProviderResult(params) {
|
|
253
|
-
const { provider,
|
|
310
|
+
const { provider, ttlMs, bypassCache = false } = params;
|
|
311
|
+
const ctx = params.forceRefresh
|
|
312
|
+
? { ...params.ctx, operationCache: new Map(params.ctx.operationCache) }
|
|
313
|
+
: params.ctx;
|
|
314
|
+
if (params.forceRefresh)
|
|
315
|
+
ctx.operationCache.set(QUOTA_FORCE_REFRESH, true);
|
|
254
316
|
const fetchUncached = async (cacheContext = {}) => {
|
|
255
317
|
const snapshot = await fetchValidatedProviderResult(provider, ctx, cacheContext);
|
|
256
|
-
rememberProcessLocalLatest({
|
|
318
|
+
rememberProcessLocalLatest({
|
|
319
|
+
provider,
|
|
320
|
+
ctx,
|
|
321
|
+
result: snapshot,
|
|
322
|
+
runtimeEligibleQuotaProviders: cacheContext.runtimeEligibleQuotaProviders,
|
|
323
|
+
});
|
|
257
324
|
publishQuotaTelemetry({
|
|
258
325
|
ctx,
|
|
259
326
|
providerId: provider.id,
|
|
@@ -275,6 +342,25 @@ export async function fetchQuotaProviderResult(params) {
|
|
|
275
342
|
runtimeEligibleQuotaProviders,
|
|
276
343
|
resolvedAuthIdentity: scope.resolvedAuthIdentity,
|
|
277
344
|
});
|
|
345
|
+
if (params.forceRefresh && !isLiveLocalUsageProviderId(provider.id)) {
|
|
346
|
+
const existing = refreshByKey.get(key);
|
|
347
|
+
if (existing)
|
|
348
|
+
return cloneQuotaProviderResult(await existing);
|
|
349
|
+
const refresh = (async () => {
|
|
350
|
+
// An earlier ordinary request is not a refresh; wait for it to settle
|
|
351
|
+
// before retrying so its result cannot overwrite the newer measurement.
|
|
352
|
+
await inFlightByKey.get(key)?.catch(() => undefined);
|
|
353
|
+
return fetchQuotaProviderResult({ provider, ctx, ttlMs: 0 });
|
|
354
|
+
})();
|
|
355
|
+
refreshByKey.set(key, refresh);
|
|
356
|
+
try {
|
|
357
|
+
return cloneQuotaProviderResult(await refresh);
|
|
358
|
+
}
|
|
359
|
+
finally {
|
|
360
|
+
if (refreshByKey.get(key) === refresh)
|
|
361
|
+
refreshByKey.delete(key);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
278
364
|
if (isLiveLocalUsageProviderId(provider.id)) {
|
|
279
365
|
const snapshot = await fetchValidatedProviderResult(provider, ctx, cacheContext);
|
|
280
366
|
if (!(await isProviderCacheScopeCurrent(provider, ctx, scope))) {
|
|
@@ -308,6 +394,7 @@ export async function fetchQuotaProviderResult(params) {
|
|
|
308
394
|
await maybePrunePersistedQuotaProviderCache(now);
|
|
309
395
|
const inMemory = forceAggregateRefresh ? undefined : inMemoryCache.get(key);
|
|
310
396
|
if (inMemory &&
|
|
397
|
+
!inMemory.stale &&
|
|
311
398
|
inMemory.packageVersion === packageVersion &&
|
|
312
399
|
ttlMs > 0 &&
|
|
313
400
|
now - inMemory.timestamp < ttlMs) {
|
|
@@ -318,10 +405,14 @@ export async function fetchQuotaProviderResult(params) {
|
|
|
318
405
|
result: inMemory.result,
|
|
319
406
|
cacheTimestamp: inMemory.timestamp,
|
|
320
407
|
});
|
|
321
|
-
return cloneQuotaProviderResult(inMemory.result);
|
|
408
|
+
return withoutExpiredClaudeResets(cloneQuotaProviderResult(inMemory.result));
|
|
322
409
|
}
|
|
323
410
|
const inFlight = inFlightByKey.get(key);
|
|
324
411
|
if (inFlight) {
|
|
412
|
+
if (ctx.operationCache?.get(QUOTA_FORCE_REFRESH) === true) {
|
|
413
|
+
await inFlight.catch(() => undefined);
|
|
414
|
+
return fetchQuotaProviderResult({ provider, ctx, ttlMs: 0 });
|
|
415
|
+
}
|
|
325
416
|
const snapshot = await inFlight;
|
|
326
417
|
publishQuotaTelemetry({
|
|
327
418
|
ctx,
|
|
@@ -341,7 +432,7 @@ export async function fetchQuotaProviderResult(params) {
|
|
|
341
432
|
ttlMs,
|
|
342
433
|
now,
|
|
343
434
|
});
|
|
344
|
-
if (persisted) {
|
|
435
|
+
if (persisted && !inMemoryCache.has(key)) {
|
|
345
436
|
inMemoryCache.set(key, {
|
|
346
437
|
...persisted,
|
|
347
438
|
result: cloneQuotaProviderResult(persisted.result),
|
|
@@ -353,10 +444,14 @@ export async function fetchQuotaProviderResult(params) {
|
|
|
353
444
|
result: persisted.result,
|
|
354
445
|
cacheTimestamp: persisted.timestamp,
|
|
355
446
|
});
|
|
356
|
-
return cloneQuotaProviderResult(persisted.result);
|
|
447
|
+
return withoutExpiredClaudeResets(cloneQuotaProviderResult(persisted.result));
|
|
357
448
|
}
|
|
358
449
|
const inFlightAfterDiskRead = inFlightByKey.get(key);
|
|
359
450
|
if (inFlightAfterDiskRead) {
|
|
451
|
+
if (ctx.operationCache?.get(QUOTA_FORCE_REFRESH) === true) {
|
|
452
|
+
await inFlightAfterDiskRead.catch(() => undefined);
|
|
453
|
+
return fetchQuotaProviderResult({ provider, ctx, ttlMs: 0 });
|
|
454
|
+
}
|
|
360
455
|
const snapshot = await inFlightAfterDiskRead;
|
|
361
456
|
publishQuotaTelemetry({
|
|
362
457
|
ctx,
|
|
@@ -368,7 +463,68 @@ export async function fetchQuotaProviderResult(params) {
|
|
|
368
463
|
return cloneQuotaProviderResult(snapshot);
|
|
369
464
|
}
|
|
370
465
|
const fetchPromise = (async () => {
|
|
371
|
-
|
|
466
|
+
let snapshot;
|
|
467
|
+
try {
|
|
468
|
+
snapshot = await fetchValidatedProviderResult(provider, ctx, cacheContext);
|
|
469
|
+
}
|
|
470
|
+
catch (error) {
|
|
471
|
+
if (ctx.operationCache?.get(QUOTA_FORCE_REFRESH) === true) {
|
|
472
|
+
const previous = inMemoryCache.get(key) ??
|
|
473
|
+
(await readPersistedQuotaProviderCacheEntry({
|
|
474
|
+
key,
|
|
475
|
+
providerId: provider.id,
|
|
476
|
+
packageVersion,
|
|
477
|
+
ttlMs,
|
|
478
|
+
now: Date.now(),
|
|
479
|
+
ignoreExpiry: true,
|
|
480
|
+
}));
|
|
481
|
+
if (previous && (await isProviderCacheScopeCurrent(provider, ctx, scope))) {
|
|
482
|
+
inMemoryCache.set(key, {
|
|
483
|
+
...previous,
|
|
484
|
+
stale: true,
|
|
485
|
+
result: {
|
|
486
|
+
...previous.result,
|
|
487
|
+
entries: previous.result.entries.filter((entry) => !isClaudeResetsEntry(entry)),
|
|
488
|
+
},
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
else {
|
|
492
|
+
inMemoryCache.delete(key);
|
|
493
|
+
}
|
|
494
|
+
await safeRm(getQuotaProviderStateCacheFilePath(provider.id, key));
|
|
495
|
+
}
|
|
496
|
+
throw error;
|
|
497
|
+
}
|
|
498
|
+
const rateLimited = snapshot.errors.filter((error) => error.retryAtMs !== undefined);
|
|
499
|
+
const previous = inMemoryCache.get(key);
|
|
500
|
+
if (rateLimited.length > 0 &&
|
|
501
|
+
previous &&
|
|
502
|
+
(await isProviderCacheScopeCurrent(provider, ctx, scope))) {
|
|
503
|
+
const failedAccounts = new Set(rateLimited.map((error) => error.sourceId).filter((id) => id !== undefined));
|
|
504
|
+
const accountsWithFreshEntries = new Set(snapshot.entries
|
|
505
|
+
.map((entry) => entry.accounting.sourceId)
|
|
506
|
+
.filter((id) => id !== undefined));
|
|
507
|
+
// A failed refresh proves neither eligibility nor remaining expiry, so saved resets are
|
|
508
|
+
// never carried over from an earlier snapshot.
|
|
509
|
+
const retained = previous.result.entries.filter((entry) => !isClaudeResetsEntry(entry));
|
|
510
|
+
const fallback = snapshot.entries.length === 0 && rateLimited.some((error) => error.sourceId === undefined)
|
|
511
|
+
? provider.id === "openrouter"
|
|
512
|
+
? retained.filter((entry) => entry.accounting.sourceId === undefined)
|
|
513
|
+
: retained
|
|
514
|
+
: retained.filter((entry) => entry.accounting.sourceId !== undefined &&
|
|
515
|
+
failedAccounts.has(entry.accounting.sourceId) &&
|
|
516
|
+
!accountsWithFreshEntries.has(entry.accounting.sourceId));
|
|
517
|
+
if (fallback.length > 0) {
|
|
518
|
+
const stale = { ...snapshot, entries: [...snapshot.entries, ...fallback] };
|
|
519
|
+
inMemoryCache.set(key, {
|
|
520
|
+
...previous,
|
|
521
|
+
stale: true,
|
|
522
|
+
result: cloneQuotaProviderResult(stale),
|
|
523
|
+
});
|
|
524
|
+
await safeRm(getQuotaProviderStateCacheFilePath(provider.id, key));
|
|
525
|
+
return stale;
|
|
526
|
+
}
|
|
527
|
+
}
|
|
372
528
|
if (!snapshot.attempted ||
|
|
373
529
|
snapshot.entries.length === 0 ||
|
|
374
530
|
!(await isProviderCacheScopeCurrent(provider, ctx, scope))) {
|
|
@@ -383,6 +539,11 @@ export async function fetchQuotaProviderResult(params) {
|
|
|
383
539
|
timestamp: Date.now(),
|
|
384
540
|
result: snapshot,
|
|
385
541
|
});
|
|
542
|
+
if (snapshot.errors.some((error) => error.kind !== "intentional-filter")) {
|
|
543
|
+
inMemoryCache.set(key, { ...entry, stale: true, result: cloneQuotaProviderResult(snapshot) });
|
|
544
|
+
await safeRm(getQuotaProviderStateCacheFilePath(provider.id, key));
|
|
545
|
+
return snapshot;
|
|
546
|
+
}
|
|
386
547
|
inMemoryCache.set(key, {
|
|
387
548
|
...entry,
|
|
388
549
|
result: cloneQuotaProviderResult(entry.result),
|
|
@@ -407,12 +568,17 @@ export async function readCachedProviderResult(params) {
|
|
|
407
568
|
const runtimeEligibleQuotaProviders = await resolveRuntimeEligibleQuotaProviders(params.provider.id, params.ctx);
|
|
408
569
|
if (runtimeEligibleQuotaProviders === null)
|
|
409
570
|
return { hit: false };
|
|
571
|
+
if (runtimeEligibleQuotaProviders?.length === 0)
|
|
572
|
+
return { hit: false };
|
|
410
573
|
const cacheContext = { runtimeEligibleQuotaProviders };
|
|
411
574
|
const scope = await resolveProviderCacheScope(params.provider, params.ctx, cacheContext);
|
|
412
575
|
if (!scope) {
|
|
576
|
+
if (params.provider.cachePolicy?.kind === "resolved-auth")
|
|
577
|
+
return { hit: false };
|
|
413
578
|
return readProcessLocalLatest({
|
|
414
579
|
provider: params.provider,
|
|
415
580
|
ctx: params.ctx,
|
|
581
|
+
runtimeEligibleQuotaProviders,
|
|
416
582
|
});
|
|
417
583
|
}
|
|
418
584
|
const key = buildQuotaProviderStateCacheKey(params.provider.id, params.ctx, {
|
|
@@ -431,7 +597,7 @@ export async function readCachedProviderResult(params) {
|
|
|
431
597
|
});
|
|
432
598
|
return {
|
|
433
599
|
hit: true,
|
|
434
|
-
result: cloneQuotaProviderResult(inMemory.result),
|
|
600
|
+
result: withoutExpiredClaudeResets(cloneQuotaProviderResult(inMemory.result)),
|
|
435
601
|
timestamp: inMemory.timestamp,
|
|
436
602
|
};
|
|
437
603
|
}
|
|
@@ -445,21 +611,28 @@ export async function readCachedProviderResult(params) {
|
|
|
445
611
|
ignoreExpiry: true,
|
|
446
612
|
});
|
|
447
613
|
if (persisted) {
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
614
|
+
if (!(await isProviderCacheScopeCurrent(params.provider, params.ctx, scope))) {
|
|
615
|
+
return { hit: false };
|
|
616
|
+
}
|
|
617
|
+
const current = inMemoryCache.get(key);
|
|
618
|
+
const selected = current ?? persisted;
|
|
619
|
+
if (!current) {
|
|
620
|
+
inMemoryCache.set(key, {
|
|
621
|
+
...persisted,
|
|
622
|
+
result: cloneQuotaProviderResult(persisted.result),
|
|
623
|
+
});
|
|
624
|
+
}
|
|
452
625
|
publishQuotaTelemetry({
|
|
453
626
|
ctx: params.ctx,
|
|
454
627
|
providerId: params.provider.id,
|
|
455
628
|
snapshotId: key,
|
|
456
|
-
result:
|
|
457
|
-
cacheTimestamp:
|
|
629
|
+
result: selected.result,
|
|
630
|
+
cacheTimestamp: selected.timestamp,
|
|
458
631
|
});
|
|
459
632
|
return {
|
|
460
633
|
hit: true,
|
|
461
|
-
result: cloneQuotaProviderResult(
|
|
462
|
-
timestamp:
|
|
634
|
+
result: withoutExpiredClaudeResets(cloneQuotaProviderResult(selected.result)),
|
|
635
|
+
timestamp: selected.timestamp,
|
|
463
636
|
};
|
|
464
637
|
}
|
|
465
638
|
return { hit: false };
|
|
@@ -467,6 +640,7 @@ export async function readCachedProviderResult(params) {
|
|
|
467
640
|
export function __resetQuotaStateForTests() {
|
|
468
641
|
inMemoryCache.clear();
|
|
469
642
|
inFlightByKey.clear();
|
|
643
|
+
refreshByKey.clear();
|
|
470
644
|
processLocalLatestByRuntime = new WeakMap();
|
|
471
645
|
lastPruneAtMs = 0;
|
|
472
646
|
}
|
package/dist/lib/quota-stats.js
CHANGED
|
@@ -95,6 +95,13 @@ function parseModelIdHint(rawModelId) {
|
|
|
95
95
|
* literal instead of deriving nearby versions.
|
|
96
96
|
*/
|
|
97
97
|
const PROVIDER_MODEL_PRICING_ALIASES = {
|
|
98
|
+
// Claude Code Anthropic API family aliases, current list-price estimates only:
|
|
99
|
+
// https://code.claude.com/docs/en/model-config#model-aliases
|
|
100
|
+
anthropic: {
|
|
101
|
+
haiku: "claude-haiku-5-5",
|
|
102
|
+
sonnet: "claude-sonnet-5-5",
|
|
103
|
+
opus: "claude-opus-5-5",
|
|
104
|
+
},
|
|
98
105
|
"opencode-go": {
|
|
99
106
|
"deepseek-v4-flash": "deepseek-v4.1-flash",
|
|
100
107
|
},
|
|
@@ -119,6 +126,7 @@ function resolveExplicitPricingAlias(providerID, ...models) {
|
|
|
119
126
|
return null;
|
|
120
127
|
}
|
|
121
128
|
const SOURCE_PROVIDER_ALIASES = {
|
|
129
|
+
"claude-agent": "anthropic",
|
|
122
130
|
cursor: "cursor",
|
|
123
131
|
"cursor-acp": "cursor",
|
|
124
132
|
"github-copilot": "openai",
|
|
@@ -359,6 +367,19 @@ export function resolvePricingKey(source) {
|
|
|
359
367
|
method: "source_provider",
|
|
360
368
|
};
|
|
361
369
|
}
|
|
370
|
+
// Family aliases require an Anthropic source and its concrete price; do not
|
|
371
|
+
// infer another route from an alias or from an Anthropic model prefix alone.
|
|
372
|
+
if ((sourceProviderHint === "anthropic" || modelProviderHint === "anthropic") &&
|
|
373
|
+
Object.hasOwn(PROVIDER_MODEL_PRICING_ALIASES.anthropic, normalizedModel)) {
|
|
374
|
+
return {
|
|
375
|
+
ok: false,
|
|
376
|
+
unknown: {
|
|
377
|
+
sourceProviderID: srcProvider,
|
|
378
|
+
sourceModelID: srcModel,
|
|
379
|
+
reason: "missing_provider",
|
|
380
|
+
},
|
|
381
|
+
};
|
|
382
|
+
}
|
|
362
383
|
// Only now run same-provider heuristics (free-suffix stripping, -thinking,
|
|
363
384
|
// Gemini preview, Kimi/Anthropic variants).
|
|
364
385
|
const fromSourceProvider = tryProvider(sourceProviderHint, "source_provider");
|
package/dist/lib/quota-status.js
CHANGED
|
@@ -11,7 +11,6 @@ import { getOpenCodeDbPath } from "./opencode-db-path.js";
|
|
|
11
11
|
import { getOpencodeRuntimeDirs } from "./opencode-runtime-paths.js";
|
|
12
12
|
import { getOpenCodeDbStats } from "./opencode-storage.js";
|
|
13
13
|
import { getQuotaProviderDisplayLabel } from "./provider-metadata.js";
|
|
14
|
-
import { isMaintainedQuotaProviderTuning } from "./quota-providers.js";
|
|
15
14
|
import { aggregateUsage } from "./quota-stats.js";
|
|
16
15
|
import { commandHeading, renderPlainTextReport, } from "./report-document.js";
|
|
17
16
|
import { totalTokenBuckets } from "./token-buckets.js";
|
|
@@ -110,20 +109,6 @@ function appendProviderStatusDetailRows(rows, providerId, probes, keys) {
|
|
|
110
109
|
}
|
|
111
110
|
}
|
|
112
111
|
}
|
|
113
|
-
function findProviderStatusDetail(providerId, key, probes) {
|
|
114
|
-
return getProviderStatusDetails(providerId, probes)?.find((detail) => detail.key === key)?.value;
|
|
115
|
-
}
|
|
116
|
-
function getLiveProbeState(probe) {
|
|
117
|
-
if (!probe)
|
|
118
|
-
return "unavailable";
|
|
119
|
-
if (probe.result.entries.length > 0 && probe.result.errors.length > 0)
|
|
120
|
-
return "partial";
|
|
121
|
-
if (probe.result.entries.length > 0)
|
|
122
|
-
return "success";
|
|
123
|
-
if (probe.result.errors.length > 0)
|
|
124
|
-
return "error";
|
|
125
|
-
return "no_data";
|
|
126
|
-
}
|
|
127
112
|
function appendProviderCompactLiveProbeRows(rows, providerId, probes, availability, homeDir) {
|
|
128
113
|
const provider = availability.find((item) => item.id === providerId);
|
|
129
114
|
if (!provider?.enabled || !provider.available)
|
|
@@ -229,32 +214,6 @@ function createQuotaProvidersSection(params) {
|
|
|
229
214
|
for (const definition of params.definitions) {
|
|
230
215
|
const diagnostic = diagnosticsBySource.get(definition.id);
|
|
231
216
|
const coverage = definition.modelIds ? definition.modelIds.join(",") : "all_models";
|
|
232
|
-
if (definition.mode === "local-estimate" && isMaintainedQuotaProviderTuning(definition)) {
|
|
233
|
-
const probe = findProviderLiveProbe(definition.id, params.probes);
|
|
234
|
-
const statePath = findProviderStatusDetail(definition.id, "local_state_path", params.probes);
|
|
235
|
-
const stateExists = findProviderStatusDetail(definition.id, "local_state_exists", params.probes);
|
|
236
|
-
const stateHealth = findProviderStatusDetail(definition.id, "local_state_health", params.probes);
|
|
237
|
-
const stateVersion = findProviderStatusDetail(definition.id, "local_state_version", params.probes);
|
|
238
|
-
const stateLastUpdate = findProviderStatusDetail(definition.id, "local_state_last_update", params.probes);
|
|
239
|
-
rows.push({
|
|
240
|
-
key: `provider_${definition.id}`,
|
|
241
|
-
value: [
|
|
242
|
-
`provider_id=${definition.providerId}`,
|
|
243
|
-
"mode=local-estimate",
|
|
244
|
-
`coverage=${coverage}`,
|
|
245
|
-
`outcome=${getLiveProbeState(probe)}`,
|
|
246
|
-
`limits=${definition.windows.map((window) => `${window.id}:${window.requestLimit}`).join(",")}`,
|
|
247
|
-
`state_path=${statePath ?? "(none)"}`,
|
|
248
|
-
`state_exists=${stateExists ?? "false"}`,
|
|
249
|
-
`state_health=${stateHealth ?? "missing"}`,
|
|
250
|
-
`state_version=${stateVersion ?? "(none)"}`,
|
|
251
|
-
`state_last_update=${stateLastUpdate ?? "(none)"}`,
|
|
252
|
-
]
|
|
253
|
-
.map((part) => sanitizeSingleLineDisplayText(part))
|
|
254
|
-
.join(" "),
|
|
255
|
-
});
|
|
256
|
-
continue;
|
|
257
|
-
}
|
|
258
217
|
if (definition.mode === "local-estimate") {
|
|
259
218
|
const stateHealth = diagnostic?.stateHealth ?? "missing";
|
|
260
219
|
rows.push({
|
|
@@ -389,7 +348,7 @@ function supportedProviderPricingRow(params) {
|
|
|
389
348
|
return {
|
|
390
349
|
id,
|
|
391
350
|
pricing: "no",
|
|
392
|
-
notes: "
|
|
351
|
+
notes: "official Bailian CLI Coding Plan quota (not token-priced)",
|
|
393
352
|
};
|
|
394
353
|
}
|
|
395
354
|
if (id === "alibaba-token-plan") {
|
|
@@ -565,14 +524,7 @@ export async function buildQuotaStatusReportDocument(params) {
|
|
|
565
524
|
key: "opencode.db",
|
|
566
525
|
value: `path=${dbPath} present=${(await pathExists(dbPath)) ? "true" : "false"} (session and token history)`,
|
|
567
526
|
});
|
|
568
|
-
appendProviderStatusDetailRows(pathsRows, "alibaba-coding-plan", params.providerLiveProbes, new Set([
|
|
569
|
-
"alibaba auth configured",
|
|
570
|
-
"alibaba_api_key_source",
|
|
571
|
-
"alibaba_api_key_checked_paths",
|
|
572
|
-
"alibaba_api_key_credential_database_paths",
|
|
573
|
-
"alibaba_coding_plan",
|
|
574
|
-
"alibaba_auth_error",
|
|
575
|
-
]));
|
|
527
|
+
appendProviderStatusDetailRows(pathsRows, "alibaba-coding-plan", params.providerLiveProbes, new Set(["alibaba_coding_plan_source", "alibaba_coding_plan_cli_status"]));
|
|
576
528
|
sections.push(createKvSection("paths", "paths:", pathsRows));
|
|
577
529
|
// === credential_source ===
|
|
578
530
|
const credentialSource = getCredentialSourceDiagnostics();
|
|
@@ -592,6 +544,7 @@ export async function buildQuotaStatusReportDocument(params) {
|
|
|
592
544
|
for (const [id, providerId] of [
|
|
593
545
|
["openai", "openai"],
|
|
594
546
|
["anthropic", "anthropic"],
|
|
547
|
+
["claude-agent", "claude-agent"],
|
|
595
548
|
]) {
|
|
596
549
|
sections.push(createProviderStatusSection({
|
|
597
550
|
id,
|
|
@@ -605,7 +558,6 @@ export async function buildQuotaStatusReportDocument(params) {
|
|
|
605
558
|
// === cursor ===
|
|
606
559
|
const cursorRows = [];
|
|
607
560
|
appendProviderStatusDetailRows(cursorRows, "cursor", params.providerLiveProbes);
|
|
608
|
-
appendProviderStatusDetailRows(cursorRows, "alibaba-coding-plan", params.providerLiveProbes, new Set(["alibaba coding plan local quota", "alibaba coding plan error"]));
|
|
609
561
|
appendProviderCompactLiveProbeRows(cursorRows, "cursor", params.providerLiveProbes, params.providerAvailability, homeDir);
|
|
610
562
|
sections.push(createKvSection("cursor", "cursor:", cursorRows));
|
|
611
563
|
const alibabaCodingPlanLiveProbeSection = createCompactLiveProbeOnlySection({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ConfigWriteTargetSnapshot } from "./config-write-target.js";
|
|
2
|
-
import {
|
|
2
|
+
import type { OpenCodeMajor } from "./opencode-version-core.js";
|
|
3
3
|
import { type ScopedUpdateManualFinding, type ScopedUpdateSafeAction } from "./scoped-update-migration.js";
|
|
4
4
|
export declare const QUOTA_PACKAGE_NAME = "opencode-quota-gui";
|
|
5
5
|
export declare const LEGACY_QUOTA_PACKAGE_NAME = "@slkiser/opencode-quota";
|