Skip to main content

Module client

Module client 

Source
Expand description

Consume an AG-UI agent through local conversations.

Thread maintains history, current state and pending interrupts. Every send or resume_many returns a checked, lazily dispatched RunStream. Use RunStream::collect_report for the outcome and retained diagnostics, or consume Update values for a streaming UI. Configure on_event to observe every decoded event while preserving automatic state management.

With feature http, HttpAgent::new(url)?.thread(id) is the standard entrypoint. RemoteAgent::run_events and Transport expose unassembled events for proxies and custom transports. The client feature requires no executor; HTTP support is an additional opt-in feature.

use ag_ui::client::{Thread, transport::ReplayTransport};
use ag_ui::Event;
let mut thread = Thread::new(ReplayTransport::new([]), "thread-1");
thread.set_state(serde_json::json!({"checked": false}))?;
assert_eq!(thread.state()?["checked"], false);
// Preparing and dropping a request without polling does not send or append it.
drop(thread.send("Hello")?);
assert!(thread.messages().is_empty());

Re-exports§

pub use agent::RemoteAgent;
pub use agent::RunParams;
pub use apply::Applier;
pub use apply::Changed;
pub use apply::MessageChange;
pub use apply::MessageChangeKind;
pub use apply::ReasoningChange;
pub use apply::ReasoningChangeKind;
pub use apply::Subagent;
pub use apply::SubagentChange;
pub use apply::SubagentChangeKind;
pub use apply::SubagentStatus;
pub use chunks::ChunkNormalizer;
pub use chunks::normalize_all;
pub use error::Error;
pub use error::Result;
pub use interrupts::InterruptExt;
pub use interrupts::ResumeBuilder;
pub use interrupts::interrupts_of;
pub use interrupts::resume_run;
pub use thread::AbortHandle;
pub use thread::MergeReport;
pub use thread::MessageUpdate;
pub use thread::ReasoningUpdate;
pub use thread::ResumeSubmission;
pub use thread::RunDiagnostic;
pub use thread::RunEnd;
pub use thread::RunReport;
pub use thread::RunStream;
pub use thread::RunSummary;
pub use thread::StateViewError;
pub use thread::SubagentUpdate;
pub use thread::SubmissionStatus;
pub use thread::Thread;
pub use thread::ThreadBuilder;
pub use thread::ThreadSnapshot;
pub use thread::Update;
pub use thread::merge_messages;
pub use transport::EventStream;
pub use transport::Transport;
pub use transport::TransportStream;
pub use verify::Verifier;
pub use verify::verify_all;
pub use agent::HttpAgent;
pub use agent::HttpAgentBuilder;

Modules§

agent
The low-level API: start a run, get its events.
apply
Turning a stream of events into materialised state.
chunks
Normalizing *_CHUNK events into explicit start/content/end triples.
error
Errors this crate can produce.
interrupts
The human-in-the-loop round trip.
thread
A local conversation: independent history, state and human input over a shared transport.
transport
Getting events from somewhere.
verify
Client-side protocol verification.