codex-multi-auth 2.3.0-beta.1 → 2.3.0-beta.3
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/.codex-plugin/plugin.json +2 -1
- package/README.md +4 -4
- package/config/schema/config.schema.json +268 -21
- package/dist/index.js +0 -1
- package/dist/lib/account-policy.d.ts.map +1 -1
- package/dist/lib/account-policy.js +2 -2
- package/dist/lib/accounts/rate-limits.js +0 -1
- package/dist/lib/accounts.d.ts +3 -8
- package/dist/lib/accounts.d.ts.map +1 -1
- package/dist/lib/accounts.js +2 -3
- package/dist/lib/audit.d.ts +0 -9
- package/dist/lib/audit.d.ts.map +1 -1
- package/dist/lib/audit.js +0 -1
- package/dist/lib/auth/auth.js +0 -1
- package/dist/lib/auth/browser.js +0 -1
- package/dist/lib/auth/device-auth.d.ts +1 -6
- package/dist/lib/auth/device-auth.d.ts.map +1 -1
- package/dist/lib/auth/device-auth.js +5 -6
- package/dist/lib/auth/index.js +0 -1
- package/dist/lib/auth/org-override.js +0 -1
- package/dist/lib/auth/server.js +0 -1
- package/dist/lib/auth/token-utils.js +0 -1
- package/dist/lib/auth-rate-limit.js +0 -1
- package/dist/lib/budget-guard.d.ts.map +1 -1
- package/dist/lib/budget-guard.js +2 -2
- package/dist/lib/capability-policy.js +0 -1
- package/dist/lib/circuit-breaker.js +0 -1
- package/dist/lib/cli.js +1 -2
- package/dist/lib/codex-cli/index.js +0 -1
- package/dist/lib/codex-cli/observability.js +0 -1
- package/dist/lib/codex-cli/state.js +0 -1
- package/dist/lib/codex-cli/sync.d.ts +2 -2
- package/dist/lib/codex-cli/sync.d.ts.map +1 -1
- package/dist/lib/codex-cli/sync.js +1 -2
- package/dist/lib/codex-cli/writer.d.ts.map +1 -1
- package/dist/lib/codex-cli/writer.js +2 -2
- package/dist/lib/codex-manager/account-credentials.d.ts +13 -0
- package/dist/lib/codex-manager/account-credentials.d.ts.map +1 -0
- package/dist/lib/codex-manager/account-credentials.js +55 -0
- package/dist/lib/codex-manager/account-manager-commands.js +0 -1
- package/dist/lib/codex-manager/account-pool-write.d.ts +1 -1
- package/dist/lib/codex-manager/account-pool-write.d.ts.map +1 -1
- package/dist/lib/codex-manager/account-pool-write.js +0 -1
- package/dist/lib/codex-manager/backend-category-entry.js +0 -1
- package/dist/lib/codex-manager/backend-category-helpers.js +0 -1
- package/dist/lib/codex-manager/backend-category-prompt.js +0 -1
- package/dist/lib/codex-manager/backend-settings-controller.js +0 -1
- package/dist/lib/codex-manager/backend-settings-entry.js +0 -1
- package/dist/lib/codex-manager/backend-settings-helpers.d.ts +0 -1
- package/dist/lib/codex-manager/backend-settings-helpers.d.ts.map +1 -1
- package/dist/lib/codex-manager/backend-settings-helpers.js +1 -2
- package/dist/lib/codex-manager/backend-settings-prompt.js +0 -1
- package/dist/lib/codex-manager/backend-settings-schema.js +0 -1
- package/dist/lib/codex-manager/behavior-settings-panel.d.ts +1 -20
- package/dist/lib/codex-manager/behavior-settings-panel.d.ts.map +1 -1
- package/dist/lib/codex-manager/behavior-settings-panel.js +0 -1
- package/dist/lib/codex-manager/commands/account.js +0 -1
- package/dist/lib/codex-manager/commands/best.d.ts +8 -0
- package/dist/lib/codex-manager/commands/best.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/best.js +64 -1
- package/dist/lib/codex-manager/commands/bridge.js +0 -1
- package/dist/lib/codex-manager/commands/budget.js +0 -1
- package/dist/lib/codex-manager/commands/check.js +0 -1
- package/dist/lib/codex-manager/commands/config-explain.js +0 -1
- package/dist/lib/codex-manager/commands/debug-bundle.js +0 -1
- package/dist/lib/codex-manager/commands/forecast.js +0 -1
- package/dist/lib/codex-manager/commands/init-config.js +0 -1
- package/dist/lib/codex-manager/commands/integrations.js +0 -1
- package/dist/lib/codex-manager/commands/models.js +0 -1
- package/dist/lib/codex-manager/commands/monitor.js +0 -1
- package/dist/lib/codex-manager/commands/report.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/report.js +2 -2
- package/dist/lib/codex-manager/commands/rotation.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/rotation.js +1 -4
- package/dist/lib/codex-manager/commands/status.js +0 -1
- package/dist/lib/codex-manager/commands/switch.js +0 -1
- package/dist/lib/codex-manager/commands/uninstall.d.ts +2 -2
- package/dist/lib/codex-manager/commands/uninstall.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/uninstall.js +3 -34
- package/dist/lib/codex-manager/commands/unpin.js +0 -1
- package/dist/lib/codex-manager/commands/usage.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/usage.js +2 -2
- package/dist/lib/codex-manager/commands/verify.d.ts +2 -2
- package/dist/lib/codex-manager/commands/verify.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/verify.js +0 -1
- package/dist/lib/codex-manager/commands/why-selected.d.ts +1 -22
- package/dist/lib/codex-manager/commands/why-selected.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/why-selected.js +0 -1
- package/dist/lib/codex-manager/commands/workspace.js +0 -1
- package/dist/lib/codex-manager/dashboard-display-panel.d.ts +1 -15
- package/dist/lib/codex-manager/dashboard-display-panel.d.ts.map +1 -1
- package/dist/lib/codex-manager/dashboard-display-panel.js +0 -1
- package/dist/lib/codex-manager/dashboard-formatters.js +0 -1
- package/dist/lib/codex-manager/dashboard-settings-controller.js +0 -1
- package/dist/lib/codex-manager/dashboard-settings-data.js +0 -1
- package/dist/lib/codex-manager/dashboard-settings-entry.js +0 -1
- package/dist/lib/codex-manager/experimental-settings-entry.js +0 -1
- package/dist/lib/codex-manager/experimental-settings-prompt.d.ts +2 -1
- package/dist/lib/codex-manager/experimental-settings-prompt.d.ts.map +1 -1
- package/dist/lib/codex-manager/experimental-settings-prompt.js +0 -1
- package/dist/lib/codex-manager/experimental-settings-schema.js +1 -2
- package/dist/lib/codex-manager/experimental-sync-target-entry.js +0 -1
- package/dist/lib/codex-manager/experimental-sync-target.js +0 -1
- package/dist/lib/codex-manager/forecast-report-commands.js +0 -1
- package/dist/lib/codex-manager/forecast-report-shared.d.ts +2 -2
- package/dist/lib/codex-manager/forecast-report-shared.d.ts.map +1 -1
- package/dist/lib/codex-manager/forecast-report-shared.js +5 -21
- package/dist/lib/codex-manager/formatters/account-formatters.d.ts +11 -0
- package/dist/lib/codex-manager/formatters/account-formatters.d.ts.map +1 -0
- package/dist/lib/codex-manager/formatters/account-formatters.js +79 -0
- package/dist/lib/codex-manager/formatters/index.d.ts +5 -0
- package/dist/lib/codex-manager/formatters/index.d.ts.map +1 -0
- package/dist/lib/codex-manager/formatters/index.js +4 -0
- package/dist/lib/codex-manager/formatters/model-formatters.d.ts +12 -0
- package/dist/lib/codex-manager/formatters/model-formatters.d.ts.map +1 -0
- package/dist/lib/codex-manager/formatters/model-formatters.js +23 -0
- package/dist/lib/codex-manager/formatters/quota-formatters.d.ts +9 -0
- package/dist/lib/codex-manager/formatters/quota-formatters.d.ts.map +1 -0
- package/dist/lib/codex-manager/formatters/quota-formatters.js +104 -0
- package/dist/lib/codex-manager/formatters/text-style.d.ts +14 -0
- package/dist/lib/codex-manager/formatters/text-style.d.ts.map +1 -0
- package/dist/lib/codex-manager/formatters/text-style.js +111 -0
- package/dist/lib/codex-manager/health-check.d.ts +14 -0
- package/dist/lib/codex-manager/health-check.d.ts.map +1 -0
- package/dist/lib/codex-manager/health-check.js +278 -0
- package/dist/lib/codex-manager/help.d.ts +2 -1
- package/dist/lib/codex-manager/help.d.ts.map +1 -1
- package/dist/lib/codex-manager/help.js +0 -1
- package/dist/lib/codex-manager/login-action-panel.d.ts +4 -0
- package/dist/lib/codex-manager/login-action-panel.d.ts.map +1 -0
- package/dist/lib/codex-manager/login-action-panel.js +238 -0
- package/dist/lib/codex-manager/login-flow.d.ts +17 -0
- package/dist/lib/codex-manager/login-flow.d.ts.map +1 -0
- package/dist/lib/codex-manager/login-flow.js +387 -0
- package/dist/lib/codex-manager/login-menu-actions.d.ts +20 -0
- package/dist/lib/codex-manager/login-menu-actions.d.ts.map +1 -0
- package/dist/lib/codex-manager/login-menu-actions.js +303 -0
- package/dist/lib/codex-manager/login-menu-data.d.ts +19 -0
- package/dist/lib/codex-manager/login-menu-data.d.ts.map +1 -0
- package/dist/lib/codex-manager/login-menu-data.js +378 -0
- package/dist/lib/codex-manager/login-oauth.d.ts +55 -0
- package/dist/lib/codex-manager/login-oauth.d.ts.map +1 -0
- package/dist/lib/codex-manager/login-oauth.js +345 -0
- package/dist/lib/codex-manager/manual-callback.js +0 -1
- package/dist/lib/codex-manager/persist-selected-account.d.ts +24 -0
- package/dist/lib/codex-manager/persist-selected-account.d.ts.map +1 -0
- package/dist/lib/codex-manager/persist-selected-account.js +107 -0
- package/dist/lib/codex-manager/quota-cache-helpers.d.ts +18 -0
- package/dist/lib/codex-manager/quota-cache-helpers.d.ts.map +1 -0
- package/dist/lib/codex-manager/quota-cache-helpers.js +112 -0
- package/dist/lib/codex-manager/rate-limit-markers.js +0 -1
- package/dist/lib/codex-manager/repair-commands.d.ts +0 -15
- package/dist/lib/codex-manager/repair-commands.d.ts.map +1 -1
- package/dist/lib/codex-manager/repair-commands.js +5 -6
- package/dist/lib/codex-manager/settings-hub/backend.d.ts +0 -5
- package/dist/lib/codex-manager/settings-hub/backend.d.ts.map +1 -1
- package/dist/lib/codex-manager/settings-hub/backend.js +2 -3
- package/dist/lib/codex-manager/settings-hub/dashboard.d.ts +1 -14
- package/dist/lib/codex-manager/settings-hub/dashboard.d.ts.map +1 -1
- package/dist/lib/codex-manager/settings-hub/dashboard.js +9 -10
- package/dist/lib/codex-manager/settings-hub/experimental.js +1 -2
- package/dist/lib/codex-manager/settings-hub/index.js +1 -2
- package/dist/lib/codex-manager/settings-hub/shared.js +0 -1
- package/dist/lib/codex-manager/settings-hub-entry.js +0 -1
- package/dist/lib/codex-manager/settings-hub-menu.js +0 -1
- package/dist/lib/codex-manager/settings-hub-prompt.js +0 -1
- package/dist/lib/codex-manager/settings-hub.js +0 -1
- package/dist/lib/codex-manager/settings-panels.js +0 -1
- package/dist/lib/codex-manager/settings-persist-utils.js +0 -1
- package/dist/lib/codex-manager/settings-preview.js +0 -1
- package/dist/lib/codex-manager/settings-write-queue.d.ts +0 -10
- package/dist/lib/codex-manager/settings-write-queue.d.ts.map +1 -1
- package/dist/lib/codex-manager/settings-write-queue.js +10 -11
- package/dist/lib/codex-manager/statusline-order.js +0 -1
- package/dist/lib/codex-manager/statusline-settings-panel.d.ts +3 -18
- package/dist/lib/codex-manager/statusline-settings-panel.d.ts.map +1 -1
- package/dist/lib/codex-manager/statusline-settings-panel.js +0 -1
- package/dist/lib/codex-manager/theme-settings-panel.d.ts +1 -14
- package/dist/lib/codex-manager/theme-settings-panel.d.ts.map +1 -1
- package/dist/lib/codex-manager/theme-settings-panel.js +0 -1
- package/dist/lib/codex-manager/unified-settings-controller.js +0 -1
- package/dist/lib/codex-manager/unified-settings-entry.js +0 -1
- package/dist/lib/codex-manager.d.ts +2 -4
- package/dist/lib/codex-manager.d.ts.map +1 -1
- package/dist/lib/codex-manager.js +219 -2570
- package/dist/lib/config-schema.d.ts +32 -0
- package/dist/lib/config-schema.d.ts.map +1 -0
- package/dist/lib/config-schema.js +96 -0
- package/dist/lib/config.d.ts +0 -13
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +82 -123
- package/dist/lib/constants.js +0 -1
- package/dist/lib/context-overflow.js +0 -1
- package/dist/lib/dashboard-settings.d.ts +3 -3
- package/dist/lib/dashboard-settings.d.ts.map +1 -1
- package/dist/lib/dashboard-settings.js +0 -2
- package/dist/lib/entitlement-cache.js +0 -1
- package/dist/lib/env-parsing.js +0 -1
- package/dist/lib/errors.d.ts +0 -1
- package/dist/lib/errors.d.ts.map +1 -1
- package/dist/lib/errors.js +0 -1
- package/dist/lib/forecast.d.ts +4 -3
- package/dist/lib/forecast.d.ts.map +1 -1
- package/dist/lib/forecast.js +0 -1
- package/dist/lib/fs-retry.d.ts +46 -3
- package/dist/lib/fs-retry.d.ts.map +1 -1
- package/dist/lib/fs-retry.js +77 -9
- package/dist/lib/health.js +0 -1
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +1 -1
- package/dist/lib/integration-generators.js +0 -1
- package/dist/lib/live-account-sync.js +0 -1
- package/dist/lib/local-bridge.js +0 -1
- package/dist/lib/local-client-tokens.d.ts.map +1 -1
- package/dist/lib/local-client-tokens.js +2 -2
- package/dist/lib/logger.js +0 -1
- package/dist/lib/model-capability-matrix.js +0 -1
- package/dist/lib/named-backup-export.js +0 -1
- package/dist/lib/oc-chatgpt-import-adapter.d.ts +1 -1
- package/dist/lib/oc-chatgpt-import-adapter.d.ts.map +1 -1
- package/dist/lib/oc-chatgpt-import-adapter.js +0 -1
- package/dist/lib/oc-chatgpt-orchestrator.d.ts.map +1 -1
- package/dist/lib/oc-chatgpt-orchestrator.js +2 -2
- package/dist/lib/oc-chatgpt-target-detection.d.ts +1 -1
- package/dist/lib/oc-chatgpt-target-detection.d.ts.map +1 -1
- package/dist/lib/oc-chatgpt-target-detection.js +0 -1
- package/dist/lib/parallel-probe.js +0 -1
- package/dist/lib/policy/runtime-policy.js +0 -1
- package/dist/lib/preemptive-quota-scheduler.js +0 -1
- package/dist/lib/proactive-refresh.js +0 -1
- package/dist/lib/prompts/codex-host-bridge.d.ts +0 -8
- package/dist/lib/prompts/codex-host-bridge.d.ts.map +1 -1
- package/dist/lib/prompts/codex-host-bridge.js +0 -21
- package/dist/lib/prompts/codex.d.ts +3 -11
- package/dist/lib/prompts/codex.d.ts.map +1 -1
- package/dist/lib/prompts/codex.js +6 -13
- package/dist/lib/prompts/fetch-utils.d.ts +0 -2
- package/dist/lib/prompts/fetch-utils.d.ts.map +1 -1
- package/dist/lib/prompts/fetch-utils.js +2 -3
- package/dist/lib/prompts/host-codex-prompt.d.ts.map +1 -1
- package/dist/lib/prompts/host-codex-prompt.js +2 -2
- package/dist/lib/quota-cache.d.ts.map +1 -1
- package/dist/lib/quota-cache.js +17 -44
- package/dist/lib/quota-probe.js +0 -1
- package/dist/lib/quota-readiness.js +0 -1
- package/dist/lib/recovery/constants.js +0 -1
- package/dist/lib/recovery/index.js +0 -1
- package/dist/lib/recovery/storage.d.ts.map +1 -1
- package/dist/lib/recovery/storage.js +35 -54
- package/dist/lib/recovery/storage.js.map +1 -1
- package/dist/lib/recovery/types.d.ts +4 -12
- package/dist/lib/recovery/types.d.ts.map +1 -1
- package/dist/lib/recovery/types.js +0 -1
- package/dist/lib/recovery.d.ts +2 -2
- package/dist/lib/recovery.d.ts.map +1 -1
- package/dist/lib/recovery.js +0 -1
- package/dist/lib/refresh-guardian.js +0 -1
- package/dist/lib/refresh-lease.d.ts.map +1 -1
- package/dist/lib/refresh-lease.js +1 -4
- package/dist/lib/refresh-queue.js +0 -1
- package/dist/lib/request/error-classification.d.ts +75 -0
- package/dist/lib/request/error-classification.d.ts.map +1 -0
- package/dist/lib/request/error-classification.js +295 -0
- package/dist/lib/request/failover-config.js +0 -1
- package/dist/lib/request/failure-policy.js +0 -1
- package/dist/lib/request/fetch-helpers.d.ts +10 -114
- package/dist/lib/request/fetch-helpers.d.ts.map +1 -1
- package/dist/lib/request/fetch-helpers.js +7 -589
- package/dist/lib/request/headers.d.ts +33 -0
- package/dist/lib/request/headers.d.ts.map +1 -0
- package/dist/lib/request/headers.js +64 -0
- package/dist/lib/request/helpers/input-utils.js +0 -1
- package/dist/lib/request/helpers/model-map.d.ts +10 -0
- package/dist/lib/request/helpers/model-map.d.ts.map +1 -1
- package/dist/lib/request/helpers/model-map.js +11 -1
- package/dist/lib/request/helpers/tool-utils.js +0 -1
- package/dist/lib/request/index.js +0 -1
- package/dist/lib/request/rate-limit-backoff.js +0 -1
- package/dist/lib/request/rate-limit-decision.d.ts +28 -0
- package/dist/lib/request/rate-limit-decision.d.ts.map +1 -0
- package/dist/lib/request/rate-limit-decision.js +191 -0
- package/dist/lib/request/request-attempt-budget.js +0 -1
- package/dist/lib/request/request-init.js +0 -1
- package/dist/lib/request/request-resilience.js +0 -1
- package/dist/lib/request/request-transformer.js +0 -1
- package/dist/lib/request/response-compaction.d.ts +2 -1
- package/dist/lib/request/response-compaction.d.ts.map +1 -1
- package/dist/lib/request/response-compaction.js +0 -1
- package/dist/lib/request/response-handler.js +0 -1
- package/dist/lib/request/response-metadata.js +0 -1
- package/dist/lib/request/stream-failover-runtime.d.ts +8 -0
- package/dist/lib/request/stream-failover-runtime.d.ts.map +1 -0
- package/dist/lib/request/stream-failover-runtime.js +171 -0
- package/dist/lib/request/stream-failover.js +0 -1
- package/dist/lib/request/token-refresh.d.ts +30 -0
- package/dist/lib/request/token-refresh.d.ts.map +1 -0
- package/dist/lib/request/token-refresh.js +116 -0
- package/dist/lib/request/url-rewriting.d.ts +24 -0
- package/dist/lib/request/url-rewriting.d.ts.map +1 -0
- package/dist/lib/request/url-rewriting.js +153 -0
- package/dist/lib/request/wait-utils.js +0 -1
- package/dist/lib/rotation.d.ts +2 -4
- package/dist/lib/rotation.d.ts.map +1 -1
- package/dist/lib/rotation.js +1 -3
- package/dist/lib/routing-mutex.js +0 -1
- package/dist/lib/routing-profiles.d.ts.map +1 -1
- package/dist/lib/routing-profiles.js +2 -2
- package/dist/lib/runtime/account-check-helpers.js +0 -1
- package/dist/lib/runtime/account-check-types.js +0 -1
- package/dist/lib/runtime/account-check.js +0 -1
- package/dist/lib/runtime/account-health-check.js +0 -1
- package/dist/lib/runtime/account-manager-cache-entry.js +0 -1
- package/dist/lib/runtime/account-manager-cache.js +0 -1
- package/dist/lib/runtime/account-pool.js +0 -1
- package/dist/lib/runtime/account-scope.js +0 -1
- package/dist/lib/runtime/account-select-event.js +0 -1
- package/dist/lib/runtime/account-selection.js +0 -1
- package/dist/lib/runtime/account-state.js +0 -1
- package/dist/lib/runtime/account-status.js +0 -1
- package/dist/lib/runtime/account-storage-scope-entry.js +0 -1
- package/dist/lib/runtime/app-bind.js +0 -1
- package/dist/lib/runtime/auth-facade.js +0 -1
- package/dist/lib/runtime/browser-oauth-flow.js +0 -1
- package/dist/lib/runtime/capability-boost.js +0 -1
- package/dist/lib/runtime/config-toml.d.ts +0 -6
- package/dist/lib/runtime/config-toml.d.ts.map +1 -1
- package/dist/lib/runtime/config-toml.js +6 -7
- package/dist/lib/runtime/event-handler.d.ts +0 -31
- package/dist/lib/runtime/event-handler.d.ts.map +1 -1
- package/dist/lib/runtime/event-handler.js +0 -23
- package/dist/lib/runtime/first-run.d.ts +78 -0
- package/dist/lib/runtime/first-run.d.ts.map +1 -0
- package/dist/lib/runtime/first-run.js +327 -0
- package/dist/lib/runtime/flagged-verify-types.js +0 -1
- package/dist/lib/runtime/hydrate-emails.js +0 -1
- package/dist/lib/runtime/live-sync-entry.js +0 -1
- package/dist/lib/runtime/live-sync.js +0 -1
- package/dist/lib/runtime/loader-setup.js +0 -1
- package/dist/lib/runtime/login-menu-accounts.js +0 -1
- package/dist/lib/runtime/manual-oauth-flow.js +0 -1
- package/dist/lib/runtime/oauth-browser-flow.js +0 -1
- package/dist/lib/runtime/preemptive-quota.js +0 -1
- package/dist/lib/runtime/quota-headers.d.ts +1 -6
- package/dist/lib/runtime/quota-headers.d.ts.map +1 -1
- package/dist/lib/runtime/quota-headers.js +5 -6
- package/dist/lib/runtime/quota-probe.js +0 -1
- package/dist/lib/runtime/quota-settings.js +0 -1
- package/dist/lib/runtime/refresh-guardian-entry.js +0 -1
- package/dist/lib/runtime/refresh-guardian.js +0 -1
- package/dist/lib/runtime/request-init.js +0 -1
- package/dist/lib/runtime/rotation-account-selection.d.ts +38 -0
- package/dist/lib/runtime/rotation-account-selection.d.ts.map +1 -0
- package/dist/lib/runtime/rotation-account-selection.js +172 -0
- package/dist/lib/runtime/rotation-proxy-state.d.ts +54 -0
- package/dist/lib/runtime/rotation-proxy-state.d.ts.map +1 -0
- package/dist/lib/runtime/rotation-proxy-state.js +56 -0
- package/dist/lib/runtime/rotation-server-types.d.ts +57 -0
- package/dist/lib/runtime/rotation-server-types.d.ts.map +1 -0
- package/dist/lib/runtime/rotation-server-types.js +1 -0
- package/dist/lib/runtime/rotation-storage-meta.d.ts +40 -0
- package/dist/lib/runtime/rotation-storage-meta.d.ts.map +1 -0
- package/dist/lib/runtime/rotation-storage-meta.js +143 -0
- package/dist/lib/runtime/rotation-token-refresh.d.ts +25 -0
- package/dist/lib/runtime/rotation-token-refresh.d.ts.map +1 -0
- package/dist/lib/runtime/rotation-token-refresh.js +99 -0
- package/dist/lib/runtime/runtime-current-account.d.ts +3 -3
- package/dist/lib/runtime/runtime-current-account.d.ts.map +1 -1
- package/dist/lib/runtime/runtime-current-account.js +2 -5
- package/dist/lib/runtime/runtime-observability.d.ts +2 -2
- package/dist/lib/runtime/runtime-observability.d.ts.map +1 -1
- package/dist/lib/runtime/runtime-observability.js +0 -5
- package/dist/lib/runtime/runtime-services.js +0 -1
- package/dist/lib/runtime/session-affinity-entry.js +0 -1
- package/dist/lib/runtime/session-affinity.js +0 -1
- package/dist/lib/runtime/session-recovery.js +0 -1
- package/dist/lib/runtime/status-marker.js +0 -1
- package/dist/lib/runtime/storage-scope.js +0 -1
- package/dist/lib/runtime/toast.js +0 -1
- package/dist/lib/runtime/ui-runtime-entry.js +0 -1
- package/dist/lib/runtime/ui-runtime.js +0 -1
- package/dist/lib/runtime/verify-flagged.js +0 -1
- package/dist/lib/runtime-constants.js +0 -1
- package/dist/lib/runtime-paths.js +0 -1
- package/dist/lib/runtime-rotation-proxy.d.ts +7 -124
- package/dist/lib/runtime-rotation-proxy.d.ts.map +1 -1
- package/dist/lib/runtime-rotation-proxy.js +618 -1356
- package/dist/lib/schemas.d.ts +5 -93
- package/dist/lib/schemas.d.ts.map +1 -1
- package/dist/lib/schemas.js +9 -10
- package/dist/lib/session-affinity.js +0 -1
- package/dist/lib/shutdown.js +0 -1
- package/dist/lib/storage/account-clear-entry.js +0 -1
- package/dist/lib/storage/account-clear.js +0 -1
- package/dist/lib/storage/account-match-utils.js +0 -1
- package/dist/lib/storage/account-persistence.d.ts +1 -1
- package/dist/lib/storage/account-persistence.d.ts.map +1 -1
- package/dist/lib/storage/account-persistence.js +0 -1
- package/dist/lib/storage/account-port.d.ts +1 -1
- package/dist/lib/storage/account-port.d.ts.map +1 -1
- package/dist/lib/storage/account-port.js +0 -1
- package/dist/lib/storage/account-save-entry.d.ts +1 -1
- package/dist/lib/storage/account-save-entry.d.ts.map +1 -1
- package/dist/lib/storage/account-save-entry.js +0 -1
- package/dist/lib/storage/account-save.d.ts +1 -1
- package/dist/lib/storage/account-save.d.ts.map +1 -1
- package/dist/lib/storage/account-save.js +0 -1
- package/dist/lib/storage/account-snapshot.js +0 -1
- package/dist/lib/storage/backup-metadata-builder.d.ts +1 -1
- package/dist/lib/storage/backup-metadata-builder.d.ts.map +1 -1
- package/dist/lib/storage/backup-metadata-builder.js +0 -1
- package/dist/lib/storage/backup-metadata.d.ts +13 -0
- package/dist/lib/storage/backup-metadata.d.ts.map +1 -1
- package/dist/lib/storage/backup-metadata.js +0 -1
- package/dist/lib/storage/backup-paths.js +0 -1
- package/dist/lib/storage/backup-restore.d.ts +1 -1
- package/dist/lib/storage/backup-restore.d.ts.map +1 -1
- package/dist/lib/storage/backup-restore.js +0 -1
- package/dist/lib/storage/cache-artifacts.js +0 -1
- package/dist/lib/storage/error-hints.js +0 -1
- package/dist/lib/storage/file-paths.d.ts +2 -2
- package/dist/lib/storage/file-paths.d.ts.map +1 -1
- package/dist/lib/storage/file-paths.js +2 -3
- package/dist/lib/storage/fixture-guards.d.ts +1 -1
- package/dist/lib/storage/fixture-guards.d.ts.map +1 -1
- package/dist/lib/storage/fixture-guards.js +0 -1
- package/dist/lib/storage/flagged-entry.js +0 -1
- package/dist/lib/storage/flagged-load-entry.d.ts +1 -1
- package/dist/lib/storage/flagged-load-entry.d.ts.map +1 -1
- package/dist/lib/storage/flagged-load-entry.js +0 -1
- package/dist/lib/storage/flagged-save-entry.d.ts +1 -1
- package/dist/lib/storage/flagged-save-entry.d.ts.map +1 -1
- package/dist/lib/storage/flagged-save-entry.js +0 -1
- package/dist/lib/storage/flagged-storage-file.d.ts +1 -1
- package/dist/lib/storage/flagged-storage-file.d.ts.map +1 -1
- package/dist/lib/storage/flagged-storage-file.js +0 -1
- package/dist/lib/storage/flagged-storage-io.d.ts +1 -1
- package/dist/lib/storage/flagged-storage-io.d.ts.map +1 -1
- package/dist/lib/storage/flagged-storage-io.js +2 -3
- package/dist/lib/storage/flagged-storage.d.ts +1 -1
- package/dist/lib/storage/flagged-storage.d.ts.map +1 -1
- package/dist/lib/storage/flagged-storage.js +15 -2
- package/dist/lib/storage/flagged-storage.js.map +1 -1
- package/dist/lib/storage/gitignore.js +0 -1
- package/dist/lib/storage/hash.js +0 -1
- package/dist/lib/storage/health.js +0 -1
- package/dist/lib/storage/identity.js +0 -1
- package/dist/lib/storage/import-export.d.ts +1 -1
- package/dist/lib/storage/import-export.d.ts.map +1 -1
- package/dist/lib/storage/import-export.js +2 -3
- package/dist/lib/storage/metadata-section.js +0 -1
- package/dist/lib/storage/migrations.d.ts +7 -49
- package/dist/lib/storage/migrations.d.ts.map +1 -1
- package/dist/lib/storage/migrations.js +5 -2
- package/dist/lib/storage/named-backup-entry.js +0 -1
- package/dist/lib/storage/named-backups-entry.d.ts +1 -1
- package/dist/lib/storage/named-backups-entry.d.ts.map +1 -1
- package/dist/lib/storage/named-backups-entry.js +0 -1
- package/dist/lib/storage/named-backups.js +0 -1
- package/dist/lib/storage/path-state.js +0 -1
- package/dist/lib/storage/paths.js +0 -1
- package/dist/lib/storage/project-migration.d.ts +1 -1
- package/dist/lib/storage/project-migration.d.ts.map +1 -1
- package/dist/lib/storage/project-migration.js +0 -1
- package/dist/lib/storage/public-types.d.ts +70 -0
- package/dist/lib/storage/public-types.d.ts.map +1 -0
- package/dist/lib/storage/public-types.js +6 -0
- package/dist/lib/storage/record-utils.js +0 -1
- package/dist/lib/storage/restore-assessment.d.ts +1 -1
- package/dist/lib/storage/restore-assessment.d.ts.map +1 -1
- package/dist/lib/storage/restore-assessment.js +0 -1
- package/dist/lib/storage/restore-backup-entry.d.ts +1 -1
- package/dist/lib/storage/restore-backup-entry.d.ts.map +1 -1
- package/dist/lib/storage/restore-backup-entry.js +0 -1
- package/dist/lib/storage/restore-metadata.d.ts +1 -1
- package/dist/lib/storage/restore-metadata.d.ts.map +1 -1
- package/dist/lib/storage/restore-metadata.js +0 -1
- package/dist/lib/storage/restore.d.ts +1 -1
- package/dist/lib/storage/restore.d.ts.map +1 -1
- package/dist/lib/storage/restore.js +0 -1
- package/dist/lib/storage/save-retry.d.ts +10 -0
- package/dist/lib/storage/save-retry.d.ts.map +1 -0
- package/dist/lib/storage/save-retry.js +26 -0
- package/dist/lib/storage/snapshot-inspectors.d.ts +1 -1
- package/dist/lib/storage/snapshot-inspectors.d.ts.map +1 -1
- package/dist/lib/storage/snapshot-inspectors.js +0 -1
- package/dist/lib/storage/storage-parser.d.ts +1 -1
- package/dist/lib/storage/storage-parser.d.ts.map +1 -1
- package/dist/lib/storage/storage-parser.js +0 -1
- package/dist/lib/storage/transactions.d.ts +1 -1
- package/dist/lib/storage/transactions.d.ts.map +1 -1
- package/dist/lib/storage/transactions.js +0 -1
- package/dist/lib/storage.d.ts +3 -24
- package/dist/lib/storage.d.ts.map +1 -1
- package/dist/lib/storage.js +47 -55
- package/dist/lib/table-formatter.js +0 -1
- package/dist/lib/temp-path.d.ts +26 -0
- package/dist/lib/temp-path.d.ts.map +1 -0
- package/dist/lib/temp-path.js +30 -0
- package/dist/lib/tools/hashline-tools.js +0 -1
- package/dist/lib/types.js +0 -1
- package/dist/lib/ui/ansi.js +0 -1
- package/dist/lib/ui/auth-menu-builder.d.ts +89 -0
- package/dist/lib/ui/auth-menu-builder.d.ts.map +1 -0
- package/dist/lib/ui/auth-menu-builder.js +350 -0
- package/dist/lib/ui/auth-menu.d.ts +2 -76
- package/dist/lib/ui/auth-menu.d.ts.map +1 -1
- package/dist/lib/ui/auth-menu.js +3 -349
- package/dist/lib/ui/confirm.js +0 -1
- package/dist/lib/ui/display-width.js +0 -1
- package/dist/lib/ui/format.js +0 -1
- package/dist/lib/ui/index.d.ts +10 -0
- package/dist/lib/ui/index.d.ts.map +1 -0
- package/dist/lib/ui/index.js +9 -0
- package/dist/lib/ui/runtime.js +0 -1
- package/dist/lib/ui/select.js +0 -1
- package/dist/lib/ui/theme.d.ts +3 -2
- package/dist/lib/ui/theme.d.ts.map +1 -1
- package/dist/lib/ui/theme.js +0 -1
- package/dist/lib/ui/ui-copy.d.ts +159 -0
- package/dist/lib/ui/ui-copy.d.ts.map +1 -0
- package/dist/lib/ui/ui-copy.js +163 -0
- package/dist/lib/unified-settings.d.ts.map +1 -1
- package/dist/lib/unified-settings.js +2 -2
- package/dist/lib/update-notice.d.ts.map +1 -1
- package/dist/lib/update-notice.js +2 -2
- package/dist/lib/usage/index.js +0 -1
- package/dist/lib/usage/ledger.js +0 -1
- package/dist/lib/usage/pricing.js +0 -1
- package/dist/lib/usage/redaction.js +0 -1
- package/dist/lib/usage/types.js +0 -1
- package/dist/lib/utils.js +0 -1
- package/package.json +8 -9
- package/scripts/postinstall.js +34 -265
- package/scripts/preuninstall.js +2 -2
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error classification helpers for the custom fetch implementation
|
|
3
|
+
* Extracted from fetch-helpers.ts (audit roadmap §4.1.2); fetch-helpers.ts
|
|
4
|
+
* re-exports the public symbols so existing importers are unchanged.
|
|
5
|
+
*/
|
|
6
|
+
import { isRecord } from "../utils.js";
|
|
7
|
+
import { HTTP_STATUS } from "../constants.js";
|
|
8
|
+
/** @internal Exported only for sibling lib/request modules; import via fetch-helpers.ts elsewhere. */
|
|
9
|
+
export const CHATGPT_CODEX_UNSUPPORTED_MODEL_CODE = "model_not_supported_with_chatgpt_account";
|
|
10
|
+
const CHATGPT_CODEX_UNSUPPORTED_MODEL_PATTERN = /model is not supported when using codex with a chatgpt account/i;
|
|
11
|
+
const NORMALIZED_UNSUPPORTED_MODEL_PATTERN = /the model ['"]([^'"]+)['"] is not currently available for this chatgpt account/i;
|
|
12
|
+
const MODEL_ACCESS_DENIED_PATTERN = /the model [`'"]([^`'"]+)[`'"] does not exist or you do not have access to it/i;
|
|
13
|
+
export const DEFAULT_UNSUPPORTED_CODEX_FALLBACK_CHAIN = {
|
|
14
|
+
"gpt-5": ["gpt-5.5"],
|
|
15
|
+
"gpt-5-pro": ["gpt-5.5-pro"],
|
|
16
|
+
"gpt-5-chat-latest": ["gpt-5.5"],
|
|
17
|
+
"gpt-5.5": ["gpt-5.4"],
|
|
18
|
+
"gpt-5.5-pro": ["gpt-5.4"],
|
|
19
|
+
"gpt-5.5-2026-04-23": ["gpt-5.4"],
|
|
20
|
+
"gpt-5.5-pro-2026-04-23": ["gpt-5.4"],
|
|
21
|
+
"gpt-5.5-20260423": ["gpt-5.4"],
|
|
22
|
+
"gpt-5.5-pro-20260423": ["gpt-5.4"],
|
|
23
|
+
"gpt-5.3-codex-spark": ["gpt-5.3-codex", "gpt-5.2-codex"],
|
|
24
|
+
"gpt-5.3-codex": ["gpt-5.2-codex"],
|
|
25
|
+
"codex-max": ["gpt-5.3-codex"],
|
|
26
|
+
"gpt-5.1-codex-max": ["gpt-5.3-codex"],
|
|
27
|
+
"codex-mini-latest": ["gpt-5.3-codex"],
|
|
28
|
+
"gpt-5-codex-mini": ["gpt-5.3-codex"],
|
|
29
|
+
"gpt-5.1-codex-mini": ["gpt-5.3-codex"],
|
|
30
|
+
"gpt-5-codex": ["gpt-5.3-codex", "gpt-5.2-codex"],
|
|
31
|
+
"gpt-5.2-codex": ["gpt-5.3-codex"],
|
|
32
|
+
"gpt-5.1-codex": ["gpt-5.3-codex"],
|
|
33
|
+
};
|
|
34
|
+
function canonicalizeModelName(model) {
|
|
35
|
+
if (!model)
|
|
36
|
+
return undefined;
|
|
37
|
+
const trimmed = model.trim().toLowerCase();
|
|
38
|
+
if (!trimmed)
|
|
39
|
+
return undefined;
|
|
40
|
+
const stripped = trimmed.includes("/")
|
|
41
|
+
? (trimmed.split("/").pop() ?? trimmed)
|
|
42
|
+
: trimmed;
|
|
43
|
+
return stripped.replace(/-(none|minimal|low|medium|high|xhigh)$/i, "");
|
|
44
|
+
}
|
|
45
|
+
function normalizeFallbackChain(customChain) {
|
|
46
|
+
const normalized = {};
|
|
47
|
+
for (const [key, values] of Object.entries(DEFAULT_UNSUPPORTED_CODEX_FALLBACK_CHAIN)) {
|
|
48
|
+
const normalizedKey = canonicalizeModelName(key);
|
|
49
|
+
if (!normalizedKey)
|
|
50
|
+
continue;
|
|
51
|
+
normalized[normalizedKey] = values
|
|
52
|
+
.map((value) => canonicalizeModelName(value))
|
|
53
|
+
.filter((value) => !!value);
|
|
54
|
+
}
|
|
55
|
+
if (!customChain) {
|
|
56
|
+
return normalized;
|
|
57
|
+
}
|
|
58
|
+
for (const [key, values] of Object.entries(customChain)) {
|
|
59
|
+
const normalizedKey = canonicalizeModelName(key);
|
|
60
|
+
if (!normalizedKey || !Array.isArray(values))
|
|
61
|
+
continue;
|
|
62
|
+
const normalizedValues = values
|
|
63
|
+
.map((value) => canonicalizeModelName(value))
|
|
64
|
+
.filter((value) => !!value);
|
|
65
|
+
if (normalizedValues.length > 0) {
|
|
66
|
+
normalized[normalizedKey] = normalizedValues;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return normalized;
|
|
70
|
+
}
|
|
71
|
+
export function extractUnsupportedCodexModelFromText(bodyText) {
|
|
72
|
+
const directMatch = bodyText.match(/['"]([^'"]+)['"]\s+model is not supported when using codex with a chatgpt account/i);
|
|
73
|
+
if (directMatch?.[1]) {
|
|
74
|
+
return canonicalizeModelName(directMatch[1]);
|
|
75
|
+
}
|
|
76
|
+
const normalizedMatch = bodyText.match(NORMALIZED_UNSUPPORTED_MODEL_PATTERN);
|
|
77
|
+
if (normalizedMatch?.[1]) {
|
|
78
|
+
return canonicalizeModelName(normalizedMatch[1]);
|
|
79
|
+
}
|
|
80
|
+
const accessDeniedMatch = bodyText.match(MODEL_ACCESS_DENIED_PATTERN);
|
|
81
|
+
if (accessDeniedMatch?.[1]) {
|
|
82
|
+
return canonicalizeModelName(accessDeniedMatch[1]);
|
|
83
|
+
}
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
/** @internal Exported only for sibling lib/request modules; import via fetch-helpers.ts elsewhere. */
|
|
87
|
+
export function isUnsupportedCodexModelForChatGpt(status, bodyText) {
|
|
88
|
+
if (status !== HTTP_STATUS.BAD_REQUEST)
|
|
89
|
+
return false;
|
|
90
|
+
if (!bodyText)
|
|
91
|
+
return false;
|
|
92
|
+
return (CHATGPT_CODEX_UNSUPPORTED_MODEL_PATTERN.test(bodyText) ||
|
|
93
|
+
NORMALIZED_UNSUPPORTED_MODEL_PATTERN.test(bodyText) ||
|
|
94
|
+
MODEL_ACCESS_DENIED_PATTERN.test(bodyText));
|
|
95
|
+
}
|
|
96
|
+
export function getUnsupportedCodexModelInfo(errorBody) {
|
|
97
|
+
if (!isRecord(errorBody)) {
|
|
98
|
+
return { isUnsupported: false };
|
|
99
|
+
}
|
|
100
|
+
const maybeError = errorBody.error;
|
|
101
|
+
if (!isRecord(maybeError)) {
|
|
102
|
+
// Some upstreams (e.g. the Codex quota endpoint) return the flat
|
|
103
|
+
// `{ "detail": "...model is not supported..." }` shape instead of the
|
|
104
|
+
// nested `{ "error": { "message": "..." } }` envelope. Fall back to the
|
|
105
|
+
// top-level `detail` string so model-fallback detection still works.
|
|
106
|
+
const detail = typeof errorBody.detail === "string" ? errorBody.detail : undefined;
|
|
107
|
+
if (!detail) {
|
|
108
|
+
return { isUnsupported: false };
|
|
109
|
+
}
|
|
110
|
+
const isUnsupportedDetail = CHATGPT_CODEX_UNSUPPORTED_MODEL_PATTERN.test(detail) ||
|
|
111
|
+
NORMALIZED_UNSUPPORTED_MODEL_PATTERN.test(detail) ||
|
|
112
|
+
MODEL_ACCESS_DENIED_PATTERN.test(detail);
|
|
113
|
+
if (!isUnsupportedDetail) {
|
|
114
|
+
return { isUnsupported: false };
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
isUnsupported: true,
|
|
118
|
+
message: detail,
|
|
119
|
+
unsupportedModel: extractUnsupportedCodexModelFromText(detail) ?? undefined,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
const code = typeof maybeError.code === "string" ? maybeError.code : undefined;
|
|
123
|
+
const message = typeof maybeError.message === "string" ? maybeError.message : undefined;
|
|
124
|
+
const unsupportedModelFromPayload = typeof maybeError.unsupported_model === "string"
|
|
125
|
+
? maybeError.unsupported_model
|
|
126
|
+
: undefined;
|
|
127
|
+
const unsupportedModel = unsupportedModelFromPayload
|
|
128
|
+
? canonicalizeModelName(unsupportedModelFromPayload)
|
|
129
|
+
: extractUnsupportedCodexModelFromText(message ?? "");
|
|
130
|
+
const isUnsupported = code === CHATGPT_CODEX_UNSUPPORTED_MODEL_CODE ||
|
|
131
|
+
(message
|
|
132
|
+
? CHATGPT_CODEX_UNSUPPORTED_MODEL_PATTERN.test(message) ||
|
|
133
|
+
NORMALIZED_UNSUPPORTED_MODEL_PATTERN.test(message) ||
|
|
134
|
+
MODEL_ACCESS_DENIED_PATTERN.test(message)
|
|
135
|
+
: false);
|
|
136
|
+
return {
|
|
137
|
+
isUnsupported,
|
|
138
|
+
code,
|
|
139
|
+
message,
|
|
140
|
+
unsupportedModel: unsupportedModel ?? undefined,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
export function resolveUnsupportedCodexFallbackModel(options) {
|
|
144
|
+
if (!options.fallbackOnUnsupportedCodexModel)
|
|
145
|
+
return undefined;
|
|
146
|
+
const unsupported = getUnsupportedCodexModelInfo(options.errorBody);
|
|
147
|
+
if (!unsupported.isUnsupported)
|
|
148
|
+
return undefined;
|
|
149
|
+
const requestedModel = canonicalizeModelName(options.requestedModel);
|
|
150
|
+
const currentModel = requestedModel ?? unsupported.unsupportedModel;
|
|
151
|
+
if (!currentModel)
|
|
152
|
+
return undefined;
|
|
153
|
+
const attempted = new Set();
|
|
154
|
+
for (const model of options.attemptedModels ?? []) {
|
|
155
|
+
const normalized = canonicalizeModelName(model);
|
|
156
|
+
if (normalized)
|
|
157
|
+
attempted.add(normalized);
|
|
158
|
+
}
|
|
159
|
+
const chain = normalizeFallbackChain(options.customChain);
|
|
160
|
+
const targets = chain[currentModel] ?? [];
|
|
161
|
+
if (targets.length === 0)
|
|
162
|
+
return undefined;
|
|
163
|
+
for (const target of targets) {
|
|
164
|
+
if (!options.fallbackToGpt52OnUnsupportedGpt53 &&
|
|
165
|
+
currentModel === "gpt-5.3-codex" &&
|
|
166
|
+
target === "gpt-5.2-codex") {
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
if (target === currentModel)
|
|
170
|
+
continue;
|
|
171
|
+
if (attempted.has(target))
|
|
172
|
+
continue;
|
|
173
|
+
return target;
|
|
174
|
+
}
|
|
175
|
+
return undefined;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Returns true when the legacy `gpt-5.3-codex -> gpt-5.2-codex` edge is available.
|
|
179
|
+
*/
|
|
180
|
+
export function shouldFallbackToGpt52OnUnsupportedGpt53(requestedModel, errorBody) {
|
|
181
|
+
if (canonicalizeModelName(requestedModel) !== "gpt-5.3-codex") {
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
return (resolveUnsupportedCodexFallbackModel({
|
|
185
|
+
requestedModel,
|
|
186
|
+
errorBody,
|
|
187
|
+
// Probe whether the legacy gpt-5.2 edge is still active under current
|
|
188
|
+
// policy/toggles when the current Codex model is blocked.
|
|
189
|
+
attemptedModels: [],
|
|
190
|
+
fallbackOnUnsupportedCodexModel: true,
|
|
191
|
+
fallbackToGpt52OnUnsupportedGpt53: true,
|
|
192
|
+
}) === "gpt-5.2-codex");
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Detects whether an error code or response body indicates an entitlement/subscription issue for Codex models.
|
|
196
|
+
*
|
|
197
|
+
* Entitlement errors signal that the requested feature is not included in the user's plan and should not be treated as rate limits.
|
|
198
|
+
* This function is pure and safe to call concurrently; it performs no filesystem access (including on Windows) and does not read or redact tokens — callers must avoid passing sensitive credentials in `code` or `bodyText`.
|
|
199
|
+
*
|
|
200
|
+
* @param code - The error code string returned by the service
|
|
201
|
+
* @param bodyText - The response body text to inspect for entitlement-related phrases
|
|
202
|
+
* @returns `true` if the combined `code` or `bodyText` indicates an entitlement/subscription issue, `false` otherwise
|
|
203
|
+
*/
|
|
204
|
+
export function isEntitlementError(code, bodyText) {
|
|
205
|
+
const haystack = `${code} ${bodyText}`.toLowerCase();
|
|
206
|
+
// "usage_not_included" means the subscription doesn't include this feature
|
|
207
|
+
// This is different from "usage_limit_reached" which is a temporary quota limit
|
|
208
|
+
return /usage_not_included|not.included.in.your.plan|subscription.does.not.include/i.test(haystack);
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Detects whether an error indicates the workspace/account has been disabled or expired.
|
|
212
|
+
*
|
|
213
|
+
* Workspace disabled errors signal that the current workspace is no longer accessible
|
|
214
|
+
* (expired, disabled, or removed) and the plugin should automatically switch to another account.
|
|
215
|
+
*
|
|
216
|
+
* @param status - HTTP status code
|
|
217
|
+
* @param code - The error code string returned by the service
|
|
218
|
+
* @param bodyText - The response body text to inspect for workspace-related phrases
|
|
219
|
+
* @returns `true` if the error indicates a disabled/expired workspace
|
|
220
|
+
*/
|
|
221
|
+
export function isWorkspaceDisabledError(status, code, bodyText) {
|
|
222
|
+
const normalizedCode = typeof code === "string" ? code.trim().toLowerCase() : "";
|
|
223
|
+
if (status === 402) {
|
|
224
|
+
const normalizedTokens = normalizedCode
|
|
225
|
+
.split(/[^a-z0-9_]+/i)
|
|
226
|
+
.map((token) => token.trim())
|
|
227
|
+
.filter((token) => token.length > 0);
|
|
228
|
+
return (normalizedTokens.includes("deactivated_workspace") ||
|
|
229
|
+
/\bdeactivated_workspace\b/i.test(bodyText));
|
|
230
|
+
}
|
|
231
|
+
if (status !== 403) {
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
const haystack = `${normalizedCode} ${bodyText}`.toLowerCase();
|
|
235
|
+
const normalizedTokens = normalizedCode
|
|
236
|
+
.split(/[^a-z0-9_]+/i)
|
|
237
|
+
.map((token) => token.trim())
|
|
238
|
+
.filter((token) => token.length > 0);
|
|
239
|
+
const disabledPatterns = [
|
|
240
|
+
/workspace.*(?:disabled|expired|deactivated|terminated)/i,
|
|
241
|
+
/account\s+(?:has\s+been|is)\s+(?:disabled|expired|deactivated|terminated|closed)/i,
|
|
242
|
+
/(?:workspace|org(?:anization)?).*no longer.*(?:active|available|valid)/i,
|
|
243
|
+
/(?:workspace|org(?:anization)?).*has been.*(?:disabled|expired|closed)/i,
|
|
244
|
+
/workspace.*(?:access|subscription).*expired/i,
|
|
245
|
+
/org(?:anization)?.*(?:disabled|expired|inactive)/i,
|
|
246
|
+
];
|
|
247
|
+
for (const pattern of disabledPatterns) {
|
|
248
|
+
if (pattern.test(haystack)) {
|
|
249
|
+
return true;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
const workspaceErrorCodes = new Set([
|
|
253
|
+
"workspace_disabled",
|
|
254
|
+
"workspace_expired",
|
|
255
|
+
"workspace_terminated",
|
|
256
|
+
"account_disabled",
|
|
257
|
+
"account_expired",
|
|
258
|
+
"organization_disabled",
|
|
259
|
+
]);
|
|
260
|
+
if (workspaceErrorCodes.has(normalizedCode)) {
|
|
261
|
+
return true;
|
|
262
|
+
}
|
|
263
|
+
return normalizedTokens.some((token) => workspaceErrorCodes.has(token));
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Constructs a standardized 403 entitlement error Response indicating the user lacks access to Codex models.
|
|
267
|
+
*
|
|
268
|
+
* This function returns a JSON Response with an `error` payload containing a user-facing message, a
|
|
269
|
+
* `type` of `"entitlement_error"`, and a `code` of `"usage_not_included"`. The message suggests checking
|
|
270
|
+
* account/workspace access and re-authenticating with `codex-multi-auth login`.
|
|
271
|
+
*
|
|
272
|
+
* Concurrency: stateless and safe to call concurrently from multiple threads or requests.
|
|
273
|
+
* Windows filesystem behavior: none (function does not access the filesystem).
|
|
274
|
+
* Token redaction: any tokens are not included in the generated payload; do not pass sensitive tokens in `_bodyText`.
|
|
275
|
+
*
|
|
276
|
+
* @param _bodyText - Original response body text (accepted for compatibility; ignored when building the response)
|
|
277
|
+
* @returns A 403 Response with a JSON body describing the entitlement error and guidance for resolving it
|
|
278
|
+
*/
|
|
279
|
+
export function createEntitlementErrorResponse(_bodyText) {
|
|
280
|
+
const message = "This model is not included in your ChatGPT subscription. " +
|
|
281
|
+
"Please check that your account or workspace has access to Codex models (Plus/Pro/Business/Enterprise). " +
|
|
282
|
+
"If you recently subscribed or switched workspaces, try logging out and back in with `codex-multi-auth login`.";
|
|
283
|
+
const payload = {
|
|
284
|
+
error: {
|
|
285
|
+
message,
|
|
286
|
+
type: "entitlement_error",
|
|
287
|
+
code: "usage_not_included",
|
|
288
|
+
},
|
|
289
|
+
};
|
|
290
|
+
return new Response(JSON.stringify(payload), {
|
|
291
|
+
status: 403, // Forbidden - not a rate limit
|
|
292
|
+
statusText: "Forbidden",
|
|
293
|
+
headers: { "content-type": "application/json; charset=utf-8" },
|
|
294
|
+
});
|
|
295
|
+
}
|
|
@@ -2,83 +2,24 @@
|
|
|
2
2
|
* Helper functions for the custom fetch implementation
|
|
3
3
|
* These functions break down the complex fetch logic into manageable, testable units
|
|
4
4
|
*/
|
|
5
|
-
import type { Auth, CodexClient } from "@codex-ai/sdk";
|
|
6
5
|
import { type FastSessionInputTrimPlan } from "./request-transformer.js";
|
|
7
6
|
import type { UserConfig, RequestBody } from "../types.js";
|
|
7
|
+
export { shouldRefreshToken, refreshAndUpdateToken } from "./token-refresh.js";
|
|
8
|
+
export { DEFAULT_UNSUPPORTED_CODEX_FALLBACK_CHAIN, extractUnsupportedCodexModelFromText, getUnsupportedCodexModelInfo, resolveUnsupportedCodexFallbackModel, shouldFallbackToGpt52OnUnsupportedGpt53, isEntitlementError, isWorkspaceDisabledError, createEntitlementErrorResponse, } from "./error-classification.js";
|
|
9
|
+
export type { EntitlementError, UnsupportedCodexModelInfo, ResolveUnsupportedCodexFallbackOptions, } from "./error-classification.js";
|
|
10
|
+
export { extractRequestUrl, rewriteUrlForCodex, resolveProxyUrlForRequest, closeSharedProxyDispatchers, applyProxyCompatibleInit, } from "./url-rewriting.js";
|
|
11
|
+
export type { ProxyCompatibleRequestInit } from "./url-rewriting.js";
|
|
12
|
+
export { createCodexHeaders } from "./headers.js";
|
|
13
|
+
export type { CreateCodexHeadersOptions, CreateCodexHeadersParams, } from "./headers.js";
|
|
8
14
|
export interface RateLimitInfo {
|
|
9
15
|
retryAfterMs: number;
|
|
10
16
|
code?: string;
|
|
11
17
|
}
|
|
12
|
-
export interface EntitlementError {
|
|
13
|
-
isEntitlement: true;
|
|
14
|
-
code: string;
|
|
15
|
-
message: string;
|
|
16
|
-
}
|
|
17
|
-
export declare const DEFAULT_UNSUPPORTED_CODEX_FALLBACK_CHAIN: Record<string, string[]>;
|
|
18
|
-
export interface UnsupportedCodexModelInfo {
|
|
19
|
-
isUnsupported: boolean;
|
|
20
|
-
code?: string;
|
|
21
|
-
message?: string;
|
|
22
|
-
unsupportedModel?: string;
|
|
23
|
-
}
|
|
24
|
-
export interface ResolveUnsupportedCodexFallbackOptions {
|
|
25
|
-
requestedModel: string | undefined;
|
|
26
|
-
errorBody: unknown;
|
|
27
|
-
attemptedModels?: Iterable<string>;
|
|
28
|
-
fallbackOnUnsupportedCodexModel: boolean;
|
|
29
|
-
fallbackToGpt52OnUnsupportedGpt53: boolean;
|
|
30
|
-
customChain?: Record<string, string[]>;
|
|
31
|
-
}
|
|
32
18
|
export interface TransformRequestForCodexResult {
|
|
33
19
|
body: RequestBody;
|
|
34
20
|
updatedInit: RequestInit;
|
|
35
21
|
deferredFastSessionInputTrim?: FastSessionInputTrimPlan["trim"];
|
|
36
22
|
}
|
|
37
|
-
export declare function extractUnsupportedCodexModelFromText(bodyText: string): string | undefined;
|
|
38
|
-
export declare function getUnsupportedCodexModelInfo(errorBody: unknown): UnsupportedCodexModelInfo;
|
|
39
|
-
export declare function resolveUnsupportedCodexFallbackModel(options: ResolveUnsupportedCodexFallbackOptions): string | undefined;
|
|
40
|
-
/**
|
|
41
|
-
* Returns true when the legacy `gpt-5.3-codex -> gpt-5.2-codex` edge is available.
|
|
42
|
-
*/
|
|
43
|
-
export declare function shouldFallbackToGpt52OnUnsupportedGpt53(requestedModel: string | undefined, errorBody: unknown): boolean;
|
|
44
|
-
/**
|
|
45
|
-
* Detects whether an error code or response body indicates an entitlement/subscription issue for Codex models.
|
|
46
|
-
*
|
|
47
|
-
* Entitlement errors signal that the requested feature is not included in the user's plan and should not be treated as rate limits.
|
|
48
|
-
* This function is pure and safe to call concurrently; it performs no filesystem access (including on Windows) and does not read or redact tokens — callers must avoid passing sensitive credentials in `code` or `bodyText`.
|
|
49
|
-
*
|
|
50
|
-
* @param code - The error code string returned by the service
|
|
51
|
-
* @param bodyText - The response body text to inspect for entitlement-related phrases
|
|
52
|
-
* @returns `true` if the combined `code` or `bodyText` indicates an entitlement/subscription issue, `false` otherwise
|
|
53
|
-
*/
|
|
54
|
-
export declare function isEntitlementError(code: string, bodyText: string): boolean;
|
|
55
|
-
/**
|
|
56
|
-
* Detects whether an error indicates the workspace/account has been disabled or expired.
|
|
57
|
-
*
|
|
58
|
-
* Workspace disabled errors signal that the current workspace is no longer accessible
|
|
59
|
-
* (expired, disabled, or removed) and the plugin should automatically switch to another account.
|
|
60
|
-
*
|
|
61
|
-
* @param status - HTTP status code
|
|
62
|
-
* @param code - The error code string returned by the service
|
|
63
|
-
* @param bodyText - The response body text to inspect for workspace-related phrases
|
|
64
|
-
* @returns `true` if the error indicates a disabled/expired workspace
|
|
65
|
-
*/
|
|
66
|
-
export declare function isWorkspaceDisabledError(status: number, code: unknown, bodyText: string): boolean;
|
|
67
|
-
/**
|
|
68
|
-
* Constructs a standardized 403 entitlement error Response indicating the user lacks access to Codex models.
|
|
69
|
-
*
|
|
70
|
-
* This function returns a JSON Response with an `error` payload containing a user-facing message, a
|
|
71
|
-
* `type` of `"entitlement_error"`, and a `code` of `"usage_not_included"`. The message suggests checking
|
|
72
|
-
* account/workspace access and re-authenticating with `codex-multi-auth login`.
|
|
73
|
-
*
|
|
74
|
-
* Concurrency: stateless and safe to call concurrently from multiple threads or requests.
|
|
75
|
-
* Windows filesystem behavior: none (function does not access the filesystem).
|
|
76
|
-
* Token redaction: any tokens are not included in the generated payload; do not pass sensitive tokens in `_bodyText`.
|
|
77
|
-
*
|
|
78
|
-
* @param _bodyText - Original response body text (accepted for compatibility; ignored when building the response)
|
|
79
|
-
* @returns A 403 Response with a JSON body describing the entitlement error and guidance for resolving it
|
|
80
|
-
*/
|
|
81
|
-
export declare function createEntitlementErrorResponse(_bodyText: string): Response;
|
|
82
23
|
export interface ErrorHandlingResult {
|
|
83
24
|
response: Response;
|
|
84
25
|
rateLimit?: RateLimitInfo;
|
|
@@ -95,47 +36,6 @@ export interface ErrorDiagnostics {
|
|
|
95
36
|
threadId?: string;
|
|
96
37
|
httpStatus?: number;
|
|
97
38
|
}
|
|
98
|
-
export interface CreateCodexHeadersOptions {
|
|
99
|
-
model?: string;
|
|
100
|
-
promptCacheKey?: string;
|
|
101
|
-
}
|
|
102
|
-
export interface ProxyCompatibleRequestInit extends RequestInit {
|
|
103
|
-
agent?: unknown;
|
|
104
|
-
}
|
|
105
|
-
export interface CreateCodexHeadersParams {
|
|
106
|
-
init?: RequestInit;
|
|
107
|
-
accountId: string;
|
|
108
|
-
accessToken: string;
|
|
109
|
-
opts?: CreateCodexHeadersOptions;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Determines if the current auth token needs to be refreshed
|
|
113
|
-
* @param auth - Current authentication state
|
|
114
|
-
* @returns True if token is expired or invalid
|
|
115
|
-
*/
|
|
116
|
-
export declare function shouldRefreshToken(auth: Auth, skewMs?: number): boolean;
|
|
117
|
-
/**
|
|
118
|
-
* Refreshes the OAuth token and updates stored credentials
|
|
119
|
-
* @param currentAuth - Current auth state
|
|
120
|
-
* @param client - Codex client for updating stored credentials
|
|
121
|
-
* @returns Updated auth (throws on failure)
|
|
122
|
-
*/
|
|
123
|
-
export declare function refreshAndUpdateToken(currentAuth: Auth, client: CodexClient): Promise<Auth>;
|
|
124
|
-
/**
|
|
125
|
-
* Extracts URL string from various request input types
|
|
126
|
-
* @param input - Request input (string, URL, or Request object)
|
|
127
|
-
* @returns URL string
|
|
128
|
-
*/
|
|
129
|
-
export declare function extractRequestUrl(input: Request | string | URL): string;
|
|
130
|
-
/**
|
|
131
|
-
* Rewrites OpenAI API URLs to Codex backend URLs
|
|
132
|
-
* @param url - Original URL
|
|
133
|
-
* @returns Rewritten URL for Codex backend
|
|
134
|
-
*/
|
|
135
|
-
export declare function rewriteUrlForCodex(url: string): string;
|
|
136
|
-
export declare function resolveProxyUrlForRequest(url: string, env?: NodeJS.ProcessEnv): string | undefined;
|
|
137
|
-
export declare function closeSharedProxyDispatchers(): Promise<void>;
|
|
138
|
-
export declare function applyProxyCompatibleInit(url: string, init?: ProxyCompatibleRequestInit, env?: NodeJS.ProcessEnv): ProxyCompatibleRequestInit;
|
|
139
39
|
/**
|
|
140
40
|
* Transforms request body and logs the transformation
|
|
141
41
|
* Fetches model-specific Codex instructions based on the request model
|
|
@@ -155,14 +55,10 @@ export declare function transformRequestForCodex(init: RequestInit | undefined,
|
|
|
155
55
|
allowBackgroundResponses?: boolean;
|
|
156
56
|
}): Promise<TransformRequestForCodexResult | undefined>;
|
|
157
57
|
/**
|
|
158
|
-
*
|
|
159
|
-
* @param
|
|
160
|
-
* @
|
|
161
|
-
* @param accessToken - OAuth access token
|
|
162
|
-
* @returns Headers object with all required Codex headers
|
|
58
|
+
* Handles error responses from the Codex API
|
|
59
|
+
* @param response - Error response from API
|
|
60
|
+
* @returns Original response or mapped retryable response
|
|
163
61
|
*/
|
|
164
|
-
export declare function createCodexHeaders(params: CreateCodexHeadersParams): Headers;
|
|
165
|
-
export declare function createCodexHeaders(init: RequestInit | undefined, accountId: string, accessToken: string, opts?: CreateCodexHeadersOptions): Headers;
|
|
166
62
|
export declare function handleErrorResponse(response: Response, options?: ErrorHandlingOptions): Promise<ErrorHandlingResult>;
|
|
167
63
|
/**
|
|
168
64
|
* Handles successful responses from the Codex API
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch-helpers.d.ts","sourceRoot":"","sources":["../../../lib/request/fetch-helpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"fetch-helpers.d.ts","sourceRoot":"","sources":["../../../lib/request/fetch-helpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAIN,KAAK,wBAAwB,EAC7B,MAAM,0BAA0B,CAAC;AAMlC,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAgB3D,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC/E,OAAO,EACN,wCAAwC,EACxC,oCAAoC,EACpC,4BAA4B,EAC5B,oCAAoC,EACpC,uCAAuC,EACvC,kBAAkB,EAClB,wBAAwB,EACxB,8BAA8B,GAC9B,MAAM,2BAA2B,CAAC;AACnC,YAAY,EACX,gBAAgB,EAChB,yBAAyB,EACzB,sCAAsC,GACtC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACN,iBAAiB,EACjB,kBAAkB,EAClB,yBAAyB,EACzB,2BAA2B,EAC3B,wBAAwB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,YAAY,EACX,yBAAyB,EACzB,wBAAwB,GACxB,MAAM,cAAc,CAAC;AAEtB,MAAM,WAAW,aAAa;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;CACrB;AAQD,MAAM,WAAW,8BAA8B;IAC9C,IAAI,EAAE,WAAW,CAAC;IAClB,WAAW,EAAE,WAAW,CAAC;IACzB,4BAA4B,CAAC,EAAE,wBAAwB,CAAC,MAAM,CAAC,CAAC;CAChE;AAED,MAAM,WAAW,mBAAmB;IAC5B,QAAQ,EAAE,QAAQ,CAAC;IACnB,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,SAAS,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,oBAAoB;IACpC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,gBAAgB;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,wBAAwB,CAC7C,IAAI,EAAE,WAAW,GAAG,SAAS,EAC7B,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,UAAU,EACtB,SAAS,UAAO,EAChB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpC,OAAO,CAAC,EAAE;IACT,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,mBAAmB,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC1C,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,6BAA6B,CAAC,EAAE,OAAO,CAAC;IACxC,wBAAwB,CAAC,EAAE,OAAO,CAAC;CACnC,GACC,OAAO,CAAC,8BAA8B,GAAG,SAAS,CAAC,CA4FrD;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CACjC,QAAQ,EAAE,QAAQ,EAClB,OAAO,CAAC,EAAE,oBAAoB,GACnC,OAAO,CAAC,mBAAmB,CAAC,CA4C9B;AAED;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CACvC,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,OAAO,EACpB,OAAO,CAAC,EAAE;IACZ,YAAY,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5C,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC9B,GACC,OAAO,CAAC,QAAQ,CAAC,CAanB"}
|