Compare commits
2 Commits
338fa14bbb
...
cd84fd3f07
| Author | SHA1 | Date | |
|---|---|---|---|
| cd84fd3f07 | |||
| 328532bcbb |
@@ -81,6 +81,7 @@ def _build_custom_buttons(labels: list, prefix: str = "", style: str = "default"
|
|||||||
prefix: Payload prefix for correlation (e.g. "ONBOARD:<rid>")
|
prefix: Payload prefix for correlation (e.g. "ONBOARD:<rid>")
|
||||||
style: Rocket.Chat button style — "default" (grey) or "primary" (blue)
|
style: Rocket.Chat button style — "default" (grey) or "primary" (blue)
|
||||||
"""
|
"""
|
||||||
|
import hashlib
|
||||||
buttons = []
|
buttons = []
|
||||||
for idx, label in enumerate(labels):
|
for idx, label in enumerate(labels):
|
||||||
# Sanitize label for button text (keep short)
|
# Sanitize label for button text (keep short)
|
||||||
@@ -89,12 +90,15 @@ def _build_custom_buttons(labels: list, prefix: str = "", style: str = "default"
|
|||||||
msg_payload = display
|
msg_payload = display
|
||||||
if prefix:
|
if prefix:
|
||||||
msg_payload = f"{prefix}::{msg_payload}"
|
msg_payload = f"{prefix}::{msg_payload}"
|
||||||
|
# P-051: action_id zwingend für RC 6.x (sonst actions-Array ignoriert)
|
||||||
|
action_id = hashlib.sha1(f"{msg_payload}:{idx}".encode()).hexdigest()[:12]
|
||||||
buttons.append({
|
buttons.append({
|
||||||
"type": "button",
|
"type": "button",
|
||||||
"text": display,
|
"text": display,
|
||||||
"msg": msg_payload,
|
"msg": msg_payload,
|
||||||
"msg_in_chat_window": True,
|
"msg_in_chat_window": True,
|
||||||
"style": style,
|
"style": style,
|
||||||
|
"action_id": action_id,
|
||||||
})
|
})
|
||||||
return buttons
|
return buttons
|
||||||
|
|
||||||
|
|||||||
+13
-2
@@ -5150,18 +5150,22 @@ class RocketChatAdapter(BasePlatformAdapter):
|
|||||||
log_tag = "clarification"
|
log_tag = "clarification"
|
||||||
|
|
||||||
# Build native RC buttons from Archivar actions
|
# Build native RC buttons from Archivar actions
|
||||||
|
import hashlib
|
||||||
buttons = []
|
buttons = []
|
||||||
for i, action in enumerate(actions):
|
for i, action in enumerate(actions):
|
||||||
action_type = action.get("type", f"action_{i}")
|
action_type = action.get("type", f"action_{i}")
|
||||||
action_text = action.get("text", f"Option {i+1}")
|
action_text = action.get("text", f"Option {i+1}")
|
||||||
# Move-request buttons use :: separator for line 722 parsing
|
# Move-request buttons use :: separator for line 722 parsing
|
||||||
selector = f"{msg_prefix}::{action_type}" if move_req_ctx else f"{msg_prefix}:{action_type}"
|
selector = f"{msg_prefix}::{action_type}" if move_req_ctx else f"{msg_prefix}:{action_type}"
|
||||||
|
# P-051: action_id zwingend für RC 6.x
|
||||||
|
action_id = hashlib.sha1(f"{selector}:{i}".encode()).hexdigest()[:12]
|
||||||
buttons.append({
|
buttons.append({
|
||||||
"type": "button",
|
"type": "button",
|
||||||
"text": action_text,
|
"text": action_text,
|
||||||
"msg": selector,
|
"msg": selector,
|
||||||
"msg_in_chat_window": True,
|
"msg_in_chat_window": True,
|
||||||
"style": "default",
|
"style": "default",
|
||||||
|
"action_id": action_id,
|
||||||
})
|
})
|
||||||
|
|
||||||
attachments = [{
|
attachments = [{
|
||||||
@@ -5208,18 +5212,22 @@ class RocketChatAdapter(BasePlatformAdapter):
|
|||||||
return fn
|
return fn
|
||||||
# Fallback: local implementation (Bug 3 fix — ensures buttons always render)
|
# Fallback: local implementation (Bug 3 fix — ensures buttons always render)
|
||||||
def _local_build(labels, prefix='', style='default'):
|
def _local_build(labels, prefix='', style='default'):
|
||||||
|
import hashlib
|
||||||
buttons = []
|
buttons = []
|
||||||
for label in labels:
|
for idx, label in enumerate(labels):
|
||||||
display = label.strip()
|
display = label.strip()
|
||||||
msg_payload = display
|
msg_payload = display
|
||||||
if prefix:
|
if prefix:
|
||||||
msg_payload = f"{prefix}::{msg_payload}"
|
msg_payload = f"{prefix}::{msg_payload}"
|
||||||
|
# P-051: action_id zwingend für RC 6.x
|
||||||
|
action_id = hashlib.sha1(f"{msg_payload}:{idx}".encode()).hexdigest()[:12]
|
||||||
buttons.append({
|
buttons.append({
|
||||||
"type": "button",
|
"type": "button",
|
||||||
"text": display,
|
"text": display,
|
||||||
"msg": msg_payload,
|
"msg": msg_payload,
|
||||||
"msg_in_chat_window": True,
|
"msg_in_chat_window": True,
|
||||||
"style": style,
|
"style": style,
|
||||||
|
"action_id": action_id,
|
||||||
})
|
})
|
||||||
return buttons
|
return buttons
|
||||||
logger.warning("[rocketchat] _build_custom_buttons not found in rocketchat module — using local fallback")
|
logger.warning("[rocketchat] _build_custom_buttons not found in rocketchat module — using local fallback")
|
||||||
@@ -7627,12 +7635,14 @@ class RocketChatAdapter(BasePlatformAdapter):
|
|||||||
buttons = []
|
buttons = []
|
||||||
for i in range(len(choices)):
|
for i in range(len(choices)):
|
||||||
emoji = self.EMOJI_NUMBERS[i] if i < len(self.EMOJI_NUMBERS) else str(i + 1)
|
emoji = self.EMOJI_NUMBERS[i] if i < len(self.EMOJI_NUMBERS) else str(i + 1)
|
||||||
|
msg_payload = f"CLARIFY:{clarify_id}::{i + 1}"
|
||||||
buttons.append({
|
buttons.append({
|
||||||
"type": "button",
|
"type": "button",
|
||||||
"text": emoji,
|
"text": emoji,
|
||||||
"msg": f"CLARIFY:{clarify_id}::{i + 1}",
|
"msg": msg_payload,
|
||||||
"msg_in_chat_window": False,
|
"msg_in_chat_window": False,
|
||||||
"style": "default",
|
"style": "default",
|
||||||
|
"action_id": f"clarify_{clarify_id}_{i}",
|
||||||
})
|
})
|
||||||
|
|
||||||
# Add "Other" button with special handling
|
# Add "Other" button with special handling
|
||||||
@@ -7642,6 +7652,7 @@ class RocketChatAdapter(BasePlatformAdapter):
|
|||||||
"msg": f"CLARIFY:{clarify_id}:other",
|
"msg": f"CLARIFY:{clarify_id}:other",
|
||||||
"msg_in_chat_window": False,
|
"msg_in_chat_window": False,
|
||||||
"style": "default",
|
"style": "default",
|
||||||
|
"action_id": f"clarify_{clarify_id}_other",
|
||||||
})
|
})
|
||||||
|
|
||||||
# Create attachment(s) with buttons — max 3 per row (UX: mobile readability)
|
# Create attachment(s) with buttons — max 3 per row (UX: mobile readability)
|
||||||
|
|||||||
@@ -11,12 +11,23 @@ Regeln:
|
|||||||
- Jedes Attachment hat max 3 actions
|
- Jedes Attachment hat max 3 actions
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import hashlib
|
||||||
from typing import Any, List, Tuple
|
from typing import Any, List, Tuple
|
||||||
|
|
||||||
# Emoji-Nummern für bis zu 10 Buttons
|
# Emoji-Nummern für bis zu 10 Buttons
|
||||||
EMOJI_NUMBERS = ["1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", "7️⃣", "8️⃣", "9️⃣", "🔟"]
|
EMOJI_NUMBERS = ["1️⃣", "2️⃣", "3️⃣", "4️⃣", "5️⃣", "6️⃣", "7️⃣", "8️⃣", "9️⃣", "🔟"]
|
||||||
|
|
||||||
|
|
||||||
|
def _make_action_id(msg_payload: str, index: int = 0) -> str:
|
||||||
|
"""Deterministische action_id aus msg-Payload (SHA1, 12 Zeichen).
|
||||||
|
|
||||||
|
Rocket.Chat 6.x benötigt zwingend ein action_id-Feld im Button-Dict,
|
||||||
|
sonst wird das gesamte actions-Array ignoriert (P-051).
|
||||||
|
"""
|
||||||
|
raw = f"{msg_payload}:{index}".encode()
|
||||||
|
return hashlib.sha1(raw).hexdigest()[:12]
|
||||||
|
|
||||||
|
|
||||||
def build_button_attachments(
|
def build_button_attachments(
|
||||||
num_buttons: List[Tuple[Any, ...]],
|
num_buttons: List[Tuple[Any, ...]],
|
||||||
special_buttons: List[Tuple[Any, ...]],
|
special_buttons: List[Tuple[Any, ...]],
|
||||||
@@ -75,6 +86,7 @@ def build_button_attachments(
|
|||||||
"msg": msg_payload,
|
"msg": msg_payload,
|
||||||
"msg_in_chat_window": True,
|
"msg_in_chat_window": True,
|
||||||
"style": button_style,
|
"style": button_style,
|
||||||
|
"action_id": _make_action_id(msg_payload, i + j),
|
||||||
})
|
})
|
||||||
att = {
|
att = {
|
||||||
"color": color,
|
"color": color,
|
||||||
@@ -87,7 +99,7 @@ def build_button_attachments(
|
|||||||
# Sonderschaltflächen in separatem Attachment
|
# Sonderschaltflächen in separatem Attachment
|
||||||
if special_buttons:
|
if special_buttons:
|
||||||
special_actions = []
|
special_actions = []
|
||||||
for tup in special_buttons:
|
for s_idx, tup in enumerate(special_buttons):
|
||||||
label = tup[0]
|
label = tup[0]
|
||||||
prefix = tup[1]
|
prefix = tup[1]
|
||||||
style = tup[2]
|
style = tup[2]
|
||||||
@@ -99,6 +111,7 @@ def build_button_attachments(
|
|||||||
"msg": msg_payload,
|
"msg": msg_payload,
|
||||||
"msg_in_chat_window": True,
|
"msg_in_chat_window": True,
|
||||||
"style": style,
|
"style": style,
|
||||||
|
"action_id": _make_action_id(msg_payload, s_idx),
|
||||||
})
|
})
|
||||||
attachments.append({
|
attachments.append({
|
||||||
"color": color,
|
"color": color,
|
||||||
|
|||||||
@@ -628,7 +628,19 @@ class _Mediator:
|
|||||||
- NOT is_pulse_phase → Cache greift immer (nur bei Phasenübergang)
|
- NOT is_pulse_phase → Cache greift immer (nur bei Phasenübergang)
|
||||||
"""
|
"""
|
||||||
# Cooldown-Check
|
# Cooldown-Check
|
||||||
|
# P-052: Clarify-Modal-Puls muss Cooldown ignorieren — sonst sieht
|
||||||
|
# der User roten Status ohne Pulsieren. Modal ist zeitlich begrenzt,
|
||||||
|
# das 429-Risiko ist akzeptabel. Force-REST (kein DDP, da DDP auf
|
||||||
|
# .101 unzuverlässig).
|
||||||
if self._rest_cooldown_until > time.monotonic():
|
if self._rest_cooldown_until > time.monotonic():
|
||||||
|
if self._clarify_modal:
|
||||||
|
logger.info(
|
||||||
|
"[presence-v10] P-052: Cooldown ignoriert für Modal-Puls "
|
||||||
|
"(noch %.1fs Cooldown, Modal aktiv)",
|
||||||
|
self._rest_cooldown_until - time.monotonic(),
|
||||||
|
)
|
||||||
|
# Fall through — Modal-Puls wird via REST gesendet
|
||||||
|
else:
|
||||||
self.telemetry_phase_transitions_suppressed += 1
|
self.telemetry_phase_transitions_suppressed += 1
|
||||||
logger.info(
|
logger.info(
|
||||||
"[presence-v10] Phasen-Status unterdrückt (Cooldown aktiv, "
|
"[presence-v10] Phasen-Status unterdrückt (Cooldown aktiv, "
|
||||||
@@ -1794,9 +1806,27 @@ class PresenceEngine:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def on_pre_tool_call(self, **kwargs) -> None:
|
def on_pre_tool_call(self, **kwargs) -> None:
|
||||||
"""Hook: pre_tool_call → background_term += 1 wenn terminal(background=true)."""
|
"""Hook: pre_tool_call → background_term += 1 wenn terminal(background=true).
|
||||||
|
|
||||||
|
P-053: Blockiert skill_manage-Tool-Calls während Clarify-Modal,
|
||||||
|
um Gateway-Crash durch Self-Improvement-Loop zu verhindern.
|
||||||
|
Der Self-Improvement-Loop (background_review.py) patched SKILL.md
|
||||||
|
ohne Rücksicht auf aktiven Clarify-Modal → SystemExit(75) → Gateway-Crash.
|
||||||
|
"""
|
||||||
tool_name = kwargs.get("tool_name", "")
|
tool_name = kwargs.get("tool_name", "")
|
||||||
args = kwargs.get("args", {}) or {}
|
args = kwargs.get("args", {}) or {}
|
||||||
|
|
||||||
|
# P-053: Self-Improvement-Loop-Guard — kein SKILL.md-Patch während Modal
|
||||||
|
if tool_name == "skill_manage" and self.is_clarify_modal_active():
|
||||||
|
logger.warning(
|
||||||
|
"[presence-v10] P-053: skill_manage blockiert — "
|
||||||
|
"Clarify-Modal aktiv. Patch wird nach Modal-Ende nachgeholt."
|
||||||
|
)
|
||||||
|
raise RuntimeError(
|
||||||
|
"P-053: skill_manage blockiert — Clarify-Modal aktiv. "
|
||||||
|
"Bitte nach Abschluss der User-Interaktion erneut versuchen."
|
||||||
|
)
|
||||||
|
|
||||||
if tool_name == "terminal" and args.get("background") is True:
|
if tool_name == "terminal" and args.get("background") is True:
|
||||||
self._apply_counter_delta("background_term", +1)
|
self._apply_counter_delta("background_term", +1)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user