Commit Graph
1717 Commits
Author SHA1 Message Date
Michael Bolin 95da270f6b Merge 8b66da118e into sapling-pr-archive-bolinfest 2025-06-05 21:56:04 -07:00
Michael Bolin 8b66da118e fix: include codex-linux-sandbox-aarch64-unknown-linux-musl in the set of release artifacts 2025-06-05 21:55:57 -07:00
Michael Bolin 0ec9a3bc45 Merge 70e420d1d2 into sapling-pr-archive-bolinfest 2025-06-05 21:50:07 -07:00
Michael Bolin 70e420d1d2 fix: use aarch64-unknown-linux-musl instead of aarch64-unknown-linux-gnu 2025-06-05 21:36:13 -07:00
Michael Bolin 2a63375959 Merge d77563d78d into sapling-pr-archive-bolinfest 2025-06-05 20:42:42 -07:00
Michael Bolin d77563d78d fix: use aarch64-unknown-linux-musl instead of aarch64-unknown-linux-gnu 2025-06-05 20:42:34 -07:00
Michael Bolin 9db53b33aa fix: support arm64 build for Linux (#1225)
Users were running into issues with glibc mismatches on arm64 linux. In
the past, we did not provide a musl build for arm64 Linux because we had
trouble getting the openssl dependency to build correctly. Though today
I just tried the same trick in `Cargo.toml` that we were doing for
`x86_64-unknown-linux-musl` (using `openssl-sys` with `features =
["vendored"]`), so I'm not sure what problem we had in the past the
builds "just worked" today!

Though one tweak that did have to be made is that the integration tests
for Seccomp/Landlock empirically require longer timeouts on arm64 linux,
or at least on the `ubuntu-24.04-arm` GitHub Runner. As such, we change
the timeouts for arm64 in `codex-rs/linux-sandbox/tests/landlock.rs`.

Though in solving this problem, I decided I needed a turnkey solution
for testing the Linux build(s) from my Mac laptop, so this PR introduces
`.devcontainer/Dockerfile` and `.devcontainer/devcontainer.json` to
facilitate this. Detailed instructions are in `.devcontainer/README.md`.

We will update `dotslash-config.json` and other release-related scripts
in a follow-up PR.
codex-rs-84eae7b1bc4e3b5420f2d6127b7c17e7a979a5b0-1-rust-v0.0.2506052135
2025-06-05 20:29:46 -07:00
Michael Bolin 33724c2ae1 merge commit for archive created by Sapling 2025-06-05 20:25:33 -07:00
Michael Bolin 19bb463b97 fix: support arm64 build for Linux 2025-06-05 20:25:28 -07:00
Michael Bolin bb335f44c3 merge commit for archive created by Sapling 2025-06-05 20:22:25 -07:00
Michael Bolin bca266f5ca fix: support arm64 build for Linux 2025-06-05 20:22:18 -07:00
Michael Bolin 6df663a988 Merge f5c9a961b0 into sapling-pr-archive-bolinfest 2025-06-05 20:17:51 -07:00
Michael Bolin f5c9a961b0 fix: support arm64 build for Linux 2025-06-05 20:17:46 -07:00
Michael Bolin 5b684d03e6 merge commit for archive created by Sapling 2025-06-05 17:27:39 -07:00
Michael Bolin 7c845c34d4 fix: support arm64 build for Linux 2025-06-05 17:27:32 -07:00
Michael Bolin de221589d3 Merge 5bd4ce9efa into sapling-pr-archive-bolinfest 2025-06-05 17:12:59 -07:00
Michael Bolin 5bd4ce9efa fix: support arm64 build for Linux 2025-06-05 17:12:53 -07:00
Michael Bolin b9b3d13b12 Merge 38f17182c9 into sapling-pr-archive-bolinfest 2025-06-05 17:08:04 -07:00
Michael Bolin 38f17182c9 fix: support arm64 build for Linux 2025-06-05 17:07:57 -07:00
Michael Bolin 1938f06bbc merge commit for archive created by Sapling 2025-06-04 21:23:46 -07:00
Michael Bolin e59083f73b feat: port maybeRedeemCredits() from get-api-key.tsx to login_with_chatgpt.py 2025-06-04 21:23:26 -07:00
Michael Bolin 515b6331bd feat: add support for login with ChatGPT (#1212)
This does not implement the full Login with ChatGPT experience, but it
should unblock people.

**What works**

* The `codex` multitool now has a `login` subcommand, so you can run
`codex login`, which should write `CODEX_HOME/auth.json` if you complete
the flow successfully. The TUI will now read the `OPENAI_API_KEY` from
`auth.json`.
* The TUI should refresh the token if it has expired and the necessary
information is in `auth.json`.
* There is a `LoginScreen` in the TUI that tells you to run `codex
login` if both (1) your model provider expects to use `OPENAI_API_KEY`
as its env var, and (2) `OPENAI_API_KEY` is not set.

**What does not work**

* The `LoginScreen` does not support the login flow from within the TUI.
Instead, it tells you to quit, run `codex login`, and then run `codex`
again.
* `codex exec` does read from `auth.json` yet, nor does it direct the
user to go through the login flow if `OPENAI_API_KEY` is not be found.
* The `maybeRedeemCredits()` function from `get-api-key.tsx` has not
been ported from TypeScript to `login_with_chatgpt.py` yet:


https://github.com/openai/codex/blob/a67a67f3258fc21e147b6786a143fe3e15e6d5ba/codex-cli/src/utils/get-api-key.tsx#L84-L89

**Implementation**

Currently, the OAuth flow requires running a local webserver on
`127.0.0.1:1455`. It seemed wasteful to incur the additional binary cost
of a webserver dependency in the Rust CLI just to support login, so
instead we implement this logic in Python, as Python has a `http.server`
module as part of its standard library. Specifically, we bundle the
contents of a single Python file as a string in the Rust CLI and then
use it to spawn a subprocess as `python3 -c
{{SOURCE_FOR_PYTHON_SERVER}}`.

As such, the most significant files in this PR are:

```
codex-rs/login/src/login_with_chatgpt.py
codex-rs/login/src/lib.rs
```

Now that the CLI may load `OPENAI_API_KEY` from the environment _or_
`CODEX_HOME/auth.json`, we need a new abstraction for reading/writing
this variable, so we introduce:

```
codex-rs/core/src/openai_api_key.rs
```

Note that `std::env::set_var()` is [rightfully] `unsafe` in Rust 2024,
so we use a LazyLock<RwLock<Option<String>>> to store `OPENAI_API_KEY`
so it is read in a thread-safe manner.

Ultimately, it should be possible to go through the entire login flow
from the TUI. This PR introduces a placeholder `LoginScreen` UI for that
right now, though the new `codex login` subcommand introduced in this PR
should be a viable workaround until the UI is ready.

**Testing**

Because the login flow is currently implemented in a standalone Python
file, you can test it without building any Rust code as follows:

```
rm -rf /tmp/codex_home && mkdir /tmp/codex_home
CODEX_HOME=/tmp/codex_home python3 codex-rs/login/src/login_with_chatgpt.py
```

For reference:

* the original TypeScript implementation was introduced in
https://github.com/openai/codex/pull/963
* support for redeeming credits was later added in
https://github.com/openai/codex/pull/974
2025-06-04 08:44:17 -07:00
Michael Bolin 1af354db57 merge commit for archive created by Sapling 2025-06-04 08:33:59 -07:00
Michael Bolin 88c34a9675 feat: add support for login with ChatGPT 2025-06-04 08:33:53 -07:00
Michael Bolin 6dba011651 merge commit for archive created by Sapling 2025-06-04 08:22:36 -07:00
Michael Bolin 908ca8f162 feat: add support for login with ChatGPT 2025-06-04 08:22:30 -07:00
Michael Bolin 210525e27c merge commit for archive created by Sapling 2025-06-04 00:22:25 -07:00
Michael Bolin 9182f93da5 feat: add support for login with ChatGPT 2025-06-04 00:22:19 -07:00
Michael Bolin 6462e6eb1a merge commit for archive created by Sapling 2025-06-04 00:06:12 -07:00
Michael Bolin 46a7e4ad18 feat: add support for login with ChatGPT 2025-06-04 00:06:06 -07:00
Michael Bolin 1609db9e04 Merge 592b354a87 into sapling-pr-archive-bolinfest 2025-06-04 00:03:51 -07:00
Michael Bolin 592b354a87 feat: add support for login with ChatGPT 2025-06-04 00:03:46 -07:00
Michael Bolin 3297f12026 merge commit for archive created by Sapling 2025-06-03 23:59:42 -07:00
Michael Bolin 2bb6a7454b feat: add support for login with ChatGPT 2025-06-03 23:59:30 -07:00
Michael Bolin 09d07b6767 merge commit for archive created by Sapling 2025-06-03 23:29:14 -07:00
Michael Bolin 1277c0557d feat: add support for login with ChatGPT 2025-06-03 23:28:39 -07:00
Michael Bolin 682751d19d merge commit for archive created by Sapling 2025-06-03 16:22:32 -07:00
Michael Bolin d061e26e70 feat: add support for login with ChatGPT 2025-06-03 16:22:21 -07:00
Michael Bolin 6a47c689a0 merge commit for archive created by Sapling 2025-06-03 16:10:24 -07:00
Michael Bolin 1ab5b27920 feat: add support for login with ChatGPT 2025-06-03 16:10:19 -07:00
Michael Bolin 5a5dc357f4 merge commit for archive created by Sapling 2025-06-03 15:51:05 -07:00
Michael Bolin 815bff6964 feat: add support for login with ChatGPT 2025-06-03 15:50:59 -07:00
Michael Bolin d607b6cc3b merge commit for archive created by Sapling 2025-06-03 15:50:27 -07:00
Michael Bolin c2ecf2818a feat: add support for login with ChatGPT 2025-06-03 15:50:17 -07:00
Michael Bolin 5b73f7cc05 merge commit for archive created by Sapling 2025-06-03 14:32:05 -07:00
Michael Bolin 000b715181 feat: add support for login with ChatGPT 2025-06-03 14:31:59 -07:00
Reilly Wood a67a67f325 codex-rs: make tool calls prettier (#1211)
This PR overhauls how active tool calls and completed tool calls are
displayed:

1. More use of colour to indicate success/failure and distinguish
between components like tool name+arguments
2. Previously, the entire `CallToolResult` was serialized to JSON and
pretty-printed. Now, we extract each individual `CallToolResultContent`
and print those
1. The previous solution was wasting space by unnecessarily showing
details of the `CallToolResult` struct to users, without formatting the
actual tool call results nicely
2. We're now able to show users more information from tool results in
less space, with nicer formatting when tools return JSON results

### Before:

<img width="1251" alt="Screenshot 2025-06-03 at 11 24 26"
src="https://github.com/user-attachments/assets/5a58f222-219c-4c53-ace7-d887194e30cf"
/>

### After:

<img width="1265" alt="image"
src="https://github.com/user-attachments/assets/99fe54d0-9ebe-406a-855b-7aa529b91274"
/>

## Future Work

1. Integrate image tool result handling better. We should be able to
display images even if they're not the first `CallToolResultContent`
2. Users should have some way to view the full version of truncated tool
results
3. It would be nice to add some left padding for tool results, make it
more clear that they are results. This is doable, just a little fiddly
due to the way `first_visible_line` scrolling works
4. There's almost certainly a better way to format JSON than "all on 1
line with spaces to make Ratatui wrapping work". But I think that works
OK for now.
2025-06-03 14:29:26 -07:00
Michael Bolin 1c581c5d76 Merge 4f2686bb18 into sapling-pr-archive-bolinfest 2025-06-03 14:15:31 -07:00
Michael Bolin 4f2686bb18 feat: add support for login with ChatGPT 2025-06-03 14:15:12 -07:00
Michael Bolin c6fcec55fe fix: always send full instructions when using the Responses API (#1207)
This fixes a longstanding error in the Rust CLI where `codex.rs`
contained an errant `is_first_turn` check that would exclude the user
instructions for subsequent "turns" of a conversation when using the
responses API (i.e., when `previous_response_id` existed).

While here, renames `Prompt.instructions` to `Prompt.user_instructions`
since we now have quite a few levels of instructions floating around.
Also removed an unnecessary use of `clone()` in
`Prompt.get_full_instructions()`.
codex-rs-45519e12f39777b65c05ed498503ddcb60beb289-1-rust-v0.0.2506030956
2025-06-03 09:40:19 -07:00