Skip to main content

Module rpc_protocol

Module rpc_protocol 

Source
Expand description

RPC protocol types for the synaps-bridge parent↔child IPC channel.

§Overview

The synaps-bridge RPC protocol enables a parent process to spawn a long-lived “rpc child” process and communicate with it over a pair of stdio pipes (child’s stdin / stdout). This module defines every message type exchanged over that channel.

See also: synaps-bridge.SPEC.md §4 (path: /home/jr/Projects/Maha-Media/synaps-bridge.SPEC.md).

§Framing

  • Encoding: UTF-8, line-delimited JSON (LDJSON / NDJSON).
  • One frame per line: each JSON object is terminated by a single \n (0x0A). No Content-Length header or other envelope.
  • Max frame size: 1 MiB (1 048 576 bytes). Frames that exceed this limit are considered malformed. The rpc child must emit an RpcEvent::Error with id: None and remain alive when it encounters an oversized inbound frame. Enforcement logic lives in Task 2.
  • Direction: the parent writes RpcCommand frames to the child’s stdin; the child writes RpcEvent frames to its stdout.

§Version semantics

The current protocol version is RPC_PROTOCOL_VERSION = 1. The child emits RpcEvent::Ready immediately after startup, advertising its protocol_version. The parent must refuse to proceed if the version does not match its own expectation.

§Correlation

Every RpcCommand variant except RpcCommand::Shutdown carries an id: String field. The rpc child echoes the same id in the corresponding RpcEvent::Response frame, allowing the parent to correlate requests and responses. The id format is opaque to the child (UUID, monotonic counter, or any other string).

Structs§

RpcAttachment
A file attachment included with a RpcCommand::Prompt message.
TurnUsage
Token-usage summary for a completed agent turn.

Enums§

AssistantEvent
Granular events emitted by the assistant during a streaming turn.
RpcCommand
Commands sent from the parent process to the rpc child over the child’s stdin.
RpcEvent
Events emitted by the rpc child to the parent over the child’s stdout.

Constants§

RPC_PROTOCOL_VERSION
Wire-format protocol version. Both sides must agree on this value; the child advertises it in its RpcEvent::Ready frame.