AS AgentScopeAPI 手册 / API Reference

ChannelManager

public final class ChannelManager
源码Source io/agentscope/harness/agent/gateway/ChannelManager.java:47–186

渠道管理器,承载智能体的部署、调度与服务化运行。位于 io.agentscope.harness.agent.gateway 包。核心成员包括 register、unregister、getChannel、channelIds、getAllChannels、initAll。

Registry and lifecycle manager for Channel adapters. Provides outbound dispatch so the gateway can deliver proactive messages (e.g. subagent announces) through the correct channel.

Lifecycle

  • #register(Channel) — add a channel to the registry

  • #initAll(Gateway) — inject the gateway into all registered channels

  • #startAll() — start all channels (connect to external transports)

  • #stopAll() — stop all channels and release resources

Outbound delivery

#deliver(OutboundAddress, List) looks up the target channel by OutboundAddress#channelId() and delegates to Channel#deliver(OutboundAddress, List).

构造器摘要Constructor Summary

构造器Constructor说明Description
public ChannelManager()
初始化 `ChannelManager` 实例。
Creates a new instance.

方法摘要Method Summary

方法Method说明Description
public void register(Channel channel)
设置注册。
Registers a channel adapter.
public boolean unregister(String channelId)
设置注销。
Stops and removes the channel registered under `channelId`, if any.
public Optional<Channel> getChannel(String channelId)
获取渠道。
Returns the channel registered under the given id, if any.
public List<String> channelIds()
返回 `channelIds` 结果。
Returns an unmodifiable snapshot of all registered channel ids.
public Collection<Channel> getAllChannels()
获取所有渠道。
Returns an unmodifiable snapshot of all registered channels.
public void initAll(Gateway gateway)
设置初始化所有。
Injects the gateway into all registered channels via `Channel#init(Gateway)`.
public void startAll()
启动所有。
Starts all registered channels.
public void stopAll()
停止所有。
Stops all registered channels and clears the registry.
public boolean isStarted()
判断是否已启动。
Whether `#startAll()` has been called.
public void deliver(OutboundAddress address, List<Msg> messages)
执行 `deliver` 方法。
Delivers proactive outbound messages through the channel identified by `OutboundAddress#channelId()`.

构造器详情Constructor Detail

ChannelManager

public ChannelManager()

初始化 ChannelManager 实例。

Creates a new instance.

源码Source io/agentscope/harness/agent/gateway/ChannelManager.java:54

方法详情Method Detail

register

public void register(Channel channel)

设置注册。

Registers a channel adapter.

参数Parameters
名称Name类型Type说明Description
channelChannel渠道(类型 `Channel`)。The channel.
源码Source io/agentscope/harness/agent/gateway/ChannelManager.java:60–63

unregister

public boolean unregister(String channelId)

设置注销。

Stops and removes the channel registered under channelId, if any.

参数Parameters
名称Name类型Type说明Description
channelIdString渠道标识(类型 `String`)。The channel id.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/harness/agent/gateway/ChannelManager.java:70–89

getChannel

public Optional<Channel> getChannel(String channelId)

获取渠道。

Returns the channel registered under the given id, if any.

参数Parameters
名称Name类型Type说明Description
channelIdString渠道标识(类型 `String`)。The channel id.
返回Returns Optional<Channel>
返回可选。Returns optional.
源码Source io/agentscope/harness/agent/gateway/ChannelManager.java:92–97

channelIds

public List<String> channelIds()

返回 channelIds 结果。

Returns an unmodifiable snapshot of all registered channel ids.

返回Returns List<String>
返回列出。Returns list.
源码Source io/agentscope/harness/agent/gateway/ChannelManager.java:100–102

getAllChannels

public Collection<Channel> getAllChannels()

获取所有渠道。

Returns an unmodifiable snapshot of all registered channels.

返回Returns Collection<Channel>
返回集合。Returns collection.
源码Source io/agentscope/harness/agent/gateway/ChannelManager.java:105–107

initAll

public void initAll(Gateway gateway)

设置初始化所有。

Injects the gateway into all registered channels via Channel#init(Gateway).

参数Parameters
名称Name类型Type说明Description
gatewayGateway网关(类型 `Gateway`)。The gateway.
源码Source io/agentscope/harness/agent/gateway/ChannelManager.java:113–122

startAll

public void startAll()

启动所有。

Starts all registered channels.

源码Source io/agentscope/harness/agent/gateway/ChannelManager.java:125–135

stopAll

public void stopAll()

停止所有。

Stops all registered channels and clears the registry.

源码Source io/agentscope/harness/agent/gateway/ChannelManager.java:138–148

isStarted

public boolean isStarted()

判断是否已启动。

Whether #startAll() has been called.

返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/harness/agent/gateway/ChannelManager.java:151–153

deliver

public void deliver(OutboundAddress address, List<Msg> messages)

执行 deliver 方法。

Delivers proactive outbound messages through the channel identified by OutboundAddress#channelId().

参数Parameters
名称Name类型Type说明Description
addressOutboundAddressaddress(类型 `OutboundAddress`)。the delivery target
messagesList<Msg>消息列表(类型 `List`)。the messages to deliver
源码Source io/agentscope/harness/agent/gateway/ChannelManager.java:163–185
基于官方固定版本源码静态生成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.