Skip to main content

merlion_cron/
lib.rs

1//! Scheduled-job manager for Merlion Agent.
2//!
3//! Jobs are stored in `~/.merlion/cron.yaml` as a list of `(name, schedule,
4//! prompt)` triples where `schedule` is a 5-field POSIX cron expression
5//! (with an optional 6th seconds field — the `cron` crate's default). When
6//! `merlion cron daemon` runs, each job fires at its scheduled time and
7//! the resulting agent response is logged (or delivered through a
8//! gateway, if configured).
9
10pub mod registry;
11pub mod scheduler;
12
13pub use registry::{CronRegistry, Job};
14pub use scheduler::{run_once, Scheduler};
15
16use thiserror::Error;
17
18#[derive(Debug, Error)]
19pub enum Error {
20    #[error("invalid cron expression `{0}`: {1}")]
21    BadSchedule(String, String),
22    #[error("no job named `{0}`")]
23    NotFound(String),
24    #[error(transparent)]
25    Io(#[from] std::io::Error),
26    #[error(transparent)]
27    Yaml(#[from] serde_yaml::Error),
28    #[error("{0}")]
29    Other(String),
30}
31
32pub type Result<T> = std::result::Result<T, Error>;