@copylee/dsh-computer-use 0.8.2 → 0.8.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.md CHANGED
@@ -3,142 +3,49 @@
3
3
  [![Awesome DSH Plugin](https://awesome-dsh-plugin.com/badge.svg)](https://awesome-dsh-plugin.com)
4
4
  [![npm](https://img.shields.io/npm/v/@copylee/dsh-computer-use)](https://www.npmjs.com/package/@copylee/dsh-computer-use)
5
5
 
6
- 让 DeepSeek Harness 直接操控你的 Windows 电脑:看屏幕、点鼠标、敲键盘,打开应用、切换窗口、读写剪贴板。控制期间屏幕四周会泛起**橙色光晕**,顶部出现“**DeepSeek Harness 正在操控你的电脑**”提示条,DeepSeek Harness 自己最小化,右下角换成一张**迷你进度卡片**,两行滚动显示 AI 的回复正文和思考 / 工具调用,让你同时看清操作过程和 AI 在想什么。按 **Esc** 暂停 / 继续,点“停止”结束本轮。
7
-
8
- 仅支持 Windows。
9
-
10
- ![AI 用电脑控制打开记事本,逐行输入一首小诗](assets/demo-notepad.gif)
11
-
12
- 上图是一次真实操作的录屏(只录了被操控的记事本窗口):AI 打开记事本并逐行输入文字。下图是对话里看到的过程,以及设置页。
13
-
14
- | 对话中的操作过程 | 设置页 |
15
- |---|---|
16
- | ![对话:AI 打开计算器并用鼠标点按钮算出结果](assets/chat.png) | ![设置 → 电脑控制:运行状态、授权方式、禁止操控的应用](assets/settings.png) |
17
-
18
- ## 功能
19
-
20
- | 功能 | 说明 |
21
- |---|---|
22
- | 截图即坐标系 | 模型只用最近一张截图的像素坐标,DPI、缩放、多显示器偏移全部由插件换算,高分屏(200% 缩放)也点得准 |
23
- | 动作后自动回传截图 | 点击 / 输入 / 按键 / 滚动后,**等画面不再变化**(页面加载、动画结束,最多约 2.5 秒)再截图;`wait` 也直接带回截图,“等一下再看”只需一步,而且画面一静止就提前结束,不会死等满时长;画面与上一张截图完全相同时不再发图,只告诉模型“没有可见变化”,省 token |
24
- | 批量动作 | `computer_batch` 一次执行“点输入框 → 输入 → 回车”等多步,最后只截一张图 |
25
- | 按名称点控件 | 动作里用 `target`(控件的可见名称,如 `"保存"`、`"按钮:确定"`)代替坐标。上一张截图里还没出现的控件也能点,比如上一步才打开的菜单项、才弹出的对话框按钮;最多等 3 秒它出现。重名时不猜,直接把候选和坐标告诉模型;`ui_elements` 现在会返回 `automationId`,重名时可用 `target: "id:<AutomationId>"`(或 `"#<AutomationId>"`)明确指定 |
26
- | 等条件而不是等时间 | `wait` 加 `until`(`"window:另存为"`、`"target:保存"`):窗口或控件一出现(或一消失)就继续,超时才报错。配合 `target`,“按 Ctrl+S → 等另存为 → 填文件名 → 点保存”可以写进同一个批量调用 |
27
- | 把窗口读成文本 | `ui_elements` 加 `text: true` 直接读出文档、网页、聊天回复或日志的文字(默认取末尾 4000 字),比滚动加放大截图快,也能逐字引用;批量调用加 `finish: "text"` 可以用文字代替结尾的截图 |
28
- | 按应用授权 | 先 `request_access` 列出要操控的应用,经 DSH 原生审批后才能操作;也可改为“全部允许” |
29
- | 不会操作自己 | 永远拒绝向 DeepSeek Harness 自身窗口输入;常见密码管理器默认禁止,可再自定义禁用列表 |
30
- | 正在控制的提示 | 橙色光晕 + 胶囊提示条(显示当前动作),**不会出现在截图里**;AI 还在忙但已不再操作电脑时(约 90 秒没有电脑操作,或连续调用了 3 个其他工具)自动收起,下次操作电脑时再出现 |
31
- | 迷你进度卡片(默认) | 操控期间 DeepSeek Harness 最小化,右下角显示一张半透明小卡片:标题行有 DeepSeek 图标和“输入”“展开”“暂停”“停止”四个圆形按钮;第一行滚动显示回复正文(实时流式),第二行显示思考过程,或最近几步的小时间线(已完成的步骤打勾,如“打开 Word › 输入正文 › 另存为”)。点“展开”变成长卡片:多行回复、思考、最近 5 步时间线。点“输入”在卡片下方弹出输入框,AI 自动暂停,输入指令按 Enter 发送(与在 DSH 里插话一样,AI 下一步就会看到),Esc 取消。任务结束时卡片显示“已完成”几秒再消失(鼠标停在上面会一直保留)。卡片可拖动、跟随系统深浅色,AI 的截图里看不到它,点击也会穿透它。操控中你把 DSH 窗口打开,它会自动变成下面的半透明悬浮卡片,不会挡住 AI |
32
- | 悬浮卡片 | 操控期间 DeepSeek Harness 窗口缩成右下角置顶卡片,结束后自动恢复原尺寸、位置和最大化 / 最小化状态(也可选最小化或不动)。卡片只给你看:AI 的截图里看到的是卡片下面的内容(通过 Windows 放大镜接口截图时把卡片排除在外,不闪烁;该接口不可用时退回为截图瞬间让卡片透明约 20 毫秒),点击和滚动也直接穿透卡片,卡片不会挪位置。卡片默认 80% 不透明,可以透过它看清下面的操作过程;鼠标在卡片上停一下就变回不透明,方便阅读和点击(透明度可在设置里调) |
33
- | 暂停与停止 | 你亲手按 **Esc** 暂停(AI 停在下一步之前),再按 Esc 或点“继续”恢复,对话不会被中断;点“停止”才结束本轮。插件自己发出的 Esc 不会误触发 |
34
- | 你随时可以插手 | 你用键盘打字时 AI 自动暂停,停手 1.5 秒后继续(单按 Shift / Ctrl 等修饰键不算);你切换或打开了别的窗口,AI 下一步不会盲目执行,而是先看新截图再决定。你只是点进 DSH 卡片看对话时不算切换,AI 的按键会自动回到它正在操作的窗口。鼠标移动不会触发,避免误触 |
35
- | 文字输入 | Unicode 直接输入,不受输入法状态影响。短文字逐字打出来;长文本默认“流式”:按段落逐段粘贴(代码块不拆开),看得到一段段出现,又不会被 Typora、Obsidian、Word 的自动补全打乱。可在设置里改成逐字输入或一次粘贴。剪贴板文本统一为 CRLF,不丢换行 |
36
- | 不弄乱剪贴板 | 插件写入剪贴板的内容不进 Windows 剪贴板历史(Win+V)和云剪贴板;粘贴后按原样恢复你的剪贴板(图片、文件也保留);AI 用 `clipboard` 工具写过剪贴板的,本轮结束后自动还原(期间你自己复制了新内容则不动) |
37
- | 应用技能 | AI 对各个应用的操作笔记,每个应用一份 Markdown(`~/.dsh/computer-use-skills/`)。AI 摸索清楚一个不熟悉的应用后用 `app_skill` 自己记下来(只记操作规律,不记任务内容),以后 `open_application` 打开该应用时自动附带,不占系统提示。自带 Word、PowerPoint、Excel、Chrome、文件资源管理器、Obsidian、Typora、微信、QQ、记事本十份内置技能(含各应用的快捷键清单,PowerPoint 含原生公式和动画的做法);AI 在内置技能上追加的笔记单独保存,内置部分随插件更新;设置页“应用技能”里可以查看、修改、删除、新建,内置技能可覆盖和恢复 |
38
- | 打开应用 | `open_application` 同时搜索开始菜单和桌面快捷方式(含公共桌面),便携软件也能按名字打开。已经关到系统托盘的应用(QQ、微信等)会像人一样点托盘图标把窗口叫回来(必要时先展开“显示隐藏的图标”),不会再启动第二个实例、也不会重复登录;你明确要多开时(如微信双开)AI 会用 `new_instance` 另开一个。任务结束时 AI 会收拾现场:关掉自己打开、你不再需要的窗口,`windows tidy` 把原本最小化或在托盘里的应用重新最小化 |
39
- | 看不见图的模型 | `ui_elements` 用 Windows UI Automation 列出可点击元素和坐标,纯文本模型也能用。Chromium / Electron 会先唤醒无障碍树,同时保留浏览器标签栏、地址栏等控件;支持识别常见网页编辑器,并返回应用提供的 AutomationId、焦点能力和编辑器标记 |
40
- | 返回 DSH | 操控结束时恢复桌面窗口并切回前台。若从 DSH Web 标签开始,会返回记录的浏览器窗口并尝试选回该标签。反代或自定义域名可在插件配置中将 `harnessUrl` 设为实际 Web GUI 地址 |
41
- | UIA 动作 | 按名称或 ID 单击时,支持 UIA Invoke 的控件优先执行语义动作,输入框可通过 UIA 聚焦。缺少对应能力时重新确认控件后使用坐标。多击、右键和组合键点击仍使用坐标 |
42
- | 零原生依赖 | 截图、窗口查询和输入直接调用 DeepSeek Harness 自带的 koffi,不需要额外安装;浮层、UI Automation、剪贴板等由一个小 helper 负责,首次使用时用 Windows 自带的 .NET Framework `csc.exe` 编译(约 1 秒,之后缓存)。不需要 node-gyp,也不受 Electron ABI 影响。开启了智能应用控制(Smart App Control)时,helper 改为在系统自带的 PowerShell 里运行 |
43
-
44
- ## 安装
45
-
46
- DSH 桌面版:**插件 → 添加插件**,输入 `@copylee/dsh-computer-use`,安装后启用。
47
-
48
- 命令行(web 等其他 profile):
49
-
50
- ```bash
51
- dsh plugin --profile web add @copylee/dsh-computer-use@latest
52
- ```
53
-
54
- 要求:Windows 10 2004+ / Windows 11(自带 .NET Framework 4.8),DSH 0.2.0-rc.2 或更高。截图需要**支持图片输入的模型**(如 DeepSeek V4.1 Flash);纯文本模型会自动改用 `ui_elements`。
55
-
56
- > 如果之前装过其他 computer-use 插件或 skill(例如 `dsh-computer-use-win`、Hermes 的 computer-use skill),建议先停用,避免工具和说明互相冲突。
57
-
58
- ## 使用
59
-
60
- 直接说要做什么就行,例如:
61
-
62
- - 用 Chrome 打开 github.com
63
- - 打开记事本,写一段会议纪要并保存到桌面
64
- - 用计算器算一下 1234×5678
65
-
66
- 按应用授权模式下,模型会先请求操控对应应用,你在 DSH 里批准即可。会话权限为“完全权限”或“自动审查”(不弹审批)时,请求会被自动批准,但 DeepSeek Harness 自身和禁用列表里的应用仍然不可操作。
67
-
68
- **随时按 Esc 暂停**,再按一次继续;点提示条上的“停止”结束本轮。想临时帮一把也可以直接上手:打字时提示条显示“你正在操作,已暂停”,AI 会等你停手;切到别的窗口后 AI 会先重新看屏幕。
69
-
70
- ## Agent 工具
71
-
72
- | 工具 | 作用 |
73
- |---|---|
74
- | `computer` | 单个动作:`screenshot` `left_click` `double_click` `triple_click` `right_click` `middle_click` `mouse_move` `left_click_drag` `left_mouse_down/up` `scroll` `type` `key` `hold_key` `wait` `zoom` `cursor_position`(沿用通用 computer-use 动作命名,模型上手即会) |
75
- | `computer_batch` | 顺序执行多个动作,遇错即停,最后回传一张截图;最后一步可以是 `zoom`(回传放大区域),`finish` 可选 `screenshot` / `text` / `none` |
76
- | `app_skill` | 应用技能:`list` 列出、`read` 读取、`append` 追加、`write` 重写某个应用的操作笔记(单份上限 4000 字) |
77
- | `open_application` | 按名称(“Chrome”“记事本”“微信”)或 exe 路径打开应用,已运行则切到前台,在托盘里则恢复。HTTP(S) 网址在受支持的默认浏览器中显式新开窗口 |
78
- | `windows` | 列出窗口(含进程 exe 名)、聚焦 / 最小化 / 最大化 / 还原 / 关闭 |
79
- | `ui_elements` | 前台窗口(含已打开的菜单)的 UI Automation 元素列表,坐标已换算到截图坐标系;`text: true` 改为读出窗口的文字内容 |
80
- | `clipboard` | 读 / 写剪贴板文本 |
81
- | `switch_display` | 多显示器时切换截图所在屏幕 |
82
- | `request_access` / `list_granted_applications` | 按应用授权 |
83
-
84
- ## 设置
85
-
86
- 在 **设置 → 电脑控制** 中修改,保存后下一步操作即生效。页面上还能看到运行状态(屏幕分辨率、缩放比例和实际发给模型的截图尺寸),并可点“预览效果”看 3 秒光晕和提示条:
87
-
88
- | 选项 | 默认 | 说明 |
89
- |---|---|---|
90
- | 授权方式 | 按应用授权 | 或“全部允许” |
91
- | 光晕与提示条 | 开 | 控制时显示橙色边框和提示条 |
92
- | 提示条名称 | DeepSeek Harness | 显示为“<名称> 正在操控你的电脑” |
93
- | 操控期间 DSH 窗口 | 迷你进度卡片 | 迷你进度卡片 / 悬浮卡片 / 最小化 / 保持不变,结束后自动恢复 |
94
- | 卡片透明度 | 80% | 100%–50%;迷你卡片只让背景变透明,文字始终清晰;DSH 悬浮卡片在鼠标停留时变回不透明 |
95
- | 操作后自动截图 | 开 | 关闭可省 token,但模型需要自己截图 |
96
- | 等待稳定 | 400 ms | 动作后至少等这么久,之后画面静止即截图(最多约 2.5 秒) |
97
- | 截图最长边 / 总像素 / JPEG 质量 | 1366 / 1.15MP / 70 | 越大越清晰、越费 token |
98
- | 操作时不深度思考(Beta) | 关 | 试验功能,一般不用开。开始操作电脑后,本轮改用模型的最低思考强度,每一步快约 1 秒;下一轮恢复会话里选的思考强度。不思考时模型更容易出错、多走几步;工具参数写坏时会自动重发那一步,为此本轮的回复文字整段出现而不是逐字流出。目前只在 DeepSeek 官方模型上有效 |
99
- | 检测到你在操作时让出控制 | 开 | 键盘输入暂停、窗口被切换时重新看屏幕 |
100
- | 文字输入方式 | 流式 | 流式(长文本逐段出现)/ 逐字输入(最像打字,最慢)/ 一次粘贴(最快) |
101
- | 键盘静止多久后恢复 | 1500 ms | |
102
- | 禁止操控的应用 | 空 | 名称或 exe,如 `alipay` |
103
- | 进程内截图与输入 | 开 | 截图、显示器和窗口查询,以及浮层未显示时的输入,改由 DSH 自带的 koffi 在进程内完成,启动更快,也少一次进程间往返。出问题时可以关掉,全部交给 helper |
104
- | 强调色 | 陶土橙 | 陶土橙 / 蓝色 / 黑色,决定设置页主按钮和开关的颜色,与 copylee 的其他插件共用同一个选择。操控时的橙色光晕不随它变化 |
105
-
106
- ## 数据与隐私
107
-
108
- - 截图只作为当前会话的图片附件发给你选择的模型,插件不上传、不保存到别处。
109
- - 截图附件存放在 `~/.dsh/attachments`,随会话历史保留(DSH 会校验附件,删掉仍被会话引用的截图会让该会话无法继续,所以插件不会动它们)。会话删除后留下的“孤儿”截图会在 DSH 启动几分钟后及之后每 12 小时自动清理;设置页“截图缓存”可查看占用并立即清理。
110
- - helper 源码 `helper/CuHelper.cs` 随包发布,可自行审阅;编译产物缓存在 `%LOCALAPPDATA%\dsh-computer-use\`。进程内的部分(`src/native/`)只加载 DSH 自带的 koffi.node 和 Windows 系统 DLL。
111
- - 以管理员身份运行的窗口、UAC 弹窗、锁屏无法被控制(Windows UIPI 限制),遇到时模型会请你手动处理。
112
- - 插件注入的系统提示要求模型不代填密码、支付信息、不处理验证码,遇到时交还给你。
113
-
114
- ## 工作原理
115
-
116
- ```
117
- DSH Host (Electron, Node 模式)
118
- └─ lib/index.js 工具 / 审批 / 系统提示 / overlay 生命周期
119
- ├─ lib/native-worker.js(worker 线程,DSH 自带的 koffi)
120
- │ 截图 · 显示器 / 窗口查询 · 浮层未显示时的鼠标键盘
121
- └─ cu-helper.exe(常驻,stdin/stdout 每行一个 JSON;SAC 下在 powershell.exe 里加载)
122
- Per-Monitor-V2 DPI 感知 · GDI 截图 + 缩放 + JPEG · SendInput 鼠标键盘
123
- 窗口枚举与前置 · shell:AppsFolder 启动应用 · 剪贴板 · UI Automation
124
- 分层窗口 overlay(WDA_EXCLUDEFROMCAPTURE)· 低级键盘钩子(只认物理 Esc)
125
- ```
126
-
127
- ## 开发
128
-
129
- ```bash
130
- pnpm install
131
- pnpm typecheck
132
- pnpm test # vitest(mock helper,跨平台)
133
- pnpm build # tsc → lib/types,tsdown → lib/index.js
134
- node scripts/helper-smoke.mjs # 本机实测:编译 helper、截图、overlay
135
- node scripts/helper-smoke.mjs --notepad # 另外用临时文件测试中文输入
136
- node scripts/native-smoke.mjs --notepad # koffi 路径与 helper 对比;需在 DSH 运行时下跑或设 DSH_KOFFI_PATH
137
- pnpm pack:check
138
- ```
139
-
140
- 本地联调:DSH 桌面版“添加插件”里填本仓库目录路径即可(以 link 方式安装),改完 `pnpm build` 后重启 DSH 生效。
141
-
142
- ## 许可证
6
+ 在 DeepSeek Harness 里交代一个任务,让模型用你已经安装的 Windows 应用完成它。它可以打开应用、读界面、点击和输入,也可以在操作后检查结果。你可以在屏幕上看着它做,随时暂停或接手。
143
7
 
144
- MIT
8
+ > **可以这样说**:「打开记事本,把下面三条待办写进去,保存到桌面,最后告诉我文件名。」
9
+
10
+ ![Computer Use 按控件名填写测试报名表,暂停后继续提交,进度卡片显示完成结果](assets/demo-form.gif)
11
+
12
+ *演示中,插件按控件名填写报名表,中途暂停,继续后提交并读出确认文字。画面取自隔离 Chrome 配置中的实际操作,动作由脚本发起,卡片使用演示文案。*
13
+
14
+ ## 可以用它做什么
15
+
16
+ | 场景 | 可以交给 DSH 的任务 |
17
+ | --- | --- |
18
+ | 浏览器 | 用当前已打开的 Chrome,在同一窗口的新标签打开网址,填写表单并检查确认提示。 |
19
+ | 办公软件 | 在 Word、WPS 或记事本中输入和整理内容,按指定位置保存,再确认文件名。 |
20
+ | 桌面应用 | 打开计算器、文件资源管理器等应用,操作菜单或对话框,再读出屏幕上的结果。 |
21
+
22
+ ## 一次操作是怎么完成的
23
+
24
+ - **先看清界面。** 模型可以读截图,也可以通过 Windows UI Automation 获取按钮、输入框及其内容。例如,直接定位「按钮:提交报名」;同名控件还能用 AutomationId 区分。截图上的坐标由插件换算,适配 Windows 的缩放和多显示器。
25
+ - **连续完成几步。** 「填字段 → 提交 → 等成功提示」可以放进同一个批次。等待条件满足就继续,结束时等画面稳定再回传截图,也可以只读出窗口文字。
26
+ - **处理常用应用时参考操作笔记。** 插件内置 Word、Excel、Chrome 等应用的技能,模型打开对应应用时会收到常用快捷键和操作步骤。你可以在设置页查看或编辑这些笔记。
27
+
28
+ ## 操控期间,你仍然掌握主动权
29
+
30
+ 默认按应用授权,DSH 会在需要时请求操作目标应用。开始操控后,橙色光晕标出操控状态,迷你卡片上方显示 DSH 提供的思考内容,下方保留操作时间线。按 **Esc** 暂停或继续,点 **停止** 结束本轮。你也可以直接在卡片上输入新指令,或者亲自接手键盘。
31
+
32
+ 正文一开始输出,就回到 DSH 对话阅读。桌面版会恢复窗口并切回前台,Web GUI 会尝试回到任务开始时识别到的活动 DSH 标签。可查看[暂停时的卡片](assets/demo-paused.png)和[任务结束的画面](assets/demo-complete.png)。授权范围、截图和剪贴板的处理规则见[数据与权限](docs/privacy.md)。
33
+
34
+ ## 安装并试一次
35
+
36
+ 需要 **Windows 10 2004+ 或 Windows 11**,以及 **DeepSeek Harness 0.2.0-rc.2 或更新版本**。在 DSH 桌面版的 **插件 → 添加插件** 中输入 `@copylee/dsh-computer-use`,安装后启用。
37
+
38
+ 第一次可以试试「打开计算器,算 1234 × 5678,然后读出结果」。支持图片输入的模型可以看截图;纯文本模型可以读取应用提供的无障碍控件和窗口文字。游戏、画布和部分自绘界面可能需要截图定位。Web GUI 安装方式和常见问题见[安装与排障](docs/getting-started.md)。
39
+
40
+ ## 文档
41
+
42
+ | 文档 | 内容 |
43
+ | --- | --- |
44
+ | [安装与排障](docs/getting-started.md) | 桌面版与 Web 安装、第一次操作和常见问题 |
45
+ | [操作指南](docs/usage.md) | 示例任务、授权、暂停与接管、应用技能 |
46
+ | [设置参考](docs/settings.md) | 截图、输入方式、浮层和 Web GUI 地址 |
47
+ | [Agent 工具](docs/tools.md) | 工具清单、控件定位、批量动作与文字结果 |
48
+ | [数据与权限](docs/privacy.md) | 模型可见数据、截图缓存、剪贴板与 Windows 限制 |
49
+ | [开发与验证](docs/development.md) | 架构、构建、Windows 冒烟测试和本地联调 |
50
+
51
+ [MIT License](LICENSE)
@@ -299,6 +299,7 @@ namespace DshComputerUse
299
299
  case "launch": return Apps.Launch(r);
300
300
  case "open_url": return Apps.OpenUrl(Args.Str(r, "url", ""));
301
301
  case "browser_tab": return Uia.BrowserTab(r);
302
+ case "browser_open_tab": return Uia.OpenBrowserTab(r);
302
303
  case "act": return Uia.Act(r);
303
304
  case "clipboard_get": { var d = new Dictionary<string, object>(); d["text"] = Clip.Get(); return d; }
304
305
  case "clipboard_set": if (Args.Bool(r, "agent", false)) Clip.AgentSet(Args.Str(r, "text", "")); else Clip.Set(Args.Str(r, "text", ""), false); return null;
@@ -310,8 +311,8 @@ namespace DshComputerUse
310
311
  case "window_card": CardLayer.SetOpacity(Args.Int(r, "opacity", 100)); return Windows.Card(new IntPtr(Convert.ToInt64(r["hwnd"])), Args.Int(r, "x", 0), Args.Int(r, "y", 0), Args.Int(r, "width", 0), Args.Int(r, "height", 0));
311
312
  case "window_uncard": return Windows.Uncard(new IntPtr(Convert.ToInt64(r["hwnd"])));
312
313
  case "overlay_status": Overlay.Status(Args.Str(r, "status", "")); return null;
313
- case "pet_update": Overlay.PetUpdate(Args.Str(r, "text", ""), Args.Str(r, "thinking", ""), Args.Strs(r, "steps"), Args.Bool(r, "thinkingLatest", false)); return null;
314
- case "pet_finish": Overlay.Finish(Args.Str(r, "text", ""), Args.Int(r, "holdMs", 4000)); return null;
314
+ case "pet_update": Overlay.PetUpdate(Args.Str(r, "thinking", ""), Args.Strs(r, "steps")); return null;
315
+ case "pet_finish": Overlay.Finish(Args.Int(r, "holdMs", 4000)); return null;
315
316
  case "overlay_hide": Overlay.Hide(); return null;
316
317
  default: throw new Exception("unknown command: " + cmd);
317
318
  }
@@ -1841,6 +1842,85 @@ namespace DshComputerUse
1841
1842
  return false;
1842
1843
  }
1843
1844
 
1845
+ static bool BrowserContentFocused()
1846
+ {
1847
+ for (var el = AutomationElement.FocusedElement; el != null; el = TreeWalker.ControlViewWalker.GetParent(el))
1848
+ {
1849
+ if (el.Current.ControlType == ControlType.Document) return true;
1850
+ if (el.Current.ControlType == ControlType.Window) return false;
1851
+ }
1852
+ return false;
1853
+ }
1854
+
1855
+ public static object OpenBrowserTab(Dictionary<string, object> r)
1856
+ {
1857
+ var hwnd = new IntPtr(Convert.ToInt64(r["hwnd"]));
1858
+ uint pid = Convert.ToUInt32(r["pid"]);
1859
+ string expected = Args.Str(r, "tab", "");
1860
+ Uri url;
1861
+ if (!Uri.TryCreate(Args.Str(r, "url", ""), UriKind.Absolute, out url) || (url.Scheme != "http" && url.Scheme != "https"))
1862
+ throw new Exception("Expected an HTTP(S) URL");
1863
+ Func<bool> current = delegate { return SameWindow(hwnd, pid) && Native.GetForegroundWindow() == hwnd; };
1864
+ Func<Dictionary<string, object>> read = delegate { return BrowserTab(r) as Dictionary<string, object>; };
1865
+ var initial = new Dictionary<string, object>(r) { { "listTabs", true } };
1866
+ var before = current() ? BrowserTab(initial) as Dictionary<string, object> : null;
1867
+ object tabIds;
1868
+ if (expected.Length == 0 || before == null || Args.Str(before, "tab", "") != expected || !current())
1869
+ throw new Exception("The browser window or active tab changed before opening a new tab");
1870
+ if (!before.TryGetValue("tabs", out tabIds) || !(tabIds is List<string>))
1871
+ throw new Exception("Could not verify the browser's existing tabs");
1872
+ var existing = new HashSet<string>((List<string>)tabIds);
1873
+ if (!existing.Contains(expected)) throw new Exception("The active browser tab could not be verified");
1874
+
1875
+ Input.Keys(new Dictionary<string, object> { { "combos", new[] { new[] { 0x11, 0x54 } } } });
1876
+ var clock = Stopwatch.StartNew();
1877
+ string created = "";
1878
+ while (clock.ElapsedMilliseconds < 2400 && current())
1879
+ {
1880
+ var fresh = read();
1881
+ if (fresh != null && !existing.Contains(Args.Str(fresh, "tab", ""))
1882
+ && Args.Str(fresh, "url", "unavailable") == "")
1883
+ {
1884
+ created = Args.Str(fresh, "tab", "");
1885
+ if (created.Length > 0) break;
1886
+ }
1887
+ Thread.Sleep(65);
1888
+ }
1889
+ if (created.Length == 0 || !current())
1890
+ throw new Exception("Could not confirm a new blank tab in the original browser window");
1891
+ Input.Keys(new Dictionary<string, object> { { "combos", new[] { new[] { 0x11, 0x4C } } } });
1892
+ clock.Restart();
1893
+ bool addressReady = false;
1894
+ while (clock.ElapsedMilliseconds < 1200 && current())
1895
+ {
1896
+ var blank = read();
1897
+ if (blank != null)
1898
+ {
1899
+ if (Args.Str(blank, "tab", "") != created || Args.Str(blank, "url", "unavailable") != "") break;
1900
+ if (Args.Bool(blank, "addressFocused", false)) { addressReady = true; break; }
1901
+ }
1902
+ Thread.Sleep(65);
1903
+ }
1904
+ if (!addressReady || !current()) throw new Exception("Could not verify focus in the new tab's address bar");
1905
+ Input.Paste(url.AbsoluteUri, true, 120);
1906
+ clock.Restart();
1907
+ while (clock.ElapsedMilliseconds < 1200 && current())
1908
+ {
1909
+ var address = read();
1910
+ if (address != null)
1911
+ {
1912
+ if (Args.Str(address, "tab", "") != created || !Args.Bool(address, "addressFocused", false)) break;
1913
+ if (Args.Str(address, "url", "") == url.AbsoluteUri && current())
1914
+ {
1915
+ Input.Keys(new Dictionary<string, object> { { "combos", new[] { new[] { 0x0D } } } });
1916
+ return new Dictionary<string, object> { { "tab", created } };
1917
+ }
1918
+ }
1919
+ Thread.Sleep(65);
1920
+ }
1921
+ throw new Exception("Could not verify the new tab's address before navigation");
1922
+ }
1923
+
1844
1924
  public static object BrowserTab(Dictionary<string, object> r)
1845
1925
  {
1846
1926
  IntPtr hwnd = new IntPtr(Convert.ToInt64(r["hwnd"]));
@@ -1858,9 +1938,10 @@ namespace DshComputerUse
1858
1938
  new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Edit),
1859
1939
  new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.TabItem)));
1860
1940
  var state = new Dictionary<string, object>();
1941
+ var tabs = Args.Bool(r, "listTabs", false) ? new List<string>() : null;
1861
1942
  foreach (AutomationElement el in controls)
1862
1943
  {
1863
- if (el.Current.IsOffscreen) continue;
1944
+ if (el.Current.IsOffscreen && (tabs == null || el.Current.ControlType != ControlType.TabItem)) continue;
1864
1945
  object pattern;
1865
1946
  if (el.Current.ControlType == ControlType.Edit)
1866
1947
  {
@@ -1868,12 +1949,16 @@ namespace DshComputerUse
1868
1949
  string name = el.Current.Name;
1869
1950
  if (id != "view_1012" && id != "urlbar-input" && name != "Address and search bar" && name != "地址和搜索栏") continue;
1870
1951
  if (BrowserChrome(el) && el.TryGetCurrentPattern(ValuePattern.Pattern, out pattern))
1952
+ {
1871
1953
  state["url"] = ((ValuePattern)pattern).Current.Value;
1954
+ state["addressFocused"] = el.Current.HasKeyboardFocus;
1955
+ }
1872
1956
  }
1873
1957
  else if (el.TryGetCurrentPattern(SelectionItemPattern.Pattern, out pattern) && BrowserChrome(el))
1874
1958
  {
1875
1959
  var tab = (SelectionItemPattern)pattern;
1876
1960
  string id = String.Join(",", el.GetRuntimeId());
1961
+ if (tabs != null) tabs.Add(id);
1877
1962
  if (select.Length > 0 && id == select)
1878
1963
  {
1879
1964
  if (clock.ElapsedMilliseconds < 1200 && SameWindow(hwnd, pid) && Native.GetForegroundWindow() == hwnd)
@@ -1886,6 +1971,17 @@ namespace DshComputerUse
1886
1971
  if (tab.Current.IsSelected) state["tab"] = id;
1887
1972
  }
1888
1973
  }
1974
+ if (tabs != null) state["tabs"] = tabs;
1975
+ if (Args.Bool(r, "details", false) && Native.GetForegroundWindow() == hwnd)
1976
+ {
1977
+ var render = ChromiumRoot(hwnd);
1978
+ Native.RECT rect;
1979
+ if (render != hwnd && Native.GetWindowRect(render, out rect) && rect.Right > rect.Left && rect.Bottom > rect.Top)
1980
+ state["content"] = new Dictionary<string, object> {
1981
+ { "x", rect.Left }, { "y", rect.Top }, { "width", rect.Right - rect.Left }, { "height", rect.Bottom - rect.Top },
1982
+ };
1983
+ state["contentFocused"] = BrowserContentFocused();
1984
+ }
1889
1985
  result = state;
1890
1986
  }
1891
1987
  catch (Exception) { }
@@ -2314,9 +2410,8 @@ namespace DshComputerUse
2314
2410
  static bool petMode;
2315
2411
  static LayeredForm pet;
2316
2412
  public static volatile IntPtr PetHwnd = IntPtr.Zero;
2317
- static string petText = "", petThinking = "";
2413
+ static string petThinking = "";
2318
2414
  static List<string> petSteps = new List<string>();
2319
- static bool petThinkingLatest;
2320
2415
  /** Bottom-right corner of the card body; the card grows upward when expanded. */
2321
2416
  static Point petAnchor = Point.Empty;
2322
2417
  static int petShadow;
@@ -2393,7 +2488,8 @@ namespace DshComputerUse
2393
2488
  if (visible && !petFinished) { RenderPill(); return; }
2394
2489
  if (visible) HideCore(); // the previous run's "done" card is still up
2395
2490
  petMode = Args.Bool(r, "pet", false);
2396
- petText = Args.Str(r, "text", ""); petThinking = ""; petSteps = new List<string>(); petThinkingLatest = false;
2491
+ petThinking = Args.Str(r, "thinking", "");
2492
+ petSteps = new List<string>();
2397
2493
  if (status.Length > 0) petSteps.Add(status);
2398
2494
  pillAtBottom = false;
2399
2495
  paused = false;
@@ -2461,23 +2557,21 @@ namespace DshComputerUse
2461
2557
  Ui(delegate { status = newStatus; RenderPill(); });
2462
2558
  }
2463
2559
 
2464
- /** New agent output for the progress card: reply text, thinking, and the recent steps (oldest first). */
2465
- public static void PetUpdate(string text, string thinking, List<string> steps, bool thinkingLatest)
2560
+ /** Latest host-provided reasoning and recent operations, oldest first. */
2561
+ public static void PetUpdate(string thinking, List<string> steps)
2466
2562
  {
2467
2563
  if (thread == null || !visible || !petMode || petFinished) return;
2468
2564
  invoker.BeginInvoke((MethodInvoker)delegate
2469
2565
  {
2470
2566
  if (petFinished) return;
2471
- petText = text;
2472
2567
  petThinking = thinking;
2473
2568
  if (steps.Count > 0) petSteps = steps;
2474
- petThinkingLatest = thinkingLatest;
2475
2569
  RenderPill();
2476
2570
  });
2477
2571
  }
2478
2572
 
2479
2573
  /** The run ended: the card says so for a moment (longer while the pointer rests on it), then everything hides. */
2480
- public static void Finish(string text, int holdMs)
2574
+ public static void Finish(int holdMs)
2481
2575
  {
2482
2576
  if (thread == null) return;
2483
2577
  Ui(delegate
@@ -2488,7 +2582,6 @@ namespace DshComputerUse
2488
2582
  glows.Clear();
2489
2583
  RemoveHook();
2490
2584
  paused = false;
2491
- if (text.Length > 0) petText = text;
2492
2585
  petFinished = true;
2493
2586
  finishedAt = DateTime.UtcNow;
2494
2587
  finishHoldMs = holdMs;
@@ -2791,6 +2884,7 @@ namespace DshComputerUse
2791
2884
  petShadow = shadow;
2792
2885
  float bodyW = 420 * s, pad = 16 * s;
2793
2886
  float headH = 44 * s, replyH = 26 * s;
2887
+ string progress = petFinished ? "已交还电脑控制" : petThinking.Length > 0 ? "思考 · " + petThinking : "正在操作,等待下一步…";
2794
2888
  if (petExpanded)
2795
2889
  {
2796
2890
  // Grow with the reply, up to about eight lines.
@@ -2798,14 +2892,12 @@ namespace DshComputerUse
2798
2892
  using (var pg = Graphics.FromImage(probe))
2799
2893
  using (var pf = new Font("Microsoft YaHei UI", 10.5f * 1.333f * scale, FontStyle.Regular, GraphicsUnit.Pixel))
2800
2894
  {
2801
- string t = petText.Length > 0 ? petText : "正在操作…";
2802
- float need = pg.MeasureString(t, pf, new SizeF(420 * scale - 32 * scale, 100000), new StringFormat(StringFormat.GenericTypographic)).Height + 6 * scale;
2895
+ float need = pg.MeasureString(progress, pf, new SizeF(420 * scale - 32 * scale, 100000), new StringFormat(StringFormat.GenericTypographic)).Height + 6 * scale;
2803
2896
  replyH = Math.Max(26 * scale, Math.Min(172 * scale, need));
2804
2897
  }
2805
2898
  }
2806
2899
  int stepRows = petExpanded ? Math.Min(5, Math.Max(1, petSteps.Count)) : 0;
2807
- bool thinkingRow = petExpanded && petThinking.Length > 0 && !petFinished;
2808
- float listH = petExpanded ? 8 * s + (thinkingRow ? 24 * s : 0) + stepRows * 22 * s : 24 * s;
2900
+ float listH = petExpanded ? 8 * s + stepRows * 22 * s : 24 * s;
2809
2901
  float inputH = input != null ? 46 * s : 0;
2810
2902
  float bodyH = headH + replyH + listH + inputH + 12 * s;
2811
2903
  int W = (int)Math.Ceiling(bodyW) + 2 * shadow, H = (int)Math.Ceiling(bodyH) + 2 * shadow;
@@ -2885,17 +2977,18 @@ namespace DshComputerUse
2885
2977
  using (var b = new SolidBrush(paused ? Accent : muted)) g.DrawString(st, fState, b, tx, hy + (hh - stSize.Height) / 2f, fmt);
2886
2978
  }
2887
2979
 
2888
- // The reply as it streams: one scrolling line, or the latest lines when expanded.
2980
+ // Reasoning and operations use separate rows throughout.
2889
2981
  float lineW = bodyW - 2 * pad;
2890
2982
  float ry = body.Y + headH;
2891
- string text = petText.Length > 0 ? petText : (petFinished ? "" : "正在操作…");
2892
- using (var b = new SolidBrush(petText.Length > 0 ? ink : muted))
2983
+ using (var b = new SolidBrush(petThinking.Length > 0 && !petFinished ? ink : muted))
2893
2984
  {
2894
2985
  if (petExpanded)
2895
- g.DrawString(TailWrapped(g, text, fText, lineW, replyH, wrap), fText, b, new RectangleF(body.X + pad, ry, lineW, replyH), wrap);
2986
+ g.DrawString(TailWrapped(g, progress, fText, lineW, replyH, wrap), fText, b, new RectangleF(body.X + pad, ry, lineW, replyH), wrap);
2896
2987
  else
2897
2988
  {
2898
- string shown = Tail(g, text, fText, lineW, fmt);
2989
+ string shown = petThinking.Length > 0 && !petFinished
2990
+ ? "思考 · " + Tail(g, petThinking, fText, lineW - g.MeasureString("思考 · ", fText, 100000, fmt).Width, fmt)
2991
+ : Tail(g, progress, fText, lineW, fmt);
2899
2992
  SizeF size = g.MeasureString(shown.Length > 0 ? shown : " ", fText, 100000, fmt);
2900
2993
  g.DrawString(shown, fText, b, body.X + pad, ry + (replyH - size.Height) / 2f, fmt);
2901
2994
  }
@@ -2908,13 +3001,6 @@ namespace DshComputerUse
2908
3001
  ly += 4 * s;
2909
3002
  using (var pen = new Pen(edge, Math.Max(1f, s))) g.DrawLine(pen, body.X + pad, ly, body.Right - pad, ly);
2910
3003
  ly += 4 * s;
2911
- if (thinkingRow)
2912
- {
2913
- float prefixW = g.MeasureString("思考:", fAct, 100000, fmt).Width;
2914
- string th = Tail(g, petThinking, fAct, lineW - prefixW, fmt);
2915
- using (var b = new SolidBrush(muted)) { g.DrawString("思考:", fAct, b, body.X + pad, ly + 3 * s, fmt); g.DrawString(th, fAct, b, body.X + pad + prefixW, ly + 3 * s, fmt); }
2916
- ly += 24 * s;
2917
- }
2918
3004
  int first = Math.Max(0, petSteps.Count - stepRows);
2919
3005
  for (int i = first; i < petSteps.Count; i++)
2920
3006
  {
@@ -2930,8 +3016,7 @@ namespace DshComputerUse
2930
3016
  else
2931
3017
  {
2932
3018
  string act;
2933
- if (petFinished) act = petSteps.Count > 0 ? "共 " + petSteps.Count + " 步 · " + petSteps[petSteps.Count - 1] : "";
2934
- else if (petThinkingLatest && petThinking.Length > 0) act = "思考:" + Tail(g, petThinking, fAct, lineW - 14 * s - g.MeasureString("思考:", fAct, 100000, fmt).Width, fmt);
3019
+ if (petFinished) act = petSteps.Count > 0 ? "最后操作 · " + petSteps[petSteps.Count - 1] : "";
2935
3020
  else
2936
3021
  {
2937
3022
  var parts = new List<string>();
package/lib/client.js CHANGED
@@ -1182,7 +1182,7 @@ window.__ModuleLoader__.load({
1182
1182
  }), h("span", { style: {
1183
1183
  ...S.hint,
1184
1184
  fontWeight: 400
1185
- } }, draft.hostWindow === "pet" ? "DSH 最小化,右下角显示迷你卡片:一行滚动显示回复正文,一行显示思考和工具调用;可拖动,有暂停 / 停止按钮。结束后自动恢复。" : "操控结束后自动恢复原尺寸和位置。")), h("div", { style: S.label }, "悬浮卡片透明度", h(Select, {
1185
+ } }, draft.hostWindow === "pet" ? "卡片上方显示思考,下方显示操作。可拖动、暂停或停止。正文开始输出时,回到 DSH 对话。" : "操控结束或正文开始输出时,恢复 DSH 窗口。")), h("div", { style: S.label }, "悬浮卡片透明度", h(Select, {
1186
1186
  label: "悬浮卡片透明度",
1187
1187
  disabled: disabled || draft.hostWindow !== "card" && draft.hostWindow !== "pet",
1188
1188
  value: String(draft.cardOpacity),
package/lib/index.js CHANGED
@@ -216,12 +216,44 @@ function isHarnessAddress(address, harnessUrl) {
216
216
  const a = new URL(actual), b = new URL(expected);
217
217
  return loopback.has(a.hostname) && loopback.has(b.hostname) && a.protocol === b.protocol && a.port === b.port;
218
218
  }
219
- async function readBrowserTab(helper, win) {
219
+ async function readBrowserTab(helper, win, details = false) {
220
220
  return await helper.call("browser_tab", {
221
221
  hwnd: win.hwnd,
222
- pid: win.pid
222
+ pid: win.pid,
223
+ ...details ? { details } : {}
223
224
  }, 2500).catch(() => null) ?? void 0;
224
225
  }
226
+ function safeSharedBrowserKeys(combos) {
227
+ return combos.every((combo) => {
228
+ const key = combo.at(-1);
229
+ if (key === void 0) return false;
230
+ const modifiers = combo.slice(0, -1);
231
+ if (modifiers.includes(17)) return modifiers.length === 1 && [
232
+ 65,
233
+ 67,
234
+ 86,
235
+ 88,
236
+ 89,
237
+ 90
238
+ ].includes(key);
239
+ return modifiers.every((mod) => mod === 16) && ([
240
+ 8,
241
+ 9,
242
+ 13,
243
+ 27,
244
+ 32,
245
+ 33,
246
+ 34,
247
+ 35,
248
+ 36,
249
+ 37,
250
+ 38,
251
+ 39,
252
+ 40,
253
+ 46
254
+ ].includes(key) || key >= 48 && key <= 90);
255
+ });
256
+ }
225
257
  //#endregion
226
258
  //#region lib/types/coords.js
227
259
  /**
@@ -975,22 +1007,29 @@ var Computer = class Computer {
975
1007
  const reason = this.access.denial(call.session, win, s.accessMode, s.blockedApps, verb);
976
1008
  if (reason) throw new Error(reason);
977
1009
  if (win && s.harnessUrl && isBrowser(win)) {
978
- const tab = await readBrowserTab(this.helper, win);
979
- if (isHarnessAddress(tab?.url, s.harnessUrl) || this.overlay.isRememberedWebWindow(win)) throw new Error("The DeepSeek Harness Web tab is protected. Use open_application with a URL to open a separate browser window.");
980
- if (typeof tab?.url !== "string" || !tab.tab) throw new Error("Could not verify the active browser tab. Use open_application with a URL or switch to a browser window with a visible address bar.");
1010
+ const shared = this.overlay.isRememberedWebWindow(win);
1011
+ const tab = await readBrowserTab(this.helper, win, shared);
1012
+ if (isHarnessAddress(tab?.url, s.harnessUrl) || shared && (!tab?.tab || !this.overlay.isWorkTab(tab.tab))) throw new Error("The DeepSeek Harness Web tab is protected. Use open_application with the target URL to open a work tab in the current browser.");
1013
+ if (typeof tab?.url !== "string" || !tab.tab) throw new Error("Could not verify the active browser tab. Use open_application with the target URL or switch to a browser window with a visible address bar.");
1014
+ if (shared) return tab;
981
1015
  }
982
1016
  }
1017
+ checkWebContent(tab, point) {
1018
+ if (tab && (!tab.content || !contains$1(tab.content, point))) throw new Error("Only the work tab’s page content can be operated in the window containing DeepSeek Harness.");
1019
+ }
983
1020
  async checkPointer(call, point, verb) {
984
1021
  const target = point ?? await this.cursor();
985
- await this.assertAllowed(call, await this.windowAt(target), verb);
1022
+ this.checkWebContent(await this.assertAllowed(call, await this.windowAt(target), verb), target);
986
1023
  }
987
1024
  async checkKeyboard(call, verb) {
988
1025
  const window = await this.foreground();
989
- await this.assertAllowed(call, window, verb);
1026
+ const tab = await this.assertAllowed(call, window, verb);
1027
+ if (tab && !tab.contentFocused) throw new Error("Focus a control in the work tab’s page before sending keyboard input.");
990
1028
  return window;
991
1029
  }
992
1030
  async sendKeys(call, combos, holdMs) {
993
1031
  const window = await this.checkKeyboard(call, "send keys to");
1032
+ if (window && this.overlay.isRememberedWebWindow(window) && (holdMs !== void 0 || !safeSharedBrowserKeys(combos))) throw new Error("Browser and window shortcuts are protected in the window containing DeepSeek Harness.");
994
1033
  const args = holdMs === void 0 ? {} : { holdMs };
995
1034
  if (!this.settings().harnessUrl || !window || !isBrowser(window) || combos.length < 2) {
996
1035
  await this.helper.call("keys", {
@@ -1003,6 +1042,7 @@ var Computer = class Computer {
1003
1042
  if (index > 0) {
1004
1043
  await setTimeout$1(100, void 0, { signal: call.signal });
1005
1044
  await this.checkNamed(call, window);
1045
+ if (this.overlay.isRememberedWebWindow(window)) await this.checkKeyboard(call, "send keys to");
1006
1046
  }
1007
1047
  await this.helper.call("keys", {
1008
1048
  combos: [combo],
@@ -1121,10 +1161,10 @@ var Computer = class Computer {
1121
1161
  async checkNamed(call, win) {
1122
1162
  const current = await this.foreground();
1123
1163
  if (current?.hwnd !== win.hwnd || current.pid !== win.pid) throw new Error("The named target window changed. Look again before acting.");
1124
- await this.assertAllowed(call, current, "act on");
1164
+ return this.assertAllowed(call, current, "act on");
1125
1165
  }
1126
1166
  async checkNamedPoint(call, point, window, element) {
1127
- await this.checkNamed(call, window);
1167
+ this.checkWebContent(await this.checkNamed(call, window), point);
1128
1168
  const hit = await this.windowAt(point);
1129
1169
  if (!hit || hit.pid !== window.pid || hit.hwnd !== (element.windowHwnd ?? window.hwnd)) throw new Error("Another window covers the named target. Look again before acting.");
1130
1170
  if (hit.hwnd !== window.hwnd && !isBrowser(window)) await this.assertAllowed(call, hit, "click");
@@ -1161,15 +1201,32 @@ var Computer = class Computer {
1161
1201
  const until = (input.until ?? "").trim();
1162
1202
  const split = until.search(/[::]/);
1163
1203
  const prefix = split > 0 ? until.slice(0, split).trim().toLowerCase() : "";
1164
- const kind = prefix === "window" ? "window" : "target";
1165
- const subject = (prefix === "window" || prefix === "target" ? until.slice(split + 1) : until).trim();
1166
- if (subject === "") throw new Error("wait until needs \"window:<title or exe>\" or \"target:<control name>\".");
1204
+ const kind = prefix === "window" || prefix === "text" ? prefix : "target";
1205
+ const subject = (prefix === "window" || prefix === "target" || prefix === "text" ? until.slice(split + 1) : until).trim();
1206
+ if (subject === "") throw new Error("wait until needs \"window:<title or exe>\", \"target:<control name>\", or \"text:<window text>\".");
1167
1207
  const gone = input.gone === true;
1168
1208
  const timeout = Math.min(60, Math.max(.2, Number(input.duration ?? 10) || 10)) * 1e3;
1169
1209
  const needle = subject.toLowerCase();
1170
1210
  let suggestions = [];
1171
1211
  let firstSeen;
1212
+ const started = Date.now();
1213
+ const textWindow = kind === "text" ? await this.foreground() : void 0;
1214
+ if (kind === "text" && !textWindow) throw new Error("No foreground window to observe for text.");
1215
+ const textTab = textWindow && isBrowser(textWindow) ? (await readBrowserTab(this.helper, textWindow))?.tab : void 0;
1172
1216
  const present = async () => {
1217
+ if (textWindow) {
1218
+ const limit = Math.max(100, Math.min(1500, timeout - (Date.now() - started)));
1219
+ if (textTab && (await readBrowserTab(this.helper, textWindow))?.tab !== textTab) return void 0;
1220
+ const result = await this.helper.call("text", {
1221
+ hwnd: textWindow.hwnd,
1222
+ timeoutMs: limit,
1223
+ tail: 2e4
1224
+ }, limit + 1500).catch(() => void 0);
1225
+ if (!result || result.hwnd !== textWindow.hwnd || result.pid !== textWindow.pid || result.source === "none") return void 0;
1226
+ if (textTab && (await readBrowserTab(this.helper, textWindow))?.tab !== textTab) return void 0;
1227
+ const found = result.text.toLowerCase().includes(needle);
1228
+ return !found && result.truncated && gone ? void 0 : found;
1229
+ }
1173
1230
  if (kind === "window") {
1174
1231
  const matches = (win) => win.title.toLowerCase().includes(needle) || win.exe.toLowerCase().includes(needle) || appMatches(subject, win);
1175
1232
  const fg = await this.foreground().catch(() => void 0);
@@ -1186,17 +1243,17 @@ var Computer = class Computer {
1186
1243
  if (match.kind === "missing") suggestions = match.suggestions;
1187
1244
  return match.kind !== "missing";
1188
1245
  };
1189
- const started = Date.now();
1190
1246
  for (;;) {
1191
1247
  if (signal.aborted) throw new Error("Cancelled.");
1192
- if (await present() !== gone) {
1193
- const text = `${kind === "window" ? "Window" : "Control"} "${subject}" ${gone ? "is gone" : "is there"} after ${((Date.now() - started) / 1e3).toFixed(1)}s.`;
1248
+ const found = await present();
1249
+ if (found !== void 0 && found !== gone) {
1250
+ const text = `${kind === "window" ? "Window" : kind === "text" ? "Text" : "Control"} "${subject}" ${gone ? "is gone" : "is there"} after ${((Date.now() - started) / 1e3).toFixed(1)}s.`;
1194
1251
  await this.settle(signal);
1195
1252
  return text;
1196
1253
  }
1197
1254
  if (Date.now() - started >= timeout) {
1198
1255
  const near = !gone && kind === "target" && suggestions.length ? ` Controls there now: ${suggestions.map((name) => `"${name.slice(0, 40)}"`).join(", ")}.` : "";
1199
- throw new Error(`Timed out after ${Math.round(timeout / 1e3)}s waiting for ${kind === "window" ? "window" : "control"} "${subject}" to ${gone ? "disappear" : "appear"}.${near}`);
1256
+ throw new Error(`Timed out after ${Math.round(timeout / 1e3)}s waiting for ${kind === "window" ? "window" : kind === "text" ? "text" : "control"} "${subject}" to ${gone ? "disappear" : "appear"}.${near}`);
1200
1257
  }
1201
1258
  await setTimeout$1(POLL_MS, void 0, { signal });
1202
1259
  }
@@ -1290,6 +1347,7 @@ var Computer = class Computer {
1290
1347
  const from = await this.point(input.start_coordinate, "start_coordinate");
1291
1348
  const to = await this.point(input.coordinate);
1292
1349
  await this.checkPointer(call, from, "drag in");
1350
+ if (this.settings().harnessUrl) await this.checkPointer(call, to, "drag to");
1293
1351
  await this.helper.call("drag", {
1294
1352
  x1: from.x,
1295
1353
  y1: from.y,
@@ -1302,7 +1360,11 @@ var Computer = class Computer {
1302
1360
  case "left_mouse_down":
1303
1361
  case "left_mouse_up": {
1304
1362
  const p = input.coordinate ? await this.point(input.coordinate) : void 0;
1305
- if (action === "left_mouse_down") await this.checkPointer(call, p, "press the mouse in");
1363
+ if (action === "left_mouse_down") {
1364
+ const window = await this.windowAt(p ?? await this.cursor());
1365
+ if (window && this.overlay.isRememberedWebWindow(window)) throw new Error("Use a single drag action within the work page instead of holding the mouse button in this browser window.");
1366
+ await this.assertAllowed(call, window, "press the mouse in");
1367
+ }
1306
1368
  await this.helper.call("button", {
1307
1369
  ...p ?? {},
1308
1370
  button: "left",
@@ -1413,6 +1475,7 @@ var Computer = class Computer {
1413
1475
  const now = await this.foreground().catch(() => void 0);
1414
1476
  if (target && now && now.hwnd !== target.hwnd) throw new Error(`Stopped after ${done} of ${items.join("").length} characters: the user paused and ${now.exe} is now in front. Check the screen and continue from where the text stops.`);
1415
1477
  }
1478
+ if (index > 0 && target && this.overlay.isRememberedWebWindow(target)) await this.checkKeyboard(call, "type into");
1416
1479
  await step(item, index);
1417
1480
  done += item.length;
1418
1481
  }
@@ -1979,22 +2042,21 @@ var OverlayController = class {
1979
2042
  hostWindows = [];
1980
2043
  returnTo;
1981
2044
  ending;
2045
+ workTab;
1982
2046
  starting;
1983
2047
  stopping = false;
1984
- /** Progress card lines: the reply as it streams, and what the agent is doing. */
2048
+ /** Progress card lines: host-provided reasoning and recent operations. */
1985
2049
  streamAgent;
1986
- text = "";
1987
2050
  thinking = "";
1988
2051
  /** Recent steps (tool actions), oldest first. */
1989
2052
  steps = [];
1990
- /** Whether the agent is thinking now (newer than the last step). */
1991
- thinkingLatest = false;
1992
- freshAttempt = true;
2053
+ resume;
1993
2054
  pushTimer;
1994
2055
  /** An instruction the user typed into the progress card. */
1995
2056
  onMessage;
1996
2057
  /** Called when control starts (before the first action), e.g. to remember the window layout. */
1997
2058
  onStart;
2059
+ onRelease;
1998
2060
  /** Opacity the card was last given, to apply setting changes while it floats. */
1999
2061
  cardOpacity = 100;
2000
2062
  /** Paused by Esc or the pill; actions wait until resumed. */
@@ -2076,16 +2138,29 @@ var OverlayController = class {
2076
2138
  }
2077
2139
  async start(agent, status, settings) {
2078
2140
  await this.rememberHost(settings.harnessUrl).catch((error) => this.log(`remember host: ${String(error)}`));
2141
+ const resume = this.resume;
2142
+ this.resume = void 0;
2143
+ const host = this.returnTo?.window;
2144
+ const foreground = resume && await this.helper.call("foreground").catch(() => null);
2079
2145
  await this.onStart?.().catch((error) => this.log(`overlay start: ${String(error)}`));
2080
2146
  await this.shrinkHost(settings.hostWindow);
2147
+ if (resume && resume.agent === agent && host?.hwnd === resume.host.hwnd && host.pid === resume.host.pid && foreground?.hwnd === host.hwnd && foreground.pid === host.pid) {
2148
+ const { hwnd, pid } = resume.target;
2149
+ if ((await this.helper.call("focus", {
2150
+ hwnd,
2151
+ pid
2152
+ }, 3e3).catch(() => void 0))?.focused && resume.tab) {
2153
+ if ((await this.helper.call("browser_tab", {
2154
+ hwnd,
2155
+ pid,
2156
+ select: resume.tab
2157
+ }, 2500).catch(() => void 0))?.selected) this.rememberWorkTab(resume.target, resume.tab);
2158
+ }
2159
+ }
2081
2160
  const pet = settings.hostWindow === "pet";
2082
2161
  if (settings.overlay || pet) {
2083
- if (this.streamAgent !== agent) {
2084
- this.text = "";
2085
- this.thinking = "";
2086
- }
2162
+ if (this.streamAgent !== agent) this.thinking = "";
2087
2163
  this.steps = status ? [status] : [];
2088
- this.thinkingLatest = false;
2089
2164
  await this.helper.call("overlay_show", {
2090
2165
  label: pet ? `${settings.overlayLabel || "DeepSeek Harness"} 正在操控` : `${settings.overlayLabel || "DeepSeek Harness"} 正在操控你的电脑`,
2091
2166
  status,
@@ -2095,7 +2170,7 @@ var OverlayController = class {
2095
2170
  glow: settings.overlay,
2096
2171
  pet,
2097
2172
  petOpacity: settings.cardOpacity,
2098
- text: this.text
2173
+ thinking: this.thinking
2099
2174
  }).catch((error) => this.log(`overlay: ${String(error)}`));
2100
2175
  }
2101
2176
  }
@@ -2114,35 +2189,30 @@ var OverlayController = class {
2114
2189
  const line = plainLine(text).trim();
2115
2190
  if (line === "" || this.steps.at(-1) === line) return;
2116
2191
  this.steps = [...this.steps, line].slice(-8);
2117
- this.thinkingLatest = false;
2118
2192
  this.schedulePush();
2119
2193
  }
2120
2194
  /** Live model output (DSH agent/assistant-stream) for the progress card. */
2121
2195
  stream(agent, frame) {
2196
+ if (this.visible && agent !== this.agent) return;
2122
2197
  if (agent !== this.streamAgent) {
2123
2198
  this.streamAgent = agent;
2124
- this.text = "";
2125
2199
  this.thinking = "";
2126
2200
  this.steps = [];
2127
2201
  }
2128
2202
  if (frame.type === "start") {
2129
- this.freshAttempt = true;
2130
2203
  this.thinking = "";
2204
+ this.schedulePush();
2131
2205
  return;
2132
2206
  }
2133
2207
  if (this.visible && agent === this.agent) this.armIdle();
2134
2208
  const chunk = frame.type === "chunk" ? frame.chunk : void 0;
2135
2209
  if (!chunk) return;
2136
- if (chunk.type === "text-delta" && chunk.text) {
2137
- if (this.freshAttempt) {
2138
- this.text = "";
2139
- this.freshAttempt = false;
2140
- }
2141
- this.text = plainLine(this.text + chunk.text).slice(-2e3);
2142
- } else if (chunk.type === "reasoning-delta" && chunk.text) {
2143
- this.thinking = plainLine(this.thinking + chunk.text).slice(-300);
2144
- this.thinkingLatest = true;
2145
- } else return;
2210
+ if (chunk.type === "text-delta" && chunk.text?.trim()) {
2211
+ if (this.visible && this.agent && agent === this.agent && !this.paused && !this.stopping) this.end(this.agent, true).catch((error) => this.log(`reply handoff: ${String(error)}`));
2212
+ return;
2213
+ }
2214
+ if (chunk.type !== "reasoning-delta" || !chunk.text) return;
2215
+ this.thinking = plainLine(this.thinking + chunk.text).slice(-300);
2146
2216
  this.schedulePush();
2147
2217
  }
2148
2218
  /** A tool of another plugin started (computer-use tools report their own steps). */
@@ -2164,16 +2234,14 @@ var OverlayController = class {
2164
2234
  this.pushTimer = void 0;
2165
2235
  if (!this.visible) return;
2166
2236
  this.helper.call("pet_update", {
2167
- text: this.text,
2168
2237
  thinking: this.thinking.trim(),
2169
- steps: this.steps,
2170
- thinkingLatest: this.thinkingLatest
2238
+ steps: this.steps
2171
2239
  }).catch(() => {});
2172
2240
  }, 80);
2173
2241
  this.pushTimer.unref?.();
2174
2242
  }
2175
2243
  /** Agent finished (idle), was cancelled, or the plugin is stopping. */
2176
- async end(agent) {
2244
+ async end(agent, replying = false) {
2177
2245
  if (this.starting) await this.starting;
2178
2246
  if (agent !== void 0 && this.agent !== void 0 && agent !== this.agent) return;
2179
2247
  if (this.idleTimer) clearTimeout(this.idleTimer);
@@ -2190,10 +2258,18 @@ var OverlayController = class {
2190
2258
  this.pushTimer = void 0;
2191
2259
  }
2192
2260
  this.ending = (async () => {
2193
- if (this.settings().hostWindow === "pet" && !this.stopping) await this.helper.call("pet_finish", {
2194
- text: this.text,
2195
- holdMs: FINISH_HOLD_MS
2196
- }).catch(() => {});
2261
+ await this.onRelease?.().catch((error) => this.log(`release input: ${String(error)}`));
2262
+ if (replying && agent && this.returnTo) {
2263
+ const host = this.returnTo.window;
2264
+ const target = await this.helper.call("foreground").catch(() => null);
2265
+ if (target?.hwnd && (target.hwnd !== host.hwnd || this.workTab)) this.resume = {
2266
+ agent,
2267
+ host,
2268
+ target,
2269
+ tab: target.hwnd === host.hwnd ? this.workTab : void 0
2270
+ };
2271
+ }
2272
+ if (!replying && this.settings().hostWindow === "pet" && !this.stopping) await this.helper.call("pet_finish", { holdMs: FINISH_HOLD_MS }).catch(() => {});
2197
2273
  else await this.helper.call("overlay_hide").catch(() => {});
2198
2274
  await this.restoreHost();
2199
2275
  await this.focusRememberedHost().catch((error) => this.log(`restore focus: ${String(error)}`));
@@ -2208,6 +2284,26 @@ var OverlayController = class {
2208
2284
  const target = this.returnTo;
2209
2285
  return target?.web === true && target.window.hwnd === win.hwnd && target.window.pid === win.pid;
2210
2286
  }
2287
+ forgetResume(agent) {
2288
+ const clear = () => {
2289
+ if (this.resume?.agent === agent) this.resume = void 0;
2290
+ };
2291
+ if (this.ending) this.ending.then(clear, clear);
2292
+ else clear();
2293
+ }
2294
+ rememberWorkTab(win, tab) {
2295
+ if (this.isRememberedWebWindow(win)) this.workTab = tab;
2296
+ }
2297
+ rememberWebHost(win, tab) {
2298
+ if (!this.returnTo) this.returnTo = {
2299
+ window: win,
2300
+ web: true,
2301
+ tab
2302
+ };
2303
+ }
2304
+ isWorkTab(tab) {
2305
+ return this.workTab === tab && this.returnTo?.tab !== tab;
2306
+ }
2211
2307
  async rememberHost(harnessUrl) {
2212
2308
  const foreground = await this.helper.call("foreground");
2213
2309
  if (foreground?.hwnd && isHostWindow(foreground)) {
@@ -2237,6 +2333,7 @@ var OverlayController = class {
2237
2333
  async focusRememberedHost() {
2238
2334
  const target = this.returnTo;
2239
2335
  this.returnTo = void 0;
2336
+ this.workTab = void 0;
2240
2337
  if (!target) return;
2241
2338
  const { hwnd, pid } = target.window;
2242
2339
  if ((await this.helper.call("focus", {
@@ -2370,7 +2467,7 @@ ${mode === "per-app" ? "- Before acting on an app, call request_access once with
2370
2467
  - Saving: in any Save As dialog do not click through folders; press alt+n (file name box), ctrl+a, type the full path including the file name, then Return. Office apps: F12 opens that classic dialog directly. To check a saved file, look at the exact path; never search a whole drive or user profile recursively.
2371
2468
  - Be fast: what the user waits for is mostly the number of calls you make (each costs seconds). Once you have seen the app's window, put everything predictable into ONE computer_batch, including steps whose target is not on screen yet: name the control with target ("保存", "按钮:确定") instead of a coordinate, and use wait with until ("window:另存为") for a dialog to appear before keys meant for it. Do not end a batch with wait or follow it with a wait or a screenshot: its result already is the settled screen. Do not split work into two batches just to look in between when the second does not depend on what you would see (type the text and format it in the same batch). If you will need to read small text, end the batch with zoom; to read what a window says (a document, a page, a reply, a log) use ui_elements with text: true or finish: "text" instead of scrolling and zooming screenshots. Keep your own text between calls to a line. Avoid shell commands for things you can see on screen.
2372
2469
  - When two controls share a name, ui_elements reports automationId; use target "id:<AutomationId>" (or "#<AutomationId>") to pick the intended one.
2373
- - Open HTTP(S) URLs with open_application so they use a new browser window. The DeepSeek Harness Web tab is protected just like the desktop chat window.
2470
+ - Open HTTP(S) URLs with open_application. To use the user's current Chrome, bring it forward by name first and then pass the URL. This opens a work tab in the current verified browser window when supported. Keep browser chrome and the DeepSeek Harness Web tab untouched. Use new_instance only if the user asks for a separate window.
2374
2471
  - To see more of a page or list, scroll (action "scroll" with coordinate over the area, scroll_direction, scroll_amount 5-10) instead of hunting with zoom; for long web pages Page Down / End keys also work.
2375
2472
  - If a dedicated tool fits the whole task better (an API, or browser automation attached to the user's own browser), choose it at the start; do not switch tools halfway through a task that is going fine on screen.
2376
2473
  - Do not enter passwords, payment details or solve CAPTCHAs: stop and ask the user to do that step. Ask before irreversible actions (sending messages, deleting, purchasing) unless the user clearly asked for them.
@@ -2771,18 +2868,15 @@ function previewRoute(helper, settings, overlay, iconPath) {
2771
2868
  idleMs: s.userIdleMs,
2772
2869
  glow: s.overlay,
2773
2870
  pet,
2774
- petOpacity: s.cardOpacity,
2775
- text: ""
2871
+ petOpacity: s.cardOpacity
2776
2872
  });
2777
2873
  if (pet) await helper.call("pet_update", {
2778
- text: "这是预览:操控电脑时,这里滚动显示 AI 的回复正文。",
2779
- thinking: "第二行显示思考过程和最近几步操作",
2874
+ thinking: "先确认表单内容,再核对提交结果。",
2780
2875
  steps: [
2781
2876
  "打开应用",
2782
2877
  "输入文字",
2783
2878
  "预览 · 4 秒后消失"
2784
- ],
2785
- thinkingLatest: false
2879
+ ]
2786
2880
  }).catch(() => {});
2787
2881
  setTimeout(() => {
2788
2882
  if (overlay.controller === void 0) helper.call("overlay_hide").catch(() => {});
@@ -8866,7 +8960,7 @@ const actionProperties = {
8866
8960
  },
8867
8961
  until: {
8868
8962
  type: "string",
8869
- description: "wait: return as soon as this is there, \"window:<title or exe part>\" or \"target:<control name>\", instead of waiting a fixed time."
8963
+ description: "wait: observe \"window:<title or exe part>\", \"target:<control name>\", or \"text:<window text>\" instead of waiting a fixed time."
8870
8964
  },
8871
8965
  gone: {
8872
8966
  type: "boolean",
@@ -8998,7 +9092,7 @@ function createTools(host) {
8998
9092
  },
8999
9093
  new_instance: {
9000
9094
  type: "boolean",
9001
- description: "Start another copy even though the app is already running. Only when the user explicitly asks for a second window / instance / account."
9095
+ description: "Open a separate browser window for a URL, or start another app instance. Use only when explicitly requested."
9002
9096
  }
9003
9097
  },
9004
9098
  output,
@@ -9029,13 +9123,40 @@ function createTools(host) {
9029
9123
  await computer.overlay.begin(call.agent, `打开 ${name}`);
9030
9124
  await computer.overlay.yieldToUser(call.signal, false);
9031
9125
  const before = await computer.foreground();
9126
+ if (isUrl && !newInstance && before?.exe.toLowerCase() === "chrome.exe" && before.className.startsWith("Chrome_WidgetWin")) {
9127
+ const tab = await readBrowserTab(computer.helper, before);
9128
+ if (tab?.tab && typeof tab.url === "string") {
9129
+ const denial = computer.access.denial(call.session, before, call.autoApprove ? "allow-all" : settings.accessMode, settings.blockedApps, "open a new tab in");
9130
+ if (denial) throw new Error(denial);
9131
+ if (settings.harnessUrl && isHarnessAddress(tab.url, settings.harnessUrl)) {
9132
+ computer.overlay.rememberWebHost(before, tab.tab);
9133
+ if (!computer.overlay.isRememberedWebWindow(before)) throw new Error("The current browser shows another DeepSeek Harness session. Switch to the intended browser window before opening the URL.");
9134
+ }
9135
+ if (call.signal.aborted) throw new Error("Cancelled.");
9136
+ const opened = await computer.helper.call("browser_open_tab", {
9137
+ hwnd: before.hwnd,
9138
+ pid: before.pid,
9139
+ tab: tab.tab,
9140
+ url: name
9141
+ }, 12e3);
9142
+ if (!opened?.tab || opened.tab === tab.tab) throw new Error("The browser did not confirm a separate work tab.");
9143
+ computer.overlay.rememberWorkTab(before, opened.tab);
9144
+ if (settings.accessMode === "per-app" && call.autoApprove) computer.access.grant(call.session, [before.exe]);
9145
+ return `Opened ${name} in a new tab of the current ${before.exe} window. ${await computer.describeForeground()}${skillNote(call.session, name, before)}`;
9146
+ }
9147
+ throw new Error("Could not verify the current browser tab. Bring a regular browser tab into view and retry. Use new_instance only if a separate window is wanted.");
9148
+ }
9032
9149
  let how;
9033
9150
  let openedUrlWindow;
9034
9151
  const isUri = isUrl || /^[a-z][a-z0-9+.-]+:(?![\/])/i.test(name);
9035
- const running = isUri || newInstance ? void 0 : (await computer.windows()).find((win) => !isHostWindow(win) && appMatches(name, win));
9152
+ const matches = (win) => !isHostWindow(win) && appMatches(name, win);
9153
+ const running = isUri || newInstance ? void 0 : before && matches(before) ? before : (await computer.windows()).find(matches);
9036
9154
  const hidden = running || isUri || newInstance ? void 0 : (await computer.backgroundApps(false)).find((win) => !isHostWindow(win) && appMatches(name, win));
9037
- if (running) how = (await computer.focus(running)).focused ? `Brought ${running.exe} ("${running.title.slice(0, 60)}") to the front.` : `Tried to bring ${running.exe} to the front, but Windows kept another window focused.`;
9038
- else if (hidden) {
9155
+ if (running) {
9156
+ const denial = computer.access.denial(call.session, running, settings.accessMode, settings.blockedApps, "focus");
9157
+ if (denial) throw new Error(denial);
9158
+ how = (await computer.focus(running)).focused ? `Brought ${running.exe} ("${running.title.slice(0, 60)}") to the front.` : `Tried to bring ${running.exe} to the front, but Windows kept another window focused.`;
9159
+ } else if (hidden) {
9039
9160
  const restored = await computer.helper.call("tray_restore", { exe: hidden.exe }, 2e4);
9040
9161
  if (restored.window) computer.noteFromTray(restored.window.hwnd);
9041
9162
  how = restored.window ? `${hidden.exe} was already running in the system tray: restored its window from the tray icon (no second instance started).` : `${hidden.exe} is already running in the background${restored.icon ? " (system tray)" : ""}, but its window did not come back automatically. Open it from its notification-area icon (click ^ "show hidden icons" on the taskbar first). Do not launch it again (that starts a second instance and login), and never force its hidden window visible from a shell (Electron / Qt apps freeze).`;
@@ -9419,8 +9540,8 @@ const Config = z.object({
9419
9540
  }),
9420
9541
  hostWindow: z.union([
9421
9542
  z.const("pet").i18n({
9422
- "zh-CN": { $description: "最小化,改用右下角迷你进度卡片(两行滚动显示回复和思考 / 工具调用)" },
9423
- "en-US": { $description: "Minimize it and show a mini progress card (reply + thinking / tool calls)" }
9543
+ "zh-CN": { $description: "最小化,改用右下角迷你进度卡片(思考与操作时间线)" },
9544
+ "en-US": { $description: "Minimize it and show a mini progress card (reasoning and action timeline)" }
9424
9545
  }),
9425
9546
  z.const("card").i18n({
9426
9547
  "zh-CN": { $description: "缩成右下角置顶悬浮卡片" },
@@ -9517,6 +9638,7 @@ function apply(ctx, config = {}) {
9517
9638
  const iconPath = helperAssetPath("deepseek-white.png");
9518
9639
  const overlay = new OverlayController(helper, settings, log, iconPath);
9519
9640
  const computer = new Computer(helper, access, overlay, settings);
9641
+ overlay.onRelease = () => computer.releaseHeld();
9520
9642
  ctx.effect(() => () => {
9521
9643
  overlay.end().finally(() => helper.dispose());
9522
9644
  }, "computer-use: helper");
@@ -9677,6 +9799,7 @@ function apply(ctx, config = {}) {
9677
9799
  };
9678
9800
  ctx.on("agent/status", ({ agent, status }) => {
9679
9801
  if (status === "running") computer.resetLook();
9802
+ if (status === "idle") overlay.forgetResume(agent);
9680
9803
  if (status === "idle" && computer.clipboardAgent === agent) {
9681
9804
  computer.clipboardAgent = void 0;
9682
9805
  helper.call("clipboard_restore").catch(() => {});
@@ -9684,6 +9807,7 @@ function apply(ctx, config = {}) {
9684
9807
  if (status === "idle" && overlay.controller === agent) overlay.end(agent);
9685
9808
  });
9686
9809
  ctx.on("agent/disposed", ({ agent }) => {
9810
+ overlay.forgetResume(agent);
9687
9811
  access.forget(agent.session.id);
9688
9812
  if (overlay.controller === agent) overlay.end();
9689
9813
  });
@@ -1,4 +1,5 @@
1
1
  import type { HelperLike } from './helper-client.js';
2
+ import type { Rect } from './coords.js';
2
3
  interface BrowserWindow {
3
4
  hwnd: number;
4
5
  pid: number;
@@ -7,9 +8,12 @@ interface BrowserWindow {
7
8
  export interface BrowserTab {
8
9
  url?: string;
9
10
  tab?: string;
11
+ content?: Rect;
12
+ contentFocused?: boolean;
10
13
  }
11
14
  export declare function isBrowser(win: BrowserWindow): boolean;
12
15
  export declare function httpOrigin(value: string): string | undefined;
13
16
  export declare function isHarnessAddress(address: string | undefined, harnessUrl: string): boolean;
14
- export declare function readBrowserTab(helper: HelperLike, win: BrowserWindow): Promise<BrowserTab | undefined>;
17
+ export declare function readBrowserTab(helper: HelperLike, win: BrowserWindow, details?: boolean): Promise<BrowserTab | undefined>;
18
+ export declare function safeSharedBrowserKeys(combos: number[][]): boolean;
15
19
  export {};
@@ -1,4 +1,5 @@
1
1
  import { type AccessControl, type AccessMode, type WindowLike } from './access.js';
2
+ import { type BrowserTab } from './browser-host.js';
2
3
  import { type Display, type Point, type Size } from './coords.js';
3
4
  import type { HelperLike } from './helper-client.js';
4
5
  import { type UiElement } from './target.js';
@@ -157,7 +158,8 @@ export declare class Computer {
157
158
  cursor(): Promise<Point>;
158
159
  /** Short description of the frontmost window, for result text. */
159
160
  describeForeground(): Promise<string>;
160
- assertAllowed(call: CallContext, win: WindowInfo | undefined, verb: string): Promise<void>;
161
+ assertAllowed(call: CallContext, win: WindowInfo | undefined, verb: string): Promise<BrowserTab | undefined>;
162
+ private checkWebContent;
161
163
  private checkPointer;
162
164
  private checkKeyboard;
163
165
  private sendKeys;
@@ -36,4 +36,4 @@ export declare function toScreenshot(point: Point, display: Display, shot: Size)
36
36
  /** Screenshot-space region [x1, y1, x2, y2] → physical rect clamped to the display. */
37
37
  export declare function regionToPhysical(region: readonly number[], display: Display, shot: Size): Rect;
38
38
  /** Is a physical point on this display? */
39
- export declare function contains(display: Display, point: Point): boolean;
39
+ export declare function contains(display: Rect, point: Point): boolean;
@@ -24,6 +24,19 @@ export interface OverlaySettings {
24
24
  cardOpacity: number;
25
25
  userIdleMs: number;
26
26
  }
27
+ interface WindowRow {
28
+ hwnd: number;
29
+ pid: number;
30
+ exe: string;
31
+ title: string;
32
+ minimized: boolean;
33
+ maximized?: boolean;
34
+ foreground?: boolean;
35
+ x: number;
36
+ y: number;
37
+ width: number;
38
+ height: number;
39
+ }
27
40
  interface DisplayRow {
28
41
  x: number;
29
42
  y: number;
@@ -57,22 +70,21 @@ export declare class OverlayController {
57
70
  private hostWindows;
58
71
  private returnTo;
59
72
  private ending;
73
+ private workTab;
60
74
  private starting;
61
75
  private stopping;
62
- /** Progress card lines: the reply as it streams, and what the agent is doing. */
76
+ /** Progress card lines: host-provided reasoning and recent operations. */
63
77
  private streamAgent;
64
- private text;
65
78
  private thinking;
66
79
  /** Recent steps (tool actions), oldest first. */
67
80
  private steps;
68
- /** Whether the agent is thinking now (newer than the last step). */
69
- private thinkingLatest;
70
- private freshAttempt;
81
+ private resume;
71
82
  private pushTimer;
72
83
  /** An instruction the user typed into the progress card. */
73
84
  onMessage: ((agent: CancellableAgent, text: string) => void) | undefined;
74
85
  /** Called when control starts (before the first action), e.g. to remember the window layout. */
75
86
  onStart: (() => Promise<void>) | undefined;
87
+ onRelease: (() => Promise<void>) | undefined;
76
88
  /** Opacity the card was last given, to apply setting changes while it floats. */
77
89
  private cardOpacity;
78
90
  /** Paused by Esc or the pill; actions wait until resumed. */
@@ -105,11 +117,18 @@ export declare class OverlayController {
105
117
  toolStarted(agent: unknown, name: string, detail: string): void;
106
118
  private schedulePush;
107
119
  /** Agent finished (idle), was cancelled, or the plugin is stopping. */
108
- end(agent?: CancellableAgent): Promise<void>;
120
+ end(agent?: CancellableAgent, replying?: boolean): Promise<void>;
109
121
  isRememberedWebWindow(win: {
110
122
  hwnd: number;
111
123
  pid: number;
112
124
  }): boolean;
125
+ forgetResume(agent: unknown): void;
126
+ rememberWorkTab(win: {
127
+ hwnd: number;
128
+ pid: number;
129
+ }, tab: string): void;
130
+ rememberWebHost(win: WindowRow, tab: string): void;
131
+ isWorkTab(tab: string): boolean;
113
132
  private rememberHost;
114
133
  private focusRememberedHost;
115
134
  private stop;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@copylee/dsh-computer-use",
3
- "version": "0.8.2",
3
+ "version": "0.8.3",
4
4
  "description": "DeepSeek Harness Computer Use 插件(Windows):让 AI 看屏幕、点鼠标、敲键盘操控电脑;控制时屏幕泛起橙色光晕并显示“DeepSeek Harness 正在操控你的电脑”,按 Esc 暂停 / 继续。",
5
5
  "type": "module",
6
6
  "author": "copylee",