rua.capabilities holds the rua/0 wire both sides share: the capability factory, the client, and the codec.
Direct control and code control are the clients of a running env, so an agent does not dial it.
robot_capability
rua/0, the URL normalized with default scheme ws
and default port 9091, and params={"contract": contract}. Bridges call it from capabilities().
RobotClient
rua/0 connection. Importing rua registers it with HUD, so await run.client.open("robot")
returns one. To dial directly:
get_observation returns:
The wire
The robot wire (protocolrua/0, the constant PROTOCOL) is a WebSocket carrying msgpack frames, with numpy
arrays encoded by the codec below (packb / unpackb). The env is the server. A string (text) frame in either direction is
an error message, usually a traceback.
An observation frame is the slot’s row of every data array, plus
"terminated": bool, plus "reward" when the
sim put one in its data. A frame with terminated: true is the slot’s last; the bridge stops waiting for its
actions. Rejections (an unknown token, a slot that already has a connection, a malformed claim) arrive as a
string frame, then the socket closes.
RobotClient skips the claim when the server doesn’t send claim_required and no token is given.
The control channel
Each bridge also serves a TCP control channel speaking JSON-RPC 2.0, framed with HUD’s control-channel framing (hud.environment.send_frame / read_frame). RobotEndpoint is its client; requests are serialized, one in
flight at a time.
Errors use code
-32001 when every slot is claimed (SlotsFull, which the endpoint retries) and -32000
otherwise.
Tokens look like slot-<index>-<8 hex>. A reset while every slot is free resets the sim for the whole batch;
later claims must pass identical task args, or get ValueError. A freed slot is reclaimable only once every slot
is free again.
Codec
packb(frame) -> bytes and unpackb(data) are msgpack with numpy support, so nested arrays and numpy scalars
travel without manual wrapping. Both ends of the wire use them.
Keys of those maps are byte strings. Structured, object and complex dtypes raise
ValueError on packb. Frames
packed by one version of rua/0 unpack under any other.