@copylee/dsh-computer-use 0.1.5 → 0.1.7

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
@@ -7,15 +7,16 @@
7
7
  | 功能 | 说明 |
8
8
  |---|---|
9
9
  | 截图即坐标系 | 模型只用最近一张截图的像素坐标,DPI、缩放、多显示器偏移全部由插件换算,高分屏(200% 缩放)也点得准 |
10
- | 动作后自动回传截图 | 点击 / 输入 / 按键后自动等界面稳定再截图,少一轮调用 |
10
+ | 动作后自动回传截图 | 点击 / 输入 / 按键 / 滚动后,**等画面不再变化**(页面加载、动画结束,最多约 2.5 秒)再截图;`wait` 也直接带回截图,“等一下再看”只需一步;画面与上一张截图完全相同时不再发图,只告诉模型“没有可见变化”,省 token |
11
11
  | 批量动作 | `computer_batch` 一次执行“点输入框 → 输入 → 回车”等多步,最后只截一张图 |
12
12
  | 按应用授权 | 先 `request_access` 列出要操控的应用,经 DSH 原生审批后才能操作;也可改为“全部允许” |
13
13
  | 不会操作自己 | 永远拒绝向 DeepSeek Harness 自身窗口输入;常见密码管理器默认禁止,可再自定义禁用列表 |
14
14
  | 正在控制的提示 | 橙色光晕 + 胶囊提示条(显示当前动作),**不会出现在截图里** |
15
- | 悬浮卡片 | 操控期间 DeepSeek Harness 窗口缩成右下角置顶卡片,结束后自动恢复原尺寸、位置和最大化 / 最小化状态(也可选最小化或不动) |
15
+ | 悬浮卡片 | 操控期间 DeepSeek Harness 窗口缩成右下角置顶卡片,结束后自动恢复原尺寸、位置和最大化 / 最小化状态(也可选最小化或不动)。AI 要点击 / 滚动 / 查看卡片下面的内容时,卡片自动躲到另一侧角落 |
16
16
  | 暂停与停止 | 你亲手按 **Esc** 暂停(AI 停在下一步之前),再按 Esc 或点“继续”恢复,对话不会被中断;点“停止”才结束本轮。插件自己发出的 Esc 不会误触发 |
17
- | 你随时可以插手 | 你用键盘打字时 AI 自动暂停,停手 1.5 秒后继续;你切换或打开了别的窗口,AI 下一步不会盲目执行,而是先看新截图再决定。鼠标移动不会触发,避免误触 |
18
- | 中文输入 | Unicode 直接输入,不受输入法状态影响;长文本走剪贴板并自动恢复原剪贴板;剪贴板文本统一为 CRLF,粘贴到 Obsidian 等应用不丢换行 |
17
+ | 你随时可以插手 | 你用键盘打字时 AI 自动暂停,停手 1.5 秒后继续(单按 Shift / Ctrl 等修饰键不算);你切换或打开了别的窗口,AI 下一步不会盲目执行,而是先看新截图再决定。你只是点进 DSH 卡片看对话时不算切换,AI 的按键会自动回到它正在操作的窗口。鼠标移动不会触发,避免误触 |
18
+ | 中文输入 | Unicode 直接输入,不受输入法状态影响;长文本走剪贴板粘贴,剪贴板文本统一为 CRLF,粘贴到 Obsidian 等应用不丢换行 |
19
+ | 不弄乱剪贴板 | 插件写入剪贴板的内容不进 Windows 剪贴板历史(Win+V)和云剪贴板;粘贴后按原样恢复你的剪贴板(图片、文件也保留);AI 用 `clipboard` 工具写过剪贴板的,本轮结束后自动还原(期间你自己复制了新内容则不动) |
19
20
  | 打开应用 | `open_application` 同时搜索开始菜单和桌面快捷方式(含公共桌面),便携软件也能按名字打开 |
20
21
  | 看不见图的模型 | `ui_elements` 用 Windows UI Automation 列出可点击元素和坐标,纯文本模型也能用 |
21
22
  | 零原生依赖 | 首次使用时用 Windows 自带的 .NET Framework `csc.exe` 编译一个小 helper(约 1 秒,之后缓存),不需要 node-gyp、不受 Electron ABI 影响 |
@@ -70,7 +71,7 @@ dsh plugin --profile web add @copylee/dsh-computer-use@latest
70
71
  | 提示条名称 | DeepSeek Harness | 显示为“<名称> 正在操控你的电脑” |
71
72
  | 操控期间 DSH 窗口 | 悬浮卡片 | 悬浮卡片 / 最小化 / 保持不变,结束后自动恢复 |
72
73
  | 操作后自动截图 | 开 | 关闭可省 token,但模型需要自己截图 |
73
- | 等待稳定 | 400 ms | 动作后多久再截图 |
74
+ | 等待稳定 | 400 ms | 动作后至少等这么久,之后画面静止即截图(最多约 2.5 秒) |
74
75
  | 截图最长边 / 总像素 / JPEG 质量 | 1366 / 1.15MP / 80 | 越大越清晰、越费 token |
75
76
  | 检测到你在操作时让出控制 | 开 | 键盘输入暂停、窗口被切换时重新看屏幕 |
76
77
  | 键盘静止多久后恢复 | 1500 ms | |
@@ -250,6 +250,9 @@ namespace DshComputerUse
250
250
  case "ping": { var d = new Dictionary<string, object>(); d["version"] = Program.Version; return d; }
251
251
  case "displays": return Screen2.Displays();
252
252
  case "screenshot": return Screen2.Capture(r);
253
+ case "settle": return Screen2.Settle(r);
254
+ case "shot_mark": Screen2.Mark(r); return null;
255
+ case "shot_diff": return Screen2.Diff(r);
253
256
  case "cursor": { Native.POINT p; Native.GetCursorPos(out p); return Pt(p.X, p.Y); }
254
257
  case "move": Overlay.Dodge(Args.Int(r, "x", 0), Args.Int(r, "y", 0)); Input.Move(Args.Int(r, "x", 0), Args.Int(r, "y", 0)); return null;
255
258
  case "click": return Input.Click(r);
@@ -268,7 +271,8 @@ namespace DshComputerUse
268
271
  case "apps": return Apps.Search(Args.Str(r, "query", ""), Args.Int(r, "limit", 8));
269
272
  case "launch": return Apps.Launch(r);
270
273
  case "clipboard_get": { var d = new Dictionary<string, object>(); d["text"] = Clip.Get(); return d; }
