@deepseek-ai/dsh-experimental-cua-macos 0.2.2-alpha.2 → 0.2.2-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.i18n.yaml +6 -6
- package/README.md +14 -9
- package/README.zh.md +14 -9
- package/cua-helper.json +16 -0
- package/lib/index.js +190 -98
- package/lib/types/index.d.ts +61 -3
- package/lib/types/native-build.d.ts +12 -12
- package/lib/types/permission-guide.d.ts +23 -0
- package/native/DSHComputerUse.icns +0 -0
- package/native/Info.plist +24 -0
- package/native/LICENSE.computer-use-icon +18 -0
- package/native/README.md +24 -6
- package/native/README.zh.md +24 -6
- package/native/Sources/CuaNative/Main.swift +40 -27
- package/native/Sources/CuaNative/NativeProtocol.generated.swift +2 -2
- package/native/Sources/CuaNative/PermissionGuide.swift +404 -0
- package/native/Sources/CuaNative/Permissions.swift +79 -19
- package/native/Sources/CuaNative/RequestCoordinator.swift +10 -3
- package/native/Sources/CuaNative/SharedHelperProxy.swift +7 -7
- package/native/Sources/CuaNative/SharedHelperRuntime.swift +106 -51
- package/native/Sources/CuaNative/SharedHelperServer.swift +2 -2
- package/native/bin/darwin-arm64/007deaf0f4b6b473af03a201a5042208f8249172c41c27894bc09241e5e3f19b/DSH Computer Use.app/Contents/CodeResources +0 -0
- package/native/bin/darwin-arm64/007deaf0f4b6b473af03a201a5042208f8249172c41c27894bc09241e5e3f19b/DSH Computer Use.app/Contents/Info.plist +24 -0
- package/native/bin/darwin-arm64/007deaf0f4b6b473af03a201a5042208f8249172c41c27894bc09241e5e3f19b/DSH Computer Use.app/Contents/MacOS/dsh-cua-native +0 -0
- package/native/bin/darwin-arm64/007deaf0f4b6b473af03a201a5042208f8249172c41c27894bc09241e5e3f19b/DSH Computer Use.app/Contents/Resources/DSHComputerUse.icns +0 -0
- package/native/bin/darwin-arm64/007deaf0f4b6b473af03a201a5042208f8249172c41c27894bc09241e5e3f19b/DSH Computer Use.app/Contents/Resources/LICENSE.computer-use-icon +18 -0
- package/native/bin/darwin-arm64/007deaf0f4b6b473af03a201a5042208f8249172c41c27894bc09241e5e3f19b/DSH Computer Use.app/Contents/Resources/LICENSE.cua-driver +21 -0
- package/native/bin/darwin-arm64/007deaf0f4b6b473af03a201a5042208f8249172c41c27894bc09241e5e3f19b/DSH Computer Use.app/Contents/_CodeSignature/CodeResources +150 -0
- package/native/bin/darwin-arm64/current.json +1 -0
- package/native/bin/darwin-x64/9f6e6dedbc05279505e36b140ddd74a7d143b31838e17ba22ad3115fc14c55b2/DSH Computer Use.app/Contents/CodeResources +0 -0
- package/native/bin/darwin-x64/9f6e6dedbc05279505e36b140ddd74a7d143b31838e17ba22ad3115fc14c55b2/DSH Computer Use.app/Contents/Info.plist +24 -0
- package/native/bin/darwin-x64/9f6e6dedbc05279505e36b140ddd74a7d143b31838e17ba22ad3115fc14c55b2/DSH Computer Use.app/Contents/MacOS/dsh-cua-native +0 -0
- package/native/bin/darwin-x64/9f6e6dedbc05279505e36b140ddd74a7d143b31838e17ba22ad3115fc14c55b2/DSH Computer Use.app/Contents/Resources/DSHComputerUse.icns +0 -0
- package/native/bin/darwin-x64/9f6e6dedbc05279505e36b140ddd74a7d143b31838e17ba22ad3115fc14c55b2/DSH Computer Use.app/Contents/Resources/LICENSE.computer-use-icon +18 -0
- package/native/bin/darwin-x64/9f6e6dedbc05279505e36b140ddd74a7d143b31838e17ba22ad3115fc14c55b2/DSH Computer Use.app/Contents/Resources/LICENSE.cua-driver +21 -0
- package/native/bin/darwin-x64/9f6e6dedbc05279505e36b140ddd74a7d143b31838e17ba22ad3115fc14c55b2/DSH Computer Use.app/Contents/_CodeSignature/CodeResources +150 -0
- package/native/bin/darwin-x64/current.json +1 -0
- package/native/build_app.py +85 -0
- package/native/protocol.schema.json +38 -2
- package/native/tests/swift/SharedHelperTests.swift +52 -0
- package/native/tests/swift/SystemPermissionsTests.swift +245 -0
- package/native/upstream.json +1 -0
- package/package.json +53 -46
package/README.i18n.yaml
CHANGED
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
en: 4549f02fc53854a5
|
|
13
13
|
zh: 6f74f1130b6623a8
|
|
14
14
|
/deepseek-ai-dsh-experimental-cua-macos/table-of-contents:
|
|
15
|
-
en:
|
|
16
|
-
zh:
|
|
15
|
+
en: 1c91307fdaebba7a
|
|
16
|
+
zh: 910fba0aa793f47f
|
|
17
17
|
/deepseek-ai-dsh-experimental-cua-macos/use-this-package:
|
|
18
|
-
en:
|
|
19
|
-
zh:
|
|
18
|
+
en: ead96859cdf97de5
|
|
19
|
+
zh: acaf62c479d5d6e8
|
|
20
20
|
/deepseek-ai-dsh-experimental-cua-macos/use-this-package/connect-an-external-execution-environment:
|
|
21
21
|
en: 786b8fd630b11e5f
|
|
22
22
|
zh: 55143f15486afce8
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
en: a2c9acb5a4320dda
|
|
46
46
|
zh: e8d1586af60215c4
|
|
47
47
|
/deepseek-ai-dsh-experimental-cua-macos/known-limitations-and-deferred-work:
|
|
48
|
-
en:
|
|
49
|
-
zh:
|
|
48
|
+
en: 791c1ec9ff4b2978
|
|
49
|
+
zh: a32d35de026f3285
|
|
50
50
|
/deepseek-ai-dsh-experimental-cua-macos/known-limitations-and-deferred-work/dev-note:
|
|
51
51
|
en: b836f01bd0bceb4a
|
|
52
52
|
zh: 8122fa08b2aa95fa
|
package/README.md
CHANGED
|
@@ -22,34 +22,36 @@ Inspect macOS permissions, select running applications and windows, read accessi
|
|
|
22
22
|
|
|
23
23
|
The helper supplies bounded 64-pixel PNG application icons for permission prompts and saved-application lists. Icon reads do not launch an application or inspect its windows; icons do not determine reusable consent.
|
|
24
24
|
|
|
25
|
-
The
|
|
25
|
+
The helper runs through LaunchServices as the independent application `DSH Computer Use.app`. Accessibility and Screen Recording permissions belong to this application. Permission guidance uses the responsible application’s bundle URL, identifier, filename, and system icon captured at startup; unavailable system attribution falls back to the independent helper’s own bundle. Dragging and Finder selection read the current on-disk bundle identifier and executable through the application-discovery reader. The page and guide both display the application’s `.app` filename. Existing connections retain their running application generation when another build updates `current.json`.
|
|
26
|
+
|
|
27
|
+
Permission requests open the selected privacy pane and a native floating guide. The guide selects the largest settings window once and follows that window by ID. It uses the normal window level, ordered immediately above the selected window so authentication dialogs remain above it. Placement reads window bounds without requesting Accessibility access. The guide stays hidden until the settings window is identified; a failed settings-open request displays manual navigation instructions independently. A material alpha mask gives the panel and its shadow rounded corners. The latest request replaces the shared guide, and only its owning connection can close it during cleanup. Navigation is attempted even when the application is unavailable, and the page reports that failure. Already-granted permissions open settings without a guide; explicit settings navigation dismisses previous guidance. A rejected settings-open request reports `SETTINGS_UNAVAILABLE`; missing or replaced application targets report `APPLICATION_UNAVAILABLE`. System Settings owns drag acceptance and any relaunch requirement.
|
|
28
|
+
|
|
29
|
+
The provider resolves guide and recovery copy from the current Client language, with English for unsupported languages. Drag the guide’s application row into the permission list and enable its switch; enable the existing entry when already listed. The guide hides during dragging, closes when a drop is accepted, and returns after a canceled or rejected drag. The back button closes it and returns to the previous application. Right-click the row, or click it for keyboard focus and press Return or Space, to reveal the bundle in Finder. While open, the guide checks permission and window position every `permissionPollIntervalMs` (default 1000 ms), and closes after a confirmed grant, dismissal, disappearance of the settings window, or its owning connection’s cleanup. Dragging does not establish consent. Follow any macOS quit-and-reopen prompt; the shared helper is not automatically terminated.
|
|
26
30
|
|
|
27
31
|
-----
|
|
28
32
|
|
|
29
33
|
<a id="use-this-package"></a>
|
|
30
34
|
## Use this package
|
|
31
35
|
|
|
32
|
-
This package is an optional dependency
|
|
36
|
+
This package is an optional macOS dependency. For local development, run `pnpm --dir packages/experimental/cua-macos run build:native` to generate an ad-hoc-signed application and `current.json` under `native/bin`. Release packaging requires `--identity "Developer ID Application: <name> (<team>)"` and notarization; see [native build and service](native/README.md#build-and-service). Installed packages preserve the distributed signature. Source preparation requires Swift and Python 3 from Apple Command Line Tools.
|
|
33
37
|
|
|
34
38
|
For repository Web use, enable [Computer Use](../cua-bundle/README.md) in Plugins. This prepares the local executable on macOS 14 or later; Windows support is in development. Subsequent builds check it while the existing Web profile keeps the bundle selected. Disabled profiles do not prepare native components. Explicit source composition is also available:
|
|
35
39
|
|
|
36
40
|
```sh
|
|
37
|
-
swift build --package-path packages/experimental/cua-macos/native --configuration release
|
|
38
|
-
cua_native_root="$PWD/packages/experimental/cua-macos/native"
|
|
39
|
-
export DSH_CUA_HELPER="$cua_native_root/.build/release/dsh-cua-native"
|
|
40
41
|
pnpm dsh headless --patch packages/experimental/cua-macos/examples/macos.cordis.yml --dump-config
|
|
41
42
|
```
|
|
42
43
|
|
|
43
|
-
The dump command checks profile composition without a model request. For a real task, replace `--dump-config` with a prompt and configure the profile’s model credentials. The overlay mounts the computer-use registry and this provider; remove an existing competing provider before using it.
|
|
44
|
+
The dump command checks profile composition without a model request. For a real task, replace `--dump-config` with a prompt and configure the profile’s model credentials. The overlay mounts the computer-use registry and this provider; remove an existing competing provider before using it. `DSH Computer Use.app` needs Accessibility permission for AX/input and Screen Recording permission for capture; use the Computer Use permission page to open System Settings and add the helper. `getCapabilities` reports permissions and session lock state without opening a system dialog. Locked or unavailable desktop sessions reject UI observations and input before dispatch; the user must unlock macOS before resuming. `listApps` and `cua.getState` list running applications. `findApps(query)` searches standard macOS application directories by name, bundle ID or absolute path. `getApp` selects a unique name, bundle ID, path or running PID, obtains application consent, and launches a stopped app in the background when needed. A stopped application’s bundle identifier and executable path are read from disk before approval and rechecked before and after launch; applications without a bundle identifier use their canonical executable path for reusable consent. Selecting a stopped installation requests a new instance of that copy. The helper waits for the launched application to finish launching before returning its PID. A post-launch verification failure expires the pending handle but can leave the process running; inspect running applications before selecting a fresh handle. The returned object reads initial AX without activating the app. Launch cancellation may leave the application running. Model guidance starts with background observation and input, without activation during initialization or before each action. For hidden or minimized windows, try `app.show()` or `window.show()` and read fresh state. This requests unhide and unminimize without activation, raising or switching Spaces; app-level restoration selects the focused, main or sole AX window. The result names the selected `windowId`, or null when no window was selected, and reports `foregroundChanged` by comparing the front app and top window before and after the request. Null means foreground evidence was unavailable; later focus changes remain possible. If restoration fails or the window remains unusable, explain the needed foreground step, call `app.activate()` or an observed window’s `raise` action, then observe again. Necessary foreground access takes priority over preserving focus. Applications may change focus after input; background delivery does not guarantee an undisturbed user session.
|
|
44
45
|
|
|
45
46
|
| Field | Default | Meaning |
|
|
46
47
|
| --- | --- | --- |
|
|
47
48
|
| `agentPreset` | `ptc` | Register tools and guidance only for Agents bound to this preset; `false` registers globally. |
|
|
48
49
|
| `allowedApps` | `[]` | Legacy path/signature grants, imported once for removal; they do not authorize new bundle-ID identities. |
|
|
49
|
-
| `helperPath` | package-owned executable |
|
|
50
|
+
| `helperPath` | package-owned executable | Absolute executable inside the signed helper `.app`; a bare binary fails with `NATIVE_APPLICATION_REQUIRED`. |
|
|
50
51
|
| `buildTimeoutMs` | `300000` | Maximum native preparation time. |
|
|
51
52
|
| `timeoutMs` | `30000` | Per-operation deadline; cancellation can leave partial input. |
|
|
52
53
|
| `connectTimeoutMs` | `5000` | Deadline for connecting to or starting the shared helper. |
|
|
54
|
+
| `permissionPollIntervalMs` | `1000` | Interval in milliseconds between permission and position checks while the native guide is open. |
|
|
53
55
|
| `screenshotTimeoutMs` | `5000` | Screenshot deadline including queue time, capped by `timeoutMs`. |
|
|
54
56
|
| `axTimeoutMs` | `3000` | Deadline per Accessibility system call, configured independently of the complete operation. |
|
|
55
57
|
| `maxRequestBytes` / `maxResponseBytes` | `1048576` / `33554432` | UTF-8 request and response limits. |
|
|
@@ -79,7 +81,7 @@ Observations emit by default and also return their value. In persistent PTC, use
|
|
|
79
81
|
|
|
80
82
|
Screenshot diagnostics use `[cua-screenshot]` records keyed by the tool request ID. Native phase records return over the originating Agent connection and cover window/AX geometry checks, system capture, PNG/Base64 encoding and response writing. Host debug logs add dispatch, reply and cleanup timings. Each request retains at most 8192 bytes of complete diagnostic records, with explicit truncation; screenshot failures append these records to the error for Session export. Records contain stages, timings and error codes, not window titles, AX text or image bytes.
|
|
81
83
|
|
|
82
|
-
Native preparation serializes
|
|
84
|
+
Native preparation serializes building and signing with a file lock. It retains complete applications under content-addressed `native/.build/prepared` directories and atomically selects a generation through `current.json`. Existing connections retain their application; identical builds reuse its files, and corrupted copies are rejected. Cancellation and failure finish managed process cleanup before releasing the lock.
|
|
83
85
|
|
|
84
86
|
### Connect an external execution environment
|
|
85
87
|
|
|
@@ -213,12 +215,15 @@ The queue orders individual native requests. Holding an app object does not rese
|
|
|
213
215
|
|
|
214
216
|
<a id="known-limitations-and-deferred-work"></a>
|
|
215
217
|
|
|
218
|
+
- macOS 14 is the minimum supported version; settings navigation, drag acceptance, and permission refresh require qualification on each supported release. If macOS requires quitting and reopening the helper after a Screen Recording change, its preflight check can remain denied until that restart. The guide can be dismissed without terminating other connections.
|
|
219
|
+
- The guide closes when its selected settings window leaves the visible-window list, including when a Space switch or minimization removes it. Request permission again after returning to reopen the guide.
|
|
216
220
|
- Only the macOS native implementation is provided. Windows support is in development; this package remains in `experimental` until that support is complete, then moves to the `computer-use` group. Browser tabs, AX diffs, unassociated system panels and accessory-only apps are unsupported.
|
|
217
221
|
- Coordinates use the returned screenshot pixels, including the title bar; `relative: true` selects integers from 0 to 999. Native point conversion is Host-owned. Window movement, application changes and other desktop users can race observations and input.
|
|
218
222
|
- macOS Stage Manager can reduce background window bounds and screenshots to thumbnails. Full-window observation and coordinate input in this state are not guaranteed; model guidance requires explaining foreground needs and avoiding repeated focus reclamation.
|
|
219
223
|
- Background input depends on private SkyLight symbols; macOS updates can make them unavailable. Validate each target OS version.
|
|
220
224
|
- Observed failures include dispatched Unicode text not appearing in Blender and background Command+A not selecting all text in AppKit. Inspect application state after input; a successful tool result confirms dispatch only.
|
|
221
|
-
-
|
|
225
|
+
- Source builds use ad-hoc signatures and may require authorization again after source changes. Release distribution needs a stable Developer ID signature and notarization; the build command accepts `--identity`, and installed packages preserve the distributed signature. The [permission page](../cua/README.md) offers helper authorization and target-application revocation.
|
|
226
|
+
- Release packaging does not automatically verify GUI startup, helper identity or exit cleanup. Release maintainers can run the [distribution smoke](native/README.md#build-and-service) on a logged-in Mac before publication; a successful package build does not establish those runtime results.
|
|
222
227
|
- Saved permission rows show the name, path and icon of one approved copy, not an inventory of every installation sharing its identity. Removing that copy can leave its icon unavailable. Revocation still applies to every copy with the same identity.
|
|
223
228
|
- If macOS does not expose a running application’s bundle identifier, the helper checks its reported bundle only when its executable matches the observed process path, then falls back to that path. Consent identity creation fails only when both the bundle identifier and actual executable path are unavailable; process-instance verification can still fail independently.
|
|
224
229
|
- Persistent PTC is an external dependency assumption, not an implementation in this package. Real-model task success requires separate evaluation beyond native and protocol fixtures.
|
package/README.zh.md
CHANGED
|
@@ -22,34 +22,36 @@ kind: "package-reference"
|
|
|
22
22
|
|
|
23
23
|
helper 为授权提示和已授权应用列表提供 64 像素 PNG 图标。读取图标不会启动应用或检查窗口,图标不决定可复用授权。
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
helper 通过 LaunchServices 作为独立应用 `DSH Computer Use.app` 运行。辅助功能和屏幕录制权限属于此应用。授权引导使用启动时记录的责任应用 bundle URL、标识、文件名和系统图标;系统归属信息不可用时使用独立 helper 自身的 bundle。拖动和 Finder 选择通过应用发现模块读取磁盘上当前的 bundle 标识及可执行文件。页面和引导框统一显示应用的 `.app` 文件名。其他构建更新 `current.json` 后,已有连接仍指向正在运行的应用版本。
|
|
26
|
+
|
|
27
|
+
权限请求打开对应隐私设置页和原生悬浮引导框。引导框首次选择面积最大的设置窗口,随后按窗口 ID 跟随。它使用普通窗口层级,紧邻所选窗口上方排列,使认证弹窗保持在其上方。定位读取窗口边界,不申请辅助功能权限。引导框等到识别出设置窗口后才显示;打开设置失败时独立显示手动导航说明。材质的透明度遮罩为面板和阴影提供圆角。最新请求替换共享引导,连接清理只关闭自身创建的引导。应用不可用时仍尝试打开设置,并在页面报告失败原因。权限已授予时只打开设置;显式进入设置会关闭原有引导。系统拒绝打开设置时报告 `SETTINGS_UNAVAILABLE`;应用目标缺失或被替换时报告 `APPLICATION_UNAVAILABLE`。系统设置决定是否接收拖入的应用,以及是否要求重新启动。
|
|
28
|
+
|
|
29
|
+
provider 按当前界面语言生成引导和恢复文案,不支持的语言使用英语。将引导框内的应用拖入权限列表并开启开关;已有此应用时直接开启现有条目。拖动时隐藏引导框,放置被接收后关闭,拖动取消或被拒绝后恢复。返回按钮关闭引导框并返回之前的应用。右键点击应用行,或点击它使引导框获得键盘焦点后按 Return、空格,可在 Finder 中选中同一应用。原生引导打开期间,每隔 `permissionPollIntervalMs` 检查权限和窗口位置,默认 1000 毫秒;在确认授权、用户关闭、系统设置窗口消失或所属连接清理时关闭。拖动应用不代表授权完成。若 macOS 提示退出并重新打开应用,请按提示操作;系统不会自动终止共享 helper。
|
|
26
30
|
|
|
27
31
|
-----
|
|
28
32
|
|
|
29
33
|
<a id="use-this-package"></a>
|
|
30
34
|
## 使用本包
|
|
31
35
|
|
|
32
|
-
本包是仅限 macOS
|
|
36
|
+
本包是仅限 macOS 的可选依赖。本地开发时运行 `pnpm --dir packages/experimental/cua-macos run build:native`,在 `native/bin` 下生成临时签名应用及 `current.json`。正式打包需要指定 `--identity "Developer ID Application: <name> (<team>)"` 并完成公证,参见[原生构建与服务](native/README.zh.md#build-and-service)。安装版保留分发时的签名。源码准备需要 Apple Command Line Tools 提供的 Swift 和 Python 3。
|
|
33
37
|
|
|
34
38
|
从仓库运行 Web 时,在插件页开启 [Computer Use](../cua-bundle/README.zh.md)。首次启用会在 macOS 14 及以上准备本机组件,Windows 支持正在开发中。现有 Web profile 保持选中时,后续构建继续检查更新。未开启的 profile 不准备原生组件。也可以显式加载源码覆盖层:
|
|
35
39
|
|
|
36
40
|
```sh
|
|
37
|
-
swift build --package-path packages/experimental/cua-macos/native --configuration release
|
|
38
|
-
cua_native_root="$PWD/packages/experimental/cua-macos/native"
|
|
39
|
-
export DSH_CUA_HELPER="$cua_native_root/.build/release/dsh-cua-native"
|
|
40
41
|
pnpm dsh headless --patch packages/experimental/cua-macos/examples/macos.cordis.yml --dump-config
|
|
41
42
|
```
|
|
42
43
|
|
|
43
|
-
配置输出命令不发起模型请求。执行真实任务时,将 `--dump-config` 替换为任务提示,并配置该 profile 的模型凭据。配置挂载 computer-use 注册表和本 provider;使用前需移除已有的竞争 provider
|
|
44
|
+
配置输出命令不发起模型请求。执行真实任务时,将 `--dump-config` 替换为任务提示,并配置该 profile 的模型凭据。配置挂载 computer-use 注册表和本 provider;使用前需移除已有的竞争 provider。`DSH Computer Use.app` 需要辅助功能权限来读取 AX 和输入,需要屏幕录制权限来截图;通过 Computer Use 权限页打开系统设置并添加 helper。`getCapabilities` 查询权限和锁屏状态,不弹出系统授权窗口。桌面会话锁定或不可用时,界面观察与输入会在分派前拒绝,需由用户解锁 macOS 后继续。`listApps` 和 `cua.getState` 列出运行中的应用。`findApps(query)` 按名称、bundle ID 或绝对路径搜索 macOS 标准应用目录。`getApp` 按唯一名称、bundle ID、路径或运行中的 PID 选择应用,取得应用许可后,在需要时后台启动尚未运行的应用。授权前从磁盘读取应用的 Bundle ID 和可执行路径,在启动前后重新读取并核对;没有 Bundle ID 的应用使用规范化的可执行路径复用授权。选择尚未运行的安装副本时,会请求为该副本创建新实例。helper 等待应用完成启动后才返回其 PID。启动后验证失败会使待启动句柄失效,但进程可能仍在运行;应先查看运行中的应用,再取得新句柄。返回的对象读取初始 AX,不自动激活应用。启动被取消时,应用可能已经运行。模型指引要求先在后台观察和输入,不在初始化或每次动作前激活应用。窗口隐藏或最小化时,先尝试 `app.show()` 或 `window.show()`,再重新观察。它请求取消隐藏和恢复最小化,不主动激活、抬起窗口或切换桌面空间;应用级恢复选择焦点窗口、主窗口或唯一 AX 窗口。结果通过 `windowId` 指明选中的窗口,未选中时为 null;`foregroundChanged` 比较操作前后的前台应用和最上层窗口,无法取得完整观察时为 null,返回后仍可能发生焦点变化。恢复失败或窗口仍不可用时,说明需要前台的步骤,再调用 `app.activate()` 或窗口的 `raise` 动作并重新观察。必须使用前台时,以完成任务为先。应用收到输入后仍可能改变焦点,后台投递不保证用户操作始终不受干扰。
|
|
44
45
|
|
|
45
46
|
| 字段 | 默认值 | 含义 |
|
|
46
47
|
| --- | --- | --- |
|
|
47
48
|
| `agentPreset` | `ptc` | 仅为绑定该 preset 的 Agent 注册工具和指引;`false` 表示全局注册。 |
|
|
48
49
|
| `allowedApps` | `[]` | 旧路径和签名许可,只导入 profile 存储一次供撤销,不授予新 Bundle ID 身份访问权限。 |
|
|
49
|
-
| `helperPath` | 包内可执行文件 |
|
|
50
|
+
| `helperPath` | 包内可执行文件 | 已签名 helper `.app` 内可执行文件的绝对路径;裸二进制会触发 `NATIVE_APPLICATION_REQUIRED`。 |
|
|
50
51
|
| `buildTimeoutMs` | `300000` | 原生组件准备的最长时间。 |
|
|
51
52
|
| `timeoutMs` | `30000` | 单次操作截止时间,取消后可能已发生部分输入。 |
|
|
52
53
|
| `connectTimeoutMs` | `5000` | 连接或启动共享 helper 的截止时间。 |
|
|
54
|
+
| `permissionPollIntervalMs` | `1000` | 原生引导打开期间检查权限和窗口位置的间隔,单位为毫秒。 |
|
|
53
55
|
| `screenshotTimeoutMs` | `5000` | 截图总期限,包含排队时间,且不超过 `timeoutMs`。 |
|
|
54
56
|
| `axTimeoutMs` | `3000` | 每次 Accessibility 系统调用的截止时间,与完整操作截止独立配置。 |
|
|
55
57
|
| `maxRequestBytes` / `maxResponseBytes` | `1048576` / `33554432` | UTF-8 请求与响应字节限制。 |
|
|
@@ -79,7 +81,7 @@ AX 观察默认只展示菜单栏入口。使用 `app.getAXState({ includeMenus:
|
|
|
79
81
|
|
|
80
82
|
截图诊断使用带工具请求 ID 的 `[cua-screenshot]` 记录。原生阶段记录经本次 Agent 连接返回,覆盖窗口及 AX 几何检查、系统截图、PNG/Base64 编码和响应写出。Host 调试日志补充发送、响应和清理耗时。每次请求最多保留 8192 字节完整诊断记录,超限会明确标记;截图失败时附在错误中,保留到 Session trace。记录只含阶段、耗时和错误码,不含窗口标题、AX 正文或图片内容。
|
|
81
83
|
|
|
82
|
-
|
|
84
|
+
原生准备通过文件锁串行构建和签名,将完整应用保存在 `native/.build/prepared` 下的内容摘要目录中,再原子更新 `current.json`。旧连接继续使用原应用,相同构建复用已有文件,损坏的副本拒绝使用。取消或准备失败后,先完成受管进程清理再释放锁。
|
|
83
85
|
|
|
84
86
|
### 接入外部执行环境
|
|
85
87
|
|
|
@@ -213,12 +215,15 @@ Use selectText only on controls advertising selectionWritable. It selects a uniq
|
|
|
213
215
|
|
|
214
216
|
<a id="known-limitations-and-deferred-work"></a>
|
|
215
217
|
|
|
218
|
+
- 最低支持 macOS 14;设置导航、拖放接收和权限刷新需要在各支持版本验收。若 macOS 要求在修改屏幕录制权限后退出并重新打开 helper,权限检查在重启前可能仍返回未授权。可以关闭引导框,不必终止其他连接。
|
|
219
|
+
- 所选设置窗口离开可见窗口列表时,引导框会关闭,包括切换桌面空间或最小化导致窗口不再可见的情况。返回后再次申请权限可重新打开引导。
|
|
216
220
|
- 只提供 macOS 原生实现,Windows 支持正在开发中。本包暂放在 `experimental`,待 Windows 支持完成后迁回 `computer-use` 组。不支持浏览器标签、启动应用、AX 差分、无法确认应用归属的系统面板,以及仅后台辅助类型的应用。
|
|
217
221
|
- 坐标使用包含标题栏的返回截图像素;`relative: true` 使用 0~999 的整数,由 Host 换算原生 point。窗口移动、应用变化及其他桌面使用者的操作可能与观察和输入交错。
|
|
218
222
|
- macOS 台前调度可能将后台窗口的尺寸与截图变为缩略图,当前无法保证这种状态下的完整画面与坐标输入;模型指引要求说明前台需求并避免反复抢回焦点。
|
|
219
223
|
- 后台输入依赖私有 SkyLight 符号,macOS 升级可能使其不可用,需在目标系统版本验证。
|
|
220
224
|
- 实测 Blender Unicode 输入曾出现分派成功但界面未显示文本,后台 AppKit 的 Command+A 曾未选中全文。输入后必须检查应用状态;工具返回成功只表示已分派。
|
|
221
|
-
-
|
|
225
|
+
- 源码构建使用临时签名,源码变化后可能需要重新授权。正式分发应以固定 Developer ID 签名并完成公证;构建命令支持 `--identity` 指定签名身份,安装版保留分发时的签名。[权限页面](../cua/README.zh.md)提供 helper 授权入口和目标应用许可撤销。
|
|
226
|
+
- 发布打包不自动验证 GUI 启动、helper 身份或退出清理。发布维护者可在发布前,在已登录桌面的 Mac 上执行[分发 smoke](native/README.zh.md#build-and-service);打包成功不能证明这些运行行为已通过验收。
|
|
222
227
|
- 已保存许可的条目显示一个已批准副本的名称、路径和图标,不枚举共享身份的所有安装副本。删除该副本后图标可能不可用,撤销仍作用于同一身份的所有副本。
|
|
223
228
|
- macOS 无法提供运行中应用的 Bundle ID 时,helper 仅在其报告的 bundle 可执行路径与实际进程路径相同时读取该 bundle,仍无标识则使用路径。只有 Bundle ID 和实际可执行路径均不可用时才拒绝生成授权身份;进程实例验证仍可能独立失败。
|
|
224
229
|
- 持久 PTC 是对外部运行环境的假设,本包不实现它。真实模型任务成功率需要在原生测试和协议测试之外单独评估。
|
package/cua-helper.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 1,
|
|
3
|
+
"version": "0.2.2-alpha.3",
|
|
4
|
+
"commit": "43a1ef19789470cb0adf5090298a1b2210cf5c2a",
|
|
5
|
+
"teamId": "NAN929V4UM",
|
|
6
|
+
"applications": [
|
|
7
|
+
{
|
|
8
|
+
"architecture": "arm64",
|
|
9
|
+
"bundle": "007deaf0f4b6b473af03a201a5042208f8249172c41c27894bc09241e5e3f19b"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"architecture": "x64",
|
|
13
|
+
"bundle": "9f6e6dedbc05279505e36b140ddd74a7d143b31838e17ba22ad3115fc14c55b2"
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
}
|
package/lib/index.js
CHANGED
|
@@ -1,19 +1,129 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isAbsolute, join, resolve } from "node:path";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
|
+
import Schema from "@deepseek-ai/schemastery";
|
|
4
|
+
import { z } from "zod";
|
|
3
5
|
import { CuaConfig, installCua } from "@deepseek-ai/dsh-cua";
|
|
4
6
|
import { constants } from "node:fs";
|
|
5
|
-
import { createHash } from "node:crypto";
|
|
6
7
|
import { access, lstat, mkdir, readFile, realpath } from "node:fs/promises";
|
|
7
|
-
import { withFileLock
|
|
8
|
+
import { withFileLock } from "@deepseek-ai/dsh-atomic-write";
|
|
9
|
+
import { createHash } from "node:crypto";
|
|
8
10
|
import { Socket } from "node:net";
|
|
9
11
|
import { userInfo } from "node:os";
|
|
10
12
|
import { PassThrough, Writable } from "node:stream";
|
|
11
13
|
import { setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
12
|
-
|
|
14
|
+
z.object({ settingsMessage: z.string().min(1) }).extend({
|
|
15
|
+
instruction: z.string().min(1),
|
|
16
|
+
backLabel: z.string().min(1),
|
|
17
|
+
finderLabel: z.string().min(1),
|
|
18
|
+
unavailableMessage: z.string().min(1),
|
|
19
|
+
pollIntervalMs: z.number().int().min(100).max(2 ** 31 - 1)
|
|
20
|
+
});
|
|
21
|
+
const en = {
|
|
22
|
+
instruction: "Drag {application} to the list above to allow {permission}",
|
|
23
|
+
backLabel: "Back",
|
|
24
|
+
finderLabel: "Show in Finder",
|
|
25
|
+
unavailableMessage: "Application unavailable. Enable Computer Use again and retry.",
|
|
26
|
+
settingsMessage: "Open System Settings > Privacy & Security > {permission} manually.",
|
|
27
|
+
accessibility: "Accessibility",
|
|
28
|
+
screenRecording: "Screen Recording"
|
|
29
|
+
};
|
|
30
|
+
const dictionaries = new Map(Object.entries({
|
|
31
|
+
en,
|
|
32
|
+
zh: {
|
|
33
|
+
instruction: "将 {application} 拖入上方列表以允许{permission}",
|
|
34
|
+
backLabel: "返回",
|
|
35
|
+
finderLabel: "在 Finder 中显示",
|
|
36
|
+
unavailableMessage: "找不到此应用。请重新启用 Computer Use 后重试",
|
|
37
|
+
settingsMessage: "请手动打开系统设置 > 隐私与安全性 > {permission}",
|
|
38
|
+
accessibility: "辅助功能",
|
|
39
|
+
screenRecording: "屏幕录制"
|
|
40
|
+
},
|
|
41
|
+
ja: {
|
|
42
|
+
instruction: "{permission}を許可するには、{application}を上の一覧にドラッグしてください",
|
|
43
|
+
backLabel: "戻る",
|
|
44
|
+
finderLabel: "Finder で表示",
|
|
45
|
+
unavailableMessage: "アプリが見つかりません。Computer Use を再度有効にしてください。",
|
|
46
|
+
settingsMessage: "システム設定 > プライバシーとセキュリティ > {permission} を開いてください。",
|
|
47
|
+
accessibility: "アクセシビリティ",
|
|
48
|
+
screenRecording: "画面収録"
|
|
49
|
+
},
|
|
50
|
+
es: {
|
|
51
|
+
instruction: "Arrastra {application} a la lista de arriba para permitir {permission}",
|
|
52
|
+
backLabel: "Volver",
|
|
53
|
+
finderLabel: "Mostrar en Finder",
|
|
54
|
+
unavailableMessage: "Aplicación no disponible. Vuelve a activar Computer Use e inténtalo de nuevo.",
|
|
55
|
+
settingsMessage: "Abre Configuración del sistema > Privacidad y seguridad > {permission}.",
|
|
56
|
+
accessibility: "Accesibilidad",
|
|
57
|
+
screenRecording: "Grabación de pantalla"
|
|
58
|
+
},
|
|
59
|
+
fr: {
|
|
60
|
+
instruction: "Glissez {application} dans la liste ci-dessus pour autoriser {permission}",
|
|
61
|
+
backLabel: "Retour",
|
|
62
|
+
finderLabel: "Afficher dans le Finder",
|
|
63
|
+
unavailableMessage: "Application introuvable. Réactivez Computer Use et réessayez.",
|
|
64
|
+
settingsMessage: "Ouvrez Réglages Système > Confidentialité et sécurité > {permission}.",
|
|
65
|
+
accessibility: "Accessibilité",
|
|
66
|
+
screenRecording: "Enregistrement d'écran"
|
|
67
|
+
},
|
|
68
|
+
de: {
|
|
69
|
+
instruction: "Ziehe {application} in die Liste oben, um {permission} zu erlauben",
|
|
70
|
+
backLabel: "Zurück",
|
|
71
|
+
finderLabel: "Im Finder anzeigen",
|
|
72
|
+
unavailableMessage: "Anwendung nicht verfügbar. Aktiviere Computer Use erneut.",
|
|
73
|
+
settingsMessage: "Öffne Systemeinstellungen > Datenschutz & Sicherheit > {permission}.",
|
|
74
|
+
accessibility: "Barrierefreiheit",
|
|
75
|
+
screenRecording: "Bildschirmaufzeichnung"
|
|
76
|
+
},
|
|
77
|
+
ru: {
|
|
78
|
+
instruction: "Перетащите {application} в список выше, чтобы разрешить {permission}",
|
|
79
|
+
backLabel: "Назад",
|
|
80
|
+
finderLabel: "Показать в Finder",
|
|
81
|
+
unavailableMessage: "Приложение недоступно. Снова включите Computer Use и повторите попытку.",
|
|
82
|
+
settingsMessage: "Откройте Системные настройки > Конфиденциальность и безопасность > {permission}.",
|
|
83
|
+
accessibility: "Доступность",
|
|
84
|
+
screenRecording: "Запись экрана"
|
|
85
|
+
},
|
|
86
|
+
pt: {
|
|
87
|
+
instruction: "Arraste {application} para a lista acima para permitir {permission}",
|
|
88
|
+
backLabel: "Voltar",
|
|
89
|
+
finderLabel: "Mostrar no Finder",
|
|
90
|
+
unavailableMessage: "Aplicativo indisponível. Ative Computer Use novamente e tente de novo.",
|
|
91
|
+
settingsMessage: "Abra Ajustes do Sistema > Privacidade e Segurança > {permission}.",
|
|
92
|
+
accessibility: "Acessibilidade",
|
|
93
|
+
screenRecording: "Gravação de tela"
|
|
94
|
+
}
|
|
95
|
+
}));
|
|
96
|
+
/**
|
|
97
|
+
* Resolve native permission copy from the Client language; unsupported languages use English.
|
|
98
|
+
* @param pollIntervalMs Interval between native guide permission and position checks.
|
|
99
|
+
* @returns Provider-owned parameters for the selected permission action.
|
|
100
|
+
*/
|
|
101
|
+
function createPermissionParameters(pollIntervalMs) {
|
|
102
|
+
return (method, permission, locale) => {
|
|
103
|
+
const language = locale.toLowerCase().replace(/-.*/, "");
|
|
104
|
+
const text = dictionaries.get(language) ?? en;
|
|
105
|
+
const settingsMessage = text.settingsMessage.replace("{permission}", text[permission]);
|
|
106
|
+
if (method === "openPermissionSettings") return {
|
|
107
|
+
permission,
|
|
108
|
+
settingsMessage
|
|
109
|
+
};
|
|
110
|
+
return {
|
|
111
|
+
permission,
|
|
112
|
+
settingsMessage,
|
|
113
|
+
pollIntervalMs,
|
|
114
|
+
instruction: text.instruction.replace("{permission}", text[permission]),
|
|
115
|
+
backLabel: text.backLabel,
|
|
116
|
+
finderLabel: text.finderLabel,
|
|
117
|
+
unavailableMessage: text.unavailableMessage
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
//#endregion
|
|
13
122
|
//#region lib/types/native-build.js
|
|
14
|
-
/** Source-checkout preparation and installed
|
|
123
|
+
/** Source-checkout preparation and installed macOS application resolution. */
|
|
124
|
+
const NativeApplication = z.object({ bundle: z.string().regex(/^[a-f0-9]{64}$/) }).strict();
|
|
15
125
|
/**
|
|
16
|
-
* Validate the host before preparing a platform-specific
|
|
126
|
+
* Validate the host before preparing a platform-specific application.
|
|
17
127
|
* @param platform - Node host platform.
|
|
18
128
|
* @param architecture - Node host architecture.
|
|
19
129
|
* @returns Supported macOS architecture.
|
|
@@ -24,17 +134,19 @@ function nativeHostArchitecture(platform, architecture) {
|
|
|
24
134
|
return architecture;
|
|
25
135
|
}
|
|
26
136
|
/**
|
|
27
|
-
*
|
|
28
|
-
* @param
|
|
29
|
-
* @
|
|
30
|
-
* @
|
|
137
|
+
* Resolve the immutable application selected by a packaged or source-build receipt.
|
|
138
|
+
* @param directory - Architecture-specific directory containing current.json and application generations.
|
|
139
|
+
* @returns Executable inside the selected application bundle.
|
|
140
|
+
* @throws When the receipt is invalid or the application executable is missing.
|
|
31
141
|
*/
|
|
32
|
-
function nativeExecutablePath(
|
|
33
|
-
|
|
142
|
+
async function nativeExecutablePath(directory) {
|
|
143
|
+
const executable = join(directory, NativeApplication.parse(JSON.parse(await readFile(join(directory, "current.json"), "utf8"))).bundle, "DSH Computer Use.app", "Contents", "MacOS", "dsh-cua-native");
|
|
144
|
+
await access(executable, constants.X_OK);
|
|
145
|
+
return executable;
|
|
34
146
|
}
|
|
35
147
|
/**
|
|
36
148
|
* Recognize the repository-owned package location before allowing local compilation.
|
|
37
|
-
* @param packageRoot - Real directory containing
|
|
149
|
+
* @param packageRoot - Real directory containing the CUA package manifest.
|
|
38
150
|
* @returns True only for a CUA package in a DSH source checkout.
|
|
39
151
|
*/
|
|
40
152
|
async function isSourcePackage(packageRoot) {
|
|
@@ -49,97 +161,68 @@ async function isSourcePackage(packageRoot) {
|
|
|
49
161
|
}
|
|
50
162
|
}
|
|
51
163
|
/**
|
|
52
|
-
* Build
|
|
164
|
+
* Build and sign an immutable helper application with the selected Apple developer tools.
|
|
53
165
|
* @param spec - Checkout, target, managed process provider and cancellation/deadline limits.
|
|
54
|
-
* @returns
|
|
55
|
-
* @throws When
|
|
166
|
+
* @returns Executable inside the prepared application, after complete compiler cleanup.
|
|
167
|
+
* @throws When preparation, cancellation, resource cleanup or receipt validation fails.
|
|
56
168
|
*/
|
|
57
169
|
async function buildNativeExecutable(spec) {
|
|
58
170
|
spec.signal.throwIfAborted();
|
|
59
|
-
const executable = nativeExecutablePath(spec.packageRoot, spec.architecture);
|
|
60
|
-
await mkdir(dirname(executable), { recursive: true });
|
|
61
|
-
const signal = AbortSignal.any([spec.signal, AbortSignal.timeout(spec.timeoutMs)]);
|
|
62
|
-
return withFileLock(executable, () => compileNative(spec, signal, executable), {
|
|
63
|
-
waitMs: spec.timeoutMs,
|
|
64
|
-
signal
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
async function compileNative(spec, signal, executable) {
|
|
68
171
|
const nativeRoot = join(spec.packageRoot, "native");
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
let outcome;
|
|
96
|
-
try {
|
|
97
|
-
outcome = await handle.done;
|
|
98
|
-
} finally {
|
|
172
|
+
const directory = join(nativeRoot, ".build", "prepared", spec.architecture);
|
|
173
|
+
const signal = AbortSignal.any([spec.signal, AbortSignal.timeout(spec.timeoutMs)]);
|
|
174
|
+
await mkdir(join(nativeRoot, ".build"), { recursive: true });
|
|
175
|
+
return withFileLock(join(nativeRoot, ".build", "application-build"), async () => {
|
|
176
|
+
const handle = spec.subprocess.spawn({
|
|
177
|
+
argv: [
|
|
178
|
+
"/usr/bin/xcrun",
|
|
179
|
+
"python3",
|
|
180
|
+
join(nativeRoot, "build_app.py"),
|
|
181
|
+
"--scratch-path",
|
|
182
|
+
join(nativeRoot, ".build", `runtime-${spec.architecture}`),
|
|
183
|
+
"--output-directory",
|
|
184
|
+
directory,
|
|
185
|
+
"--arch",
|
|
186
|
+
spec.architecture === "x64" ? "x86_64" : "arm64"
|
|
187
|
+
],
|
|
188
|
+
cwd: spec.packageRoot,
|
|
189
|
+
signal,
|
|
190
|
+
graceMs: spec.graceMs,
|
|
191
|
+
stdio: {
|
|
192
|
+
stdin: "ignore",
|
|
193
|
+
stdout: { maxBytes: 65536 },
|
|
194
|
+
stderr: { maxBytes: 65536 }
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
let outcome;
|
|
99
198
|
try {
|
|
100
|
-
handle.
|
|
199
|
+
outcome = await handle.done;
|
|
101
200
|
} finally {
|
|
102
|
-
|
|
201
|
+
try {
|
|
202
|
+
handle.terminate();
|
|
203
|
+
} finally {
|
|
204
|
+
if (!await handle.waitForExit()) throw new Error("Computer use preparation did not release its managed process range");
|
|
205
|
+
}
|
|
103
206
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
} catch (error) {
|
|
115
|
-
if (error.code !== "ENOENT") throw error;
|
|
116
|
-
}
|
|
117
|
-
signal.throwIfAborted();
|
|
118
|
-
if (!previous?.equals(built)) await writeFileAtomic(executable, built, { mode: 493 });
|
|
119
|
-
const digest = createHash("sha256").update(built).digest("hex");
|
|
120
|
-
const runtime = join(nativeRoot, ".build", "prepared", spec.architecture, digest, "dsh-cua-native");
|
|
121
|
-
await mkdir(dirname(runtime), { recursive: true });
|
|
122
|
-
let retained;
|
|
123
|
-
try {
|
|
124
|
-
retained = await readFile(runtime);
|
|
125
|
-
} catch (error) {
|
|
126
|
-
if (error.code !== "ENOENT") throw error;
|
|
127
|
-
}
|
|
128
|
-
if (retained && !retained.equals(built)) throw new Error("Computer use retained executable does not match its content digest");
|
|
129
|
-
signal.throwIfAborted();
|
|
130
|
-
if (!retained) await writeFileAtomic(runtime, built, { mode: 493 });
|
|
131
|
-
await access(runtime, constants.X_OK);
|
|
132
|
-
return runtime;
|
|
207
|
+
signal.throwIfAborted();
|
|
208
|
+
if (outcome.exitCode !== 0 || outcome.signal !== null) {
|
|
209
|
+
const diagnostics = `${handle.collected.stdout?.readFrom(0).text ?? ""}${handle.collected.stderr?.readFrom(0).text ?? ""}`;
|
|
210
|
+
throw new Error(`Computer use native preparation failed (${String(outcome.exitCode)}, ${String(outcome.signal)}): ${diagnostics}`);
|
|
211
|
+
}
|
|
212
|
+
return nativeExecutablePath(directory);
|
|
213
|
+
}, {
|
|
214
|
+
waitMs: spec.timeoutMs,
|
|
215
|
+
signal
|
|
216
|
+
});
|
|
133
217
|
}
|
|
134
218
|
/**
|
|
135
|
-
* Prepare source builds on activation; installed packages
|
|
219
|
+
* Prepare source builds on activation; installed packages carry their signed application.
|
|
136
220
|
* @param spec - Native preparation inputs for this host.
|
|
137
|
-
* @returns
|
|
221
|
+
* @returns Executable inside a ready application without compiling or re-signing an installed package.
|
|
138
222
|
*/
|
|
139
223
|
async function prepareNativeExecutable(spec) {
|
|
140
224
|
if (await isSourcePackage(spec.packageRoot)) return buildNativeExecutable(spec);
|
|
141
|
-
const executable = nativeExecutablePath(spec.packageRoot, spec.architecture);
|
|
142
|
-
await access(executable, constants.X_OK);
|
|
225
|
+
const executable = await nativeExecutablePath(join(spec.packageRoot, "native", "bin", `darwin-${spec.architecture}`));
|
|
143
226
|
spec.signal.throwIfAborted();
|
|
144
227
|
return executable;
|
|
145
228
|
}
|
|
@@ -332,6 +415,13 @@ var SharedNativeChannel = class {
|
|
|
332
415
|
if (!range.value) throw transportError("NATIVE_CLEANUP", "Native launcher process range did not close");
|
|
333
416
|
if (outcome.status === "rejected") throw outcome.reason;
|
|
334
417
|
if (outcome.value.exitCode !== 0 || outcome.value.signal !== null) {
|
|
418
|
+
const stdout = this.launcher.collected.stdout?.readFrom(0).text ?? "";
|
|
419
|
+
let response;
|
|
420
|
+
try {
|
|
421
|
+
response = JSON.parse(stdout);
|
|
422
|
+
} catch (_error) {}
|
|
423
|
+
const refusal = Refusal.safeParse(response);
|
|
424
|
+
if (refusal.success) throw transportError(refusal.data.code, refusal.data.message);
|
|
335
425
|
const stderr = this.launcher.collected.stderr?.readFrom(0).text ?? "";
|
|
336
426
|
throw transportError("NATIVE_STARTUP", `Native launcher failed (exit ${outcome.value.exitCode}, signal ${outcome.value.signal})${stderr ? `: ${stderr}` : ""}`);
|
|
337
427
|
}
|
|
@@ -527,8 +617,8 @@ const inject = [
|
|
|
527
617
|
"subprocess",
|
|
528
618
|
"agents"
|
|
529
619
|
];
|
|
530
|
-
/** Validate
|
|
531
|
-
const Config = CuaConfig;
|
|
620
|
+
/** Validate shared resource bounds and macOS guide configuration before preparing the helper. */
|
|
621
|
+
const Config = Schema.intersect([CuaConfig, Schema.object({ permissionPollIntervalMs: Schema.number().step(1).min(100).max(2 ** 31 - 1).default(1e3) })]);
|
|
532
622
|
const description = "Inspect macOS permissions, select an application and window, read AX state, capture screenshots or dispatch input. Use appHandle from getApp; verify actions by reading fresh state.";
|
|
533
623
|
/**
|
|
534
624
|
* Mount logged native operations with separate Agent connections to the shared helper.
|
|
@@ -537,13 +627,17 @@ const description = "Inspect macOS permissions, select an application and window
|
|
|
537
627
|
* @returns Completion after native preparation and tool registration.
|
|
538
628
|
*/
|
|
539
629
|
async function apply(ctx, config) {
|
|
630
|
+
const backend = {
|
|
631
|
+
createChannel: createSharedNativeChannel,
|
|
632
|
+
guidance: GUIDANCE,
|
|
633
|
+
description,
|
|
634
|
+
permissionParameters: createPermissionParameters(config.permissionPollIntervalMs)
|
|
635
|
+
};
|
|
540
636
|
if (config.helperPath !== void 0) {
|
|
541
637
|
if (!isAbsolute(config.helperPath)) throw new Error("dsh-cua helperPath must be absolute");
|
|
542
638
|
installCua(ctx, config, {
|
|
543
639
|
helperPath: config.helperPath,
|
|
544
|
-
|
|
545
|
-
guidance: GUIDANCE,
|
|
546
|
-
description
|
|
640
|
+
...backend
|
|
547
641
|
});
|
|
548
642
|
return;
|
|
549
643
|
}
|
|
@@ -565,9 +659,7 @@ async function apply(ctx, config) {
|
|
|
565
659
|
controller.signal.throwIfAborted();
|
|
566
660
|
installCua(ctx, config, {
|
|
567
661
|
helperPath,
|
|
568
|
-
|
|
569
|
-
guidance: GUIDANCE,
|
|
570
|
-
description
|
|
662
|
+
...backend
|
|
571
663
|
});
|
|
572
664
|
}
|
|
573
665
|
//#endregion
|