fix(install.sh): MULTIROOM_AGENT conditional — numpy/faiss, room-map.json, systemd-Unit Environment=, OLLAMA_API_KEY

This commit is contained in:
Bernd (Hermes)
2026-06-23 07:01:15 +02:00
parent 8760d29036
commit 4f9054fea1
+65 -16
View File
@@ -380,12 +380,27 @@ 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.
# 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
@@ -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.
# 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
# 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
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
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