Remove interact verify endpoint
All checks were successful
python-syntax / syntax-check (push) Successful in 31s

This commit is contained in:
Space-Banane
2026-05-04 15:59:43 +02:00
parent f05e0c56e6
commit 22ca0097d1
8 changed files with 6 additions and 182 deletions

View File

@@ -15,11 +15,9 @@ from .models import (
ActionRequest,
ClickTextAction,
GridTarget,
InteractVerifyRequest,
LaunchRequest,
PixelTarget,
Target,
VerifyOCRTextNearPoint,
WindowActionRequest,
WindowQuery,
)
@@ -357,52 +355,6 @@ def exec_action(req: ActionRequest, screen: int = 0) -> dict:
}
def _verify_ocr_text_near_point(spec: VerifyOCRTextNearPoint) -> dict:
radius = spec.radius
display, _, _ = select_display(spec.screen)
region_x = max(display["x"], spec.x - radius)
region_y = max(display["y"], spec.y - radius)
max_right = display["x"] + display["width"]
max_bottom = display["y"] + display["height"]
region_right = min(max_right, spec.x + radius)
region_bottom = min(max_bottom, spec.y + radius)
region_w = max(1, region_right - region_x)
region_h = max(1, region_bottom - region_y)
img, region, _, _, screen_selection = capture_region_image(spec.screen, region_x, region_y, region_w, region_h)
items = extract_ocr_items(img, region["x"], region["y"], spec.min_confidence, spec.ocr_lang, spec.ocr_psm)
matches = [item for item in items if _text_matches(item["text"], spec.text, spec.match, spec.case_sensitive)]
return {"ok": len(matches) > 0, "matches": matches[:8], "items_count": len(items), "screen": screen_selection, "region": region}
def execute_and_verify(req: InteractVerifyRequest) -> dict:
started = time.time()
action_result = exec_action(req.action.action, req.action.screen)
attempts = 0
last_check = None
deadline = started + (req.timeout_ms / 1000.0)
while True:
attempts += 1
check = _verify_ocr_text_near_point(req.verify)
last_check = check
if check["ok"]:
return {
"action_result": action_result,
"verified": True,
"attempts": attempts,
"last_check": last_check,
"duration_ms": int((time.time() - started) * 1000),
}
if time.time() >= deadline:
return {
"action_result": action_result,
"verified": False,
"attempts": attempts,
"last_check": last_check,
"duration_ms": int((time.time() - started) * 1000),
}
time.sleep(req.check_interval_ms / 1000.0)
def windows_only(feature: str):
if sys.platform != "win32":
raise HTTPException(status_code=501, detail=f"{feature} is currently supported on Windows hosts only")