Skip to content

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

feat(integrations): add composio authorization and device owner checks

Steven Enamakel69bc15844733
diff --git a/crates/openhuman-core/src/integrations/composio/tools/authorize.rs b/crates/openhuman-core/src/integrations/composio/tools/authorize.rs
index f24a01de07..0fde35e67d 100644
--- a/crates/openhuman-core/src/integrations/composio/tools/authorize.rs
+++ b/crates/openhuman-core/src/integrations/composio/tools/authorize.rs
@@ -8,7 +8,9 @@ use serde_json::{json, Value};
use super::live_config::live_composio_config;
use super::redact::redact_composio_outcome;
use crate::config::Config;
-use tinytools::{PermissionLevel, Tool, ToolCategory, ToolResult};
+use crate::agent::tinyagents::host::run_context::dispatch_ctx_for_tool;
+use crate::core::runtime::DispatchCtx;
+use tinytools::{PermissionLevel, Tool, ToolCallOptions, ToolCategory, ToolResult, ToolRunContext};
use super::super::client::{resolve_composio_route, ComposioRoute};
use super::super::module_client::{self as connectors};
@@ -58,13 +60,23 @@ impl Tool for ComposioAuthorizeTool {
ToolCategory::Workflow
}
async fn execute(&self, args: Value) -> anyhow::Result<ToolResult> {
- let outcome = Box::pin(self.execute_unredacted(args)).await;
+ self.execute_with_context(args, ToolCallOptions::default(), None)
+ .await
+ }
+ async fn execute_with_context(
+ &self,
+ args: Value,
+ _options: ToolCallOptions,
+ context: Option<&dyn ToolRunContext>,
+ ) -> anyhow::Result<ToolResult> {
+ let ctx = dispatch_ctx_for_tool(context);
+ let outcome = Box::pin(self.execute_unredacted(&ctx, args)).await;
redact_composio_outcome(&self.config, outcome)
}
}
impl ComposioAuthorizeTool {
- async fn execute_unredacted(&self, args: Value) -> anyhow::Result<ToolResult> {
+ async fn execute_unredacted(&self, ctx: &DispatchCtx, args: Value) -> anyhow::Result<ToolResult> {
let toolkit = args
.get("toolkit")
.and_then(|v| v.as_str())
@@ -130,6 +142,7 @@ impl ComposioAuthorizeTool {
toolkit: toolkit.clone(),
connection_id: resp.connection_id.clone(),
connect_url: resp.connect_url.clone(),
+ tenant: ctx.event_tenant(),
},
);
Ok(ToolResult::success(format!(
diff --git a/crates/openhuman-core/src/security/devices/owner.rs b/crates/openhuman-core/src/security/devices/owner.rs
index ea415b5f12..aa95f6c92a 100644
--- a/crates/openhuman-core/src/security/devices/owner.rs
+++ b/crates/openhuman-core/src/security/devices/owner.rs
@@ -150,8 +150,8 @@ pub(super) async fn owner_of(
Some(Ok(false)) | None => forget(channel_id),
}
}
- let lookups = crate::storage::agents::for_each_scope("device owner", |scope_ctx| {
- has_live_device(&scope_ctx, channel_id)
+ let lookups = crate::storage::agents::for_each_scope("device owner", |scope_ctx| async move {
+ has_live_device(&scope_ctx, channel_id).await
})
.await;
let owner = decide(lookups)?;