Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

feat(system): pass a filtered environment to install commands

Steven Enamakel3d812ccd2c23
diff --git a/crates/openhuman-core/src/tools/impl/system/exec_adapters.rs b/crates/openhuman-core/src/tools/impl/system/exec_adapters.rs
index 711ca3ab26..c3b73b6780 100644
--- a/crates/openhuman-core/src/tools/impl/system/exec_adapters.rs
+++ b/crates/openhuman-core/src/tools/impl/system/exec_adapters.rs
@@ -29,6 +29,7 @@ use super::shell::ShellHost;
pub(super) struct InstallGate {
pub security: Arc<SecurityPolicy>,
pub audit: Arc<AuditLogger>,
+ pub environment: std::collections::BTreeMap<std::ffi::OsString, std::ffi::OsString>,
}
#[async_trait]
diff --git a/crates/openhuman-core/src/tools/impl/system/install_tool.rs b/crates/openhuman-core/src/tools/impl/system/install_tool.rs
index a7544f1a57..903b5845ed 100644
--- a/crates/openhuman-core/src/tools/impl/system/install_tool.rs
+++ b/crates/openhuman-core/src/tools/impl/system/install_tool.rs
@@ -20,17 +20,64 @@ impl InstallToolTool {
}
pub fn with_audit(security: Arc<SecurityPolicy>, audit: Arc<AuditLogger>) -> Self {
- let gate = Arc::new(InstallGate { security, audit });
- let backend: Arc<dyn ExecBackend> =
+ Self::with_backend_and_environment(
+ security,
+ audit,
Arc::new(tinyagents_harness_tools::exec::NativeExecBackend::new(
tinyagents_harness_tools::exec::ShellFlavor::Posix,
- ));
+ )),
+ install_environment(),
+ )
+ }
+
+ fn with_backend_and_environment(
+ security: Arc<SecurityPolicy>,
+ audit: Arc<AuditLogger>,
+ backend: Arc<dyn ExecBackend>,
+ environment: std::collections::BTreeMap<std::ffi::OsString, std::ffi::OsString>,
+ ) -> Self {
+ let gate = Arc::new(InstallGate {
+ security,
+ audit,
+ environment,
+ });
Self {
inner: InstallTool::new(gate, backend),
}
}
}
+fn install_environment() -> std::collections::BTreeMap<std::ffi::OsString, std::ffi::OsString> {
+ let allowed = [
+ "PATH",
+ "HOME",
+ "USERPROFILE",
+ "APPDATA",
+ "LOCALAPPDATA",
+ "SYSTEMROOT",
+ "WINDIR",
+ "PATHEXT",
+ "TEMP",
+ "TMP",
+ "TMPDIR",
+ "CARGO_HOME",
+ "RUSTUP_HOME",
+ "PIPX_HOME",
+ "PIPX_BIN_DIR",
+ "NPM_CONFIG_PREFIX",
+ "HOMEBREW_PREFIX",
+ "HOMEBREW_CELLAR",
+ "HOMEBREW_REPOSITORY",
+ "XDG_CACHE_HOME",
+ "XDG_CONFIG_HOME",
+ "XDG_DATA_HOME",
+ "XDG_STATE_HOME",
+ ];
+ std::env::vars_os()
+ .filter(|(name, _)| allowed.iter().any(|allowed| name == allowed))
+ .collect()
+}
+
#[async_trait]
impl Tool for InstallToolTool {
fn name(&self) -> &str {