@deepseek-ai/dsh-cua 0.0.0-stage → 0.2.1-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/LICENSE +21 -0
- package/README.i18n.yaml +46 -0
- package/README.md +93 -2
- package/README.zh.md +94 -0
- package/lib/api.js +591 -0
- package/lib/bridge.js +605 -0
- package/lib/index.js +1184 -0
- package/lib/native-client.js +285 -0
- package/lib/protocol.js +295 -0
- package/lib/types/api.d.ts +10 -0
- package/lib/types/application-access.d.ts +74 -0
- package/lib/types/application-types.d.ts +14 -0
- package/lib/types/bridge.d.ts +13 -0
- package/lib/types/coordinates.d.ts +35 -0
- package/lib/types/index.d.ts +117 -0
- package/lib/types/native-client.d.ts +91 -0
- package/lib/types/protocol.d.ts +417 -0
- package/lib/types/types.d.ts +262 -0
- package/package.json +96 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 DeepSeek
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.i18n.yaml
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Bilingual-pair consistency record for README.md (docs/i18n/README.md): per heading
|
|
2
|
+
# section, a hash of its English and Chinese blocks outside code blocks and generated regions.
|
|
3
|
+
# After editing either side, bring the other along and re-record with:
|
|
4
|
+
# pnpm run verify-translation-pairing --write packages/experimental/cua/README.md
|
|
5
|
+
/:
|
|
6
|
+
en: aa3d316ef17feae7
|
|
7
|
+
zh: 5a30d743ce257d5b
|
|
8
|
+
/deepseek-ai-dsh-cua:
|
|
9
|
+
en: 0ef7ee882840cf1b
|
|
10
|
+
zh: 01b9e768eff2d302
|
|
11
|
+
/deepseek-ai-dsh-cua/summary:
|
|
12
|
+
en: f4d9cc48587d62a2
|
|
13
|
+
zh: d1bac6c1fe7eb29e
|
|
14
|
+
/deepseek-ai-dsh-cua/table-of-contents:
|
|
15
|
+
en: d152484eb41ac6b4
|
|
16
|
+
zh: 1db86285abf6c499
|
|
17
|
+
/deepseek-ai-dsh-cua/use-this-package:
|
|
18
|
+
en: 52cacbe2d2aeb2bc
|
|
19
|
+
zh: b3c65814d9a17052
|
|
20
|
+
/deepseek-ai-dsh-cua/understand-the-implementation:
|
|
21
|
+
en: effcee57d8854c32
|
|
22
|
+
zh: d02c6b76e7249051
|
|
23
|
+
/deepseek-ai-dsh-cua/further-exploration:
|
|
24
|
+
en: b8b0aece886fadaa
|
|
25
|
+
zh: ecd8c88d601f2179
|
|
26
|
+
/deepseek-ai-dsh-cua/model-experience:
|
|
27
|
+
en: 215e7ba838619b7b
|
|
28
|
+
zh: a311da3843709f90
|
|
29
|
+
/deepseek-ai-dsh-cua/model-experience/authorized-application-operations:
|
|
30
|
+
en: 0faf1e4d409d61aa
|
|
31
|
+
zh: 1866dd0b702f2a26
|
|
32
|
+
/deepseek-ai-dsh-cua/model-experience/authorized-application-operations/what-the-model-sees:
|
|
33
|
+
en: 4f90c4a6b121bce0
|
|
34
|
+
zh: c36ab4b80985c76e
|
|
35
|
+
/deepseek-ai-dsh-cua/model-experience/authorized-application-operations/token-effect:
|
|
36
|
+
en: 88463f0304c207bd
|
|
37
|
+
zh: 6d3ae2f1b8e45747
|
|
38
|
+
/deepseek-ai-dsh-cua/model-experience/authorized-application-operations/kv-cache-effect:
|
|
39
|
+
en: 2d5df52dafa1d940
|
|
40
|
+
zh: 06e815759b9150c3
|
|
41
|
+
/deepseek-ai-dsh-cua/known-limitations-and-deferred-work:
|
|
42
|
+
en: da6aefcb279aea83
|
|
43
|
+
zh: b45b7bb300b9f792
|
|
44
|
+
/deepseek-ai-dsh-cua/known-limitations-and-deferred-work/dev-note:
|
|
45
|
+
en: 0a1253c6f7b5e8b9
|
|
46
|
+
zh: 9f56528562c7c914
|
package/README.md
CHANGED
|
@@ -1,3 +1,94 @@
|
|
|
1
|
-
|
|
1
|
+
---
|
|
2
|
+
description: "Reuse Computer Use application and window objects with authorized, logged platform operations."
|
|
3
|
+
kind: "package-library"
|
|
4
|
+
---
|
|
2
5
|
|
|
3
|
-
|
|
6
|
+
# @deepseek-ai/dsh-cua
|
|
7
|
+
|
|
8
|
+
English | [中文](README.zh.md)
|
|
9
|
+
|
|
10
|
+
## Summary
|
|
11
|
+
|
|
12
|
+
Inspect applications, retain window objects across PTC calls, and send actions through the normal tool pipeline. Platform providers supply native execution; this library owns the object API, request validation, application consent, and image admission. The external PTC runtime owns variable persistence.
|
|
13
|
+
|
|
14
|
+
## Table of Contents
|
|
15
|
+
|
|
16
|
+
- [Use this package](#use-this-package)
|
|
17
|
+
- [Understand the implementation](#understand-the-implementation)
|
|
18
|
+
- [Further Exploration](#further-exploration)
|
|
19
|
+
- [Model Experience](#model-experience)
|
|
20
|
+
- [Known Limitations and Deferred Work](#known-limitations-and-deferred-work)
|
|
21
|
+
- [Dev Note](#dev-note)
|
|
22
|
+
|
|
23
|
+
-----
|
|
24
|
+
|
|
25
|
+
<a id="use-this-package"></a>
|
|
26
|
+
## Use this package
|
|
27
|
+
|
|
28
|
+
Mount the [macOS provider](../cua-macos/README.md) to enable native operations. External PTC hosts import `connectCua` from `@deepseek-ai/dsh-cua/bridge` and supply the current `tools.cua` binding. Source compositions and native preparation belong to the provider.
|
|
29
|
+
|
|
30
|
+
Use App methods for a single-window task. `getApp` reads initial accessibility state; `getWindows` and `getWindow` select an explicit window when needed. Re-reading one app/window scope replaces its element indices without invalidating another window's snapshot. Keyboard input follows the application's focus. Invalid request arguments reject before dispatch with a readable method, parameter and requirement.
|
|
31
|
+
|
|
32
|
+
Observation methods emit and return their result. Use `void await app.getAXState()` for one visible copy, or use `emit:false` and print the returned text once. Screenshots return `CuaScreenshot` with `bytes`, `mimeType`, `pixelWidth`, `pixelHeight`, and `windowId`. The image sink receives the same object. Use its MIME type when selecting a file extension or declaring an image; the format can be PNG, JPEG, WebP, or GIF. Each screenshot enters the attachment pipeline once; `emit:false` only suppresses the object sink.
|
|
33
|
+
|
|
34
|
+
`tools.cua` returns operation values directly. Screenshot values retain the encoded image Base64 and add a durable `attachment` reference for the tool renderer; model content contains coordinate metadata and one image, without the encoded bytes. Before capture, the tool requires an attachment store and a resolved model route declaring image input. Admission and storage failures reject the call. The object bridge preserves the screenshot bytes and validated metadata without uploading or emitting the same image again.
|
|
35
|
+
|
|
36
|
+
Application consent precedes launch, observation, capture, and input. Task access belongs to the selected instance; saved grants require platform-verified executable identity. Revocation closes affected Agent connections, so their old objects require fresh selection. No input is replayed after cancellation, timeout, or reconnect.
|
|
37
|
+
|
|
38
|
+
Actions return `dispatched:true, verified:false`; read fresh state to verify the result. Coordinate actions default to pixels in the latest returned screenshot; `relative: true` accepts integers from 0 to 1000 after a successful window observation. The Host resolves attachment normalization and the selected model route’s image projection before returning the screenshot, then converts input to native window points. Resizing invalidates the screenshot mapping; `SCREENSHOT_REQUIRED` requires a new screenshot for absolute coordinates. Resizing rejects old coordinates with `WINDOW_CHANGED`; movement alone preserves window-local coordinates.
|
|
39
|
+
|
|
40
|
+
-----
|
|
41
|
+
|
|
42
|
+
<a id="understand-the-implementation"></a>
|
|
43
|
+
## Understand the implementation
|
|
44
|
+
|
|
45
|
+
<details>
|
|
46
|
+
<summary>Shared execution and platform ownership</summary>
|
|
47
|
+
|
|
48
|
+
The provider calls [installCua](src/index.ts) with its prepared helper, connection factory, and guidance. [NativeClient](src/native-client.ts) owns request correlation, byte limits, cancellation acknowledgement, and failure settlement. The platform connector owns startup and connection cleanup. The shared executor retains one connection per Agent and joins in-flight image writes during disposal.
|
|
49
|
+
|
|
50
|
+
[The operation schema](src/protocol.ts) is the authority for model parameters and separately declared Host-only fields. Native implementations enforce target identity, window geometry, resource limits, and operating-system access at execution. No invariant companion is published because this library has no separately projected registry or durable state.
|
|
51
|
+
|
|
52
|
+
</details>
|
|
53
|
+
|
|
54
|
+
-----
|
|
55
|
+
|
|
56
|
+
<a id="further-exploration"></a>
|
|
57
|
+
## Further Exploration
|
|
58
|
+
|
|
59
|
+
- [macOS provider](../cua-macos/README.md)
|
|
60
|
+
- [Object interfaces](src/types.ts)
|
|
61
|
+
|
|
62
|
+
-----
|
|
63
|
+
|
|
64
|
+
<a id="model-experience"></a>
|
|
65
|
+
## Model Experience
|
|
66
|
+
|
|
67
|
+
### Authorized application operations
|
|
68
|
+
|
|
69
|
+
#### What the model sees
|
|
70
|
+
|
|
71
|
+
Platform providers mount the shared `cua` tool and supply operating instructions. Calls and observations use the same app/window interface and enter normal Session history. Platform guidance is documented by the [macOS provider](../cua-macos/README.md#model-experience).
|
|
72
|
+
|
|
73
|
+
#### Token effect
|
|
74
|
+
|
|
75
|
+
Operation results and admitted images add model input. Retained JavaScript objects are not serialized into prompts. Duplicate caller printing can repeat observation text.
|
|
76
|
+
|
|
77
|
+
#### KV Cache effect
|
|
78
|
+
|
|
79
|
+
Results append to history. Retaining objects does not rewrite previous messages; changing the mounted tools or guidance can change the request prefix.
|
|
80
|
+
|
|
81
|
+
## Known Limitations and Deferred Work
|
|
82
|
+
|
|
83
|
+
<a id="known-limitations-and-deferred-work"></a>
|
|
84
|
+
|
|
85
|
+
- Native execution currently uses the macOS provider. Windows support is planned as a separate provider package with a C# helper, retaining the shared app/window API, authorization, snapshot validity, and action-result semantics. Its implementation must document system-specific limitations and distinguish cross-compilation evidence from Windows desktop validation.
|
|
86
|
+
- Persistent variables do not reserve an application across a sequence of operations. Other Agents and the user can change its state. Hover and observations do not restore the previous pointer position; [continuous interaction](../../../.agents/notes/implemented/architecture/2026-10-13-cua-continuous-hover.md) uses no cross-call ownership.
|
|
87
|
+
- The package stays in `experimental` until Windows support and platform validation permit promotion to the `computer-use` group.
|
|
88
|
+
|
|
89
|
+
-----
|
|
90
|
+
|
|
91
|
+
<a id="dev-note"></a>
|
|
92
|
+
### Dev Note
|
|
93
|
+
|
|
94
|
+
None.
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "复用 Computer Use 应用和窗口对象,通过已授权并记录日志的平台操作完成任务。"
|
|
3
|
+
kind: "package-library"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# @deepseek-ai/dsh-cua
|
|
7
|
+
|
|
8
|
+
[English](README.md) | 中文
|
|
9
|
+
|
|
10
|
+
## 概述
|
|
11
|
+
|
|
12
|
+
检查应用、跨 PTC 调用保留窗口对象,并通过正常工具执行链发送动作。平台提供方负责原生执行;本库负责对象 API、请求校验、应用授权和图像接纳。变量持久性由外部 PTC 运行时负责。
|
|
13
|
+
|
|
14
|
+
## 目录
|
|
15
|
+
|
|
16
|
+
- [使用本包](#use-this-package)
|
|
17
|
+
- [理解实现](#understand-the-implementation)
|
|
18
|
+
- [进一步探索](#further-exploration)
|
|
19
|
+
- [模型体验](#model-experience)
|
|
20
|
+
- [已知限制与后续工作](#known-limitations-and-deferred-work)
|
|
21
|
+
- [开发备注](#dev-note)
|
|
22
|
+
|
|
23
|
+
-----
|
|
24
|
+
|
|
25
|
+
<a id="use-this-package"></a>
|
|
26
|
+
## 使用本包
|
|
27
|
+
|
|
28
|
+
挂载 [macOS 提供方](../cua-macos/README.zh.md)以启用原生操作。外部 PTC 宿主从 `@deepseek-ai/dsh-cua/bridge` 导入 `connectCua`,并提供当前 `tools.cua` 绑定。源码组合与原生组件准备由提供方负责。
|
|
29
|
+
|
|
30
|
+
单窗口任务直接使用 App 方法。`getApp` 读取初始辅助功能状态;需要指定窗口时使用 `getWindows` 和 `getWindow`。重新读取一个应用或窗口范围会替换其中的元素编号,不使其他窗口的快照失效。键盘输入跟随应用焦点。请求参数校验失败时,在分派前返回包含方法、参数和要求的可读消息。
|
|
31
|
+
|
|
32
|
+
观察方法会输出并返回结果。使用 `void await app.getAXState()` 只展示一份内容,或使用 `emit:false` 后打印一次返回文本。截图返回包含 `bytes`、`mimeType`、`pixelWidth`、`pixelHeight` 和 `windowId` 的 `CuaScreenshot`,图片输出回调接收同一个对象。选择文件后缀或声明图片时使用其中的 MIME 类型;格式可能是 PNG、JPEG、WebP 或 GIF。每张截图只进入一次附件处理链;`emit:false` 只抑制对象层的输出。
|
|
33
|
+
|
|
34
|
+
`tools.cua` 直接返回操作结果。截图结果保留图片 Base64,并增加供工具渲染使用的持久 `attachment` 引用;模型内容只包含坐标元数据和一张图片,不包含编码字节。截图前要求附件服务可用,并确认当前模型支持图片输入。图片接入或保存失败会拒绝调用。对象桥接保留截图字节和已校验的元数据,不重复上传或输出同一张图片。
|
|
35
|
+
|
|
36
|
+
应用授权发生在启动、观察、截图和输入之前。任务许可绑定已选择的应用实例;长期许可要求平台验证可执行文件身份。撤销会关闭受影响的 Agent 连接,因此旧对象必须重新选择目标。取消、超时或重新连接后均不重放输入。
|
|
37
|
+
|
|
38
|
+
动作返回 `dispatched:true, verified:false`;请读取新状态以验证结果。坐标操作默认使用最近返回截图中的像素;成功观察窗口后,传入 `relative: true` 可使用 0~1000 的整数比例。Host 在返回截图前解析附件归一化和当前模型的图片缩放规则,再将输入换算为原生窗口 point。窗口尺寸变化会使截图映射失效,绝对坐标遇到 `SCREENSHOT_REQUIRED` 时需要重新截图。窗口缩放后以 `WINDOW_CHANGED` 拒绝旧坐标;单纯移动窗口不改变窗口内坐标。
|
|
39
|
+
|
|
40
|
+
-----
|
|
41
|
+
|
|
42
|
+
<a id="understand-the-implementation"></a>
|
|
43
|
+
## 理解实现
|
|
44
|
+
|
|
45
|
+
<details>
|
|
46
|
+
<summary>共享执行与平台职责</summary>
|
|
47
|
+
|
|
48
|
+
提供方将准备好的 helper、连接工厂和指引传给 [installCua](src/index.ts)。[NativeClient](src/native-client.ts) 负责请求关联、字节上限、取消确认和失败处理。平台连接器负责启动和连接清理。共享执行器为每个 Agent 保留一个连接,并在销毁时等待进行中的图像写入。
|
|
49
|
+
|
|
50
|
+
[操作 schema](src/protocol.ts) 定义模型参数,并单独声明 Host 专用字段。原生实现在执行时检查目标身份、窗口几何、资源上限和操作系统访问条件。本库没有独立投影的注册表或持久状态,因此不发布 invariant 模块。
|
|
51
|
+
|
|
52
|
+
</details>
|
|
53
|
+
|
|
54
|
+
-----
|
|
55
|
+
|
|
56
|
+
<a id="further-exploration"></a>
|
|
57
|
+
## 进一步探索
|
|
58
|
+
|
|
59
|
+
- [macOS 提供方](../cua-macos/README.zh.md)
|
|
60
|
+
- [对象接口](src/types.ts)
|
|
61
|
+
|
|
62
|
+
-----
|
|
63
|
+
|
|
64
|
+
<a id="model-experience"></a>
|
|
65
|
+
## 模型体验
|
|
66
|
+
|
|
67
|
+
### 已授权的应用操作
|
|
68
|
+
|
|
69
|
+
#### 模型可见内容
|
|
70
|
+
|
|
71
|
+
平台提供方挂载共享的 `cua` 工具并提供操作指引。调用和观察使用同一套应用与窗口接口,进入正常 Session 历史。平台指引见 [macOS 提供方](../cua-macos/README.zh.md#model-experience)。
|
|
72
|
+
|
|
73
|
+
#### Token 影响
|
|
74
|
+
|
|
75
|
+
操作结果和接纳的图像增加模型输入。保留的 JavaScript 对象不会序列化进提示词。调用方重复打印会重复观察文本。
|
|
76
|
+
|
|
77
|
+
#### KV Cache 影响
|
|
78
|
+
|
|
79
|
+
结果追加到历史。保留对象不重写已有消息;更改挂载的工具或指引可能改变请求前缀。
|
|
80
|
+
|
|
81
|
+
## 已知限制与后续工作
|
|
82
|
+
|
|
83
|
+
<a id="known-limitations-and-deferred-work"></a>
|
|
84
|
+
|
|
85
|
+
- 当前原生执行使用 macOS 提供方。Windows 支持计划使用独立的提供方包和 C# helper,保留共享应用与窗口 API、授权、快照有效性和动作结果语义。实现须说明系统特有的限制,并区分交叉编译证据和 Windows 桌面验证。
|
|
86
|
+
- 持久变量不会在一组连续操作期间独占应用。其他 Agent 和用户可能改变其状态。 悬停和观察不恢复先前的鼠标位置;[连续交互](../../../.agents/notes/implemented/architecture/2026-10-13-cua-continuous-hover.zh.md)不分配跨调用所有权。
|
|
87
|
+
- 本包保留在 `experimental`,Windows 支持和平台验证完成后可迁至 `computer-use` 组。
|
|
88
|
+
|
|
89
|
+
-----
|
|
90
|
+
|
|
91
|
+
<a id="dev-note"></a>
|
|
92
|
+
### 开发备注
|
|
93
|
+
|
|
94
|
+
无。
|