Skip to main content

A2AHandler

Trait A2AHandler 

Source
pub trait A2AHandler:
    Send
    + Sync
    + 'static {
Show 18 methods // Required methods fn get_agent_card<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<AgentCard, A2AError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn send_message<'life0, 'async_trait>( &'life0 self, request: SendMessageRequest, ) -> Pin<Box<dyn Future<Output = Result<SendMessageResponse, A2AError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; // Provided methods fn send_streaming_message<'life0, 'async_trait>( &'life0 self, _request: SendMessageRequest, ) -> Pin<Box<dyn Future<Output = Result<A2AStream, A2AError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn get_task<'life0, 'async_trait>( &'life0 self, _request: GetTaskRequest, ) -> Pin<Box<dyn Future<Output = Result<Task, A2AError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn list_tasks<'life0, 'async_trait>( &'life0 self, _request: ListTasksRequest, ) -> Pin<Box<dyn Future<Output = Result<ListTasksResponse, A2AError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn cancel_task<'life0, 'async_trait>( &'life0 self, _request: CancelTaskRequest, ) -> Pin<Box<dyn Future<Output = Result<Task, A2AError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn subscribe_to_task<'life0, 'async_trait>( &'life0 self, _request: SubscribeToTaskRequest, ) -> Pin<Box<dyn Future<Output = Result<A2AStream, A2AError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn create_task_push_notification_config<'life0, 'async_trait>( &'life0 self, _request: TaskPushNotificationConfig, ) -> Pin<Box<dyn Future<Output = Result<TaskPushNotificationConfig, A2AError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn get_task_push_notification_config<'life0, 'async_trait>( &'life0 self, _request: GetTaskPushNotificationConfigRequest, ) -> Pin<Box<dyn Future<Output = Result<TaskPushNotificationConfig, A2AError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn list_task_push_notification_configs<'life0, 'async_trait>( &'life0 self, _request: ListTaskPushNotificationConfigsRequest, ) -> Pin<Box<dyn Future<Output = Result<ListTaskPushNotificationConfigsResponse, A2AError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn delete_task_push_notification_config<'life0, 'async_trait>( &'life0 self, _request: DeleteTaskPushNotificationConfigRequest, ) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn get_extended_agent_card<'life0, 'async_trait>( &'life0 self, _request: GetExtendedAgentCardRequest, ) -> Pin<Box<dyn Future<Output = Result<AgentCard, A2AError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn require_streaming_capability<'life0, 'life1, 'async_trait>( &'life0 self, operation: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn require_push_notifications_capability<'life0, 'life1, 'async_trait>( &'life0 self, operation: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn require_extended_agent_card_capability<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn validate_protocol_headers<'life0, 'life1, 'async_trait>( &'life0 self, headers: &'life1 HeaderMap, ) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn require_supported_version<'life0, 'life1, 'async_trait>( &'life0 self, headers: &'life1 HeaderMap, ) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn require_required_extensions<'life0, 'life1, 'async_trait>( &'life0 self, headers: &'life1 HeaderMap, ) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... }
}
Expand description

Core server trait for implementing an A2A agent.

The default capability helpers call get_agent_card() on each gated request. Implementations that fetch the card from storage should cache it or override the relevant operation methods.

Required Methods§

Source

fn get_agent_card<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<AgentCard, A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Return the agent card served from discovery and capability endpoints.

Source

fn send_message<'life0, 'async_trait>( &'life0 self, request: SendMessageRequest, ) -> Pin<Box<dyn Future<Output = Result<SendMessageResponse, A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Process a unary SendMessage request.

Provided Methods§

Source

fn send_streaming_message<'life0, 'async_trait>( &'life0 self, _request: SendMessageRequest, ) -> Pin<Box<dyn Future<Output = Result<A2AStream, A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Stream responses for a submitted message.

Message-only flows should emit exactly one StreamResponse::Message. Task-based flows should emit the initial task first, followed by status and artifact updates until the stream closes.

Source

fn get_task<'life0, 'async_trait>( &'life0 self, _request: GetTaskRequest, ) -> Pin<Box<dyn Future<Output = Result<Task, A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Fetch a task by identifier.

Source

fn list_tasks<'life0, 'async_trait>( &'life0 self, _request: ListTasksRequest, ) -> Pin<Box<dyn Future<Output = Result<ListTasksResponse, A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

List tasks visible to the caller.

Source

fn cancel_task<'life0, 'async_trait>( &'life0 self, _request: CancelTaskRequest, ) -> Pin<Box<dyn Future<Output = Result<Task, A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Attempt to cancel a task.

Source

fn subscribe_to_task<'life0, 'async_trait>( &'life0 self, _request: SubscribeToTaskRequest, ) -> Pin<Box<dyn Future<Output = Result<A2AStream, A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Subscribe to updates for an existing task.

Implementations must emit the current StreamResponse::Task first before any subsequent status or artifact updates.

Source

fn create_task_push_notification_config<'life0, 'async_trait>( &'life0 self, _request: TaskPushNotificationConfig, ) -> Pin<Box<dyn Future<Output = Result<TaskPushNotificationConfig, A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Create or replace a push-notification configuration.

Source

fn get_task_push_notification_config<'life0, 'async_trait>( &'life0 self, _request: GetTaskPushNotificationConfigRequest, ) -> Pin<Box<dyn Future<Output = Result<TaskPushNotificationConfig, A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Fetch a stored push-notification configuration.

Source

fn list_task_push_notification_configs<'life0, 'async_trait>( &'life0 self, _request: ListTaskPushNotificationConfigsRequest, ) -> Pin<Box<dyn Future<Output = Result<ListTaskPushNotificationConfigsResponse, A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

List stored push-notification configurations.

Source

fn delete_task_push_notification_config<'life0, 'async_trait>( &'life0 self, _request: DeleteTaskPushNotificationConfigRequest, ) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Delete a stored push-notification configuration.

Source

fn get_extended_agent_card<'life0, 'async_trait>( &'life0 self, _request: GetExtendedAgentCardRequest, ) -> Pin<Box<dyn Future<Output = Result<AgentCard, A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Fetch the extended agent card.

Source

fn require_streaming_capability<'life0, 'life1, 'async_trait>( &'life0 self, operation: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Enforce the A2A streaming capability gate.

Do not override unless you preserve the same protocol behavior.

Source

fn require_push_notifications_capability<'life0, 'life1, 'async_trait>( &'life0 self, operation: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Enforce the A2A push-notifications capability gate.

Do not override unless you preserve the same protocol behavior.

Source

fn require_extended_agent_card_capability<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Enforce the A2A extended-agent-card capability gate.

Do not override unless you preserve the same protocol behavior.

Source

fn validate_protocol_headers<'life0, 'life1, 'async_trait>( &'life0 self, headers: &'life1 HeaderMap, ) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Validate A2A-Version and A2A-Extensions request headers.

Source

fn require_supported_version<'life0, 'life1, 'async_trait>( &'life0 self, headers: &'life1 HeaderMap, ) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Enforce that the request version is supported by the advertised interfaces.

Source

fn require_required_extensions<'life0, 'life1, 'async_trait>( &'life0 self, headers: &'life1 HeaderMap, ) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Enforce that all required agent extensions are acknowledged by the caller.

Implementors§