codex-multi-auth 2.17.0 → 2.17.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.codex-plugin/plugin.json +9 -9
- package/LICENSE +21 -21
- package/README.md +142 -484
- package/assets/codex-multi-auth-icon.svg +39 -39
- package/assets/readme-hero.svg +31 -31
- package/config/README.md +31 -31
- package/config/codex-legacy.json +1221 -1221
- package/config/codex-modern.json +423 -423
- package/config/minimal-codex.json +15 -15
- package/dist/index.d.ts +0 -1
- package/dist/lib/account-policy.d.ts +18 -2
- package/dist/lib/account-policy.js +97 -40
- package/dist/lib/accounts/rate-limits.d.ts +0 -1
- package/dist/lib/accounts.d.ts +1 -8
- package/dist/lib/accounts.d.ts.map +1 -1
- package/dist/lib/accounts.js +7 -19
- package/dist/lib/api-route-store.d.ts +0 -1
- package/dist/lib/audit.d.ts +0 -1
- package/dist/lib/audit.js +43 -12
- package/dist/lib/auth/account-access.d.ts +0 -1
- package/dist/lib/auth/account-access.js +5 -1
- package/dist/lib/auth/auth.d.ts +4 -3
- package/dist/lib/auth/auth.js +220 -28
- package/dist/lib/auth/browser.d.ts +0 -1
- package/dist/lib/auth/callback-guidance.d.ts +0 -1
- package/dist/lib/auth/device-auth.d.ts +0 -1
- package/dist/lib/auth/index.d.ts +0 -1
- package/dist/lib/auth/org-override.d.ts +0 -1
- package/dist/lib/auth/server.d.ts +1 -2
- package/dist/lib/auth/server.js +100 -53
- package/dist/lib/auth/token-utils.d.ts +0 -1
- package/dist/lib/auth-rate-limit.d.ts +0 -1
- package/dist/lib/budget-guard.d.ts +16 -2
- package/dist/lib/budget-guard.js +123 -43
- package/dist/lib/capability-policy.d.ts +0 -1
- package/dist/lib/circuit-breaker.d.ts +20 -1
- package/dist/lib/circuit-breaker.js +24 -5
- package/dist/lib/cli.d.ts +0 -1
- package/dist/lib/codex-cli/index.d.ts +0 -1
- package/dist/lib/codex-cli/observability.d.ts +0 -1
- package/dist/lib/codex-cli/state.d.ts +0 -1
- package/dist/lib/codex-cli/sync.d.ts +0 -1
- package/dist/lib/codex-cli/writer.d.ts +0 -1
- package/dist/lib/codex-manager/account-credentials.d.ts +0 -1
- package/dist/lib/codex-manager/account-manager-commands.d.ts +0 -1
- package/dist/lib/codex-manager/account-pool-write.d.ts +0 -1
- package/dist/lib/codex-manager/active-account-sync.d.ts +6 -0
- package/dist/lib/codex-manager/active-account-sync.js +336 -0
- package/dist/lib/codex-manager/api-login-menu.d.ts +0 -1
- package/dist/lib/codex-manager/backend-category-entry.d.ts +0 -1
- package/dist/lib/codex-manager/backend-category-helpers.d.ts +0 -1
- package/dist/lib/codex-manager/backend-category-prompt.d.ts +0 -1
- package/dist/lib/codex-manager/backend-settings-controller.d.ts +0 -1
- package/dist/lib/codex-manager/backend-settings-entry.d.ts +0 -1
- package/dist/lib/codex-manager/backend-settings-helpers.d.ts +0 -1
- package/dist/lib/codex-manager/backend-settings-prompt.d.ts +0 -1
- package/dist/lib/codex-manager/backend-settings-schema.d.ts +0 -1
- package/dist/lib/codex-manager/behavior-settings-panel.d.ts +0 -1
- package/dist/lib/codex-manager/commands/account.d.ts +8 -3
- package/dist/lib/codex-manager/commands/account.js +46 -34
- package/dist/lib/codex-manager/commands/best.d.ts +0 -1
- package/dist/lib/codex-manager/commands/bridge.d.ts +0 -1
- package/dist/lib/codex-manager/commands/budget.d.ts +8 -3
- package/dist/lib/codex-manager/commands/budget.js +6 -4
- package/dist/lib/codex-manager/commands/check.d.ts +0 -1
- package/dist/lib/codex-manager/commands/config-explain.d.ts +0 -1
- package/dist/lib/codex-manager/commands/debug-bundle.d.ts +0 -1
- package/dist/lib/codex-manager/commands/forecast.d.ts +1 -2
- package/dist/lib/codex-manager/commands/forecast.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/forecast.js +2 -2
- package/dist/lib/codex-manager/commands/history.d.ts +0 -1
- package/dist/lib/codex-manager/commands/init-config.d.ts +0 -1
- package/dist/lib/codex-manager/commands/integrations.d.ts +0 -1
- package/dist/lib/codex-manager/commands/limits.d.ts +0 -1
- package/dist/lib/codex-manager/commands/models.d.ts +0 -1
- package/dist/lib/codex-manager/commands/monitor.d.ts +0 -1
- package/dist/lib/codex-manager/commands/report.d.ts +0 -1
- package/dist/lib/codex-manager/commands/resets.d.ts +0 -1
- package/dist/lib/codex-manager/commands/resets.js +9 -1
- package/dist/lib/codex-manager/commands/rotation.d.ts +0 -1
- package/dist/lib/codex-manager/commands/status.d.ts +0 -1
- package/dist/lib/codex-manager/commands/switch.d.ts +0 -1
- package/dist/lib/codex-manager/commands/uninstall.d.ts +0 -1
- package/dist/lib/codex-manager/commands/unpin.d.ts +0 -1
- package/dist/lib/codex-manager/commands/usage.d.ts +0 -1
- package/dist/lib/codex-manager/commands/verify.d.ts +0 -1
- package/dist/lib/codex-manager/commands/why-selected.d.ts +0 -1
- package/dist/lib/codex-manager/commands/workspace.d.ts +0 -1
- package/dist/lib/codex-manager/dashboard-display-panel.d.ts +0 -1
- package/dist/lib/codex-manager/dashboard-formatters.d.ts +0 -1
- package/dist/lib/codex-manager/dashboard-settings-controller.d.ts +0 -1
- package/dist/lib/codex-manager/dashboard-settings-data.d.ts +0 -1
- package/dist/lib/codex-manager/dashboard-settings-entry.d.ts +0 -1
- package/dist/lib/codex-manager/experimental-settings-entry.d.ts +0 -1
- package/dist/lib/codex-manager/experimental-settings-prompt.d.ts +0 -1
- package/dist/lib/codex-manager/experimental-settings-schema.d.ts +0 -1
- package/dist/lib/codex-manager/experimental-sync-target-entry.d.ts +0 -1
- package/dist/lib/codex-manager/experimental-sync-target.d.ts +0 -1
- package/dist/lib/codex-manager/forecast-report-shared.d.ts +0 -1
- package/dist/lib/codex-manager/formatters/account-formatters.d.ts +0 -1
- package/dist/lib/codex-manager/formatters/index.d.ts +0 -1
- package/dist/lib/codex-manager/formatters/model-formatters.d.ts +0 -1
- package/dist/lib/codex-manager/formatters/quota-formatters.d.ts +0 -1
- package/dist/lib/codex-manager/formatters/text-style.d.ts +0 -1
- package/dist/lib/codex-manager/health-check.d.ts +0 -1
- package/dist/lib/codex-manager/health-check.js +1 -1
- package/dist/lib/codex-manager/help.d.ts +0 -1
- package/dist/lib/codex-manager/login-action-panel.d.ts +0 -1
- package/dist/lib/codex-manager/login-flow.d.ts +0 -1
- package/dist/lib/codex-manager/login-menu-actions.d.ts +0 -1
- package/dist/lib/codex-manager/login-menu-data.d.ts +0 -1
- package/dist/lib/codex-manager/login-menu-data.d.ts.map +1 -1
- package/dist/lib/codex-manager/login-menu-data.js +7 -3
- package/dist/lib/codex-manager/login-oauth.d.ts +0 -1
- package/dist/lib/codex-manager/login-workspace-choice.d.ts +0 -1
- package/dist/lib/codex-manager/manual-callback.d.ts +0 -1
- package/dist/lib/codex-manager/persist-selected-account.d.ts +0 -1
- package/dist/lib/codex-manager/quota-cache-helpers.d.ts +7 -2
- package/dist/lib/codex-manager/quota-cache-helpers.d.ts.map +1 -1
- package/dist/lib/codex-manager/quota-cache-helpers.js +34 -19
- package/dist/lib/codex-manager/rate-limit-markers.d.ts +0 -1
- package/dist/lib/codex-manager/repair-commands.d.ts +0 -1
- package/dist/lib/codex-manager/repair-commands.js +1 -1
- package/dist/lib/codex-manager/settings-hub/backend.d.ts +0 -1
- package/dist/lib/codex-manager/settings-hub/dashboard.d.ts +0 -1
- package/dist/lib/codex-manager/settings-hub/experimental.d.ts +0 -1
- package/dist/lib/codex-manager/settings-hub/index.d.ts +0 -1
- package/dist/lib/codex-manager/settings-hub/shared.d.ts +0 -1
- package/dist/lib/codex-manager/settings-hub-entry.d.ts +0 -1
- package/dist/lib/codex-manager/settings-hub-menu.d.ts +0 -1
- package/dist/lib/codex-manager/settings-hub-prompt.d.ts +0 -1
- package/dist/lib/codex-manager/settings-hub.d.ts +0 -1
- package/dist/lib/codex-manager/settings-panels.d.ts +0 -1
- package/dist/lib/codex-manager/settings-persist-utils.d.ts +0 -1
- package/dist/lib/codex-manager/settings-preview.d.ts +0 -1
- package/dist/lib/codex-manager/settings-write-queue.d.ts +0 -1
- package/dist/lib/codex-manager/statusline-settings-panel.d.ts +0 -1
- package/dist/lib/codex-manager/theme-settings-panel.d.ts +0 -1
- package/dist/lib/codex-manager/unified-settings-controller.d.ts +0 -1
- package/dist/lib/codex-manager/unified-settings-entry.d.ts +0 -1
- package/dist/lib/codex-manager.d.ts +1 -2
- package/dist/lib/codex-manager.js +5 -95
- package/dist/lib/concurrency.d.ts +0 -1
- package/dist/lib/config-schema.d.ts +0 -1
- package/dist/lib/config.d.ts +0 -1
- package/dist/lib/config.js +46 -241
- package/dist/lib/constants.d.ts +0 -1
- package/dist/lib/context-budget/model-context-windows.d.ts +0 -1
- package/dist/lib/context-budget-guard.d.ts +0 -1
- package/dist/lib/context-budget-response.d.ts +0 -1
- package/dist/lib/context-budget-response.js +8 -8
- package/dist/lib/context-overflow.d.ts +0 -1
- package/dist/lib/context-overflow.js +10 -10
- package/dist/lib/dashboard-settings.d.ts +0 -1
- package/dist/lib/entitlement-cache.d.ts +0 -1
- package/dist/lib/env-parsing.d.ts +13 -1
- package/dist/lib/env-parsing.js +21 -0
- package/dist/lib/errors.d.ts +0 -1
- package/dist/lib/forecast.d.ts +0 -1
- package/dist/lib/fs-retry.d.ts +0 -1
- package/dist/lib/health.d.ts +0 -1
- package/dist/lib/index.d.ts +0 -1
- package/dist/lib/integration-generators.d.ts +0 -1
- package/dist/lib/live-account-sync.d.ts +0 -1
- package/dist/lib/local-bridge.d.ts +0 -1
- package/dist/lib/local-bridge.js +4 -1
- package/dist/lib/local-client-tokens.d.ts +0 -1
- package/dist/lib/local-client-tokens.js +125 -30
- package/dist/lib/logger.d.ts +0 -1
- package/dist/lib/logger.js +11 -1
- package/dist/lib/model-capability-matrix.d.ts +0 -1
- package/dist/lib/model-route-policy.d.ts +1 -2
- package/dist/lib/named-backup-export.d.ts +0 -1
- package/dist/lib/oauth-success.html +125 -125
- package/dist/lib/oc-chatgpt-import-adapter.d.ts +0 -1
- package/dist/lib/oc-chatgpt-orchestrator.d.ts +0 -1
- package/dist/lib/oc-chatgpt-target-detection.d.ts +0 -1
- package/dist/lib/parallel-probe.d.ts +0 -1
- package/dist/lib/policy/runtime-policy-cache.d.ts +80 -0
- package/dist/lib/policy/runtime-policy-cache.js +310 -0
- package/dist/lib/policy/runtime-policy.d.ts +1 -2
- package/dist/lib/policy/runtime-policy.js +46 -19
- package/dist/lib/preemptive-quota-scheduler.d.ts +0 -1
- package/dist/lib/proactive-refresh.d.ts +0 -1
- package/dist/lib/prompts/codex-host-bridge.d.ts +0 -1
- package/dist/lib/prompts/codex-host-bridge.js +138 -138
- package/dist/lib/prompts/codex.d.ts +0 -1
- package/dist/lib/prompts/codex.js +79 -79
- package/dist/lib/prompts/fetch-utils.d.ts +0 -1
- package/dist/lib/prompts/host-codex-prompt.d.ts +0 -1
- package/dist/lib/quota-cache.d.ts +7 -4
- package/dist/lib/quota-cache.d.ts.map +1 -1
- package/dist/lib/quota-cache.js +117 -61
- package/dist/lib/quota-probe.d.ts +0 -1
- package/dist/lib/quota-probe.js +5 -2
- package/dist/lib/quota-readiness.d.ts +7 -3
- package/dist/lib/quota-readiness.d.ts.map +1 -1
- package/dist/lib/quota-readiness.js +25 -4
- package/dist/lib/recovery/constants.d.ts +0 -1
- package/dist/lib/recovery/storage.d.ts +0 -1
- package/dist/lib/recovery/types.d.ts +0 -1
- package/dist/lib/recovery.d.ts +0 -1
- package/dist/lib/redaction.d.ts +0 -1
- package/dist/lib/refresh-guardian.d.ts +0 -1
- package/dist/lib/refresh-lease.d.ts +0 -1
- package/dist/lib/refresh-queue.d.ts +0 -1
- package/dist/lib/request/client-cancellation.d.ts +0 -1
- package/dist/lib/request/error-classification.d.ts +0 -1
- package/dist/lib/request/failover-config.d.ts +0 -1
- package/dist/lib/request/failure-policy.d.ts +0 -1
- package/dist/lib/request/fetch-helpers.d.ts +0 -1
- package/dist/lib/request/headers.d.ts +0 -1
- package/dist/lib/request/helpers/input-utils.d.ts +0 -1
- package/dist/lib/request/helpers/input-utils.js +88 -34
- package/dist/lib/request/helpers/model-map.d.ts +0 -1
- package/dist/lib/request/helpers/tool-utils.d.ts +0 -1
- package/dist/lib/request/helpers/tool-utils.js +421 -4
- package/dist/lib/request/index.d.ts +0 -1
- package/dist/lib/request/rate-limit-backoff.d.ts +0 -1
- package/dist/lib/request/rate-limit-decision.d.ts +0 -1
- package/dist/lib/request/request-attempt-budget.d.ts +0 -1
- package/dist/lib/request/request-init.d.ts +0 -1
- package/dist/lib/request/request-resilience.d.ts +0 -1
- package/dist/lib/request/request-transformer.d.ts +0 -1
- package/dist/lib/request/request-transformer.js +50 -25
- package/dist/lib/request/response-compaction.d.ts +0 -1
- package/dist/lib/request/response-handler.d.ts +0 -1
- package/dist/lib/request/response-metadata.d.ts +0 -1
- package/dist/lib/request/response-outcome.d.ts +0 -1
- package/dist/lib/request/stream-failover-runtime.d.ts +0 -1
- package/dist/lib/request/stream-failover.d.ts +0 -1
- package/dist/lib/request/stream-failover.js +28 -4
- package/dist/lib/request/token-refresh.d.ts +0 -1
- package/dist/lib/request/url-rewriting.d.ts +0 -1
- package/dist/lib/request/wait-utils.d.ts +0 -1
- package/dist/lib/rotation.d.ts +0 -1
- package/dist/lib/routing-mutex.d.ts +0 -1
- package/dist/lib/routing-profiles.d.ts +16 -2
- package/dist/lib/routing-profiles.js +119 -44
- package/dist/lib/runtime/account-check-helpers.d.ts +0 -1
- package/dist/lib/runtime/account-check-types.d.ts +0 -1
- package/dist/lib/runtime/account-check.d.ts +0 -1
- package/dist/lib/runtime/account-manager-cache-entry.d.ts +0 -1
- package/dist/lib/runtime/account-manager-cache.d.ts +0 -1
- package/dist/lib/runtime/account-model-catalog.d.ts +1 -2
- package/dist/lib/runtime/account-pool.d.ts +0 -1
- package/dist/lib/runtime/account-reset-credits.d.ts +0 -1
- package/dist/lib/runtime/account-reset-credits.js +8 -2
- package/dist/lib/runtime/account-scope.d.ts +0 -1
- package/dist/lib/runtime/account-select-event.d.ts +0 -1
- package/dist/lib/runtime/account-selection.d.ts +0 -1
- package/dist/lib/runtime/account-state.d.ts +0 -1
- package/dist/lib/runtime/account-status.d.ts +0 -1
- package/dist/lib/runtime/account-storage-scope-entry.d.ts +0 -1
- package/dist/lib/runtime/api-model-capabilities.d.ts +0 -1
- package/dist/lib/runtime/api-model-runtime.d.ts +0 -1
- package/dist/lib/runtime/app-bind.d.ts +0 -1
- package/dist/lib/runtime/app-bind.d.ts.map +1 -1
- package/dist/lib/runtime/app-bind.js +10 -2
- package/dist/lib/runtime/app-helper-selection.d.ts +0 -1
- package/dist/lib/runtime/auth-facade.d.ts +0 -1
- package/dist/lib/runtime/automatic-account-checks.d.ts +5 -2
- package/dist/lib/runtime/automatic-account-checks.d.ts.map +1 -1
- package/dist/lib/runtime/automatic-account-checks.js +29 -2
- package/dist/lib/runtime/automatic-subscription-checks.d.ts +1 -2
- package/dist/lib/runtime/automatic-subscription-checks.d.ts.map +1 -1
- package/dist/lib/runtime/automatic-subscription-checks.js +13 -16
- package/dist/lib/runtime/browser-oauth-flow.d.ts +0 -1
- package/dist/lib/runtime/capability-boost.d.ts +0 -1
- package/dist/lib/runtime/catalog-capabilities.d.ts +0 -1
- package/dist/lib/runtime/config-toml.d.ts +0 -1
- package/dist/lib/runtime/context-budget-settings.d.ts +0 -1
- package/dist/lib/runtime/event-handler.d.ts +0 -1
- package/dist/lib/runtime/first-run.d.ts +0 -1
- package/dist/lib/runtime/flagged-verify-types.d.ts +0 -1
- package/dist/lib/runtime/hydrate-emails.d.ts +0 -1
- package/dist/lib/runtime/inference-activity.d.ts +0 -1
- package/dist/lib/runtime/live-sync-entry.d.ts +0 -1
- package/dist/lib/runtime/live-sync.d.ts +0 -1
- package/dist/lib/runtime/loader-setup.d.ts +0 -1
- package/dist/lib/runtime/login-menu-accounts.d.ts +0 -1
- package/dist/lib/runtime/manual-oauth-flow.d.ts +0 -1
- package/dist/lib/runtime/model-discovery-status.d.ts +2 -3
- package/dist/lib/runtime/native-account-storage.d.ts +0 -1
- package/dist/lib/runtime/native-account-sync.d.ts +0 -1
- package/dist/lib/runtime/native-binding-lock.d.ts +0 -1
- package/dist/lib/runtime/native-client-auth.d.ts +0 -1
- package/dist/lib/runtime/native-provider-config.d.ts +0 -1
- package/dist/lib/runtime/native-rate-limits.d.ts +2 -1
- package/dist/lib/runtime/native-rate-limits.js +23 -6
- package/dist/lib/runtime/preemptive-quota.d.ts +0 -1
- package/dist/lib/runtime/quota-headers.d.ts +0 -1
- package/dist/lib/runtime/quota-probe.d.ts +0 -1
- package/dist/lib/runtime/quota-settings.d.ts +0 -1
- package/dist/lib/runtime/refresh-guardian-entry.d.ts +0 -1
- package/dist/lib/runtime/refresh-guardian.d.ts +0 -1
- package/dist/lib/runtime/request-init.d.ts +0 -1
- package/dist/lib/runtime/reset-credit-routing.d.ts +0 -1
- package/dist/lib/runtime/reset-credits.d.ts +0 -1
- package/dist/lib/runtime/response-output-history.d.ts +0 -1
- package/dist/lib/runtime/responses-websocket.d.ts +0 -1
- package/dist/lib/runtime/resume-picker.d.ts +0 -1
- package/dist/lib/runtime/rotation-account-selection.d.ts +0 -1
- package/dist/lib/runtime/rotation-proxy-state.d.ts +0 -1
- package/dist/lib/runtime/rotation-server-types.d.ts +0 -1
- package/dist/lib/runtime/rotation-storage-meta.d.ts +0 -1
- package/dist/lib/runtime/rotation-token-refresh.d.ts +0 -1
- package/dist/lib/runtime/runtime-capability-failures.d.ts +0 -1
- package/dist/lib/runtime/runtime-current-account.d.ts +0 -1
- package/dist/lib/runtime/runtime-observability.d.ts +0 -1
- package/dist/lib/runtime/runtime-services.d.ts +0 -1
- package/dist/lib/runtime/session-affinity-entry.d.ts +0 -1
- package/dist/lib/runtime/session-recovery.d.ts +0 -1
- package/dist/lib/runtime/status-marker.d.ts +0 -1
- package/dist/lib/runtime/storage-scope.d.ts +0 -1
- package/dist/lib/runtime/subscription-first-use.d.ts +0 -1
- package/dist/lib/runtime/subscription-quota-event.d.ts +0 -1
- package/dist/lib/runtime/subscription-quota-order.d.ts +0 -1
- package/dist/lib/runtime/toast.d.ts +0 -1
- package/dist/lib/runtime/ui-runtime-entry.d.ts +0 -1
- package/dist/lib/runtime/ui-runtime.d.ts +0 -1
- package/dist/lib/runtime/verify-flagged.d.ts +0 -1
- package/dist/lib/runtime/workspace-model-scopes.d.ts +0 -1
- package/dist/lib/runtime-constants.d.ts +0 -1
- package/dist/lib/runtime-paths.d.ts +0 -1
- package/dist/lib/runtime-rotation-proxy.d.ts +1 -1
- package/dist/lib/runtime-rotation-proxy.js +136 -3
- package/dist/lib/schemas.d.ts +35 -13
- package/dist/lib/schemas.js +19 -2
- package/dist/lib/session-affinity.d.ts +0 -1
- package/dist/lib/shutdown.d.ts +0 -1
- package/dist/lib/storage/account-clear-entry.d.ts +0 -1
- package/dist/lib/storage/account-clear.d.ts +0 -1
- package/dist/lib/storage/account-match-utils.d.ts +0 -1
- package/dist/lib/storage/account-persistence.d.ts +0 -1
- package/dist/lib/storage/account-port.d.ts +0 -1
- package/dist/lib/storage/account-save-entry.d.ts +0 -1
- package/dist/lib/storage/account-save.d.ts +9 -2
- package/dist/lib/storage/account-save.js +4 -1
- package/dist/lib/storage/account-snapshot.d.ts +0 -1
- package/dist/lib/storage/backup-metadata-builder.d.ts +0 -1
- package/dist/lib/storage/backup-metadata.d.ts +0 -1
- package/dist/lib/storage/backup-paths.d.ts +0 -1
- package/dist/lib/storage/backup-restore.d.ts +0 -1
- package/dist/lib/storage/cache-artifacts.d.ts +0 -1
- package/dist/lib/storage/credential-sidecars.d.ts +0 -1
- package/dist/lib/storage/error-hints.d.ts +0 -1
- package/dist/lib/storage/file-lock.d.ts +0 -1
- package/dist/lib/storage/file-lock.js +33 -1
- package/dist/lib/storage/file-paths.d.ts +0 -1
- package/dist/lib/storage/fixture-guards.d.ts +0 -1
- package/dist/lib/storage/flagged-entry.d.ts +0 -1
- package/dist/lib/storage/flagged-load-entry.d.ts +0 -1
- package/dist/lib/storage/flagged-save-entry.d.ts +0 -1
- package/dist/lib/storage/flagged-storage-file.d.ts +0 -1
- package/dist/lib/storage/flagged-storage-io.d.ts +0 -1
- package/dist/lib/storage/flagged-storage.d.ts +0 -1
- package/dist/lib/storage/gitignore.d.ts +0 -1
- package/dist/lib/storage/hash.d.ts +0 -1
- package/dist/lib/storage/health.d.ts +0 -1
- package/dist/lib/storage/identity.d.ts +0 -1
- package/dist/lib/storage/import-export.d.ts +0 -1
- package/dist/lib/storage/json-store-lock.d.ts +105 -0
- package/dist/lib/storage/json-store-lock.js +259 -0
- package/dist/lib/storage/metadata-section.d.ts +0 -1
- package/dist/lib/storage/migrations.d.ts +0 -1
- package/dist/lib/storage/migrations.js +31 -18
- package/dist/lib/storage/named-backup-entry.d.ts +0 -1
- package/dist/lib/storage/named-backups-entry.d.ts +0 -1
- package/dist/lib/storage/named-backups.d.ts +0 -1
- package/dist/lib/storage/path-state.d.ts +0 -1
- package/dist/lib/storage/paths.d.ts +0 -1
- package/dist/lib/storage/pending-auth.d.ts +10 -3
- package/dist/lib/storage/pending-auth.d.ts.map +1 -1
- package/dist/lib/storage/pending-auth.js +33 -9
- package/dist/lib/storage/project-migration.d.ts +0 -1
- package/dist/lib/storage/public-types.d.ts +0 -1
- package/dist/lib/storage/record-identity.d.ts +15 -0
- package/dist/lib/storage/record-identity.d.ts.map +1 -0
- package/dist/lib/storage/record-identity.js +16 -0
- package/dist/lib/storage/record-utils.d.ts +0 -1
- package/dist/lib/storage/restore-assessment.d.ts +0 -1
- package/dist/lib/storage/restore-backup-entry.d.ts +0 -1
- package/dist/lib/storage/restore-metadata.d.ts +0 -1
- package/dist/lib/storage/save-retry.d.ts +0 -1
- package/dist/lib/storage/snapshot-inspectors.d.ts +0 -1
- package/dist/lib/storage/snapshot-merge.d.ts +0 -1
- package/dist/lib/storage/storage-parser.d.ts +2 -1
- package/dist/lib/storage/storage-parser.js +10 -2
- package/dist/lib/storage/transactions.d.ts +0 -1
- package/dist/lib/storage.d.ts +15 -2
- package/dist/lib/storage.js +612 -25
- package/dist/lib/synthetic-response.d.ts +0 -1
- package/dist/lib/table-formatter.d.ts +0 -1
- package/dist/lib/temp-path.d.ts +0 -1
- package/dist/lib/tools/hashline-tools.d.ts +0 -1
- package/dist/lib/types.d.ts +0 -1
- package/dist/lib/ui/ansi.d.ts +0 -1
- package/dist/lib/ui/auth-menu-builder.d.ts +0 -1
- package/dist/lib/ui/auth-menu.d.ts +0 -1
- package/dist/lib/ui/check-progress.d.ts +0 -1
- package/dist/lib/ui/confirm.d.ts +0 -1
- package/dist/lib/ui/display-width.d.ts +0 -1
- package/dist/lib/ui/format.d.ts +0 -1
- package/dist/lib/ui/index.d.ts +0 -1
- package/dist/lib/ui/runtime.d.ts +0 -1
- package/dist/lib/ui/select.d.ts +0 -1
- package/dist/lib/ui/theme.d.ts +0 -1
- package/dist/lib/ui/ui-copy.d.ts +0 -1
- package/dist/lib/unified-settings.d.ts +13 -11
- package/dist/lib/unified-settings.js +22 -14
- package/dist/lib/update-notice.d.ts +0 -1
- package/dist/lib/usage/index.d.ts +0 -1
- package/dist/lib/usage/ledger.d.ts +0 -1
- package/dist/lib/usage/pricing.d.ts +0 -1
- package/dist/lib/usage/redaction.d.ts +0 -1
- package/dist/lib/usage/stream-usage-deferral.d.ts +0 -1
- package/dist/lib/usage/types.d.ts +0 -1
- package/dist/lib/usage/usage-extraction.d.ts +0 -1
- package/dist/lib/utils.d.ts +21 -1
- package/dist/lib/utils.js +31 -0
- package/dist/lib/wsl.d.ts +0 -1
- package/node_modules/@codex-ai/plugin/dist/index.d.ts +2 -2
- package/node_modules/@codex-ai/plugin/dist/index.js +2 -2
- package/node_modules/@codex-ai/plugin/dist/tool.d.ts +42 -42
- package/node_modules/@codex-ai/plugin/dist/tool.js +29 -29
- package/node_modules/@codex-ai/plugin/package.json +9 -9
- package/node_modules/@codex-ai/sdk/dist/index.d.ts +4 -4
- package/node_modules/@codex-ai/sdk/dist/index.js +2 -2
- package/node_modules/@codex-ai/sdk/package.json +8 -8
- package/package.json +206 -200
- package/scripts/codex-app-launcher.js +653 -653
- package/scripts/codex-app-router.js +373 -373
- package/scripts/codex-bin-resolver.js +332 -313
- package/scripts/codex-multi-auth.js +65 -59
- package/scripts/codex-routing.js +62 -62
- package/scripts/codex.js +6923 -6642
- package/scripts/install-codex-auth-utils.js +213 -213
- package/scripts/mcodex.js +367 -367
- package/scripts/postinstall.js +114 -114
- package/scripts/preuninstall.js +265 -265
- package/skills/codex-auth-setup/SKILL.md +73 -0
- package/vendor/codex-ai-plugin/dist/index.d.ts +2 -2
- package/vendor/codex-ai-plugin/dist/index.js +2 -2
- package/vendor/codex-ai-plugin/dist/tool.d.ts +42 -42
- package/vendor/codex-ai-plugin/dist/tool.js +29 -29
- package/vendor/codex-ai-plugin/package.json +9 -9
- package/vendor/codex-ai-sdk/dist/index.d.ts +4 -4
- package/vendor/codex-ai-sdk/dist/index.js +2 -2
- package/vendor/codex-ai-sdk/package.json +8 -8
package/dist/lib/quota-cache.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { promises as fs } from "node:fs";
|
|
2
2
|
import { basename, join } from "node:path";
|
|
3
3
|
import { withRetry } from "./fs-retry.js";
|
|
4
4
|
import { logWarn } from "./logger.js";
|
|
5
5
|
import { getCodexMultiAuthDir } from "./runtime-paths.js";
|
|
6
6
|
import { tempPathFor } from "./temp-path.js";
|
|
7
|
+
import { withFileTransactionLock } from "./storage/file-lock.js";
|
|
8
|
+
import { assertJsonStoreFileMtimeUnchanged, getJsonStoreFileMtimeMs, withJsonStoreCasRetry, } from "./storage/json-store-lock.js";
|
|
7
9
|
import { isRecord } from "./utils.js";
|
|
8
10
|
const QUOTA_CACHE_PATH = join(getCodexMultiAuthDir(), "quota-cache.json");
|
|
9
11
|
const QUOTA_CACHE_LABEL = basename(QUOTA_CACHE_PATH);
|
|
@@ -127,29 +129,71 @@ export function getQuotaCachePath() {
|
|
|
127
129
|
* will be empty if the on-disk file is absent, malformed, or could not be read.
|
|
128
130
|
*/
|
|
129
131
|
export async function loadQuotaCache() {
|
|
130
|
-
if (!existsSync(QUOTA_CACHE_PATH)) {
|
|
131
|
-
return { byAccountId: {}, byEmail: {} };
|
|
132
|
-
}
|
|
133
132
|
try {
|
|
134
|
-
|
|
135
|
-
const parsed = JSON.parse(content);
|
|
136
|
-
if (!isRecord(parsed)) {
|
|
137
|
-
return { byAccountId: {}, byEmail: {} };
|
|
138
|
-
}
|
|
139
|
-
if (parsed.version !== 1) {
|
|
140
|
-
logWarn(`Quota cache rejected due to version mismatch: ${String(parsed.version)}`);
|
|
141
|
-
return { byAccountId: {}, byEmail: {} };
|
|
142
|
-
}
|
|
143
|
-
return {
|
|
144
|
-
byAccountId: normalizeEntryMap(parsed.byAccountId),
|
|
145
|
-
byEmail: normalizeEntryMap(parsed.byEmail),
|
|
146
|
-
};
|
|
133
|
+
return await readQuotaCache();
|
|
147
134
|
}
|
|
148
135
|
catch (error) {
|
|
149
136
|
logWarn(`Failed to load quota cache from ${QUOTA_CACHE_LABEL}: ${error instanceof Error ? error.message : String(error)}`);
|
|
150
137
|
return { byAccountId: {}, byEmail: {} };
|
|
151
138
|
}
|
|
152
139
|
}
|
|
140
|
+
/** Only a missing file is empty for writers; read failures must never erase concurrent data. */
|
|
141
|
+
async function readQuotaCache() {
|
|
142
|
+
let content;
|
|
143
|
+
try {
|
|
144
|
+
content = await readCacheFileWithRetry(QUOTA_CACHE_PATH);
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
if (error.code === "ENOENT")
|
|
148
|
+
return { byAccountId: {}, byEmail: {} };
|
|
149
|
+
throw error;
|
|
150
|
+
}
|
|
151
|
+
const parsed = JSON.parse(content);
|
|
152
|
+
if (!isRecord(parsed) || parsed.version !== 1) {
|
|
153
|
+
throw Error("Quota cache rejected due to version mismatch or invalid payload");
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
byAccountId: normalizeEntryMap(parsed.byAccountId),
|
|
157
|
+
byEmail: normalizeEntryMap(parsed.byEmail),
|
|
158
|
+
...(parsed.byWorkspace ? { byWorkspace: normalizeEntryMap(parsed.byWorkspace) } : {}),
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
/** Reapply this run's changed entries, preserving unrelated or newer concurrent observations. */
|
|
162
|
+
function mergeQuotaChanges(current, proposed, baseline) {
|
|
163
|
+
const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
164
|
+
for (const namespace of ["byAccountId", "byEmail", "byWorkspace"]) {
|
|
165
|
+
const before = baseline[namespace] ?? {}, next = proposed[namespace] ?? {};
|
|
166
|
+
for (const key of new Set([...Object.keys(before), ...Object.keys(next)])) {
|
|
167
|
+
if (same(before[key], next[key]))
|
|
168
|
+
continue;
|
|
169
|
+
const latest = current[namespace]?.[key], update = next[key];
|
|
170
|
+
if (update) {
|
|
171
|
+
if (!latest || update.updatedAt >= latest.updatedAt) {
|
|
172
|
+
current[namespace] ??= {};
|
|
173
|
+
current[namespace][key] = update;
|
|
174
|
+
}
|
|
175
|
+
else if (same(latest, before[key])) {
|
|
176
|
+
// The on-disk entry is still exactly the one this caller's
|
|
177
|
+
// baseline saw, so nothing concurrent touched this key:
|
|
178
|
+
// `update` is a deliberate write whose lower stamp can only
|
|
179
|
+
// come from a backward clock jump on this writer. Re-stamp
|
|
180
|
+
// it just ahead instead of silently losing it. A raced key
|
|
181
|
+
// (`!same`) falls through and keeps the on-disk entry: its
|
|
182
|
+
// higher stamp marks a newer observation, and bumping an
|
|
183
|
+
// older one past it would let stale quota data overwrite
|
|
184
|
+
// fresher data.
|
|
185
|
+
update.updatedAt = latest.updatedAt + 1;
|
|
186
|
+
current[namespace] ??= {};
|
|
187
|
+
current[namespace][key] = update;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
else if (same(latest, before[key])) {
|
|
191
|
+
delete current[namespace]?.[key];
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
return current;
|
|
196
|
+
}
|
|
153
197
|
/**
|
|
154
198
|
* Persist the quota cache to the on-disk JSON file used by the multi-auth runtime.
|
|
155
199
|
*
|
|
@@ -157,8 +201,9 @@ export async function loadQuotaCache() {
|
|
|
157
201
|
* quota cache path. Failures are logged and do not throw, so callers should handle
|
|
158
202
|
* eventual consistency or retry as needed.
|
|
159
203
|
*
|
|
160
|
-
* Concurrency:
|
|
161
|
-
*
|
|
204
|
+
* Concurrency: reload, apply changes since `baseline`, and atomically write under
|
|
205
|
+
* a cross-process lock. Pass the pre-edit snapshot for read–modify–write callers.
|
|
206
|
+
* Without a baseline, supplied entries are upserts; omitted entries are retained.
|
|
162
207
|
*
|
|
163
208
|
* Filesystem notes: Windows path length, permissions, or antivirus locks may cause
|
|
164
209
|
* write failures; such errors are logged rather than thrown.
|
|
@@ -168,54 +213,65 @@ export async function loadQuotaCache() {
|
|
|
168
213
|
*
|
|
169
214
|
* @param data - The quota cache data (byAccountId and byEmail maps) to persist; callers
|
|
170
215
|
* should pass normalized QuotaCacheData.
|
|
216
|
+
* @param baseline - The unmodified pre-edit snapshot; only changes since it are applied.
|
|
171
217
|
*/
|
|
172
|
-
export async function saveQuotaCache(data) {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
byAccountId: data.byAccountId,
|
|
176
|
-
byEmail: data.byEmail,
|
|
177
|
-
};
|
|
218
|
+
export async function saveQuotaCache(data, baseline = { byAccountId: {}, byEmail: {} }) {
|
|
219
|
+
// Snapshot at invocation, not after waiting behind other writers.
|
|
220
|
+
const proposed = structuredClone(data), before = structuredClone(baseline);
|
|
178
221
|
const writeTask = async () => {
|
|
179
222
|
try {
|
|
180
|
-
|
|
181
|
-
//
|
|
182
|
-
//
|
|
183
|
-
|
|
184
|
-
//
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
223
|
+
// The transaction lock gives the read-merge-write cross-process mutual
|
|
224
|
+
// exclusion; the mtime CAS retry inside it is the second-line guard for
|
|
225
|
+
// writers that do not take the lock: every attempt re-stats, re-reads
|
|
226
|
+
// the freshest on-disk cache, and re-merges this call's diff onto it
|
|
227
|
+
// (matching the config save's reload-and-retry ESTALE semantics).
|
|
228
|
+
await withFileTransactionLock(QUOTA_CACHE_PATH, async () => {
|
|
229
|
+
await withJsonStoreCasRetry(async () => {
|
|
230
|
+
const expectedMtimeMs = await getJsonStoreFileMtimeMs(QUOTA_CACHE_PATH);
|
|
231
|
+
const merged = mergeQuotaChanges(await readQuotaCache(), proposed, before);
|
|
232
|
+
const payload = { version: 1, ...merged };
|
|
233
|
+
const cacheDir = getCodexMultiAuthDir();
|
|
234
|
+
// The quota cache lives alongside other at-rest secrets, so keep the
|
|
235
|
+
// directory owner-only on POSIX (mode is a no-op on win32 / ACL-based).
|
|
236
|
+
await fs.mkdir(cacheDir, { recursive: true, mode: 0o700 });
|
|
237
|
+
// mkdir's mode only applies to a freshly-created dir; an upgrade with a
|
|
238
|
+
// pre-existing multi-auth dir keeps its old (possibly world-listable)
|
|
239
|
+
// perms, so re-assert 0o700 on POSIX. Best-effort: a chmod failure must
|
|
240
|
+
// not break the cache write (the 0o600 file below still protects data).
|
|
241
|
+
if (process.platform !== "win32") {
|
|
242
|
+
try {
|
|
243
|
+
await fs.chmod(cacheDir, 0o700);
|
|
244
|
+
}
|
|
245
|
+
catch {
|
|
246
|
+
// Best-effort hardening only.
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
const tempPath = tempPathFor(QUOTA_CACHE_PATH);
|
|
250
|
+
await fs.writeFile(tempPath, `${JSON.stringify(payload, null, 2)}\n`, {
|
|
251
|
+
encoding: "utf8",
|
|
252
|
+
mode: 0o600,
|
|
253
|
+
});
|
|
254
|
+
let renamed = false;
|
|
211
255
|
try {
|
|
212
|
-
await
|
|
256
|
+
await assertJsonStoreFileMtimeUnchanged(QUOTA_CACHE_PATH, expectedMtimeMs);
|
|
257
|
+
await withRetry(() => fs.rename(tempPath, QUOTA_CACHE_PATH), {
|
|
258
|
+
maxAttempts: 5,
|
|
259
|
+
backoffMs: (attempt) => 10 * 2 ** (attempt - 1),
|
|
260
|
+
});
|
|
261
|
+
renamed = true;
|
|
213
262
|
}
|
|
214
|
-
|
|
215
|
-
|
|
263
|
+
finally {
|
|
264
|
+
if (!renamed) {
|
|
265
|
+
try {
|
|
266
|
+
await fs.unlink(tempPath);
|
|
267
|
+
}
|
|
268
|
+
catch {
|
|
269
|
+
// Best effort temp cleanup.
|
|
270
|
+
}
|
|
271
|
+
}
|
|
216
272
|
}
|
|
217
|
-
}
|
|
218
|
-
}
|
|
273
|
+
});
|
|
274
|
+
});
|
|
219
275
|
}
|
|
220
276
|
catch (error) {
|
|
221
277
|
logWarn(`Failed to save quota cache to ${QUOTA_CACHE_LABEL}: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -85,4 +85,3 @@ export interface ProbeCodexQuotaOptions {
|
|
|
85
85
|
* @throws If no candidate model produces a quota snapshot, throws the last encountered error or a generic failure error.
|
|
86
86
|
*/
|
|
87
87
|
export declare function fetchCodexQuotaSnapshot(options: ProbeCodexQuotaOptions): Promise<CodexQuotaSnapshot>;
|
|
88
|
-
//# sourceMappingURL=quota-probe.d.ts.map
|
package/dist/lib/quota-probe.js
CHANGED
|
@@ -4,7 +4,7 @@ import { QUOTA_PROBE_MODEL_CHAIN, resolveProbeReasoningEffort, } from "./request
|
|
|
4
4
|
import { CodexUnavailableError, isCodexUnavailableError } from "./errors.js";
|
|
5
5
|
import { getCodexInstructions } from "./prompts/codex.js";
|
|
6
6
|
import { mutateRuntimeObservabilitySnapshot } from "./runtime/runtime-observability.js";
|
|
7
|
-
import { isRecord } from "./utils.js";
|
|
7
|
+
import { combineSignals, isRecord } from "./utils.js";
|
|
8
8
|
import { FirstUseProbeError, finishSubscriptionFirstUse, needsSubscriptionFirstUse } from "./runtime/subscription-first-use.js";
|
|
9
9
|
/**
|
|
10
10
|
* Human-readable note shown when a live probe fails solely because the account
|
|
@@ -371,7 +371,10 @@ export async function fetchCodexQuotaSnapshot(options) {
|
|
|
371
371
|
method: "POST",
|
|
372
372
|
headers,
|
|
373
373
|
body: JSON.stringify(probeBody),
|
|
374
|
-
|
|
374
|
+
// combineSignals wraps AbortSignal.any with null-tolerance:
|
|
375
|
+
// the composite detaches from a long-lived caller signal once
|
|
376
|
+
// this probe completes, instead of pinning a listener on it.
|
|
377
|
+
signal: options.signal ? combineSignals(controller.signal, options.signal) : controller.signal,
|
|
375
378
|
});
|
|
376
379
|
}
|
|
377
380
|
finally {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { QuotaCacheData, QuotaCacheEntry } from "./quota-cache.js";
|
|
2
2
|
import type { AccountMetadataV3 } from "./storage.js";
|
|
3
|
-
export type QuotaCacheAccountRef = Pick<AccountMetadataV3, "accountId" | "email"
|
|
3
|
+
export type QuotaCacheAccountRef = Pick<AccountMetadataV3, "accountId" | "email" | "recordId" | "workspaces" | "currentWorkspaceIndex"> & Partial<Pick<AccountMetadataV3, "refreshToken" | "addedAt">>;
|
|
4
4
|
export declare function normalizeQuotaAccountId(value: string | undefined): string | null;
|
|
5
5
|
export declare function normalizeQuotaEmail(value: string | undefined): string | null;
|
|
6
6
|
export declare function hasUniqueQuotaAccountId(accounts: readonly QuotaCacheAccountRef[], account: QuotaCacheAccountRef): boolean;
|
|
@@ -15,5 +15,9 @@ export declare function quotaUsedPercentIsExhausted(usedPercent: number | undefi
|
|
|
15
15
|
export declare function isQuotaCacheEntryExhausted(entry: Pick<QuotaCacheEntry, "primary" | "secondary"> & {
|
|
16
16
|
updatedAt?: number;
|
|
17
17
|
} | null | undefined, now?: number): boolean;
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
/** Cache identity includes the credential record, so shared organization IDs cannot collide. */
|
|
19
|
+
export declare function quotaWorkspaceKey(account: QuotaCacheAccountRef, workspaceId: string): string | undefined;
|
|
20
|
+
/** Display the selected workspace; callers routing another scope must pass that exact workspace. */
|
|
21
|
+
export declare function quotaWorkspaceId(account: QuotaCacheAccountRef): string | undefined;
|
|
22
|
+
/** Read exact-workspace quota, using legacy binding entries only for that binding. */
|
|
23
|
+
export declare function findQuotaCacheEntryForAccount(cache: QuotaCacheData | null | undefined, account: QuotaCacheAccountRef, accounts: readonly QuotaCacheAccountRef[], emailFallbackState?: ReadonlyMap<string, QuotaEmailFallbackState>, workspaceId?: string | undefined): QuotaCacheEntry | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quota-readiness.d.ts","sourceRoot":"","sources":["../../lib/quota-readiness.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"quota-readiness.d.ts","sourceRoot":"","sources":["../../lib/quota-readiness.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAoB,MAAM,kBAAkB,CAAC;AAC1F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtD,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,iBAAiB,EAAE,WAAW,GAAG,OAAO,GAAG,UAAU,GAAG,YAAY,GAAG,uBAAuB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,iBAAiB,EAAE,cAAc,GAAG,SAAS,CAAC,CAAC,CAAC;AAIvM,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAGhF;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAG5E;AAED,wBAAgB,uBAAuB,CACtC,QAAQ,EAAE,SAAS,oBAAoB,EAAE,EACzC,OAAO,EAAE,oBAAoB,GAC3B,OAAO,CAQT;AAED,MAAM,MAAM,uBAAuB,GAAG;IACrC,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAChC,CAAC;AAEF,wBAAgB,4BAA4B,CAC3C,QAAQ,EAAE,SAAS,oBAAoB,EAAE,GACvC,WAAW,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAiB9C;AAED,wBAAgB,yBAAyB,CACxC,kBAAkB,EAAE,WAAW,CAAC,MAAM,EAAE,uBAAuB,CAAC,EAChE,OAAO,EAAE,oBAAoB,GAC3B,OAAO,CAMT;AAED,wBAAgB,wBAAwB,CACvC,WAAW,EAAE,MAAM,GAAG,SAAS,GAC7B,MAAM,GAAG,SAAS,CAKpB;AAQD,wBAAgB,2BAA2B,CAC1C,WAAW,EAAE,MAAM,GAAG,SAAS,GAC7B,OAAO,CAMT;AA2BD,wBAAgB,0BAA0B,CACzC,KAAK,EAAE,IAAI,CAAC,eAAe,EAAE,SAAS,GAAG,WAAW,CAAC,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,EACjG,GAAG,SAAa,GACd,OAAO,CAQT;AAED,gGAAgG;AAChG,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAIxG;AAED,oGAAoG;AACpG,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,oBAAoB,GAAG,MAAM,GAAG,SAAS,CAIlF;AAED,sFAAsF;AACtF,wBAAgB,6BAA6B,CAC5C,KAAK,EAAE,cAAc,GAAG,IAAI,GAAG,SAAS,EACxC,OAAO,EAAE,oBAAoB,EAC7B,QAAQ,EAAE,SAAS,oBAAoB,EAAE,EACzC,kBAAkB,+CAAyC,EAC3D,WAAW,qBAA4B,GACrC,eAAe,GAAG,IAAI,CAgBxB"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { resolveAccountRecordId } from "./storage/record-identity.js";
|
|
1
3
|
export function normalizeQuotaAccountId(value) {
|
|
2
4
|
const trimmed = value?.trim();
|
|
3
5
|
return trimmed && trimmed.length > 0 ? trimmed : null;
|
|
@@ -89,16 +91,35 @@ export function isQuotaCacheEntryExhausted(entry, now = Date.now()) {
|
|
|
89
91
|
return (quotaWindowIsExhausted(entry?.primary, now, updatedAt) ||
|
|
90
92
|
quotaWindowIsExhausted(entry?.secondary, now, updatedAt));
|
|
91
93
|
}
|
|
92
|
-
|
|
94
|
+
/** Cache identity includes the credential record, so shared organization IDs cannot collide. */
|
|
95
|
+
export function quotaWorkspaceKey(account, workspaceId) {
|
|
96
|
+
const recordId = account.recordId?.trim() || (account.refreshToken !== undefined && account.addedAt !== undefined
|
|
97
|
+
? resolveAccountRecordId({ ...account, refreshToken: account.refreshToken, addedAt: account.addedAt }) : undefined);
|
|
98
|
+
return recordId ? createHash("sha256").update(JSON.stringify(["oauth", recordId, workspaceId.trim()])).digest("hex") : undefined;
|
|
99
|
+
}
|
|
100
|
+
/** Display the selected workspace; callers routing another scope must pass that exact workspace. */
|
|
101
|
+
export function quotaWorkspaceId(account) {
|
|
102
|
+
return account.workspaces?.length
|
|
103
|
+
? account.workspaces[account.currentWorkspaceIndex ?? 0]?.id.trim()
|
|
104
|
+
: account.accountId?.trim();
|
|
105
|
+
}
|
|
106
|
+
/** Read exact-workspace quota, using legacy binding entries only for that binding. */
|
|
107
|
+
export function findQuotaCacheEntryForAccount(cache, account, accounts, emailFallbackState = buildQuotaEmailFallbackState(accounts), workspaceId = quotaWorkspaceId(account)) {
|
|
93
108
|
if (!cache)
|
|
94
109
|
return null;
|
|
110
|
+
const key = workspaceId && quotaWorkspaceKey(account, workspaceId);
|
|
111
|
+
const scoped = key ? cache.byWorkspace?.[key] : undefined;
|
|
112
|
+
// Legacy entries describe only the stored binding, never a sibling workspace.
|
|
113
|
+
if (normalizeQuotaAccountId(workspaceId) !== normalizeQuotaAccountId(account.accountId))
|
|
114
|
+
return scoped ?? null;
|
|
95
115
|
const accountId = normalizeQuotaAccountId(account.accountId);
|
|
116
|
+
const newer = (legacy) => scoped && (!legacy || scoped.updatedAt >= legacy.updatedAt) ? scoped : legacy ?? null;
|
|
96
117
|
if (accountId && hasUniqueQuotaAccountId(accounts, account) && cache.byAccountId[accountId]) {
|
|
97
|
-
return cache.byAccountId[accountId]
|
|
118
|
+
return newer(cache.byAccountId[accountId]);
|
|
98
119
|
}
|
|
99
120
|
const email = normalizeQuotaEmail(account.email);
|
|
100
121
|
if (email && hasSafeQuotaEmailFallback(emailFallbackState, account) && cache.byEmail[email]) {
|
|
101
|
-
return cache.byEmail[email]
|
|
122
|
+
return newer(cache.byEmail[email]);
|
|
102
123
|
}
|
|
103
|
-
return null;
|
|
124
|
+
return scoped ?? null;
|
|
104
125
|
}
|
|
@@ -41,4 +41,3 @@ export declare function findEmptyMessageByIndex(sessionID: string, targetIndex:
|
|
|
41
41
|
export declare function findMessageByIndexNeedingThinking(sessionID: string, targetIndex: number): string | null;
|
|
42
42
|
export declare function replaceEmptyTextParts(messageID: string, replacementText: string): boolean;
|
|
43
43
|
export declare function findMessagesWithEmptyTextParts(sessionID: string): string[];
|
|
44
|
-
//# sourceMappingURL=storage.d.ts.map
|
package/dist/lib/recovery.d.ts
CHANGED
package/dist/lib/redaction.d.ts
CHANGED
|
@@ -79,4 +79,3 @@ export declare function isWorkspaceDisabledError(status: number, code: unknown,
|
|
|
79
79
|
* @returns A 403 Response with a JSON body describing the entitlement error and guidance for resolving it
|
|
80
80
|
*/
|
|
81
81
|
export declare function createEntitlementErrorResponse(_bodyText: string): Response;
|
|
82
|
-
//# sourceMappingURL=error-classification.d.ts.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type { FailoverMode } from "./failure-policy.js";
|
|
2
2
|
export declare function parseFailoverMode(value: string | undefined): FailoverMode;
|
|
3
3
|
export declare function parseEnvInt(value: string | undefined): number | undefined;
|
|
4
|
-
//# sourceMappingURL=failover-config.d.ts.map
|
|
@@ -30,4 +30,3 @@ export declare function createCodexHeaders(init: RequestInit | undefined, accoun
|
|
|
30
30
|
* @internal Exported only for sibling lib/request modules; import via fetch-helpers.ts elsewhere.
|
|
31
31
|
*/
|
|
32
32
|
export declare function logDeprecationHeaders(response: Response): void;
|
|
33
|
-
//# sourceMappingURL=headers.d.ts.map
|
|
@@ -4,4 +4,3 @@ export declare function isHostSystemPrompt(item: InputItem, cachedPrompt: string
|
|
|
4
4
|
export declare function filterHostSystemPromptsWithCachedPrompt(input: InputItem[] | undefined, cachedPrompt: string | null): InputItem[] | undefined;
|
|
5
5
|
export declare const normalizeOrphanedToolOutputs: (input: InputItem[]) => InputItem[];
|
|
6
6
|
export declare const injectMissingToolOutputs: (input: InputItem[]) => InputItem[];
|
|
7
|
-
//# sourceMappingURL=input-utils.d.ts.map
|
|
@@ -49,47 +49,78 @@ const extractHostContext = (contentText) => {
|
|
|
49
49
|
return null;
|
|
50
50
|
return contentText.slice(earliestIndex).trimStart();
|
|
51
51
|
};
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Normalizes the cached host prompt once per filter pass so the per-item
|
|
54
|
+
* checks do not re-trim/re-slice the same string.
|
|
55
|
+
*/
|
|
56
|
+
const prepareCachedPrompt = (cachedPrompt) => {
|
|
57
|
+
if (!cachedPrompt)
|
|
58
|
+
return null;
|
|
59
|
+
const trimmed = cachedPrompt.trim();
|
|
60
|
+
return { trimmed, prefix: trimmed.substring(0, 200) };
|
|
61
|
+
};
|
|
62
|
+
const isHostPromptContent = (contentText, cached) => {
|
|
57
63
|
if (!contentText)
|
|
58
64
|
return false;
|
|
59
|
-
if (
|
|
65
|
+
if (cached) {
|
|
60
66
|
const contentTrimmed = contentText.trim();
|
|
61
|
-
|
|
62
|
-
if (contentTrimmed === cachedTrimmed) {
|
|
67
|
+
if (contentTrimmed === cached.trimmed) {
|
|
63
68
|
return true;
|
|
64
69
|
}
|
|
65
|
-
if (contentTrimmed.startsWith(
|
|
70
|
+
if (contentTrimmed.startsWith(cached.trimmed)) {
|
|
66
71
|
return true;
|
|
67
72
|
}
|
|
68
73
|
const contentPrefix = contentTrimmed.substring(0, 200);
|
|
69
|
-
|
|
70
|
-
if (contentPrefix === cachedPrefix) {
|
|
74
|
+
if (contentPrefix === cached.prefix) {
|
|
71
75
|
return true;
|
|
72
76
|
}
|
|
73
77
|
}
|
|
74
78
|
const normalized = contentText.trimStart().toLowerCase();
|
|
75
79
|
return HOST_PROMPT_SIGNATURES.some((signature) => normalized.startsWith(signature));
|
|
80
|
+
};
|
|
81
|
+
export function isHostSystemPrompt(item, cachedPrompt) {
|
|
82
|
+
const isSystemRole = item.role === "developer" || item.role === "system";
|
|
83
|
+
if (!isSystemRole)
|
|
84
|
+
return false;
|
|
85
|
+
return isHostPromptContent(getContentText(item), prepareCachedPrompt(cachedPrompt));
|
|
76
86
|
}
|
|
77
87
|
export function filterHostSystemPromptsWithCachedPrompt(input, cachedPrompt) {
|
|
78
88
|
if (!Array.isArray(input))
|
|
79
89
|
return input;
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
90
|
+
const cached = prepareCachedPrompt(cachedPrompt);
|
|
91
|
+
// Copy-on-write: most items pass through untouched, so the result array is
|
|
92
|
+
// only materialized once an item is actually dropped or rewritten.
|
|
93
|
+
let filtered = null;
|
|
94
|
+
for (let i = 0; i < input.length; i++) {
|
|
95
|
+
// flatMap skips sparse holes entirely; an explicit `undefined` element
|
|
96
|
+
// still reaches the callback and throws on `.role` — mirrored below.
|
|
97
|
+
if (!(i in input)) {
|
|
98
|
+
if (filtered === null)
|
|
99
|
+
filtered = input.slice(0, i);
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
const item = input[i];
|
|
103
|
+
const isSystemRole = item.role === "developer" || item.role === "system";
|
|
104
|
+
if (!isSystemRole) {
|
|
105
|
+
if (filtered !== null)
|
|
106
|
+
filtered.push(item);
|
|
107
|
+
continue;
|
|
85
108
|
}
|
|
86
109
|
const contentText = getContentText(item);
|
|
110
|
+
if (!isHostPromptContent(contentText, cached)) {
|
|
111
|
+
if (filtered !== null)
|
|
112
|
+
filtered.push(item);
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
87
115
|
const preservedContext = extractHostContext(contentText);
|
|
116
|
+
if (filtered === null) {
|
|
117
|
+
filtered = input.slice(0, i);
|
|
118
|
+
}
|
|
88
119
|
if (preservedContext) {
|
|
89
|
-
|
|
120
|
+
filtered.push(replaceContentText(item, preservedContext));
|
|
90
121
|
}
|
|
91
|
-
|
|
92
|
-
|
|
122
|
+
}
|
|
123
|
+
return filtered ?? input;
|
|
93
124
|
}
|
|
94
125
|
const getCallId = (item) => {
|
|
95
126
|
const rawCallId = item.call_id;
|
|
@@ -103,13 +134,16 @@ const convertOrphanedOutputToMessage = (item, callId) => {
|
|
|
103
134
|
? item.name
|
|
104
135
|
: "tool";
|
|
105
136
|
const labelCallId = callId ?? "unknown";
|
|
137
|
+
// Read `.output` once: the catch fallback must use the same value —
|
|
138
|
+
// re-reading a throwing getter inside the catch would just re-throw.
|
|
139
|
+
const out = item.output;
|
|
106
140
|
let text;
|
|
107
141
|
try {
|
|
108
|
-
|
|
109
|
-
|
|
142
|
+
text =
|
|
143
|
+
typeof out === "string" ? out : (JSON.stringify(out) ?? "");
|
|
110
144
|
}
|
|
111
145
|
catch {
|
|
112
|
-
text = String(
|
|
146
|
+
text = String(out ?? "");
|
|
113
147
|
}
|
|
114
148
|
if (text.length > 16000) {
|
|
115
149
|
text = text.slice(0, 16000) + "\n...[truncated]";
|
|
@@ -146,31 +180,43 @@ const collectCallIds = (input) => {
|
|
|
146
180
|
};
|
|
147
181
|
export const normalizeOrphanedToolOutputs = (input) => {
|
|
148
182
|
const { functionCallIds, localShellCallIds, customToolCallIds } = collectCallIds(input);
|
|
149
|
-
|
|
183
|
+
// Copy-on-write: items pass through by reference until an output actually
|
|
184
|
+
// needs converting; an unchanged input returns the original array instead
|
|
185
|
+
// of a per-item `map` copy.
|
|
186
|
+
let mapped = null;
|
|
187
|
+
for (let i = 0; i < input.length; i++) {
|
|
188
|
+
const item = input[i];
|
|
189
|
+
let converted = item;
|
|
150
190
|
if (item.type === "function_call_output") {
|
|
151
191
|
const callId = getCallId(item);
|
|
152
192
|
const hasMatch = !!callId &&
|
|
153
193
|
(functionCallIds.has(callId) || localShellCallIds.has(callId));
|
|
154
194
|
if (!hasMatch) {
|
|
155
|
-
|
|
195
|
+
converted = convertOrphanedOutputToMessage(item, callId);
|
|
156
196
|
}
|
|
157
197
|
}
|
|
158
|
-
if (item.type === "custom_tool_call_output") {
|
|
198
|
+
else if (item.type === "custom_tool_call_output") {
|
|
159
199
|
const callId = getCallId(item);
|
|
160
200
|
const hasMatch = !!callId && customToolCallIds.has(callId);
|
|
161
201
|
if (!hasMatch) {
|
|
162
|
-
|
|
202
|
+
converted = convertOrphanedOutputToMessage(item, callId);
|
|
163
203
|
}
|
|
164
204
|
}
|
|
165
|
-
if (item.type === "local_shell_call_output") {
|
|
205
|
+
else if (item.type === "local_shell_call_output") {
|
|
166
206
|
const callId = getCallId(item);
|
|
167
207
|
const hasMatch = !!callId && localShellCallIds.has(callId);
|
|
168
208
|
if (!hasMatch) {
|
|
169
|
-
|
|
209
|
+
converted = convertOrphanedOutputToMessage(item, callId);
|
|
170
210
|
}
|
|
171
211
|
}
|
|
172
|
-
|
|
173
|
-
|
|
212
|
+
if (converted !== item && mapped === null) {
|
|
213
|
+
mapped = input.slice(0, i);
|
|
214
|
+
}
|
|
215
|
+
if (mapped !== null) {
|
|
216
|
+
mapped.push(converted);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
return mapped ?? input;
|
|
174
220
|
};
|
|
175
221
|
const CANCELLED_TOOL_OUTPUT = "Operation cancelled by user";
|
|
176
222
|
const collectOutputCallIds = (input) => {
|
|
@@ -188,9 +234,14 @@ const collectOutputCallIds = (input) => {
|
|
|
188
234
|
};
|
|
189
235
|
export const injectMissingToolOutputs = (input) => {
|
|
190
236
|
const outputCallIds = collectOutputCallIds(input);
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
237
|
+
// Copy-on-write: items pass through by reference; the result array is only
|
|
238
|
+
// materialized when a synthetic output is actually injected.
|
|
239
|
+
let result = null;
|
|
240
|
+
for (let i = 0; i < input.length; i++) {
|
|
241
|
+
const item = input[i];
|
|
242
|
+
if (result !== null) {
|
|
243
|
+
result.push(item);
|
|
244
|
+
}
|
|
194
245
|
if (item.type === "function_call" ||
|
|
195
246
|
item.type === "local_shell_call" ||
|
|
196
247
|
item.type === "custom_tool_call") {
|
|
@@ -201,6 +252,9 @@ export const injectMissingToolOutputs = (input) => {
|
|
|
201
252
|
: item.type === "local_shell_call"
|
|
202
253
|
? "local_shell_call_output"
|
|
203
254
|
: "custom_tool_call_output";
|
|
255
|
+
if (result === null) {
|
|
256
|
+
result = input.slice(0, i + 1);
|
|
257
|
+
}
|
|
204
258
|
result.push({
|
|
205
259
|
type: outputType,
|
|
206
260
|
call_id: callId,
|
|
@@ -209,5 +263,5 @@ export const injectMissingToolOutputs = (input) => {
|
|
|
209
263
|
}
|
|
210
264
|
}
|
|
211
265
|
}
|
|
212
|
-
return result;
|
|
266
|
+
return result ?? input;
|
|
213
267
|
};
|