Add guest sessions and agent VM defaults
Add daemon-backed workspace and guest-session primitives so host orchestrators can prepare /root/repo, launch long-lived guest commands, and attach to pipe-mode sessions over the local stdio mux bridge. Persist richer session metadata and launch diagnostics, preflight guest cwd/command requirements, make pipe-mode attach rehydratable from guest state after daemon restart, and allow submodules when workspace prepare runs in full_copy mode. At the same time, stop vm run from auto-attaching opencode, make it print next-step commands instead, and make glibc guest images more agent-ready by installing node, opencode, claude, and pi while syncing opencode/claude/pi auth files into work disks on VM start. Validation: - GOCACHE=/tmp/banger-gocache go test ./... - make build - banger vm workspace prepare --help - banger vm session --help - banger vm session start --help - banger vm session attach --help
This commit is contained in:
parent
497e6dca3d
commit
37c4c091ec
18 changed files with 3212 additions and 405 deletions
46
README.md
46
README.md
|
|
@ -113,17 +113,45 @@ Create and use a VM:
|
|||
|
||||
`vm create` stays synchronous by default, but on a TTY it now shows live progress until the VM is fully ready.
|
||||
|
||||
Start a repo-backed VM session and attach `opencode` automatically:
|
||||
Start a repo-backed VM session:
|
||||
|
||||
```bash
|
||||
./build/bin/banger vm run
|
||||
./build/bin/banger vm run ../some-repo --branch feature/alpine --from HEAD
|
||||
```
|
||||
|
||||
`vm run` resolves the enclosing git repository, creates a VM, copies a git checkout plus current tracked and untracked non-ignored files into `/root/repo`, starts a best-effort guest tooling harness that inspects the repo and installs clearly-needed tools with `mise`, and then prefers a host-side `opencode attach` session when the local client supports it. Older host opencode clients fall back to starting `opencode` inside the guest over SSH. The harness runs asynchronously and logs its output inside the guest.
|
||||
`vm run` resolves the enclosing git repository, creates a VM, copies a git checkout plus current tracked and untracked non-ignored files into `/root/repo`, starts a best-effort guest tooling bootstrap that only uses `mise`, prints next-step commands, and exits. It does not auto-attach `opencode` anymore. The bootstrap runs asynchronously and logs its output inside the guest.
|
||||
|
||||
After `vm run`, use one of:
|
||||
|
||||
```bash
|
||||
./build/bin/banger vm ssh <vm-name>
|
||||
opencode attach http://<vm-name>.vm:4096 --dir /root/repo
|
||||
./build/bin/banger vm acp <vm-name>
|
||||
./build/bin/banger vm ssh <vm-name> -- "cd /root/repo && claude"
|
||||
./build/bin/banger vm ssh <vm-name> -- "cd /root/repo && pi"
|
||||
```
|
||||
|
||||
For ACP-aware host tools, `./build/bin/banger vm acp <vm-name>` bridges stdio to guest `opencode acp` over SSH. It uses `/root/repo` when that checkout exists, otherwise `/root`, and `--cwd` lets you override the guest working directory explicitly.
|
||||
|
||||
If you want reusable orchestration primitives instead of the `vm run` convenience flow, use the daemon-backed workspace and session commands directly:
|
||||
|
||||
```bash
|
||||
./build/bin/banger vm workspace prepare <vm-name>
|
||||
./build/bin/banger vm workspace prepare <vm-name> ../other-repo --guest-path /root/repo --readonly
|
||||
./build/bin/banger vm session start <vm-name> --name planner --cwd /root/repo --stdin-mode pipe -- pi --mode rpc --no-session
|
||||
./build/bin/banger vm session list <vm-name>
|
||||
./build/bin/banger vm session attach <vm-name> planner
|
||||
./build/bin/banger vm session logs <vm-name> planner --stream stderr
|
||||
./build/bin/banger vm session stop <vm-name> planner
|
||||
```
|
||||
|
||||
`vm workspace prepare` materializes a local git checkout into a running VM. The default guest path is `/root/repo` and the default mode is a shallow metadata copy plus tracked and untracked non-ignored overlay. Repositories with git submodules must use `--mode full_copy`; the metadata-based modes still reject them.
|
||||
|
||||
`vm session start` creates a daemon-managed long-lived guest command. The daemon preflights that the requested guest `cwd` exists and that the main command, plus any repeated `--require-command` entries, exist in guest `PATH` before launch. Use `--stdin-mode pipe` when you need live `attach`; otherwise use the default detached mode and inspect sessions with `list`, `show`, `logs`, `stop`, and `kill`.
|
||||
|
||||
`vm session attach` is currently exclusive and same-host only. The daemon exposes a local Unix socket bridge using `stdio_mux_v1`, so only one active attach is allowed at a time. Pipe-mode sessions keep enough guest-side state for the daemon to rebuild that bridge after a daemon restart.
|
||||
|
||||
## Web UI
|
||||
|
||||
`bangerd` serves a local web UI by default at:
|
||||
|
|
@ -144,15 +172,25 @@ web_listen_addr = ""
|
|||
|
||||
## Guest Services
|
||||
|
||||
Provisioned images include:
|
||||
Provisioned glibc-backed images include:
|
||||
|
||||
- `banger-vsock-agent`
|
||||
- guest networking bootstrap
|
||||
- `mise`
|
||||
- `opencode`
|
||||
- `claude`
|
||||
- `pi`
|
||||
- a default guest `opencode` service on `0.0.0.0:4096`
|
||||
|
||||
If host `~/.local/share/opencode/auth.json` exists, `banger` syncs it into the guest at `/root/.local/share/opencode/auth.json` on VM start. Changes on the host take effect after the VM is restarted.
|
||||
Alpine currently remains `opencode`-only.
|
||||
|
||||
If these host auth files exist, `banger` syncs them into the guest on VM start:
|
||||
|
||||
- `~/.local/share/opencode/auth.json` -> `/root/.local/share/opencode/auth.json`
|
||||
- `~/.claude/.credentials.json` -> `/root/.claude/.credentials.json`
|
||||
- `~/.pi/agent/auth.json` -> `/root/.pi/agent/auth.json`
|
||||
|
||||
Changes on the host take effect after the VM is restarted. Session/history directories are not copied.
|
||||
|
||||
From the host:
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue