LemonRouter.AgentDirectory (lemon_router v0.1.0)

View Source

Discoverable directory for agent sessions and routing endpoints.

This module merges:

to provide a "phonebook" for agent/session addressing.

Summary

Functions

Returns the latest route-backed session (kind == :channel_peer) for an agent.

Returns the latest known session for an agent.

List agent directory entries with lightweight session/activity stats.

List known sessions.

List known channel targets for human-friendly routing.

Types

route_filter()

@type route_filter() :: %{
  optional(:channel_id) => binary(),
  optional(:account_id) => binary(),
  optional(:peer_kind) => atom(),
  optional(:peer_id) => binary(),
  optional(:thread_id) => binary()
}

session_entry()

@type session_entry() :: %{
  session_key: binary(),
  agent_id: binary(),
  kind: :main | :channel_peer | :unknown,
  channel_id: binary() | nil,
  account_id: binary() | nil,
  peer_kind: atom() | nil,
  peer_id: binary() | nil,
  thread_id: binary() | nil,
  peer_label: binary() | nil,
  peer_username: binary() | nil,
  topic_name: binary() | nil,
  chat_type: binary() | nil,
  sub_id: binary() | nil,
  created_at_ms: integer() | nil,
  updated_at_ms: integer() | nil,
  active?: boolean(),
  run_id: binary() | nil,
  run_count: non_neg_integer() | nil,
  origin: term()
}

Functions

latest_route_session(agent_id, opts \\ [])

@spec latest_route_session(
  binary(),
  keyword()
) :: {:ok, session_entry()} | {:error, :not_found}

Returns the latest route-backed session (kind == :channel_peer) for an agent.

latest_session(agent_id, opts \\ [])

@spec latest_session(
  binary(),
  keyword()
) :: {:ok, session_entry()} | {:error, :not_found}

Returns the latest known session for an agent.

list_agents(opts \\ [])

@spec list_agents(keyword()) :: [map()]

List agent directory entries with lightweight session/activity stats.

list_sessions(opts \\ [])

@spec list_sessions(keyword()) :: [session_entry()]

List known sessions.

Options:

  • :agent_id - optional agent filter
  • :route - optional route filter map (channel_id, account_id, peer_kind, peer_id, thread_id)
  • :limit - optional max rows

list_targets(opts \\ [])

@spec list_targets(keyword()) :: [map()]

List known channel targets for human-friendly routing.

This is intended for CLI/UI discovery before creating endpoint aliases.