feat: functionality to open a sandbox workspace in vs code

This commit is contained in:
2026-10-22 18:59:15 +02:00
parent 230927d8db
commit 1ac5193b0e
12 changed files with 426 additions and 18 deletions
+14
View File
@@ -16,6 +16,8 @@ wsbx run -p 8000 alpine # host's localhost:8000 reachable as localh
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 code NAME # VS Code in the browser, running in the sandbox (until Ctrl-C)
wsbx code NAME --desktop # desktop VS Code via Remote-SSH; also: ssh NAME.wsbx
wsbx ps # sandboxes: status, CPU, memory, net/block I/O, PIDs, disk, image (alias: ls)
wsbx ps -f # same, refreshed every second like `docker stats`
wsbx rm NAME... # delete stopped sandboxes; --disk deletes only the disk (fresh on next start)
@@ -35,6 +37,14 @@ You get a pty (with resize) when stdin and stdout are terminals, plain pipes oth
**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.
**code**: browser mode fetches the official VS Code CLI into the sandbox (`~/.wsbx-vscode`, needs internet in the VM) and runs
`code serve-web` on the guest's loopback, forwarded like `forward` to a random host port behind a random connection token.
The CLI downloads the matching server on first open (glibc or Alpine images). `--desktop` writes `~/.wsbx/ssh_config` (a `NAME.wsbx`
host per sandbox) and adds an `Include` for it at the top of `~/.ssh/config` once. ssh reaches an SSH server in the guest helper through `wsbx exec`
(`ProxyCommand`): no port, no keys, you're the image user. Remote-SSH then installs its server in the VM as usual.
If the VM was killed mid-download and the server won't start, delete `~/.vscode/cli/serve-web` (browser) or `~/.vscode-server` (desktop) in the sandbox.
Both need a sandbox started by this wsbx version (the guest helper ships with each start).
**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.
@@ -66,6 +76,10 @@ The VM is the boundary. The guest (including a prompt-injected agent or a malici
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.
- **code**: the SSH server is only reachable through `wsbx exec` (your user's `~/.wsbx`), so it skips auth, with an ephemeral host key.
It allows sessions and host → guest forwarding only; guest → host forwarding (`-R`) and agent forwarding are refused. Desktop VS Code
auto-forwards ports the guest opens to your localhost (turn off `remote.autoForwardPorts` if unwanted), and its client
trusts the remote server more than a browser tab does. The browser mode has the same localhost-cookie caveat as `forward`.
- **Host tunnel**: only the ports you pass with `-p` (or the local `baseUrl`s in pi's `models.json`), over vsock.
Remaining risks: