pub struct A2aV1Client { /* private fields */ }a2a-v1 and server only.Expand description
A2A v1.0.0 client.
Sends A2A-Version: 1.0 on every request, supports all 11 operations
via JSON-RPC (and optionally REST), parses structured error responses,
caches agent cards with conditional headers, and retries transient
failures.
Implementations§
Source§impl A2aV1Client
impl A2aV1Client
Sourcepub fn new(agent_card: AgentCard) -> A2aV1Client
pub fn new(agent_card: AgentCard) -> A2aV1Client
Creates a new v1 client from an already-resolved agent card.
Sourcepub fn with_retry(
agent_card: AgentCard,
retry_config: RetryConfig,
) -> A2aV1Client
pub fn with_retry( agent_card: AgentCard, retry_config: RetryConfig, ) -> A2aV1Client
Creates a new v1 client with custom retry configuration.
Sourcepub fn agent_card(&self) -> &AgentCard
pub fn agent_card(&self) -> &AgentCard
Returns a reference to the agent card.
Sourcepub async fn resolve_agent_card(
base_url: &str,
) -> Result<AgentCard, V1ClientError>
pub async fn resolve_agent_card( base_url: &str, ) -> Result<AgentCard, V1ClientError>
Resolves an agent card from a base URL, fetching from
/.well-known/agent-card.json with A2A-Version: 1.0.
Caches the ETag and Last-Modified headers for subsequent conditional requests.
Sourcepub async fn resolve_agent_card_cached(
&self,
base_url: &str,
) -> Result<Option<AgentCard>, V1ClientError>
pub async fn resolve_agent_card_cached( &self, base_url: &str, ) -> Result<Option<AgentCard>, V1ClientError>
Resolves an agent card using conditional headers if a cached
version exists. Returns None if the server responds 304.
Sourcepub async fn send_message(
&self,
message: Message,
) -> Result<Task, V1ClientError>
pub async fn send_message( &self, message: Message, ) -> Result<Task, V1ClientError>
Sends a message to the remote agent (JSON-RPC SendMessage).
Sourcepub async fn send_streaming_message(
&self,
message: Message,
) -> Result<Response, V1ClientError>
pub async fn send_streaming_message( &self, message: Message, ) -> Result<Response, V1ClientError>
Sends a streaming message (JSON-RPC SendStreamingMessage).
Returns the raw response for SSE parsing by the caller.
Sourcepub async fn get_task(
&self,
task_id: &str,
history_length: Option<u32>,
) -> Result<Task, V1ClientError>
pub async fn get_task( &self, task_id: &str, history_length: Option<u32>, ) -> Result<Task, V1ClientError>
Retrieves a task by ID (JSON-RPC GetTask).
Sourcepub async fn cancel_task(&self, task_id: &str) -> Result<Task, V1ClientError>
pub async fn cancel_task(&self, task_id: &str) -> Result<Task, V1ClientError>
Cancels a task (JSON-RPC CancelTask).
Sourcepub async fn list_tasks(
&self,
context_id: Option<&str>,
status: Option<TaskState>,
page_size: Option<u32>,
page_token: Option<&str>,
) -> Result<Vec<Task>, V1ClientError>
pub async fn list_tasks( &self, context_id: Option<&str>, status: Option<TaskState>, page_size: Option<u32>, page_token: Option<&str>, ) -> Result<Vec<Task>, V1ClientError>
Lists tasks with optional filtering (JSON-RPC ListTasks).
Sourcepub async fn subscribe_to_task(
&self,
task_id: &str,
) -> Result<Response, V1ClientError>
pub async fn subscribe_to_task( &self, task_id: &str, ) -> Result<Response, V1ClientError>
Subscribes to task updates (JSON-RPC SubscribeToTask).
Returns the raw response for SSE parsing by the caller.
Sourcepub async fn create_push_notification_config(
&self,
config: TaskPushNotificationConfig,
) -> Result<TaskPushNotificationConfig, V1ClientError>
pub async fn create_push_notification_config( &self, config: TaskPushNotificationConfig, ) -> Result<TaskPushNotificationConfig, V1ClientError>
Creates a push notification config (JSON-RPC
CreateTaskPushNotificationConfig).
Sourcepub async fn get_push_notification_config(
&self,
task_id: &str,
config_id: &str,
) -> Result<TaskPushNotificationConfig, V1ClientError>
pub async fn get_push_notification_config( &self, task_id: &str, config_id: &str, ) -> Result<TaskPushNotificationConfig, V1ClientError>
Gets a push notification config (JSON-RPC
GetTaskPushNotificationConfig).
Sourcepub async fn list_push_notification_configs(
&self,
task_id: &str,
) -> Result<Vec<TaskPushNotificationConfig>, V1ClientError>
pub async fn list_push_notification_configs( &self, task_id: &str, ) -> Result<Vec<TaskPushNotificationConfig>, V1ClientError>
Lists push notification configs (JSON-RPC
ListTaskPushNotificationConfigs).
Sourcepub async fn delete_push_notification_config(
&self,
task_id: &str,
config_id: &str,
) -> Result<(), V1ClientError>
pub async fn delete_push_notification_config( &self, task_id: &str, config_id: &str, ) -> Result<(), V1ClientError>
Deletes a push notification config (JSON-RPC
DeleteTaskPushNotificationConfig).
Sourcepub async fn get_extended_agent_card(&self) -> Result<AgentCard, V1ClientError>
pub async fn get_extended_agent_card(&self) -> Result<AgentCard, V1ClientError>
Gets the extended agent card (JSON-RPC GetExtendedAgentCard).
Sourcepub async fn send_message_rest(
&self,
message: Message,
) -> Result<Task, V1ClientError>
pub async fn send_message_rest( &self, message: Message, ) -> Result<Task, V1ClientError>
Sends a message via REST (POST /message:send).
Sourcepub async fn get_task_rest(&self, task_id: &str) -> Result<Task, V1ClientError>
pub async fn get_task_rest(&self, task_id: &str) -> Result<Task, V1ClientError>
Gets a task via REST (GET /tasks/{taskId}).
Sourcepub async fn cancel_task_rest(
&self,
task_id: &str,
) -> Result<Task, V1ClientError>
pub async fn cancel_task_rest( &self, task_id: &str, ) -> Result<Task, V1ClientError>
Cancels a task via REST (POST /tasks/{taskId}:cancel).
Sourcepub async fn list_tasks_rest(&self) -> Result<Vec<Task>, V1ClientError>
pub async fn list_tasks_rest(&self) -> Result<Vec<Task>, V1ClientError>
Lists tasks via REST (GET /tasks).
Sourcepub async fn create_push_notification_config_rest(
&self,
task_id: &str,
config: TaskPushNotificationConfig,
) -> Result<TaskPushNotificationConfig, V1ClientError>
pub async fn create_push_notification_config_rest( &self, task_id: &str, config: TaskPushNotificationConfig, ) -> Result<TaskPushNotificationConfig, V1ClientError>
Creates a push notification config via REST
(POST /tasks/{taskId}/pushNotificationConfigs).
Sourcepub async fn get_push_notification_config_rest(
&self,
task_id: &str,
config_id: &str,
) -> Result<TaskPushNotificationConfig, V1ClientError>
pub async fn get_push_notification_config_rest( &self, task_id: &str, config_id: &str, ) -> Result<TaskPushNotificationConfig, V1ClientError>
Gets a push notification config via REST
(GET /tasks/{taskId}/pushNotificationConfigs/{configId}).
Sourcepub async fn list_push_notification_configs_rest(
&self,
task_id: &str,
) -> Result<Vec<TaskPushNotificationConfig>, V1ClientError>
pub async fn list_push_notification_configs_rest( &self, task_id: &str, ) -> Result<Vec<TaskPushNotificationConfig>, V1ClientError>
Lists push notification configs via REST
(GET /tasks/{taskId}/pushNotificationConfigs).
Sourcepub async fn delete_push_notification_config_rest(
&self,
task_id: &str,
config_id: &str,
) -> Result<(), V1ClientError>
pub async fn delete_push_notification_config_rest( &self, task_id: &str, config_id: &str, ) -> Result<(), V1ClientError>
Deletes a push notification config via REST
(DELETE /tasks/{taskId}/pushNotificationConfigs/{configId}).
Sourcepub async fn get_extended_agent_card_rest(
&self,
) -> Result<AgentCard, V1ClientError>
pub async fn get_extended_agent_card_rest( &self, ) -> Result<AgentCard, V1ClientError>
Gets the extended agent card via REST (GET /extendedAgentCard).