Skip to content

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

feat(config): add config loading support

Steven Enamakel281d50447bcc
diff --git a/crates/openhuman-core/src/config/mod.rs b/crates/openhuman-core/src/config/mod.rs
index 9a8ce4b330..e7680c77eb 100644
--- a/crates/openhuman-core/src/config/mod.rs
+++ b/crates/openhuman-core/src/config/mod.rs
@@ -9,6 +9,7 @@
pub mod app_env;
pub mod daemon;
+pub mod enrichers;
pub mod migrations;
pub mod ops;
pub mod schema;
@@ -19,6 +20,9 @@ pub mod workspace_handle;
#[allow(unused_imports)]
pub use daemon::DaemonConfig;
+pub use enrichers::{
+ register_enricher, register_enricher_in, run_enrichers, unregister_enricher, ConfigEnricher,
+};
/// RPC operations for configuration.
pub use ops as rpc;
diff --git a/crates/openhuman-core/src/config/ops/loader/load.rs b/crates/openhuman-core/src/config/ops/loader/load.rs
index 644195a0ec..3a34bb3ed6 100644
--- a/crates/openhuman-core/src/config/ops/loader/load.rs
+++ b/crates/openhuman-core/src/config/ops/loader/load.rs
@@ -204,6 +204,9 @@ async fn normalize_loaded_config(config: &mut Config) {
binding.apply_chat(config);
}
seed_and_enrich_model_registry(config);
+ // Hook point for a host's resolved endpoints; covers the embedder-supplied
+ // config path, which never goes through `Config::load_*`.
+ crate::config::enrichers::run_enrichers(config);
}
/// Populate per-token pricing on the model registry from the static catalog.
diff --git a/crates/openhuman-core/src/config/schema/load/impl_load.rs b/crates/openhuman-core/src/config/schema/load/impl_load.rs
index a2578dd29c..3581846693 100644
--- a/crates/openhuman-core/src/config/schema/load/impl_load.rs
+++ b/crates/openhuman-core/src/config/schema/load/impl_load.rs
@@ -318,6 +318,12 @@ async fn describe_config_ownership(_path: &Path) -> String {
impl Config {
pub async fn load_or_init() -> Result<Self> {
+ Self::load_or_init_unenriched()
+ .await
+ .map(crate::config::enrichers::enriched)
+ }
+
+ async fn load_or_init_unenriched() -> Result<Self> {
if let Some(scoped) = super::saas_scope::saas_scoped_config() {
return scoped;
}
@@ -407,6 +413,12 @@ impl Config {
/// for auth token resolution when the dump script overrides
/// `OPENHUMAN_WORKSPACE` to a throwaway temp directory.
pub async fn load_from_default_paths() -> Result<Self> {
+ Self::load_from_default_paths_unenriched()
+ .await
+ .map(crate::config::enrichers::enriched)
+ }
+
+ async fn load_from_default_paths_unenriched() -> Result<Self> {
let (default_openhuman_dir, default_workspace_dir) = default_config_and_workspace_dirs()?;
let (openhuman_dir, workspace_dir, _source) =
resolve_config_dirs_ignoring_env(&default_openhuman_dir, &default_workspace_dir)
@@ -455,6 +467,15 @@ impl Config {
/// streams with unrelated tests or runtime tasks that temporarily
/// repoint it. Other process env overrides still apply.
pub async fn load_from_config_path(config_path: &Path, workspace_dir: &Path) -> Result<Self> {
+ Self::load_from_config_path_unenriched(config_path, workspace_dir)
+ .await
+ .map(crate::config::enrichers::enriched)
+ }
+
+ async fn load_from_config_path_unenriched(
+ config_path: &Path,
+ workspace_dir: &Path,
+ ) -> Result<Self> {
let config_path = config_path.to_path_buf();
let workspace_dir = workspace_dir.to_path_buf();