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
fix(sandbox): resolve shell execution failures in native jail
Steven Enamakeleb06a938950d
diff --git a/crates/openhuman-core/src/sandbox/native_jail.rs b/crates/openhuman-core/src/sandbox/native_jail.rsindex 7df13d0ec4..b1335ff2c6 100644--- a/crates/openhuman-core/src/sandbox/native_jail.rs+++ b/crates/openhuman-core/src/sandbox/native_jail.rs@@ -91,6 +91,7 @@ pub(crate) async fn require_backend(_config: &Config, _expected: &str) -> anyhow/// Run a command inside TinyBox's native jail and keep its resource lifecycle module-owned.pub(crate) async fn execute(+ ctx: &crate::core::runtime::DispatchCtx,config: &Config,policy: &SandboxPolicy,command: &str,@@ -102,6 +103,7 @@ pub(crate) async fn execute() -> anyhow::Result<SandboxExecResult> {#[cfg(feature = "modules")]{+ let ctx = ctx.clone();let config = config.clone();let policy = policy.clone();let command = command.to_owned();@@ -110,6 +112,7 @@ pub(crate) async fn execute(// The worker owns cancellation and resource cleanup if the caller drops its wait.tokio::spawn(async move {execute_owned(+ &ctx,&config,&policy,&command,@@ -127,6 +130,7 @@ pub(crate) async fn execute(#[cfg(not(feature = "modules"))]{let _ = (+ ctx,config,policy,command,@@ -142,6 +146,7 @@ pub(crate) async fn execute(#[cfg(feature = "modules")]async fn execute_owned(+ ctx: &crate::core::runtime::DispatchCtx,config: &Config,policy: &SandboxPolicy,command: &str,@@ -183,7 +188,7 @@ async fn execute_owned(// TinyBox adds its own per-call scratch directory to the writable grants and// points TMPDIR, TMP and TEMP at it unless the caller overrides them.run.jail = Some(jail_request(policy, isolation)?);- super::shell_exec::run(config, run).await+ super::shell_exec::run(ctx, config, run).await}/// The caller's environment overrides, which must be UTF-8 to cross the bus.diff --git a/crates/openhuman-core/src/sandbox/ops.rs b/crates/openhuman-core/src/sandbox/ops.rsindex 7f8285c1e6..5bac3875d8 100644--- a/crates/openhuman-core/src/sandbox/ops.rs+++ b/crates/openhuman-core/src/sandbox/ops.rs@@ -390,6 +390,7 @@ pub(crate) async fn execute_in_sandbox_metered(};let policy = super::local_grants::with_resolved_grants(&config, policy).await?;super::native_jail::execute(+ ctx,&config,&policy,command,diff --git a/crates/openhuman-core/src/sandbox/shell_exec.rs b/crates/openhuman-core/src/sandbox/shell_exec.rsindex a374c8456d..e9e45446d4 100644--- a/crates/openhuman-core/src/sandbox/shell_exec.rs+++ b/crates/openhuman-core/src/sandbox/shell_exec.rs@@ -97,10 +97,14 @@ pub(crate) static USE_FIXTURE: std::sync::atomic::AtomicBool =/// Run `run` through the module and collect its output.////// A worker owns cancellation and resource cleanup if the caller drops its wait.-pub(crate) async fn run(config: &Config, mut run: NativeShellRun) -> anyhow::Result<SandboxExecResult> {+pub(crate) async fn run(+ ctx: &crate::core::runtime::DispatchCtx,+ config: &Config,+ mut run: NativeShellRun,+) -> anyhow::Result<SandboxExecResult> {#[cfg(test)]if !run.is_jailed() && USE_FIXTURE.load(std::sync::atomic::Ordering::SeqCst) {- let _ = config;+ let _ = (ctx, config);return fixture::run(run).await;}#[cfg(feature = "modules")]@@ -119,7 +123,7 @@ pub(crate) async fn run(config: &Config, mut run: NativeShellRun) -> anyhow::Res// cancellation is acknowledged only after the command is gone.let hold = tinytools_std::timeout::ProcessCleanup::hold();let (_caller, abandoned) = tokio::sync::oneshot::channel::<std::convert::Infallible>();- crate::core::runtime::DispatchCtx::ambient().spawn(async move {+ ctx.spawn(async move {let _hold = hold;run_owned(&config, run, abandoned, meter).await})@@ -128,7 +132,7 @@ pub(crate) async fn run(config: &Config, mut run: NativeShellRun) -> anyhow::Res}#[cfg(not(feature = "modules"))]{- let _ = (config, run);+ let _ = (ctx, config, run);anyhow::bail!("TinyBox module support is disabled; command execution is unavailable")}}diff --git a/crates/openhuman-core/src/tools/impl/system/shell.rs b/crates/openhuman-core/src/tools/impl/system/shell.rsindex 0ca2065db5..55618ea852 100644--- a/crates/openhuman-core/src/tools/impl/system/shell.rs+++ b/crates/openhuman-core/src/tools/impl/system/shell.rs@@ -626,7 +626,7 @@ impl ShellTool {run.python_utf8 = true;run.hide_window = self.runtime.hide_window();run.meter = meter;- let result = crate::sandbox::shell_exec::run(&config, run).await;+ let result = crate::sandbox::shell_exec::run(ctx, &config, run).await;(true, exec_result(result, effective))}