@openai/codex 0.16.0 → 0.19.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/README.md CHANGED
@@ -1,11 +1,12 @@
1
1
  <h1 align="center">OpenAI Codex CLI</h1>
2
- <p align="center">Lightweight coding agent that runs in your terminal</p>
3
2
 
4
3
  <p align="center"><code>npm i -g @openai/codex</code><br />or <code>brew install codex</code></p>
5
4
 
6
- This is the home of the **Codex CLI**, which is a coding agent from OpenAI that runs locally on your computer. If you are looking for the _cloud-based agent_ from OpenAI, **Codex [Web]**, see <https://chatgpt.com/codex>.
5
+ <p align="center"><strong>Codex CLI</strong> is a coding agent from OpenAI that runs locally on your computer.</br>If you are looking for the <em>cloud-based agent</em> from OpenAI, <strong>Codex Web</strong>, see <a href="https://chatgpt.com/codex">chatgpt.com/codex</a>.</p>
7
6
 
8
- <!-- ![Codex demo GIF using: codex "explain this codebase to me"](./.github/demo.gif) -->
7
+ <p align="center">
8
+ <img src="./.github/codex-cli-splash.png" alt="Codex CLI splash" width="50%" />
9
+ </p>
9
10
 
10
11
  ---
11
12
 
@@ -14,22 +15,27 @@ This is the home of the **Codex CLI**, which is a coding agent from OpenAI that
14
15
 
15
16
  <!-- Begin ToC -->
16
17
 
