@copylee/dsh-computer-use 0.14.2 → 0.16.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/Input.cs +17 -10
- package/helper/Native.cs +9 -1
- package/helper/Overlay.cs +170 -27
- package/helper/Program.cs +1 -1
- package/helper/Uia.cs +40 -7
- package/lib/client.js +45 -30
- package/lib/index.js +434 -52
- package/lib/types/client/accent.d.ts +8 -9
- package/lib/types/client/select.d.ts +1 -1
- package/lib/types/computer.d.ts +29 -6
- package/lib/types/diagnostics.d.ts +10 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/retention.d.ts +60 -0
- package/lib/types/routes.d.ts +5 -1
- package/lib/types/screenshots.d.ts +14 -1
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -80,6 +80,7 @@ window.__ModuleLoader__.load({
|
|
|
80
80
|
maxLongEdge: 1366,
|
|
81
81
|
maxPixels: 115e4,
|
|
82
82
|
jpegQuality: 70,
|
|
83
|
+
keepScreenshots: 2,
|
|
83
84
|
blockedApps: [],
|
|
84
85
|
pauseOnUserInput: true,
|
|
85
86
|
reportUserActions: true,
|
|
@@ -122,6 +123,7 @@ window.__ModuleLoader__.load({
|
|
|
122
123
|
maxLongEdge: num("maxLongEdge", 640, 3840),
|
|
123
124
|
maxPixels: num("maxPixels", 3e5, 8e6),
|
|
124
125
|
jpegQuality: num("jpegQuality", 30, 100),
|
|
126
|
+
keepScreenshots: num("keepScreenshots", 0, 20),
|
|
125
127
|
pauseOnUserInput: bool("pauseOnUserInput"),
|
|
126
128
|
reportUserActions: bool("reportUserActions"),
|
|
127
129
|
userIdleMs: num("userIdleMs", 300, 1e4),
|
|
@@ -140,17 +142,20 @@ window.__ModuleLoader__.load({
|
|
|
140
142
|
//#endregion
|
|
141
143
|
//#region lib/types/client/accent.js
|
|
142
144
|
/**
|
|
143
|
-
*
|
|
145
|
+
* This plugin's own accent colour (settings page, composer pill).
|
|
144
146
|
*
|
|
145
|
-
* One choice —
|
|
146
|
-
* browser under a key
|
|
147
|
-
* `<body
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
* This file is identical in every plugin; change it in all of them together.
|
|
147
|
+
* One choice — black by default, terracotta orange or blue — is kept in the
|
|
148
|
+
* browser under a key only this plugin reads, and painted as two CSS
|
|
149
|
+
* variables on `<body>` that only this plugin's styles use
|
|
150
|
+
* (`var(--dshcu-accent)` / `var(--dshcu-accent-ink)`). Changing it here does
|
|
151
|
+
* not recolour the other copylee plugins, and theirs does not recolour this one.
|
|
152
152
|
*/
|
|
153
153
|
const ACCENTS = {
|
|
154
|
+
black: {
|
|
155
|
+
name: "黑色",
|
|
156
|
+
accent: "var(--dsw-alias-label-primary, #1F1E1D)",
|
|
157
|
+
ink: "var(--dsw-alias-bg-base, #FFFFFF)"
|
|
158
|
+
},
|
|
154
159
|
orange: {
|
|
155
160
|
name: "陶土橙",
|
|
156
161
|
accent: "#D97757",
|
|
@@ -160,20 +165,15 @@ window.__ModuleLoader__.load({
|
|
|
160
165
|
name: "蓝色",
|
|
161
166
|
accent: "#3D63E6",
|
|
162
167
|
ink: "#FFFFFF"
|
|
163
|
-
},
|
|
164
|
-
black: {
|
|
165
|
-
name: "黑色",
|
|
166
|
-
accent: "var(--dsw-alias-label-primary, #1F1E1D)",
|
|
167
|
-
ink: "var(--dsw-alias-bg-base, #FFFFFF)"
|
|
168
168
|
}
|
|
169
169
|
};
|
|
170
170
|
const ACCENT_IDS = Object.keys(ACCENTS);
|
|
171
|
-
const DEFAULT_ACCENT = "
|
|
171
|
+
const DEFAULT_ACCENT = "black";
|
|
172
172
|
/** Use these in styles; the fallbacks cover the moment before the first paint. */
|
|
173
|
-
const ACCENT = `var(--
|
|
174
|
-
const ACCENT_INK = `var(--
|
|
175
|
-
const KEY = "copylee.dsh.accent";
|
|
176
|
-
const EVENT = "
|
|
173
|
+
const ACCENT = `var(--dshcu-accent, ${ACCENTS[DEFAULT_ACCENT].accent})`;
|
|
174
|
+
const ACCENT_INK = `var(--dshcu-accent-ink, ${ACCENTS[DEFAULT_ACCENT].ink})`;
|
|
175
|
+
const KEY = "copylee.dsh.computer-use.accent";
|
|
176
|
+
const EVENT = "dsh-computer-use-accent";
|
|
177
177
|
function isAccent(value) {
|
|
178
178
|
return typeof value === "string" && Object.hasOwn(ACCENTS, value);
|
|
179
179
|
}
|
|
@@ -187,14 +187,14 @@ window.__ModuleLoader__.load({
|
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
function readAccent() {
|
|
190
|
-
return storedAccent() ?? "
|
|
190
|
+
return storedAccent() ?? "black";
|
|
191
191
|
}
|
|
192
192
|
function paint() {
|
|
193
193
|
const colors = ACCENTS[readAccent()];
|
|
194
|
-
document.body?.style.setProperty("--
|
|
195
|
-
document.body?.style.setProperty("--
|
|
194
|
+
document.body?.style.setProperty("--dshcu-accent", colors.accent);
|
|
195
|
+
document.body?.style.setProperty("--dshcu-accent-ink", colors.ink);
|
|
196
196
|
}
|
|
197
|
-
/** Choose
|
|
197
|
+
/** Choose this plugin's accent. */
|
|
198
198
|
function writeAccent(accent) {
|
|
199
199
|
try {
|
|
200
200
|
localStorage.setItem(KEY, accent);
|
|
@@ -207,11 +207,16 @@ window.__ModuleLoader__.load({
|
|
|
207
207
|
if (typeof document === "undefined") return () => {};
|
|
208
208
|
paint();
|
|
209
209
|
if (document.body === null) document.addEventListener("DOMContentLoaded", paint, { once: true });
|
|
210
|
+
const onStorage = (event) => {
|
|
211
|
+
if (event.key === null || event.key === KEY) paint();
|
|
212
|
+
};
|
|
210
213
|
window.addEventListener(EVENT, paint);
|
|
211
|
-
window.addEventListener("storage",
|
|
214
|
+
window.addEventListener("storage", onStorage);
|
|
212
215
|
return () => {
|
|
216
|
+
document.body?.style.removeProperty("--dshcu-accent");
|
|
217
|
+
document.body?.style.removeProperty("--dshcu-accent-ink");
|
|
213
218
|
window.removeEventListener(EVENT, paint);
|
|
214
|
-
window.removeEventListener("storage",
|
|
219
|
+
window.removeEventListener("storage", onStorage);
|
|
215
220
|
};
|
|
216
221
|
}
|
|
217
222
|
function useAccent() {
|
|
@@ -527,14 +532,14 @@ window.__ModuleLoader__.load({
|
|
|
527
532
|
const selectCss = `
|
|
528
533
|
@keyframes dshcu-menu-in{from{opacity:0;transform:translateY(-4px) scale(.985)}to{opacity:1;transform:translateY(0) scale(1)}}
|
|
529
534
|
.dshcu-select{box-sizing:border-box;width:100%;height:36px;padding:0 12px;display:flex;align-items:center;gap:8px;text-align:left;border:1px solid var(--dsw-alias-border-l4,rgba(127,127,127,.28));border-radius:var(--dsw-radius-md,9px);background:var(--dsw-alias-bg-layer-3,transparent);color:inherit;font:inherit;font-size:13px;cursor:pointer;transition:border-color .16s ease,background-color .16s ease,box-shadow .16s ease}
|
|
530
|
-
.dshcu-select:hover:not(:disabled){border-color:color-mix(in srgb,var(--
|
|
531
|
-
.dshcu-select:focus-visible,.dshcu-select[aria-expanded=true]{outline:none;border-color:var(--
|
|
535
|
+
.dshcu-select:hover:not(:disabled){border-color:color-mix(in srgb,var(--dshcu-accent,#1F1E1D) 55%,var(--dsw-alias-border-l3,#888));background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.05))}
|
|
536
|
+
.dshcu-select:focus-visible,.dshcu-select[aria-expanded=true]{outline:none;border-color:var(--dshcu-accent,#1F1E1D);box-shadow:0 0 0 3px color-mix(in srgb,var(--dshcu-accent,#1F1E1D) 20%,transparent)}
|
|
532
537
|
.dshcu-select:disabled{opacity:.48;cursor:default}
|
|
533
538
|
.dshcu-select svg{flex:none;transition:transform .2s cubic-bezier(.22,1,.36,1)}
|
|
534
539
|
.dshcu-menu{position:fixed;z-index:1100;box-sizing:border-box;padding:5px;overflow-y:auto;overscroll-behavior:contain;border-radius:var(--dsw-radius-lg,12px);border:1px solid var(--dsw-alias-border-l2,rgba(127,127,127,.18));background:var(--dsw-menu-surface-fill,var(--dsw-alias-bg-layer-1,#fff));color:var(--dsw-alias-label-primary,#222);backdrop-filter:var(--dsw-menu-backdrop-filter,none);box-shadow:var(--dsw-elevation-prominent,0 12px 32px rgba(0,0,0,.16),0 2px 6px rgba(0,0,0,.06));animation:dshcu-menu-in .14s cubic-bezier(.22,1,.36,1)}
|
|
535
540
|
.dshcu-option{display:flex;align-items:center;gap:8px;min-height:34px;padding:6px 10px;box-sizing:border-box;border-radius:var(--dsw-radius-md,8px);font-size:13px;line-height:20px;cursor:pointer;user-select:none;transition:background-color .12s ease,color .12s ease}
|
|
536
541
|
.dshcu-option[data-active=true]{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.11))}
|
|
537
|
-
.dshcu-option[aria-selected=true]{font-weight:500;color:var(--
|
|
542
|
+
.dshcu-option[aria-selected=true]{font-weight:500;color:var(--dshcu-accent,#1F1E1D)}
|
|
538
543
|
`;
|
|
539
544
|
function Select({ options, value, disabled, label, onChange }) {
|
|
540
545
|
const id = react.useId();
|
|
@@ -705,7 +710,7 @@ window.__ModuleLoader__.load({
|
|
|
705
710
|
.dshcu-skill-row:hover{background:var(--dsw-alias-bg-layer-2,rgba(127,127,127,.07));border-color:var(--dsw-alias-border-l2,rgba(127,127,127,.18))}
|
|
706
711
|
.dshcu-chip-tab{padding:4px 10px;border-radius:999px;font-size:12px;cursor:pointer;border:1px solid var(--dsw-alias-border-l2,rgba(127,127,127,.25));background:transparent;color:var(--dsw-alias-label-secondary,#666);transition:background .15s ease,color .15s ease,border-color .15s ease}
|
|
707
712
|
.dshcu-chip-tab:hover{background:var(--dsw-alias-bg-layer-2,rgba(127,127,127,.08))}
|
|
708
|
-
.dshcu-chip-tab[data-active="true"]{background:var(--dshcu-accent
|
|
713
|
+
.dshcu-chip-tab[data-active="true"]{background:color-mix(in srgb,var(--dshcu-accent,#1F1E1D) 12%,transparent);color:var(--dshcu-accent,#1F1E1D);border-color:var(--dshcu-accent,#1F1E1D);font-weight:600}
|
|
709
714
|
.dshcu-modal-backdrop{position:fixed;inset:0;z-index:9999;background:rgba(15,15,18,.48);backdrop-filter:blur(4px);display:flex;align-items:center;justify-content:center;padding:20px;animation:dshcu-backdrop-in .16s ease}
|
|
710
715
|
.dshcu-modal{width:min(640px,100%);max-height:min(86vh,720px);display:flex;flex-direction:column;border-radius:16px;background:var(--dsw-alias-bg-layer-1,#fff);color:var(--dsw-alias-label-primary,inherit);border:1px solid var(--dsw-alias-border-l2,rgba(127,127,127,.25));box-shadow:0 24px 64px rgba(0,0,0,.28);overflow:hidden;animation:dshcu-modal-in .18s cubic-bezier(.16,1,.3,1)}
|
|
711
716
|
`;
|
|
@@ -1254,6 +1259,7 @@ window.__ModuleLoader__.load({
|
|
|
1254
1259
|
maxLongEdge: String(s.maxLongEdge),
|
|
1255
1260
|
maxMegapixels: String(Math.round(s.maxPixels / 1e4) / 100),
|
|
1256
1261
|
jpegQuality: String(s.jpegQuality),
|
|
1262
|
+
keepScreenshots: String(s.keepScreenshots),
|
|
1257
1263
|
elementFirstClick: s.elementFirstClick,
|
|
1258
1264
|
restorePointer: s.restorePointer,
|
|
1259
1265
|
protectPasswords: s.protectPasswords,
|
|
@@ -1274,6 +1280,7 @@ window.__ModuleLoader__.load({
|
|
|
1274
1280
|
check("maxLongEdge", 640, 3840);
|
|
1275
1281
|
check("maxMegapixels", .3, 8);
|
|
1276
1282
|
check("jpegQuality", 30, 100);
|
|
1283
|
+
check("keepScreenshots", 0, 20);
|
|
1277
1284
|
check("cdpPort", 0, 65535);
|
|
1278
1285
|
return errors;
|
|
1279
1286
|
}
|
|
@@ -1299,6 +1306,7 @@ window.__ModuleLoader__.load({
|
|
|
1299
1306
|
maxLongEdge: Math.round(Number(d.maxLongEdge)),
|
|
1300
1307
|
maxPixels: Math.round(Number(d.maxMegapixels) * 1e6),
|
|
1301
1308
|
jpegQuality: Math.round(Number(d.jpegQuality)),
|
|
1309
|
+
keepScreenshots: Math.round(Number(d.keepScreenshots)),
|
|
1302
1310
|
elementFirstClick: d.elementFirstClick,
|
|
1303
1311
|
restorePointer: d.restorePointer,
|
|
1304
1312
|
protectPasswords: d.protectPasswords,
|
|
@@ -2052,14 +2060,21 @@ window.__ModuleLoader__.load({
|
|
|
2052
2060
|
error: errors.jpegQuality,
|
|
2053
2061
|
disabled,
|
|
2054
2062
|
onChange: (value) => edit("jpegQuality", value)
|
|
2055
|
-
})), liveShot ? h("div", { className: "dshcu-metric-bar" }, h("strong", null, `主屏实际输出 ${liveShot.width}×${liveShot.height}`), h("span", { style: S.hint }, `${liveShot.megapixels} MP · ${limitLabel(liveShot.limitedBy)}${liveCompactShot ? ` | 紧凑档 ${liveCompactShot.width}×${liveCompactShot.height}(${liveCompactShot.megapixels} MP)` : ""}`)) : h("p", { style: S.hint }, "截图越大越清晰、点得越准,但每张图消耗的 token 也越多。最长边与总像素上限同时生效,取更紧的一项。")), h(SkillsCard, { S }), h("section", { className: "dshcu-card" }, h("div", { style: S.cardHeader }, h("h3", { style: S.cardTitle }, "截图缓存")), h("p", { style: S.hint }, cache === null ? cacheBusy ? "正在统计…" : "无法统计截图缓存。" : !cache.ok ? `统计失败:${cache.error ?? ""}` : `本插件的截图共 ${cache.count} 张,占用 ${mb(cache.bytes)};其中 ${cache.orphans} 张(${mb(cache.orphanBytes)}
|
|
2063
|
+
})), liveShot ? h("div", { className: "dshcu-metric-bar" }, h("strong", null, `主屏实际输出 ${liveShot.width}×${liveShot.height}`), h("span", { style: S.hint }, `${liveShot.megapixels} MP · ${limitLabel(liveShot.limitedBy)}${liveCompactShot ? ` | 紧凑档 ${liveCompactShot.width}×${liveCompactShot.height}(${liveCompactShot.megapixels} MP)` : ""}`)) : h("p", { style: S.hint }, "截图越大越清晰、点得越准,但每张图消耗的 token 也越多。最长边与总像素上限同时生效,取更紧的一项。")), h(SkillsCard, { S }), h("section", { className: "dshcu-card" }, h("div", { style: S.cardHeader }, h("h3", { style: S.cardTitle }, "截图缓存")), h("p", { style: S.hint }, cache === null ? cacheBusy ? "正在统计…" : "无法统计截图缓存。" : !cache.ok ? `统计失败:${cache.error ?? ""}` : `本插件的截图共 ${cache.count} 张,占用 ${mb(cache.bytes)};其中 ${cache.orphans} 张(${mb(cache.orphanBytes)})已不再需要(已被新截图替换或所属会话已删除),可以安全清理。`), h("div", { style: S.grid2 }, h(NumberField, {
|
|
2064
|
+
label: "对话里保留的截图",
|
|
2065
|
+
unit: "张(0 = 全部保留)",
|
|
2066
|
+
value: draft.keepScreenshots,
|
|
2067
|
+
error: errors.keepScreenshots,
|
|
2068
|
+
disabled,
|
|
2069
|
+
onChange: (value) => edit("keepScreenshots", value)
|
|
2070
|
+
})), h("p", { style: S.hint }, "模型每次请求都会重发对话里所有截图。这里只保留最近几张,更早的换成一行文字占位(省 token),文件在几分钟后自动删除;已删除会话的截图在启动后及每 12 小时清理。"), h("div", { style: S.actions }, h("button", {
|
|
2056
2071
|
type: "button",
|
|
2057
2072
|
className: "dshcu-btn",
|
|
2058
2073
|
disabled: cacheBusy || !cache?.orphans,
|
|
2059
2074
|
onClick: () => {
|
|
2060
2075
|
cleanCache();
|
|
2061
2076
|
}
|
|
2062
|
-
}, "
|
|
2077
|
+
}, "立即清理不再需要的截图"), h("button", {
|
|
2063
2078
|
type: "button",
|
|
2064
2079
|
className: "dshcu-btn",
|
|
2065
2080
|
disabled: cacheBusy,
|