@copylee/dsh-computer-use 0.8.5 → 0.8.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/icon.svg +12 -0
- package/helper/CuHelper.cs +37 -2
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +5 -1
package/assets/icon.svg
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 128 128" fill="none">
|
|
2
|
+
<defs>
|
|
3
|
+
<linearGradient id="dsh_computer_use_bg" x1="0" y1="0" x2="128" y2="128" gradientUnits="userSpaceOnUse">
|
|
4
|
+
<stop stop-color="#FB923C"/>
|
|
5
|
+
<stop offset="1" stop-color="#EA580C"/>
|
|
6
|
+
</linearGradient>
|
|
7
|
+
</defs>
|
|
8
|
+
<rect width="128" height="128" rx="28" fill="url(#dsh_computer_use_bg)"/>
|
|
9
|
+
<g transform="translate(28 28) scale(3)" stroke="#FFFFFF" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
10
|
+
<path d="M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z"/>
|
|
11
|
+
</g>
|
|
12
|
+
</svg>
|
package/helper/CuHelper.cs
CHANGED
|
@@ -1077,6 +1077,7 @@ namespace DshComputerUse
|
|
|
1077
1077
|
public static Bitmap Capture(Rectangle area, IntPtr exclude)
|
|
1078
1078
|
{
|
|
1079
1079
|
if (!Ready()) return null;
|
|
1080
|
+
Bitmap result = null;
|
|
1080
1081
|
try
|
|
1081
1082
|
{
|
|
1082
1083
|
// The never-shown host must be as large as the capture, or the control is clipped.
|
|
@@ -1086,7 +1087,7 @@ namespace DshComputerUse
|
|
|
1086
1087
|
frame = null;
|
|
1087
1088
|
var rc = new Native.RECT { Left = area.Left, Top = area.Top, Right = area.Right, Bottom = area.Bottom };
|
|
1088
1089
|
if (!MagSetWindowSource(magnifier, rc)) { broken = true; Why = "source"; return null; }
|
|
1089
|
-
|
|
1090
|
+
result = frame;
|
|
1090
1091
|
frame = null;
|
|
1091
1092
|
if (result == null || result.Width != area.Width || result.Height != area.Height)
|
|
1092
1093
|
{
|
|
@@ -1095,9 +1096,43 @@ namespace DshComputerUse
|
|
|
1095
1096
|
broken = true;
|
|
1096
1097
|
return null;
|
|
1097
1098
|
}
|
|
1099
|
+
if (!HasVisiblePixels(result))
|
|
1100
|
+
{
|
|
1101
|
+
result.Dispose();
|
|
1102
|
+
broken = true;
|
|
1103
|
+
Why = "black magnifier frame";
|
|
1104
|
+
Console.Error.WriteLine("Magnification capture returned a black frame; using BitBlt for the rest of this helper process.");
|
|
1105
|
+
return null;
|
|
1106
|
+
}
|
|
1098
1107
|
return result;
|
|
1099
1108
|
}
|
|
1100
|
-
catch (Exception e)
|
|
1109
|
+
catch (Exception e)
|
|
1110
|
+
{
|
|
1111
|
+
if (result != null) result.Dispose();
|
|
1112
|
+
broken = true;
|
|
1113
|
+
Why = "capture: " + e.Message;
|
|
1114
|
+
return null;
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
internal static bool HasVisiblePixels(Bitmap bitmap)
|
|
1119
|
+
{
|
|
1120
|
+
var data = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppRgb);
|
|
1121
|
+
try
|
|
1122
|
+
{
|
|
1123
|
+
var row = new byte[bitmap.Width * 4];
|
|
1124
|
+
for (int y = 0; y < bitmap.Height; y++)
|
|
1125
|
+
{
|
|
1126
|
+
Marshal.Copy(IntPtr.Add(data.Scan0, y * data.Stride), row, 0, row.Length);
|
|
1127
|
+
for (int x = 0; x < row.Length; x += 4)
|
|
1128
|
+
{
|
|
1129
|
+
// Ignore the padding byte and allow black-level noise.
|
|
1130
|
+
if (row[x] > 3 || row[x + 1] > 3 || row[x + 2] > 3) return true;
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
return false;
|
|
1134
|
+
}
|
|
1135
|
+
finally { bitmap.UnlockBits(data); }
|
|
1101
1136
|
}
|
|
1102
1137
|
|
|
1103
1138
|
static bool OnImage(IntPtr hwnd, IntPtr srcdata, MAGIMAGEHEADER h, IntPtr destdata, MAGIMAGEHEADER dh, Native.RECT unclipped, Native.RECT clipped, IntPtr dirty)
|
package/locale/en.json
ADDED
package/locale/zh.json
ADDED
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@copylee/dsh-computer-use",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.7",
|
|
4
4
|
"description": "DeepSeek Harness Computer Use 插件(Windows):让 AI 看屏幕、点鼠标、敲键盘操控电脑;控制时屏幕泛起橙色光晕并显示“DeepSeek Harness 正在操控你的电脑”,按 Esc 暂停 / 继续。",
|
|
5
|
+
"icon": "assets/icon.svg",
|
|
5
6
|
"type": "module",
|
|
6
7
|
"author": "copylee",
|
|
7
8
|
"repository": {
|
|
@@ -23,9 +24,12 @@
|
|
|
23
24
|
"types": "./lib/types/client/index.d.ts",
|
|
24
25
|
"default": "./lib/client.js"
|
|
25
26
|
},
|
|
27
|
+
"./locale/*.json": "./locale/*.json",
|
|
26
28
|
"./package.json": "./package.json"
|
|
27
29
|
},
|
|
28
30
|
"files": [
|
|
31
|
+
"locale/*.json",
|
|
32
|
+
"assets/icon.svg",
|
|
29
33
|
"lib/index.js",
|
|
30
34
|
"lib/native-worker.js",
|
|
31
35
|
"lib/client.js",
|