Class A2AProtocolSerializer

java.lang.Object
com.mulesoft.connectors.a2a.internal.protocol.A2AProtocolSerializer
All Implemented Interfaces:
org.mule.runtime.api.lifecycle.Initialisable

public class A2AProtocolSerializer extends Object implements org.mule.runtime.api.lifecycle.Initialisable
  • Constructor Details

    • A2AProtocolSerializer

      public A2AProtocolSerializer()
  • Method Details

    • getJsonMessageFromResult

      public String getJsonMessageFromResult(String json)
    • parseResult

      public JsonRpcResult parseResult(String json)
    • getJsonMessageFromRequest

      public String getJsonMessageFromRequest(String json)
    • getTaskQueryParams

      public JsonRpcResult getTaskQueryParams(String params)
    • transformTaskHistoryResponse

      public String transformTaskHistoryResponse(String taskHistoryJson, int historyLength)
    • transformPushNotificationConfigResponse

      public String transformPushNotificationConfigResponse(String taskId, EffectivePushNotificationConfig pushConfig)
      Transforms push notification config data into the proper response format.
      Parameters:
      taskId - The task ID
      pushConfig - The push notification configuration
      Returns:
      The transformed response as JSON string
    • transformPushNotificationConfigListResponse

      public String transformPushNotificationConfigListResponse(String taskId, List<EffectivePushNotificationConfig> pushConfigs)
      Transforms push notification configs data into the proper response format.
      Parameters:
      taskId - The task ID
      pushConfigs - The push notification configurations for taskId
      Returns:
      The transformed response as JSON string
    • extractMessageFromParams

      public MessageObject extractMessageFromParams(String paramsJson)
      Extracts taskId from A2A message structure in params JSON. Looks for taskId in params.message.taskId structure.
      Parameters:
      paramsJson - The JSON string containing the request parameters
      Returns:
      The taskId if found, null otherwise
    • extractTaskIdForPushNotificationConfig

      public String extractTaskIdForPushNotificationConfig(String paramsJson)
      Extracts taskId for push notification config set method. Looks for taskId at the top level of params.
      Parameters:
      paramsJson - The JSON string containing the request parameters
      Returns:
      The taskId if found, null otherwise
    • toAgentCardJson

      public String toAgentCardJson(AgentCard agentCard) throws AgentCardDiscoveryException.InvalidAgentCardException
      Throws:
      AgentCardDiscoveryException.InvalidAgentCardException
    • parseAgentCard

      public AgentCard parseAgentCard(String json)
    • parsePushNotificationConfig

      public EffectivePushNotificationConfig parsePushNotificationConfig(String json)
    • extractPushNotificationConfigJson

      public String extractPushNotificationConfigJson(String fullParamsJson)
    • getTaskPushNotificationConfigParams

      public JsonRpcResult getTaskPushNotificationConfigParams(String params)
      Extracts the taskQueryParams with {id an pushNotificationConfigId} and transforms into TaskIdParams/TaskQueryParams for push notification get/list/delete usage
      Parameters:
      params - from the json rpc request
      Returns:
      JsonRpcResult with the result field as TaskIdParams/TaskQueryParams
    • initialise

      public void initialise()
      Specified by:
      initialise in interface org.mule.runtime.api.lifecycle.Initialisable