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
chore(deps): update tinysearch vendor dependency
Steven Enamakel10aba59ff24d
diff --git a/crates/openhuman-core/src/config/schema/tools/search.rs b/crates/openhuman-core/src/config/schema/tools/search.rsindex cf866aa74c..be1fd12527 100644--- a/crates/openhuman-core/src/config/schema/tools/search.rs+++ b/crates/openhuman-core/src/config/schema/tools/search.rs@@ -2,7 +2,7 @@use schemars::JsonSchema;use serde::{Deserialize, Serialize};-use std::collections::BTreeSet;+use std::collections::{BTreeMap, BTreeSet};#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]#[serde(default)]@@ -119,29 +119,52 @@ impl Default for WebSearchConfig {}}-// ── Search engines ──────────────────────────────────────────────────+// ── Search providers ────────────────────────────────────────────────//-// Unified search-engine selector. Only one engine is active at a time-// (mirrors the LLM-provider API-key flow). The active engine governs-// which tools are registered: `disabled` → no search tools; `managed` →-// backend-proxied `web_search`; `parallel` → direct Parallel API tools-// (search/extract/chat/research/enrich/dataset); `brave` → direct Brave Search-// tools (web/news/images/videos); `querit` → direct Querit web search;-// `exa` → direct Exa neural search (search / find similar / contents);-// `tavily` → direct Tavily Search + Extract (web / news / finance).+// Several providers can be active at once. Each provider has a route —+// `managed` (TinyHumans backend, billed to the signed-in session or API key)+// or `direct` (the user's own key). The agent does not see providers; it sees+// one tool per capability role (`search`, `answer`, `contents`), and each role+// is served by the first usable provider in its ordered list. Provider+// execution lives in the TinySearch module; this file only owns the settings+// and the one-time migration from the single-engine format.++/// Settings format written by this build. Files without the field (or with a+/// lower value) carry the legacy single-engine fields and are migrated on load.+pub const SEARCH_SCHEMA_VERSION: u32 = 2;++pub const SEARCH_ROLE_SEARCH: &str = "search";+pub const SEARCH_ROLE_ANSWER: &str = "answer";+pub const SEARCH_ROLE_CONTENTS: &str = "contents";+/// Capability roles, in display order.+pub const SEARCH_ROLES: &[&str] = &[SEARCH_ROLE_SEARCH, SEARCH_ROLE_ANSWER, SEARCH_ROLE_CONTENTS];++/// Providers the host knows how to configure. Mirrors the TinySearch catalog;+/// `modules::search` tests assert the two stay in sync.+pub const SEARCH_PROVIDERS: &[&str] = &[+ "exa",+ "gemini",+ "gemini_deep_research",+ "tinyfish",+ "brave",+ "querit",+ "tavily",+ "seltz",+ "searxng",+];+/// Providers that can be reached through the managed TinyHumans backend.+pub const MANAGED_SEARCH_PROVIDERS: &[&str] = &["exa", "gemini", "tinyfish"];++// Legacy single-engine ids, still accepted by `config.update_search_settings`+// for older clients and by the `SEARCH_ENGINE` env var.pub const SEARCH_ENGINE_DISABLED: &str = "disabled";pub const SEARCH_ENGINE_MANAGED: &str = "managed";-pub const SEARCH_ENGINE_PARALLEL: &str = "parallel";pub const SEARCH_ENGINE_BRAVE: &str = "brave";pub const SEARCH_ENGINE_QUERIT: &str = "querit";pub const SEARCH_ENGINE_EXA: &str = "exa";pub const SEARCH_ENGINE_TAVILY: &str = "tavily";-fn default_search_engine() -> String {- SEARCH_ENGINE_MANAGED.into()-}-fn default_search_max_results() -> usize {5}@@ -150,9 +173,8 @@ fn default_search_timeout_secs() -> u64 {15}-/// Credentials for a BYO search engine. Mirrors the LLM provider API--/// key shape — a simple `Option<String>` that is considered configured-/// iff the trimmed value is non-empty.+/// Credentials for a BYO search provider. Considered configured iff the+/// trimmed value is non-empty.#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonSchema)]#[serde(default)]pub struct SearchEngineCredentials {@@ -162,10 +184,7 @@ pub struct SearchEngineCredentials {impl SearchEngineCredentials {pub fn has_key(&self) -> bool {- self.api_key- .as_deref()- .map(|s| !s.trim().is_empty())- .unwrap_or(false)+ self.key().is_some()}pub fn key(&self) -> Option<&str> {@@ -180,43 +199,133 @@ impl SearchEngineCredentials {}}-/// Search configuration. New settings select a provider set; an omitted set-/// derives available providers from saved keys, the backend credential, and-/// the separate TinyFish toggle. The legacy engine remains for migration.+/// How calls to a provider are routed.+#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]+#[serde(rename_all = "snake_case")]+pub enum SearchRoute {+ /// Through the TinyHumans backend with the session credential.+ Managed,+ /// Straight to the provider with the user's own key.+ #[default]+ Direct,+}++impl SearchRoute {+ pub fn as_str(self) -> &'static str {+ match self {+ Self::Managed => "managed",+ Self::Direct => "direct",+ }+ }++ pub fn parse(value: &str) -> Option<Self> {+ match value.trim().to_ascii_lowercase().as_str() {+ "managed" | "backend" => Some(Self::Managed),+ "direct" => Some(Self::Direct),+ _ => None,+ }+ }+}++/// How search tools are presented to the agent.+#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]+#[serde(rename_all = "snake_case")]+pub enum SearchPresentation {+ /// One tool per capability role (the default).+ #[default]+ Roles,+ /// Every usable provider's own tools.+ AllTools,+ /// One `search` router tool with a provider argument.+ Router,+ /// Only the tools of `presentation_provider`.+ OneProvider,+}++impl SearchPresentation {+ pub fn as_str(self) -> &'static str {+ match self {+ Self::Roles => "roles",+ Self::AllTools => "all_tools",+ Self::Router => "router",+ Self::OneProvider => "one_provider",+ }+ }++ pub fn parse(value: &str) -> Option<Self> {+ match value.trim().to_ascii_lowercase().as_str() {+ "roles" => Some(Self::Roles),+ "all_tools" => Some(Self::AllTools),+ "router" => Some(Self::Router),+ "one_provider" => Some(Self::OneProvider),+ _ => None,+ }+ }+}++/// Per-provider selection.+#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]+#[serde(default)]+pub struct SearchProviderSettings {+ /// Whether the user turned this provider on.+ pub enabled: bool,+ /// Managed or direct.+ pub route: SearchRoute,+}++impl Default for SearchProviderSettings {+ fn default() -> Self {+ Self {+ enabled: true,+ route: SearchRoute::Direct,+ }+ }+}++impl SearchProviderSettings {+ pub fn managed() -> Self {+ Self {+ enabled: true,+ route: SearchRoute::Managed,+ }+ }++ pub fn direct() -> Self {+ Self {+ enabled: true,+ route: SearchRoute::Direct,+ }+ }+}++/// Search configuration.#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]#[serde(default)]pub struct SearchConfig {- /// Active search engine. One of [`SEARCH_ENGINE_DISABLED`],- /// [`SEARCH_ENGINE_MANAGED`], [`SEARCH_ENGINE_PARALLEL`],- /// [`SEARCH_ENGINE_BRAVE`], [`SEARCH_ENGINE_QUERIT`],- /// [`SEARCH_ENGINE_EXA`], or [`SEARCH_ENGINE_TAVILY`]. Unknown values fall- /// back to managed at registration time.- #[serde(default = "default_search_engine")]- pub engine: String,-- /// Explicit global switch. Missing in older config files, where `engine`- /// still decides whether search was disabled.+ /// Settings format; see [`SEARCH_SCHEMA_VERSION`]. Absent in legacy files.+ #[serde(default)]+ pub schema_version: u32,++ /// Global switch. `None` only in legacy files before migration.#[serde(default)]pub enabled: Option<bool>,- /// Explicit provider selection. Missing migrates from saved credentials- /// and the legacy TinyFish integration toggle. When present, this set is- /// authoritative, including for TinyFish.- /// Managed and direct Parallel share one module route; explicit Parallel- /// selection takes precedence when both are selected.++ /// Provider selection and routes, keyed by [`SEARCH_PROVIDERS`] name.#[serde(default)]- pub enabled_providers: Option<BTreeSet<String>>,- /// `all_tools`, `router`, or `one_provider`.- #[serde(default = "default_search_presentation")]- pub presentation: String,- /// Provider used by `one_provider`, or router default.+ pub providers: BTreeMap<String, SearchProviderSettings>,++ /// Ordered provider list per role (keys from [`SEARCH_ROLES`]). A missing+ /// or empty role uses TinySearch's default order.+ #[serde(default)]+ pub roles: BTreeMap<String, Vec<String>>,++ /// Tool presentation.+ #[serde(default)]+ pub presentation: SearchPresentation,++ /// Provider for `one_provider`, or the router default.#[serde(default)]pub presentation_provider: Option<String>,- /// `direct` or `backend` for Parallel.- #[serde(default = "default_direct_route")]- pub parallel_route: String,- /// `direct` or `backend` for Gemini.- #[serde(default = "default_direct_route")]- pub gemini_route: String,/// Max results per query (1–20, default 5).#[serde(default = "default_search_max_results")]@@ -226,153 +335,285 @@ pub struct SearchConfig {#[serde(default = "default_search_timeout_secs")]pub timeout_secs: u64,- /// Parallel API credentials (used when `engine = "parallel"`).- #[serde(default)]- pub parallel: SearchEngineCredentials,-- /// Brave Search credentials (used when `engine = "brave"`).+ /// Brave Search key (direct route).#[serde(default)]pub brave: SearchEngineCredentials,-- /// Querit credentials (used when `engine = "querit"`).+ /// Querit key (direct route).#[serde(default)]pub querit: SearchEngineCredentials,-- /// Exa credentials (used when `engine = "exa"`). BYOK: search calls go- /// straight to `https://api.exa.ai`, never through the managed backend.+ /// Exa key (direct route). Managed Exa needs no key.#[serde(default)]pub exa: SearchEngineCredentials,-- /// Tavily credentials (used when `engine = "tavily"`). BYOK: search and- /// extract calls go straight to `https://api.tavily.com`, never through- /// the managed backend.+ /// Tavily key (direct route).#[serde(default)]pub tavily: SearchEngineCredentials,-- /// Gemini direct API credential.+ /// Gemini API key (direct route, and required for deep research).+ /// Managed Gemini needs no key.#[serde(default)]pub gemini: SearchEngineCredentials,-}-fn default_search_presentation() -> String {- "all_tools".into()-}-fn default_direct_route() -> String {- "direct".into()+ // ── Legacy single-engine fields: read for migration, never written ──+ #[serde(default, skip_serializing)]+ #[schemars(skip)]+ pub engine: Option<String>,+ #[serde(default, skip_serializing)]+ #[schemars(skip)]+ pub enabled_providers: Option<BTreeSet<String>>,+ #[serde(default, skip_serializing)]+ #[schemars(skip)]+ pub parallel_route: Option<String>,+ #[serde(default, skip_serializing)]+ #[schemars(skip)]+ pub gemini_route: Option<String>,+ #[serde(default, skip_serializing)]+ #[schemars(skip)]+ pub parallel: SearchEngineCredentials,}-pub const SEARCH_PROVIDERS: &[&str] = &[- "managed", "parallel", "brave", "querit", "exa", "tavily", "gemini", "tinyfish", "seltz",- "searxng",-];-impl Default for SearchConfig {fn default() -> Self {Self {- engine: default_search_engine(),- enabled: None,- enabled_providers: None,- presentation: default_search_presentation(),+ schema_version: SEARCH_SCHEMA_VERSION,+ enabled: Some(true),+ providers: default_providers(),+ roles: BTreeMap::new(),+ presentation: SearchPresentation::Roles,presentation_provider: None,- parallel_route: default_direct_route(),- gemini_route: default_direct_route(),max_results: default_search_max_results(),timeout_secs: default_search_timeout_secs(),- parallel: SearchEngineCredentials::default(),brave: SearchEngineCredentials::default(),querit: SearchEngineCredentials::default(),exa: SearchEngineCredentials::default(),tavily: SearchEngineCredentials::default(),gemini: SearchEngineCredentials::default(),+ engine: None,+ enabled_providers: None,+ parallel_route: None,+ gemini_route: None,+ parallel: SearchEngineCredentials::default(),}}}-/// Normalized search-engine enum used at tool-registration time. Falls-/// back to [`SearchEngine::Managed`] for unknown strings and for BYO-/// engines that have no API key configured.-#[derive(Debug, Clone, Copy, PartialEq, Eq)]-pub enum SearchEngine {- Disabled,- Managed,- Parallel,- Brave,- Querit,- Exa,- Tavily,+/// Fresh installs: managed Exa for ranked search and contents, managed Gemini+/// for grounded answers. Both need a signed-in session to become usable.+fn default_providers() -> BTreeMap<String, SearchProviderSettings> {+ BTreeMap::from([+ ("exa".to_string(), SearchProviderSettings::managed()),+ ("gemini".to_string(), SearchProviderSettings::managed()),+ ])+}++/// Legacy inputs that lived outside `[search]`.+#[derive(Debug, Clone, Copy, Default)]+pub struct LegacySearchInputs {+ /// `integrations.tinyfish.is_active()`.+ pub tinyfish_active: bool,+ /// `seltz.enabled` with a key.+ pub seltz_active: bool,+ /// `searxng.enabled`.+ pub searxng_active: bool,}impl SearchConfig {pub fn is_enabled(&self) -> bool {- self.enabled- .unwrap_or(self.engine.trim() != SEARCH_ENGINE_DISABLED)+ self.enabled.unwrap_or(true)}- /// Resolve provider selections. `None` is the old single-engine format.- pub fn providers(- &self,- managed_available: bool,- tinyfish_enabled: bool,- seltz_enabled: bool,- searxng_enabled: bool,- ) -> BTreeSet<String> {- if !self.is_enabled() {- return BTreeSet::new();- }- if let Some(selected) = &self.enabled_providers {- return selected.clone();- }- let mut providers = BTreeSet::new();- if managed_available {- providers.insert("managed".into());+ /// Stored key for a direct-route provider, if any. Seltz and SearXNG keep+ /// their options in their own sections and are resolved by the caller.+ pub fn credentials(&self, provider: &str) -> Option<&SearchEngineCredentials> {+ match provider {+ "brave" => Some(&self.brave),+ "querit" => Some(&self.querit),+ "exa" => Some(&self.exa),+ "tavily" => Some(&self.tavily),+ "gemini" | "gemini_deep_research" => Some(&self.gemini),+ _ => None,}- for (name, credentials) in [- ("parallel", &self.parallel),- ("brave", &self.brave),- ("querit", &self.querit),- ("exa", &self.exa),- ("tavily", &self.tavily),- ("gemini", &self.gemini),- ] {- if credentials.has_key() {- providers.insert(name.into());- }+ }++ pub fn credentials_mut(&mut self, provider: &str) -> Option<&mut SearchEngineCredentials> {+ match provider {+ "brave" => Some(&mut self.brave),+ "querit" => Some(&mut self.querit),+ "exa" => Some(&mut self.exa),+ "tavily" => Some(&mut self.tavily),+ "gemini" | "gemini_deep_research" => Some(&mut self.gemini),+ _ => None,}- if tinyfish_enabled {- providers.insert("tinyfish".into());+ }++ /// Enabled providers (ignores the global switch and usability).+ pub fn enabled_provider_names(&self) -> BTreeSet<String> {+ self.providers+ .iter()+ .filter(|(_, settings)| settings.enabled)+ .map(|(name, _)| name.clone())+ .collect()+ }++ /// Route for `provider`; providers that cannot be managed are always direct.+ pub fn route(&self, provider: &str) -> SearchRoute {+ if !MANAGED_SEARCH_PROVIDERS.contains(&provider) {+ return SearchRoute::Direct;}- if seltz_enabled {- providers.insert("seltz".into());+ self.providers+ .get(provider)+ .map(|settings| settings.route)+ .unwrap_or(SearchRoute::Direct)+ }++ /// Whether this file still carries the single-engine format.+ pub fn needs_migration(&self) -> bool {+ self.schema_version < SEARCH_SCHEMA_VERSION+ }++ /// Convert the single-engine format into providers, routes and roles.+ /// Idempotent: returns `false` and changes nothing on a current file.+ ///+ /// Managed selections map to managed Exa (search, contents) plus managed+ /// Gemini (answer) regardless of whether a session exists right now; the+ /// settings RPC reports them as "sign in required" until one does.+ /// Parallel is no longer offered: its selection and key are dropped.+ pub fn migrate_legacy(&mut self, legacy: LegacySearchInputs) -> bool {+ if !self.needs_migration() {+ return false;}- if searxng_enabled {- providers.insert("searxng".into());+ let engine = self+ .engine+ .as_deref()+ .map(|e| e.trim().to_ascii_lowercase())+ .unwrap_or_else(|| SEARCH_ENGINE_MANAGED.to_string());+ let enabled = self.enabled.unwrap_or(engine != SEARCH_ENGINE_DISABLED);+ let gemini_route = self+ .gemini_route+ .as_deref()+ .and_then(SearchRoute::parse)+ .unwrap_or(SearchRoute::Managed);+ let mut providers = BTreeMap::new();+ let mut dropped_parallel = self.parallel.has_key() || engine == "parallel";++ match self.enabled_providers.take() {+ Some(selected) => {+ for name in selected {+ match name.as_str() {+ "managed" => {+ providers.insert("exa".into(), SearchProviderSettings::managed());+ providers+ .entry("gemini".into())+ .or_insert_with(SearchProviderSettings::managed);+ }+ "parallel" => dropped_parallel = true,+ "gemini" => {+ providers.insert(+ "gemini".into(),+ SearchProviderSettings {+ enabled: true,+ route: gemini_route,+ },+ );+ }+ "tinyfish" => {+ providers.insert("tinyfish".into(), SearchProviderSettings::managed());+ }+ other if SEARCH_PROVIDERS.contains(&other) => {+ providers+ .entry(other.to_string())+ .or_insert_with(SearchProviderSettings::direct);+ }+ other => {+ tracing::warn!(+ provider = other,+ "[config][migrate][search] dropping unknown provider"+ );+ }+ }+ }+ }+ None => {+ let exa_route = if engine == SEARCH_ENGINE_EXA && self.exa.has_key() {+ SearchRoute::Direct+ } else {+ SearchRoute::Managed+ };+ providers.insert(+ "exa".into(),+ SearchProviderSettings {+ enabled: true,+ route: exa_route,+ },+ );+ let gemini_route = if self.gemini.has_key() && self.gemini_route.is_some() {+ gemini_route+ } else {+ SearchRoute::Managed+ };+ providers.insert(+ "gemini".into(),+ SearchProviderSettings {+ enabled: true,+ route: gemini_route,+ },+ );+ for (name, credentials) in [+ ("brave", &self.brave),+ ("querit", &self.querit),+ ("tavily", &self.tavily),+ ] {+ if credentials.has_key() {+ providers.insert(name.into(), SearchProviderSettings::direct());+ }+ }+ if legacy.tinyfish_active {+ providers.insert("tinyfish".into(), SearchProviderSettings::managed());+ }+ if legacy.seltz_active {+ providers.insert("seltz".into(), SearchProviderSettings::direct());+ }+ if legacy.searxng_active {+ providers.insert("searxng".into(), SearchProviderSettings::direct());+ }+ }}- providers- }- /// Resolve the *effective* engine after gating on API-key- /// availability. A BYO engine without a key silently falls back to- /// managed so the agent never ends up with zero search tools — the- /// UI surfaces the misconfiguration separately.- pub fn effective_engine(&self) -> SearchEngine {- match self.engine.trim().to_ascii_lowercase().as_str() {- SEARCH_ENGINE_DISABLED => SearchEngine::Disabled,- SEARCH_ENGINE_PARALLEL if self.parallel.has_key() => SearchEngine::Parallel,- SEARCH_ENGINE_BRAVE if self.brave.has_key() => SearchEngine::Brave,- SEARCH_ENGINE_QUERIT if self.querit.has_key() => SearchEngine::Querit,- SEARCH_ENGINE_EXA if self.exa.has_key() => SearchEngine::Exa,- SEARCH_ENGINE_TAVILY if self.tavily.has_key() => SearchEngine::Tavily,- _ => SearchEngine::Managed,+ // A deliberately chosen BYO engine stays first for ranked search.+ let mut roles = BTreeMap::new();+ if matches!(+ engine.as_str(),+ SEARCH_ENGINE_BRAVE | SEARCH_ENGINE_QUERIT | SEARCH_ENGINE_TAVILY+ ) && providers.contains_key(engine.as_str())+ {+ roles.insert(SEARCH_ROLE_SEARCH.to_string(), vec![engine.clone(), "exa".into()]);}- }- pub fn requested_engine_str(&self) -> &str {- let trimmed = self.engine.trim();- if trimmed.is_empty() {- SEARCH_ENGINE_MANAGED- } else {- trimmed+ if dropped_parallel {+ tracing::warn!(+ "[config][migrate][search] Parallel is no longer a search provider; \+ its selection and key were dropped (Exa and Gemini replace it)"+ );+ }+ tracing::info!(+ engine = %engine,+ enabled,+ providers = ?providers.keys().collect::<Vec<_>>(),+ "[config][migrate][search] migrated single-engine search settings"+ );++ self.enabled = Some(enabled);+ self.providers = providers;+ self.roles = roles;+ if self.presentation_provider.as_deref() == Some("managed")+ || self.presentation_provider.as_deref() == Some("parallel")+ {+ self.presentation_provider = None;}+ self.engine = None;+ self.parallel_route = None;+ self.gemini_route = None;+ self.parallel = SearchEngineCredentials::default();+ self.schema_version = SEARCH_SCHEMA_VERSION;+ true}}diff --git a/vendor/tinysearch b/vendor/tinysearchindex bde804e435..5ae99c3482 160000--- a/vendor/tinysearch+++ b/vendor/tinysearch@@ -1 +1 @@-Subproject commit bde804e43579bcfb7dde989619310bae9cadcea6+Subproject commit 5ae99c3482da63868c5c0d2d316c7ffde899d071