AS AgentScopeAPI 手册 / API Reference

ChannelBinding

public record ChannelBinding( String agentId, String peer, String parentPeer, String guild, Set<String> roles, String team, String account, String channel, DmScope sessionScope)
源码Source io/agentscope/harness/agent/gateway/channel/ChannelBinding.java:57–114

承载渠道绑定数据的记录类型。位于 io.agentscope.harness.agent.gateway.channel 包。核心成员包括 agentId、peer、parentPeer、guild、roles、team。

One routing rule that maps a set of inbound-message conditions to a target agentId.

A binding is evaluated by ChannelRouter at the tier corresponding to the most specific non-null condition field it carries (priority order):

  • #peer — exact peer-key match ("direct:u_123" or "channel:c_help")

  • #parentPeer — parent-peer key match (thread-parent inheritance)

  • #guild + #roles — guild membership AND at least one role matches

  • #guild alone — guild membership (no role constraint)

  • #team — team id match

  • #account — account id match

  • #channel — channel id match

Within a tier, the first binding in ChannelConfig#bindings() list order that matches wins. Only one condition tier is active per binding: the most specific non-null field determines the tier.

The optional #sessionScope field provides a per-binding session override: when non-null it takes precedence over the channel-level ChannelConfig#dmScope() for DM session key construction.

记录组件摘要Record Component Summary

组件Component类型Type说明Description
agentIdString
执行智能体标识相关操作。
the target agent id when this binding matches (required)
peerString
执行对端相关操作。
exact peer key to match (e.g. `"direct:u_42"`); highest priority
parentPeerString
执行父级对端相关操作。
parent-peer key for thread-parent inheritance (e.g. `"channel:c_ops"`)
guildString
执行 `guild` 方法。
guild/server/workspace id to match
rolesSet<String>
执行 `roles` 方法。
role ids to match within the guild (evaluated alongside `guild`); if non-empty the binding is a guild+roles tier binding; if empty it is a guild-only tier binding
teamString
执行团队相关操作。
team id to match
accountString
执行 `account` 方法。
account id to match
channelString
执行渠道相关操作。
channel id to match (lower priority; rarely needed inside channel-specific config)
sessionScopeDmScope
执行会话范围相关操作。
optional per-binding DM session scope override; null means inherit from `ChannelConfig#dmScope()`

构造器摘要Constructor Summary

构造器Constructor说明Description
public ChannelBinding(String agentId, String peer, String parentPeer, String guild, Set<String> roles, String team, String account, String channel, DmScope sessionScope)
初始化 `ChannelBinding` 实例。
Creates a new instance.

方法摘要Method Summary

