类 DefaultA2AClient

java.lang.Object
io.github.a2ap.core.client.impl.DefaultA2AClient
所有已实现的接口:
A2AClient

public class DefaultA2AClient extends Object implements A2AClient
Default implementation of the A2AClient interface providing comprehensive A2A protocol client functionality. This implementation offers a complete HTTP-based client for interacting with A2A protocol-compliant agents. It handles all aspects of the client-side A2A communication including agent discovery, task management, streaming operations, and push notification configuration. Key features: - JSON-RPC 2.0 based communication over HTTP - Automatic agent card resolution and caching - Support for both synchronous and streaming message operations - Comprehensive task lifecycle management (send, get, cancel, resubscribe) - Push notification configuration management - Built-in capability detection and validation - Robust error handling and logging Communication protocol: - Uses Reactor Netty HttpClient for non-blocking HTTP operations - All requests follow JSON-RPC 2.0 specification - Streaming responses are handled via Server-Sent Events (SSE) - Automatic request ID generation for proper correlation Supported A2A methods: - "message/send": Send messages and create tasks - "message/stream": Send messages with streaming updates - "tasks/get": Retrieve task information - "tasks/cancel": Cancel ongoing tasks - "tasks/pushNotificationConfig/set": Configure push notifications - "tasks/pushNotificationConfig/get": Retrieve push notification settings - "tasks/resubscribe": Resubscribe to task updates The client maintains agent card information for efficient communication and provides capability checking to ensure operations are supported by the target agent. Thread safety: This implementation is thread-safe and can be used concurrently across multiple threads.
  • 构造器详细资料

    • DefaultA2AClient

      public DefaultA2AClient(CardResolver cardResolver)
      Constructs a new A2AClientImpl with the specified CardResolver.
      参数:
      cardResolver - The CardResolver to use for resolving agent cards.
    • DefaultA2AClient

      public DefaultA2AClient(AgentCard agentCard)
      Constructs a new A2aClient with the agent card info
      参数:
      agentCard - agent card info
    • DefaultA2AClient

      public DefaultA2AClient(AgentCard agentCard, CardResolver cardResolver)
      Constructs a new A2AClientImpl with the specified CardResolver.
      参数:
      cardResolver - The CardResolver to use for resolving agent cards.
      agentCard - The agent card info.
  • 方法详细资料

    • agentCard

      public AgentCard agentCard()
      从接口复制的说明: A2AClient
      Get the AgentCard info current in client
      指定者:
      agentCard 在接口中 A2AClient
      返回:
      AgentCard
    • retrieveAgentCard

      public AgentCard retrieveAgentCard()
      从接口复制的说明: A2AClient
      Retrieves the AgentCard for the server this client connects to. This is typically fetched from a well-known endpoint.
      指定者:
      retrieveAgentCard 在接口中 A2AClient
      返回:
      AgentCard.
    • sendMessage

      public SendMessageResponse sendMessage(MessageSendParams taskSendParams) throws A2AError
      Sends a task request to the target agent URL.
      指定者:
      sendMessage 在接口中 A2AClient
      参数:
      taskSendParams - The parameters for sending the task.
      返回:
      The created Task object received from the agent.
      抛出:
      A2AError
    • sendMessageStream

      public reactor.core.publisher.Flux<SendStreamingMessageResponse> sendMessageStream(MessageSendParams params)
      从接口复制的说明: A2AClient
      Sends a task request and subscribes to streaming updates. Returns a Flux that emits TaskUpdateEvent payloads (either TaskStatusUpdateEvent or TaskArtifactUpdateEvent).
      指定者:
      sendMessageStream 在接口中 A2AClient
      参数:
      params - The parameters for the tasks/sendSubscribe method.
      返回:
      A Flux of task update events.
    • getTask

      public Task getTask(TaskQueryParams queryParams)
      Retrieves a specific task by its ID from the target agent URL.
      指定者:
      getTask 在接口中 A2AClient
      参数:
      queryParams - The query params task to retrieve.
      返回:
      An Optional containing the Task object if found, otherwise empty.
    • cancelTask

      public Task cancelTask(TaskIdParams params)
      从接口复制的说明: A2AClient
      Cancels a currently running task.
      指定者:
      cancelTask 在接口中 A2AClient
      参数:
      params - The parameters for the tasks/cancel method.
      返回:
      the updated Task object (usually canceled state) or null.
    • setTaskPushNotification

      public TaskPushNotificationConfig setTaskPushNotification(TaskPushNotificationConfig params)
      从接口复制的说明: A2AClient
      Sets or updates the push notification config for a task.
      指定者:
      setTaskPushNotification 在接口中 A2AClient
      参数:
      params - The parameters for the tasks/pushNotification/set method.
      返回:
      the confirmed TaskPushNotificationConfig or null.
    • getTaskPushNotification

      public TaskPushNotificationConfig getTaskPushNotification(TaskIdParams params)
      从接口复制的说明: A2AClient
      Retrieves the currently configured push notification config for a task.
      指定者:
      getTaskPushNotification 在接口中 A2AClient
      参数:
      params - The parameters for the tasks/pushNotification/get method.
      返回:
      the TaskPushNotificationConfig or null.
    • resubscribeTask

      public reactor.core.publisher.Flux<SendStreamingMessageResponse> resubscribeTask(TaskQueryParams params)
      从接口复制的说明: A2AClient
      Resubscribes to updates for a task after a potential connection interruption. Returns a Publisher that emits TaskUpdateEvent payloads (either TaskStatusUpdateEvent or TaskArtifactUpdateEvent).
      指定者:
      resubscribeTask 在接口中 A2AClient
      参数:
      params - The parameters for the tasks/resubscribe method.
      返回:
      A Flux of task update events.
    • supports

      public Boolean supports(String capability)
      从接口复制的说明: A2AClient
      Optional: Checks if the server likely supports optional methods based on agent card. This is a client-side heuristic and might not be perfectly accurate.
      指定者:
      supports 在接口中 A2AClient
      参数:
      capability - The capability to check (e.g., 'streaming', 'pushNotifications').
      返回:
      true if the capability is likely supported.