Commit Graph
8472 Commits
Author SHA1 Message Date
Luci 3fe7e53327 fix: nits in apply patch (#640)
## Description

Fix a nit in `apply patch`, potentially improving performance slightly.
2025-04-25 07:27:48 -07:00
LuciandThibault Sottiaux 1ef8e8afd3 docs: provider config (#653)
close: #651

Hi! @tibo-openai 👋 Could you share some great examples of
`instructions.md` files? Thanks!

---------

Co-authored-by: Thibault Sottiaux <tibo@openai.com>
2025-04-25 07:25:32 -07:00
Luci a9ecb2efce chore: upgrade prettier to v3 (#644)
## Description

This PR addresses the following improvements:

**Unify Prettier Version**: Currently, the Prettier version used in
`/package.json` and `/codex-cli/package.json` are different. In this PR,
we're updating both to use Prettier v3.

- Prettier v3 introduces improved support for JavaScript and TypeScript.
(e.g. the formatting scenario shown in the image below. This is more
aligned with the TypeScript indentation standard).

<img width="1126" alt="image"
src="https://github.com/user-attachments/assets/6e237eb8-4553-4574-b336-ed9561c55370"
/>

**Add Prettier Auto-Formatting in lint-staged**: We've added a step to
automatically run prettier --write on JavaScript and TypeScript files as
part of the lint-staged process, before the ESLint checks.

- This will help ensure that all committed code is properly formatted
according to the project's Prettier configuration.
2025-04-25 07:21:50 -07:00
Michael Bolin 7177f709b5 Merge 9717ac87c1 into sapling-pr-archive-bolinfest 2025-04-24 23:55:20 -07:00
Michael Bolin 9717ac87c1 feat: add ZDR support to Rust implementation 2025-04-24 23:54:21 -07:00
Michael Bolin 5847374630 merge commit for archive created by Sapling 2025-04-24 23:07:29 -07:00
Michael Bolin 73eb766637 feat(tui-rs): add support for mousewheel scrolling 2025-04-24 23:06:25 -07:00
Michael Bolin ea3637eac1 merge commit for archive created by Sapling 2025-04-24 22:36:17 -07:00
Michael Bolin 461ab550ce feat(tui-rs): add support for mousewheel scrolling 2025-04-24 22:36:13 -07:00
Michael Bolin 5e4164b251 merge commit for archive created by Sapling 2025-04-24 22:32:52 -07:00
Michael Bolin b90cf2a778 feat(tui-rs): add support for mousewheel scrolling 2025-04-24 22:32:47 -07:00
Michael Bolin 74aee5cdc8 Merge 006da34ada into sapling-pr-archive-bolinfest 2025-04-24 22:29:31 -07:00
Michael Bolin 006da34ada feat(tui-rs): add support for mousewheel scrolling 2025-04-24 22:29:28 -07:00
Michael Bolin abfe8c48cf Merge ea4557f963 into sapling-pr-archive-bolinfest 2025-04-24 22:23:50 -07:00
Michael Bolin ea4557f963 feat(tui-rs): add support for mousewheel scrolling 2025-04-24 22:22:32 -07:00
Michael Bolin bfe6fac463 fix: close stdin when running an exec tool call (#636)
We were already doing this in the TypeScript version, but forgot to
bring this over to Rust:


https://github.com/openai/codex/blob/c38c2a59c72504a72a537123dc4b6026875cdfac/codex-cli/src/utils/agent/sandbox/raw-exec.ts#L76-L78
2025-04-24 18:06:08 -07:00
Michael Bolin 6a9c9f4b6c fix: add RUST_BACKTRACE=full when running cargo test in CI (#638)
This should provide more information in the event of a failure.
2025-04-24 18:05:56 -07:00
Michael Bolin cc91e701a9 Merge 4db909caa7 into sapling-pr-archive-bolinfest 2025-04-24 18:03:27 -07:00
Michael Bolin 4db909caa7 fix: add RUST_BACKTRACE=full when running cargo test in CI 2025-04-24 18:03:21 -07:00
Michael Bolin 5cdcbfa9b4 fix: only run rust-ci.yml on PRs that modify files in codex-rs (#637)
The `rust-ci.yml` build appears to be a bit flaky (we're looking into
it...), so to save TypeScript contributors some noise, restrict the
`rust-ci.yml` job so that it only runs on PRs that touch files in
`codex-rs/`.
2025-04-24 17:59:35 -07:00
Michael Bolin 3b7b999a5e merge commit for archive created by Sapling 2025-04-24 17:56:29 -07:00
Michael Bolin eec2b1a3d4 fix: for now, only run rust-ci.yml on PRs that modify files in codex-rs 2025-04-24 17:56:23 -07:00
Michael Bolin bd71affbd1 Merge c9dffbaf04 into sapling-pr-archive-bolinfest 2025-04-24 17:54:48 -07:00
Michael Bolin c9dffbaf04 fix: for now, only run rust-ci.yml on PRs that modify files in codex-rs 2025-04-24 17:54:42 -07:00
Michael Bolin f356dfe8d6 Merge d2cb604b7d into sapling-pr-archive-bolinfest 2025-04-24 17:46:19 -07:00
Michael Bolin d2cb604b7d fix: close stdin when running an exec tool call 2025-04-24 17:46:10 -07:00
LuciandThibault Sottiaux c38c2a59c7 fix(utils): save config (#578)
## Description

When `saveConfig` is called, the project doc is incorrectly saved into
user instructions. This change ensures that only user instructions are
saved to `instructions.md` during saveConfig, preventing data
corruption.

close: #576

---------

Co-authored-by: Thibault Sottiaux <tibo@openai.com>
2025-04-24 17:32:33 -07:00
Michael Bolin 58f0e5ab74 feat: introduce codex_execpolicy crate for defining "safe" commands (#634)
As described in detail in `codex-rs/execpolicy/README.md` introduced in
this PR, `execpolicy` is a tool that lets you define a set of _patterns_
used to match [`execv(3)`](https://linux.die.net/man/3/execv)
invocations. When a pattern is matched, `execpolicy` returns the parsed
version in a structured form that is amenable to static analysis.

The primary use case is to define patterns match commands that should be
auto-approved by a tool such as Codex. This supports a richer pattern
matching mechanism that the sort of prefix-matching we have done to
date, e.g.:


https://github.com/openai/codex/blob/5e40d9d2211737f46136610497bcd9a8271009e0/codex-cli/src/approvals.ts#L333-L354

Note we are still playing with the API and the `system_path` option in
particular still needs some work.
2025-04-24 17:14:47 -07:00
Michael Bolin b6d4412762 merge commit for archive created by Sapling 2025-04-24 17:07:42 -07:00
Michael Bolin 687dc8b68b feat: introduce codex_execpolicy crate for defining "safe" commands 2025-04-24 17:07:37 -07:00
nvp159andThibault Sottiaux 5e40d9d221 feat(bug-report): print bug report URL in terminal instead of opening browser (#510) (#528)
Solves #510 
This PR changes the `/bug` command to print the URL into the terminal
(so it works in headless sessions) instead of trying to open a browser.

---------

Co-authored-by: Thibault Sottiaux <tibo@openai.com>
2025-04-24 17:00:14 -07:00
sooraj 36a5a02d5c feat: display error on selection of invalid model (#594)
Up-to-date of #78 

Fixes #32

addressed requested changes @tibo-openai :) made sense to me


though, previous rationale with passing the state up was assuming there
could be a future need to have a shared state with all available models
being available to the parent
2025-04-24 16:56:00 -07:00
Michael Bolin bb2d411043 fix: update scripts/build_container.sh to use pnpm instead of npm (#631)
I suspect this is why some contributors kept accidentally including a
new `codex-cli/package-lock.json` in their PRs.

Note the `Dockerfile` still uses `npm` instead of `pnpm`, but that
appears to be fine. (Probably nicer to globally install as few things as
possible in the image.)
2025-04-24 16:38:57 -07:00
oai-ragona b34ed2ab83 [codex-rs] More fine-grained sandbox flag support on Linux (#632)
##### What/Why
This PR makes it so that in Linux we actually respect the different
types of `--sandbox` flag, such that users can apply network and
filesystem restrictions in combination (currently the only supported
behavior), or just pick one or the other.

We should add similar support for OSX in a future PR.

##### Testing
From Linux devbox, updated tests to use more specific flags:
```
test linux::tests_linux::sandbox_blocks_ping ... ok
test linux::tests_linux::sandbox_blocks_getent ... ok
test linux::tests_linux::test_root_read ... ok
test linux::tests_linux::test_dev_null_write ... ok
test linux::tests_linux::sandbox_blocks_dev_tcp_redirection ... ok
test linux::tests_linux::sandbox_blocks_ssh ... ok
test linux::tests_linux::test_writable_root ... ok
test linux::tests_linux::sandbox_blocks_curl ... ok
test linux::tests_linux::sandbox_blocks_wget ... ok
test linux::tests_linux::sandbox_blocks_nc ... ok
test linux::tests_linux::test_root_write - should panic ... ok
```

##### Todo
- [ ] Add negative tests (e.g. confirm you can hit the network if you
configure filesystem only restrictions)
2025-04-24 15:33:45 -07:00
Michael Bolin 42a99121b8 Merge 36987ab76c into sapling-pr-archive-bolinfest 2025-04-24 15:04:05 -07:00
Michael Bolin 36987ab76c feat: introduce codex_execpolicy crate for defining "safe" commands 2025-04-24 15:03:56 -07:00
Michael Bolin c7906dfe47 Merge 55a8e70c5d into sapling-pr-archive-bolinfest 2025-04-24 14:29:39 -07:00
Michael Bolin 55a8e70c5d fix: update scripts/build_container.sh to use pnpm instead of npm 2025-04-24 14:29:32 -07:00
Michael Bolin 61805a832d fix: do not grant "node" user sudo access when using run_in_container.sh (#627)
This exploration came out of my review of
https://github.com/openai/codex/pull/414.

`run_in_container.sh` runs Codex in a Docker container like so:


https://github.com/openai/codex/blob/bd1c3deed9f4f103e755baa3f3a45e7a1c1a134b/codex-cli/scripts/run_in_container.sh#L51-L58

But then runs `init_firewall.sh` to set up the firewall to restrict
network access.

Previously, we did this by adding `/usr/local/bin/init_firewall.sh` to
the container and adding a special rule in `/etc/sudoers.d` so the
unprivileged user (`node`) could run the privileged `init_firewall.sh`
script to open up the firewall for `api.openai.com`:


https://github.com/openai/codex/blob/31d0d7a305305ad557035a2edcab60b6be5018d8/codex-cli/Dockerfile#L51-L56

Though I believe this is unnecessary, as we can use `docker exec --user
root` from _outside_ the container to run
`/usr/local/bin/init_firewall.sh` as `root` without adding a special
case in `/etc/sudoers.d`.

This appears to work as expected, as I tested it by doing the following:

```
./codex-cli/scripts/build_container.sh
./codex-cli/scripts/run_in_container.sh 'what is the output of `curl https://www.openai.com`'
```

This was a bit funny because in some of my runs, Codex wasn't convinced
it had network access, so I had to convince it to try the `curl`
request:


![image](https://github.com/user-attachments/assets/80bd487c-74e2-4cd3-aa0f-26a6edd8d3f7)

As you can see, when it ran `curl -s https\://www.openai.com`, it a
connection failure, so the network policy appears to be working as
intended.

Note this PR also removes `sudo` from the `apt-get install` list in the
`Dockerfile`.
2025-04-24 14:25:02 -07:00
Michael Bolin 51e659a9da merge commit for archive created by Sapling 2025-04-24 14:18:00 -07:00
Michael Bolin 65d1cc097d fix: do not grant "node" user sudo access when using run_in_container.sh 2025-04-24 14:16:54 -07:00
Fouad Matin bd1c3deed9 update: readme (#630)
- mention support for ZDR
- codex open source fund
2025-04-24 14:05:26 -07:00
Michael Bolin 31d0d7a305 feat: initial import of Rust implementation of Codex CLI in codex-rs/ (#629)
As stated in `codex-rs/README.md`:

Today, Codex CLI is written in TypeScript and requires Node.js 22+ to
run it. For a number of users, this runtime requirement inhibits
adoption: they would be better served by a standalone executable. As
maintainers, we want Codex to run efficiently in a wide range of
environments with minimal overhead. We also want to take advantage of
operating system-specific APIs to provide better sandboxing, where
possible.

To that end, we are moving forward with a Rust implementation of Codex
CLI contained in this folder, which has the following benefits:

- The CLI compiles to small, standalone, platform-specific binaries.
- Can make direct, native calls to
[seccomp](https://man7.org/linux/man-pages/man2/seccomp.2.html) and
[landlock](https://man7.org/linux/man-pages/man7/landlock.7.html) in
order to support sandboxing on Linux.
- No runtime garbage collection, resulting in lower memory consumption
and better, more predictable performance.

Currently, the Rust implementation is materially behind the TypeScript
implementation in functionality, so continue to use the TypeScript
implmentation for the time being. We will publish native executables via
GitHub Releases as soon as we feel the Rust version is usable.
2025-04-24 13:31:40 -07:00
Michael Bolin 8c8341d00b merge commit for archive created by Sapling 2025-04-24 13:15:21 -07:00
Michael Bolin 05aa166673 fix: do not grant "node" user sudo access when using run_in_container.sh 2025-04-24 13:15:13 -07:00
Misha Davidov acc4acc81e fix: apply_patch unicode characters (#625)
fuzzy-er matching for apply_patch to handle u00A0 and u202F spaces.
2025-04-24 13:04:37 -07:00
Luci e84fa6793d fix(agent-loop): notify type (#608)
## Description

The `as AppConfig` type assertion in the constructor may introduce
potential type safety risks. Removing the assertion and making `notify`
an optional parameter could enhance type robustness and prevent
unexpected runtime errors.

close: #605
2025-04-24 11:08:52 -07:00
Asa d1c0d5e683 feat: update README and config to support custom providers with API k… (#577)
When using a non-built-in provider with the `--provider` option, users
are prompted:

```
Set the environment variable <provider>_API_KEY and re-run this command.
You can create a <provider>_API_KEY in the <provider> dashboard.
```

However, many users are confused because, even after correctly setting
`<provider>_API_KEY`, authentication may still fail unless
`OPENAI_API_KEY` is _also_ present in the environment. This is not
intuitive and leads to ambiguity about which API key is actually
required and used as a fallback, especially when using custom or
third-party (non-listed) providers.

Furthermore, the original README/documentation did not mention the
requirement to set `<provider>_BASE_URL` for non-built-in providers,
which is necessary for proper client behavior. This omission made the
configuration process more difficult for users trying to integrate with
custom endpoints.
2025-04-24 11:08:19 -07:00
Luci 6d68a90064 feat: enhance toCodePoints to prevent potential unicode 14 errors (#615)
## Description

`Array.from` may fail when handling certain characters newly added in
Unicode 14. Where possible, it seems better to use `Intl.Segmenter` for
more reliable processing.


![image](https://github.com/user-attachments/assets/2cbd779d-69d3-448e-b76a-d793cb639d96)
2025-04-24 10:49:18 -07:00
Ilya Kamen 1008e1b9a0 fix: update bug report template - there is no --revision flag (#614)
I think there was a wrong word; --revision seems not to exist in help
and does nothing.
2025-04-24 10:48:42 -07:00