feat(automation): add daily briefing preset and cron backup scheduling
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import type { Config, CronJobConfig } from '../config/schema.js';
|
||||
|
||||
/**
|
||||
* Builds config-derived cron jobs that are not manually listed under automation.cron.
|
||||
* This keeps opinionated automation features opt-in while reusing the existing CronScheduler.
|
||||
*/
|
||||
export function buildPresetCronJobs(config: Config): CronJobConfig[] {
|
||||
const jobs: CronJobConfig[] = [];
|
||||
const existingNames = new Set(config.automation.cron.map((job) => job.name));
|
||||
|
||||
const briefing = config.automation.daily_briefing;
|
||||
if (briefing.enabled) {
|
||||
if (!briefing.output) {
|
||||
console.warn('automation.daily_briefing.enabled=true but output is missing; skipping daily briefing job');
|
||||
} else if (existingNames.has(briefing.name)) {
|
||||
console.warn(`automation.daily_briefing name '${briefing.name}' conflicts with automation.cron; skipping preset job`);
|
||||
} else {
|
||||
jobs.push({
|
||||
name: briefing.name,
|
||||
schedule: briefing.schedule,
|
||||
message: briefing.prompt,
|
||||
output: briefing.output,
|
||||
enabled: true,
|
||||
timezone: briefing.timezone,
|
||||
model_tier: briefing.model_tier,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return jobs;
|
||||
}
|
||||
Reference in New Issue
Block a user