codex-multi-auth 0.1.3 → 0.1.5

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.
Files changed (86) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +7 -10
  3. package/assets/readme-hero.svg +31 -31
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +51 -13
  6. package/dist/index.js.map +1 -1
  7. package/dist/lib/auth/auth.d.ts +6 -2
  8. package/dist/lib/auth/auth.d.ts.map +1 -1
  9. package/dist/lib/auth/auth.js +34 -11
  10. package/dist/lib/auth/auth.js.map +1 -1
  11. package/dist/lib/auth/server.d.ts +1 -1
  12. package/dist/lib/auth/server.js +3 -3
  13. package/dist/lib/codex-cli/state.d.ts +9 -0
  14. package/dist/lib/codex-cli/state.d.ts.map +1 -1
  15. package/dist/lib/codex-cli/state.js +14 -0
  16. package/dist/lib/codex-cli/state.js.map +1 -1
  17. package/dist/lib/codex-cli/writer.d.ts.map +1 -1
  18. package/dist/lib/codex-cli/writer.js +106 -14
  19. package/dist/lib/codex-cli/writer.js.map +1 -1
  20. package/dist/lib/codex-manager/settings-hub.d.ts +16 -1
  21. package/dist/lib/codex-manager/settings-hub.d.ts.map +1 -1
  22. package/dist/lib/codex-manager/settings-hub.js +28 -2
  23. package/dist/lib/codex-manager/settings-hub.js.map +1 -1
  24. package/dist/lib/codex-manager.d.ts +1 -0
  25. package/dist/lib/codex-manager.d.ts.map +1 -1
  26. package/dist/lib/codex-manager.js +319 -16
  27. package/dist/lib/codex-manager.js.map +1 -1
  28. package/dist/lib/context-overflow.js +10 -10
  29. package/dist/lib/oauth-success.html +192 -260
  30. package/dist/lib/parallel-probe.d.ts +7 -0
  31. package/dist/lib/parallel-probe.d.ts.map +1 -1
  32. package/dist/lib/parallel-probe.js +37 -9
  33. package/dist/lib/parallel-probe.js.map +1 -1
  34. package/dist/lib/prompts/codex.js +2 -2
  35. package/dist/lib/refresh-queue.d.ts +4 -5
  36. package/dist/lib/refresh-queue.d.ts.map +1 -1
  37. package/dist/lib/refresh-queue.js +99 -21
  38. package/dist/lib/refresh-queue.js.map +1 -1
  39. package/dist/lib/request/fetch-helpers.d.ts +12 -4
  40. package/dist/lib/request/fetch-helpers.d.ts.map +1 -1
  41. package/dist/lib/request/fetch-helpers.js +53 -25
  42. package/dist/lib/request/fetch-helpers.js.map +1 -1
  43. package/dist/lib/request/helpers/tool-utils.d.ts.map +1 -1
  44. package/dist/lib/request/helpers/tool-utils.js +36 -6
  45. package/dist/lib/request/helpers/tool-utils.js.map +1 -1
  46. package/dist/lib/request/rate-limit-backoff.d.ts +7 -0
  47. package/dist/lib/request/rate-limit-backoff.d.ts.map +1 -1
  48. package/dist/lib/request/rate-limit-backoff.js +24 -4
  49. package/dist/lib/request/rate-limit-backoff.js.map +1 -1
  50. package/dist/lib/request/request-transformer.d.ts +10 -0
  51. package/dist/lib/request/request-transformer.d.ts.map +1 -1
  52. package/dist/lib/request/request-transformer.js +61 -37
  53. package/dist/lib/request/request-transformer.js.map +1 -1
  54. package/dist/lib/rotation.d.ts +19 -0
  55. package/dist/lib/rotation.d.ts.map +1 -1
  56. package/dist/lib/rotation.js +60 -39
  57. package/dist/lib/rotation.js.map +1 -1
  58. package/dist/lib/ui/copy.d.ts +1 -1
  59. package/dist/lib/ui/copy.js +1 -1
  60. package/dist/lib/utils.d.ts +6 -0
  61. package/dist/lib/utils.d.ts.map +1 -1
  62. package/dist/lib/utils.js +11 -0
  63. package/dist/lib/utils.js.map +1 -1
  64. package/node_modules/@codex-ai/plugin/dist/index.d.ts +1 -1
  65. package/node_modules/@codex-ai/plugin/dist/tool.d.ts +41 -41
  66. package/node_modules/@codex-ai/plugin/dist/tool.js +28 -28
  67. package/package.json +9 -5
  68. package/scripts/audit-dev-allowlist.js +186 -94
  69. package/scripts/bench-format/hashline-v2.mjs +642 -642
  70. package/scripts/bench-format/render.mjs +496 -496
  71. package/scripts/bench-format/stats.mjs +54 -54
  72. package/scripts/bench-format/tasks.mjs +151 -151
  73. package/scripts/benchmark-render-dashboard.mjs +49 -49
  74. package/scripts/benchmark-runtime-path.mjs +166 -0
  75. package/scripts/codex-multi-auth.js +1 -1
  76. package/scripts/codex.js +86 -26
  77. package/scripts/copy-oauth-success.js +42 -3
  78. package/scripts/install-codex-auth-utils.js +69 -0
  79. package/scripts/install-codex-auth.js +23 -14
  80. package/scripts/test-all-models.sh +7 -7
  81. package/scripts/test-model-matrix.js +108 -80
  82. package/scripts/validate-model-map.sh +7 -7
  83. package/vendor/codex-ai-plugin/dist/index.d.ts +1 -1
  84. package/vendor/codex-ai-plugin/dist/tool.d.ts +41 -41
  85. package/vendor/codex-ai-plugin/dist/tool.js +28 -28
  86. package/vendor/codex-ai-sdk/dist/index.d.ts +3 -3
