codex-multi-auth 1.3.2 → 2.0.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/README.md +39 -26
- package/config/README.md +3 -3
- package/dist/lib/codex-manager/commands/rotation.d.ts +22 -0
- package/dist/lib/codex-manager/commands/rotation.d.ts.map +1 -0
- package/dist/lib/codex-manager/commands/rotation.js +287 -0
- package/dist/lib/codex-manager/commands/rotation.js.map +1 -0
- package/dist/lib/codex-manager/commands/status.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/status.js +38 -7
- package/dist/lib/codex-manager/commands/status.js.map +1 -1
- package/dist/lib/codex-manager/help.d.ts.map +1 -1
- package/dist/lib/codex-manager/help.js +1 -0
- package/dist/lib/codex-manager/help.js.map +1 -1
- package/dist/lib/codex-manager.d.ts.map +1 -1
- package/dist/lib/codex-manager.js +59 -1
- package/dist/lib/codex-manager.js.map +1 -1
- package/dist/lib/config.d.ts +1 -0
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +9 -0
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/constants.d.ts +2 -0
- package/dist/lib/constants.d.ts.map +1 -1
- package/dist/lib/constants.js +2 -0
- package/dist/lib/constants.js.map +1 -1
- package/dist/lib/fs-retry.d.ts +7 -0
- package/dist/lib/fs-retry.d.ts.map +1 -0
- package/dist/lib/fs-retry.js +35 -0
- package/dist/lib/fs-retry.js.map +1 -0
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +1 -0
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/logger.d.ts.map +1 -1
- package/dist/lib/logger.js +1 -0
- package/dist/lib/logger.js.map +1 -1
- package/dist/lib/runtime/app-bind.d.ts +74 -0
- package/dist/lib/runtime/app-bind.d.ts.map +1 -0
- package/dist/lib/runtime/app-bind.js +620 -0
- package/dist/lib/runtime/app-bind.js.map +1 -0
- package/dist/lib/runtime/config-toml.d.ts +10 -0
- package/dist/lib/runtime/config-toml.d.ts.map +1 -0
- package/dist/lib/runtime/config-toml.js +128 -0
- package/dist/lib/runtime/config-toml.js.map +1 -0
- package/dist/lib/runtime/runtime-observability.d.ts +5 -0
- package/dist/lib/runtime/runtime-observability.d.ts.map +1 -1
- package/dist/lib/runtime/runtime-observability.js +5 -0
- package/dist/lib/runtime/runtime-observability.js.map +1 -1
- package/dist/lib/runtime-constants.d.ts +3 -0
- package/dist/lib/runtime-constants.d.ts.map +1 -0
- package/dist/lib/runtime-constants.js +3 -0
- package/dist/lib/runtime-constants.js.map +1 -0
- package/dist/lib/runtime-rotation-proxy.d.ts +36 -0
- package/dist/lib/runtime-rotation-proxy.d.ts.map +1 -0
- package/dist/lib/runtime-rotation-proxy.js +828 -0
- package/dist/lib/runtime-rotation-proxy.js.map +1 -0
- package/dist/lib/schemas.d.ts +1 -0
- package/dist/lib/schemas.d.ts.map +1 -1
- package/dist/lib/schemas.js +1 -0
- package/dist/lib/schemas.js.map +1 -1
- package/package.json +13 -11
- package/scripts/bench-format/codex-host.mjs +142 -73
- package/scripts/bench-format/models.mjs +17 -16
- package/scripts/benchmark-edit-formats.mjs +8 -6
- package/scripts/check-pack-budget-lib.js +49 -6
- package/scripts/codex-app-launcher.js +653 -0
- package/scripts/codex-app-router.js +322 -0
- package/scripts/codex-multi-auth.js +3 -1
- package/scripts/codex-routing.js +6 -0
- package/scripts/codex.js +3390 -1570
- package/scripts/postinstall.js +237 -0
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { exec } from "node:child_process";
|
|
2
2
|
import { promisify } from "node:util";
|
|
3
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} */
|
|
4
13
|
const execAsync = promisify(exec);
|
|
5
14
|
|
|
6
15
|
export const MAX_PACKAGE_SIZE = 8 * 1024 * 1024;
|
|
@@ -25,18 +34,35 @@ export const FORBIDDEN_PREFIXES = [
|
|
|
25
34
|
".codex/",
|
|
26
35
|
];
|
|
27
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
|
+
*/
|
|
28
49
|
export function normalizePackPath(filePath) {
|
|
29
50
|
return filePath.replaceAll("\\", "/");
|
|
30
51
|
}
|
|
31
52
|
|
|
53
|
+
/**
|
|
54
|
+
* @param {string} stdout
|
|
55
|
+
* @returns {ParsedPackMetadata}
|
|
56
|
+
*/
|
|
32
57
|
export function parsePackMetadata(stdout) {
|
|
58
|
+
/** @type {unknown} */
|
|
33
59
|
const packs = JSON.parse(stdout);
|
|
34
60
|
if (!Array.isArray(packs) || packs.length === 0) {
|
|
35
61
|
throw new Error("npm pack --dry-run --json returned no package metadata");
|
|
36
62
|
}
|
|
37
63
|
|
|
38
64
|
const pack = packs[0];
|
|
39
|
-
if (!pack || !Array.isArray(pack.files)) {
|
|
65
|
+
if (!isRecord(pack) || !Array.isArray(pack.files)) {
|
|
40
66
|
throw new Error("npm pack metadata did not include file list");
|
|
41
67
|
}
|
|
42
68
|
|
|
@@ -46,13 +72,17 @@ export function parsePackMetadata(stdout) {
|
|
|
46
72
|
}
|
|
47
73
|
|
|
48
74
|
const paths = pack.files
|
|
49
|
-
.map((file) => file
|
|
75
|
+
.map((file) => (isRecord(file) ? file.path : undefined))
|
|
50
76
|
.filter((value) => typeof value === "string")
|
|
51
77
|
.map((value) => normalizePackPath(value));
|
|
52
78
|
|
|
53
79
|
return { packageSize, paths };
|
|
54
80
|
}
|
|
55
81
|
|
|
82
|
+
/**
|
|
83
|
+
* @param {ParsedPackMetadata} metadata
|
|
84
|
+
* @returns {string}
|
|
85
|
+
*/
|
|
56
86
|
export function validatePackMetadata({ packageSize, paths }) {
|
|
57
87
|
if (packageSize > MAX_PACKAGE_SIZE) {
|
|
58
88
|
throw new Error(
|
|
@@ -83,20 +113,33 @@ export function validatePackMetadata({ packageSize, paths }) {
|
|
|
83
113
|
return `Pack budget ok: ${packageSize} bytes across ${paths.length} files`;
|
|
84
114
|
}
|
|
85
115
|
|
|
116
|
+
/**
|
|
117
|
+
* @param {RunPackBudgetDeps} [deps]
|
|
118
|
+
* @returns {Promise<string>}
|
|
119
|
+
*/
|
|
86
120
|
export async function runPackBudgetCheck(deps = {}) {
|
|
87
121
|
const npmCommand = process.platform === "win32" ? "npm.cmd" : "npm";
|
|
88
122
|
const runExec = deps.execAsync ?? execAsync;
|
|
89
123
|
const log = deps.log ?? console.log;
|
|
90
124
|
let stdout = "";
|
|
91
125
|
try {
|
|
92
|
-
|
|
126
|
+
const result = await runExec(`${npmCommand} pack --dry-run --json`, {
|
|
93
127
|
windowsHide: true,
|
|
94
128
|
maxBuffer: 10 * 1024 * 1024,
|
|
95
|
-
})
|
|
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");
|
|
96
137
|
} catch (error) {
|
|
97
138
|
const message = error instanceof Error ? error.message : String(error);
|
|
98
|
-
const stdoutText =
|
|
99
|
-
|
|
139
|
+
const stdoutText =
|
|
140
|
+
isRecord(error) && "stdout" in error ? String(error.stdout ?? "") : "";
|
|
141
|
+
const stderrText =
|
|
142
|
+
isRecord(error) && "stderr" in error ? String(error.stderr ?? "") : "";
|
|
100
143
|
throw new Error(`npm pack --dry-run --json failed via ${npmCommand}: ${message}${stdoutText ? `
|
|
101
144
|
stdout: ${stdoutText.slice(0, 500)}` : ""}${stderrText ? `
|
|
102
145
|
stderr: ${stderrText.slice(0, 500)}` : ""}`);
|