cortexai_tools/lib.rs
1//! # Built-in Tools
2//!
3//! Common tools that can be used by agents, with enhanced registry
4
5#![allow(clippy::new_without_default)]
6#![allow(clippy::match_single_binding)]
7#![allow(clippy::match_wildcard_for_single_variants)]
8#![allow(clippy::wildcard_in_or_patterns)]
9//! featuring circuit breaker, retry, and timeout patterns.
10//!
11//! ## Available Tools
12//!
13//! ### Math
14//! - `CalculatorTool` - Full expression evaluation with scientific functions
15//! - `UnitConverterTool` - Convert between units (length, weight, temperature)
16//! - `StatisticsTool` - Calculate mean, median, std dev, etc.
17//!
18//! ### DateTime
19//! - `CurrentTimeTool` - Get current date/time
20//! - `DateParserTool` - Parse dates in various formats
21//! - `DateCalculatorTool` - Date arithmetic and differences
22//!
23//! ### Encoding
24//! - `JsonTool` - Parse, format, merge JSON
25//! - `Base64Tool` - Encode/decode Base64
26//! - `HashTool` - SHA256/SHA512 hashing
27//! - `UrlEncodeTool` - URL encode/decode
28//!
29//! ### File System
30//! - `ReadFileTool` - Read file contents
31//! - `WriteFileTool` - Write to files
32//! - `ListDirectoryTool` - List directory contents
33//!
34//! ### Web
35//! - `HttpRequestTool` - Make HTTP requests
36//! - `WebSearchTool` - Web search (stub)
37//!
38//! ### SQL (requires `postgres` feature)
39//! - `ExecuteSqlTool` - Execute read-only SQL queries
40//! - `ListTablesTool` - List database tables and columns
41//! - `DescribeTableTool` - Get detailed table schema information
42//!
43//! ### Cross-Reference (requires `crossref` feature)
44//! - `CrossReferenceEntityTool` - Cross-reference entities across data sources with PT-BR narratives
45
46pub use cortexai_core::tool::*;
47pub use cortexai_macros::Tool;
48
49use std::sync::Arc;
50
51#[cfg(feature = "crossref")]
52pub mod crossref;
53pub mod datetime;
54pub mod delegation;
55pub mod encoding;
56pub mod file;
57pub mod macro_tools;
58pub mod math;
59pub mod registry;
60#[cfg(feature = "postgres")]
61pub mod sql;
62pub mod web;
63
64#[cfg(feature = "crossref")]
65pub use crossref::*;
66pub use datetime::*;
67pub use delegation::*;
68pub use encoding::*;
69pub use file::*;
70pub use macro_tools::*;
71pub use math::*;
72pub use registry::*;
73#[cfg(feature = "postgres")]
74pub use sql::*;
75pub use web::*;
76
77/// Create a registry with all built-in tools
78pub fn create_default_registry() -> ToolRegistry {
79 let mut registry = ToolRegistry::new();
80
81 // Math tools
82 registry.register(Arc::new(CalculatorTool::new()));
83 registry.register(Arc::new(UnitConverterTool::new()));
84 registry.register(Arc::new(StatisticsTool::new()));
85
86 // DateTime tools
87 registry.register(Arc::new(CurrentTimeTool::new()));
88 registry.register(Arc::new(DateParserTool::new()));
89 registry.register(Arc::new(DateCalculatorTool::new()));
90
91 // Encoding tools
92 registry.register(Arc::new(JsonTool::new()));
93 registry.register(Arc::new(Base64Tool::new()));
94 registry.register(Arc::new(HashTool::new()));
95 registry.register(Arc::new(UrlEncodeTool::new()));
96
97 // File tools
98 registry.register(Arc::new(ReadFileTool::new()));
99 registry.register(Arc::new(WriteFileTool::new()));
100 registry.register(Arc::new(ListDirectoryTool::new()));
101
102 // Web tools
103 registry.register(Arc::new(HttpRequestTool::new()));
104 registry.register(Arc::new(WebSearchTool::new()));
105
106 registry
107}