Agent Sandbox Registry

python-sdk

Decision: PTY Terminal Protocol (L2, WebSocket)

无中文版

.agents/notes/implemented/feature/2026-09-02-protocol-terminal.md

Decision: PTY Terminal Protocol (L2, WebSocket)

Status: implemented Implemented: 2026-09-02

Problem

Interactive terminal needs bidirectional WebSocket for real-time PTY sessions with resize support.

Decision

protocol/terminal.py manages PTY WebSocket channel: - open_terminal(cols, rows, shell) → TerminalSession - TerminalSession.send(data: bytes) → None - TerminalSession.receive() → AsyncIterator[bytes] - TerminalSession.resize(cols, rows) → None - TerminalSession.close() → None

WebSocket messages are binary frames. Resize commands sent as JSON control frames with a type prefix byte.

API Design

async def open_terminal(cols: int, rows: int, shell: str) -> TerminalSession: ...

class TerminalSession:
    async def send(self, data: bytes) -> None: ...
    def receive(self) -> AsyncIterator[bytes]: ...
    async def resize(self, cols: int, rows: int) -> None: ...
    async def close(self) -> None: ...
# Binary WebSocket frames; resize sent as JSON control frames with a type-prefix byte.

Implementation

Alternatives considered

Dependencies

Test Strategy

Acceptance criteria