INNER CODE UNIT · TypeScript
arbitrateSharedBotResult
agentconnect-md/agentconnect · packages/activation-policy/src/index.ts:567
export function arbitrateSharedBotResult(
a: SharedBotAssignmentFacts,
msg: SharedBotMessageFacts,
affinity: ReadonlyMap<string, SharedBotRouteTarget>,
verifiedAgentAuthor?: string
): SharedBotArbitration {
const hit = (target: SharedBotRouteTarget): SharedBotArbitration => ({ kind: 'target', target })
const none: SharedBotArbitration = { kind: 'none' }
// Own echoes never route. A third-party bot may enter only through an explicit
// mention, and only on a platform whose manifest admits bot senders at all
// (§5 botSenderRouting — fail-closed for unknown ids); AgentConnect-managed app
// messages are removed by the manager using the collaboration snapshot before
// forwarding.
if (a.botUserId !== undefined && msg.sender.id === a.botUserId && verifiedAgentAuthor === undefined) return none
const explicitlyMentioned = a.botUserId !== undefined && msg.mentionedBots.includes(a.botUserId)
if (
msg.sender.isBot &&
verifiedAgentAuthor === undefined &&