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
docs(sandbox): add README for sandbox module
Steven Enamakel91421335b0c1
diff --git a/crates/openhuman-core/src/sandbox/README.md b/crates/openhuman-core/src/sandbox/README.mdindex 6561ee9c0c..852c423750 100644--- a/crates/openhuman-core/src/sandbox/README.md+++ b/crates/openhuman-core/src/sandbox/README.md@@ -1,56 +1,54 @@# SandboxPer-session sandbox backend selection and routed execution for agent tool-commands. Separates three concerns that used to be conflated: **where** a-tool runs (this module), **which** tools are allowed (security / tool-policy), and **whether** a tool needs host access (elevated ops, also owned-here). The gateway/core process itself always runs on the host; only-selected tool families (shell, filesystem, process) execute through a-sandbox backend.+commands. This separates three concerns that used to be conflated: where a+tool runs (this module), which tools are allowed (security and tool policy),+and whether a tool needs host access (elevated ops, also owned here). The+gateway/core process itself always runs on the host; only selected tool+families (shell, filesystem, process) execute through a sandbox backend.This is a distinct layer from `crate::security::traits::Sandbox` (the older-`Command`-wrapping backends in `security/{docker,bubblewrap,firejail,landlock}.rs`-used by `security::create_sandbox`). That trait wraps a `Command` in-place;+`Command`-wrapping backends in `security/{docker,bubblewrap,firejail,landlock}.rs`,+used by `security::create_sandbox`). That trait wraps a `Command` in place;this domain resolves a per-session `SandboxPolicy`, owns its own Dockerbackend, and delegates local OS-level confinement to `cwd_jail`.## Public surface-- `pub enum SandboxBackendKind { None, Local, Docker }` — `types.rs` — which+- `pub enum SandboxBackendKind { None, Local, Docker }` (`types.rs`): whichbackend a session resolved to.-- `pub struct SandboxPolicy` — `types.rs` — `backend`, `workspace_root`,- `read_only_mounts`, `allow_network`, `env_passthrough`,- `docker_overrides`.-- `pub struct DockerOverrides` — `types.rs` — per-session image/network/+- `pub struct SandboxPolicy` (`types.rs`): `backend`, `workspace_root`,+ `read_only_mounts`, `allow_network`, `env_passthrough`, `docker_overrides`.+- `pub struct DockerOverrides` (`types.rs`): per-session image, network, andresource-limit overrides layered on `RuntimeConfig`'s `[runtime.docker]`.-- `pub struct ElevatedOp` / `pub const ELEVATED_TOOLS` — `types.rs` — tools+- `pub struct ElevatedOp` and `pub const ELEVATED_TOOLS` (`types.rs`): tools(`git_operations`, `install_tool`, `docker_management`,`process_management`) that always require host access and must be audited- via `build_elevated_op` rather than silently bypassing the sandbox. No- code outside this domain calls `is_elevated_op`/`build_elevated_op` yet.-- `pub const SANDBOX_ENV_PASSTHROUGH` — `ops.rs` — the allowlisted- environment variables (`PATH`, `HOME`, `TERM`, ...) forwarded into- sandboxed execution; no other host env leaks in.+ via `build_elevated_op` rather than silently bypassing the sandbox. No code+ outside this domain calls `is_elevated_op`/`build_elevated_op` yet.+- `pub const SANDBOX_ENV_PASSTHROUGH` (`ops.rs`): the allowlisted environment+ variables (`PATH`, `HOME`, `TERM`, and so on) forwarded into sandboxed+ execution; no other host env leaks in.- `pub fn resolve_sandbox_policy(mode: SandboxMode, action_dir, runtime_config, is_remote_session) -> SandboxPolicy`- — `ops.rs` — `SandboxMode::None`/`ReadOnly` resolve to `SandboxBackendKind::None`;- `Sandboxed` resolves to `Docker` when `runtime_config.kind == "docker"` or- the session is remote (channel/cron), else `Local` (OS jail via- `cwd_jail`). `allow_network` is `!is_remote_session` for `Sandboxed` and- `true` otherwise; `workspace_root` is `action_dir`; `read_only_mounts` is- always empty; `docker_overrides` is populated from `[runtime.docker]` only- for the `Docker` backend.-- `pub async fn create_sandbox_backend(policy) -> SandboxBackendHandle` —- `ops.rs` — instantiates/probes the resolved backend.+ (`ops.rs`): `SandboxMode::None`/`ReadOnly` resolve to+ `SandboxBackendKind::None`. `Sandboxed` resolves to `Docker` when+ `runtime_config.kind == "docker"` or the session is remote (channel/cron),+ otherwise `Local` (OS jail via `cwd_jail`). `allow_network` is+ `!is_remote_session` for `Sandboxed` and `true` otherwise; `workspace_root`+ is `action_dir`; `read_only_mounts` is always empty; `docker_overrides` is+ populated from `[runtime.docker]` only for the `Docker` backend.+- `pub async fn create_sandbox_backend(policy) -> SandboxBackendHandle`+ (`ops.rs`): instantiates and probes the resolved backend.- `pub async fn execute_in_sandbox(policy, command, working_dir, extra_env, timeout) -> anyhow::Result<SandboxExecResult>`- — `ops.rs` — routes to unsandboxed, `cwd_jail`-based local jail, or Docker- execution based on `policy.backend`.-- `pub fn is_elevated_op(tool_name) -> bool` / `pub fn build_elevated_op(...) -> ElevatedOp`- — `ops.rs` — the escape hatch a sandboxed tool call uses to run on the- host, with an audited reason.-- `pub mod docker` — Docker-specific container execution- (`docker_exec`, `docker_backend_handle`, orphan cleanup).-- `pub mod cwd_jail` — the OS-level path-confinement backend used by- `Local`; see [`cwd_jail/README.md`](cwd_jail/README.md).+ (`ops.rs`): routes to unsandboxed execution, the `cwd_jail`-based local+ jail, or Docker execution based on `policy.backend`.+- `pub fn is_elevated_op(tool_name) -> bool` and+ `pub fn build_elevated_op(...) -> ElevatedOp` (`ops.rs`): the escape hatch a+ sandboxed tool call uses to run on the host, with an audited reason.+- `pub mod docker`: Docker-specific container execution (`docker_exec`,+ `docker_backend_handle`, orphan cleanup).+- `pub mod cwd_jail`: the OS-level path-confinement backend used by `Local`.+ See [`cwd_jail/README.md`](cwd_jail/README.md).- `sandbox` RPC namespace (`schemas.rs`): `status`, `resolve_policy`,`cleanup_orphans`, `validate_policy`, wired through`all_sandbox_registered_controllers()` in@@ -58,21 +56,22 @@ backend, and delegates local OS-level confinement to `cwd_jail`.## Backend behavior-- **None** — `execute_unsandboxed` runs the command directly via+- **None**: `execute_unsandboxed` runs the command directly via`agent::platform_shell` after validating `working_dir` with`config::ensure_usable_cwd`.-- **Local** — `execute_local_jail` builds a `cwd_jail::Jail` rooted at- `policy.workspace_root`, applies `deny_net()`/read-only mounts from the- policy, and spawns through `cwd_jail::default_backend()` (falling back to- `NoopBackend` if no OS jail is available on the host). Output is captured- by redirecting stdout/stderr to temp files inside the jail root because- some backends (macOS Seatbelt) rebuild the command and drop piped stdio.-- **Docker** — `docker::docker_exec` runs `docker run --rm` with the host- `action_dir` mounted read/write at `/workspace`, network `none` by- default, `--cap-drop ALL` (plus policy-specified extra drops),+- **Local**: `execute_local_jail` builds a `cwd_jail::Jail` rooted at+ `policy.workspace_root`, applies `deny_net()` and any read-only mounts from+ the policy, and spawns through `cwd_jail::default_backend()` (falling back+ to `NoopBackend` if no OS jail is available on the host). Output is+ captured by redirecting stdout/stderr to temp files inside the jail root,+ because some backends (macOS Seatbelt) rebuild the command and drop piped+ stdio.+- **Docker**: `docker::docker_exec` runs `docker run --rm` with the host+ `action_dir` mounted read/write at `/workspace`, network `none` by default,+ `--cap-drop ALL` (plus policy-specified extra drops),`--security-opt no-new-privileges`, a read-only rootfs with `/tmp` and- `/var/tmp` tmpfs mounts, memory/CPU limits (512 MB / 1 CPU defaults),- and only the explicit env passthrough list injected. Containers carry+ `/var/tmp` tmpfs mounts, memory/CPU limits (512 MB / 1 CPU defaults), and+ only the explicit env passthrough list injected. Containers carry`openhuman.sandbox=true` for orphan cleanup. `validate_docker_policy`rejects host networking and `/`, `/etc`, `/proc`, `/sys`, or the Dockersocket as mount roots.@@ -80,10 +79,10 @@ backend, and delegates local OS-level confinement to `cwd_jail`.## Security invariantSandbox backend selection is a defense-in-depth layer, not a replacement for-policy. Rust path checks in `security` (`is_workspace_internal_path`,+policy. The Rust path checks in `security` (`is_workspace_internal_path`,`is_always_forbidden`, `classify_command`) still apply even when-`resolve_sandbox_policy` falls back to `SandboxBackendKind::None` — either-explicitly (`SandboxMode::None`/`ReadOnly`) or implicitly when the `Local`+`resolve_sandbox_policy` falls back to `SandboxBackendKind::None`, whether+explicitly (`SandboxMode::None`/`ReadOnly`) or implicitly, when the `Local`backend has no usable OS jail: `cwd_jail::default_backend()` substitutes`NoopBackend`, `execute_local_jail` in `ops.rs` spawns through it, and`create_sandbox_backend` reports the handle as `SandboxStatus::Inactive`@@ -92,29 +91,29 @@ resolved `SandboxBackendKind` as a security boundary on its own.## Dependencies-- `crate::agent::harness::definition::SandboxMode` — the agent-declared- mode this domain resolves against.-- `crate::agent::platform_shell` — Windows-aware shell/command building for+- `crate::agent::harness::definition::SandboxMode`: the agent-declared mode+ this domain resolves against.+- `crate::agent::platform_shell`: Windows-aware shell/command building forthe unsandboxed and local-jail paths.-- `crate::config::RuntimeConfig` — `[runtime] kind` and `[runtime.docker]`+- `crate::config::RuntimeConfig`: `[runtime] kind` and `[runtime.docker]`overrides feed `resolve_sandbox_policy`.## Called by-- `crates/openhuman-core/src/tools/impl/system/{shell,node_exec,npm_exec,python_exec}.rs`- — resolve a policy and call `execute_in_sandbox` per invocation.-- `crates/openhuman-core/src/flows/tinyflows/caps/code.rs` — sandboxed code+- `crates/openhuman-core/src/tools/impl/system/{shell,node_exec,npm_exec,python_exec}.rs`:+ resolve a policy and call `execute_in_sandbox` per invocation.+- `crates/openhuman-core/src/flows/tinyflows/caps/code.rs`: sandboxed codeexecution capability.-- `crates/openhuman-core/src/agent/platform_shell.rs` — doc references- only; it is the shared Windows-aware command builder that+- `crates/openhuman-core/src/agent/platform_shell.rs`: doc references only;+ it is the shared Windows-aware command builder that`execute_unsandboxed`/`execute_local_jail` call into.-- `crates/openhuman-core/src/config/ops/sandbox.rs` — RPC settings surface+- `crates/openhuman-core/src/config/ops/sandbox.rs`: RPC settings surface(`get_sandbox_settings`) reads `SANDBOX_ENV_PASSTHROUGH` and`[security.sandbox]` config.## Tests-- `types_tests.rs`, `ops_tests.rs`, `schemas_tests.rs`, `docker_tests.rs` —+- `types_tests.rs`, `ops_tests.rs`, `schemas_tests.rs`, `docker_tests.rs`:sibling `#[cfg(test)]` suites per file.- `ops_tests.rs` includes a regression test (#3235) pinning`local_status_for_backend` so a host with no OS jail reports `Inactive`diff --git a/gitbooks/developing/architecture/frontend.md b/gitbooks/developing/architecture/frontend.mdindex ea818232f7..9dc25e776d 100644--- a/gitbooks/developing/architecture/frontend.md+++ b/gitbooks/developing/architecture/frontend.md@@ -468,7 +468,7 @@ There is **no** `/login` route: authentication flows through the Welcome page, tAll three guards read `useCoreState()` (not Redux auth state) and render `RouteLoadingScreen` while bootstrapping:-- **`ProtectedRoute`** (`components/ProtectedRoute.tsx`) (`({ children, requireAuth = true, redirectTo })`; without a session token, navigates to `redirectTo || '/'`. Onboarding gating is _not_ done here) an effect in `AppShellDesktop` (App.tsx) forces non-onboarding routes back to `/onboarding` while `onboarding_completed` is false, and bounces off it once complete.+- **`ProtectedRoute`** (`components/ProtectedRoute.tsx`, `({ children, requireAuth = true, redirectTo })`): without a session token, navigates to `redirectTo || '/'`. Onboarding gating is _not_ done here; an effect in `AppShellDesktop` (App.tsx) forces non-onboarding routes back to `/onboarding` while `onboarding_completed` is false, and bounces off it once complete.- **`PublicRoute`** (`components/PublicRoute.tsx`): redirects signed-in users to `/home` (which forwards to `/chat`).- **`DefaultRedirect`** (`components/DefaultRedirect.tsx`): signed out → `/`; signed in but onboarding incomplete → `/onboarding`; otherwise → `/chat`. Waits for `snapshot.currentUser` to avoid the post-login race.diff --git a/gitbooks/developing/building-rust-core.md b/gitbooks/developing/building-rust-core.mdindex 87562764d1..bbb68939a8 100644--- a/gitbooks/developing/building-rust-core.md+++ b/gitbooks/developing/building-rust-core.md@@ -84,7 +84,7 @@ From the repository root:cargo check --manifest-path Cargo.toml# Debug build of the actual CLI / RPC binary-cargo build --manifest-path Cargo.toml --bin openhuman-core+cargo build --manifest-path Cargo.toml -p openhuman-cli --bin openhuman-core# Check the stable host-facing embedding facadecargo check --manifest-path Cargo.toml -p openhuman-embed@@ -99,7 +99,7 @@ cargo build --manifest-path Cargo.toml -p openhuman-tuicargo check --manifest-path crates/openhuman-app/Cargo.toml# Release build-cargo build --manifest-path Cargo.toml --release --bin openhuman-core+cargo build --manifest-path Cargo.toml --release -p openhuman-cli --bin openhuman-core# Rust testscargo test --manifest-path Cargo.toml@@ -107,8 +107,7 @@ cargo test --manifest-path Cargo.tomlNotes:-- The **package** name is `openhuman`, but the runnable binary is **`openhuman-core`**.-- If you prefer package-oriented cargo commands for packager scripts, use `-p openhuman`.+- The core library's package name is `openhuman` (crate `openhuman_core`), but the runnable binary, `openhuman-core`, is built from the `openhuman-cli` package (`crates/openhuman-cli/src/main.rs`), which is why the commands above pass `-p openhuman-cli`.- The built binary lands at `target/debug/openhuman-core` or `target/release/openhuman-core`.### Faster local linking (optional)