tools: each module exports only tool() or tools(), nothing else

Every tool module now has a clean interface:
- read, write, edit, grep, glob, bash, vision: pub fn tool() -> Tool
- web: pub fn tools() -> [Tool; 2]
- memory: pub fn memory_tools() -> Vec<Tool>
- channels: pub fn tools() -> Vec<Tool>
- control: pub fn tools() -> Vec<Tool>

Definition and handler functions are private to each module.
mod.rs::tools() just chains the module exports.

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
ProofOfConcept 2026-04-04 15:34:07 -04:00 committed by Kent Overstreet
parent fdb8c989f5
commit ed150df628
10 changed files with 65 additions and 36 deletions

View file

@ -16,7 +16,11 @@ struct Args {
fn default_offset() -> usize { 1 }
pub fn definition() -> ToolDef {
pub fn tool() -> super::Tool {
super::Tool { def: definition(), handler: |_a, v| Box::pin(async move { read_file(&v) }) }
}
fn definition() -> ToolDef {
ToolDef::new(
"read_file",
"Read the contents of a file. Returns the file contents with line numbers.",
@ -41,7 +45,7 @@ pub fn definition() -> ToolDef {
)
}
pub fn read_file(args: &serde_json::Value) -> Result<String> {
fn read_file(args: &serde_json::Value) -> Result<String> {
let args: Args = serde_json::from_value(args.clone())
.context("invalid read_file arguments")?;