@copylee/dsh-computer-use 0.8.6 → 0.8.8
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 +63 -3
- package/lib/index.js +4 -3
- 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
|
@@ -279,7 +279,12 @@ namespace DshComputerUse
|
|
|
279
279
|
case "settle": return Screen2.Settle(r);
|
|
280
280
|
case "cursor": { Native.POINT p; Native.GetCursorPos(out p); return Pt(p.X, p.Y); }
|
|
281
281
|
case "move": using (new PassThrough()) { Overlay.Dodge(Args.Int(r, "x", 0), Args.Int(r, "y", 0)); Input.Move(Args.Int(r, "x", 0), Args.Int(r, "y", 0)); } return null;
|
|
282
|
-
case "click":
|
|
282
|
+
case "click":
|
|
283
|
+
Native.POINT clickPoint;
|
|
284
|
+
if (Args.Has(r, "x")) clickPoint = new Native.POINT(Args.Int(r, "x", 0), Args.Int(r, "y", 0));
|
|
285
|
+
else if (!Native.GetCursorPos(out clickPoint)) throw new Exception("Cannot read cursor position");
|
|
286
|
+
using (CardLayer.UncoverClick(clickPoint))
|
|
287
|
+
using (new PassThrough()) return Input.Click(r);
|
|
283
288
|
case "button": using (new PassThrough()) return Input.Button(r);
|
|
284
289
|
case "drag": using (new PassThrough()) return Input.Drag(r);
|
|
285
290
|
case "scroll": using (new PassThrough()) return Input.Scroll(r);
|
|
@@ -1007,6 +1012,57 @@ namespace DshComputerUse
|
|
|
1007
1012
|
return new Hidden(r.IntersectsWith(area) ? Hwnd : IntPtr.Zero);
|
|
1008
1013
|
}
|
|
1009
1014
|
|
|
1015
|
+
// Chromium cards can swallow SendInput even after WS_EX_TRANSPARENT has
|
|
1016
|
+
// changed the hit test. Hide the card through dispatch only when it covers
|
|
1017
|
+
// the click, keeping its position, z-order and the work window's focus.
|
|
1018
|
+
public static IDisposable UncoverClick(Native.POINT point)
|
|
1019
|
+
{
|
|
1020
|
+
var hwnd = Hwnd;
|
|
1021
|
+
if (!Live()) return null;
|
|
1022
|
+
Native.RECT rect;
|
|
1023
|
+
if (!Native.GetWindowRect(hwnd, out rect)) throw new Exception("Cannot verify the control card bounds");
|
|
1024
|
+
if (point.X < rect.Left || point.X >= rect.Right || point.Y < rect.Top || point.Y >= rect.Bottom) return null;
|
|
1025
|
+
if (Native.GetForegroundWindow() == hwnd) throw new Exception("The control card is focused. Focus the work window before clicking.");
|
|
1026
|
+
object expected;
|
|
1027
|
+
if (!Windows.At(point.X, point.Y).TryGetValue("hwnd", out expected))
|
|
1028
|
+
throw new Exception("No work window found under the control card");
|
|
1029
|
+
var uncovered = new Uncovered(hwnd);
|
|
1030
|
+
try
|
|
1031
|
+
{
|
|
1032
|
+
object hit;
|
|
1033
|
+
if (!Windows.At(point.X, point.Y).TryGetValue("hwnd", out hit) || !Object.Equals(expected, hit))
|
|
1034
|
+
throw new Exception("The window under the control card changed. Look again before clicking.");
|
|
1035
|
+
return uncovered;
|
|
1036
|
+
}
|
|
1037
|
+
catch
|
|
1038
|
+
{
|
|
1039
|
+
uncovered.Dispose();
|
|
1040
|
+
throw;
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
sealed class Uncovered : IDisposable
|
|
1045
|
+
{
|
|
1046
|
+
// NOSIZE | NOMOVE | NOZORDER | NOACTIVATE | NOOWNERZORDER.
|
|
1047
|
+
const uint PreservePlacement = 0x0217;
|
|
1048
|
+
readonly IntPtr hwnd;
|
|
1049
|
+
|
|
1050
|
+
public Uncovered(IntPtr hwnd)
|
|
1051
|
+
{
|
|
1052
|
+
this.hwnd = hwnd;
|
|
1053
|
+
if (!Native.SetWindowPos(hwnd, IntPtr.Zero, 0, 0, 0, 0, PreservePlacement | 0x0080)
|
|
1054
|
+
|| Native.IsWindowVisible(hwnd))
|
|
1055
|
+
throw new Exception("Cannot hide the control card for the click");
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
public void Dispose()
|
|
1059
|
+
{
|
|
1060
|
+
if (Hwnd == hwnd && Native.IsWindow(hwnd)
|
|
1061
|
+
&& !Native.SetWindowPos(hwnd, IntPtr.Zero, 0, 0, 0, 0, PreservePlacement | 0x0040))
|
|
1062
|
+
Native.ShowWindow(hwnd, 4); // SW_SHOWNOACTIVATE
|
|
1063
|
+
}
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1010
1066
|
sealed class Hidden : IDisposable
|
|
1011
1067
|
{
|
|
1012
1068
|
readonly IntPtr hwnd;
|
|
@@ -1900,8 +1956,12 @@ namespace DshComputerUse
|
|
|
1900
1956
|
if (String.Join(",", el.GetRuntimeId()) == runtimeId) { target = el; break; }
|
|
1901
1957
|
if (el.Current.ControlType == ControlType.Window) break;
|
|
1902
1958
|
}
|
|
1903
|
-
|
|
1904
|
-
|
|
1959
|
+
// Some providers stop the hit test at a host pane. The caller can
|
|
1960
|
+
// re-resolve the control and verify its window before a pointer click.
|
|
1961
|
+
if (target == null) return result;
|
|
1962
|
+
if (target.Current.IsOffscreen) throw new Exception("The named target is offscreen");
|
|
1963
|
+
if (!target.Current.IsEnabled)
|
|
1964
|
+
throw new Exception("The named target is disabled");
|
|
1905
1965
|
object pattern = null;
|
|
1906
1966
|
if (action == "invoke" && !target.TryGetCurrentPattern(InvokePattern.Pattern, out pattern)) return result;
|
|
1907
1967
|
if (action == "focus" && !target.Current.IsKeyboardFocusable) return result;
|
package/lib/index.js
CHANGED
|
@@ -9102,7 +9102,7 @@ function createTools(host) {
|
|
|
9102
9102
|
}));
|
|
9103
9103
|
tools.push(defineTool({
|
|
9104
9104
|
name: "open_application",
|
|
9105
|
-
description: "Open an app by name (e.g. \"Chrome\", \"记事本\", \"微信\", \"Excel\"), an .exe path, or a URL, or bring it to the front if it is already running. Faster and more reliable than clicking the taskbar or Start menu.
|
|
9105
|
+
description: "Open an app by name (e.g. \"Chrome\", \"记事本\", \"微信\", \"Excel\"), an .exe path, or a URL, or bring it to the front if it is already running. Faster and more reliable than clicking the taskbar or Start menu. Includes a screenshot when automatic screenshots are enabled and the model supports images.",
|
|
9106
9106
|
parameters: {
|
|
9107
9107
|
name: {
|
|
9108
9108
|
type: "string",
|
|
@@ -9119,8 +9119,9 @@ function createTools(host) {
|
|
|
9119
9119
|
async execute(args, exec) {
|
|
9120
9120
|
const call = await host.context(exec);
|
|
9121
9121
|
const text = await openApp(String(args.name ?? ""), args.new_instance === true, call);
|
|
9122
|
+
if (!call.vision || !computer.settings().autoScreenshot) return { text };
|
|
9122
9123
|
await computer.settle(call.signal);
|
|
9123
|
-
return withShot(host, text,
|
|
9124
|
+
return withShot(host, text, await computer.screenshot(), call);
|
|
9124
9125
|
},
|
|
9125
9126
|
presentCall: (args) => card(`打开应用 · ${args.name ?? ""}`)
|
|
9126
9127
|
}));
|
|
@@ -9411,7 +9412,7 @@ function createTools(host) {
|
|
|
9411
9412
|
if (index !== void 0) await computer.selectDisplay(index);
|
|
9412
9413
|
const list = (await computer.refreshDisplays()).map((d, i) => `${i}: ${d.width}x${d.height} at (${d.x}, ${d.y}), ${Math.round(d.dpi / 96 * 100)}% scale${d.primary ? ", primary" : ""}${i === computer.currentIndex ? " ← current" : ""}`).join("\n");
|
|
9413
9414
|
if (index === void 0) return { text: list };
|
|
9414
|
-
const shot = call.vision ? await computer.screenshot() : void 0;
|
|
9415
|
+
const shot = call.vision && computer.settings().autoScreenshot ? await computer.screenshot() : void 0;
|
|
9415
9416
|
return withShot(host, `Switched to display ${index}.\n${list}`, shot, call);
|
|
9416
9417
|
},
|
|
9417
9418
|
presentCall: () => card("切换显示器")
|
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.8",
|
|
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",
|