#!/usr/bin/env ts-node
import { runWorkflow } from './run-workflow.ts';
import { generateMorningReport } from './morning-report.ts';

export async function runScheduledWorkflow(): Promise<void> {
  await runWorkflow({ mode: 'resume' });
  await generateMorningReport();
}

if (import.meta.url === `file://${process.argv[1]}`) {
  runScheduledWorkflow().catch((error) => {
    const message = error instanceof Error ? error.message : String(error);
    console.error(`[workflow:schedule] failed: ${message}`);
    process.exitCode = 1;
  });
}
