Skip to content

[codex] Add unsandboxed process exec API#19040

Merged
owenlin0 merged 19 commits into
mainfrom
ruslan/app-server-unsandboxed-exec
May 4, 2026
Merged

[codex] Add unsandboxed process exec API#19040
owenlin0 merged 19 commits into
mainfrom
ruslan/app-server-unsandboxed-exec

Conversation

@euroelessar

@euroelessar euroelessar commented Apr 22, 2026

Copy link
Copy Markdown
Collaborator

Why

App-server clients sometimes need argv-based local process execution while sandbox policy is controlled outside Codex. Those environments can reject sandbox-disabling paths before a command ever starts, even when the caller intentionally wants unsandboxed execution.

This PR adds a distinct process/* API for that use case instead of extending command/exec with another sandbox-disabling shape. Keeping the new surface separate also makes the future removal of command/exec simpler: clients that need explicit process lifecycle control can move to the newer handle-based API without depending on command/exec business logic.

What changed

  • Added v2 process lifecycle methods: process/spawn, process/writeStdin, process/resizePty, and process/kill.
  • Added process notifications: process/outputDelta for streamed stdout/stderr chunks and process/exited for final exit status and buffered output.
  • Made process/spawn intentionally unsandboxed and omitted sandbox-selection fields such as sandboxPolicy and permissionProfile.
  • Added client-supplied, connection-scoped processHandle values for follow-up control requests and notification routing.
  • Supported cwd, environment overrides, PTY mode and size, stdin streaming, stdout/stderr streaming, per-stream output caps, and timeout controls.
  • Killed active process sessions when the originating app-server connection closes.
  • Wired the implementation through the modular request_processors/ app-server layout, with process-handle request serialization for follow-up control calls.
  • Updated generated JSON/TypeScript schema fixtures and documented the new API in codex-rs/app-server/README.md.
  • Added v2 app-server integration coverage in codex-rs/app-server/tests/suite/v2/process_exec.rs for spawn acknowledgement before exit, buffered output caps, and process termination.

Verification

  • cargo test -p codex-app-server-protocol
  • cargo test -p codex-app-server

@euroelessar euroelessar marked this pull request as ready for review April 22, 2026 22:14

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9a269ff272

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread codex-rs/app-server-protocol/src/protocol/v2.rs Outdated
Comment thread codex-rs/app-server-protocol/src/protocol/v2.rs Outdated
Comment thread codex-rs/app-server-protocol/src/protocol/v2.rs Outdated
Comment thread codex-rs/app-server-protocol/src/protocol/v2.rs Outdated
Comment thread codex-rs/app-server-protocol/src/protocol/v2.rs Outdated
Comment thread codex-rs/app-server-protocol/src/protocol/v2.rs Outdated
Comment thread codex-rs/app-server/src/codex_message_processor.rs Outdated
@owenlin0 owenlin0 force-pushed the ruslan/app-server-unsandboxed-exec branch from 9a269ff to 2654ece Compare May 1, 2026 20:21
@owenlin0 owenlin0 force-pushed the ruslan/app-server-unsandboxed-exec branch from cf963c7 to efd8792 Compare May 4, 2026 16:06
@owenlin0 owenlin0 force-pushed the ruslan/app-server-unsandboxed-exec branch from 32f8f49 to 15e265b Compare May 4, 2026 16:54
@owenlin0 owenlin0 changed the title [codex] Add unsandboxed command exec API [codex] Add unsandboxed process exec API May 4, 2026
Stderr,
}

/// PTY size in character cells for `process/spawn` PTY sessions.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incidentally, we should probably start to break up this file...

If we need the content defined in this file, we could use #[path = "process.rs"] though ideally we would just use the more standard mod process?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed... let's punt to a separate PR that mechanically splits up v2.rs?

Comment thread codex-rs/app-server-protocol/src/protocol/v2.rs Outdated
Comment thread codex-rs/app-server-protocol/src/protocol/v2.rs
Comment thread codex-rs/app-server-protocol/src/protocol/v2.rs Outdated
Comment thread codex-rs/app-server/src/request_processors/process_exec_processor.rs Outdated
Comment thread codex-rs/app-server/src/request_processors/process_exec_processor.rs Outdated
Comment thread codex-rs/app-server/src/request_processors/process_exec_processor.rs Outdated
fn terminal_size_from_protocol(
size: ProcessTerminalSize,
) -> Result<TerminalSize, JSONRPCErrorError> {
if size.rows == 0 || size.cols == 0 {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider std::num::NonZero?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO let's keep as is - so that it's a simple number in the API schema but we validate on the server

if size.is_some() && !tty {
return Err(invalid_params("process/spawn size requires tty: true"));
}
let mut env = std::env::vars().collect::<HashMap<_, _>>();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this build on std::env? The caller shouldn't have to know the PATH on the app server host, right?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep it does!

@bolinfest bolinfest left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice job: ty!

@owenlin0 owenlin0 merged commit 4950e7d into main May 4, 2026
37 of 38 checks passed
@owenlin0 owenlin0 deleted the ruslan/app-server-unsandboxed-exec branch May 4, 2026 23:44
@github-actions github-actions Bot locked and limited conversation to collaborators May 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants