@ai-nd-co/codex-responses-api-proxy 1.0.9
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
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# @openai/codex-responses-api-proxy
|
|
2
|
+
|
|
3
|
+
<p align="center"><code>npm i -g @openai/codex-responses-api-proxy</code> to install <code>codex-responses-api-proxy</code></p>
|
|
4
|
+
|
|
5
|
+
This package distributes the prebuilt [Codex Responses API proxy binary](https://github.com/openai/codex/tree/main/codex-rs/responses-api-proxy) for macOS, Linux, and Windows.
|
|
6
|
+
|
|
7
|
+
To see available options, run:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
node ./bin/codex-responses-api-proxy.js --help
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Refer to [`codex-rs/responses-api-proxy/README.md`](https://github.com/openai/codex/blob/main/codex-rs/responses-api-proxy/README.md) for detailed documentation.
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Entry point for the Codex responses API proxy binary.
|
|
3
|
+
|
|
4
|
+
import { spawn } from "node:child_process";
|
|
5
|
+
import path from "path";
|
|
6
|
+
import { fileURLToPath } from "url";
|
|
7
|
+
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = path.dirname(__filename);
|
|
10
|
+
|
|
11
|
+
function determineTargetTriple(platform, arch) {
|
|
12
|
+
switch (platform) {
|
|
13
|
+
case "linux":
|
|
14
|
+
case "android":
|
|
15
|
+
if (arch === "x64") {
|
|
16
|
+
return "x86_64-unknown-linux-musl";
|
|
17
|
+
}
|
|
18
|
+
if (arch === "arm64") {
|
|
19
|
+
return "aarch64-unknown-linux-musl";
|
|
20
|
+
}
|
|
21
|
+
break;
|
|
22
|
+
case "darwin":
|
|
23
|
+
if (arch === "x64") {
|
|
24
|
+
return "x86_64-apple-darwin";
|
|
25
|
+
}
|
|
26
|
+
if (arch === "arm64") {
|
|
27
|
+
return "aarch64-apple-darwin";
|
|
28
|
+
}
|
|
29
|
+
break;
|
|
30
|
+
case "win32":
|
|
31
|
+
if (arch === "x64") {
|
|
32
|
+
return "x86_64-pc-windows-msvc";
|
|
33
|
+
}
|
|
34
|
+
if (arch === "arm64") {
|
|
35
|
+
return "aarch64-pc-windows-msvc";
|
|
36
|
+
}
|
|
37
|
+
break;
|
|
38
|
+
default:
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const targetTriple = determineTargetTriple(process.platform, process.arch);
|
|
45
|
+
if (!targetTriple) {
|
|
46
|
+
throw new Error(
|
|
47
|
+
`Unsupported platform: ${process.platform} (${process.arch})`,
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const vendorRoot = path.join(__dirname, "..", "vendor");
|
|
52
|
+
const archRoot = path.join(vendorRoot, targetTriple);
|
|
53
|
+
const binaryBaseName = "codex-responses-api-proxy";
|
|
54
|
+
const binaryPath = path.join(
|
|
55
|
+
archRoot,
|
|
56
|
+
binaryBaseName,
|
|
57
|
+
process.platform === "win32" ? `${binaryBaseName}.exe` : binaryBaseName,
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const child = spawn(binaryPath, process.argv.slice(2), {
|
|
61
|
+
stdio: "inherit",
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
child.on("error", (err) => {
|
|
65
|
+
console.error(err);
|
|
66
|
+
process.exit(1);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
const forwardSignal = (signal) => {
|
|
70
|
+
if (!child.killed) {
|
|
71
|
+
try {
|
|
72
|
+
child.kill(signal);
|
|
73
|
+
} catch {
|
|
74
|
+
/* ignore */
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
["SIGINT", "SIGTERM", "SIGHUP"].forEach((sig) => {
|
|
80
|
+
process.on(sig, () => forwardSignal(sig));
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const childResult = await new Promise((resolve) => {
|
|
84
|
+
child.on("exit", (code, signal) => {
|
|
85
|
+
if (signal) {
|
|
86
|
+
resolve({ type: "signal", signal });
|
|
87
|
+
} else {
|
|
88
|
+
resolve({ type: "code", exitCode: code ?? 1 });
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
if (childResult.type === "signal") {
|
|
94
|
+
process.kill(process.pid, childResult.signal);
|
|
95
|
+
} else {
|
|
96
|
+
process.exit(childResult.exitCode);
|
|
97
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ai-nd-co/codex-responses-api-proxy",
|
|
3
|
+
"version": "1.0.9",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"bin": {
|
|
9
|
+
"codex-responses-api-proxy": "bin/codex-responses-api-proxy.js"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=16"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"bin",
|
|
17
|
+
"vendor"
|
|
18
|
+
],
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/ai-nd-co/codex.git",
|
|
22
|
+
"directory": "codex-rs/responses-api-proxy/npm"
|
|
23
|
+
}
|
|
24
|
+
}
|