Commit Graph
834 Commits
Author SHA1 Message Date
iceweasel-oai 80d0a67185 Share runtime registration across app-server startup clients (#65106)
## Why

Statsig starts before the model catalog. When runtime agent instances are
enabled, separate auth managers can cause Statsig and model discovery to
register the same app-server runtime twice.

## What changed

Pass a shared runtime auth slot to Statsig and model discovery in both
standalone and in-process app-server startup so they use the same runtime
registration.

## Testing

Extend the CLI startup integration test to require exactly one runtime
registration and verify that both Statsig evaluations and model discovery
send `AgentAssertion` authorization headers.

GitOrigin-RevId: 132521b685c5c7c617e7067c648de65b9a4287b2
2026-12-01 23:12:29 +00:00
Eric Traut 75c48af16f Support --search with the shared background server (#65103)
## Why

Launching Codex with `--search` forced the TUI into embedded mode, even when the shared background server was available.

## What changed

Treat `--search` as a per-thread request for live web search. Check daemon eligibility before applying the flag, and restore the launch setting when reconnecting to an unloaded conversation or reopening an unloaded saved side chat.

## Testing

Cover daemon startup with `--search` and verify that a conversation retains its history and search behavior across a daemon restart. Check that worktree launches honor the flag per invocation and that reattaching to an already loaded side chat leaves its search settings intact.

GitOrigin-RevId: 9d15ec3d103383d80442e07845442341f6da6727
2026-12-01 23:03:41 +00:00
vishnu-oai 4c75131c9c Validate config server policy before replacing login credentials (#65066)
## Why

An explicit `codex login` can reuse a saved config server grant, leaving
users without a way to switch accounts through that command. Saving a new
grant before validating its managed configuration can also displace a
working session if the policy fetch or validation fails.

## What changed

- Start a fresh config server sign-in for explicit browser and device-code
  logins, even when a grant is already saved.
- Hold the new grant in memory while fetching and validating its managed
  configuration. Save the grant and then update the policy cache after
  validation succeeds.
- Recheck config server and proxy settings and reload local network rules
  before fetching policy. Reject logout while a config server sign-in owns
  the login lock, including during the first sign-in.

## Testing

Cover successful grant replacement and preservation of the saved grant
when authorization, policy fetch, or policy validation fails. Verify that
network restrictions can block the policy fetch and that logout detects
an in-progress first sign-in.

GitOrigin-RevId: 427a70d556f92fd96c43f6e8737371aa3651e70c
2026-12-01 19:33:48 +00:00
Benjamin Carlsson 854e723882 Add --cloud to launch interactive Codex sessions on Cloud (#65063)
## What changed

- Select the Codex Cloud backend at startup with `codex --cloud`,
  `codex agents --cloud`, or `codex resume --cloud`.
- Use `--env <ENV_ID>` to select a saved Cloud environment for new
  threads. Resume by picker, most recent session, ID, or name using the
  thread's saved environment and model.
- Reject local execution overrides and managed execution requirements
  that Cloud cannot enforce. Recheck managed requirements for the
  ChatGPT workspace selected when connecting.

## Testing

Cover initial prompt delivery, resume by ID and name, and rejection of
unsupported settings, including managed execution requirements from a
workspace selected after startup configuration was loaded.

GitOrigin-RevId: 6144decb9679f903607a586466cff37e402ab4a4
2026-12-01 19:17:41 +00:00
Eric Traut b6087365cd Repair app-server daemon packages with update --from-cli (#65046)
## Why

A daemon with a dangling package selection or a missing executable can
fail to start, and leftover logs can make an absent installation look
like an existing one.

## What changed

- Let `codex app-server daemon update --from-cli` install or repair and
  pin the daemon from a complete CLI package. Point missing-executable
  errors to that command. Repair checks that the daemon and updater are
  stopped and that the package selection has stayed unchanged.
- Let `codex app-server daemon start` bootstrap a missing installation
  even when old daemon logs remain. Use legacy logs to infer a stopped
  standalone installation only when its package selection still exists
  and dedicated daemon logs are absent.
- Allow repair to replace a dangling Windows junction whose target is
  directly under the daemon's releases directory.

## Testing

Extend coverage for startup with leftover logs, package repair after
losing the selection or executable, repair blocked by a starting
daemon or updater, and replacement of a dangling Windows junction.

GitOrigin-RevId: 679266cc22b7ff7a34bbd41c2bf0659d3068eb75
2026-12-01 17:56:54 +00:00
Eric Traut 09984ca85d Fix app-server daemon startup with BusyBox ps (#65043)
## Why

BusyBox `ps` can reject the arguments Codex uses to read a process start
time. That failure prevents the managed app-server daemon and updater
from starting even when Linux can identify both processes through `/proc`.

## What changed

On Linux, allow startup to proceed when the `ps` lookup fails and
`/proc` identifies a live process. Store that identity in the PID record
with an empty legacy start timestamp.

## Testing

Add a Linux CLI regression test that substitutes a failing `ps`, checks
both PID records for a process identity and an empty legacy timestamp,
and verifies that `daemon version` reports the daemon running and
`daemon stop` stops it.

GitOrigin-RevId: fc82e0e32a62ffbb1dc1683403757f3ab109000a
2026-12-01 17:52:27 +00:00
Eric Traut e14750e0b9 Preserve the exit summary when Ctrl+C is pressed again on Windows (#65038)
## Why

Once the TUI restores the terminal, another Ctrl+C becomes a Windows
console event and can terminate Codex before it prints the exit summary,
including the resume hint when available. The npm launcher can also
force-terminate the child by forwarding a Ctrl+C that Windows already
delivered to it.

## What changed

Register a Windows Ctrl+C listener before restoring the terminal and keep
it alive until the CLI or standalone TUI finishes printing the exit
summary. Skip forwarding `SIGINT` from the npm launcher on Windows.

## Testing

Add a Windows regression test that simulates `SIGINT` in the npm launcher
and checks that the child can finish and report its own exit code.

GitOrigin-RevId: cd73a4a2ecc22812bc301787e67c349f7720a93b
2026-12-01 17:07:18 +00:00
alexsong-oai 945cf1400b Enable the gateway setup wizard by default (#64791)
## What changed

Offer “Use a custom provider or gateway” in eligible terminal sign-in flows
without requiring users to set `features.gateway_setup_wizard = true`.

## Testing

Exercise the default in the gateway onboarding test, which verifies that the
selected gateway authenticates before receiving the first chat request.

GitOrigin-RevId: e140b13dc12ebe9b35f37711d5b088fd02a0707c
2026-11-30 19:07:18 +00:00
alexsong-oai 4c82954eb0 Select the Amazon Bedrock Runtime provider during TUI onboarding (#64790)
## Why

When the TUI omitted the provider ID, the app server defaulted to
`amazon-bedrock`. Bedrock onboarding needs to select `amazon-bedrock-runtime`
for the first thread.

## What changed

Pass `AmazonBedrockRuntime` explicitly when onboarding with an API key, an
AWS profile, environment credentials, or manually entered AWS credentials.

## Testing

Extend the daemon startup integration test to accept credentials detected in
the running daemon and verify that the first thread shows
`amazon-bedrock-runtime` in the status line. The test leaves the model unset
so the thread uses the selected provider's catalog.

GitOrigin-RevId: 57753a29c77b0bd1bcbb0494057770329cd0b67d
2026-11-30 19:06:01 +00:00
Felipe Coury f92681791d Open /status in an interactive TUI modal (#64772)
## Why

Rate limits and thread usage can arrive after `/status` is displayed.
Updating a status card already in terminal scrollback required rewriting
history and depended on where the card was rendered.

## What changed

- Show the report in a scrollable modal with Overview, Configuration, and
  Session tabs. Apply rate limit and thread usage results to the open report
  without writing status output to the transcript or terminal scrollback.
- Copy a selected field or the full report directly from the modal, and open
  usage settings from the same view. Remove status fields from the `/copy`
  picker.

## Testing

Add coverage for overlapping refreshes, dismissal during account or thread
changes, keyboard navigation and copying during an active turn, and scrolling
in a narrow terminal.

GitOrigin-RevId: 64961c4d013607e373d50a79182b74e3048c632f
2026-11-30 17:40:02 +00:00
smurching-oai f0f1040931 Allow local MCP HTTP header helpers to receive selected env vars (#64672)
## Why

Local MCP HTTP header helpers run with a restricted environment. A helper that needs a host setting such as `HTTPS_PROXY` needs a way to receive that variable while keeping the rest of the host environment restricted.

## What changed

- Add `http_headers_helper_env_vars` for local Streamable HTTP servers. A nonempty list requires the server URL and an absolute helper executable path in the same user or administrator configuration entry. Codex launches that executable directly, and Windows requires an `.exe` path. Helper entries without the list retain shell command syntax.
- Revoke inherited access when a higher-priority entry overrides the URL, helper, or variable list. An empty list explicitly clears an inherited grant.
- Show effective variable names in `codex mcp get` and the JSON output of `codex mcp list`, while keeping helper commands and variable values out of the output. Make `codex mcp add` and `codex mcp remove` edit only the named server so unrelated grants stay in their original configuration layer.

## Testing

Add coverage for grant validation and revocation, variable forwarding during OAuth startup and header refresh, CLI redaction, and preservation of administrator grants during unrelated CLI edits.

GitOrigin-RevId: d1ebdcf4dbd7946c0f3bfb982464a0024768d585
2026-11-30 04:08:38 +00:00
jif 923c098613 Drop the child session during Statsig startup test cleanup (#64152)
After observing the expected Statsig request, drop the child session
before awaiting its exit. This uses the process handle's existing
cleanup to terminate the child and stop its I/O tasks.

GitOrigin-RevId: 17be552b74f7539ab46bbb4cb9dfa3bf9697ee08
2026-11-26 13:53:26 +00:00
Felipe Coury 1d05b9851c Show Command Center shortcuts that match focus and input (#64025)
## Why

The Command Center can show action shortcuts while the conversation has
keyboard focus or while a search or rename field consumes those keys.

## What changed

Use the shared footer renderer to show a focus shortcut in the unfocused
Command Center and action hints when it has focus. Keep the editor cursor
in the active pane and hide header shortcuts when their actions are
unavailable. For example, the default `g` grouping hint disappears while
typing a search because `g` goes into the query.

## Testing

Extend the workspace navigation test to check the focus hint and cover
custom accept and grouping bindings during search and rename.

GitOrigin-RevId: a96a093b77b6ef04d717b542e30b041164d1210c
2026-11-26 00:33:01 +00:00
iceweasel-oai f39c3c78d7 Initialize Statsig feature gates across Codex launch modes (#64001)
## Why

Enabling `statsig_gates` can only load evaluations if the process starts
the Statsig runtime. Several Codex entry points never started it.

## What changed

Start Statsig in standalone and embedded app servers, the TUI when it
connects to a separate app server, eligible `codex sandbox` launches, and
local and remote exec servers. This also covers `codex exec` through its
embedded app server. Use the serving or local account where applicable
and installation identity for remote execution. Share the runtime with
the embedded TUI and flush it on normal shutdown.

## Testing

Add a CLI integration test that checks which evaluation endpoint each
launch mode requests, including signed-in and signed-out sandbox launches.
Supply a bundled fixture key in Bazel and nextest CI builds so the test runs.

GitOrigin-RevId: 64df9933c1a9783a86be8712fa012b495f34b0f8
2026-11-25 22:46:26 +00:00
jif 06c718ae68 Remove the shadow skill ranking experiment (#63993)
## What changed

Remove the background ranking of skill candidates and the metrics that
compared those rankings with skills actually used. Drop the experiment's
per-thread state and metrics wiring.

Continue accepting `skill_search` in existing feature configurations as
an ignored compatibility key.

## Testing

Extend the feature configuration test to cover both `true` and `false`
values for `skill_search`.

GitOrigin-RevId: 9492533bdeea58d4976bc9fbcffb6b82036b7894
2026-11-25 22:41:36 +00:00
Eric Traut 8603da0718 Centralize terminal compatibility policy in the TUI (#63793)
## What changed

Have startup and screen code consume capability decisions for inline mode,
Kitty graphics, mouse capture, session polling, and pointer reset. Keep
terminal and multiplexer detection behind the capability helpers for these
decisions.

Share stdout color detection between the CLI and standalone TUI exit
messages, and use the TUI's terminal warning helper for the CLI startup
confirmation.

## Testing

Exercise mouse-capture cleanup in separate Kitty and Ghostty test processes
and verify that each emits its expected OSC 22 reset sequence.

GitOrigin-RevId: 15cb972034397e521a97c2813628533b71539530
2026-11-25 01:27:56 +00:00
Adam Perry @ OpenAI 9a3c131eb4 Deduplicate model catalog strings in memory (#63735)
## Why

Identical instructions and tool descriptions can appear in multiple
model catalog records. Each decode or clone previously allocated its own
copy of that text.

## What changed

Use `CodexCachedStr` for catalog instructions, messages, and tool
overrides. It stores short strings inline and interns longer strings so
independent decodes and clones can share storage. Resolved incremental
tool messages also reuse cached text from overrides and bundled defaults.
JSON and generated TypeScript still represent these values as strings.

## Testing

Add tests for shared storage across catalog fields, independent decodes,
clones, and incremental tool defaults. Cover plain JSON string round
trips and borrowed access to short inline UTF-8 strings.

GitOrigin-RevId: 6f53b4e19f01f6ed52a8fd364279b924cf794be2
2026-11-24 20:21:47 +00:00
Eric Traut 7ce4437488 Scope resume --approve-for-me to the initial conversation (#63589)
## Why

An already-loaded conversation can ignore permission overrides sent with
a resume request. Applying the preset to the TUI's launch configuration
can also carry it into later conversations.

## What changed

Resolve the preset using the selected conversation's workspace and
managed requirements. Apply it only to the initial resume, so `/new`
and later resumes use the regular launch configuration.

If an already-loaded conversation needs a settings update, read back
its approval and sandbox settings before submitting the initial prompt.
Stop the resume when the server cannot confirm the requested settings
or when workspace or managed restrictions cannot be verified.

## Testing

Regression tests cover CLI flag precedence, updating an already-loaded
conversation, rejecting unverifiable restrictions, and keeping the
preset out of new and subsequently resumed conversations.

GitOrigin-RevId: 6a09097dfc64fdeb890c03cd3e56bb404e5199c8
2026-11-24 09:35:28 +00:00
Benjamin Carlsson 6b776372fd Honor configured and saved approvals in codex exec (#63515)
## Why

`codex exec` could force the approval policy to `never`, overriding
configured approvals on new threads and saved approvals when continuing
a thread.

## What changed

New local and remote threads use their configured approval settings.
Resumed and forked threads inherit the source thread's approval policy
and reviewer independently. An explicit local CLI or profile override
changes the supplied setting and saves it on the resulting thread.

Before an interactive approval can be requested, `codex exec` warns on
stderr when the effective settings call for a human reviewer. Exec
rejects those requests immediately because it runs non-interactively.

## Testing

Regression tests cover approval outcomes, warnings, and saved settings
across local and remote runs. They also cover managed sandbox validation
against an inherited approval policy.

GitOrigin-RevId: 5d3499f7a59ce16b8d909e669e9f74682f6c3b69
2026-11-24 03:13:18 +00:00
vishnu-oai 83077214a4 Reuse config server discovery when loading managed policy (#63473)
## Why

CLI login and interactive TUI startup could look up the same config server's
OAuth metadata again when loading managed policy, even after resolving it
for sign-in.

## What changed

- Carry the resolved config server settings in memory from sign-in to policy
  loading and through TUI startup and worktree setup. Reuse them only when
  the configured server, outbound proxy policy, and system proxy fallback
  setting match.
- Rediscover anonymous servers after onboarding so the TUI can pick up a
  newly enabled OAuth requirement.
- Use discovered OAuth settings to classify app-server startup errors as
  config server errors when applicable.

## Testing

Add a regression test that blocks discovery requests and checks reuse for
matching OAuth and anonymous resolutions, as well as cache misses when the
server or either proxy setting changes.

GitOrigin-RevId: 28b5c8ffdb80db09dd8bbae3c1e187189ea393bf
2026-11-24 00:11:35 +00:00
Matthew Zeng d4af2452f7 Honor explicit plugin disablement without a global default (#63468)
## Why

Without `plugins._default`, the activation policy ignored a plugin's explicit `enabled = false`. The CLI also reported remote plugin enablement directly from the marketplace, so its output could disagree with the effective state.

## What changed

Apply per-plugin enablement before falling back to `plugins._default.enabled`. The `codex plugin list` command now applies that policy to remote plugins, so an installed plugin can appear as disabled while retaining its installation and account settings. Plugins disabled at their source stay disabled.

## Testing

Cover explicit disablement without a global default in config and remote plugin loading tests, and check that the CLI reports the plugin as installed and disabled in both JSON and table output.

GitOrigin-RevId: ab9f5a5b36150d7350c2d11a8421f9e14524a1ad
2026-11-23 23:39:54 +00:00
jgrodman-arch 56bb44c05c Support model and reasoning effort overrides in remote exec (#63462)
## Why

`codex exec --remote` rejected model and reasoning effort overrides,
so callers had to configure those settings on the app server.

## What changed

Accept `--model`, `-c model=...`, and `-c model_reasoning_effort=...`
when starting or resuming a remote thread. As in local exec, `--model`
takes precedence over `-c model=...`.

Explicit overrides update the remote thread for the current and
subsequent turns. Omitted settings retain the thread's current values
or use the server defaults for a new thread.

## Testing

Add CLI integration coverage for fresh and resumed threads, override
precedence, and inheritance across turns. Check that invalid or
unrelated overrides fail before connecting.

GitOrigin-RevId: 9bd18b65978962cf6f325feee1056d130e9e6b91
2026-11-23 23:13:28 +00:00
Dmitriy Kovalenko 91f5c31ddb Make Codex tests more portable across environments (#63427)
## Why

Read-only Bazel runfiles can leave copied patch fixtures unwritable, and
restricted Linux environments can deny the mount setup Bubblewrap needs.
Test environments can also lack Python or use paths long enough to
produce identical truncated worktree headings.

## What changed

- Write fresh, writable copies of patch scenario inputs.
- Treat Bubblewrap's mount permission error as sandbox unavailability in
  the CLI and Linux sandbox tests.
- Use `printf` and `tr` to generate output for code mode truncation tests.
- Normalize one worktree heading at a time in the overview snapshot.

GitOrigin-RevId: 88590c9c08a739ecdd4ed49bd41734b02ece3f66
2026-11-23 20:25:06 +00:00
Anton Panasenko 794584993e Cancel folder trust prompts when the app server disconnects (#63262)
## Why

A daemon restart can invalidate the connection while a folder trust
prompt is open. A queued confirmation can otherwise still be handled
against that closed connection.

## What changed

Dismiss the folder trust prompt when the connection closes, giving the
disconnect priority over queued input. Leave the disconnect event for
the Agents overview to handle. During startup, exit with a message
asking the user to restart Codex.

## Testing

Add tests for daemon restarts during folder consent in the Agents
overview and at startup. Both check that the restart leaves the trust
setting unset. A unit test checks that disconnect wins over queued Enter.

GitOrigin-RevId: 21ee1ca625ed8bc2266a9a37a260254d4e87369d
2026-11-23 04:58:33 +00:00
Won Park 8653ca9e99 Add an async user messaging opt-in for spawned subagents (#63069)
## Why

Async user messaging was limited to root agents. Spawned subagents need
their own opt-in so they can send messages without requiring the root
feature flag.

## What changed

Add independent `root_agent` and `subagents` settings under
`features.send_message_to_user_async`. For example, this opts spawned
subagents in and turns off the root feature flag:

```toml
[features.send_message_to_user_async]
root_agent = false
subagents = true
```

The existing boolean shorthand still sets the root feature flag, and the
model catalog can still enable the tool for the root agent. Config layer
merges, CLI overrides, and feature toggle edits preserve the separate
`subagents` setting when changing the root flag.

## Testing

Extend coverage for tool availability across root agents, spawned
subagents, and compaction helpers, and for preserving the subagent
setting when applying boolean overrides.

GitOrigin-RevId: 5f34f182bc107d32797143a58f0d79395767ed49
2026-11-22 01:25:05 +00:00
Eric Traut 586bd4b891 Support the Orca integrated terminal (#63013)
## What changed

Recognize Orca from `TERM_PROGRAM=Orca` and report it in `codex doctor`.

Render Markdown links as clickable labels in Orca and keep destinations
visible under terminal multiplexers. Enable Kitty graphics for pet images
only when Orca advertises `ORCA_IMAGE_PROTOCOL=kitty` and the session
passes the direct-terminal checks.

## Testing

Cover Orca detection, Markdown link rendering and multiplexer fallback,
and pet image capability checks.

GitOrigin-RevId: 978a9cd99a8090bfe9198611e9ae7e0dd2709c3b
2026-11-21 17:25:41 +00:00
arnavpatidar-OAI cf8992e940 Enable configuration server OAuth during app-server startup (#62867)
## Why

When an organization's configuration server requires a new OAuth grant,
clients need a way to sign in before the app server starts so they can
load and validate the required settings.

## What changed

- Have `--print-startup-config` return the `configServerLogin` action
  when browser sign-in is required, and verify that the required server
  settings were applied before returning startup requirements.
- Add `codex app-server --startup-oauth`, a dedicated stdio mode that
  resolves the configuration server from local managed requirements,
  sends the client a browser authorization URL, and handles the callback,
  token exchange, and credential storage. Clients can cancel a pending
  sign-in or rerun `--print-startup-config` after it succeeds.

## Testing

Add a test that checks the browser handoff URL and verifies that
cancellation completes the pending login request with `LoginFailed`.

GitOrigin-RevId: 00f10d28befe33539882f4f3c0d2baf868ceb4a1
2026-11-21 00:03:42 +00:00
mpc-oai df6064096a Load managed cloud config for plugin add and list (#62837)
## Why

`codex plugin add` and `codex plugin list` loaded configuration without
the managed cloud configuration layer, so plugin discovery and
installation could miss settings supplied by that layer.

## What changed

Use the shared cloud-aware configuration builder for add and list,
passing through CLI overrides. Keep `codex plugin remove` on the local
configuration loader and use the loaded configuration's Codex home
for all three commands.

GitOrigin-RevId: 5ebe94de30e553c57ae6296a2ddb91792260a61f
2026-11-20 21:08:57 +00:00
vishnu-oai 60fc55bb69 Enable OAuth discovery by default for config servers (#62824)
## Why

Config servers that publish OAuth metadata still required administrators
to configure OAuth endpoints explicitly for Codex to use them.

## What changed

- Discover OAuth metadata when `config_server.oauth` is omitted. Use
  explicit settings when provided, and fetch managed configuration
  anonymously when discovery finds no metadata.
- Have the Git credential helper resolve the config server before
  fetching managed configuration. It refuses explicit or discovered
  OAuth so it can apply workspace policy without opening the OS keyring.
- Apply local network policy to discovery during `codex logout`.

## Testing

Cover app-server recovery after a discovery failure, Git credential
helper rejection of explicit OAuth without a network request, and
logout discovery blocked by local network policy.

GitOrigin-RevId: 1ad84effef48fd9b56371ee177bd53c54f3e87b8
2026-11-20 19:16:07 +00:00
vishnu-oai 14302d5de9 Add opt-in OAuth discovery to config server loaders (#62432)
## What changed

Allow config server bundle and auth loaders to discover authorization and
token endpoints, plus an optional device authorization endpoint, from OAuth
metadata when callers enable discovery and omit `config_server.oauth`.
Discovery uses the bootstrap HTTP policy, times out after five seconds,
and keeps the discovered settings in memory. Existing managed-config
entry points pass `ConfigServerDiscovery::Disabled`.

If bundle loader initialization fails, report the error on the first read
and retry on later reads until a loader and its refresh worker can start.

## Testing

Add tests for endpoint parsing and defaults, the discovery timeout,
explicit OAuth precedence, disabled discovery, and local network policy.

GitOrigin-RevId: 7cb72054147ec34f985d55dfe708fccfafcb4ba3
2026-11-19 05:12:34 +00:00
Henry Levy d64451b049 Support tool-specific JavaScript preloads in Code Mode (#62430)
## What changed

Let in-process sessions and hosts using stdio or gRPC supply trusted
JavaScript helpers. Run each helper before the cell's module in the same V8
context, only when the cell exposes a unique matching binding with the
expected tool name and namespace.

Report ambiguous bindings and preload failures as bounded cell errors.
Suppress V8 diagnostics on stdout so they cannot corrupt stdio protocol frames.

## Testing

Add coverage for per-session helper selection, exact tool matching, ambiguous
bindings, and bounded compile and execution errors. A stdio subprocess test
checks that a failed preload leaves another session on the same connection
usable. Allow more time for existing CLI and MCP integration tests to connect,
start their test server, or shut down.

GitOrigin-RevId: f9f037de7f9d6018ae755b38475c4131ca7ba1f0
2026-11-19 04:48:49 +00:00
Charlie Marsh 097a8a7439 Add a shared sandbox launcher for Linux and macOS (#62353)
## Why

Running each helper through `codex sandbox` keeps a separate Codex
supervisor process alive for each helper. A shared launcher lets one
supervisor manage multiple helpers concurrently.

## What changed

Add a launcher mode that multiplexes helper I/O and exit status over a
newline-delimited JSON protocol on stdin and stdout. Each helper uses
the host sandbox setup with its own configuration and network proxy.
The launcher applies backpressure to helper I/O, drains buffered output
on exit, and stops tracked helpers when the controller disconnects.

## Testing

Add integration coverage for per-helper filesystem isolation, stdin
backpressure, buffered output after helper exit, and controller
disconnect while output is blocked.

GitOrigin-RevId: a7f75fdedbe0928ff5b93a412c7223371d0f321a
2026-11-18 20:14:05 +00:00
Charlie Marsh 60fcb1649f Support piped I/O when starting Seatbelt sandbox commands (#62350)
## What changed

Split Seatbelt command startup from waiting for the command to exit.
The startup helper can pipe stdin, stdout, and stderr and returns a
handle that keeps the network proxy alive while the caller manages the
child process.

The sandbox CLI still inherits stdio, waits for the child, reports
Seatbelt denials when requested, and propagates the child's exit status.

GitOrigin-RevId: 6a52a1a539bc2861b2357e9e60fab61ee65265fb
2026-11-18 19:56:33 +00:00
Alex Chang cc7a62e19c Report API spend limit errors by scope (#62329)
## Why

Generic quota errors hide whether the project or organization spend limit
blocked a request. Reporting the scope tells users which limit to check.

## What changed

Recognize API key, project, and organization spend limit errors across
HTTP, SSE, and WebSocket responses. Show a message that names the scope and
treat the error as non-retryable, even when the provider sends
`Retry-After`. Apply the existing usage-limit handling to goals and
compaction.

Expose distinct `CodexErrorInfo` values in the app-server protocol and
generated bindings so clients can identify the limit in live errors and
failed turn history.

## Testing

Extend the transport tests to cover all three scopes and verify that they
stop retries. Extend the app-server test to check that the error survives
`thread/read` and that a subsequent turn can succeed in the same thread.

GitOrigin-RevId: 03341f7a78daa7540e7baa519f1a29ec07e34509
2026-11-18 18:11:54 +00:00
richardopenai c1ed51ca2c Accept inbound Noise connections in remote exec-server (#62325)
## Why

Remote Noise executors previously connected outbound to a rendezvous relay. An inbound listener lets harnesses that can reach the executor connect directly while retaining registry-backed authorization.

## What changed

Use `--listen ws://IP:PORT` with `--remote` in Noise mode to accept inbound WebSockets. The listener serves RPCs over encrypted Noise streams after the registry authorizes the harness. It limits concurrent connections and handshake attempts, closes sockets that miss the first authorization deadline, and drains connections on shutdown.

Noise clients can attach optional admission headers from the connection bundle to `wss://` requests.

## Testing

The inbound integration test exercises a registry-authorized file read, rejection of a registry-denied harness, the absence of a plaintext RPC response, and connection closure on shutdown. Unit tests cover handshake limits and rejection of admission headers before dialing a plaintext WebSocket.

GitOrigin-RevId: b388672e49a3fe806e38f6db38825435ba25d27a
2026-11-18 17:55:49 +00:00
viyatb-oai 6257fbc4bd Move sandbox preparation into platform backends (#62317)
## What changed

Have `SandboxManager` handle backend selection and shared preparation, then
delegate command wrapping and session setup to the Linux, macOS Seatbelt,
Windows token, and Windows MXC backends.

Centralize Windows managed proxy routing in `codex-sandboxing` so the exec
server and other callers use the same rule for selecting dedicated MXC
listeners.

GitOrigin-RevId: a75886809aefebf6c267bb39dbc104f76bda3409
2026-11-18 17:09:03 +00:00
viyatb-oai bcff988bd1 Resolve Linux sandbox mode once before launching the helper (#62215)
## Why

Managed proxy routes require bubblewrap's network namespace even when
`features.use_legacy_landlock` is enabled. WSL1 compatibility checks and
helper arguments need to agree on the effective mode.

## What changed

Resolve bubblewrap or legacy Landlock once and use that mode for both the
WSL1 check and the `codex-linux-sandbox` arguments. Use Linux sandbox
naming for the shared launcher and CLI code, and preserve the published
analytics category for a missing helper executable.

## Testing

Unit tests exercise the production argument builder, including managed
network context serialization when legacy Landlock is requested. They
also cover which sandbox configurations WSL1 accepts and rejects.

GitOrigin-RevId: 619ab9d3eef965de6bc6cb13ff8a33132018abcf
2026-11-18 07:23:25 +00:00
viyatb-oai a4495dd5c9 Keep sandbox preparation with the command through launch (#62205)
## What changed

- Keep the prepared `SandboxExecRequest` intact in core and let
  `command/exec` borrow the prepared command for streaming. Windows
  restricted-token commands continue through the dedicated sandbox launcher.
- Move runtime read-path selection for exec-server commands and filesystem
  helpers into `SandboxManager`. It derives the paths from the executor's
  binaries and, for managed process launches, finds the generated proxy CA
  bundle in the command environment.

GitOrigin-RevId: 8c9d278496d84589bc4a7b7d0ed08cb1b8e6ba21
2026-11-18 06:22:36 +00:00
zm-oai b78fa4af86 Distinguish Windows sandbox provisioning timeouts and pipe closures (#62192)
## Why

When a registered Core provisioning request timed out or its pipe closed
before a reply, setup reported only that the service was unavailable. That
made the two failures indistinguishable in setup metrics.

## What changed

Preserve the underlying I/O error and attach distinct setup error codes for
timeouts and pipe closures. Registered Core still reports the service as
unavailable and refuses helper fallback. `codex doctor` advises checking
that the sandbox service is running and letting pending setup finish before
retrying.

## Testing

Add a unit test that checks error classification for timeouts, unexpected
EOF, and broken pipes. It also checks that a non-registered request still
returns an unavailable response on timeout and that permission errors
receive neither new code.

GitOrigin-RevId: fa6653fe5f9cafd10fc1562eb0763857a1bd628f
2026-11-18 04:52:38 +00:00
Michael Bolin bb6b4b63b9 Move the app-server socket relay into the Codex CLI (#62163)
## What changed

Move the stdio-to-Unix-socket relay used by `codex app-server proxy`
into the CLI crate. Remove the standalone `codex-stdio-to-uds` crate
and binary and the hidden `codex stdio-to-uds` subcommand.

## Testing

Replace the standalone binary test with a CLI integration test that
runs `codex app-server proxy --sock` and checks that the socket receives
the bytes from stdin and the reply appears on stdout.

GitOrigin-RevId: e630f8f70e93ce90b0005e4992a3d0b257b208db
2026-11-18 02:18:36 +00:00
vishnu-oai 2df29476ae Support device-code login for config servers (#62079)
## Why

`codex login --device-auth` still used browser authorization when config server sign-in was required, preventing the selected device-code flow from being used there.

## What changed

- Use device authorization for config server sign-in when `--device-auth` is selected, display the verification URL and code, and report a missing `config_server.oauth.device_authorization_url` explicitly.
- Include the configured OAuth `resource` in device authorization and token polling requests.
- Reserve sign-in per credential across Codex processes, reuse saved grants, and release the reservation when sign-in completes or is canceled.
- Report config server sign-in failures with guidance specific to `config_server.oauth` and the credential store.

## Testing

Add or extend tests for the device-code prompt, config server failure messages, OAuth resource parameters, policy reload after credential replacement, and rejection of concurrent sign-in with retry after cancellation.

GitOrigin-RevId: 013176d0e10128c347dd072b818e22b5038a2791
2026-11-17 16:42:48 +00:00
Eric Traut 0cc88d0c74 Reject conflicting remote endpoints for resume and fork (#62065)
Extend the remote endpoint conflict check to `codex resume` and `codex fork` so
conflicting root and subcommand `--remote` values report a command-specific
error before authentication token lookup.

Add regression coverage for both commands with conflicting endpoints and an
unset authentication token environment variable.

GitOrigin-RevId: 7fb7bc3f05d8d17d740b0d82c7cd9b327426c1fb
2026-11-17 15:32:10 +00:00
viyatb-oai 05ae1b0fdd Centralize sandbox network and shell credential setup (#62050)
## Why

A missing executor proxy launch config can still require managed networking. Only an explicitly disabled executor proxy should suppress that enforcement.

## What changed

- Prepare executor proxy launch settings and enforcement together, preserving the distinction between missing and disabled proxy configurations.
- Bundle sandbox enforcement, the live proxy, and the environment ID in `SandboxNetwork`, retaining the proxy through shell snapshot setup.
- Share shell-startup credential classification and application through `ShellStartupCredentials`, including protected `zsh` snapshots, supported `bash -c` commands, and unmasked fallback handling.

## Testing

Extend the exec-server sandbox preparation test to verify that an explicitly disabled proxy omits both the proxy launch config and managed-network enforcement.

GitOrigin-RevId: e2f3b543680c9184b6557b81de02a61f0a977e32
2026-11-17 13:52:56 +00:00
richardopenai 98323eddf9 Simplify SSH tunneling and honor system HTTPS proxies (#61975)
## What changed

- Make `codex tcp-tunnel` an SSH stdio helper, removing the loopback listener, stdin control protocol, and JSON diagnostics.
- Add `--token-file` for one-use credentials, consumed only after gateway verification, with environment-based OAuth routing or a legacy IPv4 `--target`.
- Honor system HTTPS proxy settings without attempting direct QUIC, and keep gateway credentials inside verified TLS.
- Race direct TCP addresses through TLS and HTTP/2 readiness so stalled peers do not block a working address.

## Testing

Add coverage for proxy credential isolation and stalled TLS peers, plus an opt-in Linux OpenSSH integration test for complete uploads and remote exit while local stdin remains open.

GitOrigin-RevId: 62423c8a8267842c9e401b3f9094c7278c47a490
2026-11-17 06:03:45 +00:00
viyatb-oai c656014177 Centralize exec-server launches in WrappedSandboxCommand (#61942)
## What changed

- Move process spawning and Windows token session preparation into `codex-sandboxing`. Keep filesystem overrides, proxy enforcement, and the restricting SID with the prepared command, and reject conversion to a plain command request when a Windows session launcher is required.
- Route shell snapshot capture and replay through the prepared command. Limit script replacement to the submitted shell invocation while preserving its sandbox, environment, and proxy.
- Pass borrowed launch facts to sandbox integrity checks, and distinguish explicitly supplied runtime readable paths from automatic proxy CA bundle discovery.

## Testing

Extend coverage for Windows TEMP permissions and managed proxy routing with empty workspace roots, native launch and prewarm input validation, and proxy availability after the process leader exits while a descendant holds stdout open.

GitOrigin-RevId: fe2bdb9e44f4fb273295fbde66b44bf01f0b7fbc
2026-11-17 02:02:21 +00:00
Joe Savona 30be9534c8 Fall back to the built-in status line for invalid providers (#61915)
## Why

An invalid `tui.status_line_provider` should not prevent startup in normal mode.

## What changed

Use the built-in status line when the effective provider selection is invalid and emit a startup warning identifying its source. Keep the invalid selection's precedence so it overrides lower-priority providers, while preserving the original configuration for diagnostics and `config/read`.

With `--strict-config`, reject invalid provider selections in every configuration source.

## Testing

Update coverage for malformed user settings and incomplete profile selections, and add a CLI case verifying strict provider validation before terminal checks.

GitOrigin-RevId: 797d1c71dd4803db59ca91880a07e2e2118ce097
2026-11-16 23:57:23 +00:00
viyatb-oai c9df641eac Preserve native sandbox executable paths and PTY dispatch names (#61910)
## Why

Sandbox helpers with non-UTF-8 paths can lose their exact executable path when converted into command requests. PTY launches with a custom `argv[0]` can also try to execute the dispatch name instead of the configured program.

## What changed

- Carry native executable paths through sandbox requests, local execution, shell snapshots, and sandbox integrity checks.
- Use native Unix PTY spawning when `argv[0]` differs from the executable, preserving the dispatch name and controlling terminal setup.
- Preserve PTY executable lookup through the child environment's `PATH` and fallback to its home directory when the requested working directory is missing.

## Testing

Add regression coverage for non-UTF-8 sandbox helper paths, PTY dispatch names, child `HOME`/`PATH` lookup, controlling terminals, and exit-code preservation.

GitOrigin-RevId: 6a2af0486220d98195f5d67fde2597e3c4515e11
2026-11-16 23:26:42 +00:00
cassirer-openai ef6ce8100a Bound rollout trace capture with configurable storage limits (#61896)
## What changed

- Add `rollout_trace.max_payload_bytes` and `rollout_trace.max_bytes`, defaulting to 64 MiB per body or separated value and 256 MiB per bundle. Root and child threads share the bundle budget.
- Record explicit truncations and omissions when limits are reached, reserve space for later events, and stop at the last complete event if the event log fills.
- Reuse identical prepared-prompt items and store inline images separately from message structure. Preserve exact JSON bytes for complete composite payloads and surviving content and links in partial captures.
- Let reducers handle partial payloads while retaining lifecycle information and reporting `closed_with_partial_payloads` for closed bundles with incomplete captures.

## Testing

Add coverage for payload reuse and byte-exact reconstruction, truncation, compressed bundle budgets, later events after omissions, readable prefixes after event-space exhaustion, and CLI capture-limit configuration and startup failures.

GitOrigin-RevId: be99a68da427414a7a12bf8209f232c1a0bbe545
2026-11-16 22:26:31 +00:00
viyatb-oai effad7568c Allow network policy to enable transparent TCP capture (#61851)
## What changed

- Add `transparent_tcp` to network configuration and managed requirements, defaulting to off. When enabled, route outbound TCP from managed Linux sandbox commands through the managed SOCKS5 proxy without requiring an executor startup flag.
- Propagate the setting through local and remote execution, require an enabled SOCKS5 proxy, and check the executor's `networkProxyTransparentTcp` capability before remote launches.
- Refresh the live proxy when switching between permission profiles with different network settings.

## Testing

Add coverage for configuration-driven sandbox capture, rejection of unsupported launch contexts, execution parameter propagation, and live permission profile changes.

GitOrigin-RevId: c4db87056de116f433a128806bef673802f35397
2026-11-16 18:19:16 +00:00
Eric Traut e51c551fb4 Support remote app servers in codex exec (#61707)
## What changed

Allow `codex exec --remote <ADDR>` to run a noninteractive turn using an existing app server's configuration and credentials. Support starting a new thread or resuming one by UUID, with human-readable or JSON output and optional bearer-token authentication through `--remote-auth-token-env`.

Accept remote options before or after `exec`, and reject conflicting endpoints. Reject unsupported agent configuration overrides and active threads, and report an error if the server disconnects before the turn completes.

## Testing

Extend CLI integration coverage for remote execution and resume using server authentication, JSON completion events, human-readable thread IDs, and conflicting endpoints. Add a snapshot for `--remote` help text.

GitOrigin-RevId: d4c3b16fb80eb6e8c523aff92110eaa878cbd3ee
2026-11-16 00:02:00 +00:00