opencode-quota-gui 1.2.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +104 -34
- package/dist/contracts/analytics-entity.d.ts +6 -1
- package/dist/contracts/analytics-entity.js +27 -10
- package/dist/contracts/build-identity.js +1 -1
- package/dist/contracts/card-visibility.d.ts +21 -0
- package/dist/contracts/card-visibility.js +19 -0
- package/dist/contracts/dashboard.d.ts +35 -1
- package/dist/contracts/dashboard.js +2 -0
- package/dist/contracts/dto-guards.d.ts +24 -0
- package/dist/contracts/dto-guards.js +594 -0
- package/dist/contracts/openai-quota.d.ts +3 -0
- package/dist/contracts/openai-quota.js +3 -0
- package/dist/contracts/provider-failure.d.ts +18 -0
- package/dist/contracts/provider-failure.js +25 -0
- package/dist/data/modelsdev-temporal.min.json +57 -0
- package/dist/gui/config.d.ts +20 -3
- package/dist/gui/config.js +72 -4
- package/dist/gui/dashboard-errors.d.ts +32 -0
- package/dist/gui/dashboard-errors.js +97 -0
- package/dist/gui/lifecycle.d.ts +47 -12
- package/dist/gui/lifecycle.js +215 -37
- package/dist/gui/primary-quota-windows.d.ts +28 -0
- package/dist/gui/primary-quota-windows.js +149 -0
- package/dist/gui/provider-cards.d.ts +11 -3
- package/dist/gui/provider-cards.js +85 -33
- package/dist/gui/quota-notification-detector.d.ts +151 -0
- package/dist/gui/quota-notification-detector.js +318 -0
- package/dist/gui/quota-notification-observer.d.ts +54 -0
- package/dist/gui/quota-notification-observer.js +412 -0
- package/dist/gui/rpc.d.ts +61 -0
- package/dist/gui/rpc.js +310 -0
- package/dist/gui/server.d.ts +15 -27
- package/dist/gui/server.js +34 -123
- package/dist/gui/snapshot-service.d.ts +34 -5
- package/dist/gui/snapshot-service.js +301 -70
- package/dist/gui/sources.d.ts +1 -1
- package/dist/gui/sources.js +98 -56
- package/dist/gui-experimental.cjs +1761 -0
- package/dist/lib/accounting-format.js +8 -0
- package/dist/lib/alibaba-coding-plan-cli.d.ts +79 -0
- package/dist/lib/alibaba-coding-plan-cli.js +539 -0
- package/dist/lib/anthropic-auth.d.ts +2 -3
- package/dist/lib/anthropic-auth.js +2 -3
- package/dist/lib/anthropic.d.ts +53 -12
- package/dist/lib/anthropic.js +622 -270
- package/dist/lib/api-key-retry-after.d.ts +7 -0
- package/dist/lib/api-key-retry-after.js +62 -0
- package/dist/lib/atomic-json.d.ts +2 -0
- package/dist/lib/atomic-json.js +1 -0
- package/dist/lib/cache-observer-ingestion.d.ts +90 -0
- package/dist/lib/cache-observer-ingestion.js +981 -0
- package/dist/lib/cache-observer.d.ts +138 -0
- package/dist/lib/cache-observer.js +317 -0
- package/dist/lib/canonical-config-lock.d.ts +9 -0
- package/dist/lib/canonical-config-lock.js +36 -0
- package/dist/lib/chutes.js +63 -35
- package/dist/lib/claude-agent-transcript-ttl.d.ts +48 -0
- package/dist/lib/claude-agent-transcript-ttl.js +154 -0
- package/dist/lib/claude-agent-ttl-tracker.d.ts +21 -0
- package/dist/lib/claude-agent-ttl-tracker.js +152 -0
- package/dist/lib/cli-show.js +5 -3
- package/dist/lib/config-write-target.d.ts +1 -1
- package/dist/lib/config-write-target.js +5 -2
- package/dist/lib/config.d.ts +6 -1
- package/dist/lib/config.js +241 -2
- package/dist/lib/copilot.js +198 -85
- package/dist/lib/dashboard-web-policy.d.ts +35 -0
- package/dist/lib/dashboard-web-policy.js +24 -0
- package/dist/lib/deepseek.js +34 -11
- package/dist/lib/display-sanitize.js +3 -0
- package/dist/lib/entries.d.ts +26 -0
- package/dist/lib/entries.js +2 -0
- package/dist/lib/format-utils.d.ts +1 -1
- package/dist/lib/format-utils.js +2 -2
- package/dist/lib/glm-coding-plan.js +102 -68
- package/dist/lib/google-agy.js +147 -24
- package/dist/lib/google-gemini-cli.js +140 -23
- package/dist/lib/http.d.ts +4 -0
- package/dist/lib/http.js +16 -2
- package/dist/lib/init-installer.js +30 -7
- package/dist/lib/kilo.js +63 -55
- package/dist/lib/kimi.js +43 -14
- package/dist/lib/mimo.d.ts +4 -0
- package/dist/lib/mimo.js +45 -1
- package/dist/lib/nanogpt.d.ts +3 -0
- package/dist/lib/nanogpt.js +50 -6
- package/dist/lib/ollama-cloud.d.ts +1 -1
- package/dist/lib/ollama-cloud.js +51 -29
- package/dist/lib/openai.js +90 -40
- package/dist/lib/opencode-auth-sqlite.d.ts +2 -2
- package/dist/lib/opencode-auth-sqlite.js +2 -2
- package/dist/lib/opencode-auth.d.ts +3 -2
- package/dist/lib/opencode-auth.js +8 -1
- package/dist/lib/opencode-config-editor.d.ts +1 -0
- package/dist/lib/opencode-config-editor.js +6 -1
- package/dist/lib/opencode-go.js +53 -5
- package/dist/lib/opencode-version-core.d.ts +23 -0
- package/dist/lib/opencode-version-core.js +49 -0
- package/dist/lib/opencode-version.d.ts +4 -3
- package/dist/lib/opencode-version.js +15 -11
- package/dist/lib/opencode-zen.d.ts +12 -1
- package/dist/lib/opencode-zen.js +98 -12
- package/dist/lib/provider-add.js +5 -2
- package/dist/lib/provider-registration.d.ts +19 -9
- package/dist/lib/provider-registration.js +17 -6
- package/dist/lib/quota-command-format.js +1 -1
- package/dist/lib/quota-exhaustion-projection.d.ts +11 -0
- package/dist/lib/quota-exhaustion-projection.js +25 -0
- package/dist/lib/quota-providers-remote.d.ts +4 -1
- package/dist/lib/quota-providers-remote.js +137 -22
- package/dist/lib/quota-providers.d.ts +1 -1
- package/dist/lib/quota-providers.js +12 -35
- package/dist/lib/quota-render-data.d.ts +6 -0
- package/dist/lib/quota-render-data.js +43 -17
- package/dist/lib/quota-reset-notifications.d.ts +17 -0
- package/dist/lib/quota-reset-notifications.js +11 -2
- package/dist/lib/quota-state-codec.js +19 -1
- package/dist/lib/quota-state.d.ts +7 -1
- package/dist/lib/quota-state.js +208 -34
- package/dist/lib/quota-stats.js +21 -0
- package/dist/lib/quota-status.js +3 -51
- package/dist/lib/scoped-update.d.ts +1 -1
- package/dist/lib/synthetic.js +67 -48
- package/dist/lib/types.d.ts +49 -1
- package/dist/lib/types.js +16 -0
- package/dist/lib/xai.js +64 -24
- package/dist/plugin.d.ts +4 -3
- package/dist/plugin.js +293 -16
- package/dist/provider-logos/NOTICE.md +1 -1
- package/dist/provider-logos/OPENCODE-NOTICE.md +4 -3
- package/dist/providers/alibaba-coding-plan.js +107 -102
- package/dist/providers/alibaba-token-plan.js +17 -0
- package/dist/providers/anthropic.d.ts +12 -3
- package/dist/providers/anthropic.js +71 -219
- package/dist/providers/cache-policies.d.ts +11 -4
- package/dist/providers/cache-policies.js +19 -13
- package/dist/providers/claude-agent.d.ts +19 -0
- package/dist/providers/claude-agent.js +196 -0
- package/dist/providers/copilot.js +12 -2
- package/dist/providers/glm-coding-plan-provider.d.ts +3 -0
- package/dist/providers/glm-coding-plan-provider.js +5 -1
- package/dist/providers/google-account-format.js +2 -0
- package/dist/providers/google-agy.d.ts +6 -5
- package/dist/providers/google-agy.js +55 -17
- package/dist/providers/google-gemini-cli.js +13 -2
- package/dist/providers/kilo.js +10 -1
- package/dist/providers/kimi-code.js +13 -6
- package/dist/providers/mimo.js +9 -2
- package/dist/providers/minimax-coding-plan.js +28 -5
- package/dist/providers/nanogpt.js +4 -0
- package/dist/providers/ollama-cloud.js +3 -0
- package/dist/providers/openai.js +1 -0
- package/dist/providers/opencode-go.js +11 -1
- package/dist/providers/opencode-zen.js +32 -3
- package/dist/providers/openrouter.js +4 -0
- package/dist/providers/quota-providers.js +46 -9
- package/dist/providers/registry.js +2 -0
- package/dist/providers/result-helpers.d.ts +6 -0
- package/dist/providers/result-helpers.js +18 -2
- package/dist/rpc.d.ts +440 -4
- package/dist/rpc.js +507 -2
- package/dist/ui/assets/{index-Cs-nrywz.css → index-BcueIm3Z.css} +1 -1
- package/dist/ui/assets/index-C6qRSoh8.js +10 -0
- package/dist/ui/assets/{popover-DKRrwr_K.js → popover-4bFSvRZ7.js} +1 -1
- package/dist/ui/assets/providers/claude-agent.svg +3 -0
- package/dist/ui/index.html +2 -2
- package/package.json +15 -7
- package/dist/bin/opencode-quota-gui.d.ts.map +0 -1
- package/dist/bin/opencode-quota-gui.js.map +0 -1
- package/dist/contracts/analytics-entity.d.ts.map +0 -1
- package/dist/contracts/analytics-entity.js.map +0 -1
- package/dist/contracts/analytics-temporal.d.ts.map +0 -1
- package/dist/contracts/analytics-temporal.js.map +0 -1
- package/dist/contracts/build-identity.d.ts.map +0 -1
- package/dist/contracts/card-order.d.ts.map +0 -1
- package/dist/contracts/card-order.js.map +0 -1
- package/dist/contracts/collision-safe-key.d.ts.map +0 -1
- package/dist/contracts/collision-safe-key.js.map +0 -1
- package/dist/contracts/dashboard.d.ts.map +0 -1
- package/dist/contracts/dashboard.js.map +0 -1
- package/dist/contracts/guards.d.ts.map +0 -1
- package/dist/contracts/guards.js.map +0 -1
- package/dist/contracts/identity.d.ts.map +0 -1
- package/dist/contracts/identity.js.map +0 -1
- package/dist/contracts/openai-quota.d.ts.map +0 -1
- package/dist/contracts/openai-quota.js.map +0 -1
- package/dist/contracts/ranges.d.ts.map +0 -1
- package/dist/contracts/ranges.js.map +0 -1
- package/dist/contracts/settings.d.ts.map +0 -1
- package/dist/contracts/settings.js.map +0 -1
- package/dist/contracts/temporal.d.ts.map +0 -1
- package/dist/contracts/temporal.js.map +0 -1
- package/dist/contracts/time-zone.d.ts.map +0 -1
- package/dist/contracts/time-zone.js.map +0 -1
- package/dist/gui/aggregation.d.ts.map +0 -1
- package/dist/gui/aggregation.js.map +0 -1
- package/dist/gui/analytics-bridge.d.ts.map +0 -1
- package/dist/gui/analytics-bridge.js.map +0 -1
- package/dist/gui/analytics-engine.d.ts.map +0 -1
- package/dist/gui/analytics-engine.js.map +0 -1
- package/dist/gui/analytics-indexes.d.ts.map +0 -1
- package/dist/gui/analytics-indexes.js.map +0 -1
- package/dist/gui/analytics-model.d.ts.map +0 -1
- package/dist/gui/analytics-model.js.map +0 -1
- package/dist/gui/analytics-pricing-revision.d.ts.map +0 -1
- package/dist/gui/analytics-pricing-revision.js.map +0 -1
- package/dist/gui/analytics-protocol.d.ts.map +0 -1
- package/dist/gui/analytics-protocol.js.map +0 -1
- package/dist/gui/analytics-reader.d.ts.map +0 -1
- package/dist/gui/analytics-reader.js.map +0 -1
- package/dist/gui/analytics-service.d.ts.map +0 -1
- package/dist/gui/analytics-service.js.map +0 -1
- package/dist/gui/analytics-state.d.ts.map +0 -1
- package/dist/gui/analytics-state.js.map +0 -1
- package/dist/gui/analytics-worker-runtime.d.ts.map +0 -1
- package/dist/gui/analytics-worker-runtime.js.map +0 -1
- package/dist/gui/analytics-worker.d.ts.map +0 -1
- package/dist/gui/analytics-worker.js.map +0 -1
- package/dist/gui/config.d.ts.map +0 -1
- package/dist/gui/config.js.map +0 -1
- package/dist/gui/identity.d.ts.map +0 -1
- package/dist/gui/identity.js.map +0 -1
- package/dist/gui/lifecycle.d.ts.map +0 -1
- package/dist/gui/lifecycle.js.map +0 -1
- package/dist/gui/log.d.ts.map +0 -1
- package/dist/gui/log.js.map +0 -1
- package/dist/gui/provider-cards.d.ts.map +0 -1
- package/dist/gui/provider-cards.js.map +0 -1
- package/dist/gui/server.d.ts.map +0 -1
- package/dist/gui/server.js.map +0 -1
- package/dist/gui/settings-file-opener.d.ts.map +0 -1
- package/dist/gui/settings-file-opener.js.map +0 -1
- package/dist/gui/snapshot-service.d.ts.map +0 -1
- package/dist/gui/snapshot-service.js.map +0 -1
- package/dist/gui/sources.d.ts.map +0 -1
- package/dist/gui/sources.js.map +0 -1
- package/dist/gui/sse.d.ts.map +0 -1
- package/dist/gui/sse.js.map +0 -1
- package/dist/gui/temporal-quota-policy-data.d.ts.map +0 -1
- package/dist/gui/temporal-quota-policy-data.js.map +0 -1
- package/dist/gui/temporal-quota-policy.d.ts.map +0 -1
- package/dist/gui/temporal-quota-policy.js.map +0 -1
- package/dist/gui/temporal-status.d.ts.map +0 -1
- package/dist/gui/temporal-status.js.map +0 -1
- package/dist/gui/time-zone.d.ts.map +0 -1
- package/dist/gui/time-zone.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/accounting-format.d.ts.map +0 -1
- package/dist/lib/accounting-format.js.map +0 -1
- package/dist/lib/alibaba-auth.d.ts.map +0 -1
- package/dist/lib/alibaba-auth.js.map +0 -1
- package/dist/lib/alibaba-coding-plan-local-quota.d.ts +0 -47
- package/dist/lib/alibaba-coding-plan-local-quota.d.ts.map +0 -1
- package/dist/lib/alibaba-coding-plan-local-quota.js +0 -146
- package/dist/lib/alibaba-coding-plan-local-quota.js.map +0 -1
- package/dist/lib/alibaba-token-plan.d.ts.map +0 -1
- package/dist/lib/alibaba-token-plan.js.map +0 -1
- package/dist/lib/anthropic-auth.d.ts.map +0 -1
- package/dist/lib/anthropic-auth.js.map +0 -1
- package/dist/lib/anthropic.d.ts.map +0 -1
- package/dist/lib/anthropic.js.map +0 -1
- package/dist/lib/api-key-resolver.d.ts.map +0 -1
- package/dist/lib/api-key-resolver.js.map +0 -1
- package/dist/lib/atomic-json.d.ts.map +0 -1
- package/dist/lib/atomic-json.js.map +0 -1
- package/dist/lib/chutes-config.d.ts.map +0 -1
- package/dist/lib/chutes-config.js.map +0 -1
- package/dist/lib/chutes.d.ts.map +0 -1
- package/dist/lib/chutes.js.map +0 -1
- package/dist/lib/cli-reports.d.ts.map +0 -1
- package/dist/lib/cli-reports.js.map +0 -1
- package/dist/lib/cli-show.d.ts.map +0 -1
- package/dist/lib/cli-show.js.map +0 -1
- package/dist/lib/cli-status.d.ts.map +0 -1
- package/dist/lib/cli-status.js.map +0 -1
- package/dist/lib/command-parsing.d.ts.map +0 -1
- package/dist/lib/command-parsing.js.map +0 -1
- package/dist/lib/config-file-utils.d.ts.map +0 -1
- package/dist/lib/config-file-utils.js.map +0 -1
- package/dist/lib/config-write-target.d.ts.map +0 -1
- package/dist/lib/config-write-target.js.map +0 -1
- package/dist/lib/config.d.ts.map +0 -1
- package/dist/lib/config.js.map +0 -1
- package/dist/lib/copilot.d.ts.map +0 -1
- package/dist/lib/copilot.js.map +0 -1
- package/dist/lib/cursor-detection.d.ts.map +0 -1
- package/dist/lib/cursor-detection.js.map +0 -1
- package/dist/lib/cursor-pricing.d.ts.map +0 -1
- package/dist/lib/cursor-pricing.js.map +0 -1
- package/dist/lib/cursor-usage.d.ts.map +0 -1
- package/dist/lib/cursor-usage.js.map +0 -1
- package/dist/lib/dashboard-visibility.d.ts.map +0 -1
- package/dist/lib/dashboard-visibility.js.map +0 -1
- package/dist/lib/deepseek-auth.d.ts.map +0 -1
- package/dist/lib/deepseek-auth.js.map +0 -1
- package/dist/lib/deepseek.d.ts.map +0 -1
- package/dist/lib/deepseek.js.map +0 -1
- package/dist/lib/display-sanitize.d.ts.map +0 -1
- package/dist/lib/display-sanitize.js.map +0 -1
- package/dist/lib/entries.d.ts.map +0 -1
- package/dist/lib/entries.js.map +0 -1
- package/dist/lib/env-template.d.ts.map +0 -1
- package/dist/lib/env-template.js.map +0 -1
- package/dist/lib/format-utils.d.ts.map +0 -1
- package/dist/lib/format-utils.js.map +0 -1
- package/dist/lib/format.d.ts.map +0 -1
- package/dist/lib/format.js.map +0 -1
- package/dist/lib/glm-coding-plan.d.ts.map +0 -1
- package/dist/lib/glm-coding-plan.js.map +0 -1
- package/dist/lib/google-agy-companion.d.ts.map +0 -1
- package/dist/lib/google-agy-companion.js.map +0 -1
- package/dist/lib/google-agy.d.ts.map +0 -1
- package/dist/lib/google-agy.js.map +0 -1
- package/dist/lib/google-companion-credentials.d.ts.map +0 -1
- package/dist/lib/google-companion-credentials.js.map +0 -1
- package/dist/lib/google-gemini-cli-companion.d.ts.map +0 -1
- package/dist/lib/google-gemini-cli-companion.js.map +0 -1
- package/dist/lib/google-gemini-cli.d.ts.map +0 -1
- package/dist/lib/google-gemini-cli.js.map +0 -1
- package/dist/lib/google-token-cache.d.ts.map +0 -1
- package/dist/lib/google-token-cache.js.map +0 -1
- package/dist/lib/grouped-entry-normalization.d.ts.map +0 -1
- package/dist/lib/grouped-entry-normalization.js.map +0 -1
- package/dist/lib/grouped-header-format.d.ts.map +0 -1
- package/dist/lib/grouped-header-format.js.map +0 -1
- package/dist/lib/gui-config-target.d.ts.map +0 -1
- package/dist/lib/gui-config-target.js.map +0 -1
- package/dist/lib/home-dir-display.d.ts.map +0 -1
- package/dist/lib/home-dir-display.js.map +0 -1
- package/dist/lib/http.d.ts.map +0 -1
- package/dist/lib/http.js.map +0 -1
- package/dist/lib/init-installer.d.ts.map +0 -1
- package/dist/lib/init-installer.js.map +0 -1
- package/dist/lib/jsonc.d.ts.map +0 -1
- package/dist/lib/jsonc.js.map +0 -1
- package/dist/lib/kilo-config.d.ts.map +0 -1
- package/dist/lib/kilo-config.js.map +0 -1
- package/dist/lib/kilo.d.ts.map +0 -1
- package/dist/lib/kilo.js.map +0 -1
- package/dist/lib/kimi-auth.d.ts.map +0 -1
- package/dist/lib/kimi-auth.js.map +0 -1
- package/dist/lib/kimi-endpoints.d.ts.map +0 -1
- package/dist/lib/kimi-endpoints.js.map +0 -1
- package/dist/lib/kimi.d.ts.map +0 -1
- package/dist/lib/kimi.js.map +0 -1
- package/dist/lib/maintainer-announcements.d.ts.map +0 -1
- package/dist/lib/maintainer-announcements.js.map +0 -1
- package/dist/lib/map-with-concurrency.d.ts.map +0 -1
- package/dist/lib/map-with-concurrency.js.map +0 -1
- package/dist/lib/markdown-table.d.ts.map +0 -1
- package/dist/lib/markdown-table.js.map +0 -1
- package/dist/lib/mimo-config.d.ts.map +0 -1
- package/dist/lib/mimo-config.js.map +0 -1
- package/dist/lib/mimo.d.ts.map +0 -1
- package/dist/lib/mimo.js.map +0 -1
- package/dist/lib/minimax-auth.d.ts.map +0 -1
- package/dist/lib/minimax-auth.js.map +0 -1
- package/dist/lib/minimax-endpoints.d.ts.map +0 -1
- package/dist/lib/minimax-endpoints.js.map +0 -1
- package/dist/lib/modelsdev-pricing.d.ts.map +0 -1
- package/dist/lib/modelsdev-pricing.js.map +0 -1
- package/dist/lib/modelsdev-temporal.d.ts.map +0 -1
- package/dist/lib/modelsdev-temporal.js.map +0 -1
- package/dist/lib/nanogpt-config.d.ts.map +0 -1
- package/dist/lib/nanogpt-config.js.map +0 -1
- package/dist/lib/nanogpt.d.ts.map +0 -1
- package/dist/lib/nanogpt.js.map +0 -1
- package/dist/lib/ollama-cloud-config.d.ts.map +0 -1
- package/dist/lib/ollama-cloud-config.js.map +0 -1
- package/dist/lib/ollama-cloud.d.ts.map +0 -1
- package/dist/lib/ollama-cloud.js.map +0 -1
- package/dist/lib/openai.d.ts.map +0 -1
- package/dist/lib/openai.js.map +0 -1
- package/dist/lib/opencode-auth-sqlite.d.ts.map +0 -1
- package/dist/lib/opencode-auth-sqlite.js.map +0 -1
- package/dist/lib/opencode-auth.d.ts.map +0 -1
- package/dist/lib/opencode-auth.js.map +0 -1
- package/dist/lib/opencode-config-editor.d.ts.map +0 -1
- package/dist/lib/opencode-config-editor.js.map +0 -1
- package/dist/lib/opencode-config-providers.d.ts.map +0 -1
- package/dist/lib/opencode-config-providers.js.map +0 -1
- package/dist/lib/opencode-config-read.d.ts.map +0 -1
- package/dist/lib/opencode-config-read.js.map +0 -1
- package/dist/lib/opencode-console-auth.d.ts.map +0 -1
- package/dist/lib/opencode-console-auth.js.map +0 -1
- package/dist/lib/opencode-db-path.d.ts.map +0 -1
- package/dist/lib/opencode-db-path.js.map +0 -1
- package/dist/lib/opencode-go-auth.d.ts.map +0 -1
- package/dist/lib/opencode-go-auth.js.map +0 -1
- package/dist/lib/opencode-go.d.ts.map +0 -1
- package/dist/lib/opencode-go.js.map +0 -1
- package/dist/lib/opencode-runtime-paths.d.ts.map +0 -1
- package/dist/lib/opencode-runtime-paths.js.map +0 -1
- package/dist/lib/opencode-sqlite.d.ts.map +0 -1
- package/dist/lib/opencode-sqlite.js.map +0 -1
- package/dist/lib/opencode-storage.d.ts.map +0 -1
- package/dist/lib/opencode-storage.js.map +0 -1
- package/dist/lib/opencode-version.d.ts.map +0 -1
- package/dist/lib/opencode-version.js.map +0 -1
- package/dist/lib/opencode-zen.d.ts.map +0 -1
- package/dist/lib/opencode-zen.js.map +0 -1
- package/dist/lib/openrouter.d.ts.map +0 -1
- package/dist/lib/openrouter.js.map +0 -1
- package/dist/lib/private-state-paths.d.ts.map +0 -1
- package/dist/lib/private-state-paths.js.map +0 -1
- package/dist/lib/provider-add-command.d.ts.map +0 -1
- package/dist/lib/provider-add-command.js.map +0 -1
- package/dist/lib/provider-add-json-v1-questionnaire.d.ts.map +0 -1
- package/dist/lib/provider-add-json-v1-questionnaire.js.map +0 -1
- package/dist/lib/provider-add.d.ts.map +0 -1
- package/dist/lib/provider-add.js.map +0 -1
- package/dist/lib/provider-availability.d.ts.map +0 -1
- package/dist/lib/provider-availability.js.map +0 -1
- package/dist/lib/provider-metadata.d.ts.map +0 -1
- package/dist/lib/provider-metadata.js.map +0 -1
- package/dist/lib/provider-model-matching.d.ts.map +0 -1
- package/dist/lib/provider-model-matching.js.map +0 -1
- package/dist/lib/provider-registration.d.ts.map +0 -1
- package/dist/lib/provider-registration.js.map +0 -1
- package/dist/lib/quota-accounting-projection.d.ts.map +0 -1
- package/dist/lib/quota-accounting-projection.js.map +0 -1
- package/dist/lib/quota-columns.d.ts.map +0 -1
- package/dist/lib/quota-columns.js.map +0 -1
- package/dist/lib/quota-command-format.d.ts.map +0 -1
- package/dist/lib/quota-command-format.js.map +0 -1
- package/dist/lib/quota-dialog-command-specs.d.ts.map +0 -1
- package/dist/lib/quota-dialog-command-specs.js.map +0 -1
- package/dist/lib/quota-dialog-commands.d.ts.map +0 -1
- package/dist/lib/quota-dialog-commands.js.map +0 -1
- package/dist/lib/quota-entry-display.d.ts.map +0 -1
- package/dist/lib/quota-entry-display.js.map +0 -1
- package/dist/lib/quota-exhaustion-projection.d.ts.map +0 -1
- package/dist/lib/quota-exhaustion-projection.js.map +0 -1
- package/dist/lib/quota-export-types.d.ts.map +0 -1
- package/dist/lib/quota-export-types.js.map +0 -1
- package/dist/lib/quota-export.d.ts.map +0 -1
- package/dist/lib/quota-export.js.map +0 -1
- package/dist/lib/quota-format-style.d.ts.map +0 -1
- package/dist/lib/quota-format-style.js.map +0 -1
- package/dist/lib/quota-providers-local.d.ts.map +0 -1
- package/dist/lib/quota-providers-local.js.map +0 -1
- package/dist/lib/quota-providers-remote.d.ts.map +0 -1
- package/dist/lib/quota-providers-remote.js.map +0 -1
- package/dist/lib/quota-providers.d.ts.map +0 -1
- package/dist/lib/quota-providers.js.map +0 -1
- package/dist/lib/quota-render-data.d.ts.map +0 -1
- package/dist/lib/quota-render-data.js.map +0 -1
- package/dist/lib/quota-report-message.d.ts.map +0 -1
- package/dist/lib/quota-report-message.js.map +0 -1
- package/dist/lib/quota-reset-notifications.d.ts.map +0 -1
- package/dist/lib/quota-reset-notifications.js.map +0 -1
- package/dist/lib/quota-retry-wait.d.ts.map +0 -1
- package/dist/lib/quota-retry-wait.js.map +0 -1
- package/dist/lib/quota-runtime-context.d.ts.map +0 -1
- package/dist/lib/quota-runtime-context.js.map +0 -1
- package/dist/lib/quota-state-codec.d.ts.map +0 -1
- package/dist/lib/quota-state-codec.js.map +0 -1
- package/dist/lib/quota-state.d.ts.map +0 -1
- package/dist/lib/quota-state.js.map +0 -1
- package/dist/lib/quota-stats-format.d.ts.map +0 -1
- package/dist/lib/quota-stats-format.js.map +0 -1
- package/dist/lib/quota-stats.d.ts.map +0 -1
- package/dist/lib/quota-stats.js.map +0 -1
- package/dist/lib/quota-status.d.ts.map +0 -1
- package/dist/lib/quota-status.js.map +0 -1
- package/dist/lib/quota-surface-data.d.ts.map +0 -1
- package/dist/lib/quota-surface-data.js.map +0 -1
- package/dist/lib/quota-telemetry.d.ts.map +0 -1
- package/dist/lib/quota-telemetry.js.map +0 -1
- package/dist/lib/report-document.d.ts.map +0 -1
- package/dist/lib/report-document.js.map +0 -1
- package/dist/lib/resolved-auth-identity.d.ts.map +0 -1
- package/dist/lib/resolved-auth-identity.js.map +0 -1
- package/dist/lib/runtime-provider-ids.d.ts.map +0 -1
- package/dist/lib/runtime-provider-ids.js.map +0 -1
- package/dist/lib/scoped-query-chunks.d.ts.map +0 -1
- package/dist/lib/scoped-query-chunks.js.map +0 -1
- package/dist/lib/scoped-update-migration.d.ts.map +0 -1
- package/dist/lib/scoped-update-migration.js.map +0 -1
- package/dist/lib/scoped-update.d.ts.map +0 -1
- package/dist/lib/scoped-update.js.map +0 -1
- package/dist/lib/session-tokens-format.d.ts.map +0 -1
- package/dist/lib/session-tokens-format.js.map +0 -1
- package/dist/lib/session-tokens.d.ts.map +0 -1
- package/dist/lib/session-tokens.js.map +0 -1
- package/dist/lib/synthetic-config.d.ts.map +0 -1
- package/dist/lib/synthetic-config.js.map +0 -1
- package/dist/lib/synthetic.d.ts.map +0 -1
- package/dist/lib/synthetic.js.map +0 -1
- package/dist/lib/toast-format-grouped.d.ts.map +0 -1
- package/dist/lib/toast-format-grouped.js.map +0 -1
- package/dist/lib/token-buckets.d.ts.map +0 -1
- package/dist/lib/token-buckets.js.map +0 -1
- package/dist/lib/token-cost.d.ts.map +0 -1
- package/dist/lib/token-cost.js.map +0 -1
- package/dist/lib/tui-compact-format.d.ts.map +0 -1
- package/dist/lib/tui-compact-format.js.map +0 -1
- package/dist/lib/tui-panel-state.d.ts.map +0 -1
- package/dist/lib/tui-panel-state.js.map +0 -1
- package/dist/lib/tui-prompt-bar-format.d.ts.map +0 -1
- package/dist/lib/tui-prompt-bar-format.js.map +0 -1
- package/dist/lib/tui-sidebar-format.d.ts.map +0 -1
- package/dist/lib/tui-sidebar-format.js.map +0 -1
- package/dist/lib/types.d.ts.map +0 -1
- package/dist/lib/types.js.map +0 -1
- package/dist/lib/usage-ownership.d.ts.map +0 -1
- package/dist/lib/usage-ownership.js.map +0 -1
- package/dist/lib/version.d.ts.map +0 -1
- package/dist/lib/version.js.map +0 -1
- package/dist/lib/xai.d.ts.map +0 -1
- package/dist/lib/xai.js.map +0 -1
- package/dist/lib/zai-auth.d.ts.map +0 -1
- package/dist/lib/zai-auth.js.map +0 -1
- package/dist/lib/zai.d.ts.map +0 -1
- package/dist/lib/zai.js.map +0 -1
- package/dist/lib/zhipu-auth.d.ts.map +0 -1
- package/dist/lib/zhipu-auth.js.map +0 -1
- package/dist/lib/zhipu.d.ts.map +0 -1
- package/dist/lib/zhipu.js.map +0 -1
- package/dist/plugin.d.ts.map +0 -1
- package/dist/plugin.js.map +0 -1
- package/dist/providers/accounting-decimal.d.ts.map +0 -1
- package/dist/providers/accounting-decimal.js.map +0 -1
- package/dist/providers/alibaba-coding-plan.d.ts.map +0 -1
- package/dist/providers/alibaba-coding-plan.js.map +0 -1
- package/dist/providers/alibaba-token-plan.d.ts.map +0 -1
- package/dist/providers/alibaba-token-plan.js.map +0 -1
- package/dist/providers/anthropic.d.ts.map +0 -1
- package/dist/providers/anthropic.js.map +0 -1
- package/dist/providers/cache-policies.d.ts.map +0 -1
- package/dist/providers/cache-policies.js.map +0 -1
- package/dist/providers/chutes.d.ts.map +0 -1
- package/dist/providers/chutes.js.map +0 -1
- package/dist/providers/copilot.d.ts.map +0 -1
- package/dist/providers/copilot.js.map +0 -1
- package/dist/providers/cursor.d.ts.map +0 -1
- package/dist/providers/cursor.js.map +0 -1
- package/dist/providers/deepseek.d.ts.map +0 -1
- package/dist/providers/deepseek.js.map +0 -1
- package/dist/providers/glm-coding-plan-provider.d.ts.map +0 -1
- package/dist/providers/glm-coding-plan-provider.js.map +0 -1
- package/dist/providers/google-account-format.d.ts.map +0 -1
- package/dist/providers/google-account-format.js.map +0 -1
- package/dist/providers/google-agy.d.ts.map +0 -1
- package/dist/providers/google-agy.js.map +0 -1
- package/dist/providers/google-gemini-cli.d.ts.map +0 -1
- package/dist/providers/google-gemini-cli.js.map +0 -1
- package/dist/providers/kilo.d.ts.map +0 -1
- package/dist/providers/kilo.js.map +0 -1
- package/dist/providers/kimi-code.d.ts.map +0 -1
- package/dist/providers/kimi-code.js.map +0 -1
- package/dist/providers/mimo.d.ts.map +0 -1
- package/dist/providers/mimo.js.map +0 -1
- package/dist/providers/minimax-coding-plan.d.ts.map +0 -1
- package/dist/providers/minimax-coding-plan.js.map +0 -1
- package/dist/providers/nanogpt.d.ts.map +0 -1
- package/dist/providers/nanogpt.js.map +0 -1
- package/dist/providers/ollama-cloud.d.ts.map +0 -1
- package/dist/providers/ollama-cloud.js.map +0 -1
- package/dist/providers/openai.d.ts.map +0 -1
- package/dist/providers/openai.js.map +0 -1
- package/dist/providers/opencode-go.d.ts.map +0 -1
- package/dist/providers/opencode-go.js.map +0 -1
- package/dist/providers/opencode-zen.d.ts.map +0 -1
- package/dist/providers/opencode-zen.js.map +0 -1
- package/dist/providers/openrouter.d.ts.map +0 -1
- package/dist/providers/openrouter.js.map +0 -1
- package/dist/providers/quota-providers.d.ts.map +0 -1
- package/dist/providers/quota-providers.js.map +0 -1
- package/dist/providers/registry.d.ts.map +0 -1
- package/dist/providers/registry.js.map +0 -1
- package/dist/providers/result-helpers.d.ts.map +0 -1
- package/dist/providers/result-helpers.js.map +0 -1
- package/dist/providers/synthetic.d.ts.map +0 -1
- package/dist/providers/synthetic.js.map +0 -1
- package/dist/providers/xai.d.ts.map +0 -1
- package/dist/providers/xai.js.map +0 -1
- package/dist/providers/zai.d.ts.map +0 -1
- package/dist/providers/zai.js.map +0 -1
- package/dist/providers/zhipu.d.ts.map +0 -1
- package/dist/providers/zhipu.js.map +0 -1
- package/dist/rpc.d.ts.map +0 -1
- package/dist/rpc.js.map +0 -1
- package/dist/ui/assets/index-D9lFKhSN.js +0 -9
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure, bounded retention-estimate model for cache observation. This module does
|
|
3
|
+
* not read storage, subscribe to host events, issue requests, or observe provider
|
|
4
|
+
* cache validity. Every colour is an estimate: the retention window starts at the
|
|
5
|
+
* request start of the newest successful primary LLM call on the scoped route,
|
|
6
|
+
* plus a route-scoped retention policy, regardless of its cache read or write
|
|
7
|
+
* counters.
|
|
8
|
+
*/
|
|
9
|
+
export declare const CACHE_OBSERVER_MAX_INVOCATIONS = 128;
|
|
10
|
+
export interface CacheEvidenceBasis {
|
|
11
|
+
/** The concrete source that supplied this fact (not a guessed provider rule). */
|
|
12
|
+
source: string;
|
|
13
|
+
/** An opaque source reference, such as a message id or documentation locator. */
|
|
14
|
+
reference: string;
|
|
15
|
+
}
|
|
16
|
+
/** Selected provider/model/variant from Started; this does not prove the effective HTTP route. */
|
|
17
|
+
export interface CacheRouteProvenance {
|
|
18
|
+
providerId: string;
|
|
19
|
+
modelId: string;
|
|
20
|
+
variantId?: string;
|
|
21
|
+
protocolId?: "anthropic-messages";
|
|
22
|
+
basis: CacheEvidenceBasis;
|
|
23
|
+
}
|
|
24
|
+
export interface CacheInvocationOrder {
|
|
25
|
+
/** Physical assistant-message completion time from ingestion. */
|
|
26
|
+
completedAtMs: number;
|
|
27
|
+
/** Stable source tie-breaker for invocations sharing a completion time. */
|
|
28
|
+
messageId: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Omitted means the category was not reported. A reported zero is a real value;
|
|
32
|
+
* the ingestion layer decides whether an all-zero set is usable telemetry.
|
|
33
|
+
*/
|
|
34
|
+
export interface CacheInvocationCounts {
|
|
35
|
+
/** Host-reported fresh input tokens, distinct from cache reads and writes. */
|
|
36
|
+
fresh?: number;
|
|
37
|
+
/** Host-reported cache-read tokens. */
|
|
38
|
+
read?: number;
|
|
39
|
+
/** Host-reported cache-write tokens. */
|
|
40
|
+
write?: number;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* A successful, eligible primary LLM request (finish `stop` or `tool-calls`).
|
|
44
|
+
* Failed or incomplete requests are excluded by the ingestion layer before they
|
|
45
|
+
* reach this model.
|
|
46
|
+
*/
|
|
47
|
+
export interface CacheInvocationObservation {
|
|
48
|
+
sessionId: string;
|
|
49
|
+
order: CacheInvocationOrder;
|
|
50
|
+
/** Host request-start timestamp (step.started), not exact provider acceptance; completion time is never a TTL origin. */
|
|
51
|
+
dispatchAtMs?: number;
|
|
52
|
+
route?: CacheRouteProvenance;
|
|
53
|
+
/** The concrete source that established this invocation as an eligible primary request. */
|
|
54
|
+
basis: CacheEvidenceBasis;
|
|
55
|
+
counts: CacheInvocationCounts;
|
|
56
|
+
/** Best-effort current configuration snapshot captured during this live call. */
|
|
57
|
+
configuredTtlMs?: CacheConfiguredTtlMs;
|
|
58
|
+
connectionMethod?: "oauth" | "key" | "external";
|
|
59
|
+
/** Claude Agent only: this exact invocation's cache writes were observed as 1-hour-only. */
|
|
60
|
+
observedTtlMs?: 3_600_000;
|
|
61
|
+
}
|
|
62
|
+
/** Host-configured retention values the observer accepts for a configurable route. */
|
|
63
|
+
export type CacheConfiguredTtlMs = 300_000 | 3_600_000;
|
|
64
|
+
/** Retention windows an estimate may use. */
|
|
65
|
+
export type CacheSupportedTtlMs = CacheConfiguredTtlMs | 1_800_000 | 86_400_000;
|
|
66
|
+
/**
|
|
67
|
+
* Host-derived facts about one route. Absent fields mean the route's policy default
|
|
68
|
+
* applies: the observer never assumes a direct OpenAI API route it cannot confirm.
|
|
69
|
+
*/
|
|
70
|
+
export interface CacheRouteConfiguration {
|
|
71
|
+
/** The host's `cache.ttl` for a configurable route (direct Anthropic or Kimi). */
|
|
72
|
+
configuredTtlMs?: CacheConfiguredTtlMs;
|
|
73
|
+
}
|
|
74
|
+
export interface CacheTtlEstimate {
|
|
75
|
+
/**
|
|
76
|
+
* configured: the host-configured `cache.ttl` for a configurable route; documented:
|
|
77
|
+
* vendor documentation; empirical: owner-approved observed retention; observed: Claude Agent 1-hour-only cache writes matched to this call; fallback:
|
|
78
|
+
* the generic 5-minute window for unknown, gateway, and OpenAI-family routes.
|
|
79
|
+
*/
|
|
80
|
+
kind: "configured" | "documented" | "empirical" | "observed" | "fallback";
|
|
81
|
+
ttlMs: CacheSupportedTtlMs;
|
|
82
|
+
source: string;
|
|
83
|
+
reference: string;
|
|
84
|
+
assumption: string;
|
|
85
|
+
/** Omitted when the source has no valid request-start timestamp. */
|
|
86
|
+
dispatchAtMs?: number;
|
|
87
|
+
/** Estimated boundary only; this is not proof of physical eviction. */
|
|
88
|
+
deadlineAtMs?: number;
|
|
89
|
+
}
|
|
90
|
+
export interface CacheObserverScope {
|
|
91
|
+
/** Each child session is classified independently; no tree roll-up occurs. */
|
|
92
|
+
sessionId: string;
|
|
93
|
+
route?: CacheRouteProvenance;
|
|
94
|
+
}
|
|
95
|
+
/** Immutable-by-convention value state; update helpers return a new bounded state. */
|
|
96
|
+
export interface CacheObserverState {
|
|
97
|
+
readonly scope: CacheObserverScope;
|
|
98
|
+
readonly invocations: readonly CacheInvocationObservation[];
|
|
99
|
+
}
|
|
100
|
+
export interface CachePrimaryRatio {
|
|
101
|
+
/** Host-reported usage telemetry only; not protocol, cache-validity, or TTL evidence. */
|
|
102
|
+
value: number;
|
|
103
|
+
messageId: string;
|
|
104
|
+
/** Source assistant-message completion time; no age/staleness threshold is inferred. */
|
|
105
|
+
observedAtMs: number;
|
|
106
|
+
numerator: "cache-read";
|
|
107
|
+
denominator: "fresh+read+write";
|
|
108
|
+
basis: CacheEvidenceBasis;
|
|
109
|
+
}
|
|
110
|
+
export type CacheObserverColor = "gray" | "green" | "yellow" | "red";
|
|
111
|
+
/**
|
|
112
|
+
* The reason union is the Native pill's reason vocabulary. Members this model no
|
|
113
|
+
* longer produces are retained only so the pill's exhaustive reason mapping still
|
|
114
|
+
* type-checks; they should be pruned with that consumer.
|
|
115
|
+
*/
|
|
116
|
+
export type CacheObserverReason = "insufficient-evidence" | "observed-reuse-with-active-ttl" | "observed-write-with-active-ttl" | "ambiguous-invocation" | "history-truncated" | "ttl-unverified" | "ttl-expired" | "dispatch-time-unavailable" | "estimated-reuse-within-ttl" | "estimated-write-within-ttl" | "estimated-within-ttl" | "estimated-ttl-near-expiry" | "estimated-ttl-expired" | "out-of-order-invocation" | "observation-gap" | "route-unverified" | "invalidation-unverified" | "known-invalidation" | "compaction-boundary-uncertain" | "assumed-route-risk";
|
|
117
|
+
export interface CacheObserverClassification {
|
|
118
|
+
color: CacheObserverColor;
|
|
119
|
+
reason: CacheObserverReason;
|
|
120
|
+
ttlEstimate?: CacheTtlEstimate;
|
|
121
|
+
primaryCacheReadRatio?: CachePrimaryRatio;
|
|
122
|
+
/** Distinguishes received but unusable usage counters from no observed step telemetry. */
|
|
123
|
+
primaryCacheReadTelemetry?: "available" | "unavailable";
|
|
124
|
+
/** Earliest instant to reconsider the estimate without a newer event. */
|
|
125
|
+
recheckAtMs?: number;
|
|
126
|
+
}
|
|
127
|
+
export declare function createCacheObserverState(scope: CacheObserverScope): CacheObserverState;
|
|
128
|
+
export declare function observeCacheInvocation(state: CacheObserverState, observation: CacheInvocationObservation): CacheObserverState;
|
|
129
|
+
export declare function classifyCacheObserverState(state: CacheObserverState, nowMs: number, routeConfiguration?: CacheRouteConfiguration): CacheObserverClassification;
|
|
130
|
+
/**
|
|
131
|
+
* The host's `cache.ttl` value (`<number><ms|s|m|h|d>`, models.dev duration format)
|
|
132
|
+
* as one of the windows the observer accepts. Any other value is unsupported and
|
|
133
|
+
* yields undefined, so the route's default applies.
|
|
134
|
+
*/
|
|
135
|
+
export declare function cacheConfiguredTtlMsFromHostValue(value: unknown): CacheConfiguredTtlMs | undefined;
|
|
136
|
+
/** Providers whose host `cache.ttl` the observer reads: direct Anthropic and Kimi. */
|
|
137
|
+
export declare function isCacheConfigurableProviderId(providerId: string): boolean;
|
|
138
|
+
//# sourceMappingURL=cache-observer.d.ts.map
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure, bounded retention-estimate model for cache observation. This module does
|
|
3
|
+
* not read storage, subscribe to host events, issue requests, or observe provider
|
|
4
|
+
* cache validity. Every colour is an estimate: the retention window starts at the
|
|
5
|
+
* request start of the newest successful primary LLM call on the scoped route,
|
|
6
|
+
* plus a route-scoped retention policy, regardless of its cache read or write
|
|
7
|
+
* counters.
|
|
8
|
+
*/
|
|
9
|
+
export const CACHE_OBSERVER_MAX_INVOCATIONS = 128;
|
|
10
|
+
export function createCacheObserverState(scope) {
|
|
11
|
+
if (!scope.sessionId.trim())
|
|
12
|
+
throw new TypeError("cache observer sessionId must be non-empty");
|
|
13
|
+
return {
|
|
14
|
+
scope: {
|
|
15
|
+
...scope,
|
|
16
|
+
...(scope.route === undefined
|
|
17
|
+
? {}
|
|
18
|
+
: { route: { ...scope.route, basis: { ...scope.route.basis } } }),
|
|
19
|
+
},
|
|
20
|
+
invocations: [],
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export function observeCacheInvocation(state, observation) {
|
|
24
|
+
assertSession(state, observation.sessionId);
|
|
25
|
+
// A missing route is retained so a newer unrouted invocation cannot leave an
|
|
26
|
+
// older estimate looking current; it classifies as route-unverified.
|
|
27
|
+
if (observation.route !== undefined)
|
|
28
|
+
assertRoute(state.scope.route, observation.route);
|
|
29
|
+
assertOrder(observation.order);
|
|
30
|
+
const withoutRevision = state.invocations.filter((entry) => entry.order.messageId !== observation.order.messageId);
|
|
31
|
+
const invocations = [...withoutRevision, cloneInvocation(observation)].sort((a, b) => compareOrder(a.order, b.order));
|
|
32
|
+
return {
|
|
33
|
+
...state,
|
|
34
|
+
invocations: invocations.slice(-CACHE_OBSERVER_MAX_INVOCATIONS),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export function classifyCacheObserverState(state, nowMs, routeConfiguration = {}) {
|
|
38
|
+
const latest = last(state.invocations);
|
|
39
|
+
if (latest === undefined)
|
|
40
|
+
return { color: "gray", reason: "insufficient-evidence" };
|
|
41
|
+
// The cache share belongs to the newest successful call and stays independent
|
|
42
|
+
// of the retention estimate, so a route-unverified estimate still shows it.
|
|
43
|
+
const telemetry = primaryRatioOf(latest);
|
|
44
|
+
const reported = {
|
|
45
|
+
primaryCacheReadTelemetry: telemetry.status,
|
|
46
|
+
...optionalRatio(telemetry.ratio),
|
|
47
|
+
};
|
|
48
|
+
if (!Number.isFinite(nowMs) || !hasValidRouteProvenance(state.scope.route)) {
|
|
49
|
+
return { color: "gray", reason: "route-unverified", ...reported };
|
|
50
|
+
}
|
|
51
|
+
if (!hasValidRouteProvenance(latest.route)) {
|
|
52
|
+
return { color: "gray", reason: "route-unverified", ...reported };
|
|
53
|
+
}
|
|
54
|
+
const policy = retentionPolicy(latest.route, latest.configuredTtlMs === undefined
|
|
55
|
+
? routeConfiguration
|
|
56
|
+
: { configuredTtlMs: latest.configuredTtlMs }, latest.connectionMethod, latest.observedTtlMs);
|
|
57
|
+
const ttlEstimate = {
|
|
58
|
+
kind: policy.kind,
|
|
59
|
+
ttlMs: policy.ttlMs,
|
|
60
|
+
source: policy.source,
|
|
61
|
+
reference: policy.reference,
|
|
62
|
+
assumption: policy.assumption,
|
|
63
|
+
};
|
|
64
|
+
if (!hasValidDispatchTime(latest, nowMs)) {
|
|
65
|
+
return { color: "gray", reason: "dispatch-time-unavailable", ttlEstimate, ...reported };
|
|
66
|
+
}
|
|
67
|
+
const dispatchAtMs = latest.dispatchAtMs;
|
|
68
|
+
const deadlineAtMs = dispatchAtMs + policy.ttlMs;
|
|
69
|
+
const warningAtMs = dispatchAtMs + Math.floor(policy.ttlMs * 0.8);
|
|
70
|
+
const estimate = { ...ttlEstimate, dispatchAtMs, deadlineAtMs };
|
|
71
|
+
if (deadlineAtMs <= nowMs) {
|
|
72
|
+
return { color: "red", reason: "estimated-ttl-expired", ttlEstimate: estimate, ...reported };
|
|
73
|
+
}
|
|
74
|
+
if (warningAtMs <= nowMs) {
|
|
75
|
+
return {
|
|
76
|
+
color: "yellow",
|
|
77
|
+
reason: "estimated-ttl-near-expiry",
|
|
78
|
+
ttlEstimate: estimate,
|
|
79
|
+
recheckAtMs: deadlineAtMs,
|
|
80
|
+
...reported,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
color: "green",
|
|
85
|
+
reason: greenReasonFor(latest.counts),
|
|
86
|
+
ttlEstimate: estimate,
|
|
87
|
+
recheckAtMs: warningAtMs,
|
|
88
|
+
...reported,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
const DURATION_UNIT_MS = {
|
|
92
|
+
ms: 1,
|
|
93
|
+
s: 1_000,
|
|
94
|
+
m: 60_000,
|
|
95
|
+
h: 3_600_000,
|
|
96
|
+
d: 86_400_000,
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* The host's `cache.ttl` value (`<number><ms|s|m|h|d>`, models.dev duration format)
|
|
100
|
+
* as one of the windows the observer accepts. Any other value is unsupported and
|
|
101
|
+
* yields undefined, so the route's default applies.
|
|
102
|
+
*/
|
|
103
|
+
export function cacheConfiguredTtlMsFromHostValue(value) {
|
|
104
|
+
if (typeof value !== "string")
|
|
105
|
+
return undefined;
|
|
106
|
+
const match = /^(\d+(?:\.\d+)?)(ms|s|m|h|d)$/.exec(value.trim());
|
|
107
|
+
if (match === null)
|
|
108
|
+
return undefined;
|
|
109
|
+
const ttlMs = Number(match[1]) * DURATION_UNIT_MS[match[2]];
|
|
110
|
+
return ttlMs === 300_000 || ttlMs === 3_600_000 ? ttlMs : undefined;
|
|
111
|
+
}
|
|
112
|
+
/** Providers whose host `cache.ttl` the observer reads: direct Anthropic and Kimi. */
|
|
113
|
+
export function isCacheConfigurableProviderId(providerId) {
|
|
114
|
+
return providerId === "anthropic" || KIMI_PROVIDER_IDS.has(providerId);
|
|
115
|
+
}
|
|
116
|
+
function assertSession(state, sessionId) {
|
|
117
|
+
if (sessionId !== state.scope.sessionId) {
|
|
118
|
+
throw new TypeError("cache observer evidence belongs to a different session");
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function assertRoute(expected, observed) {
|
|
122
|
+
if (!sameRoute(expected, observed)) {
|
|
123
|
+
throw new TypeError("cache observer evidence belongs to a different or unknown route");
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
function assertOrder(order) {
|
|
127
|
+
if (!Number.isFinite(order.completedAtMs) || !order.messageId.trim()) {
|
|
128
|
+
throw new TypeError("cache observer ordering requires a finite completion time and message id");
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function cloneInvocation(entry) {
|
|
132
|
+
return {
|
|
133
|
+
...entry,
|
|
134
|
+
order: { ...entry.order },
|
|
135
|
+
...(entry.route === undefined
|
|
136
|
+
? {}
|
|
137
|
+
: { route: { ...entry.route, basis: { ...entry.route.basis } } }),
|
|
138
|
+
basis: { ...entry.basis },
|
|
139
|
+
counts: { ...entry.counts },
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function compareOrder(a, b) {
|
|
143
|
+
if (a.completedAtMs !== b.completedAtMs)
|
|
144
|
+
return a.completedAtMs - b.completedAtMs;
|
|
145
|
+
return compareText(a.messageId, b.messageId);
|
|
146
|
+
}
|
|
147
|
+
function compareText(a, b) {
|
|
148
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
149
|
+
}
|
|
150
|
+
function last(entries) {
|
|
151
|
+
return entries[entries.length - 1];
|
|
152
|
+
}
|
|
153
|
+
function greenReasonFor(counts) {
|
|
154
|
+
if (isPositiveFinite(counts.read))
|
|
155
|
+
return "estimated-reuse-within-ttl";
|
|
156
|
+
if (isPositiveFinite(counts.write))
|
|
157
|
+
return "estimated-write-within-ttl";
|
|
158
|
+
return "estimated-within-ttl";
|
|
159
|
+
}
|
|
160
|
+
function isPositiveFinite(value) {
|
|
161
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0;
|
|
162
|
+
}
|
|
163
|
+
function isNonNegativeFinite(value) {
|
|
164
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Cache share of one successful call: read / (fresh + read + write). A reported
|
|
168
|
+
* zero read is a valid 0%; a call with missing counters, or with no input at
|
|
169
|
+
* all, has no usable share.
|
|
170
|
+
*/
|
|
171
|
+
function primaryRatioOf(invocation) {
|
|
172
|
+
const { fresh, read, write } = invocation.counts;
|
|
173
|
+
if (!isNonNegativeFinite(fresh) || !isNonNegativeFinite(read) || !isNonNegativeFinite(write)) {
|
|
174
|
+
return { status: "unavailable" };
|
|
175
|
+
}
|
|
176
|
+
const denominator = fresh + read + write;
|
|
177
|
+
if (!(denominator > 0) || !Number.isFinite(denominator))
|
|
178
|
+
return { status: "unavailable" };
|
|
179
|
+
return {
|
|
180
|
+
status: "available",
|
|
181
|
+
ratio: {
|
|
182
|
+
value: read / denominator,
|
|
183
|
+
messageId: invocation.order.messageId,
|
|
184
|
+
observedAtMs: invocation.order.completedAtMs,
|
|
185
|
+
numerator: "cache-read",
|
|
186
|
+
denominator: "fresh+read+write",
|
|
187
|
+
basis: { ...invocation.basis },
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
const ROUTE_DEFAULT_ASSUMPTION = "assuming direct standard route/default TTL; custom endpoint, gateway, changed configuration or provider eviction may cause miss";
|
|
192
|
+
const GENERIC_FALLBACK_ASSUMPTION = "generic 5-minute fallback; no vendor retention is inferred for this route; gateway, custom endpoint, changed configuration or provider eviction may cause a miss";
|
|
193
|
+
const KIMI_PROVIDER_IDS = new Set([
|
|
194
|
+
"moonshotai",
|
|
195
|
+
"moonshotai-cn",
|
|
196
|
+
"kimi-code-plan-global",
|
|
197
|
+
"kimi-code-plan-cn",
|
|
198
|
+
"kimi-for-coding",
|
|
199
|
+
"kimi",
|
|
200
|
+
"kimi-code",
|
|
201
|
+
]);
|
|
202
|
+
/**
|
|
203
|
+
* Route-scoped retention policy, matched by exact provider id (and model for the
|
|
204
|
+
* one empirical OpenCode Go entry), so a gateway never inherits a vendor window.
|
|
205
|
+
* A host-configured `cache.ttl` applies only to a configurable route; every other
|
|
206
|
+
* route keeps its policy default.
|
|
207
|
+
*/
|
|
208
|
+
function retentionPolicy(route, routeConfiguration, connectionMethod, observedTtlMs) {
|
|
209
|
+
if (route.providerId === "claude-agent" && observedTtlMs === 3_600_000) {
|
|
210
|
+
return {
|
|
211
|
+
kind: "observed",
|
|
212
|
+
ttlMs: 3_600_000,
|
|
213
|
+
source: "Claude Agent session transcript cache-write split",
|
|
214
|
+
reference: "cache-observer-policy:claude-agent-observed-1h",
|
|
215
|
+
assumption: "Estimated from this call's 1-hour-only cache writes in the Claude Agent session record; physical retention is not observable and provider eviction may cause a miss.",
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
const configuredTtlMs = routeConfiguration.configuredTtlMs;
|
|
219
|
+
if (configuredTtlMs !== undefined && isCacheConfigurableProviderId(route.providerId)) {
|
|
220
|
+
return {
|
|
221
|
+
kind: "configured",
|
|
222
|
+
ttlMs: configuredTtlMs,
|
|
223
|
+
source: "Current host settings snapshot",
|
|
224
|
+
reference: "opencode-config:provider-settings.cache.ttl",
|
|
225
|
+
assumption: "Best-effort current host cache.ttl snapshot; may differ from dispatch settings or effective route. Physical provider expiry is not observable.",
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
if (route.providerId === "anthropic") {
|
|
229
|
+
return {
|
|
230
|
+
kind: "documented",
|
|
231
|
+
ttlMs: 300_000,
|
|
232
|
+
source: "Anthropic prompt caching documentation",
|
|
233
|
+
reference: "https://platform.claude.com/docs/en/build-with-claude/prompt-caching",
|
|
234
|
+
assumption: ROUTE_DEFAULT_ASSUMPTION,
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
if (KIMI_PROVIDER_IDS.has(route.providerId)) {
|
|
238
|
+
return {
|
|
239
|
+
kind: "documented",
|
|
240
|
+
ttlMs: 300_000,
|
|
241
|
+
source: "Kimi context caching documentation",
|
|
242
|
+
reference: "https://platform.kimi.ai/docs/guide/context-caching",
|
|
243
|
+
assumption: ROUTE_DEFAULT_ASSUMPTION,
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
if (route.providerId === "deepseek") {
|
|
247
|
+
return {
|
|
248
|
+
kind: "empirical",
|
|
249
|
+
ttlMs: 86_400_000,
|
|
250
|
+
source: "DeepSeek direct retention (owner-approved empirical policy)",
|
|
251
|
+
reference: "cache-observer-policy:deepseek-direct-24h",
|
|
252
|
+
assumption: "Empirical 24-hour estimate for direct DeepSeek; physical retention is not observable and provider eviction may cause a miss.",
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
if (route.providerId === "opencode-go" && route.modelId === "deepseek-v4.1-flash") {
|
|
256
|
+
return {
|
|
257
|
+
kind: "empirical",
|
|
258
|
+
ttlMs: 3_600_000,
|
|
259
|
+
source: "OpenCode Go deepseek-v4.1-flash retention (owner-approved empirical policy)",
|
|
260
|
+
reference: "cache-observer-policy:opencode-go-deepseek-v4.1-flash-60m",
|
|
261
|
+
assumption: "Empirical 60-minute estimate for this OpenCode Go model; physical retention is not observable and provider eviction may cause a miss.",
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
const version = /^gpt-(\d+)(?:\.(\d+))?(?:-[a-z0-9]+)*$/i.exec(route.modelId);
|
|
265
|
+
if (route.providerId === "openai" &&
|
|
266
|
+
connectionMethod === "oauth" &&
|
|
267
|
+
version !== null &&
|
|
268
|
+
(Number(version[1]) > 5 || (Number(version[1]) === 5 && Number(version[2] ?? 0) >= 6))) {
|
|
269
|
+
return {
|
|
270
|
+
kind: "empirical",
|
|
271
|
+
ttlMs: 1_800_000,
|
|
272
|
+
source: "Estimated ChatGPT subscription sign-in retention",
|
|
273
|
+
reference: "cache-observer-policy:chatgpt-oauth-30m",
|
|
274
|
+
assumption: "Owner-approved estimate based on the active OpenAI connection, not per-request proof or a retention guarantee.",
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
return {
|
|
278
|
+
kind: "fallback",
|
|
279
|
+
ttlMs: 300_000,
|
|
280
|
+
source: "Generic 5-minute fallback for unknown, gateway, or OpenAI-family routes",
|
|
281
|
+
reference: "cache-observer-policy:generic-5m-fallback",
|
|
282
|
+
assumption: GENERIC_FALLBACK_ASSUMPTION,
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
function hasValidDispatchTime(invocation, nowMs) {
|
|
286
|
+
return (typeof invocation.dispatchAtMs === "number" &&
|
|
287
|
+
Number.isFinite(invocation.dispatchAtMs) &&
|
|
288
|
+
invocation.dispatchAtMs >= 0 &&
|
|
289
|
+
invocation.dispatchAtMs <= invocation.order.completedAtMs &&
|
|
290
|
+
invocation.dispatchAtMs <= nowMs);
|
|
291
|
+
}
|
|
292
|
+
function hasValidBasis(basis) {
|
|
293
|
+
return (typeof basis?.source === "string" &&
|
|
294
|
+
basis.source.trim().length > 0 &&
|
|
295
|
+
typeof basis.reference === "string" &&
|
|
296
|
+
basis.reference.trim().length > 0);
|
|
297
|
+
}
|
|
298
|
+
function hasValidRouteProvenance(route) {
|
|
299
|
+
return (typeof route?.providerId === "string" &&
|
|
300
|
+
route.providerId.trim().length > 0 &&
|
|
301
|
+
typeof route.modelId === "string" &&
|
|
302
|
+
route.modelId.trim().length > 0 &&
|
|
303
|
+
hasValidBasis(route.basis));
|
|
304
|
+
}
|
|
305
|
+
function sameRoute(left, right) {
|
|
306
|
+
return left === undefined
|
|
307
|
+
? right === undefined
|
|
308
|
+
: right !== undefined &&
|
|
309
|
+
left.providerId === right.providerId &&
|
|
310
|
+
left.modelId === right.modelId &&
|
|
311
|
+
left.variantId === right.variantId &&
|
|
312
|
+
left.protocolId === right.protocolId;
|
|
313
|
+
}
|
|
314
|
+
function optionalRatio(ratio) {
|
|
315
|
+
return ratio === undefined ? {} : { primaryCacheReadRatio: ratio };
|
|
316
|
+
}
|
|
317
|
+
//# sourceMappingURL=cache-observer.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serialize cooperating in-process writers of the same canonical file, even
|
|
3
|
+
* when separate GUI and proposal-store instances perform asynchronous edits.
|
|
4
|
+
* External editors/processes do not participate in this lock. Config document
|
|
5
|
+
* writes recheck bytes and target after staging and immediately before rename,
|
|
6
|
+
* which narrows but cannot eliminate a race with noncooperating writers.
|
|
7
|
+
*/
|
|
8
|
+
export declare function withCanonicalConfigLock<T>(path: string, run: () => Promise<T>): Promise<T>;
|
|
9
|
+
//# sourceMappingURL=canonical-config-lock.d.ts.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
const CANONICAL_CONFIG_LOCKS = Symbol.for("opencode-quota-gui.canonical-config-locks.v1");
|
|
3
|
+
function registry() {
|
|
4
|
+
const globalState = globalThis;
|
|
5
|
+
const existing = globalState[CANONICAL_CONFIG_LOCKS];
|
|
6
|
+
if (existing)
|
|
7
|
+
return existing;
|
|
8
|
+
const created = new Map();
|
|
9
|
+
globalState[CANONICAL_CONFIG_LOCKS] = created;
|
|
10
|
+
return created;
|
|
11
|
+
}
|
|
12
|
+
function lockKey(path) {
|
|
13
|
+
const absolute = resolve(path);
|
|
14
|
+
return process.platform === "win32" ? absolute.toLowerCase() : absolute;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Serialize cooperating in-process writers of the same canonical file, even
|
|
18
|
+
* when separate GUI and proposal-store instances perform asynchronous edits.
|
|
19
|
+
* External editors/processes do not participate in this lock. Config document
|
|
20
|
+
* writes recheck bytes and target after staging and immediately before rename,
|
|
21
|
+
* which narrows but cannot eliminate a race with noncooperating writers.
|
|
22
|
+
*/
|
|
23
|
+
export function withCanonicalConfigLock(path, run) {
|
|
24
|
+
const locks = registry();
|
|
25
|
+
const key = lockKey(path);
|
|
26
|
+
const prior = locks.get(key) ?? Promise.resolve();
|
|
27
|
+
const next = prior.then(run, run);
|
|
28
|
+
const tail = next.then(() => undefined, () => undefined);
|
|
29
|
+
locks.set(key, tail);
|
|
30
|
+
void tail.then(() => {
|
|
31
|
+
if (locks.get(key) === tail)
|
|
32
|
+
locks.delete(key);
|
|
33
|
+
});
|
|
34
|
+
return next;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=canonical-config-lock.js.map
|
package/dist/lib/chutes.js
CHANGED
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
* Resolves API key from multiple sources and queries:
|
|
5
5
|
* https://api.chutes.ai/users/me/quota_usage/me
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
7
|
+
import { providerFailureCategoryForHttpStatus } from "../contracts/provider-failure.js";
|
|
8
|
+
import { createApiKeyRetryGuard, retryAfterDeadline } from "./api-key-retry-after.js";
|
|
9
|
+
import { resolveChutesApiKey } from "./chutes-config.js";
|
|
8
10
|
import { sanitizeDisplaySnippet, sanitizeDisplayText } from "./display-sanitize.js";
|
|
9
11
|
import { clampPercent } from "./format-utils.js";
|
|
10
12
|
import { fetchWithTimeout } from "./http.js";
|
|
@@ -14,47 +16,73 @@ function getNextDailyResetUtc() {
|
|
|
14
16
|
return reset.toISOString();
|
|
15
17
|
}
|
|
16
18
|
const CHUTES_QUOTA_URL = "https://api.chutes.ai/users/me/quota_usage/me";
|
|
19
|
+
const guard = createApiKeyRetryGuard((retryAtMs) => ({
|
|
20
|
+
success: false,
|
|
21
|
+
error: "Chutes API error 429",
|
|
22
|
+
failureCategory: "provider_api",
|
|
23
|
+
retryAtMs,
|
|
24
|
+
}));
|
|
17
25
|
export { getChutesKeyDiagnostics, hasChutesApiKey as hasChutesApiKeyConfigured, } from "./chutes-config.js";
|
|
18
26
|
export async function queryChutesQuota(options = {}) {
|
|
19
27
|
const resolved = await resolveChutesApiKey();
|
|
20
28
|
if (!resolved)
|
|
21
29
|
return null;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
30
|
+
return guard(resolved.key, async () => {
|
|
31
|
+
let responseStatus;
|
|
32
|
+
try {
|
|
33
|
+
return await fetchWithTimeout(CHUTES_QUOTA_URL, {
|
|
34
|
+
request: {
|
|
35
|
+
method: "GET",
|
|
36
|
+
headers: {
|
|
37
|
+
Authorization: `Bearer ${resolved.key}`,
|
|
38
|
+
"User-Agent": "opencode-quota-gui/1.0",
|
|
39
|
+
},
|
|
29
40
|
},
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
41
|
+
timeoutMs: options.requestTimeoutMs,
|
|
42
|
+
consume: async (resp) => {
|
|
43
|
+
responseStatus = resp.status;
|
|
44
|
+
if (!resp.ok) {
|
|
45
|
+
const retryAtMs = retryAfterDeadline(resp);
|
|
46
|
+
const text = await resp.text().catch(() => "");
|
|
47
|
+
return {
|
|
48
|
+
success: false,
|
|
49
|
+
error: `Chutes API error ${resp.status}: ${sanitizeDisplaySnippet(text, 120)}`,
|
|
50
|
+
failureCategory: providerFailureCategoryForHttpStatus(resp.status),
|
|
51
|
+
...(retryAtMs !== undefined ? { retryAtMs } : {}),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
const data = (await resp.json());
|
|
55
|
+
if (typeof data.used !== "number" ||
|
|
56
|
+
!Number.isFinite(data.used) ||
|
|
57
|
+
typeof data.quota !== "number" ||
|
|
58
|
+
!Number.isFinite(data.quota)) {
|
|
59
|
+
return {
|
|
60
|
+
success: false,
|
|
61
|
+
error: "Chutes API response returned an unexpected response shape",
|
|
62
|
+
failureCategory: "provider_api",
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
// Chutes returns used and quota.
|
|
66
|
+
const used = data.used;
|
|
67
|
+
const quota = data.quota;
|
|
68
|
+
const percentRemaining = quota > 0 ? clampPercent(((quota - used) / quota) * 100) : 0;
|
|
35
69
|
return {
|
|
36
|
-
success:
|
|
37
|
-
|
|
70
|
+
success: true,
|
|
71
|
+
percentRemaining,
|
|
72
|
+
resetTimeIso: getNextDailyResetUtc(),
|
|
38
73
|
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
catch (err) {
|
|
54
|
-
return {
|
|
55
|
-
success: false,
|
|
56
|
-
error: sanitizeDisplayText(err instanceof Error ? err.message : String(err)),
|
|
57
|
-
};
|
|
58
|
-
}
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
catch (err) {
|
|
78
|
+
return {
|
|
79
|
+
success: false,
|
|
80
|
+
error: sanitizeDisplayText(err instanceof Error ? err.message : String(err)),
|
|
81
|
+
failureCategory: responseStatus === undefined
|
|
82
|
+
? "provider_api"
|
|
83
|
+
: providerFailureCategoryForHttpStatus(responseStatus),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
}, options.requestTimeoutMs);
|
|
59
87
|
}
|
|
60
88
|
//# sourceMappingURL=chutes.js.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { open } from "node:fs/promises";
|
|
2
|
+
/**
|
|
3
|
+
* Observed-retention reader for one Claude Agent invocation. It stats/reads exactly one
|
|
4
|
+
* computed transcript path (no directory listing), keeps only numeric cache counters, and
|
|
5
|
+
* never returns, logs or stores transcript content, paths or ids.
|
|
6
|
+
*/
|
|
7
|
+
export type ClaudeObservedTtlResult = "1h" | "unchanged" | "retry";
|
|
8
|
+
/** Numeric counters of one grouped API message; nothing else leaves the parser. */
|
|
9
|
+
export interface TranscriptUsage {
|
|
10
|
+
input?: number;
|
|
11
|
+
read?: number;
|
|
12
|
+
write?: number;
|
|
13
|
+
oneHour?: number;
|
|
14
|
+
fiveMinute?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface ClaudeTranscriptQuery {
|
|
17
|
+
/** The OpenCode session directory the SDK ran in (its `cwd`). */
|
|
18
|
+
directory: string;
|
|
19
|
+
/** Claude SDK session UUID (`native.sessionID`). */
|
|
20
|
+
nativeSessionId: string;
|
|
21
|
+
/** Transcript record `uuid` (`native.messageID`). */
|
|
22
|
+
nativeMessageId: string;
|
|
23
|
+
/** The step's reported tokens.input / cache.read / cache.write. */
|
|
24
|
+
tokens: {
|
|
25
|
+
input: number;
|
|
26
|
+
read: number;
|
|
27
|
+
write: number;
|
|
28
|
+
};
|
|
29
|
+
env?: Readonly<Record<string, string | undefined>>;
|
|
30
|
+
home?: string;
|
|
31
|
+
}
|
|
32
|
+
/** The single candidate transcript path, or undefined when it cannot be computed safely. */
|
|
33
|
+
export declare function claudeTranscriptPath(query: Pick<ClaudeTranscriptQuery, "directory" | "nativeSessionId" | "env" | "home">): string | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Groups assistant records by `message.id` (records repeat it per content block; the max of
|
|
36
|
+
* each counter wins) and returns the group of the record whose `uuid` matches. Only text up
|
|
37
|
+
* to the last newline is parsed, so a partially flushed trailing line is ignored.
|
|
38
|
+
*/
|
|
39
|
+
export declare function parseTranscriptTail(text: string, uuid: string): TranscriptUsage | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* "1h" only when the matched message's cache writes are 1-hour-only and its grouped
|
|
42
|
+
* counters equal the step's reported tokens exactly; "retry" when the file or record is not
|
|
43
|
+
* (yet) there; "unchanged" for everything else.
|
|
44
|
+
*/
|
|
45
|
+
export declare function readClaudeObservedTtl(query: ClaudeTranscriptQuery, deps?: {
|
|
46
|
+
open?: typeof open;
|
|
47
|
+
}): Promise<ClaudeObservedTtlResult>;
|
|
48
|
+
//# sourceMappingURL=claude-agent-transcript-ttl.d.ts.map
|