Class A2A_v0_3

java.lang.Object
org.a2aproject.sdk.compat03.A2A_v0_3

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

    • A2A_v0_3

      public A2A_v0_3()
  • Method Details

    • toUserMessage

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

      public static Message_v0_3 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_v0_3 toAgentMessage(String text)
      Convert the given text to an agent message.
      Parameters:
      text - the message text
      Returns:
      the agent message
    • toAgentMessage

      public static Message_v0_3 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
    • createUserTextMessage

      public static Message_v0_3 createUserTextMessage(String text, String contextId, String taskId)
      Create a user message with text content and optional context and task IDs.
      Parameters:
      text - the message text (required)
      contextId - the context ID to use (optional)
      taskId - the task ID to use (optional)
      Returns:
      the user message
    • createAgentTextMessage

      public static Message_v0_3 createAgentTextMessage(String text, String contextId, String taskId)
      Create an agent message with text content and optional context and task IDs.
      Parameters:
      text - the message text (required)
      contextId - the context ID to use (optional)
      taskId - the task ID to use (optional)
      Returns:
      the agent message
    • createAgentPartsMessage

      public static Message_v0_3 createAgentPartsMessage(List<Part_v0_3<?>> parts, String contextId, String taskId)
      Create an agent message with custom parts and optional context and task IDs.
      Parameters:
      parts - the message parts (required)
      contextId - the context ID to use (optional)
      taskId - the task ID to use (optional)
      Returns:
      the agent message
    • getAgentCard

      public static AgentCard_v0_3 getAgentCard(String agentUrl) throws A2AClientError_v0_3, A2AClientJSONError_v0_3
      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_v0_3 - If an HTTP error occurs fetching the card
      A2AClientJSONError_v0_3 - If the response body cannot be decoded as JSON or validated against the AgentCard schema
    • getAgentCard

      public static AgentCard_v0_3 getAgentCard(A2AHttpClient httpClient, String agentUrl) throws A2AClientError_v0_3, A2AClientJSONError_v0_3
      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_v0_3 - If an HTTP error occurs fetching the card
      A2AClientJSONError_v0_3 - If the response body cannot be decoded as JSON or validated against the AgentCard schema
    • getAgentCard

      public static AgentCard_v0_3 getAgentCard(String agentUrl, String relativeCardPath, Map<String,String> authHeaders) throws A2AClientError_v0_3, A2AClientJSONError_v0_3
      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-card.json"
      authHeaders - the HTTP authentication headers to use
      Returns:
      the agent card
      Throws:
      A2AClientError_v0_3 - If an HTTP error occurs fetching the card
      A2AClientJSONError_v0_3 - If the response body cannot be decoded as JSON or validated against the AgentCard schema
    • getAgentCard

      public static AgentCard_v0_3 getAgentCard(A2AHttpClient httpClient, String agentUrl, String relativeCardPath, Map<String,String> authHeaders) throws A2AClientError_v0_3, A2AClientJSONError_v0_3
      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-card.json"
      authHeaders - the HTTP authentication headers to use
      Returns:
      the agent card
      Throws:
      A2AClientError_v0_3 - If an HTTP error occurs fetching the card
      A2AClientJSONError_v0_3 - If the response body cannot be decoded as JSON or validated against the AgentCard schema