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/tools/impl/system/shell.rs,crates/openhuman-core/src/
Steven Enamakelac76ec2be14c
diff --git a/crates/openhuman-core/src/tools/impl/system/shell.rs b/crates/openhuman-core/src/tools/impl/system/shell.rsindex 2a97156bee..0df9648b43 100644--- a/crates/openhuman-core/src/tools/impl/system/shell.rs+++ b/crates/openhuman-core/src/tools/impl/system/shell.rs@@ -365,7 +365,7 @@ impl ShellTool {// SaaS: every command runs in the user's container, whatever the// agent's sandbox mode says, and never on the host.let saas_action_dir = self.effective_action_dir_for_context(context);- if let Some(resolved) = saas_sandbox_with(crate::core::runtime::is_saas(), || {+ if let Some(resolved) = super::shell_saas::saas_sandbox_with(crate::core::runtime::is_saas(), || {crate::user_agents::tools::sandbox_policy(&saas_action_dir,&self.security.workspace_dir,@@ -380,7 +380,7 @@ impl ShellTool {Err(why) => {tracing::warn!(reason = %why, "[shell] SaaS sandbox refused the command");// Nothing ran: report it as not allowed.- saas_sandbox_refusal(&why)+ super::shell_saas::saas_sandbox_refusal(&why)}};}@@ -542,7 +542,7 @@ impl ShellTool {let mut extra_env = std::collections::HashMap::new();// A managed runtime's PATH names host directories, which a SaaS// container cannot see.- if passes_runtime_path_with(crate::core::runtime::is_saas()) {+ if super::shell_saas::passes_runtime_path_with(crate::core::runtime::is_saas()) {if let Some(path) = self.runtime_path_for_command(command).await {extra_env.insert("PATH".into(), path.into());}@@ -736,30 +736,6 @@ fn versioned_executable(executable: &str, prefix: &str) -> bool {.is_some_and(|suffix| !suffix.is_empty() && suffix.chars().all(|c| c.is_ascii_digit()))}-/// In SaaS, resolves the container policy every command must run in; `None`-/// outside SaaS, where the agent's sandbox mode decides.-pub(crate) fn saas_sandbox_with(- saas: bool,- resolve: impl FnOnce() -> Result<crate::sandbox::SandboxPolicy, String>,-) -> Option<Result<crate::sandbox::SandboxPolicy, String>> {- saas.then(resolve)-}--/// The result for a SaaS command whose sandbox could not be set up: nothing-/// ran, so it is reported as not allowed, and never falls back to the host.-pub(crate) fn saas_sandbox_refusal(why: &str) -> (bool, ToolResult) {- (- false,- ToolResult::error(format!("Sandbox unavailable: {why}")),- )-}--/// Whether the managed runtime's `PATH` is passed into a sandboxed command.-/// Not in SaaS: it names host directories a container cannot see.-pub(crate) fn passes_runtime_path_with(saas: bool) -> bool {- !saas-}-#[cfg(test)]#[path = "shell_tests.rs"]mod tests;diff --git a/crates/openhuman-core/src/tools/impl/system/shell_saas.rs b/crates/openhuman-core/src/tools/impl/system/shell_saas.rsnew file mode 100644index 0000000000..49f44d76f5--- /dev/null+++ b/crates/openhuman-core/src/tools/impl/system/shell_saas.rs@@ -0,0 +1,32 @@+//! Shell tool behaviour that differs in SaaS mode, split out so each branch can+//! be tested with the mode passed in.++use crate::tools::ToolResult;++/// In SaaS, resolves the container policy every command must run in; `None`+/// outside SaaS, where the agent's sandbox mode decides.+pub(crate) fn saas_sandbox_with(+ saas: bool,+ resolve: impl FnOnce() -> Result<crate::sandbox::SandboxPolicy, String>,+) -> Option<Result<crate::sandbox::SandboxPolicy, String>> {+ saas.then(resolve)+}++/// The result for a SaaS command whose sandbox could not be set up: nothing+/// ran, so it is reported as not allowed, and never falls back to the host.+pub(crate) fn saas_sandbox_refusal(why: &str) -> (bool, ToolResult) {+ (+ false,+ ToolResult::error(format!("Sandbox unavailable: {why}")),+ )+}++/// Whether the managed runtime's `PATH` is passed into a sandboxed command.+/// Not in SaaS: it names host directories a container cannot see.+pub(crate) fn passes_runtime_path_with(saas: bool) -> bool {+ !saas+}++#[cfg(test)]+#[path = "shell_saas_tests.rs"]+mod tests;diff --git a/crates/openhuman-core/src/tools/impl/system/shell_saas_tests.rs b/crates/openhuman-core/src/tools/impl/system/shell_saas_tests.rsnew file mode 100644index 0000000000..2001852c40--- /dev/null+++ b/crates/openhuman-core/src/tools/impl/system/shell_saas_tests.rs@@ -0,0 +1,28 @@+use super::*;++#[test]+fn saas_sandbox_is_not_resolved_outside_saas() {+ let resolved = saas_sandbox_with(false, || panic!("must not resolve a policy"));+ assert!(resolved.is_none());+}++#[test]+fn saas_sandbox_refuses_instead_of_falling_back_to_the_host() {+ let resolved = saas_sandbox_with(true, || Err("no such sandbox".to_string()));+ let why = match resolved {+ Some(Err(why)) => why,+ other => panic!("expected a refusal, got {other:?}"),+ };+ let (allowed, result) = saas_sandbox_refusal(&why);+ assert!(!allowed);+ assert!(result.is_error);+ assert!(result+ .output()+ .contains("Sandbox unavailable: no such sandbox"));+}++#[test]+fn runtime_path_is_withheld_only_in_saas() {+ assert!(!passes_runtime_path_with(true));+ assert!(passes_runtime_path_with(false));+}diff --git a/crates/openhuman-core/src/tools/impl/system/shell_tests_runtime_and_sandbox_tests.rs b/crates/openhuman-core/src/tools/impl/system/shell_tests_runtime_and_sandbox_tests.rsindex a62f196b8c..d609ca3406 100644--- a/crates/openhuman-core/src/tools/impl/system/shell_tests_runtime_and_sandbox_tests.rs+++ b/crates/openhuman-core/src/tools/impl/system/shell_tests_runtime_and_sandbox_tests.rs@@ -258,30 +258,3 @@ fn shell_family_tools_route_to_sandbox_when_sandboxed_mode_active() {);}}--#[test]-fn saas_sandbox_is_not_resolved_outside_saas() {- let resolved = saas_sandbox_with(false, || panic!("must not resolve a policy"));- assert!(resolved.is_none());-}--#[test]-fn saas_sandbox_refuses_instead_of_falling_back_to_the_host() {- let resolved = saas_sandbox_with(true, || Err("no such sandbox".to_string()));- let why = match resolved {- Some(Err(why)) => why,- other => panic!("expected a refusal, got {other:?}"),- };- let (allowed, result) = saas_sandbox_refusal(&why);- assert!(!allowed);- assert!(result.is_error);- assert!(result- .output()- .contains("Sandbox unavailable: no such sandbox"));-}--#[test]-fn runtime_path_is_withheld_only_in_saas() {- assert!(!passes_runtime_path_with(true));- assert!(passes_runtime_path_with(false));-}