@copylee/dsh-computer-use 0.14.1 → 0.14.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/helper/Native.cs CHANGED
@@ -51,7 +51,7 @@ namespace DshComputerUse
51
51
  [DllImport("user32.dll", SetLastError = true)] public static extern bool SetSystemCursor(IntPtr hcur, uint id);
52
52
  [DllImport("user32.dll", SetLastError = true)] public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, IntPtr pvParam, uint fWinIni);
53
53
  public const uint SPI_SETCURSORS = 0x0057;
54
- public const uint OCR_NORMAL = 32512, OCR_IBEAM = 32513, OCR_HAND = 32649;
54
+ public const uint OCR_NORMAL = 32512, OCR_IBEAM = 32513, OCR_WAIT = 32514, OCR_HAND = 32649, OCR_APPSTARTING = 32650;
55
55
 
56
56
  public delegate bool MonitorEnumProc(IntPtr hMonitor, IntPtr hdc, ref RECT rect, IntPtr data);
57
57
  [DllImport("user32.dll")] public static extern bool EnumDisplayMonitors(IntPtr hdc, IntPtr clip, MonitorEnumProc proc, IntPtr data);
@@ -67,6 +67,7 @@ namespace DshComputerUse
67
67
  [DllImport("gdi32.dll")] public static extern bool DeleteDC(IntPtr hdc);
68
68
  [DllImport("gdi32.dll")] public static extern IntPtr SelectObject(IntPtr hdc, IntPtr obj);
69
69
  [DllImport("gdi32.dll")] public static extern bool DeleteObject(IntPtr obj);
70
+ [DllImport("gdi32.dll")] public static extern IntPtr CreateBitmap(int nWidth, int nHeight, uint cPlanes, uint cBitsPerPel, IntPtr lpvBits);
70
71
 
71
72
  public delegate bool EnumWindowsProc(IntPtr hwnd, IntPtr data);
72
73
  [DllImport("user32.dll")] public static extern bool EnumWindows(EnumWindowsProc proc, IntPtr data);
package/helper/Overlay.cs CHANGED
@@ -217,6 +217,7 @@ namespace DshComputerUse
217
217
  {
218
218
  readonly bool clickThrough;
219
219
  public Rectangle Physical;
220
+ int affinityState = -1;
220
221
 
221
222
  public LayeredForm(bool clickThrough)
222
223
  {
@@ -245,6 +246,7 @@ namespace DshComputerUse
245
246
  {
246
247
  base.OnHandleCreated(e);
247
248
  // Keep the overlay out of every screenshot, including our own.
249
+ affinityState = Overlay.ExcludeFromCapture ? 1 : 0;
248
250
  if (Overlay.ExcludeFromCapture) { try { Native.SetWindowDisplayAffinity(Handle, 0x11); } catch (Exception) { } }
249
251
  }
250
252
 
@@ -291,6 +293,9 @@ namespace DshComputerUse
291
293
 
292
294
  public void SetCapturable(bool capturable)
293
295
  {
296
+ int want = capturable ? 0 : 1;
297
+ if (affinityState == want) return;
298
+ affinityState = want;
294
299
  try { Native.SetWindowDisplayAffinity(Handle, capturable ? 0u : 0x11u); } catch (Exception) { }
295
300
  }
296
301
  }
@@ -377,6 +382,10 @@ namespace DshComputerUse
377
382
  static volatile bool visible;
378
383
  static volatile bool paused;
379
384
  static volatile bool petWaiting;
385
+ static DateTime petWaitingSince = DateTime.UtcNow;
386
+ static string petPhase = "";
387
+ static DateTime petPhaseSince = DateTime.UtcNow;
388
+ static int lastPhaseSec = -1;
380
389
  public static volatile bool SkipWaitRequested;
381
390
  static volatile bool clickTargetEnabled = true;
382
391
  static volatile bool customCursorActive;
@@ -393,6 +402,7 @@ namespace DshComputerUse
393
402
  static bool hasCachedMarkBitmap;
394
403
  static volatile int latestMouseX, latestMouseY;
395
404
  static int mouseMovePending;
405
+ static int lastMouseMoveTick = int.MinValue / 2;
396
406
  static int lastTyping = int.MinValue / 2;
397
407
  static int lastEmit;
398
408
  static readonly object RectLock = new object();
@@ -646,33 +656,31 @@ namespace DshComputerUse
646
656
  g.DrawPolygon(outline, arrow);
647
657
  }
