Skip to content

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

feat(composio): add identity lookup helper for connection matching

Steven Enamakel5e82e4cafc68
diff --git a/crates/openhuman-core/src/integrations/composio/ops/connections.rs b/crates/openhuman-core/src/integrations/composio/ops/connections.rs
index 45140c88f7..ff8ab07c87 100644
--- a/crates/openhuman-core/src/integrations/composio/ops/connections.rs
+++ b/crates/openhuman-core/src/integrations/composio/ops/connections.rs
@@ -17,6 +17,29 @@ use super::super::types::{
ComposioAuthorizeRequest, ComposioAuthorizeResponse, ComposioConnectionsResponse,
ComposioDeleteConnectionRequest, ComposioDeleteResponse,
};
+
+/// Matches cached identity records to normalized provider/account keys shared
+/// by the settings response and the flow connection picker.
+pub(crate) fn identity_lookup<'a>(
+ identities: &'a [crate::integrations::composio::contract::ConnectedIdentity],
+ normalized_keys: &HashMap<String, String>,
+) -> HashMap<(String, String), &'a crate::integrations::composio::contract::ConnectedIdentity> {
+ let normalize = |value: &str| {
+ normalized_keys
+ .get(value)
+ .cloned()
+ .unwrap_or_else(|| value.to_string())
+ };
+ identities
+ .iter()
+ .map(|identity| {
+ (
+ (normalize(&identity.source), normalize(&identity.identifier)),
+ identity,
+ )
+ })
+ .collect()
+}
use super::error_utils::{
backend_mode_without_session, direct_mode_without_key, report_composio_op_error, OpResult,
COMPOSIO_NO_SESSION,