tools: each module owns its Tool list, no duplication

Each tool module exports its own tools() returning Vec<Tool>.
mod.rs::tools() chains them. Individual _def() and handler functions
are pub(super), not exported. Aggregate definitions derived from
the Tool lists.

- memory: memory_tools(), journal_tools()
- channels: tools()
- control: tools()
- mod.rs: just chains + adds file/bash/web/vision

Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
ProofOfConcept 2026-04-04 15:22:03 -04:00 committed by Kent Overstreet
parent aa7511d110
commit 6d6da07f91
4 changed files with 91 additions and 81 deletions

View file

@ -50,7 +50,26 @@ pub(super) fn yield_to_user(args: &serde_json::Value) -> Result<ToolOutput> {
})
}
pub(super) fn definitions() -> Vec<ToolDef> {
pub(super) fn tools() -> Vec<super::Tool> {
use super::Tool;
let defs = definitions();
vec![
Tool { def: defs[0].clone(), // switch_model
handler: |_a, v| Box::pin(async move {
let model = v.get("model").and_then(|v| v.as_str()).unwrap_or("");
Ok(format!("Switching to model: {}", model))
}) },
Tool { def: defs[1].clone(), // pause
handler: |_a, _v| Box::pin(async { Ok("Pausing autonomous behavior. Only user input will wake you.".into()) }) },
Tool { def: defs[2].clone(), // yield_to_user
handler: |_a, v| Box::pin(async move {
let msg = v.get("message").and_then(|v| v.as_str()).unwrap_or("(yielding to user)");
Ok(msg.to_string())
}) },
]
}
fn definitions() -> Vec<ToolDef> {
vec![
ToolDef::new(
"switch_model",