@copylee/dsh-computer-use 0.9.0 → 0.10.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 +453 -56
- package/lib/client.js +74 -12
- package/lib/index.js +432 -30
- package/lib/types/access.d.ts +5 -0
- package/lib/types/computer.d.ts +30 -2
- package/lib/types/diagnostics.d.ts +71 -0
- package/lib/types/index.d.ts +5 -1
- package/lib/types/routes.d.ts +6 -0
- package/lib/types/sessions.d.ts +2 -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",
|
|
@@ -94,10 +95,12 @@ window.__ModuleLoader__.load({
|
|
|
94
95
|
return typeof value === "number" && Number.isFinite(value) ? Math.min(max, Math.max(min, Math.round(value))) : DEFAULTS[key];
|
|
95
96
|
};
|
|
96
97
|
const bool = (key) => typeof out[key] === "boolean" ? out[key] : DEFAULTS[key];
|
|
98
|
+
const sessionMode = out.sessionMode === "off" || out.sessionMode === "on" || out.sessionMode === "always" ? out.sessionMode : out.defaultSessionEnabled === true ? "on" : DEFAULTS.sessionMode;
|
|
97
99
|
return {
|
|
98
100
|
harnessUrl: typeof out.harnessUrl === "string" ? httpOrigin(out.harnessUrl.trim()) : void 0,
|
|
99
101
|
accessMode: out.accessMode === "allow-all" || out.accessMode === "per-app" ? out.accessMode : DEFAULTS.accessMode,
|
|
100
|
-
|
|
102
|
+
sessionMode,
|
|
103
|
+
defaultSessionEnabled: sessionMode !== "off",
|
|
101
104
|
overlay: bool("overlay"),
|
|
102
105
|
overlayLabel: typeof out.overlayLabel === "string" && out.overlayLabel.trim() !== "" ? out.overlayLabel.trim().slice(0, 40) : DEFAULTS.overlayLabel,
|
|
103
106
|
hostWindow: out.hostWindow === "pet" || out.hostWindow === "card" || out.hostWindow === "minimize" || out.hostWindow === "keep" ? out.hostWindow : out.minimizeHostWindow === true ? "minimize" : DEFAULTS.hostWindow,
|
|
@@ -259,6 +262,8 @@ window.__ModuleLoader__.load({
|
|
|
259
262
|
const h$3 = react.createElement;
|
|
260
263
|
/** Client-side cache so switching between sessions does not flash stale state. */
|
|
261
264
|
const cache = /* @__PURE__ */ new Map();
|
|
265
|
+
/** Remember whether Settings hides the pill ("总是开启" mode) so remounts do not flash it. */
|
|
266
|
+
let cachedHidden;
|
|
262
267
|
const PILL_CSS = `
|
|
263
268
|
.cl-cu-pill {
|
|
264
269
|
display: inline-flex;
|
|
@@ -341,7 +346,8 @@ window.__ModuleLoader__.load({
|
|
|
341
346
|
return function ComposerPill(props) {
|
|
342
347
|
const sessionId = typeof props?.sessionId === "string" && props.sessionId.trim() !== "" ? props.sessionId : void 0;
|
|
343
348
|
const [enabled, setEnabled] = react.useState(() => sessionId ? cache.get(sessionId) ?? false : false);
|
|
344
|
-
const [
|
|
349
|
+
const [hidden, setHidden] = react.useState(() => cachedHidden === true);
|
|
350
|
+
const [ready, setReady] = react.useState(() => sessionId ? cache.has(sessionId) && cachedHidden !== void 0 : false);
|
|
345
351
|
const [busy, setBusy] = react.useState(false);
|
|
346
352
|
react.useEffect(() => {
|
|
347
353
|
ensureStyle();
|
|
@@ -356,8 +362,11 @@ window.__ModuleLoader__.load({
|
|
|
356
362
|
const body = await res.json();
|
|
357
363
|
if (cancelled.current) return;
|
|
358
364
|
const value = body.enabled === true;
|
|
365
|
+
const hidePill = body.alwaysOn === true || body.showPill === false;
|
|
359
366
|
cache.set(id, value);
|
|
367
|
+
cachedHidden = hidePill;
|
|
360
368
|
setEnabled(value);
|
|
369
|
+
setHidden(hidePill);
|
|
361
370
|
setReady(true);
|
|
362
371
|
} catch {
|
|
363
372
|
if (!cancelled.current) setReady(true);
|
|
@@ -366,8 +375,9 @@ window.__ModuleLoader__.load({
|
|
|
366
375
|
react.useEffect(() => {
|
|
367
376
|
if (!sessionId) return;
|
|
368
377
|
const cancelled = { current: false };
|
|
369
|
-
if (cache.has(sessionId)) {
|
|
378
|
+
if (cache.has(sessionId) && cachedHidden !== void 0) {
|
|
370
379
|
setEnabled(cache.get(sessionId));
|
|
380
|
+
setHidden(cachedHidden);
|
|
371
381
|
setReady(true);
|
|
372
382
|
} else {
|
|
373
383
|
setEnabled(false);
|
|
@@ -382,7 +392,7 @@ window.__ModuleLoader__.load({
|
|
|
382
392
|
unsub?.();
|
|
383
393
|
};
|
|
384
394
|
}, [sessionId, fetchState]);
|
|
385
|
-
if (!sessionId) return null;
|
|
395
|
+
if (!sessionId || hidden || !ready && cachedHidden !== false) return null;
|
|
386
396
|
const zh = isZh();
|
|
387
397
|
const label = zh ? "电脑控制" : "Computer";
|
|
388
398
|
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)";
|
|
@@ -907,6 +917,7 @@ window.__ModuleLoader__.load({
|
|
|
907
917
|
const STATUS_ROUTE = "/api/dsh-computer-use/status";
|
|
908
918
|
const SCREENSHOTS_ROUTE = "/api/dsh-computer-use/screenshots";
|
|
909
919
|
const SCREENSHOTS_CLEAN_ROUTE = "/api/dsh-computer-use/screenshots/clean";
|
|
920
|
+
const DIAGNOSTICS_ROUTE = "/api/dsh-computer-use/diagnostics";
|
|
910
921
|
const mb = (bytes) => `${(bytes / 1048576).toFixed(1)} MB`;
|
|
911
922
|
const PREVIEW_ROUTE = "/api/dsh-computer-use/preview";
|
|
912
923
|
const h = react.createElement;
|
|
@@ -914,7 +925,7 @@ window.__ModuleLoader__.load({
|
|
|
914
925
|
const s = resolveConfig(value);
|
|
915
926
|
return {
|
|
916
927
|
accessMode: s.accessMode,
|
|
917
|
-
|
|
928
|
+
sessionMode: s.sessionMode,
|
|
918
929
|
blockedApps: s.blockedApps.join("\n"),
|
|
919
930
|
overlay: s.overlay,
|
|
920
931
|
overlayLabel: s.overlayLabel,
|
|
@@ -949,7 +960,8 @@ window.__ModuleLoader__.load({
|
|
|
949
960
|
function valuesFrom(d) {
|
|
950
961
|
return {
|
|
951
962
|
accessMode: d.accessMode,
|
|
952
|
-
|
|
963
|
+
sessionMode: d.sessionMode,
|
|
964
|
+
defaultSessionEnabled: d.sessionMode !== "off",
|
|
953
965
|
blockedApps: d.blockedApps.split(/[\n,,]/).map((item) => item.trim()).filter(Boolean),
|
|
954
966
|
overlay: d.overlay,
|
|
955
967
|
overlayLabel: d.overlayLabel.trim() || DEFAULTS.overlayLabel,
|
|
@@ -1313,6 +1325,34 @@ window.__ModuleLoader__.load({
|
|
|
1313
1325
|
});
|
|
1314
1326
|
}
|
|
1315
1327
|
};
|
|
1328
|
+
const exportDiagnostics = async () => {
|
|
1329
|
+
try {
|
|
1330
|
+
const response = await fetch(DIAGNOSTICS_ROUTE, {
|
|
1331
|
+
credentials: "same-origin",
|
|
1332
|
+
cache: "no-store"
|
|
1333
|
+
});
|
|
1334
|
+
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
1335
|
+
const text = await response.text();
|
|
1336
|
+
const blob = new Blob([text], { type: "text/plain;charset=utf-8" });
|
|
1337
|
+
const url = URL.createObjectURL(blob);
|
|
1338
|
+
const a = document.createElement("a");
|
|
1339
|
+
a.href = url;
|
|
1340
|
+
a.download = `dsh-computer-use-diagnostics-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.txt`;
|
|
1341
|
+
document.body.appendChild(a);
|
|
1342
|
+
a.click();
|
|
1343
|
+
a.remove();
|
|
1344
|
+
URL.revokeObjectURL(url);
|
|
1345
|
+
setMessage({
|
|
1346
|
+
kind: "ok",
|
|
1347
|
+
text: "已导出脱敏诊断报告(不含输入文本、剪贴板和截图)"
|
|
1348
|
+
});
|
|
1349
|
+
} catch (error) {
|
|
1350
|
+
setMessage({
|
|
1351
|
+
kind: "error",
|
|
1352
|
+
text: `导出诊断失败:${error.message}`
|
|
1353
|
+
});
|
|
1354
|
+
}
|
|
1355
|
+
};
|
|
1316
1356
|
if (!loaded) return h("div", { style: S.page }, "加载中…");
|
|
1317
1357
|
const primary = status?.displays.find((d) => d.primary) ?? status?.displays[0];
|
|
1318
1358
|
const helperOk = status?.helper === "ready";
|
|
@@ -1344,13 +1384,35 @@ window.__ModuleLoader__.load({
|
|
|
1344
1384
|
onClick: () => {
|
|
1345
1385
|
refreshStatus();
|
|
1346
1386
|
}
|
|
1347
|
-
}, "刷新状态"), h("
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1387
|
+
}, "刷新状态"), h("button", {
|
|
1388
|
+
type: "button",
|
|
1389
|
+
style: S.secondary,
|
|
1390
|
+
onClick: () => {
|
|
1391
|
+
exportDiagnostics();
|
|
1392
|
+
}
|
|
1393
|
+
}, "导出诊断报告"), h("span", { style: S.hint }, "预览 4 秒:按已保存的设置显示光晕与提示条/进度卡片;诊断报告已脱敏,不含输入文本与截图。"))), h("section", { style: S.card }, h("h3", { style: S.cardTitle }, "授权"), h("div", { style: S.label }, "会话启用方式", h(Select, {
|
|
1394
|
+
label: "会话启用方式",
|
|
1351
1395
|
disabled,
|
|
1352
|
-
|
|
1353
|
-
|
|
1396
|
+
value: draft.sessionMode,
|
|
1397
|
+
options: [
|
|
1398
|
+
{
|
|
1399
|
+
value: "off",
|
|
1400
|
+
label: "按会话开启(默认关闭,推荐)"
|
|
1401
|
+
},
|
|
1402
|
+
{
|
|
1403
|
+
value: "on",
|
|
1404
|
+
label: "新会话默认开启(保留输入框开关)"
|
|
1405
|
+
},
|
|
1406
|
+
{
|
|
1407
|
+
value: "always",
|
|
1408
|
+
label: "总是开启(所有会话启用,隐藏输入框开关)"
|
|
1409
|
+
}
|
|
1410
|
+
],
|
|
1411
|
+
onChange: (value) => edit("sessionMode", value)
|
|
1412
|
+
}), h("span", { style: {
|
|
1413
|
+
...S.hint,
|
|
1414
|
+
fontWeight: 400
|
|
1415
|
+
} }, draft.sessionMode === "always" ? "所有会话始终开启电脑控制,不再在输入框左下角显示「电脑控制」胶囊按钮,界面更简洁。" : draft.sessionMode === "on" ? "新会话默认开启电脑控制;仍会在输入框左下角显示「电脑控制」胶囊,可针对单个会话关闭或用 /cu 切换。" : "普通对话默认不加载桌面工具与系统提示;需要在输入框左下角点击「电脑控制」胶囊或输入 /cu on 为当前会话按需开启,子代理自动继承。")), h("div", { style: S.label }, "授权方式", h(Select, {
|
|
1354
1416
|
label: "授权方式",
|
|
1355
1417
|
disabled,
|
|
1356
1418
|
value: draft.accessMode,
|