java.lang.Object
com.mulesoft.connectors.a2a.internal.server.agent.ServerAgent

public class ServerAgent extends Object
  • Field Details

    • TASK_OS_TTL

      public static final long TASK_OS_TTL
  • Constructor Details

    • ServerAgent

      public ServerAgent(org.mule.runtime.http.api.server.HttpServer httpServer, String path, org.mule.runtime.api.lock.LockFactory lockFactory, org.mule.runtime.api.store.ObjectStoreManager objectStoreManager, org.mule.runtime.http.api.client.HttpClient client, A2ASerializer a2ASerializer, org.mule.runtime.core.api.MuleContext muleContext, org.mule.runtime.api.scheduler.Scheduler pollerScheduler)
  • Method Details

    • initServer

      public void initServer(ServerConfig config, org.mule.runtime.api.component.location.ComponentLocation listenerComponentLocation, Consumer<RpcRequestContext> onRequest)
    • setPushNotificationHandler

      public void setPushNotificationHandler(Function<RpcRequestContext,CompletableFuture<EffectivePushNotificationConfig>> handler)
    • removePushNotificationHandler

      public void removePushNotificationHandler()
    • setTaskStreamHandler

      public void setTaskStreamHandler(Function<RpcRequestContext,CompletableFuture<Void>> handler)
    • removeTaskStreamHandler

      public void removeTaskStreamHandler()
    • addTracingData

      public void addTracingData(RpcRequestContext context, org.mule.sdk.api.runtime.source.DistributedTraceContextManager traceManager)
    • stop

      public void stop()
    • getCard

      public io.a2a.spec.AgentCard getCard()
    • getA2aService

      public A2ASerializer getA2aService()
    • getTaskRepository

      public TaskRepository getTaskRepository()
    • setTaskRepository

      protected void setTaskRepository(TaskRepository taskRepository)
      Sets the task repository. Visible for testing purposes.
      Parameters:
      taskRepository - the task repository to set
    • setTaskStoreService

      protected void setTaskStoreService(TaskStoreService taskStoreService)
      Sets the task store service. Visible for testing purposes.
      Parameters:
      taskStoreService - the task store service to set
    • sendPushNotificationUpdate

      public CompletableFuture<Void> sendPushNotificationUpdate(String taskId, String payload, boolean clearAfterSend)
      Sends a push notification update for a specific task. Retrieves the push notification config from the repository and sends the provided JSON-RPC formatted payload.
      Parameters:
      taskId - The ID of the task for which to send the notification
      payload - The JSON-RPC formatted payload to send
      clearAfterSend - Whether to clear the push notification config after successful send
      Returns:
      CompletableFuture that completes successfully when all push notifications have been sent, or completes exceptionally with ModuleException if there's an error accessing the repository or sending, or with IllegalStateException if no push notification config is found for the task
    • sendPushNotificationCallback

      public CompletableFuture<Void> sendPushNotificationCallback(String body, EffectivePushNotificationConfig config, String taskId, boolean clearAfterSend)
      Sends a push notification callback to the configured URL with the provided JSON-RPC formatted body.
      Parameters:
      body - The JSON-RPC formatted body to send
      config - The push notification configuration containing URL, auth, headers, etc.
      taskId - The task ID (for logging and clearing config)
      clearAfterSend - Whether to clear the push notification config after successful send
      Returns:
      CompletableFuture that completes when the HTTP request finishes
    • getTaskStoreService

      public TaskStoreService getTaskStoreService()
    • getSseClientRegistry

      public SseClientRegistry getSseClientRegistry()