Expand description
Two framings over a byte stream, sharing the JSON-RPC codec in the parent
module (crate::rpc).
- NDJSON (
read_line/write_line): one JSON value per line, no embedded newlines. The MCP stdio transport framing. - Length-prefix (
read_frame/write_frame): a 4-byte big-endian length followed by that many payload bytes. The private supervisor↔ subagent control channel — robust to payloads (instructions, context seeds, distilled results) that legitimately contain newlines.
Both are generic over Read/Write so they drop onto pipes, unix
sockets, TLS streams, and vsock alike.
Constants§
- MAX_
FRAME - Hard cap on a single frame/line, for both framings. A peer claiming more is a protocol error, not an allocation. 16 MiB matches the MCP-side cap.
Functions§
- read_
frame - Read one length-prefixed frame. Returns
Ok(None)on clean EOF before the length prefix (orderly shutdown). A declared length overMAX_FRAMEis rejected before allocation. - read_
line - Read one newline-delimited frame. Returns
Ok(None)on clean EOF (the peer closed the stream between messages — an orderly shutdown signal). A line longer thanMAX_FRAMEis an error. - write_
frame - Write a 4-byte big-endian length prefix followed by the JSON payload.
- write_
line - Serialize
valueas compact JSON plus a trailing\n. Errors if the encoded form contains a newline (it cannot for valid compact JSON, but we assert the invariant the transport relies on).