Skip to main content

Crate zeph_a2a

Crate zeph_a2a 

Source
Expand description

A2A (Agent-to-Agent) protocol client, server, and agent discovery for Zeph.

This crate implements the A2A protocol — a JSON-RPC 2.0 based specification for communication between AI agents. It provides:

  • Client (A2aClient): sends messages and streams responses to remote A2A agents.
  • Server (A2aServer, feature server): exposes an HTTP endpoint that accepts A2A JSON-RPC requests and streams Server-Sent Events (SSE) for real-time output.
  • Discovery (AgentRegistry): fetches and caches agent capability cards from /.well-known/agent.json with configurable TTL.
  • Capability cards (AgentCardBuilder): builds AgentCard metadata describing the agent’s skills, I/O modes, and protocol version.
  • IBCT (Ibct, feature ibct): Invocation-Bound Capability Tokens for scoped delegation — HMAC-SHA256 signed tokens bound to a specific task and endpoint.
  • JSON-RPC 2.0 types (jsonrpc): request/response envelope types and the A2A method name constants.
  • Protocol types (types): shared wire-format types re-exported at the crate root.

§Architecture

zeph-a2a is an optional feature-gated dependency of the main zeph binary. The A2aServer is started by zeph-core as a background service when [a2a] is enabled in config. The A2aClient is used by the agent to delegate tasks to peer agents discovered through the AgentRegistry.

§Features

FeatureDescription
serverEnables A2aServer, TaskManager, and TaskProcessor
ibctEnables Ibct token issuance and verification (HMAC-SHA256)

§Examples

use zeph_a2a::{A2aClient, AgentCardBuilder, AgentRegistry, SendMessageParams, Message};
use std::time::Duration;

// Build an agent card for this agent.
let card = AgentCardBuilder::new("my-agent", "http://localhost:8080", "0.1.0")
    .description("A helpful AI agent")
    .streaming(true)
    .build();

// Discover a peer agent's capabilities.
let registry = AgentRegistry::new(reqwest::Client::new(), Duration::from_secs(300));
let peer_card = registry.discover("http://peer-agent.example.com").await?;

// Send a message to the peer agent.
let client = A2aClient::new(reqwest::Client::new());
let params = SendMessageParams {
    message: Message::user_text("Hello, peer agent!"),
    configuration: None,
};
let task = client.send_message(&peer_card.url, params, None).await?;
println!("Task {} in state {:?}", task.id, task.status.state);

Re-exports§

pub use card::AgentCardBuilder;
pub use client::A2aClient;
pub use client::TaskEvent;
pub use client::TaskEventStream;
pub use discovery::AgentRegistry;
pub use error::A2aError;
pub use ibct::Ibct;
pub use ibct::IbctError;
pub use ibct::IbctKey;
pub use jsonrpc::SendMessageParams;
pub use types::*;

Modules§

card
Builder for AgentCard capability advertisement documents.
client
A2A protocol HTTP client with optional TLS enforcement and SSRF protection.
discovery
Agent discovery via /.well-known/agent.json with TTL-based caching.
error
Error types for A2A client, server, and discovery operations.
ibct
Invocation-Bound Capability Tokens (IBCT) for A2A delegation.
jsonrpc
JSON-RPC 2.0 envelope types and A2A method constants.
types
Wire-format types for the A2A protocol.

Constants§

A2A_PROTOCOL_VERSION
A2A protocol version implemented by this crate.