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 user agent surface module
Steven Enamakel639fde0b8d8b
diff --git a/crates/openhuman-core/src/core/all.rs b/crates/openhuman-core/src/core/all.rsindex 4ee8f4e8df..098ef79297 100644--- a/crates/openhuman-core/src/core/all.rs+++ b/crates/openhuman-core/src/core/all.rs@@ -922,7 +922,12 @@ pub fn rpc_method_from_parts(namespace: &str, function: &str) -> Option<String>let found = view.iter().find(|g| {- g.controller.schema.namespace == namespace && g.controller.schema.function == function+ g.controller.schema.namespace == namespace+ && g.controller.schema.function == function+ && crate::user_agents::surface::method_visible(+ &g.controller.rpc_method_name(),+ g.group == DomainGroup::Operator,+ )}).map(|g| g.controller.rpc_method_name());founddiff --git a/crates/openhuman-core/src/user_agents/surface.rs b/crates/openhuman-core/src/user_agents/surface.rsindex 3fd4ea09ed..f3b888d49c 100644--- a/crates/openhuman-core/src/user_agents/surface.rs+++ b/crates/openhuman-core/src/user_agents/surface.rs@@ -42,15 +42,31 @@ pub const USER_METHODS: &[&str] = &[/// Whether `method` (of an operator-plane controller or not) may be/// dispatched or listed in the current scope.pub fn method_visible(method: &str, operator_plane: bool) -> bool {- visible_in(- is_saas(),+ visible_in(is_saas(), current_scope(), method, operator_plane)+}++/// Who the current work runs for, in SaaS terms.+#[derive(Debug, Clone, Copy, PartialEq, Eq)]+pub enum Scope {+ /// No task scope at all.+ None,+ Operator,+ User,+}++/// The current task's scope. In SaaS only the task-local scope counts; a task+/// that lost it is [`Scope::None`], never the operator's default context.+pub fn current_scope() -> Scope {+ let ctx = if is_saas() {+ CoreContext::scoped()+ } else {CoreContext::current()- .as_deref()- .and_then(CoreContext::session_agent)- .is_some(),- method,- operator_plane,- )+ };+ match ctx {+ None => Scope::None,+ Some(ctx) if ctx.session_agent().is_some() => Scope::User,+ Some(_) => Scope::Operator,+ }}/// [`method_visible`] as a pure function of the mode and the scope.@@ -60,11 +76,14 @@ pub fn method_visible(method: &str, operator_plane: bool) -> bool {/// `DomainSet` registers the user families on the runtime so user contexts/// can derive them; this keeps the operator from serving them on its own/// workspace.-pub fn visible_in(saas: bool, user_scope: bool, method: &str, operator_plane: bool) -> bool {- match (saas, user_scope) {+///+/// A SaaS task with no scope sees nothing: missing scope fails closed.+pub fn visible_in(saas: bool, scope: Scope, method: &str, operator_plane: bool) -> bool {+ match (saas, scope) {(false, _) => true,- (true, false) => operator_plane,- (true, true) => !operator_plane && USER_METHODS.contains(&method),+ (true, Scope::None) => false,+ (true, Scope::Operator) => operator_plane,+ (true, Scope::User) => !operator_plane && USER_METHODS.contains(&method),}}@@ -90,11 +109,7 @@ pub fn validate_user_thread_id(id: &str) -> Result<(), String> {/// Whether the current work runs for a SaaS user.fn in_user_scope() -> bool {- is_saas()- && CoreContext::current()- .as_deref()- .and_then(CoreContext::session_agent)- .is_some()+ is_saas() && current_scope() == Scope::User}/// A SaaS user cannot pick a thread's working folder: their threads always