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 component config schema and env overlay
Steven Enamakelc09f87576658
diff --git a/crates/openhuman-core/src/config/schema/components.rs b/crates/openhuman-core/src/config/schema/components.rsnew file mode 100644index 0000000000..86bb7bad6a--- /dev/null+++ b/crates/openhuman-core/src/config/schema/components.rs@@ -0,0 +1,163 @@+//! `[components]` — which tiny dependencies this core uses.+//!+//! One `bool` per dependency, all on by default. The set only *narrows*: it is+//! resolved into a [`ComponentSet`](crate::core::runtime::ComponentSet) that is+//! intersected with whatever the host chose (`DomainSet`, `ServiceSet`,+//! `ToolGroups`), so a switch here can never enable something the host left+//! out. There are no Cargo gates behind these; a disabled component is still+//! compiled in, just unused.+//!+//! Changing a switch takes effect on the next core start; there is no hot+//! toggling. The kernel dependencies (tinyagents, tinytools, tinyinference,+//! tinybus) are not toggleable, and `[modules] enabled` stays the global kill+//! switch for loadable modules.+//!+//! Each switch also reads `OPENHUMAN_COMPONENT_<NAME>=0|1`.++use schemars::JsonSchema;+use serde::{Deserialize, Serialize};++use super::defaults::default_true;++/// Names of every toggleable component, in declaration order.+pub const COMPONENT_NAMES: [&str; 15] = [+ "flows",+ "memes",+ "documents",+ "search",+ "mcp",+ "connectors",+ "hosting",+ "juice",+ "memory",+ "wallet",+ "computer",+ "sandbox",+ "channels",+ "skills",+ "voice",+];++#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]+#[serde(default)]+pub struct ComponentsConfig {+ /// Saved workflows (tinyflows).+ #[serde(default = "default_true")]+ pub flows: bool,+ /// Meme remixing (tinymemes).+ #[serde(default = "default_true")]+ pub memes: bool,+ /// Document extraction and generation (tinydocs).+ #[serde(default = "default_true")]+ pub documents: bool,+ /// Web search (tinysearch).+ #[serde(default = "default_true")]+ pub search: bool,+ /// MCP client (tinymcp).+ #[serde(default = "default_true")]+ pub mcp: bool,+ /// OAuth connectors (tinyconnectors).+ #[serde(default = "default_true")]+ pub connectors: bool,+ /// Hosting providers (tinyhosts).+ #[serde(default = "default_true")]+ pub hosting: bool,+ /// Tool-output compression (tinyjuice).+ #[serde(default = "default_true")]+ pub juice: bool,+ /// Memory engine (tinymemory).+ #[serde(default = "default_true")]+ pub memory: bool,+ /// Wallet, web3 and x402 payments (tinywallet).+ #[serde(default = "default_true")]+ pub wallet: bool,+ /// Computer use (tinycomputer).+ #[serde(default = "default_true")]+ pub computer: bool,+ /// Isolated execution (tinybox).+ #[serde(default = "default_true")]+ pub sandbox: bool,+ /// Messaging channels (tinychannels).+ #[serde(default = "default_true")]+ pub channels: bool,+ /// Skill bundles (tinyskills).+ #[serde(default = "default_true")]+ pub skills: bool,+ /// Voice (tinyvoice).+ #[serde(default = "default_true")]+ pub voice: bool,+}++impl Default for ComponentsConfig {+ fn default() -> Self {+ Self {+ flows: true,+ memes: true,+ documents: true,+ search: true,+ mcp: true,+ connectors: true,+ hosting: true,+ juice: true,+ memory: true,+ wallet: true,+ computer: true,+ sandbox: true,+ channels: true,+ skills: true,+ voice: true,+ }+ }+}++impl ComponentsConfig {+ /// The switch named `name`, or `None` for an unknown component.+ pub fn get(&self, name: &str) -> Option<bool> {+ Some(match name {+ "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,+ _ => return None,+ })+ }++ /// Set the switch named `name`; returns `false` for an unknown component.+ pub fn set(&mut self, name: &str, value: bool) -> bool {+ let slot = match name {+ "flows" => &mut self.flows,+ "memes" => &mut self.memes,+ "documents" => &mut self.documents,+ "search" => &mut self.search,+ "mcp" => &mut self.mcp,+ "connectors" => &mut self.connectors,+ "hosting" => &mut self.hosting,+ "juice" => &mut self.juice,+ "memory" => &mut self.memory,+ "wallet" => &mut self.wallet,+ "computer" => &mut self.computer,+ "sandbox" => &mut self.sandbox,+ "channels" => &mut self.channels,+ "skills" => &mut self.skills,+ "voice" => &mut self.voice,+ _ => return false,+ };+ *slot = value;+ true+ }+}++#[cfg(test)]+#[path = "components_tests.rs"]+mod tests;diff --git a/crates/openhuman-core/src/config/schema/components_tests.rs b/crates/openhuman-core/src/config/schema/components_tests.rsnew file mode 100644index 0000000000..cffd0c87ca--- /dev/null+++ b/crates/openhuman-core/src/config/schema/components_tests.rs@@ -0,0 +1,44 @@+use super::*;++#[test]+fn every_component_defaults_on() {+ let c = ComponentsConfig::default();+ for name in COMPONENT_NAMES {+ assert_eq!(c.get(name), Some(true), "{name} must default on");+ }+}++#[test]+fn empty_and_partial_tables_fill_defaults() {+ let c: ComponentsConfig = toml::from_str("").unwrap();+ assert_eq!(c, ComponentsConfig::default());+ let c: ComponentsConfig = toml::from_str("flows = false").unwrap();+ assert!(!c.flows);+ assert!(c.memory && c.voice);+}++#[test]+fn get_and_set_cover_every_name_and_reject_unknown() {+ let mut c = ComponentsConfig::default();+ for name in COMPONENT_NAMES {+ assert!(c.set(name, false), "{name}");+ assert_eq!(c.get(name), Some(false));+ }+ assert!(!c.set("nope", false));+ assert_eq!(c.get("nope"), None);+}++#[test]+fn roundtrips_through_toml() {+ let mut c = ComponentsConfig::default();+ c.hosting = false;+ let text = toml::to_string(&c).unwrap();+ assert_eq!(toml::from_str::<ComponentsConfig>(&text).unwrap(), c);+}++#[test]+fn config_carries_components_table() {+ let cfg: crate::config::Config = toml::from_str("[components]\nmcp = false\n").unwrap();+ assert!(!cfg.components.mcp);+ assert!(cfg.components.flows);+}diff --git a/crates/openhuman-core/src/config/schema/load/env_overlay/components.rs b/crates/openhuman-core/src/config/schema/load/env_overlay/components.rsnew file mode 100644index 0000000000..ab31f8f3cf--- /dev/null+++ b/crates/openhuman-core/src/config/schema/load/env_overlay/components.rs@@ -0,0 +1,30 @@+//! Env overrides for `[components]`: `OPENHUMAN_COMPONENT_<NAME>=0|1`.++use crate::config::schema::components::COMPONENT_NAMES;+use crate::config::schema::load::env::EnvLookup;+use crate::config::schema::Config;++/// Parse a `0|1|true|false|on|off|yes|no` flag; `None` for anything else.+pub(crate) fn parse_flag(raw: &str) -> Option<bool> {+ match raw.trim().to_ascii_lowercase().as_str() {+ "1" | "true" | "on" | "yes" => Some(true),+ "0" | "false" | "off" | "no" => Some(false),+ _ => None,+ }+}++impl Config {+ pub(super) fn apply_components_env<E: EnvLookup + ?Sized>(&mut self, env: &E) {+ for name in COMPONENT_NAMES {+ let key = format!("OPENHUMAN_COMPONENT_{}", name.to_ascii_uppercase());+ let Some(raw) = env.get(&key) else { continue };+ match parse_flag(&raw) {+ Some(value) => {+ tracing::debug!("[components] env override {key}={value}");+ self.components.set(name, value);+ }+ None => tracing::warn!("[components] ignoring invalid {key} (use 0 or 1)"),+ }+ }+ }+}