synwire_agent/middleware/filesystem.rs
1//! Filesystem middleware — exposes backend file operations as agent tools.
2
3use synwire_core::agents::middleware::Middleware;
4use synwire_core::tools::Tool;
5
6/// Middleware that registers filesystem tools into the agent context.
7///
8/// Tools exposed: `ls`, `read_file`, `write_file`, `edit_file`, `rm`, `pwd`, `cd`.
9#[derive(Debug, Default)]
10pub struct FilesystemMiddleware;
11
12impl Middleware for FilesystemMiddleware {
13 fn name(&self) -> &'static str {
14 "filesystem"
15 }
16
17 fn tools(&self) -> Vec<Box<dyn Tool>> {
18 // Tool implementations are wired up at runtime by the runner,
19 // which injects the configured backend. Here we return an empty
20 // list; the runner collects tools from middleware by name.
21 Vec::new()
22 }
23
24 fn system_prompt_additions(&self) -> Vec<String> {
25 vec![
26 "You have access to filesystem tools: ls, read_file, write_file, edit_file, rm, pwd, cd.".to_string(),
27 ]
28 }
29}