GatewayBootstrap
public final class GatewayBootstrap
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()
返回新的构建器。
Returns a new builder.
Builderio/agentscope/harness/agent/gateway/GatewayBootstrap.java:104–106gateway
public HarnessGateway gateway()
返回网关。
The underlying gateway (advanced usage).
HarnessGatewayio/agentscope/harness/agent/gateway/GatewayBootstrap.java:109–111channelManager
public ChannelManager channelManager()
返回渠道管理器。
The channel manager (advanced usage).
ChannelManagerio/agentscope/harness/agent/gateway/GatewayBootstrap.java:114–116agents
public Map<String, HarnessAgent> agents()
返回智能体。
The registered agents keyed by id.
Map<String, HarnessAgent>io/agentscope/harness/agent/gateway/GatewayBootstrap.java:119–121mainAgentId
public String mainAgentId()
主智能体标识。
The main agent id.
Stringio/agentscope/harness/agent/gateway/GatewayBootstrap.java:124–126gatewayBridge
public SubagentGatewayBridge gatewayBridge()
返回 gatewayBridge 结果。
Returns a SubagentGatewayBridge that exposes subagents as user-addressable threads within this gateway.
SubagentGatewayBridgeio/agentscope/harness/agent/gateway/GatewayBootstrap.java:134–139chatUiChannel
public ChatUiChannel chatUiChannel()
返回聊天 Ui 渠道。
Returns a ChatUiChannel with default DmScope.MAIN config, pre-wired to this gateway.
ChatUiChannelio/agentscope/harness/agent/gateway/GatewayBootstrap.java:145–147chatUiChannel
public ChatUiChannel chatUiChannel(ChannelConfig config)
设置聊天 Ui 渠道。
Returns a ChatUiChannel with custom routing config, pre-wired to this gateway.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
config | ChannelConfig | 配置对象(类型 `ChannelConfig`)。The config. |
ChatUiChannelio/agentscope/harness/agent/gateway/GatewayBootstrap.java:153–155start
public GatewayBootstrap start()
返回启动。
Initializes and starts all pre-registered channels (injecting the gateway into each).
GatewayBootstrapio/agentscope/harness/agent/gateway/GatewayBootstrap.java:161–165stop
public void stop()
执行停止相关操作。
Stops all channels and releases resources.
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.