codex-multi-auth 2.1.9 → 2.1.11

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 (57) hide show
  1. package/README.md +4 -2
  2. package/assets/codex-multi-auth-icon.svg +39 -0
  3. package/dist/lib/accounts.d.ts +2 -0
  4. package/dist/lib/accounts.d.ts.map +1 -1
  5. package/dist/lib/accounts.js +26 -2
  6. package/dist/lib/accounts.js.map +1 -1
  7. package/dist/lib/codex-manager/commands/forecast.d.ts +5 -1
  8. package/dist/lib/codex-manager/commands/forecast.d.ts.map +1 -1
  9. package/dist/lib/codex-manager/commands/forecast.js +14 -1
  10. package/dist/lib/codex-manager/commands/forecast.js.map +1 -1
  11. package/dist/lib/codex-manager/commands/report.d.ts +2 -0
  12. package/dist/lib/codex-manager/commands/report.d.ts.map +1 -1
  13. package/dist/lib/codex-manager/commands/report.js +17 -1
  14. package/dist/lib/codex-manager/commands/report.js.map +1 -1
  15. package/dist/lib/codex-manager/commands/rotation.d.ts +1 -1
  16. package/dist/lib/codex-manager/commands/rotation.d.ts.map +1 -1
  17. package/dist/lib/codex-manager/commands/rotation.js +71 -1
  18. package/dist/lib/codex-manager/commands/rotation.js.map +1 -1
  19. package/dist/lib/codex-manager/repair-commands.d.ts.map +1 -1
  20. package/dist/lib/codex-manager/repair-commands.js +35 -0
  21. package/dist/lib/codex-manager/repair-commands.js.map +1 -1
  22. package/dist/lib/codex-manager.d.ts.map +1 -1
  23. package/dist/lib/codex-manager.js +2 -0
  24. package/dist/lib/codex-manager.js.map +1 -1
  25. package/dist/lib/forecast.d.ts +9 -0
  26. package/dist/lib/forecast.d.ts.map +1 -1
  27. package/dist/lib/forecast.js +36 -0
  28. package/dist/lib/forecast.js.map +1 -1
  29. package/dist/lib/runtime/runtime-observability.d.ts +17 -0
  30. package/dist/lib/runtime/runtime-observability.d.ts.map +1 -1
  31. package/dist/lib/runtime/runtime-observability.js +48 -0
  32. package/dist/lib/runtime/runtime-observability.js.map +1 -1
  33. package/dist/lib/runtime-rotation-proxy.d.ts +1 -0
  34. package/dist/lib/runtime-rotation-proxy.d.ts.map +1 -1
  35. package/dist/lib/runtime-rotation-proxy.js +119 -20
  36. package/dist/lib/runtime-rotation-proxy.js.map +1 -1
  37. package/package.json +12 -4
  38. package/scripts/audit-dev-allowlist.js +0 -220
  39. package/scripts/bench-format/codex-host.mjs +0 -275
  40. package/scripts/bench-format/hashline-v2.mjs +0 -642
  41. package/scripts/bench-format/models.mjs +0 -110
  42. package/scripts/bench-format/render.mjs +0 -496
  43. package/scripts/bench-format/stats.mjs +0 -54
  44. package/scripts/bench-format/tasks.mjs +0 -151
  45. package/scripts/benchmark-edit-formats.mjs +0 -1164
  46. package/scripts/benchmark-render-dashboard.mjs +0 -49
  47. package/scripts/benchmark-runtime-path.mjs +0 -166
  48. package/scripts/check-pack-budget-lib.js +0 -157
  49. package/scripts/check-pack-budget.mjs +0 -10
  50. package/scripts/copy-oauth-success.js +0 -76
  51. package/scripts/install-codex-auth.js +0 -258
  52. package/scripts/repo-hygiene.js +0 -320
  53. package/scripts/test-all-models.sh +0 -7
  54. package/scripts/test-model-matrix.js +0 -687
  55. package/scripts/update-vendor-provenance.mjs +0 -96
  56. package/scripts/validate-model-map.sh +0 -7
  57. package/scripts/verify-vendor-provenance.mjs +0 -53
