Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
aa5f400
chore(tinybox): pin vendor/tinybox to main 690bb563 (contract 2.4)
senamakel Nov 11, 2026
e593c4b
chore(deps): update sha2 to 0.11.1 and add tokio dependency
senamakel Nov 11, 2026
1b5a48d
feat(sandbox): add retention field to sandbox create requests
senamakel Nov 11, 2026
c103d59
refactor(sandbox): rename openshell module to boxes
senamakel Nov 11, 2026
0371272
feat(sandbox): add agent37 box settings and retention policy
senamakel Nov 11, 2026
5bc889f
feat(config): add agent37 box lifecycle settings
senamakel Nov 11, 2026
1bb96ad
test(config): cover agent37 retention defaults and toml overrides
senamakel Nov 11, 2026
5c8246b
feat(sandbox): add box retention and forget to the driver trait
senamakel Nov 11, 2026
74fa4f8
refactor(sandbox): re-export box retention and workdir types
senamakel Nov 11, 2026
31982d6
test(sandbox): update box test fixtures for new settings fields
senamakel Nov 11, 2026
70dfa50
feat(sandbox): add owner_key helper for retaining backends
senamakel Nov 11, 2026
f05a6aa
feat(sandbox): support retained boxes keyed by tenant owner
senamakel Nov 11, 2026
b5bcf40
feat(sandbox): add agent37 as a box-keeping backend alongside openshell
senamakel Nov 11, 2026
a9a703b
feat(sandbox): support agent37 backend and box retention
senamakel Nov 11, 2026
df534bf
refactor(sandbox): run agent37 commands in a retained per-tenant box
senamakel Nov 11, 2026
7edfecf
refactor(sandbox): pass box backend explicitly to execute
senamakel Nov 11, 2026
f32291e
feat(sandbox): treat agent37 as a box-keeping backend
senamakel Nov 11, 2026
526432a
refactor(sandbox): regroup policy re-exports in ops module
senamakel Nov 11, 2026
9e4eaef
refactor(sandbox): drop unused sandbox_keeps_boxes re-export
senamakel Nov 11, 2026
ebc8fa4
test(sandbox): build box settings from default openshell config in tests
senamakel Nov 11, 2026
aaceebd
test(boxes): cover agent37 request building and retention
senamakel Nov 11, 2026
315fcf4
test(sandbox): cover agent37 work folder and settings
senamakel Nov 11, 2026
2f01c1b
test(sandbox): cover backend selection and box refusal paths
senamakel Nov 11, 2026
68194af
docs(sandbox): document agent37 retained boxes and per-backend workdirs
senamakel Nov 11, 2026
200e28b
docs(sandbox): document agent37 as a box backend
senamakel Nov 11, 2026
f744176
style(sandbox): reformat sandbox modules with rustfmt
senamakel Nov 11, 2026
6f42f0c
chore(registry): bump tinybox module to 0.2.6
senamakel Nov 11, 2026
a846fa3
test(registry): update tinybox manifest expectations to v0.2.6
senamakel Nov 11, 2026
54f81fa
chore(deps): bump tinybox crates from 0.2.5 to 0.2.6
senamakel Nov 11, 2026
36e8747
merge: bring origin/main into agent37-keep
senamakel Nov 11, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 21 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/openhuman-app/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/openhuman-app/src/gateway/provision.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ pub(super) fn create_request(
resources: contract::ResourceLimits::default(),
ports,
env: env.clone(),
retention: None,
}
}

