feat(computer-use): complete cua-driver integration with passing integration tests - #15328
Closed
ddupont808 wants to merge 2 commits into
Closed
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Completes the cua-driver integration introduced in #14817. All backend methods are wired up to the correct cua-driver MCP tools, and a 9-test integration suite passes end-to-end against a real macOS Safari instance.
Paired cua-driver changes: trycua/cua#1375
Changes
cua_backend.pyWindow-aware
capture()— replaces the original implementation withlist_windows+get_window_state. PrefersstructuredContent.windows(MCP 2024-11-05+ cua-driver) for zero-parse window enumeration; falls back to regex-parsed text for older builds. Stores(pid, window_id)as sticky context reused by action tools.Action routing —
click,scroll,type_text,keynow pass the stickypid/window_idto the correct cua-driver tools.type_textroutes throughtype_text_chars(synthesised key events) — WebKitAXTextFields reject AX attribute writes from non-frontmost processes.Key parsing —
_parse_key_combosplitscmd+s-style strings into(key, [modifiers])and dispatches tohotkeyorpress_key, matching cua-driver's actual tool names.set_value(value, element)— new method calls the cua-driverset_valueMCP tool. Required forAXPopUpButton/ HTML<select>in backgrounded Safari:AXPressopens the native popup which closes immediately when the window is non-frontmost;set_valueselects the matching option directly without a popup.focus_app— reimplemented as a window-selector vialist_windows(updates stickypid/window_id).list_apps— fixed tool namelistApps→list_apps.Structured-content extraction —
_extract_tool_resultnow surfacesstructuredContentfrom MCP results.Helpers —
_parse_windows_from_text,_parse_elements_from_tree,_split_tree_text,_parse_key_comboextracted as module-level functions.schema.pyAdded
set_valueto the action enum +valuefield for its payload.tool.pyRouted
set_valuethrough_dispatch→backend.set_value. Addedset_valueto_DESTRUCTIVE_ACTIONS. Fixed MIME detection in_capture_response: detect JPEG vs PNG from base64 magic bytes rather than hardcodingimage/png.agent/display.py+run_agent.pyGuard failure detection and result-preview/logging against non-string
function_result— multimodal dict results (_multimodal=True) are not string-sliceable.Validation
test_hermes_form_fill.py— 9 input types (text, password, email, number, textarea, checkbox, select, radio, submit) in backgrounded Safaritest_overlay_z_order.py— agent cursor overlay z-orderingCaveats
set_valueandstructuredContentonlist_windows/launch_app.dragis not implemented — cua-driver does not expose a drag tool.