Generic create: [0x18][nonce:2][rows:2][cols:2][features:1][tag_len:2][tag:N][…optional fields]
Features: bit 0 = has src_pty_id (2 bytes after tag), bit 1 = has command (remaining bytes after src_pty_id if present)
Server responds with S2C_CREATED_N using the same nonce.
Mouse event: [0x06][pty_id:2][type:1][button:1][col:2][row:2]
type: 0=down, 1=up, 2=move
button: 0=left, 1=mid, 2=right, 3=release, 64=wheel_up, 65=wheel_down
The server generates the correct escape sequence based on mouse_mode and mouse_encoding.
Read text from a PTY’s scrollback + viewport: [0x19][nonce:2][pty_id:2][offset:4][limit:4][flags:1]
offset: number of lines to skip from the top (oldest = 0), or from the end if READ_TAIL is set
limit: max lines to return (0 = all)
flags: bit 0 = include ANSI styling, bit 1 = offset counts from the end
Server responds with S2C_TEXT using the same nonce.
Desired viewport size(s): [0x01][pty_id:2][rows:2][cols:2]…
Clients may batch multiple PTY resize entries in one message. The server
mediates these per-client desired sizes into each PTY’s effective size.
A rows, cols pair of 0, 0 clears this client’s desired size for that PTY.
The PTY’s subprocess has exited but the terminal state is retained.
Clients can still read/scroll the last frame. Send C2S_CLOSE to dismiss.
Wire: [0x08][pty_id:2][exit_status:4]
exit_status: WEXITSTATUS if normal exit, negative signal number if signalled,
EXIT_STATUS_UNKNOWN if not yet collected.
Sent after the initial burst (HELLO, LIST, TITLE*, EXITED*) is complete.
Clients can use this to know when the initial state has been fully transmitted.
Text response: [0x0A][nonce:2][pty_id:2][total_lines:4][offset:4][text:N]
nonce: echoed from C2S_READ request
total_lines: total available lines (scrollback + viewport rows)
offset: the offset that was requested
text: UTF-8 text, lines separated by \n