Expand description
Session-scoped prompt scheduler — backs /loop, /cron-list, /cron-cancel.
Users schedule recurring prompts with /loop 5m check the deployment.
The scheduler fires them via a tokio channel; AgentSession drains the
channel after each send() and runs the fired prompts.
§Design
CronSchedulerholds astd::sync::Mutex<CronSchedulerInner>so it can be accessed from synchronous slash command handlers.- A background tokio task holds a
Weak<CronScheduler>and ticks every second. It exits automatically when the session is dropped. - Fired prompts are delivered via
tokio::sync::mpsc::UnboundedSender. - Deterministic jitter (0–10% of period, capped at 15 min) is derived from the task ID so the same task always fires with the same offset.
Structs§
- Cron
Scheduler - Session-scoped prompt scheduler.
- Scheduled
Fire - A task fire event delivered to
AgentSession. - Scheduled
Task - A pending scheduled task.
- Scheduled
Task Info - Snapshot of a task used for display (avoids exposing
Instantin public API).
Functions§
- format_
duration - Format a duration in seconds to a human-readable string (
"5m","2h 30m", etc.). - parse_
interval - Parse a duration string like
"5m","30s","2h","1d". - parse_
loop_ args - Parse the argument string from
/loop <args>.