The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
feat(config): add resolved endpoints to config schema
Steven Enamakel9ecf32a46504
diff --git a/crates/openhuman-core/src/config/enrichers.rs b/crates/openhuman-core/src/config/enrichers.rsnew file mode 100644index 0000000000..19cbde4745--- /dev/null+++ b/crates/openhuman-core/src/config/enrichers.rs@@ -0,0 +1,61 @@+//! Config enrichers: hooks the loader runs on every loaded [`Config`].+//!+//! An outside crate registers a function that fills the config's+//! `#[serde(skip)]` resolved fields (see+//! [`ResolvedEndpoints`](crate::config::schema::resolved_endpoints::ResolvedEndpoints))+//! from its own state. Enrichers run in registration order, after the file+//! (or the embedder's config) has been read and normalized, and must be+//! idempotent: the same config can be enriched more than once. They never+//! persist anything, because the fields they write cannot be serialized.+//!+//! With none registered a load returns exactly what it returned before.++use std::sync::Arc;++use super::Config;+use crate::core::slots::{Extensions, HookSlot};++/// A registered enricher.+pub type ConfigEnricher = Arc<dyn Fn(&mut Config) + Send + Sync>;++static ENRICHERS: HookSlot<ConfigEnricher> = HookSlot::new("config::enrichers");++/// Registers the enricher `id` for the whole process. Re-registering an id+/// replaces it and keeps its position.+pub fn register_enricher<F>(id: impl Into<String>, enricher: F)+where+ F: Fn(&mut Config) + Send + Sync + 'static,+{+ ENRICHERS.register(id, Arc::new(enricher));+}++/// Registers the enricher `id` for the context built from `extensions`.+pub fn register_enricher_in<F>(extensions: &Extensions, id: impl Into<String>, enricher: F)+where+ F: Fn(&mut Config) + Send + Sync + 'static,+{+ ENRICHERS.register_in(extensions, id, Arc::new(enricher));+}++/// Removes the process-wide enricher `id`.+pub fn unregister_enricher(id: &str) -> bool {+ ENRICHERS.unregister(id)+}++/// Runs every registered enricher over `config`, in registration order.+pub fn run_enrichers(config: &mut Config) {+ for (id, enricher) in ENRICHERS.entries() {+ tracing::trace!(enricher = %id, "[config] running enricher");+ enricher(config);+ }+}++/// Consumes `config`, enriched.+pub(crate) fn enriched(mut config: Config) -> Config {+ run_enrichers(&mut config);+ config+}++#[cfg(test)]+#[path = "enrichers_tests.rs"]+mod tests;diff --git a/crates/openhuman-core/src/config/schema/mod.rs b/crates/openhuman-core/src/config/schema/mod.rsindex e315760604..fbcf8f77f9 100644--- a/crates/openhuman-core/src/config/schema/mod.rs+++ b/crates/openhuman-core/src/config/schema/mod.rs@@ -6,6 +6,8 @@ pub mod cloud_providers;pub use cloud_providers::{generate_provider_id, is_slug_reserved, AuthStyle, CloudProviderCreds};pub mod ephemeral_route;pub use ephemeral_route::{EphemeralRoute, EPHEMERAL_ROUTE_SLUG};+pub mod resolved_endpoints;+pub use resolved_endpoints::ResolvedEndpoints;mod agent;mod autonomy;mod capability_providers;diff --git a/crates/openhuman-core/src/config/schema/resolved_endpoints.rs b/crates/openhuman-core/src/config/schema/resolved_endpoints.rsnew file mode 100644index 0000000000..8dd82eb051--- /dev/null+++ b/crates/openhuman-core/src/config/schema/resolved_endpoints.rs@@ -0,0 +1,41 @@+//! Runtime-resolved service endpoints that a host fills in after a config load.+//!+//! The config file holds what the *user* chose. Some values the core needs are+//! not the user's to choose: the control-plane origin a host talks to, the+//! socket and tracing-ingestion URLs it derives, the attribution headers it+//! stamps on its requests, the product it reports as. A host that has such+//! values registers a config enricher+//! ([`register_enricher`](crate::config::register_enricher)); the loader runs it+//! on every load and it writes them here.+//!+//! The core reads these fields instead of owning the values. Like+//! [`EphemeralRoute`](super::ephemeral_route::EphemeralRoute) the field is+//! `#[serde(skip)]`: it never reaches `config.toml`, and nothing a caller+//! saves can persist it. With no enricher registered every field is empty and+//! the core behaves as it does with no hosted connection.++/// Endpoints and identity resolved by a registered config enricher. Every+/// field is `None`/empty until an enricher fills it.+#[derive(Debug, Clone, Default, PartialEq, Eq)]+pub struct ResolvedEndpoints {+ /// The origin of the host's control plane (REST API base URL).+ pub control_plane_url: Option<String>,+ /// The origin inference requests go to, when it differs from the control+ /// plane.+ pub inference_url: Option<String>,+ /// The realtime socket URL.+ pub socket_url: Option<String>,+ /// Where tracing/observability events are pushed.+ pub tracing_ingest_url: Option<String>,+ /// Headers stamped on every request to the control plane, `(name, value)`.+ pub attribution_headers: Vec<(String, String)>,+ /// The product identity the host reports (the `x-sdk-name` value).+ pub product_identity: Option<String>,+}++impl ResolvedEndpoints {+ /// Whether an enricher has filled nothing in.+ pub fn is_empty(&self) -> bool {+ *self == Self::default()+ }+}diff --git a/crates/openhuman-core/src/config/schema/types/config.rs b/crates/openhuman-core/src/config/schema/types/config.rsindex 61246a9141..c084491cf2 100644--- a/crates/openhuman-core/src/config/schema/types/config.rs+++ b/crates/openhuman-core/src/config/schema/types/config.rs@@ -383,6 +383,14 @@ pub struct Config {#[schemars(skip)]pub ephemeral_route: Option<crate::config::schema::ephemeral_route::EphemeralRoute>,+ /// Runtime only — service endpoints and identity a host's config enricher+ /// resolved ([`crate::config::register_enricher`]). Empty until one runs;+ /// never serialized. See+ /// [`resolved_endpoints`](crate::config::schema::resolved_endpoints).+ #[serde(skip)]+ #[schemars(skip)]+ pub resolved_endpoints: crate::config::schema::resolved_endpoints::ResolvedEndpoints,+/// Provider string for direct conversational chat (simple back-and-forth).#[serde(default)]pub chat_provider: Option<String>,diff --git a/crates/openhuman-core/src/config/schema/types/config_clone.rs b/crates/openhuman-core/src/config/schema/types/config_clone.rsindex bb25e363c6..3c4cd44ea3 100644--- a/crates/openhuman-core/src/config/schema/types/config_clone.rs+++ b/crates/openhuman-core/src/config/schema/types/config_clone.rs@@ -81,6 +81,7 @@ impl Clone for Config {cloud_provider_ca_certs: self.cloud_provider_ca_certs.clone(),primary_cloud: self.primary_cloud.clone(),ephemeral_route: self.ephemeral_route.clone(),+ resolved_endpoints: self.resolved_endpoints.clone(),chat_provider: self.chat_provider.clone(),reasoning_provider: self.reasoning_provider.clone(),agentic_provider: self.agentic_provider.clone(),diff --git a/crates/openhuman-core/src/config/schema/types/defaults.rs b/crates/openhuman-core/src/config/schema/types/defaults.rsindex 61279ec7cf..d22057e33e 100644--- a/crates/openhuman-core/src/config/schema/types/defaults.rs+++ b/crates/openhuman-core/src/config/schema/types/defaults.rs@@ -39,6 +39,7 @@ impl Default for Config {api_key: None,inference_url: None,ephemeral_route: None,+ resolved_endpoints: Default::default(),default_model: Some(DEFAULT_MODEL.to_string()),default_temperature: DEFAULT_TEMPERATURE,output_language: None,