#!/usr/bin/env bash # homeai-visual/setup.sh — P7: VTube Studio Expression Bridge # # Sets up: # - Python venv with websockets # - vtube-bridge daemon (HTTP ↔ WebSocket bridge) # - vtube-ctl CLI (symlinked to PATH) # - launchd service # # Prerequisites: # - P4 (homeai-agent) — OpenClaw running # - P5 (homeai-character) — aria.json with live2d_expressions set # - VTube Studio installed (Mac App Store) with WebSocket API enabled set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" REPO_DIR="$(cd "${SCRIPT_DIR}/.." && pwd)" source "${REPO_DIR}/scripts/common.sh" VENV_DIR="$HOME/homeai-visual-env" PLIST_SRC="${SCRIPT_DIR}/launchd/com.homeai.vtube-bridge.plist" PLIST_DST="$HOME/Library/LaunchAgents/com.homeai.vtube-bridge.plist" VTUBE_CTL_SRC="$HOME/.openclaw/skills/vtube-studio/scripts/vtube-ctl" log_section "P7: VTube Studio Expression Bridge" # ─── Python venv ────────────────────────────────────────────────────────────── if [[ ! -d "$VENV_DIR" ]]; then log_info "Creating Python venv at $VENV_DIR..." python3 -m venv "$VENV_DIR" fi log_info "Installing dependencies..." "$VENV_DIR/bin/pip" install --upgrade pip -q "$VENV_DIR/bin/pip" install websockets -q log_ok "Python venv ready ($(${VENV_DIR}/bin/python3 --version))" # ─── vtube-ctl symlink ─────────────────────────────────────────────────────── if [[ -f "$VTUBE_CTL_SRC" ]]; then chmod +x "$VTUBE_CTL_SRC" ln -sf "$VTUBE_CTL_SRC" /opt/homebrew/bin/vtube-ctl log_ok "vtube-ctl symlinked to /opt/homebrew/bin/vtube-ctl" else log_warn "vtube-ctl not found at $VTUBE_CTL_SRC — skipping symlink" fi # ─── launchd service ───────────────────────────────────────────────────────── if [[ -f "$PLIST_SRC" ]]; then # Unload if already loaded launchctl bootout "gui/$(id -u)/com.homeai.vtube-bridge" 2>/dev/null || true cp "$PLIST_SRC" "$PLIST_DST" launchctl bootstrap "gui/$(id -u)" "$PLIST_DST" log_ok "launchd service loaded: com.homeai.vtube-bridge" else log_warn "Plist not found at $PLIST_SRC — skipping launchd setup" fi # ─── Status ────────────────────────────────────────────────────────────────── echo "" log_info "VTube Bridge setup complete." log_info "" log_info "Next steps:" log_info " 1. Install VTube Studio from Mac App Store" log_info " 2. Enable WebSocket API: Settings > WebSocket API > port 8001" log_info " 3. Load a Live2D model" log_info " 4. Create expression hotkeys (idle, listening, thinking, speaking, happy, sad, surprised, error)" log_info " 5. Run: vtube-ctl auth (click Allow in VTube Studio)" log_info " 6. Run: python3 ${SCRIPT_DIR}/scripts/test-expressions.py --all" log_info " 7. Update aria.json with real hotkey UUIDs" log_info "" log_info "Logs: /tmp/homeai-vtube-bridge.log" log_info "Bridge: http://localhost:8002/status"