AS AgentScopeAPI 手册 / API Reference

InboundMessage

public record InboundMessage( String channelId, String accountId, Peer peer, String senderId, Peer parentPeer, String guild, String team, Set<String> roles, List<Msg> messages, String preferredAgentId, RuntimeContext runtimeContext)
源码Source io/agentscope/harness/agent/gateway/channel/InboundMessage.java:63–270

承载入站消息数据的记录类型。位于 io.agentscope.harness.agent.gateway.channel 包。核心成员包括 channelId、accountId、peer、senderId、parentPeer、guild。

Normalized inbound message produced by a Channel adapter before routing. Carries all identity and context metadata needed by ChannelRouter to resolve an agent and build a stable session key.

Two identity fields are deliberately separate:

  • #peer — the conversation identifier used to construct the session key (DM user id, group chat id, channel id)

  • #senderId — the message sender's identity, used as userId for HarnessAgent namespace isolation. In DM scenarios these are equal; in group/channel scenarios peer.id is the group and senderId is the individual author.

#runtimeContext() is not used for routing and does not participate in session key computation. It is forwarded to the Gateway as the caller merge base for the agent turn.

记录组件摘要Record Component Summary

组件Component类型Type说明Description
channelIdString
执行渠道标识相关操作。
identifier of the originating channel (e.g. `"chatui"`, `"slack"`)
accountIdString
执行 `accountId` 方法。
optional multi-account identifier (e.g. Slack app installation id); null for single-account channels
peerPeer
执行对端相关操作。
the conversation peer (DM partner, channel, group, or thread) — used for session key
senderIdString
执行 `senderId` 方法。
optional sender identity for user-level isolation; if null, `#peer`'s id is used as fallback in DM contexts
parentPeerPeer
执行父级对端相关操作。
optional parent peer for thread-nested messages; used for `binding.peer.parent` inheritance
guildString
执行 `guild` 方法。
optional guild / server / workspace id (Discord guild, Slack workspace)
teamString
执行团队相关操作。
optional team id (Slack team, MS Teams team)
rolesSet<String>
执行 `roles` 方法。
optional set of role ids the sender holds within the guild; used for `binding.guild+roles` tier evaluation
messagesList<Msg>
执行消息相关操作。
the actual message content to forward to the agent
preferredAgentIdString
执行 `preferredAgentId` 方法。
optional explicit agent override evaluated by `ChannelRouter` as a tier-0 short-circuit before any binding tier. Set this when the caller already knows which agent should handle the request (e.g. a path-mapped Web UI where the user clicked an agent card); the router still builds session and outbound context normally so bindings continue to control `sessionScope` and outbound addressing. `null` for normal binding-driven routing.
runtimeContextRuntimeContext
执行运行时上下文相关操作。
optional caller-supplied `RuntimeContext` merged into the agent turn; `null` when none. Not part of routing / session identity.

嵌套类摘要Nested Class Summary

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

构造器摘要Constructor Summary

构造器Constructor说明Description
public InboundMessage(String channelId, String accountId, Peer peer, String senderId, Peer parentPeer, String guild, String team, Set<String> roles, List<Msg> messages, String preferredAgentId, RuntimeContext runtimeContext)
初始化 `InboundMessage` 实例。
Creates a new instance.

方法摘要Method Summary

方法Method说明Description
public static InboundMessage dm(String channelId, String peerId, List<Msg> messages)
static
执行 `dm` 方法。
Single-turn DM with no guild/team/role metadata (typical for direct chat UI use).
public static InboundMessage dmFor(String channelId, String peerId, String agentId, List<Msg> messages)
static
执行dm 用于相关操作。
Single-turn DM with an explicit `#preferredAgentId()` override — the router will use the supplied `agentId` as a tier-0 short-circuit instead of evaluating bindings.
public static InboundMessage channel(String channelId, String roomId, String senderId, String guild, List<Msg> messages)
static
执行渠道相关操作。
Channel / group message with optional guild context.
public static InboundMessage channel(String channelId, String roomId, String guild, List<Msg> messages)
static
执行渠道相关操作。
Channel message with optional guild context (no explicit senderId — sender identity unknown, falls back to room peer for isolation).
public boolean isDm()
判断是否Dm。
Whether this message originates from a direct / DM peer.
public boolean isThread()
判断是否会话线程。
Whether this message is a thread-nested reply.
public InboundMessage withRuntimeContext(RuntimeContext runtimeContext)
执行使用运行时上下文相关操作。
Returns a copy carrying the given `RuntimeContext`.
public static Builder builder(String channelId, Peer peer, List<Msg> messages)
static
返回构建器实例。
Returns a builder for constructing messages with all optional fields.

