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: apply rustfmt formatting across profile and search modules
Steven Enamakel2945edeb30b8
diff --git a/Cargo.lock b/Cargo.lockindex 569ad9192c..03fafe5520 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -7074,7 +7074,7 @@ dependencies = [[[package]]name = "tinymcp"-version = "0.10.0"+version = "0.9.0"dependencies = ["anyhow","async-trait",@@ -7103,7 +7103,7 @@ dependencies = [[[package]]name = "tinymcp-bus"-version = "0.10.0"+version = "0.9.0"dependencies = ["schemars","serde",@@ -7346,13 +7346,12 @@ dependencies = [[[package]]name = "tinywallet"-version = "0.17.0"+version = "0.13.0"dependencies = ["coins-bip32","coins-bip39","ed25519-dalek","hmac 0.13.0",- "rand 0.9.5","ripemd 0.2.0","sha2 0.11.0","sha3 0.12.0",@@ -7365,7 +7364,7 @@ dependencies = [[[package]]name = "tinywallet-bus"-version = "0.17.0"+version = "0.13.0"dependencies = ["serde","serde_json",@@ -7374,7 +7373,7 @@ dependencies = [[[package]]name = "tinywallet-crypto"-version = "0.17.0"+version = "0.13.0"dependencies = ["async-trait","bech32 0.12.0",@@ -7390,7 +7389,7 @@ dependencies = [[[package]]name = "tinywallet-web3"-version = "0.17.0"+version = "0.13.0"dependencies = ["anyhow","async-trait",@@ -7411,7 +7410,7 @@ dependencies = [[[package]]name = "tinywallet-x402"-version = "0.17.0"+version = "0.13.0"dependencies = ["anyhow","async-trait",diff --git a/crates/openhuman-core/src/agent/session_host/builder/factory.rs b/crates/openhuman-core/src/agent/session_host/builder/factory.rsindex 884befce4d..2ee507fe15 100644--- a/crates/openhuman-core/src/agent/session_host/builder/factory.rs+++ b/crates/openhuman-core/src/agent/session_host/builder/factory.rs@@ -302,7 +302,11 @@ impl OpenHumanSessionHost {model_name = pinned_model.to_string();}- if let Some(model) = config.profile_providers.as_ref().and_then(|binding| binding.chat_model()) {+ if let Some(model) = config+ .profile_providers+ .as_ref()+ .and_then(|binding| binding.chat_model())+ {model_name = model.to_owned();}diff --git a/crates/openhuman-core/src/config/ops/loader/load.rs b/crates/openhuman-core/src/config/ops/loader/load.rsindex b0d7ecdf6d..97a2d8e3fd 100644--- a/crates/openhuman-core/src/config/ops/loader/load.rs+++ b/crates/openhuman-core/src/config/ops/loader/load.rs@@ -185,7 +185,9 @@ async fn normalize_loaded_config(config: &mut Config) {// `chat_onboarding_completed` field is retained only for backward-compatible// deserialization.- if let Some(binding) = config.profile_providers.clone() { binding.apply_chat(config); }+ if let Some(binding) = config.profile_providers.clone() {+ binding.apply_chat(config);+ }seed_and_enrich_model_registry(config);}diff --git a/crates/openhuman-core/src/config/schema/ephemeral_route.rs b/crates/openhuman-core/src/config/schema/ephemeral_route.rsindex fb0914dffa..09b48b5193 100644--- a/crates/openhuman-core/src/config/schema/ephemeral_route.rs+++ b/crates/openhuman-core/src/config/schema/ephemeral_route.rs@@ -68,7 +68,10 @@ pub struct EphemeralRoute {impl std::fmt::Debug for EphemeralRoute {fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {f.debug_struct("EphemeralRoute")- .field("endpoint", &crate::inference::provider::factory::redact_endpoint(&self.endpoint))+ .field(+ "endpoint",+ &crate::inference::provider::factory::redact_endpoint(&self.endpoint),+ ).field("api_key", &"[redacted]").field("header_count", &self.headers.len()).finish()diff --git a/crates/openhuman-core/src/config/schema/types/config.rs b/crates/openhuman-core/src/config/schema/types/config.rsindex 54250e45b3..c8ff0bd9ec 100644--- a/crates/openhuman-core/src/config/schema/types/config.rs+++ b/crates/openhuman-core/src/config/schema/types/config.rs@@ -58,7 +58,8 @@ pub struct Config {#[serde(skip)]#[schemars(skip)]#[doc(hidden)]- pub profile_providers: Option<std::sync::Arc<crate::profiles::provider_settings::ProfileProviderSettings>>,+ pub profile_providers:+ Option<std::sync::Arc<crate::profiles::provider_settings::ProfileProviderSettings>>,#[serde(skip)]pub workspace_dir: PathBuf,/// Agent action sandbox root — the default cwd for shell/file/git tools.diff --git a/crates/openhuman-core/src/core/runtime/direct_profile_provider.rs b/crates/openhuman-core/src/core/runtime/direct_profile_provider.rsindex d6a13a79cd..f0c198d8b9 100644--- a/crates/openhuman-core/src/core/runtime/direct_profile_provider.rs+++ b/crates/openhuman-core/src/core/runtime/direct_profile_provider.rs@@ -15,7 +15,8 @@ pub struct DirectProfileProvider {impl std::fmt::Debug for DirectProfileProvider {fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {- formatter.debug_struct("DirectProfileProvider")+ formatter+ .debug_struct("DirectProfileProvider").field("route", &self.route).field("model", &self.model).finish()@@ -46,12 +47,18 @@ impl DirectProfileProvider {anyhow::bail!("direct profile provider requires a nonblank model");}Ok(Self {- route: EphemeralRoute { endpoint, api_key, headers: Vec::new() },+ route: EphemeralRoute {+ endpoint,+ api_key,+ headers: Vec::new(),+ },model,})}- pub(crate) fn model(&self) -> &str { &self.model }+ pub(crate) fn model(&self) -> &str {+ &self.model+ }pub(crate) fn apply(&self, config: &mut crate::config::Config) {config.default_model = Some(self.model.clone());@@ -85,7 +92,11 @@ impl<'de> Deserialize<'de> for DirectProfileProvider {fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {#[derive(Deserialize)]#[serde(deny_unknown_fields)]- struct Input { endpoint: String, api_key: String, model: String }+ struct Input {+ endpoint: String,+ api_key: String,+ model: String,+ }let input = Input::deserialize(deserializer)?;Self::openai_compatible(input.endpoint, input.api_key, input.model).map_err(serde::de::Error::custom)diff --git a/crates/openhuman-core/src/core/runtime/direct_profile_provider_tests.rs b/crates/openhuman-core/src/core/runtime/direct_profile_provider_tests.rsindex 33357cb0f0..eb29029713 100644--- a/crates/openhuman-core/src/core/runtime/direct_profile_provider_tests.rs+++ b/crates/openhuman-core/src/core/runtime/direct_profile_provider_tests.rs@@ -8,8 +8,16 @@ fn rejects_partial_and_unsafe_endpoints_without_disclosing_credentials() {("https://fixture.example/v1", "private-key", " "),("file:///secret", "private-key", "model"),("http://public.example/v1", "private-key", "model"),- ("https://user:[email protected]/v1", "private-key", "model"),- ("https://fixture.example/v1?token=secret", "private-key", "model"),+ (+ "https://user:[email protected]/v1",+ "private-key",+ "model",+ ),+ (+ "https://fixture.example/v1?token=secret",+ "private-key",+ "model",+ ),] {let error = DirectProfileProvider::openai_compatible(endpoint, key, model).unwrap_err();assert!(!error.to_string().contains("private-key"));@@ -19,22 +27,34 @@ fn rejects_partial_and_unsafe_endpoints_without_disclosing_credentials() {#[test]fn pins_every_turn_workload_without_persisting_bearer() {let direct = DirectProfileProvider::openai_compatible(- "http://127.0.0.1:1234/v1", "private-key", "fixture-model",- ).unwrap();+ "http://127.0.0.1:1234/v1",+ "private-key",+ "fixture-model",+ )+ .unwrap();let mut config = crate::config::Config::default();direct.apply(&mut config);assert_eq!(config.default_model.as_deref(), Some("fixture-model"));- for route in [&config.chat_provider, &config.reasoning_provider, &config.agentic_provider, &config.coding_provider] {+ for route in [+ &config.chat_provider,+ &config.reasoning_provider,+ &config.agentic_provider,+ &config.coding_provider,+ ] {assert_eq!(route.as_deref(), Some("ephemeral-route:fixture-model"));}- assert_eq!(config.ephemeral_route.as_ref().unwrap().endpoint, "http://127.0.0.1:1234/v1");+ assert_eq!(+ config.ephemeral_route.as_ref().unwrap().endpoint,+ "http://127.0.0.1:1234/v1"+ );assert!(!toml::to_string(&config).unwrap().contains("private-key"));assert!(!format!("{direct:?}").contains("private-key"));}#[test]fn deserialization_validates_route_without_echoing_credentials() {- let invalid = "endpoint = 'file:///private'\napi_key = 'unique-deserialize-key'\nmodel = 'fixture'\n";+ let invalid =+ "endpoint = 'file:///private'\napi_key = 'unique-deserialize-key'\nmodel = 'fixture'\n";let error = toml::from_str::<DirectProfileProvider>(invalid).unwrap_err();assert!(!error.message().contains("unique-deserialize-key"));let valid = invalid.replace("file:///private", "https://fixture.example/v1");diff --git a/crates/openhuman-core/src/core/runtime/saas.rs b/crates/openhuman-core/src/core/runtime/saas.rsindex f1cd882415..d6f5141b5a 100644--- a/crates/openhuman-core/src/core/runtime/saas.rs+++ b/crates/openhuman-core/src/core/runtime/saas.rs@@ -203,8 +203,12 @@ impl SaasConfig {pub fn load(path: &Path) -> anyhow::Result<Self> {let raw = std::fs::read_to_string(path).map_err(|e| anyhow::anyhow!("reading SaaS config {}: {e}", path.display()))?;- let config: Self = toml::from_str(&raw)- .map_err(|_| anyhow::anyhow!("parsing SaaS config {}: invalid operator settings", path.display()))?;+ let config: Self = toml::from_str(&raw).map_err(|_| {+ anyhow::anyhow!(+ "parsing SaaS config {}: invalid operator settings",+ path.display()+ )+ })?;log::debug!("[saas] loaded operator config from {} (root={})",path.display(),diff --git a/crates/openhuman-core/src/modules/search/mod.rs b/crates/openhuman-core/src/modules/search/mod.rsindex 43f55846d3..8ccbde4ae3 100644--- a/crates/openhuman-core/src/modules/search/mod.rs+++ b/crates/openhuman-core/src/modules/search/mod.rs@@ -67,7 +67,11 @@ fn direct_settings(config: &Config, provider: &str) -> ProviderConfig {settings.base_url = search.host_credential(other).and_then(|pinned| pinned.base_url())- .or_else(|| search.credentials(other).and_then(|c| c.base_url.as_deref()))+ .or_else(|| {+ search+ .credentials(other)+ .and_then(|c| c.base_url.as_deref())+ }).map(str::to_owned);}}@@ -91,22 +95,32 @@ fn provider_config(config: &Config, provider: &ResolvedProvider) -> ProviderConf/// The complete private configuration for TinySearch.pub fn module_config(config: &Config) -> ModuleSearchConfig {- let private = config.profile_providers.as_ref().map(|binding| binding.effective_search(config));+ let private = config+ .profile_providers+ .as_ref()+ .map(|binding| binding.effective_search(config));let config = private.as_ref().unwrap_or(config);let direct_profile = config.profile_providers.is_some();- let credential = if direct_profile { None } else {- crate::security::credentials::session_support::resolve_backend_credential(config).ok() };+ let credential = if direct_profile {+ None+ } else {+ crate::security::credentials::session_support::resolve_backend_credential(config).ok()+ };let resolved = providers::resolve_with(config, credential.is_some());- let backend = if direct_profile { BackendConfig::default() } else { BackendConfig {- 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: crate::backend::product_identity(),- } };+ let backend = if direct_profile {+ BackendConfig::default()+ } else {+ BackendConfig {+ 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: crate::backend::product_identity(),+ }+ };let mut module_providers: BTreeMap<String, ProviderConfig> = resolved.iter()@@ -115,7 +129,8 @@ pub fn module_config(config: &Config) -> ModuleSearchConfig {.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 !direct_profile && module_providers.contains_key("gemini")+ if !direct_profile+ && module_providers.contains_key("gemini")&& !module_providers.contains_key("gemini_deep_research"){let mut deep = direct_settings(config, "gemini_deep_research");@@ -166,7 +181,9 @@ pub fn configured_tool_specs(config: &Config) -> Vec<tinysearch_bus::ToolSpec> {let available =tinysearch_bus::configured_provider_tools(&module, &tinysearch_bus::provider_tool_specs());let mut specs = tinysearch_bus::select_tools(&available, &module.presentation).tools;- if let Some(binding) = &config.profile_providers { binding.present(&mut specs); }+ if let Some(binding) = &config.profile_providers {+ binding.present(&mut specs);+ }specs}diff --git a/crates/openhuman-core/src/modules/search/proxy.rs b/crates/openhuman-core/src/modules/search/proxy.rsindex 5492f758de..bd9adde7d3 100644--- a/crates/openhuman-core/src/modules/search/proxy.rs+++ b/crates/openhuman-core/src/modules/search/proxy.rs@@ -175,7 +175,9 @@ async fn current_config(config: &Config) -> Result<Config, String> {if config.profile_providers.is_some() {let context = crate::core::runtime::CoreContext::scoped().ok_or_else(|| "profile search requires its authenticated context".to_owned())?;- let current = context.embedder_config().filter(|current| current.config_path == config.config_path)+ let current = context+ .embedder_config()+ .filter(|current| current.config_path == config.config_path).filter(|_| context.profile().is_some()).ok_or_else(|| "profile search configuration belongs to another context".to_owned())?;return Ok(current.clone());@@ -209,39 +211,80 @@ pub async fn refresh_loaded(config: &Config) -> Result<(), String> {pub async fn list_tools(config: &Config) -> Result<ListToolsResponse, String> {let current = current_config(config).await?;with_module_lock(|| async {- let mut listed: ListToolsResponse = proxy(¤t).await?- .call(names::methods::LIST_TOOLS, ()).await+ let mut listed: ListToolsResponse = proxy(¤t)+ .await?+ .call(names::methods::LIST_TOOLS, ())+ .await.map_err(|error| format!("search ListTools failed: {error}"))?;if let Some(binding) = ¤t.profile_providers {binding.present(&mut listed.tools);let capabilities = crate::profiles::capabilities::ProfileCapabilities::current();- listed.tools.retain(|tool| capabilities.as_ref().is_some_and(|capabilities| capabilities.admits(&tool.name)));+ listed.tools.retain(|tool| {+ capabilities+ .as_ref()+ .is_some_and(|capabilities| capabilities.admits(&tool.name))+ });}Ok(listed)- }).await+ })+ .await}/// The presentation and route boundary is checked before any module load or call.-fn canonical_request(config: &Config, mut request: ExecuteToolRequest) -> Result<ExecuteToolRequest, String> {- let Some(binding) = &config.profile_providers else { return Ok(request) };- if !crate::profiles::capabilities::ProfileCapabilities::current().is_some_and(|capabilities| capabilities.admits(&request.name)) {+fn canonical_request(+ config: &Config,+ mut request: ExecuteToolRequest,+) -> Result<ExecuteToolRequest, String> {+ let Some(binding) = &config.profile_providers else {+ return Ok(request);+ };+ if !crate::profiles::capabilities::ProfileCapabilities::current()+ .is_some_and(|capabilities| capabilities.admits(&request.name))+ {return Err("search tool is outside the profile capability boundary".into());}- let canonical = binding.canonical_role_name(&request.name)+ let canonical = binding+ .canonical_role_name(&request.name).ok_or_else(|| "search tool was not advertised by this profile".to_owned())?;- if !super::configured_tool_specs(config).iter().any(|tool| tool.name == request.name) {+ if !super::configured_tool_specs(config)+ .iter()+ .any(|tool| tool.name == request.name)+ {return Err("search tool is unavailable in this profile".into());}let role = tinysearch_bus::role_for_tool(canonical).ok_or_else(|| "search alias has no canonical role".to_owned())?;let module = module_config(config);- if let Some(provider) = request.arguments.get("provider").and_then(serde_json::Value::as_str) {- if !module.presentation.roles.get(&role).is_some_and(|order| order.iter().any(|allowed| allowed == provider)) {+ if let Some(provider) = request+ .arguments+ .get("provider")+ .and_then(serde_json::Value::as_str)+ {+ if !module+ .presentation+ .roles+ .get(&role)+ .is_some_and(|order| order.iter().any(|allowed| allowed == provider))+ {return Err("search provider is outside the operator role policy".into());}}- if request.arguments.get("depth").and_then(serde_json::Value::as_str).is_some_and(|depth| depth != "standard")- || ["api_key", "credential", "endpoint", "base_url", "route", "provider_url", "backend"].into_iter().any(|key| request.arguments.get(key).is_some())+ if request+ .arguments+ .get("depth")+ .and_then(serde_json::Value::as_str)+ .is_some_and(|depth| depth != "standard")+ || [+ "api_key",+ "credential",+ "endpoint",+ "base_url",+ "route",+ "provider_url",+ "backend",+ ]+ .into_iter()+ .any(|key| request.arguments.get(key).is_some()){return Err("search arguments cannot override operator routes or capabilities".into());}diff --git a/crates/openhuman-core/src/profiles/capabilities.rs b/crates/openhuman-core/src/profiles/capabilities.rsindex ebc4c36131..15b8cbaaf4 100644--- a/crates/openhuman-core/src/profiles/capabilities.rs+++ b/crates/openhuman-core/src/profiles/capabilities.rs@@ -95,7 +95,6 @@ impl ProfileCapabilities {&& !name.starts_with("mcp_")&& !crate::tools::toolpacks::pack_for_tool(name).is_some_and(|pack| pack.id == "workflows")-}/// An explicitly named operation can pass the supervised gate only with a host callback.@@ -120,8 +119,12 @@ impl ProfileCapabilities {let mut groups = ToolGroups::none();for name in names.iter().filter(|name| self.admits(name)) {let binding = super::provider_settings::ProfileProviderSettings::current();- let canonical = binding.as_ref().and_then(|binding| binding.policy_name(name));- if let Some(pack) = crate::tools::toolpacks::pack_for_tool(canonical.as_deref().unwrap_or(name)) {+ let canonical = binding+ .as_ref()+ .and_then(|binding| binding.policy_name(name));+ if let Some(pack) =+ crate::tools::toolpacks::pack_for_tool(canonical.as_deref().unwrap_or(name))+ {groups = groups.with(pack.id, GroupMode::Advertised);}}@@ -222,29 +225,35 @@ impl ToolHook for ProfilePermission {match &self.capabilities.permission {Some(permission) => {let binding = super::provider_settings::ProfileProviderSettings::current();- let canonical = binding.as_ref().and_then(|binding| binding.canonical_role_name(&context.tool_name));+ let canonical = binding+ .as_ref()+ .and_then(|binding| binding.canonical_role_name(&context.tool_name));let mut advertised = context.clone();let mut rewritten = false;if let Some(canonical) = canonical.filter(|name| *name != context.tool_name) {if !self.capabilities.admits_capability(canonical) {- return ToolHookDecision::Deny("canonical search capability is denied".into());+ return ToolHookDecision::Deny(+ "canonical search capability is denied".into(),+ );}let mut original = context.clone();original.tool_name = canonical.to_owned();match permission.before_tool_decision(&original).await {- ToolHookDecision::Proceed => {},+ ToolHookDecision::Proceed => {}ToolHookDecision::ProceedWith(arguments) => {advertised.arguments = arguments;rewritten = true;- },+ }refusal => return refusal,}}match permission.before_tool_decision(&advertised).await {- ToolHookDecision::Proceed if rewritten => ToolHookDecision::ProceedWith(advertised.arguments),+ ToolHookDecision::Proceed if rewritten => {+ ToolHookDecision::ProceedWith(advertised.arguments)+ }decision => decision,}- },+ }None => {ToolHookDecision::Deny("this profile has no host tool permission callback".into())}diff --git a/crates/openhuman-core/src/profiles/host.rs b/crates/openhuman-core/src/profiles/host.rsindex 9d5830db9f..726e2fc803 100644--- a/crates/openhuman-core/src/profiles/host.rs+++ b/crates/openhuman-core/src/profiles/host.rs@@ -141,7 +141,8 @@ impl ProfileHost {operator: Arc<CoreContext>,backend: Option<Arc<dyn StorageBackend>>,) -> Result<Self, String> {- super::provider_settings::ProfileProviderSettings::from_saas(&saas).map_err(|error| error.to_string())?;+ super::provider_settings::ProfileProviderSettings::from_saas(&saas)+ .map_err(|error| error.to_string())?;let node = saas.resolve_node_id(None).to_owned();let leases = profile_lease::store_for(&saas.root,diff --git a/crates/openhuman-core/src/profiles/provider_settings.rs b/crates/openhuman-core/src/profiles/provider_settings.rsindex 8e0721ffe1..81a31a76f7 100644--- a/crates/openhuman-core/src/profiles/provider_settings.rs+++ b/crates/openhuman-core/src/profiles/provider_settings.rs@@ -5,14 +5,16 @@//! operator keys. Role aliases are a host policy boundary, never a module tool//! router that can point at arbitrary native capabilities.+use crate::config::{+ Config, SearchConfig, SearchPresentation, SearchProviderSettings, SearchRoute,+};+use crate::core::runtime::direct_profile_provider::{validate_endpoint, DirectProfileProvider};+use crate::core::runtime::SaasConfig;use std::collections::{BTreeMap, HashSet};use std::sync::Arc;use tinysearch_bus::Role;/// Search capability vocabulary for operator presentation settings.pub use tinysearch_bus::Role as SearchRole;-use crate::config::{Config, SearchConfig, SearchPresentation, SearchProviderSettings, SearchRoute};-use crate::core::runtime::direct_profile_provider::{DirectProfileProvider, validate_endpoint};-use crate::core::runtime::SaasConfig;/// Host-only settings carried by a profile's immutable config/context.#[derive(Debug, Clone)]@@ -36,7 +38,9 @@ impl ProfileProviderSettings {if let Some(canonical) = self.canonical_role_name(name) {return Some(std::borrow::Cow::Borrowed(canonical));}- tinysearch_bus::role_for_tool(name).is_none().then(|| std::borrow::Cow::Borrowed(name))+ tinysearch_bus::role_for_tool(name)+ .is_none()+ .then(|| std::borrow::Cow::Borrowed(name))}/// Validate operator-owned direct routes and their presentation.@@ -46,40 +50,82 @@ impl ProfileProviderSettings {/// endpoints, unsafe aliases, duplicate names, and native tool collisions.pub fn from_saas(saas: &SaasConfig) -> anyhow::Result<Self> {let mut search = saas.search.clone().unwrap_or_else(|| SearchConfig {- enabled: Some(false), providers: BTreeMap::new(), ..SearchConfig::default()+ enabled: Some(false),+ providers: BTreeMap::new(),+ ..SearchConfig::default()});if search.presentation != SearchPresentation::Roles {anyhow::bail!("profile search requires role presentation");}if search.providers.iter().any(|(provider, setting)| {- setting.enabled && (!matches!(provider.as_str(), "exa" | "gemini") || setting.route != SearchRoute::Direct)+ setting.enabled+ && (!matches!(provider.as_str(), "exa" | "gemini")+ || setting.route != SearchRoute::Direct)}) {anyhow::bail!("profile search permits only direct Exa and Gemini providers");}for provider in ["exa", "gemini"] {- if let Some(endpoint) = search.credentials(provider).and_then(|credential| credential.base_url.as_deref()) {+ if let Some(endpoint) = search+ .credentials(provider)+ .and_then(|credential| credential.base_url.as_deref())+ {validate_endpoint(endpoint)?;}}// The deployment has exactly these roles and fallback order. Arguments// and stored user settings cannot add another provider or capability.- let usable: HashSet<_> = ["exa", "gemini"].into_iter().filter(|provider| {- search.providers.get(*provider).is_some_and(|setting| setting.enabled)- && search.credentials(provider).is_some_and(|credential| credential.has_key())- }).collect();- search.providers = usable.iter().map(|provider| ((*provider).to_owned(), SearchProviderSettings::direct())).collect();+ let usable: HashSet<_> = ["exa", "gemini"]+ .into_iter()+ .filter(|provider| {+ search+ .providers+ .get(*provider)+ .is_some_and(|setting| setting.enabled)+ && search+ .credentials(provider)+ .is_some_and(|credential| credential.has_key())+ })+ .collect();+ search.providers = usable+ .iter()+ .map(|provider| ((*provider).to_owned(), SearchProviderSettings::direct()))+ .collect();search.enabled = Some(!usable.is_empty());search.presentation_provider = None;search.roles = BTreeMap::from([- ("search".into(), ["exa", "gemini"].into_iter().filter(|name| usable.contains(name)).map(str::to_owned).collect()),- ("answer".into(), ["gemini"].into_iter().filter(|name| usable.contains(name)).map(str::to_owned).collect()),- ("contents".into(), ["exa"].into_iter().filter(|name| usable.contains(name)).map(str::to_owned).collect()),+ (+ "search".into(),+ ["exa", "gemini"]+ .into_iter()+ .filter(|name| usable.contains(name))+ .map(str::to_owned)+ .collect(),+ ),+ (+ "answer".into(),+ ["gemini"]+ .into_iter()+ .filter(|name| usable.contains(name))+ .map(str::to_owned)+ .collect(),+ ),+ (+ "contents".into(),+ ["exa"]+ .into_iter()+ .filter(|name| usable.contains(name))+ .map(str::to_owned)+ .collect(),+ ),]);let role_names = saas.search_role_names.clone();let mut used = HashSet::new();for role in crate::search::providers::ROLES {let canonical = tinysearch_bus::names::role_tool_name(role);- let name = role_names.get(&role).map(String::as_str).unwrap_or(canonical);+ let name = role_names+ .get(&role)+ .map(String::as_str)+ .unwrap_or(canonical);if !valid_identifier(name) || !used.insert(name.to_owned()) {anyhow::bail!("profile search role names require unique safe tool identifiers");}@@ -87,7 +133,11 @@ impl ProfileProviderSettings {anyhow::bail!("profile search role name collides with a native tool");}}- Ok(Self { chat: saas.chat_provider.clone(), search, role_names })+ Ok(Self {+ chat: saas.chat_provider.clone(),+ search,+ role_names,+ })}/// Attach a serialization-skipped binding to a profile config. The visible@@ -106,10 +156,14 @@ impl ProfileProviderSettings {}/// Model fixed by the operator, when direct chat was configured.- pub(crate) fn chat_model(&self) -> Option<&str> { self.chat.as_ref().map(DirectProfileProvider::model) }+ pub(crate) fn chat_model(&self) -> Option<&str> {+ self.chat.as_ref().map(DirectProfileProvider::model)+ }pub(crate) fn apply_chat(&self, config: &mut Config) {- if let Some(chat) = &self.chat { chat.apply(config); }+ if let Some(chat) = &self.chat {+ chat.apply(config);+ }}/// Private search configuration for module initialization only.@@ -125,23 +179,35 @@ impl ProfileProviderSettings {/// An advertised role maps exactly once to its canonical module operation./// Renamed canonical operations and provider-native names never resolve.pub fn canonical_role_name(&self, advertised: &str) -> Option<&'static str> {- crate::search::providers::ROLES.into_iter().find_map(|role| {- (self.advertised_role_name(role) == advertised).then(|| tinysearch_bus::names::role_tool_name(role))- })+ crate::search::providers::ROLES+ .into_iter()+ .find_map(|role| {+ (self.advertised_role_name(role) == advertised)+ .then(|| tinysearch_bus::names::role_tool_name(role))+ })}/// The operator-selected name for a role, or the ordinary canonical name.pub fn advertised_role_name(&self, role: Role) -> &str {- self.role_names.get(&role).map(String::as_str).unwrap_or_else(|| tinysearch_bus::names::role_tool_name(role))+ self.role_names+ .get(&role)+ .map(String::as_str)+ .unwrap_or_else(|| tinysearch_bus::names::role_tool_name(role))}/// Rename only canonical role declarations; no provider extras are exposed.pub(crate) fn present(&self, specs: &mut Vec<tinysearch_bus::ToolSpec>) {specs.retain_mut(|spec| {- let Some(role) = tinysearch_bus::role_for_tool(&spec.name) else { return false };+ let Some(role) = tinysearch_bus::role_for_tool(&spec.name) else {+ return false;+ };spec.name = self.advertised_role_name(role).to_owned();// Deep research is a separate capability the deployment never grants.- if let Some(properties) = spec.parameters.get_mut("properties").and_then(serde_json::Value::as_object_mut) {+ if let Some(properties) = spec+ .parameters+ .get_mut("properties")+ .and_then(serde_json::Value::as_object_mut)+ {properties.remove("depth");}true@@ -151,17 +217,33 @@ impl ProfileProviderSettings {fn valid_identifier(name: &str) -> bool {let mut characters = name.chars();- name.len() <= 64 && characters.next().is_some_and(|first| first.is_ascii_alphabetic() || first == '_')+ name.len() <= 64+ && characters+ .next()+ .is_some_and(|first| first.is_ascii_alphabetic() || first == '_')&& characters.all(|character| character.is_ascii_alphanumeric() || character == '_')}fn collides(name: &str) -> bool {tinysearch_bus::role_for_tool(name).is_some()- || tinysearch_bus::provider_tool_specs().iter().any(|tool| tool.name == name)+ || tinysearch_bus::provider_tool_specs()+ .iter()+ .any(|tool| tool.name == name)|| crate::tools::toolpacks::pack_for_tool(name).is_some()|| super::tools::HARD_DENIED.contains(&name)- || super::tools::HARD_DENIED_PREFIXES.iter().any(|prefix| name.starts_with(prefix))- || matches!(name, "shell" | "memory" | "show_page" | "search" | "http_request" | "spawn_agent" | "spawn_async_subagent")+ || super::tools::HARD_DENIED_PREFIXES+ .iter()+ .any(|prefix| name.starts_with(prefix))+ || matches!(+ name,+ "shell"+ | "memory"+ | "show_page"+ | "search"+ | "http_request"+ | "spawn_agent"+ | "spawn_async_subagent"+ )}#[cfg(test)]diff --git a/crates/openhuman-core/src/profiles/provider_settings_tests.rs b/crates/openhuman-core/src/profiles/provider_settings_tests.rsindex 6438bcd03c..5fc1455008 100644--- a/crates/openhuman-core/src/profiles/provider_settings_tests.rs+++ b/crates/openhuman-core/src/profiles/provider_settings_tests.rs@@ -14,8 +14,14 @@ fn deployment(exa: Option<&str>, gemini: Option<&str>) -> crate::core::runtime::("answer".into(), vec!["gemini".into()]),("contents".into(), vec!["exa".into()]),]);- search.exa = SearchEngineCredentials { api_key: exa.map(str::to_owned), base_url: Some("http://127.0.0.1:1234".into()) };- search.gemini = SearchEngineCredentials { api_key: gemini.map(str::to_owned), base_url: Some("http://127.0.0.1:2345".into()) };+ search.exa = SearchEngineCredentials {+ api_key: exa.map(str::to_owned),+ base_url: Some("http://127.0.0.1:1234".into()),+ };+ search.gemini = SearchEngineCredentials {+ api_key: gemini.map(str::to_owned),+ base_url: Some("http://127.0.0.1:2345".into()),+ };deployment.search = Some(search);deployment.search_role_names = std::collections::BTreeMap::from([(Role::Search, "web_search".into()),@@ -41,31 +47,75 @@ fn direct_search_binding_never_serializes_operator_credentials() {#[test]fn role_aliases_resolve_once_and_canonical_names_cannot_bypass_presentation() {- let settings = ProfileProviderSettings::from_saas(&deployment(Some("key"), Some("key"))).unwrap();- assert_eq!(settings.canonical_role_name("web_search"), Some("web_search_tool"));- assert_eq!(settings.canonical_role_name("web_answer"), Some("web_answer_tool"));- assert_eq!(settings.canonical_role_name("web_contents"), Some("web_contents_tool"));- for name in ["web_search_tool", "web_answer_tool", "web_contents_tool", "shell", "exa_search", "unknown", "web_search_tool_tool"] {+ let settings =+ ProfileProviderSettings::from_saas(&deployment(Some("key"), Some("key"))).unwrap();+ assert_eq!(+ settings.canonical_role_name("web_search"),+ Some("web_search_tool")+ );+ assert_eq!(+ settings.canonical_role_name("web_answer"),+ Some("web_answer_tool")+ );+ assert_eq!(+ settings.canonical_role_name("web_contents"),+ Some("web_contents_tool")+ );+ for name in [+ "web_search_tool",+ "web_answer_tool",+ "web_contents_tool",+ "shell",+ "exa_search",+ "unknown",+ "web_search_tool_tool",+ ] {assert_eq!(settings.canonical_role_name(name), None, "{name}");}}#[test]fn rejects_collisions_duplicates_unsafe_identifiers_and_alias_chains() {- for alias in ["", " ", "shell", "memory", "show_page", "web_answer_tool", "exa_search", "bad.name", "chain->web_search", "web_answer"] {+ for alias in [+ "",+ " ",+ "shell",+ "memory",+ "show_page",+ "web_answer_tool",+ "exa_search",+ "bad.name",+ "chain->web_search",+ "web_answer",+ ] {let mut deployment = deployment(Some("key"), Some("key"));- deployment.search_role_names.insert(Role::Search, alias.into());- assert!(ProfileProviderSettings::from_saas(&deployment).is_err(), "{alias}");+ deployment+ .search_role_names+ .insert(Role::Search, alias.into());+ assert!(+ ProfileProviderSettings::from_saas(&deployment).is_err(),+ "{alias}"+ );}}#[test]fn rejects_managed_routes_extra_providers_and_provider_native_presentation() {let mut managed = deployment(Some("key"), None);- managed.search.as_mut().unwrap().providers.insert("exa".into(), SearchProviderSettings::managed());+ managed+ .search+ .as_mut()+ .unwrap()+ .providers+ .insert("exa".into(), SearchProviderSettings::managed());assert!(ProfileProviderSettings::from_saas(&managed).is_err());let mut extra = deployment(Some("key"), None);- extra.search.as_mut().unwrap().providers.insert("brave".into(), SearchProviderSettings::direct());+ extra+ .search+ .as_mut()+ .unwrap()+ .providers+ .insert("brave".into(), SearchProviderSettings::direct());assert!(ProfileProviderSettings::from_saas(&extra).is_err());let mut native = deployment(Some("key"), None);native.search.as_mut().unwrap().presentation = SearchPresentation::AllTools;@@ -81,17 +131,42 @@ fn private_module_configuration_preserves_direct_urls_and_never_resolves_managedconfig.api_key = Some("ambient-managed-key-must-not-be-read".into());settings.bind(&mut config);let module = crate::modules::search::module_config(&config);- assert_eq!(module.providers.keys().map(String::as_str).collect::<Vec<_>>(), ["exa", "gemini"]);- assert_eq!(module.providers["exa"].base_url.as_deref(), Some("http://127.0.0.1:1234"));- assert_eq!(module.providers["gemini"].base_url.as_deref(), Some("http://127.0.0.1:2345"));- assert_eq!(module.providers["exa"].credential.as_deref(), Some("exa-fixture-key"));- assert_eq!(module.providers["gemini"].credential.as_deref(), Some("gemini-fixture-key"));+ assert_eq!(+ module+ .providers+ .keys()+ .map(String::as_str)+ .collect::<Vec<_>>(),+ ["exa", "gemini"]+ );+ assert_eq!(+ module.providers["exa"].base_url.as_deref(),+ Some("http://127.0.0.1:1234")+ );+ assert_eq!(+ module.providers["gemini"].base_url.as_deref(),+ Some("http://127.0.0.1:2345")+ );+ assert_eq!(+ module.providers["exa"].credential.as_deref(),+ Some("exa-fixture-key")+ );+ assert_eq!(+ module.providers["gemini"].credential.as_deref(),+ Some("gemini-fixture-key")+ );assert!(module.backend.credential.is_none());assert!(module.backend.base_url.is_none());assert_eq!(module.presentation.roles[&Role::Search], ["exa", "gemini"]);assert_eq!(module.presentation.roles[&Role::Answer], ["gemini"]);assert_eq!(module.presentation.roles[&Role::Contents], ["exa"]);- assert_eq!(crate::modules::search::configured_tool_specs(&config).iter().map(|spec| spec.name.as_str()).collect::<Vec<_>>(), ["web_search", "web_answer", "web_contents"]);+ assert_eq!(+ crate::modules::search::configured_tool_specs(&config)+ .iter()+ .map(|spec| spec.name.as_str())+ .collect::<Vec<_>>(),+ ["web_search", "web_answer", "web_contents"]+ );}#[cfg(feature = "modules")]@@ -108,7 +183,13 @@ fn blank_search_keys_remove_tools_instead_of_inheriting_managed_defaults() {settings.bind(&mut config);let module = crate::modules::search::module_config(&config);assert_eq!(module.enabled, !expected.is_empty());- assert_eq!(crate::modules::search::configured_tool_specs(&config).iter().map(|spec| spec.name.as_str()).collect::<Vec<_>>(), expected);+ assert_eq!(+ crate::modules::search::configured_tool_specs(&config)+ .iter()+ .map(|spec| spec.name.as_str())+ .collect::<Vec<_>>(),+ expected+ );assert!(module.backend.base_url.is_none());assert!(module.backend.credential.is_none());}diff --git a/crates/openhuman-core/src/search/providers.rs b/crates/openhuman-core/src/search/providers.rsindex de4e167c60..f205651f40 100644--- a/crates/openhuman-core/src/search/providers.rs+++ b/crates/openhuman-core/src/search/providers.rs@@ -76,7 +76,9 @@ pub fn direct_configured(config: &Config, provider: &str) -> bool {/// Whether the process holds a credential the managed backend accepts.pub fn backend_credential_available(config: &Config) -> bool {- if config.profile_providers.is_some() { return false; }+ if config.profile_providers.is_some() {+ return false;+ }crate::security::credentials::session_support::resolve_backend_credential(config).is_ok()}diff --git a/crates/openhuman-embed/src/config.rs b/crates/openhuman-embed/src/config.rsindex fcfca0b748..79cfbf9a9e 100644--- a/crates/openhuman-embed/src/config.rs+++ b/crates/openhuman-embed/src/config.rs@@ -110,6 +110,8 @@ pub fn read_active_user_id(root: &Path) -> Option<String> {mod tests;/// Operator search policy and direct-route credential vocabulary.-pub use openhuman_core::config::{SearchConfig, SearchEngineCredentials, SearchPresentation, SearchProviderSettings, SearchRoute};+pub use openhuman_core::config::{+ SearchConfig, SearchEngineCredentials, SearchPresentation, SearchProviderSettings, SearchRoute,+};/// The three native search capabilities whose names an operator can present.pub use openhuman_core::profiles::provider_settings::SearchRole;diff --git a/crates/openhuman-embed/src/lib.rs b/crates/openhuman-embed/src/lib.rsindex 2d4507ce9c..5d930ce78e 100644--- a/crates/openhuman-embed/src/lib.rs+++ b/crates/openhuman-embed/src/lib.rs@@ -189,9 +189,9 @@ pub use harness::{pub use harness::{HttpHeader, McpAuthConfig, McpServer};#[cfg(feature = "channels")]pub use profiles::{- ChatReply, DirectProfileProvider, OpenError, ProfileError, ProfileEvents, ProfileHandle, ProfileId, ProfileIdMode,- ProfileRuntime, ProfileRuntimeBuilder, ProfileSummary, Provisioned, RelayAccepted,- RelayMessage, SaasConfig,+ ChatReply, DirectProfileProvider, OpenError, ProfileError, ProfileEvents, ProfileHandle,+ ProfileId, ProfileIdMode, ProfileRuntime, ProfileRuntimeBuilder, ProfileSummary, Provisioned,+ RelayAccepted, RelayMessage, SaasConfig,};pub use runtime::builder::DEFAULT_MAX_AGENTS;/// Read-only view of a [`RuntimeBuilder`], for the layered crates' tests.diff --git a/crates/openhuman-embed/src/profiles.rs b/crates/openhuman-embed/src/profiles.rsindex 205e204321..9db3564d93 100644--- a/crates/openhuman-embed/src/profiles.rs+++ b/crates/openhuman-embed/src/profiles.rs@@ -65,10 +65,10 @@ mod host;pub use handle::{ChatReply, ProfileEvents, ProfileHandle, RelayAccepted};pub use openhuman_core::channels::providers::relay::RelayInboundParams as RelayMessage;-pub use openhuman_core::core::runtime::saas::SaasSandboxConfig;-pub use openhuman_core::core::runtime::SaasConfig;/// Validated operator-owned direct inference settings.pub use openhuman_core::core::runtime::direct_profile_provider::DirectProfileProvider;+pub use openhuman_core::core::runtime::saas::SaasSandboxConfig;+pub use openhuman_core::core::runtime::SaasConfig;pub use openhuman_core::profiles::{OpenError, ProfileId, ProfileIdMode, ProfileSummary};pub use openhuman_core::storage::lease::LeaseRecord;pub use openhuman_core::threads::{ConversationMessageRecord, ConversationThreadSummary};