@@ -1,9 +1,9 @@
1
- import { existsSync } from "node:fs";
2
- import { readFile, writeFile, rm, mkdir } from "node:fs/promises";
3
- import { spawnSync } from "node:child_process";
4
- import { dirname, join, resolve } from "node:path";
5
- import { fileURLToPath } from "node:url";
6
- import process from "node:process";
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import { readFile, writeFile, rm, mkdir } from "node:fs/promises";
3
+ import { spawnSync } from "node:child_process";
4
+ import { dirname, join, resolve } from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+ import process from "node:process";
7
7
 
8
8
  const scriptDir = dirname(fileURLToPath(import.meta.url));
9
9
  const repoRoot = resolve(scriptDir, "..");
@@ -13,21 +13,50 @@ const scenarioTemplates = {
13
13
  modern: join(repoRoot, "config", "codex-modern.json"),
14
14
  };
15
15
 
16
- const defaultPromptPrefix = "Reply exactly:";
17
- const modelProviderId = "openai";
18
- const pluginPackageName = "codex-multi-auth";
19
- const DEFAULT_MATRIX_TIMEOUT_MS = 120000;
20
-
21
- export function resolveCodexExecutable() {
22
- const envOverride = process.env.CODEX_BIN;
23
- if (envOverride && envOverride.trim().length > 0) {
24
- const command = envOverride.trim();
25
- return { command, shell: /\.cmd$/i.test(command) };
26
- }
27
-
28
- if (process.platform !== "win32") {
29
- return { command: "codex", shell: false };
30
- }
16
+ const pluginPackageName = "codex-multi-auth";
17
+ const DEFAULT_MATRIX_TIMEOUT_MS = 120000;
18
+
19
+ function resolveCmdScriptEntry(commandPath) {
20
+ if (!/\.cmd$/i.test(commandPath)) {
21
+ return null;
22
+ }
23
+ try {
24
+ const raw = readFileSync(commandPath, "utf8");
25
+ const match = raw.match(/"%dp0%\\([^"\r\n]+\.js)"/i);
26
+ if (!match || typeof match[1] !== "string") {
27
+ return null;
28
+ }
29
+ const relScriptPath = match[1].replace(/[\\/]+/g, "/");
30
+ const scriptPath = resolve(dirname(commandPath), relScriptPath);
31
+ return existsSync(scriptPath) ? scriptPath : null;
32
+ } catch {
33
+ return null;
34
+ }
35
+ }
36
+
37
+ function buildExecutable(command) {
38
+ const scriptEntry = resolveCmdScriptEntry(command);
39
+ if (scriptEntry) {
40
+ return {
41
+ command: process.execPath,
42
+ shell: false,
43
+ prefixArgs: [scriptEntry],
44
+ displayCommand: command,
45
+ };
46
+ }
47
+ return { command, shell: /\.cmd$/i.test(command) };
48
+ }
49
+
50
+ export function resolveCodexExecutable() {
51
+ const envOverride = process.env.CODEX_BIN;
52
+ if (envOverride && envOverride.trim().length > 0) {
53
+ const command = envOverride.trim();
54
+ return buildExecutable(command);
55
+ }
56
+
57
+ if (process.platform !== "win32") {
58
+ return { command: "codex", shell: false };
59
+ }
31
60
 
32
61
  const whereResult = spawnSync("where", ["Codex"], {
33
62
  encoding: "utf8",
@@ -42,27 +71,27 @@ export function resolveCodexExecutable() {
42
71
  return { command: "codex", shell: false };
43
72
  }
44
73
 
45
- const exactExe = candidates.find((candidate) =>
46
- /npm\\Codex\.exe$/i.test(candidate),
47
- );
48
- if (exactExe) {
49
- return { command: exactExe, shell: false };
74
+ const exactExe = candidates.find((candidate) =>
75
+ /npm\\Codex\.exe$/i.test(candidate),
76
+ );
77
+ if (exactExe) {
78
+ return { command: exactExe, shell: false };
50
79
  }
51
80
 
52
- const exactCmd = candidates.find((candidate) =>
53
- /npm\\Codex\.cmd$/i.test(candidate),
54
- );
55
- if (exactCmd) {
56
- return { command: exactCmd, shell: true };
57
- }
58
-
59
- const anyCmd = candidates.find((candidate) => /\.cmd$/i.test(candidate));
60
- if (anyCmd) {
61
- return { command: anyCmd, shell: true };
62
- }
63
-
64
- return { command: candidates[0], shell: false };
65
- }
81
+ const exactCmd = candidates.find((candidate) =>
82
+ /npm\\Codex\.cmd$/i.test(candidate),
83
+ );
84
+ if (exactCmd) {
85
+ return buildExecutable(exactCmd);
86
+ }
87
+
88
+ const anyCmd = candidates.find((candidate) => /\.cmd$/i.test(candidate));
89
+ if (anyCmd) {
90
+ return buildExecutable(anyCmd);
91
+ }
92
+
93
+ return { command: candidates[0], shell: false };
94
+ }
66
95
 
67
96
  const CodexExecutable = resolveCodexExecutable();
68
97
 
@@ -215,27 +244,28 @@ function enumerateCases(models, smoke, maxCases) {
215
244
  return selected;
216
245
  }
217
246
 
218
- function executeModelCase(caseInfo, index, port) {
219
- const token = `MODEL_MATRIX_OK_${index}`;
220
- const message = `${defaultPromptPrefix} ${token}`;
221
- const args = [
222
- "run",
223
- message,
224
- "--model",
225
- `${modelProviderId}/${caseInfo.model}`,
226
- "--port",
227
- String(port),
228
- ];
229
- if (caseInfo.variant) {
230
- args.push("--variant", caseInfo.variant);
231
- }
232
-
233
- const timeoutMs = resolveMatrixTimeoutMs();
234
- const finalized = spawnSync(CodexExecutable.command, args, {
235
- cwd: repoRoot,
236
- encoding: "utf8",
237
- windowsHide: true,
238
- shell: CodexExecutable.shell,
247
+ function executeModelCase(caseInfo, index) {
248
+ const token = `MODEL_MATRIX_OK_${index}`;
249
+ const message = token;
250
+ const args = [
251
+ "exec",
252
+ message,
253
+ "--model",
254
+ caseInfo.model,
255
+ "--json",
256
+ "--skip-git-repo-check",
257
+ ];
258
+ if (caseInfo.variant) {
259
+ args.push("-c", `model_reasoning_effort="${caseInfo.variant}"`);
260
+ }
261
+
262
+ const timeoutMs = resolveMatrixTimeoutMs();
263
+ const commandArgs = [...(CodexExecutable.prefixArgs ?? []), ...args];
264
+ const finalized = spawnSync(CodexExecutable.command, commandArgs, {
265
+ cwd: repoRoot,
266
+ encoding: "utf8",
267
+ windowsHide: true,
268
+ shell: CodexExecutable.shell,
239
269
  timeout: timeoutMs,
240
270
  killSignal: "SIGKILL",
241
271
  env: {
@@ -256,11 +286,10 @@ function executeModelCase(caseInfo, index, port) {
256
286
  };
257
287
  }
258
288
 
259
- const combinedOutput = `${finalized.stdout ?? ""}\n${finalized.stderr ?? ""}`.trim();
260
- const hasToken = combinedOutput.includes(token);
261
- const hasFatalError = /ProviderModelNotFoundError|Model not found/i.test(combinedOutput);
262
- const exitCode = finalized.status ?? 1;
263
- const ok = exitCode === 0 && hasToken && !hasFatalError;
289
+ const combinedOutput = `${finalized.stdout ?? ""}\n${finalized.stderr ?? ""}`.trim();
290
+ const hasToken = combinedOutput.includes(token);
291
+ const exitCode = finalized.status ?? 1;
292
+ const ok = exitCode === 0 && hasToken;
264
293
 
265
294
  return {
266
295
  ...caseInfo,
@@ -342,12 +371,11 @@ async function runScenario(scenario, options) {
342
371
 
343
372
  const results = [];
344
373
  for (let i = 0; i < cases.length; i += 1) {
345
- const caseInfo = cases[i];
346
- const result = executeModelCase(
347
- caseInfo,
348
- i + 1,
349
- options.portStart + i,
350
- );
374
+ const caseInfo = cases[i];
375
+ const result = executeModelCase(
376
+ caseInfo,
377
+ i + 1,
378
+ );
351
379
  results.push(result);
352
380
  const variantLabel = result.variant ? ` [variant=${result.variant}]` : "";
353
381
  if (result.ok) {
@@ -398,10 +426,10 @@ async function main() {
398
426
 
399
427
  console.log("Codex Model Matrix Audit");
400
428
  console.log(`Repo: ${repoRoot}`);
401
- console.log(`Scenarios: ${scenarios.join(", ")}`);
402
- console.log(`Mode: ${smoke ? "smoke" : "full"}`);
403
- console.log(`Plugin: ${pluginRef}`);
404
- console.log(`Codex command: ${CodexExecutable.command}`);
429
+ console.log(`Scenarios: ${scenarios.join(", ")}`);
430
+ console.log(`Mode: ${smoke ? "smoke" : "full"}`);
431
+ console.log(`Plugin: ${pluginRef}`);
432
+ console.log(`Codex command: ${CodexExecutable.displayCommand ?? CodexExecutable.command}`);
405
433
 
406
434
  const backups = await backupLocalConfigs();
407
435
  const allResults = [];
@@ -435,10 +463,10 @@ async function main() {
435
463
  generatedAt: new Date().toISOString(),
436
464
  repoRoot,
437
465
  scenarios,
438
- mode: smoke ? "smoke" : "full",
439
- plugin: pluginRef,
440
- CodexCommand: CodexExecutable.command,
441
- totals: {
466
+ mode: smoke ? "smoke" : "full",
467
+ plugin: pluginRef,
468
+ CodexCommand: CodexExecutable.displayCommand ?? CodexExecutable.command,
469
+ totals: {
442
470
  total: allResults.length,
443
471
  passed,
444
472
  failed: failed.length,
@@ -1,7 +1,7 @@
1
- #!/bin/bash
2
-
3
- set -euo pipefail
4
-
5
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6
- node "${SCRIPT_DIR}/test-model-matrix.js" --smoke "$@"
7
-
1
+ #!/bin/bash
2
+
3
+ set -euo pipefail
4
+
5
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6
+ node "${SCRIPT_DIR}/test-model-matrix.js" --smoke "$@"
7
+
@@ -1,2 +1,2 @@
1
- export type PluginInput = any;
1
+ export type PluginInput = any;
2
2
  export type Plugin = any;
@@ -1,42 +1,42 @@
1
- export interface ToolContext {
2
- [key: string]: any;
3
- directory: string;
4
- worktree: string;
5
- ask: (request: any) => Promise<any> | any;
6
- }
7
-
8
- export interface ToolDefinition<TArgs = any, TResult = any> {
9
- description?: string;
10
- args?: Record<string, any>;
11
- parameters?: unknown;
12
- execute: (args: TArgs, context: ToolContext) => Promise<TResult> | TResult;
13
- [key: string]: any;
14
- }
15
-
16
- export interface SchemaNode {
17
- optional: () => SchemaNode;
18
- describe: (_text: string) => SchemaNode;
19
- min: (_value: number) => SchemaNode;
20
- max: (_value: number) => SchemaNode;
21
- default: (_value: unknown) => SchemaNode;
22
- int: () => SchemaNode;
23
- array: (_node?: unknown) => SchemaNode;
24
- [key: string]: any;
25
- }
26
-
27
- export interface ToolFactory {
28
- <TArgs = any, TResult = any>(definition: ToolDefinition<TArgs, TResult>): ToolDefinition<TArgs, TResult>;
29
- schema: {
30
- string: () => SchemaNode;
31
- number: () => SchemaNode;
32
- boolean: () => SchemaNode;
33
- object: (shape: Record<string, unknown>) => SchemaNode;
34
- enum: (values: readonly unknown[]) => SchemaNode;
35
- literal: (value: unknown) => SchemaNode;
36
- array: (node: unknown) => SchemaNode;
37
- any: () => SchemaNode;
38
- unknown: () => SchemaNode;
39
- };
40
- }
41
-
1
+ export interface ToolContext {
2
+ [key: string]: any;
3
+ directory: string;
4
+ worktree: string;
5
+ ask: (request: any) => Promise<any> | any;
6
+ }
7
+
8
+ export interface ToolDefinition<TArgs = any, TResult = any> {
9
+ description?: string;
10
+ args?: Record<string, any>;
11
+ parameters?: unknown;
12
+ execute: (args: TArgs, context: ToolContext) => Promise<TResult> | TResult;
13
+ [key: string]: any;
14
+ }
15
+
16
+ export interface SchemaNode {
17
+ optional: () => SchemaNode;
18
+ describe: (_text: string) => SchemaNode;
19
+ min: (_value: number) => SchemaNode;
20
+ max: (_value: number) => SchemaNode;
21
+ default: (_value: unknown) => SchemaNode;
22
+ int: () => SchemaNode;
23
+ array: (_node?: unknown) => SchemaNode;
24
+ [key: string]: any;
25
+ }
26
+
27
+ export interface ToolFactory {
28
+ <TArgs = any, TResult = any>(definition: ToolDefinition<TArgs, TResult>): ToolDefinition<TArgs, TResult>;
29
+ schema: {
30
+ string: () => SchemaNode;
31
+ number: () => SchemaNode;
32
+ boolean: () => SchemaNode;
33
+ object: (shape: Record<string, unknown>) => SchemaNode;
34
+ enum: (values: readonly unknown[]) => SchemaNode;
35
+ literal: (value: unknown) => SchemaNode;
36
+ array: (node: unknown) => SchemaNode;
37
+ any: () => SchemaNode;
38
+ unknown: () => SchemaNode;
39
+ };
40
+ }
41
+
42
42
  export declare const tool: ToolFactory;
@@ -1,29 +1,29 @@
1
- const chain = {
2
- optional() { return this; },
3
- describe() { return this; },
4
- min() { return this; },
5
- max() { return this; },
6
- default() { return this; },
7
- int() { return this; },
8
- array() { return this; },
9
- };
10
-
11
- function node() {
12
- return Object.create(chain);
13
- }
14
-
15
- export function tool(definition) {
16
- return definition;
17
- }
18
-
19
- tool.schema = {
20
- string: () => node(),
21
- number: () => node(),
22
- boolean: () => node(),
23
- object: () => node(),
24
- enum: () => node(),
25
- literal: () => node(),
26
- array: () => node(),
27
- any: () => node(),
28
- unknown: () => node(),
1
+ const chain = {
2
+ optional() { return this; },
3
+ describe() { return this; },
4
+ min() { return this; },
5
+ max() { return this; },
6
+ default() { return this; },
7
+ int() { return this; },
8
+ array() { return this; },
9
+ };
10
+
11
+ function node() {
12
+ return Object.create(chain);
13
+ }
14
+
15
+ export function tool(definition) {
16
+ return definition;
17
+ }
18
+
19
+ tool.schema = {
20
+ string: () => node(),
21
+ number: () => node(),
22
+ boolean: () => node(),
23
+ object: () => node(),
24
+ enum: () => node(),
25
+ literal: () => node(),
26
+ array: () => node(),
27
+ any: () => node(),
28
+ unknown: () => node(),
29
29
  };
@@ -1,4 +1,4 @@
1
- export type Auth = any;
2
- export type Provider = any;
3
- export type Model = any;
1
+ export type Auth = any;
2
+ export type Provider = any;
3
+ export type Model = any;
4
4
  export type CodexClient = any;