Skip to content

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

fix(composio): handle missing identity store file gracefully

Steven Enamakel10b7e88cc9b5
diff --git a/crates/openhuman-core/src/integrations/composio/identity_store.rs b/crates/openhuman-core/src/integrations/composio/identity_store.rs
index f2a9377083..859c34bdb8 100644
--- a/crates/openhuman-core/src/integrations/composio/identity_store.rs
+++ b/crates/openhuman-core/src/integrations/composio/identity_store.rs
@@ -10,7 +10,7 @@
use crate::config::Config;
use crate::integrations::composio::contract::{
- canonicalize, normalize_connection_identifier, ConnectedIdentity, IdentityKind,
+ canonicalize_values, normalize_connection_identifiers, ConnectedIdentity, IdentityKind,
ProviderUserProfile,
};
@@ -29,15 +29,16 @@ pub async fn persist_provider_profile(
config: &Config,
profile: &ProviderUserProfile,
) -> Result<usize, String> {
- let toolkit = normalize_connection_identifier(&profile.toolkit);
- let identifier = profile
- .connection_id
- .as_deref()
- .map(normalize_connection_identifier)
+ let mut keys = vec![profile.toolkit.clone()];
+ keys.extend(profile.connection_id.clone());
+ let mut keys = normalize_connection_identifiers(config, &keys).await?.into_iter();
+ let toolkit = keys.next().unwrap_or_default();
+ let identifier = keys
+ .next()
.filter(|v| !v.is_empty())
.unwrap_or_else(|| "default".to_string());
- let rows = expand_identity_rows(&toolkit, profile);
+ let rows = expand_identity_rows(config, &toolkit, profile).await?;
if rows.is_empty() {
return Ok(0);
}
@@ -88,15 +89,17 @@ pub async fn persist_provider_profile(
/// Expand a [`ProviderUserProfile`] (and provider-specific `extras`) into the
/// canonical `(kind, value)` rows. **All per-toolkit quirks live here**; the
-/// matcher only sees normalized tuples.
-fn expand_identity_rows(
+/// matcher only sees normalized tuples. Canonicalisation itself runs in the
+/// connector module, in one call for the whole profile.
+async fn expand_identity_rows(
+ config: &Config,
toolkit: &str,
profile: &ProviderUserProfile,
-) -> Vec<(IdentityKind, String)> {
- let mut rows: Vec<(IdentityKind, String)> = Vec::new();
+) -> Result<Vec<(IdentityKind, String)>, String> {
+ let mut candidates: Vec<(IdentityKind, String)> = Vec::new();
let mut push = |kind: IdentityKind, raw: Option<&str>| {
- if let Some(v) = raw.and_then(|s| canonicalize(kind, s)) {
- rows.push((kind, v));
+ if let Some(s) = raw {
+ candidates.push((kind, s.to_string()));
}
};
@@ -127,7 +130,12 @@ fn expand_identity_rows(
}
}
- rows
+ let canonical = canonicalize_values(config, &candidates).await?;
+ Ok(candidates
+ .into_iter()
+ .zip(canonical)
+ .filter_map(|((kind, _), value)| value.map(|v| (kind, v)))
+ .collect())
}
fn json_str<'a>(v: &'a serde_json::Value, key: &str) -> Option<&'a str> {
@@ -155,8 +163,14 @@ pub async fn delete_connected_identity_facets(
source: &str,
identifier: &str,
) -> Result<usize, String> {
- let source = normalize_connection_identifier(source);
- let identifier = normalize_connection_identifier(identifier);
+ let mut keys = normalize_connection_identifiers(
+ config,
+ &[source.to_string(), identifier.to_string()],
+ )
+ .await?
+ .into_iter();
+ let source = keys.next().unwrap_or_default();
+ let identifier = keys.next().unwrap_or_default();
let path = file_store::path(config, IDENTITIES_FILE);
file_store::update(&path, move |identities: &mut Vec<ConnectedIdentity>| {