@copylee/dsh-computer-use 0.7.1 → 0.7.2

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/lib/index.js CHANGED
@@ -2164,22 +2164,32 @@ function resolveConfig(raw) {
2164
2164
  * is "look at the screenshot, pick the next click". Deliberating over that
2165
2165
  * costs seconds per step and is what makes the motion feel halting, so those
2166
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.
2167
+ * not part of operating (planning from the user's message, turns that never
2168
+ * touch the computer) keep the session's own setting.
2169
2169
  */
2170
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?
2171
+ * Has this turn started operating the computer: is there a result of one of
2172
+ * this plugin's tools since the user's last message?
2173
+ *
2174
+ * It has to hold for the rest of the turn, not only right after such a result:
2175
+ * the replies written at the lowered effort carry no reasoning, and a provider
2176
+ * in thinking mode refuses a turn whose earlier tool-calling replies lack it
2177
+ * (DeepSeek: "content[].thinking ... must be passed back"). So once a turn has
2178
+ * a reply written without thinking, every later request of that turn goes
2179
+ * without it too.
2173
2180
  */
2174
2181
  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--) {
2182
+ let start = messages.length;
2183
+ while (start > 0 && messages[start - 1]?.role !== "user") start--;
2184
+ const names = /* @__PURE__ */ new Map();
2185
+ for (let index = start; index < messages.length; index++) {
2178
2186
  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;
2187
+ if (message?.role === "assistant" && Array.isArray(message.content)) {
2188
+ for (const part of message.content) if (part.type === "tool-call" && typeof part.id === "string" && typeof part.name === "string") names.set(part.id, part.name);
2189
+ } else if (message?.role === "tool" && typeof message.toolCallId === "string") {
2190
+ const name = names.get(message.toolCallId);
2191
+ if (name !== void 0 && ownTools.has(name)) return true;
2192
+ }
2183
2193
  }
2184
2194
  return false;
2185
2195
  }
@@ -3,12 +3,19 @@
3
3
  * is "look at the screenshot, pick the next click". Deliberating over that
4
4
  * costs seconds per step and is what makes the motion feel halting, so those
5
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.
6
+ * not part of operating (planning from the user's message, turns that never
7
+ * touch the computer) keep the session's own setting.
8
8
  */
9
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?
10
+ * Has this turn started operating the computer: is there a result of one of
11
+ * this plugin's tools since the user's last message?
12
+ *
13
+ * It has to hold for the rest of the turn, not only right after such a result:
14
+ * the replies written at the lowered effort carry no reasoning, and a provider
15
+ * in thinking mode refuses a turn whose earlier tool-calling replies lack it
16
+ * (DeepSeek: "content[].thinking ... must be passed back"). So once a turn has
17
+ * a reply written without thinking, every later request of that turn goes
18
+ * without it too.
12
19
  */
13
20
  export declare function isOperating(messages: readonly unknown[], ownTools: ReadonlySet<string>): boolean;
14
21
  /** The lowest reasoning effort a model offers, or undefined when it offers none we recognise. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@copylee/dsh-computer-use",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "description": "DeepSeek Harness Computer Use 插件(Windows):让 AI 看屏幕、点鼠标、敲键盘操控电脑;控制时屏幕泛起橙色光晕并显示“DeepSeek Harness 正在操控你的电脑”,按 Esc 暂停 / 继续。",
5
5
  "type": "module",
6
6
  "author": "copylee",