From daba424a46ce6e00000af9b9d7e99f05c91bd8c8 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Wed, 8 Apr 2026 20:38:42 -0400 Subject: [PATCH] =?UTF-8?q?WIP:=20Fix=20Arc::new()=20wrapping=20on=20tool?= =?UTF-8?q?=20handlers=20=E2=80=94=20some=20import/paren=20issues=20remain?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Proof of Concept --- src/agent/tools/control.rs | 6 +++--- src/agent/tools/edit.rs | 2 +- src/agent/tools/glob.rs | 2 +- src/agent/tools/grep.rs | 2 +- src/agent/tools/read.rs | 2 +- src/agent/tools/vision.rs | 2 +- src/agent/tools/web.rs | 4 ++-- src/agent/tools/write.rs | 2 +- src/subconscious/digest.rs | 10 +++++----- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/agent/tools/control.rs b/src/agent/tools/control.rs index 02e5d95..14edc41 100644 --- a/src/agent/tools/control.rs +++ b/src/agent/tools/control.rs @@ -18,7 +18,7 @@ pub(super) fn tools() -> [super::Tool; 3] { a.pending_model_switch = Some(model.to_string()); } Ok(format!("Switching to model '{}' after this turn.", model)) - }) }, + })) }, Tool { name: "pause", description: "Pause all autonomous behavior. Only the user can unpause (Ctrl+P or /wake).", parameters_json: r#"{"type":"object","properties":{}}"#, @@ -29,7 +29,7 @@ pub(super) fn tools() -> [super::Tool; 3] { a.pending_dmn_pause = true; } Ok("Pausing autonomous behavior. Only user input will wake you.".into()) - }) }, + })) }, Tool { name: "yield_to_user", description: "Wait for user input before continuing. The only way to enter a waiting state.", parameters_json: r#"{"type":"object","properties":{"message":{"type":"string","description":"Optional status message"}}}"#, @@ -40,6 +40,6 @@ pub(super) fn tools() -> [super::Tool; 3] { a.pending_yield = true; } Ok(format!("Yielding. {}", msg)) - }) }, + })) }, ] } diff --git a/src/agent/tools/edit.rs b/src/agent/tools/edit.rs index f136f00..a917fc9 100644 --- a/src/agent/tools/edit.rs +++ b/src/agent/tools/edit.rs @@ -8,7 +8,7 @@ pub fn tool() -> super::Tool { name: "edit_file", description: "Perform exact string replacement in a file. The old_string must appear exactly once (unless replace_all is true). Use read_file first to see current contents.", parameters_json: r#"{"type":"object","properties":{"file_path":{"type":"string","description":"Absolute path to the file to edit"},"old_string":{"type":"string","description":"The exact text to find and replace"},"new_string":{"type":"string","description":"The replacement text"},"replace_all":{"type":"boolean","description":"Replace all occurrences (default false)"}},"required":["file_path","old_string","new_string"]}"#, - handler: Arc::new(|_a, v| Box::pin(async move { edit_file(&v)) }), + handler: Arc::new(|_a, v| Box::pin(async move { edit_file(&v) })), } } diff --git a/src/agent/tools/glob.rs b/src/agent/tools/glob.rs index ce51ad4..af4cb24 100644 --- a/src/agent/tools/glob.rs +++ b/src/agent/tools/glob.rs @@ -22,7 +22,7 @@ pub fn tool() -> super::Tool { name: "glob", description: "Find files matching a glob pattern. Returns file paths sorted by modification time (newest first).", parameters_json: r#"{"type":"object","properties":{"pattern":{"type":"string","description":"Glob pattern to match files (e.g. '**/*.rs')"},"path":{"type":"string","description":"Directory to search in (default: current directory)"}},"required":["pattern"]}"#, - handler: Arc::new(|_a, v| Box::pin(async move { glob_search(&v)) }), + handler: Arc::new(|_a, v| Box::pin(async move { glob_search(&v) })), } } diff --git a/src/agent/tools/grep.rs b/src/agent/tools/grep.rs index 213e3b4..8549d77 100644 --- a/src/agent/tools/grep.rs +++ b/src/agent/tools/grep.rs @@ -25,7 +25,7 @@ pub fn tool() -> super::Tool { name: "grep", description: "Search for a pattern in files. Returns matching file paths by default, or matching lines with context.", parameters_json: r#"{"type":"object","properties":{"pattern":{"type":"string","description":"Regex pattern to search for"},"path":{"type":"string","description":"Directory or file to search in (default: current directory)"},"glob":{"type":"string","description":"Glob pattern to filter files (e.g. '*.rs')"},"show_content":{"type":"boolean","description":"Show matching lines instead of just file paths"},"context_lines":{"type":"integer","description":"Lines of context around matches"}},"required":["pattern"]}"#, - handler: Arc::new(|_a, v| Box::pin(async move { grep(&v)) }), + handler: Arc::new(|_a, v| Box::pin(async move { grep(&v) })), } } diff --git a/src/agent/tools/read.rs b/src/agent/tools/read.rs index 330205d..4a7fa90 100644 --- a/src/agent/tools/read.rs +++ b/src/agent/tools/read.rs @@ -8,7 +8,7 @@ pub fn tool() -> super::Tool { name: "read_file", description: "Read the contents of a file. Returns the file contents with line numbers.", parameters_json: r#"{"type":"object","properties":{"file_path":{"type":"string","description":"Absolute path to the file to read"},"offset":{"type":"integer","description":"Line number to start reading from (1-based)"},"limit":{"type":"integer","description":"Maximum number of lines to read"}},"required":["file_path"]}"#, - handler: Arc::new(|_a, v| Box::pin(async move { read_file(&v)) }), + handler: Arc::new(|_a, v| Box::pin(async move { read_file(&v) })), } } diff --git a/src/agent/tools/vision.rs b/src/agent/tools/vision.rs index 965ddd6..f3bf4a2 100644 --- a/src/agent/tools/vision.rs +++ b/src/agent/tools/vision.rs @@ -23,7 +23,7 @@ pub fn tool() -> super::Tool { name: "view_image", description: "View an image file or capture a tmux pane screenshot. Supports PNG, JPEG, GIF, WebP. Use pane_id to capture a tmux pane instead.", parameters_json: r#"{"type":"object","properties":{"file_path":{"type":"string","description":"Path to an image file"},"pane_id":{"type":"string","description":"Tmux pane ID to capture (e.g. '0:1.0')"},"lines":{"type":"integer","description":"Lines to capture from tmux pane (default 50)"}}}"#, - handler: Arc::new(|_a, v| Box::pin(async move { view_image_text(&v)) }), + handler: Arc::new(|_a, v| Box::pin(async move { view_image_text(&v) })), } } diff --git a/src/agent/tools/web.rs b/src/agent/tools/web.rs index 92f3e50..3d07c29 100644 --- a/src/agent/tools/web.rs +++ b/src/agent/tools/web.rs @@ -9,13 +9,13 @@ pub fn tools() -> [super::Tool; 2] { name: "web_fetch", description: "Fetch content from a URL and return it as text. Use for reading web pages, API responses, documentation.", parameters_json: r#"{"type":"object","properties":{"url":{"type":"string","description":"The URL to fetch"}},"required":["url"]}"#, - handler: Arc::new(|_a, v| Box::pin(async move { web_fetch(&v).await }), + handler: Arc::new(|_a, v| Box::pin(async move { web_fetch(&v).await })), }, super::Tool { name: "web_search", description: "Search the web and return results. Use for finding documentation, looking up APIs, researching topics.", parameters_json: r#"{"type":"object","properties":{"query":{"type":"string","description":"The search query"},"num_results":{"type":"integer","description":"Number of results to return (default 5)"}},"required":["query"]}"#, - handler: Arc::new(|_a, v| Box::pin(async move { web_search(&v).await }), + handler: Arc::new(|_a, v| Box::pin(async move { web_search(&v).await })), }, ] } diff --git a/src/agent/tools/write.rs b/src/agent/tools/write.rs index 48a99ee..6147bf2 100644 --- a/src/agent/tools/write.rs +++ b/src/agent/tools/write.rs @@ -8,7 +8,7 @@ pub fn tool() -> super::Tool { name: "write_file", description: "Create or overwrite a file with the given content.", parameters_json: r#"{"type":"object","properties":{"file_path":{"type":"string","description":"Absolute path to write"},"content":{"type":"string","description":"File content"}},"required":["file_path","content"]}"#, - handler: Arc::new(|_a, v| Box::pin(async move { write_file(&v)) }), + handler: Arc::new(|_a, v| Box::pin(async move { write_file(&v) })), } } diff --git a/src/subconscious/digest.rs b/src/subconscious/digest.rs index aab7bed..3aef33e 100644 --- a/src/subconscious/digest.rs +++ b/src/subconscious/digest.rs @@ -663,31 +663,31 @@ pub fn digest_tools() -> [super::super::agent::tools::Tool; 5] { name: "digest_daily", description: "Generate a daily digest from journal entries.", parameters_json: r#"{"type":"object","properties":{"date":{"type":"string","description":"Date in YYYY-MM-DD format"}}, "required":["date"]}"#, - handler: Arc::new(|_a, v| Box::pin(async move { handle_digest_daily(_a, v).await }), + handler: Arc::new(|_a, v| Box::pin(async move { handle_digest_daily(_a, v).await })), }, Tool { name: "digest_weekly", description: "Generate a weekly digest from daily digests.", parameters_json: r#"{"type":"object","properties":{"week":{"type":"string","description":"Week label (YYYY-W##) or date (YYYY-MM-DD)"}}, "required":["week"]}"#, - handler: Arc::new(|_a, v| Box::pin(async move { handle_digest_weekly(_a, v).await }), + handler: Arc::new(|_a, v| Box::pin(async move { handle_digest_weekly(_a, v).await })), }, Tool { name: "digest_monthly", description: "Generate a monthly digest from weekly digests.", parameters_json: r#"{"type":"object","properties":{"month":{"type":"string","description":"Month label (YYYY-MM) or date (YYYY-MM-DD)"}}, "required":["month"]}"#, - handler: Arc::new(|_a, v| Box::pin(async move { handle_digest_monthly(_a, v).await }), + handler: Arc::new(|_a, v| Box::pin(async move { handle_digest_monthly(_a, v).await })), }, Tool { name: "digest_auto", description: "Auto-generate all missing digests (daily, weekly, monthly) for past dates that have content but no digest yet.", parameters_json: r#"{"type":"object","properties":{}}"#, - handler: Arc::new(|_a, v| Box::pin(async move { handle_digest_auto(_a, v).await }), + handler: Arc::new(|_a, v| Box::pin(async move { handle_digest_auto(_a, v).await })), }, Tool { name: "digest_links", description: "Parse and apply structural links from digest nodes to the memory graph.", parameters_json: r#"{"type":"object","properties":{}}"#, - handler: Arc::new(|_a, v| Box::pin(async move { handle_digest_links(_a, v).await }), + handler: Arc::new(|_a, v| Box::pin(async move { handle_digest_links(_a, v).await })), }, ] }