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
impl StarpodAgent
Sourcepub async fn new(config: StarpodConfig) -> Result<Self>
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.
Sourcepub async fn with_paths(
agent_config: AgentConfig,
paths: ResolvedPaths,
) -> Result<Self>
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.
Sourcepub fn paths(&self) -> &ResolvedPaths
pub fn paths(&self) -> &ResolvedPaths
Get the resolved paths.
Sourcepub fn reload_config(&self, new_config: StarpodConfig)
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
impl StarpodAgent
Sourcepub async fn invalidate_model_registry(&self)
pub async fn invalidate_model_registry(&self)
Invalidate the cached model registry (e.g. after config change).
Sourcepub async fn chat(&self, message: ChatMessage) -> Result<ChatResponse>
pub async fn chat(&self, message: ChatMessage) -> Result<ChatResponse>
Process a chat message through the full Starpod pipeline.
Sourcepub async fn chat_stream(
&self,
message: &ChatMessage,
) -> Result<(Query, String, UnboundedSender<String>, Arc<Mutex<Vec<Attachment>>>)>
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.
Sourcepub fn followup_mode(&self) -> FollowupMode
pub fn followup_mode(&self) -> FollowupMode
Get the configured followup mode.
Sourcepub async fn finalize_chat(
&self,
session_id: &str,
user_text: &str,
result_text: &str,
result: &ResultMessage,
user_id: Option<&str>,
)
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.
Sourcepub fn memory(&self) -> &Arc<MemoryStore>
pub fn memory(&self) -> &Arc<MemoryStore>
Get a reference to the memory store.
Sourcepub fn session_mgr(&self) -> &Arc<SessionManager>
pub fn session_mgr(&self) -> &Arc<SessionManager>
Get a reference to the session manager.
Sourcepub fn skills(&self) -> &Arc<SkillStore>
pub fn skills(&self) -> &Arc<SkillStore>
Get a reference to the skill store.
Sourcepub fn config(&self) -> StarpodConfig
pub fn config(&self) -> StarpodConfig
Get a snapshot of the current config.
Sourcepub fn run_lifecycle(self: &Arc<Self>) -> JoinHandle<()>
pub fn run_lifecycle(self: &Arc<Self>) -> JoinHandle<()>
Run startup lifecycle prompts (boot + bootstrap) in the background.
See [run_lifecycle_prompts] for details.
Sourcepub fn start_scheduler(
self: &Arc<Self>,
notifier: Option<NotificationSender>,
) -> JoinHandle<()>
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§
impl !Freeze for StarpodAgent
impl !RefUnwindSafe for StarpodAgent
impl Send for StarpodAgent
impl Sync for StarpodAgent
impl Unpin for StarpodAgent
impl UnsafeUnpin for StarpodAgent
impl !UnwindSafe for StarpodAgent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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