feat: implement exec and forward commands for running commands in sandboxes
- Added `exec` command to run a shell or command in a running sandbox, utilizing a new exec server. - Introduced `forward` command to expose ports of a running sandbox on the host's localhost. - Updated Cargo.toml and Cargo.lock to reflect version bump and new dependencies. - Enhanced README.md with usage instructions for new commands. - Refactored build.rs to include new guest helper files for exec functionality. - Created new source files for exec and forward logic, including protocol handling and connection management.
This commit is contained in:
@@ -13,6 +13,9 @@ wsbx pi # pi coding agent, same version + config as
|
||||
wsbx run alpine # bare VM, interactive shell
|
||||
wsbx run -w . ubuntu -- make test # one-off command, exit code propagated
|
||||
wsbx run -p 8000 alpine # host's localhost:8000 reachable as localhost:8000 in the VM
|
||||
wsbx exec NAME # shell in a running sandbox (alias: sh), as the image's user
|
||||
wsbx exec -u root NAME -- apk add git # command, exit code propagated
|
||||
wsbx forward NAME 3000 8080:80 # sandbox's localhost:3000 on the Mac's localhost:3000 (until Ctrl-C; alias fwd)
|
||||
wsbx ps # sandboxes: running/stopped, image, disk use, workspace (alias: ls)
|
||||
wsbx rm NAME... # delete stopped sandboxes; --disk deletes only the disk (fresh on next start)
|
||||
wsbx pull IMAGE
|
||||
@@ -25,6 +28,12 @@ are re-resolved after 24 h (cached copy used when offline); the superseded image
|
||||
|
||||
Options: `--name --workspace --cpus --memory --disk --env K[=V] --host-port/-p PORT --fresh --pull --kernel`.
|
||||
|
||||
**exec**: host → vfkit unix socket (`exec.sock`) → vsock → guest helper. It runs in the workspace dir with the sandbox's env.
|
||||
You get a pty (with resize) when stdin and stdout are terminals, plain pipes otherwise, so `wsbx exec x -- cat f > out` is byte-exact.
|
||||
|
||||
**forward**: host `127.0.0.1:HOSTPORT` → `exec.sock` → vsock → guest helper → guest `localhost:PORT`, one exec-style session
|
||||
per connection. Works for services bound only to the guest's loopback, on running sandboxes, no restart. `0:PORT` picks a free host port.
|
||||
|
||||
**Host tunnel** (`-p PORT`): guest `localhost:PORT` → vsock → vfkit → unix socket → host `localhost:PORT`.
|
||||
Nothing listens on a host network interface, and only the listed ports are reachable.
|
||||
|
||||
@@ -52,6 +61,10 @@ The VM is the boundary. The guest (including a prompt-injected agent or a malici
|
||||
(token realms and redirects included).
|
||||
- **pi config**: allowlisted items only. Symlinks are followed only into `~/.pi/agent` or `~/.agents/skills`, with no cycles
|
||||
and no special files, capped at 256 MB.
|
||||
- **exec**: sessions run as root before dropping to the user, so the guest helper accepts them only from the host's vsock CID,
|
||||
not from guest processes via vsock loopback.
|
||||
- **forward**: listens on the host's loopback only. Browsers don't isolate `localhost` cookies by port, so a forwarded guest
|
||||
page can read non-HttpOnly cookies your other localhost apps set. Forward only what you need.
|
||||
- **Host tunnel**: only the ports you pass with `-p` (or the local `baseUrl`s in pi's `models.json`), over vsock.
|
||||
|
||||
Remaining risks:
|
||||
|
||||
Reference in New Issue
Block a user