brainwires_tool_builtins/lib.rs
1#![deny(missing_docs)]
2//! `brainwires-tool-builtins` — the concrete-tools half of the Brainwires
3//! tool surface. Companion crate to `brainwires-tool-runtime` (the executor /
4//! registry / framework), unified by the `brainwires-tools` façade.
5//!
6//! ## Always Available (native feature)
7//! - **bash** — Shell command execution with proactive output management
8//! - **file_ops** — File read/write/edit/patch/list/search/delete/create_directory
9//! - **git** — Git operations (status, diff, log, stage, commit, push, pull, …)
10//! - **web** — URL fetching
11//! - **search** — Regex-based code search (respects .gitignore)
12//! - **default_executor::BuiltinToolExecutor** — `ToolExecutor` impl that
13//! hardcodes dispatch to the above plus the feature-gated builtins below.
14//!
15//! ## Feature-Gated
16//! - **code_exec / interpreters** (`interpreters` feature) — sandboxed
17//! multi-language code execution.
18//! - **semantic_search** (`rag` feature) — RAG-powered codebase search.
19//! - **email** (`email` feature) — IMAP/SMTP/Gmail-push integration.
20//! - **calendar** (`calendar` feature) — Google Calendar / CalDAV.
21//! - **browser** (`browser` feature) — headless-browser tooling via the MCP
22//! Thalora subprocess.
23//! - **system** (`system` feature) — filesystem-event watching, service
24//! management (absorbed from `brainwires-system`).
25//!
26//! The runtime trait surface (`ToolExecutor`, `ToolRegistry`, error types,
27//! `transaction`, `validation`, optional `orchestrator` / `oauth` /
28//! `openapi` / `sandbox_executor` / `sessions`) is **not** exported from this
29//! crate — depend on `brainwires-tool-runtime` directly, or use the
30//! `brainwires-tools` façade which re-exports both.
31
32mod default_executor;
33
34#[cfg(feature = "native")]
35mod bash;
36#[cfg(feature = "native")]
37mod file_ops;
38#[cfg(feature = "native")]
39mod git;
40#[cfg(feature = "native")]
41mod search;
42#[cfg(feature = "native")]
43mod web;
44
45#[cfg(feature = "interpreters")]
46mod code_exec;
47
48#[cfg(feature = "rag")]
49mod semantic_search;
50
51#[cfg(feature = "email")]
52mod email;
53
54#[cfg(feature = "calendar")]
55pub mod calendar;
56
57#[cfg(feature = "browser")]
58mod browser;
59
60/// OS-level primitives — filesystem event watching and service management
61/// (absorbed from brainwires-system).
62#[cfg(feature = "system")]
63pub mod system;
64
65/// Sandboxed multi-language code interpreters (absorbed from brainwires-code-interpreters).
66#[cfg(feature = "interpreters")]
67pub mod interpreters;
68
69// ── Public re-exports ──────────────────────────────────────────────────────
70
71pub use default_executor::BuiltinToolExecutor;
72
73#[cfg(feature = "native")]
74pub use bash::BashTool;
75#[cfg(feature = "native")]
76pub use file_ops::FileOpsTool;
77#[cfg(feature = "native")]
78pub use git::GitTool;
79#[cfg(feature = "native")]
80pub use search::SearchTool;
81#[cfg(feature = "native")]
82pub use web::WebTool;
83
84#[cfg(feature = "interpreters")]
85pub use code_exec::CodeExecTool;
86
87#[cfg(feature = "rag")]
88pub use semantic_search::SemanticSearchTool;
89
90#[cfg(feature = "email")]
91pub use email::{EmailConfig, EmailProvider, EmailSource, EmailTool, gmail_push};
92
93#[cfg(feature = "calendar")]
94pub use calendar::CalendarTool;
95
96#[cfg(feature = "browser")]
97pub use browser::BrowserTool;
98
99/// Build a [`brainwires_tool_runtime::ToolRegistry`] pre-populated with
100/// every concrete builtin gated on by the active feature set.
101///
102/// Only registers tools owned by **this crate** (plus the runtime's
103/// `tool_search` meta-tool and `validation` tools for backward compat).
104/// Runtime-only tools like `OrchestratorTool` are not in scope here —
105/// the `brainwires-tools` façade composes those on top via its own
106/// `registry_with_builtins()` that has visibility into both crates.
107///
108/// Replaces the historical `ToolRegistry::with_builtins()` constructor
109/// that lived in the runtime crate before the runtime/builtins split —
110/// the runtime can't reference concrete builtins, so the convenience
111/// constructor lives here where it can.
112pub fn registry_with_builtins() -> brainwires_tool_runtime::ToolRegistry {
113 let mut registry = brainwires_tool_runtime::ToolRegistry::with_runtime_meta_tools();
114
115 #[cfg(feature = "native")]
116 {
117 registry.register_tools(BashTool::get_tools());
118 registry.register_tools(FileOpsTool::get_tools());
119 registry.register_tools(GitTool::get_tools());
120 registry.register_tools(WebTool::get_tools());
121 registry.register_tools(SearchTool::get_tools());
122 registry.register_tools(brainwires_tool_runtime::get_validation_tools());
123 }
124
125 #[cfg(feature = "interpreters")]
126 registry.register_tools(CodeExecTool::get_tools());
127
128 #[cfg(feature = "rag")]
129 registry.register_tools(SemanticSearchTool::get_tools());
130
131 registry
132}