Files
zesdex/apps/infrastructure/src/workflow/engine/execution.rs
T

33 lines
970 B
Rust
Raw Normal View History

//! Workflow execution — runs a parsed workflow script phase by phase.
use anyhow::Result;
use tracing::{info, instrument};
use crate::llm::provider::LlmClient;
use crate::tools::ToolCtx;
use crate::workflow::engine::primitives::execute_primitive;
use zesdex_domain::workflow::WorkflowScript;
/// Execute each phase of a workflow script sequentially.
///
/// Flow: for each phase → execute_primitive → collect result.
#[instrument(skip(tool_ctx, _llm_client))]
pub async fn execute_workflow(
script: &WorkflowScript,
tool_ctx: &ToolCtx,
_llm_client: &LlmClient,
) -> Result<Vec<String>> {
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)
}