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 and module schemas
Steven Enamakeld0027c42c39e
diff --git a/crates/openhuman-core/src/core/runtime/components.rs b/crates/openhuman-core/src/core/runtime/components.rsindex 0a2bb01c64..3c8eca18ec 100644--- a/crates/openhuman-core/src/core/runtime/components.rs+++ b/crates/openhuman-core/src/core/runtime/components.rs@@ -184,6 +184,21 @@ pub fn component_disabled(name: &str) -> StructuredRpcError {}}+/// Refuse an RPC handler with the encoded `COMPONENT_DISABLED:<name>` error+/// when the config it loaded has `name` switched off. For handlers that load+/// their own config and so cannot read the ambient scope.+pub fn require_config(+ config: &crate::config::Config,+ name: &str,+) -> Result<(), String> {+ if config.components.get(name).unwrap_or(true) {+ Ok(())+ } else {+ log::debug!("[rpc][component-gate] refused, component '{name}' disabled");+ Err(component_disabled(name).encode())+ }+}+#[cfg(test)]#[path = "components_tests.rs"]mod tests;diff --git a/crates/openhuman-core/src/desktop/control/schemas.rs b/crates/openhuman-core/src/desktop/control/schemas.rsindex b3bdf9e47b..530b76ddb0 100644--- a/crates/openhuman-core/src/desktop/control/schemas.rs+++ b/crates/openhuman-core/src/desktop/control/schemas.rs@@ -80,6 +80,7 @@ fn status(_: Map<String, Value>) -> ControllerFuture {let config = crate::config::rpc::load_config_with_timeout().await.map_err(|error| format!("config unavailable: {error}"))?;+ crate::core::runtime::components::require_config(&config, "computer")?;serde_json::to_value(super::ops::status(&config).await).map_err(|error| error.to_string())})}@@ -93,6 +94,7 @@ fn set_enabled(params: Map<String, Value>) -> ControllerFuture {let config = crate::config::rpc::load_config_with_timeout().await.map_err(|error| format!("config unavailable: {error}"))?;+ crate::core::runtime::components::require_config(&config, "computer")?;let result = super::ops::set_enabled(&config, value).await?;serde_json::to_value(result).map_err(|error| error.to_string())})@@ -103,6 +105,7 @@ fn probe(_: Map<String, Value>) -> ControllerFuture {let config = crate::config::rpc::load_config_with_timeout().await.map_err(|error| format!("config unavailable: {error}"))?;+ crate::core::runtime::components::require_config(&config, "computer")?;serde_json::to_value(super::ops::probe(&config).await).map_err(|error| error.to_string())})}@@ -127,6 +130,7 @@ fn confirm(params: Map<String, Value>) -> ControllerFuture {let config = crate::config::rpc::load_config_with_timeout().await.map_err(|error| format!("config unavailable: {error}"))?;+ crate::core::runtime::components::require_config(&config, "computer")?;super::confirmation::confirm(&config, id, approve).await})}diff --git a/crates/openhuman-core/src/modules/schemas.rs b/crates/openhuman-core/src/modules/schemas.rsindex c862a947cd..795bef7143 100644--- a/crates/openhuman-core/src/modules/schemas.rs+++ b/crates/openhuman-core/src/modules/schemas.rs@@ -202,6 +202,7 @@ fn readiness_error(detail: &str) -> String {fn handle_browser_check_readiness(_params: Map<String, Value>) -> ControllerFuture {Box::pin(async move {let mut config = config_rpc::load_config_with_timeout().await?;+ crate::core::runtime::components::require_config(&config, "computer")?;// The probe never navigates. Give its disposable session a non-routable// origin so an empty website allowlist does not prevent a Chrome check.config.http_request.allowed_domains = vec!["example.invalid".into()];@@ -251,6 +252,7 @@ fn handle_browser_forget_sites(params: Map<String, Value>) -> ControllerFuture {}};let config = config_rpc::load_config_with_timeout().await?;+ crate::core::runtime::components::require_config(&config, "computer")?;let forgotten = super::browser_sites::forget(&config, site.as_deref()).await.map_err(|error| format!("could not forget learned site data: {error}"))?;@@ -267,6 +269,7 @@ fn handle_computer_status(params: Map<String, Value>) -> ControllerFuture {Box::pin(async move {let load = params.get("load").and_then(Value::as_bool).unwrap_or(false);let config = config_rpc::load_config_with_timeout().await?;+ crate::core::runtime::components::require_config(&config, "computer")?;controller_value(super::computer::status(&config, load).await)})}