Brain Bridge
External service relay — WebSocket client that connects Brain to a remote messaging gateway and relays inbound messages through Brain's signal processing pipeline.
Protocol
BridgeClientconnects to the configuredurlvia WebSocket.- Each inbound text frame must be a JSON-encoded [
BridgeMessage]. - A caller-supplied
handlerfunction processes the message and returns a [BridgeMessage] response. - The response is serialised and sent back as a text frame.
- On disconnect, the client reconnects with exponential backoff.
Usage
# use brainos_bridge::{BridgeClient, BridgeConfig, BridgeMessage};
# #[tokio::main] async fn main() -> anyhow::Result<()> {
let client = BridgeClient::new("ws://gateway.example.com/brain", BridgeConfig::default());
client.connect_and_relay(|msg| async move {
BridgeMessage::reply(&msg, format!("Echo: {}", msg.content))
}).await?;
# Ok(())
# }