648
658
  }
649
- IntPtr hIcon = bmp.GetHicon();
659
+ // Build a clean 32-bit ARGB cursor with an all-zero monochrome AND mask
660
+ // so Windows DWM composites it purely on the hardware cursor plane without flicker.
661
+ IntPtr hbmColor = bmp.GetHbitmap(Color.FromArgb(0));
662
+ IntPtr hbmMask = Native.CreateBitmap(size, size, 1, 1, IntPtr.Zero);
650
663
  try
651
664
  {
652
- Native.ICONINFO ii;
653
- if (Native.GetIconInfo(hIcon, out ii))
665
+ if (hbmColor != IntPtr.Zero && hbmMask != IntPtr.Zero)
654
666
  {
655
- try
656
- {
657
- ii.fIcon = false;
658
- ii.xHotspot = tipX;
659
- ii.yHotspot = tipY;
660
- hCursor = Native.CreateIconIndirect(ref ii);
661
- }
662
- finally
663
- {
664
- if (ii.hbmMask != IntPtr.Zero) Native.DeleteObject(ii.hbmMask);
665
- if (ii.hbmColor != IntPtr.Zero) Native.DeleteObject(ii.hbmColor);
666
- }
667
+ var ii = new Native.ICONINFO();
668
+ ii.fIcon = false;
669
+ ii.xHotspot = tipX;
670
+ ii.yHotspot = tipY;
671
+ ii.hbmColor = hbmColor;
672
+ ii.hbmMask = hbmMask;
673
+ hCursor = Native.CreateIconIndirect(ref ii);
667
674
  }
668
675
  }
669
676
  finally
670
677
  {
671
- Native.DestroyIcon(hIcon);
678
+ if (hbmColor != IntPtr.Zero) Native.DeleteObject(hbmColor);
679
+ if (hbmMask != IntPtr.Zero) Native.DeleteObject(hbmMask);
672
680
  }
673
681
  }
674
682
  if (hCursor == IntPtr.Zero) return;
675
- uint[] ids = new uint[] { Native.OCR_NORMAL, Native.OCR_IBEAM, Native.OCR_HAND };
683
+ uint[] ids = new uint[] { Native.OCR_NORMAL, Native.OCR_IBEAM, Native.OCR_HAND, Native.OCR_APPSTARTING, Native.OCR_WAIT };
676
684
  bool anyApplied = false;
677
685
  for (int i = 0; i < ids.Length; i++)
