Skip to content

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

feat(tinybox): add docker run without workspace mount

Steven Enamakeld9a3cb48404c
diff --git a/crates/openhuman-core/src/modules/tinybox.rs b/crates/openhuman-core/src/modules/tinybox.rs
index 2f798338b8..57df9de7b2 100644
--- a/crates/openhuman-core/src/modules/tinybox.rs
+++ b/crates/openhuman-core/src/modules/tinybox.rs
@@ -51,6 +51,7 @@ const START_JAILED_EXEC: &str = contract::METHODS[26];
const RUN_DOCKER: &str = contract::METHODS[27];
const DOCKER_STATUS: &str = contract::METHODS[28];
const CLEANUP_DOCKER: &str = contract::METHODS[29];
+const RUN_DOCKER_WITHOUT_WORKSPACE: &str = contract::METHODS[30];
const DOCKER_CALL_GRACE: Duration = Duration::from_secs(5);
#[cfg(test)]
@@ -178,6 +179,19 @@ pub async fn run_docker(
call_run_docker_with_client(&client, request).await
}
+/// Run one bounded Docker-isolated command without mounting a workspace.
+///
+/// This is used by the configured Docker runtime, whose existing behavior
+/// intentionally does not expose host workspace files to the container.
+pub async fn run_docker_without_workspace(
+ config: &Config,
+ request: contract::DockerRunRequest,
+) -> Result<contract::DockerRunOutput, String> {
+ let timeout = Duration::from_millis(request.timeout_ms).saturating_add(DOCKER_CALL_GRACE);
+ let client = ModuleClient::new(config.clone()).with_timeout(timeout);
+ call_run_docker_without_workspace_with_client(&client, request).await
+}
+
/// Probe the Docker daemon owned by the TinyBox module host.
pub async fn docker_status(
config: &Config,
@@ -244,6 +258,13 @@ async fn call_run_docker_with_client(
call_with_client(client, RUN_DOCKER, (request,), true).await
}
+async fn call_run_docker_without_workspace_with_client(
+ client: &ModuleClient,
+ request: contract::DockerRunRequest,
+) -> Result<contract::DockerRunOutput, String> {
+ call_with_client(client, RUN_DOCKER_WITHOUT_WORKSPACE, (request,), true).await
+}
+
/// Read a bounded output batch from a live or completed process.
pub async fn read_output(
config: &Config,
diff --git a/crates/openhuman-core/src/modules/tinybox_tests.rs b/crates/openhuman-core/src/modules/tinybox_tests.rs
index ab6184824b..7ff2906e2f 100644
--- a/crates/openhuman-core/src/modules/tinybox_tests.rs
+++ b/crates/openhuman-core/src/modules/tinybox_tests.rs
@@ -72,6 +72,15 @@ impl Interface for MockTinyBox {
.map_err(tinybus::Error::from),
DOCKER_STATUS => serde_json::to_value(contract::DockerStatus { available: true })
.map_err(tinybus::Error::from),
+ RUN_DOCKER | RUN_DOCKER_WITHOUT_WORKSPACE => {
+ serde_json::to_value(contract::DockerRunOutput {
+ exit_code: 0,
+ stdout: "ok".to_owned(),
+ stderr: String::new(),
+ timed_out: false,
+ })
+ .map_err(tinybus::Error::from)
+ }
CLEANUP_DOCKER => serde_json::to_value(contract::CleanupDockerOutput {
containers_stopped: 3,
})
@@ -211,6 +220,7 @@ async fn docker_command_refusal_is_not_retried_as_an_ordinary_call() {
workspace: "/workspace".to_owned(),
image: None,
command: "printf secret".to_owned(),
+ login_shell: false,
network: None,
memory_limit_mb: None,
cpus: None,
@@ -364,10 +374,95 @@ fn every_host_operation_is_a_member_of_the_canonical_contract() {
RUN_DOCKER,
DOCKER_STATUS,
CLEANUP_DOCKER,
+ RUN_DOCKER_WITHOUT_WORKSPACE,
];
assert_eq!(methods, contract::METHODS);
}
+#[tokio::test]
+async fn no_workspace_docker_call_uses_its_typed_member_and_request() {
+ let (_service, client, calls) = mock_client().await;
+ let request = contract::DockerRunRequest {
+ workspace: String::new(),
+ image: Some("local-fixture:latest".to_owned()),
+ command: "printf ok".to_owned(),
+ login_shell: true,
+ network: Some("none".to_owned()),
+ memory_limit_mb: Some(128),
+ cpus: Some(1.5),
+ read_only_rootfs: Some(true),
+ read_only_mounts: Vec::new(),
+ extra_cap_drops: vec!["NET_RAW".to_owned()],
+ env: Default::default(),
+ label: Some("openhuman.runtime=true".to_owned()),
+ timeout_ms: 12_000,
+ };
+ let output: contract::DockerRunOutput = call_with_client(
+ &client,
+ RUN_DOCKER_WITHOUT_WORKSPACE,
+ (request,),
+ false,
+ )
+ .await
+ .expect("the adapter decodes the typed no-workspace result");
+
+ assert_eq!(output.exit_code, 0);
+ let calls = calls.lock().expect("recorded TinyBox calls");
+ let call = calls
+ .iter()
+ .find(|(member, _)| member == RUN_DOCKER_WITHOUT_WORKSPACE)
+ .expect("no-workspace member called");
+ assert_eq!(
+ call.1,
+ json!({
+ "workspace": "",
+ "image": "local-fixture:latest",
+ "command": "printf ok",
+ "login_shell": true,
+ "network": "none",
+ "memory_limit_mb": 128,
+ "cpus": 1.5,
+ "read_only_rootfs": true,
+ "read_only_mounts": [],
+ "extra_cap_drops": ["NET_RAW"],
+ "env": {},
+ "label": "openhuman.runtime=true",
+ "timeout_ms": 12_000
+ })
+ );
+}
+
+#[tokio::test]
+async fn no_workspace_docker_refusal_is_not_retried_as_an_ordinary_call() {
+ let (_service, client, calls) = mock_client().await;
+ let error = call_run_docker_without_workspace_with_client(
+ &client,
+ contract::DockerRunRequest {
+ workspace: String::new(),
+ image: None,
+ command: "printf private".to_owned(),
+ login_shell: true,
+ network: None,
+ memory_limit_mb: None,
+ cpus: None,
+ read_only_rootfs: None,
+ read_only_mounts: Vec::new(),
+ extra_cap_drops: Vec::new(),
+ env: Default::default(),
+ label: None,
+ timeout_ms: 1_000,
+ },
+ )
+ .await
+ .expect_err("an unattested fixture cannot receive a shell command");
+
+ assert!(error.contains("MODULE_CALL_REPORTED"), "{error}");
+ assert!(!error.contains("printf private"));
+ let calls = calls.lock().expect("call log lock");
+ assert_eq!(calls.len(), 1, "only the public capabilities probe ran");
+ assert_eq!(calls[0].0, CAPABILITIES);
+}
+
#[tokio::test]
async fn docker_controls_use_typed_calls_with_validated_contract_capability(
) -> Result<(), Box<dyn std::error::Error>> {