Skip to main content

A2aHandler

Trait A2aHandler 

Source
pub trait A2aHandler:
    Send
    + Sync
    + 'static {
    // Required methods
    fn agent_card(&self) -> &AgentCard;
    fn on_send_message<'life0, 'async_trait>(
        &'life0 self,
        req: SendMessageRequest,
    ) -> Pin<Box<dyn Future<Output = Result<SendMessageResponse, A2aError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn on_send_streaming_message<'life0, 'async_trait>(
        &'life0 self,
        req: SendMessageRequest,
    ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<StreamResponse, A2aError>> + Send>>, A2aError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn on_get_task<'life0, 'async_trait>(
        &'life0 self,
        req: GetTaskRequest,
    ) -> Pin<Box<dyn Future<Output = Result<Task, A2aError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn on_list_tasks<'life0, 'async_trait>(
        &'life0 self,
        req: ListTasksRequest,
    ) -> Pin<Box<dyn Future<Output = Result<ListTasksResponse, A2aError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn on_cancel_task<'life0, 'async_trait>(
        &'life0 self,
        req: CancelTaskRequest,
    ) -> Pin<Box<dyn Future<Output = Result<Task, A2aError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn on_subscribe_to_task<'life0, 'async_trait>(
        &'life0 self,
        req: SubscribeToTaskRequest,
    ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<StreamResponse, A2aError>> + Send>>, A2aError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn on_create_push_config<'life0, 'async_trait>(
        &'life0 self,
        _config: TaskPushNotificationConfig,
    ) -> Pin<Box<dyn Future<Output = Result<TaskPushNotificationConfig, A2aError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn on_get_push_config<'life0, 'async_trait>(
        &'life0 self,
        _req: GetTaskPushNotificationConfigRequest,
    ) -> Pin<Box<dyn Future<Output = Result<TaskPushNotificationConfig, A2aError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn on_list_push_configs<'life0, 'async_trait>(
        &'life0 self,
        _req: ListTaskPushNotificationConfigsRequest,
    ) -> Pin<Box<dyn Future<Output = Result<ListTaskPushNotificationConfigsResponse, A2aError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn on_delete_push_config<'life0, 'async_trait>(
        &'life0 self,
        _req: DeleteTaskPushNotificationConfigRequest,
    ) -> Pin<Box<dyn Future<Output = Result<(), A2aError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn on_get_extended_agent_card<'life0, 'async_trait>(
        &'life0 self,
        _req: GetExtendedAgentCardRequest,
    ) -> Pin<Box<dyn Future<Output = Result<AgentCard, A2aError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Core handler trait for A2A agents.

Implement this trait to define agent behavior. The server infrastructure will route requests from JSON-RPC, REST, and gRPC to these methods.

Required Methods§

Source

fn agent_card(&self) -> &AgentCard

Return the agent card for discovery.

Source

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

Handle a message/send request.

Source

fn on_send_streaming_message<'life0, 'async_trait>( &'life0 self, req: SendMessageRequest, ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<StreamResponse, A2aError>> + Send>>, A2aError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Handle a message/stream request (server-streaming).

Source

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

Handle a tasks/get request.

Source

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

Handle a tasks/list request.

Source

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

Handle a tasks/cancel request.

Source

fn on_subscribe_to_task<'life0, 'async_trait>( &'life0 self, req: SubscribeToTaskRequest, ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<StreamResponse, A2aError>> + Send>>, A2aError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Handle a tasks/resubscribe request (server-streaming).

Provided Methods§

Source

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

Create a push notification config. Default returns unsupported.

Source

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

Get a push notification config. Default returns unsupported.

Source

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

List push notification configs. Default returns unsupported.

Source

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

Delete a push notification config. Default returns unsupported.

Source

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

Get the authenticated extended agent card. Default returns not configured.

Implementors§