678
686
  {
@@ -755,7 +763,28 @@ namespace DshComputerUse
755
763
  {
756
764
  if (thread == null) return;
757
765
  if (value) SkipWaitRequested = false;
758
- Ui(delegate { petWaiting = value; if (visible) RenderPill(); });
766
+ Ui(delegate
767
+ {
768
+ petWaiting = value;
769
+ if (value) { petWaitingSince = DateTime.UtcNow; lastPhaseSec = -1; }
770
+ if (visible) RenderPill();
771
+ });
772
+ }
773
+
774
+ public static void SetPhase(string phase)
775
+ {
776
+ if (thread == null) return;
777
+ Ui(delegate
778
+ {
779
+ string next = phase ?? "";
780
+ if (petPhase != next)
781
+ {
782
+ petPhase = next;
783
+ petPhaseSince = DateTime.UtcNow;
784
+ lastPhaseSec = -1;
785
+ }
786
+ if (visible && !petFinished) RenderPill();
787
+ });
759
788
  }
760
789
 
761
790
  public static void Hide()
@@ -772,6 +801,8 @@ namespace DshComputerUse
772
801
  CloseInput(false);
773
802
  petFinished = false;
774
803
  petWaiting = false;
804
+ petPhase = "";
805
+ lastPhaseSec = -1;
775
806
  SkipWaitRequested = false;
776
807
  petReply = "";
777
808
  visible = false;
@@ -857,15 +888,16 @@ namespace DshComputerUse
857
888
  float pillW = textSize.Width > 0 ? (float)Math.Ceiling(textSize.Width + 2f * pillPadX) : 0f;
858
889
  float pillH = textSize.Height > 0 ? Math.Max(19f * s, (float)Math.Ceiling(textSize.Height + 5f * s)) : 0f;
859
890
 
860
- // Offsets relative to the pointer tip at (0, 0). Clear the native Windows pointer
861
- // arrow cleanly when attaching to the live OS cursor (drawArrow == false).
862
- float tagX = flipX ? (-10f * s - pillW) : (drawArrow ? 13f * s : 14f * s);
863
- float tagY = flipY ? (-10f * s - pillH) : (drawArrow ? 15f * s : 18f * s);
891
+ // Offsets relative to the pointer tip at (0, 0). When not showing a click ripple,
892
+ // keep the layered pill strictly outside the hardware cursor's bounding box so
893
+ // Windows DWM never flickers the hardware cursor plane over WDA_EXCLUDEFROMCAPTURE.
894
+ float tagX = flipX ? (-10f * s - pillW) : (ripple ? 14f * s : 16f * s);
895
+ float tagY = flipY ? (-10f * s - pillH) : (ripple ? 16f * s : 21f * s);
864
896
 
865
- float minX = Math.Min(-glowR, pillW > 0 ? tagX : 0f) - pad;
866
- float maxX = Math.Max(glowR, Math.Max(14f * s, pillW > 0 ? tagX + pillW : 0f)) + pad;
867
- float minY = Math.Min(-glowR, pillH > 0 ? tagY : 0f) - pad;
868
- float maxY = Math.Max(glowR, Math.Max(22f * s, pillH > 0 ? tagY + pillH : 0f)) + pad;
897
+ float minX = ripple ? Math.Min(-glowR, pillW > 0 ? tagX : 0f) - pad : (pillW > 0 ? tagX - pad : 0f);
898
+ float maxX = ripple ? Math.Max(glowR, Math.Max(14f * s, pillW > 0 ? tagX + pillW : 0f)) + pad : (pillW > 0 ? tagX + pillW + pad : 1f);
899
+ float minY = ripple ? Math.Min(-glowR, pillH > 0 ? tagY : 0f) - pad : (pillH > 0 ? tagY - pad : 0f);
900
+ float maxY = ripple ? Math.Max(glowR, Math.Max(22f * s, pillH > 0 ? tagY + pillH : 0f)) + pad : (pillH > 0 ? tagY + pillH + pad + 2f * s : 1f);
869
901
 
870
902
  int W = Math.Max(1, (int)Math.Ceiling(maxX - minX));
871
903
  int H = Math.Max(1, (int)Math.Ceiling(maxY - minY));
@@ -879,16 +911,19 @@ namespace DshComputerUse
879
911
  g.SmoothingMode = SmoothingMode.AntiAlias;
880
912
  g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
881
913
 
882
- // 1. Soft radial spotlight centered right under the tip (cx, cy).
883
- using (var spot = new GraphicsPath())
914
+ // 1. Soft radial spotlight ONLY on post-click ripples (avoid overlapping the live hardware cursor).
915
+ if (ripple)
884
916
  {
885
- spot.AddEllipse(cx - glowR, cy - glowR, glowR * 2f, glowR * 2f);
886
- using (var glow = new PathGradientBrush(spot))
917
+ using (var spot = new GraphicsPath())
887
918
  {
888
- glow.CenterPoint = new PointF(cx, cy);
889
- glow.CenterColor = Color.FromArgb(ripple ? 135 : 115, color);
890
- glow.SurroundColors = new Color[] { Color.FromArgb(0, color) };
891
- g.FillPath(glow, spot);
919
+ spot.AddEllipse(cx - glowR, cy - glowR, glowR * 2f, glowR * 2f);
920
+ using (var glow = new PathGradientBrush(spot))
921
+ {
922
+ glow.CenterPoint = new PointF(cx, cy);
923
+ glow.CenterColor = Color.FromArgb(135, color);
924
+ glow.SurroundColors = new Color[] { Color.FromArgb(0, color) };
925
+ g.FillPath(glow, spot);
926
+ }
892
927
  }
893
928
  }
894
929
 
@@ -1227,12 +1262,16 @@ namespace DshComputerUse
1227
1262
  byte alpha = (byte)Math.Max(0, Math.Min(255, 255 * fadeIn * breathe));
1228
1263
  foreach (var g in glows) g.SetAlpha(alpha);
1229
1264
  if (Key() != rendered) RenderPill(); // typing started or stopped
1265
+ else if (!paused && (petWaiting || petPhase == "llm"))
1266
+ {
1267
+ int sec = (int)Math.Max(0, Math.Floor((DateTime.UtcNow - (petWaiting ? petWaitingSince : petPhaseSince)).TotalSeconds));
1268
+ if (sec != lastPhaseSec) { lastPhaseSec = sec; RenderPill(); }
1269
+ }
1230
1270
  if ((int)(t * 25) % 50 == 0)
1231
1271
  {
1232
1272
  foreach (var g in glows) g.KeepOnTop();
1233
1273
  if (pill != null) pill.KeepOnTop();
1234
1274
  if (pet != null) pet.KeepOnTop();
1235
- if (markForm != null) markForm.KeepOnTop();
1236
1275
  if (input != null) Native.SetWindowPos(input.Handle, new IntPtr(-1), 0, 0, 0, 0, 0x0001 | 0x0002 | 0x0010);
1237
1276
  }
1238
1277
  }