271
- case "clipboard_set": Clip.Set(Args.Str(r, "text", "")); return null;
274
+ 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;
275
+ case "clipboard_restore": { var d = new Dictionary<string, object>(); d["restored"] = Clip.RestoreAgent(); return d; }
272
276
  case "ui": return Uia.Elements(r);
273
277
  case "overlay_show": Overlay.ExcludeFromCapture = Args.Bool(r, "excludeFromCapture", true); Overlay.Show(r); return null;
274
278
  case "overlay_pause": Overlay.SetPaused(Args.Bool(r, "paused", false)); return null;
@@ -311,6 +315,97 @@ namespace DshComputerUse
311
315
  return list;
312
316
  }
313
317
 
318
+ /** Sample every 8th pixel of a screen rectangle (BGR bytes). */
319
+ static byte[] Sample(int x, int y, int w, int h)
320
+ {
321
+ using (var bmp = new Bitmap(w, h, PixelFormat.Format24bppRgb))
322
+ {
323
+ using (var g = Graphics.FromImage(bmp))
324
+ {
325
+ IntPtr dst = g.GetHdc();
326
+ IntPtr src = Native.GetDC(IntPtr.Zero);
327
+ try { Native.BitBlt(dst, 0, 0, w, h, src, x, y, 0x00CC0020 | 0x40000000); }
328
+ finally { Native.ReleaseDC(IntPtr.Zero, src); g.ReleaseHdc(dst); }
329
+ }
330
+ var data = bmp.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
331
+ try
332
+ {
333
+ int sx = (w + 7) / 8, sy = (h + 7) / 8;
334
+ var row = new byte[data.Stride];
335
+ var outp = new byte[sx * sy * 3];
336
+ int k = 0;
337
+ for (int j = 0; j < sy; j++)
338
+ {
339
+ Marshal.Copy(new IntPtr(data.Scan0.ToInt64() + (long)j * 8 * data.Stride), row, 0, data.Stride);
340
+ for (int i = 0; i < sx; i++) { int o = i * 8 * 3; outp[k++] = row[o]; outp[k++] = row[o + 1]; outp[k++] = row[o + 2]; }
341
+ }
342
+ return outp;
343
+ }
344
+ finally { bmp.UnlockBits(data); }
345
+ }
346
+ }
347
+
348
+ static byte[] marked;
349
+ static string markedRect;
350
+
351
+ static string RectKey(int x, int y, int w, int h) { return x + "," + y + "," + w + "," + h; }
352
+
353
+ /** Remember what the screen looked like when the model was last shown it. */
354
+ public static void Mark(Dictionary<string, object> r)
355
+ {
356
+ int x = Args.Int(r, "x", 0), y = Args.Int(r, "y", 0), w = Args.Int(r, "width", 0), h = Args.Int(r, "height", 0);
357
+ marked = Sample(x, y, w, h);
358
+ markedRect = RectKey(x, y, w, h);
359
+ }
360
+
361
+ /** Fraction of sampled pixels changed since Mark (-1 when there is nothing comparable). */
362
+ public static Dictionary<string, object> Diff(Dictionary<string, object> r)
363
+ {
364
+ int x = Args.Int(r, "x", 0), y = Args.Int(r, "y", 0), w = Args.Int(r, "width", 0), h = Args.Int(r, "height", 0);
365
+ var d = new Dictionary<string, object>();
366
+ d["diff"] = marked == null || markedRect != RectKey(x, y, w, h) ? -1.0 : Changed(marked, Sample(x, y, w, h));
367
+ return d;
368
+ }
369
+
370
+ static double Changed(byte[] a, byte[] b)
371
+ {
372
+ int n = a.Length / 3, diff = 0;
373
+ for (int i = 0; i < a.Length; i += 3)
374
+ if (Math.Abs(a[i] - b[i]) + Math.Abs(a[i + 1] - b[i + 1]) + Math.Abs(a[i + 2] - b[i + 2]) > 30) diff++;
375
+ return n == 0 ? 0 : (double)diff / n;
376
+ }
377
+
378
+ /**
379
+ * Wait until the screen stops changing: at least minMs, then until two
380
+ * consecutive samples (quietMs apart in total) differ in under 0.2% of
381
+ * the sampled pixels, or maxMs passes (videos, spinners).
382
+ */
383
+ public static Dictionary<string, object> Settle(Dictionary<string, object> r)
384
+ {
385
+ int x = Args.Int(r, "x", 0), y = Args.Int(r, "y", 0), w = Args.Int(r, "width", 0), h = Args.Int(r, "height", 0);
386
+ int minMs = Args.Int(r, "minMs", 300), maxMs = Args.Int(r, "maxMs", 2500), interval = Args.Int(r, "intervalMs", 120), quietMs = Args.Int(r, "quietMs", 240);
387
+ if (w <= 0 || h <= 0) throw new Exception("invalid settle rect");
388
+ var watch = System.Diagnostics.Stopwatch.StartNew();
389
+ byte[] prev = Sample(x, y, w, h);
390
+ long quietSince = -1;
391
+ bool stable = false;
392
+ while (true)
393
+ {
394
+ Thread.Sleep(interval);
395
+ byte[] cur = Sample(x, y, w, h);
396
+ long now = watch.ElapsedMilliseconds;
397
+ if (Changed(prev, cur) < 0.002) { if (quietSince < 0) quietSince = now - interval; }
398
+ else quietSince = -1;
399
+ prev = cur;
400
+ if (now >= minMs && quietSince >= 0 && now - quietSince >= quietMs) { stable = true; break; }
401
+ if (now >= maxMs) break;
402
+ }
403
+ var d = new Dictionary<string, object>();
404
+ d["ms"] = (int)watch.ElapsedMilliseconds;
405
+ d["stable"] = stable;
406
+ return d;
407
+ }
408
+
314
409
  static ImageCodecInfo jpegCodec;
315
410
 
316
411
  public static Dictionary<string, object> Capture(Dictionary<string, object> r)
@@ -546,15 +641,16 @@ namespace DshComputerUse
546
641
 
547
642
  public static object Paste(string text, bool restore)
