Skip to main content

Module handshake

Module handshake 

Source
Expand description

The length-prefixed stdio handshake that precedes the WebSocket session.

Everything else in this protocol is protobuf-JSON, but the very first exchange is binary protobuf on the harness’s stdin/stdout:

client -> harness   u32le length, then a serialised InputConfig
harness -> client   u32le length, then a serialised OutputConfig

OutputConfig carries the loopback port the harness just bound and the per-process API key the WebSocket upgrade must present. Two messages, seven fields between them, so this module hand-rolls the wire format rather than taking a protobuf runtime dependency for it — see scripts/codegen_antigravity.py for why a runtime is otherwise unnecessary.

The field numbers below are pinned by the descriptor snapshot in tests/schemas/localharness.descriptor.bin, and this module’s tests lock them against bytes captured from a live 0.1.10 harness.

Enums§

DecodeError
A malformed handshake reply.

Functions§

decode_output_config
Parses the OutputConfig the harness writes to stdout.
encode_input_config
Serialises an InputConfig to binary protobuf, fields in tag order.
frame
Prefixes a serialised message with its length, as the harness expects.