Skip to main content

lc_a2a/
lib.rs

1//! A2A (Agent-to-Agent) protocol support.
2//!
3//! This module implements the A2A protocol for inter-agent communication.
4//! It enables LangChain Rust agents to discover, invoke, and communicate
5//! with other agents over HTTP using a JSON-RPC style protocol.
6//!
7//! # Architecture
8//!
9//! - **protocol**: Core data types (`AgentCard`, `A2ATask`, `A2ARequest`, etc.)
10//! - **server**: `A2AServer` - handler functions to expose an agent via A2A
11//! - **client**: `A2AClient` - HTTP client to connect to remote A2A agents
12//!
13//! # Quick Start
14//!
15//! ## Server (expose your agent)
16//!
17//! ```ignore
18//! use lc_a2a::{A2AServer, AgentCard};
19//! use lc_chains::LLMChain;
20//! use std::sync::Arc;
21//!
22//! let chain = Arc::new(LLMChain::new(llm, "You are a helpful assistant"));
23//! let server = A2AServer::new(chain)
24//!     .with_card(AgentCard::new("my-agent", "A helpful agent", "http://localhost:8080"));
25//!
26//! // In your HTTP handler (axum, actix, warp, etc.):
27//! // GET /.well-known/agent.json -> server.get_agent_card()
28//! // POST / -> server.handle_a2a_request(body).await
29//! ```
30//!
31//! ## Client (call a remote agent)
32//!
33//! ```ignore
34//! use lc_a2a::{A2AClient, A2AMessage};
35//!
36//! let client = A2AClient::new("http://localhost:8080".to_string());
37//! let card = client.get_agent_card().await?;
38//! let task = client.send_task(A2AMessage::user("hello")).await?;
39//! ```
40
41pub mod client;
42pub mod protocol;
43pub mod server;
44
45pub use client::{A2AClient, A2AError};
46pub use protocol::{
47    A2AErrorData, A2AMessage, A2ARequest, A2AResponse, A2ATask, A2ATaskResult, AgentCard,
48    TaskStatus,
49};
50pub use server::A2AServer;