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
fix(composio): remove unused direct client module
Steven Enamakel1f134752b1f9
diff --git a/crates/openhuman-core/src/integrations/composio/client.rs b/crates/openhuman-core/src/integrations/composio/client.rsindex 530c33ef1d..31406bffcb 100644--- a/crates/openhuman-core/src/integrations/composio/client.rs+++ b/crates/openhuman-core/src/integrations/composio/client.rs@@ -4,19 +4,22 @@//! reached through [`super::module_client`]. What remains here is the part the//! module does not decide for the host: which route the config selects//! ([`resolve_composio_route`]) and the two direct-mode v3 reads-//! ([`direct_list_connections`], [`direct_list_tools`]) that keep the-//! pagination and toolkit-version parameters the pinned module route omits.+//! ([`direct_list_connections`], [`direct_list_tools`]), which run in the module+//! as stateless members under the host's key-health gate, proxy and TLS policy.//!//! Logging uses the `[composio]` grep-prefix so all sidecar output for//! this domain can be filtered in one shot.+mod credential;mod direct;mod factory;+mod network;#[cfg(test)]#[path = "client_tests.rs"]mod tests;+pub use credential::DirectCredential;pub use direct::direct_list_connections;pub(crate) use direct::direct_list_tools;pub(crate) use factory::create_direct_client_for_api_key;diff --git a/crates/openhuman-core/src/integrations/composio/client/direct.rs b/crates/openhuman-core/src/integrations/composio/client/direct.rsindex bfa5f675e3..92b9fc336c 100644--- a/crates/openhuman-core/src/integrations/composio/client/direct.rs+++ b/crates/openhuman-core/src/integrations/composio/client/direct.rs@@ -1,22 +1,62 @@//! Direct-mode reads: `direct_list_connections` and `direct_list_tools`.//!-//! The v3 requests and their reshaping into the canonical envelopes are the-//! connector module's `DirectRoute`, driven in-process over the host transport-//! on a bound [`crate::tools::DirectComposioClient`]. What stays here is host-//! policy: the process-wide invalid-key gate (`direct_auth`) and its-//! user-facing messages.+//! The v3 requests and their reshaping into the canonical envelopes run in the+//! connector module, reached over the bus with `ListConnectionsDirect` and+//! `ListToolsDirect`. Those members carry the credential on the request, so the+//! module's configured route is untouched and nothing is persisted (which is+//! also how `composio.set_api_key` checks a key before storing it).+//!+//! What stays here is host policy: the process-wide invalid-key gate+//! (`direct_auth`) and its user-facing messages, the host's proxy and TLS policy+//! (handed to the module with the credential, see `network`), and the identity+//! fields the host fills in itself.use std::sync::Arc;+use tinyconnectors_bus::{+ methods, ComposioDirectConnectionsRequest, ComposioDirectToolsRequest,+};+use super::super::direct_auth;+use super::super::module_client;use super::super::types::{ComposioConnectionsResponse, ComposioToolsResponse};+use super::DirectCredential;++/// `ListConnectionsDirect`, with the member failure peeled down to the message+/// the user is shown.+async fn module_list_connections(+ config: &crate::config::Config,+ direct: &DirectCredential,+) -> anyhow::Result<ComposioConnectionsResponse> {+ let request = ComposioDirectConnectionsRequest {+ credential: direct.module_credential(),+ };+ let mut response: ComposioConnectionsResponse =+ module_client::call_stateless(config, methods::LIST_CONNECTIONS_DIRECT, request)+ .await+ .map_err(|error| {+ anyhow::anyhow!(module_client::member_failure_message(+ methods::LIST_CONNECTIONS_DIRECT,+ &error+ ))+ })?;+ // Identity fields are the host's to fill (`enrich_connections_with_identity`+ // from cached profile data); the module also lifts them from the v3 row.+ for connection in &mut response.connections {+ connection.account_email = None;+ connection.workspace = None;+ connection.username = None;+ }+ Ok(response)+}/// Direct-mode connection listing (Composio v3 `/connected_accounts`), gated/// by the host's invalid-key breaker. Rows come back as canonical/// [`ComposioConnection`](super::super::types::ComposioConnection)s; a malformed/// row is kept with empty fields and reads as inactive (fail-safe).pub async fn direct_list_connections(- direct: &Arc<crate::tools::DirectComposioClient>,+ config: &crate::config::Config,+ direct: &Arc<DirectCredential>,) -> anyhow::Result<ComposioConnectionsResponse> {tracing::debug!("[composio-direct] list_connections: GET v3 /connected_accounts");let key_id = direct.auth_key_fingerprint();@@ -28,7 +68,7 @@ pub async fn direct_list_connections(anyhow::bail!("{error}");}- let response = match direct.list_connections().await {+ let response = match module_list_connections(config, direct).await {Ok(response) => {direct_auth::record_direct_auth_success(key_id);response@@ -64,7 +104,7 @@ pub async fn direct_list_connections(Ok(response)}-/// Direct-mode tool listing. Calls Composio v3 `/tools` (the route sends+/// Direct-mode tool listing. Calls Composio v3 `/tools` through the module (it sends/// `limit=200`, `toolkit_versions=latest`, `toolkits=<csv>` and repeated/// `tags=`) and returns the same `ComposioToolSchema` envelope the/// backend-proxied path returns.@@ -94,7 +134,8 @@ pub async fn direct_list_connections(/// which this function never applies itself; the filter is layered on by/// its `composio_list_tools` caller, not baked in here.pub(crate) async fn direct_list_tools(- direct: &Arc<crate::tools::DirectComposioClient>,+ config: &crate::config::Config,+ direct: &Arc<DirectCredential>,toolkits: &[String],tags: Option<&[String]>,) -> anyhow::Result<ComposioToolsResponse> {@@ -103,7 +144,20 @@ pub(crate) async fn direct_list_tools(tags = tags.map(<[String]>::len).unwrap_or(0),"[composio-direct] list_tools: GET v3 /tools");- let response = direct.list_tools(toolkits, tags.unwrap_or(&[])).await?;+ let request = ComposioDirectToolsRequest {+ credential: direct.module_credential(),+ toolkits: toolkits.to_vec(),+ tags: tags.unwrap_or(&[]).to_vec(),+ };+ let response: ComposioToolsResponse =+ module_client::call_stateless(config, methods::LIST_TOOLS_DIRECT, request)+ .await+ .map_err(|error| {+ anyhow::anyhow!(module_client::member_failure_message(+ methods::LIST_TOOLS_DIRECT,+ &error+ ))+ })?;tracing::debug!(count = response.tools.len(),"[composio-direct] list_tools: mapped v3 tool schemas"diff --git a/crates/openhuman-core/src/integrations/composio/client/factory.rs b/crates/openhuman-core/src/integrations/composio/client/factory.rsindex 143a385b9b..d51584b71f 100644--- a/crates/openhuman-core/src/integrations/composio/client/factory.rs+++ b/crates/openhuman-core/src/integrations/composio/client/factory.rs@@ -9,15 +9,14 @@//! "no connector route" the module reports when it is configured without one//! (#1710).//!-//! [`ComposioRoute::Direct`] carries the slim direct-mode HTTP reader the host-//! still needs for the two v3 reads the pinned module route does not match-//! byte-for-byte (`/connected_accounts?limit=200`, `/tools` with-//! `toolkit_versions=latest`, #3932) and for its loopback overrides.+//! [`ComposioRoute::Direct`] carries the credential (key and validated base+//! URL) the direct reads are made with, including the host-pinned and loopback+//! overrides the module's single configured route cannot express per call.use std::sync::Arc;use crate::config::schema::{COMPOSIO_MODE_BACKEND, COMPOSIO_MODE_DIRECT};-use crate::integrations::composio::tools::DirectComposioClient;+use super::DirectCredential;// Re-declare the mode strings as local consts so they can be used as// pattern arms in the `match` below. `use` imports of `pub const &str`@@ -32,12 +31,12 @@ const MODE_DIRECT_PAT: &str = COMPOSIO_MODE_DIRECT;////// `Backend` is a unit: the backend-proxied route is reached through the/// connector module, whose configuration (`modules::connectors::module_config`)-/// carries the base URL and bearer. `Direct` wraps the host-side v3 reader-/// (see the module docs) for the user's own key.+/// carries the base URL and bearer. `Direct` wraps the user's own key and its+/// base URL (see the module docs).pub enum ComposioRoute {Backend,/// Held inside an `Arc` so the variant stays cheap to clone.- Direct(Arc<DirectComposioClient>),+ Direct(Arc<DirectCredential>),}impl ComposioRoute {@@ -52,14 +51,14 @@ impl ComposioRoute {pub(crate) fn create_direct_client_for_api_key(api_key: &str,-) -> anyhow::Result<Arc<DirectComposioClient>> {+) -> anyhow::Result<Arc<DirectCredential>> {direct_client(api_key, None)}fn direct_client(api_key: &str,base_urls: Option<&crate::config::ComposioDirectBaseUrls>,-) -> anyhow::Result<Arc<DirectComposioClient>> {+) -> anyhow::Result<Arc<DirectCredential>> {let api_key = api_key.trim();if api_key.is_empty() {anyhow::bail!("composio direct api key must not be empty");@@ -67,7 +66,7 @@ fn direct_client(if let Some(urls) = base_urls {let client =- DirectComposioClient::new_with_base_urls(api_key, urls.v2.clone(), urls.v3.clone())?;+ DirectCredential::new_with_base_urls(api_key, urls.v2.clone(), urls.v3.clone())?;return Ok(Arc::new(client));}#[cfg(debug_assertions)]@@ -76,15 +75,15 @@ fn direct_client(std::env::var("OPENHUMAN_COMPOSIO_DIRECT_BASE_V3").ok(),) {(Some(base_v2), Some(base_v3)) => {- DirectComposioClient::new_with_base_urls_for_loopback(api_key, base_v2, base_v3)+ DirectCredential::new_with_base_urls_for_loopback(api_key, base_v2, base_v3).map_err(|e| {anyhow::anyhow!("invalid debug composio direct loopback base override: {e}")})?}- _ => DirectComposioClient::new(api_key),+ _ => DirectCredential::new(api_key),};#[cfg(not(debug_assertions))]- let client = DirectComposioClient::new(api_key);+ let client = DirectCredential::new(api_key);Ok(Arc::new(client))}