feat: default 1ms delay and prompt improvements

This commit is contained in:
Richard Tang
2026-04-16 16:19:38 -07:00
parent 9e71f16d15
commit 44d114f0d0
6 changed files with 22 additions and 43 deletions
+2 -2
View File
@@ -90,8 +90,8 @@ reach shadow elements transparently.
3. `browser_coords(x, y)` CSS px
4. `browser_click_coordinate(css_x, css_y)` lands via native hit
test; inputs get focused regardless of shadow depth
5. Type via `browser_type` or, if the selector path can't reach the
element, dispatch keys to the focused element
5. Type via `browser_type_focused` (no selector needed types into the
already-focused element), or `browser_type` if you have a selector
For selector-style access when you know the shadow path:
`browser_shadow_query("#interop-outlet >>> #msg-overlay >>> p")`
+1
View File
@@ -899,6 +899,7 @@ def test_concurrency_safe_allowlist_is_conservative():
"hashline_edit",
"browser_click",
"browser_type",
"browser_type_focused",
"browser_navigate",
):
assert forbidden not in allowlist, f"{forbidden} must not be concurrency-safe"
+2 -2
View File
@@ -45,8 +45,8 @@ def register_tools(mcp: FastMCP) -> None:
- Tabs: browser_tabs, browser_open, browser_close, browser_focus
- Navigation: browser_navigate, browser_go_back, browser_go_forward, browser_reload
- Inspection: browser_screenshot, browser_snapshot, browser_console
- Interactions: browser_click, browser_click_coordinate, browser_type, browser_fill,
browser_press, browser_hover, browser_select, browser_scroll, browser_drag
- Interactions: browser_click, browser_click_coordinate, browser_type, browser_type_focused,
browser_fill, browser_press, browser_hover, browser_select, browser_scroll, browser_drag
- Advanced: browser_wait, browser_evaluate, browser_get_text, browser_get_attribute,
browser_resize, browser_upload, browser_dialog
"""
+1 -1
View File
@@ -998,7 +998,7 @@ class BeelineBridge:
selector: str | None,
text: str,
clear_first: bool = True,
delay_ms: int = 0,
delay_ms: int = 1,
timeout_ms: int = 30000,
use_insert_text: bool = True,
) -> dict:
+2 -2
View File
@@ -29,7 +29,7 @@ TOOL_SCHEMAS: dict[str, dict] = {
"text": {"type": "string", "required": True},
"tab_id": {"type": "integer"},
"profile": {"type": "string"},
"delay_ms": {"type": "integer", "default": 0},
"delay_ms": {"type": "integer", "default": 1},
"clear_first": {"type": "boolean", "default": True},
"timeout_ms": {"type": "integer", "default": 30000},
"use_insert_text": {"type": "boolean", "default": True},
@@ -51,7 +51,7 @@ TOOL_SCHEMAS: dict[str, dict] = {
"text": {"type": "string", "required": True},
"tab_id": {"type": "integer"},
"profile": {"type": "string"},
"delay_ms": {"type": "integer", "default": 0},
"delay_ms": {"type": "integer", "default": 1},
"clear_first": {"type": "boolean", "default": True},
"use_insert_text": {"type": "boolean", "default": True},
},
+14 -36
View File
@@ -179,36 +179,25 @@ def register_interaction_tools(mcp: FastMCP) -> None:
text: str,
tab_id: int | None = None,
profile: str | None = None,
delay_ms: int = 0,
delay_ms: int = 1,
clear_first: bool = True,
timeout_ms: int = 30000,
use_insert_text: bool = True,
) -> dict:
"""
Type text into an element identified by CSS selector.
Click a selector to focus it, then type text into it.
Performs a CDP click on the selector first (to focus it), then
inserts text via CDP Input.insertText. This handles plain
<input>/<textarea> as well as rich-text editors (Lexical,
Draft.js, ProseMirror) that require a real pointer-sourced
focus event.
For the click-coordinate-then-type pattern (shadow DOM, iframes,
or when you don't have a reliable selector), use
``browser_type_focused`` instead it types into
document.activeElement without needing a selector.
By default uses CDP Input.insertText (``use_insert_text=True``).
Set ``use_insert_text=False`` only for code editors that watch
specific keystrokes, or when ``delay_ms`` typing animation is
required.
Uses CDP ``Input.insertText`` by default, which works for both
standard inputs and many rich-text editors. Use
``browser_type_focused`` when the target is already focused or
you cannot reliably address it with a selector.
Args:
selector: CSS selector for the input element.
text: Text to type.
tab_id: Chrome tab ID (default: active tab).
profile: Browser profile name (default: "default").
delay_ms: Delay between keystrokes in ms (default: 0).
delay_ms: Delay between keystrokes in ms (default: 1).
Forces the per-keystroke fallback when > 0.
clear_first: Clear existing text before typing (default: True).
timeout_ms: Timeout waiting for element (default: 30000).
@@ -300,34 +289,23 @@ def register_interaction_tools(mcp: FastMCP) -> None:
text: str,
tab_id: int | None = None,
profile: str | None = None,
delay_ms: int = 0,
delay_ms: int = 1,
clear_first: bool = True,
use_insert_text: bool = True,
) -> dict:
"""
Type text into the already-focused element (document.activeElement).
Type text into the already-focused element.
CANONICAL PATTERN:
browser_click_coordinate(x, y) # focus the target
browser_type_focused(text="...") # type into it
CDP's Input.insertText takes no target parameter — it operates
implicitly on the focused editable. This makes it shadow-agnostic
and iframe-agnostic, and the ONLY reliable way to type into:
- LinkedIn's #interop-outlet Lexical composer
- X/Twitter's Draft.js compose box
- Reddit's ProseMirror comment box
- Any site wrapped in Trusted Types CSP
- Any nested-iframe message overlay
Much faster than repeated browser_press calls for multi-character
input.
Targets ``document.activeElement`` and is ideal after a
coordinate click, or when the editable cannot be reached
reliably with a selector. Faster than repeated
``browser_press`` calls for multi-character input.
Args:
text: Text to insert at the current cursor position.
tab_id: Chrome tab ID (default: active tab).
profile: Browser profile name (default: "default").
delay_ms: Delay between keystrokes in ms (default: 0).
delay_ms: Delay between keystrokes in ms (default: 1).
Forces per-keystroke dispatch when > 0.
clear_first: Clear existing text before typing (default: True).
use_insert_text: Use CDP Input.insertText (default: True).