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 store and scope preference persistence

Steven Enamakel8e37dbd88abe
diff --git a/crates/openhuman-core/src/integrations/composio/identity_store.rs b/crates/openhuman-core/src/integrations/composio/identity_store.rs
index 7f5f7ebc96..33edd37986 100644
--- a/crates/openhuman-core/src/integrations/composio/identity_store.rs
+++ b/crates/openhuman-core/src/integrations/composio/identity_store.rs
@@ -45,10 +45,9 @@ pub async fn persist_provider_profile(
return Ok(0);
}
- let path = file_store::path(config, IDENTITIES_FILE);
let written = rows.len();
let (key_source, key_identifier) = (toolkit.clone(), identifier.clone());
- file_store::update(&path, move |identities: &mut Vec<ConnectedIdentity>| {
+ file_store::update(config, IDENTITIES_FILE, move |identities: &mut Vec<ConnectedIdentity>| {
let index = match identities
.iter()
.position(|id| id.source == key_source && id.identifier == key_identifier)
@@ -151,7 +150,7 @@ fn json_str<'a>(v: &'a serde_json::Value, key: &str) -> Option<&'a str> {
///
/// The identities file exists but cannot be read or parsed.
pub async fn load_connected_identities(config: &Config) -> Result<Vec<ConnectedIdentity>, String> {
- file_store::load(&file_store::path(config, IDENTITIES_FILE)).await
+ file_store::load(config, IDENTITIES_FILE).await
}
/// Delete the stored identity for a `(source, connection_id)` pair — used on
@@ -172,8 +171,7 @@ pub async fn delete_connected_identity_facets(
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>| {
+ file_store::update(config, IDENTITIES_FILE, move |identities: &mut Vec<ConnectedIdentity>| {
let mut deleted = 0usize;
identities.retain(|id| {
if id.source == source && id.identifier == identifier {
diff --git a/crates/openhuman-core/src/integrations/composio/ops/scope_prefs.rs b/crates/openhuman-core/src/integrations/composio/ops/scope_prefs.rs
index 24f17e0531..f2ed283caa 100644
--- a/crates/openhuman-core/src/integrations/composio/ops/scope_prefs.rs
+++ b/crates/openhuman-core/src/integrations/composio/ops/scope_prefs.rs
@@ -5,8 +5,8 @@
//! forwarder the `composio.{get,set}_user_scopes` handlers, the agent's scope
//! gate and the flows capability gate read through.
//!
-//! Before the module owned the rows the host kept them in
-//! `<workspace>/integrations/composio_user_scopes.json`. [`migrate_legacy`]
+//! Before the module owned the rows the host kept them in the
+//! `composio_user_scopes.json` state value. [`migrate_legacy`]
//! moves any rows still there into the module (once per workspace, on the
//! first read or write) and then empties that file, so a preference a user
//! chose before the move still decides what the agent may run.
@@ -65,8 +65,7 @@ async fn migrate_legacy(config: &Config) {
{
return;
}
- let path = file_store::path(config, USER_SCOPES_FILE);
- let rows = match file_store::load::<LegacyScopeFile>(&path).await {
+ let rows = match file_store::load::<LegacyScopeFile>(config, USER_SCOPES_FILE).await {
Ok(rows) => rows,
Err(error) => {
// Unreadable is not "no rows": keep the file and try again later.
@@ -91,7 +90,7 @@ async fn migrate_legacy(config: &Config) {
}
}
if !rows.is_empty() {
- let cleared = file_store::update(&path, |prefs: &mut LegacyScopeFile| {
+ let cleared = file_store::update(config, USER_SCOPES_FILE, |prefs: &mut LegacyScopeFile| {
prefs.clear();
((), true)
})