@copylee/dsh-computer-use 0.13.0 → 0.13.1

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/Overlay.cs CHANGED
@@ -363,6 +363,7 @@ namespace DshComputerUse
363
363
  static int idleMs = 1500;
364
364
  static System.Windows.Forms.Timer timer;
365
365
  static DateTime shownAt;
366
+ static int shownTick = int.MinValue / 2;
366
367
  static IntPtr hook = IntPtr.Zero;
367
368
  static Native.LowLevelKeyboardProc hookProc;
368
369
  static IntPtr mouseHook = IntPtr.Zero;
@@ -376,9 +377,11 @@ namespace DshComputerUse
376
377
  static volatile bool visible;
377
378
  static volatile bool paused;
378
379
  static volatile bool clickTargetEnabled = true;
380
+ static string cursorBadge = "DeepSeek";
379
381
  static LayeredForm markForm;
380
382
  static DateTime markExpiresAt = DateTime.MinValue;
381
383
  static bool markActive;
384
+ static bool markIsResting;
382
385
  static int lastTyping = int.MinValue / 2;
383
386
  static int lastEmit;
384
387
  static readonly object RectLock = new object();
@@ -391,6 +394,7 @@ namespace DshComputerUse
391
394
  static LayeredForm pet;
392
395
  public static volatile IntPtr PetHwnd = IntPtr.Zero;
393
396
  static string petThinking = "";
397
+ static string petReply = "";
394
398
  static List<string> petSteps = new List<string>();
395
399
  /** Bottom-right corner of the card body; the card grows upward when expanded. */
396
400
  static Point petAnchor = Point.Empty;
@@ -468,12 +472,17 @@ namespace DshComputerUse
468
472
  string reqSize = Args.Str(r, "petSize", "");
469
473
  if (reqSize == "compact" || reqSize == "standard" || reqSize == "detailed") petSize = reqSize;
470
474
  clickTargetEnabled = Args.Bool(r, "glow", true);
475
+ string badgeSrc = label.Replace("正在操控你的电脑", "").Replace("正在操控", "").Trim();
476
+ if (badgeSrc.StartsWith("DeepSeek", StringComparison.OrdinalIgnoreCase)) cursorBadge = "DeepSeek";
477
+ else if (badgeSrc.Length > 0) cursorBadge = badgeSrc.Length > 10 ? badgeSrc.Substring(0, 10) : badgeSrc;
478
+ else cursorBadge = "AI";
471
479
  if (visible && !petFinished) { RenderPill(); return; }
472
480
  if (visible) HideCore(); // the previous run's "done" card is still up
473
481
  petMode = Args.Bool(r, "pet", false);
474
482
  hoveredBtn = "";
475
483
  pressedBtn = "";
476
484
  petThinking = Args.Str(r, "thinking", "");
485
+ petReply = "";
477
486
  petSteps = new List<string>();
478
487
  if (status.Length > 0) petSteps.Add(status);
479
488
  pillAtBottom = false;
@@ -562,7 +571,13 @@ namespace DshComputerUse
562
571
  RenderPill();
563
572
  InstallHook();
564
573
  shownAt = DateTime.UtcNow;
574
+ shownTick = Environment.TickCount;
565
575
  visible = true;
576
+ if (clickTargetEnabled)
577
+ {
578
+ Native.POINT cp;
579
+ if (Native.GetCursorPos(out cp)) ShowRestingMarkOnUi(cp.X, cp.Y);
580
+ }
566
581
  timer.Start();
567
582
  });
568
583
  }
@@ -573,14 +588,15 @@ namespace DshComputerUse
573
588
  Ui(delegate { status = newStatus; RenderPill(); });
574
589
  }
575
590
 
576
- /** Latest host-provided reasoning and recent operations, oldest first. */
577
- public static void PetUpdate(string thinking, List<string> steps)
591
+ /** Latest host-provided reasoning, brief reply text, and recent operations, oldest first. */
592
+ public static void PetUpdate(string thinking, string reply, List<string> steps)
578
593
  {
579
594
  if (thread == null || !visible || !petMode || petFinished) return;
580
595
  invoker.BeginInvoke((MethodInvoker)delegate
581
596
  {
582
597
  if (petFinished) return;
583
598
  petThinking = thinking;
599
+ petReply = reply ?? "";
584
600
  if (steps.Count > 0) petSteps = steps;
585
601
  RenderPill();
586
602
  });
@@ -624,6 +640,7 @@ namespace DshComputerUse
624
640
  HideMark();
625
641
  CloseInput(false);
626
642
  petFinished = false;
643
+ petReply = "";
627
644
  visible = false;
628
645
  paused = false;
629
646
  timer.Stop();
@@ -835,6 +852,36 @@ namespace DshComputerUse
835
852
  Mark(x, y, text, color, holdMs, capturable, ripple);
836
853
  }
837
854
 
855
+ static void ShowRestingMarkOnUi(int x, int y)
856
+ {
857
+ lastMarkX = x;
858
+ lastMarkY = y;
859
+ hasLastMark = true;
860
+ if (markForm == null)
861
+ {
862
+ markForm = new LayeredForm(true);
863
+ markForm.Show();
864
+ }
865
+ // Resting Codex cursor stays visible to the user during control mode,
866
+ // while remaining invisible to screenshots so it never obscures target pixels.
867
+ markForm.SetCapturable(false);
868
+ float scale; Rectangle mon;
869
+ MonitorAt(x, y, out scale, out mon);
870
+ float s = Math.Max(0.75f, Math.Min(3f, scale));
871
+ int estW = (int)((Math.Max(6, cursorBadge.Length) * 11 + 36) * s);
872
+ bool flipX = !mon.IsEmpty && x + estW > mon.Right;
873
+ bool flipY = !mon.IsEmpty && y + (int)(52 * s) > mon.Bottom;
874
+ int cx, cy;
875
+ using (var bmp = DrawMark(cursorBadge, Accent, scale, flipX, flipY, false, out cx, out cy))
876
+ {
877
+ markForm.SetBitmap(bmp, new Rectangle(x - cx, y - cy, bmp.Width, bmp.Height), 255);
878
+ }
879
+ markForm.KeepOnTop();
880
+ markActive = true;
881
+ markIsResting = true;
882
+ markExpiresAt = DateTime.MaxValue;
883
+ }
884
+
838
885
  public static void Mark(int x, int y, string text, Color color, int holdMs, bool capturable, bool ripple)
