Expand description
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.
Re-exports§
pub use broadcast::WebBroadcastHandler;pub use broadcast::WsMessage;pub use ext::ChoiceMetadata;pub use ext::NoWebExtension;pub use ext::StatusField;pub use ext::WebExtensionRenderer;pub use snapshot::UiStateSnapshot;
Modules§
- broadcast
EventHandlerthat converts harness events into WebSocket messages.- ext
- Extension trait for domain-specific web UI rendering.
- snapshot
- Serializable projection of
UiStatefor WebSocket and REST transport.
Structs§
- WebConfig
- Configuration for the web server.
Functions§
- spawn_
web - Spawn the web server on a Tokio task.