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(mcp): add host agent and write root tests
Steven Enamakelbe60d3f52df4
diff --git a/crates/openhuman-core/src/mcp/host_agent_tests.rs b/crates/openhuman-core/src/mcp/host_agent_tests.rsindex f1e4aba9c8..686612e673 100644--- a/crates/openhuman-core/src/mcp/host_agent_tests.rs+++ b/crates/openhuman-core/src/mcp/host_agent_tests.rs@@ -92,3 +92,48 @@ async fn reading_an_agents_connections_does_not_create_its_host() {assert!(ambient, "the ambient lookup answers nothing connected");assert!(!temporary.path().join("agents").join("epsilon").exists());}++/// A profile's context as the SaaS profile host derives it: the profile's+/// own workspace, a profile id, and no agent id.+fn profile_context(config: &Config, profile: &str) -> Arc<CoreContext> {+ CoreContext::for_test_with_config(DomainSet::full(), config.clone()).derive_with(+ ContextOverlay::new(config.clone(), DomainSet::full(), ToolGroups::none())+ .profile(profile),+ )+}++#[tokio::test]+async fn two_profiles_default_agents_get_their_own_hosts_and_never_the_default() {+ let (one, two) = (+ tempfile::tempdir().expect("tempdir"),+ tempfile::tempdir().expect("tempdir"),+ );+ let (alice, bob) = (workspace_config(one.path()), workspace_config(two.path()));++ // Before either installed anything, neither sees a host — not each+ // other's, not the process default — and a read creates none.+ for (config, name) in [(&alice, "alice"), (&bob, "bob")] {+ let seen = CoreContext::scope(profile_context(config, name), async { try_service() }).await;+ assert!(seen.is_none(), "{name} saw a host it never opened");+ assert!(!tinymcp::Store::path_for(&config.workspace_dir).exists());+ }++ let alice_host = CoreContext::scope(profile_context(&alice, "alice"), async {+ for_config(&alice).expect("alice's host opens")+ })+ .await;+ let bob_host = CoreContext::scope(profile_context(&bob, "bob"), async {+ for_config(&bob).expect("bob's host opens")+ })+ .await;+ assert!(!Arc::ptr_eq(&alice_host, &bob_host));+ // The default agent's host sits at the profile's workspace root.+ assert!(tinymcp::Store::path_for(one.path()).exists());+ assert!(!one.path().join("agents").exists());++ let ambient_alice =+ CoreContext::scope(profile_context(&alice, "alice"), async { try_service() }).await;+ let ambient_bob = CoreContext::scope(profile_context(&bob, "bob"), async { try_service() }).await;+ assert!(Arc::ptr_eq(&ambient_alice.expect("alice's host"), &alice_host));+ assert!(Arc::ptr_eq(&ambient_bob.expect("bob's host"), &bob_host));+}diff --git a/crates/openhuman-core/src/skills/write_root_tests.rs b/crates/openhuman-core/src/skills/write_root_tests.rsindex 7cab21392b..d1a4f66d8e 100644--- a/crates/openhuman-core/src/skills/write_root_tests.rs+++ b/crates/openhuman-core/src/skills/write_root_tests.rs@@ -92,3 +92,76 @@ async fn an_agents_created_skill_lands_in_its_directory_and_only_it_discovers_it.await.contains(&"alpha-owned".to_string()));}++fn profile_on(workspace: &Path, profile: &str) -> Arc<CoreContext> {+ let mut config = crate::config::Config::default();+ config.workspace_dir = workspace.to_path_buf();+ CoreContext::for_test_with_config(DomainSet::full(), config.clone()).derive_with(+ ContextOverlay::new(config, DomainSet::full(), ToolGroups::none()).profile(profile),+ )+}++#[test]+fn skill_homes_key_on_the_tenant() {+ let workspace = Path::new("/ws");+ let tenant = |profile: Option<&str>, agent: Option<&str>| Tenant {+ profile: profile.map(str::to_owned),+ agent: agent.map(str::to_owned),+ };+ // Desktop keys are unchanged.+ assert_eq!(skill_home_for(&tenant(None, None), workspace), None);+ assert_eq!(+ skill_home_for(&tenant(None, Some("alpha")), workspace),+ Some(workspace.join("agents/alpha"))+ );+ // A profile's default agent has a home of its own, under its workspace.+ assert_eq!(+ skill_home_for(&tenant(Some("alice"), None), workspace),+ Some(workspace.join("agents/default"))+ );+}++#[tokio::test]+async fn two_profiles_default_agents_keep_their_skills_apart_from_each_other_and_the_operator() {+ let home = tempfile::tempdir().expect("home");+ let (one, two) = (+ tempfile::tempdir().expect("ws"),+ tempfile::tempdir().expect("ws"),+ );+ let home_path = home.path().to_path_buf();++ let alice_root = CoreContext::scope(profile_on(one.path(), "alice"), async {+ user_skill_install_root(one.path(), Some(&home_path))+ })+ .await;+ let bob_root = CoreContext::scope(profile_on(two.path(), "bob"), async {+ user_skill_install_root(two.path(), Some(&home_path))+ })+ .await;+ assert_eq!(alice_root, Some(one.path().join("agents/default/skills")));+ assert_eq!(bob_root, Some(two.path().join("agents/default/skills")));++ let (alice_ws, home_for_create) = (one.path().to_path_buf(), home_path.clone());+ CoreContext::scope(profile_on(one.path(), "alice"), async move {+ create_workflow_inner(user_workflow("alice-only"), Some(&home_for_create), &alice_ws)+ .expect("alice creates a workflow");+ })+ .await;+ assert!(+ !home.path().join(".openhuman").exists(),+ "a profile's workflow never lands in the operator's home"+ );++ let discover = |ws: std::path::PathBuf, profile: &'static str| {+ let ctx = profile_on(&ws, profile);+ CoreContext::scope(ctx, async move {+ names(&discover_workflows(None, Some(&ws), false))+ })+ };+ assert!(discover(one.path().to_path_buf(), "alice")+ .await+ .contains(&"alice-only".to_string()));+ assert!(!discover(two.path().to_path_buf(), "bob")+ .await+ .contains(&"alice-only".to_string()));+}