839
886
  {
840
887
  lastMarkX = x;
@@ -862,6 +909,7 @@ namespace DshComputerUse
862
909
  }
863
910
  markForm.KeepOnTop();
864
911
  markActive = true;
912
+ markIsResting = false;
865
913
  markExpiresAt = holdMs > 0 ? DateTime.UtcNow.AddMilliseconds(holdMs) : DateTime.MaxValue;
866
914
  if (!timer.Enabled) timer.Start();
867
915
  });
@@ -882,6 +930,7 @@ namespace DshComputerUse
882
930
  static void HideMark()
883
931
  {
884
932
  markActive = false;
933
+ markIsResting = false;
885
934
  markExpiresAt = DateTime.MinValue;
886
935
  if (markForm != null)
887
936
  {
@@ -969,12 +1018,29 @@ namespace DshComputerUse
969
1018
 
970
1019
  static void Tick()
971
1020
  {
972
- if (markActive && DateTime.UtcNow >= markExpiresAt) HideMark();
1021
+ if (markActive && DateTime.UtcNow >= markExpiresAt)
1022
+ {
1023
+ if (visible && clickTargetEnabled && !petFinished && hasLastMark)
1024
+ ShowRestingMarkOnUi(lastMarkX, lastMarkY);
1025
+ else
1026
+ HideMark();
1027
+ }
973
1028
  if (!visible)
974
1029
  {
975
1030
  if (!markActive) timer.Stop();
976
1031
  return;
977
1032
  }
1033
+ if (visible && clickTargetEnabled && !petFinished && !markActive)
1034
+ {
1035
+ Native.POINT cp;
1036
+ if (Native.GetCursorPos(out cp)) ShowRestingMarkOnUi(cp.X, cp.Y);
1037
+ }
1038
+ else if (visible && clickTargetEnabled && !petFinished && markActive && markIsResting)
1039
+ {
1040
+ Native.POINT cp;
1041
+ if (Native.GetCursorPos(out cp) && (Math.Abs(cp.X - lastMarkX) > 2 || Math.Abs(cp.Y - lastMarkY) > 2))
1042
+ ShowRestingMarkOnUi(cp.X, cp.Y);
1043
+ }
978
1044
  if (petFinished)
979
1045
  {
980
1046
  Native.POINT p; Native.GetCursorPos(out p);
@@ -1175,10 +1241,13 @@ namespace DshComputerUse
1175
1241
  float bodyW = (isCompact ? 320f : isDetailed ? 484f : 420f) * s;
1176
1242
  float pad = (isCompact ? 13f : 16f) * s;
1177
1243
  float headH = (isCompact ? 40f : 44f) * s;
1178
- bool showThinking = !isCompact || petExpanded;
1244
+ bool showThinking = !isCompact || petExpanded || (!petFinished && petReply.Length > 0);
1179
1245
  bool showTimeline = petExpanded || isDetailed;
1180
1246
  float replyH = showThinking ? (isDetailed && !petExpanded ? 42f * s : 26f * s) : 0f;
1181
- string progress = petFinished ? "已交还电脑控制" : petThinking.Length > 0 ? "思考 · " + petThinking : "正在操作,等待下一步…";
1247
+ bool hasReply = !petFinished && petReply.Length > 0;
1248
+ string progressPrefix = hasReply ? "说明 · " : "思考 · ";
1249
+ string progressBody = hasReply ? petReply : petThinking;
1250
+ string progress = petFinished ? "已交还电脑控制" : progressBody.Length > 0 ? progressPrefix + progressBody : "正在操作,等待下一步…";
1182
1251
  if (showThinking && (petExpanded || isDetailed))
1183
1252
  {
1184
1253
  using (var probe = new Bitmap(1, 1))
@@ -1299,14 +1368,14 @@ namespace DshComputerUse
1299
1368
  float ry = body.Y + headH;
1300
1369
  if (showThinking)
1301
1370
  {
1302
- using (var b = new SolidBrush(petThinking.Length > 0 && !petFinished ? ink : muted))
1371
+ using (var b = new SolidBrush(progressBody.Length > 0 && !petFinished ? ink : muted))
1303
1372
  {
1304
1373
  if (petExpanded || isDetailed)
1305
1374
  g.DrawString(TailWrapped(g, progress, fText, lineW, replyH, wrap), fText, b, new RectangleF(body.X + pad, ry, lineW, replyH), wrap);
1306
1375
  else
1307
1376
  {
1308
- string shown = petThinking.Length > 0 && !petFinished
1309
- ? "思考 · " + Tail(g, petThinking, fText, lineW - g.MeasureString("思考 · ", fText, 100000, fmt).Width, fmt)
1377
+ string shown = progressBody.Length > 0 && !petFinished
1378
+ ? progressPrefix + Tail(g, progressBody, fText, lineW - g.MeasureString(progressPrefix, fText, 100000, fmt).Width, fmt)
1310
1379
  : Tail(g, progress, fText, lineW, fmt);
1311
1380
  SizeF size = g.MeasureString(shown.Length > 0 ? shown : " ", fText, 100000, fmt);
1312
1381
  g.DrawString(shown, fText, b, body.X + pad, ry + (replyH - size.Height) / 2f, fmt);
@@ -1590,10 +1659,11 @@ namespace DshComputerUse
1590
1659
  if (isClick || isWheel)
1591
1660
  {
1592
1661
  var ms = (Native.MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(Native.MSLLHOOKSTRUCT));
1593
- // Ignore synthetic clicks injected by our own SendInput (LLMHF_INJECTED = 0x01, lower IL = 0x02).
1594
- if ((ms.flags & 0x03) == 0 && ms.dwExtraInfo != Native.Marker && !IsOnOwnUi(ms.pt.X, ms.pt.Y))
1662
+ // Ignore synthetic clicks injected by our own SendInput (LLMHF_INJECTED = 0x01, lower IL = 0x02),
1663
+ // and ignore trailing clicks during the first 350ms after control mode begins.
1664
+ int now = Environment.TickCount;
1665
+ if ((ms.flags & 0x03) == 0 && ms.dwExtraInfo != Native.Marker && unchecked(now - shownTick) >= 350 && !IsOnOwnUi(ms.pt.X, ms.pt.Y))
1595
1666
  {
1596
- int now = Environment.TickCount;
1597
1667
  lastTyping = now;
1598
1668
  if (isClick)
1599
1669
  {
package/helper/Program.cs CHANGED
@@ -231,7 +231,7 @@ namespace DshComputerUse
231
231
  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));
232
232
  case "window_uncard": return Windows.Uncard(new IntPtr(Convert.ToInt64(r["hwnd"])));
233
233
  case "overlay_status": Overlay.Status(Args.Str(r, "status", "")); return null;
234
- case "pet_update": Overlay.PetUpdate(Args.Str(r, "thinking", ""), Args.Strs(r, "steps")); return null;
234
+ case "pet_update": Overlay.PetUpdate(Args.Str(r, "thinking", ""), Args.Str(r, "reply", ""), Args.Strs(r, "steps")); return null;
235
235
  case "pet_finish": Overlay.Finish(Args.Int(r, "holdMs", 4000)); return null;
236
236
  case "overlay_hide": Overlay.Hide(); return null;
237
237
  default: throw new Exception("unknown command: " + cmd);
package/helper/Uia.cs CHANGED
@@ -430,6 +430,22 @@ namespace DshComputerUse
430
430
 
431
431
  const int ReadLimit = 200000;
432
432
 
433
+ static bool IsAddressBar(AutomationElement el)
434
+ {
435
+ try
436
+ {
437
+ if (el.Current.ControlType != ControlType.Edit) return false;
438
+ string aid = el.Current.AutomationId ?? "";
439
+ if (aid.Equals("addressEditBox", StringComparison.OrdinalIgnoreCase)) return true;
440
+ string name = el.Current.Name ?? "";
441
+ return name.IndexOf("地址和搜索栏", StringComparison.OrdinalIgnoreCase) >= 0
442
+ || name.IndexOf("Address and search bar", StringComparison.OrdinalIgnoreCase) >= 0
443
+ || name.IndexOf("Search or enter web address", StringComparison.OrdinalIgnoreCase) >= 0
444
+ || name.IndexOf("搜索或输入网址", StringComparison.OrdinalIgnoreCase) >= 0;
445
+ }
446
+ catch (Exception) { return false; }
447
+ }
448
+
433
449
  static string Read(IntPtr hwnd, out string source)
434
450
  {
435
451
  var root = AutomationElement.FromHandle(hwnd);
@@ -444,6 +460,7 @@ namespace DshComputerUse
444
460
  if (++looked > 40) break;
445
461
  try
446
462
  {
463
+ if (IsAddressBar(el)) continue;
447
464
  var rect = el.Current.BoundingRectangle;
448
465
  double area = rect.IsEmpty ? 0 : rect.Width * rect.Height;
449
466
  if (area <= bestArea) continue;
@@ -457,7 +474,7 @@ namespace DshComputerUse
457
474
  }
458
475
  if (best.Length > 0) { source = "text"; return best; }
459
476
 
460
- // 2. The longest value of an edit or document control.
477
+ // 2. The longest value of an edit or document control (excluding browser URL address bars).
461
478
  var withValue = root.FindAll(TreeScope.Subtree, new AndCondition(visible, new PropertyCondition(AutomationElement.IsValuePatternAvailableProperty, true)));
462
479
  looked = 0;
463
480
  foreach (AutomationElement el in withValue)
@@ -465,7 +482,7 @@ namespace DshComputerUse
465
482
  if (++looked > 200) break;
466
483
  try
467
484
  {
468
- if (IsPasswordElement(el)) continue;
485
+ if (IsPasswordElement(el) || IsAddressBar(el)) continue;
469
486
  object pattern;
470
487
  if (!el.TryGetCurrentPattern(ValuePattern.Pattern, out pattern)) continue;
471
488
  string got = ((ValuePattern)pattern).Current.Value;
package/lib/client.js CHANGED
@@ -690,18 +690,33 @@ window.__ModuleLoader__.load({
690
690
  //#endregion
691
691
  //#region lib/types/client/skills-card.js
692
692
  /**
693
- * "应用技能" card: the per-app notes the agent keeps (see ../skills.ts). The
694
- * user can read, edit, add and delete them here; built-in skills can be
695
- * overridden and restored.
693
+ * "应用技能" card: per-app notes the agent keeps (see ../skills.ts).
694
+ * Compact collapsible list with live search & source filter, plus a centered
695
+ * modal dialog for viewing, editing, and creating skills.
696
696
  */
697
697
  const SKILLS_ROUTE = "/api/dsh-computer-use/skills";
698
698
  const MAX_CHARS = 4e3;
699
699
  const h$1 = react.createElement;
700
+ const modalCss = `
701
+ @keyframes dshcu-backdrop-in{from{opacity:0}to{opacity:1}}
702
+ @keyframes dshcu-modal-in{from{opacity:0;transform:translateY(8px) scale(.97)}to{opacity:1;transform:translateY(0) scale(1)}}
703
+ .dshcu-skill-list{max-height:300px;overflow-y:auto;padding-right:2px;display:grid;gap:2px}
704
+ .dshcu-skill-row{display:flex;gap:10px;align-items:center;padding:9px 10px;border-radius:10px;border:1px solid transparent;transition:background .15s ease,border-color .15s ease}
705
+ .dshcu-skill-row:hover{background:var(--dsw-alias-bg-layer-2,rgba(127,127,127,.07));border-color:var(--dsw-alias-border-l2,rgba(127,127,127,.18))}
706
+ .dshcu-chip-tab{padding:4px 10px;border-radius:999px;font-size:12px;cursor:pointer;border:1px solid var(--dsw-alias-border-l2,rgba(127,127,127,.25));background:transparent;color:var(--dsw-alias-label-secondary,#666);transition:background .15s ease,color .15s ease,border-color .15s ease}
707
+ .dshcu-chip-tab:hover{background:var(--dsw-alias-bg-layer-2,rgba(127,127,127,.08))}
708
+ .dshcu-chip-tab[data-active="true"]{background:var(--dshcu-accent-soft,rgba(217,119,87,.14));color:var(--dshcu-accent,#d97757);border-color:var(--dshcu-accent,#d97757);font-weight:600}
709
+ .dshcu-modal-backdrop{position:fixed;inset:0;z-index:9999;background:rgba(15,15,18,.48);backdrop-filter:blur(4px);display:flex;align-items:center;justify-content:center;padding:20px;animation:dshcu-backdrop-in .16s ease}
710
+ .dshcu-modal{width:min(640px,100%);max-height:min(86vh,720px);display:flex;flex-direction:column;border-radius:16px;background:var(--dsw-alias-bg-layer-1,#fff);color:var(--dsw-alias-label-primary,inherit);border:1px solid var(--dsw-alias-border-l2,rgba(127,127,127,.25));box-shadow:0 24px 64px rgba(0,0,0,.28);overflow:hidden;animation:dshcu-modal-in .18s cubic-bezier(.16,1,.3,1)}
711
+ `;
700
712
  function SkillsCard({ S }) {
701
713
  const [skills, setSkills] = react.useState(null);
702
714
  const [dir, setDir] = react.useState("");
703
715
  const [draft, setDraft] = react.useState(null);
704
716
  const [busy, setBusy] = react.useState(false);
717
+ const [expanded, setExpanded] = react.useState(false);
718
+ const [query, setQuery] = react.useState("");
719
+ const [filter, setFilter] = react.useState("all");
705
720
  const [note, setNote] = react.useState(null);
706
721
  const call = react.useCallback(async (body) => {
707
722
  setBusy(true);
@@ -729,6 +744,14 @@ window.__ModuleLoader__.load({
729
744
  react.useEffect(() => {
730
745
  call();
731
746
  }, [call]);
747
+ react.useEffect(() => {
748
+ if (!draft) return;
749
+ const onKey = (e) => {
750
+ if (e.key === "Escape" && !busy) setDraft(null);
751
+ };
752
+ window.addEventListener("keydown", onKey);
753
+ return () => window.removeEventListener("keydown", onKey);
754
+ }, [draft, busy]);
732
755
  const edit = (skill) => {
733
756
  setNote(null);
734
757
  setDraft({
@@ -737,7 +760,20 @@ window.__ModuleLoader__.load({
737
760
  match: skill.match.join(", "),
738
761
  summary: skill.summary,
739
762
  content: skill.content,
740
- isNew: false
763
+ isNew: false,
764
+ source: skill.source,
765
+ overrides: skill.overrides
766
+ });
767
+ };
768
+ const openNew = () => {
769
+ setNote(null);
770
+ setDraft({
771
+ id: "",
772
+ app: "",
773
+ match: "",
774
+ summary: "",
775
+ content: "",
776
+ isNew: true
741
777
  });
742
778
  };
743
779
  const save = async () => {
@@ -771,26 +807,30 @@ window.__ModuleLoader__.load({
771
807
  });
772
808
  }
773
809
  };
774
- const reset = async (skill) => {
810
+ const reset = async (id, app) => {
775
811
  setNote(null);
776
812
  if (await call({
777
813
  op: "reset",
778
- id: skill.id
814
+ id
779
815
  })) {
780
- if (draft?.id === skill.id) setDraft(null);
816
+ if (draft?.id === id) setDraft(null);
781
817
  setNote({
782
818
  kind: "ok",
783
- text: `已恢复“${skill.app}”的内置版本`
819
+ text: `已恢复“${app}”的内置版本`
784
820
  });
785
821
  }
786
822
  };
787
- const row = {
788
- display: "flex",
789
- gap: 10,
790
- alignItems: "center",
791
- padding: "8px 0",
792
- borderTop: "1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.18))"
793
- };
823
+ const allSkills = skills ?? [];
824
+ const userCount = allSkills.filter((s) => s.source !== "builtin").length;
825
+ const builtinCount = allSkills.length - userCount;
826
+ const q = query.trim().toLowerCase();
827
+ const showList = expanded || q.length > 0;
828
+ const filtered = allSkills.filter((skill) => {
829
+ if (filter === "user" && skill.source === "builtin") return false;
830
+ if (filter === "builtin" && skill.source !== "builtin") return false;
831
+ if (!q) return true;
832
+ return skill.app.toLowerCase().includes(q) || skill.summary.toLowerCase().includes(q) || skill.match.some((m) => m.toLowerCase().includes(q));
833
+ });
794
834
  const small = {
795
835
  ...S.secondary,
796
836
  padding: "4px 10px",
@@ -805,9 +845,105 @@ window.__ModuleLoader__.load({
805
845
  whiteSpace: "nowrap"
806
846
  };
807
847
  const invalid = draft !== null && (draft.app.trim() === "" || draft.content.trim() === "" || draft.content.length > MAX_CHARS);
808
- return h$1("section", { style: S.card }, h$1("h3", { style: S.cardTitle }, "应用技能"), h$1("p", { style: S.hint }, "AI 对各个应用的操作笔记:每个应用一份,AI 摸索清楚一个不熟悉的应用后会自己记下来,以后打开这个应用时自动读取,不占用系统提示。你可以在这里查看、修改、删除或新建。"), skills === null ? h$1("p", { style: S.hint }, busy ? "正在读取…" : "无法读取应用技能。") : skills.length === 0 ? h$1("p", { style: S.hint }, "还没有应用技能。") : h$1("div", null, ...skills.map((skill) => h$1("div", {
848
+ return h$1("section", {
849
+ className: "dshcu-card",
850
+ style: S.card
851
+ }, h$1("style", null, modalCss), h$1("div", { style: {
852
+ display: "flex",
853
+ alignItems: "center",
854
+ justifyContent: "space-between",
855
+ gap: 10,
856
+ flexWrap: "wrap"
857
+ } }, h$1("div", { style: {
858
+ display: "flex",
859
+ alignItems: "center",
860
+ gap: 8,
861
+ flexWrap: "wrap"
862
+ } }, h$1("h3", { style: S.cardTitle }, "应用技能"), skills !== null ? h$1("span", {
863
+ className: "dshcu-badge",
864
+ style: tag
865
+ }, `共 ${allSkills.length} 项 · ${userCount} 自定义 / ${builtinCount} 内置`) : null), h$1("div", { style: {
866
+ display: "flex",
867
+ gap: 8,
868
+ alignItems: "center"
869
+ } }, h$1("button", {
870
+ type: "button",
871
+ className: "dshcu-btn",
872
+ style: small,
873
+ disabled: busy,
874
+ onClick: openNew
875
+ }, "+ 新建技能"), h$1("button", {
876
+ type: "button",
877
+ className: "dshcu-btn",
878
+ style: small,
879
+ disabled: busy,
880
+ onClick: () => setExpanded((prev) => !prev)
881
+ }, showList && !q ? "收起列表 ▴" : `展开列表 (${allSkills.length}) ▾`))), h$1("p", { style: S.hint }, "AI 对各个应用的操作笔记:打开应用时自动读取,不占用常规系统提示。支持实时搜索,点击「查看 / 编辑」在弹窗中修改。"), h$1("div", { style: {
882
+ display: "flex",
883
+ gap: 8,
884
+ alignItems: "center",
885
+ flexWrap: "wrap"
886
+ } }, h$1("div", { style: {
887
+ position: "relative",
888
+ flex: "1 1 220px",
889
+ minWidth: 180
890
+ } }, h$1("input", {
891
+ style: {
892
+ ...S.input,
893
+ width: "100%",
894
+ boxSizing: "border-box",
895
+ paddingRight: q ? 30 : 12
896
+ },
897
+ value: query,
898
+ placeholder: "搜索应用名、进程名或摘要(输入即可过滤)…",
899
+ onChange: (e) => setQuery(e.target.value)
900
+ }), q ? h$1("button", {
901
+ type: "button",
902
+ "aria-label": "清空搜索",
903
+ onClick: () => setQuery(""),
904
+ style: {
905
+ position: "absolute",
906
+ right: 8,
907
+ top: "50%",
908
+ transform: "translateY(-50%)",
909
+ border: "none",
910
+ background: "transparent",
911
+ color: "var(--dsw-alias-label-tertiary, #888)",
912
+ cursor: "pointer",
913
+ fontSize: 15,
914
+ lineHeight: 1,
915
+ padding: "2px 4px"
916
+ }
917
+ }, "×") : null), showList ? h$1("div", { style: {
918
+ display: "flex",
919
+ gap: 6,
920
+ alignItems: "center"
921
+ } }, h$1("button", {
922
+ type: "button",
923
+ className: "dshcu-chip-tab",
924
+ "data-active": String(filter === "all"),
925
+ onClick: () => setFilter("all")
926
+ }, `全部 (${allSkills.length})`), h$1("button", {
927
+ type: "button",
928
+ className: "dshcu-chip-tab",
929
+ "data-active": String(filter === "user"),
930
+ onClick: () => setFilter("user")
931
+ }, `自定义 (${userCount})`), h$1("button", {
932
+ type: "button",
933
+ className: "dshcu-chip-tab",
934
+ "data-active": String(filter === "builtin"),
935
+ onClick: () => setFilter("builtin")
936
+ }, `内置 (${builtinCount})`), h$1("button", {
937
+ type: "button",
938
+ className: "dshcu-btn",
939
+ style: small,
940
+ disabled: busy,
941
+ onClick: () => {
942
+ call();
943
+ }
944
+ }, "刷新")) : null), skills === null ? h$1("p", { style: S.hint }, busy ? "正在读取…" : "无法读取应用技能。") : !showList ? null : filtered.length === 0 ? h$1("p", { style: S.hint }, q ? `未找到包含「${query}」的应用技能。` : "当前分类下还没有应用技能。") : h$1("div", { className: "dshcu-skill-list" }, ...filtered.map((skill) => h$1("div", {
809
945
  key: skill.id,
810
- style: row
946
+ className: "dshcu-skill-row"
811
947
  }, h$1("div", { style: {
812
948
  flex: 1,
813
949
  minWidth: 0
@@ -824,27 +960,70 @@ window.__ModuleLoader__.load({
824
960
  whiteSpace: "nowrap"
825
961
  } }, `${skill.summary || "(无摘要)"} · ${skill.content.length} 字`)), h$1("button", {
826
962
  type: "button",
963
+ className: "dshcu-btn",
827
964
  style: small,
828
965
  disabled: busy,
829
966
  onClick: () => edit(skill)
830
967
  }, "查看 / 编辑"), skill.overrides ? h$1("button", {
831
968
  type: "button",
969
+ className: "dshcu-btn",
832
970
  style: small,
833
971
  disabled: busy,
834
972
  onClick: () => {
835
- reset(skill);
973
+ reset(skill.id, skill.app);
836
974
  }
837
975
  }, "恢复内置") : null, h$1("button", {
838
976
  type: "button",
977
+ className: "dshcu-btn",
839
978
  style: small,
840
979
  disabled: busy,
841
980
  onClick: () => {
842
981
  remove(skill);
843
982
  }
844
- }, "删除")))), draft === null ? null : h$1("div", { style: {
845
- display: "grid",
983
+ }, "删除")))), note !== null ? h$1("div", { style: {
984
+ fontSize: 12,
985
+ color: (note.kind === "ok" ? S.ok : S.error)?.color
986
+ } }, note.text) : null, showList && dir ? h$1("p", { style: S.hint }, `保存位置:${dir}(每个应用一个 .md 文件,也可直接编辑)。删除内置技能后,新建同名技能即可重新启用。`) : null, draft === null ? null : h$1("div", {
987
+ className: "dshcu-modal-backdrop",
988
+ onClick: (e) => {
989
+ if (e.target === e.currentTarget && !busy) setDraft(null);
990
+ }
991
+ }, h$1("div", {
992
+ className: "dshcu-modal",
993
+ role: "dialog",
994
+ "aria-modal": "true",
995
+ "aria-label": draft.isNew ? "新建应用技能" : `编辑应用技能 ${draft.app}`
996
+ }, h$1("div", { style: {
997
+ display: "flex",
998
+ alignItems: "center",
999
+ justifyContent: "space-between",
846
1000
  gap: 10,
847
- paddingTop: 4
1001
+ padding: "16px 20px",
1002
+ borderBottom: "1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.18))"
1003
+ } }, h$1("div", { style: {
1004
+ display: "flex",
1005
+ alignItems: "center",
1006
+ gap: 8
1007
+ } }, h$1("strong", { style: { fontSize: 15 } }, draft.isNew ? "新建应用技能" : `编辑技能 · ${draft.app}`), !draft.isNew ? h$1("span", { style: tag }, draft.source === "builtin" ? "内置" : draft.overrides ? "已修改" : "AI / 自定义") : null), h$1("button", {
1008
+ type: "button",
1009
+ "aria-label": "关闭",
1010
+ disabled: busy,
1011
+ onClick: () => setDraft(null),
1012
+ style: {
1013
+ border: "none",
1014
+ background: "transparent",
1015
+ color: "var(--dsw-alias-label-secondary, #666)",
1016
+ cursor: "pointer",
1017
+ fontSize: 20,
1018
+ lineHeight: 1,
1019
+ padding: "2px 6px",
1020
+ borderRadius: 6
1021
+ }
1022
+ }, "×")), h$1("div", { style: {
1023
+ padding: "16px 20px",
1024
+ overflowY: "auto",
1025
+ display: "grid",
1026
+ gap: 12
848
1027
  } }, h$1("div", { style: S.grid2 }, h$1("label", { style: S.label }, "应用名称", h$1("input", {
849
1028
  style: S.input,
850
1029
  value: draft.app,
@@ -876,7 +1055,7 @@ window.__ModuleLoader__.load({
876
1055
  })), h$1("label", { style: S.label }, `内容(${draft.content.length} / ${MAX_CHARS} 字)`, h$1("textarea", {
877
1056
  style: {
878
1057
  ...S.input,
879
- minHeight: 200,
1058
+ minHeight: 240,
880
1059
  resize: "vertical",
881
1060
  fontFamily: "inherit",
882
1061
  lineHeight: 1.55
@@ -887,44 +1066,45 @@ window.__ModuleLoader__.load({
887
1066
  ...draft,
888
1067
  content: e.target.value
889
1068
  })
890
- })), h$1("div", { style: S.actions }, h$1("button", {
891
- type: "button",
892
- style: {
893
- ...S.primary,
894
- opacity: busy || invalid ? .5 : 1
895
- },
896
- disabled: busy || invalid,
897
- onClick: () => {
898
- save();
899
- }
900
- }, "保存技能"), h$1("button", {
901
- type: "button",
902
- style: S.secondary,
903
- disabled: busy,
904
- onClick: () => setDraft(null)
905
- }, "取消"), draft.content.length > MAX_CHARS ? h$1("span", { style: S.error }, "内容过长,请精简") : null)), h$1("div", { style: S.actions }, draft === null ? h$1("button", {
1069
+ })), draft.content.length > MAX_CHARS ? h$1("span", { style: S.error }, "内容过长,请精简至 4000 字以内") : null), h$1("div", { style: {
1070
+ display: "flex",
1071
+ alignItems: "center",
1072
+ justifyContent: "space-between",
1073
+ gap: 10,
1074
+ padding: "14px 20px",
1075
+ borderTop: "1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.18))"
1076
+ } }, h$1("div", { style: {
1077
+ display: "flex",
1078
+ gap: 8
1079
+ } }, !draft.isNew && draft.overrides ? h$1("button", {
906
1080
  type: "button",
1081
+ className: "dshcu-btn",
907
1082
  style: S.secondary,
908
1083
  disabled: busy,
909
1084
  onClick: () => {
910
- setNote(null);
911
- setDraft({
912
- id: "",
913
- app: "",
914
- match: "",
915
- summary: "",
916
- content: "",
917
- isNew: true
918
- });
1085
+ reset(draft.id, draft.app);
919
1086
  }
920
- }, "新建技能") : null, h$1("button", {
1087
+ }, "恢复内置版本") : null), h$1("div", { style: {
1088
+ display: "flex",
1089
+ gap: 8
1090
+ } }, h$1("button", {
921
1091
  type: "button",
1092
+ className: "dshcu-btn",
922
1093
  style: S.secondary,
923
1094
  disabled: busy,
1095
+ onClick: () => setDraft(null)
1096
+ }, "取消"), h$1("button", {
1097
+ type: "button",
1098
+ className: "dshcu-btn",
1099
+ style: {
1100
+ ...S.primary,
1101
+ opacity: busy || invalid ? .5 : 1
1102
+ },
1103
+ disabled: busy || invalid,
924
1104
  onClick: () => {
925
- call();
1105
+ save();
926
1106
  }
927
- }, "刷新"), note === null ? null : h$1("span", { style: note.kind === "ok" ? S.ok : S.error }, note.text)), dir ? h$1("p", { style: S.hint }, `保存位置:${dir}(每个应用一个 .md 文件,也可以直接用编辑器改)。删除内置技能后,新建同名技能即可重新启用。`) : null);
1107
+ }, "保存技能"))))));
928
1108
  }
929
1109
  //#endregion
930
1110
  //#region lib/types/client/window-refs.js
package/lib/index.js CHANGED
@@ -3024,9 +3024,10 @@ var OverlayController = class {
3024
3024
  workTab;
3025
3025
  starting;
3026
3026
  stopping = false;
3027
- /** Progress card lines: host-provided reasoning and recent operations. */
3027
+ /** Progress card lines: host-provided reasoning, brief mid-turn reply, and recent operations. */
3028
3028
  streamAgent;
3029
3029
  thinking = "";
3030
+ reply = "";
3030
3031
  /** Recent steps (tool actions), oldest first. */
3031
3032
  steps = [];
3032
3033
  resume;
@@ -3128,6 +3129,7 @@ var OverlayController = class {
3128
3129
  await this.ending;
3129
3130
  await this.starting;
3130
3131
  if (agent) this.agent = agent;
3132
+ this.reply = "";
3131
3133
  this.armIdle();
3132
3134
  this.armUnused();
3133
3135
  const settings = this.settings();
@@ -3212,21 +3214,32 @@ var OverlayController = class {
3212
3214
  if (agent !== this.streamAgent) {
3213
3215
  this.streamAgent = agent;
3214
3216
  this.thinking = "";
3217
+ this.reply = "";
3215
3218
  this.steps = [];
3216
3219
  }
3217
3220
  if (frame.type === "start") {
3218
3221
  this.thinking = "";
3222
+ this.reply = "";
3219
3223
  this.schedulePush();
3220
3224
  return;
3221
3225
  }
3222
3226
  if (this.visible && agent === this.agent) this.armIdle();
3223
3227
  const chunk = frame.type === "chunk" ? frame.chunk : void 0;
3224
3228
  if (!chunk) return;
3225
- if (chunk.type === "text-delta" && chunk.text?.trim()) {
3226
- if (this.visible && this.agent && agent === this.agent && !this.paused && !this.stopping) this.end(this.agent, true).catch((error) => this.log(`reply handoff: ${String(error)}`));
3229
+ if (chunk.type === "text-delta" && chunk.text) {
3230
+ if (this.visible && this.agent && agent === this.agent && !this.paused && !this.stopping) {
3231
+ if (this.settings().hostWindow === "pet") {
3232
+ this.reply = plainLine(this.reply + chunk.text).slice(-300);
3233
+ this.schedulePush();
3234
+ if (this.reply.length >= 260) this.end(this.agent, true).catch((error) => this.log(`reply handoff: ${String(error)}`));
3235
+ return;
3236
+ }
3237
+ if (chunk.text.trim()) this.end(this.agent, true).catch((error) => this.log(`reply handoff: ${String(error)}`));
3238
+ }
3227
3239
  return;
3228
3240
  }
3229
3241
  if (chunk.type !== "reasoning-delta" || !chunk.text) return;
3242
+ this.reply = "";
3230
3243
  this.thinking = plainLine(this.thinking + chunk.text).slice(-300);
3231
3244
  this.schedulePush();
3232
3245
  }
@@ -3250,6 +3263,7 @@ var OverlayController = class {
3250
3263
  if (!this.visible) return;
3251
3264
  this.helper.call("pet_update", {
3252
3265
  thinking: this.thinking.trim(),
3266
+ ...this.reply.trim() ? { reply: this.reply.trim() } : {},
3253
3267
  steps: this.steps
3254
3268
  }).catch(() => {});
3255
3269
  }, 80);
@@ -3470,7 +3484,7 @@ var OverlayController = class {
3470
3484
  function promptText(mode) {
3471
3485
  return `# Computer use (Windows desktop)
3472
3486
  You can see and operate the user's Windows computer with the computer, computer_batch, open_application, windows, ui_elements, clipboard and app_skill tools.
3473
- ${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" : ""}- If the task begins with an app, open it right away with open_application (after request_access when the app is not granted yet): it returns the screenshot, so do not take one first. Otherwise 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.
3487
+ ${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" : "- Access mode is allow-all: you do not need to call list_granted_applications or request_access; open or operate apps directly.\n"}- If the task begins with an app, open it right away with open_application (after request_access when the app is not granted yet): it returns the screenshot, so do not take one first. Otherwise 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.
3474
3488
  - 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. Apps closed to the system tray (QQ, 微信...) are still running: open_application restores them from their tray icon. Do not start a second copy of a running app unless the user explicitly asks for one (then pass new_instance: true), and never show or kill its hidden windows from a shell (Electron / Qt apps freeze, and a second QQ / WeChat asks for another login).
3475
3489
  - When the task is done, tidy up: close windows and dialogs you opened that the user no longer needs (keep the one showing the result they asked for), and call windows tidy to minimize again the apps that were minimized or in the tray before you started. Never close windows the user already had open.
3476
3490
  - The "DeepSeek Harness.exe" window is your own chat interface. While you control the computer it floats as a card that only the user sees: your screenshots show what is underneath it and your clicks and scrolls pass through it, so simply ignore it. Never type into DeepSeek Harness; keys go to the window you were working in.
@@ -10694,6 +10708,7 @@ function createTools(host) {
10694
10708
  if (actions.length > 30) throw new Error("At most 30 actions per batch.");
10695
10709
  return computer.lease.withLease(call.session, call.signal, async () => {
10696
10710
  let zoomed;
10711
+ let skippedImage;
10697
10712
  let endedWithZoom = false;
10698
10713
  const lines = [];
10699
10714
  let failure;
@@ -10711,6 +10726,7 @@ function createTools(host) {
10711
10726
  zoomed = outcome.image;
10712
10727
  }
10713
10728
  if (outcome.skipped) {
10729
+ skippedImage = outcome.image;
10714
10730
  failure = `#${index + 1} ${input.action} skipped: ${outcome.text}`;
10715
10731
  break;
10716
10732
  }
@@ -10739,6 +10755,7 @@ function createTools(host) {
10739
10755
  await computer.settle(call.signal);
10740
10756
  return { text: `${summary}\n${await windowText(computer, call, void 0, void 0).catch((error) => `Could not read the window text: ${error instanceof Error ? error.message : String(error)}`)}` };
10741
10757
  }
10758
+ if (skippedImage) return withShot(host, summary, skippedImage, call);
10742
10759
  const waited = failure === void 0 && actions[actions.length - 1]?.action === "wait";
10743
10760
  const shot = call.vision && computer.settings().autoScreenshot ? await (waited ? Promise.resolve() : computer.settle(call.signal)).then(() => computer.freshShot(detail)) : void 0;
10744
10761
  return withShot(host, shot === void 0 ? `${summary}\n${await computer.describeForeground()}` : summary, shot, call);
@@ -10844,6 +10861,12 @@ function createTools(host) {
10844
10861
  if (now?.exe.toLowerCase() === browser.exe && !existing.has(now.hwnd)) {
10845
10862
  openedUrlWindow = now;
10846
10863
  how = `Opened ${name} in a new browser window.`;
10864
+ const blankTitle = (t) => /^(?:$|无标题|untitled|new tab|新标签页|about:blank)(?:\s*[-–—].*)?$/i.test(t.trim());
10865
+ if (blankTitle(now.title)) for (let j = 0; j < 12; j++) {
10866
+ await setTimeout$1(200, void 0, { signal: call.signal });
10867
+ const cur = await computer.foreground().catch(() => void 0);
10868
+ if (!cur || cur.hwnd !== now.hwnd || !blankTitle(cur.title)) break;
10869
+ }
10847
10870
  break;
10848
10871
  }
10849
10872
  continue;
@@ -1,7 +1,7 @@
1
1
  /**
2
- * "应用技能" card: the per-app notes the agent keeps (see ../skills.ts). The
3
- * user can read, edit, add and delete them here; built-in skills can be
4
- * overridden and restored.
2
+ * "应用技能" card: per-app notes the agent keeps (see ../skills.ts).
3
+ * Compact collapsible list with live search & source filter, plus a centered
4
+ * modal dialog for viewing, editing, and creating skills.
5
5
  */
6
6
  import * as React from 'react';
7
7
  export declare function SkillsCard({ S }: {
@@ -90,9 +90,10 @@ export declare class OverlayController {
90
90
  private workTab;
91
91
  private starting;
92
92
  private stopping;
93
- /** Progress card lines: host-provided reasoning and recent operations. */
93
+ /** Progress card lines: host-provided reasoning, brief mid-turn reply, and recent operations. */
94
94
  private streamAgent;
95
95
  private thinking;
96
+ private reply;
96
97
  /** Recent steps (tool actions), oldest first. */
97
98
  private steps;
98
99
  private resume;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@copylee/dsh-computer-use",
3
- "version": "0.13.0",
3
+ "version": "0.13.1",
4
4
  "description": "DeepSeek Harness Computer Use 插件(Windows):让 AI 看屏幕、点鼠标、敲键盘操控电脑;控制时屏幕泛起橙色光晕并显示“DeepSeek Harness 正在操控你的电脑”,按 Esc 暂停 / 继续。",
5
5
  "icon": "assets/icon.svg",
6
6
  "type": "module",