Commit Graph
142 Commits
Author SHA1 Message Date
James Peter 2c3d9744fd chore(codex-rs): sync with upstream main 2025-10-05 12:05:06 +10:00
James Peter 224af74fc0 chore(workspace): sync codex tree and finish reset plan 2025-10-05 09:04:09 +10:00
James Peter a674871f82 Merge upstream/main: adopt CLI stdin login and TUI fixes 2025-10-03 23:11:53 +10:00
James Peter 9f4221ec4a feat(protocol): add MCP shim and sync tool stack 2025-10-03 14:36:00 +10:00
pakrym-oaiandGitHub c0ee4ab851 Separate interactive and non-interactive sessions (#4612)
Do not show exec session in VSCode/TUI selector.
2025-10-02 13:06:21 -07:00
Jeremy RoseandGitHub 0619df61ae show "Viewed Image" when the model views an image (#4475)
<img width="1022" height="339" alt="Screenshot 2025-09-29 at 4 22 00 PM"
src="https://github.com/user-attachments/assets/12da7358-19be-4010-a71b-496ede6dfbbf"
/>
2025-10-02 18:36:03 +00:00
James Peter 00e2cc6f69 feat(tui/history): consolidate history state and spinner cadence 2025-10-02 09:46:04 +10:00
Michael BolinandGitHub 0684d9c990 fix: remove mcp-types from app server protocol (#4537)
We continue the separation between `codex app-server` and `codex
mcp-server`.

In particular, we introduce a new crate, `codex-app-server-protocol`,
and migrate `codex-rs/protocol/src/mcp_protocol.rs` into it, renaming it
`codex-rs/app-server-protocol/src/protocol.rs`.

Because `ConversationId` was defined in `mcp_protocol.rs`, we move it
into its own file, `codex-rs/protocol/src/conversation_id.rs`, and
because it is referenced in a ton of places, we have to touch a lot of
files as part of this PR.

We also decide to get away from proper JSON-RPC 2.0 semantics, so we
also introduce `codex-rs/app-server-protocol/src/jsonrpc_lite.rs`, which
is basically the same `JSONRPCMessage` type defined in `mcp-types`
except with all of the `"jsonrpc": "2.0"` removed.

Getting rid of `"jsonrpc": "2.0"` makes our serialization logic
considerably simpler, as we can lean heavier on serde to serialize
directly into the wire format that we use now.
2025-10-01 02:16:26 +00:00
Michael BolinandGitHub 3bd3a714e0 fix: use macros to ensure request/response symmetry (#4529)
Manually curating `protocol-ts/src/lib.rs` was error-prone, as expected.
I finally asked Codex to write some Rust macros so we can ensure that:

- For every variant of `ClientRequest` and `ServerRequest`, there is an
associated `params` and `response` type.
- All response types are included automatically in the output of `codex
generate-ts`.
2025-09-30 18:06:05 -07:00
James Peter c5007007d0 Merge remote-tracking branch 'upstream/main' into code-branch-20250930-131454 2025-10-01 08:07:52 +10:00
Michael BolinandGitHub b97198f0dd fix: ensure every variant of ClientRequest has a params field (#4512)
This ensures changes the generated TypeScript type for `ClientRequest`
so that instead of this:

```typescript
/**
 * Request from the client to the server.
 */
export type ClientRequest =
  | { method: "initialize"; id: RequestId; params: InitializeParams }
  | { method: "newConversation"; id: RequestId; params: NewConversationParams }
  // ...
  | { method: "getUserAgent"; id: RequestId }
  | { method: "userInfo"; id: RequestId }
  // ...
```

we have this:

```typescript
/**
 * Request from the client to the server.
 */
export type ClientRequest =
  | { method: "initialize"; id: RequestId; params: InitializeParams }
  | { method: "newConversation"; id: RequestId; params: NewConversationParams }
  // ...
  | { method: "getUserAgent"; id: RequestId; params: undefined }
  | { method: "userInfo"; id: RequestId; params: undefined }
  // ...
```

which makes TypeScript happier when it comes to destructuring instances
of `ClientRequest` because it does not complain about `params` not being
guaranteed to exist anymore.
2025-09-30 12:03:32 -07:00
James Peter b0e445a4ef chore(merge): prepare workspace for vitual cherry-pick 2025-10-01 04:11:40 +10:00
Michael BolinandGitHub 56e664c6d6 fix: separate codex mcp into codex mcp-server and codex app-server (#4471)
This is a very large PR with some non-backwards-compatible changes.

Historically, `codex mcp` (or `codex mcp serve`) started a JSON-RPC-ish
server that had two overlapping responsibilities:

- Running an MCP server, providing some basic tool calls.
- Running the app server used to power experiences such as the VS Code
extension.

This PR aims to separate these into distinct concepts:

- `codex mcp-server` for the MCP server
- `codex app-server` for the "application server"

Note `codex mcp` still exists because it already has its own subcommands
for MCP management (`list`, `add`, etc.)

The MCP logic continues to live in `codex-rs/mcp-server` whereas the
refactored app server logic is in the new `codex-rs/app-server` folder.
Note that most of the existing integration tests in
`codex-rs/mcp-server/tests/suite` were actually for the app server, so
all the tests have been moved with the exception of
`codex-rs/mcp-server/tests/suite/mod.rs`.

Because this is already a large diff, I tried not to change more than I
had to, so `codex-rs/app-server/tests/common/mcp_process.rs` still uses
the name `McpProcess` for now, but I will do some mechanical renamings
to things like `AppServer` in subsequent PRs.

While `mcp-server` and `app-server` share some overlapping functionality
(like reading streams of JSONL and dispatching based on message types)
and some differences (completely different message types), I ended up
doing a bit of copypasta between the two crates, as both have somewhat
similar `message_processor.rs` and `outgoing_message.rs` files for now,
though I expect them to diverge more in the near future.

One material change is that of the initialize handshake for `codex
app-server`, as we no longer use the MCP types for that handshake.
Instead, we update `codex-rs/protocol/src/mcp_protocol.rs` to add an
`Initialize` variant to `ClientRequest`, which takes the `ClientInfo`
object we need to update the `USER_AGENT_SUFFIX` in
`codex-rs/app-server/src/message_processor.rs`.

One other material change is in
`codex-rs/app-server/src/codex_message_processor.rs` where I eliminated
a use of the `send_event_as_notification()` method I am generally trying
to deprecate (because it blindly maps an `EventMsg` into a
`JSONNotification`) in favor of `send_server_notification()`, which
takes a `ServerNotification`, as that is intended to be a custom enum of
all notification types supported by the app server. So to make this
update, I had to introduce a new variant of `ServerNotification`,
`SessionConfigured`, which is a non-backwards compatible change with the
old `codex mcp`, and clients will have to be updated after the next
release that contains this PR. Note that
`codex-rs/app-server/tests/suite/list_resume.rs` also had to be update
to reflect this change.

I introduced `codex-rs/utils/json-to-toml/src/lib.rs` as a small utility
crate to avoid some of the copying between `mcp-server` and
`app-server`.
2025-09-30 07:06:18 +00:00
dedrisian-oaiandGitHub 107df6e0d7 Custom prompts begin with /prompts: (#4476)
<img width="608" height="354" alt="Screenshot 2025-09-29 at 4 41 08 PM"
src="https://github.com/user-attachments/assets/162508eb-c1ac-4bc0-95f2-5e23cb4ae428"
/>
2025-09-29 17:58:16 -07:00
dedrisian-oaiandGitHub 8abfd67115 Parse out frontmatter for custom prompts (#4456)
[Cherry picked from https://github.com/openai/codex/pull/3565]

Removes the frontmatter description/args from custom prompt files and
only includes body.
2025-09-29 13:06:08 -07:00
DylanandGitHub b275eba756 [mcp-server] Expose fuzzy file search in MCP (#2677)
## Summary
Expose a simple fuzzy file search implementation for mcp clients to work
with

## Testing
- [x] Tested locally
2025-09-29 12:19:09 -07:00
vishnu-oaiandGitHub 00e9385e78 OpenTelemetry events (#2103)
### Title

## otel

Codex can emit [OpenTelemetry](https://opentelemetry.io/) **log events**
that
describe each run: outbound API requests, streamed responses, user
input,
tool-approval decisions, and the result of every tool invocation. Export
is
**disabled by default** so local runs remain self-contained. Opt in by
adding an
`[otel]` table and choosing an exporter.

```toml
[otel]
environment = "staging"   # defaults to "dev"
exporter = "none"          # defaults to "none"; set to otlp-http or otlp-grpc to send events
log_user_prompt = false    # defaults to false; redact prompt text unless explicitly enabled
```

Codex tags every exported event with `service.name = "codex-cli"`, the
CLI
version, and an `env` attribute so downstream collectors can distinguish
dev/staging/prod traffic. Only telemetry produced inside the
`codex_otel`
crate—the events listed below—is forwarded to the exporter.

### Event catalog

Every event shares a common set of metadata fields: `event.timestamp`,
`conversation.id`, `app.version`, `auth_mode` (when available),
`user.account_id` (when available), `terminal.type`, `model`, and
`slug`.

With OTEL enabled Codex emits the following event types (in addition to
the
metadata above):

- `codex.api_request`
  - `cf_ray` (optional)
  - `attempt`
  - `duration_ms`
  - `http.response.status_code` (optional)
  - `error.message` (failures)
- `codex.sse_event`
  - `event.kind`
  - `duration_ms`
  - `error.message` (failures)
  - `input_token_count` (completion only)
  - `output_token_count` (completion only)
  - `cached_token_count` (completion only, optional)
  - `reasoning_token_count` (completion only, optional)
  - `tool_token_count` (completion only)
- `codex.user_prompt`
  - `prompt_length`
  - `prompt` (redacted unless `log_user_prompt = true`)
- `codex.tool_decision`
  - `tool_name`
  - `call_id`
- `decision` (`approved`, `approved_for_session`, `denied`, or `abort`)
  - `source` (`config` or `user`)
- `codex.tool_result`
  - `tool_name`
  - `call_id`
  - `arguments`
  - `duration_ms` (execution time for the tool)
  - `success` (`"true"` or `"false"`)
  - `output`

### Choosing an exporter

Set `otel.exporter` to control where events go:

- `none` – leaves instrumentation active but skips exporting. This is
the
  default.
- `otlp-http` – posts OTLP log records to an OTLP/HTTP collector.
Specify the
  endpoint, protocol, and headers your collector expects:

  ```toml
  [otel]
  exporter = { otlp-http = {
    endpoint = "https://otel.example.com/v1/logs",
    protocol = "binary",
    headers = { "x-otlp-api-key" = "${OTLP_TOKEN}" }
  }}
  ```

- `otlp-grpc` – streams OTLP log records over gRPC. Provide the endpoint
and any
  metadata headers:

  ```toml
  [otel]
  exporter = { otlp-grpc = {
    endpoint = "https://otel.example.com:4317",
    headers = { "x-otlp-meta" = "abc123" }
  }}
  ```

If the exporter is `none` nothing is written anywhere; otherwise you
must run or point to your
own collector. All exporters run on a background batch worker that is
flushed on
shutdown.

If you build Codex from source the OTEL crate is still behind an `otel`
feature
flag; the official prebuilt binaries ship with the feature enabled. When
the
feature is disabled the telemetry hooks become no-ops so the CLI
continues to
function without the extra dependencies.

---------

Co-authored-by: Hanzo Dev <[email protected]>
2025-09-29 11:30:55 -07:00
James Peter 336a07b7e7 Merge origin/upstream-merge: reconcile rate limit snapshot schema 2025-09-25 12:19:17 +10:00
James Peter 7067a071e6 feat(tui/history): extract deterministic cell state modules 2025-09-25 11:09:47 +10:00
just-every-code b3810b12f3 merge(upstream): merge upstream/main into upstream-merge
- Keep our TUI and workflows per policy
- Preserve rate-limit event type (RateLimitSnapshotEvent) in core/client
- Restore SavedSession/SessionStateSnapshot for resume compat in rollout recorder
- Adopt upstream in common/core areas where compatible

Status: ./build-fast.sh OK; verify.sh build_fast=ok api_check=ok
2025-09-24 15:51:34 +00:00
Ahmed IbrahimandGitHub 9a24251b69 Add Reset in for rate limits (#4111)
- Parse the headers
- Reorganize the struct because it's getting too long
- show the resets at in the tui

<img width="324" height="79" alt="image"
src="https://github.com/user-attachments/assets/ca15cd48-f112-4556-91ab-1e3a9bc4683d"
/>
2025-09-24 15:31:08 +00:00
James Peter 13e55be8fc Merge upstream-merge: bring pro observer and readiness updates 2025-09-24 09:47:07 +10:00
just-every-code 25cd98b068 merge(upstream): by-bucket sync with openai/codex@main
- Keep forked core/TUI (browser/agent tools, strict ordering, UA/version)
- Adopt safe upstream changes in shared crates; wire rate-limit events
- Preserve core RateLimitSnapshotEvent; adapt client imports accordingly

Status: verify.sh PASS; build-fast.sh PASS (no warnings)
2025-09-23 23:34:06 +00:00
Ahmed IbrahimandGitHub c07f49604a Send limits when getting rate limited (#4102)
Users need visibility on rate limits when they are rate limited.
2025-09-23 22:56:34 +00:00
just-every-code 75becf25c9 merge(upstream): incorporate openai/codex@main into upstream-merge
- Adopt upstream changes in exec, mcp-server, and common by bucket.
- Preserve fork-specific core (codex.rs, browser/agent tools, UA/version).
- Add Prompt.output_schema; keep our Text controls; adjust tests.
- Fallback to Op::UserInput for UserTurn in exec and MCP.
- Keep ours for core codex files to preserve TUI/stream ordering.

verify.sh: pass; build-fast.sh: pass (no warnings).
2025-09-23 21:30:54 +00:00
pakrym-oaiandGitHub 2804e9b73e Add exec output-schema parameter (#4079)
Adds structured output to `exec` via the `--structured-output`
parameter.
2025-09-23 13:59:16 -07:00
just-every-code 19d50c1f7e merge(upstream): upstream main into upstream-merge using by-bucket policy\n\n- Prefer ours for MCP server files to preserve UA/tool invariants\n- Adopt upstream for Cargo.lock and protocol updates\n- Purged any reintroduced CLI image assets 2025-09-23 20:43:34 +00:00
pakrym-oaiandGitHub f8367522f6 Use anyhow::Result in tests for error propagation (#4105) 2025-09-23 13:31:36 -07:00
James Peter 4ec497e492 feat(review): add scoped picker and metadata flow 2025-09-24 05:31:41 +10:00
just-every-code 83d48aa8a4 merge(upstream): by-bucket merge upstream/main into upstream-merge\n\n- Keep ours for TUI fixtures; purge binary-size-log.jsonl\n- Adopt upstream MCP typed config tests (GetUserSavedConfigResponse)\n- Sync defaults to gpt-5-codex where applicable\n\nverify.sh: PASS; build-fast.sh: PASS 2025-09-23 03:40:47 +00:00
James Peter f52a1d0168 feat(review): carry metadata to main thread and enrich summary 2025-09-23 13:17:13 +10:00
Thibault SottiauxandGitHub 585432f0fd feat: update default (#4076)
Changes:
- Default model and docs now use gpt-5-codex. 
- Disables the GPT-5 Codex NUX by default.
- Keeps presets available for API key users.
2025-09-22 20:10:52 -07:00
just-every-code 18b12894d9 Merge upstream/main: adopt rate limit struct changes; keep TUI behavior
- Prefer ours for TUI conflicted files (chatwidget.rs, history_cell.rs)
- Adopt upstream protocol rate limit renames (primary/secondary)
- Update core + exec + TUI to new fields and labels
- Purge check: no reintroduced images
- verify.sh + build-fast.sh: pass (zero warnings)
2025-09-22 21:24:09 +00:00
Ahmed IbrahimandGitHub facc6901f6 Change headers and struct of rate limits (#4060) 2025-09-22 21:06:20 +00:00
James Peter edccb279f1 feat(acp): integrate ACP support and rename MCP server 2025-09-22 13:17:51 +10:00
just-every-code 40549c44e4 merge(upstream): adopt upstream/main into upstream-merge; preserve core/codex.rs and fork tool behaviors; include upstream RateLimits stream event; pass verify + build-fast 2025-09-21 04:54:30 +00:00
Ahmed IbrahimandGitHub c440823d68 Forward Rate limits to the UI (#3965)
We currently get information about rate limits in the response headers.
We want to forward them to the clients to have better transparency.
UI/UX plans have been discussed and this information is needed.
2025-09-20 21:26:16 -07:00
James Peter 1b0c220715 feat(approval): add semantic prefix matching 2025-09-19 14:03:22 +10:00
James Peter deb150a4f4 Merge origin/upstream-merge: adopt MCP conversation id refactor 2025-09-19 09:45:42 +10:00
just-every-code 2811c2f365 merge: upstream main into upstream-merge (preserve core/TUI, adapt exec). build-fast ok 2025-09-18 21:33:38 +00:00
dedrisian-oaiandGitHub 36bd3c910d feat: /review (#3774)
Adds `/review` action in TUI

<img width="637" height="370" alt="Screenshot 2025-09-17 at 12 41 19 AM"
src="https://github.com/user-attachments/assets/b1979a6e-844a-4b97-ab20-107c185aec1d"
/>
2025-09-18 14:14:16 -07:00
just-every-code 9dc353a653 merge(upstream): incorporate upstream main into upstream-merge
- Align ConversationId API to upstream; add From conversions
- Keep MCP server UA semantics and disable login flows in server
- Preserve ICU/sys-locale deps; keep uuid v4 usage
- Minimal fixes to core + recorder for new id type

Build: verify.sh ok; build-fast.sh ok (no warnings)
2025-09-18 15:07:28 +00:00
pakrym-oaiandGitHub ff528bf0c3 Switch to uuid_v7 and tighten ConversationId usage (#3819)
Make sure conversations have a timestamp.
2025-09-18 14:37:03 +00:00
James Peter 8bdd190a1c Queue user prompts into next request 2025-09-18 21:05:16 +10:00
James Peter f83caff5f7 Merge branch 'code-branch-20250916-172734' into main 2025-09-18 12:21:18 +10:00
James Peter 9d6fbd1989 fix(resume): restore full history replay 2025-09-18 11:56:22 +10:00
James Peter e0c54a7769 feat: add plan names and terminal title sync 2025-09-17 15:47:52 +10:00
James Peter 24f4629af5 Add Exploring support for read-only git commands 2025-09-17 09:32:44 +10:00
just-every-code 7e82930009 Merge upstream/main: preserve TUI/tooling; adopt core updates (verify.sh ok, build-fast: zero warnings) 2025-09-15 01:30:16 +00:00
dedrisian-oaiandGitHub 9cfc23e4a1 Fix EventMsg Optional (#3604) 2025-09-15 00:34:33 +00:00