opencode-quota-gui 0.0.0-stage → 1.0.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/LICENSE +21 -0
- package/README.md +245 -2
- package/dist/bin/opencode-quota-gui.d.ts +4 -0
- package/dist/bin/opencode-quota-gui.d.ts.map +1 -0
- package/dist/bin/opencode-quota-gui.js +75 -0
- package/dist/bin/opencode-quota-gui.js.map +1 -0
- package/dist/contracts/build-identity.d.ts +8 -0
- package/dist/contracts/build-identity.d.ts.map +1 -0
- package/dist/contracts/build-identity.js +1 -0
- package/dist/contracts/dashboard.d.ts +358 -0
- package/dist/contracts/dashboard.d.ts.map +1 -0
- package/dist/contracts/dashboard.js +3 -0
- package/dist/contracts/dashboard.js.map +1 -0
- package/dist/contracts/guards.d.ts +14 -0
- package/dist/contracts/guards.d.ts.map +1 -0
- package/dist/contracts/guards.js +56 -0
- package/dist/contracts/guards.js.map +1 -0
- package/dist/contracts/identity.d.ts +41 -0
- package/dist/contracts/identity.d.ts.map +1 -0
- package/dist/contracts/identity.js +27 -0
- package/dist/contracts/identity.js.map +1 -0
- package/dist/contracts/openai-quota.d.ts +34 -0
- package/dist/contracts/openai-quota.d.ts.map +1 -0
- package/dist/contracts/openai-quota.js +19 -0
- package/dist/contracts/openai-quota.js.map +1 -0
- package/dist/contracts/ranges.d.ts +48 -0
- package/dist/contracts/ranges.d.ts.map +1 -0
- package/dist/contracts/ranges.js +84 -0
- package/dist/contracts/ranges.js.map +1 -0
- package/dist/contracts/settings.d.ts +4 -0
- package/dist/contracts/settings.d.ts.map +1 -0
- package/dist/contracts/settings.js +14 -0
- package/dist/contracts/settings.js.map +1 -0
- package/dist/contracts/time-zone.d.ts +33 -0
- package/dist/contracts/time-zone.d.ts.map +1 -0
- package/dist/contracts/time-zone.js +217 -0
- package/dist/contracts/time-zone.js.map +1 -0
- package/dist/data/modelsdev-pricing.min.json +1064 -0
- package/dist/gui/aggregation.d.ts +55 -0
- package/dist/gui/aggregation.d.ts.map +1 -0
- package/dist/gui/aggregation.js +792 -0
- package/dist/gui/aggregation.js.map +1 -0
- package/dist/gui/analytics-bridge.d.ts +50 -0
- package/dist/gui/analytics-bridge.d.ts.map +1 -0
- package/dist/gui/analytics-bridge.js +382 -0
- package/dist/gui/analytics-bridge.js.map +1 -0
- package/dist/gui/analytics-engine.d.ts +61 -0
- package/dist/gui/analytics-engine.d.ts.map +1 -0
- package/dist/gui/analytics-engine.js +2381 -0
- package/dist/gui/analytics-engine.js.map +1 -0
- package/dist/gui/analytics-indexes.d.ts +34 -0
- package/dist/gui/analytics-indexes.d.ts.map +1 -0
- package/dist/gui/analytics-indexes.js +142 -0
- package/dist/gui/analytics-indexes.js.map +1 -0
- package/dist/gui/analytics-model.d.ts +48 -0
- package/dist/gui/analytics-model.d.ts.map +1 -0
- package/dist/gui/analytics-model.js +824 -0
- package/dist/gui/analytics-model.js.map +1 -0
- package/dist/gui/analytics-protocol.d.ts +102 -0
- package/dist/gui/analytics-protocol.d.ts.map +1 -0
- package/dist/gui/analytics-protocol.js +11 -0
- package/dist/gui/analytics-protocol.js.map +1 -0
- package/dist/gui/analytics-reader.d.ts +14 -0
- package/dist/gui/analytics-reader.d.ts.map +1 -0
- package/dist/gui/analytics-reader.js +15 -0
- package/dist/gui/analytics-reader.js.map +1 -0
- package/dist/gui/analytics-service.d.ts +49 -0
- package/dist/gui/analytics-service.d.ts.map +1 -0
- package/dist/gui/analytics-service.js +187 -0
- package/dist/gui/analytics-service.js.map +1 -0
- package/dist/gui/analytics-state.d.ts +183 -0
- package/dist/gui/analytics-state.d.ts.map +1 -0
- package/dist/gui/analytics-state.js +692 -0
- package/dist/gui/analytics-state.js.map +1 -0
- package/dist/gui/analytics-worker-runtime.d.ts +11 -0
- package/dist/gui/analytics-worker-runtime.d.ts.map +1 -0
- package/dist/gui/analytics-worker-runtime.js +98 -0
- package/dist/gui/analytics-worker-runtime.js.map +1 -0
- package/dist/gui/analytics-worker.d.ts +2 -0
- package/dist/gui/analytics-worker.d.ts.map +1 -0
- package/dist/gui/analytics-worker.js +64 -0
- package/dist/gui/analytics-worker.js.map +1 -0
- package/dist/gui/config.d.ts +53 -0
- package/dist/gui/config.d.ts.map +1 -0
- package/dist/gui/config.js +679 -0
- package/dist/gui/config.js.map +1 -0
- package/dist/gui/identity.d.ts +23 -0
- package/dist/gui/identity.d.ts.map +1 -0
- package/dist/gui/identity.js +57 -0
- package/dist/gui/identity.js.map +1 -0
- package/dist/gui/lifecycle.d.ts +82 -0
- package/dist/gui/lifecycle.d.ts.map +1 -0
- package/dist/gui/lifecycle.js +402 -0
- package/dist/gui/lifecycle.js.map +1 -0
- package/dist/gui/log.d.ts +23 -0
- package/dist/gui/log.d.ts.map +1 -0
- package/dist/gui/log.js +37 -0
- package/dist/gui/log.js.map +1 -0
- package/dist/gui/provider-cards.d.ts +58 -0
- package/dist/gui/provider-cards.d.ts.map +1 -0
- package/dist/gui/provider-cards.js +413 -0
- package/dist/gui/provider-cards.js.map +1 -0
- package/dist/gui/server.d.ts +60 -0
- package/dist/gui/server.d.ts.map +1 -0
- package/dist/gui/server.js +815 -0
- package/dist/gui/server.js.map +1 -0
- package/dist/gui/settings-file-opener.d.ts +34 -0
- package/dist/gui/settings-file-opener.d.ts.map +1 -0
- package/dist/gui/settings-file-opener.js +110 -0
- package/dist/gui/settings-file-opener.js.map +1 -0
- package/dist/gui/snapshot-service.d.ts +128 -0
- package/dist/gui/snapshot-service.d.ts.map +1 -0
- package/dist/gui/snapshot-service.js +591 -0
- package/dist/gui/snapshot-service.js.map +1 -0
- package/dist/gui/sources.d.ts +94 -0
- package/dist/gui/sources.d.ts.map +1 -0
- package/dist/gui/sources.js +404 -0
- package/dist/gui/sources.js.map +1 -0
- package/dist/gui/sse.d.ts +32 -0
- package/dist/gui/sse.d.ts.map +1 -0
- package/dist/gui/sse.js +100 -0
- package/dist/gui/sse.js.map +1 -0
- package/dist/gui/time-zone.d.ts +10 -0
- package/dist/gui/time-zone.d.ts.map +1 -0
- package/dist/gui/time-zone.js +21 -0
- package/dist/gui/time-zone.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/accounting-format.d.ts +54 -0
- package/dist/lib/accounting-format.d.ts.map +1 -0
- package/dist/lib/accounting-format.js +271 -0
- package/dist/lib/accounting-format.js.map +1 -0
- package/dist/lib/alibaba-auth.d.ts +46 -0
- package/dist/lib/alibaba-auth.d.ts.map +1 -0
- package/dist/lib/alibaba-auth.js +193 -0
- package/dist/lib/alibaba-auth.js.map +1 -0
- package/dist/lib/alibaba-coding-plan-local-quota.d.ts +47 -0
- package/dist/lib/alibaba-coding-plan-local-quota.d.ts.map +1 -0
- package/dist/lib/alibaba-coding-plan-local-quota.js +146 -0
- package/dist/lib/alibaba-coding-plan-local-quota.js.map +1 -0
- package/dist/lib/alibaba-token-plan.d.ts +91 -0
- package/dist/lib/alibaba-token-plan.d.ts.map +1 -0
- package/dist/lib/alibaba-token-plan.js +527 -0
- package/dist/lib/alibaba-token-plan.js.map +1 -0
- package/dist/lib/anthropic-auth.d.ts +29 -0
- package/dist/lib/anthropic-auth.d.ts.map +1 -0
- package/dist/lib/anthropic-auth.js +37 -0
- package/dist/lib/anthropic-auth.js.map +1 -0
- package/dist/lib/anthropic.d.ts +104 -0
- package/dist/lib/anthropic.d.ts.map +1 -0
- package/dist/lib/anthropic.js +1134 -0
- package/dist/lib/anthropic.js.map +1 -0
- package/dist/lib/api-key-resolver.d.ts +227 -0
- package/dist/lib/api-key-resolver.d.ts.map +1 -0
- package/dist/lib/api-key-resolver.js +336 -0
- package/dist/lib/api-key-resolver.js.map +1 -0
- package/dist/lib/atomic-json.d.ts +11 -0
- package/dist/lib/atomic-json.d.ts.map +1 -0
- package/dist/lib/atomic-json.js +64 -0
- package/dist/lib/atomic-json.js.map +1 -0
- package/dist/lib/chutes-config.d.ts +15 -0
- package/dist/lib/chutes-config.d.ts.map +1 -0
- package/dist/lib/chutes-config.js +28 -0
- package/dist/lib/chutes-config.js.map +1 -0
- package/dist/lib/chutes.d.ts +12 -0
- package/dist/lib/chutes.d.ts.map +1 -0
- package/dist/lib/chutes.js +60 -0
- package/dist/lib/chutes.js.map +1 -0
- package/dist/lib/cli-reports.d.ts +30 -0
- package/dist/lib/cli-reports.d.ts.map +1 -0
- package/dist/lib/cli-reports.js +172 -0
- package/dist/lib/cli-reports.js.map +1 -0
- package/dist/lib/cli-show.d.ts +30 -0
- package/dist/lib/cli-show.d.ts.map +1 -0
- package/dist/lib/cli-show.js +213 -0
- package/dist/lib/cli-show.js.map +1 -0
- package/dist/lib/cli-status.d.ts +8 -0
- package/dist/lib/cli-status.d.ts.map +1 -0
- package/dist/lib/cli-status.js +98 -0
- package/dist/lib/cli-status.js.map +1 -0
- package/dist/lib/command-parsing.d.ts +43 -0
- package/dist/lib/command-parsing.d.ts.map +1 -0
- package/dist/lib/command-parsing.js +103 -0
- package/dist/lib/command-parsing.js.map +1 -0
- package/dist/lib/config-file-utils.d.ts +46 -0
- package/dist/lib/config-file-utils.d.ts.map +1 -0
- package/dist/lib/config-file-utils.js +194 -0
- package/dist/lib/config-file-utils.js.map +1 -0
- package/dist/lib/config-write-target.d.ts +28 -0
- package/dist/lib/config-write-target.d.ts.map +1 -0
- package/dist/lib/config-write-target.js +159 -0
- package/dist/lib/config-write-target.js.map +1 -0
- package/dist/lib/config.d.ts +119 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +1327 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/copilot.d.ts +78 -0
- package/dist/lib/copilot.d.ts.map +1 -0
- package/dist/lib/copilot.js +1111 -0
- package/dist/lib/copilot.js.map +1 -0
- package/dist/lib/cursor-detection.d.ts +18 -0
- package/dist/lib/cursor-detection.d.ts.map +1 -0
- package/dist/lib/cursor-detection.js +189 -0
- package/dist/lib/cursor-detection.js.map +1 -0
- package/dist/lib/cursor-pricing.d.ts +34 -0
- package/dist/lib/cursor-pricing.d.ts.map +1 -0
- package/dist/lib/cursor-pricing.js +235 -0
- package/dist/lib/cursor-pricing.js.map +1 -0
- package/dist/lib/cursor-usage.d.ts +33 -0
- package/dist/lib/cursor-usage.d.ts.map +1 -0
- package/dist/lib/cursor-usage.js +109 -0
- package/dist/lib/cursor-usage.js.map +1 -0
- package/dist/lib/deepseek-auth.d.ts +15 -0
- package/dist/lib/deepseek-auth.d.ts.map +1 -0
- package/dist/lib/deepseek-auth.js +28 -0
- package/dist/lib/deepseek-auth.js.map +1 -0
- package/dist/lib/deepseek.d.ts +40 -0
- package/dist/lib/deepseek.d.ts.map +1 -0
- package/dist/lib/deepseek.js +118 -0
- package/dist/lib/deepseek.js.map +1 -0
- package/dist/lib/display-sanitize.d.ts +20 -0
- package/dist/lib/display-sanitize.d.ts.map +1 -0
- package/dist/lib/display-sanitize.js +178 -0
- package/dist/lib/display-sanitize.js.map +1 -0
- package/dist/lib/entries.d.ts +365 -0
- package/dist/lib/entries.d.ts.map +1 -0
- package/dist/lib/entries.js +69 -0
- package/dist/lib/entries.js.map +1 -0
- package/dist/lib/env-template.d.ts +26 -0
- package/dist/lib/env-template.d.ts.map +1 -0
- package/dist/lib/env-template.js +36 -0
- package/dist/lib/env-template.js.map +1 -0
- package/dist/lib/format-utils.d.ts +89 -0
- package/dist/lib/format-utils.d.ts.map +1 -0
- package/dist/lib/format-utils.js +206 -0
- package/dist/lib/format-utils.js.map +1 -0
- package/dist/lib/format.d.ts +25 -0
- package/dist/lib/format.d.ts.map +1 -0
- package/dist/lib/format.js +300 -0
- package/dist/lib/format.js.map +1 -0
- package/dist/lib/glm-coding-plan.d.ts +19 -0
- package/dist/lib/glm-coding-plan.d.ts.map +1 -0
- package/dist/lib/glm-coding-plan.js +81 -0
- package/dist/lib/glm-coding-plan.js.map +1 -0
- package/dist/lib/google-agy-companion.d.ts +8 -0
- package/dist/lib/google-agy-companion.d.ts.map +1 -0
- package/dist/lib/google-agy-companion.js +64 -0
- package/dist/lib/google-agy-companion.js.map +1 -0
- package/dist/lib/google-agy.d.ts +48 -0
- package/dist/lib/google-agy.d.ts.map +1 -0
- package/dist/lib/google-agy.js +572 -0
- package/dist/lib/google-agy.js.map +1 -0
- package/dist/lib/google-companion-credentials.d.ts +70 -0
- package/dist/lib/google-companion-credentials.d.ts.map +1 -0
- package/dist/lib/google-companion-credentials.js +315 -0
- package/dist/lib/google-companion-credentials.js.map +1 -0
- package/dist/lib/google-gemini-cli-companion.d.ts +8 -0
- package/dist/lib/google-gemini-cli-companion.d.ts.map +1 -0
- package/dist/lib/google-gemini-cli-companion.js +64 -0
- package/dist/lib/google-gemini-cli-companion.js.map +1 -0
- package/dist/lib/google-gemini-cli.d.ts +47 -0
- package/dist/lib/google-gemini-cli.d.ts.map +1 -0
- package/dist/lib/google-gemini-cli.js +481 -0
- package/dist/lib/google-gemini-cli.js.map +1 -0
- package/dist/lib/google-token-cache.d.ts +27 -0
- package/dist/lib/google-token-cache.d.ts.map +1 -0
- package/dist/lib/google-token-cache.js +52 -0
- package/dist/lib/google-token-cache.js.map +1 -0
- package/dist/lib/grouped-entry-normalization.d.ts +12 -0
- package/dist/lib/grouped-entry-normalization.d.ts.map +1 -0
- package/dist/lib/grouped-entry-normalization.js +124 -0
- package/dist/lib/grouped-entry-normalization.js.map +1 -0
- package/dist/lib/grouped-header-format.d.ts +5 -0
- package/dist/lib/grouped-header-format.d.ts.map +1 -0
- package/dist/lib/grouped-header-format.js +16 -0
- package/dist/lib/grouped-header-format.js.map +1 -0
- package/dist/lib/gui-config-target.d.ts +12 -0
- package/dist/lib/gui-config-target.d.ts.map +1 -0
- package/dist/lib/gui-config-target.js +88 -0
- package/dist/lib/gui-config-target.js.map +1 -0
- package/dist/lib/home-dir-display.d.ts +10 -0
- package/dist/lib/home-dir-display.d.ts.map +1 -0
- package/dist/lib/home-dir-display.js +108 -0
- package/dist/lib/home-dir-display.js.map +1 -0
- package/dist/lib/http.d.ts +19 -0
- package/dist/lib/http.d.ts.map +1 -0
- package/dist/lib/http.js +47 -0
- package/dist/lib/http.js.map +1 -0
- package/dist/lib/init-installer.d.ts +146 -0
- package/dist/lib/init-installer.d.ts.map +1 -0
- package/dist/lib/init-installer.js +1056 -0
- package/dist/lib/init-installer.js.map +1 -0
- package/dist/lib/jsonc.d.ts +17 -0
- package/dist/lib/jsonc.d.ts.map +1 -0
- package/dist/lib/jsonc.js +23 -0
- package/dist/lib/jsonc.js.map +1 -0
- package/dist/lib/kilo-config.d.ts +15 -0
- package/dist/lib/kilo-config.d.ts.map +1 -0
- package/dist/lib/kilo-config.js +27 -0
- package/dist/lib/kilo-config.js.map +1 -0
- package/dist/lib/kilo.d.ts +32 -0
- package/dist/lib/kilo.d.ts.map +1 -0
- package/dist/lib/kilo.js +265 -0
- package/dist/lib/kilo.js.map +1 -0
- package/dist/lib/kimi-auth.d.ts +49 -0
- package/dist/lib/kimi-auth.d.ts.map +1 -0
- package/dist/lib/kimi-auth.js +82 -0
- package/dist/lib/kimi-auth.js.map +1 -0
- package/dist/lib/kimi-endpoints.d.ts +10 -0
- package/dist/lib/kimi-endpoints.d.ts.map +1 -0
- package/dist/lib/kimi-endpoints.js +18 -0
- package/dist/lib/kimi-endpoints.js.map +1 -0
- package/dist/lib/kimi.d.ts +26 -0
- package/dist/lib/kimi.d.ts.map +1 -0
- package/dist/lib/kimi.js +230 -0
- package/dist/lib/kimi.js.map +1 -0
- package/dist/lib/maintainer-announcements.d.ts +46 -0
- package/dist/lib/maintainer-announcements.d.ts.map +1 -0
- package/dist/lib/maintainer-announcements.js +155 -0
- package/dist/lib/maintainer-announcements.js.map +1 -0
- package/dist/lib/map-with-concurrency.d.ts +2 -0
- package/dist/lib/map-with-concurrency.d.ts.map +1 -0
- package/dist/lib/map-with-concurrency.js +17 -0
- package/dist/lib/map-with-concurrency.js.map +1 -0
- package/dist/lib/markdown-table.d.ts +51 -0
- package/dist/lib/markdown-table.d.ts.map +1 -0
- package/dist/lib/markdown-table.js +179 -0
- package/dist/lib/markdown-table.js.map +1 -0
- package/dist/lib/mimo-config.d.ts +29 -0
- package/dist/lib/mimo-config.d.ts.map +1 -0
- package/dist/lib/mimo-config.js +146 -0
- package/dist/lib/mimo-config.js.map +1 -0
- package/dist/lib/mimo.d.ts +35 -0
- package/dist/lib/mimo.d.ts.map +1 -0
- package/dist/lib/mimo.js +236 -0
- package/dist/lib/mimo.js.map +1 -0
- package/dist/lib/minimax-auth.d.ts +62 -0
- package/dist/lib/minimax-auth.d.ts.map +1 -0
- package/dist/lib/minimax-auth.js +206 -0
- package/dist/lib/minimax-auth.js.map +1 -0
- package/dist/lib/minimax-endpoints.d.ts +10 -0
- package/dist/lib/minimax-endpoints.d.ts.map +1 -0
- package/dist/lib/minimax-endpoints.js +19 -0
- package/dist/lib/minimax-endpoints.js.map +1 -0
- package/dist/lib/modelsdev-pricing.d.ts +93 -0
- package/dist/lib/modelsdev-pricing.d.ts.map +1 -0
- package/dist/lib/modelsdev-pricing.js +674 -0
- package/dist/lib/modelsdev-pricing.js.map +1 -0
- package/dist/lib/nanogpt-config.d.ts +15 -0
- package/dist/lib/nanogpt-config.d.ts.map +1 -0
- package/dist/lib/nanogpt-config.js +31 -0
- package/dist/lib/nanogpt-config.js.map +1 -0
- package/dist/lib/nanogpt.d.ts +48 -0
- package/dist/lib/nanogpt.d.ts.map +1 -0
- package/dist/lib/nanogpt.js +251 -0
- package/dist/lib/nanogpt.js.map +1 -0
- package/dist/lib/ollama-cloud-config.d.ts +15 -0
- package/dist/lib/ollama-cloud-config.d.ts.map +1 -0
- package/dist/lib/ollama-cloud-config.js +27 -0
- package/dist/lib/ollama-cloud-config.js.map +1 -0
- package/dist/lib/ollama-cloud.d.ts +14 -0
- package/dist/lib/ollama-cloud.d.ts.map +1 -0
- package/dist/lib/ollama-cloud.js +186 -0
- package/dist/lib/ollama-cloud.js.map +1 -0
- package/dist/lib/openai.d.ts +68 -0
- package/dist/lib/openai.d.ts.map +1 -0
- package/dist/lib/openai.js +394 -0
- package/dist/lib/openai.js.map +1 -0
- package/dist/lib/opencode-auth-sqlite.d.ts +17 -0
- package/dist/lib/opencode-auth-sqlite.d.ts.map +1 -0
- package/dist/lib/opencode-auth-sqlite.js +105 -0
- package/dist/lib/opencode-auth-sqlite.js.map +1 -0
- package/dist/lib/opencode-auth.d.ts +146 -0
- package/dist/lib/opencode-auth.d.ts.map +1 -0
- package/dist/lib/opencode-auth.js +465 -0
- package/dist/lib/opencode-auth.js.map +1 -0
- package/dist/lib/opencode-config-editor.d.ts +62 -0
- package/dist/lib/opencode-config-editor.d.ts.map +1 -0
- package/dist/lib/opencode-config-editor.js +387 -0
- package/dist/lib/opencode-config-editor.js.map +1 -0
- package/dist/lib/opencode-config-providers.d.ts +24 -0
- package/dist/lib/opencode-config-providers.d.ts.map +1 -0
- package/dist/lib/opencode-config-providers.js +144 -0
- package/dist/lib/opencode-config-providers.js.map +1 -0
- package/dist/lib/opencode-config-read.d.ts +23 -0
- package/dist/lib/opencode-config-read.d.ts.map +1 -0
- package/dist/lib/opencode-config-read.js +30 -0
- package/dist/lib/opencode-config-read.js.map +1 -0
- package/dist/lib/opencode-console-auth.d.ts +47 -0
- package/dist/lib/opencode-console-auth.d.ts.map +1 -0
- package/dist/lib/opencode-console-auth.js +63 -0
- package/dist/lib/opencode-console-auth.js.map +1 -0
- package/dist/lib/opencode-db-path.d.ts +9 -0
- package/dist/lib/opencode-db-path.d.ts.map +1 -0
- package/dist/lib/opencode-db-path.js +16 -0
- package/dist/lib/opencode-db-path.js.map +1 -0
- package/dist/lib/opencode-go-auth.d.ts +16 -0
- package/dist/lib/opencode-go-auth.d.ts.map +1 -0
- package/dist/lib/opencode-go-auth.js +42 -0
- package/dist/lib/opencode-go-auth.js.map +1 -0
- package/dist/lib/opencode-go.d.ts +17 -0
- package/dist/lib/opencode-go.d.ts.map +1 -0
- package/dist/lib/opencode-go.js +278 -0
- package/dist/lib/opencode-go.js.map +1 -0
- package/dist/lib/opencode-runtime-paths.d.ts +17 -0
- package/dist/lib/opencode-runtime-paths.d.ts.map +1 -0
- package/dist/lib/opencode-runtime-paths.js +24 -0
- package/dist/lib/opencode-runtime-paths.js.map +1 -0
- package/dist/lib/opencode-sqlite.d.ts +11 -0
- package/dist/lib/opencode-sqlite.d.ts.map +1 -0
- package/dist/lib/opencode-sqlite.js +88 -0
- package/dist/lib/opencode-sqlite.js.map +1 -0
- package/dist/lib/opencode-storage.d.ts +306 -0
- package/dist/lib/opencode-storage.d.ts.map +1 -0
- package/dist/lib/opencode-storage.js +1269 -0
- package/dist/lib/opencode-storage.js.map +1 -0
- package/dist/lib/opencode-version.d.ts +6 -0
- package/dist/lib/opencode-version.d.ts.map +1 -0
- package/dist/lib/opencode-version.js +26 -0
- package/dist/lib/opencode-version.js.map +1 -0
- package/dist/lib/opencode-zen.d.ts +55 -0
- package/dist/lib/opencode-zen.d.ts.map +1 -0
- package/dist/lib/opencode-zen.js +348 -0
- package/dist/lib/opencode-zen.js.map +1 -0
- package/dist/lib/openrouter.d.ts +16 -0
- package/dist/lib/openrouter.d.ts.map +1 -0
- package/dist/lib/openrouter.js +50 -0
- package/dist/lib/openrouter.js.map +1 -0
- package/dist/lib/private-state-paths.d.ts +10 -0
- package/dist/lib/private-state-paths.d.ts.map +1 -0
- package/dist/lib/private-state-paths.js +28 -0
- package/dist/lib/private-state-paths.js.map +1 -0
- package/dist/lib/provider-add-command.d.ts +35 -0
- package/dist/lib/provider-add-command.d.ts.map +1 -0
- package/dist/lib/provider-add-command.js +204 -0
- package/dist/lib/provider-add-command.js.map +1 -0
- package/dist/lib/provider-add-json-v1-questionnaire.d.ts +32 -0
- package/dist/lib/provider-add-json-v1-questionnaire.d.ts.map +1 -0
- package/dist/lib/provider-add-json-v1-questionnaire.js +336 -0
- package/dist/lib/provider-add-json-v1-questionnaire.js.map +1 -0
- package/dist/lib/provider-add.d.ts +21 -0
- package/dist/lib/provider-add.d.ts.map +1 -0
- package/dist/lib/provider-add.js +219 -0
- package/dist/lib/provider-add.js.map +1 -0
- package/dist/lib/provider-availability.d.ts +13 -0
- package/dist/lib/provider-availability.d.ts.map +1 -0
- package/dist/lib/provider-availability.js +20 -0
- package/dist/lib/provider-availability.js.map +1 -0
- package/dist/lib/provider-metadata.d.ts +32 -0
- package/dist/lib/provider-metadata.d.ts.map +1 -0
- package/dist/lib/provider-metadata.js +90 -0
- package/dist/lib/provider-metadata.js.map +1 -0
- package/dist/lib/provider-model-matching.d.ts +12 -0
- package/dist/lib/provider-model-matching.d.ts.map +1 -0
- package/dist/lib/provider-model-matching.js +23 -0
- package/dist/lib/provider-model-matching.js.map +1 -0
- package/dist/lib/provider-registration.d.ts +321 -0
- package/dist/lib/provider-registration.d.ts.map +1 -0
- package/dist/lib/provider-registration.js +335 -0
- package/dist/lib/provider-registration.js.map +1 -0
- package/dist/lib/quota-accounting-projection.d.ts +9 -0
- package/dist/lib/quota-accounting-projection.d.ts.map +1 -0
- package/dist/lib/quota-accounting-projection.js +254 -0
- package/dist/lib/quota-accounting-projection.js.map +1 -0
- package/dist/lib/quota-columns.d.ts +38 -0
- package/dist/lib/quota-columns.d.ts.map +1 -0
- package/dist/lib/quota-columns.js +129 -0
- package/dist/lib/quota-columns.js.map +1 -0
- package/dist/lib/quota-command-format.d.ts +34 -0
- package/dist/lib/quota-command-format.d.ts.map +1 -0
- package/dist/lib/quota-command-format.js +240 -0
- package/dist/lib/quota-command-format.js.map +1 -0
- package/dist/lib/quota-dialog-command-specs.d.ts +63 -0
- package/dist/lib/quota-dialog-command-specs.d.ts.map +1 -0
- package/dist/lib/quota-dialog-command-specs.js +145 -0
- package/dist/lib/quota-dialog-command-specs.js.map +1 -0
- package/dist/lib/quota-dialog-commands.d.ts +75 -0
- package/dist/lib/quota-dialog-commands.d.ts.map +1 -0
- package/dist/lib/quota-dialog-commands.js +586 -0
- package/dist/lib/quota-dialog-commands.js.map +1 -0
- package/dist/lib/quota-entry-display.d.ts +7 -0
- package/dist/lib/quota-entry-display.d.ts.map +1 -0
- package/dist/lib/quota-entry-display.js +59 -0
- package/dist/lib/quota-entry-display.js.map +1 -0
- package/dist/lib/quota-exhaustion-projection.d.ts +11 -0
- package/dist/lib/quota-exhaustion-projection.d.ts.map +1 -0
- package/dist/lib/quota-exhaustion-projection.js +105 -0
- package/dist/lib/quota-exhaustion-projection.js.map +1 -0
- package/dist/lib/quota-export-types.d.ts +96 -0
- package/dist/lib/quota-export-types.d.ts.map +1 -0
- package/dist/lib/quota-export-types.js +2 -0
- package/dist/lib/quota-export-types.js.map +1 -0
- package/dist/lib/quota-export.d.ts +44 -0
- package/dist/lib/quota-export.d.ts.map +1 -0
- package/dist/lib/quota-export.js +221 -0
- package/dist/lib/quota-export.js.map +1 -0
- package/dist/lib/quota-format-style.d.ts +21 -0
- package/dist/lib/quota-format-style.d.ts.map +1 -0
- package/dist/lib/quota-format-style.js +38 -0
- package/dist/lib/quota-format-style.js.map +1 -0
- package/dist/lib/quota-providers-local.d.ts +55 -0
- package/dist/lib/quota-providers-local.d.ts.map +1 -0
- package/dist/lib/quota-providers-local.js +327 -0
- package/dist/lib/quota-providers-local.js.map +1 -0
- package/dist/lib/quota-providers-remote.d.ts +27 -0
- package/dist/lib/quota-providers-remote.d.ts.map +1 -0
- package/dist/lib/quota-providers-remote.js +678 -0
- package/dist/lib/quota-providers-remote.js.map +1 -0
- package/dist/lib/quota-providers.d.ts +158 -0
- package/dist/lib/quota-providers.d.ts.map +1 -0
- package/dist/lib/quota-providers.js +1160 -0
- package/dist/lib/quota-providers.js.map +1 -0
- package/dist/lib/quota-render-data.d.ts +135 -0
- package/dist/lib/quota-render-data.d.ts.map +1 -0
- package/dist/lib/quota-render-data.js +462 -0
- package/dist/lib/quota-render-data.js.map +1 -0
- package/dist/lib/quota-report-message.d.ts +22 -0
- package/dist/lib/quota-report-message.d.ts.map +1 -0
- package/dist/lib/quota-report-message.js +36 -0
- package/dist/lib/quota-report-message.js.map +1 -0
- package/dist/lib/quota-reset-notifications.d.ts +20 -0
- package/dist/lib/quota-reset-notifications.d.ts.map +1 -0
- package/dist/lib/quota-reset-notifications.js +331 -0
- package/dist/lib/quota-reset-notifications.js.map +1 -0
- package/dist/lib/quota-retry-wait.d.ts +36 -0
- package/dist/lib/quota-retry-wait.d.ts.map +1 -0
- package/dist/lib/quota-retry-wait.js +67 -0
- package/dist/lib/quota-retry-wait.js.map +1 -0
- package/dist/lib/quota-runtime-context.d.ts +56 -0
- package/dist/lib/quota-runtime-context.d.ts.map +1 -0
- package/dist/lib/quota-runtime-context.js +113 -0
- package/dist/lib/quota-runtime-context.js.map +1 -0
- package/dist/lib/quota-state-codec.d.ts +16 -0
- package/dist/lib/quota-state-codec.d.ts.map +1 -0
- package/dist/lib/quota-state-codec.js +475 -0
- package/dist/lib/quota-state-codec.js.map +1 -0
- package/dist/lib/quota-state.d.ts +28 -0
- package/dist/lib/quota-state.d.ts.map +1 -0
- package/dist/lib/quota-state.js +473 -0
- package/dist/lib/quota-state.js.map +1 -0
- package/dist/lib/quota-stats-format.d.ts +29 -0
- package/dist/lib/quota-stats-format.d.ts.map +1 -0
- package/dist/lib/quota-stats-format.js +459 -0
- package/dist/lib/quota-stats-format.js.map +1 -0
- package/dist/lib/quota-stats.d.ts +174 -0
- package/dist/lib/quota-stats.d.ts.map +1 -0
- package/dist/lib/quota-stats.js +713 -0
- package/dist/lib/quota-stats.js.map +1 -0
- package/dist/lib/quota-status.d.ts +58 -0
- package/dist/lib/quota-status.d.ts.map +1 -0
- package/dist/lib/quota-status.js +865 -0
- package/dist/lib/quota-status.js.map +1 -0
- package/dist/lib/quota-surface-data.d.ts +21 -0
- package/dist/lib/quota-surface-data.d.ts.map +1 -0
- package/dist/lib/quota-surface-data.js +361 -0
- package/dist/lib/quota-surface-data.js.map +1 -0
- package/dist/lib/quota-telemetry.d.ts +45 -0
- package/dist/lib/quota-telemetry.d.ts.map +1 -0
- package/dist/lib/quota-telemetry.js +304 -0
- package/dist/lib/quota-telemetry.js.map +1 -0
- package/dist/lib/report-document.d.ts +90 -0
- package/dist/lib/report-document.d.ts.map +1 -0
- package/dist/lib/report-document.js +190 -0
- package/dist/lib/report-document.js.map +1 -0
- package/dist/lib/resolved-auth-identity.d.ts +36 -0
- package/dist/lib/resolved-auth-identity.d.ts.map +1 -0
- package/dist/lib/resolved-auth-identity.js +192 -0
- package/dist/lib/resolved-auth-identity.js.map +1 -0
- package/dist/lib/runtime-provider-ids.d.ts +4 -0
- package/dist/lib/runtime-provider-ids.d.ts.map +1 -0
- package/dist/lib/runtime-provider-ids.js +10 -0
- package/dist/lib/runtime-provider-ids.js.map +1 -0
- package/dist/lib/scoped-update-migration.d.ts +103 -0
- package/dist/lib/scoped-update-migration.d.ts.map +1 -0
- package/dist/lib/scoped-update-migration.js +348 -0
- package/dist/lib/scoped-update-migration.js.map +1 -0
- package/dist/lib/scoped-update.d.ts +78 -0
- package/dist/lib/scoped-update.d.ts.map +1 -0
- package/dist/lib/scoped-update.js +640 -0
- package/dist/lib/scoped-update.js.map +1 -0
- package/dist/lib/session-tokens-format.d.ts +36 -0
- package/dist/lib/session-tokens-format.d.ts.map +1 -0
- package/dist/lib/session-tokens-format.js +111 -0
- package/dist/lib/session-tokens-format.js.map +1 -0
- package/dist/lib/session-tokens.d.ts +27 -0
- package/dist/lib/session-tokens.d.ts.map +1 -0
- package/dist/lib/session-tokens.js +55 -0
- package/dist/lib/session-tokens.js.map +1 -0
- package/dist/lib/synthetic-config.d.ts +15 -0
- package/dist/lib/synthetic-config.d.ts.map +1 -0
- package/dist/lib/synthetic-config.js +28 -0
- package/dist/lib/synthetic-config.js.map +1 -0
- package/dist/lib/synthetic.d.ts +12 -0
- package/dist/lib/synthetic.d.ts.map +1 -0
- package/dist/lib/synthetic.js +173 -0
- package/dist/lib/synthetic.js.map +1 -0
- package/dist/lib/toast-format-grouped.d.ts +25 -0
- package/dist/lib/toast-format-grouped.d.ts.map +1 -0
- package/dist/lib/toast-format-grouped.js +296 -0
- package/dist/lib/toast-format-grouped.js.map +1 -0
- package/dist/lib/token-buckets.d.ts +24 -0
- package/dist/lib/token-buckets.d.ts.map +1 -0
- package/dist/lib/token-buckets.js +28 -0
- package/dist/lib/token-buckets.js.map +1 -0
- package/dist/lib/token-cost.d.ts +10 -0
- package/dist/lib/token-cost.d.ts.map +1 -0
- package/dist/lib/token-cost.js +16 -0
- package/dist/lib/token-cost.js.map +1 -0
- package/dist/lib/tui-compact-format.d.ts +10 -0
- package/dist/lib/tui-compact-format.d.ts.map +1 -0
- package/dist/lib/tui-compact-format.js +460 -0
- package/dist/lib/tui-compact-format.js.map +1 -0
- package/dist/lib/tui-panel-state.d.ts +15 -0
- package/dist/lib/tui-panel-state.d.ts.map +1 -0
- package/dist/lib/tui-panel-state.js +2 -0
- package/dist/lib/tui-panel-state.js.map +1 -0
- package/dist/lib/tui-prompt-bar-format.d.ts +25 -0
- package/dist/lib/tui-prompt-bar-format.d.ts.map +1 -0
- package/dist/lib/tui-prompt-bar-format.js +206 -0
- package/dist/lib/tui-prompt-bar-format.js.map +1 -0
- package/dist/lib/tui-sidebar-format.d.ts +13 -0
- package/dist/lib/tui-sidebar-format.d.ts.map +1 -0
- package/dist/lib/tui-sidebar-format.js +34 -0
- package/dist/lib/tui-sidebar-format.js.map +1 -0
- package/dist/lib/types.d.ts +724 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +83 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/usage-ownership.d.ts +47 -0
- package/dist/lib/usage-ownership.d.ts.map +1 -0
- package/dist/lib/usage-ownership.js +98 -0
- package/dist/lib/usage-ownership.js.map +1 -0
- package/dist/lib/version.d.ts +2 -0
- package/dist/lib/version.d.ts.map +1 -0
- package/dist/lib/version.js +33 -0
- package/dist/lib/version.js.map +1 -0
- package/dist/lib/xai.d.ts +52 -0
- package/dist/lib/xai.d.ts.map +1 -0
- package/dist/lib/xai.js +253 -0
- package/dist/lib/xai.js.map +1 -0
- package/dist/lib/zai-auth.d.ts +15 -0
- package/dist/lib/zai-auth.d.ts.map +1 -0
- package/dist/lib/zai-auth.js +37 -0
- package/dist/lib/zai-auth.js.map +1 -0
- package/dist/lib/zai.d.ts +5 -0
- package/dist/lib/zai.d.ts.map +1 -0
- package/dist/lib/zai.js +14 -0
- package/dist/lib/zai.js.map +1 -0
- package/dist/lib/zhipu-auth.d.ts +15 -0
- package/dist/lib/zhipu-auth.d.ts.map +1 -0
- package/dist/lib/zhipu-auth.js +42 -0
- package/dist/lib/zhipu-auth.js.map +1 -0
- package/dist/lib/zhipu.d.ts +5 -0
- package/dist/lib/zhipu.d.ts.map +1 -0
- package/dist/lib/zhipu.js +13 -0
- package/dist/lib/zhipu.js.map +1 -0
- package/dist/plugin.d.ts +10 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +95 -0
- package/dist/plugin.js.map +1 -0
- package/dist/providers/accounting-decimal.d.ts +2 -0
- package/dist/providers/accounting-decimal.d.ts.map +1 -0
- package/dist/providers/accounting-decimal.js +23 -0
- package/dist/providers/accounting-decimal.js.map +1 -0
- package/dist/providers/alibaba-coding-plan.d.ts +3 -0
- package/dist/providers/alibaba-coding-plan.d.ts.map +1 -0
- package/dist/providers/alibaba-coding-plan.js +122 -0
- package/dist/providers/alibaba-coding-plan.js.map +1 -0
- package/dist/providers/alibaba-token-plan.d.ts +3 -0
- package/dist/providers/alibaba-token-plan.d.ts.map +1 -0
- package/dist/providers/alibaba-token-plan.js +90 -0
- package/dist/providers/alibaba-token-plan.js.map +1 -0
- package/dist/providers/anthropic.d.ts +9 -0
- package/dist/providers/anthropic.d.ts.map +1 -0
- package/dist/providers/anthropic.js +236 -0
- package/dist/providers/anthropic.js.map +1 -0
- package/dist/providers/cache-policies.d.ts +61 -0
- package/dist/providers/cache-policies.d.ts.map +1 -0
- package/dist/providers/cache-policies.js +210 -0
- package/dist/providers/cache-policies.js.map +1 -0
- package/dist/providers/chutes.d.ts +6 -0
- package/dist/providers/chutes.d.ts.map +1 -0
- package/dist/providers/chutes.js +50 -0
- package/dist/providers/chutes.js.map +1 -0
- package/dist/providers/copilot.d.ts +9 -0
- package/dist/providers/copilot.d.ts.map +1 -0
- package/dist/providers/copilot.js +323 -0
- package/dist/providers/copilot.js.map +1 -0
- package/dist/providers/cursor.d.ts +3 -0
- package/dist/providers/cursor.d.ts.map +1 -0
- package/dist/providers/cursor.js +182 -0
- package/dist/providers/cursor.js.map +1 -0
- package/dist/providers/deepseek.d.ts +9 -0
- package/dist/providers/deepseek.d.ts.map +1 -0
- package/dist/providers/deepseek.js +111 -0
- package/dist/providers/deepseek.js.map +1 -0
- package/dist/providers/glm-coding-plan-provider.d.ts +56 -0
- package/dist/providers/glm-coding-plan-provider.d.ts.map +1 -0
- package/dist/providers/glm-coding-plan-provider.js +146 -0
- package/dist/providers/glm-coding-plan-provider.js.map +1 -0
- package/dist/providers/google-account-format.d.ts +7 -0
- package/dist/providers/google-account-format.d.ts.map +1 -0
- package/dist/providers/google-account-format.js +52 -0
- package/dist/providers/google-account-format.js.map +1 -0
- package/dist/providers/google-agy.d.ts +17 -0
- package/dist/providers/google-agy.d.ts.map +1 -0
- package/dist/providers/google-agy.js +256 -0
- package/dist/providers/google-agy.js.map +1 -0
- package/dist/providers/google-gemini-cli.d.ts +17 -0
- package/dist/providers/google-gemini-cli.d.ts.map +1 -0
- package/dist/providers/google-gemini-cli.js +228 -0
- package/dist/providers/google-gemini-cli.js.map +1 -0
- package/dist/providers/kilo.d.ts +6 -0
- package/dist/providers/kilo.d.ts.map +1 -0
- package/dist/providers/kilo.js +145 -0
- package/dist/providers/kilo.js.map +1 -0
- package/dist/providers/kimi-code.d.ts +4 -0
- package/dist/providers/kimi-code.d.ts.map +1 -0
- package/dist/providers/kimi-code.js +175 -0
- package/dist/providers/kimi-code.js.map +1 -0
- package/dist/providers/mimo.d.ts +3 -0
- package/dist/providers/mimo.d.ts.map +1 -0
- package/dist/providers/mimo.js +149 -0
- package/dist/providers/mimo.js.map +1 -0
- package/dist/providers/minimax-coding-plan.d.ts +26 -0
- package/dist/providers/minimax-coding-plan.d.ts.map +1 -0
- package/dist/providers/minimax-coding-plan.js +391 -0
- package/dist/providers/minimax-coding-plan.js.map +1 -0
- package/dist/providers/nanogpt.d.ts +6 -0
- package/dist/providers/nanogpt.d.ts.map +1 -0
- package/dist/providers/nanogpt.js +160 -0
- package/dist/providers/nanogpt.js.map +1 -0
- package/dist/providers/ollama-cloud.d.ts +9 -0
- package/dist/providers/ollama-cloud.d.ts.map +1 -0
- package/dist/providers/ollama-cloud.js +129 -0
- package/dist/providers/ollama-cloud.js.map +1 -0
- package/dist/providers/openai.d.ts +6 -0
- package/dist/providers/openai.d.ts.map +1 -0
- package/dist/providers/openai.js +313 -0
- package/dist/providers/openai.js.map +1 -0
- package/dist/providers/opencode-go.d.ts +4 -0
- package/dist/providers/opencode-go.d.ts.map +1 -0
- package/dist/providers/opencode-go.js +294 -0
- package/dist/providers/opencode-go.js.map +1 -0
- package/dist/providers/opencode-zen.d.ts +3 -0
- package/dist/providers/opencode-zen.d.ts.map +1 -0
- package/dist/providers/opencode-zen.js +221 -0
- package/dist/providers/opencode-zen.js.map +1 -0
- package/dist/providers/openrouter.d.ts +6 -0
- package/dist/providers/openrouter.d.ts.map +1 -0
- package/dist/providers/openrouter.js +32 -0
- package/dist/providers/openrouter.js.map +1 -0
- package/dist/providers/quota-providers.d.ts +6 -0
- package/dist/providers/quota-providers.d.ts.map +1 -0
- package/dist/providers/quota-providers.js +287 -0
- package/dist/providers/quota-providers.js.map +1 -0
- package/dist/providers/registry.d.ts +9 -0
- package/dist/providers/registry.d.ts.map +1 -0
- package/dist/providers/registry.js +71 -0
- package/dist/providers/registry.js.map +1 -0
- package/dist/providers/result-helpers.d.ts +61 -0
- package/dist/providers/result-helpers.d.ts.map +1 -0
- package/dist/providers/result-helpers.js +117 -0
- package/dist/providers/result-helpers.js.map +1 -0
- package/dist/providers/synthetic.d.ts +6 -0
- package/dist/providers/synthetic.d.ts.map +1 -0
- package/dist/providers/synthetic.js +79 -0
- package/dist/providers/synthetic.js.map +1 -0
- package/dist/providers/xai.d.ts +6 -0
- package/dist/providers/xai.d.ts.map +1 -0
- package/dist/providers/xai.js +122 -0
- package/dist/providers/xai.js.map +1 -0
- package/dist/providers/zai.d.ts +2 -0
- package/dist/providers/zai.d.ts.map +1 -0
- package/dist/providers/zai.js +24 -0
- package/dist/providers/zai.js.map +1 -0
- package/dist/providers/zhipu.d.ts +2 -0
- package/dist/providers/zhipu.d.ts.map +1 -0
- package/dist/providers/zhipu.js +21 -0
- package/dist/providers/zhipu.js.map +1 -0
- package/dist/rpc.d.ts +72 -0
- package/dist/rpc.d.ts.map +1 -0
- package/dist/rpc.js +77 -0
- package/dist/rpc.js.map +1 -0
- package/dist/ui/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/dist/ui/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/dist/ui/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/dist/ui/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/dist/ui/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/dist/ui/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/dist/ui/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/dist/ui/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/dist/ui/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/dist/ui/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/dist/ui/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/dist/ui/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/dist/ui/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/dist/ui/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/dist/ui/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/dist/ui/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/dist/ui/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/dist/ui/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/dist/ui/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/dist/ui/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/dist/ui/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/dist/ui/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/dist/ui/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/dist/ui/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/dist/ui/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/dist/ui/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/dist/ui/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/dist/ui/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/dist/ui/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/dist/ui/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/dist/ui/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/dist/ui/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/dist/ui/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/dist/ui/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/dist/ui/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/dist/ui/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/dist/ui/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/dist/ui/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/dist/ui/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/dist/ui/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/dist/ui/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/dist/ui/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/dist/ui/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/dist/ui/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/dist/ui/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/dist/ui/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/dist/ui/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/dist/ui/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/dist/ui/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/dist/ui/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/dist/ui/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/dist/ui/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/dist/ui/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/dist/ui/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/dist/ui/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/dist/ui/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/dist/ui/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/dist/ui/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/dist/ui/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/dist/ui/assets/index-BvKGj9wc.js +8 -0
- package/dist/ui/assets/index-wlxynmbV.css +1 -0
- package/dist/ui/index.html +13 -0
- package/package.json +123 -3
|
@@ -0,0 +1,1056 @@
|
|
|
1
|
+
import { existsSync } from "fs";
|
|
2
|
+
import { readFile } from "fs/promises";
|
|
3
|
+
import { basename, dirname, join, resolve } from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
import { getGuiConfigPath, getGuiConfigSiblingJsonPath, loadConfig } from "./config.js";
|
|
6
|
+
import { dedupeNonEmptyStrings, findGitWorktreeRoot, getPluginSpecFromEntry, resolveEditableConfigPath, } from "./config-file-utils.js";
|
|
7
|
+
import { writeConfiguredJsonAtomic } from "./config-write-target.js";
|
|
8
|
+
import { assertGuiConfigTargetIsIndependent } from "./gui-config-target.js";
|
|
9
|
+
import { parseJsonOrJsonc } from "./jsonc.js";
|
|
10
|
+
import { applyConfigDocumentEdit, planConfigDocumentEdit, validateConfigDocumentEdit, } from "./opencode-config-editor.js";
|
|
11
|
+
import { getOpencodeRuntimeDirs } from "./opencode-runtime-paths.js";
|
|
12
|
+
import { detectOpenCodeMajor } from "./opencode-version.js";
|
|
13
|
+
import { getQuotaProviderDisplayLabel, normalizeQuotaProviderId, QUOTA_PROVIDER_SHAPES, } from "./provider-metadata.js";
|
|
14
|
+
import { getQuotaFormatStyleLabel, isQuotaFormatStyle, resolveQuotaFormatStyle, } from "./quota-format-style.js";
|
|
15
|
+
import { QUOTA_PROVIDERS_AGGREGATE_ID } from "./quota-providers.js";
|
|
16
|
+
import { DEFAULT_DASHBOARD_PORT, } from "./types.js";
|
|
17
|
+
import { getPackageVersion } from "./version.js";
|
|
18
|
+
const OPENCODE_SCHEMA_URL = "https://opencode.ai/config.json";
|
|
19
|
+
const GITHUB_REPO_URL = "https://github.com/PVLPM/opencode-quota-gui";
|
|
20
|
+
const GITHUB_STAR_NOTE = `if this helps, stars are appreciated: ${GITHUB_REPO_URL}`;
|
|
21
|
+
export class InitInstallerError extends Error {
|
|
22
|
+
details;
|
|
23
|
+
constructor(message, details) {
|
|
24
|
+
super(message);
|
|
25
|
+
this.details = details;
|
|
26
|
+
this.name = "InitInstallerError";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/** The renamed package identity. Legacy `@slkiser/opencode-quota` installs stay recognized. */
|
|
30
|
+
export const QUOTA_PLUGIN_PACKAGE_NAME = "opencode-quota-gui";
|
|
31
|
+
/** Optional explicit pack/tarball (or other) spec for new installs; local development and tests. */
|
|
32
|
+
export const QUOTA_PLUGIN_SPEC_ENV = "OPENCODE_QUOTA_PLUGIN_SPEC";
|
|
33
|
+
/** A prerelease (version with `-`) installs from the npm `next` tag; a stable release from `latest`. */
|
|
34
|
+
export function getQuotaPluginSpecForVersion(version, packageName = QUOTA_PLUGIN_PACKAGE_NAME) {
|
|
35
|
+
return version.includes("-") ? `${packageName}@next` : `${packageName}@latest`;
|
|
36
|
+
}
|
|
37
|
+
function normalizePluginSpecText(spec) {
|
|
38
|
+
return spec.replace(/\\/g, "/").toLowerCase();
|
|
39
|
+
}
|
|
40
|
+
function isUpstreamQuotaPackageSpec(spec) {
|
|
41
|
+
return normalizePluginSpecText(spec).includes("@slkiser/opencode-quota");
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* True only for this package's own OpenCode plugin entry. Upstream
|
|
45
|
+
* `@slkiser/opencode-quota` entries are deliberately excluded so both products can be
|
|
46
|
+
* configured at once and GUI maintenance never rewrites the upstream entry.
|
|
47
|
+
*/
|
|
48
|
+
export async function isVerifiedGuiQuotaPluginSpec(spec, configDir) {
|
|
49
|
+
if (isUpstreamQuotaPackageSpec(spec))
|
|
50
|
+
return false;
|
|
51
|
+
if (/^opencode-quota-gui(?:@[^/\\\s]+)?$/.test(spec))
|
|
52
|
+
return true;
|
|
53
|
+
if (!/^(?:file:|\.{1,2}[/\\]|[/\\]|[A-Za-z]:[/\\])/.test(spec))
|
|
54
|
+
return false;
|
|
55
|
+
let path;
|
|
56
|
+
try {
|
|
57
|
+
path = spec.startsWith("file://")
|
|
58
|
+
? fileURLToPath(spec)
|
|
59
|
+
: resolve(configDir, spec.replace(/^file:/, ""));
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
const normalized = path.replace(/\\/g, "/");
|
|
65
|
+
if (/\/dist\//.test(normalized) && !normalized.endsWith("/dist/index.js"))
|
|
66
|
+
return false;
|
|
67
|
+
const packageDir = normalized.endsWith("/dist/index.js")
|
|
68
|
+
? dirname(dirname(path))
|
|
69
|
+
: normalized.endsWith("/server.ts")
|
|
70
|
+
? dirname(path)
|
|
71
|
+
: path;
|
|
72
|
+
try {
|
|
73
|
+
const manifest = JSON.parse(await readFile(join(packageDir, "package.json"), "utf8"));
|
|
74
|
+
return Boolean(manifest &&
|
|
75
|
+
typeof manifest === "object" &&
|
|
76
|
+
"name" in manifest &&
|
|
77
|
+
manifest.name === QUOTA_PLUGIN_PACKAGE_NAME);
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Resolves an explicit plugin spec (a local pack/tarball or the user's own package), or null when
|
|
85
|
+
* none is given. An explicit spec that points at the upstream `@slkiser/opencode-quota` package
|
|
86
|
+
* is refused.
|
|
87
|
+
*/
|
|
88
|
+
export function resolveExplicitQuotaPluginSpec(params) {
|
|
89
|
+
const env = params.env ?? process.env;
|
|
90
|
+
const raw = params.pluginSpec ?? env[QUOTA_PLUGIN_SPEC_ENV];
|
|
91
|
+
const spec = typeof raw === "string" ? raw.trim() : "";
|
|
92
|
+
if (!spec) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
if (isUpstreamQuotaPackageSpec(spec)) {
|
|
96
|
+
throw new InitInstallerError(`Refusing to install the upstream @slkiser/opencode-quota package; provide a local pack/tarball or an explicit spec for the ${QUOTA_PLUGIN_PACKAGE_NAME} package.`);
|
|
97
|
+
}
|
|
98
|
+
return spec;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Resolves the plugin spec new installs write: an explicit spec when provided, otherwise the
|
|
102
|
+
* canonical `opencode-quota-gui` npm tag for the running package version.
|
|
103
|
+
*/
|
|
104
|
+
async function resolveQuotaPluginSpec(params) {
|
|
105
|
+
const explicit = resolveExplicitQuotaPluginSpec(params);
|
|
106
|
+
if (explicit !== null) {
|
|
107
|
+
return explicit;
|
|
108
|
+
}
|
|
109
|
+
const version = await getPackageVersion();
|
|
110
|
+
if (!version) {
|
|
111
|
+
throw new InitInstallerError("Cannot read the OpenCode Quota package version.");
|
|
112
|
+
}
|
|
113
|
+
return getQuotaPluginSpecForVersion(version);
|
|
114
|
+
}
|
|
115
|
+
function isPlainObject(value) {
|
|
116
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
117
|
+
}
|
|
118
|
+
function hasOwnKey(value, key) {
|
|
119
|
+
return Object.hasOwn(value, key);
|
|
120
|
+
}
|
|
121
|
+
function jsonEqual(left, right) {
|
|
122
|
+
return JSON.stringify(left) === JSON.stringify(right);
|
|
123
|
+
}
|
|
124
|
+
function stableJsonStringify(value) {
|
|
125
|
+
if (Array.isArray(value)) {
|
|
126
|
+
return `[${value.map(stableJsonStringify).join(",")}]`;
|
|
127
|
+
}
|
|
128
|
+
if (isPlainObject(value)) {
|
|
129
|
+
return `{${Object.keys(value)
|
|
130
|
+
.sort()
|
|
131
|
+
.map((key) => `${JSON.stringify(key)}:${stableJsonStringify(value[key])}`)
|
|
132
|
+
.join(",")}}`;
|
|
133
|
+
}
|
|
134
|
+
return JSON.stringify(value) ?? "undefined";
|
|
135
|
+
}
|
|
136
|
+
function getPluginEntryOptionPayload(entry) {
|
|
137
|
+
if (typeof entry === "string")
|
|
138
|
+
return null;
|
|
139
|
+
if (Array.isArray(entry))
|
|
140
|
+
return entry.length > 1 ? entry.slice(1) : null;
|
|
141
|
+
if (!isPlainObject(entry))
|
|
142
|
+
return null;
|
|
143
|
+
const payload = Object.fromEntries(Object.entries(entry).filter(([key]) => key !== "package"));
|
|
144
|
+
const keys = Object.keys(payload);
|
|
145
|
+
if (keys.length === 0)
|
|
146
|
+
return null;
|
|
147
|
+
if (keys.length === 1 && keys[0] === "options")
|
|
148
|
+
return [payload.options];
|
|
149
|
+
return payload;
|
|
150
|
+
}
|
|
151
|
+
const QUOTA_UI_CHOICE_ORDER = ["sidebar", "toast", "compact_status", "none"];
|
|
152
|
+
function normalizeQuotaUiIntent(selections) {
|
|
153
|
+
const rawSelections = selections;
|
|
154
|
+
if (hasOwnKey(rawSelections, "tuiCompactStatus")) {
|
|
155
|
+
throw new InitInstallerError("Unsupported installer selection: tuiCompactStatus");
|
|
156
|
+
}
|
|
157
|
+
const quotaUi = rawSelections.quotaUi;
|
|
158
|
+
if (!Array.isArray(quotaUi)) {
|
|
159
|
+
throw new InitInstallerError("Quota UI selections must be an array.");
|
|
160
|
+
}
|
|
161
|
+
if (quotaUi.length === 0) {
|
|
162
|
+
throw new InitInstallerError("Quota UI selections must not be empty.");
|
|
163
|
+
}
|
|
164
|
+
const seen = new Set();
|
|
165
|
+
for (const rawChoice of quotaUi) {
|
|
166
|
+
if (typeof rawChoice !== "string" ||
|
|
167
|
+
!QUOTA_UI_CHOICE_ORDER.includes(rawChoice)) {
|
|
168
|
+
throw new InitInstallerError(`Unknown Quota UI option: ${String(rawChoice)}`);
|
|
169
|
+
}
|
|
170
|
+
seen.add(rawChoice);
|
|
171
|
+
}
|
|
172
|
+
if (seen.has("none") && seen.size > 1) {
|
|
173
|
+
throw new InitInstallerError("Manual commands only cannot be combined with automatic quota displays.");
|
|
174
|
+
}
|
|
175
|
+
const choices = QUOTA_UI_CHOICE_ORDER.filter((choice) => seen.has(choice));
|
|
176
|
+
const enableSidebarPanel = choices.includes("sidebar");
|
|
177
|
+
const enableCompactStatus = choices.includes("compact_status");
|
|
178
|
+
return {
|
|
179
|
+
choices,
|
|
180
|
+
enableToast: choices.includes("toast"),
|
|
181
|
+
enableSidebarPanel,
|
|
182
|
+
enableCompactStatus,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
function getProviderModeLabel(mode) {
|
|
186
|
+
return mode === "manual" ? "Manual" : "Auto-detect";
|
|
187
|
+
}
|
|
188
|
+
function getPercentDisplayModeLabel(mode) {
|
|
189
|
+
return mode === "used" ? "Used" : "Remaining";
|
|
190
|
+
}
|
|
191
|
+
function resolveRequestedProviders(selections) {
|
|
192
|
+
if (selections.providerMode === "auto") {
|
|
193
|
+
return "auto";
|
|
194
|
+
}
|
|
195
|
+
const normalized = dedupeNonEmptyStrings(selections.manualProviders
|
|
196
|
+
.map((providerId) => normalizeQuotaProviderId(providerId))
|
|
197
|
+
.filter((providerId) => QUOTA_PROVIDER_SHAPES.some((shape) => shape.id === providerId)));
|
|
198
|
+
if (normalized.length === 0) {
|
|
199
|
+
throw new InitInstallerError("Manual provider mode requires at least one supported provider.");
|
|
200
|
+
}
|
|
201
|
+
return normalized;
|
|
202
|
+
}
|
|
203
|
+
function pickFormatStyleToWrite(params) {
|
|
204
|
+
if (isQuotaFormatStyle(params.quotaToast.toastStyle)) {
|
|
205
|
+
return resolveQuotaFormatStyle(params.quotaToast.toastStyle);
|
|
206
|
+
}
|
|
207
|
+
return params.selectedFormatStyle;
|
|
208
|
+
}
|
|
209
|
+
function pushSkippedIfChanged(edit, pathLabel, existingValue, desiredValue) {
|
|
210
|
+
if (!jsonEqual(existingValue, desiredValue)) {
|
|
211
|
+
edit.skippedValues.push(`${pathLabel} preserved existing value`);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
function ensureSchema(root, schemaUrl, edit) {
|
|
215
|
+
if (!hasOwnKey(root, "$schema")) {
|
|
216
|
+
root.$schema = schemaUrl;
|
|
217
|
+
edit.changed = true;
|
|
218
|
+
edit.addedKeys.push("$schema");
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
pushSkippedIfChanged(edit, "$schema", root.$schema, schemaUrl);
|
|
222
|
+
}
|
|
223
|
+
function withPluginSpec(entry, spec) {
|
|
224
|
+
if (typeof entry === "string")
|
|
225
|
+
return spec;
|
|
226
|
+
if (Array.isArray(entry))
|
|
227
|
+
return [spec, ...entry.slice(1)];
|
|
228
|
+
return { ...entry, package: spec };
|
|
229
|
+
}
|
|
230
|
+
async function planPluginEntries(root, params) {
|
|
231
|
+
for (const key of ["plugin", "plugins"]) {
|
|
232
|
+
if (hasOwnKey(root, key) && !Array.isArray(root[key])) {
|
|
233
|
+
throw new InitInstallerError(`Cannot update opencode config because ${key} is not an array.`, { path: params.edit.path });
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
// This package requires v2; an unavailable binary must not create a legacy key.
|
|
237
|
+
const key = (await detectOpenCodeMajor()) === 1 ? "plugin" : "plugins";
|
|
238
|
+
const native = root[key] ?? [];
|
|
239
|
+
const legacy = key === "plugins" ? (root.plugin ?? []) : [];
|
|
240
|
+
const beforeArrays = JSON.stringify([root.plugin, root.plugins]);
|
|
241
|
+
const entries = [
|
|
242
|
+
...native.map((entry) => ({ entry, inNative: true })),
|
|
243
|
+
...legacy.map((entry) => ({ entry, inNative: false })),
|
|
244
|
+
];
|
|
245
|
+
const inspectedEntries = [];
|
|
246
|
+
const options = new Set();
|
|
247
|
+
for (const item of entries) {
|
|
248
|
+
const spec = getPluginSpecFromEntry(item.entry);
|
|
249
|
+
const isQuotaPlugin = spec !== null &&
|
|
250
|
+
(spec === params.pluginSpec || (await isVerifiedGuiQuotaPluginSpec(spec, params.baseDir)));
|
|
251
|
+
inspectedEntries.push({
|
|
252
|
+
entry: item.entry,
|
|
253
|
+
inNative: item.inNative,
|
|
254
|
+
spec: isQuotaPlugin ? spec : null,
|
|
255
|
+
});
|
|
256
|
+
if (isQuotaPlugin) {
|
|
257
|
+
options.add(stableJsonStringify(getPluginEntryOptionPayload(item.entry)));
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
if (options.size > 1) {
|
|
261
|
+
throw new InitInstallerError("Multiple quota plugin entries have different options; review them manually before replacing the plugin spec.", { path: params.edit.path });
|
|
262
|
+
}
|
|
263
|
+
const next = [];
|
|
264
|
+
const remainingLegacy = [];
|
|
265
|
+
let retainedSpec = null;
|
|
266
|
+
let migratedLegacySpec = null;
|
|
267
|
+
let foundLegacyQuotaPlugin = false;
|
|
268
|
+
for (const { entry, inNative, spec } of inspectedEntries) {
|
|
269
|
+
if (spec === null) {
|
|
270
|
+
// Legacy unrelated entries stay in their original array.
|
|
271
|
+
if (inNative)
|
|
272
|
+
next.push(entry);
|
|
273
|
+
else
|
|
274
|
+
remainingLegacy.push(entry);
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
if (!inNative)
|
|
278
|
+
foundLegacyQuotaPlugin = true;
|
|
279
|
+
if (retainedSpec !== null) {
|
|
280
|
+
params.edit.updatedKeys.push(key);
|
|
281
|
+
const removalLocation = inNative ? key : `plugin -> ${key}`;
|
|
282
|
+
params.edit.valueChanges.push(`${removalLocation}: remove duplicate quota plugin ${JSON.stringify(spec)}; keep ${JSON.stringify(retainedSpec)}`);
|
|
283
|
+
continue;
|
|
284
|
+
}
|
|
285
|
+
const retainedEntry = params.explicit ? withPluginSpec(entry, params.pluginSpec) : entry;
|
|
286
|
+
retainedSpec = getPluginSpecFromEntry(retainedEntry) ?? spec;
|
|
287
|
+
next.push(retainedEntry);
|
|
288
|
+
if (!inNative)
|
|
289
|
+
migratedLegacySpec = retainedSpec;
|
|
290
|
+
if (params.explicit && spec !== retainedSpec) {
|
|
291
|
+
params.edit.updatedKeys.push(key);
|
|
292
|
+
params.edit.valueChanges.push(`${key}: ${JSON.stringify(spec)} -> ${JSON.stringify(retainedSpec)}`);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
if (retainedSpec === null) {
|
|
296
|
+
next.push(params.pluginSpec);
|
|
297
|
+
params.edit.addedPlugins.push(`${key}: ${params.pluginSpec}`);
|
|
298
|
+
}
|
|
299
|
+
if (legacy.length > 0)
|
|
300
|
+
root.plugin = remainingLegacy;
|
|
301
|
+
if (foundLegacyQuotaPlugin) {
|
|
302
|
+
params.edit.updatedKeys.push("plugin -> plugins");
|
|
303
|
+
if (migratedLegacySpec !== null) {
|
|
304
|
+
params.edit.valueChanges.push(`plugin -> plugins: ${JSON.stringify([migratedLegacySpec])}`);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
root[key] = next;
|
|
308
|
+
if (!params.explicit &&
|
|
309
|
+
retainedSpec !== null &&
|
|
310
|
+
JSON.stringify([root.plugin, root.plugins]) === beforeArrays) {
|
|
311
|
+
params.edit.skippedValues.push(`${key} already includes a quota plugin entry`);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
function addSettingIfMissing(target, key, value, pathLabel, edit) {
|
|
315
|
+
if (!hasOwnKey(target, key)) {
|
|
316
|
+
target[key] = value;
|
|
317
|
+
edit.changed = true;
|
|
318
|
+
edit.addedKeys.push(pathLabel);
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
pushSkippedIfChanged(edit, pathLabel, target[key], value);
|
|
322
|
+
}
|
|
323
|
+
function setInstallerOwnedSetting(target, key, value, pathLabel, edit) {
|
|
324
|
+
if (!hasOwnKey(target, key)) {
|
|
325
|
+
target[key] = value;
|
|
326
|
+
edit.changed = true;
|
|
327
|
+
edit.addedKeys.push(pathLabel);
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
if (!jsonEqual(target[key], value)) {
|
|
331
|
+
const previousValue = target[key];
|
|
332
|
+
target[key] = value;
|
|
333
|
+
edit.changed = true;
|
|
334
|
+
edit.updatedKeys.push(pathLabel);
|
|
335
|
+
edit.valueChanges.push(`${pathLabel}: ${JSON.stringify(previousValue)} -> ${JSON.stringify(value)}`);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
function planTuiSidebarPanelConfig(params) {
|
|
339
|
+
const pathLabel = "quotaToast.tuiSidebarPanel";
|
|
340
|
+
let tuiSidebarPanel;
|
|
341
|
+
if (!hasOwnKey(params.quotaToast, "tuiSidebarPanel")) {
|
|
342
|
+
tuiSidebarPanel = {};
|
|
343
|
+
params.quotaToast.tuiSidebarPanel = tuiSidebarPanel;
|
|
344
|
+
}
|
|
345
|
+
else if (isPlainObject(params.quotaToast.tuiSidebarPanel)) {
|
|
346
|
+
tuiSidebarPanel = params.quotaToast.tuiSidebarPanel;
|
|
347
|
+
}
|
|
348
|
+
else {
|
|
349
|
+
params.edit.warnings.push(`${pathLabel} is not an object; preserved existing value.`);
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
setInstallerOwnedSetting(tuiSidebarPanel, "enabled", params.quotaUiIntent.enableSidebarPanel, `${pathLabel}.enabled`, params.edit);
|
|
353
|
+
}
|
|
354
|
+
function planMaintainerAnnouncementsConfig(params) {
|
|
355
|
+
if (params.selections.maintainerAnnouncements === undefined) {
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
const enabled = params.selections.maintainerAnnouncements;
|
|
359
|
+
const pathLabel = "quotaToast.maintainerAnnouncements";
|
|
360
|
+
let maintainerAnnouncements;
|
|
361
|
+
if (!hasOwnKey(params.quotaToast, "maintainerAnnouncements")) {
|
|
362
|
+
maintainerAnnouncements = {};
|
|
363
|
+
params.quotaToast.maintainerAnnouncements = maintainerAnnouncements;
|
|
364
|
+
}
|
|
365
|
+
else if (isPlainObject(params.quotaToast.maintainerAnnouncements)) {
|
|
366
|
+
maintainerAnnouncements = params.quotaToast.maintainerAnnouncements;
|
|
367
|
+
}
|
|
368
|
+
else {
|
|
369
|
+
params.edit.warnings.push(`${pathLabel} is not an object; preserved existing value.`);
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
setInstallerOwnedSetting(maintainerAnnouncements, "enabled", enabled, `${pathLabel}.enabled`, params.edit);
|
|
373
|
+
if (enabled) {
|
|
374
|
+
setInstallerOwnedSetting(maintainerAnnouncements, "home", true, `${pathLabel}.home`, params.edit);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
function planTuiCompactStatusConfig(params) {
|
|
378
|
+
const hasExistingCompactStatus = hasOwnKey(params.quotaToast, "tuiCompactStatus");
|
|
379
|
+
if (!params.quotaUiIntent.enableCompactStatus && !hasExistingCompactStatus) {
|
|
380
|
+
return;
|
|
381
|
+
}
|
|
382
|
+
const pathLabel = "quotaToast.tuiCompactStatus";
|
|
383
|
+
let tuiCompactStatus;
|
|
384
|
+
if (!hasExistingCompactStatus) {
|
|
385
|
+
tuiCompactStatus = {};
|
|
386
|
+
params.quotaToast.tuiCompactStatus = tuiCompactStatus;
|
|
387
|
+
}
|
|
388
|
+
else if (isPlainObject(params.quotaToast.tuiCompactStatus)) {
|
|
389
|
+
tuiCompactStatus = params.quotaToast.tuiCompactStatus;
|
|
390
|
+
}
|
|
391
|
+
else {
|
|
392
|
+
params.edit.warnings.push(`${pathLabel} is not an object; preserved existing value.`);
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
setInstallerOwnedSetting(tuiCompactStatus, "enabled", params.quotaUiIntent.enableCompactStatus, `${pathLabel}.enabled`, params.edit);
|
|
396
|
+
if (!params.quotaUiIntent.enableCompactStatus) {
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
setInstallerOwnedSetting(tuiCompactStatus, "homeBottom", true, `${pathLabel}.homeBottom`, params.edit);
|
|
400
|
+
setInstallerOwnedSetting(tuiCompactStatus, "sessionPrompt", true, `${pathLabel}.sessionPrompt`, params.edit);
|
|
401
|
+
}
|
|
402
|
+
async function readExistingConfig(params) {
|
|
403
|
+
try {
|
|
404
|
+
const content = await readFile(params.path, "utf-8");
|
|
405
|
+
const parsed = parseJsonOrJsonc(content, params.format === "jsonc");
|
|
406
|
+
if (!isPlainObject(parsed)) {
|
|
407
|
+
throw new InitInstallerError("Existing config root must be a JSON object.", {
|
|
408
|
+
path: params.path,
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
return parsed;
|
|
412
|
+
}
|
|
413
|
+
catch (error) {
|
|
414
|
+
if (error instanceof InitInstallerError) {
|
|
415
|
+
throw error;
|
|
416
|
+
}
|
|
417
|
+
throw new InitInstallerError(`Failed to parse ${basename(params.path)}.`, {
|
|
418
|
+
path: params.path,
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
function buildQuickSetupNotes(selections) {
|
|
423
|
+
if (selections.providerMode !== "manual") {
|
|
424
|
+
return [];
|
|
425
|
+
}
|
|
426
|
+
const requestedProviders = resolveRequestedProviders(selections);
|
|
427
|
+
if (requestedProviders === "auto") {
|
|
428
|
+
return [];
|
|
429
|
+
}
|
|
430
|
+
return requestedProviders
|
|
431
|
+
.map((providerId) => QUOTA_PROVIDER_SHAPES.find((shape) => shape.id === providerId))
|
|
432
|
+
.filter((shape) => Boolean(shape?.quickSetupAnchor && shape.autoSetup === "needs_quick_setup"))
|
|
433
|
+
.map((shape) => ({
|
|
434
|
+
providerId: shape.id,
|
|
435
|
+
label: getQuotaProviderDisplayLabel(shape.id),
|
|
436
|
+
anchor: shape.quickSetupAnchor,
|
|
437
|
+
}));
|
|
438
|
+
}
|
|
439
|
+
async function planOpencodeEdit(params) {
|
|
440
|
+
const target = resolveEditableConfigPath({
|
|
441
|
+
dir: params.baseDir,
|
|
442
|
+
kind: "opencode",
|
|
443
|
+
preferredFormat: params.selections.configFormat ?? "jsonc",
|
|
444
|
+
convertJsonToJsonc: !params.guiFirst,
|
|
445
|
+
});
|
|
446
|
+
const edit = {
|
|
447
|
+
kind: "opencode",
|
|
448
|
+
path: target.path,
|
|
449
|
+
existed: target.existed,
|
|
450
|
+
format: target.format,
|
|
451
|
+
changed: false,
|
|
452
|
+
addedPlugins: [],
|
|
453
|
+
addedKeys: [],
|
|
454
|
+
updatedKeys: [],
|
|
455
|
+
valueChanges: [],
|
|
456
|
+
skippedValues: [],
|
|
457
|
+
warnings: [],
|
|
458
|
+
};
|
|
459
|
+
const root = target.existed
|
|
460
|
+
? await readExistingConfig({
|
|
461
|
+
path: target.sourcePath,
|
|
462
|
+
format: target.sourcePath.endsWith(".jsonc") ? "jsonc" : "json",
|
|
463
|
+
})
|
|
464
|
+
: {};
|
|
465
|
+
if (!target.existed) {
|
|
466
|
+
ensureSchema(root, OPENCODE_SCHEMA_URL, edit);
|
|
467
|
+
}
|
|
468
|
+
const beforePlugins = JSON.stringify(root);
|
|
469
|
+
await planPluginEntries(root, { ...params, edit });
|
|
470
|
+
const pluginsChanged = beforePlugins !== JSON.stringify(root);
|
|
471
|
+
const documentEdit = await planConfigDocumentEdit({
|
|
472
|
+
target,
|
|
473
|
+
desiredData: root,
|
|
474
|
+
managedComments: pluginsChanged
|
|
475
|
+
? [
|
|
476
|
+
{
|
|
477
|
+
path: ["plugins"],
|
|
478
|
+
text: "// OpenCode Quota GUI: loads the server plugin for the local dashboard.",
|
|
479
|
+
},
|
|
480
|
+
]
|
|
481
|
+
: [],
|
|
482
|
+
});
|
|
483
|
+
edit.changed = documentEdit.changed;
|
|
484
|
+
edit.documentEdit = documentEdit;
|
|
485
|
+
return edit;
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* The dashboard only reads the canonical `opencode-quota-gui/config.jsonc`. Keep the
|
|
489
|
+
* target independent of the host OpenCode format and never touch/convert the dormant
|
|
490
|
+
* sibling `config.json`.
|
|
491
|
+
*/
|
|
492
|
+
function resolveQuotaConfigTarget(configDir) {
|
|
493
|
+
const path = getGuiConfigPath(configDir);
|
|
494
|
+
return {
|
|
495
|
+
path,
|
|
496
|
+
sourcePath: path,
|
|
497
|
+
format: "jsonc",
|
|
498
|
+
existed: existsSync(path),
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
async function planQuotaConfigEdit(params) {
|
|
502
|
+
const target = resolveQuotaConfigTarget(params.configDir);
|
|
503
|
+
await assertGuiConfigTargetIsIndependent(target.path, params.configDir);
|
|
504
|
+
const edit = {
|
|
505
|
+
kind: "quota",
|
|
506
|
+
path: target.path,
|
|
507
|
+
existed: target.existed,
|
|
508
|
+
format: target.format,
|
|
509
|
+
changed: false,
|
|
510
|
+
addedPlugins: [],
|
|
511
|
+
addedKeys: [],
|
|
512
|
+
updatedKeys: [],
|
|
513
|
+
valueChanges: [],
|
|
514
|
+
skippedValues: [],
|
|
515
|
+
warnings: [],
|
|
516
|
+
};
|
|
517
|
+
if (existsSync(getGuiConfigSiblingJsonPath(params.configDir))) {
|
|
518
|
+
edit.warnings.push(target.existed
|
|
519
|
+
? "Both opencode-quota-gui/config.jsonc and config.json exist; using JSONC and preserving the JSON file."
|
|
520
|
+
: "Existing opencode-quota-gui/config.json is preserved unchanged; the dashboard reads only config.jsonc.");
|
|
521
|
+
}
|
|
522
|
+
const quotaToast = target.existed
|
|
523
|
+
? await readExistingConfig({
|
|
524
|
+
path: target.sourcePath,
|
|
525
|
+
format: "jsonc",
|
|
526
|
+
})
|
|
527
|
+
: {};
|
|
528
|
+
if (!target.existed) {
|
|
529
|
+
edit.addedKeys.push("opencode-quota-gui/config.jsonc");
|
|
530
|
+
}
|
|
531
|
+
const setUnaskedSetting = params.guiFirst ? addSettingIfMissing : setInstallerOwnedSetting;
|
|
532
|
+
setUnaskedSetting(quotaToast, "enableToast", params.quotaUiIntent.enableToast, "quotaToast.enableToast", edit);
|
|
533
|
+
if (params.selections.tuiCommandDisplay !== undefined) {
|
|
534
|
+
setInstallerOwnedSetting(quotaToast, "tuiCommandDisplay", params.selections.tuiCommandDisplay, "quotaToast.tuiCommandDisplay", edit);
|
|
535
|
+
}
|
|
536
|
+
setUnaskedSetting(quotaToast, "showSessionTokens", params.selections.showSessionTokens, "quotaToast.showSessionTokens", edit);
|
|
537
|
+
setUnaskedSetting(quotaToast, "sessionTokenScope", params.selections.sessionTokenScope ?? "current", "quotaToast.sessionTokenScope", edit);
|
|
538
|
+
const requestedProviders = resolveRequestedProviders(params.selections);
|
|
539
|
+
const enabledProviders = requestedProviders !== "auto" &&
|
|
540
|
+
Array.isArray(quotaToast.enabledProviders) &&
|
|
541
|
+
quotaToast.enabledProviders.includes(QUOTA_PROVIDERS_AGGREGATE_ID)
|
|
542
|
+
? [...requestedProviders, QUOTA_PROVIDERS_AGGREGATE_ID]
|
|
543
|
+
: requestedProviders;
|
|
544
|
+
setInstallerOwnedSetting(quotaToast, "enabledProviders", enabledProviders, "quotaToast.enabledProviders", edit);
|
|
545
|
+
setUnaskedSetting(quotaToast, "formatStyle", params.selections.formatStyle, "quotaToast.formatStyle", edit);
|
|
546
|
+
setInstallerOwnedSetting(quotaToast, "percentDisplayMode", params.selections.percentDisplayMode, "quotaToast.percentDisplayMode", edit);
|
|
547
|
+
if (params.guiFirst) {
|
|
548
|
+
for (const key of ["tuiSidebarPanel", "tuiCompactStatus", "maintainerAnnouncements"]) {
|
|
549
|
+
addSettingIfMissing(quotaToast, key, { enabled: false }, `quotaToast.${key}`, edit);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
else {
|
|
553
|
+
planTuiSidebarPanelConfig({ quotaToast, quotaUiIntent: params.quotaUiIntent, edit });
|
|
554
|
+
planTuiCompactStatusConfig({ quotaToast, quotaUiIntent: params.quotaUiIntent, edit });
|
|
555
|
+
planMaintainerAnnouncementsConfig({ quotaToast, selections: params.selections, edit });
|
|
556
|
+
}
|
|
557
|
+
const documentEdit = await planConfigDocumentEdit({
|
|
558
|
+
target,
|
|
559
|
+
desiredData: quotaToast,
|
|
560
|
+
managedComments: [
|
|
561
|
+
{
|
|
562
|
+
path: ["enableToast"],
|
|
563
|
+
text: "// Automatic quota surfaces. Dashboard settings remain separate when these are disabled.",
|
|
564
|
+
},
|
|
565
|
+
{
|
|
566
|
+
path: ["enabledProviders"],
|
|
567
|
+
text: '// Provider selection: "auto" detects providers; an array tracks only listed providers.',
|
|
568
|
+
},
|
|
569
|
+
{
|
|
570
|
+
path: ["formatStyle"],
|
|
571
|
+
text: "// Quota presentation and reset-period choices.",
|
|
572
|
+
},
|
|
573
|
+
{
|
|
574
|
+
path: ["showSessionTokens"],
|
|
575
|
+
text: "// Include or hide session input and output token totals.",
|
|
576
|
+
},
|
|
577
|
+
{
|
|
578
|
+
path: ["sessionTokenScope"],
|
|
579
|
+
text: '// Session token totals: "current" session only, or "tree" including descendants.',
|
|
580
|
+
},
|
|
581
|
+
{
|
|
582
|
+
path: ["maintainerAnnouncements"],
|
|
583
|
+
text: "// Optional bundled maintainer Home announcements.",
|
|
584
|
+
},
|
|
585
|
+
],
|
|
586
|
+
});
|
|
587
|
+
edit.changed = documentEdit.changed;
|
|
588
|
+
edit.documentEdit = documentEdit;
|
|
589
|
+
edit.plannedData = quotaToast;
|
|
590
|
+
return edit;
|
|
591
|
+
}
|
|
592
|
+
function buildPlanSummary(plan) {
|
|
593
|
+
const opencodeFormat = plan.edits.find((edit) => edit.kind === "opencode")?.format ??
|
|
594
|
+
plan.selections.configFormat ??
|
|
595
|
+
"jsonc";
|
|
596
|
+
const lines = [
|
|
597
|
+
"Interface: GUI dashboard",
|
|
598
|
+
`OpenCode plugin scope: ${plan.selections.scope} (${plan.baseDir})`,
|
|
599
|
+
`Dashboard config (global): ${getGuiConfigPath(plan.guiConfigDir)}`,
|
|
600
|
+
`OpenCode config format: ${opencodeFormat.toUpperCase()}`,
|
|
601
|
+
];
|
|
602
|
+
lines.push(`Provider mode: ${getProviderModeLabel(plan.selections.providerMode)}`, `Quota reset periods: ${getQuotaFormatStyleLabel(plan.selections.formatStyle)}`, `Quota percentage meaning: ${getPercentDisplayModeLabel(plan.selections.percentDisplayMode)}`, `Session input/output tokens: ${plan.selections.showSessionTokens ? "Show" : "Hide"}`, `Session token scope: ${plan.selections.sessionTokenScope === "tree" ? "Current session and descendants" : "Current session"}`);
|
|
603
|
+
if (plan.selections.maintainerAnnouncements !== undefined) {
|
|
604
|
+
lines.push(`Maintainer announcements: ${plan.selections.maintainerAnnouncements ? "Enabled" : "Disabled"}`);
|
|
605
|
+
}
|
|
606
|
+
const requestedProviders = resolveRequestedProviders(plan.selections);
|
|
607
|
+
if (requestedProviders !== "auto") {
|
|
608
|
+
lines.push(`Manual providers: ${requestedProviders.map((providerId) => getQuotaProviderDisplayLabel(providerId)).join(", ")}`);
|
|
609
|
+
}
|
|
610
|
+
for (const edit of plan.edits) {
|
|
611
|
+
const convertedFrom = edit.documentEdit?.removeSourcePath;
|
|
612
|
+
const mode = convertedFrom
|
|
613
|
+
? "convert"
|
|
614
|
+
: !edit.existed
|
|
615
|
+
? "create"
|
|
616
|
+
: edit.changed
|
|
617
|
+
? "update"
|
|
618
|
+
: "unchanged";
|
|
619
|
+
lines.push(convertedFrom ? `${mode}: ${convertedFrom} -> ${edit.path}` : `${mode}: ${edit.path}`);
|
|
620
|
+
for (const plugin of edit.addedPlugins) {
|
|
621
|
+
lines.push(` + plugin ${plugin}`);
|
|
622
|
+
}
|
|
623
|
+
for (const key of edit.addedKeys) {
|
|
624
|
+
lines.push(` + ${key}`);
|
|
625
|
+
}
|
|
626
|
+
for (const key of edit.updatedKeys) {
|
|
627
|
+
lines.push(` ~ ${key}`);
|
|
628
|
+
}
|
|
629
|
+
for (const change of edit.valueChanges) {
|
|
630
|
+
lines.push(` ${change}`);
|
|
631
|
+
}
|
|
632
|
+
for (const skipped of edit.skippedValues) {
|
|
633
|
+
lines.push(` = ${skipped}`);
|
|
634
|
+
}
|
|
635
|
+
for (const warning of edit.warnings) {
|
|
636
|
+
lines.push(` ! ${warning}`);
|
|
637
|
+
}
|
|
638
|
+
}
|
|
639
|
+
if (plan.quickSetupNotes.length > 0) {
|
|
640
|
+
lines.push("Quick setup reminders:");
|
|
641
|
+
for (const note of plan.quickSetupNotes) {
|
|
642
|
+
lines.push(` - ${note.label}: docs/readme/providers.md#${note.anchor}`);
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
if (plan.warnings.length > 0) {
|
|
646
|
+
lines.push("Warnings:");
|
|
647
|
+
for (const warning of plan.warnings) {
|
|
648
|
+
lines.push(` ! ${warning}`);
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
return lines;
|
|
652
|
+
}
|
|
653
|
+
export function getInstallerProviderPromptOptions() {
|
|
654
|
+
return QUOTA_PROVIDER_SHAPES.map((shape) => ({
|
|
655
|
+
label: shape.autoSetup === "needs_quick_setup"
|
|
656
|
+
? `${getQuotaProviderDisplayLabel(shape.id)} (quick setup)`
|
|
657
|
+
: getQuotaProviderDisplayLabel(shape.id),
|
|
658
|
+
value: shape.id,
|
|
659
|
+
}));
|
|
660
|
+
}
|
|
661
|
+
export function resolveInitInstallerBaseDir(params) {
|
|
662
|
+
if (params.scope === "global") {
|
|
663
|
+
return getOpencodeRuntimeDirs({ env: params.env, homeDir: params.homeDir }).configDir;
|
|
664
|
+
}
|
|
665
|
+
const cwd = params.cwd ?? process.cwd();
|
|
666
|
+
return findGitWorktreeRoot(cwd) ?? cwd;
|
|
667
|
+
}
|
|
668
|
+
export async function planInitInstaller(params) {
|
|
669
|
+
const requestedSelections = {
|
|
670
|
+
...params.selections,
|
|
671
|
+
quotaUi: params.selections.interfaces === "web" ? ["none"] : params.selections.quotaUi,
|
|
672
|
+
};
|
|
673
|
+
const quotaUiIntent = normalizeQuotaUiIntent(requestedSelections);
|
|
674
|
+
const selections = {
|
|
675
|
+
...requestedSelections,
|
|
676
|
+
configFormat: params.selections.configFormat ?? "jsonc",
|
|
677
|
+
quotaUi: quotaUiIntent.choices,
|
|
678
|
+
tuiCommandDisplay: params.selections.interfaces === "web"
|
|
679
|
+
? undefined
|
|
680
|
+
: (params.selections.tuiCommandDisplay ?? "dialog"),
|
|
681
|
+
maintainerAnnouncements: params.selections.maintainerAnnouncements,
|
|
682
|
+
manualProviders: params.selections.providerMode === "manual"
|
|
683
|
+
? resolveRequestedProviders(params.selections)
|
|
684
|
+
: [],
|
|
685
|
+
};
|
|
686
|
+
const baseDir = resolveInitInstallerBaseDir({
|
|
687
|
+
scope: selections.scope,
|
|
688
|
+
cwd: params.cwd,
|
|
689
|
+
env: params.env,
|
|
690
|
+
homeDir: params.homeDir,
|
|
691
|
+
});
|
|
692
|
+
// Dashboard behavior always lives in the global canonical config, even when the
|
|
693
|
+
// plugin entry is installed for the current project only.
|
|
694
|
+
const guiConfigDir = resolveInitInstallerBaseDir({
|
|
695
|
+
scope: "global",
|
|
696
|
+
env: params.env,
|
|
697
|
+
homeDir: params.homeDir,
|
|
698
|
+
});
|
|
699
|
+
const quotaEdit = await planQuotaConfigEdit({
|
|
700
|
+
selections,
|
|
701
|
+
quotaUiIntent,
|
|
702
|
+
configDir: guiConfigDir,
|
|
703
|
+
guiFirst: params.guiFirst,
|
|
704
|
+
});
|
|
705
|
+
const pluginSpec = await resolveQuotaPluginSpec({
|
|
706
|
+
pluginSpec: params.pluginSpec,
|
|
707
|
+
env: params.env,
|
|
708
|
+
});
|
|
709
|
+
const edits = [
|
|
710
|
+
await planOpencodeEdit({
|
|
711
|
+
selections,
|
|
712
|
+
baseDir,
|
|
713
|
+
pluginSpec,
|
|
714
|
+
explicit: resolveExplicitQuotaPluginSpec(params) !== null,
|
|
715
|
+
guiFirst: params.guiFirst,
|
|
716
|
+
}),
|
|
717
|
+
quotaEdit,
|
|
718
|
+
];
|
|
719
|
+
const quickSetupNotes = buildQuickSetupNotes(selections);
|
|
720
|
+
const warnings = edits.flatMap((edit) => edit.warnings);
|
|
721
|
+
const plan = {
|
|
722
|
+
selections,
|
|
723
|
+
baseDir,
|
|
724
|
+
guiConfigDir,
|
|
725
|
+
edits,
|
|
726
|
+
warnings,
|
|
727
|
+
quickSetupNotes,
|
|
728
|
+
summaryLines: [],
|
|
729
|
+
};
|
|
730
|
+
plan.summaryLines = buildPlanSummary(plan);
|
|
731
|
+
return plan;
|
|
732
|
+
}
|
|
733
|
+
export async function applyInitInstallerPlan(plan) {
|
|
734
|
+
const writtenPaths = [];
|
|
735
|
+
const unchangedPaths = [];
|
|
736
|
+
// Re-check the canonical target immediately before apply so a symlink retarget cannot
|
|
737
|
+
// redirect this write into upstream quota sources after planning.
|
|
738
|
+
await Promise.all(plan.edits
|
|
739
|
+
.filter((edit) => edit.kind === "quota")
|
|
740
|
+
.map((edit) => assertGuiConfigTargetIsIndependent(edit.path, plan.guiConfigDir)));
|
|
741
|
+
try {
|
|
742
|
+
await Promise.all(plan.edits.flatMap((edit) => edit.documentEdit ? [validateConfigDocumentEdit(edit.documentEdit)] : []));
|
|
743
|
+
}
|
|
744
|
+
catch (error) {
|
|
745
|
+
const path = error && typeof error === "object" && "path" in error
|
|
746
|
+
? String(error.path ?? "")
|
|
747
|
+
: "";
|
|
748
|
+
throw new InitInstallerError(`Config changed since preview${path ? `: ${path}` : "."}`, {
|
|
749
|
+
path: path || undefined,
|
|
750
|
+
writtenPaths,
|
|
751
|
+
});
|
|
752
|
+
}
|
|
753
|
+
for (const edit of plan.edits) {
|
|
754
|
+
if (!edit.changed || (!edit.nextData && !edit.documentEdit)) {
|
|
755
|
+
unchangedPaths.push(edit.path);
|
|
756
|
+
continue;
|
|
757
|
+
}
|
|
758
|
+
try {
|
|
759
|
+
if (edit.documentEdit) {
|
|
760
|
+
await applyConfigDocumentEdit(edit.documentEdit);
|
|
761
|
+
}
|
|
762
|
+
else {
|
|
763
|
+
await writeConfiguredJsonAtomic(edit.path, edit.nextData, { trailingNewline: true });
|
|
764
|
+
}
|
|
765
|
+
writtenPaths.push(edit.path);
|
|
766
|
+
}
|
|
767
|
+
catch (error) {
|
|
768
|
+
throw new InitInstallerError(`Failed writing ${edit.path}.`, {
|
|
769
|
+
path: edit.path,
|
|
770
|
+
writtenPaths,
|
|
771
|
+
});
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
return {
|
|
775
|
+
writtenPaths,
|
|
776
|
+
unchangedPaths,
|
|
777
|
+
};
|
|
778
|
+
}
|
|
779
|
+
async function readExistingInstallerAnswers(params) {
|
|
780
|
+
const existingHostPath = ["opencode.jsonc", "opencode.json"]
|
|
781
|
+
.map((name) => join(params.hostBaseDir, name))
|
|
782
|
+
.find((path) => existsSync(path));
|
|
783
|
+
const answers = {
|
|
784
|
+
// Host format only; the dashboard target is always canonical JSONC and the
|
|
785
|
+
// dormant GUI sibling config.json is never a defaults source.
|
|
786
|
+
configFormat: existingHostPath?.endsWith(".jsonc")
|
|
787
|
+
? "jsonc"
|
|
788
|
+
: existingHostPath
|
|
789
|
+
? "json"
|
|
790
|
+
: undefined,
|
|
791
|
+
};
|
|
792
|
+
const existingQuotaPath = getGuiConfigPath(params.guiConfigDir);
|
|
793
|
+
if (!existsSync(existingQuotaPath))
|
|
794
|
+
return answers;
|
|
795
|
+
const quotaToast = await readExistingConfig({
|
|
796
|
+
path: existingQuotaPath,
|
|
797
|
+
format: "jsonc",
|
|
798
|
+
});
|
|
799
|
+
const quotaUi = [];
|
|
800
|
+
if (isPlainObject(quotaToast.tuiSidebarPanel) && quotaToast.tuiSidebarPanel.enabled === true) {
|
|
801
|
+
quotaUi.push("sidebar");
|
|
802
|
+
}
|
|
803
|
+
if (quotaToast.enableToast === true)
|
|
804
|
+
quotaUi.push("toast");
|
|
805
|
+
if (isPlainObject(quotaToast.tuiCompactStatus) && quotaToast.tuiCompactStatus.enabled === true) {
|
|
806
|
+
quotaUi.push("compact_status");
|
|
807
|
+
}
|
|
808
|
+
answers.quotaUi = quotaUi.length > 0 ? quotaUi : ["none"];
|
|
809
|
+
if (quotaToast.enabledProviders === "auto") {
|
|
810
|
+
answers.providerMode = "auto";
|
|
811
|
+
answers.manualProviders = [];
|
|
812
|
+
}
|
|
813
|
+
else if (Array.isArray(quotaToast.enabledProviders)) {
|
|
814
|
+
answers.providerMode = "manual";
|
|
815
|
+
answers.manualProviders = quotaToast.enabledProviders.filter((value) => typeof value === "string" &&
|
|
816
|
+
QUOTA_PROVIDER_SHAPES.some((shape) => shape.id === normalizeQuotaProviderId(value)));
|
|
817
|
+
}
|
|
818
|
+
if (isQuotaFormatStyle(quotaToast.formatStyle)) {
|
|
819
|
+
answers.formatStyle = resolveQuotaFormatStyle(quotaToast.formatStyle);
|
|
820
|
+
}
|
|
821
|
+
if (quotaToast.percentDisplayMode === "remaining" || quotaToast.percentDisplayMode === "used") {
|
|
822
|
+
answers.percentDisplayMode = quotaToast.percentDisplayMode;
|
|
823
|
+
}
|
|
824
|
+
if (typeof quotaToast.showSessionTokens === "boolean") {
|
|
825
|
+
answers.showSessionTokens = quotaToast.showSessionTokens;
|
|
826
|
+
}
|
|
827
|
+
if (quotaToast.sessionTokenScope === "current" || quotaToast.sessionTokenScope === "tree") {
|
|
828
|
+
answers.sessionTokenScope = quotaToast.sessionTokenScope;
|
|
829
|
+
}
|
|
830
|
+
if (quotaToast.tuiCommandDisplay === "inline" || quotaToast.tuiCommandDisplay === "dialog") {
|
|
831
|
+
answers.tuiCommandDisplay = quotaToast.tuiCommandDisplay;
|
|
832
|
+
}
|
|
833
|
+
if (isPlainObject(quotaToast.maintainerAnnouncements) &&
|
|
834
|
+
typeof quotaToast.maintainerAnnouncements.enabled === "boolean") {
|
|
835
|
+
answers.maintainerAnnouncements = quotaToast.maintainerAnnouncements.enabled;
|
|
836
|
+
}
|
|
837
|
+
return answers;
|
|
838
|
+
}
|
|
839
|
+
async function promptForSelections(prompts, context) {
|
|
840
|
+
const scope = await prompts.select({
|
|
841
|
+
message: "Where should OpenCode Quota GUI be configured?",
|
|
842
|
+
initialValue: "global",
|
|
843
|
+
options: [
|
|
844
|
+
{
|
|
845
|
+
label: "Global OpenCode config (recommended)",
|
|
846
|
+
value: "global",
|
|
847
|
+
hint: "install for all projects using your global config",
|
|
848
|
+
},
|
|
849
|
+
{ label: "Current project", value: "project", hint: "install only for this repo/worktree" },
|
|
850
|
+
],
|
|
851
|
+
});
|
|
852
|
+
if (prompts.isCancel(scope))
|
|
853
|
+
return null;
|
|
854
|
+
const hostBaseDir = resolveInitInstallerBaseDir({
|
|
855
|
+
scope: scope,
|
|
856
|
+
cwd: context.cwd,
|
|
857
|
+
env: context.env,
|
|
858
|
+
homeDir: context.homeDir,
|
|
859
|
+
});
|
|
860
|
+
const guiConfigDir = resolveInitInstallerBaseDir({
|
|
861
|
+
scope: "global",
|
|
862
|
+
env: context.env,
|
|
863
|
+
homeDir: context.homeDir,
|
|
864
|
+
});
|
|
865
|
+
const existing = await readExistingInstallerAnswers({ hostBaseDir, guiConfigDir });
|
|
866
|
+
const providerMode = await prompts.select({
|
|
867
|
+
message: "How should pre-configured providers be selected?",
|
|
868
|
+
initialValue: existing.providerMode ?? "auto",
|
|
869
|
+
options: [
|
|
870
|
+
{
|
|
871
|
+
label: "Auto-detect providers",
|
|
872
|
+
value: "auto",
|
|
873
|
+
hint: "use providers found in your OpenCode configuration and authentication",
|
|
874
|
+
},
|
|
875
|
+
{
|
|
876
|
+
label: "Choose providers manually",
|
|
877
|
+
value: "manual",
|
|
878
|
+
hint: "track only the pre-configured providers you select",
|
|
879
|
+
},
|
|
880
|
+
],
|
|
881
|
+
});
|
|
882
|
+
if (prompts.isCancel(providerMode))
|
|
883
|
+
return null;
|
|
884
|
+
let manualProviders = [];
|
|
885
|
+
if (providerMode === "manual") {
|
|
886
|
+
const selected = await prompts.multiselect({
|
|
887
|
+
message: "Which pre-configured providers should be tracked?",
|
|
888
|
+
required: true,
|
|
889
|
+
initialValues: existing.manualProviders,
|
|
890
|
+
options: getInstallerProviderPromptOptions(),
|
|
891
|
+
});
|
|
892
|
+
if (prompts.isCancel(selected))
|
|
893
|
+
return null;
|
|
894
|
+
if (!Array.isArray(selected) || selected.length === 0) {
|
|
895
|
+
throw new InitInstallerError("Manual provider mode requires at least one selected provider.");
|
|
896
|
+
}
|
|
897
|
+
manualProviders = selected.filter((value) => typeof value === "string");
|
|
898
|
+
}
|
|
899
|
+
prompts.log.info("Custom providers are configured after installation.");
|
|
900
|
+
const percentDisplayMode = await prompts.select({
|
|
901
|
+
message: "What should quota percentages show?",
|
|
902
|
+
initialValue: existing.percentDisplayMode ?? "remaining",
|
|
903
|
+
options: [
|
|
904
|
+
{ label: "Remaining quota", value: "remaining", hint: "show how much quota is left" },
|
|
905
|
+
{ label: "Used quota", value: "used", hint: "show how much quota has been consumed" },
|
|
906
|
+
],
|
|
907
|
+
});
|
|
908
|
+
if (prompts.isCancel(percentDisplayMode))
|
|
909
|
+
return null;
|
|
910
|
+
return {
|
|
911
|
+
interfaces: "web",
|
|
912
|
+
scope: scope,
|
|
913
|
+
quotaUi: ["none"],
|
|
914
|
+
providerMode: providerMode,
|
|
915
|
+
manualProviders,
|
|
916
|
+
formatStyle: existing.formatStyle ?? "allWindows",
|
|
917
|
+
percentDisplayMode: percentDisplayMode,
|
|
918
|
+
showSessionTokens: existing.showSessionTokens ?? false,
|
|
919
|
+
sessionTokenScope: existing.sessionTokenScope ?? "current",
|
|
920
|
+
configFormat: existing.configFormat ?? "jsonc",
|
|
921
|
+
};
|
|
922
|
+
}
|
|
923
|
+
export async function runInitInstaller(params) {
|
|
924
|
+
const prompts = params?.prompts ?? (await import("@clack/prompts"));
|
|
925
|
+
prompts.intro("Configure OpenCode Quota GUI");
|
|
926
|
+
try {
|
|
927
|
+
let openCodeMajor = await detectOpenCodeMajor();
|
|
928
|
+
if (openCodeMajor === undefined) {
|
|
929
|
+
const answer = await prompts.select({
|
|
930
|
+
message: "Could not detect your OpenCode version. Which OpenCode do you use?",
|
|
931
|
+
initialValue: "2",
|
|
932
|
+
options: [
|
|
933
|
+
{ label: "OpenCode 2", value: "2", hint: "default" },
|
|
934
|
+
{ label: "OpenCode 1", value: "1" },
|
|
935
|
+
],
|
|
936
|
+
});
|
|
937
|
+
if (prompts.isCancel(answer)) {
|
|
938
|
+
prompts.outro("OpenCode Quota setup cancelled — no files changed.");
|
|
939
|
+
return 0;
|
|
940
|
+
}
|
|
941
|
+
openCodeMajor = answer === "1" ? 1 : 2;
|
|
942
|
+
}
|
|
943
|
+
if (openCodeMajor === 1) {
|
|
944
|
+
prompts.log.error("You're on OpenCode 1. OpenCode Quota 5 needs OpenCode 2.");
|
|
945
|
+
prompts.outro("OpenCode Quota GUI requires OpenCode 2 — no files changed.");
|
|
946
|
+
return 1;
|
|
947
|
+
}
|
|
948
|
+
const pluginSpec = await resolveQuotaPluginSpec({
|
|
949
|
+
pluginSpec: params?.pluginSpec,
|
|
950
|
+
env: params?.env,
|
|
951
|
+
});
|
|
952
|
+
const selections = await promptForSelections(prompts, {
|
|
953
|
+
cwd: params?.cwd,
|
|
954
|
+
env: params?.env,
|
|
955
|
+
homeDir: params?.homeDir,
|
|
956
|
+
pluginSpec,
|
|
957
|
+
});
|
|
958
|
+
if (!selections) {
|
|
959
|
+
prompts.outro("OpenCode Quota setup cancelled — no files changed.");
|
|
960
|
+
return 0;
|
|
961
|
+
}
|
|
962
|
+
const plan = await planInitInstaller({
|
|
963
|
+
selections,
|
|
964
|
+
cwd: params?.cwd,
|
|
965
|
+
env: params?.env,
|
|
966
|
+
homeDir: params?.homeDir,
|
|
967
|
+
pluginSpec: params?.pluginSpec,
|
|
968
|
+
guiFirst: true,
|
|
969
|
+
});
|
|
970
|
+
if (plan.edits.some((edit) => {
|
|
971
|
+
if (edit.kind !== "opencode" || !edit.documentEdit?.originalBytes)
|
|
972
|
+
return false;
|
|
973
|
+
const root = parseJsonOrJsonc(edit.documentEdit.originalBytes.toString("utf8"), edit.documentEdit.sourcePath.endsWith(".jsonc"));
|
|
974
|
+
if (isPlainObject(root.experimental) && isPlainObject(root.experimental.quotaToast))
|
|
975
|
+
return true;
|
|
976
|
+
return [root.plugin, root.plugins].some((entries) => Array.isArray(entries) &&
|
|
977
|
+
entries.some((entry) => {
|
|
978
|
+
const spec = getPluginSpecFromEntry(entry);
|
|
979
|
+
return spec !== null && /^@slkiser\/opencode-quota(?:@[^/\\\s]+)?$/.test(spec);
|
|
980
|
+
}));
|
|
981
|
+
})) {
|
|
982
|
+
prompts.log.info("Legacy quota configuration detected. Only previewed changes will be applied; existing source settings are preserved.");
|
|
983
|
+
}
|
|
984
|
+
prompts.log.info("Preview changes");
|
|
985
|
+
for (const line of plan.summaryLines) {
|
|
986
|
+
prompts.log.info(line);
|
|
987
|
+
}
|
|
988
|
+
if (!plan.edits.some((edit) => edit.changed)) {
|
|
989
|
+
prompts.outro(`OpenCode Quota is already configured and current. No files changed. ${GITHUB_STAR_NOTE}`);
|
|
990
|
+
return 0;
|
|
991
|
+
}
|
|
992
|
+
if (params?.dryRun) {
|
|
993
|
+
prompts.outro(`OpenCode Quota setup preview complete — no files changed. Run npx ${pluginSpec} init to apply.`);
|
|
994
|
+
return 0;
|
|
995
|
+
}
|
|
996
|
+
const confirmed = await prompts.confirm({
|
|
997
|
+
message: "Apply changes?",
|
|
998
|
+
initialValue: true,
|
|
999
|
+
});
|
|
1000
|
+
if (prompts.isCancel(confirmed) || !confirmed) {
|
|
1001
|
+
prompts.outro("OpenCode Quota setup cancelled — no files changed.");
|
|
1002
|
+
return 0;
|
|
1003
|
+
}
|
|
1004
|
+
const result = await applyInitInstallerPlan(plan);
|
|
1005
|
+
for (const path of result.writtenPaths) {
|
|
1006
|
+
prompts.log.success(`Wrote ${path}`);
|
|
1007
|
+
}
|
|
1008
|
+
for (const path of result.unchangedPaths) {
|
|
1009
|
+
prompts.log.info(`Unchanged ${path}`);
|
|
1010
|
+
}
|
|
1011
|
+
if (plan.quickSetupNotes.length > 0) {
|
|
1012
|
+
prompts.log.info("Manual quick-setup still needed:");
|
|
1013
|
+
for (const note of plan.quickSetupNotes) {
|
|
1014
|
+
prompts.log.info(`- ${note.label}: docs/readme/providers.md#${note.anchor}`);
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
const interfaceLabel = plan.selections.interfaces === "tui"
|
|
1018
|
+
? "TUI"
|
|
1019
|
+
: plan.selections.interfaces === "web"
|
|
1020
|
+
? "Web"
|
|
1021
|
+
: "TUI and Web";
|
|
1022
|
+
const configuredPaths = [...result.writtenPaths, ...result.unchangedPaths];
|
|
1023
|
+
const config = await loadConfig(undefined, undefined, {
|
|
1024
|
+
configRootDir: resolveInitInstallerBaseDir({ scope: "project", cwd: params?.cwd }),
|
|
1025
|
+
globalConfigDir: resolveInitInstallerBaseDir({
|
|
1026
|
+
scope: "global",
|
|
1027
|
+
env: params?.env,
|
|
1028
|
+
homeDir: params?.homeDir,
|
|
1029
|
+
}),
|
|
1030
|
+
});
|
|
1031
|
+
const dashboardUrl = `http://localhost:${config.dashboard?.port ?? DEFAULT_DASHBOARD_PORT}/quota`;
|
|
1032
|
+
prompts.outro([
|
|
1033
|
+
"OpenCode Quota setup complete.",
|
|
1034
|
+
`Interfaces: ${interfaceLabel}`,
|
|
1035
|
+
"Configured paths:",
|
|
1036
|
+
...configuredPaths.map((path) => `- ${path}`),
|
|
1037
|
+
`Restart OpenCode, then open ${dashboardUrl}.`,
|
|
1038
|
+
`If OpenCode Quota helps, please consider a star: ${GITHUB_REPO_URL}`,
|
|
1039
|
+
].join("\n"));
|
|
1040
|
+
return 0;
|
|
1041
|
+
}
|
|
1042
|
+
catch (error) {
|
|
1043
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
1044
|
+
prompts.log.error(reason);
|
|
1045
|
+
const writtenPaths = error instanceof InitInstallerError ? (error.details?.writtenPaths ?? []) : [];
|
|
1046
|
+
if (writtenPaths.length > 0) {
|
|
1047
|
+
prompts.log.info(`Files changed before failure: ${writtenPaths.join(", ")}`);
|
|
1048
|
+
prompts.outro("OpenCode Quota setup failed after some files changed. Review the listed files, fix the reason above, then rerun init.");
|
|
1049
|
+
}
|
|
1050
|
+
else {
|
|
1051
|
+
prompts.outro("OpenCode Quota setup failed before any files changed. Fix the reason above, then rerun init.");
|
|
1052
|
+
}
|
|
1053
|
+
return 1;
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
//# sourceMappingURL=init-installer.js.map
|