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
feat(composio): add flow backend integration
Steven Enamakel89e0e380e5d7
diff --git a/crates/openhuman-core/src/integrations/composio/flow_backend.rs b/crates/openhuman-core/src/integrations/composio/flow_backend.rsnew file mode 100644index 0000000000..aa3673ae9e--- /dev/null+++ b/crates/openhuman-core/src/integrations/composio/flow_backend.rs@@ -0,0 +1,84 @@+//! Composio execution for flow tool calls. The flow host supplies generic tier+//! and approval decisions through `FlowCallPolicy`; Composio owns gate order,+//! curation, preflight, account resolution, and dispatch.++use async_trait::async_trait;+use serde_json::Value;+use crate::{config::Config, core::runtime::DispatchCtx, security::{GateDecision, SecurityPolicy}};+use crate::security::approval::ApprovalTurnContext;++#[async_trait]+pub(crate) trait FlowCallPolicy: Send + Sync {+ async fn tier_decision(+ &self,+ dispatch: &DispatchCtx,+ captured: &Config,+ live: &Config,+ security: &SecurityPolicy,+ class: tinybox_bus::CommandClass,+ ) -> Result<GateDecision, String>;+ async fn approve(+ &self,+ dispatch: &DispatchCtx,+ approval: &ApprovalTurnContext,+ decision: GateDecision,+ slug: &str,+ args: &Value,+ ) -> Result<Option<String>, String>;+ fn record(&self, audit_id: &str, result: &Result<Value, String>);+}++pub(crate) struct FlowToolCallCtx<'a> {+ pub dispatch: &'a DispatchCtx,+ pub config: &'a Config,+ pub security: &'a SecurityPolicy,+ pub approval: &'a ApprovalTurnContext,+ pub policy: &'a dyn FlowCallPolicy,+}++pub(crate) async fn preflight(config: &Config, slug: &str, args: &Value) -> Result<(), String> {+ crate::integrations::composio::flow_gate::preflight_composio_args(config, slug, args).await+}++pub(crate) async fn invoke(+ ctx: &FlowToolCallCtx<'_>,+ slug: &str,+ args: Value,+ conn: Option<&str>,+) -> Result<Value, String> {+ let live = crate::config::ops::reload_config_snapshot_with_timeout(ctx.config)+ .await+ .map_err(|_| policy_refresh_error())?;+ if live.recovered_from_corruption { return Err(policy_refresh_error()); }++ // Keep the privacy-sensitive tier decision before curation so a read-only+ // caller cannot probe which actions are in scope.+ let class = crate::integrations::composio::flow_gate::classify_composio_action_for_tier(slug);+ let decision = ctx.policy.tier_decision(ctx.dispatch, ctx.config, &live, ctx.security, class).await?;+ if !crate::integrations::composio::flow_gate::is_curated_flow_tool(ctx.dispatch, &live, slug).await {+ return Err(format!("tool not permitted: {slug}"));+ }+ preflight(&live, slug, &args).await?;+ let audit_id = if decision == GateDecision::Allow { None } else {+ ctx.policy.approve(ctx.dispatch, ctx.approval, decision, slug, &args).await?+ };++ let connection_id = crate::integrations::composio::flow_gate::composio_connection_id(conn);+ let response = crate::integrations::composio::module_client::call::<_, crate::integrations::composio::ComposioExecuteResponse>(+ &live,+ tinyconnectors_bus::names::methods::EXECUTE,+ crate::integrations::composio::types::ComposioExecuteRequest {+ tool: slug.to_string(),+ arguments: (!args.is_null()).then_some(args),+ connection_id: connection_id.map(str::to_string),+ },+ ).await.map_err(|error| error.to_string())+ .and_then(|result| crate::integrations::composio::flow_gate::reject_unsuccessful_composio_response(slug, result).map_err(|error| error.to_string()))+ .and_then(|result| serde_json::to_value(result).map_err(|error| error.to_string()));+ if let Some(audit_id) = audit_id { ctx.policy.record(&audit_id, &response); }+ response+}++fn policy_refresh_error() -> String {+ format!("{} flows autonomy and Composio settings could not be refreshed; refusing the node", tinytools::status::POLICY_BLOCKED_MARKER)+}