codex-multi-auth 2.1.13-beta.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +415 -415
- package/assets/codex-multi-auth-icon.svg +39 -39
- package/assets/readme-hero.svg +31 -31
- package/config/README.md +29 -29
- package/config/codex-legacy.json +571 -571
- package/config/codex-modern.json +258 -258
- package/config/minimal-codex.json +15 -15
- package/config/schema/config.schema.json +20 -20
- package/dist/lib/accounts.d.ts.map +1 -1
- package/dist/lib/accounts.js +30 -1
- package/dist/lib/accounts.js.map +1 -1
- package/dist/lib/auth/org-override.d.ts +19 -0
- package/dist/lib/auth/org-override.d.ts.map +1 -0
- package/dist/lib/auth/org-override.js +23 -0
- package/dist/lib/auth/org-override.js.map +1 -0
- package/dist/lib/circuit-breaker.d.ts +6 -0
- package/dist/lib/circuit-breaker.d.ts.map +1 -1
- package/dist/lib/circuit-breaker.js +8 -0
- package/dist/lib/circuit-breaker.js.map +1 -1
- package/dist/lib/codex-manager/account-manager-commands.d.ts +14 -0
- package/dist/lib/codex-manager/account-manager-commands.d.ts.map +1 -0
- package/dist/lib/codex-manager/account-manager-commands.js +43 -0
- package/dist/lib/codex-manager/account-manager-commands.js.map +1 -0
- package/dist/lib/codex-manager/commands/best.d.ts +1 -1
- package/dist/lib/codex-manager/commands/best.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/best.js +2 -1
- package/dist/lib/codex-manager/commands/best.js.map +1 -1
- package/dist/lib/codex-manager/commands/debug-bundle.d.ts +16 -0
- package/dist/lib/codex-manager/commands/debug-bundle.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/debug-bundle.js +80 -5
- package/dist/lib/codex-manager/commands/debug-bundle.js.map +1 -1
- 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 +2 -1
- package/dist/lib/codex-manager/commands/forecast.js.map +1 -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/report.js.map +1 -1
- package/dist/lib/codex-manager/commands/status.d.ts +2 -0
- package/dist/lib/codex-manager/commands/status.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/status.js +84 -25
- package/dist/lib/codex-manager/commands/status.js.map +1 -1
- package/dist/lib/codex-manager/commands/switch.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/switch.js +7 -0
- package/dist/lib/codex-manager/commands/switch.js.map +1 -1
- package/dist/lib/codex-manager/experimental-settings-prompt.d.ts.map +1 -1
- package/dist/lib/codex-manager/experimental-settings-prompt.js +13 -3
- package/dist/lib/codex-manager/experimental-settings-prompt.js.map +1 -1
- package/dist/lib/codex-manager/forecast-report-commands.d.ts.map +1 -1
- package/dist/lib/codex-manager/forecast-report-commands.js +3 -3
- package/dist/lib/codex-manager/forecast-report-commands.js.map +1 -1
- package/dist/lib/codex-manager/repair-commands.d.ts.map +1 -1
- package/dist/lib/codex-manager/repair-commands.js +11 -1
- package/dist/lib/codex-manager/repair-commands.js.map +1 -1
- package/dist/lib/codex-manager/settings-hub/experimental.d.ts.map +1 -1
- package/dist/lib/codex-manager/settings-hub/experimental.js +8 -0
- package/dist/lib/codex-manager/settings-hub/experimental.js.map +1 -1
- package/dist/lib/codex-manager.d.ts +3 -0
- package/dist/lib/codex-manager.d.ts.map +1 -1
- package/dist/lib/codex-manager.js +53 -65
- package/dist/lib/codex-manager.js.map +1 -1
- package/dist/lib/config.d.ts +26 -0
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +152 -5
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/context-overflow.d.ts +7 -2
- package/dist/lib/context-overflow.d.ts.map +1 -1
- package/dist/lib/context-overflow.js +65 -47
- package/dist/lib/context-overflow.js.map +1 -1
- package/dist/lib/errors.d.ts +16 -0
- package/dist/lib/errors.d.ts.map +1 -1
- package/dist/lib/errors.js +23 -0
- package/dist/lib/errors.js.map +1 -1
- package/dist/lib/local-bridge.d.ts +8 -0
- package/dist/lib/local-bridge.d.ts.map +1 -1
- package/dist/lib/local-bridge.js +81 -7
- package/dist/lib/local-bridge.js.map +1 -1
- package/dist/lib/logger.d.ts +9 -1
- package/dist/lib/logger.d.ts.map +1 -1
- package/dist/lib/logger.js +104 -19
- package/dist/lib/logger.js.map +1 -1
- package/dist/lib/oauth-success.html +125 -125
- package/dist/lib/oc-chatgpt-orchestrator.d.ts +7 -1
- package/dist/lib/oc-chatgpt-orchestrator.d.ts.map +1 -1
- package/dist/lib/oc-chatgpt-orchestrator.js +68 -9
- package/dist/lib/oc-chatgpt-orchestrator.js.map +1 -1
- package/dist/lib/policy/runtime-policy.d.ts.map +1 -1
- package/dist/lib/policy/runtime-policy.js +15 -1
- package/dist/lib/policy/runtime-policy.js.map +1 -1
- package/dist/lib/prompts/codex-host-bridge.js +138 -138
- package/dist/lib/prompts/codex.d.ts.map +1 -1
- package/dist/lib/prompts/codex.js +203 -108
- package/dist/lib/prompts/codex.js.map +1 -1
- package/dist/lib/prompts/fetch-utils.d.ts +72 -0
- package/dist/lib/prompts/fetch-utils.d.ts.map +1 -0
- package/dist/lib/prompts/fetch-utils.js +165 -0
- package/dist/lib/prompts/fetch-utils.js.map +1 -0
- package/dist/lib/prompts/host-codex-prompt.d.ts.map +1 -1
- package/dist/lib/prompts/host-codex-prompt.js +24 -10
- package/dist/lib/prompts/host-codex-prompt.js.map +1 -1
- package/dist/lib/quota-cache.d.ts.map +1 -1
- package/dist/lib/quota-cache.js +10 -1
- package/dist/lib/quota-cache.js.map +1 -1
- package/dist/lib/quota-probe.d.ts +21 -0
- package/dist/lib/quota-probe.d.ts.map +1 -1
- package/dist/lib/quota-probe.js +39 -0
- package/dist/lib/quota-probe.js.map +1 -1
- package/dist/lib/quota-readiness.d.ts +3 -1
- package/dist/lib/quota-readiness.d.ts.map +1 -1
- package/dist/lib/quota-readiness.js +16 -3
- package/dist/lib/quota-readiness.js.map +1 -1
- package/dist/lib/recovery/storage.d.ts +7 -0
- package/dist/lib/recovery/storage.d.ts.map +1 -1
- package/dist/lib/recovery/storage.js +178 -10
- package/dist/lib/recovery/storage.js.map +1 -1
- package/dist/lib/refresh-lease.d.ts +1 -1
- package/dist/lib/refresh-lease.d.ts.map +1 -1
- package/dist/lib/refresh-lease.js +25 -3
- package/dist/lib/refresh-lease.js.map +1 -1
- package/dist/lib/refresh-queue.d.ts.map +1 -1
- package/dist/lib/refresh-queue.js +31 -17
- package/dist/lib/refresh-queue.js.map +1 -1
- package/dist/lib/request/fetch-helpers.d.ts +0 -5
- package/dist/lib/request/fetch-helpers.d.ts.map +1 -1
- package/dist/lib/request/fetch-helpers.js +36 -7
- package/dist/lib/request/fetch-helpers.js.map +1 -1
- package/dist/lib/rotation.d.ts +12 -0
- package/dist/lib/rotation.d.ts.map +1 -1
- package/dist/lib/rotation.js +36 -0
- package/dist/lib/rotation.js.map +1 -1
- package/dist/lib/runtime/account-check-types.d.ts +1 -0
- package/dist/lib/runtime/account-check-types.d.ts.map +1 -1
- package/dist/lib/runtime/account-check-types.js +1 -0
- package/dist/lib/runtime/account-check-types.js.map +1 -1
- package/dist/lib/runtime/account-check.d.ts.map +1 -1
- package/dist/lib/runtime/account-check.js +15 -4
- package/dist/lib/runtime/account-check.js.map +1 -1
- package/dist/lib/runtime/runtime-observability.d.ts.map +1 -1
- package/dist/lib/runtime/runtime-observability.js +24 -2
- package/dist/lib/runtime/runtime-observability.js.map +1 -1
- package/dist/lib/runtime-rotation-proxy.d.ts +3 -0
- package/dist/lib/runtime-rotation-proxy.d.ts.map +1 -1
- package/dist/lib/runtime-rotation-proxy.js +296 -21
- package/dist/lib/runtime-rotation-proxy.js.map +1 -1
- package/dist/lib/schemas.d.ts +2 -0
- package/dist/lib/schemas.d.ts.map +1 -1
- package/dist/lib/schemas.js +2 -0
- package/dist/lib/schemas.js.map +1 -1
- package/dist/lib/storage/account-clear.d.ts.map +1 -1
- package/dist/lib/storage/account-clear.js +4 -2
- package/dist/lib/storage/account-clear.js.map +1 -1
- package/dist/lib/storage/flagged-storage-io.d.ts.map +1 -1
- package/dist/lib/storage/flagged-storage-io.js +4 -1
- package/dist/lib/storage/flagged-storage-io.js.map +1 -1
- package/dist/lib/storage/import-export.d.ts.map +1 -1
- package/dist/lib/storage/import-export.js +29 -9
- package/dist/lib/storage/import-export.js.map +1 -1
- package/dist/lib/storage/paths.d.ts.map +1 -1
- package/dist/lib/storage/paths.js +93 -0
- package/dist/lib/storage/paths.js.map +1 -1
- package/dist/lib/storage/storage-parser.d.ts.map +1 -1
- package/dist/lib/storage/storage-parser.js +7 -1
- package/dist/lib/storage/storage-parser.js.map +1 -1
- package/dist/lib/storage.d.ts.map +1 -1
- package/dist/lib/storage.js +13 -9
- package/dist/lib/storage.js.map +1 -1
- package/dist/lib/table-formatter.d.ts.map +1 -1
- package/dist/lib/table-formatter.js +20 -2
- package/dist/lib/table-formatter.js.map +1 -1
- package/dist/lib/types.d.ts +7 -0
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/ui/auth-menu.d.ts.map +1 -1
- package/dist/lib/ui/auth-menu.js +8 -2
- package/dist/lib/ui/auth-menu.js.map +1 -1
- package/dist/lib/ui/display-width.d.ts +27 -0
- package/dist/lib/ui/display-width.d.ts.map +1 -0
- package/dist/lib/ui/display-width.js +194 -0
- package/dist/lib/ui/display-width.js.map +1 -0
- package/dist/lib/ui/select.d.ts +23 -0
- package/dist/lib/ui/select.d.ts.map +1 -1
- package/dist/lib/ui/select.js +64 -16
- package/dist/lib/ui/select.js.map +1 -1
- package/dist/lib/ui/theme.d.ts +13 -0
- package/dist/lib/ui/theme.d.ts.map +1 -1
- package/dist/lib/ui/theme.js +34 -1
- package/dist/lib/ui/theme.js.map +1 -1
- package/node_modules/@codex-ai/plugin/dist/index.d.ts +2 -2
- package/node_modules/@codex-ai/plugin/dist/index.js +2 -2
- package/node_modules/@codex-ai/plugin/dist/tool.d.ts +42 -42
- package/node_modules/@codex-ai/plugin/dist/tool.js +29 -29
- package/node_modules/@codex-ai/plugin/package.json +9 -9
- package/node_modules/@codex-ai/sdk/dist/index.d.ts +4 -0
- package/node_modules/@codex-ai/sdk/dist/index.js +2 -0
- package/node_modules/@codex-ai/sdk/package.json +8 -0
- package/package.json +196 -193
- package/scripts/codex-app-launcher.js +653 -653
- package/scripts/codex-app-router.js +322 -322
- package/scripts/codex-bin-resolver.js +254 -254
- package/scripts/codex-multi-auth.js +59 -59
- package/scripts/codex-routing.js +59 -56
- package/scripts/codex.js +4782 -4275
- package/scripts/install-codex-auth-utils.js +206 -206
- package/scripts/mcodex +117 -0
- package/scripts/postinstall.js +343 -343
- package/scripts/preuninstall.js +254 -254
- 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
|
@@ -3,6 +3,7 @@ import { createInterface } from "node:readline/promises";
|
|
|
3
3
|
import { extractAccountEmail, extractAccountId, formatAccountLabel, formatWaitTime, getAccountIdCandidates, resolveRequestAccountId, sanitizeEmail, selectBestAccountCandidate, shouldUpdateAccountIdFromToken, } from "./accounts.js";
|
|
4
4
|
import { createAuthorizationFlow, exchangeAuthorizationCode, parseAuthorizationInput, redactOAuthUrlForLog, REDIRECT_URI, } from "./auth/auth.js";
|
|
5
5
|
import { runDeviceAuthFlow } from "./auth/device-auth.js";
|
|
6
|
+
import { resolveOrgOverride } from "./auth/org-override.js";
|
|
6
7
|
import { copyTextToClipboard, isBrowserLaunchSuppressed, openBrowserUrl, } from "./auth/browser.js";
|
|
7
8
|
import { startLocalOAuthServer } from "./auth/server.js";
|
|
8
9
|
import { promptAddAnotherAccount, promptLoginMode, } from "./cli.js";
|
|
@@ -10,6 +11,7 @@ import { loadCodexCliState } from "./codex-cli/state.js";
|
|
|
10
11
|
import { setCodexCliActiveSelection } from "./codex-cli/writer.js";
|
|
11
12
|
import { runBestCommand, } from "./codex-manager/commands/best.js";
|
|
12
13
|
import { runAccountCommand } from "./codex-manager/commands/account.js";
|
|
14
|
+
import { ACCOUNT_MANAGER_COMMANDS } from "./codex-manager/account-manager-commands.js";
|
|
13
15
|
import { runBudgetCommand } from "./codex-manager/commands/budget.js";
|
|
14
16
|
import { runBridgeCommand } from "./codex-manager/commands/bridge.js";
|
|
15
17
|
import { runCheckCommand } from "./codex-manager/commands/check.js";
|
|
@@ -49,7 +51,8 @@ import { formatRateLimitEntry as formatAccountRateLimitEntry, getRateLimitResetT
|
|
|
49
51
|
import { buildQuotaEmailFallbackState, hasSafeQuotaEmailFallback, hasUniqueQuotaAccountId, isQuotaCacheEntryExhausted, normalizeQuotaAccountId, normalizeQuotaEmail, quotaLeftPercentFromUsed, } from "./quota-readiness.js";
|
|
50
52
|
import { loadQuotaCache, saveQuotaCache, } from "./quota-cache.js";
|
|
51
53
|
import { isDisplayCurrentAccount, readAppRuntimeHelperAccountSignal, resolveAccountCurrentMarkers, resolveRuntimeCurrentAccount, } from "./runtime/runtime-current-account.js";
|
|
52
|
-
import { fetchCodexQuotaSnapshot, formatQuotaSnapshotLine, } from "./quota-probe.js";
|
|
54
|
+
import { fetchCodexQuotaSnapshot, formatQuotaSnapshotLine, CODEX_UNAVAILABLE_PROBE_NOTE, } from "./quota-probe.js";
|
|
55
|
+
import { isCodexUnavailableError } from "./errors.js";
|
|
53
56
|
import { queuedRefresh } from "./refresh-queue.js";
|
|
54
57
|
import { clearAccounts, findMatchingAccountIndex, formatStorageErrorHint, inspectStorageHealth, getLastAccountsSaveTimestamp, getNamedBackups, getStoragePath, loadAccounts, loadFlaggedAccounts, readAffinityGenerationFromDisk, restoreAccountsFromBackup, StorageError, saveAccounts, setStoragePath, withAccountStorageTransaction, } from "./storage.js";
|
|
55
58
|
import { ANSI } from "./ui/ansi.js";
|
|
@@ -59,36 +62,6 @@ import { paintUiText, quotaToneFromLeftPercent } from "./ui/format.js";
|
|
|
59
62
|
import { getUiRuntimeOptions } from "./ui/runtime.js";
|
|
60
63
|
import { select } from "./ui/select.js";
|
|
61
64
|
const log = createLogger("codex-manager");
|
|
62
|
-
const ACCOUNT_MANAGER_COMMANDS = new Set([
|
|
63
|
-
"login",
|
|
64
|
-
"list",
|
|
65
|
-
"status",
|
|
66
|
-
"switch",
|
|
67
|
-
"unpin",
|
|
68
|
-
"workspace",
|
|
69
|
-
"best",
|
|
70
|
-
"check",
|
|
71
|
-
"features",
|
|
72
|
-
"usage",
|
|
73
|
-
"verify-flagged",
|
|
74
|
-
"verify",
|
|
75
|
-
"forecast",
|
|
76
|
-
"report",
|
|
77
|
-
"fix",
|
|
78
|
-
"doctor",
|
|
79
|
-
"uninstall",
|
|
80
|
-
"account",
|
|
81
|
-
"budget",
|
|
82
|
-
"bridge",
|
|
83
|
-
"integrations",
|
|
84
|
-
"models",
|
|
85
|
-
"monitor",
|
|
86
|
-
"rotation",
|
|
87
|
-
"why-selected",
|
|
88
|
-
"config",
|
|
89
|
-
"init-config",
|
|
90
|
-
"debug",
|
|
91
|
-
]);
|
|
92
65
|
function stylePromptText(text, tone) {
|
|
93
66
|
if (!output.isTTY)
|
|
94
67
|
return text;
|
|
@@ -254,7 +227,10 @@ function styleQuotaSummary(summary) {
|
|
|
254
227
|
});
|
|
255
228
|
return joinStyledSegments(rendered);
|
|
256
229
|
}
|
|
257
|
-
|
|
230
|
+
// Exported for unit tests: tone precedence (danger before warning) is
|
|
231
|
+
// security/UX-relevant — a failure whose text contains "unavailable" must
|
|
232
|
+
// render red, not be downgraded to yellow. See test/codex-manager-detail-tone.test.ts.
|
|
233
|
+
export function styleAccountDetailText(detail, fallbackTone = "muted") {
|
|
258
234
|
const compact = collapseWhitespace(detail);
|
|
259
235
|
if (!compact)
|
|
260
236
|
return stylePromptText("", fallbackTone);
|
|
@@ -268,10 +244,14 @@ function styleAccountDetailText(detail, fallbackTone = "muted") {
|
|
|
268
244
|
: /ok|working|succeeded|valid/i.test(prefix)
|
|
269
245
|
? "success"
|
|
270
246
|
: fallbackTone;
|
|
271
|
-
const suffixTone =
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
247
|
+
const suffixTone =
|
|
248
|
+
// danger wins first: a real failure whose text happens to contain
|
|
249
|
+
// "unavailable"/"not available" (e.g. a 5xx "service not available")
|
|
250
|
+
// must render red, not be downgraded to a yellow warning.
|
|
251
|
+
/failed|error/i.test(suffix)
|
|
252
|
+
? "danger"
|
|
253
|
+
: /re-login|stale|warning|retry|fallback|unavailable|not available/i.test(suffix)
|
|
254
|
+
? "warning"
|
|
275
255
|
: "muted";
|
|
276
256
|
const chunks = [];
|
|
277
257
|
if (prefix)
|
|
@@ -283,10 +263,10 @@ function styleAccountDetailText(detail, fallbackTone = "muted") {
|
|
|
283
263
|
}
|
|
284
264
|
if (/rate-limited/i.test(compact))
|
|
285
265
|
return stylePromptText(compact, "danger");
|
|
286
|
-
if (/re-login|stale|warning|fallback/i.test(compact))
|
|
287
|
-
return stylePromptText(compact, "warning");
|
|
288
266
|
if (/failed|error/i.test(compact))
|
|
289
267
|
return stylePromptText(compact, "danger");
|
|
268
|
+
if (/re-login|stale|warning|fallback|unavailable|not available/i.test(compact))
|
|
269
|
+
return stylePromptText(compact, "warning");
|
|
290
270
|
if (/ok|working|succeeded|valid/i.test(compact))
|
|
291
271
|
return stylePromptText(compact, "success");
|
|
292
272
|
return stylePromptText(compact, fallbackTone);
|
|
@@ -860,8 +840,17 @@ async function syncCodexCliActiveSelectionIfDrifted(storage) {
|
|
|
860
840
|
return false;
|
|
861
841
|
}
|
|
862
842
|
}
|
|
863
|
-
|
|
864
|
-
|
|
843
|
+
/**
|
|
844
|
+
* Resolve the account-id selection for freshly-minted tokens.
|
|
845
|
+
*
|
|
846
|
+
* The org-override precedence (explicit `login --org` wins over the ambient
|
|
847
|
+
* CODEX_AUTH_ACCOUNT_ID env, for this call only) lives in the internal
|
|
848
|
+
* lib/auth/org-override.ts module so it can be unit-tested without exporting this
|
|
849
|
+
* CLI-internal function. Threading the org as a parameter avoids mutating
|
|
850
|
+
* process.env for the duration of a login, which raced on concurrent re-entry.
|
|
851
|
+
*/
|
|
852
|
+
function resolveAccountSelection(tokens, orgOverride) {
|
|
853
|
+
const override = resolveOrgOverride(orgOverride);
|
|
865
854
|
if (override) {
|
|
866
855
|
return {
|
|
867
856
|
...tokens,
|
|
@@ -1660,9 +1649,15 @@ async function runHealthCheck(options = {}) {
|
|
|
1660
1649
|
healthDetail = formatQuotaSnapshotForDashboard(snapshot, display);
|
|
1661
1650
|
}
|
|
1662
1651
|
catch (error) {
|
|
1663
|
-
const message = normalizeFailureDetail(error instanceof Error ? error.message : String(error), undefined);
|
|
1664
1652
|
warnings += 1;
|
|
1665
|
-
|
|
1653
|
+
if (isCodexUnavailableError(error)) {
|
|
1654
|
+
healthDetail =
|
|
1655
|
+
`signed in and working (${CODEX_UNAVAILABLE_PROBE_NOTE})`;
|
|
1656
|
+
}
|
|
1657
|
+
else {
|
|
1658
|
+
const message = normalizeFailureDetail(error instanceof Error ? error.message : String(error), undefined);
|
|
1659
|
+
healthDetail = `signed in and working (live check failed: ${message})`;
|
|
1660
|
+
}
|
|
1666
1661
|
}
|
|
1667
1662
|
}
|
|
1668
1663
|
}
|
|
@@ -1738,9 +1733,15 @@ async function runHealthCheck(options = {}) {
|
|
|
1738
1733
|
healthyMessage = formatQuotaSnapshotForDashboard(snapshot, display);
|
|
1739
1734
|
}
|
|
1740
1735
|
catch (error) {
|
|
1741
|
-
const message = normalizeFailureDetail(error instanceof Error ? error.message : String(error), undefined);
|
|
1742
1736
|
warnings += 1;
|
|
1743
|
-
|
|
1737
|
+
if (isCodexUnavailableError(error)) {
|
|
1738
|
+
healthyMessage =
|
|
1739
|
+
`working now (${CODEX_UNAVAILABLE_PROBE_NOTE})`;
|
|
1740
|
+
}
|
|
1741
|
+
else {
|
|
1742
|
+
const message = normalizeFailureDetail(error instanceof Error ? error.message : String(error), undefined);
|
|
1743
|
+
healthyMessage = `working now (live check failed: ${message})`;
|
|
1744
|
+
}
|
|
1744
1745
|
}
|
|
1745
1746
|
}
|
|
1746
1747
|
}
|
|
@@ -2074,27 +2075,13 @@ async function runAuthLogin(args) {
|
|
|
2074
2075
|
const loginOptions = parsedArgs.options;
|
|
2075
2076
|
// `--org <id>` binds this login to a specific workspace/org so the same
|
|
2076
2077
|
// email's personal vs business/team workspace can be registered on demand
|
|
2077
|
-
// (issue #491).
|
|
2078
|
-
//
|
|
2079
|
-
//
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
return runAuthLoginFlow(loginOptions);
|
|
2083
|
-
}
|
|
2084
|
-
const previousAccountIdOverride = process.env.CODEX_AUTH_ACCOUNT_ID;
|
|
2085
|
-
process.env.CODEX_AUTH_ACCOUNT_ID = loginOptions.org;
|
|
2086
|
-
console.log(`Binding this login to workspace org id: ${loginOptions.org}`);
|
|
2087
|
-
try {
|
|
2088
|
-
return await runAuthLoginFlow(loginOptions);
|
|
2089
|
-
}
|
|
2090
|
-
finally {
|
|
2091
|
-
if (previousAccountIdOverride === undefined) {
|
|
2092
|
-
delete process.env.CODEX_AUTH_ACCOUNT_ID;
|
|
2093
|
-
}
|
|
2094
|
-
else {
|
|
2095
|
-
process.env.CODEX_AUTH_ACCOUNT_ID = previousAccountIdOverride;
|
|
2096
|
-
}
|
|
2078
|
+
// (issue #491). The org is threaded explicitly into resolveAccountSelection
|
|
2079
|
+
// (no process.env mutation), so concurrent re-entry (menu re-entry, a reused
|
|
2080
|
+
// test worker) can never bind a login to a stale org via a shared global.
|
|
2081
|
+
if (loginOptions.org) {
|
|
2082
|
+
console.log(`Binding this login to workspace org id: ${loginOptions.org}`);
|
|
2097
2083
|
}
|
|
2084
|
+
return runAuthLoginFlow(loginOptions);
|
|
2098
2085
|
}
|
|
2099
2086
|
async function runAuthLoginFlow(loginOptions) {
|
|
2100
2087
|
setStoragePath(null);
|
|
@@ -2368,7 +2355,7 @@ async function runAuthLoginFlow(loginOptions) {
|
|
|
2368
2355
|
console.error(`Login failed: ${tokenResult.message ?? tokenResult.reason ?? "unknown error"}`);
|
|
2369
2356
|
return 1;
|
|
2370
2357
|
}
|
|
2371
|
-
const resolved = resolveAccountSelection(tokenResult);
|
|
2358
|
+
const resolved = resolveAccountSelection(tokenResult, loginOptions.org);
|
|
2372
2359
|
await persistAccountPool([resolved], false);
|
|
2373
2360
|
await syncSelectionToCodex(resolved);
|
|
2374
2361
|
const latestStorage = await loadAccounts();
|
|
@@ -2688,6 +2675,7 @@ export async function runCodexMultiAuthCli(rawArgs) {
|
|
|
2688
2675
|
.catch(() => null),
|
|
2689
2676
|
loadAppHelperStatus: readAppRuntimeHelperAccountSignal,
|
|
2690
2677
|
loadQuotaCache,
|
|
2678
|
+
json: rest.includes("--json") || rest.includes("-j"),
|
|
2691
2679
|
});
|
|
2692
2680
|
}
|
|
2693
2681
|
if (command === "switch") {
|