Protocol

The gRPC contracts of cua-spacesd (cua.env.v1) and the cua daemon (cua.daemon.v1): ports, routes, auth and every RPC.

The gRPC contracts, generated from the .proto files in libs/cua/proto. cua.env.v1 is served by cua-spacesd inside a sandbox; cua.daemon.v1 is served by the local cua daemon. Changes are additive and pass buf breaking.

Contract revision: cua.env.v1 protocol version 1, revision 13 (reported by SystemService.GetCapabilities).

Clients use the SDK's SpacesdClient or cua spacesd ...; SpacesdClient.call_json reaches any RPC below. Sandboxes do not require cua-spacesd: only the computer interfaces and the Spaces primitives need it. It never injects input itself; pointer and keyboard actions go to Cua Driver.

PortCarries
TCP 3211Native gRPC (HTTP/2) and gRPC-Web (HTTP/1.1), gRPC reflection, and the HTTP routes below
UDP 3212QUIC media datagrams (ALPN rcdp/2, certificate pinned through StreamService.OpenMedia)

The default bind is 0.0.0.0:3211 with a token and 127.0.0.1:3211 without one; a non-loopback bind without a token is refused. Clients send the env token as authorization: Bearer <token> or x-cua-env-authorization: Bearer <token> (a gateway may consume authorization). The token grants full control of the computer: never put it in a URL; browsers use tickets and signed URLs.

RouteAuthPurpose
GET /healthNone204 while serving, 503 while shutting down
GET, HEAD, PUT, POST /filesSigned URL from CreateSignedUrlUpload and download with Range; a URL signed for PUT also takes POST multipart/form-data (the first file part, answered with [{"name","path","type"}]); 403 when expired or tampered
POST /mcpEnv tokenStreamable-HTTP MCP over the Cua Driver tools; 501 when disabled
GET /tunnel (WebSocket)Ticket from TunnelService.ForwardPort forwarding
GET /hotspot (WebSocket)Ticket from StartHotspotReverse SOCKS egress
GET /media (WebSocket)Ticket from StreamService.OpenMediaVideo (H.264) and audio (Opus), media wire v2 (libs/cua/proto/MEDIA.md)

Tickets go in ?ticket= or the WebSocket subprotocol cua.ticket.<ticket>. Tickets and signed URLs are keyed from the env token, so rotating the token revokes them.

Services#

Metadata and HTTP routes#

Well-known metadata keys and HTTP paths (cua_proto::metadata).

ConstantValueMeaning
AUTHORIZATIONauthorizationBearer token header: authorization: Bearer <token>.
ENV_AUTHORIZATIONx-cua-env-authorizationAlternate spacesd token header, x-cua-env-authorization: Bearer <token>, for paths where authorization belongs to an outer hop (a gateway consumes and strips it). Servers accept either header.
PRINCIPAL_BINx-cua-principal-binBinary metadata carrying a serialized cua.env.v1.Principal.
HEALTH_PATH/healthPlain-HTTP, unauthenticated health route (204 when healthy).
MEDIA_WS_PATH/mediaMedia WebSocket path (ticket-authenticated).
TUNNEL_WS_PATH/tunnelTCP-over-WebSocket tunnel path (ticket-authenticated).
HOTSPOT_WS_PATH/hotspotReverse-SOCKS hotspot WebSocket path (ticket-authenticated).
SPAWN_WS_PATH/spawnSpawn channel WebSocket path (ticket-authenticated): the host that runs the Space serves its child-Space API over it.
HOST_PORTS_WS_PATH/hostportsHost ports WebSocket path (ticket-authenticated): the host that runs the Space carries its listed host ports, published on the Space's own loopback.
SPAWN_TOKEN_FILEspawn-tokenFile (in a [spawn_dirs] directory) holding a Space's spawn capability.
SPAWN_ADDRESS_FILEspawn-addressFile (in a [spawn_dirs] directory) holding the spawn listener's URL.
ENV_SPACECUA_SPACEEnvironment of processes in a Space: its id.
ENV_SPAWNCUA_SPAWNEnvironment of processes in a Space: the spawn listener's URL.
ENV_SPAWN_TOKEN_FILECUA_SPAWN_TOKEN_FILEEnvironment of processes in a Space: the capability's file.
VOLUME_WS_PATH/volumeCua Volume WebSocket path (ticket-authenticated): the client serves the guest's volume mount over it.
FILES_PATH/filesSigned-URL file route.
MCP_PATH/mcpStreamable-HTTP MCP endpoint for the cua-driver tool registry.
SNAPSHOT_BLOBS_PATH/v1/snapshots/blobs/{sha}A host's checkpoint files, by SHA-256 (<path>/<sha256>), for copying them to the owner's other machines; authenticated by a snapshot read grant (HostSnapshotsService.ExportHostSnapshot), with HTTP range requests. Served by hosts that provide Spaces.
VIEWER_PATH/viewerThe web viewer (static page, unauthenticated; it reads its viewer ticket from the URL fragment). Served with and without the trailing slash; assets live under /viewer/.

gRPC-Web fallbacks#

gRPC-Web cannot carry client streams, so every client-streaming RPC has a unary fallback (cua_proto::CLIENT_STREAM_FALLBACKS).

Client streamUnary fallback
/cua.env.v1.ProcessService/StreamInput/cua.env.v1.ProcessService/SendInput
/cua.env.v1.FilesystemService/WriteFile/cua.env.v1.FilesystemService/UploadChunk

Errors#

Errors are google.rpc.Status with typed details: spacesd packs ErrorInfo and the daemon packs DaemonErrorInfo.