codex-multi-auth 2.17.0 → 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 +9 -9
- package/LICENSE +21 -21
- package/README.md +142 -484
- package/assets/codex-multi-auth-icon.svg +39 -39
- package/assets/readme-hero.svg +31 -31
- package/config/README.md +31 -31
- package/config/codex-legacy.json +1221 -1221
- package/config/codex-modern.json +423 -423
- package/config/minimal-codex.json +15 -15
- 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 +1 -8
- package/dist/lib/accounts.d.ts.map +1 -1
- package/dist/lib/accounts.js +7 -19
- 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 +1 -2
- package/dist/lib/codex-manager/commands/forecast.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/forecast.js +2 -2
- 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/health-check.js +1 -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-menu-data.d.ts.map +1 -1
- package/dist/lib/codex-manager/login-menu-data.js +7 -3
- 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 +7 -2
- package/dist/lib/codex-manager/quota-cache-helpers.d.ts.map +1 -1
- package/dist/lib/codex-manager/quota-cache-helpers.js +34 -19
- 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/repair-commands.js +1 -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-budget-response.js +8 -8
- package/dist/lib/context-overflow.d.ts +0 -1
- package/dist/lib/context-overflow.js +10 -10
- 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/oauth-success.html +125 -125
- 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-host-bridge.js +138 -138
- package/dist/lib/prompts/codex.d.ts +0 -1
- package/dist/lib/prompts/codex.js +79 -79
- 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 +7 -4
- package/dist/lib/quota-cache.d.ts.map +1 -1
- package/dist/lib/quota-cache.js +117 -61
- package/dist/lib/quota-probe.d.ts +0 -1
- package/dist/lib/quota-probe.js +5 -2
- package/dist/lib/quota-readiness.d.ts +7 -3
- package/dist/lib/quota-readiness.d.ts.map +1 -1
- package/dist/lib/quota-readiness.js +25 -4
- 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-bind.d.ts.map +1 -1
- package/dist/lib/runtime/app-bind.js +10 -2
- 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 +5 -2
- package/dist/lib/runtime/automatic-account-checks.d.ts.map +1 -1
- package/dist/lib/runtime/automatic-account-checks.js +29 -2
- package/dist/lib/runtime/automatic-subscription-checks.d.ts +1 -2
- package/dist/lib/runtime/automatic-subscription-checks.d.ts.map +1 -1
- package/dist/lib/runtime/automatic-subscription-checks.js +13 -16
- 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 +136 -3
- 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 +10 -3
- package/dist/lib/storage/pending-auth.d.ts.map +1 -1
- package/dist/lib/storage/pending-auth.js +33 -9
- 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 +15 -0
- package/dist/lib/storage/record-identity.d.ts.map +1 -0
- package/dist/lib/storage/record-identity.js +16 -0
- 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/node_modules/@codex-ai/plugin/dist/index.d.ts +2 -2
- package/node_modules/@codex-ai/plugin/dist/index.js +2 -2
- package/node_modules/@codex-ai/plugin/dist/tool.d.ts +42 -42
- package/node_modules/@codex-ai/plugin/dist/tool.js +29 -29
- package/node_modules/@codex-ai/plugin/package.json +9 -9
- package/node_modules/@codex-ai/sdk/dist/index.d.ts +4 -4
- package/node_modules/@codex-ai/sdk/dist/index.js +2 -2
- package/node_modules/@codex-ai/sdk/package.json +8 -8
- package/package.json +206 -200
- package/scripts/codex-app-launcher.js +653 -653
- package/scripts/codex-app-router.js +373 -373
- package/scripts/codex-bin-resolver.js +332 -313
- package/scripts/codex-multi-auth.js +65 -59
- package/scripts/codex-routing.js +62 -62
- package/scripts/codex.js +6923 -6642
- package/scripts/install-codex-auth-utils.js +213 -213
- package/scripts/mcodex.js +367 -367
- package/scripts/postinstall.js +114 -114
- package/scripts/preuninstall.js +265 -265
- package/skills/codex-auth-setup/SKILL.md +73 -0
- package/vendor/codex-ai-plugin/dist/index.d.ts +2 -2
- package/vendor/codex-ai-plugin/dist/index.js +2 -2
- package/vendor/codex-ai-plugin/dist/tool.d.ts +42 -42
- package/vendor/codex-ai-plugin/dist/tool.js +29 -29
- package/vendor/codex-ai-plugin/package.json +9 -9
- package/vendor/codex-ai-sdk/dist/index.d.ts +4 -4
- package/vendor/codex-ai-sdk/dist/index.js +2 -2
- package/vendor/codex-ai-sdk/package.json +8 -8
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
import { ensureContentType } from "./response-handler.js";
|
|
2
2
|
const DEFAULT_MAX_FAILOVERS = 1;
|
|
3
|
+
// Generous hard bound for the library API: the runtime path already clamps to
|
|
4
|
+
// MAX_STREAM_FAILOVERS via capStreamFailoverMax, but a direct caller passing a
|
|
5
|
+
// non-finite or huge value must not produce unbounded fallback churn.
|
|
6
|
+
const MAX_FAILOVERS_HARD_BOUND = 32;
|
|
7
|
+
function normalizeMaxFailovers(value) {
|
|
8
|
+
if (value === undefined || !Number.isFinite(value)) {
|
|
9
|
+
return DEFAULT_MAX_FAILOVERS;
|
|
10
|
+
}
|
|
11
|
+
return Math.max(0, Math.min(MAX_FAILOVERS_HARD_BOUND, Math.floor(value)));
|
|
12
|
+
}
|
|
3
13
|
const DEFAULT_STALL_TIMEOUT_MS = 45_000;
|
|
4
14
|
const DEFAULT_SOFT_TIMEOUT_MS = 15_000;
|
|
5
15
|
const MAX_REQUEST_INSTANCE_ID_LENGTH = 64;
|
|
16
|
+
// Node clamps setTimeout delays above 2^31-1 (~24.8 days) to ~1ms, so an
|
|
17
|
+
// oversized-but-finite timeout would otherwise fire the stall window almost
|
|
18
|
+
// immediately and churn fallovers. Cap effective delays at the supported
|
|
19
|
+
// maximum.
|
|
20
|
+
const MAX_TIMER_DELAY_MS = 2_147_483_647;
|
|
6
21
|
class StallTimeoutError extends Error {
|
|
7
22
|
isStallTimeout = true;
|
|
8
23
|
constructor(timeoutMs) {
|
|
@@ -106,10 +121,19 @@ async function readChunkWithSoftHardTimeout(reader, softTimeoutMs, hardTimeoutMs
|
|
|
106
121
|
* @returns A new Response that streams data from the initial response but may switch to fallback responses on stall/error, preserving the original status, statusText, and content-type header.
|
|
107
122
|
*/
|
|
108
123
|
export function withStreamingFailover(initialResponse, getFallbackResponse, options = {}) {
|
|
109
|
-
const maxFailovers =
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
124
|
+
const maxFailovers = normalizeMaxFailovers(options.maxFailovers);
|
|
125
|
+
const stallTimeoutOption = options.stallTimeoutMs !== undefined && Number.isFinite(options.stallTimeoutMs)
|
|
126
|
+
? options.stallTimeoutMs
|
|
127
|
+
: DEFAULT_STALL_TIMEOUT_MS;
|
|
128
|
+
const defaultHardTimeoutMs = stallTimeoutOption;
|
|
129
|
+
const softTimeoutOption = options.softTimeoutMs !== undefined && Number.isFinite(options.softTimeoutMs)
|
|
130
|
+
? options.softTimeoutMs
|
|
131
|
+
: Math.min(defaultHardTimeoutMs, DEFAULT_SOFT_TIMEOUT_MS);
|
|
132
|
+
const softTimeoutMs = Math.min(MAX_TIMER_DELAY_MS, Math.max(1_000, Math.floor(softTimeoutOption)));
|
|
133
|
+
const hardTimeoutOption = options.hardTimeoutMs !== undefined && Number.isFinite(options.hardTimeoutMs)
|
|
134
|
+
? options.hardTimeoutMs
|
|
135
|
+
: defaultHardTimeoutMs;
|
|
136
|
+
const hardTimeoutMs = Math.min(MAX_TIMER_DELAY_MS, Math.max(softTimeoutMs, Math.floor(hardTimeoutOption)));
|
|
113
137
|
const requestInstanceId = normalizeRequestInstanceId(options.requestInstanceId);
|
|
114
138
|
const headers = ensureContentType(initialResponse.headers);
|
|
115
139
|
if (!initialResponse.body || maxFailovers <= 0) {
|
|
@@ -27,4 +27,3 @@ export declare function shouldRefreshToken(auth: Auth, skewMs?: number): boolean
|
|
|
27
27
|
* @returns Updated auth (throws on failure)
|
|
28
28
|
*/
|
|
29
29
|
export declare function refreshAndUpdateToken(currentAuth: Auth, client: CodexClient): Promise<Auth>;
|
|
30
|
-
//# sourceMappingURL=token-refresh.d.ts.map
|
|
@@ -21,4 +21,3 @@ export declare function rewriteUrlForCodex(url: string): string;
|
|
|
21
21
|
export declare function resolveProxyUrlForRequest(url: string, env?: NodeJS.ProcessEnv): string | undefined;
|
|
22
22
|
export declare function closeSharedProxyDispatchers(): Promise<void>;
|
|
23
23
|
export declare function applyProxyCompatibleInit(url: string, init?: ProxyCompatibleRequestInit, env?: NodeJS.ProcessEnv): ProxyCompatibleRequestInit;
|
|
24
|
-
//# sourceMappingURL=url-rewriting.d.ts.map
|
package/dist/lib/rotation.d.ts
CHANGED
|
@@ -233,4 +233,3 @@ export declare function getHealthTracker(config?: Partial<HealthScoreConfig>): H
|
|
|
233
233
|
export declare function getTokenTracker(config?: Partial<TokenBucketConfig>): TokenBucketTracker;
|
|
234
234
|
export declare function resetTrackers(): void;
|
|
235
235
|
export {};
|
|
236
|
-
//# sourceMappingURL=rotation.d.ts.map
|
|
@@ -116,4 +116,3 @@ export declare function __resetRoutingMutexForTests(): void;
|
|
|
116
116
|
* `withRoutingMutex` calls it makes are detected as reentrant.
|
|
117
117
|
*/
|
|
118
118
|
export declare function withRoutingMutex<T>(mode: RoutingMutexMode, fn: () => Promise<T> | T): Promise<T>;
|
|
119
|
-
//# sourceMappingURL=routing-mutex.d.ts.map
|
|
@@ -23,7 +23,22 @@ export interface ProjectRoutingProfileContext {
|
|
|
23
23
|
}
|
|
24
24
|
export declare function getRoutingProfilesPath(): string;
|
|
25
25
|
export declare function loadRoutingProfileStore(): Promise<RoutingProfileStore>;
|
|
26
|
-
export declare function saveRoutingProfileStore(store: RoutingProfileStore): Promise<void>;
|
|
26
|
+
export declare function saveRoutingProfileStore(store: RoutingProfileStore, baseline?: RoutingProfileStore): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Run a routing-profile read→mutate→write inside the write queue (in-process
|
|
29
|
+
* serialization) AND the cross-process lock directory, with mtime CAS retry:
|
|
30
|
+
* every attempt re-reads the freshest on-disk store and re-applies `mutate`
|
|
31
|
+
* before writing — so a mutation is applied to the latest committed state
|
|
32
|
+
* rather than merged by whole-record `updatedAt`, which can drop or clobber
|
|
33
|
+
* a concurrent process's change to the same profile. `mutate` must be
|
|
34
|
+
* re-appliable across retries (apply precomputed work onto the store it is
|
|
35
|
+
* handed, don't capture mutated state). Prefer this over load→upsert→save
|
|
36
|
+
* whenever the caller is mutating rather than importing a foreign store.
|
|
37
|
+
*/
|
|
38
|
+
export declare function updateRoutingProfileStore<T>(mutate: (store: RoutingProfileStore) => {
|
|
39
|
+
result: T;
|
|
40
|
+
dirty: boolean;
|
|
41
|
+
}): Promise<T>;
|
|
27
42
|
export declare function createDefaultRoutingProfile(input: {
|
|
28
43
|
projectKey: string;
|
|
29
44
|
projectName: string;
|
|
@@ -33,4 +48,3 @@ export declare function createDefaultRoutingProfile(input: {
|
|
|
33
48
|
export declare function upsertRoutingProfile(store: RoutingProfileStore, profile: RoutingProfile, mutate?: (profile: RoutingProfile) => void, now?: number): RoutingProfile;
|
|
34
49
|
export declare function resolveProjectRoutingProfile(startDir?: string, storeLoader?: () => Promise<RoutingProfileStore>): Promise<ProjectRoutingProfileContext>;
|
|
35
50
|
export declare function resetRoutingProfileWriteQueueForTests(): void;
|
|
36
|
-
//# sourceMappingURL=routing-profiles.d.ts.map
|
|
@@ -4,10 +4,9 @@ import { logWarn } from "./logger.js";
|
|
|
4
4
|
import { getCodexMultiAuthDir } from "./runtime-paths.js";
|
|
5
5
|
import { findProjectRoot, getProjectStorageKey, resolveProjectStorageIdentityRoot, } from "./storage/paths.js";
|
|
6
6
|
import { isRecord, sleep } from "./utils.js";
|
|
7
|
-
import {
|
|
7
|
+
import { getJsonStoreFileMtimeMs, resetJsonStoreWriteQueuesForTests, stampUpdatedAt, withJsonStoreCasRetry, withJsonStoreFileLock, withJsonStoreWriteQueue, writeJsonStoreFileAtomicWithRetry, } from "./storage/json-store-lock.js";
|
|
8
8
|
const ROUTING_PROFILES_FILE_NAME = "routing-profiles.json";
|
|
9
9
|
const RETRYABLE_FS_CODES = new Set(["EBUSY", "EPERM"]);
|
|
10
|
-
let writeQueue = Promise.resolve();
|
|
11
10
|
function isRetryableFsError(error) {
|
|
12
11
|
const code = error?.code;
|
|
13
12
|
return typeof code === "string" && RETRYABLE_FS_CODES.has(code);
|
|
@@ -64,13 +63,24 @@ function normalizeProfile(key, value) {
|
|
|
64
63
|
: 0,
|
|
65
64
|
};
|
|
66
65
|
}
|
|
66
|
+
// Profile keys are caller/project-derived strings — including, via a crafted
|
|
67
|
+
// store file or a literal upsert, Object.prototype member names such as
|
|
68
|
+
// "constructor" or "__proto__". On a plain object, reading an absent key
|
|
69
|
+
// resolves an inherited member ({}.constructor === Object), which made a
|
|
70
|
+
// same-named profile look "already present" to the merge and silently dropped
|
|
71
|
+
// the incoming entry; writing "__proto__" invokes the setter and mutates the
|
|
72
|
+
// prototype instead of storing anything. Null-prototype maps make every key a
|
|
73
|
+
// plain data slot regardless of name.
|
|
74
|
+
function newProfilesMap() {
|
|
75
|
+
return Object.create(null);
|
|
76
|
+
}
|
|
67
77
|
function emptyStore() {
|
|
68
|
-
return { version: 1, profiles:
|
|
78
|
+
return { version: 1, profiles: newProfilesMap() };
|
|
69
79
|
}
|
|
70
80
|
function normalizeStore(value) {
|
|
71
81
|
if (!isRecord(value) || value.version !== 1)
|
|
72
82
|
return emptyStore();
|
|
73
|
-
const profiles =
|
|
83
|
+
const profiles = newProfilesMap();
|
|
74
84
|
if (isRecord(value.profiles)) {
|
|
75
85
|
for (const [key, raw] of Object.entries(value.profiles)) {
|
|
76
86
|
const profile = normalizeProfile(key, raw);
|
|
@@ -112,45 +122,100 @@ export async function loadRoutingProfileStore() {
|
|
|
112
122
|
return emptyStore();
|
|
113
123
|
}
|
|
114
124
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
125
|
+
/**
|
|
126
|
+
* Per-key merge of the caller's normalized store over the freshest on-disk
|
|
127
|
+
* store. Profiles carry `updatedAt`; the newer entry wins per key so a save
|
|
128
|
+
* built on a stale snapshot cannot resurrect an older profile over a
|
|
129
|
+
* concurrent process's newer one. Keys the caller does not carry are
|
|
130
|
+
* preserved (upsert-only store — nothing deletes entries), matching the
|
|
131
|
+
* config save's patch-over-fresh-read semantics.
|
|
132
|
+
*
|
|
133
|
+
* When `baseline` (the caller's pre-edit snapshot) is supplied, entries
|
|
134
|
+
* identical to it are untouched carried copies and skipped entirely, so a
|
|
135
|
+
* stale snapshot row can never be re-stamped over a raced write. Entries
|
|
136
|
+
* that differ are deliberate writes and must not lose purely on timestamp:
|
|
137
|
+
* the upsert-time floor stamps against the caller's snapshot, but a
|
|
138
|
+
* concurrent writer can land a still-newer entry before this merge runs, so
|
|
139
|
+
* the merge re-stamps against the freshest on-disk entry instead of
|
|
140
|
+
* silently dropping the edit. Without a baseline every supplied entry is a
|
|
141
|
+
* plain `updatedAt >=` upsert.
|
|
142
|
+
*/
|
|
143
|
+
function mergeRoutingProfiles(current, incoming, baseline) {
|
|
144
|
+
const merged = {
|
|
145
|
+
version: 1,
|
|
146
|
+
profiles: Object.assign(newProfilesMap(), current.profiles),
|
|
147
|
+
};
|
|
148
|
+
const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
149
|
+
for (const [key, profile] of Object.entries(incoming.profiles)) {
|
|
150
|
+
const existing = merged.profiles[key];
|
|
151
|
+
if (!baseline) {
|
|
152
|
+
if (!existing || profile.updatedAt >= existing.updatedAt) {
|
|
153
|
+
merged.profiles[key] = profile;
|
|
138
154
|
}
|
|
155
|
+
continue;
|
|
139
156
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
157
|
+
if (same(profile, baseline.profiles[key]))
|
|
158
|
+
continue;
|
|
159
|
+
profile.updatedAt = stampUpdatedAt(profile.updatedAt, existing?.updatedAt);
|
|
160
|
+
merged.profiles[key] = profile;
|
|
161
|
+
}
|
|
162
|
+
return merged;
|
|
163
|
+
}
|
|
164
|
+
export async function saveRoutingProfileStore(store, baseline) {
|
|
165
|
+
const path = getRoutingProfilesPath();
|
|
166
|
+
const incoming = normalizeStore(store);
|
|
167
|
+
// Normalize at invocation like `incoming`: later caller-side mutation of
|
|
168
|
+
// `baseline` must not shift which entries the merge counts as deliberate.
|
|
169
|
+
const prior = baseline ? normalizeStore(baseline) : undefined;
|
|
170
|
+
// Per-path promise queue serializes writers inside THIS process; the
|
|
171
|
+
// lock directory closes the same window against OTHER processes. Inside the lock
|
|
172
|
+
// every attempt re-stats (CAS), re-reads the freshest on-disk store, and
|
|
173
|
+
// merges this call's entries over it — so a save that raced a concurrent
|
|
174
|
+
// write reloads-and-retries rather than blindly overwriting it.
|
|
175
|
+
await withJsonStoreWriteQueue(path, async () => {
|
|
176
|
+
await withJsonStoreFileLock(path, async () => {
|
|
177
|
+
await withJsonStoreCasRetry(async () => {
|
|
178
|
+
const expectedMtimeMs = await getJsonStoreFileMtimeMs(path);
|
|
179
|
+
const current = await loadRoutingProfileStore();
|
|
180
|
+
const merged = mergeRoutingProfiles(current, incoming, prior);
|
|
181
|
+
await fs.mkdir(getCodexMultiAuthDir(), {
|
|
182
|
+
recursive: true,
|
|
183
|
+
mode: 0o700,
|
|
184
|
+
});
|
|
185
|
+
await writeJsonStoreFileAtomicWithRetry(path, merged, {
|
|
186
|
+
expectedMtimeMs,
|
|
187
|
+
mode: 0o600,
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Run a routing-profile read→mutate→write inside the write queue (in-process
|
|
195
|
+
* serialization) AND the cross-process lock directory, with mtime CAS retry:
|
|
196
|
+
* every attempt re-reads the freshest on-disk store and re-applies `mutate`
|
|
197
|
+
* before writing — so a mutation is applied to the latest committed state
|
|
198
|
+
* rather than merged by whole-record `updatedAt`, which can drop or clobber
|
|
199
|
+
* a concurrent process's change to the same profile. `mutate` must be
|
|
200
|
+
* re-appliable across retries (apply precomputed work onto the store it is
|
|
201
|
+
* handed, don't capture mutated state). Prefer this over load→upsert→save
|
|
202
|
+
* whenever the caller is mutating rather than importing a foreign store.
|
|
203
|
+
*/
|
|
204
|
+
export async function updateRoutingProfileStore(mutate) {
|
|
205
|
+
const path = getRoutingProfilesPath();
|
|
206
|
+
return withJsonStoreWriteQueue(path, () => withJsonStoreFileLock(path, () => withJsonStoreCasRetry(async () => {
|
|
207
|
+
const expectedMtimeMs = await getJsonStoreFileMtimeMs(path);
|
|
208
|
+
const store = await loadRoutingProfileStore();
|
|
209
|
+
const { result, dirty } = mutate(store);
|
|
210
|
+
if (dirty) {
|
|
211
|
+
await fs.mkdir(getCodexMultiAuthDir(), {
|
|
212
|
+
recursive: true,
|
|
213
|
+
mode: 0o700,
|
|
214
|
+
});
|
|
215
|
+
await writeJsonStoreFileAtomicWithRetry(path, normalizeStore(store), { expectedMtimeMs, mode: 0o600 });
|
|
149
216
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
writeQueue = queued.then(() => undefined, () => undefined);
|
|
153
|
-
await queued;
|
|
217
|
+
return result;
|
|
218
|
+
})));
|
|
154
219
|
}
|
|
155
220
|
export function createDefaultRoutingProfile(input) {
|
|
156
221
|
return {
|
|
@@ -167,13 +232,23 @@ export function createDefaultRoutingProfile(input) {
|
|
|
167
232
|
};
|
|
168
233
|
}
|
|
169
234
|
export function upsertRoutingProfile(store, profile, mutate, now = Date.now()) {
|
|
170
|
-
|
|
235
|
+
// store.profiles may be a caller-built plain object, so absent-key reads
|
|
236
|
+
// need an own-property check and "__proto__" needs a setter-safe write.
|
|
237
|
+
const existing = Object.hasOwn(store.profiles, profile.projectKey)
|
|
238
|
+
? store.profiles[profile.projectKey]
|
|
239
|
+
: undefined;
|
|
240
|
+
const next = structuredClone(existing ?? profile);
|
|
171
241
|
mutate?.(next);
|
|
172
|
-
next.updatedAt = now;
|
|
242
|
+
next.updatedAt = stampUpdatedAt(now, existing?.updatedAt);
|
|
173
243
|
const normalized = normalizeProfile(profile.projectKey, next);
|
|
174
244
|
if (!normalized)
|
|
175
245
|
throw new Error("Invalid routing profile");
|
|
176
|
-
store.profiles
|
|
246
|
+
Object.defineProperty(store.profiles, profile.projectKey, {
|
|
247
|
+
value: normalized,
|
|
248
|
+
writable: true,
|
|
249
|
+
enumerable: true,
|
|
250
|
+
configurable: true,
|
|
251
|
+
});
|
|
177
252
|
return normalized;
|
|
178
253
|
}
|
|
179
254
|
export async function resolveProjectRoutingProfile(startDir = process.cwd(), storeLoader = loadRoutingProfileStore) {
|
|
@@ -199,5 +274,5 @@ export async function resolveProjectRoutingProfile(startDir = process.cwd(), sto
|
|
|
199
274
|
};
|
|
200
275
|
}
|
|
201
276
|
export function resetRoutingProfileWriteQueueForTests() {
|
|
202
|
-
|
|
277
|
+
resetJsonStoreWriteQueuesForTests(getRoutingProfilesPath());
|
|
203
278
|
}
|
|
@@ -53,7 +53,7 @@ export declare class AccountModelCatalog {
|
|
|
53
53
|
reasoningLevels: string[];
|
|
54
54
|
accessPrograms: string[];
|
|
55
55
|
probes?: {
|
|
56
|
-
[k: string]: "
|
|
56
|
+
[k: string]: "verified" | "unsupported" | "unverified" | "downgraded";
|
|
57
57
|
} | undefined;
|
|
58
58
|
checkedAt?: number | undefined;
|
|
59
59
|
model: string;
|
|
@@ -61,4 +61,3 @@ export declare class AccountModelCatalog {
|
|
|
61
61
|
error: boolean;
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
-
//# sourceMappingURL=account-model-catalog.d.ts.map
|
|
@@ -22,4 +22,3 @@ export declare function persistAccountPoolResults(params: {
|
|
|
22
22
|
extractAccountEmail: (accessToken: string, idToken?: string) => string | undefined;
|
|
23
23
|
sanitizeEmail: (email: string | undefined) => string | undefined;
|
|
24
24
|
}): Promise<void>;
|
|
25
|
-
//# sourceMappingURL=account-pool.d.ts.map
|
|
@@ -39,4 +39,3 @@ export declare function loadResetCreditState(): Promise<{
|
|
|
39
39
|
/** Local terminal labels only; never used in provider requests or public artifacts. */
|
|
40
40
|
export declare function resetAccountLabel(account: Pick<AccountMetadataV3, "email">, index: number): string;
|
|
41
41
|
export declare function refreshAndPrintResetCredits(log: (message: string) => void): Promise<void>;
|
|
42
|
-
//# sourceMappingURL=account-reset-credits.d.ts.map
|
|
@@ -29,7 +29,10 @@ export function isResetTargetEnabled(account, target) {
|
|
|
29
29
|
}
|
|
30
30
|
export function createResetCreditService(manager) {
|
|
31
31
|
const auth = async (target) => {
|
|
32
|
-
const
|
|
32
|
+
const matches = manager?.getAccountsSnapshot().filter(a => workspaceModelScopes(a).some(s => s.id === target.key && s.accountId === target.accountId && s.routable) || (resetTargetForStoredAccount({ ...a, accessToken: a.access })?.key === target.key && resetTargetForStoredAccount({ ...a, accessToken: a.access })?.accountId === target.accountId));
|
|
33
|
+
if (matches && matches.length > 1)
|
|
34
|
+
throw Error('Reset account identity is ambiguous; repair duplicate records before checking or redeeming');
|
|
35
|
+
const account = matches?.[0];
|
|
33
36
|
const current = account && manager?.getAccountByIndex(account.index);
|
|
34
37
|
if (!manager || !current || current.enabled === false)
|
|
35
38
|
throw Error('Reset workspace is not enabled');
|
|
@@ -53,7 +56,10 @@ export function createResetCreditService(manager) {
|
|
|
53
56
|
consume: async (target, idempotencyKey) => {
|
|
54
57
|
const freshAuth = await auth(target);
|
|
55
58
|
const disk = await loadAccounts();
|
|
56
|
-
|
|
59
|
+
const matches = disk?.accounts.filter(a => isResetTargetEnabled(a, target)) ?? [];
|
|
60
|
+
if (matches.length > 1)
|
|
61
|
+
throw Error('Reset account identity is ambiguous; no credit consumed');
|
|
62
|
+
if (matches.length !== 1)
|
|
57
63
|
throw Error('Reset target was removed, disabled, or changed; no credit consumed');
|
|
58
64
|
return nativeRateLimitsRpc(freshAuth, 'account/rateLimitResetCredit/consume', { idempotencyKey });
|
|
59
65
|
},
|
|
@@ -16,4 +16,3 @@ export declare function handleAccountSelectEvent(input: {
|
|
|
16
16
|
setLastCodexCliActiveSyncIndex: (index: number) => void;
|
|
17
17
|
showToast: (message: string, variant?: "info" | "success" | "warning" | "error") => Promise<void>;
|
|
18
18
|
}): Promise<boolean>;
|
|
19
|
-
//# sourceMappingURL=account-select-event.d.ts.map
|
|
@@ -77,4 +77,3 @@ export declare function formatRateLimitEntry(account: {
|
|
|
77
77
|
export declare function getRateLimitResetTimeForModel(account: {
|
|
78
78
|
rateLimitResetTimes?: Record<string, number | undefined>;
|
|
79
79
|
}, now: number, family: ModelFamily, model: string): number | null;
|
|
80
|
-
//# sourceMappingURL=account-status.d.ts.map
|
|
@@ -143,4 +143,3 @@ export declare function getAppBindStatus(options?: AppBindOptions): Promise<AppB
|
|
|
143
143
|
export declare function bindCodexAppRuntimeRotation(options?: AppBindOptions): Promise<AppBindResult>;
|
|
144
144
|
export declare function unbindCodexAppRuntimeRotation(options?: AppBindOptions): Promise<AppBindResult>;
|
|
145
145
|
export declare function formatAppBindStatus(status: AppBindStatus): string;
|
|
146
|
-
//# sourceMappingURL=app-bind.d.ts.map
|
|
@@ -1 +1 @@
|
|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,GAAE,0BAA+B,GACtC,OAAO,CAAC,OAAO,CAAC,CA6DlB;AAmED;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,IAAI,CAAC;AA8C3C,wBAAsB,mCAAmC,CACxD,MAAM,EAAE,8BAA8B,EACtC,OAAO,GAAE,0BAA0B,GAAG;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAA;CAAO,GACvE,OAAO,CAAC,OAAO,CAAC,CAwClB;AAUD,wBAAsB,gBAAgB,CAAC,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,aAAa,CAAC,CAqB3F;AAED,wBAAsB,2BAA2B,CAChD,OAAO,GAAE,cAAmB,GAC1B,OAAO,CAAC,aAAa,CAAC,CAKxB;AA2JD,wBAAsB,6BAA6B,CAClD,OAAO,GAAE,cAAmB,GAC1B,OAAO,CAAC,aAAa,CAAC,CAKxB;AAsQD,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAuCjE"}
|
|
@@ -570,6 +570,13 @@ async function runWindowsTaskkill(pid) {
|
|
|
570
570
|
}
|
|
571
571
|
});
|
|
572
572
|
}
|
|
573
|
+
// `ps -o lstart=` is locale-sensitive: under a non-English LC_TIME it prints
|
|
574
|
+
// localized day/month names that parsePosixProcessStartTime cannot read, so
|
|
575
|
+
// every POSIX identity probe would fail and unbind would leak live routers.
|
|
576
|
+
const POSIX_IDENTITY_PROBE_ENV = {
|
|
577
|
+
...process.env,
|
|
578
|
+
LC_ALL: "C",
|
|
579
|
+
};
|
|
573
580
|
async function runProcessIdentityProbe(command, args, options = {}) {
|
|
574
581
|
return new Promise((resolve) => {
|
|
575
582
|
let output = "";
|
|
@@ -601,6 +608,7 @@ async function runProcessIdentityProbe(command, args, options = {}) {
|
|
|
601
608
|
child = spawn(command, args, {
|
|
602
609
|
stdio: ["ignore", "pipe", "ignore"],
|
|
603
610
|
windowsHide: true,
|
|
611
|
+
...(options.env ? { env: options.env } : {}),
|
|
604
612
|
});
|
|
605
613
|
child.stdout?.setEncoding("utf8");
|
|
606
614
|
child.stdout?.on("data", (chunk) => {
|
|
@@ -649,8 +657,8 @@ async function readProcessIdentity(pid, platform, log) {
|
|
|
649
657
|
};
|
|
650
658
|
}
|
|
651
659
|
const [startedAtRaw, commandLineRaw] = await Promise.all([
|
|
652
|
-
runProcessIdentityProbe("ps", ["-p", String(pid), "-o", "lstart="], { log }),
|
|
653
|
-
runProcessIdentityProbe("ps", ["-p", String(pid), "-o", "command="], { log }),
|
|
660
|
+
runProcessIdentityProbe("ps", ["-p", String(pid), "-o", "lstart="], { env: POSIX_IDENTITY_PROBE_ENV, log }),
|
|
661
|
+
runProcessIdentityProbe("ps", ["-p", String(pid), "-o", "command="], { env: POSIX_IDENTITY_PROBE_ENV, log }),
|
|
654
662
|
]);
|
|
655
663
|
if (!startedAtRaw || !commandLineRaw) {
|
|
656
664
|
log?.(`Process identity probe returned no POSIX record for PID ${pid}`);
|
|
@@ -66,4 +66,3 @@ export declare function liveRuntimeHelpers<T extends RuntimeHelperSelectable>(st
|
|
|
66
66
|
* count describe one instant rather than two.
|
|
67
67
|
*/
|
|
68
68
|
export declare function selectRuntimeHelperStatus<T extends RuntimeHelperSelectable>(statuses: readonly T[], now?: number): T | null;
|
|
69
|
-
//# sourceMappingURL=app-helper-selection.d.ts.map
|
|
@@ -48,4 +48,3 @@ export declare function createAccountManagerReloader<TAccountManager>(deps: {
|
|
|
48
48
|
setAccountManagerPromise: (value: Promise<TAccountManager> | null) => void;
|
|
49
49
|
setReloadInFlight: (value: Promise<TAccountManager> | null) => void;
|
|
50
50
|
}): (authFallback?: OAuthAuthDetails) => Promise<TAccountManager>;
|
|
51
|
-
//# sourceMappingURL=auth-facade.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AccountPolicyStore } from "../account-policy.js";
|
|
2
|
-
import type { AccountStorageV3 } from "../storage.js";
|
|
2
|
+
import type { AccountMetadataV3, AccountStorageV3 } from "../storage.js";
|
|
3
3
|
export declare const AUTOMATIC_CHECK_INTERVAL_MS: number;
|
|
4
4
|
/** First tick after router start, so a short CLI session still gets its check. */
|
|
5
5
|
export declare const AUTOMATIC_CHECK_INITIAL_DELAY_MS = 5000;
|
|
@@ -11,6 +11,10 @@ export interface AutomaticAccountCheckOptions {
|
|
|
11
11
|
now?: () => number;
|
|
12
12
|
signal?: AbortSignal;
|
|
13
13
|
}
|
|
14
|
+
/** Honor the saved selection; a disabled/invalid selection must not fall back to a sibling. */
|
|
15
|
+
export declare function automaticCheckWorkspaceId(account: AccountMetadataV3): string | undefined;
|
|
16
|
+
/** Policy keys can be shared by organization members; attempt limits must never be. */
|
|
17
|
+
export declare function automaticAccountCheckKey(account: AccountMetadataV3): string;
|
|
14
18
|
/** A durable attempt precedes network I/O, so failures and competing routers cannot double-prime. */
|
|
15
19
|
export declare function runAutomaticAccountChecks(options: AutomaticAccountCheckOptions): Promise<void>;
|
|
16
20
|
/**
|
|
@@ -28,4 +32,3 @@ export declare function runAutomaticAccountChecks(options: AutomaticAccountCheck
|
|
|
28
32
|
export declare function startAutomaticAccountChecks(run: (signal: AbortSignal) => Promise<void>): {
|
|
29
33
|
stop(): Promise<void>;
|
|
30
34
|
};
|
|
31
|
-
//# sourceMappingURL=automatic-account-checks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"automatic-account-checks.d.ts","sourceRoot":"","sources":["../../../lib/runtime/automatic-account-checks.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"automatic-account-checks.d.ts","sourceRoot":"","sources":["../../../lib/runtime/automatic-account-checks.ts"],"names":[],"mappings":"AAKA,OAAO,EAAuB,KAAK,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACpF,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAKzE,eAAO,MAAM,2BAA2B,QAAa,CAAC;AACtD,kFAAkF;AAClF,eAAO,MAAM,gCAAgC,OAAO,CAAC;AAKrD,MAAM,WAAW,4BAA4B;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;IACrD,YAAY,EAAE,MAAM,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAChD,KAAK,EAAE,CAAC,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACxF,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,WAAW,CAAC;CACxB;AACD,+FAA+F;AAC/F,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,GAAG,SAAS,CAMxF;AAED,uFAAuF;AACvF,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,CAE3E;AAkCD,qGAAqG;AACrG,wBAAsB,yBAAyB,CAAC,OAAO,EAAE,4BAA4B,GAAG,OAAO,CAAC,IAAI,CAAC,CAyCpG;AACD;;;;;;;;;;;GAWG;AACH,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC;;EAwBtF"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
1
2
|
import { promises as fs } from "node:fs";
|
|
2
3
|
import { z } from "zod";
|
|
4
|
+
import { resolveAccountRecordId } from "../accounts.js";
|
|
5
|
+
import { extractAccountId } from "../auth/token-utils.js";
|
|
3
6
|
import { getAccountPolicyKey } from "../account-policy.js";
|
|
4
7
|
import { withFileTransactionLock } from "../storage/file-lock.js";
|
|
5
8
|
import { withRetry } from "../fs-retry.js";
|
|
@@ -12,6 +15,25 @@ export const AUTOMATIC_CHECK_INITIAL_DELAY_MS = 5000;
|
|
|
12
15
|
const FUTURE_SKEW_MS = 5 * 60000;
|
|
13
16
|
const schema = z.record(z.string().regex(/^sha256:[a-f0-9]{64}$/), z.number().finite().nonnegative());
|
|
14
17
|
const retry = { maxAttempts: 6, backoffMs: 25 };
|
|
18
|
+
/** Honor the saved selection; a disabled/invalid selection must not fall back to a sibling. */
|
|
19
|
+
export function automaticCheckWorkspaceId(account) {
|
|
20
|
+
if (account.workspaces?.length) {
|
|
21
|
+
const selected = account.workspaces[account.currentWorkspaceIndex ?? 0];
|
|
22
|
+
return selected?.enabled === false ? undefined : selected?.id.trim() || undefined;
|
|
23
|
+
}
|
|
24
|
+
return account.accountId?.trim() || extractAccountId(account.accessToken) || undefined;
|
|
25
|
+
}
|
|
26
|
+
/** Policy keys can be shared by organization members; attempt limits must never be. */
|
|
27
|
+
export function automaticAccountCheckKey(account) {
|
|
28
|
+
return workspaceAttemptKey(account, automaticCheckWorkspaceId(account) ?? "");
|
|
29
|
+
}
|
|
30
|
+
/** Build the same key for inactive workspaces while pruning the attempt journal. */
|
|
31
|
+
function workspaceAttemptKey(account, workspaceId) {
|
|
32
|
+
return `sha256:${createHash("sha256").update(JSON.stringify([
|
|
33
|
+
"automatic-check-v2", resolveAccountRecordId(account), workspaceId,
|
|
34
|
+
])).digest("hex")}`;
|
|
35
|
+
}
|
|
36
|
+
/** Reject unreadable or oversized history rather than silently allowing duplicate probes. */
|
|
15
37
|
async function readAttempts(path) {
|
|
16
38
|
try {
|
|
17
39
|
const raw = await withRetry(() => fs.readFile(path, "utf8"), retry);
|
|
@@ -25,6 +47,7 @@ async function readAttempts(path) {
|
|
|
25
47
|
throw error;
|
|
26
48
|
}
|
|
27
49
|
}
|
|
50
|
+
/** Atomically persist attempt timestamps before any billable network request. */
|
|
28
51
|
async function saveAttempts(path, attempts) {
|
|
29
52
|
const temp = tempPathFor(path);
|
|
30
53
|
try {
|
|
@@ -46,7 +69,11 @@ export async function runAutomaticAccountChecks(options) {
|
|
|
46
69
|
if (!storage || signal.aborted)
|
|
47
70
|
return;
|
|
48
71
|
const attempts = await readAttempts(options.path);
|
|
49
|
-
|
|
72
|
+
// Keep every still-saved workspace's throttle, including temporarily disabled selections.
|
|
73
|
+
const keys = new Set(storage.accounts.flatMap(account => [
|
|
74
|
+
automaticAccountCheckKey(account),
|
|
75
|
+
...(account.workspaces ?? []).map(workspace => workspaceAttemptKey(account, workspace.id.trim())),
|
|
76
|
+
]));
|
|
50
77
|
for (const key of Object.keys(attempts))
|
|
51
78
|
if (!keys.has(key))
|
|
52
79
|
delete attempts[key];
|
|
@@ -56,7 +83,7 @@ export async function runAutomaticAccountChecks(options) {
|
|
|
56
83
|
const account = storage.accounts[index];
|
|
57
84
|
if (!account)
|
|
58
85
|
continue;
|
|
59
|
-
const key =
|
|
86
|
+
const key = automaticAccountCheckKey(account), policy = policies.accounts[getAccountPolicyKey(account)], now = options.now?.() ?? Date.now();
|
|
60
87
|
if (!policy?.autoPrime || policy.paused || policy.drained || account.enabled === false || account.authInvalidatedAt || (account.coolingDownUntil ?? 0) > now)
|
|
61
88
|
continue;
|
|
62
89
|
const lastAttempt = attempts[key];
|