Skip to content

Feature request: PTY allocation support in execd for interactive terminal sessions #623

@AlexandrePh

Description

@AlexandrePh

Summary

The OpenSandbox execd API currently supports non-interactive command execution via POST /command with SSE output streaming. For interactive terminal use cases (e.g., attaching to a running agent's terminal, debugging sessions), we need PTY (pseudo-terminal) allocation support.

Current Behavior

ExecRequest only supports:

{
  "command": "string",
  "background": bool,
  "timeout": int
}

Output is streamed via SSE (stdout, stderr, exit events) — unidirectional, no stdin support.

Proposed Changes

  1. Add tty: bool field to exec request — allocates a PTY for the command
  2. WebSocket exec endpoint — bidirectional communication for interactive sessions:
    • Client sends stdin data as binary frames
    • Server sends stdout/stderr as binary frames
    • Support terminal resize events (SIGWINCH)
  3. PTY lifecycle management — graceful shutdown, signal forwarding

Use Case

Building a worker interaction system where users can attach to get a raw terminal session inside a sandbox. This requires:

  • Bidirectional I/O (stdin + stdout/stderr)
  • PTY allocation for proper terminal behavior (line editing, colors, etc.)
  • Terminal resize propagation

Suggested API

WS /v1/sandboxes/{id}/proxy/{port}/terminal
  Query params: ?cols=80&rows=24&command=bash

  Client → Server: binary frames (stdin bytes) + JSON control frames (resize)
  Server → Client: binary frames (stdout bytes)

Or extend the existing exec endpoint:

POST /command
{
  "command": "bash",
  "tty": true,
  "cols": 80,
  "rows": 24
}

With a WebSocket upgrade path for the response.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions