Skip to content

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

feat(config): add user state loading and profile layout schema

Steven Enamakel988232859d4d
diff --git a/crates/openhuman-core/src/config/schema/load_user_state.rs b/crates/openhuman-core/src/config/schema/load_user_state.rs
index 8ba130e028..89944acf60 100644
--- a/crates/openhuman-core/src/config/schema/load_user_state.rs
+++ b/crates/openhuman-core/src/config/schema/load_user_state.rs
@@ -234,7 +234,7 @@ pub fn clear_active_user(default_openhuman_dir: &Path) -> Result<()> {
/// Returns the user-scoped openhuman directory for the given user id:
/// `{default_openhuman_dir}/users/{user_id}`.
pub fn user_openhuman_dir(default_openhuman_dir: &Path, user_id: &str) -> PathBuf {
- default_openhuman_dir.join("users").join(user_id)
+ crate::config::schema::profile_layout::users_dir(default_openhuman_dir).join(user_id)
}
/// Stable id used to scope the openhuman directory before any user has
diff --git a/crates/openhuman-core/src/config/schema/mod.rs b/crates/openhuman-core/src/config/schema/mod.rs
index abcb5ce1f0..03f4386d2a 100644
--- a/crates/openhuman-core/src/config/schema/mod.rs
+++ b/crates/openhuman-core/src/config/schema/mod.rs
@@ -31,6 +31,8 @@ pub mod hosting;
pub use hosting::HostingConfig;
pub mod storage;
pub use storage::StorageConfig;
+pub mod profile_layout;
+pub use profile_layout::{users_dir, ProfileLayout};
mod identity_cost;
mod load;
pub(crate) use load::config_from_toml_str;
diff --git a/crates/openhuman-core/src/config/schema/profile_layout.rs b/crates/openhuman-core/src/config/schema/profile_layout.rs
index 0ea946bd21..81d5dc2a5a 100644
--- a/crates/openhuman-core/src/config/schema/profile_layout.rs
+++ b/crates/openhuman-core/src/config/schema/profile_layout.rs
@@ -18,7 +18,7 @@
use std::path::{Path, PathBuf};
-use super::load_user_state_paths::user_openhuman_dir;
+use super::user_openhuman_dir;
/// The profile metadata file, beside `config.toml`.
pub const PROFILE_META_FILE: &str = "profile.toml";
@@ -64,13 +64,13 @@ impl ProfileLayout {
}
}
-/// `<root>/users`: the parent of every profile directory.
+/// The directory under a root that holds every profile.
+pub const USERS_DIR: &str = "users";
+
+/// `<root>/users`: the parent of every profile directory. The desktop's
+/// [`user_openhuman_dir`] is built on it.
pub fn users_dir(root: &Path) -> PathBuf {
- // Derived from `user_openhuman_dir` so the two never disagree.
- user_openhuman_dir(root, "")
- .parent()
- .map(Path::to_path_buf)
- .unwrap_or_else(|| root.join("users"))
+ root.join(USERS_DIR)
}
#[cfg(test)]