summaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/mod.rs10
-rw-r--r--src/tools/shell.rs6
2 files changed, 12 insertions, 4 deletions
diff --git a/src/tools/mod.rs b/src/tools/mod.rs
index 7c6a921..5d6189f 100644
--- a/src/tools/mod.rs
+++ b/src/tools/mod.rs
@@ -75,7 +75,11 @@ pub fn validate(name: &str, args: &Value) -> Result<(), String> {
75 }; 75 };
76 76
77 match name { 77 match name {
78 "bash" => required_text("cmd"), 78 "bash" => match args.get("cmd").or_else(|| args.get("command")) {
79 Some(value) if !value.as_str().unwrap_or("").trim().is_empty() => Ok(()),
80 Some(_) => Err("`cmd` is present but empty".into()),
81 None => Err(missing("cmd")),
82 },
79 "read" => required_text("path"), 83 "read" => required_text("path"),
80 "write" => { 84 "write" => {
81 required_text("path")?; 85 required_text("path")?;
@@ -177,11 +181,11 @@ pub fn schemas() -> Vec<Value> {
177 "type": "function", 181 "type": "function",
178 "function": { 182 "function": {
179 "name": "bash", 183 "name": "bash",
180 "description": "Run a shell command. Each call is a fresh shell at the working directory, so `cd` does not persist; pass cwd instead. stdout and stderr are reported in separate labelled sections when both produce output. Times out after timeout_seconds (default 120, maximum 600). Large output is truncated head+tail with an explicit marker; raise max_bytes if the match you need is in the middle.", 184 "description": "Run a shell command. The command string is the `cmd` parameter (not `command`). Each call is a fresh shell at the working directory, so `cd` does not persist; pass cwd instead. stdout and stderr are reported in separate labelled sections when both produce output. Times out after timeout_seconds (default 120, maximum 600). Large output is truncated head+tail with an explicit marker; raise max_bytes if the match you need is in the middle.",
181 "parameters": { 185 "parameters": {
182 "type": "object", 186 "type": "object",
183 "properties": { 187 "properties": {
184 "cmd": { "type": "string" }, 188 "cmd": { "type": "string", "description": "the shell command to run" },
185 "cwd": { "type": "string", "description": "working directory (default: project root)" }, 189 "cwd": { "type": "string", "description": "working directory (default: project root)" },
186 "timeout_seconds": { "type": "integer", "description": "1-600, default 120" }, 190 "timeout_seconds": { "type": "integer", "description": "1-600, default 120" },
187 "max_bytes": { "type": "integer", "description": "per-stream output budget, 1024-16777216, default 81920" } 191 "max_bytes": { "type": "integer", "description": "per-stream output budget, 1024-16777216, default 81920" }
diff --git a/src/tools/shell.rs b/src/tools/shell.rs
index c38f032..c64bab3 100644
--- a/src/tools/shell.rs
+++ b/src/tools/shell.rs
@@ -37,7 +37,11 @@ pub fn bash(
37 timeout: Duration, 37 timeout: Duration,
38 cancel: &AtomicBool, 38 cancel: &AtomicBool,
39) -> Result<String, String> { 39) -> Result<String, String> {
40 let cmd = match args.get("cmd").and_then(|v| v.as_str()) { 40 let cmd = match args
41 .get("cmd")
42 .or_else(|| args.get("command"))
43 .and_then(|v| v.as_str())
44 {
41 Some(cmd) => cmd.to_string(), 45 Some(cmd) => cmd.to_string(),
42 None => return Err("missing required argument `cmd`".into()), 46 None => return Err("missing required argument `cmd`".into()),
43 }; 47 };