opencode-quota-gui 0.0.0-stage → 1.0.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/LICENSE +21 -0
- package/README.md +243 -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/card-order.d.ts +25 -0
- package/dist/contracts/card-order.d.ts.map +1 -0
- package/dist/contracts/card-order.js +50 -0
- package/dist/contracts/card-order.js.map +1 -0
- package/dist/contracts/dashboard.d.ts +368 -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 +56 -0
- package/dist/gui/config.d.ts.map +1 -0
- package/dist/gui/config.js +701 -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 +55 -0
- package/dist/gui/provider-cards.d.ts.map +1 -0
- package/dist/gui/provider-cards.js +417 -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 +99 -0
- package/dist/gui/sources.d.ts.map +1 -0
- package/dist/gui/sources.js +410 -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 +1352 -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/dashboard-visibility.d.ts +13 -0
- package/dist/lib/dashboard-visibility.d.ts.map +1 -0
- package/dist/lib/dashboard-visibility.js +51 -0
- package/dist/lib/dashboard-visibility.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 +367 -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 +96 -0
- package/dist/lib/opencode-console-auth.d.ts.map +1 -0
- package/dist/lib/opencode-console-auth.js +213 -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 +284 -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 +60 -0
- package/dist/lib/openrouter.d.ts.map +1 -0
- package/dist/lib/openrouter.js +215 -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 +757 -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 +479 -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 +738 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +85 -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 +67 -0
- package/dist/providers/cache-policies.d.ts.map +1 -0
- package/dist/providers/cache-policies.js +263 -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 +409 -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 +288 -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 +94 -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-CPEiQt-C.js +8 -0
- package/dist/ui/assets/index-D3-Yn_WA.css +1 -0
- package/dist/ui/index.html +13 -0
- package/package.json +123 -3
|
@@ -0,0 +1,1134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anthropic Claude quota probing.
|
|
3
|
+
*
|
|
4
|
+
* Uses the local Claude CLI/runtime to detect install/auth state first. When
|
|
5
|
+
* Claude auth is confirmed but local quota windows are missing, it falls back
|
|
6
|
+
* to Anthropic's OAuth usage endpoint using the first usable OAuth access
|
|
7
|
+
* token: OpenCode's own Anthropic login, then Claude OAuth credentials (macOS
|
|
8
|
+
* Keychain first, then the local credentials file).
|
|
9
|
+
*/
|
|
10
|
+
import { execFile } from "child_process";
|
|
11
|
+
import { createHash } from "crypto";
|
|
12
|
+
import { existsSync } from "fs";
|
|
13
|
+
import { readFile } from "fs/promises";
|
|
14
|
+
import { homedir } from "os";
|
|
15
|
+
import { join } from "path";
|
|
16
|
+
import { resolveAnthropicOAuthCached } from "./anthropic-auth.js";
|
|
17
|
+
import { sanitizeDisplaySnippet, sanitizeDisplayText } from "./display-sanitize.js";
|
|
18
|
+
import { fetchWithTimeout } from "./http.js";
|
|
19
|
+
import { composeResolvedAuthIdentities, deriveResolvedAuthIdentity, } from "./resolved-auth-identity.js";
|
|
20
|
+
const DEFAULT_CLAUDE_BINARY = "claude";
|
|
21
|
+
/** How `binaryPath` reads when the default `claude` ran from PATH. */
|
|
22
|
+
const CLAUDE_ON_PATH_DISPLAY = "claude (PATH)";
|
|
23
|
+
const CLAUDE_COMMAND_TIMEOUT_MS = 3_000;
|
|
24
|
+
const ANTHROPIC_DIAGNOSTICS_TTL_MS = 5_000;
|
|
25
|
+
const ANTHROPIC_OAUTH_BACKOFF_BASE_MS = 30_000;
|
|
26
|
+
const ANTHROPIC_OAUTH_COOLDOWN_MAX_MS = 15 * 60_000;
|
|
27
|
+
const ANTHROPIC_OAUTH_COOLDOWN_MAX_ENTRIES = 16;
|
|
28
|
+
const ANTHROPIC_USAGE_URL = "https://api.anthropic.com/api/oauth/usage";
|
|
29
|
+
const ANTHROPIC_BETA_HEADER = "oauth-2025-04-20";
|
|
30
|
+
const CLAUDE_CODE_CREDENTIALS_SERVICE = "Claude Code-credentials";
|
|
31
|
+
const CLAUDE_NO_LOCAL_QUOTA_MESSAGE = "Claude CLI auth detected, but local quota windows were not exposed.";
|
|
32
|
+
const ANTHROPIC_NO_QUOTA_MESSAGE = "Claude CLI auth detected, but quota was unavailable from the local CLI and OAuth credential sources.";
|
|
33
|
+
const diagnosticsCache = new Map();
|
|
34
|
+
const localDiagnosticsCache = new Map();
|
|
35
|
+
const anthropicOAuthCooldowns = new Map();
|
|
36
|
+
const anthropicOAuthInFlight = new Map();
|
|
37
|
+
export function resolveAnthropicBinaryPath(binaryPath) {
|
|
38
|
+
const trimmed = binaryPath?.trim();
|
|
39
|
+
return trimmed ? trimmed : DEFAULT_CLAUDE_BINARY;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Usual Claude CLI install locations, tried in order when `anthropicBinaryPath`
|
|
43
|
+
* is not set and `claude` is not on the PATH of the OpenCode service. Windows
|
|
44
|
+
* is skipped: set `anthropicBinaryPath` there.
|
|
45
|
+
*/
|
|
46
|
+
function claudeInstallFolderCandidates() {
|
|
47
|
+
if (process.platform === "win32")
|
|
48
|
+
return [];
|
|
49
|
+
return [
|
|
50
|
+
join(homedir(), ".claude", "local", "claude"),
|
|
51
|
+
join(homedir(), ".local", "bin", "claude"),
|
|
52
|
+
"/opt/homebrew/bin/claude",
|
|
53
|
+
"/usr/local/bin/claude",
|
|
54
|
+
];
|
|
55
|
+
}
|
|
56
|
+
function formatCommandDisplayArg(value) {
|
|
57
|
+
const sanitized = sanitizeDisplayText(value);
|
|
58
|
+
return /[\s"]/u.test(sanitized) ? JSON.stringify(sanitized) : sanitized;
|
|
59
|
+
}
|
|
60
|
+
function formatCommandDisplay(parts) {
|
|
61
|
+
return parts.map(formatCommandDisplayArg).join(" ");
|
|
62
|
+
}
|
|
63
|
+
function quoteWindowsCmdArg(value) {
|
|
64
|
+
const escaped = value.replace(/(\\*)"/g, '$1$1\\"').replace(/(\\+)$/g, "$1$1");
|
|
65
|
+
return `"${escaped}"`;
|
|
66
|
+
}
|
|
67
|
+
function shouldBridgeClaudeCommandThroughWindowsShell(binaryPath) {
|
|
68
|
+
const normalized = binaryPath.trim().toLowerCase();
|
|
69
|
+
if (!/[\\/]/u.test(normalized)) {
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
return /\.(?:cmd|bat)$/u.test(normalized);
|
|
73
|
+
}
|
|
74
|
+
export function buildClaudeCommandInvocation(binaryPath, args, runtime = {}) {
|
|
75
|
+
const resolvedBinaryPath = resolveAnthropicBinaryPath(binaryPath);
|
|
76
|
+
const display = formatCommandDisplay([resolvedBinaryPath, ...args]);
|
|
77
|
+
if ((runtime.platform ?? process.platform) === "win32" &&
|
|
78
|
+
shouldBridgeClaudeCommandThroughWindowsShell(resolvedBinaryPath)) {
|
|
79
|
+
return {
|
|
80
|
+
file: runtime.comspec?.trim() || process.env["ComSpec"]?.trim() || "cmd.exe",
|
|
81
|
+
args: ["/d", "/s", "/c", [resolvedBinaryPath, ...args].map(quoteWindowsCmdArg).join(" ")],
|
|
82
|
+
display,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
file: resolvedBinaryPath,
|
|
87
|
+
args: [...args],
|
|
88
|
+
display,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function asRecord(value) {
|
|
92
|
+
return value && typeof value === "object" && !Array.isArray(value)
|
|
93
|
+
? value
|
|
94
|
+
: null;
|
|
95
|
+
}
|
|
96
|
+
function normalizeResetTimeIso(value) {
|
|
97
|
+
if (typeof value !== "string") {
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
const trimmed = value.trim();
|
|
101
|
+
if (!trimmed) {
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
const parsed = Date.parse(trimmed);
|
|
105
|
+
if (!Number.isFinite(parsed)) {
|
|
106
|
+
return undefined;
|
|
107
|
+
}
|
|
108
|
+
return new Date(parsed).toISOString();
|
|
109
|
+
}
|
|
110
|
+
function normalizeUsagePercent(value) {
|
|
111
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
112
|
+
return value;
|
|
113
|
+
}
|
|
114
|
+
if (typeof value === "string") {
|
|
115
|
+
const trimmed = value.trim();
|
|
116
|
+
if (!trimmed) {
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
const parsed = Number(trimmed);
|
|
120
|
+
return Number.isFinite(parsed) ? parsed : undefined;
|
|
121
|
+
}
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
function getWindowUsedPercent(window) {
|
|
125
|
+
const candidates = [
|
|
126
|
+
window["utilization"],
|
|
127
|
+
window["used_percentage"],
|
|
128
|
+
window["usedPercentage"],
|
|
129
|
+
window["used_percent"],
|
|
130
|
+
window["usedPercent"],
|
|
131
|
+
window["percent_used"],
|
|
132
|
+
window["percentUsed"],
|
|
133
|
+
];
|
|
134
|
+
for (const candidate of candidates) {
|
|
135
|
+
const normalized = normalizeUsagePercent(candidate);
|
|
136
|
+
if (normalized !== undefined) {
|
|
137
|
+
return normalized;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
142
|
+
function getWindowResetTimeIso(window) {
|
|
143
|
+
return normalizeResetTimeIso(window["resets_at"] ?? window["resetsAt"] ?? window["reset_at"] ?? window["resetAt"]);
|
|
144
|
+
}
|
|
145
|
+
function parseQuotaWindow(window) {
|
|
146
|
+
const record = asRecord(window);
|
|
147
|
+
if (!record) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
const used = getWindowUsedPercent(record);
|
|
151
|
+
if (used === undefined) {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
return {
|
|
155
|
+
percentRemaining: Math.min(100, Math.round(100 - used)),
|
|
156
|
+
resetTimeIso: getWindowResetTimeIso(record),
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
function parseExtraUsageQuota(extraUsage) {
|
|
160
|
+
const record = asRecord(extraUsage);
|
|
161
|
+
if (!record || record["is_enabled"] !== true) {
|
|
162
|
+
return undefined;
|
|
163
|
+
}
|
|
164
|
+
const used = record["utilization"];
|
|
165
|
+
if (typeof used !== "number" || !Number.isFinite(used) || used < 0 || used > 100) {
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
168
|
+
return { percentRemaining: Math.round(100 - used) };
|
|
169
|
+
}
|
|
170
|
+
function getUsageRoots(data) {
|
|
171
|
+
const root = asRecord(data);
|
|
172
|
+
if (!root) {
|
|
173
|
+
return [];
|
|
174
|
+
}
|
|
175
|
+
const candidates = [
|
|
176
|
+
root,
|
|
177
|
+
asRecord(root["quota"]),
|
|
178
|
+
asRecord(root["usage"]),
|
|
179
|
+
asRecord(root["rate_limits"]),
|
|
180
|
+
asRecord(root["rateLimits"]),
|
|
181
|
+
asRecord(root["oauth_usage"]),
|
|
182
|
+
asRecord(root["oauthUsage"]),
|
|
183
|
+
];
|
|
184
|
+
const seen = new Set();
|
|
185
|
+
const roots = [];
|
|
186
|
+
for (const candidate of candidates) {
|
|
187
|
+
if (!candidate || seen.has(candidate)) {
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
seen.add(candidate);
|
|
191
|
+
roots.push(candidate);
|
|
192
|
+
}
|
|
193
|
+
return roots;
|
|
194
|
+
}
|
|
195
|
+
function parseFableWeeklyWindow(limits) {
|
|
196
|
+
if (!Array.isArray(limits)) {
|
|
197
|
+
return undefined;
|
|
198
|
+
}
|
|
199
|
+
for (const value of limits) {
|
|
200
|
+
const limit = asRecord(value);
|
|
201
|
+
if (!limit || limit["kind"] !== "weekly_scoped") {
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
const scope = asRecord(limit["scope"]);
|
|
205
|
+
const model = asRecord(scope?.["model"]);
|
|
206
|
+
const displayName = model?.["display_name"];
|
|
207
|
+
if (displayName !== "Fable") {
|
|
208
|
+
continue;
|
|
209
|
+
}
|
|
210
|
+
const window = parseQuotaWindow({
|
|
211
|
+
utilization: limit["percent"],
|
|
212
|
+
resets_at: limit["resets_at"],
|
|
213
|
+
});
|
|
214
|
+
if (window) {
|
|
215
|
+
return window;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return undefined;
|
|
219
|
+
}
|
|
220
|
+
function parseUsageResponse(data, options = {}) {
|
|
221
|
+
for (const root of getUsageRoots(data)) {
|
|
222
|
+
const fiveHour = parseQuotaWindow(root["five_hour"] ?? root["fiveHour"]);
|
|
223
|
+
const sevenDay = parseQuotaWindow(root["seven_day"] ?? root["sevenDay"]);
|
|
224
|
+
if (!fiveHour || !sevenDay) {
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
const extraUsage = options.includeExtraUsage
|
|
228
|
+
? parseExtraUsageQuota(root["extra_usage"])
|
|
229
|
+
: undefined;
|
|
230
|
+
return {
|
|
231
|
+
success: true,
|
|
232
|
+
five_hour: fiveHour,
|
|
233
|
+
seven_day: sevenDay,
|
|
234
|
+
...(extraUsage ? { extra_usage: extraUsage } : {}),
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
return null;
|
|
238
|
+
}
|
|
239
|
+
function parseOAuthUsageResponse(data) {
|
|
240
|
+
for (const root of getUsageRoots(data)) {
|
|
241
|
+
const fiveHour = parseQuotaWindow(root["five_hour"] ?? root["fiveHour"]);
|
|
242
|
+
const sevenDay = parseQuotaWindow(root["seven_day"] ?? root["sevenDay"]);
|
|
243
|
+
if (!fiveHour || !sevenDay) {
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
const extraUsage = parseExtraUsageQuota(root["extra_usage"]);
|
|
247
|
+
const fableWeekly = parseFableWeeklyWindow(root["limits"]);
|
|
248
|
+
return {
|
|
249
|
+
success: true,
|
|
250
|
+
five_hour: fiveHour,
|
|
251
|
+
seven_day: sevenDay,
|
|
252
|
+
...(extraUsage ? { extra_usage: extraUsage } : {}),
|
|
253
|
+
...(fableWeekly ? { fable_weekly: fableWeekly } : {}),
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
return null;
|
|
257
|
+
}
|
|
258
|
+
function getClaudeCredentialsPath() {
|
|
259
|
+
return join(homedir(), ".claude", ".credentials.json");
|
|
260
|
+
}
|
|
261
|
+
function getClaudeKeychainLocation() {
|
|
262
|
+
return `macOS Keychain service ${sanitizeDisplayText(CLAUDE_CODE_CREDENTIALS_SERVICE)}`;
|
|
263
|
+
}
|
|
264
|
+
function getClaudeCredentialsNotFoundDetail(locations) {
|
|
265
|
+
if (locations.length === 0) {
|
|
266
|
+
return "Claude OAuth credentials were not found.";
|
|
267
|
+
}
|
|
268
|
+
if (locations.length === 1) {
|
|
269
|
+
return `Claude OAuth credentials not found in ${locations[0]}.`;
|
|
270
|
+
}
|
|
271
|
+
const [head, ...tail] = locations;
|
|
272
|
+
return `Claude OAuth credentials not found in ${head} or ${tail.join(" or ")}.`;
|
|
273
|
+
}
|
|
274
|
+
function buildAnthropicNoQuotaDiagnosticsMessage(detail) {
|
|
275
|
+
const normalizedDetail = detail?.trim();
|
|
276
|
+
return normalizedDetail
|
|
277
|
+
? `${ANTHROPIC_NO_QUOTA_MESSAGE} ${normalizedDetail}`
|
|
278
|
+
: ANTHROPIC_NO_QUOTA_MESSAGE;
|
|
279
|
+
}
|
|
280
|
+
function extractClaudeCredentialsAccessToken(data) {
|
|
281
|
+
const root = asRecord(data);
|
|
282
|
+
if (!root) {
|
|
283
|
+
return "";
|
|
284
|
+
}
|
|
285
|
+
for (const candidate of [asRecord(root["claudeAiOauth"]), asRecord(root["oauth"]), root]) {
|
|
286
|
+
if (!candidate) {
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
for (const key of ["accessToken", "access_token", "token"]) {
|
|
290
|
+
const token = candidate[key];
|
|
291
|
+
if (typeof token === "string" && token.trim()) {
|
|
292
|
+
return token.trim();
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return "";
|
|
297
|
+
}
|
|
298
|
+
function parseClaudeCredentialsAccessToken(content, options) {
|
|
299
|
+
const trimmed = content.trim();
|
|
300
|
+
if (!trimmed) {
|
|
301
|
+
return { error: "missing" };
|
|
302
|
+
}
|
|
303
|
+
if (!trimmed.startsWith("{") && !trimmed.startsWith("[")) {
|
|
304
|
+
return options.allowPlainText ? { accessToken: trimmed } : { error: "missing" };
|
|
305
|
+
}
|
|
306
|
+
try {
|
|
307
|
+
const parsed = JSON.parse(trimmed);
|
|
308
|
+
const accessToken = extractClaudeCredentialsAccessToken(parsed);
|
|
309
|
+
return accessToken ? { accessToken } : { error: "missing" };
|
|
310
|
+
}
|
|
311
|
+
catch (error) {
|
|
312
|
+
return {
|
|
313
|
+
error: sanitizeDisplayText(error instanceof Error ? error.message : String(error)),
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
async function runCredentialCommand(file, args) {
|
|
318
|
+
return await new Promise((resolve, reject) => {
|
|
319
|
+
try {
|
|
320
|
+
execFile(file, args, {
|
|
321
|
+
encoding: "utf8",
|
|
322
|
+
timeout: CLAUDE_COMMAND_TIMEOUT_MS,
|
|
323
|
+
maxBuffer: 1024 * 1024,
|
|
324
|
+
}, (error, stdout, stderr) => {
|
|
325
|
+
const stdoutText = typeof stdout === "string" ? stdout : stdout.toString("utf8");
|
|
326
|
+
const stderrText = typeof stderr === "string" ? stderr : stderr.toString("utf8");
|
|
327
|
+
if (!error) {
|
|
328
|
+
resolve({
|
|
329
|
+
code: 0,
|
|
330
|
+
stdout: stdoutText,
|
|
331
|
+
stderr: stderrText,
|
|
332
|
+
timedOut: false,
|
|
333
|
+
});
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
const execError = error;
|
|
337
|
+
resolve({
|
|
338
|
+
code: typeof execError.code === "number" ? execError.code : null,
|
|
339
|
+
stdout: stdoutText,
|
|
340
|
+
stderr: stderrText,
|
|
341
|
+
timedOut: isTimedOutError(execError),
|
|
342
|
+
spawnErrorCode: execError.code,
|
|
343
|
+
errorMessage: execError.message,
|
|
344
|
+
});
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
catch (error) {
|
|
348
|
+
reject(error);
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
async function readClaudeCredentialsAccessTokenFromMacOSKeychain() {
|
|
353
|
+
if (process.platform !== "darwin") {
|
|
354
|
+
return null;
|
|
355
|
+
}
|
|
356
|
+
const location = getClaudeKeychainLocation();
|
|
357
|
+
const result = await runCredentialCommand("security", [
|
|
358
|
+
"find-generic-password",
|
|
359
|
+
"-s",
|
|
360
|
+
CLAUDE_CODE_CREDENTIALS_SERVICE,
|
|
361
|
+
"-w",
|
|
362
|
+
]);
|
|
363
|
+
if (result.code !== 0) {
|
|
364
|
+
return {
|
|
365
|
+
state: "not-found",
|
|
366
|
+
location,
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
const parsed = parseClaudeCredentialsAccessToken(result.stdout, { allowPlainText: true });
|
|
370
|
+
if (parsed.accessToken) {
|
|
371
|
+
return {
|
|
372
|
+
state: "configured",
|
|
373
|
+
accessToken: parsed.accessToken,
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
return {
|
|
377
|
+
state: "unavailable",
|
|
378
|
+
detail: parsed.error && parsed.error !== "missing"
|
|
379
|
+
? `Could not parse Claude OAuth credentials from ${location}: ${parsed.error}.`
|
|
380
|
+
: `Claude OAuth access token missing in ${location}.`,
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
async function readClaudeCredentialsAccessTokenFromFile() {
|
|
384
|
+
const credentialsPath = getClaudeCredentialsPath();
|
|
385
|
+
try {
|
|
386
|
+
const content = await readFile(credentialsPath, "utf8");
|
|
387
|
+
const parsed = parseClaudeCredentialsAccessToken(content, { allowPlainText: false });
|
|
388
|
+
const accessToken = parsed.accessToken?.trim() ?? "";
|
|
389
|
+
if (!accessToken) {
|
|
390
|
+
return {
|
|
391
|
+
state: "unavailable",
|
|
392
|
+
detail: parsed.error && parsed.error !== "missing"
|
|
393
|
+
? `Could not parse Claude credentials file ${sanitizeDisplayText(credentialsPath)}: ${parsed.error}.`
|
|
394
|
+
: `Claude OAuth access token missing in ${sanitizeDisplayText(credentialsPath)}.`,
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
return {
|
|
398
|
+
state: "configured",
|
|
399
|
+
accessToken,
|
|
400
|
+
};
|
|
401
|
+
}
|
|
402
|
+
catch (error) {
|
|
403
|
+
const code = error && typeof error === "object" && "code" in error
|
|
404
|
+
? error.code
|
|
405
|
+
: undefined;
|
|
406
|
+
if (code === "ENOENT") {
|
|
407
|
+
return {
|
|
408
|
+
state: "not-found",
|
|
409
|
+
location: sanitizeDisplayText(credentialsPath),
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
return {
|
|
413
|
+
state: "unavailable",
|
|
414
|
+
detail: `Could not read Claude credentials file: ${sanitizeDisplayText(error instanceof Error ? error.message : String(error))}`,
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
async function readClaudeOAuthAccessToken() {
|
|
419
|
+
const locationsChecked = [];
|
|
420
|
+
const unavailableDetails = [];
|
|
421
|
+
const keychainCredentials = await readClaudeCredentialsAccessTokenFromMacOSKeychain();
|
|
422
|
+
if (keychainCredentials?.state === "configured") {
|
|
423
|
+
return { ...keychainCredentials, source: "claude-credentials" };
|
|
424
|
+
}
|
|
425
|
+
if (keychainCredentials?.state === "unavailable") {
|
|
426
|
+
unavailableDetails.push(keychainCredentials.detail);
|
|
427
|
+
}
|
|
428
|
+
if (keychainCredentials?.state === "not-found") {
|
|
429
|
+
locationsChecked.push(keychainCredentials.location);
|
|
430
|
+
}
|
|
431
|
+
const fileCredentials = await readClaudeCredentialsAccessTokenFromFile();
|
|
432
|
+
if (fileCredentials.state === "configured") {
|
|
433
|
+
return { ...fileCredentials, source: "claude-credentials" };
|
|
434
|
+
}
|
|
435
|
+
if (fileCredentials.state === "unavailable") {
|
|
436
|
+
unavailableDetails.push(fileCredentials.detail);
|
|
437
|
+
}
|
|
438
|
+
if (fileCredentials.state === "not-found") {
|
|
439
|
+
locationsChecked.push(fileCredentials.location);
|
|
440
|
+
}
|
|
441
|
+
return {
|
|
442
|
+
state: "unavailable",
|
|
443
|
+
detail: unavailableDetails[0] ?? getClaudeCredentialsNotFoundDetail(locationsChecked),
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
async function readAnthropicOAuthAccessToken(options) {
|
|
447
|
+
const opencodeCredentials = await resolveAnthropicOAuthCached();
|
|
448
|
+
if (opencodeCredentials.state === "configured") {
|
|
449
|
+
return {
|
|
450
|
+
state: "configured",
|
|
451
|
+
accessToken: opencodeCredentials.accessToken,
|
|
452
|
+
source: "opencode-auth",
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
return options.includeClaudeCredentials
|
|
456
|
+
? await readClaudeOAuthAccessToken()
|
|
457
|
+
: { state: "unavailable" };
|
|
458
|
+
}
|
|
459
|
+
function fingerprintAccessToken(accessToken) {
|
|
460
|
+
return createHash("sha256").update(accessToken).digest("hex");
|
|
461
|
+
}
|
|
462
|
+
function parseRetryAfterMs(value, nowMs) {
|
|
463
|
+
const trimmed = value?.trim();
|
|
464
|
+
if (!trimmed) {
|
|
465
|
+
return undefined;
|
|
466
|
+
}
|
|
467
|
+
if (/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(trimmed)) {
|
|
468
|
+
const seconds = Number(trimmed);
|
|
469
|
+
return Number.isFinite(seconds) && seconds > 0 ? seconds * 1_000 : undefined;
|
|
470
|
+
}
|
|
471
|
+
const retryAtMs = Date.parse(trimmed);
|
|
472
|
+
const durationMs = retryAtMs - nowMs;
|
|
473
|
+
return Number.isFinite(durationMs) && durationMs > 0 ? durationMs : undefined;
|
|
474
|
+
}
|
|
475
|
+
function getAnthropicOAuthCooldownDurationMs(failureCount, retryAfter, nowMs) {
|
|
476
|
+
const exponentialMs = Math.min(ANTHROPIC_OAUTH_COOLDOWN_MAX_MS, ANTHROPIC_OAUTH_BACKOFF_BASE_MS * 2 ** Math.min(failureCount, 30));
|
|
477
|
+
const retryAfterMs = Math.min(ANTHROPIC_OAUTH_COOLDOWN_MAX_MS, parseRetryAfterMs(retryAfter, nowMs) ?? 0);
|
|
478
|
+
return Math.max(exponentialMs, retryAfterMs);
|
|
479
|
+
}
|
|
480
|
+
function getAnthropicOAuthCooldownMessage(remainingMs) {
|
|
481
|
+
const boundedRemainingMs = Math.min(ANTHROPIC_OAUTH_COOLDOWN_MAX_MS, Math.max(0, remainingMs));
|
|
482
|
+
return `Anthropic OAuth usage probe paused after HTTP 429; retry in ${Math.ceil(boundedRemainingMs / 1_000)}s.`;
|
|
483
|
+
}
|
|
484
|
+
function retainAnthropicOAuthCooldownForToken(tokenFingerprint) {
|
|
485
|
+
const targetSize = anthropicOAuthCooldowns.has(tokenFingerprint)
|
|
486
|
+
? ANTHROPIC_OAUTH_COOLDOWN_MAX_ENTRIES
|
|
487
|
+
: ANTHROPIC_OAUTH_COOLDOWN_MAX_ENTRIES - 1;
|
|
488
|
+
const oldestFirst = [...anthropicOAuthCooldowns.entries()].sort(([, left], [, right]) => left.blockedUntilMs - right.blockedUntilMs);
|
|
489
|
+
for (const [fingerprint] of oldestFirst) {
|
|
490
|
+
if (anthropicOAuthCooldowns.size <= targetSize)
|
|
491
|
+
break;
|
|
492
|
+
if (fingerprint !== tokenFingerprint)
|
|
493
|
+
anthropicOAuthCooldowns.delete(fingerprint);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
function redactAccessTokenFromSanitizedDetail(detail, accessToken) {
|
|
497
|
+
const sanitizedDetail = sanitizeDisplayText(detail);
|
|
498
|
+
const sanitizedAccessToken = sanitizeDisplayText(accessToken);
|
|
499
|
+
const redactedDetail = sanitizedDetail.split(accessToken).join("[redacted]");
|
|
500
|
+
return sanitizedAccessToken
|
|
501
|
+
? redactedDetail.split(sanitizedAccessToken).join("[redacted]")
|
|
502
|
+
: redactedDetail;
|
|
503
|
+
}
|
|
504
|
+
function sanitizeAnthropicApiDetail(detail, accessToken) {
|
|
505
|
+
return redactAccessTokenFromSanitizedDetail(detail, accessToken).slice(0, 120);
|
|
506
|
+
}
|
|
507
|
+
function sanitizeAnthropicRequestError(detail, accessToken) {
|
|
508
|
+
return redactAccessTokenFromSanitizedDetail(detail, accessToken);
|
|
509
|
+
}
|
|
510
|
+
async function performAnthropicOAuthUsageRequest(accessToken, tokenFingerprint, requestTimeoutMs) {
|
|
511
|
+
try {
|
|
512
|
+
return await fetchWithTimeout(ANTHROPIC_USAGE_URL, {
|
|
513
|
+
request: {
|
|
514
|
+
headers: {
|
|
515
|
+
Authorization: `Bearer ${accessToken}`,
|
|
516
|
+
"anthropic-beta": ANTHROPIC_BETA_HEADER,
|
|
517
|
+
},
|
|
518
|
+
},
|
|
519
|
+
timeoutMs: requestTimeoutMs,
|
|
520
|
+
consume: async (response, timeoutSignal) => {
|
|
521
|
+
if (response.status === 429) {
|
|
522
|
+
const nowMs = Date.now();
|
|
523
|
+
const previousFailureCount = anthropicOAuthCooldowns.get(tokenFingerprint)?.failureCount ?? 0;
|
|
524
|
+
const durationMs = getAnthropicOAuthCooldownDurationMs(previousFailureCount, response.headers?.get?.("Retry-After") ?? null, nowMs);
|
|
525
|
+
anthropicOAuthCooldowns.set(tokenFingerprint, {
|
|
526
|
+
failureCount: previousFailureCount + 1,
|
|
527
|
+
blockedUntilMs: nowMs + durationMs,
|
|
528
|
+
});
|
|
529
|
+
let detail = "";
|
|
530
|
+
try {
|
|
531
|
+
detail = sanitizeAnthropicApiDetail(await response.text(), accessToken);
|
|
532
|
+
}
|
|
533
|
+
catch (error) {
|
|
534
|
+
if (timeoutSignal.aborted)
|
|
535
|
+
throw error;
|
|
536
|
+
detail = "";
|
|
537
|
+
}
|
|
538
|
+
const errorDetail = detail
|
|
539
|
+
? `Anthropic API error ${response.status}: ${detail}`
|
|
540
|
+
: `Anthropic API returned ${response.status}`;
|
|
541
|
+
return {
|
|
542
|
+
state: "unavailable",
|
|
543
|
+
detail: `${errorDetail} ${getAnthropicOAuthCooldownMessage(durationMs)}`,
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
anthropicOAuthCooldowns.delete(tokenFingerprint);
|
|
547
|
+
if (!response.ok) {
|
|
548
|
+
const authenticationFailure = response.status === 401 || response.status === 403;
|
|
549
|
+
let detail = "";
|
|
550
|
+
try {
|
|
551
|
+
detail = sanitizeAnthropicApiDetail(await response.text(), accessToken);
|
|
552
|
+
}
|
|
553
|
+
catch (error) {
|
|
554
|
+
if (timeoutSignal.aborted && !authenticationFailure)
|
|
555
|
+
throw error;
|
|
556
|
+
detail = "";
|
|
557
|
+
}
|
|
558
|
+
return {
|
|
559
|
+
state: "unavailable",
|
|
560
|
+
detail: detail
|
|
561
|
+
? `Anthropic API error ${response.status}: ${detail}`
|
|
562
|
+
: `Anthropic API returned ${response.status}`,
|
|
563
|
+
...(authenticationFailure ? { failureKind: "authentication" } : {}),
|
|
564
|
+
};
|
|
565
|
+
}
|
|
566
|
+
let data;
|
|
567
|
+
try {
|
|
568
|
+
data = await response.json();
|
|
569
|
+
}
|
|
570
|
+
catch (error) {
|
|
571
|
+
if (timeoutSignal.aborted)
|
|
572
|
+
throw error;
|
|
573
|
+
return {
|
|
574
|
+
state: "unavailable",
|
|
575
|
+
detail: "Failed to parse Anthropic quota response",
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
const quota = parseOAuthUsageResponse(data);
|
|
579
|
+
if (!quota) {
|
|
580
|
+
return {
|
|
581
|
+
state: "unavailable",
|
|
582
|
+
detail: "Unexpected Anthropic quota response shape",
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
return {
|
|
586
|
+
state: "success",
|
|
587
|
+
quota,
|
|
588
|
+
};
|
|
589
|
+
},
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
catch (error) {
|
|
593
|
+
return {
|
|
594
|
+
state: "unavailable",
|
|
595
|
+
detail: sanitizeAnthropicRequestError(error instanceof Error ? error.message : String(error), accessToken),
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
async function queryAnthropicQuotaFromOAuthAccessToken(accessToken, requestTimeoutMs) {
|
|
600
|
+
const tokenFingerprint = fingerprintAccessToken(accessToken);
|
|
601
|
+
retainAnthropicOAuthCooldownForToken(tokenFingerprint);
|
|
602
|
+
const nowMs = Date.now();
|
|
603
|
+
const cooldown = anthropicOAuthCooldowns.get(tokenFingerprint);
|
|
604
|
+
if (cooldown && cooldown.blockedUntilMs > nowMs) {
|
|
605
|
+
return {
|
|
606
|
+
state: "unavailable",
|
|
607
|
+
detail: getAnthropicOAuthCooldownMessage(cooldown.blockedUntilMs - nowMs),
|
|
608
|
+
};
|
|
609
|
+
}
|
|
610
|
+
const existingInFlight = anthropicOAuthInFlight.get(tokenFingerprint);
|
|
611
|
+
if (existingInFlight) {
|
|
612
|
+
return await existingInFlight;
|
|
613
|
+
}
|
|
614
|
+
const inFlight = performAnthropicOAuthUsageRequest(accessToken, tokenFingerprint, requestTimeoutMs);
|
|
615
|
+
anthropicOAuthInFlight.set(tokenFingerprint, inFlight);
|
|
616
|
+
try {
|
|
617
|
+
return await inFlight;
|
|
618
|
+
}
|
|
619
|
+
finally {
|
|
620
|
+
if (anthropicOAuthInFlight.get(tokenFingerprint) === inFlight) {
|
|
621
|
+
anthropicOAuthInFlight.delete(tokenFingerprint);
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
export async function queryAnthropicQuotaWithOAuth(accessToken, requestTimeoutMs) {
|
|
626
|
+
const result = await queryAnthropicQuotaFromOAuthAccessToken(accessToken, requestTimeoutMs);
|
|
627
|
+
return result.state === "success"
|
|
628
|
+
? result.quota
|
|
629
|
+
: { success: false, error: result.detail ?? "Anthropic OAuth quota unavailable" };
|
|
630
|
+
}
|
|
631
|
+
function extractAuthBoolean(data) {
|
|
632
|
+
const record = asRecord(data);
|
|
633
|
+
if (!record) {
|
|
634
|
+
return undefined;
|
|
635
|
+
}
|
|
636
|
+
for (const candidate of [
|
|
637
|
+
record["authenticated"],
|
|
638
|
+
record["isAuthenticated"],
|
|
639
|
+
record["loggedIn"],
|
|
640
|
+
]) {
|
|
641
|
+
if (typeof candidate === "boolean") {
|
|
642
|
+
return candidate;
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
const authRecord = asRecord(record["auth"]);
|
|
646
|
+
if (authRecord) {
|
|
647
|
+
for (const candidate of [authRecord["authenticated"], authRecord["loggedIn"]]) {
|
|
648
|
+
if (typeof candidate === "boolean") {
|
|
649
|
+
return candidate;
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
const status = record["status"];
|
|
654
|
+
if (typeof status === "string") {
|
|
655
|
+
const normalized = status.trim().toLowerCase();
|
|
656
|
+
if (normalized === "authenticated") {
|
|
657
|
+
return true;
|
|
658
|
+
}
|
|
659
|
+
if (normalized === "unauthenticated") {
|
|
660
|
+
return false;
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
return undefined;
|
|
664
|
+
}
|
|
665
|
+
function hasUnsupportedCommandText(output) {
|
|
666
|
+
const normalized = output.toLowerCase();
|
|
667
|
+
return (normalized.includes("unknown command") ||
|
|
668
|
+
normalized.includes("unrecognized command") ||
|
|
669
|
+
normalized.includes("unexpected argument"));
|
|
670
|
+
}
|
|
671
|
+
function hasUnauthenticatedText(output) {
|
|
672
|
+
const normalized = output.toLowerCase();
|
|
673
|
+
return (normalized.includes("not logged in") ||
|
|
674
|
+
normalized.includes("login required") ||
|
|
675
|
+
normalized.includes("authentication required") ||
|
|
676
|
+
normalized.includes("run `claude login`") ||
|
|
677
|
+
normalized.includes("run `claude auth login`") ||
|
|
678
|
+
normalized.includes("run claude login") ||
|
|
679
|
+
normalized.includes("run claude auth login"));
|
|
680
|
+
}
|
|
681
|
+
function detailFromCommandResult(result) {
|
|
682
|
+
const detail = `${result.stderr}\n${result.stdout}\n${result.errorMessage ?? ""}`.trim();
|
|
683
|
+
return detail ? sanitizeDisplaySnippet(detail, 160) : undefined;
|
|
684
|
+
}
|
|
685
|
+
function parseVersion(output) {
|
|
686
|
+
const match = output.match(/\b\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?\b/);
|
|
687
|
+
return match ? match[0] : null;
|
|
688
|
+
}
|
|
689
|
+
function isCommandMissing(result) {
|
|
690
|
+
if (result.spawnErrorCode === "ENOENT") {
|
|
691
|
+
return true;
|
|
692
|
+
}
|
|
693
|
+
const output = `${result.stderr}\n${result.stdout}\n${result.errorMessage ?? ""}`.toLowerCase();
|
|
694
|
+
return (output.includes("command not found") ||
|
|
695
|
+
output.includes("not recognized as an internal or external command") ||
|
|
696
|
+
output.includes("no such file or directory"));
|
|
697
|
+
}
|
|
698
|
+
function isTimedOutError(error) {
|
|
699
|
+
return (error.code === "ETIMEDOUT" ||
|
|
700
|
+
error.killed === true ||
|
|
701
|
+
error.message.toLowerCase().includes("timed out"));
|
|
702
|
+
}
|
|
703
|
+
async function runClaudeCommand(invocation) {
|
|
704
|
+
return await new Promise((resolve, reject) => {
|
|
705
|
+
try {
|
|
706
|
+
execFile(invocation.file, invocation.args, {
|
|
707
|
+
encoding: "utf8",
|
|
708
|
+
timeout: CLAUDE_COMMAND_TIMEOUT_MS,
|
|
709
|
+
maxBuffer: 1024 * 1024,
|
|
710
|
+
}, (error, stdout, stderr) => {
|
|
711
|
+
const stdoutText = typeof stdout === "string" ? stdout : stdout.toString("utf8");
|
|
712
|
+
const stderrText = typeof stderr === "string" ? stderr : stderr.toString("utf8");
|
|
713
|
+
if (!error) {
|
|
714
|
+
resolve({
|
|
715
|
+
code: 0,
|
|
716
|
+
stdout: stdoutText,
|
|
717
|
+
stderr: stderrText,
|
|
718
|
+
timedOut: false,
|
|
719
|
+
});
|
|
720
|
+
return;
|
|
721
|
+
}
|
|
722
|
+
const execError = error;
|
|
723
|
+
resolve({
|
|
724
|
+
code: typeof execError.code === "number" ? execError.code : null,
|
|
725
|
+
stdout: stdoutText,
|
|
726
|
+
stderr: stderrText,
|
|
727
|
+
timedOut: isTimedOutError(execError),
|
|
728
|
+
spawnErrorCode: execError.code,
|
|
729
|
+
errorMessage: execError.message,
|
|
730
|
+
});
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
catch (error) {
|
|
734
|
+
reject(error);
|
|
735
|
+
}
|
|
736
|
+
});
|
|
737
|
+
}
|
|
738
|
+
function parseClaudeAuthStatusResult(result) {
|
|
739
|
+
const combinedOutput = `${result.stdout}\n${result.stderr}`;
|
|
740
|
+
if (hasUnsupportedCommandText(combinedOutput)) {
|
|
741
|
+
return {
|
|
742
|
+
authStatus: "unknown",
|
|
743
|
+
unsupportedCommand: true,
|
|
744
|
+
message: "Claude CLI authentication status JSON is unavailable in this version of Claude.",
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
if (hasUnauthenticatedText(combinedOutput)) {
|
|
748
|
+
return {
|
|
749
|
+
authStatus: "unauthenticated",
|
|
750
|
+
message: "Claude is not authenticated. Run `claude auth login` and try again.",
|
|
751
|
+
};
|
|
752
|
+
}
|
|
753
|
+
const trimmed = result.stdout.trim();
|
|
754
|
+
if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
|
|
755
|
+
try {
|
|
756
|
+
const payload = JSON.parse(trimmed);
|
|
757
|
+
const auth = extractAuthBoolean(payload);
|
|
758
|
+
if (auth === true) {
|
|
759
|
+
return {
|
|
760
|
+
authStatus: "authenticated",
|
|
761
|
+
jsonPayload: payload,
|
|
762
|
+
};
|
|
763
|
+
}
|
|
764
|
+
if (auth === false) {
|
|
765
|
+
return {
|
|
766
|
+
authStatus: "unauthenticated",
|
|
767
|
+
message: "Claude is not authenticated. Run `claude auth login` and try again.",
|
|
768
|
+
jsonPayload: payload,
|
|
769
|
+
};
|
|
770
|
+
}
|
|
771
|
+
return {
|
|
772
|
+
authStatus: "unknown",
|
|
773
|
+
message: "Could not verify Claude authentication status from JSON output.",
|
|
774
|
+
jsonPayload: payload,
|
|
775
|
+
};
|
|
776
|
+
}
|
|
777
|
+
catch {
|
|
778
|
+
// Fall through to exit-code-based handling.
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
if (result.code === 0) {
|
|
782
|
+
return { authStatus: "authenticated" };
|
|
783
|
+
}
|
|
784
|
+
if (result.timedOut) {
|
|
785
|
+
return {
|
|
786
|
+
authStatus: "unknown",
|
|
787
|
+
message: "Timed out while running Claude CLI auth status.",
|
|
788
|
+
};
|
|
789
|
+
}
|
|
790
|
+
const detail = detailFromCommandResult(result);
|
|
791
|
+
return {
|
|
792
|
+
authStatus: "unknown",
|
|
793
|
+
message: detail
|
|
794
|
+
? `Could not verify Claude authentication status. ${detail}`
|
|
795
|
+
: "Could not verify Claude authentication status.",
|
|
796
|
+
};
|
|
797
|
+
}
|
|
798
|
+
function mapLocalDiagnosticsToAnthropicDiagnostics(localDiagnostics) {
|
|
799
|
+
if (localDiagnostics.localQuota) {
|
|
800
|
+
return {
|
|
801
|
+
installed: localDiagnostics.installed,
|
|
802
|
+
version: localDiagnostics.version,
|
|
803
|
+
authStatus: localDiagnostics.authStatus,
|
|
804
|
+
quotaSupported: true,
|
|
805
|
+
quotaSource: "claude-auth-status-json",
|
|
806
|
+
binaryPath: localDiagnostics.binaryPath,
|
|
807
|
+
checkedCommands: localDiagnostics.checkedCommands,
|
|
808
|
+
quota: localDiagnostics.localQuota,
|
|
809
|
+
};
|
|
810
|
+
}
|
|
811
|
+
const diagnostics = {
|
|
812
|
+
installed: localDiagnostics.installed,
|
|
813
|
+
version: localDiagnostics.version,
|
|
814
|
+
authStatus: localDiagnostics.authStatus,
|
|
815
|
+
quotaSupported: false,
|
|
816
|
+
quotaSource: "none",
|
|
817
|
+
binaryPath: localDiagnostics.binaryPath,
|
|
818
|
+
checkedCommands: localDiagnostics.checkedCommands,
|
|
819
|
+
};
|
|
820
|
+
if (localDiagnostics.message) {
|
|
821
|
+
diagnostics.message = localDiagnostics.message;
|
|
822
|
+
}
|
|
823
|
+
return diagnostics;
|
|
824
|
+
}
|
|
825
|
+
async function runClaudeVersionCommand(binaryPath, checkedCommands) {
|
|
826
|
+
const versionCommand = buildClaudeCommandInvocation(binaryPath, ["--version"]);
|
|
827
|
+
checkedCommands.push(versionCommand.display);
|
|
828
|
+
return await runClaudeCommand(versionCommand);
|
|
829
|
+
}
|
|
830
|
+
async function probeAnthropicLocalDiagnostics(options = {}) {
|
|
831
|
+
const configuredBinaryPath = resolveAnthropicBinaryPath(options.binaryPath);
|
|
832
|
+
const checkedCommands = [];
|
|
833
|
+
let binaryPath = configuredBinaryPath;
|
|
834
|
+
let versionResult = await runClaudeVersionCommand(binaryPath, checkedCommands);
|
|
835
|
+
// No configured path and no `claude` on PATH: the first install folder whose CLI runs wins.
|
|
836
|
+
const installFolderCandidates = configuredBinaryPath === DEFAULT_CLAUDE_BINARY ? claudeInstallFolderCandidates() : [];
|
|
837
|
+
if (isCommandMissing(versionResult)) {
|
|
838
|
+
for (const candidate of installFolderCandidates) {
|
|
839
|
+
if (!existsSync(candidate))
|
|
840
|
+
continue;
|
|
841
|
+
binaryPath = candidate;
|
|
842
|
+
versionResult = await runClaudeVersionCommand(candidate, checkedCommands);
|
|
843
|
+
if (!isCommandMissing(versionResult))
|
|
844
|
+
break;
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
if (isCommandMissing(versionResult)) {
|
|
848
|
+
const alsoChecked = installFolderCandidates.length > 0
|
|
849
|
+
? ` Also checked: ${installFolderCandidates.map((candidate) => sanitizeDisplayText(candidate)).join(", ")}.`
|
|
850
|
+
: "";
|
|
851
|
+
return {
|
|
852
|
+
installed: false,
|
|
853
|
+
version: null,
|
|
854
|
+
authStatus: "unknown",
|
|
855
|
+
binaryPath: null,
|
|
856
|
+
checkedCommands,
|
|
857
|
+
message: `Claude CLI (\`${sanitizeDisplayText(configuredBinaryPath)}\`) is not installed or not on PATH.${alsoChecked}`,
|
|
858
|
+
};
|
|
859
|
+
}
|
|
860
|
+
const binaryPathDisplay = binaryPath === DEFAULT_CLAUDE_BINARY ? CLAUDE_ON_PATH_DISPLAY : binaryPath;
|
|
861
|
+
const version = parseVersion(`${versionResult.stdout}\n${versionResult.stderr}`);
|
|
862
|
+
const authStatusJsonCommand = buildClaudeCommandInvocation(binaryPath, [
|
|
863
|
+
"auth",
|
|
864
|
+
"status",
|
|
865
|
+
"--json",
|
|
866
|
+
]);
|
|
867
|
+
checkedCommands.push(authStatusJsonCommand.display);
|
|
868
|
+
const authJsonResult = await runClaudeCommand(authStatusJsonCommand);
|
|
869
|
+
let parsedAuth = parseClaudeAuthStatusResult(authJsonResult);
|
|
870
|
+
if (parsedAuth.unsupportedCommand) {
|
|
871
|
+
const authStatusCommand = buildClaudeCommandInvocation(binaryPath, ["auth", "status"]);
|
|
872
|
+
checkedCommands.push(authStatusCommand.display);
|
|
873
|
+
parsedAuth = parseClaudeAuthStatusResult(await runClaudeCommand(authStatusCommand));
|
|
874
|
+
}
|
|
875
|
+
if (parsedAuth.authStatus !== "authenticated") {
|
|
876
|
+
return {
|
|
877
|
+
installed: true,
|
|
878
|
+
version,
|
|
879
|
+
authStatus: parsedAuth.authStatus,
|
|
880
|
+
binaryPath: binaryPathDisplay,
|
|
881
|
+
checkedCommands,
|
|
882
|
+
message: parsedAuth.message,
|
|
883
|
+
};
|
|
884
|
+
}
|
|
885
|
+
const quota = parsedAuth.jsonPayload ? parseUsageResponse(parsedAuth.jsonPayload) : null;
|
|
886
|
+
if (quota) {
|
|
887
|
+
return {
|
|
888
|
+
installed: true,
|
|
889
|
+
version,
|
|
890
|
+
authStatus: "authenticated",
|
|
891
|
+
binaryPath: binaryPathDisplay,
|
|
892
|
+
checkedCommands,
|
|
893
|
+
localQuota: quota,
|
|
894
|
+
};
|
|
895
|
+
}
|
|
896
|
+
return {
|
|
897
|
+
installed: true,
|
|
898
|
+
version,
|
|
899
|
+
authStatus: "authenticated",
|
|
900
|
+
binaryPath: binaryPathDisplay,
|
|
901
|
+
checkedCommands,
|
|
902
|
+
message: CLAUDE_NO_LOCAL_QUOTA_MESSAGE,
|
|
903
|
+
};
|
|
904
|
+
}
|
|
905
|
+
export function clearAnthropicDiagnosticsCacheForTests() {
|
|
906
|
+
diagnosticsCache.clear();
|
|
907
|
+
localDiagnosticsCache.clear();
|
|
908
|
+
anthropicOAuthCooldowns.clear();
|
|
909
|
+
anthropicOAuthInFlight.clear();
|
|
910
|
+
}
|
|
911
|
+
async function getCachedAnthropicLocalDiagnostics(options = {}) {
|
|
912
|
+
const binaryPath = resolveAnthropicBinaryPath(options.binaryPath);
|
|
913
|
+
const now = Date.now();
|
|
914
|
+
const cached = localDiagnosticsCache.get(binaryPath) ?? {
|
|
915
|
+
timestamp: 0,
|
|
916
|
+
value: null,
|
|
917
|
+
};
|
|
918
|
+
if (cached.value &&
|
|
919
|
+
cached.timestamp > 0 &&
|
|
920
|
+
now - cached.timestamp < ANTHROPIC_DIAGNOSTICS_TTL_MS) {
|
|
921
|
+
return cached.value;
|
|
922
|
+
}
|
|
923
|
+
if (cached.inFlight) {
|
|
924
|
+
return cached.inFlight;
|
|
925
|
+
}
|
|
926
|
+
const inFlight = probeAnthropicLocalDiagnostics({ binaryPath }).then((value) => {
|
|
927
|
+
localDiagnosticsCache.set(binaryPath, {
|
|
928
|
+
timestamp: Date.now(),
|
|
929
|
+
value,
|
|
930
|
+
});
|
|
931
|
+
return value;
|
|
932
|
+
});
|
|
933
|
+
localDiagnosticsCache.set(binaryPath, {
|
|
934
|
+
timestamp: cached.timestamp,
|
|
935
|
+
value: cached.value,
|
|
936
|
+
inFlight,
|
|
937
|
+
});
|
|
938
|
+
try {
|
|
939
|
+
return await inFlight;
|
|
940
|
+
}
|
|
941
|
+
finally {
|
|
942
|
+
const latest = localDiagnosticsCache.get(binaryPath);
|
|
943
|
+
if (latest?.inFlight === inFlight) {
|
|
944
|
+
localDiagnosticsCache.set(binaryPath, {
|
|
945
|
+
timestamp: latest.timestamp,
|
|
946
|
+
value: latest.value,
|
|
947
|
+
});
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
export async function getAnthropicDiagnostics(options = {}) {
|
|
952
|
+
const binaryPath = resolveAnthropicBinaryPath(options.binaryPath);
|
|
953
|
+
const now = Date.now();
|
|
954
|
+
const cached = diagnosticsCache.get(binaryPath) ?? {
|
|
955
|
+
timestamp: 0,
|
|
956
|
+
value: null,
|
|
957
|
+
};
|
|
958
|
+
if (cached.value &&
|
|
959
|
+
cached.timestamp > 0 &&
|
|
960
|
+
now - cached.timestamp < ANTHROPIC_DIAGNOSTICS_TTL_MS) {
|
|
961
|
+
return cached.value;
|
|
962
|
+
}
|
|
963
|
+
if (cached.inFlight) {
|
|
964
|
+
return cached.inFlight;
|
|
965
|
+
}
|
|
966
|
+
const inFlight = (async () => {
|
|
967
|
+
const localDiagnostics = await getCachedAnthropicLocalDiagnostics({ binaryPath });
|
|
968
|
+
if (localDiagnostics.localQuota) {
|
|
969
|
+
return mapLocalDiagnosticsToAnthropicDiagnostics(localDiagnostics);
|
|
970
|
+
}
|
|
971
|
+
let credentials = await readAnthropicOAuthAccessToken({
|
|
972
|
+
includeClaudeCredentials: localDiagnostics.authStatus === "authenticated",
|
|
973
|
+
});
|
|
974
|
+
if (credentials.state !== "configured") {
|
|
975
|
+
if (localDiagnostics.authStatus !== "authenticated") {
|
|
976
|
+
return mapLocalDiagnosticsToAnthropicDiagnostics(localDiagnostics);
|
|
977
|
+
}
|
|
978
|
+
const diagnostics = {
|
|
979
|
+
installed: localDiagnostics.installed,
|
|
980
|
+
version: localDiagnostics.version,
|
|
981
|
+
authStatus: localDiagnostics.authStatus,
|
|
982
|
+
quotaSupported: false,
|
|
983
|
+
quotaSource: "none",
|
|
984
|
+
binaryPath: localDiagnostics.binaryPath,
|
|
985
|
+
checkedCommands: localDiagnostics.checkedCommands,
|
|
986
|
+
message: buildAnthropicNoQuotaDiagnosticsMessage(credentials.detail),
|
|
987
|
+
};
|
|
988
|
+
return diagnostics;
|
|
989
|
+
}
|
|
990
|
+
let fallbackQuota = await queryAnthropicQuotaFromOAuthAccessToken(credentials.accessToken, options.requestTimeoutMs);
|
|
991
|
+
if (fallbackQuota.state === "unavailable" &&
|
|
992
|
+
fallbackQuota.failureKind === "authentication" &&
|
|
993
|
+
credentials.source === "opencode-auth" &&
|
|
994
|
+
localDiagnostics.authStatus === "authenticated") {
|
|
995
|
+
const claudeCredentials = await readClaudeOAuthAccessToken();
|
|
996
|
+
if (claudeCredentials.state === "configured") {
|
|
997
|
+
credentials = claudeCredentials;
|
|
998
|
+
fallbackQuota = await queryAnthropicQuotaFromOAuthAccessToken(claudeCredentials.accessToken, options.requestTimeoutMs);
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
if (fallbackQuota.state !== "success") {
|
|
1002
|
+
const diagnostics = {
|
|
1003
|
+
installed: localDiagnostics.installed,
|
|
1004
|
+
version: localDiagnostics.version,
|
|
1005
|
+
authStatus: localDiagnostics.authStatus,
|
|
1006
|
+
quotaSupported: false,
|
|
1007
|
+
quotaSource: "none",
|
|
1008
|
+
oauthCredentialSource: credentials.source,
|
|
1009
|
+
binaryPath: localDiagnostics.binaryPath,
|
|
1010
|
+
checkedCommands: localDiagnostics.checkedCommands,
|
|
1011
|
+
message: buildAnthropicNoQuotaDiagnosticsMessage(fallbackQuota.detail),
|
|
1012
|
+
};
|
|
1013
|
+
return diagnostics;
|
|
1014
|
+
}
|
|
1015
|
+
const diagnostics = {
|
|
1016
|
+
installed: localDiagnostics.installed,
|
|
1017
|
+
version: localDiagnostics.version,
|
|
1018
|
+
authStatus: localDiagnostics.authStatus,
|
|
1019
|
+
quotaSupported: true,
|
|
1020
|
+
quotaSource: credentials.source === "opencode-auth"
|
|
1021
|
+
? "opencode-auth-oauth-api"
|
|
1022
|
+
: "claude-credentials-oauth-api",
|
|
1023
|
+
oauthCredentialSource: credentials.source,
|
|
1024
|
+
binaryPath: localDiagnostics.binaryPath,
|
|
1025
|
+
checkedCommands: localDiagnostics.checkedCommands,
|
|
1026
|
+
quota: fallbackQuota.quota,
|
|
1027
|
+
};
|
|
1028
|
+
return diagnostics;
|
|
1029
|
+
})().then((value) => {
|
|
1030
|
+
diagnosticsCache.set(binaryPath, {
|
|
1031
|
+
timestamp: Date.now(),
|
|
1032
|
+
value,
|
|
1033
|
+
});
|
|
1034
|
+
return value;
|
|
1035
|
+
});
|
|
1036
|
+
diagnosticsCache.set(binaryPath, {
|
|
1037
|
+
timestamp: cached.timestamp,
|
|
1038
|
+
value: cached.value,
|
|
1039
|
+
inFlight,
|
|
1040
|
+
});
|
|
1041
|
+
try {
|
|
1042
|
+
return await inFlight;
|
|
1043
|
+
}
|
|
1044
|
+
finally {
|
|
1045
|
+
const latest = diagnosticsCache.get(binaryPath);
|
|
1046
|
+
if (latest?.inFlight === inFlight) {
|
|
1047
|
+
diagnosticsCache.set(binaryPath, {
|
|
1048
|
+
timestamp: latest.timestamp,
|
|
1049
|
+
value: latest.value,
|
|
1050
|
+
});
|
|
1051
|
+
}
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
export async function hasAnthropicCredentialsConfigured(options = {}) {
|
|
1055
|
+
try {
|
|
1056
|
+
const opencodeCredentials = await resolveAnthropicOAuthCached();
|
|
1057
|
+
// A login OpenCode could not return still counts, so it shows as an error.
|
|
1058
|
+
if (opencodeCredentials.state === "configured" || opencodeCredentials.state === "failed") {
|
|
1059
|
+
return true;
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
catch {
|
|
1063
|
+
// Fall back to the existing local Claude CLI probe.
|
|
1064
|
+
}
|
|
1065
|
+
try {
|
|
1066
|
+
const diagnostics = await getCachedAnthropicLocalDiagnostics(options);
|
|
1067
|
+
return diagnostics.installed && diagnostics.authStatus === "authenticated";
|
|
1068
|
+
}
|
|
1069
|
+
catch {
|
|
1070
|
+
return false;
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
export async function resolveAnthropicAuthIdentity(options = {}) {
|
|
1074
|
+
let localDiagnostics;
|
|
1075
|
+
try {
|
|
1076
|
+
localDiagnostics = await getCachedAnthropicLocalDiagnostics(options);
|
|
1077
|
+
}
|
|
1078
|
+
catch {
|
|
1079
|
+
return null;
|
|
1080
|
+
}
|
|
1081
|
+
// Claude CLI quota does not expose an account identity. Keep that winning
|
|
1082
|
+
// path process-local rather than risking reuse after a CLI account switch.
|
|
1083
|
+
if (localDiagnostics.localQuota)
|
|
1084
|
+
return null;
|
|
1085
|
+
const opencodeCredentials = await resolveAnthropicOAuthCached();
|
|
1086
|
+
const opencodeIdentity = opencodeCredentials.state === "configured"
|
|
1087
|
+
? await deriveResolvedAuthIdentity({
|
|
1088
|
+
providerId: "anthropic:opencode-auth",
|
|
1089
|
+
principal: { kind: "credential", value: opencodeCredentials.accessToken },
|
|
1090
|
+
})
|
|
1091
|
+
: null;
|
|
1092
|
+
if (localDiagnostics.authStatus !== "authenticated") {
|
|
1093
|
+
return opencodeIdentity;
|
|
1094
|
+
}
|
|
1095
|
+
const claudeCredentials = await readClaudeOAuthAccessToken();
|
|
1096
|
+
const claudeIdentity = claudeCredentials.state === "configured"
|
|
1097
|
+
? await deriveResolvedAuthIdentity({
|
|
1098
|
+
providerId: "anthropic:claude-credentials",
|
|
1099
|
+
principal: { kind: "credential", value: claudeCredentials.accessToken },
|
|
1100
|
+
})
|
|
1101
|
+
: null;
|
|
1102
|
+
if (opencodeIdentity && claudeIdentity) {
|
|
1103
|
+
return composeResolvedAuthIdentities({
|
|
1104
|
+
providerId: "anthropic",
|
|
1105
|
+
identities: [opencodeIdentity, claudeIdentity],
|
|
1106
|
+
});
|
|
1107
|
+
}
|
|
1108
|
+
return opencodeIdentity ?? claudeIdentity;
|
|
1109
|
+
}
|
|
1110
|
+
export async function queryAnthropicQuota(options = {}) {
|
|
1111
|
+
try {
|
|
1112
|
+
const diagnostics = await getAnthropicDiagnostics(options);
|
|
1113
|
+
if (diagnostics.quotaSupported) {
|
|
1114
|
+
return diagnostics.quota ?? null;
|
|
1115
|
+
}
|
|
1116
|
+
if ((diagnostics.authStatus === "authenticated" ||
|
|
1117
|
+
diagnostics.oauthCredentialSource !== undefined) &&
|
|
1118
|
+
diagnostics.message) {
|
|
1119
|
+
return {
|
|
1120
|
+
success: false,
|
|
1121
|
+
error: diagnostics.message,
|
|
1122
|
+
};
|
|
1123
|
+
}
|
|
1124
|
+
return null;
|
|
1125
|
+
}
|
|
1126
|
+
catch (err) {
|
|
1127
|
+
return {
|
|
1128
|
+
success: false,
|
|
1129
|
+
error: `Claude CLI probe failed: ${sanitizeDisplayText(err instanceof Error ? err.message : String(err))}`,
|
|
1130
|
+
};
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
export { parseOAuthUsageResponse, parseUsageResponse };
|
|
1134
|
+
//# sourceMappingURL=anthropic.js.map
|