Commit Graph

951 Commits

Author SHA1 Message Date
Michael Bolin
dc210fcfe4 merge commit for archive created by Sapling 2025-05-08 23:23:13 -07:00
Michael Bolin
eeda502171 fix: make McpConnectionManager tolerant of MCPs that fail to start 2025-05-08 23:23:07 -07:00
Michael Bolin
371e236185 Merge 009403b02b into sapling-pr-archive-bolinfest 2025-05-08 23:16:24 -07:00
Michael Bolin
009403b02b fix: make McpConnectionManager tolerant of MCPs that fail to start 2025-05-08 23:16:16 -07:00
Michael Bolin
b940adae8e fix: get responses API working again in Rust (#872)
I inadvertently regressed support for the Responses API when adding
support for the chat completions API in
https://github.com/openai/codex/pull/862. This should get both APIs
working again, but the chat completions codepath seems more complex than
necessary. I'll try to clean that up shortly, but I want to get things
working again ASAP.
2025-05-08 22:49:15 -07:00
Michael Bolin
b40c62362e Merge 5530786d9c into sapling-pr-archive-bolinfest 2025-05-08 22:44:59 -07:00
Michael Bolin
5530786d9c fix: get responses API working again in Rust 2025-05-08 22:44:52 -07:00
Michael Bolin
990c9ba727 Merge 88d1c77431 into sapling-pr-archive-bolinfest 2025-05-08 22:44:41 -07:00
Michael Bolin
88d1c77431 fix: get responses API working again in Rust 2025-05-08 22:44:34 -07:00
Michael Bolin
e924070cee feat: support the chat completions API in the Rust CLI (#862)
This is a substantial PR to add support for the chat completions API,
which in turn makes it possible to use non-OpenAI model providers (just
like in the TypeScript CLI):

* It moves a number of structs from `client.rs` to `client_common.rs` so
they can be shared.
* It introduces support for the chat completions API in
`chat_completions.rs`.
* It updates `ModelProviderInfo` so that `env_key` is `Option<String>`
instead of `String` (for e.g., ollama) and adds a `wire_api` field
* It updates `client.rs` to choose between `stream_responses()` and
`stream_chat_completions()` based on the `wire_api` for the
`ModelProviderInfo`
* It updates the `exec` and TUI CLIs to no longer fail if the
`OPENAI_API_KEY` environment variable is not set
* It updates the TUI so that `EventMsg::Error` is displayed more
prominently when it occurs, particularly now that it is important to
alert users to the `CodexErr::EnvVar` variant.
* `CodexErr::EnvVar` was updated to include an optional `instructions`
field so we can preserve the behavior where we direct users to
https://platform.openai.com if `OPENAI_API_KEY` is not set.
* Cleaned up the "welcome message" in the TUI to ensure the model
provider is displayed.
* Updated the docs in `codex-rs/README.md`.

To exercise the chat completions API from OpenAI models, I added the
following to my `config.toml`:

```toml
model = "gpt-4o"
model_provider = "openai-chat-completions"

[model_providers.openai-chat-completions]
name = "OpenAI using Chat Completions"
base_url = "https://api.openai.com/v1"
env_key = "OPENAI_API_KEY"
wire_api = "chat"
```

Though to test a non-OpenAI provider, I installed ollama with mistral
locally on my Mac because ChatGPT said that would be a good match for my
hardware:

```shell
brew install ollama
ollama serve
ollama pull mistral
```

Then I added the following to my `~/.codex/config.toml`:

```toml
model = "mistral"
model_provider = "ollama"
```

Note this code could certainly use more test coverage, but I want to get
this in so folks can start playing with it.

For reference, I believe https://github.com/openai/codex/pull/247 was
roughly the comparable PR on the TypeScript side.
2025-05-08 21:46:06 -07:00
Michael Bolin
d754120924 Merge bf8a38663a into sapling-pr-archive-bolinfest 2025-05-08 21:37:04 -07:00
Michael Bolin
bf8a38663a feat: support the chat completions API in the Rust CLI 2025-05-08 21:37:00 -07:00
Michael Bolin
1690a080de merge commit for archive created by Sapling 2025-05-08 16:41:41 -07:00
Michael Bolin
f216606834 feat: support the chat completions API in the Rust CLI 2025-05-08 16:41:34 -07:00
Michael Bolin
f458d391c1 Merge fb3a17e809 into sapling-pr-archive-bolinfest 2025-05-08 16:37:27 -07:00
Michael Bolin
fb3a17e809 feat: support the chat completions API in the Rust CLI 2025-05-08 16:37:20 -07:00
Michael Bolin
a538e6acb2 fix: use continue-on-error: true to tidy up GitHub Action (#871)
I installed the GitHub Actions extension for VS Code and it started
giving me lint warnings about this line:


a9adb4175c/.github/workflows/rust-ci.yml (L99)

Using an env var to track the state of individual steps was not great,
so I did some research about GitHub actions, which led to the discovery
of combining `continue-on-error: true` with `if .. steps.STEP.outcome ==
'failure'...`.

Apparently there is also a `failure()` macro that is supposed to make
this simpler, but I saw a number of complains online about it not
working as expected. Checking `outcome` seems maybe more reliable at the
cost of being slightly more verbose.
2025-05-08 16:21:11 -07:00
Michael Bolin
e4e3b3399e merge commit for archive created by Sapling 2025-05-08 16:17:09 -07:00
Michael Bolin
9991cb43f6 fix: use continue-on-error: true to tidy up GitHub Action 2025-05-08 16:16:59 -07:00
Michael Bolin
9ca1a68541 merge commit for archive created by Sapling 2025-05-08 16:12:43 -07:00
Michael Bolin
6cb677f2ab fix: use continue-on-error: true to tidy up GitHub Action 2025-05-08 16:12:33 -07:00
Michael Bolin
aac4fbd28d merge commit for archive created by Sapling 2025-05-08 16:11:27 -07:00
Michael Bolin
c9e9b1b365 fix: use continue-on-error: true to tidy up GitHub Action 2025-05-08 16:11:19 -07:00
Michael Bolin
a9adb4175c fix: enable clippy on tests (#870)
https://github.com/openai/codex/pull/855 added the clippy warning to
disallow `unwrap()`, but apparently we were not verifying that tests
were "clippy clean" in CI, so I ended up with a lot of local errors in
VS Code.

This turns on the check in CI and fixes the offenders.
2025-05-08 16:02:56 -07:00
Michael Bolin
35d7d23da4 Merge 81b854604e into sapling-pr-archive-bolinfest 2025-05-08 15:57:30 -07:00
Michael Bolin
81b854604e fix: enable clippy on tests 2025-05-08 15:57:24 -07:00
Michael Bolin
bda6cf4db9 Merge f0498675b6 into sapling-pr-archive-bolinfest 2025-05-08 15:53:18 -07:00
Michael Bolin
f0498675b6 fix: enable clippy on tests 2025-05-08 15:53:13 -07:00
Michael Bolin
c977e80515 Merge b07e74a95e into sapling-pr-archive-bolinfest 2025-05-08 15:40:16 -07:00
Michael Bolin
b07e74a95e fix: enable clippy on tests 2025-05-08 15:40:08 -07:00
Michael Bolin
2b5e41db65 Merge a32d8f8e3b into sapling-pr-archive-bolinfest 2025-05-08 15:17:39 -07:00
Michael Bolin
a32d8f8e3b feat: support the chat completions API in the Rust CLI 2025-05-08 15:17:29 -07:00
Michael Bolin
699ec5a87f fix: remove wrapping in Rust TUI that was incompatible with scrolling math (#868)
I noticed that sometimes I would enter a new message, but it would not
show up in the conversation history. Even if I focused the conversation
history and tried to scroll it to the bottom, I could not bring it into
view. At first, I was concerned that messages were not making it to the
UI layer, but I added debug statements and verified that was not the
issue.

It turned out that, previous to this PR, lines that are wider than the
viewport take up multiple lines of vertical space because `wrap()` was
set on the `Paragraph` inside the scroll pane. Unfortunately, that broke
our "scrollbar math" that assumed each `Line` contributes one line of
height in the UI.

This PR removes the `wrap()`, but introduces a new issue, which is that
now you cannot see long lines without resizing your terminal window. For
now, I filed an issue here:

https://github.com/openai/codex/issues/869

I think the long-term fix is to fix our math so it calculates the height
of a `Line` after it is wrapped given the current width of the viewport.
2025-05-08 15:17:17 -07:00
Michael Bolin
cc48304d61 Merge 3d676c3032 into sapling-pr-archive-bolinfest 2025-05-08 15:09:40 -07:00
Michael Bolin
3d676c3032 fix: remove wrapping in Rust TUI that was incompatible with scrolling math 2025-05-08 15:09:33 -07:00
Michael Bolin
55807005da Merge e57d102e88 into sapling-pr-archive-bolinfest 2025-05-08 13:55:53 -07:00
Michael Bolin
e57d102e88 feat: support the chat completions API in the Rust CLI 2025-05-08 13:55:49 -07:00
Michael Bolin
5decf2267c merge commit for archive created by Sapling 2025-05-08 13:53:25 -07:00
Michael Bolin
f403b25c84 feat: support the chat completions API in the Rust CLI 2025-05-08 13:53:11 -07:00
Michael Bolin
9bfed3a8fd Merge f45974fcf6 into sapling-pr-archive-bolinfest 2025-05-08 13:47:11 -07:00
Michael Bolin
f45974fcf6 feat: support the chat completions API in the Rust CLI 2025-05-08 13:47:07 -07:00
Michael Bolin
fb6dab2afc merge commit for archive created by Sapling 2025-05-08 13:25:11 -07:00
Michael Bolin
6f37f2d828 feat: support the chat completions API in the Rust CLI 2025-05-08 13:25:05 -07:00
Michael Bolin
ca37891b68 merge commit for archive created by Sapling 2025-05-08 12:57:54 -07:00
Michael Bolin
294634377b feat: support the chat completions API in the Rust CLI 2025-05-08 12:57:49 -07:00
Michael Bolin
fbbc809820 merge commit for archive created by Sapling 2025-05-08 12:44:47 -07:00
Michael Bolin
81fc1307d5 feat: support the chat completions API in the Rust CLI 2025-05-08 12:44:41 -07:00
Michael Bolin
833a96d0b9 merge commit for archive created by Sapling 2025-05-08 12:41:49 -07:00
Michael Bolin
dd4f0453d5 feat: support the chat completions API in the Rust CLI 2025-05-08 12:41:43 -07:00
Michael Bolin
e02ffee98d merge commit for archive created by Sapling 2025-05-08 12:35:18 -07:00