548
643
  {
549
- string previous = null;
550
- if (restore) { try { previous = Clip.Get(); } catch (Exception) { } }
551
- Clip.Set(text);
644
+ // Keep every format the user had (images, files, rich text), not just text.
645
+ DataObject previous = null;
646
+ if (restore) { try { previous = Clip.Snapshot(); } catch (Exception) { } }
647
+ Clip.Set(text, true);
552
648
  Thread.Sleep(40);
553
649
  Send(new List<Native.INPUT> { Key(0x11, false), Key(0x56, false) });
554
650
  Thread.Sleep(30);
555
651
  Send(new List<Native.INPUT> { Key(0x56, true), Key(0x11, true) });
556
652
  Thread.Sleep(250);
557
- if (restore && previous != null) { try { Clip.Set(previous); } catch (Exception) { } }
653
+ if (restore) { try { Clip.Put(previous); } catch (Exception) { } }
558
654
  return null;
559
655
  }
560
656
  }
@@ -571,20 +667,107 @@ namespace DshComputerUse
571
667
  throw new Exception("clipboard is busy");
572
668
  }
573
669
 
574
- public static void Set(string text)
670
+ /** The user's clipboard before the agent first wrote to it, restored when control ends. */
671
+ static DataObject saved;
672
+ static bool hasSaved;
673
+ /** What the agent last put there, to tell whether the user copied something since. */
674
+ static string agentText;
675
+
676
+ static string Normalize(string text)
677
+ {
678
+ return string.IsNullOrEmpty(text) ? "" : text.Replace("\r\n", "\n").Replace("\r", "\n").Replace("\n", "\r\n");
679
+ }
680
+
681
+ /** Mark data as transient: clipboard history (Win+V), cloud clipboard and clipboard managers skip it. */
682
+ static void MarkPrivate(DataObject d)
683
+ {
684
+ d.SetData("ExcludeClipboardContentFromMonitorProcessing", false, new MemoryStream(new byte[] { 1, 0, 0, 0 }));
685
+ d.SetData("CanIncludeInClipboardHistory", false, new MemoryStream(BitConverter.GetBytes(0)));
686
+ d.SetData("CanUploadToCloudClipboard", false, new MemoryStream(BitConverter.GetBytes(0)));
687
+ }
688
+
689
+ /** Copy every format currently on the clipboard (null when empty). */
690
+ public static DataObject Snapshot()
691
+ {
692
+ for (int i = 0; i < 5; i++)
693
+ {
694
+ try
695
+ {
696
+ var src = Clipboard.GetDataObject();
697
+ if (src == null) return null;
698
+ var formats = src.GetFormats(false);
699
+ if (formats.Length == 0) return null;
700
+ var dst = new DataObject();
701
+ foreach (var f in formats)
702
+ {
703
+ if (f == "CanIncludeInClipboardHistory" || f == "CanUploadToCloudClipboard" || f == "ExcludeClipboardContentFromMonitorProcessing") continue;
704
+ try { var v = src.GetData(f, false); if (v != null) dst.SetData(f, false, v); } catch (Exception) { }
705
+ }
706
+ return dst;
707
+ }
708
+ catch (ExternalException) { Thread.Sleep(50); }
709
+ }
710
+ throw new Exception("clipboard is busy");
711
+ }
712
+
713
+ /** Put a snapshot back without adding a history entry (null clears). */
714
+ public static void Put(DataObject data)
575
715
  {
576
- if (!string.IsNullOrEmpty(text)) text = text.Replace("\r\n", "\n").Replace("\r", "\n").Replace("\n", "\r\n");
577
716
  for (int i = 0; i < 5; i++)
578
717
  {
579
718
  try
580
719
  {
581
- if (string.IsNullOrEmpty(text)) Clipboard.Clear(); else Clipboard.SetText(text);
720
+ if (data == null) Clipboard.Clear();
721
+ else { MarkPrivate(data); Clipboard.SetDataObject(data, true); }
582
722
  return;
583
723
  }
584
724
  catch (ExternalException) { Thread.Sleep(50); }
585
725
  }
586
726
  throw new Exception("clipboard is busy");
587
727
  }
728
+
729
+ public static void Set(string text, bool isPrivate)
730
+ {
731
+ text = Normalize(text);
732
+ for (int i = 0; i < 5; i++)
733
+ {
734
+ try
735
+ {
736
+ if (text.Length == 0) Clipboard.Clear();
737
+ else
738
+ {
739
+ var d = new DataObject();
740
+ d.SetData(DataFormats.UnicodeText, false, text);
741
+ if (isPrivate) MarkPrivate(d);
742
+ Clipboard.SetDataObject(d, true);
743
+ }
744
+ return;
745
+ }
746
+ catch (ExternalException) { Thread.Sleep(50); }
747
+ }
748
+ throw new Exception("clipboard is busy");
749
+ }
750
+
751
+ /** The agent writes the clipboard: remember the user's content first (once per control session). */
752
+ public static void AgentSet(string text)
753
+ {
754
+ if (!hasSaved) { saved = Snapshot(); hasSaved = true; }
755
+ Set(text, true);
756
+ agentText = Normalize(text);
757
+ }
758
+
759
+ /** Control ended: put the user's clipboard back, unless they copied something since the agent's last write. */
760
+ public static bool RestoreAgent()
761
+ {
762
+ if (!hasSaved) return false;
763
+ bool ours = false;
764
+ try { ours = Get() == agentText; } catch (Exception) { }
765
+ var data = saved;
766
+ saved = null; hasSaved = false; agentText = null;
767
+ if (!ours) return false;
768
+ Put(data);
769
+ return true;
770
+ }
588
771
  }
589
772
 
590
773
  internal static class Windows
@@ -1366,13 +1549,17 @@ namespace DshComputerUse
1366
1549
  if (down) invoker.BeginInvoke((MethodInvoker)delegate { Press(paused ? "resume" : "pause"); });
1367
1550
  return new IntPtr(1);
1368
1551
  }
1369
- if (down)
1552
+ // Modifier-only presses (Shift to switch the IME, Ctrl, Alt, Win)
1553
+ // and synthetic packets are not typing.
1554
+ int vk = (int)kb.vkCode;
1555
+ bool modifier = vk == 0x10 || vk == 0x11 || vk == 0x12 || (vk >= 0xA0 && vk <= 0xA5) || vk == 0x5B || vk == 0x5C || vk == 0x14 || vk == 0xE7 || vk == 0xFF;
1556
+ if (down && !modifier)
1370
1557
  {
1371
1558
  // The user is typing: the host waits. Mouse movement is
1372
1559
  // deliberately ignored (too easy to nudge).
1373
1560
  int now = Environment.TickCount;
1374
1561
  lastTyping = now;
1375
- if (unchecked(now - lastEmit) > 250) { lastEmit = now; Program.EmitEvent("user_input", "keyboard"); }
1562
+ if (unchecked(now - lastEmit) > 250) { lastEmit = now; Program.EmitEvent("user_input", "vk=0x" + vk.ToString("X2")); }
1376
1563
  }
