@copylee/dsh-computer-use 0.6.1 → 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 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,
@@ -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 }, "让出控制"), h(ToggleRow, {
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
@@ -2127,7 +2127,8 @@ const DEFAULTS = {
2127
2127
  blockedApps: [],
2128
2128
  pauseOnUserInput: true,
2129
2129
  userIdleMs: 1500,
2130
- typingMode: "stream"
2130
+ typingMode: "stream",
2131
+ quickSteps: false
2131
2132
  };
2132
2133
  /** Unwrap `.volatile()` refs (`{ get() }`) and fall back to defaults for bad values. */
2133
2134
  function resolveConfig(raw) {
@@ -2151,11 +2152,53 @@ function resolveConfig(raw) {
2151
2152
  jpegQuality: num("jpegQuality", 30, 100),
2152
2153
  pauseOnUserInput: bool("pauseOnUserInput"),
2153
2154
  userIdleMs: num("userIdleMs", 300, 1e4),
2155
+ quickSteps: bool("quickSteps"),
2154
2156
  typingMode: out.typingMode === "stream" || out.typingMode === "type" || out.typingMode === "paste" ? out.typingMode : DEFAULTS.typingMode,
2155
2157
  blockedApps: Array.isArray(out.blockedApps) ? out.blockedApps.filter((item) => typeof item === "string" && item.trim() !== "") : []
2156
2158
  };
2157
2159
  }
2158
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
2159
2202
  //#region lib/types/routes.js
2160
2203
  const STATUS_ROUTE = "/api/dsh-computer-use/status";
2161
2204
  const PREVIEW_ROUTE = "/api/dsh-computer-use/preview";
@@ -8892,6 +8935,10 @@ const Config = z.object({
8892
8935
  "zh-CN": { $description: "文字输入方式" },
8893
8936
  "en-US": { $description: "How text is entered" }
8894
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
+ }),
8895
8942
  autoScreenshot: z.boolean().default(true).volatile().i18n({
8896
8943
  "zh-CN": { $description: "每次操作后自动回传截图(省去一轮调用)" },
8897
8944
  "en-US": { $description: "Return a screenshot after every action (saves a round trip)" }
@@ -9027,6 +9074,40 @@ function apply(ctx, config = {}) {
9027
9074
  }
9028
9075
  };
9029
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
+ });
9030
9111
  ctx.on("agent/assistant-stream", ({ agent, frame }) => {
9031
9112
  overlay.stream(agent, frame);
9032
9113
  });
@@ -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 {
@@ -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;
@@ -23,6 +23,7 @@ export interface Config {
23
23
  pauseOnUserInput?: boolean;
24
24
  userIdleMs?: number;
25
25
  typingMode?: TypingMode;
26
+ quickSteps?: boolean;
26
27
  }
27
28
  export declare const Config: z<Config>;
28
29
  export declare function apply(ctx: Context, config?: Config): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@copylee/dsh-computer-use",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "description": "DeepSeek Harness Computer Use 插件(Windows):让 AI 看屏幕、点鼠标、敲键盘操控电脑;控制时屏幕泛起橙色光晕并显示“DeepSeek Harness 正在操控你的电脑”,按 Esc 暂停 / 继续。",
5
5
  "type": "module",
6
6
  "author": "copylee",