codex-multi-auth 2.16.0 → 2.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.codex-plugin/plugin.json +9 -9
- package/LICENSE +21 -21
- package/README.md +487 -463
- 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.map +1 -1
- package/dist/index.js +8 -3
- package/dist/lib/account-policy.d.ts +4 -0
- package/dist/lib/account-policy.d.ts.map +1 -1
- package/dist/lib/account-policy.js +8 -0
- package/dist/lib/accounts/rate-limits.d.ts.map +1 -1
- package/dist/lib/accounts/rate-limits.js +2 -0
- package/dist/lib/accounts.d.ts +15 -3
- package/dist/lib/accounts.d.ts.map +1 -1
- package/dist/lib/accounts.js +231 -30
- package/dist/lib/api-route-store.d.ts +24 -0
- package/dist/lib/api-route-store.d.ts.map +1 -0
- package/dist/lib/api-route-store.js +145 -0
- package/dist/lib/auth/account-access.d.ts +115 -0
- package/dist/lib/auth/account-access.d.ts.map +1 -0
- package/dist/lib/auth/account-access.js +214 -0
- package/dist/lib/auth/token-utils.d.ts +54 -1
- package/dist/lib/auth/token-utils.d.ts.map +1 -1
- package/dist/lib/auth/token-utils.js +92 -7
- package/dist/lib/cli.d.ts +1 -1
- package/dist/lib/cli.d.ts.map +1 -1
- package/dist/lib/cli.js +4 -0
- package/dist/lib/codex-cli/state.d.ts +7 -0
- package/dist/lib/codex-cli/state.d.ts.map +1 -1
- package/dist/lib/codex-cli/state.js +18 -0
- package/dist/lib/codex-cli/writer.d.ts.map +1 -1
- package/dist/lib/codex-cli/writer.js +60 -8
- package/dist/lib/codex-manager/account-manager-commands.d.ts.map +1 -1
- package/dist/lib/codex-manager/account-manager-commands.js +1 -0
- package/dist/lib/codex-manager/account-pool-write.d.ts +3 -1
- package/dist/lib/codex-manager/account-pool-write.d.ts.map +1 -1
- package/dist/lib/codex-manager/account-pool-write.js +4 -0
- package/dist/lib/codex-manager/api-login-menu.d.ts +14 -0
- package/dist/lib/codex-manager/api-login-menu.d.ts.map +1 -0
- package/dist/lib/codex-manager/api-login-menu.js +224 -0
- package/dist/lib/codex-manager/commands/account.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/account.js +27 -0
- package/dist/lib/codex-manager/commands/best.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/best.js +6 -2
- package/dist/lib/codex-manager/commands/check.d.ts +7 -1
- package/dist/lib/codex-manager/commands/check.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/check.js +24 -3
- package/dist/lib/codex-manager/commands/forecast.d.ts +1 -1
- package/dist/lib/codex-manager/commands/forecast.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/forecast.js +7 -3
- package/dist/lib/codex-manager/commands/report.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/report.js +5 -1
- package/dist/lib/codex-manager/commands/resets.d.ts +2 -0
- package/dist/lib/codex-manager/commands/resets.d.ts.map +1 -0
- package/dist/lib/codex-manager/commands/resets.js +67 -0
- package/dist/lib/codex-manager/commands/rotation.d.ts +2 -2
- package/dist/lib/codex-manager/commands/rotation.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/rotation.js +63 -12
- package/dist/lib/codex-manager/commands/status.d.ts +12 -1
- package/dist/lib/codex-manager/commands/status.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/status.js +166 -22
- package/dist/lib/codex-manager/commands/uninstall.js +1 -1
- package/dist/lib/codex-manager/formatters/quota-formatters.d.ts.map +1 -1
- package/dist/lib/codex-manager/formatters/quota-formatters.js +3 -2
- package/dist/lib/codex-manager/health-check.d.ts +3 -0
- package/dist/lib/codex-manager/health-check.d.ts.map +1 -1
- package/dist/lib/codex-manager/health-check.js +57 -7
- package/dist/lib/codex-manager/help.d.ts.map +1 -1
- package/dist/lib/codex-manager/help.js +4 -2
- package/dist/lib/codex-manager/login-flow.d.ts.map +1 -1
- package/dist/lib/codex-manager/login-flow.js +69 -7
- package/dist/lib/codex-manager/login-menu-data.d.ts.map +1 -1
- package/dist/lib/codex-manager/login-menu-data.js +21 -8
- package/dist/lib/codex-manager/login-oauth.d.ts +3 -0
- package/dist/lib/codex-manager/login-oauth.d.ts.map +1 -1
- package/dist/lib/codex-manager/login-oauth.js +6 -1
- package/dist/lib/codex-manager/login-workspace-choice.d.ts +11 -0
- package/dist/lib/codex-manager/login-workspace-choice.d.ts.map +1 -0
- package/dist/lib/codex-manager/login-workspace-choice.js +37 -0
- package/dist/lib/codex-manager/persist-selected-account.d.ts.map +1 -1
- package/dist/lib/codex-manager/persist-selected-account.js +2 -1
- package/dist/lib/codex-manager/quota-cache-helpers.d.ts +7 -1
- 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/repair-commands.d.ts +13 -0
- package/dist/lib/codex-manager/repair-commands.d.ts.map +1 -1
- package/dist/lib/codex-manager/repair-commands.js +144 -9
- package/dist/lib/codex-manager.d.ts.map +1 -1
- package/dist/lib/codex-manager.js +25 -6
- package/dist/lib/concurrency.d.ts +3 -0
- package/dist/lib/concurrency.d.ts.map +1 -0
- package/dist/lib/concurrency.js +31 -0
- package/dist/lib/context-budget-response.js +8 -8
- package/dist/lib/context-overflow.js +10 -10
- package/dist/lib/model-route-policy.d.ts +52 -0
- package/dist/lib/model-route-policy.d.ts.map +1 -0
- package/dist/lib/model-route-policy.js +159 -0
- package/dist/lib/oauth-success.html +125 -125
- package/dist/lib/policy/runtime-policy.d.ts +1 -0
- package/dist/lib/policy/runtime-policy.d.ts.map +1 -1
- package/dist/lib/policy/runtime-policy.js +3 -0
- package/dist/lib/preemptive-quota-scheduler.d.ts +2 -0
- package/dist/lib/preemptive-quota-scheduler.d.ts.map +1 -1
- package/dist/lib/preemptive-quota-scheduler.js +4 -0
- package/dist/lib/prompts/codex-host-bridge.js +138 -138
- package/dist/lib/prompts/codex.js +79 -79
- package/dist/lib/quota-cache.d.ts +7 -3
- package/dist/lib/quota-cache.d.ts.map +1 -1
- package/dist/lib/quota-cache.js +91 -59
- package/dist/lib/quota-probe.d.ts +5 -0
- package/dist/lib/quota-probe.d.ts.map +1 -1
- package/dist/lib/quota-probe.js +26 -2
- package/dist/lib/quota-readiness.d.ts +7 -2
- package/dist/lib/quota-readiness.d.ts.map +1 -1
- package/dist/lib/quota-readiness.js +25 -4
- package/dist/lib/request/client-cancellation.d.ts +5 -0
- package/dist/lib/request/client-cancellation.d.ts.map +1 -0
- package/dist/lib/request/client-cancellation.js +7 -0
- package/dist/lib/request/response-outcome.d.ts +25 -0
- package/dist/lib/request/response-outcome.d.ts.map +1 -0
- package/dist/lib/request/response-outcome.js +49 -0
- package/dist/lib/request/stream-failover-runtime.d.ts +2 -1
- package/dist/lib/request/stream-failover-runtime.d.ts.map +1 -1
- package/dist/lib/request/stream-failover-runtime.js +29 -10
- package/dist/lib/runtime/account-check.d.ts.map +1 -1
- package/dist/lib/runtime/account-check.js +2 -8
- package/dist/lib/runtime/account-model-catalog.d.ts +64 -0
- package/dist/lib/runtime/account-model-catalog.d.ts.map +1 -0
- package/dist/lib/runtime/account-model-catalog.js +154 -0
- package/dist/lib/runtime/account-pool.d.ts +3 -1
- package/dist/lib/runtime/account-pool.d.ts.map +1 -1
- package/dist/lib/runtime/account-pool.js +4 -0
- package/dist/lib/runtime/account-reset-credits.d.ts +42 -0
- package/dist/lib/runtime/account-reset-credits.d.ts.map +1 -0
- package/dist/lib/runtime/account-reset-credits.js +82 -0
- package/dist/lib/runtime/api-model-capabilities.d.ts +30 -0
- package/dist/lib/runtime/api-model-capabilities.d.ts.map +1 -0
- package/dist/lib/runtime/api-model-capabilities.js +434 -0
- package/dist/lib/runtime/api-model-runtime.d.ts +42 -0
- package/dist/lib/runtime/api-model-runtime.d.ts.map +1 -0
- package/dist/lib/runtime/api-model-runtime.js +358 -0
- package/dist/lib/runtime/app-bind.d.ts +19 -1
- package/dist/lib/runtime/app-bind.d.ts.map +1 -1
- package/dist/lib/runtime/app-bind.js +89 -11
- package/dist/lib/runtime/automatic-account-checks.d.ts +35 -0
- package/dist/lib/runtime/automatic-account-checks.d.ts.map +1 -0
- package/dist/lib/runtime/automatic-account-checks.js +140 -0
- package/dist/lib/runtime/automatic-subscription-checks.d.ts +7 -0
- package/dist/lib/runtime/automatic-subscription-checks.d.ts.map +1 -0
- package/dist/lib/runtime/automatic-subscription-checks.js +54 -0
- package/dist/lib/runtime/catalog-capabilities.d.ts +8 -0
- package/dist/lib/runtime/catalog-capabilities.d.ts.map +1 -0
- package/dist/lib/runtime/catalog-capabilities.js +61 -0
- package/dist/lib/runtime/inference-activity.d.ts +15 -0
- package/dist/lib/runtime/inference-activity.d.ts.map +1 -0
- package/dist/lib/runtime/inference-activity.js +95 -0
- package/dist/lib/runtime/model-discovery-status.d.ts +100 -0
- package/dist/lib/runtime/model-discovery-status.d.ts.map +1 -0
- package/dist/lib/runtime/model-discovery-status.js +387 -0
- package/dist/lib/runtime/native-account-storage.d.ts +11 -0
- package/dist/lib/runtime/native-account-storage.d.ts.map +1 -0
- package/dist/lib/runtime/native-account-storage.js +50 -0
- package/dist/lib/runtime/native-account-sync.d.ts +19 -0
- package/dist/lib/runtime/native-account-sync.d.ts.map +1 -0
- package/dist/lib/runtime/native-account-sync.js +62 -0
- package/dist/lib/runtime/native-binding-lock.d.ts +3 -0
- package/dist/lib/runtime/native-binding-lock.d.ts.map +1 -0
- package/dist/lib/runtime/native-binding-lock.js +5 -0
- package/dist/lib/runtime/native-client-auth.d.ts +3 -0
- package/dist/lib/runtime/native-client-auth.d.ts.map +1 -0
- package/dist/lib/runtime/native-client-auth.js +42 -0
- package/dist/lib/runtime/native-provider-config.d.ts +4 -0
- package/dist/lib/runtime/native-provider-config.d.ts.map +1 -0
- package/dist/lib/runtime/native-provider-config.js +52 -0
- package/dist/lib/runtime/native-rate-limits.d.ts +18 -0
- package/dist/lib/runtime/native-rate-limits.d.ts.map +1 -0
- package/dist/lib/runtime/native-rate-limits.js +135 -0
- package/dist/lib/runtime/reset-credit-routing.d.ts +41 -0
- package/dist/lib/runtime/reset-credit-routing.d.ts.map +1 -0
- package/dist/lib/runtime/reset-credit-routing.js +66 -0
- package/dist/lib/runtime/reset-credits.d.ts +101 -0
- package/dist/lib/runtime/reset-credits.d.ts.map +1 -0
- package/dist/lib/runtime/reset-credits.js +162 -0
- package/dist/lib/runtime/response-output-history.d.ts +17 -0
- package/dist/lib/runtime/response-output-history.d.ts.map +1 -0
- package/dist/lib/runtime/response-output-history.js +85 -0
- package/dist/lib/runtime/responses-websocket.d.ts +31 -0
- package/dist/lib/runtime/responses-websocket.d.ts.map +1 -0
- package/dist/lib/runtime/responses-websocket.js +636 -0
- package/dist/lib/runtime/resume-picker.d.ts +41 -0
- package/dist/lib/runtime/resume-picker.d.ts.map +1 -0
- package/dist/lib/runtime/resume-picker.js +169 -0
- package/dist/lib/runtime/rotation-account-selection.d.ts +6 -0
- package/dist/lib/runtime/rotation-account-selection.d.ts.map +1 -1
- package/dist/lib/runtime/rotation-account-selection.js +63 -0
- package/dist/lib/runtime/rotation-proxy-state.d.ts +33 -0
- package/dist/lib/runtime/rotation-proxy-state.d.ts.map +1 -1
- package/dist/lib/runtime/rotation-server-types.d.ts +18 -0
- package/dist/lib/runtime/rotation-server-types.d.ts.map +1 -1
- package/dist/lib/runtime/runtime-capability-failures.d.ts +14 -0
- package/dist/lib/runtime/runtime-capability-failures.d.ts.map +1 -0
- package/dist/lib/runtime/runtime-capability-failures.js +76 -0
- package/dist/lib/runtime/runtime-observability.d.ts +7 -0
- package/dist/lib/runtime/runtime-observability.d.ts.map +1 -1
- package/dist/lib/runtime/runtime-observability.js +42 -2
- package/dist/lib/runtime/subscription-first-use.d.ts +10 -0
- package/dist/lib/runtime/subscription-first-use.d.ts.map +1 -0
- package/dist/lib/runtime/subscription-first-use.js +64 -0
- package/dist/lib/runtime/subscription-quota-event.d.ts +6 -0
- package/dist/lib/runtime/subscription-quota-event.d.ts.map +1 -0
- package/dist/lib/runtime/subscription-quota-event.js +31 -0
- package/dist/lib/runtime/subscription-quota-order.d.ts +17 -0
- package/dist/lib/runtime/subscription-quota-order.d.ts.map +1 -0
- package/dist/lib/runtime/subscription-quota-order.js +31 -0
- package/dist/lib/runtime/workspace-model-scopes.d.ts +15 -0
- package/dist/lib/runtime/workspace-model-scopes.d.ts.map +1 -0
- package/dist/lib/runtime/workspace-model-scopes.js +34 -0
- package/dist/lib/runtime-constants.d.ts +3 -0
- package/dist/lib/runtime-constants.d.ts.map +1 -1
- package/dist/lib/runtime-constants.js +5 -0
- package/dist/lib/runtime-paths.d.ts.map +1 -1
- package/dist/lib/runtime-paths.js +4 -1
- package/dist/lib/runtime-rotation-proxy.d.ts.map +1 -1
- package/dist/lib/runtime-rotation-proxy.js +852 -42
- package/dist/lib/schemas.d.ts +20 -0
- package/dist/lib/schemas.d.ts.map +1 -1
- package/dist/lib/schemas.js +3 -0
- package/dist/lib/storage/credential-sidecars.d.ts +13 -0
- package/dist/lib/storage/credential-sidecars.d.ts.map +1 -0
- package/dist/lib/storage/credential-sidecars.js +52 -0
- package/dist/lib/storage/file-lock.d.ts +9 -0
- package/dist/lib/storage/file-lock.d.ts.map +1 -0
- package/dist/lib/storage/file-lock.js +186 -0
- package/dist/lib/storage/flagged-storage.d.ts.map +1 -1
- package/dist/lib/storage/flagged-storage.js +12 -0
- package/dist/lib/storage/path-state.d.ts +2 -0
- package/dist/lib/storage/path-state.d.ts.map +1 -1
- package/dist/lib/storage/path-state.js +9 -0
- package/dist/lib/storage/paths.js +4 -4
- package/dist/lib/storage/pending-auth.d.ts +18 -0
- package/dist/lib/storage/pending-auth.d.ts.map +1 -0
- package/dist/lib/storage/pending-auth.js +155 -0
- package/dist/lib/storage/public-types.d.ts +13 -0
- package/dist/lib/storage/public-types.d.ts.map +1 -1
- package/dist/lib/storage/record-identity.d.ts +16 -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/snapshot-merge.d.ts +16 -0
- package/dist/lib/storage/snapshot-merge.d.ts.map +1 -0
- package/dist/lib/storage/snapshot-merge.js +206 -0
- package/dist/lib/storage/transactions.d.ts.map +1 -1
- package/dist/lib/storage/transactions.js +5 -4
- package/dist/lib/storage.d.ts +6 -0
- package/dist/lib/storage.d.ts.map +1 -1
- package/dist/lib/storage.js +77 -7
- package/dist/lib/ui/auth-menu-builder.d.ts +2 -0
- package/dist/lib/ui/auth-menu-builder.d.ts.map +1 -1
- package/dist/lib/ui/auth-menu-builder.js +1 -0
- package/dist/lib/ui/auth-menu.d.ts.map +1 -1
- package/dist/lib/ui/auth-menu.js +1 -0
- package/dist/lib/ui/check-progress.d.ts +8 -0
- package/dist/lib/ui/check-progress.d.ts.map +1 -0
- package/dist/lib/ui/check-progress.js +30 -0
- package/dist/lib/ui/format.d.ts +3 -1
- package/dist/lib/ui/format.d.ts.map +1 -1
- package/dist/lib/ui/format.js +8 -0
- package/dist/lib/ui/ui-copy.d.ts +2 -2
- package/dist/lib/ui/ui-copy.js +2 -2
- package/dist/lib/usage/pricing.js +2 -2
- package/dist/lib/usage/usage-extraction.d.ts +3 -1
- package/dist/lib/usage/usage-extraction.d.ts.map +1 -1
- package/dist/lib/usage/usage-extraction.js +46 -9
- 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 +200 -197
- package/scripts/codex-app-launcher.js +653 -653
- package/scripts/codex-app-router.js +373 -366
- package/scripts/codex-bin-resolver.js +313 -281
- package/scripts/codex-multi-auth.js +59 -59
- package/scripts/codex-routing.js +62 -61
- package/scripts/codex.js +6642 -6564
- 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/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
|
@@ -6,7 +6,10 @@ import { type DashboardDisplaySettings } from "../dashboard-settings.js";
|
|
|
6
6
|
*/
|
|
7
7
|
export interface HealthCheckOptions {
|
|
8
8
|
forceRefresh?: boolean;
|
|
9
|
+
discoverModels?: boolean;
|
|
9
10
|
liveProbe?: boolean;
|
|
11
|
+
/** Explicit `check --prime` only: may start an unused subscription's quota windows. */
|
|
12
|
+
primeUnusedSubscription?: boolean;
|
|
10
13
|
model?: string;
|
|
11
14
|
display?: DashboardDisplaySettings;
|
|
12
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"health-check.d.ts","sourceRoot":"","sources":["../../../lib/codex-manager/health-check.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"health-check.d.ts","sourceRoot":"","sources":["../../../lib/codex-manager/health-check.ts"],"names":[],"mappings":"AAaA,OAAO,EACN,KAAK,wBAAwB,EAE7B,MAAM,0BAA0B,CAAC;AA2ClC;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IAClC,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,uFAAuF;IACvF,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,wBAAwB,CAAC;CACnC;AAED,wBAAsB,cAAc,CACnC,OAAO,GAAE,kBAAuB,GAC9B,OAAO,CAAC,IAAI,CAAC,CA6Wf"}
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
+
import { refreshAndPrintResetCredits } from "../runtime/account-reset-credits.js";
|
|
2
|
+
import { mapWithConcurrency } from "../concurrency.js";
|
|
3
|
+
import { withCheckProgress } from "../ui/check-progress.js";
|
|
4
|
+
import { refreshAndPrintModelInventory } from "../runtime/model-discovery-status.js";
|
|
1
5
|
import { AUTH_INVALIDATION_MARKER, extractAccountEmail, extractAccountId, formatAccountLabel, sanitizeEmail, } from "../accounts.js";
|
|
6
|
+
import { codexCliAccountIdFor } from "../auth/token-utils.js";
|
|
2
7
|
import { setCodexCliActiveSelection } from "../codex-cli/writer.js";
|
|
3
8
|
import { DEFAULT_DASHBOARD_DISPLAY_SETTINGS, } from "../dashboard-settings.js";
|
|
4
9
|
import { isCodexUnavailableError } from "../errors.js";
|
|
@@ -21,6 +26,7 @@ function appendAuthInvalidationMarker(account, detail) {
|
|
|
21
26
|
export async function runHealthCheck(options = {}) {
|
|
22
27
|
const forceRefresh = options.forceRefresh === true;
|
|
23
28
|
const liveProbe = options.liveProbe === true;
|
|
29
|
+
const primeUnusedSubscription = options.primeUnusedSubscription === true;
|
|
24
30
|
const probeModel = options.model?.trim() || DEFAULT_LIVE_PROBE_MODEL;
|
|
25
31
|
const modelInspection = inspectRequestedModel(probeModel);
|
|
26
32
|
const display = options.display ?? DEFAULT_DASHBOARD_DISPLAY_SETTINGS;
|
|
@@ -31,6 +37,8 @@ export async function runHealthCheck(options = {}) {
|
|
|
31
37
|
const storage = await loadAccounts();
|
|
32
38
|
if (!storage || storage.accounts.length === 0) {
|
|
33
39
|
console.log("No accounts configured.");
|
|
40
|
+
if (options.discoverModels)
|
|
41
|
+
await refreshAndPrintModelInventory(console.log);
|
|
34
42
|
return;
|
|
35
43
|
}
|
|
36
44
|
let quotaEmailFallbackState = liveProbe && quotaCache
|
|
@@ -51,6 +59,31 @@ export async function runHealthCheck(options = {}) {
|
|
|
51
59
|
if (liveProbe) {
|
|
52
60
|
console.log(stylePromptText(`Model probe: ${formatModelInspection(modelInspection)}`, "muted"));
|
|
53
61
|
}
|
|
62
|
+
const quickProbes = new Map();
|
|
63
|
+
if (liveProbe && !forceRefresh) {
|
|
64
|
+
const candidates = storage.accounts.flatMap((account, index) => {
|
|
65
|
+
const accountId = account.accountId ?? extractAccountId(account.accessToken);
|
|
66
|
+
return hasUsableAccessToken(account, now) && account.accessToken && accountId
|
|
67
|
+
? [{ index, accountId, accessToken: account.accessToken }] : [];
|
|
68
|
+
});
|
|
69
|
+
if (candidates.length) {
|
|
70
|
+
let completed = 0;
|
|
71
|
+
await withCheckProgress(() => `Checking account probes: ${completed}/${candidates.length}`, async () => {
|
|
72
|
+
await mapWithConcurrency(candidates, 3, async (candidate) => {
|
|
73
|
+
try {
|
|
74
|
+
const value = await fetchCodexQuotaSnapshot({ primeUnusedSubscription, accountId: candidate.accountId, accessToken: candidate.accessToken, model: modelInspection.normalized });
|
|
75
|
+
quickProbes.set(candidate.index, { ok: true, value });
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
quickProbes.set(candidate.index, { ok: false, error });
|
|
79
|
+
}
|
|
80
|
+
finally {
|
|
81
|
+
completed++;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
}, console.log);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
54
87
|
for (let i = 0; i < storage.accounts.length; i += 1) {
|
|
55
88
|
const account = storage.accounts[i];
|
|
56
89
|
if (!account)
|
|
@@ -82,16 +115,23 @@ export async function runHealthCheck(options = {}) {
|
|
|
82
115
|
}
|
|
83
116
|
else {
|
|
84
117
|
try {
|
|
85
|
-
const
|
|
118
|
+
const priorProbe = quickProbes.get(i);
|
|
119
|
+
if (priorProbe && !priorProbe.ok)
|
|
120
|
+
throw priorProbe.error;
|
|
121
|
+
const snapshot = priorProbe?.ok ? priorProbe.value : await withCheckProgress(`Account ${i + 1}/${storage.accounts.length}: live probe`, () => fetchCodexQuotaSnapshot({ primeUnusedSubscription,
|
|
86
122
|
accountId: probeAccountId,
|
|
87
123
|
accessToken: currentAccessToken,
|
|
88
124
|
model: modelInspection.normalized,
|
|
89
|
-
});
|
|
125
|
+
}), console.log);
|
|
90
126
|
if (workingQuotaCache) {
|
|
91
127
|
quotaCacheChanged =
|
|
92
128
|
updateQuotaCacheForAccount(workingQuotaCache, account, snapshot, storage.accounts, quotaEmailFallbackState ?? undefined) || quotaCacheChanged;
|
|
93
129
|
}
|
|
94
130
|
healthDetail = formatQuotaSnapshotForDashboard(snapshot, display);
|
|
131
|
+
if (snapshot.primingFailure) {
|
|
132
|
+
healthTone = "warning";
|
|
133
|
+
warnings += 1;
|
|
134
|
+
}
|
|
95
135
|
codexAvailable += 1;
|
|
96
136
|
}
|
|
97
137
|
catch (error) {
|
|
@@ -120,7 +160,7 @@ export async function runHealthCheck(options = {}) {
|
|
|
120
160
|
}
|
|
121
161
|
continue;
|
|
122
162
|
}
|
|
123
|
-
const result = await queuedRefresh(account.refreshToken);
|
|
163
|
+
const result = await withCheckProgress(`Account ${i + 1}/${storage.accounts.length}: refreshing sign-in`, () => queuedRefresh(account.refreshToken), console.log);
|
|
124
164
|
if (result.type === "success") {
|
|
125
165
|
const tokenAccountId = extractAccountId(result.access);
|
|
126
166
|
const nextEmail = sanitizeEmail(extractAccountEmail(result.access, result.idToken));
|
|
@@ -180,16 +220,20 @@ export async function runHealthCheck(options = {}) {
|
|
|
180
220
|
}
|
|
181
221
|
else {
|
|
182
222
|
try {
|
|
183
|
-
const snapshot = await fetchCodexQuotaSnapshot({
|
|
223
|
+
const snapshot = await withCheckProgress(`Account ${i + 1}/${storage.accounts.length}: live probe`, () => fetchCodexQuotaSnapshot({ primeUnusedSubscription,
|
|
184
224
|
accountId: probeAccountId,
|
|
185
225
|
accessToken: result.access,
|
|
186
226
|
model: modelInspection.normalized,
|
|
187
|
-
});
|
|
227
|
+
}), console.log);
|
|
188
228
|
if (workingQuotaCache) {
|
|
189
229
|
quotaCacheChanged =
|
|
190
230
|
updateQuotaCacheForAccount(workingQuotaCache, account, snapshot, storage.accounts, quotaEmailFallbackState ?? undefined) || quotaCacheChanged;
|
|
191
231
|
}
|
|
192
232
|
healthyMessage = formatQuotaSnapshotForDashboard(snapshot, display);
|
|
233
|
+
if (snapshot.primingFailure) {
|
|
234
|
+
healthyTone = "warning";
|
|
235
|
+
warnings += 1;
|
|
236
|
+
}
|
|
193
237
|
codexAvailable += 1;
|
|
194
238
|
}
|
|
195
239
|
catch (error) {
|
|
@@ -239,7 +283,7 @@ export async function runHealthCheck(options = {}) {
|
|
|
239
283
|
}
|
|
240
284
|
if (workingQuotaCache && quotaCacheChanged) {
|
|
241
285
|
try {
|
|
242
|
-
await saveQuotaCache(workingQuotaCache);
|
|
286
|
+
await saveQuotaCache(workingQuotaCache, quotaCache ?? undefined);
|
|
243
287
|
}
|
|
244
288
|
catch (error) {
|
|
245
289
|
// Quota cache is a derived artifact; a transient Windows EBUSY/EPERM
|
|
@@ -256,7 +300,7 @@ export async function runHealthCheck(options = {}) {
|
|
|
256
300
|
const activeAccount = storage.accounts[activeIndex];
|
|
257
301
|
if (activeAccount) {
|
|
258
302
|
await setCodexCliActiveSelection({
|
|
259
|
-
accountId: activeAccount.
|
|
303
|
+
accountId: codexCliAccountIdFor(activeAccount, activeAccount.accessToken),
|
|
260
304
|
email: activeAccount.email,
|
|
261
305
|
accessToken: activeAccount.accessToken,
|
|
262
306
|
refreshToken: activeAccount.refreshToken,
|
|
@@ -291,4 +335,10 @@ export async function runHealthCheck(options = {}) {
|
|
|
291
335
|
tone: warnings > 0 ? "warning" : "muted",
|
|
292
336
|
},
|
|
293
337
|
]));
|
|
338
|
+
if (options.discoverModels) {
|
|
339
|
+
await refreshAndPrintResetCredits(console.log).catch(() => {
|
|
340
|
+
console.log("Reset-credit availability could not be refreshed; cached counts may be stale.");
|
|
341
|
+
});
|
|
342
|
+
await refreshAndPrintModelInventory(console.log);
|
|
343
|
+
}
|
|
294
344
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../../lib/codex-manager/help.ts"],"names":[],"mappings":"AAIA,wBAAgB,UAAU,IAAI,IAAI,
|
|
1
|
+
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../../lib/codex-manager/help.ts"],"names":[],"mappings":"AAIA,wBAAgB,UAAU,IAAI,IAAI,CAyDjC;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC9B,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,OAAO,CAAC;IACpB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAC5B;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,gBAAgB,CAAA;CAAE,GACvC;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC7B;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,mBAAmB,CAuGtE;AAED,UAAU,cAAc;IACvB,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,MAAM,cAAc,GACvB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,cAAc,CAAA;CAAE,GACrC;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC7B;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnD,wBAAgB,cAAc,IAAI,IAAI,CAgBrC;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,cAAc,CAyD5D"}
|
|
@@ -6,18 +6,20 @@ export function printUsage() {
|
|
|
6
6
|
"",
|
|
7
7
|
"Start here:",
|
|
8
8
|
" codex-multi-auth login [--device-auth|--manual|--no-browser] [--org <org_id>] [--preserve-selection] [--account <index|email|account_id>]",
|
|
9
|
+
" codex-multi-auth login --api (API credentials and visible models)",
|
|
9
10
|
" codex-multi-auth status [--json] (list is the same command)",
|
|
10
|
-
" codex-multi-auth check
|
|
11
|
+
" codex-multi-auth check [accounts|resets|capabilities] [--prime] (default: all checks)",
|
|
11
12
|
" codex-multi-auth limits --json [--refresh] (structured quota windows; refresh is age-gated)",
|
|
12
13
|
"",
|
|
13
14
|
"Daily use:",
|
|
14
15
|
" codex-multi-auth list [--json]",
|
|
15
16
|
" codex-multi-auth switch <index> (pins the account for runtime routing)",
|
|
17
|
+
" codex-multi-auth resets list [--refresh] | redeem <account> | auto manual|last-resort",
|
|
16
18
|
" codex-multi-auth unpin (clears the manual pin set by switch)",
|
|
17
19
|
" codex-multi-auth workspace <account> [workspace] (list or switch an account's workspaces)",
|
|
18
20
|
" codex-multi-auth best [--live] [--json] [--model <model>] (clears any manual pin set by switch)",
|
|
19
21
|
" codex-multi-auth forecast [--live] [--json] [--explain] [--model <model>] [--no-runtime-overlay]",
|
|
20
|
-
" codex-multi-auth account tag|untag|weight|pause|unpause|drain|undrain|note|policy list ...",
|
|
22
|
+
" codex-multi-auth account tag|untag|weight|priority|auto-prime|pause|unpause|drain|undrain|note|policy list ...",
|
|
21
23
|
"",
|
|
22
24
|
"Repair:",
|
|
23
25
|
" codex-multi-auth uninstall [--dry-run] [--json] [--clear-accounts]",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login-flow.d.ts","sourceRoot":"","sources":["../../../lib/codex-manager/login-flow.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"login-flow.d.ts","sourceRoot":"","sources":["../../../lib/codex-manager/login-flow.ts"],"names":[],"mappings":"AAWA,OAAO,EACN,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EAUrB,MAAM,eAAe,CAAC;AAwCvB,OAAO,EACN,KAAK,iBAAiB,EAGtB,MAAM,sBAAsB,CAAC;AAM9B;;;;;;;GAOG;AAEH,gBAAgB;AAChB,MAAM,WAAW,aAAa;IAC7B,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC7C,uBAAuB,IAAI,iBAAiB,CAAC;CAC7C;AAkCD,gBAAgB;AAChB,wBAAgB,yBAAyB,CACxC,OAAO,EAAE,gBAAgB,EACzB,UAAU,EAAE,MAAM,GAChB,iBAAiB,GAAG,IAAI,CAkB1B;AAED,gBAAgB;AAChB,wBAAsB,YAAY,CACjC,IAAI,EAAE,MAAM,EAAE,EACd,IAAI,EAAE,aAAa,GACjB,OAAO,CAAC,MAAM,CAAC,CAsBjB"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { runApiLoginMenu } from "./api-login-menu.js";
|
|
2
|
+
import { sanitizeEmail, getAccountIdCandidates } from "../accounts.js";
|
|
3
|
+
import { resolveOrgOverride } from "../auth/org-override.js";
|
|
4
|
+
import { chooseLoginWorkspace } from "./login-workspace-choice.js";
|
|
2
5
|
import { isBrowserLaunchSuppressed } from "../auth/browser.js";
|
|
3
6
|
import { promptAddAnotherAccount, promptLoginMode } from "../cli.js";
|
|
4
7
|
import { ACCOUNT_LIMITS } from "../constants.js";
|
|
@@ -14,9 +17,11 @@ import { stylePromptText } from "./formatters/index.js";
|
|
|
14
17
|
import { runHealthCheck } from "./health-check.js";
|
|
15
18
|
import { parseAuthLoginArgs, printUsage, } from "./help.js";
|
|
16
19
|
import { runActionPanel } from "./login-action-panel.js";
|
|
20
|
+
import { clearAccountsAndCredentialSidecars } from "../storage/credential-sidecars.js";
|
|
17
21
|
import { handleManageAction, promptBackupRestoreMode, promptManualBackupSelection, promptOAuthSignInMode, } from "./login-menu-actions.js";
|
|
18
22
|
import { countMenuQuotaRefreshTargets, DEFAULT_MENU_QUOTA_REFRESH_TTL_MS, loadRuntimeCurrentSelectionForStorage, refreshQuotaCacheForMenu, syncCodexCliActiveSelectionIfDrifted, toExistingAccountInfo, } from "./login-menu-data.js";
|
|
19
23
|
import { isOAuthCancellation, persistAccountPool, resolveAccountSelection, runSignInFlow, syncSelectionToCodex, } from "./login-oauth.js";
|
|
24
|
+
import { applyAuthorizedAccountConstraint, fetchAuthorizedAccounts, } from "../auth/account-access.js";
|
|
20
25
|
import { persistAndSyncSelectedAccount } from "./persist-selected-account.js";
|
|
21
26
|
import { runFix as runRepairFix, runVerifyFlagged as runRepairVerifyFlagged, } from "./repair-commands.js";
|
|
22
27
|
import { applyUiThemeFromDashboardSettings, configureUnifiedSettings, } from "./settings-hub.js";
|
|
@@ -37,7 +42,7 @@ async function drainPendingMenuQuotaRefresh(state) {
|
|
|
37
42
|
}
|
|
38
43
|
const log = createLogger("codex-manager");
|
|
39
44
|
async function clearAccountsAndReset() {
|
|
40
|
-
await clearAccounts
|
|
45
|
+
await clearAccountsAndCredentialSidecars(clearAccounts);
|
|
41
46
|
}
|
|
42
47
|
/** @internal */
|
|
43
48
|
export function resolveLoginAccountTarget(storage, identifier) {
|
|
@@ -58,6 +63,8 @@ export function resolveLoginAccountTarget(storage, identifier) {
|
|
|
58
63
|
}
|
|
59
64
|
/** @internal */
|
|
60
65
|
export async function runAuthLogin(args, deps) {
|
|
66
|
+
if (args.length === 1 && args[0] === "--api")
|
|
67
|
+
return runApiLoginMenu();
|
|
61
68
|
const parsedArgs = parseAuthLoginArgs(args);
|
|
62
69
|
if (!parsedArgs.ok) {
|
|
63
70
|
if (parsedArgs.reason === "error") {
|
|
@@ -141,14 +148,14 @@ async function runLoginDashboardLoop(menuState, deps) {
|
|
|
141
148
|
if (menuResult.mode === "check") {
|
|
142
149
|
clearMenuQuotaAutoRefreshSkip(menuState);
|
|
143
150
|
await runActionPanel("Quick Check", "Checking local session + live status", async () => {
|
|
144
|
-
await runHealthCheck({ forceRefresh: false, liveProbe: true });
|
|
151
|
+
await runHealthCheck({ forceRefresh: false, liveProbe: true, discoverModels: true });
|
|
145
152
|
}, displaySettings);
|
|
146
153
|
continue;
|
|
147
154
|
}
|
|
148
155
|
if (menuResult.mode === "deep-check") {
|
|
149
156
|
clearMenuQuotaAutoRefreshSkip(menuState);
|
|
150
157
|
await runActionPanel("Deep Check", "Refreshing and testing all accounts", async () => {
|
|
151
|
-
await runHealthCheck({ forceRefresh: true, liveProbe: true });
|
|
158
|
+
await runHealthCheck({ forceRefresh: true, liveProbe: true, discoverModels: true });
|
|
152
159
|
}, displaySettings);
|
|
153
160
|
continue;
|
|
154
161
|
}
|
|
@@ -166,6 +173,11 @@ async function runLoginDashboardLoop(menuState, deps) {
|
|
|
166
173
|
}, displaySettings);
|
|
167
174
|
continue;
|
|
168
175
|
}
|
|
176
|
+
if (menuResult.mode === "api-models") {
|
|
177
|
+
await drainPendingMenuQuotaRefresh(menuState);
|
|
178
|
+
await runApiLoginMenu();
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
169
181
|
if (menuResult.mode === "settings") {
|
|
170
182
|
clearMenuQuotaAutoRefreshSkip(menuState);
|
|
171
183
|
await configureUnifiedSettings(displaySettings);
|
|
@@ -182,7 +194,7 @@ async function runLoginDashboardLoop(menuState, deps) {
|
|
|
182
194
|
clearMenuQuotaAutoRefreshSkip(menuState);
|
|
183
195
|
await runActionPanel("Reset Accounts", "Deleting all saved accounts", async () => {
|
|
184
196
|
await clearAccountsAndReset();
|
|
185
|
-
console.log("Cleared saved accounts
|
|
197
|
+
console.log("Cleared saved accounts and API credentials. Account recovery snapshots remain available.");
|
|
186
198
|
}, displaySettings);
|
|
187
199
|
continue;
|
|
188
200
|
}
|
|
@@ -385,9 +397,59 @@ async function runAuthLoginFlow(loginOptions, deps) {
|
|
|
385
397
|
console.error(`Login failed: ${tokenResult.message ?? tokenResult.reason ?? "unknown error"}`);
|
|
386
398
|
return 1;
|
|
387
399
|
}
|
|
388
|
-
|
|
400
|
+
let resolved;
|
|
389
401
|
let persistResult;
|
|
390
402
|
try {
|
|
403
|
+
const workspaceOverride = expectedAccount || resolveOrgOverride(loginOptions.org)
|
|
404
|
+
? loginOptions.org
|
|
405
|
+
: await chooseLoginWorkspace(getAccountIdCandidates(tokenResult.access, tokenResult.idToken));
|
|
406
|
+
if (workspaceOverride === null) {
|
|
407
|
+
// Same as an OAuth cancel: back to the dashboard when it launched
|
|
408
|
+
// this sign-in, otherwise exit.
|
|
409
|
+
if (!explicitSignInMode && existingCount > 0) {
|
|
410
|
+
console.log(stylePromptText("Cancelled. Account was not saved.", "muted"));
|
|
411
|
+
continue loginFlow;
|
|
412
|
+
}
|
|
413
|
+
console.log("Cancelled. Account was not saved.");
|
|
414
|
+
return 0;
|
|
415
|
+
}
|
|
416
|
+
resolved = resolveAccountSelection(tokenResult, workspaceOverride, expectedAccount?.accountId);
|
|
417
|
+
// The workspace list comes from token claims, which can name an
|
|
418
|
+
// organization these credentials hold no live authorization for. Codex
|
|
419
|
+
// CLI >= 0.156.0 checks that against wham/accounts/check and refuses
|
|
420
|
+
// every request with "selected workspace missing from routing
|
|
421
|
+
// discovery", so ask the same question before persisting the id.
|
|
422
|
+
// A targeted re-auth is skipped: persistAccountPool identity-checks it
|
|
423
|
+
// and would reject a rewritten id.
|
|
424
|
+
if (!expectedAccount && resolved.accountIdOverride) {
|
|
425
|
+
const authorized = await fetchAuthorizedAccounts(tokenResult.access);
|
|
426
|
+
const constrained = applyAuthorizedAccountConstraint(resolved, authorized);
|
|
427
|
+
if (constrained.result?.changed) {
|
|
428
|
+
if (resolved.accountIdSource === "manual") {
|
|
429
|
+
// `--org` / CODEX_AUTH_ACCOUNT_ID is explicit intent, so the saved
|
|
430
|
+
// binding is kept as chosen. Codex CLI would refuse it though, so
|
|
431
|
+
// every ~/.codex/auth.json writer gets the authorized id through
|
|
432
|
+
// the saved CodexCliMirror instead.
|
|
433
|
+
resolved = {
|
|
434
|
+
...resolved,
|
|
435
|
+
codexCliMirror: {
|
|
436
|
+
forAccountId: resolved.accountIdOverride,
|
|
437
|
+
accountId: constrained.result.accountId,
|
|
438
|
+
},
|
|
439
|
+
};
|
|
440
|
+
console.warn("Warning: the workspace you selected is not authorized for these credentials. It is saved as chosen, but the Codex CLI auth file gets the backend's default account instead, because Codex CLI 0.156+ refuses unauthorized workspaces.");
|
|
441
|
+
}
|
|
442
|
+
else {
|
|
443
|
+
resolved = { ...constrained.selection, codexCliMirror: null };
|
|
444
|
+
console.warn("Warning: the automatically selected workspace is not authorized for these credentials; using the account the backend reports as default instead. Re-authenticate while that workspace is active in ChatGPT to bind it.");
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
else if (authorized?.accountIds.includes(resolved.accountIdOverride.trim())) {
|
|
448
|
+
// The id is authorized now: drop a mirror left by an earlier login.
|
|
449
|
+
// Without an answer (fail open) the saved mirror is kept.
|
|
450
|
+
resolved = { ...resolved, codexCliMirror: null };
|
|
451
|
+
}
|
|
452
|
+
}
|
|
391
453
|
persistResult = await persistAccountPool([resolved], false, {
|
|
392
454
|
preserveSelection: loginOptions.preserveSelection,
|
|
393
455
|
expectedAccount: expectedAccount ?? undefined,
|
|
@@ -396,7 +458,7 @@ async function runAuthLoginFlow(loginOptions, deps) {
|
|
|
396
458
|
}
|
|
397
459
|
catch (error) {
|
|
398
460
|
if (error instanceof CodexValidationError) {
|
|
399
|
-
console.error(
|
|
461
|
+
console.error(`${expectedAccount ? "Re-authentication" : "Login"} failed: ${error.message}`);
|
|
400
462
|
return 1;
|
|
401
463
|
}
|
|
402
464
|
throw error;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login-menu-data.d.ts","sourceRoot":"","sources":["../../../lib/codex-manager/login-menu-data.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"login-menu-data.d.ts","sourceRoot":"","sources":["../../../lib/codex-manager/login-menu-data.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAGrD,OAAO,EAEN,KAAK,wBAAwB,EAE7B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAEN,KAAK,cAAc,EAGnB,MAAM,mBAAmB,CAAC;AAe3B,OAAO,EAKN,KAAK,8BAA8B,EACnC,MAAM,uCAAuC,CAAC;AAE/C,OAAO,KAAK,EAAqB,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAezE;;;;;;GAMG;AAEH,eAAO,MAAM,iCAAiC,QAAa,CAAC;AA+E5D,wBAAgB,4BAA4B,CAC3C,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,cAAc,EACrB,QAAQ,EAAE,MAAM,EAChB,GAAG,SAAa,GACd,MAAM,CAkBR;AAED,wBAAsB,wBAAwB,CAC7C,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,cAAc,EACrB,QAAQ,EAAE,MAAM,EAChB,UAAU,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,GACnD,OAAO,CAAC,cAAc,CAAC,CAqGzB;AAoKD,wBAAgB,qBAAqB,CACpC,OAAO,EAAE,gBAAgB,EACzB,UAAU,EAAE,cAAc,GAAG,IAAI,EACjC,eAAe,EAAE,wBAAwB,EACzC,cAAc,GAAE,8BAA8B,GAAG,IAAW,GAC1D,mBAAmB,EAAE,CA+EvB;AAED,wBAAsB,qCAAqC,CAC1D,OAAO,EAAE,gBAAgB,EACzB,GAAG,SAAa,GACd,OAAO,CAAC,8BAA8B,GAAG,IAAI,CAAC,CAgBhD;AAgCD,wBAAsB,oCAAoC,CACzD,OAAO,EAAE,gBAAgB,GACvB,OAAO,CAAC,OAAO,CAAC,CAyBlB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { extractAccountId, sanitizeEmail } from "../accounts.js";
|
|
2
|
+
import { codexAuthAccountIdsMatch, codexCliAccountIdFor, codexCliActiveIdentity, isOpenAiOrgId, } from "../auth/token-utils.js";
|
|
2
3
|
import { loadCodexCliState } from "../codex-cli/state.js";
|
|
3
4
|
import { setCodexCliActiveSelection } from "../codex-cli/writer.js";
|
|
4
5
|
import { DEFAULT_DASHBOARD_DISPLAY_SETTINGS, } from "../dashboard-settings.js";
|
|
@@ -110,7 +111,8 @@ export async function refreshQuotaCacheForMenu(storage, cache, maxAgeMs, onProgr
|
|
|
110
111
|
// loaded; another writer (a deep check, a second session) may have saved
|
|
111
112
|
// entries meanwhile, and writing the stale clone back whole-file would
|
|
112
113
|
// silently discard them (last write wins). Re-apply this run's results
|
|
113
|
-
// onto the
|
|
114
|
+
// onto a fresh snapshot for the returned menu view. saveQuotaCache then
|
|
115
|
+
// reloads under its file lock and applies only changes since saveBaseline.
|
|
114
116
|
//
|
|
115
117
|
// loadQuotaCache() is documented to never throw — on any read failure it
|
|
116
118
|
// returns empty maps. We also guard the empty-maps case explicitly: if the
|
|
@@ -118,11 +120,14 @@ export async function refreshQuotaCacheForMenu(storage, cache, maxAgeMs, onProgr
|
|
|
118
120
|
// nextCache so non-probed entries are not wiped. The try/catch handles any
|
|
119
121
|
// mocked or future implementation that does throw.
|
|
120
122
|
let cacheToSave = nextCache;
|
|
123
|
+
let saveBaseline = cache;
|
|
121
124
|
try {
|
|
122
125
|
const persisted = await loadQuotaCache();
|
|
123
126
|
const persistedHasData = Object.keys(persisted.byAccountId).length > 0 ||
|
|
124
|
-
Object.keys(persisted.byEmail).length > 0
|
|
127
|
+
Object.keys(persisted.byEmail).length > 0 ||
|
|
128
|
+
Object.keys(persisted.byWorkspace ?? {}).length > 0;
|
|
125
129
|
if (persistedHasData) {
|
|
130
|
+
saveBaseline = cloneQuotaCacheData(persisted);
|
|
126
131
|
for (const { account, snapshot } of appliedSnapshots) {
|
|
127
132
|
updateQuotaCacheForAccount(persisted, account, snapshot, storage.accounts, emailFallbackState);
|
|
128
133
|
}
|
|
@@ -135,7 +140,7 @@ export async function refreshQuotaCacheForMenu(storage, cache, maxAgeMs, onProgr
|
|
|
135
140
|
// so non-probed entries survive.
|
|
136
141
|
}
|
|
137
142
|
try {
|
|
138
|
-
await saveQuotaCache(cacheToSave);
|
|
143
|
+
await saveQuotaCache(cacheToSave, saveBaseline);
|
|
139
144
|
}
|
|
140
145
|
catch (error) {
|
|
141
146
|
// Quota cache is a derived artifact; a transient Windows EBUSY/EPERM
|
|
@@ -349,10 +354,18 @@ export async function loadRuntimeCurrentSelectionForStorage(storage, now = Date.
|
|
|
349
354
|
function activeAccountMatchesCodexCliState(account, state) {
|
|
350
355
|
if (!state)
|
|
351
356
|
return true;
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
if (
|
|
355
|
-
return
|
|
357
|
+
// An org account_id in auth.json (written before #700) makes Codex CLI
|
|
358
|
+
// 0.156+ fail; resync so the writer replaces it with the workspace id.
|
|
359
|
+
if (isOpenAiOrgId(state.authFileAccountId))
|
|
360
|
+
return false;
|
|
361
|
+
// A stored "org-..." id is written to auth.json as the token's workspace
|
|
362
|
+
// id, while the legacy accounts.json keeps the raw id (#700); match either.
|
|
363
|
+
// Compared as the writer would write it: through the account's
|
|
364
|
+
// CodexCliMirror, or an explicit id the backend refused comes back here.
|
|
365
|
+
const accountId = codexCliAccountIdFor(account, account.accessToken)?.trim();
|
|
366
|
+
const activeIdentity = codexCliActiveIdentity(state);
|
|
367
|
+
if (accountId && activeIdentity.accountId) {
|
|
368
|
+
return codexAuthAccountIdsMatch({ accountId, accessToken: account.accessToken }, activeIdentity);
|
|
356
369
|
}
|
|
357
370
|
const email = sanitizeEmail(account.email);
|
|
358
371
|
const activeEmail = sanitizeEmail(state.activeEmail);
|
|
@@ -376,7 +389,7 @@ export async function syncCodexCliActiveSelectionIfDrifted(storage) {
|
|
|
376
389
|
return false;
|
|
377
390
|
}
|
|
378
391
|
return setCodexCliActiveSelection({
|
|
379
|
-
accountId: account.
|
|
392
|
+
accountId: codexCliAccountIdFor(account, account.accessToken),
|
|
380
393
|
email: account.email,
|
|
381
394
|
accessToken: account.accessToken,
|
|
382
395
|
refreshToken: account.refreshToken,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type Workspace } from "../accounts.js";
|
|
2
2
|
import { type AccountMetadataV3 } from "../storage.js";
|
|
3
|
+
import type { CodexCliMirror } from "../storage/public-types.js";
|
|
3
4
|
import type { AccountIdSource, TokenResult } from "../types.js";
|
|
4
5
|
import { type AccountPoolWriteOutcome } from "./account-pool-write.js";
|
|
5
6
|
/**
|
|
@@ -18,6 +19,8 @@ export type TokenSuccessWithAccount = TokenSuccess & {
|
|
|
18
19
|
accountIdSource?: AccountIdSource;
|
|
19
20
|
accountLabel?: string;
|
|
20
21
|
workspaces?: Workspace[];
|
|
22
|
+
/** Set, keep (undefined) or clear (null) the saved CodexCliMirror. */
|
|
23
|
+
codexCliMirror?: CodexCliMirror | null;
|
|
21
24
|
};
|
|
22
25
|
/** @internal */
|
|
23
26
|
export declare function isOAuthCancellation(result: Exclude<TokenResult, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login-oauth.d.ts","sourceRoot":"","sources":["../../../lib/codex-manager/login-oauth.ts"],"names":[],"mappings":"AAEA,OAAO,EAON,KAAK,SAAS,EACd,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"login-oauth.d.ts","sourceRoot":"","sources":["../../../lib/codex-manager/login-oauth.ts"],"names":[],"mappings":"AAEA,OAAO,EAON,KAAK,SAAS,EACd,MAAM,gBAAgB,CAAC;AAmBxB,OAAO,EACN,KAAK,iBAAiB,EAGtB,MAAM,eAAe,CAAC;AAGvB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEhE,OAAO,EACN,KAAK,uBAAuB,EAG5B,MAAM,yBAAyB,CAAC;AAOjC;;;;;GAKG;AAEH,gBAAgB;AAChB,MAAM,MAAM,YAAY,GAAG,OAAO,CAAC,WAAW,EAAE;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC,CAAC;AACrE,gBAAgB;AAChB,MAAM,MAAM,uBAAuB,GAAG,YAAY,GAAG;IACpD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC;IACzB,sEAAsE;IACtE,cAAc,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;CACvC,CAAC;AAIF,gBAAgB;AAChB,wBAAgB,mBAAmB,CAClC,MAAM,EAAE,OAAO,CAAC,WAAW,EAAE;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC,GAC/C,OAAO,CAGT;AAED,gBAAgB;AAChB,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAIpD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CACtC,MAAM,EAAE,YAAY,EACpB,WAAW,CAAC,EAAE,MAAM,EACpB,eAAe,CAAC,EAAE,MAAM,GACtB,uBAAuB,CAiGzB;AA0FD,gBAAgB;AAChB,MAAM,MAAM,eAAe,GACxB,SAAS,GACT,QAAQ,GACR,QAAQ,GACR,gBAAgB,GAChB,QAAQ,CAAC;AACZ,gBAAgB;AAChB,MAAM,MAAM,iBAAiB,GAAG;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,gBAAgB;AAChB,wBAAsB,YAAY,CACjC,aAAa,EAAE,OAAO,EACtB,UAAU,EAAE,OAAO,CAAC,eAAe,EAAE,SAAS,GAAG,QAAQ,CAAC,GACxD,OAAO,CAAC,WAAW,CAAC,CA6ItB;AAED,gBAAgB;AAChB,wBAAsB,aAAa,CAClC,aAAa,EAAE,OAAO,EACtB,UAAU,EAAE,OAAO,CAAC,eAAe,EAAE,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC,EACrE,OAAO,GAAE,iBAAsB,GAC7B,OAAO,CAAC,WAAW,CAAC,CAetB;AAED,gBAAgB;AAChB,MAAM,MAAM,yBAAyB,GAAG,uBAAuB,CAAC;AAEhE,gBAAgB;AAChB,MAAM,WAAW,wBAAwB;IACxC,0EAA0E;IAC1E,OAAO,EAAE,yBAAyB,CAAC;IACnC,iDAAiD;IACjD,YAAY,EAAE,MAAM,CAAC;IACrB,8CAA8C;IAC9C,WAAW,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,eAAe,EAAE,OAAO,CAAC;IACzB,uEAAuE;IACvE,cAAc,EAAE,OAAO,CAAC;CACxB;AAED,gBAAgB;AAChB,MAAM,MAAM,oBAAoB,GAAG,IAAI,CACtC,iBAAiB,EACjB,UAAU,GAAG,WAAW,GAAG,OAAO,GAAG,cAAc,CACnD,CAAC;AAEF,gBAAgB;AAChB,MAAM,WAAW,yBAAyB;IACzC,0EAA0E;IAC1E,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,sEAAsE;IACtE,eAAe,CAAC,EAAE,oBAAoB,CAAC;IACvC;;;;;;;OAOG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAuGD,gBAAgB;AAChB,wBAAsB,kBAAkB,CACvC,OAAO,EAAE,uBAAuB,EAAE,EAClC,UAAU,EAAE,OAAO,EACnB,OAAO,GAAE,yBAA8B,GACrC,OAAO,CAAC,wBAAwB,GAAG,IAAI,CAAC,CAwJ1C;AAED,gBAAgB;AAChB,wBAAsB,oBAAoB,CACzC,MAAM,EAAE,uBAAuB,GAC7B,OAAO,CAAC,IAAI,CAAC,CAyBf"}
|
|
@@ -7,6 +7,7 @@ import { runDeviceAuthFlow } from "../auth/device-auth.js";
|
|
|
7
7
|
import { resolveOrgOverride } from "../auth/org-override.js";
|
|
8
8
|
import { startLocalOAuthServer } from "../auth/server.js";
|
|
9
9
|
import { describeCallbackFailure } from "../auth/callback-guidance.js";
|
|
10
|
+
import { codexCliAccountIdFor } from "../auth/token-utils.js";
|
|
10
11
|
import { setCodexCliActiveSelection } from "../codex-cli/writer.js";
|
|
11
12
|
import { createLogger } from "../logger.js";
|
|
12
13
|
import { MODEL_FAMILIES } from "../prompts/codex.js";
|
|
@@ -431,6 +432,7 @@ export async function persistAccountPool(results, replaceAll, options = {}) {
|
|
|
431
432
|
accessToken: result.access,
|
|
432
433
|
expiresAt: result.expires,
|
|
433
434
|
workspaces: result.workspaces,
|
|
435
|
+
codexCliMirror: result.codexCliMirror,
|
|
434
436
|
// A targeted re-auth only tops up credentials for the row the user
|
|
435
437
|
// named; it must not silently re-enable an account they disabled.
|
|
436
438
|
preserveEnabledState: Boolean(options.expectedAccount),
|
|
@@ -531,7 +533,10 @@ export async function persistAccountPool(results, replaceAll, options = {}) {
|
|
|
531
533
|
/** @internal */
|
|
532
534
|
export async function syncSelectionToCodex(tokens) {
|
|
533
535
|
const tokenAccountId = extractAccountId(tokens.access);
|
|
534
|
-
const accountId =
|
|
536
|
+
const accountId = codexCliAccountIdFor({
|
|
537
|
+
accountId: resolveRequestAccountId(tokens.accountIdOverride, tokens.accountIdSource, tokenAccountId),
|
|
538
|
+
codexCliMirror: tokens.codexCliMirror ?? undefined,
|
|
539
|
+
}, tokens.access, tokens.idToken);
|
|
535
540
|
const email = sanitizeEmail(extractAccountEmail(tokens.access, tokens.idToken));
|
|
536
541
|
await setCodexCliActiveSelection({
|
|
537
542
|
accountId,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type AccountIdCandidate } from "../auth/token-utils.js";
|
|
2
|
+
import { type MenuItem } from "../ui/select.js";
|
|
3
|
+
interface WorkspaceChoiceDeps {
|
|
4
|
+
interactive: boolean;
|
|
5
|
+
select: (items: MenuItem<string>[]) => Promise<string | null>;
|
|
6
|
+
warn?: (message: string) => void;
|
|
7
|
+
}
|
|
8
|
+
/** Undefined delegates to the unambiguous default; null means cancel without saving. */
|
|
9
|
+
export declare function chooseLoginWorkspace(candidates: AccountIdCandidate[], deps?: WorkspaceChoiceDeps): Promise<string | undefined | null>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=login-workspace-choice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login-workspace-choice.d.ts","sourceRoot":"","sources":["../../../lib/codex-manager/login-workspace-choice.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,KAAK,kBAAkB,EACvB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAU,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAExD,UAAU,mBAAmB;IAC5B,WAAW,EAAE,OAAO,CAAC;IACrB,MAAM,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC9D,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC;AAED,wFAAwF;AACxF,wBAAsB,oBAAoB,CACzC,UAAU,EAAE,kBAAkB,EAAE,EAChC,IAAI,GAAE,mBAOL,GACC,OAAO,CAAC,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC,CAyBpC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { isPersonalAccountCandidate, } from "../auth/token-utils.js";
|
|
2
|
+
import { CodexValidationError } from "../errors.js";
|
|
3
|
+
import { stylePromptText } from "./formatters/index.js";
|
|
4
|
+
import { select } from "../ui/select.js";
|
|
5
|
+
/** Undefined delegates to the unambiguous default; null means cancel without saving. */
|
|
6
|
+
export async function chooseLoginWorkspace(candidates, deps = {
|
|
7
|
+
interactive: Boolean(process.stdin.isTTY && process.stdout.isTTY),
|
|
8
|
+
select: (items) => select(items, {
|
|
9
|
+
message: "Choose the workspace for this account",
|
|
10
|
+
subtitle: "No unique Personal workspace was identified. Choose explicitly before saving.",
|
|
11
|
+
allowEscape: true,
|
|
12
|
+
}),
|
|
13
|
+
}) {
|
|
14
|
+
// An org- id is an API organization alias of a workspace (normalized to the
|
|
15
|
+
// token's workspace when saved), so it never adds a real choice on its own.
|
|
16
|
+
const workspaces = candidates.filter((candidate) => !candidate.accountId.startsWith("org-"));
|
|
17
|
+
if (workspaces.length <= 1 || candidates.filter(isPersonalAccountCandidate).length === 1) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
if (!deps.interactive) {
|
|
21
|
+
// Scripted logins keep the 2.16.0 automatic choice rather than discarding
|
|
22
|
+
// a completed OAuth exchange.
|
|
23
|
+
(deps.warn ?? ((message) => console.warn(stylePromptText(message, "warning"))))("Multiple workspaces found without a unique Personal workspace; saving the automatic choice. Re-run login with --org <workspace-id> to bind a specific workspace.");
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
// An interactive pick is explicit intent and is saved like --org.
|
|
27
|
+
const choice = await deps.select(workspaces.map((candidate) => ({
|
|
28
|
+
label: candidate.label,
|
|
29
|
+
value: candidate.accountId,
|
|
30
|
+
})));
|
|
31
|
+
if (choice === null)
|
|
32
|
+
return null;
|
|
33
|
+
if (!workspaces.some((candidate) => candidate.accountId === choice)) {
|
|
34
|
+
throw new CodexValidationError("Invalid workspace selection. Account was not saved.");
|
|
35
|
+
}
|
|
36
|
+
return choice;
|
|
37
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"persist-selected-account.d.ts","sourceRoot":"","sources":["../../../lib/codex-manager/persist-selected-account.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"persist-selected-account.d.ts","sourceRoot":"","sources":["../../../lib/codex-manager/persist-selected-account.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EACN,KAAK,gBAAgB,EAIrB,MAAM,eAAe,CAAC;AAQvB;;;;;;GAMG;AACH,wBAAsB,6BAA6B,CAAC,EACnD,OAAO,EACP,WAAW,EACX,MAAM,EACN,YAAY,EACZ,kBAAkB,EAClB,2BAAmC,EACnC,MAAc,EACd,QAAgB,EAChB,sBAA8B,GAC9B,EAAE;IACF,OAAO,EAAE,gBAAgB,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,qBAAqB,CAAC;IACpC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,sBAAsB,CAAC,EAAE,OAAO,CAAC;CACjC,GAAG,OAAO,CAAC;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,WAAW,EAAE,OAAO,CAAA;CAAE,CAAC,CAmHrD"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { extractAccountEmail, extractAccountId, sanitizeEmail, } from "../accounts.js";
|
|
2
|
+
import { codexCliAccountIdFor } from "../auth/token-utils.js";
|
|
2
3
|
import { setCodexCliActiveSelection } from "../codex-cli/writer.js";
|
|
3
4
|
import { MODEL_FAMILIES } from "../prompts/codex.js";
|
|
4
5
|
import { queuedRefresh } from "../refresh-queue.js";
|
|
@@ -110,7 +111,7 @@ export async function persistAndSyncSelectedAccount({ storage, targetIndex, pars
|
|
|
110
111
|
}
|
|
111
112
|
await saveAccountsWithRetry(storage, saveAccounts);
|
|
112
113
|
const synced = await setCodexCliActiveSelection({
|
|
113
|
-
accountId: account
|
|
114
|
+
accountId: codexCliAccountIdFor(account, syncAccessToken, syncIdToken),
|
|
114
115
|
email: account.email,
|
|
115
116
|
accessToken: syncAccessToken,
|
|
116
117
|
refreshToken: syncRefreshToken,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type QuotaCacheAccountRef } from "../quota-readiness.js";
|
|
1
2
|
import { type QuotaCacheData, type QuotaCacheEntry } from "../quota-cache.js";
|
|
2
3
|
import type { CodexQuotaSnapshot } from "../quota-probe.js";
|
|
3
4
|
import type { AccountMetadataV3 } from "../storage.js";
|
|
@@ -11,8 +12,13 @@ import type { AccountMetadataV3 } from "../storage.js";
|
|
|
11
12
|
*/
|
|
12
13
|
/** Default model used for live quota probes across manager commands. */
|
|
13
14
|
export declare const DEFAULT_LIVE_PROBE_MODEL = "gpt-5.6-sol";
|
|
14
|
-
|
|
15
|
+
/** Combine selected-workspace observations with persisted account-level rate-limit blockers. */
|
|
16
|
+
export declare function getPersistedQuotaViewForAccount(cache: QuotaCacheData | null, account: QuotaCacheAccountRef & Pick<AccountMetadataV3, "rateLimitResetTimes">, accounts: readonly Pick<AccountMetadataV3, "accountId" | "email">[], now: number, emailFallbackState?: ReadonlyMap<string, import("../quota-readiness.js").QuotaEmailFallbackState>): QuotaCacheEntry | null;
|
|
17
|
+
/** Update legacy stored-binding quota with a unique ID or safe email fallback. */
|
|
15
18
|
export declare function updateQuotaCacheForAccount(cache: QuotaCacheData, account: Pick<AccountMetadataV3, "accountId" | "email">, snapshot: CodexQuotaSnapshot, accounts: readonly Pick<AccountMetadataV3, "accountId" | "email">[], emailFallbackState?: ReadonlyMap<string, import("../quota-readiness.js").QuotaEmailFallbackState>): boolean;
|
|
19
|
+
/** Persist the observed workspace without attributing sibling quota to a stored binding. */
|
|
20
|
+
export declare function updateQuotaCacheForWorkspace(cache: QuotaCacheData, account: AccountMetadataV3, workspaceId: string, snapshot: CodexQuotaSnapshot, accounts: readonly AccountMetadataV3[]): void;
|
|
21
|
+
/** Clone every cache namespace; immutable entries may safely remain shared. */
|
|
16
22
|
export declare function cloneQuotaCacheData(cache: QuotaCacheData): QuotaCacheData;
|
|
17
23
|
export declare function pruneUnsafeQuotaEmailCacheEntry(cache: QuotaCacheData, email: string | undefined, accounts: readonly Pick<AccountMetadataV3, "accountId" | "email">[], emailFallbackState?: ReadonlyMap<string, import("../quota-readiness.js").QuotaEmailFallbackState>): boolean;
|
|
18
24
|
//# sourceMappingURL=quota-cache-helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quota-cache-helpers.d.ts","sourceRoot":"","sources":["../../../lib/codex-manager/quota-cache-helpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"quota-cache-helpers.d.ts","sourceRoot":"","sources":["../../../lib/codex-manager/quota-cache-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,KAAK,oBAAoB,EAKzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAM5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD;;;;;;;GAOG;AAEH,wEAAwE;AACxE,eAAO,MAAM,wBAAwB,gBAAsB,CAAC;AAE5D,gGAAgG;AAChG,wBAAgB,+BAA+B,CAC9C,KAAK,EAAE,cAAc,GAAG,IAAI,EAC5B,OAAO,EAAE,oBAAoB,GAAG,IAAI,CAAC,iBAAiB,EAAE,qBAAqB,CAAC,EAC9E,QAAQ,EAAE,SAAS,IAAI,CAAC,iBAAiB,EAAE,WAAW,GAAG,OAAO,CAAC,EAAE,EACnE,GAAG,EAAE,MAAM,EACX,kBAAkB,+EAAyC,GACzD,eAAe,GAAG,IAAI,CA+BxB;AAsBD,kFAAkF;AAClF,wBAAgB,0BAA0B,CACzC,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,IAAI,CAAC,iBAAiB,EAAE,WAAW,GAAG,OAAO,CAAC,EACvD,QAAQ,EAAE,kBAAkB,EAC5B,QAAQ,EAAE,SAAS,IAAI,CAAC,iBAAiB,EAAE,WAAW,GAAG,OAAO,CAAC,EAAE,EACnE,kBAAkB,+EAAyC,GACzD,OAAO,CAwBT;AAED,4FAA4F;AAC5F,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,kBAAkB,EAAE,QAAQ,EAAE,SAAS,iBAAiB,EAAE,GAAG,IAAI,CAgB/L;AAED,+EAA+E;AAC/E,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,cAAc,GAAG,cAAc,CAQzE;AAED,wBAAgB,+BAA+B,CAC9C,KAAK,EAAE,cAAc,EACrB,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,QAAQ,EAAE,SAAS,IAAI,CAAC,iBAAiB,EAAE,WAAW,GAAG,OAAO,CAAC,EAAE,EACnE,kBAAkB,+EAAyC,GACzD,OAAO,CAeT"}
|