Skip to main content

mofa_foundation/workflow/dsl/
mod.rs

1//! Workflow DSL (Domain Specific Language)
2//!
3//! Provides declarative configuration for workflows using YAML/TOML.
4//!
5//! # Example
6//!
7//! ```yaml
8//! metadata:
9//!   id: customer_support
10//!   name: Customer Support Workflow
11//!
12//! agents:
13//!   classifier:
14//!     model: gpt-4
15//!     system_prompt: "Classify queries into: billing, technical, general"
16//!     temperature: 0.3
17//!
18//! nodes:
19//!   - type: start
20//!     id: start
21//!
22//!   - type: llm_agent
23//!     id: classify
24//!     name: Classify Query
25//!     agent:
26//!       agent_id: classifier
27//!
28//!   - type: end
29//!     id: end
30//!
31//! edges:
32//!   - from: start
33//!     to: classify
34//!   - from: classify
35//!     to: end
36//! ```
37
38mod env;
39mod parser;
40mod schema;
41
42pub use parser::*;
43pub use schema::*;
44
45/// Result type for DSL operations
46pub type DslResult<T> = Result<T, DslError>;
47
48/// Errors that can occur during DSL parsing
49#[derive(Debug, thiserror::Error)]
50pub enum DslError {
51    #[error("IO error: {0}")]
52    Io(#[from] std::io::Error),
53
54    #[error("YAML parse error: {0}")]
55    YamlParse(#[from] serde_yaml::Error),
56
57    #[error("TOML parse error: {0}")]
58    TomlParse(#[from] toml::de::Error),
59
60    #[error("JSON parse error: {0}")]
61    JsonParse(#[from] serde_json::Error),
62
63    #[error("Validation error: {0}")]
64    Validation(String),
65
66    #[error("Agent not found: {0}")]
67    AgentNotFound(String),
68
69    #[error("Invalid node type: {0}")]
70    InvalidNodeType(String),
71
72    #[error("Invalid edge: from '{from}' to '{to}'")]
73    InvalidEdge { from: String, to: String },
74
75    #[error("Build error: {0}")]
76    Build(String),
77}