Package io.agentscope.core.a2a.server
Class AgentScopeA2aServer
java.lang.Object
io.agentscope.core.a2a.server.AgentScopeA2aServer
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
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic AgentScopeA2aServer.Builderbuilder(AgentRunner agentRunner) Get a Builder ofAgentScopeA2aServerfrom customAgentRunner.static AgentScopeA2aServer.Builderbuilder(io.agentscope.core.ReActAgent.Builder agentBuilder) Get a Builder ofAgentScopeA2aServerfromReActAgent.Builder.io.a2a.spec.AgentCardGetAgentCardinstance for this server.getTransportWrapper(String transportName) Get a raw typeTransportWrapperinstance by its name.<W extends TransportWrapper<?,?>>
WgetTransportWrapper(String transportName, Class<W> expectedType) Get a specificTransportWrapperinstance by its name and expected type.voidCall this method when all endpoint ready to access.
-
Method Details
-
getTransportWrapper
Get a raw typeTransportWrapperinstance by its name. Developers should judge type whether expected their expected before actual use.- Parameters:
transportName- transport name- Returns:
- a raw type
TransportWrapperinstance
-
getTransportWrapper
public <W extends TransportWrapper<?,?>> W getTransportWrapper(String transportName, Class<W> expectedType) Get a specificTransportWrapperinstance by its name and expected type.- Type Parameters:
W- subtype ofTransportWrapper- Parameters:
transportName- transport nameexpectedType- expected classTransportWrapper- Returns:
TransportWrapperinstance with expected type- Throws:
ClassCastException- If the found wrapper is not the expected type
-
getAgentCard
public io.a2a.spec.AgentCard getAgentCard()GetAgentCardinstance for this server.- Returns:
- agent card
-
postEndpointReady
public void postEndpointReady()Call this method when all endpoint ready to access.By default, it should be called after web server ready or other network endpoint ready. To let AgentScope end some A2A Server operation such as register A2A Registry,
-
builder
public static AgentScopeA2aServer.Builder builder(io.agentscope.core.ReActAgent.Builder agentBuilder) Get a Builder ofAgentScopeA2aServerfromReActAgent.Builder.For Most situation, will use default
ReActAgentWithBuilderRunneras theAgentRunner- Parameters:
agentBuilder- builder ofReActAgent- Returns:
- builder instance of
AgentScopeA2aServer - See Also:
-
builder
Get a Builder ofAgentScopeA2aServerfrom customAgentRunner.- Parameters:
agentRunner- custom agent runner- Returns:
- builder instance of
AgentScopeA2aServer
-