2026-07-12 11:28:39 +07:00
|
|
|
//! Script primitives for the workflow engine: agent invocation, parallel
|
|
|
|
|
//! execution, pipelines, and phases.
|
|
|
|
|
|
2026-07-11 13:16:10 +07:00
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
|
2026-07-12 11:28:39 +07:00
|
|
|
/// A workflow script primitive — can be a single agent, a parallel fan-out,
|
|
|
|
|
/// a sequential pipeline, or a named phase.
|
2026-07-11 13:16:10 +07:00
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
|
|
|
pub enum ScriptPrimitive {
|
2026-07-12 11:28:39 +07:00
|
|
|
/// Run a single agent with the given prompt template.
|
2026-07-11 13:16:10 +07:00
|
|
|
Agent(String),
|
2026-07-14 08:12:37 +07:00
|
|
|
/// Run a single agent with an explicit node designation and
|
|
|
|
|
/// tool-scope tier.
|
|
|
|
|
///
|
|
|
|
|
/// Used by the hive-mind pipeline, where a node's identity is its
|
|
|
|
|
/// system-assigned designation (e.g. `"Node-0-1"`) paired with a
|
|
|
|
|
/// bounded tool allowlist. `tool_scope` is one of `"read"`,
|
|
|
|
|
/// `"write"`, `"full"` (see `app::subagent::division::tool_scope`);
|
|
|
|
|
/// unrecognized values fall back to `"read"`.
|
|
|
|
|
ScopedAgent {
|
|
|
|
|
prompt: String,
|
|
|
|
|
node_id: String,
|
|
|
|
|
tool_scope: String,
|
|
|
|
|
},
|
2026-07-12 11:28:39 +07:00
|
|
|
/// Execute several primitives concurrently.
|
2026-07-11 13:16:10 +07:00
|
|
|
Parallel(Vec<ScriptPrimitive>),
|
2026-07-12 11:28:39 +07:00
|
|
|
/// Execute several primitives sequentially, each waiting for the
|
|
|
|
|
/// previous to complete.
|
2026-07-11 13:16:10 +07:00
|
|
|
Pipeline(Vec<ScriptPrimitive>),
|
2026-07-12 11:28:39 +07:00
|
|
|
/// A named wrapper around another primitive (used for display/tracing).
|
2026-07-11 13:16:10 +07:00
|
|
|
Phase {
|
|
|
|
|
name: String,
|
|
|
|
|
script: Box<ScriptPrimitive>,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-12 11:28:39 +07:00
|
|
|
/// Runtime options for a workflow execution.
|
2026-07-11 13:16:10 +07:00
|
|
|
#[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,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-12 11:28:39 +07:00
|
|
|
/// A named, versioned workflow script with its primitives and options.
|
2026-07-11 13:16:10 +07:00
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
|
|
|
pub struct WorkflowScript {
|
|
|
|
|
pub name: String,
|
|
|
|
|
pub description: String,
|
|
|
|
|
pub script: ScriptPrimitive,
|
|
|
|
|
pub options: ScriptOptions,
|
|
|
|
|
}
|