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
fix(composio): gate toolkit tools behind scope preferences
Steven Enamakelb80c12358a90
diff --git a/crates/openhuman-core/src/flows/builder_tools/catalog_search.rs b/crates/openhuman-core/src/flows/builder_tools/catalog_search.rsindex b02e102877..f0f0322a8e 100644--- a/crates/openhuman-core/src/flows/builder_tools/catalog_search.rs+++ b/crates/openhuman-core/src/flows/builder_tools/catalog_search.rs@@ -137,7 +137,9 @@ pub(crate) async fn search_catalog(use crate::integrations::composio::contract::agent_ready_toolkits;// Curated-catalog lookups below read the module's process snapshot.- crate::integrations::composio::module_client::ensure_catalogs(config).await;+ // A failure leaves the lookups reading every toolkit as uncurated, which+ // the search already handles (it falls back to the live catalog).+ let _ = crate::integrations::composio::module_client::ensure_catalogs(config).await;let terms: Vec<String> = query.split_whitespace()diff --git a/crates/openhuman-core/src/integrations/composio/module_client.rs b/crates/openhuman-core/src/integrations/composio/module_client.rsindex 1bd9afd850..ad8084c475 100644--- a/crates/openhuman-core/src/integrations/composio/module_client.rs+++ b/crates/openhuman-core/src/integrations/composio/module_client.rs@@ -100,20 +100,28 @@ async fn prime_curated_catalogs(config: &crate::config::Config) {}}-/// Make sure the curated-catalog snapshot is filled before a synchronous-/// lookup that does not itself call the module (the agent-ready list, catalog-/// search). The module is loaded if it is not yet, then asked once per pinned-/// version; a failure is logged and the lookups read every toolkit as-/// uncurated until a later call succeeds. A build without a module loader has-/// no catalogs to read and does nothing.+/// Make sure the curated-catalog snapshot is filled before a lookup that does+/// not itself call the module (the agent-ready list, catalog search). The+/// module is loaded if it is not yet, then asked once per pinned version.+///+/// # Errors+///+/// The module could not be reached, so the snapshot is empty and an answer read+/// from it would look like "no curated toolkits" rather than "unknown". A build+/// without a module loader has no catalogs to read and answers `Ok`.#[cfg(feature = "modules")]-pub async fn ensure_catalogs(config: &crate::config::Config) {- prime_curated_catalogs(config).await;+pub async fn ensure_catalogs(config: &crate::config::Config) -> Result<(), String> {+ super::contract::curated::prime(config).await.map_err(|error| {+ tracing::debug!("[composio][curated] prime failed: {error}");+ error+ })}/// Without the module loader there is no catalog to read.#[cfg(not(feature = "modules"))]-pub async fn ensure_catalogs(_config: &crate::config::Config) {}+pub async fn ensure_catalogs(_config: &crate::config::Config) -> Result<(), String> {+ Ok(())+}/// Call one member with an argument and decode its reply.///diff --git a/crates/openhuman-core/src/integrations/composio/ops/mod.rs b/crates/openhuman-core/src/integrations/composio/ops/mod.rsindex 9dbcf4668c..51d5330c6e 100644--- a/crates/openhuman-core/src/integrations/composio/ops/mod.rs+++ b/crates/openhuman-core/src/integrations/composio/ops/mod.rs@@ -55,7 +55,8 @@ pub use triggers::{};// The `composio.{get,set}_user_scopes` handlers' storage half.pub(crate) use scope_prefs::{- load_or_default as load_user_scope_pref, save as save_user_scope_pref,+ ensure_migrated as ensure_user_scopes_migrated, load_or_default as load_user_scope_pref,+ save as save_user_scope_pref,};// ── Re-export connected_integrations public items ──────────────────────────diff --git a/crates/openhuman-core/src/integrations/composio/ops/scope_prefs.rs b/crates/openhuman-core/src/integrations/composio/ops/scope_prefs.rsindex 2f6a2f4369..24f17e0531 100644--- a/crates/openhuman-core/src/integrations/composio/ops/scope_prefs.rs+++ b/crates/openhuman-core/src/integrations/composio/ops/scope_prefs.rs@@ -108,6 +108,14 @@ async fn migrate_legacy(config: &Config) {.insert(workspace);}+/// Run the one-time legacy-file migration, so a module-side read of the+/// preference (a visibility query, a filtered listing) sees rows a user stored+/// before the preference moved into the module. Idempotent per workspace; the+/// pref reads and writes below call it themselves.+pub(crate) async fn ensure_migrated(config: &Config) {+ migrate_legacy(config).await;+}+/// The scope pref stored for `toolkit`, or the default when none is.////// **This read fails open**: a module that cannot be reached lands on thediff --git a/crates/openhuman-core/src/integrations/composio/ops/toolkits.rs b/crates/openhuman-core/src/integrations/composio/ops/toolkits.rsindex 259f2d0624..0f82b3c0b1 100644--- a/crates/openhuman-core/src/integrations/composio/ops/toolkits.rs+++ b/crates/openhuman-core/src/integrations/composio/ops/toolkits.rs@@ -82,7 +82,9 @@ pub async fn composio_list_agent_ready_toolkits(tracing::debug!("[composio] rpc list_agent_ready_toolkits");// The list is the module's, read through the process snapshot; fill it// first so this does not answer empty ahead of the first connector call.- connectors::ensure_catalogs(config).await;+ connectors::ensure_catalogs(config).await.map_err(|error| {+ format!("[composio] list_agent_ready_toolkits: curated catalogs unavailable: {error}")+ })?;let toolkits: Vec<String> = agent_ready_toolkits();let count = toolkits.len();let resp = super::super::types::ComposioAgentReadyToolkitsResponse { toolkits };diff --git a/crates/openhuman-core/src/integrations/composio/ops/tools_ops.rs b/crates/openhuman-core/src/integrations/composio/ops/tools_ops.rsindex d2f5644e9b..46b7b63b3c 100644--- a/crates/openhuman-core/src/integrations/composio/ops/tools_ops.rs+++ b/crates/openhuman-core/src/integrations/composio/ops/tools_ops.rs@@ -34,6 +34,9 @@ pub async fn composio_list_tools(};tracing::debug!(?toolkits, ?effective_tags, "[composio] rpc 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;let request = ComposioListToolsRequest {toolkits: toolkits.unwrap_or_default(),tags: effective_tags.unwrap_or_default(),diff --git a/crates/openhuman-core/src/integrations/composio/tools/list_tools.rs b/crates/openhuman-core/src/integrations/composio/tools/list_tools.rsindex 33ddcc3d8a..b0a5ecd5bc 100644--- a/crates/openhuman-core/src/integrations/composio/tools/list_tools.rs+++ b/crates/openhuman-core/src/integrations/composio/tools/list_tools.rs@@ -180,6 +180,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;let request = ComposioListToolsRequest {toolkits: toolkits.clone().unwrap_or_default(),tags: tags.clone().unwrap_or_default(),diff --git a/crates/openhuman-core/src/integrations/composio/tools/scope_gate.rs b/crates/openhuman-core/src/integrations/composio/tools/scope_gate.rsindex 3a0a7622fe..3d69c03ccc 100644--- a/crates/openhuman-core/src/integrations/composio/tools/scope_gate.rs+++ b/crates/openhuman-core/src/integrations/composio/tools/scope_gate.rs@@ -82,6 +82,9 @@ pub(super) async fn evaluate_tool_visibility(config: &Config, slug: &str) -> Too// 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;let request = VisibleToolsRequest {toolkit: toolkit.clone(),preference: None,