aboutsummaryrefslogtreecommitdiffstats
path: root/src/tools/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/tools/mod.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/tools/mod.rs b/src/tools/mod.rs
index 060dd7b..ddb1004 100644
--- a/src/tools/mod.rs
+++ b/src/tools/mod.rs
@@ -24,6 +24,19 @@ pub fn approval(name: &str) -> Approval {
24 } 24 }
25} 25}
26 26
27/// A call with no arguments at all. Every tool here requires at least one, so
28/// this is a placeholder some backends emit next to a real call, not an attempt.
29pub fn is_placeholder(arguments: &str) -> bool {
30 let trimmed = arguments.trim();
31 if trimmed.is_empty() {
32 return true;
33 }
34 matches!(
35 serde_json::from_str::<Value>(trimmed),
36 Ok(Value::Object(map)) if map.is_empty()
37 )
38}
39
27/// Rejects a call that cannot possibly run, before a human is asked to approve 40/// Rejects a call that cannot possibly run, before a human is asked to approve
28/// it. An empty `cmd` used to mean an approval prompt for `run: `. 41/// it. An empty `cmd` used to mean an approval prompt for `run: `.
29pub fn validate(name: &str, args: &Value) -> Result<(), String> { 42pub fn validate(name: &str, args: &Value) -> Result<(), String> {