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
|
@@ -13,4 +13,3 @@ import type { RequestToolDefinition } from "../../types.js";
|
|
|
13
13
|
* @returns Cleaned array of tool definitions
|
|
14
14
|
*/
|
|
15
15
|
export declare function cleanupToolDefinitions(tools: RequestToolDefinition[] | undefined): RequestToolDefinition[] | undefined;
|
|
16
|
-
//# sourceMappingURL=tool-utils.d.ts.map
|
|
@@ -1,7 +1,393 @@
|
|
|
1
1
|
import { isRecord } from "../../utils.js";
|
|
2
|
+
const hasOwn = (obj, key) => Object.prototype.hasOwnProperty.call(obj, key);
|
|
2
3
|
function cloneRecord(value) {
|
|
3
4
|
return JSON.parse(JSON.stringify(value));
|
|
4
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* Defines an own enumerable property on a clone output object. A plain
|
|
8
|
+
* `clone["__proto__"] = v` assignment would silently rewrite the clone's
|
|
9
|
+
* prototype instead of creating the own property `JSON.parse` produces.
|
|
10
|
+
*/
|
|
11
|
+
const setCloneProp = (out, key, child) => {
|
|
12
|
+
if (key === "__proto__") {
|
|
13
|
+
Object.defineProperty(out, key, {
|
|
14
|
+
value: child,
|
|
15
|
+
writable: true,
|
|
16
|
+
enumerable: true,
|
|
17
|
+
configurable: true,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
out[key] = child;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Deep-clones a tree already proven to be plain JSON data by
|
|
26
|
+
* {@link inspectSchema}. Produces the same result as
|
|
27
|
+
* `JSON.parse(JSON.stringify(value))` for that input class without building
|
|
28
|
+
* an intermediate string.
|
|
29
|
+
*/
|
|
30
|
+
function clonePlainValue(value) {
|
|
31
|
+
if (value === null || typeof value !== "object")
|
|
32
|
+
return value;
|
|
33
|
+
if (Array.isArray(value)) {
|
|
34
|
+
const clone = new Array(value.length);
|
|
35
|
+
for (let i = 0; i < value.length; i++) {
|
|
36
|
+
clone[i] = clonePlainValue(value[i]);
|
|
37
|
+
}
|
|
38
|
+
return clone;
|
|
39
|
+
}
|
|
40
|
+
const clone = {};
|
|
41
|
+
for (const key of Object.keys(value)) {
|
|
42
|
+
setCloneProp(clone, key, clonePlainValue(value[key]));
|
|
43
|
+
}
|
|
44
|
+
return clone;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Values that are schema nodes (a `properties` entry, an `items` schema) get
|
|
48
|
+
* the fused clone+clean; everything else is a plain JSON clone. Mirrors
|
|
49
|
+
* cleanupSchema only recursing through `properties` values and `items`.
|
|
50
|
+
*/
|
|
51
|
+
function cloneSchemaChild(value) {
|
|
52
|
+
if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
53
|
+
return cloneAndCleanSchema(value);
|
|
54
|
+
}
|
|
55
|
+
return clonePlainValue(value);
|
|
56
|
+
}
|
|
57
|
+
function clonePropertiesMap(rawProps) {
|
|
58
|
+
if (Array.isArray(rawProps)) {
|
|
59
|
+
const out = new Array(rawProps.length);
|
|
60
|
+
for (let i = 0; i < rawProps.length; i++) {
|
|
61
|
+
out[i] = cloneSchemaChild(rawProps[i]);
|
|
62
|
+
}
|
|
63
|
+
return out;
|
|
64
|
+
}
|
|
65
|
+
const out = {};
|
|
66
|
+
for (const key of Object.keys(rawProps)) {
|
|
67
|
+
setCloneProp(out, key, cloneSchemaChild(rawProps[key]));
|
|
68
|
+
}
|
|
69
|
+
return out;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* The node-local half of {@link cleanupSchema}: steps 1-4 plus the unsupported
|
|
73
|
+
* keyword drops (step 5). Step 0 (undefined `properties` values) is skipped
|
|
74
|
+
* because this only runs on trees {@link inspectSchema} verified contain no
|
|
75
|
+
* `undefined` values. Child recursion is already done by the fused clone.
|
|
76
|
+
*/
|
|
77
|
+
function applySchemaTransforms(out) {
|
|
78
|
+
// 1. Flatten Unions (anyOf -> enum)
|
|
79
|
+
if (Array.isArray(out.anyOf)) {
|
|
80
|
+
const anyOf = out.anyOf;
|
|
81
|
+
const allConst = anyOf.every((opt) => "const" in opt);
|
|
82
|
+
if (allConst && anyOf.length > 0) {
|
|
83
|
+
const enumValues = anyOf.map((opt) => opt.const);
|
|
84
|
+
out.enum = enumValues;
|
|
85
|
+
delete out.anyOf;
|
|
86
|
+
if (!out.type) {
|
|
87
|
+
const firstVal = enumValues[0];
|
|
88
|
+
if (typeof firstVal === "string")
|
|
89
|
+
out.type = "string";
|
|
90
|
+
else if (typeof firstVal === "number")
|
|
91
|
+
out.type = "number";
|
|
92
|
+
else if (typeof firstVal === "boolean")
|
|
93
|
+
out.type = "boolean";
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// 2. Flatten Nullable Types (["string", "null"] -> "string")
|
|
98
|
+
if (Array.isArray(out.type)) {
|
|
99
|
+
const types = out.type;
|
|
100
|
+
const isNullable = types.includes("null");
|
|
101
|
+
const nonNullTypes = types.filter((t) => t !== "null");
|
|
102
|
+
if (nonNullTypes.length > 0) {
|
|
103
|
+
out.type = nonNullTypes[0];
|
|
104
|
+
if (isNullable) {
|
|
105
|
+
const desc = out.description || "";
|
|
106
|
+
if (!desc.toLowerCase().includes("nullable")) {
|
|
107
|
+
out.description = desc ? `${desc} (nullable)` : "(nullable)";
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// 3. Filter 'required' array
|
|
113
|
+
if (Array.isArray(out.required) &&
|
|
114
|
+
out.properties &&
|
|
115
|
+
typeof out.properties === "object") {
|
|
116
|
+
const properties = out.properties;
|
|
117
|
+
const required = out.required;
|
|
118
|
+
const validRequired = required.filter((key) => hasOwn(properties, key));
|
|
119
|
+
if (validRequired.length === 0) {
|
|
120
|
+
delete out.required;
|
|
121
|
+
}
|
|
122
|
+
else if (validRequired.length !== required.length) {
|
|
123
|
+
out.required = validRequired;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
// 4. Handle empty object parameters
|
|
127
|
+
if (out.type === "object" &&
|
|
128
|
+
(!out.properties || Object.keys(out.properties).length === 0)) {
|
|
129
|
+
out.properties = {
|
|
130
|
+
_placeholder: {
|
|
131
|
+
type: "boolean",
|
|
132
|
+
description: "This property is a placeholder and should be ignored.",
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Fused clone+clean: produces exactly `cleanupSchema(JSON.clone(node))` in a
|
|
139
|
+
* single pass for trees {@link inspectSchema} verified as plain JSON data.
|
|
140
|
+
* The unsupported keywords are dropped during the key copy (equivalent to
|
|
141
|
+
* step-5 deletes); node-level rewrites then run in cleanupSchema's order, and
|
|
142
|
+
* they never observe child-cleaned state, so children can be cleaned eagerly
|
|
143
|
+
* while copying.
|
|
144
|
+
*/
|
|
145
|
+
function cloneAndCleanSchema(node) {
|
|
146
|
+
const out = {};
|
|
147
|
+
for (const key of Object.keys(node)) {
|
|
148
|
+
// Read once — and before the keyword skip — exactly like
|
|
149
|
+
// JSON.stringify reads every enumerable value: a throwing get trap on
|
|
150
|
+
// a dropped keyword must still fail (and fall back) here.
|
|
151
|
+
const value = node[key];
|
|
152
|
+
if (key === "additionalProperties" ||
|
|
153
|
+
key === "const" ||
|
|
154
|
+
key === "title" ||
|
|
155
|
+
key === "$schema") {
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
if (key === "properties" && value !== null && typeof value === "object") {
|
|
159
|
+
setCloneProp(out, key, clonePropertiesMap(value));
|
|
160
|
+
}
|
|
161
|
+
else if (key === "items" && value !== null && typeof value === "object") {
|
|
162
|
+
setCloneProp(out, key, cloneSchemaChild(value));
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
setCloneProp(out, key, clonePlainValue(value));
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
applySchemaTransforms(out);
|
|
169
|
+
return out;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Read-only mirror of {@link cleanupSchema}'s mutation conditions at a single
|
|
173
|
+
* schema node. Mirrors the same short-circuit cascade: a node counts as dirty
|
|
174
|
+
* iff cleanupSchema would delete, inject, or rewrite anything on it.
|
|
175
|
+
* Recursion into `properties`/`items` is handled by {@link inspectSchema}.
|
|
176
|
+
*/
|
|
177
|
+
function schemaWouldChange(schema) {
|
|
178
|
+
const rawProps = schema.properties;
|
|
179
|
+
const propsObject = !!rawProps && typeof rawProps === "object";
|
|
180
|
+
// Step 0/3/4 helper state: own enumerable `properties` keys with a defined
|
|
181
|
+
// value — exactly the keys the cleaned clone still has after the
|
|
182
|
+
// undefined-value deletions (non-enumerable keys never survive the clone).
|
|
183
|
+
const definedPropKeys = propsObject ? new Set() : null;
|
|
184
|
+
if (definedPropKeys !== null) {
|
|
185
|
+
for (const key of Object.keys(rawProps)) {
|
|
186
|
+
if (rawProps[key] === undefined) {
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
definedPropKeys.add(key);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
// 1. anyOf of all-`const` options flattens into `enum`.
|
|
193
|
+
if (Array.isArray(schema.anyOf) &&
|
|
194
|
+
schema.anyOf.length > 0 &&
|
|
195
|
+
schema.anyOf.every((opt) => "const" in opt)) {
|
|
196
|
+
return true;
|
|
197
|
+
}
|
|
198
|
+
// 2. A type array holding at least one non-"null" member collapses.
|
|
199
|
+
if (Array.isArray(schema.type)) {
|
|
200
|
+
for (const member of schema.type) {
|
|
201
|
+
if (member !== "null")
|
|
202
|
+
return true;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
// 3. `required` is rewritten when any entry is not a surviving property
|
|
206
|
+
// key (evaluated after the step-0 undefined deletions).
|
|
207
|
+
if (Array.isArray(schema.required) &&
|
|
208
|
+
propsObject &&
|
|
209
|
+
definedPropKeys !== null) {
|
|
210
|
+
let valid = 0;
|
|
211
|
+
for (const key of schema.required) {
|
|
212
|
+
// hasOwnProperty coerces non-string entries; mirror that for the Set lookup.
|
|
213
|
+
if (definedPropKeys.has(typeof key === "string" ? key : String(key))) {
|
|
214
|
+
valid += 1;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
// cleanupSchema deletes `required` whenever zero entries survive —
|
|
218
|
+
// including an empty `required: []`, which is a mutation, not a no-op.
|
|
219
|
+
if (valid === 0 || valid !== schema.required.length)
|
|
220
|
+
return true;
|
|
221
|
+
}
|
|
222
|
+
// 4. `type: "object"` with no surviving properties gains a placeholder.
|
|
223
|
+
// Only reachable when step 2 left `type` as a non-array.
|
|
224
|
+
if (schema.type === "object") {
|
|
225
|
+
const empty = !rawProps
|
|
226
|
+
? true
|
|
227
|
+
: propsObject && definedPropKeys !== null
|
|
228
|
+
? definedPropKeys.size === 0
|
|
229
|
+
: Object.keys(rawProps).length === 0;
|
|
230
|
+
if (empty)
|
|
231
|
+
return true;
|
|
232
|
+
}
|
|
233
|
+
// 5. Unsupported keywords are deleted unconditionally.
|
|
234
|
+
if (hasOwn(schema, "additionalProperties") ||
|
|
235
|
+
hasOwn(schema, "const") ||
|
|
236
|
+
hasOwn(schema, "title") ||
|
|
237
|
+
hasOwn(schema, "$schema")) {
|
|
238
|
+
return true;
|
|
239
|
+
}
|
|
240
|
+
return false;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Walks a parameters schema once, answering two questions at the same time:
|
|
244
|
+
*
|
|
245
|
+
* - `needsCleanup`: would {@link cleanupSchema} mutate anything? Mirrors its
|
|
246
|
+
* traversal (schema nodes are the root, `properties` values, and `items`).
|
|
247
|
+
* - `jsonSerializable`: is the tree plain JSON data such that
|
|
248
|
+
* `JSON.parse(JSON.stringify(tree))` is the identity transform on values?
|
|
249
|
+
* Anything the round-trip would rewrite or reject (cycles, bigint,
|
|
250
|
+
* `undefined` properties, `toJSON` hooks, exotic prototypes, sparse arrays,
|
|
251
|
+
* non-finite numbers) makes cleanup semantics depend on the actual clone,
|
|
252
|
+
* so such trees must stay on the legacy path for identical results.
|
|
253
|
+
*/
|
|
254
|
+
// Legitimate JSON Schemas are never this deep; deeper nesting means either a
|
|
255
|
+
// cycle (JSON.stringify would throw) or a pathological tree the legacy path
|
|
256
|
+
// can evaluate correctly. Bounding the walk keeps cycle detection free.
|
|
257
|
+
const MAX_SCHEMA_DEPTH = 512;
|
|
258
|
+
function inspectSchema(root) {
|
|
259
|
+
let jsonSerializable = true;
|
|
260
|
+
// Mode-1 schema nodes are collected during the walk but only evaluated
|
|
261
|
+
// afterwards: schemaWouldChange reads one level into children
|
|
262
|
+
// (properties values, required/type/anyOf elements), which is only safe
|
|
263
|
+
// once the whole tree is verified free of accessors.
|
|
264
|
+
const schemaNodes = [];
|
|
265
|
+
// mode 0: not a schema node (walked only for serializability)
|
|
266
|
+
// mode 1: schema node (root / properties values / items)
|
|
267
|
+
// mode 2: properties container (its VALUES are schema nodes)
|
|
268
|
+
const walk = (value, mode, depth) => {
|
|
269
|
+
if (!jsonSerializable)
|
|
270
|
+
return;
|
|
271
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") {
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
if (typeof value === "number") {
|
|
275
|
+
// JSON.stringify emits non-finite numbers (and -0) differently.
|
|
276
|
+
if (!Number.isFinite(value) || Object.is(value, -0)) {
|
|
277
|
+
jsonSerializable = false;
|
|
278
|
+
}
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
if (typeof value !== "object" || depth > MAX_SCHEMA_DEPTH) {
|
|
282
|
+
// bigint/symbol/function/undefined: JSON.stringify throws or drops.
|
|
283
|
+
// Over-depth: cycle or pathological nesting — stay on legacy path.
|
|
284
|
+
jsonSerializable = false;
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
const isArr = Array.isArray(value);
|
|
288
|
+
const proto = Object.getPrototypeOf(value);
|
|
289
|
+
if (isArr
|
|
290
|
+
? proto !== Array.prototype
|
|
291
|
+
: proto !== Object.prototype && proto !== null) {
|
|
292
|
+
jsonSerializable = false;
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
// ownKeys covers non-enumerable + symbol keys that JSON.stringify and
|
|
296
|
+
// the fast clone both skip; extra own keys mean the views diverge.
|
|
297
|
+
const ownKeyCount = Reflect.ownKeys(value).length;
|
|
298
|
+
// Values are read through property descriptors so accessors are never
|
|
299
|
+
// invoked: a getter is stateful — it can return a different value than
|
|
300
|
+
// the single read JSON.stringify performs, or throw on a later call —
|
|
301
|
+
// so any accessor (or a descriptor a proxy withholds) routes the tree
|
|
302
|
+
// to the legacy path before any getter can run.
|
|
303
|
+
const descs = Object.getOwnPropertyDescriptors(value);
|
|
304
|
+
if (isArr) {
|
|
305
|
+
// Arrays own `length` plus their indices; sparse slots or extra
|
|
306
|
+
// named keys serialize differently.
|
|
307
|
+
if (ownKeyCount !== value.length + 1) {
|
|
308
|
+
jsonSerializable = false;
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
// An array used as a `properties` map has its elements cleaned as
|
|
312
|
+
// schemas by cleanupSchema's `for key in props` recursion.
|
|
313
|
+
const childMode = mode === 2 ? 1 : 0;
|
|
314
|
+
for (let i = 0; i < value.length; i++) {
|
|
315
|
+
const desc = descs[i];
|
|
316
|
+
if (!desc || "get" in desc || "set" in desc) {
|
|
317
|
+
jsonSerializable = false;
|
|
318
|
+
return;
|
|
319
|
+
}
|
|
320
|
+
const child = desc.value;
|
|
321
|
+
if (child === undefined) {
|
|
322
|
+
// JSON.stringify rewrites undefined array elements to null.
|
|
323
|
+
jsonSerializable = false;
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
walk(child, childMode, depth + 1);
|
|
327
|
+
if (!jsonSerializable)
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
const keys = Object.keys(value);
|
|
333
|
+
if (ownKeyCount !== keys.length) {
|
|
334
|
+
jsonSerializable = false;
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
const childKeys = [];
|
|
338
|
+
const childValues = [];
|
|
339
|
+
for (const key of keys) {
|
|
340
|
+
const desc = descs[key];
|
|
341
|
+
if (!desc || "get" in desc || "set" in desc) {
|
|
342
|
+
jsonSerializable = false;
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
childKeys.push(key);
|
|
346
|
+
childValues.push(desc.value);
|
|
347
|
+
}
|
|
348
|
+
if (typeof value.toJSON === "function") {
|
|
349
|
+
// JSON.stringify would call it and serialize the result instead.
|
|
350
|
+
jsonSerializable = false;
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
if (mode === 1) {
|
|
354
|
+
schemaNodes.push(value);
|
|
355
|
+
}
|
|
356
|
+
for (const [i, key] of childKeys.entries()) {
|
|
357
|
+
const child = childValues[i];
|
|
358
|
+
if (child === undefined) {
|
|
359
|
+
// JSON.stringify drops undefined-valued keys entirely.
|
|
360
|
+
jsonSerializable = false;
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
walk(child, childSchemaMode(mode, key), depth + 1);
|
|
364
|
+
if (!jsonSerializable)
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
walk(root, 1, 0);
|
|
370
|
+
if (!jsonSerializable) {
|
|
371
|
+
return { needsCleanup: false, jsonSerializable };
|
|
372
|
+
}
|
|
373
|
+
for (const node of schemaNodes) {
|
|
374
|
+
if (schemaWouldChange(node)) {
|
|
375
|
+
return { needsCleanup: true, jsonSerializable };
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
return { needsCleanup: false, jsonSerializable };
|
|
379
|
+
}
|
|
380
|
+
function childSchemaMode(mode, key) {
|
|
381
|
+
if (mode === 2)
|
|
382
|
+
return 1;
|
|
383
|
+
if (mode === 1) {
|
|
384
|
+
if (key === "properties")
|
|
385
|
+
return 2;
|
|
386
|
+
if (key === "items")
|
|
387
|
+
return 1;
|
|
388
|
+
}
|
|
389
|
+
return 0;
|
|
390
|
+
}
|
|
5
391
|
/**
|
|
6
392
|
* Cleans up tool definitions to ensure strict JSON Schema compliance.
|
|
7
393
|
*
|
|
@@ -44,15 +430,46 @@ function cleanupFunctionTool(tool) {
|
|
|
44
430
|
if (!isRecord(parameters)) {
|
|
45
431
|
return tool;
|
|
46
432
|
}
|
|
47
|
-
//
|
|
48
|
-
|
|
433
|
+
// Read-only pre-check: a schema that needs no cleanup skips the deep clone
|
|
434
|
+
// entirely. The check also verifies the tree is plain JSON data, because
|
|
435
|
+
// clone semantics (and therefore cleanup outcomes) only differ from
|
|
436
|
+
// observable behavior on inputs JSON.stringify would rewrite or reject.
|
|
437
|
+
// Any failure here just falls back to the exact legacy path.
|
|
438
|
+
let inspection = null;
|
|
49
439
|
try {
|
|
50
|
-
|
|
440
|
+
inspection = inspectSchema(parameters);
|
|
51
441
|
}
|
|
52
442
|
catch {
|
|
443
|
+
inspection = null;
|
|
444
|
+
}
|
|
445
|
+
if (inspection?.jsonSerializable && !inspection.needsCleanup) {
|
|
53
446
|
return tool;
|
|
54
447
|
}
|
|
55
|
-
|
|
448
|
+
// Clone only the schema tree we mutate to avoid heavy deep cloning of entire tools.
|
|
449
|
+
// Verified-JSON trees get the fused single-pass clone+clean; everything
|
|
450
|
+
// else keeps the exact JSON round-trip + in-place cleanup so throw/rewrite
|
|
451
|
+
// semantics on exotic inputs stay identical. If the fused pass still hits a
|
|
452
|
+
// value that lies about being plain data (e.g. a proxy whose get trap throws
|
|
453
|
+
// after reporting data descriptors), retry through the legacy clone rather
|
|
454
|
+
// than adding a new failure mode — the input tree is never mutated.
|
|
455
|
+
let cleanedParameters = null;
|
|
456
|
+
if (inspection?.jsonSerializable) {
|
|
457
|
+
try {
|
|
458
|
+
cleanedParameters = cloneAndCleanSchema(parameters);
|
|
459
|
+
}
|
|
460
|
+
catch {
|
|
461
|
+
cleanedParameters = null;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
if (cleanedParameters === null) {
|
|
465
|
+
try {
|
|
466
|
+
cleanedParameters = cloneRecord(parameters);
|
|
467
|
+
}
|
|
468
|
+
catch {
|
|
469
|
+
return tool;
|
|
470
|
+
}
|
|
471
|
+
cleanupSchema(cleanedParameters);
|
|
472
|
+
}
|
|
56
473
|
return {
|
|
57
474
|
...tool,
|
|
58
475
|
function: {
|
|
@@ -54,4 +54,3 @@ export interface RateLimitBackoffWithReasonParams {
|
|
|
54
54
|
export declare function getRateLimitBackoffWithReason(params: RateLimitBackoffWithReasonParams): RateLimitBackoffResult;
|
|
55
55
|
export declare function getRateLimitBackoffWithReason(accountIndex: number, quotaKey: string, serverRetryAfterMs: number | null | undefined, reason?: RateLimitReason, stableAccountKey?: StableAccountKey): RateLimitBackoffResult;
|
|
56
56
|
export {};
|
|
57
|
-
//# sourceMappingURL=rate-limit-backoff.d.ts.map
|
|
@@ -69,4 +69,3 @@ export interface PinnedUnavailableContext {
|
|
|
69
69
|
now?: number;
|
|
70
70
|
}
|
|
71
71
|
export declare function buildPinnedUnavailableErrorBody(pinnedIndex: number | null | undefined, accountSkipReasons: ReadonlyMap<number, string>, context?: PinnedUnavailableContext): PinnedUnavailableErrorBody;
|
|
72
|
-
//# sourceMappingURL=rate-limit-decision.d.ts.map
|
|
@@ -21,4 +21,3 @@ export declare function computeOutboundRequestAttemptBudget(params: {
|
|
|
21
21
|
* most one alternate account to avoid broad replay fan-out.
|
|
22
22
|
*/
|
|
23
23
|
export declare function buildStreamFailoverCandidateOrder(primaryIndex: number, accountIndices: number[]): number[];
|
|
24
|
-
//# sourceMappingURL=request-attempt-budget.d.ts.map
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
export declare function normalizeRequestInit(requestInput: Request | string | URL, requestInit: RequestInit | undefined): Promise<RequestInit | undefined>;
|
|
2
2
|
export declare function parseRequestBodyFromInit(body: unknown, logWarn: (message: string) => void): Promise<Record<string, unknown>>;
|
|
3
|
-
//# sourceMappingURL=request-init.d.ts.map
|
|
@@ -7,4 +7,3 @@ export declare function recordServerBurstFailure(accountIndex: number, now?: num
|
|
|
7
7
|
export declare function clearServerBurstCooldown(): void;
|
|
8
8
|
export declare function buildAdaptiveStreamFailoverCandidateOrder(primaryIndex: number, accounts: Array<Pick<ManagedAccount, "index" | "lastUsed" | "enabled" | "coolingDownUntil" | "rateLimitResetTimes">>, now?: number): number[];
|
|
9
9
|
export declare function resetRequestResilienceStateForTests(): void;
|
|
10
|
-
//# sourceMappingURL=request-resilience.d.ts.map
|
|
@@ -127,4 +127,3 @@ export declare function addToolRemapMessage(input: InputItem[] | undefined, hasT
|
|
|
127
127
|
*/
|
|
128
128
|
export declare function transformRequestBody(params: TransformRequestBodyParams): Promise<RequestBody>;
|
|
129
129
|
export declare function transformRequestBody(body: RequestBody, codexInstructions: string, userConfig?: UserConfig, codexMode?: boolean, fastSession?: boolean, fastSessionStrategy?: FastSessionStrategy, fastSessionMaxInputItems?: number, deferFastSessionInputTrimming?: boolean, allowBackgroundResponses?: boolean): Promise<RequestBody>;
|
|
130
|
-
//# sourceMappingURL=request-transformer.d.ts.map
|
|
@@ -409,25 +409,33 @@ export function filterInput(input, options) {
|
|
|
409
409
|
if (!Array.isArray(input))
|
|
410
410
|
return input;
|
|
411
411
|
const stripIds = options?.stripIds ?? true;
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
412
|
+
// Copy-on-write: items pass through by reference until the first drop or
|
|
413
|
+
// ID strip, so inputs with no ids never allocate a clone per item.
|
|
414
|
+
let filtered = null;
|
|
415
|
+
for (let i = 0; i < input.length; i++) {
|
|
416
|
+
const item = input[i];
|
|
417
|
+
if (!item || typeof item !== "object" || item.type === "item_reference") {
|
|
418
|
+
// Drop AI SDK constructs not supported by Codex API (and holes).
|
|
419
|
+
if (filtered === null) {
|
|
420
|
+
filtered = input.slice(0, i);
|
|
421
|
+
}
|
|
419
422
|
continue;
|
|
420
423
|
}
|
|
421
424
|
// Strip IDs from all items (Codex API stateless mode).
|
|
422
425
|
if (stripIds && "id" in item) {
|
|
423
426
|
const { id: _omit, ...itemWithoutId } = item;
|
|
424
427
|
void _omit;
|
|
428
|
+
if (filtered === null) {
|
|
429
|
+
filtered = input.slice(0, i);
|
|
430
|
+
}
|
|
425
431
|
filtered.push(itemWithoutId);
|
|
426
432
|
continue;
|
|
427
433
|
}
|
|
428
|
-
filtered
|
|
434
|
+
if (filtered !== null) {
|
|
435
|
+
filtered.push(item);
|
|
436
|
+
}
|
|
429
437
|
}
|
|
430
|
-
return filtered;
|
|
438
|
+
return filtered ?? input;
|
|
431
439
|
}
|
|
432
440
|
/**
|
|
433
441
|
* Trim long stateless histories for low-latency sessions.
|
|
@@ -512,6 +520,15 @@ export function trimInputForFastSession(input, maxItems, options) {
|
|
|
512
520
|
...trimmed.slice(trimmed.length - tailBudget),
|
|
513
521
|
];
|
|
514
522
|
}
|
|
523
|
+
// `[^\S\n]` is every whitespace except newline: `\s` between the anchor and the
|
|
524
|
+
// marker could span blank lines, and on whitespace-heavy multi-MB payloads the
|
|
525
|
+
// `^|\n` + `\s*` combination backtracked per position (a >20s stall observed on
|
|
526
|
+
// an all-whitespace body). Confining the run to a single line keeps the scan
|
|
527
|
+
// linear while matching the same "line starts with a list marker" shapes.
|
|
528
|
+
const MARKDOWN_LIST_ITEM_PATTERN = /(^|\n)[^\S\n]*(?:[-*]|\d+\.)[^\S\n]+\S/;
|
|
529
|
+
function hasMarkdownListItem(text) {
|
|
530
|
+
return MARKDOWN_LIST_ITEM_PATTERN.test(text);
|
|
531
|
+
}
|
|
515
532
|
function isTrivialLatestPrompt(text) {
|
|
516
533
|
const normalized = text.trim();
|
|
517
534
|
if (!normalized)
|
|
@@ -522,7 +539,7 @@ function isTrivialLatestPrompt(text) {
|
|
|
522
539
|
return false;
|
|
523
540
|
if (normalized.includes("```"))
|
|
524
541
|
return false;
|
|
525
|
-
if (
|
|
542
|
+
if (hasMarkdownListItem(normalized))
|
|
526
543
|
return false;
|
|
527
544
|
if (/https?:\/\//i.test(normalized))
|
|
528
545
|
return false;
|
|
@@ -539,7 +556,7 @@ function isStructurallyComplexPrompt(text) {
|
|
|
539
556
|
const lineCount = normalized.split(/\r?\n/).filter(Boolean).length;
|
|
540
557
|
if (lineCount >= 3)
|
|
541
558
|
return true;
|
|
542
|
-
if (
|
|
559
|
+
if (hasMarkdownListItem(normalized))
|
|
543
560
|
return true;
|
|
544
561
|
if (/\|.+\|/.test(normalized))
|
|
545
562
|
return true;
|
|
@@ -791,10 +808,12 @@ export async function transformRequestBody(bodyOrParams, codexInstructions, user
|
|
|
791
808
|
preferLatestUserOnly: fastSessionInputTrimPlan.trim?.preferLatestUserOnly ?? false,
|
|
792
809
|
}) ?? inputItems;
|
|
793
810
|
}
|
|
794
|
-
// Debug:
|
|
795
|
-
const originalIds =
|
|
796
|
-
|
|
797
|
-
|
|
811
|
+
// Debug: collect original input message IDs before filtering (single pass).
|
|
812
|
+
const originalIds = [];
|
|
813
|
+
for (const item of inputItems) {
|
|
814
|
+
if (item?.id)
|
|
815
|
+
originalIds.push(item.id);
|
|
816
|
+
}
|
|
798
817
|
if (originalIds.length > 0) {
|
|
799
818
|
logDebug(`Filtering ${originalIds.length} message IDs from input:`, originalIds);
|
|
800
819
|
}
|
|
@@ -802,16 +821,22 @@ export async function transformRequestBody(bodyOrParams, codexInstructions, user
|
|
|
802
821
|
stripIds: !backgroundModeRequested,
|
|
803
822
|
}) ?? inputItems;
|
|
804
823
|
body.input = inputItems;
|
|
805
|
-
//
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
824
|
+
// IDs surviving the filter are always a subset of the originals, so the
|
|
825
|
+
// second scan only runs when an ID was present beforehand. In stateless
|
|
826
|
+
// mode filterInput removes every ID, so the warn branch stays defensive.
|
|
827
|
+
if (originalIds.length > 0) {
|
|
828
|
+
const remainingIds = [];
|
|
829
|
+
for (const item of body.input) {
|
|
830
|
+
if (item?.id)
|
|
831
|
+
remainingIds.push(item.id);
|
|
832
|
+
}
|
|
833
|
+
// istanbul ignore next -- filterInput always removes IDs in stateless mode; this is defensive debug code
|
|
834
|
+
if (remainingIds.length > 0 && !backgroundModeRequested) {
|
|
835
|
+
logWarn(`WARNING: ${remainingIds.length} IDs still present after filtering:`, remainingIds);
|
|
836
|
+
}
|
|
837
|
+
else {
|
|
838
|
+
logDebug(`Successfully removed all ${originalIds.length} message IDs`);
|
|
839
|
+
}
|
|
815
840
|
}
|
|
816
841
|
if (resolvedCodexMode) {
|
|
817
842
|
// CODEX_MODE: Remove host system prompt, add bridge prompt
|
|
@@ -24,4 +24,3 @@ export declare function ensureContentType(headers: Headers): Headers;
|
|
|
24
24
|
*/
|
|
25
25
|
export declare function isEmptyResponse(body: unknown): boolean;
|
|
26
26
|
export declare function attachResponseIdCapture(response: Response, headers: Headers, onResponseId?: (responseId: string) => void, onUsage?: (usage: UsageTokenCounts) => void): Response;
|
|
27
|
-
//# sourceMappingURL=response-handler.d.ts.map
|
|
@@ -15,4 +15,3 @@ export declare function forwardStreamingResponse(upstream: Response, res: Server
|
|
|
15
15
|
onChunk?: (chunk: Uint8Array) => void,
|
|
16
16
|
/** Additional response headers, applied after (so they can override) the forwarded upstream ones. */
|
|
17
17
|
extraHeaders?: Record<string, string>, completion?: () => StreamCompletion): Promise<boolean>;
|
|
18
|
-
//# sourceMappingURL=stream-failover-runtime.d.ts.map
|
|
@@ -22,4 +22,3 @@ export interface StreamFailoverOptions {
|
|
|
22
22
|
* @returns A new Response that streams data from the initial response but may switch to fallback responses on stall/error, preserving the original status, statusText, and content-type header.
|
|
23
23
|
*/
|
|
24
24
|
export declare function withStreamingFailover(initialResponse: Response, getFallbackResponse: (attempt: number, emittedBytes: number) => Promise<Response | null>, options?: StreamFailoverOptions): Response;
|
|
25
|
-
//# sourceMappingURL=stream-failover.d.ts.map
|