opencode-quota-gui 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +90 -30
- package/dist/bin/opencode-quota-gui.js +0 -0
- package/dist/contracts/analytics-entity.d.ts +6 -1
- package/dist/contracts/analytics-entity.js +27 -10
- package/dist/contracts/build-identity.js +1 -1
- package/dist/contracts/card-visibility.d.ts +21 -0
- package/dist/contracts/card-visibility.js +19 -0
- package/dist/contracts/dashboard.d.ts +27 -0
- package/dist/contracts/dashboard.js +2 -0
- package/dist/contracts/dto-guards.d.ts +24 -0
- package/dist/contracts/dto-guards.js +592 -0
- package/dist/contracts/provider-failure.d.ts +18 -0
- package/dist/contracts/provider-failure.js +25 -0
- package/dist/gui/config.d.ts +20 -3
- package/dist/gui/config.js +42 -3
- package/dist/gui/dashboard-errors.d.ts +32 -0
- package/dist/gui/dashboard-errors.js +97 -0
- package/dist/gui/lifecycle.d.ts +44 -11
- package/dist/gui/lifecycle.js +214 -36
- package/dist/gui/primary-quota-windows.d.ts +28 -0
- package/dist/gui/primary-quota-windows.js +147 -0
- package/dist/gui/provider-cards.d.ts +1 -1
- package/dist/gui/provider-cards.js +40 -16
- package/dist/gui/quota-notification-detector.d.ts +151 -0
- package/dist/gui/quota-notification-detector.js +284 -0
- package/dist/gui/quota-notification-observer.d.ts +55 -0
- package/dist/gui/quota-notification-observer.js +363 -0
- package/dist/gui/rpc.d.ts +59 -0
- package/dist/gui/rpc.js +302 -0
- package/dist/gui/server.d.ts +15 -27
- package/dist/gui/server.js +23 -121
- package/dist/gui/snapshot-service.d.ts +31 -4
- package/dist/gui/snapshot-service.js +177 -54
- package/dist/gui/sources.d.ts +1 -1
- package/dist/gui-experimental.cjs +1756 -0
- package/dist/lib/anthropic.d.ts +5 -0
- package/dist/lib/anthropic.js +18 -1
- package/dist/lib/chutes.js +19 -2
- package/dist/lib/config.d.ts +5 -1
- package/dist/lib/config.js +48 -0
- package/dist/lib/copilot.js +42 -14
- package/dist/lib/dashboard-web-policy.d.ts +35 -0
- package/dist/lib/dashboard-web-policy.js +24 -0
- package/dist/lib/deepseek.js +12 -1
- package/dist/lib/display-sanitize.js +2 -0
- package/dist/lib/entries.d.ts +3 -0
- package/dist/lib/format-utils.d.ts +1 -1
- package/dist/lib/format-utils.js +2 -2
- package/dist/lib/glm-coding-plan.js +14 -4
- package/dist/lib/google-agy.js +59 -14
- package/dist/lib/google-gemini-cli.js +58 -14
- package/dist/lib/init-installer.js +25 -4
- package/dist/lib/kilo.js +29 -40
- package/dist/lib/kimi.js +13 -1
- package/dist/lib/mimo.d.ts +2 -0
- package/dist/lib/mimo.js +9 -1
- package/dist/lib/nanogpt.d.ts +2 -0
- package/dist/lib/nanogpt.js +24 -3
- package/dist/lib/ollama-cloud.js +9 -0
- package/dist/lib/openai.js +6 -2
- package/dist/lib/opencode-auth.d.ts +3 -2
- package/dist/lib/opencode-auth.js +8 -1
- package/dist/lib/opencode-go.js +24 -3
- package/dist/lib/opencode-version.d.ts +21 -0
- package/dist/lib/opencode-version.js +53 -5
- package/dist/lib/opencode-zen.d.ts +9 -1
- package/dist/lib/opencode-zen.js +27 -7
- package/dist/lib/quota-providers-remote.d.ts +2 -0
- package/dist/lib/quota-providers-remote.js +78 -19
- package/dist/lib/quota-reset-notifications.d.ts +17 -0
- package/dist/lib/quota-reset-notifications.js +11 -2
- package/dist/lib/quota-state-codec.js +3 -1
- package/dist/lib/synthetic.js +8 -0
- package/dist/lib/types.d.ts +18 -0
- package/dist/lib/types.js +3 -0
- package/dist/lib/xai.js +16 -2
- package/dist/plugin.d.ts +4 -3
- package/dist/plugin.js +33 -4
- package/dist/providers/alibaba-coding-plan.js +3 -1
- package/dist/providers/alibaba-token-plan.js +17 -0
- package/dist/providers/anthropic.js +12 -3
- package/dist/providers/copilot.js +10 -2
- package/dist/providers/glm-coding-plan-provider.d.ts +2 -0
- package/dist/providers/glm-coding-plan-provider.js +5 -1
- package/dist/providers/google-account-format.js +1 -0
- package/dist/providers/google-agy.js +12 -2
- package/dist/providers/google-gemini-cli.js +12 -2
- package/dist/providers/kilo.js +9 -1
- package/dist/providers/kimi-code.js +11 -6
- package/dist/providers/mimo.js +8 -2
- package/dist/providers/minimax-coding-plan.js +28 -5
- package/dist/providers/nanogpt.js +3 -0
- package/dist/providers/ollama-cloud.js +3 -0
- package/dist/providers/openai.js +1 -0
- package/dist/providers/opencode-go.js +8 -1
- package/dist/providers/opencode-zen.js +30 -3
- package/dist/providers/openrouter.js +3 -0
- package/dist/providers/quota-providers.js +30 -4
- package/dist/providers/result-helpers.d.ts +4 -0
- package/dist/providers/result-helpers.js +16 -2
- package/dist/rpc.d.ts +327 -4
- package/dist/rpc.js +315 -2
- package/dist/ui/assets/index-DLHeXYff.js +9 -0
- package/dist/ui/assets/{index-Cs-nrywz.css → index-cDd9jUVY.css} +1 -1
- package/dist/ui/assets/{popover-DKRrwr_K.js → popover-BGkgv9s0.js} +1 -1
- package/dist/ui/index.html +2 -2
- package/package.json +49 -40
- package/dist/bin/opencode-quota-gui.d.ts.map +0 -1
- package/dist/bin/opencode-quota-gui.js.map +0 -1
- package/dist/contracts/analytics-entity.d.ts.map +0 -1
- package/dist/contracts/analytics-entity.js.map +0 -1
- package/dist/contracts/analytics-temporal.d.ts.map +0 -1
- package/dist/contracts/analytics-temporal.js.map +0 -1
- package/dist/contracts/build-identity.d.ts.map +0 -1
- package/dist/contracts/card-order.d.ts.map +0 -1
- package/dist/contracts/card-order.js.map +0 -1
- package/dist/contracts/collision-safe-key.d.ts.map +0 -1
- package/dist/contracts/collision-safe-key.js.map +0 -1
- package/dist/contracts/dashboard.d.ts.map +0 -1
- package/dist/contracts/dashboard.js.map +0 -1
- package/dist/contracts/guards.d.ts.map +0 -1
- package/dist/contracts/guards.js.map +0 -1
- package/dist/contracts/identity.d.ts.map +0 -1
- package/dist/contracts/identity.js.map +0 -1
- package/dist/contracts/openai-quota.d.ts.map +0 -1
- package/dist/contracts/openai-quota.js.map +0 -1
- package/dist/contracts/ranges.d.ts.map +0 -1
- package/dist/contracts/ranges.js.map +0 -1
- package/dist/contracts/settings.d.ts.map +0 -1
- package/dist/contracts/settings.js.map +0 -1
- package/dist/contracts/temporal.d.ts.map +0 -1
- package/dist/contracts/temporal.js.map +0 -1
- package/dist/contracts/time-zone.d.ts.map +0 -1
- package/dist/contracts/time-zone.js.map +0 -1
- package/dist/gui/aggregation.d.ts.map +0 -1
- package/dist/gui/aggregation.js.map +0 -1
- package/dist/gui/analytics-bridge.d.ts.map +0 -1
- package/dist/gui/analytics-bridge.js.map +0 -1
- package/dist/gui/analytics-engine.d.ts.map +0 -1
- package/dist/gui/analytics-engine.js.map +0 -1
- package/dist/gui/analytics-indexes.d.ts.map +0 -1
- package/dist/gui/analytics-indexes.js.map +0 -1
- package/dist/gui/analytics-model.d.ts.map +0 -1
- package/dist/gui/analytics-model.js.map +0 -1
- package/dist/gui/analytics-pricing-revision.d.ts.map +0 -1
- package/dist/gui/analytics-pricing-revision.js.map +0 -1
- package/dist/gui/analytics-protocol.d.ts.map +0 -1
- package/dist/gui/analytics-protocol.js.map +0 -1
- package/dist/gui/analytics-reader.d.ts.map +0 -1
- package/dist/gui/analytics-reader.js.map +0 -1
- package/dist/gui/analytics-service.d.ts.map +0 -1
- package/dist/gui/analytics-service.js.map +0 -1
- package/dist/gui/analytics-state.d.ts.map +0 -1
- package/dist/gui/analytics-state.js.map +0 -1
- package/dist/gui/analytics-worker-runtime.d.ts.map +0 -1
- package/dist/gui/analytics-worker-runtime.js.map +0 -1
- package/dist/gui/analytics-worker.d.ts.map +0 -1
- package/dist/gui/analytics-worker.js.map +0 -1
- package/dist/gui/config.d.ts.map +0 -1
- package/dist/gui/config.js.map +0 -1
- package/dist/gui/identity.d.ts.map +0 -1
- package/dist/gui/identity.js.map +0 -1
- package/dist/gui/lifecycle.d.ts.map +0 -1
- package/dist/gui/lifecycle.js.map +0 -1
- package/dist/gui/log.d.ts.map +0 -1
- package/dist/gui/log.js.map +0 -1
- package/dist/gui/provider-cards.d.ts.map +0 -1
- package/dist/gui/provider-cards.js.map +0 -1
- package/dist/gui/server.d.ts.map +0 -1
- package/dist/gui/server.js.map +0 -1
- package/dist/gui/settings-file-opener.d.ts.map +0 -1
- package/dist/gui/settings-file-opener.js.map +0 -1
- package/dist/gui/snapshot-service.d.ts.map +0 -1
- package/dist/gui/snapshot-service.js.map +0 -1
- package/dist/gui/sources.d.ts.map +0 -1
- package/dist/gui/sources.js.map +0 -1
- package/dist/gui/sse.d.ts.map +0 -1
- package/dist/gui/sse.js.map +0 -1
- package/dist/gui/temporal-quota-policy-data.d.ts.map +0 -1
- package/dist/gui/temporal-quota-policy-data.js.map +0 -1
- package/dist/gui/temporal-quota-policy.d.ts.map +0 -1
- package/dist/gui/temporal-quota-policy.js.map +0 -1
- package/dist/gui/temporal-status.d.ts.map +0 -1
- package/dist/gui/temporal-status.js.map +0 -1
- package/dist/gui/time-zone.d.ts.map +0 -1
- package/dist/gui/time-zone.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/accounting-format.d.ts.map +0 -1
- package/dist/lib/accounting-format.js.map +0 -1
- package/dist/lib/alibaba-auth.d.ts.map +0 -1
- package/dist/lib/alibaba-auth.js.map +0 -1
- package/dist/lib/alibaba-coding-plan-local-quota.d.ts.map +0 -1
- package/dist/lib/alibaba-coding-plan-local-quota.js.map +0 -1
- package/dist/lib/alibaba-token-plan.d.ts.map +0 -1
- package/dist/lib/alibaba-token-plan.js.map +0 -1
- package/dist/lib/anthropic-auth.d.ts.map +0 -1
- package/dist/lib/anthropic-auth.js.map +0 -1
- package/dist/lib/anthropic.d.ts.map +0 -1
- package/dist/lib/anthropic.js.map +0 -1
- package/dist/lib/api-key-resolver.d.ts.map +0 -1
- package/dist/lib/api-key-resolver.js.map +0 -1
- package/dist/lib/atomic-json.d.ts.map +0 -1
- package/dist/lib/atomic-json.js.map +0 -1
- package/dist/lib/chutes-config.d.ts.map +0 -1
- package/dist/lib/chutes-config.js.map +0 -1
- package/dist/lib/chutes.d.ts.map +0 -1
- package/dist/lib/chutes.js.map +0 -1
- package/dist/lib/cli-reports.d.ts.map +0 -1
- package/dist/lib/cli-reports.js.map +0 -1
- package/dist/lib/cli-show.d.ts.map +0 -1
- package/dist/lib/cli-show.js.map +0 -1
- package/dist/lib/cli-status.d.ts.map +0 -1
- package/dist/lib/cli-status.js.map +0 -1
- package/dist/lib/command-parsing.d.ts.map +0 -1
- package/dist/lib/command-parsing.js.map +0 -1
- package/dist/lib/config-file-utils.d.ts.map +0 -1
- package/dist/lib/config-file-utils.js.map +0 -1
- package/dist/lib/config-write-target.d.ts.map +0 -1
- package/dist/lib/config-write-target.js.map +0 -1
- package/dist/lib/config.d.ts.map +0 -1
- package/dist/lib/config.js.map +0 -1
- package/dist/lib/copilot.d.ts.map +0 -1
- package/dist/lib/copilot.js.map +0 -1
- package/dist/lib/cursor-detection.d.ts.map +0 -1
- package/dist/lib/cursor-detection.js.map +0 -1
- package/dist/lib/cursor-pricing.d.ts.map +0 -1
- package/dist/lib/cursor-pricing.js.map +0 -1
- package/dist/lib/cursor-usage.d.ts.map +0 -1
- package/dist/lib/cursor-usage.js.map +0 -1
- package/dist/lib/dashboard-visibility.d.ts.map +0 -1
- package/dist/lib/dashboard-visibility.js.map +0 -1
- package/dist/lib/deepseek-auth.d.ts.map +0 -1
- package/dist/lib/deepseek-auth.js.map +0 -1
- package/dist/lib/deepseek.d.ts.map +0 -1
- package/dist/lib/deepseek.js.map +0 -1
- package/dist/lib/display-sanitize.d.ts.map +0 -1
- package/dist/lib/display-sanitize.js.map +0 -1
- package/dist/lib/entries.d.ts.map +0 -1
- package/dist/lib/entries.js.map +0 -1
- package/dist/lib/env-template.d.ts.map +0 -1
- package/dist/lib/env-template.js.map +0 -1
- package/dist/lib/format-utils.d.ts.map +0 -1
- package/dist/lib/format-utils.js.map +0 -1
- package/dist/lib/format.d.ts.map +0 -1
- package/dist/lib/format.js.map +0 -1
- package/dist/lib/glm-coding-plan.d.ts.map +0 -1
- package/dist/lib/glm-coding-plan.js.map +0 -1
- package/dist/lib/google-agy-companion.d.ts.map +0 -1
- package/dist/lib/google-agy-companion.js.map +0 -1
- package/dist/lib/google-agy.d.ts.map +0 -1
- package/dist/lib/google-agy.js.map +0 -1
- package/dist/lib/google-companion-credentials.d.ts.map +0 -1
- package/dist/lib/google-companion-credentials.js.map +0 -1
- package/dist/lib/google-gemini-cli-companion.d.ts.map +0 -1
- package/dist/lib/google-gemini-cli-companion.js.map +0 -1
- package/dist/lib/google-gemini-cli.d.ts.map +0 -1
- package/dist/lib/google-gemini-cli.js.map +0 -1
- package/dist/lib/google-token-cache.d.ts.map +0 -1
- package/dist/lib/google-token-cache.js.map +0 -1
- package/dist/lib/grouped-entry-normalization.d.ts.map +0 -1
- package/dist/lib/grouped-entry-normalization.js.map +0 -1
- package/dist/lib/grouped-header-format.d.ts.map +0 -1
- package/dist/lib/grouped-header-format.js.map +0 -1
- package/dist/lib/gui-config-target.d.ts.map +0 -1
- package/dist/lib/gui-config-target.js.map +0 -1
- package/dist/lib/home-dir-display.d.ts.map +0 -1
- package/dist/lib/home-dir-display.js.map +0 -1
- package/dist/lib/http.d.ts.map +0 -1
- package/dist/lib/http.js.map +0 -1
- package/dist/lib/init-installer.d.ts.map +0 -1
- package/dist/lib/init-installer.js.map +0 -1
- package/dist/lib/jsonc.d.ts.map +0 -1
- package/dist/lib/jsonc.js.map +0 -1
- package/dist/lib/kilo-config.d.ts.map +0 -1
- package/dist/lib/kilo-config.js.map +0 -1
- package/dist/lib/kilo.d.ts.map +0 -1
- package/dist/lib/kilo.js.map +0 -1
- package/dist/lib/kimi-auth.d.ts.map +0 -1
- package/dist/lib/kimi-auth.js.map +0 -1
- package/dist/lib/kimi-endpoints.d.ts.map +0 -1
- package/dist/lib/kimi-endpoints.js.map +0 -1
- package/dist/lib/kimi.d.ts.map +0 -1
- package/dist/lib/kimi.js.map +0 -1
- package/dist/lib/maintainer-announcements.d.ts.map +0 -1
- package/dist/lib/maintainer-announcements.js.map +0 -1
- package/dist/lib/map-with-concurrency.d.ts.map +0 -1
- package/dist/lib/map-with-concurrency.js.map +0 -1
- package/dist/lib/markdown-table.d.ts.map +0 -1
- package/dist/lib/markdown-table.js.map +0 -1
- package/dist/lib/mimo-config.d.ts.map +0 -1
- package/dist/lib/mimo-config.js.map +0 -1
- package/dist/lib/mimo.d.ts.map +0 -1
- package/dist/lib/mimo.js.map +0 -1
- package/dist/lib/minimax-auth.d.ts.map +0 -1
- package/dist/lib/minimax-auth.js.map +0 -1
- package/dist/lib/minimax-endpoints.d.ts.map +0 -1
- package/dist/lib/minimax-endpoints.js.map +0 -1
- package/dist/lib/modelsdev-pricing.d.ts.map +0 -1
- package/dist/lib/modelsdev-pricing.js.map +0 -1
- package/dist/lib/modelsdev-temporal.d.ts.map +0 -1
- package/dist/lib/modelsdev-temporal.js.map +0 -1
- package/dist/lib/nanogpt-config.d.ts.map +0 -1
- package/dist/lib/nanogpt-config.js.map +0 -1
- package/dist/lib/nanogpt.d.ts.map +0 -1
- package/dist/lib/nanogpt.js.map +0 -1
- package/dist/lib/ollama-cloud-config.d.ts.map +0 -1
- package/dist/lib/ollama-cloud-config.js.map +0 -1
- package/dist/lib/ollama-cloud.d.ts.map +0 -1
- package/dist/lib/ollama-cloud.js.map +0 -1
- package/dist/lib/openai.d.ts.map +0 -1
- package/dist/lib/openai.js.map +0 -1
- package/dist/lib/opencode-auth-sqlite.d.ts.map +0 -1
- package/dist/lib/opencode-auth-sqlite.js.map +0 -1
- package/dist/lib/opencode-auth.d.ts.map +0 -1
- package/dist/lib/opencode-auth.js.map +0 -1
- package/dist/lib/opencode-config-editor.d.ts.map +0 -1
- package/dist/lib/opencode-config-editor.js.map +0 -1
- package/dist/lib/opencode-config-providers.d.ts.map +0 -1
- package/dist/lib/opencode-config-providers.js.map +0 -1
- package/dist/lib/opencode-config-read.d.ts.map +0 -1
- package/dist/lib/opencode-config-read.js.map +0 -1
- package/dist/lib/opencode-console-auth.d.ts.map +0 -1
- package/dist/lib/opencode-console-auth.js.map +0 -1
- package/dist/lib/opencode-db-path.d.ts.map +0 -1
- package/dist/lib/opencode-db-path.js.map +0 -1
- package/dist/lib/opencode-go-auth.d.ts.map +0 -1
- package/dist/lib/opencode-go-auth.js.map +0 -1
- package/dist/lib/opencode-go.d.ts.map +0 -1
- package/dist/lib/opencode-go.js.map +0 -1
- package/dist/lib/opencode-runtime-paths.d.ts.map +0 -1
- package/dist/lib/opencode-runtime-paths.js.map +0 -1
- package/dist/lib/opencode-sqlite.d.ts.map +0 -1
- package/dist/lib/opencode-sqlite.js.map +0 -1
- package/dist/lib/opencode-storage.d.ts.map +0 -1
- package/dist/lib/opencode-storage.js.map +0 -1
- package/dist/lib/opencode-version.d.ts.map +0 -1
- package/dist/lib/opencode-version.js.map +0 -1
- package/dist/lib/opencode-zen.d.ts.map +0 -1
- package/dist/lib/opencode-zen.js.map +0 -1
- package/dist/lib/openrouter.d.ts.map +0 -1
- package/dist/lib/openrouter.js.map +0 -1
- package/dist/lib/private-state-paths.d.ts.map +0 -1
- package/dist/lib/private-state-paths.js.map +0 -1
- package/dist/lib/provider-add-command.d.ts.map +0 -1
- package/dist/lib/provider-add-command.js.map +0 -1
- package/dist/lib/provider-add-json-v1-questionnaire.d.ts.map +0 -1
- package/dist/lib/provider-add-json-v1-questionnaire.js.map +0 -1
- package/dist/lib/provider-add.d.ts.map +0 -1
- package/dist/lib/provider-add.js.map +0 -1
- package/dist/lib/provider-availability.d.ts.map +0 -1
- package/dist/lib/provider-availability.js.map +0 -1
- package/dist/lib/provider-metadata.d.ts.map +0 -1
- package/dist/lib/provider-metadata.js.map +0 -1
- package/dist/lib/provider-model-matching.d.ts.map +0 -1
- package/dist/lib/provider-model-matching.js.map +0 -1
- package/dist/lib/provider-registration.d.ts.map +0 -1
- package/dist/lib/provider-registration.js.map +0 -1
- package/dist/lib/quota-accounting-projection.d.ts.map +0 -1
- package/dist/lib/quota-accounting-projection.js.map +0 -1
- package/dist/lib/quota-columns.d.ts.map +0 -1
- package/dist/lib/quota-columns.js.map +0 -1
- package/dist/lib/quota-command-format.d.ts.map +0 -1
- package/dist/lib/quota-command-format.js.map +0 -1
- package/dist/lib/quota-dialog-command-specs.d.ts.map +0 -1
- package/dist/lib/quota-dialog-command-specs.js.map +0 -1
- package/dist/lib/quota-dialog-commands.d.ts.map +0 -1
- package/dist/lib/quota-dialog-commands.js.map +0 -1
- package/dist/lib/quota-entry-display.d.ts.map +0 -1
- package/dist/lib/quota-entry-display.js.map +0 -1
- package/dist/lib/quota-exhaustion-projection.d.ts.map +0 -1
- package/dist/lib/quota-exhaustion-projection.js.map +0 -1
- package/dist/lib/quota-export-types.d.ts.map +0 -1
- package/dist/lib/quota-export-types.js.map +0 -1
- package/dist/lib/quota-export.d.ts.map +0 -1
- package/dist/lib/quota-export.js.map +0 -1
- package/dist/lib/quota-format-style.d.ts.map +0 -1
- package/dist/lib/quota-format-style.js.map +0 -1
- package/dist/lib/quota-providers-local.d.ts.map +0 -1
- package/dist/lib/quota-providers-local.js.map +0 -1
- package/dist/lib/quota-providers-remote.d.ts.map +0 -1
- package/dist/lib/quota-providers-remote.js.map +0 -1
- package/dist/lib/quota-providers.d.ts.map +0 -1
- package/dist/lib/quota-providers.js.map +0 -1
- package/dist/lib/quota-render-data.d.ts.map +0 -1
- package/dist/lib/quota-render-data.js.map +0 -1
- package/dist/lib/quota-report-message.d.ts.map +0 -1
- package/dist/lib/quota-report-message.js.map +0 -1
- package/dist/lib/quota-reset-notifications.d.ts.map +0 -1
- package/dist/lib/quota-reset-notifications.js.map +0 -1
- package/dist/lib/quota-retry-wait.d.ts.map +0 -1
- package/dist/lib/quota-retry-wait.js.map +0 -1
- package/dist/lib/quota-runtime-context.d.ts.map +0 -1
- package/dist/lib/quota-runtime-context.js.map +0 -1
- package/dist/lib/quota-state-codec.d.ts.map +0 -1
- package/dist/lib/quota-state-codec.js.map +0 -1
- package/dist/lib/quota-state.d.ts.map +0 -1
- package/dist/lib/quota-state.js.map +0 -1
- package/dist/lib/quota-stats-format.d.ts.map +0 -1
- package/dist/lib/quota-stats-format.js.map +0 -1
- package/dist/lib/quota-stats.d.ts.map +0 -1
- package/dist/lib/quota-stats.js.map +0 -1
- package/dist/lib/quota-status.d.ts.map +0 -1
- package/dist/lib/quota-status.js.map +0 -1
- package/dist/lib/quota-surface-data.d.ts.map +0 -1
- package/dist/lib/quota-surface-data.js.map +0 -1
- package/dist/lib/quota-telemetry.d.ts.map +0 -1
- package/dist/lib/quota-telemetry.js.map +0 -1
- package/dist/lib/report-document.d.ts.map +0 -1
- package/dist/lib/report-document.js.map +0 -1
- package/dist/lib/resolved-auth-identity.d.ts.map +0 -1
- package/dist/lib/resolved-auth-identity.js.map +0 -1
- package/dist/lib/runtime-provider-ids.d.ts.map +0 -1
- package/dist/lib/runtime-provider-ids.js.map +0 -1
- package/dist/lib/scoped-query-chunks.d.ts.map +0 -1
- package/dist/lib/scoped-query-chunks.js.map +0 -1
- package/dist/lib/scoped-update-migration.d.ts.map +0 -1
- package/dist/lib/scoped-update-migration.js.map +0 -1
- package/dist/lib/scoped-update.d.ts.map +0 -1
- package/dist/lib/scoped-update.js.map +0 -1
- package/dist/lib/session-tokens-format.d.ts.map +0 -1
- package/dist/lib/session-tokens-format.js.map +0 -1
- package/dist/lib/session-tokens.d.ts.map +0 -1
- package/dist/lib/session-tokens.js.map +0 -1
- package/dist/lib/synthetic-config.d.ts.map +0 -1
- package/dist/lib/synthetic-config.js.map +0 -1
- package/dist/lib/synthetic.d.ts.map +0 -1
- package/dist/lib/synthetic.js.map +0 -1
- package/dist/lib/toast-format-grouped.d.ts.map +0 -1
- package/dist/lib/toast-format-grouped.js.map +0 -1
- package/dist/lib/token-buckets.d.ts.map +0 -1
- package/dist/lib/token-buckets.js.map +0 -1
- package/dist/lib/token-cost.d.ts.map +0 -1
- package/dist/lib/token-cost.js.map +0 -1
- package/dist/lib/tui-compact-format.d.ts.map +0 -1
- package/dist/lib/tui-compact-format.js.map +0 -1
- package/dist/lib/tui-panel-state.d.ts.map +0 -1
- package/dist/lib/tui-panel-state.js.map +0 -1
- package/dist/lib/tui-prompt-bar-format.d.ts.map +0 -1
- package/dist/lib/tui-prompt-bar-format.js.map +0 -1
- package/dist/lib/tui-sidebar-format.d.ts.map +0 -1
- package/dist/lib/tui-sidebar-format.js.map +0 -1
- package/dist/lib/types.d.ts.map +0 -1
- package/dist/lib/types.js.map +0 -1
- package/dist/lib/usage-ownership.d.ts.map +0 -1
- package/dist/lib/usage-ownership.js.map +0 -1
- package/dist/lib/version.d.ts.map +0 -1
- package/dist/lib/version.js.map +0 -1
- package/dist/lib/xai.d.ts.map +0 -1
- package/dist/lib/xai.js.map +0 -1
- package/dist/lib/zai-auth.d.ts.map +0 -1
- package/dist/lib/zai-auth.js.map +0 -1
- package/dist/lib/zai.d.ts.map +0 -1
- package/dist/lib/zai.js.map +0 -1
- package/dist/lib/zhipu-auth.d.ts.map +0 -1
- package/dist/lib/zhipu-auth.js.map +0 -1
- package/dist/lib/zhipu.d.ts.map +0 -1
- package/dist/lib/zhipu.js.map +0 -1
- package/dist/plugin.d.ts.map +0 -1
- package/dist/plugin.js.map +0 -1
- package/dist/providers/accounting-decimal.d.ts.map +0 -1
- package/dist/providers/accounting-decimal.js.map +0 -1
- package/dist/providers/alibaba-coding-plan.d.ts.map +0 -1
- package/dist/providers/alibaba-coding-plan.js.map +0 -1
- package/dist/providers/alibaba-token-plan.d.ts.map +0 -1
- package/dist/providers/alibaba-token-plan.js.map +0 -1
- package/dist/providers/anthropic.d.ts.map +0 -1
- package/dist/providers/anthropic.js.map +0 -1
- package/dist/providers/cache-policies.d.ts.map +0 -1
- package/dist/providers/cache-policies.js.map +0 -1
- package/dist/providers/chutes.d.ts.map +0 -1
- package/dist/providers/chutes.js.map +0 -1
- package/dist/providers/copilot.d.ts.map +0 -1
- package/dist/providers/copilot.js.map +0 -1
- package/dist/providers/cursor.d.ts.map +0 -1
- package/dist/providers/cursor.js.map +0 -1
- package/dist/providers/deepseek.d.ts.map +0 -1
- package/dist/providers/deepseek.js.map +0 -1
- package/dist/providers/glm-coding-plan-provider.d.ts.map +0 -1
- package/dist/providers/glm-coding-plan-provider.js.map +0 -1
- package/dist/providers/google-account-format.d.ts.map +0 -1
- package/dist/providers/google-account-format.js.map +0 -1
- package/dist/providers/google-agy.d.ts.map +0 -1
- package/dist/providers/google-agy.js.map +0 -1
- package/dist/providers/google-gemini-cli.d.ts.map +0 -1
- package/dist/providers/google-gemini-cli.js.map +0 -1
- package/dist/providers/kilo.d.ts.map +0 -1
- package/dist/providers/kilo.js.map +0 -1
- package/dist/providers/kimi-code.d.ts.map +0 -1
- package/dist/providers/kimi-code.js.map +0 -1
- package/dist/providers/mimo.d.ts.map +0 -1
- package/dist/providers/mimo.js.map +0 -1
- package/dist/providers/minimax-coding-plan.d.ts.map +0 -1
- package/dist/providers/minimax-coding-plan.js.map +0 -1
- package/dist/providers/nanogpt.d.ts.map +0 -1
- package/dist/providers/nanogpt.js.map +0 -1
- package/dist/providers/ollama-cloud.d.ts.map +0 -1
- package/dist/providers/ollama-cloud.js.map +0 -1
- package/dist/providers/openai.d.ts.map +0 -1
- package/dist/providers/openai.js.map +0 -1
- package/dist/providers/opencode-go.d.ts.map +0 -1
- package/dist/providers/opencode-go.js.map +0 -1
- package/dist/providers/opencode-zen.d.ts.map +0 -1
- package/dist/providers/opencode-zen.js.map +0 -1
- package/dist/providers/openrouter.d.ts.map +0 -1
- package/dist/providers/openrouter.js.map +0 -1
- package/dist/providers/quota-providers.d.ts.map +0 -1
- package/dist/providers/quota-providers.js.map +0 -1
- package/dist/providers/registry.d.ts.map +0 -1
- package/dist/providers/registry.js.map +0 -1
- package/dist/providers/result-helpers.d.ts.map +0 -1
- package/dist/providers/result-helpers.js.map +0 -1
- package/dist/providers/synthetic.d.ts.map +0 -1
- package/dist/providers/synthetic.js.map +0 -1
- package/dist/providers/xai.d.ts.map +0 -1
- package/dist/providers/xai.js.map +0 -1
- package/dist/providers/zai.d.ts.map +0 -1
- package/dist/providers/zai.js.map +0 -1
- package/dist/providers/zhipu.d.ts.map +0 -1
- package/dist/providers/zhipu.js.map +0 -1
- package/dist/rpc.d.ts.map +0 -1
- package/dist/rpc.js.map +0 -1
- package/dist/ui/assets/index-D9lFKhSN.js +0 -9
package/dist/lib/nanogpt.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* - https://nano-gpt.com/api/subscription/v1/usage
|
|
6
6
|
* - https://nano-gpt.com/api/check-balance
|
|
7
7
|
*/
|
|
8
|
+
import { type ProviderFailureCategory } from "../contracts/provider-failure.js";
|
|
8
9
|
import type { QuotaError } from "./types.js";
|
|
9
10
|
export type NanoGptEndpoint = "usage" | "balance";
|
|
10
11
|
export type NanoGptUsageWindow = {
|
|
@@ -39,6 +40,7 @@ export type NanoGptResult = {
|
|
|
39
40
|
endpointErrors?: Array<{
|
|
40
41
|
endpoint: NanoGptEndpoint;
|
|
41
42
|
message: string;
|
|
43
|
+
failureCategory?: ProviderFailureCategory;
|
|
42
44
|
}>;
|
|
43
45
|
} | QuotaError | null;
|
|
44
46
|
export { getNanoGptKeyDiagnostics, hasNanoGptApiKey as hasNanoGptApiKeyConfigured, type NanoGptKeySource, } from "./nanogpt-config.js";
|
package/dist/lib/nanogpt.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* - https://nano-gpt.com/api/subscription/v1/usage
|
|
6
6
|
* - https://nano-gpt.com/api/check-balance
|
|
7
7
|
*/
|
|
8
|
+
import { providerFailureCategoryForHttpStatus, } from "../contracts/provider-failure.js";
|
|
8
9
|
import { isCanonicalAccountingDecimal } from "./accounting-format.js";
|
|
9
10
|
import { sanitizeDisplaySnippet, sanitizeDisplayText } from "./display-sanitize.js";
|
|
10
11
|
import { clampPercent } from "./format-utils.js";
|
|
@@ -154,6 +155,7 @@ async function fetchNanoGptUsage(headers, requestTimeoutMs) {
|
|
|
154
155
|
success: false,
|
|
155
156
|
message: `NanoGPT API error ${response.status}: ${sanitizeDisplaySnippet(text, 120)}`,
|
|
156
157
|
retryable: isRetryableHttpStatus(response.status),
|
|
158
|
+
failureCategory: providerFailureCategoryForHttpStatus(response.status),
|
|
157
159
|
};
|
|
158
160
|
}
|
|
159
161
|
return {
|
|
@@ -168,6 +170,7 @@ async function fetchNanoGptUsage(headers, requestTimeoutMs) {
|
|
|
168
170
|
success: false,
|
|
169
171
|
message: sanitizeDisplayText(err instanceof Error ? err.message : String(err)),
|
|
170
172
|
retryable: true,
|
|
173
|
+
failureCategory: "provider_api",
|
|
171
174
|
};
|
|
172
175
|
}
|
|
173
176
|
}
|
|
@@ -192,6 +195,7 @@ async function fetchNanoGptBalance(headers, requestTimeoutMs) {
|
|
|
192
195
|
success: false,
|
|
193
196
|
message: `NanoGPT API error ${response.status}: ${sanitizeDisplaySnippet(text, 120)}`,
|
|
194
197
|
retryable: isRetryableHttpStatus(response.status),
|
|
198
|
+
failureCategory: providerFailureCategoryForHttpStatus(response.status),
|
|
195
199
|
};
|
|
196
200
|
}
|
|
197
201
|
return {
|
|
@@ -206,6 +210,7 @@ async function fetchNanoGptBalance(headers, requestTimeoutMs) {
|
|
|
206
210
|
success: false,
|
|
207
211
|
message: sanitizeDisplayText(err instanceof Error ? err.message : String(err)),
|
|
208
212
|
retryable: true,
|
|
213
|
+
failureCategory: "provider_api",
|
|
209
214
|
};
|
|
210
215
|
}
|
|
211
216
|
}
|
|
@@ -224,13 +229,25 @@ export async function queryNanoGptQuota(options = {}) {
|
|
|
224
229
|
]);
|
|
225
230
|
const endpointErrors = [];
|
|
226
231
|
if (!usageResult.success) {
|
|
227
|
-
endpointErrors.push({
|
|
232
|
+
endpointErrors.push({
|
|
233
|
+
endpoint: "usage",
|
|
234
|
+
message: usageResult.message,
|
|
235
|
+
failureCategory: usageResult.failureCategory,
|
|
236
|
+
});
|
|
228
237
|
}
|
|
229
238
|
if (!balanceResult.success) {
|
|
230
|
-
endpointErrors.push({
|
|
239
|
+
endpointErrors.push({
|
|
240
|
+
endpoint: "balance",
|
|
241
|
+
message: balanceResult.message,
|
|
242
|
+
failureCategory: balanceResult.failureCategory,
|
|
243
|
+
});
|
|
231
244
|
}
|
|
232
245
|
else if (balanceResult.fieldErrors.length > 0) {
|
|
233
|
-
endpointErrors.push({
|
|
246
|
+
endpointErrors.push({
|
|
247
|
+
endpoint: "balance",
|
|
248
|
+
message: balanceResult.fieldErrors.join("; "),
|
|
249
|
+
failureCategory: "provider_api",
|
|
250
|
+
});
|
|
234
251
|
}
|
|
235
252
|
if (!usageResult.success && !balanceResult.success) {
|
|
236
253
|
return {
|
|
@@ -239,6 +256,10 @@ export async function queryNanoGptQuota(options = {}) {
|
|
|
239
256
|
.map((entry) => `${entry.endpoint === "usage" ? "Usage" : "Balance"}: ${entry.message}`)
|
|
240
257
|
.join("; "),
|
|
241
258
|
retryable: usageResult.retryable || balanceResult.retryable,
|
|
259
|
+
failureCategory: usageResult.failureCategory === "provider_api" ||
|
|
260
|
+
balanceResult.failureCategory === "provider_api"
|
|
261
|
+
? "provider_api"
|
|
262
|
+
: "credentials",
|
|
242
263
|
};
|
|
243
264
|
}
|
|
244
265
|
return {
|
package/dist/lib/ollama-cloud.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* plans), plus purchased credits, from the authenticated Ollama Cloud balance
|
|
6
6
|
* endpoint.
|
|
7
7
|
*/
|
|
8
|
+
import { providerFailureCategoryForHttpStatus } from "../contracts/provider-failure.js";
|
|
8
9
|
import { sanitizeSingleLineDisplayText } from "./display-sanitize.js";
|
|
9
10
|
import { fetchWithTimeout } from "./http.js";
|
|
10
11
|
import { resolveOllamaCloudApiKey } from "./ollama-cloud-config.js";
|
|
@@ -105,6 +106,7 @@ function parseOllamaCloudBalance(payload) {
|
|
|
105
106
|
return {
|
|
106
107
|
success: false,
|
|
107
108
|
error: "Ollama Cloud balance API returned an unexpected response shape",
|
|
109
|
+
failureCategory: "provider_api",
|
|
108
110
|
};
|
|
109
111
|
}
|
|
110
112
|
const rowErrors = [];
|
|
@@ -136,6 +138,7 @@ function parseOllamaCloudBalance(payload) {
|
|
|
136
138
|
return {
|
|
137
139
|
success: false,
|
|
138
140
|
error: "Ollama Cloud balance API returned no limits or balance",
|
|
141
|
+
failureCategory: "provider_api",
|
|
139
142
|
};
|
|
140
143
|
}
|
|
141
144
|
return {
|
|
@@ -151,6 +154,7 @@ export async function queryOllamaCloudQuota(options = {}) {
|
|
|
151
154
|
const resolved = await resolveOllamaCloudApiKey();
|
|
152
155
|
if (!resolved)
|
|
153
156
|
return null;
|
|
157
|
+
let responseStatus;
|
|
154
158
|
try {
|
|
155
159
|
return await fetchWithTimeout(OLLAMA_CLOUD_BALANCE_URL, {
|
|
156
160
|
request: {
|
|
@@ -163,12 +167,14 @@ export async function queryOllamaCloudQuota(options = {}) {
|
|
|
163
167
|
},
|
|
164
168
|
timeoutMs: options.requestTimeoutMs,
|
|
165
169
|
consume: async (response) => {
|
|
170
|
+
responseStatus = response.status;
|
|
166
171
|
const text = await readBoundedText(response, MAX_RESPONSE_BYTES);
|
|
167
172
|
if (!response.ok) {
|
|
168
173
|
const snippet = sanitizeMessage(text, resolved.key);
|
|
169
174
|
return {
|
|
170
175
|
success: false,
|
|
171
176
|
error: `Ollama Cloud balance API error ${response.status}: ${snippet}`,
|
|
177
|
+
failureCategory: providerFailureCategoryForHttpStatus(response.status),
|
|
172
178
|
};
|
|
173
179
|
}
|
|
174
180
|
return parseOllamaCloudBalance(JSON.parse(text));
|
|
@@ -179,6 +185,9 @@ export async function queryOllamaCloudQuota(options = {}) {
|
|
|
179
185
|
return {
|
|
180
186
|
success: false,
|
|
181
187
|
error: sanitizeMessage(error instanceof Error ? error.message : String(error), resolved.key),
|
|
188
|
+
failureCategory: responseStatus === undefined
|
|
189
|
+
? "provider_api"
|
|
190
|
+
: providerFailureCategoryForHttpStatus(responseStatus),
|
|
182
191
|
};
|
|
183
192
|
}
|
|
184
193
|
}
|
package/dist/lib/openai.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Uses OpenCode's opencode.db native OpenCode OAuth entries and queries:
|
|
5
5
|
* https://chatgpt.com/backend-api/wham/usage
|
|
6
6
|
*/
|
|
7
|
+
import { providerFailureCategoryForHttpStatus } from "../contracts/provider-failure.js";
|
|
7
8
|
import { sanitizeDisplayText, sanitizeSingleLineDisplayText } from "./display-sanitize.js";
|
|
8
9
|
import { clampPercent } from "./format-utils.js";
|
|
9
10
|
import { fetchWithTimeout } from "./http.js";
|
|
@@ -295,12 +296,13 @@ export async function queryOpenAIQuota(options = {}) {
|
|
|
295
296
|
return {
|
|
296
297
|
success: false,
|
|
297
298
|
error: `OpenAI sign-in could not be refreshed: ${resolvedAuth.error}. ${fix}`,
|
|
299
|
+
failureCategory: "credentials",
|
|
298
300
|
};
|
|
299
301
|
}
|
|
300
302
|
if (resolvedAuth.state !== "configured")
|
|
301
303
|
return null;
|
|
302
304
|
if (resolvedAuth.expiresAt && resolvedAuth.expiresAt < Date.now()) {
|
|
303
|
-
return { success: false, error: "Token expired" };
|
|
305
|
+
return { success: false, error: "Token expired", failureCategory: "credentials" };
|
|
304
306
|
}
|
|
305
307
|
try {
|
|
306
308
|
const headers = {
|
|
@@ -320,6 +322,7 @@ export async function queryOpenAIQuota(options = {}) {
|
|
|
320
322
|
return {
|
|
321
323
|
success: false,
|
|
322
324
|
error: `OpenAI API error ${resp.status}${code ? ` (${code})` : ""}`,
|
|
325
|
+
failureCategory: providerFailureCategoryForHttpStatus(resp.status),
|
|
323
326
|
};
|
|
324
327
|
}
|
|
325
328
|
const data = (await resp.json());
|
|
@@ -364,7 +367,7 @@ export async function queryOpenAIQuota(options = {}) {
|
|
|
364
367
|
// Empty bodies stay invalid; a useful Credits-only/reset-count-only
|
|
365
368
|
// payload is a real measurement even without a percent window.
|
|
366
369
|
if (Object.keys(windows).length === 0 && !positiveCredits && availableResetCount === null) {
|
|
367
|
-
return { success: false, error: "No quota data" };
|
|
370
|
+
return { success: false, error: "No quota data", failureCategory: "provider_api" };
|
|
368
371
|
}
|
|
369
372
|
return {
|
|
370
373
|
success: true,
|
|
@@ -388,6 +391,7 @@ export async function queryOpenAIQuota(options = {}) {
|
|
|
388
391
|
return {
|
|
389
392
|
success: false,
|
|
390
393
|
error: sanitizeDisplayText(err instanceof Error ? err.message : String(err)),
|
|
394
|
+
failureCategory: "provider_api",
|
|
391
395
|
};
|
|
392
396
|
}
|
|
393
397
|
}
|
|
@@ -24,8 +24,9 @@ export type CredentialRow = {
|
|
|
24
24
|
/**
|
|
25
25
|
* Why OpenCode could not return this login (for example a failed token
|
|
26
26
|
* refresh), as `<category>: <scrubbed detail>`. A failed row keeps its id,
|
|
27
|
-
* label and position, but its `value` is only `{ type: "api" | "oauth" }
|
|
28
|
-
*
|
|
27
|
+
* label and position, but its `value` is only `{ type: "api" | "oauth" }`.
|
|
28
|
+
* A failed `external` connection uses the same fallback because the failed-row
|
|
29
|
+
* shape only names api/oauth; consumers show `resolveError` as a per-account error.
|
|
29
30
|
*/
|
|
30
31
|
resolveError?: string;
|
|
31
32
|
};
|
|
@@ -304,7 +304,14 @@ async function credentialRowForSlot(integration, slot, methods) {
|
|
|
304
304
|
* has rows, since a firstOnly read returns one active connection per id.
|
|
305
305
|
*/
|
|
306
306
|
async function credentialRowsForSlots(integration, slots, methods, activeConnections) {
|
|
307
|
-
const wanted = slots.filter((slot) =>
|
|
307
|
+
const wanted = slots.filter((slot) => {
|
|
308
|
+
if (!methods || !("connection" in slot))
|
|
309
|
+
return true;
|
|
310
|
+
// SDK 2.2 added the host-provided `external` connection method. It is never
|
|
311
|
+
// one of the readable key/OAuth slots, so compare values instead of asking
|
|
312
|
+
// a narrower array whether it includes a wider union.
|
|
313
|
+
return methods.some((method) => method === slot.connection.method);
|
|
314
|
+
});
|
|
308
315
|
const pairs = await Promise.all(wanted.map(async (slot) => ({
|
|
309
316
|
slot,
|
|
310
317
|
row: await credentialRowForSlot(integration, slot, methods),
|
package/dist/lib/opencode-go.js
CHANGED
|
@@ -21,7 +21,15 @@ function errorMessage(error, accessToken) {
|
|
|
21
21
|
return sanitizeMessage(error instanceof Error ? error.message : String(error), accessToken);
|
|
22
22
|
}
|
|
23
23
|
function contractError(message) {
|
|
24
|
-
return {
|
|
24
|
+
return {
|
|
25
|
+
success: false,
|
|
26
|
+
error: `Invalid OpenCode Go API response: ${message}`,
|
|
27
|
+
failureCategory: "provider_api",
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/** 401/403 resolve credentials before the endpoint contract can be read. */
|
|
31
|
+
function httpFailureCategory(status) {
|
|
32
|
+
return status === 401 || status === 403 ? "credentials" : "provider_api";
|
|
25
33
|
}
|
|
26
34
|
function isRetryableHttpStatus(status) {
|
|
27
35
|
return status === 408 || status === 425 || status === 429 || status >= 500;
|
|
@@ -132,6 +140,7 @@ export async function queryOpenCodeGoQuota(accessToken, options = {}) {
|
|
|
132
140
|
success: false,
|
|
133
141
|
error: `OpenCode Go API error ${response.status}: ${errorMessage(error, accessToken)}`,
|
|
134
142
|
retryable: isRetryableHttpStatus(response.status),
|
|
143
|
+
failureCategory: httpFailureCategory(response.status),
|
|
135
144
|
};
|
|
136
145
|
}
|
|
137
146
|
if (isNotSubscribedResponse(response.status, text)) {
|
|
@@ -146,6 +155,7 @@ export async function queryOpenCodeGoQuota(accessToken, options = {}) {
|
|
|
146
155
|
success: false,
|
|
147
156
|
error: `OpenCode Go API error ${response.status}: ${sanitizeMessage(text, accessToken)}`,
|
|
148
157
|
retryable: isRetryableHttpStatus(response.status),
|
|
158
|
+
failureCategory: httpFailureCategory(response.status),
|
|
149
159
|
};
|
|
150
160
|
}
|
|
151
161
|
let payload;
|
|
@@ -160,7 +170,12 @@ export async function queryOpenCodeGoQuota(accessToken, options = {}) {
|
|
|
160
170
|
});
|
|
161
171
|
}
|
|
162
172
|
catch (error) {
|
|
163
|
-
return {
|
|
173
|
+
return {
|
|
174
|
+
success: false,
|
|
175
|
+
error: errorMessage(error, accessToken),
|
|
176
|
+
retryable: true,
|
|
177
|
+
failureCategory: "provider_api",
|
|
178
|
+
};
|
|
164
179
|
}
|
|
165
180
|
}
|
|
166
181
|
function asMicroCents(value) {
|
|
@@ -229,6 +244,7 @@ export async function queryOpenCodeGoConsoleStatus(credential, options = {}) {
|
|
|
229
244
|
success: false,
|
|
230
245
|
error: `OpenCode Console API error ${response.status} (/api/go/status)`,
|
|
231
246
|
retryable: isRetryableHttpStatus(response.status),
|
|
247
|
+
failureCategory: httpFailureCategory(response.status),
|
|
232
248
|
};
|
|
233
249
|
}
|
|
234
250
|
let payload;
|
|
@@ -278,7 +294,12 @@ export async function queryOpenCodeGoConsoleStatus(credential, options = {}) {
|
|
|
278
294
|
});
|
|
279
295
|
}
|
|
280
296
|
catch (error) {
|
|
281
|
-
return {
|
|
297
|
+
return {
|
|
298
|
+
success: false,
|
|
299
|
+
error: errorMessage(error, credential.accessToken),
|
|
300
|
+
retryable: true,
|
|
301
|
+
failureCategory: "provider_api",
|
|
302
|
+
};
|
|
282
303
|
}
|
|
283
304
|
}
|
|
284
305
|
//# sourceMappingURL=opencode-go.js.map
|
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
export type OpenCodeMajor = 1 | 2;
|
|
2
|
+
/** Numeric host version; a prerelease/build suffix is ignored. */
|
|
3
|
+
export interface OpenCodeVersion {
|
|
4
|
+
major: number;
|
|
5
|
+
minor: number;
|
|
6
|
+
patch: number;
|
|
7
|
+
}
|
|
8
|
+
/** Parses the numeric version core; a prerelease or build suffix is ignored. */
|
|
9
|
+
export declare function parseOpenCodeVersion(output: string): OpenCodeVersion | undefined;
|
|
2
10
|
/** OpenCode 1 prints a bare `1.18.32`; OpenCode 2 prints `opencode v2.0.16`. */
|
|
3
11
|
export declare function parseOpenCodeMajor(output: string): OpenCodeMajor | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Whether the host has the Native GUI baseline (2.2.0+). Missing or
|
|
14
|
+
* unparseable versions are not assumed capable.
|
|
15
|
+
*/
|
|
16
|
+
export declare function supportsNativeGui(version: string | OpenCodeVersion | undefined): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Whether the host predates the Native GUI and therefore keeps the compatibility
|
|
19
|
+
* web dashboard on by default. Only a parseable version below 2.2.0 qualifies;
|
|
20
|
+
* missing or unparseable versions fail closed.
|
|
21
|
+
*/
|
|
22
|
+
export declare function isPreNativeGuiVersion(version: string | OpenCodeVersion | undefined): boolean;
|
|
23
|
+
/** Returns undefined when `opencode` is not on PATH, fails, times out, or prints an unknown version. */
|
|
24
|
+
export declare function detectOpenCodeVersion(runVersion?: () => Promise<string>): Promise<OpenCodeVersion | undefined>;
|
|
4
25
|
/** Returns undefined when `opencode` is not on PATH, fails, times out, or prints an unknown version. */
|
|
5
26
|
export declare function detectOpenCodeMajor(runVersion?: () => Promise<string>): Promise<OpenCodeMajor | undefined>;
|
|
6
27
|
//# sourceMappingURL=opencode-version.d.ts.map
|
|
@@ -1,26 +1,74 @@
|
|
|
1
1
|
import { execFile } from "node:child_process";
|
|
2
2
|
const OPENCODE_VERSION_TIMEOUT_MS = 5_000;
|
|
3
|
+
/** The numeric core of `1.18.32`, `opencode v2.2.0`, or `2.2.0-beta.1`. */
|
|
4
|
+
const OPENCODE_VERSION_PATTERN = /^(?:opencode\s+)?v?(\d+)\.(\d+)\.(\d+)/;
|
|
5
|
+
/** Parses the numeric version core; a prerelease or build suffix is ignored. */
|
|
6
|
+
export function parseOpenCodeVersion(output) {
|
|
7
|
+
const match = OPENCODE_VERSION_PATTERN.exec(output.trim());
|
|
8
|
+
if (!match)
|
|
9
|
+
return undefined;
|
|
10
|
+
const major = Number(match[1]);
|
|
11
|
+
const minor = Number(match[2]);
|
|
12
|
+
const patch = Number(match[3]);
|
|
13
|
+
if (![major, minor, patch].every((part) => Number.isSafeInteger(part)))
|
|
14
|
+
return undefined;
|
|
15
|
+
return { major, minor, patch };
|
|
16
|
+
}
|
|
3
17
|
/** OpenCode 1 prints a bare `1.18.32`; OpenCode 2 prints `opencode v2.0.16`. */
|
|
4
18
|
export function parseOpenCodeMajor(output) {
|
|
5
|
-
const
|
|
6
|
-
if (
|
|
19
|
+
const version = parseOpenCodeVersion(output);
|
|
20
|
+
if (version?.major === 1)
|
|
7
21
|
return 1;
|
|
8
|
-
if (
|
|
22
|
+
if (version?.major === 2)
|
|
9
23
|
return 2;
|
|
10
24
|
return undefined;
|
|
11
25
|
}
|
|
26
|
+
/** Compares the numeric parts only; a prerelease suffix never lowers the result. */
|
|
27
|
+
function isAtLeast(version, major, minor, patch) {
|
|
28
|
+
if (version.major !== major)
|
|
29
|
+
return version.major > major;
|
|
30
|
+
if (version.minor !== minor)
|
|
31
|
+
return version.minor > minor;
|
|
32
|
+
return version.patch >= patch;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Whether the host has the Native GUI baseline (2.2.0+). Missing or
|
|
36
|
+
* unparseable versions are not assumed capable.
|
|
37
|
+
*/
|
|
38
|
+
export function supportsNativeGui(version) {
|
|
39
|
+
const parsed = typeof version === "string" ? parseOpenCodeVersion(version) : version;
|
|
40
|
+
return parsed !== undefined && isAtLeast(parsed, 2, 2, 0);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Whether the host predates the Native GUI and therefore keeps the compatibility
|
|
44
|
+
* web dashboard on by default. Only a parseable version below 2.2.0 qualifies;
|
|
45
|
+
* missing or unparseable versions fail closed.
|
|
46
|
+
*/
|
|
47
|
+
export function isPreNativeGuiVersion(version) {
|
|
48
|
+
const parsed = typeof version === "string" ? parseOpenCodeVersion(version) : version;
|
|
49
|
+
return parsed !== undefined && !isAtLeast(parsed, 2, 2, 0);
|
|
50
|
+
}
|
|
12
51
|
function runOpenCodeVersion() {
|
|
13
52
|
return new Promise((resolve, reject) => {
|
|
14
53
|
execFile("opencode", ["--version"], { encoding: "utf8", timeout: OPENCODE_VERSION_TIMEOUT_MS, windowsHide: true }, (error, stdout) => (error ? reject(error) : resolve(stdout)));
|
|
15
54
|
});
|
|
16
55
|
}
|
|
17
56
|
/** Returns undefined when `opencode` is not on PATH, fails, times out, or prints an unknown version. */
|
|
18
|
-
export async function
|
|
57
|
+
export async function detectOpenCodeVersion(runVersion = runOpenCodeVersion) {
|
|
19
58
|
try {
|
|
20
|
-
return
|
|
59
|
+
return parseOpenCodeVersion(await runVersion());
|
|
21
60
|
}
|
|
22
61
|
catch {
|
|
23
62
|
return undefined;
|
|
24
63
|
}
|
|
25
64
|
}
|
|
65
|
+
/** Returns undefined when `opencode` is not on PATH, fails, times out, or prints an unknown version. */
|
|
66
|
+
export async function detectOpenCodeMajor(runVersion = runOpenCodeVersion) {
|
|
67
|
+
const version = await detectOpenCodeVersion(runVersion);
|
|
68
|
+
if (version?.major === 1)
|
|
69
|
+
return 1;
|
|
70
|
+
if (version?.major === 2)
|
|
71
|
+
return 2;
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
26
74
|
//# sourceMappingURL=opencode-version.js.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ProviderFailureCategory } from "../contracts/provider-failure.js";
|
|
1
2
|
import { type OpenCodeConsoleCredential } from "./opencode-console-auth.js";
|
|
2
3
|
/**
|
|
3
4
|
* The OpenCode Console reports amounts in micro-cents:
|
|
@@ -39,15 +40,22 @@ export interface OpenCodeZenBillingData {
|
|
|
39
40
|
}
|
|
40
41
|
/**
|
|
41
42
|
* billing/status (balance) is required. The other routes are optional: when one fails,
|
|
42
|
-
* its fields are null and its error is listed in `errors`.
|
|
43
|
+
* its fields are null and its error is listed in `errors`. `optionalErrors`
|
|
44
|
+
* carries the same messages with their producer-assigned failure category.
|
|
43
45
|
*/
|
|
46
|
+
export type OpenCodeZenOptionalError = {
|
|
47
|
+
message: string;
|
|
48
|
+
failureCategory?: ProviderFailureCategory;
|
|
49
|
+
};
|
|
44
50
|
export type OpenCodeZenResult = {
|
|
45
51
|
success: true;
|
|
46
52
|
data: OpenCodeZenBillingData;
|
|
47
53
|
errors: string[];
|
|
54
|
+
optionalErrors?: OpenCodeZenOptionalError[];
|
|
48
55
|
} | {
|
|
49
56
|
success: false;
|
|
50
57
|
error: string;
|
|
58
|
+
failureCategory?: ProviderFailureCategory;
|
|
51
59
|
};
|
|
52
60
|
export declare function queryOpenCodeZenQuota(credential: OpenCodeConsoleCredential, options?: {
|
|
53
61
|
requestTimeoutMs?: number;
|
package/dist/lib/opencode-zen.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { providerFailureCategoryForHttpStatus } from "../contracts/provider-failure.js";
|
|
1
2
|
import { sanitizeDisplayText } from "./display-sanitize.js";
|
|
2
3
|
import { fetchWithTimeout } from "./http.js";
|
|
3
4
|
import { consoleBaseUrl, consoleHeaders, } from "./opencode-console-auth.js";
|
|
@@ -228,19 +229,21 @@ async function fetchConsoleRoute(params) {
|
|
|
228
229
|
},
|
|
229
230
|
timeoutMs: params.timeoutMs,
|
|
230
231
|
consume: async (response) => {
|
|
231
|
-
// Redirects and 401 mean the whole session is gone; a 403
|
|
232
|
-
//
|
|
232
|
+
// Redirects and 401 mean the whole session is gone; a 403 stays a
|
|
233
|
+
// per-route failure so optional routes can fall back gracefully, but it
|
|
234
|
+
// is still an authorization outcome at the HTTP boundary.
|
|
233
235
|
if ((response.status >= 300 && response.status < 400) || response.status === 401) {
|
|
234
|
-
return { success: false, error: SESSION_ERROR };
|
|
236
|
+
return { success: false, error: SESSION_ERROR, failureCategory: "credentials" };
|
|
235
237
|
}
|
|
236
238
|
if (!response.ok) {
|
|
237
239
|
return {
|
|
238
240
|
success: false,
|
|
239
241
|
error: `OpenCode Console ${params.route} error ${response.status}`,
|
|
242
|
+
failureCategory: providerFailureCategoryForHttpStatus(response.status),
|
|
240
243
|
};
|
|
241
244
|
}
|
|
242
245
|
if (response.headers.get("content-type")?.includes("text/html")) {
|
|
243
|
-
return { success: false, error: SESSION_ERROR };
|
|
246
|
+
return { success: false, error: SESSION_ERROR, failureCategory: "credentials" };
|
|
244
247
|
}
|
|
245
248
|
const text = await response.text();
|
|
246
249
|
try {
|
|
@@ -252,6 +255,7 @@ async function fetchConsoleRoute(params) {
|
|
|
252
255
|
return {
|
|
253
256
|
success: false,
|
|
254
257
|
error: `Could not parse OpenCode Console ${params.route} response`,
|
|
258
|
+
failureCategory: "provider_api",
|
|
255
259
|
};
|
|
256
260
|
}
|
|
257
261
|
},
|
|
@@ -265,7 +269,11 @@ async function fetchConsoleRoute(params) {
|
|
|
265
269
|
accountId,
|
|
266
270
|
accountId && encodeURIComponent(accountId),
|
|
267
271
|
]);
|
|
268
|
-
return {
|
|
272
|
+
return {
|
|
273
|
+
success: false,
|
|
274
|
+
error: `OpenCode Console ${params.route} request failed: ${message}`,
|
|
275
|
+
failureCategory: "provider_api",
|
|
276
|
+
};
|
|
269
277
|
}
|
|
270
278
|
}
|
|
271
279
|
/** The member detail route key, or an error explaining why it cannot be fetched. */
|
|
@@ -275,6 +283,7 @@ function memberBudgetRequest(request) {
|
|
|
275
283
|
return {
|
|
276
284
|
success: false,
|
|
277
285
|
error: "OpenCode Console member budgets unavailable: the Console sign-in has no account id",
|
|
286
|
+
failureCategory: "discovery",
|
|
278
287
|
};
|
|
279
288
|
}
|
|
280
289
|
return fetchConsoleRoute({
|
|
@@ -303,7 +312,7 @@ export async function queryOpenCodeZenQuota(credential, options = {}) {
|
|
|
303
312
|
]);
|
|
304
313
|
const optional = [creditLimit, autoRecharge, member, monthlyUsage];
|
|
305
314
|
if ([balance, ...optional].some((result) => !result.success && result.error === SESSION_ERROR)) {
|
|
306
|
-
return { success: false, error: SESSION_ERROR };
|
|
315
|
+
return { success: false, error: SESSION_ERROR, failureCategory: "credentials" };
|
|
307
316
|
}
|
|
308
317
|
if (!balance.success)
|
|
309
318
|
return balance;
|
|
@@ -328,6 +337,16 @@ export async function queryOpenCodeZenQuota(credential, options = {}) {
|
|
|
328
337
|
memberBudgetsSkipped = true;
|
|
329
338
|
}
|
|
330
339
|
}
|
|
340
|
+
const optionalErrors = optional.flatMap((result) => result.success
|
|
341
|
+
? []
|
|
342
|
+
: [
|
|
343
|
+
{
|
|
344
|
+
message: result.error,
|
|
345
|
+
...(result.failureCategory !== undefined
|
|
346
|
+
? { failureCategory: result.failureCategory }
|
|
347
|
+
: {}),
|
|
348
|
+
},
|
|
349
|
+
]);
|
|
331
350
|
return {
|
|
332
351
|
success: true,
|
|
333
352
|
data: {
|
|
@@ -342,7 +361,8 @@ export async function queryOpenCodeZenQuota(credential, options = {}) {
|
|
|
342
361
|
budgetSource,
|
|
343
362
|
memberBudgetsSkipped,
|
|
344
363
|
},
|
|
345
|
-
errors:
|
|
364
|
+
errors: optionalErrors.map((error) => error.message),
|
|
365
|
+
...(optionalErrors.length > 0 ? { optionalErrors } : {}),
|
|
346
366
|
};
|
|
347
367
|
}
|
|
348
368
|
//# sourceMappingURL=opencode-zen.js.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ProviderFailureCategory } from "../contracts/provider-failure.js";
|
|
1
2
|
import type { QuotaToastEntry } from "./entries.js";
|
|
2
3
|
import type { RemoteApiQuotaProviderDefinition } from "./quota-providers.js";
|
|
3
4
|
export declare const QUOTA_PROVIDER_MAX_BODY_BYTES: number;
|
|
@@ -21,6 +22,7 @@ export type RemoteQuotaProviderResult = {
|
|
|
21
22
|
} | {
|
|
22
23
|
success: false;
|
|
23
24
|
error: string;
|
|
25
|
+
failureCategory?: ProviderFailureCategory;
|
|
24
26
|
};
|
|
25
27
|
export declare function resolveQuotaProviderApiKey(source: RemoteApiQuotaProviderDefinition): Promise<QuotaProviderAuthResolution>;
|
|
26
28
|
export declare function fetchRemoteQuotaProvider(source: RemoteApiQuotaProviderDefinition, apiKey: string, requestTimeoutMs?: number): Promise<RemoteQuotaProviderResult>;
|