Package io.a2a
Class A2A
java.lang.Object
io.a2a.A2A
Constants and utility methods related to the A2A protocol.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic AgentCardgetAgentCard(A2AHttpClient httpClient, String agentUrl) Get the agent card for an A2A agent.static AgentCardgetAgentCard(A2AHttpClient httpClient, String agentUrl, String relativeCardPath, Map<String, String> authHeaders) Get the agent card for an A2A agent.static AgentCardgetAgentCard(String agentUrl) Get the agent card for an A2A agent.static AgentCardGet the agent card for an A2A agent.static MessagetoAgentMessage(String text) Convert the given text to an agent message.static MessagetoAgentMessage(String text, String messageId) Convert the given text to an agent message.static MessagetoUserMessage(String text) Convert the given text to a user message.static MessagetoUserMessage(String text, String messageId) Convert the given text to a user message.
-
Constructor Details
-
A2A
public A2A()
-
-
Method Details
-
toUserMessage
Convert the given text to a user message.- Parameters:
text- the message text- Returns:
- the user message
-
toUserMessage
Convert the given text to a user message.- Parameters:
text- the message textmessageId- the message ID to use- Returns:
- the user message
-
toAgentMessage
Convert the given text to an agent message.- Parameters:
text- the message text- Returns:
- the agent message
-
toAgentMessage
Convert the given text to an agent message.- Parameters:
text- the message textmessageId- the message ID to use- Returns:
- the agent message
-
getAgentCard
Get the agent card for an A2A agent.- Parameters:
agentUrl- the base URL for the agent whose agent card we want to retrieve- Returns:
- the agent card
- Throws:
A2AClientError- If an HTTP error occurs fetching the cardA2AClientJSONError- f the response body cannot be decoded as JSON or validated against the AgentCard schema
-
getAgentCard
public static AgentCard getAgentCard(A2AHttpClient httpClient, String agentUrl) throws A2AClientError, A2AClientJSONError Get the agent card for an A2A agent.- Parameters:
httpClient- the http client to useagentUrl- the base URL for the agent whose agent card we want to retrieve- Returns:
- the agent card
- Throws:
A2AClientError- If an HTTP error occurs fetching the cardA2AClientJSONError- f the response body cannot be decoded as JSON or validated against the AgentCard schema
-
getAgentCard
public static AgentCard getAgentCard(String agentUrl, String relativeCardPath, Map<String, String> authHeaders) throws A2AClientError, A2AClientJSONErrorGet the agent card for an A2A agent.- Parameters:
agentUrl- the base URL for the agent whose agent card we want to retrieverelativeCardPath- optional path to the agent card endpoint relative to the base agent URL, defaults to ".well-known/agent.json"authHeaders- the HTTP authentication headers to use- Returns:
- the agent card
- Throws:
A2AClientError- If an HTTP error occurs fetching the cardA2AClientJSONError- f the response body cannot be decoded as JSON or validated against the AgentCard schema
-
getAgentCard
public static AgentCard getAgentCard(A2AHttpClient httpClient, String agentUrl, String relativeCardPath, Map<String, String> authHeaders) throws A2AClientError, A2AClientJSONErrorGet the agent card for an A2A agent.- Parameters:
httpClient- the http client to useagentUrl- the base URL for the agent whose agent card we want to retrieverelativeCardPath- optional path to the agent card endpoint relative to the base agent URL, defaults to ".well-known/agent.json"authHeaders- the HTTP authentication headers to use- Returns:
- the agent card
- Throws:
A2AClientError- If an HTTP error occurs fetching the cardA2AClientJSONError- f the response body cannot be decoded as JSON or validated against the AgentCard schema
-