Skip to main content

StarpodAgent

Struct StarpodAgent 

Source
pub struct StarpodAgent { /* private fields */ }
Expand description

The Starpod agent orchestrator.

Wires together memory, sessions, vault, skills, cron, and the agent-sdk to provide a high-level chat() interface.

Config is wrapped in RwLock for hot reload support — config files can be updated on disk and the agent will pick up changes on the next request.

Implementations§

Source§

impl StarpodAgent

Source

pub async fn new(config: StarpodConfig) -> Result<Self>

Create a new StarpodAgent from a StarpodConfig.

Constructs synthetic ResolvedPaths from the config’s db_dir and project_root. Prefer with_paths() for workspace-aware construction.

Source

pub async fn with_paths( agent_config: AgentConfig, paths: ResolvedPaths, ) -> Result<Self>

Create a new StarpodAgent from an AgentConfig and ResolvedPaths.

This is the workspace-aware constructor that uses resolved paths for all file locations instead of deriving them from db_dir.

Source

pub fn paths(&self) -> &ResolvedPaths

Get the resolved paths.

Source

pub fn core_db(&self) -> &Arc<CoreDb>

Get the shared core database.

Source

pub fn reload_config(&self, new_config: StarpodConfig)

Hot-reload the agent config. Updates per-request settings (model, provider, agent_name, etc.) and applies memory tuning parameters immediately.

Settings that require restart: server_addr, TELEGRAM_BOT_TOKEN env var.

Source§

impl StarpodAgent

Source

pub async fn invalidate_model_registry(&self)

Invalidate the cached model registry (e.g. after config change).

Source

pub async fn chat(&self, message: ChatMessage) -> Result<ChatResponse>

Process a chat message through the full Starpod pipeline.

Source

pub async fn chat_stream( &self, message: &ChatMessage, ) -> Result<(Query, String, UnboundedSender<String>, Arc<Mutex<Vec<Attachment>>>)>

Start a streaming chat that yields raw agent-sdk messages.

Returns (Query stream, session_id, followup_tx, out_attachments). The caller should consume the stream for real-time display, then call finalize_chat() with the collected results. After the stream ends, drain out_attachments for any files the agent attached via the Attach tool.

The returned followup_tx can be used to inject followup messages into the running agent loop (when followup_mode = "inject"). Messages sent through this channel are drained at each iteration boundary and appended as user messages before the next API call.

Source

pub fn followup_mode(&self) -> FollowupMode

Get the configured followup mode.

Source

pub async fn finalize_chat( &self, session_id: &str, user_text: &str, result_text: &str, result: &ResultMessage, user_id: Option<&str>, )

Finalize a streaming chat — record usage and append daily log.

Source

pub fn memory(&self) -> &Arc<MemoryStore>

Get a reference to the memory store.

Source

pub fn session_mgr(&self) -> &Arc<SessionManager>

Get a reference to the session manager.

Source

pub fn skills(&self) -> &Arc<SkillStore>

Get a reference to the skill store.

Source

pub fn cron(&self) -> &Arc<CronStore>

Get a reference to the cron store.

Source

pub fn vault(&self) -> Option<&Arc<Vault>>

Get a reference to the vault (if available).

Source

pub fn config(&self) -> StarpodConfig

Get a snapshot of the current config.

Source

pub fn run_lifecycle(self: &Arc<Self>) -> JoinHandle<()>

Run startup lifecycle prompts (boot + bootstrap) in the background.

See [run_lifecycle_prompts] for details.

Source

pub fn start_scheduler( self: &Arc<Self>, notifier: Option<NotificationSender>, ) -> JoinHandle<()>

Start the cron scheduler as a background task.

The executor callback sends the job prompt through chat(). Session routing depends on JobContext.session_mode:

  • Isolated: channel_id=“scheduler”, no session key (each run is its own session)
  • Main: channel_id=“main”, channel_session_key=“main” (shared main session)

An optional notifier is called after each job completes to deliver results to the user (e.g. via Telegram). Returns a JoinHandle for the background task.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
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