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::Usagepayload into aTurnUsagecounter. - build_
tools_ list_ body - Build the
tools_listresponse body from aToolRegistryschema snapshot. - build_
user_ content - map_
stream_ event - Map a single
StreamEventto an optionalRpcEvent. - merge_
split - Option-accumulate for the cache-TTL split buckets: stay
Noneuntil a split value arrives, then sum.Nonemeans “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.