17
- - [Experimental technology disclaimer](#experimental-technology-disclaimer)
18
18
  - [Quickstart](#quickstart)
19
- - [OpenAI API Users](#openai-api-users)
20
- - [OpenAI Plus/Pro Users](#openai-pluspro-users)
19
+ - [Installing and running Codex CLI](#installing-and-running-codex-cli)
20
+ - [Using Codex with your ChatGPT plan](#using-codex-with-your-chatgpt-plan)
21
+ - [Usage-based billing alternative: Use an OpenAI API key](#usage-based-billing-alternative-use-an-openai-api-key)
22
+ - [Choosing Codex's level of autonomy](#choosing-codexs-level-of-autonomy)
23
+ - [**1. Read/write**](#1-readwrite)
24
+ - [**2. Read-only**](#2-read-only)
25
+ - [**3. Advanced configuration**](#3-advanced-configuration)
26
+ - [Can I run without ANY approvals?](#can-i-run-without-any-approvals)
27
+ - [Fine-tuning in `config.toml`](#fine-tuning-in-configtoml)
28
+ - [Example prompts](#example-prompts)
29
+ - [Running with a prompt as input](#running-with-a-prompt-as-input)
21
30
  - [Using Open Source Models](#using-open-source-models)
22
- - [Why Codex?](#why-codex)
23
- - [Security model & permissions](#security-model--permissions)
24
31
  - [Platform sandboxing details](#platform-sandboxing-details)
32
+ - [Experimental technology disclaimer](#experimental-technology-disclaimer)
25
33
  - [System requirements](#system-requirements)
26
34
  - [CLI reference](#cli-reference)
27
35
  - [Memory & project docs](#memory--project-docs)
28
36
  - [Non-interactive / CI mode](#non-interactive--ci-mode)
29
37
  - [Model Context Protocol (MCP)](#model-context-protocol-mcp)
30
38
  - [Tracing / verbose logging](#tracing--verbose-logging)
31
- - [Recipes](#recipes)
32
- - [Installation](#installation)
33
39
  - [DotSlash](#dotslash)
34
40
  - [Configuration](#configuration)
35
41
  - [FAQ](#faq)
@@ -54,55 +60,156 @@ This is the home of the **Codex CLI**, which is a coding agent from OpenAI that
54
60
 
55
61
  ---
56
62
 
57
- ## Experimental technology disclaimer
58
-
59
- Codex CLI is an experimental project under active development. It is not yet stable, may contain bugs, incomplete features, or undergo breaking changes. We're building it in the open with the community and welcome:
60
-
61
- - Bug reports
62
- - Feature requests
63
- - Pull requests
64
- - Good vibes
65
-
66
- Help us improve by filing issues or submitting PRs (see the section below for how to contribute)!
67
-
68
63
  ## Quickstart
69
64
 
65
+ ### Installing and running Codex CLI
66
+
70
67
  Install globally with your preferred package manager:
71
68
 
72
69
  ```shell
73
70
  npm install -g @openai/codex # Alternatively: `brew install codex`
74
71
  ```
75
72
 
76
- Or go to the [latest GitHub Release](https://github.com/openai/codex/releases/latest) and download the appropriate binary for your platform.
73
+ Then simply run `codex` to get started:
74
+
75
+ ```shell
76
+ codex
77
+ ```
77
78
 
78
- ### OpenAI API Users
79
+ <details>
80
+ <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>
79
81
 
80
- Next, set your OpenAI API key as an environment variable:
82
+ Each GitHub Release contains many executables, but in practice, you likely want one of these:
83
+
84
+ - macOS
85
+ - Apple Silicon/arm64: `codex-aarch64-apple-darwin.tar.gz`
86
+ - x86_64 (older Mac hardware): `codex-x86_64-apple-darwin.tar.gz`
87
+ - Linux
88
+ - x86_64: `codex-x86_64-unknown-linux-musl.tar.gz`
89
+ - arm64: `codex-aarch64-unknown-linux-musl.tar.gz`
90
+
91
+ 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.
92
+
93
+ </details>
94
+
95
+ ### Using Codex with your ChatGPT plan
96
+
97
+ <p align="center">
98
+ <img src="./.github/codex-cli-login.png" alt="Codex CLI login" width="50%" />
99
+ </p>
100
+
101
+ After you run `codex` select Sign in with ChatGPT. You'll need a Plus, Pro, or Team ChatGPT account, and will get access to our latest models, including `gpt-5`, at no extra cost to your plan. (Enterprise is coming soon.)
102
+
103
+ > Important: If you've used the Codex CLI before, you'll need to follow these steps to migrate from usage-based billing with your API key:
104
+ >
105
+ > 1. Update the CLI with `codex update` and ensure `codex --version` is greater than 0.13
106
+ > 2. Ensure that there is no `OPENAI_API_KEY` environment variable set. (Check that `env | grep 'OPENAI_API_KEY'` returns empty)
107
+ > 3. Run `codex login` again
108
+
109
+ If you encounter problems with the login flow, please comment on [this issue](https://github.com/openai/codex/issues/1243).
110
+
111
+ ### Usage-based billing alternative: Use an OpenAI API key
112
+
113
+ If you prefer to pay-as-you-go, you can still authenticate with your OpenAI API key by setting it as an environment variable:
81
114
 
82
115
  ```shell
83
116
  export OPENAI_API_KEY="your-api-key-here"
84
117
  ```
85
118
 
86
- > [!NOTE]
87
- > This command sets the key only for your current terminal session. You can add the `export` line to your shell's configuration file (e.g., `~/.zshrc`), but we recommend setting it for the session.
119
+ > Note: This command only sets the key for your current terminal session, which we recommend. To set it for all future sessions, you can also add the `export` line to your shell's configuration file (e.g., `~/.zshrc`).
120
+
121
+ ### Choosing Codex's level of autonomy
122
+
123
+ We always recommend running Codex in its default sandbox that gives you strong guardrails around what the agent can do. The default sandbox prevents it from editing files outside its workspace, or from accessing the network.
124
+
125
+ When you launch Codex in a new folder, it detects whether the folder is version controlled and recommends one of two levels of autonomy:
126
+
127
+ #### **1. Read/write**
88
128
 
89
- ### OpenAI Plus/Pro Users
129
+ - Codex can run commands and write files in the workspace without approval.
130
+ - To write files in other folders, access network, update git or perform other actions protected by the sandbox, Codex will need your permission.
131
+ - By default, the workspace includes the current directory, as well as temporary directories like `/tmp`. You can see what directories are in the workspace with the `/status` command. See the docs for how to customize this behavior.
132
+ - Advanced: You can manually specify this configuration by running `codex --sandbox workspace-write --ask-for-approval on-request`
133
+ - This is the recommended default for version-controlled folders.
90
134
 
91
- If you have a paid OpenAI account, run the following to start the login process:
135
+ #### **2. Read-only**
92
136
 
137
+ - Codex can run read-only commands without approval.
138
+ - To edit files, access network, or perform other actions protected by the sandbox, Codex will need your permission.
139
+ - Advanced: You can manually specify this configuration by running `codex --sandbox read-only --ask-for-approval on-request`
140
+ - This is the recommended default non-version-controlled folders.
141
+
142
+ #### **3. Advanced configuration**
143
+
144
+ Codex gives you fine-grained control over the sandbox with the `--sandbox` option, and over when it requests approval with the `--ask-for-approval` option. Run `codex help` for more on these options.
145
+
146
+ #### Can I run without ANY approvals?
147
+
148
+ Yes, run codex non-interactively with `--ask-for-approval never`. This option works with all `--sandbox` options, so you still have full control over Codex's level of autonomy. It will make its best attempt with whatever contrainsts you provide. For example:
149
+
150
+ - Use `codex --ask-for-approval never --sandbox read-only` when you are running many agents to answer questions in parallel in the same workspace.
151
+ - Use `codex --ask-for-approval never --sandbox workspace-write` when you want the agent to non-interactively take time to produce the best outcome, with strong guardrails around its behavior.
152
+ - Use `codex --ask-for-approval never --sandbox danger-full-access` to dangerously give the agent full autonomy. Because this disables important safety mechanisms, we recommend against using this unless running Codex in an isolated environment.
153
+
154
+ #### Fine-tuning in `config.toml`
155
+
156
+ ```toml
157
+ # approval mode
158
+ approval_policy = "untrusted"
159
+ sandbox_mode = "read-only"
160
+
161
+ # full-auto mode
162
+ approval_policy = "on-request"
163
+ sandbox_mode = "workspace-write"
164
+
165
+ # Optional: allow network in workspace-write mode
166
+ [sandbox_workspace_write]
167
+ network_access = true
93
168
  ```
94
- codex login
169
+
170
+ You can also save presets as **profiles**:
171
+
172
+ ```toml
173
+ [profiles.full_auto]
174
+ approval_policy = "on-request"
175
+ sandbox_mode = "workspace-write"
176
+
177
+ [profiles.readonly_quiet]
178
+ approval_policy = "never"
179
+ sandbox_mode = "read-only"
95
180
  ```
96
181
 
97
- If you complete the process successfully, you should have a `~/.codex/auth.json` file that contains the credentials that Codex will use.
182
+ ### Example prompts
183
+
184
+ Below are a few bite-size examples you can copy-paste. Replace the text in quotes with your own task. See the [prompting guide](https://github.com/openai/codex/blob/main/codex-cli/examples/prompting_guide.md) for more tips and usage patterns.
185
+
186
+ | ✨ | What you type | What happens |
187
+ | --- | ------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
188
+ | 1 | `codex "Refactor the Dashboard component to React Hooks"` | Codex rewrites the class component, runs `npm test`, and shows the diff. |
189
+ | 2 | `codex "Generate SQL migrations for adding a users table"` | Infers your ORM, creates migration files, and runs them in a sandboxed DB. |
190
+ | 3 | `codex "Write unit tests for utils/date.ts"` | Generates tests, executes them, and iterates until they pass. |
191
+ | 4 | `codex "Bulk-rename *.jpeg -> *.jpg with git mv"` | Safely renames files and updates imports/usages. |
192
+ | 5 | `codex "Explain what this regex does: ^(?=.*[A-Z]).{8,}$"` | Outputs a step-by-step human explanation. |
193
+ | 6 | `codex "Carefully review this repo, and propose 3 high impact well-scoped PRs"` | Suggests impactful PRs in the current codebase. |
194
+ | 7 | `codex "Look for vulnerabilities and create a security review report"` | Finds and explains security bugs. |
195
+
196
+ ## Running with a prompt as input
98
197
 
99
- To verify whether you are currently logged in, run:
198
+ You can also run Codex CLI with a prompt as input:
100
199
 
200
+ ```shell
201
+ codex "explain this codebase to me"
101
202
  ```
102
- codex login status
203
+
204
+ ```shell
205
+ codex --full-auto "create the fanciest todo-list app"
103
206
  ```
104
207
 
105
- If you encounter problems with the login flow, please comment on <https://github.com/openai/codex/issues/1243>.
208
+ That's it - Codex will scaffold a file, run it inside a sandbox, install any
209
+ missing dependencies, and show you the live result. Approve the changes and
210
+ they'll be committed to your working directory.
211
+
212
+ ## Using Open Source Models
106
213
 
107
214
  <details>
108
215
  <summary><strong>Use <code>--profile</code> to use other models</strong></summary>
@@ -163,31 +270,6 @@ model = "mistral"
163
270
  This way, you can specify one command-line argument (.e.g., `--profile o3`, `--profile mistral`) to override multiple settings together.
164
271
 
165
272
  </details>
166
- <br />
167
-
168
- Run interactively:
169
-
170
- ```shell
171
- codex
172
- ```
173
-
174
- Or, run with a prompt as input (and optionally in `Full Auto` mode):
175
-
176
- ```shell
177
- codex "explain this codebase to me"
178
- ```
179
-
180
- ```shell
181
- codex --full-auto "create the fanciest todo-list app"
182
- ```
183
-
184
- That's it - Codex will scaffold a file, run it inside a sandbox, install any
185
- missing dependencies, and show you the live result. Approve the changes and
186
- they'll be committed to your working directory.
187
-
188
- ---
189
-
190
- ## Using Open Source Models
191
273
 
192
274
  Codex can run fully locally against an OpenAI-compatible OSS host (like Ollama) using the `--oss` flag:
193
275
 
@@ -222,52 +304,27 @@ base_url = "http://my-ollama.example.com:11434/v1"
222
304
 
223
305
  ---
224
306
 
225
- ## Why Codex?
307
+ ### Platform sandboxing details
226
308
 
227
- Codex CLI is built for developers who already **live in the terminal** and want
228
- ChatGPT-level reasoning **plus** the power to actually run code, manipulate
229
- files, and iterate - all under version control. In short, it's _chat-driven
230
- development_ that understands and executes your repo.
309
+ The mechanism Codex uses to implement the sandbox policy depends on your OS:
231
310
 
232
- - **Zero setup** - bring your OpenAI API key and it just works!
233
- - **Full auto-approval, while safe + secure** by running network-disabled and directory-sandboxed
234
- - **Multimodal** - pass in screenshots or diagrams to implement features ✨
311
+ - **macOS 12+** uses **Apple Seatbelt** and runs commands using `sandbox-exec` with a profile (`-p`) that corresponds to the `--sandbox` that was specified.
312
+ - **Linux** uses a combination of Landlock/seccomp APIs to enforce the `sandbox` configuration.
235
313
 
236
- And it's **fully open-source** so you can see and contribute to how it develops!
314
+ Note that when running Linux in a containerized environment such as Docker, sandboxing may not work if the host/container configuration does not support the necessary Landlock/seccomp APIs. In such cases, we recommend configuring your Docker container so that it provides the sandbox guarantees you are looking for and then running `codex` with `--sandbox danger-full-access` (or, more simply, the `--dangerously-bypass-approvals-and-sandbox` flag) within your container.
237
315
 
238
316
  ---
239
317
 
240
- ## Security model & permissions
241
-
242
- Codex lets you decide _how much autonomy_ you want to grant the agent. The following options can be configured independently:
243
-
244
- - [`approval_policy`](./codex-rs/config.md#approval_policy) determines when you should be prompted to approve whether Codex can execute a command
245
- - [`sandbox`](./codex-rs/config.md#sandbox) determines the _sandbox policy_ that Codex uses to execute untrusted commands
246
-
247
- By default, Codex runs with `--ask-for-approval untrusted` and `--sandbox read-only`, which means that:
248
-
249
- - The user is prompted to approve every command not on the set of "trusted" commands built into Codex (`cat`, `ls`, etc.)
250
- - Approved commands are run outside of a sandbox because user approval implies "trust," in this case.
251
-
252
- Running Codex with the `--full-auto` convenience flag changes the configuration to `--ask-for-approval on-failure` and `--sandbox workspace-write`, which means that:
253
-
254
- - Codex does not initially ask for user approval before running an individual command.
255
- - Though when it runs a command, it is run under a sandbox in which:
256
- - It can read any file on the system.
257
- - It can only write files under the current directory (or the directory specified via `--cd`).
258
- - Network requests are completely disabled.
259
- - Only if the command exits with a non-zero exit code will it ask the user for approval. If granted, it will re-attempt the command outside of the sandbox. (A common case is when Codex cannot `npm install` a dependency because that requires network access.)
260
-
261
- Again, these two options can be configured independently. For example, if you want Codex to perform an "exploration" where you are happy for it to read anything it wants but you never want to be prompted, you could run Codex with `--ask-for-approval never` and `--sandbox read-only`.
262
-
263
- ### Platform sandboxing details
318
+ ## Experimental technology disclaimer
264
319
 
265
- The mechanism Codex uses to implement the sandbox policy depends on your OS:
320
+ Codex CLI is an experimental project under active development. It is not yet stable, may contain bugs, incomplete features, or undergo breaking changes. We're building it in the open with the community and welcome:
266
321
 
267
- - **macOS 12+** uses **Apple Seatbelt** and runs commands using `sandbox-exec` with a profile (`-p`) that corresponds to the `--sandbox` that was specified.
268
- - **Linux** uses a combination of Landlock/seccomp APIs to enforce the `sandbox` configuration.
322
+ - Bug reports
323
+ - Feature requests
324
+ - Pull requests
325
+ - Good vibes
269
326
 
270
- Note that when running Linux in a containerized environment such as Docker, sandboxing may not work if the host/container configuration does not support the necessary Landlock/seccomp APIs. In such cases, we recommend configuring your Docker container so that it provides the sandbox guarantees you are looking for and then running `codex` with `--sandbox danger-full-access` (or, more simply, the `--dangerously-bypass-approvals-and-sandbox` flag) within your container.
327
+ Help us improve by filing issues or submitting PRs (see the section below for how to contribute)!
271
328
 
272
329
  ---
273
330
 
@@ -346,52 +403,6 @@ See the Rust documentation on [`RUST_LOG`](https://docs.rs/env_logger/latest/env
346
403
 
347
404
  ---
348
405
 
349
- ## Recipes
350
-
351
- Below are a few bite-size examples you can copy-paste. Replace the text in quotes with your own task. See the [prompting guide](https://github.com/openai/codex/blob/main/codex-cli/examples/prompting_guide.md) for more tips and usage patterns.
352
-
353
- | ✨ | What you type | What happens |
354
- | --- | ------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
355
- | 1 | `codex "Refactor the Dashboard component to React Hooks"` | Codex rewrites the class component, runs `npm test`, and shows the diff. |
356
- | 2 | `codex "Generate SQL migrations for adding a users table"` | Infers your ORM, creates migration files, and runs them in a sandboxed DB. |
357
- | 3 | `codex "Write unit tests for utils/date.ts"` | Generates tests, executes them, and iterates until they pass. |
358
- | 4 | `codex "Bulk-rename *.jpeg -> *.jpg with git mv"` | Safely renames files and updates imports/usages. |
359
- | 5 | `codex "Explain what this regex does: ^(?=.*[A-Z]).{8,}$"` | Outputs a step-by-step human explanation. |
360
- | 6 | `codex "Carefully review this repo, and propose 3 high impact well-scoped PRs"` | Suggests impactful PRs in the current codebase. |
361
- | 7 | `codex "Look for vulnerabilities and create a security review report"` | Finds and explains security bugs. |
362
-
363
- ---
364
-
365
- ## Installation
366
-
367
- <details open>
368
- <summary><strong>Install Codex CLI using your preferred package manager.</strong></summary>
369
-
370
- From `brew` (recommended, downloads only the binary for your platform):
371
-
372
- ```bash
373
- brew install codex
374
- ```
375
-
376
- From `npm` (generally more readily available, but downloads binaries for all supported platforms):
377
-
378
- ```bash
379
- npm i -g @openai/codex
380
- ```
381
-
382
- Or go to the [latest GitHub Release](https://github.com/openai/codex/releases/latest) and download the appropriate binary for your platform.
383
-
384
- Admittedly, each GitHub Release contains many executables, but in practice, you likely want one of these:
385
-
386
- - macOS
387
- - Apple Silicon/arm64: `codex-aarch64-apple-darwin.tar.gz`
388
- - x86_64 (older Mac hardware): `codex-x86_64-apple-darwin.tar.gz`
389
- - Linux
390
- - x86_64: `codex-x86_64-unknown-linux-musl.tar.gz`
391
- - arm64: `codex-aarch64-unknown-linux-musl.tar.gz`
392
-
393
- 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.
394
-
395
406
  ### DotSlash
396
407
 
397
408
  The GitHub Release also contains a [DotSlash](https://dotslash-cli.com/) file for the Codex CLI named `codex`. Using a DotSlash file makes it possible to make a lightweight commit to source control to ensure all contributors use the same version of an executable, regardless of what platform they use for development.
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openai/codex",
3
- "version": "0.16.0",
3
+ "version": "0.19.0",
4
4
  "license": "Apache-2.0",
5
5
  "bin": {
6
6
  "codex": "bin/codex.js"