Skip to main content

a2a_protocol_server/
lib.rs

1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2026 Tom F.
3
4//! A2A protocol v1.0 — server framework.
5//!
6//! Provides [`RequestHandler`] and [`AgentExecutor`] for implementing A2A
7//! agents over HTTP/1.1 and HTTP/2 using hyper 1.x.
8//!
9//! # Quick start
10//!
11//! 1. Implement [`AgentExecutor`] with your agent logic.
12//! 2. Build a [`RequestHandler`] via [`RequestHandlerBuilder`].
13//! 3. Wire [`JsonRpcDispatcher`] or [`RestDispatcher`] into your hyper server.
14//!
15//! # Module overview
16//!
17//! | Module | Contents |
18//! |---|---|
19//! | [`error`] | [`ServerError`], [`ServerResult`] |
20//! | [`executor`] | [`AgentExecutor`] trait |
21//! | [`handler`] | [`RequestHandler`], [`SendMessageResult`] |
22//! | [`builder`] | [`RequestHandlerBuilder`] |
23//! | [`store`] | [`TaskStore`], [`InMemoryTaskStore`] |
24//! | [`streaming`] | Event queues, SSE response builder |
25//! | [`push`] | Push config store, push sender |
26//! | [`agent_card`] | Static/dynamic agent card handlers |
27//! | [`dispatch`] | [`JsonRpcDispatcher`], [`RestDispatcher`] |
28//! | [`interceptor`] | [`ServerInterceptor`], [`ServerInterceptorChain`] |
29//! | [`request_context`] | [`RequestContext`] |
30//! | [`call_context`] | [`CallContext`] |
31//!
32//! # Transport limitations
33//!
34//! The A2A specification lists gRPC as an optional transport binding. This
35//! implementation currently supports **HTTP + SSE only**; gRPC transport is
36//! not yet implemented.
37//!
38//! # Rate limiting
39//!
40//! This library does **not** perform request rate limiting. Deployments that
41//! require rate limiting should handle it in a reverse proxy (e.g. nginx,
42//! Envoy) or a middleware layer in front of the A2A handler.
43
44#![deny(missing_docs)]
45#![deny(unsafe_op_in_unsafe_fn)]
46#![warn(clippy::all, clippy::pedantic, clippy::nursery)]
47#![allow(clippy::module_name_repetitions)]
48
49#[macro_use]
50mod trace;
51
52pub mod agent_card;
53pub mod builder;
54pub mod call_context;
55pub mod dispatch;
56pub mod error;
57pub mod executor;
58pub mod handler;
59pub mod interceptor;
60pub mod metrics;
61pub mod push;
62pub mod request_context;
63pub mod store;
64pub mod streaming;
65
66// ── Flat re-exports ───────────────────────────────────────────────────────────
67
68pub use agent_card::{
69    AgentCardProducer, DynamicAgentCardHandler, StaticAgentCardHandler, CORS_ALLOW_ALL,
70};
71pub use builder::RequestHandlerBuilder;
72pub use call_context::CallContext;
73pub use dispatch::{CorsConfig, JsonRpcDispatcher, RestDispatcher};
74pub use error::{ServerError, ServerResult};
75pub use executor::AgentExecutor;
76pub use handler::{RequestHandler, SendMessageResult};
77pub use interceptor::{ServerInterceptor, ServerInterceptorChain};
78pub use push::{HttpPushSender, InMemoryPushConfigStore, PushConfigStore, PushSender};
79pub use request_context::RequestContext;
80pub use store::{InMemoryTaskStore, TaskStore, TaskStoreConfig};
81pub use streaming::{
82    EventQueueManager, EventQueueReader, EventQueueWriter, InMemoryQueueReader, InMemoryQueueWriter,
83};