Skip to content

app-server: Add streaming and tty/pty capabilities to command/exec#13640

Open
euroelessar wants to merge 1 commit intoruslan/pty-and-streamingfrom
ruslan/exec-stream
Open

app-server: Add streaming and tty/pty capabilities to command/exec#13640
euroelessar wants to merge 1 commit intoruslan/pty-and-streamingfrom
ruslan/exec-stream

Conversation

@euroelessar
Copy link
Contributor

@euroelessar euroelessar commented Mar 5, 2026

  • Add an ability to stream stdin, stdout, and stderr
  • Streaming of stdout and stderr has a configurable cap for total amount of transmitted bytes (with an ability to disable it)
  • Add support for overriding environment variables
  • Add an ability to terminate running applications (using command/exec/terminate)
  • Add TTY/PTY support, with an ability to resize the terminal (using command/exec/resize)

@euroelessar euroelessar changed the base branch from main to ruslan/pty-and-streaming March 6, 2026 06:30
@euroelessar euroelessar force-pushed the ruslan/pty-and-streaming branch from f06a405 to 7c5bb76 Compare March 6, 2026 06:53
@euroelessar euroelessar force-pushed the ruslan/pty-and-streaming branch from 7c5bb76 to 6cfc6f8 Compare March 6, 2026 07:13
Define the v2 command/exec contract and wire it through app-server and core in one slice: processId, env overrides, timeout and output-cap controls, streaming notifications, and PTY write/resize/terminate support.

Keep the generated schema, README updates, backend plumbing, and test harness changes together so reviewers can read the API and runtime behavior in the same commit.
@euroelessar euroelessar force-pushed the ruslan/pty-and-streaming branch from 6cfc6f8 to f59dcaf Compare March 6, 2026 07:58
@owenlin0
Copy link
Collaborator

owenlin0 commented Mar 6, 2026

@codex review

Copy link
Collaborator

@owenlin0 owenlin0 left a comment

Choose a reason for hiding this comment

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

api design looks great to me! 🚢

fyi I triggered a codex review to see if it catches anything in the impl

Copy link
Contributor

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

Choose a reason for hiding this comment

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

💡 Codex Review


P2 Badge Preserve ExecParams arg0 in build_exec_request

build_exec_request discards ExecParams.arg0 (arg0: _). Since process_exec_tool_call now always goes through this builder, caller-supplied argv[0] overrides are silently lost unless a sandbox transformation injects one. This changes execution behavior versus the prior direct spawn path and can break consumers that rely on custom arg0 semantics.

ℹ️ 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".

};

for control in controls {
if let CommandExecSession::Active { control_tx } = control {
Copy link
Contributor

Choose a reason for hiding this comment

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

P1 Badge Terminate windows sandbox execs on connection close

connection_closed only sends Terminate for CommandExecSession::Active and skips UnsupportedWindowsSandbox. Those Windows sessions are launched in start() via execute_env without a control channel, so a disconnect does not stop the child process. Long-running commands (especially with disableTimeout) can continue orphaned, leaking resources and violating connection-scoped lifecycle cleanup.

Useful? React with 👍 / 👎.

- `thread/realtime/stop` — stop the active realtime session for the thread (experimental); returns `{}`.
- `review/start` — kick off Codex’s automated reviewer for a thread; responds like `turn/start` and emits `item/started`/`item/completed` notifications with `enteredReviewMode` and `exitedReviewMode` items, plus a final assistant `agentMessage` containing the review.
- `command/exec` — run a single command under the server sandbox without starting a thread/turn (handy for utilities and validation).
- `command/exec/resize` — resize a running PTY-backed `command/exec` session by `processId`; returns `{}`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

oh, probably worth documenting the rest of the API

"sandboxPolicy": { "type": "workspaceWrite" }, // optional; defaults to user config
"timeoutMs": 10000 // optional; ms timeout; defaults to server timeout
"outputBytesCap": 1048576, // optional; per-stream capture cap
"disableOutputCap": false, // optional; cannot be combined with outputBytesCap
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we add docstrings / move these to v2.rs so they get included in the exported TS and JSON schema types?

@owenlin0
Copy link
Collaborator

owenlin0 commented Mar 6, 2026

@euroelessar btw I triggered a local codex review and it mentioned this:

P1 Detached control handlers can reorder stdin/resize/terminate requests

These three RPC handlers immediately tokio::spawn a detached task before they forward the request into CommandExecManager. That drops the per-connection ordering guarantee the request loop otherwise has: two back-to-back command/exec/write calls can reach the manager in the opposite order, and resize or terminate can race ahead of earlier input. For an interactive PTY or streamed stdin session, that corrupts the byte stream and makes behavior nondeterministic. These handlers should await the manager call inline, or otherwise serialize by process id before enqueuing control messages.

seems worthwhile to address?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants