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 curated toolkit slug validation
Steven Enamakel134d12faf994
diff --git a/crates/openhuman-core/src/integrations/composio/contract/curated.rs b/crates/openhuman-core/src/integrations/composio/contract/curated.rsindex e66f9bc623..e14f556cda 100644--- a/crates/openhuman-core/src/integrations/composio/contract/curated.rs+++ b/crates/openhuman-core/src/integrations/composio/contract/curated.rs@@ -16,11 +16,11 @@ use std::sync::{Arc, Mutex, RwLock};use tinyconnectors_bus::names::methods;use tinyconnectors_bus::vocabulary::{- CuratedCatalogRequest, CuratedTool as BusCuratedTool, ToolScope as BusScope, VocabularyRequest,- VocabularyResponse,+ CuratedCatalogRequest, CuratedTool, ToolScope, VocabularyRequest, VocabularyResponse,};-use super::scopes::{CuratedTool, ToolScope};+use super::slug::{classify_unknown, find_curated, toolkit_from_slug};+use super::UserScopePref;const LOG: &str = "[composio][curated]";@@ -53,6 +53,8 @@ struct Snapshot {native: HashSet<String>,/// Canonical toolkits with a catalog, in the module's order.toolkits: Vec<String>,+ /// The module's agent-ready toolkit list, sorted.+ agent_ready: Vec<String>,}fn store() -> &'static RwLock<Option<Arc<Snapshot>>> {@@ -84,7 +86,7 @@ fn test_fixture() -> Arc<Snapshot> {#[derive(serde::Deserialize)]struct Row {slug: String,- scope: BusScope,+ scope: ToolScope,}let actions: HashMap<String, Vec<Row>> =serde_json::from_str(include_str!("curated_fixtures/catalog-actions.json"))@@ -111,7 +113,13 @@ fn test_fixture() -> Arc<Snapshot> {.collect();let vocabulary = VocabularyResponse {toolkits,- agent_ready_toolkits: Vec::new(),+ agent_ready_toolkits: vec![+ "github".to_owned(),+ "gmail".to_owned(),+ "linear".to_owned(),+ "notion".to_owned(),+ "slack".to_owned(),+ ],};Arc::new(build("fixture", &[], &vocabulary))})@@ -134,14 +142,6 @@ fn intern(text: &str) -> &'static str {leaked}-fn scope(bus: BusScope) -> ToolScope {- match bus {- BusScope::Read => ToolScope::Read,- BusScope::Write => ToolScope::Write,- BusScope::Admin => ToolScope::Admin,- }-}-fn key(toolkit: &str) -> String {toolkit.trim().to_ascii_lowercase()}@@ -150,7 +150,7 @@ fn key(toolkit: &str) -> String {/// without a loaded module.fn build(module_version: &str,- listed: &[BusCuratedTool],+ listed: &[CuratedTool],vocabulary: &VocabularyResponse,) -> Snapshot {let mut snapshot = Snapshot {@@ -174,13 +174,17 @@ fn build(let catalog: Arc<[CuratedTool]> = actions.iter().map(|action| CuratedTool {- slug: intern(&action.slug),- scope: scope(action.scope),+ toolkit: entry.toolkit.clone(),+ slug: action.slug.clone(),+ scope: action.scope,}).collect();snapshot.catalogs.insert(name, catalog);}}+ snapshot.agent_ready = vocabulary.agent_ready_toolkits.clone();+ snapshot.agent_ready.sort_unstable();+ snapshot.agent_ready.dedup();snapshot}@@ -197,7 +201,7 @@ pub async fn prime(config: &crate::config::Config) -> Result<(), String> {if current().is_some_and(|snapshot| snapshot.module_version == version) {return Ok(());}- let listed: Vec<BusCuratedTool> = crate::modules::connectors::call_stateless(+ let listed: Vec<CuratedTool> = crate::modules::connectors::call_stateless(config,methods::LIST_CURATED_CATALOG,CuratedCatalogRequest { toolkit: None },@@ -238,7 +242,7 @@ pub fn invalidate() {/// Replace the snapshot directly. Test seam for callers that exercise the/// host adapters without a loaded module.#[cfg(test)]-pub(crate) fn install_for_test(listed: &[BusCuratedTool], vocabulary: &VocabularyResponse) {+pub(crate) fn install_for_test(listed: &[CuratedTool], vocabulary: &VocabularyResponse) {*store().write().unwrap_or_else(std::sync::PoisonError::into_inner) =@@ -251,6 +255,12 @@ pub fn catalog_for_toolkit(toolkit: &str) -> Option<Arc<[CuratedTool]>> {current()?.catalogs.get(&key(toolkit)).cloned()}+/// Toolkits the module marks agent-ready, sorted. Empty until [`prime`] runs.+#[must_use]+pub fn agent_ready_toolkits() -> Vec<String> {+ current().map(|s| s.agent_ready.clone()).unwrap_or_default()+}+/// Canonical toolkits that have a curated catalog.#[must_use]pub fn curated_toolkits() -> Vec<String> {@@ -275,8 +285,7 @@ pub fn toolkit_description(toolkit: &str) -> &'static str {/// already-loaded user scope preference? See `ListTools`: the module applies/// the same rule when it lists tools.#[must_use]-pub fn is_action_visible_with_pref(slug: &str, pref: &super::scopes::UserScopePref) -> bool {- use super::scopes::{classify_unknown, find_curated, toolkit_from_slug};+pub fn is_action_visible_with_pref(slug: &str, pref: &UserScopePref) -> bool {let Some(toolkit) = toolkit_from_slug(slug) else {return true;};@@ -289,7 +298,6 @@ pub fn is_action_visible_with_pref(slug: &str, pref: &super::scopes::UserScopePr/// The curated scope `slug` requires, if it appears in a catalog.#[must_use]pub fn curated_scope_for(slug: &str) -> Option<ToolScope> {- use super::scopes::{find_curated, toolkit_from_slug};let catalog = catalog_for_toolkit(&toolkit_from_slug(slug)?)?;find_curated(&catalog, slug).map(|c| c.scope)}diff --git a/crates/openhuman-core/src/integrations/composio/contract/mod.rs b/crates/openhuman-core/src/integrations/composio/contract/mod.rsindex 5b480ec1e6..595e60ba38 100644--- a/crates/openhuman-core/src/integrations/composio/contract/mod.rs+++ b/crates/openhuman-core/src/integrations/composio/contract/mod.rs@@ -1,28 +1,29 @@//! The Composio vocabulary the host's integration code shares: the toolkit//! catalogs (curated action lists and descriptions, read from the connector//! module), connected-identity-//! profiles, per-toolkit user scope preferences and the-//! normalised task shape.+//! profiles and the normalised task shape. The scope vocabulary+//! ([`ToolScope`], [`UserScopePref`], [`CuratedTool`]) is the connector+//! contract's, re-exported here for the host's callers.//!//! These shapes live beside the integration that produces and reads them.//! They are plain data and pure functions: no HTTP, no persistence.pub mod curated;pub mod profile;-pub mod scopes;+pub mod slug;pub mod tasks;pub use profile::{canonicalize, normalize_connection_identifier, render_connected_identities_section,ConnectedIdentity, IdentityKind, ProviderUserProfile,};-pub use scopes::{- action_slug_matches, agent_ready_toolkits, canonical_action_slug, classify_unknown,- find_curated, toolkit_from_slug, CuratedTool, ToolScope, UserScopePref,+pub use slug::{+ action_slug_matches, canonical_action_slug, classify_unknown, find_curated, toolkit_from_slug,};+pub use tinyconnectors_bus::vocabulary::{CuratedTool, ToolScope, UserScopePref};pub use tasks::{GithubFetchMode, NormalizedTask, TaskContainer, TaskFetchFilter, TaskKind};pub use curated::{- catalog_for_toolkit, curated_scope_for, curated_toolkits, has_native_provider,+ agent_ready_toolkits, catalog_for_toolkit, curated_scope_for, curated_toolkits, has_native_provider,is_action_visible_with_pref, toolkit_description,};diff --git a/crates/openhuman-core/src/integrations/composio/contract/slug_tests.rs b/crates/openhuman-core/src/integrations/composio/contract/slug_tests.rsindex 8462ec5db9..545a2c79b5 100644--- a/crates/openhuman-core/src/integrations/composio/contract/slug_tests.rs+++ b/crates/openhuman-core/src/integrations/composio/contract/slug_tests.rs@@ -1,12 +1,6 @@-//! Tests for the action-scope classification and the per-toolkit preference.-//!-//! The storage half — reading and writing a [`super::UserScopePref`] through-//! the key/value seam — is tested in the engine crate next to the code that-//! performs it. What is pinned here is everything two separately compiled-//! processes have to agree on: the verb precedence in-//! [`super::classify_unknown`], the multi-segment toolkit prefixes, the-//! persisted preference shape, and the default that decides what a brand-new-//! connection is allowed to do.+//! Pins the text-only slug helpers: verb precedence in+//! [`super::classify_unknown`], the multi-segment toolkit prefixes and the+//! alias rewrite.#![allow(clippy::expect_used, clippy::unwrap_used, clippy::panic)]