Create credentials
Request a terminal session from the server. The response containswsUrl, expiresAt, and an optional protocols array.
The URL and protocols can contain temporary credentials. They belong only to the deployment owner.
Open the socket
Pass the protocols to the WebSocket constructor:Control messages
Control messages use text frames with JSON:
Before input, wait for
ready. After readiness, send the latest terminal dimensions.
The terminal applies 1 to 500 columns and 1 to 300 rows.
Input and output
Terminal data uses binary frames. Input is UTF-8 text:ArrayBuffer data. A terminal renderer can consume those bytes as a Uint8Array.
A text decoder must preserve partial UTF-8 characters between output frames. xterm accepts byte arrays directly.
Reconnect and expiration
Every reconnect requires a new terminal-session request. The previous URL and protocols are not reusable credentials for a new connection. The server replays recent output on every new connection, so clear the screen before writing it. A closed socket does not end the lab. Each lab allows up to 4 terminal connections at once. An expired or ended lab can reject session creation. The learner must request a separate lab launch to start another environment.expiresAt is the deadline for connection authorization. It does not set the shell lifetime or deployment deadline.
An existing connection can continue after token expiration until the lab ends.
Close codes
Anexit message arrives both when the shell exits and when the lab ends. The close code that follows tells them apart.
