pub struct Daemon {
pub runtime: Arc<RwLock<Arc<Runtime<ProviderRegistry, DaemonHook>>>>,
/* private fields */
}Expand description
Shared daemon state — holds the runtime. Cheap to clone (Arc-backed).
The runtime is stored behind Arc<RwLock<Arc<Runtime>>> so that
Daemon::reload can swap it atomically while in-flight requests that
already cloned the inner Arc complete normally.
Fields§
§runtime: Arc<RwLock<Arc<Runtime<ProviderRegistry, DaemonHook>>>>The crabtalk runtime, swappable via Daemon::reload.
Implementations§
Source§impl Daemon
impl Daemon
Sourcepub async fn start(config_dir: &Path) -> Result<DaemonHandle>
pub async fn start(config_dir: &Path) -> Result<DaemonHandle>
Load config, build runtime, and start the event loop.
Returns a DaemonHandle with the event sender exposed. The caller
spawns transports (socket, channels) using the handle’s event_tx
and shutdown_tx, then integrates its own channels by cloning
event_tx and sending DaemonEvent::Message variants.
Trait Implementations§
Source§impl Server for Daemon
impl Server for Daemon
Source§async fn send(&self, req: SendMsg) -> Result<SendResponse>
async fn send(&self, req: SendMsg) -> Result<SendResponse>
Handle
Send — run agent and return complete response.Source§fn stream(
&self,
req: StreamMsg,
) -> impl Stream<Item = Result<StreamEvent>> + Send
fn stream( &self, req: StreamMsg, ) -> impl Stream<Item = Result<StreamEvent>> + Send
Handle
Stream — run agent and stream response events.Source§async fn compact_session(&self, session: u64) -> Result<String>
async fn compact_session(&self, session: u64) -> Result<String>
Handle
Compact — compact a session’s history into a summary.Source§async fn list_sessions(&self) -> Result<Vec<SessionInfo>>
async fn list_sessions(&self) -> Result<Vec<SessionInfo>>
Handle
Sessions — list active sessions.Source§async fn kill_session(&self, session: u64) -> Result<bool>
async fn kill_session(&self, session: u64) -> Result<bool>
Handle
Kill — close a session by ID.Source§fn subscribe_events(&self) -> impl Stream<Item = Result<AgentEventMsg>> + Send
fn subscribe_events(&self) -> impl Stream<Item = Result<AgentEventMsg>> + Send
Handle
SubscribeEvents — stream agent events.Source§async fn get_config(&self) -> Result<String>
async fn get_config(&self) -> Result<String>
Handle
GetConfig — return the full daemon config as JSON.Source§async fn set_config(&self, config: String) -> Result<()>
async fn set_config(&self, config: String) -> Result<()>
Handle
SetConfig — replace the daemon config from JSON.Source§async fn get_stats(&self) -> Result<DaemonStats>
async fn get_stats(&self) -> Result<DaemonStats>
Handle
GetStats — return daemon-level stats.Source§async fn create_cron(&self, req: CreateCronMsg) -> Result<CronInfo>
async fn create_cron(&self, req: CreateCronMsg) -> Result<CronInfo>
Handle
CreateCron — create a new cron entry and start its timer.Source§async fn delete_cron(&self, id: u64) -> Result<bool>
async fn delete_cron(&self, id: u64) -> Result<bool>
Handle
DeleteCron — remove a cron entry and stop its timer.Source§async fn list_crons(&self) -> Result<CronList>
async fn list_crons(&self) -> Result<CronList>
Handle
ListCrons — return all cron entries.Source§async fn reply_to_ask(&self, session: u64, content: String) -> Result<()>
async fn reply_to_ask(&self, session: u64, content: String) -> Result<()>
Handle
ReplyToAsk — deliver a user reply to a pending ask_user tool call.Source§fn dispatch(
&self,
msg: ClientMessage,
) -> impl Stream<Item = ServerMessage> + Send
fn dispatch( &self, msg: ClientMessage, ) -> impl Stream<Item = ServerMessage> + Send
Dispatch a
ClientMessage to the appropriate handler method. Read moreAuto Trait Implementations§
impl Freeze for Daemon
impl !RefUnwindSafe for Daemon
impl Send for Daemon
impl Sync for Daemon
impl Unpin for Daemon
impl UnsafeUnpin for Daemon
impl !UnwindSafe for Daemon
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
Mutably borrows from an owned value. Read more