@copylee/dsh-computer-use 0.13.0 → 0.14.0
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 +7 -7
- package/helper/Capture.cs +4 -0
- package/helper/Overlay.cs +220 -87
- package/helper/Program.cs +3 -1
- package/helper/Uia.cs +217 -7
- package/lib/client.js +230 -50
- package/lib/index.js +2668 -2316
- package/lib/types/client/skills-card.d.ts +3 -3
- package/lib/types/computer.d.ts +29 -8
- package/lib/types/overlay.d.ts +27 -2
- package/lib/types/prompt.d.ts +3 -1
- package/lib/types/tools.d.ts +2 -0
- package/lib/types/ui-diff.d.ts +15 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
|
|
14
14
|
## 典型场景与核心特色
|
|
15
15
|
|
|
16
|
-
### 1. Codex
|
|
16
|
+
### 1. 常驻 Codex 协作光标 + Set-of-Marks 编号标图(密集同名按钮精准定位)
|
|
17
17
|
|
|
18
|
-
面对表格、后台系统里多个同名「编辑 / 通过」按钮,调用 `ui_elements({ marks: true })` 为每个交互控件叠加编号角标(`#1`、`#2`…),模型按 `#编号`
|
|
18
|
+
面对表格、后台系统里多个同名「编辑 / 通过」按钮,调用 `ui_elements({ marks: true })` 为每个交互控件叠加编号角标(`#1`、`#2`…),模型按 `#编号` 直接精准操作(页面变更或执行动作后自动失效防误点);进入操控模式后,Codex 风格光晕与徽章全程伴随指针无重影,点击后按手势变色带细微涟漪,并优先走后台 UIA 语义触发(三态防双点,超时绝不重复物理点击)。
|
|
19
19
|
|
|
20
20
|

