feat(tools): add long_press tool with humanize hook

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-07-15 19:16:25 +08:00
co-authored by Claude Opus 4.6
parent 8a73edf4db
commit c4ee4279ef
2 changed files with 70 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
from __future__ import annotations
from device.manager import DeviceManager
from tools._device import get_driver
from tools.humanize import (
get_rng,
jitter_duration,
jitter_point,
load_humanize_config,
)
def long_press(
x: float,
y: float,
*,
duration_ms: int = 1200,
device_id: str | None = None,
manager: DeviceManager | None = None,
) -> dict[str, object]:
cfg = load_humanize_config()
px, py = x, y
dms = duration_ms
if cfg.enabled:
rng = get_rng()
px, py = jitter_point(x, y, radius=cfg.tap_radius_px, rng=rng)
dms = jitter_duration(duration_ms, spread=cfg.duration_spread, rng=rng)
get_driver(device_id, manager=manager).long_press(px, py, dms)
return {"ok": True, "action": "long_press", "x": px, "y": py, "duration_ms": dms}