- A REPL that holds state between inputs.
- An installer or migration tool that asks questions part way through.
- A TUI, a pager, or anything that behaves differently when it detects a terminal.
- A long running foreground job you want to interrupt with Ctrl-C rather than kill.
isatty is true, line editing
and job control work, SIGWINCH is delivered on resize, and colour output is enabled.
Lifecycle
1
Create
POST /v1/agents/runtime/{runtime_id}/pty starts a shell and returns a session_id.
The session keeps running after the call returns.2
Stream
GET .../pty/{session_id}/stream replays the retained scrollback and then follows live
output. Multiple readers can stream the same session.3
Drive
POST .../pty/{session_id}/input writes to the terminal.
.../resize and .../signal control the terminal geometry and the foreground job.4
Kill
DELETE .../pty/{session_id} terminates the session. Sessions are also reaped when the
runtime is stopped or deleted.Endpoints
End to end example
Session object (PtySession)
Limits
- 8 concurrent sessions per runtime. Creating a ninth fails; kill sessions you no longer need.
- 256 KB of scrollback per session. Older output is discarded as new output arrives, so a session that has been unattended for a long time replays only its recent tail.
- Exited sessions are retained briefly so you can read the final output and exit code, then reaped automatically.
- Only permitted shells may be launched. The
shellargument is validated against the runtime’s allowlist rather than executed directly.