Skip to main content

ag_ui/client/
mod.rs

1//! Consume an AG-UI agent through local conversations.
2//!
3//! [`Thread`] maintains history, current state and pending interrupts. Every
4//! `send` or `resume_many` returns a checked, lazily dispatched [`RunStream`].
5//! Use [`RunStream::collect_report`] for the outcome and retained diagnostics,
6//! or consume [`Update`] values for a streaming UI. Configure `on_event` to
7//! observe every decoded event while preserving automatic state management.
8//!
9//! With feature `http`, `HttpAgent::new(url)?.thread(id)` is the standard
10//! entrypoint. [`RemoteAgent::run_events`] and [`Transport`] expose unassembled
11//! events for proxies and custom transports. The `client` feature requires no
12//! executor; HTTP support is an additional opt-in feature.
13//!
14//! ```
15//! use ag_ui::client::{Thread, transport::ReplayTransport};
16//! use ag_ui::Event;
17//! let mut thread = Thread::new(ReplayTransport::new([]), "thread-1");
18//! thread.set_state(serde_json::json!({"checked": false}))?;
19//! assert_eq!(thread.state()?["checked"], false);
20//! // Preparing and dropping a request without polling does not send or append it.
21//! drop(thread.send("Hello")?);
22//! assert!(thread.messages().is_empty());
23//! # Ok::<(), Box<dyn std::error::Error>>(())
24//! ```
25
26pub mod agent;
27pub mod apply;
28pub mod chunks;
29mod enforce;
30pub mod error;
31pub mod interrupts;
32pub mod thread;
33pub mod transport;
34pub mod verify;
35
36pub use agent::{RemoteAgent, RunParams};
37pub use apply::{
38    Applier, Changed, MessageChange, MessageChangeKind, ReasoningChange, ReasoningChangeKind,
39    Subagent, SubagentChange, SubagentChangeKind, SubagentStatus,
40};
41pub use chunks::{ChunkNormalizer, normalize_all};
42pub use error::{Error, Result};
43pub use interrupts::{InterruptExt, ResumeBuilder, interrupts_of, resume_run};
44pub use thread::{
45    AbortHandle, MergeReport, MessageUpdate, ReasoningUpdate, ResumeSubmission, RunDiagnostic,
46    RunEnd, RunReport, RunStream, RunSummary, StateViewError, SubagentUpdate, SubmissionStatus,
47    Thread, ThreadBuilder, ThreadSnapshot, Update, merge_messages,
48};
49pub use transport::{EventStream, Transport, TransportStream};
50pub use verify::{Verifier, verify_all};
51
52#[cfg(feature = "http")]
53pub use agent::{HttpAgent, HttpAgentBuilder};