类 DefaultA2AClient
java.lang.Object
io.github.a2ap.core.client.impl.DefaultA2AClient
- 所有已实现的接口:
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(CardResolver cardResolver) Constructs a new A2AClientImpl with the specified CardResolver.DefaultA2AClient(AgentCard agentCard) Constructs a new A2aClient with the agent card infoDefaultA2AClient(AgentCard agentCard, CardResolver cardResolver) Constructs a new A2AClientImpl with the specified CardResolver. -
方法概要
修饰符和类型方法说明Get the AgentCard info current in clientcancelTask(TaskIdParams params) Cancels a currently running task.getTask(TaskQueryParams queryParams) Retrieves a specific task by its ID from the target agent URL.getTaskPushNotification(TaskIdParams params) Retrieves the currently configured push notification config for a task.reactor.core.publisher.Flux<SendStreamingMessageResponse>resubscribeTask(TaskQueryParams params) Resubscribes to updates for a task after a potential connection interruption.Retrieves the AgentCard for the server this client connects to.sendMessage(MessageSendParams taskSendParams) Sends a task request to the target agent URL.reactor.core.publisher.Flux<SendStreamingMessageResponse>sendMessageStream(MessageSendParams params) Sends a task request and subscribes to streaming updates.Sets or updates the push notification config for a task.Optional: Checks if the server likely supports optional methods based on agent card.
-
构造器详细资料
-
DefaultA2AClient
Constructs a new A2AClientImpl with the specified CardResolver.- 参数:
cardResolver- The CardResolver to use for resolving agent cards.
-
DefaultA2AClient
Constructs a new A2aClient with the agent card info- 参数:
agentCard- agent card info
-
DefaultA2AClient
Constructs a new A2AClientImpl with the specified CardResolver.- 参数:
cardResolver- The CardResolver to use for resolving agent cards.agentCard- The agent card info.
-
-
方法详细资料
-
agentCard
从接口复制的说明:A2AClientGet the AgentCard info current in client -
retrieveAgentCard
从接口复制的说明:A2AClientRetrieves the AgentCard for the server this client connects to. This is typically fetched from a well-known endpoint.- 指定者:
retrieveAgentCard在接口中A2AClient- 返回:
- AgentCard.
-
sendMessage
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) 从接口复制的说明:A2AClientSends 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
Retrieves a specific task by its ID from the target agent URL. -
cancelTask
从接口复制的说明:A2AClientCancels a currently running task.- 指定者:
cancelTask在接口中A2AClient- 参数:
params- The parameters for the tasks/cancel method.- 返回:
- the updated Task object (usually canceled state) or null.
-
setTaskPushNotification
从接口复制的说明:A2AClientSets 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
从接口复制的说明:A2AClientRetrieves 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) 从接口复制的说明:A2AClientResubscribes 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
从接口复制的说明:A2AClientOptional: Checks if the server likely supports optional methods based on agent card. This is a client-side heuristic and might not be perfectly accurate.
-