32 lines
913 B
Rust
32 lines
913 B
Rust
//! Workflow execution — runs a parsed workflow script phase by phase.
|
|||
|
|
|
||
|
|
use anyhow::Result;
|
||
|
|
use tracing::info;
|
||
|
|
|
||
|
|
use crate::llm::provider::LlmClient;
|
||
|
|
use crate::tools::ToolCtx;
|
||
|
|
use crate::workflow::engine::primitives::execute_primitive;
|
||
|
|
use crate::workflow::script::WorkflowScript;
|
||
|
|
|
||
|
|
/// Execute each phase of a workflow script sequentially.
|
||
|
|
///
|
||
|
|
/// Flow: for each phase → execute_primitive → collect result.
|
||
|
|
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)
|
||
|
|
}
|