Skip to content

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

feat(composio): route list_toolkits through the connector bus

Steven Enamakel3319baa46034
diff --git a/src/openhuman/integrations/composio/ops/toolkits.rs b/src/openhuman/integrations/composio/ops/toolkits.rs
index c07ffe5783..f21165617e 100644
--- a/src/openhuman/integrations/composio/ops/toolkits.rs
+++ b/src/openhuman/integrations/composio/ops/toolkits.rs
@@ -1,6 +1,7 @@
//! Toolkit and capability listing ops.
use crate::openhuman::config::Config;
+use crate::openhuman::modules::connectors::{self, methods};
use crate::rpc::RpcOutcome;
use super::super::client::{create_composio_client, ComposioClientKind};
@@ -12,26 +13,24 @@ pub async fn composio_list_toolkits(
config: &Config,
) -> OpResult<RpcOutcome<ComposioToolkitsResponse>> {
tracing::debug!("[composio] rpc list_toolkits");
- let kind =
- create_composio_client(config).map_err(|e| format!("[composio] list_toolkits: {e}"))?;
- match kind {
- ComposioClientKind::Backend(client) => {
- tracing::debug!("[composio] list_toolkits: backend variant");
- let resp = client.list_toolkits().await.map_err(|e| {
- report_composio_op_error("list_toolkits", &e);
- format!("[composio] list_toolkits failed: {e:#}")
- })?;
+
+ match connectors::call_bare::<ComposioToolkitsResponse>(config, methods::LIST_TOOLKITS).await {
+ Ok(resp) => {
let count = resp.toolkits.len();
Ok(RpcOutcome::new(
resp,
vec![format!("composio: {count} toolkit(s) enabled")],
))
}
- ComposioClientKind::Direct(_) => {
+ // Direct mode has no per-user allowlist to report, and the module says
+ // so by name rather than returning an empty list. The empty list is
+ // still the right *answer* for this surface — the user manages their
+ // toolkits at app.composio.dev — so the host renders it here, with the
+ // note it has always shown, instead of the module inventing it.
+ Err(error) if connectors::is_unsupported_by_route(&error) => {
tracing::info!(
- "[composio-direct] list_toolkits: direct mode active — no \
- server-side allowlist is enforced; returning empty toolkits \
- list. Users manage available toolkits via app.composio.dev."
+ "[composio] list_toolkits: the live route enforces no server-side allowlist; \
+ returning an empty list"
);
Ok(RpcOutcome::new(
ComposioToolkitsResponse::default(),
@@ -40,6 +39,10 @@ pub async fn composio_list_toolkits(
.to_string()],
))
}
+ Err(error) => {
+ report_composio_op_error("list_toolkits", &anyhow::anyhow!("{error}"));
+ Err(format!("[composio] list_toolkits failed: {error}"))
+ }
}
}
diff --git a/src/openhuman/modules/connectors.rs b/src/openhuman/modules/connectors.rs
index e55001368d..0fbd3c7e25 100644
--- a/src/openhuman/modules/connectors.rs
+++ b/src/openhuman/modules/connectors.rs
@@ -177,6 +177,22 @@ pub async fn call_bare<Reply: DeserializeOwned>(
.map_err(|error| format!("{member}: {error}"))
}
+/// Whether a member failure is the module refusing an operation the live route
+/// does not offer.
+///
+/// The two routes are not equivalent, and the module says so by name rather
+/// than by returning an empty result. A host that wants to render its own
+/// message for that case — "direct mode has no curated allowlist" — needs to
+/// tell the refusal apart from a real failure, and this is how.
+///
+/// Matched on the message because that is what crosses the bus: `TinyBus`
+/// carries an error name and a string, not a typed enum, so the structure of
+/// [`tinyconnectors_bus`]'s error is flattened by the time it arrives.
+#[must_use]
+pub fn is_unsupported_by_route(error: &str) -> bool {
+ error.contains("is not available over the") && error.contains("route")
+}
+
#[cfg(test)]
#[path = "connectors_tests.rs"]
mod tests;