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
chore: files changed crates/openhuman-core/src/sandbox/native_jail.rs,crates/openhuman-core/src/sand
Steven Enamakel16e7368c81a2
diff --git a/crates/openhuman-core/src/sandbox/native_jail.rs b/crates/openhuman-core/src/sandbox/native_jail.rsindex 0e8e3701ad..dd6859833e 100644--- a/crates/openhuman-core/src/sandbox/native_jail.rs+++ b/crates/openhuman-core/src/sandbox/native_jail.rs@@ -85,7 +85,15 @@ pub(crate) async fn execute(}#[cfg(not(feature = "modules"))]{- let _ = (config, policy, command, working_dir, extra_env, timeout, explicitly_requested);+ let _ = (+ config,+ policy,+ command,+ working_dir,+ extra_env,+ timeout,+ explicitly_requested,+ );anyhow::bail!("TinyBox module support is disabled; native jail execution is unavailable")}}@@ -138,12 +146,9 @@ async fn execute_owned(let (env, read_write) = execution_environment(policy, extra_env, &scratch.path)?;let exec = shell_request(&resource, command, working_dir, env)?;let jail = jail_request(policy, read_write)?;- let process = tinybox::reserve(- config,- contract::ReserveRequest::Process(resource.clone()),- )- .await- .map_err(|_| anyhow::anyhow!("TinyBox could not reserve a native jail process"))?;+ let process = tinybox::reserve(config, contract::ReserveRequest::Process(resource.clone()))+ .await+ .map_err(|_| anyhow::anyhow!("TinyBox could not reserve a native jail process"))?;let process = tinybox::start_jailed_exec(config,contract::SpawnRequest {@@ -280,7 +285,9 @@ async fn collect_process(if tokio::time::Instant::now() >= deadline {tinybox::cancel(config, process.clone()).await- .map_err(|_| anyhow::anyhow!("TinyBox could not acknowledge process cancellation"))?;+ .map_err(|_| {+ anyhow::anyhow!("TinyBox could not acknowledge process cancellation")+ })?;break true;}let batch = tinybox::read_output(config, process.clone(), cursor)@@ -299,9 +306,9 @@ async fn collect_process(match batch.state {ExecutionState::Running => tokio::time::sleep(Duration::from_millis(20)).await,ExecutionState::Exited { exit_code } => {- tinybox::release_output(config, process).await.map_err(|_| {- anyhow::anyhow!("TinyBox could not release native jail output")- })?;+ tinybox::release_output(config, process)+ .await+ .map_err(|_| anyhow::anyhow!("TinyBox could not release native jail output"))?;return Ok(SandboxExecResult {exit_code,stdout: String::from_utf8_lossy(&stdout).into_owned(),@@ -313,7 +320,9 @@ async fn collect_process(ExecutionState::Failed {code: ExecutionFailure::CleanupFailed,} => anyhow::bail!("TinyBox retained native process cleanup for retry"),- ExecutionState::Failed { .. } => anyhow::bail!("TinyBox native jailed execution failed"),+ ExecutionState::Failed { .. } => {+ anyhow::bail!("TinyBox native jailed execution failed")+ }}};tinybox::release_output(config, process)diff --git a/crates/openhuman-core/src/sandbox/native_jail_tests.rs b/crates/openhuman-core/src/sandbox/native_jail_tests.rsindex b14dd0e53b..63846fa709 100644--- a/crates/openhuman-core/src/sandbox/native_jail_tests.rs+++ b/crates/openhuman-core/src/sandbox/native_jail_tests.rs@@ -29,7 +29,11 @@ fn shell_request_uses_the_platform_shell_and_caller_known_process_resource() ->let expected = platform_shell::build_std_command("printf 'one two'");let expected_argv = std::iter::once(expected.get_program().to_str().unwrap().to_owned())- .chain(expected.get_args().map(|arg| arg.to_str().unwrap().to_owned()))+ .chain(+ expected+ .get_args()+ .map(|arg| arg.to_str().unwrap().to_owned()),+ ).collect::<Vec<_>>();assert_eq!(request.resource, resource);assert_eq!(request.argv, expected_argv);@@ -58,7 +62,10 @@ fn native_jail_request_preserves_grants_and_requires_enforcement() -> anyhow::Relet request = jail_request(&policy, vec!["/scratch".to_owned()])?;assert_eq!(request.read_only, [readonly.path().to_str().unwrap()]);- assert_eq!(request.read_write, [readwrite.path().to_str().unwrap(), "/scratch"]);+ assert_eq!(+ request.read_write,+ [readwrite.path().to_str().unwrap(), "/scratch"]+ );assert!(!request.allow_net);assert!(request.allow_subprocess);assert_eq!(request.enforcement, contract::JailEnforcement::Enforced);@@ -81,16 +88,20 @@ fn native_jail_environment_keeps_the_sandbox_allowlist_and_scratch_grant() -> anenv_passthrough: Vec::new(),docker_overrides: None,};- let extra = HashMap::from([(- OsString::from("CUSTOM_SAFE"),- OsString::from("value"),- )]);+ let extra = HashMap::from([(OsString::from("CUSTOM_SAFE"), OsString::from("value"))]);let (env, read_write) = execution_environment(&policy, &extra, scratch.path())?;assert_eq!(env.get("CUSTOM_SAFE").map(String::as_str), Some("value"));- assert_eq!(env.get("TMPDIR").map(String::as_str), scratch.path().to_str());- assert!(read_write.iter().any(|path| path == scratch.path().to_str().unwrap()));- assert!(!env.keys().any(|name| name.contains("TOKEN") || name.contains("SECRET")));+ assert_eq!(+ env.get("TMPDIR").map(String::as_str),+ scratch.path().to_str()+ );+ assert!(read_write+ .iter()+ .any(|path| path == scratch.path().to_str().unwrap()));+ assert!(!env+ .keys()+ .any(|name| name.contains("TOKEN") || name.contains("SECRET")));Ok(())}@@ -114,9 +125,9 @@ impl Drop for BundledModulesRestore {async fn released_tinybox_runs_a_native_jail_through_the_pinned_loader() -> anyhow::Result<()> {let _environment_lock = crate::config::TEST_ENV_LOCK.lock().await;const KEY: &str = "OPENHUMAN_BUNDLED_MODULES";- let artifact_root = std::env::var_os(KEY)- .map(PathBuf::from)- .ok_or_else(|| anyhow::anyhow!("set OPENHUMAN_BUNDLED_MODULES to the downloaded v0.1.20 release assets"))?;+ let artifact_root = std::env::var_os(KEY).map(PathBuf::from).ok_or_else(|| {+ anyhow::anyhow!("set OPENHUMAN_BUNDLED_MODULES to the downloaded v0.1.20 release assets")+ })?;let _environment_restore = BundledModulesRestore(std::env::var_os(KEY));let record = crate::modules::registry::find("tinybox").ok_or_else(|| anyhow::anyhow!("TinyBox registry record is missing"))?;@@ -125,7 +136,10 @@ async fn released_tinybox_runs_a_native_jail_through_the_pinned_loader() -> anyh.find_map(|host_key| record.asset_for(host_key)).ok_or_else(|| anyhow::anyhow!("the pinned TinyBox release does not support this host"))?;let archive = artifact_root.join(asset.archive);- anyhow::ensure!(archive.is_file(), "missing verified release archive: {archive:?}");+ anyhow::ensure!(+ archive.is_file(),+ "missing verified release archive: {archive:?}"+ );let bundled = tempfile::tempdir()?;let bundle_asset_dir = bundleddiff --git a/crates/openhuman-core/src/sandbox/ops.rs b/crates/openhuman-core/src/sandbox/ops.rsindex d86c75c166..3da64f5386 100644--- a/crates/openhuman-core/src/sandbox/ops.rs+++ b/crates/openhuman-core/src/sandbox/ops.rs@@ -2,10 +2,10 @@//! routed execution.use super::docker;-use super::grants::{JailGrants, resolve_local_jail_grants};+use super::grants::{resolve_local_jail_grants, JailGrants};use super::types::{- ELEVATED_TOOLS, ElevatedOp, SandboxBackendHandle, SandboxBackendKind, SandboxExecRequest,- SandboxExecResult, SandboxPolicy, SandboxStatus,+ ElevatedOp, SandboxBackendHandle, SandboxBackendKind, SandboxExecRequest, SandboxExecResult,+ SandboxPolicy, SandboxStatus, ELEVATED_TOOLS,};use crate::agent::harness::definition::SandboxMode;use crate::agent::platform_shell;@@ -337,7 +337,9 @@ pub async fn execute_in_sandbox(Some(config) => config,None => crate::config::ops::load_config_with_timeout().await- .map_err(|error| anyhow::anyhow!("Cannot read module configuration: {error}"))?,+ .map_err(|error| {+ anyhow::anyhow!("Cannot read module configuration: {error}")+ })?,};super::native_jail::execute(&config,@@ -482,7 +484,10 @@ impl CallDir {pub(super) fn create(root: PathBuf, kind: &'static str) -> anyhow::Result<Self> {let path = root.join(uuid::Uuid::new_v4().to_string());std::fs::create_dir_all(&path).map_err(|error| {- anyhow::anyhow!("Failed to create sandbox {kind} dir {}: {error}", path.display())+ anyhow::anyhow!(+ "Failed to create sandbox {kind} dir {}: {error}",+ path.display()+ )})?;tracing::debug!(dir = %path.display(), kind, "[sandbox:local] created per-call dir");Ok(Self { path, kind })diff --git a/crates/openhuman-core/src/sandbox/ops_tests.rs b/crates/openhuman-core/src/sandbox/ops_tests.rsindex 3efc2f08eb..060ad7a70f 100644--- a/crates/openhuman-core/src/sandbox/ops_tests.rs+++ b/crates/openhuman-core/src/sandbox/ops_tests.rs@@ -249,11 +249,9 @@ async fn execute_in_sandbox_none_backend_runs_on_every_os() {fn env_passthrough_includes_safe_vars() {assert!(SANDBOX_ENV_PASSTHROUGH.contains(&"PATH"));assert!(SANDBOX_ENV_PASSTHROUGH.contains(&"HOME"));- assert!(- !SANDBOX_ENV_PASSTHROUGH- .iter()- .any(|v| v.contains("KEY") || v.contains("SECRET"))- );+ assert!(!SANDBOX_ENV_PASSTHROUGH+ .iter()+ .any(|v| v.contains("KEY") || v.contains("SECRET")));}// ── Windows child environment ────────────────────────────────────────────────diff --git a/crates/openhuman-core/src/sandbox/schemas.rs b/crates/openhuman-core/src/sandbox/schemas.rsindex de26e860f6..0c5f85e2f6 100644--- a/crates/openhuman-core/src/sandbox/schemas.rs+++ b/crates/openhuman-core/src/sandbox/schemas.rs@@ -3,8 +3,8 @@use serde_json::{Map, Value};use crate::config::rpc as config_rpc;-use crate::core::Outcome;use crate::core::all::{ControllerFuture, RegisteredController};+use crate::core::Outcome;use crate::core::{ControllerSchema, FieldSchema, TypeSchema};pub fn all_controller_schemas() -> Vec<ControllerSchema> {@@ -206,8 +206,8 @@ fn handle_status(params: Map<String, Value>) -> ControllerFuture {&config.runtime,&config,)- .await- .map_err(|e| e.to_string())?;+ .await+ .map_err(|e| e.to_string())?;}let handle = super::ops::create_sandbox_backend_with_config(&policy, &config).await?;to_json(Outcome::new(handle, vec![]))@@ -265,8 +265,8 @@ fn handle_resolve_policy(params: Map<String, Value>) -> ControllerFuture {&config.runtime,&config,)- .await- .map_err(|e| e.to_string())?;+ .await+ .map_err(|e| e.to_string())?;}to_json(Outcome::new(policy, vec![]))})