praxis_graph/node.rs
1use anyhow::Result;
2use async_trait::async_trait;
3use crate::types::{GraphState, StreamEvent};
4use tokio::sync::mpsc;
5
6pub type EventSender = mpsc::Sender<StreamEvent>;
7
8/// Core abstraction for a unit of computation in the graph
9#[async_trait]
10pub trait Node: Send + Sync {
11 /// Execute the node's logic, potentially modifying state and emitting events
12 async fn execute(&self, state: &mut GraphState, event_tx: EventSender) -> Result<()>;
13
14 /// Return the type of this node
15 fn node_type(&self) -> NodeType;
16}
17
18#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
19pub enum NodeType {
20 LLM,
21 Tool,
22}
23