Commit Graph

184 Commits

Author SHA1 Message Date
Hermes Agent ffb7cafff6 fix(archivar): Move-Request NICHT returnen — Originaltext an Agent durchreichen
Kritischer Bug: Nach 'Hier bleiben'/'Generell hier bleiben' wurde return
aufgerufen → der Original-Auftragstext ging verloren, nur '3' erreichte
den Agenten → Agent antwortete verwirrt.

Jetzt: Originaltext aus move_req['text'] wiederherstellen, skip_archivar=True
setzen, als normale Nachricht durchreichen. Der Agent verarbeitet den Auftrag
normal weiter — der User hat nur das Routing entschieden.
2026-06-08 16:05:55 +02:00
Hermes Agent 62c996c4da fix(archivar): Move-Request vor Archivar, room-basiert, numerische Antworten
Drei kritische Bugs behoben:
1. Move-Request-Prüfung VOR Archivar-Klassifikation — '3' wurde vorher als
   thematische Frage ins Catch-All kopiert, jetzt wird die Antwort erkannt
2. _pending_move_requests von msg_id auf room_id umgestellt — jede Antwort
   mit neuer msg_id schlug vorher fehl
3. Numerische Antworten (1/2/3) werden jetzt direkt erkannt, nicht nur
   Text-Matches ('rüberkopieren'/'hier bleiben'/'generell')
2026-06-08 15:53:51 +02:00
Hermes Agent f47ffc93f4 fix(archivar): Raum-Name-Fallback + nummerierte Optionen statt Buttons
- Bug 1: 'Zielraum' als Platzhalter → jetzt 3-Stufen-Fallback (matched_room_name → room_info → room_map → ID-Fragment)
- Bug 2: Native Buttons existieren nicht im Adapter → nummerierte Text-Optionen (1/2/3)
2026-06-08 14:32:31 +02:00
Hermes Agent e7ed81c189 fix: send() method structure — restore button-parsing + REST-post code that fell out of method body
The send() method in adapter.py had a structural defect where the
button-parsing, template-handling, and rest.post_message code (98 lines)
was at module level instead of inside the send() method body.

send() ended after room-resolution without a return statement, causing
it to return None. _send_with_retry() in base.py then crashed with
AttributeError: 'NoneType' object has no attribute 'success'.

This made every Rocket.Chat response silently fail — the agent
processed messages but could never deliver replies.

Fix: moved the orphaned code block back into the send() method body
where it belongs, after the room-resolution logic and before
_find_fallback_room_for_user.
2026-06-08 11:33:59 +02:00
Hermes Agent 83a5d262c7 fix: User-Map-Fallback + LLM-Prompt-Fix
- User-Map: Fallback aus DM-Namen-Parsing + REST-API-Abfrage wenn usernames-Feld fehlt (Rainer)
- LLM: max_tokens 10→5, Prompt verschärft auf Ein-Wort-Antwort (Raum-Name oder CATCH_ALL)
- Keine Erklärungen, keine Sätze — der Validator akzeptiert jetzt alle Antworten
- Vault-Doku: Rocket.Chat Plugin.md aktualisiert (User-Flow C, Bugfixes)
2026-06-08 07:40:04 +02:00
Hermes Agent af56280ebc fix(archivar): User-Flow C — Antwort bleibt im Ursprungsraum, Nachricht wird kopiert
DM-Aufträge werden nie geroutet. Bei thematischen Fragen: Silent Copy.
Bei Aufträgen: Buttons [Ja, rüberkopieren] [Hier bleiben] [Generell hier bleiben].

Architektur-Skizze: docs/archivar-user-flow-c.md
2026-06-08 06:44:40 +02:00
Hermes Agent 5e9c4ece77 fix(adapter): button clicks bypass Archivar routing
Button responses (`is_button_response`) are ALWAYS direct replies to an agent
question and carry a `question_id::choice` payload. Routing them through the
Archivar risked landing a one-character "A" in the catch-all room where the
agent would see it without the original question context.

