refactor(tools): add execute_with_context() for ToolContext
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.
This commit is contained in:
@@ -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<String> {
|
||||
// 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,
|
||||
|
||||
Reference in New Issue
Block a user