a2a-protocol-types
Pure A2A protocol v1.0 data types -- serde only, no I/O.
Overview
- All A2A v1.0 wire types with zero I/O dependencies
- Just
serde+serde_jsonfor serialization - Foundation crate used by
a2a-protocol-clientanda2a-protocol-server - Use this crate when you need A2A types without the full HTTP stack
Key Types
| Module | Key Types | Purpose |
|---|---|---|
agent_card |
AgentCard, AgentCapabilities, AgentSkill |
Agent discovery (/.well-known/agent.json) |
task |
Task, TaskStatus, TaskState, TaskId, ContextId |
Unit of work lifecycle |
message |
Message, Part, MessageRole, FileContent |
Communication with text/file/data parts |
artifact |
Artifact, ArtifactId |
Discrete agent outputs |
error |
A2aError, ErrorCode, A2aResult |
Protocol errors (14 codes) |
jsonrpc |
JsonRpcRequest, JsonRpcResponse |
JSON-RPC 2.0 envelope |
events |
StreamResponse, TaskStatusUpdateEvent, TaskArtifactUpdateEvent |
SSE streaming events |
security |
SecurityScheme, SecurityRequirement |
API Key, OAuth 2.0, OpenID, mTLS |
params |
MessageSendParams, TaskQueryParams, ListTasksParams |
Method parameters for all 11 A2A methods |
responses |
SendMessageResponse, TaskListResponse |
Method result types |
push |
TaskPushNotificationConfig |
Push notification config |
extensions |
AgentExtension, AgentCardSignature |
Optional agent capabilities |
signing |
JWS signing functions | Agent card signing (feature-gated) |
Features
| Feature | Purpose |
|---|---|
signing |
Agent card signing (JWS/ES256, RFC 8785 canonicalization). Adds ring and base64. |
Usage
use *;
// Agent card discovery
let card: AgentCard = from_str?;
// Create a message
let msg = Message ;
// Streaming events
match event
Protocol Constants
A2A_VERSION--"1.0.0"A2A_CONTENT_TYPE--"application/a2a+json"A2A_VERSION_HEADER--"A2A-Version"
Design Notes
- ID newtypes for type safety:
TaskId,ContextId,MessageId,ArtifactId #[non_exhaustive]on enums for forward-compatible additions- ProtoJSON naming:
TaskState::Completedserializes as"TASK_STATE_COMPLETED" - No unsafe code:
#![deny(unsafe_op_in_unsafe_fn)] - All types documented:
#![deny(missing_docs)] - Property-tested: JSON ser/de round-trip verified via
proptest
License
Apache-2.0