Skip to main content

AgentBuilder

Struct AgentBuilder 

Source
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

Source

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?;
Source

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?;
Source

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?;
Source

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?;
Source

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?;
Source

pub async fn build(self) -> Result<Agent>

Build the agent and spawn all internal actors

This will:

  1. Validate configuration
  2. Create storage directories if needed
  3. Spawn the root supervisor
  4. Spawn all core actors (currently empty)
  5. 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?;

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Message for T
where T: Any + Send + 'static,

Source§

fn from_boxed(m: BoxedMessage) -> Result<Self, BoxedDowncastErr>

Convert a BoxedMessage to this concrete type
Source§

fn box_message(self, pid: &ActorId) -> Result<BoxedMessage, BoxedDowncastErr>

Convert this message to a BoxedMessage
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> State for T
where T: Any + Send + 'static,