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/copilot.js
CHANGED
|
@@ -7,8 +7,9 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { existsSync, readFileSync } from "fs";
|
|
9
9
|
import { join } from "path";
|
|
10
|
+
import { createApiKeyRetryGuard, retryAfterDeadline } from "./api-key-retry-after.js";
|
|
10
11
|
import { sanitizeDisplaySnippet, sanitizeDisplayText } from "./display-sanitize.js";
|
|
11
|
-
import { fetchWithTimeout } from "./http.js";
|
|
12
|
+
import { fetchWithTimeout, RequestTimeoutError } from "./http.js";
|
|
12
13
|
import { readAuthFile } from "./opencode-auth.js";
|
|
13
14
|
import { getOpencodeRuntimeDirs } from "./opencode-runtime-paths.js";
|
|
14
15
|
import { deriveResolvedAuthIdentity } from "./resolved-auth-identity.js";
|
|
@@ -463,6 +464,32 @@ function redactGitHubErrorText(text, secrets) {
|
|
|
463
464
|
}
|
|
464
465
|
return sanitized;
|
|
465
466
|
}
|
|
467
|
+
class CopilotRequestError extends Error {
|
|
468
|
+
failureCategory;
|
|
469
|
+
retryAtMs;
|
|
470
|
+
constructor(message, failureCategory, retryAtMs) {
|
|
471
|
+
super(message);
|
|
472
|
+
this.failureCategory = failureCategory;
|
|
473
|
+
this.retryAtMs = retryAtMs;
|
|
474
|
+
this.name = "CopilotRequestError";
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
function requestFailureCategory(error) {
|
|
478
|
+
return error instanceof CopilotRequestError ? error.failureCategory : "provider_api";
|
|
479
|
+
}
|
|
480
|
+
function requestRetryAtMs(error) {
|
|
481
|
+
if (error instanceof CopilotRequestError)
|
|
482
|
+
return error.retryAtMs;
|
|
483
|
+
return error instanceof RequestTimeoutError ? error.retryAtMs : undefined;
|
|
484
|
+
}
|
|
485
|
+
function preserveRetryAtOnTimeout(error, retryAtMs) {
|
|
486
|
+
return error instanceof RequestTimeoutError &&
|
|
487
|
+
error.retryAtMs === undefined &&
|
|
488
|
+
retryAtMs !== undefined
|
|
489
|
+
? new RequestTimeoutError(error.message, retryAtMs)
|
|
490
|
+
: error;
|
|
491
|
+
}
|
|
492
|
+
const guard = createApiKeyRetryGuard((retryAtMs) => toQuotaError("GitHub API error 429", "provider_api", retryAtMs));
|
|
466
493
|
async function readGitHubRestErrorMessage(response, secrets) {
|
|
467
494
|
const text = await response.text();
|
|
468
495
|
try {
|
|
@@ -480,26 +507,65 @@ async function readGitHubRestErrorMessage(response, secrets) {
|
|
|
480
507
|
}
|
|
481
508
|
return sanitizeDisplaySnippet(redactGitHubErrorText(text, secrets), 160);
|
|
482
509
|
}
|
|
510
|
+
/**
|
|
511
|
+
* Keeps the HTTP status available for classification when the error body
|
|
512
|
+
* cannot be read at all.
|
|
513
|
+
*/
|
|
514
|
+
async function readGitHubRestErrorMessageForClassification(response, secrets) {
|
|
515
|
+
try {
|
|
516
|
+
return await readGitHubRestErrorMessage(response, secrets);
|
|
517
|
+
}
|
|
518
|
+
catch {
|
|
519
|
+
return "response body could not be read";
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* A 429, or a 403 GitHub itself marks as a rate limit (exhausted primary limit
|
|
524
|
+
* or the documented secondary-limit message). Only then is Retry-After read,
|
|
525
|
+
* so a permission 403 never gets a cooldown.
|
|
526
|
+
*/
|
|
527
|
+
function classifyGitHubRateLimit(response, message) {
|
|
528
|
+
const limited = response.status === 429 ||
|
|
529
|
+
(response.status === 403 &&
|
|
530
|
+
(response.headers.get("x-ratelimit-remaining") === "0" ||
|
|
531
|
+
/secondary rate limit/iu.test(message)));
|
|
532
|
+
if (!limited)
|
|
533
|
+
return { limited };
|
|
534
|
+
// retryAfterDeadline only accepts 429; re-present the same headers as one.
|
|
535
|
+
const retryAtMs = retryAfterDeadline(new Response(null, { status: 429, headers: response.headers }));
|
|
536
|
+
return { limited, ...(retryAtMs !== undefined ? { retryAtMs } : {}) };
|
|
537
|
+
}
|
|
483
538
|
async function fetchGitHubRestJson(url, token, requestTimeoutMs) {
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
539
|
+
let observedRetryAtMs;
|
|
540
|
+
try {
|
|
541
|
+
return await fetchWithTimeout(url, {
|
|
542
|
+
request: { headers: buildGitHubRestHeaders(token) },
|
|
543
|
+
timeoutMs: requestTimeoutMs,
|
|
544
|
+
consume: async (response) => {
|
|
545
|
+
if (!response.ok) {
|
|
546
|
+
if (response.status === 403 && response.headers.get("x-ratelimit-remaining") === "0") {
|
|
547
|
+
// Snapshot a confirmed primary limit before its body can stall.
|
|
548
|
+
observedRetryAtMs = classifyGitHubRateLimit(response, "").retryAtMs;
|
|
549
|
+
}
|
|
550
|
+
const message = await readGitHubRestErrorMessageForClassification(response, [token]);
|
|
551
|
+
const limit = classifyGitHubRateLimit(response, message);
|
|
552
|
+
const rateLimit = response.status === 403 && limit.limited ? " (GitHub API rate limit exhausted)" : "";
|
|
553
|
+
throw new CopilotRequestError(`GitHub API error ${response.status}: ${message}${rateLimit}`, response.status === 401 || (response.status === 403 && !limit.limited)
|
|
554
|
+
? "credentials"
|
|
555
|
+
: "provider_api", limit.retryAtMs);
|
|
556
|
+
}
|
|
557
|
+
try {
|
|
558
|
+
return (await response.json());
|
|
559
|
+
}
|
|
560
|
+
catch {
|
|
561
|
+
throw new CopilotRequestError("GitHub API returned malformed JSON", "provider_api");
|
|
562
|
+
}
|
|
563
|
+
},
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
catch (error) {
|
|
567
|
+
throw preserveRetryAtOnTimeout(error, observedRetryAtMs);
|
|
568
|
+
}
|
|
503
569
|
}
|
|
504
570
|
async function resolveGitHubUsername(apiBaseUrl, token, requestTimeoutMs) {
|
|
505
571
|
const response = await fetchGitHubRestJson(`${apiBaseUrl}/user`, token, requestTimeoutMs);
|
|
@@ -764,6 +830,12 @@ async function fetchApplicableBudget(params) {
|
|
|
764
830
|
authority: percentRemaining === undefined ? "provider_reported" : "locally_derived",
|
|
765
831
|
};
|
|
766
832
|
}
|
|
833
|
+
// Separate from the usage guard: a limited budget report must not block usage.
|
|
834
|
+
const budgetGuard = createApiKeyRetryGuard((retryAtMs) => ({
|
|
835
|
+
success: false,
|
|
836
|
+
error: `GitHub API error 429: budget report rate limited until ${new Date(retryAtMs).toISOString()}`,
|
|
837
|
+
retryAtMs,
|
|
838
|
+
}));
|
|
767
839
|
function makeBudgetWarning(error) {
|
|
768
840
|
const message = error instanceof Error ? error.message : String(error);
|
|
769
841
|
return `AI Credit usage loaded, but the budget report failed: ${message}`;
|
|
@@ -774,18 +846,33 @@ async function toAiCreditResult(params) {
|
|
|
774
846
|
let budget;
|
|
775
847
|
const warnings = [];
|
|
776
848
|
if (params.target.scope !== "user") {
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
849
|
+
const target = params.target;
|
|
850
|
+
const fetched = await budgetGuard(`budget\0${params.apiBaseUrl}\0${params.token}`, async () => {
|
|
851
|
+
try {
|
|
852
|
+
return {
|
|
853
|
+
success: true,
|
|
854
|
+
budget: await fetchApplicableBudget({
|
|
855
|
+
apiBaseUrl: params.apiBaseUrl,
|
|
856
|
+
token: params.token,
|
|
857
|
+
target,
|
|
858
|
+
spentUsd: totals.billedAmountUsd,
|
|
859
|
+
requestTimeoutMs: params.requestTimeoutMs,
|
|
860
|
+
}),
|
|
861
|
+
};
|
|
862
|
+
}
|
|
863
|
+
catch (error) {
|
|
864
|
+
const retryAtMs = requestRetryAtMs(error);
|
|
865
|
+
return {
|
|
866
|
+
success: false,
|
|
867
|
+
error: error instanceof Error ? error.message : String(error),
|
|
868
|
+
...(retryAtMs !== undefined ? { retryAtMs } : {}),
|
|
869
|
+
};
|
|
870
|
+
}
|
|
871
|
+
}, params.requestTimeoutMs, undefined, JSON.stringify({ target, spentUsd: totals.billedAmountUsd }));
|
|
872
|
+
if (fetched.success)
|
|
873
|
+
budget = fetched.budget;
|
|
874
|
+
else
|
|
875
|
+
warnings.push(makeBudgetWarning(new Error(fetched.error)));
|
|
789
876
|
}
|
|
790
877
|
if (params.target.scope === "organization") {
|
|
791
878
|
return {
|
|
@@ -837,8 +924,13 @@ function toLegacyResult(response, config) {
|
|
|
837
924
|
resetTimeIso: getApproxNextResetIso(),
|
|
838
925
|
};
|
|
839
926
|
}
|
|
840
|
-
function toQuotaError(message) {
|
|
841
|
-
return {
|
|
927
|
+
function toQuotaError(message, failureCategory, retryAtMs) {
|
|
928
|
+
return {
|
|
929
|
+
success: false,
|
|
930
|
+
error: message,
|
|
931
|
+
...(failureCategory !== undefined ? { failureCategory } : {}),
|
|
932
|
+
...(retryAtMs !== undefined ? { retryAtMs } : {}),
|
|
933
|
+
};
|
|
842
934
|
}
|
|
843
935
|
function buildCopilotInternalHeaders(token) {
|
|
844
936
|
return {
|
|
@@ -956,27 +1048,42 @@ function parseCopilotInternalUser(response) {
|
|
|
956
1048
|
throw new Error("GitHub Copilot user response did not include a usable quota snapshot");
|
|
957
1049
|
}
|
|
958
1050
|
async function fetchCopilotInternalUser(params) {
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
1051
|
+
let observedRetryAtMs;
|
|
1052
|
+
try {
|
|
1053
|
+
return await fetchWithTimeout(`${params.apiBaseUrl}${COPILOT_INTERNAL_USER_PATH}`, {
|
|
1054
|
+
request: { headers: buildCopilotInternalHeaders(params.token) },
|
|
1055
|
+
timeoutMs: params.requestTimeoutMs,
|
|
1056
|
+
consume: async (response) => {
|
|
1057
|
+
if (!response.ok) {
|
|
1058
|
+
if (response.status === 403 && response.headers.get("x-ratelimit-remaining") === "0") {
|
|
1059
|
+
// Snapshot a confirmed primary limit before its body can stall.
|
|
1060
|
+
observedRetryAtMs = classifyGitHubRateLimit(response, "").retryAtMs;
|
|
1061
|
+
}
|
|
1062
|
+
const message = await readGitHubRestErrorMessageForClassification(response, [
|
|
1063
|
+
params.token,
|
|
1064
|
+
]);
|
|
1065
|
+
const limit = classifyGitHubRateLimit(response, message);
|
|
1066
|
+
throw new CopilotRequestError(`GitHub Copilot API error ${response.status}: ${message}`, response.status === 401 || (response.status === 403 && !limit.limited)
|
|
1067
|
+
? "credentials"
|
|
1068
|
+
: "provider_api", limit.retryAtMs);
|
|
1069
|
+
}
|
|
1070
|
+
let parsed;
|
|
1071
|
+
try {
|
|
1072
|
+
parsed = (await response.json());
|
|
1073
|
+
}
|
|
1074
|
+
catch {
|
|
1075
|
+
throw new CopilotRequestError("GitHub Copilot API returned malformed JSON", "provider_api");
|
|
1076
|
+
}
|
|
1077
|
+
if (!parsed || typeof parsed !== "object") {
|
|
1078
|
+
throw new CopilotRequestError("GitHub Copilot API returned malformed JSON", "provider_api");
|
|
1079
|
+
}
|
|
1080
|
+
return parseCopilotInternalUser(parsed);
|
|
1081
|
+
},
|
|
1082
|
+
});
|
|
1083
|
+
}
|
|
1084
|
+
catch (error) {
|
|
1085
|
+
throw preserveRetryAtOnTimeout(error, observedRetryAtMs);
|
|
1086
|
+
}
|
|
980
1087
|
}
|
|
981
1088
|
/**
|
|
982
1089
|
* Query GitHub Copilot accounting.
|
|
@@ -1001,16 +1108,19 @@ export async function queryCopilotQuota(options = {}) {
|
|
|
1001
1108
|
if (enterpriseHost.error) {
|
|
1002
1109
|
return toQuotaError(`Invalid OpenCode Copilot enterpriseUrl: ${enterpriseHost.error}`);
|
|
1003
1110
|
}
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1111
|
+
const apiBaseUrl = getApiBaseUrl(enterpriseHost.host);
|
|
1112
|
+
return await guard(`oauth\0${apiBaseUrl}\0${token}`, async () => {
|
|
1113
|
+
try {
|
|
1114
|
+
return await fetchCopilotInternalUser({
|
|
1115
|
+
apiBaseUrl,
|
|
1116
|
+
token,
|
|
1117
|
+
requestTimeoutMs: options.requestTimeoutMs,
|
|
1118
|
+
});
|
|
1119
|
+
}
|
|
1120
|
+
catch (error) {
|
|
1121
|
+
return toQuotaError(error instanceof Error ? error.message : String(error), requestFailureCategory(error), requestRetryAtMs(error));
|
|
1122
|
+
}
|
|
1123
|
+
}, options.requestTimeoutMs);
|
|
1014
1124
|
}
|
|
1015
1125
|
const resolved = resolvePatBillingTarget(pat.config);
|
|
1016
1126
|
if (!resolved.target) {
|
|
@@ -1019,29 +1129,32 @@ export async function queryCopilotQuota(options = {}) {
|
|
|
1019
1129
|
const compatibilityError = validatePatTargetCompatibility(resolved.target, pat.tokenKind);
|
|
1020
1130
|
if (compatibilityError)
|
|
1021
1131
|
return toQuotaError(compatibilityError);
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
target: resolved.target,
|
|
1029
|
-
billingModel,
|
|
1030
|
-
requestTimeoutMs: options.requestTimeoutMs,
|
|
1031
|
-
});
|
|
1032
|
-
return billingModel === "legacy_premium_requests"
|
|
1033
|
-
? toLegacyResult(response, pat.config)
|
|
1034
|
-
: await toAiCreditResult({
|
|
1132
|
+
const config = pat.config;
|
|
1133
|
+
const apiBaseUrl = getApiBaseUrl(config.enterpriseUrl);
|
|
1134
|
+
const billingModel = config.billingModel ?? "ai_credits";
|
|
1135
|
+
return await guard(`pat\0${apiBaseUrl}\0${config.token}`, async () => {
|
|
1136
|
+
try {
|
|
1137
|
+
const { response, target } = await fetchBillingUsage({
|
|
1035
1138
|
apiBaseUrl,
|
|
1036
|
-
|
|
1037
|
-
target,
|
|
1038
|
-
|
|
1139
|
+
token: config.token,
|
|
1140
|
+
target: resolved.target,
|
|
1141
|
+
billingModel,
|
|
1039
1142
|
requestTimeoutMs: options.requestTimeoutMs,
|
|
1040
1143
|
});
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1144
|
+
return billingModel === "legacy_premium_requests"
|
|
1145
|
+
? toLegacyResult(response, config)
|
|
1146
|
+
: await toAiCreditResult({
|
|
1147
|
+
apiBaseUrl,
|
|
1148
|
+
response,
|
|
1149
|
+
target,
|
|
1150
|
+
token: config.token,
|
|
1151
|
+
requestTimeoutMs: options.requestTimeoutMs,
|
|
1152
|
+
});
|
|
1153
|
+
}
|
|
1154
|
+
catch (error) {
|
|
1155
|
+
return toQuotaError(error instanceof Error ? error.message : String(error), requestFailureCategory(error), requestRetryAtMs(error));
|
|
1156
|
+
}
|
|
1157
|
+
}, options.requestTimeoutMs, undefined, JSON.stringify({ billingModel, tier: config.tier, target: resolved.target }));
|
|
1045
1158
|
}
|
|
1046
1159
|
export async function resolveCopilotAuthIdentity() {
|
|
1047
1160
|
const pat = readQuotaConfigWithMeta();
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Effective localhost web dashboard switch.
|
|
3
|
+
*
|
|
4
|
+
* The full Native GUI is the primary surface from OpenCode 2.2.1, so the compatibility
|
|
5
|
+
* web transport follows the host version when the canonical key is absent:
|
|
6
|
+
* supported hosts below 2.2.1 keep it on (including 2.2.0), and 2.2.1+ keeps it off.
|
|
7
|
+
* An explicit `dashboard.enabled` value always wins. Missing or unparseable host
|
|
8
|
+
* versions, a malformed canonical file, and an invalid `dashboard.enabled` value
|
|
9
|
+
* all fail closed. The listener itself stays loopback-only at `dashboard.port`.
|
|
10
|
+
*/
|
|
11
|
+
import type { LoadConfigMeta } from "./config.js";
|
|
12
|
+
import { type OpenCodeVersion } from "./opencode-version-core.js";
|
|
13
|
+
export interface DashboardWebPolicyInput {
|
|
14
|
+
/** Canonical `dashboard.enabled` when the key is present and valid. */
|
|
15
|
+
explicitEnabled?: boolean;
|
|
16
|
+
/** Running OpenCode host version; missing or unparseable fails closed. */
|
|
17
|
+
hostVersion?: string | OpenCodeVersion;
|
|
18
|
+
/** A malformed canonical file or an invalid `dashboard.enabled` fails closed. */
|
|
19
|
+
invalidConfig?: boolean;
|
|
20
|
+
}
|
|
21
|
+
/** Explicit config wins; otherwise only a parseable pre-2.2.1 host defaults on. */
|
|
22
|
+
export declare function resolveDashboardWebEnabled(input: DashboardWebPolicyInput): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* The canonical value when the loader actually applied it. The setting-source
|
|
25
|
+
* map is the explicit-presence proof: an absent or invalid value records no
|
|
26
|
+
* source, which keeps the version default in charge.
|
|
27
|
+
*/
|
|
28
|
+
export declare function getDashboardEnabledSetting(config: {
|
|
29
|
+
dashboard?: {
|
|
30
|
+
enabled?: unknown;
|
|
31
|
+
};
|
|
32
|
+
} | null | undefined, meta: Pick<LoadConfigMeta, "settingSources">): boolean | undefined;
|
|
33
|
+
/** A malformed root or an invalid `dashboard.enabled` value must not enable web. */
|
|
34
|
+
export declare function hasInvalidDashboardWebConfig(meta: Pick<LoadConfigMeta, "configIssues">): boolean;
|
|
35
|
+
//# sourceMappingURL=dashboard-web-policy.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { isPreNativeGuiVersion } from "./opencode-version-core.js";
|
|
2
|
+
/** Explicit config wins; otherwise only a parseable pre-2.2.1 host defaults on. */
|
|
3
|
+
export function resolveDashboardWebEnabled(input) {
|
|
4
|
+
if (input.invalidConfig)
|
|
5
|
+
return false;
|
|
6
|
+
if (input.explicitEnabled !== undefined)
|
|
7
|
+
return input.explicitEnabled;
|
|
8
|
+
return isPreNativeGuiVersion(input.hostVersion);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The canonical value when the loader actually applied it. The setting-source
|
|
12
|
+
* map is the explicit-presence proof: an absent or invalid value records no
|
|
13
|
+
* source, which keeps the version default in charge.
|
|
14
|
+
*/
|
|
15
|
+
export function getDashboardEnabledSetting(config, meta) {
|
|
16
|
+
if (meta.settingSources["dashboard.enabled"] === undefined)
|
|
17
|
+
return undefined;
|
|
18
|
+
return config?.dashboard?.enabled === true;
|
|
19
|
+
}
|
|
20
|
+
/** A malformed root or an invalid `dashboard.enabled` value must not enable web. */
|
|
21
|
+
export function hasInvalidDashboardWebConfig(meta) {
|
|
22
|
+
return meta.configIssues.some((issue) => issue.key === "$root" || issue.key === "dashboard.enabled");
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=dashboard-web-policy.js.map
|
package/dist/lib/deepseek.js
CHANGED
|
@@ -4,13 +4,21 @@
|
|
|
4
4
|
* Queries: GET https://api.deepseek.com/user/balance
|
|
5
5
|
* Auth: Bearer token in Authorization header.
|
|
6
6
|
*/
|
|
7
|
+
import { providerFailureCategoryForHttpStatus, } from "../contracts/provider-failure.js";
|
|
7
8
|
import { isCanonicalAccountingDecimal } from "./accounting-format.js";
|
|
9
|
+
import { createApiKeyRetryGuard, retryAfterDeadline } from "./api-key-retry-after.js";
|
|
8
10
|
import { resolveDeepSeekApiKey } from "./deepseek-auth.js";
|
|
9
11
|
import { sanitizeDisplaySnippet, sanitizeDisplayText } from "./display-sanitize.js";
|
|
10
12
|
import { fetchWithTimeout } from "./http.js";
|
|
11
13
|
const DEEPSEEK_BALANCE_URL = "https://api.deepseek.com/user/balance";
|
|
12
14
|
const USER_AGENT = "opencode-quota-gui/1.0";
|
|
13
15
|
const MAX_PARSE_ISSUES = 6;
|
|
16
|
+
const guard = createApiKeyRetryGuard((retryAtMs) => ({
|
|
17
|
+
success: false,
|
|
18
|
+
error: "DeepSeek API error 429",
|
|
19
|
+
failureCategory: "provider_api",
|
|
20
|
+
retryAtMs,
|
|
21
|
+
}));
|
|
14
22
|
function isRecord(value) {
|
|
15
23
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
16
24
|
}
|
|
@@ -62,6 +70,7 @@ function parseDeepSeekBalance(payload) {
|
|
|
62
70
|
return { isAvailable, balanceInfos, parseIssues };
|
|
63
71
|
}
|
|
64
72
|
async function fetchDeepSeekBalance(apiKey, requestTimeoutMs) {
|
|
73
|
+
let responseStatus;
|
|
65
74
|
try {
|
|
66
75
|
return await fetchWithTimeout(DEEPSEEK_BALANCE_URL, {
|
|
67
76
|
request: {
|
|
@@ -73,11 +82,15 @@ async function fetchDeepSeekBalance(apiKey, requestTimeoutMs) {
|
|
|
73
82
|
},
|
|
74
83
|
timeoutMs: requestTimeoutMs,
|
|
75
84
|
consume: async (response) => {
|
|
85
|
+
responseStatus = response.status;
|
|
76
86
|
if (!response.ok) {
|
|
77
|
-
const
|
|
87
|
+
const deadline = retryAfterDeadline(response);
|
|
88
|
+
const text = await response.text().catch(() => "");
|
|
78
89
|
return {
|
|
79
90
|
success: false,
|
|
80
91
|
message: `DeepSeek API error ${response.status}: ${sanitizeDisplaySnippet(text, 120)}`,
|
|
92
|
+
failureCategory: providerFailureCategoryForHttpStatus(response.status),
|
|
93
|
+
...(deadline !== undefined ? { retryAtMs: deadline } : {}),
|
|
81
94
|
};
|
|
82
95
|
}
|
|
83
96
|
return {
|
|
@@ -91,6 +104,9 @@ async function fetchDeepSeekBalance(apiKey, requestTimeoutMs) {
|
|
|
91
104
|
return {
|
|
92
105
|
success: false,
|
|
93
106
|
message: sanitizeDisplayText(err instanceof Error ? err.message : String(err)),
|
|
107
|
+
failureCategory: responseStatus === undefined
|
|
108
|
+
? "provider_api"
|
|
109
|
+
: providerFailureCategoryForHttpStatus(responseStatus),
|
|
94
110
|
};
|
|
95
111
|
}
|
|
96
112
|
}
|
|
@@ -103,16 +119,23 @@ export async function queryDeepSeekBalance(options = {}) {
|
|
|
103
119
|
const resolved = await resolveDeepSeekApiKey();
|
|
104
120
|
if (!resolved)
|
|
105
121
|
return null;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
122
|
+
return guard(resolved.key, async () => {
|
|
123
|
+
const result = await fetchDeepSeekBalance(resolved.key, options.requestTimeoutMs);
|
|
124
|
+
if (!result.success) {
|
|
125
|
+
return {
|
|
126
|
+
success: false,
|
|
127
|
+
error: result.message,
|
|
128
|
+
failureCategory: result.failureCategory,
|
|
129
|
+
...(result.retryAtMs !== undefined ? { retryAtMs: result.retryAtMs } : {}),
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
success: true,
|
|
134
|
+
isAvailable: result.data.isAvailable,
|
|
135
|
+
balanceInfos: result.data.balanceInfos,
|
|
136
|
+
parseIssues: result.data.parseIssues,
|
|
137
|
+
};
|
|
138
|
+
}, options.requestTimeoutMs);
|
|
116
139
|
}
|
|
117
140
|
export { getDeepSeekKeyDiagnostics, hasDeepSeekApiKey as hasDeepSeekApiKeyConfigured, } from "./deepseek-auth.js";
|
|
118
141
|
//# sourceMappingURL=deepseek.js.map
|
|
@@ -103,8 +103,11 @@ export function sanitizeQuotaToastError(error) {
|
|
|
103
103
|
return {
|
|
104
104
|
label: sanitizeDisplayText(error.label),
|
|
105
105
|
message: sanitizeDisplayText(error.message),
|
|
106
|
+
...(error.retryAtMs !== undefined ? { retryAtMs: error.retryAtMs } : {}),
|
|
106
107
|
...(error.retryable === true ? { retryable: true } : {}),
|
|
108
|
+
...(error.failureCategory !== undefined ? { failureCategory: error.failureCategory } : {}),
|
|
107
109
|
...(error.kind ? { kind: error.kind } : {}),
|
|
110
|
+
...(error.sourceId !== undefined ? { sourceId: error.sourceId } : {}),
|
|
108
111
|
};
|
|
109
112
|
}
|
|
110
113
|
export function sanitizeQuotaProviderResult(result) {
|
package/dist/lib/entries.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BankedResetAvailability } from "../contracts/openai-quota.js";
|
|
2
|
+
import type { ProviderFailureCategory } from "../contracts/provider-failure.js";
|
|
2
3
|
import type { QuotaProviderDefinition } from "./quota-providers.js";
|
|
3
4
|
import type { QuotaTelemetryToken } from "./quota-telemetry.js";
|
|
4
5
|
import type { ResolvedAuthIdentity } from "./resolved-auth-identity.js";
|
|
@@ -166,11 +167,15 @@ export declare function cloneAccountingPercentageBasis(basis: AccountingPercenta
|
|
|
166
167
|
export declare function cloneBankedResetAvailability(bankedResets: BankedResetAvailability): BankedResetAvailability;
|
|
167
168
|
export declare function cloneQuotaToastEntry(entry: QuotaToastEntry): QuotaToastEntry;
|
|
168
169
|
export interface QuotaToastError {
|
|
170
|
+
/** Deadline observed in an upstream Retry-After response. */
|
|
171
|
+
retryAtMs?: number;
|
|
169
172
|
/** Short label that will be rendered as "label: message". */
|
|
170
173
|
label: string;
|
|
171
174
|
message: string;
|
|
172
175
|
/** Whether a later refresh may succeed without user action. */
|
|
173
176
|
retryable?: boolean;
|
|
177
|
+
/** Source-assigned safe category; absence means unknown and consumers fail closed. */
|
|
178
|
+
failureCategory?: ProviderFailureCategory;
|
|
174
179
|
/** Intentional diagnostics remain verbose but do not count as compact-status issues. */
|
|
175
180
|
kind?: "intentional-filter";
|
|
176
181
|
/**
|
|
@@ -263,6 +268,11 @@ export interface QuotaProviderResult {
|
|
|
263
268
|
errors: QuotaToastError[];
|
|
264
269
|
/** Additive discovered-account descriptors; absent when no account identity exists. */
|
|
265
270
|
accounts?: readonly QuotaProviderAccount[];
|
|
271
|
+
/**
|
|
272
|
+
* Optional display-only plan for a provider-scope result with no discovered accounts (the Claude CLI
|
|
273
|
+
* login shown alone). Never an identity input and never set beside OpenCode account descriptors.
|
|
274
|
+
*/
|
|
275
|
+
planLabel?: string;
|
|
266
276
|
/** Internal provider diagnostics; not projected into normal presentation/export surfaces. */
|
|
267
277
|
diagnostics?: QuotaProviderDiagnostic[];
|
|
268
278
|
/**
|
|
@@ -279,8 +289,23 @@ export interface QuotaProviderMatchContext {
|
|
|
279
289
|
quotaProviders?: QuotaProviderDefinition[];
|
|
280
290
|
currentProviderID?: string;
|
|
281
291
|
}
|
|
292
|
+
/** Marks a single provider operation as an explicit freshness request. */
|
|
293
|
+
export declare const QUOTA_FORCE_REFRESH: unique symbol;
|
|
282
294
|
export interface QuotaProviderContext {
|
|
295
|
+
/** Ephemeral memoization shared only within one quota refresh operation. */
|
|
296
|
+
operationCache?: Map<symbol, unknown>;
|
|
283
297
|
client: {
|
|
298
|
+
integration?: {
|
|
299
|
+
list: () => Promise<{
|
|
300
|
+
data: Array<{
|
|
301
|
+
id: string;
|
|
302
|
+
connections: Array<{
|
|
303
|
+
type: string;
|
|
304
|
+
method?: string;
|
|
305
|
+
}>;
|
|
306
|
+
}>;
|
|
307
|
+
}>;
|
|
308
|
+
};
|
|
284
309
|
config: {
|
|
285
310
|
providers: () => Promise<{
|
|
286
311
|
data?: {
|
|
@@ -337,6 +362,7 @@ export type QuotaProviderCachePolicy = {
|
|
|
337
362
|
kind: "uncached";
|
|
338
363
|
} | {
|
|
339
364
|
kind: "resolved-auth";
|
|
365
|
+
revalidateWithCycleCache?: true;
|
|
340
366
|
resolveIdentity: (ctx: QuotaProviderContext, cacheContext: QuotaProviderCacheContext) => Promise<ResolvedAuthIdentity | null>;
|
|
341
367
|
};
|
|
342
368
|
export interface QuotaProvider {
|
package/dist/lib/entries.js
CHANGED
|
@@ -83,7 +83,7 @@ export interface FormatResetCountdownOptions {
|
|
|
83
83
|
* Returns a precise-to-minute value like "2d 5h 14m", "3h 45m", or "14m".
|
|
84
84
|
* When reset time is in the past or invalid, returns "reset".
|
|
85
85
|
*/
|
|
86
|
-
export declare function formatResetCountdown(iso?: string, opts?: FormatResetCountdownOptions): string;
|
|
86
|
+
export declare function formatResetCountdown(iso?: string, opts?: FormatResetCountdownOptions, nowMs?: number): string;
|
|
87
87
|
export declare const MAX_RESET_TIME_DECIMALS = 4;
|
|
88
88
|
export declare function isResetTimeDecimals(value: unknown): value is number;
|
|
89
89
|
//# sourceMappingURL=format-utils.d.ts.map
|
package/dist/lib/format-utils.js
CHANGED
|
@@ -158,11 +158,11 @@ const MS_PER_HOUR = 3_600_000;
|
|
|
158
158
|
* Returns a precise-to-minute value like "2d 5h 14m", "3h 45m", or "14m".
|
|
159
159
|
* When reset time is in the past or invalid, returns "reset".
|
|
160
160
|
*/
|
|
161
|
-
export function formatResetCountdown(iso, opts) {
|
|
161
|
+
export function formatResetCountdown(iso, opts, nowMs) {
|
|
162
162
|
if (!iso)
|
|
163
163
|
return opts?.missing ?? "";
|
|
164
164
|
const resetDate = new Date(iso);
|
|
165
|
-
const now = new Date();
|
|
165
|
+
const now = nowMs === undefined ? new Date() : new Date(nowMs);
|
|
166
166
|
const diffMs = resetDate.getTime() - now.getTime();
|
|
167
167
|
if (!Number.isFinite(diffMs) || diffMs <= 0)
|
|
168
168
|
return "reset";
|