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
style: apply rustfmt formatting to profile tests
Steven Enamakel6256bc40c5b2
diff --git a/crates/openhuman-core/src/profiles/layout_tests.rs b/crates/openhuman-core/src/profiles/layout_tests.rsindex bf247e17d5..6b2e7552d2 100644--- a/crates/openhuman-core/src/profiles/layout_tests.rs+++ b/crates/openhuman-core/src/profiles/layout_tests.rs@@ -116,5 +116,11 @@ fn profiles_never_use_the_unrestricted_empty_channel_permission_map() {let layout = profile_layout(Path::new("/srv/oh"), &id());let config = profile_config(&layout, &id());assert!(!config.agent.channel_permissions.is_empty());- assert!(config.agent.channel_permissions.values().all(|v| v == "readonly"));+ assert!(+ config+ .agent+ .channel_permissions+ .values()+ .all(|v| v == "readonly")+ );}diff --git a/crates/openhuman-embed/tests/profile_host_capabilities.rs b/crates/openhuman-embed/tests/profile_host_capabilities.rsindex a7e3d04943..ac3b4ff253 100644--- a/crates/openhuman-embed/tests/profile_host_capabilities.rs+++ b/crates/openhuman-embed/tests/profile_host_capabilities.rs@@ -6,13 +6,19 @@ mod common;use std::sync::{Arc, Mutex};use std::time::Duration;-use common::{chat_completion, chat_requests, runtime_without_master_key, tool_call_completion, tool_names, tool_results, PointedTransport};+use common::{+ PointedTransport, chat_completion, chat_requests, runtime_without_master_key,+ tool_call_completion, tool_names, tool_results,+};use openhuman_embed::memory::api::conformance::ReferenceEngine;use openhuman_embed::memory::api::{LearningKind, MemoryEngine, MemoryMeta, StoreItem};use openhuman_embed::profiles::ProfileCredentialKind;use openhuman_embed::seams::ToolHookDecision;-use openhuman_embed::{HostTurnTools, PermissionLevel, ProfileRuntime, RelayMessage, SaasConfig, Tool, ToolResult, ToolScopeSpec};-use serde_json::{json, Value};+use openhuman_embed::{+ HostTurnTools, PermissionLevel, ProfileRuntime, RelayMessage, SaasConfig, Tool, ToolResult,+ ToolScopeSpec,+};+use serde_json::{Value, json};use wiremock::{Mock, Request, Respond, ResponseTemplate};struct TenantTool {@@ -22,13 +28,22 @@ struct TenantTool {#[async_trait::async_trait]impl Tool for TenantTool {- fn name(&self) -> &str { self.name }- fn description(&self) -> &str { "Report the current profile" }- fn parameters_schema(&self) -> Value { json!({"type":"object","properties":{}}) }+ fn name(&self) -> &str {+ self.name+ }+ fn description(&self) -> &str {+ "Report the current profile"+ }+ fn parameters_schema(&self) -> Value {+ json!({"type":"object","properties":{}})+ }async fn execute(&self, _: Value) -> anyhow::Result<ToolResult> {let tenant = openhuman_core::core::runtime::current_tenant()?;let profile = tenant.profile.expect("profile tool always has a tenant");- self.calls.lock().unwrap().push(format!("{}:{profile}", self.name));+ self.calls+ .lock()+ .unwrap()+ .push(format!("{}:{profile}", self.name));Ok(ToolResult::success(profile))}}@@ -40,7 +55,14 @@ impl Respond for CallTools {return ResponseTemplate::new(200).set_body_json(chat_completion("done"));}let mut completion = tool_call_completion("tenant_probe", "{}");- let names = ["tenant_probe", "hidden", "shell", "delegate", "curl", "install_workflow_from_url"];+ let names = [+ "tenant_probe",+ "hidden",+ "shell",+ "delegate",+ "curl",+ "install_workflow_from_url",+ ];completion["choices"][0]["message"]["tool_calls"] = json!(names.iter().enumerate().map(|(i, name)| json!({"id":format!("call_{i}"),"type":"function","function":{"name":name,"arguments":"{}"}})).collect::<Vec<_>>());ResponseTemplate::new(200).set_body_json(completion)}@@ -57,58 +79,163 @@ async fn scenario() {let inference = wiremock::MockServer::start().await;Mock::given(wiremock::matchers::method("POST")).and(wiremock::matchers::path("/v1/chat/completions"))- .respond_with(CallTools).mount(&inference).await;+ .respond_with(CallTools)+ .mount(&inference)+ .await;PointedTransport::install(&inference.uri());let root = tempfile::tempdir().unwrap();let calls = Arc::new(Mutex::new(Vec::new()));let factory_calls = calls.clone();let engine = Arc::new(ReferenceEngine::new());let runtime = ProfileRuntime::builder(SaasConfig::new(root.path()))- .tools(move |_| HostTurnTools::advertised(["tenant_probe", "hidden", "shell", "delegate", "curl", "install_workflow_from_url"].into_iter().map(|name| Box::new(TenantTool { name, calls: factory_calls.clone() }) as Box<dyn Tool>).collect()))- .tool_scope(ToolScopeSpec::Named(vec!["tenant_probe".into(), "memory".into(), "shell".into(), "delegate".into(), "curl".into(), "install_workflow_from_url".into()]))+ .tools(move |_| {+ HostTurnTools::advertised(+ [+ "tenant_probe",+ "hidden",+ "shell",+ "delegate",+ "curl",+ "install_workflow_from_url",+ ]+ .into_iter()+ .map(|name| {+ Box::new(TenantTool {+ name,+ calls: factory_calls.clone(),+ }) as Box<dyn Tool>+ })+ .collect(),+ )+ })+ .tool_scope(ToolScopeSpec::Named(vec![+ "tenant_probe".into(),+ "memory".into(),+ "shell".into(),+ "delegate".into(),+ "curl".into(),+ "install_workflow_from_url".into(),+ ])).can_use_tool(|_| Box::pin(async { ToolHookDecision::Proceed }))- .channel_permissions([("cli", PermissionLevel::Execute), ("web_channel", PermissionLevel::Execute), ("telegram", PermissionLevel::Execute)])+ .channel_permissions([+ ("cli", PermissionLevel::Execute),+ ("web_channel", PermissionLevel::Execute),+ ("telegram", PermissionLevel::Execute),+ ]).memory_engine(engine.clone())- .build().await.unwrap();+ .build()+ .await+ .unwrap();let mut handles = Vec::new();for user in ["alice", "bob"] {let provisioned = runtime.provision(user).await.unwrap();- runtime.set_credential(&provisioned.profile_id, ProfileCredentialKind::ApiKey, "fixture-key").await.unwrap();+ runtime+ .set_credential(+ &provisioned.profile_id,+ ProfileCredentialKind::ApiKey,+ "fixture-key",+ )+ .await+ .unwrap();let handle = runtime.open(user).await.unwrap();assert!(handle.context().embedder_config().unwrap().autonomy.enabled);- assert_eq!(handle.context().embedder_config().unwrap().memory.root.as_deref(), Some(format!("user:{user}").as_str()));- tokio::time::timeout(Duration::from_secs(30), handle.chat("t1", "call tenant_probe")).await.unwrap().unwrap();+ assert_eq!(+ handle+ .context()+ .embedder_config()+ .unwrap()+ .memory+ .root+ .as_deref(),+ Some(format!("user:{user}").as_str())+ );+ tokio::time::timeout(+ Duration::from_secs(30),+ handle.chat("t1", "call tenant_probe"),+ )+ .await+ .unwrap()+ .unwrap();handles.push(handle);}for handle in &handles {let mut events = handle.events();- let accepted = handle.relay_inbound(RelayMessage::new("telegram", "chat", "sender", "message", "call tenant_probe")).await.unwrap();+ let accepted = handle+ .relay_inbound(RelayMessage::new(+ "telegram",+ "chat",+ "sender",+ "message",+ "call tenant_probe",+ ))+ .await+ .unwrap();assert!(accepted.accepted);tokio::time::timeout(Duration::from_secs(30), async {loop {let event = events.recv().await.unwrap();- if event.event == "channel_outbound" { break; }+ if event.event == "channel_outbound" {+ break;+ }}- }).await.unwrap();+ })+ .await+ .unwrap();}- assert_eq!(*calls.lock().unwrap(), ["tenant_probe:alice", "tenant_probe:bob", "tenant_probe:alice", "tenant_probe:bob"]);+ assert_eq!(+ *calls.lock().unwrap(),+ [+ "tenant_probe:alice",+ "tenant_probe:bob",+ "tenant_probe:alice",+ "tenant_probe:bob"+ ]+ );for request in chat_requests(&inference).await {let mut names = tool_names(&request);names.sort();if !names.is_empty() {- assert_eq!(names, ["memory", "tenant_probe"], "the model sees the selected belt exactly");+ assert_eq!(+ names,+ ["memory", "tenant_probe"],+ "the model sees the selected belt exactly"+ );}}// Shared backend contents are independent of the actor: actual contract// requests, including a malicious global-root filter, must stay confined.for user in ["alice", "bob"] {- engine.store(StoreItem::learning(format!("{user}-secret"), LearningKind::Fact, 0.9, MemoryMeta { namespace: format!("user:{user}").parse().unwrap(), ..Default::default() })).await.unwrap();+ engine+ .store(StoreItem::learning(+ format!("{user}-secret"),+ LearningKind::Fact,+ 0.9,+ MemoryMeta {+ namespace: format!("user:{user}").parse().unwrap(),+ ..Default::default()+ },+ ))+ .await+ .unwrap();}for handle in &handles {- let response: Value = handle.call("openhuman.memory_items_list", json!({"filter":{"reach":{"at":"","descendants":true,"inherit":true}}})).await.unwrap();+ let response: Value = handle+ .call(+ "openhuman.memory_items_list",+ json!({"filter":{"reach":{"at":"","descendants":true,"inherit":true}}}),+ )+ .await+ .unwrap();let text = response.to_string();- assert!(text.contains(&format!("{}-secret", handle.id())), "{response}");- let other = if handle.id().as_str() == "alice" { "bob" } else { "alice" };+ assert!(+ text.contains(&format!("{}-secret", handle.id())),+ "{response}"+ );+ let other = if handle.id().as_str() == "alice" {+ "bob"+ } else {+ "alice"+ };assert!(!text.contains(&format!("{other}-secret")), "{response}");}runtime.shutdown().await;