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(core): add runtime component registry
Steven Enamakel8066315e6380
diff --git a/crates/openhuman-core/src/core/all.rs b/crates/openhuman-core/src/core/all.rsindex fad5d9974d..8d8b7a049a 100644--- a/crates/openhuman-core/src/core/all.rs+++ b/crates/openhuman-core/src/core/all.rs@@ -1158,6 +1158,18 @@ pub async fn try_invoke_registered_rpc(// are indistinguishable from absent. Enforced HERE (dispatch), not in// schema/validation lookups, to avoid a validate/dispatch split.if !visible(grouped) {+ // A family a `[components]` switch removed answers with the typed+ // error so the UI and CLI can explain it; a family the host left+ // out stays indistinguishable from an unregistered method.+ if let Some(name) = crate::core::runtime::ComponentSet::component_for_group(grouped.group) {+ let off = crate::core::runtime::context::CoreContext::current()+ .map(|c| !c.components().enabled(name))+ .unwrap_or(false);+ if off {+ log::debug!("[rpc][component-gate] method '{method}' refused — component '{name}' disabled");+ return Some(Err(crate::core::runtime::components::component_disabled(name).encode()));+ }+ }log::debug!("[rpc][domain-gate] method '{method}' suppressed — group {:?} disabled or method \outside the user surface in the active scope",diff --git a/crates/openhuman-core/src/core/runtime/components.rs b/crates/openhuman-core/src/core/runtime/components.rsindex fec017b80c..0a2bb01c64 100644--- a/crates/openhuman-core/src/core/runtime/components.rs+++ b/crates/openhuman-core/src/core/runtime/components.rs@@ -72,23 +72,27 @@ impl ComponentSet {/// Whether the component named `name` is on. Unknown names are on: this is/// a narrowing set, and a name it does not know cannot have been switched off.pub fn enabled(&self, name: &str) -> bool {- let mut c = ComponentsConfig::default();- c.flows = self.flows;- c.memes = self.memes;- c.documents = self.documents;- c.search = self.search;- c.mcp = self.mcp;- c.connectors = self.connectors;- c.hosting = self.hosting;- c.juice = self.juice;- c.memory = self.memory;- c.wallet = self.wallet;- c.computer = self.computer;- c.sandbox = self.sandbox;- c.channels = self.channels;- c.skills = self.skills;- c.voice = self.voice;- c.get(name).unwrap_or(true)+ self.to_config().get(name).unwrap_or(true)+ }++ fn to_config(self) -> ComponentsConfig {+ ComponentsConfig {+ flows: self.flows,+ memes: self.memes,+ documents: self.documents,+ search: self.search,+ mcp: self.mcp,+ connectors: self.connectors,+ hosting: self.hosting,+ juice: self.juice,+ memory: self.memory,+ wallet: self.wallet,+ computer: self.computer,+ sandbox: self.sandbox,+ channels: self.channels,+ skills: self.skills,+ voice: self.voice,+ }}/// `Ok` when `name` is on, otherwise the typed `COMPONENT_DISABLED:<name>` error.diff --git a/crates/openhuman-core/src/core/runtime/components_tests.rs b/crates/openhuman-core/src/core/runtime/components_tests.rsnew file mode 100644index 0000000000..c6a9cc3187--- /dev/null+++ b/crates/openhuman-core/src/core/runtime/components_tests.rs@@ -0,0 +1,107 @@+use super::*;++fn off(name: &str) -> ComponentSet {+ let mut c = ComponentsConfig::default();+ assert!(c.set(name, false));+ ComponentSet::from_config(&c)+}++#[test]+fn all_on_changes_nothing() {+ let all = ComponentSet::all();+ assert_eq!(all.narrow_domains(DomainSet::full()), DomainSet::full());+ assert_eq!(all.narrow_services(ServiceSet::desktop()), ServiceSet::desktop());+ assert_eq!(all.narrow_tool_groups(ToolGroups::advertised()), ToolGroups::advertised());+}++#[test]+fn each_flag_removes_its_domain_members() {+ let full = DomainSet::full();+ assert!(!off("flows").narrow_domains(full).flows);+ assert!(!off("skills").narrow_domains(full).skills);+ assert!(!off("mcp").narrow_domains(full).mcp);+ assert!(!off("channels").narrow_domains(full).channels);+ assert!(!off("wallet").narrow_domains(full).web3);+ assert!(!off("voice").narrow_domains(full).voice);+ assert!(!off("memory").narrow_domains(full).memory);+ assert!(!off("connectors").narrow_domains(full).integrations);+ // Disabling one family leaves the others alone.+ let d = off("flows").narrow_domains(full);+ assert!(d.skills && d.mcp && d.agent);+}++#[test]+fn each_flag_removes_its_service_members() {+ let d = ServiceSet::desktop();+ assert!(!off("channels").narrow_services(d).channels);+ let m = off("memory").narrow_services(d);+ assert!(!m.memory_queue && !m.memory_sync);+ assert!(!off("skills").narrow_services(d).skill_catalog_refresh);+ assert!(!off("mcp").narrow_services(d).mcp_boot);+ assert!(!off("connectors").narrow_services(d).integrations);+ assert!(off("channels").narrow_services(d).cron);+}++#[test]+fn each_flag_turns_its_tool_groups_off() {+ let adv = ToolGroups::advertised();+ for (name, group) in [+ ("flows", "workflows"),+ ("documents", "documents"),+ ("mcp", "mcp"),+ ("connectors", "composio"),+ ("wallet", "web3"),+ ("skills", "skills"),+ ] {+ let g = off(name).narrow_tool_groups(adv.clone());+ assert_eq!(g.mode(group), GroupMode::Off, "{name} -> {group}");+ }+ let g = off("flows").narrow_tool_groups(adv);+ assert_eq!(g.mode("documents"), GroupMode::Advertised);+}++#[test]+fn config_cannot_widen_a_host_preset() {+ let all = ComponentSet::all();+ for preset in [DomainSet::harness(), DomainSet::kernel(), DomainSet::none(), DomainSet::embedded()] {+ assert_eq!(all.narrow_domains(preset), preset, "all-on must be identity");+ assert_eq!(all.narrow_domains(preset).intersect(&preset), preset);+ }+ // kernel has no flows/mcp/...; components being on must not add them.+ let k = all.narrow_domains(DomainSet::kernel());+ assert!(!k.flows && !k.mcp && !k.memory && !k.skills);+ // A tool-group host preset of `none` stays Off.+ let g = all.narrow_tool_groups(ToolGroups::none());+ assert_eq!(g.mode("workflows"), GroupMode::Off);+ // And headless services stay off.+ assert_eq!(all.narrow_services(ServiceSet::none()), ServiceSet::none());+ assert_eq!(all.narrow_services(ServiceSet::headless_api()), ServiceSet::headless_api());+}++#[test]+fn narrowing_never_raises_a_withheld_group() {+ let g = off("flows").narrow_tool_groups(ToolGroups::packed());+ assert_eq!(g.mode("workflows"), GroupMode::Off);+ assert_eq!(g.mode("documents"), GroupMode::Withheld);+}++#[test]+fn disabled_component_answers_a_typed_error() {+ let err = off("hosting").require("hosting").unwrap_err();+ assert_eq!(err.message, "COMPONENT_DISABLED:hosting");+ assert!(err.expected_user_state);+ assert_eq!(err.data.as_ref().unwrap()["component"], "hosting");+ let decoded = StructuredRpcError::decode(&err.encode()).unwrap();+ assert_eq!(decoded, err);+ assert!(ComponentSet::all().require("hosting").is_ok());+ assert!(ComponentSet::all().enabled("not-a-component"));+}++#[test]+fn group_to_component_mapping_names_real_components() {+ for g in DomainGroup::ALL {+ if let Some(n) = ComponentSet::component_for_group(*g) {+ assert!(COMPONENT_NAMES.contains(&n), "{n}");+ }+ }+}diff --git a/crates/openhuman-core/src/core/runtime/mod.rs b/crates/openhuman-core/src/core/runtime/mod.rsindex 77201aa748..c7a45db60b 100644--- a/crates/openhuman-core/src/core/runtime/mod.rs+++ b/crates/openhuman-core/src/core/runtime/mod.rs@@ -47,7 +47,7 @@ pub mod agent_scope;pub mod boot_guard;mod bootstrap;pub mod builder;-mod components;+pub mod components;pub use components::{ComponentSet, COMPONENT_NAMES};pub mod context;pub mod domain_set;