Commit Graph

2142 Commits

Author SHA1 Message Date
Michael Bolin
f37bd14c85 Merge 353e71da70 into sapling-pr-archive-bolinfest 2025-07-22 14:52:39 -07:00
Michael Bolin
353e71da70 feat: support dotenv 2025-07-22 14:52:34 -07:00
Michael Bolin
3ef544fb95 chore: for release build, build specific targets instead of --all-targets (#1656)
I noticed that releases have taken longer and longer to build.
Originally, I think I did `--all-targets` to be confident that
everything builds cleanly, but that's really the job of CI that runs on
`main`, so we're spending a lot of time in `rust-release.yml` for not
that much additional signal.
2025-07-22 14:35:50 -07:00
Michael Bolin
9795d06ebb Merge 5047dd7c25 into sapling-pr-archive-bolinfest 2025-07-22 14:08:21 -07:00
Michael Bolin
5047dd7c25 chore: for release build, build specific targets instead of --all-targets 2025-07-22 14:08:14 -07:00
Michael Bolin
07da6f346c Merge b6c6745aab into sapling-pr-archive-bolinfest 2025-07-22 14:07:59 -07:00
Michael Bolin
b6c6745aab chore: for release build, build specific targets instead of --all-targets 2025-07-22 14:07:50 -07:00
aibrahim-oai
01c0896f0f Adding interrupt Support to MCP (#1646) 2025-07-22 20:33:49 +00:00
Michael Bolin
2246175efd Merge afb94dee66 into sapling-pr-archive-bolinfest 2025-07-22 10:58:28 -07:00
Michael Bolin
afb94dee66 feat: support dotenv 2025-07-22 10:58:18 -07:00
Michael Bolin
4082246f6a chore: install an extension for TOML syntax highlighting in the devcontainer (#1650)
Small quality-of-life improvement when doing devcontainer development.
2025-07-22 10:58:09 -07:00
Michael Bolin
fc7a33ae65 Merge 4125af288a into sapling-pr-archive-bolinfest 2025-07-22 10:49:00 -07:00
Michael Bolin
4125af288a feat: support dotenv 2025-07-22 10:48:50 -07:00
Michael Bolin
a87e648071 Merge 1ccd7af0b3 into sapling-pr-archive-bolinfest 2025-07-22 10:45:11 -07:00
Michael Bolin
1ccd7af0b3 feat: support dotenv (including ~/.codex/.env) 2025-07-22 10:45:00 -07:00
Michael Bolin
dfa9a44202 feat: support dotenv 2025-07-22 10:19:42 -07:00
Michael Bolin
41f993a93f Merge d5809ef6ef into sapling-pr-archive-bolinfest 2025-07-22 10:11:13 -07:00
Michael Bolin
d5809ef6ef chore: install an extension for TOML syntax highlighting in the devcontainer 2025-07-22 10:11:07 -07:00
pakrym-oai
6d82907082 Add support for custom base instructions (#1645)
Allows providing custom instructions file as a config parameter and
custom instruction text via MCP tool call.
2025-07-22 09:42:22 -07:00
pakrym-oai
ed206d5687 Log response.failed error message and request-id (#1649)
To help with diagnosing failures.
2025-07-22 09:28:00 -07:00
Michael Bolin
d51654822f fix: use PR_SET_PDEATHSIG so to ensure child processes are killed in a timely manner (#1626)
Some users have reported issues where child processes are not cleaned up
after Codex exits (e.g., https://github.com/openai/codex/issues/1570).

This is generally a tricky issue on operating systems: if a parent
process receives `SIGKILL`, then it terminates immediately and cannot
communicate with the child.

**It only helps on Linux**, but this PR introduces the use of `prctl(2)`
so that if the parent process dies, `SIGTERM` will be delivered to the
child process. Whereas previously, I believe that if Codex spawned a
long-running process (like `tsc --watch`) and the Codex process received
`SIGKILL`, the `tsc --watch` process would be reparented to the init
process and would never be killed. Now with the use of `prctl(2)`, the
`tsc --watch` process should receive `SIGTERM` in that scenario.

We still need to come up with a solution for macOS. I've started to look
at `launchd`, but I'm researching a number of options.
2025-07-22 00:41:27 -07:00
Michael Bolin
79c7804f1b Merge 50755c65b7 into sapling-pr-archive-bolinfest 2025-07-22 00:29:59 -07:00
Michael Bolin
50755c65b7 fix: use PR_SET_PDEATHSIG so to ensure child processes are killed in a timely manner 2025-07-22 00:29:45 -07:00
Gabriel Peal
710f728124 Add an elicitation for approve patch and refactor tool calls (#1642)
1. Added an elicitation for `approve-patch` which is very similar to
`approve-exec`.
2. Extracted both elicitations to their own files to prevent
`codex_tool_runner` from blowing up in size.
2025-07-22 02:58:41 -04:00
Michael Bolin
6cf4b96f9d fix: check flags to ripgrep when deciding whether the invocation is "trusted" (#1644)
With this change, if any of `--pre`, `--hostname-bin`, `--search-zip`, or `-z` are used with a proposed invocation of `rg`, do not auto-approve.
2025-07-21 22:38:50 -07:00
Michael Bolin
23cc9d726b merge commit for archive created by Sapling 2025-07-21 22:03:20 -07:00
Michael Bolin
2511223680 fix 2025-07-21 22:03:13 -07:00
Michael Bolin
a7263bbf97 Merge 022c5dc997 into sapling-pr-archive-bolinfest 2025-07-21 21:55:36 -07:00
Michael Bolin
022c5dc997 fix 2025-07-21 21:55:30 -07:00
Dylan
18b2b30841 [mcp-server] Add reply tool call (#1643)
## Summary
Adds a new mcp tool call, `codex-reply`, so we can continue existing
sessions. This is a first draft and does not yet support sessions from
previous processes.

## Testing
- [x] tested with mcp client
2025-07-21 21:01:56 -07:00
Michael Bolin
6567a14a3d merge commit for archive created by Sapling 2025-07-21 17:13:33 -07:00
Michael Bolin
50f38401d4 fix 2025-07-21 17:13:23 -07:00
Michael Bolin
3d8537b850 Merge 94f1a946ae into sapling-pr-archive-bolinfest 2025-07-21 17:09:11 -07:00
Michael Bolin
94f1a946ae fix 2025-07-21 17:08:58 -07:00
Michael Bolin
4ea6d54de9 Merge ac85a01ea7 into sapling-pr-archive-bolinfest 2025-07-21 10:27:44 -07:00
Michael Bolin
ac85a01ea7 fix: use PR_SET_PDEATHSIG so to ensure child processes are killed in a timely manner 2025-07-21 10:27:34 -07:00
Michael Bolin
d49d802b06 test: add integration test for MCP server (#1633)
This PR introduces a single integration test for `cargo mcp`, though it
also introduces a number of reusable components so that it should be
easier to introduce more integration tests going forward.

The new test is introduced in `codex-rs/mcp-server/tests/elicitation.rs`
and the reusable pieces are in `codex-rs/mcp-server/tests/common`.

The test itself verifies new functionality around elicitations
introduced in https://github.com/openai/codex/pull/1623 (and the fix
introduced in https://github.com/openai/codex/pull/1629) by doing the
following:

- starts a mock model provider with canned responses for
`/v1/chat/completions`
- starts the MCP server with a `config.toml` to use that model provider
(and `approval_policy = "untrusted"`)
- sends the `codex` tool call which causes the mock model provider to
request a shell call for `git init`
- the MCP server sends an elicitation to the client to approve the
request
- the client replies to the elicitation with `"approved"`
- the MCP server runs the command and re-samples the model, getting a
`"finish_reason": "stop"`
- in turn, the MCP server sends the final response to the original
`codex` tool call
- verifies that `git init` ran as expected

To test:

```
cargo test shell_command_approval_triggers_elicitation
```

In writing this test, I discovered that `ExecApprovalResponse` does not
conform to `ElicitResult`, so I added a TODO to fix that, since I think
that should be updated in a separate PR. As it stands, this PR does not
update any business logic, though it does make a number of members of
the `mcp-server` crate `pub` so they can be used in the test.

One additional learning from this PR is that
`std::process::Command::cargo_bin()` from the `assert_cmd` trait is only
available for `std::process::Command`, but we really want to use
`tokio::process::Command` so that everything is async and we can
leverage utilities like `tokio::time::timeout()`. The trick I came up
with was to use `cargo_bin()` to locate the program, and then to use
`std::process::Command::get_program()` when constructing the
`tokio::process::Command`.
2025-07-21 10:27:07 -07:00
Michael Bolin
f5d3cb0dd6 merge commit for archive created by Sapling 2025-07-20 20:09:58 -07:00
Michael Bolin
24a80cf9d7 fix: integration test for MCP server 2025-07-20 20:09:52 -07:00
Michael Bolin
12c516f7ba merge commit for archive created by Sapling 2025-07-20 19:56:42 -07:00
Michael Bolin
111bab0a61 fix: integration test for MCP server 2025-07-20 19:56:19 -07:00
Michael Bolin
d7e6ba42d8 merge commit for archive created by Sapling 2025-07-20 19:44:22 -07:00
Michael Bolin
4640946c05 fix: integration test for MCP server 2025-07-20 19:44:17 -07:00
Michael Bolin
547342b2e1 merge commit for archive created by Sapling 2025-07-20 19:41:26 -07:00
Michael Bolin
69bdec9824 fix: integration test for MCP server 2025-07-20 19:41:20 -07:00
Michael Bolin
0022eeeee5 merge commit for archive created by Sapling 2025-07-20 19:23:30 -07:00
Michael Bolin
78ad35a6a9 fix: integration test for MCP server 2025-07-20 19:23:05 -07:00
Michael Bolin
20d74a9562 merge commit for archive created by Sapling 2025-07-20 19:16:20 -07:00
Michael Bolin
cfd24302bb fix: integration test for MCP server 2025-07-20 19:16:15 -07:00
Michael Bolin
6c9a411cc8 merge commit for archive created by Sapling 2025-07-20 19:15:47 -07:00