Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(connectors): handle missing module client in composio integration

Steven Enamakelec61dc73c250
diff --git a/crates/openhuman-core/src/integrations/composio/module_client.rs b/crates/openhuman-core/src/integrations/composio/module_client.rs
index 17cf99261c..1ad9be6f31 100644
--- a/crates/openhuman-core/src/integrations/composio/module_client.rs
+++ b/crates/openhuman-core/src/integrations/composio/module_client.rs
@@ -188,6 +188,70 @@ pub async fn reconcile_route_if_loaded(_config: &crate::config::Config) -> Resul
Ok(())
}
+/// Call a member that carries its own credential and leaves the configured
+/// route alone (the stateless direct reads).
+///
+/// # Errors
+///
+/// As [`call`].
+#[cfg(feature = "modules")]
+pub async fn call_stateless<Request, Reply>(
+ config: &crate::config::Config,
+ member: &str,
+ request: Request,
+) -> Result<Reply, String>
+where
+ Request: serde::Serialize + Send,
+ Reply: serde::de::DeserializeOwned,
+{
+ crate::modules::connectors::call_stateless(config, member, request).await
+}
+
+/// Call a stateless member. Always fails without the `modules` feature.
+///
+/// # Errors
+///
+/// Always, explaining that this build has no module loader.
+#[cfg(not(feature = "modules"))]
+pub async fn call_stateless<Request, Reply>(
+ _config: &crate::config::Config,
+ member: &str,
+ _request: Request,
+) -> Result<Reply, String>
+where
+ Request: serde::Serialize + Send,
+ Reply: serde::de::DeserializeOwned,
+{
+ Err(format!("{member}: {WITHOUT_MODULES}"))
+}
+
+/// The message a stateless member's failure carries, with the transport layers
+/// peeled off.
+///
+/// The bus renders a member failure as `<Member>: ai.tinyhumans.tinybus.Error.<Kind>: <message>`.
+/// For the direct reads `<message>` is the text users have always been shown
+/// (`Composio v3 connected_accounts failed: HTTP 401: Invalid API key`), and the
+/// host's invalid-key gate and failure classification key on it, so it must come
+/// back exactly. Anything not shaped like a member failure (the module could
+/// not be loaded or reached) is returned unchanged.
+#[must_use]
+pub fn member_failure_message(member: &str, error: &str) -> String {
+ const WIRE_ERROR_PREFIX: &str = "ai.tinyhumans.tinybus.Error.";
+ let Some(mut message) = error
+ .strip_prefix(member)
+ .and_then(|rest| rest.strip_prefix(": "))
+ else {
+ return error.to_string();
+ };
+ while let Some(tail) = message
+ .strip_prefix(WIRE_ERROR_PREFIX)
+ .and_then(|rest| rest.split_once(": ").map(|(_, tail)| tail))
+ {
+ message = tail;
+ }
+ message.to_string()
+}
+
/// Call a member that takes no arguments.
///
/// # Errors
diff --git a/crates/openhuman-core/src/modules/connectors.rs b/crates/openhuman-core/src/modules/connectors.rs
index 9227d12c8d..392cff44ec 100644
--- a/crates/openhuman-core/src/modules/connectors.rs
+++ b/crates/openhuman-core/src/modules/connectors.rs
@@ -308,6 +308,38 @@ where
.map_err(|error| format!("{member}: {error}"))
}
+/// Call a member that carries its own credential, without touching the route.
+///
+/// `ListConnectionsDirect` and `ListToolsDirect` read as the credential on the
+/// request, so the module's configured route is neither used nor replaced. That
+/// is why this does not reconcile the route first: a host serving several
+/// credentials from one module must not have one caller's configuration
+/// overwrite another's mid-call, and a config that names no route here would
+/// otherwise send the module `{"route": "none"}` in the middle of a read.
+///
+/// # Errors
+///
+/// As [`call`].
+pub async fn call_stateless<Request, Reply>(
+ config: &Config,
+ member: &str,
+ request: Request,
+) -> Result<Reply, String>
+where
+ Request: Serialize + Send,
+ Reply: DeserializeOwned,
+{
+ // The module's own HTTP deadline is 30s; give the bus a little longer so a
+ // slow Composio surfaces as the module's message, not a bus timeout.
+ const STATELESS_TIMEOUT: std::time::Duration = std::time::Duration::from_secs(45);
+ ops::ensure_loaded(config, MODULE_ID).await?;
+ let proxy = proxy_to_serving().await?.with_timeout(STATELESS_TIMEOUT);
+ proxy
+ .call::<Reply>(member, (request,))
+ .await
+ .map_err(|error| format!("{member}: {error}"))
+}
+
/// Call a long-running member with a deadline sized for it.
///
/// The default bus deadline (30s) fits request-shaped members. `Sync` is not