Skip to content

Terminals

A terminal is a shell or command the host starts in a session's workspace as the agent's Unix user, over WebSocket only

opc shell is a client for terminals.

Access

ItemRule
CallerThe session’s owner or an admin, with the terminals scope. Anyone else: 403 forbidden with reason: "terminal_owner_only"
Process userThe agent’s Unix user
EnvironmentHOME, USER, LOGNAME, SHELL, PATH, LANG, TERM. No session secrets

Open

{"jsonrpc":"2.0","id":8,"method":"terminals.open","params":{"sessionId":"cs_0123456789abcdef","cols":120,"rows":40}}
{"jsonrpc":"2.0","id":8,"result":{"terminal":{"id":"tm_...","channel":1,"stderrChannel":null}}}
ParamMeaning
ttyDefault true: a pseudo-terminal; cols and rows are required. False: plain pipes, with standard error on its own channel, stderrChannel
cols, rows1 to 1,000
commandA command to run instead of an interactive shell, up to 10,000 characters
termThe TERM value, up to 64 characters
ErrorCause
409 too_many_terminalsThe session already holds 8 terminals, across all connections

A session with an open terminal is not suspended for being idle. The journal records terminal.opened and terminal.closed events.

Data frames

A binary WebSocket frame is a 4-byte big-endian channel number, then the data.

DirectionChannelLimit
Client to server (input)channel1 MiB per second per terminal. The server drops input over the limit, and the next request on the connection reports rate_limited
Server to client (output)channel, and stderrChannel when there is one64 KiB per frame, channel number included

Resize, end input, close

Each method takes the terminalId.

MethodEffect
terminals.resizeSets cols and rows
terminals.eofCloses the process’s standard input
terminals.closeHangs up: SIGHUP to the process group, SIGKILL 5 seconds later

A terminal belongs to the connection that opened it.

CaseResult
Its id used on another connection404 terminal_not_found
The connection closesEvery terminal it opened closes
The process exitsThe server sends terminal.exited
{"jsonrpc":"2.0","method":"terminal.exited","params":{"terminalId":"tm_...","exitCode":0,"signal":null}}