feat(vwb): execute wait for state
This commit is contained in:
@@ -69,7 +69,7 @@ _LLM_ACTION_MAP = {
|
||||
}
|
||||
|
||||
# Actions VWB de type attente
|
||||
_WAIT_ACTION_TYPES = {"wait_for_anchor"}
|
||||
_WAIT_ACTION_TYPES = {"wait_for_anchor", "wait_for_state"}
|
||||
|
||||
# Actions VWB de type condition
|
||||
_CONDITION_ACTION_TYPES = {"visual_condition"}
|
||||
@@ -1179,6 +1179,7 @@ def execute_windows():
|
||||
'hotkey': 'key_combo',
|
||||
'scroll_to_anchor': 'scroll',
|
||||
'wait_for_anchor': 'wait',
|
||||
'wait_for_state': 'wait_for_state',
|
||||
'visual_condition': 'wait',
|
||||
}
|
||||
|
||||
@@ -1245,6 +1246,10 @@ def execute_windows():
|
||||
# ---------------------------------------------------------------
|
||||
if vwb_type in ('wait', 'wait_for_anchor', 'visual_condition') and 'duration_ms' in params:
|
||||
action['duration_ms'] = params['duration_ms']
|
||||
if vwb_type == 'wait_for_state':
|
||||
for key in ('expected_state', 'timeout_ms', 'poll_interval_ms', 'evidence_required'):
|
||||
if key in params:
|
||||
action[key] = params[key]
|
||||
|
||||
# ---------------------------------------------------------------
|
||||
# Actions fichiers → proxy vers /file-action de l'agent (port 5006)
|
||||
|
||||
@@ -80,6 +80,36 @@ _check_screen_for_patterns = _shared_check_patterns
|
||||
_handle_detected_pattern = _shared_handle_pattern
|
||||
|
||||
|
||||
def _execute_wait_for_state(params: Dict[str, Any]) -> dict:
|
||||
from visual_workflow_builder.backend.services.wait_for_state import (
|
||||
wait_for_expected_state,
|
||||
)
|
||||
|
||||
expected_state = params.get("expected_state") or {}
|
||||
timeout_ms = int(params.get("timeout_ms", 5000))
|
||||
poll_interval_ms = int(params.get("poll_interval_ms", 250))
|
||||
evidence_required = params.get("evidence_required", "window_or_process")
|
||||
|
||||
print(
|
||||
"⏱️ [Action] Attente etat "
|
||||
f"{expected_state} timeout={timeout_ms}ms"
|
||||
)
|
||||
result = wait_for_expected_state(
|
||||
expected_state=expected_state,
|
||||
timeout_ms=timeout_ms,
|
||||
poll_interval_ms=poll_interval_ms,
|
||||
evidence_required=evidence_required,
|
||||
)
|
||||
output = result.to_dict()
|
||||
if result.matched:
|
||||
return {"success": True, "output": output}
|
||||
return {
|
||||
"success": False,
|
||||
"error": "Etat attendu non observe avant timeout",
|
||||
"output": output,
|
||||
}
|
||||
|
||||
|
||||
def minimize_active_window():
|
||||
"""Minimise le navigateur VWB et active la fenêtre suivante (VM, app cible)."""
|
||||
try:
|
||||
@@ -1165,6 +1195,9 @@ def execute_action(action_type: str, params: dict) -> dict:
|
||||
}
|
||||
}
|
||||
|
||||
elif action_type == 'wait_for_state':
|
||||
return _execute_wait_for_state(params)
|
||||
|
||||
elif action_type == 'keyboard_shortcut':
|
||||
keys = params.get('keys', [])
|
||||
if not keys:
|
||||
|
||||
Reference in New Issue
Block a user