Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(core): gate component dispatch behind a components check

Steven Enamakele57c8bb94b25
diff --git a/crates/openhuman-core/src/core/all/components_gate.rs b/crates/openhuman-core/src/core/all/components_gate.rs
index f8ffb0a7e6..e5967c9d17 100644
--- a/crates/openhuman-core/src/core/all/components_gate.rs
+++ b/crates/openhuman-core/src/core/all/components_gate.rs
@@ -7,9 +7,12 @@
use super::{internal_registry, registry_view, visible};
/// `Some(component)` when `method` is registered but hidden because its
-/// component is switched off in the ambient scope. Dispatch asks this before
+/// component is switched off for `dispatch`. Dispatch asks this before
/// reporting an unknown method.
-pub fn disabled_component_for_method(method: &str) -> Option<&'static str> {
+pub fn disabled_component_for_method(
+ dispatch: &crate::core::runtime::DispatchCtx,
+ method: &str,
+) -> Option<&'static str> {
let view = registry_view();
let grouped = view
.iter()
@@ -19,8 +22,7 @@ pub fn disabled_component_for_method(method: &str) -> Option<&'static str> {
return None;
}
let name = crate::core::runtime::ComponentSet::component_for_group(grouped.group)?;
- let ctx = crate::core::runtime::context::CoreContext::current()?;
- if ctx.components().enabled(name) {
+ if dispatch.components().enabled(name) {
return None;
}
log::debug!("[rpc][component-gate] method '{method}' refused, component '{name}' disabled");
diff --git a/crates/openhuman-core/src/core/dispatch.rs b/crates/openhuman-core/src/core/dispatch.rs
index 5ec70c15fc..c7512c87da 100644
--- a/crates/openhuman-core/src/core/dispatch.rs
+++ b/crates/openhuman-core/src/core/dispatch.rs
@@ -239,7 +239,7 @@ async fn try_registry_dispatch(
let Some(schema) = crate::core::all::schema_for_rpc_method(method) else {
// Hidden because a `[components]` switch is off: say so, rather than
// reporting a method that exists as unknown.
- return crate::core::all::disabled_component_for_method(method)
+ return crate::core::all::disabled_component_for_method(&ctx, method)
.map(|name| Err(crate::core::runtime::components::component_disabled(name).encode()));
};
let params_obj = match params_to_object(params) {