Skip to main content

Module rpc_dispatch

Module rpc_dispatch 

Source
Expand description

Pure helper functions for the synaps rpc command dispatcher.

These are extracted from cmd::rpc so they can be unit-tested via cargo test --lib without hitting the binary-crate’s TUI dependencies.

See docs/rpc-protocol.md and synaps-bridge.SPEC.md §4 for the wire protocol specification these functions implement.

Constants§

MAX_FRAME_BYTES
Maximum allowed inbound frame size in bytes (1 MiB).

Functions§

accumulate_usage
Accumulate a SessionEvent::Usage payload into a TurnUsage counter.
build_tools_list_body
Build the tools_list response body from a ToolRegistry schema snapshot.
build_user_content
map_stream_event
Map a single StreamEvent to an optional RpcEvent.
merge_split
Option-accumulate for the cache-TTL split buckets: stay None until a split value arrives, then sum. None means “split never reported” — distinct from an explicit zero. Shared by every Usage accumulator that tracks the 5m/1h breakdown (RPC dispatch, subagent loops).
parse_frame
Parse a raw UTF-8 line into an RpcCommand, enforcing the 1 MiB frame limit.