Lux.AgentHub (Lux v0.5.0)
View SourceA central hub for managing and discovering agents in the system. Provides functionality for registering agents, tracking their status, and discovering agents based on capabilities.
Multiple AgentHub instances can be started with different names:
{:ok, pid} = AgentHub.start_link(name: :my_hub)
{:ok, pid} = AgentHub.start_link(name: :another_hub)
Then interact with specific hubs:
AgentHub.register(hub, agent, pid, capabilities)
AgentHub.find_by_capability(hub, :research)
Summary
Functions
Child spec for starting under a supervisor.
Finds agents by capability.
Gets information about a specific agent.
Gets the default agent hub's pid.
Lists all registered agents.
Registers an agent in the hub.
Starts a new AgentHub process.
Updates the status of an agent.
Types
@type agent_info() :: %{ agent: Lux.Agent.t(), pid: pid(), status: agent_status(), capabilities: [atom()], last_updated: DateTime.t() }
@type agent_status() :: :available | :busy | :offline
Functions
Child spec for starting under a supervisor.
Example:
children = [
{Lux.AgentHub, name: :my_hub}
]
Supervisor.start_link(children, strategy: :one_for_one)
@spec find_by_capability(hub(), atom()) :: [agent_info()]
Finds agents by capability.
@spec get_agent_info(hub(), String.t()) :: {:ok, agent_info()} | {:error, :not_found}
Gets information about a specific agent.
@spec get_default() :: pid() | nil
Gets the default agent hub's pid.
@spec list_agents(hub()) :: [agent_info()]
Lists all registered agents.
Registers an agent in the hub.
Starts a new AgentHub process.
Options
:name
- Registers the hub with the given name
@spec update_status(hub(), String.t(), agent_status()) :: :ok | {:error, term()}
Updates the status of an agent.