cinch-web 0.4.0

Browser-based chat UI for cinch-rs powered agents
Documentation

Browser-based chat UI for cinch-rs powered agents.

cinch-web provides an axum web server that exposes a WebSocket endpoint for real-time agent observation and a REST API for control. It is designed to be paired with a Next.js 16 frontend but works with any WebSocket client.

Quick start

use cinch_web::{WebConfig, spawn_web};
use cinch_rs::ui::UiState;
use std::sync::{Arc, Mutex};

let ui_state = Arc::new(Mutex::new(UiState::default()));
let (ws_tx, _) = tokio::sync::broadcast::channel(256);

let config = WebConfig::default();
let (addr, chat_rx) = spawn_web(ui_state, ws_tx, config).await;
println!("Web UI: http://{addr}");

// Read user messages sent from the browser:
while let Some(msg) = chat_rx.recv().await {
    println!("User said: {msg}");
}

Architecture

Agent runtime ──HarnessEvent──▶ WebBroadcastHandler ──WsMessage──▶ WebSocket clients
                                                                        ▲
          Arc<Mutex<UiState>> ◀── /api/answer, /api/control ────────────┘

The [WebBroadcastHandler] implements EventHandler and converts harness events into serialized WebSocket messages. Compose it alongside UiEventHandler in a CompositeEventHandler.