codex-multi-auth 2.3.0-beta.0 → 2.3.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.codex-plugin/plugin.json +1 -1
- package/README.md +4 -3
- package/config/schema/config.schema.json +268 -21
- package/dist/index.js +0 -1
- package/dist/lib/account-policy.js +0 -1
- package/dist/lib/accounts/rate-limits.js +0 -1
- package/dist/lib/accounts.d.ts +3 -8
- package/dist/lib/accounts.d.ts.map +1 -1
- package/dist/lib/accounts.js +2 -3
- package/dist/lib/audit.js +0 -1
- package/dist/lib/auth/auth.js +0 -1
- package/dist/lib/auth/browser.js +0 -1
- package/dist/lib/auth/device-auth.js +0 -1
- package/dist/lib/auth/index.js +0 -1
- package/dist/lib/auth/org-override.js +0 -1
- package/dist/lib/auth/server.js +0 -1
- package/dist/lib/auth/token-utils.js +0 -1
- package/dist/lib/auth-rate-limit.js +0 -1
- package/dist/lib/budget-guard.js +0 -1
- package/dist/lib/capability-policy.js +0 -1
- package/dist/lib/circuit-breaker.js +0 -1
- package/dist/lib/cli.js +1 -2
- package/dist/lib/codex-cli/index.js +0 -1
- package/dist/lib/codex-cli/observability.js +0 -1
- package/dist/lib/codex-cli/state.js +0 -1
- package/dist/lib/codex-cli/sync.d.ts +2 -2
- package/dist/lib/codex-cli/sync.d.ts.map +1 -1
- package/dist/lib/codex-cli/sync.js +1 -2
- package/dist/lib/codex-cli/writer.js +0 -1
- package/dist/lib/codex-manager/account-credentials.d.ts +13 -0
- package/dist/lib/codex-manager/account-credentials.d.ts.map +1 -0
- package/dist/lib/codex-manager/account-credentials.js +55 -0
- package/dist/lib/codex-manager/account-manager-commands.js +0 -1
- package/dist/lib/codex-manager/account-pool-write.d.ts +95 -0
- package/dist/lib/codex-manager/account-pool-write.d.ts.map +1 -0
- package/dist/lib/codex-manager/account-pool-write.js +165 -0
- package/dist/lib/codex-manager/account-pool-write.js.map +1 -0
- package/dist/lib/codex-manager/backend-category-entry.js +0 -1
- package/dist/lib/codex-manager/backend-category-helpers.js +0 -1
- package/dist/lib/codex-manager/backend-category-prompt.js +0 -1
- package/dist/lib/codex-manager/backend-settings-controller.js +0 -1
- package/dist/lib/codex-manager/backend-settings-entry.js +0 -1
- package/dist/lib/codex-manager/backend-settings-helpers.js +0 -1
- package/dist/lib/codex-manager/backend-settings-prompt.js +0 -1
- package/dist/lib/codex-manager/backend-settings-schema.js +0 -1
- package/dist/lib/codex-manager/behavior-settings-panel.d.ts +1 -1
- package/dist/lib/codex-manager/behavior-settings-panel.d.ts.map +1 -1
- package/dist/lib/codex-manager/behavior-settings-panel.js +0 -1
- package/dist/lib/codex-manager/commands/account.js +0 -1
- package/dist/lib/codex-manager/commands/best.d.ts +8 -0
- package/dist/lib/codex-manager/commands/best.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/best.js +64 -1
- package/dist/lib/codex-manager/commands/bridge.js +0 -1
- package/dist/lib/codex-manager/commands/budget.js +0 -1
- package/dist/lib/codex-manager/commands/check.js +0 -1
- package/dist/lib/codex-manager/commands/config-explain.js +0 -1
- package/dist/lib/codex-manager/commands/debug-bundle.js +0 -1
- package/dist/lib/codex-manager/commands/forecast.js +0 -1
- package/dist/lib/codex-manager/commands/init-config.js +0 -1
- package/dist/lib/codex-manager/commands/integrations.js +0 -1
- package/dist/lib/codex-manager/commands/models.js +0 -1
- package/dist/lib/codex-manager/commands/monitor.js +0 -1
- package/dist/lib/codex-manager/commands/report.js +0 -1
- package/dist/lib/codex-manager/commands/rotation.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/rotation.js +1 -4
- package/dist/lib/codex-manager/commands/status.js +0 -1
- package/dist/lib/codex-manager/commands/switch.js +0 -1
- package/dist/lib/codex-manager/commands/uninstall.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/uninstall.js +2 -33
- package/dist/lib/codex-manager/commands/unpin.js +0 -1
- package/dist/lib/codex-manager/commands/usage.js +0 -1
- package/dist/lib/codex-manager/commands/verify.js +0 -1
- package/dist/lib/codex-manager/commands/why-selected.js +0 -1
- package/dist/lib/codex-manager/commands/workspace.js +0 -1
- package/dist/lib/codex-manager/dashboard-display-panel.d.ts +1 -1
- package/dist/lib/codex-manager/dashboard-display-panel.d.ts.map +1 -1
- package/dist/lib/codex-manager/dashboard-display-panel.js +0 -1
- package/dist/lib/codex-manager/dashboard-formatters.js +0 -1
- package/dist/lib/codex-manager/dashboard-settings-controller.js +0 -1
- package/dist/lib/codex-manager/dashboard-settings-data.js +0 -1
- package/dist/lib/codex-manager/dashboard-settings-entry.js +0 -1
- package/dist/lib/codex-manager/experimental-settings-entry.js +0 -1
- package/dist/lib/codex-manager/experimental-settings-prompt.js +0 -1
- package/dist/lib/codex-manager/experimental-settings-schema.js +1 -2
- package/dist/lib/codex-manager/experimental-sync-target-entry.js +0 -1
- package/dist/lib/codex-manager/experimental-sync-target.js +0 -1
- package/dist/lib/codex-manager/forecast-report-commands.js +0 -1
- package/dist/lib/codex-manager/forecast-report-shared.d.ts +2 -2
- package/dist/lib/codex-manager/forecast-report-shared.d.ts.map +1 -1
- package/dist/lib/codex-manager/forecast-report-shared.js +5 -21
- package/dist/lib/codex-manager/formatters/account-formatters.d.ts +11 -0
- package/dist/lib/codex-manager/formatters/account-formatters.d.ts.map +1 -0
- package/dist/lib/codex-manager/formatters/account-formatters.js +79 -0
- package/dist/lib/codex-manager/formatters/index.d.ts +5 -0
- package/dist/lib/codex-manager/formatters/index.d.ts.map +1 -0
- package/dist/lib/codex-manager/formatters/index.js +4 -0
- package/dist/lib/codex-manager/formatters/model-formatters.d.ts +12 -0
- package/dist/lib/codex-manager/formatters/model-formatters.d.ts.map +1 -0
- package/dist/lib/codex-manager/formatters/model-formatters.js +23 -0
- package/dist/lib/codex-manager/formatters/quota-formatters.d.ts +11 -0
- package/dist/lib/codex-manager/formatters/quota-formatters.d.ts.map +1 -0
- package/dist/lib/codex-manager/formatters/quota-formatters.js +104 -0
- package/dist/lib/codex-manager/formatters/text-style.d.ts +14 -0
- package/dist/lib/codex-manager/formatters/text-style.d.ts.map +1 -0
- package/dist/lib/codex-manager/formatters/text-style.js +111 -0
- package/dist/lib/codex-manager/health-check.d.ts +14 -0
- package/dist/lib/codex-manager/health-check.d.ts.map +1 -0
- package/dist/lib/codex-manager/health-check.js +278 -0
- package/dist/lib/codex-manager/help.js +0 -1
- package/dist/lib/codex-manager/login-action-panel.d.ts +4 -0
- package/dist/lib/codex-manager/login-action-panel.d.ts.map +1 -0
- package/dist/lib/codex-manager/login-action-panel.js +238 -0
- package/dist/lib/codex-manager/login-flow.d.ts +17 -0
- package/dist/lib/codex-manager/login-flow.d.ts.map +1 -0
- package/dist/lib/codex-manager/login-flow.js +387 -0
- package/dist/lib/codex-manager/login-menu-actions.d.ts +20 -0
- package/dist/lib/codex-manager/login-menu-actions.d.ts.map +1 -0
- package/dist/lib/codex-manager/login-menu-actions.js +303 -0
- package/dist/lib/codex-manager/login-menu-data.d.ts +19 -0
- package/dist/lib/codex-manager/login-menu-data.d.ts.map +1 -0
- package/dist/lib/codex-manager/login-menu-data.js +378 -0
- package/dist/lib/codex-manager/login-oauth.d.ts +55 -0
- package/dist/lib/codex-manager/login-oauth.d.ts.map +1 -0
- package/dist/lib/codex-manager/login-oauth.js +345 -0
- package/dist/lib/codex-manager/manual-callback.d.ts +33 -0
- package/dist/lib/codex-manager/manual-callback.d.ts.map +1 -0
- package/dist/lib/codex-manager/manual-callback.js +30 -0
- package/dist/lib/codex-manager/manual-callback.js.map +1 -0
- package/dist/lib/codex-manager/persist-selected-account.d.ts +24 -0
- package/dist/lib/codex-manager/persist-selected-account.d.ts.map +1 -0
- package/dist/lib/codex-manager/persist-selected-account.js +107 -0
- package/dist/lib/codex-manager/quota-cache-helpers.d.ts +18 -0
- package/dist/lib/codex-manager/quota-cache-helpers.d.ts.map +1 -0
- package/dist/lib/codex-manager/quota-cache-helpers.js +112 -0
- package/dist/lib/codex-manager/rate-limit-markers.js +0 -1
- package/dist/lib/codex-manager/repair-commands.js +0 -1
- package/dist/lib/codex-manager/settings-hub/backend.js +1 -2
- package/dist/lib/codex-manager/settings-hub/dashboard.js +1 -2
- package/dist/lib/codex-manager/settings-hub/experimental.js +1 -2
- package/dist/lib/codex-manager/settings-hub/index.js +1 -2
- package/dist/lib/codex-manager/settings-hub/shared.js +0 -1
- package/dist/lib/codex-manager/settings-hub-entry.js +0 -1
- package/dist/lib/codex-manager/settings-hub-menu.js +0 -1
- package/dist/lib/codex-manager/settings-hub-prompt.js +0 -1
- package/dist/lib/codex-manager/settings-hub.js +0 -1
- package/dist/lib/codex-manager/settings-panels.js +0 -1
- package/dist/lib/codex-manager/settings-persist-utils.js +0 -1
- package/dist/lib/codex-manager/settings-preview.js +0 -1
- package/dist/lib/codex-manager/settings-write-queue.js +0 -1
- package/dist/lib/codex-manager/statusline-order.js +0 -1
- package/dist/lib/codex-manager/statusline-settings-panel.d.ts +1 -1
- package/dist/lib/codex-manager/statusline-settings-panel.d.ts.map +1 -1
- package/dist/lib/codex-manager/statusline-settings-panel.js +0 -1
- package/dist/lib/codex-manager/theme-settings-panel.d.ts +1 -1
- package/dist/lib/codex-manager/theme-settings-panel.d.ts.map +1 -1
- package/dist/lib/codex-manager/theme-settings-panel.js +0 -1
- package/dist/lib/codex-manager/unified-settings-controller.js +0 -1
- package/dist/lib/codex-manager/unified-settings-entry.js +0 -1
- package/dist/lib/codex-manager.d.ts +2 -4
- package/dist/lib/codex-manager.d.ts.map +1 -1
- package/dist/lib/codex-manager.js +219 -2578
- package/dist/lib/codex-manager.js.map +1 -1
- package/dist/lib/config-schema.d.ts +32 -0
- package/dist/lib/config-schema.d.ts.map +1 -0
- package/dist/lib/config-schema.js +96 -0
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +60 -104
- package/dist/lib/constants.js +0 -1
- package/dist/lib/context-overflow.js +0 -1
- package/dist/lib/dashboard-settings.js +0 -1
- package/dist/lib/entitlement-cache.js +0 -1
- package/dist/lib/env-parsing.js +0 -1
- package/dist/lib/errors.js +0 -1
- package/dist/lib/forecast.js +0 -1
- package/dist/lib/fs-retry.d.ts +46 -0
- package/dist/lib/fs-retry.d.ts.map +1 -1
- package/dist/lib/fs-retry.js +74 -6
- package/dist/lib/health.js +0 -1
- package/dist/lib/index.js +0 -1
- package/dist/lib/integration-generators.js +0 -1
- package/dist/lib/live-account-sync.js +0 -1
- package/dist/lib/local-bridge.js +0 -1
- package/dist/lib/local-client-tokens.js +0 -1
- package/dist/lib/logger.js +0 -1
- package/dist/lib/model-capability-matrix.js +0 -1
- package/dist/lib/named-backup-export.js +0 -1
- package/dist/lib/oc-chatgpt-import-adapter.js +0 -1
- package/dist/lib/oc-chatgpt-orchestrator.js +0 -1
- package/dist/lib/oc-chatgpt-target-detection.js +0 -1
- package/dist/lib/parallel-probe.js +0 -1
- package/dist/lib/policy/runtime-policy.js +0 -1
- package/dist/lib/preemptive-quota-scheduler.js +0 -1
- package/dist/lib/proactive-refresh.js +0 -1
- package/dist/lib/prompts/codex-host-bridge.js +0 -1
- package/dist/lib/prompts/codex.d.ts +3 -11
- package/dist/lib/prompts/codex.d.ts.map +1 -1
- package/dist/lib/prompts/codex.js +4 -12
- package/dist/lib/prompts/fetch-utils.js +0 -1
- package/dist/lib/prompts/host-codex-prompt.js +0 -1
- package/dist/lib/quota-cache.d.ts.map +1 -1
- package/dist/lib/quota-cache.js +15 -43
- package/dist/lib/quota-probe.js +0 -1
- package/dist/lib/quota-readiness.js +0 -1
- package/dist/lib/recovery/constants.js +0 -1
- package/dist/lib/recovery/index.js +0 -1
- package/dist/lib/recovery/storage.d.ts.map +1 -1
- package/dist/lib/recovery/storage.js +30 -51
- package/dist/lib/recovery/storage.js.map +1 -1
- package/dist/lib/recovery/types.js +0 -1
- package/dist/lib/recovery.js +0 -1
- package/dist/lib/refresh-guardian.js +0 -1
- package/dist/lib/refresh-lease.d.ts.map +1 -1
- package/dist/lib/refresh-lease.js +1 -4
- package/dist/lib/refresh-queue.js +0 -1
- package/dist/lib/request/error-classification.d.ts +75 -0
- package/dist/lib/request/error-classification.d.ts.map +1 -0
- package/dist/lib/request/error-classification.js +295 -0
- package/dist/lib/request/failover-config.js +0 -1
- package/dist/lib/request/failure-policy.js +0 -1
- package/dist/lib/request/fetch-helpers.d.ts +10 -114
- package/dist/lib/request/fetch-helpers.d.ts.map +1 -1
- package/dist/lib/request/fetch-helpers.js +7 -589
- package/dist/lib/request/headers.d.ts +33 -0
- package/dist/lib/request/headers.d.ts.map +1 -0
- package/dist/lib/request/headers.js +64 -0
- package/dist/lib/request/helpers/input-utils.js +0 -1
- package/dist/lib/request/helpers/model-map.d.ts +10 -0
- package/dist/lib/request/helpers/model-map.d.ts.map +1 -1
- package/dist/lib/request/helpers/model-map.js +11 -1
- package/dist/lib/request/helpers/tool-utils.js +0 -1
- package/dist/lib/request/index.js +0 -1
- package/dist/lib/request/rate-limit-backoff.js +0 -1
- package/dist/lib/request/rate-limit-decision.d.ts +28 -0
- package/dist/lib/request/rate-limit-decision.d.ts.map +1 -0
- package/dist/lib/request/rate-limit-decision.js +191 -0
- package/dist/lib/request/request-attempt-budget.js +0 -1
- package/dist/lib/request/request-init.js +0 -1
- package/dist/lib/request/request-resilience.js +0 -1
- package/dist/lib/request/request-transformer.js +0 -1
- package/dist/lib/request/response-compaction.js +0 -1
- package/dist/lib/request/response-handler.js +0 -1
- package/dist/lib/request/response-metadata.js +0 -1
- package/dist/lib/request/stream-failover-runtime.d.ts +8 -0
- package/dist/lib/request/stream-failover-runtime.d.ts.map +1 -0
- package/dist/lib/request/stream-failover-runtime.js +149 -0
- package/dist/lib/request/stream-failover.js +0 -1
- package/dist/lib/request/token-refresh.d.ts +30 -0
- package/dist/lib/request/token-refresh.d.ts.map +1 -0
- package/dist/lib/request/token-refresh.js +116 -0
- package/dist/lib/request/url-rewriting.d.ts +24 -0
- package/dist/lib/request/url-rewriting.d.ts.map +1 -0
- package/dist/lib/request/url-rewriting.js +153 -0
- package/dist/lib/request/wait-utils.js +0 -1
- package/dist/lib/rotation.d.ts +1 -1
- package/dist/lib/rotation.d.ts.map +1 -1
- package/dist/lib/rotation.js +0 -1
- package/dist/lib/routing-mutex.js +0 -1
- package/dist/lib/routing-profiles.js +0 -1
- package/dist/lib/runtime/account-check-helpers.js +0 -1
- package/dist/lib/runtime/account-check-types.js +0 -1
- package/dist/lib/runtime/account-check.js +0 -1
- package/dist/lib/runtime/account-health-check.js +0 -1
- package/dist/lib/runtime/account-manager-cache-entry.js +0 -1
- package/dist/lib/runtime/account-manager-cache.js +0 -1
- package/dist/lib/runtime/account-pool.js +0 -1
- package/dist/lib/runtime/account-scope.js +0 -1
- package/dist/lib/runtime/account-select-event.js +0 -1
- package/dist/lib/runtime/account-selection.js +0 -1
- package/dist/lib/runtime/account-state.js +0 -1
- package/dist/lib/runtime/account-status.js +0 -1
- package/dist/lib/runtime/account-storage-scope-entry.js +0 -1
- package/dist/lib/runtime/app-bind.js +0 -1
- package/dist/lib/runtime/auth-facade.js +0 -1
- package/dist/lib/runtime/browser-oauth-flow.js +0 -1
- package/dist/lib/runtime/capability-boost.js +0 -1
- package/dist/lib/runtime/config-toml.js +0 -1
- package/dist/lib/runtime/event-handler.js +0 -1
- package/dist/lib/runtime/first-run.d.ts +80 -0
- package/dist/lib/runtime/first-run.d.ts.map +1 -0
- package/dist/lib/runtime/first-run.js +327 -0
- package/dist/lib/runtime/flagged-verify-types.js +0 -1
- package/dist/lib/runtime/hydrate-emails.js +0 -1
- package/dist/lib/runtime/live-sync-entry.js +0 -1
- package/dist/lib/runtime/live-sync.js +0 -1
- package/dist/lib/runtime/loader-setup.js +0 -1
- package/dist/lib/runtime/login-menu-accounts.js +0 -1
- package/dist/lib/runtime/manual-oauth-flow.js +0 -1
- package/dist/lib/runtime/oauth-browser-flow.js +0 -1
- package/dist/lib/runtime/preemptive-quota.js +0 -1
- package/dist/lib/runtime/quota-headers.js +0 -1
- package/dist/lib/runtime/quota-probe.js +0 -1
- package/dist/lib/runtime/quota-settings.js +0 -1
- package/dist/lib/runtime/refresh-guardian-entry.js +0 -1
- package/dist/lib/runtime/refresh-guardian.js +0 -1
- package/dist/lib/runtime/request-init.js +0 -1
- package/dist/lib/runtime/rotation-account-selection.d.ts +38 -0
- package/dist/lib/runtime/rotation-account-selection.d.ts.map +1 -0
- package/dist/lib/runtime/rotation-account-selection.js +172 -0
- package/dist/lib/runtime/rotation-proxy-state.d.ts +54 -0
- package/dist/lib/runtime/rotation-proxy-state.d.ts.map +1 -0
- package/dist/lib/runtime/rotation-proxy-state.js +56 -0
- package/dist/lib/runtime/rotation-server-types.d.ts +57 -0
- package/dist/lib/runtime/rotation-server-types.d.ts.map +1 -0
- package/dist/lib/runtime/rotation-server-types.js +1 -0
- package/dist/lib/runtime/rotation-storage-meta.d.ts +40 -0
- package/dist/lib/runtime/rotation-storage-meta.d.ts.map +1 -0
- package/dist/lib/runtime/rotation-storage-meta.js +143 -0
- package/dist/lib/runtime/rotation-token-refresh.d.ts +25 -0
- package/dist/lib/runtime/rotation-token-refresh.d.ts.map +1 -0
- package/dist/lib/runtime/rotation-token-refresh.js +99 -0
- package/dist/lib/runtime/runtime-current-account.d.ts.map +1 -1
- package/dist/lib/runtime/runtime-current-account.js +1 -4
- package/dist/lib/runtime/runtime-observability.js +0 -1
- package/dist/lib/runtime/runtime-services.js +0 -1
- package/dist/lib/runtime/session-affinity-entry.js +0 -1
- package/dist/lib/runtime/session-affinity.js +0 -1
- package/dist/lib/runtime/session-recovery.js +0 -1
- package/dist/lib/runtime/status-marker.js +0 -1
- package/dist/lib/runtime/storage-scope.js +0 -1
- package/dist/lib/runtime/toast.js +0 -1
- package/dist/lib/runtime/ui-runtime-entry.js +0 -1
- package/dist/lib/runtime/ui-runtime.js +0 -1
- package/dist/lib/runtime/verify-flagged.js +0 -1
- package/dist/lib/runtime-constants.js +0 -1
- package/dist/lib/runtime-paths.js +0 -1
- package/dist/lib/runtime-rotation-proxy.d.ts +7 -124
- package/dist/lib/runtime-rotation-proxy.d.ts.map +1 -1
- package/dist/lib/runtime-rotation-proxy.js +614 -1353
- package/dist/lib/schemas.d.ts +3 -3
- package/dist/lib/schemas.js +1 -2
- package/dist/lib/session-affinity.js +0 -1
- package/dist/lib/shutdown.js +0 -1
- package/dist/lib/storage/account-clear-entry.js +0 -1
- package/dist/lib/storage/account-clear.js +0 -1
- package/dist/lib/storage/account-match-utils.js +0 -1
- package/dist/lib/storage/account-persistence.d.ts +1 -1
- package/dist/lib/storage/account-persistence.d.ts.map +1 -1
- package/dist/lib/storage/account-persistence.js +0 -1
- package/dist/lib/storage/account-port.d.ts +1 -1
- package/dist/lib/storage/account-port.d.ts.map +1 -1
- package/dist/lib/storage/account-port.js +0 -1
- package/dist/lib/storage/account-save-entry.d.ts +1 -1
- package/dist/lib/storage/account-save-entry.d.ts.map +1 -1
- package/dist/lib/storage/account-save-entry.js +0 -1
- package/dist/lib/storage/account-save.d.ts +1 -1
- package/dist/lib/storage/account-save.d.ts.map +1 -1
- package/dist/lib/storage/account-save.js +0 -1
- package/dist/lib/storage/account-snapshot.js +0 -1
- package/dist/lib/storage/backup-metadata-builder.d.ts +1 -1
- package/dist/lib/storage/backup-metadata-builder.d.ts.map +1 -1
- package/dist/lib/storage/backup-metadata-builder.js +0 -1
- package/dist/lib/storage/backup-metadata.d.ts +13 -0
- package/dist/lib/storage/backup-metadata.d.ts.map +1 -1
- package/dist/lib/storage/backup-metadata.js +0 -1
- package/dist/lib/storage/backup-paths.js +0 -1
- package/dist/lib/storage/backup-restore.d.ts +1 -1
- package/dist/lib/storage/backup-restore.d.ts.map +1 -1
- package/dist/lib/storage/backup-restore.js +0 -1
- package/dist/lib/storage/cache-artifacts.js +0 -1
- package/dist/lib/storage/error-hints.js +0 -1
- package/dist/lib/storage/file-paths.js +0 -1
- package/dist/lib/storage/fixture-guards.d.ts +1 -1
- package/dist/lib/storage/fixture-guards.d.ts.map +1 -1
- package/dist/lib/storage/fixture-guards.js +0 -1
- package/dist/lib/storage/flagged-entry.js +0 -1
- package/dist/lib/storage/flagged-load-entry.d.ts +1 -1
- package/dist/lib/storage/flagged-load-entry.d.ts.map +1 -1
- package/dist/lib/storage/flagged-load-entry.js +0 -1
- package/dist/lib/storage/flagged-save-entry.d.ts +1 -1
- package/dist/lib/storage/flagged-save-entry.d.ts.map +1 -1
- package/dist/lib/storage/flagged-save-entry.js +0 -1
- package/dist/lib/storage/flagged-storage-file.d.ts +1 -1
- package/dist/lib/storage/flagged-storage-file.d.ts.map +1 -1
- package/dist/lib/storage/flagged-storage-file.js +0 -1
- package/dist/lib/storage/flagged-storage-io.d.ts +1 -1
- package/dist/lib/storage/flagged-storage-io.d.ts.map +1 -1
- package/dist/lib/storage/flagged-storage-io.js +0 -1
- package/dist/lib/storage/flagged-storage.d.ts +1 -1
- package/dist/lib/storage/flagged-storage.d.ts.map +1 -1
- package/dist/lib/storage/flagged-storage.js +15 -2
- package/dist/lib/storage/flagged-storage.js.map +1 -1
- package/dist/lib/storage/gitignore.js +0 -1
- package/dist/lib/storage/hash.js +0 -1
- package/dist/lib/storage/health.js +0 -1
- package/dist/lib/storage/identity.js +0 -1
- package/dist/lib/storage/import-export.d.ts +1 -1
- package/dist/lib/storage/import-export.d.ts.map +1 -1
- package/dist/lib/storage/import-export.js +0 -1
- package/dist/lib/storage/metadata-section.js +0 -1
- package/dist/lib/storage/migrations.d.ts +5 -48
- package/dist/lib/storage/migrations.d.ts.map +1 -1
- package/dist/lib/storage/migrations.js +5 -2
- package/dist/lib/storage/named-backup-entry.js +0 -1
- package/dist/lib/storage/named-backups-entry.d.ts +1 -1
- package/dist/lib/storage/named-backups-entry.d.ts.map +1 -1
- package/dist/lib/storage/named-backups-entry.js +0 -1
- package/dist/lib/storage/named-backups.js +0 -1
- package/dist/lib/storage/path-state.js +0 -1
- package/dist/lib/storage/paths.js +0 -1
- package/dist/lib/storage/project-migration.d.ts +1 -1
- package/dist/lib/storage/project-migration.d.ts.map +1 -1
- package/dist/lib/storage/project-migration.js +0 -1
- package/dist/lib/storage/public-types.d.ts +70 -0
- package/dist/lib/storage/public-types.d.ts.map +1 -0
- package/dist/lib/storage/public-types.js +6 -0
- package/dist/lib/storage/record-utils.js +0 -1
- package/dist/lib/storage/restore-assessment.d.ts +1 -1
- package/dist/lib/storage/restore-assessment.d.ts.map +1 -1
- package/dist/lib/storage/restore-assessment.js +0 -1
- package/dist/lib/storage/restore-backup-entry.d.ts +1 -1
- package/dist/lib/storage/restore-backup-entry.d.ts.map +1 -1
- package/dist/lib/storage/restore-backup-entry.js +0 -1
- package/dist/lib/storage/restore-metadata.d.ts +1 -1
- package/dist/lib/storage/restore-metadata.d.ts.map +1 -1
- package/dist/lib/storage/restore-metadata.js +0 -1
- package/dist/lib/storage/restore.d.ts +1 -1
- package/dist/lib/storage/restore.d.ts.map +1 -1
- package/dist/lib/storage/restore.js +0 -1
- package/dist/lib/storage/save-retry.d.ts +10 -0
- package/dist/lib/storage/save-retry.d.ts.map +1 -0
- package/dist/lib/storage/save-retry.js +26 -0
- package/dist/lib/storage/snapshot-inspectors.d.ts +1 -1
- package/dist/lib/storage/snapshot-inspectors.d.ts.map +1 -1
- package/dist/lib/storage/snapshot-inspectors.js +0 -1
- package/dist/lib/storage/storage-parser.d.ts +1 -1
- package/dist/lib/storage/storage-parser.d.ts.map +1 -1
- package/dist/lib/storage/storage-parser.js +0 -1
- package/dist/lib/storage/transactions.d.ts +1 -1
- package/dist/lib/storage/transactions.d.ts.map +1 -1
- package/dist/lib/storage/transactions.js +0 -1
- package/dist/lib/storage.d.ts +3 -24
- package/dist/lib/storage.d.ts.map +1 -1
- package/dist/lib/storage.js +17 -32
- package/dist/lib/table-formatter.js +0 -1
- package/dist/lib/tools/hashline-tools.js +0 -1
- package/dist/lib/types.js +0 -1
- package/dist/lib/ui/ansi.js +0 -1
- package/dist/lib/ui/auth-menu-builder.d.ts +89 -0
- package/dist/lib/ui/auth-menu-builder.d.ts.map +1 -0
- package/dist/lib/ui/auth-menu-builder.js +350 -0
- package/dist/lib/ui/auth-menu.d.ts +2 -76
- package/dist/lib/ui/auth-menu.d.ts.map +1 -1
- package/dist/lib/ui/auth-menu.js +3 -349
- package/dist/lib/ui/confirm.js +0 -1
- package/dist/lib/ui/copy.d.ts +2 -0
- package/dist/lib/ui/copy.d.ts.map +1 -1
- package/dist/lib/ui/copy.js +2 -0
- package/dist/lib/ui/copy.js.map +1 -1
- package/dist/lib/ui/display-width.js +0 -1
- package/dist/lib/ui/format.js +0 -1
- package/dist/lib/ui/index.d.ts +10 -0
- package/dist/lib/ui/index.d.ts.map +1 -0
- package/dist/lib/ui/index.js +9 -0
- package/dist/lib/ui/runtime.js +0 -1
- package/dist/lib/ui/select.js +0 -1
- package/dist/lib/ui/theme.js +0 -1
- package/dist/lib/ui/ui-copy.d.ts +159 -0
- package/dist/lib/ui/ui-copy.d.ts.map +1 -0
- package/dist/lib/ui/ui-copy.js +163 -0
- package/dist/lib/unified-settings.js +0 -1
- package/dist/lib/update-notice.js +0 -1
- package/dist/lib/usage/index.js +0 -1
- package/dist/lib/usage/ledger.js +0 -1
- package/dist/lib/usage/pricing.js +0 -1
- package/dist/lib/usage/redaction.js +0 -1
- package/dist/lib/usage/types.js +0 -1
- package/dist/lib/utils.js +0 -1
- package/package.json +8 -8
- package/scripts/postinstall.js +34 -265
- package/scripts/preuninstall.js +2 -2
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { stdout as output } from "node:process";
|
|
2
|
+
import { ANSI } from "../../ui/ansi.js";
|
|
3
|
+
import { paintUiText } from "../../ui/format.js";
|
|
4
|
+
import { getUiRuntimeOptions } from "../../ui/runtime.js";
|
|
5
|
+
export function stylePromptText(text, tone) {
|
|
6
|
+
if (!output.isTTY)
|
|
7
|
+
return text;
|
|
8
|
+
const ui = getUiRuntimeOptions();
|
|
9
|
+
if (ui.v2Enabled) {
|
|
10
|
+
if (tone === "muted") {
|
|
11
|
+
return `${ui.theme.colors.dim}${paintUiText(ui, text, "muted")}${ui.theme.colors.reset}`;
|
|
12
|
+
}
|
|
13
|
+
const mapped = tone === "accent" ? "primary" : tone;
|
|
14
|
+
return paintUiText(ui, text, mapped);
|
|
15
|
+
}
|
|
16
|
+
const legacyCode = tone === "accent"
|
|
17
|
+
? ANSI.green
|
|
18
|
+
: tone === "success"
|
|
19
|
+
? ANSI.green
|
|
20
|
+
: tone === "warning"
|
|
21
|
+
? ANSI.yellow
|
|
22
|
+
: tone === "danger"
|
|
23
|
+
? ANSI.red
|
|
24
|
+
: ANSI.dim;
|
|
25
|
+
return `${legacyCode}${text}${ANSI.reset}`;
|
|
26
|
+
}
|
|
27
|
+
export function collapseWhitespace(value) {
|
|
28
|
+
return value.replace(/\s+/g, " ").trim();
|
|
29
|
+
}
|
|
30
|
+
export function formatReasonLabel(reason) {
|
|
31
|
+
if (!reason)
|
|
32
|
+
return undefined;
|
|
33
|
+
const normalized = collapseWhitespace(reason.replace(/_/g, " "));
|
|
34
|
+
return normalized.length > 0 ? normalized : undefined;
|
|
35
|
+
}
|
|
36
|
+
export function extractErrorMessageFromPayload(payload) {
|
|
37
|
+
if (!payload || typeof payload !== "object")
|
|
38
|
+
return undefined;
|
|
39
|
+
const record = payload;
|
|
40
|
+
const directMessage = typeof record.message === "string"
|
|
41
|
+
? collapseWhitespace(record.message)
|
|
42
|
+
: "";
|
|
43
|
+
const directCode = typeof record.code === "string" ? collapseWhitespace(record.code) : "";
|
|
44
|
+
if (directMessage) {
|
|
45
|
+
if (directCode &&
|
|
46
|
+
!directMessage.toLowerCase().includes(directCode.toLowerCase())) {
|
|
47
|
+
return `${directMessage} [${directCode}]`;
|
|
48
|
+
}
|
|
49
|
+
return directMessage;
|
|
50
|
+
}
|
|
51
|
+
const nested = record.error;
|
|
52
|
+
if (nested && typeof nested === "object") {
|
|
53
|
+
return extractErrorMessageFromPayload(nested);
|
|
54
|
+
}
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
export function parseStructuredErrorMessage(raw) {
|
|
58
|
+
const trimmed = raw.trim();
|
|
59
|
+
if (!trimmed)
|
|
60
|
+
return undefined;
|
|
61
|
+
const candidates = new Set([trimmed]);
|
|
62
|
+
const firstBrace = trimmed.indexOf("{");
|
|
63
|
+
const lastBrace = trimmed.lastIndexOf("}");
|
|
64
|
+
if (firstBrace >= 0 && lastBrace > firstBrace) {
|
|
65
|
+
candidates.add(trimmed.slice(firstBrace, lastBrace + 1));
|
|
66
|
+
}
|
|
67
|
+
for (const candidate of candidates) {
|
|
68
|
+
try {
|
|
69
|
+
const parsed = JSON.parse(candidate);
|
|
70
|
+
const message = extractErrorMessageFromPayload(parsed);
|
|
71
|
+
if (message)
|
|
72
|
+
return message;
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
// ignore non-JSON candidates
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
export function normalizeFailureDetail(message, reason) {
|
|
81
|
+
const reasonLabel = formatReasonLabel(reason);
|
|
82
|
+
const raw = message?.trim() || reasonLabel || "refresh failed";
|
|
83
|
+
const structured = parseStructuredErrorMessage(raw);
|
|
84
|
+
const normalized = collapseWhitespace(structured ?? raw);
|
|
85
|
+
const bounded = normalized.length > 260 ? `${normalized.slice(0, 257)}...` : normalized;
|
|
86
|
+
return bounded.length > 0 ? bounded : "refresh failed";
|
|
87
|
+
}
|
|
88
|
+
export function joinStyledSegments(parts) {
|
|
89
|
+
if (parts.length === 0)
|
|
90
|
+
return "";
|
|
91
|
+
const separator = stylePromptText(" | ", "muted");
|
|
92
|
+
return parts.join(separator);
|
|
93
|
+
}
|
|
94
|
+
export function formatResultSummary(segments) {
|
|
95
|
+
const rendered = segments.map((segment) => stylePromptText(segment.text, segment.tone));
|
|
96
|
+
return `${stylePromptText("Result:", "accent")} ${joinStyledSegments(rendered)}`;
|
|
97
|
+
}
|
|
98
|
+
export function stringifyLogArgs(args) {
|
|
99
|
+
return args
|
|
100
|
+
.map((value) => {
|
|
101
|
+
if (typeof value === "string")
|
|
102
|
+
return value;
|
|
103
|
+
try {
|
|
104
|
+
return JSON.stringify(value);
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
return String(value);
|
|
108
|
+
}
|
|
109
|
+
})
|
|
110
|
+
.join(" ");
|
|
111
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type DashboardDisplaySettings } from "../dashboard-settings.js";
|
|
2
|
+
/**
|
|
3
|
+
* Body of the `check` command, also reused by the login dashboard's quick
|
|
4
|
+
* check / deep check actions. Moved verbatim out of lib/codex-manager.ts
|
|
5
|
+
* (audit roadmap §4.1.1 phase 3).
|
|
6
|
+
*/
|
|
7
|
+
export interface HealthCheckOptions {
|
|
8
|
+
forceRefresh?: boolean;
|
|
9
|
+
liveProbe?: boolean;
|
|
10
|
+
model?: string;
|
|
11
|
+
display?: DashboardDisplaySettings;
|
|
12
|
+
}
|
|
13
|
+
export declare function runHealthCheck(options?: HealthCheckOptions): Promise<void>;
|
|
14
|
+
//# sourceMappingURL=health-check.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health-check.d.ts","sourceRoot":"","sources":["../../../lib/codex-manager/health-check.ts"],"names":[],"mappings":"AAOA,OAAO,EACN,KAAK,wBAAwB,EAE7B,MAAM,0BAA0B,CAAC;AAiClC;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IAClC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,wBAAwB,CAAC;CACnC;AAED,wBAAsB,cAAc,CACnC,OAAO,GAAE,kBAAuB,GAC9B,OAAO,CAAC,IAAI,CAAC,CA6Tf"}
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import { extractAccountEmail, extractAccountId, formatAccountLabel, sanitizeEmail, } from "../accounts.js";
|
|
2
|
+
import { setCodexCliActiveSelection } from "../codex-cli/writer.js";
|
|
3
|
+
import { DEFAULT_DASHBOARD_DISPLAY_SETTINGS, } from "../dashboard-settings.js";
|
|
4
|
+
import { isCodexUnavailableError } from "../errors.js";
|
|
5
|
+
import { loadQuotaCache, saveQuotaCache } from "../quota-cache.js";
|
|
6
|
+
import { CODEX_UNAVAILABLE_PROBE_NOTE, fetchCodexQuotaSnapshot, } from "../quota-probe.js";
|
|
7
|
+
import { buildQuotaEmailFallbackState } from "../quota-readiness.js";
|
|
8
|
+
import { queuedRefresh } from "../refresh-queue.js";
|
|
9
|
+
import { resolveActiveIndex } from "../runtime/account-status.js";
|
|
10
|
+
import { loadAccounts, saveAccounts, setStoragePath } from "../storage.js";
|
|
11
|
+
import { applyTokenAccountIdentity, hasLikelyInvalidRefreshToken, hasUsableAccessToken, } from "./account-credentials.js";
|
|
12
|
+
import { saveAccountsWithRetry } from "./forecast-report-shared.js";
|
|
13
|
+
import { formatModelInspection, formatQuotaSnapshotForDashboard, formatResultSummary, inspectRequestedModel, normalizeFailureDetail, styleAccountDetailText, stylePromptText, } from "./formatters/index.js";
|
|
14
|
+
import { cloneQuotaCacheData, DEFAULT_LIVE_PROBE_MODEL, pruneUnsafeQuotaEmailCacheEntry, updateQuotaCacheForAccount, } from "./quota-cache-helpers.js";
|
|
15
|
+
export async function runHealthCheck(options = {}) {
|
|
16
|
+
const forceRefresh = options.forceRefresh === true;
|
|
17
|
+
const liveProbe = options.liveProbe === true;
|
|
18
|
+
const probeModel = options.model?.trim() || DEFAULT_LIVE_PROBE_MODEL;
|
|
19
|
+
const modelInspection = inspectRequestedModel(probeModel);
|
|
20
|
+
const display = options.display ?? DEFAULT_DASHBOARD_DISPLAY_SETTINGS;
|
|
21
|
+
const quotaCache = liveProbe ? await loadQuotaCache() : null;
|
|
22
|
+
const workingQuotaCache = quotaCache ? cloneQuotaCacheData(quotaCache) : null;
|
|
23
|
+
let quotaCacheChanged = false;
|
|
24
|
+
setStoragePath(null);
|
|
25
|
+
const storage = await loadAccounts();
|
|
26
|
+
if (!storage || storage.accounts.length === 0) {
|
|
27
|
+
console.log("No accounts configured.");
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
let quotaEmailFallbackState = liveProbe && quotaCache
|
|
31
|
+
? buildQuotaEmailFallbackState(storage.accounts)
|
|
32
|
+
: null;
|
|
33
|
+
let changed = false;
|
|
34
|
+
let ok = 0;
|
|
35
|
+
let failed = 0;
|
|
36
|
+
let warnings = 0;
|
|
37
|
+
let codexAvailable = 0;
|
|
38
|
+
let signedInOnly = 0;
|
|
39
|
+
const activeIndex = resolveActiveIndex(storage, "codex");
|
|
40
|
+
let activeAccountRefreshed = false;
|
|
41
|
+
const now = Date.now();
|
|
42
|
+
console.log(stylePromptText(forceRefresh
|
|
43
|
+
? `Checking ${storage.accounts.length} account(s) with full refresh test...`
|
|
44
|
+
: `Checking ${storage.accounts.length} account(s) with quick check${liveProbe ? " + live check" : ""}...`, "accent"));
|
|
45
|
+
if (liveProbe) {
|
|
46
|
+
console.log(stylePromptText(`Model probe: ${formatModelInspection(modelInspection)}`, "muted"));
|
|
47
|
+
}
|
|
48
|
+
for (let i = 0; i < storage.accounts.length; i += 1) {
|
|
49
|
+
const account = storage.accounts[i];
|
|
50
|
+
if (!account)
|
|
51
|
+
continue;
|
|
52
|
+
const label = formatAccountLabel(account, i);
|
|
53
|
+
const labelText = stylePromptText(label, "accent");
|
|
54
|
+
const sessionLikelyValid = hasUsableAccessToken(account, now);
|
|
55
|
+
if (!forceRefresh && sessionLikelyValid) {
|
|
56
|
+
if (account.enabled === false) {
|
|
57
|
+
account.enabled = true;
|
|
58
|
+
changed = true;
|
|
59
|
+
}
|
|
60
|
+
if (i === activeIndex) {
|
|
61
|
+
activeAccountRefreshed = true;
|
|
62
|
+
}
|
|
63
|
+
let healthDetail = "signed in and working";
|
|
64
|
+
let healthTone = "success";
|
|
65
|
+
if (liveProbe) {
|
|
66
|
+
const currentAccessToken = account.accessToken;
|
|
67
|
+
const probeAccountId = currentAccessToken
|
|
68
|
+
? (account.accountId ?? extractAccountId(currentAccessToken))
|
|
69
|
+
: undefined;
|
|
70
|
+
if (!probeAccountId || !currentAccessToken) {
|
|
71
|
+
warnings += 1;
|
|
72
|
+
signedInOnly += 1;
|
|
73
|
+
healthTone = "warning";
|
|
74
|
+
healthDetail =
|
|
75
|
+
"signed in (live check skipped: missing account ID)";
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
try {
|
|
79
|
+
const snapshot = await fetchCodexQuotaSnapshot({
|
|
80
|
+
accountId: probeAccountId,
|
|
81
|
+
accessToken: currentAccessToken,
|
|
82
|
+
model: modelInspection.normalized,
|
|
83
|
+
});
|
|
84
|
+
if (workingQuotaCache) {
|
|
85
|
+
quotaCacheChanged =
|
|
86
|
+
updateQuotaCacheForAccount(workingQuotaCache, account, snapshot, storage.accounts, quotaEmailFallbackState ?? undefined) || quotaCacheChanged;
|
|
87
|
+
}
|
|
88
|
+
healthDetail = formatQuotaSnapshotForDashboard(snapshot, display);
|
|
89
|
+
codexAvailable += 1;
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
warnings += 1;
|
|
93
|
+
signedInOnly += 1;
|
|
94
|
+
healthTone = "warning";
|
|
95
|
+
if (isCodexUnavailableError(error)) {
|
|
96
|
+
healthDetail =
|
|
97
|
+
`signed in; ${CODEX_UNAVAILABLE_PROBE_NOTE}`;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
const message = normalizeFailureDetail(error instanceof Error ? error.message : String(error), undefined);
|
|
101
|
+
healthDetail = `signed in (live check failed: ${message})`;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (hasLikelyInvalidRefreshToken(account.refreshToken)) {
|
|
107
|
+
healthDetail += " (re-login suggested soon)";
|
|
108
|
+
}
|
|
109
|
+
ok += 1;
|
|
110
|
+
if (display.showPerAccountRows) {
|
|
111
|
+
const healthMarker = healthTone === "success" ? "✓" : "!";
|
|
112
|
+
console.log(` ${stylePromptText(healthMarker, healthTone)} ${labelText} ${stylePromptText("|", "muted")} ${styleAccountDetailText(healthDetail, healthTone)}`);
|
|
113
|
+
}
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
const result = await queuedRefresh(account.refreshToken);
|
|
117
|
+
if (result.type === "success") {
|
|
118
|
+
const tokenAccountId = extractAccountId(result.access);
|
|
119
|
+
const nextEmail = sanitizeEmail(extractAccountEmail(result.access, result.idToken));
|
|
120
|
+
const previousEmail = account.email;
|
|
121
|
+
let accountIdentityChanged = false;
|
|
122
|
+
if (account.refreshToken !== result.refresh) {
|
|
123
|
+
account.refreshToken = result.refresh;
|
|
124
|
+
changed = true;
|
|
125
|
+
}
|
|
126
|
+
if (account.accessToken !== result.access) {
|
|
127
|
+
account.accessToken = result.access;
|
|
128
|
+
changed = true;
|
|
129
|
+
}
|
|
130
|
+
if (account.expiresAt !== result.expires) {
|
|
131
|
+
account.expiresAt = result.expires;
|
|
132
|
+
changed = true;
|
|
133
|
+
}
|
|
134
|
+
if (nextEmail && nextEmail !== account.email) {
|
|
135
|
+
account.email = nextEmail;
|
|
136
|
+
changed = true;
|
|
137
|
+
accountIdentityChanged = true;
|
|
138
|
+
}
|
|
139
|
+
if (applyTokenAccountIdentity(account, tokenAccountId)) {
|
|
140
|
+
changed = true;
|
|
141
|
+
accountIdentityChanged = true;
|
|
142
|
+
}
|
|
143
|
+
if (account.enabled === false) {
|
|
144
|
+
account.enabled = true;
|
|
145
|
+
changed = true;
|
|
146
|
+
}
|
|
147
|
+
if (accountIdentityChanged && liveProbe && workingQuotaCache) {
|
|
148
|
+
quotaEmailFallbackState = buildQuotaEmailFallbackState(storage.accounts);
|
|
149
|
+
quotaCacheChanged =
|
|
150
|
+
pruneUnsafeQuotaEmailCacheEntry(workingQuotaCache, previousEmail, storage.accounts, quotaEmailFallbackState) || quotaCacheChanged;
|
|
151
|
+
}
|
|
152
|
+
account.lastUsed = Date.now();
|
|
153
|
+
if (i === activeIndex) {
|
|
154
|
+
activeAccountRefreshed = true;
|
|
155
|
+
}
|
|
156
|
+
ok += 1;
|
|
157
|
+
let healthyMessage = "working now";
|
|
158
|
+
let healthyTone = "success";
|
|
159
|
+
if (liveProbe) {
|
|
160
|
+
const probeAccountId = account.accountId ?? tokenAccountId;
|
|
161
|
+
if (!probeAccountId) {
|
|
162
|
+
warnings += 1;
|
|
163
|
+
signedInOnly += 1;
|
|
164
|
+
healthyTone = "warning";
|
|
165
|
+
healthyMessage =
|
|
166
|
+
"signed in (live check skipped: missing account ID)";
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
try {
|
|
170
|
+
const snapshot = await fetchCodexQuotaSnapshot({
|
|
171
|
+
accountId: probeAccountId,
|
|
172
|
+
accessToken: result.access,
|
|
173
|
+
model: modelInspection.normalized,
|
|
174
|
+
});
|
|
175
|
+
if (workingQuotaCache) {
|
|
176
|
+
quotaCacheChanged =
|
|
177
|
+
updateQuotaCacheForAccount(workingQuotaCache, account, snapshot, storage.accounts, quotaEmailFallbackState ?? undefined) || quotaCacheChanged;
|
|
178
|
+
}
|
|
179
|
+
healthyMessage = formatQuotaSnapshotForDashboard(snapshot, display);
|
|
180
|
+
codexAvailable += 1;
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
warnings += 1;
|
|
184
|
+
signedInOnly += 1;
|
|
185
|
+
healthyTone = "warning";
|
|
186
|
+
if (isCodexUnavailableError(error)) {
|
|
187
|
+
healthyMessage =
|
|
188
|
+
`signed in; ${CODEX_UNAVAILABLE_PROBE_NOTE}`;
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
const message = normalizeFailureDetail(error instanceof Error ? error.message : String(error), undefined);
|
|
192
|
+
healthyMessage = `signed in (live check failed: ${message})`;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (display.showPerAccountRows) {
|
|
198
|
+
const healthyMarker = healthyTone === "success" ? "✓" : "!";
|
|
199
|
+
console.log(` ${stylePromptText(healthyMarker, healthyTone)} ${labelText} ${stylePromptText("|", "muted")} ${styleAccountDetailText(healthyMessage, healthyTone)}`);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
const detail = normalizeFailureDetail(result.message, result.reason);
|
|
204
|
+
if (sessionLikelyValid) {
|
|
205
|
+
warnings += 1;
|
|
206
|
+
if (liveProbe) {
|
|
207
|
+
signedInOnly += 1;
|
|
208
|
+
}
|
|
209
|
+
if (display.showPerAccountRows) {
|
|
210
|
+
console.log(` ${stylePromptText("!", "warning")} ${labelText} ${stylePromptText("|", "muted")} ${stylePromptText(`refresh failed (${detail}) but this account still works right now`, "warning")}`);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
failed += 1;
|
|
215
|
+
if (display.showPerAccountRows) {
|
|
216
|
+
console.log(` ${stylePromptText("✗", "danger")} ${labelText} ${stylePromptText("|", "muted")} ${stylePromptText(detail, "danger")}`);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
if (!display.showPerAccountRows) {
|
|
222
|
+
console.log(stylePromptText("Per-account lines are hidden in dashboard settings.", "muted"));
|
|
223
|
+
}
|
|
224
|
+
if (workingQuotaCache && quotaCacheChanged) {
|
|
225
|
+
try {
|
|
226
|
+
await saveQuotaCache(workingQuotaCache);
|
|
227
|
+
}
|
|
228
|
+
catch (error) {
|
|
229
|
+
// Quota cache is a derived artifact; a transient Windows EBUSY/EPERM
|
|
230
|
+
// here must not abort the health check before account fixes commit.
|
|
231
|
+
console.warn(`Quota cache save failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if (changed) {
|
|
235
|
+
await saveAccountsWithRetry(storage, saveAccounts);
|
|
236
|
+
}
|
|
237
|
+
if (activeAccountRefreshed &&
|
|
238
|
+
activeIndex >= 0 &&
|
|
239
|
+
activeIndex < storage.accounts.length) {
|
|
240
|
+
const activeAccount = storage.accounts[activeIndex];
|
|
241
|
+
if (activeAccount) {
|
|
242
|
+
await setCodexCliActiveSelection({
|
|
243
|
+
accountId: activeAccount.accountId,
|
|
244
|
+
email: activeAccount.email,
|
|
245
|
+
accessToken: activeAccount.accessToken,
|
|
246
|
+
refreshToken: activeAccount.refreshToken,
|
|
247
|
+
expiresAt: activeAccount.expiresAt,
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
console.log("");
|
|
252
|
+
console.log(formatResultSummary(liveProbe
|
|
253
|
+
? [
|
|
254
|
+
{
|
|
255
|
+
text: `${codexAvailable} Codex available`,
|
|
256
|
+
tone: codexAvailable > 0 ? "success" : "muted",
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
text: `${signedInOnly} signed in only`,
|
|
260
|
+
tone: signedInOnly > 0 ? "warning" : "muted",
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
text: `${failed} need re-login`,
|
|
264
|
+
tone: failed > 0 ? "danger" : "muted",
|
|
265
|
+
},
|
|
266
|
+
]
|
|
267
|
+
: [
|
|
268
|
+
{ text: `${ok} working`, tone: "success" },
|
|
269
|
+
{
|
|
270
|
+
text: `${failed} need re-login`,
|
|
271
|
+
tone: failed > 0 ? "danger" : "muted",
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
text: `${warnings} warning${warnings === 1 ? "" : "s"}`,
|
|
275
|
+
tone: warnings > 0 ? "warning" : "muted",
|
|
276
|
+
},
|
|
277
|
+
]));
|
|
278
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { DashboardDisplaySettings } from "../dashboard-settings.js";
|
|
2
|
+
/** @internal */
|
|
3
|
+
export declare function runActionPanel(title: string, stage: string, action: () => Promise<void> | void, settings?: DashboardDisplaySettings): Promise<void>;
|
|
4
|
+
//# sourceMappingURL=login-action-panel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login-action-panel.d.ts","sourceRoot":"","sources":["../../../lib/codex-manager/login-action-panel.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAuJzE,gBAAgB;AAChB,wBAAsB,cAAc,CACnC,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,EAClC,QAAQ,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,IAAI,CAAC,CAgHf"}
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { stdin as input, stdout as output } from "node:process";
|
|
2
|
+
import { createInterface } from "node:readline/promises";
|
|
3
|
+
import { ANSI } from "../ui/ansi.js";
|
|
4
|
+
import { UI_COPY } from "../ui/ui-copy.js";
|
|
5
|
+
import { stringifyLogArgs, stylePromptText, } from "./formatters/index.js";
|
|
6
|
+
import { isAbortError } from "./login-oauth.js";
|
|
7
|
+
async function waitForMenuReturn(options = {}) {
|
|
8
|
+
if (!input.isTTY || !output.isTTY) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const promptText = options.promptText ?? UI_COPY.returnFlow.continuePrompt;
|
|
12
|
+
const autoReturnMs = options.autoReturnMs ?? 0;
|
|
13
|
+
const pauseOnAnyKey = options.pauseOnAnyKey ?? true;
|
|
14
|
+
try {
|
|
15
|
+
let chunk;
|
|
16
|
+
do {
|
|
17
|
+
chunk = input.read();
|
|
18
|
+
} while (chunk !== null);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
// best effort buffer drain
|
|
22
|
+
}
|
|
23
|
+
const writeInlineStatus = (message) => {
|
|
24
|
+
output.write(`\r${ANSI.clearLine}${stylePromptText(message, "muted")}`);
|
|
25
|
+
};
|
|
26
|
+
const clearInlineStatus = () => {
|
|
27
|
+
output.write(`\r${ANSI.clearLine}`);
|
|
28
|
+
};
|
|
29
|
+
if (autoReturnMs > 0) {
|
|
30
|
+
if (!pauseOnAnyKey) {
|
|
31
|
+
await new Promise((resolve) => setTimeout(resolve, autoReturnMs));
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const wasRaw = input.isRaw ?? false;
|
|
35
|
+
const endAt = Date.now() + autoReturnMs;
|
|
36
|
+
let lastShownSeconds = null;
|
|
37
|
+
const renderCountdown = () => {
|
|
38
|
+
const remainingMs = Math.max(0, endAt - Date.now());
|
|
39
|
+
const remainingSeconds = Math.max(1, Math.ceil(remainingMs / 1000));
|
|
40
|
+
if (lastShownSeconds === remainingSeconds)
|
|
41
|
+
return;
|
|
42
|
+
lastShownSeconds = remainingSeconds;
|
|
43
|
+
writeInlineStatus(UI_COPY.returnFlow.autoReturn(remainingSeconds));
|
|
44
|
+
};
|
|
45
|
+
renderCountdown();
|
|
46
|
+
const pinned = await new Promise((resolve) => {
|
|
47
|
+
let done = false;
|
|
48
|
+
const interval = setInterval(renderCountdown, 80);
|
|
49
|
+
let timeout = setTimeout(() => {
|
|
50
|
+
timeout = null;
|
|
51
|
+
if (!done) {
|
|
52
|
+
done = true;
|
|
53
|
+
cleanup();
|
|
54
|
+
resolve(false);
|
|
55
|
+
}
|
|
56
|
+
}, autoReturnMs);
|
|
57
|
+
const onData = () => {
|
|
58
|
+
if (done)
|
|
59
|
+
return;
|
|
60
|
+
done = true;
|
|
61
|
+
cleanup();
|
|
62
|
+
resolve(true);
|
|
63
|
+
};
|
|
64
|
+
const cleanup = () => {
|
|
65
|
+
clearInterval(interval);
|
|
66
|
+
if (timeout) {
|
|
67
|
+
clearTimeout(timeout);
|
|
68
|
+
timeout = null;
|
|
69
|
+
}
|
|
70
|
+
input.removeListener("data", onData);
|
|
71
|
+
try {
|
|
72
|
+
input.setRawMode(wasRaw);
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
// best effort restore
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
try {
|
|
79
|
+
input.setRawMode(true);
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
// if raw mode fails, keep countdown behavior
|
|
83
|
+
}
|
|
84
|
+
input.on("data", onData);
|
|
85
|
+
input.resume();
|
|
86
|
+
});
|
|
87
|
+
clearInlineStatus();
|
|
88
|
+
if (!pinned) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
const paused = stylePromptText(UI_COPY.returnFlow.paused, "muted");
|
|
92
|
+
writeInlineStatus(paused);
|
|
93
|
+
await new Promise((resolve) => {
|
|
94
|
+
const wasRaw = input.isRaw ?? false;
|
|
95
|
+
const onData = () => {
|
|
96
|
+
cleanup();
|
|
97
|
+
resolve();
|
|
98
|
+
};
|
|
99
|
+
const cleanup = () => {
|
|
100
|
+
input.removeListener("data", onData);
|
|
101
|
+
try {
|
|
102
|
+
input.setRawMode(wasRaw);
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
// best effort restore
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
try {
|
|
109
|
+
input.setRawMode(true);
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
// best effort fallback
|
|
113
|
+
}
|
|
114
|
+
input.on("data", onData);
|
|
115
|
+
input.resume();
|
|
116
|
+
});
|
|
117
|
+
clearInlineStatus();
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const rl = createInterface({ input, output });
|
|
121
|
+
try {
|
|
122
|
+
const question = promptText.length > 0 ? `${stylePromptText(promptText, "muted")} ` : "";
|
|
123
|
+
output.write(`\r${ANSI.clearLine}`);
|
|
124
|
+
await rl.question(question);
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
if (!isAbortError(error)) {
|
|
128
|
+
throw error;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
finally {
|
|
132
|
+
rl.close();
|
|
133
|
+
clearInlineStatus();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/** @internal */
|
|
137
|
+
export async function runActionPanel(title, stage, action, settings) {
|
|
138
|
+
if (!input.isTTY || !output.isTTY) {
|
|
139
|
+
await action();
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
const spinnerFrames = ["-", "\\", "|", "/"];
|
|
143
|
+
let frame = 0;
|
|
144
|
+
let running = true;
|
|
145
|
+
let failed = null;
|
|
146
|
+
const captured = [];
|
|
147
|
+
const maxVisibleLines = Math.max(8, (output.rows ?? 24) - 8);
|
|
148
|
+
const previousLog = console.log;
|
|
149
|
+
const previousWarn = console.warn;
|
|
150
|
+
const previousError = console.error;
|
|
151
|
+
const capture = (prefix, args) => {
|
|
152
|
+
const line = stringifyLogArgs(args).trim();
|
|
153
|
+
if (!line)
|
|
154
|
+
return;
|
|
155
|
+
captured.push(prefix ? `${prefix}${line}` : line);
|
|
156
|
+
if (captured.length > 400) {
|
|
157
|
+
captured.splice(0, captured.length - 400);
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
const render = () => {
|
|
161
|
+
output.write(ANSI.clearScreen + ANSI.moveTo(1, 1));
|
|
162
|
+
const spinner = running
|
|
163
|
+
? `${spinnerFrames[frame % spinnerFrames.length] ?? "-"} `
|
|
164
|
+
: failed
|
|
165
|
+
? "x "
|
|
166
|
+
: "+ ";
|
|
167
|
+
const stageText = running
|
|
168
|
+
? `${spinner}${stage}`
|
|
169
|
+
: failed
|
|
170
|
+
? UI_COPY.returnFlow.failed
|
|
171
|
+
: UI_COPY.returnFlow.done;
|
|
172
|
+
previousLog(stylePromptText(title, "accent"));
|
|
173
|
+
previousLog(stylePromptText(stageText, failed ? "danger" : running ? "accent" : "success"));
|
|
174
|
+
previousLog("");
|
|
175
|
+
const lines = captured.slice(-maxVisibleLines);
|
|
176
|
+
for (const line of lines) {
|
|
177
|
+
previousLog(line);
|
|
178
|
+
}
|
|
179
|
+
const remainingLines = Math.max(0, maxVisibleLines - lines.length);
|
|
180
|
+
for (let i = 0; i < remainingLines; i += 1) {
|
|
181
|
+
previousLog("");
|
|
182
|
+
}
|
|
183
|
+
previousLog("");
|
|
184
|
+
if (running)
|
|
185
|
+
previousLog(stylePromptText(UI_COPY.returnFlow.working, "muted"));
|
|
186
|
+
frame += 1;
|
|
187
|
+
};
|
|
188
|
+
console.log = (...args) => {
|
|
189
|
+
capture("", args);
|
|
190
|
+
};
|
|
191
|
+
console.warn = (...args) => {
|
|
192
|
+
capture("! ", args);
|
|
193
|
+
};
|
|
194
|
+
console.error = (...args) => {
|
|
195
|
+
capture("x ", args);
|
|
196
|
+
};
|
|
197
|
+
output.write(ANSI.altScreenOn + ANSI.hide);
|
|
198
|
+
let timer = null;
|
|
199
|
+
try {
|
|
200
|
+
render();
|
|
201
|
+
timer = setInterval(() => {
|
|
202
|
+
if (!running)
|
|
203
|
+
return;
|
|
204
|
+
render();
|
|
205
|
+
}, 120);
|
|
206
|
+
await action();
|
|
207
|
+
}
|
|
208
|
+
catch (error) {
|
|
209
|
+
failed = error;
|
|
210
|
+
capture("x ", [error instanceof Error ? error.message : String(error)]);
|
|
211
|
+
}
|
|
212
|
+
finally {
|
|
213
|
+
running = false;
|
|
214
|
+
if (timer) {
|
|
215
|
+
clearInterval(timer);
|
|
216
|
+
timer = null;
|
|
217
|
+
}
|
|
218
|
+
render();
|
|
219
|
+
console.log = previousLog;
|
|
220
|
+
console.warn = previousWarn;
|
|
221
|
+
console.error = previousError;
|
|
222
|
+
}
|
|
223
|
+
if (failed) {
|
|
224
|
+
await waitForMenuReturn({
|
|
225
|
+
promptText: UI_COPY.returnFlow.actionFailedPrompt,
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
await waitForMenuReturn({
|
|
230
|
+
autoReturnMs: settings?.actionAutoReturnMs ?? 2_000,
|
|
231
|
+
pauseOnAnyKey: settings?.actionPauseOnKey ?? true,
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
output.write(ANSI.altScreenOff + ANSI.show + ANSI.clearScreen + ANSI.moveTo(1, 1));
|
|
235
|
+
if (failed) {
|
|
236
|
+
throw failed;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type RepairCommandDeps } from "./repair-commands.js";
|
|
2
|
+
/**
|
|
3
|
+
* Interactive control loop for the `login` command: the account dashboard menu
|
|
4
|
+
* and the add-account/onboarding flow. Moved verbatim out of
|
|
5
|
+
* lib/codex-manager.ts (audit roadmap §4.1.1 phase 4); the menu quota-refresh
|
|
6
|
+
* bookkeeping that previously lived in closure-mutable variables is now an
|
|
7
|
+
* explicit {@link MenuQuotaRefreshState} created in runAuthLoginFlow and passed
|
|
8
|
+
* through.
|
|
9
|
+
*/
|
|
10
|
+
/** @internal */
|
|
11
|
+
export interface LoginFlowDeps {
|
|
12
|
+
runForecast(args: string[]): Promise<number>;
|
|
13
|
+
createRepairCommandDeps(): RepairCommandDeps;
|
|
14
|
+
}
|
|
15
|
+
/** @internal */
|
|
16
|
+
export declare function runAuthLogin(args: string[], deps: LoginFlowDeps): Promise<number>;
|
|
17
|
+
//# sourceMappingURL=login-flow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login-flow.d.ts","sourceRoot":"","sources":["../../../lib/codex-manager/login-flow.ts"],"names":[],"mappings":"AAmDA,OAAO,EACN,KAAK,iBAAiB,EAGtB,MAAM,sBAAsB,CAAC;AAM9B;;;;;;;GAOG;AAEH,gBAAgB;AAChB,MAAM,WAAW,aAAa;IAC7B,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7C,uBAAuB,IAAI,iBAAiB,CAAC;CAC7C;AAkCD,gBAAgB;AAChB,wBAAsB,YAAY,CACjC,IAAI,EAAE,MAAM,EAAE,EACd,IAAI,EAAE,aAAa,GACjB,OAAO,CAAC,MAAM,CAAC,CAqBjB"}
|