use crate::command::NodeOutput;
use crate::config::GraphConfig;
use crate::node::Node;
use crate::state::AgentState;
use crate::Result;
use std::future::Future;
use std::pin::Pin;
use std::sync::Arc;
pub trait Executor: Send + Sync {
fn execute_node(
&self,
node: Arc<dyn Node>,
state: AgentState,
config: GraphConfig,
) -> Pin<Box<dyn Future<Output = Result<NodeOutput>> + Send>>;
}
pub struct InProcessExecutor;
impl InProcessExecutor {
pub fn new() -> Self {
Self
}
}
impl Default for InProcessExecutor {
fn default() -> Self {
Self::new()
}
}
impl Executor for InProcessExecutor {
fn execute_node(
&self,
node: Arc<dyn Node>,
state: AgentState,
config: GraphConfig,
) -> Pin<Box<dyn Future<Output = Result<NodeOutput>> + Send>> {
Box::pin(async move { node.execute(&state, &config).await })
}
}