3.2 Transports
Every transport carries JSON-RPC 2.0 messages encoded as UTF-8 JSON. This version defines two transports. Both reach the same Hub functions, so a method behaves the same on either.
3.2.1 WebSocket
- The Hub serves the protocol at
ws://127.0.0.1:7420/rpc. The port is configurable. - Each WebSocket text frame MUST carry exactly one JSON-RPC message.
- Clients MUST NOT send binary frames.
- The Hub applies the network rules in Security before it accepts the connection.
3.2.2 stdio
- A Client that spawns a process runs
openhal rpc. It bridges the process'sstdinandstdoutto the Hub's WebSocket. - Each message is one line of UTF-8 JSON ending in
\n. A message MUST NOT contain a raw newline. - The bridge writes nothing but messages to
stdout. Diagnostics go tostderr. - When
stdincloses, the bridge closes the WebSocket.
3.2.3 Authentication
Every connection authenticates with a bearer token (Security).
- The Client sends the token in the
Authorization: Bearer <token>header of the WebSocket handshake, or in thetokenparam ofhal/initialize. - A stdio Client sends the token in
hal/initialize. - A missing, unknown or revoked token gets
UNAUTHORIZED(-32002). - The Hub maps the token to one Principal for the life of the connection.
hal/initializereports it. - The Hub MUST NOT log tokens. The reference Hub redacts
tokenfrom thehal/initializeparams it records.
3.2.4 Other front ends
The reference Hub also serves a REST API under /v1 with the same tokens and network rules. It is a convenience for its dashboard and scripts and is not part of this specification.