codex-multi-auth 2.3.0-beta.1 → 2.3.0-beta.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 +2 -1
- package/README.md +4 -4
- package/config/schema/config.schema.json +268 -21
- package/dist/index.js +0 -1
- package/dist/lib/account-policy.d.ts.map +1 -1
- package/dist/lib/account-policy.js +2 -2
- package/dist/lib/accounts/rate-limits.js +0 -1
- package/dist/lib/accounts.d.ts +3 -8
- package/dist/lib/accounts.d.ts.map +1 -1
- package/dist/lib/accounts.js +2 -3
- package/dist/lib/audit.d.ts +0 -9
- package/dist/lib/audit.d.ts.map +1 -1
- package/dist/lib/audit.js +0 -1
- package/dist/lib/auth/auth.js +0 -1
- package/dist/lib/auth/browser.js +0 -1
- package/dist/lib/auth/device-auth.d.ts +1 -6
- package/dist/lib/auth/device-auth.d.ts.map +1 -1
- package/dist/lib/auth/device-auth.js +5 -6
- package/dist/lib/auth/index.js +0 -1
- package/dist/lib/auth/org-override.js +0 -1
- package/dist/lib/auth/server.js +0 -1
- package/dist/lib/auth/token-utils.js +0 -1
- package/dist/lib/auth-rate-limit.js +0 -1
- package/dist/lib/budget-guard.d.ts.map +1 -1
- package/dist/lib/budget-guard.js +2 -2
- package/dist/lib/capability-policy.js +0 -1
- package/dist/lib/circuit-breaker.js +0 -1
- package/dist/lib/cli.js +1 -2
- package/dist/lib/codex-cli/index.js +0 -1
- package/dist/lib/codex-cli/observability.js +0 -1
- package/dist/lib/codex-cli/state.js +0 -1
- package/dist/lib/codex-cli/sync.d.ts +2 -2
- package/dist/lib/codex-cli/sync.d.ts.map +1 -1
- package/dist/lib/codex-cli/sync.js +1 -2
- package/dist/lib/codex-cli/writer.d.ts.map +1 -1
- package/dist/lib/codex-cli/writer.js +2 -2
- package/dist/lib/codex-manager/account-credentials.d.ts +13 -0
- package/dist/lib/codex-manager/account-credentials.d.ts.map +1 -0
- package/dist/lib/codex-manager/account-credentials.js +55 -0
- package/dist/lib/codex-manager/account-manager-commands.js +0 -1
- package/dist/lib/codex-manager/account-pool-write.d.ts +1 -1
- package/dist/lib/codex-manager/account-pool-write.d.ts.map +1 -1
- package/dist/lib/codex-manager/account-pool-write.js +0 -1
- package/dist/lib/codex-manager/backend-category-entry.js +0 -1
- package/dist/lib/codex-manager/backend-category-helpers.js +0 -1
- package/dist/lib/codex-manager/backend-category-prompt.js +0 -1
- package/dist/lib/codex-manager/backend-settings-controller.js +0 -1
- package/dist/lib/codex-manager/backend-settings-entry.js +0 -1
- package/dist/lib/codex-manager/backend-settings-helpers.d.ts +0 -1
- package/dist/lib/codex-manager/backend-settings-helpers.d.ts.map +1 -1
- package/dist/lib/codex-manager/backend-settings-helpers.js +1 -2
- package/dist/lib/codex-manager/backend-settings-prompt.js +0 -1
- package/dist/lib/codex-manager/backend-settings-schema.js +0 -1
- package/dist/lib/codex-manager/behavior-settings-panel.d.ts +1 -20
- package/dist/lib/codex-manager/behavior-settings-panel.d.ts.map +1 -1
- package/dist/lib/codex-manager/behavior-settings-panel.js +0 -1
- package/dist/lib/codex-manager/commands/account.js +0 -1
- package/dist/lib/codex-manager/commands/best.d.ts +8 -0
- package/dist/lib/codex-manager/commands/best.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/best.js +64 -1
- package/dist/lib/codex-manager/commands/bridge.js +0 -1
- package/dist/lib/codex-manager/commands/budget.js +0 -1
- package/dist/lib/codex-manager/commands/check.js +0 -1
- package/dist/lib/codex-manager/commands/config-explain.js +0 -1
- package/dist/lib/codex-manager/commands/debug-bundle.js +0 -1
- package/dist/lib/codex-manager/commands/forecast.js +0 -1
- package/dist/lib/codex-manager/commands/init-config.js +0 -1
- package/dist/lib/codex-manager/commands/integrations.js +0 -1
- package/dist/lib/codex-manager/commands/models.js +0 -1
- package/dist/lib/codex-manager/commands/monitor.js +0 -1
- package/dist/lib/codex-manager/commands/report.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/report.js +2 -2
- package/dist/lib/codex-manager/commands/rotation.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/rotation.js +1 -4
- package/dist/lib/codex-manager/commands/status.js +0 -1
- package/dist/lib/codex-manager/commands/switch.js +0 -1
- package/dist/lib/codex-manager/commands/uninstall.d.ts +2 -2
- package/dist/lib/codex-manager/commands/uninstall.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/uninstall.js +3 -34
- package/dist/lib/codex-manager/commands/unpin.js +0 -1
- package/dist/lib/codex-manager/commands/usage.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/usage.js +2 -2
- package/dist/lib/codex-manager/commands/verify.d.ts +2 -2
- package/dist/lib/codex-manager/commands/verify.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/verify.js +0 -1
- package/dist/lib/codex-manager/commands/why-selected.d.ts +1 -22
- package/dist/lib/codex-manager/commands/why-selected.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/why-selected.js +0 -1
- package/dist/lib/codex-manager/commands/workspace.js +0 -1
- package/dist/lib/codex-manager/dashboard-display-panel.d.ts +1 -15
- package/dist/lib/codex-manager/dashboard-display-panel.d.ts.map +1 -1
- package/dist/lib/codex-manager/dashboard-display-panel.js +0 -1
- package/dist/lib/codex-manager/dashboard-formatters.js +0 -1
- package/dist/lib/codex-manager/dashboard-settings-controller.js +0 -1
- package/dist/lib/codex-manager/dashboard-settings-data.js +0 -1
- package/dist/lib/codex-manager/dashboard-settings-entry.js +0 -1
- package/dist/lib/codex-manager/experimental-settings-entry.js +0 -1
- package/dist/lib/codex-manager/experimental-settings-prompt.d.ts +2 -1
- package/dist/lib/codex-manager/experimental-settings-prompt.d.ts.map +1 -1
- package/dist/lib/codex-manager/experimental-settings-prompt.js +0 -1
- package/dist/lib/codex-manager/experimental-settings-schema.js +1 -2
- package/dist/lib/codex-manager/experimental-sync-target-entry.js +0 -1
- package/dist/lib/codex-manager/experimental-sync-target.js +0 -1
- package/dist/lib/codex-manager/forecast-report-commands.js +0 -1
- package/dist/lib/codex-manager/forecast-report-shared.d.ts +2 -2
- package/dist/lib/codex-manager/forecast-report-shared.d.ts.map +1 -1
- package/dist/lib/codex-manager/forecast-report-shared.js +5 -21
- package/dist/lib/codex-manager/formatters/account-formatters.d.ts +11 -0
- package/dist/lib/codex-manager/formatters/account-formatters.d.ts.map +1 -0
- package/dist/lib/codex-manager/formatters/account-formatters.js +79 -0
- package/dist/lib/codex-manager/formatters/index.d.ts +5 -0
- package/dist/lib/codex-manager/formatters/index.d.ts.map +1 -0
- package/dist/lib/codex-manager/formatters/index.js +4 -0
- package/dist/lib/codex-manager/formatters/model-formatters.d.ts +12 -0
- package/dist/lib/codex-manager/formatters/model-formatters.d.ts.map +1 -0
- package/dist/lib/codex-manager/formatters/model-formatters.js +23 -0
- package/dist/lib/codex-manager/formatters/quota-formatters.d.ts +9 -0
- package/dist/lib/codex-manager/formatters/quota-formatters.d.ts.map +1 -0
- package/dist/lib/codex-manager/formatters/quota-formatters.js +104 -0
- package/dist/lib/codex-manager/formatters/text-style.d.ts +14 -0
- package/dist/lib/codex-manager/formatters/text-style.d.ts.map +1 -0
- package/dist/lib/codex-manager/formatters/text-style.js +111 -0
- package/dist/lib/codex-manager/health-check.d.ts +14 -0
- package/dist/lib/codex-manager/health-check.d.ts.map +1 -0
- package/dist/lib/codex-manager/health-check.js +278 -0
- package/dist/lib/codex-manager/help.d.ts +2 -1
- package/dist/lib/codex-manager/help.d.ts.map +1 -1
- package/dist/lib/codex-manager/help.js +0 -1
- package/dist/lib/codex-manager/login-action-panel.d.ts +4 -0
- package/dist/lib/codex-manager/login-action-panel.d.ts.map +1 -0
- package/dist/lib/codex-manager/login-action-panel.js +238 -0
- package/dist/lib/codex-manager/login-flow.d.ts +17 -0
- package/dist/lib/codex-manager/login-flow.d.ts.map +1 -0
- package/dist/lib/codex-manager/login-flow.js +387 -0
- package/dist/lib/codex-manager/login-menu-actions.d.ts +20 -0
- package/dist/lib/codex-manager/login-menu-actions.d.ts.map +1 -0
- package/dist/lib/codex-manager/login-menu-actions.js +303 -0
- package/dist/lib/codex-manager/login-menu-data.d.ts +19 -0
- package/dist/lib/codex-manager/login-menu-data.d.ts.map +1 -0
- package/dist/lib/codex-manager/login-menu-data.js +378 -0
- package/dist/lib/codex-manager/login-oauth.d.ts +55 -0
- package/dist/lib/codex-manager/login-oauth.d.ts.map +1 -0
- package/dist/lib/codex-manager/login-oauth.js +345 -0
- package/dist/lib/codex-manager/manual-callback.js +0 -1
- package/dist/lib/codex-manager/persist-selected-account.d.ts +24 -0
- package/dist/lib/codex-manager/persist-selected-account.d.ts.map +1 -0
- package/dist/lib/codex-manager/persist-selected-account.js +107 -0
- package/dist/lib/codex-manager/quota-cache-helpers.d.ts +18 -0
- package/dist/lib/codex-manager/quota-cache-helpers.d.ts.map +1 -0
- package/dist/lib/codex-manager/quota-cache-helpers.js +112 -0
- package/dist/lib/codex-manager/rate-limit-markers.js +0 -1
- package/dist/lib/codex-manager/repair-commands.d.ts +0 -15
- package/dist/lib/codex-manager/repair-commands.d.ts.map +1 -1
- package/dist/lib/codex-manager/repair-commands.js +5 -6
- package/dist/lib/codex-manager/settings-hub/backend.d.ts +0 -5
- package/dist/lib/codex-manager/settings-hub/backend.d.ts.map +1 -1
- package/dist/lib/codex-manager/settings-hub/backend.js +2 -3
- package/dist/lib/codex-manager/settings-hub/dashboard.d.ts +1 -14
- package/dist/lib/codex-manager/settings-hub/dashboard.d.ts.map +1 -1
- package/dist/lib/codex-manager/settings-hub/dashboard.js +9 -10
- package/dist/lib/codex-manager/settings-hub/experimental.js +1 -2
- package/dist/lib/codex-manager/settings-hub/index.js +1 -2
- package/dist/lib/codex-manager/settings-hub/shared.js +0 -1
- package/dist/lib/codex-manager/settings-hub-entry.js +0 -1
- package/dist/lib/codex-manager/settings-hub-menu.js +0 -1
- package/dist/lib/codex-manager/settings-hub-prompt.js +0 -1
- package/dist/lib/codex-manager/settings-hub.js +0 -1
- package/dist/lib/codex-manager/settings-panels.js +0 -1
- package/dist/lib/codex-manager/settings-persist-utils.js +0 -1
- package/dist/lib/codex-manager/settings-preview.js +0 -1
- package/dist/lib/codex-manager/settings-write-queue.d.ts +0 -10
- package/dist/lib/codex-manager/settings-write-queue.d.ts.map +1 -1
- package/dist/lib/codex-manager/settings-write-queue.js +10 -11
- package/dist/lib/codex-manager/statusline-order.js +0 -1
- package/dist/lib/codex-manager/statusline-settings-panel.d.ts +3 -18
- package/dist/lib/codex-manager/statusline-settings-panel.d.ts.map +1 -1
- package/dist/lib/codex-manager/statusline-settings-panel.js +0 -1
- package/dist/lib/codex-manager/theme-settings-panel.d.ts +1 -14
- package/dist/lib/codex-manager/theme-settings-panel.d.ts.map +1 -1
- package/dist/lib/codex-manager/theme-settings-panel.js +0 -1
- package/dist/lib/codex-manager/unified-settings-controller.js +0 -1
- package/dist/lib/codex-manager/unified-settings-entry.js +0 -1
- package/dist/lib/codex-manager.d.ts +2 -4
- package/dist/lib/codex-manager.d.ts.map +1 -1
- package/dist/lib/codex-manager.js +219 -2570
- package/dist/lib/config-schema.d.ts +32 -0
- package/dist/lib/config-schema.d.ts.map +1 -0
- package/dist/lib/config-schema.js +96 -0
- package/dist/lib/config.d.ts +0 -13
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +82 -123
- package/dist/lib/constants.js +0 -1
- package/dist/lib/context-overflow.js +0 -1
- package/dist/lib/dashboard-settings.d.ts +3 -3
- package/dist/lib/dashboard-settings.d.ts.map +1 -1
- package/dist/lib/dashboard-settings.js +0 -2
- package/dist/lib/entitlement-cache.js +0 -1
- package/dist/lib/env-parsing.js +0 -1
- package/dist/lib/errors.d.ts +0 -1
- package/dist/lib/errors.d.ts.map +1 -1
- package/dist/lib/errors.js +0 -1
- package/dist/lib/forecast.d.ts +4 -3
- package/dist/lib/forecast.d.ts.map +1 -1
- package/dist/lib/forecast.js +0 -1
- package/dist/lib/fs-retry.d.ts +46 -3
- package/dist/lib/fs-retry.d.ts.map +1 -1
- package/dist/lib/fs-retry.js +77 -9
- package/dist/lib/health.js +0 -1
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +1 -1
- package/dist/lib/integration-generators.js +0 -1
- package/dist/lib/live-account-sync.js +0 -1
- package/dist/lib/local-bridge.js +0 -1
- package/dist/lib/local-client-tokens.d.ts.map +1 -1
- package/dist/lib/local-client-tokens.js +2 -2
- package/dist/lib/logger.js +0 -1
- package/dist/lib/model-capability-matrix.js +0 -1
- package/dist/lib/named-backup-export.js +0 -1
- package/dist/lib/oc-chatgpt-import-adapter.d.ts +1 -1
- package/dist/lib/oc-chatgpt-import-adapter.d.ts.map +1 -1
- package/dist/lib/oc-chatgpt-import-adapter.js +0 -1
- package/dist/lib/oc-chatgpt-orchestrator.d.ts.map +1 -1
- package/dist/lib/oc-chatgpt-orchestrator.js +2 -2
- package/dist/lib/oc-chatgpt-target-detection.d.ts +1 -1
- package/dist/lib/oc-chatgpt-target-detection.d.ts.map +1 -1
- package/dist/lib/oc-chatgpt-target-detection.js +0 -1
- package/dist/lib/parallel-probe.js +0 -1
- package/dist/lib/policy/runtime-policy.js +0 -1
- package/dist/lib/preemptive-quota-scheduler.js +0 -1
- package/dist/lib/proactive-refresh.js +0 -1
- package/dist/lib/prompts/codex-host-bridge.d.ts +0 -8
- package/dist/lib/prompts/codex-host-bridge.d.ts.map +1 -1
- package/dist/lib/prompts/codex-host-bridge.js +0 -21
- package/dist/lib/prompts/codex.d.ts +3 -11
- package/dist/lib/prompts/codex.d.ts.map +1 -1
- package/dist/lib/prompts/codex.js +6 -13
- package/dist/lib/prompts/fetch-utils.d.ts +0 -2
- package/dist/lib/prompts/fetch-utils.d.ts.map +1 -1
- package/dist/lib/prompts/fetch-utils.js +2 -3
- package/dist/lib/prompts/host-codex-prompt.d.ts.map +1 -1
- package/dist/lib/prompts/host-codex-prompt.js +2 -2
- package/dist/lib/quota-cache.d.ts.map +1 -1
- package/dist/lib/quota-cache.js +17 -44
- package/dist/lib/quota-probe.js +0 -1
- package/dist/lib/quota-readiness.js +0 -1
- package/dist/lib/recovery/constants.js +0 -1
- package/dist/lib/recovery/index.js +0 -1
- package/dist/lib/recovery/storage.d.ts.map +1 -1
- package/dist/lib/recovery/storage.js +35 -54
- package/dist/lib/recovery/storage.js.map +1 -1
- package/dist/lib/recovery/types.d.ts +4 -12
- package/dist/lib/recovery/types.d.ts.map +1 -1
- package/dist/lib/recovery/types.js +0 -1
- package/dist/lib/recovery.d.ts +2 -2
- package/dist/lib/recovery.d.ts.map +1 -1
- package/dist/lib/recovery.js +0 -1
- package/dist/lib/refresh-guardian.js +0 -1
- package/dist/lib/refresh-lease.d.ts.map +1 -1
- package/dist/lib/refresh-lease.js +1 -4
- package/dist/lib/refresh-queue.js +0 -1
- package/dist/lib/request/error-classification.d.ts +75 -0
- package/dist/lib/request/error-classification.d.ts.map +1 -0
- package/dist/lib/request/error-classification.js +295 -0
- package/dist/lib/request/failover-config.js +0 -1
- package/dist/lib/request/failure-policy.js +0 -1
- package/dist/lib/request/fetch-helpers.d.ts +10 -114
- package/dist/lib/request/fetch-helpers.d.ts.map +1 -1
- package/dist/lib/request/fetch-helpers.js +7 -589
- package/dist/lib/request/headers.d.ts +33 -0
- package/dist/lib/request/headers.d.ts.map +1 -0
- package/dist/lib/request/headers.js +64 -0
- package/dist/lib/request/helpers/input-utils.js +0 -1
- package/dist/lib/request/helpers/model-map.d.ts +10 -0
- package/dist/lib/request/helpers/model-map.d.ts.map +1 -1
- package/dist/lib/request/helpers/model-map.js +11 -1
- package/dist/lib/request/helpers/tool-utils.js +0 -1
- package/dist/lib/request/index.js +0 -1
- package/dist/lib/request/rate-limit-backoff.js +0 -1
- package/dist/lib/request/rate-limit-decision.d.ts +28 -0
- package/dist/lib/request/rate-limit-decision.d.ts.map +1 -0
- package/dist/lib/request/rate-limit-decision.js +191 -0
- package/dist/lib/request/request-attempt-budget.js +0 -1
- package/dist/lib/request/request-init.js +0 -1
- package/dist/lib/request/request-resilience.js +0 -1
- package/dist/lib/request/request-transformer.js +0 -1
- package/dist/lib/request/response-compaction.d.ts +2 -1
- package/dist/lib/request/response-compaction.d.ts.map +1 -1
- package/dist/lib/request/response-compaction.js +0 -1
- package/dist/lib/request/response-handler.js +0 -1
- package/dist/lib/request/response-metadata.js +0 -1
- package/dist/lib/request/stream-failover-runtime.d.ts +8 -0
- package/dist/lib/request/stream-failover-runtime.d.ts.map +1 -0
- package/dist/lib/request/stream-failover-runtime.js +171 -0
- package/dist/lib/request/stream-failover.js +0 -1
- package/dist/lib/request/token-refresh.d.ts +30 -0
- package/dist/lib/request/token-refresh.d.ts.map +1 -0
- package/dist/lib/request/token-refresh.js +116 -0
- package/dist/lib/request/url-rewriting.d.ts +24 -0
- package/dist/lib/request/url-rewriting.d.ts.map +1 -0
- package/dist/lib/request/url-rewriting.js +153 -0
- package/dist/lib/request/wait-utils.js +0 -1
- package/dist/lib/rotation.d.ts +2 -4
- package/dist/lib/rotation.d.ts.map +1 -1
- package/dist/lib/rotation.js +1 -3
- package/dist/lib/routing-mutex.js +0 -1
- package/dist/lib/routing-profiles.d.ts.map +1 -1
- package/dist/lib/routing-profiles.js +2 -2
- package/dist/lib/runtime/account-check-helpers.js +0 -1
- package/dist/lib/runtime/account-check-types.js +0 -1
- package/dist/lib/runtime/account-check.js +0 -1
- package/dist/lib/runtime/account-health-check.js +0 -1
- package/dist/lib/runtime/account-manager-cache-entry.js +0 -1
- package/dist/lib/runtime/account-manager-cache.js +0 -1
- package/dist/lib/runtime/account-pool.js +0 -1
- package/dist/lib/runtime/account-scope.js +0 -1
- package/dist/lib/runtime/account-select-event.js +0 -1
- package/dist/lib/runtime/account-selection.js +0 -1
- package/dist/lib/runtime/account-state.js +0 -1
- package/dist/lib/runtime/account-status.js +0 -1
- package/dist/lib/runtime/account-storage-scope-entry.js +0 -1
- package/dist/lib/runtime/app-bind.js +0 -1
- package/dist/lib/runtime/auth-facade.js +0 -1
- package/dist/lib/runtime/browser-oauth-flow.js +0 -1
- package/dist/lib/runtime/capability-boost.js +0 -1
- package/dist/lib/runtime/config-toml.d.ts +0 -6
- package/dist/lib/runtime/config-toml.d.ts.map +1 -1
- package/dist/lib/runtime/config-toml.js +6 -7
- package/dist/lib/runtime/event-handler.d.ts +0 -31
- package/dist/lib/runtime/event-handler.d.ts.map +1 -1
- package/dist/lib/runtime/event-handler.js +0 -23
- package/dist/lib/runtime/first-run.d.ts +78 -0
- package/dist/lib/runtime/first-run.d.ts.map +1 -0
- package/dist/lib/runtime/first-run.js +327 -0
- package/dist/lib/runtime/flagged-verify-types.js +0 -1
- package/dist/lib/runtime/hydrate-emails.js +0 -1
- package/dist/lib/runtime/live-sync-entry.js +0 -1
- package/dist/lib/runtime/live-sync.js +0 -1
- package/dist/lib/runtime/loader-setup.js +0 -1
- package/dist/lib/runtime/login-menu-accounts.js +0 -1
- package/dist/lib/runtime/manual-oauth-flow.js +0 -1
- package/dist/lib/runtime/oauth-browser-flow.js +0 -1
- package/dist/lib/runtime/preemptive-quota.js +0 -1
- package/dist/lib/runtime/quota-headers.d.ts +1 -6
- package/dist/lib/runtime/quota-headers.d.ts.map +1 -1
- package/dist/lib/runtime/quota-headers.js +5 -6
- package/dist/lib/runtime/quota-probe.js +0 -1
- package/dist/lib/runtime/quota-settings.js +0 -1
- package/dist/lib/runtime/refresh-guardian-entry.js +0 -1
- package/dist/lib/runtime/refresh-guardian.js +0 -1
- package/dist/lib/runtime/request-init.js +0 -1
- package/dist/lib/runtime/rotation-account-selection.d.ts +38 -0
- package/dist/lib/runtime/rotation-account-selection.d.ts.map +1 -0
- package/dist/lib/runtime/rotation-account-selection.js +172 -0
- package/dist/lib/runtime/rotation-proxy-state.d.ts +54 -0
- package/dist/lib/runtime/rotation-proxy-state.d.ts.map +1 -0
- package/dist/lib/runtime/rotation-proxy-state.js +56 -0
- package/dist/lib/runtime/rotation-server-types.d.ts +57 -0
- package/dist/lib/runtime/rotation-server-types.d.ts.map +1 -0
- package/dist/lib/runtime/rotation-server-types.js +1 -0
- package/dist/lib/runtime/rotation-storage-meta.d.ts +40 -0
- package/dist/lib/runtime/rotation-storage-meta.d.ts.map +1 -0
- package/dist/lib/runtime/rotation-storage-meta.js +143 -0
- package/dist/lib/runtime/rotation-token-refresh.d.ts +25 -0
- package/dist/lib/runtime/rotation-token-refresh.d.ts.map +1 -0
- package/dist/lib/runtime/rotation-token-refresh.js +99 -0
- package/dist/lib/runtime/runtime-current-account.d.ts +3 -3
- package/dist/lib/runtime/runtime-current-account.d.ts.map +1 -1
- package/dist/lib/runtime/runtime-current-account.js +2 -5
- package/dist/lib/runtime/runtime-observability.d.ts +2 -2
- package/dist/lib/runtime/runtime-observability.d.ts.map +1 -1
- package/dist/lib/runtime/runtime-observability.js +0 -5
- package/dist/lib/runtime/runtime-services.js +0 -1
- package/dist/lib/runtime/session-affinity-entry.js +0 -1
- package/dist/lib/runtime/session-affinity.js +0 -1
- package/dist/lib/runtime/session-recovery.js +0 -1
- package/dist/lib/runtime/status-marker.js +0 -1
- package/dist/lib/runtime/storage-scope.js +0 -1
- package/dist/lib/runtime/toast.js +0 -1
- package/dist/lib/runtime/ui-runtime-entry.js +0 -1
- package/dist/lib/runtime/ui-runtime.js +0 -1
- package/dist/lib/runtime/verify-flagged.js +0 -1
- package/dist/lib/runtime-constants.js +0 -1
- package/dist/lib/runtime-paths.js +0 -1
- package/dist/lib/runtime-rotation-proxy.d.ts +7 -124
- package/dist/lib/runtime-rotation-proxy.d.ts.map +1 -1
- package/dist/lib/runtime-rotation-proxy.js +618 -1356
- package/dist/lib/schemas.d.ts +5 -93
- package/dist/lib/schemas.d.ts.map +1 -1
- package/dist/lib/schemas.js +9 -10
- package/dist/lib/session-affinity.js +0 -1
- package/dist/lib/shutdown.js +0 -1
- package/dist/lib/storage/account-clear-entry.js +0 -1
- package/dist/lib/storage/account-clear.js +0 -1
- package/dist/lib/storage/account-match-utils.js +0 -1
- package/dist/lib/storage/account-persistence.d.ts +1 -1
- package/dist/lib/storage/account-persistence.d.ts.map +1 -1
- package/dist/lib/storage/account-persistence.js +0 -1
- package/dist/lib/storage/account-port.d.ts +1 -1
- package/dist/lib/storage/account-port.d.ts.map +1 -1
- package/dist/lib/storage/account-port.js +0 -1
- package/dist/lib/storage/account-save-entry.d.ts +1 -1
- package/dist/lib/storage/account-save-entry.d.ts.map +1 -1
- package/dist/lib/storage/account-save-entry.js +0 -1
- package/dist/lib/storage/account-save.d.ts +1 -1
- package/dist/lib/storage/account-save.d.ts.map +1 -1
- package/dist/lib/storage/account-save.js +0 -1
- package/dist/lib/storage/account-snapshot.js +0 -1
- package/dist/lib/storage/backup-metadata-builder.d.ts +1 -1
- package/dist/lib/storage/backup-metadata-builder.d.ts.map +1 -1
- package/dist/lib/storage/backup-metadata-builder.js +0 -1
- package/dist/lib/storage/backup-metadata.d.ts +13 -0
- package/dist/lib/storage/backup-metadata.d.ts.map +1 -1
- package/dist/lib/storage/backup-metadata.js +0 -1
- package/dist/lib/storage/backup-paths.js +0 -1
- package/dist/lib/storage/backup-restore.d.ts +1 -1
- package/dist/lib/storage/backup-restore.d.ts.map +1 -1
- package/dist/lib/storage/backup-restore.js +0 -1
- package/dist/lib/storage/cache-artifacts.js +0 -1
- package/dist/lib/storage/error-hints.js +0 -1
- package/dist/lib/storage/file-paths.d.ts +2 -2
- package/dist/lib/storage/file-paths.d.ts.map +1 -1
- package/dist/lib/storage/file-paths.js +2 -3
- package/dist/lib/storage/fixture-guards.d.ts +1 -1
- package/dist/lib/storage/fixture-guards.d.ts.map +1 -1
- package/dist/lib/storage/fixture-guards.js +0 -1
- package/dist/lib/storage/flagged-entry.js +0 -1
- package/dist/lib/storage/flagged-load-entry.d.ts +1 -1
- package/dist/lib/storage/flagged-load-entry.d.ts.map +1 -1
- package/dist/lib/storage/flagged-load-entry.js +0 -1
- package/dist/lib/storage/flagged-save-entry.d.ts +1 -1
- package/dist/lib/storage/flagged-save-entry.d.ts.map +1 -1
- package/dist/lib/storage/flagged-save-entry.js +0 -1
- package/dist/lib/storage/flagged-storage-file.d.ts +1 -1
- package/dist/lib/storage/flagged-storage-file.d.ts.map +1 -1
- package/dist/lib/storage/flagged-storage-file.js +0 -1
- package/dist/lib/storage/flagged-storage-io.d.ts +1 -1
- package/dist/lib/storage/flagged-storage-io.d.ts.map +1 -1
- package/dist/lib/storage/flagged-storage-io.js +2 -3
- package/dist/lib/storage/flagged-storage.d.ts +1 -1
- package/dist/lib/storage/flagged-storage.d.ts.map +1 -1
- package/dist/lib/storage/flagged-storage.js +15 -2
- package/dist/lib/storage/flagged-storage.js.map +1 -1
- package/dist/lib/storage/gitignore.js +0 -1
- package/dist/lib/storage/hash.js +0 -1
- package/dist/lib/storage/health.js +0 -1
- package/dist/lib/storage/identity.js +0 -1
- package/dist/lib/storage/import-export.d.ts +1 -1
- package/dist/lib/storage/import-export.d.ts.map +1 -1
- package/dist/lib/storage/import-export.js +2 -3
- package/dist/lib/storage/metadata-section.js +0 -1
- package/dist/lib/storage/migrations.d.ts +7 -49
- package/dist/lib/storage/migrations.d.ts.map +1 -1
- package/dist/lib/storage/migrations.js +5 -2
- package/dist/lib/storage/named-backup-entry.js +0 -1
- package/dist/lib/storage/named-backups-entry.d.ts +1 -1
- package/dist/lib/storage/named-backups-entry.d.ts.map +1 -1
- package/dist/lib/storage/named-backups-entry.js +0 -1
- package/dist/lib/storage/named-backups.js +0 -1
- package/dist/lib/storage/path-state.js +0 -1
- package/dist/lib/storage/paths.js +0 -1
- package/dist/lib/storage/project-migration.d.ts +1 -1
- package/dist/lib/storage/project-migration.d.ts.map +1 -1
- package/dist/lib/storage/project-migration.js +0 -1
- package/dist/lib/storage/public-types.d.ts +70 -0
- package/dist/lib/storage/public-types.d.ts.map +1 -0
- package/dist/lib/storage/public-types.js +6 -0
- package/dist/lib/storage/record-utils.js +0 -1
- package/dist/lib/storage/restore-assessment.d.ts +1 -1
- package/dist/lib/storage/restore-assessment.d.ts.map +1 -1
- package/dist/lib/storage/restore-assessment.js +0 -1
- package/dist/lib/storage/restore-backup-entry.d.ts +1 -1
- package/dist/lib/storage/restore-backup-entry.d.ts.map +1 -1
- package/dist/lib/storage/restore-backup-entry.js +0 -1
- package/dist/lib/storage/restore-metadata.d.ts +1 -1
- package/dist/lib/storage/restore-metadata.d.ts.map +1 -1
- package/dist/lib/storage/restore-metadata.js +0 -1
- package/dist/lib/storage/restore.d.ts +1 -1
- package/dist/lib/storage/restore.d.ts.map +1 -1
- package/dist/lib/storage/restore.js +0 -1
- package/dist/lib/storage/save-retry.d.ts +10 -0
- package/dist/lib/storage/save-retry.d.ts.map +1 -0
- package/dist/lib/storage/save-retry.js +26 -0
- package/dist/lib/storage/snapshot-inspectors.d.ts +1 -1
- package/dist/lib/storage/snapshot-inspectors.d.ts.map +1 -1
- package/dist/lib/storage/snapshot-inspectors.js +0 -1
- package/dist/lib/storage/storage-parser.d.ts +1 -1
- package/dist/lib/storage/storage-parser.d.ts.map +1 -1
- package/dist/lib/storage/storage-parser.js +0 -1
- package/dist/lib/storage/transactions.d.ts +1 -1
- package/dist/lib/storage/transactions.d.ts.map +1 -1
- package/dist/lib/storage/transactions.js +0 -1
- package/dist/lib/storage.d.ts +3 -24
- package/dist/lib/storage.d.ts.map +1 -1
- package/dist/lib/storage.js +47 -55
- package/dist/lib/table-formatter.js +0 -1
- package/dist/lib/temp-path.d.ts +26 -0
- package/dist/lib/temp-path.d.ts.map +1 -0
- package/dist/lib/temp-path.js +30 -0
- package/dist/lib/tools/hashline-tools.js +0 -1
- package/dist/lib/types.js +0 -1
- package/dist/lib/ui/ansi.js +0 -1
- package/dist/lib/ui/auth-menu-builder.d.ts +89 -0
- package/dist/lib/ui/auth-menu-builder.d.ts.map +1 -0
- package/dist/lib/ui/auth-menu-builder.js +350 -0
- package/dist/lib/ui/auth-menu.d.ts +2 -76
- package/dist/lib/ui/auth-menu.d.ts.map +1 -1
- package/dist/lib/ui/auth-menu.js +3 -349
- package/dist/lib/ui/confirm.js +0 -1
- package/dist/lib/ui/display-width.js +0 -1
- package/dist/lib/ui/format.js +0 -1
- package/dist/lib/ui/index.d.ts +10 -0
- package/dist/lib/ui/index.d.ts.map +1 -0
- package/dist/lib/ui/index.js +9 -0
- package/dist/lib/ui/runtime.js +0 -1
- package/dist/lib/ui/select.js +0 -1
- package/dist/lib/ui/theme.d.ts +3 -2
- package/dist/lib/ui/theme.d.ts.map +1 -1
- package/dist/lib/ui/theme.js +0 -1
- package/dist/lib/ui/ui-copy.d.ts +159 -0
- package/dist/lib/ui/ui-copy.d.ts.map +1 -0
- package/dist/lib/ui/ui-copy.js +163 -0
- package/dist/lib/unified-settings.d.ts.map +1 -1
- package/dist/lib/unified-settings.js +2 -2
- package/dist/lib/update-notice.d.ts.map +1 -1
- package/dist/lib/update-notice.js +2 -2
- package/dist/lib/usage/index.js +0 -1
- package/dist/lib/usage/ledger.js +0 -1
- package/dist/lib/usage/pricing.js +0 -1
- package/dist/lib/usage/redaction.js +0 -1
- package/dist/lib/usage/types.js +0 -1
- package/dist/lib/utils.js +0 -1
- package/package.json +8 -9
- package/scripts/postinstall.js +34 -265
- package/scripts/preuninstall.js +2 -2
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token refresh helpers for the custom fetch implementation
|
|
3
|
+
* Extracted from fetch-helpers.ts (audit roadmap §4.1.2); fetch-helpers.ts
|
|
4
|
+
* re-exports the public symbols so existing importers are unchanged.
|
|
5
|
+
*/
|
|
6
|
+
import { queuedRefresh } from "../refresh-queue.js";
|
|
7
|
+
import { CodexAuthError } from "../errors.js";
|
|
8
|
+
import { HTTP_STATUS, ERROR_MESSAGES } from "../constants.js";
|
|
9
|
+
/**
|
|
10
|
+
* Determines if the current auth token needs to be refreshed
|
|
11
|
+
* @param auth - Current authentication state
|
|
12
|
+
* @returns True if token is expired or invalid
|
|
13
|
+
*/
|
|
14
|
+
export function shouldRefreshToken(auth, skewMs = 0) {
|
|
15
|
+
if (auth.type !== "oauth")
|
|
16
|
+
return true;
|
|
17
|
+
if (!auth.access)
|
|
18
|
+
return true;
|
|
19
|
+
const safeSkewMs = Math.max(0, Math.floor(skewMs));
|
|
20
|
+
return auth.expires <= Date.now() + safeSkewMs;
|
|
21
|
+
}
|
|
22
|
+
function isRetryableRefreshFailure(result) {
|
|
23
|
+
switch (result.reason) {
|
|
24
|
+
case "network_error":
|
|
25
|
+
case "unknown":
|
|
26
|
+
case "invalid_response":
|
|
27
|
+
return true;
|
|
28
|
+
case "missing_refresh":
|
|
29
|
+
return false;
|
|
30
|
+
case "http_error":
|
|
31
|
+
return !(result.statusCode === HTTP_STATUS.BAD_REQUEST ||
|
|
32
|
+
result.statusCode === HTTP_STATUS.UNAUTHORIZED ||
|
|
33
|
+
result.statusCode === HTTP_STATUS.FORBIDDEN);
|
|
34
|
+
default:
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function isRetryableAuthSetterError(error) {
|
|
39
|
+
if (!error || typeof error !== "object") {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
const candidate = error;
|
|
43
|
+
const code = typeof candidate.code === "string"
|
|
44
|
+
? candidate.code.toUpperCase()
|
|
45
|
+
: undefined;
|
|
46
|
+
if (code === "EAGAIN" || code === "EBUSY" || code === "EPERM") {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
if (candidate.status === HTTP_STATUS.TOO_MANY_REQUESTS) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
if (candidate.cause && candidate.cause !== error) {
|
|
53
|
+
return isRetryableAuthSetterError(candidate.cause);
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Refreshes the OAuth token and updates stored credentials
|
|
59
|
+
*
|
|
60
|
+
* Mutation contract: on success the passed `currentAuth` object is updated
|
|
61
|
+
* IN PLACE (access/refresh/expires) after the persistence await, and the same
|
|
62
|
+
* reference is returned. Same-account refreshes are serialized by
|
|
63
|
+
* `queuedRefresh`, so two concurrent calls for one account coalesce rather
|
|
64
|
+
* than race; callers must still not share one Auth object across calls for
|
|
65
|
+
* DIFFERENT accounts, and must not read token fields from a shared reference
|
|
66
|
+
* while a refresh for it is in flight (the window between the persistence
|
|
67
|
+
* await and the mutation block exposes the pre-refresh values).
|
|
68
|
+
*
|
|
69
|
+
* @param currentAuth - Current auth state
|
|
70
|
+
* @param client - Codex client for updating stored credentials
|
|
71
|
+
* @returns Updated auth (throws on failure)
|
|
72
|
+
*/
|
|
73
|
+
export async function refreshAndUpdateToken(currentAuth, client) {
|
|
74
|
+
const authSetter = client.auth;
|
|
75
|
+
if (!authSetter || typeof authSetter.set !== "function") {
|
|
76
|
+
throw new CodexAuthError(ERROR_MESSAGES.TOKEN_REFRESH_FAILED, {
|
|
77
|
+
retryable: false,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
const refreshToken = currentAuth.type === "oauth" ? currentAuth.refresh : "";
|
|
81
|
+
const refreshResult = await queuedRefresh(refreshToken);
|
|
82
|
+
if (refreshResult.type === "failed") {
|
|
83
|
+
throw new CodexAuthError(ERROR_MESSAGES.TOKEN_REFRESH_FAILED, {
|
|
84
|
+
retryable: isRetryableRefreshFailure(refreshResult),
|
|
85
|
+
context: {
|
|
86
|
+
refreshFailureReason: refreshResult.reason,
|
|
87
|
+
statusCode: refreshResult.statusCode,
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
try {
|
|
92
|
+
await authSetter.set({
|
|
93
|
+
path: { id: "openai" },
|
|
94
|
+
body: {
|
|
95
|
+
type: "oauth",
|
|
96
|
+
access: refreshResult.access,
|
|
97
|
+
refresh: refreshResult.refresh,
|
|
98
|
+
expires: refreshResult.expires,
|
|
99
|
+
multiAccount: true,
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
throw new CodexAuthError(ERROR_MESSAGES.TOKEN_REFRESH_FAILED, {
|
|
105
|
+
retryable: isRetryableAuthSetterError(error),
|
|
106
|
+
cause: error,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
// Update current auth reference if it's OAuth type
|
|
110
|
+
if (currentAuth.type === "oauth") {
|
|
111
|
+
currentAuth.access = refreshResult.access;
|
|
112
|
+
currentAuth.refresh = refreshResult.refresh;
|
|
113
|
+
currentAuth.expires = refreshResult.expires;
|
|
114
|
+
}
|
|
115
|
+
return currentAuth;
|
|
116
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* URL rewriting and proxy resolution helpers for the custom fetch implementation
|
|
3
|
+
* Extracted from fetch-helpers.ts (audit roadmap §4.1.2); fetch-helpers.ts
|
|
4
|
+
* re-exports the public symbols so existing importers are unchanged.
|
|
5
|
+
*/
|
|
6
|
+
export interface ProxyCompatibleRequestInit extends RequestInit {
|
|
7
|
+
agent?: unknown;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Extracts URL string from various request input types
|
|
11
|
+
* @param input - Request input (string, URL, or Request object)
|
|
12
|
+
* @returns URL string
|
|
13
|
+
*/
|
|
14
|
+
export declare function extractRequestUrl(input: Request | string | URL): string;
|
|
15
|
+
/**
|
|
16
|
+
* Rewrites OpenAI API URLs to Codex backend URLs
|
|
17
|
+
* @param url - Original URL
|
|
18
|
+
* @returns Rewritten URL for Codex backend
|
|
19
|
+
*/
|
|
20
|
+
export declare function rewriteUrlForCodex(url: string): string;
|
|
21
|
+
export declare function resolveProxyUrlForRequest(url: string, env?: NodeJS.ProcessEnv): string | undefined;
|
|
22
|
+
export declare function closeSharedProxyDispatchers(): Promise<void>;
|
|
23
|
+
export declare function applyProxyCompatibleInit(url: string, init?: ProxyCompatibleRequestInit, env?: NodeJS.ProcessEnv): ProxyCompatibleRequestInit;
|
|
24
|
+
//# sourceMappingURL=url-rewriting.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"url-rewriting.d.ts","sourceRoot":"","sources":["../../../lib/request/url-rewriting.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAsBH,MAAM,WAAW,0BAA2B,SAAQ,WAAW;IAC9D,KAAK,CAAC,EAAE,OAAO,CAAC;CAChB;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,GAAG,GAAG,MAAM,CAIvE;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAkBtD;AA8DD,wBAAgB,yBAAyB,CACxC,GAAG,EAAE,MAAM,EACX,GAAG,GAAE,MAAM,CAAC,UAAwB,GAClC,MAAM,GAAG,SAAS,CAoBpB;AAaD,wBAAsB,2BAA2B,IAAI,OAAO,CAAC,IAAI,CAAC,CAajE;AAID,wBAAgB,wBAAwB,CACvC,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,0BAA0B,EACjC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAClC,0BAA0B,CAe5B"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* URL rewriting and proxy resolution helpers for the custom fetch implementation
|
|
3
|
+
* Extracted from fetch-helpers.ts (audit roadmap §4.1.2); fetch-helpers.ts
|
|
4
|
+
* re-exports the public symbols so existing importers are unchanged.
|
|
5
|
+
*/
|
|
6
|
+
import { ProxyAgent } from "undici";
|
|
7
|
+
import { registerCleanup } from "../shutdown.js";
|
|
8
|
+
import { CODEX_BASE_URL, URL_PATHS } from "../constants.js";
|
|
9
|
+
const CODEX_BASE_URL_OBJECT = new URL(CODEX_BASE_URL);
|
|
10
|
+
const CODEX_BASE_PATH_PREFIX = CODEX_BASE_URL_OBJECT.pathname.endsWith("/")
|
|
11
|
+
? CODEX_BASE_URL_OBJECT.pathname.slice(0, -1)
|
|
12
|
+
: CODEX_BASE_URL_OBJECT.pathname;
|
|
13
|
+
const DEFAULT_PROXY_PORTS = {
|
|
14
|
+
"http:": 80,
|
|
15
|
+
"https:": 443,
|
|
16
|
+
};
|
|
17
|
+
const sharedProxyDispatchers = new Map();
|
|
18
|
+
/**
|
|
19
|
+
* Extracts URL string from various request input types
|
|
20
|
+
* @param input - Request input (string, URL, or Request object)
|
|
21
|
+
* @returns URL string
|
|
22
|
+
*/
|
|
23
|
+
export function extractRequestUrl(input) {
|
|
24
|
+
if (typeof input === "string")
|
|
25
|
+
return input;
|
|
26
|
+
if (input instanceof URL)
|
|
27
|
+
return input.toString();
|
|
28
|
+
return input.url;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Rewrites OpenAI API URLs to Codex backend URLs
|
|
32
|
+
* @param url - Original URL
|
|
33
|
+
* @returns Rewritten URL for Codex backend
|
|
34
|
+
*/
|
|
35
|
+
export function rewriteUrlForCodex(url) {
|
|
36
|
+
const parsedUrl = new URL(url);
|
|
37
|
+
const rewrittenPath = parsedUrl.pathname.includes(URL_PATHS.RESPONSES)
|
|
38
|
+
? parsedUrl.pathname.replace(URL_PATHS.RESPONSES, URL_PATHS.CODEX_RESPONSES)
|
|
39
|
+
: parsedUrl.pathname;
|
|
40
|
+
const normalizedPath = rewrittenPath === CODEX_BASE_PATH_PREFIX ||
|
|
41
|
+
rewrittenPath.startsWith(`${CODEX_BASE_PATH_PREFIX}/`)
|
|
42
|
+
? rewrittenPath
|
|
43
|
+
: `${CODEX_BASE_PATH_PREFIX}${rewrittenPath.startsWith("/") ? rewrittenPath : `/${rewrittenPath}`}`;
|
|
44
|
+
parsedUrl.protocol = CODEX_BASE_URL_OBJECT.protocol;
|
|
45
|
+
parsedUrl.username = "";
|
|
46
|
+
parsedUrl.password = "";
|
|
47
|
+
parsedUrl.host = CODEX_BASE_URL_OBJECT.host;
|
|
48
|
+
parsedUrl.pathname = normalizedPath;
|
|
49
|
+
return parsedUrl.toString();
|
|
50
|
+
}
|
|
51
|
+
function hasOwnEnvKey(env, key) {
|
|
52
|
+
return Object.prototype.hasOwnProperty.call(env, key);
|
|
53
|
+
}
|
|
54
|
+
function resolveProxyEnvValue(env, lowerKey, upperKey) {
|
|
55
|
+
if (hasOwnEnvKey(env, lowerKey)) {
|
|
56
|
+
const value = env[lowerKey]?.trim();
|
|
57
|
+
return value ? value : undefined;
|
|
58
|
+
}
|
|
59
|
+
const value = env[upperKey]?.trim();
|
|
60
|
+
return value ? value : undefined;
|
|
61
|
+
}
|
|
62
|
+
function parseNoProxyEntries(noProxyValue) {
|
|
63
|
+
return noProxyValue
|
|
64
|
+
.split(/[,\s]/)
|
|
65
|
+
.map((entry) => entry.trim())
|
|
66
|
+
.filter(Boolean)
|
|
67
|
+
.map((entry) => {
|
|
68
|
+
const parsed = entry.match(/^(.+):(\d+)$/);
|
|
69
|
+
const hostname = parsed?.[1] ?? entry;
|
|
70
|
+
const portText = parsed?.[2];
|
|
71
|
+
return {
|
|
72
|
+
hostname: hostname.toLowerCase(),
|
|
73
|
+
port: portText ? Number.parseInt(portText, 10) : 0,
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
function shouldBypassProxyForUrl(url, noProxyValue) {
|
|
78
|
+
if (!noProxyValue)
|
|
79
|
+
return false;
|
|
80
|
+
if (noProxyValue === "*")
|
|
81
|
+
return true;
|
|
82
|
+
const hostname = url.host.replace(/:\d*$/, "").toLowerCase();
|
|
83
|
+
const port = Number.parseInt(url.port, 10) || DEFAULT_PROXY_PORTS[url.protocol] || 0;
|
|
84
|
+
for (const entry of parseNoProxyEntries(noProxyValue)) {
|
|
85
|
+
if (entry.hostname === "*")
|
|
86
|
+
return true;
|
|
87
|
+
if (entry.port && entry.port !== port)
|
|
88
|
+
continue;
|
|
89
|
+
if (!/^[.*]/.test(entry.hostname)) {
|
|
90
|
+
if (hostname === entry.hostname) {
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if (hostname.endsWith(entry.hostname.replace(/^\*/, ""))) {
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
export function resolveProxyUrlForRequest(url, env = process.env) {
|
|
102
|
+
const parsed = new URL(url);
|
|
103
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
const httpProxy = resolveProxyEnvValue(env, "http_proxy", "HTTP_PROXY");
|
|
107
|
+
const httpsProxy = resolveProxyEnvValue(env, "https_proxy", "HTTPS_PROXY");
|
|
108
|
+
if (!httpProxy && !httpsProxy) {
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
const noProxy = resolveProxyEnvValue(env, "no_proxy", "NO_PROXY");
|
|
112
|
+
if (shouldBypassProxyForUrl(parsed, noProxy)) {
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
return parsed.protocol === "https:"
|
|
116
|
+
? (httpsProxy ?? httpProxy)
|
|
117
|
+
: httpProxy;
|
|
118
|
+
}
|
|
119
|
+
function getSharedProxyDispatcher(proxyUrl) {
|
|
120
|
+
const existing = sharedProxyDispatchers.get(proxyUrl);
|
|
121
|
+
if (existing) {
|
|
122
|
+
return existing;
|
|
123
|
+
}
|
|
124
|
+
const dispatcher = new ProxyAgent(proxyUrl);
|
|
125
|
+
sharedProxyDispatchers.set(proxyUrl, dispatcher);
|
|
126
|
+
return dispatcher;
|
|
127
|
+
}
|
|
128
|
+
export async function closeSharedProxyDispatchers() {
|
|
129
|
+
while (sharedProxyDispatchers.size > 0) {
|
|
130
|
+
const dispatchers = [...sharedProxyDispatchers.values()];
|
|
131
|
+
sharedProxyDispatchers.clear();
|
|
132
|
+
await Promise.allSettled(dispatchers.map(async (dispatcher) => {
|
|
133
|
+
if (typeof dispatcher.close === "function") {
|
|
134
|
+
await dispatcher.close();
|
|
135
|
+
}
|
|
136
|
+
}));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
registerCleanup(closeSharedProxyDispatchers);
|
|
140
|
+
export function applyProxyCompatibleInit(url, init, env = process.env) {
|
|
141
|
+
const resolvedInit = init ?? {};
|
|
142
|
+
if (resolvedInit.dispatcher || resolvedInit.agent) {
|
|
143
|
+
return resolvedInit;
|
|
144
|
+
}
|
|
145
|
+
const proxyUrl = resolveProxyUrlForRequest(url, env);
|
|
146
|
+
if (!proxyUrl) {
|
|
147
|
+
return resolvedInit;
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
...resolvedInit,
|
|
151
|
+
dispatcher: getSharedProxyDispatcher(proxyUrl),
|
|
152
|
+
};
|
|
153
|
+
}
|
package/dist/lib/rotation.d.ts
CHANGED
|
@@ -5,8 +5,6 @@
|
|
|
5
5
|
* Ported from antigravity-auth rotation logic for optimal account rotation
|
|
6
6
|
* when rate limits are encountered.
|
|
7
7
|
*/
|
|
8
|
-
export type { SelectionRecord, RoutingMutexMode, AsyncMutex, } from "./routing-mutex.js";
|
|
9
|
-
export { createAsyncMutex, getRoutingMutex, withRoutingMutex, } from "./routing-mutex.js";
|
|
10
8
|
export interface HealthScoreConfig {
|
|
11
9
|
/** Points added on successful request */
|
|
12
10
|
successDelta: number;
|
|
@@ -101,10 +99,9 @@ export interface HybridSelectionConfig {
|
|
|
101
99
|
healthWeight: number;
|
|
102
100
|
/** Weight for token count (default: 5) */
|
|
103
101
|
tokenWeight: number;
|
|
104
|
-
/** Weight for freshness/last used (default:
|
|
102
|
+
/** Weight for freshness/last used (default: 2) */
|
|
105
103
|
freshnessWeight: number;
|
|
106
104
|
}
|
|
107
|
-
export declare const DEFAULT_HYBRID_SELECTION_CONFIG: HybridSelectionConfig;
|
|
108
105
|
/**
|
|
109
106
|
* Selects the best account using a hybrid scoring strategy.
|
|
110
107
|
*
|
|
@@ -231,4 +228,5 @@ export declare function exponentialBackoff(attempt: number, baseMs?: number, max
|
|
|
231
228
|
export declare function getHealthTracker(config?: Partial<HealthScoreConfig>): HealthScoreTracker;
|
|
232
229
|
export declare function getTokenTracker(config?: Partial<TokenBucketConfig>): TokenBucketTracker;
|
|
233
230
|
export declare function resetTrackers(): void;
|
|
231
|
+
export {};
|
|
234
232
|
//# sourceMappingURL=rotation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rotation.d.ts","sourceRoot":"","sources":["../../lib/rotation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"rotation.d.ts","sourceRoot":"","sources":["../../lib/rotation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAUH,MAAM,WAAW,iBAAiB;IACjC,yCAAyC;IACzC,YAAY,EAAE,MAAM,CAAC;IACrB,+CAA+C;IAC/C,cAAc,EAAE,MAAM,CAAC;IACvB,mDAAmD;IACnD,YAAY,EAAE,MAAM,CAAC;IACrB,2BAA2B;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,2BAA2B;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,8CAA8C;IAC9C,sBAAsB,EAAE,MAAM,CAAC;CAC/B;AAED,eAAO,MAAM,2BAA2B,EAAE,iBAOzC,CAAC;AAQF,KAAK,UAAU,GAAG,MAAM,GAAG,MAAM,CAAC;AAWlC;;;GAGG;AACH,qBAAa,kBAAkB;IAC9B,OAAO,CAAC,OAAO,CAAuC;IACtD,OAAO,CAAC,MAAM,CAAoB;gBAEtB,MAAM,GAAE,OAAO,CAAC,iBAAiB,CAAM;IAInD,OAAO,CAAC,MAAM;IAId,OAAO,CAAC,oBAAoB;IAO5B,QAAQ,CAAC,UAAU,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM;IAO3D,sBAAsB,CAAC,UAAU,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM;IAMzE,aAAa,CAAC,UAAU,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;IAiB9D,eAAe,CAAC,UAAU,EAAE,UAAU,EAAE,QAAQ,C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EhE;AAED,MAAM,WAAW,yBAAyB;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,MAAM,CAAC;AAC/E,wBAAgB,kBAAkB,CACjC,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,MAAM,EACd,YAAY,CAAC,EAAE,MAAM,GACnB,MAAM,CAAC;AA2DV,wBAAgB,gBAAgB,CAC/B,MAAM,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,GACjC,kBAAkB,CAKpB;AAED,wBAAgB,eAAe,CAC9B,MAAM,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,GACjC,kBAAkB,CAKpB;AAED,wBAAgB,aAAa,IAAI,IAAI,CAGpC"}
|
package/dist/lib/rotation.js
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
* when rate limits are encountered.
|
|
7
7
|
*/
|
|
8
8
|
import { createLogger } from "./logger.js";
|
|
9
|
-
export { createAsyncMutex, getRoutingMutex, withRoutingMutex, } from "./routing-mutex.js";
|
|
10
9
|
const log = createLogger("rotation");
|
|
11
10
|
export const DEFAULT_HEALTH_SCORE_CONFIG = {
|
|
12
11
|
successDelta: 1,
|
|
@@ -261,7 +260,7 @@ export class TokenBucketTracker {
|
|
|
261
260
|
}
|
|
262
261
|
}
|
|
263
262
|
}
|
|
264
|
-
|
|
263
|
+
const DEFAULT_HYBRID_SELECTION_CONFIG = {
|
|
265
264
|
healthWeight: 2,
|
|
266
265
|
tokenWeight: 5,
|
|
267
266
|
freshnessWeight: 2.0,
|
|
@@ -519,4 +518,3 @@ export function resetTrackers() {
|
|
|
519
518
|
healthTrackerInstance?.clear();
|
|
520
519
|
tokenTrackerInstance?.clear();
|
|
521
520
|
}
|
|
522
|
-
//# sourceMappingURL=rotation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing-profiles.d.ts","sourceRoot":"","sources":["../../lib/routing-profiles.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"routing-profiles.d.ts","sourceRoot":"","sources":["../../lib/routing-profiles.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,cAAc;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,mBAAmB;IACnC,OAAO,EAAE,CAAC,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;CACzC;AAED,MAAM,WAAW,4BAA4B;IAC5C,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;CAC/B;AAoGD,wBAAgB,sBAAsB,IAAI,MAAM,CAE/C;AAED,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,mBAAmB,CAAC,CAa5E;AAED,wBAAsB,uBAAuB,CAC5C,KAAK,EAAE,mBAAmB,GACxB,OAAO,CAAC,IAAI,CAAC,CAsCf;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE;IAClD,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;CACb,GAAG,cAAc,CAajB;AAED,wBAAgB,oBAAoB,CACnC,KAAK,EAAE,mBAAmB,EAC1B,OAAO,EAAE,cAAc,EACvB,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,IAAI,EAC1C,GAAG,SAAa,GACd,cAAc,CAUhB;AAED,wBAAsB,4BAA4B,CACjD,QAAQ,SAAgB,EACxB,WAAW,GAAE,MAAM,OAAO,CAAC,mBAAmB,CAA2B,GACvE,OAAO,CAAC,4BAA4B,CAAC,CAqBvC;AAED,wBAAgB,qCAAqC,IAAI,IAAI,CAE5D"}
|
|
@@ -4,6 +4,7 @@ import { logWarn } from "./logger.js";
|
|
|
4
4
|
import { getCodexMultiAuthDir } from "./runtime-paths.js";
|
|
5
5
|
import { findProjectRoot, getProjectStorageKey, resolveProjectStorageIdentityRoot, } from "./storage/paths.js";
|
|
6
6
|
import { isRecord, sleep } from "./utils.js";
|
|
7
|
+
import { tempPathFor } from "./temp-path.js";
|
|
7
8
|
const ROUTING_PROFILES_FILE_NAME = "routing-profiles.json";
|
|
8
9
|
const RETRYABLE_FS_CODES = new Set(["EBUSY", "EPERM"]);
|
|
9
10
|
let writeQueue = Promise.resolve();
|
|
@@ -116,7 +117,7 @@ export async function saveRoutingProfileStore(store) {
|
|
|
116
117
|
const payload = normalizeStore(store);
|
|
117
118
|
const task = async () => {
|
|
118
119
|
await fs.mkdir(getCodexMultiAuthDir(), { recursive: true, mode: 0o700 });
|
|
119
|
-
const tempPath =
|
|
120
|
+
const tempPath = tempPathFor(path);
|
|
120
121
|
let moved = false;
|
|
121
122
|
try {
|
|
122
123
|
await fs.writeFile(tempPath, `${JSON.stringify(payload, null, 2)}\n`, {
|
|
@@ -200,4 +201,3 @@ export async function resolveProjectRoutingProfile(startDir = process.cwd(), sto
|
|
|
200
201
|
export function resetRoutingProfileWriteQueueForTests() {
|
|
201
202
|
writeQueue = Promise.resolve();
|
|
202
203
|
}
|
|
203
|
-
//# sourceMappingURL=routing-profiles.js.map
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
export declare function tomlStringLiteral(value: string): string;
|
|
2
|
-
export declare function readTomlTableName(line: string): string | null;
|
|
3
|
-
export declare function removeRuntimeRotationProviderBlock(rawConfig: string): string;
|
|
4
|
-
export declare function rewriteTopLevelModelProvider(rawConfig: string): string;
|
|
5
|
-
export declare function enableTopLevelResponseStorage(rawConfig: string): string;
|
|
6
2
|
export declare function restoreTopLevelModelProvider(currentConfig: string, originalConfig: string): string;
|
|
7
3
|
export declare function restoreTopLevelResponseStorage(currentConfig: string, originalConfig: string): string;
|
|
8
|
-
export declare function ensureTomlTrailingNewline(value: string): string;
|
|
9
|
-
export declare function createRuntimeRotationProviderBlock(baseUrl: string, clientApiKey?: string): string[];
|
|
10
4
|
export declare function rewriteConfigTomlForRuntimeRotationProvider(rawConfig: string, baseUrl: string, clientApiKey?: string): string;
|
|
11
5
|
export declare function restoreConfigTomlFromRuntimeRotationProvider(currentConfig: string, originalConfig: string): string;
|
|
12
6
|
//# sourceMappingURL=config-toml.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-toml.d.ts","sourceRoot":"","sources":["../../../lib/runtime/config-toml.ts"],"names":[],"mappings":"AAEA,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAqBvD;
|
|
1
|
+
{"version":3,"file":"config-toml.d.ts","sourceRoot":"","sources":["../../../lib/runtime/config-toml.ts"],"names":[],"mappings":"AAEA,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAqBvD;AA4FD,wBAAgB,4BAA4B,CAC3C,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,MAAM,GACpB,MAAM,CAiCR;AAED,wBAAgB,8BAA8B,CAC7C,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,MAAM,GACpB,MAAM,CAkDR;AA2BD,wBAAgB,2CAA2C,CAC1D,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,YAAY,SAAK,GACf,MAAM,CAkBR;AAED,wBAAgB,4CAA4C,CAC3D,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,MAAM,GACpB,MAAM,CAYR"}
|
|
@@ -21,11 +21,11 @@ export function tomlStringLiteral(value) {
|
|
|
21
21
|
}
|
|
22
22
|
})}"`;
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
function readTomlTableName(line) {
|
|
25
25
|
const match = /^\s*\[{1,2}\s*([^\]]+?)\s*\]{1,2}\s*$/.exec(line);
|
|
26
26
|
return match?.[1]?.trim() ?? null;
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
function removeRuntimeRotationProviderBlock(rawConfig) {
|
|
29
29
|
const lines = rawConfig.split(/\r?\n/);
|
|
30
30
|
const output = [];
|
|
31
31
|
let skipping = false;
|
|
@@ -47,7 +47,7 @@ export function removeRuntimeRotationProviderBlock(rawConfig) {
|
|
|
47
47
|
}
|
|
48
48
|
return output.join(rawConfig.includes("\r\n") ? "\r\n" : "\n");
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
function rewriteTopLevelModelProvider(rawConfig) {
|
|
51
51
|
const lineEnding = rawConfig.includes("\r\n") ? "\r\n" : "\n";
|
|
52
52
|
const lines = rawConfig.length > 0 ? rawConfig.split(/\r?\n/) : [];
|
|
53
53
|
const rewrittenLine = `model_provider = ${tomlStringLiteral(RUNTIME_ROTATION_PROXY_PROVIDER_ID)}`;
|
|
@@ -70,7 +70,7 @@ export function rewriteTopLevelModelProvider(rawConfig) {
|
|
|
70
70
|
output.push(rewrittenLine);
|
|
71
71
|
return output.join(lineEnding);
|
|
72
72
|
}
|
|
73
|
-
|
|
73
|
+
function enableTopLevelResponseStorage(rawConfig) {
|
|
74
74
|
const lineEnding = rawConfig.includes("\r\n") ? "\r\n" : "\n";
|
|
75
75
|
const lines = rawConfig.length > 0 ? rawConfig.split(/\r?\n/) : [];
|
|
76
76
|
const output = [];
|
|
@@ -175,10 +175,10 @@ export function restoreTopLevelResponseStorage(currentConfig, originalConfig) {
|
|
|
175
175
|
}
|
|
176
176
|
return output.join(lineEnding);
|
|
177
177
|
}
|
|
178
|
-
|
|
178
|
+
function ensureTomlTrailingNewline(value) {
|
|
179
179
|
return value.replace(/[\r\n]*$/, "\n");
|
|
180
180
|
}
|
|
181
|
-
|
|
181
|
+
function createRuntimeRotationProviderBlock(baseUrl, clientApiKey = "") {
|
|
182
182
|
const lines = [
|
|
183
183
|
`[model_providers.${RUNTIME_ROTATION_PROXY_PROVIDER_ID}]`,
|
|
184
184
|
'name = "codex-multi-auth"',
|
|
@@ -204,4 +204,3 @@ export function restoreConfigTomlFromRuntimeRotationProvider(currentConfig, orig
|
|
|
204
204
|
const withResponseStorage = restoreTopLevelResponseStorage(withoutProvider, originalConfig);
|
|
205
205
|
return ensureTomlTrailingNewline(restoreTopLevelModelProvider(withResponseStorage, originalConfig).replace(/[\r\n]*$/, ""));
|
|
206
206
|
}
|
|
207
|
-
//# sourceMappingURL=config-toml.js.map
|
|
@@ -1,36 +1,5 @@
|
|
|
1
1
|
import type { ModelFamily } from "../prompts/codex.js";
|
|
2
2
|
import type { AccountStorageV3 } from "../storage.js";
|
|
3
|
-
export declare function createRuntimeEventHandler<TLoadedStorage, TSavedStorage, TModelFamily extends string, TManager>(deps: {
|
|
4
|
-
handleAccountSelectEvent: (input: {
|
|
5
|
-
event: {
|
|
6
|
-
type: string;
|
|
7
|
-
properties?: unknown;
|
|
8
|
-
};
|
|
9
|
-
providerId: string;
|
|
10
|
-
loadAccounts: () => Promise<TLoadedStorage>;
|
|
11
|
-
saveAccounts: (storage: TSavedStorage) => Promise<void>;
|
|
12
|
-
modelFamilies: readonly TModelFamily[];
|
|
13
|
-
cachedAccountManager: TManager;
|
|
14
|
-
reloadAccountManagerFromDisk: () => Promise<void>;
|
|
15
|
-
setLastCodexCliActiveSyncIndex: (index: number) => void;
|
|
16
|
-
showToast: (message: string, variant?: "info" | "success" | "warning" | "error") => Promise<void>;
|
|
17
|
-
}) => Promise<boolean>;
|
|
18
|
-
providerId: string;
|
|
19
|
-
loadAccounts: () => Promise<TLoadedStorage>;
|
|
20
|
-
saveAccounts: (storage: TSavedStorage) => Promise<void>;
|
|
21
|
-
modelFamilies: readonly TModelFamily[];
|
|
22
|
-
getCachedAccountManager: () => TManager;
|
|
23
|
-
reloadAccountManagerFromDisk: () => Promise<void>;
|
|
24
|
-
setLastCodexCliActiveSyncIndex: (index: number) => void;
|
|
25
|
-
showToast: (message: string, variant?: "info" | "success" | "warning" | "error") => Promise<void>;
|
|
26
|
-
logDebug: (message: string) => void;
|
|
27
|
-
pluginName: string;
|
|
28
|
-
}): (input: {
|
|
29
|
-
event: {
|
|
30
|
-
type: string;
|
|
31
|
-
properties?: unknown;
|
|
32
|
-
};
|
|
33
|
-
}) => Promise<void>;
|
|
34
3
|
export declare function handleRuntimeEvent(params: {
|
|
35
4
|
input: {
|
|
36
5
|
event: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-handler.d.ts","sourceRoot":"","sources":["../../../lib/runtime/event-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGtD,
|
|
1
|
+
{"version":3,"file":"event-handler.d.ts","sourceRoot":"","sources":["../../../lib/runtime/event-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGtD,wBAAsB,kBAAkB,CAAC,MAAM,EAAE;IAChD,KAAK,EAAE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