feat(F557): Emoji-Number Fallback fuer nicht-interactive Clients @implements: [F-557]
- button_builder.py: _is_numeric_choice() Helper (Inverse der Emoji-Nummer-Generierung)
erkennt "1", Emoji-Keycap "1", "1.", "1)", "1 rueber", "Option 1" -> 1-basierter Index;
"0"/"11"/"99" + Multi-Wahl ("1 und 2") -> None
- adapter.py: is_pending_clarify_answer + Plain-Digit-Clarify-Block + Move-Request-Intercept
von isdigit()/expliziten Listen auf _is_numeric_choice() umgestellt
- Fallback IMMER aktiv (keine Client-Type-Detection, Rainer 2.4)
- test_f557_numeric_choice.py: 29 Tests (Rainer 4: 5 Test-Pflichten + Edge-Case-Matrix)
- KEINE Core-Aenderungen (nur Plugin-Layer)
This commit is contained in:
+46
-16
@@ -2,6 +2,7 @@
|
||||
# @implements: [F-551] — PFAD:-Präfix gegen Slash-Command-Blockade (FAKT-Pfad-Eingabe)
|
||||
# @implements: [F-552] — Presence-Engine Subagent-Tracking (register_engine-Verdrahtung, Variante B)
|
||||
# @implements: [F-553] — main_agent Counter-Leak Fix (Heartbeat-Refresh-Baustein, Variante B)
|
||||
# @implements: [F-557] — Emoji-Number Fallback für nicht-interactive Clients (Clarify + Move-Request)
|
||||
"""
|
||||
Rocket.Chat Platform Adapter for Hermes Agent.
|
||||
|
||||
@@ -2869,8 +2870,9 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
Clarify-Frage zu werten ist — unabhängig vom Format-Pfad:
|
||||
|
||||
1. CLARIFY:-Button-Payload (CLARIFY:<id>:<idx> / CLARIFY:<id>::<idx>)
|
||||
2. Plain-Digit-Text (Feature 53, P-047 Mobile-Workaround) in einem
|
||||
Raum mit offener Clarify-Frage (_room_clarify)
|
||||
2. Plain-Digit/Emoji-Text (Feature 53, P-047 Mobile-Workaround,
|
||||
F-557 erweitert auf Emoji/Varianten) in einem Raum mit offener
|
||||
Clarify-Frage (_room_clarify)
|
||||
|
||||
Der Archivar-Routing-Block prüft diesen Trigger VOR der
|
||||
Klassifikation und leitet Clarify-Antworten IMMER am Routing
|
||||
@@ -2891,8 +2893,16 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
# 1. CLARIFY:-Button-Payload (beide Formate)
|
||||
if stripped.startswith("CLARIFY:"):
|
||||
return True
|
||||
# 2. Plain-Digit-Text in einem Raum mit offener Clarify-Frage
|
||||
if stripped.isdigit() and room_id in getattr(self, "_room_clarify", {}):
|
||||
# 2. Plain-Digit/Emoji-Text in einem Raum mit offener Clarify-Frage
|
||||
# F-557: _is_numeric_choice statt isdigit() — erkennt Emoji-Nummern
|
||||
# ("1️⃣") und Varianten ("1.", "1 rüber", "Option 1") zusätzlich.
|
||||
_num = None
|
||||
try:
|
||||
from archivar.button_builder import _is_numeric_choice
|
||||
_num = _is_numeric_choice(stripped)
|
||||
except Exception:
|
||||
_num = None
|
||||
if _num is not None and room_id in getattr(self, "_room_clarify", {}):
|
||||
return True
|
||||
return False
|
||||
|
||||
@@ -3461,9 +3471,18 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
if not is_clarify_response and not is_archivar_clarify:
|
||||
stripped = text.strip()
|
||||
_room_clarify = getattr(self, "_room_clarify", {})
|
||||
if stripped.isdigit() and room_id in _room_clarify:
|
||||
# F-557: _is_numeric_choice statt isdigit() — erkennt Emoji-Nummern
|
||||
# ("1️⃣") und Varianten ("1.", "1 rüber", "Option 1"). Liefert den
|
||||
# 1-basierten Index direkt (oder None bei out-of-range/Multi-Wahl).
|
||||
_numeric_choice = None
|
||||
try:
|
||||
from archivar.button_builder import _is_numeric_choice
|
||||
_numeric_choice = _is_numeric_choice(stripped)
|
||||
except Exception:
|
||||
_numeric_choice = None
|
||||
if _numeric_choice is not None and room_id in _room_clarify:
|
||||
clarify_id = _room_clarify[room_id]
|
||||
idx = int(stripped) - 1 # 1-basierte Eingabe → 0-basierter Index
|
||||
idx = _numeric_choice - 1 # 1-basierte Eingabe → 0-basierter Index
|
||||
resolved_text: Optional[str] = None
|
||||
try:
|
||||
from tools.clarify_gateway import _entries as _clarify_entries
|
||||
@@ -4004,16 +4023,27 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
choice = choice[:2]
|
||||
# Altes Format: "1"/"2"/"3"/"4" = numerische Antwort
|
||||
# Neues Format: "1️⃣", "2️⃣", "3️⃣", "4️⃣" = Emoji-Nummern
|
||||
elif choice in ("1", "2", "3", "4") or choice in ("1️⃣", "2️⃣", "3️⃣", "4️⃣"):
|
||||
num = int(choice[0]) # Extrahiere die Zahl (entweder direkt oder aus dem Emoji)
|
||||
if num == 1:
|
||||
choice = "rüberkopieren"
|
||||
elif num == 2:
|
||||
choice = "generell" # v6: 2 = Generell hier bleiben (sticky)
|
||||
elif num == 3:
|
||||
choice = "hier bleiben" # v6: 3 = Hier bleiben (nur diesmal)
|
||||
else:
|
||||
choice = "falsch" # v6: 4 = Falsch geroutet (reject)
|
||||
# F-557: explizite Listen → _is_numeric_choice() + Bounds-Check.
|
||||
# Erkennt zusätzlich "1.", "1 rüber", "Option 1", "1)" mit
|
||||
# Leading/Trailing-Whitespace-Toleranz. Multi-Wahl ("1 und 2")
|
||||
# und out-of-range ("5"/"0") liefern None → normale Verarbeitung.
|
||||
else:
|
||||
_move_num = None
|
||||
try:
|
||||
from archivar.button_builder import _is_numeric_choice
|
||||
_move_num = _is_numeric_choice(choice)
|
||||
except Exception:
|
||||
_move_num = None
|
||||
if _move_num is not None and 1 <= _move_num <= 4:
|
||||
num = _move_num
|
||||
if num == 1:
|
||||
choice = "rüberkopieren"
|
||||
elif num == 2:
|
||||
choice = "generell" # v6: 2 = Generell hier bleiben (sticky)
|
||||
elif num == 3:
|
||||
choice = "hier bleiben" # v6: 3 = Hier bleiben (nur diesmal)
|
||||
else:
|
||||
choice = "falsch" # v6: 4 = Falsch geroutet (reject)
|
||||
choice = choice.lower()
|
||||
|
||||
# Neue Mapping-Logik für verbesserte Button-UX (v6)
|
||||
|
||||
Reference in New Issue
Block a user