doc: update the config.toml documentation for the Rust CLI in codex-rs/README.md (#795)
https://github.com/openai/codex/pull/793 had important information on the `notify` config option that seemed worth memorializing, so this PR updates the documentation about all of the configurable options in `~/.codex/config.toml`.
This commit is contained in:
@@ -20,3 +20,146 @@ This folder is the root of a Cargo workspace. It contains quite a bit of experim
|
|||||||
- [`exec/`](./exec) "headless" CLI for use in automation.
|
- [`exec/`](./exec) "headless" CLI for use in automation.
|
||||||
- [`tui/`](./tui) CLI that launches a fullscreen TUI built with [Ratatui](https://ratatui.rs/).
|
- [`tui/`](./tui) CLI that launches a fullscreen TUI built with [Ratatui](https://ratatui.rs/).
|
||||||
- [`cli/`](./cli) CLI multitool that provides the aforementioned CLIs via subcommands.
|
- [`cli/`](./cli) CLI multitool that provides the aforementioned CLIs via subcommands.
|
||||||
|
|
||||||
|
## Config
|
||||||
|
|
||||||
|
The CLI can be configured via `~/.codex/config.toml`. It supports the following options:
|
||||||
|
|
||||||
|
### model
|
||||||
|
|
||||||
|
The model that Codex should use.
|
||||||
|
|
||||||
|
```toml
|
||||||
|
model = "o3" # overrides the default of "o4-mini"
|
||||||
|
```
|
||||||
|
|
||||||
|
### approval_policy
|
||||||
|
|
||||||
|
Determines when the user should be prompted to approve whether Codex can execute a command:
|
||||||
|
|
||||||
|
```toml
|
||||||
|
# This is analogous to --suggest in the TypeScript Codex CLI
|
||||||
|
approval_policy = "unless-allow-listed"
|
||||||
|
```
|
||||||
|
|
||||||
|
```toml
|
||||||
|
# If the command fails when run in the sandbox, Codex asks for permission to
|
||||||
|
# retry the command outside the sandbox.
|
||||||
|
approval_policy = "on-failure"
|
||||||
|
```
|
||||||
|
|
||||||
|
```toml
|
||||||
|
# User is never prompted: if the command fails, Codex will automatically try
|
||||||
|
# something out. Note the `exec` subcommand always uses this mode.
|
||||||
|
approval_policy = "never"
|
||||||
|
```
|
||||||
|
|
||||||
|
### sandbox_permissions
|
||||||
|
|
||||||
|
List of permissions to grant to the sandbox that Codex uses to execute untrusted commands:
|
||||||
|
|
||||||
|
```toml
|
||||||
|
# This is comparable to --full-auto in the TypeScript Codex CLI, though
|
||||||
|
# specifying `disk-write-platform-global-temp-folder` adds /tmp as a writable
|
||||||
|
# folder in addition to $TMPDIR.
|
||||||
|
sandbox_permissions = [
|
||||||
|
"disk-full-read-access",
|
||||||
|
"disk-write-platform-user-temp-folder",
|
||||||
|
"disk-write-platform-global-temp-folder",
|
||||||
|
"disk-write-cwd",
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
To add additional writable folders, use `disk-write-folder`, which takes a parameter (this can be specified multiple times):
|
||||||
|
|
||||||
|
```toml
|
||||||
|
sandbox_permissions = [
|
||||||
|
# ...
|
||||||
|
"disk-write-folder=/Users/mbolin/.pyenv/shims",
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
### disable_response_storage
|
||||||
|
|
||||||
|
Currently, customers whose accounts are set to use Zero Data Retention (ZDR) must set `disable_response_storage` to `true` so that Codex uses an alternative to the Responses API that works with ZDR:
|
||||||
|
|
||||||
|
```toml
|
||||||
|
disable_response_storage = true
|
||||||
|
```
|
||||||
|
|
||||||
|
### notify
|
||||||
|
|
||||||
|
Specify a program that will be executed to get notified about events generated by Codex. Note that the program will receive the notification argument as a string of JSON, e.g.:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"type": "agent-turn-complete",
|
||||||
|
"turn-id": "12345",
|
||||||
|
"input-messages": ["Rename `foo` to `bar` and update the callsites."],
|
||||||
|
"last-assistant-message": "Rename complete and verified `cargo build` succeeds."
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
The `"type"` property will always be set. Currently, `"agent-turn-complete"` is the only notification type that is supported.
|
||||||
|
|
||||||
|
As an example, here is a Python script that parses the JSON and decides whether to show a desktop push notification using [terminal-notifier](https://github.com/julienXX/terminal-notifier) on macOS:
|
||||||
|
|
||||||
|
```python
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import json
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> int:
|
||||||
|
if len(sys.argv) != 2:
|
||||||
|
print("Usage: notify.py <NOTIFICATION_JSON>")
|
||||||
|
return 1
|
||||||
|
|
||||||
|
try:
|
||||||
|
notification = json.loads(sys.argv[1])
|
||||||
|
except json.JSONDecodeError:
|
||||||
|
return 1
|
||||||
|
|
||||||
|
match notification_type := notification.get("type"):
|
||||||
|
case "agent-turn-complete":
|
||||||
|
assistant_message = notification.get("last-assistant-message")
|
||||||
|
if assistant_message:
|
||||||
|
title = f"Codex: {assistant_message}"
|
||||||
|
else:
|
||||||
|
title = "Codex: Turn Complete!"
|
||||||
|
input_messages = notification.get("input_messages", [])
|
||||||
|
message = " ".join(input_messages)
|
||||||
|
title += message
|
||||||
|
case _:
|
||||||
|
print(f"not sending a push notification for: {notification_type}")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
subprocess.check_output(
|
||||||
|
[
|
||||||
|
"terminal-notifier",
|
||||||
|
"-title",
|
||||||
|
title,
|
||||||
|
"-message",
|
||||||
|
message,
|
||||||
|
"-group",
|
||||||
|
"codex",
|
||||||
|
"-ignoreDnD",
|
||||||
|
"-activate",
|
||||||
|
"com.googlecode.iterm2",
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main())
|
||||||
|
```
|
||||||
|
|
||||||
|
To have Codex use this script for notifications, you would configure it via `notify` in `~/.codex/config.toml` using the appropriate path to `notify.py` on your computer:
|
||||||
|
|
||||||
|
```toml
|
||||||
|
notify = ["python3", "/Users/mbolin/.codex/notify.py"]
|
||||||
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user