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
refactor(integrations): replace `include!` with real submodules
Steven Enamakel4ba5602d39db
diff --git a/crates/openhuman-core/src/integrations/client.rs b/crates/openhuman-core/src/integrations/client.rsindex 796f2ab8c3..d2912f71a0 100644--- a/crates/openhuman-core/src/integrations/client.rs+++ b/crates/openhuman-core/src/integrations/client.rs@@ -1,7 +1,22 @@//! Shared HTTP client for all integration tools.+mod construct;+mod download;+mod errors;+mod pricing;+mod requests;++pub use construct::IntegrationClient;+pub use pricing::{build_client, pricing_for_config};++// Re-exported at module scope (rather than only inside each submodule) so+// `#[cfg(test)] mod tests` below — and the `super::*` glob each test file+// does — can see them, mirroring what direct declaration in this file used+// to provide before the `include!` split was replaced with real submodules.+use construct::sanitize_backend_url;+use errors::{extract_error_detail, is_composio_soft_auth_path};+use requests::{backend_egress_descriptor, enforce_backend_egress, managed_budget_applies_to_path};+#[cfg(test)]#[path = "client_tests.rs"]mod tests;-include!("client_part_01.rs");-include!("client_part_02.rs");diff --git a/crates/openhuman-core/src/integrations/composio/catalog.rs b/crates/openhuman-core/src/integrations/composio/catalog.rsindex c99c8feb85..b957196be3 100644--- a/crates/openhuman-core/src/integrations/composio/catalog.rs+++ b/crates/openhuman-core/src/integrations/composio/catalog.rs@@ -55,7 +55,5 @@ pub use probe::{// implementation details they exercise via a plain `use super::*;`, exactly// as when this was one un-split file. See each item's `pub(super)` in its// owning submodule.-use contract::{compute_composio_array_path, live_catalog_fetch_lock, CacheEntry};+use contract::{compute_composio_array_path, live_catalog_fetch_lock};use probe::{cache_probe_result, resolve_composio_action_scope};-#[allow(unused_imports)]-use contract::COMPOSIO_CATALOG_CACHE_TTL;diff --git a/crates/openhuman-core/src/integrations/composio/tools/direct/execution.rs b/crates/openhuman-core/src/integrations/composio/tools/direct/execution.rsnew file mode 100644index 0000000000..d3fdbedc99--- /dev/null+++ b/crates/openhuman-core/src/integrations/composio/tools/direct/execution.rs@@ -0,0 +1,149 @@+//! Action execution: `execute_action` (v3-with-v2-fallback) and its two+//! version-specific request builders/senders.++use super::http_errors::response_error;+use super::types::{ComposioTool, COMPOSIO_API_BASE_V3};+use anyhow::Context;+use serde_json::json;++impl ComposioTool {+ /// Execute a Composio action/tool with given parameters.+ ///+ /// Uses v3 endpoint first and falls back to v2 for compatibility.+ pub async fn execute_action(+ &self,+ action_name: &str,+ params: serde_json::Value,+ entity_id: Option<&str>,+ connected_account_ref: Option<&str>,+ ) -> anyhow::Result<serde_json::Value> {+ // The Composio v3 action-execute contract keys off the UPPERCASE_SNAKE+ // *action* slug (e.g. `GMAIL_SEND_EMAIL`) at `/tools/execute/{slug}`.+ // The previous code lowercased + dashed it into the *toolkit* slug+ // (`gmail-send-email`) and posted to the wrong `/tools/{slug}/execute`+ // path, so every direct-mode execute 404'd (issue #3219). Pass the+ // action slug through verbatim (trimmed only); the v2 fallback already+ // used the same untransformed name.+ let action_slug = action_name.trim();++ match self+ .execute_action_v3(+ action_slug,+ params.clone(),+ entity_id,+ connected_account_ref,+ )+ .await+ {+ Ok(result) => Ok(result),+ Err(v3_err) => match self.execute_action_v2(action_name, params, entity_id).await {+ Ok(result) => Ok(result),+ Err(v2_err) => anyhow::bail!(+ "Composio execute failed on v3 ({v3_err}) and v2 fallback ({v2_err})"+ ),+ },+ }+ }++ fn build_execute_action_v3_request(+ action_slug: &str,+ params: serde_json::Value,+ entity_id: Option<&str>,+ connected_account_ref: Option<&str>,+ ) -> (String, serde_json::Value) {+ // POST /api/v3/tools/execute/{ACTION_SLUG} — the action slug stays+ // UPPERCASE_SNAKE (see `execute_action`). Path is `/tools/execute/{slug}`,+ // NOT `/tools/{slug}/execute` (issue #3219).+ let url = format!("{COMPOSIO_API_BASE_V3}/tools/execute/{action_slug}");+ let account_ref = connected_account_ref.and_then(|candidate| {+ let trimmed_candidate = candidate.trim();+ (!trimmed_candidate.is_empty()).then_some(trimmed_candidate)+ });++ let mut body = json!({+ "arguments": params,+ });++ if let Some(entity) = entity_id {+ body["user_id"] = json!(entity);+ }+ if let Some(account_ref) = account_ref {+ body["connected_account_id"] = json!(account_ref);+ }++ (url, body)+ }++ async fn execute_action_v3(+ &self,+ action_slug: &str,+ params: serde_json::Value,+ entity_id: Option<&str>,+ connected_account_ref: Option<&str>,+ ) -> anyhow::Result<serde_json::Value> {+ let (_default_url, body) = Self::build_execute_action_v3_request(+ action_slug,+ params,+ entity_id,+ connected_account_ref,+ );+ let url = format!("{}/tools/execute/{action_slug}", self.base_v3);++ self.ensure_request_url(&url)?;++ let resp = self+ .client()+ .post(&url)+ .header("x-api-key", &self.api_key)+ .json(&body)+ .send()+ .await?;++ if !resp.status().is_success() {+ let err = response_error(resp).await;+ anyhow::bail!("Composio v3 action execution failed: {err}");+ }++ let result: serde_json::Value = resp+ .json()+ .await+ .context("Failed to decode Composio v3 execute response")?;+ Ok(result)+ }++ async fn execute_action_v2(+ &self,+ action_name: &str,+ params: serde_json::Value,+ entity_id: Option<&str>,+ ) -> anyhow::Result<serde_json::Value> {+ let url = format!("{}/actions/{action_name}/execute", self.base_v2);++ let mut body = json!({+ "input": params,+ });++ if let Some(entity) = entity_id {+ body["entityId"] = json!(entity);+ }++ let resp = self+ .client()+ .post(&url)+ .header("x-api-key", &self.api_key)+ .json(&body)+ .send()+ .await?;++ if !resp.status().is_success() {+ let err = response_error(resp).await;+ anyhow::bail!("Composio v2 action execution failed: {err}");+ }++ let result: serde_json::Value = resp+ .json()+ .await+ .context("Failed to decode Composio v2 execute response")?;+ Ok(result)+ }+}