@tel-research/codex-fermilink 0.151.0-fermilink.1

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.
Files changed (3) hide show
  1. package/README.md +81 -0
  2. package/bin/codex.js +248 -0
  3. package/package.json +27 -0
package/README.md ADDED
@@ -0,0 +1,81 @@
1
+ <p align="center"><strong>Codex CLI</strong> is a coding agent from OpenAI that runs locally on your computer.
2
+ <p align="center">
3
+ <img src="https://github.com/openai/codex/blob/main/.github/codex-cli-splash.png" alt="Codex CLI splash" width="80%" />
4
+ </p>
5
+ </br>
6
+ 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>
7
+ </br>If you want the desktop app experience, run <code>codex app</code> or visit <a href="https://chatgpt.com/codex?app-landing-page=true">the Codex App page</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
+ Run the following on Mac or Linux to install Codex CLI:
17
+
18
+ ```shell
19
+ curl -fsSL https://chatgpt.com/codex/install.sh | sh
20
+ ```
21
+
22
+ Run the following on Windows to install Codex CLI:
23
+
24
+ ```shell
25
+ powershell -ExecutionPolicy ByPass -c "irm https://chatgpt.com/codex/install.ps1 | iex"
26
+ ```
27
+
28
+ The standalone installers download from `https://releases.openai.com/codex` by default and fall back to GitHub Releases if a metadata or asset download is unavailable. To force GitHub Releases, set `CODEX_INSTALLER_USE_RELEASES_OPENAI_COM` to `false` (`0` and `no` are also accepted):
29
+
30
+ ```shell
31
+ curl -fsSL https://chatgpt.com/codex/install.sh | CODEX_INSTALLER_USE_RELEASES_OPENAI_COM=false sh
32
+ ```
33
+
34
+ ```powershell
35
+ $env:CODEX_INSTALLER_USE_RELEASES_OPENAI_COM='false'; irm https://chatgpt.com/codex/install.ps1 | iex
36
+ ```
37
+
38
+ Codex CLI can also be installed via the following package managers:
39
+
40
+ ```shell
41
+ # Install using npm
42
+ npm install -g @openai/codex
43
+ ```
44
+
45
+ ```shell
46
+ # Install using Homebrew
47
+ brew install --cask codex
48
+ ```
49
+
50
+ Then simply run `codex` to get started.
51
+
52
+ <details>
53
+ <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>
54
+
55
+ Each GitHub Release contains many executables, but in practice, you likely want one of these:
56
+
57
+ - macOS
58
+ - Apple Silicon/arm64: `codex-aarch64-apple-darwin.tar.gz`
59
+ - x86_64 (older Mac hardware): `codex-x86_64-apple-darwin.tar.gz`
60
+ - Linux
61
+ - x86_64: `codex-x86_64-unknown-linux-musl.tar.gz`
62
+ - arm64: `codex-aarch64-unknown-linux-musl.tar.gz`
63
+
64
+ 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.
65
+
66
+ </details>
67
+
68
+ ### Using Codex with your ChatGPT plan
69
+
70
+ Run `codex` and select **Sign in with ChatGPT**. We recommend signing into your ChatGPT account to use Codex as part of your Plus, Pro, Business, Edu, or Enterprise plan. [Learn more about what's included in your ChatGPT plan](https://help.openai.com/en/articles/11369540-codex-in-chatgpt).
71
+
72
+ 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).
73
+
74
+ ## Docs
75
+
76
+ - [**Codex Documentation**](https://developers.openai.com/codex)
77
+ - [**Contributing**](./docs/contributing.md)
78
+ - [**Installing & building**](./docs/install.md)
79
+ - [**Open source fund**](./docs/open-source-fund.md)
80
+
81
+ This repository is licensed under the [Apache-2.0 License](LICENSE).
package/bin/codex.js ADDED
@@ -0,0 +1,248 @@
1
+ #!/usr/bin/env node
2
+ // Unified entry point for the Codex CLI.
3
+
4
+ import { spawn } from "node:child_process";
5
+ import { existsSync, realpathSync } from "fs";
6
+ import { createRequire } from "node:module";
7
+ import path from "path";
8
+ import { fileURLToPath } from "url";
9
+
10
+ // __dirname equivalent in ESM
11
+ const __filename = fileURLToPath(import.meta.url);
12
+ const __dirname = path.dirname(__filename);
13
+ const require = createRequire(import.meta.url);
14
+ const codexPackageRoot = realpathSync(path.join(__dirname, ".."));
15
+
16
+ const PLATFORM_PACKAGE_BY_TARGET = {
17
+ "x86_64-unknown-linux-musl": "@tel-research/codex-fermilink-linux-x64",
18
+ "aarch64-unknown-linux-musl": "@tel-research/codex-fermilink-linux-arm64",
19
+ "x86_64-apple-darwin": "@tel-research/codex-fermilink-darwin-x64",
20
+ "aarch64-apple-darwin": "@tel-research/codex-fermilink-darwin-arm64",
21
+ "x86_64-pc-windows-msvc": "@tel-research/codex-fermilink-win32-x64",
22
+ };
23
+
24
+ const { platform, arch } = process;
25
+
26
+ let targetTriple = null;
27
+ switch (platform) {
28
+ case "linux":
29
+ case "android":
30
+ switch (arch) {
31
+ case "x64":
32
+ targetTriple = "x86_64-unknown-linux-musl";
33
+ break;
34
+ case "arm64":
35
+ targetTriple = "aarch64-unknown-linux-musl";
36
+ break;
37
+ default:
38
+ break;
39
+ }
40
+ break;
41
+ case "darwin":
42
+ switch (arch) {
43
+ case "x64":
44
+ targetTriple = "x86_64-apple-darwin";
45
+ break;
46
+ case "arm64":
47
+ targetTriple = "aarch64-apple-darwin";
48
+ break;
49
+ default:
50
+ break;
51
+ }
52
+ break;
53
+ case "win32":
54
+ switch (arch) {
55
+ case "x64":
56
+ targetTriple = "x86_64-pc-windows-msvc";
57
+ break;
58
+ case "arm64":
59
+ targetTriple = "aarch64-pc-windows-msvc";
60
+ break;
61
+ default:
62
+ break;
63
+ }
64
+ break;
65
+ default:
66
+ break;
67
+ }
68
+
69
+ if (!targetTriple) {
70
+ throw new Error(`Unsupported platform: ${platform} (${arch})`);
71
+ }
72
+
73
+ const platformPackage = PLATFORM_PACKAGE_BY_TARGET[targetTriple];
74
+ if (!platformPackage) {
75
+ throw new Error(`Unsupported target triple: ${targetTriple}`);
76
+ }
77
+
78
+ function findCodexExecutable() {
79
+ let vendorRoot;
80
+ try {
81
+ const packageJsonPath = require.resolve(`${platformPackage}/package.json`);
82
+ vendorRoot = path.join(path.dirname(packageJsonPath), "vendor");
83
+ } catch {
84
+ vendorRoot = path.join(__dirname, "..", "vendor");
85
+ }
86
+
87
+ const codexExecutable = path.join(
88
+ vendorRoot,
89
+ targetTriple,
90
+ "bin",
91
+ process.platform === "win32" ? "codex.exe" : "codex",
92
+ );
93
+ if (existsSync(codexExecutable)) {
94
+ return codexExecutable;
95
+ }
96
+
97
+ const packageManager = detectPackageManager();
98
+ const updateCommand =
99
+ packageManager === "bun"
100
+ ? "bun install -g @tel-research/codex-fermilink@latest"
101
+ : packageManager === "pnpm"
102
+ ? "pnpm add -g @tel-research/codex-fermilink@latest"
103
+ : "npm install -g @tel-research/codex-fermilink@latest";
104
+ throw new Error(
105
+ `Missing optional dependency ${platformPackage}. Reinstall Codex: ${updateCommand}`,
106
+ );
107
+ }
108
+
109
+ const binaryPath = findCodexExecutable();
110
+
111
+ // Use an asynchronous spawn instead of spawnSync so that Node is able to
112
+ // respond to signals (e.g. Ctrl-C / SIGINT) while the native binary is
113
+ // executing. This allows us to forward those signals to the child process
114
+ // and guarantees that when either the child terminates or the parent
115
+ // receives a fatal signal, both processes exit in a predictable manner.
116
+
117
+ function isPnpmOwnedCodexInstall(nodeModulesDir) {
118
+ if (!existsSync(path.join(nodeModulesDir, ".modules.yaml"))) {
119
+ return false;
120
+ }
121
+
122
+ try {
123
+ return (
124
+ realpathSync(path.join(nodeModulesDir, "@tel-research", "codex-fermilink")) ===
125
+ codexPackageRoot
126
+ );
127
+ } catch {
128
+ return false;
129
+ }
130
+ }
131
+
132
+ /**
133
+ * Use heuristics to detect the package manager that was used to install Codex
134
+ * in order to give the user a hint about how to update it.
135
+ */
136
+ function detectPackageManager() {
137
+ // pnpm's owning node_modules directory can be several parents above the
138
+ // package in isolated global layouts. Search ancestors of both the canonical
139
+ // package root and lexical entrypoint because pnpm may link either path.
140
+ const entrypointDir = path.dirname(path.resolve(process.argv[1]));
141
+ for (const startDir of new Set([codexPackageRoot, entrypointDir])) {
142
+ const filesystemRoot = path.parse(startDir).root;
143
+ for (
144
+ let currentDir = startDir;
145
+ currentDir !== filesystemRoot;
146
+ currentDir = path.dirname(currentDir)
147
+ ) {
148
+ if (isPnpmOwnedCodexInstall(path.join(currentDir, "node_modules"))) {
149
+ return "pnpm";
150
+ }
151
+ }
152
+
153
+ if (isPnpmOwnedCodexInstall(path.join(filesystemRoot, "node_modules"))) {
154
+ return "pnpm";
155
+ }
156
+ }
157
+
158
+ const userAgent = process.env.npm_config_user_agent || "";
159
+ if (/\bbun\//.test(userAgent)) {
160
+ return "bun";
161
+ }
162
+
163
+ const execPath = process.env.npm_execpath || "";
164
+ if (execPath.includes("bun")) {
165
+ return "bun";
166
+ }
167
+
168
+ if (
169
+ __dirname.includes(".bun/install/global") ||
170
+ __dirname.includes(".bun\\install\\global")
171
+ ) {
172
+ return "bun";
173
+ }
174
+
175
+ return userAgent ? "npm" : null;
176
+ }
177
+
178
+ const packageManager = detectPackageManager();
179
+ const packageManagerEnvVar =
180
+ packageManager === "bun"
181
+ ? "CODEX_MANAGED_BY_BUN"
182
+ : packageManager === "pnpm"
183
+ ? "CODEX_MANAGED_BY_PNPM"
184
+ : "CODEX_MANAGED_BY_NPM";
185
+ const env = {
186
+ ...process.env,
187
+ CODEX_MANAGED_PACKAGE_ROOT: codexPackageRoot,
188
+ };
189
+ delete env.CODEX_MANAGED_BY_NPM;
190
+ delete env.CODEX_MANAGED_BY_BUN;
191
+ delete env.CODEX_MANAGED_BY_PNPM;
192
+ env[packageManagerEnvVar] = "1";
193
+
194
+ const child = spawn(binaryPath, process.argv.slice(2), {
195
+ stdio: "inherit",
196
+ env,
197
+ });
198
+
199
+ child.on("error", (err) => {
200
+ // Typically triggered when the binary is missing or not executable.
201
+ // Re-throwing here will terminate the parent with a non-zero exit code
202
+ // while still printing a helpful stack trace.
203
+ // eslint-disable-next-line no-console
204
+ console.error(err);
205
+ process.exit(1);
206
+ });
207
+
208
+ // Forward common termination signals to the child so that it shuts down
209
+ // gracefully. In the handler we temporarily disable the default behavior of
210
+ // exiting immediately; once the child has been signaled we simply wait for
211
+ // its exit event which will in turn terminate the parent (see below).
212
+ const forwardSignal = (signal) => {
213
+ if (child.killed) {
214
+ return;
215
+ }
216
+ try {
217
+ child.kill(signal);
218
+ } catch {
219
+ /* ignore */
220
+ }
221
+ };
222
+
223
+ ["SIGINT", "SIGTERM", "SIGHUP"].forEach((sig) => {
224
+ process.on(sig, () => forwardSignal(sig));
225
+ });
226
+
227
+ // When the child exits, mirror its termination reason in the parent so that
228
+ // shell scripts and other tooling observe the correct exit status.
229
+ // Wrap the lifetime of the child process in a Promise so that we can await
230
+ // its termination in a structured way. The Promise resolves with an object
231
+ // describing how the child exited: either via exit code or due to a signal.
232
+ const childResult = await new Promise((resolve) => {
233
+ child.on("exit", (code, signal) => {
234
+ if (signal) {
235
+ resolve({ type: "signal", signal });
236
+ } else {
237
+ resolve({ type: "code", exitCode: code ?? 1 });
238
+ }
239
+ });
240
+ });
241
+
242
+ if (childResult.type === "signal") {
243
+ // Re-emit the same signal so that the parent terminates with the expected
244
+ // semantics (this also sets the correct exit code of 128 + n).
245
+ process.kill(process.pid, childResult.signal);
246
+ } else {
247
+ process.exit(childResult.exitCode);
248
+ }
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@tel-research/codex-fermilink",
3
+ "version": "0.151.0-fermilink.1",
4
+ "description": "Codex CLI (fermilink fork): OpenAI's local coding agent extended with /profile scientific agent profiles, bundled scientific subagents, and deterministic long-running job monitoring.",
5
+ "license": "Apache-2.0",
6
+ "bin": {
7
+ "codex": "bin/codex.js",
8
+ "codex-fermilink": "bin/codex.js"
9
+ },
10
+ "type": "module",
11
+ "engines": {
12
+ "node": ">=16"
13
+ },
14
+ "files": [
15
+ "bin/codex.js"
16
+ ],
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/TaoELi/codex-fermilink.git",
20
+ "directory": "codex-cli"
21
+ },
22
+ "packageManager": "pnpm@10.34.5+sha512.a4ee05f2f73658255bd6a89859c065a45c28a57daefae2c893a168ee2b73168c37b91e83e57ea67654ad03f03031746430e8bce38e362e042605fb8abc80192e",
23
+ "optionalDependencies": {
24
+ "@tel-research/codex-fermilink-darwin-x64": "npm:@tel-research/codex-fermilink@0.151.0-fermilink.1-darwin-x64",
25
+ "@tel-research/codex-fermilink-darwin-arm64": "npm:@tel-research/codex-fermilink@0.151.0-fermilink.1-darwin-arm64"
26
+ }
27
+ }