AS AgentScopeAPI 手册 / API Reference

JSONRPCHandler

public class JSONRPCHandler
源码Source io/agentscope/runtime/protocol/a2a/JSONRPCHandler.java:55–273

JSON RPC 处理器,支持智能体之间的发现、委派与协作。位于 io.agentscope.runtime.protocol.a2a 包。核心成员包括 onMessageSend、onMessageSendStream、onCancelTask、onResubscribeToTask、getPushNotificationConfig、setPushNotificationConfig。

A class in io.agentscope.runtime.protocol.a2a that supports discovery, delegation and collaboration between agents. Declared in io.agentscope.runtime.protocol.a2a.

构造器摘要Constructor Summary

构造器Constructor说明Description
protected JSONRPCHandler()
初始化 `JSONRPCHandler` 实例。
Creates a new instance.
public JSONRPCHandler(AgentCard agentCard, RequestHandler requestHandler)
初始化 `JSONRPCHandler` 实例。
Creates a new instance.

方法摘要Method Summary

方法Method说明Description
public SendMessageResponse onMessageSend(SendMessageRequest request, ServerCallContext serverCallContext)
处理消息发送事件。
Performs the on message send operation.
public Flow.Publisher<SendStreamingMessageResponse> onMessageSendStream(SendStreamingMessageRequest request, ServerCallContext serverCallContext)
处理消息发送流事件。
Performs the on message send stream operation.
public CancelTaskResponse onCancelTask(CancelTaskRequest request, ServerCallContext serverCallContext)
处理取消任务事件。
Performs the on cancel task operation.
public Flow.Publisher<SendStreamingMessageResponse> onResubscribeToTask(TaskResubscriptionRequest request, ServerCallContext serverCallContext)
处理 `onResubscribeToTask` 事件。
Performs the on resubscribe to task operation.
public GetTaskPushNotificationConfigResponse getPushNotificationConfig(GetTaskPushNotificationConfigRequest request, ServerCallContext serverCallContext)
获取推送通知配置。
Returns the push notification config.
public SetTaskPushNotificationConfigResponse setPushNotificationConfig(SetTaskPushNotificationConfigRequest request, ServerCallContext serverCallContext)
设置推送通知配置。
Sets the push notification config.
public GetTaskResponse onGetTask(GetTaskRequest request, ServerCallContext serverCallContext)
处理读取任务事件。
Performs the on get task operation.
public ListTaskPushNotificationConfigResponse listPushNotificationConfig(ListTaskPushNotificationConfigRequest request, ServerCallContext serverCallContext)
列出推送通知配置。
Lists the push notification config.
public DeleteTaskPushNotificationConfigResponse deletePushNotificationConfig(DeleteTaskPushNotificationConfigRequest request, ServerCallContext serverCallContext)
删除推送通知配置。
Deletes the push notification config.
public AgentCard getAgentCard()
获取智能体卡片。
Returns the agent card.

构造器详情Constructor Detail

JSONRPCHandler

protected JSONRPCHandler()

初始化 JSONRPCHandler 实例。

Creates a new instance.

源码Source io/agentscope/runtime/protocol/a2a/JSONRPCHandler.java:61–62

JSONRPCHandler

public JSONRPCHandler(AgentCard agentCard, RequestHandler requestHandler)

初始化 JSONRPCHandler 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
agentCardAgentCard智能体卡片(类型 `AgentCard`)。The agent card.
requestHandlerRequestHandler请求处理器(类型 `RequestHandler`)。The request handler.
源码Source io/agentscope/runtime/protocol/a2a/JSONRPCHandler.java:64–67

方法详情Method Detail

onMessageSend

public SendMessageResponse onMessageSend(SendMessageRequest request, ServerCallContext serverCallContext)

处理消息发送事件。

Performs the on message send operation.

参数Parameters
名称Name类型Type说明Description
requestSendMessageRequest请求(类型 `SendMessageRequest`)。The request.
serverCallContextServerCallContext服务端调用上下文(类型 `ServerCallContext`)。The server call context.
返回Returns SendMessageResponse
返回SendMessageResponse。Returns send message response.
源码Source io/agentscope/runtime/protocol/a2a/JSONRPCHandler.java:69–80

onMessageSendStream

public Flow.Publisher<SendStreamingMessageResponse> onMessageSendStream(SendStreamingMessageRequest request, ServerCallContext serverCallContext)

处理消息发送流事件。

Performs the on message send stream operation.

参数Parameters
名称Name类型Type说明Description
requestSendStreamingMessageRequest请求(类型 `SendStreamingMessageRequest`)。The request.
serverCallContextServerCallContext服务端调用上下文(类型 `ServerCallContext`)。The server call context.
返回Returns Flow.Publisher<SendStreamingMessageResponse>
返回Flow.Publisher。Returns flow publisher.
源码Source io/agentscope/runtime/protocol/a2a/JSONRPCHandler.java:82–103

onCancelTask

public CancelTaskResponse onCancelTask(CancelTaskRequest request, ServerCallContext serverCallContext)

处理取消任务事件。

Performs the on cancel task operation.

