codex-multi-auth 2.17.2 → 2.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.codex-plugin/plugin.json +1 -1
- package/README.md +86 -425
- package/config/README.md +1 -1
- package/config/codex-legacy.json +12 -212
- package/config/codex-modern.json +4 -80
- package/config/minimal-codex.json +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/lib/account-policy.d.ts +18 -2
- package/dist/lib/account-policy.js +97 -40
- package/dist/lib/accounts/rate-limits.d.ts +0 -1
- package/dist/lib/accounts.d.ts +0 -1
- package/dist/lib/accounts.js +4 -5
- package/dist/lib/api-route-store.d.ts +0 -1
- package/dist/lib/audit.d.ts +0 -1
- package/dist/lib/audit.js +43 -12
- package/dist/lib/auth/account-access.d.ts +0 -1
- package/dist/lib/auth/account-access.js +5 -1
- package/dist/lib/auth/auth.d.ts +4 -3
- package/dist/lib/auth/auth.js +220 -28
- package/dist/lib/auth/browser.d.ts +0 -1
- package/dist/lib/auth/callback-guidance.d.ts +0 -1
- package/dist/lib/auth/device-auth.d.ts +0 -1
- package/dist/lib/auth/index.d.ts +0 -1
- package/dist/lib/auth/org-override.d.ts +0 -1
- package/dist/lib/auth/server.d.ts +1 -2
- package/dist/lib/auth/server.js +100 -53
- package/dist/lib/auth/token-utils.d.ts +0 -1
- package/dist/lib/auth-rate-limit.d.ts +0 -1
- package/dist/lib/budget-guard.d.ts +16 -2
- package/dist/lib/budget-guard.js +123 -43
- package/dist/lib/capability-policy.d.ts +0 -1
- package/dist/lib/circuit-breaker.d.ts +20 -1
- package/dist/lib/circuit-breaker.js +24 -5
- package/dist/lib/cli.d.ts +0 -1
- package/dist/lib/codex-cli/index.d.ts +0 -1
- package/dist/lib/codex-cli/observability.d.ts +0 -1
- package/dist/lib/codex-cli/state.d.ts +0 -1
- package/dist/lib/codex-cli/sync.d.ts +0 -1
- package/dist/lib/codex-cli/writer.d.ts +0 -1
- package/dist/lib/codex-manager/account-credentials.d.ts +0 -1
- package/dist/lib/codex-manager/account-manager-commands.d.ts +0 -1
- package/dist/lib/codex-manager/account-pool-write.d.ts +0 -1
- package/dist/lib/codex-manager/active-account-sync.d.ts +6 -0
- package/dist/lib/codex-manager/active-account-sync.js +336 -0
- package/dist/lib/codex-manager/api-login-menu.d.ts +0 -1
- package/dist/lib/codex-manager/backend-category-entry.d.ts +0 -1
- package/dist/lib/codex-manager/backend-category-helpers.d.ts +0 -1
- package/dist/lib/codex-manager/backend-category-prompt.d.ts +0 -1
- package/dist/lib/codex-manager/backend-settings-controller.d.ts +0 -1
- package/dist/lib/codex-manager/backend-settings-entry.d.ts +0 -1
- package/dist/lib/codex-manager/backend-settings-helpers.d.ts +0 -1
- package/dist/lib/codex-manager/backend-settings-prompt.d.ts +0 -1
- package/dist/lib/codex-manager/backend-settings-schema.d.ts +0 -1
- package/dist/lib/codex-manager/behavior-settings-panel.d.ts +0 -1
- package/dist/lib/codex-manager/commands/account.d.ts +8 -3
- package/dist/lib/codex-manager/commands/account.js +46 -34
- package/dist/lib/codex-manager/commands/best.d.ts +0 -1
- package/dist/lib/codex-manager/commands/bridge.d.ts +0 -1
- package/dist/lib/codex-manager/commands/budget.d.ts +8 -3
- package/dist/lib/codex-manager/commands/budget.js +6 -4
- package/dist/lib/codex-manager/commands/check.d.ts +0 -1
- package/dist/lib/codex-manager/commands/config-explain.d.ts +0 -1
- package/dist/lib/codex-manager/commands/debug-bundle.d.ts +0 -1
- package/dist/lib/codex-manager/commands/forecast.d.ts +0 -1
- package/dist/lib/codex-manager/commands/history.d.ts +0 -1
- package/dist/lib/codex-manager/commands/init-config.d.ts +0 -1
- package/dist/lib/codex-manager/commands/integrations.d.ts +0 -1
- package/dist/lib/codex-manager/commands/limits.d.ts +0 -1
- package/dist/lib/codex-manager/commands/models.d.ts +0 -1
- package/dist/lib/codex-manager/commands/monitor.d.ts +0 -1
- package/dist/lib/codex-manager/commands/report.d.ts +0 -1
- package/dist/lib/codex-manager/commands/resets.d.ts +0 -1
- package/dist/lib/codex-manager/commands/resets.js +9 -1
- package/dist/lib/codex-manager/commands/rotation.d.ts +0 -1
- package/dist/lib/codex-manager/commands/status.d.ts +0 -1
- package/dist/lib/codex-manager/commands/switch.d.ts +0 -1
- package/dist/lib/codex-manager/commands/uninstall.d.ts +0 -1
- package/dist/lib/codex-manager/commands/unpin.d.ts +0 -1
- package/dist/lib/codex-manager/commands/usage.d.ts +0 -1
- package/dist/lib/codex-manager/commands/verify.d.ts +0 -1
- package/dist/lib/codex-manager/commands/why-selected.d.ts +0 -1
- package/dist/lib/codex-manager/commands/workspace.d.ts +0 -1
- package/dist/lib/codex-manager/dashboard-display-panel.d.ts +0 -1
- package/dist/lib/codex-manager/dashboard-formatters.d.ts +0 -1
- package/dist/lib/codex-manager/dashboard-settings-controller.d.ts +0 -1
- package/dist/lib/codex-manager/dashboard-settings-data.d.ts +0 -1
- package/dist/lib/codex-manager/dashboard-settings-entry.d.ts +0 -1
- package/dist/lib/codex-manager/experimental-settings-entry.d.ts +0 -1
- package/dist/lib/codex-manager/experimental-settings-prompt.d.ts +0 -1
- package/dist/lib/codex-manager/experimental-settings-schema.d.ts +0 -1
- package/dist/lib/codex-manager/experimental-sync-target-entry.d.ts +0 -1
- package/dist/lib/codex-manager/experimental-sync-target.d.ts +0 -1
- package/dist/lib/codex-manager/forecast-report-shared.d.ts +0 -1
- package/dist/lib/codex-manager/formatters/account-formatters.d.ts +0 -1
- package/dist/lib/codex-manager/formatters/index.d.ts +0 -1
- package/dist/lib/codex-manager/formatters/model-formatters.d.ts +0 -1
- package/dist/lib/codex-manager/formatters/quota-formatters.d.ts +0 -1
- package/dist/lib/codex-manager/formatters/text-style.d.ts +0 -1
- package/dist/lib/codex-manager/health-check.d.ts +0 -1
- package/dist/lib/codex-manager/help.d.ts +0 -1
- package/dist/lib/codex-manager/login-action-panel.d.ts +0 -1
- package/dist/lib/codex-manager/login-flow.d.ts +0 -1
- package/dist/lib/codex-manager/login-menu-actions.d.ts +0 -1
- package/dist/lib/codex-manager/login-menu-data.d.ts +0 -1
- package/dist/lib/codex-manager/login-oauth.d.ts +0 -1
- package/dist/lib/codex-manager/login-workspace-choice.d.ts +0 -1
- package/dist/lib/codex-manager/manual-callback.d.ts +0 -1
- package/dist/lib/codex-manager/persist-selected-account.d.ts +0 -1
- package/dist/lib/codex-manager/quota-cache-helpers.d.ts +0 -1
- package/dist/lib/codex-manager/rate-limit-markers.d.ts +0 -1
- package/dist/lib/codex-manager/repair-commands.d.ts +0 -1
- package/dist/lib/codex-manager/settings-hub/backend.d.ts +0 -1
- package/dist/lib/codex-manager/settings-hub/dashboard.d.ts +0 -1
- package/dist/lib/codex-manager/settings-hub/experimental.d.ts +0 -1
- package/dist/lib/codex-manager/settings-hub/index.d.ts +0 -1
- package/dist/lib/codex-manager/settings-hub/shared.d.ts +0 -1
- package/dist/lib/codex-manager/settings-hub-entry.d.ts +0 -1
- package/dist/lib/codex-manager/settings-hub-menu.d.ts +0 -1
- package/dist/lib/codex-manager/settings-hub-prompt.d.ts +0 -1
- package/dist/lib/codex-manager/settings-hub.d.ts +0 -1
- package/dist/lib/codex-manager/settings-panels.d.ts +0 -1
- package/dist/lib/codex-manager/settings-persist-utils.d.ts +0 -1
- package/dist/lib/codex-manager/settings-preview.d.ts +0 -1
- package/dist/lib/codex-manager/settings-write-queue.d.ts +0 -1
- package/dist/lib/codex-manager/statusline-settings-panel.d.ts +0 -1
- package/dist/lib/codex-manager/theme-settings-panel.d.ts +0 -1
- package/dist/lib/codex-manager/unified-settings-controller.d.ts +0 -1
- package/dist/lib/codex-manager/unified-settings-entry.d.ts +0 -1
- package/dist/lib/codex-manager.d.ts +1 -2
- package/dist/lib/codex-manager.js +5 -95
- package/dist/lib/concurrency.d.ts +0 -1
- package/dist/lib/config-schema.d.ts +0 -1
- package/dist/lib/config.d.ts +0 -1
- package/dist/lib/config.js +46 -241
- package/dist/lib/constants.d.ts +0 -1
- package/dist/lib/context-budget/model-context-windows.d.ts +1 -2
- package/dist/lib/context-budget/model-context-windows.js +10 -13
- package/dist/lib/context-budget-guard.d.ts +0 -1
- package/dist/lib/context-budget-response.d.ts +0 -1
- package/dist/lib/context-overflow.d.ts +0 -1
- package/dist/lib/dashboard-settings.d.ts +0 -1
- package/dist/lib/entitlement-cache.d.ts +0 -1
- package/dist/lib/env-parsing.d.ts +13 -1
- package/dist/lib/env-parsing.js +21 -0
- package/dist/lib/errors.d.ts +0 -1
- package/dist/lib/forecast.d.ts +0 -1
- package/dist/lib/fs-retry.d.ts +0 -1
- package/dist/lib/health.d.ts +0 -1
- package/dist/lib/index.d.ts +0 -1
- package/dist/lib/integration-generators.d.ts +0 -1
- package/dist/lib/live-account-sync.d.ts +0 -1
- package/dist/lib/local-bridge.d.ts +0 -1
- package/dist/lib/local-bridge.js +4 -1
- package/dist/lib/local-client-tokens.d.ts +0 -1
- package/dist/lib/local-client-tokens.js +125 -30
- package/dist/lib/logger.d.ts +0 -1
- package/dist/lib/logger.js +11 -1
- package/dist/lib/model-capability-matrix.d.ts +0 -1
- package/dist/lib/model-route-policy.d.ts +1 -2
- package/dist/lib/named-backup-export.d.ts +0 -1
- package/dist/lib/oc-chatgpt-import-adapter.d.ts +0 -1
- package/dist/lib/oc-chatgpt-orchestrator.d.ts +0 -1
- package/dist/lib/oc-chatgpt-target-detection.d.ts +3 -3
- package/dist/lib/oc-chatgpt-target-detection.js +40 -13
- package/dist/lib/parallel-probe.d.ts +0 -1
- package/dist/lib/policy/runtime-policy-cache.d.ts +80 -0
- package/dist/lib/policy/runtime-policy-cache.js +310 -0
- package/dist/lib/policy/runtime-policy.d.ts +1 -2
- package/dist/lib/policy/runtime-policy.js +46 -19
- package/dist/lib/preemptive-quota-scheduler.d.ts +0 -1
- package/dist/lib/proactive-refresh.d.ts +0 -1
- package/dist/lib/prompts/codex-host-bridge.d.ts +0 -1
- package/dist/lib/prompts/codex.d.ts +0 -1
- package/dist/lib/prompts/fetch-utils.d.ts +0 -1
- package/dist/lib/prompts/host-codex-prompt.d.ts +0 -1
- package/dist/lib/quota-cache.d.ts +0 -1
- package/dist/lib/quota-cache.js +60 -36
- package/dist/lib/quota-probe.d.ts +0 -1
- package/dist/lib/quota-probe.js +5 -2
- package/dist/lib/quota-readiness.d.ts +0 -1
- package/dist/lib/recovery/constants.d.ts +0 -1
- package/dist/lib/recovery/storage.d.ts +0 -1
- package/dist/lib/recovery/types.d.ts +0 -1
- package/dist/lib/recovery.d.ts +0 -1
- package/dist/lib/redaction.d.ts +0 -1
- package/dist/lib/refresh-guardian.d.ts +0 -1
- package/dist/lib/refresh-lease.d.ts +0 -1
- package/dist/lib/refresh-queue.d.ts +0 -1
- package/dist/lib/request/client-cancellation.d.ts +0 -1
- package/dist/lib/request/error-classification.d.ts +0 -1
- package/dist/lib/request/error-classification.js +41 -52
- package/dist/lib/request/failover-config.d.ts +0 -1
- package/dist/lib/request/failure-policy.d.ts +0 -1
- package/dist/lib/request/fetch-helpers.d.ts +0 -1
- package/dist/lib/request/fetch-helpers.js +1 -1
- package/dist/lib/request/headers.d.ts +0 -1
- package/dist/lib/request/helpers/input-utils.d.ts +0 -1
- package/dist/lib/request/helpers/input-utils.js +88 -34
- package/dist/lib/request/helpers/model-map.d.ts +2 -3
- package/dist/lib/request/helpers/model-map.js +120 -78
- package/dist/lib/request/helpers/tool-utils.d.ts +0 -1
- package/dist/lib/request/helpers/tool-utils.js +421 -4
- package/dist/lib/request/index.d.ts +0 -1
- package/dist/lib/request/rate-limit-backoff.d.ts +0 -1
- package/dist/lib/request/rate-limit-decision.d.ts +0 -1
- package/dist/lib/request/request-attempt-budget.d.ts +0 -1
- package/dist/lib/request/request-init.d.ts +0 -1
- package/dist/lib/request/request-resilience.d.ts +0 -1
- package/dist/lib/request/request-transformer.d.ts +1 -2
- package/dist/lib/request/request-transformer.js +51 -26
- package/dist/lib/request/response-compaction.d.ts +0 -1
- package/dist/lib/request/response-handler.d.ts +0 -1
- package/dist/lib/request/response-metadata.d.ts +0 -1
- package/dist/lib/request/response-outcome.d.ts +0 -1
- package/dist/lib/request/stream-failover-runtime.d.ts +0 -1
- package/dist/lib/request/stream-failover.d.ts +0 -1
- package/dist/lib/request/stream-failover.js +28 -4
- package/dist/lib/request/token-refresh.d.ts +0 -1
- package/dist/lib/request/url-rewriting.d.ts +0 -1
- package/dist/lib/request/wait-utils.d.ts +0 -1
- package/dist/lib/rotation.d.ts +0 -1
- package/dist/lib/routing-mutex.d.ts +0 -1
- package/dist/lib/routing-profiles.d.ts +16 -2
- package/dist/lib/routing-profiles.js +119 -44
- package/dist/lib/runtime/account-check-helpers.d.ts +0 -1
- package/dist/lib/runtime/account-check-types.d.ts +0 -1
- package/dist/lib/runtime/account-check.d.ts +0 -1
- package/dist/lib/runtime/account-manager-cache-entry.d.ts +0 -1
- package/dist/lib/runtime/account-manager-cache.d.ts +0 -1
- package/dist/lib/runtime/account-model-catalog.d.ts +1 -2
- package/dist/lib/runtime/account-pool.d.ts +0 -1
- package/dist/lib/runtime/account-reset-credits.d.ts +0 -1
- package/dist/lib/runtime/account-reset-credits.js +8 -2
- package/dist/lib/runtime/account-scope.d.ts +0 -1
- package/dist/lib/runtime/account-select-event.d.ts +0 -1
- package/dist/lib/runtime/account-selection.d.ts +0 -1
- package/dist/lib/runtime/account-state.d.ts +0 -1
- package/dist/lib/runtime/account-status.d.ts +0 -1
- package/dist/lib/runtime/account-storage-scope-entry.d.ts +0 -1
- package/dist/lib/runtime/api-model-capabilities.d.ts +0 -1
- package/dist/lib/runtime/api-model-runtime.d.ts +0 -1
- package/dist/lib/runtime/app-bind.d.ts +0 -1
- package/dist/lib/runtime/app-helper-selection.d.ts +0 -1
- package/dist/lib/runtime/auth-facade.d.ts +0 -1
- package/dist/lib/runtime/automatic-account-checks.d.ts +0 -1
- package/dist/lib/runtime/automatic-subscription-checks.d.ts +0 -1
- package/dist/lib/runtime/browser-oauth-flow.d.ts +0 -1
- package/dist/lib/runtime/capability-boost.d.ts +0 -1
- package/dist/lib/runtime/catalog-capabilities.d.ts +0 -1
- package/dist/lib/runtime/config-toml.d.ts +0 -1
- package/dist/lib/runtime/context-budget-settings.d.ts +0 -1
- package/dist/lib/runtime/event-handler.d.ts +0 -1
- package/dist/lib/runtime/first-run.d.ts +0 -1
- package/dist/lib/runtime/flagged-verify-types.d.ts +0 -1
- package/dist/lib/runtime/hydrate-emails.d.ts +0 -1
- package/dist/lib/runtime/inference-activity.d.ts +0 -1
- package/dist/lib/runtime/live-sync-entry.d.ts +0 -1
- package/dist/lib/runtime/live-sync.d.ts +0 -1
- package/dist/lib/runtime/loader-setup.d.ts +0 -1
- package/dist/lib/runtime/login-menu-accounts.d.ts +0 -1
- package/dist/lib/runtime/manual-oauth-flow.d.ts +0 -1
- package/dist/lib/runtime/model-discovery-status.d.ts +0 -1
- package/dist/lib/runtime/native-account-storage.d.ts +0 -1
- package/dist/lib/runtime/native-account-sync.d.ts +0 -1
- package/dist/lib/runtime/native-binding-lock.d.ts +0 -1
- package/dist/lib/runtime/native-client-auth.d.ts +0 -1
- package/dist/lib/runtime/native-provider-config.d.ts +0 -1
- package/dist/lib/runtime/native-rate-limits.d.ts +2 -1
- package/dist/lib/runtime/native-rate-limits.js +23 -6
- package/dist/lib/runtime/preemptive-quota.d.ts +0 -1
- package/dist/lib/runtime/quota-headers.d.ts +0 -1
- package/dist/lib/runtime/quota-probe.d.ts +0 -1
- package/dist/lib/runtime/quota-settings.d.ts +0 -1
- package/dist/lib/runtime/refresh-guardian-entry.d.ts +0 -1
- package/dist/lib/runtime/refresh-guardian.d.ts +0 -1
- package/dist/lib/runtime/request-init.d.ts +0 -1
- package/dist/lib/runtime/reset-credit-routing.d.ts +0 -1
- package/dist/lib/runtime/reset-credits.d.ts +0 -1
- package/dist/lib/runtime/response-output-history.d.ts +0 -1
- package/dist/lib/runtime/responses-websocket.d.ts +0 -1
- package/dist/lib/runtime/resume-picker.d.ts +0 -1
- package/dist/lib/runtime/rotation-account-selection.d.ts +0 -1
- package/dist/lib/runtime/rotation-proxy-state.d.ts +0 -1
- package/dist/lib/runtime/rotation-server-types.d.ts +0 -1
- package/dist/lib/runtime/rotation-storage-meta.d.ts +0 -1
- package/dist/lib/runtime/rotation-token-refresh.d.ts +0 -1
- package/dist/lib/runtime/runtime-capability-failures.d.ts +0 -1
- package/dist/lib/runtime/runtime-current-account.d.ts +0 -1
- package/dist/lib/runtime/runtime-observability.d.ts +0 -1
- package/dist/lib/runtime/runtime-services.d.ts +0 -1
- package/dist/lib/runtime/session-affinity-entry.d.ts +0 -1
- package/dist/lib/runtime/session-recovery.d.ts +0 -1
- package/dist/lib/runtime/status-marker.d.ts +0 -1
- package/dist/lib/runtime/storage-scope.d.ts +0 -1
- package/dist/lib/runtime/subscription-first-use.d.ts +0 -1
- package/dist/lib/runtime/subscription-quota-event.d.ts +0 -1
- package/dist/lib/runtime/subscription-quota-order.d.ts +0 -1
- package/dist/lib/runtime/toast.d.ts +0 -1
- package/dist/lib/runtime/ui-runtime-entry.d.ts +0 -1
- package/dist/lib/runtime/ui-runtime.d.ts +0 -1
- package/dist/lib/runtime/verify-flagged.d.ts +0 -1
- package/dist/lib/runtime/workspace-model-scopes.d.ts +0 -1
- package/dist/lib/runtime-constants.d.ts +0 -1
- package/dist/lib/runtime-paths.d.ts +0 -1
- package/dist/lib/runtime-rotation-proxy.d.ts +1 -1
- package/dist/lib/runtime-rotation-proxy.js +133 -0
- package/dist/lib/schemas.d.ts +35 -13
- package/dist/lib/schemas.js +19 -2
- package/dist/lib/session-affinity.d.ts +0 -1
- package/dist/lib/shutdown.d.ts +0 -1
- package/dist/lib/storage/account-clear-entry.d.ts +0 -1
- package/dist/lib/storage/account-clear.d.ts +0 -1
- package/dist/lib/storage/account-match-utils.d.ts +0 -1
- package/dist/lib/storage/account-persistence.d.ts +0 -1
- package/dist/lib/storage/account-port.d.ts +0 -1
- package/dist/lib/storage/account-save-entry.d.ts +0 -1
- package/dist/lib/storage/account-save.d.ts +9 -2
- package/dist/lib/storage/account-save.js +4 -1
- package/dist/lib/storage/account-snapshot.d.ts +0 -1
- package/dist/lib/storage/backup-metadata-builder.d.ts +0 -1
- package/dist/lib/storage/backup-metadata.d.ts +0 -1
- package/dist/lib/storage/backup-paths.d.ts +0 -1
- package/dist/lib/storage/backup-restore.d.ts +0 -1
- package/dist/lib/storage/cache-artifacts.d.ts +0 -1
- package/dist/lib/storage/credential-sidecars.d.ts +0 -1
- package/dist/lib/storage/error-hints.d.ts +0 -1
- package/dist/lib/storage/file-lock.d.ts +0 -1
- package/dist/lib/storage/file-lock.js +33 -1
- package/dist/lib/storage/file-paths.d.ts +0 -1
- package/dist/lib/storage/fixture-guards.d.ts +0 -1
- package/dist/lib/storage/flagged-entry.d.ts +0 -1
- package/dist/lib/storage/flagged-load-entry.d.ts +0 -1
- package/dist/lib/storage/flagged-save-entry.d.ts +0 -1
- package/dist/lib/storage/flagged-storage-file.d.ts +0 -1
- package/dist/lib/storage/flagged-storage-io.d.ts +0 -1
- package/dist/lib/storage/flagged-storage.d.ts +0 -1
- package/dist/lib/storage/gitignore.d.ts +0 -1
- package/dist/lib/storage/hash.d.ts +0 -1
- package/dist/lib/storage/health.d.ts +0 -1
- package/dist/lib/storage/identity.d.ts +0 -1
- package/dist/lib/storage/import-export.d.ts +0 -1
- package/dist/lib/storage/json-store-lock.d.ts +105 -0
- package/dist/lib/storage/json-store-lock.js +259 -0
- package/dist/lib/storage/metadata-section.d.ts +0 -1
- package/dist/lib/storage/migrations.d.ts +0 -1
- package/dist/lib/storage/migrations.js +31 -18
- package/dist/lib/storage/named-backup-entry.d.ts +0 -1
- package/dist/lib/storage/named-backups-entry.d.ts +0 -1
- package/dist/lib/storage/named-backups.d.ts +0 -1
- package/dist/lib/storage/path-state.d.ts +0 -1
- package/dist/lib/storage/paths.d.ts +0 -1
- package/dist/lib/storage/pending-auth.d.ts +9 -3
- package/dist/lib/storage/pending-auth.js +30 -8
- package/dist/lib/storage/project-migration.d.ts +0 -1
- package/dist/lib/storage/public-types.d.ts +0 -1
- package/dist/lib/storage/record-identity.d.ts +0 -1
- package/dist/lib/storage/record-utils.d.ts +0 -1
- package/dist/lib/storage/restore-assessment.d.ts +0 -1
- package/dist/lib/storage/restore-backup-entry.d.ts +0 -1
- package/dist/lib/storage/restore-metadata.d.ts +0 -1
- package/dist/lib/storage/save-retry.d.ts +0 -1
- package/dist/lib/storage/snapshot-inspectors.d.ts +0 -1
- package/dist/lib/storage/snapshot-merge.d.ts +0 -1
- package/dist/lib/storage/storage-parser.d.ts +2 -1
- package/dist/lib/storage/storage-parser.js +10 -2
- package/dist/lib/storage/transactions.d.ts +0 -1
- package/dist/lib/storage.d.ts +15 -2
- package/dist/lib/storage.js +612 -25
- package/dist/lib/synthetic-response.d.ts +0 -1
- package/dist/lib/table-formatter.d.ts +0 -1
- package/dist/lib/temp-path.d.ts +0 -1
- package/dist/lib/tools/hashline-tools.d.ts +0 -1
- package/dist/lib/types.d.ts +0 -1
- package/dist/lib/ui/ansi.d.ts +0 -1
- package/dist/lib/ui/auth-menu-builder.d.ts +0 -1
- package/dist/lib/ui/auth-menu.d.ts +0 -1
- package/dist/lib/ui/check-progress.d.ts +0 -1
- package/dist/lib/ui/confirm.d.ts +0 -1
- package/dist/lib/ui/display-width.d.ts +0 -1
- package/dist/lib/ui/format.d.ts +0 -1
- package/dist/lib/ui/index.d.ts +0 -1
- package/dist/lib/ui/runtime.d.ts +0 -1
- package/dist/lib/ui/select.d.ts +0 -1
- package/dist/lib/ui/theme.d.ts +0 -1
- package/dist/lib/ui/ui-copy.d.ts +1 -2
- package/dist/lib/ui/ui-copy.js +1 -1
- package/dist/lib/unified-settings.d.ts +13 -11
- package/dist/lib/unified-settings.js +22 -14
- package/dist/lib/update-notice.d.ts +0 -1
- package/dist/lib/usage/index.d.ts +0 -1
- package/dist/lib/usage/ledger.d.ts +0 -1
- package/dist/lib/usage/pricing.d.ts +1 -2
- package/dist/lib/usage/pricing.js +41 -16
- package/dist/lib/usage/redaction.d.ts +0 -1
- package/dist/lib/usage/stream-usage-deferral.d.ts +0 -1
- package/dist/lib/usage/types.d.ts +0 -1
- package/dist/lib/usage/usage-extraction.d.ts +0 -1
- package/dist/lib/utils.d.ts +21 -1
- package/dist/lib/utils.js +31 -0
- package/dist/lib/wsl.d.ts +0 -1
- package/package.json +11 -5
- package/scripts/codex-bin-resolver.js +20 -1
- package/scripts/codex-multi-auth.js +7 -1
- package/scripts/codex.js +385 -89
- package/skills/codex-auth-setup/SKILL.md +73 -0
package/config/codex-legacy.json
CHANGED
|
@@ -165,8 +165,8 @@
|
|
|
165
165
|
"store": false
|
|
166
166
|
}
|
|
167
167
|
},
|
|
168
|
-
"gpt-6-
|
|
169
|
-
"name": "GPT 6
|
|
168
|
+
"gpt-6.1-sol-low": {
|
|
169
|
+
"name": "GPT 6.1 Sol Low (OAuth)",
|
|
170
170
|
"limit": {
|
|
171
171
|
"context": 272000,
|
|
172
172
|
"output": 128000
|
|
@@ -190,8 +190,8 @@
|
|
|
190
190
|
"store": false
|
|
191
191
|
}
|
|
192
192
|
},
|
|
193
|
-
"gpt-6-
|
|
194
|
-
"name": "GPT 6
|
|
193
|
+
"gpt-6.1-sol-medium": {
|
|
194
|
+
"name": "GPT 6.1 Sol Medium (OAuth)",
|
|
195
195
|
"limit": {
|
|
196
196
|
"context": 272000,
|
|
197
197
|
"output": 128000
|
|
@@ -215,8 +215,8 @@
|
|
|
215
215
|
"store": false
|
|
216
216
|
}
|
|
217
217
|
},
|
|
218
|
-
"gpt-6-
|
|
219
|
-
"name": "GPT 6
|
|
218
|
+
"gpt-6.1-sol-high": {
|
|
219
|
+
"name": "GPT 6.1 Sol High (OAuth)",
|
|
220
220
|
"limit": {
|
|
221
221
|
"context": 272000,
|
|
222
222
|
"output": 128000
|
|
@@ -240,8 +240,8 @@
|
|
|
240
240
|
"store": false
|
|
241
241
|
}
|
|
242
242
|
},
|
|
243
|
-
"gpt-6-
|
|
244
|
-
"name": "GPT 6
|
|
243
|
+
"gpt-6.1-sol-xhigh": {
|
|
244
|
+
"name": "GPT 6.1 Sol Xhigh (OAuth)",
|
|
245
245
|
"limit": {
|
|
246
246
|
"context": 272000,
|
|
247
247
|
"output": 128000
|
|
@@ -265,8 +265,8 @@
|
|
|
265
265
|
"store": false
|
|
266
266
|
}
|
|
267
267
|
},
|
|
268
|
-
"gpt-6-
|
|
269
|
-
"name": "GPT 6
|
|
268
|
+
"gpt-6.1-sol-max": {
|
|
269
|
+
"name": "GPT 6.1 Sol Max (OAuth)",
|
|
270
270
|
"limit": {
|
|
271
271
|
"context": 272000,
|
|
272
272
|
"output": 128000
|
|
@@ -290,8 +290,8 @@
|
|
|
290
290
|
"store": false
|
|
291
291
|
}
|
|
292
292
|
},
|
|
293
|
-
"gpt-6-
|
|
294
|
-
"name": "GPT 6
|
|
293
|
+
"gpt-6.1-sol-ultra": {
|
|
294
|
+
"name": "GPT 6.1 Sol Ultra (OAuth)",
|
|
295
295
|
"limit": {
|
|
296
296
|
"context": 272000,
|
|
297
297
|
"output": 128000
|
|
@@ -1014,206 +1014,6 @@
|
|
|
1014
1014
|
],
|
|
1015
1015
|
"store": false
|
|
1016
1016
|
}
|
|
1017
|
-
},
|
|
1018
|
-
"gpt-5.5-none": {
|
|
1019
|
-
"name": "GPT 5.5 None (OAuth)",
|
|
1020
|
-
"limit": {
|
|
1021
|
-
"context": 272000,
|
|
1022
|
-
"output": 128000
|
|
1023
|
-
},
|
|
1024
|
-
"modalities": {
|
|
1025
|
-
"input": [
|
|
1026
|
-
"text",
|
|
1027
|
-
"image"
|
|
1028
|
-
],
|
|
1029
|
-
"output": [
|
|
1030
|
-
"text"
|
|
1031
|
-
]
|
|
1032
|
-
},
|
|
1033
|
-
"options": {
|
|
1034
|
-
"reasoningEffort": "none",
|
|
1035
|
-
"reasoningSummary": "auto",
|
|
1036
|
-
"textVerbosity": "medium",
|
|
1037
|
-
"include": [
|
|
1038
|
-
"reasoning.encrypted_content"
|
|
1039
|
-
],
|
|
1040
|
-
"store": false
|
|
1041
|
-
}
|
|
1042
|
-
},
|
|
1043
|
-
"gpt-5.5-low": {
|
|
1044
|
-
"name": "GPT 5.5 Low (OAuth)",
|
|
1045
|
-
"limit": {
|
|
1046
|
-
"context": 272000,
|
|
1047
|
-
"output": 128000
|
|
1048
|
-
},
|
|
1049
|
-
"modalities": {
|
|
1050
|
-
"input": [
|
|
1051
|
-
"text",
|
|
1052
|
-
"image"
|
|
1053
|
-
],
|
|
1054
|
-
"output": [
|
|
1055
|
-
"text"
|
|
1056
|
-
]
|
|
1057
|
-
},
|
|
1058
|
-
"options": {
|
|
1059
|
-
"reasoningEffort": "low",
|
|
1060
|
-
"reasoningSummary": "auto",
|
|
1061
|
-
"textVerbosity": "medium",
|
|
1062
|
-
"include": [
|
|
1063
|
-
"reasoning.encrypted_content"
|
|
1064
|
-
],
|
|
1065
|
-
"store": false
|
|
1066
|
-
}
|
|
1067
|
-
},
|
|
1068
|
-
"gpt-5.5-medium": {
|
|
1069
|
-
"name": "GPT 5.5 Medium (OAuth)",
|
|
1070
|
-
"limit": {
|
|
1071
|
-
"context": 272000,
|
|
1072
|
-
"output": 128000
|
|
1073
|
-
},
|
|
1074
|
-
"modalities": {
|
|
1075
|
-
"input": [
|
|
1076
|
-
"text",
|
|
1077
|
-
"image"
|
|
1078
|
-
],
|
|
1079
|
-
"output": [
|
|
1080
|
-
"text"
|
|
1081
|
-
]
|
|
1082
|
-
},
|
|
1083
|
-
"options": {
|
|
1084
|
-
"reasoningEffort": "medium",
|
|
1085
|
-
"reasoningSummary": "auto",
|
|
1086
|
-
"textVerbosity": "medium",
|
|
1087
|
-
"include": [
|
|
1088
|
-
"reasoning.encrypted_content"
|
|
1089
|
-
],
|
|
1090
|
-
"store": false
|
|
1091
|
-
}
|
|
1092
|
-
},
|
|
1093
|
-
"gpt-5.5-high": {
|
|
1094
|
-
"name": "GPT 5.5 High (OAuth)",
|
|
1095
|
-
"limit": {
|
|
1096
|
-
"context": 272000,
|
|
1097
|
-
"output": 128000
|
|
1098
|
-
},
|
|
1099
|
-
"modalities": {
|
|
1100
|
-
"input": [
|
|
1101
|
-
"text",
|
|
1102
|
-
"image"
|
|
1103
|
-
],
|
|
1104
|
-
"output": [
|
|
1105
|
-
"text"
|
|
1106
|
-
]
|
|
1107
|
-
},
|
|
1108
|
-
"options": {
|
|
1109
|
-
"reasoningEffort": "high",
|
|
1110
|
-
"reasoningSummary": "detailed",
|
|
1111
|
-
"textVerbosity": "medium",
|
|
1112
|
-
"include": [
|
|
1113
|
-
"reasoning.encrypted_content"
|
|
1114
|
-
],
|
|
1115
|
-
"store": false
|
|
1116
|
-
}
|
|
1117
|
-
},
|
|
1118
|
-
"gpt-5.5-xhigh": {
|
|
1119
|
-
"name": "GPT 5.5 Extra High (OAuth)",
|
|
1120
|
-
"limit": {
|
|
1121
|
-
"context": 272000,
|
|
1122
|
-
"output": 128000
|
|
1123
|
-
},
|
|
1124
|
-
"modalities": {
|
|
1125
|
-
"input": [
|
|
1126
|
-
"text",
|
|
1127
|
-
"image"
|
|
1128
|
-
],
|
|
1129
|
-
"output": [
|
|
1130
|
-
"text"
|
|
1131
|
-
]
|
|
1132
|
-
},
|
|
1133
|
-
"options": {
|
|
1134
|
-
"reasoningEffort": "xhigh",
|
|
1135
|
-
"reasoningSummary": "detailed",
|
|
1136
|
-
"textVerbosity": "medium",
|
|
1137
|
-
"include": [
|
|
1138
|
-
"reasoning.encrypted_content"
|
|
1139
|
-
],
|
|
1140
|
-
"store": false
|
|
1141
|
-
}
|
|
1142
|
-
},
|
|
1143
|
-
"gpt-5.5-pro-medium": {
|
|
1144
|
-
"name": "GPT 5.5 Pro Medium (OAuth)",
|
|
1145
|
-
"limit": {
|
|
1146
|
-
"context": 272000,
|
|
1147
|
-
"output": 128000
|
|
1148
|
-
},
|
|
1149
|
-
"modalities": {
|
|
1150
|
-
"input": [
|
|
1151
|
-
"text",
|
|
1152
|
-
"image"
|
|
1153
|
-
],
|
|
1154
|
-
"output": [
|
|
1155
|
-
"text"
|
|
1156
|
-
]
|
|
1157
|
-
},
|
|
1158
|
-
"options": {
|
|
1159
|
-
"reasoningEffort": "medium",
|
|
1160
|
-
"reasoningSummary": "detailed",
|
|
1161
|
-
"textVerbosity": "medium",
|
|
1162
|
-
"include": [
|
|
1163
|
-
"reasoning.encrypted_content"
|
|
1164
|
-
],
|
|
1165
|
-
"store": false
|
|
1166
|
-
}
|
|
1167
|
-
},
|
|
1168
|
-
"gpt-5.5-pro-high": {
|
|
1169
|
-
"name": "GPT 5.5 Pro High (OAuth)",
|
|
1170
|
-
"limit": {
|
|
1171
|
-
"context": 272000,
|
|
1172
|
-
"output": 128000
|
|
1173
|
-
},
|
|
1174
|
-
"modalities": {
|
|
1175
|
-
"input": [
|
|
1176
|
-
"text",
|
|
1177
|
-
"image"
|
|
1178
|
-
],
|
|
1179
|
-
"output": [
|
|
1180
|
-
"text"
|
|
1181
|
-
]
|
|
1182
|
-
},
|
|
1183
|
-
"options": {
|
|
1184
|
-
"reasoningEffort": "high",
|
|
1185
|
-
"reasoningSummary": "detailed",
|
|
1186
|
-
"textVerbosity": "medium",
|
|
1187
|
-
"include": [
|
|
1188
|
-
"reasoning.encrypted_content"
|
|
1189
|
-
],
|
|
1190
|
-
"store": false
|
|
1191
|
-
}
|
|
1192
|
-
},
|
|
1193
|
-
"gpt-5.5-pro-xhigh": {
|
|
1194
|
-
"name": "GPT 5.5 Pro Extra High (OAuth)",
|
|
1195
|
-
"limit": {
|
|
1196
|
-
"context": 272000,
|
|
1197
|
-
"output": 128000
|
|
1198
|
-
},
|
|
1199
|
-
"modalities": {
|
|
1200
|
-
"input": [
|
|
1201
|
-
"text",
|
|
1202
|
-
"image"
|
|
1203
|
-
],
|
|
1204
|
-
"output": [
|
|
1205
|
-
"text"
|
|
1206
|
-
]
|
|
1207
|
-
},
|
|
1208
|
-
"options": {
|
|
1209
|
-
"reasoningEffort": "xhigh",
|
|
1210
|
-
"reasoningSummary": "detailed",
|
|
1211
|
-
"textVerbosity": "medium",
|
|
1212
|
-
"include": [
|
|
1213
|
-
"reasoning.encrypted_content"
|
|
1214
|
-
],
|
|
1215
|
-
"store": false
|
|
1216
|
-
}
|
|
1217
1017
|
}
|
|
1218
1018
|
}
|
|
1219
1019
|
}
|
package/config/codex-modern.json
CHANGED
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
"store": false
|
|
16
16
|
},
|
|
17
17
|
"models": {
|
|
18
|
-
"gpt-6-
|
|
19
|
-
"name": "GPT 6
|
|
18
|
+
"gpt-6.1-sol": {
|
|
19
|
+
"name": "GPT 6.1 Sol (OAuth)",
|
|
20
20
|
"limit": {
|
|
21
21
|
"context": 272000,
|
|
22
22
|
"output": 128000
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
},
|
|
66
|
-
"gpt-6-astra
|
|
67
|
-
"name": "GPT 6 Astra
|
|
66
|
+
"gpt-6-astra": {
|
|
67
|
+
"name": "GPT 6 Astra (OAuth)",
|
|
68
68
|
"limit": {
|
|
69
69
|
"context": 272000,
|
|
70
70
|
"output": 128000
|
|
@@ -340,82 +340,6 @@
|
|
|
340
340
|
"textVerbosity": "medium"
|
|
341
341
|
}
|
|
342
342
|
}
|
|
343
|
-
},
|
|
344
|
-
"gpt-5.5": {
|
|
345
|
-
"name": "GPT 5.5 (OAuth)",
|
|
346
|
-
"limit": {
|
|
347
|
-
"context": 272000,
|
|
348
|
-
"output": 128000
|
|
349
|
-
},
|
|
350
|
-
"modalities": {
|
|
351
|
-
"input": [
|
|
352
|
-
"text",
|
|
353
|
-
"image"
|
|
354
|
-
],
|
|
355
|
-
"output": [
|
|
356
|
-
"text"
|
|
357
|
-
]
|
|
358
|
-
},
|
|
359
|
-
"variants": {
|
|
360
|
-
"none": {
|
|
361
|
-
"reasoningEffort": "none",
|
|
362
|
-
"reasoningSummary": "auto",
|
|
363
|
-
"textVerbosity": "medium"
|
|
364
|
-
},
|
|
365
|
-
"low": {
|
|
366
|
-
"reasoningEffort": "low",
|
|
367
|
-
"reasoningSummary": "auto",
|
|
368
|
-
"textVerbosity": "medium"
|
|
369
|
-
},
|
|
370
|
-
"medium": {
|
|
371
|
-
"reasoningEffort": "medium",
|
|
372
|
-
"reasoningSummary": "auto",
|
|
373
|
-
"textVerbosity": "medium"
|
|
374
|
-
},
|
|
375
|
-
"high": {
|
|
376
|
-
"reasoningEffort": "high",
|
|
377
|
-
"reasoningSummary": "detailed",
|
|
378
|
-
"textVerbosity": "medium"
|
|
379
|
-
},
|
|
380
|
-
"xhigh": {
|
|
381
|
-
"reasoningEffort": "xhigh",
|
|
382
|
-
"reasoningSummary": "detailed",
|
|
383
|
-
"textVerbosity": "medium"
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
},
|
|
387
|
-
"gpt-5.5-pro": {
|
|
388
|
-
"name": "GPT 5.5 Pro (OAuth)",
|
|
389
|
-
"limit": {
|
|
390
|
-
"context": 272000,
|
|
391
|
-
"output": 128000
|
|
392
|
-
},
|
|
393
|
-
"modalities": {
|
|
394
|
-
"input": [
|
|
395
|
-
"text",
|
|
396
|
-
"image"
|
|
397
|
-
],
|
|
398
|
-
"output": [
|
|
399
|
-
"text"
|
|
400
|
-
]
|
|
401
|
-
},
|
|
402
|
-
"variants": {
|
|
403
|
-
"medium": {
|
|
404
|
-
"reasoningEffort": "medium",
|
|
405
|
-
"reasoningSummary": "detailed",
|
|
406
|
-
"textVerbosity": "medium"
|
|
407
|
-
},
|
|
408
|
-
"high": {
|
|
409
|
-
"reasoningEffort": "high",
|
|
410
|
-
"reasoningSummary": "detailed",
|
|
411
|
-
"textVerbosity": "medium"
|
|
412
|
-
},
|
|
413
|
-
"xhigh": {
|
|
414
|
-
"reasoningEffort": "xhigh",
|
|
415
|
-
"reasoningSummary": "detailed",
|
|
416
|
-
"textVerbosity": "medium"
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
343
|
}
|
|
420
344
|
}
|
|
421
345
|
}
|
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
package/dist/lib/accounts.js
CHANGED
|
@@ -922,16 +922,15 @@ export class AccountManager {
|
|
|
922
922
|
if (shouldConsumeToken && !tokenTracker.tryConsume(trackerKey, quotaKey)) {
|
|
923
923
|
return { ok: false, reason: "token-exhausted" };
|
|
924
924
|
}
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
}
|
|
929
|
-
catch {
|
|
925
|
+
// Non-throwing probe keeps circuit-open storms off the exception path.
|
|
926
|
+
const admission = getCircuitBreaker(getAccountCircuitKey(account)).tryCanExecute();
|
|
927
|
+
if (!admission.ok) {
|
|
930
928
|
if (shouldConsumeToken) {
|
|
931
929
|
tokenTracker.refundToken(trackerKey, quotaKey);
|
|
932
930
|
}
|
|
933
931
|
return { ok: false, reason: "circuit-open" };
|
|
934
932
|
}
|
|
933
|
+
return { ok: true };
|
|
935
934
|
}
|
|
936
935
|
/**
|
|
937
936
|
* Refund a token consumed within the refund window (30 seconds).
|
|
@@ -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
|