Now button clicks skip `classify_and_route()` entirely and stay in whatever
room they originated from.
2026-06-06 20:43:36 +02:00
Hermes Agent ad852c1642 fix(archivar): doc_store writes to fact_store_path from room_map
DocumentationStore() now uses RoomMap.fact_store_path instead of the
hardcoded ~/.hermes/.../archivar_docs default. One-line change — the
doc_store is initialized after _load_room_map() so room_map is available.

This allows per-deployment configuration: in production, fact_store_path
points to /data/Wissensdatenbank/0100 Inbox so FAKT messages land in the
Obsidian vault's inbox for StartObsidian integration.
2026-06-06 20:32:13 +02:00
Hermes Agent 7140da3154 feat(onboarding): catch-all change via numeric answer, generic example
- Trigger now catches 'Name = Thema', '#Name', 'Raum:', digits, skip words
- After onboarding: numbered room list with Catch-All marker
- User can change Catch-All by replying with room number
- 'überspringen'/'skip' keeps current Catch-All
- Example text is generic (not project-specific): 'Projektraum = Entwicklung, ...'
2026-06-06 20:03:04 +02:00
Hermes Agent 72e8c8cb90 fix(onboarding): generic example, numbered rooms, catch-all change prompt
- Example text: 'Projektraum = Entwicklung, Code-Reviews, ...' (not project-specific)
- Onboarding prompt: numbered list (1. Raum, 2. Raum, ...)
- After completion: shows all rooms with Catch-All marker, asks if change wanted
2026-06-06 20:01:02 +02:00
Hermes Agent ddc69167c1 fix(onboarding): remove # from display to prevent RC link rendering
- Onboarding message shows room names WITHOUT # (RC auto-links them)
- Parser accepts both 'Name' and '#Name' (case-insensitive match)
- Pattern: #? makes hash optional, matching against lstrip(#)
2026-06-06 19:58:31 +02:00
Hermes Agent 7d454f62b6 fix(onboarding): parse #Name = Thema format, auto-derive keywords, fix newlines
- Parser accepts '#Name = Thema' (no 'Raum:' prefix needed)
- _derive_keywords() extracts keywords from room name + theme
- Onboarding message uses real newlines (join list, not \n literals)
- Shows actual missing room names with '=' prompt, plus example
2026-06-06 19:51:34 +02:00
Hermes Agent 8591933d8d feat(archivar): auto-onboarding — room-map completeness check after gateway start
Implements the RC-Skill's promised room-map completeness check after
Adapter.connect(). Previously the adapter subscribed to rooms but never
verified they were all present in room-map.json. New rooms were
subscribed but invisible to the Archivar router.

Scope (~450 lines, 4 files):

- adapter_integration.py: check_room_map_completeness() compares
  subscribed rooms (filtered to c/p types) against RoomMap.
  Single-Room-Regel: 1 relevant room → auto catch_all, no interview.
  onboarding_active flag in _stats prevents re-triggering.

- room_map.py: add_or_update_room() for safe in-memory mutations,
  reload() for disk-to-memory sync without gateway restart,
  static save() for atomic file writes.

- adapter.py: connect() calls check after Archivar init, triggers
  _start_onboarding() if rooms missing. _process_incoming() intercepts
  'Raum: #Name = Thema' responses during active onboarding.

- test_auto_onboarding.py: 4 unit tests covering single-room
  auto-assign, multi-room detection, DM filtering, and already-
  complete map (no action).

