codex-multi-auth 2.17.2 → 2.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.codex-plugin/plugin.json +1 -1
- package/README.md +86 -425
- package/config/README.md +1 -1
- package/config/codex-legacy.json +12 -212
- package/config/codex-modern.json +4 -80
- package/config/minimal-codex.json +1 -1
- 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 +1 -2
- package/dist/lib/context-budget/model-context-windows.js +10 -13
- 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 +3 -3
- package/dist/lib/oc-chatgpt-target-detection.js +40 -13
- 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/error-classification.js +41 -52
- 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/fetch-helpers.js +1 -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 +2 -3
- package/dist/lib/request/helpers/model-map.js +120 -78
- 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 +1 -2
- package/dist/lib/request/request-transformer.js +51 -26
- 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 +0 -1
- 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 +1 -2
- package/dist/lib/ui/ui-copy.js +1 -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 +1 -2
- package/dist/lib/usage/pricing.js +41 -16
- 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 +385 -89
- package/skills/codex-auth-setup/SKILL.md +73 -0
package/scripts/codex.js
CHANGED
|
@@ -20,12 +20,13 @@ import {
|
|
|
20
20
|
} from "node:fs";
|
|
21
21
|
import { rm as rmAsync } from "node:fs/promises";
|
|
22
22
|
import { createRequire } from "node:module";
|
|
23
|
-
import { homedir, tmpdir } from "node:os";
|
|
24
|
-
import { basename, delimiter, dirname, join, resolve as resolvePath, sep } from "node:path";
|
|
23
|
+
import { constants as osConstants, homedir, tmpdir } from "node:os";
|
|
24
|
+
import { basename, delimiter, dirname, isAbsolute, join, resolve as resolvePath, sep } from "node:path";
|
|
25
25
|
import process from "node:process";
|
|
26
26
|
import { StringDecoder } from "node:string_decoder";
|
|
27
27
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
28
28
|
import {
|
|
29
|
+
isFullyQualifiedBinOverride,
|
|
29
30
|
isWindowsShimPath,
|
|
30
31
|
resolveRealCodexBin as resolveRealCodexBinFromEnvironment,
|
|
31
32
|
resolveWindowsShimPackageEntry,
|
|
@@ -65,6 +66,11 @@ const SHADOW_HOME_STATE_FILE_SET = new Set(SHADOW_HOME_STATE_FILES);
|
|
|
65
66
|
const SHADOW_HOME_CONFIG_FILE = "config.toml";
|
|
66
67
|
const SHADOW_HOME_SYNC_LOCK_DIR = ".codex-multi-auth-shadow-sync.lock";
|
|
67
68
|
const SHADOW_HOME_SYNC_STATE_FILE = ".codex-multi-auth-shadow-sync-state.json";
|
|
69
|
+
// Housekeeping marker written into every shadow home ({pid, createdAt, and the
|
|
70
|
+
// forwarded child's pid once spawned}) so the next launch can tell a dead
|
|
71
|
+
// owner's leftover from a home still in use. It is never mirrored in from the
|
|
72
|
+
// real home nor synced back into it.
|
|
73
|
+
const SHADOW_HOME_OWNER_FILE = ".codex-multi-auth-owner.json";
|
|
68
74
|
const APP_SERVER_ACCOUNT_DISPLAY_NAME = "codex-multi-auth";
|
|
69
75
|
const RUNTIME_CONSTANTS = await loadRuntimeConstants();
|
|
70
76
|
const RUNTIME_ROTATION_PROXY_PROVIDER_ID =
|
|
@@ -1329,7 +1335,10 @@ async function autoSyncManagerActiveSelectionIfEnabled() {
|
|
|
1329
1335
|
if (!enabled) return;
|
|
1330
1336
|
|
|
1331
1337
|
try {
|
|
1332
|
-
|
|
1338
|
+
// Slim entry point: importing dist/lib/codex-manager.js here would pull
|
|
1339
|
+
// the whole command/dispatch/settings graph (~126 modules incl. zod)
|
|
1340
|
+
// onto every forwarded invocation's cold-start path.
|
|
1341
|
+
const mod = await import("../dist/lib/codex-manager/active-account-sync.js");
|
|
1333
1342
|
if (typeof mod.autoSyncActiveAccountToCodex !== "function") {
|
|
1334
1343
|
return;
|
|
1335
1344
|
}
|
|
@@ -1346,6 +1355,15 @@ async function autoSyncManagerActiveSelectionIfEnabled() {
|
|
|
1346
1355
|
function resolveRealCodexBin() {
|
|
1347
1356
|
const override = (process.env.CODEX_MULTI_AUTH_REAL_CODEX_BIN ?? "").trim();
|
|
1348
1357
|
if (override.length > 0) {
|
|
1358
|
+
// Fully-qualified = absolute AND drive-qualified on Windows: a
|
|
1359
|
+
// root-relative override like "\bin\codex.exe" resolves against the cwd's
|
|
1360
|
+
// drive and could exec a planted file (CWE-426).
|
|
1361
|
+
if (!isFullyQualifiedBinOverride(override, process.platform)) {
|
|
1362
|
+
console.error(
|
|
1363
|
+
`CODEX_MULTI_AUTH_REAL_CODEX_BIN must be a fully-qualified absolute path (a drive-qualified or UNC path on Windows), got: ${override}`,
|
|
1364
|
+
);
|
|
1365
|
+
return null;
|
|
1366
|
+
}
|
|
1349
1367
|
if (!existsSync(override)) {
|
|
1350
1368
|
console.error(
|
|
1351
1369
|
`CODEX_MULTI_AUTH_REAL_CODEX_BIN is set but missing: ${override}`,
|
|
@@ -1387,12 +1405,25 @@ const DIRECT_UNSUPPORTED_MODEL_PATTERN =
|
|
|
1387
1405
|
const CURRENT_CODEX_MODEL = "gpt-5.6-sol";
|
|
1388
1406
|
const CODEX_MINI_REPLACEMENT_MODEL = "gpt-5.6-terra";
|
|
1389
1407
|
const RETIRED_MODEL_REPLACEMENTS = {
|
|
1408
|
+
// `gpt-6-astra-aeon` never appeared in the bundled Codex catalog or the
|
|
1409
|
+
// public model docs — a Statsig-flag leak, now dead — so it aliases the
|
|
1410
|
+
// flagship it was a variant of.
|
|
1411
|
+
"gpt-6-astra-aeon": "gpt-6-astra",
|
|
1412
|
+
// `gpt-5.5` leaves ChatGPT/Codex OAuth on 2026-10-14 (the catalog names
|
|
1413
|
+
// GPT-6 Sol as the migration target); `gpt-5.5-pro` left the bundled
|
|
1414
|
+
// catalog earlier and is API-only, so it goes to the frontier flagship.
|
|
1415
|
+
"gpt-5.5": "gpt-6-sol",
|
|
1416
|
+
"gpt-5.5-2026-04-23": "gpt-6-sol",
|
|
1417
|
+
"gpt-5.5-20260423": "gpt-6-sol",
|
|
1418
|
+
"gpt-5.5-pro": "gpt-6-astra",
|
|
1419
|
+
"gpt-5.5-pro-2026-04-23": "gpt-6-astra",
|
|
1420
|
+
"gpt-5.5-pro-20260423": "gpt-6-astra",
|
|
1390
1421
|
"gpt-5.4": "gpt-6-sol",
|
|
1391
1422
|
"gpt-5.4-mini": "gpt-6-luna",
|
|
1392
1423
|
"gpt-5.4-nano": "gpt-6-luna",
|
|
1393
|
-
"gpt-5.4-pro": "gpt-
|
|
1424
|
+
"gpt-5.4-pro": "gpt-6-astra",
|
|
1394
1425
|
"gpt-5.2": "gpt-5.6-sol",
|
|
1395
|
-
"gpt-5.2-pro": "gpt-
|
|
1426
|
+
"gpt-5.2-pro": "gpt-6-astra",
|
|
1396
1427
|
"gpt-5.1": "gpt-5.6-sol",
|
|
1397
1428
|
"gpt-5-mini": "gpt-5.6-terra",
|
|
1398
1429
|
"gpt-5-nano": "gpt-5.6-luna",
|
|
@@ -1411,30 +1442,26 @@ const RETIRED_MODEL_REPLACEMENTS = {
|
|
|
1411
1442
|
"gpt-5-codex-mini": CODEX_MINI_REPLACEMENT_MODEL,
|
|
1412
1443
|
"codex-mini-latest": CODEX_MINI_REPLACEMENT_MODEL,
|
|
1413
1444
|
};
|
|
1414
|
-
// Mirrors
|
|
1445
|
+
// Mirrors lib/request/error-classification.ts
|
|
1415
1446
|
// `DEFAULT_UNSUPPORTED_CODEX_FALLBACK_CHAIN`. This table is walked differently
|
|
1416
1447
|
// from lib's: `resolveUnsupportedModelRetryTarget` keys on the model named in
|
|
1417
1448
|
// the error output and falls back to the original requested model, with
|
|
1418
1449
|
// `attemptedModels` accumulating, so a row's later entries ARE reachable here.
|
|
1419
|
-
// The
|
|
1420
|
-
//
|
|
1421
|
-
//
|
|
1450
|
+
// The explicit rows and the retired-id spread are pinned in parity by
|
|
1451
|
+
// test/codex-model-resolution.test.ts; `gpt-6-luna` closes the general walks
|
|
1452
|
+
// because it ships on the most plans of any catalog model.
|
|
1422
1453
|
const WRAPPER_UNSUPPORTED_MODEL_FALLBACK_CHAIN = {
|
|
1423
|
-
"gpt-6-
|
|
1424
|
-
"gpt-6-astra
|
|
1454
|
+
"gpt-6.1-sol": ["gpt-6-sol"],
|
|
1455
|
+
"gpt-6-astra": ["gpt-6-sol"],
|
|
1425
1456
|
"gpt-6-sol": ["gpt-5.6-sol"],
|
|
1426
1457
|
"gpt-6-luna": ["gpt-5.6-luna"],
|
|
1427
|
-
"gpt-5.6-sol": ["gpt-
|
|
1428
|
-
"gpt-5.6-luna": ["gpt-5.
|
|
1429
|
-
"gpt-5.6-terra": ["gpt-5.
|
|
1430
|
-
"gpt-5": ["gpt-5.
|
|
1431
|
-
"gpt-5-pro": ["gpt-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
"gpt-5.5-pro-2026-04-23": ["gpt-5.5-pro"],
|
|
1435
|
-
"gpt-5.5-pro-20260423": ["gpt-5.5-pro"],
|
|
1436
|
-
// `gpt-5.5`/`gpt-5.5-pro` are the floor; `gpt-5.4` is retired. A retired id
|
|
1437
|
-
// steps once to its replacement.
|
|
1458
|
+
"gpt-5.6-sol": ["gpt-6-luna"],
|
|
1459
|
+
"gpt-5.6-luna": ["gpt-5.6-sol"],
|
|
1460
|
+
"gpt-5.6-terra": ["gpt-5.6-sol"],
|
|
1461
|
+
"gpt-5": ["gpt-5.6-sol"],
|
|
1462
|
+
"gpt-5-pro": ["gpt-6-astra"],
|
|
1463
|
+
// A retired id still reaches the backend verbatim and is rejected; one hop
|
|
1464
|
+
// to its named replacement turns that into a working request.
|
|
1438
1465
|
...Object.fromEntries(
|
|
1439
1466
|
Object.entries(RETIRED_MODEL_REPLACEMENTS).map(([retired, replacement]) => [
|
|
1440
1467
|
retired,
|
|
@@ -1817,11 +1844,23 @@ function forwardToRealCodexOnce(
|
|
|
1817
1844
|
? createAppServerAccountReadProtocolProxy()
|
|
1818
1845
|
: null;
|
|
1819
1846
|
let cleanupProtocolProxy = () => {};
|
|
1847
|
+
let detachSignalRelay = () => {};
|
|
1848
|
+
let signalForceTimer = null;
|
|
1849
|
+
// Set the moment finalization begins so a repeated signal during cleanup
|
|
1850
|
+
// can exit with the result already decided instead of the default
|
|
1851
|
+
// disposition, which would look like a signal death and truncate
|
|
1852
|
+
// shadow-home sync-back mid-write.
|
|
1853
|
+
let finalizedExitCode = null;
|
|
1820
1854
|
const finalize = async (exitCode) => {
|
|
1821
1855
|
if (settled) {
|
|
1822
1856
|
return;
|
|
1823
1857
|
}
|
|
1824
1858
|
settled = true;
|
|
1859
|
+
finalizedExitCode = exitCode;
|
|
1860
|
+
if (signalForceTimer !== null) {
|
|
1861
|
+
clearTimeout(signalForceTimer);
|
|
1862
|
+
signalForceTimer = null;
|
|
1863
|
+
}
|
|
1825
1864
|
cleanupProtocolProxy();
|
|
1826
1865
|
protocolProxy?.flushOutput();
|
|
1827
1866
|
try {
|
|
@@ -1829,6 +1868,11 @@ function forwardToRealCodexOnce(
|
|
|
1829
1868
|
} catch {
|
|
1830
1869
|
// Best-effort cleanup only.
|
|
1831
1870
|
}
|
|
1871
|
+
// The relay stays installed until cleanup has run: a repeated signal
|
|
1872
|
+
// landing mid-finalize exits with the decided code (see
|
|
1873
|
+
// onRelayedSignal) rather than a default kill that truncates
|
|
1874
|
+
// shadow-home sync-back.
|
|
1875
|
+
detachSignalRelay();
|
|
1832
1876
|
if (captureOutput && stdout.length > 0) {
|
|
1833
1877
|
const filteredStdout = filterKnownForwardedCodexStderr(stdout);
|
|
1834
1878
|
if (filteredStdout.length > 0) {
|
|
@@ -1878,6 +1922,68 @@ function forwardToRealCodexOnce(
|
|
|
1878
1922
|
return;
|
|
1879
1923
|
}
|
|
1880
1924
|
|
|
1925
|
+
// The forwarded child can outlive this wrapper — SIGKILL can neither be
|
|
1926
|
+
// caught nor relayed — so the shadow-home owner marker names the child
|
|
1927
|
+
// too; otherwise the next launch's sweep would see only the dead wrapper
|
|
1928
|
+
// PID and reap a home a live child is still writing to.
|
|
1929
|
+
recordShadowHomeChildPid(env.CODEX_HOME, child?.pid);
|
|
1930
|
+
|
|
1931
|
+
// Relay terminal signals to the forwarded child. Without this the child
|
|
1932
|
+
// outlives the wrapper whenever a signal targets the wrapper PID
|
|
1933
|
+
// directly (kill, launcher, monitor) rather than the process group, and
|
|
1934
|
+
// the shadow-home cleanup inside finalize never runs.
|
|
1935
|
+
const signalRelayHandlers = new Map();
|
|
1936
|
+
// The first relayed signal decides the exit result: once the force-kill
|
|
1937
|
+
// fallback SIGKILLs the child, its `close` event reports SIGKILL, which
|
|
1938
|
+
// would mask the SIGTERM the caller actually sent (137 instead of 143).
|
|
1939
|
+
let relayedSignal = null;
|
|
1940
|
+
const onRelayedSignal = (signal) => {
|
|
1941
|
+
if (settled) {
|
|
1942
|
+
// Finalization is already running. A repeated signal here is the
|
|
1943
|
+
// caller escalating (Ctrl-C again, a monitor's follow-up TERM):
|
|
1944
|
+
// exit with the result finalization produced rather than hang on
|
|
1945
|
+
// a slow cleanup — but never with signal-death semantics, which
|
|
1946
|
+
// is what the pre-handler default would have reported.
|
|
1947
|
+
process.exit(finalizedExitCode ?? 1);
|
|
1948
|
+
}
|
|
1949
|
+
relayedSignal ??= signal;
|
|
1950
|
+
try {
|
|
1951
|
+
child?.kill(signal);
|
|
1952
|
+
} catch {
|
|
1953
|
+
// Best-effort forward only.
|
|
1954
|
+
}
|
|
1955
|
+
if (signalForceTimer !== null) {
|
|
1956
|
+
return;
|
|
1957
|
+
}
|
|
1958
|
+
// If the child ignores the signal, force-kill it — but leave
|
|
1959
|
+
// finalization to the child's "close" event, so shadow-home sync and
|
|
1960
|
+
// removal run only after the child is reaped and its stdio drained.
|
|
1961
|
+
signalForceTimer = setTimeout(() => {
|
|
1962
|
+
signalForceTimer = null;
|
|
1963
|
+
try {
|
|
1964
|
+
child?.kill("SIGKILL");
|
|
1965
|
+
} catch {
|
|
1966
|
+
// Best-effort only.
|
|
1967
|
+
}
|
|
1968
|
+
}, 1_000);
|
|
1969
|
+
signalForceTimer.unref?.();
|
|
1970
|
+
};
|
|
1971
|
+
// `on`, not `once`: the handlers stay installed until finalization, so a
|
|
1972
|
+
// repeated signal while a child still ignores the first keeps relaying
|
|
1973
|
+
// instead of falling back to the default disposition — which would kill
|
|
1974
|
+
// the wrapper before it can reap the child or clean the shadow home.
|
|
1975
|
+
for (const signal of ["SIGINT", "SIGTERM", "SIGHUP"]) {
|
|
1976
|
+
const handler = () => onRelayedSignal(signal);
|
|
1977
|
+
signalRelayHandlers.set(signal, handler);
|
|
1978
|
+
process.on(signal, handler);
|
|
1979
|
+
}
|
|
1980
|
+
detachSignalRelay = () => {
|
|
1981
|
+
for (const [signal, handler] of signalRelayHandlers) {
|
|
1982
|
+
process.removeListener(signal, handler);
|
|
1983
|
+
}
|
|
1984
|
+
signalRelayHandlers.clear();
|
|
1985
|
+
};
|
|
1986
|
+
|
|
1881
1987
|
if (proxyAppServerAccountRead && protocolProxy) {
|
|
1882
1988
|
let stdinClosed = false;
|
|
1883
1989
|
let stdoutClosed = false;
|
|
@@ -1948,9 +2054,16 @@ function forwardToRealCodexOnce(
|
|
|
1948
2054
|
});
|
|
1949
2055
|
|
|
1950
2056
|
child.once("close", (code, signal) => {
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
2057
|
+
const reportedSignal = relayedSignal ?? signal;
|
|
2058
|
+
if (reportedSignal) {
|
|
2059
|
+
const signalNumber = osConstants.signals?.[reportedSignal];
|
|
2060
|
+
finalize(
|
|
2061
|
+
typeof signalNumber === "number"
|
|
2062
|
+
? 128 + signalNumber
|
|
2063
|
+
: reportedSignal === "SIGINT"
|
|
2064
|
+
? 130
|
|
2065
|
+
: 1,
|
|
2066
|
+
);
|
|
1954
2067
|
return;
|
|
1955
2068
|
}
|
|
1956
2069
|
finalize(typeof code === "number" ? code : 1);
|
|
@@ -1959,11 +2072,16 @@ function forwardToRealCodexOnce(
|
|
|
1959
2072
|
}
|
|
1960
2073
|
|
|
1961
2074
|
async function forwardToRealCodex(codexBin, rawArgs, baseEnv = process.env) {
|
|
2075
|
+
sweepStaleShadowHomes(baseEnv);
|
|
1962
2076
|
let currentArgs = [...rawArgs];
|
|
1963
2077
|
let lastExitCode = 1;
|
|
1964
2078
|
const attemptedModels = new Set();
|
|
1965
2079
|
|
|
1966
|
-
|
|
2080
|
+
// Five forwards: the deepest supported-model staircase (gpt-6.1-sol ->
|
|
2081
|
+
// gpt-6-sol -> gpt-5.6-sol -> gpt-6-luna -> gpt-5.6-luna) spends exactly
|
|
2082
|
+
// the shared per-request attempt budget of 5 the plugin host uses. With 4
|
|
2083
|
+
// the terminal model was unreachable from the new default.
|
|
2084
|
+
for (let attempt = 0; attempt < 5; attempt += 1) {
|
|
1967
2085
|
const requestedModel = extractRequestedModel(currentArgs);
|
|
1968
2086
|
if (requestedModel) {
|
|
1969
2087
|
attemptedModels.add(requestedModel);
|
|
@@ -2064,7 +2182,7 @@ function hasCliAuthCredentialsStoreOverride(args) {
|
|
|
2064
2182
|
// This wrapper runs before the TypeScript build, so it cannot import that source.
|
|
2065
2183
|
const SUPPORTED_REASONING_EFFORTS_BY_MODEL = {
|
|
2066
2184
|
"gpt-6-astra": ["low", "medium", "high", "xhigh", "max", "ultra"],
|
|
2067
|
-
"gpt-6-
|
|
2185
|
+
"gpt-6.1-sol": ["low", "medium", "high", "xhigh", "max", "ultra"],
|
|
2068
2186
|
"gpt-6-sol": ["low", "medium", "high", "xhigh", "max", "ultra"],
|
|
2069
2187
|
"gpt-6-luna": ["low", "medium", "high", "xhigh", "max"],
|
|
2070
2188
|
"gpt-daybreak-blue-latest": ["low", "medium", "high", "xhigh", "max", "ultra"],
|
|
@@ -2072,8 +2190,6 @@ const SUPPORTED_REASONING_EFFORTS_BY_MODEL = {
|
|
|
2072
2190
|
"gpt-5.6-sol": ["low", "medium", "high", "xhigh", "max", "ultra"],
|
|
2073
2191
|
"gpt-5.6-terra": ["low", "medium", "high", "xhigh", "max", "ultra"],
|
|
2074
2192
|
"gpt-5.6-luna": ["low", "medium", "high", "xhigh", "max"],
|
|
2075
|
-
"gpt-5.5": ["none", "low", "medium", "high", "xhigh"],
|
|
2076
|
-
"gpt-5.5-pro": ["medium", "high", "xhigh"],
|
|
2077
2193
|
};
|
|
2078
2194
|
|
|
2079
2195
|
const REASONING_FALLBACKS = {
|
|
@@ -2104,13 +2220,9 @@ const REASONING_ALIAS_VARIANTS = [
|
|
|
2104
2220
|
"xhigh",
|
|
2105
2221
|
];
|
|
2106
2222
|
const REQUESTED_MODEL_ALIASES = new Map();
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
const
|
|
2110
|
-
const GPT_5_5_RELEASE_MODEL = "gpt-5.5-2026-04-23";
|
|
2111
|
-
const GPT_5_5_PRO_RELEASE_MODEL = "gpt-5.5-pro-2026-04-23";
|
|
2112
|
-
const GPT_5_5_RELEASE_COMPAT_MODEL = "gpt-5.5-20260423";
|
|
2113
|
-
const GPT_5_5_PRO_RELEASE_COMPAT_MODEL = "gpt-5.5-pro-20260423";
|
|
2223
|
+
// The general GPT-5 landing spot: with 5.5 retired, the newest living 5.x
|
|
2224
|
+
// flagship is 5.6 Sol. Mirrors lib/request/helpers/model-map.ts.
|
|
2225
|
+
const DEFAULT_GENERAL_GPT5_MODEL = "gpt-5.6-sol";
|
|
2114
2226
|
// GPT-5.6 tiers. Sol and Terra expose `ultra`; Luna stops at `max`. No tier
|
|
2115
2227
|
// accepts `none`/`minimal`. Bare `gpt-5.6` aliases to the flagship (Sol).
|
|
2116
2228
|
const GPT_5_6_SOL_MODEL = "gpt-5.6-sol";
|
|
@@ -2119,11 +2231,11 @@ const GPT_5_6_LUNA_MODEL = "gpt-5.6-luna";
|
|
|
2119
2231
|
const GPT_5_6_FLAGSHIP_ALIAS = "gpt-5.6";
|
|
2120
2232
|
const GPT_5_6_SOL_TERRA_EFFORTS = ["low", "medium", "high", "xhigh", "max", "ultra"];
|
|
2121
2233
|
const GPT_5_6_LUNA_EFFORTS = ["low", "medium", "high", "xhigh", "max"];
|
|
2122
|
-
// GPT-6 Astra (2026-09-03): the flagship
|
|
2123
|
-
//
|
|
2124
|
-
//
|
|
2234
|
+
// GPT-6 Astra (2026-09-03): the frontier flagship. Same frontier effort
|
|
2235
|
+
// ladder as 5.6 (no `none`/`minimal`, `ultra` at the top). Bare `gpt-6` ->
|
|
2236
|
+
// flagship. The leaked `aeon` long-horizon variant was never catalog-listed
|
|
2237
|
+
// and is retired; its ids alias the flagship.
|
|
2125
2238
|
const GPT_6_ASTRA_MODEL = "gpt-6-astra";
|
|
2126
|
-
const GPT_6_ASTRA_AEON_MODEL = "gpt-6-astra-aeon";
|
|
2127
2239
|
const GPT_6_FLAGSHIP_ALIAS = "gpt-6";
|
|
2128
2240
|
const GPT_6_ASTRA_EFFORTS = ["low", "medium", "high", "xhigh", "max", "ultra"];
|
|
2129
2241
|
// GPT-6 Sol and Luna (upstream catalog, 2026-09-22). Sol reaches `ultra`, Luna
|
|
@@ -2132,6 +2244,12 @@ const GPT_6_SOL_MODEL = "gpt-6-sol";
|
|
|
2132
2244
|
const GPT_6_LUNA_MODEL = "gpt-6-luna";
|
|
2133
2245
|
const GPT_6_SOL_EFFORTS = GPT_6_ASTRA_EFFORTS;
|
|
2134
2246
|
const GPT_6_LUNA_EFFORTS = ["low", "medium", "high", "xhigh", "max"];
|
|
2247
|
+
// GPT-6.1 Sol (upstream catalog, 2026-09-29): the first 6.1 release, added as
|
|
2248
|
+
// the catalog's default model. Sol is the only 6.1 tier yet, so bare `gpt-6.1`
|
|
2249
|
+
// aliases to it, matching the bare-alias convention.
|
|
2250
|
+
const GPT_6_1_SOL_MODEL = "gpt-6.1-sol";
|
|
2251
|
+
const GPT_6_1_FLAGSHIP_ALIAS = "gpt-6.1";
|
|
2252
|
+
const GPT_6_1_SOL_EFFORTS = GPT_6_ASTRA_EFFORTS;
|
|
2135
2253
|
// Daybreak cyber models from the upstream Codex catalog. `red` is the
|
|
2136
2254
|
// cyber-permissive variant, `blue` the defensive one.
|
|
2137
2255
|
const DAYBREAK_BLUE_MODEL = "gpt-daybreak-blue-latest";
|
|
@@ -2141,29 +2259,37 @@ const DAYBREAK_EFFORTS = ["low", "medium", "high", "xhigh", "max", "ultra"];
|
|
|
2141
2259
|
const GENERAL_GPT5_VERSION_CATALOG = {
|
|
2142
2260
|
1: {
|
|
2143
2261
|
base: GPT_5_6_SOL_MODEL,
|
|
2144
|
-
pro:
|
|
2262
|
+
pro: GPT_6_ASTRA_MODEL,
|
|
2145
2263
|
},
|
|
2146
2264
|
2: {
|
|
2147
2265
|
base: GPT_5_6_SOL_MODEL,
|
|
2148
|
-
pro:
|
|
2266
|
+
pro: GPT_6_ASTRA_MODEL,
|
|
2149
2267
|
},
|
|
2150
2268
|
4: {
|
|
2151
2269
|
base: GPT_6_SOL_MODEL,
|
|
2152
|
-
pro:
|
|
2270
|
+
pro: GPT_6_ASTRA_MODEL,
|
|
2153
2271
|
mini: GPT_6_LUNA_MODEL,
|
|
2154
2272
|
nano: GPT_6_LUNA_MODEL,
|
|
2155
2273
|
},
|
|
2156
2274
|
5: {
|
|
2157
|
-
base:
|
|
2158
|
-
pro:
|
|
2275
|
+
base: GPT_6_SOL_MODEL,
|
|
2276
|
+
pro: GPT_6_ASTRA_MODEL,
|
|
2159
2277
|
mini: GPT_5_6_TERRA_MODEL,
|
|
2160
2278
|
nano: GPT_5_6_LUNA_MODEL,
|
|
2161
2279
|
},
|
|
2162
2280
|
};
|
|
2163
|
-
|
|
2281
|
+
// Unknown future 5.x minors land on the newest generation the line still
|
|
2282
|
+
// serves — deliberately NOT `gpt-6-sol`, since an id naming a 5.x minor keeps
|
|
2283
|
+
// its generation. Mirrors lib GENERAL_GPT5_STABLE_VARIANTS.
|
|
2284
|
+
const GENERAL_GPT5_STABLE_VARIANTS = {
|
|
2285
|
+
base: GPT_5_6_SOL_MODEL,
|
|
2286
|
+
pro: GPT_6_ASTRA_MODEL,
|
|
2287
|
+
mini: GPT_5_6_TERRA_MODEL,
|
|
2288
|
+
nano: GPT_5_6_LUNA_MODEL,
|
|
2289
|
+
};
|
|
2164
2290
|
const GENERAL_GPT5_GENERIC_VARIANTS = {
|
|
2165
2291
|
base: DEFAULT_GENERAL_GPT5_MODEL,
|
|
2166
|
-
pro:
|
|
2292
|
+
pro: GPT_6_ASTRA_MODEL,
|
|
2167
2293
|
mini: GPT_5_6_TERRA_MODEL,
|
|
2168
2294
|
nano: GPT_5_6_LUNA_MODEL,
|
|
2169
2295
|
};
|
|
@@ -2285,31 +2411,10 @@ function renameFileWithRetry(sourcePath, destinationPath, expectedDestinationSta
|
|
|
2285
2411
|
}
|
|
2286
2412
|
|
|
2287
2413
|
function seedRequestedModelAliases() {
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
);
|
|
2292
|
-
addRequestedModelReasoningAliases(
|
|
2293
|
-
GPT_5_5_RELEASE_MODEL,
|
|
2294
|
-
GPT_5_5_CANONICAL_MODEL,
|
|
2295
|
-
);
|
|
2296
|
-
addRequestedModelReasoningAliases(
|
|
2297
|
-
GPT_5_5_RELEASE_COMPAT_MODEL,
|
|
2298
|
-
GPT_5_5_CANONICAL_MODEL,
|
|
2299
|
-
);
|
|
2300
|
-
addRequestedModelReasoningAliases(
|
|
2301
|
-
GPT_5_5_PRO_CANONICAL_MODEL,
|
|
2302
|
-
GPT_5_5_PRO_CANONICAL_MODEL,
|
|
2303
|
-
);
|
|
2304
|
-
addRequestedModelReasoningAliases(
|
|
2305
|
-
GPT_5_5_PRO_RELEASE_MODEL,
|
|
2306
|
-
GPT_5_5_PRO_CANONICAL_MODEL,
|
|
2307
|
-
);
|
|
2308
|
-
addRequestedModelReasoningAliases(
|
|
2309
|
-
GPT_5_5_PRO_RELEASE_COMPAT_MODEL,
|
|
2310
|
-
GPT_5_5_PRO_CANONICAL_MODEL,
|
|
2311
|
-
);
|
|
2312
|
-
addRequestedModelReasoningAliases("gpt-5-pro", GPT_5_5_PRO_CANONICAL_MODEL);
|
|
2414
|
+
// `gpt-5` and `gpt-5-pro` are the last un-versioned ids upstream published;
|
|
2415
|
+
// with 5.5 retired the 5.x flagship is Sol 5.6 and the pro tier is Astra.
|
|
2416
|
+
// 5.5's own dated and suffixed forms come from the retired table below.
|
|
2417
|
+
addRequestedModelReasoningAliases("gpt-5-pro", GPT_6_ASTRA_MODEL);
|
|
2313
2418
|
addRequestedModelReasoningAliases("gpt-5", DEFAULT_GENERAL_GPT5_MODEL);
|
|
2314
2419
|
addRequestedModelEffortAliases(
|
|
2315
2420
|
GPT_5_6_SOL_MODEL,
|
|
@@ -2336,20 +2441,18 @@ function seedRequestedModelAliases() {
|
|
|
2336
2441
|
GPT_6_ASTRA_MODEL,
|
|
2337
2442
|
GPT_6_ASTRA_EFFORTS,
|
|
2338
2443
|
);
|
|
2339
|
-
addRequestedModelEffortAliases(
|
|
2340
|
-
GPT_6_ASTRA_AEON_MODEL,
|
|
2341
|
-
GPT_6_ASTRA_AEON_MODEL,
|
|
2342
|
-
GPT_6_ASTRA_EFFORTS,
|
|
2343
|
-
);
|
|
2344
2444
|
addRequestedModelEffortAliases(
|
|
2345
2445
|
GPT_6_FLAGSHIP_ALIAS,
|
|
2346
2446
|
GPT_6_ASTRA_MODEL,
|
|
2347
2447
|
GPT_6_ASTRA_EFFORTS,
|
|
2348
2448
|
);
|
|
2349
2449
|
addRequestedModelEffortAliases("astra", GPT_6_ASTRA_MODEL, GPT_6_ASTRA_EFFORTS);
|
|
2450
|
+
// `astra-aeon` was only ever a leaked slug and is retired now, so the name
|
|
2451
|
+
// resolves to the flagship. Its `gpt-6-astra-aeon` form comes from the
|
|
2452
|
+
// retired table, not from a dedicated registration.
|
|
2350
2453
|
addRequestedModelEffortAliases(
|
|
2351
2454
|
"astra-aeon",
|
|
2352
|
-
|
|
2455
|
+
GPT_6_ASTRA_MODEL,
|
|
2353
2456
|
GPT_6_ASTRA_EFFORTS,
|
|
2354
2457
|
);
|
|
2355
2458
|
// No bare `sol`/`luna` aliases: those already mean the 5.6 tiers.
|
|
@@ -2359,6 +2462,16 @@ function seedRequestedModelAliases() {
|
|
|
2359
2462
|
GPT_6_LUNA_MODEL,
|
|
2360
2463
|
GPT_6_LUNA_EFFORTS,
|
|
2361
2464
|
);
|
|
2465
|
+
addRequestedModelEffortAliases(
|
|
2466
|
+
GPT_6_1_SOL_MODEL,
|
|
2467
|
+
GPT_6_1_SOL_MODEL,
|
|
2468
|
+
GPT_6_1_SOL_EFFORTS,
|
|
2469
|
+
);
|
|
2470
|
+
addRequestedModelEffortAliases(
|
|
2471
|
+
GPT_6_1_FLAGSHIP_ALIAS,
|
|
2472
|
+
GPT_6_1_SOL_MODEL,
|
|
2473
|
+
GPT_6_1_SOL_EFFORTS,
|
|
2474
|
+
);
|
|
2362
2475
|
addRequestedModelEffortAliases(
|
|
2363
2476
|
DAYBREAK_BLUE_MODEL,
|
|
2364
2477
|
DAYBREAK_BLUE_MODEL,
|
|
@@ -2451,23 +2564,28 @@ function resolveCodexRequestedModel(normalized) {
|
|
|
2451
2564
|
// Resolve GPT-6 identifiers that are not exact aliases (a dated snapshot, the
|
|
2452
2565
|
// `gpt-6-astra-pro` plan tier, or a tier OpenAI adds later). Without this the
|
|
2453
2566
|
// general GPT-5 resolver never matches (it needs a `gpt 5` token pair) and the
|
|
2454
|
-
// id falls through to
|
|
2455
|
-
//
|
|
2456
|
-
//
|
|
2567
|
+
// id falls through to the default — running 6.1 Sol for a caller who asked for
|
|
2568
|
+
// a different model. `aeon` resolves to the flagship it was a leaked variant
|
|
2569
|
+
// of. Mirrors lib/request/helpers/model-map.ts.
|
|
2457
2570
|
function resolveGpt6RequestedModel(stripped) {
|
|
2458
2571
|
const tokens = tokenizeRequestedModel(stripped);
|
|
2459
2572
|
const gptIndex = tokens.indexOf("gpt");
|
|
2460
|
-
// `gpt6` with no separator tokenizes as one token, so the `gpt` + `6` pair
|
|
2461
|
-
// never forms; mirror lib and claim it here.
|
|
2462
2573
|
const versionToken = gptIndex === -1 ? undefined : tokens[gptIndex + 1];
|
|
2463
2574
|
// `gpt6` with no separator tokenizes as one token, so the `gpt` + `6` pair
|
|
2464
2575
|
// never forms; mirror lib and claim it here.
|
|
2465
|
-
const
|
|
2576
|
+
const gpt6Index = tokens.indexOf("gpt6");
|
|
2577
|
+
const isGpt6 = versionToken === "6" || gpt6Index !== -1;
|
|
2578
|
+
// A 6.1 minor shows up as the token after `6` (`gpt-6.1-sol`) or after
|
|
2579
|
+
// `gpt6` (`gpt6.1-sol`); both forms land on the 6.1 generation, not on the
|
|
2580
|
+
// 6.0 tier the trailing `sol`/`luna` tokens name.
|
|
2581
|
+
const isGpt61 =
|
|
2582
|
+
(isGpt6 && gptIndex !== -1 && tokens[gptIndex + 2] === "1") ||
|
|
2583
|
+
(gpt6Index !== -1 && tokens[gpt6Index + 1] === "1");
|
|
2466
2584
|
// A bare `astra` token counts too: picker labels and OpenAI's own material
|
|
2467
2585
|
// say "Astra" with no `gpt-6` prefix, so `Astra Pro` arrives with no version
|
|
2468
|
-
// tokens and would otherwise miss every branch and land on
|
|
2469
|
-
// an id naming a different GPT major version, `gpt-4-astra-x`,
|
|
2470
|
-
// claimed for the frontier model.
|
|
2586
|
+
// tokens and would otherwise miss every branch and land on the default.
|
|
2587
|
+
// Anchored so an id naming a different GPT major version, `gpt-4-astra-x`,
|
|
2588
|
+
// is not claimed for the frontier model.
|
|
2471
2589
|
const namesOtherGptVersion =
|
|
2472
2590
|
versionToken !== undefined &&
|
|
2473
2591
|
/^\d+$/.test(versionToken) &&
|
|
@@ -2476,8 +2594,10 @@ function resolveGpt6RequestedModel(stripped) {
|
|
|
2476
2594
|
if ((!isGpt6 && !isAstra) || tokens.includes("codex")) {
|
|
2477
2595
|
return "";
|
|
2478
2596
|
}
|
|
2479
|
-
if (tokens.includes("aeon")) return
|
|
2597
|
+
if (tokens.includes("aeon")) return GPT_6_ASTRA_MODEL;
|
|
2480
2598
|
if (isAstra) return GPT_6_ASTRA_MODEL;
|
|
2599
|
+
// Every unrecognised 6.1 id resolves to the generation's only tier, Sol.
|
|
2600
|
+
if (isGpt61) return GPT_6_1_SOL_MODEL;
|
|
2481
2601
|
// `terra` goes to Sol: there is no GPT-6 Terra, and upstream migrates
|
|
2482
2602
|
// `gpt-5.6-terra` users to Sol.
|
|
2483
2603
|
if (tokens.includes("luna")) return GPT_6_LUNA_MODEL;
|
|
@@ -3271,6 +3391,7 @@ function collectShadowHomeSyncFileNames(shadowCodexHome, syncFileNames) {
|
|
|
3271
3391
|
if (
|
|
3272
3392
|
name === SHADOW_HOME_CONFIG_FILE ||
|
|
3273
3393
|
name === SHADOW_HOME_SYNC_STATE_FILE ||
|
|
3394
|
+
name === SHADOW_HOME_OWNER_FILE ||
|
|
3274
3395
|
syncFileNames.has(name)
|
|
3275
3396
|
) {
|
|
3276
3397
|
continue;
|
|
@@ -3442,6 +3563,7 @@ function createShadowHomeMirror(
|
|
|
3442
3563
|
name === SHADOW_HOME_CONFIG_FILE ||
|
|
3443
3564
|
name === SHADOW_HOME_SYNC_STATE_FILE ||
|
|
3444
3565
|
name === SHADOW_HOME_SYNC_LOCK_DIR ||
|
|
3566
|
+
name === SHADOW_HOME_OWNER_FILE ||
|
|
3445
3567
|
skipMirrorPredicate(name)
|
|
3446
3568
|
) {
|
|
3447
3569
|
continue;
|
|
@@ -3671,6 +3793,175 @@ function resolveRuntimeRotationProxyOriginalCodexHome(baseEnv) {
|
|
|
3671
3793
|
return override || resolveCodexHomeDir(baseEnv);
|
|
3672
3794
|
}
|
|
3673
3795
|
|
|
3796
|
+
// Markerless dirs are pre-sweeper leftovers (or crashed-before-mark runs);
|
|
3797
|
+
// 24h is generous next to any real session so a live shadow is never reaped.
|
|
3798
|
+
const STALE_SHADOW_HOME_AGE_MS = 24 * 60 * 60 * 1000;
|
|
3799
|
+
// A recorded PID is an identity, not just a liveness token: the owning process
|
|
3800
|
+
// necessarily started before its marker was written, so a process now holding
|
|
3801
|
+
// the PID that started meaningfully later is a different process — the PID was
|
|
3802
|
+
// recycled. Same rule sweepStaleRuntimeRotationAppHelperMetadata uses.
|
|
3803
|
+
const SHADOW_HOME_OWNER_SKEW_MS = 60_000;
|
|
3804
|
+
let staleShadowHomeSweepDone = false;
|
|
3805
|
+
|
|
3806
|
+
function writeShadowHomeOwnerMarker(shadowDir) {
|
|
3807
|
+
try {
|
|
3808
|
+
writeFileSync(
|
|
3809
|
+
join(shadowDir, SHADOW_HOME_OWNER_FILE),
|
|
3810
|
+
JSON.stringify({ pid: process.pid, createdAt: Date.now() }),
|
|
3811
|
+
{ mode: 0o600 },
|
|
3812
|
+
);
|
|
3813
|
+
} catch {
|
|
3814
|
+
// Best-effort only; a missing marker just defers reaping to the age rule.
|
|
3815
|
+
}
|
|
3816
|
+
}
|
|
3817
|
+
|
|
3818
|
+
// Once the forwarded child exists it is recorded alongside the wrapper PID: a
|
|
3819
|
+
// wrapper that dies ungracefully (SIGKILL cannot be relayed) leaves a marker
|
|
3820
|
+
// whose wrapper PID is dead while the child may still be running against the
|
|
3821
|
+
// shadow home. Only markers this process wrote are updated — a foreign or
|
|
3822
|
+
// leaked marker is left for the sweep's own rules.
|
|
3823
|
+
function recordShadowHomeChildPid(shadowDir, childPid) {
|
|
3824
|
+
if (typeof shadowDir !== "string" || shadowDir.trim().length === 0) {
|
|
3825
|
+
return;
|
|
3826
|
+
}
|
|
3827
|
+
if (typeof childPid !== "number" || !Number.isFinite(childPid)) {
|
|
3828
|
+
return;
|
|
3829
|
+
}
|
|
3830
|
+
try {
|
|
3831
|
+
const ownerPath = join(shadowDir, SHADOW_HOME_OWNER_FILE);
|
|
3832
|
+
if (!existsSync(ownerPath)) {
|
|
3833
|
+
return;
|
|
3834
|
+
}
|
|
3835
|
+
const owner = JSON.parse(readFileSync(ownerPath, "utf8"));
|
|
3836
|
+
if (owner?.pid !== process.pid) {
|
|
3837
|
+
return;
|
|
3838
|
+
}
|
|
3839
|
+
writeFileSync(
|
|
3840
|
+
ownerPath,
|
|
3841
|
+
JSON.stringify({
|
|
3842
|
+
...owner,
|
|
3843
|
+
childPid,
|
|
3844
|
+
childRecordedAt: Date.now(),
|
|
3845
|
+
}),
|
|
3846
|
+
{ mode: 0o600 },
|
|
3847
|
+
);
|
|
3848
|
+
} catch {
|
|
3849
|
+
// Best-effort only; a missing child record just shortens retention.
|
|
3850
|
+
}
|
|
3851
|
+
}
|
|
3852
|
+
|
|
3853
|
+
function isShadowHomeStale(shadowDir, probeStartTime) {
|
|
3854
|
+
const ownerPath = join(shadowDir, SHADOW_HOME_OWNER_FILE);
|
|
3855
|
+
if (existsSync(ownerPath)) {
|
|
3856
|
+
try {
|
|
3857
|
+
const owner = JSON.parse(readFileSync(ownerPath, "utf8"));
|
|
3858
|
+
if (typeof owner?.pid === "number" && Number.isFinite(owner.pid)) {
|
|
3859
|
+
const recordedProcessAlive = (pid, recordedAt) => {
|
|
3860
|
+
if (typeof pid !== "number" || !Number.isFinite(pid)) {
|
|
3861
|
+
return false;
|
|
3862
|
+
}
|
|
3863
|
+
if (!isProcessAlive(pid)) {
|
|
3864
|
+
return false;
|
|
3865
|
+
}
|
|
3866
|
+
if (
|
|
3867
|
+
typeof recordedAt !== "number" ||
|
|
3868
|
+
!Number.isFinite(recordedAt)
|
|
3869
|
+
) {
|
|
3870
|
+
// No marker timestamp to check identity against — bare liveness.
|
|
3871
|
+
return true;
|
|
3872
|
+
}
|
|
3873
|
+
const actualStartTimeMs = probeStartTime(pid);
|
|
3874
|
+
if (actualStartTimeMs === null || actualStartTimeMs === undefined) {
|
|
3875
|
+
// Identity unknowable (Windows, no ps, probe budget spent) —
|
|
3876
|
+
// retaining a maybe-live home beats reaping a live one.
|
|
3877
|
+
return true;
|
|
3878
|
+
}
|
|
3879
|
+
return actualStartTimeMs <= recordedAt + SHADOW_HOME_OWNER_SKEW_MS;
|
|
3880
|
+
};
|
|
3881
|
+
if (recordedProcessAlive(owner.pid, owner.createdAt)) {
|
|
3882
|
+
return false;
|
|
3883
|
+
}
|
|
3884
|
+
// The wrapper that owned this home is gone, but a killed wrapper
|
|
3885
|
+
// can leave its forwarded child running against the shadow home;
|
|
3886
|
+
// the home is only orphaned once the child is gone too.
|
|
3887
|
+
if (
|
|
3888
|
+
recordedProcessAlive(
|
|
3889
|
+
owner.childPid,
|
|
3890
|
+
owner.childRecordedAt ?? owner.createdAt,
|
|
3891
|
+
)
|
|
3892
|
+
) {
|
|
3893
|
+
return false;
|
|
3894
|
+
}
|
|
3895
|
+
return true;
|
|
3896
|
+
}
|
|
3897
|
+
} catch {
|
|
3898
|
+
// Corrupt marker — fall through to the age rule.
|
|
3899
|
+
}
|
|
3900
|
+
}
|
|
3901
|
+
try {
|
|
3902
|
+
return Date.now() - statSync(shadowDir).mtimeMs > STALE_SHADOW_HOME_AGE_MS;
|
|
3903
|
+
} catch {
|
|
3904
|
+
return false;
|
|
3905
|
+
}
|
|
3906
|
+
}
|
|
3907
|
+
|
|
3908
|
+
function sweepStaleShadowHomes(baseEnv) {
|
|
3909
|
+
if (staleShadowHomeSweepDone) {
|
|
3910
|
+
return;
|
|
3911
|
+
}
|
|
3912
|
+
staleShadowHomeSweepDone = true;
|
|
3913
|
+
const candidates = [
|
|
3914
|
+
{
|
|
3915
|
+
root: join(
|
|
3916
|
+
resolveCodexHomeDir(baseEnv),
|
|
3917
|
+
"multi-auth",
|
|
3918
|
+
"runtime-shadow-homes",
|
|
3919
|
+
),
|
|
3920
|
+
prefix: "codex-multi-auth-runtime-home-",
|
|
3921
|
+
},
|
|
3922
|
+
{ root: tmpdir(), prefix: "codex-multi-auth-home-" },
|
|
3923
|
+
];
|
|
3924
|
+
// Identity probes are memoized per PID and bounded: at most a handful of
|
|
3925
|
+
// `ps` spawns run per launch, and only for markers whose PID is still live —
|
|
3926
|
+
// dead-PID markers, the common case after a crash, never probe at all.
|
|
3927
|
+
const probedStartTimes = new Map();
|
|
3928
|
+
let probeBudget = 20;
|
|
3929
|
+
const probeStartTime = (pid) => {
|
|
3930
|
+
if (probedStartTimes.has(pid)) {
|
|
3931
|
+
return probedStartTimes.get(pid);
|
|
3932
|
+
}
|
|
3933
|
+
if (probeBudget <= 0) {
|
|
3934
|
+
return undefined;
|
|
3935
|
+
}
|
|
3936
|
+
probeBudget -= 1;
|
|
3937
|
+
const startTime = readProcessStartTimeMs(pid);
|
|
3938
|
+
probedStartTimes.set(pid, startTime);
|
|
3939
|
+
return startTime;
|
|
3940
|
+
};
|
|
3941
|
+
for (const { root, prefix } of candidates) {
|
|
3942
|
+
let entries;
|
|
3943
|
+
try {
|
|
3944
|
+
entries = readdirSync(root, { withFileTypes: true });
|
|
3945
|
+
} catch {
|
|
3946
|
+
continue;
|
|
3947
|
+
}
|
|
3948
|
+
for (const entry of entries) {
|
|
3949
|
+
if (!entry.isDirectory() || !entry.name.startsWith(prefix)) {
|
|
3950
|
+
continue;
|
|
3951
|
+
}
|
|
3952
|
+
const shadowDir = join(root, entry.name);
|
|
3953
|
+
if (!isShadowHomeStale(shadowDir, probeStartTime)) {
|
|
3954
|
+
continue;
|
|
3955
|
+
}
|
|
3956
|
+
try {
|
|
3957
|
+
removeDirectoryWithRetry(shadowDir);
|
|
3958
|
+
} catch {
|
|
3959
|
+
// Best-effort sweep; a busy shadow is retried on the next launch.
|
|
3960
|
+
}
|
|
3961
|
+
}
|
|
3962
|
+
}
|
|
3963
|
+
}
|
|
3964
|
+
|
|
3674
3965
|
function createRuntimeRotationShadowHome(originalCodexHome) {
|
|
3675
3966
|
const shadowRoot = join(
|
|
3676
3967
|
originalCodexHome,
|
|
@@ -3678,7 +3969,11 @@ function createRuntimeRotationShadowHome(originalCodexHome) {
|
|
|
3678
3969
|
"runtime-shadow-homes",
|
|
3679
3970
|
);
|
|
3680
3971
|
mkdirSync(shadowRoot, { recursive: true });
|
|
3681
|
-
|
|
3972
|
+
const shadowDir = mkdtempSync(
|
|
3973
|
+
join(shadowRoot, "codex-multi-auth-runtime-home-"),
|
|
3974
|
+
);
|
|
3975
|
+
writeShadowHomeOwnerMarker(shadowDir);
|
|
3976
|
+
return shadowDir;
|
|
3682
3977
|
}
|
|
3683
3978
|
|
|
3684
3979
|
function parseHookStateTableKey(line) {
|
|
@@ -5927,6 +6222,7 @@ function createCompatibilityCodexHome(
|
|
|
5927
6222
|
}
|
|
5928
6223
|
|
|
5929
6224
|
const shadowCodexHome = mkdtempSync(join(tmpdir(), "codex-multi-auth-home-"));
|
|
6225
|
+
writeShadowHomeOwnerMarker(shadowCodexHome);
|
|
5930
6226
|
let syncShadowHomeStateBack = () => {};
|
|
5931
6227
|
const cleanup = () => {
|
|
5932
6228
|
try {
|