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): feed the caller's meter from the shell exec fixture
Steven Enamakele33338369309
diff --git a/crates/openhuman-core/src/sandbox/shell_exec_fixture.rs b/crates/openhuman-core/src/sandbox/shell_exec_fixture.rsindex 37d2706925..3b53d2600e 100644--- a/crates/openhuman-core/src/sandbox/shell_exec_fixture.rs+++ b/crates/openhuman-core/src/sandbox/shell_exec_fixture.rs@@ -61,12 +61,20 @@ pub(crate) async fn run(run: NativeShellRun) -> anyhow::Result<SandboxExecResult.kill_on_drop(true);tinytools_std::timeout::own_process_group(command.as_std_mut());match tinytools_std::timeout::output_or_kill(&mut command, run.timeout).await {- Ok(Ok(output)) => Ok(SandboxExecResult {- exit_code: output.status.code().unwrap_or(-1),- stdout: String::from_utf8_lossy(&output.stdout).into_owned(),- stderr: String::from_utf8_lossy(&output.stderr).into_owned(),- timed_out: false,- }),+ Ok(Ok(output)) => {+ // The module streams output into the caller's meter as it reads it;+ // the fixture folds the finished output in the same way.+ if let Some(meter) = &run.meter {+ meter.record(&output.stdout);+ meter.record(&output.stderr);+ }+ Ok(SandboxExecResult {+ exit_code: output.status.code().unwrap_or(-1),+ stdout: String::from_utf8_lossy(&output.stdout).into_owned(),+ stderr: String::from_utf8_lossy(&output.stderr).into_owned(),+ timed_out: false,+ })+ }Ok(Err(error)) => anyhow::bail!("Failed to execute command: {error}"),Err(_) => Ok(SandboxExecResult {exit_code: -1,diff --git a/crates/openhuman-core/src/sandbox/shell_exec_tests.rs b/crates/openhuman-core/src/sandbox/shell_exec_tests.rsindex 918664cdfc..ebfe047f1d 100644--- a/crates/openhuman-core/src/sandbox/shell_exec_tests.rs+++ b/crates/openhuman-core/src/sandbox/shell_exec_tests.rs@@ -120,3 +120,26 @@ async fn a_disabled_module_never_falls_back_to_a_host_shell_for_a_jailed_run() {assert!(run(&config, shell).await.is_err());assert!(!marker.exists());}++/// The progress meter rides the run itself (no ambient scope), so output of a+/// command started through `run_host` reaches the meter its caller passed.+#[cfg(unix)]+#[tokio::test]+async fn run_host_feeds_the_callers_meter() {+ let dir = tempfile::tempdir().unwrap();+ let meter = crate::sandbox::shell_progress::ShellOutputMeter::default();+ let output = run_host(+ &Config::default(),+ "printf 'line one\\nline two\\n'",+ dir.path(),+ dir.path(),+ BTreeMap::new(),+ Duration::from_secs(10),+ false,+ Some(meter.clone()),+ )+ .await+ .unwrap();+ assert!(output.success());+ assert_eq!(meter.snapshot(), (18, Some("line two".to_string())));+}diff --git a/crates/openhuman-core/src/tools/impl/system/shell.rs b/crates/openhuman-core/src/tools/impl/system/shell.rsindex beb4c438a5..97e30a2f23 100644--- a/crates/openhuman-core/src/tools/impl/system/shell.rs+++ b/crates/openhuman-core/src/tools/impl/system/shell.rs@@ -680,11 +680,10 @@ impl ShellTool {"[shell] starting sandboxed command");- let result =- sandbox::ops::execute_in_sandbox_metered(- &policy, command, action_dir, extra_env, effective, meter,- )- .await;+ let result = sandbox::ops::execute_in_sandbox_metered(+ &policy, command, action_dir, extra_env, effective, meter,+ )+ .await;(true, exec_result(result, effective))}}