Skip to content

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

Merge upstream/main into saas-profiles (carry tenant changes into profiles/)

Steven Enamakel536290a1cd35
diff --cc crates/openhuman-core/src/core/runtime/README.md
index a52fc97b53,d9af8f12f1..16543028b9
--- a/crates/openhuman-core/src/core/runtime/README.md
+++ b/crates/openhuman-core/src/core/runtime/README.md
@@@ -172,17 -172,16 +172,17 @@@ through `runtime/saas.rs`
bearer is the RPC token.
The SaaS presets are closed. `DomainSet::saas()` registers the operator plane
-(`DomainGroup::Operator`, the `user_agents.*` controllers) and the user
+(`DomainGroup::Operator`, the `profiles.*` controllers) and the user
families whose per-user isolation has landed (threads, channels for web chat,
-memory). `user_agents::surface`
+memory). `profiles::surface`
keeps the two planes apart: the operator scope reaches only the operator
plane, and a user's scope only the reviewed `USER_METHODS`.
-`saas::build` installs the process's `user_agents::AgentHost`. Each open user
-agent runs under a context derived from the operator's, with its own forced
-config and `session_agent` (see `user_agents/README.md`).
+`saas::build` installs the process's `profiles::ProfileHost`. Each open
+profile (`<root>/users/<profile-id>/`, the desktop's user layout) runs under a
+context derived from the operator's, with its own forced config and
+`session_agent` (see `profiles/README.md`).
- Two guards keep SaaS work from falling back to process-wide state:
+ Three guards keep SaaS work from falling back to process-wide state:
- **Config redirect.** In SaaS, `Config::load_or_init()` returns the config the
current context carries and fails outside any context
diff --cc crates/openhuman-core/src/profiles/host.rs
index 24698770be,d41a022edc..20ea3f62e3
--- a/crates/openhuman-core/src/profiles/host.rs
+++ b/crates/openhuman-core/src/profiles/host.rs
@@@ -127,18 -129,18 +127,18 @@@ impl ProfileHost
Ok(true)
}
- /// Close agent `id` and archive its state under `<root>/deprovisioned/`.
- /// Nothing is deleted. Returns whether there was such an agent.
+ /// Close profile `id` and archive its state under `<root>/deprovisioned/`.
+ /// Nothing is deleted. Returns whether there was such a profile.
///
- /// The open-agent lock is held for the whole operation, so no `open` can
- /// re-open the agent between closing it and moving its directory. An
- /// agent still in use (a request holds its state) is not archived from
+ /// The open-profile lock is held for the whole operation, so no `open` can
+ /// re-open the profile between closing it and moving its directory. An
+ /// profile still in use (a request holds its state) is not archived from
/// under it: deprovisioning fails and can be retried.
- pub fn deprovision(&self, id: &UserAgentId) -> Result<bool, String> {
+ pub fn deprovision(&self, id: &ProfileId) -> Result<bool, String> {
let mut open = self.lock();
if let Some(slot) = open.get(id) {
- if Arc::strong_count(&slot.state) > 1 {
+ if in_use(slot) {
- return Err(format!("agent {id} is in use; try again shortly"));
+ return Err(format!("profile {id} is in use; try again shortly"));
}
}
open.remove(id);
@@@ -219,9 -218,12 +219,12 @@@
let context = self.operator.derive_with(
ContextOverlay::new(config.clone(), user_domains(), ToolGroups::none())
.without_user_skill_roots()
- .session_agent(id.as_str()),
+ .session_agent(id.as_str())
+ .profile(id.as_str())
+ .agent_policy(profile_policy(&config)),
);
+ crate::platform::cost::seed_tenant_tracker(&context, &config);
- let state = Arc::new(UserAgentState {
+ let state = Arc::new(Profile {
id: id.clone(),
layout,
config,
@@@ -303,24 -305,22 +306,22 @@@
self.evict_locked(&mut open, Instant::now());
}
- /// Close agents idle past `idle_evict_secs` that nothing is using.
- fn sweep_idle_locked(&self, open: &mut HashMap<UserAgentId, Slot>, now: Instant) {
+ /// Close profiles idle past `idle_evict_secs` that nothing is using.
+ fn sweep_idle_locked(&self, open: &mut HashMap<ProfileId, Slot>, now: Instant) {
let idle_limit = Duration::from_secs(self.saas.idle_evict_secs);
open.retain(|id, slot| {
- let keep = Arc::strong_count(&slot.state) > 1
- || now.duration_since(slot.last_used) < idle_limit;
+ let keep = in_use(slot) || now.duration_since(slot.last_used) < idle_limit;
if !keep {
- log::debug!("[user_agents] evicted idle agent={id}");
+ log::debug!("[profiles] evicted idle profile={id}");
}
keep
});
}
- fn evict_locked(&self, open: &mut HashMap<UserAgentId, Slot>, now: Instant) {
+ fn evict_locked(&self, open: &mut HashMap<ProfileId, Slot>, now: Instant) {
- let in_use = |slot: &Slot| Arc::strong_count(&slot.state) > 1;
self.sweep_idle_locked(open, now);
// Still full: make room by closing the least recently used idle one.
- if open.len() >= self.saas.max_agents_open.max(1) {
+ if open.len() >= self.saas.max_profiles_open.max(1) {
let victim = open
.iter()
.filter(|(_, slot)| !in_use(slot))
@@@ -338,11 -338,31 +339,31 @@@
}
}
-/// Whether anything still uses an open agent: a request holding its state,
++/// Whether anything still uses an open profile: a request holding its state,
+ /// or a turn still running on its context (a detached turn outlives the
+ /// request that started it).
+ fn in_use(slot: &Slot) -> bool {
+ Arc::strong_count(&slot.state) > 1 || slot.state.context.tenant_in_use()
+ }
+
-/// The security policy agent work is gated by: its own forced autonomy over
++/// The security policy profile work is gated by: its own forced autonomy over
+ /// its workspace and sandbox, never the operator's live policy.
+ fn profile_policy(config: &Config) -> Arc<crate::security::SecurityPolicy> {
+ Arc::new(
+ crate::security::SecurityPolicy::from_config(
+ &config.autonomy,
+ &config.workspace_dir,
+ &config.action_dir,
+ )
+ .with_privacy_mode(config.privacy.mode),
+ )
+ }
+
-/// Settle what a previous process left in agent `id`'s workspace: turns that
+/// Settle what a previous process left in profile `id`'s workspace: turns that
/// were mid-flight become interrupted and run-ledger rows left running are
-/// closed. The sweep a single-user core runs at boot, run per agent on its
-/// first open in this process. Failures are logged; the agent still opens.
-pub(crate) fn recover_workspace(id: &UserAgentId, workspace_dir: &std::path::Path) {
+/// closed. The sweep a single-user core runs at boot, run per profile on its
+/// first open in this process. Failures are logged; the profile still opens.
+pub(crate) fn recover_workspace(id: &ProfileId, workspace_dir: &std::path::Path) {
let now = chrono::Utc::now().to_rfc3339();
match tinyagents_session::turn_state::store::mark_all_interrupted(
workspace_dir.to_path_buf(),
@@@ -374,10 -394,10 +395,10 @@@ pub fn host() -> Option<Arc<ProfileHost
HOST.get().cloned()
}
-/// The user agent the current work runs for, if any.
-pub fn current() -> Option<Arc<UserAgentState>> {
+/// The profile the current work runs for, if any.
+pub fn current() -> Option<Arc<Profile>> {
- let profile = CoreContext::current()?.session_agent()?.to_owned();
+ let profile = crate::core::runtime::current_tenant().ok()?.profile?;
- let id = UserAgentId::parse(&profile).ok()?;
+ let id = ProfileId::parse(&profile).ok()?;
host()?.get(&id)
}
diff --cc crates/openhuman-core/src/profiles/host_tests.rs
index 5a1111e2db,1da470faa1..3db5bc1499
--- a/crates/openhuman-core/src/profiles/host_tests.rs
+++ b/crates/openhuman-core/src/profiles/host_tests.rs
@@@ -255,5 -259,60 +255,60 @@@ fn a_provisioned_config_needs_no_profil
let _held = host.open(&a).unwrap();
assert!(host.open(&b).is_err(), "the only slot is taken");
assert!(host.provisioned_config(&b).is_ok());
- assert!(host.provisioned_config(&agent("nobody")).is_err());
+ assert!(host.provisioned_config(&profile("nobody")).is_err());
}
+
+ #[tokio::test]
+ async fn an_open_agent_is_gated_by_its_own_policy_not_the_operators() {
+ let tmp = tempfile::tempdir().unwrap();
+ let host = host(&tmp, 4, 60);
- let id = agent("alice");
++ let id = profile("alice");
+ host.provision(&id).unwrap();
+ let state = host.open(&id).unwrap();
+ assert_eq!(state.context().profile(), Some(id.as_str()));
+
+ let own = state
+ .context()
+ .agent_policy()
+ .expect("the profile carries a policy");
+ assert!(own.enabled, "the forced autonomy policy is on");
+ assert!(own.workspace_only);
+ let effective = CoreContext::scope(Arc::clone(state.context()), async {
+ crate::security::live_policy::effective()
+ })
+ .await
+ .expect("a policy is in effect");
+ assert!(
+ Arc::ptr_eq(&effective, &own),
+ "inside the profile's scope the gate answers with its policy"
+ );
+ }
+
+ #[tokio::test]
+ async fn an_agent_with_a_live_turn_is_not_evicted() {
+ let tmp = tempfile::tempdir().unwrap();
+ let host = host(&tmp, 1, 0);
- let (a, b) = (agent("a"), agent("b"));
++ let (a, b) = (profile("a"), profile("b"));
+ host.provision(&a).unwrap();
+ host.provision(&b).unwrap();
+ // The request that started the turn has answered and let go of the
+ // state; the turn keeps running on a context derived from the agent's.
+ let context = Arc::clone(host.open(&a).unwrap().context());
+ let (release, released) = tokio::sync::oneshot::channel::<()>();
+ let turn = tokio::spawn(CoreContext::scope_with_turn_origin(context, None, async {
+ let _ = released.await;
+ }));
+ tokio::task::yield_now().await;
+
+ host.evict_idle();
+ assert!(host.is_open(&a), "a live turn keeps its agent open");
+ let err = host.open(&b).unwrap_err();
+ assert!(err.contains("slots are in use"), "{err}");
+ assert!(host.deprovision(&a).unwrap_err().contains("in use"));
+
+ release.send(()).unwrap();
+ turn.await.unwrap();
+ host.evict_idle();
+ assert!(!host.is_open(&a), "evicted once the turn ended");
+ host.open(&b).unwrap();
+ }
diff --cc crates/openhuman-core/src/profiles/ops.rs
index d59b555fe1,0000000000..374e4266c8
mode 100644,000000..100644
--- a/crates/openhuman-core/src/profiles/ops.rs
+++ b/crates/openhuman-core/src/profiles/ops.rs
@@@ -1,157 -1,0 +1,154 @@@
+//! Operator-plane operations on profiles.
+//!
+//! Gateway user ids are taken here and turned into profile ids at once. The
+//! user id itself is never logged, stored or returned; under raw `profile_ids`
+//! mode a qualifying id *is* the profile id, so it is stored and returned as
+//! one (use `"hashed"` where that must not happen). Log lines and `Outcome`
+//! messages stay content-free either way.
+
+use super::credentials::{self, UserCredentialKind};
+use super::host::{self, ProfileHost};
+use super::types::{
+ CredentialResult, DeprovisionResult, ProfileId, ProfileSummary, ProvisionResult,
+};
+use crate::core::Outcome;
+
+fn require_host() -> Result<std::sync::Arc<ProfileHost>, String> {
+ host::host().ok_or_else(|| "profiles exist only in SaaS mode".to_string())
+}
+
+/// Create the profile for gateway user `user_id`, if it does not exist yet.
+pub fn provision(user_id: &str) -> Result<Outcome<ProvisionResult>, String> {
+ provision_on(&*require_host()?, user_id)
+}
+
+pub(crate) fn provision_on(
+ host: &ProfileHost,
+ user_id: &str,
+) -> Result<Outcome<ProvisionResult>, String> {
+ let profile_id = ProfileId::for_user(user_id, host.saas().profile_ids)?;
+ let created = host.provision(&profile_id)?;
+ let log = if created {
+ "profile provisioned"
+ } else {
+ "profile already provisioned"
+ };
+ Ok(Outcome::single_log(
+ ProvisionResult {
+ profile_id,
+ created,
+ },
+ log,
+ ))
+}
+
+/// Close profile `profile_id` and archive its state.
+pub fn deprovision(profile_id: &str) -> Result<Outcome<DeprovisionResult>, String> {
+ deprovision_on(&*require_host()?, profile_id)
+}
+
+pub(crate) fn deprovision_on(
+ host: &ProfileHost,
+ profile_id: &str,
+) -> Result<Outcome<DeprovisionResult>, String> {
+ let profile_id = ProfileId::parse(profile_id)?;
+ let removed = host.deprovision(&profile_id)?;
+ let log = if removed {
+ "profile archived"
+ } else {
+ "profile was not provisioned"
+ };
+ Ok(Outcome::single_log(
+ DeprovisionResult {
+ profile_id,
+ removed,
+ },
+ log,
+ ))
+}
+
+/// Every provisioned profile.
+pub fn list() -> Result<Outcome<Vec<ProfileSummary>>, String> {
+ let profiles = require_host()?.list()?;
+ let log = format!("{} profile(s)", profiles.len());
+ Ok(Outcome::single_log(profiles, log))
+}
+
+/// One profile, or an error when it is not provisioned.
+pub fn status(profile_id: &str) -> Result<Outcome<ProfileSummary>, String> {
+ status_on(&*require_host()?, profile_id)
+}
+
+pub(crate) fn status_on(
+ host: &ProfileHost,
+ profile_id: &str,
+) -> Result<Outcome<ProfileSummary>, String> {
+ let profile_id = ProfileId::parse(profile_id)?;
+ let summary = host
+ .summary(&profile_id)?
+ .ok_or_else(|| "profile is not provisioned".to_string())?;
- Ok(Outcome::single_log(
- summary,
- "profile status read",
- ))
++ Ok(Outcome::single_log(summary, "profile status read"))
+}
+
+/// Install the backend credential the gateway holds for profile `profile_id`.
+pub fn set_credential(
+ profile_id: &str,
+ kind: UserCredentialKind,
+ token: &str,
+ expires_at: Option<&str>,
+) -> Result<Outcome<CredentialResult>, String> {
+ set_credential_on(&*require_host()?, profile_id, kind, token, expires_at)
+}
+
+pub(crate) fn set_credential_on(
+ host: &ProfileHost,
+ profile_id: &str,
+ kind: UserCredentialKind,
+ token: &str,
+ expires_at: Option<&str>,
+) -> Result<Outcome<CredentialResult>, String> {
+ let profile_id = ProfileId::parse(profile_id)?;
+ // From the layout, not `open`: installing or revoking a credential must
+ // work even when every profile slot is busy.
+ let config = host.provisioned_config(&profile_id)?;
+ credentials::store(&config, kind, token, expires_at)?;
+ log::info!("[profiles] credential installed kind={kind:?}");
+ Ok(Outcome::single_log(
+ CredentialResult {
+ profile_id: profile_id.clone(),
+ has_credential: true,
+ },
+ "credential installed",
+ ))
+}
+
+/// Remove every credential profile `profile_id` holds.
+pub fn clear_credential(profile_id: &str) -> Result<Outcome<CredentialResult>, String> {
+ clear_credential_on(&*require_host()?, profile_id)
+}
+
+pub(crate) fn clear_credential_on(
+ host: &ProfileHost,
+ profile_id: &str,
+) -> Result<Outcome<CredentialResult>, String> {
+ let profile_id = ProfileId::parse(profile_id)?;
+ let config = host.provisioned_config(&profile_id)?;
+ let removed = credentials::clear(&config)?;
+ log::info!("[profiles] credential cleared removed={removed}");
+ let log = if removed {
+ "credential cleared"
+ } else {
+ "profile held no credential"
+ };
+ Ok(Outcome::single_log(
+ CredentialResult {
+ profile_id,
+ has_credential: false,
+ },
+ log,
+ ))
+}
+
+#[cfg(test)]
+#[path = "ops_tests.rs"]
+mod tests;
diff --cc crates/openhuman-embed/src/host_internals.rs
index 4ea9a5012d,01ee76f93c..a96a31c546
--- a/crates/openhuman-embed/src/host_internals.rs
+++ b/crates/openhuman-embed/src/host_internals.rs
@@@ -2,16 -2,339 +2,339 @@@
//! (`openhuman-tinyhumans`, `openhuman-rpc`), and nothing else.
//!
//! Those layers implement the backend transport, the hosted controllers and
- //! the JSON-RPC server, which reach deep into the core by nature. Routing
- //! them through this module keeps the dependency chain strict (they need no
+ //! the JSON-RPC server, which reach into the core by nature. Routing them
+ //! through this module keeps the dependency chain strict (they need no
//! `openhuman-core` dependency of their own) without inventing a public API
- //! for every server internal. It is an explicit list of modules, not a glob:
- //! a new reach-in is added here on purpose. Hosts (app, CLI, TUI) use the
- //! curated facade at the crate root instead.
-
- pub use openhuman_core::{
- agent, backend, channels, config, core, desktop, inference, integrations, mcp, platform,
- profiles, security, storage, tools, util, voice, web3, web_chat,
- };
+ //! for every server internal.
+ //!
+ //! This is an explicit list of items, not a glob of modules: every entry is a
+ //! symbol one of the two consumers named in its group actually uses, and a new
+ //! reach-in is added here on purpose. The nested module layout mirrors the
+ //! core's paths so a consumer's `__host::a::b::item` reads like the core path.
+ //! Hosts (app, CLI, TUI) never see this module: the curated facade at the
+ //! crate root is theirs, and the layers above embed re-export no part of it
+ //! (`scripts/ci/check-crate-chain.mjs` enforces that).
pub use openhuman_core::run_core_from_args;
+
+ /// Shared by tinyhumans (hosted controllers) and rpc (`http_host`, `/health`).
+ pub mod core {
+ pub use openhuman_core::core::{
+ unwrap_rpc, ControllerSchema, FieldSchema, Outcome, StructuredRpcError, TypeSchema,
+ };
+
+ pub mod all {
+ // tinyhumans: hosted controller extension; rpc: http_host + `/health`.
+ pub use openhuman_core::core::all::{
+ all_controller_schemas, all_http_method_schemas, cli_handler_for_namespace,
+ namespace_description, register_controller_extension, rpc_method_from_parts,
+ schema_for_rpc_method, ControllerExtension, ControllerFuture, DomainGroup,
+ RegisteredController,
+ };
+ }
+
+ /// Error classification shared by the hosted client (tinyhumans) and the
+ /// RPC handler and classifier (rpc).
+ pub mod observability {
+ pub use openhuman_core::core::observability::{
+ contains_transient_transport_phrase, expected_error_kind, is_api_key_rejected_message,
+ is_session_expired_message, is_suppressed_usage_probe_backoff,
+ is_transient_http_status_code, is_transient_message_failure, report_error_or_expected,
+ report_warning_message, API_KEY_REJECTED_PREFIX, BACKEND_UNAVAILABLE_PREFIX,
+ REPORT_ERROR_TRACING_TARGET,
+ };
+ }
+
+ // rpc server only, below.
+ pub mod auth {
+ pub use openhuman_core::core::auth::{
+ bearer_matches, get_rpc_token, init_rpc_token, init_rpc_token_with_value,
+ verify_bearer_token, CORE_TOKEN_ENV_VAR,
+ };
+ }
+ pub mod bus {
+ pub use openhuman_core::core::bus::{init, BUS};
+ }
+ pub mod cli {
+ pub use openhuman_core::core::cli::load_dotenv_for_cli;
+ }
+ pub mod dispatch {
+ pub use openhuman_core::core::dispatch::{
+ is_known_probe_method, unknown_method_name, UNKNOWN_METHOD_PREFIX,
+ };
+ }
+ pub mod event_bind_tokens {
+ pub use openhuman_core::core::event_bind_tokens::{consume, issue};
+ }
+ pub mod events {
+ // `DomainEvent` is matched variant by variant by the Socket.IO bridge.
+ pub use openhuman_core::core::events::DomainEvent;
+ }
+ pub mod invoke {
+ pub use openhuman_core::core::invoke::{default_state, invoke_method};
+ }
+ pub mod params {
+ pub use openhuman_core::core::params::{
+ is_param_validation_error, missing_required_param_message, unknown_param_message,
+ };
+ }
+ pub mod runtime {
+ pub use openhuman_core::core::runtime::{
- is_saas, CoreContext, CoreRuntime, Mode, SaasConfig,
++ current_tenant, is_saas, CoreContext, CoreRuntime, Mode, SaasConfig,
+ };
+ pub mod saas {
+ pub use openhuman_core::core::runtime::saas::build;
+ }
+ }
+ pub mod server_launcher {
+ pub use openhuman_core::core::server_launcher::{install_server_launcher, ServeRequest};
+ }
+ pub mod session_expiry {
+ pub use openhuman_core::core::session_expiry::is_session_expired_error;
+ }
+ pub mod shutdown {
+ pub use openhuman_core::core::shutdown::{register, signal};
+ }
+ pub mod types {
+ pub use openhuman_core::core::types::AppState;
+ }
+ }
+
+ /// tinyhumans (backend transport, hosted client, team ops) and rpc (`/health`).
+ pub mod backend {
+ pub use openhuman_core::backend::{
+ base_url, flatten_authed_error, BackendApiError, BackendClient,
+ };
+
+ pub mod transport {
+ pub use openhuman_core::backend::transport::{
+ clear_backend_transport, resolve_backend_transport, BackendTransport,
+ BackendTransportError, TransportProfile,
+ };
+ }
+ }
+
+ /// tinyhumans (every hosted controller loads its config) and rpc (server).
+ pub mod config {
+ pub use openhuman_core::config::{
+ active_workspace_dir, active_workspace_dir_cached, active_workspace_snapshot,
+ load_config_with_timeout, workspace_handle, Config,
+ };
+
+ pub mod app_env {
+ // tinyhumans: backend URL selection.
+ pub use openhuman_core::config::app_env::{
+ app_env_from_env, is_staging_app_env, APP_ENV_VAR, VITE_APP_ENV_VAR,
+ };
+ }
+ pub mod ops {
+ pub use openhuman_core::config::ops::load_config_with_timeout;
+ }
+ pub mod rpc {
+ pub use openhuman_core::config::rpc::load_config_with_timeout;
+ }
+ pub mod schema {
+ pub mod cloud_providers {
+ pub use openhuman_core::config::schema::cloud_providers::{
+ endpoint_host, host_is_builtin_cloud_provider,
+ };
+ }
+ }
+ }
+
+ /// tinyhumans: the Jev tool ranker and the jev route.
+ pub mod agent {
+ pub mod tinyagents {
+ pub mod discovery {
+ pub use openhuman_core::agent::tinyagents::discovery::{
+ embedding_provider_is_usable, embedding_tool_ranker, install_tool_ranker,
+ installed_tool_ranker,
+ };
+ }
+ // rpc: Socket.IO run-mode toggles.
+ pub mod run_mode {
+ pub use openhuman_core::agent::tinyagents::run_mode::{parse_mode_label, set_mode};
+ }
+ }
+ // rpc: shutdown, plan review over Socket.IO, and the session store install.
+ pub mod orchestration {
+ pub use openhuman_core::agent::orchestration::release_background_completion_stores;
+ }
+ pub mod plan_review {
+ pub mod gate {
+ pub use openhuman_core::agent::plan_review::gate::global;
+ }
+ }
+ pub mod session_store {
+ pub use openhuman_core::agent::session_store::{
+ context_workspace_dir, install, installed, restore,
+ };
+ }
+ }
+
+ /// tinyhumans: the channel-link controller schema.
+ pub mod channels {
+ pub mod contract_schema {
+ pub use openhuman_core::channels::contract_schema::contract_controller_schema;
+ }
+ }
+
+ /// tinyhumans: embeddings and provider-key lookup for the Jev ranker; rpc: the
+ /// OpenAI-compatible HTTP router.
+ pub mod inference {
+ pub mod embedding_host {
+ pub use openhuman_core::inference::embedding_host::default_embedding_provider_with_config;
+ }
+ pub mod provider {
+ pub mod factory {
+ pub use openhuman_core::inference::provider::factory::lookup_key_for_slug;
+ }
+ }
+ pub mod http {
+ #[cfg(feature = "http-server")]
+ pub use openhuman_core::inference::http::router;
+ pub use openhuman_core::inference::http::EXTERNAL_OPENAI_COMPAT_PROVIDER;
+ }
+ }
+
+ /// tinyhumans: the team ops budget gate.
+ pub mod integrations {
+ pub mod client {
+ pub use openhuman_core::integrations::client::budget_gate;
+ }
+ }
+
+ /// tinyhumans (credentials for the hosted client) and rpc (server auth,
+ /// Socket.IO approvals, bind policy).
+ pub mod security {
+ pub mod credentials {
+ pub use openhuman_core::security::credentials::{
+ AuthService, APP_SESSION_PROVIDER, DEFAULT_AUTH_PROFILE_NAME,
+ };
+ pub mod ops {
+ pub use openhuman_core::security::credentials::ops::{
+ list_provider_credentials, store_provider_credentials,
+ };
+ }
+ pub mod session_support {
+ pub use openhuman_core::security::credentials::session_support::{
+ build_session_state, current_session_is_local, resolve_backend_credential,
+ BackendCredential, LOCAL_SESSION_BACKEND_UNAVAILABLE,
+ };
+ }
+ }
+ pub mod approval {
+ pub use openhuman_core::security::approval::ApprovalGate;
+ }
+ pub mod pairing {
+ pub use openhuman_core::security::pairing::is_public_bind;
+ }
+ }
+
+ /// tinyhumans: TLS, URL and redaction helpers for the backend client.
+ pub mod util {
+ pub use openhuman_core::util::redact_url_for_log;
+
+ pub mod redact {
+ pub use openhuman_core::util::redact::redact_url_for_log;
+ }
+ pub mod tls {
+ pub use openhuman_core::util::tls::tls_client_builder;
+ }
+ pub mod url {
+ pub use openhuman_core::util::url::{
+ host_is_local, join_url, normalize_api_base_url, normalize_backend_api_base_url,
+ };
+ }
+ }
+
+ // The rest is the rpc server alone.
+
+ pub mod desktop {
+ pub mod notifications {
+ pub use openhuman_core::desktop::notifications::subscribe_core_notifications;
+ }
+ pub mod overlay {
+ pub use openhuman_core::desktop::overlay::subscribe_attention_events;
+ }
+ }
+
+ pub mod mcp {
+ pub mod registry {
+ pub mod oauth {
+ pub use openhuman_core::mcp::registry::oauth::complete;
+ }
+ }
+ }
+
+ pub mod platform {
+ pub mod connectivity {
+ pub mod rpc {
+ pub use openhuman_core::platform::connectivity::rpc::{
+ pick_listen_port_for_host_with, OccupiedByCore,
+ };
+ }
+ }
+ pub mod health {
+ pub use openhuman_core::platform::health::{snapshot, verdict};
+ }
+ }
+
+ pub mod storage {
+ pub use openhuman_core::storage::{
+ block_on_anyhow, clear, configured_url, driver_is_shared, install, installed, open,
+ url_from, StorageBackend, STORAGE_URL_VAR,
+ };
+ }
+
-pub mod user_agents {
++pub mod profiles {
+ pub mod gateway {
- pub use openhuman_core::user_agents::gateway::{
++ pub use openhuman_core::profiles::gateway::{
+ resolve_scope, sign, verify, GatewayRefusal, GatewayScope, USER_HEADER, USER_SIG_HEADER,
+ };
+ }
+ }
+
+ pub mod voice {
+ pub mod dictation_listener {
+ pub use openhuman_core::voice::dictation_listener::{
+ subscribe_dictation_events, subscribe_transcription_results,
+ };
+ }
+ // The core carries the live-voice and dictation sockets only with voice and
+ // the HTTP server compiled in. Where its features differ from embed's (a
+ // workspace build unifies them separately), rpc still names these paths, so
+ // embed supplies a socket-dropping stand-in rather than a missing item.
+ pub mod live {
+ pub mod ws {
+ #[cfg(all(feature = "voice", feature = "http-server"))]
+ pub use openhuman_core::voice::live::ws::handle_live_voice_ws;
+ #[cfg(not(all(feature = "voice", feature = "http-server")))]
+ pub async fn handle_live_voice_ws<S, C>(_socket: S, _config: C) {}
+ }
+ }
+ pub mod streaming {
+ #[cfg(all(feature = "voice", feature = "http-server"))]
+ pub use openhuman_core::voice::streaming::handle_dictation_ws;
+ #[cfg(not(all(feature = "voice", feature = "http-server")))]
+ pub async fn handle_dictation_ws<S, C>(_socket: S, _config: C) {}
+ }
+ }
+
+ pub mod web3 {
+ pub mod wallet {
+ pub use openhuman_core::web3::wallet::WALLET_NOT_CONFIGURED_MESSAGE;
+ }
+ }
+
+ pub mod web_chat {
+ pub use openhuman_core::web_chat::{
+ approval_request_event, cancel_chat_scoped, plan_review_request_event,
+ publish_web_channel_event, start_chat, subscribe_web_channel_events, unix_epoch_ms,
+ ChatRequestMetadata, GuardrailPayload, StartChatError, WebChannelEvent,
+ };
+ }
+
+ #[cfg(test)]
+ #[path = "host_internals_tests.rs"]
+ mod tests;