Endpoints
Execute stream (WebSocket)
Stream execution output over a persistent WebSocket connection with bidirectional messaging.
GET
Upgrades to a WebSocket connection for real-time bidirectional streaming of execution events.
Client → server messages (
Triggers code execution. Only one execution per WebSocket connection.
Server → client messages (
Server messages use the same
When to use WebSocket vs SSE
Authentication
Authentication uses theAuthorization header on the WebSocket upgrade request, identical to all other authenticated endpoints.
Connection lifecycle
- Client sends HTTP upgrade request with
Authorizationheader. - Server validates auth and upgrades to WebSocket.
- Client sends an
executemessage with the code and options. - Server streams
stdout,stderr,exit, anderrorevents as JSON messages. - Server closes the connection with code
1000after execution completes.
Client → server messages (WsClientMessage)
execute
Triggers code execution. Only one execution per WebSocket connection.
Optional execution options merged over server defaults.
poolStrategy and poolSize are always taken from server config.stdin (reserved)
Data to send to the running process’s stdin. Reserved for future interactive execution support.
signal (reserved)
Control signal to forward to the running process. Accepts
"SIGINT" or "SIGTERM". Reserved for future use.Server → client messages (WsServerMessage)
Server messages use the same StreamEvent format as the SSE endpoint.
Close codes
Error handling
- Invalid JSON: Server sends
{"type":"error","data":"Invalid JSON message"}then closes with code1003. - Unknown message type: Server sends
{"type":"error","data":"Unknown message type: ..."}(connection stays open). - Execution error: Server sends
{"type":"error","data":"..."}then closes with1000.
The WebSocket endpoint always uses ephemeral execution mode. Persistent sessions via
sessionId are not supported on WebSocket — use POST /execute for persistent sessions.