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 profile layout schema
Steven Enamakelff5a1354c158
diff --git a/crates/openhuman-core/src/config/schema/profile_layout.rs b/crates/openhuman-core/src/config/schema/profile_layout.rsnew file mode 100644index 0000000000..0ea946bd21--- /dev/null+++ b/crates/openhuman-core/src/config/schema/profile_layout.rs@@ -0,0 +1,78 @@+//! Where one user profile's state lives: the layout the desktop and a SaaS+//! core share.+//!+//! ```text+//! <root>/users/<profile-id>/+//! profile.toml SaaS profile metadata (the desktop does not write it)+//! config.toml the profile's config_path+//! workspace/ sessions, memory, threads, cron, cost — internal state+//! sandbox/ a SaaS profile's action_dir+//! ```+//!+//! On the desktop `<root>` is `~/.openhuman` and the profile id is the+//! signed-in user's id (or `local` before login); the config loader resolves+//! `config.toml` and `workspace/` from here+//! (`load::dirs::resolve_config_dirs_ignoring_env`). A SaaS core roots it at+//! its operator-chosen directory (`profiles::layout`). Both build every path+//! through [`ProfileLayout::new`], so the two cannot drift apart.++use std::path::{Path, PathBuf};++use super::load_user_state_paths::user_openhuman_dir;++/// The profile metadata file, beside `config.toml`.+pub const PROFILE_META_FILE: &str = "profile.toml";+/// The profile's config file.+pub const PROFILE_CONFIG_FILE: &str = "config.toml";+/// The profile's internal-state directory.+pub const PROFILE_WORKSPACE_DIR: &str = "workspace";+/// The profile's sandbox (a SaaS profile's `action_dir`).+pub const PROFILE_SANDBOX_DIR: &str = "sandbox";++/// Resolved paths of one profile under a root.+#[derive(Debug, Clone, PartialEq, Eq)]+pub struct ProfileLayout {+ /// `<root>/users/<id>`.+ pub dir: PathBuf,+ /// `<dir>/profile.toml`.+ pub meta_path: PathBuf,+ /// `<dir>/config.toml`.+ pub config_path: PathBuf,+ /// `<dir>/workspace`.+ pub workspace_dir: PathBuf,+ /// `<dir>/sandbox`.+ pub sandbox_dir: PathBuf,+}++impl ProfileLayout {+ /// The layout of profile `id` under `root`. The id is used as one path+ /// segment; callers pass a validated id (`profiles::ProfileId`, or the+ /// desktop's active user id).+ pub fn new(root: &Path, id: impl AsRef<str>) -> Self {+ Self::at(user_openhuman_dir(root, id.as_ref()))+ }++ /// The layout of the profile whose directory is `dir`.+ pub fn at(dir: PathBuf) -> Self {+ Self {+ meta_path: dir.join(PROFILE_META_FILE),+ config_path: dir.join(PROFILE_CONFIG_FILE),+ workspace_dir: dir.join(PROFILE_WORKSPACE_DIR),+ sandbox_dir: dir.join(PROFILE_SANDBOX_DIR),+ dir,+ }+ }+}++/// `<root>/users`: the parent of every profile directory.+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"))+}++#[cfg(test)]+#[path = "profile_layout_tests.rs"]+mod tests;diff --git a/crates/openhuman-core/src/config/schema/profile_layout_tests.rs b/crates/openhuman-core/src/config/schema/profile_layout_tests.rsnew file mode 100644index 0000000000..9cd382527a--- /dev/null+++ b/crates/openhuman-core/src/config/schema/profile_layout_tests.rs@@ -0,0 +1,30 @@+use super::*;++#[test]+fn every_path_sits_under_the_profile_directory() {+ let layout = ProfileLayout::new(Path::new("/srv/oh"), "alice");+ assert_eq!(layout.dir, Path::new("/srv/oh/users/alice"));+ assert_eq!(layout.meta_path, Path::new("/srv/oh/users/alice/profile.toml"));+ assert_eq!(layout.config_path, Path::new("/srv/oh/users/alice/config.toml"));+ assert_eq!(layout.workspace_dir, Path::new("/srv/oh/users/alice/workspace"));+ assert_eq!(layout.sandbox_dir, Path::new("/srv/oh/users/alice/sandbox"));+}++#[test]+fn users_dir_is_the_parent_of_every_profile() {+ let root = Path::new("/srv/oh");+ assert_eq!(users_dir(root), Path::new("/srv/oh/users"));+ assert_eq!(+ ProfileLayout::new(root, "bob").dir.parent(),+ Some(users_dir(root).as_path())+ );+}++#[test]+fn the_layout_matches_the_desktop_user_directory() {+ let root = Path::new("/home/u/.openhuman");+ assert_eq!(+ ProfileLayout::new(root, "65f1c0ffee0123456789abcd").dir,+ super::super::user_openhuman_dir(root, "65f1c0ffee0123456789abcd")+ );+}