Verify system release independently of window delivery and refresh SDK CUA
This commit is contained in:
1 parent
cddddfff82
commit
efa1b999a6
5 files changed
+28
-7
No files matched your search
@@ -152,6 +152,11 @@ if CommandLine.arguments.dropFirst().first == "--cursor" {
|
||||
print("[\(position.x),\(position.y)]")
|
||||
exit(0)
|
||||
}
|
||||
if CommandLine.arguments.dropFirst().first == "--buttons" {
|
||||
let values = [CGMouseButton.left, .right, .center].map { CGEventSource.buttonState(.combinedSessionState, button: $0) }
|
||||
print(String(data: try! JSONSerialization.data(withJSONObject: values), encoding: .utf8)!)
|
||||
exit(0)
|
||||
}
|
||||
let statePath = CommandLine.arguments.dropFirst().first ?? Bundle.main.object(forInfoDictionaryKey: "DSHFixtureStatePath") as? String
|
||||
if let statePath {
|
||||
let application = NSApplication.shared
|
||||
|
||||
@@ -123,20 +123,35 @@ def check_toggle_mouse(helper, owner, state_file, executable):
|
||||
events = wait_for_state(state_file, lambda s: len(s["events"]) >= count + 3)["events"][count:]
|
||||
assert [e["type"] for e in events] == [down, moved, up], events
|
||||
assert len({e["eventNumber"] for e in events}) == 1 and not events[-1]["pressedButtons"] & (1 << index), events
|
||||
def wait_button(pressed):
|
||||
deadline = time.monotonic() + 10
|
||||
while time.monotonic() < deadline:
|
||||
buttons = json.loads(subprocess.check_output([executable, "--buttons"], text=True))
|
||||
if buttons[0] == pressed:
|
||||
return
|
||||
time.sleep(0.025)
|
||||
raise AssertionError(f"System left button did not become {pressed}")
|
||||
|
||||
for ending in ("releaseHeldInputs", "disconnect"):
|
||||
call("activate", owner)
|
||||
wait_for_state(state_file, lambda s: s["active"] and s["keyWindow"])
|
||||
assert cursor(*inside) == inside
|
||||
connection = Connection(socket, key)
|
||||
try:
|
||||
app = connection.call("getApp", {"selector": str(state["pid"])})
|
||||
count = len(json.loads(state_file.read_text())["events"])
|
||||
params = {**window, "mouseButton": "left", "useSystemPointer": True}
|
||||
connection.call("toggleMouse", {**params, "appHandle": app["appHandle"], "direction": "down"})
|
||||
wait_for_state(state_file, lambda s: len(s["events"]) > count)
|
||||
wait_button(True)
|
||||
call("toggleMouse", {**params, "direction": "up"}, "INVALID_ARGUMENT")
|
||||
wait_button(True)
|
||||
call("activate", {"appHandle": other_app["appHandle"]})
|
||||
wait_for_state(state_file, lambda s: not s["active"])
|
||||
if ending != "disconnect":
|
||||
connection.call(ending, {})
|
||||
finally:
|
||||
connection.close()
|
||||
events = wait_for_state(state_file, lambda s: len(s["events"]) >= count + 2)["events"][count:]
|
||||
assert [e["type"] for e in events] == [25, 26] and events[-1]["pressedButtons"] == 0, events
|
||||
wait_button(False)
|
||||
|
||||
finally:
|
||||
run_cleanup(lambda: cursor(*original), *([lambda: stop(other)] if other else []))
|
||||
|
||||
|
||||
@@ -456,7 +456,8 @@ it.each(['agent', 'provider', 'context'] as const)('awaits held input cleanup wh
|
||||
const release = f.native.controlNext('releaseHeldInputs')
|
||||
let disposed = false
|
||||
const closing = (owner === 'agent' ? f.handle.dispose() : owner === 'provider' ? f.provider.dispose() : f.ctx.fiber.dispose()).then(() => { disposed = true })
|
||||
await release.entered
|
||||
const first = await Promise.race([release.entered.then(() => 'cleanup'), closing.then(() => 'closed')])
|
||||
expect(first, JSON.stringify({ calls: f.native.calls, events: f.native.events, held: f.native.held })).toBe('cleanup')
|
||||
try {
|
||||
expect(disposed).toBe(false)
|
||||
expect(f.native.state.closedChannels).toBe(0)
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
{"type":"assistant/message","data":{"turn":1,"step":1,"message":{"role":"assistant","content":[{"type":"tool-call","id":"cua_first","name":"cua_run_code","arguments":"{\"code\":\"globalThis.visits = 1; var app = await cua.getApp(\\\"test.fixture\\\"); var win = await app.getWindow('7'); await win.getAccessibilityTree(); await win.click(\\\"0\\\"); var screenshot = await win.getScreenshot(); inspect(JSON.stringify({ visits, bindings: Object.keys(tools), app: app.appHandle, window: win.windowId })); inspect(screenshot)\",\"description\":\"Select and capture the fixture window\"}"}],"source":{"kind":"model","provider":"deepseek-official","model":"deepseek-v4-flash-vision-exp"},"id":"{{message:6}}"},"stream":[{"type":"chunk","time":1792108800000,"chunk":{"type":"block-start","index":0,"blockType":"tool-call"}},{"type":"chunk","time":1792108800000,"chunk":{"type":"block-end","index":0,"block":{"type":"tool-call","id":"cua_first","name":"cua_run_code","arguments":"{\"code\":\"globalThis.visits = 1; var app = await cua.getApp(\\\"test.fixture\\\"); var win = await app.getWindow('7'); await win.getAccessibilityTree(); await win.click(\\\"0\\\"); var screenshot = await win.getScreenshot(); inspect(JSON.stringify({ visits, bindings: Object.keys(tools), app: app.appHandle, window: win.windowId })); inspect(screenshot)\",\"description\":\"Select and capture the fixture window\"}"}}},{"type":"chunk","time":1792108800000,"chunk":{"type":"finish","reason":{"kind":"tool-calls"}}}]},"surfaceOp":"append"}
|
||||
{"type":"tool/call","data":{"turn":1,"step":1,"callId":"cua_first","name":"cua_run_code","arguments":"{\"code\":\"globalThis.visits = 1; var app = await cua.getApp(\\\"test.fixture\\\"); var win = await app.getWindow('7'); await win.getAccessibilityTree(); await win.click(\\\"0\\\"); var screenshot = await win.getScreenshot(); inspect(JSON.stringify({ visits, bindings: Object.keys(tools), app: app.appHandle, window: win.windowId })); inspect(screenshot)\",\"description\":\"Select and capture the fixture window\"}"}}
|
||||
{"type":"tool/ptc-dispatch-start","data":{"rootCallId":"cua_first","parentCallId":"cua_first","subCallId":"cua_first:ptc:1","name":"cua","arguments":{"method":"getCapabilities","params":{}}}}
|
||||
{"type":"tool/ptc-dispatch","data":{"rootCallId":"cua_first","parentCallId":"cua_first","subCallId":"cua_first:ptc:1","name":"cua","arguments":{"method":"getCapabilities","params":{}},"isError":false,"content":[{"type":"text","text":"{\"sessionLocked\":false,\"permissions\":{\"accessibility\":true,\"screenRecording\":true},\"platform\":\"macos\",\"systemPointer\":false,\"methods\":[\"getCapabilities\",\"getApp\",\"getState\",\"click\",\"screenshot\"],\"appLevelAccessibility\":true,\"keyboard\":[\"app\"],\"browser\":false,\"coordinateSpace\":\"screenshot-pixels\"}"}]}}
|
||||
{"type":"tool/ptc-dispatch","data":{"rootCallId":"cua_first","parentCallId":"cua_first","subCallId":"cua_first:ptc:1","name":"cua","arguments":{"method":"getCapabilities","params":{}},"isError":false,"content":[{"type":"text","text":"{\"sessionLocked\":false,\"permissions\":{\"accessibility\":true,\"screenRecording\":true},\"platform\":\"macos\",\"systemPointer\":false,\"methods\":[\"getCapabilities\",\"getApp\",\"getState\",\"click\",\"screenshot\",\"sendKeyEvent\",\"toggleMouse\"],\"appLevelAccessibility\":true,\"keyboard\":[\"app\"],\"browser\":false,\"coordinateSpace\":\"screenshot-pixels\"}"}]}}
|
||||
{"type":"tool/ptc-dispatch-start","data":{"rootCallId":"cua_first","parentCallId":"cua_first","subCallId":"cua_first:ptc:2","name":"cua","arguments":{"method":"getApp","params":{"selector":"test.fixture"}}}}
|
||||
{"type":"tool/ptc-dispatch","data":{"rootCallId":"cua_first","parentCallId":"cua_first","subCallId":"cua_first:ptc:2","name":"cua","arguments":{"method":"getApp","params":{"selector":"test.fixture"}},"isError":false,"content":[{"type":"text","text":"{\"appHandle\":\"fixture-app\",\"name\":\"Fixture\",\"bundleId\":\"test.fixture\",\"running\":true}"}]}}
|
||||
{"type":"tool/ptc-dispatch-start","data":{"rootCallId":"cua_first","parentCallId":"cua_first","subCallId":"cua_first:ptc:3","name":"cua","arguments":{"method":"getState","params":{"appHandle":"fixture-app","windowId":"7"}}}}
|
||||
|
||||
@@ -72,7 +72,7 @@ Use an explicit window for screenshots.
|
||||
## Simulated mouse
|
||||
Use an explicit window for pointer input. Before coordinate input, including relative coordinates, obtain a successful getAccessibilityTree observation covering that window or take its screenshot. Absolute pixel coordinates require a returned screenshot.
|
||||
- mouseMove(target: string | [number, number], options?: { relative?: boolean }) -> { dispatched: boolean, foregroundChanged?: boolean | null, hoverRoute: 'accessibility' | 'system-pointer', systemPointerMoved: boolean } — request a mouse move to the target without pressing a button; inspect hoverRoute and systemPointerMoved, and expect no automatic pointer restoration.
|
||||
- toggleMouse(mouseButton: 'left' | 'right' | 'middle', direction: 'down' | 'up') -> ActionResult — press or release the specified mouse button at the current pointer position without moving it. No coordinates are accepted. Release held buttons explicitly with 'up'; the opposite event is not sent automatically.
|
||||
- toggleMouse(mouseButton: 'left' | 'right' | 'middle', direction: 'down' | 'up') -> ActionResult — press or release the specified mouse button at the current pointer position without moving it. No coordinates are accepted. Release held buttons explicitly with 'up'; platform guidance defines their cleanup scope.
|
||||
- click(target: string | [number, number], options?: { mouseButton?: 'left' | 'right' | 'middle', clickCount?: 1 | 2, modifiers?: Modifier[], holdMs?: number, relative?: boolean }) -> ActionResult — click an element id or point, or perform a left-button double-click; holdMs controls the press duration of each press.
|
||||
- scroll(options: { x: number, y: number, deltaLinesX: number, deltaLinesY: number, relative?: boolean }) -> ActionResult — scroll at a point; deltas are integers from -10 to 10 with at least one nonzero, and positive values reveal content above or left.
|
||||
- drag(from: [number, number], to: [number, number], options?: { mouseButton?: 'left' | 'right' | 'middle', modifiers?: Modifier[], relative?: boolean }) -> ActionResult — drag between two points of one window.
|
||||
|
||||
Reference in new issue
Block a user