codex-multi-auth 0.1.0 → 0.1.2
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/LICENSE +1 -1
- package/README.md +223 -98
- package/assets/readme-hero.svg +31 -31
- package/config/README.md +30 -87
- package/config/{opencode-legacy.json → codex-legacy.json} +571 -571
- package/config/{opencode-modern.json → codex-modern.json} +241 -239
- package/config/{minimal-opencode.json → minimal-codex.json} +15 -13
- package/config/schema/config.schema.json +21 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -20
- package/dist/index.js.map +1 -1
- package/dist/lib/accounts.d.ts +1 -1
- package/dist/lib/accounts.d.ts.map +1 -1
- package/dist/lib/auth/auth.d.ts +1 -1
- package/dist/lib/auth/auth.js +1 -1
- package/dist/lib/cli.d.ts +1 -1
- package/dist/lib/cli.js +4 -4
- package/dist/lib/cli.js.map +1 -1
- package/dist/lib/codex-manager/settings-hub.d.ts +6 -0
- package/dist/lib/codex-manager/settings-hub.d.ts.map +1 -0
- package/dist/lib/codex-manager/settings-hub.js +1786 -0
- package/dist/lib/codex-manager/settings-hub.js.map +1 -0
- package/dist/lib/codex-manager.d.ts.map +1 -1
- package/dist/lib/codex-manager.js +5 -1637
- package/dist/lib/codex-manager.js.map +1 -1
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +20 -11
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/context-overflow.d.ts +1 -1
- package/dist/lib/context-overflow.js +11 -11
- package/dist/lib/oauth-success.html +1 -1
- package/dist/lib/prompts/codex-host-bridge.d.ts +19 -0
- package/dist/lib/prompts/codex-host-bridge.d.ts.map +1 -0
- package/dist/lib/prompts/{codex-opencode-bridge.js → codex-host-bridge.js} +143 -143
- package/dist/lib/prompts/codex-host-bridge.js.map +1 -0
- package/dist/lib/prompts/codex.d.ts +2 -2
- package/dist/lib/prompts/codex.d.ts.map +1 -1
- package/dist/lib/prompts/codex.js +3 -3
- package/dist/lib/prompts/host-codex-prompt.d.ts +25 -0
- package/dist/lib/prompts/host-codex-prompt.d.ts.map +1 -0
- package/dist/lib/prompts/{opencode-codex.js → host-codex-prompt.js} +136 -47
- package/dist/lib/prompts/host-codex-prompt.js.map +1 -0
- package/dist/lib/recovery/storage.d.ts +2 -2
- package/dist/lib/recovery/storage.js +2 -2
- package/dist/lib/recovery/types.d.ts +1 -1
- package/dist/lib/recovery/types.js +1 -1
- package/dist/lib/recovery.d.ts +1 -1
- package/dist/lib/recovery.d.ts.map +1 -1
- package/dist/lib/recovery.js +1 -4
- package/dist/lib/recovery.js.map +1 -1
- package/dist/lib/request/fetch-helpers.d.ts +3 -3
- package/dist/lib/request/fetch-helpers.d.ts.map +1 -1
- package/dist/lib/request/fetch-helpers.js +6 -2
- package/dist/lib/request/fetch-helpers.js.map +1 -1
- package/dist/lib/request/helpers/input-utils.d.ts +2 -2
- package/dist/lib/request/helpers/input-utils.d.ts.map +1 -1
- package/dist/lib/request/helpers/input-utils.js +14 -14
- package/dist/lib/request/helpers/input-utils.js.map +1 -1
- package/dist/lib/request/helpers/model-map.d.ts +2 -2
- package/dist/lib/request/helpers/model-map.js +2 -2
- package/dist/lib/request/request-transformer.d.ts +12 -12
- package/dist/lib/request/request-transformer.d.ts.map +1 -1
- package/dist/lib/request/request-transformer.js +23 -24
- package/dist/lib/request/request-transformer.js.map +1 -1
- package/dist/lib/runtime-paths.d.ts +4 -4
- package/dist/lib/runtime-paths.d.ts.map +1 -1
- package/dist/lib/runtime-paths.js +57 -13
- package/dist/lib/runtime-paths.js.map +1 -1
- package/dist/lib/storage/paths.d.ts +11 -0
- package/dist/lib/storage/paths.d.ts.map +1 -1
- package/dist/lib/storage/paths.js +167 -5
- package/dist/lib/storage/paths.js.map +1 -1
- package/dist/lib/storage.d.ts +1 -0
- package/dist/lib/storage.d.ts.map +1 -1
- package/dist/lib/storage.js +290 -81
- package/dist/lib/storage.js.map +1 -1
- package/dist/lib/tools/hashline-tools.d.ts +1 -1
- package/dist/lib/tools/hashline-tools.d.ts.map +1 -1
- package/dist/lib/tools/hashline-tools.js +1 -1
- package/dist/lib/tools/hashline-tools.js.map +1 -1
- package/dist/lib/types.d.ts +1 -1
- package/dist/lib/types.d.ts.map +1 -1
- package/dist/lib/ui/copy.d.ts +6 -6
- package/dist/lib/ui/copy.js +6 -6
- package/dist/lib/ui/copy.js.map +1 -1
- package/node_modules/@codex-ai/plugin/dist/index.d.ts +2 -0
- package/node_modules/@codex-ai/plugin/dist/index.js +2 -0
- package/node_modules/@codex-ai/plugin/dist/tool.d.ts +42 -0
- package/node_modules/@codex-ai/plugin/dist/tool.js +29 -0
- package/node_modules/@codex-ai/plugin/package.json +9 -0
- package/package.json +30 -16
- package/scripts/audit-dev-allowlist.js +128 -128
- package/scripts/bench-format/{opencode.mjs → codex-host.mjs} +206 -205
- package/scripts/bench-format/hashline-v2.mjs +642 -642
- package/scripts/bench-format/models.mjs +111 -105
- package/scripts/bench-format/render.mjs +496 -496
- package/scripts/bench-format/stats.mjs +54 -54
- package/scripts/bench-format/tasks.mjs +151 -151
- package/scripts/benchmark-edit-formats.mjs +1162 -1161
- package/scripts/benchmark-render-dashboard.mjs +49 -49
- package/scripts/codex.js +40 -2
- package/scripts/copy-oauth-success.js +37 -37
- package/scripts/install-codex-auth-utils.js +49 -0
- package/scripts/{install-opencode-codex-auth.js → install-codex-auth.js} +220 -193
- package/scripts/repo-hygiene.js +320 -0
- package/scripts/test-all-models.sh +7 -7
- package/scripts/test-model-matrix.js +475 -423
- package/scripts/validate-model-map.sh +7 -7
- package/vendor/codex-ai-plugin/dist/index.d.ts +2 -0
- package/vendor/codex-ai-plugin/dist/index.js +2 -0
- package/vendor/codex-ai-plugin/dist/tool.d.ts +42 -0
- package/vendor/codex-ai-plugin/dist/tool.js +29 -0
- package/vendor/codex-ai-plugin/package.json +9 -0
- package/vendor/codex-ai-sdk/dist/index.d.ts +4 -0
- package/vendor/codex-ai-sdk/dist/index.js +2 -0
- package/vendor/codex-ai-sdk/package.json +8 -0
- package/assets/opencode-logo-ornate-dark.svg +0 -18
- package/dist/lib/prompts/codex-opencode-bridge.d.ts +0 -19
- package/dist/lib/prompts/codex-opencode-bridge.d.ts.map +0 -1
- package/dist/lib/prompts/codex-opencode-bridge.js.map +0 -1
- package/dist/lib/prompts/opencode-codex.d.ts +0 -25
- package/dist/lib/prompts/opencode-codex.d.ts.map +0 -1
- package/dist/lib/prompts/opencode-codex.js.map +0 -1
|
@@ -1,49 +1,49 @@
|
|
|
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
|
+
#!/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
|
+
});
|
package/scripts/codex.js
CHANGED
|
@@ -6,9 +6,32 @@ import { createRequire } from "node:module";
|
|
|
6
6
|
import { dirname, join } from "node:path";
|
|
7
7
|
import process from "node:process";
|
|
8
8
|
import { fileURLToPath } from "node:url";
|
|
9
|
-
import { runCodexMultiAuthCli } from "../dist/lib/codex-manager.js";
|
|
10
9
|
import { normalizeAuthAlias, shouldHandleMultiAuthAuth } from "./codex-routing.js";
|
|
11
10
|
|
|
11
|
+
async function loadRunCodexMultiAuthCli() {
|
|
12
|
+
try {
|
|
13
|
+
const mod = await import("../dist/lib/codex-manager.js");
|
|
14
|
+
if (typeof mod.runCodexMultiAuthCli !== "function") {
|
|
15
|
+
console.error(
|
|
16
|
+
"dist/lib/codex-manager.js is missing required export: runCodexMultiAuthCli",
|
|
17
|
+
);
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return mod.runCodexMultiAuthCli;
|
|
21
|
+
} catch (error) {
|
|
22
|
+
if (error && typeof error === "object" && "code" in error && error.code === "ERR_MODULE_NOT_FOUND") {
|
|
23
|
+
console.error(
|
|
24
|
+
[
|
|
25
|
+
"codex-multi-auth auth commands require built runtime files, but dist output is missing.",
|
|
26
|
+
"Run: npm run build",
|
|
27
|
+
].join("\n"),
|
|
28
|
+
);
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
12
35
|
function resolveRealCodexBin() {
|
|
13
36
|
const override = (process.env.CODEX_MULTI_AUTH_REAL_CODEX_BIN ?? "").trim();
|
|
14
37
|
if (override.length > 0) {
|
|
@@ -90,14 +113,29 @@ function forwardToRealCodex(codexBin, args) {
|
|
|
90
113
|
});
|
|
91
114
|
}
|
|
92
115
|
|
|
116
|
+
function normalizeExitCode(value) {
|
|
117
|
+
if (typeof value === "number" && Number.isInteger(value)) {
|
|
118
|
+
return value;
|
|
119
|
+
}
|
|
120
|
+
const parsed = Number(value);
|
|
121
|
+
if (Number.isInteger(parsed)) {
|
|
122
|
+
return parsed;
|
|
123
|
+
}
|
|
124
|
+
return 1;
|
|
125
|
+
}
|
|
126
|
+
|
|
93
127
|
const rawArgs = process.argv.slice(2);
|
|
94
128
|
const normalizedArgs = normalizeAuthAlias(rawArgs);
|
|
95
129
|
const bypass = (process.env.CODEX_MULTI_AUTH_BYPASS ?? "").trim() === "1";
|
|
96
130
|
|
|
97
131
|
if (!bypass && shouldHandleMultiAuthAuth(normalizedArgs)) {
|
|
98
132
|
try {
|
|
133
|
+
const runCodexMultiAuthCli = await loadRunCodexMultiAuthCli();
|
|
134
|
+
if (!runCodexMultiAuthCli) {
|
|
135
|
+
process.exit(1);
|
|
136
|
+
}
|
|
99
137
|
const exitCode = await runCodexMultiAuthCli(normalizedArgs);
|
|
100
|
-
process.exit(exitCode);
|
|
138
|
+
process.exit(normalizeExitCode(exitCode));
|
|
101
139
|
} catch (error) {
|
|
102
140
|
console.error(
|
|
103
141
|
`codex-multi-auth runner failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import { promises as fs } from "node:fs";
|
|
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
|
-
export async function copyOAuthSuccessHtml(options = {}) {
|
|
20
|
-
const defaults = getDefaultPaths();
|
|
21
|
-
const src = options.src ?? defaults.src;
|
|
22
|
-
const dest = options.dest ?? defaults.dest;
|
|
23
|
-
|
|
24
|
-
await fs.mkdir(dirname(dest), { recursive: true });
|
|
25
|
-
await fs.copyFile(src, dest);
|
|
26
|
-
|
|
27
|
-
return { src, dest };
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const isDirectRun = (() => {
|
|
31
|
-
if (!process.argv[1]) return false;
|
|
32
|
-
return normalizePathForCompare(process.argv[1]) === normalizePathForCompare(__filename);
|
|
33
|
-
})();
|
|
34
|
-
|
|
35
|
-
if (isDirectRun) {
|
|
36
|
-
await copyOAuthSuccessHtml();
|
|
37
|
-
}
|
|
1
|
+
import { promises as fs } from "node:fs";
|
|
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
|
+
export async function copyOAuthSuccessHtml(options = {}) {
|
|
20
|
+
const defaults = getDefaultPaths();
|
|
21
|
+
const src = options.src ?? defaults.src;
|
|
22
|
+
const dest = options.dest ?? defaults.dest;
|
|
23
|
+
|
|
24
|
+
await fs.mkdir(dirname(dest), { recursive: true });
|
|
25
|
+
await fs.copyFile(src, dest);
|
|
26
|
+
|
|
27
|
+
return { src, dest };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const isDirectRun = (() => {
|
|
31
|
+
if (!process.argv[1]) return false;
|
|
32
|
+
return normalizePathForCompare(process.argv[1]) === normalizePathForCompare(__filename);
|
|
33
|
+
})();
|
|
34
|
+
|
|
35
|
+
if (isDirectRun) {
|
|
36
|
+
await copyOAuthSuccessHtml();
|
|
37
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
|
|
4
|
+
const PLUGIN_NAME = "codex-multi-auth";
|
|
5
|
+
|
|
6
|
+
export function resolveInstallPaths(
|
|
7
|
+
platform = process.platform,
|
|
8
|
+
env = process.env,
|
|
9
|
+
home = homedir(),
|
|
10
|
+
) {
|
|
11
|
+
const isWindows = platform === "win32";
|
|
12
|
+
const appData = (env.APPDATA ?? "").trim();
|
|
13
|
+
const localAppData = (env.LOCALAPPDATA ?? appData).trim();
|
|
14
|
+
const configBase = isWindows
|
|
15
|
+
? appData || join(home, "AppData", "Roaming")
|
|
16
|
+
: join(home, ".config");
|
|
17
|
+
const cacheBase = isWindows
|
|
18
|
+
? localAppData || join(home, "AppData", "Local")
|
|
19
|
+
: join(home, ".cache");
|
|
20
|
+
const configDir = join(configBase, "Codex");
|
|
21
|
+
const configPath = join(configDir, "Codex.json");
|
|
22
|
+
const cacheDir = join(cacheBase, "Codex");
|
|
23
|
+
return {
|
|
24
|
+
configDir,
|
|
25
|
+
configPath,
|
|
26
|
+
cacheDir,
|
|
27
|
+
cacheNodeModules: join(cacheDir, "node_modules", PLUGIN_NAME),
|
|
28
|
+
cacheBunLock: join(cacheDir, "bun.lock"),
|
|
29
|
+
cachePackageJson: join(cacheDir, "package.json"),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function normalizePluginList(list) {
|
|
34
|
+
const entries = Array.isArray(list) ? list.filter(Boolean) : [];
|
|
35
|
+
const filtered = entries.filter((entry) => {
|
|
36
|
+
if (typeof entry !== "string") return true;
|
|
37
|
+
return entry !== PLUGIN_NAME && !entry.startsWith(`${PLUGIN_NAME}@`);
|
|
38
|
+
});
|
|
39
|
+
const deduped = [];
|
|
40
|
+
const seen = new Set();
|
|
41
|
+
for (const entry of filtered) {
|
|
42
|
+
const key = typeof entry === "string" ? `s:${entry}` : `j:${JSON.stringify(entry)}`;
|
|
43
|
+
if (seen.has(key)) continue;
|
|
44
|
+
seen.add(key);
|
|
45
|
+
deduped.push(entry);
|
|
46
|
+
}
|
|
47
|
+
return [...deduped, PLUGIN_NAME];
|
|
48
|
+
}
|
|
49
|
+
|