Record Class ChannelBinding

java.lang.Object
java.lang.Record
io.agentscope.harness.agent.gateway.channel.ChannelBinding
Record Components:
agentId - the target agent id when this binding matches (required)
peer - exact peer key to match (e.g. "direct:u_42"); highest priority
parentPeer - parent-peer key for thread-parent inheritance (e.g. "channel:c_ops")
guild - guild/server/workspace id to match
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
team - team id to match
account - account id to match
channel - channel id to match (lower priority; rarely needed inside channel-specific config)
sessionScope - optional per-binding DM session scope override; null means inherit from ChannelConfig.dmScope()

public record ChannelBinding(String agentId, String peer, String parentPeer, String guild, Set<String> roles, String team, String account, String channel, DmScope sessionScope) extends Record
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):

  1. peer — exact peer-key match ("direct:u_123" or "channel:c_help")
  2. parentPeer — parent-peer key match (thread-parent inheritance)
  3. guild + roles — guild membership AND at least one role matches
  4. guild alone — guild membership (no role constraint)
  5. team — team id match
  6. account — account id match
  7. 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.

  • Constructor Details

    • ChannelBinding

      public ChannelBinding(String agentId, String peer, String parentPeer, String guild, Set<String> roles, String team, String account, String channel, DmScope sessionScope)
      Creates an instance of a ChannelBinding record class.
      Parameters:
      agentId - the value for the agentId record component
      peer - the value for the peer record component
      parentPeer - the value for the parentPeer record component
      guild - the value for the guild record component
      roles - the value for the roles record component
      team - the value for the team record component
      account - the value for the account record component
      channel - the value for the channel record component
      sessionScope - the value for the sessionScope record component
  • Method Details

    • forPeer

      public static ChannelBinding forPeer(String peer, String agentId)
      Matches an exact peer (e.g. a specific DM user or channel id).
    • forParentPeer

      public static ChannelBinding forParentPeer(String parentPeer, String agentId)
      Matches messages that are threads under a specific parent peer.
    • forGuild

      public static ChannelBinding forGuild(String guild, String agentId)
      Matches any message from a specific guild (server/workspace).
    • forGuildRoles

      public static ChannelBinding forGuildRoles(String guild, Set<String> roles, String agentId)
      Matches messages from a guild where the sender holds at least one of the given roles.
    • forTeam

      public static ChannelBinding forTeam(String team, String agentId)
      Matches a specific team id.
    • forAccount

      public static ChannelBinding forAccount(String account, String agentId)
      Matches a specific account id.
    • forChannel

      public static ChannelBinding forChannel(String channel, String agentId)
      Matches a specific channel id.
    • withSessionScope

      public ChannelBinding withSessionScope(DmScope scope)
      Returns a copy of this binding with a per-binding session scope override.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • agentId

      public String agentId()
      Returns the value of the agentId record component.
      Returns:
      the value of the agentId record component
    • peer

      public String peer()
      Returns the value of the peer record component.
      Returns:
      the value of the peer record component
    • parentPeer

      public String parentPeer()
      Returns the value of the parentPeer record component.
      Returns:
      the value of the parentPeer record component
    • guild

      public String guild()
      Returns the value of the guild record component.
      Returns:
      the value of the guild record component
    • roles

      public Set<String> roles()
      Returns the value of the roles record component.
      Returns:
      the value of the roles record component
    • team

      public String team()
      Returns the value of the team record component.
      Returns:
      the value of the team record component
    • account

      public String account()
      Returns the value of the account record component.
      Returns:
      the value of the account record component
    • channel

      public String channel()
      Returns the value of the channel record component.
      Returns:
      the value of the channel record component
    • sessionScope

      public DmScope sessionScope()
      Returns the value of the sessionScope record component.
      Returns:
      the value of the sessionScope record component