pub mod bash;
pub mod delegate;
pub mod finish_task;
pub mod fs;
pub mod goals;
pub mod recall_session;
pub mod registry;
pub mod skill;
pub mod traits;
pub mod trusty_search;
#[allow(unused_imports)]
pub use bash::{BASH_TOOL_NAME, BashTool};
#[allow(unused_imports)]
pub use delegate::{DelegateToAgentTool, EngineerCompletionSignal};
pub use finish_task::{
FINISH_TASK_TOOL_NAME, FinishStatus, FinishTaskArgs, FinishTaskTool, render_finish_summary,
};
pub use fs::{
EditTool, GlobTool, GrepTool, ListDirTool, ReadFileTool, WRITE_FILES_TOOL_NAME, WriteFileTool,
WriteFilesTool,
};
pub use goals::{CLEAR_GOAL_TOOL_NAME, ClearGoalTool, SET_GOAL_TOOL_NAME, SetGoalTool};
pub use recall_session::{RECALL_SESSION_TOOL_NAME, RecallSessionTool};
pub use registry::ToolRegistry;
pub use skill::{USE_SKILL_TOOL_NAME, UseSkillTool};
pub use traits::{
AgentOutput, AgentRunner, HistoryMessage, RunContext, SearchProvider, SearchResult,
ServiceTier, SkillResolver, ToolExecutor, ToolResult,
};
pub use trusty_search::{SEARCH_CODE_TOOL_NAME, TrustySearchTool};
#[cfg(test)]
mod fs_registry_tests {
use std::sync::Arc;
use serde_json::json;
use super::{EditTool, ReadFileTool, ToolRegistry, WriteFileTool};
#[tokio::test]
async fn fs_tools_register_and_appear_in_schemas() {
let tmp = tempfile::tempdir().expect("tempdir");
let mut reg = ToolRegistry::new();
reg.register(Arc::new(ReadFileTool::new(tmp.path())));
reg.register(Arc::new(WriteFileTool::new(tmp.path())));
reg.register(Arc::new(EditTool::new(tmp.path())));
assert!(reg.contains("read_file"), "read_file must be registered");
assert!(reg.contains("write_file"), "write_file must be registered");
assert!(reg.contains("edit"), "edit must be registered");
let schemas = reg.schemas();
assert_eq!(schemas.len(), 3, "exactly three tools");
let names: Vec<&str> = schemas
.iter()
.filter_map(|s| s["function"]["name"].as_str())
.collect();
assert!(names.contains(&"read_file"));
assert!(names.contains(&"write_file"));
assert!(names.contains(&"edit"));
}
#[tokio::test]
async fn dispatch_gated_routes_write_file() {
let tmp = tempfile::tempdir().expect("tempdir");
let mut reg = ToolRegistry::new();
reg.register(Arc::new(WriteFileTool::new(tmp.path())));
let result = reg
.dispatch_gated(
"write_file",
json!({"path": "via_registry.txt", "content": "registry dispatch test"}),
None,
)
.await;
assert!(
!result.is_error(),
"dispatch should succeed: {}",
result.content()
);
let content = std::fs::read_to_string(tmp.path().join("via_registry.txt")).expect("read");
assert_eq!(content, "registry dispatch test");
}
#[tokio::test]
async fn dispatch_gated_routes_read_file() {
let tmp = tempfile::tempdir().expect("tempdir");
std::fs::write(tmp.path().join("test.txt"), "hello from registry").expect("seed");
let mut reg = ToolRegistry::new();
reg.register(Arc::new(ReadFileTool::new(tmp.path())));
let result = reg
.dispatch_gated("read_file", json!({"path": "test.txt"}), None)
.await;
assert!(
!result.is_error(),
"dispatch should succeed: {}",
result.content()
);
assert!(result.content().contains("hello from registry"));
}
#[tokio::test]
async fn dispatch_gated_routes_edit() {
let tmp = tempfile::tempdir().expect("tempdir");
std::fs::write(tmp.path().join("target.py"), "x = 0\n").expect("seed");
let mut reg = ToolRegistry::new();
reg.register(Arc::new(EditTool::new(tmp.path())));
let result = reg
.dispatch_gated(
"edit",
json!({"path": "target.py", "old_string": "x = 0", "new_string": "x = 99"}),
None,
)
.await;
assert!(
!result.is_error(),
"dispatch should succeed: {}",
result.content()
);
let content = std::fs::read_to_string(tmp.path().join("target.py")).expect("read");
assert!(content.contains("x = 99"));
}
}