1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//! Base node types and traits.
use serde::{Deserialize, Serialize};
/// Base node struct containing common properties.
///
/// All nodes embed this struct to inherit common functionality.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct NodeBase {
/// The scope of the node
#[serde(default)]
pub scope: String,
/// Unique identifier for this node instance
#[serde(default)]
pub guid: String,
/// Display name of the node
#[serde(default)]
pub name: String,
/// Delay before executing the node (in seconds)
#[serde(default, rename = "delayBefore")]
pub delay_before: f32,
/// Delay after executing the node (in seconds)
#[serde(default, rename = "delayAfter")]
pub delay_after: f32,
/// Whether to continue flow execution on error
#[serde(default, rename = "continueOnError")]
pub continue_on_error: bool,
}
impl NodeBase {
/// Create a new NodeBase with default values.
pub fn new() -> Self {
Self::default()
}
/// Get the GUID of this node.
pub fn guid(&self) -> &str {
&self.guid
}
}
/// Trait for types that have a NodeBase.
pub trait HasNodeBase {
/// Get a reference to the NodeBase.
fn node_base(&self) -> &NodeBase;
/// Get a mutable reference to the NodeBase.
fn node_base_mut(&mut self) -> &mut NodeBase;
}
/// Trait for types that can be initialized as nodes.
pub trait Node: HasNodeBase + Send + Sync + 'static {
/// Initialize the node with the runtime helper.
fn init(&mut self) -> crate::runtime::Result<()> {
Ok(())
}
}
/// Marker trait for nodes that support AI tool functionality.
pub trait ToolNode: Node {}