fix(computer_use): correct type_text MCP tool name and implement drag action
Bug 3: The cua_backend type_text() method called MCP tool 'type_text_chars' which does not exist in current cua-driver. Changed to 'type_text' which is the correct MCP tool name. Bug 4: The drag() method returned a hardcoded 'not supported' error even though cua-driver exposes a 'drag' MCP tool. Implemented proper drag dispatching with coordinate-based and element-based targeting. Added dispatch-level validation for drag to ensure from/to coordinates or elements are provided before calling any backend. Fixes #24170 (bugs 3 and 4)
This commit is contained in:
@@ -357,6 +357,12 @@ def _dispatch(backend: ComputerUseBackend, action: str, args: Dict[str, Any]) ->
|
||||
return _maybe_follow_capture(backend, res, capture_after)
|
||||
|
||||
if action == "drag":
|
||||
has_elements = args.get("from_element") is not None and args.get("to_element") is not None
|
||||
has_coords = args.get("from_coordinate") and args.get("to_coordinate")
|
||||
if not has_elements and not has_coords:
|
||||
return json.dumps({
|
||||
"error": "drag requires from_coordinate/to_coordinate or from_element/to_element",
|
||||
})
|
||||
res = backend.drag(
|
||||
from_element=args.get("from_element"),
|
||||
to_element=args.get("to_element"),
|
||||
|
||||
Reference in New Issue
Block a user