Skip to main content

ares_tools/
lib.rs

1//! Built-in agent tools for A.R.E.S.
2
3pub mod config;
4pub use config::ToolConfig;
5
6pub mod calculator;
7pub mod fence;
8pub mod http_tool;
9pub mod plugins;
10pub(crate) mod registry;
11#[cfg(feature = "script-tools")]
12pub mod rhai_tool;
13#[cfg(feature = "script-tools")]
14pub mod script_tool;
15pub mod tool_service;
16pub mod tools;
17
18#[cfg(any(feature = "postgres", test))]
19pub(crate) mod runtime_registry;
20
21#[cfg(any(feature = "postgres", test))]
22pub(crate) use runtime_registry::RuntimeToolRegistry;
23
24#[cfg(any(feature = "postgres", test))]
25pub mod sql_tool;
26
27#[cfg(any(feature = "search-tools", test))]
28pub mod search;
29
30#[cfg(any(feature = "search-tools", test))]
31pub mod web_scrape;
32
33#[cfg(any(feature = "mcp", test))]
34pub mod mcp_bridge;
35
36#[cfg(any(feature = "postgres", test))]
37pub mod connectors;
38
39pub use calculator::{Calculator, CalculatorConfig, CalculatorService};
40pub use tools::provider_web_search::ProviderWebSearch;
41pub use plugins::register_plugins;
42pub use registry::Tool;
43#[cfg(feature = "script-tools")]
44pub use rhai_tool::{RhaiTool, RhaiToolConfig};
45pub use tool_service::Tools;
46
47#[cfg(test)]
48mod tests {
49    use super::{calculator::Calculator, ProviderWebSearch, Tool, Tools};
50    use std::sync::Arc;
51
52    #[test]
53    fn calculator_and_tools_are_wired() {
54        let tools = Tools::from_static([Arc::new(Calculator) as Arc<dyn Tool>]);
55        let ctx = cordis::Context::new_root();
56        assert!(tools.resolve(&ctx, "calculator").is_some());
57        assert!(tools
58            .list(&ctx)
59            .iter()
60            .any(|definition| definition.name == "calculator"));
61    }
62
63    #[test]
64    fn provider_web_search_is_always_on_and_distinct_from_daedra() {
65        let tools = Tools::from_static([
66            Arc::new(Calculator) as Arc<dyn Tool>,
67            Arc::new(ProviderWebSearch) as Arc<dyn Tool>,
68        ]);
69        let ctx = cordis::Context::new_root();
70        let tool = tools
71            .resolve(&ctx, "provider_web_search")
72            .expect("provider_web_search should resolve");
73        assert_eq!(tool.name(), "provider_web_search");
74        assert_eq!(crate::search::WebSearch::new().name(), "web_search");
75        assert_ne!(tool.name(), crate::search::WebSearch::new().name());
76    }
77
78    #[test]
79    fn search_and_scrape_modules_compile_under_test_cfg() {
80        let _ = std::any::type_name::<crate::search::WebSearch>();
81        let _ = std::any::type_name::<crate::web_scrape::WebScrape>();
82    }
83}