@copylee/dsh-computer-use 0.6.0 → 0.7.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/README.md +1 -0
- package/lib/client.js +13 -3
- package/lib/index.js +128 -12
- package/lib/types/computer.d.ts +4 -0
- package/lib/types/effort.d.ts +17 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/text.d.ts +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -84,6 +84,7 @@ dsh plugin --profile web add @copylee/dsh-computer-use@latest
|
|
|
84
84
|
| 操作后自动截图 | 开 | 关闭可省 token,但模型需要自己截图 |
|
|
85
85
|
| 等待稳定 | 400 ms | 动作后至少等这么久,之后画面静止即截图(最多约 2.5 秒) |
|
|
86
86
|
| 截图最长边 / 总像素 / JPEG 质量 | 1366 / 1.15MP / 70 | 越大越清晰、越费 token |
|
|
87
|
+
| 操作时不深度思考 | 关 | 开启后,正在操作电脑的那几轮请求(看截图、决定下一步)改用模型的最低思考强度,每一步更快;任务开头的规划和其他对话仍按会话里选的思考强度。模型不提供可调的思考强度时不起作用 |
|
|
87
88
|
| 检测到你在操作时让出控制 | 开 | 键盘输入暂停、窗口被切换时重新看屏幕 |
|
|
88
89
|
| 文字输入方式 | 流式 | 流式(长文本逐段出现)/ 逐字输入(最像打字,最慢)/ 一次粘贴(最快) |
|
|
89
90
|
| 键盘静止多久后恢复 | 1500 ms | |
|
package/lib/client.js
CHANGED
|
@@ -45,7 +45,8 @@ window.__ModuleLoader__.load({
|
|
|
45
45
|
blockedApps: [],
|
|
46
46
|
pauseOnUserInput: true,
|
|
47
47
|
userIdleMs: 1500,
|
|
48
|
-
typingMode: "stream"
|
|
48
|
+
typingMode: "stream",
|
|
49
|
+
quickSteps: false
|
|
49
50
|
};
|
|
50
51
|
/** Unwrap `.volatile()` refs (`{ get() }`) and fall back to defaults for bad values. */
|
|
51
52
|
function resolveConfig(raw) {
|
|
@@ -69,6 +70,7 @@ window.__ModuleLoader__.load({
|
|
|
69
70
|
jpegQuality: num("jpegQuality", 30, 100),
|
|
70
71
|
pauseOnUserInput: bool("pauseOnUserInput"),
|
|
71
72
|
userIdleMs: num("userIdleMs", 300, 1e4),
|
|
73
|
+
quickSteps: bool("quickSteps"),
|
|
72
74
|
typingMode: out.typingMode === "stream" || out.typingMode === "type" || out.typingMode === "paste" ? out.typingMode : DEFAULTS.typingMode,
|
|
73
75
|
blockedApps: Array.isArray(out.blockedApps) ? out.blockedApps.filter((item) => typeof item === "string" && item.trim() !== "") : []
|
|
74
76
|
};
|
|
@@ -692,6 +694,7 @@ window.__ModuleLoader__.load({
|
|
|
692
694
|
hostWindow: s.hostWindow,
|
|
693
695
|
cardOpacity: s.cardOpacity,
|
|
694
696
|
typingMode: s.typingMode,
|
|
697
|
+
quickSteps: s.quickSteps,
|
|
695
698
|
pauseOnUserInput: s.pauseOnUserInput,
|
|
696
699
|
userIdleMs: String(s.userIdleMs),
|
|
697
700
|
autoScreenshot: s.autoScreenshot,
|
|
@@ -724,6 +727,7 @@ window.__ModuleLoader__.load({
|
|
|
724
727
|
hostWindow: d.hostWindow,
|
|
725
728
|
cardOpacity: d.cardOpacity,
|
|
726
729
|
typingMode: d.typingMode,
|
|
730
|
+
quickSteps: d.quickSteps,
|
|
727
731
|
pauseOnUserInput: d.pauseOnUserInput,
|
|
728
732
|
userIdleMs: Math.round(Number(d.userIdleMs)),
|
|
729
733
|
autoScreenshot: d.autoScreenshot,
|
|
@@ -1073,7 +1077,7 @@ window.__ModuleLoader__.load({
|
|
|
1073
1077
|
onClick: () => {
|
|
1074
1078
|
refreshStatus();
|
|
1075
1079
|
}
|
|
1076
|
-
}, "刷新状态"), h("span", { style: S.hint }, "
|
|
1080
|
+
}, "刷新状态"), h("span", { style: S.hint }, "预览 4 秒:按已保存的设置显示光晕,以及迷你进度卡片或提示条。"))), h("section", { style: S.card }, h("h3", { style: S.cardTitle }, "授权"), h("div", { style: S.label }, "授权方式", h(Select, {
|
|
1077
1081
|
label: "授权方式",
|
|
1078
1082
|
disabled,
|
|
1079
1083
|
value: draft.accessMode,
|
|
@@ -1199,7 +1203,13 @@ window.__ModuleLoader__.load({
|
|
|
1199
1203
|
}), h("span", { style: {
|
|
1200
1204
|
...S.hint,
|
|
1201
1205
|
fontWeight: 400
|
|
1202
|
-
} }, "短文字都会逐字打出来。长文本逐字输入在 Typora、Obsidian、Word 等编辑器里可能被自动补全括号、自动续列表打乱;流式按段落粘贴,既看得到过程又不会乱。")))), h("section", { style: S.card }, h("h3", { style: S.cardTitle }, "
|
|
1206
|
+
} }, "短文字都会逐字打出来。长文本逐字输入在 Typora、Obsidian、Word 等编辑器里可能被自动补全括号、自动续列表打乱;流式按段落粘贴,既看得到过程又不会乱。")))), h("section", { style: S.card }, h("h3", { style: S.cardTitle }, "速度"), h(ToggleRow, {
|
|
1207
|
+
title: "操作时不深度思考",
|
|
1208
|
+
hint: "正在操作电脑的那几轮(看截图、决定下一步点哪里)改用模型的最低思考强度,每一步明显更快、动作更连贯;任务开头的规划和其他对话仍按会话里选的思考强度。模型不支持调整思考强度时不起作用。",
|
|
1209
|
+
checked: draft.quickSteps,
|
|
1210
|
+
disabled,
|
|
1211
|
+
onChange: (value) => edit("quickSteps", value)
|
|
1212
|
+
})), h("section", { style: S.card }, h("h3", { style: S.cardTitle }, "让出控制"), h(ToggleRow, {
|
|
1203
1213
|
title: "检测到你在操作时暂停",
|
|
1204
1214
|
hint: "你用键盘打字时 AI 等你停手;你切换了窗口时 AI 先重新看屏幕。鼠标移动不会触发。",
|
|
1205
1215
|
checked: draft.pauseOnUserInput,
|
package/lib/index.js
CHANGED
|
@@ -582,10 +582,13 @@ function suggest(elements, wanted) {
|
|
|
582
582
|
*
|
|
583
583
|
* Blocks end after a blank-line separator, never inside a ``` / ~~~ fence and
|
|
584
584
|
* never inside a paragraph (a half-pasted **bold** or link may not re-render).
|
|
585
|
-
*
|
|
585
|
+
* Text with no blank line at all (a story written one paragraph per line) is
|
|
586
|
+
* split at its line ends instead, or it would go in as a single block; a table
|
|
587
|
+
* keeps its rows together. Joining the blocks gives back the original text exactly.
|
|
586
588
|
*/
|
|
587
589
|
function splitBlocks(text, minChars = 80) {
|
|
588
590
|
const lines = text.split(/(?<=\n)/);
|
|
591
|
+
const byLine = !/\n[ \t]*\r?\n/.test(text) && !/^\s*(```|~~~|\|)/m.test(text);
|
|
589
592
|
const blocks = [];
|
|
590
593
|
let current = "";
|
|
591
594
|
let fence;
|
|
@@ -598,7 +601,7 @@ function splitBlocks(text, minChars = 80) {
|
|
|
598
601
|
else if (marker.startsWith(fence)) fence = void 0;
|
|
599
602
|
}
|
|
600
603
|
const blank = bare.trim() === "";
|
|
601
|
-
if (fence === void 0 && !blank && previousBlank && current.length >= minChars) {
|
|
604
|
+
if (fence === void 0 && !blank && (previousBlank || byLine && current !== "") && current.length >= minChars) {
|
|
602
605
|
blocks.push(current);
|
|
603
606
|
current = "";
|
|
604
607
|
}
|
|
@@ -1059,7 +1062,11 @@ var Computer = class Computer {
|
|
|
1059
1062
|
const started = Date.now();
|
|
1060
1063
|
for (;;) {
|
|
1061
1064
|
if (signal.aborted) throw new Error("Cancelled.");
|
|
1062
|
-
if (await present() !== gone)
|
|
1065
|
+
if (await present() !== gone) {
|
|
1066
|
+
const text = `${kind === "window" ? "Window" : "Control"} "${subject}" ${gone ? "is gone" : "is there"} after ${((Date.now() - started) / 1e3).toFixed(1)}s.`;
|
|
1067
|
+
await this.settle(signal);
|
|
1068
|
+
return text;
|
|
1069
|
+
}
|
|
1063
1070
|
if (Date.now() - started >= timeout) {
|
|
1064
1071
|
const near = !gone && kind === "target" && suggestions.length ? ` Controls there now: ${suggestions.map((name) => `"${name.slice(0, 40)}"`).join(", ")}.` : "";
|
|
1065
1072
|
throw new Error(`Timed out after ${Math.round(timeout / 1e3)}s waiting for ${kind === "window" ? "window" : "control"} "${subject}" to ${gone ? "disappear" : "appear"}.${near}`);
|
|
@@ -1884,7 +1891,7 @@ var OverlayController = class {
|
|
|
1884
1891
|
function promptText(mode) {
|
|
1885
1892
|
return `# Computer use (Windows desktop)
|
|
1886
1893
|
You can see and operate the user's Windows computer with the computer, computer_batch, open_application, windows, ui_elements, clipboard and app_skill tools.
|
|
1887
|
-
${mode === "per-app" ? "- Before acting on an app, call request_access once with every app the task needs; the user approves it. Input to apps that are not granted is refused.\n" : ""}-
|
|
1894
|
+
${mode === "per-app" ? "- Before acting on an app, call request_access once with every app the task needs; the user approves it. Input to apps that are not granted is refused.\n" : ""}- If the task begins with an app, open it right away with open_application (after request_access when the app is not granted yet): it returns the screenshot, so do not take one first. Otherwise start with a screenshot (computer action "screenshot") unless you just received one. All coordinates are pixels of the latest screenshot; the plugin converts them for DPI and scaling.
|
|
1888
1895
|
- Open or switch apps with open_application (by name; it also finds desktop shortcuts) rather than hunting through the taskbar or Start menu or starting GUI apps from a shell. Use windows to see which windows exist; each line shows the process .exe. Apps closed to the system tray (QQ, 微信...) are still running: open_application restores them from their tray icon. Do not start a second copy of a running app unless the user explicitly asks for one (then pass new_instance: true), and never show or kill its hidden windows from a shell (Electron / Qt apps freeze, and a second QQ / WeChat asks for another login).
|
|
1889
1896
|
- When the task is done, tidy up: close windows and dialogs you opened that the user no longer needs (keep the one showing the result they asked for), and call windows tidy to minimize again the apps that were minimized or in the tray before you started. Never close windows the user already had open.
|
|
1890
1897
|
- The "DeepSeek Harness.exe" window is your own chat interface. While you control the computer it floats as a card that only the user sees: your screenshots show what is underneath it and your clicks and scrolls pass through it, so simply ignore it. Never type into DeepSeek Harness; keys go to the window you were working in.
|
|
@@ -1894,7 +1901,7 @@ ${mode === "per-app" ? "- Before acting on an app, call request_access once with
|
|
|
1894
1901
|
- When the user asks you to write something in an app, enter it there with type, even long or multi-line Markdown: the user watches it appear (long text is streamed in paragraph by paragraph, literally, without the editor's auto-formatting getting in the way). Do not write the file from a shell and reopen it instead, and do not put text on the clipboard with shell commands (Set-Clipboard, clip): that clutters the user's clipboard history.
|
|
1895
1902
|
- App skills: open_application returns your saved notes for the app it opens; follow them instead of rediscovering how the app behaves. After working out an unfamiliar app (or finding a note wrong), record the reusable part with app_skill rather than in general memory.
|
|
1896
1903
|
- Saving: in any Save As dialog do not click through folders; press alt+n (file name box), ctrl+a, type the full path including the file name, then Return. Office apps: F12 opens that classic dialog directly. To check a saved file, look at the exact path; never search a whole drive or user profile recursively.
|
|
1897
|
-
- Be fast: what the user waits for is mostly the number of calls you make (each costs seconds). Once you have seen the app's window, put everything predictable into ONE computer_batch, including steps whose target is not on screen yet: name the control with target ("保存", "按钮:确定") instead of a coordinate, and use wait with until ("window:另存为") for a dialog to appear before keys meant for it. Do not end a batch with wait or follow it with a screenshot: its result already is the settled screen. If you will need to read small text, end the batch with zoom; to read what a window says (a document, a page, a reply, a log) use ui_elements with text: true or finish: "text" instead of scrolling and zooming screenshots. Keep your own text between calls to a line. Avoid shell commands for things you can see on screen.
|
|
1904
|
+
- Be fast: what the user waits for is mostly the number of calls you make (each costs seconds). Once you have seen the app's window, put everything predictable into ONE computer_batch, including steps whose target is not on screen yet: name the control with target ("保存", "按钮:确定") instead of a coordinate, and use wait with until ("window:另存为") for a dialog to appear before keys meant for it. Do not end a batch with wait or follow it with a wait or a screenshot: its result already is the settled screen. Do not split work into two batches just to look in between when the second does not depend on what you would see (type the text and format it in the same batch). If you will need to read small text, end the batch with zoom; to read what a window says (a document, a page, a reply, a log) use ui_elements with text: true or finish: "text" instead of scrolling and zooming screenshots. Keep your own text between calls to a line. Avoid shell commands for things you can see on screen.
|
|
1898
1905
|
- To see more of a page or list, scroll (action "scroll" with coordinate over the area, scroll_direction, scroll_amount 5-10) instead of hunting with zoom; for long web pages Page Down / End keys also work.
|
|
1899
1906
|
- If a dedicated tool fits the whole task better (an API, or browser automation attached to the user's own browser), choose it at the start; do not switch tools halfway through a task that is going fine on screen.
|
|
1900
1907
|
- Do not enter passwords, payment details or solve CAPTCHAs: stop and ask the user to do that step. Ask before irreversible actions (sending messages, deleting, purchasing) unless the user clearly asked for them.
|
|
@@ -2120,7 +2127,8 @@ const DEFAULTS = {
|
|
|
2120
2127
|
blockedApps: [],
|
|
2121
2128
|
pauseOnUserInput: true,
|
|
2122
2129
|
userIdleMs: 1500,
|
|
2123
|
-
typingMode: "stream"
|
|
2130
|
+
typingMode: "stream",
|
|
2131
|
+
quickSteps: false
|
|
2124
2132
|
};
|
|
2125
2133
|
/** Unwrap `.volatile()` refs (`{ get() }`) and fall back to defaults for bad values. */
|
|
2126
2134
|
function resolveConfig(raw) {
|
|
@@ -2144,11 +2152,53 @@ function resolveConfig(raw) {
|
|
|
2144
2152
|
jpegQuality: num("jpegQuality", 30, 100),
|
|
2145
2153
|
pauseOnUserInput: bool("pauseOnUserInput"),
|
|
2146
2154
|
userIdleMs: num("userIdleMs", 300, 1e4),
|
|
2155
|
+
quickSteps: bool("quickSteps"),
|
|
2147
2156
|
typingMode: out.typingMode === "stream" || out.typingMode === "type" || out.typingMode === "paste" ? out.typingMode : DEFAULTS.typingMode,
|
|
2148
2157
|
blockedApps: Array.isArray(out.blockedApps) ? out.blockedApps.filter((item) => typeof item === "string" && item.trim() !== "") : []
|
|
2149
2158
|
};
|
|
2150
2159
|
}
|
|
2151
2160
|
//#endregion
|
|
2161
|
+
//#region lib/types/effort.js
|
|
2162
|
+
/**
|
|
2163
|
+
* Quick steps: while the agent is operating the computer, each model request
|
|
2164
|
+
* is "look at the screenshot, pick the next click". Deliberating over that
|
|
2165
|
+
* costs seconds per step and is what makes the motion feel halting, so those
|
|
2166
|
+
* requests can run at the model's lowest reasoning effort. Requests that are
|
|
2167
|
+
* not in the middle of operating (planning from the user's message, working
|
|
2168
|
+
* with other tools) keep the session's own setting.
|
|
2169
|
+
*/
|
|
2170
|
+
/**
|
|
2171
|
+
* Is this request the continuation of computer use: was the last thing in the
|
|
2172
|
+
* conversation the result of one of this plugin's tools?
|
|
2173
|
+
*/
|
|
2174
|
+
function isOperating(messages, ownTools) {
|
|
2175
|
+
const last = messages[messages.length - 1];
|
|
2176
|
+
if (last?.role !== "tool" || typeof last.toolCallId !== "string") return false;
|
|
2177
|
+
for (let index = messages.length - 2; index >= 0; index--) {
|
|
2178
|
+
const message = messages[index];
|
|
2179
|
+
if (message.role !== "assistant" || !Array.isArray(message.content)) continue;
|
|
2180
|
+
const call = message.content.find((part) => part.type === "tool-call" && part.id === last.toolCallId);
|
|
2181
|
+
if (call) return typeof call.name === "string" && ownTools.has(call.name);
|
|
2182
|
+
return false;
|
|
2183
|
+
}
|
|
2184
|
+
return false;
|
|
2185
|
+
}
|
|
2186
|
+
/** Effort ids that mean "do not deliberate", best first. Only an exact, advertised id is ever used. */
|
|
2187
|
+
const LOWEST = [
|
|
2188
|
+
"off",
|
|
2189
|
+
"none",
|
|
2190
|
+
"disabled",
|
|
2191
|
+
"minimal",
|
|
2192
|
+
"low"
|
|
2193
|
+
];
|
|
2194
|
+
/** The lowest reasoning effort a model offers, or undefined when it offers none we recognise. */
|
|
2195
|
+
function lowestEffort(efforts) {
|
|
2196
|
+
if (!Array.isArray(efforts)) return void 0;
|
|
2197
|
+
const ids = new Set(efforts.map((effort) => String(effort.id).toLowerCase()));
|
|
2198
|
+
const pick = LOWEST.find((id) => ids.has(id));
|
|
2199
|
+
return pick === void 0 ? void 0 : efforts.find((effort) => String(effort.id).toLowerCase() === pick).id;
|
|
2200
|
+
}
|
|
2201
|
+
//#endregion
|
|
2152
2202
|
//#region lib/types/routes.js
|
|
2153
2203
|
const STATUS_ROUTE = "/api/dsh-computer-use/status";
|
|
2154
2204
|
const PREVIEW_ROUTE = "/api/dsh-computer-use/preview";
|
|
@@ -2210,16 +2260,31 @@ function previewRoute(helper, settings, overlay, iconPath) {
|
|
|
2210
2260
|
return;
|
|
2211
2261
|
}
|
|
2212
2262
|
const s = settings();
|
|
2263
|
+
const pet = s.hostWindow === "pet";
|
|
2213
2264
|
await helper.call("overlay_show", {
|
|
2214
|
-
label: `${s.overlayLabel} 正在操控你的电脑`,
|
|
2215
|
-
status: "预览 ·
|
|
2265
|
+
label: pet ? `${s.overlayLabel} 正在操控` : `${s.overlayLabel} 正在操控你的电脑`,
|
|
2266
|
+
status: pet ? "预览" : "预览 · 4 秒后消失",
|
|
2216
2267
|
icon: iconPath,
|
|
2268
|
+
iconLight: iconPath.replace(/deepseek-white\.png$/, "deepseek-black.png"),
|
|
2217
2269
|
idleMs: s.userIdleMs,
|
|
2218
|
-
glow: s.overlay
|
|
2270
|
+
glow: s.overlay,
|
|
2271
|
+
pet,
|
|
2272
|
+
petOpacity: s.cardOpacity,
|
|
2273
|
+
text: ""
|
|
2219
2274
|
});
|
|
2275
|
+
if (pet) await helper.call("pet_update", {
|
|
2276
|
+
text: "这是预览:操控电脑时,这里滚动显示 AI 的回复正文。",
|
|
2277
|
+
thinking: "第二行显示思考过程和最近几步操作",
|
|
2278
|
+
steps: [
|
|
2279
|
+
"打开应用",
|
|
2280
|
+
"输入文字",
|
|
2281
|
+
"预览 · 4 秒后消失"
|
|
2282
|
+
],
|
|
2283
|
+
thinkingLatest: false
|
|
2284
|
+
}).catch(() => {});
|
|
2220
2285
|
setTimeout(() => {
|
|
2221
2286
|
if (overlay.controller === void 0) helper.call("overlay_hide").catch(() => {});
|
|
2222
|
-
},
|
|
2287
|
+
}, 4e3).unref();
|
|
2223
2288
|
json(res, 200, { ok: true });
|
|
2224
2289
|
};
|
|
2225
2290
|
}
|
|
@@ -8454,7 +8519,10 @@ function createTools(host) {
|
|
|
8454
8519
|
const appName = /^ms-settings:/i.test(name) ? "设置" : name;
|
|
8455
8520
|
if (settings.accessMode === "per-app" && !isUrl && computer.access.missing(call.session, [appName]).length > 0) {
|
|
8456
8521
|
const running = (await computer.windows()).find((win) => appMatches(appName, win)) ?? (await computer.backgroundApps(false)).find((win) => appMatches(appName, win));
|
|
8457
|
-
if (!running || !computer.access.isGranted(call.session, running))
|
|
8522
|
+
if (!running || !computer.access.isGranted(call.session, running)) {
|
|
8523
|
+
if (call.autoApprove !== true || normalizeApp(appName).includes("deepseek harness")) throw new Error(`"${appName}" is not granted for this session. Call request_access with ["${appName}"] first.`);
|
|
8524
|
+
computer.access.grant(call.session, [appName]);
|
|
8525
|
+
}
|
|
8458
8526
|
}
|
|
8459
8527
|
await computer.overlay.begin(call.agent, `打开 ${name}`);
|
|
8460
8528
|
await computer.overlay.yieldToUser(call.signal, false);
|
|
@@ -8867,6 +8935,10 @@ const Config = z.object({
|
|
|
8867
8935
|
"zh-CN": { $description: "文字输入方式" },
|
|
8868
8936
|
"en-US": { $description: "How text is entered" }
|
|
8869
8937
|
}),
|
|
8938
|
+
quickSteps: z.boolean().default(false).volatile().i18n({
|
|
8939
|
+
"zh-CN": { $description: "操作电脑的那几轮请求用模型的最低思考强度(每步更快);其余请求沿用会话的思考强度" },
|
|
8940
|
+
"en-US": { $description: "Use the model's lowest reasoning effort for the requests in the middle of operating the computer (faster steps); other requests keep the session's effort" }
|
|
8941
|
+
}),
|
|
8870
8942
|
autoScreenshot: z.boolean().default(true).volatile().i18n({
|
|
8871
8943
|
"zh-CN": { $description: "每次操作后自动回传截图(省去一轮调用)" },
|
|
8872
8944
|
"en-US": { $description: "Return a screenshot after every action (saves a round trip)" }
|
|
@@ -8934,6 +9006,15 @@ function apply(ctx, config = {}) {
|
|
|
8934
9006
|
return cached;
|
|
8935
9007
|
};
|
|
8936
9008
|
const attachments = () => ctx.attachments;
|
|
9009
|
+
/** "never" comes from the full-access / auto presets: the user opted out of approval prompts. */
|
|
9010
|
+
const approvalPolicy = (agent) => {
|
|
9011
|
+
const approval = ctx.get("approval");
|
|
9012
|
+
try {
|
|
9013
|
+
return approval?.effectivePolicy?.(agent.session);
|
|
9014
|
+
} catch {
|
|
9015
|
+
return;
|
|
9016
|
+
}
|
|
9017
|
+
};
|
|
8937
9018
|
const screenshots = new ScreenshotCache(void 0, void 0, log);
|
|
8938
9019
|
ctx.effect(() => {
|
|
8939
9020
|
const sweep = () => {
|
|
@@ -8967,7 +9048,8 @@ function apply(ctx, config = {}) {
|
|
|
8967
9048
|
session: exec.agent?.session.id ?? "default",
|
|
8968
9049
|
agent: exec.agent,
|
|
8969
9050
|
signal: exec.signal,
|
|
8970
|
-
vision: await supportsVision(exec.agent, exec.signal)
|
|
9051
|
+
vision: await supportsVision(exec.agent, exec.signal),
|
|
9052
|
+
autoApprove: exec.agent !== void 0 && approvalPolicy(exec.agent) === "never"
|
|
8971
9053
|
};
|
|
8972
9054
|
}
|
|
8973
9055
|
});
|
|
@@ -8992,6 +9074,40 @@ function apply(ctx, config = {}) {
|
|
|
8992
9074
|
}
|
|
8993
9075
|
};
|
|
8994
9076
|
});
|
|
9077
|
+
ctx.inject(["llm"], (llmCtx) => {
|
|
9078
|
+
const lowest = /* @__PURE__ */ new Map();
|
|
9079
|
+
const lowestFor = (provider, model) => {
|
|
9080
|
+
const key = `${provider}\u0000${model}`;
|
|
9081
|
+
let cached = lowest.get(key);
|
|
9082
|
+
if (!cached) {
|
|
9083
|
+
const llm = llmCtx.llm;
|
|
9084
|
+
cached = typeof llm.resolveModelInfo === "function" ? llm.resolveModelInfo(provider, model).then((info) => lowestEffort(info.reasoning?.efforts)).catch(() => {
|
|
9085
|
+
lowest.delete(key);
|
|
9086
|
+
}) : Promise.resolve(void 0);
|
|
9087
|
+
lowest.set(key, cached);
|
|
9088
|
+
}
|
|
9089
|
+
return cached;
|
|
9090
|
+
};
|
|
9091
|
+
const lowered = /* @__PURE__ */ new WeakSet();
|
|
9092
|
+
llmCtx.effect(() => llmCtx.on("llm/stream", ((options, next) => {
|
|
9093
|
+
if (!settings().quickSteps || !options.provider || !options.model || !Array.isArray(options.messages) || !isOperating(options.messages, OWN_TOOLS)) return next();
|
|
9094
|
+
if (lowered.has(options)) return next();
|
|
9095
|
+
const { provider, model } = options;
|
|
9096
|
+
return (async function* () {
|
|
9097
|
+
const effort = await lowestFor(provider, model);
|
|
9098
|
+
if (effort === void 0 || options.reasoningEffort === effort) {
|
|
9099
|
+
yield* next();
|
|
9100
|
+
return;
|
|
9101
|
+
}
|
|
9102
|
+
const copy = Object.freeze({
|
|
9103
|
+
...options,
|
|
9104
|
+
reasoningEffort: effort
|
|
9105
|
+
});
|
|
9106
|
+
lowered.add(copy);
|
|
9107
|
+
yield* llmCtx.llm.stream(copy);
|
|
9108
|
+
})();
|
|
9109
|
+
}), { global: true }), "computer-use: quick steps");
|
|
9110
|
+
});
|
|
8995
9111
|
ctx.on("agent/assistant-stream", ({ agent, frame }) => {
|
|
8996
9112
|
overlay.stream(agent, frame);
|
|
8997
9113
|
});
|
package/lib/types/computer.d.ts
CHANGED
|
@@ -22,6 +22,8 @@ export interface Settings {
|
|
|
22
22
|
userIdleMs: number;
|
|
23
23
|
/** How text is entered: stream = paste block by block, type = key by key, paste = at once. */
|
|
24
24
|
typingMode: TypingMode;
|
|
25
|
+
/** Run the model at its lowest reasoning effort for the requests in the middle of operating the computer. */
|
|
26
|
+
quickSteps: boolean;
|
|
25
27
|
}
|
|
26
28
|
export type TypingMode = 'stream' | 'type' | 'paste';
|
|
27
29
|
export interface WindowInfo extends WindowLike {
|
|
@@ -49,6 +51,8 @@ export interface CallContext {
|
|
|
49
51
|
signal: AbortSignal;
|
|
50
52
|
/** Whether the conversation model can look at images. */
|
|
51
53
|
vision: boolean;
|
|
54
|
+
/** The session never prompts for approval (full access / auto review): access requests are granted as they come. */
|
|
55
|
+
autoApprove?: boolean;
|
|
52
56
|
}
|
|
53
57
|
export declare const ACTIONS: readonly ["screenshot", "left_click", "right_click", "middle_click", "double_click", "triple_click", "mouse_move", "left_click_drag", "left_mouse_down", "left_mouse_up", "scroll", "type", "key", "hold_key", "wait", "zoom", "cursor_position"];
|
|
54
58
|
export type Action = typeof ACTIONS[number];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Quick steps: while the agent is operating the computer, each model request
|
|
3
|
+
* is "look at the screenshot, pick the next click". Deliberating over that
|
|
4
|
+
* costs seconds per step and is what makes the motion feel halting, so those
|
|
5
|
+
* requests can run at the model's lowest reasoning effort. Requests that are
|
|
6
|
+
* not in the middle of operating (planning from the user's message, working
|
|
7
|
+
* with other tools) keep the session's own setting.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Is this request the continuation of computer use: was the last thing in the
|
|
11
|
+
* conversation the result of one of this plugin's tools?
|
|
12
|
+
*/
|
|
13
|
+
export declare function isOperating(messages: readonly unknown[], ownTools: ReadonlySet<string>): boolean;
|
|
14
|
+
/** The lowest reasoning effort a model offers, or undefined when it offers none we recognise. */
|
|
15
|
+
export declare function lowestEffort(efforts: readonly {
|
|
16
|
+
id: string;
|
|
17
|
+
}[] | undefined): string | undefined;
|
package/lib/types/index.d.ts
CHANGED
package/lib/types/text.d.ts
CHANGED
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Blocks end after a blank-line separator, never inside a ``` / ~~~ fence and
|
|
7
7
|
* never inside a paragraph (a half-pasted **bold** or link may not re-render).
|
|
8
|
-
*
|
|
8
|
+
* Text with no blank line at all (a story written one paragraph per line) is
|
|
9
|
+
* split at its line ends instead, or it would go in as a single block; a table
|
|
10
|
+
* keeps its rows together. Joining the blocks gives back the original text exactly.
|
|
9
11
|
*/
|
|
10
12
|
export declare function splitBlocks(text: string, minChars?: number): string[];
|
|
11
13
|
/** Pieces of at most ~`size` characters, broken after whitespace where possible (for paced typing). */
|
package/package.json
CHANGED