import { WorkflowRunner } from './runner.js';
import { formatDryRunReport } from './dry-run-format.js';
export async function runWorkflow(yamlPath, options = {}) {
    const runner = new WorkflowRunner({
        cwd: options.cwd,
        relay: options.relay,
    });
    const config = await runner.parseYamlFile(yamlPath);
    // Allow programmatic trajectory override
    if (options.trajectories !== undefined) {
        config.trajectories = options.trajectories;
    }
    // Auto-detect DRY_RUN env var so existing scripts get dry-run for free
    const isDryRun = options.dryRun ?? !!process.env.DRY_RUN;
    if (isDryRun) {
        const report = runner.dryRun(config, options.workflow, options.vars);
        console.log(formatDryRunReport(report));
        return report;
    }
    if (options.onEvent) {
        runner.on(options.onEvent);
    }
    return runner.execute(config, options.workflow, options.vars);
}
//# sourceMappingURL=run.js.map