Skip to content

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

chore(search): remove unused test files and vendor dependency

Steven Enamakelbd6928d79059
diff --git a/crates/openhuman-core/src/modules/search.rs b/crates/openhuman-core/src/modules/search.rs
deleted file mode 100644
index 913ab5374f..0000000000
--- a/crates/openhuman-core/src/modules/search.rs
+++ /dev/null
@@ -1,291 +0,0 @@
-//! Host adapter for the TinySearch module. Secrets enter only through private
-//! TinyBus initialization and reinitialization payloads.
-
-use std::{
- collections::BTreeMap,
- future::Future,
- hash::{Hash, Hasher},
- sync::OnceLock,
-};
-use tinysearch_bus::{
- names, BackendAuthMode, BackendConfig, ExecuteToolRequest, ExecuteToolResponse,
- ListToolsResponse, PresentationConfig, PresentationMode, ProviderConfig, ProviderRoute,
- SearchConfig as ModuleSearchConfig,
-};
-
-use crate::config::Config;
-
-pub const MODULE_ID: &str = "tinysearch";
-
-fn provider(
- enabled: bool,
- credential: Option<&str>,
- route: ProviderRoute,
- max_results: Option<u64>,
- timeout_secs: Option<u64>,
-) -> ProviderConfig {
- ProviderConfig {
- enabled,
- credential: credential.map(str::to_owned),
- route,
- max_results,
- timeout_secs,
- ..Default::default()
- }
-}
-
-/// The complete private configuration for TinySearch. No credentials are
-/// returned over settings RPC or sent on ordinary bus method calls.
-pub fn module_config(config: &Config) -> ModuleSearchConfig {
- let credential =
- crate::security::credentials::session_support::resolve_backend_credential(config).ok();
- let selected = config.search.providers(
- credential.is_some(),
- config.integrations.tinyfish.is_active(),
- config.seltz.enabled
- && config
- .seltz
- .api_key
- .as_deref()
- .is_some_and(|key| !key.trim().is_empty()),
- config.searxng.enabled,
- );
- let backend = BackendConfig {
- base_url: Some(crate::api::effective_backend_api_url(&config.api_url)),
- auth_mode: if credential.as_ref().is_some_and(|c| c.is_api_key()) {
- BackendAuthMode::ApiKey
- } else {
- BackendAuthMode::Session
- },
- credential: credential.map(|c| c.into_secret()),
- sdk_name: Some(crate::api::product_identity().as_str().to_owned()),
- };
- let mut providers = BTreeMap::new();
- let limits = (
- Some(config.search.max_results as u64),
- Some(config.search.timeout_secs),
- );
- for (name, key) in [
- ("brave", config.search.brave.key()),
- ("querit", config.search.querit.key()),
- ("exa", config.search.exa.key()),
- ("tavily", config.search.tavily.key()),
- ("gemini", config.search.gemini.key()),
- ("parallel", config.search.parallel.key()),
- ] {
- let route = if (name == "parallel" && config.search.parallel_route == "backend")
- || (name == "gemini" && config.search.gemini_route == "backend")
- {
- ProviderRoute::Backend
- } else {
- ProviderRoute::Direct
- };
- let enabled = selected.contains(name)
- && (key.is_some() || (route == ProviderRoute::Backend && backend.credential.is_some()));
- providers.insert(
- name.into(),
- provider(enabled, key, route, limits.0, limits.1),
- );
- }
- // TinySearch names managed search `parallel` with its backend route.
- // A usable direct Parallel route takes precedence until the bus can
- // represent both routes of that provider at once. If no direct key is
- // present, preserve the managed backend route.
- if selected.contains("managed")
- && (!selected.contains("parallel")
- || (config.search.parallel_route != "backend" && !config.search.parallel.has_key()))
- {
- providers.insert(
- "parallel".into(),
- provider(
- backend.credential.is_some(),
- None,
- ProviderRoute::Backend,
- limits.0,
- limits.1,
- ),
- );
- }
- providers.insert(
- "tinyfish".into(),
- provider(
- selected.contains("tinyfish")
- && (config.search.enabled_providers.is_some()
- || config.integrations.tinyfish.is_active()),
- None,
- ProviderRoute::Backend,
- limits.0,
- limits.1,
- ),
- );
- // Deep Research is direct-only even when grounded Gemini search takes
- // the managed backend route.
- providers.insert(
- "gemini_deep_research".into(),
- provider(
- selected.contains("gemini") && config.search.gemini.has_key(),
- config.search.gemini.key(),
- ProviderRoute::Direct,
- limits.0,
- limits.1,
- ),
- );
- providers.insert(
- "seltz".into(),
- ProviderConfig {
- enabled: selected.contains("seltz")
- && config
- .seltz
- .api_key
- .as_deref()
- .is_some_and(|key| !key.trim().is_empty()),
- credential: config.seltz.api_key.clone(),
- base_url: config.seltz.api_url.clone(),
- max_results: Some(config.seltz.max_results as u64),
- timeout_secs: Some(config.seltz.timeout_secs),
- ..Default::default()
- },
- );
- providers.insert(
- "searxng".into(),
- ProviderConfig {
- enabled: selected.contains("searxng"),
- base_url: Some(config.searxng.base_url.clone()),
- max_results: Some(config.searxng.max_results as u64),
- timeout_secs: Some(config.searxng.timeout_secs),
- default_language: Some(config.searxng.default_language.clone()),
- ..Default::default()
- },
- );
- ModuleSearchConfig {
- enabled: config.search.is_enabled(),
- backend,
- providers,
- presentation: PresentationConfig {
- mode: match config.search.presentation.as_str() {
- "router" => PresentationMode::Router,
- "one_provider" => PresentationMode::OneProvider,
- _ => PresentationMode::AllTools,
- },
- provider: config.search.presentation_provider.as_deref().map(|name| {
- if name == "managed" {
- "parallel".to_owned()
- } else {
- name.to_owned()
- }
- }),
- },
- }
-}
-
-/// Deterministic declarations for synchronous tool registration. Invocation
-/// still refreshes the module and lets it validate the current tool set.
-pub fn configured_tool_specs(config: &Config) -> Vec<tinysearch_bus::ToolSpec> {
- let module = module_config(config);
- let available =
- tinysearch_bus::configured_provider_tools(&module, &tinysearch_bus::provider_tool_specs());
- tinysearch_bus::select_tools(&available, &module.presentation).tools
-}
-
-fn last_config() -> &'static tokio::sync::Mutex<Option<u64>> {
- static LAST: OnceLock<tokio::sync::Mutex<Option<u64>>> = OnceLock::new();
- LAST.get_or_init(|| tokio::sync::Mutex::new(None))
-}
-
-fn fingerprint(value: &serde_json::Value) -> u64 {
- let mut hasher = std::collections::hash_map::DefaultHasher::new();
- value.to_string().hash(&mut hasher);
- hasher.finish()
-}
-
-async fn proxy(config: &Config) -> Result<tinybus::Proxy, String> {
- super::ops::ensure_loaded_within(config, MODULE_ID, Some(std::time::Duration::from_secs(8)))
- .await
- .map_err(super::ops::LoadError::into_message)?;
- let runtime = super::host::runtime()
- .await
- .map_err(|error| format!("search module bus unavailable: {error}"))?;
- let configuration =
- serde_json::to_value(module_config(config)).map_err(|error| error.to_string())?;
- let current = fingerprint(&configuration);
- // Caller holds the module call lock through the subsequent bus call.
- let mut previous = last_config().lock().await;
- if *previous != Some(current) {
- runtime
- .connection()
- .reinitialize_module(MODULE_ID, configuration)
- .await
- .map_err(|error| format!("search module configuration refresh failed: {error}"))?;
- *previous = Some(current);
- }
- runtime
- .proxy(names::INTERFACE, names::OBJECT_PATH)
- .map_err(|error| format!("search module proxy unavailable: {error}"))
-}
-
-async fn with_module_lock<T, F, Fut>(operation: F) -> Result<T, String>
-where
- F: FnOnce() -> Fut,
- Fut: Future<Output = Result<T, String>>,
-{
- static CALL_LOCK: OnceLock<tokio::sync::Mutex<()>> = OnceLock::new();
- let guard = CALL_LOCK
- .get_or_init(|| tokio::sync::Mutex::new(()))
- .lock()
- .await;
- let result = operation().await;
- drop(guard);
- result
-}
-
-async fn current_config(config: &Config) -> Result<Config, String> {
- crate::config::ops::reload_config_from_paths(&config.config_path, &config.workspace_dir).await
-}
-
-/// Refresh a loaded module after a settings or login change. An unloaded
-/// module gets the current configuration during its first initialization.
-pub async fn refresh_loaded(config: &Config) -> Result<(), String> {
- if matches!(
- super::ops::state_of(MODULE_ID),
- super::types::ModuleState::Ready
- ) {
- let current = current_config(config).await?;
- with_module_lock(|| async {
- let _ = proxy(&current).await?;
- Ok(())
- })
- .await?;
- }
- Ok(())
-}
-
-pub async fn list_tools(config: &Config) -> Result<ListToolsResponse, String> {
- let current = current_config(config).await?;
- with_module_lock(|| async {
- proxy(&current)
- .await?
- .call(names::methods::LIST_TOOLS, ())
- .await
- .map_err(|error| format!("search ListTools failed: {error}"))
- })
- .await
-}
-
-pub async fn execute_tool(
- config: &Config,
- request: ExecuteToolRequest,
-) -> Result<ExecuteToolResponse, String> {
- let current = current_config(config).await?;
- with_module_lock(|| async {
- proxy(&current)
- .await?
- .call_confidential(names::methods::EXECUTE_TOOL, (request,))
- .await
- .map_err(|error| format!("search ExecuteTool failed: {error}"))
- })
- .await
-}
-
-#[cfg(test)]
-#[path = "search_tests.rs"]
-mod tests;
diff --git a/crates/openhuman-core/src/modules/search_tests.rs b/crates/openhuman-core/src/modules/search/config_tests.rs
similarity index 100%
rename from crates/openhuman-core/src/modules/search_tests.rs
rename to crates/openhuman-core/src/modules/search/config_tests.rs
diff --git a/crates/openhuman-core/src/modules/search/mod.rs b/crates/openhuman-core/src/modules/search/mod.rs
new file mode 100644
index 0000000000..1e11d9992e
--- /dev/null
+++ b/crates/openhuman-core/src/modules/search/mod.rs
@@ -0,0 +1,149 @@
+//! Host adapter for the TinySearch module.
+//!
+//! `module_config` turns the host's resolved search policy
+//! (`crate::search::providers`) into the module's private configuration.
+//! Secrets enter only through that configuration, delivered at TinyBus
+//! initialization and reinitialization; they never ride an ordinary method
+//! call or a settings RPC response. `proxy` holds the call path.
+
+use std::collections::BTreeMap;
+
+use tinysearch_bus::{
+ BackendAuthMode, BackendConfig, PresentationConfig, PresentationMode, ProviderConfig,
+ ProviderRoute, SearchConfig as ModuleSearchConfig,
+};
+
+use crate::config::{Config, SearchPresentation, SearchRoute};
+use crate::search::providers::{self, ResolvedProvider, ROLES};
+
+mod proxy;
+
+pub use proxy::{execute_tool, list_tools, refresh_loaded};
+
+pub const MODULE_ID: &str = "tinysearch";
+
+/// Private direct-route settings for one provider: key, base URL, limits.
+fn direct_settings(config: &Config, provider: &str) -> ProviderConfig {
+ let search = &config.search;
+ let mut settings = ProviderConfig {
+ enabled: true,
+ route: ProviderRoute::Direct,
+ max_results: Some(search.max_results as u64),
+ timeout_secs: Some(search.timeout_secs),
+ ..Default::default()
+ };
+ match provider {
+ "seltz" => {
+ settings.credential = config.seltz.api_key.clone().filter(|k| !k.trim().is_empty());
+ settings.base_url = config.seltz.api_url.clone();
+ settings.max_results = Some(config.seltz.max_results as u64);
+ settings.timeout_secs = Some(config.seltz.timeout_secs);
+ }
+ "searxng" => {
+ settings.base_url = Some(config.searxng.base_url.clone());
+ settings.max_results = Some(config.searxng.max_results as u64);
+ settings.timeout_secs = Some(config.searxng.timeout_secs);
+ settings.default_language = Some(config.searxng.default_language.clone());
+ }
+ other => {
+ settings.credential = search
+ .credentials(other)
+ .and_then(|c| c.key())
+ .map(str::to_owned);
+ }
+ }
+ settings
+}
+
+fn provider_config(config: &Config, provider: &ResolvedProvider) -> ProviderConfig {
+ let mut settings = match provider.route {
+ SearchRoute::Managed => ProviderConfig {
+ enabled: true,
+ route: ProviderRoute::Backend,
+ max_results: Some(config.search.max_results as u64),
+ timeout_secs: Some(config.search.timeout_secs),
+ ..Default::default()
+ },
+ SearchRoute::Direct => direct_settings(config, provider.id),
+ };
+ settings.enabled = provider.usable;
+ settings
+}
+
+/// The complete private configuration for TinySearch.
+pub fn module_config(config: &Config) -> ModuleSearchConfig {
+ let credential =
+ crate::security::credentials::session_support::resolve_backend_credential(config).ok();
+ let resolved = providers::resolve_with(config, credential.is_some());
+ let backend = BackendConfig {
+ base_url: Some(crate::api::effective_backend_api_url(&config.api_url)),
+ auth_mode: if credential.as_ref().is_some_and(|c| c.is_api_key()) {
+ BackendAuthMode::ApiKey
+ } else {
+ BackendAuthMode::Session
+ },
+ credential: credential.map(|c| c.into_secret()),
+ sdk_name: Some(crate::api::product_identity().as_str().to_owned()),
+ };
+
+ let mut module_providers: BTreeMap<String, ProviderConfig> = resolved
+ .iter()
+ .filter(|provider| provider.enabled)
+ .map(|provider| (provider.id.to_string(), provider_config(config, provider)))
+ .collect();
+ // Deep research runs on the direct Gemini API and needs the user's key,
+ // even when grounded Gemini answers go through the managed route.
+ if module_providers.contains_key("gemini") && !module_providers.contains_key("gemini_deep_research") {
+ let mut deep = direct_settings(config, "gemini_deep_research");
+ deep.enabled = config.search.is_enabled() && deep.credential.is_some();
+ module_providers.insert("gemini_deep_research".into(), deep);
+ }
+
+ let roles = ROLES
+ .into_iter()
+ .map(|role| (role, providers::role_order(config, role)))
+ .collect();
+ let presentation = PresentationConfig {
+ mode: match config.search.presentation {
+ SearchPresentation::Roles => PresentationMode::Roles,
+ SearchPresentation::AllTools => PresentationMode::AllTools,
+ SearchPresentation::Router => PresentationMode::Router,
+ SearchPresentation::OneProvider => PresentationMode::OneProvider,
+ },
+ provider: config.search.presentation_provider.clone(),
+ roles,
+ };
+
+ tracing::debug!(
+ enabled = config.search.is_enabled(),
+ providers = ?module_providers
+ .iter()
+ .map(|(name, p)| format!("{name}:{:?}:{}", p.route, p.enabled))
+ .collect::<Vec<_>>(),
+ presentation = config.search.presentation.as_str(),
+ "[modules][search] built module configuration"
+ );
+
+ ModuleSearchConfig {
+ enabled: config.search.is_enabled(),
+ backend,
+ providers: module_providers,
+ presentation,
+ }
+}
+
+/// Deterministic declarations for synchronous tool registration, computed
+/// from the same configuration the module will receive.
+pub fn configured_tool_specs(config: &Config) -> Vec<tinysearch_bus::ToolSpec> {
+ let module = module_config(config);
+ if !module.enabled {
+ return Vec::new();
+ }
+ let available =
+ tinysearch_bus::configured_provider_tools(&module, &tinysearch_bus::provider_tool_specs());
+ tinysearch_bus::select_tools(&available, &module.presentation).tools
+}
+
+#[cfg(test)]
+#[path = "config_tests.rs"]
+mod config_tests;
diff --git a/crates/openhuman-core/src/modules/search/proxy.rs b/crates/openhuman-core/src/modules/search/proxy.rs
new file mode 100644
index 0000000000..f3794f1f8f
--- /dev/null
+++ b/crates/openhuman-core/src/modules/search/proxy.rs
@@ -0,0 +1,126 @@
+//! Call path to the loaded TinySearch module: lazy load, private
+//! reconfiguration when the resolved configuration changes, and serialized
+//! `ListTools` / `ExecuteTool` calls.
+
+use std::{
+ future::Future,
+ hash::{Hash, Hasher},
+ sync::OnceLock,
+};
+
+use tinysearch_bus::{names, ExecuteToolRequest, ExecuteToolResponse, ListToolsResponse};
+
+use super::{module_config, MODULE_ID};
+use crate::config::Config;
+
+fn last_config() -> &'static tokio::sync::Mutex<Option<u64>> {
+ static LAST: OnceLock<tokio::sync::Mutex<Option<u64>>> = OnceLock::new();
+ LAST.get_or_init(|| tokio::sync::Mutex::new(None))
+}
+
+fn fingerprint(value: &serde_json::Value) -> u64 {
+ let mut hasher = std::collections::hash_map::DefaultHasher::new();
+ value.to_string().hash(&mut hasher);
+ hasher.finish()
+}
+
+async fn proxy(config: &Config) -> Result<tinybus::Proxy, String> {
+ crate::modules::ops::ensure_loaded_within(
+ config,
+ MODULE_ID,
+ Some(std::time::Duration::from_secs(8)),
+ )
+ .await
+ .map_err(crate::modules::ops::LoadError::into_message)?;
+ let runtime = crate::modules::host::runtime()
+ .await
+ .map_err(|error| format!("search module bus unavailable: {error}"))?;
+ let configuration =
+ serde_json::to_value(module_config(config)).map_err(|error| error.to_string())?;
+ let current = fingerprint(&configuration);
+ // Caller holds the module call lock through the subsequent bus call.
+ let mut previous = last_config().lock().await;
+ if *previous != Some(current) {
+ tracing::debug!("[modules][search] configuration changed; reinitializing module");
+ runtime
+ .connection()
+ .reinitialize_module(MODULE_ID, configuration)
+ .await
+ .map_err(|error| format!("search module configuration refresh failed: {error}"))?;
+ *previous = Some(current);
+ }
+ runtime
+ .proxy(names::INTERFACE, names::OBJECT_PATH)
+ .map_err(|error| format!("search module proxy unavailable: {error}"))
+}
+
+pub(super) async fn with_module_lock<T, F, Fut>(operation: F) -> Result<T, String>
+where
+ F: FnOnce() -> Fut,
+ Fut: Future<Output = Result<T, String>>,
+{
+ static CALL_LOCK: OnceLock<tokio::sync::Mutex<()>> = OnceLock::new();
+ let guard = CALL_LOCK
+ .get_or_init(|| tokio::sync::Mutex::new(()))
+ .lock()
+ .await;
+ let result = operation().await;
+ drop(guard);
+ result
+}
+
+async fn current_config(config: &Config) -> Result<Config, String> {
+ crate::config::ops::reload_config_from_paths(&config.config_path, &config.workspace_dir).await
+}
+
+/// Refresh a loaded module after a settings or credential change. An unloaded
+/// module gets the current configuration during its first initialization.
+pub async fn refresh_loaded(config: &Config) -> Result<(), String> {
+ if matches!(
+ crate::modules::ops::state_of(MODULE_ID),
+ crate::modules::types::ModuleState::Ready
+ ) {
+ let current = current_config(config).await?;
+ with_module_lock(|| async {
+ let _ = proxy(&current).await?;
+ Ok(())
+ })
+ .await?;
+ }
+ Ok(())
+}
+
+pub async fn list_tools(config: &Config) -> Result<ListToolsResponse, String> {
+ let current = current_config(config).await?;
+ with_module_lock(|| async {
+ proxy(&current)
+ .await?
+ .call(names::methods::LIST_TOOLS, ())
+ .await
+ .map_err(|error| format!("search ListTools failed: {error}"))
+ })
+ .await
+}
+
+pub async fn execute_tool(
+ config: &Config,
+ request: ExecuteToolRequest,
+) -> Result<ExecuteToolResponse, String> {
+ let current = current_config(config).await?;
+ let tool = request.name.clone();
+ with_module_lock(|| async {
+ proxy(&current)
+ .await?
+ .call_confidential(names::methods::EXECUTE_TOOL, (request,))
+ .await
+ .map_err(|error| {
+ tracing::debug!(tool = %tool, "[modules][search] ExecuteTool failed");
+ format!("search ExecuteTool failed: {error}")
+ })
+ })
+ .await
+}
+
+#[cfg(test)]
+#[path = "proxy_tests.rs"]
+mod proxy_tests;
diff --git a/vendor/tinysearch b/vendor/tinysearch
index 922734b49f..2789d39e9b 160000
--- a/vendor/tinysearch
+++ b/vendor/tinysearch
@@ -1 +1 @@
-Subproject commit 922734b49f8769ca65cb9a8ea82650d04a83a3ef
+Subproject commit 2789d39e9bd9360fdedfb838b0dd17d288eed75a