Class ServerAgent
java.lang.Object
com.mulesoft.connectors.a2a.internal.server.agent.ServerAgent
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionServerAgent(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 Summary
Modifier and TypeMethodDescriptionvoidaddTracingData(RpcRequestContext context, org.mule.sdk.api.runtime.source.DistributedTraceContextManager traceManager) io.a2a.spec.AgentCardgetCard()voidinitServer(ServerConfig config, org.mule.runtime.api.component.location.ComponentLocation listenerComponentLocation, Consumer<RpcRequestContext> onRequest) voidvoidsendPushNotificationCallback(String body, EffectivePushNotificationConfig config, String taskId, boolean clearAfterSend) Sends a push notification callback to the configured URL with the provided JSON-RPC formatted body.sendPushNotificationUpdate(String taskId, String payload, boolean clearAfterSend) Sends a push notification update for a specific task.voidsetPushNotificationHandler(Function<RpcRequestContext, CompletableFuture<EffectivePushNotificationConfig>> handler) protected voidsetTaskRepository(TaskRepository taskRepository) Sets the task repository.protected voidsetTaskStoreService(TaskStoreService taskStoreService) Sets the task store service.voidvoidstop()
-
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
-
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
-
getTaskRepository
-
setTaskRepository
Sets the task repository. Visible for testing purposes.- Parameters:
taskRepository- the task repository to set
-
setTaskStoreService
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 notificationpayload- The JSON-RPC formatted payload to sendclearAfterSend- 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 sendconfig- 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
-
getSseClientRegistry
-