记录组件详情Record Component Detail

channelId

String channelId

执行渠道标识相关操作。

identifier of the originating channel (e.g. "chatui", "slack")

源码Source io/agentscope/harness/agent/gateway/channel/InboundMessage.java:63–270

accountId

String accountId

执行 accountId 方法。

optional multi-account identifier (e.g. Slack app installation id); null for single-account channels

源码Source io/agentscope/harness/agent/gateway/channel/InboundMessage.java:63–270

peer

Peer peer

执行对端相关操作。

the conversation peer (DM partner, channel, group, or thread) — used for session key

源码Source io/agentscope/harness/agent/gateway/channel/InboundMessage.java:63–270

senderId

String senderId

执行 senderId 方法。

optional sender identity for user-level isolation; if null, #peer's id is used as fallback in DM contexts

源码Source io/agentscope/harness/agent/gateway/channel/InboundMessage.java:63–270

parentPeer

Peer parentPeer

执行父级对端相关操作。

optional parent peer for thread-nested messages; used for binding.peer.parent inheritance

源码Source io/agentscope/harness/agent/gateway/channel/InboundMessage.java:63–270

guild

String guild

执行 guild 方法。

optional guild / server / workspace id (Discord guild, Slack workspace)

源码Source io/agentscope/harness/agent/gateway/channel/InboundMessage.java:63–270

team

String team

执行团队相关操作。

optional team id (Slack team, MS Teams team)

源码Source io/agentscope/harness/agent/gateway/channel/InboundMessage.java:63–270

roles

Set<String> roles

执行 roles 方法。

optional set of role ids the sender holds within the guild; used for binding.guild+roles tier evaluation

源码Source io/agentscope/harness/agent/gateway/channel/InboundMessage.java:63–270

messages

List<Msg> messages

执行消息相关操作。

the actual message content to forward to the agent

源码Source io/agentscope/harness/agent/gateway/channel/InboundMessage.java:63–270

preferredAgentId

String preferredAgentId

执行 preferredAgentId 方法。

optional explicit agent override evaluated by ChannelRouter as a tier-0 short-circuit before any binding tier. Set this when the caller already knows which agent should handle the request (e.g. a path-mapped Web UI where the user clicked an agent card); the router still builds session and outbound context normally so bindings continue to control sessionScope and outbound addressing. null for normal binding-driven routing.

源码Source io/agentscope/harness/agent/gateway/channel/InboundMessage.java:63–270

runtimeContext

RuntimeContext runtimeContext

执行运行时上下文相关操作。

optional caller-supplied RuntimeContext merged into the agent turn; null when none. Not part of routing / session identity.

源码Source io/agentscope/harness/agent/gateway/channel/InboundMessage.java:63–270

构造器详情Constructor Detail

InboundMessage

public InboundMessage(String channelId, String accountId, Peer peer, String senderId, Peer parentPeer, String guild, String team, Set<String> roles, List<Msg> messages, String preferredAgentId, RuntimeContext runtimeContext)

初始化 InboundMessage 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
channelIdString渠道标识(类型 `String`)。The channel id.
accountIdStringaccount 标识(类型 `String`)。The account id.
peerPeer对端(类型 `Peer`)。The peer.
senderIdStringsender 标识(类型 `String`)。The sender id.
parentPeerPeer父级对端(类型 `Peer`)。The parent peer.
guildStringguild(类型 `String`)。The guild.
teamString团队(类型 `String`)。The team.
rolesSet<String>roles(类型 `Set`)。The roles.
messagesList<Msg>消息列表(类型 `List`)。The messages.
preferredAgentIdStringpreferred 智能体标识(类型 `String`)。The preferred agent id.
runtimeContextRuntimeContext运行时上下文(类型 `RuntimeContext`)。The runtime context.
源码Source io/agentscope/harness/agent/gateway/channel/InboundMessage.java:76–81

方法详情Method Detail

dm

