aboutsummaryrefslogtreecommitdiffstats
path: root/src/tools/mod.rs
diff options
context:
space:
mode:
authorsalmonik <salmonik@tuta.io>2026-11-15 18:00:12 +0100
committersalmonik <salmonik@tuta.io>2026-11-15 18:00:12 +0100
commit8ae5bd48cf233315b5f36a7a6b39002a5e77f74b (patch)
tree71c9b71f90f3cc64544dd506041468ee9bcbcda1 /src/tools/mod.rs
parent0.6.2: resizing no longer duplicates the prompt (diff)
downloadagent686-8ae5bd48cf233315b5f36a7a6b39002a5e77f74b.tar.gz
agent686-8ae5bd48cf233315b5f36a7a6b39002a5e77f74b.zip
0.7.0: resume shows where you left off; no approval for unparsable calls
- --continue prints the last answer, or the last reasoning block if there was none - tool arguments are validated before prompting, so an empty bash call becomes an error for the model instead of a blank approval - empty placeholder tool calls are dropped and reported - sessions tolerate invalid UTF-8 lines from a torn write - AGENT686_DEBUG_STREAM=1 dumps SSE frames
Diffstat (limited to '')
-rw-r--r--src/tools/mod.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/tools/mod.rs b/src/tools/mod.rs
index a8851ab..060dd7b 100644
--- a/src/tools/mod.rs
+++ b/src/tools/mod.rs
@@ -24,6 +24,30 @@ pub fn approval(name: &str) -> Approval {
24 } 24 }
25} 25}
26 26
27/// 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: `.
29pub fn validate(name: &str, args: &Value) -> Result<(), String> {
30 let text = |key: &str| args.get(key).and_then(|value| value.as_str()).unwrap_or("");
31 let required = |key: &str| {
32 if text(key).trim().is_empty() {
33 Err(format!("`{key}` is required and must not be empty"))
34 } else {
35 Ok(())
36 }
37 };
38
39 match name {
40 "bash" => required("cmd"),
41 "read" | "write" => required("path"),
42 "edit" => {
43 required("path")?;
44 required("old")
45 }
46 "grep" | "glob" => required("pattern"),
47 _ => Ok(()),
48 }
49}
50
27/// Tools that execute immediately. 51/// Tools that execute immediately.
28pub fn run(name: &str, args: &Value, cancel: &std::sync::atomic::AtomicBool) -> Result<String, String> { 52pub fn run(name: &str, args: &Value, cancel: &std::sync::atomic::AtomicBool) -> Result<String, String> {
29 match name { 53 match name {