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 resolution
Steven Enamakel3c5dcb93ea23
diff --git a/crates/openhuman-core/src/integrations/composio/contract/curated.rs b/crates/openhuman-core/src/integrations/composio/contract/curated.rsindex 0a2d61abe2..c8f46835f8 100644--- a/crates/openhuman-core/src/integrations/composio/contract/curated.rs+++ b/crates/openhuman-core/src/integrations/composio/contract/curated.rs@@ -19,8 +19,9 @@ use tinyconnectors_bus::vocabulary::{CuratedCatalogRequest, CuratedTool, ToolScope, VocabularyRequest, VocabularyResponse,};-use super::slug::{classify_unknown, find_curated, toolkit_from_slug};-use super::UserScopePref;+use tinyconnectors_bus::vocabulary::{+ classify_unknown, find_curated, toolkit_from_slug, UserScopePref,+};const LOG: &str = "[composio][curated]";diff --git a/crates/openhuman-core/src/integrations/composio/contract/mod.rs b/crates/openhuman-core/src/integrations/composio/contract/mod.rsindex 7c7a90a39d..367c9ed240 100644--- a/crates/openhuman-core/src/integrations/composio/contract/mod.rs+++ b/crates/openhuman-core/src/integrations/composio/contract/mod.rs@@ -10,15 +10,12 @@pub mod curated;pub mod identity;-pub mod slug;pub use identity::{canonicalize_values, normalize_connection_identifiers, render_connected_identities_section,};-pub use slug::{- action_slug_matches, canonical_action_slug, classify_unknown, find_curated, toolkit_from_slug,-};pub use tinyconnectors_bus::vocabulary::{+ action_slug_matches, canonical_action_slug, classify_unknown, find_curated, toolkit_from_slug,ConnectedIdentity, CuratedTool, GithubFetchMode, IdentityKind, NormalizedTask,ProviderUserProfile, TaskContainer, TaskFetchFilter, TaskKind, ToolScope, UserScopePref,};diff --git a/crates/openhuman-core/src/integrations/composio/contract/slug.rs b/crates/openhuman-core/src/integrations/composio/contract/slug.rsdeleted file mode 100644index 4e937de2da..0000000000--- a/crates/openhuman-core/src/integrations/composio/contract/slug.rs+++ /dev/null@@ -1,134 +0,0 @@-//! Synchronous slug helpers for the Composio action slugs the host's hot-//! paths (tool visibility, flow gates, approval hooks) must classify without-//! awaiting the connector module.-//!-//! The types they return ([`ToolScope`], [`CuratedTool`], [`UserScopePref`])-//! are the connector contract's (`tinyconnectors_bus::vocabulary`); the-//! curated catalogs and the stored preference are the module's, read through-//! [`super::curated`] and `ops::scope_prefs`. What remains here is text-only-//! slug parsing that the contract does not yet serve synchronously-//! (`EvaluateActions` answers the same questions, asynchronously).--use super::{CuratedTool, ToolScope};--/// Heuristic fallback for gating a tool that is not in any provider's curated-/// list.-///-/// Prefer the curated classification when one exists; only reach for this when-/// a toolkit has no catalog or the catalog does not mention the slug. Admin-/// verbs are checked first so `MODIFY_LABELS` does not slip into the write-/// bucket on the `UPDATE` substring rule — the ordering is the whole point of-/// the function and not an implementation detail.-pub fn classify_unknown(slug: &str) -> ToolScope {- let upper = slug.to_ascii_uppercase();- const ADMIN: &[&str] = &[- "DELETE",- "TRASH",- "REMOVE",- "MODIFY_LABELS",- "SHARE",- "REVOKE",- "DESTROY",- ];- const WRITE: &[&str] = &[- "SEND", "CREATE", "UPDATE", "REPLY", "APPEND", "INSERT", "ADD", "POST", "PATCH", "WRITE",- "DRAFT",- ];- if ADMIN.iter().any(|kw| upper.contains(kw)) {- return ToolScope::Admin;- }- if WRITE.iter().any(|kw| upper.contains(kw)) {- return ToolScope::Write;- }- ToolScope::Read-}--/// Look up a slug inside a curated catalog, case-insensitively.-pub fn find_curated<'a>(catalog: &'a [CuratedTool], slug: &str) -> Option<&'a CuratedTool> {- catalog.iter().find(|t| t.slug.eq_ignore_ascii_case(slug))-}--/// Toolkits whose identifier itself contains an underscore, so the first-/// segment of their action slugs is not the toolkit: `(action prefix, toolkit)`.-/// Their real action slugs carry the prefix as written.-const MULTI_SEGMENT_TOOLKIT_PREFIXES: &[(&str, &str)] = &[- ("MICROSOFT_TEAMS_", "microsoft_teams"),- ("ONE_DRIVE_", "one_drive"),- ("ZOHO_MAIL_", "zoho_mail"),- ("GOOGLE_MAPS_", "google_maps"),-];--/// Spellings models use for toolkits whose real slugs have no separator-/// (`GOOGLE_DRIVE_FIND_FILE` for `GOOGLEDRIVE_FIND_FILE`):-/// `(alias prefix, toolkit, canonical action prefix)`. Without them the first-/// segment, `google`, names a toolkit that does not exist.-const ALIASED_TOOLKIT_PREFIXES: &[(&str, &str, &str)] = &[- ("GOOGLE_DRIVE_", "googledrive", "GOOGLEDRIVE_"),- ("GOOGLE_CALENDAR_", "googlecalendar", "GOOGLECALENDAR_"),- ("GOOGLE_SHEETS_", "googlesheets", "GOOGLESHEETS_"),- ("GOOGLE_DOCS_", "googledocs", "GOOGLEDOCS_"),- ("GOOGLE_MEET_", "googlemeet", "GOOGLEMEET_"),- ("GOOGLE_TASKS_", "googletasks", "GOOGLETASKS_"),- ("GOOGLE_SLIDES_", "googleslides", "GOOGLESLIDES_"),- ("GOOGLE_PHOTOS_", "googlephotos", "GOOGLEPHOTOS_"),- ("MICROSOFT_OUTLOOK_", "outlook", "OUTLOOK_"),-];--/// Extract the toolkit slug from a Composio action slug.-///-/// Most action slugs follow `<TOOLKIT>_<VERB>_…` — `GMAIL_SEND_EMAIL` yields-/// `gmail`. A few toolkit identifiers contain underscores themselves, so those-/// need known-prefix handling or a connected-toolkit check silently drops every-/// action for them (`ZOHO_MAIL_*` would resolve to the non-existent `zoho`).-/// Separated spellings of separator-less toolkits (`GOOGLE_DRIVE_*`) resolve to-/// the real toolkit too (`googledrive`); see [`canonical_action_slug`].-///-/// Returns `None` only for an empty or whitespace-only slug.-pub fn toolkit_from_slug(slug: &str) -> Option<String> {- let trimmed = slug.trim();- if trimmed.is_empty() {- return None;- }- let upper = trimmed.to_ascii_uppercase();- for (prefix, toolkit) in MULTI_SEGMENT_TOOLKIT_PREFIXES {- if upper.starts_with(prefix) {- return Some((*toolkit).to_string());- }- }- for (alias, toolkit, _) in ALIASED_TOOLKIT_PREFIXES {- if upper.starts_with(alias) {- return Some((*toolkit).to_string());- }- }- let prefix = trimmed.split('_').next()?;- if prefix.is_empty() {- None- } else {- Some(prefix.to_ascii_lowercase())- }-}--/// The real action slug for an aliased spelling — `GOOGLE_DRIVE_FIND_FILE`-/// becomes `GOOGLEDRIVE_FIND_FILE` — or `None` when `slug` uses no alias.-pub fn canonical_action_slug(slug: &str) -> Option<String> {- let upper = slug.trim().to_ascii_uppercase();- ALIASED_TOOLKIT_PREFIXES- .iter()- .find_map(|(alias, _, canonical)| {- upper- .strip_prefix(alias)- .map(|rest| format!("{canonical}{rest}"))- })-}--/// Whether catalog slug `candidate` is the action `requested` names, ignoring-/// case and accepting an aliased spelling ([`canonical_action_slug`]).-pub fn action_slug_matches(candidate: &str, requested: &str) -> bool {- let requested = requested.trim();- candidate.eq_ignore_ascii_case(requested)- || canonical_action_slug(requested).is_some_and(|c| candidate.eq_ignore_ascii_case(&c))-}--#[cfg(test)]-#[path = "slug_tests.rs"]-mod tests;diff --git a/crates/openhuman-core/src/integrations/composio/contract/slug_tests.rs b/crates/openhuman-core/src/integrations/composio/contract/slug_tests.rsdeleted file mode 100644index 545a2c79b5..0000000000--- a/crates/openhuman-core/src/integrations/composio/contract/slug_tests.rs+++ /dev/null@@ -1,164 +0,0 @@-//! 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)]--use super::*;--#[test]-fn destructive_verbs_classify_as_admin() {- assert_eq!(classify_unknown("GMAIL_DELETE_EMAIL"), ToolScope::Admin);- assert_eq!(classify_unknown("GMAIL_TRASH_EMAIL"), ToolScope::Admin);- assert_eq!(classify_unknown("GMAIL_MODIFY_LABELS"), ToolScope::Admin);- assert_eq!(classify_unknown("DRIVE_SHARE_FILE"), ToolScope::Admin);-}--#[test]-fn mutating_verbs_classify_as_write() {- assert_eq!(classify_unknown("GMAIL_SEND_EMAIL"), ToolScope::Write);- assert_eq!(classify_unknown("NOTION_CREATE_PAGE"), ToolScope::Write);- assert_eq!(classify_unknown("NOTION_UPDATE_PAGE"), ToolScope::Write);-}--#[test]-fn anything_else_classifies_as_read() {- assert_eq!(classify_unknown("GMAIL_FETCH_EMAILS"), ToolScope::Read);- assert_eq!(classify_unknown("NOTION_SEARCH"), ToolScope::Read);- assert_eq!(classify_unknown("GMAIL_GET_PROFILE"), ToolScope::Read);-}--#[test]-fn admin_verbs_are_checked_before_write_verbs() {- // `DELETE_DRAFT` contains `DRAFT`, a write verb. If the two lists were- // checked in the other order this would gate as a write and a destructive- // action would run under a write-only preference.- assert_eq!(classify_unknown("GMAIL_DELETE_DRAFT"), ToolScope::Admin);-}--#[test]-fn classification_ignores_slug_casing() {- assert_eq!(classify_unknown("gmail_delete_email"), ToolScope::Admin);- assert_eq!(classify_unknown("gmail_send_email"), ToolScope::Write);-}--#[test]-fn a_toolkit_slug_is_the_lowercased_first_segment() {- assert_eq!(- toolkit_from_slug("GMAIL_SEND_EMAIL").as_deref(),- Some("gmail")- );- assert_eq!(- toolkit_from_slug("NOTION_FETCH_DATA").as_deref(),- Some("notion")- );- assert_eq!(- toolkit_from_slug("noUnderscore").as_deref(),- Some("nounderscore")- );-}--#[test]-fn an_empty_slug_names_no_toolkit() {- assert_eq!(toolkit_from_slug(""), None);- assert_eq!(toolkit_from_slug(" "), None);-}--#[test]-fn multi_segment_toolkits_keep_their_whole_prefix() {- // Without these three, `ZOHO_MAIL_*` resolves to `zoho`, matches no- // connected toolkit, and every action for it is silently dropped.- assert_eq!(- toolkit_from_slug("ZOHO_MAIL_SEND_EMAIL").as_deref(),- Some("zoho_mail")- );- assert_eq!(- toolkit_from_slug("ONE_DRIVE_GET_FILE").as_deref(),- Some("one_drive")- );- assert_eq!(- toolkit_from_slug("MICROSOFT_TEAMS_SEND_MESSAGE").as_deref(),- Some("microsoft_teams")- );-}--#[test]-fn a_curated_lookup_ignores_casing_and_reports_a_miss() {- let catalog = &[CuratedTool {- toolkit: "gmail".to_string(),- slug: "GMAIL_SEND_EMAIL".to_string(),- scope: ToolScope::Write,- }];- assert!(find_curated(catalog, "gmail_send_email").is_some());- assert!(find_curated(catalog, "GMAIL_SEND_EMAIL").is_some());- assert!(find_curated(catalog, "GMAIL_DELETE_EMAIL").is_none());-}--#[test]-fn spaced_google_and_microsoft_prefixes_resolve_to_the_real_toolkit() {- // Production: `get_tool_contract { slug: "GOOGLE_DRIVE_FIND_FILE" }` looked- // up the non-existent toolkit `google` and told the model to retry a fetch- // that could never succeed.- for (slug, toolkit) in [- ("GOOGLE_DRIVE_FIND_FILE", "googledrive"),- ("GOOGLE_CALENDAR_EVENTS_LIST", "googlecalendar"),- ("GOOGLE_SHEETS_BATCH_GET", "googlesheets"),- ("GOOGLE_DOCS_GET_DOCUMENT_BY_ID", "googledocs"),- ("GOOGLE_MEET_CREATE_MEET", "googlemeet"),- ("GOOGLE_TASKS_LIST_TASKS", "googletasks"),- ("GOOGLE_SLIDES_CREATE_PRESENTATION", "googleslides"),- ("GOOGLE_PHOTOS_LIST_ALBUMS", "googlephotos"),- ("GOOGLE_MAPS_TEXT_SEARCH", "google_maps"),- ("MICROSOFT_OUTLOOK_SEND_EMAIL", "outlook"),- ("google_drive_find_file", "googledrive"),- ] {- assert_eq!(toolkit_from_slug(slug).as_deref(), Some(toolkit), "{slug}");- }- // The canonical spellings are unchanged.- assert_eq!(- toolkit_from_slug("GOOGLEDRIVE_FIND_FILE").as_deref(),- Some("googledrive")- );- assert_eq!(- toolkit_from_slug("GOOGLECALENDAR_FIND_EVENT").as_deref(),- Some("googlecalendar")- );- // A prefix only matches at a segment boundary.- assert_eq!(- toolkit_from_slug("GOOGLE_DRIVERS_X").as_deref(),- Some("google")- );-}--#[test]-fn a_spaced_alias_is_rewritten_to_the_canonical_action_slug() {- assert_eq!(- canonical_action_slug("GOOGLE_DRIVE_FIND_FILE").as_deref(),- Some("GOOGLEDRIVE_FIND_FILE")- );- assert_eq!(- canonical_action_slug("google_calendar_events_list").as_deref(),- Some("GOOGLECALENDAR_EVENTS_LIST")- );- assert_eq!(- canonical_action_slug("MICROSOFT_OUTLOOK_SEND_EMAIL").as_deref(),- Some("OUTLOOK_SEND_EMAIL")- );- // Already canonical, or a toolkit whose real actions carry the underscore.- assert_eq!(canonical_action_slug("GOOGLEDRIVE_FIND_FILE"), None);- assert_eq!(canonical_action_slug("MICROSOFT_TEAMS_SEND_MESSAGE"), None);- assert_eq!(canonical_action_slug("GMAIL_SEND_EMAIL"), None);-- assert!(action_slug_matches(- "GOOGLEDRIVE_FIND_FILE",- "GOOGLE_DRIVE_FIND_FILE"- ));- assert!(action_slug_matches(- "GOOGLEDRIVE_FIND_FILE",- "googledrive_find_file"- ));- assert!(!action_slug_matches(- "GOOGLEDRIVE_FIND_FILE",- "GOOGLE_DRIVE_LIST_FILES"- ));-}diff --git a/crates/openhuman-core/src/integrations/task_sources/types.rs b/crates/openhuman-core/src/integrations/task_sources/types.rsindex cae6741536..3b08b9c94b 100644--- a/crates/openhuman-core/src/integrations/task_sources/types.rs+++ b/crates/openhuman-core/src/integrations/task_sources/types.rs@@ -2,7 +2,8 @@//!//! A [`TaskSource`] is a user-configured pull of work items from an//! external tool (GitHub, Notion, Linear, ClickUp) with a per-provider-//! [`FilterSpec`]. The periodic poll fetches matching items, normalizes+//! [`FilterSpec`] (the provider, filter, target and reason types are the+//! connector contract's). The periodic poll fetches matching items, normalizes//! them ([`super::NormalizedTask`]), enriches them ([`EnrichedTask`]),//! and routes them onto the agent's todo board.@@ -10,165 +11,35 @@ use chrono::{DateTime, Utc};use serde::{Deserialize, Serialize};use serde_json::Value;-/// External tool a [`TaskSource`] pulls from. The string form matches-/// the Composio toolkit slug, so it keys directly into the provider-/// registry (`get_provider`).-#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]-#[serde(rename_all = "snake_case")]-pub enum ProviderSlug {- Github,- Notion,- Linear,- Clickup,-}--impl ProviderSlug {- pub fn as_str(self) -> &'static str {- match self {- Self::Github => "github",- Self::Notion => "notion",- Self::Linear => "linear",- Self::Clickup => "clickup",- }- }-- /// Parse a toolkit slug into a `ProviderSlug`. Case-insensitive.- pub fn parse(raw: &str) -> Result<Self, String> {- match raw.trim().to_ascii_lowercase().as_str() {- "github" => Ok(Self::Github),- "notion" => Ok(Self::Notion),- "linear" => Ok(Self::Linear),- "clickup" => Ok(Self::Clickup),- other => Err(format!(- "unknown task source provider '{other}' (expected github|notion|linear|clickup)"- )),- }- }-- /// Whether this provider has a working task-fetch path today.- ///- /// **This is the single place that answers the question**, so the- /// periodic scheduler and the RPC surface cannot drift apart on it.- ///- /// Every provider returns `false` right now: the pipeline's fetch step- /// (`pipeline::fetch_tasks_unavailable`) is an unconditional `Err` for- /// every toolkit, because tinymemory v1.13.4 deleted- /// `ComposioProvider::fetch_tasks` with no replacement. Nothing- /// downstream of the fetch is broken — dedup, enrichment, routing and- /// reconciliation all still work — so the moment a provider grows a real- /// fetch again this flips to `true` for that variant and the scheduler- /// starts polling it, with no other change.- ///- /// It is deliberately a per-variant `match` rather than a blanket- /// `false`: the restoration lands one toolkit at a time, and a- /// wholesale constant would have to be redesigned on the first one- /// instead of edited.- pub fn can_fetch(self) -> bool {- match self {- Self::Github | Self::Notion | Self::Linear | Self::Clickup => false,- }- }-}--/// Per-provider, user-configured filter. Tagged by `provider` on the-/// wire so the frontend can render typed pickers; each variant carries a-/// free-form `extra` object as an advanced escape hatch.-#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]-#[serde(tag = "provider", rename_all = "snake_case")]-pub enum FilterSpec {- Github {- #[serde(default, skip_serializing_if = "Option::is_none")]- repo: Option<String>,- #[serde(default)]- labels: Vec<String>,- #[serde(default)]- assignee_is_me: bool,- #[serde(default, skip_serializing_if = "Option::is_none")]- state: Option<String>,- /// How to fetch: Composio connection, local `gh`/REST, or `auto`- /// (Composio-first with local fallback). Defaults to `auto`.- #[serde(default)]- fetch_mode: crate::integrations::composio::contract::GithubFetchMode,- #[serde(default)]- extra: Value,- },- Notion {- #[serde(default, skip_serializing_if = "Option::is_none")]- database_id: Option<String>,- #[serde(default)]- assigned_to_me: bool,- #[serde(default, skip_serializing_if = "Option::is_none")]- status: Option<String>,- #[serde(default)]- extra: Value,- },- Linear {- #[serde(default, skip_serializing_if = "Option::is_none")]- team_id: Option<String>,- #[serde(default)]- assignee_is_me: bool,- #[serde(default, skip_serializing_if = "Option::is_none")]- state: Option<String>,- #[serde(default)]- extra: Value,- },- Clickup {- #[serde(default, skip_serializing_if = "Option::is_none")]- team_id: Option<String>,- #[serde(default, skip_serializing_if = "Option::is_none")]- list_id: Option<String>,- #[serde(default)]- assignee_is_me: bool,- #[serde(default)]- extra: Value,- },-}--impl FilterSpec {- /// The provider this filter targets — must match the owning- /// [`TaskSource::provider`].- pub fn provider(&self) -> ProviderSlug {- match self {- Self::Github { .. } => ProviderSlug::Github,- Self::Notion { .. } => ProviderSlug::Notion,- Self::Linear { .. } => ProviderSlug::Linear,- Self::Clickup { .. } => ProviderSlug::Clickup,- }- }-}--/// How enriched tasks are routed once fetched.-#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]-#[serde(rename_all = "snake_case")]-#[derive(Default)]-pub enum SourceTarget {- /// Append a todo card AND dispatch a triage turn so an agent may- /// start working immediately (triage still gates noise).- #[default]- AgentTodoProactive,- /// Collect into the ingestion ledger only; never auto-start an agent turn.- TodoOnly,-}--/// Why a fetch ran — mirrors the provider `SyncReason` semantics.-#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]-#[serde(rename_all = "snake_case")]-pub enum FetchReason {- /// First fetch right after an OAuth connection is created.- ConnectionCreated,- /// Periodic background poll.- Periodic,- /// Explicit user / RPC trigger.- Manual,-}+pub use tinyconnectors_bus::vocabulary::{FetchReason, FilterSpec, ProviderSlug, SourceTarget};-impl FetchReason {- pub fn as_str(self) -> &'static str {- match self {- Self::ConnectionCreated => "connection_created",- Self::Periodic => "periodic",- Self::Manual => "manual",- }+/// Whether `provider` has a working task-fetch path today.+///+/// **This is the single place that answers the question**, so the+/// periodic scheduler and the RPC surface cannot drift apart on it.+///+/// Every provider returns `false` right now: the pipeline's fetch step+/// (`pipeline::fetch_tasks_unavailable`) is an unconditional `Err` for+/// every toolkit, because tinymemory v1.13.4 deleted+/// `ComposioProvider::fetch_tasks` with no replacement. Nothing+/// downstream of the fetch is broken — dedup, enrichment, routing and+/// reconciliation all still work — so the moment a provider grows a real+/// fetch again this flips to `true` for that variant and the scheduler+/// starts polling it, with no other change.+///+/// It is deliberately a per-variant `match` rather than a blanket+/// `false`: the restoration lands one toolkit at a time, and a+/// wholesale constant would have to be redesigned on the first one+/// instead of edited. The provider and filter types themselves are the+/// connector contract's (`tinyconnectors_bus::vocabulary`); whether the host+/// can poll one is the host's call.+#[must_use]+pub fn provider_can_fetch(provider: ProviderSlug) -> bool {+ match provider {+ ProviderSlug::Github+ | ProviderSlug::Notion+ | ProviderSlug::Linear+ | ProviderSlug::Clickup => false,}}diff --git a/vendor/tinyconnectors b/vendor/tinyconnectorsindex a3485d742a..a0540851a1 160000--- a/vendor/tinyconnectors+++ b/vendor/tinyconnectors@@ -1 +1 @@-Subproject commit a3485d742adba29675eca8d996534dca6932f26c+Subproject commit a0540851a16f6a37659eccb72bdd0e67b0c88d5a