Skip to content

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

fix(sandbox): gate docker helpers behind modules feature

Steven Enamakelf22098b768eb
diff --git a/crates/openhuman-core/src/sandbox/docker.rs b/crates/openhuman-core/src/sandbox/docker.rs
index 1456b7ae7b..ba85827e5e 100644
--- a/crates/openhuman-core/src/sandbox/docker.rs
+++ b/crates/openhuman-core/src/sandbox/docker.rs
@@ -19,12 +19,14 @@ use super::types::{
SandboxStatus,
};
use crate::config::Config;
+#[cfg(feature = "modules")]
use crate::modules::tinybox::{self, contract};
/// Label applied to all sandbox containers for orphan cleanup.
const CONTAINER_LABEL: &str = "openhuman.sandbox=true";
/// Check whether Docker is available and responsive.
+#[cfg(feature = "modules")]
pub async fn is_docker_available(config: &Config) -> Result<bool, String> {
let status = tinybox::docker_status(
config,
@@ -36,6 +38,11 @@ pub async fn is_docker_available(config: &Config) -> Result<bool, String> {
Ok(status.available)
}
+#[cfg(not(feature = "modules"))]
+pub async fn is_docker_available(_config: &Config) -> Result<bool, String> {
+ Err("TinyBox module support is disabled; Docker status is unavailable".to_owned())
+}
+
/// Execute a command inside an ephemeral Docker container.
///
/// Policy stays here (which image, network, limits and mounts the
@@ -163,8 +170,9 @@ fn path_string(path: &std::path::Path, kind: &str) -> anyhow::Result<String> {
.ok_or_else(|| anyhow::anyhow!("Docker {kind} path is not UTF-8"))
}
-/// Clean up orphaned sandbox containers (those labeled with
-/// `openhuman.sandbox=true` that are still running).
+/// Clean up orphaned sandbox containers owned by TinyBox and carrying the
+/// OpenHuman label.
+#[cfg(feature = "modules")]
pub async fn cleanup_orphaned_containers(config: &Config) -> anyhow::Result<u32> {
let output = tinybox::cleanup_docker(
config,
@@ -180,6 +188,11 @@ pub async fn cleanup_orphaned_containers(config: &Config) -> anyhow::Result<u32>
Ok(count)
}
+#[cfg(not(feature = "modules"))]
+pub async fn cleanup_orphaned_containers(_config: &Config) -> anyhow::Result<u32> {
+ anyhow::bail!("TinyBox module support is disabled; Docker cleanup is unavailable")
+}
+
/// Create a handle representing the Docker backend state.
pub async fn docker_backend_handle(config: &Config) -> Result<SandboxBackendHandle, String> {
let available = is_docker_available(config).await?;