feat(planner): expose long_press/double_tap to the AI planner

This commit is contained in:
2026-07-15 19:45:06 +08:00
parent dda70940c0
commit 5a93651db7
5 changed files with 79 additions and 4 deletions
+4
View File
@@ -113,10 +113,12 @@ def default_tool_registry(
) -> dict[str, ToolCallable]:
from runtime.describe_screen_semantic import describe_screen_semantic
from tools.describe_screen import describe_screen
from tools.double_tap import double_tap
from tools.find_icon import find_icon, find_icon_on_screen
from tools.find_text import find_text, find_text_on_screen
from tools.input_text import input_text
from tools.launch_app import launch_app, terminate_app
from tools.long_press import long_press
from tools.screenshot import take_screenshot
from tools.swipe import swipe
from tools.tap import tap
@@ -126,6 +128,8 @@ def default_tool_registry(
"take_screenshot": _bind_manager(take_screenshot, manager),
"screenshot": _bind_manager(take_screenshot, manager),
"tap": _bind_manager(tap, manager),
"long_press": _bind_manager(long_press, manager),
"double_tap": _bind_manager(double_tap, manager),
"swipe": _bind_manager(swipe, manager),
"input_text": _bind_manager(input_text, manager),
"launch_app": _bind_manager(launch_app, manager),
+4 -2
View File
@@ -26,8 +26,10 @@ Before calling a tool, output a short text block (1-2 sentences):
Keep this reflection concise and factual.
You must then call exactly one tool:
- One of `tap`, `swipe`, `input_text`, `launch_app`, `terminate_app` to make
progress toward the goal.
- One of `tap`, `long_press`, `double_tap`, `swipe`, `input_text`,
`launch_app`, `terminate_app` to make progress toward the goal. Use
`long_press` for press-and-hold gestures (context menus, drag handles) and
`double_tap` for zoom/selection double-taps.
- `finish_task` when the goal has been reached, or when it cannot be reached
and no further action would help.
+36
View File
@@ -80,6 +80,40 @@ SWIPE_SPEC = ToolSpec(
),
)
LONG_PRESS_SPEC = ToolSpec(
name="long_press",
description="Press and hold a point on the screen, given in Scene pixel coordinates.",
parameters=_action_parameters(
required=["x", "y"],
properties={
"x": {"type": "number", "description": "X coordinate in Scene pixel space."},
"y": {"type": "number", "description": "Y coordinate in Scene pixel space."},
"duration_ms": {
"type": "integer",
"description": "Hold duration in milliseconds (ignored on some platforms).",
"default": 1200,
},
},
),
)
DOUBLE_TAP_SPEC = ToolSpec(
name="double_tap",
description="Tap a point twice quickly, given in Scene pixel coordinates.",
parameters=_action_parameters(
required=["x", "y"],
properties={
"x": {"type": "number", "description": "X coordinate in Scene pixel space."},
"y": {"type": "number", "description": "Y coordinate in Scene pixel space."},
"interval_ms": {
"type": "integer",
"description": "Milliseconds between the two taps.",
"default": 80,
},
},
),
)
INPUT_TEXT_SPEC = ToolSpec(
name="input_text",
description="Type text into the currently focused input field.",
@@ -145,6 +179,8 @@ FINISH_TASK_SPEC = ToolSpec(
ACTION_TOOL_SPECS: list[ToolSpec] = [
TAP_SPEC,
LONG_PRESS_SPEC,
DOUBLE_TAP_SPEC,
SWIPE_SPEC,
INPUT_TEXT_SPEC,
LAUNCH_APP_SPEC,