routing

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 28, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultAgentID   = "main"
	DefaultMainKey   = "main"
	DefaultAccountID = "default"
	MaxAgentIDLength = 64
)

Variables

This section is empty.

Functions

func BuildAgentMainSessionKey

func BuildAgentMainSessionKey(agentID string) string

BuildAgentMainSessionKey returns "agent:<agentId>:main".

func BuildAgentPeerSessionKey

func BuildAgentPeerSessionKey(params SessionKeyParams) string

BuildAgentPeerSessionKey constructs a session key based on agent, channel, peer, and DM scope.

func IsSubagentSessionKey

func IsSubagentSessionKey(sessionKey string) bool

IsSubagentSessionKey returns true if the session key represents a subagent.

func NormalizeAccountID

func NormalizeAccountID(id string) string

NormalizeAccountID sanitizes an account ID. Empty returns DefaultAccountID.

func NormalizeAgentID

func NormalizeAgentID(id string) string

NormalizeAgentID sanitizes an agent ID to [a-z0-9][a-z0-9_-]{0,63}. Invalid characters are collapsed to "-". Leading/trailing dashes stripped. Empty input returns DefaultAgentID ("main").

Types

type DMScope

type DMScope string

DMScope controls DM session isolation granularity.

const (
	DMScopeMain                  DMScope = "main"
	DMScopePerPeer               DMScope = "per-peer"
	DMScopePerChannelPeer        DMScope = "per-channel-peer"
	DMScopePerAccountChannelPeer DMScope = "per-account-channel-peer"
)

type ParsedSessionKey

type ParsedSessionKey struct {
	AgentID string
	Rest    string
}

ParsedSessionKey is the result of parsing an agent-scoped session key.

func ParseAgentSessionKey

func ParseAgentSessionKey(sessionKey string) *ParsedSessionKey

ParseAgentSessionKey extracts agentId and rest from "agent:<agentId>:<rest>".

type ResolvedRoute

type ResolvedRoute struct {
	AgentID        string
	Channel        string
	AccountID      string
	SessionKey     string
	MainSessionKey string
	MatchedBy      string // "binding.peer", "binding.peer.parent", "binding.guild", "binding.team", "binding.account", "binding.channel", "default"
}

ResolvedRoute is the result of agent routing.

type RouteInput

type RouteInput struct {
	Channel    string
	AccountID  string
	Peer       *RoutePeer
	ParentPeer *RoutePeer
	GuildID    string
	TeamID     string
}

RouteInput contains the routing context from an inbound message.

type RoutePeer

type RoutePeer struct {
	Kind string // "direct", "group", "channel"
	ID   string
}

RoutePeer represents a chat peer with kind and ID.

type RouteResolver

type RouteResolver struct {
	// contains filtered or unexported fields
}

RouteResolver determines which agent handles a message based on config bindings.

func NewRouteResolver

func NewRouteResolver(cfg *config.Config) *RouteResolver

NewRouteResolver creates a new route resolver.

func (*RouteResolver) ResolveRoute

func (r *RouteResolver) ResolveRoute(input RouteInput) ResolvedRoute

ResolveRoute determines which agent handles the message and constructs session keys. Implements the 7-level priority cascade: peer > parent_peer > guild > team > account > channel_wildcard > default

type SessionKeyParams

type SessionKeyParams struct {
	AgentID       string
	Channel       string
	AccountID     string
	Peer          *RoutePeer
	DMScope       DMScope
	IdentityLinks map[string][]string
}

SessionKeyParams holds all inputs for session key construction.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL