Skip to main content

Crate byob_exec

Crate byob_exec 

Source
Expand description

Tools that run code: RunCommand (run_command, a shell command), RunPython (run_python, Python code or a script), InstallPackages (install_packages, programs and Python libraries for the workspace, with Nix or pixi, or in the workspace’s container), InstallPythonPackages (install_python_packages, into byob’s managed venv with uv, where there is no package manager for install_packages) and InstallSystemPackages (install_system_packages, Homebrew/winget, the last resort a person approves every time).

Every run is prepared by env::Envs: it runs in the workspace’s container if the user opted in; otherwise installed packages, the workspace’s .venv and (once the user agreed) its dev shell go on PATH, and the nix CLI works inside the sandbox.

Everything runs through byob_sandbox: read the system, read+write the workspace and a private temp folder, no network unless the call asks (and the user approves), a minimal environment without inherited secrets, wall-clock timeout, bounded output, and the whole process tree is killed on timeout or Stop. Where the OS can’t sandbox (no Landlock), commands still run, with a warning in the log and in the tool output; BYOB_SANDBOX=off turns the sandbox off explicitly (Mode::Unsandboxed).

Re-exports§

pub use python::Python;

Modules§

env
Workspace environments: where the programs and libraries a run needs come from.
python
Which Python runs model code, and the managed environment for data-analysis packages.

Structs§

Exec
Shared by the tools.
InstallPackages
install_packages: programs and Python libraries for this workspace, from the machine’s package manager (Nix). They stay installed (per workspace) and are on PATH for every later run_command / run_python.
InstallPythonPackages
install_python_packages: add packages to byob’s managed venv (created on first use) with uv. Wheels only (--only-binary :all:), so installing never runs package code.
InstallSystemPackages
install_system_packages: the last resort, Homebrew or winget, system-wide. Every call needs a person’s approval (it is never auto-approved), and while there is a workspace installer it only takes packages install_packages couldn’t find.
Job
One sandboxed invocation (what an env::EnvProvider hands its env::Runner).
RunCommand
run_command: a shell command in the workspace.
RunPython
run_python: Python code (or a workspace script) in the workspace.

Enums§

Mode
How commands run.

Constants§

DEFAULT_TIMEOUT_S
MAX_OUTPUT
Bytes kept per stream (head and tail halves) for the model.
MAX_TIMEOUT_S

Functions§

install
Create the managed venv if needed and install packages into it. Usable by the app directly (e.g. a “set up Python for data analysis” button). Runs in the sandbox with network on, writing only under <data>/python.
register
Register run_command, run_python, and — when there’s a data folder — either install_packages (a package manager like Nix is installed) or, failing that, install_python_packages (uv is installed).