参数Parameters
名称Name类型Type说明Description
requestCancelTaskRequest请求(类型 `CancelTaskRequest`)。The request.
serverCallContextServerCallContext服务端调用上下文(类型 `ServerCallContext`)。The server call context.
返回Returns CancelTaskResponse
返回CancelTaskResponse。Returns cancel task response.
源码Source io/agentscope/runtime/protocol/a2a/JSONRPCHandler.java:105–119

onResubscribeToTask

public Flow.Publisher<SendStreamingMessageResponse> onResubscribeToTask(TaskResubscriptionRequest request, ServerCallContext serverCallContext)

处理 onResubscribeToTask 事件。

Performs the on resubscribe to task operation.

参数Parameters
名称Name类型Type说明Description
requestTaskResubscriptionRequest请求(类型 `TaskResubscriptionRequest`)。The request.
serverCallContextServerCallContext服务端调用上下文(类型 `ServerCallContext`)。The server call context.
返回Returns Flow.Publisher<SendStreamingMessageResponse>
返回Flow.Publisher。Returns flow publisher.
源码Source io/agentscope/runtime/protocol/a2a/JSONRPCHandler.java:121–142

getPushNotificationConfig

public GetTaskPushNotificationConfigResponse getPushNotificationConfig(GetTaskPushNotificationConfigRequest request, ServerCallContext serverCallContext)

获取推送通知配置。

Returns the push notification config.

参数Parameters
名称Name类型Type说明Description
requestGetTaskPushNotificationConfigRequest请求(类型 `GetTaskPushNotificationConfigRequest`)。The request.
serverCallContextServerCallContext服务端调用上下文(类型 `ServerCallContext`)。The server call context.
返回Returns GetTaskPushNotificationConfigResponse
返回GetTaskPushNotificationConfigResponse。Returns get task push notification config response.
源码Source io/agentscope/runtime/protocol/a2a/JSONRPCHandler.java:144–159

setPushNotificationConfig

public SetTaskPushNotificationConfigResponse setPushNotificationConfig(SetTaskPushNotificationConfigRequest request, ServerCallContext serverCallContext)

设置推送通知配置。

Sets the push notification config.

参数Parameters
名称Name类型Type说明Description
requestSetTaskPushNotificationConfigRequest请求(类型 `SetTaskPushNotificationConfigRequest`)。The request.
serverCallContextServerCallContext服务端调用上下文(类型 `ServerCallContext`)。The server call context.
返回Returns SetTaskPushNotificationConfigResponse
返回SetTaskPushNotificationConfigResponse。Returns set task push notification config response.
源码Source io/agentscope/runtime/protocol/a2a/JSONRPCHandler.java:161–176

onGetTask

public GetTaskResponse onGetTask(GetTaskRequest request, ServerCallContext serverCallContext)

处理读取任务事件。

Performs the on get task operation.

参数Parameters
名称Name类型Type说明Description
requestGetTaskRequest请求(类型 `GetTaskRequest`)。The request.
serverCallContextServerCallContext服务端调用上下文(类型 `ServerCallContext`)。The server call context.
返回Returns GetTaskResponse
返回GetTaskResponse。Returns get task response.
源码Source io/agentscope/runtime/protocol/a2a/JSONRPCHandler.java:178–189

listPushNotificationConfig

public ListTaskPushNotificationConfigResponse listPushNotificationConfig(ListTaskPushNotificationConfigRequest request, ServerCallContext serverCallContext)

列出推送通知配置。

Lists the push notification config.

参数Parameters
名称Name类型Type说明Description
requestListTaskPushNotificationConfigRequest请求(类型 `ListTaskPushNotificationConfigRequest`)。The request.
serverCallContextServerCallContext服务端调用上下文(类型 `ServerCallContext`)。The server call context.
返回Returns ListTaskPushNotificationConfigResponse
返回ListTaskPushNotificationConfigResponse。Returns list task push notification config response.
源码Source io/agentscope/runtime/protocol/a2a/JSONRPCHandler.java:191–207

deletePushNotificationConfig

public DeleteTaskPushNotificationConfigResponse deletePushNotificationConfig(DeleteTaskPushNotificationConfigRequest request, ServerCallContext serverCallContext)

删除推送通知配置。

Deletes the push notification config.

参数Parameters
名称Name类型Type说明Description
requestDeleteTaskPushNotificationConfigRequest请求(类型 `DeleteTaskPushNotificationConfigRequest`)。The request.
serverCallContextServerCallContext服务端调用上下文(类型 `ServerCallContext`)。The server call context.
返回Returns DeleteTaskPushNotificationConfigResponse
返回DeleteTaskPushNotificationConfigResponse。Returns delete task push notification config response.
源码Source io/agentscope/runtime/protocol/a2a/JSONRPCHandler.java:209–225

getAgentCard

public AgentCard getAgentCard()

获取智能体卡片。

Returns the agent card.

返回Returns AgentCard
返回AgentCard。Returns agent card.
源码Source io/agentscope/runtime/protocol/a2a/JSONRPCHandler.java:227–229
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.