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/gui/lifecycle.js
CHANGED
|
@@ -8,7 +8,13 @@
|
|
|
8
8
|
* owner's source, and when that owner disposes while other leases remain the
|
|
9
9
|
* host switches to a live owner's source — created lazily on the next request —
|
|
10
10
|
* without dropping the socket. The settings store is host-scoped file access.
|
|
11
|
-
*
|
|
11
|
+
* One runtime — the stable delegating source and one `SnapshotService` — is
|
|
12
|
+
* shared by every transport attached to that host. The host closes with the
|
|
13
|
+
* last lease, releasing the snapshot service and every source it created. The
|
|
14
|
+
* web transport is optional and follows the host version when `dashboard.enabled`
|
|
15
|
+
* is absent (on below OpenCode 2.2.0, off from 2.2.0): when it is off, or when
|
|
16
|
+
* its fixed port cannot bind, the shared runtime stays available for the
|
|
17
|
+
* remaining leases and no HTTP/SSE/static surface is started.
|
|
12
18
|
*
|
|
13
19
|
* The registry lives on `globalThis` under a versioned `Symbol.for` key (the
|
|
14
20
|
* quota-telemetry precedent), so two separately loaded copies of this module in
|
|
@@ -17,27 +23,33 @@
|
|
|
17
23
|
* an error thrown by another module graph is structurally identical.
|
|
18
24
|
*
|
|
19
25
|
* Nothing here throws into the plugin: every failure becomes one controlled log
|
|
20
|
-
* line and a lease in state `unavailable`. A failed bind is terminal
|
|
21
|
-
* §4.3) — no alternate port is ever tried, and the plugin's
|
|
22
|
-
* untouched.
|
|
26
|
+
* line and a lease in state `unavailable`. A failed bind is terminal for the web
|
|
27
|
+
* transport (spec §4.3) — no alternate port is ever tried, and the plugin's
|
|
28
|
+
* other surfaces are untouched.
|
|
23
29
|
*/
|
|
24
30
|
import { existsSync, readFileSync } from "node:fs";
|
|
25
|
-
import { getGuiConfigPath, loadConfig } from "../lib/config.js";
|
|
31
|
+
import { createLoadConfigMeta, getGuiConfigPath, loadConfig } from "../lib/config.js";
|
|
32
|
+
import { getDashboardEnabledSetting, hasInvalidDashboardWebConfig, resolveDashboardWebEnabled, } from "../lib/dashboard-web-policy.js";
|
|
26
33
|
import { parseConfigDocument } from "../lib/opencode-config-editor.js";
|
|
27
34
|
import { getOpencodeRuntimeDirs } from "../lib/opencode-runtime-paths.js";
|
|
28
|
-
import {
|
|
35
|
+
import { detectOpenCodeVersion } from "../lib/opencode-version.js";
|
|
36
|
+
import { createGuiSettingsStore, getGuiDashboardPort, } from "./config.js";
|
|
29
37
|
import { createGuiLogger } from "./log.js";
|
|
38
|
+
import { createQuotaNotificationObserver, quotaNotificationSettingsFromSnapshot, } from "./quota-notification-observer.js";
|
|
30
39
|
import { createDashboardServer, } from "./server.js";
|
|
31
|
-
import { DEFAULT_POLL_INTERVAL_MS } from "./snapshot-service.js";
|
|
40
|
+
import { createSnapshotService, DEFAULT_POLL_INTERVAL_MS, } from "./snapshot-service.js";
|
|
32
41
|
import { createDashboardReadSource } from "./sources.js";
|
|
33
42
|
/**
|
|
34
43
|
* Versioned process-wide host registry. `Symbol.for` is realm-global, so every
|
|
35
44
|
* separately loaded copy of this module in the same process resolves the same
|
|
36
45
|
* map and shares the refcount and socket. The version is bumped when the host
|
|
37
|
-
* record
|
|
38
|
-
*
|
|
46
|
+
* record or start semantics change (`v2` added owner delegation, `v3` added the
|
|
47
|
+
* shared snapshot/source runtime, `v4` made the web transport optional while
|
|
48
|
+
* keeping the runtime, `v5` publishes the shared settings/snapshot runtime for
|
|
49
|
+
* RPC): an older copy then fails the fixed port terminally instead of mutating
|
|
50
|
+
* a host it does not understand.
|
|
39
51
|
*/
|
|
40
|
-
const HOST_REGISTRY_KEY = Symbol.for("opencode-quota-gui/dashboard-lifecycle/
|
|
52
|
+
const HOST_REGISTRY_KEY = Symbol.for("opencode-quota-gui/dashboard-lifecycle/v5");
|
|
41
53
|
function hostRegistry() {
|
|
42
54
|
const globalState = globalThis;
|
|
43
55
|
const existing = globalState[HOST_REGISTRY_KEY];
|
|
@@ -58,6 +70,52 @@ function createOwner(options, configDir) {
|
|
|
58
70
|
disposed: false,
|
|
59
71
|
};
|
|
60
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* One host's shared runtime. `close` is idempotent and is called by the final
|
|
75
|
+
* lease disposal; only the first call releases the snapshot service and every
|
|
76
|
+
* owner source still registered at that moment.
|
|
77
|
+
*/
|
|
78
|
+
function createRuntime(source, logger) {
|
|
79
|
+
let closing;
|
|
80
|
+
const runtime = {
|
|
81
|
+
source,
|
|
82
|
+
snapshots: undefined,
|
|
83
|
+
quotaMonitor: undefined,
|
|
84
|
+
quotaNotifications: undefined,
|
|
85
|
+
settings: undefined,
|
|
86
|
+
close() {
|
|
87
|
+
if (closing)
|
|
88
|
+
return closing;
|
|
89
|
+
closing = (async () => {
|
|
90
|
+
try {
|
|
91
|
+
await runtime.quotaNotifications?.close();
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
logger.warn("quota notification observer close failed", failureLabel(error));
|
|
95
|
+
}
|
|
96
|
+
runtime.quotaNotifications = undefined;
|
|
97
|
+
try {
|
|
98
|
+
runtime.quotaMonitor?.release();
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
logger.warn("dashboard quota monitor close failed", failureLabel(error));
|
|
102
|
+
}
|
|
103
|
+
runtime.quotaMonitor = undefined;
|
|
104
|
+
try {
|
|
105
|
+
runtime.snapshots?.close();
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
logger.warn("dashboard runtime close failed", failureLabel(error));
|
|
109
|
+
}
|
|
110
|
+
runtime.snapshots = undefined;
|
|
111
|
+
runtime.settings = undefined;
|
|
112
|
+
await closeSource(source, logger);
|
|
113
|
+
})();
|
|
114
|
+
return closing;
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
return runtime;
|
|
118
|
+
}
|
|
61
119
|
/** The owner's source, created at most once and shared by concurrent callers. */
|
|
62
120
|
function ownerSource(owner, logger) {
|
|
63
121
|
if (owner.source)
|
|
@@ -124,22 +182,26 @@ function disposeOwner(owner, logger) {
|
|
|
124
182
|
owner.sourceOptions = undefined;
|
|
125
183
|
return releaseOwnerSource(owner, logger);
|
|
126
184
|
}
|
|
127
|
-
/**
|
|
185
|
+
/**
|
|
186
|
+
* Removes a disposed owner and hands the host to the most recent live owner.
|
|
187
|
+
* Returns true when the active serving identity changed.
|
|
188
|
+
*/
|
|
128
189
|
function dropOwner(host, owner) {
|
|
129
190
|
const { owners } = host.delegation;
|
|
130
191
|
const index = owners.indexOf(owner);
|
|
131
192
|
if (index !== -1)
|
|
132
193
|
owners.splice(index, 1);
|
|
133
|
-
if (host.delegation.activeOwner
|
|
134
|
-
|
|
135
|
-
|
|
194
|
+
if (host.delegation.activeOwner !== owner)
|
|
195
|
+
return false;
|
|
196
|
+
host.delegation.activeOwner = owners[owners.length - 1];
|
|
197
|
+
return true;
|
|
136
198
|
}
|
|
137
199
|
/**
|
|
138
200
|
* The stable source the transport keeps for the host's lifetime. Every read
|
|
139
201
|
* resolves the active owner's source; a delegate's source is not created until
|
|
140
202
|
* a request needs it, so a handoff starts no analytics work by itself.
|
|
141
203
|
*/
|
|
142
|
-
function createDelegatingSource(delegation, logger) {
|
|
204
|
+
function createDelegatingSource(delegation, logger, observation) {
|
|
143
205
|
const requireSource = () => {
|
|
144
206
|
const owner = delegation.activeOwner;
|
|
145
207
|
if (!owner)
|
|
@@ -152,19 +214,30 @@ function createDelegatingSource(delegation, logger) {
|
|
|
152
214
|
session: async (input) => (await requireSource()).session(input),
|
|
153
215
|
groups: async (query) => (await requireSource()).groups(query),
|
|
154
216
|
quota: async () => {
|
|
217
|
+
// Capture the source generation before resolving the owner and before the
|
|
218
|
+
// asynchronous provider read. A handoff during either step changes the
|
|
219
|
+
// token, and the observer drops the old source's snapshot instead of
|
|
220
|
+
// classifying it against the replacement source's baseline.
|
|
221
|
+
const observer = observation.observer;
|
|
222
|
+
const epoch = observer?.epoch();
|
|
223
|
+
const owner = delegation.activeOwner;
|
|
155
224
|
const source = await requireSource();
|
|
156
225
|
// Mirrors `SnapshotService`: a source without quota answers as unavailable.
|
|
157
226
|
if (!source.quota)
|
|
158
227
|
throw new Error("Quota source unavailable");
|
|
159
|
-
|
|
228
|
+
const snapshot = await source.quota();
|
|
229
|
+
if (observer !== undefined && delegation.activeOwner === owner) {
|
|
230
|
+
observer.observe(snapshot, epoch);
|
|
231
|
+
}
|
|
232
|
+
return snapshot;
|
|
160
233
|
},
|
|
161
234
|
refreshAnalytics: async () => {
|
|
162
235
|
// Only refresh an already-created active source; never build one here.
|
|
163
236
|
await delegation.activeOwner?.source?.refreshAnalytics?.();
|
|
164
237
|
},
|
|
165
238
|
close: async () => {
|
|
166
|
-
//
|
|
167
|
-
//
|
|
239
|
+
// Final host close lands here: release every source this host created,
|
|
240
|
+
// without ending the leases themselves.
|
|
168
241
|
await Promise.all(delegation.owners.map((owner) => releaseOwnerSource(owner, logger)));
|
|
169
242
|
},
|
|
170
243
|
};
|
|
@@ -248,43 +321,89 @@ function canonicalMinIntervalMs(configDir) {
|
|
|
248
321
|
return undefined;
|
|
249
322
|
}
|
|
250
323
|
}
|
|
251
|
-
/**
|
|
252
|
-
|
|
324
|
+
/**
|
|
325
|
+
* Port, effective web switch and interval from the loaded config and host
|
|
326
|
+
* version; a read failure keeps safe defaults. The version probe runs only when
|
|
327
|
+
* the key is absent, so explicit configuration never spawns a CLI process.
|
|
328
|
+
*/
|
|
329
|
+
async function readDashboardConfig(workspaceRoot, configDir, logger, hostVersion, detectHostVersion) {
|
|
253
330
|
try {
|
|
254
|
-
const
|
|
331
|
+
const meta = createLoadConfigMeta();
|
|
332
|
+
const config = await loadConfig(undefined, meta, {
|
|
255
333
|
configRootDir: workspaceRoot,
|
|
256
334
|
globalConfigDir: configDir,
|
|
257
335
|
});
|
|
336
|
+
const explicitEnabled = getDashboardEnabledSetting(config, meta);
|
|
337
|
+
const invalidConfig = hasInvalidDashboardWebConfig(meta);
|
|
338
|
+
let resolvedHostVersion = typeof hostVersion === "string" && hostVersion.trim().length > 0 ? hostVersion : undefined;
|
|
339
|
+
if (explicitEnabled === undefined && !invalidConfig && resolvedHostVersion === undefined) {
|
|
340
|
+
resolvedHostVersion = await detectHostVersion();
|
|
341
|
+
}
|
|
258
342
|
return {
|
|
259
343
|
port: getGuiDashboardPort(config),
|
|
344
|
+
webEnabled: resolveDashboardWebEnabled({
|
|
345
|
+
...(explicitEnabled !== undefined ? { explicitEnabled } : {}),
|
|
346
|
+
...(resolvedHostVersion !== undefined ? { hostVersion: resolvedHostVersion } : {}),
|
|
347
|
+
invalidConfig,
|
|
348
|
+
}),
|
|
349
|
+
hostVersion: resolvedHostVersion,
|
|
260
350
|
minIntervalMs: positiveNumber(config.minIntervalMs),
|
|
261
351
|
};
|
|
262
352
|
}
|
|
263
353
|
catch {
|
|
264
|
-
logger.warn("dashboard config unavailable; using
|
|
265
|
-
return {
|
|
354
|
+
logger.warn("dashboard config unavailable; using safe defaults", "config-unavailable");
|
|
355
|
+
return {
|
|
356
|
+
port: getGuiDashboardPort(undefined),
|
|
357
|
+
webEnabled: false,
|
|
358
|
+
hostVersion: undefined,
|
|
359
|
+
minIntervalMs: undefined,
|
|
360
|
+
};
|
|
266
361
|
}
|
|
267
362
|
}
|
|
268
363
|
async function createProductionSource(options) {
|
|
269
364
|
return createDashboardReadSource(options);
|
|
270
365
|
}
|
|
271
366
|
/**
|
|
272
|
-
* Settings store, first owner's eager source
|
|
273
|
-
*
|
|
274
|
-
*
|
|
367
|
+
* Settings store, first owner's eager source, one host snapshot service and the
|
|
368
|
+
* optional web transport, in that order; each failure is contained. The
|
|
369
|
+
* transport receives that snapshot service, whose stable delegating source
|
|
370
|
+
* keeps the same cache and pollers across later owner handoffs. A disabled or
|
|
371
|
+
* unavailable web transport never tears down that shared runtime.
|
|
275
372
|
*/
|
|
276
|
-
async function startHost(options, context, delegation) {
|
|
373
|
+
async function startHost(options, context, delegation, runtime, observation) {
|
|
277
374
|
const createSettingsStore = options.createSettingsStore ?? createGuiSettingsStore;
|
|
278
375
|
let settings;
|
|
279
376
|
try {
|
|
280
377
|
settings = createSettingsStore({
|
|
281
378
|
configDir: context.configDir,
|
|
282
379
|
workspaceRoot: options.workspaceRoot,
|
|
380
|
+
...(context.hostVersion !== undefined ? { hostVersion: context.hostVersion } : {}),
|
|
283
381
|
});
|
|
284
382
|
}
|
|
285
383
|
catch {
|
|
286
384
|
throw new DashboardLifecycleError("settings-unavailable");
|
|
287
385
|
}
|
|
386
|
+
// Publish the same store to every transport. It stays host-owned until the
|
|
387
|
+
// last lease disposes, regardless of whether the web transport starts.
|
|
388
|
+
runtime.settings = settings;
|
|
389
|
+
// One observer for this shared host. It is fed by the stable delegating
|
|
390
|
+
// source's quota cycle, so it adds no poller and works with every transport
|
|
391
|
+
// combination, including a closed panel. Settings are read per cycle so a
|
|
392
|
+
// saved threshold or visibility change applies without a restart.
|
|
393
|
+
try {
|
|
394
|
+
const quotaNotifications = createQuotaNotificationObserver({
|
|
395
|
+
loadSettings: async () => quotaNotificationSettingsFromSnapshot(await settings.settings()),
|
|
396
|
+
...(options.quotaNotificationStatePath !== undefined
|
|
397
|
+
? { statePath: options.quotaNotificationStatePath }
|
|
398
|
+
: {}),
|
|
399
|
+
logger: context.logger,
|
|
400
|
+
});
|
|
401
|
+
runtime.quotaNotifications = quotaNotifications;
|
|
402
|
+
observation.observer = quotaNotifications;
|
|
403
|
+
}
|
|
404
|
+
catch (error) {
|
|
405
|
+
context.logger.warn("quota notifications unavailable", failureLabel(error));
|
|
406
|
+
}
|
|
288
407
|
const firstOwner = delegation.activeOwner;
|
|
289
408
|
if (!firstOwner)
|
|
290
409
|
throw new DashboardLifecycleError("source-unavailable");
|
|
@@ -296,24 +415,68 @@ async function startHost(options, context, delegation) {
|
|
|
296
415
|
catch {
|
|
297
416
|
throw new DashboardLifecycleError("source-unavailable");
|
|
298
417
|
}
|
|
299
|
-
|
|
418
|
+
// The host owns exactly one snapshot service. HTTP and the typed RPC
|
|
419
|
+
// transport receive it; they never construct or close it themselves.
|
|
420
|
+
const createSnapshots = options.createSnapshots ?? createSnapshotService;
|
|
421
|
+
let snapshots;
|
|
422
|
+
try {
|
|
423
|
+
snapshots = createSnapshots({
|
|
424
|
+
source: runtime.source,
|
|
425
|
+
minIntervalMs: minIntervalGetter(context),
|
|
426
|
+
logger: context.logger,
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
catch {
|
|
430
|
+
await runtime.close();
|
|
431
|
+
throw new DashboardLifecycleError("server-unavailable");
|
|
432
|
+
}
|
|
433
|
+
runtime.snapshots = snapshots;
|
|
434
|
+
// One host-lifetime quota viewer keeps `viewers >= 1` across ordinary window
|
|
435
|
+
// watch aborts and silent renewals, so the original `viewers === 0` teardown
|
|
436
|
+
// (stopPollers, compute clearing, cache dirtying) never runs on a timeout.
|
|
437
|
+
// Global bounded analytics pages therefore stay warm until normal eviction.
|
|
438
|
+
runtime.quotaMonitor = snapshots.addScopedViewer("quota");
|
|
439
|
+
// A scoped viewer starts the shared pollers, but quota polling has no
|
|
440
|
+
// registered interest until an actual quota read installs its compute key.
|
|
441
|
+
// Prime it once so the single host poller remains useful between windows.
|
|
442
|
+
void snapshots.quota().catch(() => undefined);
|
|
443
|
+
// Web is a secondary transport; the version-gated policy decides whether it
|
|
444
|
+
// starts. The shared quota monitor is already live; returning no handle starts
|
|
445
|
+
// no HTTP listener, SSE hub, or static serving, and does not activate analytics.
|
|
446
|
+
if (!context.webEnabled)
|
|
447
|
+
return undefined;
|
|
300
448
|
const createServer = options.createServer ?? createDashboardServer;
|
|
301
449
|
try {
|
|
302
450
|
return await createServer({
|
|
303
451
|
port: context.port,
|
|
304
|
-
|
|
452
|
+
snapshots,
|
|
305
453
|
settings,
|
|
306
|
-
minIntervalMs: minIntervalGetter(context),
|
|
307
454
|
logger: context.logger,
|
|
308
455
|
});
|
|
309
456
|
}
|
|
310
457
|
catch (error) {
|
|
311
458
|
// A bind failure already logged its one controlled line inside the transport
|
|
312
459
|
// and keeps its `port-unavailable` reason; every other server failure is
|
|
313
|
-
// reported as `server-unavailable`.
|
|
460
|
+
// reported as `server-unavailable`. The shared runtime deliberately stays
|
|
461
|
+
// alive for its leases (the RPC transport can still use it); only the
|
|
462
|
+
// failed web transport is detached by the transport itself.
|
|
314
463
|
throw new DashboardLifecycleError(unavailableReason(error));
|
|
315
464
|
}
|
|
316
465
|
}
|
|
466
|
+
/**
|
|
467
|
+
* The transport-neutral host dependencies for a lease. A missing snapshot
|
|
468
|
+
* service or settings store means the shared runtime never completed, so there
|
|
469
|
+
* is nothing safe to attach a second transport to.
|
|
470
|
+
*/
|
|
471
|
+
function transportRuntime(runtime) {
|
|
472
|
+
if (!runtime.snapshots || !runtime.settings)
|
|
473
|
+
return undefined;
|
|
474
|
+
return {
|
|
475
|
+
snapshots: runtime.snapshots,
|
|
476
|
+
settings: runtime.settings,
|
|
477
|
+
...(runtime.quotaNotifications ? { quotaNotifications: runtime.quotaNotifications } : {}),
|
|
478
|
+
};
|
|
479
|
+
}
|
|
317
480
|
function makeDispose(host, owner, handle) {
|
|
318
481
|
let disposed = false;
|
|
319
482
|
return async () => {
|
|
@@ -321,10 +484,16 @@ function makeDispose(host, owner, handle) {
|
|
|
321
484
|
return;
|
|
322
485
|
disposed = true;
|
|
323
486
|
host.refs = Math.max(0, host.refs - 1);
|
|
324
|
-
dropOwner(host, owner);
|
|
487
|
+
const activeChanged = dropOwner(host, owner);
|
|
325
488
|
const closing = disposeOwner(owner, host.logger);
|
|
326
489
|
if (host.refs > 0) {
|
|
327
|
-
// A live lease keeps the socket
|
|
490
|
+
// A live lease keeps the socket and the shared runtime. The surviving
|
|
491
|
+
// owner serves the next request, so cached pages from the disposed owner
|
|
492
|
+
// are invalidated before any client can see them as fresh.
|
|
493
|
+
if (activeChanged) {
|
|
494
|
+
host.runtime.snapshots?.sourceChanged();
|
|
495
|
+
host.runtime.quotaNotifications?.sourceChanged();
|
|
496
|
+
}
|
|
328
497
|
await closing;
|
|
329
498
|
return;
|
|
330
499
|
}
|
|
@@ -339,6 +508,7 @@ function makeDispose(host, owner, handle) {
|
|
|
339
508
|
host.logger.warn("dashboard stop failed", failureLabel(error));
|
|
340
509
|
}
|
|
341
510
|
}
|
|
511
|
+
await host.runtime.close();
|
|
342
512
|
await closing;
|
|
343
513
|
};
|
|
344
514
|
}
|
|
@@ -358,17 +528,21 @@ async function attachLease(host, owner) {
|
|
|
358
528
|
host.logger.error("dashboard unavailable", host.failure);
|
|
359
529
|
}
|
|
360
530
|
}
|
|
531
|
+
const runtime = transportRuntime(host.runtime);
|
|
361
532
|
return {
|
|
362
533
|
port: host.port,
|
|
363
534
|
state: "unavailable",
|
|
364
535
|
reason: host.failure,
|
|
536
|
+
...(runtime ? { runtime } : {}),
|
|
365
537
|
dispose: makeDispose(host, owner, undefined),
|
|
366
538
|
};
|
|
367
539
|
}
|
|
540
|
+
const runtime = transportRuntime(host.runtime);
|
|
368
541
|
return {
|
|
369
542
|
port: host.port,
|
|
370
543
|
state: "running",
|
|
371
|
-
url: handle.url,
|
|
544
|
+
...(handle ? { url: handle.url } : {}),
|
|
545
|
+
...(runtime ? { runtime } : {}),
|
|
372
546
|
dispose: makeDispose(host, owner, handle),
|
|
373
547
|
};
|
|
374
548
|
}
|
|
@@ -379,7 +553,8 @@ async function attachLease(host, owner) {
|
|
|
379
553
|
export async function startDashboard(options) {
|
|
380
554
|
const logger = options.logger ?? createGuiLogger();
|
|
381
555
|
const configDir = options.configDir ?? getOpencodeRuntimeDirs().configDir;
|
|
382
|
-
const
|
|
556
|
+
const detectHostVersion = options.detectHostVersion ?? detectOpenCodeVersion;
|
|
557
|
+
const { port, webEnabled, hostVersion, minIntervalMs } = await readDashboardConfig(options.workspaceRoot, configDir, logger, options.hostVersion, detectHostVersion);
|
|
383
558
|
const hosts = hostRegistry().hosts;
|
|
384
559
|
const existing = hosts.get(port);
|
|
385
560
|
if (existing) {
|
|
@@ -390,12 +565,15 @@ export async function startDashboard(options) {
|
|
|
390
565
|
}
|
|
391
566
|
const owner = createOwner(options, configDir);
|
|
392
567
|
const delegation = { owners: [owner], activeOwner: owner };
|
|
568
|
+
const observation = {};
|
|
569
|
+
const runtime = createRuntime(createDelegatingSource(delegation, logger, observation), logger);
|
|
393
570
|
const host = {
|
|
394
571
|
port,
|
|
395
572
|
logger,
|
|
396
573
|
delegation,
|
|
574
|
+
runtime,
|
|
397
575
|
refs: 1,
|
|
398
|
-
start: startHost(options, { configDir, port, minIntervalMs, logger }, delegation),
|
|
576
|
+
start: startHost(options, { configDir, port, webEnabled, hostVersion, minIntervalMs, logger }, delegation, runtime, observation),
|
|
399
577
|
};
|
|
400
578
|
hosts.set(port, host);
|
|
401
579
|
return attachLease(host, owner);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-side primary quota-window classification for the native
|
|
3
|
+
* `session.header` tokens (migration architecture §8, Stage 6).
|
|
4
|
+
*
|
|
5
|
+
* The projection only promotes an **existing** finite percentage row whose
|
|
6
|
+
* provider-owned identity says it is one of the subscription's main usage
|
|
7
|
+
* windows. Display labels, emission position, current utilization and the
|
|
8
|
+
* "most constraining" row never decide membership or slot. Budget, spend,
|
|
9
|
+
* balance, credits, model/tool-specific secondary allowances and
|
|
10
|
+
* response-defined dynamic rows stay in the combined preview and full card.
|
|
11
|
+
*
|
|
12
|
+
* Slots are stable per-card family positions in full-card order (0 outer,
|
|
13
|
+
* 1 middle, 2 inner), not global time-unit ranks; they are assigned from
|
|
14
|
+
* established window semantics, never from utilization. A missing earlier
|
|
15
|
+
* window leaves later windows on their original slot. Identity follows
|
|
16
|
+
* `rowIdForEntry` exactly: `semantic.metric` first, then an explicit provider
|
|
17
|
+
* `rowKey`, then the aggregate result-type identity. Rules are keyed by
|
|
18
|
+
* provider id so a shared row key cannot leak across providers.
|
|
19
|
+
*/
|
|
20
|
+
import type { PrimaryQuotaWindowSlot } from "../contracts/dashboard.js";
|
|
21
|
+
import type { QuotaToastEntry } from "../lib/entries.js";
|
|
22
|
+
/**
|
|
23
|
+
* Stable slot for an eligible primary window, or `undefined` when the entry is
|
|
24
|
+
* not classified. Callers must still apply row-id deduplication and the
|
|
25
|
+
* three-reference limit.
|
|
26
|
+
*/
|
|
27
|
+
export declare function primaryQuotaWindowSlot(providerId: string, entry: QuotaToastEntry): PrimaryQuotaWindowSlot | undefined;
|
|
28
|
+
//# sourceMappingURL=primary-quota-windows.d.ts.map
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { isPercentEntry } from "../lib/entries.js";
|
|
2
|
+
/**
|
|
3
|
+
* Explicit, evidence-backed mapping. Omitted providers intentionally have no
|
|
4
|
+
* defensible primary/auxiliary split in their current source (see the Stage 6
|
|
5
|
+
* report); adding one is a provider-semantics change, not a label heuristic.
|
|
6
|
+
*/
|
|
7
|
+
const PRIMARY_QUOTA_WINDOW_RULES = {
|
|
8
|
+
// 5h, weekly, and the provider's explicit Fable weekly slot; `window:month`
|
|
9
|
+
// is Usage Credits (`src/providers/anthropic.ts` 160-195, 240-274).
|
|
10
|
+
anthropic: {
|
|
11
|
+
rowKeys: [
|
|
12
|
+
{ value: "window:five_hour", slot: 0 },
|
|
13
|
+
{ value: "window:week", slot: 1 },
|
|
14
|
+
],
|
|
15
|
+
namedMetrics: [{ value: "Fable weekly", slot: 2 }],
|
|
16
|
+
},
|
|
17
|
+
// 5h/weekly/monthly ChatGPT windows; Code Review is a special secondary
|
|
18
|
+
// window (`src/providers/openai.ts` 56-75, 239-261).
|
|
19
|
+
openai: {
|
|
20
|
+
rowKeys: [
|
|
21
|
+
{ value: "window:five_hour", slot: 0 },
|
|
22
|
+
{ value: "window:week", slot: 1 },
|
|
23
|
+
{ value: "window:month", slot: 2 },
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
// GLM five-hour/weekly plan windows; MCP is a tool-specific allowance
|
|
27
|
+
// (`src/providers/glm-coding-plan-provider.ts` 40-79).
|
|
28
|
+
zai: {
|
|
29
|
+
rowKeys: [
|
|
30
|
+
{ value: "window:five_hour", slot: 0 },
|
|
31
|
+
{ value: "window:week", slot: 1 },
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
zhipu: {
|
|
35
|
+
rowKeys: [
|
|
36
|
+
{ value: "window:five_hour", slot: 0 },
|
|
37
|
+
{ value: "window:week", slot: 1 },
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
// Rolling/weekly/monthly Go plan windows (`src/providers/opencode-go.ts` 44-55).
|
|
41
|
+
"opencode-go": {
|
|
42
|
+
rowKeys: [
|
|
43
|
+
{ value: "window:five_hour", slot: 0 },
|
|
44
|
+
{ value: "window:week", slot: 1 },
|
|
45
|
+
{ value: "window:month", slot: 2 },
|
|
46
|
+
],
|
|
47
|
+
},
|
|
48
|
+
// The plan entitlement is Copilot's only primary window, so it occupies the
|
|
49
|
+
// outer slot; the additional-usage row is a budget percent
|
|
50
|
+
// (`src/providers/copilot.ts` 109-142, 185-215).
|
|
51
|
+
copilot: { rowKeys: [{ value: "window:month", slot: 0 }] },
|
|
52
|
+
// Daily/monthly subscription limits are the provider's two-window family in
|
|
53
|
+
// full-card order (`src/providers/nanogpt.ts` 70-105).
|
|
54
|
+
nanogpt: {
|
|
55
|
+
windows: [
|
|
56
|
+
{ value: "day", slot: 0 },
|
|
57
|
+
{ value: "month", slot: 1 },
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
// MiniMax token-plan 5h/weekly windows (`src/providers/minimax-coding-plan.ts`
|
|
61
|
+
// 105-126, 246-260).
|
|
62
|
+
"minimax-coding-plan": {
|
|
63
|
+
windows: [
|
|
64
|
+
{ value: "five_hour", slot: 0 },
|
|
65
|
+
{ value: "week", slot: 1 },
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
"minimax-china-coding-plan": {
|
|
69
|
+
windows: [
|
|
70
|
+
{ value: "five_hour", slot: 0 },
|
|
71
|
+
{ value: "week", slot: 1 },
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
// MiMo's plan window is the card's only primary window, so it occupies the
|
|
75
|
+
// outer slot; its balance rows are quantities, not percentages
|
|
76
|
+
// (`src/providers/mimo.ts` 154-189).
|
|
77
|
+
xiaomi: { windows: [{ value: "month", slot: 0 }] },
|
|
78
|
+
// Kilo Pass credits are a quota percentage with a used/limit/remaining basis,
|
|
79
|
+
// not a balance; the card has one stable primary slot (`src/providers/kilo.ts`
|
|
80
|
+
// 52-82).
|
|
81
|
+
kilo: { components: [{ value: "remaining_credits", slot: 0 }] },
|
|
82
|
+
// xAI always emits exactly one provider-supplied period row, so any valid
|
|
83
|
+
// period identity occupies the same outer slot even when the response-defined
|
|
84
|
+
// period changes (`src/providers/xai.ts` 29-40, 92-153).
|
|
85
|
+
xai: {
|
|
86
|
+
rowKeys: [
|
|
87
|
+
{ value: "window:day", slot: 0 },
|
|
88
|
+
{ value: "window:week", slot: 0 },
|
|
89
|
+
{ value: "window:month", slot: 0 },
|
|
90
|
+
{ value: "named:period", slot: 0 },
|
|
91
|
+
],
|
|
92
|
+
},
|
|
93
|
+
// These providers always emit the same single surviving row, so its window
|
|
94
|
+
// meaning cannot move with availability. Synthetic always emits 5h then
|
|
95
|
+
// weekly; Alibaba Coding Plan always emits 5h/weekly/monthly in that order;
|
|
96
|
+
// Chutes emits one daily-reset quota window (`src/providers/synthetic.ts`
|
|
97
|
+
// 84-103, `src/providers/alibaba-coding-plan.ts` 116-159,
|
|
98
|
+
// `src/providers/chutes.ts` 43-55).
|
|
99
|
+
//
|
|
100
|
+
// Deliberately omitted untyped providers:
|
|
101
|
+
// - Alibaba Token Plan emits optional 5h/weekly
|
|
102
|
+
// (`src/providers/alibaba-token-plan.ts` 69-74).
|
|
103
|
+
// - Ollama Cloud emits optional session/weekly/included-credit rows
|
|
104
|
+
// (`src/providers/ollama-cloud.ts` 35-80).
|
|
105
|
+
// Their shared aggregate row keeps one rowId while the represented window
|
|
106
|
+
// changes with availability, so a reference would be unstable.
|
|
107
|
+
// - Custom `quota-providers` result types are user configuration, not
|
|
108
|
+
// provider-owned primary/auxiliary evidence.
|
|
109
|
+
synthetic: { untypedSlot: 0 },
|
|
110
|
+
chutes: { untypedSlot: 0 },
|
|
111
|
+
"alibaba-coding-plan": { untypedSlot: 0 },
|
|
112
|
+
};
|
|
113
|
+
function slotFor(values, value) {
|
|
114
|
+
return values?.find((entry) => entry.value === value)?.slot;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Stable slot for an eligible primary window, or `undefined` when the entry is
|
|
118
|
+
* not classified. Callers must still apply row-id deduplication and the
|
|
119
|
+
* three-reference limit.
|
|
120
|
+
*/
|
|
121
|
+
export function primaryQuotaWindowSlot(providerId, entry) {
|
|
122
|
+
const rule = PRIMARY_QUOTA_WINDOW_RULES[providerId];
|
|
123
|
+
if (!rule)
|
|
124
|
+
return undefined;
|
|
125
|
+
if (!isPercentEntry(entry) || !Number.isFinite(entry.percentRemaining))
|
|
126
|
+
return undefined;
|
|
127
|
+
if (entry.accounting.resultType !== "quota" && entry.accounting.resultType !== "rate_limit") {
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
if (entry.semantic) {
|
|
131
|
+
if (entry.semantic.prominence !== "primary")
|
|
132
|
+
return undefined;
|
|
133
|
+
const metric = entry.semantic.metric;
|
|
134
|
+
if (metric.kind === "window")
|
|
135
|
+
return slotFor(rule.windows, metric.window);
|
|
136
|
+
if (metric.kind === "named")
|
|
137
|
+
return slotFor(rule.namedMetrics, metric.name);
|
|
138
|
+
if (metric.kind === "component")
|
|
139
|
+
return slotFor(rule.components, metric.component);
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
142
|
+
if (entry.rowKey !== undefined) {
|
|
143
|
+
return slotFor(rule.rowKeys, entry.rowKey);
|
|
144
|
+
}
|
|
145
|
+
return rule.untypedSlot;
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=primary-quota-windows.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ProviderCard } from "../contracts/dashboard.js";
|
|
2
2
|
import type { CardId } from "../contracts/identity.js";
|
|
3
3
|
import type { QuotaStatusLiveProbe } from "../lib/quota-render-data.js";
|
|
4
4
|
import type { QuotaToastConfig } from "../lib/types.js";
|