ChatUiChannel
public final class ChatUiChannel implements Channel
io/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:64–483聊天 Ui 渠道,承载智能体的部署、调度与服务化运行。位于 io.agentscope.harness.agent.gateway.channel.chatui 包,实现 Channel。核心成员包括 create、perPeer、init、start、stop、channelId。
Default Channel implementation for direct Chat UI interactions: no external transport,
no webhook, no websocket — the caller submits a ChatUiRequest programmatically and
receives the agent reply reactively.
Suitable for:
-
Embedded web chat UIs that send HTTP requests to the harness
-
CLI tools and integration tests that need a typed API to the agent
-
Single-agent single-session scenarios where the default
DmScope#MAINcollapses all conversations into one session
Obtaining an instance
The recommended way is through io.agentscope.harness.agent.gateway.GatewayBootstrap#chatUiChannel():
`GatewayBootstrap gw = GatewayBootstrap.builder().model(model)
.agent("main", b -> b.name("assistant").sysPrompt("..."))
.build();
ChatUiChannel chat = gw.chatUiChannel();
chat.send("Hello!").block();
`
字段摘要Field Summary
| 字段Field | 类型Type | 说明Description |
|---|---|---|
CHANNEL_IDstaticfinal | String | 渠道标识字段。 The CHANNEL ID field. |
方法摘要Method Summary
字段详情Field Detail
CHANNEL_ID
public static final String CHANNEL_ID
渠道标识字段。声明为 public static final String CHANNEL_ID。
The CHANNEL ID field.
io/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:66方法详情Method Detail
create
public static ChatUiChannel create()
创建聊天 UI 渠道使用默认DmScope#MAIN配置。
Creates a Chat UI channel with the default DmScope#MAIN config.
ChatUiChannelio/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:85–87create
public static ChatUiChannel create(ChannelConfig config)
创建并返回实例。
Creates a Chat UI channel with an explicit config.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
config | ChannelConfig | 配置对象(类型 `ChannelConfig`)。The config. |
ChatUiChannelio/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:90–92perPeer
public static ChatUiChannel perPeer()
返回每个对端。
Creates a per-peer Chat UI channel.
ChatUiChannelio/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:95–98create
public static ChatUiChannel create(Gateway gateway)
创建并返回实例。
Creates a Chat UI channel with a pre-wired gateway.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
gateway | Gateway | 网关(类型 `Gateway`)。The gateway. |
ChatUiChannelio/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:101–104create
public static ChatUiChannel create(Gateway gateway, ChannelConfig config)
创建并返回实例。
Creates a Chat UI channel with a pre-wired gateway and explicit config.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
gateway | Gateway | 网关(类型 `Gateway`)。The gateway. |
config | ChannelConfig | 配置对象(类型 `ChannelConfig`)。The config. |
ChatUiChannelio/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:107–109init
public void init(Gateway gateway)
初始化 ChatUiChannel 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
gateway | Gateway | 网关(类型 `Gateway`)。The gateway. |
io/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:115–120start
public void start()
执行启动相关操作。
Returns the start.
io/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:122–123stop
public void stop()
执行停止相关操作。
Returns the stop.
io/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:125–126channelId
public String channelId()
返回渠道标识。
Returns the channel id.
Stringio/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:128–131config
public ChannelConfig config()
返回配置。
Returns the config.
ChannelConfigio/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:133–136applyRoutingConfig
public boolean applyRoutingConfig(ChannelConfig newConfig)
应用路由配置。
Performs the apply routing config operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
newConfig | ChannelConfig | 新建配置(类型 `ChannelConfig`)。The new config. |
booleanio/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:138–146dispatch
public Mono<Msg> dispatch(InboundMessage message)
设置该参数。
Performs the dispatch operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
message | InboundMessage | 消息(类型 `InboundMessage`)。The message. |
Mono<Msg>io/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:148–159previewRoute
public RouteResult previewRoute(InboundMessage message)
设置预览路由。
Returns the RouteResult this channel would produce for message without dispatching it.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
message | InboundMessage | 消息(类型 `InboundMessage`)。The message. |
RouteResultio/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:165–168deliver
public void deliver(OutboundAddress address, List<Msg> messages)
执行 deliver 方法。
Performs the deliver operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
address | OutboundAddress | address(类型 `OutboundAddress`)。The address. |
messages | List<Msg> | 消息列表(类型 `List`)。The messages. |
io/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:170–175pollOutbound
public List<OutboundEnvelope> pollOutbound()
返回 pollOutbound 结果。
Drains and returns all buffered proactive outbound messages.
List<OutboundEnvelope>io/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:181–188outboundQueueSize
public int outboundQueueSize()
返回出站队列大小。
Returns the number of buffered proactive outbound messages.
intio/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:191–193send
public Mono<Msg> send(String text)
设置发送。
Sends a plain-text message in single-session mode (no peer id).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
text | String | 文本(类型 `String`)。The text. |
Mono<Msg>io/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:200–202send
public Mono<Msg> send(Msg message)
设置发送。
Sends a pre-built Msg (text or multimodal) in single-session mode.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
message | Msg | 消息(类型 `Msg`)。The message. |
Mono<Msg>io/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:219–222send
public Mono<Msg> send(List<Msg> messages)
设置发送。
Sends one or more pre-built Msgs in single-session mode.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
messages | List<Msg> | 消息列表(类型 `List`)。The messages. |
Mono<Msg>io/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:228–230send
public Mono<Msg> send(String peerId, String text)
执行发送相关操作。
Sends a plain-text message from a specific peer.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
peerId | String | 对端标识(类型 `String`)。The peer id. |
text | String | 文本(类型 `String`)。The text. |
Mono<Msg>io/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:233–237send
public Mono<Msg> send(String peerId, Msg message)
执行发送相关操作。
Sends a pre-built Msg from a specific peer.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
peerId | String | 对端标识(类型 `String`)。The peer id. |
message | Msg | 消息(类型 `Msg`)。The message. |
Mono<Msg>io/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:240–244send
public Mono<Msg> send(String peerId, List<Msg> messages)
执行发送相关操作。
Sends one or more pre-built Msgs from a specific peer.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
peerId | String | 对端标识(类型 `String`)。The peer id. |
messages | List<Msg> | 消息列表(类型 `List`)。The messages. |
Mono<Msg>io/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:247–250send
public Mono<Msg> send(SendOptions options, String text)
执行发送相关操作。
Sends a plain-text message with explicit routing identity.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
options | SendOptions | 选项(类型 `SendOptions`)。The options. |
text | String | 文本(类型 `String`)。The text. |
Mono<Msg>io/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:259–264send
public Mono<Msg> send(SendOptions options, Msg message)
执行发送相关操作。
Sends a pre-built Msg with explicit routing identity.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
options | SendOptions | 选项(类型 `SendOptions`)。The options. |
message | Msg | 消息(类型 `Msg`)。The message. |
Mono<Msg>io/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:271–275send
public Mono<Msg> send(SendOptions options, List<Msg> messages)
执行发送相关操作。
Sends one or more pre-built Msgs with explicit routing identity.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
options | SendOptions | 选项(类型 `SendOptions`)。The options. |
messages | List<Msg> | 消息列表(类型 `List`)。The messages. |
Mono<Msg>io/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:281–284sendToSubagent
public Mono<Msg> sendToSubagent(String subagentId, String text)
发送到子智能体。
Sends a message directly to an exposed subagent, bypassing normal routing.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
subagentId | String | 子智能体标识(类型 `String`)。The subagent id. |
text | String | 文本(类型 `String`)。The text. |
Mono<Msg>io/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:287–292sendToSubagent
public Mono<Msg> sendToSubagent(String subagentId, Msg message)
发送到子智能体。
Sends a pre-built Msg directly to an exposed subagent.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
subagentId | String | 子智能体标识(类型 `String`)。The subagent id. |
message | Msg | 消息(类型 `Msg`)。The message. |
Mono<Msg>io/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:295–299sendToSubagent
public Mono<Msg> sendToSubagent(String subagentId, List<Msg> messages)
发送到子智能体。
Sends one or more pre-built Msgs directly to an exposed subagent.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
subagentId | String | 子智能体标识(类型 `String`)。The subagent id. |
messages | List<Msg> | 消息列表(类型 `List`)。The messages. |
Mono<Msg>io/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:302–305send
public Mono<Msg> send(ChatUiRequest request)
设置发送。
Sends a structured ChatUiRequest and returns the agent reply reactively.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
request | ChatUiRequest | 请求(类型 `ChatUiRequest`)。The request. |
Mono<Msg>io/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:308–314dispatchStream
public Flux<AgentEvent> dispatchStream(InboundMessage message)
设置该参数。
Performs the dispatch stream operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
message | InboundMessage | 消息(类型 `InboundMessage`)。The message. |
Flux<AgentEvent>io/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:320–331sendStream
public Flux<AgentEvent> sendStream(String text)
发送流。
Streaming variant of #send(String).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
text | String | 文本(类型 `String`)。The text. |
Flux<AgentEvent>io/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:334–336sendStream
public Flux<AgentEvent> sendStream(Msg message)
发送流。
Streaming variant of #send(Msg).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
message | Msg | 消息(类型 `Msg`)。The message. |
Flux<AgentEvent>io/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:339–342sendStream
public Flux<AgentEvent> sendStream(List<Msg> messages)
发送流。
Streaming variant of #send(List).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
messages | List<Msg> | 消息列表(类型 `List`)。The messages. |
Flux<AgentEvent>io/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:345–347sendStream
public Flux<AgentEvent> sendStream(String peerId, String text)
发送流。
Streaming variant of #send(String, String).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
peerId | String | 对端标识(类型 `String`)。The peer id. |
text | String | 文本(类型 `String`)。The text. |
Flux<AgentEvent>io/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:350–354sendStream
public Flux<AgentEvent> sendStream(String peerId, Msg message)
发送流。
Streaming variant of #send(String, Msg).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
peerId | String | 对端标识(类型 `String`)。The peer id. |
message | Msg | 消息(类型 `Msg`)。The message. |
Flux<AgentEvent>io/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:357–361sendStream
public Flux<AgentEvent> sendStream(String peerId, List<Msg> messages)
发送流。
Streaming variant of #send(String, List).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
peerId | String | 对端标识(类型 `String`)。The peer id. |
messages | List<Msg> | 消息列表(类型 `List`)。The messages. |
Flux<AgentEvent>io/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:364–367sendStream
public Flux<AgentEvent> sendStream(SendOptions options, String text)
发送流。
Streaming variant of #send(SendOptions, String).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
options | SendOptions | 选项(类型 `SendOptions`)。The options. |
text | String | 文本(类型 `String`)。The text. |
Flux<AgentEvent>io/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:370–375sendStream
public Flux<AgentEvent> sendStream(SendOptions options, Msg message)
发送流。
Streaming variant of #send(SendOptions, Msg).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
options | SendOptions | 选项(类型 `SendOptions`)。The options. |
message | Msg | 消息(类型 `Msg`)。The message. |
Flux<AgentEvent>io/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:378–382sendStream
public Flux<AgentEvent> sendStream(SendOptions options, List<Msg> messages)
发送流。
Streaming variant of #send(SendOptions, List).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
options | SendOptions | 选项(类型 `SendOptions`)。The options. |
messages | List<Msg> | 消息列表(类型 `List`)。The messages. |
Flux<AgentEvent>io/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:385–388sendToSubagentStream
public Flux<AgentEvent> sendToSubagentStream(String subagentId, String text)
发送到子智能体流。
Streaming variant of #sendToSubagent(String, String).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
subagentId | String | 子智能体标识(类型 `String`)。The subagent id. |
text | String | 文本(类型 `String`)。The text. |
Flux<AgentEvent>io/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:391–396sendToSubagentStream
public Flux<AgentEvent> sendToSubagentStream(String subagentId, Msg message)
发送到子智能体流。
Streaming variant of #sendToSubagent(String, Msg).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
subagentId | String | 子智能体标识(类型 `String`)。The subagent id. |
message | Msg | 消息(类型 `Msg`)。The message. |
Flux<AgentEvent>io/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:399–403sendToSubagentStream
public Flux<AgentEvent> sendToSubagentStream(String subagentId, List<Msg> messages)
发送到子智能体流。
Streaming variant of #sendToSubagent(String, List).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
subagentId | String | 子智能体标识(类型 `String`)。The subagent id. |
messages | List<Msg> | 消息列表(类型 `List`)。The messages. |
Flux<AgentEvent>io/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:406–409sendStream
public Flux<AgentEvent> sendStream(ChatUiRequest request)
发送流。
Streaming variant of #send(ChatUiRequest).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
request | ChatUiRequest | 请求(类型 `ChatUiRequest`)。The request. |
Flux<AgentEvent>io/agentscope/harness/agent/gateway/channel/chatui/ChatUiChannel.java:412–418