Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9be9e616d1 | |||
| bc7b05d768 | |||
| 6f47885b1c | |||
| 572bc89205 | |||
| 54de0d1b69 | |||
| 868ee153ac | |||
| 40563864ac | |||
| 5c8026c0f0 | |||
| 52dd470e00 | |||
| a442e42b4e |
+89
-6
@@ -13,6 +13,7 @@ CHECK_ONLY=false
|
||||
UPDATE_MODE=false
|
||||
UPDATE_ONLY=false
|
||||
UPDATE_AVAILABLE=false
|
||||
RC_MULTIROOM="false"
|
||||
|
||||
# ─── Language packs ─────────────────────────────────────────
|
||||
declare -A T
|
||||
@@ -38,6 +39,8 @@ load_lang() {
|
||||
[enter_botuser]="Bot Username (the bot account on the Rocket.Chat server)"
|
||||
[enter_botpass]="Bot Password"
|
||||
[enter_channel]="Home Channel (name or room ID, e.g. #ki-assistent or 69f4e…)"
|
||||
[multiroom_ask]="Enable multi-room agent? (y/N)"
|
||||
[multiroom_warn]="⚠️ Multi-room agent requires significant system resources:\n - Local Ollama with embedding model (nomic-embed-text, ~274 MB)\n - FAISS vector index (CPU/RAM)\n - LLM router (e.g. qwen2.5:7b, ~4.7 GB)\n - Recommended: min. 16 GB RAM, 4 CPU cores\n - Without these resources: choose single-room mode (default N)"
|
||||
[current_val]=" Current: %s"
|
||||
[new_val]=" → "
|
||||
[summary]="📋 Configuration Summary:"
|
||||
@@ -94,6 +97,8 @@ load_lang() {
|
||||
[enter_botuser]="Bot Username (der Bot-Account auf dem Rocket.Chat Server)"
|
||||
[enter_botpass]="Bot Passwort"
|
||||
[enter_channel]="Home Channel (Name oder Raum-ID, z.B. #ki-assistent oder 69f4e…)"
|
||||
[multiroom_ask]="Multi-Room-Agent aktivieren? (y/N)"
|
||||
[multiroom_warn]="⚠️ Multi-Room-Agent benötigt erhebliche Systemressourcen:\n - Lokales Ollama mit Embedding-Modell (nomic-embed-text, ~274 MB)\n - FAISS-Vektorindex (CPU/RAM)\n - LLM-Router (z.B. qwen2.5:7b, ~4.7 GB)\n - Empfohlen: mind. 16 GB RAM, 4 CPU-Kerne\n - Ohne diese Ressourcen: Single-Room-Modus wählen (Default N)"
|
||||
[current_val]=" Aktuell: %s"
|
||||
[new_val]=" → "
|
||||
[summary]="📋 Zusammenfassung der Konfiguration:"
|
||||
@@ -334,7 +339,7 @@ perform_update() {
|
||||
hermes_dir=$(find_hermes_dir 2>/dev/null || echo "")
|
||||
|
||||
if [ -n "$hermes_dir" ]; then
|
||||
local plugin_dir="$hermes_dir/plugins/platforms/rocketchat"
|
||||
local plugin_dir="$hermes_dir/plugins/rocketchat"
|
||||
local config_file="$HOME/.hermes/config.yaml"
|
||||
local env_file="$HOME/.config/hermes/rocketchat.env"
|
||||
create_backup "$backup_file" "$plugin_dir" "$config_file" "$env_file"
|
||||
@@ -347,7 +352,7 @@ perform_update() {
|
||||
git pull origin main 2>&1 || { update_error="Failed to pull from origin main"; return 1; }
|
||||
|
||||
# Copy plugin files directly (lines 448-466)
|
||||
PLUGIN_DST="$hermes_dir/plugins/platforms/rocketchat"
|
||||
PLUGIN_DST="$hermes_dir/plugins/rocketchat"
|
||||
mkdir -p "$PLUGIN_DST"
|
||||
|
||||
# Rekursiv kopieren (inkl. Submodule wie archivar/), __pycache__ ausschließen
|
||||
@@ -363,11 +368,25 @@ perform_update() {
|
||||
copied_count=$(find "$script_dir/plugin" -type f ! -path '*/__pycache__/*' ! -name '*.pyc' | wc -l)
|
||||
msg copied "$copied_count"
|
||||
|
||||
# Symlink for core plugin loader: archivar must be importable as top-level module
|
||||
if [ -d "$PLUGIN_DST/plugin/archivar" ]; then
|
||||
ln -sfn "$PLUGIN_DST/plugin/archivar" "$hermes_dir/archivar"
|
||||
fi
|
||||
|
||||
# NOTE: room-map.json is MACHINE-SPECIFIC — never deployed
|
||||
# by the installer. It is created by the RC-Skill onboarding
|
||||
# flow after gateway start. See RC-Skill: "Room Topic Discipline"
|
||||
fi
|
||||
|
||||
# ── 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
|
||||
fi
|
||||
|
||||
# Execute backend checks directly (Ollama check from lines 429-446)
|
||||
msg ollama_check
|
||||
if command -v ollama >/dev/null 2>&1; then
|
||||
@@ -463,7 +482,7 @@ perform_update_only() {
|
||||
|
||||
# 2. Backup current state
|
||||
local backup_file="/tmp/hermes-rocketchat-backup-$(date +%s).tar.gz"
|
||||
local plugin_dir="$hermes_dir/plugins/platforms/rocketchat"
|
||||
local plugin_dir="$hermes_dir/plugins/rocketchat"
|
||||
if [ -d "$plugin_dir" ]; then
|
||||
create_backup "$backup_file" "$plugin_dir" \
|
||||
"$HOME/.hermes/config.yaml" \
|
||||
@@ -472,7 +491,7 @@ perform_update_only() {
|
||||
|
||||
# 3. Deploy all plugin files
|
||||
msg deploying
|
||||
local PLUGIN_DST="$hermes_dir/plugins/platforms/rocketchat"
|
||||
local PLUGIN_DST="$hermes_dir/plugins/rocketchat"
|
||||
mkdir -p "$PLUGIN_DST"
|
||||
|
||||
# GUARD 1: Syntax-Check VOR Deployment
|
||||
@@ -517,6 +536,11 @@ perform_update_only() {
|
||||
local copied_count
|
||||
copied_count=$(find "$script_dir/plugin" -type f ! -path '*/__pycache__/*' ! -name '*.pyc' | wc -l)
|
||||
msg deploy_done "$copied_count" "$PLUGIN_DST"
|
||||
|
||||
# Symlink for core plugin loader: archivar must be importable as top-level module
|
||||
if [ -d "$PLUGIN_DST/plugin/archivar" ]; then
|
||||
ln -sfn "$PLUGIN_DST/plugin/archivar" "$hermes_dir/archivar"
|
||||
fi
|
||||
else
|
||||
msg update_failed "plugin/ directory not found in $script_dir"
|
||||
return 1
|
||||
@@ -528,6 +552,15 @@ perform_update_only() {
|
||||
find "$PLUGIN_DST" -name '*.pyc' -delete 2>/dev/null || true
|
||||
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
|
||||
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"
|
||||
@@ -674,6 +707,7 @@ if $NONINTERACTIVE; then
|
||||
RC_BOT_USER="${RC_BOT_USER:-${ROCKETCHAT_USER:-}}"
|
||||
RC_BOT_PASS="${RC_BOT_PASS:-${ROCKETCHAT_PASSWORD:-}}"
|
||||
RC_HOME_CHANNEL="${RC_HOME_CHANNEL:-${ROCKETCHAT_ROOM_NAME:-}}"
|
||||
RC_MULTIROOM="${RC_MULTIROOM:-false}"
|
||||
if [ -z "$RC_URL" ] || [ -z "$RC_BOT_USER" ] || [ -z "$RC_BOT_PASS" ] || [ -z "$RC_HOME_CHANNEL" ]; then
|
||||
msg env_required; exit 1
|
||||
fi
|
||||
@@ -689,11 +723,22 @@ else
|
||||
confirm_or_edit RC_BOT_PASS enter_botpass ""
|
||||
confirm_or_edit RC_HOME_CHANNEL enter_channel "$RC_HOME_CHANNEL"
|
||||
|
||||
# Multi-Room-Agent: default N (Single-Room, community-tauglich)
|
||||
echo -e "${T[multiroom_warn]}"
|
||||
echo
|
||||
printf "%s" "${T[multiroom_ask]} "
|
||||
read -r multiroom_input
|
||||
case "${multiroom_input:-}" in
|
||||
y|Y|yes|ja|Yes|Ja|YES|JA) RC_MULTIROOM="true" ;;
|
||||
*) RC_MULTIROOM="false" ;;
|
||||
esac
|
||||
|
||||
echo
|
||||
msg summary
|
||||
echo " URL: $RC_URL"
|
||||
echo " Bot User: $RC_BOT_USER"
|
||||
echo " Home Channel: $RC_HOME_CHANNEL"
|
||||
echo " Multi-Room: $RC_MULTIROOM"
|
||||
echo
|
||||
fi
|
||||
|
||||
@@ -713,9 +758,10 @@ ROCKETCHAT_ALLOW_ALL_USERS=true
|
||||
GATEWAY_ALLOW_ALL_USERS=true
|
||||
ROCKETCHAT_PING_SEC=8
|
||||
ROCKETCHAT_IDLE_SEC=900
|
||||
RC_MULTIROOM=PLACEHOLDER_RC_MULTIROOM
|
||||
EOF
|
||||
# Ersetze Platzhalter mit python3 (sicher für $-Zeichen im Passwort)
|
||||
export RC_URL RC_BOT_USER RC_BOT_PASS RC_HOME_CHANNEL
|
||||
export RC_URL RC_BOT_USER RC_BOT_PASS RC_HOME_CHANNEL RC_MULTIROOM
|
||||
export ENV_FILE
|
||||
python3 -c "
|
||||
import os
|
||||
@@ -726,6 +772,7 @@ content = content.replace('PLACEHOLDER_RC_URL', os.environ.get('RC_URL', ''))
|
||||
content = content.replace('PLACEHOLDER_RC_USER', os.environ.get('RC_BOT_USER', ''))
|
||||
content = content.replace('PLACEHOLDER_RC_PASS', os.environ.get('RC_BOT_PASS', ''))
|
||||
content = content.replace('PLACEHOLDER_RC_CHANNEL', os.environ.get('RC_HOME_CHANNEL', ''))
|
||||
content = content.replace('PLACEHOLDER_RC_MULTIROOM', os.environ.get('RC_MULTIROOM', 'false'))
|
||||
with open(env_file, 'w') as f:
|
||||
f.write(content)
|
||||
"
|
||||
@@ -753,7 +800,7 @@ fi
|
||||
|
||||
# ─── Copy plugin files ────────────────────────────────────
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
PLUGIN_DST="$HERMES_DIR/plugins/platforms/rocketchat"
|
||||
PLUGIN_DST="$HERMES_DIR/plugins/rocketchat"
|
||||
mkdir -p "$PLUGIN_DST"
|
||||
|
||||
# GUARD 1: Syntax-Check VOR Deployment
|
||||
@@ -779,6 +826,11 @@ if [ -d "$SCRIPT_DIR/plugin" ]; then
|
||||
done < <(find "$SCRIPT_DIR/plugin" -type f ! -path '*/__pycache__/*' ! -name '*.pyc')
|
||||
copied_count=$(find "$SCRIPT_DIR/plugin" -type f ! -path '*/__pycache__/*' ! -name '*.pyc' | wc -l)
|
||||
msg copied "$copied_count"
|
||||
|
||||
# Symlink for core plugin loader: archivar must be importable as top-level module
|
||||
if [ -d "$PLUGIN_DST/plugin/archivar" ]; then
|
||||
ln -sfn "$PLUGIN_DST/plugin/archivar" "$HERMES_DIR/archivar"
|
||||
fi
|
||||
fi
|
||||
|
||||
# GUARD 2: Vollständigkeits-Check
|
||||
@@ -808,6 +860,26 @@ find "$PLUGIN_DST" -name '__pycache__' -type d -exec rm -rf {} + 2>/dev/null ||
|
||||
find "$PLUGIN_DST" -name '*.pyc' -delete 2>/dev/null || true
|
||||
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
|
||||
fi
|
||||
|
||||
# ─── FIX: room-map.json bereitstellen ────────────────────────
|
||||
# Der Installer stellt eine minimale room-map.json ins Datenverzeichnis.
|
||||
# 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"
|
||||
fi
|
||||
|
||||
# ─── Fix #9: Provision minimal config.yaml + .env ──────────
|
||||
# Only when hermes has NO config yet (fresh install, no setup run)
|
||||
HERMES_HOME="$HOME/.hermes"
|
||||
@@ -867,6 +939,17 @@ fi
|
||||
# Install / refresh systemd user service
|
||||
$PYTHON -m hermes_cli.main gateway install 2>/dev/null || true
|
||||
|
||||
# ─── Fix: overwrite generated unit to use "gateway run" ────
|
||||
# hermes_cli.main gateway install creates a unit with run_agent.py gateway
|
||||
# (AI-agent only, no platform adapter). For Rocket.Chat we NEED the full
|
||||
# gateway run (hermes_cli.main gateway run) which loads platform plugins.
|
||||
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"
|
||||
systemctl --user daemon-reload 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# ─── Fix #10: systemd EnvironmentFile drop-in ─────────────
|
||||
# Gateway needs rocketchat.env + .env — hermes gateway install
|
||||
# does not wire them automatically.
|
||||
|
||||
@@ -102,6 +102,8 @@ def is_connected(config) -> bool:
|
||||
|
||||
def register(ctx):
|
||||
"""Plugin entry point — called by the Hermes plugin system at startup."""
|
||||
_MULTIROOM = os.getenv("MULTIROOM_AGENT", "true").strip().lower() not in ("false", "0", "no", "off")
|
||||
|
||||
from .adapter import RocketChatAdapter # lazy import avoids circular deps
|
||||
from .tools import register_tools
|
||||
|
||||
|
||||
+37
-5
@@ -35,7 +35,12 @@ class RocketChatRateLimitError(Exception):
|
||||
_room_context: Dict[str, Dict[str, str]] = {} # chat_id → {thematic_target, origin_room}
|
||||
_room_context_lock = threading.Lock()
|
||||
|
||||
from archivar.adapter_integration import ArchivarMessageHandler
|
||||
def _MULTIROOM() -> bool:
|
||||
"""Laufzeit-Auswertung von MULTIROOM_AGENT (nicht beim Import, da .env via systemd EnvironmentFile erst später geladen wird)."""
|
||||
return os.getenv("MULTIROOM_AGENT", "true").strip().lower() not in ("false", "0", "no", "off")
|
||||
|
||||
if _MULTIROOM():
|
||||
from archivar.adapter_integration import ArchivarMessageHandler
|
||||
|
||||
# ── Access __init__ symbols (plugin loaded as flat module, no relative imports) ──
|
||||
import sys as _sys
|
||||
@@ -478,10 +483,13 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
self._last_ddp_ping_ok = False
|
||||
self._running = False
|
||||
# Archivar: Embedding-basierte Nachrichten-Klassifikation
|
||||
if _MULTIROOM():
|
||||
self.archivar = ArchivarMessageHandler(
|
||||
send_callback=self._send_via_archivar,
|
||||
button_send_callback=self._send_archivar_buttons,
|
||||
)
|
||||
else:
|
||||
self.archivar = None
|
||||
# User-Flow C: Move-Requests + Sticky Rooms
|
||||
self._pending_move_requests: Dict[str, dict] = {}
|
||||
self._sticky_rooms: Dict[str, float] = {} # room_id → timestamp
|
||||
@@ -592,6 +600,7 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
len(self._user_rooms),
|
||||
{k: f"{len(v)} rooms" for k, v in self._user_rooms.items()})
|
||||
# Archivar initialisieren (Embedding-basierte Klassifikation)
|
||||
if _MULTIROOM() and self.archivar is not None:
|
||||
try:
|
||||
await self.archivar.initialize()
|
||||
# Feed the actual subscribed room IDs to the router so it can
|
||||
@@ -704,10 +713,15 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
# Skip own messages (case-insensitive comparison)
|
||||
filter_match = (username == (self.user or "").lower())
|
||||
logger.debug("Filter check: username=%s, self.user=%s, match=%s", username, self.user, filter_match)
|
||||
if filter_match or not text or not room_id:
|
||||
if filter_match:
|
||||
logger.debug("[rocketchat] ARCHIVAR-DEBUG: Own message filtered — skipping")
|
||||
return
|
||||
if not text or not room_id:
|
||||
logger.debug("[rocketchat] ARCHIVAR-DEBUG: Empty text/room_id — skipping")
|
||||
return
|
||||
# Skip system messages
|
||||
if msg_obj.get("t"):
|
||||
logger.debug("[rocketchat] ARCHIVAR-DEBUG: System message (t=%s) — skipping", msg_obj.get("t"))
|
||||
return
|
||||
|
||||
logger.debug("Message passed filter: %s", msg_id)
|
||||
@@ -736,6 +750,7 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
parts = text.split(":", 2)
|
||||
if len(parts) != 3:
|
||||
logger.debug("[rocketchat] Unrecognized CLARIFY format: %s", text)
|
||||
logger.debug("[rocketchat] ARCHIVAR-DEBUG: CLARIFY unrecognized format — skipping")
|
||||
return
|
||||
_, clarify_id, choice = parts
|
||||
if choice == "other":
|
||||
@@ -743,6 +758,7 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
from tools.clarify_gateway import mark_awaiting_text
|
||||
mark_awaiting_text(clarify_id)
|
||||
logger.debug("[rocketchat] Clarify %s: awaiting text response from %s", clarify_id, username)
|
||||
logger.debug("[rocketchat] ARCHIVAR-DEBUG: CLARIFY other — awaiting text")
|
||||
# Don't process further - wait for the next text message
|
||||
return
|
||||
elif choice.isdigit():
|
||||
@@ -774,6 +790,7 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
except Exception as exc:
|
||||
logger.error("[rocketchat] resolve_gateway_clarify failed: %s", exc)
|
||||
# Don't route to agent — this was a button click
|
||||
logger.debug("[rocketchat] ARCHIVAR-DEBUG: CLARIFY resolved — skipping")
|
||||
return
|
||||
else:
|
||||
# Unknown token — let it fall through as regular text
|
||||
@@ -782,7 +799,7 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
logger.debug("[rocketchat] Error processing CLARIFY response: %s", e)
|
||||
|
||||
# Auto-Onboarding: Wenn onboarding_active, fange alle relevanten Antworten ab
|
||||
if self.archivar._stats.get("onboarding_active", False):
|
||||
if _MULTIROOM() and self.archivar is not None and self.archivar._stats.get("onboarding_active", False):
|
||||
stripped = text.strip()
|
||||
# Nur Nachrichten aus dem Operator-DM-Raum als Onboarding behandeln
|
||||
operator_room = self._onboarding_state.get("operator_room_id", "")
|
||||
@@ -798,6 +815,7 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
)
|
||||
if is_onboarding:
|
||||
await self._process_onboarding_response(text, room_id)
|
||||
logger.debug("[rocketchat] ARCHIVAR-DEBUG: Onboarding active — skipping")
|
||||
return # Nachricht wurde verarbeitet, keine weitere Verarbeitung nötig
|
||||
|
||||
# ── Move-Request-Antwort? (VOR Archivar-Klassifikation!) ────────
|
||||
@@ -851,13 +869,14 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
feedback_type = "stay"
|
||||
|
||||
# Lernsystem: Keyword-Gewichte aus User-Entscheidung lernen
|
||||
if move_req.get("message_id"):
|
||||
if _MULTIROOM() and self.archivar is not None and move_req.get("message_id"):
|
||||
user_id = user_info.get("_id", "")
|
||||
await self.archivar.handle_feedback_response(
|
||||
message_id=move_req["message_id"],
|
||||
user_id=user_id,
|
||||
feedback_type=feedback_type
|
||||
)
|
||||
logger.debug("[rocketchat] ARCHIVAR-DEBUG: Move-Request processed — skipping")
|
||||
return # Move-Request verarbeitet — keine weitere Verarbeitung
|
||||
|
||||
forwarded = False
|
||||
@@ -870,19 +889,33 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
decision = None
|
||||
is_auftrag = _is_auftrag(text)
|
||||
|
||||
logger.debug("[rocketchat] ARCHIVAR-DEBUG: Entering Archivar block — room_type=%s, is_auftrag=%s, _MULTIROOM=%s, archivar=%s", room_type, is_auftrag, _MULTIROOM(), self.archivar is not None)
|
||||
|
||||
try:
|
||||
if _MULTIROOM() and self.archivar is not None:
|
||||
if is_button_response or room_id in self._rooms_with_pending_questions:
|
||||
if not is_button_response:
|
||||
logger.debug("[rocketchat] Room %s had pending question — Archivar bypassed", room_id)
|
||||
logger.debug("[rocketchat] ARCHIVAR-DEBUG: Archivar bypassed — pending_questions")
|
||||
self._rooms_with_pending_questions.discard(room_id)
|
||||
elif room_id in self._sticky_rooms:
|
||||
logger.debug("[rocketchat] Room %s is sticky — Archivar bypassed", room_id[:8])
|
||||
logger.debug("[rocketchat] ARCHIVAR-DEBUG: Archivar bypassed — sticky_room=%s", room_id[:8])
|
||||
elif room_type == "d" and is_auftrag:
|
||||
logger.debug("[rocketchat] DM-Auftrag von %s — kein Routing", username)
|
||||
logger.debug("[rocketchat] ARCHIVAR-DEBUG: Archivar bypassed — DM-Auftrag")
|
||||
else:
|
||||
logger.debug("[rocketchat] ARCHIVAR-DEBUG: Calling classify_and_route for room=%s", room_id[:12])
|
||||
decision = await self.archivar.classify_and_route(text, origin_room_id=room_id)
|
||||
if decision and decision.category:
|
||||
category = decision.category
|
||||
# Wenn Zielraum = Ursprungsraum → stay_in_room, kein Move-Request
|
||||
# MUSS VOR _THEMATIC_TARGET_ROOM.set() kommen, sonst wird
|
||||
# der Zielraum gesetzt und send() routet in den DM
|
||||
if (hasattr(decision, 'target_room') and decision.target_room
|
||||
and decision.target_room == room_id):
|
||||
decision.stay_in_room = True
|
||||
decision.move_request_sent = False
|
||||
# ── Archivar-Kontext-Weitergabe: Zielraum + Frage-Nr ──────
|
||||
if hasattr(decision, 'target_room') and decision.target_room:
|
||||
_THEMATIC_TARGET_ROOM.set(decision.target_room)
|
||||
@@ -916,7 +949,6 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
logger.warning("[rocketchat] Archivar classify_and_route() timed out")
|
||||
with _question_counter_lock:
|
||||
_question_counter += 1
|
||||
# _THEMATIC_TARGET_ROOM bleibt leer → Prompt sagt "Timeout"
|
||||
except Exception as e:
|
||||
logger.debug("[rocketchat] Archivar classification skipped: %s", e)
|
||||
|
||||
|
||||
@@ -93,13 +93,6 @@ except ImportError:
|
||||
from .seed_data import SEED_DATA
|
||||
from .feedback_detector import RoutingWiderspruchDetector, ContradictionResult
|
||||
|
||||
# ── _room_context import from adapter.py ─────────────────────────────
|
||||
# Needed by handle_feedback_response to clear thematic_target on 'stay'.
|
||||
try:
|
||||
from adapter import _room_context, _room_context_lock
|
||||
except ImportError:
|
||||
from ..adapter import _room_context, _room_context_lock
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.setLevel(logging.INFO)
|
||||
# Ensure adapter_integration logs are visible by adding a stderr handler
|
||||
@@ -898,6 +891,12 @@ class ArchivarMessageHandler:
|
||||
# geleert werden, damit der nächste Send nicht auf den falschen
|
||||
# (Archivar-vorgeschlagenen) Zielraum fällt.
|
||||
if feedback_type == "stay" and username:
|
||||
# Lazy import to break circular dependency with adapter.py
|
||||
try:
|
||||
from adapter import _room_context, _room_context_lock
|
||||
except ImportError:
|
||||
from ..adapter import _room_context, _room_context_lock
|
||||
|
||||
virtual_chat_id = f"user:{username}"
|
||||
with _room_context_lock:
|
||||
ctx = _room_context.setdefault(virtual_chat_id, {})
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"version": 1,
|
||||
"rooms": {},
|
||||
"excluded_rooms": [],
|
||||
"fact_store_path": "/data/Wissensdatenbank/0100 Inbox"
|
||||
}
|
||||
Reference in New Issue
Block a user