a2a_protocol_core
A2A Protocol Core — v1.0.0
Section titled “A2A Protocol Core — v1.0.0”Pure A2A (Agent-to-Agent) protocol domain logic, completely transport agnostic.
Constants
Section titled “Constants”A2A_PROTOCOL_VERSION
Section titled “A2A_PROTOCOL_VERSION”const A2A_PROTOCOL_VERSION: &str = ;A2A Protocol Version
Type Aliases
Section titled “Type Aliases”A2AResult
Section titled “A2AResult”type A2AResult = Result<T, A2AError>;A2AMethodHandler
Section titled “A2AMethodHandler”type A2AMethodHandler = Arc<dyn Fn + Send + Sync>;A2A Method Handler function type
Handlers receive a JSON-RPC request and return a JSON-RPC response. All A2A protocol logic is handled through JSON-RPC 2.0 messages.
A2ANotificationHandler
Section titled “A2ANotificationHandler”type A2ANotificationHandler = Arc<dyn Fn + Send + Sync>;A2A Notification Handler function type
Notification handlers receive notifications and perform side effects without returning responses (fire-and-forget).
MessageSendParams
Section titled “MessageSendParams”type MessageSendParams = SendMessageRequest;MessageSendResponse
Section titled “MessageSendResponse”type MessageSendResponse = SendMessageResponse;TaskCancelParams
Section titled “TaskCancelParams”type TaskCancelParams = CancelTaskRequest;TaskGetParams
Section titled “TaskGetParams”type TaskGetParams = GetTaskRequest;TaskListParams
Section titled “TaskListParams”type TaskListParams = ListTasksRequest;TaskListResult
Section titled “TaskListResult”type TaskListResult = ListTasksResponse;Traits
Section titled “Traits”A2ATransport
Section titled “A2ATransport”A2A Transport trait
Defines the interface for sending A2A protocol messages over various transport mechanisms. Implementations handle the actual network communication while the protocol core handles the A2A semantics.
Design Principles
Section titled “Design Principles”- Transport Agnostic: Works with HTTP, WebSocket, gRPC, etc.
- JSON-RPC Foundation: Uses JSON-RPC 2.0 message types
- Async Compatible: Supports both sync and async implementations
- Error Transparent: Transport errors are mapped to A2A errors
Examples
Section titled “Examples”use a2a_protocol_core::{A2ATransport, JsonRpcRequest, JsonRpcResponse, JsonRpcNotification, A2AResult};use serde_json::json;
// Mock transport implementationstruct MockTransport;
impl A2ATransport for MockTransport { async fn send_request(&self, request: JsonRpcRequest) -> A2AResult<JsonRpcResponse> { // Implementation sends request over network Ok(JsonRpcResponse::success(request.id, json!({"pong": true}))) }
async fn send_notification(&self, notification: JsonRpcNotification) -> A2AResult<()> { // Implementation sends notification (fire-and-forget) Ok(()) }
async fn health_check(&self) -> A2AResult<()> { // Check if transport is available Ok(()) }}Required / Provided Methods
async fn send_request(&self, request: JsonRpcRequest) -> A2AResult<JsonRpcResponse>Send a JSON-RPC request and wait for response
This method sends a request to a remote agent and waits for the response. The transport implementation handles the actual network communication, serialization, and correlation of requests with responses.
Arguments
Section titled “Arguments”request: The JSON-RPC 2.0 request to send
Returns
Section titled “Returns”Ok(JsonRpcResponse): The response from the remote agentErr(A2AError): Transport or protocol error
async fn send_notification(&self, notification: JsonRpcNotification) -> A2AResult<()>Send a JSON-RPC notification (fire-and-forget)
This method sends a notification to a remote agent without waiting for a response. Notifications are used for logging, metrics, events, and other operations where the sender doesn’t need confirmation.
Arguments
Section titled “Arguments”notification: The JSON-RPC 2.0 notification to send
Returns
Section titled “Returns”Ok(()): Notification was sent successfullyErr(A2AError): Transport error occurred
async fn health_check(&self) -> A2AResult<()>Check if the transport is available and healthy
This method verifies that the transport can communicate with remote agents. It’s used for health checks, circuit breakers, and load balancing decisions.
Returns
Section titled “Returns”Ok(()): Transport is healthy and availableErr(A2AError): Transport is unavailable or unhealthy
fn get_metadata(&self) -> HashMap<String, Value>Get transport-specific metadata
This method returns metadata about the transport implementation, such as connection info, capabilities, or configuration details.
Returns
Section titled “Returns”A map of metadata key-value pairs
fn transport_type(&self) -> &''static strGet the transport type identifier
Returns a string identifying the transport type (e.g., “http”, “websocket”). This is used for logging, monitoring, and debugging.
A2ATransportFactory
Section titled “A2ATransportFactory”A2A Transport Factory trait
Factory for creating transport instances for different agents or endpoints. This enables connection pooling, load balancing, and dynamic transport configuration.
Associated Types
type Transport— Transport type created by this factory
Required / Provided Methods
async fn create_transport(&self, agent_id: &str, endpoint: &str, config: Option<HashMap<String, Value>>) -> A2AResult<<Self as ?>::Transport>Create a transport instance for the specified agent
Arguments
Section titled “Arguments”agent_id: Target agent identifierendpoint: Agent endpoint URL or connection stringconfig: Optional transport-specific configuration
Returns
Section titled “Returns”Ok(Transport): Successfully created transportErr(A2AError): Failed to create transport
async fn get_transport(&self, agent_id: &str, endpoint: &str) -> A2AResult<<Self as ?>::Transport>Get or create cached transport for agent
This method may reuse existing connections for better performance.
Arguments
Section titled “Arguments”agent_id: Target agent identifierendpoint: Agent endpoint URL or connection string
Returns
Section titled “Returns”Ok(Transport): Transport ready for useErr(A2AError): Failed to get/create transport
async fn remove_transport(&self, agent_id: &str) -> A2AResult<()>Remove cached transport for agent
Forces creation of a new transport on next request. Useful for handling connection failures or configuration changes.
fn get_config(&self) -> HashMap<String, Value>Get factory configuration
AgentDiscovery
Section titled “AgentDiscovery”Trait for agent discovery.
Required / Provided Methods
fn agent_authenticated_extended_card(&self, params: AuthenticatedExtendedCardParams) -> A2AResult<AuthenticatedExtendedCardResult>TaskStorage
Section titled “TaskStorage”Enhanced Task Storage Service Interface
Defines the contract for task storage operations with proper A2A protocol support for context-based operations (1 context : N tasks relationship).
Required / Provided Methods
fn store_task(&self, task: Task) -> A2AResult<()>Store a new or updated task
fn get_task(&self, task_id: &str) -> A2AResult<Option<Task>>Retrieve a task by ID
fn update_task(&self, task: Task) -> A2AResult<()>Update an existing task
fn list_tasks(&self) -> A2AResult<Vec<Task>>List all tasks (for tasks/list method)
fn remove_task(&self, task_id: &str) -> A2AResult<bool>Remove a task (if needed for cleanup)
fn task_exists(&self, task_id: &str) -> A2AResult<bool>Check if a task exists
fn get_tasks_by_context(&self, context_id: &str) -> A2AResult<Vec<Task>>Get all tasks within a specific context (conversation)
This is the key method for A2A protocol compliance - allows retrieving all tasks that belong to the same conversation context.
fn get_latest_task_in_context(&self, context_id: &str) -> A2AResult<Option<Task>>Get the latest (most recently created) task in a context
Useful for conversation continuity and determining the most recent task state within a conversation.
fn get_context_history(&self, context_id: &str) -> A2AResult<Vec<Message>>Get conversation history from all tasks in a context
Aggregates message history from all tasks in a conversation context for LLM context management as specified in A2A protocol.
fn get_or_create_context(&self, context_id: &str) -> A2AResult<ConversationContext>Get or create conversation context
Manages conversation context lifecycle - creates new context if it doesn’t exist, returns existing context otherwise.
fn update_context_activity(&self, context_id: &str) -> A2AResult<()>Update context activity (called when new task is added)
Updates the conversation context metadata when tasks are added to track conversation lifecycle.
fn list_contexts(&self) -> A2AResult<Vec<ConversationContext>>List all conversation contexts
Returns all active conversation contexts for management/debugging.
Structs
Section titled “Structs”AgentCapabilities
Section titled “AgentCapabilities”Agent Capabilities (v1.0)
Fields
| Field | Type | Description |
|---|---|---|
streaming | bool | |
push_notifications | bool | |
extensions | Option<Vec<AgentExtension>> | |
extended_agent_card | bool |
AgentCard
Section titled “AgentCard”Agent Card — v1.0 top-level metadata object.
Fields
| Field | Type | Description |
|---|---|---|
name | String | |
description | Option<String> | |
version | Option<String> | |
supported_interfaces | Option<Vec<AgentInterface>> | |
capabilities | Option<AgentCapabilities> | |
skills | Vec<AgentSkill> | |
default_input_modes | Option<Vec<String>> | |
default_output_modes | Option<Vec<String>> | |
security_schemes | Option<HashMap<String, SecurityScheme>> | |
security_requirements | Option<Vec<SecurityRequirement>> | |
signatures | Option<Vec<AgentCardSignature>> | |
icon_url | Option<String> | |
provider | Option<AgentProvider> | |
documentation_url | Option<String> | |
metadata | Option<HashMap<String, serde_json::Value>> |
Methods
fn new<impl Into<String>>(name: impl Into) -> SelfMinimal card with just a name.
with_capability
Section titled “with_capability”fn with_capability<impl Into<String>, impl Into<String>>(self, method: impl Into, description: impl Into) -> SelfRegister a method capability on this agent card.
Stores the method name and description in the card’s pf:methods
metadata map. Used by A2AProtocol::register_method to keep the
agent card in sync with the method registry.
supports_method
Section titled “supports_method”fn supports_method(&self, method: &str) -> boolget_method_description
Section titled “get_method_description”fn get_method_description(&self, method: &str) -> Option<String>add_skill
Section titled “add_skill”fn add_skill(self, skill: AgentSkill) -> Selfget_skill
Section titled “get_skill”fn get_skill(&self, skill_id: &str) -> Option<&AgentSkill>get_skills_by_input_mode
Section titled “get_skills_by_input_mode”fn get_skills_by_input_mode(&self, input_mode: &str) -> Vec<&AgentSkill>supports_structured_skills
Section titled “supports_structured_skills”fn supports_structured_skills(&self) -> boolAgentCardSignature
Section titled “AgentCardSignature”JWS signature for agent card integrity.
Fields
| Field | Type | Description |
|---|---|---|
protected | String | |
signature | String | |
header | Option<serde_json::Value> |
AgentExtension
Section titled “AgentExtension”Agent Extension (v1.0)
Fields
| Field | Type | Description |
|---|---|---|
uri | String | |
description | Option<String> | |
required | bool | |
params | Option<serde_json::Value> |
AgentInterface
Section titled “AgentInterface”Agent Interface (v1.0) — how to reach this agent.
Fields
| Field | Type | Description |
|---|---|---|
url | String | |
protocol_binding | String | |
tenant | Option<String> | |
protocol_version | Option<String> |
AgentProvider
Section titled “AgentProvider”Agent Provider (v1.0)
Fields
| Field | Type | Description |
|---|---|---|
url | Option<String> | |
organization | String |
AgentSkill
Section titled “AgentSkill”Agent Skill (v1.0)
Fields
| Field | Type | Description |
|---|---|---|
id | String | |
name | String | |
description | String | |
tags | Option<Vec<String>> | |
examples | Option<Vec<String>> | |
input_modes | Option<Vec<String>> | |
output_modes | Option<Vec<String>> | |
security_requirements | Option<Vec<SecurityRequirement>> |
Methods
with_examples
Section titled “with_examples”fn with_examples(self, examples: Vec<String>) -> Selfwith_example
Section titled “with_example”fn with_example<impl Into<String>>(self, example: impl Into) -> Selfwith_tags
Section titled “with_tags”fn with_tags(self, tags: Vec<String>) -> Selfsupports_json_input
Section titled “supports_json_input”fn supports_json_input(&self) -> boolA2AProtocol
Section titled “A2AProtocol”Methods
fn new(agent_card: AgentCard) -> Selfwith_registry
Section titled “with_registry”fn with_registry(agent_card: AgentCard, registry: A2AMethodRegistry) -> Selfagent_card
Section titled “agent_card”fn agent_card(&self) -> &AgentCardupdate_agent_card
Section titled “update_agent_card”fn update_agent_card(&mut self, agent_card: AgentCard)registry
Section titled “registry”fn registry(&self) -> &A2AMethodRegistryregistry_mut
Section titled “registry_mut”fn registry_mut(&mut self) -> &mut A2AMethodRegistryregister_method
Section titled “register_method”fn register_method<F>(&mut self, method: &str, description: &str, handler: F)where F: Fn + Send + Sync + ?register_notification
Section titled “register_notification”fn register_notification<F>(&mut self, method: &str, description: &str, handler: F)where F: Fn + Send + Sync + ?handle_request
Section titled “handle_request”fn handle_request(&self, request: JsonRpcRequest) -> A2AResult<JsonRpcResponse>handle_notification
Section titled “handle_notification”fn handle_notification(&self, notification: JsonRpcNotification) -> A2AResult<()>handle_incoming
Section titled “handle_incoming”fn handle_incoming(&self, incoming: JsonRpcIncoming) -> A2AResult<Option<JsonRpcResponse>>get_capabilities
Section titled “get_capabilities”fn get_capabilities(&self) -> Valueget_method_metadata
Section titled “get_method_metadata”fn get_method_metadata(&self) -> HashMap<String, &MethodMetadata>validate_request_params
Section titled “validate_request_params”fn validate_request_params(&self, method: &str, params: &Value) -> A2AResult<()>register_a2a_methods
Section titled “register_a2a_methods”fn register_a2a_methods(&mut self, storage: Option<Arc<dyn TaskStorage>>)Register all A2A v1.0 protocol methods.
send_request
Section titled “send_request”async fn send_request<T>(&self, transport: &T, request: JsonRpcRequest) -> A2AResult<JsonRpcResponse>send_notification
Section titled “send_notification”async fn send_notification<T>(&self, transport: &T, notification: JsonRpcNotification) -> A2AResult<()>A2AMethodRegistry
Section titled “A2AMethodRegistry”A2A Method Registry
Central registry for A2A protocol methods and their handlers. Provides method registration, lookup, and validation functionality without any transport dependencies.
Design Principles
Section titled “Design Principles”- Pure Domain Logic: No transport or infrastructure concerns
- JSON-RPC Foundation: All methods use JSON-RPC 2.0 message types
- Thread Safe: Can be safely shared across multiple threads
- Method Metadata: Rich metadata for discovery and documentation
Examples
Section titled “Examples”use a2a_protocol_core::{A2AMethodRegistry, JsonRpcRequest, JsonRpcResponse, A2AError};use serde_json::json;use std::sync::Arc;
fn example() -> Result<(), A2AError> { let mut registry = A2AMethodRegistry::new();
// Register a method handler registry.register_method( "ping", "Simple ping method", Arc::new(|request| { Ok(JsonRpcResponse::success(request.id, json!({"pong": true}))) }) );
// Handle requests let request = JsonRpcRequest::new(json!("req-123"), "ping".to_string(), json!({})); let response = registry.handle_request(request)?; Ok(())}Methods
fn new() -> SelfCreate a new empty registry
with_agent_card
Section titled “with_agent_card”fn with_agent_card(agent_card: AgentCard) -> SelfCreate a registry with agent card
set_agent_card
Section titled “set_agent_card”fn set_agent_card(&mut self, agent_card: AgentCard)Set the agent card for this registry
agent_card
Section titled “agent_card”fn agent_card(&self) -> Option<&AgentCard>Get the agent card
register_method
Section titled “register_method”fn register_method<impl Into<String>, impl Into<String>>(&mut self, method: impl Into, description: impl Into, handler: A2AMethodHandler)Register a method handler
Registers a handler function for JSON-RPC requests to the specified method.
Arguments
Section titled “Arguments”method: Method name (e.g., “ping”, “process_data”)description: Human-readable description of the methodhandler: Function that handles requests for this method
register_method_with_metadata
Section titled “register_method_with_metadata”fn register_method_with_metadata<impl Into<String>, impl Into<String>>(&mut self, method: impl Into, description: impl Into, parameters: Option<Value>, returns: Option<Value>, handler: A2AMethodHandler)Register a method handler with metadata
Registers a method handler with detailed parameter and return type information.
register_notification
Section titled “register_notification”fn register_notification<impl Into<String>, impl Into<String>>(&mut self, method: impl Into, description: impl Into, handler: A2ANotificationHandler)Register a notification handler
Registers a handler function for JSON-RPC notifications (fire-and-forget).
Arguments
Section titled “Arguments”method: Method name (e.g., “log.info”, “metric.counter”)description: Human-readable description of the notificationhandler: Function that handles notifications for this method
handle_request
Section titled “handle_request”fn handle_request(&self, request: JsonRpcRequest) -> A2AResult<JsonRpcResponse>Handle a JSON-RPC request
Looks up the method handler and executes it with the request.
Arguments
Section titled “Arguments”request: The JSON-RPC 2.0 request to handle
Returns
Section titled “Returns”Ok(JsonRpcResponse): Success response from method handlerErr(A2AError): Method not found or handler error
handle_notification
Section titled “handle_notification”fn handle_notification(&self, notification: JsonRpcNotification) -> A2AResult<()>Handle a JSON-RPC notification
Looks up the notification handler and executes it.
Arguments
Section titled “Arguments”notification: The JSON-RPC 2.0 notification to handle
Returns
Section titled “Returns”Ok(()): Notification handled successfullyErr(A2AError): Method not found or handler error
has_method
Section titled “has_method”fn has_method(&self, method: &str) -> boolCheck if method is registered
has_notification
Section titled “has_notification”fn has_notification(&self, method: &str) -> boolCheck if notification is registered
get_method_metadata
Section titled “get_method_metadata”fn get_method_metadata(&self, method: &str) -> Option<&MethodMetadata>Get method metadata
list_methods
Section titled “list_methods”fn list_methods(&self) -> Vec<String>List all registered methods
list_notifications
Section titled “list_notifications”fn list_notifications(&self) -> Vec<String>List all registered notifications
get_all_metadata
Section titled “get_all_metadata”fn get_all_metadata(&self) -> &HashMap<String, MethodMetadata>Get all method metadata
unregister_method
Section titled “unregister_method”fn unregister_method(&mut self, method: &str) -> boolUnregister a method
unregister_notification
Section titled “unregister_notification”fn unregister_notification(&mut self, method: &str) -> boolUnregister a notification
fn clear(&mut self)Clear all registrations
fn stats(&self) -> RegistryStatsGet registry statistics
MethodMetadata
Section titled “MethodMetadata”Method metadata
Contains information about a registered method including its description, parameters, and capabilities.
Fields
| Field | Type | Description |
|---|---|---|
name | String | |
description | String | |
parameters | Option<serde_json::Value> | |
returns | Option<serde_json::Value> | |
is_notification | bool |
RegistryStats
Section titled “RegistryStats”Registry statistics
Fields
| Field | Type | Description |
|---|---|---|
method_count | usize | |
notification_count | usize | |
total_registrations | usize |
ApiKeySecurityScheme
Section titled “ApiKeySecurityScheme”Fields
| Field | Type | Description |
|---|---|---|
description | Option<String> | |
location | String | |
name | String |
AuthorizationCodeOAuthFlow
Section titled “AuthorizationCodeOAuthFlow”Fields
| Field | Type | Description |
|---|---|---|
authorization_url | String | |
token_url | String | |
refresh_url | Option<String> | |
scopes | Option<HashMap<String, String>> | |
pkce_required | Option<bool> |
ClientCredentialsOAuthFlow
Section titled “ClientCredentialsOAuthFlow”Fields
| Field | Type | Description |
|---|---|---|
token_url | String | |
refresh_url | Option<String> | |
scopes | Option<HashMap<String, String>> |
DeviceCodeOAuthFlow
Section titled “DeviceCodeOAuthFlow”Fields
| Field | Type | Description |
|---|---|---|
device_authorization_url | String | |
token_url | String | |
scopes | Option<HashMap<String, String>> |
HttpAuthSecurityScheme
Section titled “HttpAuthSecurityScheme”Fields
| Field | Type | Description |
|---|---|---|
description | Option<String> | |
scheme | String | |
bearer_format | Option<String> |
MutualTlsSecurityScheme
Section titled “MutualTlsSecurityScheme”Fields
| Field | Type | Description |
|---|---|---|
description | Option<String> |
OAuthFlows
Section titled “OAuthFlows”Fields
| Field | Type | Description |
|---|---|---|
authorization_code | Option<AuthorizationCodeOAuthFlow> | |
client_credentials | Option<ClientCredentialsOAuthFlow> | |
device_code | Option<DeviceCodeOAuthFlow> |
OAuth2SecurityScheme
Section titled “OAuth2SecurityScheme”Fields
| Field | Type | Description |
|---|---|---|
description | Option<String> | |
flows | OAuthFlows | |
oauth2_metadata_url | Option<String> |
OpenIdConnectSecurityScheme
Section titled “OpenIdConnectSecurityScheme”Fields
| Field | Type | Description |
|---|---|---|
description | Option<String> | |
open_id_connect_url | String |
SecurityRequirement
Section titled “SecurityRequirement”Security requirement: map of scheme name -> required scopes.
Fields
| Field | Type | Description |
|---|---|---|
schemes | HashMap<String, Vec<String>> |
Artifact
Section titled “Artifact”Artifact: Agent output (v1.0 shape)
Fields
| Field | Type | Description |
|---|---|---|
artifact_id | String | |
name | Option<String> | |
description | Option<String> | |
parts | Vec<Part> | |
metadata | Option<HashMap<String, serde_json::Value>> | |
extensions | Option<Vec<String>> |
Methods
fn new(parts: Vec<Part>) -> SelfCreate an artifact with a generated ID.
fn text<impl Into<String>>(text: impl Into) -> SelfCreate a simple text artifact.
fn data(value: Value) -> SelfCreate a data artifact.
with_name
Section titled “with_name”fn with_name<impl Into<String>>(self, name: impl Into) -> SelfBuilder: set name.
with_description
Section titled “with_description”fn with_description<impl Into<String>>(self, description: impl Into) -> SelfBuilder: set description.
with_id
Section titled “with_id”fn with_id<impl Into<String>>(self, id: impl Into) -> SelfBuilder: set artifact_id explicitly.
set_metadata
Section titled “set_metadata”fn set_metadata(&mut self, key: String, value: Value)get_text_content
Section titled “get_text_content”fn get_text_content(&self) -> Option<&str>Extract text from the first text part (convenience).
get_data_content
Section titled “get_data_content”fn get_data_content(&self) -> Option<&Value>Extract data from the first data part (convenience).
AuthenticationInfo
Section titled “AuthenticationInfo”Authentication information for push notification delivery.
Fields
| Field | Type | Description |
|---|---|---|
scheme | String | |
credentials | String |
Message
Section titled “Message”Message: Core A2A communication object (v1.0)
Fields
| Field | Type | Description |
|---|---|---|
role | MessageRole | |
parts | Vec<Part> | |
message_id | String | |
task_id | Option<String> | |
context_id | Option<String> | |
metadata | Option<HashMap<String, serde_json::Value>> | |
extensions | Option<Vec<String>> | |
reference_task_ids | Option<Vec<String>> |
Methods
fn new(role: MessageRole, parts: Vec<Part>, task_id: String) -> Selfwith_id
Section titled “with_id”fn with_id(message_id: String, role: MessageRole, parts: Vec<Part>) -> Selffn text<impl Into<String>>(role: MessageRole, text: impl Into, task_id: String) -> Selfstatus
Section titled “status”fn status<impl Into<String>>(text: impl Into, task_id: String) -> Selffn error<impl Into<String>>(text: impl Into, task_id: String) -> Selfadd_part
Section titled “add_part”fn add_part(&mut self, part: Part)set_metadata
Section titled “set_metadata”fn set_metadata(&mut self, key: String, value: Value)with_context
Section titled “with_context”fn with_context(self, context_id: String) -> Selfadd_extension
Section titled “add_extension”fn add_extension(&mut self, extension: String)get_text_content
Section titled “get_text_content”fn get_text_content(&self) -> Stringis_text_only
Section titled “is_text_only”fn is_text_only(&self) -> boolget_data_parts
Section titled “get_data_parts”fn get_data_parts(&self) -> Vec<&Part>Part: Flat multi-modal content container (v1.0)
A Part carries exactly one of: text, raw (base64), url, or structured data. Additional fields (filename, media_type, metadata) annotate the content.
Fields
| Field | Type | Description |
|---|---|---|
text | Option<String> | |
raw | Option<String> | |
url | Option<String> | |
data | Option<serde_json::Value> | |
metadata | Option<HashMap<String, serde_json::Value>> | |
filename | Option<String> | |
media_type | Option<String> |
Methods
fn text<impl Into<String>>(text: impl Into) -> SelfText-only part.
fn data(value: Value) -> SelfStructured data part.
fn url<impl Into<String>>(uri: impl Into) -> SelfURL reference part.
fn raw<impl Into<String>>(base64: impl Into) -> SelfBase64-encoded raw bytes part.
url_with_media
Section titled “url_with_media”fn url_with_media<impl Into<String>, impl Into<String>>(uri: impl Into, media_type: impl Into) -> SelfURL part with media type annotation.
is_text
Section titled “is_text”fn is_text(&self) -> boolCheck which content variant is populated.
is_data
Section titled “is_data”fn is_data(&self) -> boolis_url
Section titled “is_url”fn is_url(&self) -> boolis_raw
Section titled “is_raw”fn is_raw(&self) -> boolget_text
Section titled “get_text”fn get_text(&self) -> Option<&str>Extract text content (if present).
Task: Core A2A work unit (v1.0)
Fields
| Field | Type | Description |
|---|---|---|
id | String | |
context_id | String | |
status | TaskStatus | |
history | Option<Vec<Message>> | |
artifacts | Option<Vec<Artifact>> | |
metadata | Option<HashMap<String, serde_json::Value>> |
Methods
fn new(context_id: String) -> Selfwith_id
Section titled “with_id”fn with_id(id: String, context_id: String) -> Selfupdate_status
Section titled “update_status”fn update_status(&mut self, state: TaskState)update_status_with_message
Section titled “update_status_with_message”fn update_status_with_message(&mut self, state: TaskState, message: Message)add_artifact
Section titled “add_artifact”fn add_artifact(&mut self, artifact: Artifact)add_to_history
Section titled “add_to_history”fn add_to_history(&mut self, message: Message)set_metadata
Section titled “set_metadata”fn set_metadata(&mut self, key: String, value: Value)is_terminal
Section titled “is_terminal”fn is_terminal(&self) -> boolis_active
Section titled “is_active”fn is_active(&self) -> boolTaskPushNotificationConfig
Section titled “TaskPushNotificationConfig”Per-task push notification configuration (v1.0).
Fields
| Field | Type | Description |
|---|---|---|
tenant | Option<String> | |
id | String | |
task_id | String | |
url | String | |
token | Option<String> | |
authentication | Option<AuthenticationInfo> |
Methods
fn new<impl Into<String>, impl Into<String>, impl Into<String>>(id: impl Into, task_id: impl Into, url: impl Into) -> Selfwith_tenant
Section titled “with_tenant”fn with_tenant<impl Into<String>>(self, tenant: impl Into) -> Selfwith_token
Section titled “with_token”fn with_token<impl Into<String>>(self, token: impl Into) -> Selfwith_authentication
Section titled “with_authentication”fn with_authentication(self, auth: AuthenticationInfo) -> SelfTaskStatus
Section titled “TaskStatus”Task Status: Current state with optional message.
Fields
| Field | Type | Description |
|---|---|---|
state | TaskState | |
message | Option<Message> | |
timestamp | Option<String> |
Methods
fn new(state: TaskState) -> Selfupdate_timestamp
Section titled “update_timestamp”fn update_timestamp(&mut self)AuthenticatedExtendedCardParams
Section titled “AuthenticatedExtendedCardParams”Params for GetExtendedAgentCard (was agent/card/getAuthenticatedExtended).
Fields
| Field | Type | Description |
|---|---|---|
auth_token | Option<String> | |
scope | Option<Vec<String>> | |
metadata | Option<HashMap<String, serde_json::Value>> |
AuthenticatedExtendedCardResult
Section titled “AuthenticatedExtendedCardResult”Result for GetExtendedAgentCard.
Fields
| Field | Type | Description |
|---|---|---|
agent_card | crate::AgentCard | |
discovery_metadata | Option<HashMap<String, serde_json::Value>> | |
timestamp | Option<String> |
DefaultAgentDiscovery
Section titled “DefaultAgentDiscovery”Default discovery implementation.
Methods
fn new(agent_card: AgentCard) -> Selfwith_authentication_required
Section titled “with_authentication_required”fn with_authentication_required(self, required: bool) -> SelfCancelTaskRequest
Section titled “CancelTaskRequest”Request params for CancelTask (was tasks/cancel).
Fields
| Field | Type | Description |
|---|---|---|
id | String | |
tenant | Option<String> | |
metadata | Option<HashMap<String, serde_json::Value>> |
Methods
from_json
Section titled “from_json”fn from_json(params: Value) -> A2AResult<Self>validate
Section titled “validate”fn validate(&self) -> A2AResult<()>CreateTaskPushNotificationConfigRequest
Section titled “CreateTaskPushNotificationConfigRequest”Fields
| Field | Type | Description |
|---|---|---|
config | TaskPushNotificationConfig |
DeleteTaskPushNotificationConfigRequest
Section titled “DeleteTaskPushNotificationConfigRequest”Fields
| Field | Type | Description |
|---|---|---|
id | String | |
task_id | String |
GetTaskPushNotificationConfigRequest
Section titled “GetTaskPushNotificationConfigRequest”Fields
| Field | Type | Description |
|---|---|---|
id | String | |
task_id | String |
GetTaskRequest
Section titled “GetTaskRequest”Request params for GetTask (was tasks/get).
Fields
| Field | Type | Description |
|---|---|---|
id | String | |
tenant | Option<String> | |
history_length | Option<u32> |
Methods
from_json
Section titled “from_json”fn from_json(params: Value) -> A2AResult<Self>validate
Section titled “validate”fn validate(&self) -> A2AResult<()>ListTaskPushNotificationConfigsRequest
Section titled “ListTaskPushNotificationConfigsRequest”Fields
| Field | Type | Description |
|---|---|---|
task_id | String |
ListTasksRequest
Section titled “ListTasksRequest”Request params for ListTasks (was tasks/list).
Fields
| Field | Type | Description |
|---|---|---|
tenant | Option<String> | |
context_id | Option<String> | |
status | Option<String> | |
page_size | Option<u32> | |
page_token | Option<String> | |
history_length | Option<u32> | |
status_timestamp_after | Option<String> | |
include_artifacts | bool |
Methods
from_json
Section titled “from_json”fn from_json(params: Value) -> A2AResult<Self>validate
Section titled “validate”fn validate(&self) -> A2AResult<()>ListTasksResponse
Section titled “ListTasksResponse”Response for ListTasks.
Fields
| Field | Type | Description |
|---|---|---|
tasks | Vec<Task> | |
next_page_token | Option<String> | |
page_size | Option<u32> | |
total_size | Option<u32> |
SendMessageConfiguration
Section titled “SendMessageConfiguration”Optional configuration for SendMessage.
Fields
| Field | Type | Description |
|---|---|---|
accepted_output_modes | Option<Vec<String>> | |
task_push_notification_config | Option<TaskPushNotificationConfig> | |
history_length | Option<u32> | |
return_immediately | bool |
SendMessageRequest
Section titled “SendMessageRequest”Request params for SendMessage (was message/send).
Fields
| Field | Type | Description |
|---|---|---|
message | Message | |
tenant | Option<String> | |
configuration | Option<SendMessageConfiguration> | |
metadata | Option<HashMap<String, serde_json::Value>> |
Methods
from_json
Section titled “from_json”fn from_json(params: Value) -> A2AResult<Self>validate
Section titled “validate”fn validate(&self) -> A2AResult<()>SubscribeToTaskRequest
Section titled “SubscribeToTaskRequest”Request params for SubscribeToTask (reconnect to existing task SSE).
Fields
| Field | Type | Description |
|---|---|---|
id | String | |
tenant | Option<String> |
ConversationContext
Section titled “ConversationContext”Context Information for Conversation Management
Represents a conversation context that contains multiple tasks following the A2A protocol specification.
Fields
| Field | Type | Description |
|---|---|---|
context_id | String | Unique context identifier (persistent across tasks) |
created_at | String | When the conversation started |
last_active | String | Last interaction time |
task_count | u32 | Number of tasks in this context |
Methods
fn new(context_id: String) -> SelfCreate a new conversation context
update_activity
Section titled “update_activity”fn update_activity(&mut self)Update last active timestamp and increment task count
InMemoryTaskStorage
Section titled “InMemoryTaskStorage”In-Memory Task Storage Implementation
Provides a simple in-memory task storage for development and testing. In production, this would be replaced with persistent storage.
Enhanced A2A Protocol Support: Now includes separate context tracking for proper conversation management with 1:N context:task relationship.
Methods
fn new() -> SelfCreate a new in-memory task storage
task_count
Section titled “task_count”fn task_count(&self) -> usizeGet the number of stored tasks (for testing)
context_count
Section titled “context_count”fn context_count(&self) -> usizeGet the number of stored contexts (for testing)
fn clear(&self)Clear all tasks and contexts (for testing)
A2AError
Section titled “A2AError”A2A Protocol Error
Variants
| Variant | Description |
|---|---|
MethodNotFound { ... } | |
InvalidParams { ... } | |
AgentUnavailable { ... } | |
CapabilityValidationFailed { ... } | |
MethodExecutionFailed { ... } | |
RegistryError { ... } | |
ProtocolValidationError { ... } | |
JsonRpcError(anyhow::Error) | |
SerializationError(serde_json::Error) | |
Internal { ... } | |
TaskNotFound { ... } | |
TaskNotCancelable { ... } | |
PushNotificationNotSupported | |
UnsupportedOperation { ... } | |
ContentTypeNotSupported { ... } | |
InvalidAgentResponse { ... } | |
VersionNotSupported { ... } |
Methods
to_jsonrpc_error
Section titled “to_jsonrpc_error”fn to_jsonrpc_error(&self) -> JsonRpcErrormethod_not_found
Section titled “method_not_found”fn method_not_found<impl Into<String>>(method: impl Into) -> Selfinvalid_params
Section titled “invalid_params”fn invalid_params<impl Into<String>, impl Into<String>>(method: impl Into, details: impl Into) -> Selfagent_unavailable
Section titled “agent_unavailable”fn agent_unavailable<impl Into<String>, impl Into<String>>(agent_id: impl Into, reason: impl Into) -> Selfcapability_validation_failed
Section titled “capability_validation_failed”fn capability_validation_failed<impl Into<String>>(details: impl Into) -> Selfmethod_execution_failed
Section titled “method_execution_failed”fn method_execution_failed<impl Into<String>, impl Into<String>>(method: impl Into, details: impl Into) -> Selfregistry_error
Section titled “registry_error”fn registry_error<impl Into<String>>(details: impl Into) -> Selfprotocol_validation_error
Section titled “protocol_validation_error”fn protocol_validation_error<impl Into<String>>(details: impl Into) -> Selfinternal
Section titled “internal”fn internal<impl Into<String>>(details: impl Into) -> Selftask_not_found
Section titled “task_not_found”fn task_not_found<impl Into<String>>(task_id: impl Into) -> Selftask_not_cancelable
Section titled “task_not_cancelable”fn task_not_cancelable<impl Into<String>>(task_id: impl Into) -> Selfunsupported_operation
Section titled “unsupported_operation”fn unsupported_operation<impl Into<String>>(details: impl Into) -> Selfversion_not_supported
Section titled “version_not_supported”fn version_not_supported<impl Into<String>>(version: impl Into) -> SelfSecurityScheme
Section titled “SecurityScheme”Security scheme union (v1.0).
Variants
| Variant | Description |
|---|---|
ApiKey(ApiKeySecurityScheme) | |
Http(HttpAuthSecurityScheme) | |
OAuth2(OAuth2SecurityScheme) | |
OpenIdConnect(OpenIdConnectSecurityScheme) | |
MutualTls(MutualTlsSecurityScheme) |
MessageRole
Section titled “MessageRole”Message Role (v1.0 — SCREAMING_SNAKE serialization)
Variants
| Variant | Description |
|---|---|
Unspecified | |
User | |
Agent |
TaskState
Section titled “TaskState”Task State: A2A v1.0 SCREAMING_SNAKE enum.
Variants
| Variant | Description |
|---|---|
Unspecified | |
Submitted | |
Working | |
InputRequired | |
Completed | |
Failed | |
Canceled | |
Rejected | |
AuthRequired |
Methods
is_terminal
Section titled “is_terminal”fn is_terminal(&self) -> boolReturns true for terminal states: Completed, Failed, Canceled, Rejected.
is_active
Section titled “is_active”fn is_active(&self) -> boolReturns true for active states: Submitted, Working, InputRequired.
as_str
Section titled “as_str”fn as_str(&self) -> &''static strLowercase string for logging/display (not wire format).
SendMessageResponse
Section titled “SendMessageResponse”Response for SendMessage — either a Task or a direct Message.
Serialized as externally-tagged {"task": {...}} or {"message": {...}}
matching the protobuf oneof JSON mapping required by A2A v1.0.
Variants
| Variant | Description |
|---|---|
Task(Task) | |
Message(Message) |