ironflow_engine/config/
mod.rs1mod agent;
8mod approval;
9mod artifact;
10mod http;
11mod shell;
12mod workflow;
13
14pub use agent::AgentStepConfig;
15pub use approval::ApprovalConfig;
16pub use artifact::{ArtifactInput, ArtifactOutput};
17pub use http::HttpConfig;
18pub use shell::ShellConfig;
19pub use workflow::WorkflowStepConfig;
20
21use ironflow_store::entities::StepKind;
22use serde::{Deserialize, Serialize};
23
24#[derive(Debug, Clone, Serialize, Deserialize)]
39#[serde(tag = "type", rename_all = "snake_case")]
40pub enum StepConfig {
41 Shell(ShellConfig),
43 Http(HttpConfig),
45 Agent(AgentStepConfig),
47 Workflow(WorkflowStepConfig),
49 Approval(ApprovalConfig),
51}
52
53impl StepConfig {
54 pub fn kind(&self) -> StepKind {
66 match self {
67 StepConfig::Shell(_) => StepKind::Shell,
68 StepConfig::Http(_) => StepKind::Http,
69 StepConfig::Agent(_) => StepKind::Agent,
70 StepConfig::Workflow(_) => StepKind::Workflow,
71 StepConfig::Approval(_) => StepKind::Approval,
72 }
73 }
74}
75
76#[cfg(test)]
77mod tests {
78 use super::*;
79
80 #[test]
81 fn serde_roundtrip() {
82 let configs = vec![
83 StepConfig::Shell(ShellConfig::new("echo test")),
84 StepConfig::Http(HttpConfig::get("http://example.com")),
85 StepConfig::Agent(AgentStepConfig::new("summarize")),
86 StepConfig::Workflow(WorkflowStepConfig::new("build", serde_json::json!({}))),
87 StepConfig::Approval(ApprovalConfig::new("Deploy to production?")),
88 ];
89
90 for config in configs {
91 let json = serde_json::to_string(&config).expect("serialize");
92 let back: StepConfig = serde_json::from_str(&json).expect("deserialize");
93 let json2 = serde_json::to_string(&back).expect("serialize2");
94 assert_eq!(json, json2);
95 }
96 }
97}