Expand Down
27 changes: 13 additions & 14 deletions crates/openhuman-core/src/artifacts/box_source.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//! `create_artifact` and `update_artifact` for a sandbox that keeps boxes: a
//! file `path` names a file in the calling tenant's box, not on the host.
//!
//! With a backend that keeps one box per tenant (`openshell`; see
//! With a backend that keeps one box per tenant (`openshell`, `agent37`; see
//! [`SandboxBackendKind::keeps_boxes`](crate::sandbox::types::SandboxBackendKind::keeps_boxes)),
//! the files an agent makes live in its box, and the host has never seen
//! them. [`BoxSourced`] wraps the artifact crate's `create_artifact`
//! tool (and likewise `update_artifact`, whose artifact kind comes from its
//! stored record): for an `image` or `file` artifact it reads the file out of the
//! caller's box ([`crate::sandbox::openshell::read_file`]) and hands the bytes
//! caller's box ([`crate::sandbox::boxes::read_file`]) and hands the bytes
//! to the crate's tool in memory ([`Content::Bytes`]), with the box file's name
//! for its extension. Nothing is written to the host on the way. Everything
//! after that is [`create_artifact`](tiny_artifacts::CreateArtifactTool) as
Expand All @@ -25,20 +25,20 @@ use tiny_artifacts::{ArtifactKind, Artifacts, Content, CreateArtifactTool, Updat
use tinytools::{PermissionLevel, Tool, ToolResult};

use crate::core::runtime::{DispatchCtx, NoTenant, Tenant};
use crate::sandbox::openshell::BoxError;
use crate::sandbox::boxes::BoxError;
use crate::sandbox::MAX_BOX_FILE_BYTES;

/// Where a call's box files are read from, and whether they are.
#[async_trait]
pub(crate) trait BoxFiles: Send + Sync {
/// Whether this call's sandbox keeps a box per tenant, so a file `path`
/// names a file in it.
/// The work folder of this call's box when its sandbox keeps a box per
/// tenant, so a file `path` names a file in it; `None` when it keeps none.
///
/// # Errors
///
/// When the configuration cannot be read: the call's source is then
/// unknown, and it must not fall back to reading the host's disk.
async fn keeps_boxes(&self) -> Result<bool, BoxError>;
async fn work_folder(&self) -> Result<Option<&'static str>, BoxError>;

/// The file at `path` in `tenant`'s box.
async fn read(
Expand All @@ -62,12 +62,12 @@ impl SandboxBoxFiles {

#[async_trait]
impl BoxFiles for SandboxBoxFiles {
async fn keeps_boxes(&self) -> Result<bool, BoxError> {
async fn work_folder(&self) -> Result<Option<&'static str>, BoxError> {
let config =
self.ctx.load_config().await.map_err(|error| {
BoxError::Driver(format!("cannot read the configuration: {error}"))
})?;
Ok(crate::sandbox::ops::sandbox_keeps_boxes(&self.ctx, &config))
Ok(crate::sandbox::ops::sandbox_box_workdir(&self.ctx, &config))
}

async fn read(
Expand All @@ -76,7 +76,7 @@ impl BoxFiles for SandboxBoxFiles {
path: &str,
max_bytes: u64,
) -> Result<Vec<u8>, BoxError> {
let tenant = crate::sandbox::openshell::tenant_for_box(tenant)?;
let tenant = crate::sandbox::boxes::tenant_for_box(tenant)?;
let config =
self.ctx.load_config().await.map_err(|error| {
BoxError::Driver(format!("cannot read the configuration: {error}"))
Expand Down Expand Up @@ -116,10 +116,9 @@ impl BytesTool for UpdateArtifactTool {
}
}

/// `path` as a name relative to the box's work folder: an agent in the box
/// `path` as a name relative to the box's `work_folder`: an agent in the box
/// knows that folder by its absolute name, so one under it is accepted.
fn box_path(path: &str) -> &str {
let work_folder = crate::sandbox::openshell::BOX_WORKDIR;
fn box_path<'a>(path: &'a str, work_folder: &str) -> &'a str {
path.strip_prefix(work_folder)
.and_then(|rest| rest.strip_prefix('/'))
.filter(|rest| !rest.is_empty())
Expand Down Expand Up @@ -230,9 +229,9 @@ impl BoxSourced {
};
Ok(self
.boxes
.keeps_boxes()
.work_folder()
.await?
.then(|| box_path(path).to_owned()))
.map(|work_folder| box_path(path, work_folder).to_owned()))
}
}

Expand Down
39 changes: 30 additions & 9 deletions crates/openhuman-core/src/artifacts/box_source_tests.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use super::*;
use crate::artifacts::tiny_store::{artifacts_service, version_files_dir};
use crate::artifacts::{read_artifact_bytes, FileRoots};
use crate::config::OpenShellRuntimeConfig;
use crate::core::runtime::DispatchCtx;
use crate::sandbox::openshell::scripted_driver::{Call, ExecStep, ScriptedDriver};
use crate::sandbox::openshell::{read_file_in, BoxOutput, BoxRegistry, RegistryLimits};
use crate::sandbox::boxes::scripted_driver::{Call, ExecStep, ScriptedDriver};
use crate::sandbox::boxes::{read_file_in, BoxOutput, BoxRegistry, BoxSettings, RegistryLimits};
use base64::Engine as _;
use serde_json::{json, Value};
use std::path::PathBuf;
Expand Down Expand Up @@ -33,8 +32,9 @@ struct ScriptedBoxes {

#[async_trait]
impl BoxFiles for ScriptedBoxes {
async fn keeps_boxes(&self) -> Result<bool, BoxError> {
async fn work_folder(&self) -> Result<Option<&'static str>, BoxError> {
self.keeps
.map(|keeps| keeps.then_some("/sandbox"))
.ok_or_else(|| BoxError::Driver("cannot read the configuration: unreadable".into()))
}

Expand All @@ -47,7 +47,8 @@ impl BoxFiles for ScriptedBoxes {
read_file_in(
&self.registry,
tenant,
&OpenShellRuntimeConfig::default(),
&BoxSettings::from_config(&crate::config::OpenShellRuntimeConfig::default())
.expect("the default OpenShell settings are valid"),
path,
max_bytes,
)
Expand Down Expand Up @@ -115,6 +116,7 @@ impl Fixture {
RegistryLimits {
idle_ttl: Duration::from_secs(900),
max_live: 10,
retain: None,
},
);
let service = Arc::new(service);
Expand Down Expand Up @@ -378,10 +380,29 @@ async fn the_tool_keeps_the_artifact_tools_name_and_schema() {

#[test]
fn a_box_path_is_the_name_relative_to_the_work_folder() {
assert_eq!(box_path("report.pdf"), "report.pdf");
assert_eq!(box_path("/sandbox/out/report.pdf"), "out/report.pdf");
assert_eq!(box_path("/sandboxed/report.pdf"), "/sandboxed/report.pdf");
assert_eq!(box_path("/sandbox"), "/sandbox");
assert_eq!(box_path("report.pdf", "/sandbox"), "report.pdf");
assert_eq!(
box_path("/sandbox/out/report.pdf", "/sandbox"),
"out/report.pdf"
);
assert_eq!(
box_path("/sandboxed/report.pdf", "/sandbox"),
"/sandboxed/report.pdf"
);
assert_eq!(box_path("/sandbox", "/sandbox"), "/sandbox");
}

#[test]
fn an_agent37_box_path_is_relative_to_its_home() {
assert_eq!(
box_path("/home/node/out/report.pdf", "/home/node"),
"out/report.pdf"
);
// Another backend's work folder is just an absolute path here.
assert_eq!(
box_path("/sandbox/out/report.pdf", "/home/node"),
"/sandbox/out/report.pdf"
);
}

#[tokio::test]
Expand Down
Loading
Loading