vex_llm/tools/
mod.rs

1//! Built-in tools for VEX agents
2//!
3//! This module provides a set of ready-to-use tools:
4//!
5//! - [`CalculatorTool`] - Evaluate mathematical expressions
6//! - [`DateTimeTool`] - Get current date and time
7//! - [`UuidTool`] - Generate UUIDs
8//! - [`HashTool`] - Compute SHA-256/SHA-512 hashes
9//! - [`RegexTool`] - Pattern matching and extraction
10//! - [`JsonPathTool`] - JSON value extraction
11//!
12//! All built-in tools are pure computation (no network I/O) and safe for sandboxing.
13
14mod calculator;
15mod datetime;
16mod hash;
17mod json_path;
18mod regex;
19mod uuid_tool;
20
21pub use calculator::CalculatorTool;
22pub use datetime::DateTimeTool;
23pub use hash::HashTool;
24pub use json_path::JsonPathTool;
25pub use regex::RegexTool;
26pub use uuid_tool::UuidTool;
27
28use crate::tool::ToolRegistry;
29use std::sync::Arc;
30
31/// Create a registry with all built-in tools pre-registered
32///
33/// # Example
34///
35/// ```ignore
36/// let registry = vex_llm::tools::builtin_registry();
37/// assert!(registry.contains("calculator"));
38/// assert!(registry.contains("hash"));
39/// ```
40pub fn builtin_registry() -> ToolRegistry {
41    let mut registry = ToolRegistry::new();
42    registry.register(Arc::new(CalculatorTool::new()));
43    registry.register(Arc::new(DateTimeTool::new()));
44    registry.register(Arc::new(UuidTool::new()));
45    registry.register(Arc::new(HashTool::new()));
46    registry.register(Arc::new(RegexTool::new()));
47    registry.register(Arc::new(JsonPathTool::new()));
48    registry
49}
50
51#[cfg(test)]
52mod tests {
53    use super::*;
54
55    #[test]
56    fn test_builtin_registry() {
57        let registry = builtin_registry();
58
59        assert!(registry.contains("calculator"));
60        assert!(registry.contains("datetime"));
61        assert!(registry.contains("uuid"));
62        assert!(registry.contains("hash"));
63        assert!(registry.contains("regex"));
64        assert!(registry.contains("json_path"));
65        assert_eq!(registry.len(), 6);
66    }
67}