@@ -1,49 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { readFile, writeFile } from "node:fs/promises";
4
- import { resolve } from "node:path";
5
- import process from "node:process";
6
- import { renderDashboardHtml } from "./bench-format/render.mjs";
7
-
8
- function usage() {
9
- console.log([
10
- "Usage: node scripts/benchmark-render-dashboard.mjs --input=PATH [--output=PATH]",
11
- "",
12
- "Options:",
13
- " --input=PATH Path to benchmark summary.json",
14
- " --output=PATH Output HTML path (default: alongside input as dashboard.html)",
15
- ].join("\n"));
16
- }
17
-
18
- function argValue(args, name) {
19
- const prefix = `${name}=`;
20
- const match = args.find((arg) => arg.startsWith(prefix));
21
- return match ? match.slice(prefix.length) : undefined;
22
- }
23
-
24
- async function main() {
25
- const args = process.argv.slice(2);
26
- if (args.includes("--help") || args.includes("-h")) {
27
- usage();
28
- return;
29
- }
30
-
31
- const inputRaw = argValue(args, "--input");
32
- if (!inputRaw) {
33
- usage();
34
- process.exitCode = 1;
35
- return;
36
- }
37
- const inputPath = resolve(inputRaw);
38
- const outputPath = resolve(argValue(args, "--output") ?? inputPath.replace(/summary\.json$/i, "dashboard.html"));
39
-
40
- const summary = JSON.parse(await readFile(inputPath, "utf8"));
41
- const html = renderDashboardHtml(summary);
42
- await writeFile(outputPath, html, "utf8");
43
- console.log(`Dashboard written: ${outputPath}`);
44
- }
45
-
46
- main().catch((error) => {
47
- console.error(`Render failed: ${error instanceof Error ? error.message : String(error)}`);
48
- process.exit(1);
49
- });
@@ -1,166 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { mkdir, writeFile } from "node:fs/promises";
4
- import { performance } from "node:perf_hooks";
5
- import process from "node:process";
6
- import { dirname, resolve } from "node:path";
7
- import { filterInput } from "../dist/lib/request/request-transformer.js";
8
- import { cleanupToolDefinitions } from "../dist/lib/request/helpers/tool-utils.js";
9
- import { AccountManager } from "../dist/lib/accounts.js";
10
-
11
- function argValue(args, name) {
12
- const prefix = `${name}=`;
13
- const match = args.find((arg) => arg.startsWith(prefix));
14
- return match ? match.slice(prefix.length) : undefined;
15
- }
16
-
17
- function parsePositiveInt(value, fallback) {
18
- if (!value) return fallback;
19
- const parsed = Number.parseInt(value, 10);
20
- if (!Number.isFinite(parsed) || parsed <= 0) return fallback;
21
- return parsed;
22
- }
23
-
24
- function benchmarkCase(name, iterations, fn) {
25
- for (let i = 0; i < 5; i += 1) {
26
- fn();
27
- }
28
- const start = performance.now();
29
- for (let i = 0; i < iterations; i += 1) {
30
- fn();
31
- }
32
- const end = performance.now();
33
- return {
34
- name,
35
- iterations,
36
- avgMs: Number(((end - start) / iterations).toFixed(6)),
37
- };
38
- }
39
-
40
- function buildInputItems(size) {
41
- const items = [];
42
- for (let i = 0; i < size; i += 1) {
43
- items.push({
44
- type: "message",
45
- role: i % 2 === 0 ? "user" : "assistant",
46
- id: `msg_${i}`,
47
- content: [{ type: "input_text", text: `payload-${i}` }],
48
- });
49
- if (i % 40 === 0) {
50
- items.push({ type: "item_reference", id: `ref_${i}` });
51
- }
52
- }
53
- return items;
54
- }
55
-
56
- function buildTools(toolCount, propertyCount) {
57
- const tools = [];
58
- for (let i = 0; i < toolCount; i += 1) {
59
- const properties = {};
60
- const required = [];
61
- for (let j = 0; j < propertyCount; j += 1) {
62
- const key = `field_${j}`;
63
- properties[key] = { type: ["string", "null"], description: `property-${j}` };
64
- required.push(key);
65
- }
66
- required.push("ghost_field");
67
- tools.push({
68
- type: "function",
69
- function: {
70
- name: `tool_${i}`,
71
- parameters: {
72
- type: "object",
73
- properties,
74
- required,
75
- additionalProperties: false,
76
- },
77
- },
78
- });
79
- }
80
- return tools;
81
- }
82
-
83
- function buildManager(accountCount) {
84
- const now = Date.now();
85
- const accounts = [];
86
- for (let i = 0; i < accountCount; i += 1) {
87
- accounts.push({
88
- refreshToken: `rt_${i}`,
89
- accessToken: `at_${i}`,
90
- expiresAt: now + 3_600_000,
91
- accountId: `acct_${i}`,
92
- email: `user${i}@example.com`,
93
- enabled: true,
94
- addedAt: now,
95
- lastUsed: 0,
96
- rateLimitResetTimes: {},
97
- });
98
- }
99
- return new AccountManager(undefined, {
100
- version: 3,
101
- accounts,
102
- activeIndex: 0,
103
- activeIndexByFamily: {},
104
- });
105
- }
106
-
107
- function run() {
108
- const args = process.argv.slice(2);
109
- const iterations = parsePositiveInt(argValue(args, "--iterations"), 30);
110
- const outputPath = argValue(args, "--output");
111
-
112
- const inputSmall = buildInputItems(400);
113
- const inputLarge = buildInputItems(2000);
114
- const toolsMedium = buildTools(40, 12);
115
- const toolsLarge = buildTools(140, 25);
116
-
117
- const results = [
118
- benchmarkCase("filterInput_small", iterations, () => {
119
- const out = filterInput(inputSmall);
120
- if (!Array.isArray(out)) throw new Error("filterInput_small failed");
121
- }),
122
- benchmarkCase("filterInput_large", iterations, () => {
123
- const out = filterInput(inputLarge);
124
- if (!Array.isArray(out)) throw new Error("filterInput_large failed");
125
- }),
126
- benchmarkCase("cleanupToolDefinitions_medium", iterations, () => {
127
- const out = cleanupToolDefinitions(toolsMedium);
128
- if (!Array.isArray(out)) throw new Error("cleanupToolDefinitions_medium failed");
129
- }),
130
- benchmarkCase("cleanupToolDefinitions_large", iterations, () => {
131
- const out = cleanupToolDefinitions(toolsLarge);
132
- if (!Array.isArray(out)) throw new Error("cleanupToolDefinitions_large failed");
133
- }),
134
- benchmarkCase("accountHybridSelection_200", iterations, () => {
135
- const manager = buildManager(200);
136
- for (let i = 0; i < 200; i += 1) {
137
- manager.getCurrentOrNextForFamilyHybrid("codex", "gpt-5-codex", { pidOffsetEnabled: false });
138
- }
139
- }),
140
- ];
141
-
142
- const payload = {
143
- generatedAt: new Date().toISOString(),
144
- node: process.version,
145
- iterations,
146
- results,
147
- };
148
-
149
- if (outputPath) {
150
- const resolved = resolve(outputPath);
151
- return mkdir(dirname(resolved), { recursive: true }).then(() =>
152
- writeFile(resolved, `${JSON.stringify(payload, null, 2)}\n`, "utf8"),
153
- ).then(() => {
154
- console.log(`Runtime benchmark written: ${resolved}`);
155
- console.log(JSON.stringify(payload, null, 2));
156
- });
157
- }
158
-
159
- console.log(JSON.stringify(payload, null, 2));
160
- return Promise.resolve();
161
- }
162
-
163
- run().catch((error) => {
164
- console.error(`Runtime benchmark failed: ${error instanceof Error ? error.message : String(error)}`);
165
- process.exit(1);
166
- });
@@ -1,157 +0,0 @@
1
- import { exec } from "node:child_process";
2
- import { promisify } from "node:util";
3
-
4
- /**
5
- * @typedef {{ packageSize: number, paths: string[] }} ParsedPackMetadata
6
- * @typedef {{ windowsHide: boolean, maxBuffer: number }} ExecOptions
7
- * @typedef {{ stdout: string | Buffer, stderr?: string | Buffer }} ExecResult
8
- * @typedef {(command: string, options: ExecOptions) => Promise<ExecResult>} ExecAsync
9
- * @typedef {{ execAsync?: ExecAsync, log?: (message: string) => void }} RunPackBudgetDeps
10
- */
11
-
12
- /** @type {ExecAsync} */
13
- const execAsync = promisify(exec);
14
-
15
- export const MAX_PACKAGE_SIZE = 8 * 1024 * 1024;
16
- export const REQUIRED_PREFIXES = [
17
- "dist/",
18
- "assets/",
19
- "config/",
20
- "scripts/",
21
- "vendor/codex-ai-plugin/",
22
- "vendor/codex-ai-sdk/",
23
- "README.md",
24
- "LICENSE",
25
- ];
26
-
27
- export const FORBIDDEN_PREFIXES = [
28
- ".github/",
29
- "test/",
30
- "src/",
31
- "lib/",
32
- "tmp/",
33
- ".tmp/",
34
- ".codex/",
35
- ];
36
-
37
- /**
38
- * @param {unknown} value
39
- * @returns {value is Record<string, unknown>}
40
- */
41
- function isRecord(value) {
42
- return typeof value === "object" && value !== null && !Array.isArray(value);
43
- }
44
-
45
- /**
46
- * @param {string} filePath
47
- * @returns {string}
48
- */
49
- export function normalizePackPath(filePath) {
50
- return filePath.replaceAll("\\", "/");
51
- }
52
-
53
- /**
54
- * @param {string} stdout
55
- * @returns {ParsedPackMetadata}
56
- */
57
- export function parsePackMetadata(stdout) {
58
- /** @type {unknown} */
59
- const packs = JSON.parse(stdout);
60
- if (!Array.isArray(packs) || packs.length === 0) {
61
- throw new Error("npm pack --dry-run --json returned no package metadata");
62
- }
63
-
64
- const pack = packs[0];
65
- if (!isRecord(pack) || !Array.isArray(pack.files)) {
66
- throw new Error("npm pack metadata did not include file list");
67
- }
68
-
69
- const packageSize = typeof pack.size === "number" ? pack.size : 0;
70
- if (packageSize <= 0) {
71
- throw new Error("npm pack metadata did not include a valid package size");
72
- }
73
-
74
- const paths = pack.files
75
- .map((file) => (isRecord(file) ? file.path : undefined))
76
- .filter((value) => typeof value === "string")
77
- .map((value) => normalizePackPath(value));
78
-
79
- return { packageSize, paths };
80
- }
81
-
82
- /**
83
- * @param {ParsedPackMetadata} metadata
84
- * @returns {string}
85
- */
86
- export function validatePackMetadata({ packageSize, paths }) {
87
- if (packageSize > MAX_PACKAGE_SIZE) {
88
- throw new Error(
89
- `Packed tarball is too large: ${packageSize} bytes (max ${MAX_PACKAGE_SIZE})`,
90
- );
91
- }
92
-
93
- for (const forbidden of FORBIDDEN_PREFIXES) {
94
- const leaked = paths.find(
95
- (path) => path === forbidden || path.startsWith(forbidden),
96
- );
97
- if (leaked) {
98
- throw new Error(`Forbidden file leaked into package: ${leaked}`);
99
- }
100
- }
101
-
102
- for (const required of REQUIRED_PREFIXES) {
103
- const present = paths.some(
104
- (path) => path === required || path.startsWith(required),
105
- );
106
- if (!present) {
107
- throw new Error(
108
- `Required package content missing from npm pack output: ${required}`,
109
- );
110
- }
111
- }
112
-
113
- return `Pack budget ok: ${packageSize} bytes across ${paths.length} files`;
114
- }
115
-
116
- /**
117
- * @param {RunPackBudgetDeps} [deps]
118
- * @returns {Promise<string>}
119
- */
120
- export async function runPackBudgetCheck(deps = {}) {
121
- const npmCommand = process.platform === "win32" ? "npm.cmd" : "npm";
122
- const runExec = deps.execAsync ?? execAsync;
123
- const log = deps.log ?? console.log;
124
- let stdout = "";
125
- try {
126
- const result = await runExec(`${npmCommand} pack --dry-run --json`, {
127
- windowsHide: true,
128
- maxBuffer: 10 * 1024 * 1024,
129
- });
130
- if (result.stdout === null || result.stdout === undefined) {
131
- throw new Error("npm pack --dry-run --json returned no stdout");
132
- }
133
- stdout =
134
- typeof result.stdout === "string"
135
- ? result.stdout
136
- : result.stdout.toString("utf8");
137
- } catch (error) {
138
- const message = error instanceof Error ? error.message : String(error);
139
- const stdoutText =
140
- isRecord(error) && "stdout" in error ? String(error.stdout ?? "") : "";
141
- const stderrText =
142
- isRecord(error) && "stderr" in error ? String(error.stderr ?? "") : "";
143
- throw new Error(`npm pack --dry-run --json failed via ${npmCommand}: ${message}${stdoutText ? `
144
- stdout: ${stdoutText.slice(0, 500)}` : ""}${stderrText ? `
145
- stderr: ${stderrText.slice(0, 500)}` : ""}`);
146
- }
147
- let summary;
148
- try {
149
- summary = validatePackMetadata(parsePackMetadata(stdout));
150
- } catch (error) {
151
- const message = error instanceof Error ? error.message : String(error);
152
- throw new Error(`Failed to validate npm pack output: ${message}
153
- stdout: ${stdout.slice(0, 500)}`);
154
- }
155
- log(summary);
156
- return summary;
157
- }
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env node
2
- import { resolve } from "node:path";
3
- import { fileURLToPath } from "node:url";
4
- import { runPackBudgetCheck } from "./check-pack-budget-lib.js";
5
-
6
- export { runPackBudgetCheck } from "./check-pack-budget-lib.js";
7
-
8
- if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
9
- await runPackBudgetCheck();
10
- }
@@ -1,76 +0,0 @@
1
- import * as fs from "node:fs/promises";
2
- import { dirname, join, resolve } from "node:path";
3
- import { fileURLToPath } from "node:url";
4
-
5
- const __filename = fileURLToPath(import.meta.url);
6
- const __dirname = dirname(__filename);
7
-
8
- function normalizePathForCompare(path) {
9
- const resolved = resolve(path);
10
- return process.platform === "win32" ? resolved.toLowerCase() : resolved;
11
- }
12
-
13
- function getDefaultPaths() {
14
- const src = join(__dirname, "..", "lib", "oauth-success.html");
15
- const dest = join(__dirname, "..", "dist", "lib", "oauth-success.html");
16
- return { src, dest };
17
- }
18
-
19
- /**
20
- * Copy a file and retry automatically while the destination is temporarily locked.
21
- * @param {string} src absolute path to the source HTML file
22
- * @param {string} dest absolute path to the destination HTML file
23
- * @param {{ maxAttempts?: number, backoffMs?: number }} options retry configuration
24
- */
25
- async function copyWithRetry(
26
- src,
27
- dest,
28
- { maxAttempts = 3, backoffMs = 50 } = {},
29
- ) {
30
- const retryableCodes = new Set(["EBUSY", "EPERM", "EACCES"]);
31
- let attempt = 0;
32
- for (;;) {
33
- try {
34
- await fs.copyFile(src, dest);
35
- return;
36
- } catch (err) {
37
- const code = err && typeof err === "object" && "code" in err ? err.code : undefined;
38
- const isRetryable = typeof code === "string" && retryableCodes.has(code);
39
- if (!isRetryable || attempt >= maxAttempts - 1) {
40
- throw err;
41
- }
42
- attempt += 1;
43
- const delayMs = backoffMs * (2 ** (attempt - 1));
44
- await new Promise((resolve) => {
45
- setTimeout(resolve, delayMs);
46
- });
47
- }
48
- }
49
- }
50
-
51
- /**
52
- * Copy the OAuth success HTML into dist/, ensuring safe directory creation and retries.
53
- * @param {{ src?: string, dest?: string }} options optional override paths for testing
54
- */
55
- export async function copyOAuthSuccessHtml(options = {}) {
56
- const defaults = getDefaultPaths();
57
- const src = options.src ?? defaults.src;
58
- const dest = options.dest ?? defaults.dest;
59
-
60
- await fs.mkdir(dirname(dest), { recursive: true });
61
- await copyWithRetry(src, dest);
62
-
63
- return { src, dest };
64
- }
65
-
66
- const isDirectRun = (() => {
67
- if (!process.argv[1]) return false;
68
- return (
69
- normalizePathForCompare(process.argv[1]) ===
70
- normalizePathForCompare(__filename)
71
- );
72
- })();
73
-
74
- if (isDirectRun) {
75
- await copyOAuthSuccessHtml();
76
- }