Skip to main content

lc_a2a/
lib.rs

1#![warn(missing_docs)]
2//! A2A (Agent-to-Agent) protocol support.
3//!
4//! This module implements the A2A protocol for inter-agent communication.
5//! It enables LangChain Rust agents to discover, invoke, and communicate
6//! with other agents over HTTP using a JSON-RPC style protocol.
7//!
8//! # Architecture
9//!
10//! - **protocol**: Core data types (`AgentCard`, `A2ATask`, `A2ARequest`, etc.)
11//! - **server**: `A2AServer` - handler functions to expose an agent via A2A
12//! - **client**: `A2AClient` - HTTP client to connect to remote A2A agents
13//! - **rate_limiter**: `RateLimiter` - concurrency + per-minute request limits
14//!
15//! # Quick Start
16//!
17//! ## Server (expose your agent)
18//!
19//! ```ignore
20//! use lc_a2a::{A2AServer, AgentCard};
21//! use lc_chains::LLMChain;
22//! use std::sync::Arc;
23//!
24//! let chain = Arc::new(LLMChain::new(llm, "You are a helpful assistant"));
25//! let server = A2AServer::new(chain)
26//!     .with_card(AgentCard::new("my-agent", "A helpful agent", "http://localhost:8080"));
27//!
28//! // In your HTTP handler (axum, actix, warp, etc.):
29//! // GET /.well-known/agent-card.json -> server.get_agent_card()
30//! // POST / -> server.handle_a2a_request(body).await
31//! ```
32//!
33//! ## Client (call a remote agent)
34//!
35//! ```ignore
36//! use lc_a2a::{A2AClient, A2AMessage};
37//!
38//! let client = A2AClient::new("http://localhost:8080".to_string()).unwrap();
39//! let card = client.get_agent_card().await?;
40//! let task = client.send_task(A2AMessage::user("hello")).await?;
41//! ```
42
43pub mod agent_adapter;
44pub mod client;
45pub mod discovery;
46pub mod gateway;
47pub mod protocol;
48pub mod rate_limiter;
49pub mod resilient;
50pub mod router;
51pub mod scale;
52pub mod security;
53pub mod server;
54#[cfg(feature = "axum")]
55pub mod server_impl;
56pub mod store;
57
58pub use agent_adapter::AgentExecutorChain;
59pub use client::{A2AClient, A2AClientBuilder, A2AError};
60pub use discovery::{AgentRegistry, RegistryClient, RegistryError};
61pub use gateway::{CallPolicy, DataContract, FederationGateway, GatewayError};
62pub use protocol::{
63    metadata_keys, A2AErrorData, A2AMessage, A2ARequest, A2AResponse, A2ATask, A2ATaskDetails,
64    A2ATaskResult, A2AWorkflow, AgentCard, AgentSkill, MessageEnvelope, TaskFilter,
65    TaskPushNotification, TaskStatus, TraceContext, WorkflowStep,
66};
67pub use rate_limiter::{RateLimitError, RateLimiter};
68pub use resilient::{ResilienceConfig, ResilientA2AClient};
69pub use router::{SkillMapRouter, SkillRouter};
70pub use scale::{
71    AgentTier, BreakerState, CircuitBreaker, CircuitBreakerConfig, DelegationGuard,
72    HierarchyPolicy, ScaleError, SkillEntry, SkillIndex, StickyRouter, TaskGraph, TaskSharder,
73};
74pub use security::{
75    AccessRequest, SandboxConfig, SecurityError, TrustConfig, TrustRegistry, TrustRole,
76    TrustVerification, TrustedAgent,
77};
78pub use server::A2AServer;
79pub use store::{in_memory_store, InMemoryTaskStore, StoreError, StoredTask, TaskStore};