From 4f9054fea161620ab890d13853bf474c31eff130 Mon Sep 17 00:00:00 2001 From: "Bernd (Hermes)" Date: Tue, 23 Jun 2026 07:01:15 +0200 Subject: [PATCH] =?UTF-8?q?fix(install.sh):=20MULTIROOM=5FAGENT=20conditio?= =?UTF-8?q?nal=20=E2=80=94=20numpy/faiss,=20room-map.json,=20systemd-Unit?= =?UTF-8?q?=20Environment=3D,=20OLLAMA=5FAPI=5FKEY?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.sh | 107 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 78 insertions(+), 29 deletions(-) diff --git a/install.sh b/install.sh index 5c4c1b8..e59ace3 100755 --- a/install.sh +++ b/install.sh @@ -380,13 +380,28 @@ perform_update() { # ── FIX: numpy/faiss im venv installieren ────────────────────── # Archivar braucht numpy + faiss für FAISS Phase-1 RoomIndex. - # Ohne diese Packages crasht der Import beim Gateway-Start. - if [ -f "$hermes_dir/venv/bin/pip" ]; then - "$hermes_dir/venv/bin/pip" install numpy faiss-cpu 2>&1 | tail -1 - elif [ -f "$hermes_dir/.venv/bin/pip" ]; then - "$hermes_dir/.venv/bin/pip" install numpy faiss-cpu 2>&1 | tail -1 + # Nur im Multi-Room-Agent-Modus nötig; Single-Room-Bot bleibt schlank. + if [ "$RC_MULTIROOM" = "true" ]; then + if [ -f "$hermes_dir/venv/bin/pip" ]; then + "$hermes_dir/venv/bin/pip" install numpy faiss-cpu 2>&1 | tail -1 + elif [ -f "$hermes_dir/.venv/bin/pip" ]; then + "$hermes_dir/.venv/bin/pip" install numpy faiss-cpu 2>&1 | tail -1 + fi fi - + + # ─── FIX: room-map.json bereitstellen (nur Multi-Room) ───────── + # room-map.json ist maschinenspezifisch; nur im Multi-Room-Modus + # deployen. Die vollständige Version wird vom RC-Skill-Onboarding + # nach dem Gateway-Start erstellt. + if [ "$RC_MULTIROOM" = "true" ]; then + local room_map_data_dir="$HOME/.hermes/hermes-agent/data" + mkdir -p "$room_map_data_dir" + if [ ! -f "$room_map_data_dir/room-map.json" ] && [ -f "$script_dir/templates/room-map.json" ]; then + cp "$script_dir/templates/room-map.json" "$room_map_data_dir/room-map.json" + msg room_map_deployed "$room_map_data_dir/room-map.json" + fi + fi + # Execute backend checks directly (Ollama check from lines 429-446) msg ollama_check if command -v ollama >/dev/null 2>&1; then @@ -554,16 +569,27 @@ perform_update_only() { # ── FIX: numpy/faiss im venv installieren ────────────────────── # Archivar braucht numpy + faiss für FAISS Phase-1 RoomIndex. - # Ohne diese Packages crasht der Import beim Gateway-Start. - if [ -f "$hermes_dir/venv/bin/pip" ]; then - "$hermes_dir/venv/bin/pip" install numpy faiss-cpu 2>&1 | tail -1 - elif [ -f "$hermes_dir/.venv/bin/pip" ]; then - "$hermes_dir/.venv/bin/pip" install numpy faiss-cpu 2>&1 | tail -1 + # Nur im Multi-Room-Agent-Modus nötig; Single-Room-Bot bleibt schlank. + if [ "$RC_MULTIROOM" = "true" ]; then + if [ -f "$hermes_dir/venv/bin/pip" ]; then + "$hermes_dir/venv/bin/pip" install numpy faiss-cpu 2>&1 | tail -1 + elif [ -f "$hermes_dir/.venv/bin/pip" ]; then + "$hermes_dir/.venv/bin/pip" install numpy faiss-cpu 2>&1 | tail -1 + fi fi - # NOTE: room-map.json is MACHINE-SPECIFIC — never deployed - # by --update-only. It is created by the RC-Skill onboarding - # flow after gateway start. See RC-Skill: "Room Topic Discipline" + # ─── FIX: room-map.json bereitstellen (nur Multi-Room) ───────── + # room-map.json ist maschinenspezifisch; nur im Multi-Room-Modus + # deployen. Die vollständige Version wird vom RC-Skill-Onboarding + # nach dem Gateway-Start erstellt. + if [ "$RC_MULTIROOM" = "true" ]; then + local room_map_data_dir="$HOME/.hermes/hermes-agent/data" + mkdir -p "$room_map_data_dir" + if [ ! -f "$room_map_data_dir/room-map.json" ] && [ -f "$script_dir/templates/room-map.json" ]; then + cp "$script_dir/templates/room-map.json" "$room_map_data_dir/room-map.json" + msg room_map_deployed "$room_map_data_dir/room-map.json" + fi + fi # 5. Restart gateway (mit State-Cleanup gegen Discovery-Bug + Auto-Resume-Loop) msg restarting @@ -862,22 +888,26 @@ msg cache_cleared # ── FIX: numpy/faiss im venv installieren ────────────────────── # Archivar braucht numpy + faiss für FAISS Phase-1 RoomIndex. -# Ohne diese Packages crasht der Import beim Gateway-Start. -if [ -f "$HERMES_DIR/venv/bin/pip" ]; then - "$HERMES_DIR/venv/bin/pip" install numpy faiss-cpu 2>&1 | tail -1 -elif [ -f "$HERMES_DIR/.venv/bin/pip" ]; then - "$HERMES_DIR/.venv/bin/pip" install numpy faiss-cpu 2>&1 | tail -1 +# Nur im Multi-Room-Agent-Modus nötig; Single-Room-Bot bleibt schlank. +if [ "$RC_MULTIROOM" = "true" ]; then + if [ -f "$HERMES_DIR/venv/bin/pip" ]; then + "$HERMES_DIR/venv/bin/pip" install numpy faiss-cpu 2>&1 | tail -1 + elif [ -f "$HERMES_DIR/.venv/bin/pip" ]; then + "$HERMES_DIR/.venv/bin/pip" install numpy faiss-cpu 2>&1 | tail -1 + fi fi # ─── FIX: room-map.json bereitstellen ──────────────────────── -# Der Installer stellt eine minimale room-map.json ins Datenverzeichnis. +# room-map.json ist maschinenspezifisch; nur im Multi-Room-Modus deployen. # Die vollständige, maschinen-spezifische Version wird vom RC-Skill- # Onboarding-Flow nach dem Gateway-Start erstellt. -ROOM_MAP_DATA_DIR="$HOME/.hermes/hermes-agent/data" -mkdir -p "$ROOM_MAP_DATA_DIR" -if [ ! -f "$ROOM_MAP_DATA_DIR/room-map.json" ] && [ -f "$SCRIPT_DIR/templates/room-map.json" ]; then - cp "$SCRIPT_DIR/templates/room-map.json" "$ROOM_MAP_DATA_DIR/room-map.json" - msg room_map_deployed "$ROOM_MAP_DATA_DIR/room-map.json" +if [ "$RC_MULTIROOM" = "true" ]; then + ROOM_MAP_DATA_DIR="$HOME/.hermes/hermes-agent/data" + mkdir -p "$ROOM_MAP_DATA_DIR" + if [ ! -f "$ROOM_MAP_DATA_DIR/room-map.json" ] && [ -f "$SCRIPT_DIR/templates/room-map.json" ]; then + cp "$SCRIPT_DIR/templates/room-map.json" "$ROOM_MAP_DATA_DIR/room-map.json" + msg room_map_deployed "$ROOM_MAP_DATA_DIR/room-map.json" + fi fi # ─── Fix #9: Provision minimal config.yaml + .env ────────── @@ -902,13 +932,24 @@ fi if [ ! -f "$ENVFILE" ] && [ -f "$SCRIPT_DIR/templates/.env" ]; then cp "$SCRIPT_DIR/templates/.env" "$ENVFILE" chmod 600 "$ENVFILE" - # OLLAMA_API_KEY ersetzen falls gesetzt - if [ -n "${OLLAMA_API_KEY:-}" ]; then - sed -i "s|PLACEHOLDER_OLLAMA_API_KEY|${OLLAMA_API_KEY}|g" "$ENVFILE" - fi msg env_provisioned fi +# ─── Fix #9b: OLLAMA_API_KEY in ~/.hermes/.env persistieren ─ +# Secret gehört NICHT in die systemd-Unit, sondern in die .env-Datei. +if [ -n "${OLLAMA_API_KEY:-}" ]; then + mkdir -p "$HERMES_HOME" + touch "$ENVFILE" + chmod 600 "$ENVFILE" + if grep -q "^OLLAMA_API_KEY=" "$ENVFILE" 2>/dev/null; then + # Bestehenden Wert ersetzen (Inline, ohne Backups) + sed -i "s|^OLLAMA_API_KEY=.*|OLLAMA_API_KEY=${OLLAMA_API_KEY}|" "$ENVFILE" + else + # Neu anhängen + echo "OLLAMA_API_KEY=${OLLAMA_API_KEY}" >> "$ENVFILE" + fi +fi + # ─── Patch config.yaml ──────────────────────────────────── if [ -f "$CONFIG" ]; then # Ensure rocketchat-platform is in plugins.enabled @@ -947,6 +988,14 @@ UNIT_FILE="$HOME/.config/systemd/user/hermes-gateway.service" if [ -f "$UNIT_FILE" ]; then # Replace ExecStart to use "gateway run" instead of "run_agent.py gateway" sed -i 's|ExecStart=.*|ExecStart='"$PYTHON"' -m hermes_cli.main gateway run|' "$UNIT_FILE" + # Multi-Room-Flag als Environment-Variable in der Unit setzen + if [ "$RC_MULTIROOM" = "true" ]; then + if ! grep -q "^Environment=MULTIROOM_AGENT=" "$UNIT_FILE" 2>/dev/null; then + sed -i '/^ExecStart=.*/a Environment=MULTIROOM_AGENT=true' "$UNIT_FILE" + else + sed -i 's|^Environment=MULTIROOM_AGENT=.*|Environment=MULTIROOM_AGENT=true|' "$UNIT_FILE" + fi + fi systemctl --user daemon-reload 2>/dev/null || true fi