codex-multi-auth 2.0.0 → 2.0.1
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/README.md +7 -6
- package/config/README.md +1 -1
- package/config/codex-legacy.json +571 -646
- package/config/codex-modern.json +258 -274
- package/config/minimal-codex.json +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +85 -14
- package/dist/index.js.map +1 -1
- package/dist/lib/auto-update-checker.d.ts +23 -1
- package/dist/lib/auto-update-checker.d.ts.map +1 -1
- package/dist/lib/auto-update-checker.js +481 -8
- package/dist/lib/auto-update-checker.js.map +1 -1
- package/dist/lib/cli.d.ts +5 -0
- package/dist/lib/cli.d.ts.map +1 -1
- package/dist/lib/cli.js.map +1 -1
- package/dist/lib/codex-manager/commands/best.js +1 -1
- package/dist/lib/codex-manager/commands/best.js.map +1 -1
- package/dist/lib/codex-manager/commands/forecast.js +3 -3
- package/dist/lib/codex-manager/commands/forecast.js.map +1 -1
- package/dist/lib/codex-manager/commands/report.js +3 -3
- package/dist/lib/codex-manager/commands/report.js.map +1 -1
- package/dist/lib/codex-manager/commands/rotation.d.ts +4 -0
- package/dist/lib/codex-manager/commands/rotation.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/rotation.js +37 -11
- package/dist/lib/codex-manager/commands/rotation.js.map +1 -1
- package/dist/lib/codex-manager/commands/status.d.ts +6 -0
- package/dist/lib/codex-manager/commands/status.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/status.js +26 -3
- package/dist/lib/codex-manager/commands/status.js.map +1 -1
- package/dist/lib/codex-manager/forecast-report-commands.js +4 -4
- package/dist/lib/codex-manager/forecast-report-commands.js.map +1 -1
- package/dist/lib/codex-manager/help.js +2 -2
- package/dist/lib/codex-manager/help.js.map +1 -1
- package/dist/lib/codex-manager/rate-limit-markers.d.ts +2 -0
- package/dist/lib/codex-manager/rate-limit-markers.d.ts.map +1 -0
- package/dist/lib/codex-manager/rate-limit-markers.js +4 -0
- package/dist/lib/codex-manager/rate-limit-markers.js.map +1 -0
- package/dist/lib/codex-manager/repair-commands.js +3 -3
- package/dist/lib/codex-manager/repair-commands.js.map +1 -1
- package/dist/lib/codex-manager.d.ts.map +1 -1
- package/dist/lib/codex-manager.js +56 -86
- package/dist/lib/codex-manager.js.map +1 -1
- package/dist/lib/config.js +2 -2
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/prompts/codex.d.ts +1 -1
- package/dist/lib/prompts/codex.d.ts.map +1 -1
- package/dist/lib/prompts/codex.js +3 -3
- package/dist/lib/prompts/codex.js.map +1 -1
- package/dist/lib/quota-probe.js +1 -1
- package/dist/lib/quota-probe.js.map +1 -1
- package/dist/lib/quota-readiness.d.ts +16 -0
- package/dist/lib/quota-readiness.d.ts.map +1 -0
- package/dist/lib/quota-readiness.js +82 -0
- package/dist/lib/quota-readiness.js.map +1 -0
- package/dist/lib/request/fetch-helpers.d.ts.map +1 -1
- package/dist/lib/request/fetch-helpers.js +19 -8
- package/dist/lib/request/fetch-helpers.js.map +1 -1
- package/dist/lib/request/helpers/model-map.d.ts +2 -1
- package/dist/lib/request/helpers/model-map.d.ts.map +1 -1
- package/dist/lib/request/helpers/model-map.js +52 -60
- package/dist/lib/request/helpers/model-map.js.map +1 -1
- package/dist/lib/request/request-transformer.d.ts +2 -2
- package/dist/lib/request/request-transformer.js +4 -3
- package/dist/lib/request/request-transformer.js.map +1 -1
- package/dist/lib/runtime/login-menu-accounts.d.ts +5 -0
- package/dist/lib/runtime/login-menu-accounts.d.ts.map +1 -1
- package/dist/lib/runtime/login-menu-accounts.js +7 -2
- package/dist/lib/runtime/login-menu-accounts.js.map +1 -1
- package/dist/lib/runtime/quota-probe.js +1 -1
- package/dist/lib/runtime/quota-probe.js.map +1 -1
- package/dist/lib/runtime/runtime-current-account.d.ts +52 -0
- package/dist/lib/runtime/runtime-current-account.d.ts.map +1 -0
- package/dist/lib/runtime/runtime-current-account.js +252 -0
- package/dist/lib/runtime/runtime-current-account.js.map +1 -0
- package/dist/lib/runtime-rotation-proxy.js +1 -1
- package/dist/lib/runtime-rotation-proxy.js.map +1 -1
- package/dist/lib/ui/auth-menu.d.ts +6 -1
- package/dist/lib/ui/auth-menu.d.ts.map +1 -1
- package/dist/lib/ui/auth-menu.js +22 -2
- package/dist/lib/ui/auth-menu.js.map +1 -1
- package/package.json +1 -1
- package/scripts/bench-format/models.mjs +6 -8
- package/scripts/benchmark-edit-formats.mjs +1 -1
- package/scripts/codex.js +3538 -3375
- package/scripts/postinstall.js +120 -14
package/dist/index.js
CHANGED
|
@@ -40,6 +40,8 @@ import { PreemptiveQuotaScheduler, readQuotaSchedulerSnapshot, } from "./lib/pre
|
|
|
40
40
|
import { getModelFamily, MODEL_FAMILIES, prewarmCodexInstructions, } from "./lib/prompts/codex.js";
|
|
41
41
|
import { prewarmHostCodexPrompt } from "./lib/prompts/host-codex-prompt.js";
|
|
42
42
|
import { fetchCodexQuotaSnapshot, formatQuotaSnapshotLine, } from "./lib/quota-probe.js";
|
|
43
|
+
import { loadQuotaCache } from "./lib/quota-cache.js";
|
|
44
|
+
import { findQuotaCacheEntryForAccount, isQuotaCacheEntryExhausted, } from "./lib/quota-readiness.js";
|
|
43
45
|
import { detectErrorType, getRecoveryToastContent, isRecoverableError, } from "./lib/recovery.js";
|
|
44
46
|
import { RefreshGuardian } from "./lib/refresh-guardian.js";
|
|
45
47
|
import { queuedRefresh } from "./lib/refresh-queue.js";
|
|
@@ -67,16 +69,19 @@ import { resolveAccountSelection } from "./lib/runtime/account-selection.js";
|
|
|
67
69
|
import { formatRateLimitEntry, getRateLimitResetTimeForFamily, resolveActiveIndex, } from "./lib/runtime/account-status.js";
|
|
68
70
|
import { createPersistAccounts, runRuntimeOAuthFlow, } from "./lib/runtime/auth-facade.js";
|
|
69
71
|
import { applyAccountStorageScopeEntry } from "./lib/runtime/account-storage-scope-entry.js";
|
|
72
|
+
import { getAppBindStatus } from "./lib/runtime/app-bind.js";
|
|
70
73
|
import { runBrowserOAuthFlow } from "./lib/runtime/browser-oauth-flow.js";
|
|
71
74
|
import { handleRuntimeEvent } from "./lib/runtime/event-handler.js";
|
|
72
75
|
import { hydrateRuntimeEmails } from "./lib/runtime/hydrate-emails.js";
|
|
73
76
|
import { buildLoginMenuAccounts } from "./lib/runtime/login-menu-accounts.js";
|
|
77
|
+
import { readAppRuntimeHelperAccountSignal, resolveAccountCurrentMarkers, resolveRuntimeCurrentAccount, } from "./lib/runtime/runtime-current-account.js";
|
|
78
|
+
import { isRateLimitedMarker } from "./lib/codex-manager/rate-limit-markers.js";
|
|
74
79
|
import { ensureLiveAccountSyncEntry } from "./lib/runtime/live-sync-entry.js";
|
|
75
80
|
import { applyLoaderRuntimeSetup } from "./lib/runtime/loader-setup.js";
|
|
76
81
|
import { buildManualOAuthFlow } from "./lib/runtime/manual-oauth-flow.js";
|
|
77
82
|
import { applyPreemptiveQuotaSettingsFromConfig } from "./lib/runtime/quota-settings.js";
|
|
78
83
|
import { ensureLiveAccountSyncState, ensureRefreshGuardianState, ensureSessionAffinityState, } from "./lib/runtime/runtime-services.js";
|
|
79
|
-
import { mutateRuntimeObservabilitySnapshot } from "./lib/runtime/runtime-observability.js";
|
|
84
|
+
import { getRuntimeObservabilitySnapshot, mutateRuntimeObservabilitySnapshot, } from "./lib/runtime/runtime-observability.js";
|
|
80
85
|
import { applyAccountStorageScopeFromConfig } from "./lib/runtime/storage-scope.js";
|
|
81
86
|
import { showRuntimeToast } from "./lib/runtime/toast.js";
|
|
82
87
|
import { createRuntimeSessionRecoveryHook } from "./lib/runtime/session-recovery.js";
|
|
@@ -89,6 +94,33 @@ import { buildTableHeader, buildTableRow, } from "./lib/table-formatter.js";
|
|
|
89
94
|
import { createHashlineEditTool, createHashlineReadTool, } from "./lib/tools/hashline-tools.js";
|
|
90
95
|
import { formatUiBadge, formatUiHeader, formatUiItem, formatUiKeyValue, formatUiSection, paintUiText, } from "./lib/ui/format.js";
|
|
91
96
|
import { setUiRuntimeOptions } from "./lib/ui/runtime.js";
|
|
97
|
+
function currentMarkerLabel(marker) {
|
|
98
|
+
return marker === "in-use" ? "in use" : marker;
|
|
99
|
+
}
|
|
100
|
+
async function resolveRuntimeCurrentForStorage(storage, now) {
|
|
101
|
+
const [appBindStatus, appHelperStatus] = await Promise.all([
|
|
102
|
+
getAppBindStatus()
|
|
103
|
+
.then((status) => (status.running ? status.router : null))
|
|
104
|
+
.catch(() => null),
|
|
105
|
+
Promise.resolve()
|
|
106
|
+
.then(() => readAppRuntimeHelperAccountSignal())
|
|
107
|
+
.catch(() => null),
|
|
108
|
+
]);
|
|
109
|
+
return resolveRuntimeCurrentAccount(storage, {
|
|
110
|
+
runtimeSnapshot: getRuntimeObservabilitySnapshot(),
|
|
111
|
+
appBindStatus,
|
|
112
|
+
appHelperStatus,
|
|
113
|
+
}, { now });
|
|
114
|
+
}
|
|
115
|
+
function appendQuotaStatusMarkers(statuses, quotaEntry, now = Date.now()) {
|
|
116
|
+
if (quotaEntry?.status === 429 &&
|
|
117
|
+
!statuses.some((status) => isRateLimitedMarker(status))) {
|
|
118
|
+
statuses.push("rate-limited");
|
|
119
|
+
}
|
|
120
|
+
if (isQuotaCacheEntryExhausted(quotaEntry, now)) {
|
|
121
|
+
statuses.push("quota-exhausted");
|
|
122
|
+
}
|
|
123
|
+
}
|
|
92
124
|
/**
|
|
93
125
|
* OpenAI Codex OAuth authentication plugin for Codex CLI host runtime
|
|
94
126
|
*
|
|
@@ -101,7 +133,7 @@ import { setUiRuntimeOptions } from "./lib/ui/runtime.js";
|
|
|
101
133
|
* {
|
|
102
134
|
* "plugin": ["codex-multi-auth"],
|
|
103
135
|
|
|
104
|
-
* "model": "openai/gpt-5-codex"
|
|
136
|
+
* "model": "openai/gpt-5.3-codex"
|
|
105
137
|
* }
|
|
106
138
|
* ```
|
|
107
139
|
*/
|
|
@@ -1001,6 +1033,9 @@ export const OpenAIOAuthPlugin = async ({ client }) => {
|
|
|
1001
1033
|
const shouldForceGpt55Fallback = unsupportedModelInfo.isUnsupported &&
|
|
1002
1034
|
(blockedModelNormalized === "gpt-5.5" ||
|
|
1003
1035
|
blockedModelNormalized === "gpt-5.5-pro" ||
|
|
1036
|
+
blockedModelNormalized === "gpt-5.5-2026-04-23" ||
|
|
1037
|
+
blockedModelNormalized ===
|
|
1038
|
+
"gpt-5.5-pro-2026-04-23" ||
|
|
1004
1039
|
blockedModelNormalized === "gpt-5.5-20260423" ||
|
|
1005
1040
|
blockedModelNormalized ===
|
|
1006
1041
|
"gpt-5.5-pro-20260423");
|
|
@@ -1041,7 +1076,7 @@ export const OpenAIOAuthPlugin = async ({ client }) => {
|
|
|
1041
1076
|
customChain: unsupportedCodexFallbackChain,
|
|
1042
1077
|
});
|
|
1043
1078
|
if (fallbackModel) {
|
|
1044
|
-
const previousModel = model ?? "gpt-5-codex";
|
|
1079
|
+
const previousModel = model ?? "gpt-5.3-codex";
|
|
1045
1080
|
const previousModelFamily = modelFamily;
|
|
1046
1081
|
attemptedUnsupportedFallbackModels.add(previousModel);
|
|
1047
1082
|
attemptedUnsupportedFallbackModels.add(fallbackModel);
|
|
@@ -1699,9 +1734,11 @@ export const OpenAIOAuthPlugin = async ({ client }) => {
|
|
|
1699
1734
|
}
|
|
1700
1735
|
const now = Date.now();
|
|
1701
1736
|
const activeIndex = resolveActiveIndex(workingStorage, "codex");
|
|
1737
|
+
const runtimeCurrent = await resolveRuntimeCurrentForStorage(workingStorage, now);
|
|
1702
1738
|
const existingAccounts = buildLoginMenuAccounts(workingStorage.accounts, {
|
|
1703
1739
|
now,
|
|
1704
1740
|
activeIndex,
|
|
1741
|
+
runtimeCurrent,
|
|
1705
1742
|
formatRateLimitEntry: (account, currentNow) => formatRateLimitEntry(account, currentNow, formatWaitTime),
|
|
1706
1743
|
});
|
|
1707
1744
|
const menuResult = await promptLoginMode(existingAccounts, {
|
|
@@ -2098,6 +2135,8 @@ export const OpenAIOAuthPlugin = async ({ client }) => {
|
|
|
2098
2135
|
}
|
|
2099
2136
|
const now = Date.now();
|
|
2100
2137
|
const activeIndex = resolveActiveIndex(storage, "codex");
|
|
2138
|
+
const runtimeCurrent = await resolveRuntimeCurrentForStorage(storage, now);
|
|
2139
|
+
const quotaCache = await loadQuotaCache().catch(() => null);
|
|
2101
2140
|
if (ui.v2Enabled) {
|
|
2102
2141
|
const lines = [
|
|
2103
2142
|
...formatUiHeader(ui, "Codex accounts"),
|
|
@@ -2109,13 +2148,21 @@ export const OpenAIOAuthPlugin = async ({ client }) => {
|
|
|
2109
2148
|
storage.accounts.forEach((account, index) => {
|
|
2110
2149
|
const label = formatAccountLabel(account, index);
|
|
2111
2150
|
const badges = [];
|
|
2112
|
-
|
|
2113
|
-
badges.push(formatUiBadge(ui, "current"
|
|
2151
|
+
for (const marker of resolveAccountCurrentMarkers(index, activeIndex, runtimeCurrent)) {
|
|
2152
|
+
badges.push(formatUiBadge(ui, currentMarkerLabel(marker), marker === "current" ? "accent" : "muted"));
|
|
2153
|
+
}
|
|
2114
2154
|
if (account.enabled === false)
|
|
2115
2155
|
badges.push(formatUiBadge(ui, "disabled", "danger"));
|
|
2116
2156
|
const rateLimit = formatRateLimitEntry(account, now, formatWaitTime);
|
|
2117
2157
|
if (rateLimit)
|
|
2118
2158
|
badges.push(formatUiBadge(ui, "rate-limited", "warning"));
|
|
2159
|
+
const quotaEntry = findQuotaCacheEntryForAccount(quotaCache, account, storage.accounts);
|
|
2160
|
+
if (quotaEntry?.status === 429 && !rateLimit) {
|
|
2161
|
+
badges.push(formatUiBadge(ui, "rate-limited", "warning"));
|
|
2162
|
+
}
|
|
2163
|
+
if (isQuotaCacheEntryExhausted(quotaEntry, now)) {
|
|
2164
|
+
badges.push(formatUiBadge(ui, "quota-exhausted", "warning"));
|
|
2165
|
+
}
|
|
2119
2166
|
if (typeof account.coolingDownUntil === "number" &&
|
|
2120
2167
|
account.coolingDownUntil > now) {
|
|
2121
2168
|
badges.push(formatUiBadge(ui, "cooldown", "warning"));
|
|
@@ -2140,7 +2187,7 @@ export const OpenAIOAuthPlugin = async ({ client }) => {
|
|
|
2140
2187
|
columns: [
|
|
2141
2188
|
{ header: "#", width: 3 },
|
|
2142
2189
|
{ header: "Label", width: 42 },
|
|
2143
|
-
{ header: "Status", width:
|
|
2190
|
+
{ header: "Status", width: 44 },
|
|
2144
2191
|
],
|
|
2145
2192
|
};
|
|
2146
2193
|
const lines = [
|
|
@@ -2152,10 +2199,11 @@ export const OpenAIOAuthPlugin = async ({ client }) => {
|
|
|
2152
2199
|
const label = formatAccountLabel(account, index);
|
|
2153
2200
|
const statuses = [];
|
|
2154
2201
|
const rateLimit = formatRateLimitEntry(account, now, formatWaitTime);
|
|
2155
|
-
|
|
2156
|
-
|
|
2202
|
+
const quotaEntry = findQuotaCacheEntryForAccount(quotaCache, account, storage.accounts);
|
|
2203
|
+
statuses.push(...resolveAccountCurrentMarkers(index, activeIndex, runtimeCurrent).map(currentMarkerLabel));
|
|
2157
2204
|
if (rateLimit)
|
|
2158
2205
|
statuses.push("rate-limited");
|
|
2206
|
+
appendQuotaStatusMarkers(statuses, quotaEntry, now);
|
|
2159
2207
|
if (typeof account.coolingDownUntil === "number" &&
|
|
2160
2208
|
account.coolingDownUntil > now) {
|
|
2161
2209
|
statuses.push("cooldown");
|
|
@@ -2270,6 +2318,8 @@ export const OpenAIOAuthPlugin = async ({ client }) => {
|
|
|
2270
2318
|
}
|
|
2271
2319
|
const now = Date.now();
|
|
2272
2320
|
const activeIndex = resolveActiveIndex(storage, "codex");
|
|
2321
|
+
const runtimeCurrent = await resolveRuntimeCurrentForStorage(storage, now);
|
|
2322
|
+
const quotaCache = await loadQuotaCache().catch(() => null);
|
|
2273
2323
|
if (ui.v2Enabled) {
|
|
2274
2324
|
const lines = [
|
|
2275
2325
|
...formatUiHeader(ui, "Account status"),
|
|
@@ -2280,14 +2330,20 @@ export const OpenAIOAuthPlugin = async ({ client }) => {
|
|
|
2280
2330
|
storage.accounts.forEach((account, index) => {
|
|
2281
2331
|
const label = formatAccountLabel(account, index);
|
|
2282
2332
|
const badges = [];
|
|
2283
|
-
|
|
2284
|
-
badges.push(formatUiBadge(ui, "
|
|
2333
|
+
for (const marker of resolveAccountCurrentMarkers(index, activeIndex, runtimeCurrent)) {
|
|
2334
|
+
badges.push(formatUiBadge(ui, currentMarkerLabel(marker), marker === "current" ? "accent" : "muted"));
|
|
2335
|
+
}
|
|
2285
2336
|
if (account.enabled === false)
|
|
2286
2337
|
badges.push(formatUiBadge(ui, "disabled", "danger"));
|
|
2287
2338
|
const rateLimit = formatRateLimitEntry(account, now, formatWaitTime) ?? "none";
|
|
2288
2339
|
const cooldown = formatCooldown(account, now) ?? "none";
|
|
2340
|
+
const quotaEntry = findQuotaCacheEntryForAccount(quotaCache, account, storage.accounts);
|
|
2289
2341
|
if (rateLimit !== "none")
|
|
2290
2342
|
badges.push(formatUiBadge(ui, "rate-limited", "warning"));
|
|
2343
|
+
if (quotaEntry?.status === 429 && rateLimit === "none")
|
|
2344
|
+
badges.push(formatUiBadge(ui, "rate-limited", "warning"));
|
|
2345
|
+
if (isQuotaCacheEntryExhausted(quotaEntry, now))
|
|
2346
|
+
badges.push(formatUiBadge(ui, "quota-exhausted", "warning"));
|
|
2291
2347
|
if (cooldown !== "none")
|
|
2292
2348
|
badges.push(formatUiBadge(ui, "cooldown", "warning"));
|
|
2293
2349
|
if (badges.length === 0)
|
|
@@ -2322,8 +2378,8 @@ export const OpenAIOAuthPlugin = async ({ client }) => {
|
|
|
2322
2378
|
columns: [
|
|
2323
2379
|
{ header: "#", width: 3 },
|
|
2324
2380
|
{ header: "Label", width: 42 },
|
|
2325
|
-
{ header: "
|
|
2326
|
-
{ header: "Rate Limit", width:
|
|
2381
|
+
{ header: "Current", width: 18 },
|
|
2382
|
+
{ header: "Rate Limit", width: 48 },
|
|
2327
2383
|
{ header: "Cooldown", width: 16 },
|
|
2328
2384
|
{ header: "Last Used", width: 16 },
|
|
2329
2385
|
],
|
|
@@ -2335,8 +2391,23 @@ export const OpenAIOAuthPlugin = async ({ client }) => {
|
|
|
2335
2391
|
];
|
|
2336
2392
|
storage.accounts.forEach((account, index) => {
|
|
2337
2393
|
const label = formatAccountLabel(account, index);
|
|
2338
|
-
const active = index
|
|
2394
|
+
const active = resolveAccountCurrentMarkers(index, activeIndex, runtimeCurrent)
|
|
2395
|
+
.map(currentMarkerLabel)
|
|
2396
|
+
.join(", ") || "No";
|
|
2339
2397
|
const rateLimit = formatRateLimitEntry(account, now, formatWaitTime) ?? "None";
|
|
2398
|
+
const quotaEntry = findQuotaCacheEntryForAccount(quotaCache, account, storage.accounts);
|
|
2399
|
+
const quotaStatuses = [];
|
|
2400
|
+
if (rateLimit === "None" && quotaEntry?.status === 429) {
|
|
2401
|
+
quotaStatuses.push("rate-limited");
|
|
2402
|
+
}
|
|
2403
|
+
if (isQuotaCacheEntryExhausted(quotaEntry, now)) {
|
|
2404
|
+
quotaStatuses.push("quota-exhausted");
|
|
2405
|
+
}
|
|
2406
|
+
const rateLimitDisplay = rateLimit !== "None"
|
|
2407
|
+
? [rateLimit, ...quotaStatuses].join(", ")
|
|
2408
|
+
: quotaStatuses.length > 0
|
|
2409
|
+
? quotaStatuses.join(", ")
|
|
2410
|
+
: "None";
|
|
2340
2411
|
const cooldown = formatCooldown(account, now) ?? "No";
|
|
2341
2412
|
const lastUsed = typeof account.lastUsed === "number" && account.lastUsed > 0
|
|
2342
2413
|
? `${formatWaitTime(now - account.lastUsed)} ago`
|
|
@@ -2345,7 +2416,7 @@ export const OpenAIOAuthPlugin = async ({ client }) => {
|
|
|
2345
2416
|
String(index + 1),
|
|
2346
2417
|
label,
|
|
2347
2418
|
active,
|
|
2348
|
-
|
|
2419
|
+
rateLimitDisplay,
|
|
2349
2420
|
cooldown,
|
|
2350
2421
|
lastUsed,
|
|
2351
2422
|
], statusTableOptions));
|