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(http_host): add session-scoped auth and host internals
Steven Enamakel39f2d0f7a38d
diff --git a/crates/openhuman-embed/src/host_internals.rs b/crates/openhuman-embed/src/host_internals.rsindex 7dcf1ec315..9b38ebc982 100644--- a/crates/openhuman-embed/src/host_internals.rs+++ b/crates/openhuman-embed/src/host_internals.rs@@ -128,7 +128,7 @@ pub mod config {};}pub mod ops {- pub use openhuman_core::config::ops::load_config_with_timeout;+ pub use openhuman_core::config::ops::{load_config_in, load_config_with_timeout};}pub mod rpc {pub use openhuman_core::config::rpc::load_config_with_timeout;diff --git a/crates/openhuman-rpc/src/http_host/auth.rs b/crates/openhuman-rpc/src/http_host/auth.rsindex 95cae22852..47a39e6a33 100644--- a/crates/openhuman-rpc/src/http_host/auth.rs+++ b/crates/openhuman-rpc/src/http_host/auth.rs@@ -4,6 +4,7 @@ use base64::Engine as _;use rand::RngExt as _;use crate::core_host::config;+use crate::core_host::core::runtime::DispatchCtx;use crate::core_host::security::credentials::session_support;use crate::http_host::types::HostedDirAuth;use crate::http_host::LOG_PREFIX;@@ -55,8 +56,8 @@ fn unauthorized_response() -> Response {response}-pub(crate) async fn resolve_default_auth_username() -> Option<String> {- let config = match config::load_config_with_timeout().await {+pub(crate) async fn resolve_default_auth_username(ctx: &DispatchCtx) -> Option<String> {+ let config = match config::ops::load_config_in(ctx).await {Ok(config) => config,Err(error) => {log::debug!("{LOG_PREFIX} default auth username config load failed: {error}");diff --git a/crates/openhuman-rpc/src/http_host/http_host_tests.rs b/crates/openhuman-rpc/src/http_host/http_host_tests.rsindex 0422c52893..c985e03475 100644--- a/crates/openhuman-rpc/src/http_host/http_host_tests.rs+++ b/crates/openhuman-rpc/src/http_host/http_host_tests.rs@@ -55,7 +55,7 @@ async fn start_serves_files_with_basic_auth() {let mut file = std::fs::File::create(&file_path).unwrap();writeln!(file, "hello from hosted dir").unwrap();- let server = start_hosted_dir_server(StartHostedDirParams {+ let server = start_hosted_dir_server(&DispatchCtx::host_default(), StartHostedDirParams {directory: tmp.path().display().to_string(),port: 0,bind_host: "127.0.0.1".to_string(),diff --git a/crates/openhuman-rpc/src/http_host/ops.rs b/crates/openhuman-rpc/src/http_host/ops.rsindex 8195f7f58b..024c922609 100644--- a/crates/openhuman-rpc/src/http_host/ops.rs+++ b/crates/openhuman-rpc/src/http_host/ops.rs@@ -54,6 +54,7 @@ fn registry() -> &'static HostedDirRegistry {}pub async fn start_hosted_dir_server(+ ctx: &crate::core_host::core::runtime::DispatchCtx,params: StartHostedDirParams,) -> Result<HostedDirServerInfo, String> {register_shutdown_hook_once();@@ -68,7 +69,7 @@ pub async fn start_hosted_dir_server(password: None,}} else {- let default_username = resolve_default_auth_username().await;+ let default_username = resolve_default_auth_username(ctx).await;let username = params.username.as_deref()diff --git a/crates/openhuman-rpc/src/http_host/rpc.rs b/crates/openhuman-rpc/src/http_host/rpc.rsindex bcf241e445..1184c9b65b 100644--- a/crates/openhuman-rpc/src/http_host/rpc.rs+++ b/crates/openhuman-rpc/src/http_host/rpc.rs@@ -7,8 +7,11 @@ use crate::http_host::types::{HostedDirStopResult, StartHostedDirParams,};-pub async fn start(params: StartHostedDirParams) -> Result<Outcome<HostedDirStartResult>, String> {- let server = ops::start_hosted_dir_server(params).await?;+pub async fn start(+ ctx: &crate::core_host::core::runtime::DispatchCtx,+ params: StartHostedDirParams,+) -> Result<Outcome<HostedDirStartResult>, String> {+ let server = ops::start_hosted_dir_server(ctx, params).await?;Ok(Outcome::single_log(HostedDirStartResult { server },"started hosted directory HTTP server",diff --git a/crates/openhuman-rpc/src/http_host/schemas.rs b/crates/openhuman-rpc/src/http_host/schemas.rsindex b2fd52b87b..fa22f15dc4 100644--- a/crates/openhuman-rpc/src/http_host/schemas.rs+++ b/crates/openhuman-rpc/src/http_host/schemas.rs@@ -160,10 +160,10 @@ pub fn schemas(function: &str) -> ControllerSchema {}}-fn handle_start(_ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {+fn handle_start(ctx: DispatchCtx, params: Map<String, Value>) -> ControllerFuture {Box::pin(async move {let params: StartHostedDirParams = parse(params)?;- crate::http_host::rpc::start(params)+ crate::http_host::rpc::start(&ctx, params).await?.into_cli_compatible_json()})diff --git a/crates/openhuman-rpc/src/session_store/mod.rs b/crates/openhuman-rpc/src/session_store/mod.rsindex b1de261271..f5c0d3004e 100644--- a/crates/openhuman-rpc/src/session_store/mod.rs+++ b/crates/openhuman-rpc/src/session_store/mod.rs@@ -97,8 +97,11 @@ async fn configured_storage_url() -> anyhow::Result<Option<String>> {if env.as_deref().is_some_and(|url| !url.trim().is_empty()) {return Ok(storage_url_from(env, &Default::default()));}- let config = crate::core_host::config::rpc::load_config_with_timeout()- .await+ // Boot-time resolution: the host's own context, no turn's.+ let config = crate::core_host::config::ops::load_config_in(+ &crate::core_host::core::runtime::DispatchCtx::host_default(),+ )+ .await.map_err(|error| {anyhow::anyhow!("loading the config to resolve the storage url: {error}")})?;