Skip to content

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

refactor(composio): decouple backend route from modules feature

Steven Enamakel4e878d55d8f8
diff --git a/crates/openhuman-core/src/integrations/composio/test_backend_route.rs b/crates/openhuman-core/src/integrations/composio/test_backend_route.rs
index 54d0947519..89c4acc5f2 100644
--- a/crates/openhuman-core/src/integrations/composio/test_backend_route.rs
+++ b/crates/openhuman-core/src/integrations/composio/test_backend_route.rs
@@ -9,6 +9,7 @@
use crate::config::schema::COMPOSIO_MODE_BACKEND;
use crate::config::Config;
+#[cfg(feature = "modules")]
use crate::modules::connectors::{register_proxy_target, ProxyTarget};
use super::client::{register_composio_route_builder, ComposioRoute};
@@ -16,7 +17,8 @@ use super::client::{register_composio_route_builder, ComposioRoute};
const NO_SESSION: &str =
"composio backend mode unavailable: no backend session token. Sign in or set a TinyHumans API key.";
-fn target(config: &Config) -> Result<ProxyTarget, String> {
+/// The backend origin and credential secret the stand-in resolves.
+fn resolve(config: &Config) -> Result<(String, String), String> {
use crate::security::credentials::session_support::{
is_local_session_token, resolve_backend_credential, BackendCredential,
};
@@ -29,21 +31,31 @@ fn target(config: &Config) -> Result<ProxyTarget, String> {
if credential.secret().trim().is_empty() {
return Err(NO_SESSION.to_string());
}
- Ok(ProxyTarget {
- base_url: config
+ Ok((
+ config
.api_url
.clone()
.unwrap_or_else(|| "http://127.0.0.1:1".to_string()),
- auth_token: credential.secret().trim().to_string(),
+ credential.secret().trim().to_string(),
+ ))
+}
+
+#[cfg(feature = "modules")]
+fn target(config: &Config) -> Result<ProxyTarget, String> {
+ let (base_url, auth_token) = resolve(config)?;
+ Ok(ProxyTarget {
+ base_url,
+ auth_token,
})
}
/// Registers the stand-in route builder and proxy target on this thread.
pub(crate) fn register() {
register_composio_route_builder(COMPOSIO_MODE_BACKEND, |config| {
- target(config)
+ resolve(config)
.map(|_| ComposioRoute::Backend)
.map_err(|message| anyhow::anyhow!(message))
});
+ #[cfg(feature = "modules")]
register_proxy_target(COMPOSIO_MODE_BACKEND, target);
}