@ai-nd-co/codex 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 +59 -0
- package/bin/codex.js +176 -0
- package/bin/rg +79 -0
- package/package.json +24 -0
- package/vendor/x86_64-pc-windows-msvc/codex/codex-command-runner.exe +0 -0
- package/vendor/x86_64-pc-windows-msvc/codex/codex-windows-sandbox-setup.exe +0 -0
- package/vendor/x86_64-pc-windows-msvc/codex/codex.exe +0 -0
- package/vendor/x86_64-pc-windows-msvc/path/rg.exe +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<p align="center"><code>npm i -g @openai/codex</code><br />or <code>brew install --cask codex</code></p>
|
|
2
|
+
<p align="center"><strong>Codex CLI</strong> is a coding agent from OpenAI that runs locally on your computer.
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="./.github/codex-cli-splash.png" alt="Codex CLI splash" width="80%" />
|
|
5
|
+
</p>
|
|
6
|
+
</br>
|
|
7
|
+
If you want Codex in your code editor (VS Code, Cursor, Windsurf), <a href="https://developers.openai.com/codex/ide">install in your IDE.</a>
|
|
8
|
+
</br>If you are looking for the <em>cloud-based agent</em> from OpenAI, <strong>Codex Web</strong>, go to <a href="https://chatgpt.com/codex">chatgpt.com/codex</a>.</p>
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Quickstart
|
|
13
|
+
|
|
14
|
+
### Installing and running Codex CLI
|
|
15
|
+
|
|
16
|
+
Install globally with your preferred package manager:
|
|
17
|
+
|
|
18
|
+
```shell
|
|
19
|
+
# Install using npm
|
|
20
|
+
npm install -g @openai/codex
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
```shell
|
|
24
|
+
# Install using Homebrew
|
|
25
|
+
brew install --cask codex
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Then simply run `codex` to get started.
|
|
29
|
+
|
|
30
|
+
<details>
|
|
31
|
+
<summary>You can also go to the <a href="https://github.com/openai/codex/releases/latest">latest GitHub Release</a> and download the appropriate binary for your platform.</summary>
|
|
32
|
+
|
|
33
|
+
Each GitHub Release contains many executables, but in practice, you likely want one of these:
|
|
34
|
+
|
|
35
|
+
- macOS
|
|
36
|
+
- Apple Silicon/arm64: `codex-aarch64-apple-darwin.tar.gz`
|
|
37
|
+
- x86_64 (older Mac hardware): `codex-x86_64-apple-darwin.tar.gz`
|
|
38
|
+
- Linux
|
|
39
|
+
- x86_64: `codex-x86_64-unknown-linux-musl.tar.gz`
|
|
40
|
+
- arm64: `codex-aarch64-unknown-linux-musl.tar.gz`
|
|
41
|
+
|
|
42
|
+
Each archive contains a single entry with the platform baked into the name (e.g., `codex-x86_64-unknown-linux-musl`), so you likely want to rename it to `codex` after extracting it.
|
|
43
|
+
|
|
44
|
+
</details>
|
|
45
|
+
|
|
46
|
+
### Using Codex with your ChatGPT plan
|
|
47
|
+
|
|
48
|
+
Run `codex` and select **Sign in with ChatGPT**. We recommend signing into your ChatGPT account to use Codex as part of your Plus, Pro, Team, Edu, or Enterprise plan. [Learn more about what's included in your ChatGPT plan](https://help.openai.com/en/articles/11369540-codex-in-chatgpt).
|
|
49
|
+
|
|
50
|
+
You can also use Codex with an API key, but this requires [additional setup](https://developers.openai.com/codex/auth#sign-in-with-an-api-key).
|
|
51
|
+
|
|
52
|
+
## Docs
|
|
53
|
+
|
|
54
|
+
- [**Codex Documentation**](https://developers.openai.com/codex)
|
|
55
|
+
- [**Contributing**](./docs/contributing.md)
|
|
56
|
+
- [**Installing & building**](./docs/install.md)
|
|
57
|
+
- [**Open source fund**](./docs/open-source-fund.md)
|
|
58
|
+
|
|
59
|
+
This repository is licensed under the [Apache-2.0 License](LICENSE).
|
package/bin/codex.js
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Unified entry point for the Codex CLI.
|
|
3
|
+
|
|
4
|
+
import { spawn } from "node:child_process";
|
|
5
|
+
import { existsSync } from "fs";
|
|
6
|
+
import path from "path";
|
|
7
|
+
import { fileURLToPath } from "url";
|
|
8
|
+
|
|
9
|
+
// __dirname equivalent in ESM
|
|
10
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
11
|
+
const __dirname = path.dirname(__filename);
|
|
12
|
+
|
|
13
|
+
const { platform, arch } = process;
|
|
14
|
+
|
|
15
|
+
let targetTriple = null;
|
|
16
|
+
switch (platform) {
|
|
17
|
+
case "linux":
|
|
18
|
+
case "android":
|
|
19
|
+
switch (arch) {
|
|
20
|
+
case "x64":
|
|
21
|
+
targetTriple = "x86_64-unknown-linux-musl";
|
|
22
|
+
break;
|
|
23
|
+
case "arm64":
|
|
24
|
+
targetTriple = "aarch64-unknown-linux-musl";
|
|
25
|
+
break;
|
|
26
|
+
default:
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
break;
|
|
30
|
+
case "darwin":
|
|
31
|
+
switch (arch) {
|
|
32
|
+
case "x64":
|
|
33
|
+
targetTriple = "x86_64-apple-darwin";
|
|
34
|
+
break;
|
|
35
|
+
case "arm64":
|
|
36
|
+
targetTriple = "aarch64-apple-darwin";
|
|
37
|
+
break;
|
|
38
|
+
default:
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
break;
|
|
42
|
+
case "win32":
|
|
43
|
+
switch (arch) {
|
|
44
|
+
case "x64":
|
|
45
|
+
targetTriple = "x86_64-pc-windows-msvc";
|
|
46
|
+
break;
|
|
47
|
+
case "arm64":
|
|
48
|
+
targetTriple = "aarch64-pc-windows-msvc";
|
|
49
|
+
break;
|
|
50
|
+
default:
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
break;
|
|
54
|
+
default:
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (!targetTriple) {
|
|
59
|
+
throw new Error(`Unsupported platform: ${platform} (${arch})`);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const vendorRoot = path.join(__dirname, "..", "vendor");
|
|
63
|
+
const archRoot = path.join(vendorRoot, targetTriple);
|
|
64
|
+
const codexBinaryName = process.platform === "win32" ? "codex.exe" : "codex";
|
|
65
|
+
const binaryPath = path.join(archRoot, "codex", codexBinaryName);
|
|
66
|
+
|
|
67
|
+
// Use an asynchronous spawn instead of spawnSync so that Node is able to
|
|
68
|
+
// respond to signals (e.g. Ctrl-C / SIGINT) while the native binary is
|
|
69
|
+
// executing. This allows us to forward those signals to the child process
|
|
70
|
+
// and guarantees that when either the child terminates or the parent
|
|
71
|
+
// receives a fatal signal, both processes exit in a predictable manner.
|
|
72
|
+
|
|
73
|
+
function getUpdatedPath(newDirs) {
|
|
74
|
+
const pathSep = process.platform === "win32" ? ";" : ":";
|
|
75
|
+
const existingPath = process.env.PATH || "";
|
|
76
|
+
const updatedPath = [
|
|
77
|
+
...newDirs,
|
|
78
|
+
...existingPath.split(pathSep).filter(Boolean),
|
|
79
|
+
].join(pathSep);
|
|
80
|
+
return updatedPath;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Use heuristics to detect the package manager that was used to install Codex
|
|
85
|
+
* in order to give the user a hint about how to update it.
|
|
86
|
+
*/
|
|
87
|
+
function detectPackageManager() {
|
|
88
|
+
const userAgent = process.env.npm_config_user_agent || "";
|
|
89
|
+
if (/\bbun\//.test(userAgent)) {
|
|
90
|
+
return "bun";
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const execPath = process.env.npm_execpath || "";
|
|
94
|
+
if (execPath.includes("bun")) {
|
|
95
|
+
return "bun";
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (
|
|
99
|
+
__dirname.includes(".bun/install/global") ||
|
|
100
|
+
__dirname.includes(".bun\\install\\global")
|
|
101
|
+
) {
|
|
102
|
+
return "bun";
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return userAgent ? "npm" : null;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const additionalDirs = [];
|
|
109
|
+
const pathDir = path.join(archRoot, "path");
|
|
110
|
+
if (existsSync(pathDir)) {
|
|
111
|
+
additionalDirs.push(pathDir);
|
|
112
|
+
}
|
|
113
|
+
const updatedPath = getUpdatedPath(additionalDirs);
|
|
114
|
+
|
|
115
|
+
const env = { ...process.env, PATH: updatedPath };
|
|
116
|
+
const packageManagerEnvVar =
|
|
117
|
+
detectPackageManager() === "bun"
|
|
118
|
+
? "CODEX_MANAGED_BY_BUN"
|
|
119
|
+
: "CODEX_MANAGED_BY_NPM";
|
|
120
|
+
env[packageManagerEnvVar] = "1";
|
|
121
|
+
|
|
122
|
+
const child = spawn(binaryPath, process.argv.slice(2), {
|
|
123
|
+
stdio: "inherit",
|
|
124
|
+
env,
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
child.on("error", (err) => {
|
|
128
|
+
// Typically triggered when the binary is missing or not executable.
|
|
129
|
+
// Re-throwing here will terminate the parent with a non-zero exit code
|
|
130
|
+
// while still printing a helpful stack trace.
|
|
131
|
+
// eslint-disable-next-line no-console
|
|
132
|
+
console.error(err);
|
|
133
|
+
process.exit(1);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
// Forward common termination signals to the child so that it shuts down
|
|
137
|
+
// gracefully. In the handler we temporarily disable the default behavior of
|
|
138
|
+
// exiting immediately; once the child has been signaled we simply wait for
|
|
139
|
+
// its exit event which will in turn terminate the parent (see below).
|
|
140
|
+
const forwardSignal = (signal) => {
|
|
141
|
+
if (child.killed) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
try {
|
|
145
|
+
child.kill(signal);
|
|
146
|
+
} catch {
|
|
147
|
+
/* ignore */
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
["SIGINT", "SIGTERM", "SIGHUP"].forEach((sig) => {
|
|
152
|
+
process.on(sig, () => forwardSignal(sig));
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
// When the child exits, mirror its termination reason in the parent so that
|
|
156
|
+
// shell scripts and other tooling observe the correct exit status.
|
|
157
|
+
// Wrap the lifetime of the child process in a Promise so that we can await
|
|
158
|
+
// its termination in a structured way. The Promise resolves with an object
|
|
159
|
+
// describing how the child exited: either via exit code or due to a signal.
|
|
160
|
+
const childResult = await new Promise((resolve) => {
|
|
161
|
+
child.on("exit", (code, signal) => {
|
|
162
|
+
if (signal) {
|
|
163
|
+
resolve({ type: "signal", signal });
|
|
164
|
+
} else {
|
|
165
|
+
resolve({ type: "code", exitCode: code ?? 1 });
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
if (childResult.type === "signal") {
|
|
171
|
+
// Re-emit the same signal so that the parent terminates with the expected
|
|
172
|
+
// semantics (this also sets the correct exit code of 128 + n).
|
|
173
|
+
process.kill(process.pid, childResult.signal);
|
|
174
|
+
} else {
|
|
175
|
+
process.exit(childResult.exitCode);
|
|
176
|
+
}
|
package/bin/rg
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
#!/usr/bin/env dotslash
|
|
2
|
+
|
|
3
|
+
{
|
|
4
|
+
"name": "rg",
|
|
5
|
+
"platforms": {
|
|
6
|
+
"macos-aarch64": {
|
|
7
|
+
"size": 1787248,
|
|
8
|
+
"hash": "blake3",
|
|
9
|
+
"digest": "8d9942032585ea8ee805937634238d9aee7b210069f4703c88fbe568e26fb78a",
|
|
10
|
+
"format": "tar.gz",
|
|
11
|
+
"path": "ripgrep-14.1.1-aarch64-apple-darwin/rg",
|
|
12
|
+
"providers": [
|
|
13
|
+
{
|
|
14
|
+
"url": "https://github.com/BurntSushi/ripgrep/releases/download/14.1.1/ripgrep-14.1.1-aarch64-apple-darwin.tar.gz"
|
|
15
|
+
}
|
|
16
|
+
]
|
|
17
|
+
},
|
|
18
|
+
"linux-aarch64": {
|
|
19
|
+
"size": 2047405,
|
|
20
|
+
"hash": "blake3",
|
|
21
|
+
"digest": "0b670b8fa0a3df2762af2fc82cc4932f684ca4c02dbd1260d4f3133fd4b2a515",
|
|
22
|
+
"format": "tar.gz",
|
|
23
|
+
"path": "ripgrep-14.1.1-aarch64-unknown-linux-gnu/rg",
|
|
24
|
+
"providers": [
|
|
25
|
+
{
|
|
26
|
+
"url": "https://github.com/BurntSushi/ripgrep/releases/download/14.1.1/ripgrep-14.1.1-aarch64-unknown-linux-gnu.tar.gz"
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
"macos-x86_64": {
|
|
31
|
+
"size": 2082672,
|
|
32
|
+
"hash": "blake3",
|
|
33
|
+
"digest": "e9b862fc8da3127f92791f0ff6a799504154ca9d36c98bf3e60a81c6b1f7289e",
|
|
34
|
+
"format": "tar.gz",
|
|
35
|
+
"path": "ripgrep-14.1.1-x86_64-apple-darwin/rg",
|
|
36
|
+
"providers": [
|
|
37
|
+
{
|
|
38
|
+
"url": "https://github.com/BurntSushi/ripgrep/releases/download/14.1.1/ripgrep-14.1.1-x86_64-apple-darwin.tar.gz"
|
|
39
|
+
}
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
"linux-x86_64": {
|
|
43
|
+
"size": 2566310,
|
|
44
|
+
"hash": "blake3",
|
|
45
|
+
"digest": "f73cca4e54d78c31f832c7f6e2c0b4db8b04fa3eaa747915727d570893dbee76",
|
|
46
|
+
"format": "tar.gz",
|
|
47
|
+
"path": "ripgrep-14.1.1-x86_64-unknown-linux-musl/rg",
|
|
48
|
+
"providers": [
|
|
49
|
+
{
|
|
50
|
+
"url": "https://github.com/BurntSushi/ripgrep/releases/download/14.1.1/ripgrep-14.1.1-x86_64-unknown-linux-musl.tar.gz"
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
"windows-x86_64": {
|
|
55
|
+
"size": 2058893,
|
|
56
|
+
"hash": "blake3",
|
|
57
|
+
"digest": "a8ce1a6fed4f8093ee997e57f33254e94b2cd18e26358b09db599c89882eadbd",
|
|
58
|
+
"format": "zip",
|
|
59
|
+
"path": "ripgrep-14.1.1-x86_64-pc-windows-msvc/rg.exe",
|
|
60
|
+
"providers": [
|
|
61
|
+
{
|
|
62
|
+
"url": "https://github.com/BurntSushi/ripgrep/releases/download/14.1.1/ripgrep-14.1.1-x86_64-pc-windows-msvc.zip"
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
},
|
|
66
|
+
"windows-aarch64": {
|
|
67
|
+
"size": 1667740,
|
|
68
|
+
"hash": "blake3",
|
|
69
|
+
"digest": "47b971a8c4fca1d23a4e7c19bd4d88465ebc395598458133139406d3bf85f3fa",
|
|
70
|
+
"format": "zip",
|
|
71
|
+
"path": "rg.exe",
|
|
72
|
+
"providers": [
|
|
73
|
+
{
|
|
74
|
+
"url": "https://github.com/microsoft/ripgrep-prebuilt/releases/download/v13.0.0-13/ripgrep-v13.0.0-13-aarch64-pc-windows-msvc.zip"
|
|
75
|
+
}
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ai-nd-co/codex",
|
|
3
|
+
"version": "1.0.9",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"bin": {
|
|
9
|
+
"codex": "bin/codex.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-cli"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|