Commit Graph

8634 Commits

Author SHA1 Message Date
Michael Bolin
221f92debc feat: add debug landlock subcommand comparable to debug seatbelt 2025-04-28 15:38:49 -07:00
Michael Bolin
ba8cd0061e Merge 8d57637549 into sapling-pr-archive-bolinfest 2025-04-28 15:03:35 -07:00
Michael Bolin
8d57637549 feat: add debug landlock subcommand comparable to debug seatbelt 2025-04-28 15:03:27 -07:00
Michael Bolin
750f31e3c0 merge commit for archive created by Sapling 2025-04-28 13:46:38 -07:00
Michael Bolin
08d4748dff feat: make it possible to set disable_response_storage = true in config.toml 2025-04-28 13:46:32 -07:00
Michael Bolin
cca1122ddc fix: make the TUI the default/"interactive" CLI in Rust (#711)
Originally, the `interactive` crate was going to be a placeholder for
building out a UX that was comparable to that of the existing TypeScript
CLI. Though after researching how Ratatui works, that seems difficult to
do because it is designed around the idea that it will redraw the full
screen buffer each time (and so any scrolling should be "internal" to
your Ratatui app) whereas the TypeScript CLI expects to render the full
history of the conversation every time(*) (which is why you can use your
terminal scrollbar to scroll it).

While it is possible to use Ratatui in a way that acts more like what
the TypeScript CLI is doing, it is awkward and seemingly results in
tedious code, so I think we should abandon that approach. As such, this
PR deletes the `interactive/` folder and the code that depended on it.

Further, since we added support for mousewheel scrolling in the TUI in
https://github.com/openai/codex/pull/641, it certainly feels much better
and the need for scroll support via the terminal scrollbar is greatly
diminished. This is now a more appropriate default UX for the
"multitool" CLI.

(*) Incidentally, I haven't verified this, but I think this results in
O(N^2) work in rendering, which seems potentially problematic for long
conversations.
2025-04-28 13:46:22 -07:00
Michael Bolin
40460faf2a fix: tighten up check for /usr/bin/sandbox-exec (#710)
* In both TypeScript and Rust, we now invoke `/usr/bin/sandbox-exec`
explicitly rather than whatever `sandbox-exec` happens to be on the
`PATH`.
* Changed `isSandboxExecAvailable` to use `access()` rather than
`command -v` so that:
  *  We only do the check once over the lifetime of the Codex process.
  * The check is specific to `/usr/bin/sandbox-exec`.
* We now do a syscall rather than incur the overhead of spawning a
process, dealing with timeouts, etc.

I think there is still room for improvement here where we should move
the `isSandboxExecAvailable` check earlier in the CLI, ideally right
after we do arg parsing to verify that we can provide the Seatbelt
sandbox if that is what the user has requested.
2025-04-28 13:42:04 -07:00
Michael Bolin
19251bb234 Merge 1e5d059dce into sapling-pr-archive-bolinfest 2025-04-28 13:37:40 -07:00
Michael Bolin
1e5d059dce fix: tighten up check for /usr/bin/sandbox-exec 2025-04-28 13:37:28 -07:00
Michael Bolin
25ef01f8c0 Merge 8ab5a4793b into sapling-pr-archive-bolinfest 2025-04-28 13:37:22 -07:00
Michael Bolin
8ab5a4793b fix: make the TUI the default/"interactive" CLI 2025-04-28 13:37:16 -07:00
Michael Bolin
3933ade4f6 Merge 6bda0d3096 into sapling-pr-archive-bolinfest 2025-04-28 13:36:40 -07:00
Michael Bolin
6bda0d3096 feat: make it possible to set disable_response_storage = true in config.toml 2025-04-28 13:36:33 -07:00
Michael Bolin
38575ed8aa fix: increase timeout of test_writable_root (#713)
Although we made some promising fixes in
https://github.com/openai/codex/pull/662, we are still seeing some
flakiness in `test_writable_root()`. If this continues to flake with the
more generous timeout, we should try something other than simply
increasing the timeout.
2025-04-28 13:09:27 -07:00
Michael Bolin
fedf79574c Merge 835df9e5dd into sapling-pr-archive-bolinfest 2025-04-28 13:06:10 -07:00
Michael Bolin
835df9e5dd fix: increase timeout of test_writable_root 2025-04-28 13:06:02 -07:00
Michael Bolin
d4df003be9 Merge f5d320beaa into sapling-pr-archive-bolinfest 2025-04-28 12:35:36 -07:00
Michael Bolin
f5d320beaa fix: make the TUI the default/"interactive" CLI 2025-04-28 12:35:29 -07:00
Michael Bolin
c46d362dc2 merge commit for archive created by Sapling 2025-04-28 12:24:58 -07:00
Michael Bolin
15e3d634d8 fix: tighten up check for /usr/bin/sandbox-exec 2025-04-28 12:24:53 -07:00
Michael Bolin
8344fd2917 merge commit for archive created by Sapling 2025-04-28 12:19:16 -07:00
Michael Bolin
ea47723b8f fix: tighten up check for /usr/bin/sandbox-exec 2025-04-28 12:19:12 -07:00
Michael Bolin
531ebac59c Merge decb0cc953 into sapling-pr-archive-bolinfest 2025-04-28 12:13:59 -07:00
Michael Bolin
decb0cc953 fix: tighten up check for /usr/bin/sandbox-exec 2025-04-28 12:13:52 -07:00
Michael Bolin
77e2918049 fix: drop d as keyboard shortcut for scrolling in the TUI (#704)
The existing `b` and `space` are sufficient and `d` and `u` default to
half-page scrolling in `less`, so the way we supported `d` and `u`
wasn't faithful to that, anyway:

https://man7.org/linux/man-pages/man1/less.1.html

If we decide to bring `d` and `u` back, they should probably match
`less`?
2025-04-28 10:39:58 -07:00
Michael Bolin
f3b4195009 Merge 8deabff73f into sapling-pr-archive-bolinfest 2025-04-28 09:28:56 -07:00
Michael Bolin
8deabff73f fix: drop d as keyboard shortcut for scrolling in the TUI 2025-04-28 09:28:38 -07:00
Michael Bolin
5a5024334f Merge 07c1f65e65 into sapling-pr-archive-bolinfest 2025-04-28 09:21:56 -07:00
Michael Bolin
07c1f65e65 fix: drop d as keyboard shortcut for scrolling in the TUI 2025-04-28 09:21:49 -07:00
Thibault Sottiaux
fa5fa8effc fix: only allow running without sandbox if explicitly marked in safe container (#699)
Signed-off-by: Thibault Sottiaux <tibo@openai.com>
2025-04-28 07:48:38 -07:00
Michael Bolin
4eda4dd772 feat: load defaults into Config and introduce ConfigOverrides (#677)
This changes how instantiating `Config` works and also adds
`approval_policy` and `sandbox_policy` as fields. The idea is:

* All fields of `Config` have appropriate default values.
* `Config` is initially loaded from `~/.codex/config.toml`, so values in
`config.toml` will override those defaults.
* Clients must instantiate `Config` via
`Config::load_with_overrides(ConfigOverrides)` where `ConfigOverrides`
has optional overrides that are expected to be settable based on CLI
flags.

The `Config` should be defined early in the program and then passed
down. Now functions like `init_codex()` take fewer individual parameters
because they can just take a `Config`.

Also, `Config::load()` used to fail silently if `~/.codex/config.toml`
had a parse error and fell back to the default config. This seemed
really bad because it wasn't clear why the values in my `config.toml`
weren't getting picked up. I changed things so that
`load_with_overrides()` returns `Result<Config>` and verified that the
various CLIs print a reasonable error if `config.toml` is malformed.

Finally, I also updated the TUI to show which **sandbox** value is being
used, as we do for other key values like **model** and **approval**.
This was also a reminder that the various values of `--sandbox` are
honored on Linux but not macOS today, so I added some TODOs about fixing
that.
2025-04-27 21:47:50 -07:00
Thibault Sottiaux
e9d16d3c2b fix: check if sandbox-exec is available (#696)
- Introduce `isSandboxExecAvailable()` helper and tidy import ordering
in `handle-exec-command.ts`.
- Add runtime check for the `sandbox-exec` binary on macOS; fall back to
`SandboxType.NONE` with a warning if it’s missing, preventing crashes.

---------

Signed-off-by: Thibault Sottiaux <tibo@openai.com>
Co-authored-by: Fouad Matin <fouad@openai.com>
2025-04-27 17:04:47 -07:00
Fouad Matin
523996b5cb fix: /diff should include untracked files (#686) 2025-04-26 12:43:51 -07:00
Tomas Cupr
bc500d3009 feat: user config api key (#569)
Adds support for reading OPENAI_API_KEY (and other variables) from a
user‑wide dotenv file (~/.codex.config). Precedence order is now:
  1. explicit environment variable
  2. project‑local .env (loaded earlier)
  3. ~/.codex.config

Also adds a regression test that ensures the multiline editor correctly
handles cases where printable text and the CSI‑u Shift+Enter sequence
arrive in the same input chunk.

House‑kept with Prettier; removed stray temp.json artifact.
2025-04-26 10:13:30 -07:00
moppywhip
9b0ccf9aeb fix: duplicate messages in quiet mode (#680)
Addressing #600 and #664 (partially)

## Bug
Codex was staging duplicate items in output running when the same
response item appeared in both the streaming events. Specifically:

1. Items would be staged once when received as a
`response.output_item.done` event
2. The same items would be staged again when included in the final
`response.completed` payload

This duplication would result in each message being sent several times
in the quiet mode output.

## Changes
- Added a Set (`alreadyStagedItemIds`) to track items that have already
been staged
- Modified the `stageItem` function to check if an item's ID is already
in this set before staging it
- Added a regression test (`agent-dedupe-items.test.ts`) that verifies
items with the same ID are only staged once

## Testing
Like other tests, the included test creates a mock OpenAI stream that
emits the same message twice (once as an incremental event and once in
the final response) and verifies the item is only passed to `onItem`
once.
2025-04-26 09:14:50 -07:00
Michael Bolin
bf6990bb5f merge commit for archive created by Sapling 2025-04-25 21:57:38 -07:00
Michael Bolin
1f15594e99 feat: load defaults into Config and introduce ConfigOverrides 2025-04-25 21:57:34 -07:00
Michael Bolin
8c0d4280fc merge commit for archive created by Sapling 2025-04-25 21:53:40 -07:00
Michael Bolin
caa48d66b8 feat: load defaults into Config and introduce ConfigOverrides 2025-04-25 21:53:35 -07:00
Michael Bolin
cd3c6c929d merge commit for archive created by Sapling 2025-04-25 21:28:34 -07:00
Michael Bolin
18f9ac5c38 feat: load defaults into Config and introduce ConfigOverrides 2025-04-25 21:28:29 -07:00
Michael Bolin
886ee2fc58 merge commit for archive created by Sapling 2025-04-25 21:26:22 -07:00
Michael Bolin
43a09e314e feat: load defaults into Config and introduce ConfigOverrides 2025-04-25 21:26:09 -07:00
Michael Bolin
26b2fb9a6f merge commit for archive created by Sapling 2025-04-25 21:23:30 -07:00
Michael Bolin
e72e201fb1 feat: load defaults into Config and introduce ConfigOverrides 2025-04-25 21:23:26 -07:00
Michael Bolin
a5ad1cf002 merge commit for archive created by Sapling 2025-04-25 20:49:56 -07:00
Michael Bolin
c4bafdca9c feat: load defaults into Config and introduce ConfigOverrides 2025-04-25 20:49:51 -07:00
Michael Bolin
7a6d918234 Merge e4ad444fd1 into sapling-pr-archive-bolinfest 2025-04-25 20:45:22 -07:00
Michael Bolin
e4ad444fd1 feat: load defaults into Config and introduce ConfigOverrides 2025-04-25 20:44:51 -07:00
Michael Bolin
21f036a511 merge commit for archive created by Sapling 2025-04-25 20:41:29 -07:00