Crate tower_a2a

Crate tower_a2a 

Source
Expand description

§Tower A2A

A Tower-based implementation of the Agent2Agent (A2A) protocol.

This library provides a composable, transport-agnostic implementation of the A2A protocol using Tower’s Service and Layer abstractions. It supports multiple transport protocols (HTTP, gRPC, WebSocket) through a unified interface.

§Features

  • Transport Agnostic: Works with HTTP, gRPC, WebSocket, or custom transports
  • Composable Middleware: Auth, retry, timeout, validation as Tower layers
  • Type Safe: Compile-time guarantees for protocol operations
  • Async: Built on tokio for high performance

§Example

use tower_a2a::prelude::*;
use std::time::Duration;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let url = "https://agent.example.com".parse().unwrap();
    let mut client = A2AClientBuilder::new_http(url)
        .with_bearer_auth("token123".to_string())
        .with_timeout(Duration::from_secs(30))
        .build()?;

    let agent_card = client.discover().await?;
    println!("Connected to: {}", agent_card.name);

    Ok(())
}

Modules§

client
High-level client API for A2A protocol
codec
Serialization codecs for different protocol bindings
layer
Tower Layer implementations for A2A protocol
prelude
Prelude module for convenient imports
protocol
Core A2A protocol types and definitions
service
Tower Service implementations
transport
Transport abstraction layer for A2A protocol