Skip to content

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

feat(user_agents): gate user-agent RPCs by user surface

Steven Enamakel84a02e69d00c
diff --git a/crates/openhuman-core/src/core/all.rs b/crates/openhuman-core/src/core/all.rs
index 5a7553ca56..720027a12c 100644
--- a/crates/openhuman-core/src/core/all.rs
+++ b/crates/openhuman-core/src/core/all.rs
@@ -86,6 +86,13 @@ fn group_allowed(group: DomainGroup) -> bool {
active_domain_set().is_none_or(|s| s.allows(group))
}
+/// Whether `g` is live in the ambient scope: its family is enabled and, for a
+/// SaaS user, the method is on the user surface (`user_agents::surface`).
+fn visible(g: &GroupedController) -> bool {
+ group_allowed(g.group)
+ && crate::user_agents::surface::method_visible(&g.controller.rpc_method_name())
+}
+
/// The global static registry of all controllers, initialized once on first access.
static REGISTRY: OnceLock<Vec<GroupedController>> = OnceLock::new();
@@ -769,7 +776,7 @@ pub fn all_registered_controllers() -> Vec<RegisteredController> {
fn registered_controllers(view: &RegistryView) -> Vec<RegisteredController> {
let found = view
.iter()
- .filter(|g| group_allowed(g.group))
+ .filter(|g| visible(g))
.map(|g| g.controller.clone())
.collect();
found
@@ -788,7 +795,7 @@ pub fn all_controller_schemas() -> Vec<ControllerSchema> {
fn controller_schemas(view: &RegistryView) -> Vec<ControllerSchema> {
view.iter()
- .filter(|g| group_allowed(g.group))
+ .filter(|g| visible(g))
.map(|g| g.controller.schema.clone())
.collect()
}
@@ -1172,9 +1179,10 @@ pub async fn try_invoke_registered_rpc(
// gets for a genuinely-unregistered method, so a gated domain's controllers
// are indistinguishable from absent. Enforced HERE (dispatch), not in
// schema/validation lookups, to avoid a validate/dispatch split.
- if !group_allowed(grouped.group) {
+ if !visible(grouped) {
log::debug!(
- "[rpc][domain-gate] method '{method}' suppressed — group {:?} disabled under active DomainSet",
+ "[rpc][domain-gate] method '{method}' suppressed — group {:?} disabled or method \
+ outside the user surface in the active scope",
grouped.group
);
return None;
diff --git a/crates/openhuman-core/src/user_agents/host.rs b/crates/openhuman-core/src/user_agents/host.rs
index c0b755a001..a0740ac138 100644
--- a/crates/openhuman-core/src/user_agents/host.rs
+++ b/crates/openhuman-core/src/user_agents/host.rs
@@ -64,10 +64,13 @@ impl std::fmt::Debug for AgentHost {
}
}
-/// The domain families a user agent's context serves. None yet: each family
-/// opens once its per-user isolation lands.
+/// The domain families a user agent's context serves. Within them, only the
+/// methods on [`USER_METHODS`](super::surface::USER_METHODS) are reachable.
pub fn user_domains() -> DomainSet {
- DomainSet::none()
+ DomainSet {
+ threads: true,
+ ..DomainSet::none()
+ }
}
impl AgentHost {
diff --git a/crates/openhuman-core/src/user_agents/mod.rs b/crates/openhuman-core/src/user_agents/mod.rs
index ede162c128..9b4262f989 100644
--- a/crates/openhuman-core/src/user_agents/mod.rs
+++ b/crates/openhuman-core/src/user_agents/mod.rs
@@ -20,6 +20,7 @@ pub mod host;
pub mod layout;
pub mod ops;
pub mod schemas;
+pub mod surface;
pub mod types;
pub use host::{current, AgentHost, UserAgentState};