codex-multi-auth 1.3.0 → 1.3.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 +1 -1
- package/config/codex-legacy.json +85 -10
- package/config/codex-modern.json +35 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/accounts.d.ts.map +1 -1
- package/dist/lib/accounts.js +60 -2
- package/dist/lib/accounts.js.map +1 -1
- package/dist/lib/auth/auth.d.ts +19 -0
- package/dist/lib/auth/auth.d.ts.map +1 -1
- package/dist/lib/auth/auth.js +90 -4
- package/dist/lib/auth/auth.js.map +1 -1
- package/dist/lib/auth/server.d.ts.map +1 -1
- package/dist/lib/auth/server.js +11 -5
- package/dist/lib/auth/server.js.map +1 -1
- package/dist/lib/capability-policy.d.ts.map +1 -1
- package/dist/lib/capability-policy.js +7 -2
- package/dist/lib/capability-policy.js.map +1 -1
- package/dist/lib/codex-manager.js +2 -2
- package/dist/lib/codex-manager.js.map +1 -1
- package/dist/lib/prompts/codex.d.ts +2 -2
- package/dist/lib/prompts/codex.js +2 -2
- package/dist/lib/recovery/storage.d.ts +13 -0
- package/dist/lib/recovery/storage.d.ts.map +1 -1
- package/dist/lib/recovery/storage.js +32 -1
- package/dist/lib/recovery/storage.js.map +1 -1
- package/dist/lib/request/fetch-helpers.d.ts.map +1 -1
- package/dist/lib/request/fetch-helpers.js +15 -2
- package/dist/lib/request/fetch-helpers.js.map +1 -1
- package/dist/lib/request/helpers/model-map.d.ts +3 -3
- package/dist/lib/request/helpers/model-map.d.ts.map +1 -1
- package/dist/lib/request/helpers/model-map.js +146 -70
- package/dist/lib/request/helpers/model-map.js.map +1 -1
- package/dist/lib/request/rate-limit-backoff.d.ts +14 -1
- package/dist/lib/request/rate-limit-backoff.d.ts.map +1 -1
- package/dist/lib/request/rate-limit-backoff.js +26 -5
- package/dist/lib/request/rate-limit-backoff.js.map +1 -1
- package/dist/lib/request/response-handler.d.ts.map +1 -1
- package/dist/lib/request/response-handler.js +16 -3
- package/dist/lib/request/response-handler.js.map +1 -1
- package/dist/lib/rotation.d.ts +2 -0
- package/dist/lib/rotation.d.ts.map +1 -1
- package/dist/lib/rotation.js +26 -0
- package/dist/lib/rotation.js.map +1 -1
- package/dist/lib/shutdown.d.ts.map +1 -1
- package/dist/lib/shutdown.js +19 -10
- package/dist/lib/shutdown.js.map +1 -1
- package/dist/lib/storage/import-export.d.ts.map +1 -1
- package/dist/lib/storage/import-export.js +15 -1
- package/dist/lib/storage/import-export.js.map +1 -1
- package/dist/lib/ui/select.d.ts.map +1 -1
- package/dist/lib/ui/select.js +5 -1
- package/dist/lib/ui/select.js.map +1 -1
- package/dist/lib/unified-settings.d.ts.map +1 -1
- package/dist/lib/unified-settings.js +69 -14
- package/dist/lib/unified-settings.js.map +1 -1
- package/package.json +1 -1
- package/scripts/codex.js +330 -65
- package/dist/lib/codex-manager/auth-commands.d.ts +0 -72
- package/dist/lib/codex-manager/auth-commands.d.ts.map +0 -1
- package/dist/lib/codex-manager/auth-commands.js +0 -643
- package/dist/lib/codex-manager/auth-commands.js.map +0 -1
- package/dist/lib/codex-manager/commands/doctor.d.ts +0 -85
- package/dist/lib/codex-manager/commands/doctor.d.ts.map +0 -1
- package/dist/lib/codex-manager/commands/doctor.js +0 -424
- package/dist/lib/codex-manager/commands/doctor.js.map +0 -1
- package/dist/lib/codex-manager/commands/fix.d.ts +0 -92
- package/dist/lib/codex-manager/commands/fix.d.ts.map +0 -1
- package/dist/lib/codex-manager/commands/fix.js +0 -347
- package/dist/lib/codex-manager/commands/fix.js.map +0 -1
- package/dist/lib/codex-manager/commands/verify-flagged.d.ts +0 -69
- package/dist/lib/codex-manager/commands/verify-flagged.d.ts.map +0 -1
- package/dist/lib/codex-manager/commands/verify-flagged.js +0 -251
- package/dist/lib/codex-manager/commands/verify-flagged.js.map +0 -1
package/scripts/codex.js
CHANGED
|
@@ -143,30 +143,163 @@ function resolveRealCodexBin() {
|
|
|
143
143
|
return resolveRealCodexBinFromEnvironment({ moduleUrl: import.meta.url });
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
|
|
146
|
+
const CHATGPT_CODEX_UNSUPPORTED_MODEL_PATTERN =
|
|
147
|
+
/model is not supported when using codex with a chatgpt account/i;
|
|
148
|
+
const NORMALIZED_UNSUPPORTED_MODEL_PATTERN =
|
|
149
|
+
/model ['"]([^'"]+)['"] is not currently available for this chatgpt account when using codex oauth/i;
|
|
150
|
+
const MODEL_ACCESS_DENIED_PATTERN =
|
|
151
|
+
/the model [`'"]([^`'"]+)[`'"] does not exist or you do not have access to it/i;
|
|
152
|
+
const DIRECT_UNSUPPORTED_MODEL_PATTERN =
|
|
153
|
+
/['"]([^'"]+)['"]\s+model is not supported when using codex with a chatgpt account/i;
|
|
154
|
+
const WRAPPER_UNSUPPORTED_MODEL_FALLBACK_CHAIN = {
|
|
155
|
+
"gpt-5.5": ["gpt-5.4"],
|
|
156
|
+
"gpt-5.5-pro": ["gpt-5.4"],
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
function canonicalizeRequestedModelName(model) {
|
|
160
|
+
if (typeof model !== "string") return "";
|
|
161
|
+
const normalizedModel = normalizeRequestedModel(model);
|
|
162
|
+
if (normalizedModel) {
|
|
163
|
+
return normalizedModel;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const stripped = stripProviderPrefix(model).trim().toLowerCase();
|
|
167
|
+
if (!stripped) {
|
|
168
|
+
return "";
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
return stripped.replace(/-(none|minimal|low|medium|high|xhigh)$/i, "");
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function extractUnsupportedModelFromOutput(output) {
|
|
175
|
+
if (typeof output !== "string" || output.length === 0) {
|
|
176
|
+
return undefined;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const directMatch = output.match(DIRECT_UNSUPPORTED_MODEL_PATTERN);
|
|
180
|
+
if (directMatch?.[1]) {
|
|
181
|
+
return canonicalizeRequestedModelName(directMatch[1]);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const normalizedMatch = output.match(NORMALIZED_UNSUPPORTED_MODEL_PATTERN);
|
|
185
|
+
if (normalizedMatch?.[1]) {
|
|
186
|
+
return canonicalizeRequestedModelName(normalizedMatch[1]);
|
|
187
|
+
}
|
|
188
|
+
const accessDeniedMatch = output.match(MODEL_ACCESS_DENIED_PATTERN);
|
|
189
|
+
if (accessDeniedMatch?.[1]) {
|
|
190
|
+
return canonicalizeRequestedModelName(accessDeniedMatch[1]);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return undefined;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function resolveUnsupportedModelRetryTarget(
|
|
197
|
+
requestedModel,
|
|
198
|
+
output,
|
|
199
|
+
attemptedModels = [],
|
|
200
|
+
) {
|
|
201
|
+
if (
|
|
202
|
+
typeof output !== "string" ||
|
|
203
|
+
output.length === 0 ||
|
|
204
|
+
(!CHATGPT_CODEX_UNSUPPORTED_MODEL_PATTERN.test(output) &&
|
|
205
|
+
!NORMALIZED_UNSUPPORTED_MODEL_PATTERN.test(output) &&
|
|
206
|
+
!MODEL_ACCESS_DENIED_PATTERN.test(output))
|
|
207
|
+
) {
|
|
208
|
+
return undefined;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const attempted = new Set(
|
|
212
|
+
attemptedModels
|
|
213
|
+
.map((model) => canonicalizeRequestedModelName(model))
|
|
214
|
+
.filter(Boolean),
|
|
215
|
+
);
|
|
216
|
+
const normalizedRequestedModel = canonicalizeRequestedModelName(requestedModel);
|
|
217
|
+
const blockedModel =
|
|
218
|
+
extractUnsupportedModelFromOutput(output) ?? normalizedRequestedModel;
|
|
219
|
+
const fallbackChain =
|
|
220
|
+
WRAPPER_UNSUPPORTED_MODEL_FALLBACK_CHAIN[blockedModel] ??
|
|
221
|
+
(normalizedRequestedModel
|
|
222
|
+
? WRAPPER_UNSUPPORTED_MODEL_FALLBACK_CHAIN[normalizedRequestedModel]
|
|
223
|
+
: undefined) ??
|
|
224
|
+
[];
|
|
225
|
+
|
|
226
|
+
for (const fallbackModel of fallbackChain) {
|
|
227
|
+
if (fallbackModel !== blockedModel && !attempted.has(fallbackModel)) {
|
|
228
|
+
return fallbackModel;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return undefined;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function replaceRequestedModel(args, nextModel) {
|
|
236
|
+
if (!nextModel) {
|
|
237
|
+
return [...args];
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const nextArgs = [...args];
|
|
241
|
+
for (let i = 0; i < nextArgs.length; i += 1) {
|
|
242
|
+
const arg = nextArgs[i];
|
|
243
|
+
if (arg === "--model" && typeof nextArgs[i + 1] === "string") {
|
|
244
|
+
nextArgs[i + 1] = nextModel;
|
|
245
|
+
return nextArgs;
|
|
246
|
+
}
|
|
247
|
+
if (typeof arg === "string" && arg.startsWith("--model=")) {
|
|
248
|
+
nextArgs[i] = `--model=${nextModel}`;
|
|
249
|
+
return nextArgs;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
return nextArgs;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function forwardToRealCodexOnce(codexBin, args, env = process.env, cleanup) {
|
|
147
257
|
return new Promise((resolve) => {
|
|
258
|
+
let settled = false;
|
|
259
|
+
let stdout = "";
|
|
260
|
+
let stderr = "";
|
|
148
261
|
const finalize = (exitCode) => {
|
|
262
|
+
if (settled) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
settled = true;
|
|
149
266
|
try {
|
|
150
267
|
cleanup?.();
|
|
151
268
|
} catch {
|
|
152
269
|
// Best-effort cleanup only.
|
|
153
270
|
}
|
|
154
|
-
resolve(
|
|
271
|
+
resolve({
|
|
272
|
+
exitCode,
|
|
273
|
+
output: `${stdout}\n${stderr}`.trim(),
|
|
274
|
+
});
|
|
155
275
|
};
|
|
156
276
|
|
|
157
277
|
const command = codexBin.launchWithNode ? process.execPath : codexBin.path;
|
|
158
278
|
const commandArgs = codexBin.launchWithNode ? [codexBin.path, ...args] : args;
|
|
159
279
|
const child = spawn(command, commandArgs, {
|
|
160
|
-
stdio: "inherit",
|
|
280
|
+
stdio: ["inherit", "pipe", "pipe"],
|
|
161
281
|
env,
|
|
162
282
|
});
|
|
163
283
|
|
|
284
|
+
child.stdout?.on("data", (chunk) => {
|
|
285
|
+
const text = typeof chunk === "string" ? chunk : chunk.toString("utf8");
|
|
286
|
+
stdout += text;
|
|
287
|
+
process.stdout.write(chunk);
|
|
288
|
+
});
|
|
289
|
+
child.stderr?.on("data", (chunk) => {
|
|
290
|
+
const text = typeof chunk === "string" ? chunk : chunk.toString("utf8");
|
|
291
|
+
stderr += text;
|
|
292
|
+
process.stderr.write(chunk);
|
|
293
|
+
});
|
|
294
|
+
|
|
164
295
|
child.once("error", (error) => {
|
|
165
|
-
|
|
296
|
+
const message = `Failed to launch real Codex CLI: ${String(error)}`;
|
|
297
|
+
stderr += `${stderr ? "\n" : ""}${message}`;
|
|
298
|
+
console.error(message);
|
|
166
299
|
finalize(1);
|
|
167
300
|
});
|
|
168
301
|
|
|
169
|
-
child.once("
|
|
302
|
+
child.once("close", (code, signal) => {
|
|
170
303
|
if (signal) {
|
|
171
304
|
const signalNumber = signal === "SIGINT" ? 130 : 1;
|
|
172
305
|
finalize(signalNumber);
|
|
@@ -177,6 +310,58 @@ function forwardToRealCodex(codexBin, args, env = process.env, cleanup) {
|
|
|
177
310
|
});
|
|
178
311
|
}
|
|
179
312
|
|
|
313
|
+
async function forwardToRealCodex(codexBin, rawArgs, baseEnv = process.env) {
|
|
314
|
+
let currentArgs = [...rawArgs];
|
|
315
|
+
let lastExitCode = 1;
|
|
316
|
+
const attemptedModels = new Set();
|
|
317
|
+
|
|
318
|
+
for (let attempt = 0; attempt < 4; attempt += 1) {
|
|
319
|
+
const requestedModel = extractRequestedModel(currentArgs);
|
|
320
|
+
if (requestedModel) {
|
|
321
|
+
attemptedModels.add(requestedModel);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
const { args: forwardArgs, requestedModel: compatibilityRequestedModel } =
|
|
325
|
+
buildForwardArgs(currentArgs);
|
|
326
|
+
const compatibility = createCompatibilityCodexHome(
|
|
327
|
+
forwardArgs,
|
|
328
|
+
compatibilityRequestedModel,
|
|
329
|
+
baseEnv,
|
|
330
|
+
);
|
|
331
|
+
const result = await forwardToRealCodexOnce(
|
|
332
|
+
codexBin,
|
|
333
|
+
compatibility.args,
|
|
334
|
+
compatibility.env,
|
|
335
|
+
compatibility.cleanup,
|
|
336
|
+
);
|
|
337
|
+
lastExitCode = result.exitCode;
|
|
338
|
+
if (result.exitCode === 0) {
|
|
339
|
+
return result.exitCode;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
const fallbackModel = resolveUnsupportedModelRetryTarget(
|
|
343
|
+
requestedModel,
|
|
344
|
+
result.output,
|
|
345
|
+
[...attemptedModels],
|
|
346
|
+
);
|
|
347
|
+
if (!fallbackModel) {
|
|
348
|
+
return result.exitCode;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
console.error(
|
|
352
|
+
`codex-multi-auth: model ${requestedModel ?? "requested model"} is unsupported on this ChatGPT Codex surface. Retrying with ${fallbackModel}.`,
|
|
353
|
+
);
|
|
354
|
+
attemptedModels.add(fallbackModel);
|
|
355
|
+
const nextArgs = replaceRequestedModel(currentArgs, fallbackModel);
|
|
356
|
+
if (JSON.stringify(nextArgs) === JSON.stringify(currentArgs)) {
|
|
357
|
+
return result.exitCode;
|
|
358
|
+
}
|
|
359
|
+
currentArgs = nextArgs;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
return lastExitCode;
|
|
363
|
+
}
|
|
364
|
+
|
|
180
365
|
function hasCliAuthCredentialsStoreOverride(args) {
|
|
181
366
|
for (let i = 0; i < args.length; i += 1) {
|
|
182
367
|
const arg = args[i];
|
|
@@ -201,12 +386,15 @@ function hasCliAuthCredentialsStoreOverride(args) {
|
|
|
201
386
|
}
|
|
202
387
|
|
|
203
388
|
// IMPORTANT: Keep this mapping in sync with
|
|
204
|
-
// `lib/request/helpers/model-map.ts` `MODEL_PROFILES
|
|
389
|
+
// `lib/request/helpers/model-map.ts` `MODEL_PROFILES`
|
|
390
|
+
// and its GPT-5 normalization helpers.
|
|
205
391
|
// This wrapper runs before the TypeScript build, so it cannot import that source.
|
|
206
392
|
const SUPPORTED_REASONING_EFFORTS_BY_MODEL = {
|
|
207
393
|
"gpt-5-codex": ["low", "medium", "high", "xhigh"],
|
|
208
394
|
"gpt-5.1-codex-max": ["medium", "high", "xhigh"],
|
|
209
395
|
"gpt-5.1-codex-mini": ["medium", "high"],
|
|
396
|
+
"gpt-5.5": ["none", "low", "medium", "high", "xhigh"],
|
|
397
|
+
"gpt-5.5-pro": ["medium", "high", "xhigh"],
|
|
210
398
|
"gpt-5.4": ["none", "low", "medium", "high", "xhigh"],
|
|
211
399
|
"gpt-5.4-pro": ["medium", "high", "xhigh"],
|
|
212
400
|
"gpt-5.2-pro": ["medium", "high", "xhigh"],
|
|
@@ -229,6 +417,39 @@ const REASONING_FALLBACKS = {
|
|
|
229
417
|
|
|
230
418
|
const KNOWN_REASONING_EFFORTS = new Set(Object.keys(REASONING_FALLBACKS));
|
|
231
419
|
const REQUESTED_MODEL_ALIASES = new Map();
|
|
420
|
+
const DEFAULT_GENERAL_GPT5_MODEL = "gpt-5.4";
|
|
421
|
+
const GPT_5_5_CANONICAL_MODEL = "gpt-5.5";
|
|
422
|
+
const GPT_5_5_PRO_CANONICAL_MODEL = "gpt-5.5-pro";
|
|
423
|
+
const GPT_5_5_RELEASE_MODEL = "gpt-5.5-20260423";
|
|
424
|
+
const GPT_5_5_PRO_RELEASE_MODEL = "gpt-5.5-pro-20260423";
|
|
425
|
+
const GENERAL_GPT5_VERSION_CATALOG = {
|
|
426
|
+
1: {
|
|
427
|
+
base: "gpt-5.1",
|
|
428
|
+
},
|
|
429
|
+
2: {
|
|
430
|
+
base: "gpt-5.2",
|
|
431
|
+
pro: "gpt-5.2-pro",
|
|
432
|
+
},
|
|
433
|
+
4: {
|
|
434
|
+
base: DEFAULT_GENERAL_GPT5_MODEL,
|
|
435
|
+
pro: "gpt-5.4-pro",
|
|
436
|
+
mini: "gpt-5-mini",
|
|
437
|
+
nano: "gpt-5-nano",
|
|
438
|
+
},
|
|
439
|
+
5: {
|
|
440
|
+
base: GPT_5_5_CANONICAL_MODEL,
|
|
441
|
+
pro: GPT_5_5_PRO_CANONICAL_MODEL,
|
|
442
|
+
mini: "gpt-5-mini",
|
|
443
|
+
nano: "gpt-5-nano",
|
|
444
|
+
},
|
|
445
|
+
};
|
|
446
|
+
const GENERAL_GPT5_STABLE_VARIANTS = GENERAL_GPT5_VERSION_CATALOG[4];
|
|
447
|
+
const GENERAL_GPT5_GENERIC_VARIANTS = {
|
|
448
|
+
base: DEFAULT_GENERAL_GPT5_MODEL,
|
|
449
|
+
pro: "gpt-5-pro",
|
|
450
|
+
mini: "gpt-5-mini",
|
|
451
|
+
nano: "gpt-5-nano",
|
|
452
|
+
};
|
|
232
453
|
|
|
233
454
|
function addRequestedModelAlias(alias, normalizedModel) {
|
|
234
455
|
REQUESTED_MODEL_ALIASES.set(alias, normalizedModel);
|
|
@@ -316,6 +537,22 @@ function renameFileWithRetry(sourcePath, destinationPath, expectedDestinationSta
|
|
|
316
537
|
}
|
|
317
538
|
|
|
318
539
|
function seedRequestedModelAliases() {
|
|
540
|
+
addRequestedModelReasoningAliases(
|
|
541
|
+
GPT_5_5_CANONICAL_MODEL,
|
|
542
|
+
GPT_5_5_CANONICAL_MODEL,
|
|
543
|
+
);
|
|
544
|
+
addRequestedModelReasoningAliases(
|
|
545
|
+
GPT_5_5_RELEASE_MODEL,
|
|
546
|
+
GPT_5_5_CANONICAL_MODEL,
|
|
547
|
+
);
|
|
548
|
+
addRequestedModelReasoningAliases(
|
|
549
|
+
GPT_5_5_PRO_CANONICAL_MODEL,
|
|
550
|
+
GPT_5_5_PRO_CANONICAL_MODEL,
|
|
551
|
+
);
|
|
552
|
+
addRequestedModelReasoningAliases(
|
|
553
|
+
GPT_5_5_PRO_RELEASE_MODEL,
|
|
554
|
+
GPT_5_5_PRO_CANONICAL_MODEL,
|
|
555
|
+
);
|
|
319
556
|
addRequestedModelReasoningAliases("gpt-5.4", "gpt-5.4");
|
|
320
557
|
addRequestedModelReasoningAliases("gpt-5.4-pro", "gpt-5.4-pro");
|
|
321
558
|
addRequestedModelReasoningAliases("gpt-5.2-pro", "gpt-5.2-pro");
|
|
@@ -350,15 +587,41 @@ function stripProviderPrefix(model) {
|
|
|
350
587
|
: model;
|
|
351
588
|
}
|
|
352
589
|
|
|
353
|
-
function
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
590
|
+
function tokenizeRequestedModel(model) {
|
|
591
|
+
return String(model ?? "")
|
|
592
|
+
.toLowerCase()
|
|
593
|
+
.split(/[^a-z0-9]+/)
|
|
594
|
+
.filter(Boolean);
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
function getGeneralGpt5CatalogForMinor(minor) {
|
|
598
|
+
switch (minor) {
|
|
599
|
+
case 1:
|
|
600
|
+
case 2:
|
|
601
|
+
case 4:
|
|
602
|
+
case 5:
|
|
603
|
+
return GENERAL_GPT5_VERSION_CATALOG[minor];
|
|
604
|
+
default:
|
|
605
|
+
return undefined;
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
function resolveGeneralGpt5CatalogVariant(catalog, variant) {
|
|
610
|
+
return catalog?.[variant] ?? catalog?.base;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
function resolveStableGeneralGpt5Variant(variant) {
|
|
614
|
+
const fallback = (
|
|
615
|
+
GENERAL_GPT5_STABLE_VARIANTS[variant] ??
|
|
616
|
+
GENERAL_GPT5_STABLE_VARIANTS.base
|
|
617
|
+
);
|
|
618
|
+
if (!fallback) {
|
|
619
|
+
throw new Error(`Stable GPT-5 fallback is missing for variant ${variant}`);
|
|
360
620
|
}
|
|
621
|
+
return fallback;
|
|
622
|
+
}
|
|
361
623
|
|
|
624
|
+
function resolveCodexRequestedModel(normalized) {
|
|
362
625
|
if (
|
|
363
626
|
normalized.includes("gpt-5.1-codex-max") ||
|
|
364
627
|
normalized.includes("gpt 5.1 codex max") ||
|
|
@@ -390,51 +653,63 @@ function normalizeRequestedModel(model) {
|
|
|
390
653
|
) {
|
|
391
654
|
return "gpt-5-codex";
|
|
392
655
|
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
if (
|
|
419
|
-
return
|
|
656
|
+
|
|
657
|
+
return "";
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
function resolveGeneralGpt5RequestedModel(stripped) {
|
|
661
|
+
const tokens = tokenizeRequestedModel(stripped);
|
|
662
|
+
const gptIndex = tokens.indexOf("gpt");
|
|
663
|
+
const isGpt5 = gptIndex !== -1 && tokens[gptIndex + 1] === "5";
|
|
664
|
+
if (!isGpt5 || tokens.includes("codex")) {
|
|
665
|
+
return "";
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
const rawMinor = tokens[gptIndex + 2];
|
|
669
|
+
const minor =
|
|
670
|
+
typeof rawMinor === "string" && /^\d+$/.test(rawMinor)
|
|
671
|
+
? Number(rawMinor)
|
|
672
|
+
: undefined;
|
|
673
|
+
const variant = tokens.includes("mini")
|
|
674
|
+
? "mini"
|
|
675
|
+
: tokens.includes("nano")
|
|
676
|
+
? "nano"
|
|
677
|
+
: tokens.includes("pro")
|
|
678
|
+
? "pro"
|
|
679
|
+
: "base";
|
|
680
|
+
|
|
681
|
+
if (minor === undefined) {
|
|
682
|
+
return GENERAL_GPT5_GENERIC_VARIANTS[variant];
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
const exactCatalog = getGeneralGpt5CatalogForMinor(minor);
|
|
686
|
+
const exactMatch = resolveGeneralGpt5CatalogVariant(exactCatalog, variant);
|
|
687
|
+
if (exactMatch) {
|
|
688
|
+
return exactMatch;
|
|
420
689
|
}
|
|
421
|
-
|
|
422
|
-
|
|
690
|
+
|
|
691
|
+
return resolveStableGeneralGpt5Variant(variant);
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
function normalizeRequestedModel(model) {
|
|
695
|
+
const stripped = stripProviderPrefix(model ?? "");
|
|
696
|
+
const normalized = stripped.trim().toLowerCase();
|
|
697
|
+
if (normalized.length === 0) return "";
|
|
698
|
+
const exactMatch = REQUESTED_MODEL_ALIASES.get(normalized);
|
|
699
|
+
if (exactMatch) {
|
|
700
|
+
return exactMatch;
|
|
423
701
|
}
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
) {
|
|
429
|
-
return "gpt-5.1";
|
|
702
|
+
|
|
703
|
+
const codexModel = resolveCodexRequestedModel(normalized);
|
|
704
|
+
if (codexModel) {
|
|
705
|
+
return codexModel;
|
|
430
706
|
}
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
) {
|
|
436
|
-
return "gpt-5";
|
|
707
|
+
|
|
708
|
+
const generalModel = resolveGeneralGpt5RequestedModel(stripped);
|
|
709
|
+
if (generalModel) {
|
|
710
|
+
return generalModel;
|
|
437
711
|
}
|
|
712
|
+
|
|
438
713
|
return "";
|
|
439
714
|
}
|
|
440
715
|
|
|
@@ -1334,18 +1609,8 @@ async function main() {
|
|
|
1334
1609
|
}
|
|
1335
1610
|
|
|
1336
1611
|
await autoSyncManagerActiveSelectionIfEnabled();
|
|
1337
|
-
const { args: forwardArgs, requestedModel } = buildForwardArgs(rawArgs);
|
|
1338
|
-
const compatibility = createCompatibilityCodexHome(
|
|
1339
|
-
forwardArgs,
|
|
1340
|
-
requestedModel,
|
|
1341
|
-
);
|
|
1342
1612
|
return withForwardedRuntimeObservability(rawArgs, () =>
|
|
1343
|
-
forwardToRealCodex(
|
|
1344
|
-
realCodexBin,
|
|
1345
|
-
compatibility.args,
|
|
1346
|
-
compatibility.env,
|
|
1347
|
-
compatibility.cleanup,
|
|
1348
|
-
),
|
|
1613
|
+
forwardToRealCodex(realCodexBin, rawArgs),
|
|
1349
1614
|
);
|
|
1350
1615
|
}
|
|
1351
1616
|
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { promptLoginMode, type ExistingAccountInfo } from "../cli.js";
|
|
2
|
-
import { type DashboardDisplaySettings } from "../dashboard-settings.js";
|
|
3
|
-
import { type QuotaCacheData } from "../quota-cache.js";
|
|
4
|
-
import { type AccountMetadataV3, type AccountStorageV3, type NamedBackupSummary } from "../storage.js";
|
|
5
|
-
import type { AccountIdSource, TokenResult } from "../types.js";
|
|
6
|
-
import { type ModelFamily } from "../prompts/codex.js";
|
|
7
|
-
type PromptTone = "accent" | "success" | "warning" | "danger" | "muted";
|
|
8
|
-
type TokenSuccess = Extract<TokenResult, {
|
|
9
|
-
type: "success";
|
|
10
|
-
}>;
|
|
11
|
-
type TokenSuccessWithAccount = TokenSuccess & {
|
|
12
|
-
accountIdOverride?: string;
|
|
13
|
-
accountIdSource?: AccountIdSource;
|
|
14
|
-
accountLabel?: string;
|
|
15
|
-
};
|
|
16
|
-
type OAuthSignInMode = "browser" | "manual" | "restore-backup" | "cancel";
|
|
17
|
-
type BackupRestoreMode = "latest" | "manual" | "back";
|
|
18
|
-
type LoginMenuResult = Awaited<ReturnType<typeof promptLoginMode>>;
|
|
19
|
-
type HealthCheckOptions = {
|
|
20
|
-
forceRefresh?: boolean;
|
|
21
|
-
liveProbe?: boolean;
|
|
22
|
-
};
|
|
23
|
-
export interface AuthCommandHelpers {
|
|
24
|
-
resolveActiveIndex: (storage: AccountStorageV3, family?: ModelFamily) => number;
|
|
25
|
-
hasUsableAccessToken: (account: AccountMetadataV3, now: number) => boolean;
|
|
26
|
-
applyTokenAccountIdentity: (account: {
|
|
27
|
-
accountId?: string;
|
|
28
|
-
accountIdSource?: AccountIdSource;
|
|
29
|
-
}, tokenAccountId: string | undefined) => boolean;
|
|
30
|
-
normalizeFailureDetail: (message: string | undefined, reason: string | undefined) => string;
|
|
31
|
-
}
|
|
32
|
-
export interface AuthLoginCommandDeps extends AuthCommandHelpers {
|
|
33
|
-
stylePromptText: (text: string, tone: PromptTone) => string;
|
|
34
|
-
runActionPanel: (title: string, stage: string, action: () => Promise<void> | void, settings?: DashboardDisplaySettings) => Promise<void>;
|
|
35
|
-
toExistingAccountInfo: (storage: AccountStorageV3, cache: QuotaCacheData, settings: DashboardDisplaySettings) => ExistingAccountInfo[];
|
|
36
|
-
countMenuQuotaRefreshTargets: (storage: AccountStorageV3, cache: QuotaCacheData, maxAgeMs: number) => number;
|
|
37
|
-
defaultMenuQuotaRefreshTtlMs: number;
|
|
38
|
-
refreshQuotaCacheForMenu: (storage: AccountStorageV3, cache: QuotaCacheData, maxAgeMs: number, onProgress?: (current: number, total: number) => void) => Promise<QuotaCacheData>;
|
|
39
|
-
clearAccountsAndReset: () => Promise<void>;
|
|
40
|
-
handleManageAction: (storage: AccountStorageV3, menuResult: LoginMenuResult) => Promise<void>;
|
|
41
|
-
promptOAuthSignInMode: (backupOption: NamedBackupSummary | null, backupDiscoveryWarning?: string | null) => Promise<OAuthSignInMode>;
|
|
42
|
-
promptBackupRestoreMode: (latestBackup: NamedBackupSummary) => Promise<BackupRestoreMode>;
|
|
43
|
-
promptManualBackupSelection: (namedBackups: NamedBackupSummary[]) => Promise<NamedBackupSummary | null>;
|
|
44
|
-
runOAuthFlow: (forceNewLogin: boolean, signInMode: Extract<OAuthSignInMode, "browser" | "manual">) => Promise<TokenResult>;
|
|
45
|
-
resolveAccountSelection: (tokens: TokenSuccess) => TokenSuccessWithAccount;
|
|
46
|
-
persistAccountPool: (tokens: TokenSuccessWithAccount[], preserveActiveIndexByFamily: boolean) => Promise<void>;
|
|
47
|
-
syncSelectionToCodex: (tokens: TokenSuccessWithAccount) => Promise<void>;
|
|
48
|
-
runHealthCheck: (options: HealthCheckOptions) => Promise<void>;
|
|
49
|
-
runForecast: (args: string[]) => Promise<number>;
|
|
50
|
-
runFix: (args: string[]) => Promise<number>;
|
|
51
|
-
runVerifyFlagged: (args: string[]) => Promise<number>;
|
|
52
|
-
log: {
|
|
53
|
-
debug: (message: string, meta?: unknown) => void;
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
export declare function persistAndSyncSelectedAccount({ storage, targetIndex, parsed, switchReason, initialSyncIdToken, preserveActiveIndexByFamily, helpers, }: {
|
|
57
|
-
storage: AccountStorageV3;
|
|
58
|
-
targetIndex: number;
|
|
59
|
-
parsed: number;
|
|
60
|
-
switchReason: "rotation" | "best" | "restore";
|
|
61
|
-
initialSyncIdToken?: string;
|
|
62
|
-
preserveActiveIndexByFamily?: boolean;
|
|
63
|
-
helpers: AuthCommandHelpers;
|
|
64
|
-
}): Promise<{
|
|
65
|
-
synced: boolean;
|
|
66
|
-
wasDisabled: boolean;
|
|
67
|
-
}>;
|
|
68
|
-
export declare function runSwitch(args: string[], helpers: AuthCommandHelpers): Promise<number>;
|
|
69
|
-
export declare function runBest(args: string[], helpers: AuthCommandHelpers): Promise<number>;
|
|
70
|
-
export declare function runAuthLogin(args: string[], deps: AuthLoginCommandDeps): Promise<number>;
|
|
71
|
-
export {};
|
|
72
|
-
//# sourceMappingURL=auth-commands.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth-commands.d.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