codex-multi-auth 2.17.2 → 2.17.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 +1 -1
- package/README.md +83 -428
- package/dist/index.d.ts +0 -1
- package/dist/lib/account-policy.d.ts +18 -2
- package/dist/lib/account-policy.js +97 -40
- package/dist/lib/accounts/rate-limits.d.ts +0 -1
- package/dist/lib/accounts.d.ts +0 -1
- package/dist/lib/accounts.js +4 -5
- package/dist/lib/api-route-store.d.ts +0 -1
- package/dist/lib/audit.d.ts +0 -1
- package/dist/lib/audit.js +43 -12
- package/dist/lib/auth/account-access.d.ts +0 -1
- package/dist/lib/auth/account-access.js +5 -1
- package/dist/lib/auth/auth.d.ts +4 -3
- package/dist/lib/auth/auth.js +220 -28
- package/dist/lib/auth/browser.d.ts +0 -1
- package/dist/lib/auth/callback-guidance.d.ts +0 -1
- package/dist/lib/auth/device-auth.d.ts +0 -1
- package/dist/lib/auth/index.d.ts +0 -1
- package/dist/lib/auth/org-override.d.ts +0 -1
- package/dist/lib/auth/server.d.ts +1 -2
- package/dist/lib/auth/server.js +100 -53
- package/dist/lib/auth/token-utils.d.ts +0 -1
- package/dist/lib/auth-rate-limit.d.ts +0 -1
- package/dist/lib/budget-guard.d.ts +16 -2
- package/dist/lib/budget-guard.js +123 -43
- package/dist/lib/capability-policy.d.ts +0 -1
- package/dist/lib/circuit-breaker.d.ts +20 -1
- package/dist/lib/circuit-breaker.js +24 -5
- package/dist/lib/cli.d.ts +0 -1
- package/dist/lib/codex-cli/index.d.ts +0 -1
- package/dist/lib/codex-cli/observability.d.ts +0 -1
- package/dist/lib/codex-cli/state.d.ts +0 -1
- package/dist/lib/codex-cli/sync.d.ts +0 -1
- package/dist/lib/codex-cli/writer.d.ts +0 -1
- package/dist/lib/codex-manager/account-credentials.d.ts +0 -1
- package/dist/lib/codex-manager/account-manager-commands.d.ts +0 -1
- package/dist/lib/codex-manager/account-pool-write.d.ts +0 -1
- package/dist/lib/codex-manager/active-account-sync.d.ts +6 -0
- package/dist/lib/codex-manager/active-account-sync.js +336 -0
- package/dist/lib/codex-manager/api-login-menu.d.ts +0 -1
- package/dist/lib/codex-manager/backend-category-entry.d.ts +0 -1
- package/dist/lib/codex-manager/backend-category-helpers.d.ts +0 -1
- package/dist/lib/codex-manager/backend-category-prompt.d.ts +0 -1
- package/dist/lib/codex-manager/backend-settings-controller.d.ts +0 -1
- package/dist/lib/codex-manager/backend-settings-entry.d.ts +0 -1
- package/dist/lib/codex-manager/backend-settings-helpers.d.ts +0 -1
- package/dist/lib/codex-manager/backend-settings-prompt.d.ts +0 -1
- package/dist/lib/codex-manager/backend-settings-schema.d.ts +0 -1
- package/dist/lib/codex-manager/behavior-settings-panel.d.ts +0 -1
- package/dist/lib/codex-manager/commands/account.d.ts +8 -3
- package/dist/lib/codex-manager/commands/account.js +46 -34
- package/dist/lib/codex-manager/commands/best.d.ts +0 -1
- package/dist/lib/codex-manager/commands/bridge.d.ts +0 -1
- package/dist/lib/codex-manager/commands/budget.d.ts +8 -3
- package/dist/lib/codex-manager/commands/budget.js +6 -4
- package/dist/lib/codex-manager/commands/check.d.ts +0 -1
- package/dist/lib/codex-manager/commands/config-explain.d.ts +0 -1
- package/dist/lib/codex-manager/commands/debug-bundle.d.ts +0 -1
- package/dist/lib/codex-manager/commands/forecast.d.ts +0 -1
- package/dist/lib/codex-manager/commands/history.d.ts +0 -1
- package/dist/lib/codex-manager/commands/init-config.d.ts +0 -1
- package/dist/lib/codex-manager/commands/integrations.d.ts +0 -1
- package/dist/lib/codex-manager/commands/limits.d.ts +0 -1
- package/dist/lib/codex-manager/commands/models.d.ts +0 -1
- package/dist/lib/codex-manager/commands/monitor.d.ts +0 -1
- package/dist/lib/codex-manager/commands/report.d.ts +0 -1
- package/dist/lib/codex-manager/commands/resets.d.ts +0 -1
- package/dist/lib/codex-manager/commands/resets.js +9 -1
- package/dist/lib/codex-manager/commands/rotation.d.ts +0 -1
- package/dist/lib/codex-manager/commands/status.d.ts +0 -1
- package/dist/lib/codex-manager/commands/switch.d.ts +0 -1
- package/dist/lib/codex-manager/commands/uninstall.d.ts +0 -1
- package/dist/lib/codex-manager/commands/unpin.d.ts +0 -1
- package/dist/lib/codex-manager/commands/usage.d.ts +0 -1
- package/dist/lib/codex-manager/commands/verify.d.ts +0 -1
- package/dist/lib/codex-manager/commands/why-selected.d.ts +0 -1
- package/dist/lib/codex-manager/commands/workspace.d.ts +0 -1
- package/dist/lib/codex-manager/dashboard-display-panel.d.ts +0 -1
- package/dist/lib/codex-manager/dashboard-formatters.d.ts +0 -1
- package/dist/lib/codex-manager/dashboard-settings-controller.d.ts +0 -1
- package/dist/lib/codex-manager/dashboard-settings-data.d.ts +0 -1
- package/dist/lib/codex-manager/dashboard-settings-entry.d.ts +0 -1
- package/dist/lib/codex-manager/experimental-settings-entry.d.ts +0 -1
- package/dist/lib/codex-manager/experimental-settings-prompt.d.ts +0 -1
- package/dist/lib/codex-manager/experimental-settings-schema.d.ts +0 -1
- package/dist/lib/codex-manager/experimental-sync-target-entry.d.ts +0 -1
- package/dist/lib/codex-manager/experimental-sync-target.d.ts +0 -1
- package/dist/lib/codex-manager/forecast-report-shared.d.ts +0 -1
- package/dist/lib/codex-manager/formatters/account-formatters.d.ts +0 -1
- package/dist/lib/codex-manager/formatters/index.d.ts +0 -1
- package/dist/lib/codex-manager/formatters/model-formatters.d.ts +0 -1
- package/dist/lib/codex-manager/formatters/quota-formatters.d.ts +0 -1
- package/dist/lib/codex-manager/formatters/text-style.d.ts +0 -1
- package/dist/lib/codex-manager/health-check.d.ts +0 -1
- package/dist/lib/codex-manager/help.d.ts +0 -1
- package/dist/lib/codex-manager/login-action-panel.d.ts +0 -1
- package/dist/lib/codex-manager/login-flow.d.ts +0 -1
- package/dist/lib/codex-manager/login-menu-actions.d.ts +0 -1
- package/dist/lib/codex-manager/login-menu-data.d.ts +0 -1
- package/dist/lib/codex-manager/login-oauth.d.ts +0 -1
- package/dist/lib/codex-manager/login-workspace-choice.d.ts +0 -1
- package/dist/lib/codex-manager/manual-callback.d.ts +0 -1
- package/dist/lib/codex-manager/persist-selected-account.d.ts +0 -1
- package/dist/lib/codex-manager/quota-cache-helpers.d.ts +0 -1
- package/dist/lib/codex-manager/rate-limit-markers.d.ts +0 -1
- package/dist/lib/codex-manager/repair-commands.d.ts +0 -1
- package/dist/lib/codex-manager/settings-hub/backend.d.ts +0 -1
- package/dist/lib/codex-manager/settings-hub/dashboard.d.ts +0 -1
- package/dist/lib/codex-manager/settings-hub/experimental.d.ts +0 -1
- package/dist/lib/codex-manager/settings-hub/index.d.ts +0 -1
- package/dist/lib/codex-manager/settings-hub/shared.d.ts +0 -1
- package/dist/lib/codex-manager/settings-hub-entry.d.ts +0 -1
- package/dist/lib/codex-manager/settings-hub-menu.d.ts +0 -1
- package/dist/lib/codex-manager/settings-hub-prompt.d.ts +0 -1
- package/dist/lib/codex-manager/settings-hub.d.ts +0 -1
- package/dist/lib/codex-manager/settings-panels.d.ts +0 -1
- package/dist/lib/codex-manager/settings-persist-utils.d.ts +0 -1
- package/dist/lib/codex-manager/settings-preview.d.ts +0 -1
- package/dist/lib/codex-manager/settings-write-queue.d.ts +0 -1
- package/dist/lib/codex-manager/statusline-settings-panel.d.ts +0 -1
- package/dist/lib/codex-manager/theme-settings-panel.d.ts +0 -1
- package/dist/lib/codex-manager/unified-settings-controller.d.ts +0 -1
- package/dist/lib/codex-manager/unified-settings-entry.d.ts +0 -1
- package/dist/lib/codex-manager.d.ts +1 -2
- package/dist/lib/codex-manager.js +5 -95
- package/dist/lib/concurrency.d.ts +0 -1
- package/dist/lib/config-schema.d.ts +0 -1
- package/dist/lib/config.d.ts +0 -1
- package/dist/lib/config.js +46 -241
- package/dist/lib/constants.d.ts +0 -1
- package/dist/lib/context-budget/model-context-windows.d.ts +0 -1
- package/dist/lib/context-budget-guard.d.ts +0 -1
- package/dist/lib/context-budget-response.d.ts +0 -1
- package/dist/lib/context-overflow.d.ts +0 -1
- package/dist/lib/dashboard-settings.d.ts +0 -1
- package/dist/lib/entitlement-cache.d.ts +0 -1
- package/dist/lib/env-parsing.d.ts +13 -1
- package/dist/lib/env-parsing.js +21 -0
- package/dist/lib/errors.d.ts +0 -1
- package/dist/lib/forecast.d.ts +0 -1
- package/dist/lib/fs-retry.d.ts +0 -1
- package/dist/lib/health.d.ts +0 -1
- package/dist/lib/index.d.ts +0 -1
- package/dist/lib/integration-generators.d.ts +0 -1
- package/dist/lib/live-account-sync.d.ts +0 -1
- package/dist/lib/local-bridge.d.ts +0 -1
- package/dist/lib/local-bridge.js +4 -1
- package/dist/lib/local-client-tokens.d.ts +0 -1
- package/dist/lib/local-client-tokens.js +125 -30
- package/dist/lib/logger.d.ts +0 -1
- package/dist/lib/logger.js +11 -1
- package/dist/lib/model-capability-matrix.d.ts +0 -1
- package/dist/lib/model-route-policy.d.ts +1 -2
- package/dist/lib/named-backup-export.d.ts +0 -1
- package/dist/lib/oc-chatgpt-import-adapter.d.ts +0 -1
- package/dist/lib/oc-chatgpt-orchestrator.d.ts +0 -1
- package/dist/lib/oc-chatgpt-target-detection.d.ts +0 -1
- package/dist/lib/parallel-probe.d.ts +0 -1
- package/dist/lib/policy/runtime-policy-cache.d.ts +80 -0
- package/dist/lib/policy/runtime-policy-cache.js +310 -0
- package/dist/lib/policy/runtime-policy.d.ts +1 -2
- package/dist/lib/policy/runtime-policy.js +46 -19
- package/dist/lib/preemptive-quota-scheduler.d.ts +0 -1
- package/dist/lib/proactive-refresh.d.ts +0 -1
- package/dist/lib/prompts/codex-host-bridge.d.ts +0 -1
- package/dist/lib/prompts/codex.d.ts +0 -1
- package/dist/lib/prompts/fetch-utils.d.ts +0 -1
- package/dist/lib/prompts/host-codex-prompt.d.ts +0 -1
- package/dist/lib/quota-cache.d.ts +0 -1
- package/dist/lib/quota-cache.js +60 -36
- package/dist/lib/quota-probe.d.ts +0 -1
- package/dist/lib/quota-probe.js +5 -2
- package/dist/lib/quota-readiness.d.ts +0 -1
- package/dist/lib/recovery/constants.d.ts +0 -1
- package/dist/lib/recovery/storage.d.ts +0 -1
- package/dist/lib/recovery/types.d.ts +0 -1
- package/dist/lib/recovery.d.ts +0 -1
- package/dist/lib/redaction.d.ts +0 -1
- package/dist/lib/refresh-guardian.d.ts +0 -1
- package/dist/lib/refresh-lease.d.ts +0 -1
- package/dist/lib/refresh-queue.d.ts +0 -1
- package/dist/lib/request/client-cancellation.d.ts +0 -1
- package/dist/lib/request/error-classification.d.ts +0 -1
- package/dist/lib/request/failover-config.d.ts +0 -1
- package/dist/lib/request/failure-policy.d.ts +0 -1
- package/dist/lib/request/fetch-helpers.d.ts +0 -1
- package/dist/lib/request/headers.d.ts +0 -1
- package/dist/lib/request/helpers/input-utils.d.ts +0 -1
- package/dist/lib/request/helpers/input-utils.js +88 -34
- package/dist/lib/request/helpers/model-map.d.ts +0 -1
- package/dist/lib/request/helpers/tool-utils.d.ts +0 -1
- package/dist/lib/request/helpers/tool-utils.js +421 -4
- package/dist/lib/request/index.d.ts +0 -1
- package/dist/lib/request/rate-limit-backoff.d.ts +0 -1
- package/dist/lib/request/rate-limit-decision.d.ts +0 -1
- package/dist/lib/request/request-attempt-budget.d.ts +0 -1
- package/dist/lib/request/request-init.d.ts +0 -1
- package/dist/lib/request/request-resilience.d.ts +0 -1
- package/dist/lib/request/request-transformer.d.ts +0 -1
- package/dist/lib/request/request-transformer.js +50 -25
- package/dist/lib/request/response-compaction.d.ts +0 -1
- package/dist/lib/request/response-handler.d.ts +0 -1
- package/dist/lib/request/response-metadata.d.ts +0 -1
- package/dist/lib/request/response-outcome.d.ts +0 -1
- package/dist/lib/request/stream-failover-runtime.d.ts +0 -1
- package/dist/lib/request/stream-failover.d.ts +0 -1
- package/dist/lib/request/stream-failover.js +28 -4
- package/dist/lib/request/token-refresh.d.ts +0 -1
- package/dist/lib/request/url-rewriting.d.ts +0 -1
- package/dist/lib/request/wait-utils.d.ts +0 -1
- package/dist/lib/rotation.d.ts +0 -1
- package/dist/lib/routing-mutex.d.ts +0 -1
- package/dist/lib/routing-profiles.d.ts +16 -2
- package/dist/lib/routing-profiles.js +119 -44
- package/dist/lib/runtime/account-check-helpers.d.ts +0 -1
- package/dist/lib/runtime/account-check-types.d.ts +0 -1
- package/dist/lib/runtime/account-check.d.ts +0 -1
- package/dist/lib/runtime/account-manager-cache-entry.d.ts +0 -1
- package/dist/lib/runtime/account-manager-cache.d.ts +0 -1
- package/dist/lib/runtime/account-model-catalog.d.ts +1 -2
- package/dist/lib/runtime/account-pool.d.ts +0 -1
- package/dist/lib/runtime/account-reset-credits.d.ts +0 -1
- package/dist/lib/runtime/account-reset-credits.js +8 -2
- package/dist/lib/runtime/account-scope.d.ts +0 -1
- package/dist/lib/runtime/account-select-event.d.ts +0 -1
- package/dist/lib/runtime/account-selection.d.ts +0 -1
- package/dist/lib/runtime/account-state.d.ts +0 -1
- package/dist/lib/runtime/account-status.d.ts +0 -1
- package/dist/lib/runtime/account-storage-scope-entry.d.ts +0 -1
- package/dist/lib/runtime/api-model-capabilities.d.ts +0 -1
- package/dist/lib/runtime/api-model-runtime.d.ts +0 -1
- package/dist/lib/runtime/app-bind.d.ts +0 -1
- package/dist/lib/runtime/app-helper-selection.d.ts +0 -1
- package/dist/lib/runtime/auth-facade.d.ts +0 -1
- package/dist/lib/runtime/automatic-account-checks.d.ts +0 -1
- package/dist/lib/runtime/automatic-subscription-checks.d.ts +0 -1
- package/dist/lib/runtime/browser-oauth-flow.d.ts +0 -1
- package/dist/lib/runtime/capability-boost.d.ts +0 -1
- package/dist/lib/runtime/catalog-capabilities.d.ts +0 -1
- package/dist/lib/runtime/config-toml.d.ts +0 -1
- package/dist/lib/runtime/context-budget-settings.d.ts +0 -1
- package/dist/lib/runtime/event-handler.d.ts +0 -1
- package/dist/lib/runtime/first-run.d.ts +0 -1
- package/dist/lib/runtime/flagged-verify-types.d.ts +0 -1
- package/dist/lib/runtime/hydrate-emails.d.ts +0 -1
- package/dist/lib/runtime/inference-activity.d.ts +0 -1
- package/dist/lib/runtime/live-sync-entry.d.ts +0 -1
- package/dist/lib/runtime/live-sync.d.ts +0 -1
- package/dist/lib/runtime/loader-setup.d.ts +0 -1
- package/dist/lib/runtime/login-menu-accounts.d.ts +0 -1
- package/dist/lib/runtime/manual-oauth-flow.d.ts +0 -1
- package/dist/lib/runtime/model-discovery-status.d.ts +2 -3
- package/dist/lib/runtime/native-account-storage.d.ts +0 -1
- package/dist/lib/runtime/native-account-sync.d.ts +0 -1
- package/dist/lib/runtime/native-binding-lock.d.ts +0 -1
- package/dist/lib/runtime/native-client-auth.d.ts +0 -1
- package/dist/lib/runtime/native-provider-config.d.ts +0 -1
- package/dist/lib/runtime/native-rate-limits.d.ts +2 -1
- package/dist/lib/runtime/native-rate-limits.js +23 -6
- package/dist/lib/runtime/preemptive-quota.d.ts +0 -1
- package/dist/lib/runtime/quota-headers.d.ts +0 -1
- package/dist/lib/runtime/quota-probe.d.ts +0 -1
- package/dist/lib/runtime/quota-settings.d.ts +0 -1
- package/dist/lib/runtime/refresh-guardian-entry.d.ts +0 -1
- package/dist/lib/runtime/refresh-guardian.d.ts +0 -1
- package/dist/lib/runtime/request-init.d.ts +0 -1
- package/dist/lib/runtime/reset-credit-routing.d.ts +0 -1
- package/dist/lib/runtime/reset-credits.d.ts +0 -1
- package/dist/lib/runtime/response-output-history.d.ts +0 -1
- package/dist/lib/runtime/responses-websocket.d.ts +0 -1
- package/dist/lib/runtime/resume-picker.d.ts +0 -1
- package/dist/lib/runtime/rotation-account-selection.d.ts +0 -1
- package/dist/lib/runtime/rotation-proxy-state.d.ts +0 -1
- package/dist/lib/runtime/rotation-server-types.d.ts +0 -1
- package/dist/lib/runtime/rotation-storage-meta.d.ts +0 -1
- package/dist/lib/runtime/rotation-token-refresh.d.ts +0 -1
- package/dist/lib/runtime/runtime-capability-failures.d.ts +0 -1
- package/dist/lib/runtime/runtime-current-account.d.ts +0 -1
- package/dist/lib/runtime/runtime-observability.d.ts +0 -1
- package/dist/lib/runtime/runtime-services.d.ts +0 -1
- package/dist/lib/runtime/session-affinity-entry.d.ts +0 -1
- package/dist/lib/runtime/session-recovery.d.ts +0 -1
- package/dist/lib/runtime/status-marker.d.ts +0 -1
- package/dist/lib/runtime/storage-scope.d.ts +0 -1
- package/dist/lib/runtime/subscription-first-use.d.ts +0 -1
- package/dist/lib/runtime/subscription-quota-event.d.ts +0 -1
- package/dist/lib/runtime/subscription-quota-order.d.ts +0 -1
- package/dist/lib/runtime/toast.d.ts +0 -1
- package/dist/lib/runtime/ui-runtime-entry.d.ts +0 -1
- package/dist/lib/runtime/ui-runtime.d.ts +0 -1
- package/dist/lib/runtime/verify-flagged.d.ts +0 -1
- package/dist/lib/runtime/workspace-model-scopes.d.ts +0 -1
- package/dist/lib/runtime-constants.d.ts +0 -1
- package/dist/lib/runtime-paths.d.ts +0 -1
- package/dist/lib/runtime-rotation-proxy.d.ts +1 -1
- package/dist/lib/runtime-rotation-proxy.js +133 -0
- package/dist/lib/schemas.d.ts +35 -13
- package/dist/lib/schemas.js +19 -2
- package/dist/lib/session-affinity.d.ts +0 -1
- package/dist/lib/shutdown.d.ts +0 -1
- package/dist/lib/storage/account-clear-entry.d.ts +0 -1
- package/dist/lib/storage/account-clear.d.ts +0 -1
- package/dist/lib/storage/account-match-utils.d.ts +0 -1
- package/dist/lib/storage/account-persistence.d.ts +0 -1
- package/dist/lib/storage/account-port.d.ts +0 -1
- package/dist/lib/storage/account-save-entry.d.ts +0 -1
- package/dist/lib/storage/account-save.d.ts +9 -2
- package/dist/lib/storage/account-save.js +4 -1
- package/dist/lib/storage/account-snapshot.d.ts +0 -1
- package/dist/lib/storage/backup-metadata-builder.d.ts +0 -1
- package/dist/lib/storage/backup-metadata.d.ts +0 -1
- package/dist/lib/storage/backup-paths.d.ts +0 -1
- package/dist/lib/storage/backup-restore.d.ts +0 -1
- package/dist/lib/storage/cache-artifacts.d.ts +0 -1
- package/dist/lib/storage/credential-sidecars.d.ts +0 -1
- package/dist/lib/storage/error-hints.d.ts +0 -1
- package/dist/lib/storage/file-lock.d.ts +0 -1
- package/dist/lib/storage/file-lock.js +33 -1
- package/dist/lib/storage/file-paths.d.ts +0 -1
- package/dist/lib/storage/fixture-guards.d.ts +0 -1
- package/dist/lib/storage/flagged-entry.d.ts +0 -1
- package/dist/lib/storage/flagged-load-entry.d.ts +0 -1
- package/dist/lib/storage/flagged-save-entry.d.ts +0 -1
- package/dist/lib/storage/flagged-storage-file.d.ts +0 -1
- package/dist/lib/storage/flagged-storage-io.d.ts +0 -1
- package/dist/lib/storage/flagged-storage.d.ts +0 -1
- package/dist/lib/storage/gitignore.d.ts +0 -1
- package/dist/lib/storage/hash.d.ts +0 -1
- package/dist/lib/storage/health.d.ts +0 -1
- package/dist/lib/storage/identity.d.ts +0 -1
- package/dist/lib/storage/import-export.d.ts +0 -1
- package/dist/lib/storage/json-store-lock.d.ts +105 -0
- package/dist/lib/storage/json-store-lock.js +259 -0
- package/dist/lib/storage/metadata-section.d.ts +0 -1
- package/dist/lib/storage/migrations.d.ts +0 -1
- package/dist/lib/storage/migrations.js +31 -18
- package/dist/lib/storage/named-backup-entry.d.ts +0 -1
- package/dist/lib/storage/named-backups-entry.d.ts +0 -1
- package/dist/lib/storage/named-backups.d.ts +0 -1
- package/dist/lib/storage/path-state.d.ts +0 -1
- package/dist/lib/storage/paths.d.ts +0 -1
- package/dist/lib/storage/pending-auth.d.ts +9 -3
- package/dist/lib/storage/pending-auth.js +30 -8
- package/dist/lib/storage/project-migration.d.ts +0 -1
- package/dist/lib/storage/public-types.d.ts +0 -1
- package/dist/lib/storage/record-identity.d.ts +0 -1
- package/dist/lib/storage/record-utils.d.ts +0 -1
- package/dist/lib/storage/restore-assessment.d.ts +0 -1
- package/dist/lib/storage/restore-backup-entry.d.ts +0 -1
- package/dist/lib/storage/restore-metadata.d.ts +0 -1
- package/dist/lib/storage/save-retry.d.ts +0 -1
- package/dist/lib/storage/snapshot-inspectors.d.ts +0 -1
- package/dist/lib/storage/snapshot-merge.d.ts +0 -1
- package/dist/lib/storage/storage-parser.d.ts +2 -1
- package/dist/lib/storage/storage-parser.js +10 -2
- package/dist/lib/storage/transactions.d.ts +0 -1
- package/dist/lib/storage.d.ts +15 -2
- package/dist/lib/storage.js +612 -25
- package/dist/lib/synthetic-response.d.ts +0 -1
- package/dist/lib/table-formatter.d.ts +0 -1
- package/dist/lib/temp-path.d.ts +0 -1
- package/dist/lib/tools/hashline-tools.d.ts +0 -1
- package/dist/lib/types.d.ts +0 -1
- package/dist/lib/ui/ansi.d.ts +0 -1
- package/dist/lib/ui/auth-menu-builder.d.ts +0 -1
- package/dist/lib/ui/auth-menu.d.ts +0 -1
- package/dist/lib/ui/check-progress.d.ts +0 -1
- package/dist/lib/ui/confirm.d.ts +0 -1
- package/dist/lib/ui/display-width.d.ts +0 -1
- package/dist/lib/ui/format.d.ts +0 -1
- package/dist/lib/ui/index.d.ts +0 -1
- package/dist/lib/ui/runtime.d.ts +0 -1
- package/dist/lib/ui/select.d.ts +0 -1
- package/dist/lib/ui/theme.d.ts +0 -1
- package/dist/lib/ui/ui-copy.d.ts +0 -1
- package/dist/lib/unified-settings.d.ts +13 -11
- package/dist/lib/unified-settings.js +22 -14
- package/dist/lib/update-notice.d.ts +0 -1
- package/dist/lib/usage/index.d.ts +0 -1
- package/dist/lib/usage/ledger.d.ts +0 -1
- package/dist/lib/usage/pricing.d.ts +0 -1
- package/dist/lib/usage/redaction.d.ts +0 -1
- package/dist/lib/usage/stream-usage-deferral.d.ts +0 -1
- package/dist/lib/usage/types.d.ts +0 -1
- package/dist/lib/usage/usage-extraction.d.ts +0 -1
- package/dist/lib/utils.d.ts +21 -1
- package/dist/lib/utils.js +31 -0
- package/dist/lib/wsl.d.ts +0 -1
- package/package.json +11 -5
- package/scripts/codex-bin-resolver.js +20 -1
- package/scripts/codex-multi-auth.js +7 -1
- package/scripts/codex.js +288 -7
- package/skills/codex-auth-setup/SKILL.md +73 -0
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export { hasNativeProviderConfig } from "../runtime-constants.js";
|
|
2
2
|
export declare function rewriteNativeProviderConfig(content: string, baseUrl: string): string;
|
|
3
3
|
export declare function restoreNativeProviderConfig(content: string, original: string): string;
|
|
4
|
-
//# sourceMappingURL=native-provider-config.d.ts.map
|
|
@@ -7,6 +7,8 @@ export interface NativeUsageAuth {
|
|
|
7
7
|
codexCliMirror?: CodexCliMirror;
|
|
8
8
|
}
|
|
9
9
|
type Method = 'account/rateLimits/read' | 'account/rateLimitResetCredit/consume';
|
|
10
|
+
/** @internal Native usage needs the desktop backend when it is installed. */
|
|
11
|
+
export declare function resolveNativeUsageCommand(platform?: NodeJS.Platform): string[];
|
|
10
12
|
/** One bounded native RPC session in an isolated home. No refresh token, API key,
|
|
11
13
|
* global configuration, or desktop auth changes are available to this process. */
|
|
12
14
|
export declare function nativeRateLimitsRpc(auth: NativeUsageAuth, method: Method, params: Record<string, unknown>, options?: {
|
|
@@ -15,4 +17,3 @@ export declare function nativeRateLimitsRpc(auth: NativeUsageAuth, method: Metho
|
|
|
15
17
|
timeoutMs?: number;
|
|
16
18
|
}): Promise<unknown>;
|
|
17
19
|
export {};
|
|
18
|
-
//# sourceMappingURL=native-rate-limits.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
|
-
import { existsSync, promises as fs } from 'node:fs';
|
|
2
|
+
import { accessSync, constants, existsSync, promises as fs, statSync } from 'node:fs';
|
|
3
3
|
import { createRequire } from 'node:module';
|
|
4
4
|
import { isAbsolute, join } from 'node:path';
|
|
5
5
|
import { codexCliAccountIdFor } from '../auth/token-utils.js';
|
|
@@ -18,7 +18,8 @@ async function sweepStaleHomes(root) {
|
|
|
18
18
|
catch { /* Another process owns or already removed it. */ }
|
|
19
19
|
}));
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
/** @internal Native usage needs the desktop backend when it is installed. */
|
|
22
|
+
export function resolveNativeUsageCommand(platform = process.platform) {
|
|
22
23
|
const override = process.env.CODEX_MULTI_AUTH_USAGE_CODEX_BIN?.trim();
|
|
23
24
|
if (override) {
|
|
24
25
|
if (!isAbsolute(override) || !existsSync(override))
|
|
@@ -26,9 +27,25 @@ function nativeCommand() {
|
|
|
26
27
|
return [override];
|
|
27
28
|
}
|
|
28
29
|
// Prefer the desktop backend whose protocol supplies the native usage UI.
|
|
29
|
-
const bundled =
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
const bundled = [
|
|
31
|
+
'/Applications/ChatGPT.app/Contents/Resources/codex-cli/bin/codex',
|
|
32
|
+
'/Applications/ChatGPT.app/Contents/Resources/codex',
|
|
33
|
+
];
|
|
34
|
+
if (platform === 'darwin') {
|
|
35
|
+
const executable = bundled.find(path => {
|
|
36
|
+
try {
|
|
37
|
+
if (!statSync(path).isFile())
|
|
38
|
+
return false;
|
|
39
|
+
accessSync(path, constants.X_OK);
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
if (executable)
|
|
47
|
+
return [executable];
|
|
48
|
+
}
|
|
32
49
|
try {
|
|
33
50
|
return [process.execPath, createRequire(import.meta.url).resolve('@openai/codex/bin/codex.js')];
|
|
34
51
|
}
|
|
@@ -41,7 +58,7 @@ function nativeCommand() {
|
|
|
41
58
|
export async function nativeRateLimitsRpc(auth, method, params, options = {}) {
|
|
42
59
|
if (!auth.accessToken || !auth.accountId || auth.expiresAt <= Date.now() + 30000)
|
|
43
60
|
throw Error('Native usage requires a fresh account access token');
|
|
44
|
-
const command = options.command ??
|
|
61
|
+
const command = options.command ?? resolveNativeUsageCommand();
|
|
45
62
|
const executable = command[0];
|
|
46
63
|
if (!executable)
|
|
47
64
|
throw Error('Native usage backend unavailable');
|
|
@@ -10,4 +10,3 @@ export declare function applyRuntimePreemptiveQuotaSettings<TConfig>(pluginConfi
|
|
|
10
10
|
getPreemptiveQuotaRemainingPercent7d: (config: TConfig) => number;
|
|
11
11
|
getPreemptiveQuotaMaxDeferralMs: (config: TConfig) => number;
|
|
12
12
|
}): void;
|
|
13
|
-
//# sourceMappingURL=preemptive-quota.d.ts.map
|
|
@@ -4,4 +4,3 @@ export type ParsedCodexQuotaSnapshot = Omit<CodexQuotaSnapshot, "model">;
|
|
|
4
4
|
export declare function parseResetAtMs(headers: Headers, prefix: string): number | undefined;
|
|
5
5
|
export declare function parseCodexQuotaSnapshot(headers: Headers, status: number): ParsedCodexQuotaSnapshot | null;
|
|
6
6
|
export declare function formatCodexQuotaLine(snapshot: Pick<CodexQuotaSnapshot, "status" | "planType" | "activeLimit" | "primary" | "secondary">): string;
|
|
7
|
-
//# sourceMappingURL=quota-headers.d.ts.map
|
|
@@ -11,4 +11,3 @@ export declare function applyPreemptiveQuotaSettingsFromConfig(pluginConfig: Ret
|
|
|
11
11
|
getPreemptiveQuotaMaxDeferralMs: (config: ReturnType<typeof import("../config.js").loadPluginConfig>) => number;
|
|
12
12
|
}): void;
|
|
13
13
|
export declare function resolveUiRuntimeFromConfig(loadPluginConfig: () => ReturnType<typeof import("../config.js").loadPluginConfig>, applyUiRuntimeFromConfig: (pluginConfig: ReturnType<typeof import("../config.js").loadPluginConfig>) => ReturnType<typeof import("../ui/runtime.js").getUiRuntimeOptions>): ReturnType<typeof import("../ui/runtime.js").getUiRuntimeOptions>;
|
|
14
|
-
//# sourceMappingURL=quota-settings.d.ts.map
|
|
@@ -2,4 +2,3 @@ export declare function normalizeRuntimeRequestInit(requestInput: Request | stri
|
|
|
2
2
|
export declare function parseRuntimeRequestBody(body: unknown, deps: {
|
|
3
3
|
logWarn: (message: string) => void;
|
|
4
4
|
}): Promise<Record<string, unknown>>;
|
|
5
|
-
//# sourceMappingURL=request-init.d.ts.map
|
|
@@ -38,4 +38,3 @@ export declare function pickResumeThread(options: ResumePickerOptions, deps?: {
|
|
|
38
38
|
select: (items: MenuItem<Choice>[], options: import("../ui/select.js").SelectOptions<Choice>) => Promise<Choice | null>;
|
|
39
39
|
}): Promise<string | null>;
|
|
40
40
|
export {};
|
|
41
|
-
//# sourceMappingURL=resume-picker.d.ts.map
|
|
@@ -101,4 +101,3 @@ export interface RotationProxyState extends RotationProxyStateInit {
|
|
|
101
101
|
export declare function createRotationProxyState(init: RotationProxyStateInit): RotationProxyState;
|
|
102
102
|
/** @internal */
|
|
103
103
|
export declare function recoverStaleRuntimeState(state: RotationProxyState): Promise<AccountManager | null>;
|
|
104
|
-
//# sourceMappingURL=rotation-proxy-state.d.ts.map
|
|
@@ -37,4 +37,3 @@ export declare function resetPinCacheForTesting(): void;
|
|
|
37
37
|
* spinning up the full proxy. See issue #474.
|
|
38
38
|
*/
|
|
39
39
|
export declare function maybeInvalidateAffinityFromDisk(sessionAffinityStore: SessionAffinityStore | null, lastObservedGeneration: number, storagePath?: string): number;
|
|
40
|
-
//# sourceMappingURL=rotation-storage-meta.d.ts.map
|
|
@@ -11,4 +11,3 @@ export declare class RuntimeCapabilityFailures {
|
|
|
11
11
|
record(credential: string, model: string, kind: CapabilityFailure, effort?: string, tier?: string): void;
|
|
12
12
|
supports(credential: string, model: string, effort?: string, tier?: string): boolean;
|
|
13
13
|
}
|
|
14
|
-
//# sourceMappingURL=runtime-capability-failures.d.ts.map
|
|
@@ -50,4 +50,3 @@ export declare function resolveRuntimeCurrentAccount(storage: AccountStorageV3,
|
|
|
50
50
|
export declare function resolveAccountCurrentMarkers(index: number, storedCurrentIndex: number, runtimeCurrent: RuntimeCurrentAccountSelection | null): AccountCurrentMarker[];
|
|
51
51
|
export declare function isDisplayCurrentAccount(index: number, storedCurrentIndex: number, runtimeCurrent: RuntimeCurrentAccountSelection | null): boolean;
|
|
52
52
|
export {};
|
|
53
|
-
//# sourceMappingURL=runtime-current-account.d.ts.map
|
|
@@ -81,4 +81,3 @@ export declare function recordRuntimeReset(reason: string): void;
|
|
|
81
81
|
export declare function recordRuntimeAccountRecovery(index: number): void;
|
|
82
82
|
export declare function loadPersistedRuntimeObservabilitySnapshot(): Promise<RuntimeObservabilitySnapshot | null>;
|
|
83
83
|
export {};
|
|
84
|
-
//# sourceMappingURL=runtime-observability.d.ts.map
|
|
@@ -7,4 +7,3 @@ export declare class FirstUseProbeError extends Error {
|
|
|
7
7
|
}
|
|
8
8
|
/** Consume the already-open tiny response, never start a second request. */
|
|
9
9
|
export declare function finishSubscriptionFirstUse(response: Response, timeoutMs: number): Promise<void>;
|
|
10
|
-
//# sourceMappingURL=subscription-first-use.d.ts.map
|
|
@@ -3,4 +3,3 @@ import type { QuotaSchedulerSnapshot } from "../preemptive-quota-scheduler.js";
|
|
|
3
3
|
export declare function readSubscriptionQuotaEvent(event: unknown, now: number): (QuotaSchedulerSnapshot & {
|
|
4
4
|
planType?: string;
|
|
5
5
|
}) | null;
|
|
6
|
-
//# sourceMappingURL=subscription-quota-event.d.ts.map
|
|
@@ -14,4 +14,3 @@ export declare function subscriptionQuotaPreference(entry: QuotaCacheEntry | nul
|
|
|
14
14
|
export declare function usesSubscriptionReserve(preference: SubscriptionQuotaPreference | undefined): boolean;
|
|
15
15
|
/** Negative means a should be used first. Equal hints leave existing health/affinity scoring intact. */
|
|
16
16
|
export declare function compareSubscriptionQuota(a: SubscriptionQuotaPreference, b: SubscriptionQuotaPreference): number;
|
|
17
|
-
//# sourceMappingURL=subscription-quota-order.d.ts.map
|
|
@@ -4,4 +4,3 @@ export declare function resolveUiRuntimeEntry(params: {
|
|
|
4
4
|
resolveUiRuntimeFromConfig: (loadPluginConfig: () => ReturnType<typeof import("../config.js").loadPluginConfig>, applyUiRuntimeFromConfig: (pluginConfig: ReturnType<typeof import("../config.js").loadPluginConfig>) => UiRuntimeOptions) => UiRuntimeOptions;
|
|
5
5
|
applyUiRuntimeFromConfig: (pluginConfig: ReturnType<typeof import("../config.js").loadPluginConfig>) => UiRuntimeOptions;
|
|
6
6
|
}): UiRuntimeOptions;
|
|
7
|
-
//# sourceMappingURL=ui-runtime-entry.d.ts.map
|
|
@@ -6,4 +6,3 @@ export declare function applyUiRuntimeFromConfig(pluginConfig: ReturnType<typeof
|
|
|
6
6
|
glyphMode: ReturnType<typeof getCodexTuiGlyphMode>;
|
|
7
7
|
}) => UiRuntimeOptions): UiRuntimeOptions;
|
|
8
8
|
export declare function getStatusMarker(ui: UiRuntimeOptions, status: "ok" | "warning" | "error"): string;
|
|
9
|
-
//# sourceMappingURL=ui-runtime.d.ts.map
|
|
@@ -35,4 +35,3 @@ export declare function listRuntimeHelperOwnerPaths(baseDir: string, entries: re
|
|
|
35
35
|
/** Marker shared by config binding and desktop-auth sync protection. */
|
|
36
36
|
export declare const NATIVE_PROVIDER_BEGIN = "# codex-multi-auth native provider begin";
|
|
37
37
|
export declare function hasNativeProviderConfig(content: string): boolean;
|
|
38
|
-
//# sourceMappingURL=runtime-constants.d.ts.map
|
|
@@ -7,6 +7,7 @@ export type { PinnedUnavailableErrorBody } from "./request/rate-limit-decision.j
|
|
|
7
7
|
export { chooseAccount } from "./runtime/rotation-account-selection.js";
|
|
8
8
|
export { maybeInvalidateAffinityFromDisk, readPinnedAccountIndexFromDisk, readStorageMetaFromDisk, resetPinCacheForTesting, } from "./runtime/rotation-storage-meta.js";
|
|
9
9
|
export type { StorageMeta } from "./runtime/rotation-storage-meta.js";
|
|
10
|
+
export { resetRuntimePolicyCacheForTests } from "./policy/runtime-policy-cache.js";
|
|
10
11
|
/** @internal Stable identity key for in-memory quota snapshots across reloads. */
|
|
11
12
|
/**
|
|
12
13
|
* Quota-scheduler key prefix identifying ONE account across every family and
|
|
@@ -47,4 +48,3 @@ export declare function resolveModelCapacityRetryMs(env?: NodeJS.ProcessEnv): nu
|
|
|
47
48
|
*/
|
|
48
49
|
export declare function normalizeForcedAccountIndex(value: number | string | null | undefined): number | null;
|
|
49
50
|
export declare function startRuntimeRotationProxy(options: RuntimeRotationProxyOptions): Promise<RuntimeRotationProxyServer>;
|
|
50
|
-
//# sourceMappingURL=runtime-rotation-proxy.d.ts.map
|
|
@@ -54,6 +54,7 @@ import { isRecord, sleep } from "./utils.js";
|
|
|
54
54
|
export { buildPinnedUnavailableErrorBody, buildTokenInvalidationBody, } from "./request/rate-limit-decision.js";
|
|
55
55
|
export { chooseAccount } from "./runtime/rotation-account-selection.js";
|
|
56
56
|
export { maybeInvalidateAffinityFromDisk, readPinnedAccountIndexFromDisk, readStorageMetaFromDisk, resetPinCacheForTesting, } from "./runtime/rotation-storage-meta.js";
|
|
57
|
+
export { resetRuntimePolicyCacheForTests } from "./policy/runtime-policy-cache.js";
|
|
57
58
|
const DEFAULT_HOST = "127.0.0.1";
|
|
58
59
|
function isLoopbackHost(host) {
|
|
59
60
|
const normalized = host.trim().toLowerCase();
|
|
@@ -87,6 +88,102 @@ function toUrlHost(host) {
|
|
|
87
88
|
const bare = stripIpv6Brackets(host);
|
|
88
89
|
return bare.includes(":") ? `[${bare}]` : bare;
|
|
89
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* True only for a NUMERIC loopback literal, as `new URL().hostname` reports it.
|
|
93
|
+
*
|
|
94
|
+
* Duplicates the wrapper's predicate (scripts/codex.js) at library level — a
|
|
95
|
+
* hostname like "localhost" is deliberately NOT enough: it is resolved by the
|
|
96
|
+
* OS at connect time, so an /etc/hosts or Windows hosts entry can point it at
|
|
97
|
+
* a routable address, and the upstream request carries the managed OAuth
|
|
98
|
+
* bearer token and the request body. WHATWG URL always reports an IPv6 host in
|
|
99
|
+
* its bracketed form, so `::1` is only ever seen here as `[::1]`.
|
|
100
|
+
*/
|
|
101
|
+
function isNumericLoopbackUrlHostname(hostname) {
|
|
102
|
+
if (hostname === "[::1]") {
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
const ipv4 = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/.exec(hostname);
|
|
106
|
+
if (!ipv4) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
const octets = ipv4.slice(1).map((part) => Number(part));
|
|
110
|
+
if (octets.some((octet) => !Number.isInteger(octet) || octet > 255)) {
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
// The whole 127.0.0.0/8 block is loopback, not just 127.0.0.1.
|
|
114
|
+
return octets[0] === 127;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Whether the raw URL text carries an explicit `:port` (mirrors the wrapper).
|
|
118
|
+
*
|
|
119
|
+
* `new URL()` erases a port that matches the scheme default, so
|
|
120
|
+
* `http://127.0.0.1:80/x` reports `parsed.port === ""` and a `!parsed.port`
|
|
121
|
+
* check would reject a perfectly valid, explicitly-ported loopback URL.
|
|
122
|
+
*/
|
|
123
|
+
function urlHasExplicitPort(raw) {
|
|
124
|
+
const withoutScheme = raw.replace(/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//, "");
|
|
125
|
+
const authority = withoutScheme.split(/[/?#]/, 1)[0] ?? "";
|
|
126
|
+
// Strip userinfo first, or a password containing ':' reads as a port.
|
|
127
|
+
const hostAndPort = authority.slice(authority.lastIndexOf("@") + 1);
|
|
128
|
+
if (hostAndPort.startsWith("[")) {
|
|
129
|
+
const close = hostAndPort.indexOf("]");
|
|
130
|
+
return close !== -1 && /^:\d+$/.test(hostAndPort.slice(close + 1));
|
|
131
|
+
}
|
|
132
|
+
const colon = hostAndPort.indexOf(":");
|
|
133
|
+
return colon !== -1 && /^:\d+$/.test(hostAndPort.slice(colon));
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Library-boundary enforcement for the upstream the proxy forwards managed
|
|
137
|
+
* OAuth Bearer tokens to (runtime-proxy trust boundary).
|
|
138
|
+
*
|
|
139
|
+
* `options.upstreamBaseUrl` is a library input: callers are not all the
|
|
140
|
+
* wrapper, so the env-var validation in scripts/codex.js does not protect this
|
|
141
|
+
* boundary. A non-https or non-loopback value would exfiltrate account tokens
|
|
142
|
+
* to whatever host it names. The policy mirrors the wrapper exactly: https is
|
|
143
|
+
* always allowed, while http is accepted only for the documented dev path — a
|
|
144
|
+
* NUMERIC loopback host (127.0.0.0/8 or [::1], never a name) with an explicit
|
|
145
|
+
* port — and no URL may carry credentials, a query, or a fragment.
|
|
146
|
+
*/
|
|
147
|
+
function assertAllowedUpstreamBaseUrl(raw) {
|
|
148
|
+
let parsed;
|
|
149
|
+
try {
|
|
150
|
+
parsed = new URL(raw);
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
throw new CodexValidationError(`Runtime rotation proxy upstreamBaseUrl is not a valid absolute URL.`, { field: "upstreamBaseUrl", expected: "an https URL, or an http URL on a numeric loopback host with an explicit port" });
|
|
154
|
+
}
|
|
155
|
+
const isDevLoopback = parsed.protocol === "http:" &&
|
|
156
|
+
isNumericLoopbackUrlHostname(parsed.hostname.toLowerCase()) &&
|
|
157
|
+
Boolean(parsed.port || urlHasExplicitPort(raw));
|
|
158
|
+
if ((parsed.protocol !== "https:" && !isDevLoopback) ||
|
|
159
|
+
parsed.username ||
|
|
160
|
+
parsed.password ||
|
|
161
|
+
parsed.search ||
|
|
162
|
+
parsed.hash) {
|
|
163
|
+
throw new CodexValidationError(`Runtime rotation proxy refuses upstreamBaseUrl "${raw}". ` +
|
|
164
|
+
"It forwards managed OAuth tokens: use https, or http only on a " +
|
|
165
|
+
"numeric loopback host (127.0.0.0/8 or [::1]; a name such as " +
|
|
166
|
+
'"localhost" can resolve off-host) with an explicit port, and no ' +
|
|
167
|
+
"credentials, query, or fragment.", {
|
|
168
|
+
field: "upstreamBaseUrl",
|
|
169
|
+
expected: "an https URL, or an http URL on a numeric loopback host with an explicit port",
|
|
170
|
+
context: { upstreamBaseUrl: raw },
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Whether a fetch rejection is undici refusing to follow a redirect.
|
|
176
|
+
*
|
|
177
|
+
* The upstream fetch runs `redirect: "error"` so a 3xx can never re-send the
|
|
178
|
+
* managed Bearer token to an arbitrary host. Instead of a Response, fetch
|
|
179
|
+
* rejects with `TypeError("fetch failed")` whose `cause` is the network error
|
|
180
|
+
* `unexpected redirect` (see undici's httpNetworkOrCacheFetch). Check the cause
|
|
181
|
+
* level and the bare message so a custom fetchImpl delivering the same network
|
|
182
|
+
* error unwrapped classifies identically.
|
|
183
|
+
*/
|
|
184
|
+
function isRedirectRejection(error) {
|
|
185
|
+
return [error, error?.cause].some((candidate) => candidate instanceof Error && candidate.message === "unexpected redirect");
|
|
186
|
+
}
|
|
90
187
|
// Structured logger for the default-on runtime proxy (errors-logging-01,
|
|
91
188
|
// runtime-proxy-04). Previously the 1900-LOC proxy had zero logger integration;
|
|
92
189
|
// failures surfaced only as a last-write-wins status.lastError string. Logs are
|
|
@@ -746,6 +843,13 @@ export async function startRuntimeRotationProxy(options) {
|
|
|
746
843
|
const bindHost = toBindHost(host);
|
|
747
844
|
const urlHost = toUrlHost(host);
|
|
748
845
|
const port = options.port ?? 0;
|
|
846
|
+
// Library-boundary trust enforcement: the wrapper validates the env override,
|
|
847
|
+
// but options.upstreamBaseUrl reaches here from any caller — and Bearer
|
|
848
|
+
// tokens are forwarded to whatever host it names. https always passes; http
|
|
849
|
+
// is allowed only for the documented numeric-loopback dev path.
|
|
850
|
+
if (options.upstreamBaseUrl !== undefined) {
|
|
851
|
+
assertAllowedUpstreamBaseUrl(options.upstreamBaseUrl);
|
|
852
|
+
}
|
|
749
853
|
const upstreamBaseUrl = options.upstreamBaseUrl ?? CODEX_BASE_URL;
|
|
750
854
|
const clientApiKey = typeof options.clientApiKey === "string" &&
|
|
751
855
|
options.clientApiKey.trim().length > 0
|
|
@@ -2030,6 +2134,11 @@ async function handleRequestInner(state, req, res, traceId) {
|
|
|
2030
2134
|
method: context.method,
|
|
2031
2135
|
headers: outboundHeaders,
|
|
2032
2136
|
signal: fetchAbortController.signal,
|
|
2137
|
+
// Redirect pinning: never follow an upstream redirect — a 3xx from
|
|
2138
|
+
// a compromised or misconfigured endpoint would re-send the
|
|
2139
|
+
// managed Bearer token to an arbitrary host. Matches the model
|
|
2140
|
+
// catalog fetch above.
|
|
2141
|
+
redirect: "error",
|
|
2033
2142
|
};
|
|
2034
2143
|
if (context.method === "POST") {
|
|
2035
2144
|
upstreamRequestInit.body = context.body;
|
|
@@ -2062,6 +2171,30 @@ async function handleRequestInner(state, req, res, traceId) {
|
|
|
2062
2171
|
error: transportError,
|
|
2063
2172
|
});
|
|
2064
2173
|
refundConsumedPoolToken(refreshed.account);
|
|
2174
|
+
// A redirect rejection is upstream configuration, not a transport
|
|
2175
|
+
// outage or an account-health signal: the 3xx arrived (so the path
|
|
2176
|
+
// works and no generation started), the Bearer token never reached
|
|
2177
|
+
// the redirect target, and every managed account would hit the
|
|
2178
|
+
// same redirect — cooling + rotating here would drain the pool on
|
|
2179
|
+
// one endpoint fault. This also covers the WebSocket httpFetch
|
|
2180
|
+
// fallback: SocketSession preserves init, so a refused-upgrade
|
|
2181
|
+
// turn on API/ZDR credentials can reject this way. Fail the
|
|
2182
|
+
// request in place and leave account state untouched.
|
|
2183
|
+
if (isRedirectRejection(error)) {
|
|
2184
|
+
writeJson(res, 502, {
|
|
2185
|
+
error: {
|
|
2186
|
+
code: "upstream_redirect_rejected",
|
|
2187
|
+
message: "Upstream endpoint attempted a redirect; redirects are never followed.",
|
|
2188
|
+
},
|
|
2189
|
+
});
|
|
2190
|
+
await usageRecorder.record({
|
|
2191
|
+
outcome: "failure",
|
|
2192
|
+
statusCode: 502,
|
|
2193
|
+
errorCode: "upstream_redirect_rejected",
|
|
2194
|
+
account: refreshed.account,
|
|
2195
|
+
});
|
|
2196
|
+
return;
|
|
2197
|
+
}
|
|
2065
2198
|
// A timeout may occur after generation; do not retry within this request.
|
|
2066
2199
|
if (isImageRequest) {
|
|
2067
2200
|
writeJson(res, 502, {
|