AS AgentScopeAPI 手册 / API Reference

GatewayBootstrap

public final class GatewayBootstrap
源码Source io/agentscope/harness/agent/gateway/GatewayBootstrap.java:85–331

网关 Bootstrap,承载智能体的部署、调度与服务化运行。位于 io.agentscope.harness.agent.gateway 包。核心成员包括 builder、gateway、channelManager、agents、mainAgentId、gatewayBridge。

Multi-agent + channel routing bootstrap. The primary user-facing entry point for building a gateway-managed agent system.

Minimal usage — single agent + ChatUI

`HarnessAgent agent = HarnessAgent.builder()
.model(model).name("assistant").sysPrompt("You are helpful.")
.build();

GatewayBootstrap gw = GatewayBootstrap.builder()
.agent("main", agent)
.build();

ChatUiChannel chat = gw.chatUiChannel();
Msg reply = chat.send("hello").block();
`

Multi-agent + binding routing

`GatewayBootstrap gw = GatewayBootstrap.builder()
.agent("sales", salesAgent)
.agent("support", supportAgent)
.mainAgent("sales")
.build();

ChannelConfig config = ChannelConfig.builder("chatui")
.dmScope(DmScope.PER_PEER)
.binding(ChannelBinding.forPeer("direct:vip-user-1", "support"))
.build();

ChatUiChannel chat = gw.chatUiChannel(config);
chat.send("vip-user-1", "help me").block(); // routes to support agent
chat.send("normal-user", "hi").block(); // routes to sales (default)
`

External channels

`GatewayBootstrap gw = GatewayBootstrap.builder()
.agent("main", agent)
.channel(mySlackChannel)
.build();

gw.start(); // init + start all channels
gw.stop(); // stop all channels
`

嵌套类摘要Nested Class Summary

类Class类型Kind说明Description
Builder类class
构建器,用于构建并配置目标实例。
A class in io.agentscope.harness.agent.gateway that deploys, schedules and serves agents.

方法摘要Method Summary

方法Method说明Description
public static Builder builder()
static
返回新的构建器。
Returns a new builder.
public HarnessGateway gateway()
返回网关。
The underlying gateway (advanced usage).
public ChannelManager channelManager()
返回渠道管理器。
The channel manager (advanced usage).
public Map<String, HarnessAgent> agents()
返回智能体。
The registered agents keyed by id.
public String mainAgentId()
主智能体标识。
The main agent id.
public SubagentGatewayBridge gatewayBridge()
返回 `gatewayBridge` 结果。
Returns a `SubagentGatewayBridge` that exposes subagents as user-addressable threads within this gateway.
public ChatUiChannel chatUiChannel()
返回聊天 Ui 渠道。
Returns a `ChatUiChannel` with default DmScope.MAIN config, pre-wired to this gateway.
public ChatUiChannel chatUiChannel(ChannelConfig config)
设置聊天 Ui 渠道。
Returns a `ChatUiChannel` with custom routing config, pre-wired to this gateway.
public GatewayBootstrap start()
返回启动。
Initializes and starts all pre-registered channels (injecting the gateway into each).
public void stop()
执行停止相关操作。
Stops all channels and releases resources.

方法详情Method Detail

builder

public static Builder builder()
static

返回新的构建器。

Returns a new builder.

返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/harness/agent/gateway/GatewayBootstrap.java:104–106

gateway

public HarnessGateway gateway()

返回网关。

The underlying gateway (advanced usage).

返回Returns HarnessGateway
返回HarnessGateway。Returns harness gateway.
源码Source io/agentscope/harness/agent/gateway/GatewayBootstrap.java:109–111

channelManager

public ChannelManager channelManager()

返回渠道管理器。

The channel manager (advanced usage).

返回Returns ChannelManager
返回ChannelManager。Returns channel manager.
源码Source io/agentscope/harness/agent/gateway/GatewayBootstrap.java:114–116

agents

public Map<String, HarnessAgent> agents()

返回智能体。

The registered agents keyed by id.

返回Returns Map<String, HarnessAgent>
返回映射。Returns map.
源码Source io/agentscope/harness/agent/gateway/GatewayBootstrap.java:119–121

mainAgentId

public String mainAgentId()

主智能体标识。

The main agent id.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/harness/agent/gateway/GatewayBootstrap.java:124–126

gatewayBridge

public SubagentGatewayBridge gatewayBridge()

返回 gatewayBridge 结果。

Returns a SubagentGatewayBridge that exposes subagents as user-addressable threads within this gateway.

返回Returns SubagentGatewayBridge
返回SubagentGatewayBridge。Returns subagent gateway bridge.
源码Source io/agentscope/harness/agent/gateway/GatewayBootstrap.java:134–139

chatUiChannel

public ChatUiChannel chatUiChannel()

返回聊天 Ui 渠道。

Returns a ChatUiChannel with default DmScope.MAIN config, pre-wired to this gateway.

返回Returns ChatUiChannel
返回ChatUiChannel。Returns chat ui channel.
源码Source io/agentscope/harness/agent/gateway/GatewayBootstrap.java:145–147

chatUiChannel

public ChatUiChannel chatUiChannel(ChannelConfig config)

设置聊天 Ui 渠道。

Returns a ChatUiChannel with custom routing config, pre-wired to this gateway.

参数Parameters
名称Name类型Type说明Description
configChannelConfig配置对象(类型 `ChannelConfig`)。The config.
返回Returns ChatUiChannel
返回ChatUiChannel。Returns chat ui channel.
源码Source io/agentscope/harness/agent/gateway/GatewayBootstrap.java:153–155

start

public GatewayBootstrap start()

返回启动。

Initializes and starts all pre-registered channels (injecting the gateway into each).

返回Returns GatewayBootstrap
返回GatewayBootstrap。Returns gateway bootstrap.
源码Source io/agentscope/harness/agent/gateway/GatewayBootstrap.java:161–165

stop

public void stop()

执行停止相关操作。

Stops all channels and releases resources.

源码Source io/agentscope/harness/agent/gateway/GatewayBootstrap.java:168–170

嵌套类详情Nested Class Detail

Builder

public static final class Builder

构建器,用于构建并配置目标实例。位于 io.agentscope.harness.agent.gateway 包。核心成员包括 agent、mainAgent、channel、configureAllAgents、distributedStore、runtimeContextResolver。

A class in io.agentscope.harness.agent.gateway that deploys, schedules and serves agents. Declared in io.agentscope.harness.agent.gateway.

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