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(integrations): register tool sources and integration tools
Steven Enamakel7eb7e8d79e54
diff --git a/crates/openhuman-tinyhumans/src/integrations/composio.rs b/crates/openhuman-tinyhumans/src/integrations/composio.rsnew file mode 100644index 0000000000..b576147796--- /dev/null+++ b/crates/openhuman-tinyhumans/src/integrations/composio.rs@@ -0,0 +1,46 @@+//! The Composio backend route.+//!+//! `composio.mode = "backend"` sends Composio calls through the TinyHumans+//! backend's proxy. The core decides nothing about that mode itself: it asks+//! the route builder and proxy-target resolver registered here+//! ([`register`]). With this crate absent the mode answers+//! `BACKEND_UNAVAILABLE:`.++use openhuman_embed::__host::composio::{+ register_composio_route_builder, register_proxy_target, ComposioRoute, ProxyTarget,+};+use openhuman_embed::__host::config::schema::COMPOSIO_MODE_BACKEND;+use openhuman_embed::__host::config::Config;++use super::build_client;++/// The message when the backend mode has no usable credential. Wording is+/// load-bearing: the core's session-expiry classifier recognises "no backend+/// session token" and demotes it to an expected user-state error.+const NO_SESSION: &str =+ "composio backend mode unavailable: no backend session token. Sign in or set a TinyHumans API key.";++/// The proxy target for `config`: the backend origin and the credential secret.+fn proxy_target(config: &Config) -> Result<ProxyTarget, String> {+ let client = build_client(config).ok_or_else(|| {+ "composio backend mode is unavailable: no backend session token. Sign in or set a TinyHumans API key."+ .to_string()+ })?;+ Ok(ProxyTarget {+ base_url: client.backend_url.clone(),+ auth_token: client.auth_token.clone(),+ })+}++/// Registers the backend route builder and proxy target with the core.+/// Idempotent.+pub(crate) fn register() {+ register_composio_route_builder(COMPOSIO_MODE_BACKEND, |config| {+ if build_client(config).is_none() {+ anyhow::bail!("{NO_SESSION}");+ }+ log::debug!("[tinyhumans] composio: resolved backend route");+ Ok(ComposioRoute::Backend)+ });+ register_proxy_target(COMPOSIO_MODE_BACKEND, proxy_target);+}diff --git a/crates/openhuman-tinyhumans/src/integrations/mod.rs b/crates/openhuman-tinyhumans/src/integrations/mod.rsindex 239e543933..314d1de0f5 100644--- a/crates/openhuman-tinyhumans/src/integrations/mod.rs+++ b/crates/openhuman-tinyhumans/src/integrations/mod.rs@@ -12,10 +12,13 @@//! `install()`.pub mod client;+pub mod composio;pub mod file_storage;+#[cfg(feature = "media")]pub mod media;pub mod tools;pub mod types;+#[cfg(feature = "web3")]pub mod web3;pub use client::{build_client, pricing_for_config, IntegrationClient};@@ -23,13 +26,36 @@ pub use types::{BackendResponse, IntegrationPricing, IntegrationPricingEntry, PricingIntegrations,};+use openhuman_embed::__host::tool_sources::register_tool_source;+use crate::install::InstallOptions;/// Registers this area's hooks with the core. Idempotent.+///+/// The tool sources register in the order the core used to build them inline+/// (media, file storage, then the Google Places / stock tools), but they now+/// follow every built-in tool in the catalogue instead of sitting between the+/// search and hosting tools.pub(crate) fn register(_options: &InstallOptions) {- log::trace!("[tinyhumans] integrations: nothing to register yet");+ #[cfg(feature = "media")]+ media::register();+ register_tool_source(FILE_STORAGE_SOURCE_ID, |ctx| {+ file_storage::build_file_storage_tools(ctx.root_config, ctx.action_dir)+ });+ register_tool_source(INTEGRATION_TOOLS_SOURCE_ID, |ctx| {+ tools::build_integration_tools(ctx.root_config)+ });+ #[cfg(feature = "web3")]+ web3::register();+ composio::register();+ log::debug!("[tinyhumans] integrations: tool sources, wallet backend and composio route registered");}+/// The id the file-storage tool source registers under.+pub const FILE_STORAGE_SOURCE_ID: &str = "tinyhumans-file-storage";+/// The id the Google Places / stock tool source registers under.+pub const INTEGRATION_TOOLS_SOURCE_ID: &str = "tinyhumans-integrations";+#[cfg(test)]#[path = "mod_tests.rs"]mod tests;diff --git a/crates/openhuman-tinyhumans/src/integrations/tools/mod.rs b/crates/openhuman-tinyhumans/src/integrations/tools/mod.rsindex a0c456d61c..3d5bf34c97 100644--- a/crates/openhuman-tinyhumans/src/integrations/tools/mod.rs+++ b/crates/openhuman-tinyhumans/src/integrations/tools/mod.rs@@ -8,3 +8,42 @@ pub use stock_prices::{StockCommodityTool, StockCryptoSeriesTool, StockExchangeRateTool, StockOptionsTool,StockQuoteTool,};++/// The Google Places and stock-data tools over a client built from `config`,+/// or nothing when there is no usable backend credential. Each family is+/// gated by its own `[integrations.*]` switch.+///+/// Web search providers (Exa, Gemini, TinyFish, ...) register through the+/// TinySearch module, so `[search] enabled = false` suppresses them too;+/// `integrations.parallel` is parsed for old config files and no longer does+/// anything.+pub fn build_integration_tools(+ root_config: &openhuman_embed::__host::config::Config,+) -> Vec<Box<dyn tinytools::Tool>> {+ use std::sync::Arc;++ let mut tools: Vec<Box<dyn tinytools::Tool>> = Vec::new();+ let Some(client) = super::build_client(root_config) else {+ log::debug!("[integrations] build_client returned None; integration tools not registered");+ return tools;+ };+ log::debug!("[integrations] client built successfully");+ if root_config.integrations.google_places.is_active() {+ tools.push(Box::new(GooglePlacesSearchTool::new(Arc::clone(&client))));+ tools.push(Box::new(GooglePlacesDetailsTool::new(Arc::clone(&client))));+ log::debug!("[integrations] registered google_places tools");+ } else {+ log::debug!("[integrations] google_places disabled; skipping");+ }+ if root_config.integrations.stock_prices.is_active() {+ tools.push(Box::new(StockQuoteTool::new(Arc::clone(&client))));+ tools.push(Box::new(StockExchangeRateTool::new(Arc::clone(&client))));+ tools.push(Box::new(StockOptionsTool::new(Arc::clone(&client))));+ tools.push(Box::new(StockCryptoSeriesTool::new(Arc::clone(&client))));+ tools.push(Box::new(StockCommodityTool::new(Arc::clone(&client))));+ log::debug!("[integrations] registered stock_prices tools");+ } else {+ log::debug!("[integrations] stock_prices disabled; skipping");+ }+ tools+}diff --git a/crates/openhuman-tinyhumans/src/integrations/web3/mod.rs b/crates/openhuman-tinyhumans/src/integrations/web3/mod.rsnew file mode 100644index 0000000000..6cb5c8a3cd--- /dev/null+++ b/crates/openhuman-tinyhumans/src/integrations/web3/mod.rs@@ -0,0 +1,29 @@+//! The web3 crypto client (`/agent-integrations/crypto/*`, deBridge DLN) and+//! the wallet-backend handler that serves the wallet module's callbacks with it.+//!+//! The core's wallet host forwards the module's `WalletBackend` requests to the+//! handler registered here ([`register`]); with this crate absent the callback+//! answers `BACKEND_UNAVAILABLE:`.++pub mod client;++use openhuman_embed::__host::wallet_backend::{register_wallet_backend, WalletBackendCall};++pub use client::CryptoClient;++/// The id the wallet-backend handler registers under.+pub const HANDLER_ID: &str = "tinyhumans-web3";++/// Registers the wallet-backend handler with the core. Idempotent.+pub(crate) fn register() {+ register_wallet_backend(HANDLER_ID, |config, call| {+ Box::pin(async move {+ let client = CryptoClient::from_config(&config)?;+ match call {+ WalletBackendCall::Routes => client.routes().await,+ WalletBackendCall::SwapTransaction(body) => client.swap_tx(&body).await,+ WalletBackendCall::BridgeTransaction(body) => client.bridge_tx(&body).await,+ }+ })+ });+}