1377
1564
  }
1378
1565
  }
package/lib/client.js CHANGED
@@ -734,7 +734,7 @@ window.__ModuleLoader__.load({
734
734
  disabled,
735
735
  onChange: (value) => edit("autoScreenshot", value)
736
736
  }), h("div", { style: S.grid2 }, h(NumberField, {
737
- label: "操作后等待界面稳定",
737
+ label: "操作后至少等待(之后画面静止即截图,最多约 2.5 秒)",
738
738
  unit: "毫秒",
739
739
  value: draft.settleMs,
740
740
  error: errors.settleMs,
package/lib/index.js CHANGED
@@ -107,6 +107,17 @@ function normalizeApp(name) {
107
107
  function exeBase(win) {
108
108
  return normalizeApp(win.exe.split(/[\\/]/).pop() ?? "");
109
109
  }
110
+ /** Executable names an app name stands for (UWP's shared frame host excluded). */
111
+ function exeNames(name) {
112
+ const n = normalizeApp(name);
113
+ return new Set([n.replace(/\s/g, ""), ...ALIASES[n] ?? []].filter((exe) => exe !== "applicationframehost"));
114
+ }
115
+ /** Do two app names refer to the same program ("explorer" and "文件资源管理器")? */
116
+ function sameApp(a, b) {
117
+ const x = exeNames(a);
118
+ for (const exe of exeNames(b)) if (x.has(exe)) return true;
119
+ return false;
120
+ }
110
121
  function isHostWindow(win) {
111
122
  return HOST_EXES.includes(win.exe.toLowerCase());
112
123
  }
@@ -148,10 +159,10 @@ var AccessControl = class {
148
159
  isGranted(session, win) {
149
160
  return this.granted(session).some((name) => appMatches(name, win));
150
161
  }
151
- /** Names from `names` the session has not been granted yet. */
162
+ /** Names from `names` the session has not been granted yet (aliases count). */
152
163
  missing(session, names) {
153
164
  const set = this.grants.get(session) ?? /* @__PURE__ */ new Set();
154
- return names.filter((name) => !set.has(normalizeApp(name)));
165
+ return names.filter((name) => !set.has(normalizeApp(name)) && ![...set].some((granted) => sameApp(granted, name)));
155
166
  }
156
167
  forget(session) {
157
168
  this.grants.delete(session);
@@ -467,6 +478,16 @@ const MUTATING = /* @__PURE__ */ new Set([
467
478
  ]);
468
479
  /** Actions that wait for the user to stop typing before they run. */
469
480
  const INPUT = new Set([...MUTATING].filter((action) => action !== "mouse_move"));
481
+ /** Actions whose input goes to the foreground window. */
482
+ const KEYBOARD = /* @__PURE__ */ new Set([
483
+ "type",
484
+ "key",
485
+ "hold_key"
486
+ ]);
487
+ /** Below this fraction of changed sample pixels, the screen counts as unchanged. */
488
+ const UNCHANGED_DIFF = 5e-4;
489
+ /** Text returned instead of an identical screenshot. */
490
+ const UNCHANGED_TEXT = "The screen looks exactly as in your previous screenshot: the action had no visible effect.";
470
491
  var Computer = class Computer {
471
492
  helper;
472
493
  access;
@@ -475,6 +496,8 @@ var Computer = class Computer {
475
496
  displays = [];
476
497
  displayIndex = -1;
477
498
  heldButton = false;
499
+ /** The agent that last wrote the clipboard; when it goes idle the user's clipboard comes back. */
500
+ clipboardAgent;
478
501
  constructor(helper, access, overlay, settings) {
479
502
  this.helper = helper;
480
503
  this.access = access;
@@ -511,10 +534,12 @@ var Computer = class Computer {
511
534
  async point(coordinate, field = "coordinate") {
512
535
  if (!Array.isArray(coordinate) || coordinate.length !== 2) throw new Error(`${field} must be [x, y] in screenshot pixels.`);
513
536
  const display = await this.display();
514
- return toPhysical({
537
+ const p = toPhysical({
515
538
  x: coordinate[0],
516
539
  y: coordinate[1]
517
540
  }, display, this.shotSize(display));
541
+ await this.overlay.dodgeCard(p);
542
+ return p;
518
543
  }
519
544
  async toModel(point) {
520
545
  const display = await this.display();
@@ -528,11 +553,40 @@ var Computer = class Computer {
528
553
  const display = await this.display();
529
554
  const size = this.shotSize(display);
530
555
  const shot = await this.capture(display, size);
556
+ await this.helper.call("shot_mark", this.rect(display)).catch(() => {});
531
557
  await this.remember();
532
558
  return shot;
533
559
  }
560
+ rect(display) {
561
+ return {
562
+ x: display.x,
563
+ y: display.y,
564
+ width: display.width,
565
+ height: display.height
566
+ };
567
+ }
568
+ /**
569
+ * A fresh screenshot, or 'unchanged' when the screen looks the same as in
570
+ * the last one the model saw (saves an image and tells it the action had no
571
+ * visible effect).
572
+ */
573
+ async freshShot() {
574
+ const display = await this.display();
575
+ const result = await this.helper.call("shot_diff", this.rect(display)).catch(() => null);
576
+ if (result && result.diff >= 0 && result.diff < UNCHANGED_DIFF) {
577
+ await this.remember();
578
+ return "unchanged";
579
+ }
580
+ return this.screenshot();
581
+ }
534
582
  /** The foreground window as of the model's latest look at the screen. */
535
583
  seen;
584
+ /** The latest foreground window that was not DeepSeek Harness itself. */
585
+ lastTarget;
586
+ /** A new turn starts: the user may have rearranged things while chatting. */
587
+ resetLook() {
588
+ this.seen = void 0;
589
+ }
536
590
  async remember() {
537
591
  this.seen = await this.foreground().catch(() => void 0);
538
592
  }
@@ -575,7 +629,34 @@ var Computer = class Computer {
575
629
  }
576
630
  async foreground() {
577
631
  const win = await this.helper.call("foreground");
578
- return typeof win.hwnd === "number" ? win : void 0;
632
+ if (!win || typeof win.hwnd !== "number") return void 0;
633
+ if (!isHostWindow(win)) this.lastTarget = win;
634
+ return win;
635
+ }
636
+ /**
637
+ * The user clicked into the DeepSeek Harness card (to read or scroll the
638
+ * chat): keys would go there. Put the window the agent was working in back
639
+ * in front instead of refusing.
640
+ */
641
+ async refocusFromHost() {
642
+ const target = this.lastTarget;
643
+ const fg = await this.foreground().catch(() => void 0);
644
+ if (!fg || !isHostWindow(fg) || !target || target.hwnd === fg.hwnd) return;
645
+ if ((await this.focus(target).catch(() => void 0))?.focused) await setTimeout$1(80);
646
+ }
647
+ /** Wait until the screen stops changing (bounded), instead of a fixed delay. */
648
+ async settle(signal) {
649
+ const s = this.settings();
650
+ const display = await this.display();
651
+ if (await this.helper.call("settle", {
652
+ x: display.x,
653
+ y: display.y,
654
+ width: display.width,
655
+ height: display.height,
656
+ minMs: s.settleMs,
657
+ maxMs: Math.max(s.settleMs, 2500)
658
+ }, 15e3).catch(() => null) === null) await setTimeout$1(s.settleMs, void 0, { signal });
659
+ if (signal.aborted) throw new Error("Cancelled.");
579
660
  }
580
661
  async windowAt(point) {
581
662
  const win = await this.helper.call("window_at", { ...point });
@@ -646,7 +727,7 @@ var Computer = class Computer {
646
727
  }
647
728
  if (s.pauseOnUserInput && INPUT.has(action)) {
648
729
  const changed = await this.foregroundChanged();
649
- if (changed) {
730
+ if (changed && !isHostWindow(changed)) {
650
731
  await this.overlay.status("检测到窗口切换,重新查看屏幕");
651
732
  const image = call.vision ? await this.screenshot() : void 0;
652
733
  if (!image) this.seen = changed;
@@ -658,6 +739,7 @@ var Computer = class Computer {
658
739
  }
659
740
  }
660
741
  if (INPUT.has(action)) this.seen = void 0;
742
+ if (KEYBOARD.has(action)) await this.refocusFromHost();
661
743
  switch (action) {
662
744
  case "screenshot": {
663
745
  const shot = await this.screenshot();
@@ -783,13 +865,17 @@ var Computer = class Computer {
783
865
  up: true
784
866
  }).catch(() => {});
785
867
  }
786
- /** After a mutating action: settle, then capture (vision models only). */
868
+ /**
869
+ * After a mutating action: wait for the screen to settle, then capture
870
+ * (vision models only). A wait already waited, so it is captured at once:
871
+ * "wait, then look" should be one step, not two.
872
+ */
787
873
  async after(inputs, call) {
788
- const s = this.settings();
789
- if (!s.autoScreenshot || !call.vision) return void 0;
790
- if (!inputs.some((input) => MUTATING.has(input.action))) return void 0;
791
- await setTimeout$1(s.settleMs, void 0, { signal: call.signal });
792
- return this.screenshot();
874
+ if (!this.settings().autoScreenshot || !call.vision) return void 0;
875
+ const mutating = inputs.some((input) => MUTATING.has(input.action));
876
+ if (!mutating && !inputs.some((input) => input.action === "wait")) return void 0;
877
+ if (mutating) await this.settle(call.signal);
878
+ return this.freshShot();
793
879
  }
794
880
  /** Bring a window forward and verify it is the foreground window. */
795
881
  async focus(win) {
@@ -1062,11 +1148,15 @@ var OverlayController = class {
1062
1148
  visible = false;
1063
1149
  idleTimer;
1064
1150
  hostWindows = [];
1151
+ /** The floating card and the display it lives on, while carded. */
1152
+ card;
1065
1153
  stopping = false;
1066
1154
  /** Paused by Esc or the pill; actions wait until resumed. */
1067
1155
  paused = false;
1068
1156
  /** When the user last typed on the physical keyboard while the overlay was up (ms epoch). */
1069
1157
  lastUserInput = 0;
1158
+ /** Which physical key that was (helper reason, e.g. "vk=0x41"), for the log. */
1159
+ lastUserKey = "";
1070
1160
  constructor(helper, settings, log, iconPath = "") {
1071
1161
  this.helper = helper;
1072
1162
  this.settings = settings;
@@ -1076,7 +1166,10 @@ var OverlayController = class {
1076
1166
  if (event.event === "stop") this.stop(event.reason ?? "user");
1077
1167
  else if (event.event === "pause") this.paused = true;
1078
1168
  else if (event.event === "resume") this.paused = false;
1079
- else if (event.event === "user_input") this.lastUserInput = Date.now();
1169
+ else if (event.event === "user_input") {
1170
+ this.lastUserInput = Date.now();
1171
+ this.lastUserKey = event.reason ?? "";
1172
+ }
1080
1173
  });
1081
1174
  }
1082
1175
  /** The agent currently driving the computer, if any. */
@@ -1095,6 +1188,7 @@ var OverlayController = class {
1095
1188
  const idleMs = this.settings().userIdleMs;
1096
1189
  const typing = () => waitForTyping && Date.now() - this.lastUserInput < idleMs;
1097
1190
  if (!this.paused && !typing()) return false;
1191
+ if (!this.paused) this.log(`computer use waits: the user is typing (${this.lastUserKey})`);
1098
1192
  const started = Date.now();
1099
1193
  while (this.paused || typing()) {
1100
1194
  if (signal.aborted) throw new Error("Cancelled.");
@@ -1189,13 +1283,46 @@ var OverlayController = class {
1189
1283
  hwnd: main.hwnd,
1190
1284
  mode: "card"
1191
1285
  }];
1286
+ this.card = {
1287
+ hwnd: main.hwnd,
1288
+ display
1289
+ };
1192
1290
  } catch (error) {
1193
1291
  this.log(`host window ${mode}: ${String(error)}`);
1194
1292
  }
1195
1293
  }
1294
+ /**
1295
+ * The agent is about to point at something under the card: move the card to
1296
+ * the opposite bottom corner so the target is visible and clickable.
1297
+ * Returns whether it moved.
1298
+ */
1299
+ async dodgeCard(point) {
1300
+ const card = this.card;
1301
+ if (!card) return false;
1302
+ try {
1303
+ const win = await this.helper.call("window_at", { ...point });
1304
+ if (!win || win.hwnd !== card.hwnd) return false;
1305
+ const d = card.display;
1306
+ const margin = Math.round(16 * d.dpi / 96);
1307
+ const x = win.x + win.width / 2 > d.workX + d.workWidth / 2 ? d.workX + margin : d.workX + d.workWidth - win.width - margin;
1308
+ await this.helper.call("window_card", {
1309
+ hwnd: card.hwnd,
1310
+ x,
1311
+ y: win.y,
1312
+ width: win.width,
1313
+ height: win.height
1314
+ });
1315
+ await new Promise((resolve) => setTimeout(resolve, 120));
1316
+ return true;
1317
+ } catch (error) {
1318
+ this.log(`card dodge: ${String(error)}`);
1319
+ return false;
1320
+ }
1321
+ }
1196
1322
  async restoreHost() {
1197
1323
  const windows = this.hostWindows;
1198
1324
  this.hostWindows = [];
1325
+ this.card = void 0;
1199
1326
  for (const win of windows) if (win.mode === "card") await this.helper.call("window_uncard", { hwnd: win.hwnd }).catch(() => {});
1200
1327
  else await this.helper.call("window_cmd", {
1201
1328
  hwnd: win.hwnd,
@@ -1210,10 +1337,14 @@ function promptText(mode) {
1210
1337
  You can see and operate the user's Windows computer with the computer, computer_batch, open_application, windows, ui_elements and clipboard tools.
1211
1338
  ${mode === "per-app" ? "- Before acting on an app, call request_access once with every app the task needs; the user approves it. Input to apps that are not granted is refused.\n" : ""}- Start with a screenshot (computer action "screenshot") unless you just received one. All coordinates are pixels of the latest screenshot; the plugin converts them for DPI and scaling.
1212
1339
  - Open or switch apps with open_application (by name; it also finds desktop shortcuts) rather than hunting through the taskbar or Start menu or starting GUI apps from a shell. Use windows to see which windows exist; each line shows the process .exe.
1213
- - The "DeepSeek Harness.exe" window is your own chat interface; while you control the computer it may float as a small card in a corner. Never click or type into it; bring the target window to the front first, and work around the card.
1340
+ - The "DeepSeek Harness.exe" window is your own chat interface; while you control the computer it floats as a card in a bottom corner. Never type into it. If the card hides something you need, point at that spot (mouse_move, or just click/scroll there): the card jumps to the other corner. Keys go to the window you were working in even if the user clicked the card.
1214
1341
  - Prefer reliable keyboard shortcuts (ctrl+l for a browser address bar, ctrl+s, alt+F4, ctrl+t). Click the center of targets; zoom in when text is small.
1215
- - 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.
1216
- - If the user has a dedicated tool for a website or service (browser automation, an API tool), prefer it over driving the desktop.
1342
+ - Actions return a fresh screenshot taken once the screen stops changing (page loads included, up to a few seconds), so you rarely need wait. If something is still loading, use wait: it also returns a screenshot, so never follow it with a separate screenshot call.
1343
+ - Enter text with type, even long or multi-line text (over 200 characters it is pasted and the user's clipboard is restored). Do not put text on the clipboard with shell commands (Set-Clipboard, clip): that clutters the user's clipboard history.
1344
+ - Office apps: F12 opens the classic Save As dialog, where you can type a full path in the file name box.
1345
+ - Be efficient: every tool call costs the user several seconds. Put predictable sequences (click a field, type, press Return; open a menu and pick an item you can already see) into one computer_batch. Avoid shell commands for things you can see on screen.
1346
+ - 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.
1347
+ - 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.
1217
1348
  - 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.
1218
1349
  - The user sees an orange border and can press Esc to pause you at any time. If they pause, type on the keyboard or switch windows, you wait; when an action reports it was not performed, re-check the screen instead of repeating it blindly.`;
1219
1350
  }
@@ -6999,6 +7130,8 @@ function toJson(ref) {
6999
7130
  }
7000
7131
  async function withShot(host, text, shot, call) {
7001
7132
  if (shot === void 0) return { text };
7133
+ if (shot === "unchanged") return { text: `${text}
7134
+ ${UNCHANGED_TEXT}` };
7002
7135
  if (!call.vision) return { text: `${text}\n(The current model cannot view images; use ui_elements to read the screen.)` };
7003
7136
  const ref = await host.saveImage(shot, "screenshot.jpg");
7004
7137
  return {
@@ -7067,7 +7200,7 @@ function createTools(host) {
7067
7200
  const tools = [];
7068
7201
  tools.push(defineTool({
7069
7202
  name: "computer",
7070
- description: "Control the Windows desktop with the mouse and keyboard, like a person. Coordinates are pixels of the latest screenshot (the plugin handles DPI and scaling). Clicks, typing, keys and scrolls return a fresh screenshot automatically, so do not call screenshot again right after. Prefer keyboard shortcuts when they are reliable. zoom shows a region at full resolution for small text.",
7203
+ description: "Control the Windows desktop with the mouse and keyboard, like a person. Coordinates are pixels of the latest screenshot (the plugin handles DPI and scaling). Clicks, typing, keys, scrolls and wait return a fresh screenshot automatically (taken once the screen settles), so do not call screenshot again right after. Prefer keyboard shortcuts when they are reliable. zoom shows a region at full resolution for small text.",
7071
7204
  parameters: actionProperties,
7072
7205
  output,
7073
7206
  timeoutMs: 18e5,
@@ -7142,7 +7275,7 @@ function createTools(host) {
7142
7275
  }
7143
7276
  }
7144
7277
  const done = lines.join("\n");
7145
- const shot = call.vision && computer.settings().autoScreenshot ? await setTimeout$1(computer.settings().settleMs, void 0, { signal: call.signal }).then(() => computer.screenshot()) : void 0;
7278
+ const shot = call.vision && computer.settings().autoScreenshot ? await computer.settle(call.signal).then(() => computer.freshShot()) : void 0;
7146
7279
  const summary = failure === void 0 ? `All ${actions.length} actions done.\n${done}` : `Stopped: ${failure}${done ? `\nCompleted before it:\n${done}` : ""}\nRemaining actions were skipped.`;
7147
7280
  return withShot(host, shot === void 0 ? `${summary}\n${await computer.describeForeground()}` : summary, shot, call);
7148
7281
  },
@@ -7164,18 +7297,20 @@ function createTools(host) {
7164
7297
  if (name === "") throw new Error("name is required.");
7165
7298
  const settings = computer.settings();
7166
7299
  const isUrl = /^https?:\/\//i.test(name);
7167
- if (settings.accessMode === "per-app" && !isUrl && computer.access.missing(call.session, [name]).length > 0) {
7168
- const running = (await computer.windows()).find((win) => appMatches(name, win));
7169
- if (!running || !computer.access.isGranted(call.session, running)) throw new Error(`"${name}" is not granted for this session. Call request_access with ["${name}"] first.`);
7300
+ const appName = /^ms-settings:/i.test(name) ? "设置" : name;
7301
+ if (settings.accessMode === "per-app" && !isUrl && computer.access.missing(call.session, [appName]).length > 0) {
7302
+ const running = (await computer.windows()).find((win) => appMatches(appName, win));
7303
+ if (!running || !computer.access.isGranted(call.session, running)) throw new Error(`"${appName}" is not granted for this session. Call request_access with ["${appName}"] first.`);
7170
7304
  }
7171
7305
  await computer.overlay.begin(call.agent, `打开 ${name}`);
7172
7306
  await computer.overlay.yieldToUser(call.signal, false);
7173
7307
  const before = await computer.foreground();
7174
7308
  let how;
7175
- const running = isUrl ? void 0 : (await computer.windows()).find((win) => !isHostWindow(win) && appMatches(name, win));
7309
+ const isUri = isUrl || /^[a-z][a-z0-9+.-]+:(?![\/])/i.test(name);
7310
+ const running = isUri ? void 0 : (await computer.windows()).find((win) => !isHostWindow(win) && appMatches(name, win));
7176
7311
  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.`;
7177
7312
  else {
7178
- const app = (isUrl ? [] : await computer.helper.call("apps", {
7313
+ const app = (isUri ? [] : await computer.helper.call("apps", {
7179
7314
  query: name,
7180
7315
  limit: 5
7181
7316
  }, 3e4))[0];
@@ -7185,12 +7320,12 @@ function createTools(host) {
7185
7320
  for (let i = 0; i < 32; i++) {
7186
7321
  await setTimeout$1(250, void 0, { signal: call.signal });
7187
7322
  const now = await computer.foreground();
7188
- if (now && now.hwnd !== before?.hwnd && !isHostWindow(now) && now.exe.toLowerCase() !== "explorer.exe") break;
7323
+ if (now && now.hwnd !== before?.hwnd && !isHostWindow(now) && (now.exe.toLowerCase() !== "explorer.exe" || now.className === "CabinetWClass")) break;
7189
7324
  }
7190
7325
  }
7191
7326
  const fg = await computer.foreground();
7192
- if (fg && !isHostWindow(fg) && settings.accessMode === "per-app" && (computer.access.missing(call.session, [name]).length === 0 || isUrl)) computer.access.grant(call.session, [fg.exe]);
7193
- await setTimeout$1(settings.settleMs, void 0, { signal: call.signal });
7327
+ if (fg && !isHostWindow(fg) && settings.accessMode === "per-app" && (computer.access.missing(call.session, [appName]).length === 0 || isUrl)) computer.access.grant(call.session, [fg.exe]);
7328
+ await computer.settle(call.signal);
7194
7329
  const shot = call.vision ? await computer.screenshot() : void 0;
7195
7330
  return withShot(host, `${how} ${await computer.describeForeground()}`, shot, call);
7196
7331
  },
@@ -7296,7 +7431,7 @@ function createTools(host) {
7296
7431
  }));
7297
7432
  tools.push(defineTool({
7298
7433
  name: "clipboard",
7299
- description: "Read or write the clipboard text.",
7434
+ description: "Read or write the clipboard text. Writes stay out of Windows clipboard history, and the user clipboard is restored when you finish. To enter long text, prefer computer type (it pastes for you); never set the clipboard from a shell.",
7300
7435
  parameters: {
7301
7436
  action: {
7302
7437
  type: "string",
@@ -7309,10 +7444,14 @@ function createTools(host) {
7309
7444
  }
7310
7445
  },
7311
7446
  output,
7312
- async execute(args) {
7447
+ async execute(args, exec) {
7313
7448
  const { action, text } = args;
7314
7449
  if (action === "write") {
7315
- await computer.helper.call("clipboard_set", { text: text ?? "" });
7450
+ computer.clipboardAgent = (await host.context(exec)).agent;
7451
+ await computer.helper.call("clipboard_set", {
7452
+ text: text ?? "",
7453
+ agent: true
7454
+ });
7316
7455
  return { text: `Clipboard set (${(text ?? "").length} characters).` };
7317
7456
  }
7318
7457
  const result = await computer.helper.call("clipboard_get");
@@ -7427,8 +7566,8 @@ const Config = z.object({
7427
7566
  "en-US": { $description: "Return a screenshot after every action (saves a round trip)" }
7428
7567
  }),
7429
7568
  settleMs: z.natural().max(5e3).default(400).volatile().i18n({
7430
- "zh-CN": { $description: "操作后等待界面稳定的毫秒数,再截图" },
7431
- "en-US": { $description: "Milliseconds to wait after an action before the screenshot" }
7569
+ "zh-CN": { $description: "操作后至少等待的毫秒数;之后画面静止即截图(最多约 2.5 秒)" },
7570
+ "en-US": { $description: "Minimum wait after an action; then the screenshot is taken once the screen stops changing (up to ~2.5 s)" }
7432
7571
  }),
7433
7572
  maxLongEdge: z.natural().min(640).max(3840).default(1366).volatile().i18n({
7434
7573
  "zh-CN": { $description: "截图最长边像素(越大越清晰、越费 token)" },
@@ -7527,6 +7666,11 @@ function apply(ctx, config = {}) {
7527
7666
  };
7528
7667
  });
7529
7668
  ctx.on("agent/status", ({ agent, status }) => {
7669
+ if (status === "running") computer.resetLook();
7670
+ if (status === "idle" && computer.clipboardAgent === agent) {
7671
+ computer.clipboardAgent = void 0;
7672
+ helper.call("clipboard_restore").catch(() => {});
7673
+ }
7530
7674
  if (status === "idle" && overlay.controller === agent) overlay.end(agent);
7531
7675
  });
7532
7676
  ctx.on("agent/disposed", ({ agent }) => {
@@ -12,6 +12,8 @@ export interface WindowLike {
12
12
  /** The DSH desktop host: the agent must never type into its own chat. */
13
13
  export declare const HOST_EXES: string[];
14
14
  export declare function normalizeApp(name: string): string;
15
+ /** Do two app names refer to the same program ("explorer" and "文件资源管理器")? */
16
+ export declare function sameApp(a: string, b: string): boolean;
15
17
  export declare function isHostWindow(win: WindowLike): boolean;
16
18
  /** Does a granted (or requested) app name refer to this window? */
17
19
  export declare function appMatches(name: string, win: WindowLike): boolean;
@@ -20,7 +22,7 @@ export declare class AccessControl {
20
22
  grant(session: string, names: readonly string[]): string[];
21
23
  granted(session: string): string[];
22
24
  isGranted(session: string, win: WindowLike): boolean;
23
- /** Names from `names` the session has not been granted yet. */
25
+ /** Names from `names` the session has not been granted yet (aliases count). */
24
26
  missing(session: string, names: readonly string[]): string[];
25
27
  forget(session: string): void;
26
28
  /**
@@ -1,4 +1,4 @@
1
- import type { AccessControl, AccessMode, WindowLike } from './access.js';
1
+ import { type AccessControl, type AccessMode, type WindowLike } from './access.js';
2
2
  import { type Display, type Point, type Size } from './coords.js';
3
3
  import type { HelperLike } from './helper-client.js';
4
4
  import type { CancellableAgent, HostWindowMode, OverlayController } from './overlay.js';
@@ -64,6 +64,10 @@ export interface ActionOutcome {
64
64
  /** The action was not performed because the user took over the keyboard. */
65
65
  skipped?: boolean;
66
66
  }
67
+ /** Text returned instead of an identical screenshot. */
68
+ export declare const UNCHANGED_TEXT = "The screen looks exactly as in your previous screenshot: the action had no visible effect.";
69
+ /** Longest adaptive wait for the screen to settle after an action. */
70
+ export declare const MAX_SETTLE_MS = 2500;
67
71
  export declare class Computer {
68
72
  readonly helper: HelperLike;
69
73
  readonly access: AccessControl;
@@ -72,6 +76,8 @@ export declare class Computer {
72
76
  private displays;
73
77
  private displayIndex;
74
78
  private heldButton;
79
+ /** The agent that last wrote the clipboard; when it goes idle the user's clipboard comes back. */
80
+ clipboardAgent: CancellableAgent | undefined;
75
81
  constructor(helper: HelperLike, access: AccessControl, overlay: OverlayController, settings: () => Settings);
76
82
  refreshDisplays(): Promise<Display[]>;
77
83
  display(): Promise<Display>;
@@ -83,8 +89,19 @@ export declare class Computer {
83
89
  offscreen: boolean;
84
90
  }>;
85
91
  screenshot(): Promise<Shot>;
92
+ private rect;
93
+ /**
94
+ * A fresh screenshot, or 'unchanged' when the screen looks the same as in
95
+ * the last one the model saw (saves an image and tells it the action had no
96
+ * visible effect).
97
+ */
98
+ freshShot(): Promise<Shot | 'unchanged'>;
86
99
  /** The foreground window as of the model's latest look at the screen. */
87
100
  private seen;
101
+ /** The latest foreground window that was not DeepSeek Harness itself. */
102
+ private lastTarget;
103
+ /** A new turn starts: the user may have rearranged things while chatting. */
104
+ resetLook(): void;
88
105
  private remember;
89
106
  /**
90
107
  * Did another window come to the front since the model last looked, without
@@ -94,6 +111,14 @@ export declare class Computer {
94
111
  private capture;
95
112
  zoom(region: number[] | undefined): Promise<Shot>;
96
113
  foreground(): Promise<WindowInfo | undefined>;
114
+ /**
115
+ * The user clicked into the DeepSeek Harness card (to read or scroll the
116
+ * chat): keys would go there. Put the window the agent was working in back
117
+ * in front instead of refusing.
118
+ */
119
+ private refocusFromHost;
120
+ /** Wait until the screen stops changing (bounded), instead of a fixed delay. */
121
+ settle(signal: AbortSignal): Promise<void>;
97
122
  windowAt(point: Point): Promise<WindowInfo | undefined>;
98
123
  windows(): Promise<WindowInfo[]>;
99
124
  cursor(): Promise<Point>;
@@ -108,8 +133,12 @@ export declare class Computer {
108
133
  run(input: ActionInput, call: CallContext): Promise<ActionOutcome>;
109
134
  /** Release a mouse button left down by an aborted run. */
110
135
  releaseHeld(): Promise<void>;
111
- /** After a mutating action: settle, then capture (vision models only). */
112
- after(inputs: readonly ActionInput[], call: CallContext): Promise<Shot | undefined>;
136
+ /**
137
+ * After a mutating action: wait for the screen to settle, then capture
138
+ * (vision models only). A wait already waited, so it is captured at once:
139
+ * "wait, then look" should be one step, not two.
140
+ */
141
+ after(inputs: readonly ActionInput[], call: CallContext): Promise<Shot | 'unchanged' | undefined>;
113
142
  /** Bring a window forward and verify it is the foreground window. */
114
143
  focus(win: WindowInfo): Promise<WindowInfo & {
115
144
  focused: boolean;
@@ -40,11 +40,15 @@ export declare class OverlayController {
40
40
  private visible;
41
41
  private idleTimer;
42
42
  private hostWindows;
43
+ /** The floating card and the display it lives on, while carded. */
44
+ private card;
43
45
  private stopping;
44
46
  /** Paused by Esc or the pill; actions wait until resumed. */
45
47
  paused: boolean;
46
48
  /** When the user last typed on the physical keyboard while the overlay was up (ms epoch). */
47
49
  lastUserInput: number;
50
+ /** Which physical key that was (helper reason, e.g. "vk=0x41"), for the log. */
51
+ private lastUserKey;
48
52
  constructor(helper: HelperLike, settings: () => OverlaySettings, log: (message: string) => void,
49
53
  /** Absolute path of the pill icon (PNG). */
50
54
  iconPath?: string);
@@ -66,6 +70,15 @@ export declare class OverlayController {
66
70
  private armIdle;
67
71
  /** Card: shrink the DSH window to an always-on-top corner card; minimize: get it out of the way. */
68
72
  private shrinkHost;
73
+ /**
74
+ * The agent is about to point at something under the card: move the card to
75
+ * the opposite bottom corner so the target is visible and clickable.
76
+ * Returns whether it moved.
77
+ */
78
+ dodgeCard(point: {
79
+ x: number;
80
+ y: number;
81
+ }): Promise<boolean>;
69
82
  private restoreHost;
70
83
  }
71
84
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@copylee/dsh-computer-use",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "DeepSeek Harness Computer Use 插件(Windows):让 AI 看屏幕、点鼠标、敲键盘操控电脑;控制时屏幕泛起橙色光晕并显示“DeepSeek Harness 正在操控你的电脑”,按 Esc 暂停 / 继续。",
5
5
  "type": "module",
6
6
  "author": "copylee",