Skip to content

PTY Session

pawaca edited this page Aug 30, 2026 · 1 revision

PTY Session

Not implemented. Upstream provides persistent interactive terminal sessions; Edge currently uses non-interactive just-bash.

Upstream reference: PTY Session

What Upstream Provides

The persistent PTY subsystem manages interactive terminal sessions via ctx.terminals (TerminalSessionService). Key capabilities:

  • Persistent shell sessions — long-lived terminals that survive across tool calls, identified by TerminalSessionId with exclusive Agent ownership.
  • Interactive I/O — exclusive send operations with wait-reason detection (stdin_read, inferred_idle, timeout, session_exit), SIGINT delivery, scrollback pagination.
  • Replaceable backendTerminalBackend interface; upstream uses node-pty for native PTY spawning.
  • Output streaming — bounded viewport deltas, truncation flags, and owner-visible snapshots. State stays process-local; model inputs persist through tool/call and tool/result events.

Current Edge State

Not Implemented Edge does not install TerminalSessionService or any TerminalBackend. Command execution uses createEdgeBashTool() backed by just-bash — a pure JS shell running inside Computer VFS. This is non-interactive: each command runs to completion, returns output, and exits. No persistent shell state, no scrollback, no SIGINT.

The model's system prompt explicitly states: "The shell is just-bash, not Linux: native binaries and background processes are unavailable."

Cloudflare Enablers

Product Capability Plan
Containers Full Linux environment with real bash, process spawning, TTY support. A Container connected to the DO could serve as a TerminalBackend — spawning PTY sessions inside the container and streaming I/O over the internal network. Workers Paid or Enterprise
Computer (current) Computer's WorkerShellBackend already provides isolated command execution. If Computer evolves to support persistent shell sessions or PTY, it could serve as a lighter-weight backend without full Containers. Available on current plan

Architecture Summary

Component Status Notes
TerminalSessionService Missing Not installed
TerminalBackend Missing No backend provider
Interactive shell Substitute just-bash (non-interactive, per-command)

TODO

Evaluate Container-backed PTY. Cloudflare Containers provide full Linux environments where node-pty or direct PTY spawning is possible. The integration path: Container runs a PTY process, streams I/O to the DO via internal network or WebSocket, DO bridges to the browser. Requires Workers Paid plan. The upstream TerminalBackend interface is designed for exactly this kind of replaceable provider.

Evaluate Computer persistent shell. If Cloudflare's Computer product adds persistent shell session support (beyond one-shot command execution), it could serve as a lighter alternative to Containers for PTY — available on the current free tier without plan upgrade.

English

中文

Clone this wiki locally