Skip to content

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

refactor(tools): move domain tool construction into registered_tools

Steven Enamakel66a5c0559241
diff --git a/crates/openhuman-core/src/desktop/control/tools.rs b/crates/openhuman-core/src/desktop/control/tools.rs
index 5c0bd6ce39..7d3f1d59e5 100644
--- a/crates/openhuman-core/src/desktop/control/tools.rs
+++ b/crates/openhuman-core/src/desktop/control/tools.rs
@@ -424,6 +424,24 @@ impl Tool for DesktopTool {
}
}
+/// Build this domain's tools in their persisted catalogue order.
+pub(crate) fn registered_tools(
+ config: std::sync::Arc<crate::config::Config>,
+) -> Vec<Box<dyn tinytools::Tool>> {
+ vec![
+ Box::new(DesktopTool::new(config.clone(), DesktopToolKind::Apps)),
+ Box::new(DesktopTool::new(config.clone(), DesktopToolKind::Windows)),
+ Box::new(DesktopTool::new(config.clone(), DesktopToolKind::Launch)),
+ Box::new(DesktopTool::new(config.clone(), DesktopToolKind::Snapshot)),
+ Box::new(DesktopTool::new(config.clone(), DesktopToolKind::Find)),
+ Box::new(DesktopTool::new(config.clone(), DesktopToolKind::Goal)),
+ Box::new(DesktopTool::new(
+ config.clone(),
+ DesktopToolKind::ContinueGoal,
+ )),
+ ]
+}
+
#[cfg(test)]
#[path = "tools_tests.rs"]
mod tests;
diff --git a/crates/openhuman-core/src/integrations/tools.rs b/crates/openhuman-core/src/integrations/tools.rs
index 4cb3d10d6a..50850802fb 100644
--- a/crates/openhuman-core/src/integrations/tools.rs
+++ b/crates/openhuman-core/src/integrations/tools.rs
@@ -8,3 +8,14 @@ pub use stock_prices::{
StockCommodityTool, StockCryptoSeriesTool, StockExchangeRateTool, StockOptionsTool,
StockQuoteTool,
};
+
+/// Build this domain's tools in their persisted catalogue order.
+pub(crate) fn registered_tools(
+ config: std::sync::Arc<crate::config::Config>,
+) -> Vec<Box<dyn tinytools::Tool>> {
+ vec![
+ Box::new(SessionStateTool::new(config.clone())),
+ Box::new(OAuthConnectUrlTool::new(config.clone())),
+ Box::new(OAuthListTool::new(config.clone())),
+ ]
+}
diff --git a/crates/openhuman-core/src/mcp/registry/tools.rs b/crates/openhuman-core/src/mcp/registry/tools.rs
index 070f90e4a9..1f96b6f55c 100644
--- a/crates/openhuman-core/src/mcp/registry/tools.rs
+++ b/crates/openhuman-core/src/mcp/registry/tools.rs
@@ -286,6 +286,23 @@ impl Tool for McpRegistryUninstallTool {
}
}
+/// Build this domain's tools in their persisted catalogue order.
+pub(crate) fn registered_tools(
+ config: std::sync::Arc<crate::config::Config>,
+) -> Vec<Box<dyn tinytools::Tool>> {
+ vec![
+ Box::new(McpRegistrySearchTool::new(config.clone())),
+ Box::new(McpRegistryGetTool::new(config.clone())),
+ Box::new(McpRegistryInstalledListTool::new(config.clone())),
+ Box::new(McpRegistryStatusTool::new(config.clone())),
+ Box::new(McpRegistryListToolsTool::new(config.clone())),
+ Box::new(McpRegistryConnectTool::new(config.clone())),
+ Box::new(McpRegistryDisconnectTool::new(config.clone())),
+ Box::new(McpRegistryToolCallTool::new(config.clone())),
+ Box::new(McpRegistryUninstallTool::new(config.clone())),
+ ]
+}
+
#[cfg(test)]
#[path = "tools_tests.rs"]
mod tests;
diff --git a/crates/openhuman-core/src/security/credentials/tools.rs b/crates/openhuman-core/src/security/credentials/tools.rs
index a19b071268..8e741e7772 100644
--- a/crates/openhuman-core/src/security/credentials/tools.rs
+++ b/crates/openhuman-core/src/security/credentials/tools.rs
@@ -227,6 +227,13 @@ impl Tool for OAuthListTool {
}
}
+/// Build this domain's tools in their persisted catalogue order.
+pub(crate) fn registered_tools(
+ config: std::sync::Arc<crate::config::Config>,
+) -> Vec<Box<dyn tinytools::Tool>> {
+ vec![Box::new(CredentialListTool::new(config.clone()))]
+}
+
#[cfg(test)]
#[path = "tools_tests.rs"]
mod tests;
diff --git a/crates/openhuman-core/src/security/tools.rs b/crates/openhuman-core/src/security/tools.rs
index 4eab01a77f..d1b84e4eb0 100644
--- a/crates/openhuman-core/src/security/tools.rs
+++ b/crates/openhuman-core/src/security/tools.rs
@@ -55,6 +55,13 @@ impl Tool for SecurityPolicyInfoTool {
}
}
+/// Build this domain's tools in their persisted catalogue order.
+pub(crate) fn registered_tools(
+ config: std::sync::Arc<crate::config::Config>,
+) -> Vec<Box<dyn tinytools::Tool>> {
+ vec![Box::new(SecurityPolicyInfoTool::new(config.clone()))]
+}
+
#[cfg(test)]
#[path = "tools_tests.rs"]
mod tests;
diff --git a/crates/openhuman-core/src/tools/mod.rs b/crates/openhuman-core/src/tools/mod.rs
index 5a359eb815..d5c8c07da4 100644
--- a/crates/openhuman-core/src/tools/mod.rs
+++ b/crates/openhuman-core/src/tools/mod.rs
@@ -18,19 +18,10 @@ pub(crate) mod implementations;
pub use crate::agent::orchestration::tools::*;
pub use crate::agent::tools::*;
-#[cfg(feature = "modules")]
-pub use crate::desktop::control::tools::*;
pub use crate::integrations::composio::tools::*;
-pub use crate::integrations::tools::*;
-#[cfg(feature = "mcp")]
-pub use crate::mcp::registry::tools::*;
pub use crate::memory::tools::{MemoryTool, MEMORY_TOOL_NAME};
#[cfg(feature = "modules")]
pub use crate::search::TinySearchTool;
-pub use crate::security::credentials::tools::*;
-pub use crate::security::tools::*;
-#[cfg(feature = "voice")]
-pub use crate::voice::audio_toolkit::tools::*;
pub use implementations::*;
pub use schemas::{
all_controller_schemas as all_tools_controller_schemas,
diff --git a/crates/openhuman-core/src/tools/ops.rs b/crates/openhuman-core/src/tools/ops.rs
index 4229254dc9..33a22e50eb 100644
--- a/crates/openhuman-core/src/tools/ops.rs
+++ b/crates/openhuman-core/src/tools/ops.rs
@@ -201,23 +201,13 @@ pub fn all_tools_with_runtime(
security.clone(),
action_dir.to_path_buf(),
)),
- // Audio-toolkit podcast tools — gated with the `voice` feature (they
- // live in the `audio_toolkit` domain, which is compiled out when voice
- // is disabled).
- #[cfg(feature = "voice")]
- Box::new(AudioGeneratePodcastTool::new(
- config.clone(),
- security.clone(),
- )),
- #[cfg(feature = "voice")]
- Box::new(AudioEmailPodcastTool::new(config.clone(), security.clone())),
- #[cfg(feature = "voice")]
- Box::new(AudioGenerateAndEmailPodcastTool::new(
- config.clone(),
- security.clone(),
- )),
- Box::new(GmailUnsubscribeTool),
]);
+ #[cfg(feature = "voice")]
+ tools.extend(crate::voice::audio_toolkit::tools::registered_tools(
+ config.clone(),
+ security,
+ ));
+ tools.extend(vec![Box::new(GmailUnsubscribeTool)]);
#[cfg(feature = "skills")]
tools.extend(crate::skills::registration::tools(config.clone()));
tools.extend(vec![
@@ -250,26 +240,14 @@ pub fn all_tools_with_runtime(
tools.extend(crate::desktop::dashboard::tools::registered_tools(
config.clone(),
));
- tools.extend(vec![
- #[cfg(feature = "modules")]
- Box::new(DesktopTool::new(config.clone(), DesktopToolKind::Apps)),
- #[cfg(feature = "modules")]
- Box::new(DesktopTool::new(config.clone(), DesktopToolKind::Windows)),
- #[cfg(feature = "modules")]
- Box::new(DesktopTool::new(config.clone(), DesktopToolKind::Launch)),
- #[cfg(feature = "modules")]
- Box::new(DesktopTool::new(config.clone(), DesktopToolKind::Snapshot)),
- #[cfg(feature = "modules")]
- Box::new(DesktopTool::new(config.clone(), DesktopToolKind::Find)),
- #[cfg(feature = "modules")]
- Box::new(DesktopTool::new(config.clone(), DesktopToolKind::Goal)),
- #[cfg(feature = "modules")]
- Box::new(DesktopTool::new(
- config.clone(),
- DesktopToolKind::ContinueGoal,
- )),
- Box::new(SecurityPolicyInfoTool::new(config.clone())),
- ]);
+ tools.extend(vec![]);
+ #[cfg(feature = "modules")]
+ tools.extend(crate::desktop::control::tools::registered_tools(
+ config.clone(),
+ ));
+ tools.extend(vec![]);
+ tools.extend(crate::security::tools::registered_tools(config.clone()));
+ tools.extend(vec![]);
tools.extend(crate::platform::service::tools::registered_tools(
config.clone(),
));
@@ -284,10 +262,13 @@ pub fn all_tools_with_runtime(
// surfaces, not things an agent should reach for mid-turn, and their
// controllers remain registered for the UI. `credentials` exposes only
// non-secret reads.
- Box::new(CredentialListTool::new(config.clone())),
- Box::new(SessionStateTool::new(config.clone())),
- Box::new(OAuthConnectUrlTool::new(config.clone())),
- Box::new(OAuthListTool::new(config.clone())),
+ ]);
+ tools.extend(crate::security::credentials::tools::registered_tools(
+ config.clone(),
+ ));
+ tools.extend(vec![]);
+ tools.extend(crate::integrations::tools::registered_tools(config.clone()));
+ tools.extend(vec![
// MCP registry and workspace persona. Observe/connect/call tools
// default-ON; MCP uninstall (mcp_manage), and persona/workspace writers
// (workspace_manage) ship default-OFF via `tools::user_filter`. There
@@ -296,25 +277,12 @@ pub fn all_tools_with_runtime(
// MCP registry (dynamic, user-installed servers) — compiled out with
// the `mcp` feature. Per-element attrs inside the `vec![]` mirror the
// voice idiom used earlier in this same literal.
- #[cfg(feature = "mcp")]
- Box::new(McpRegistrySearchTool::new(config.clone())),
- #[cfg(feature = "mcp")]
- Box::new(McpRegistryGetTool::new(config.clone())),
- #[cfg(feature = "mcp")]
- Box::new(McpRegistryInstalledListTool::new(config.clone())),
- #[cfg(feature = "mcp")]
- Box::new(McpRegistryStatusTool::new(config.clone())),
- #[cfg(feature = "mcp")]
- Box::new(McpRegistryListToolsTool::new(config.clone())),
- #[cfg(feature = "mcp")]
- Box::new(McpRegistryConnectTool::new(config.clone())),
- #[cfg(feature = "mcp")]
- Box::new(McpRegistryDisconnectTool::new(config.clone())),
- #[cfg(feature = "mcp")]
- Box::new(McpRegistryToolCallTool::new(config.clone())),
- #[cfg(feature = "mcp")]
- Box::new(McpRegistryUninstallTool::new(config.clone())),
]);
+ #[cfg(feature = "mcp")]
+ tools.extend(crate::mcp::registry::tools::registered_tools(
+ config.clone(),
+ ));
+ tools.extend(vec![]);
tools.extend(crate::config::workspace::tools::registered_tools(
config.clone(),
));
diff --git a/crates/openhuman-core/src/voice/audio_toolkit/tools.rs b/crates/openhuman-core/src/voice/audio_toolkit/tools.rs
index 3d196dde24..ead0c3ab73 100644
--- a/crates/openhuman-core/src/voice/audio_toolkit/tools.rs
+++ b/crates/openhuman-core/src/voice/audio_toolkit/tools.rs
@@ -3,3 +3,24 @@ mod podcast;
pub use podcast::{
AudioEmailPodcastTool, AudioGenerateAndEmailPodcastTool, AudioGeneratePodcastTool,
};
+
+/// Build this domain's tools in their persisted catalogue order.
+pub(crate) fn registered_tools(
+ config: std::sync::Arc<crate::config::Config>,
+ security: &std::sync::Arc<crate::security::SecurityPolicy>,
+) -> Vec<Box<dyn tinytools::Tool>> {
+ vec![
+ // Audio-toolkit podcast tools — gated with the `voice` feature (they
+ // live in the `audio_toolkit` domain, which is compiled out when voice
+ // is disabled).
+ Box::new(AudioGeneratePodcastTool::new(
+ config.clone(),
+ security.clone(),
+ )),
+ Box::new(AudioEmailPodcastTool::new(config.clone(), security.clone())),
+ Box::new(AudioGenerateAndEmailPodcastTool::new(
+ config.clone(),
+ security.clone(),
+ )),
+ ]
+}