|
|
21
21
|
|
|
@@ -41,15 +41,15 @@
|
|
|
41
41
|
|
|
42
42
|
## 一次操作是怎么完成的
|
|
43
43
|
|
|
44
|
-
-
|
|
45
|
-
-
|
|
46
|
-
-
|
|
44
|
+
- **按需惰性感知 + 省 Token。** 支持窗口截图(画面未变自动去重、紧凑/标准清晰度分档)、Windows UI Automation 定向查询(`ui_elements({ query, role })`)与**增量 Diff(`diff: true`,重复观察最高省 94% 字符)**、**Set-of-Marks 编号标图**、**Windows 内置 OCR** 以及可选本地 **Chromium CDP** 严格单标签快车道。
|
|
45
|
+
- **确定性语义操作 + 参数化宏。** 支持 `ui_action` 幂等 UIA Pattern(`set_checked`、`expand`/`collapse`、`select`、`set_value`),「填字段 → 提交 → 等成功提示」可放入同一个 `computer_batch`;跑通的固定流程还能存为参数化动作宏一键重放。
|
|
46
|
+
- **生态协同与经验沉淀。** 内置 7 模块零依赖 C# Helper(系统自带 `csc.exe` ~350ms 编译);检测到已安装 [`@copylee/dsh-office`](https://github.com/copylee711/dsh-office) 时自动协同路由 Word/Excel/PPT 到原生 COM 后台编辑;设置页「应用技能」支持折叠搜索与弹窗编辑,输入框支持 `@` 引用运行中窗口。
|
|
47
47
|
|
|
48
48
|
## 操控期间,你仍然掌握主动权
|
|
49
49
|
|
|
50
50
|
- **三档会话启用方式**:在 **设置 → 电脑控制** 可选「按会话开启(默认关闭)」「新会话默认开启」或「总是开启(隐藏输入框左下角「电脑控制」胶囊)」;也支持 `/cu on|off|toggle|status|reset|stop|revoke <应用>` 快捷控制。
|
|
51
|
-
-
|
|
52
|
-
-
|
|
51
|
+
- **实时接管感知 + 三档尺寸迷你卡片**:开始操控后,屏幕四周亮起橙色光晕,迷你进度卡片支持**紧凑 / 标准 / 详情**三档尺寸与按钮悬停中文提示,简短中间回复直接留在卡片内不闪弹主窗口;你随时可按 **Esc** 暂停,或直接用鼠标点击/滚轮/键盘接管——插件会自动将脱敏操作语义(控件名称、窗口、坐标,绝不记录密码与输入明文)实时同步给 AI,让它顺着你的意图继续。
|
|
52
|
+
- **多会话租约与纵深安全**:全工具覆盖单机桌面控制租约(防止多 Agent 并发互抢鼠标),统一拦截密码管理器、密码框(UIA `IsPassword` + Win32 `ES_PASSWORD`)、命令解释器启动及跨标签页 CDP 读取;内置 `pnpm run bench` 8 场景基准回归测试与一键导出脱敏诊断报告。
|
|
53
53
|
|
|
54
54
|
正文一开始输出,就回到 DSH 对话阅读。可查看[暂停时的卡片](assets/demo-paused.png)和[任务结束的画面](assets/demo-complete.png)。授权范围、截图和剪贴板的处理规则见[数据与权限](docs/privacy.md)。
|
|
55
55
|
|
package/helper/Capture.cs
CHANGED
|
@@ -121,9 +121,12 @@ namespace DshComputerUse
|
|
|
121
121
|
byte[] prev = Sample(x, y, w, h);
|
|
122
122
|
long quietSince = -1;
|
|
123
123
|
bool stable = false;
|
|
124
|
+
bool skipped = false;
|
|
124
125
|
while (true)
|
|
125
126
|
{
|
|
127
|
+
if (Overlay.SkipWaitRequested) { skipped = true; break; }
|
|
126
128
|
Thread.Sleep(interval);
|
|
129
|
+
if (Overlay.SkipWaitRequested) { skipped = true; break; }
|
|
127
130
|
byte[] cur = Sample(x, y, w, h);
|
|
128
131
|
long now = watch.ElapsedMilliseconds;
|
|
129
132
|
if (Changed(prev, cur) < 0.002) { if (quietSince < 0) quietSince = now - interval; }
|
|
@@ -135,6 +138,7 @@ namespace DshComputerUse
|
|
|
135
138
|
var d = new Dictionary<string, object>();
|
|
136
139
|
d["ms"] = (int)watch.ElapsedMilliseconds;
|
|
137
140
|
d["stable"] = stable;
|
|
141
|
+
if (skipped) d["skipped"] = true;
|
|
138
142
|
return d;
|
|
139
143
|
}
|
|
140
144
|
|
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;
|
|
@@ -375,10 +376,22 @@ namespace DshComputerUse
|
|
|
375
376
|
static int keyBurstCount;
|
|
376
377
|
static volatile bool visible;
|
|
377
378
|
static volatile bool paused;
|
|
379
|
+
static volatile bool petWaiting;
|
|
380
|
+
public static volatile bool SkipWaitRequested;
|
|
378
381
|
static volatile bool clickTargetEnabled = true;
|
|
382
|
+
static string cursorBadge = "DeepSeek";
|
|
379
383
|
static LayeredForm markForm;
|
|
380
384
|
static DateTime markExpiresAt = DateTime.MinValue;
|
|
381
385
|
static bool markActive;
|
|
386
|
+
static bool markIsResting;
|
|
387
|
+
static float cachedMarkScale;
|
|
388
|
+
static bool cachedMarkFlipX, cachedMarkFlipY, cachedMarkRipple, cachedMarkArrow;
|
|
389
|
+
static string cachedMarkText = "";
|
|
390
|
+
static Color cachedMarkColor = Color.Empty;
|
|
391
|
+
static int cachedMarkCx, cachedMarkCy;
|
|
392
|
+
static bool hasCachedMarkBitmap;
|
|
393
|
+
static volatile int latestMouseX, latestMouseY;
|
|
394
|
+
static int mouseMovePending;
|
|
382
395
|
static int lastTyping = int.MinValue / 2;
|
|
383
396
|
static int lastEmit;
|
|
384
397
|
static readonly object RectLock = new object();
|
|
@@ -391,6 +404,7 @@ namespace DshComputerUse
|
|
|
391
404
|
static LayeredForm pet;
|
|
392
405
|
public static volatile IntPtr PetHwnd = IntPtr.Zero;
|
|
393
406
|
static string petThinking = "";
|
|
407
|
+
static string petReply = "";
|
|
394
408
|
static List<string> petSteps = new List<string>();
|
|
395
409
|
/** Bottom-right corner of the card body; the card grows upward when expanded. */
|
|
396
410
|
static Point petAnchor = Point.Empty;
|
|
@@ -468,12 +482,17 @@ namespace DshComputerUse
|
|
|
468
482
|
string reqSize = Args.Str(r, "petSize", "");
|
|
469
483
|
if (reqSize == "compact" || reqSize == "standard" || reqSize == "detailed") petSize = reqSize;
|
|
470
484
|
clickTargetEnabled = Args.Bool(r, "glow", true);
|
|
485
|
+
string badgeSrc = label.Replace("正在操控你的电脑", "").Replace("正在操控", "").Trim();
|
|
486
|
+
if (badgeSrc.StartsWith("DeepSeek", StringComparison.OrdinalIgnoreCase)) cursorBadge = "DeepSeek";
|
|
487
|
+
else if (badgeSrc.Length > 0) cursorBadge = badgeSrc.Length > 10 ? badgeSrc.Substring(0, 10) : badgeSrc;
|
|
488
|
+
else cursorBadge = "AI";
|
|
471
489
|
if (visible && !petFinished) { RenderPill(); return; }
|
|
472
490
|
if (visible) HideCore(); // the previous run's "done" card is still up
|
|
473
491
|
petMode = Args.Bool(r, "pet", false);
|
|
474
492
|
hoveredBtn = "";
|
|
475
493
|
pressedBtn = "";
|
|
476
494
|
petThinking = Args.Str(r, "thinking", "");
|
|
495
|
+
petReply = "";
|
|
477
496
|
petSteps = new List<string>();
|
|
478
497
|
if (status.Length > 0) petSteps.Add(status);
|
|
479
498
|
pillAtBottom = false;
|
|
@@ -562,7 +581,13 @@ namespace DshComputerUse
|
|
|
562
581
|
RenderPill();
|
|
563
582
|
InstallHook();
|
|
564
583
|
shownAt = DateTime.UtcNow;
|
|
584
|
+
shownTick = Environment.TickCount;
|
|
565
585
|
visible = true;
|
|
586
|
+
if (clickTargetEnabled)
|
|
587
|
+
{
|
|
588
|
+
Native.POINT cp;
|
|
589
|
+
if (Native.GetCursorPos(out cp)) ShowRestingMarkOnUi(cp.X, cp.Y);
|
|
590
|
+
}
|
|
566
591
|
timer.Start();
|
|
567
592
|
});
|
|
568
593
|
}
|
|
@@ -573,14 +598,15 @@ namespace DshComputerUse
|
|
|
573
598
|
Ui(delegate { status = newStatus; RenderPill(); });
|
|
574
599
|
}
|
|
575
600
|
|
|
576
|
-
/** Latest host-provided reasoning and recent operations, oldest first. */
|
|
577
|
-
public static void PetUpdate(string thinking, List<string> steps)
|
|
601
|
+
/** Latest host-provided reasoning, brief reply text, and recent operations, oldest first. */
|
|
602
|
+
public static void PetUpdate(string thinking, string reply, List<string> steps)
|
|
578
603
|
{
|
|
579
604
|
if (thread == null || !visible || !petMode || petFinished) return;
|
|
580
605
|
invoker.BeginInvoke((MethodInvoker)delegate
|
|
581
606
|
{
|
|
582
607
|
if (petFinished) return;
|
|
583
608
|
petThinking = thinking;
|
|
609
|
+
petReply = reply ?? "";
|
|
584
610
|
if (steps.Count > 0) petSteps = steps;
|
|
585
611
|
RenderPill();
|
|
586
612
|
});
|
|
@@ -612,6 +638,13 @@ namespace DshComputerUse
|
|
|
612
638
|
Ui(delegate { paused = value; RenderPill(); });
|
|
613
639
|
}
|
|
614
640
|
|
|
641
|
+
public static void SetWaiting(bool value)
|
|
642
|
+
{
|
|
643
|
+
if (thread == null) return;
|
|
644
|
+
if (value) SkipWaitRequested = false;
|
|
645
|
+
Ui(delegate { petWaiting = value; if (visible) RenderPill(); });
|
|
646
|
+
}
|
|
647
|
+
|
|
615
648
|
public static void Hide()
|
|
616
649
|
{
|
|
617
650
|
if (thread == null) return;
|
|
@@ -624,6 +657,9 @@ namespace DshComputerUse
|
|
|
624
657
|
HideMark();
|
|
625
658
|
CloseInput(false);
|
|
626
659
|
petFinished = false;
|
|
660
|
+
petWaiting = false;
|
|
661
|
+
SkipWaitRequested = false;
|
|
662
|
+
petReply = "";
|
|
627
663
|
visible = false;
|
|
628
664
|
paused = false;
|
|
629
665
|
timer.Stop();
|
|
@@ -687,11 +723,11 @@ namespace DshComputerUse
|
|
|
687
723
|
* arrow with white outline, attached rounded name-tag pill (auto-flipping
|
|
688
724
|
* at all 4 screen edges), and a subtle click ripple ring on post-click.
|
|
689
725
|
*/
|
|
690
|
-
static Bitmap DrawMark(string text, Color color, float scale, bool flipX, bool flipY, bool ripple, out int cx, out int cy)
|
|
726
|
+
static Bitmap DrawMark(string text, Color color, float scale, bool flipX, bool flipY, bool ripple, bool drawArrow, out int cx, out int cy)
|
|
691
727
|
{
|
|
692
728
|
float s = Math.Max(0.75f, Math.Min(3f, scale));
|
|
693
729
|
float px = 1.333f * s;
|
|
694
|
-
float glowR = (ripple ? 20f :
|
|
730
|
+
float glowR = (ripple ? 20f : 17f) * s;
|
|
695
731
|
float pad = 4f * s;
|
|
696
732
|
using (var font = new Font("Microsoft YaHei UI", 8f * px, FontStyle.Bold, GraphicsUnit.Pixel))
|
|
697
733
|
using (var probe = new Bitmap(1, 1))
|
|
@@ -705,9 +741,10 @@ namespace DshComputerUse
|
|
|
705
741
|
float pillW = textSize.Width > 0 ? (float)Math.Ceiling(textSize.Width + 2f * pillPadX) : 0f;
|
|
706
742
|
float pillH = textSize.Height > 0 ? Math.Max(19f * s, (float)Math.Ceiling(textSize.Height + 5f * s)) : 0f;
|
|
707
743
|
|
|
708
|
-
// Offsets relative to the pointer tip at (0, 0).
|
|
709
|
-
|
|
710
|
-
float
|
|
744
|
+
// Offsets relative to the pointer tip at (0, 0). Clear the native Windows pointer
|
|
745
|
+
// arrow cleanly when attaching to the live OS cursor (drawArrow == false).
|
|
746
|
+
float tagX = flipX ? (-10f * s - pillW) : (drawArrow ? 13f * s : 14f * s);
|
|
747
|
+
float tagY = flipY ? (-10f * s - pillH) : (drawArrow ? 15f * s : 18f * s);
|
|
711
748
|
|
|
712
749
|
float minX = Math.Min(-glowR, pillW > 0 ? tagX : 0f) - pad;
|
|
713
750
|
float maxX = Math.Max(glowR, Math.Max(14f * s, pillW > 0 ? tagX + pillW : 0f)) + pad;
|
|
@@ -733,7 +770,7 @@ namespace DshComputerUse
|
|
|
733
770
|
using (var glow = new PathGradientBrush(spot))
|
|
734
771
|
{
|
|
735
772
|
glow.CenterPoint = new PointF(cx, cy);
|
|
736
|
-
glow.CenterColor = Color.FromArgb(ripple ?
|
|
773
|
+
glow.CenterColor = Color.FromArgb(ripple ? 135 : 115, color);
|
|
737
774
|
glow.SurroundColors = new Color[] { Color.FromArgb(0, color) };
|
|
738
775
|
g.FillPath(glow, spot);
|
|
739
776
|
}
|
|
@@ -769,26 +806,31 @@ namespace DshComputerUse
|
|
|
769
806
|
g.DrawString(text, font, fg, bx + (pillW - textSize.Width) / 2f, by + (pillH - textSize.Height) / 2f - 0.5f * s, fmt);
|
|
770
807
|
}
|
|
771
808
|
|
|
772
|
-
// 4.
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
new PointF(cx, cy + 16.5f * s),
|
|
777
|
-
new PointF(cx + 4.3f * s, cy + 12.8f * s),
|
|
778
|
-
new PointF(cx + 7.4f * s, cy + 19.2f * s),
|
|
779
|
-
new PointF(cx + 10.0f * s, cy + 17.9f * s),
|
|
780
|
-
new PointF(cx + 6.9f * s, cy + 11.7f * s),
|
|
781
|
-
new PointF(cx + 12.4f * s, cy + 11.4f * s),
|
|
782
|
-
};
|
|
783
|
-
var arrowShadow = new PointF[arrow.Length];
|
|
784
|
-
for (int i = 0; i < arrow.Length; i++)
|
|
785
|
-
arrowShadow[i] = new PointF(arrow[i].X + 0.8f * s, arrow[i].Y + 1.5f * s);
|
|
786
|
-
using (var sb = new SolidBrush(Color.FromArgb(72, 0, 0, 0))) g.FillPolygon(sb, arrowShadow);
|
|
787
|
-
using (var fill = new SolidBrush(Color.FromArgb(255, color))) g.FillPolygon(fill, arrow);
|
|
788
|
-
using (var outline = new Pen(Color.FromArgb(248, 255, 255, 255), Math.Max(1.2f, 1.5f * s)))
|
|
809
|
+
// 4. Vector cursor arrow ONLY for capturable post-click markers (screenshots do not
|
|
810
|
+
// capture Windows' hardware cursor). Live resting/gliding states omit the fake arrow
|
|
811
|
+
// so Windows' native cursor never double-renders on top of a duplicate arrow.
|
|
812
|
+
if (drawArrow)
|
|
789
813
|
{
|
|
790
|
-
|
|
791
|
-
|
|
814
|
+
var arrow = new PointF[]
|
|
815
|
+
{
|
|
816
|
+
new PointF(cx, cy),
|
|
817
|
+
new PointF(cx, cy + 16.5f * s),
|
|
818
|
+
new PointF(cx + 4.3f * s, cy + 12.8f * s),
|
|
819
|
+
new PointF(cx + 7.4f * s, cy + 19.2f * s),
|
|
820
|
+
new PointF(cx + 10.0f * s, cy + 17.9f * s),
|
|
821
|
+
new PointF(cx + 6.9f * s, cy + 11.7f * s),
|
|
822
|
+
new PointF(cx + 12.4f * s, cy + 11.4f * s),
|
|
823
|
+
};
|
|
824
|
+
var arrowShadow = new PointF[arrow.Length];
|
|
825
|
+
for (int i = 0; i < arrow.Length; i++)
|
|
826
|
+
arrowShadow[i] = new PointF(arrow[i].X + 0.8f * s, arrow[i].Y + 1.5f * s);
|
|
827
|
+
using (var sb = new SolidBrush(Color.FromArgb(72, 0, 0, 0))) g.FillPolygon(sb, arrowShadow);
|
|
828
|
+
using (var fill = new SolidBrush(Color.FromArgb(255, color))) g.FillPolygon(fill, arrow);
|
|
829
|
+
using (var outline = new Pen(Color.FromArgb(248, 255, 255, 255), Math.Max(1.2f, 1.5f * s)))
|
|
830
|
+
{
|
|
831
|
+
outline.LineJoin = LineJoin.Round;
|
|
832
|
+
g.DrawPolygon(outline, arrow);
|
|
833
|
+
}
|
|
792
834
|
}
|
|
793
835
|
}
|
|
794
836
|
return bmp;
|
|
@@ -803,68 +845,107 @@ namespace DshComputerUse
|
|
|
803
845
|
GlideMark(x, y, text, Accent, holdMs, false, false);
|
|
804
846
|
}
|
|
805
847
|
|
|
806
|
-
/**
|
|
807
|
-
|
|
848
|
+
/** Move or render the mark form: uses ultra-fast SetWindowPos when only (x, y) changed. */
|
|
849
|
+
static void PlaceMarkOnUi(int x, int y, string text, Color color, int holdMs, bool capturable, bool ripple, bool resting)
|
|
808
850
|
{
|
|
809
|
-
|
|
810
|
-
|
|
851
|
+
lastMarkX = x;
|
|
852
|
+
lastMarkY = y;
|
|
853
|
+
hasLastMark = true;
|
|
854
|
+
if (markForm == null)
|
|
811
855
|
{
|
|
812
|
-
|
|
813
|
-
|
|
856
|
+
markForm = new LayeredForm(true);
|
|
857
|
+
markForm.Show();
|
|
858
|
+
hasCachedMarkBitmap = false;
|
|
859
|
+
}
|
|
860
|
+
markForm.SetCapturable(capturable || !ExcludeFromCapture);
|
|
861
|
+
float scale; Rectangle mon;
|
|
862
|
+
MonitorAt(x, y, out scale, out mon);
|
|
863
|
+
float s = Math.Max(0.75f, Math.Min(3f, scale));
|
|
864
|
+
string labelText = text ?? "";
|
|
865
|
+
int estW = (int)((Math.Max(6, labelText.Length) * 11 + 36) * s);
|
|
866
|
+
bool flipX = !mon.IsEmpty && x + estW > mon.Right;
|
|
867
|
+
bool flipY = !mon.IsEmpty && y + (int)(52 * s) > mon.Bottom;
|
|
868
|
+
bool drawArrow = capturable;
|
|
869
|
+
|
|
870
|
+
bool sameVisual = hasCachedMarkBitmap
|
|
871
|
+
&& Math.Abs(scale - cachedMarkScale) < 0.01f
|
|
872
|
+
&& flipX == cachedMarkFlipX && flipY == cachedMarkFlipY
|
|
873
|
+
&& ripple == cachedMarkRipple && drawArrow == cachedMarkArrow
|
|
874
|
+
&& labelText == cachedMarkText && color.ToArgb() == cachedMarkColor.ToArgb();
|
|
875
|
+
|
|
876
|
+
if (sameVisual)
|
|
877
|
+
{
|
|
878
|
+
// Pure DWM sprite move (< 0.05ms, zero GDI+ redraw) for native-smooth cursor tracking.
|
|
879
|
+
Native.SetWindowPos(markForm.Handle, IntPtr.Zero, x - cachedMarkCx, y - cachedMarkCy, 0, 0, 0x0001 | 0x0004 | 0x0010);
|
|
814
880
|
}
|
|
815
881
|
else
|
|
816
882
|
{
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
883
|
+
int cx, cy;
|
|
884
|
+
using (var bmp = DrawMark(labelText, color, scale, flipX, flipY, ripple, drawArrow, out cx, out cy))
|
|
885
|
+
{
|
|
886
|
+
markForm.SetBitmap(bmp, new Rectangle(x - cx, y - cy, bmp.Width, bmp.Height), 255);
|
|
887
|
+
}
|
|
888
|
+
cachedMarkScale = scale;
|
|
889
|
+
cachedMarkFlipX = flipX;
|
|
890
|
+
cachedMarkFlipY = flipY;
|
|
891
|
+
cachedMarkRipple = ripple;
|
|
892
|
+
cachedMarkArrow = drawArrow;
|
|
893
|
+
cachedMarkText = labelText;
|
|
894
|
+
cachedMarkColor = color;
|
|
895
|
+
cachedMarkCx = cx;
|
|
896
|
+
cachedMarkCy = cy;
|
|
897
|
+
hasCachedMarkBitmap = true;
|
|
898
|
+
markForm.KeepOnTop();
|
|
820
899
|
}
|
|
900
|
+
markActive = true;
|
|
901
|
+
markIsResting = resting;
|
|
902
|
+
markExpiresAt = holdMs > 0 ? DateTime.UtcNow.AddMilliseconds(holdMs) : DateTime.MaxValue;
|
|
903
|
+
if (!timer.Enabled) timer.Start();
|
|
904
|
+
}
|
|
905
|
+
|
|
906
|
+
static void SyncRestingCursorOnUi()
|
|
907
|
+
{
|
|
908
|
+
Interlocked.Exchange(ref mouseMovePending, 0);
|
|
909
|
+
if (!visible || !clickTargetEnabled || petFinished || !markActive || !markIsResting) return;
|
|
910
|
+
PlaceMarkOnUi(latestMouseX, latestMouseY, cursorBadge, Accent, 0, false, false, true);
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
/** Smooth EaseOutCubic glide (~150ms @ ~60-90Hz) moving both OS cursor and cached badge in lockstep. */
|
|
914
|
+
public static void GlideMark(int x, int y, string text, Color color, int holdMs, bool capturable, bool ripple)
|
|
915
|
+
{
|
|
916
|
+
int startX, startY;
|
|
917
|
+
Native.POINT cur;
|
|
918
|
+
if (Native.GetCursorPos(out cur)) { startX = cur.X; startY = cur.Y; }
|
|
919
|
+
else if (hasLastMark) { startX = lastMarkX; startY = lastMarkY; }
|
|
920
|
+
else { startX = x; startY = y; }
|
|
821
921
|
double dist = Math.Sqrt((double)(x - startX) * (x - startX) + (double)(y - startY) * (y - startY));
|
|
822
|
-
if (dist >=
|
|
922
|
+
if (dist >= 30.0)
|
|
823
923
|
{
|
|
824
|
-
int steps = Math.Max(
|
|
924
|
+
int steps = Math.Max(8, Math.Min(16, (int)(dist / 65.0) + 8));
|
|
825
925
|
for (int i = 1; i < steps; i++)
|
|
826
926
|
{
|
|
827
927
|
double t = (double)i / steps;
|
|
828
928
|
double ease = 1.0 - Math.Pow(1.0 - t, 3.0); // EaseOutCubic
|
|
829
929
|
int ix = startX + (int)Math.Round((x - startX) * ease);
|
|
830
930
|
int iy = startY + (int)Math.Round((y - startY) * ease);
|
|
931
|
+
try { Native.SetCursorPos(ix, iy); } catch (Exception) { }
|
|
831
932
|
Mark(ix, iy, text, color, holdMs, capturable, false);
|
|
832
|
-
Thread.Sleep(
|
|
933
|
+
Thread.Sleep(10);
|
|
833
934
|
}
|
|
834
935
|
}
|
|
936
|
+
try { Native.SetCursorPos(x, y); } catch (Exception) { }
|
|
835
937
|
Mark(x, y, text, color, holdMs, capturable, ripple);
|
|
836
938
|
}
|
|
837
939
|
|
|
940
|
+
static void ShowRestingMarkOnUi(int x, int y)
|
|
941
|
+
{
|
|
942
|
+
PlaceMarkOnUi(x, y, cursorBadge, Accent, 0, false, false, true);
|
|
943
|
+
}
|
|
944
|
+
|
|
838
945
|
public static void Mark(int x, int y, string text, Color color, int holdMs, bool capturable, bool ripple)
|
|
839
946
|
{
|
|
840
|
-
lastMarkX = x;
|
|
841
|
-
lastMarkY = y;
|
|
842
|
-
hasLastMark = true;
|
|
843
947
|
Ensure();
|
|
844
|
-
Ui(delegate
|
|
845
|
-
{
|
|
846
|
-
if (markForm == null)
|
|
847
|
-
{
|
|
848
|
-
markForm = new LayeredForm(true);
|
|
849
|
-
markForm.Show();
|
|
850
|
-
}
|
|
851
|
-
markForm.SetCapturable(capturable || !ExcludeFromCapture);
|
|
852
|
-
float scale; Rectangle mon;
|
|
853
|
-
MonitorAt(x, y, out scale, out mon);
|
|
854
|
-
float s = Math.Max(0.75f, Math.Min(3f, scale));
|
|
855
|
-
int estW = (int)((Math.Max(6, (text ?? "").Length) * 11 + 36) * s);
|
|
856
|
-
bool flipX = !mon.IsEmpty && x + estW > mon.Right;
|
|
857
|
-
bool flipY = !mon.IsEmpty && y + (int)(52 * s) > mon.Bottom;
|
|
858
|
-
int cx, cy;
|
|
859
|
-
using (var bmp = DrawMark(text, color, scale, flipX, flipY, ripple, out cx, out cy))
|
|
860
|
-
{
|
|
861
|
-
markForm.SetBitmap(bmp, new Rectangle(x - cx, y - cy, bmp.Width, bmp.Height), 255);
|
|
862
|
-
}
|
|
863
|
-
markForm.KeepOnTop();
|
|
864
|
-
markActive = true;
|
|
865
|
-
markExpiresAt = holdMs > 0 ? DateTime.UtcNow.AddMilliseconds(holdMs) : DateTime.MaxValue;
|
|
866
|
-
if (!timer.Enabled) timer.Start();
|
|
867
|
-
});
|
|
948
|
+
Ui(delegate { PlaceMarkOnUi(x, y, text, color, holdMs, capturable, ripple, false); });
|
|
868
949
|
}
|
|
869
950
|
|
|
870
951
|
public static void MarkResult(int x, int y, string button, int count, string coordLabel)
|
|
@@ -882,6 +963,8 @@ namespace DshComputerUse
|
|
|
882
963
|
static void HideMark()
|
|
883
964
|
{
|
|
884
965
|
markActive = false;
|
|
966
|
+
markIsResting = false;
|
|
967
|
+
hasCachedMarkBitmap = false;
|
|
885
968
|
markExpiresAt = DateTime.MinValue;
|
|
886
969
|
if (markForm != null)
|
|
887
970
|
{
|
|
@@ -907,7 +990,8 @@ namespace DshComputerUse
|
|
|
907
990
|
// pause / resume / stop, from Esc or the pill buttons.
|
|
908
991
|
static void Press(string action)
|
|
909
992
|
{
|
|
910
|
-
if (action == "stop") { paused = false; Program.EmitEvent("stop", "button"); }
|
|
993
|
+
if (action == "stop") { paused = false; petWaiting = false; SkipWaitRequested = true; Program.EmitEvent("stop", "button"); }
|
|
994
|
+
else if (action == "skip_wait") { petWaiting = false; SkipWaitRequested = true; Program.EmitEvent("skip_wait", "button"); }
|
|
911
995
|
else if (action == "pause") { paused = true; Program.EmitEvent("pause", "user"); }
|
|
912
996
|
else if (action == "resume") { paused = false; pausedByInput = false; Program.EmitEvent("resume", "user"); }
|
|
913
997
|
else if (action == "expand") petExpanded = !petExpanded;
|
|
@@ -969,12 +1053,29 @@ namespace DshComputerUse
|
|
|
969
1053
|
|
|
970
1054
|
static void Tick()
|
|
971
1055
|
{
|
|
972
|
-
if (markActive && DateTime.UtcNow >= markExpiresAt)
|
|
1056
|
+
if (markActive && DateTime.UtcNow >= markExpiresAt)
|
|
1057
|
+
{
|
|
1058
|
+
if (visible && clickTargetEnabled && !petFinished && hasLastMark)
|
|
1059
|
+
ShowRestingMarkOnUi(lastMarkX, lastMarkY);
|
|
1060
|
+
else
|
|
1061
|
+
HideMark();
|
|
1062
|
+
}
|
|
973
1063
|
if (!visible)
|
|
974
1064
|
{
|
|
975
1065
|
if (!markActive) timer.Stop();
|
|
976
1066
|
return;
|
|
977
1067
|
}
|
|
1068
|
+
if (visible && clickTargetEnabled && !petFinished && !markActive)
|
|
1069
|
+
{
|
|
1070
|
+
Native.POINT cp;
|
|
1071
|
+
if (Native.GetCursorPos(out cp)) ShowRestingMarkOnUi(cp.X, cp.Y);
|
|
1072
|
+
}
|
|
1073
|
+
else if (visible && clickTargetEnabled && !petFinished && markActive && markIsResting)
|
|
1074
|
+
{
|
|
1075
|
+
Native.POINT cp;
|
|
1076
|
+
if (Native.GetCursorPos(out cp) && (Math.Abs(cp.X - lastMarkX) > 2 || Math.Abs(cp.Y - lastMarkY) > 2))
|
|
1077
|
+
ShowRestingMarkOnUi(cp.X, cp.Y);
|
|
1078
|
+
}
|
|
978
1079
|
if (petFinished)
|
|
979
1080
|
{
|
|
980
1081
|
Native.POINT p; Native.GetCursorPos(out p);
|
|
@@ -1042,19 +1143,24 @@ namespace DshComputerUse
|
|
|
1042
1143
|
if (paused)
|
|
1043
1144
|
{
|
|
1044
1145
|
main = "已暂停"; sub = "按 Esc 继续";
|
|
1045
|
-
actions = new[] { "resume", "stop" }; captions = new[] { "继续", "
|
|
1146
|
+
actions = new[] { "resume", "stop" }; captions = new[] { "继续", "停止控制" };
|
|
1046
1147
|
return;
|
|
1047
1148
|
}
|
|
1048
1149
|
main = label;
|
|
1049
1150
|
sub = Typing() ? "你正在操作,已暂停" : status.Length > 0 ? status : "Esc 暂停";
|
|
1050
|
-
|
|
1151
|
+
if (petWaiting)
|
|
1152
|
+
{
|
|
1153
|
+
actions = new[] { "skip_wait", "stop" }; captions = new[] { "跳过等待", "停止控制" };
|
|
1154
|
+
return;
|
|
1155
|
+
}
|
|
1156
|
+
actions = new[] { "stop" }; captions = new[] { "停止控制" };
|
|
1051
1157
|
}
|
|
1052
1158
|
|
|
1053
1159
|
static string Key()
|
|
1054
1160
|
{
|
|
1055
1161
|
string main, sub; string[] actions, captions;
|
|
1056
1162
|
Content(out main, out sub, out actions, out captions);
|
|
1057
|
-
return main + "|" + sub + "|" + string.Join(",", actions) + "|" + pillAtBottom + "|" + Typing();
|
|
1163
|
+
return main + "|" + sub + "|" + string.Join(",", actions) + "|" + pillAtBottom + "|" + Typing() + "|" + petWaiting;
|
|
1058
1164
|
}
|
|
1059
1165
|
|
|
1060
1166
|
static bool DarkTheme()
|
|
@@ -1118,7 +1224,8 @@ namespace DshComputerUse
|
|
|
1118
1224
|
|
|
1119
1225
|
static string ButtonTip(string act)
|
|
1120
1226
|
{
|
|
1121
|
-
if (act == "stop") return "
|
|
1227
|
+
if (act == "stop") return "停止控制并回到 DSH";
|
|
1228
|
+
if (act == "skip_wait") return "跳过等待,立即继续";
|
|
1122
1229
|
if (act == "pause") return "暂停操控";
|
|
1123
1230
|
if (act == "resume") return "继续操控";
|
|
1124
1231
|
if (act == "expand") return petExpanded ? "收起详情" : "展开详情";
|
|
@@ -1153,8 +1260,10 @@ namespace DshComputerUse
|
|
|
1153
1260
|
|
|
1154
1261
|
bool isCompact = petSize == "compact";
|
|
1155
1262
|
bool isDetailed = petSize == "detailed";
|
|
1156
|
-
string title = petFinished ? "已完成" : (isCompact && label.Length > 12 ? label.Substring(0, 11) + "…" : label);
|
|
1157
1263
|
string hoverTip = ButtonTip(hoveredBtn);
|
|
1264
|
+
string title = hoverTip.Length > 0
|
|
1265
|
+
? (isCompact ? "" : "DeepSeek")
|
|
1266
|
+
: petFinished ? "已完成" : (isCompact && label.Length > 12 ? label.Substring(0, 11) + "…" : label);
|
|
1158
1267
|
string state = hoverTip.Length > 0 ? hoverTip
|
|
1159
1268
|
: petFinished ? "" : paused ? (input != null ? "输入指令中…" : "已暂停 · Esc 继续")
|
|
1160
1269
|
: Typing() ? "你正在操作,已暂停" : (isCompact ? "" : "Esc 暂停");
|
|
@@ -1165,6 +1274,7 @@ namespace DshComputerUse
|
|
|
1165
1274
|
{
|
|
1166
1275
|
actions.Add("stop"); glyphs.Add("\uE71A");
|
|
1167
1276
|
if (paused) { actions.Add("resume"); glyphs.Add("\uE768"); } else { actions.Add("pause"); glyphs.Add("\uE769"); }
|
|
1277
|
+
if (petWaiting && !paused) { actions.Add("skip_wait"); glyphs.Add("\uE893"); }
|
|
1168
1278
|
}
|
|
1169
1279
|
actions.Add("expand"); glyphs.Add(petExpanded ? "\uE70D" : "\uE70E");
|
|
1170
1280
|
if (!petFinished) { actions.Add("input"); glyphs.Add("\uE70F"); }
|
|
@@ -1175,10 +1285,13 @@ namespace DshComputerUse
|
|
|
1175
1285
|
float bodyW = (isCompact ? 320f : isDetailed ? 484f : 420f) * s;
|
|
1176
1286
|
float pad = (isCompact ? 13f : 16f) * s;
|
|
1177
1287
|
float headH = (isCompact ? 40f : 44f) * s;
|
|
1178
|
-
bool showThinking = !isCompact || petExpanded;
|
|
1288
|
+
bool showThinking = !isCompact || petExpanded || (!petFinished && petReply.Length > 0);
|
|
1179
1289
|
bool showTimeline = petExpanded || isDetailed;
|
|
1180
1290
|
float replyH = showThinking ? (isDetailed && !petExpanded ? 42f * s : 26f * s) : 0f;
|
|
1181
|
-
|
|
1291
|
+
bool hasReply = !petFinished && petReply.Length > 0;
|
|
1292
|
+
string progressPrefix = hasReply ? "说明 · " : "思考 · ";
|
|
1293
|
+
string progressBody = hasReply ? petReply : petThinking;
|
|
1294
|
+
string progress = petFinished ? "已交还电脑控制" : progressBody.Length > 0 ? progressPrefix + progressBody : "正在操作,等待下一步…";
|
|
1182
1295
|
if (showThinking && (petExpanded || isDetailed))
|
|
1183
1296
|
{
|
|
1184
1297
|
using (var probe = new Bitmap(1, 1))
|
|
@@ -1247,9 +1360,12 @@ namespace DshComputerUse
|
|
|
1247
1360
|
else if (logo != null) g.DrawImage(logo, iconRect);
|
|
1248
1361
|
else using (var brush = new SolidBrush(Accent)) g.FillEllipse(brush, RectangleF.Inflate(iconRect, -3 * s, -3 * s));
|
|
1249
1362
|
float tx = iconRect.Right + 8 * s;
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1363
|
+
if (title.Length > 0)
|
|
1364
|
+
{
|
|
1365
|
+
SizeF headSize = g.MeasureString(title, fHead, 100000, fmt);
|
|
1366
|
+
using (var b = new SolidBrush(ink)) g.DrawString(title, fHead, b, tx, hy + (hh - headSize.Height) / 2f, fmt);
|
|
1367
|
+
tx += headSize.Width + 8 * s;
|
|
1368
|
+
}
|
|
1253
1369
|
|
|
1254
1370
|
buttons.Clear();
|
|
1255
1371
|
float d = (isCompact ? 24f : 26f) * s, bx = body.Right - pad;
|
|
@@ -1259,7 +1375,7 @@ namespace DshComputerUse
|
|
|
1259
1375
|
bx -= d;
|
|
1260
1376
|
var hitRect = new RectangleF(bx, hy + (hh - d) / 2f, d, d);
|
|
1261
1377
|
bool stop = act == "stop";
|
|
1262
|
-
bool on = (act == "input" && input != null) || (act == "resume");
|
|
1378
|
+
bool on = (act == "input" && input != null) || (act == "resume") || (act == "skip_wait");
|
|
1263
1379
|
bool hover = hoveredBtn == act;
|
|
1264
1380
|
bool press = pressedBtn == act;
|
|
1265
1381
|
float inflate = press ? -0.8f * s : hover ? 1.1f * s : 0f;
|
|
@@ -1280,7 +1396,7 @@ namespace DshComputerUse
|
|
|
1280
1396
|
using (var ring = new Pen(Color.FromArgb(dark ? 150 : 120, Accent), Math.Max(1f, 1.2f * s)))
|
|
1281
1397
|
g.DrawEllipse(ring, circle);
|
|
1282
1398
|
}
|
|
1283
|
-
string glyph = glyphFont.Length > 0 ? glyphs[i] : (stop ? "■" : act == "pause" ? "❚❚" : act == "resume" ? "▶" : act == "expand" ? (petExpanded ? "˅" : "˄") : act == "close" ? "✕" : "✎");
|
|
1399
|
+
string glyph = glyphFont.Length > 0 ? glyphs[i] : (stop ? "■" : act == "skip_wait" ? "⏭" : act == "pause" ? "❚❚" : act == "resume" ? "▶" : act == "expand" ? (petExpanded ? "˅" : "˄") : act == "close" ? "✕" : "✎");
|
|
1284
1400
|
Color glyphColor = stop ? Color.White : (hover || on) ? (dark ? Color.White : Color.FromArgb(168, 72, 42)) : ink;
|
|
1285
1401
|
using (var b = new SolidBrush(glyphColor)) g.DrawString(glyph, fGlyph, b, circle, center);
|
|
1286
1402
|
buttons.Add(new KeyValuePair<Rectangle, string>(Rectangle.Round(hitRect), act));
|
|
@@ -1299,14 +1415,14 @@ namespace DshComputerUse
|
|
|
1299
1415
|
float ry = body.Y + headH;
|
|
1300
1416
|
if (showThinking)
|
|
1301
1417
|
{
|
|
1302
|
-
using (var b = new SolidBrush(
|
|
1418
|
+
using (var b = new SolidBrush(progressBody.Length > 0 && !petFinished ? ink : muted))
|
|
1303
1419
|
{
|
|
1304
1420
|
if (petExpanded || isDetailed)
|
|
1305
1421
|
g.DrawString(TailWrapped(g, progress, fText, lineW, replyH, wrap), fText, b, new RectangleF(body.X + pad, ry, lineW, replyH), wrap);
|
|
1306
1422
|
else
|
|
1307
1423
|
{
|
|
1308
|
-
string shown =
|
|
1309
|
-
?
|
|
1424
|
+
string shown = progressBody.Length > 0 && !petFinished
|
|
1425
|
+
? progressPrefix + Tail(g, progressBody, fText, lineW - g.MeasureString(progressPrefix, fText, 100000, fmt).Width, fmt)
|
|
1310
1426
|
: Tail(g, progress, fText, lineW, fmt);
|
|
1311
1427
|
SizeF size = g.MeasureString(shown.Length > 0 ? shown : " ", fText, 100000, fmt);
|
|
1312
1428
|
g.DrawString(shown, fText, b, body.X + pad, ry + (replyH - size.Height) / 2f, fmt);
|
|
@@ -1584,16 +1700,33 @@ namespace DshComputerUse
|
|
|
1584
1700
|
if (nCode >= 0 && visible)
|
|
1585
1701
|
{
|
|
1586
1702
|
int msg = wParam.ToInt32();
|
|
1587
|
-
//
|
|
1703
|
+
// Hardware-rate cursor tracking on WM_MOUSEMOVE: never triggers takeover, only moves
|
|
1704
|
+
// the cached resting badge via SetWindowPos for silky native-grade responsiveness.
|
|
1705
|
+
if (msg == 0x0200)
|
|
1706
|
+
{
|
|
1707
|
+
if (clickTargetEnabled && !petFinished && markActive && markIsResting && invoker != null)
|
|
1708
|
+
{
|
|
1709
|
+
var mm = (Native.MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(Native.MSLLHOOKSTRUCT));
|
|
1710
|
+
latestMouseX = mm.pt.X;
|
|
1711
|
+
latestMouseY = mm.pt.Y;
|
|
1712
|
+
if (Interlocked.Exchange(ref mouseMovePending, 1) == 0)
|
|
1713
|
+
{
|
|
1714
|
+
try { invoker.BeginInvoke((MethodInvoker)SyncRestingCursorOnUi); }
|
|
1715
|
+
catch (Exception) { Interlocked.Exchange(ref mouseMovePending, 0); }
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
return Native.CallNextHookEx(mouseHook, nCode, wParam, lParam);
|
|
1719
|
+
}
|
|
1588
1720
|
bool isClick = msg == 0x0201 || msg == 0x0204 || msg == 0x0207;
|
|
1589
1721
|
bool isWheel = msg == 0x020A || msg == 0x020E;
|
|
1590
1722
|
if (isClick || isWheel)
|
|
1591
1723
|
{
|
|
1592
1724
|
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
|
-
|
|
1725
|
+
// Ignore synthetic clicks injected by our own SendInput (LLMHF_INJECTED = 0x01, lower IL = 0x02),
|
|
1726
|
+
// and ignore trailing clicks during the first 350ms after control mode begins.
|
|
1727
|
+
int now = Environment.TickCount;
|
|
1728
|
+
if ((ms.flags & 0x03) == 0 && ms.dwExtraInfo != Native.Marker && unchecked(now - shownTick) >= 350 && !IsOnOwnUi(ms.pt.X, ms.pt.Y))
|
|
1595
1729
|
{
|
|
1596
|
-
int now = Environment.TickCount;
|
|
1597
1730
|
lastTyping = now;
|
|
1598
1731
|
if (isClick)
|
|
1599
1732
|
{
|
package/helper/Program.cs
CHANGED
|
@@ -221,6 +221,7 @@ namespace DshComputerUse
|
|
|
221
221
|
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;
|
|
222
222
|
case "clipboard_restore": { var d = new Dictionary<string, object>(); d["restored"] = Clip.RestoreAgent(); return d; }
|
|
223
223
|
case "ui": return Uia.Elements(r);
|
|
224
|
+
case "ui_find": return Uia.Find(r);
|
|
224
225
|
case "text": return Uia.Text(r);
|
|
225
226
|
case "ocr": return Ocr.Read(r);
|
|
226
227
|
case "marks": return Uia.Marks(r);
|
|
@@ -228,10 +229,11 @@ namespace DshComputerUse
|
|
|
228
229
|
case "ui_point_click": return Uia.ClickAtPoint(r);
|
|
229
230
|
case "overlay_show": Overlay.ExcludeFromCapture = Args.Bool(r, "excludeFromCapture", true); Overlay.Show(r); return null;
|
|
230
231
|
case "overlay_pause": Overlay.SetPaused(Args.Bool(r, "paused", false)); return null;
|
|
232
|
+
case "overlay_waiting": Overlay.SetWaiting(Args.Bool(r, "waiting", false)); return null;
|
|
231
233
|
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
234
|
case "window_uncard": return Windows.Uncard(new IntPtr(Convert.ToInt64(r["hwnd"])));
|
|
233
235
|
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;
|
|
236
|
+
case "pet_update": Overlay.PetUpdate(Args.Str(r, "thinking", ""), Args.Str(r, "reply", ""), Args.Strs(r, "steps")); return null;
|
|
235
237
|
case "pet_finish": Overlay.Finish(Args.Int(r, "holdMs", 4000)); return null;
|
|
236
238
|
case "overlay_hide": Overlay.Hide(); return null;
|
|
237
239
|
default: throw new Exception("unknown command: " + cmd);
|