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 scope gate for tool and trigger operations
Steven Enamakela7a38c1b6334
diff --git a/crates/openhuman-core/src/integrations/composio/ops/tools_ops.rs b/crates/openhuman-core/src/integrations/composio/ops/tools_ops.rsindex 46b7b63b3c..80e33db512 100644--- a/crates/openhuman-core/src/integrations/composio/ops/tools_ops.rs+++ b/crates/openhuman-core/src/integrations/composio/ops/tools_ops.rs@@ -23,6 +23,7 @@ use tinyconnectors_bus::names::methods;/// component decides both and the two cannot disagree. A curated toolkit/// offers only the actions in its catalog.pub async fn composio_list_tools(+ ctx: &crate::core::runtime::DispatchCtx,config: &Config,toolkits: Option<Vec<String>>,tags: Option<Vec<String>>,@@ -36,7 +37,7 @@ pub async fn composio_list_tools(// The module filters the listing by the stored preference; make sure a// preference still in the legacy file is there to be applied.- super::ensure_user_scopes_migrated(config).await;+ super::ensure_user_scopes_migrated(ctx, config).await;let request = ComposioListToolsRequest {toolkits: toolkits.unwrap_or_default(),tags: effective_tags.unwrap_or_default(),diff --git a/crates/openhuman-core/src/integrations/composio/schemas/handlers_identity.rs b/crates/openhuman-core/src/integrations/composio/schemas/handlers_identity.rsindex a9088ab7e0..99e94be10c 100644--- a/crates/openhuman-core/src/integrations/composio/schemas/handlers_identity.rs+++ b/crates/openhuman-core/src/integrations/composio/schemas/handlers_identity.rs@@ -64,7 +64,7 @@ pub(super) fn handle_get_user_scopes(// unreadable" into an RPC error would make the scopes panel fail where// it used to render the defaults.let pref = match ctx.load_config().await {- Ok(config) => ops::load_user_scope_pref(&config, &toolkit).await,+ Ok(config) => ops::load_user_scope_pref(&ctx, &config, &toolkit).await,Err(error) => {tracing::warn!(method = "composio.get_user_scopes",@@ -121,7 +121,7 @@ pub(super) fn handle_set_user_scopes(// done, and `ops::user_scopes::save` refuses on the same three// grounds (no driver, no `Graph` family, backend write failure).let config = ctx.load_config().await?;- if let Err(e) = ops::save_user_scope_pref(&config, &toolkit, pref).await {+ if let Err(e) = ops::save_user_scope_pref(&ctx, &config, &toolkit, pref).await {tracing::error!(method = "composio.set_user_scopes",toolkit = %toolkit,diff --git a/crates/openhuman-core/src/integrations/composio/schemas/handlers_tools.rs b/crates/openhuman-core/src/integrations/composio/schemas/handlers_tools.rsindex 53bdad3f21..5798ffc6da 100644--- a/crates/openhuman-core/src/integrations/composio/schemas/handlers_tools.rs+++ b/crates/openhuman-core/src/integrations/composio/schemas/handlers_tools.rs@@ -14,7 +14,7 @@ pub(super) fn handle_list_tools(ctx: DispatchCtx, params: Map<String, Value>) ->let config = ctx.load_config().await?;let toolkits = read_optional::<Vec<String>>(¶ms, "toolkits")?;let tags = read_optional::<Vec<String>>(¶ms, "tags")?;- to_json(ops::composio_list_tools(&config, toolkits, tags).await?)+ to_json(ops::composio_list_tools(&ctx, &config, toolkits, tags).await?)})}diff --git a/crates/openhuman-core/src/integrations/composio/schemas/handlers_triggers.rs b/crates/openhuman-core/src/integrations/composio/schemas/handlers_triggers.rsindex 223c392e88..39e8533735 100644--- a/crates/openhuman-core/src/integrations/composio/schemas/handlers_triggers.rs+++ b/crates/openhuman-core/src/integrations/composio/schemas/handlers_triggers.rs@@ -59,7 +59,7 @@ pub(super) fn handle_list_trigger_history(let config = ctx.load_config().await?;let payload: TriggerHistoryParams = serde_json::from_value(Value::Object(params)).map_err(|e| format!("invalid params: {e}"))?;- to_json(ops::composio_list_trigger_history(&config, payload.limit).await?)+ to_json(ops::composio_list_trigger_history(&ctx, &config, payload.limit).await?)})}diff --git a/crates/openhuman-core/src/integrations/composio/tools/scope_gate.rs b/crates/openhuman-core/src/integrations/composio/tools/scope_gate.rsindex 3d69c03ccc..ff0001a0f6 100644--- a/crates/openhuman-core/src/integrations/composio/tools/scope_gate.rs+++ b/crates/openhuman-core/src/integrations/composio/tools/scope_gate.rs@@ -77,14 +77,18 @@ pub(crate) fn action_mutates_external_state(slug: &str) -> bool {/// preference and the catalog are read from the module that enforces them./// A module that cannot be reached answers as the default preference would,/// which is what the host did before the preference moved.-pub(super) async fn evaluate_tool_visibility(config: &Config, slug: &str) -> ToolDecision {+pub(super) async fn evaluate_tool_visibility(+ ctx: &crate::core::runtime::DispatchCtx,+ config: &Config,+ slug: &str,+) -> ToolDecision {let Some(toolkit) = toolkit_from_slug(slug) else {// Unparseable slug — let the backend return its own error.return ToolDecision::Allow;};// Rows still in the legacy workspace file must be in the module before it// is asked, or its default (`write` on) would outrank a stored `write=false`.- super::super::ops::ensure_user_scopes_migrated(config).await;+ super::super::ops::ensure_user_scopes_migrated(ctx, config).await;let request = VisibleToolsRequest {toolkit: toolkit.clone(),preference: None,