Skip to content

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

feat(composio): add direct execution mode for composio integrations

Steven Enamakel54b0274a80a4
diff --git a/crates/openhuman-core/src/integrations/composio/execute_dispatch.rs b/crates/openhuman-core/src/integrations/composio/execute_dispatch.rs
index 45314cfc51..d9178a21b6 100644
--- a/crates/openhuman-core/src/integrations/composio/execute_dispatch.rs
+++ b/crates/openhuman-core/src/integrations/composio/execute_dispatch.rs
@@ -42,7 +42,7 @@ pub async fn execute_composio_action(
// without a route answers with an opaque "no connector route" error, so a
// missing direct-mode key or backend session must fail here with the
// actionable message (#1710).
- if let Err(e) = super::client::create_composio_client(config) {
+ if let Err(e) = super::client::resolve_composio_route(config) {
tracing::debug!(tool = %tool, "[composio][dispatch] route unavailable");
return Err(format!("{e:#}"));
}
diff --git a/crates/openhuman-core/src/integrations/composio/mod.rs b/crates/openhuman-core/src/integrations/composio/mod.rs
index 01c3e6405d..b430d2e994 100644
--- a/crates/openhuman-core/src/integrations/composio/mod.rs
+++ b/crates/openhuman-core/src/integrations/composio/mod.rs
@@ -66,7 +66,6 @@ pub use crate::memory::sync::composio::bus::{
ComposioTriggerSubscriber,
};
pub use action_tool::ComposioActionTool;
-pub use client::ComposioClient;
pub use identity::connection_identity;
pub use ops::{
cached_active_integrations, cached_active_integrations_including_expired, connected_set_hash,
diff --git a/crates/openhuman-core/src/integrations/composio/ops/connections.rs b/crates/openhuman-core/src/integrations/composio/ops/connections.rs
index e2c8096ceb..f57729b24a 100644
--- a/crates/openhuman-core/src/integrations/composio/ops/connections.rs
+++ b/crates/openhuman-core/src/integrations/composio/ops/connections.rs
@@ -2,7 +2,7 @@
use std::collections::HashMap;
-use super::super::client::{create_composio_client, direct_list_connections, ComposioClientKind};
+use super::super::client::{direct_list_connections, resolve_composio_route, ComposioRoute};
use super::super::module_client::{self as connectors, methods};
use crate::config::Config;
use crate::core::Outcome;
@@ -71,7 +71,7 @@ pub async fn composio_list_connections(
// host-side because its client accepts the local loopback overrides used
// by desktop development and its v3 response mapper lives here.
let resp = if config.composio.mode.trim() == crate::config::schema::COMPOSIO_MODE_DIRECT {
- let ComposioClientKind::Direct(direct) = create_composio_client(config)
+ let ComposioRoute::Direct(direct) = resolve_composio_route(config)
.map_err(|error| format!("[composio-direct] list_connections: {error:#}"))?
else {
unreachable!("direct Composio mode must construct a direct client")
diff --git a/crates/openhuman-core/src/integrations/composio/ops/direct_mode.rs b/crates/openhuman-core/src/integrations/composio/ops/direct_mode.rs
index 1b18ad8032..29331ddaca 100644
--- a/crates/openhuman-core/src/integrations/composio/ops/direct_mode.rs
+++ b/crates/openhuman-core/src/integrations/composio/ops/direct_mode.rs
@@ -4,7 +4,7 @@ use crate::config::Config;
use crate::core::Outcome;
use super::super::{
- client::{create_direct_composio_tool_for_api_key, direct_list_connections},
+ client::{create_direct_client_for_api_key, direct_list_connections},
direct_auth,
};
use super::error_utils::OpResult;
@@ -13,7 +13,7 @@ async fn validate_direct_api_key_before_store(config: &Config, api_key: &str) ->
let key_id = direct_auth::fingerprint_api_key(api_key);
direct_auth::reset_direct_auth_failure(key_id);
- let direct = create_direct_composio_tool_for_api_key(config, api_key)
+ let direct = create_direct_client_for_api_key(api_key)
.map_err(|e| format!("[composio-direct] validate_api_key: {e}"))?;
match direct_list_connections(&direct).await {
diff --git a/crates/openhuman-core/src/integrations/composio/ops/error_utils.rs b/crates/openhuman-core/src/integrations/composio/ops/error_utils.rs
index 401590ed32..1b653e66ef 100644
--- a/crates/openhuman-core/src/integrations/composio/ops/error_utils.rs
+++ b/crates/openhuman-core/src/integrations/composio/ops/error_utils.rs
@@ -2,8 +2,6 @@
use crate::config::Config;
-use super::super::client::{build_composio_client, ComposioClient};
-
/// Toolkits that honour the `tags` query param on the backend tool-list endpoint.
/// Expand this list when a new toolkit gains tag support.
const TAG_QUERYABLE_TOOLKITS: &[&str] = &["github"];
@@ -38,12 +36,6 @@ pub(super) type OpResult<T> = std::result::Result<T, String>;
pub(crate) const COMPOSIO_NO_SESSION: &str =
"composio unavailable: no backend session token. Sign in or set a TinyHumans API key.";
-/// Resolve a backend-mode [`ComposioClient`] from the root config, or
-/// return an error string that the caller can surface over RPC.
-pub(crate) fn resolve_client(config: &Config) -> OpResult<ComposioClient> {
- build_composio_client(config).ok_or_else(|| COMPOSIO_NO_SESSION.to_string())
-}
-
/// True when the user has selected Composio **direct** mode but has not yet
/// configured an API key (neither in the keychain nor `config.toml`).
///
@@ -55,7 +47,7 @@ pub(crate) fn resolve_client(config: &Config) -> OpResult<ComposioClient> {
/// Sentry on every tick (TAURI-RUST-R4).
///
/// Key presence MUST mirror the factory's own resolution in
-/// [`create_composio_client`] (`client.rs`): a key counts if it is in the
+/// [`resolve_composio_route`](super::super::client::resolve_composio_route) (`client/factory.rs`): a key counts if it is in the
/// keychain (`credentials::get_composio_api_key`) **or** in `config.toml`
/// (`config.composio.api_key`). Checking only the keychain would wrongly
/// short-circuit to an empty list for a user who configured their key via