brainos-bridge 0.2.0

WebSocket relay client for connecting external platforms to Brain OS
Documentation

Brain Bridge

External service relay — WebSocket client that connects Brain to remote messaging gateways (Slack bots, Telegram bridges, custom agents, etc.) and relays inbound messages through Brain's signal processing pipeline.

Protocol

  1. BridgeClient connects to the configured url via WebSocket.
  2. Each inbound text frame must be a JSON-encoded [BridgeMessage].
  3. A caller-supplied handler function processes the message and returns a [BridgeMessage] response.
  4. The response is serialised and sent back as a text frame.
  5. 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(())
# }