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,15 +1,15 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "./schema/config.schema.json",
|
|
3
|
-
"plugin": ["codex-multi-auth"],
|
|
4
|
-
|
|
5
|
-
"provider": {
|
|
6
|
-
"openai": {
|
|
7
|
-
"options": {
|
|
8
|
-
"store": false
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
"model": "openai/gpt-5.3-codex"
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
{
|
|
2
|
+
"$schema": "./schema/config.schema.json",
|
|
3
|
+
"plugin": ["codex-multi-auth"],
|
|
4
|
+
|
|
5
|
+
"provider": {
|
|
6
|
+
"openai": {
|
|
7
|
+
"options": {
|
|
8
|
+
"store": false
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"model": "openai/gpt-5.3-codex"
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
|
package/dist/index.d.ts
CHANGED
|
@@ -21,8 +21,24 @@ export declare function getAccountPolicyKey(account: Pick<AccountMetadataV3, "ac
|
|
|
21
21
|
refreshToken?: string | null;
|
|
22
22
|
}, _index?: number): string;
|
|
23
23
|
export declare function loadAccountPolicyStore(): Promise<AccountPolicyStore>;
|
|
24
|
-
export declare function saveAccountPolicyStore(store: AccountPolicyStore): Promise<void>;
|
|
24
|
+
export declare function saveAccountPolicyStore(store: AccountPolicyStore, baseline?: AccountPolicyStore): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Run a policy-store read→mutate→write inside the write queue (in-process
|
|
27
|
+
* serialization) AND the cross-process lock directory, with mtime CAS retry:
|
|
28
|
+
* every attempt re-reads the freshest on-disk store and re-applies `mutate`
|
|
29
|
+
* before writing — so two commands editing DIFFERENT fields of the same
|
|
30
|
+
* policy (e.g. `weight` vs `tags`) both land, which the whole-record
|
|
31
|
+
* `updatedAt` merge in {@link saveAccountPolicyStore} cannot guarantee: a
|
|
32
|
+
* stale snapshot's record would either clobber a newer record wholesale or be
|
|
33
|
+
* discarded entirely. `mutate` must be re-appliable across retries (apply
|
|
34
|
+
* precomputed work onto the store it is handed, don't capture mutated state).
|
|
35
|
+
* Prefer this over load→upsert→save whenever the caller is mutating rather
|
|
36
|
+
* than importing a foreign store.
|
|
37
|
+
*/
|
|
38
|
+
export declare function updateAccountPolicyStore<T>(mutate: (store: AccountPolicyStore) => {
|
|
39
|
+
result: T;
|
|
40
|
+
dirty: boolean;
|
|
41
|
+
}): Promise<T>;
|
|
25
42
|
export declare function upsertAccountPolicy(store: AccountPolicyStore, accountKey: string, mutate: (policy: AccountPolicy) => void, now?: number): AccountPolicy;
|
|
26
43
|
export declare function normalizeAccountPolicyTag(value: string): string | null;
|
|
27
44
|
export declare function resetAccountPolicyWriteQueueForTests(): void;
|
|
28
|
-
//# sourceMappingURL=account-policy.d.ts.map
|
|
@@ -4,10 +4,9 @@ import { basename, join } from "node:path";
|
|
|
4
4
|
import { logWarn } from "./logger.js";
|
|
5
5
|
import { getCodexMultiAuthDir } from "./runtime-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 ACCOUNT_POLICY_FILE_NAME = "account-policies.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);
|
|
@@ -113,45 +112,103 @@ export async function loadAccountPolicyStore() {
|
|
|
113
112
|
return emptyStore();
|
|
114
113
|
}
|
|
115
114
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
115
|
+
/**
|
|
116
|
+
* Per-key merge of the caller's normalized store over the freshest on-disk
|
|
117
|
+
* store. Policies are keyed by the account's hashed identity (`sha256:`) and
|
|
118
|
+
* carry `updatedAt`; the newer entry wins per key so a save built on a stale
|
|
119
|
+
* snapshot cannot resurrect an older policy over a concurrent process's
|
|
120
|
+
* newer one. Keys the caller does not carry are preserved (upsert-only store
|
|
121
|
+
* — nothing deletes entries), matching the config save's
|
|
122
|
+
* patch-over-fresh-read semantics.
|
|
123
|
+
*
|
|
124
|
+
* When `baseline` (the caller's pre-edit snapshot) is supplied, entries
|
|
125
|
+
* identical to it are untouched carried copies and skipped entirely, so a
|
|
126
|
+
* stale snapshot row can never be re-stamped over a raced write. Entries
|
|
127
|
+
* that differ are deliberate writes and must not lose purely on timestamp:
|
|
128
|
+
* the upsert-time floor stamps against the caller's snapshot, but a
|
|
129
|
+
* concurrent writer can land a still-newer entry before this merge runs, so
|
|
130
|
+
* the merge re-stamps against the freshest on-disk entry instead of
|
|
131
|
+
* silently dropping the edit. Without a baseline every supplied entry is a
|
|
132
|
+
* plain `updatedAt >=` upsert.
|
|
133
|
+
*/
|
|
134
|
+
function mergeAccountPolicies(current, incoming, baseline) {
|
|
135
|
+
const merged = {
|
|
136
|
+
version: 1,
|
|
137
|
+
accounts: { ...current.accounts },
|
|
138
|
+
};
|
|
139
|
+
const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
140
|
+
for (const [key, policy] of Object.entries(incoming.accounts)) {
|
|
141
|
+
const existing = merged.accounts[key];
|
|
142
|
+
if (!baseline) {
|
|
143
|
+
if (!existing || policy.updatedAt >= existing.updatedAt) {
|
|
144
|
+
merged.accounts[key] = policy;
|
|
139
145
|
}
|
|
146
|
+
continue;
|
|
140
147
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
148
|
+
if (same(policy, baseline.accounts[key]))
|
|
149
|
+
continue;
|
|
150
|
+
policy.updatedAt = stampUpdatedAt(policy.updatedAt, existing?.updatedAt);
|
|
151
|
+
merged.accounts[key] = policy;
|
|
152
|
+
}
|
|
153
|
+
return merged;
|
|
154
|
+
}
|
|
155
|
+
export async function saveAccountPolicyStore(store, baseline) {
|
|
156
|
+
const path = getAccountPolicyPath();
|
|
157
|
+
const incoming = normalizeStore(store);
|
|
158
|
+
// Normalize at invocation like `incoming`: later caller-side mutation of
|
|
159
|
+
// `baseline` must not shift which entries the merge counts as deliberate.
|
|
160
|
+
const prior = baseline ? normalizeStore(baseline) : undefined;
|
|
161
|
+
// Per-path promise queue serializes writers inside THIS process; the
|
|
162
|
+
// lock directory closes the same window against OTHER processes. Inside the lock
|
|
163
|
+
// every attempt re-stats (CAS), re-reads the freshest on-disk store, and
|
|
164
|
+
// merges this call's entries over it — so a save that raced a concurrent
|
|
165
|
+
// write reloads-and-retries rather than blindly overwriting it.
|
|
166
|
+
await withJsonStoreWriteQueue(path, async () => {
|
|
167
|
+
await withJsonStoreFileLock(path, async () => {
|
|
168
|
+
await withJsonStoreCasRetry(async () => {
|
|
169
|
+
const expectedMtimeMs = await getJsonStoreFileMtimeMs(path);
|
|
170
|
+
const current = await loadAccountPolicyStore();
|
|
171
|
+
const merged = mergeAccountPolicies(current, incoming, prior);
|
|
172
|
+
await fs.mkdir(getCodexMultiAuthDir(), {
|
|
173
|
+
recursive: true,
|
|
174
|
+
mode: 0o700,
|
|
175
|
+
});
|
|
176
|
+
await writeJsonStoreFileAtomicWithRetry(path, merged, {
|
|
177
|
+
expectedMtimeMs,
|
|
178
|
+
mode: 0o600,
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Run a policy-store read→mutate→write inside the write queue (in-process
|
|
186
|
+
* serialization) AND the cross-process lock directory, with mtime CAS retry:
|
|
187
|
+
* every attempt re-reads the freshest on-disk store and re-applies `mutate`
|
|
188
|
+
* before writing — so two commands editing DIFFERENT fields of the same
|
|
189
|
+
* policy (e.g. `weight` vs `tags`) both land, which the whole-record
|
|
190
|
+
* `updatedAt` merge in {@link saveAccountPolicyStore} cannot guarantee: a
|
|
191
|
+
* stale snapshot's record would either clobber a newer record wholesale or be
|
|
192
|
+
* discarded entirely. `mutate` must be re-appliable across retries (apply
|
|
193
|
+
* precomputed work onto the store it is handed, don't capture mutated state).
|
|
194
|
+
* Prefer this over load→upsert→save whenever the caller is mutating rather
|
|
195
|
+
* than importing a foreign store.
|
|
196
|
+
*/
|
|
197
|
+
export async function updateAccountPolicyStore(mutate) {
|
|
198
|
+
const path = getAccountPolicyPath();
|
|
199
|
+
return withJsonStoreWriteQueue(path, () => withJsonStoreFileLock(path, () => withJsonStoreCasRetry(async () => {
|
|
200
|
+
const expectedMtimeMs = await getJsonStoreFileMtimeMs(path);
|
|
201
|
+
const store = await loadAccountPolicyStore();
|
|
202
|
+
const { result, dirty } = mutate(store);
|
|
203
|
+
if (dirty) {
|
|
204
|
+
await fs.mkdir(getCodexMultiAuthDir(), {
|
|
205
|
+
recursive: true,
|
|
206
|
+
mode: 0o700,
|
|
207
|
+
});
|
|
208
|
+
await writeJsonStoreFileAtomicWithRetry(path, normalizeStore(store), { expectedMtimeMs, mode: 0o600 });
|
|
150
209
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
writeQueue = queued.then(() => undefined, () => undefined);
|
|
154
|
-
await queued;
|
|
210
|
+
return result;
|
|
211
|
+
})));
|
|
155
212
|
}
|
|
156
213
|
/** Tiers are integers 0-9; anything else (including legacy absence) is tier 1. */
|
|
157
214
|
function normalizePriority(value) {
|
|
@@ -168,7 +225,7 @@ export function upsertAccountPolicy(store, accountKey, mutate, now = Date.now())
|
|
|
168
225
|
next.weight = normalizeWeight(next.weight);
|
|
169
226
|
next.priority = normalizePriority(next.priority);
|
|
170
227
|
next.autoPrime = next.autoPrime === true;
|
|
171
|
-
next.updatedAt = now;
|
|
228
|
+
next.updatedAt = stampUpdatedAt(now, store.accounts[accountKey]?.updatedAt);
|
|
172
229
|
store.accounts[accountKey] = next;
|
|
173
230
|
return next;
|
|
174
231
|
}
|
|
@@ -176,5 +233,5 @@ export function normalizeAccountPolicyTag(value) {
|
|
|
176
233
|
return normalizeTag(value);
|
|
177
234
|
}
|
|
178
235
|
export function resetAccountPolicyWriteQueueForTests() {
|
|
179
|
-
|
|
236
|
+
resetJsonStoreWriteQueuesForTests(getAccountPolicyPath());
|
|
180
237
|
}
|
|
@@ -27,4 +27,3 @@ export declare function clearAllRateLimits(entity: RateLimitedEntity): void;
|
|
|
27
27
|
export declare function isRateLimitedForQuotaKey(entity: RateLimitedEntity, key: QuotaKey): boolean;
|
|
28
28
|
export declare function isRateLimitedForFamily(entity: RateLimitedEntity, family: ModelFamily, model?: string | null): boolean;
|
|
29
29
|
export declare function formatWaitTime(ms: number): string;
|
|
30
|
-
//# sourceMappingURL=rate-limits.d.ts.map
|
package/dist/lib/accounts.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Auth } from "@codex-ai/sdk";
|
|
2
|
+
export { resolveAccountRecordId } from "./storage/record-identity.js";
|
|
2
3
|
import { type AccountStorageV3, type CooldownReason, type RateLimitStateV3 } from "./storage.js";
|
|
3
4
|
import type { AccountIdSource, OAuthAuthDetails } from "./types.js";
|
|
4
5
|
import type { CodexCliMirror, Workspace } from "./storage/public-types.js";
|
|
@@ -9,13 +10,6 @@ export { extractAccountId, extractAccountEmail, getAccountIdCandidates, selectBe
|
|
|
9
10
|
export { parseRateLimitReason, getQuotaKey, clampNonNegativeInt, clearExpiredRateLimits, clearAllRateLimits, isRateLimitedForQuotaKey, isRateLimitedForFamily, formatWaitTime, type QuotaKey, type BaseQuotaKey, type RateLimitReason, type RateLimitState, type RateLimitedEntity, } from "./accounts/rate-limits.js";
|
|
10
11
|
export { lookupCodexCliTokensByEmail, isCodexCliSyncEnabled, type CodexCliTokenCacheEntry, } from "./codex-cli/state.js";
|
|
11
12
|
import { type RateLimitReason } from "./accounts/rate-limits.js";
|
|
12
|
-
export declare function resolveAccountRecordId(account: {
|
|
13
|
-
recordId?: string;
|
|
14
|
-
accountId?: string;
|
|
15
|
-
email?: string;
|
|
16
|
-
refreshToken: string;
|
|
17
|
-
addedAt: number;
|
|
18
|
-
}): string;
|
|
19
13
|
export declare function getRuntimeTrackerKey(account: ManagedAccount): string | number;
|
|
20
14
|
type AccountIdentityCandidate = Pick<ManagedAccount, "accountId" | "email" | "refreshToken"> & {
|
|
21
15
|
index?: number;
|
|
@@ -391,4 +385,3 @@ export declare function formatCooldown(account: {
|
|
|
391
385
|
coolingDownUntil?: number;
|
|
392
386
|
cooldownReason?: string;
|
|
393
387
|
}, now?: number): string | null;
|
|
394
|
-
//# sourceMappingURL=accounts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../lib/accounts.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../lib/accounts.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAE1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AAItE,OAAO,EAKN,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EAKrB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3E,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAClF,OAAO,EAMN,KAAK,sBAAsB,EAC3B,MAAM,eAAe,CAAC;AACvB,OAAO,EAEN,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,MAAM,oBAAoB,CAAC;AAqB5B,OAAO,EACN,gBAAgB,EAChB,mBAAmB,EACnB,sBAAsB,EACtB,0BAA0B,EAC1B,6BAA6B,EAC7B,8BAA8B,EAC9B,uBAAuB,EACvB,aAAa,EACb,KAAK,kBAAkB,GACvB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACN,oBAAoB,EACpB,WAAW,EACX,mBAAmB,EACnB,sBAAsB,EACtB,kBAAkB,EAClB,wBAAwB,EACxB,sBAAsB,EACtB,cAAc,EACd,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAA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EAAE,cAAc,GAAG,SAAS,GAAG,IAAI;IAoBhE;;;OAGG;IACH,oBAAoB,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO;IAOtD,iBAAiB,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM;IAIlD,wBAAwB,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM;CAIzD;AAmBD,wBAAgB,kBAAkB,CACjC,OAAO,EACJ;IACA,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC;IACzB,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAC9B,GACD,SAAS,EACZ,KAAK,EAAE,MAAM,GACX,MAAM,CA4BR;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CACnC,OAAO,EACJ;IAAE,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC;IAAC,qBAAqB,CAAC,EAAE,MAAM,CAAA;CAAE,GAC5D,SAAS,EACZ,MAAM,SAAQ,EACd,cAAc,SAAW,GACvB,MAAM,EAAE,CAgBV;AAED,wBAAgB,cAAc,CAC7B,OAAO,EAAE;IAAE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,CAAC,EAAE,MAAM,CAAA;CAAE,EAC/D,GAAG,SAAU,GACX,MAAM,GAAG,IAAI,CAMf"}
|
package/dist/lib/accounts.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { mergeAccountCooldown, mergeAccountSnapshot, mergeAccountRuntimeObservations } from "./storage/snapshot-merge.js";
|
|
2
|
-
import {
|
|
2
|
+
import { deriveAccountRecordId, resolveAccountRecordId } from "./storage/record-identity.js";
|
|
3
|
+
export { resolveAccountRecordId } from "./storage/record-identity.js";
|
|
3
4
|
import { existsSync } from "node:fs";
|
|
4
5
|
import { saveAccountsWithRetry } from "./storage/save-retry.js";
|
|
5
6
|
import { createLogger } from "./logger.js";
|
|
@@ -30,19 +31,6 @@ function getAccountCircuitKey(account) {
|
|
|
30
31
|
}
|
|
31
32
|
return account.circuitKeyId;
|
|
32
33
|
}
|
|
33
|
-
function deriveAccountRecordId(account) {
|
|
34
|
-
const seed = [
|
|
35
|
-
account.addedAt,
|
|
36
|
-
account.accountId?.trim() ?? "",
|
|
37
|
-
account.email?.trim().toLowerCase() ?? "",
|
|
38
|
-
account.refreshToken.trim(),
|
|
39
|
-
].join("\u0000");
|
|
40
|
-
return `record:${createHash("sha256").update(seed).digest("hex")}`;
|
|
41
|
-
}
|
|
42
|
-
export function resolveAccountRecordId(account) {
|
|
43
|
-
const stored = account.recordId?.trim();
|
|
44
|
-
return stored || deriveAccountRecordId(account);
|
|
45
|
-
}
|
|
46
34
|
export function getRuntimeTrackerKey(account) {
|
|
47
35
|
if (account._runtimeTrackerKey !== undefined) {
|
|
48
36
|
return account._runtimeTrackerKey;
|
|
@@ -934,16 +922,15 @@ export class AccountManager {
|
|
|
934
922
|
if (shouldConsumeToken && !tokenTracker.tryConsume(trackerKey, quotaKey)) {
|
|
935
923
|
return { ok: false, reason: "token-exhausted" };
|
|
936
924
|
}
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
}
|
|
941
|
-
catch {
|
|
925
|
+
// Non-throwing probe keeps circuit-open storms off the exception path.
|
|
926
|
+
const admission = getCircuitBreaker(getAccountCircuitKey(account)).tryCanExecute();
|
|
927
|
+
if (!admission.ok) {
|
|
942
928
|
if (shouldConsumeToken) {
|
|
943
929
|
tokenTracker.refundToken(trackerKey, quotaKey);
|
|
944
930
|
}
|
|
945
931
|
return { ok: false, reason: "circuit-open" };
|
|
946
932
|
}
|
|
933
|
+
return { ok: true };
|
|
947
934
|
}
|
|
948
935
|
/**
|
|
949
936
|
* Refund a token consumed within the refund window (30 seconds).
|
|
@@ -1503,6 +1490,7 @@ export class AccountManager {
|
|
|
1503
1490
|
try {
|
|
1504
1491
|
await runWithStoragePathState(this.storagePathState, () => recordPendingAuth(getStoragePath(), {
|
|
1505
1492
|
priorRefreshToken,
|
|
1493
|
+
recordId: live.recordId,
|
|
1506
1494
|
refreshToken: auth.refresh,
|
|
1507
1495
|
accessToken: auth.access,
|
|
1508
1496
|
expiresAt: auth.expires,
|
|
@@ -21,4 +21,3 @@ export declare function loadApiRoutes(path?: string): Promise<ApiRouteCredential
|
|
|
21
21
|
export declare function saveApiRoutes(routes: ApiRouteCredential[], path?: string, expected?: ApiRouteCredential[]): Promise<void>;
|
|
22
22
|
export declare function updateApiModelDiscovery(route: ApiRouteCredential, models: string[], path?: string): Promise<ApiRouteCredential>;
|
|
23
23
|
export {};
|
|
24
|
-
//# sourceMappingURL=api-route-store.d.ts.map
|
package/dist/lib/audit.d.ts
CHANGED
|
@@ -33,4 +33,3 @@ export declare function getAuditConfig(): AuditConfig;
|
|
|
33
33
|
export declare function auditLog(action: AuditAction, actor: string, resource: string, outcome: AuditOutcome, metadata?: Record<string, unknown>): void;
|
|
34
34
|
export declare function getAuditLogPath(): string;
|
|
35
35
|
export declare function listAuditLogFiles(): string[];
|
|
36
|
-
//# sourceMappingURL=audit.d.ts.map
|
package/dist/lib/audit.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { writeFileSync, mkdirSync, existsSync, statSync, renameSync, readdirSync, unlinkSync } from "node:fs";
|
|
1
|
+
import { writeFileSync, mkdirSync, existsSync, statSync, chmodSync, renameSync, readdirSync, unlinkSync } from "node:fs";
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { getCorrelationId, maskEmail } from "./logger.js";
|
|
4
4
|
import { getCodexLogDir } from "./runtime-paths.js";
|
|
@@ -49,11 +49,32 @@ function ensureLogDir() {
|
|
|
49
49
|
function getLogFilePath() {
|
|
50
50
|
return join(auditConfig.logDir, "audit.log");
|
|
51
51
|
}
|
|
52
|
+
// POSIX-only permission re-assertion. The append-mode `mode` option applies
|
|
53
|
+
// only when the file is created, so an audit log that already exists with
|
|
54
|
+
// permissive bits (a shared/custom logDir, or one written before this
|
|
55
|
+
// hardening) would stay readable by other local users, and rotation would
|
|
56
|
+
// carry those bits onto the backups. On Windows chmod cannot establish the
|
|
57
|
+
// equivalent ACL — the logDir's ACLs govern access there — so this is skipped
|
|
58
|
+
// on win32 rather than half-applied.
|
|
59
|
+
function restrictLogPermissions(path, currentMode) {
|
|
60
|
+
if (process.platform === "win32")
|
|
61
|
+
return;
|
|
62
|
+
try {
|
|
63
|
+
const mode = currentMode ?? statSync(path).mode;
|
|
64
|
+
if ((mode & 0o777) !== 0o600) {
|
|
65
|
+
chmodSync(path, 0o600);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
// Best-effort hardening: audit logging must never break the application.
|
|
70
|
+
}
|
|
71
|
+
}
|
|
52
72
|
function rotateLogsIfNeeded() {
|
|
53
73
|
const logPath = getLogFilePath();
|
|
54
74
|
if (!existsSync(logPath))
|
|
55
75
|
return;
|
|
56
76
|
const stats = statSync(logPath);
|
|
77
|
+
restrictLogPermissions(logPath, stats.mode);
|
|
57
78
|
if (stats.size < auditConfig.maxFileSizeBytes)
|
|
58
79
|
return;
|
|
59
80
|
for (let i = auditConfig.maxFiles - 1; i >= 1; i--) {
|
|
@@ -64,26 +85,34 @@ function rotateLogsIfNeeded() {
|
|
|
64
85
|
}
|
|
65
86
|
if (existsSync(newer)) {
|
|
66
87
|
renameSync(newer, older);
|
|
88
|
+
restrictLogPermissions(older);
|
|
67
89
|
}
|
|
68
90
|
}
|
|
69
91
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
92
|
+
// Same email shape logger.ts scrubs, applied as a SUBSTRING masker. Feeding
|
|
93
|
+
// the whole value to maskEmail would treat any "@" as an email separator and
|
|
94
|
+
// mangle non-email identifiers that legitimately carry one — "@scope/package",
|
|
95
|
+
// "@user" handles, URLs with embedded credentials — leaving the audit entry
|
|
96
|
+
// unable to identify the resource. Only real email-shaped spans are masked.
|
|
97
|
+
const EMAIL_SUBSTRING_PATTERN = /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g;
|
|
98
|
+
function maskAuditField(value) {
|
|
99
|
+
return value.replace(EMAIL_SUBSTRING_PATTERN, maskEmail);
|
|
75
100
|
}
|
|
101
|
+
// Substring markers matched against the lowercased metadata key. Covers
|
|
102
|
+
// token/secret/password plus credential-carrying spellings: "authorization"
|
|
103
|
+
// (raw headers), "api_key"/"api-key"/"apiKey" (api[-_]?key), and "credential".
|
|
104
|
+
const SENSITIVE_KEY_PATTERN = /token|secret|password|authorization|api[-_]?key|credential/;
|
|
76
105
|
function sanitizeMetadata(metadata) {
|
|
77
106
|
if (!metadata)
|
|
78
107
|
return undefined;
|
|
79
108
|
const sanitized = {};
|
|
80
109
|
for (const [key, value] of Object.entries(metadata)) {
|
|
81
110
|
const lowerKey = key.toLowerCase();
|
|
82
|
-
if (
|
|
111
|
+
if (SENSITIVE_KEY_PATTERN.test(lowerKey)) {
|
|
83
112
|
sanitized[key] = "***REDACTED***";
|
|
84
113
|
}
|
|
85
|
-
else if (typeof value === "string"
|
|
86
|
-
sanitized[key] =
|
|
114
|
+
else if (typeof value === "string") {
|
|
115
|
+
sanitized[key] = maskAuditField(value);
|
|
87
116
|
}
|
|
88
117
|
else if (typeof value === "object" && value !== null) {
|
|
89
118
|
sanitized[key] = sanitizeMetadata(value);
|
|
@@ -104,14 +133,16 @@ export function auditLog(action, actor, resource, outcome, metadata) {
|
|
|
104
133
|
timestamp: new Date().toISOString(),
|
|
105
134
|
correlationId: getCorrelationId(),
|
|
106
135
|
action,
|
|
107
|
-
actor:
|
|
108
|
-
resource,
|
|
136
|
+
actor: maskAuditField(actor),
|
|
137
|
+
resource: maskAuditField(resource),
|
|
109
138
|
outcome,
|
|
110
139
|
metadata: sanitizeMetadata(metadata),
|
|
111
140
|
};
|
|
112
141
|
const logPath = getLogFilePath();
|
|
113
142
|
const line = JSON.stringify(entry) + "\n";
|
|
114
|
-
|
|
143
|
+
// mode applies only at creation; rotateLogsIfNeeded already re-asserted
|
|
144
|
+
// 0o600 on an existing file (and on every backup it renamed).
|
|
145
|
+
writeFileSync(logPath, line, { flag: "a", mode: 0o600 });
|
|
115
146
|
}
|
|
116
147
|
catch {
|
|
117
148
|
// Audit logging should never break the application
|
|
@@ -112,4 +112,3 @@ export interface StoredAccountIdentity {
|
|
|
112
112
|
* "manual" is an explicit `login --org` binding this must not override.
|
|
113
113
|
*/
|
|
114
114
|
export declare function reboundUnauthorizedAccountIdentity(account: StoredAccountIdentity, accessToken: string, options?: FetchAuthorizedAccountsOptions): Promise<ConstrainedSelection | null>;
|
|
115
|
-
//# sourceMappingURL=account-access.d.ts.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CODEX_BASE_URL } from "../constants.js";
|
|
2
|
+
import { combineSignals } from "../utils.js";
|
|
2
3
|
const ACCOUNTS_CHECK_PATH = "/wham/accounts/check";
|
|
3
4
|
const ACCOUNTS_CHECK_TIMEOUT_MS = 10_000;
|
|
4
5
|
function readString(value) {
|
|
@@ -50,8 +51,11 @@ export async function fetchAuthorizedAccounts(accessToken, options = {}) {
|
|
|
50
51
|
return null;
|
|
51
52
|
const doFetch = options.fetch ?? globalThis.fetch;
|
|
52
53
|
const timeout = AbortSignal.timeout(ACCOUNTS_CHECK_TIMEOUT_MS);
|
|
54
|
+
// combineSignals wraps AbortSignal.any (available since Node 18.17, the
|
|
55
|
+
// engines floor) with null-tolerance; the native composite also detaches
|
|
56
|
+
// from a long-lived caller signal once this request completes.
|
|
53
57
|
const signal = options.signal
|
|
54
|
-
?
|
|
58
|
+
? combineSignals(options.signal, timeout)
|
|
55
59
|
: timeout;
|
|
56
60
|
try {
|
|
57
61
|
const response = await doFetch(`${CODEX_BASE_URL}${ACCOUNTS_CHECK_PATH}`, {
|
package/dist/lib/auth/auth.d.ts
CHANGED
|
@@ -40,8 +40,10 @@ export declare const AUTH_REDIRECT: Readonly<{
|
|
|
40
40
|
*/
|
|
41
41
|
export declare function sanitizeOAuthResponseBodyForLog(rawBody: string): string;
|
|
42
42
|
/**
|
|
43
|
-
* Redacts sensitive OAuth
|
|
44
|
-
*
|
|
43
|
+
* Redacts sensitive OAuth parameters for safe logging: query keys match
|
|
44
|
+
* case-insensitively, fragment and nested-URL params are covered, userinfo is
|
|
45
|
+
* masked, and unparseable input collapses to `<unparseable-url>` so the raw
|
|
46
|
+
* string can never reach a log verbatim.
|
|
45
47
|
*/
|
|
46
48
|
export declare function redactOAuthUrlForLog(rawUrl: string): string;
|
|
47
49
|
/**
|
|
@@ -92,4 +94,3 @@ export interface AuthorizationFlowOptions {
|
|
|
92
94
|
*/
|
|
93
95
|
export declare function createAuthorizationFlow(options?: AuthorizationFlowOptions): Promise<AuthorizationFlow>;
|
|
94
96
|
export {};
|
|
95
|
-
//# sourceMappingURL=auth.d.ts.map
|