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
|
|
@ -94,6 +94,10 @@ INITRD=""
|
|||
MISE_VERSION="v2025.12.0"
|
||||
MISE_INSTALL_PATH="/usr/local/bin/mise"
|
||||
MISE_ACTIVATE_LINE='eval "$(/usr/local/bin/mise activate bash)"'
|
||||
NODE_TOOL="node@22"
|
||||
CLAUDE_CODE_PACKAGE="@anthropic-ai/claude-code"
|
||||
PI_PACKAGE="@mariozechner/pi-coding-agent"
|
||||
NPM_GLOBAL_PREFIX="/root/.local/share/banger/npm-global"
|
||||
TMUX_PLUGIN_DIR="/root/.tmux/plugins"
|
||||
TMUX_RESURRECT_DIR="/root/.tmux/resurrect"
|
||||
TMUX_TPM_REPO="https://github.com/tmux-plugins/tpm"
|
||||
|
|
@ -399,14 +403,35 @@ fi
|
|||
apt-get update
|
||||
DEBIAN_FRONTEND=noninteractive apt-get -y upgrade
|
||||
DEBIAN_FRONTEND=noninteractive apt-get -y install ${APT_PACKAGES_ESCAPED}
|
||||
curl -fsSL https://mise.run | MISE_INSTALL_PATH=\"$MISE_INSTALL_PATH\" MISE_VERSION=\"$MISE_VERSION\" sh
|
||||
\"$MISE_INSTALL_PATH\" use -g github:anomalyco/opencode
|
||||
\"$MISE_INSTALL_PATH\" reshim
|
||||
curl -fsSL https://mise.run | MISE_INSTALL_PATH="$MISE_INSTALL_PATH" MISE_VERSION="$MISE_VERSION" sh
|
||||
"$MISE_INSTALL_PATH" use -g "$NODE_TOOL"
|
||||
"$MISE_INSTALL_PATH" use -g github:anomalyco/opencode
|
||||
"$MISE_INSTALL_PATH" reshim
|
||||
if [[ ! -e /root/.local/share/mise/shims/node ]]; then
|
||||
echo 'node shim not found after mise install' >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -e /root/.local/share/mise/shims/npm ]]; then
|
||||
echo 'npm shim not found after mise install' >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -e /root/.local/share/mise/shims/opencode ]]; then
|
||||
echo 'opencode shim not found after mise install' >&2
|
||||
exit 1
|
||||
fi
|
||||
mkdir -p "$NPM_GLOBAL_PREFIX"
|
||||
NPM_CONFIG_PREFIX="$NPM_GLOBAL_PREFIX" /root/.local/share/mise/shims/npm install -g "$CLAUDE_CODE_PACKAGE" "$PI_PACKAGE"
|
||||
if [[ ! -e "$NPM_GLOBAL_PREFIX/bin/claude" ]]; then
|
||||
echo 'claude binary not found after npm install' >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -e "$NPM_GLOBAL_PREFIX/bin/pi" ]]; then
|
||||
echo 'pi binary not found after npm install' >&2
|
||||
exit 1
|
||||
fi
|
||||
ln -snf /root/.local/share/mise/shims/opencode /usr/local/bin/opencode
|
||||
ln -snf "$NPM_GLOBAL_PREFIX/bin/claude" /usr/local/bin/claude
|
||||
ln -snf "$NPM_GLOBAL_PREFIX/bin/pi" /usr/local/bin/pi
|
||||
mkdir -p /etc/profile.d
|
||||
cat > /etc/profile.d/mise.sh <<'MISEPROFILE'
|
||||
if [ -n \"\${BASH_VERSION:-}\" ] && [ -x \"$MISE_INSTALL_PATH\" ]; then
|
||||
|
|
|
|||
|
|
@ -332,7 +332,7 @@ EOF
|
|||
sudo chmod 0644 "$bashrc" "$bash_profile" "$profile_prompt"
|
||||
}
|
||||
|
||||
install_mise_and_opencode() {
|
||||
install_guest_tools() {
|
||||
local profile_mise="$ROOT_MOUNT/etc/profile.d/mise.sh"
|
||||
|
||||
sudo mkdir -p "$ROOT_MOUNT/etc/profile.d"
|
||||
|
|
@ -340,19 +340,37 @@ install_mise_and_opencode() {
|
|||
sudo install -m 0644 /etc/resolv.conf "$ROOT_MOUNT/etc/resolv.conf"
|
||||
fi
|
||||
|
||||
sudo env \
|
||||
HOME=/root \
|
||||
PATH=/usr/local/bin:/usr/bin:/bin \
|
||||
chroot "$ROOT_MOUNT" /bin/bash -se <<EOF
|
||||
sudo env HOME=/root PATH=/usr/local/bin:/usr/bin:/bin chroot "$ROOT_MOUNT" /bin/bash -se <<EOF
|
||||
set -euo pipefail
|
||||
curl -fsSL https://mise.run | MISE_INSTALL_PATH="$MISE_INSTALL_PATH" MISE_VERSION="$MISE_VERSION" sh
|
||||
"$MISE_INSTALL_PATH" use -g "$NODE_TOOL"
|
||||
"$MISE_INSTALL_PATH" use -g "$OPENCODE_TOOL"
|
||||
"$MISE_INSTALL_PATH" reshim
|
||||
if [[ ! -e /root/.local/share/mise/shims/node ]]; then
|
||||
echo "node shim not found after mise install" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -e /root/.local/share/mise/shims/npm ]]; then
|
||||
echo "npm shim not found after mise install" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -e /root/.local/share/mise/shims/opencode ]]; then
|
||||
echo "opencode shim not found after mise install" >&2
|
||||
exit 1
|
||||
fi
|
||||
mkdir -p "$NPM_GLOBAL_PREFIX"
|
||||
NPM_CONFIG_PREFIX="$NPM_GLOBAL_PREFIX" /root/.local/share/mise/shims/npm install -g "$CLAUDE_CODE_PACKAGE" "$PI_PACKAGE"
|
||||
if [[ ! -e "$NPM_GLOBAL_PREFIX/bin/claude" ]]; then
|
||||
echo "claude binary not found after npm install" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -e "$NPM_GLOBAL_PREFIX/bin/pi" ]]; then
|
||||
echo "pi binary not found after npm install" >&2
|
||||
exit 1
|
||||
fi
|
||||
ln -snf /root/.local/share/mise/shims/opencode /usr/local/bin/opencode
|
||||
ln -snf "$NPM_GLOBAL_PREFIX/bin/claude" /usr/local/bin/claude
|
||||
ln -snf "$NPM_GLOBAL_PREFIX/bin/pi" /usr/local/bin/pi
|
||||
EOF
|
||||
|
||||
cat <<'EOF' | sudo tee "$profile_mise" >/dev/null
|
||||
|
|
@ -387,7 +405,11 @@ MIRROR="https://repo-default.voidlinux.org"
|
|||
ARCH="x86_64"
|
||||
MISE_VERSION="v2025.12.0"
|
||||
MISE_INSTALL_PATH="/usr/local/bin/mise"
|
||||
NODE_TOOL="node@22"
|
||||
OPENCODE_TOOL="github:anomalyco/opencode"
|
||||
CLAUDE_CODE_PACKAGE="@anthropic-ai/claude-code"
|
||||
PI_PACKAGE="@mariozechner/pi-coding-agent"
|
||||
NPM_GLOBAL_PREFIX="/root/.local/share/banger/npm-global"
|
||||
GUESTNET_BOOTSTRAP_SCRIPT="$REPO_ROOT/internal/guestnet/assets/bootstrap.sh"
|
||||
GUESTNET_VOID_CORE_SERVICE="$REPO_ROOT/internal/guestnet/assets/void-core-service.sh"
|
||||
MODULES_DIR=""
|
||||
|
|
@ -556,8 +578,8 @@ configure_docker_bootstrap
|
|||
enable_docker_service
|
||||
normalize_root_shell
|
||||
configure_root_bash_prompt
|
||||
log "installing mise and opencode"
|
||||
install_mise_and_opencode
|
||||
log "installing guest tools"
|
||||
install_guest_tools
|
||||
install_opencode_service
|
||||
install_root_authorized_key
|
||||
sudo touch "$ROOT_MOUNT/etc/fstab" "$ROOT_MOUNT/etc/hostname"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue