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
refactor(composio): thread DispatchCtx through connection and identity ops
Steven Enamakel6f611d8898bd
diff --git a/crates/openhuman-core/src/agent/prompts/connected_identities.rs b/crates/openhuman-core/src/agent/prompts/connected_identities.rsindex a7e4e9cd9e..57c78efb98 100644--- a/crates/openhuman-core/src/agent/prompts/connected_identities.rs+++ b/crates/openhuman-core/src/agent/prompts/connected_identities.rs@@ -36,7 +36,7 @@ async fn render_section(ctx: &crate::core::runtime::DispatchCtx) -> String {}};let identities =- match crate::integrations::composio::identity_store::load_connected_identities(&config)+ match crate::integrations::composio::identity_store::load_connected_identities(ctx, &config).await{Ok(identities) => identities,diff --git a/crates/openhuman-core/src/integrations/composio/bus/connection_created_subscriber.rs b/crates/openhuman-core/src/integrations/composio/bus/connection_created_subscriber.rsindex c77ff6d85f..1a16a8c6e7 100644--- a/crates/openhuman-core/src/integrations/composio/bus/connection_created_subscriber.rs+++ b/crates/openhuman-core/src/integrations/composio/bus/connection_created_subscriber.rs@@ -189,7 +189,7 @@ async fn on_connection_created(ctx: &DispatchCtx, toolkit: String, connection_id);return;}- if let Err(e) = ops::composio_get_user_profile(&live_config, &connection_id).await {+ if let Err(e) = ops::composio_get_user_profile(ctx, &live_config, &connection_id).await {tracing::warn!(toolkit = %toolkit,connection_id = %connection_id,diff --git a/crates/openhuman-core/src/integrations/composio/ops/connections.rs b/crates/openhuman-core/src/integrations/composio/ops/connections.rsindex 492b074076..45140c88f7 100644--- a/crates/openhuman-core/src/integrations/composio/ops/connections.rs+++ b/crates/openhuman-core/src/integrations/composio/ops/connections.rs@@ -24,6 +24,7 @@ use super::error_utils::{use crate::integrations::composio::contract::normalize_connection_identifiers;pub async fn composio_list_connections(+ ctx: &crate::core::runtime::DispatchCtx,config: &Config,) -> OpResult<Outcome<ComposioConnectionsResponse>> {tracing::debug!("[composio] rpc list_connections");@@ -97,11 +98,11 @@ pub async fn composio_list_connections(// connection-created subscriber's readiness window. Re-warm here so// the next chat turn does not perform the three discovery requests.let config = config.clone();- crate::core::runtime::DispatchCtx::ambient().spawn(async move {+ ctx.spawn(async move {let _ = fetch_connected_integrations_status(&config).await;});}- let resp = enrich_connections_with_identity(config, resp).await;+ let resp = enrich_connections_with_identity(ctx, config, resp).await;Ok(Outcome::new(resp,vec![format!(@@ -158,6 +159,7 @@ pub struct ComposioDeleteResult {}pub async fn composio_delete_connection(+ ctx: &crate::core::runtime::DispatchCtx,config: &Config,connection_id: &str,) -> OpResult<Outcome<ComposioDeleteResult>> {@@ -182,7 +184,7 @@ pub async fn composio_delete_connection(format!("[composio] delete_connection failed: {error}")})?;if let Some(toolkit) = toolkit.as_deref() {- let deleted = delete_connected_identity_facets(config, toolkit, connection_id)+ let deleted = delete_connected_identity_facets(ctx, config, toolkit, connection_id).await.unwrap_or_else(|error| {tracing::warn!(@@ -290,10 +292,11 @@ pub(super) async fn resolve_toolkit_for_connection(////// This is best-effort — no live API calls are made (one SQLite read per poll).pub(crate) async fn enrich_connections_with_identity(+ ctx: &crate::core::runtime::DispatchCtx,config: &Config,mut resp: ComposioConnectionsResponse,) -> ComposioConnectionsResponse {- let identities = load_connected_identities(config)+ let identities = load_connected_identities(ctx, config).await.unwrap_or_else(|error| {tracing::debug!(diff --git a/crates/openhuman-core/src/integrations/composio/ops/providers_ops.rs b/crates/openhuman-core/src/integrations/composio/ops/providers_ops.rsindex dd6265796f..2d47bb59b3 100644--- a/crates/openhuman-core/src/integrations/composio/ops/providers_ops.rs+++ b/crates/openhuman-core/src/integrations/composio/ops/providers_ops.rs@@ -28,14 +28,19 @@ pub struct RefreshIdentitiesReport {}/// Persist one profile's identity fields and report how many it wrote.-async fn persist_identity(config: &Config, profile: &ComposioUserProfile) -> OpResult<usize> {+async fn persist_identity(+ ctx: &crate::core::runtime::DispatchCtx,+ config: &Config,+ profile: &ComposioUserProfile,+) -> OpResult<usize> {let native = ProviderUserProfile::from(profile.clone());- super::super::identity_store::persist_provider_profile(config, &native).await+ super::super::identity_store::persist_provider_profile(ctx, config, &native).await}/// `openhuman.composio_get_user_profile` — fetch a normalized user profile for/// a connected account.pub async fn composio_get_user_profile(+ ctx: &crate::core::runtime::DispatchCtx,config: &Config,connection_id: &str,) -> OpResult<Outcome<ProviderUserProfile>> {@@ -56,7 +61,7 @@ pub async fn composio_get_user_profile(format!("[composio] get_user_profile({toolkit}) failed: {error}")})?;- let facets = persist_identity(config, &profile).await?;+ let facets = persist_identity(ctx, config, &profile).await?;tracing::debug!(toolkit = %toolkit,facets_written = facets,@@ -78,6 +83,7 @@ pub async fn composio_get_user_profile(/// failures alongside the profiles it could, because a refresh exists precisely/// to find the broken ones.pub async fn composio_refresh_all_identities(+ ctx: &crate::core::runtime::DispatchCtx,config: &Config,) -> OpResult<Outcome<RefreshIdentitiesReport>> {tracing::info!("[composio] rpc refresh_all_identities");@@ -110,7 +116,7 @@ pub async fn composio_refresh_all_identities(continue;}- let rows = persist_identity(config, profile).await?;+ let rows = persist_identity(ctx, config, profile).await?;report.refreshed += 1;report.rows_written += rows;tracing::debug!(diff --git a/crates/openhuman-core/src/integrations/composio/schemas/handlers_connections.rs b/crates/openhuman-core/src/integrations/composio/schemas/handlers_connections.rsindex 734d269790..68a2e98dfb 100644--- a/crates/openhuman-core/src/integrations/composio/schemas/handlers_connections.rs+++ b/crates/openhuman-core/src/integrations/composio/schemas/handlers_connections.rs@@ -48,7 +48,7 @@ pub(super) fn handle_list_connections() -> ControllerFuture {Box::pin(async move {let config = ctx.load_config().await?;- to_json(ops::composio_list_connections(&config).await?)+ to_json(ops::composio_list_connections(&ctx, &config).await?)})}@@ -68,7 +68,7 @@ pub(super) fn handle_delete_connection(Box::pin(async move {let config = ctx.load_config().await?;let connection_id = read_required_non_empty(¶ms, "connection_id")?;- to_json(ops::composio_delete_connection(&config, &connection_id).await?)+ to_json(ops::composio_delete_connection(&ctx, &config, &connection_id).await?)})}diff --git a/crates/openhuman-core/src/integrations/composio/schemas/handlers_identity.rs b/crates/openhuman-core/src/integrations/composio/schemas/handlers_identity.rsindex 6e21e02ff3..a9088ab7e0 100644--- a/crates/openhuman-core/src/integrations/composio/schemas/handlers_identity.rs+++ b/crates/openhuman-core/src/integrations/composio/schemas/handlers_identity.rs@@ -18,7 +18,7 @@ pub(super) fn handle_get_user_profile(Box::pin(async move {let config = ctx.load_config().await?;let connection_id = read_required_non_empty(¶ms, "connection_id")?;- to_json(ops::composio_get_user_profile(&config, &connection_id).await?)+ to_json(ops::composio_get_user_profile(&ctx, &config, &connection_id).await?)})}@@ -28,7 +28,7 @@ pub(super) fn handle_refresh_all_identities() -> ControllerFuture {Box::pin(async move {let config = ctx.load_config().await?;- to_json(ops::composio_refresh_all_identities(&config).await?)+ to_json(ops::composio_refresh_all_identities(&ctx, &config).await?)})}