AgentScopeA2aServer
@SuppressWarnings("rawtypes") public class AgentScopeA2aServer
io/agentscope/core/a2a/server/AgentScopeA2aServer.java:82–485AgentScope A 2 a 服务端,支持智能体之间的发现、委派与协作。位于 io.agentscope.core.a2a.server 包。核心成员包括 getTransportWrapper、getAgentCard、postEndpointReady、builder。
Agentscope A2a Server.
The core enter class for developer to export agent as A2A Server by agentscope, Developers should build server with:
-
Required: Custom
Agentsuch asReActAgent. -
Optional: Custom AgentCard.
-
Optional: Choose supported to export transport, such as
JSONRPC. -
Optional: A2A Registry(s) when server ready to access request.
-
Optional: A2A Server Feature implementations,
TaskStore,QueueManager,PushNotificationConfigStore,PushNotificationSender.
The Server is not listen ports and export endpoints. The main logic for this Server class is build and assemble all component for handle a2a request.
For example, Developers want to export JSON-RPC transport for A2A server, they should do follow the simplest steps:
-
Build Custom
Agent, such asReActAgentwithReActAgent.Builder. -
Create Builder of
AgentScopeA2aServerwith requiredReActAgent.Builder. -
Build
AgentScopeA2aServerinstance and hold it. -
Export web server with custom port and custom Controller to access web JSON-RPC request.
-
call
#postEndpointReady()when web server ready. -
Get
TransportWrapperimplementation for JSON-RPC from thisAgentScopeA2aServerto actual handle request when client request received.
嵌套类摘要Nested Class Summary
| 类Class | 类型Kind | 说明Description |
|---|---|---|
Builder | 类class | 构建器,用于构建并配置目标实例。 A class in io.agentscope.core.a2a.server that supports discovery, delegation and collaboration between agents. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public TransportWrapper getTransportWrapper(String transportName) | 获取传输层包装器。 Get a raw type `TransportWrapper` instance by its name. |
public W extends TransportWrapper<?, ?> W getTransportWrapper(String transportName, Class<W> expectedType) | 获取传输层包装器。 Get a specific `TransportWrapper` instance by its name and expected type. |
public AgentCard getAgentCard() | 获取`AgentCard`实例用于此服务端。 Get `AgentCard` instance for this server. |
public void postEndpointReady() | 执行后置端点就绪相关操作。 Call this method when all endpoint ready to access. |
public static Builder builder(ReActAgent.Builder agentBuilder)static | 获取构建器的`AgentScopeA2aServer`来自`ReActAgent.Builder`。 Get a Builder of `AgentScopeA2aServer` from `ReActAgent.Builder`. |
public static Builder builder(AgentRunner agentRunner)static | 获取构建器的`AgentScopeA2aServer`来自自定义`AgentRunner`。 Get a Builder of `AgentScopeA2aServer` from custom `AgentRunner`. |
方法详情Method Detail
getTransportWrapper
public TransportWrapper getTransportWrapper(String transportName)
获取传输层包装器。
Get a raw type TransportWrapper instance by its name.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
transportName | String | 传输层名称(类型 `String`)。transport name |
TransportWrapperio/agentscope/core/a2a/server/AgentScopeA2aServer.java:113–119getTransportWrapper
public W extends TransportWrapper<?, ?> W getTransportWrapper(String transportName, Class<W> expectedType)
获取传输层包装器。
Get a specific TransportWrapper instance by its name and expected type.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
transportName | String | 传输层名称(类型 `String`)。transport name |
expectedType | Class<W> | expected 类型(类型 `Class`)。expected class `TransportWrapper` |
WClassCastException可能抛出 `ClassCastException`。If the found wrapper is not the expected type
io/agentscope/core/a2a/server/AgentScopeA2aServer.java:130–144getAgentCard
public AgentCard getAgentCard()
获取AgentCard实例用于此服务端。
Get AgentCard instance for this server.
AgentCardio/agentscope/core/a2a/server/AgentScopeA2aServer.java:151–153postEndpointReady
public void postEndpointReady()
执行后置端点就绪相关操作。
Call this method when all endpoint ready to access.
io/agentscope/core/a2a/server/AgentScopeA2aServer.java:161–163builder
public static Builder builder(ReActAgent.Builder agentBuilder)
获取构建器的AgentScopeA2aServer来自ReActAgent.Builder。
Get a Builder of AgentScopeA2aServer from ReActAgent.Builder.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
agentBuilder | ReActAgent.Builder | `ReActAgent`的构建器。builder of `ReActAgent` |
Builderio/agentscope/core/a2a/server/AgentScopeA2aServer.java:174–176builder
public static Builder builder(AgentRunner agentRunner)
获取构建器的AgentScopeA2aServer来自自定义AgentRunner。
Get a Builder of AgentScopeA2aServer from custom AgentRunner.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
agentRunner | AgentRunner | 智能体运行器(类型 `AgentRunner`)。custom agent runner |
Builderio/agentscope/core/a2a/server/AgentScopeA2aServer.java:184–186嵌套类详情Nested Class Detail
Builder
public static class Builder构建器,用于构建并配置目标实例。位于 io.agentscope.core.a2a.server 包。核心成员包括 agentCard、withTransport、taskStore、queueManager、pushConfigStore、pushSender。
A class in io.agentscope.core.a2a.server that supports discovery, delegation and collaboration between agents. Declared in io.agentscope.core.a2a.server.