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
chore(flows): apply rustfmt formatting and add caps host interface test
Steven Enamakel2b3bda6a2737
diff --git a/crates/openhuman-core/src/flows/agent_route_tests.rs b/crates/openhuman-core/src/flows/agent_route_tests.rsindex 18239fc7a5..d95f9561c3 100644--- a/crates/openhuman-core/src/flows/agent_route_tests.rs+++ b/crates/openhuman-core/src/flows/agent_route_tests.rs@@ -68,5 +68,8 @@ fn custom_agent_route_requires_an_enabled_registry_entry() {route_custom_entry_lookup(Some(&custom_registry_entry(false))),AgentRoute::RegistryFallback);- assert_eq!(route_custom_entry_lookup(None), AgentRoute::RegistryFallback);+ assert_eq!(+ route_custom_entry_lookup(None),+ AgentRoute::RegistryFallback+ );}diff --git a/crates/openhuman-core/src/flows/builder_host.rs b/crates/openhuman-core/src/flows/builder_host.rsindex 96723e8b99..63d0ad0624 100644--- a/crates/openhuman-core/src/flows/builder_host.rs+++ b/crates/openhuman-core/src/flows/builder_host.rs@@ -4,7 +4,7 @@ use std::future::Future;use std::sync::Arc;use serde::de::DeserializeOwned;-use serde_json::{json, Value};+use serde_json::{Value, json};use tinybus::Result as BusResult;use tinyflows_bus::copilot::{self, CopilotHost, PortOperation};diff --git a/crates/openhuman-core/src/flows/caps_host/binding.rs b/crates/openhuman-core/src/flows/caps_host/binding.rsindex 59cfcaa1af..f635ad0691 100644--- a/crates/openhuman-core/src/flows/caps_host/binding.rs+++ b/crates/openhuman-core/src/flows/caps_host/binding.rs@@ -96,8 +96,7 @@ impl AgentRunRegistry {cancellation,};self.by_handle.insert(entry.handle.clone(), state);- self.by_request_id- .insert(client_request_id, entry.clone());+ self.by_request_id.insert(client_request_id, entry.clone());Ok(AgentRunAdmission {entry,start_task: !cancelled_before_admission,diff --git a/crates/openhuman-core/src/flows/caps_host/binding_tests.rs b/crates/openhuman-core/src/flows/caps_host/binding_tests.rsindex 0371ea567e..39e597bf5b 100644--- a/crates/openhuman-core/src/flows/caps_host/binding_tests.rs+++ b/crates/openhuman-core/src/flows/caps_host/binding_tests.rs@@ -6,7 +6,7 @@ use crate::core::runtime::{ComponentSet, CoreContext, DispatchCtx, DomainSet};use std::sync::Arc;use tempfile::TempDir;-fn binding(ctx: DispatchCtx, temp: &TempDir) -> CapsHostBinding {+pub(super) fn binding(ctx: DispatchCtx, temp: &TempDir) -> CapsHostBinding {let config = Config {workspace_dir: temp.path().join("workspace"),action_dir: temp.path().join("workspace"),@@ -41,7 +41,11 @@ async fn callback_reenters_the_captured_context_instead_of_ambient_context() {CoreContext::scope(ambient, async {assert!(DispatchCtx::ambient().components().sandbox);- assert!(!binding.within(async { DispatchCtx::ambient().components().sandbox }).await);+ assert!(+ !binding+ .within(async { DispatchCtx::ambient().components().sandbox })+ .await+ );}).await;}diff --git a/crates/openhuman-core/src/flows/caps_host/mod.rs b/crates/openhuman-core/src/flows/caps_host/mod.rsindex 074dd90c82..01180da403 100644--- a/crates/openhuman-core/src/flows/caps_host/mod.rs+++ b/crates/openhuman-core/src/flows/caps_host/mod.rs@@ -16,8 +16,8 @@ pub(crate) mod tools;#[path = "binding_tests.rs"]mod binding_tests;-pub(crate) use binding::{CapsHostRegistration, serve};pub(crate) use agent::OpenHumanAgentRunner;+pub(crate) use binding::{CapsHostRegistration, serve};pub(crate) use code::OpenHumanCode;pub(crate) use error::{CapsError, EngineError, Result};pub(crate) use http::{OpenHumanHttp, resolve_http_credential};diff --git a/crates/openhuman-core/src/flows/caps_host/service.rs b/crates/openhuman-core/src/flows/caps_host/service.rsindex 9dd196f584..8536f7b877 100644--- a/crates/openhuman-core/src/flows/caps_host/service.rs+++ b/crates/openhuman-core/src/flows/caps_host/service.rs@@ -185,11 +185,7 @@ impl CapsHostService {.agent_runs.lock().await- .admit(- request.client_request_id.clone(),- state,- cancellation,- )+ .admit(request.client_request_id.clone(), state, cancellation).map_err(tinybus::Error::failed)?;if admission.cancelled_before_admission {let mut state = admission.entry.state.lock().await;@@ -213,10 +209,7 @@ impl CapsHostService {Ok(runs::AgentRunHandle { handle })}- async fn agent_cancel(- &self,- request: runs::AgentCancelRequest,- ) -> tinybus::Result<()> {+ async fn agent_cancel(&self, request: runs::AgentCancelRequest) -> tinybus::Result<()> {if !valid_agent_request_id(&request.client_request_id) {return Err(tinybus::Error::failed("AgentCancel requires a nonempty bounded client_request_id",diff --git a/crates/openhuman-core/src/flows/caps_host/service_agent.rs b/crates/openhuman-core/src/flows/caps_host/service_agent.rsindex 01c9b5ee29..9fb5ce03fd 100644--- a/crates/openhuman-core/src/flows/caps_host/service_agent.rs+++ b/crates/openhuman-core/src/flows/caps_host/service_agent.rs@@ -77,10 +77,10 @@ pub(crate) async fn run_agent(};let scope = Arc::clone(&binding);let turn = scope.within(async move {- runner- .run_agent(&agent_ref, config, connection.as_deref())- .await- });+ runner+ .run_agent(&agent_ref, config, connection.as_deref())+ .await+ });let result = tokio::select! {biased;_ = cancellation.cancelled() => Err("agent run was cancelled".to_owned()),diff --git a/crates/openhuman-core/src/flows/caps_host/service_tests.rs b/crates/openhuman-core/src/flows/caps_host/service_tests.rsindex fb0fa35578..0abee9fb4f 100644--- a/crates/openhuman-core/src/flows/caps_host/service_tests.rs+++ b/crates/openhuman-core/src/flows/caps_host/service_tests.rs@@ -2,6 +2,23 @@ use super::*;use super::super::binding::AgentRunRegistry;+#[test]+fn generated_caps_host_interface_members_match_the_v2_wire_contract() {+ let temp = tempfile::TempDir::new().unwrap();+ let binding =+ super::super::binding_tests::binding(crate::core::runtime::DispatchCtx::unbound(), &temp);+ let service = CapsHostService::new(Arc::new(binding));+ let actual: std::collections::HashSet<_> = tinybus::service::Interface::members(&service)+ .into_iter()+ .map(|member| member.to_string())+ .collect();+ let expected: std::collections::HashSet<_> = runs::CAPS_METHODS+ .iter()+ .map(|member| (*member).to_owned())+ .collect();+ assert_eq!(actual, expected);+}+fn state() -> Arc<tokio::sync::Mutex<super::super::agent::AgentRunState>> {Arc::new(tokio::sync::Mutex::new(super::super::agent::AgentRunState::default(),@@ -50,7 +67,11 @@ async fn duplicate_agent_run_request_returns_the_original_handle_without_restart.unwrap();let duplicate = registry- .admit("request-1".into(), state(), tokio_util::sync::CancellationToken::new())+ .admit(+ "request-1".into(),+ state(),+ tokio_util::sync::CancellationToken::new(),+ ).unwrap();assert!(first.start_task);diff --git a/crates/openhuman-core/src/flows/ops/inference_readiness.rs b/crates/openhuman-core/src/flows/ops/inference_readiness.rsindex 57bf82510c..3f85efbd31 100644--- a/crates/openhuman-core/src/flows/ops/inference_readiness.rs+++ b/crates/openhuman-core/src/flows/ops/inference_readiness.rs@@ -142,7 +142,11 @@ pub(super) async fn evaluate_inference_readiness(graph: &WorkflowGraph,) -> Option<InferenceReadinessEvaluation> {let mut roles = Vec::new();- for node in graph.nodes.iter().filter(|node| node.kind == NodeKind::Agent) {+ for node in graph+ .nodes+ .iter()+ .filter(|node| node.kind == NodeKind::Agent)+ {roles.push((node.id.clone(), agent_node_role(config, node).await));}let evaluation = crate::inference::readiness::evaluate(ctx, config, &roles).await?;diff --git a/crates/openhuman-core/src/modules/tinyflows.rs b/crates/openhuman-core/src/modules/tinyflows.rsindex 5e3d564848..37d9906454 100644--- a/crates/openhuman-core/src/modules/tinyflows.rs+++ b/crates/openhuman-core/src/modules/tinyflows.rs@@ -283,8 +283,7 @@ mod imp {.serve_at(object_path.clone(), object).await.map_err(|error| error.to_string())?;- if announces_caps_host- && let Err(error) = announce_caps_host_v2(&connection).await+ if announces_caps_host && let Err(error) = announce_caps_host_v2(&connection).await{let _ = connection.unserve(&object_path).await;return Err(error);diff --git a/crates/openhuman-core/src/modules/tinyflows_tests.rs b/crates/openhuman-core/src/modules/tinyflows_tests.rsindex 2e8dde9edf..c83d10399a 100644--- a/crates/openhuman-core/src/modules/tinyflows_tests.rs+++ b/crates/openhuman-core/src/modules/tinyflows_tests.rs@@ -296,7 +296,9 @@ async fn serving_caps_host_advertises_v2_without_replacing_other_peer_manifest_e.await.expect("manifest lookup succeeds").unwrap_or_else(|| tinybus::PeerManifest::new("openhuman-module-host"));- original.provides.retain(|item| item.interface != caps_interface);+ original+ .provides+ .retain(|item| item.interface != caps_interface);original.provides.push(tinybus::InterfaceVersion::provided(caps_interface.clone(),tinybus::Version::new(1, 0, 0),@@ -328,17 +330,26 @@ async fn serving_caps_host_advertises_v2_without_replacing_other_peer_manifest_e.provided(&caps_interface).expect("CapsHost is advertised");assert_eq!(caps_host.speaks, tinybus::Version::new(2, 0, 0));- assert!(announced- .provides- .iter()- .any(|item| item.interface.as_str() == "ai.tinyhumans.openhuman.TestPreserved"));+ assert!(+ announced+ .provides+ .iter()+ .any(|item| item.interface.as_str() == "ai.tinyhumans.openhuman.TestPreserved")+ );assert_eq!(announced.consumes, prior_consumes);let proxy = connection- .proxy(HOST_BUS_NAME, ®istration.0, tinyflows_bus::runs::CAPS_INTERFACE)+ .proxy(+ HOST_BUS_NAME,+ ®istration.0,+ tinyflows_bus::runs::CAPS_INTERFACE,+ ).expect("CapsHost proxy resolves");proxy- .call::<serde_json::Value>("AgentCancel", (serde_json::json!({"client_request_id":"probe"}),))+ .call::<serde_json::Value>(+ "AgentCancel",+ (serde_json::json!({"client_request_id":"probe"}),),+ ).await.expect("the advertised member is actually served");}