Skip to main content

a2a_client/
lib.rs

1//! # A2A Protocol Client
2//!
3//! This crate provides a client for calling remote A2A (Agent-to-Agent) protocol compliant agents.
4//! It supports both streaming and non-streaming interactions over HTTP/HTTPS.
5//!
6//! ## Features
7//!
8//! - A2A v1 transport support over HTTP+JSON and JSON-RPC 2.0
9//! - Non-streaming and streaming message support
10//! - Task retrieval and listing
11//! - Agent discovery via agent cards
12//! - Authentication support (Bearer tokens)
13//! - Error handling with detailed error types
14//!
15//! ## Example
16//!
17//! ```rust,no_run
18//! use a2a_client::A2AClient;
19//! use a2a_types::{Message, Part, Role, SendMessageRequest, part};
20//!
21//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
22//! // Create client from agent card URL
23//! let client = A2AClient::from_card_url("https://agent.example.com")
24//!     .await?
25//!     .with_auth_token("your_api_key");
26//!
27//! // Create message
28//! let message = Message {
29//!     message_id: "msg_123".to_string(),
30//!     context_id: String::new(),
31//!     task_id: String::new(),
32//!     role: Role::User.into(),
33//!     parts: vec![Part {
34//!         content: Some(part::Content::Text("Hello!".to_string())),
35//!         metadata: None,
36//!         filename: String::new(),
37//!         media_type: "text/plain".to_string(),
38//!     }],
39//!     metadata: None,
40//!     extensions: Vec::new(),
41//!     reference_task_ids: Vec::new(),
42//! };
43//!
44//! // Send message
45//! let result = client
46//!     .send_message(SendMessageRequest {
47//!         tenant: String::new(),
48//!         message: Some(message),
49//!         configuration: None,
50//!         metadata: None,
51//!     })
52//!     .await?;
53//! # let _ = result;
54//! # Ok(())
55//! # }
56//! ```
57
58pub mod client;
59pub mod constants;
60pub mod error;
61
62pub use client::A2AClient;
63pub use error::{A2AError, A2AResult};
64
65/// Re-export A2A protocol types so downstream crates can ensure they use the
66/// exact same type definitions as the client.
67pub mod types {
68    pub use a2a_types::{self as v1, JSONRPCError, JSONRPCErrorResponse, JSONRPCId};
69}