codex-account-orchestrator 1.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/CHANGELOG.md +31 -0
- package/LICENSE +21 -0
- package/README.md +140 -0
- package/dist/account_manager.d.ts +9 -0
- package/dist/account_manager.js +103 -0
- package/dist/cli_main.d.ts +2 -0
- package/dist/cli_main.js +334 -0
- package/dist/codex_auth.d.ts +2 -0
- package/dist/codex_auth.js +29 -0
- package/dist/constants.d.ts +5 -0
- package/dist/constants.js +20 -0
- package/dist/gateway/account_pool.d.ts +25 -0
- package/dist/gateway/account_pool.js +125 -0
- package/dist/gateway/codex_config.d.ts +6 -0
- package/dist/gateway/codex_config.js +73 -0
- package/dist/gateway/codex_shim.d.ts +7 -0
- package/dist/gateway/codex_shim.js +83 -0
- package/dist/gateway/gateway_config.d.ts +14 -0
- package/dist/gateway/gateway_config.js +46 -0
- package/dist/gateway/openai_gateway.d.ts +15 -0
- package/dist/gateway/openai_gateway.js +478 -0
- package/dist/gateway/server.d.ts +4 -0
- package/dist/gateway/server.js +23 -0
- package/dist/gateway/token_utils.d.ts +18 -0
- package/dist/gateway/token_utils.js +73 -0
- package/dist/output_capture.d.ts +6 -0
- package/dist/output_capture.js +25 -0
- package/dist/paths.d.ts +3 -0
- package/dist/paths.js +23 -0
- package/dist/process_runner.d.ts +5 -0
- package/dist/process_runner.js +40 -0
- package/dist/quota_detector.d.ts +1 -0
- package/dist/quota_detector.js +7 -0
- package/dist/registry_store.d.ts +6 -0
- package/dist/registry_store.js +26 -0
- package/package.json +55 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runCodexOnce = runCodexOnce;
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
const output_capture_1 = require("./output_capture");
|
|
6
|
+
const quota_detector_1 = require("./quota_detector");
|
|
7
|
+
async function runCodexOnce(codexBin, codexArgs, accountDir, captureOutput) {
|
|
8
|
+
const capture = new output_capture_1.OutputCapture();
|
|
9
|
+
const env = { ...process.env, CODEX_HOME: accountDir };
|
|
10
|
+
const child = (0, child_process_1.spawn)(codexBin, codexArgs, {
|
|
11
|
+
env,
|
|
12
|
+
stdio: captureOutput ? ["inherit", "pipe", "pipe"] : ["inherit", "inherit", "inherit"]
|
|
13
|
+
});
|
|
14
|
+
if (captureOutput && child.stdout) {
|
|
15
|
+
child.stdout.on("data", (chunk) => {
|
|
16
|
+
process.stdout.write(chunk);
|
|
17
|
+
capture.addChunk(chunk);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
if (captureOutput && child.stderr) {
|
|
21
|
+
child.stderr.on("data", (chunk) => {
|
|
22
|
+
process.stderr.write(chunk);
|
|
23
|
+
capture.addChunk(chunk);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
const exitCode = await new Promise((resolve) => {
|
|
27
|
+
child.on("close", (code) => {
|
|
28
|
+
resolve(code ?? 1);
|
|
29
|
+
});
|
|
30
|
+
child.on("error", (error) => {
|
|
31
|
+
process.stderr.write(`Failed to start codex: ${error.message}\n`);
|
|
32
|
+
resolve(1);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
const outputText = captureOutput ? capture.getText() : "";
|
|
36
|
+
return {
|
|
37
|
+
exitCode,
|
|
38
|
+
quotaError: captureOutput ? (0, quota_detector_1.isQuotaError)(outputText) : false
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isQuotaError(outputText: string): boolean;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isQuotaError = isQuotaError;
|
|
4
|
+
const constants_1 = require("./constants");
|
|
5
|
+
function isQuotaError(outputText) {
|
|
6
|
+
return constants_1.QUOTA_ERROR_PATTERNS.some((pattern) => pattern.test(outputText));
|
|
7
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.loadRegistry = loadRegistry;
|
|
7
|
+
exports.saveRegistry = saveRegistry;
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const paths_1 = require("./paths");
|
|
10
|
+
function loadRegistry(baseDir) {
|
|
11
|
+
const registryPath = (0, paths_1.getRegistryPath)(baseDir);
|
|
12
|
+
if (!fs_1.default.existsSync(registryPath)) {
|
|
13
|
+
return { default_account: null, accounts: [] };
|
|
14
|
+
}
|
|
15
|
+
const raw = fs_1.default.readFileSync(registryPath, "utf8");
|
|
16
|
+
const parsed = JSON.parse(raw);
|
|
17
|
+
return {
|
|
18
|
+
default_account: parsed.default_account ?? null,
|
|
19
|
+
accounts: Array.isArray(parsed.accounts) ? parsed.accounts : []
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function saveRegistry(baseDir, registry) {
|
|
23
|
+
const registryPath = (0, paths_1.getRegistryPath)(baseDir);
|
|
24
|
+
const payload = JSON.stringify(registry, null, 2) + "\n";
|
|
25
|
+
fs_1.default.writeFileSync(registryPath, payload, "utf8");
|
|
26
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "codex-account-orchestrator",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Codex OAuth account fallback orchestrator with seamless gateway mode",
|
|
5
|
+
"main": "dist/cli_main.js",
|
|
6
|
+
"types": "dist/cli_main.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"codex-account-orchestrator": "dist/cli_main.js",
|
|
9
|
+
"cao": "dist/cli_main.js"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"clean": "rm -rf dist",
|
|
14
|
+
"prepublishOnly": "npm run clean && npm run build",
|
|
15
|
+
"start": "node dist/cli_main.js"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/DAWNCR0W/codex-account-orchestrator.git"
|
|
20
|
+
},
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/DAWNCR0W/codex-account-orchestrator/issues"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://github.com/DAWNCR0W/codex-account-orchestrator#readme",
|
|
25
|
+
"keywords": [
|
|
26
|
+
"codex",
|
|
27
|
+
"openai",
|
|
28
|
+
"oauth",
|
|
29
|
+
"account",
|
|
30
|
+
"fallback",
|
|
31
|
+
"orchestrator",
|
|
32
|
+
"gateway",
|
|
33
|
+
"proxy",
|
|
34
|
+
"cli"
|
|
35
|
+
],
|
|
36
|
+
"author": "DAWNCR0W",
|
|
37
|
+
"license": "MIT",
|
|
38
|
+
"type": "commonjs",
|
|
39
|
+
"files": [
|
|
40
|
+
"dist",
|
|
41
|
+
"README.md",
|
|
42
|
+
"LICENSE",
|
|
43
|
+
"CHANGELOG.md"
|
|
44
|
+
],
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=18"
|
|
47
|
+
},
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"commander": "^14.0.2"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@types/node": "^25.0.10",
|
|
53
|
+
"typescript": "^5.9.3"
|
|
54
|
+
}
|
|
55
|
+
}
|