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
style(composio): reformat composio flow and contract modules
Steven Enamakelf3ec66247643
diff --git a/crates/openhuman-core/src/flows/ops/catalog.rs b/crates/openhuman-core/src/flows/ops/catalog.rsindex 3f742067bd..358dd835c0 100644--- a/crates/openhuman-core/src/flows/ops/catalog.rs+++ b/crates/openhuman-core/src/flows/ops/catalog.rs@@ -1,9 +1,7 @@use super::*;-pub(crate) use crate::integrations::composio::catalog::{- lookup_contract, ContractLookupError,-};pub(crate) use crate::integrations::composio::catalog::toolkit_for_contract_slug;+pub(crate) use crate::integrations::composio::catalog::{lookup_contract, ContractLookupError};// ─────────────────────────────────────────────────────────────────────────────// Catalog RPCs for the UI (Phase 5, item 16) — one implementation, two consumersdiff --git a/crates/openhuman-core/src/flows/ops/connection_ref_gate.rs b/crates/openhuman-core/src/flows/ops/connection_ref_gate.rsindex bde19edd12..b9042ce5de 100644--- a/crates/openhuman-core/src/flows/ops/connection_ref_gate.rs+++ b/crates/openhuman-core/src/flows/ops/connection_ref_gate.rs@@ -81,10 +81,13 @@ pub(super) fn validate_connection_refs_against(}).collect();let accounts = connections.map(|items| {- items.iter().map(|item| ConnectedAccountRef {- connection_ref: item.connection_ref.clone(),- toolkit: item.toolkit.clone(),- }).collect::<Vec<_>>()+ items+ .iter()+ .map(|item| ConnectedAccountRef {+ connection_ref: item.connection_ref.clone(),+ toolkit: item.toolkit.clone(),+ })+ .collect::<Vec<_>>()});validate(&nodes, accounts.as_deref())}diff --git a/crates/openhuman-core/src/flows/ops/connections.rs b/crates/openhuman-core/src/flows/ops/connections.rsindex 2a358c1576..65117944f9 100644--- a/crates/openhuman-core/src/flows/ops/connections.rs+++ b/crates/openhuman-core/src/flows/ops/connections.rs@@ -159,11 +159,8 @@ pub(super) fn build_flow_connections(identities: &[crate::integrations::composio::contract::ConnectedIdentity],keys: &std::collections::HashMap<String, String>,) -> Vec<FlowConnection> {- let entries = crate::integrations::composio::ops::flow_connection_entries(- &composio,- identities,- keys,- );+ let entries =+ crate::integrations::composio::ops::flow_connection_entries(&composio, identities, keys);let mut out = Vec::with_capacity(composio.len() + http.len());out.extend(entries.into_iter().map(|entry| FlowConnection {connection_ref: entry.connection_ref,diff --git a/crates/openhuman-core/src/flows/ops/tool_contract_gate.rs b/crates/openhuman-core/src/flows/ops/tool_contract_gate.rsindex da346107f5..a41e8f48ad 100644--- a/crates/openhuman-core/src/flows/ops/tool_contract_gate.rs+++ b/crates/openhuman-core/src/flows/ops/tool_contract_gate.rs@@ -61,13 +61,17 @@ pub(crate) async fn validate_tool_contracts(config: &Config, graph: &WorkflowGravalidate_tool_contract_nodes, ToolContractNode,};- let nodes: Vec<_> = graph.nodes.iter()+ let nodes: Vec<_> = graph+ .nodes+ .iter().filter(|node| node.kind == NodeKind::ToolCall)- .filter_map(|node| Some(ToolContractNode {- id: node.id.clone(),- slug: node.config.get("slug")?.as_str()?.to_string(),- args: node.config.get("args").cloned().unwrap_or(Value::Null),- }))+ .filter_map(|node| {+ Some(ToolContractNode {+ id: node.id.clone(),+ slug: node.config.get("slug")?.as_str()?.to_string(),+ args: node.config.get("args").cloned().unwrap_or(Value::Null),+ })+ }).collect();validate_tool_contract_nodes(config, &nodes).await}diff --git a/crates/openhuman-core/src/integrations/composio/catalog.rs b/crates/openhuman-core/src/integrations/composio/catalog.rsindex df067b84a5..6ff52273b9 100644--- a/crates/openhuman-core/src/integrations/composio/catalog.rs+++ b/crates/openhuman-core/src/integrations/composio/catalog.rs@@ -38,7 +38,9 @@ pub(crate) async fn lookup_contract() -> Result<(ToolContract, Option<&'static str>), ContractLookupError> {let trimmed = slug.trim();let Some(toolkit) = toolkit_for_contract_slug(trimmed) else {- return Err(ContractLookupError::InvalidSlug { slug: slug.to_string() });+ return Err(ContractLookupError::InvalidSlug {+ slug: slug.to_string(),+ });};let Some(catalog) = fetch_live_toolkit_catalog(config, &toolkit).await else {return Err(ContractLookupError::CatalogUnavailable { toolkit });@@ -46,10 +48,13 @@ pub(crate) async fn lookup_contract(let Some(contract) = catalog.iter().find(|contract| {crate::integrations::composio::contract::action_slug_matches(&contract.slug, trimmed)}) else {- return Err(ContractLookupError::ActionNotFound { slug: trimmed.to_string(), toolkit });+ return Err(ContractLookupError::ActionNotFound {+ slug: trimmed.to_string(),+ toolkit,+ });};- let warning = (!contract.is_curated && has_curated_catalog(&toolkit))- .then_some(RUNTIME_GATE_WARNING);+ let warning =+ (!contract.is_curated && has_curated_catalog(&toolkit)).then_some(RUNTIME_GATE_WARNING);Ok((contract.clone(), warning))}diff --git a/crates/openhuman-core/src/integrations/composio/contract/validation.rs b/crates/openhuman-core/src/integrations/composio/contract/validation.rsindex bc11a87afa..d55d987163 100644--- a/crates/openhuman-core/src/integrations/composio/contract/validation.rs+++ b/crates/openhuman-core/src/integrations/composio/contract/validation.rs@@ -61,7 +61,8 @@ pub(crate) fn validate_connection_refs(let mut errors = Vec::new();for node in nodes {let slug = node.slug.as_str();- if slug.starts_with('=') || slug.starts_with("oh:") || node.connection_ref.trim().is_empty() {+ if slug.starts_with('=') || slug.starts_with("oh:") || node.connection_ref.trim().is_empty()+ {continue;}let Some(slug_toolkit) = toolkit_from_slug(slug) else {@@ -90,13 +91,20 @@ pub(crate) fn validate_connection_refs());continue;}- let Some(connections) = connections else { continue };+ let Some(connections) = connections else {+ continue;+ };let id_exists = connections.iter().any(|connection| {- connection.toolkit.as_deref().is_some_and(|toolkit| toolkit.eq_ignore_ascii_case(&slug_toolkit))+ connection+ .toolkit+ .as_deref()+ .is_some_and(|toolkit| toolkit.eq_ignore_ascii_case(&slug_toolkit))&& parse_composio_connection_ref(&connection.connection_ref).is_some_and(|(_, id)| id.eq_ignore_ascii_case(ref_id))});- if id_exists { continue; }+ if id_exists {+ continue;+ }match first_connection_ref_for_toolkit(connections, &slug_toolkit) {Some(reference) => errors.push(format!("Node '{}': `connection_ref` `{conn_ref}` does not match any connected `{slug_toolkit}` account — did you mean `{reference}`?",@@ -136,46 +144,77 @@ pub(crate) async fn validate_tool_contract_nodes(.find(|item| contract::action_slug_matches(&item.slug, slug))else {tracing::warn!(target: "flows", node = %node.id, %slug, %toolkit, "[flows] tool-contract check: slug is not a real action in the live catalog — rejecting");- errors.push(format!("Node '{}': `{slug}` is not a real action in the `{toolkit}` toolkit's live \+ errors.push(format!(+ "Node '{}': `{slug}` is not a real action in the `{toolkit}` toolkit's live \Composio catalog — use search_tool_catalog {{ query: ..., toolkit: \"{toolkit}\" \- }} to find a real action slug.", node.id));+ }} to find a real action slug.",+ node.id+ ));continue;};if catalog::has_curated_catalog(&toolkit) && !action.is_curated {tracing::warn!(target: "flows", node = %node.id, %slug, %toolkit, "[flows] tool-contract check: slug is real but not curated for a statically-catalogued toolkit — rejecting to match the runtime allowlist");- errors.push(format!("Node '{}': `{slug}` is a real `{toolkit}` action but not one of OpenHuman's \+ errors.push(format!(+ "Node '{}': `{slug}` is a real `{toolkit}` action but not one of OpenHuman's \curated actions for `{toolkit}` — the runtime tool gate only allows curated \actions for toolkits with a curated catalog, so this would be rejected on \every run. Use search_tool_catalog {{ query: ..., toolkit: \"{toolkit}\" }} and \- pick a result with `featured: true`.", node.id));+ pick a result with `featured: true`.",+ node.id+ ));continue;}- let missing: Vec<_> = action.required_args.iter()+ let missing: Vec<_> = action+ .required_args+ .iter().filter(|name| node.args.get(name.as_str()).is_none_or(Value::is_null)).collect();if !missing.is_empty() {tracing::warn!(target: "flows", node = %node.id, %slug, ?missing, "[flows] tool-contract check: required arg(s) missing or null — rejecting");- let list = missing.iter().map(|name| format!("`{name}`")).collect::<Vec<_>>().join(", ");- errors.push(format!("Node '{}': tool_call `{slug}` is missing required arg(s) {list} — wire each \+ let list = missing+ .iter()+ .map(|name| format!("`{name}`"))+ .collect::<Vec<_>>()+ .join(", ");+ errors.push(format!(+ "Node '{}': tool_call `{slug}` is missing required arg(s) {list} — wire each \from an upstream node's output, e.g. \"{}\": \\"=nodes.<node_id>.item.json.<field>\" (call get_tool_contract {{ slug: \- \"{slug}\" }} for the exact required_args list).", node.id, missing[0]));+ \"{slug}\" }} for the exact required_args list).",+ node.id, missing[0]+ ));}if let Some(unsupported) = unsupported_arg_names(action.input_schema.as_ref(), &node.args) {if !unsupported.is_empty() {- let mut valid_names = action.input_schema.as_ref()+ let mut valid_names = action+ .input_schema+ .as_ref().and_then(|schema| schema.get("properties")).and_then(Value::as_object).map(|properties| properties.keys().cloned().collect::<Vec<_>>()).unwrap_or_default();valid_names.sort();tracing::warn!(target: "flows", node = %node.id, %slug, ?unsupported, ?valid_names, "[flows] tool-contract check: arg name(s) not declared by the action's input schema — rejecting");- let bad_list = unsupported.iter().map(|name| format!("`{name}`")).collect::<Vec<_>>().join(", ");- let valid_suffix = if valid_names.is_empty() { String::new() } else { format!(" — valid arg names for `{slug}` are: {}", valid_names.join(", ")) };- errors.push(format!("Node '{}': tool_call `{slug}` has unsupported arg name(s) {bad_list} — not \+ let bad_list = unsupported+ .iter()+ .map(|name| format!("`{name}`"))+ .collect::<Vec<_>>()+ .join(", ");+ let valid_suffix = if valid_names.is_empty() {+ String::new()+ } else {+ format!(+ " — valid arg names for `{slug}` are: {}",+ valid_names.join(", ")+ )+ };+ errors.push(format!(+ "Node '{}': tool_call `{slug}` has unsupported arg name(s) {bad_list} — not \a property of this action's input schema{valid_suffix}. Call \get_tool_contract {{ slug: \"{slug}\" }} and use the exact property names \- from `input_schema` (never guess an arg name).", node.id));+ from `input_schema` (never guess an arg name).",+ node.id+ ));}}}@@ -184,19 +223,32 @@ pub(crate) async fn validate_tool_contract_nodes(fn unsupported_arg_names(schema: Option<&Value>, args: &Value) -> Option<Vec<String>> {let schema = schema?.as_object()?;- if schema.get("additionalProperties").is_some_and(|value| value.as_bool() == Some(true) || value.is_object()) {+ if schema+ .get("additionalProperties")+ .is_some_and(|value| value.as_bool() == Some(true) || value.is_object())+ {return None;}let properties = schema.get("properties")?.as_object()?;let patterns = match schema.get("patternProperties").and_then(Value::as_object) {- Some(patterns) => patterns.keys().map(|pattern| regex::Regex::new(pattern))- .collect::<Result<Vec<_>, _>>().ok()?,+ Some(patterns) => patterns+ .keys()+ .map(|pattern| regex::Regex::new(pattern))+ .collect::<Result<Vec<_>, _>>()+ .ok()?,None => Vec::new(),};- let Some(args) = args.as_object() else { return Some(Vec::new()) };- let mut unsupported = args.keys().filter(|key| {- !properties.contains_key(key.as_str()) && !patterns.iter().any(|pattern| pattern.is_match(key))- }).cloned().collect::<Vec<_>>();+ let Some(args) = args.as_object() else {+ return Some(Vec::new());+ };+ let mut unsupported = args+ .keys()+ .filter(|key| {+ !properties.contains_key(key.as_str())+ && !patterns.iter().any(|pattern| pattern.is_match(key))+ })+ .cloned()+ .collect::<Vec<_>>();unsupported.sort();Some(unsupported)}diff --git a/crates/openhuman-core/src/integrations/composio/flow_gate.rs b/crates/openhuman-core/src/integrations/composio/flow_gate.rsindex eea1a3df94..55c1e8a4eb 100644--- a/crates/openhuman-core/src/integrations/composio/flow_gate.rs+++ b/crates/openhuman-core/src/integrations/composio/flow_gate.rs@@ -79,16 +79,23 @@ pub(crate) async fn flow_tool_allowed(}if !connected_toolkits.is_some_and(|toolkits| {- toolkits.iter().any(|item| item.eq_ignore_ascii_case(&toolkit))+ toolkits+ .iter()+ .any(|item| item.eq_ignore_ascii_case(&toolkit))}) {tracing::debug!(target: "flows", %slug, %toolkit, "[flows] tool_call curation: reject — toolkit has no static catalog and is not connected");return false;}- let Some(live_catalog) = crate::integrations::composio::catalog::fetch_live_toolkit_catalog(config, &toolkit).await else {+ let Some(live_catalog) =+ crate::integrations::composio::catalog::fetch_live_toolkit_catalog(config, &toolkit).await+ else {tracing::warn!(target: "flows", %slug, %toolkit, "[flows] tool_call curation: reject — connected but the live catalog fetch failed (fail-closed)");return false;};- if !live_catalog.iter().any(|item| item.slug.eq_ignore_ascii_case(slug)) {+ if !live_catalog+ .iter()+ .any(|item| item.slug.eq_ignore_ascii_case(slug))+ {tracing::debug!(target: "flows", %slug, %toolkit, "[flows] tool_call curation: reject — slug is not a real action in this toolkit's live catalog");return false;}@@ -165,7 +172,9 @@ pub(crate) async fn preflight_composio_args(tracing::warn!(target: "flows", %slug, error = %error, "[flows] preflight: static arg rule rejected the call — failing before dispatch");return Err(format!("tool_call `{slug}`: {error}"));}- let Some(required) = crate::integrations::composio::catalog::composio_required_args(config, slug).await else {+ let Some(required) =+ crate::integrations::composio::catalog::composio_required_args(config, slug).await+ else {tracing::info!(target: "flows", %slug, "[flows] preflight: no live catalog schema for action — required-arg check limited to static rules");return Ok(());};@@ -178,7 +187,11 @@ pub(crate) async fn preflight_composio_args(return Ok(());}tracing::warn!(target: "flows", %slug, ?missing, "[flows] preflight: required arg(s) missing or null — failing before dispatch");- let list = missing.iter().map(|name| format!("`{name}`")).collect::<Vec<_>>().join(", ");+ let list = missing+ .iter()+ .map(|name| format!("`{name}`"))+ .collect::<Vec<_>>()+ .join(", ");let first = missing[0];Err(format!("tool_call `{slug}`: required arg(s) {list} missing or resolved to null — wire each from an upstream node's output, e.g. \"{first}\": \"=nodes.<node_id>.item.json.<field>\" (drop `.json` only if `<node_id>` is a code/transform/split_out/merge/trigger node — `agent`/`tool_call`/`http_request` nodes wrap their output in a `{{json,text,raw}}` envelope). If the value comes from an agent node, give that agent an output schema (config.output_parser.schema) so its fields are addressable."))}@@ -197,5 +210,7 @@ pub(crate) fn reject_unsuccessful_composio_response(.map(str::trim).filter(|value| !value.is_empty()).unwrap_or("no error detail returned by the provider");- Err(format!("tool_call `{slug}` failed at the connected provider: {detail}"))+ Err(format!(+ "tool_call `{slug}` failed at the connected provider: {detail}"+ ))}diff --git a/crates/openhuman-core/src/integrations/composio/mod.rs b/crates/openhuman-core/src/integrations/composio/mod.rsindex a902040042..cca219ac94 100644--- a/crates/openhuman-core/src/integrations/composio/mod.rs+++ b/crates/openhuman-core/src/integrations/composio/mod.rs@@ -44,11 +44,11 @@ pub mod client;pub mod connected_integrations;pub mod contract;pub mod contract_gate;-pub mod flow_gate;pub(crate) mod direct_auth;pub mod execute_dispatch;pub(crate) mod file_store;mod file_store_documents;+pub mod flow_gate;pub mod googlecalendar_args;pub mod identity;pub mod identity_store;diff --git a/crates/openhuman-core/src/integrations/composio/ops/connections.rs b/crates/openhuman-core/src/integrations/composio/ops/connections.rsindex 4b8f7bfea1..6950629ed0 100644--- a/crates/openhuman-core/src/integrations/composio/ops/connections.rs+++ b/crates/openhuman-core/src/integrations/composio/ops/connections.rs@@ -67,9 +67,7 @@ pub(crate) fn flow_connection_entries(.filter(|connection| connection.is_active()).map(|connection| {let toolkit = connection.normalized_toolkit();- let normalize = |raw: &str| {- keys.get(raw).cloned().unwrap_or_else(|| raw.to_string())- };+ let normalize = |raw: &str| keys.get(raw).cloned().unwrap_or_else(|| raw.to_string());let platform_user_id = identity_lookup.get(&(normalize(&toolkit), normalize(&connection.id))).and_then(|identity| identity.user_id.clone());diff --git a/crates/openhuman-core/src/integrations/composio/ops/mod.rs b/crates/openhuman-core/src/integrations/composio/ops/mod.rsindex 3e8ed46535..633982fa9c 100644--- a/crates/openhuman-core/src/integrations/composio/ops/mod.rs+++ b/crates/openhuman-core/src/integrations/composio/ops/mod.rs@@ -34,13 +34,13 @@ mod triggers;// ── Public re-exports (match original ops.rs public surface) ───────────────+pub(crate) use connections::identity_lookup;+pub(crate) use connections::title_case_toolkit;pub use connections::{active_connection_ids, composio_authorize, composio_delete_connection,composio_list_connections, ComposioDeleteResult,};-pub(crate) use connections::identity_lookup;pub(crate) use connections::{flow_connection_entries, FlowConnectionEntry};-pub(crate) use connections::title_case_toolkit;pub use direct_mode::{composio_clear_api_key, composio_get_mode, composio_set_api_key};pub(crate) use error_utils::{report_composio_op_error, should_forward_tags};pub use execute::composio_execute;