@copylee/dsh-computer-use 0.9.0 → 0.11.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/helper/CuHelper.cs +907 -73
- package/lib/client.js +276 -19
- package/lib/index.js +1127 -59
- package/lib/types/access.d.ts +7 -0
- package/lib/types/cdp.d.ts +55 -0
- package/lib/types/client/index.d.ts +4 -0
- package/lib/types/client/window-refs.d.ts +37 -0
- package/lib/types/computer.d.ts +52 -2
- package/lib/types/diagnostics.d.ts +76 -0
- package/lib/types/index.d.ts +12 -1
- package/lib/types/macros.d.ts +30 -0
- package/lib/types/routes.d.ts +14 -1
- package/lib/types/sessions.d.ts +2 -0
- package/lib/types/target.d.ts +4 -0
- package/lib/types/tools.d.ts +3 -0
- package/lib/types/update-check.d.ts +15 -0
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -67,6 +67,7 @@ window.__ModuleLoader__.load({
|
|
|
67
67
|
const ENTRY_ID = "copylee-computer-use";
|
|
68
68
|
const DEFAULTS = {
|
|
69
69
|
accessMode: "per-app",
|
|
70
|
+
sessionMode: "off",
|
|
70
71
|
defaultSessionEnabled: false,
|
|
71
72
|
overlay: true,
|
|
72
73
|
overlayLabel: "DeepSeek Harness",
|
|
@@ -83,7 +84,12 @@ window.__ModuleLoader__.load({
|
|
|
83
84
|
userIdleMs: 1500,
|
|
84
85
|
typingMode: "stream",
|
|
85
86
|
quickSteps: false,
|
|
86
|
-
nativeHelper: true
|
|
87
|
+
nativeHelper: true,
|
|
88
|
+
elementFirstClick: true,
|
|
89
|
+
restorePointer: false,
|
|
90
|
+
protectPasswords: true,
|
|
91
|
+
windowChangeGuard: true,
|
|
92
|
+
cdpPort: 0
|
|
87
93
|
};
|
|
88
94
|
/** Unwrap `.volatile()` refs (`{ get() }`) and fall back to defaults for bad values. */
|
|
89
95
|
function resolveConfig(raw) {
|
|
@@ -94,10 +100,12 @@ window.__ModuleLoader__.load({
|
|
|
94
100
|
return typeof value === "number" && Number.isFinite(value) ? Math.min(max, Math.max(min, Math.round(value))) : DEFAULTS[key];
|
|
95
101
|
};
|
|
96
102
|
const bool = (key) => typeof out[key] === "boolean" ? out[key] : DEFAULTS[key];
|
|
103
|
+
const sessionMode = out.sessionMode === "off" || out.sessionMode === "on" || out.sessionMode === "always" ? out.sessionMode : out.defaultSessionEnabled === true ? "on" : DEFAULTS.sessionMode;
|
|
97
104
|
return {
|
|
98
105
|
harnessUrl: typeof out.harnessUrl === "string" ? httpOrigin(out.harnessUrl.trim()) : void 0,
|
|
99
106
|
accessMode: out.accessMode === "allow-all" || out.accessMode === "per-app" ? out.accessMode : DEFAULTS.accessMode,
|
|
100
|
-
|
|
107
|
+
sessionMode,
|
|
108
|
+
defaultSessionEnabled: sessionMode !== "off",
|
|
101
109
|
overlay: bool("overlay"),
|
|
102
110
|
overlayLabel: typeof out.overlayLabel === "string" && out.overlayLabel.trim() !== "" ? out.overlayLabel.trim().slice(0, 40) : DEFAULTS.overlayLabel,
|
|
103
111
|
hostWindow: out.hostWindow === "pet" || out.hostWindow === "card" || out.hostWindow === "minimize" || out.hostWindow === "keep" ? out.hostWindow : out.minimizeHostWindow === true ? "minimize" : DEFAULTS.hostWindow,
|
|
@@ -112,6 +120,11 @@ window.__ModuleLoader__.load({
|
|
|
112
120
|
userIdleMs: num("userIdleMs", 300, 1e4),
|
|
113
121
|
quickSteps: bool("quickSteps"),
|
|
114
122
|
nativeHelper: bool("nativeHelper"),
|
|
123
|
+
elementFirstClick: bool("elementFirstClick"),
|
|
124
|
+
restorePointer: bool("restorePointer"),
|
|
125
|
+
protectPasswords: bool("protectPasswords"),
|
|
126
|
+
windowChangeGuard: bool("windowChangeGuard"),
|
|
127
|
+
cdpPort: num("cdpPort", 0, 65535),
|
|
115
128
|
typingMode: out.typingMode === "stream" || out.typingMode === "type" || out.typingMode === "paste" ? out.typingMode : DEFAULTS.typingMode,
|
|
116
129
|
blockedApps: Array.isArray(out.blockedApps) ? out.blockedApps.filter((item) => typeof item === "string" && item.trim() !== "") : []
|
|
117
130
|
};
|
|
@@ -259,6 +272,8 @@ window.__ModuleLoader__.load({
|
|
|
259
272
|
const h$3 = react.createElement;
|
|
260
273
|
/** Client-side cache so switching between sessions does not flash stale state. */
|
|
261
274
|
const cache = /* @__PURE__ */ new Map();
|
|
275
|
+
/** Remember whether Settings hides the pill ("总是开启" mode) so remounts do not flash it. */
|
|
276
|
+
let cachedHidden;
|
|
262
277
|
const PILL_CSS = `
|
|
263
278
|
.cl-cu-pill {
|
|
264
279
|
display: inline-flex;
|
|
@@ -314,7 +329,7 @@ window.__ModuleLoader__.load({
|
|
|
314
329
|
style.textContent = PILL_CSS;
|
|
315
330
|
document.head.appendChild(style);
|
|
316
331
|
}
|
|
317
|
-
function isZh() {
|
|
332
|
+
function isZh$1() {
|
|
318
333
|
if (typeof document === "undefined") return true;
|
|
319
334
|
return (document.documentElement.lang || navigator.language || "zh").toLowerCase().startsWith("zh");
|
|
320
335
|
}
|
|
@@ -341,7 +356,8 @@ window.__ModuleLoader__.load({
|
|
|
341
356
|
return function ComposerPill(props) {
|
|
342
357
|
const sessionId = typeof props?.sessionId === "string" && props.sessionId.trim() !== "" ? props.sessionId : void 0;
|
|
343
358
|
const [enabled, setEnabled] = react.useState(() => sessionId ? cache.get(sessionId) ?? false : false);
|
|
344
|
-
const [
|
|
359
|
+
const [hidden, setHidden] = react.useState(() => cachedHidden === true);
|
|
360
|
+
const [ready, setReady] = react.useState(() => sessionId ? cache.has(sessionId) && cachedHidden !== void 0 : false);
|
|
345
361
|
const [busy, setBusy] = react.useState(false);
|
|
346
362
|
react.useEffect(() => {
|
|
347
363
|
ensureStyle();
|
|
@@ -356,8 +372,11 @@ window.__ModuleLoader__.load({
|
|
|
356
372
|
const body = await res.json();
|
|
357
373
|
if (cancelled.current) return;
|
|
358
374
|
const value = body.enabled === true;
|
|
375
|
+
const hidePill = body.alwaysOn === true || body.showPill === false;
|
|
359
376
|
cache.set(id, value);
|
|
377
|
+
cachedHidden = hidePill;
|
|
360
378
|
setEnabled(value);
|
|
379
|
+
setHidden(hidePill);
|
|
361
380
|
setReady(true);
|
|
362
381
|
} catch {
|
|
363
382
|
if (!cancelled.current) setReady(true);
|
|
@@ -366,8 +385,9 @@ window.__ModuleLoader__.load({
|
|
|
366
385
|
react.useEffect(() => {
|
|
367
386
|
if (!sessionId) return;
|
|
368
387
|
const cancelled = { current: false };
|
|
369
|
-
if (cache.has(sessionId)) {
|
|
388
|
+
if (cache.has(sessionId) && cachedHidden !== void 0) {
|
|
370
389
|
setEnabled(cache.get(sessionId));
|
|
390
|
+
setHidden(cachedHidden);
|
|
371
391
|
setReady(true);
|
|
372
392
|
} else {
|
|
373
393
|
setEnabled(false);
|
|
@@ -382,8 +402,8 @@ window.__ModuleLoader__.load({
|
|
|
382
402
|
unsub?.();
|
|
383
403
|
};
|
|
384
404
|
}, [sessionId, fetchState]);
|
|
385
|
-
if (!sessionId) return null;
|
|
386
|
-
const zh = isZh();
|
|
405
|
+
if (!sessionId || hidden || !ready && cachedHidden !== false) return null;
|
|
406
|
+
const zh = isZh$1();
|
|
387
407
|
const label = zh ? "电脑控制" : "Computer";
|
|
388
408
|
const title = enabled ? zh ? "当前会话已开启电脑控制,点击关闭" : "Computer use is enabled for this session (click to disable)" : zh ? "当前会话未开启电脑控制,点击开启" : "Computer use is disabled for this session (click to enable)";
|
|
389
409
|
const toggle = async () => {
|
|
@@ -896,6 +916,115 @@ window.__ModuleLoader__.load({
|
|
|
896
916
|
}, "刷新"), 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);
|
|
897
917
|
}
|
|
898
918
|
//#endregion
|
|
919
|
+
//#region lib/types/client/window-refs.js
|
|
920
|
+
/**
|
|
921
|
+
* Composer `@` reference source for running Windows application windows.
|
|
922
|
+
* Uses DSH's optional `inputTriggers` service (`ctx.inject(['inputTriggers'])`)
|
|
923
|
+
* and queries the passive read-only `/api/dsh-computer-use/windows` endpoint
|
|
924
|
+
* without ever lighting up the overlay or focusing any window.
|
|
925
|
+
*/
|
|
926
|
+
const WINDOWS_ROUTE = "/api/dsh-computer-use/windows";
|
|
927
|
+
const SOURCE_NAME = "copylee-computer-use:windows";
|
|
928
|
+
const REF_PREFIX = "cu-window:";
|
|
929
|
+
function isZh() {
|
|
930
|
+
if (typeof document === "undefined") return true;
|
|
931
|
+
return (document.documentElement.lang || navigator.language || "zh").toLowerCase().startsWith("zh");
|
|
932
|
+
}
|
|
933
|
+
function formatRefText(win) {
|
|
934
|
+
return `[窗口: ${win.title.replace(/[\r\n\]]+/g, " ").trim().slice(0, 80)} | exe=${win.exe} | hwnd=${win.hwnd} | pid=${win.pid}]`;
|
|
935
|
+
}
|
|
936
|
+
function parseWindowRef(ref) {
|
|
937
|
+
if (!ref.startsWith(REF_PREFIX)) return void 0;
|
|
938
|
+
const parts = ref.slice(10).split("|");
|
|
939
|
+
const hwnd = Number.parseInt(parts[0] ?? "", 10);
|
|
940
|
+
const pid = Number.parseInt(parts[1] ?? "", 10);
|
|
941
|
+
if (!Number.isFinite(hwnd) || !Number.isFinite(pid)) return void 0;
|
|
942
|
+
return {
|
|
943
|
+
hwnd,
|
|
944
|
+
pid,
|
|
945
|
+
exe: decodeURIComponent(parts[2] ?? ""),
|
|
946
|
+
title: decodeURIComponent(parts[3] ?? "")
|
|
947
|
+
};
|
|
948
|
+
}
|
|
949
|
+
function registerWindowReferenceSource(scope) {
|
|
950
|
+
const triggers = scope.inputTriggers;
|
|
951
|
+
if (typeof triggers?.registerSource !== "function") return;
|
|
952
|
+
const zh = isZh();
|
|
953
|
+
const section = zh ? "运行中的窗口" : "Running windows";
|
|
954
|
+
scope.effect(() => triggers.registerSource({
|
|
955
|
+
trigger: "@",
|
|
956
|
+
name: SOURCE_NAME,
|
|
957
|
+
showGroupTitle: false,
|
|
958
|
+
lexicon: () => [],
|
|
959
|
+
subscribeLexicon: () => () => {},
|
|
960
|
+
async candidates(_session, request) {
|
|
961
|
+
if (request?.quoted || request?.drilled) return [];
|
|
962
|
+
const narrowed = (request?.query ?? "").trim().replace(/^(窗口|应用|win|window|app)\s*[::]\s*/i, "");
|
|
963
|
+
try {
|
|
964
|
+
const res = await fetch(`${WINDOWS_ROUTE}?q=${encodeURIComponent(narrowed)}`, {
|
|
965
|
+
credentials: "same-origin",
|
|
966
|
+
cache: "no-store",
|
|
967
|
+
...request?.signal ? { signal: request.signal } : {}
|
|
968
|
+
});
|
|
969
|
+
if (!res.ok) return [];
|
|
970
|
+
const body = await res.json();
|
|
971
|
+
return (Array.isArray(body.windows) ? body.windows : []).map((win) => {
|
|
972
|
+
const shortTitle = win.title.slice(0, 48);
|
|
973
|
+
const ref = `${REF_PREFIX}${win.hwnd}|${win.pid}|${encodeURIComponent(win.exe)}|${encodeURIComponent(shortTitle)}`;
|
|
974
|
+
return {
|
|
975
|
+
name: shortTitle,
|
|
976
|
+
label: `${shortTitle}`,
|
|
977
|
+
description: `${win.exe}${win.minimized ? zh ? " · 已最小化" : " · minimized" : ""}`,
|
|
978
|
+
icon: "window",
|
|
979
|
+
section,
|
|
980
|
+
value: {
|
|
981
|
+
kind: "cu-window",
|
|
982
|
+
ref,
|
|
983
|
+
win
|
|
984
|
+
}
|
|
985
|
+
};
|
|
986
|
+
});
|
|
987
|
+
} catch {
|
|
988
|
+
return [];
|
|
989
|
+
}
|
|
990
|
+
},
|
|
991
|
+
onPick(pick) {
|
|
992
|
+
const value = pick?.candidate?.value;
|
|
993
|
+
if (value?.kind !== "cu-window" || !value.ref || !value.win) return { text: "" };
|
|
994
|
+
const label = value.win.title.slice(0, 32) || value.win.exe;
|
|
995
|
+
return { insert: {
|
|
996
|
+
source: SOURCE_NAME,
|
|
997
|
+
ref: value.ref,
|
|
998
|
+
label,
|
|
999
|
+
appearance: "file",
|
|
1000
|
+
clipboardText: formatRefText(value.win)
|
|
1001
|
+
} };
|
|
1002
|
+
},
|
|
1003
|
+
codec: {
|
|
1004
|
+
clipboardText: (ref) => {
|
|
1005
|
+
const parsed = parseWindowRef(ref);
|
|
1006
|
+
return parsed ? formatRefText(parsed) : ref;
|
|
1007
|
+
},
|
|
1008
|
+
async serialize(ref, signal) {
|
|
1009
|
+
const parsed = parseWindowRef(ref);
|
|
1010
|
+
if (!parsed) return ref;
|
|
1011
|
+
try {
|
|
1012
|
+
const res = await fetch(WINDOWS_ROUTE, {
|
|
1013
|
+
credentials: "same-origin",
|
|
1014
|
+
cache: "no-store",
|
|
1015
|
+
...signal ? { signal } : {}
|
|
1016
|
+
});
|
|
1017
|
+
if (res.ok) {
|
|
1018
|
+
const live = (await res.json()).windows?.find((w) => w.hwnd === parsed.hwnd && w.pid === parsed.pid);
|
|
1019
|
+
if (live) return formatRefText(live);
|
|
1020
|
+
}
|
|
1021
|
+
} catch {}
|
|
1022
|
+
return formatRefText(parsed);
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
}), "computer-use: @window reference source");
|
|
1026
|
+
}
|
|
1027
|
+
//#endregion
|
|
899
1028
|
//#region lib/types/client/index.js
|
|
900
1029
|
/**
|
|
901
1030
|
* Browser half: the "电脑控制" (Computer use) section in Settings. It reads the
|
|
@@ -907,6 +1036,8 @@ window.__ModuleLoader__.load({
|
|
|
907
1036
|
const STATUS_ROUTE = "/api/dsh-computer-use/status";
|
|
908
1037
|
const SCREENSHOTS_ROUTE = "/api/dsh-computer-use/screenshots";
|
|
909
1038
|
const SCREENSHOTS_CLEAN_ROUTE = "/api/dsh-computer-use/screenshots/clean";
|
|
1039
|
+
const DIAGNOSTICS_ROUTE = "/api/dsh-computer-use/diagnostics";
|
|
1040
|
+
const UPDATE_ROUTE = "/api/dsh-computer-use/update";
|
|
910
1041
|
const mb = (bytes) => `${(bytes / 1048576).toFixed(1)} MB`;
|
|
911
1042
|
const PREVIEW_ROUTE = "/api/dsh-computer-use/preview";
|
|
912
1043
|
const h = react.createElement;
|
|
@@ -914,7 +1045,7 @@ window.__ModuleLoader__.load({
|
|
|
914
1045
|
const s = resolveConfig(value);
|
|
915
1046
|
return {
|
|
916
1047
|
accessMode: s.accessMode,
|
|
917
|
-
|
|
1048
|
+
sessionMode: s.sessionMode,
|
|
918
1049
|
blockedApps: s.blockedApps.join("\n"),
|
|
919
1050
|
overlay: s.overlay,
|
|
920
1051
|
overlayLabel: s.overlayLabel,
|
|
@@ -929,7 +1060,12 @@ window.__ModuleLoader__.load({
|
|
|
929
1060
|
settleMs: String(s.settleMs),
|
|
930
1061
|
maxLongEdge: String(s.maxLongEdge),
|
|
931
1062
|
maxMegapixels: String(Math.round(s.maxPixels / 1e4) / 100),
|
|
932
|
-
jpegQuality: String(s.jpegQuality)
|
|
1063
|
+
jpegQuality: String(s.jpegQuality),
|
|
1064
|
+
elementFirstClick: s.elementFirstClick,
|
|
1065
|
+
restorePointer: s.restorePointer,
|
|
1066
|
+
protectPasswords: s.protectPasswords,
|
|
1067
|
+
windowChangeGuard: s.windowChangeGuard,
|
|
1068
|
+
cdpPort: String(s.cdpPort)
|
|
933
1069
|
};
|
|
934
1070
|
}
|
|
935
1071
|
/** Range-checked numbers; returns field errors keyed by Draft field. */
|
|
@@ -944,12 +1080,14 @@ window.__ModuleLoader__.load({
|
|
|
944
1080
|
check("maxLongEdge", 640, 3840);
|
|
945
1081
|
check("maxMegapixels", .3, 8);
|
|
946
1082
|
check("jpegQuality", 30, 100);
|
|
1083
|
+
check("cdpPort", 0, 65535);
|
|
947
1084
|
return errors;
|
|
948
1085
|
}
|
|
949
1086
|
function valuesFrom(d) {
|
|
950
1087
|
return {
|
|
951
1088
|
accessMode: d.accessMode,
|
|
952
|
-
|
|
1089
|
+
sessionMode: d.sessionMode,
|
|
1090
|
+
defaultSessionEnabled: d.sessionMode !== "off",
|
|
953
1091
|
blockedApps: d.blockedApps.split(/[\n,,]/).map((item) => item.trim()).filter(Boolean),
|
|
954
1092
|
overlay: d.overlay,
|
|
955
1093
|
overlayLabel: d.overlayLabel.trim() || DEFAULTS.overlayLabel,
|
|
@@ -964,7 +1102,12 @@ window.__ModuleLoader__.load({
|
|
|
964
1102
|
settleMs: Math.round(Number(d.settleMs)),
|
|
965
1103
|
maxLongEdge: Math.round(Number(d.maxLongEdge)),
|
|
966
1104
|
maxPixels: Math.round(Number(d.maxMegapixels) * 1e6),
|
|
967
|
-
jpegQuality: Math.round(Number(d.jpegQuality))
|
|
1105
|
+
jpegQuality: Math.round(Number(d.jpegQuality)),
|
|
1106
|
+
elementFirstClick: d.elementFirstClick,
|
|
1107
|
+
restorePointer: d.restorePointer,
|
|
1108
|
+
protectPasswords: d.protectPasswords,
|
|
1109
|
+
windowChangeGuard: d.windowChangeGuard,
|
|
1110
|
+
cdpPort: Math.round(Number(d.cdpPort))
|
|
968
1111
|
};
|
|
969
1112
|
}
|
|
970
1113
|
const S = {
|
|
@@ -1157,6 +1300,8 @@ window.__ModuleLoader__.load({
|
|
|
1157
1300
|
const [cache, setCache] = react.useState(null);
|
|
1158
1301
|
const [cacheBusy, setCacheBusy] = react.useState(false);
|
|
1159
1302
|
const [cacheNote, setCacheNote] = react.useState(null);
|
|
1303
|
+
const [updateBusy, setUpdateBusy] = react.useState(false);
|
|
1304
|
+
const [updateInfo, setUpdateInfo] = react.useState(null);
|
|
1160
1305
|
const load = react.useCallback(async (reset) => {
|
|
1161
1306
|
try {
|
|
1162
1307
|
const result = await ctx.remote.settings.describe();
|
|
@@ -1313,6 +1458,52 @@ window.__ModuleLoader__.load({
|
|
|
1313
1458
|
});
|
|
1314
1459
|
}
|
|
1315
1460
|
};
|
|
1461
|
+
const exportDiagnostics = async () => {
|
|
1462
|
+
try {
|
|
1463
|
+
const response = await fetch(DIAGNOSTICS_ROUTE, {
|
|
1464
|
+
credentials: "same-origin",
|
|
1465
|
+
cache: "no-store"
|
|
1466
|
+
});
|
|
1467
|
+
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
1468
|
+
const text = await response.text();
|
|
1469
|
+
const blob = new Blob([text], { type: "text/plain;charset=utf-8" });
|
|
1470
|
+
const url = URL.createObjectURL(blob);
|
|
1471
|
+
const a = document.createElement("a");
|
|
1472
|
+
a.href = url;
|
|
1473
|
+
a.download = `dsh-computer-use-diagnostics-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.txt`;
|
|
1474
|
+
document.body.appendChild(a);
|
|
1475
|
+
a.click();
|
|
1476
|
+
a.remove();
|
|
1477
|
+
URL.revokeObjectURL(url);
|
|
1478
|
+
setMessage({
|
|
1479
|
+
kind: "ok",
|
|
1480
|
+
text: "已导出脱敏诊断报告(不含输入文本、剪贴板和截图)"
|
|
1481
|
+
});
|
|
1482
|
+
} catch (error) {
|
|
1483
|
+
setMessage({
|
|
1484
|
+
kind: "error",
|
|
1485
|
+
text: `导出诊断失败:${error.message}`
|
|
1486
|
+
});
|
|
1487
|
+
}
|
|
1488
|
+
};
|
|
1489
|
+
const checkUpdate = async () => {
|
|
1490
|
+
setUpdateBusy(true);
|
|
1491
|
+
try {
|
|
1492
|
+
const response = await fetch(UPDATE_ROUTE, {
|
|
1493
|
+
credentials: "same-origin",
|
|
1494
|
+
cache: "no-store"
|
|
1495
|
+
});
|
|
1496
|
+
setUpdateInfo(await response.json());
|
|
1497
|
+
} catch (error) {
|
|
1498
|
+
setUpdateInfo({
|
|
1499
|
+
current: status?.version ?? "0.0.0",
|
|
1500
|
+
hasUpdate: false,
|
|
1501
|
+
error: error.message
|
|
1502
|
+
});
|
|
1503
|
+
} finally {
|
|
1504
|
+
setUpdateBusy(false);
|
|
1505
|
+
}
|
|
1506
|
+
};
|
|
1316
1507
|
if (!loaded) return h("div", { style: S.page }, "加载中…");
|
|
1317
1508
|
const primary = status?.displays.find((d) => d.primary) ?? status?.displays[0];
|
|
1318
1509
|
const helperOk = status?.helper === "ready";
|
|
@@ -1332,7 +1523,10 @@ window.__ModuleLoader__.load({
|
|
|
1332
1523
|
return h("div", { style: S.page }, h("style", null, selectCss), h("div", null, h("h2", { style: S.title }, "电脑控制"), h("p", { style: S.subtitle }, "让 AI 看屏幕、点鼠标、敲键盘操控这台 Windows 电脑。操控时屏幕四周泛起橙色光晕;按 Esc 暂停 / 继续,点提示条上的“停止”结束本轮。")), view === void 0 ? h("div", { style: S.error }, "没有找到本插件的设置项(插件可能未启用)。") : null, view !== void 0 && !writable ? h("div", { style: S.error }, "当前设置为只读。") : null, h("section", { style: S.card }, h("h3", { style: S.cardTitle }, "运行状态"), h("div", { style: S.statusLine }, h("span", { style: {
|
|
1333
1524
|
...S.dot,
|
|
1334
1525
|
background: status === null ? "#999" : helperOk ? "#2a2" : "#d33"
|
|
1335
|
-
} }), status === null ? "无法获取状态" : helperOk ? status.controlling ? "正在操控电脑" : "就绪" : `控制组件不可用:${status.error ?? ""}
|
|
1526
|
+
} }), status === null ? "无法获取状态" : helperOk ? status.controlling ? "正在操控电脑" : "就绪" : `控制组件不可用:${status.error ?? ""}`, status?.version ? h("span", { style: {
|
|
1527
|
+
...S.hint,
|
|
1528
|
+
marginLeft: 4
|
|
1529
|
+
} }, `v${status.version}`) : null), primary ? h("p", { style: S.hint }, `主屏幕 ${primary.width}×${primary.height}(${Math.round(primary.dpi / 96 * 100)}% 缩放),发给模型的截图为 ${primary.shot.width}×${primary.shot.height}。`) : null, status && status.displays.length > 1 ? h("p", { style: S.hint }, `共 ${status.displays.length} 块显示器,模型可用 switch_display 切换。`) : null, updateInfo ? h("p", { style: updateInfo.error ? S.error : updateInfo.hasUpdate ? S.ok : S.hint }, updateInfo.error ? `检查更新失败:${updateInfo.error}` : updateInfo.hasUpdate ? `发现新版本 v${updateInfo.latest}(当前 v${updateInfo.current},来源 ${updateInfo.source}),可在「插件」页更新。` : `已是最新版本 v${updateInfo.current}(${updateInfo.source ?? "npm"})。`) : null, h("div", { style: S.actions }, h("button", {
|
|
1336
1530
|
type: "button",
|
|
1337
1531
|
style: S.secondary,
|
|
1338
1532
|
onClick: () => {
|
|
@@ -1344,13 +1538,42 @@ window.__ModuleLoader__.load({
|
|
|
1344
1538
|
onClick: () => {
|
|
1345
1539
|
refreshStatus();
|
|
1346
1540
|
}
|
|
1347
|
-
}, "刷新状态"), h("
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1541
|
+
}, "刷新状态"), h("button", {
|
|
1542
|
+
type: "button",
|
|
1543
|
+
style: S.secondary,
|
|
1544
|
+
disabled: updateBusy,
|
|
1545
|
+
onClick: () => {
|
|
1546
|
+
checkUpdate();
|
|
1547
|
+
}
|
|
1548
|
+
}, updateBusy ? "检查中…" : "检查更新"), h("button", {
|
|
1549
|
+
type: "button",
|
|
1550
|
+
style: S.secondary,
|
|
1551
|
+
onClick: () => {
|
|
1552
|
+
exportDiagnostics();
|
|
1553
|
+
}
|
|
1554
|
+
}, "导出诊断报告"), h("span", { style: S.hint }, "预览 4 秒:按已保存的设置显示光晕与提示条/进度卡片;诊断报告已脱敏,不含输入文本与截图。"))), h("section", { style: S.card }, h("h3", { style: S.cardTitle }, "授权"), h("div", { style: S.label }, "会话启用方式", h(Select, {
|
|
1555
|
+
label: "会话启用方式",
|
|
1351
1556
|
disabled,
|
|
1352
|
-
|
|
1353
|
-
|
|
1557
|
+
value: draft.sessionMode,
|
|
1558
|
+
options: [
|
|
1559
|
+
{
|
|
1560
|
+
value: "off",
|
|
1561
|
+
label: "按会话开启(默认关闭,推荐)"
|
|
1562
|
+
},
|
|
1563
|
+
{
|
|
1564
|
+
value: "on",
|
|
1565
|
+
label: "新会话默认开启(保留输入框开关)"
|
|
1566
|
+
},
|
|
1567
|
+
{
|
|
1568
|
+
value: "always",
|
|
1569
|
+
label: "总是开启(所有会话启用,隐藏输入框开关)"
|
|
1570
|
+
}
|
|
1571
|
+
],
|
|
1572
|
+
onChange: (value) => edit("sessionMode", value)
|
|
1573
|
+
}), h("span", { style: {
|
|
1574
|
+
...S.hint,
|
|
1575
|
+
fontWeight: 400
|
|
1576
|
+
} }, draft.sessionMode === "always" ? "所有会话始终开启电脑控制,不再在输入框左下角显示「电脑控制」胶囊按钮,界面更简洁。" : draft.sessionMode === "on" ? "新会话默认开启电脑控制;仍会在输入框左下角显示「电脑控制」胶囊,可针对单个会话关闭或用 /cu 切换。" : "普通对话默认不加载桌面工具与系统提示;需要在输入框左下角点击「电脑控制」胶囊或输入 /cu on 为当前会话按需开启,子代理自动继承。")), h("div", { style: S.label }, "授权方式", h(Select, {
|
|
1354
1577
|
label: "授权方式",
|
|
1355
1578
|
disabled,
|
|
1356
1579
|
value: draft.accessMode,
|
|
@@ -1379,7 +1602,19 @@ window.__ModuleLoader__.load({
|
|
|
1379
1602
|
}), h("span", { style: {
|
|
1380
1603
|
...S.hint,
|
|
1381
1604
|
fontWeight: 400
|
|
1382
|
-
} }, "1Password、Bitwarden、KeePass 等常见密码管理器始终禁止。"))
|
|
1605
|
+
} }, "1Password、Bitwarden、KeePass 等常见密码管理器始终禁止。")), h(ToggleRow, {
|
|
1606
|
+
title: "密码框硬保护",
|
|
1607
|
+
hint: "检测 UIA IsPassword 与 Win32 ES_PASSWORD 结构位:自动脱敏密码框内容为 [password],并拒绝向密码框自动输入文本。",
|
|
1608
|
+
checked: draft.protectPasswords,
|
|
1609
|
+
disabled,
|
|
1610
|
+
onChange: (value) => edit("protectPasswords", value)
|
|
1611
|
+
}), h(ToggleRow, {
|
|
1612
|
+
title: "窗口位移 / 遮挡防误点",
|
|
1613
|
+
hint: "坐标点击前核对前台窗口自上次截图后是否移动/缩放或被新弹窗遮挡,发生变化时阻止盲点并提示模型先重看屏幕。",
|
|
1614
|
+
checked: draft.windowChangeGuard,
|
|
1615
|
+
disabled,
|
|
1616
|
+
onChange: (value) => edit("windowChangeGuard", value)
|
|
1617
|
+
})), h("section", { style: S.card }, h("h3", { style: S.cardTitle }, "操控时的显示"), h(ToggleRow, {
|
|
1383
1618
|
title: "橙色光晕与提示条",
|
|
1384
1619
|
hint: "不会出现在模型看到的截图里。",
|
|
1385
1620
|
checked: draft.overlay,
|
|
@@ -1488,6 +1723,18 @@ window.__ModuleLoader__.load({
|
|
|
1488
1723
|
checked: draft.pauseOnUserInput,
|
|
1489
1724
|
disabled,
|
|
1490
1725
|
onChange: (value) => edit("pauseOnUserInput", value)
|
|
1726
|
+
}), h(ToggleRow, {
|
|
1727
|
+
title: "坐标点击优先后台控件触发",
|
|
1728
|
+
hint: "坐标左键点击命中原生按钮、复选框或标签页时,优先走后台 UIA 语义触发,不移动真实鼠标也不抢焦点。",
|
|
1729
|
+
checked: draft.elementFirstClick,
|
|
1730
|
+
disabled,
|
|
1731
|
+
onChange: (value) => edit("elementFirstClick", value)
|
|
1732
|
+
}), h(ToggleRow, {
|
|
1733
|
+
title: "物理点击后还原鼠标位置",
|
|
1734
|
+
hint: "需要真实物理点击时,点击完成后立即把你的鼠标指针还原到原来的位置。",
|
|
1735
|
+
checked: draft.restorePointer,
|
|
1736
|
+
disabled,
|
|
1737
|
+
onChange: (value) => edit("restorePointer", value)
|
|
1491
1738
|
}), h("div", { style: S.grid2 }, h(NumberField, {
|
|
1492
1739
|
label: "停手多久后继续",
|
|
1493
1740
|
unit: "毫秒",
|
|
@@ -1495,6 +1742,13 @@ window.__ModuleLoader__.load({
|
|
|
1495
1742
|
error: errors.userIdleMs,
|
|
1496
1743
|
disabled: disabled || !draft.pauseOnUserInput,
|
|
1497
1744
|
onChange: (value) => edit("userIdleMs", value)
|
|
1745
|
+
}), h(NumberField, {
|
|
1746
|
+
label: "可选 Chromium CDP 端口(0=自动探测 9222/9229)",
|
|
1747
|
+
unit: "端口",
|
|
1748
|
+
value: draft.cdpPort,
|
|
1749
|
+
error: errors.cdpPort,
|
|
1750
|
+
disabled,
|
|
1751
|
+
onChange: (value) => edit("cdpPort", value)
|
|
1498
1752
|
}))), h("section", { style: S.card }, h("h3", { style: S.cardTitle }, "截图"), h(ToggleRow, {
|
|
1499
1753
|
title: "操作后自动回传截图",
|
|
1500
1754
|
hint: "省去模型再截一次图的一轮调用;关闭可省 token。画面未变化时自动跳过重复图片。",
|
|
@@ -1600,6 +1854,9 @@ window.__ModuleLoader__.load({
|
|
|
1600
1854
|
id: ENTRY_ID,
|
|
1601
1855
|
order: 40
|
|
1602
1856
|
}, (props) => h(ComposerPill, props)));
|
|
1857
|
+
ctx.inject?.(["inputTriggers"], (scope) => {
|
|
1858
|
+
registerWindowReferenceSource(scope);
|
|
1859
|
+
});
|
|
1603
1860
|
}
|
|
1604
1861
|
//#endregion
|
|
1605
1862
|
exports.apply = apply;
|