INNER CODE UNIT · TypeScript

conversationAdmitsAgent

agentconnect-md/agentconnect · packages/activation-policy/src/index.ts:243

export function conversationAdmitsAgent(rules: readonly ActivationRule[], agentId: string, channel: string): boolean {
  const agentRules = rules.filter((rule) => rule.agentId === agentId)
  if (agentRules.length === 0) return false
  const covers = (scopeChannel: string | undefined): boolean => scopeChannel === undefined || scopeChannel === channel
  if (agentRules.some((rule) => rule.mutedChannels?.some((muted) => covers(muted)))) return false
  return agentRules.some((rule) => covers(rule.scope.channel))
}

/** Is a stamped source depth usable at all? §4.1 rule 1 / §5.2a fail-closed: a
 *  missing, non-integer, or negative depth must never coerce to zero — the
 *  message stays transcript-only instead. */
export function isUsableSourceDepth(value: number | undefined): value is number {
  return value !== undefined && Number.isInteger(value) && value >= 0
}

/**
 * The §4.1 trusted hop transition: ONE +1 per agent-to-agent delivery, against
 * the SAME `MAX_AGENT_CALL_HOPS` cap an internal call spends — so a mention

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…