use std::collections::BTreeSet;
use std::sync::{Mutex, OnceLock};
use crate::utils::lock::LockRecover;
use serde::{Deserialize, Serialize};
use uuid::Uuid;
use crate::paths::removed_default_routines_path;
use crate::routine_storage::write_routine;
use crate::utils::cron::normalize_schedule;
use crate::utils::time::now_secs;
use super::command::slugify;
use super::model::{Routine, RoutineStore};
#[allow(
clippy::missing_docs_in_private_items,
reason = "split-out module keeps the file under the linecheck limit"
)]
mod write_removed_defaults;
pub(crate) use write_removed_defaults::*;
mod the_1_percent;
mod token_trim;
mod update_moadim;
struct DefaultRoutine {
title: &'static str,
schedule: &'static str,
agent: &'static str,
prompt: &'static str,
goal: &'static str,
}
const DEFAULT_ROUTINES: &[DefaultRoutine] =
&[update_moadim::SPEC, the_1_percent::SPEC, token_trim::SPEC];
fn materialize(spec: &DefaultRoutine, now: u64) -> Routine {
let schedule = normalize_schedule(spec.schedule);
Routine {
id: Uuid::new_v4().to_string(),
schedule: schedule.clone(),
schedules: vec![schedule],
title: spec.title.to_string(),
agent: spec.agent.to_string(),
model: None,
prompt: spec.prompt.to_string(),
goal: Some(spec.goal.to_string()),
repositories: Vec::new(),
machines: vec![crate::machine::current_machine()],
enabled: true,
source: "managed".to_string(),
created_at: now,
updated_at: now,
last_manual_trigger_at: None,
last_scheduled_trigger_at: None,
snoozed_until: None,
skip_runs: None,
power_saving: false,
power_saving_exempt: false,
consecutive_failures: 0,
auto_disabled_reason: None,
ttl_secs: None,
max_runtime_secs: None,
failure_threshold: None,
tags: Vec::new(),
env: std::collections::HashMap::new(),
}
}
include!("reconcile.rs");