miyabi-workflow
Workflow DSL for Miyabi - Define and execute agent workflows with conditional branching and state persistence.
Features
- Fluent API - Build workflows with method chaining
- Sequential Execution -
.step()and.then()for sequential steps - Parallel Execution -
.parallel()for concurrent tasks - Conditional Branching -
.branch()and.branch_on()for dynamic paths - State Persistence - Track execution state with sled database
- DAG Construction - Automatic dependency graph generation
Quick Start
use ;
use AgentType;
// Define a workflow
let workflow = new
.step
.then
.branch_on
.step
.step;
// Build DAG
let dag = workflow.build_dag?;
Conditional Branching
Simple Pass/Fail Branch
let workflow = new
.step
.branch;
Custom Conditions
use Condition;
let workflow = new
.step
.branch_on;
Available Conditions
Condition::Always- Always evaluates to true (fallback branch)Condition::FieldEquals { field, value }- Field equals a specific valueCondition::FieldGreaterThan { field, value }- Numeric field > thresholdCondition::FieldLessThan { field, value }- Numeric field < thresholdCondition::FieldExists { field }- Field exists in contextCondition::And(vec![...])- All conditions must be trueCondition::Or(vec![...])- At least one condition must be trueCondition::Not(Box::new(...))- Negate a condition
Execution with CoordinatorAgent
use CoordinatorAgent;
let coordinator = new;
// Execute workflow with state tracking
let execution_state = coordinator
.execute_workflow
.await?;
println!;
println!;
State Management
The workflow execution state is automatically persisted:
use StateStore;
let state_store = with_path?;
// Load execution state
if let Some = state_store.load_execution?
Integration
This crate is designed to work with:
- miyabi-agent-coordinator - Execute workflows with agent orchestration
- miyabi-types - Task and Agent type definitions
- miyabi-dag - DAG-based task graph construction
License
Apache-2.0