Package io.a2a

Class A2A

java.lang.Object
io.a2a.A2A

public class A2A extends Object
Constants and utility methods related to the A2A protocol.
  • Constructor Details

    • A2A

      public A2A()
  • Method Details

    • toUserMessage

      public static Message toUserMessage(String text)
      Convert the given text to a user message.
      Parameters:
      text - the message text
      Returns:
      the user message
    • toUserMessage

      public static Message toUserMessage(String text, String messageId)
      Convert the given text to a user message.
      Parameters:
      text - the message text
      messageId - the message ID to use
      Returns:
      the user message
    • toAgentMessage

      public static Message toAgentMessage(String text)
      Convert the given text to an agent message.
      Parameters:
      text - the message text
      Returns:
      the agent message
    • toAgentMessage

      public static Message toAgentMessage(String text, String messageId)
      Convert the given text to an agent message.
      Parameters:
      text - the message text
      messageId - the message ID to use
      Returns:
      the agent message
    • getAgentCard

      public static AgentCard getAgentCard(String agentUrl) throws A2AClientError, A2AClientJSONError
      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 card
      A2AClientJSONError - 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 use
      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 card
      A2AClientJSONError - 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, A2AClientJSONError
      Get the agent card for an A2A agent.
      Parameters:
      agentUrl - the base URL for the agent whose agent card we want to retrieve
      relativeCardPath - 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 card
      A2AClientJSONError - 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, A2AClientJSONError
      Get the agent card for an A2A agent.
      Parameters:
      httpClient - the http client to use
      agentUrl - the base URL for the agent whose agent card we want to retrieve
      relativeCardPath - 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 card
      A2AClientJSONError - f the response body cannot be decoded as JSON or validated against the AgentCard schema