opencode-quota-gui 1.1.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 +96 -34
- 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/analytics-temporal.d.ts +39 -0
- package/dist/contracts/analytics-temporal.js +11 -0
- 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 +40 -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/contracts/temporal.d.ts +126 -0
- package/dist/contracts/temporal.js +10 -0
- package/dist/data/modelsdev-temporal.min.json +3075 -0
- package/dist/gui/aggregation.js +3 -0
- package/dist/gui/analytics-engine.js +30 -0
- package/dist/gui/analytics-model.js +181 -1
- package/dist/gui/analytics-pricing-revision.d.ts +43 -0
- package/dist/gui/analytics-pricing-revision.js +160 -0
- package/dist/gui/analytics-state.d.ts +7 -2
- package/dist/gui/analytics-state.js +14 -2
- package/dist/gui/config.d.ts +20 -3
- package/dist/gui/config.js +60 -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/sources.js +28 -0
- package/dist/gui/temporal-quota-policy-data.d.ts +24 -0
- package/dist/gui/temporal-quota-policy-data.js +43 -0
- package/dist/gui/temporal-quota-policy.d.ts +38 -0
- package/dist/gui/temporal-quota-policy.js +182 -0
- package/dist/gui/temporal-status.d.ts +53 -0
- package/dist/gui/temporal-status.js +815 -0
- 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 +81 -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/modelsdev-temporal.d.ts +143 -0
- package/dist/lib/modelsdev-temporal.js +896 -0
- 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/quota-stats.d.ts +22 -1
- package/dist/lib/quota-stats.js +111 -15
- package/dist/lib/synthetic.js +8 -0
- package/dist/lib/types.d.ts +24 -0
- package/dist/lib/types.js +4 -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-BZwMJ6Ax.css → index-cDd9jUVY.css} +1 -1
- package/dist/ui/assets/popover-BGkgv9s0.js +1 -0
- package/dist/ui/assets/popover-mkHTmNjv.css +1 -0
- package/dist/ui/index.html +2 -2
- package/package.json +49 -39
- 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/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/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-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/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/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-CjNjqsse.js +0 -8
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* diagnostics are never copied into a payload.
|
|
11
11
|
*/
|
|
12
12
|
import { orderCardsByPreference } from "../contracts/card-order.js";
|
|
13
|
+
import { PRIMARY_QUOTA_WINDOW_LIMIT, } from "../contracts/dashboard.js";
|
|
13
14
|
import { OPENAI_CREDITS_INFO, OPENAI_CREDITS_ROW_KEY, OPENAI_CREDITS_ROW_LABEL, OPENAI_CREDITS_ROW_RESULT_TYPE, OPENAI_RESETS_INFO, OPENAI_RESETS_ROW_KEY, OPENAI_RESETS_ROW_LABEL, OPENAI_RESETS_ROW_RESULT_TYPE, } from "../contracts/openai-quota.js";
|
|
14
15
|
import { formatAccountingQuantity, interpretAccountingRow, isCanonicalAccountingDecimal, } from "../lib/accounting-format.js";
|
|
15
16
|
import { sanitizeDisplayText, sanitizeQuotaToastEntry, sanitizeSingleLineDisplayText, } from "../lib/display-sanitize.js";
|
|
@@ -19,6 +20,7 @@ import { scrubCredentialErrorText } from "../lib/opencode-auth.js";
|
|
|
19
20
|
import { getQuotaProviderDisplayLabel } from "../lib/provider-metadata.js";
|
|
20
21
|
import { projectQuotaRunway } from "../lib/quota-exhaustion-projection.js";
|
|
21
22
|
import { buildCardId, buildProviderScopeCardId, hashQuotaCardIdentity, PROVIDER_SCOPE_IDENTITY_KEY, rowIdForEntry, } from "./identity.js";
|
|
23
|
+
import { primaryQuotaWindowSlot } from "./primary-quota-windows.js";
|
|
22
24
|
/** Controlled fallback for unknown/unsafe provider errors (spec §9 R38). */
|
|
23
25
|
export const PROVIDER_ERROR_GENERIC_MESSAGE = "Provider request failed; check upstream quota diagnostics.";
|
|
24
26
|
/** Controlled fallback label when an error label itself is unredactable. */
|
|
@@ -75,6 +77,8 @@ function mapProviderError(error, secrets) {
|
|
|
75
77
|
};
|
|
76
78
|
if (error.retryable === true)
|
|
77
79
|
mapped.retryable = true;
|
|
80
|
+
if (error.failureCategory !== undefined)
|
|
81
|
+
mapped.failureCategory = error.failureCategory;
|
|
78
82
|
return mapped;
|
|
79
83
|
}
|
|
80
84
|
// ---------------------------------------------------------------------------
|
|
@@ -164,7 +168,7 @@ function mapEntryRow(params) {
|
|
|
164
168
|
if (detailRows.length > 0)
|
|
165
169
|
row.detailRows = detailRows;
|
|
166
170
|
}
|
|
167
|
-
return row;
|
|
171
|
+
return { row, sanitizedEntry: entry };
|
|
168
172
|
}
|
|
169
173
|
applyResetFields(row, entry, preferences);
|
|
170
174
|
if (isValueEntry(entry)) {
|
|
@@ -179,7 +183,7 @@ function mapEntryRow(params) {
|
|
|
179
183
|
row.kind = "boolean";
|
|
180
184
|
row.booleanValue = entry.value;
|
|
181
185
|
}
|
|
182
|
-
return row;
|
|
186
|
+
return { row, sanitizedEntry: entry };
|
|
183
187
|
}
|
|
184
188
|
/**
|
|
185
189
|
* Rows are deduplicated by `rowId`: two entries that resolve to the same typed
|
|
@@ -188,9 +192,10 @@ function mapEntryRow(params) {
|
|
|
188
192
|
*/
|
|
189
193
|
function mapEntryRows(params) {
|
|
190
194
|
const rows = [];
|
|
195
|
+
const windowsBySlot = new Map();
|
|
191
196
|
const seen = new Set();
|
|
192
197
|
for (const entry of params.entries) {
|
|
193
|
-
const row = mapEntryRow({
|
|
198
|
+
const { row, sanitizedEntry } = mapEntryRow({
|
|
194
199
|
entry,
|
|
195
200
|
cardId: params.cardId,
|
|
196
201
|
preferences: params.preferences,
|
|
@@ -200,8 +205,17 @@ function mapEntryRows(params) {
|
|
|
200
205
|
continue;
|
|
201
206
|
seen.add(row.rowId);
|
|
202
207
|
rows.push(row);
|
|
208
|
+
const slot = primaryQuotaWindowSlot(params.providerId, sanitizedEntry);
|
|
209
|
+
if (slot !== undefined &&
|
|
210
|
+
windowsBySlot.size < PRIMARY_QUOTA_WINDOW_LIMIT &&
|
|
211
|
+
!windowsBySlot.has(slot)) {
|
|
212
|
+
windowsBySlot.set(slot, { rowId: row.rowId, slot });
|
|
213
|
+
}
|
|
203
214
|
}
|
|
204
|
-
return
|
|
215
|
+
return {
|
|
216
|
+
rows,
|
|
217
|
+
primaryQuotaWindows: [...windowsBySlot.values()].sort((left, right) => left.slot - right.slot),
|
|
218
|
+
};
|
|
205
219
|
}
|
|
206
220
|
const OPENAI_OPTIONAL_ROW_ACCOUNTING = {
|
|
207
221
|
acquisitionMethod: "remote_api",
|
|
@@ -273,6 +287,13 @@ function pushInto(map, key, value) {
|
|
|
273
287
|
}
|
|
274
288
|
function buildProviderCard(params) {
|
|
275
289
|
const cardId = buildProviderScopeCardId(params.providerId);
|
|
290
|
+
const mapped = mapEntryRows({
|
|
291
|
+
entries: params.entries,
|
|
292
|
+
providerId: params.providerId,
|
|
293
|
+
cardId,
|
|
294
|
+
preferences: params.preferences,
|
|
295
|
+
nowMs: params.nowMs,
|
|
296
|
+
});
|
|
276
297
|
const card = {
|
|
277
298
|
cardId,
|
|
278
299
|
providerId: params.providerId,
|
|
@@ -280,14 +301,12 @@ function buildProviderCard(params) {
|
|
|
280
301
|
providerScopeId: params.providerScopeId,
|
|
281
302
|
providerScopeHash: params.providerScopeHash,
|
|
282
303
|
labelSource: "provider",
|
|
283
|
-
rows:
|
|
284
|
-
entries: params.entries,
|
|
285
|
-
cardId,
|
|
286
|
-
preferences: params.preferences,
|
|
287
|
-
nowMs: params.nowMs,
|
|
288
|
-
}),
|
|
304
|
+
rows: mapped.rows,
|
|
289
305
|
errors: params.errors.map((error) => mapProviderError(error, params.secrets)),
|
|
290
306
|
};
|
|
307
|
+
if (mapped.primaryQuotaWindows.length > 0) {
|
|
308
|
+
card.primaryQuotaWindows = mapped.primaryQuotaWindows;
|
|
309
|
+
}
|
|
291
310
|
if (params.providerId === "openai")
|
|
292
311
|
card.visibilityRows = openAiOptionalVisibilityRows(cardId);
|
|
293
312
|
const observedAtIso = latestObservedAtIso(params.entries);
|
|
@@ -305,6 +324,13 @@ function buildAccountCard(params) {
|
|
|
305
324
|
const planLabel = params.account.planLabel
|
|
306
325
|
? sanitizeSingleLineDisplayText(params.account.planLabel).trim()
|
|
307
326
|
: "";
|
|
327
|
+
const mapped = mapEntryRows({
|
|
328
|
+
entries: params.entries,
|
|
329
|
+
providerId: params.providerId,
|
|
330
|
+
cardId,
|
|
331
|
+
preferences: params.preferences,
|
|
332
|
+
nowMs: params.nowMs,
|
|
333
|
+
});
|
|
308
334
|
const card = {
|
|
309
335
|
cardId,
|
|
310
336
|
providerId: params.providerId,
|
|
@@ -315,14 +341,12 @@ function buildAccountCard(params) {
|
|
|
315
341
|
accountLabel: sanitizedLabel || `Account ${params.accountIndex + 1}`,
|
|
316
342
|
...(planLabel ? { planLabel } : {}),
|
|
317
343
|
labelSource: sanitizedLabel ? "connection" : "account",
|
|
318
|
-
rows:
|
|
319
|
-
entries: params.entries,
|
|
320
|
-
cardId,
|
|
321
|
-
preferences: params.preferences,
|
|
322
|
-
nowMs: params.nowMs,
|
|
323
|
-
}),
|
|
344
|
+
rows: mapped.rows,
|
|
324
345
|
errors: params.errors.map((error) => mapProviderError(error, params.secrets)),
|
|
325
346
|
};
|
|
347
|
+
if (mapped.primaryQuotaWindows.length > 0) {
|
|
348
|
+
card.primaryQuotaWindows = mapped.primaryQuotaWindows;
|
|
349
|
+
}
|
|
326
350
|
if (params.providerId === "openai")
|
|
327
351
|
card.visibilityRows = openAiOptionalVisibilityRows(cardId);
|
|
328
352
|
const observedAtIso = latestObservedAtIso(params.entries);
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import type { QuotaCardRow } from "../contracts/dashboard.js";
|
|
2
|
+
import type { ProviderFailureCategory } from "../contracts/provider-failure.js";
|
|
3
|
+
import { type ResetObservation } from "../lib/quota-reset-notifications.js";
|
|
4
|
+
export declare const QUOTA_NOTIFICATION_DETECTOR_STATE_VERSION: 1;
|
|
5
|
+
/** Shared proven reset-transition age limit re-exported for detector consumers. */
|
|
6
|
+
export declare const RESET_TRANSITION_MAX_AGE_MS: number;
|
|
7
|
+
/**
|
|
8
|
+
* The only provider failure category that may produce a `provider-error`
|
|
9
|
+
* notification. It must come from structured provenance, never display text.
|
|
10
|
+
*/
|
|
11
|
+
export declare const QUOTA_NOTIFICATION_PROVIDER_ERROR_CATEGORY: "provider_api";
|
|
12
|
+
export type QuotaNotificationProviderFailureCategory = typeof QUOTA_NOTIFICATION_PROVIDER_ERROR_CATEGORY;
|
|
13
|
+
export type QuotaNotificationKind = "low" | "exhausted" | "reset" | "provider-error";
|
|
14
|
+
interface QuotaNotificationBase {
|
|
15
|
+
/** Deterministic event identity used for cooldown and delivery dedupe. */
|
|
16
|
+
fingerprint: string;
|
|
17
|
+
cardId: string;
|
|
18
|
+
providerId: string;
|
|
19
|
+
/** Display-only context; never part of `fingerprint`. */
|
|
20
|
+
providerLabel: string;
|
|
21
|
+
/** Display-only context; never part of `fingerprint`. */
|
|
22
|
+
accountLabel?: string;
|
|
23
|
+
observedAtMs: number;
|
|
24
|
+
}
|
|
25
|
+
export interface QuotaLowNotification extends QuotaNotificationBase {
|
|
26
|
+
kind: "low";
|
|
27
|
+
rowId: string;
|
|
28
|
+
/** Display-only context; never part of `fingerprint`. */
|
|
29
|
+
rowLabel: string;
|
|
30
|
+
thresholdPercent: number;
|
|
31
|
+
percentRemaining: number;
|
|
32
|
+
/** Present only when the current row carried a valid reset boundary. */
|
|
33
|
+
resetAtIso?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface QuotaExhaustedNotification extends QuotaNotificationBase {
|
|
36
|
+
kind: "exhausted";
|
|
37
|
+
rowId: string;
|
|
38
|
+
/** Display-only context; never part of `fingerprint`. */
|
|
39
|
+
rowLabel: string;
|
|
40
|
+
percentRemaining: number;
|
|
41
|
+
/** Present only when the current row carried a valid reset boundary. */
|
|
42
|
+
resetAtIso?: string;
|
|
43
|
+
}
|
|
44
|
+
export interface QuotaResetNotification extends QuotaNotificationBase {
|
|
45
|
+
kind: "reset";
|
|
46
|
+
rowId: string;
|
|
47
|
+
rowLabel: string;
|
|
48
|
+
percentRemaining: number;
|
|
49
|
+
/** The new boundary that proved the reset. */
|
|
50
|
+
resetAtIso: string;
|
|
51
|
+
/** The previous boundary that had not passed when the proof was captured. */
|
|
52
|
+
previousResetAtIso: string;
|
|
53
|
+
}
|
|
54
|
+
export interface QuotaProviderErrorNotification extends QuotaNotificationBase {
|
|
55
|
+
kind: "provider-error";
|
|
56
|
+
category: QuotaNotificationProviderFailureCategory;
|
|
57
|
+
}
|
|
58
|
+
export type QuotaNotification = QuotaLowNotification | QuotaExhaustedNotification | QuotaResetNotification | QuotaProviderErrorNotification;
|
|
59
|
+
/** One normalized semantic quota row. `QuotaCardRow` is structurally assignable. */
|
|
60
|
+
export interface QuotaNotificationRowObservation {
|
|
61
|
+
rowId: string;
|
|
62
|
+
label: string;
|
|
63
|
+
kind: QuotaCardRow["kind"];
|
|
64
|
+
resultType: QuotaCardRow["resultType"];
|
|
65
|
+
percentRemaining?: number;
|
|
66
|
+
resetAtIso?: string;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* One normalized visible card. `ProviderCard` is structurally assignable; its
|
|
70
|
+
* structured errors are passed through unchanged.
|
|
71
|
+
*/
|
|
72
|
+
export interface QuotaNotificationCardObservation {
|
|
73
|
+
cardId: string;
|
|
74
|
+
providerId: string;
|
|
75
|
+
providerLabel: string;
|
|
76
|
+
accountLabel?: string;
|
|
77
|
+
/** Bare provider-scope hash used by normalized legacy hidden-card semantics. */
|
|
78
|
+
providerScopeHash?: string;
|
|
79
|
+
rows: readonly QuotaNotificationRowObservation[];
|
|
80
|
+
errors?: readonly QuotaNotificationProviderErrorObservation[];
|
|
81
|
+
}
|
|
82
|
+
/** Only the safe structured category is read; labels and messages are ignored. */
|
|
83
|
+
export interface QuotaNotificationProviderErrorObservation {
|
|
84
|
+
failureCategory?: ProviderFailureCategory;
|
|
85
|
+
}
|
|
86
|
+
/** Unknown or absent categories are never notifiable. */
|
|
87
|
+
export declare function isNotifiableProviderError(error: QuotaNotificationProviderErrorObservation): boolean;
|
|
88
|
+
/** Exact reset observation shared with the legacy notifier. */
|
|
89
|
+
export type QuotaNotificationResetObservation = ResetObservation;
|
|
90
|
+
export interface QuotaNotificationRowState {
|
|
91
|
+
/** Latest percent reading; drives low/exhausted independently of reset proof. */
|
|
92
|
+
percentRemaining: number;
|
|
93
|
+
/** Latest observation time for the percent reading. */
|
|
94
|
+
observedAtMs: number;
|
|
95
|
+
/** Present once the row has supplied a valid reset boundary. */
|
|
96
|
+
reset?: QuotaNotificationResetObservation;
|
|
97
|
+
}
|
|
98
|
+
export interface QuotaNotificationProviderState {
|
|
99
|
+
status: "healthy" | "error";
|
|
100
|
+
observedAtMs: number;
|
|
101
|
+
}
|
|
102
|
+
/** Memory-only detector state. Do not persist rows/providers across restarts. */
|
|
103
|
+
export interface QuotaNotificationDetectorState {
|
|
104
|
+
version: typeof QUOTA_NOTIFICATION_DETECTOR_STATE_VERSION;
|
|
105
|
+
rows: Record<string, QuotaNotificationRowState>;
|
|
106
|
+
providers: Record<string, QuotaNotificationProviderState>;
|
|
107
|
+
}
|
|
108
|
+
export interface DetectQuotaNotificationsInput {
|
|
109
|
+
cards: readonly QuotaNotificationCardObservation[];
|
|
110
|
+
/** Effective `dashboard.hiddenCards` values. */
|
|
111
|
+
hiddenCards?: readonly string[];
|
|
112
|
+
/** Effective `dashboard.hiddenRows` values. */
|
|
113
|
+
hiddenRows?: readonly string[];
|
|
114
|
+
/** Previous in-memory result state. */
|
|
115
|
+
state?: QuotaNotificationDetectorState;
|
|
116
|
+
/** Caller-persisted fingerprint -> last emitted epoch milliseconds. */
|
|
117
|
+
cooldowns?: Readonly<Record<string, number>>;
|
|
118
|
+
/** Injectable clock supplied by the caller. */
|
|
119
|
+
nowMs: number;
|
|
120
|
+
/** Caller/settings-supplied low threshold. The detector owns no default. */
|
|
121
|
+
lowThresholdPercent: number;
|
|
122
|
+
/** Caller/settings-supplied cooldown. The detector owns no default. */
|
|
123
|
+
cooldownMs: number;
|
|
124
|
+
}
|
|
125
|
+
export interface DetectQuotaNotificationsResult {
|
|
126
|
+
notifications: QuotaNotification[];
|
|
127
|
+
state: QuotaNotificationDetectorState;
|
|
128
|
+
/** Next cooldown map for the caller to persist. */
|
|
129
|
+
cooldowns: Record<string, number>;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Deterministic notification identity. Labels, percentages, display text and
|
|
133
|
+
* the observation clock are excluded.
|
|
134
|
+
*/
|
|
135
|
+
export declare function quotaNotificationFingerprint(input: {
|
|
136
|
+
kind: "low" | "exhausted";
|
|
137
|
+
cardId: string;
|
|
138
|
+
rowId: string;
|
|
139
|
+
} | {
|
|
140
|
+
kind: "reset";
|
|
141
|
+
cardId: string;
|
|
142
|
+
rowId: string;
|
|
143
|
+
resetAtIso: string;
|
|
144
|
+
} | {
|
|
145
|
+
kind: "provider-error";
|
|
146
|
+
cardId: string;
|
|
147
|
+
category: QuotaNotificationProviderFailureCategory;
|
|
148
|
+
}): string;
|
|
149
|
+
export declare function detectQuotaNotifications(input: DetectQuotaNotificationsInput): DetectQuotaNotificationsResult;
|
|
150
|
+
export {};
|
|
151
|
+
//# sourceMappingURL=quota-notification-detector.d.ts.map
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure quota notification transition detector for the native GUI host.
|
|
3
|
+
*
|
|
4
|
+
* The detector observes normalized, already-projected quota cards and returns
|
|
5
|
+
* notifications plus the next in-memory state. It performs no I/O, starts no
|
|
6
|
+
* timers, polls nothing, and never mutates its inputs. The caller owns the
|
|
7
|
+
* clock, settings, hidden-id lists, persistence and delivery.
|
|
8
|
+
*
|
|
9
|
+
* Policy (owner-approved best effort):
|
|
10
|
+
* - Exactly four event kinds: `low`, `exhausted`, `reset`, `provider-error`.
|
|
11
|
+
* - Only semantic percent-remaining rows with result type `quota` or
|
|
12
|
+
* `rate_limit` are eligible. Display labels, messages and raw values are
|
|
13
|
+
* never parsed.
|
|
14
|
+
* - `low`: previous remaining > threshold and current <= threshold. Direct
|
|
15
|
+
* zero exhaustion is never reported as low.
|
|
16
|
+
* - `exhausted`: previous remaining > 0 and current <= 0.
|
|
17
|
+
* - `reset`: reuses the exported `updateObservation` from
|
|
18
|
+
* `src/lib/quota-reset-notifications.ts`, including its proven 24-hour
|
|
19
|
+
* transition-age guard.
|
|
20
|
+
* - `provider-error`: a proven healthy -> error transition, only when the
|
|
21
|
+
* caller supplies safe structured failure provenance. Error labels and
|
|
22
|
+
* messages are never inspected.
|
|
23
|
+
* - Cooldown always applies to the exact fingerprint and is never bypassed.
|
|
24
|
+
* - First startup and newly visible cards or rows silently baseline.
|
|
25
|
+
*
|
|
26
|
+
* Fingerprints:
|
|
27
|
+
* - low/exhausted: kind + card + row.
|
|
28
|
+
* - reset: kind + card + row + reset boundary.
|
|
29
|
+
* - provider-error: kind + card + safe category.
|
|
30
|
+
*
|
|
31
|
+
* Integration seam (not implemented here): the host quota observer maps each
|
|
32
|
+
* visible `ProviderCard` to `QuotaNotificationCardObservation`. `ProviderCard`
|
|
33
|
+
* is structurally assignable because its rows and structured errors already
|
|
34
|
+
* match the normalized observation; pass the card through unchanged.
|
|
35
|
+
* `ProviderCard.errors` carries the optional source-assigned
|
|
36
|
+
* `failureCategory`; only `failureCategory === "provider_api"` is notifiable,
|
|
37
|
+
* and absent or unknown categories fail closed. Error labels and messages are
|
|
38
|
+
* never inspected.
|
|
39
|
+
*
|
|
40
|
+
* Reset-window selection (`resetNotifications.windows`) is caller policy and is
|
|
41
|
+
* not applied here: every supplied semantic percent row with a valid reset
|
|
42
|
+
* boundary is reset-eligible. If configured-window filtering is required,
|
|
43
|
+
* extend this seam with a caller-supplied predicate rather than hard-coding
|
|
44
|
+
* settings in the detector.
|
|
45
|
+
*
|
|
46
|
+
* Detector rows/providers are memory-only and should not be persisted across
|
|
47
|
+
* process starts; a restart then re-baselines silently. The returned
|
|
48
|
+
* `cooldowns` map is the only piece the caller should persist.
|
|
49
|
+
*/
|
|
50
|
+
import { createHash } from "node:crypto";
|
|
51
|
+
import { isCardHidden } from "../contracts/card-visibility.js";
|
|
52
|
+
import { MAX_TRANSITION_AGE_MS, updateObservation as updateLegacyResetObservation, } from "../lib/quota-reset-notifications.js";
|
|
53
|
+
export const QUOTA_NOTIFICATION_DETECTOR_STATE_VERSION = 1;
|
|
54
|
+
/** Shared proven reset-transition age limit re-exported for detector consumers. */
|
|
55
|
+
export const RESET_TRANSITION_MAX_AGE_MS = MAX_TRANSITION_AGE_MS;
|
|
56
|
+
/**
|
|
57
|
+
* The only provider failure category that may produce a `provider-error`
|
|
58
|
+
* notification. It must come from structured provenance, never display text.
|
|
59
|
+
*/
|
|
60
|
+
export const QUOTA_NOTIFICATION_PROVIDER_ERROR_CATEGORY = "provider_api";
|
|
61
|
+
const FINGERPRINT_DOMAIN = "ocq-quota-notification-v1";
|
|
62
|
+
/** Unknown or absent categories are never notifiable. */
|
|
63
|
+
export function isNotifiableProviderError(error) {
|
|
64
|
+
return error.failureCategory === QUOTA_NOTIFICATION_PROVIDER_ERROR_CATEGORY;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Deterministic notification identity. Labels, percentages, display text and
|
|
68
|
+
* the observation clock are excluded.
|
|
69
|
+
*/
|
|
70
|
+
export function quotaNotificationFingerprint(input) {
|
|
71
|
+
const parts = [FINGERPRINT_DOMAIN, input.kind, input.cardId];
|
|
72
|
+
if (input.kind === "provider-error") {
|
|
73
|
+
parts.push(input.category);
|
|
74
|
+
}
|
|
75
|
+
else if (input.kind === "reset") {
|
|
76
|
+
const resetAtMs = Date.parse(input.resetAtIso);
|
|
77
|
+
parts.push(input.rowId, Number.isFinite(resetAtMs) ? String(resetAtMs) : input.resetAtIso);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
parts.push(input.rowId);
|
|
81
|
+
}
|
|
82
|
+
return createHash("sha256").update(parts.join("\0"), "utf8").digest("hex");
|
|
83
|
+
}
|
|
84
|
+
function rowStateKey(cardId, rowId) {
|
|
85
|
+
return `${cardId}\u001f${rowId}`;
|
|
86
|
+
}
|
|
87
|
+
function parseResetAtMs(value) {
|
|
88
|
+
if (value === undefined)
|
|
89
|
+
return undefined;
|
|
90
|
+
const resetAtMs = Date.parse(value);
|
|
91
|
+
return Number.isFinite(resetAtMs) ? resetAtMs : undefined;
|
|
92
|
+
}
|
|
93
|
+
function makeResetObservation(current, notifiedResetAtMs) {
|
|
94
|
+
return {
|
|
95
|
+
resetAtMs: current.resetAtMs,
|
|
96
|
+
percentRemaining: current.percentRemaining,
|
|
97
|
+
observedAtMs: current.observedAtMs,
|
|
98
|
+
...(notifiedResetAtMs !== undefined ? { notifiedResetAtMs } : {}),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function cloneResetObservation(observation) {
|
|
102
|
+
return makeResetObservation(observation, observation.notifiedResetAtMs);
|
|
103
|
+
}
|
|
104
|
+
function makeRowState(percentRemaining, observedAtMs, reset) {
|
|
105
|
+
return {
|
|
106
|
+
percentRemaining,
|
|
107
|
+
observedAtMs,
|
|
108
|
+
...(reset !== undefined ? { reset } : {}),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function cloneRowState(state) {
|
|
112
|
+
return makeRowState(state.percentRemaining, state.observedAtMs, state.reset ? cloneResetObservation(state.reset) : undefined);
|
|
113
|
+
}
|
|
114
|
+
function notificationBase(card, fingerprint, observedAtMs) {
|
|
115
|
+
return {
|
|
116
|
+
fingerprint,
|
|
117
|
+
cardId: card.cardId,
|
|
118
|
+
providerId: card.providerId,
|
|
119
|
+
providerLabel: card.providerLabel,
|
|
120
|
+
...(card.accountLabel !== undefined ? { accountLabel: card.accountLabel } : {}),
|
|
121
|
+
observedAtMs,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
function isEligiblePercentRow(row) {
|
|
125
|
+
return (row.kind === "percent" &&
|
|
126
|
+
(row.resultType === "quota" || row.resultType === "rate_limit") &&
|
|
127
|
+
typeof row.percentRemaining === "number" &&
|
|
128
|
+
Number.isFinite(row.percentRemaining));
|
|
129
|
+
}
|
|
130
|
+
export function detectQuotaNotifications(input) {
|
|
131
|
+
const nowMs = input.nowMs;
|
|
132
|
+
const hiddenCards = new Set(input.hiddenCards ?? []);
|
|
133
|
+
const hiddenRows = new Set(input.hiddenRows ?? []);
|
|
134
|
+
const previousState = input.state?.version === QUOTA_NOTIFICATION_DETECTOR_STATE_VERSION ? input.state : undefined;
|
|
135
|
+
const cooldowns = { ...(input.cooldowns ?? {}) };
|
|
136
|
+
const notifications = [];
|
|
137
|
+
const nextRows = new Map();
|
|
138
|
+
const nextProviders = new Map();
|
|
139
|
+
const seenCards = new Set();
|
|
140
|
+
const emit = (fingerprint, notification) => {
|
|
141
|
+
const lastAtMs = cooldowns[fingerprint];
|
|
142
|
+
if (lastAtMs !== undefined && nowMs - lastAtMs < input.cooldownMs)
|
|
143
|
+
return false;
|
|
144
|
+
notifications.push(notification);
|
|
145
|
+
cooldowns[fingerprint] = nowMs;
|
|
146
|
+
return true;
|
|
147
|
+
};
|
|
148
|
+
for (const card of input.cards) {
|
|
149
|
+
if (seenCards.has(card.cardId) || isCardHidden(card, hiddenCards))
|
|
150
|
+
continue;
|
|
151
|
+
seenCards.add(card.cardId);
|
|
152
|
+
for (const row of card.rows) {
|
|
153
|
+
if (hiddenRows.has(row.rowId))
|
|
154
|
+
continue;
|
|
155
|
+
if (!isEligiblePercentRow(row))
|
|
156
|
+
continue;
|
|
157
|
+
const key = rowStateKey(card.cardId, row.rowId);
|
|
158
|
+
// A duplicate observation cannot be attributed safely; first occurrence wins.
|
|
159
|
+
if (nextRows.has(key))
|
|
160
|
+
continue;
|
|
161
|
+
const currentPercent = row.percentRemaining;
|
|
162
|
+
const resetAtMs = parseResetAtMs(row.resetAtIso);
|
|
163
|
+
const normalizedResetAtIso = resetAtMs !== undefined ? new Date(resetAtMs).toISOString() : undefined;
|
|
164
|
+
const currentReset = resetAtMs !== undefined
|
|
165
|
+
? {
|
|
166
|
+
resetAtMs,
|
|
167
|
+
percentRemaining: currentPercent,
|
|
168
|
+
observedAtMs: nowMs,
|
|
169
|
+
}
|
|
170
|
+
: undefined;
|
|
171
|
+
const previousRow = previousState?.rows[key];
|
|
172
|
+
if (!previousRow) {
|
|
173
|
+
nextRows.set(key, makeRowState(currentPercent, nowMs, currentReset ? makeResetObservation(currentReset) : undefined));
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
if (nowMs < previousRow.observedAtMs) {
|
|
177
|
+
nextRows.set(key, cloneRowState(previousRow));
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
let resetObservation = previousRow.reset
|
|
181
|
+
? cloneResetObservation(previousRow.reset)
|
|
182
|
+
: undefined;
|
|
183
|
+
let resetEvent;
|
|
184
|
+
if (previousRow.reset && currentReset) {
|
|
185
|
+
const update = updateLegacyResetObservation(previousRow.reset, currentReset, nowMs);
|
|
186
|
+
resetObservation = cloneResetObservation(update.observation);
|
|
187
|
+
if (update.notify) {
|
|
188
|
+
resetEvent = {
|
|
189
|
+
previousResetAtMs: previousRow.reset.resetAtMs,
|
|
190
|
+
resetAtMs: currentReset.resetAtMs,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
else if (currentReset) {
|
|
195
|
+
// First reset boundary for this row: silently baseline it.
|
|
196
|
+
resetObservation = makeResetObservation(currentReset);
|
|
197
|
+
}
|
|
198
|
+
nextRows.set(key, makeRowState(currentPercent, nowMs, resetObservation));
|
|
199
|
+
if (resetEvent) {
|
|
200
|
+
const resetAtIso = new Date(resetEvent.resetAtMs).toISOString();
|
|
201
|
+
const fingerprint = quotaNotificationFingerprint({
|
|
202
|
+
kind: "reset",
|
|
203
|
+
cardId: card.cardId,
|
|
204
|
+
rowId: row.rowId,
|
|
205
|
+
resetAtIso,
|
|
206
|
+
});
|
|
207
|
+
emit(fingerprint, {
|
|
208
|
+
...notificationBase(card, fingerprint, nowMs),
|
|
209
|
+
kind: "reset",
|
|
210
|
+
rowId: row.rowId,
|
|
211
|
+
rowLabel: row.label,
|
|
212
|
+
percentRemaining: currentPercent,
|
|
213
|
+
resetAtIso,
|
|
214
|
+
previousResetAtIso: new Date(resetEvent.previousResetAtMs).toISOString(),
|
|
215
|
+
});
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
const previousPercent = previousRow.percentRemaining;
|
|
219
|
+
if (previousPercent > 0 && currentPercent <= 0) {
|
|
220
|
+
const fingerprint = quotaNotificationFingerprint({
|
|
221
|
+
kind: "exhausted",
|
|
222
|
+
cardId: card.cardId,
|
|
223
|
+
rowId: row.rowId,
|
|
224
|
+
});
|
|
225
|
+
emit(fingerprint, {
|
|
226
|
+
...notificationBase(card, fingerprint, nowMs),
|
|
227
|
+
kind: "exhausted",
|
|
228
|
+
rowId: row.rowId,
|
|
229
|
+
rowLabel: row.label,
|
|
230
|
+
percentRemaining: currentPercent,
|
|
231
|
+
...(normalizedResetAtIso !== undefined ? { resetAtIso: normalizedResetAtIso } : {}),
|
|
232
|
+
});
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
if (previousPercent > input.lowThresholdPercent &&
|
|
236
|
+
currentPercent <= input.lowThresholdPercent) {
|
|
237
|
+
const fingerprint = quotaNotificationFingerprint({
|
|
238
|
+
kind: "low",
|
|
239
|
+
cardId: card.cardId,
|
|
240
|
+
rowId: row.rowId,
|
|
241
|
+
});
|
|
242
|
+
emit(fingerprint, {
|
|
243
|
+
...notificationBase(card, fingerprint, nowMs),
|
|
244
|
+
kind: "low",
|
|
245
|
+
rowId: row.rowId,
|
|
246
|
+
rowLabel: row.label,
|
|
247
|
+
thresholdPercent: input.lowThresholdPercent,
|
|
248
|
+
percentRemaining: currentPercent,
|
|
249
|
+
...(normalizedResetAtIso !== undefined ? { resetAtIso: normalizedResetAtIso } : {}),
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
const previousProvider = previousState?.providers[card.cardId];
|
|
254
|
+
if (previousProvider && nowMs < previousProvider.observedAtMs) {
|
|
255
|
+
nextProviders.set(card.cardId, { ...previousProvider });
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
const status = (card.errors?.some(isNotifiableProviderError) ?? false) ? "error" : "healthy";
|
|
259
|
+
nextProviders.set(card.cardId, { status, observedAtMs: nowMs });
|
|
260
|
+
if (!previousProvider || previousProvider.status !== "healthy" || status !== "error") {
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
const fingerprint = quotaNotificationFingerprint({
|
|
264
|
+
kind: "provider-error",
|
|
265
|
+
cardId: card.cardId,
|
|
266
|
+
category: QUOTA_NOTIFICATION_PROVIDER_ERROR_CATEGORY,
|
|
267
|
+
});
|
|
268
|
+
emit(fingerprint, {
|
|
269
|
+
...notificationBase(card, fingerprint, nowMs),
|
|
270
|
+
kind: "provider-error",
|
|
271
|
+
category: QUOTA_NOTIFICATION_PROVIDER_ERROR_CATEGORY,
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
return {
|
|
275
|
+
notifications,
|
|
276
|
+
state: {
|
|
277
|
+
version: QUOTA_NOTIFICATION_DETECTOR_STATE_VERSION,
|
|
278
|
+
rows: Object.fromEntries(nextRows),
|
|
279
|
+
providers: Object.fromEntries(nextProviders),
|
|
280
|
+
},
|
|
281
|
+
cooldowns,
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
//# sourceMappingURL=quota-notification-detector.js.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { QuotaSnapshot, SettingsSnapshot } from "../contracts/dashboard.js";
|
|
2
|
+
import { type PercentDisplayMode } from "../lib/types.js";
|
|
3
|
+
import type { DashboardRpcQuotaNotificationData } from "../rpc.js";
|
|
4
|
+
import { type GuiLogger } from "./log.js";
|
|
5
|
+
/** Effective settings for one observation. */
|
|
6
|
+
export interface QuotaNotificationSettings {
|
|
7
|
+
readonly lowThresholdPercent: number;
|
|
8
|
+
readonly cooldownMs: number;
|
|
9
|
+
readonly hiddenCards: readonly string[];
|
|
10
|
+
readonly hiddenRows: readonly string[];
|
|
11
|
+
readonly percentDisplayMode: PercentDisplayMode;
|
|
12
|
+
}
|
|
13
|
+
export interface QuotaNotificationObserverOptions {
|
|
14
|
+
/** Effective settings loader (the canonical GUI settings store in production). */
|
|
15
|
+
loadSettings: () => Promise<QuotaNotificationSettings>;
|
|
16
|
+
/** Cooldown/fingerprint state path; defaults to the private state namespace. */
|
|
17
|
+
statePath?: string;
|
|
18
|
+
/** Injectable clock for deterministic tests. */
|
|
19
|
+
now?: () => number;
|
|
20
|
+
/** Test seam: replaces the private atomic cooldown write. */
|
|
21
|
+
writeState?: (statePath: string, cooldowns: Record<string, number>) => Promise<void>;
|
|
22
|
+
logger?: GuiLogger;
|
|
23
|
+
}
|
|
24
|
+
export interface QuotaNotificationObserver {
|
|
25
|
+
/**
|
|
26
|
+
* Queue one observation of a fresh quota snapshot. A caller with an
|
|
27
|
+
* asynchronous source read must capture `epoch()` before that read and pass
|
|
28
|
+
* it here; an observation whose captured epoch no longer matches is dropped.
|
|
29
|
+
* Never rejects.
|
|
30
|
+
*/
|
|
31
|
+
observe(snapshot: QuotaSnapshot, epoch?: number): void;
|
|
32
|
+
/** Current source generation, captured before an asynchronous source read. */
|
|
33
|
+
epoch(): number;
|
|
34
|
+
/**
|
|
35
|
+
* The host's active source changed. Observations queued under the previous
|
|
36
|
+
* source identity are discarded and the next fresh snapshot baselines
|
|
37
|
+
* silently; persisted cooldowns stay in force.
|
|
38
|
+
*/
|
|
39
|
+
sourceChanged(): void;
|
|
40
|
+
/** Resolves after every queued observation finished. */
|
|
41
|
+
flush(): Promise<void>;
|
|
42
|
+
/** Live event listener; returns an unsubscribe function. */
|
|
43
|
+
subscribe(listener: (event: DashboardRpcQuotaNotificationData) => void): () => void;
|
|
44
|
+
/** Stop accepting observations and wait for already-started work. */
|
|
45
|
+
close(): Promise<void>;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Maps the canonical settings snapshot to the observer's effective values.
|
|
49
|
+
* Missing keys use the product defaults; malformed values and malformed or
|
|
50
|
+
* missing visibility fail closed so the caller can re-baseline instead of
|
|
51
|
+
* alerting with guessed policy (including guessed hidden-card state).
|
|
52
|
+
*/
|
|
53
|
+
export declare function quotaNotificationSettingsFromSnapshot(snapshot: Pick<SettingsSnapshot, "values" | "visibility">): QuotaNotificationSettings;
|
|
54
|
+
export declare function createQuotaNotificationObserver(options: QuotaNotificationObserverOptions): QuotaNotificationObserver;
|
|
55
|
+
//# sourceMappingURL=quota-notification-observer.d.ts.map
|