use std::sync::Arc;
use gadk_agent::{AgentError, Context};
use serde_json::Value;
use crate::error::WorkflowErrorKind;
use crate::workflow::Node;
use crate::workflow::scheduler::wf_error;
#[derive(Clone, Default)]
pub struct RunNodeOptions {
pub run_id: Option<String>,
pub use_sub_branch: bool,
pub use_as_output: bool,
pub override_branch: Option<String>,
pub isolation_scope: Option<String>,
pub isolation_scope_from_node_path: bool,
pub raise_on_wait: bool,
}
pub async fn run_node(
ctx: &Context,
child: Arc<dyn Node>,
input: Value,
opts: RunNodeOptions,
) -> Result<Value, AgentError> {
let Some(ss) = ctx.sub_scheduler() else {
return Err(wf_error(WorkflowErrorKind::InvalidRunNodeContext, ""));
};
ss.run_node(Arc::new(child), input, Some(Arc::new(opts)))
.await
}