2026-07-20 09:04:57 +07:00
|
|
|
//! Workflow execution — runs a parsed workflow script phase by phase.
|
|
|
|
|
|
|
|
|
|
use anyhow::Result;
|
2026-07-20 15:53:20 +07:00
|
|
|
use tracing::{info, instrument};
|
2026-07-20 09:04:57 +07:00
|
|
|
|
|
|
|
|
use crate::tools::ToolCtx;
|
|
|
|
|
use crate::workflow::engine::primitives::execute_primitive;
|
2026-07-21 06:24:20 +07:00
|
|
|
use zesdex_domain::workflow::WorkflowScript;
|
2026-07-20 09:04:57 +07:00
|
|
|
|
|
|
|
|
/// Execute each phase of a workflow script sequentially.
|
|
|
|
|
///
|
|
|
|
|
/// Flow: for each phase → execute_primitive → collect result.
|
2026-08-28 12:52:58 +07:00
|
|
|
#[instrument(skip(tool_ctx))]
|
|
|
|
|
pub async fn execute_workflow(script: &WorkflowScript, tool_ctx: &ToolCtx) -> Result<Vec<String>> {
|
2026-07-20 09:04:57 +07:00
|
|
|
info!(
|
|
|
|
|
"Executing workflow: {} ({} phases)",
|
|
|
|
|
script.name,
|
|
|
|
|
script.phases.len()
|
|
|
|
|
);
|
|
|
|
|
let mut results = Vec::new();
|
|
|
|
|
for phase in &script.phases {
|
|
|
|
|
info!("Executing phase: {}", phase.name);
|
|
|
|
|
let result = execute_primitive(&phase.directive, tool_ctx).await?;
|
|
|
|
|
results.push(result);
|
|
|
|
|
}
|
|
|
|
|
Ok(results)
|
|
|
|
|
}
|