qwen-code/packages/cua-driver/rust/Cargo.toml
顾盼 e06d3be2b3
fix(cua-driver): complete coordinate normalization for zoom/scroll/mouse tools (#6610)
* fix(cua-driver): denormalize from_zoom click coords in normalized mode

When CUA_DRIVER_RS_COORDINATE_SPACE=1 (0-1000 normalized coordinates),
from_zoom=true clicks were skipping denormalization entirely, causing the
model's 0-1000 values to be treated as raw pixel offsets in the zoom
image — landing clicks at the wrong position.

- Add ZOOM_SIZE_CACHE: cache zoom image dimensions (width/height) from
  zoom tool results, keyed by pid (matching platform ZoomRegistry)
- denormalize_args: when from_zoom=true and cache exists, denormalize
  x/y against zoom image dimensions instead of skipping
- rewrite_coord_desc: rewrite from_zoom description from "pixel
  coordinates" to "0-1000 normalized coordinates" so the model sends
  normalized values
- ingest_zoom_size: new output hook called after zoom tool execution to
  populate the cache

* fix(cua-driver): error on missing coord cache + normalize scroll/mouse tools

Two additional fixes for the 0-1000 normalized coordinate mode:

1. denormalize_args now returns Result<(), String> and errors when a
   required size basis is missing (SIZE_CACHE, SCREEN_SIZE,
   DESKTOP_SCREENSHOT_SIZE, ZOOM_SIZE_CACHE), instead of silently
   passing through unconverted normalized coordinates that would land
   clicks at wrong positions. The error messages guide the model to call
   the appropriate query tool (get_window_state, get_screen_size,
   get_desktop_state, zoom) first.

2. Add scroll, mouse_button_down, mouse_button_up, mouse_drag to
   input_coord_fields so their x/y coordinates are denormalized in
   normalized mode. scroll x/y specify where to deliver the wheel event
   (not scroll amount); Linux mouse tools are stateful press/drag/release
   with window-local coordinates.

* chore(cua-driver): bump version to 0.7.1

* fix(cua-driver): stop rewriting screenshot_width/height in normalized mode

normalize_result was rewriting get_window_state and get_desktop_state
screenshot_width/height to 1000, conflicting with elements[].frame
which stays in pixels. The model received contradictory coordinate
information: screenshot dimensions said 1000 but element positions
were in real pixels (e.g. x=1444).

Query tool results should be returned unmodified. The model is guided
to use 0-1000 coordinates through tool schema descriptions and MCP
instructions, not by tampering with return values.

* fix(cua-driver): address review — normalize_result + parallel_mouse_drag

1. Stop rewriting screenshot_width/height to 1000 in normalized mode.
   Query results now return real pixel values; the model is guided to
   use 0-1000 coords through schema descriptions and instructions only.

2. Fix parallel_mouse_drag per-item window_id lookup: each drag item
   resolves its own (pid, window_id) from SIZE_CACHE instead of using
   the caller-level screenshot_w/h (which is always 0 since the tool
   has no top-level pid/window_id).

3. Add x_from/x_to conversion for fn-expression domain bounds.

4. Prevent from_zoom early return from skipping nested coord handler.

5. Fix misleading comments about "non-empty entry" and "nested rewrite".
2026-07-09 14:37:42 +00:00

33 lines
867 B
TOML

[workspace]
resolver = "2"
members = [
"crates/cua-driver",
"crates/cua-driver-testkit",
"crates/cua-driver-uia",
"crates/cua-driver-core",
"crates/platform-macos",
"crates/platform-windows",
"crates/platform-linux",
"crates/cursor-overlay",
"crates/focus-monitor-win",
"crates/pip-preview",
]
[workspace.package]
version = "0.7.1"
edition = "2021"
authors = ["trycua"]
license = "MIT"
repository = "https://github.com/trycua/cua"
[workspace.dependencies]
tokio = { version = "1", features = ["full"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
anyhow = "1"
thiserror = "1"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
base64 = "0.22"
uuid = { version = "1", features = ["v4"] }
image = { version = "0.25", default-features = false, features = ["png", "jpeg"] }