adk_studio/schema/
workflow.rs

1use serde::{Deserialize, Serialize};
2
3/// Workflow definition schema
4#[derive(Debug, Clone, Serialize, Deserialize, Default)]
5pub struct WorkflowSchema {
6    #[serde(rename = "type", default)]
7    pub workflow_type: WorkflowType,
8    #[serde(default)]
9    pub edges: Vec<Edge>,
10    #[serde(default)]
11    pub conditions: Vec<Condition>,
12}
13
14/// Workflow type
15#[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq)]
16#[serde(rename_all = "snake_case")]
17pub enum WorkflowType {
18    #[default]
19    Single,
20    Sequential,
21    Parallel,
22    Graph,
23}
24
25/// Edge between nodes
26#[derive(Debug, Clone, Serialize, Deserialize)]
27pub struct Edge {
28    pub from: String,
29    pub to: String,
30    #[serde(default)]
31    pub condition: Option<String>,
32}
33
34impl Edge {
35    pub fn new(from: impl Into<String>, to: impl Into<String>) -> Self {
36        Self { from: from.into(), to: to.into(), condition: None }
37    }
38
39    pub fn conditional(
40        from: impl Into<String>,
41        to: impl Into<String>,
42        condition: impl Into<String>,
43    ) -> Self {
44        Self { from: from.into(), to: to.into(), condition: Some(condition.into()) }
45    }
46}
47
48/// Condition definition
49#[derive(Debug, Clone, Serialize, Deserialize)]
50pub struct Condition {
51    pub id: String,
52    pub expression: String,
53    #[serde(default)]
54    pub description: String,
55}
56
57/// Special node identifiers
58pub const START: &str = "START";
59pub const END: &str = "END";