fix(qw1): bus event lea:monitor_routed + cablage offset côté executor Agent V1
Cleanup post-review QW1 :
- Émission bus lea:monitor_routed dans /replay/next (idx, source, replay_id, action_id, offset, wh)
via logger.info "[BUS] lea:monitor_routed ..." (le serveur streaming n'a pas
de SocketIO local, agent_chat émet déjà lea:* sur 5004 ; ici on logge en INFO
bien lisible, prêt pour un parser/pont futur)
- Executor Agent V1 (deploy/windows_client) lit action.monitor_resolution.{offset_x, offset_y, idx}
et applique l'offset aux coords absolues du clic/type/scroll/popup quand idx >= 0
- composite_fallback (idx=-1) : pas d'offset appliqué (backward compat mono-écran)
- Log INFO "QW1 monitor cible idx=N source=X offset=(dx,dy) — appliqué aux coords"
émis une fois par action quand un offset non nul s'applique
Tests : baseline 95 passed (e2e + phase0_integration + stream_processor + monitor_router + grounding_offset)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -34,6 +34,7 @@ from .agent_registry import AgentRegistry, AgentAlreadyEnrolledError
|
||||
from .stream_processor import StreamProcessor, build_replay_from_raw_events, enrich_click_from_screenshot
|
||||
from .worker_stream import StreamWorker
|
||||
from .monitor_router import resolve_target_monitor # QW1 — résolution écran cible
|
||||
from .loop_detector import LoopDetector # QW2 — détection de boucle pendant replay
|
||||
from .execution_plan_runner import (
|
||||
execution_plan_to_actions,
|
||||
inject_plan_into_queue,
|
||||
@@ -361,6 +362,18 @@ REPLAY_LOCK_FILE = _DATA_DIR / "_replay_active.lock"
|
||||
processor = StreamProcessor(data_dir=str(LIVE_SESSIONS_DIR))
|
||||
worker = StreamWorker(live_dir=str(LIVE_SESSIONS_DIR), processor=processor)
|
||||
|
||||
# QW2 — LoopDetector singleton lazy (utilise le CLIP embedder du processor)
|
||||
_loop_detector: Optional["LoopDetector"] = None
|
||||
|
||||
|
||||
def _get_loop_detector() -> "LoopDetector":
|
||||
"""Singleton lazy — crée le LoopDetector avec le CLIP embedder du processor."""
|
||||
global _loop_detector
|
||||
if _loop_detector is None:
|
||||
embedder = getattr(processor, "_clip_embedder", None)
|
||||
_loop_detector = LoopDetector(clip_embedder=embedder)
|
||||
return _loop_detector
|
||||
|
||||
# Registre des postes Lea enroles (table enrolled_agents dans rpa_data.db)
|
||||
# Emplacement configurable via RPA_AGENTS_DB_PATH pour les tests.
|
||||
_AGENTS_DB_PATH = os.environ.get(
|
||||
@@ -3166,6 +3179,28 @@ async def get_next_action(session_id: str, machine_id: str = "default"):
|
||||
"h": target.h,
|
||||
"source": target.source,
|
||||
}
|
||||
# QW1 — Émission bus lea:monitor_routed (no-op si bus indisponible)
|
||||
# Le serveur streaming n'a pas de SocketIO local : on logge en INFO
|
||||
# bien lisible. Un consommateur (agent_chat / dashboard) peut tailer
|
||||
# `journalctl -u rpa-streaming | grep '\[BUS\] lea:monitor_routed'`.
|
||||
try:
|
||||
_replay_id_bus = (
|
||||
owning_replay.get("replay_id") if owning_replay else None
|
||||
)
|
||||
logger.info(
|
||||
"[BUS] lea:monitor_routed replay=%s action=%s idx=%d source=%s "
|
||||
"offset=(%d,%d) wh=(%d,%d)",
|
||||
_replay_id_bus,
|
||||
action.get("action_id"),
|
||||
target.idx,
|
||||
target.source,
|
||||
target.offset_x,
|
||||
target.offset_y,
|
||||
target.w,
|
||||
target.h,
|
||||
)
|
||||
except Exception as _e_bus:
|
||||
logger.debug("emit lea:monitor_routed échec (non bloquant): %s", _e_bus)
|
||||
except Exception as e:
|
||||
logger.debug("QW1 monitor_resolution skip (%s)", e)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user