@copylee/dsh-computer-use 0.16.0 → 0.17.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 CHANGED
@@ -48,7 +48,7 @@
48
48
  ## 操控期间,你仍然掌握主动权
49
49
 
50
50
  - **三档会话启用方式**:在 **设置 → 电脑控制** 可选「按会话开启(默认关闭)」「新会话默认开启」或「总是开启(隐藏输入框左下角「电脑控制」胶囊)」;也支持 `/cu on|off|toggle|status|reset|stop|revoke <应用>` 快捷控制。
51
- - **实时接管感知 + 三档尺寸迷你卡片**:开始操控后,屏幕四周亮起橙色光晕,迷你进度卡片支持**紧凑 / 标准 / 详情**三档尺寸与按钮悬停中文提示,简短中间回复直接留在卡片内不闪弹主窗口;你随时可按 **Esc** 暂停,或直接用鼠标点击/滚轮/键盘接管——插件会自动将脱敏操作语义(控件名称、窗口、坐标,绝不记录密码与输入明文)实时同步给 AI,让它顺着你的意图继续。
51
+ - **实时接管感知 + 顶部进度胶囊**:开始操控后,屏幕四周亮起橙色光晕,屏幕顶部的进度胶囊滚动显示一行思考(思考时图标上冒出 … 气泡)和最近两步,⋯ 菜单收纳暂停、跳过等待、展开、输入新指令等操作(也可换成紧凑 / 标准 / 详情三档卡片);简短中间回复留在胶囊内,持续输出的正文会在输出过程中切回 DSH;你随时可按 **Esc** 暂停,或直接用鼠标点击/滚轮/键盘接管——插件会自动将脱敏操作语义(控件名称、窗口、坐标,绝不记录密码与输入明文)实时同步给 AI,让它顺着你的意图继续。
52
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)。
package/helper/Capture.cs CHANGED
@@ -107,6 +107,31 @@ namespace DshComputerUse
107
107
  return n == 0 ? 0 : (double)diff / n;
108
108
  }
109
109
 
110
+ static readonly Dictionary<string, byte[]> lastFrames = new Dictionary<string, byte[]>();
111
+
112
+ /**
113
+ * Share of sampled pixels that changed since the previous call with the
114
+ * same key (1 on the first call). Lets a long poll notice a still screen.
115
+ */
116
+ public static Dictionary<string, object> FrameDelta(Dictionary<string, object> r)
117
+ {
118
+ int x = Args.Int(r, "x", 0), y = Args.Int(r, "y", 0), w = Args.Int(r, "width", 0), h = Args.Int(r, "height", 0);
119
+ string key = Args.Str(r, "key", "") + "|" + RectKey(x, y, w, h);
120
+ if (w <= 0 || h <= 0) throw new Exception("invalid frame rect");
121
+ byte[] cur = Sample(x, y, w, h);
122
+ byte[] prev;
123
+ double delta = 1;
124
+ lock (lastFrames)
125
+ {
126
+ if (lastFrames.TryGetValue(key, out prev) && prev.Length == cur.Length) delta = Changed(prev, cur);
127
+ if (lastFrames.Count > 16) lastFrames.Clear();
128
+ lastFrames[key] = cur;
129
+ }
130
+ var d = new Dictionary<string, object>();
131
+ d["changed"] = delta;
132
+ return d;
133
+ }
134
+
110
135
  /**
111
136
  * Wait until the screen stops changing: at least minMs, then until two
112
137
  * consecutive samples (quietMs apart in total) differ in under 0.2% of
package/helper/Native.cs CHANGED
@@ -55,6 +55,7 @@ namespace DshComputerUse
55
55
  [DllImport("winmm.dll")] public static extern uint timeEndPeriod(uint uPeriod);
56
56
  /** Blocks until the next DWM composition (vblank-locked frame pacing). */
57
57
  [DllImport("dwmapi.dll")] public static extern int DwmFlush();
58
+ [DllImport("user32.dll")] public static extern short GetAsyncKeyState(int vKey);
58
59
  [StructLayout(LayoutKind.Sequential)]
59
60
  public struct BITMAPINFOHEADER { public uint biSize; public int biWidth; public int biHeight; public ushort biPlanes; public ushort biBitCount; public uint biCompression; public uint biSizeImage; public int biXPelsPerMeter; public int biYPelsPerMeter; public uint biClrUsed; public uint biClrImportant; }
60
61
  [DllImport("gdi32.dll")] public static extern IntPtr CreateDIBSection(IntPtr hdc, ref BITMAPINFOHEADER pbmi, uint iUsage, out IntPtr ppvBits, IntPtr hSection, uint dwOffset);