From a07be70154c9c5105be6aa809d553fcf95f49408 Mon Sep 17 00:00:00 2001 From: Sienna Meridian Satterwhite Date: Mon, 23 Mar 2026 19:23:36 +0000 Subject: [PATCH] refactor(tools): add execute_with_context() for ToolContext MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ToolRegistry gains execute_with_context(&ToolContext) which bridges to the existing execute(&ResponseContext) via a shim. The orchestrator calls only the new method — no ResponseContext in its dependency tree. --- src/tools/mod.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/tools/mod.rs b/src/tools/mod.rs index cc4e608..a5282a4 100644 --- a/src/tools/mod.rs +++ b/src/tools/mod.rs @@ -20,6 +20,7 @@ use tracing::debug; use crate::config::Config; use crate::context::ResponseContext; +use crate::orchestrator::event::ToolContext; use crate::persistence::Store; use crate::sdk::gitea::GiteaClient; use crate::sdk::kratos::KratosClient; @@ -278,6 +279,25 @@ impl ToolRegistry { allowed } + /// Execute a tool with transport-agnostic context (used by orchestrator). + pub async fn execute_with_context( + &self, + name: &str, + arguments: &str, + ctx: &ToolContext, + ) -> anyhow::Result { + // Delegate to the existing execute with a shim ResponseContext + let response_ctx = ResponseContext { + matrix_user_id: String::new(), + user_id: ctx.user_id.clone(), + display_name: None, + is_dm: ctx.is_direct, + is_reply: false, + room_id: ctx.scope_key.clone(), + }; + self.execute(name, arguments, &response_ctx).await + } + pub async fn execute( &self, name: &str,