pub struct AgentBuilder { /* private fields */ }Expand description
Builder for configuring and creating an Agent
§Example
use elo::Agent;
let agent = Agent::builder()
.storage_path("/var/lib/loa")
.identity_path("/etc/loa/agent_id.key")
.dashboard_port(3000)
.build()
.await?;Implementations§
Source§impl AgentBuilder
impl AgentBuilder
Sourcepub fn storage_path<P: AsRef<Path>>(self, path: P) -> Self
pub fn storage_path<P: AsRef<Path>>(self, path: P) -> Self
Set the storage path for databases and persistent data
This is required. If not set, build() will return an error.
§Example
use elo::Agent;
let agent = Agent::builder()
.storage_path("/var/lib/loa")
.build()
.await?;Sourcepub fn identity_path<P: AsRef<Path>>(self, path: P) -> Self
pub fn identity_path<P: AsRef<Path>>(self, path: P) -> Self
Set the identity path for agent identity key
If not specified, defaults to {storage_path}/agent_id.key
§Example
use elo::Agent;
let agent = Agent::builder()
.storage_path("/var/lib/loa")
.identity_path("/etc/loa/agent_id.key")
.build()
.await?;Sourcepub fn dashboard_port(self, port: u16) -> Self
pub fn dashboard_port(self, port: u16) -> Self
Set the dashboard port
Optional. If set, a dashboard will be served on this port (future feature).
§Example
use elo::Agent;
let agent = Agent::builder()
.storage_path("/var/lib/loa")
.dashboard_port(3000)
.build()
.await?;Sourcepub fn claim<S: Into<String>>(self, workspace_id: S) -> Self
pub fn claim<S: Into<String>>(self, workspace_id: S) -> Self
Claim this agent for a workspace using a workspace ID
This allows immediate agent claiming during startup. The workspace_id is sent during registration, and the server returns a unique claim_token that the agent persists for future registrations.
- First registration: workspace_id → server creates claim_token → agent saves it
- Subsequent registrations: agent sends claim_token from file
- Transfer: agent sends both claim_token AND new workspace_id
§Example
use elo::Agent;
let agent = Agent::builder()
.storage_path("/var/lib/loa")
.claim("j57abc123def456...") // Convex workspace ID
.build()
.await?;Sourcepub fn api_url<S: Into<String>>(self, url: S) -> Self
pub fn api_url<S: Into<String>>(self, url: S) -> Self
Set a custom API URL for the backend
If not specified, uses the default production URL (https://api.loa.sh). Use this for local development or custom deployments.
§Example
use elo::Agent;
let agent = Agent::builder()
.storage_path("/var/lib/loa")
.api_url("http://localhost:8787")
.build()
.await?;Sourcepub async fn build(self) -> Result<Agent>
pub async fn build(self) -> Result<Agent>
Build the agent and spawn all internal actors
This will:
- Validate configuration
- Create storage directories if needed
- Spawn the root supervisor
- Spawn all core actors (currently empty)
- Return an Agent handle
§Errors
Returns an error if:
- storage_path is not set
- storage directories cannot be created
- supervisor fails to spawn
§Example
use elo::Agent;
let agent = Agent::builder()
.storage_path("/var/lib/loa")
.build()
.await?;
agent.run().await?;