The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
feat(composio): add tool execution and listing support
Steven Enamakel5f1116855dab
diff --git a/crates/openhuman-core/src/integrations/composio/tools/execute.rs b/crates/openhuman-core/src/integrations/composio/tools/execute.rsindex 8259a27fc8..b0be7570ec 100644--- a/crates/openhuman-core/src/integrations/composio/tools/execute.rs+++ b/crates/openhuman-core/src/integrations/composio/tools/execute.rs@@ -10,9 +10,10 @@ use serde_json::{json, Value};use super::live_config::live_composio_config;use super::redact::redact_composio_outcome;use crate::agent::tinyagents::host::run_context::{- sandbox_mode_for_tool, task_recency_window_for_tool,+ dispatch_ctx_for_tool, sandbox_mode_for_tool, task_recency_window_for_tool,};use crate::config::Config;+use crate::core::runtime::DispatchCtx;use tinyagents_definition::SandboxMode;use tinytools::{PermissionLevel, Tool, ToolCallOptions, ToolCategory, ToolResult, ToolRunContext};@@ -101,7 +102,9 @@ impl Tool for ComposioExecuteTool {ToolCategory::Workflow}async fn execute(&self, args: Value) -> anyhow::Result<ToolResult> {- let (config, outcome) = Box::pin(self.execute_unredacted(args, None, None, None)).await;+ let ctx = dispatch_ctx_for_tool(None);+ let (config, outcome) =+ Box::pin(self.execute_unredacted(&ctx, args, None, None, None)).await;redact_composio_outcome(&config, outcome)}async fn execute_with_context(@@ -110,7 +113,9 @@ impl Tool for ComposioExecuteTool {_options: ToolCallOptions,context: Option<&dyn ToolRunContext>,) -> anyhow::Result<ToolResult> {+ let ctx = dispatch_ctx_for_tool(context);let (config, outcome) = Box::pin(self.execute_unredacted(+ &ctx,args,sandbox_mode_for_tool(context),task_recency_window_for_tool(context),@@ -130,6 +135,7 @@ impl ComposioExecuteTool {/// registered.async fn execute_unredacted(&self,+ ctx: &DispatchCtx,args: Value,sandbox_mode: Option<SandboxMode>,task_recency_window: Option<std::time::Duration>,@@ -215,11 +221,11 @@ impl ComposioExecuteTool {// hazard the composio client resolution below guards against, and// restructuring the reload earlier would move it ahead of the// sandbox/task-window setup this function does first.- match evaluate_tool_visibility(self.config.as_ref(), &tool).await {+ match evaluate_tool_visibility(ctx, self.config.as_ref(), &tool).await {ToolDecision::Allow | ToolDecision::PassthroughCheckScope { .. } => {}ToolDecision::BlockedByScope { scope } => {let toolkit = toolkit_from_slug(&tool).unwrap_or_default();- let pref = load_user_scope_pref(self.config.as_ref(), &toolkit).await;+ let pref = load_user_scope_pref(ctx, self.config.as_ref(), &toolkit).await;let msg = scope_error_message(&tool, scope, pref);tracing::info!(tool = %tool,diff --git a/crates/openhuman-core/src/integrations/composio/tools/list_tools.rs b/crates/openhuman-core/src/integrations/composio/tools/list_tools.rsindex b0a5ecd5bc..c5aa0380df 100644--- a/crates/openhuman-core/src/integrations/composio/tools/list_tools.rs+++ b/crates/openhuman-core/src/integrations/composio/tools/list_tools.rs@@ -73,7 +73,17 @@ impl Tool for ComposioListToolsTool {args: Value,options: ToolCallOptions,) -> anyhow::Result<ToolResult> {- let (config, outcome) = Box::pin(self.execute_unredacted(args, options)).await;+ self.execute_with_context(args, options, None).await+ }++ async fn execute_with_context(+ &self,+ args: Value,+ options: ToolCallOptions,+ context: Option<&dyn ToolRunContext>,+ ) -> anyhow::Result<ToolResult> {+ let ctx = dispatch_ctx_for_tool(context);+ let (config, outcome) = Box::pin(self.execute_unredacted(&ctx, args, options)).await;redact_composio_outcome(&config, outcome)}@@ -89,6 +99,7 @@ impl ComposioListToolsTool {/// this tool was registered.async fn execute_unredacted(&self,+ ctx: &DispatchCtx,args: Value,options: ToolCallOptions,) -> (Box<Config>, anyhow::Result<ToolResult>) {@@ -180,7 +191,7 @@ impl ComposioListToolsTool {// The module owns the route's query construction and applies the// user's stored scope preference to the listing (the default request),// so the host does not filter a second time.- super::super::ops::ensure_user_scopes_migrated(&live_config).await;+ super::super::ops::ensure_user_scopes_migrated(ctx, &live_config).await;let request = ComposioListToolsRequest {toolkits: toolkits.clone().unwrap_or_default(),tags: tags.clone().unwrap_or_default(),