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): handle missing connection ID in tool execution
Steven Enamakel88ba1364d0f6
diff --git a/crates/openhuman-core/src/integrations/composio/tools/direct/connections.rs b/crates/openhuman-core/src/integrations/composio/tools/direct/connections.rsindex 320469fb33..119fce5d79 100644--- a/crates/openhuman-core/src/integrations/composio/tools/direct/connections.rs+++ b/crates/openhuman-core/src/integrations/composio/tools/direct/connections.rs@@ -1,118 +1,11 @@-//! OAuth connect-URL issuance and connected-account listing.+//! Connected-account listing for the direct route.-use super::http_errors::{extract_redirect_url, response_error};-use super::types::ComposioTool;+use super::http_errors::response_error;+use super::types::DirectComposioClient;use anyhow::Context;use serde::Deserialize;-use serde_json::json;--impl ComposioTool {- /// Get the OAuth connection URL for a specific app/toolkit or auth config.- ///- /// Uses v3 endpoint first and falls back to v2 for compatibility.- pub async fn get_connection_url(- &self,- app_name: Option<&str>,- auth_config_id: Option<&str>,- entity_id: &str,- ) -> anyhow::Result<String> {- let v3 = self- .get_connection_url_v3(app_name, auth_config_id, entity_id)- .await;- match v3 {- Ok(url) => Ok(url),- Err(v3_err) => {- let app = app_name.ok_or_else(|| {- anyhow::anyhow!(- "Composio v3 connect failed ({v3_err}) and v2 fallback requires 'app'"- )- })?;- match self.get_connection_url_v2(app, entity_id).await {- Ok(url) => Ok(url),- Err(v2_err) => anyhow::bail!(- "Composio connect failed on v3 ({v3_err}) and v2 fallback ({v2_err})"- ),- }- }- }- }-- async fn get_connection_url_v3(- &self,- app_name: Option<&str>,- auth_config_id: Option<&str>,- entity_id: &str,- ) -> anyhow::Result<String> {- let auth_config_id = match auth_config_id {- Some(id) => id.to_string(),- None => {- let app = app_name.ok_or_else(|| {- anyhow::anyhow!("Missing 'app' or 'auth_config_id' for v3 connect")- })?;- self.resolve_auth_config_id(app).await?- }- };-- let url = format!("{}/connected_accounts/link", self.base_v3);- let body = json!({- "auth_config_id": auth_config_id,- "user_id": entity_id,- });-- let resp = self- .client()- .post(&url)- .header("x-api-key", &self.api_key)- .json(&body)- .send()- .await?;-- if !resp.status().is_success() {- let err = response_error(resp).await;- anyhow::bail!("Composio v3 connect failed: {err}");- }-- let result: serde_json::Value = resp- .json()- .await- .context("Failed to decode Composio v3 connect response")?;- extract_redirect_url(&result)- .ok_or_else(|| anyhow::anyhow!("No redirect URL in Composio v3 response"))- }-- async fn get_connection_url_v2(- &self,- app_name: &str,- entity_id: &str,- ) -> anyhow::Result<String> {- let url = format!("{}/connectedAccounts", self.base_v2);-- let body = json!({- "integrationId": app_name,- "entityId": entity_id,- });-- let resp = self- .client()- .post(&url)- .header("x-api-key", &self.api_key)- .json(&body)- .send()- .await?;-- if !resp.status().is_success() {- let err = response_error(resp).await;- anyhow::bail!("Composio v2 connect failed: {err}");- }-- let result: serde_json::Value = resp- .json()- .await- .context("Failed to decode Composio v2 connect response")?;- extract_redirect_url(&result)- .ok_or_else(|| anyhow::anyhow!("No redirect URL in Composio v2 response"))- }+impl DirectComposioClient {/// List the user's connected accounts on Composio v3.////// GET `https://backend.composio.dev/api/v3/connected_accounts` with@@ -161,83 +54,8 @@ impl ComposioTool {);Ok(body.items)}-- async fn resolve_auth_config_id(&self, app_name: &str) -> anyhow::Result<String> {- let url = format!("{}/auth_configs", self.base_v3);-- let resp = self- .client()- .get(&url)- .header("x-api-key", &self.api_key)- .query(&[- ("toolkit_slug", app_name),- ("show_disabled", "true"),- ("limit", "25"),- ])- .send()- .await?;-- if !resp.status().is_success() {- let err = response_error(resp).await;- anyhow::bail!("Composio v3 auth config lookup failed: {err}");- }-- let body: ComposioAuthConfigsResponse = resp- .json()- .await- .context("Failed to decode Composio v3 auth configs response")?;-- if body.items.is_empty() {- anyhow::bail!(- "No auth config found for toolkit '{app_name}'. Create one in Composio first."- );- }-- let preferred = body- .items- .iter()- .find(|cfg| cfg.is_enabled())- .or_else(|| body.items.first())- .context("No usable auth config returned by Composio")?;-- Ok(preferred.id.clone())- }-}--#[derive(Debug, Deserialize)]-struct ComposioAuthConfigsResponse {- #[serde(default)]- items: Vec<ComposioAuthConfig>,-}--#[derive(Debug, Clone, Deserialize)]-pub(super) struct ComposioAuthConfig {- pub(super) id: String,- #[serde(default)]- pub(super) status: Option<String>,- #[serde(default)]- pub(super) enabled: Option<bool>,-}--impl ComposioAuthConfig {- pub(super) fn is_enabled(&self) -> bool {- self.enabled.unwrap_or(false)- || self- .status- .as_deref()- .is_some_and(|v| v.eq_ignore_ascii_case("enabled"))- }}-// ── v3 /connected_accounts envelope ─────────────────────────────────-//-// Public so the `composio/client.rs::direct_list_connections` helper-// in the domain layer can reshape it into the canonical-// `ComposioConnection` type. Kept distinct from `ComposioConnection`-// itself (which is the backend-proxied envelope) so the two paths-// don't get coupled — Composio v3 may add or rename fields and we'd-// rather adjust the mapping than reshuffle the public type.-#[derive(Debug, Deserialize)]struct ComposioConnectedAccountsResponse {#[serde(default)]