View Source SwarmEx.Client (SwarmEx v0.2.0)
Main supervisor for agent networks. Manages agent lifecycles, message passing, error recovery and context variables.
The Client acts as a coordinator for a network of AI agents, handling:
- Agent lifecycle management (creation, termination)
- Message routing between agents
- Network state and context maintenance
- Error handling and recovery
Summary
Functions
Returns a specification to start this module under a supervisor.
Creates a new agent in the network.
Lists all active agents in the network.
Sends a message to a specific agent in the network.
Starts a new agent network with the given options.
Updates the network context with new values.
Types
Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
@spec create_agent(GenServer.server(), module(), keyword()) :: {:ok, pid()} | {:error, term()}
Creates a new agent in the network.
Options
All options are passed to the agent's init function.
@spec list_agents(GenServer.server()) :: {:ok, [String.t()]} | {:error, term()}
Lists all active agents in the network.
@spec send_message(GenServer.server(), String.t(), term()) :: {:ok, term()} | {:error, term()}
Sends a message to a specific agent in the network.
@spec start_link(keyword()) :: GenServer.on_start()
Starts a new agent network with the given options.
Options
:network_id
- Custom identifier for the network (optional):context
- Initial context map (default: %{}):registry
- Custom registry for agent processes (optional)
@spec update_context(GenServer.server(), map()) :: :ok | {:error, term()}
Updates the network context with new values.