Volumes & Userspace Networking
Sandboxed workers start with zero access to user files and zero direct access to the host network stack. JetPack provides two explicit, auditable mechanisms when a worker needs user folders or outbound APIs.
1. User-Directed Host Folders ([volumes.<name>])
Never hardcode or request absolute host filesystem paths in app.toml or from browser JavaScript. Instead, declare logical volume names and access modes in app.toml:
[volumes.media_input]
mode = "read-only"
[volumes.media_output]
mode = "read-write"How Resolution & Persistence Work
- Native OS Picker (
rfd): On first launch (app.launch),jetpack-daemonprompts the human user via the native OS folder picker (Finder/Explorer/GTK Portal) for each unconfigured volume. If the user cancels, launch aborts withJetPackError::VolumeNotAuthorized. - Encrypted Store Caching (
ChaCha20-Poly1305): Selected folders are persisted inpaired_clients.db(authorized_volumes(app_id, volume_name, access_mode, host_path, updated_at)). Subsequent launches reuse the stored directory without re-prompting unless the folder was deleted/moved or the user/client requests a reset (reset_volumes: trueor"app.volumes.reset"). - Browser Privacy (
AppInfo): The browser only receives{ volume_name, folder_name, is_configured }(e.g.,folder_name: "Clips"). Full host paths are never sent over WebSockets. - Zero Client Trust: Any absolute host path passed by an untrusted browser in
AppLaunchRequestis ignored/rejected.
Accessing Mounted Volumes in Python Workers
Inside the sandbox, jetpack-daemon injects one environment variable per volume using the pattern JETPACK_VOL_<UPPERCASE_NAME>:
import os
from pathlib import Path
input_dir = Path(os.environ["JETPACK_VOL_MEDIA_INPUT"])
output_dir = Path(os.environ["JETPACK_VOL_MEDIA_OUTPUT"])
# Read-only mount: reading succeeds; writing raises PermissionError / EPERM
files = sorted(p.name for p in input_dir.iterdir() if p.is_file())
# Read-write mount: writing processed artifacts succeeds
out_file = output_dir / "processed.mp4"Note: Volumes declared with
mode = "read-only"are enforced as read-only by the OS kernel sandbox (AppContainerNTFS DACL,Seatbelt, orbwrap --ro-bind+Landlock), even if your user account owns the folder.
2. Outbound Networking via Userspace Proxy
Because workers run without direct network interfaces (CLONE_NEWNET on Linux, (deny default) on macOS, restricted capabilities on Windows), declare required remote endpoints in [permissions].network_allowlist:
[permissions]
model_cache = true
network_allowlist = [
"preset:huggingface",
# Expands to:
# "huggingface.co:443", "*.huggingface.co:443", "hf.co:443", "*.hf.co:443", "*.xethub.hf.co:443"
]Using the Proxy in Python Workers
jetpack-daemon automatically sets JETPACK_PROXY_ENDPOINT, HTTP_PROXY, HTTPS_PROXY, and ALL_PROXY inside the sandboxed process environment. jetpack_sdk.JetPackClient exposes client.proxy_endpoint:
import urllib.request
from jetpack_sdk import JetPackClient
with JetPackClient() as client:
proxy_url = client.proxy_endpoint
if proxy_url:
handler = urllib.request.ProxyHandler({
"http": proxy_url,
"https": proxy_url,
})
opener = urllib.request.build_opener(handler)
with opener.open("https://huggingface.co/api/models") as resp:
data = resp.read()Streaming Downloads, Redirect Chains, and Blocked-Host Diagnostics
- Zero-buffering multi-GB streaming:
UserspaceProxyenforces a30supstream connect timeout without capping active transfer duration, streams tunnels with fixed64 KiBdirectional buffers (tokio::io::copy_bidirectional_with_sizes), and refreshes worker idle-activity heartbeats during active transfers so multi-gigabyte model downloads (Whisper, Flux, RMBG, TTS) do not trip the idle reaper. - Redirect-chain protection: Supports HTTP headers up to
64 KiB(accommodating long presigned S3/LFS CDN redirect URLs and returning431 Request Header Fields Too Largeon overflow) and enforcesConnection: closeon plain HTTP forwarding so every hop re-validatesnetwork_allowlist. - Actionable diagnostics: Requests to any
host:portnot matchingnetwork_allowlist(or targeting loopback daemon ports) are blocked immediately with403 Forbidden, include anX-Jetpack-Blocked-Target: <host>:<port>response header, and emit aWARNevent in<root>/logs/daemon.logand the Developer Mode live terminal showing the exact domain/wildcard or"preset:huggingface"rule to add inapp.toml.
3. Persistent AI Model Cache (permissions.model_cache)
Because per-job workspaces (<root>/workspaces/job_<id>) are ephemeral and app bundles (<root>/apps/<app-id>/<version>) are read-only and replaced on updates, heavy AI workers should opt into the shared persistent model cache in app.toml:
[permissions]
model_cache = true
network_allowlist = ["preset:huggingface"]When model_cache = true:
jetpack-daemonprepares<root>/cache/models(with0o700permissions on Unix) plushuggingface/andtorch/subdirectories and mounts<root>/cache/modelsread-write into the OS sandbox (Seatbelt, AppContainer NTFS ACL, orbwrap+ Landlock).- The worker environment receives
JETPACK_MODEL_CACHE_DIR=<root>/cache/models,HF_HOME=<root>/cache/models/huggingface, andTORCH_HOME=<root>/cache/models/torch. - When
model_cache = false(the default),<root>/cache/modelsremains inaccessible under the sandbox default-deny policy and these variables are not injected.
4. Isolated Persistent App Home (JETPACK_APP_HOME / APP_HOME)
Every installed application automatically receives its own private, persistent read-write data directory at <appdata_root>/<app_id> (<root>/appdata/<app_id> by default, 0o700 on Unix) without requiring any [volumes.<name>] declaration or native folder-picker prompt:
- Provisioned automatically: Created during installation (
app.pull,install-local, core app seeding) and verified before every worker launch. - Per-app kernel isolation: Each worker's OS sandbox grants read/write access only to its own
<appdata_root>/<app_id>folder while keeping sibling<appdata_root>/<other_app_id>directories and<appdata_root>listings inaccessible. - Worker environment & Python SDK: Inside the sandbox,
jetpack-daemonunconditionally sets bothJETPACK_APP_HOMEandAPP_HOMEto<appdata_root>/<app_id>. In Python workers,client.app_homereturns apathlib.Pathpointing directly to this directory:
from jetpack_sdk import JetPackClient
with JetPackClient() as client:
db_path = client.app_home / "state.sqlite3"
db_path.parent.mkdir(parents=True, exist_ok=True)- User-configurable root folder: Users can relocate
<appdata_root>anytime under My Hardware & Security -> App Data Folder in Control Center ("Choose Folder..." invokes the daemon's main-thread nativerfdpicker; "Reset to Default" restores<root>/appdata). Uninstalling the JetPack daemon only removes internal JetPack state and leaves custom externalappdata_dirfolders untouched.
