Commit Graph
1949 Commits
Author SHA1 Message Date
Michael Bolin 39659713ae merge commit for archive created by Sapling 2025-07-07 23:43:41 -07:00
Michael Bolin bd6027b4ea chore: create a release script for the Rust CLI 2025-07-07 23:43:35 -07:00
Michael Bolin 48910b2ac9 Merge bdb9bcdac4 into sapling-pr-archive-bolinfest 2025-07-07 23:42:11 -07:00
Michael Bolin bdb9bcdac4 chore: create a release script for the Rust CLI 2025-07-07 23:42:01 -07:00
Michael Bolin e0c08cea4f feat: add support for --sandbox flag (#1476)
On a high-level, we try to design `config.toml` so that you don't have
to "comment out a lot of stuff" when testing different options.

Previously, defining a sandbox policy was somewhat at odds with this
principle because you would define the policy as attributes of
`[sandbox]` like so:

```toml
[sandbox]
mode = "workspace-write"
writable_roots = [ "/tmp" ]
```

but if you wanted to temporarily change to a read-only sandbox, you
might feel compelled to modify your file to be:

```toml
[sandbox]
mode = "read-only"
# mode = "workspace-write"
# writable_roots = [ "/tmp" ]
```

Technically, commenting out `writable_roots` would not be strictly
necessary, as `mode = "read-only"` would ignore `writable_roots`, but
it's still a reasonable thing to do to keep things tidy.

Currently, the various values for `mode` do not support that many
attributes, so this is not that hard to maintain, but one could imagine
this becoming more complex in the future.

In this PR, we change Codex CLI so that it no longer recognizes
`[sandbox]`. Instead, it introduces a top-level option, `sandbox_mode`,
and `[sandbox_workspace_write]` is used to further configure the sandbox
when when `sandbox_mode = "workspace-write"` is used:

```toml
sandbox_mode = "workspace-write"

[sandbox_workspace_write]
writable_roots = [ "/tmp" ]
```

This feels a bit more future-proof in that it is less tedious to
configure different sandboxes:

```toml
sandbox_mode = "workspace-write"

[sandbox_read_only]
# read-only options here...

[sandbox_workspace_write]
writable_roots = [ "/tmp" ]

[sandbox_danger_full_access]
# danger-full-access options here...
```

In this scheme, you never need to comment out the configuration for an
individual sandbox type: you only need to redefine `sandbox_mode`.

Relatedly, previous to this change, a user had to do `-c
sandbox.mode=read-only` to change the mode on the command line. With
this change, things are arguably a bit cleaner because the equivalent
option is `-c sandbox_mode=read-only` (and now `-c
sandbox_workspace_write=...` can be set separately).

Though more importantly, we introduce the `-s/--sandbox` option to the
CLI, which maps directly to `sandbox_mode` in `config.toml`, making
config override behavior easier to reason about. Moreover, as you can
see in the updates to the various Markdown files, it is much easier to
explain how to configure sandboxing when things like `--sandbox
read-only` can be used as an example.

Relatedly, this cleanup also made it straightforward to add support for
a `sandbox` option for Codex when used as an MCP server (see the changes
to `mcp-server/src/codex_tool_config.rs`).

Fixes https://github.com/openai/codex/issues/1248.
2025-07-07 22:31:30 -07:00
Michael Bolin 3221d2734a merge commit for archive created by Sapling 2025-07-07 22:26:02 -07:00
Michael Bolin d830be38a7 feat: add support for --sandbox flag 2025-07-07 22:25:57 -07:00
Michael Bolin 8160a140a1 merge commit for archive created by Sapling 2025-07-07 22:14:17 -07:00
Michael Bolin b752023126 feat: add support for --sandbox flag 2025-07-07 22:14:11 -07:00
Michael Bolin cfa25927b0 Merge 1cd9d47117 into sapling-pr-archive-bolinfest 2025-07-07 22:13:24 -07:00
Michael Bolin 1cd9d47117 feat: add support for --sandbox flag 2025-07-07 22:13:19 -07:00
Michael Bolin 05270c9cc8 merge commit for archive created by Sapling 2025-07-07 19:54:17 -07:00
Michael Bolin 8f75cf0bf3 feat: add support for --sandbox flag 2025-07-07 19:54:12 -07:00
Michael Bolin 4cf8c4d363 merge commit for archive created by Sapling 2025-07-07 19:40:01 -07:00
Michael Bolin 59bb84c19a feat: add support for --sandbox flag 2025-07-07 19:38:18 -07:00
Michael Bolin 9cc77fb03b Merge 6d16e22376 into sapling-pr-archive-bolinfest 2025-07-07 19:34:20 -07:00
Michael Bolin 6d16e22376 feat: add support for --sandbox flag 2025-07-07 19:34:14 -07:00
Michael Bolin 0a44c42533 docs: update README to include npm install again (#1475)
v0.2.0 of https://www.npmjs.com/package/@openai/codex now runs the Rust
CLI, so it makes sense to bring back the instructions to use `npm i -g
@openai/codex`.

In most places, I list `npm install` before `brew install` because I
believe `npm` is more readily available, though I in the more detailed
part of the documentation, I note that `brew install` will download
fewer bytes, and in that sense, is preferred.
2025-07-07 17:44:26 -07:00
Michael Bolin 4f39917501 Merge 712308c923 into sapling-pr-archive-bolinfest 2025-07-07 17:39:23 -07:00
Michael Bolin 712308c923 docs: update README to include npm install again 2025-07-07 17:39:16 -07:00
Michael Bolin a9bed68947 chore: normalize repository.url in package.json (#1474)
I got this as a warning when doing `npm publish --dry-run`, so I ran
`npm pkg fix` to create this PR, as instructed.
2025-07-07 16:33:06 -07:00
Michael Bolin 66ddf6d4c2 Merge d0dac98004 into sapling-pr-archive-bolinfest 2025-07-07 16:31:50 -07:00
Michael Bolin d0dac98004 chore: normalize repository.url in package.json 2025-07-07 16:31:43 -07:00
ryoziandMichael Bolin fd67a0086c Fix Unicode handling in chat_composer "@" token detection (#1467)
## Issues Fixed

- **Primary Issue (#1450)**: Unicode cursor positioning was incorrect
due to mixing character positions with byte positions
- **Additional Issue**: Full-width spaces (CJK whitespace like " ")
weren't properly handled as token boundaries
- ref:
https://doc.rust-lang.org/std/primitive.char.html#method.is_whitespace

---------

Co-authored-by: Michael Bolin <bolinfest@gmail.com>
2025-07-07 13:43:31 -07:00
Michael Bolin c221eab0b5 feat: support custom HTTP headers for model providers (#1473)
This adds support for two new model provider config options:

- `http_headers` for hardcoded (key, value) pairs
- `env_http_headers` for headers whose values should be read from
environment variables

This also updates the built-in `openai` provider to use this feature to
set the following headers:

- `originator` => `codex_cli_rs`
- `version` => [CLI version]
- `OpenAI-Organization` => `OPENAI_ORGANIZATION` env var
- `OpenAI-Project` => `OPENAI_PROJECT` env var

for consistency with the TypeScript implementation:


https://github.com/openai/codex/blob/bd5a9e8ba96c7d9c58ecaf5e61ec62d14ac6378d/codex-cli/src/utils/agent/agent-loop.ts#L321-L329

While here, this also consolidates some logic that was duplicated across
`client.rs` and `chat_completions.rs` by introducing
`ModelProviderInfo.create_request_builder()`.

Resolves https://github.com/openai/codex/discussions/1152
2025-07-07 13:09:16 -07:00
Michael Bolin fc593fc965 Merge 048cd07da9 into sapling-pr-archive-bolinfest 2025-07-07 11:21:50 -07:00
Michael Bolin 048cd07da9 feat: add support for http_headers and env_key_http_headers 2025-07-07 11:21:43 -07:00
Michael Bolin bd5a9e8ba9 chore: update release scripts for the TypeScript CLI (#1472)
This introduces two changes to make a quick fix so we can deploy the
Rust CLI for `0.2.0` of `@openai/codex` on npm:

- Updates `WORKFLOW_URL` to point to
https://github.com/openai/codex/actions/runs/15981617627, which is the
GitHub workflow run used to create the binaries for the `0.2.0` release
we published to Homebrew.
- Adds a `--version` option to `stage_release.sh` to specify what the
`version` field in the `package.json` will be.

Locally, I ran the following:

```
./codex-cli/scripts/stage_release.sh --native --version 0.2.0
```

Previously, we only used the `--native` flag to publish to the `native`
tag of `@openai/codex` (e.g., `npm publish --tag native`), but we should
just publish this as the default tag for `0.2.0` to be consistent with
what is in Homebrew.

We can still publish one "final" version of the TypeScript CLI as 0.1.x
later.

Under the hood, this release will still contain `dist/cli.js`,
`bin/codex-linux-sandbox-x64`, and `bin/codex-x86_64-apple-darwin`,
which are not strictly necessary, but we'll fix that in `0.3.0`.
2025-07-07 09:43:03 -07:00
Michael Bolin bce4b93e50 Merge 2d7257e327 into sapling-pr-archive-bolinfest 2025-07-07 09:34:43 -07:00
Michael Bolin 2d7257e327 chore: update release scripts for the TypeScript CLI 2025-07-07 09:31:22 -07:00
Michael Bolin abcca30d93 docs: update documentation to reflect Rust CLI release (#1440)
As promised on https://github.com/openai/codex/discussions/1405, we are
making the first official release of the Rust CLI as v0.2.0. As part of
this move, we are making it available in Homebrew:

https://github.com/Homebrew/homebrew-core/pull/228615

Ultimately, we also plan to continue to make the CLI available in npm,
as well, though brew is a bit nicer in that `brew install` will download
only the binary for your platform whereas an npm module is expected to
contain the binaries for _all_ supported platforms, so it is a bit more
heavyweight.

A big part of this change is updating the root `README.md` to document
the behavior of the Rust CLI, which differs in a number of ways from the
TypeScript CLI. The existing `README.md` is moved to
`codex-cli/README.md` as part of this PR, as it is still applicable to
that folder.

As this is still early days for the Rust CLI, I encourage folks to
provide feedback on the command line flags and configuration options.
2025-07-01 15:00:31 -07:00
Michael Bolin 612272d3f2 merge commit for archive created by Sapling 2025-06-30 17:46:11 -07:00
Michael Bolin 3cfe1bef25 docs: update documentation to reflect Rust CLI release 2025-06-30 17:45:56 -07:00
Michael Bolin 8871e3df48 merge commit for archive created by Sapling 2025-06-30 17:27:58 -07:00
Michael Bolin bd03ff57cd docs: update documentation to reflect Rust CLI release 2025-06-30 17:27:51 -07:00
Michael Bolin d7c428e44f Merge 3d00d33d60 into sapling-pr-archive-bolinfest 2025-06-30 17:25:44 -07:00
Michael Bolin 3d00d33d60 docs: update documentation to reflect Rust CLI release 2025-06-30 17:25:35 -07:00
Michael Bolin 4cb3c76798 fix: softprops/action-gh-release@v2 should use existing tag instead of creating a new tag (#1436)
https://github.com/Homebrew/homebrew-core/pull/228521 details the issues
I was having with the **Source code (tar.gz)** artifact for our GitHub
releases not being quite right. I landed these PRs as stabs in the dark
to fix this:

- https://github.com/openai/codex/pull/1423
- https://github.com/openai/codex/pull/1430

Based on the insights from
https://github.com/Homebrew/homebrew-core/pull/228521, I think those
were wrong and the real problem was this:


https://github.com/openai/codex/blob/6dad5c3b1799ac18f7c76a9612f24936682b3c1d/.github/workflows/rust-release.yml#L162

That is, I was manufacturing a new tag name on the fly instead of using
the existing one.

This PR reverts #1423 and #1430 and hopefully fixes how `tag_name` is
set for the `softprops/action-gh-release@v2` step so the **Source code
(tar.gz)** includes the correct files. Assuming this works, this should
make the Homebrew formula straightforward.
2025-06-30 12:10:48 -07:00
Michael Bolin 31b70760e9 Merge f4a8893b52 into sapling-pr-archive-bolinfest 2025-06-30 12:02:56 -07:00
Michael Bolin f4a8893b52 fix: softprops/action-gh-release@v2 should use existing tag instead of creating a new tag 2025-06-30 12:02:45 -07:00
Michael Bolin 6dad5c3b17 feat: add query_params option to ModelProviderInfo to support Azure (#1435)
As discovered in https://github.com/openai/codex/issues/1365, the Azure
provider needs to be able to specify `api-version` as a query param, so
this PR introduces a generic `query_params` option to the
`model_providers` config so that an Azure provider can be defined as
follows:

```toml
[model_providers.azure]
name = "Azure"
base_url = "https://YOUR_PROJECT_NAME.openai.azure.com/openai"
env_key = "AZURE_OPENAI_API_KEY"
query_params = { api-version = "2025-04-01-preview" }
```

This PR also updates the docs with this example.

While here, we also update `wire_api` to default to `"chat"`, as that is
likely the common case for someone defining an external provider.

Fixes https://github.com/openai/codex/issues/1365.
2025-06-30 11:39:54 -07:00
Michael Bolin cc34b9377d merge commit for archive created by Sapling 2025-06-30 11:34:18 -07:00
Michael Bolin abe7a5ec1a feat: add query_params option to ModelProviderInfo to support Azure 2025-06-30 11:34:11 -07:00
Michael Bolin 517a131d88 Merge 92986ffdb4 into sapling-pr-archive-bolinfest 2025-06-30 11:27:17 -07:00
Michael Bolin 92986ffdb4 feat: add query_params option to ModelProviderInfo to support Azure 2025-06-30 11:27:07 -07:00
Michael Bolin cd2d84d496 fix: need to check out the branch, not the tag (#1430)
This should have been done in https://github.com/openai/codex/pull/1423.
codex-rs-2925136536b06a324551627468d17e959afa18d4-1-rust-v0.2.0-alpha.2
2025-06-29 10:18:50 -07:00
Michael Bolin 6c73649443 merge commit for archive created by Sapling 2025-06-29 10:16:00 -07:00
Michael Bolin 18dcca9388 fix: need to check out the branch, not the tag 2025-06-29 10:15:48 -07:00
Michael Bolin 688100f7f4 chore: fix Rust release process so generated .tar.gz source works with Homebrew (#1423)
Looking at existing releases such as
https://github.com/openai/codex/releases/tag/codex-rs-b289c9207090b2e27494545d7b5404e063bd86f3-1-rust-v0.1.0-alpha.4,
the `.tar.gz` for the source code still seems to have `0.0.0` as the
`version` in `codex-rs/Cargo.toml` instead of what the tag seems to say
it should have:


https://github.com/openai/codex/blob/b289c9207090b2e27494545d7b5404e063bd86f3/codex-rs/Cargo.toml#L21

ChatGPT claims:

> When GitHub generates the Source code (tar.gz) archive for a tag:
	•	It uses the commit the tag points to.
• But in some cases (e.g., shallow clones, GitHub CI, or local tools
that only clone the default branch), that commit may not be included,
and you might get an outdated view or nothing at all depending on how
it’s fetched.
	
Trying this recommended fix.
2025-06-28 19:46:44 -07:00
Michael Bolin d277b0a3ce merge commit for archive created by Sapling 2025-06-28 19:42:28 -07:00