Deployed to production: adapter.py + archivar/*.py copied to
Auslieferungspfad. Gateway restarted — no onboarding triggered
(map already complete).
2026-06-06 19:31:46 +02:00
Hermes Agent 63e0616d7a docs(architektur): auto-onboarding skizze — single-room regel ergänzt 2026-06-06 19:18:58 +02:00
Hermes Agent 3f480d5423 chore: add __pycache__/ to gitignore 2026-06-06 19:15:39 +02:00
Hermes Agent 4d35669174 fix: prevent room-map.json overwrite + is_unrouteable handler
ROOT CAUSE: install.sh --update-only blindly deployed room-map.json
from the repo (containing 'GENERAL' as catch_all) to the production
/home/bernd/.hermes/data/ directory, overwriting the machine-specific map.

FIXES (3 changes):

1. REMOVED room-map.json from repo + added to .gitignore
   This file is machine-specific data, not source code.

2. REMOVED room-map.json deploy from install.sh (both paths):
   - Normal install block (section 3.5)
   - --update-only emergency deploy (section 3.5)
   Replaced with comment: 'MACHINE-SPECIFIC — created by RC-Skill onboarding'

3. FIX adapter.py: is_unrouteable guard on ContextVar routing
   Before: ContextVar set to target_room even when unrouteable
   Result: 'Ich antworte im Zielraum.' note appeared, but Hermes
   couldn't deliver to unsubscribed room — answer lost silently.
   After: Forward block checks not getattr(decision, 'is_unrouteable', False)
   If unrouteable → stays in origin room, answers there normally.

PRODUCTION: Correct room-map.json deployed with 4 project rooms
+ DM catch_all on .101. Excluded rooms: multi-agent DM, testbot DM.
2026-06-06 18:53:11 +02:00
Hermes Agent 024a173c8d Fix Archivar forward note bug: Use rest.post_message() instead of self.send() to ensure note appears in origin room 2026-06-06 09:11:41 +02:00
Hermes Agent e3f9ee31f4 feat(archivar): Route-Antwort in Zielraum + Notiz im Ursprungsraum 2026-06-06 08:42:11 +02:00
Hermes Agent 1fca310228 feat(archivar): use handle_and_forward() in _process_incoming
Ersetzt classify_and_route() durch handle_and_forward().
Nachrichten werden jetzt klassifiziert UND automatisch in den
Zielraum kopiert, wenn target_room != origin_room.

send_callback ist bereits im ArchivarMessageHandler-Konstruktor
gesetzt (adapter.py:416).
2026-06-06 06:33:26 +02:00
Hermes Agent c98228ef6f fix(archivar): pass origin_room_id to classify_and_route()
Ohne diesen Parameter kann der Router:
- Multi-Agent-Raum nicht ausschließen (Schritt 0)
- Herkunft nicht in LLM-Room-Lookup einbeziehen
- Keine korrekte Catch-All-Validierung durchführen

Adapter hat room_id in _process_incoming() bereits verfügbar.
2026-06-06 06:30:20 +02:00
Hermes Agent 1afa822e6f Task 5: Neuen test_router.py mit 2 Integrationstests erstellt 2026-06-06 06:14:58 +02:00
Hermes Agent 06567d3988 Task 4: test_room_map.py um 2 LLM-Lookup-Tests erweitert 2026-06-06 06:14:56 +02:00
Hermes Agent 54a19a039d Task 3: Deprecated marker für LLM_CLASSIFY_PROMPT in config.py hinzugefügt 2026-06-06 06:14:52 +02:00
Hermes Agent 527d664a07 Task 2: Logtext in adapter.py auf "Thematischer Raum-Router aktiv (room-map.json)" geändert 2026-06-06 06:14:49 +02:00
Hermes Agent 9bc06ef858 Task 1: LLM_CONFIDENCE_THRESHOLD-Zweig entfernt und durch einfaches Return des Embedding-Ergebnisses ersetzt 2026-06-06 06:14:45 +02:00
Hermes Agent 58f00c0c23 feat(archivar): Phase 1-3 — RoomMap + thematischer Router
Phase 1 (Datenmodell):
- plugin/archivar/room_map.py: RoomMap, RoomEntry, RoomMapValidationError
- room-map.schema.json: JSON-Schema für room-map.json
- room-map.json: Echte Raum-IDs (RC, BAT, LAN-Doku, DM Andreas)
- config.py: LLM_ROOM_PROMPT, ROOM_MAP_PATH, deprecated-Marker

Phase 2 (Router-Umbau):
- router.py: MessageRouter nutzt RoomMap statt ROOM_MAPPING Env-Vars
  - Neue Methode _llm_room_lookup() fragt LLM: 'In welchen Raum?'
  - Keyword-Match aus RoomEntry.keywords (vor Embedding)
  - Excluded rooms check via RoomMap.is_excluded()
  - origin_room_id Parameter für Multi-Agent-Raum-Ausschluss

Phase 3 (Integration):
- adapter_integration.py: _load_room_map() mit Env-Var-Fallback
  - validate() beim Gateway-Start
  - classify_and_route() reicht origin_room_id durch
- classifier.py: _llm_raw_sync() für Room-Prompts (nicht Kategorien)

12/12 Unit-Tests bestanden ✅
2026-06-05 22:06:32 +02:00
Hermes Agent 1bb3f52fad docs: Menschlicher Override ergänzt (Archivar-Architektur §6)
!r <raum> Reply-Mechanismus für Admin-Korrektur:
- Erkennt fehlgeleitete Nachrichten, löscht Original, verschiebt
- Lernt aus Overrides: keyword_overrides in room-map.json
- 3× gleiches Keyword-Muster → permanenter Override
- Höchste Keyword-Priorität im Datenfluss
- 5 Sicherheitsregeln (Admin-only, keine Selbst-Overrides, etc.)

Checkliste um 5 Override-Review-Punkte erweitert.
2026-06-05 21:36:02 +02:00
Hermes Agent 65a3baa3e5 docs: Architekturskizze Archivar-Umbau (Kategorien-Klassifikator → thematischer Router)
3 Architekturentscheidungen getroffen:
- L1: room-map.json als Single Source of Truth (JSON, ~/.hermes/hermes-agent/data/)
- L2: FATAL-Validierung bei Gateway-Start (0/>1 Catch-All)
- L3: Onboarding als separates Plugin-Tool (nicht im Archivar-Modul)

Enthält: Datenmodell (RoomMap, RoomEntry, RoomRouter), Migrationspfad
in 4 Phasen, Datenfluss-Diagramm, Checkliste für Andreas' Review.
2026-06-05 20:53:09 +02:00
Hermes Agent a3f67775ab docs: Archivar-Konzept — FAKT-Ablage + Gap-Analyse (3 Lücken für Rainer)
Ergänzt:
- FAKT-Ablage als Dateisystem-Pfad (kein Chat-Raum)
- Community-konfigurierbarer Ablagepfad
- Gap-Analyse um 3 konkrete Entscheidungspunkte erweitert:
  L1: Raum-Map-Format (JSON unter data/room-map.json)
  L2: Catch-All-Validierung (genau 1 Raum, Gateway-Start-Gate)
  L3: Onboarding als Gateway-Hook

Story ist jetzt gut genug für Rainer als Architekturauftrag.
2026-06-05 20:18:47 +02:00
Hermes Agent fa2a24f747 docs: Archivar-Konzept — Story, Gap-Analyse und Architekturziel
Dokumentiert das WARUM des Archivars als thematischen Router,
nicht als Kategorie-Klassifikator. Enthält:

- Multi-Room-Agent-Kommunikationsverhalten
- Raum-Map mit Catch-All als Raum-Attribut
- Multi-Agent-Raum-Ausschluss-Regel
- Onboarding-Interview für neue Räume
- Gap-Analyse: Konzept vs. aktuelle Implementierung (5 Gaps)
- LLM als Kontext-Interpreter, nicht als Kategorie-Klassifikator

Commit spiegelt die konzeptionelle Arbeit vom 05.06.2026 mit Andreas.
2026-06-05 20:03:06 +02:00
Hermes Agent be917afcbd feat(install): add --update-only emergency deploy mode
Adds '--update-only' flag for crisis deployment — no questions,
no Ollama, no config provisioning. Just find hermes dir, deploy
all plugin files, clear __pycache__, restart gateway, verify.

Flow:
  1. find_hermes_dir() → resolve correct path (6-priority cascade)
  2. create_backup() → tar.gz safety net
  3. cp plugin/ → $HERMES_DIR/plugins/platforms/rocketchat/
  4. rm -rf __pycache__
  5. systemctl restart hermes-gateway
  6. journalctl grep verification (15s timeout)

Use case: Gateway loses plugin discovery after clean shutdown.
Instead of manual cp + restart, one command: ./install.sh --update-only

Language strings added for DE + EN. Help text updated.
2026-06-05 18:00:36 +02:00
Hermes Agent a078620827 feat(plugin): plugin.yaml für Gateway-Platform-Discovery
Platform._scan_bundled_plugin_platforms() erwartet plugin.yaml im
Plattform-Verzeichnis, sonst wird Rocket.Chat nicht discovered.
Ohne dieses Manifest überlebt RC keinen kalten Gateway-Neustart.

Root cause: gateway/config.py:176-194 scannt plugins/platforms/
und filtert Verzeichnisse ohne plugin.yaml aus. War vorher kein
Problem, weil die platform_registry in-process überlebte.
2026-06-05 08:15:46 +02:00
Hermes Agent b5a43223ac fix: make install.sh executable (chmod +x) 2026-06-05 05:40:39 +02:00
Hermes Agent e5a32abf5c feat(archivar): dreistufiger Klassifikator — Keyword + Embedding + LLM (qwen2.5:7b)
Phase 3 (Miguel): 236 Zeilen in config.py, classifier.py, adapter_integration.py.
Phase 4 (Rainer): Quality Gate F1–F5 bestanden.

- Stufe 0: Keyword-Vorfilter mit erweiterten ALARM/FRAGE-Listen
- Stufe 1: Embedding (nomic-embed-text, Schwelle 0.70)
- Stufe 2: LLM-Klassifikation (qwen2.5:7b) für Grenzfälle
- Feature-Flag ARCHIVAR_ENABLE_LLM über Env-Variable
- LLMClient-Interface für Testbarkeit
- router.py unverändert (Blackbox-Integration)
2026-06-04 21:49:17 +02:00
Hermes Agent 4b2e933529 docs: Architektur-Skizze — zweistufiger Archivar-Klassifikator (Strategiegespräch 04.06.) 2026-06-04 20:11:12 +02:00
Hermes Agent f509710193 Fix find_hermes_dir(): trailing-space in Prio 2 sed, multi-PID in Prio 3 pgrep 2026-06-04 08:51:20 +02:00
Hermes Agent c2ded4ab9a Fix find_hermes_dir(): set +e vor jedem Subshell-Block um set -euo pipefail zu überleben 2026-06-04 08:48:51 +02:00
Hermes Agent 4af89ce13e Fix find_hermes_dir() Prio 5: check hermes-agent subdir when using get_hermes_home() 2026-06-04 08:44:49 +02:00
Hermes Agent 7364ae3333 Fix function order: move find_hermes_dir() before perform_update() to ensure proper definition before use 2026-06-04 08:42:10 +02:00
Hermes Agent 4ef07a14b9 fix: zielsichere HERMES_DIR-Ermittlung mit Prioritätenkaskade (Rainer/P1-P6) 2026-06-04 08:38:10 +02:00
Hermes Agent 7eac6b7dba Fix: replace find|while pipe with process substitution in perform_update() and main script
This fixes the issue where cp and mkdir in the while loop were running in a subshell
due to pipe usage, preventing proper error propagation with 'set -euo pipefail'.
Using process substitution ensures the while loop runs in the main process.
2026-06-04 08:04:03 +02:00
Hermes Agent c4775ca99e Fix update flow: git pull statt checkout, Plugin-Dateien direkt kopieren, kein ./install.sh Selbstaufruf 2026-06-04 06:25:30 +02:00
Hermes Agent d7ce3afcd0 Bugfixes für install.sh: 1) Zustandsvariable statt Exit-Code für Updates, 2) Stash-Mechanismus für git checkout mit lokalen Änderungen 2026-06-04 06:10:42 +02:00
Hermes Agent 70008660fc SKILL.md aktualisiert: FAKT→DocStore, Subscription-Validierung, DocumentationStore dokumentiert 2026-06-03 22:38:30 +02:00
Hermes Agent ccce90fdb0 FAKT ist Dokumentation, keine Kommunikation — nie in Chat-Räume routen
Vier harte Änderungen:
1. config.py: ARCHIVAR_FAKT_ROOM existiert nicht mehr. FAKT wird
   niemals in ROOM_MAPPING aufgenommen — Env-Variable obsolet.
2. router.py: FAKT-Entscheidungen werden VOR der Subscription-
   Validierung als is_unrouteable markiert. Kein if/else, kein
   Ermessensspielraum.
3. adapter_integration.py: classify_and_route() legt FAKT automatisch
   im DocumentationStore ab (existiert bereits).
4. Env-Variable ARCHIVAR_FAKT_ROOM aus systemd env.conf entfernt.

Resultat: Nur FRAGE und ALARM werden jemals in Chat-Räume geroutet.
FAKT-Nachrichten wie 'CPU-Last bei 92%' sind reine Dokumentation —
sie landen als Markdown unter data/archivar_docs/fakt/
2026-06-03 22:11:25 +02:00
Hermes Agent 886e566e77 Doc-Store: Messages in nicht abonnierte Räume werden im Filesystem abgelegt
Harte Durchsetzung: Der Archivar darf NUR in Räume routen, die der Bot
tatsächlich abonniert hat. Alles andere ist ein Architekturfehler.

Neu:
- doc_store.py: DocumentationStore — speichert unrouteable Nachrichten
  als Markdown mit YAML-Frontmatter unter data/archivar_docs/{category}/
- router.py: RoutingDecision.is_unrouteable + unrouteable_reason,
  MessageRouter.set_subscribed_room_ids(), Zielraum-Validierung
- adapter_integration.py: ArchivarMessageHandler.set_subscribed_room_ids(),
  classify_and_route() leitet bei is_unrouteable in doc_store um
- adapter.py: set_subscribed_room_ids() wird nach connect() mit den
  realen subscribed rooms gefüttert

Verhalten: Wenn jemand 'ALARM: Server down' in einem Raum schreibt,
den der Bot nicht abonniert hat, wird die Nachricht KLASSIFIZIERT,
aber NICHT geroutet — sie landet im doc_store mit Begründung.
2026-06-03 22:06:30 +02:00
Hermes Agent abe93cc2dc Arbeitspakete A+B: Hausinterne Begriffe durch generische Beispiele ersetzt
- room-topic-map.md: BAT-Team → Support-Team, Protonbridge-Plugin → Mail-Bridge-Plugin,
  andreas/Bernd → Admin, personenbezogene Namen anonymisiert
- OPTION_C_SESSION_SHARING.md: BAT-Team → Support-Team, andreas → admin
- BUTTON_GUIDE.md: rocketchat:protonbridge → rocketchat:my-room (3 Stellen)
- plugin/archivar/__init__.py: /home/bernd/ → docs/

Alle Beispiele sind jetzt generisch und unabhängig vom LLM nutzbar.
2026-06-03 21:55:22 +02:00
Hermes Agent 1c7b82e27f feat: Archivar-Universalisierung A–E — env-vars, SKILL.md, Pipeline-Integration, file-download
A: config.py auf Env-Vars umgestellt (ARCHIVAR_FAKT_ROOM, _FRAGE_ROOM, _ALARM_ROOM, _CATCHALL_ROOM, _PROJECT_ROOMS)
B: adapter.py-Kommentare von BAT-Terminologie auf generisch umgeschrieben
C: archivar/SKILL.md — Hermes-Skill-Schema mit Triggern, Architektur, Konfiguration, Pitfalls
D: classify_and_route() + send_callback in _process_incoming() integriert, chat_name mit [KATEGORIE] angereichert
E: RocketChatREST.download_file() — authentifizierter Datei-Download via X-Auth-Token, kein Security-Scanner-Trigger mehr
    _download_and_inline_files() inlined [FILE]-Inhalte direkt in den Prompt
2026-06-03 20:14:40 +02:00
Hermes Agent 7a0abc465a fix: template .env aufgeraeumt — nur OLLAMA_API_KEY, kein HERMES_API_KEY 2026-06-03 18:34:35 +02:00
Hermes Agent d01eded6ff fix: drei /API-KEY-Bugs — install.sh jetzt komplett productionsicher
Bug #12: /usr/bin/bash-Expansion im Passwort verhindert — cat <<'EOF' (single-quoted delimiter)
         + Platzhalter-Ersetzung via python3 (sed expandiert hBcZeichen in double quotes)
Bug #10: OLLAMA_BASE_URL aus rocketchat.env entfernt — überschreibt sonst Cloud-Provider-URL
Bug #11: OLLAMA_API_KEY via env var setzbar (OLLAMA_API_KEY=...) statt hartem Platzhalter
2026-06-03 17:37:13 +02:00