opencode-quota-gui 1.2.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +104 -34
- package/dist/contracts/analytics-entity.d.ts +6 -1
- package/dist/contracts/analytics-entity.js +27 -10
- package/dist/contracts/build-identity.js +1 -1
- package/dist/contracts/card-visibility.d.ts +21 -0
- package/dist/contracts/card-visibility.js +19 -0
- package/dist/contracts/dashboard.d.ts +35 -1
- package/dist/contracts/dashboard.js +2 -0
- package/dist/contracts/dto-guards.d.ts +24 -0
- package/dist/contracts/dto-guards.js +594 -0
- package/dist/contracts/openai-quota.d.ts +3 -0
- package/dist/contracts/openai-quota.js +3 -0
- package/dist/contracts/provider-failure.d.ts +18 -0
- package/dist/contracts/provider-failure.js +25 -0
- package/dist/data/modelsdev-temporal.min.json +57 -0
- package/dist/gui/config.d.ts +20 -3
- package/dist/gui/config.js +72 -4
- package/dist/gui/dashboard-errors.d.ts +32 -0
- package/dist/gui/dashboard-errors.js +97 -0
- package/dist/gui/lifecycle.d.ts +47 -12
- package/dist/gui/lifecycle.js +215 -37
- package/dist/gui/primary-quota-windows.d.ts +28 -0
- package/dist/gui/primary-quota-windows.js +149 -0
- package/dist/gui/provider-cards.d.ts +11 -3
- package/dist/gui/provider-cards.js +85 -33
- package/dist/gui/quota-notification-detector.d.ts +151 -0
- package/dist/gui/quota-notification-detector.js +318 -0
- package/dist/gui/quota-notification-observer.d.ts +54 -0
- package/dist/gui/quota-notification-observer.js +412 -0
- package/dist/gui/rpc.d.ts +61 -0
- package/dist/gui/rpc.js +310 -0
- package/dist/gui/server.d.ts +15 -27
- package/dist/gui/server.js +34 -123
- package/dist/gui/snapshot-service.d.ts +34 -5
- package/dist/gui/snapshot-service.js +301 -70
- package/dist/gui/sources.d.ts +1 -1
- package/dist/gui/sources.js +98 -56
- package/dist/gui-experimental.cjs +1761 -0
- package/dist/lib/accounting-format.js +8 -0
- package/dist/lib/alibaba-coding-plan-cli.d.ts +79 -0
- package/dist/lib/alibaba-coding-plan-cli.js +539 -0
- package/dist/lib/anthropic-auth.d.ts +2 -3
- package/dist/lib/anthropic-auth.js +2 -3
- package/dist/lib/anthropic.d.ts +53 -12
- package/dist/lib/anthropic.js +622 -270
- package/dist/lib/api-key-retry-after.d.ts +7 -0
- package/dist/lib/api-key-retry-after.js +62 -0
- package/dist/lib/atomic-json.d.ts +2 -0
- package/dist/lib/atomic-json.js +1 -0
- package/dist/lib/cache-observer-ingestion.d.ts +90 -0
- package/dist/lib/cache-observer-ingestion.js +981 -0
- package/dist/lib/cache-observer.d.ts +138 -0
- package/dist/lib/cache-observer.js +317 -0
- package/dist/lib/canonical-config-lock.d.ts +9 -0
- package/dist/lib/canonical-config-lock.js +36 -0
- package/dist/lib/chutes.js +63 -35
- package/dist/lib/claude-agent-transcript-ttl.d.ts +48 -0
- package/dist/lib/claude-agent-transcript-ttl.js +154 -0
- package/dist/lib/claude-agent-ttl-tracker.d.ts +21 -0
- package/dist/lib/claude-agent-ttl-tracker.js +152 -0
- package/dist/lib/cli-show.js +5 -3
- package/dist/lib/config-write-target.d.ts +1 -1
- package/dist/lib/config-write-target.js +5 -2
- package/dist/lib/config.d.ts +6 -1
- package/dist/lib/config.js +241 -2
- package/dist/lib/copilot.js +198 -85
- package/dist/lib/dashboard-web-policy.d.ts +35 -0
- package/dist/lib/dashboard-web-policy.js +24 -0
- package/dist/lib/deepseek.js +34 -11
- package/dist/lib/display-sanitize.js +3 -0
- package/dist/lib/entries.d.ts +26 -0
- package/dist/lib/entries.js +2 -0
- package/dist/lib/format-utils.d.ts +1 -1
- package/dist/lib/format-utils.js +2 -2
- package/dist/lib/glm-coding-plan.js +102 -68
- package/dist/lib/google-agy.js +147 -24
- package/dist/lib/google-gemini-cli.js +140 -23
- package/dist/lib/http.d.ts +4 -0
- package/dist/lib/http.js +16 -2
- package/dist/lib/init-installer.js +30 -7
- package/dist/lib/kilo.js +63 -55
- package/dist/lib/kimi.js +43 -14
- package/dist/lib/mimo.d.ts +4 -0
- package/dist/lib/mimo.js +45 -1
- package/dist/lib/nanogpt.d.ts +3 -0
- package/dist/lib/nanogpt.js +50 -6
- package/dist/lib/ollama-cloud.d.ts +1 -1
- package/dist/lib/ollama-cloud.js +51 -29
- package/dist/lib/openai.js +90 -40
- package/dist/lib/opencode-auth-sqlite.d.ts +2 -2
- package/dist/lib/opencode-auth-sqlite.js +2 -2
- package/dist/lib/opencode-auth.d.ts +3 -2
- package/dist/lib/opencode-auth.js +8 -1
- package/dist/lib/opencode-config-editor.d.ts +1 -0
- package/dist/lib/opencode-config-editor.js +6 -1
- package/dist/lib/opencode-go.js +53 -5
- package/dist/lib/opencode-version-core.d.ts +23 -0
- package/dist/lib/opencode-version-core.js +49 -0
- package/dist/lib/opencode-version.d.ts +4 -3
- package/dist/lib/opencode-version.js +15 -11
- package/dist/lib/opencode-zen.d.ts +12 -1
- package/dist/lib/opencode-zen.js +98 -12
- package/dist/lib/provider-add.js +5 -2
- package/dist/lib/provider-registration.d.ts +19 -9
- package/dist/lib/provider-registration.js +17 -6
- package/dist/lib/quota-command-format.js +1 -1
- package/dist/lib/quota-exhaustion-projection.d.ts +11 -0
- package/dist/lib/quota-exhaustion-projection.js +25 -0
- package/dist/lib/quota-providers-remote.d.ts +4 -1
- package/dist/lib/quota-providers-remote.js +137 -22
- package/dist/lib/quota-providers.d.ts +1 -1
- package/dist/lib/quota-providers.js +12 -35
- package/dist/lib/quota-render-data.d.ts +6 -0
- package/dist/lib/quota-render-data.js +43 -17
- package/dist/lib/quota-reset-notifications.d.ts +17 -0
- package/dist/lib/quota-reset-notifications.js +11 -2
- package/dist/lib/quota-state-codec.js +19 -1
- package/dist/lib/quota-state.d.ts +7 -1
- package/dist/lib/quota-state.js +208 -34
- package/dist/lib/quota-stats.js +21 -0
- package/dist/lib/quota-status.js +3 -51
- package/dist/lib/scoped-update.d.ts +1 -1
- package/dist/lib/synthetic.js +67 -48
- package/dist/lib/types.d.ts +49 -1
- package/dist/lib/types.js +16 -0
- package/dist/lib/xai.js +64 -24
- package/dist/plugin.d.ts +4 -3
- package/dist/plugin.js +293 -16
- package/dist/provider-logos/NOTICE.md +1 -1
- package/dist/provider-logos/OPENCODE-NOTICE.md +4 -3
- package/dist/providers/alibaba-coding-plan.js +107 -102
- package/dist/providers/alibaba-token-plan.js +17 -0
- package/dist/providers/anthropic.d.ts +12 -3
- package/dist/providers/anthropic.js +71 -219
- package/dist/providers/cache-policies.d.ts +11 -4
- package/dist/providers/cache-policies.js +19 -13
- package/dist/providers/claude-agent.d.ts +19 -0
- package/dist/providers/claude-agent.js +196 -0
- package/dist/providers/copilot.js +12 -2
- package/dist/providers/glm-coding-plan-provider.d.ts +3 -0
- package/dist/providers/glm-coding-plan-provider.js +5 -1
- package/dist/providers/google-account-format.js +2 -0
- package/dist/providers/google-agy.d.ts +6 -5
- package/dist/providers/google-agy.js +55 -17
- package/dist/providers/google-gemini-cli.js +13 -2
- package/dist/providers/kilo.js +10 -1
- package/dist/providers/kimi-code.js +13 -6
- package/dist/providers/mimo.js +9 -2
- package/dist/providers/minimax-coding-plan.js +28 -5
- package/dist/providers/nanogpt.js +4 -0
- package/dist/providers/ollama-cloud.js +3 -0
- package/dist/providers/openai.js +1 -0
- package/dist/providers/opencode-go.js +11 -1
- package/dist/providers/opencode-zen.js +32 -3
- package/dist/providers/openrouter.js +4 -0
- package/dist/providers/quota-providers.js +46 -9
- package/dist/providers/registry.js +2 -0
- package/dist/providers/result-helpers.d.ts +6 -0
- package/dist/providers/result-helpers.js +18 -2
- package/dist/rpc.d.ts +440 -4
- package/dist/rpc.js +507 -2
- package/dist/ui/assets/{index-Cs-nrywz.css → index-BcueIm3Z.css} +1 -1
- package/dist/ui/assets/index-C6qRSoh8.js +10 -0
- package/dist/ui/assets/{popover-DKRrwr_K.js → popover-4bFSvRZ7.js} +1 -1
- package/dist/ui/assets/providers/claude-agent.svg +3 -0
- package/dist/ui/index.html +2 -2
- package/package.json +15 -7
- package/dist/bin/opencode-quota-gui.d.ts.map +0 -1
- package/dist/bin/opencode-quota-gui.js.map +0 -1
- package/dist/contracts/analytics-entity.d.ts.map +0 -1
- package/dist/contracts/analytics-entity.js.map +0 -1
- package/dist/contracts/analytics-temporal.d.ts.map +0 -1
- package/dist/contracts/analytics-temporal.js.map +0 -1
- package/dist/contracts/build-identity.d.ts.map +0 -1
- package/dist/contracts/card-order.d.ts.map +0 -1
- package/dist/contracts/card-order.js.map +0 -1
- package/dist/contracts/collision-safe-key.d.ts.map +0 -1
- package/dist/contracts/collision-safe-key.js.map +0 -1
- package/dist/contracts/dashboard.d.ts.map +0 -1
- package/dist/contracts/dashboard.js.map +0 -1
- package/dist/contracts/guards.d.ts.map +0 -1
- package/dist/contracts/guards.js.map +0 -1
- package/dist/contracts/identity.d.ts.map +0 -1
- package/dist/contracts/identity.js.map +0 -1
- package/dist/contracts/openai-quota.d.ts.map +0 -1
- package/dist/contracts/openai-quota.js.map +0 -1
- package/dist/contracts/ranges.d.ts.map +0 -1
- package/dist/contracts/ranges.js.map +0 -1
- package/dist/contracts/settings.d.ts.map +0 -1
- package/dist/contracts/settings.js.map +0 -1
- package/dist/contracts/temporal.d.ts.map +0 -1
- package/dist/contracts/temporal.js.map +0 -1
- package/dist/contracts/time-zone.d.ts.map +0 -1
- package/dist/contracts/time-zone.js.map +0 -1
- package/dist/gui/aggregation.d.ts.map +0 -1
- package/dist/gui/aggregation.js.map +0 -1
- package/dist/gui/analytics-bridge.d.ts.map +0 -1
- package/dist/gui/analytics-bridge.js.map +0 -1
- package/dist/gui/analytics-engine.d.ts.map +0 -1
- package/dist/gui/analytics-engine.js.map +0 -1
- package/dist/gui/analytics-indexes.d.ts.map +0 -1
- package/dist/gui/analytics-indexes.js.map +0 -1
- package/dist/gui/analytics-model.d.ts.map +0 -1
- package/dist/gui/analytics-model.js.map +0 -1
- package/dist/gui/analytics-pricing-revision.d.ts.map +0 -1
- package/dist/gui/analytics-pricing-revision.js.map +0 -1
- package/dist/gui/analytics-protocol.d.ts.map +0 -1
- package/dist/gui/analytics-protocol.js.map +0 -1
- package/dist/gui/analytics-reader.d.ts.map +0 -1
- package/dist/gui/analytics-reader.js.map +0 -1
- package/dist/gui/analytics-service.d.ts.map +0 -1
- package/dist/gui/analytics-service.js.map +0 -1
- package/dist/gui/analytics-state.d.ts.map +0 -1
- package/dist/gui/analytics-state.js.map +0 -1
- package/dist/gui/analytics-worker-runtime.d.ts.map +0 -1
- package/dist/gui/analytics-worker-runtime.js.map +0 -1
- package/dist/gui/analytics-worker.d.ts.map +0 -1
- package/dist/gui/analytics-worker.js.map +0 -1
- package/dist/gui/config.d.ts.map +0 -1
- package/dist/gui/config.js.map +0 -1
- package/dist/gui/identity.d.ts.map +0 -1
- package/dist/gui/identity.js.map +0 -1
- package/dist/gui/lifecycle.d.ts.map +0 -1
- package/dist/gui/lifecycle.js.map +0 -1
- package/dist/gui/log.d.ts.map +0 -1
- package/dist/gui/log.js.map +0 -1
- package/dist/gui/provider-cards.d.ts.map +0 -1
- package/dist/gui/provider-cards.js.map +0 -1
- package/dist/gui/server.d.ts.map +0 -1
- package/dist/gui/server.js.map +0 -1
- package/dist/gui/settings-file-opener.d.ts.map +0 -1
- package/dist/gui/settings-file-opener.js.map +0 -1
- package/dist/gui/snapshot-service.d.ts.map +0 -1
- package/dist/gui/snapshot-service.js.map +0 -1
- package/dist/gui/sources.d.ts.map +0 -1
- package/dist/gui/sources.js.map +0 -1
- package/dist/gui/sse.d.ts.map +0 -1
- package/dist/gui/sse.js.map +0 -1
- package/dist/gui/temporal-quota-policy-data.d.ts.map +0 -1
- package/dist/gui/temporal-quota-policy-data.js.map +0 -1
- package/dist/gui/temporal-quota-policy.d.ts.map +0 -1
- package/dist/gui/temporal-quota-policy.js.map +0 -1
- package/dist/gui/temporal-status.d.ts.map +0 -1
- package/dist/gui/temporal-status.js.map +0 -1
- package/dist/gui/time-zone.d.ts.map +0 -1
- package/dist/gui/time-zone.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/accounting-format.d.ts.map +0 -1
- package/dist/lib/accounting-format.js.map +0 -1
- package/dist/lib/alibaba-auth.d.ts.map +0 -1
- package/dist/lib/alibaba-auth.js.map +0 -1
- package/dist/lib/alibaba-coding-plan-local-quota.d.ts +0 -47
- package/dist/lib/alibaba-coding-plan-local-quota.d.ts.map +0 -1
- package/dist/lib/alibaba-coding-plan-local-quota.js +0 -146
- package/dist/lib/alibaba-coding-plan-local-quota.js.map +0 -1
- package/dist/lib/alibaba-token-plan.d.ts.map +0 -1
- package/dist/lib/alibaba-token-plan.js.map +0 -1
- package/dist/lib/anthropic-auth.d.ts.map +0 -1
- package/dist/lib/anthropic-auth.js.map +0 -1
- package/dist/lib/anthropic.d.ts.map +0 -1
- package/dist/lib/anthropic.js.map +0 -1
- package/dist/lib/api-key-resolver.d.ts.map +0 -1
- package/dist/lib/api-key-resolver.js.map +0 -1
- package/dist/lib/atomic-json.d.ts.map +0 -1
- package/dist/lib/atomic-json.js.map +0 -1
- package/dist/lib/chutes-config.d.ts.map +0 -1
- package/dist/lib/chutes-config.js.map +0 -1
- package/dist/lib/chutes.d.ts.map +0 -1
- package/dist/lib/chutes.js.map +0 -1
- package/dist/lib/cli-reports.d.ts.map +0 -1
- package/dist/lib/cli-reports.js.map +0 -1
- package/dist/lib/cli-show.d.ts.map +0 -1
- package/dist/lib/cli-show.js.map +0 -1
- package/dist/lib/cli-status.d.ts.map +0 -1
- package/dist/lib/cli-status.js.map +0 -1
- package/dist/lib/command-parsing.d.ts.map +0 -1
- package/dist/lib/command-parsing.js.map +0 -1
- package/dist/lib/config-file-utils.d.ts.map +0 -1
- package/dist/lib/config-file-utils.js.map +0 -1
- package/dist/lib/config-write-target.d.ts.map +0 -1
- package/dist/lib/config-write-target.js.map +0 -1
- package/dist/lib/config.d.ts.map +0 -1
- package/dist/lib/config.js.map +0 -1
- package/dist/lib/copilot.d.ts.map +0 -1
- package/dist/lib/copilot.js.map +0 -1
- package/dist/lib/cursor-detection.d.ts.map +0 -1
- package/dist/lib/cursor-detection.js.map +0 -1
- package/dist/lib/cursor-pricing.d.ts.map +0 -1
- package/dist/lib/cursor-pricing.js.map +0 -1
- package/dist/lib/cursor-usage.d.ts.map +0 -1
- package/dist/lib/cursor-usage.js.map +0 -1
- package/dist/lib/dashboard-visibility.d.ts.map +0 -1
- package/dist/lib/dashboard-visibility.js.map +0 -1
- package/dist/lib/deepseek-auth.d.ts.map +0 -1
- package/dist/lib/deepseek-auth.js.map +0 -1
- package/dist/lib/deepseek.d.ts.map +0 -1
- package/dist/lib/deepseek.js.map +0 -1
- package/dist/lib/display-sanitize.d.ts.map +0 -1
- package/dist/lib/display-sanitize.js.map +0 -1
- package/dist/lib/entries.d.ts.map +0 -1
- package/dist/lib/entries.js.map +0 -1
- package/dist/lib/env-template.d.ts.map +0 -1
- package/dist/lib/env-template.js.map +0 -1
- package/dist/lib/format-utils.d.ts.map +0 -1
- package/dist/lib/format-utils.js.map +0 -1
- package/dist/lib/format.d.ts.map +0 -1
- package/dist/lib/format.js.map +0 -1
- package/dist/lib/glm-coding-plan.d.ts.map +0 -1
- package/dist/lib/glm-coding-plan.js.map +0 -1
- package/dist/lib/google-agy-companion.d.ts.map +0 -1
- package/dist/lib/google-agy-companion.js.map +0 -1
- package/dist/lib/google-agy.d.ts.map +0 -1
- package/dist/lib/google-agy.js.map +0 -1
- package/dist/lib/google-companion-credentials.d.ts.map +0 -1
- package/dist/lib/google-companion-credentials.js.map +0 -1
- package/dist/lib/google-gemini-cli-companion.d.ts.map +0 -1
- package/dist/lib/google-gemini-cli-companion.js.map +0 -1
- package/dist/lib/google-gemini-cli.d.ts.map +0 -1
- package/dist/lib/google-gemini-cli.js.map +0 -1
- package/dist/lib/google-token-cache.d.ts.map +0 -1
- package/dist/lib/google-token-cache.js.map +0 -1
- package/dist/lib/grouped-entry-normalization.d.ts.map +0 -1
- package/dist/lib/grouped-entry-normalization.js.map +0 -1
- package/dist/lib/grouped-header-format.d.ts.map +0 -1
- package/dist/lib/grouped-header-format.js.map +0 -1
- package/dist/lib/gui-config-target.d.ts.map +0 -1
- package/dist/lib/gui-config-target.js.map +0 -1
- package/dist/lib/home-dir-display.d.ts.map +0 -1
- package/dist/lib/home-dir-display.js.map +0 -1
- package/dist/lib/http.d.ts.map +0 -1
- package/dist/lib/http.js.map +0 -1
- package/dist/lib/init-installer.d.ts.map +0 -1
- package/dist/lib/init-installer.js.map +0 -1
- package/dist/lib/jsonc.d.ts.map +0 -1
- package/dist/lib/jsonc.js.map +0 -1
- package/dist/lib/kilo-config.d.ts.map +0 -1
- package/dist/lib/kilo-config.js.map +0 -1
- package/dist/lib/kilo.d.ts.map +0 -1
- package/dist/lib/kilo.js.map +0 -1
- package/dist/lib/kimi-auth.d.ts.map +0 -1
- package/dist/lib/kimi-auth.js.map +0 -1
- package/dist/lib/kimi-endpoints.d.ts.map +0 -1
- package/dist/lib/kimi-endpoints.js.map +0 -1
- package/dist/lib/kimi.d.ts.map +0 -1
- package/dist/lib/kimi.js.map +0 -1
- package/dist/lib/maintainer-announcements.d.ts.map +0 -1
- package/dist/lib/maintainer-announcements.js.map +0 -1
- package/dist/lib/map-with-concurrency.d.ts.map +0 -1
- package/dist/lib/map-with-concurrency.js.map +0 -1
- package/dist/lib/markdown-table.d.ts.map +0 -1
- package/dist/lib/markdown-table.js.map +0 -1
- package/dist/lib/mimo-config.d.ts.map +0 -1
- package/dist/lib/mimo-config.js.map +0 -1
- package/dist/lib/mimo.d.ts.map +0 -1
- package/dist/lib/mimo.js.map +0 -1
- package/dist/lib/minimax-auth.d.ts.map +0 -1
- package/dist/lib/minimax-auth.js.map +0 -1
- package/dist/lib/minimax-endpoints.d.ts.map +0 -1
- package/dist/lib/minimax-endpoints.js.map +0 -1
- package/dist/lib/modelsdev-pricing.d.ts.map +0 -1
- package/dist/lib/modelsdev-pricing.js.map +0 -1
- package/dist/lib/modelsdev-temporal.d.ts.map +0 -1
- package/dist/lib/modelsdev-temporal.js.map +0 -1
- package/dist/lib/nanogpt-config.d.ts.map +0 -1
- package/dist/lib/nanogpt-config.js.map +0 -1
- package/dist/lib/nanogpt.d.ts.map +0 -1
- package/dist/lib/nanogpt.js.map +0 -1
- package/dist/lib/ollama-cloud-config.d.ts.map +0 -1
- package/dist/lib/ollama-cloud-config.js.map +0 -1
- package/dist/lib/ollama-cloud.d.ts.map +0 -1
- package/dist/lib/ollama-cloud.js.map +0 -1
- package/dist/lib/openai.d.ts.map +0 -1
- package/dist/lib/openai.js.map +0 -1
- package/dist/lib/opencode-auth-sqlite.d.ts.map +0 -1
- package/dist/lib/opencode-auth-sqlite.js.map +0 -1
- package/dist/lib/opencode-auth.d.ts.map +0 -1
- package/dist/lib/opencode-auth.js.map +0 -1
- package/dist/lib/opencode-config-editor.d.ts.map +0 -1
- package/dist/lib/opencode-config-editor.js.map +0 -1
- package/dist/lib/opencode-config-providers.d.ts.map +0 -1
- package/dist/lib/opencode-config-providers.js.map +0 -1
- package/dist/lib/opencode-config-read.d.ts.map +0 -1
- package/dist/lib/opencode-config-read.js.map +0 -1
- package/dist/lib/opencode-console-auth.d.ts.map +0 -1
- package/dist/lib/opencode-console-auth.js.map +0 -1
- package/dist/lib/opencode-db-path.d.ts.map +0 -1
- package/dist/lib/opencode-db-path.js.map +0 -1
- package/dist/lib/opencode-go-auth.d.ts.map +0 -1
- package/dist/lib/opencode-go-auth.js.map +0 -1
- package/dist/lib/opencode-go.d.ts.map +0 -1
- package/dist/lib/opencode-go.js.map +0 -1
- package/dist/lib/opencode-runtime-paths.d.ts.map +0 -1
- package/dist/lib/opencode-runtime-paths.js.map +0 -1
- package/dist/lib/opencode-sqlite.d.ts.map +0 -1
- package/dist/lib/opencode-sqlite.js.map +0 -1
- package/dist/lib/opencode-storage.d.ts.map +0 -1
- package/dist/lib/opencode-storage.js.map +0 -1
- package/dist/lib/opencode-version.d.ts.map +0 -1
- package/dist/lib/opencode-version.js.map +0 -1
- package/dist/lib/opencode-zen.d.ts.map +0 -1
- package/dist/lib/opencode-zen.js.map +0 -1
- package/dist/lib/openrouter.d.ts.map +0 -1
- package/dist/lib/openrouter.js.map +0 -1
- package/dist/lib/private-state-paths.d.ts.map +0 -1
- package/dist/lib/private-state-paths.js.map +0 -1
- package/dist/lib/provider-add-command.d.ts.map +0 -1
- package/dist/lib/provider-add-command.js.map +0 -1
- package/dist/lib/provider-add-json-v1-questionnaire.d.ts.map +0 -1
- package/dist/lib/provider-add-json-v1-questionnaire.js.map +0 -1
- package/dist/lib/provider-add.d.ts.map +0 -1
- package/dist/lib/provider-add.js.map +0 -1
- package/dist/lib/provider-availability.d.ts.map +0 -1
- package/dist/lib/provider-availability.js.map +0 -1
- package/dist/lib/provider-metadata.d.ts.map +0 -1
- package/dist/lib/provider-metadata.js.map +0 -1
- package/dist/lib/provider-model-matching.d.ts.map +0 -1
- package/dist/lib/provider-model-matching.js.map +0 -1
- package/dist/lib/provider-registration.d.ts.map +0 -1
- package/dist/lib/provider-registration.js.map +0 -1
- package/dist/lib/quota-accounting-projection.d.ts.map +0 -1
- package/dist/lib/quota-accounting-projection.js.map +0 -1
- package/dist/lib/quota-columns.d.ts.map +0 -1
- package/dist/lib/quota-columns.js.map +0 -1
- package/dist/lib/quota-command-format.d.ts.map +0 -1
- package/dist/lib/quota-command-format.js.map +0 -1
- package/dist/lib/quota-dialog-command-specs.d.ts.map +0 -1
- package/dist/lib/quota-dialog-command-specs.js.map +0 -1
- package/dist/lib/quota-dialog-commands.d.ts.map +0 -1
- package/dist/lib/quota-dialog-commands.js.map +0 -1
- package/dist/lib/quota-entry-display.d.ts.map +0 -1
- package/dist/lib/quota-entry-display.js.map +0 -1
- package/dist/lib/quota-exhaustion-projection.d.ts.map +0 -1
- package/dist/lib/quota-exhaustion-projection.js.map +0 -1
- package/dist/lib/quota-export-types.d.ts.map +0 -1
- package/dist/lib/quota-export-types.js.map +0 -1
- package/dist/lib/quota-export.d.ts.map +0 -1
- package/dist/lib/quota-export.js.map +0 -1
- package/dist/lib/quota-format-style.d.ts.map +0 -1
- package/dist/lib/quota-format-style.js.map +0 -1
- package/dist/lib/quota-providers-local.d.ts.map +0 -1
- package/dist/lib/quota-providers-local.js.map +0 -1
- package/dist/lib/quota-providers-remote.d.ts.map +0 -1
- package/dist/lib/quota-providers-remote.js.map +0 -1
- package/dist/lib/quota-providers.d.ts.map +0 -1
- package/dist/lib/quota-providers.js.map +0 -1
- package/dist/lib/quota-render-data.d.ts.map +0 -1
- package/dist/lib/quota-render-data.js.map +0 -1
- package/dist/lib/quota-report-message.d.ts.map +0 -1
- package/dist/lib/quota-report-message.js.map +0 -1
- package/dist/lib/quota-reset-notifications.d.ts.map +0 -1
- package/dist/lib/quota-reset-notifications.js.map +0 -1
- package/dist/lib/quota-retry-wait.d.ts.map +0 -1
- package/dist/lib/quota-retry-wait.js.map +0 -1
- package/dist/lib/quota-runtime-context.d.ts.map +0 -1
- package/dist/lib/quota-runtime-context.js.map +0 -1
- package/dist/lib/quota-state-codec.d.ts.map +0 -1
- package/dist/lib/quota-state-codec.js.map +0 -1
- package/dist/lib/quota-state.d.ts.map +0 -1
- package/dist/lib/quota-state.js.map +0 -1
- package/dist/lib/quota-stats-format.d.ts.map +0 -1
- package/dist/lib/quota-stats-format.js.map +0 -1
- package/dist/lib/quota-stats.d.ts.map +0 -1
- package/dist/lib/quota-stats.js.map +0 -1
- package/dist/lib/quota-status.d.ts.map +0 -1
- package/dist/lib/quota-status.js.map +0 -1
- package/dist/lib/quota-surface-data.d.ts.map +0 -1
- package/dist/lib/quota-surface-data.js.map +0 -1
- package/dist/lib/quota-telemetry.d.ts.map +0 -1
- package/dist/lib/quota-telemetry.js.map +0 -1
- package/dist/lib/report-document.d.ts.map +0 -1
- package/dist/lib/report-document.js.map +0 -1
- package/dist/lib/resolved-auth-identity.d.ts.map +0 -1
- package/dist/lib/resolved-auth-identity.js.map +0 -1
- package/dist/lib/runtime-provider-ids.d.ts.map +0 -1
- package/dist/lib/runtime-provider-ids.js.map +0 -1
- package/dist/lib/scoped-query-chunks.d.ts.map +0 -1
- package/dist/lib/scoped-query-chunks.js.map +0 -1
- package/dist/lib/scoped-update-migration.d.ts.map +0 -1
- package/dist/lib/scoped-update-migration.js.map +0 -1
- package/dist/lib/scoped-update.d.ts.map +0 -1
- package/dist/lib/scoped-update.js.map +0 -1
- package/dist/lib/session-tokens-format.d.ts.map +0 -1
- package/dist/lib/session-tokens-format.js.map +0 -1
- package/dist/lib/session-tokens.d.ts.map +0 -1
- package/dist/lib/session-tokens.js.map +0 -1
- package/dist/lib/synthetic-config.d.ts.map +0 -1
- package/dist/lib/synthetic-config.js.map +0 -1
- package/dist/lib/synthetic.d.ts.map +0 -1
- package/dist/lib/synthetic.js.map +0 -1
- package/dist/lib/toast-format-grouped.d.ts.map +0 -1
- package/dist/lib/toast-format-grouped.js.map +0 -1
- package/dist/lib/token-buckets.d.ts.map +0 -1
- package/dist/lib/token-buckets.js.map +0 -1
- package/dist/lib/token-cost.d.ts.map +0 -1
- package/dist/lib/token-cost.js.map +0 -1
- package/dist/lib/tui-compact-format.d.ts.map +0 -1
- package/dist/lib/tui-compact-format.js.map +0 -1
- package/dist/lib/tui-panel-state.d.ts.map +0 -1
- package/dist/lib/tui-panel-state.js.map +0 -1
- package/dist/lib/tui-prompt-bar-format.d.ts.map +0 -1
- package/dist/lib/tui-prompt-bar-format.js.map +0 -1
- package/dist/lib/tui-sidebar-format.d.ts.map +0 -1
- package/dist/lib/tui-sidebar-format.js.map +0 -1
- package/dist/lib/types.d.ts.map +0 -1
- package/dist/lib/types.js.map +0 -1
- package/dist/lib/usage-ownership.d.ts.map +0 -1
- package/dist/lib/usage-ownership.js.map +0 -1
- package/dist/lib/version.d.ts.map +0 -1
- package/dist/lib/version.js.map +0 -1
- package/dist/lib/xai.d.ts.map +0 -1
- package/dist/lib/xai.js.map +0 -1
- package/dist/lib/zai-auth.d.ts.map +0 -1
- package/dist/lib/zai-auth.js.map +0 -1
- package/dist/lib/zai.d.ts.map +0 -1
- package/dist/lib/zai.js.map +0 -1
- package/dist/lib/zhipu-auth.d.ts.map +0 -1
- package/dist/lib/zhipu-auth.js.map +0 -1
- package/dist/lib/zhipu.d.ts.map +0 -1
- package/dist/lib/zhipu.js.map +0 -1
- package/dist/plugin.d.ts.map +0 -1
- package/dist/plugin.js.map +0 -1
- package/dist/providers/accounting-decimal.d.ts.map +0 -1
- package/dist/providers/accounting-decimal.js.map +0 -1
- package/dist/providers/alibaba-coding-plan.d.ts.map +0 -1
- package/dist/providers/alibaba-coding-plan.js.map +0 -1
- package/dist/providers/alibaba-token-plan.d.ts.map +0 -1
- package/dist/providers/alibaba-token-plan.js.map +0 -1
- package/dist/providers/anthropic.d.ts.map +0 -1
- package/dist/providers/anthropic.js.map +0 -1
- package/dist/providers/cache-policies.d.ts.map +0 -1
- package/dist/providers/cache-policies.js.map +0 -1
- package/dist/providers/chutes.d.ts.map +0 -1
- package/dist/providers/chutes.js.map +0 -1
- package/dist/providers/copilot.d.ts.map +0 -1
- package/dist/providers/copilot.js.map +0 -1
- package/dist/providers/cursor.d.ts.map +0 -1
- package/dist/providers/cursor.js.map +0 -1
- package/dist/providers/deepseek.d.ts.map +0 -1
- package/dist/providers/deepseek.js.map +0 -1
- package/dist/providers/glm-coding-plan-provider.d.ts.map +0 -1
- package/dist/providers/glm-coding-plan-provider.js.map +0 -1
- package/dist/providers/google-account-format.d.ts.map +0 -1
- package/dist/providers/google-account-format.js.map +0 -1
- package/dist/providers/google-agy.d.ts.map +0 -1
- package/dist/providers/google-agy.js.map +0 -1
- package/dist/providers/google-gemini-cli.d.ts.map +0 -1
- package/dist/providers/google-gemini-cli.js.map +0 -1
- package/dist/providers/kilo.d.ts.map +0 -1
- package/dist/providers/kilo.js.map +0 -1
- package/dist/providers/kimi-code.d.ts.map +0 -1
- package/dist/providers/kimi-code.js.map +0 -1
- package/dist/providers/mimo.d.ts.map +0 -1
- package/dist/providers/mimo.js.map +0 -1
- package/dist/providers/minimax-coding-plan.d.ts.map +0 -1
- package/dist/providers/minimax-coding-plan.js.map +0 -1
- package/dist/providers/nanogpt.d.ts.map +0 -1
- package/dist/providers/nanogpt.js.map +0 -1
- package/dist/providers/ollama-cloud.d.ts.map +0 -1
- package/dist/providers/ollama-cloud.js.map +0 -1
- package/dist/providers/openai.d.ts.map +0 -1
- package/dist/providers/openai.js.map +0 -1
- package/dist/providers/opencode-go.d.ts.map +0 -1
- package/dist/providers/opencode-go.js.map +0 -1
- package/dist/providers/opencode-zen.d.ts.map +0 -1
- package/dist/providers/opencode-zen.js.map +0 -1
- package/dist/providers/openrouter.d.ts.map +0 -1
- package/dist/providers/openrouter.js.map +0 -1
- package/dist/providers/quota-providers.d.ts.map +0 -1
- package/dist/providers/quota-providers.js.map +0 -1
- package/dist/providers/registry.d.ts.map +0 -1
- package/dist/providers/registry.js.map +0 -1
- package/dist/providers/result-helpers.d.ts.map +0 -1
- package/dist/providers/result-helpers.js.map +0 -1
- package/dist/providers/synthetic.d.ts.map +0 -1
- package/dist/providers/synthetic.js.map +0 -1
- package/dist/providers/xai.d.ts.map +0 -1
- package/dist/providers/xai.js.map +0 -1
- package/dist/providers/zai.d.ts.map +0 -1
- package/dist/providers/zai.js.map +0 -1
- package/dist/providers/zhipu.d.ts.map +0 -1
- package/dist/providers/zhipu.js.map +0 -1
- package/dist/rpc.d.ts.map +0 -1
- package/dist/rpc.js.map +0 -1
- package/dist/ui/assets/index-D9lFKhSN.js +0 -9
package/dist/plugin.js
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* OpenCode V2 server plugin for the GUI-only product: it starts the
|
|
3
|
-
* dashboard
|
|
4
|
-
*
|
|
2
|
+
* OpenCode V2 server plugin for the GUI-only product: it starts the shared
|
|
3
|
+
* dashboard runtime, attaches the typed dashboard RPC transport, and keeps the
|
|
4
|
+
* credential and quota-reset retry lifecycle working. Inherited terminal
|
|
5
|
+
* surfaces (commands, tool, the TUI quota RPC and report hooks) are retained in
|
|
5
6
|
* their source modules but are not registered by this product.
|
|
6
7
|
*/
|
|
8
|
+
import { randomUUID } from "node:crypto";
|
|
7
9
|
import { Plugin } from "@opencode/plugin";
|
|
8
10
|
import { startDashboard } from "./gui/lifecycle.js";
|
|
11
|
+
import { scrubLogReason } from "./gui/log.js";
|
|
12
|
+
import { registerDashboardRpc } from "./gui/rpc.js";
|
|
13
|
+
import { projectOpenCodeCacheObserverEvent } from "./lib/cache-observer-ingestion.js";
|
|
14
|
+
import { readClaudeObservedTtl } from "./lib/claude-agent-transcript-ttl.js";
|
|
15
|
+
import { createClaudeAgentTtlTracker } from "./lib/claude-agent-ttl-tracker.js";
|
|
9
16
|
import { resolveOpenCodeLocationRoots } from "./lib/config-file-utils.js";
|
|
10
17
|
import { bindCredentialSource, createIntegrationCredentialSource, notifyCredentialsChanged, scrubCredentialErrorText, } from "./lib/opencode-auth.js";
|
|
11
18
|
import { resolveQuotaResetRetryDelayMs } from "./lib/quota-retry-wait.js";
|
|
@@ -13,14 +20,18 @@ import { resolveQuotaResetRetryDelayMs } from "./lib/quota-retry-wait.js";
|
|
|
13
20
|
function logReason(error) {
|
|
14
21
|
return scrubCredentialErrorText(error instanceof Error ? error.message : String(error));
|
|
15
22
|
}
|
|
23
|
+
const MAX_PENDING_CACHE_OBSERVER_EVENTS = 512;
|
|
24
|
+
const MAX_SAMPLED_SESSIONS = 1_024;
|
|
25
|
+
const HOST_EVENT_RECONNECT_DELAY_MS = 1_000;
|
|
16
26
|
export const QuotaToastPlugin = Plugin.define({
|
|
17
|
-
id: "opencode-quota-gui
|
|
27
|
+
id: "opencode-quota-gui",
|
|
18
28
|
async setup(ctx) {
|
|
19
29
|
const roots = resolveOpenCodeLocationRoots(ctx.location.directory);
|
|
20
30
|
// The quota collector accepts a small V1-shaped configuration client. V2
|
|
21
31
|
// does not expose a mutable global config to plugins; runtime settings are
|
|
22
32
|
// read from the canonical GUI config file by the collector.
|
|
23
33
|
const client = {
|
|
34
|
+
integration: { list: () => ctx.integration.list() },
|
|
24
35
|
config: {
|
|
25
36
|
get: async () => ({ data: {} }),
|
|
26
37
|
providers: async () => ({
|
|
@@ -43,25 +54,245 @@ export const QuotaToastPlugin = Plugin.define({
|
|
|
43
54
|
console.warn(`[opencode-quota-gui] retry hook failed: ${logReason(error)}`);
|
|
44
55
|
}
|
|
45
56
|
});
|
|
57
|
+
// Owner-approved per-session approximation (not per-request proof): the host shares no
|
|
58
|
+
// per-invocation id between `model.request` and `session.step.started`, and connections
|
|
59
|
+
// rarely change, so the active OpenAI connection METHOD is sampled once per session — on
|
|
60
|
+
// its `session.created` event, or on its first step for a session that predates this
|
|
61
|
+
// plugin — and reused for that session's OpenAI steps. A lookup still pending (or failed)
|
|
62
|
+
// leaves the step without a method, i.e. the conservative 5-minute TTL fallback; relayed
|
|
63
|
+
// steps are never rewritten and a mid-session credential change is not reflected.
|
|
64
|
+
// Only the allowlisted method is kept; credential values, ids and labels are never read.
|
|
65
|
+
const openaiMethodBySession = new Map();
|
|
66
|
+
const sampleOpenAiMethod = (sessionID) => {
|
|
67
|
+
if (typeof sessionID !== "string" || sessionID === "")
|
|
68
|
+
return;
|
|
69
|
+
if (openaiMethodBySession.has(sessionID))
|
|
70
|
+
return;
|
|
71
|
+
if (openaiMethodBySession.size >= MAX_SAMPLED_SESSIONS) {
|
|
72
|
+
const oldest = openaiMethodBySession.keys().next().value;
|
|
73
|
+
if (oldest !== undefined)
|
|
74
|
+
openaiMethodBySession.delete(oldest);
|
|
75
|
+
}
|
|
76
|
+
const entry = {};
|
|
77
|
+
openaiMethodBySession.set(sessionID, entry);
|
|
78
|
+
void (async () => {
|
|
79
|
+
try {
|
|
80
|
+
const connection = await ctx.integration.connection.active("openai");
|
|
81
|
+
const method = connection?.type === "credential" ? connection.method : undefined;
|
|
82
|
+
if (method === "oauth" || method === "key" || method === "external") {
|
|
83
|
+
entry.method = method;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
catch {
|
|
87
|
+
// Unavailable metadata keeps the 5-minute fallback.
|
|
88
|
+
}
|
|
89
|
+
})();
|
|
90
|
+
};
|
|
46
91
|
// Every login read in this process goes through this location's `ctx.integration`. Bound
|
|
47
92
|
// last, so a setup that fails part way leaves no binding behind. OpenCode routes the
|
|
48
93
|
// retained hooks only after setup, so no read comes earlier.
|
|
49
94
|
const unbindCredentialSource = bindCredentialSource(createIntegrationCredentialSource(ctx.integration));
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
95
|
+
let dashboardRpc;
|
|
96
|
+
let cacheObserverEmitChain = Promise.resolve();
|
|
97
|
+
const pendingCacheObserverEvents = [];
|
|
98
|
+
let pendingCacheObserverEventsDropped = false;
|
|
99
|
+
let pendingHostEventObservedAtMs;
|
|
100
|
+
const cacheObserverRelayAbort = new AbortController();
|
|
101
|
+
let cacheObserverEmitWorkerRunning = false;
|
|
102
|
+
const hostEventSourceBinding = randomUUID();
|
|
103
|
+
let hostEventSourceState = "unverified";
|
|
104
|
+
const readHostEventSourceState = () => hostEventSourceState;
|
|
105
|
+
async function waitForHostEventReconnect(signal) {
|
|
106
|
+
if (signal.aborted)
|
|
107
|
+
return;
|
|
108
|
+
await new Promise((resolve) => {
|
|
109
|
+
let timer;
|
|
110
|
+
const finish = () => {
|
|
111
|
+
if (timer !== undefined)
|
|
112
|
+
clearTimeout(timer);
|
|
113
|
+
signal.removeEventListener("abort", finish);
|
|
114
|
+
resolve();
|
|
115
|
+
};
|
|
116
|
+
timer = setTimeout(finish, HOST_EVENT_RECONNECT_DELAY_MS);
|
|
117
|
+
signal.addEventListener("abort", finish, { once: true });
|
|
118
|
+
if (signal.aborted)
|
|
119
|
+
finish();
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
async function emitCacheObserverEventNow(registration, pending) {
|
|
123
|
+
const { signal } = cacheObserverRelayAbort;
|
|
124
|
+
if (signal.aborted)
|
|
125
|
+
return;
|
|
126
|
+
const emission = Promise.resolve()
|
|
127
|
+
.then(() => {
|
|
128
|
+
if (signal.aborted)
|
|
129
|
+
return;
|
|
130
|
+
return registration.events.emit("invalidated", {
|
|
131
|
+
topic: "cache.observer",
|
|
132
|
+
at: pending.at,
|
|
133
|
+
cacheObserverEvent: pending.event,
|
|
134
|
+
});
|
|
135
|
+
})
|
|
136
|
+
.then(() => undefined, () => undefined);
|
|
137
|
+
if (signal.aborted)
|
|
138
|
+
return;
|
|
139
|
+
await new Promise((resolve) => {
|
|
140
|
+
const finish = () => {
|
|
141
|
+
signal.removeEventListener("abort", finish);
|
|
142
|
+
resolve();
|
|
143
|
+
};
|
|
144
|
+
signal.addEventListener("abort", finish, { once: true });
|
|
145
|
+
void emission.then(finish);
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
async function drainCacheObserverEvents() {
|
|
149
|
+
try {
|
|
150
|
+
while (!cacheObserverRelayAbort.signal.aborted) {
|
|
151
|
+
if (pendingCacheObserverEventsDropped) {
|
|
152
|
+
pendingCacheObserverEventsDropped = false;
|
|
153
|
+
const registration = dashboardRpc;
|
|
154
|
+
if (!registration)
|
|
155
|
+
continue;
|
|
156
|
+
const gapAt = Date.now();
|
|
157
|
+
await emitCacheObserverEventNow(registration, {
|
|
158
|
+
at: gapAt,
|
|
159
|
+
event: {
|
|
160
|
+
type: "source.status",
|
|
161
|
+
created: gapAt,
|
|
162
|
+
data: { state: "unavailable", sourceBinding: hostEventSourceBinding },
|
|
163
|
+
},
|
|
164
|
+
});
|
|
165
|
+
if (hostEventSourceState === "observed")
|
|
166
|
+
pendingHostEventObservedAtMs = gapAt;
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
const pending = pendingCacheObserverEvents.shift();
|
|
170
|
+
if (!pending) {
|
|
171
|
+
const observedAt = pendingHostEventObservedAtMs;
|
|
172
|
+
if (observedAt === undefined)
|
|
173
|
+
break;
|
|
174
|
+
pendingHostEventObservedAtMs = undefined;
|
|
175
|
+
if (hostEventSourceState !== "observed")
|
|
176
|
+
continue;
|
|
177
|
+
const registration = dashboardRpc;
|
|
178
|
+
if (registration) {
|
|
179
|
+
await emitCacheObserverEventNow(registration, {
|
|
180
|
+
at: observedAt,
|
|
181
|
+
event: {
|
|
182
|
+
type: "source.status",
|
|
183
|
+
created: observedAt,
|
|
184
|
+
data: { state: "observed", sourceBinding: hostEventSourceBinding },
|
|
185
|
+
},
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
const registration = dashboardRpc;
|
|
191
|
+
if (registration)
|
|
192
|
+
await emitCacheObserverEventNow(registration, pending);
|
|
58
193
|
}
|
|
59
194
|
}
|
|
60
|
-
|
|
61
|
-
|
|
195
|
+
finally {
|
|
196
|
+
cacheObserverEmitWorkerRunning = false;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
const startCacheObserverEmitWorker = () => {
|
|
200
|
+
if (!dashboardRpc ||
|
|
201
|
+
cacheObserverRelayAbort.signal.aborted ||
|
|
202
|
+
cacheObserverEmitWorkerRunning) {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
cacheObserverEmitWorkerRunning = true;
|
|
206
|
+
cacheObserverEmitChain = drainCacheObserverEvents().catch(() => undefined);
|
|
207
|
+
};
|
|
208
|
+
const emitCacheObserverEvent = (event, at) => {
|
|
209
|
+
if (cacheObserverRelayAbort.signal.aborted)
|
|
62
210
|
return;
|
|
63
|
-
|
|
211
|
+
if (pendingCacheObserverEvents.length >= MAX_PENDING_CACHE_OBSERVER_EVENTS) {
|
|
212
|
+
pendingCacheObserverEvents.shift();
|
|
213
|
+
pendingCacheObserverEventsDropped = true;
|
|
214
|
+
}
|
|
215
|
+
pendingCacheObserverEvents.push({ at, event });
|
|
216
|
+
startCacheObserverEmitWorker();
|
|
217
|
+
};
|
|
218
|
+
const publishHostEventSourceState = (state, at) => {
|
|
219
|
+
if (hostEventSourceState === state)
|
|
220
|
+
return;
|
|
221
|
+
hostEventSourceState = state;
|
|
222
|
+
if (state !== "observed")
|
|
223
|
+
pendingHostEventObservedAtMs = undefined;
|
|
224
|
+
emitCacheObserverEvent({
|
|
225
|
+
type: "source.status",
|
|
226
|
+
created: at,
|
|
227
|
+
data: { state, sourceBinding: hostEventSourceBinding },
|
|
228
|
+
}, at);
|
|
229
|
+
};
|
|
230
|
+
const claudeTtl = createClaudeAgentTtlTracker({
|
|
231
|
+
directory: ctx.location.directory,
|
|
232
|
+
read: readClaudeObservedTtl,
|
|
233
|
+
emit: emitCacheObserverEvent,
|
|
64
234
|
});
|
|
235
|
+
// Reuse the existing host stream for credential invalidation and narrowly projected cache
|
|
236
|
+
// evidence. No Native-side OpenCode event subscription is opened.
|
|
237
|
+
const hostEvents = new AbortController();
|
|
238
|
+
void (async () => {
|
|
239
|
+
const { signal } = hostEvents;
|
|
240
|
+
while (!signal.aborted) {
|
|
241
|
+
try {
|
|
242
|
+
for await (const event of ctx.event.subscribe({ signal })) {
|
|
243
|
+
if (signal.aborted)
|
|
244
|
+
return;
|
|
245
|
+
if (readHostEventSourceState() !== "observed") {
|
|
246
|
+
publishHostEventSourceState("observed", typeof event.created === "number" && Number.isFinite(event.created)
|
|
247
|
+
? event.created
|
|
248
|
+
: Date.now());
|
|
249
|
+
}
|
|
250
|
+
if (event.type === "credential.updated" || event.type === "credential.switched") {
|
|
251
|
+
notifyCredentialsChanged();
|
|
252
|
+
}
|
|
253
|
+
// The Started event's model identity is available before invocation completion. Do not
|
|
254
|
+
// enrich it from model.list here: that mutable catalog may no longer match dispatch.
|
|
255
|
+
const sessionID = event.data?.sessionID;
|
|
256
|
+
if (event.type === "session.created")
|
|
257
|
+
sampleOpenAiMethod(sessionID);
|
|
258
|
+
else if (event.type === "session.deleted" && typeof sessionID === "string") {
|
|
259
|
+
openaiMethodBySession.delete(sessionID);
|
|
260
|
+
}
|
|
261
|
+
let cacheObserverEvent = projectOpenCodeCacheObserverEvent(event);
|
|
262
|
+
if (cacheObserverEvent?.type === "session.step.started" &&
|
|
263
|
+
cacheObserverEvent.data.model.providerID === "openai") {
|
|
264
|
+
sampleOpenAiMethod(cacheObserverEvent.data.sessionID);
|
|
265
|
+
const method = openaiMethodBySession.get(cacheObserverEvent.data.sessionID)?.method;
|
|
266
|
+
if (method !== undefined) {
|
|
267
|
+
cacheObserverEvent = {
|
|
268
|
+
...cacheObserverEvent,
|
|
269
|
+
data: { ...cacheObserverEvent.data, connectionMethod: method },
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
if (cacheObserverEvent !== undefined &&
|
|
274
|
+
typeof event.created === "number" &&
|
|
275
|
+
Number.isFinite(event.created) &&
|
|
276
|
+
event.created >= 0) {
|
|
277
|
+
emitCacheObserverEvent(cacheObserverEvent, event.created);
|
|
278
|
+
}
|
|
279
|
+
claudeTtl.observe(event, cacheObserverEvent);
|
|
280
|
+
}
|
|
281
|
+
if (signal.aborted)
|
|
282
|
+
return;
|
|
283
|
+
throw new Error("host event stream ended");
|
|
284
|
+
}
|
|
285
|
+
catch (error) {
|
|
286
|
+
if (signal.aborted)
|
|
287
|
+
return;
|
|
288
|
+
if (readHostEventSourceState() !== "unavailable") {
|
|
289
|
+
publishHostEventSourceState("unavailable", Date.now());
|
|
290
|
+
}
|
|
291
|
+
console.warn(`[opencode-quota-gui] host event subscription failed; retrying: ${logReason(error)}`);
|
|
292
|
+
await waitForHostEventReconnect(signal);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
})();
|
|
65
296
|
// The dashboard host binds last — after the retry hook and the credential binding — and it
|
|
66
297
|
// never fails setup: every dashboard error stays a controlled log line and an `unavailable`
|
|
67
298
|
// lease (spec §4.3). The first owner workspace supplies the config import root, and the
|
|
@@ -69,17 +300,63 @@ export const QuotaToastPlugin = Plugin.define({
|
|
|
69
300
|
// first snapshot is computed on the first request.
|
|
70
301
|
let dashboardLease;
|
|
71
302
|
try {
|
|
303
|
+
// Older hosts may not supply `ctx.app` at runtime; an absent or empty
|
|
304
|
+
// version lets the lifecycle use its bounded `opencode --version` probe.
|
|
305
|
+
const hostVersion = ctx.app?.version;
|
|
72
306
|
dashboardLease = await startDashboard({
|
|
73
307
|
client,
|
|
74
308
|
workspaceRoot: ctx.location.directory,
|
|
309
|
+
...(hostVersion !== undefined ? { hostVersion } : {}),
|
|
75
310
|
});
|
|
76
311
|
}
|
|
77
312
|
catch (error) {
|
|
78
313
|
console.warn(`[opencode-quota-gui] dashboard unavailable: ${logReason(error)}`);
|
|
79
314
|
}
|
|
315
|
+
// Attach the native RPC transport to the same host runtime the web
|
|
316
|
+
// transport receives. It is available when web is disabled or its bind
|
|
317
|
+
// failed, and it never constructs another source/snapshot/service.
|
|
318
|
+
if (dashboardLease?.runtime && ctx.rpc) {
|
|
319
|
+
try {
|
|
320
|
+
dashboardRpc = await registerDashboardRpc(ctx.rpc, dashboardLease.runtime, {
|
|
321
|
+
location: ctx.location,
|
|
322
|
+
onWatchSnapshot: (attemptNonce) => {
|
|
323
|
+
const at = Date.now();
|
|
324
|
+
emitCacheObserverEvent({
|
|
325
|
+
type: "source.status",
|
|
326
|
+
created: at,
|
|
327
|
+
data: {
|
|
328
|
+
state: readHostEventSourceState(),
|
|
329
|
+
attemptNonce,
|
|
330
|
+
sourceBinding: hostEventSourceBinding,
|
|
331
|
+
},
|
|
332
|
+
}, at);
|
|
333
|
+
},
|
|
334
|
+
});
|
|
335
|
+
startCacheObserverEmitWorker();
|
|
336
|
+
}
|
|
337
|
+
catch {
|
|
338
|
+
console.warn(`[opencode-quota-gui] dashboard RPC unavailable: registration-failed`);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
80
341
|
return async () => {
|
|
81
|
-
|
|
342
|
+
hostEvents.abort();
|
|
343
|
+
claudeTtl.dispose();
|
|
344
|
+
openaiMethodBySession.clear();
|
|
345
|
+
pendingCacheObserverEvents.length = 0;
|
|
346
|
+
publishHostEventSourceState("stopped", Date.now());
|
|
82
347
|
unbindCredentialSource();
|
|
348
|
+
pendingCacheObserverEvents.length = 0;
|
|
349
|
+
pendingCacheObserverEventsDropped = false;
|
|
350
|
+
cacheObserverRelayAbort.abort();
|
|
351
|
+
await cacheObserverEmitChain;
|
|
352
|
+
if (dashboardRpc) {
|
|
353
|
+
try {
|
|
354
|
+
await dashboardRpc.dispose();
|
|
355
|
+
}
|
|
356
|
+
catch (error) {
|
|
357
|
+
console.warn(`[opencode-quota-gui] dashboard RPC stop failed: ${scrubLogReason(error instanceof Error ? error.message : String(error))}`);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
83
360
|
if (dashboardLease) {
|
|
84
361
|
try {
|
|
85
362
|
await dashboardLease.dispose();
|
|
@@ -5,7 +5,7 @@ Provider logo assets in this directory are vendored from [models.dev](https://gi
|
|
|
5
5
|
- **Upstream license:** MIT. The copyright and permission notice is preserved verbatim in `UPSTREAM-MIT.txt`.
|
|
6
6
|
- **Source path:** `providers/<provider-id>/logo.svg` in the pinned models.dev archive.
|
|
7
7
|
- **Normalization:** each SVG is stored as UTF-8 with XML/DTD declarations removed, trailing horizontal whitespace outside whitespace-sensitive text content stripped, and a final newline added; the artwork itself is unchanged.
|
|
8
|
-
- **Local use:** 222 upstream provider logos, the local neutral `generic.svg` fallback and the local OpenCode Go G
|
|
8
|
+
- **Local use:** 222 upstream provider logos, the local neutral `generic.svg` fallback and the local OpenCode Go G and Claude Agent marks are copied into the package at build time and served from same-origin `/assets/providers/`. The dashboard never hotlinks a remote logo.
|
|
9
9
|
- **OpenCode identities:** the upstream `opencode` and `opencode-go` entries in models.dev both contain the O artwork and remain vendored unchanged. Presentation overrides only `opencode-go` with a dedicated G mark extracted from [OpenCode](https://github.com/anomalyco/opencode) at `86976449c40d48f2731553a024f74552593d1764`; see `OPENCODE-NOTICE.md` and `OPENCODE-MIT.txt`. `opencode` and OpenCode Zen keep the O mark. Raw analytics identities are never rewritten.
|
|
10
10
|
- **Brand rights:** the MIT license covers the models.dev repository and the assets as distributed there. It does not establish or grant rights in any provider's name, logo, or other trademark, and individual brand-use terms may still apply. The logos identify the corresponding providers in a local dashboard; no affiliation or endorsement is implied.
|
|
11
11
|
- **Mask-incompatible marks:** a small number of upstream marks use an opaque raster or full-bleed background and would collapse to a solid block under a one-colour mask. The catalog shows the local neutral fallback for those while keeping the vendored file and attribution.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# OpenCode
|
|
1
|
+
# OpenCode provider artwork attribution
|
|
2
2
|
|
|
3
3
|
The local OpenCode Go mark in `opencode-go-g.svg` is extracted from the public OpenCode provider icon sprite.
|
|
4
4
|
|
|
@@ -7,6 +7,7 @@ The local OpenCode Go mark in `opencode-go-g.svg` is extracted from the public O
|
|
|
7
7
|
- **Source file:** `packages/ui/src/components/provider-icons/sprite.svg`
|
|
8
8
|
- **Source symbol:** `<symbol id="opencode-go">`
|
|
9
9
|
- **License:** MIT; copyright `Copyright (c) 2025 opencode`. The full upstream text is preserved verbatim in `OPENCODE-MIT.txt`.
|
|
10
|
-
- **Extraction:** only the single `<path>` inside the `opencode-go` symbol is included, wrapped in a standalone SVG with `viewBox="0 0 24 24"` and `fill="currentColor"`.
|
|
10
|
+
- **Extraction:** only the single `<path>` inside the `opencode-go` symbol is included in that asset, wrapped in a standalone SVG with `viewBox="0 0 24 24"` and `fill="currentColor"`.
|
|
11
11
|
- **Upstream separation:** models.dev's upstream `opencode-go` O mark remains vendored unchanged in `opencode-go.svg`; the local G mark is a presentation override for OpenCode Go only. `opencode` and OpenCode Zen continue to use the models.dev O mark.
|
|
12
|
-
- **
|
|
12
|
+
- **Claude Agent:** `claude-agent.svg` extracts only the `<symbol id="claude-agent">` path from the same sprite at commit `850504188198976c668bd3b514c3e8de21b9e0e2` (sprite SHA-256 `9f17db4e21f4450b000c2e105ad137c775172135eb31d8441940a45e567d0792`), wrapped as a standalone monochrome SVG retaining its viewBox.
|
|
13
|
+
- **Use:** the marks identify OpenCode Go and Claude Agent in this local dashboard. No affiliation or endorsement is implied, and brand rights remain with their owners.
|
|
@@ -1,18 +1,96 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { isAlibabaModelId } from "../lib/alibaba-auth.js";
|
|
2
|
+
import { queryAlibabaCodingPlanQuota, } from "../lib/alibaba-coding-plan-cli.js";
|
|
3
|
+
import { sanitizeSingleLineDisplayText } from "../lib/display-sanitize.js";
|
|
4
|
+
import { isCanonicalProviderAvailable } from "../lib/provider-availability.js";
|
|
5
|
+
import { attemptedErrorResult, attemptedResult, statusDetailsFromRecord, withStatusDetails, } from "./result-helpers.js";
|
|
6
|
+
const CLI_LABEL = "Bailian CLI";
|
|
7
|
+
const QUOTA_ACCOUNTING = {
|
|
8
|
+
resultType: "quota",
|
|
9
|
+
acquisitionMethod: "local_cli",
|
|
10
|
+
ownership: "maintained",
|
|
11
|
+
authority: "provider_reported",
|
|
12
|
+
};
|
|
13
|
+
const STATUS_ACCOUNTING = {
|
|
14
|
+
...QUOTA_ACCOUNTING,
|
|
15
|
+
resultType: "status",
|
|
16
|
+
};
|
|
17
|
+
function windowEntry(window, params) {
|
|
18
|
+
if (!window)
|
|
19
|
+
return undefined;
|
|
20
|
+
const name = `${params.group} ${params.suffix}`;
|
|
21
|
+
const resetTime = window.resetTimeIso ? { resetTimeIso: window.resetTimeIso } : {};
|
|
22
|
+
if (window.percentage !== undefined) {
|
|
23
|
+
const hasCounts = window.used !== undefined && window.total !== undefined && window.total > 0;
|
|
24
|
+
return {
|
|
25
|
+
accounting: { ...QUOTA_ACCOUNTING },
|
|
26
|
+
name,
|
|
27
|
+
group: params.group,
|
|
28
|
+
label: params.label,
|
|
29
|
+
...(hasCounts ? { right: `${window.used}/${window.total}` } : {}),
|
|
30
|
+
percentRemaining: Math.max(0, Math.min(100, (1 - window.percentage) * 100)),
|
|
31
|
+
...resetTime,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
if (window.resetTimeIso) {
|
|
35
|
+
return {
|
|
36
|
+
kind: "value",
|
|
37
|
+
accounting: { ...STATUS_ACCOUNTING },
|
|
38
|
+
name,
|
|
39
|
+
group: params.group,
|
|
40
|
+
label: params.label,
|
|
41
|
+
value: "Quota details unavailable",
|
|
42
|
+
...resetTime,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
function entriesFromUsage(result) {
|
|
48
|
+
const instanceType = result.usage.instanceType
|
|
49
|
+
? sanitizeSingleLineDisplayText(result.usage.instanceType).trim().slice(0, 40)
|
|
50
|
+
: "";
|
|
51
|
+
const group = `Alibaba Coding Plan${instanceType ? ` (${instanceType})` : ""} (CLI)`;
|
|
52
|
+
return [
|
|
53
|
+
windowEntry(result.usage.fiveHour, { group, suffix: "5h", label: "5h:" }),
|
|
54
|
+
windowEntry(result.usage.weekly, { group, suffix: "Weekly", label: "Weekly:" }),
|
|
55
|
+
windowEntry(result.usage.monthly, { group, suffix: "Monthly", label: "Monthly:" }),
|
|
56
|
+
].filter((entry) => entry !== undefined);
|
|
57
|
+
}
|
|
58
|
+
function failureCategoryFor(kind) {
|
|
59
|
+
if (kind === "not_authenticated")
|
|
60
|
+
return "credentials";
|
|
61
|
+
if (kind === "invalid_json" ||
|
|
62
|
+
kind === "invalid_schema" ||
|
|
63
|
+
kind === "nonzero_exit" ||
|
|
64
|
+
kind === "output_truncated" ||
|
|
65
|
+
kind === "no_quota_data") {
|
|
66
|
+
return "provider_api";
|
|
67
|
+
}
|
|
68
|
+
return "local";
|
|
69
|
+
}
|
|
70
|
+
function resultWithCliStatus(result, statusDetails, status) {
|
|
71
|
+
return withStatusDetails(result, [
|
|
72
|
+
...statusDetails,
|
|
73
|
+
...statusDetailsFromRecord({ alibaba_coding_plan_cli_status: status }),
|
|
74
|
+
]);
|
|
7
75
|
}
|
|
8
76
|
export const alibabaCodingPlanProvider = {
|
|
9
77
|
id: "alibaba-coding-plan",
|
|
10
|
-
async isAvailable(
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
78
|
+
async isAvailable(ctx) {
|
|
79
|
+
const selected = await isCanonicalProviderAvailable({
|
|
80
|
+
ctx,
|
|
81
|
+
providerId: "alibaba-coding-plan",
|
|
82
|
+
fallbackOnError: false,
|
|
14
83
|
});
|
|
15
|
-
|
|
84
|
+
if (selected)
|
|
85
|
+
return true;
|
|
86
|
+
if (ctx.config.currentProviderID === "alibaba-coding-plan" ||
|
|
87
|
+
ctx.config.currentProviderID === "alibaba") {
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
const currentModel = ctx.config.currentModel;
|
|
91
|
+
return typeof currentModel === "string" && currentModel.length > 0
|
|
92
|
+
? isAlibabaModelId(currentModel)
|
|
93
|
+
: false;
|
|
16
94
|
},
|
|
17
95
|
matchesCurrentModel(model, context) {
|
|
18
96
|
return context?.currentProviderID
|
|
@@ -21,102 +99,29 @@ export const alibabaCodingPlanProvider = {
|
|
|
21
99
|
: isAlibabaModelId(model);
|
|
22
100
|
},
|
|
23
101
|
async fetch(ctx) {
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
});
|
|
28
|
-
const plan = await resolveAlibabaCodingPlanAuthCached({
|
|
29
|
-
maxAgeMs: DEFAULT_ALIBABA_AUTH_CACHE_MAX_AGE_MS,
|
|
30
|
-
fallbackTier: "lite",
|
|
102
|
+
const result = await queryAlibabaCodingPlanQuota({
|
|
103
|
+
requestTimeoutMs: ctx.config?.requestTimeoutMs,
|
|
104
|
+
runtime: { cwd: ctx.workspaceRoot },
|
|
31
105
|
});
|
|
32
|
-
const statePath = getAlibabaCodingPlanQuotaPath();
|
|
33
|
-
const state = await inspectGeneratedCounterFile(statePath, ALIBABA_CODING_PLAN_STATE_VERSION);
|
|
34
|
-
const lastUpdate = state.lastUpdatedAt === null ? "(none)" : new Date(state.lastUpdatedAt).toISOString();
|
|
35
|
-
const authError = diagnostics.state === "invalid" ? diagnostics.error : undefined;
|
|
36
106
|
const statusDetails = statusDetailsFromRecord({
|
|
37
|
-
|
|
38
|
-
alibaba_api_key_source: diagnostics.source ?? "(none)",
|
|
39
|
-
alibaba_api_key_checked_paths: diagnostics.checkedPaths.join(" | ") || "(none)",
|
|
40
|
-
alibaba_api_key_credential_database_paths: diagnostics.credentialDatabasePaths.join(" | ") || "(none)",
|
|
41
|
-
alibaba_coding_plan: diagnostics.state === "configured"
|
|
42
|
-
? diagnostics.tier
|
|
43
|
-
: diagnostics.state === "invalid"
|
|
44
|
-
? "invalid"
|
|
45
|
-
: "(none)",
|
|
46
|
-
alibaba_auth_error: authError,
|
|
47
|
-
"alibaba coding plan error": authError,
|
|
48
|
-
"alibaba coding plan local quota": `path=${statePath} exists=${state.exists ? "true" : "false"} health=${state.health} version=${state.version ?? "(none)"} last_update=${lastUpdate}`,
|
|
49
|
-
local_state_path: statePath,
|
|
50
|
-
local_state_exists: state.exists ? "true" : "false",
|
|
51
|
-
local_state_health: state.health,
|
|
52
|
-
local_state_version: String(state.version ?? "(none)"),
|
|
53
|
-
local_state_last_update: lastUpdate,
|
|
107
|
+
alibaba_coding_plan_source: "bl usage coding-plan --output json",
|
|
54
108
|
});
|
|
55
|
-
if (
|
|
56
|
-
return
|
|
109
|
+
if (result.state === "error") {
|
|
110
|
+
return resultWithCliStatus(attemptedErrorResult(`${CLI_LABEL} Coding Plan usage`, result.error.message, {
|
|
111
|
+
retryable: result.error.retryable,
|
|
112
|
+
failureCategory: failureCategoryFor(result.error.kind),
|
|
113
|
+
}), statusDetails, result.error.kind);
|
|
57
114
|
}
|
|
58
|
-
if (
|
|
59
|
-
return
|
|
115
|
+
if (result.state === "no-subscription") {
|
|
116
|
+
return resultWithCliStatus(attemptedResult([]), statusDetails, "no-subscription");
|
|
60
117
|
}
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
: undefined;
|
|
69
|
-
const quota = computeAlibabaCodingPlanQuota({
|
|
70
|
-
state: await readAlibabaCodingPlanQuotaState(),
|
|
71
|
-
tier: plan.tier,
|
|
72
|
-
...(limits ? { limits } : {}),
|
|
73
|
-
});
|
|
74
|
-
const label = `Alibaba Coding Plan (${tierLabel(plan.tier)})`;
|
|
75
|
-
const entries = [
|
|
76
|
-
{
|
|
77
|
-
accounting: {
|
|
78
|
-
resultType: "quota",
|
|
79
|
-
acquisitionMethod: "local_estimation",
|
|
80
|
-
ownership: "maintained",
|
|
81
|
-
authority: "locally_derived",
|
|
82
|
-
},
|
|
83
|
-
name: `${label} 5h`,
|
|
84
|
-
group: label,
|
|
85
|
-
label: "5h:",
|
|
86
|
-
right: `${quota.fiveHour.used}/${quota.fiveHour.limit}`,
|
|
87
|
-
percentRemaining: quota.fiveHour.percentRemaining,
|
|
88
|
-
resetTimeIso: quota.fiveHour.resetTimeIso,
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
accounting: {
|
|
92
|
-
resultType: "quota",
|
|
93
|
-
acquisitionMethod: "local_estimation",
|
|
94
|
-
ownership: "maintained",
|
|
95
|
-
authority: "locally_derived",
|
|
96
|
-
},
|
|
97
|
-
name: `${label} Weekly`,
|
|
98
|
-
group: label,
|
|
99
|
-
label: "Weekly:",
|
|
100
|
-
right: `${quota.weekly.used}/${quota.weekly.limit}`,
|
|
101
|
-
percentRemaining: quota.weekly.percentRemaining,
|
|
102
|
-
resetTimeIso: quota.weekly.resetTimeIso,
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
accounting: {
|
|
106
|
-
resultType: "quota",
|
|
107
|
-
acquisitionMethod: "local_estimation",
|
|
108
|
-
ownership: "maintained",
|
|
109
|
-
authority: "locally_derived",
|
|
110
|
-
},
|
|
111
|
-
name: `${label} Monthly`,
|
|
112
|
-
group: label,
|
|
113
|
-
label: "Monthly:",
|
|
114
|
-
right: `${quota.monthly.used}/${quota.monthly.limit}`,
|
|
115
|
-
percentRemaining: quota.monthly.percentRemaining,
|
|
116
|
-
resetTimeIso: quota.monthly.resetTimeIso,
|
|
117
|
-
},
|
|
118
|
-
];
|
|
119
|
-
return withStatusDetails(attemptedResult(entries), statusDetails);
|
|
118
|
+
const entries = entriesFromUsage(result);
|
|
119
|
+
if (entries.length === 0) {
|
|
120
|
+
return resultWithCliStatus(attemptedErrorResult(`${CLI_LABEL} Coding Plan usage`, "Bailian CLI returned no usable Coding Plan quota data.", {
|
|
121
|
+
failureCategory: "provider_api",
|
|
122
|
+
}), statusDetails, "no-quota-data");
|
|
123
|
+
}
|
|
124
|
+
return resultWithCliStatus(attemptedResult(entries), statusDetails, "success");
|
|
120
125
|
},
|
|
121
126
|
};
|
|
122
127
|
//# sourceMappingURL=alibaba-coding-plan.js.map
|
|
@@ -38,6 +38,21 @@ function statusDetailsFromResult(result, platform) {
|
|
|
38
38
|
failure_kind: result.error.kind,
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
|
+
function alibabaFailureCategory(kind) {
|
|
42
|
+
switch (kind) {
|
|
43
|
+
case "executable_not_found":
|
|
44
|
+
case "shell_launcher_rejected":
|
|
45
|
+
case "workspace_path_rejected":
|
|
46
|
+
case "spawn_failed":
|
|
47
|
+
return "local";
|
|
48
|
+
case "not_authenticated":
|
|
49
|
+
return "credentials";
|
|
50
|
+
default:
|
|
51
|
+
// Timeout, malformed output, nonzero exit, and unavailable data can come
|
|
52
|
+
// from either the CLI process or the remote console. Absence fails closed.
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
41
56
|
function mapClosedResult(result) {
|
|
42
57
|
if (result.ok) {
|
|
43
58
|
const entries = [];
|
|
@@ -50,8 +65,10 @@ function mapClosedResult(result) {
|
|
|
50
65
|
if (result.error.kind === "unsupported_platform") {
|
|
51
66
|
return notAttemptedResult();
|
|
52
67
|
}
|
|
68
|
+
const failureCategory = alibabaFailureCategory(result.error.kind);
|
|
53
69
|
return attemptedErrorResult(GROUP, result.error.message, {
|
|
54
70
|
retryable: result.error.retryable === true,
|
|
71
|
+
...(failureCategory !== undefined ? { failureCategory } : {}),
|
|
55
72
|
});
|
|
56
73
|
}
|
|
57
74
|
export const alibabaTokenPlanProvider = {
|