Files
zesdex/src/app/workflow/script.rs
T

50 lines
1.5 KiB
Rust
Raw Normal View History

//! Script primitives for the workflow engine: agent invocation, parallel
//! execution, pipelines, and phases.
use serde::{Deserialize, Serialize};
/// A workflow script primitive — can be a single agent, a parallel fan-out,
/// a sequential pipeline, or a named phase.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum ScriptPrimitive {
/// Run a single agent with the given prompt template.
Agent(String),
/// Execute several primitives concurrently.
Parallel(Vec<ScriptPrimitive>),
/// Execute several primitives sequentially, each waiting for the
/// previous to complete.
Pipeline(Vec<ScriptPrimitive>),
/// A named wrapper around another primitive (used for display/tracing).
Phase {
name: String,
script: Box<ScriptPrimitive>,
},
}
/// Runtime options for a workflow execution.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ScriptOptions {
pub max_concurrency: usize,
pub continue_on_error: bool,
pub timeout_ms: Option<u64>,
}
impl Default for ScriptOptions {
fn default() -> Self {
ScriptOptions {
max_concurrency: 5,
continue_on_error: false,
timeout_ms: None,
}
}
}
/// A named, versioned workflow script with its primitives and options.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WorkflowScript {
pub name: String,
pub description: String,
pub script: ScriptPrimitive,
pub options: ScriptOptions,
}