Package io.a2a.client

Class Client


public class Client extends AbstractClient
  • Method Details

    • builder

      public static ClientBuilder builder(AgentCard agentCard)
    • sendMessage

      public void sendMessage(Message request, @Nullable ClientCallContext context) throws A2AClientException
      Description copied from class: AbstractClient
      Send a message to the remote agent. This method will automatically use the streaming or non-streaming approach as determined by the server's agent card and the client configuration. The configured client consumers will be used to handle messages, tasks, and update events received from the remote agent. The configured streaming error handler will be used if an error occurs during streaming. The configured client push notification configuration will get used for streaming.
      Specified by:
      sendMessage in class AbstractClient
      Parameters:
      request - the message
      context - optional client call context for the request (may be null)
      Throws:
      A2AClientException - if sending the message fails for any reason
    • sendMessage

      public void sendMessage(Message request, List<BiConsumer<ClientEvent,AgentCard>> consumers, Consumer<Throwable> streamingErrorHandler, @Nullable ClientCallContext context) throws A2AClientException
      Description copied from class: AbstractClient
      Send a message to the remote agent. This method will automatically use the streaming or non-streaming approach as determined by the server's agent card and the client configuration. The specified client consumers will be used to handle messages, tasks, and update events received from the remote agent. The specified streaming error handler will be used if an error occurs during streaming. The configured client push notification configuration will get used for streaming.
      Specified by:
      sendMessage in class AbstractClient
      Parameters:
      request - the message
      consumers - a list of consumers to pass responses from the remote agent to
      streamingErrorHandler - an error handler that should be used for the streaming case if an error occurs
      context - optional client call context for the request (may be null)
      Throws:
      A2AClientException - if sending the message fails for any reason
    • sendMessage

      public void sendMessage(Message request, PushNotificationConfig pushNotificationConfiguration, Map<String,Object> metatadata, @Nullable ClientCallContext context) throws A2AClientException
      Description copied from class: AbstractClient
      Send a message to the remote agent. This method will automatically use the streaming or non-streaming approach as determined by the server's agent card and the client configuration. The configured client consumers will be used to handle messages, tasks, and update events received from the remote agent. The configured streaming error handler will be used if an error occurs during streaming.
      Specified by:
      sendMessage in class AbstractClient
      Parameters:
      request - the message
      pushNotificationConfiguration - the push notification configuration that should be used if the streaming approach is used
      metatadata - the optional metadata to include when sending the message
      context - optional client call context for the request (may be null)
      Throws:
      A2AClientException - if sending the message fails for any reason
    • getTask

      public Task getTask(TaskQueryParams request, @Nullable ClientCallContext context) throws A2AClientException
      Description copied from class: AbstractClient
      Retrieve the current state and history of a specific task.
      Specified by:
      getTask in class AbstractClient
      Parameters:
      request - the task query parameters specifying which task to retrieve
      context - optional client call context for the request (may be null)
      Returns:
      the task
      Throws:
      A2AClientException - if retrieving the task fails for any reason
    • cancelTask

      public Task cancelTask(TaskIdParams request, @Nullable ClientCallContext context) throws A2AClientException
      Description copied from class: AbstractClient
      Request the agent to cancel a specific task.
      Specified by:
      cancelTask in class AbstractClient
      Parameters:
      request - the task ID parameters specifying which task to cancel
      context - optional client call context for the request (may be null)
      Returns:
      the cancelled task
      Throws:
      A2AClientException - if cancelling the task fails for any reason
    • setTaskPushNotificationConfiguration

      public TaskPushNotificationConfig setTaskPushNotificationConfiguration(TaskPushNotificationConfig request, @Nullable ClientCallContext context) throws A2AClientException
      Description copied from class: AbstractClient
      Set or update the push notification configuration for a specific task.
      Specified by:
      setTaskPushNotificationConfiguration in class AbstractClient
      Parameters:
      request - the push notification configuration to set for the task
      context - optional client call context for the request (may be null)
      Returns:
      the configured TaskPushNotificationConfig
      Throws:
      A2AClientException - if setting the task push notification configuration fails for any reason
    • getTaskPushNotificationConfiguration

      public TaskPushNotificationConfig getTaskPushNotificationConfiguration(GetTaskPushNotificationConfigParams request, @Nullable ClientCallContext context) throws A2AClientException
      Description copied from class: AbstractClient
      Retrieve the push notification configuration for a specific task.
      Specified by:
      getTaskPushNotificationConfiguration in class AbstractClient
      Parameters:
      request - the parameters specifying which task's notification config to retrieve
      context - optional client call context for the request (may be null)
      Returns:
      the task push notification config
      Throws:
      A2AClientException - if getting the task push notification config fails for any reason
    • listTaskPushNotificationConfigurations

      public List<TaskPushNotificationConfig> listTaskPushNotificationConfigurations(ListTaskPushNotificationConfigParams request, @Nullable ClientCallContext context) throws A2AClientException
      Description copied from class: AbstractClient
      Retrieve the list of push notification configurations for a specific task.
      Specified by:
      listTaskPushNotificationConfigurations in class AbstractClient
      Parameters:
      request - the parameters specifying which task's notification configs to retrieve
      context - optional client call context for the request (may be null)
      Returns:
      the list of task push notification configs
      Throws:
      A2AClientException - if getting the task push notification configs fails for any reason
    • deleteTaskPushNotificationConfigurations

      public void deleteTaskPushNotificationConfigurations(DeleteTaskPushNotificationConfigParams request, @Nullable ClientCallContext context) throws A2AClientException
      Description copied from class: AbstractClient
      Delete the list of push notification configurations for a specific task.
      Specified by:
      deleteTaskPushNotificationConfigurations in class AbstractClient
      Parameters:
      request - the parameters specifying which task's notification configs to delete
      context - optional client call context for the request (may be null)
      Throws:
      A2AClientException - if deleting the task push notification configs fails for any reason
    • resubscribe

      public void resubscribe(TaskIdParams request, @Nullable ClientCallContext context) throws A2AClientException
      Description copied from class: AbstractClient
      Resubscribe to a task's event stream. This is only available if both the client and server support streaming. The configured client consumers will be used to handle messages, tasks, and update events received from the remote agent. The configured streaming error handler will be used if an error occurs during streaming.
      Specified by:
      resubscribe in class AbstractClient
      Parameters:
      request - the parameters specifying which task's notification configs to delete
      context - optional client call context for the request (may be null)
      Throws:
      A2AClientException - if resubscribing fails for any reason
    • resubscribe

      public void resubscribe(TaskIdParams request, @Nullable List<BiConsumer<ClientEvent,AgentCard>> consumers, @Nullable Consumer<Throwable> streamingErrorHandler, @Nullable ClientCallContext context) throws A2AClientException
      Description copied from class: AbstractClient
      Resubscribe to a task's event stream. This is only available if both the client and server support streaming. The specified client consumers will be used to handle messages, tasks, and update events received from the remote agent. The specified streaming error handler will be used if an error occurs during streaming.
      Specified by:
      resubscribe in class AbstractClient
      Parameters:
      request - the parameters specifying which task's notification configs to delete
      consumers - a list of consumers to pass responses from the remote agent to
      streamingErrorHandler - an error handler that should be used for the streaming case if an error occurs
      context - optional client call context for the request (may be null)
      Throws:
      A2AClientException - if resubscribing fails for any reason
    • getAgentCard

      public AgentCard getAgentCard(@Nullable ClientCallContext context) throws A2AClientException
      Description copied from class: AbstractClient
      Retrieve the AgentCard.
      Specified by:
      getAgentCard in class AbstractClient
      Parameters:
      context - optional client call context for the request (may be null)
      Returns:
      the AgentCard
      Throws:
      A2AClientException - if retrieving the agent card fails for any reason
    • close

      public void close()
      Description copied from class: AbstractClient
      Close the transport and release any associated resources.
      Specified by:
      close in class AbstractClient