opencode-quota-gui 1.2.0 → 1.3.0
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 +90 -30
- package/dist/bin/opencode-quota-gui.js +0 -0
- 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 +27 -0
- package/dist/contracts/dashboard.js +2 -0
- package/dist/contracts/dto-guards.d.ts +24 -0
- package/dist/contracts/dto-guards.js +592 -0
- package/dist/contracts/provider-failure.d.ts +18 -0
- package/dist/contracts/provider-failure.js +25 -0
- package/dist/gui/config.d.ts +20 -3
- package/dist/gui/config.js +42 -3
- package/dist/gui/dashboard-errors.d.ts +32 -0
- package/dist/gui/dashboard-errors.js +97 -0
- package/dist/gui/lifecycle.d.ts +44 -11
- package/dist/gui/lifecycle.js +214 -36
- package/dist/gui/primary-quota-windows.d.ts +28 -0
- package/dist/gui/primary-quota-windows.js +147 -0
- package/dist/gui/provider-cards.d.ts +1 -1
- package/dist/gui/provider-cards.js +40 -16
- package/dist/gui/quota-notification-detector.d.ts +151 -0
- package/dist/gui/quota-notification-detector.js +284 -0
- package/dist/gui/quota-notification-observer.d.ts +55 -0
- package/dist/gui/quota-notification-observer.js +363 -0
- package/dist/gui/rpc.d.ts +59 -0
- package/dist/gui/rpc.js +302 -0
- package/dist/gui/server.d.ts +15 -27
- package/dist/gui/server.js +23 -121
- package/dist/gui/snapshot-service.d.ts +31 -4
- package/dist/gui/snapshot-service.js +177 -54
- package/dist/gui/sources.d.ts +1 -1
- package/dist/gui-experimental.cjs +1756 -0
- package/dist/lib/anthropic.d.ts +5 -0
- package/dist/lib/anthropic.js +18 -1
- package/dist/lib/chutes.js +19 -2
- package/dist/lib/config.d.ts +5 -1
- package/dist/lib/config.js +48 -0
- package/dist/lib/copilot.js +42 -14
- package/dist/lib/dashboard-web-policy.d.ts +35 -0
- package/dist/lib/dashboard-web-policy.js +24 -0
- package/dist/lib/deepseek.js +12 -1
- package/dist/lib/display-sanitize.js +2 -0
- package/dist/lib/entries.d.ts +3 -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 +14 -4
- package/dist/lib/google-agy.js +59 -14
- package/dist/lib/google-gemini-cli.js +58 -14
- package/dist/lib/init-installer.js +25 -4
- package/dist/lib/kilo.js +29 -40
- package/dist/lib/kimi.js +13 -1
- package/dist/lib/mimo.d.ts +2 -0
- package/dist/lib/mimo.js +9 -1
- package/dist/lib/nanogpt.d.ts +2 -0
- package/dist/lib/nanogpt.js +24 -3
- package/dist/lib/ollama-cloud.js +9 -0
- package/dist/lib/openai.js +6 -2
- package/dist/lib/opencode-auth.d.ts +3 -2
- package/dist/lib/opencode-auth.js +8 -1
- package/dist/lib/opencode-go.js +24 -3
- package/dist/lib/opencode-version.d.ts +21 -0
- package/dist/lib/opencode-version.js +53 -5
- package/dist/lib/opencode-zen.d.ts +9 -1
- package/dist/lib/opencode-zen.js +27 -7
- package/dist/lib/quota-providers-remote.d.ts +2 -0
- package/dist/lib/quota-providers-remote.js +78 -19
- 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 +3 -1
- package/dist/lib/synthetic.js +8 -0
- package/dist/lib/types.d.ts +18 -0
- package/dist/lib/types.js +3 -0
- package/dist/lib/xai.js +16 -2
- package/dist/plugin.d.ts +4 -3
- package/dist/plugin.js +33 -4
- package/dist/providers/alibaba-coding-plan.js +3 -1
- package/dist/providers/alibaba-token-plan.js +17 -0
- package/dist/providers/anthropic.js +12 -3
- package/dist/providers/copilot.js +10 -2
- package/dist/providers/glm-coding-plan-provider.d.ts +2 -0
- package/dist/providers/glm-coding-plan-provider.js +5 -1
- package/dist/providers/google-account-format.js +1 -0
- package/dist/providers/google-agy.js +12 -2
- package/dist/providers/google-gemini-cli.js +12 -2
- package/dist/providers/kilo.js +9 -1
- package/dist/providers/kimi-code.js +11 -6
- package/dist/providers/mimo.js +8 -2
- package/dist/providers/minimax-coding-plan.js +28 -5
- package/dist/providers/nanogpt.js +3 -0
- package/dist/providers/ollama-cloud.js +3 -0
- package/dist/providers/openai.js +1 -0
- package/dist/providers/opencode-go.js +8 -1
- package/dist/providers/opencode-zen.js +30 -3
- package/dist/providers/openrouter.js +3 -0
- package/dist/providers/quota-providers.js +30 -4
- package/dist/providers/result-helpers.d.ts +4 -0
- package/dist/providers/result-helpers.js +16 -2
- package/dist/rpc.d.ts +327 -4
- package/dist/rpc.js +315 -2
- package/dist/ui/assets/index-DLHeXYff.js +9 -0
- package/dist/ui/assets/{index-Cs-nrywz.css → index-cDd9jUVY.css} +1 -1
- package/dist/ui/assets/{popover-DKRrwr_K.js → popover-BGkgv9s0.js} +1 -1
- package/dist/ui/index.html +2 -2
- package/package.json +49 -40
- 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.map +0 -1
- 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/google-agy.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import crypto from "node:crypto";
|
|
2
|
+
import { providerFailureCategoryForHttpStatus, } from "../contracts/provider-failure.js";
|
|
2
3
|
import { readGlobalProviderConfigString } from "./api-key-resolver.js";
|
|
3
4
|
import { clearAgyCompanionCacheForTests, inspectAgyCompanionPresence, resolveAgyClientCredentials, } from "./google-agy-companion.js";
|
|
4
5
|
import { getCachedAccessToken, makeAccountCacheKey, setCachedAccessToken, } from "./google-token-cache.js";
|
|
@@ -190,17 +191,29 @@ async function refreshAccessToken(params) {
|
|
|
190
191
|
try {
|
|
191
192
|
const errorData = (await response.json());
|
|
192
193
|
if (errorData.error === "invalid_grant") {
|
|
193
|
-
return { error: "Token revoked" };
|
|
194
|
+
return { error: "Token revoked", failureCategory: "credentials" };
|
|
194
195
|
}
|
|
195
|
-
return {
|
|
196
|
+
return {
|
|
197
|
+
error: errorData.error_description || `HTTP ${response.status}`,
|
|
198
|
+
failureCategory: providerFailureCategoryForHttpStatus(response.status),
|
|
199
|
+
};
|
|
196
200
|
}
|
|
197
201
|
catch (error) {
|
|
198
202
|
if (timeoutSignal.aborted)
|
|
199
203
|
throw error;
|
|
200
|
-
return {
|
|
204
|
+
return {
|
|
205
|
+
error: `HTTP ${response.status}`,
|
|
206
|
+
failureCategory: providerFailureCategoryForHttpStatus(response.status),
|
|
207
|
+
};
|
|
201
208
|
}
|
|
202
209
|
}
|
|
203
210
|
const data = (await response.json());
|
|
211
|
+
if (typeof data.access_token !== "string" ||
|
|
212
|
+
data.access_token.length === 0 ||
|
|
213
|
+
typeof data.expires_in !== "number" ||
|
|
214
|
+
!Number.isFinite(data.expires_in)) {
|
|
215
|
+
throw new Error("Token refresh response returned an unexpected response shape");
|
|
216
|
+
}
|
|
204
217
|
return {
|
|
205
218
|
accessToken: data.access_token,
|
|
206
219
|
expiresIn: data.expires_in,
|
|
@@ -210,9 +223,9 @@ async function refreshAccessToken(params) {
|
|
|
210
223
|
}
|
|
211
224
|
catch (err) {
|
|
212
225
|
if (err instanceof Error && err.message.includes("timeout")) {
|
|
213
|
-
return { error: "Token refresh timeout" };
|
|
226
|
+
return { error: "Token refresh timeout", failureCategory: "provider_api" };
|
|
214
227
|
}
|
|
215
|
-
return { error: "Token refresh failed" };
|
|
228
|
+
return { error: "Token refresh failed", failureCategory: "provider_api" };
|
|
216
229
|
}
|
|
217
230
|
}
|
|
218
231
|
async function refreshAgyAccessTokenWithCache(params) {
|
|
@@ -248,6 +261,14 @@ async function refreshAgyAccessTokenWithCache(params) {
|
|
|
248
261
|
});
|
|
249
262
|
return { accessToken: refreshed.accessToken };
|
|
250
263
|
}
|
|
264
|
+
class GoogleAgyQuotaRequestError extends Error {
|
|
265
|
+
failureCategory;
|
|
266
|
+
constructor(message, failureCategory) {
|
|
267
|
+
super(message);
|
|
268
|
+
this.name = "GoogleAgyQuotaRequestError";
|
|
269
|
+
this.failureCategory = failureCategory;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
251
272
|
async function retrieveGoogleAgyQuotaSummary(accessToken, projectId, timeoutMs = AGY_QUOTA_TIMEOUT_MS) {
|
|
252
273
|
return await fetchWithTimeout(AGY_QUOTA_SUMMARY_API_URL, {
|
|
253
274
|
request: {
|
|
@@ -263,10 +284,10 @@ async function retrieveGoogleAgyQuotaSummary(accessToken, projectId, timeoutMs =
|
|
|
263
284
|
timeoutMs,
|
|
264
285
|
consume: async (response) => {
|
|
265
286
|
if (!response.ok) {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
287
|
+
const failureCategory = providerFailureCategoryForHttpStatus(response.status);
|
|
288
|
+
throw new GoogleAgyQuotaRequestError(response.status === 401 || response.status === 403
|
|
289
|
+
? `Google AGY quota auth error: ${response.status}`
|
|
290
|
+
: `Google AGY quota API error: ${response.status}`, failureCategory);
|
|
270
291
|
}
|
|
271
292
|
return (await response.json());
|
|
272
293
|
},
|
|
@@ -474,14 +495,19 @@ async function fetchAccountQuota(params) {
|
|
|
474
495
|
timeoutMs: params.timeoutMs,
|
|
475
496
|
});
|
|
476
497
|
if ("error" in tokenResult) {
|
|
477
|
-
return {
|
|
498
|
+
return {
|
|
499
|
+
success: false,
|
|
500
|
+
error: tokenResult.error,
|
|
501
|
+
failureCategory: tokenResult.failureCategory,
|
|
502
|
+
accountEmail,
|
|
503
|
+
};
|
|
478
504
|
}
|
|
479
505
|
let summary;
|
|
480
506
|
try {
|
|
481
507
|
summary = await retrieveGoogleAgyQuotaSummary(tokenResult.accessToken, params.account.projectId, params.timeoutMs);
|
|
482
508
|
}
|
|
483
509
|
catch (err) {
|
|
484
|
-
if (err instanceof
|
|
510
|
+
if (err instanceof GoogleAgyQuotaRequestError && err.failureCategory === "credentials") {
|
|
485
511
|
const retryToken = await refreshAgyAccessTokenWithCache({
|
|
486
512
|
account: params.account,
|
|
487
513
|
credentials: params.credentials,
|
|
@@ -489,7 +515,12 @@ async function fetchAccountQuota(params) {
|
|
|
489
515
|
timeoutMs: params.timeoutMs,
|
|
490
516
|
});
|
|
491
517
|
if ("error" in retryToken) {
|
|
492
|
-
return {
|
|
518
|
+
return {
|
|
519
|
+
success: false,
|
|
520
|
+
error: retryToken.error,
|
|
521
|
+
failureCategory: retryToken.failureCategory,
|
|
522
|
+
accountEmail,
|
|
523
|
+
};
|
|
493
524
|
}
|
|
494
525
|
summary = await retrieveGoogleAgyQuotaSummary(retryToken.accessToken, params.account.projectId, params.timeoutMs);
|
|
495
526
|
}
|
|
@@ -502,6 +533,7 @@ async function fetchAccountQuota(params) {
|
|
|
502
533
|
return {
|
|
503
534
|
success: false,
|
|
504
535
|
error: "Quota summary API unavailable",
|
|
536
|
+
failureCategory: "provider_api",
|
|
505
537
|
accountEmail,
|
|
506
538
|
};
|
|
507
539
|
}
|
|
@@ -509,11 +541,17 @@ async function fetchAccountQuota(params) {
|
|
|
509
541
|
}
|
|
510
542
|
catch (err) {
|
|
511
543
|
if (err instanceof Error && err.message.includes("timeout")) {
|
|
512
|
-
return {
|
|
544
|
+
return {
|
|
545
|
+
success: false,
|
|
546
|
+
error: "API timeout",
|
|
547
|
+
failureCategory: "provider_api",
|
|
548
|
+
accountEmail,
|
|
549
|
+
};
|
|
513
550
|
}
|
|
514
551
|
return {
|
|
515
552
|
success: false,
|
|
516
553
|
error: err instanceof Error ? err.message : String(err),
|
|
554
|
+
failureCategory: err instanceof GoogleAgyQuotaRequestError ? err.failureCategory : "provider_api",
|
|
517
555
|
accountEmail,
|
|
518
556
|
};
|
|
519
557
|
}
|
|
@@ -536,6 +574,7 @@ export async function queryGoogleAgyQuota(options = {}) {
|
|
|
536
574
|
return {
|
|
537
575
|
success: false,
|
|
538
576
|
error: credentials.error || "Google AGY companion auth plugin not found",
|
|
577
|
+
failureCategory: "local",
|
|
539
578
|
};
|
|
540
579
|
}
|
|
541
580
|
const results = await mapWithConcurrency(accounts, AGY_ACCOUNTS_CONCURRENCY, async (account, accountIndex) => fetchAccountQuota({
|
|
@@ -551,7 +590,13 @@ export async function queryGoogleAgyQuota(options = {}) {
|
|
|
551
590
|
allBuckets.push(...result.buckets);
|
|
552
591
|
}
|
|
553
592
|
else if (!result.success && result.error && result.accountEmail) {
|
|
554
|
-
errors.push({
|
|
593
|
+
errors.push({
|
|
594
|
+
email: result.accountEmail,
|
|
595
|
+
error: result.error,
|
|
596
|
+
...(result.failureCategory !== undefined
|
|
597
|
+
? { failureCategory: result.failureCategory }
|
|
598
|
+
: {}),
|
|
599
|
+
});
|
|
555
600
|
}
|
|
556
601
|
}
|
|
557
602
|
if (allBuckets.length === 0 && errors.length === 0) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { providerFailureCategoryForHttpStatus, } from "../contracts/provider-failure.js";
|
|
1
2
|
import { readGlobalProviderConfigString } from "./api-key-resolver.js";
|
|
2
3
|
import { clearGeminiCliCompanionCacheForTests as clearGeminiCliCompanionResolutionCacheForTests, inspectGeminiCliCompanionPresence, resolveGeminiCliClientCredentials, } from "./google-gemini-cli-companion.js";
|
|
3
4
|
import { getCachedAccessToken, makeAccountCacheKey, setCachedAccessToken, } from "./google-token-cache.js";
|
|
@@ -217,17 +218,29 @@ async function refreshAccessToken(params) {
|
|
|
217
218
|
try {
|
|
218
219
|
const errorData = (await response.json());
|
|
219
220
|
if (errorData.error === "invalid_grant") {
|
|
220
|
-
return { error: "Token revoked" };
|
|
221
|
+
return { error: "Token revoked", failureCategory: "credentials" };
|
|
221
222
|
}
|
|
222
|
-
return {
|
|
223
|
+
return {
|
|
224
|
+
error: errorData.error_description || `HTTP ${response.status}`,
|
|
225
|
+
failureCategory: providerFailureCategoryForHttpStatus(response.status),
|
|
226
|
+
};
|
|
223
227
|
}
|
|
224
228
|
catch (error) {
|
|
225
229
|
if (timeoutSignal.aborted)
|
|
226
230
|
throw error;
|
|
227
|
-
return {
|
|
231
|
+
return {
|
|
232
|
+
error: `HTTP ${response.status}`,
|
|
233
|
+
failureCategory: providerFailureCategoryForHttpStatus(response.status),
|
|
234
|
+
};
|
|
228
235
|
}
|
|
229
236
|
}
|
|
230
237
|
const data = (await response.json());
|
|
238
|
+
if (typeof data.access_token !== "string" ||
|
|
239
|
+
data.access_token.length === 0 ||
|
|
240
|
+
typeof data.expires_in !== "number" ||
|
|
241
|
+
!Number.isFinite(data.expires_in)) {
|
|
242
|
+
throw new Error("Token refresh response returned an unexpected response shape");
|
|
243
|
+
}
|
|
231
244
|
return {
|
|
232
245
|
accessToken: data.access_token,
|
|
233
246
|
expiresIn: data.expires_in,
|
|
@@ -237,9 +250,9 @@ async function refreshAccessToken(params) {
|
|
|
237
250
|
}
|
|
238
251
|
catch (err) {
|
|
239
252
|
if (err instanceof Error && err.message.includes("timeout")) {
|
|
240
|
-
return { error: "Token refresh timeout" };
|
|
253
|
+
return { error: "Token refresh timeout", failureCategory: "provider_api" };
|
|
241
254
|
}
|
|
242
|
-
return { error: "Token refresh failed" };
|
|
255
|
+
return { error: "Token refresh failed", failureCategory: "provider_api" };
|
|
243
256
|
}
|
|
244
257
|
}
|
|
245
258
|
async function refreshGeminiCliAccessTokenWithCache(params) {
|
|
@@ -275,6 +288,14 @@ async function refreshGeminiCliAccessTokenWithCache(params) {
|
|
|
275
288
|
});
|
|
276
289
|
return { accessToken: refreshed.accessToken };
|
|
277
290
|
}
|
|
291
|
+
class GeminiCliQuotaRequestError extends Error {
|
|
292
|
+
failureCategory;
|
|
293
|
+
constructor(message, failureCategory) {
|
|
294
|
+
super(message);
|
|
295
|
+
this.name = "GeminiCliQuotaRequestError";
|
|
296
|
+
this.failureCategory = failureCategory;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
278
299
|
async function retrieveGeminiCliQuota(accessToken, projectId, timeoutMs = GEMINI_QUOTA_TIMEOUT_MS) {
|
|
279
300
|
return await fetchWithTimeout(GEMINI_QUOTA_API_URL, {
|
|
280
301
|
request: {
|
|
@@ -289,10 +310,10 @@ async function retrieveGeminiCliQuota(accessToken, projectId, timeoutMs = GEMINI
|
|
|
289
310
|
timeoutMs,
|
|
290
311
|
consume: async (response) => {
|
|
291
312
|
if (!response.ok) {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
313
|
+
const failureCategory = providerFailureCategoryForHttpStatus(response.status);
|
|
314
|
+
throw new GeminiCliQuotaRequestError(response.status === 401 || response.status === 403
|
|
315
|
+
? `Gemini CLI quota auth error: ${response.status}`
|
|
316
|
+
: `Gemini CLI quota API error: ${response.status}`, failureCategory);
|
|
296
317
|
}
|
|
297
318
|
return (await response.json());
|
|
298
319
|
},
|
|
@@ -392,14 +413,19 @@ async function fetchAccountQuota(params) {
|
|
|
392
413
|
timeoutMs: params.timeoutMs,
|
|
393
414
|
});
|
|
394
415
|
if ("error" in tokenResult) {
|
|
395
|
-
return {
|
|
416
|
+
return {
|
|
417
|
+
success: false,
|
|
418
|
+
error: tokenResult.error,
|
|
419
|
+
failureCategory: tokenResult.failureCategory,
|
|
420
|
+
accountEmail,
|
|
421
|
+
};
|
|
396
422
|
}
|
|
397
423
|
let quota;
|
|
398
424
|
try {
|
|
399
425
|
quota = await retrieveGeminiCliQuota(tokenResult.accessToken, params.account.projectId, params.timeoutMs);
|
|
400
426
|
}
|
|
401
427
|
catch (err) {
|
|
402
|
-
if (err instanceof
|
|
428
|
+
if (err instanceof GeminiCliQuotaRequestError && err.failureCategory === "credentials") {
|
|
403
429
|
const retryToken = await refreshGeminiCliAccessTokenWithCache({
|
|
404
430
|
account: params.account,
|
|
405
431
|
credentials: params.credentials,
|
|
@@ -407,7 +433,12 @@ async function fetchAccountQuota(params) {
|
|
|
407
433
|
timeoutMs: params.timeoutMs,
|
|
408
434
|
});
|
|
409
435
|
if ("error" in retryToken) {
|
|
410
|
-
return {
|
|
436
|
+
return {
|
|
437
|
+
success: false,
|
|
438
|
+
error: retryToken.error,
|
|
439
|
+
failureCategory: retryToken.failureCategory,
|
|
440
|
+
accountEmail,
|
|
441
|
+
};
|
|
411
442
|
}
|
|
412
443
|
quota = await retrieveGeminiCliQuota(retryToken.accessToken, params.account.projectId, params.timeoutMs);
|
|
413
444
|
}
|
|
@@ -423,11 +454,17 @@ async function fetchAccountQuota(params) {
|
|
|
423
454
|
}
|
|
424
455
|
catch (err) {
|
|
425
456
|
if (err instanceof Error && err.message.includes("timeout")) {
|
|
426
|
-
return {
|
|
457
|
+
return {
|
|
458
|
+
success: false,
|
|
459
|
+
error: "API timeout",
|
|
460
|
+
failureCategory: "provider_api",
|
|
461
|
+
accountEmail,
|
|
462
|
+
};
|
|
427
463
|
}
|
|
428
464
|
return {
|
|
429
465
|
success: false,
|
|
430
466
|
error: err instanceof Error ? err.message : String(err),
|
|
467
|
+
failureCategory: err instanceof GeminiCliQuotaRequestError ? err.failureCategory : "provider_api",
|
|
431
468
|
accountEmail,
|
|
432
469
|
};
|
|
433
470
|
}
|
|
@@ -450,6 +487,7 @@ export async function queryGeminiCliQuota(options = {}) {
|
|
|
450
487
|
return {
|
|
451
488
|
success: false,
|
|
452
489
|
error: getCompanionQuotaError(credentials.state),
|
|
490
|
+
failureCategory: "local",
|
|
453
491
|
};
|
|
454
492
|
}
|
|
455
493
|
const results = await mapWithConcurrency(accounts, GEMINI_ACCOUNTS_CONCURRENCY, async (account) => fetchAccountQuota({ account, credentials, timeoutMs: options.requestTimeoutMs }));
|
|
@@ -460,7 +498,13 @@ export async function queryGeminiCliQuota(options = {}) {
|
|
|
460
498
|
allBuckets.push(...result.buckets);
|
|
461
499
|
}
|
|
462
500
|
else if (!result.success && result.error && result.accountEmail) {
|
|
463
|
-
errors.push({
|
|
501
|
+
errors.push({
|
|
502
|
+
email: result.accountEmail,
|
|
503
|
+
error: result.error,
|
|
504
|
+
...(result.failureCategory !== undefined
|
|
505
|
+
? { failureCategory: result.failureCategory }
|
|
506
|
+
: {}),
|
|
507
|
+
});
|
|
464
508
|
}
|
|
465
509
|
}
|
|
466
510
|
if (allBuckets.length === 0 && errors.length === 0) {
|
|
@@ -2,14 +2,15 @@ import { existsSync } from "fs";
|
|
|
2
2
|
import { readFile } from "fs/promises";
|
|
3
3
|
import { basename, dirname, join, resolve } from "path";
|
|
4
4
|
import { fileURLToPath } from "url";
|
|
5
|
-
import { getGuiConfigPath, getGuiConfigSiblingJsonPath, loadConfig } from "./config.js";
|
|
5
|
+
import { createLoadConfigMeta, getGuiConfigPath, getGuiConfigSiblingJsonPath, loadConfig, } from "./config.js";
|
|
6
6
|
import { dedupeNonEmptyStrings, findGitWorktreeRoot, getPluginSpecFromEntry, resolveEditableConfigPath, } from "./config-file-utils.js";
|
|
7
7
|
import { writeConfiguredJsonAtomic } from "./config-write-target.js";
|
|
8
|
+
import { getDashboardEnabledSetting, hasInvalidDashboardWebConfig, resolveDashboardWebEnabled, } from "./dashboard-web-policy.js";
|
|
8
9
|
import { assertGuiConfigTargetIsIndependent } from "./gui-config-target.js";
|
|
9
10
|
import { parseJsonOrJsonc } from "./jsonc.js";
|
|
10
11
|
import { applyConfigDocumentEdit, planConfigDocumentEdit, validateConfigDocumentEdit, } from "./opencode-config-editor.js";
|
|
11
12
|
import { getOpencodeRuntimeDirs } from "./opencode-runtime-paths.js";
|
|
12
|
-
import { detectOpenCodeMajor } from "./opencode-version.js";
|
|
13
|
+
import { detectOpenCodeMajor, detectOpenCodeVersion } from "./opencode-version.js";
|
|
13
14
|
import { getQuotaProviderDisplayLabel, normalizeQuotaProviderId, QUOTA_PROVIDER_SHAPES, } from "./provider-metadata.js";
|
|
14
15
|
import { getQuotaFormatStyleLabel, isQuotaFormatStyle, resolveQuotaFormatStyle, } from "./quota-format-style.js";
|
|
15
16
|
import { QUOTA_PROVIDERS_AGGREGATE_ID } from "./quota-providers.js";
|
|
@@ -1020,7 +1021,8 @@ export async function runInitInstaller(params) {
|
|
|
1020
1021
|
? "Web"
|
|
1021
1022
|
: "TUI and Web";
|
|
1022
1023
|
const configuredPaths = [...result.writtenPaths, ...result.unchangedPaths];
|
|
1023
|
-
const
|
|
1024
|
+
const configMeta = createLoadConfigMeta();
|
|
1025
|
+
const config = await loadConfig(undefined, configMeta, {
|
|
1024
1026
|
configRootDir: resolveInitInstallerBaseDir({ scope: "project", cwd: params?.cwd }),
|
|
1025
1027
|
globalConfigDir: resolveInitInstallerBaseDir({
|
|
1026
1028
|
scope: "global",
|
|
@@ -1028,13 +1030,32 @@ export async function runInitInstaller(params) {
|
|
|
1028
1030
|
homeDir: params?.homeDir,
|
|
1029
1031
|
}),
|
|
1030
1032
|
});
|
|
1033
|
+
const explicitDashboardEnabled = getDashboardEnabledSetting(config, configMeta);
|
|
1034
|
+
const invalidDashboardConfig = hasInvalidDashboardWebConfig(configMeta);
|
|
1035
|
+
// The version probe is bounded and only needed when the canonical key is
|
|
1036
|
+
// absent; explicit configuration and malformed files decide on their own.
|
|
1037
|
+
const hostVersion = explicitDashboardEnabled === undefined && !invalidDashboardConfig
|
|
1038
|
+
? await detectOpenCodeVersion()
|
|
1039
|
+
: undefined;
|
|
1040
|
+
const webEnabled = resolveDashboardWebEnabled({
|
|
1041
|
+
...(explicitDashboardEnabled !== undefined
|
|
1042
|
+
? { explicitEnabled: explicitDashboardEnabled }
|
|
1043
|
+
: {}),
|
|
1044
|
+
...(hostVersion !== undefined ? { hostVersion } : {}),
|
|
1045
|
+
invalidConfig: invalidDashboardConfig,
|
|
1046
|
+
});
|
|
1031
1047
|
const dashboardUrl = `http://localhost:${config.dashboard?.port ?? DEFAULT_DASHBOARD_PORT}/quota`;
|
|
1048
|
+
const dashboardOutro = webEnabled
|
|
1049
|
+
? `Restart OpenCode, then open ${dashboardUrl}.`
|
|
1050
|
+
: explicitDashboardEnabled === false
|
|
1051
|
+
? `Web dashboard access is disabled in the canonical config. Set "dashboard": { "enabled": true }, then restart OpenCode and open ${dashboardUrl}.`
|
|
1052
|
+
: `Web dashboard access is off. Add "dashboard": { "enabled": true } to the canonical config, then restart OpenCode and open ${dashboardUrl}.`;
|
|
1032
1053
|
prompts.outro([
|
|
1033
1054
|
"OpenCode Quota setup complete.",
|
|
1034
1055
|
`Interfaces: ${interfaceLabel}`,
|
|
1035
1056
|
"Configured paths:",
|
|
1036
1057
|
...configuredPaths.map((path) => `- ${path}`),
|
|
1037
|
-
|
|
1058
|
+
dashboardOutro,
|
|
1038
1059
|
`If OpenCode Quota helps, please consider a star: ${GITHUB_REPO_URL}`,
|
|
1039
1060
|
].join("\n"));
|
|
1040
1061
|
return 0;
|
package/dist/lib/kilo.js
CHANGED
|
@@ -5,12 +5,16 @@
|
|
|
5
5
|
* subscription-state endpoint, with a balance-only fallback for accounts
|
|
6
6
|
* without an active Kilo Pass.
|
|
7
7
|
*/
|
|
8
|
+
import { providerFailureCategoryForHttpStatus } from "../contracts/provider-failure.js";
|
|
8
9
|
import { sanitizeSingleLineDisplayText } from "./display-sanitize.js";
|
|
9
10
|
import { fetchWithTimeout } from "./http.js";
|
|
10
11
|
import { resolveKiloApiKey } from "./kilo-config.js";
|
|
11
12
|
const KILO_PASS_STATE_ENDPOINT = "https://app.kilo.ai/api/trpc/kiloPass.getState";
|
|
12
13
|
const KILO_BALANCE_ENDPOINT = "https://api.kilo.ai/api/profile/balance";
|
|
13
14
|
const MAX_RESPONSE_BYTES = 64 * 1024;
|
|
15
|
+
function invalidKiloResponse(error) {
|
|
16
|
+
return { success: false, error, failureCategory: "provider_api" };
|
|
17
|
+
}
|
|
14
18
|
function isRecord(value) {
|
|
15
19
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
16
20
|
}
|
|
@@ -74,41 +78,26 @@ function isNoActiveKiloPassResult(result) {
|
|
|
74
78
|
function parseKiloPassState(payload) {
|
|
75
79
|
const item = Array.isArray(payload) ? payload[0] : payload;
|
|
76
80
|
if (!isRecord(item)) {
|
|
77
|
-
return
|
|
78
|
-
success: false,
|
|
79
|
-
error: "Kilo Gateway state API returned an unexpected response shape",
|
|
80
|
-
};
|
|
81
|
+
return invalidKiloResponse("Kilo Gateway state API returned an unexpected response shape");
|
|
81
82
|
}
|
|
82
83
|
const result = item.result;
|
|
83
84
|
const data = isRecord(result) ? result.data : undefined;
|
|
84
85
|
if (!isRecord(data)) {
|
|
85
|
-
return
|
|
86
|
-
success: false,
|
|
87
|
-
error: "Kilo Gateway state API returned an unexpected response shape",
|
|
88
|
-
};
|
|
86
|
+
return invalidKiloResponse("Kilo Gateway state API returned an unexpected response shape");
|
|
89
87
|
}
|
|
90
88
|
if ("json" in data && !isRecord(data.json)) {
|
|
91
|
-
return
|
|
92
|
-
success: false,
|
|
93
|
-
error: "Kilo Gateway state API returned an unexpected response shape",
|
|
94
|
-
};
|
|
89
|
+
return invalidKiloResponse("Kilo Gateway state API returned an unexpected response shape");
|
|
95
90
|
}
|
|
96
91
|
const root = isRecord(data.json) ? data.json : data;
|
|
97
92
|
if (!isRecord(root)) {
|
|
98
|
-
return
|
|
99
|
-
success: false,
|
|
100
|
-
error: "Kilo Gateway state API returned an unexpected response shape",
|
|
101
|
-
};
|
|
93
|
+
return invalidKiloResponse("Kilo Gateway state API returned an unexpected response shape");
|
|
102
94
|
}
|
|
103
95
|
const subscription = root.subscription;
|
|
104
96
|
if (subscription === null || !("subscription" in root)) {
|
|
105
97
|
return noActiveKiloPass();
|
|
106
98
|
}
|
|
107
99
|
if (!isRecord(subscription)) {
|
|
108
|
-
return
|
|
109
|
-
success: false,
|
|
110
|
-
error: "Kilo Gateway state API returned an invalid Kilo Pass subscription",
|
|
111
|
-
};
|
|
100
|
+
return invalidKiloResponse("Kilo Gateway state API returned an invalid Kilo Pass subscription");
|
|
112
101
|
}
|
|
113
102
|
const baseCreditsUsd = nonnegativeNumber(subscription.currentPeriodBaseCreditsUsd);
|
|
114
103
|
const usageUsd = nonnegativeNumber(subscription.currentPeriodUsageUsd);
|
|
@@ -117,22 +106,13 @@ function parseKiloPassState(payload) {
|
|
|
117
106
|
? 0
|
|
118
107
|
: nonnegativeNumber(rawBonusCreditsUsd);
|
|
119
108
|
if (baseCreditsUsd === null) {
|
|
120
|
-
return
|
|
121
|
-
success: false,
|
|
122
|
-
error: "Kilo Gateway state API returned invalid currentPeriodBaseCreditsUsd",
|
|
123
|
-
};
|
|
109
|
+
return invalidKiloResponse("Kilo Gateway state API returned invalid currentPeriodBaseCreditsUsd");
|
|
124
110
|
}
|
|
125
111
|
if (usageUsd === null) {
|
|
126
|
-
return
|
|
127
|
-
success: false,
|
|
128
|
-
error: "Kilo Gateway state API returned invalid currentPeriodUsageUsd",
|
|
129
|
-
};
|
|
112
|
+
return invalidKiloResponse("Kilo Gateway state API returned invalid currentPeriodUsageUsd");
|
|
130
113
|
}
|
|
131
114
|
if (bonusCreditsUsd === null) {
|
|
132
|
-
return
|
|
133
|
-
success: false,
|
|
134
|
-
error: "Kilo Gateway state API returned invalid currentPeriodBonusCreditsUsd",
|
|
135
|
-
};
|
|
115
|
+
return invalidKiloResponse("Kilo Gateway state API returned invalid currentPeriodBonusCreditsUsd");
|
|
136
116
|
}
|
|
137
117
|
const resetTimeIso = firstValidResetTimeIso(subscription.nextBillingAt, subscription.nextRenewalAt);
|
|
138
118
|
const totalCreditsUsd = baseCreditsUsd + bonusCreditsUsd;
|
|
@@ -150,17 +130,11 @@ function parseKiloPassState(payload) {
|
|
|
150
130
|
}
|
|
151
131
|
function parseKiloBalance(payload) {
|
|
152
132
|
if (!isRecord(payload)) {
|
|
153
|
-
return
|
|
154
|
-
success: false,
|
|
155
|
-
error: "Kilo Gateway balance API returned an unexpected response shape",
|
|
156
|
-
};
|
|
133
|
+
return invalidKiloResponse("Kilo Gateway balance API returned an unexpected response shape");
|
|
157
134
|
}
|
|
158
135
|
const balanceUsd = nonnegativeNumber(payload.balance);
|
|
159
136
|
if (balanceUsd === null) {
|
|
160
|
-
return
|
|
161
|
-
success: false,
|
|
162
|
-
error: "Kilo Gateway balance API returned an invalid balance",
|
|
163
|
-
};
|
|
137
|
+
return invalidKiloResponse("Kilo Gateway balance API returned an invalid balance");
|
|
164
138
|
}
|
|
165
139
|
return { success: true, balanceUsd };
|
|
166
140
|
}
|
|
@@ -169,6 +143,7 @@ async function requestKiloPassState(key, options) {
|
|
|
169
143
|
batch: "1",
|
|
170
144
|
input: JSON.stringify({ "0": null }),
|
|
171
145
|
});
|
|
146
|
+
let responseStatus;
|
|
172
147
|
try {
|
|
173
148
|
return await fetchWithTimeout(`${KILO_PASS_STATE_ENDPOINT}?${query.toString()}`, {
|
|
174
149
|
request: {
|
|
@@ -182,11 +157,13 @@ async function requestKiloPassState(key, options) {
|
|
|
182
157
|
},
|
|
183
158
|
timeoutMs: options.requestTimeoutMs,
|
|
184
159
|
consume: async (response) => {
|
|
160
|
+
responseStatus = response.status;
|
|
185
161
|
const text = await readResponseText(response, "state");
|
|
186
162
|
if (!response.ok) {
|
|
187
163
|
return {
|
|
188
164
|
success: false,
|
|
189
165
|
error: `Kilo Gateway state API error ${response.status}: ${sanitizeMessage(text, key)}`,
|
|
166
|
+
failureCategory: providerFailureCategoryForHttpStatus(response.status),
|
|
190
167
|
};
|
|
191
168
|
}
|
|
192
169
|
return parseKiloPassState(JSON.parse(text));
|
|
@@ -197,10 +174,14 @@ async function requestKiloPassState(key, options) {
|
|
|
197
174
|
return {
|
|
198
175
|
success: false,
|
|
199
176
|
error: sanitizeMessage(error instanceof Error ? error.message : String(error), key),
|
|
177
|
+
failureCategory: responseStatus === undefined
|
|
178
|
+
? "provider_api"
|
|
179
|
+
: providerFailureCategoryForHttpStatus(responseStatus),
|
|
200
180
|
};
|
|
201
181
|
}
|
|
202
182
|
}
|
|
203
183
|
async function requestKiloBalance(key, options) {
|
|
184
|
+
let responseStatus;
|
|
204
185
|
try {
|
|
205
186
|
return await fetchWithTimeout(KILO_BALANCE_ENDPOINT, {
|
|
206
187
|
request: {
|
|
@@ -214,11 +195,13 @@ async function requestKiloBalance(key, options) {
|
|
|
214
195
|
},
|
|
215
196
|
timeoutMs: options.requestTimeoutMs,
|
|
216
197
|
consume: async (response) => {
|
|
198
|
+
responseStatus = response.status;
|
|
217
199
|
const text = await readResponseText(response, "balance");
|
|
218
200
|
if (!response.ok) {
|
|
219
201
|
return {
|
|
220
202
|
success: false,
|
|
221
203
|
error: `Kilo Gateway balance API error ${response.status}: ${sanitizeMessage(text, key)}`,
|
|
204
|
+
failureCategory: providerFailureCategoryForHttpStatus(response.status),
|
|
222
205
|
};
|
|
223
206
|
}
|
|
224
207
|
return parseKiloBalance(JSON.parse(text));
|
|
@@ -229,6 +212,9 @@ async function requestKiloBalance(key, options) {
|
|
|
229
212
|
return {
|
|
230
213
|
success: false,
|
|
231
214
|
error: sanitizeMessage(error instanceof Error ? error.message : String(error), key),
|
|
215
|
+
failureCategory: responseStatus === undefined
|
|
216
|
+
? "provider_api"
|
|
217
|
+
: providerFailureCategoryForHttpStatus(responseStatus),
|
|
232
218
|
};
|
|
233
219
|
}
|
|
234
220
|
}
|
|
@@ -260,6 +246,9 @@ export async function queryKiloQuota(options = {}) {
|
|
|
260
246
|
return {
|
|
261
247
|
success: false,
|
|
262
248
|
error: `Kilo Gateway has no active Kilo Pass subscription; balance fallback failed: ${balanceResult.error}`,
|
|
249
|
+
...(balanceResult.failureCategory !== undefined
|
|
250
|
+
? { failureCategory: balanceResult.failureCategory }
|
|
251
|
+
: {}),
|
|
263
252
|
};
|
|
264
253
|
}
|
|
265
254
|
//# sourceMappingURL=kilo.js.map
|
package/dist/lib/kimi.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { providerFailureCategoryForHttpStatus, } from "../contracts/provider-failure.js";
|
|
1
2
|
import { sanitizeDisplaySnippet, sanitizeDisplayText } from "./display-sanitize.js";
|
|
2
3
|
import { clampPercent } from "./format-utils.js";
|
|
3
4
|
import { fetchWithTimeout } from "./http.js";
|
|
@@ -178,6 +179,7 @@ function parseKimiUsagePayload(payload) {
|
|
|
178
179
|
return { windows, topLevelKeys };
|
|
179
180
|
}
|
|
180
181
|
async function fetchKimiQuotaFromUrl(url, apiKey, requestTimeoutMs) {
|
|
182
|
+
let responseStatus;
|
|
181
183
|
try {
|
|
182
184
|
return await fetchWithTimeout(url, {
|
|
183
185
|
request: {
|
|
@@ -188,11 +190,13 @@ async function fetchKimiQuotaFromUrl(url, apiKey, requestTimeoutMs) {
|
|
|
188
190
|
},
|
|
189
191
|
timeoutMs: requestTimeoutMs,
|
|
190
192
|
consume: async (resp) => {
|
|
193
|
+
responseStatus = resp.status;
|
|
191
194
|
if (!resp.ok) {
|
|
192
195
|
const text = await resp.text();
|
|
193
196
|
return {
|
|
194
197
|
ok: false,
|
|
195
198
|
error: `Kimi API error ${resp.status}: ${sanitizeDisplaySnippet(text, 120)}`,
|
|
199
|
+
failureCategory: providerFailureCategoryForHttpStatus(resp.status),
|
|
196
200
|
};
|
|
197
201
|
}
|
|
198
202
|
const payload = (await resp.json());
|
|
@@ -205,6 +209,9 @@ async function fetchKimiQuotaFromUrl(url, apiKey, requestTimeoutMs) {
|
|
|
205
209
|
return {
|
|
206
210
|
ok: false,
|
|
207
211
|
error: sanitizeDisplayText(err instanceof Error ? err.message : String(err)),
|
|
212
|
+
failureCategory: responseStatus === undefined
|
|
213
|
+
? "provider_api"
|
|
214
|
+
: providerFailureCategoryForHttpStatus(responseStatus),
|
|
208
215
|
};
|
|
209
216
|
}
|
|
210
217
|
}
|
|
@@ -219,12 +226,17 @@ export async function queryKimiQuota(options) {
|
|
|
219
226
|
};
|
|
220
227
|
}
|
|
221
228
|
if (!result.ok) {
|
|
222
|
-
return {
|
|
229
|
+
return {
|
|
230
|
+
success: false,
|
|
231
|
+
error: result.error,
|
|
232
|
+
...(result.failureCategory !== undefined ? { failureCategory: result.failureCategory } : {}),
|
|
233
|
+
};
|
|
223
234
|
}
|
|
224
235
|
// Succeeded structurally but had no usable windows.
|
|
225
236
|
return {
|
|
226
237
|
success: false,
|
|
227
238
|
error: describeUnexpectedPayload(result.topLevelKeys),
|
|
239
|
+
failureCategory: "provider_api",
|
|
228
240
|
};
|
|
229
241
|
}
|
|
230
242
|
//# sourceMappingURL=kimi.js.map
|
package/dist/lib/mimo.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ProviderFailureCategory } from "../contracts/provider-failure.js";
|
|
1
2
|
export interface MimoMonthlyQuota {
|
|
2
3
|
used: number;
|
|
3
4
|
limit: number;
|
|
@@ -19,6 +20,7 @@ export type MimoEndpointResult<T> = {
|
|
|
19
20
|
} | {
|
|
20
21
|
state: "error";
|
|
21
22
|
error: string;
|
|
23
|
+
failureCategory: ProviderFailureCategory;
|
|
22
24
|
};
|
|
23
25
|
export interface MimoDashboardResult {
|
|
24
26
|
usage: MimoEndpointResult<MimoMonthlyQuota>;
|
package/dist/lib/mimo.js
CHANGED
|
@@ -163,12 +163,17 @@ async function fetchMimoEndpoint(params) {
|
|
|
163
163
|
timeoutMs: params.requestTimeoutMs,
|
|
164
164
|
consume: async (response, timeoutSignal) => {
|
|
165
165
|
if (response.status >= 300 && response.status < 400) {
|
|
166
|
-
return {
|
|
166
|
+
return {
|
|
167
|
+
state: "error",
|
|
168
|
+
error: `Xiaomi MiMo ${params.name} request requires login`,
|
|
169
|
+
failureCategory: "credentials",
|
|
170
|
+
};
|
|
167
171
|
}
|
|
168
172
|
if (!response.ok) {
|
|
169
173
|
return {
|
|
170
174
|
state: "error",
|
|
171
175
|
error: `Xiaomi MiMo ${params.name} request failed (HTTP ${response.status})`,
|
|
176
|
+
failureCategory: response.status === 401 || response.status === 403 ? "credentials" : "provider_api",
|
|
172
177
|
};
|
|
173
178
|
}
|
|
174
179
|
let json;
|
|
@@ -181,6 +186,7 @@ async function fetchMimoEndpoint(params) {
|
|
|
181
186
|
return {
|
|
182
187
|
state: "error",
|
|
183
188
|
error: `Xiaomi MiMo ${params.name} response could not be parsed`,
|
|
189
|
+
failureCategory: "provider_api",
|
|
184
190
|
};
|
|
185
191
|
}
|
|
186
192
|
try {
|
|
@@ -190,6 +196,7 @@ async function fetchMimoEndpoint(params) {
|
|
|
190
196
|
return {
|
|
191
197
|
state: "error",
|
|
192
198
|
error: `Xiaomi MiMo ${params.name} response did not match the expected schema`,
|
|
199
|
+
failureCategory: "provider_api",
|
|
193
200
|
};
|
|
194
201
|
}
|
|
195
202
|
},
|
|
@@ -199,6 +206,7 @@ async function fetchMimoEndpoint(params) {
|
|
|
199
206
|
return {
|
|
200
207
|
state: "error",
|
|
201
208
|
error: `Xiaomi MiMo ${params.name} request failed: ${sanitizeRequestError(error, params.cookie)}`,
|
|
209
|
+
failureCategory: "provider_api",
|
|
202
210
|
};
|
|
203
211
|
}
|
|
204
212
|
}
|