@copylee/dsh-computer-use 0.1.0 → 0.1.2

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 CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Copy
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.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Copy
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.md CHANGED
@@ -2,16 +2,17 @@
2
2
 
3
3
  [![npm](https://img.shields.io/npm/v/@copylee/dsh-computer-use)](https://www.npmjs.com/package/@copylee/dsh-computer-use)
4
4
 
5
- 让 DeepSeek Harness 像 Claude 的 Computer Use 一样操控你的 Windows 电脑:看屏幕、点鼠标、敲键盘,打开应用、切换窗口、读写剪贴板。控制期间屏幕四周会泛起**橙色光晕**,顶部出现“**DeepSeek 正在使用你的电脑**”提示条,按 **Esc** 或点“停止”立即中断。
5
+ 让 DeepSeek Harness 直接操控你的 Windows 电脑:看屏幕、点鼠标、敲键盘,打开应用、切换窗口、读写剪贴板。控制期间屏幕四周会泛起**橙色光晕**,顶部出现“**DeepSeek 正在使用你的电脑**”提示条,按 **Esc** 或点“停止”立即中断。
6
6
 
7
7
  | 功能 | 说明 |
8
8
  |---|---|
9
9
  | 截图即坐标系 | 模型只用最近一张截图的像素坐标,DPI、缩放、多显示器偏移全部由插件换算,高分屏(200% 缩放)也点得准 |
10
10
  | 动作后自动回传截图 | 点击 / 输入 / 按键后自动等界面稳定再截图,少一轮调用 |
11
11
  | 批量动作 | `computer_batch` 一次执行“点输入框 → 输入 → 回车”等多步,最后只截一张图 |
12
- | 按应用授权 | 仿 Claude:先 `request_access` 列出要操控的应用,经 DSH 原生审批后才能操作;也可改为“全部允许” |
12
+ | 按应用授权 | 先 `request_access` 列出要操控的应用,经 DSH 原生审批后才能操作;也可改为“全部允许” |
13
13
  | 不会操作自己 | 永远拒绝向 DeepSeek Harness 自身窗口输入;常见密码管理器默认禁止,可再自定义禁用列表 |
14
14
  | 正在控制的提示 | 橙色光晕 + 胶囊提示条(显示当前动作),**不会出现在截图里**;真实按下的 Esc 才算停止,插件自己发的 Esc 不会误触发 |
15
+ | 你随时可以插手 | 你用键盘打字时 AI 自动暂停,停手 1.5 秒后继续;你切换或打开了别的窗口,AI 下一步不会盲目执行,而是先看新截图再决定。鼠标移动不会触发,避免误触 |
15
16
  | 中文输入 | Unicode 直接输入,不受输入法状态影响;长文本走剪贴板并自动恢复原剪贴板 |
16
17
  | 看不见图的模型 | `ui_elements` 用 Windows UI Automation 列出可点击元素和坐标,纯文本模型也能用 |
17
18
  | 零原生依赖 | 首次使用时用 Windows 自带的 .NET Framework `csc.exe` 编译一个小 helper(约 1 秒,之后缓存),不需要 node-gyp、不受 Electron ABI 影响 |
@@ -40,13 +41,13 @@ dsh plugin --profile web add @copylee/dsh-computer-use@latest
40
41
 
41
42
  按应用授权模式下,模型会先请求操控对应应用,你在 DSH 里批准即可。会话权限为“完全权限”或“自动审查”(不弹审批)时,请求会被自动批准,但 DeepSeek Harness 自身和禁用列表里的应用仍然不可操作。
42
43
 
43
- **随时按 Esc 停止**,或点提示条上的“停止”。
44
+ **随时按 Esc 停止**,或点提示条上的“停止”。想临时帮一把也可以直接上手:打字时 AI 会等你,切到别的窗口后 AI 会先重新看屏幕。
44
45
 
45
46
  ## Agent 工具
46
47
 
47
48
  | 工具 | 作用 |
48
49
  |---|---|
49
- | `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`(与 Anthropic computer tool 同名同参) |
50
+ | `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 动作命名,模型上手即会) |
50
51
  | `computer_batch` | 顺序执行多个动作,遇错即停,最后回传一张截图 |
51
52
  | `open_application` | 按名称(“Chrome”“记事本”“微信”)、exe 路径或网址打开应用;已运行则切到前台 |
52
53
  | `windows` | 列出窗口(含进程 exe 名)、聚焦 / 最小化 / 最大化 / 还原 / 关闭 |
@@ -68,6 +69,8 @@ dsh plugin --profile web add @copylee/dsh-computer-use@latest
68
69
  | 操作后自动截图 | 开 | 关闭可省 token,但模型需要自己截图 |
69
70
  | 等待稳定 | 400 ms | 动作后多久再截图 |
70
71
  | 截图最长边 / 总像素 / JPEG 质量 | 1366 / 1.15MP / 80 | 越大越清晰、越费 token |
72
+ | 检测到你在操作时让出控制 | 开 | 键盘输入暂停、窗口被切换时重新看屏幕 |
73
+ | 键盘静止多久后恢复 | 1500 ms | |
71
74
  | 禁止操控的应用 | 空 | 名称或 exe,如 `alipay` |
72
75
 
73
76
  ## 数据与隐私
@@ -1121,18 +1121,31 @@ namespace DshComputerUse
1121
1121
  return p;
1122
1122
  }
1123
1123
 
1124
- static void DrawSpark(Graphics g, float cx, float cy, float radius, Color color, float width)
1124
+ static readonly Color Whale = Color.FromArgb(77, 107, 254); // DeepSeek blue #4D6BFE
1125
+
1126
+ /// A whale facing left, drawn in a 24x24 design box scaled to `size`.
1127
+ static void DrawWhale(Graphics g, float x, float y, float size, Color eye)
1125
1128
  {
1126
- using (var pen = new Pen(color, width))
1129
+ float k = size / 24f;
1130
+ Func<float, float, PointF> P = delegate (float px, float py) { return new PointF(x + px * k, y + py * k); };
1131
+ using (var path = new GraphicsPath())
1132
+ {
1133
+ path.AddBezier(P(1f, 14f), P(1f, 9f), P(5.5f, 6.5f), P(10f, 7.2f));
1134
+ path.AddBezier(P(10f, 7.2f), P(14f, 7.8f), P(16.5f, 10f), P(18f, 10.5f));
1135
+ path.AddBezier(P(18f, 10.5f), P(19.5f, 9f), P(20f, 6f), P(19.2f, 3.5f));
1136
+ path.AddBezier(P(19.2f, 3.5f), P(21.5f, 4.5f), P(23f, 3.8f), P(23.5f, 2.5f));
1137
+ path.AddBezier(P(23.5f, 2.5f), P(23.8f, 6f), P(22.5f, 9.5f), P(19.5f, 13f));
1138
+ path.AddBezier(P(19.5f, 13f), P(17.5f, 17.5f), P(13f, 19.5f), P(8.5f, 19.3f));
1139
+ path.AddBezier(P(8.5f, 19.3f), P(4f, 19f), P(1f, 17.5f), P(1f, 14f));
1140
+ path.CloseFigure();
1141
+ using (var brush = new SolidBrush(Whale)) g.FillPath(brush, path);
1142
+ }
1143
+ using (var pen = new Pen(Color.FromArgb(150, eye), Math.Max(1f, 1.1f * k)))
1127
1144
  {
1128
1145
  pen.StartCap = LineCap.Round; pen.EndCap = LineCap.Round;
1129
- for (int i = 0; i < 6; i++)
1130
- {
1131
- double a = Math.PI * i / 6;
1132
- float dx = (float)(Math.Cos(a) * radius), dy = (float)(Math.Sin(a) * radius);
1133
- g.DrawLine(pen, cx - dx, cy - dy, cx + dx, cy + dy);
1134
- }
1146
+ g.DrawBezier(pen, P(2.6f, 15.4f), P(6f, 17.2f), P(10.5f, 17.2f), P(14f, 15.6f)); // belly line
1135
1147
  }
1148
+ using (var brush = new SolidBrush(eye)) g.FillEllipse(brush, x + 4.6f * k, y + 11f * k, 2.2f * k, 2.2f * k);
1136
1149
  }
1137
1150
 
1138
1151
  static void RenderPill()
@@ -1167,7 +1180,7 @@ namespace DshComputerUse
1167
1180
  SizeF mainSize = mg.MeasureString(main, fMain, 10000, fmt);
1168
1181
  SizeF subSize = mg.MeasureString(sub, fSub, 10000, fmt);
1169
1182
  SizeF btnSize = mg.MeasureString("停止", fBtn, 10000, fmt);
1170
- float pad = 14 * scale, gap = 10 * scale, icon = 18 * scale;
1183
+ float pad = 16 * scale, gap = 11 * scale, icon = 20 * scale;
1171
1184
  float height = 40 * scale;
1172
1185
  float btnW = btnSize.Width + 22 * scale, btnH = 26 * scale;
1173
1186
  float width = pad + icon + gap + mainSize.Width + gap + 1 * scale + gap + subSize.Width + gap + btnW + (pad - 7 * scale);
@@ -1187,8 +1200,7 @@ namespace DshComputerUse
1187
1200
  using (var brush = new SolidBrush(Color.FromArgb(242, 31, 30, 29))) g.FillPath(brush, path);
1188
1201
  using (var pen = new Pen(Color.FromArgb(200, Accent), Math.Max(1f, 1.2f * scale))) g.DrawPath(pen, path);
1189
1202
  }
1190
- float cx = pad + icon / 2, cy = H / 2f;
1191
- DrawSpark(g, cx, cy, icon / 2, Accent, Math.Max(1.6f, 2.1f * scale));
1203
+ DrawWhale(g, pad - 5 * scale, (H - icon - 10 * scale) / 2f, icon + 10 * scale, Color.FromArgb(31, 30, 29));
1192
1204
  float tx = pad + icon + gap;
1193
1205
  using (var b = new SolidBrush(Color.FromArgb(250, 250, 249))) g.DrawString(main, fMain, b, tx, (H - mainSize.Height) / 2f, fmt);
1194
1206
  tx += mainSize.Width + gap;
@@ -1222,13 +1234,25 @@ namespace DshComputerUse
1222
1234
  hook = IntPtr.Zero;
1223
1235
  }
1224
1236
 
1237
+ static long lastTyping;
1238
+
1225
1239
  static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
1226
1240
  {
1227
1241
  if (nCode >= 0 && visible && (wParam.ToInt32() == 0x100 || wParam.ToInt32() == 0x104))
1228
1242
  {
1229
1243
  var kb = (Native.KBDLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(Native.KBDLLHOOKSTRUCT));
1230
- // Only a physical Esc counts: our own SendInput sets LLKHF_INJECTED (0x10).
1231
- if (kb.vkCode == 0x1B && (kb.flags & 0x10) == 0) Program.EmitEvent("stop", "esc");
1244
+ // Only physical keys count: our own SendInput sets LLKHF_INJECTED (0x10).
1245
+ if ((kb.flags & 0x10) == 0)
1246
+ {
1247
+ if (kb.vkCode == 0x1B) Program.EmitEvent("stop", "esc");
1248
+ else
1249
+ {
1250
+ // The user is typing: let the host pause. Throttled; mouse
1251
+ // movement is deliberately ignored (too easy to nudge).
1252
+ long now = Environment.TickCount;
1253
+ if (now - lastTyping > 250) { lastTyping = now; Program.EmitEvent("user_input", "keyboard"); }
1254
+ }
1255
+ }
1232
1256
  }
1233
1257
  return Native.CallNextHookEx(hook, nCode, wParam, lParam);
1234
1258
  }
package/lib/index.js CHANGED
@@ -465,6 +465,8 @@ const MUTATING = /* @__PURE__ */ new Set([
465
465
  "hold_key",
466
466
  "mouse_move"
467
467
  ]);
468
+ /** Actions that wait for the user to stop typing before they run. */
469
+ const INPUT = new Set([...MUTATING].filter((action) => action !== "mouse_move"));
468
470
  var Computer = class Computer {
469
471
  helper;
470
472
  access;
@@ -525,7 +527,24 @@ var Computer = class Computer {
525
527
  await this.refreshDisplays();
526
528
  const display = await this.display();
527
529
  const size = this.shotSize(display);
528
- return this.capture(display, size);
530
+ const shot = await this.capture(display, size);
531
+ await this.remember();
532
+ return shot;
533
+ }
534
+ /** The foreground window as of the model's latest look at the screen. */
535
+ seen;
536
+ async remember() {
537
+ this.seen = await this.foreground().catch(() => void 0);
538
+ }
539
+ /**
540
+ * Did another window come to the front since the model last looked, without
541
+ * the agent acting in between? Then the user (or a popup) changed the screen.
542
+ */
543
+ async foregroundChanged() {
544
+ const seen = this.seen;
545
+ if (!seen) return void 0;
546
+ const now = await this.foreground().catch(() => void 0);
547
+ return now && now.hwnd !== seen.hwnd ? now : void 0;
529
548
  }
530
549
  async capture(rect, out) {
531
550
  const result = await this.helper.call("screenshot", {
@@ -571,6 +590,7 @@ var Computer = class Computer {
571
590
  /** Short description of the frontmost window, for result text. */
572
591
  async describeForeground() {
573
592
  const win = await this.foreground().catch(() => void 0);
593
+ this.seen = win;
574
594
  if (!win) return "Foreground window: none (desktop).";
575
595
  return `Foreground window: ${win.exe} — "${win.title.slice(0, 80)}".`;
576
596
  }
@@ -614,6 +634,28 @@ var Computer = class Computer {
614
634
  if (call.signal.aborted) throw new Error("Cancelled.");
615
635
  await this.overlay.begin(call.agent, Computer.statusOf(input));
616
636
  const { action } = input;
637
+ const s = this.settings();
638
+ if (s.pauseOnUserInput && INPUT.has(action) && await this.overlay.waitForUserIdle(call.signal, s.userIdleMs)) {
639
+ await this.overlay.begin(call.agent, Computer.statusOf(input));
640
+ return {
641
+ text: `Not done: the user was typing on the keyboard, so you were paused until they stopped. ${action} was NOT performed. Look at the new screenshot and re-plan before acting.`,
642
+ ...call.vision ? { image: await this.screenshot() } : {},
643
+ skipped: true
644
+ };
645
+ }
646
+ if (s.pauseOnUserInput && INPUT.has(action)) {
647
+ const changed = await this.foregroundChanged();
648
+ if (changed) {
649
+ const image = call.vision ? await this.screenshot() : void 0;
650
+ if (!image) this.seen = changed;
651
+ return {
652
+ text: `Not done: since your last look the foreground window changed to ${changed.exe} ("${changed.title.slice(0, 60)}") without you acting, most likely the user opened it. ${action} was NOT performed. Look at the new screenshot and decide whether to continue there, switch back, or ask the user.`,
653
+ ...image ? { image } : {},
654
+ skipped: true
655
+ };
656
+ }
657
+ }
658
+ if (INPUT.has(action)) this.seen = void 0;
617
659
  switch (action) {
618
660
  case "screenshot": {
619
661
  const shot = await this.screenshot();
@@ -1004,8 +1046,31 @@ var OverlayController = class {
1004
1046
  this.log = log;
1005
1047
  helper.onEvent((event) => {
1006
1048
  if (event.event === "stop") this.stop(event.reason ?? "user");
1049
+ else if (event.event === "user_input") this.lastUserInput = Date.now();
1007
1050
  });
1008
1051
  }
1052
+ /** When the user last typed on the physical keyboard while the overlay was up (ms epoch). */
1053
+ lastUserInput = 0;
1054
+ /** Did the user type after `since`? */
1055
+ userTypedSince(since) {
1056
+ return this.lastUserInput > since;
1057
+ }
1058
+ /**
1059
+ * If the user is typing, pause until the keyboard has been quiet for
1060
+ * `idleMs`. Throws after `maxMs` so the model can tell the user. Returns
1061
+ * whether it had to wait.
1062
+ */
1063
+ async waitForUserIdle(signal, idleMs, maxMs = 12e4) {
1064
+ if (Date.now() - this.lastUserInput >= idleMs) return false;
1065
+ const started = Date.now();
1066
+ if (this.settings().overlay && this.visible) await this.helper.call("overlay_status", { status: "你正在操作,已暂停" }).catch(() => {});
1067
+ while (Date.now() - this.lastUserInput < idleMs) {
1068
+ if (signal.aborted) throw new Error("Cancelled.");
1069
+ if (Date.now() - started > maxMs) throw new Error("The user has been typing on the keyboard for a while, so computer use is paused. Ask the user whether to continue.");
1070
+ await new Promise((resolve) => setTimeout(resolve, 200));
1071
+ }
1072
+ return true;
1073
+ }
1009
1074
  /** The agent currently driving the computer, if any. */
1010
1075
  get controller() {
1011
1076
  return this.agent;
@@ -1091,10 +1156,10 @@ ${mode === "per-app" ? "- Before acting on an app, call request_access once with
1091
1156
  - Actions return a fresh screenshot. Check it before continuing and verify the result instead of assuming success. Use computer_batch for several confident steps in a row.
1092
1157
  - If the user has a dedicated tool for a website or service (browser automation, an API tool), prefer it over driving the desktop.
1093
1158
  - 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.
1094
- - The user sees an orange border and can press Esc at any time to stop you.`;
1159
+ - The user sees an orange border and can press Esc at any time to stop you. If they type on the keyboard you are paused; when an action reports it was not performed, re-check the screen instead of repeating it blindly.`;
1095
1160
  }
1096
1161
  //#endregion
1097
- //#region node_modules/.pnpm/@deepseek-ai+dsh-scope@0.2._0d6b19188928ab894325adc32e18b0b5/node_modules/@deepseek-ai/dsh-scope/lib/index.js
1162
+ //#region node_modules/.pnpm/@deepseek-ai+dsh-scope@0.2.0-rc.2_@deepseek-ai+cordis@4.0.4_@deepseek-ai+dsh-invariants_0d6b19188928ab894325adc32e18b0b5/node_modules/@deepseek-ai/dsh-scope/lib/index.js
1098
1163
  /**
1099
1164
  * Shared insertion-ordered storage and effect ownership for scope-aware registries.
1100
1165
  *
@@ -1373,7 +1438,7 @@ function scopeTarget(base, key) {
1373
1438
  return carrier;
1374
1439
  }
1375
1440
  //#endregion
1376
- //#region node_modules/.pnpm/@deepseek-ai+dsh-typert-pro_0ed6bf01f07b8aa74e2681abf2790db7/node_modules/@deepseek-ai/dsh-typert-protocol/lib/index.js
1441
+ //#region node_modules/.pnpm/@deepseek-ai+dsh-typert-protocol@0.2.0-rc.2_@deepseek-ai+cordis@4.0.4/node_modules/@deepseek-ai/dsh-typert-protocol/lib/index.js
1377
1442
  /** The one Remote failure class shared by owners, the Gateway, and consumers. */
1378
1443
  /**
1379
1444
  * One Remote call failure: a real Error carrying its stable code and typed
@@ -1533,7 +1598,7 @@ function validateName(subject, value) {
1533
1598
  if (!isTypertRemoteSegment(value)) throw new TypeError(`typert-protocol: ${subject} must contain only RPC endpoint segment characters`);
1534
1599
  }
1535
1600
  //#endregion
1536
- //#region node_modules/.pnpm/@deepseek-ai+dsh-util-value_a1b445b943dd6f2898d88d6b9ffb1320/node_modules/@deepseek-ai/dsh-util-values/lib/index.js
1601
+ //#region node_modules/.pnpm/@deepseek-ai+dsh-util-values@0.2.0-rc.2_@deepseek-ai+cordis@4.0.4/node_modules/@deepseek-ai/dsh-util-values/lib/index.js
1537
1602
  /** Duplicate-install-safe JSON and immutable-value helpers. @module @deepseek-ai/dsh-util-values */
1538
1603
  /**
1539
1604
  * Mark an unreachable closed-union branch.
@@ -1745,7 +1810,7 @@ function deepFreeze(value) {
1745
1810
  return value;
1746
1811
  }
1747
1812
  //#endregion
1748
- //#region node_modules/.pnpm/@deepseek-ai+dsh-util-crypt_566393aaceb27aff7afe31ca52cb276c/node_modules/@deepseek-ai/dsh-util-crypto/lib/index.js
1813
+ //#region node_modules/.pnpm/@deepseek-ai+dsh-util-crypto@0.2.0-rc.2_@deepseek-ai+cordis@4.0.4/node_modules/@deepseek-ai/dsh-util-crypto/lib/index.js
1749
1814
  /**
1750
1815
  * Random v4 UUID, minted from `crypto.getRandomValues`.
1751
1816
  * @returns the UUID string.
@@ -1781,7 +1846,7 @@ function brandString(value) {
1781
1846
  return value;
1782
1847
  }
1783
1848
  //#endregion
1784
- //#region node_modules/.pnpm/@deepseek-ai+dsh-timeout@0._b8424359025b5f3ee36fc59cc7db98be/node_modules/@deepseek-ai/dsh-timeout/lib/index.js
1849
+ //#region node_modules/.pnpm/@deepseek-ai+dsh-timeout@0.2.0-rc.2_@deepseek-ai+cordis@4.0.4/node_modules/@deepseek-ai/dsh-timeout/lib/index.js
1785
1850
  /** Largest delay Node schedules without clamping it to one millisecond. */
1786
1851
  const MAX_TIMER_DELAY_MS = 2147483647;
1787
1852
  //#endregion
@@ -2962,7 +3027,7 @@ function adapterFailureChunk(error, signal) {
2962
3027
  };
2963
3028
  }
2964
3029
  //#endregion
2965
- //#region node_modules/.pnpm/@deepseek-ai+dsh-sandbox@0._2cc6ce11d95db65b014013a78bf96eaa/node_modules/@deepseek-ai/dsh-sandbox/lib/index.js
3030
+ //#region node_modules/.pnpm/@deepseek-ai+dsh-sandbox@0.2.0-rc.2_@deepseek-ai+cordis@4.0.4_@deepseek-ai+dsh-llm@0.2._2cc6ce11d95db65b014013a78bf96eaa/node_modules/@deepseek-ai/dsh-sandbox/lib/index.js
2966
3031
  /**
2967
3032
  * The escalation vocabulary and choreography shared by every sandbox-enforcing
2968
3033
  * tool family (`@deepseek-ai/dsh-tool-bash`, `@deepseek-ai/dsh-tool-fs`): the
@@ -3048,7 +3113,7 @@ async function approveEscalation(request, approval) {
3048
3113
  }
3049
3114
  }
3050
3115
  //#endregion
3051
- //#region node_modules/.pnpm/@deepseek-ai+dsh-tools@0.2._0055658947bc774f21f98df07f5a8468/node_modules/@deepseek-ai/dsh-tools/lib/index.js
3116
+ //#region node_modules/.pnpm/@deepseek-ai+dsh-tools@0.2.0-rc.2_c6e351a6a6cfd1c2a664558bffcd410d/node_modules/@deepseek-ai/dsh-tools/lib/index.js
3052
3117
  /**
3053
3118
  * Enforced JSON Schema subset shared by tool outputs, generated PTC mode
3054
3119
  * types, subagents, and workflows. The subset accepts any JSON root, an
@@ -6882,9 +6947,18 @@ function createTools(host) {
6882
6947
  break;
6883
6948
  }
6884
6949
  try {
6950
+ const stepStart = Date.now();
6885
6951
  const outcome = await computer.run(input, call);
6952
+ if (outcome.skipped) {
6953
+ failure = `#${index + 1} ${input.action} skipped: the user was typing on the keyboard. Re-check the screen before continuing.`;
6954
+ break;
6955
+ }
6886
6956
  lines.push(`#${index + 1} ${outcome.text}`);
6887
6957
  await setTimeout$1(60, void 0, { signal: call.signal });
6958
+ if (computer.settings().pauseOnUserInput && computer.overlay.userTypedSince(stepStart - 1)) {
6959
+ failure = `#${index + 1} done, but the user typed on the keyboard meanwhile; remaining actions stopped. Re-check the screen before continuing.`;
6960
+ break;
6961
+ }
6888
6962
  } catch (error) {
6889
6963
  if (call.signal.aborted) {
6890
6964
  await computer.releaseHeld();
@@ -7147,7 +7221,9 @@ const DEFAULTS = {
7147
7221
  maxLongEdge: 1366,
7148
7222
  maxPixels: 115e4,
7149
7223
  jpegQuality: 80,
7150
- blockedApps: []
7224
+ blockedApps: [],
7225
+ pauseOnUserInput: true,
7226
+ userIdleMs: 1500
7151
7227
  };
7152
7228
  const Config = z.object({
7153
7229
  accessMode: z.union([z.const("per-app").i18n({
@@ -7192,6 +7268,14 @@ const Config = z.object({
7192
7268
  "zh-CN": { $description: "截图 JPEG 质量" },
7193
7269
  "en-US": { $description: "Screenshot JPEG quality" }
7194
7270
  }),
7271
+ pauseOnUserInput: z.boolean().default(true).volatile().i18n({
7272
+ "zh-CN": { $description: "检测到你在操作时让出控制:你用键盘打字时暂停、停手后继续;你切换或打开了新窗口时,AI 重新看屏幕再决定(鼠标移动不会触发)" },
7273
+ "en-US": { $description: "Yield to you: pause while you type, and re-check the screen when you bring up another window (mouse movement is ignored)" }
7274
+ }),
7275
+ userIdleMs: z.natural().min(300).max(1e4).default(1500).volatile().i18n({
7276
+ "zh-CN": { $description: "键盘停止多少毫秒后恢复操作" },
7277
+ "en-US": { $description: "Milliseconds of keyboard quiet before resuming" }
7278
+ }),
7195
7279
  blockedApps: z.array(z.string()).default([]).volatile().i18n({
7196
7280
  "zh-CN": { $description: "禁止操控的应用(名称或 exe,如 “alipay”)。常见密码管理器默认已禁止。" },
7197
7281
  "en-US": { $description: "Apps that may never be controlled (names or exe). Common password managers are always blocked." }
@@ -7216,6 +7300,8 @@ function resolveConfig(raw) {
7216
7300
  maxLongEdge: num("maxLongEdge", 640, 3840),
7217
7301
  maxPixels: num("maxPixels", 3e5, 8e6),
7218
7302
  jpegQuality: num("jpegQuality", 30, 100),
7303
+ pauseOnUserInput: bool("pauseOnUserInput"),
7304
+ userIdleMs: num("userIdleMs", 300, 1e4),
7219
7305
  blockedApps: Array.isArray(out.blockedApps) ? out.blockedApps.filter((item) => typeof item === "string" && item.trim() !== "") : []
7220
7306
  };
7221
7307
  }
@@ -13,6 +13,10 @@ export interface Settings {
13
13
  jpegQuality: number;
14
14
  autoScreenshot: boolean;
15
15
  settleMs: number;
16
+ /** Pause while the user types on the physical keyboard. */
17
+ pauseOnUserInput: boolean;
18
+ /** How long the keyboard must be quiet before resuming. */
19
+ userIdleMs: number;
16
20
  }
17
21
  export interface WindowInfo extends WindowLike {
18
22
  hwnd: number;
@@ -57,6 +61,8 @@ export interface ActionOutcome {
57
61
  text: string;
58
62
  /** A screenshot or zoom image to return to the model. */
59
63
  image?: Shot;
64
+ /** The action was not performed because the user took over the keyboard. */
65
+ skipped?: boolean;
60
66
  }
61
67
  export declare class Computer {
62
68
  readonly helper: HelperLike;
@@ -77,6 +83,14 @@ export declare class Computer {
77
83
  offscreen: boolean;
78
84
  }>;
79
85
  screenshot(): Promise<Shot>;
86
+ /** The foreground window as of the model's latest look at the screen. */
87
+ private seen;
88
+ private remember;
89
+ /**
90
+ * Did another window come to the front since the model last looked, without
91
+ * the agent acting in between? Then the user (or a popup) changed the screen.
92
+ */
93
+ private foregroundChanged;
80
94
  private capture;
81
95
  zoom(region: number[] | undefined): Promise<Shot>;
82
96
  foreground(): Promise<WindowInfo | undefined>;
@@ -21,6 +21,8 @@ export interface Config {
21
21
  maxPixels?: number;
22
22
  jpegQuality?: number;
23
23
  blockedApps?: string[];
24
+ pauseOnUserInput?: boolean;
25
+ userIdleMs?: number;
24
26
  }
25
27
  export declare const Config: z<Config>;
26
28
  /** Unwrap `.volatile()` refs (`{ get() }`) and fall back to defaults for bad values. */
@@ -19,6 +19,16 @@ export declare class OverlayController {
19
19
  private minimizedHost;
20
20
  private stopping;
21
21
  constructor(helper: HelperLike, settings: () => OverlaySettings, log: (message: string) => void);
22
+ /** When the user last typed on the physical keyboard while the overlay was up (ms epoch). */
23
+ lastUserInput: number;
24
+ /** Did the user type after `since`? */
25
+ userTypedSince(since: number): boolean;
26
+ /**
27
+ * If the user is typing, pause until the keyboard has been quiet for
28
+ * `idleMs`. Throws after `maxMs` so the model can tell the user. Returns
29
+ * whether it had to wait.
30
+ */
31
+ waitForUserIdle(signal: AbortSignal, idleMs: number, maxMs?: number): Promise<boolean>;
22
32
  /** The agent currently driving the computer, if any. */
23
33
  get controller(): CancellableAgent | undefined;
24
34
  /** Called before every action: shows the overlay once and updates its status line. */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@copylee/dsh-computer-use",
3
- "version": "0.1.0",
4
- "description": "DeepSeek Harness Computer Use 插件(Windows):像 Claude 一样看屏幕、点鼠标、敲键盘操控电脑;控制时屏幕泛起橙色光晕并显示“DeepSeek 正在使用你的电脑”,按 Esc 立即停止。",
3
+ "version": "0.1.2",
4
+ "description": "DeepSeek Harness Computer Use 插件(Windows):让 AI 看屏幕、点鼠标、敲键盘操控电脑;控制时屏幕泛起橙色光晕并显示“DeepSeek 正在使用你的电脑”,按 Esc 立即停止。",
5
5
  "type": "module",
6
6
  "author": "copylee",
7
7
  "repository": {