adk_studio/schema/
workflow.rs1use serde::{Deserialize, Serialize};
2
3#[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#[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#[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#[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
57pub const START: &str = "START";
59pub const END: &str = "END";