From b05241df4853d7d18a1bd309e2d3bf88212bc298 Mon Sep 17 00:00:00 2001 From: creatixchu Date: Thu, 12 Nov 2026 14:11:31 +0800 Subject: [PATCH] refactor(cua): name the shared tree flag hasUnreadableElements --- packages/experimental/cua-macos/README.i18n.yaml | 4 ++-- packages/experimental/cua-macos/README.md | 2 +- packages/experimental/cua-macos/README.zh.md | 2 +- .../cua-macos/native/README.i18n.yaml | 8 ++++---- packages/experimental/cua-macos/native/README.md | 4 ++-- .../experimental/cua-macos/native/README.zh.md | 4 ++-- .../native/Sources/CuaNative/AXAccess.swift | 16 ++++++++-------- .../Sources/CuaNative/AXObservedChildren.swift | 2 +- .../native/Sources/CuaNative/AXWorker.swift | 2 +- .../native/tests/ChildProjectionFixture.swift | 10 +++++----- .../native/tests/observation_benchmark.py | 2 +- .../tests/swift/AXObservedChildrenTests.swift | 16 ++++++++-------- packages/experimental/cua/README.i18n.yaml | 4 ++-- packages/experimental/cua/README.md | 2 +- packages/experimental/cua/README.zh.md | 2 +- packages/experimental/cua/src/protocol.ts | 2 +- packages/experimental/cua/tests/protocol.spec.ts | 2 +- snapshots/session/cua-native/session.v4.jsonl | 4 ++-- .../cua-native/workspace/native-helper.mjs | 2 +- 19 files changed, 45 insertions(+), 45 deletions(-) diff --git a/packages/experimental/cua-macos/README.i18n.yaml b/packages/experimental/cua-macos/README.i18n.yaml index c79bbde325..116539f106 100644 --- a/packages/experimental/cua-macos/README.i18n.yaml +++ b/packages/experimental/cua-macos/README.i18n.yaml @@ -15,8 +15,8 @@ en: 1777e7bf6785f986 zh: e3daac1074ebb74d /deepseek-ai-dsh-cua-macos/use-this-package: - en: cdc3a98b55b6276a - zh: 916b353eda539337 + en: 845b7d3ae975db5d + zh: 06d823bbe64eea1a /deepseek-ai-dsh-cua-macos/use-this-package/connect-an-external-execution-environment: en: 7058be5d1b778643 zh: 821de6b0ad7aba27 diff --git a/packages/experimental/cua-macos/README.md b/packages/experimental/cua-macos/README.md index 22aec98744..6f407e5f55 100644 --- a/packages/experimental/cua-macos/README.md +++ b/packages/experimental/cua-macos/README.md @@ -91,7 +91,7 @@ Application consent is enforced before AX reads, window-title reads, screenshots Raw `getState` exposes validated state fields and the complete text for the requested disclosure options. The native helper also returns structured element diagnostics with opaque string `elementId` values for native checks; the tool projection omits that duplicate array from model text and structured tool values. -AX observations show menu-bar entries by default. Use `app.getAccessibilityTree({ includeMenus: true })` to expand menu contents and `app.getAccessibilityTree({ details: true })` for identifiers, global-point bounds and complete action names. These options also apply to raw `getState`. Every read replaces the application's current snapshot; use element IDs from that read. Pass `maxElements` or `maxDepth` to override either configured limit for one read. Truncation identifies the reached limit. Unreadable children have separate markers in the tree and set the optional raw `incomplete` flag. +AX observations show menu-bar entries by default. Use `app.getAccessibilityTree({ includeMenus: true })` to expand menu contents and `app.getAccessibilityTree({ details: true })` for identifiers, global-point bounds and complete action names. These options also apply to raw `getState`. Every read replaces the application's current snapshot; use element IDs from that read. Pass `maxElements` or `maxDepth` to override either configured limit for one read. Truncation identifies the reached limit. Unreadable children have separate markers in the tree and set the optional raw `hasUnreadableElements` flag. Values and placeholders are separate. Named, stateful or actionable groups and scroll areas retain their own rows. Repeated names, descriptions and help text on one node are shown once. Values, placeholders and URLs keep their distinct meanings even when their text matches; body text shared by distinct nodes remains intact. Writability is explicit on relevant controls, including `AXIncrementor`; `unknown` means the system did not report it. Missing optional state fields do not imply false. During tree observation, an AXValue or AXSelectedTextRange writability probe returning -25200 leaves that field unknown and preserves the remaining nodes. Actual writes remain strict; permission, communication and invalid-element errors still propagate. UTF-16 ranges outside the observed value are marked unavailable. Compact tree labels can omit AppKit target and selector details. Pass the exact name returned by `listActions(elementId)` to `performAction`. diff --git a/packages/experimental/cua-macos/README.zh.md b/packages/experimental/cua-macos/README.zh.md index 6e0951656e..51214536aa 100644 --- a/packages/experimental/cua-macos/README.zh.md +++ b/packages/experimental/cua-macos/README.zh.md @@ -91,7 +91,7 @@ CUA 工具在读取 AX、窗口标题、截图、激活和输入前检查应用 原始 `getState` 操作返回经过校验的状态字段,以及按本次披露选项生成的完整文本。原生 helper 还返回供原生检查使用的结构化元素诊断数组,其中 `elementId` 是不透明字符串;工具投影会从模型文本和结构化工具值中移除这份重复数组。 -AX 观察默认只展示菜单栏入口。使用 `app.getAccessibilityTree({ includeMenus: true })` 展开菜单内容,使用 `app.getAccessibilityTree({ details: true })` 读取标识符、全局 point 坐标和完整动作名。原始 `getState` 也接受这两个选项。每次读取都会替换应用当前的快照;应使用该次读取返回的元素 ID。传入 `maxElements` 或 `maxDepth` 可调整本次读取的上限。树被截断时会提示触发的上限。子项无法读取时,树中会标出缺失部分,原始结果会返回 `incomplete: true`。 +AX 观察默认只展示菜单栏入口。使用 `app.getAccessibilityTree({ includeMenus: true })` 展开菜单内容,使用 `app.getAccessibilityTree({ details: true })` 读取标识符、全局 point 坐标和完整动作名。原始 `getState` 也接受这两个选项。每次读取都会替换应用当前的快照;应使用该次读取返回的元素 ID。传入 `maxElements` 或 `maxDepth` 可调整本次读取的上限。树被截断时会提示触发的上限。子项无法读取时,树中会标出缺失部分,原始结果会返回 `hasUnreadableElements: true`。 实际值与占位文字分别展示。有名称、状态或可用动作的分组和滚动区域保留独立行。同一节点中重复的名称、描述和帮助只显示一次。实际值、占位文字和 URL 即使文字相同也保留各自含义,不删除不同节点共有的正文。相关控件明确展示可写性,包括 `AXIncrementor`;`unknown` 表示系统未报告。缺少可选状态字段不代表 false。读树时,AXValue 或 AXSelectedTextRange 的可写性探测返回 -25200,会将该字段保留为未知并继续读取其他节点。实际写入仍严格校验;权限、通信和失效元素错误仍向上传播。超出当前值长度的 UTF-16 选区标为不可用。树中的动作简称可能省略 AppKit 的 target 和 selector 信息。调用 `performAction` 时使用 `listActions(elementId)` 返回的完整名称。 diff --git a/packages/experimental/cua-macos/native/README.i18n.yaml b/packages/experimental/cua-macos/native/README.i18n.yaml index 7606a6cae0..7633a1d118 100644 --- a/packages/experimental/cua-macos/native/README.i18n.yaml +++ b/packages/experimental/cua-macos/native/README.i18n.yaml @@ -18,11 +18,11 @@ en: f29d74be684f5840 zh: 67233850329d1db1 /dsh-cua-native-helper/request-protocol: - en: a4c19481775543da - zh: 5f941dcd6d9bbe92 + en: a993e9eacf63cceb + zh: 12292c9ba53df2ad /dsh-cua-native-helper/observation-and-input: - en: 4064b620848b6e1e - zh: 7fcfce4c0367a897 + en: a41e41d4e83e0e7b + zh: d2bdfe14578fa548 /dsh-cua-native-helper/verification: en: 908b13b2732c1bec zh: ac3bbd77ed9a69b8 diff --git a/packages/experimental/cua-macos/native/README.md b/packages/experimental/cua-macos/native/README.md index 129736c01e..8cdef2ac19 100644 --- a/packages/experimental/cua-macos/native/README.md +++ b/packages/experimental/cua-macos/native/README.md @@ -75,7 +75,7 @@ Successful `activate` returns `dispatched` and `foregroundChanged`. A known chan | `getApp` | Running selection returns `{appHandle, pid, name, bundleId?, running: true, authorization}`. A stopped selection returns `{appHandle, name, bundleId?, running: false, authorization}` with no `pid`, and waits for Host consent. An installed selection matches running processes by executable path. Multiple matching processes return `AMBIGUOUS_APP`; select a PID from `listApps`. | | `launchApp` | After Host consent, opens the selected installation without requesting activation, waits for launch completion, and binds the handle to the verified process. If multiple instances appear during approval or launch, the handle expires with `AMBIGUOUS_APP`. | | `listWindows` | Owned WindowServer records: `{windowId, appName, title, bounds, isOnScreen, onCurrentSpace, cacheOnly?}`. Space membership can be null. Only auxiliary windows that are offscreen, have zero area or are known to be on another Space carry `cacheOnly: true`. The Host observes their size but omits them from discovery. A scoped read can return its explicitly selected window; the private field never enters tool results. | -| `getState` | `{appHandle, windowId, focusedWindowId, snapshotId, tree, elements, windows, truncated, incomplete?}`. `windowId` is null for an app-wide observation. Elements include the opaque string `elementId`, role, title, value, description, identifier, bounds, actions, and enabled state. Element bounds are null or [x, y, width, height] in screen points; window input uses local points. These structured element diagnostics are retained by native checks and omitted by the model tool projection. Unavailable optional descriptive properties are null, and an unavailable action list is empty; permission, communication and window-discovery failures still reject the observation. | +| `getState` | `{appHandle, windowId, focusedWindowId, snapshotId, tree, elements, windows, truncated, hasUnreadableElements?}`. `windowId` is null for an app-wide observation. Elements include the opaque string `elementId`, role, title, value, description, identifier, bounds, actions, and enabled state. Element bounds are null or [x, y, width, height] in screen points; window input uses local points. These structured element diagnostics are retained by native checks and omitted by the model tool projection. Unavailable optional descriptive properties are null, and an unavailable action list is empty; permission, communication and window-discovery failures still reject the observation. | | `listActions` | Provider-defined action names for one element as a string array; an element may advertise none. | | `show` | `{dispatched: boolean, windowId, foregroundChanged}` records restoration dispatch. `windowId` is null when no window was selected; `foregroundChanged` is null when the sampled observation was unavailable. | | `invoke`, `performAction`, `mouseMove`, `click`, `setValue`, `selectText`, `typeText`, `paste`, `pressKey`, `sendKeyEvent`, `scroll`, `drag` | `{dispatched: boolean}` records native dispatch; `invoke` reports false when no applicable default action exists. `mouseMove` also reports `hoverRoute` and `systemPointerMoved`. Read fresh state to verify the intended application change. | @@ -95,7 +95,7 @@ Protocol declarations are generated from [the shared protocol](../../cua/src/pro ## Observation and input -`getState` optionally scopes AX traversal to an owned window or nested sheet `windowId`. A new or failed refresh invalidates the previous snapshot for that app/window scope, while other window scopes remain usable. When window discovery completes and an owned CG window has no matching AX surface, getState returns a new snapshot with empty tree/elements and no truncation; its coordinates and screenshots remain available. It rechecks process lifetime, window ownership, the unlocked session and Accessibility permission after traversal. Window-discovery APIDisabled and communication errors remain failures; unsupported or absent optional AX attributes can produce an empty observation. Missing or foreign-owned windows never produce an empty success. If reading `AXChildren` returns -25200, the helper reads failed ranges of up to five children individually and halves larger failed ranges. Successful ranges retain their original order. An observation makes at most `maxElements` extra count and range reads. It stops starting recovery reads once recovery has spent `axTimeoutMs`. The overall request deadline is `timeoutMs`. An unreadable child has a marker in sibling order and no element ID. If positions are unknown, the tree marks the parent instead. Both cases set `incomplete: true`. This field is omitted when all visited child lists were readable. Only a node or depth limit sets `truncated: true`. An AX element invalidated during traversal rejects the whole read with `STALE_SNAPSHOT`; no partial snapshot is published. Callers may read again after the application changes, without repeating input. Raw element targets require `appHandle`, `snapshotId` and an opaque string `elementId`. For `click` and `mouseMove`, the optional `windowId` must match both the snapshot scope (unless app-wide) and the element’s enclosing window or sheet. A mismatch returns `STALE_SNAPSHOT` before dispatch. Coordinate targets use `windowId`, `x` and `y` and may include a snapshot from that window or the app. Mixing an element ID with coordinates returns `INVALID_ARGUMENT`. The Host converts relative coordinates before dispatch, so the native JSONL protocol rejects the `relative` field. Native references never cross JSON. Window-list refresh releases snapshots for closed windows. Native process identity, snapshot generation, and window ownership checks do not lock the desktop against simultaneous user or application changes. +`getState` optionally scopes AX traversal to an owned window or nested sheet `windowId`. A new or failed refresh invalidates the previous snapshot for that app/window scope, while other window scopes remain usable. When window discovery completes and an owned CG window has no matching AX surface, getState returns a new snapshot with empty tree/elements and no truncation; its coordinates and screenshots remain available. It rechecks process lifetime, window ownership, the unlocked session and Accessibility permission after traversal. Window-discovery APIDisabled and communication errors remain failures; unsupported or absent optional AX attributes can produce an empty observation. Missing or foreign-owned windows never produce an empty success. If reading `AXChildren` returns -25200, the helper reads failed ranges of up to five children individually and halves larger failed ranges. Successful ranges retain their original order. An observation makes at most `maxElements` extra count and range reads. It stops starting recovery reads once recovery has spent `axTimeoutMs`. The overall request deadline is `timeoutMs`. An unreadable child has a marker in sibling order and no element ID. If positions are unknown, the tree marks the parent instead. Both cases set `hasUnreadableElements: true`. This field is omitted when all visited child lists were readable. Only a node or depth limit sets `truncated: true`. An AX element invalidated during traversal rejects the whole read with `STALE_SNAPSHOT`; no partial snapshot is published. Callers may read again after the application changes, without repeating input. Raw element targets require `appHandle`, `snapshotId` and an opaque string `elementId`. For `click` and `mouseMove`, the optional `windowId` must match both the snapshot scope (unless app-wide) and the element’s enclosing window or sheet. A mismatch returns `STALE_SNAPSHOT` before dispatch. Coordinate targets use `windowId`, `x` and `y` and may include a snapshot from that window or the app. Mixing an element ID with coordinates returns `INVALID_ARGUMENT`. The Host converts relative coordinates before dispatch, so the native JSONL protocol rejects the `relative` field. Native references never cross JSON. Window-list refresh releases snapshots for closed windows. Native process identity, snapshot generation, and window ownership checks do not lock the desktop against simultaneous user or application changes. Hiding a window does not itself expire its AX snapshot. An inventory refresh can retain the previous screenshot mapping only while the same window ID remains present at the same observed size. An observed size change requires a new screenshot for pixel input; a closed window cannot be targeted. Omission from discovery does not block input to a known ID: ownership, geometry and input checks still apply, and dispatch does not confirm receipt. diff --git a/packages/experimental/cua-macos/native/README.zh.md b/packages/experimental/cua-macos/native/README.zh.md index 0a18aab992..6a06e2cc84 100644 --- a/packages/experimental/cua-macos/native/README.zh.md +++ b/packages/experimental/cua-macos/native/README.zh.md @@ -75,7 +75,7 @@ AppKit 在主事件循环上运行。阻塞式 socket 接收与握手使用后 | `getApp` | 运行中的选择返回 `{appHandle, pid, name, bundleId?, running: true, authorization}`。未运行的选择返回 `{appHandle, name, bundleId?, running: false, authorization}`,其中没有 `pid`,并等待 Host 授权。找到安装包后,按可执行文件路径查找运行进程。若匹配多个进程,返回 `AMBIGUOUS_APP`,可从 `listApps` 选择 PID。 | | `launchApp` | Host 授权后,打开指定安装副本,等待启动完成并将句柄绑定到已核实的进程,全程不请求激活。若授权或启动期间出现多个匹配实例,待启动句柄失效,返回 `AMBIGUOUS_APP`。 | | `listWindows` | WindowServer 返回所属窗口的 `{windowId, appName, title, bounds, isOnScreen, onCurrentSpace, cacheOnly?}`,Space 归属可能为 null。只有离屏、面积为零或已确定位于其他 Space 的辅助窗口带有 `cacheOnly: true`。Host 用这些记录更新尺寸,枚举时省略它们。窗口级观察仍可返回显式选中的目标,工具结果不含这个私有字段。 | -| `getState` | `{appHandle, windowId, focusedWindowId, snapshotId, tree, elements, windows, truncated, incomplete?}`。应用级观察的 `windowId` 为 null。元素包含不透明字符串 `elementId`、role、title、value、description、identifier、bounds、actions 和 enabled 状态。元素边界为 null 或屏幕 point 单位的 [x, y, width, height],窗口输入使用局部 point。这些结构化元素诊断供原生检查保留,模型工具投影会移除它们。不可用的可选描述属性为 null,无法取得的动作列表为空;权限、通信和窗口发现失败仍会拒绝观察。 | +| `getState` | `{appHandle, windowId, focusedWindowId, snapshotId, tree, elements, windows, truncated, hasUnreadableElements?}`。应用级观察的 `windowId` 为 null。元素包含不透明字符串 `elementId`、role、title、value、description、identifier、bounds、actions 和 enabled 状态。元素边界为 null 或屏幕 point 单位的 [x, y, width, height],窗口输入使用局部 point。这些结构化元素诊断供原生检查保留,模型工具投影会移除它们。不可用的可选描述属性为 null,无法取得的动作列表为空;权限、通信和窗口发现失败仍会拒绝观察。 | | `listActions` | 一个元素由 provider 定义的动作名数组;元素可以不声明任何动作。 | | `show` | `{dispatched: boolean, windowId, foregroundChanged}` 记录恢复分派。未选中窗口时 `windowId` 为 null;无法取得采样观察时 `foregroundChanged` 为 null。 | | `invoke`, `performAction`, `mouseMove`, `click`, `setValue`, `selectText`, `typeText`, `paste`, `pressKey`, `sendKeyEvent`, `scroll`, `drag` | `{dispatched: boolean}` 记录原生分派;`invoke` 在没有可用的默认动作时返回 false。`mouseMove` 还报告 `hoverRoute` 和 `systemPointerMoved`。需要读取新状态以核实预期的应用变化。 | @@ -95,7 +95,7 @@ AppKit 在主事件循环上运行。阻塞式 socket 接收与握手使用后 ## 观察与输入 -`getState` 可将 AX 遍历限定到应用所属窗口或嵌套 sheet 的 `windowId`。新的刷新或失败的刷新使同一应用/窗口范围的旧快照失效,其他窗口范围仍可使用。窗口发现完成后,如果应用所属 CG 窗口没有匹配的 AX 界面,getState 返回空 tree/elements、truncated 为 false 的新快照,仍可截图和坐标输入。遍历后重新检查进程生命期、窗口归属、会话未锁定及辅助功能权限。窗口发现中的 APIDisabled 和通信错误仍会失败;不支持或缺失的可选 AX 属性可以产生空观察。不存在或属于其他应用的窗口不会返回空成功结果。读取 `AXChildren` 返回 -25200 时,helper 将读取失败且超过 5 项的范围对半拆分,5 项及以下的失败范围按下标逐项读取,成功的范围按原顺序保留。一次观察中的额外计数和范围读取合计不超过 `maxElements` 次。恢复累计耗时达到 `axTimeoutMs` 后停止发起新的恢复读取,整个请求受 `timeoutMs` 限制。树在不可读子项的原位置插入提示,不为提示分配元素 ID。无法确定位置时,在父节点处标记。两种情况都返回 `incomplete: true`。已访问的子项列表全部可读时省略该字段。只有触及节点数或深度上限时才返回 `truncated: true`。遍历中 AX 元素失效会以 `STALE_SNAPSHOT` 拒绝整次读取,不发布部分树。应用变化后可以重新观察,但不重复输入。原生元素目标需要 `appHandle`、`snapshotId` 和字符串 `elementId`。`click` 和 `mouseMove` 可附带 `windowId`。它必须与元素所属窗口或 sheet 一致,对窗口级快照还必须与快照的窗口一致,否则在发送输入前返回 `STALE_SNAPSHOT`。坐标目标使用 `windowId`、`x`、`y`,可以附带来自该窗口或应用的快照。混用元素 ID 和坐标会返回 `INVALID_ARGUMENT`。Host 在发送请求前换算相对坐标,原生 JSONL 协议会拒绝 `relative` 字段。原生引用不跨 JSON 传递。刷新窗口列表会释放已关闭窗口的快照。进程身份、快照代次和窗口归属检查不会锁住桌面,用户或应用仍可同时改变状态。 +`getState` 可将 AX 遍历限定到应用所属窗口或嵌套 sheet 的 `windowId`。新的刷新或失败的刷新使同一应用/窗口范围的旧快照失效,其他窗口范围仍可使用。窗口发现完成后,如果应用所属 CG 窗口没有匹配的 AX 界面,getState 返回空 tree/elements、truncated 为 false 的新快照,仍可截图和坐标输入。遍历后重新检查进程生命期、窗口归属、会话未锁定及辅助功能权限。窗口发现中的 APIDisabled 和通信错误仍会失败;不支持或缺失的可选 AX 属性可以产生空观察。不存在或属于其他应用的窗口不会返回空成功结果。读取 `AXChildren` 返回 -25200 时,helper 将读取失败且超过 5 项的范围对半拆分,5 项及以下的失败范围按下标逐项读取,成功的范围按原顺序保留。一次观察中的额外计数和范围读取合计不超过 `maxElements` 次。恢复累计耗时达到 `axTimeoutMs` 后停止发起新的恢复读取,整个请求受 `timeoutMs` 限制。树在不可读子项的原位置插入提示,不为提示分配元素 ID。无法确定位置时,在父节点处标记。两种情况都返回 `hasUnreadableElements: true`。已访问的子项列表全部可读时省略该字段。只有触及节点数或深度上限时才返回 `truncated: true`。遍历中 AX 元素失效会以 `STALE_SNAPSHOT` 拒绝整次读取,不发布部分树。应用变化后可以重新观察,但不重复输入。原生元素目标需要 `appHandle`、`snapshotId` 和字符串 `elementId`。`click` 和 `mouseMove` 可附带 `windowId`。它必须与元素所属窗口或 sheet 一致,对窗口级快照还必须与快照的窗口一致,否则在发送输入前返回 `STALE_SNAPSHOT`。坐标目标使用 `windowId`、`x`、`y`,可以附带来自该窗口或应用的快照。混用元素 ID 和坐标会返回 `INVALID_ARGUMENT`。Host 在发送请求前换算相对坐标,原生 JSONL 协议会拒绝 `relative` 字段。原生引用不跨 JSON 传递。刷新窗口列表会释放已关闭窗口的快照。进程身份、快照代次和窗口归属检查不会锁住桌面,用户或应用仍可同时改变状态。 窗口隐藏本身不会使 AX 快照失效。刷新清单时,只有同一窗口 ID 仍存在且观察到的尺寸未变,才能继续使用此前截图的像素坐标。观察到尺寸变化后需要重新截图;窗口销毁后不能继续操作。清单中省略窗口不会阻止按已知 ID 发起输入。窗口归属、尺寸和输入检查仍然生效,成功分派不代表应用已接收。 diff --git a/packages/experimental/cua-macos/native/Sources/CuaNative/AXAccess.swift b/packages/experimental/cua-macos/native/Sources/CuaNative/AXAccess.swift index b12a2e8153..cb2e199469 100644 --- a/packages/experimental/cua-macos/native/Sources/CuaNative/AXAccess.swift +++ b/packages/experimental/cua-macos/native/Sources/CuaNative/AXAccess.swift @@ -11,7 +11,7 @@ struct AXProjection { let indexed: [Int: AXUIElement] let focusedWindowID: UInt32? let truncated: Bool - let incomplete: Bool + let hasUnreadableElements: Bool } struct AXNodeObservation { @@ -621,13 +621,13 @@ final class AXAccess { } if matches.isEmpty { _ = try NativePlatform.ownedWindow(identity.pid, requested) - let incomplete = discovery.values.contains(where: \.incomplete) + let hasUnreadableElements = discovery.values.contains(where: \.hasUnreadableElements) let limited = discovery.values.contains(where: \.elementLimitReached) var lines: [String] = [] - if incomplete { lines.append(AXTextFormatter.incompleteDiscovery) } + if hasUnreadableElements { lines.append(AXTextFormatter.incompleteDiscovery) } if limited { lines.append(AXTextFormatter.truncation(maxElements: maxElements, maxDepth: nil)) } return AXProjection(tree: lines.joined(separator: "\n"), elements: [], indexed: [:], focusedWindowID: focusedID, - truncated: limited, incomplete: incomplete) + truncated: limited, hasUnreadableElements: hasUnreadableElements) } let dialog = try matches.contains { root in let role = try string(root, "AXRole") @@ -646,7 +646,7 @@ final class AXAccess { var count = 0 var elementLimitReached = appChildren.elementLimitReached var depthLimitReached = false - var childrenMissing = appChildren.incomplete + var childrenMissing = appChildren.hasUnreadableElements var menusCollapsed = false var lines = ["AX scope=\(requested == nil ? "application" : "window") offsets=UTF-16\(details ? " bounds=global-points" : "")"] var elements: [JSONValue] = [] @@ -657,12 +657,12 @@ final class AXAccess { if appChildren.parentIncomplete { lines.append(AXTextFormatter.unreadableChildLine(level: 0, positioned: false)) } } else { rootEntries = roots - if appChildren.incomplete { lines.append(AXTextFormatter.incompleteDiscovery) } + if appChildren.hasUnreadableElements { lines.append(AXTextFormatter.incompleteDiscovery) } } var pending = rootEntries.reversed().map { (element: $0, level: 0, depth: 0) } func enqueueChildren(_ parent: AXUIElement, observation: AXNodeObservation, level: Int, depth: Int) throws { let children = try observedChildren(parent, observation.attribute("AXChildren")) - if children.incomplete { childrenMissing = true } + if children.hasUnreadableElements { childrenMissing = true } if children.elementLimitReached { elementLimitReached = true } if children.parentIncomplete { lines.append(AXTextFormatter.unreadableChildLine(level: level, positioned: false)) } for child in children.entries.reversed() { pending.append((child, level, depth)) } @@ -741,7 +741,7 @@ final class AXAccess { if menusCollapsed { lines.append("Menu contents omitted; request includeMenus=true to expand.") } let truncated = elementLimitReached || depthLimitReached if truncated { lines.append(AXTextFormatter.truncation(maxElements: elementLimitReached ? maxElements : nil, maxDepth: depthLimitReached ? maxDepth : nil)) } - return AXProjection(tree: lines.joined(separator: "\n"), elements: elements, indexed: indexed, focusedWindowID: focusedID, truncated: truncated, incomplete: childrenMissing) + return AXProjection(tree: lines.joined(separator: "\n"), elements: elements, indexed: indexed, focusedWindowID: focusedID, truncated: truncated, hasUnreadableElements: childrenMissing) } func enclosingWindow(_ element: AXUIElement) throws -> (element: AXUIElement, id: UInt32) { diff --git a/packages/experimental/cua-macos/native/Sources/CuaNative/AXObservedChildren.swift b/packages/experimental/cua-macos/native/Sources/CuaNative/AXObservedChildren.swift index bd0f324c15..83a31242ab 100644 --- a/packages/experimental/cua-macos/native/Sources/CuaNative/AXObservedChildren.swift +++ b/packages/experimental/cua-macos/native/Sources/CuaNative/AXObservedChildren.swift @@ -6,7 +6,7 @@ struct AXObservedChildren { var parentIncomplete = false var elementLimitReached = false - var incomplete: Bool { parentIncomplete || entries.contains(nil) } + var hasUnreadableElements: Bool { parentIncomplete || entries.contains(nil) } static var unavailable: Self { Self(parentIncomplete: true) } enum RangeRead { diff --git a/packages/experimental/cua-macos/native/Sources/CuaNative/AXWorker.swift b/packages/experimental/cua-macos/native/Sources/CuaNative/AXWorker.swift index 7121be37d2..362fa990a4 100644 --- a/packages/experimental/cua-macos/native/Sources/CuaNative/AXWorker.swift +++ b/packages/experimental/cua-macos/native/Sources/CuaNative/AXWorker.swift @@ -341,7 +341,7 @@ actor AXWorker { "focusedWindowId": projection.focusedWindowID.map { .string(String($0)) } ?? .null, "snapshotId": .string(id), "tree": .string(projection.tree), "elements": .array(projection.elements), "windows": .array(observedWindows.map(\.json)), "truncated": .bool(projection.truncated)] - if projection.incomplete { state["incomplete"] = .bool(true) } + if projection.hasUnreadableElements { state["hasUnreadableElements"] = .bool(true) } return .result(.object(state)) case "screenshot": trace?.mark("screen-permission.begin") diff --git a/packages/experimental/cua-macos/native/tests/ChildProjectionFixture.swift b/packages/experimental/cua-macos/native/tests/ChildProjectionFixture.swift index 819083143e..0ea3c3db62 100644 --- a/packages/experimental/cua-macos/native/tests/ChildProjectionFixture.swift +++ b/packages/experimental/cua-macos/native/tests/ChildProjectionFixture.swift @@ -55,9 +55,9 @@ import ApplicationServices try check(AXUIElementCopyAttributeValue(badRoot, kAXChildrenAttribute as CFString, &whole) == .failure, "AXChildren must return -25200") let complete = try project(good) - try check(!complete.truncated && !complete.incomplete && complete.tree.contains("Healthy window"), "An unrelated window reported missing children") + try check(!complete.truncated && !complete.hasUnreadableElements && complete.tree.contains("Healthy window"), "An unrelated window reported missing children") let partial = try project(bad) - try check(!partial.truncated && partial.incomplete, "Unreadable children must only set incomplete") + try check(!partial.truncated && partial.hasUnreadableElements, "Unreadable children must only set hasUnreadableElements") let lines = partial.tree.components(separatedBy: "\n").map { $0.trimmingCharacters(in: .whitespaces) } let gaps = lines.indices.filter { lines[$0] == "[One child could not be read.]" } guard let left = lines.firstIndex(where: { $0.contains("AXButton") && $0.contains("\"Before gap\"") }), @@ -77,15 +77,15 @@ import ApplicationServices while bad.pressed.count < 2 && Date() < deadline { RunLoop.current.run(until: Date().addingTimeInterval(0.01)) } try check(bad.pressed == ["Before gap", "After gap"], "Both buttons must receive AXPress") let limited = try project(bad, depth: 1) - try check(limited.truncated && limited.incomplete && limited.tree.contains("maxDepth=1"), "Traversal and AX failures must report both flags") + try check(limited.truncated && limited.hasUnreadableElements && limited.tree.contains("maxDepth=1"), "Traversal and AX failures must report both flags") app.setAccessibilityChildren([good]) app.setAccessibilityWindows([good]) app.setAccessibilityFocusedWindow(good) let unexposed = try project(bad) - try check(unexposed.tree.isEmpty && !unexposed.incomplete, "Exhaustive discovery should report an AX-less window") + try check(unexposed.tree.isEmpty && !unexposed.hasUnreadableElements, "Exhaustive discovery should report an AX-less window") good.childList = [NSNull()] let uncertain = try project(bad) - try check(uncertain.incomplete && !uncertain.truncated && uncertain.indexed.isEmpty, + try check(uncertain.hasUnreadableElements && !uncertain.truncated && uncertain.indexed.isEmpty, "Partial window discovery must not expose controls from another window") print("Passed real AX range recovery, sibling actions, window scoping and independent observation flags.") } diff --git a/packages/experimental/cua-macos/native/tests/observation_benchmark.py b/packages/experimental/cua-macos/native/tests/observation_benchmark.py index 5b5bced711..d5c0f75e68 100644 --- a/packages/experimental/cua-macos/native/tests/observation_benchmark.py +++ b/packages/experimental/cua-macos/native/tests/observation_benchmark.py @@ -232,7 +232,7 @@ def check_observation(value, row_count, app_handle, window_id): raise AssertionError("Complete benchmark observation was truncated") if not isinstance(value["tree"], str) or not isinstance(value["elements"], list) or not isinstance(value["windows"], list): raise AssertionError("Observation tree, elements or windows have unexpected types") - if value.get("incomplete", False): + if value.get("hasUnreadableElements", False): raise AssertionError("Complete benchmark observation has unreadable children") labels = {int(number) for number in re.findall(r"\bScroll row ([0-9]+)\b", value["tree"])} if labels != set(range(1, row_count + 1)): diff --git a/packages/experimental/cua-macos/native/tests/swift/AXObservedChildrenTests.swift b/packages/experimental/cua-macos/native/tests/swift/AXObservedChildrenTests.swift index 4242d05cec..0b1c8ee18a 100644 --- a/packages/experimental/cua-macos/native/tests/swift/AXObservedChildrenTests.swift +++ b/packages/experimental/cua-macos/native/tests/swift/AXObservedChildrenTests.swift @@ -10,7 +10,7 @@ import Testing let children = AXObservedChildren.readRanges(count: nodes.count, limit: nodes.count, requests: &requests) { range in range.contains(17) ? .unreadable : .values(Array(nodes[range])) } - #expect(children.incomplete) + #expect(children.hasUnreadableElements) var expected = nodes.map(Optional.some) expected[17] = nil #expect(children.entries == expected) @@ -25,7 +25,7 @@ import Testing return range.upperBound > 2 ? .unreadable : .values(Array(repeating: node, count: range.count)) } #expect(limited.entries == [node, node]) - #expect(limited.incomplete) + #expect(limited.hasUnreadableElements) #expect(requests == 0) let exhausted = AXObservedChildren.readRanges(count: 2, limit: 2, requests: &requests) { _ in @@ -33,7 +33,7 @@ import Testing return .unreadable } #expect(exhausted.entries.isEmpty) - #expect(exhausted.incomplete) + #expect(exhausted.hasUnreadableElements) } @Test func aChangedRangeRetainsReadableReferencesAndOtherErrorsPropagate() { @@ -43,7 +43,7 @@ import Testing if range.count == 2 { return .unreadable } return range.lowerBound == 0 ? .values([node]) : .positionsUnknown } - #expect(changed.incomplete) + #expect(changed.hasUnreadableElements) #expect(changed.entries == [node]) #expect(changed.parentIncomplete) #expect(throws: CancellationError.self) { @@ -56,7 +56,7 @@ import Testing var requests = 1 let recovered = AXObservedChildren.readRanges(count: 1, limit: 1, requests: &requests) { _ in .values([node]) } #expect(recovered.entries == [node]) - #expect(!recovered.incomplete) + #expect(!recovered.hasUnreadableElements) } @Test(arguments: [1, 5, 6]) @@ -82,13 +82,13 @@ import Testing Issue.record("An empty list has no ranges") return .unreadable } - #expect(!empty.incomplete && !empty.elementLimitReached) + #expect(!empty.hasUnreadableElements && !empty.elementLimitReached) for limit in [0, 1] { let limited = AXObservedChildren.readRanges(count: 3, limit: limit, requests: &requests) { range in #expect(range == 0..<1) return .values([node]) } - #expect(limited.elementLimitReached && !limited.incomplete) + #expect(limited.elementLimitReached && !limited.hasUnreadableElements) #expect(limited.entries.count == limit) } #expect(requests == 2) @@ -103,7 +103,7 @@ import Testing NativeFailure(code: "NATIVE_ERROR", message: name, accessibilityError: code.rawValue, attribute: name) } let fresh = try AXObservedChildren.observing({ [ref] }, recover: prior) - #expect(!fresh.incomplete) + #expect(!fresh.hasUnreadableElements) let repeated = try AXObservedChildren.observing({ throw failure("AXChildren", .failure) }, recover: prior) #expect(repeated.entries == [nil, ref]) for (name, code) in [("AXRole", AXError.failure), ("AXChildren", .invalidUIElement), diff --git a/packages/experimental/cua/README.i18n.yaml b/packages/experimental/cua/README.i18n.yaml index 51ad47b62f..7d0365be3f 100644 --- a/packages/experimental/cua/README.i18n.yaml +++ b/packages/experimental/cua/README.i18n.yaml @@ -15,8 +15,8 @@ en: 5db4d4fea25493b9 zh: 65ab64fc24eb0d09 /deepseek-ai-dsh-cua/use-this-package: - en: c59986e14b6cf9ad - zh: 10c7f6acef208342 + en: 49bc5ee90b46af86 + zh: 30c8840069c40242 /deepseek-ai-dsh-cua/use-this-package/permission-controls: en: 754ca69ec462325a zh: 440d76acf2666689 diff --git a/packages/experimental/cua/README.md b/packages/experimental/cua/README.md index ab0f2757cf..e998a728c9 100644 --- a/packages/experimental/cua/README.md +++ b/packages/experimental/cua/README.md @@ -39,7 +39,7 @@ Raw `cua` registration uses the base CUA services and preset selection, independ `cua` is installed once when its environment is created. Do not overwrite this global. To rebuild a damaged environment, run `process.exit(0)` in `cua_run_code`; that call reports a process-exit failure. The next call starts a fresh environment and restores `cua`. Recreate other variables and select applications and windows again. -Use `cua.getApp(selector)` to select an application; it obtains consent and optionally launches a stopped application in the background, without reading its accessibility tree. On macOS, `cua.listApps()` and `cua.getState().apps` report each running process with its numeric `pid`. The application ID is its bundle ID or, when absent, its PID string. Pass `String(row.pid)` to `cua.getApp()` to distinguish processes with the same name or bundle ID. Running `cua.findApps(query)` matches include their PID and keep their installation ID and path. Windows returns provider-issued application IDs without a PID. `app.activate()`, `app.getWindows()`, and `app.getWindow(windowId)` operate on the selected application; `getWindow` returns the object without a native request; window operations reject closed or foreign windows. Select an application and one of its windows before any capture or pointer input. Read `app.getAccessibilityTree()` or `window.getAccessibilityTree()` explicitly before element operations. Screenshots remain available when AX reading fails. App and window reads accept `maxElements` and `maxDepth` independently. Omitted limits use the provider configuration. Within one API instance, the facade keeps one current accessibility snapshot per application handle across app and window objects, including repeated selections; each new read invalidates the previous snapshot. Element operations use the latest snapshot ID, so callers use IDs from the latest tree and do not assume an older ID still identifies the same control. Element IDs are opaque strings. +Use `cua.getApp(selector)` to select an application; it obtains consent and optionally launches a stopped application in the background, without reading its accessibility tree. On macOS, `cua.listApps()` and `cua.getState().apps` report each running process with its numeric `pid`. The application ID is its bundle ID or, when absent, its PID string. Pass `String(row.pid)` to `cua.getApp()` to distinguish processes with the same name or bundle ID. Running `cua.findApps(query)` matches include their PID and keep their installation ID and path. Windows returns provider-issued application IDs without a PID. `app.activate()`, `app.getWindows()`, and `app.getWindow(windowId)` operate on the selected application; `getWindow` returns the object without a native request; window operations reject closed or foreign windows. Select an application and one of its windows before any capture or pointer input. Read `app.getAccessibilityTree()` or `window.getAccessibilityTree()` explicitly before element operations. Screenshots remain available when AX reading fails. App and window reads accept `maxElements` and `maxDepth` independently. Omitted limits use the provider configuration. Within one API instance, the facade keeps one current accessibility snapshot per application handle across app and window objects, including repeated selections; each new read invalidates the previous snapshot. Element operations use the latest snapshot ID, so callers use IDs from the latest tree and do not assume an older ID still identifies the same control. Element IDs are opaque strings. The shared raw `getState` result sets `hasUnreadableElements: true` when the returned tree contains elements the provider could not read. Providers may omit the field otherwise. `truncated` reports a node or depth limit independently. Keyboard methods are available in the scopes a provider declares; the provider owns how input is delivered within each scope. A lost connection invalidates its handles and coordinates. Cleanup failures are reported and the connection is not reused; select the application again and inspect fresh state, because earlier input may have partially executed. Screenshot image errors retain the failing stage and attachment error code. Invalid request arguments reject before dispatch with a readable method, parameter and requirement. diff --git a/packages/experimental/cua/README.zh.md b/packages/experimental/cua/README.zh.md index c8afb9db62..7581320113 100644 --- a/packages/experimental/cua/README.zh.md +++ b/packages/experimental/cua/README.zh.md @@ -39,7 +39,7 @@ kind: "package-reference" `cua` 在创建环境时安装一次。不要覆盖这个全局对象。需要重建损坏的环境时,在 `cua_run_code` 中执行 `process.exit(0)`;该次工具调用会因进程退出而返回失败。下一次调用启动新环境并恢复 `cua`。请重新创建其他变量,并重新选择应用和窗口。 -使用 `cua.getApp(selector)` 选择应用;它会获取授权、按需在后台启动已停止的应用,不读取辅助功能树。在 macOS 上,`cua.listApps()` 和 `cua.getState().apps` 返回每个运行进程的数字 `pid`。应用 ID 优先使用 bundle ID,没有 bundle ID 时使用 PID 字符串。遇到同名或相同 bundle ID 的多个进程,把 `String(row.pid)` 传给 `cua.getApp()` 即可选中对应进程。`cua.findApps(query)` 的运行中匹配项带有 PID,并保留安装应用的 ID 和路径。Windows 返回提供方给出的应用 ID,不提供 PID。`app.activate()`、`app.getWindows()` 和 `app.getWindow(windowId)` 操作选定的应用;`getWindow` 返回对象时不发送原生请求;窗口操作会拒绝已关闭或属于其他应用的窗口。进行任何截图或指针输入前,必须选择应用及其一个窗口。元素操作前须显式读取 `app.getAccessibilityTree()` 或 `window.getAccessibilityTree()`。AX 读取失败时仍可截图。读取应用或窗口时,可以单独传入 `maxElements` 或 `maxDepth`。省略的参数使用当前平台配置。在单个 API 实例内,门面按应用句柄保存一份当前辅助功能快照,该句柄的所有应用对象和窗口对象共享它,包括重复选择;每次新读取都会使上一份快照失效。元素操作使用最新快照 ID,因此调用方应使用最新树中的元素 ID,不应假定旧 ID 仍指向同一控件。元素 ID 是不透明字符串。 +使用 `cua.getApp(selector)` 选择应用;它会获取授权、按需在后台启动已停止的应用,不读取辅助功能树。在 macOS 上,`cua.listApps()` 和 `cua.getState().apps` 返回每个运行进程的数字 `pid`。应用 ID 优先使用 bundle ID,没有 bundle ID 时使用 PID 字符串。遇到同名或相同 bundle ID 的多个进程,把 `String(row.pid)` 传给 `cua.getApp()` 即可选中对应进程。`cua.findApps(query)` 的运行中匹配项带有 PID,并保留安装应用的 ID 和路径。Windows 返回提供方给出的应用 ID,不提供 PID。`app.activate()`、`app.getWindows()` 和 `app.getWindow(windowId)` 操作选定的应用;`getWindow` 返回对象时不发送原生请求;窗口操作会拒绝已关闭或属于其他应用的窗口。进行任何截图或指针输入前,必须选择应用及其一个窗口。元素操作前须显式读取 `app.getAccessibilityTree()` 或 `window.getAccessibilityTree()`。AX 读取失败时仍可截图。读取应用或窗口时,可以单独传入 `maxElements` 或 `maxDepth`。省略的参数使用当前平台配置。在单个 API 实例内,门面按应用句柄保存一份当前辅助功能快照,该句柄的所有应用对象和窗口对象共享它,包括重复选择;每次新读取都会使上一份快照失效。元素操作使用最新快照 ID,因此调用方应使用最新树中的元素 ID,不应假定旧 ID 仍指向同一控件。元素 ID 是不透明字符串。macOS 和 Windows 共用的原始 `getState` 结果可返回 `hasUnreadableElements: true`,表示本次树中有未能读到的元素。其他情况下可省略该字段。节点数或深度达到上限时,由 `truncated` 单独标记。 键盘方法可在 provider 声明的作用域中使用;每个作用域内的输入投递由 provider 负责。连接丢失会使其句柄和坐标失效。清理失败会被报告,该连接不再复用;应重新选择应用并读取新状态,因为先前的输入可能已部分执行。截图图像错误会保留失败阶段和附件错误码。请求参数校验失败时,在分派前返回包含方法、参数和要求的可读消息。 diff --git a/packages/experimental/cua/src/protocol.ts b/packages/experimental/cua/src/protocol.ts index f271bb3635..f4b8080384 100644 --- a/packages/experimental/cua/src/protocol.ts +++ b/packages/experimental/cua/src/protocol.ts @@ -147,7 +147,7 @@ export const StateResult = z.object({ windowId: windowId.nullable(), focusedWindowId: windowId.nullable().optional(), snapshotId: z.string().min(1).transform(value => value as CuaSnapshotId), - tree: z.string(), windows: WindowsResult, truncated: z.boolean(), incomplete: z.boolean().optional(), + tree: z.string(), windows: WindowsResult, truncated: z.boolean(), hasUnreadableElements: z.boolean().optional(), }) /** Provider-defined action names for one element, including attribute-setting operations; an element may advertise none. */ export const ActionNamesResult = z.array(z.string()) diff --git a/packages/experimental/cua/tests/protocol.spec.ts b/packages/experimental/cua/tests/protocol.spec.ts index 59ded72451..d3c5fc53a7 100644 --- a/packages/experimental/cua/tests/protocol.spec.ts +++ b/packages/experimental/cua/tests/protocol.spec.ts @@ -13,7 +13,7 @@ it('preserves opaque window IDs in requests and results', () => { const state = { appHandle: 'app', windowId, focusedWindowId: windowId, snapshotId: 'snapshot', tree: '', windows, truncated: false } expect(StateResult.parse(state)).toEqual(state) for (const truncated of [false, true]) { - const partial = { ...state, truncated, incomplete: true } + const partial = { ...state, truncated, hasUnreadableElements: true } expect(StateResult.parse(partial)).toEqual(partial) } expect(ShowResult.parse({ dispatched: true, foregroundChanged: false, windowId }).windowId).toBe(windowId) diff --git a/snapshots/session/cua-native/session.v4.jsonl b/snapshots/session/cua-native/session.v4.jsonl index 3f0c79295e..9ad6fc301b 100644 --- a/snapshots/session/cua-native/session.v4.jsonl +++ b/snapshots/session/cua-native/session.v4.jsonl @@ -289,7 +289,7 @@ {"type":"step/start","data":{"turn":1,"step":56}} {"type":"assistant/message","data":{"turn":1,"step":56,"message":{"role":"assistant","content":[{"type":"tool-call","id":"cua-floating-observe","name":"cua","arguments":"{\"method\":\"getState\",\"params\":{\"appHandle\":\"fixture-app\",\"windowId\":\"10\"}}"}],"source":{"kind":"model","provider":"deepseek-official","model":"deepseek-v4-flash-vision-exp"},"id":"{{message:114}}"},"usage":{"inputTokens":3,"outputTokens":3},"stream":[{"type":"chunk","time":1794214351739,"chunk":{"type":"block-start","index":0,"blockType":"tool-call"}},{"type":"chunk","time":1794214351739,"chunk":{"type":"block-end","index":0,"block":{"type":"tool-call","id":"cua-floating-observe","name":"cua","arguments":"{\"method\":\"getState\",\"params\":{\"appHandle\":\"fixture-app\",\"windowId\":\"10\"}}"}}},{"type":"chunk","time":1794214351739,"chunk":{"type":"usage","usage":{"inputTokens":3,"outputTokens":3}}},{"type":"chunk","time":1794214351739,"chunk":{"type":"finish","reason":{"kind":"tool-calls"}}}]},"surfaceOp":"append"} {"type":"tool/call","data":{"turn":1,"step":56,"callId":"cua-floating-observe","name":"cua","arguments":"{\"method\":\"getState\",\"params\":{\"appHandle\":\"fixture-app\",\"windowId\":\"10\"}}"}} -{"type":"tool/result","data":{"turn":1,"step":56,"message":{"role":"tool","source":{"kind":"tool","callId":"cua-floating-observe"},"toolCallId":"cua-floating-observe","content":[{"type":"text","text":"{\"appHandle\":\"fixture-app\",\"windowId\":\"10\",\"focusedWindowId\":\"7\",\"snapshotId\":\"fixture-snapshot-15\",\"tree\":\"AX scope=window offsets=UTF-16\\n- AXWindow \\\"Floating panel\\\"\\n [One child could not be read.]\\n - AXStaticText \\\"Floating count: 0\\\"\",\"windows\":[{\"windowId\":\"7\",\"appName\":\"Fixture\",\"title\":\"CUA fixture\",\"bounds\":{\"x\":40,\"y\":60,\"width\":320,\"height\":200},\"isOnScreen\":true,\"onCurrentSpace\":true},{\"windowId\":\"8\",\"appName\":\"Fixture\",\"title\":\"AXless canvas\",\"bounds\":{\"x\":40,\"y\":60,\"width\":320,\"height\":200},\"isOnScreen\":true,\"onCurrentSpace\":true},{\"windowId\":\"9\",\"appName\":\"Fixture\",\"title\":\"Transformed window\",\"bounds\":{\"x\":16,\"y\":512,\"width\":131,\"height\":145},\"isOnScreen\":true,\"onCurrentSpace\":true},{\"windowId\":\"10\",\"appName\":\"Fixture\",\"title\":\"Floating panel\",\"bounds\":{\"x\":100,\"y\":120,\"width\":240,\"height\":140},\"isOnScreen\":true,\"onCurrentSpace\":true}],\"truncated\":false,\"incomplete\":true}"}],"isError":false,"id":"{{message:115}}"}},"sourceEventSeqs":[289],"surfaceOp":"append"} +{"type":"tool/result","data":{"turn":1,"step":56,"message":{"role":"tool","source":{"kind":"tool","callId":"cua-floating-observe"},"toolCallId":"cua-floating-observe","content":[{"type":"text","text":"{\"appHandle\":\"fixture-app\",\"windowId\":\"10\",\"focusedWindowId\":\"7\",\"snapshotId\":\"fixture-snapshot-15\",\"tree\":\"AX scope=window offsets=UTF-16\\n- AXWindow \\\"Floating panel\\\"\\n [One child could not be read.]\\n - AXStaticText \\\"Floating count: 0\\\"\",\"windows\":[{\"windowId\":\"7\",\"appName\":\"Fixture\",\"title\":\"CUA fixture\",\"bounds\":{\"x\":40,\"y\":60,\"width\":320,\"height\":200},\"isOnScreen\":true,\"onCurrentSpace\":true},{\"windowId\":\"8\",\"appName\":\"Fixture\",\"title\":\"AXless canvas\",\"bounds\":{\"x\":40,\"y\":60,\"width\":320,\"height\":200},\"isOnScreen\":true,\"onCurrentSpace\":true},{\"windowId\":\"9\",\"appName\":\"Fixture\",\"title\":\"Transformed window\",\"bounds\":{\"x\":16,\"y\":512,\"width\":131,\"height\":145},\"isOnScreen\":true,\"onCurrentSpace\":true},{\"windowId\":\"10\",\"appName\":\"Fixture\",\"title\":\"Floating panel\",\"bounds\":{\"x\":100,\"y\":120,\"width\":240,\"height\":140},\"isOnScreen\":true,\"onCurrentSpace\":true}],\"truncated\":false,\"hasUnreadableElements\":true}"}],"isError":false,"id":"{{message:115}}"}},"sourceEventSeqs":[289],"surfaceOp":"append"} {"type":"step/end","data":{"turn":1,"step":56}} {"type":"step/start","data":{"turn":1,"step":57}} {"type":"assistant/message","data":{"turn":1,"step":57,"message":{"role":"assistant","content":[{"type":"tool-call","id":"cua-floating-screenshot","name":"cua","arguments":"{\"method\":\"screenshot\",\"params\":{\"appHandle\":\"fixture-app\",\"windowId\":\"10\"}}"}],"source":{"kind":"model","provider":"deepseek-official","model":"deepseek-v4-flash-vision-exp"},"id":"{{message:116}}"},"usage":{"inputTokens":3,"outputTokens":3},"stream":[{"type":"chunk","time":1794214351762,"chunk":{"type":"block-start","index":0,"blockType":"tool-call"}},{"type":"chunk","time":1794214351762,"chunk":{"type":"block-end","index":0,"block":{"type":"tool-call","id":"cua-floating-screenshot","name":"cua","arguments":"{\"method\":\"screenshot\",\"params\":{\"appHandle\":\"fixture-app\",\"windowId\":\"10\"}}"}}},{"type":"chunk","time":1794214351762,"chunk":{"type":"usage","usage":{"inputTokens":3,"outputTokens":3}}},{"type":"chunk","time":1794214351762,"chunk":{"type":"finish","reason":{"kind":"tool-calls"}}}]},"surfaceOp":"append"} @@ -329,7 +329,7 @@ {"type":"step/start","data":{"turn":1,"step":64}} {"type":"assistant/message","data":{"turn":1,"step":64,"message":{"role":"assistant","content":[{"type":"tool-call","id":"cua-floating-verify","name":"cua","arguments":"{\"method\":\"getState\",\"params\":{\"appHandle\":\"fixture-app\",\"windowId\":\"10\"}}"}],"source":{"kind":"model","provider":"deepseek-official","model":"deepseek-v4-flash-vision-exp"},"id":"{{message:130}}"},"usage":{"inputTokens":3,"outputTokens":3},"stream":[{"type":"chunk","time":1794214351943,"chunk":{"type":"block-start","index":0,"blockType":"tool-call"}},{"type":"chunk","time":1794214351943,"chunk":{"type":"block-end","index":0,"block":{"type":"tool-call","id":"cua-floating-verify","name":"cua","arguments":"{\"method\":\"getState\",\"params\":{\"appHandle\":\"fixture-app\",\"windowId\":\"10\"}}"}}},{"type":"chunk","time":1794214351943,"chunk":{"type":"usage","usage":{"inputTokens":3,"outputTokens":3}}},{"type":"chunk","time":1794214351943,"chunk":{"type":"finish","reason":{"kind":"tool-calls"}}}]},"surfaceOp":"append"} {"type":"tool/call","data":{"turn":1,"step":64,"callId":"cua-floating-verify","name":"cua","arguments":"{\"method\":\"getState\",\"params\":{\"appHandle\":\"fixture-app\",\"windowId\":\"10\"}}"}} -{"type":"tool/result","data":{"turn":1,"step":64,"message":{"role":"tool","source":{"kind":"tool","callId":"cua-floating-verify"},"toolCallId":"cua-floating-verify","content":[{"type":"text","text":"{\"appHandle\":\"fixture-app\",\"windowId\":\"10\",\"focusedWindowId\":\"7\",\"snapshotId\":\"fixture-snapshot-17\",\"tree\":\"AX scope=window offsets=UTF-16\\n- AXWindow \\\"Floating panel\\\"\\n [One child could not be read.]\\n - AXStaticText \\\"Floating count: 1\\\"\",\"windows\":[{\"windowId\":\"7\",\"appName\":\"Fixture\",\"title\":\"CUA fixture\",\"bounds\":{\"x\":40,\"y\":60,\"width\":320,\"height\":200},\"isOnScreen\":true,\"onCurrentSpace\":true},{\"windowId\":\"8\",\"appName\":\"Fixture\",\"title\":\"AXless canvas\",\"bounds\":{\"x\":40,\"y\":60,\"width\":320,\"height\":200},\"isOnScreen\":true,\"onCurrentSpace\":true},{\"windowId\":\"9\",\"appName\":\"Fixture\",\"title\":\"Transformed window\",\"bounds\":{\"x\":16,\"y\":512,\"width\":131,\"height\":145},\"isOnScreen\":true,\"onCurrentSpace\":true},{\"windowId\":\"10\",\"appName\":\"Fixture\",\"title\":\"Floating panel\",\"bounds\":{\"x\":100,\"y\":120,\"width\":240,\"height\":140},\"isOnScreen\":true,\"onCurrentSpace\":true}],\"truncated\":false,\"incomplete\":true}"}],"isError":false,"id":"{{message:131}}"}},"sourceEventSeqs":[329],"surfaceOp":"append"} +{"type":"tool/result","data":{"turn":1,"step":64,"message":{"role":"tool","source":{"kind":"tool","callId":"cua-floating-verify"},"toolCallId":"cua-floating-verify","content":[{"type":"text","text":"{\"appHandle\":\"fixture-app\",\"windowId\":\"10\",\"focusedWindowId\":\"7\",\"snapshotId\":\"fixture-snapshot-17\",\"tree\":\"AX scope=window offsets=UTF-16\\n- AXWindow \\\"Floating panel\\\"\\n [One child could not be read.]\\n - AXStaticText \\\"Floating count: 1\\\"\",\"windows\":[{\"windowId\":\"7\",\"appName\":\"Fixture\",\"title\":\"CUA fixture\",\"bounds\":{\"x\":40,\"y\":60,\"width\":320,\"height\":200},\"isOnScreen\":true,\"onCurrentSpace\":true},{\"windowId\":\"8\",\"appName\":\"Fixture\",\"title\":\"AXless canvas\",\"bounds\":{\"x\":40,\"y\":60,\"width\":320,\"height\":200},\"isOnScreen\":true,\"onCurrentSpace\":true},{\"windowId\":\"9\",\"appName\":\"Fixture\",\"title\":\"Transformed window\",\"bounds\":{\"x\":16,\"y\":512,\"width\":131,\"height\":145},\"isOnScreen\":true,\"onCurrentSpace\":true},{\"windowId\":\"10\",\"appName\":\"Fixture\",\"title\":\"Floating panel\",\"bounds\":{\"x\":100,\"y\":120,\"width\":240,\"height\":140},\"isOnScreen\":true,\"onCurrentSpace\":true}],\"truncated\":false,\"hasUnreadableElements\":true}"}],"isError":false,"id":"{{message:131}}"}},"sourceEventSeqs":[329],"surfaceOp":"append"} {"type":"step/end","data":{"turn":1,"step":64}} {"type":"step/start","data":{"turn":1,"step":65}} {"type":"assistant/message","data":{"turn":1,"step":65,"message":{"role":"assistant","content":[{"type":"tool-call","id":"cua-debug-arm","name":"cua","arguments":"{\"method\":\"pressKey\",\"params\":{\"appHandle\":\"fixture-app\",\"key\":\"F12\"}}"}],"source":{"kind":"model","provider":"deepseek-official","model":"deepseek-v4-flash-vision-exp"},"id":"{{message:132}}"},"usage":{"inputTokens":3,"outputTokens":3},"stream":[{"type":"chunk","time":1794214351968,"chunk":{"type":"block-start","index":0,"blockType":"tool-call"}},{"type":"chunk","time":1794214351968,"chunk":{"type":"block-end","index":0,"block":{"type":"tool-call","id":"cua-debug-arm","name":"cua","arguments":"{\"method\":\"pressKey\",\"params\":{\"appHandle\":\"fixture-app\",\"key\":\"F12\"}}"}}},{"type":"chunk","time":1794214351968,"chunk":{"type":"usage","usage":{"inputTokens":3,"outputTokens":3}}},{"type":"chunk","time":1794214351968,"chunk":{"type":"finish","reason":{"kind":"tool-calls"}}}]},"surfaceOp":"append"} diff --git a/snapshots/session/cua-native/workspace/native-helper.mjs b/snapshots/session/cua-native/workspace/native-helper.mjs index e2b0da03cd..1eb7595127 100755 --- a/snapshots/session/cua-native/workspace/native-helper.mjs +++ b/snapshots/session/cua-native/workspace/native-helper.mjs @@ -182,7 +182,7 @@ function createApplicationState(socket, record, application, captureBroker, conn if (params.windowId === panel.windowId && application.panelVisibility !== 'closed') return { appHandle: app.appHandle, windowId: panel.windowId, snapshotId, focusedWindowId: window.windowId, tree: `AX scope=window offsets=UTF-16\n- AXWindow "Floating panel"\n [One child could not be read.]\n - AXStaticText "Floating count: ${application.panelCount}"`, - elements: [], windows: windows(), truncated: false, incomplete: true, + elements: [], windows: windows(), truncated: false, hasUnreadableElements: true, } if (axless) return { appHandle: app.appHandle, windowId: '8', snapshotId, tree: '', elements: [], windows: windows(), truncated: false }