Skip to main content

sgr_agent_tools/
lib.rs

1//! sgr-agent-tools — reusable file-system tools for sgr-agent based AI agents.
2//!
3//! 11 universal tools parameterized by `FileBackend` trait:
4//!
5//! | # | Tool | Category |
6//! |---|------|----------|
7//! | 1 | ReadTool | observe |
8//! | 2 | WriteTool | act |
9//! | 3 | DeleteTool | act |
10//! | 4 | SearchTool | observe |
11//! | 5 | ListTool | observe |
12//! | 6 | TreeTool | observe |
13//! | 7 | EvalTool | compute (feature "eval") |
14//! | 8 | ReadAllTool | observe (batch) |
15//! | 9 | MkDirTool | act (deferred) |
16//! | 10 | MoveTool | act (deferred) |
17//! | 11 | FindTool | observe (deferred) |
18//!
19//! # Usage
20//!
21//! ```rust,ignore
22//! use sgr_agent_tools::{FileBackend, TreeTool, ReadTool, SearchTool, WriteTool};
23//!
24//! // Implement FileBackend for your runtime
25//! impl FileBackend for MyBackend { ... }
26//!
27//! // Create tools
28//! let b = Arc::new(MyBackend::new());
29//! let registry = ToolRegistry::new()
30//!     .register(ReadTool(b.clone()))
31//!     .register(WriteTool(b.clone()))
32//!     .register(SearchTool(b.clone()))
33//!     .register(TreeTool(b.clone()))
34//!     .register_deferred(MkDirTool(b.clone()));
35//! ```
36
37pub mod backend;
38pub mod helpers;
39pub mod trust;
40
41// Core tools
42pub mod delete;
43pub mod list;
44pub mod read;
45pub mod read_all;
46pub mod search;
47pub mod tree;
48pub mod write;
49
50// Deferred tools
51pub mod find;
52pub mod mkdir;
53pub mod move_file;
54
55// Optional: eval (heavy dep on boa_engine)
56#[cfg(feature = "eval")]
57pub mod eval;
58
59// Optional: shell (needs tokio process feature)
60#[cfg(feature = "shell")]
61pub mod shell;
62
63// Optional: apply_patch (Codex-compatible diff editing)
64#[cfg(feature = "patch")]
65pub mod apply_patch;
66
67// Re-export the core trait
68pub use backend::FileBackend;
69
70// Re-export all tools
71pub use delete::DeleteTool;
72pub use find::FindTool;
73pub use list::ListTool;
74pub use mkdir::MkDirTool;
75pub use move_file::MoveTool;
76pub use read::ReadTool;
77pub use read_all::ReadAllTool;
78pub use search::SearchTool;
79pub use tree::TreeTool;
80pub use write::WriteTool;
81
82#[cfg(feature = "eval")]
83pub use eval::EvalTool;
84
85#[cfg(feature = "shell")]
86pub use shell::ShellTool;
87
88#[cfg(feature = "patch")]
89pub use apply_patch::ApplyPatchTool;
90
91// Re-export helpers for wrapper tools (PAC1 uses these for Pac1SearchTool, etc.)
92pub use helpers::{backend_err, has_matches, unique_files_from_search};
93pub use search::{auto_expand_search, expand_query, fuzzy_regex, is_regex, smart_search};
94pub use trust::{infer_trust, wrap_with_meta};