Expand description
AG-UI Client Consumer
This crate provides client-side event consumption for AG-UI streams. It enables Rust applications to connect to AG-UI agents and receive real-time event streams via SSE or WebSocket.
§Features
- SSE Client: Connect to Server-Sent Events endpoints
- WebSocket Client: Connect to WebSocket endpoints
- Event Stream: Unified stream abstraction for both transports
- State Reconstruction: Apply state deltas to reconstruct agent state
§Example
ⓘ
use ag_ui_client::{SseClient, EventStream};
use futures::StreamExt;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Connect to SSE endpoint
let client = SseClient::connect("http://localhost:3000/events").await?;
// Process events
let mut stream = client.into_stream();
while let Some(event) = stream.next().await {
match event {
Ok(event) => println!("Received: {:?}", event.event_type()),
Err(e) => eprintln!("Error: {}", e),
}
}
Ok(())
}Re-exports§
pub use error::ClientError;pub use sse::SseClient;pub use state::StateReconstructor;pub use ws::WsClient;
Modules§
- error
- Error types for AG-UI client operations.
- sse
- SSE (Server-Sent Events) Client
- state
- State Reconstruction
- ws
- WebSocket Client