Skip to content

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

Merge upstream/main into multi-search

Steven Enamakelad93fa89327f
diff --cc app/src/lib/i18n/en.ts
index 38de99cc91,df81ddcc48..06d04534ef
--- a/app/src/lib/i18n/en.ts
+++ b/app/src/lib/i18n/en.ts
@@@ -1689,8 -1701,40 +1701,12 @@@ const en: TranslationMap =
'settings.search.title': 'Search engine',
'settings.search.menuDesc':
'Default to OpenHuman-managed search or wire up your own provider with an API key.',
- 'settings.search.description':
- "Pick the search engine the agent uses, or disable search tools entirely. Managed uses OpenHuman's backend (no setup). Parallel, Brave, Querit, Exa, and Tavily run direct from your machine using your API key.",
- 'settings.search.engineAria': 'Search engine',
- 'settings.search.engineDisabledLabel': 'Disabled',
- 'settings.search.engineDisabledDesc':
- 'Remove search tools from the agent context and available tool list.',
- 'settings.search.engineManagedLabel': 'OpenHuman Managed',
- 'settings.search.engineManagedDesc':
- 'Default. Routed through the OpenHuman backend, currently powered by Exa: no API key required.',
- 'settings.search.localManagedUnavailable':
- 'OpenHuman Managed search is not available for local users. Add your own Parallel, Brave, Querit, Exa, or Tavily API key to enable web search.',
- 'settings.search.engineParallelLabel': 'Parallel',
- 'settings.search.engineParallelDesc':
- 'Direct Parallel API: search, extract, chat, research, enrich, dataset tools.',
- 'settings.search.engineBraveLabel': 'Brave Search',
- 'settings.search.engineBraveDesc': 'Direct Brave Search API: web, news, image, and video tools.',
- 'settings.search.engineQueritLabel': 'Querit',
- 'settings.search.engineQueritDesc':
- 'Direct Querit API: web search with site, time range, country, and language filters.',
- 'settings.search.engineExaLabel': 'Exa',
- 'settings.search.engineExaDesc':
- 'Neural search powered by Exa. Requires your own Exa API key. Adds search, find similar, and page contents tools.',
- 'settings.search.engineTavilyLabel': 'Tavily',
- 'settings.search.engineTavilyDesc':
- 'Web, news, and finance search powered by Tavily. Requires your own Tavily API key. Adds search and page extract tools.',
- 'settings.search.statusConfigured': 'Configured',
'settings.search.statusNeedsKey': 'Needs API key',
- 'settings.search.fallbackToManaged':
- 'No key configured: search will fall back to Managed until a key is saved.',
'settings.search.getApiKey': 'Get API key',
+ 'settings.search.keyStored': 'Stored',
+ 'settings.search.apiKeysHeading': 'API keys',
+ 'settings.search.apiKeysDesc':
+ 'Keys for the direct providers. They stay on this device and are used only when that engine is selected.',
'settings.search.save': 'Save',
'settings.search.clear': 'Clear',
'settings.search.show': 'Show',
diff --cc crates/openhuman-core/src/mcp/server/README.md
index a3ac30efd1,b213a68e9d..8f745749a6
--- a/crates/openhuman-core/src/mcp/server/README.md
+++ b/crates/openhuman-core/src/mcp/server/README.md
@@@ -1,6 -1,6 +1,6 @@@
# mcp/server
- Opt-in **Model Context Protocol (MCP) server** that exposes a curated, security-gated slice of OpenHuman's tool surface (memory-tree reads/writes, core/agent introspection, subagent execution, web search) and bundled prompt assets to external MCP clients (Claude Desktop, Cursor, Windsurf, …). Started via `openhuman-core mcp` — stdio transport by default, or `--transport http` for Streamable HTTP + SSE on a local bind address. It is a JSON-RPC dispatcher, not a registered RPC domain: it has no `schemas.rs`/controllers and is wired only through `crates/openhuman-core/src/core/cli.rs`, translating each MCP `tools/call` into an existing registered core RPC method.
-Opt-in **Model Context Protocol (MCP) server** that exposes a curated, security-gated slice of OpenHuman's tool surface (memory-tree reads/writes, core/agent introspection, subagent execution, SearXNG search) and bundled prompt assets to external MCP clients (Claude Desktop, Cursor, Windsurf, …). Started via `openhuman-core mcp`: stdio transport by default, or `--transport http` for Streamable HTTP + SSE on a local bind address. It is a JSON-RPC dispatcher, not a registered RPC domain: it has no `schemas.rs`/controllers and is wired only through `crates/openhuman-core/src/core/cli.rs`, translating each MCP `tools/call` into an existing registered core RPC method.
++Opt-in **Model Context Protocol (MCP) server** that exposes a curated, security-gated slice of OpenHuman's tool surface (memory-tree reads/writes, core/agent introspection, subagent execution, web search) and bundled prompt assets to external MCP clients (Claude Desktop, Cursor, Windsurf, …). Started via `openhuman-core mcp`: stdio transport by default, or `--transport http` for Streamable HTTP + SSE on a local bind address. It is a JSON-RPC dispatcher, not a registered RPC domain: it has no `schemas.rs`/controllers and is wired only through `crates/openhuman-core/src/core/cli.rs`, translating each MCP `tools/call` into an existing registered core RPC method.
## Responsibilities
@@@ -53,10 -53,8 +53,10 @@@ This module exposes **no** registered c
| `tree.top_entities` | `openhuman.memory_tree_top_entities` |
| `tree.list_sources` | `openhuman.memory_tree_list_sources` |
| `memory.store` / `memory.note` / `tree.tag` | `openhuman.memory_doc_put` |
+| `web_search` | `openhuman.tools_web_search` |
+| `web_answer` | `openhuman.tools_web_answer` |
| `searxng_search` | `openhuman.tools_searxng_search` |
- | `core.list_tools` / `core.tool_instructions` / `agent.list_subagents` / `agent.run_subagent` | (no RPC mapping — handled in-process via `Agent` / `AgentDefinitionRegistry`) |
+ | `core.list_tools` / `core.tool_instructions` / `agent.list_subagents` / `agent.run_subagent` | (no RPC mapping, handled in-process via `Agent` / `AgentDefinitionRegistry`) |
## Agent tools
@@@ -77,16 -75,16 +77,16 @@@ No `store.rs`. The only durable side ef
## Dependencies
- - `crate::core::all` — `try_invoke_registered_rpc`, `schema_for_rpc_method`, `validate_params`: dispatch MCP tool calls into the registered core RPC layer and validate params against controller schemas.
- - `crate::core::logging` (`CliLogDefault`, `init_for_cli_run`) — install the stderr tracing subscriber for the MCP subprocess.
- - `crate::config` (`Config`, `rpc::load_config_with_timeout`, `McpAuthConfig`/`McpClientIdentityConfig` in tests) — load config for policy/searxng gating and per-call config.
- - `crate::security` (`SecurityPolicy`, `ToolOperation`) — enforce read/act autonomy policy per tool call.
- - `crate::agent` (`Agent`, `registry::agents::BUILTINS`, `harness::AgentDefinitionRegistry`) — build the orchestrator agent for `core.list_tools`/`core.tool_instructions`, list/run subagents, and cross-check the resource catalog.
- - `tinyinference_llm::tool::ToolSchema` — directly materialize model-visible tool declarations for `core.tool_instructions`.
- - `tinyagents_harness::tool::prompt_tool_instructions` — render the markdown tool-use instructions block for `core.tool_instructions`.
- - `crate::search::providers` — which search tools the config can serve (`tool_specs_for_config`).
- - `crate::mcp::audit` (`record_write`, `NewMcpWriteRecord`, list/query helpers in tests) — durable write-audit log.
- - `crate::mcp::http_client::McpHttpClient` — round-trip test harness for the HTTP transport (test-only).
+ - `crate::core::all`: `try_invoke_registered_rpc`, `schema_for_rpc_method`, `validate_params`: dispatch MCP tool calls into the registered core RPC layer and validate params against controller schemas.
+ - `crate::core::logging` (`CliLogDefault`, `init_for_cli_run`): installs the stderr tracing subscriber for the MCP subprocess.
+ - `crate::config` (`Config`, `rpc::load_config_with_timeout`, `McpAuthConfig`/`McpClientIdentityConfig` in tests): loads config for policy/searxng gating and per-call config.
+ - `crate::security` (`SecurityPolicy`, `ToolOperation`): enforces read/act autonomy policy per tool call.
+ - `crate::agent` (`Agent`, `registry::agents::BUILTINS`, `harness::AgentDefinitionRegistry`): builds the orchestrator agent for `core.list_tools`/`core.tool_instructions`, lists/runs subagents, and cross-checks the resource catalog.
+ - `tinyinference_llm::tool::ToolSchema`: directly materialize model-visible tool declarations for `core.tool_instructions`.
+ - `tinyagents_harness::tool::prompt_tool_instructions`: render the markdown tool-use instructions block for `core.tool_instructions`.
-- `crate::tools` (`SEARXNG_MAX_RESULTS`, `normalize_categories`): SearXNG bounds and category normalization for `searxng_search`.
++- `crate::search::providers`: which search tools the config can serve (`tool_specs_for_config`).
+ - `crate::mcp::audit` (`record_write`, `NewMcpWriteRecord`, list/query helpers in tests): durable write-audit log.
+ - `crate::mcp::http_client::McpHttpClient`: round-trip test harness for the HTTP transport (test-only).
- External crates: `axum`/`tokio`/`tokio-stream` (HTTP+SSE), `serde_json`, `uuid`, `sha2`/`hex` (session-id redaction, slug fallback hash), `chrono` (audit timestamps).
## Used by
diff --cc crates/openhuman-core/src/modules/README.md
index 0ff31359d4,3f43ff1212..526c490e46
--- a/crates/openhuman-core/src/modules/README.md
+++ b/crates/openhuman-core/src/modules/README.md
@@@ -86,35 -86,25 +86,35 @@@ artifacts directly through the host, th
`LoadPolicy::Eager` record (currently only `tinymemory`, and only when
`memory::binding::admit` selects the module-backed driver; its host callbacks
are installed first). It never fails the boot. Everything else is
- `LoadPolicy::Lazy` and resolves on first `ensure_loaded` call — deliberately
+ `LoadPolicy::Lazy` and resolves on first `ensure_loaded` call: deliberately
not eager, so a user who never touches a feature never pays its download.
-## TinySearch development pin
+## TinySearch
-The `tinysearch` registry record has no platform assets until a published
-release provides verified checksums. Use `[[modules.overrides]]` with
-`id = "tinysearch"` and an absolute local library `path` during development.
-The host sends provider keys and the typed backend credential only in private
-module initialization and reinitialization payloads. Settings changes refresh
-a loaded module; `search::list_tools` and `search::execute_tool` reload current
-settings before each call so a captured config cannot keep old credentials.
-`search::configured_tool_specs` uses the bus contract to declare tools
-synchronously during registration.
+`search/` is the host adapter for the TinySearch module (`vendor/tinysearch`),
+which owns every web-search provider, its tool schemas, and role dispatch.
-TinySearch has one route per provider. Managed search maps to backend Parallel;
-when direct Parallel is explicitly selected, it takes precedence. Gemini
-Deep Research remains direct with a Gemini key even when grounded Gemini search
-uses the backend route.
+- `search/mod.rs` — `module_config` builds the private module configuration
+ from `crate::search::providers` (the host's resolved policy): per-provider
+ route (`managed` → `ProviderRoute::Backend`), direct keys and limits, the
+ backend credential (`resolve_backend_credential`: API key as `x-api-key`,
+ else the session JWT as a bearer), `x-sdk-name`, and the per-role provider
+ order. `configured_tool_specs` computes the tool declarations synchronously
+ from that same configuration.
+- `search/proxy.rs` — lazy load (`ensure_loaded_within`), private
+ reinitialization when the configuration fingerprint changes (the first call
+ after a load keeps the load-time configuration; a reinitialize that lands
+ while the module is still initializing waits and retries), and serialized
+ `ListTools` / `ExecuteTool` calls. `ExecuteTool` is an ordinary call: keys
+ travel only in the configuration, never in a call.
+- Credentials: `refresh_loaded` runs after a search settings save and on
+ `DomainEvent::CredentialChanged` (`search::credential_refresh`), so managed
+ providers follow login and logout without waiting for the next call.
+- Tests and local development load a local build through
+ `TINYSEARCH_TEST_MODULE` or `[[modules.overrides]]` (`id = "tinysearch"`);
+ `scripts/test-rust-with-mock.sh` and CI build the pinned submodule. Release
+ checksums are pinned in `registry/records_search.rs` from the published
+ `checksum.toml`, never from a local build.
## Contract crates
diff --cc crates/openhuman-core/src/modules/search/mod.rs
index aa855263a2,0000000000..ddc90b995d
mode 100644,000000..100644
--- a/crates/openhuman-core/src/modules/search/mod.rs
+++ b/crates/openhuman-core/src/modules/search/mod.rs
@@@ -1,155 -1,0 +1,155 @@@
+//! 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)),
++ base_url: crate::backend::base_url(&config.api_url).ok(),
+ 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()),
++ sdk_name: crate::backend::product_identity(),
+ };
+
+ 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 --cc crates/openhuman-core/src/tools/README.md
index 9907942d8b,36f6ce874b..2983d081b4
--- a/crates/openhuman-core/src/tools/README.md
+++ b/crates/openhuman-core/src/tools/README.md
@@@ -5,8 -5,8 +5,8 @@@ The agent tool layer. Defines the core
## Responsibilities
- Use the [`tinytools::Tool`] async trait and its supporting value types (`ToolResult`, `ToolSpec`, `PermissionLevel`, `ToolScope`, `ToolCategory`, `ToolCallOptions`, `ToolExposure`) directly from `tinytools`.
- - Assemble the registry the agent loop runs against — `default_tools[_with_runtime]` (minimal: shell + file read/write) and `all_tools[_with_runtime]` (full, config-gated set).
+ - Assemble the registry the agent loop runs against: `default_tools[_with_runtime]` (minimal: shell + file read/write) and `all_tools[_with_runtime]` (full, config-gated set).
-- Gate registration on config flags / env (`browser.enabled`, `node.enabled`, `runtime_python.enabled`, `learning.*`, `integrations.*`, `search.engine`, `gitbooks.enabled`, MCP registry presence, `OPENHUMAN_LSP_ENABLED`).
+- Gate registration on config flags / env (`browser.enabled`, `node.enabled`, `runtime_python.enabled`, `learning.*`, `integrations.*`, `[search]` providers, `gitbooks.enabled`, MCP registry presence, `OPENHUMAN_LSP_ENABLED`).
- Own the cross-cutting built-in tool impls under `impl/` (filesystem, browser, generic system, generic network, meta, and the `documents`-gated document/presentation tools).
- Provide the pre-execution [`ToolPolicy`] middleware (allow/deny gate) and the default allow-all policy.
- Normalize tool JSON schemas for provider compatibility (`SchemaCleanr`).
@@@ -42,9 -42,9 +42,9 @@@
| `crates/openhuman-core/src/tools/impl/system/` | Tools `shell`, `node_exec`, `npm_exec`, `python_exec`, `install_tool`, `detect_tools`, `current_time`, `resolve_time`, `schedule`, `proxy_config`, `pushover`, `lsp`, `tool_stats`, `update_check`, `update_apply`, `insert_sql_record`, `read_workspace_state`, `retrieve_tool_output`. Helper module (not a tool): `command_output`, the shared exit-code/stdout/stderr formatter for the shell family. |
| `crates/openhuman-core/src/tools/impl/network/` | Tools `http_request`, `web_fetch`, `curl`, `gitbooks_search`/`gitbooks_get_page`, `mcp_list_servers`/`mcp_list_tools`/`mcp_call_tool` (`mcp`-feature gated), `gmail_unsubscribe`. Helper module: `url_guard` (host allowlist matching, private-address rejection, `validate_url`). |
| `crates/openhuman-core/src/tools/impl/meta/` | Tools *about* the tool surface itself: `deferred` (the host's half of `ToolExposure::Deferred`; the harness's intrinsic `tool_search` bridge is the lookup half) and `collapse` (multi-action schema/permission merging helpers). |
- | `crates/openhuman-core/src/tools/impl/document/` (`documents` feature) | `DocumentTool` (`generate_document`) — structured document generation/editing engine. |
- | `crates/openhuman-core/src/tools/impl/presentation/` (`documents` feature) | `PresentationTool` (`generate_presentation`) — structured slide-deck generation engine. |
+ | `crates/openhuman-core/src/tools/impl/document/` (`documents` feature) | `DocumentTool` (`generate_document`): structured document generation/editing engine. |
+ | `crates/openhuman-core/src/tools/impl/presentation/` (`documents` feature) | `PresentationTool` (`generate_presentation`): structured slide-deck generation engine. |
-| `crates/openhuman-core/src/search/` | Search engine registry and search-owned agent tools such as `web_search`. |
+| `crates/openhuman-core/src/search/` | Search policy over the TinySearch module: provider resolution, the `TinySearchTool` bridge (`web_search_tool`, `web_answer_tool`, `web_contents_tool`), result rendering. |
| `*_tests.rs` / `#[cfg(test)] mod tests` | Co-located/sibling unit tests across the module. |
## Public surface