AS AgentScopeAPI 手册 / API Reference

AgentScopeA2aServer

@SuppressWarnings("rawtypes") public class AgentScopeA2aServer
源码Source io/agentscope/core/a2a/server/AgentScopeA2aServer.java:82–485

AgentScope 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 Agent such as ReActAgent.

  • 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 as ReActAgent with ReActAgent.Builder.

  • Create Builder of AgentScopeA2aServer with required ReActAgent.Builder.

  • Build AgentScopeA2aServer instance 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 TransportWrapper implementation for JSON-RPC from this AgentScopeA2aServer to 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.

参数Parameters
名称Name类型Type说明Description
transportNameString传输层名称(类型 `String`)。transport name
返回Returns TransportWrapper
一种原始类型`TransportWrapper`实例。a raw type `TransportWrapper` instance
源码Source io/agentscope/core/a2a/server/AgentScopeA2aServer.java:113–119

getTransportWrapper

public W extends TransportWrapper<?, ?> W getTransportWrapper(String transportName, Class<W> expectedType)

获取传输层包装器。

Get a specific TransportWrapper instance by its name and expected type.

参数Parameters
名称Name类型Type说明Description
transportNameString传输层名称(类型 `String`)。transport name
expectedTypeClass<W>expected 类型(类型 `Class`)。expected class `TransportWrapper`
返回Returns W
返回W。`TransportWrapper` instance with expected type
抛出Throws
  • ClassCastException 可能抛出 `ClassCastException`。If the found wrapper is not the expected type
源码Source io/agentscope/core/a2a/server/AgentScopeA2aServer.java:130–144

getAgentCard

public AgentCard getAgentCard()

获取AgentCard实例用于此服务端。

Get AgentCard instance for this server.

返回Returns AgentCard
返回AgentCard。agent card
源码Source io/agentscope/core/a2a/server/AgentScopeA2aServer.java:151–153

postEndpointReady

public void postEndpointReady()

执行后置端点就绪相关操作。

Call this method when all endpoint ready to access.

源码Source io/agentscope/core/a2a/server/AgentScopeA2aServer.java:161–163

builder

public static Builder builder(ReActAgent.Builder agentBuilder)
static

获取构建器的AgentScopeA2aServer来自ReActAgent.Builder。

Get a Builder of AgentScopeA2aServer from ReActAgent.Builder.

另见See also @see #builder(AgentRunner)
参数Parameters
名称Name类型Type说明Description
agentBuilderReActAgent.Builder`ReActAgent`的构建器。builder of `ReActAgent`
返回Returns Builder
`AgentScopeA2aServer`的构建器实例。builder instance of `AgentScopeA2aServer`
源码Source io/agentscope/core/a2a/server/AgentScopeA2aServer.java:174–176

builder

public static Builder builder(AgentRunner agentRunner)
static

获取构建器的AgentScopeA2aServer来自自定义AgentRunner。

Get a Builder of AgentScopeA2aServer from custom AgentRunner.

参数Parameters
名称Name类型Type说明Description
agentRunnerAgentRunner智能体运行器(类型 `AgentRunner`)。custom agent runner
返回Returns Builder
`AgentScopeA2aServer`的构建器实例。builder instance of `AgentScopeA2aServer`
源码Source io/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.

基于官方固定版本源码静态生成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.