@@ -1397,13 +1436,20 @@ namespace DshComputerUse
1397
1436
 
1398
1437
  bool isCompact = petSize == "compact";
1399
1438
  bool isDetailed = petSize == "detailed";
1439
+ int waitSec = petWaiting ? (int)Math.Max(0, Math.Floor((DateTime.UtcNow - petWaitingSince).TotalSeconds)) : 0;
1440
+ int llmSec = petPhase == "llm" ? (int)Math.Max(0, Math.Floor((DateTime.UtcNow - petPhaseSince).TotalSeconds)) : 0;
1441
+ bool hasReply = !petFinished && petReply.Length > 0;
1442
+ bool showLlmWait = !petFinished && !paused && !petWaiting && petPhase == "llm" && !hasReply && petThinking.Length == 0;
1400
1443
  string hoverTip = ButtonTip(hoveredBtn);
1401
1444
  string title = hoverTip.Length > 0
1402
1445
  ? (isCompact ? "" : "DSH")
1403
1446
  : petFinished ? "已完成" : (isCompact && label.Length > 12 ? label.Substring(0, 11) + "…" : label);
1404
1447
  string state = hoverTip.Length > 0 ? hoverTip
1405
1448
  : petFinished ? "" : paused ? (input != null ? "输入指令中…" : "已暂停 · Esc 继续")
1406
- : Typing() ? "你正在操作,已暂停" : (isCompact ? "" : "Esc 暂停");
1449
+ : Typing() ? "你正在操作,已暂停"
1450
+ : petWaiting ? (isCompact ? ("等待 " + waitSec + "s") : ("等待画面 " + waitSec + "s"))
1451
+ : showLlmWait ? (isCompact ? ("模型响应 " + llmSec + "s") : ("等待模型响应 " + llmSec + "s"))
1452
+ : (isCompact ? "" : "Esc 暂停");
1407
1453
  // Header buttons, right to left.
1408
1454
  var actions = new List<string>(); var glyphs = new List<string>();
1409
1455
  if (petFinished) { actions.Add("close"); glyphs.Add("\uE711"); }
@@ -1422,13 +1468,16 @@ namespace DshComputerUse
1422
1468
  float bodyW = (isCompact ? 320f : isDetailed ? 484f : 420f) * s;
1423
1469
  float pad = (isCompact ? 13f : 16f) * s;
1424
1470
  float headH = (isCompact ? 40f : 44f) * s;
1425
- bool showThinking = !isCompact || petExpanded || (!petFinished && petReply.Length > 0);
1471
+ bool showThinking = !isCompact || petExpanded || hasReply || petWaiting || showLlmWait;
1426
1472
  bool showTimeline = petExpanded || isDetailed;
1427
1473
  float replyH = showThinking ? (isDetailed && !petExpanded ? 42f * s : 26f * s) : 0f;
1428
- bool hasReply = !petFinished && petReply.Length > 0;
1429
1474
  string progressPrefix = hasReply ? "说明 · " : "思考 · ";
1430
1475
  string progressBody = hasReply ? petReply : petThinking;
1431
- string progress = petFinished ? "已交还电脑控制" : progressBody.Length > 0 ? progressPrefix + progressBody : "正在操作,等待下一步…";
1476
+ string progress = petFinished ? "已交还电脑控制"
1477
+ : petWaiting ? ("等待画面变化… " + waitSec + "s(点右上角 ⏭ 可提前继续)")
1478
+ : progressBody.Length > 0 ? progressPrefix + progressBody
1479
+ : showLlmWait ? ("等待模型响应中… " + llmSec + "s")
1480
+ : "正在操作,等待下一步…";
1432
1481
  if (showThinking && (petExpanded || isDetailed))
