use std::collections::{HashMap, HashSet};
use serde_json::{Map, Value};
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub enum NodeStatus {
#[default]
Inactive,
Pending,
Running,
Completed,
Waiting,
Failed,
Cancelled,
}
#[derive(Debug, Clone, Default)]
pub struct NodeState {
pub status: NodeStatus,
pub input: Option<Value>,
pub output: Option<Value>,
pub triggered_by: String,
pub branch: String,
pub interrupts: Vec<String>,
pub attempt: i32,
pub resumed_inputs: Option<Map<String, Value>>,
pub(crate) interrupt_schemas: HashMap<String, Value>,
pub(crate) answered_this_turn: bool,
}
#[derive(Debug, Clone, Default)]
pub struct RunState {
pub nodes: HashMap<String, NodeState>,
pub(crate) completed: HashSet<String>,
}
impl RunState {
pub fn new() -> Self {
Self::default()
}
pub fn ensure_node(&mut self, name: &str) -> &mut NodeState {
self.nodes.entry(name.to_owned()).or_default()
}
}