Skip to content

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

feat(composio): split monolithic client module into submodules

Steven Enamakel784dd1658c36
diff --git a/crates/openhuman-core/src/integrations/composio/client.rs b/crates/openhuman-core/src/integrations/composio/client.rs
index 197d7a9dc4..111636ac31 100644
--- a/crates/openhuman-core/src/integrations/composio/client.rs
+++ b/crates/openhuman-core/src/integrations/composio/client.rs
@@ -9,8 +9,26 @@
//! Logging uses the `[composio]` grep-prefix so all sidecar output for
//! this domain can be filtered in one shot.
+mod connections;
+mod direct;
+mod execute;
+mod factory;
+mod triggers;
+
#[cfg(test)]
#[path = "client_tests.rs"]
mod tests;
-include!("client_part_01.rs");
-include!("client_part_02.rs");
+
+pub use connections::ComposioClient;
+pub use direct::{direct_authorize, direct_execute, direct_list_connections, direct_list_tools};
+pub use factory::{
+ build_composio_client, create_composio_client, create_direct_composio_tool_for_api_key,
+ ComposioClientKind,
+};
+
+// Brought into this module's own namespace (private `use`, not `pub use`)
+// so `client_tests.rs` — declared as a direct child module of `client`
+// above — can still reach these via a plain `use super::*;`, exactly as
+// when this was one un-split file. See each item's `pub(super)` in its
+// owning submodule.
+use execute::is_post_oauth_auth_readiness_error;
diff --git a/crates/openhuman-core/src/integrations/file_storage/tools/visibility.rs b/crates/openhuman-core/src/integrations/file_storage/tools/visibility.rs
new file mode 100644
index 0000000000..f5363a706f
--- /dev/null
+++ b/crates/openhuman-core/src/integrations/file_storage/tools/visibility.rs
@@ -0,0 +1,105 @@
+//! `storage_set_visibility` — flip a stored file between public and private.
+
+use std::sync::Arc;
+
+use async_trait::async_trait;
+use serde_json::{json, Value};
+
+use super::helpers::{file_path, readonly_autonomy_block, validate_file_id, validate_visibility};
+use crate::integrations::IntegrationClient;
+use crate::security::SecurityPolicy;
+use crate::tools::traits::{PermissionLevel, Tool, ToolCategory, ToolResult};
+
+use super::types::FileMeta;
+
+pub struct StorageSetVisibilityTool {
+ client: Arc<IntegrationClient>,
+ security: Arc<SecurityPolicy>,
+}
+
+impl StorageSetVisibilityTool {
+ pub fn new(client: Arc<IntegrationClient>) -> Self {
+ Self::new_with_security(client, Arc::new(SecurityPolicy::default()))
+ }
+
+ pub fn new_with_security(
+ client: Arc<IntegrationClient>,
+ security: Arc<SecurityPolicy>,
+ ) -> Self {
+ Self { client, security }
+ }
+}
+
+#[async_trait]
+impl Tool for StorageSetVisibilityTool {
+ fn name(&self) -> &str {
+ "storage_set_visibility"
+ }
+
+ fn description(&self) -> &str {
+ "Change a stored file's visibility. Public files get a stable public URL anyone \
+ can fetch (egress billed to you); private files are only reachable via \
+ authenticated download or presigned links. Visibility changes are free."
+ }
+
+ fn parameters_schema(&self) -> Value {
+ json!({
+ "type": "object",
+ "properties": {
+ "file_id": { "type": "string", "description": "The stored file's id" },
+ "visibility": { "type": "string", "enum": ["public", "private"], "description": "New visibility" }
+ },
+ "required": ["file_id", "visibility"]
+ })
+ }
+
+ fn permission_level(&self) -> PermissionLevel {
+ PermissionLevel::Write
+ }
+
+ fn category(&self) -> ToolCategory {
+ ToolCategory::Workflow
+ }
+
+ fn external_effect(&self) -> bool {
+ true
+ }
+
+ async fn execute(&self, args: Value) -> anyhow::Result<ToolResult> {
+ if let Some(blocked) = readonly_autonomy_block(&self.security) {
+ return Ok(blocked);
+ }
+
+ let file_id = match validate_file_id(&args) {
+ Ok(id) => id,
+ Err(e) => return Ok(ToolResult::error(e)),
+ };
+ let visibility = match args.get("visibility").and_then(|v| v.as_str()) {
+ Some(v) => match validate_visibility(v) {
+ Ok(v) => v,
+ Err(e) => return Ok(ToolResult::error(e)),
+ },
+ None => return Ok(ToolResult::error("visibility is required")),
+ };
+ tracing::debug!("[file_storage] setting visibility={visibility} for file_id={file_id}");
+ match self
+ .client
+ .patch::<FileMeta>(
+ &file_path(&file_id, ""),
+ &json!({ "visibility": visibility }),
+ )
+ .await
+ {
+ Ok(meta) => {
+ let mut md = format!("File {} is now {}.", meta.file_id, meta.visibility);
+ if let Some(url) = &meta.public_url {
+ md.push_str(&format!("\nPublic URL: {url}"));
+ }
+ Ok(ToolResult::success_with_markdown(meta.to_json(), md))
+ }
+ Err(e) => Ok(ToolResult::error(format!(
+ "Failed to change file visibility: {e}"
+ ))),
+ }
+ }
+}