1433
1482
  {
1434
1483
  using (var probe = new Bitmap(1, 1))
@@ -1837,17 +1886,19 @@ namespace DshComputerUse
1837
1886
  if (nCode >= 0 && visible)
1838
1887
  {
1839
1888
  int msg = wParam.ToInt32();
1840
- // Hardware-rate cursor tracking on WM_MOUSEMOVE: never triggers takeover, only moves
1841
- // the cached resting badge via SetWindowPos for silky native-grade responsiveness.
1889
+ // Hardware-rate cursor tracking on WM_MOUSEMOVE (throttled to ~60Hz so 1000Hz mice
1890
+ // never flood the UI thread): never triggers takeover, only moves the cached badge.
1842
1891
  if (msg == 0x0200)
1843
1892
  {
1844
- if (clickTargetEnabled && !petFinished && markActive && markIsResting && invoker != null)
1893
+ if (clickTargetEnabled && !petFinished && !paused && markActive && markIsResting && invoker != null)
1845
1894
  {
1846
1895
  var mm = (Native.MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(Native.MSLLHOOKSTRUCT));
1847
1896
  latestMouseX = mm.pt.X;
1848
1897
  latestMouseY = mm.pt.Y;
1849
- if (Interlocked.Exchange(ref mouseMovePending, 1) == 0)
1898
+ int tick = Environment.TickCount;
1899
+ if (unchecked(tick - lastMouseMoveTick) >= 16 && Interlocked.Exchange(ref mouseMovePending, 1) == 0)
1850
1900
  {
1901
+ lastMouseMoveTick = tick;
1851
1902
  try { invoker.BeginInvoke((MethodInvoker)SyncRestingCursorOnUi); }
1852
1903
  catch (Exception) { Interlocked.Exchange(ref mouseMovePending, 0); }
1853
1904
  }
package/helper/Program.cs CHANGED
@@ -231,6 +231,7 @@ namespace DshComputerUse
231
231
  case "overlay_show": Overlay.ExcludeFromCapture = Args.Bool(r, "excludeFromCapture", true); Overlay.Show(r); return null;
232
232
  case "overlay_pause": Overlay.SetPaused(Args.Bool(r, "paused", false)); return null;
233
233
  case "overlay_waiting": Overlay.SetWaiting(Args.Bool(r, "waiting", false)); return null;
234
+ case "overlay_phase": Overlay.SetPhase(Args.Str(r, "phase", "")); return null;
234
235
  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));
235
236
  case "window_uncard": return Windows.Uncard(new IntPtr(Convert.ToInt64(r["hwnd"])));
236
237
  case "overlay_status": Overlay.Status(Args.Str(r, "status", "")); return null;
package/lib/index.js CHANGED
@@ -1270,9 +1270,10 @@ var OverlayController = class {
1270
1270
  if (controlSignal?.aborted) onControlAbort();
1271
1271
  else controlSignal?.addEventListener("abort", onControlAbort, { once: true });
1272
1272
  this.waitSkippers.add(skip);
1273
- this.helper.call("overlay_waiting", { waiting: true }).catch(() => {});
1273
+ const ready = this.helper.call("overlay_waiting", { waiting: true }, 2e3).then(() => {}, () => {});
1274
1274
  return {
1275
1275
  signal: ctrl.signal,
1276
+ ready,
1276
1277
  skipped: () => wasSkipped && !signal.aborted && !wasStopped,
1277
1278
  controlStopped: () => wasStopped,
1278
1279
  done: () => {
@@ -1285,6 +1286,14 @@ var OverlayController = class {
1285
1286
  }
1286
1287
  };
1287
1288
  }
1289
+ /** Mark that the computer-use tool finished and we are now waiting for the LLM API response. */
1290
+ awaitingModel(agent) {
1291
+ if (!this.visible || this.paused || this.stopping) return;
1292
+ if (agent !== void 0 && this.agent !== void 0 && agent !== this.agent) return;
1293
+ this.thinking = "";
1294
+ this.reply = "";
1295
+ this.helper.call("overlay_phase", { phase: "llm" }).catch(() => {});
1296
+ }
1288
1297
  recordUserAction(action) {
1289
1298
  const prev = this.userActions.at(-1);
1290
1299
  if (action.kind === "type" && prev?.kind === "type" && prev.exe === action.exe && prev.role === action.role && prev.name === action.name && action.at - prev.at < 8e3) {
@@ -1366,6 +1375,7 @@ var OverlayController = class {
1366
1375
  this.cardOpacity = settings.cardOpacity;
1367
1376
  await this.helper.call("card_opacity", { opacity: settings.cardOpacity }).catch(() => {});
1368
1377
  }
1378
+ this.helper.call("overlay_phase", { phase: "tool" }).catch(() => {});
1369
1379
  await this.status(status);
1370
1380
  }
1371
1381
  async start(agent, status, settings) {
@@ -1436,6 +1446,7 @@ var OverlayController = class {
1436
1446
  if (frame.type === "start") {
1437
1447
  this.thinking = "";
1438
1448
  this.reply = "";
1449
+ if (this.visible && agent === this.agent) this.helper.call("overlay_phase", { phase: "llm" }).catch(() => {});
1439
1450
  this.schedulePush();
1440
1451
  return;
1441
1452
  }
@@ -1444,6 +1455,7 @@ var OverlayController = class {
1444
1455
  if (!chunk) return;
1445
1456
  if (chunk.type === "text-delta" && chunk.text) {
1446
1457
  if (this.visible && this.agent && agent === this.agent && !this.paused && !this.stopping) {
1458
+ this.helper.call("overlay_phase", { phase: "" }).catch(() => {});
1447
1459
  if (this.settings().hostWindow === "pet") {
1448
1460
  this.reply = plainLine(this.reply + chunk.text).slice(-300);
1449
1461
  this.schedulePush();
@@ -1455,6 +1467,7 @@ var OverlayController = class {
1455
1467
  return;
1456
1468
  }
1457
1469
  if (chunk.type !== "reasoning-delta" || !chunk.text) return;
1470
+ if (this.thinking === "" && this.visible && agent === this.agent) this.helper.call("overlay_phase", { phase: "" }).catch(() => {});
1458
1471
  this.reply = "";
1459
1472
  this.thinking = plainLine(this.thinking + chunk.text).slice(-300);
1460
1473
  this.schedulePush();
@@ -2086,11 +2099,11 @@ var Computer = class Computer {
2086
2099
  height: display.height,
2087
2100
  minMs: 300,
2088
2101
  maxMs,
2089
- quietMs: waitForChange ? 1100 : 800,
2102
+ quietMs: waitForChange ? 800 : 600,
2090
2103
  ...waitForChange ? {
2091
2104
  waitForChange: true,
2092
- checkpointMs: 5e3,
2093
- noChangeMaxMs: Math.min(maxMs, 8e3)
2105
+ checkpointMs: 3500,
2106
+ noChangeMaxMs: Math.min(maxMs, 4e3)
2094
2107
  } : {}
2095
2108
  }, maxMs + 1e4).catch(() => null);
2096
2109
  const abortPromise = new Promise((resolve) => {
@@ -2720,6 +2733,7 @@ var Computer = class Computer {
2720
2733
  case "wait": {
2721
2734
  const wait = this.overlay.beginWait?.(call.signal);
2722
2735
  try {
2736
+ if (wait?.ready) await wait.ready;
2723
2737
  if (input.until) return { text: await this.waitUntil(input, call.signal, wait) };
2724
2738
  const seconds = Math.min(30, Math.max(0, Number(input.duration ?? 1) || 0));
2725
2739
  const res = await this.waitForQuiet(seconds * 1e3, call.signal, wait);
@@ -3268,6 +3282,7 @@ var HelperClient = class HelperClient {
3268
3282
  pending = /* @__PURE__ */ new Map();
3269
3283
  listeners = /* @__PURE__ */ new Set();
3270
3284
  cardChildren = /* @__PURE__ */ new WeakSet();
3285
+ overlayChildren = /* @__PURE__ */ new WeakSet();
3271
3286
  nextId = 0;
3272
3287
  disposed = false;
3273
3288
  constructor(log = () => {}) {
@@ -3296,7 +3311,9 @@ var HelperClient = class HelperClient {
3296
3311
  timer,
3297
3312
  child
3298
3313
  });
3299
- if (cmd === "window_card" || cmd === "overlay_show") this.cardChildren.add(child);
3314
+ if (cmd === "window_card") this.cardChildren.add(child);
3315
+ else if (cmd === "overlay_show") this.overlayChildren.add(child);
3316
+ else if (cmd === "overlay_hide") this.overlayChildren.delete(child);
3300
3317
  child.stdin.write(`${JSON.stringify({
3301
3318
  ...args,
3302
3319
  id,
@@ -3392,7 +3409,7 @@ var HelperClient = class HelperClient {
3392
3409
  entry.reject(/* @__PURE__ */ new Error(`computer-use helper exited (code ${String(code)})`));
3393
3410
  this.pending.delete(id);
3394
3411
  }
3395
- if (this.cardChildren.has(child) && (!this.disposed || code !== 0)) {
3412
+ if ((this.cardChildren.has(child) || this.overlayChildren.has(child)) && (!this.disposed || code !== 0)) {
3396
3413
  const recovery = this.disposed ? new HelperClient(this.log) : this;
3397
3414
  recovery.call("window_recover").catch((error) => {
3398
3415
  if (!recovery.disposed) this.log(`recover host window: ${String(error)}`);
@@ -12153,7 +12170,7 @@ function apply(ctx, config = {}) {
12153
12170
  ctx.on("agent/assistant-stream", ({ agent, frame }) => {
12154
12171
  overlay.stream(agent, frame);
12155
12172
  });
12156
- ctx.on("tools/pre-execute", (exec, next) => {
12173
+ ctx.on("tools/pre-execute", async (exec, next) => {
12157
12174
  if (!OWN_TOOLS.has(exec.name)) {
12158
12175
  const args = exec.arguments ?? {};
12159
12176
  const detail = [
@@ -12164,8 +12181,13 @@ function apply(ctx, config = {}) {
12164
12181
  args.url
12165
12182
  ].find((value) => typeof value === "string");
12166
12183
  overlay.toolStarted(exec.agent, exec.name, (detail ?? "").split("\n")[0].slice(0, 120));
12184
+ return next();
12185
+ }
12186
+ try {
12187
+ return await next();
12188
+ } finally {
12189
+ overlay.awaitingModel(exec.agent);
12167
12190
  }
12168
- return next();
12169
12191
  });
12170
12192
  overlay.onMessage = (agent, text) => {
12171
12193
  const steer = agent.steer;
@@ -24,6 +24,7 @@ export declare class HelperClient implements HelperLike {
24
24
  private readonly pending;
25
25
  private readonly listeners;
26
26
  private readonly cardChildren;
27
+ private readonly overlayChildren;
27
28
  private nextId;
28
29
  private disposed;
29
30
  constructor(log?: (message: string) => void);
@@ -76,6 +76,7 @@ export declare function cardRect(display: DisplayRow): {
76
76
  export declare const CONTROL_STOPPED_MESSAGE = "The user stopped computer control and returned to DeepSeek Harness. Do not perform further desktop actions unless the user asks again; summarize your progress and reply in DeepSeek Harness.";
77
77
  export interface WaitHandle {
78
78
  readonly signal: AbortSignal;
79
+ readonly ready: Promise<void>;
79
80
  skipped(): boolean;
80
81
  controlStopped(): boolean;
81
82
  done(): void;
@@ -134,6 +135,8 @@ export declare class OverlayController {
134
135
  private skipActiveWaits;
135
136
  /** Register an active wait so the Pet card / pill exposes the "跳过等待" button. */
136
137
  beginWait(signal: AbortSignal): WaitHandle;
138
+ /** Mark that the computer-use tool finished and we are now waiting for the LLM API response. */
139
+ awaitingModel(agent: unknown): void;
137
140
  private recordUserAction;
138
141
  /** Whether the user has performed physical mouse/keyboard actions not yet reported to the model. */
139
142
  hasUserActions(): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@copylee/dsh-computer-use",
3
- "version": "0.14.1",
3
+ "version": "0.14.2",
4
4
  "description": "DeepSeek Harness Computer Use 插件(Windows):让 AI 看屏幕、点鼠标、敲键盘操控电脑;控制时屏幕泛起橙色光晕并显示“DeepSeek Harness 正在操控你的电脑”,按 Esc 暂停 / 继续。",
5
5
  "icon": "assets/icon.svg",
6
6
  "type": "module",