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(hosted): register hosted RPC controllers as a core extension
Steven Enamakele18c9e07aa64
diff --git a/crates/openhuman-tinyhumans/src/hosted/mod.rs b/crates/openhuman-tinyhumans/src/hosted/mod.rsindex a9d89316b0..73db5af0a9 100644--- a/crates/openhuman-tinyhumans/src/hosted/mod.rs+++ b/crates/openhuman-tinyhumans/src/hosted/mod.rs@@ -2,8 +2,11 @@//!//! Every domain here is a thin proxy to `tinyhumansai/backend` — the truth lives//! server-side and this side only authenticates, forwards, and shapes results.-//! A self-hosted or embedded build that never dials the managed backend drops-//! them together, which is why they are one family.+//! They live in this crate, not the core, because a core without a TinyHumans+//! connection has no use for them: [`extension`] hands them to the core's+//! controller registry (`DomainGroup::Hosted`) when [`crate::install`] runs,+//! and the RPC names (`openhuman.billing_*`, `team_*`, `referral_*`,+//! `announcements_*`) are unchanged wire contracts.//!//! - [`announcements`] — product announcements feed//! - [`billing`] — credits, plans, Stripe/Coinbase-backed balance reads@@ -15,3 +18,39 @@ pub mod announcements;pub mod billing;pub mod referral;pub mod team;++use openhuman_core::core::all::{ControllerExtension, DomainGroup};++/// Namespace descriptions the core's `namespace_description` serves for the+/// hosted RPC surface.+pub const NAMESPACES: &[(&str, &str)] = &[+ (+ "billing",+ "Subscription plan, payment links, and credit top-up via the backend.",+ ),+ (+ "team",+ "Team member management, invites, and role changes via the backend.",+ ),+ (+ "referral",+ "Referral codes, stats, and apply flows via the hosted backend API.",+ ),+ (+ "announcements",+ "Latest active product announcement surfaced on harness init, via the backend.",+ ),+];++/// The hosted controllers as one registry extension.+pub fn extension() -> ControllerExtension {+ let mut controllers = referral::all_referral_registered_controllers();+ controllers.extend(billing::all_billing_registered_controllers());+ controllers.extend(announcements::all_announcements_registered_controllers());+ controllers.extend(team::all_team_registered_controllers());+ ControllerExtension {+ group: DomainGroup::Hosted,+ controllers,+ namespaces: NAMESPACES,+ }+}diff --git a/crates/openhuman-tinyhumans/src/install.rs b/crates/openhuman-tinyhumans/src/install.rsindex a8c35cc986..37c4272cde 100644--- a/crates/openhuman-tinyhumans/src/install.rs+++ b/crates/openhuman-tinyhumans/src/install.rs@@ -10,18 +10,34 @@use std::sync::{Arc, Mutex, OnceLock};use openhuman_core::api::transport::{install_backend_transport, installed_backend_transport};+use openhuman_core::core::all::register_controller_extension;use openhuman_core::api::{set_product_identity, ProductIdentity};use crate::transport::SdkBackendTransport;/// What [`install`] sets up.-#[derive(Debug, Default, Clone)]+#[derive(Debug, Clone)]pub struct InstallOptions {/// The `x-sdk-name` this process reports on every backend request. `None`/// keeps whatever identity is already set (the core's default is/// `"openhuman"`). Set it here, before the transport is built, because the/// transport captures the attribution headers once.pub product_identity: Option<ProductIdentity>,+ /// Register the hosted-backend RPC proxies (`billing`, `team`, `referral`,+ /// `announcements`) with the core's controller registry. Default `true`;+ /// a host whose `DomainSet` excludes `hosted` may leave it on — the group+ /// gate hides them — or turn it off to keep them out of the registry+ /// entirely.+ pub hosted_controllers: bool,+}++impl Default for InstallOptions {+ fn default() -> Self {+ Self {+ product_identity: None,+ hosted_controllers: true,+ }+ }}impl InstallOptions {@@ -30,6 +46,12 @@ impl InstallOptions {self.product_identity = Some(identity);self}++ /// Whether to register the hosted RPC proxies (default `true`).+ pub fn hosted_controllers(mut self, enabled: bool) -> Self {+ self.hosted_controllers = enabled;+ self+ }}/// Why [`install`] could not set the process up.@@ -38,6 +60,9 @@ pub enum InstallError {/// The SDK transport's HTTP client could not be built.#[error("failed to build the TinyHumans backend transport: {0:#}")]Transport(anyhow::Error),+ /// The hosted controllers collided with the core's registry.+ #[error("failed to register the hosted RPC controllers: {0}")]+ Registry(String),}static INSTALLED: OnceLock<Mutex<Option<Arc<SdkBackendTransport>>>> = OnceLock::new();@@ -63,6 +88,12 @@ pub fn install(options: InstallOptions) -> Result<Arc<SdkBackendTransport>, Inst*guard = None;}+ if options.hosted_controllers {+ // Idempotent in the core: an identical re-registration is a no-op.+ register_controller_extension(crate::hosted::extension())+ .map_err(InstallError::Registry)?;+ }+if let Some(existing) = guard.as_ref() {// Re-install into the core slot in case something cleared it (tests).if installed_backend_transport().is_none() {diff --git a/crates/openhuman-tinyhumans/src/lib.rs b/crates/openhuman-tinyhumans/src/lib.rsindex 4012b3a43c..47928555fd 100644--- a/crates/openhuman-tinyhumans/src/lib.rs+++ b/crates/openhuman-tinyhumans/src/lib.rs@@ -9,7 +9,9 @@//! - **this crate** implements the port with the vendored `tinyhumans-sdk`//! ([`SdkBackendTransport`]), installs it into a process ([`install`]),//! offers a [`RuntimeBuilder`] that boots an embed runtime already-//! connected, and owns the host-side **login and backend session**+//! connected, registers the hosted-backend RPC proxies ([`hosted`]:+//! billing, team, referral, announcements) with the core's controller+//! registry, and owns the host-side **login and backend session**//! ([`session`]: [`SessionManager`], [`SessionClient`], [`CoreLink`]) — the//! core only ever *takes* a credential.//!@@ -34,12 +36,14 @@pub use openhuman_embed as embed;+pub mod hosted;mod install;pub mod jwt;mod runtime;pub mod session;pub mod transport;+pub use hosted::extension as hosted_controllers;pub use install::{install, is_installed, InstallError, InstallOptions};pub use openhuman_embed::{BackendRequest, BackendTransport, BackendTransportError, TransportProfile,diff --git a/crates/openhuman-tinyhumans/src/runtime.rs b/crates/openhuman-tinyhumans/src/runtime.rsindex a8fba3ee84..b0feaf8e59 100644--- a/crates/openhuman-tinyhumans/src/runtime.rs+++ b/crates/openhuman-tinyhumans/src/runtime.rs@@ -52,6 +52,13 @@ impl RuntimeBuilder {self}+ /// Whether the hosted RPC proxies (`billing`, `team`, …) are registered+ /// (default `true`; the runtime's `DomainSet` still gates them).+ pub fn hosted_controllers(mut self, enabled: bool) -> Self {+ self.install.hosted_controllers = enabled;+ self+ }+/// See [`openhuman_embed::RuntimeBuilder::workspace`].pub fn workspace(mut self, workspace: Workspace) -> Self {self.inner = self.inner.workspace(workspace);