use std::sync::Arc;
use theway_core::AgentTool;
use theway_core::multiagent::graph::engine::DagEngine;
use theway_core::multiagent::jobs::SubagentJobRegistry;
#[cfg(test)]
use serde_json::{Value, json};
#[cfg(test)]
use theway_core::AgentToolError;
#[cfg(test)]
use theway_core::multiagent::graph::types::{DagNodeDef, DagRunDef, NodeStatus};
#[cfg(test)]
use theway_llm_provider::UserContentBlock;
#[cfg(test)]
use tokio_util::sync::CancellationToken;
#[cfg(test)]
use utils::{
civil_from_days, iso_time_ms, node_result_text, status_counts, tail_truncate, thousands,
};
pub mod cancel;
pub mod clear;
pub mod inspect;
pub mod plan;
pub mod retry;
pub mod skip;
pub mod status;
pub mod utils;
pub mod wait;
pub use cancel::DagCancelTool;
pub use clear::DagClearTool;
pub use inspect::DagInspectTool;
pub use plan::{DagPlanTool, plan_from_definition};
pub use retry::DagRetryTool;
pub use skip::DagSkipTool;
pub use status::DagStatusTool;
pub use wait::DagWaitTool;
const DAG_WAIT_DEFAULT_TIMEOUT_SECS: u64 = 120;
const DAG_WAIT_IDLE_SECS: u64 = 30;
const NODE_RESULT_DEFAULT_TAIL: usize = 800;
pub struct DagTools;
impl DagTools {
#[allow(clippy::new_ret_no_self)]
pub fn new(
engine: Arc<DagEngine>,
session_id: Option<String>,
spec_names: Vec<String>,
registry: SubagentJobRegistry,
) -> Vec<Arc<dyn AgentTool>> {
vec![
Arc::new(DagPlanTool {
engine: engine.clone(),
session_id: session_id.clone(),
spec_names: spec_names.clone(),
}),
Arc::new(DagStatusTool {
engine: engine.clone(),
session_id: session_id.clone(),
}),
Arc::new(DagInspectTool {
engine: engine.clone(),
session_id: session_id.clone(),
registry: registry.clone(),
}),
Arc::new(DagWaitTool {
engine: engine.clone(),
session_id: session_id.clone(),
}),
Arc::new(DagRetryTool {
engine: engine.clone(),
session_id: session_id.clone(),
}),
Arc::new(DagSkipTool {
engine: engine.clone(),
session_id: session_id.clone(),
}),
Arc::new(DagCancelTool {
engine: engine.clone(),
session_id: session_id.clone(),
}),
Arc::new(DagClearTool { engine, session_id }),
]
}
}
#[cfg(test)]
tests_bridge_macro::tests_bridge!("tools/dag_tools");