use a2a::*;
use async_trait::async_trait;
use auto_impl::auto_impl;
use futures::stream::BoxStream;
use std::collections::HashMap;
pub type ServiceParams = HashMap<String, Vec<String>>;
#[async_trait]
#[auto_impl(Box)]
pub trait Transport: Send + Sync {
async fn send_message(
&self,
params: &ServiceParams,
req: &SendMessageRequest,
) -> Result<SendMessageResponse, A2AError>;
async fn send_streaming_message(
&self,
params: &ServiceParams,
req: &SendMessageRequest,
) -> Result<BoxStream<'static, Result<StreamResponse, A2AError>>, A2AError>;
async fn get_task(
&self,
params: &ServiceParams,
req: &GetTaskRequest,
) -> Result<Task, A2AError>;
async fn list_tasks(
&self,
params: &ServiceParams,
req: &ListTasksRequest,
) -> Result<ListTasksResponse, A2AError>;
async fn cancel_task(
&self,
params: &ServiceParams,
req: &CancelTaskRequest,
) -> Result<Task, A2AError>;
async fn subscribe_to_task(
&self,
params: &ServiceParams,
req: &SubscribeToTaskRequest,
) -> Result<BoxStream<'static, Result<StreamResponse, A2AError>>, A2AError>;
async fn create_push_config(
&self,
params: &ServiceParams,
req: &TaskPushNotificationConfig,
) -> Result<TaskPushNotificationConfig, A2AError>;
async fn get_push_config(
&self,
params: &ServiceParams,
req: &GetTaskPushNotificationConfigRequest,
) -> Result<TaskPushNotificationConfig, A2AError>;
async fn list_push_configs(
&self,
params: &ServiceParams,
req: &ListTaskPushNotificationConfigsRequest,
) -> Result<ListTaskPushNotificationConfigsResponse, A2AError>;
async fn delete_push_config(
&self,
params: &ServiceParams,
req: &DeleteTaskPushNotificationConfigRequest,
) -> Result<(), A2AError>;
async fn get_extended_agent_card(
&self,
params: &ServiceParams,
req: &GetExtendedAgentCardRequest,
) -> Result<AgentCard, A2AError>;
async fn destroy(&self) -> Result<(), A2AError>;
}
#[async_trait]
pub trait TransportFactory: Send + Sync {
fn protocol(&self) -> &str;
async fn create(
&self,
card: &AgentCard,
iface: &AgentInterface,
) -> Result<Box<dyn Transport>, A2AError>;
}