public static InboundMessage dm(String channelId, String peerId, List<Msg> messages)
static

执行 dm 方法。

Single-turn DM with no guild/team/role metadata (typical for direct chat UI use).

参数Parameters
名称Name类型Type说明Description
channelIdString渠道标识(类型 `String`)。The channel id.
peerIdString对端标识(类型 `String`)。The peer id.
messagesList<Msg>消息列表(类型 `List`)。The messages.
返回Returns InboundMessage
返回InboundMessage。Returns inbound message.
源码Source io/agentscope/harness/agent/gateway/channel/InboundMessage.java:89–102

dmFor

public static InboundMessage dmFor(String channelId, String peerId, String agentId, List<Msg> messages)
static

执行dm 用于相关操作。

Single-turn DM with an explicit #preferredAgentId() override — the router will use the supplied agentId as a tier-0 short-circuit instead of evaluating bindings.

参数Parameters
名称Name类型Type说明Description
channelIdString渠道标识(类型 `String`)。The channel id.
peerIdString对端标识(类型 `String`)。The peer id.
agentIdString智能体标识(类型 `String`)。The agent id.
messagesList<Msg>消息列表(类型 `List`)。The messages.
返回Returns InboundMessage
返回InboundMessage。Returns inbound message.
源码Source io/agentscope/harness/agent/gateway/channel/InboundMessage.java:108–123

channel

public static InboundMessage channel(String channelId, String roomId, String senderId, String guild, List<Msg> messages)
static

执行渠道相关操作。

Channel / group message with optional guild context.

参数Parameters
名称Name类型Type说明Description
channelIdString渠道标识(类型 `String`)。The channel id.
roomIdStringroom 标识(类型 `String`)。The room id.
senderIdStringsender 标识(类型 `String`)。The sender id.
guildStringguild(类型 `String`)。The guild.
messagesList<Msg>消息列表(类型 `List`)。The messages.
返回Returns InboundMessage
返回InboundMessage。Returns inbound message.
源码Source io/agentscope/harness/agent/gateway/channel/InboundMessage.java:129–143

channel

public static InboundMessage channel(String channelId, String roomId, String guild, List<Msg> messages)
static

执行渠道相关操作。

Channel message with optional guild context (no explicit senderId — sender identity unknown, falls back to room peer for isolation).

参数Parameters
名称Name类型Type说明Description
channelIdString渠道标识(类型 `String`)。The channel id.
roomIdStringroom 标识(类型 `String`)。The room id.
guildStringguild(类型 `String`)。The guild.
messagesList<Msg>消息列表(类型 `List`)。The messages.
返回Returns InboundMessage
返回InboundMessage。Returns inbound message.
源码Source io/agentscope/harness/agent/gateway/channel/InboundMessage.java:149–163

isDm

public boolean isDm()

判断是否Dm。

Whether this message originates from a direct / DM peer.

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

isThread

public boolean isThread()

判断是否会话线程。

Whether this message is a thread-nested reply.

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

withRuntimeContext

public InboundMessage withRuntimeContext(RuntimeContext runtimeContext)

执行使用运行时上下文相关操作。

Returns a copy carrying the given RuntimeContext.

参数Parameters
名称Name类型Type说明Description
runtimeContextRuntimeContext运行时上下文(类型 `RuntimeContext`)。The runtime context.
返回Returns InboundMessage
返回InboundMessage。Returns inbound message.
源码Source io/agentscope/harness/agent/gateway/channel/InboundMessage.java:176–189

builder

public static Builder builder(String channelId, Peer peer, List<Msg> messages)
static

返回构建器实例。

Returns a builder for constructing messages with all optional fields.

参数Parameters
名称Name类型Type说明Description
channelIdString渠道标识(类型 `String`)。The channel id.
peerPeer对端(类型 `Peer`)。The peer.
messagesList<Msg>消息列表(类型 `List`)。The messages.
返回Returns Builder
返回当前实例,以支持链式调用。Returns the current instance for chaining.
源码Source io/agentscope/harness/agent/gateway/channel/InboundMessage.java:192–194

嵌套类详情Nested Class Detail

Builder

public static final class Builder

构建器,用于构建并配置目标实例。位于 io.agentscope.harness.agent.gateway.channel 包。核心成员包括 accountId、senderId、parentPeer、guild、team、roles。

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

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