方法Method说明Description
public static ChannelBinding forPeer(String peer, String agentId)
static
执行用于对端相关操作。
Matches an exact peer (e.g.
public static ChannelBinding forParentPeer(String parentPeer, String agentId)
static
执行用于父级对端相关操作。
Matches messages that are threads under a specific parent peer.
public static ChannelBinding forGuild(String guild, String agentId)
static
执行 `forGuild` 方法。
Matches any message from a specific guild (server/workspace).
public static ChannelBinding forGuildRoles(String guild, Set<String> roles, String agentId)
static
执行 `forGuildRoles` 方法。
Matches messages from a guild where the sender holds at least one of the given roles.
public static ChannelBinding forTeam(String team, String agentId)
static
执行用于团队相关操作。
Matches a specific team id.
public static ChannelBinding forAccount(String account, String agentId)
static
执行 `forAccount` 方法。
Matches a specific account id.
public static ChannelBinding forChannel(String channel, String agentId)
static
执行用于渠道相关操作。
Matches a specific channel id.
public ChannelBinding withSessionScope(DmScope scope)
执行使用会话范围相关操作。
Returns a copy of this binding with a per-binding session scope override.

记录组件详情Record Component Detail

agentId

String agentId

执行智能体标识相关操作。

the target agent id when this binding matches (required)

源码Source io/agentscope/harness/agent/gateway/channel/ChannelBinding.java:57–114

peer

String peer

执行对端相关操作。

exact peer key to match (e.g. "direct:u_42"); highest priority

源码Source io/agentscope/harness/agent/gateway/channel/ChannelBinding.java:57–114

parentPeer

String parentPeer

执行父级对端相关操作。

parent-peer key for thread-parent inheritance (e.g. "channel:c_ops")

源码Source io/agentscope/harness/agent/gateway/channel/ChannelBinding.java:57–114

guild

String guild

执行 guild 方法。

guild/server/workspace id to match

源码Source io/agentscope/harness/agent/gateway/channel/ChannelBinding.java:57–114

roles

Set<String> roles

执行 roles 方法。

role ids to match within the guild (evaluated alongside guild); if non-empty the binding is a guild+roles tier binding; if empty it is a guild-only tier binding

源码Source io/agentscope/harness/agent/gateway/channel/ChannelBinding.java:57–114

team

String team

执行团队相关操作。

team id to match

源码Source io/agentscope/harness/agent/gateway/channel/ChannelBinding.java:57–114

account

String account

执行 account 方法。

account id to match

源码Source io/agentscope/harness/agent/gateway/channel/ChannelBinding.java:57–114

channel

String channel

执行渠道相关操作。

channel id to match (lower priority; rarely needed inside channel-specific config)

源码Source io/agentscope/harness/agent/gateway/channel/ChannelBinding.java:57–114

sessionScope

DmScope sessionScope

执行会话范围相关操作。

optional per-binding DM session scope override; null means inherit from ChannelConfig#dmScope()

源码Source io/agentscope/harness/agent/gateway/channel/ChannelBinding.java:57–114

构造器详情Constructor Detail

ChannelBinding

public ChannelBinding(String agentId, String peer, String parentPeer, String guild, Set<String> roles, String team, String account, String channel, DmScope sessionScope)

初始化 ChannelBinding 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
agentIdString智能体标识(类型 `String`)。The agent id.
peerString对端(类型 `String`)。The peer.
parentPeerString父级对端(类型 `String`)。The parent peer.
guildStringguild(类型 `String`)。The guild.
rolesSet<String>roles(类型 `Set`)。The roles.
teamString团队(类型 `String`)。The team.
accountStringaccount(类型 `String`)。The account.
channelString渠道(类型 `String`)。The channel.
sessionScopeDmScope会话范围(类型 `DmScope`)。The session scope.
源码Source io/agentscope/harness/agent/gateway/channel/ChannelBinding.java:68–71

方法详情Method Detail

forPeer

public static ChannelBinding forPeer(String peer, String agentId)
static

执行用于对端相关操作。

Matches an exact peer (e.g.

参数Parameters
名称Name类型Type说明Description
peerString对端(类型 `String`)。The peer.
agentIdString智能体标识(类型 `String`)。The agent id.
返回Returns ChannelBinding
返回ChannelBinding。Returns channel binding.
源码Source io/agentscope/harness/agent/gateway/channel/ChannelBinding.java:74–76

forParentPeer

public static ChannelBinding forParentPeer(String parentPeer, String agentId)
static

执行用于父级对端相关操作。

Matches messages that are threads under a specific parent peer.

参数Parameters
名称Name类型Type说明Description
parentPeerString父级对端(类型 `String`)。The parent peer.
agentIdString智能体标识(类型 `String`)。The agent id.
返回Returns ChannelBinding
返回ChannelBinding。Returns channel binding.
源码Source io/agentscope/harness/agent/gateway/channel/ChannelBinding.java:79–82

forGuild

public static ChannelBinding forGuild(String guild, String agentId)
static

执行 forGuild 方法。

Matches any message from a specific guild (server/workspace).

参数Parameters
名称Name类型Type说明Description
guildStringguild(类型 `String`)。The guild.
agentIdString智能体标识(类型 `String`)。The agent id.
返回Returns ChannelBinding
返回ChannelBinding。Returns channel binding.
源码Source io/agentscope/harness/agent/gateway/channel/ChannelBinding.java:85–87

forGuildRoles

public static ChannelBinding forGuildRoles(String guild, Set<String> roles, String agentId)
static

执行 forGuildRoles 方法。

Matches messages from a guild where the sender holds at least one of the given roles.

参数Parameters
名称Name类型Type说明Description
guildStringguild(类型 `String`)。The guild.
rolesSet<String>roles(类型 `Set`)。The roles.
agentIdString智能体标识(类型 `String`)。The agent id.
返回Returns ChannelBinding
返回ChannelBinding。Returns channel binding.
源码Source io/agentscope/harness/agent/gateway/channel/ChannelBinding.java:90–92

forTeam

public static ChannelBinding forTeam(String team, String agentId)
static

执行用于团队相关操作。

Matches a specific team id.

参数Parameters
名称Name类型Type说明Description
teamString团队(类型 `String`)。The team.
agentIdString智能体标识(类型 `String`)。The agent id.
返回Returns ChannelBinding
返回ChannelBinding。Returns channel binding.
源码Source io/agentscope/harness/agent/gateway/channel/ChannelBinding.java:95–97

forAccount

public static ChannelBinding forAccount(String account, String agentId)
static

执行 forAccount 方法。

Matches a specific account id.

参数Parameters
名称Name类型Type说明Description
accountStringaccount(类型 `String`)。The account.
agentIdString智能体标识(类型 `String`)。The agent id.
返回Returns ChannelBinding
返回ChannelBinding。Returns channel binding.
源码Source io/agentscope/harness/agent/gateway/channel/ChannelBinding.java:100–102

forChannel

public static ChannelBinding forChannel(String channel, String agentId)
static

执行用于渠道相关操作。

Matches a specific channel id.

参数Parameters
名称Name类型Type说明Description
channelString渠道(类型 `String`)。The channel.
agentIdString智能体标识(类型 `String`)。The agent id.
返回Returns ChannelBinding
返回ChannelBinding。Returns channel binding.
源码Source io/agentscope/harness/agent/gateway/channel/ChannelBinding.java:105–107

withSessionScope

public ChannelBinding withSessionScope(DmScope scope)

执行使用会话范围相关操作。

Returns a copy of this binding with a per-binding session scope override.

参数Parameters
名称Name类型Type说明Description
scopeDmScope范围(类型 `DmScope`)。The scope.
返回Returns ChannelBinding
返回ChannelBinding。Returns channel binding.
源码Source io/agentscope/harness/agent/gateway/channel/ChannelBinding.java:110–113
基于官方固定版本源码静态生成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.