@copylee/dsh-computer-use 0.7.2 → 0.7.4

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
@@ -18,7 +18,7 @@
18
18
  | 把窗口读成文本 | `ui_elements` 加 `text: true` 直接读出文档、网页、聊天回复或日志的文字(默认取末尾 4000 字),比滚动加放大截图快,也能逐字引用;批量调用加 `finish: "text"` 可以用文字代替结尾的截图 |
19
19
  | 按应用授权 | 先 `request_access` 列出要操控的应用,经 DSH 原生审批后才能操作;也可改为“全部允许” |
20
20
  | 不会操作自己 | 永远拒绝向 DeepSeek Harness 自身窗口输入;常见密码管理器默认禁止,可再自定义禁用列表 |
21
- | 正在控制的提示 | 橙色光晕 + 胶囊提示条(显示当前动作),**不会出现在截图里** |
21
+ | 正在控制的提示 | 橙色光晕 + 胶囊提示条(显示当前动作),**不会出现在截图里**;AI 还在忙但已不再操作电脑时(约 90 秒没有电脑操作,或连续调用了 3 个其他工具)自动收起,下次操作电脑时再出现 |
22
22
  | 迷你进度卡片(默认) | 操控期间 DeepSeek Harness 最小化,右下角显示一张半透明小卡片:标题行有 DeepSeek 图标和“输入”“展开”“暂停”“停止”四个圆形按钮;第一行滚动显示回复正文(实时流式),第二行显示思考过程,或最近几步的小时间线(已完成的步骤打勾,如“打开 Word › 输入正文 › 另存为”)。点“展开”变成长卡片:多行回复、思考、最近 5 步时间线。点“输入”在卡片下方弹出输入框,AI 自动暂停,输入指令按 Enter 发送(与在 DSH 里插话一样,AI 下一步就会看到),Esc 取消。任务结束时卡片显示“已完成”几秒再消失(鼠标停在上面会一直保留)。卡片可拖动、跟随系统深浅色,AI 的截图里看不到它,点击也会穿透它。操控中你把 DSH 窗口打开,它会自动变成下面的半透明悬浮卡片,不会挡住 AI |
23
23
  | 悬浮卡片 | 操控期间 DeepSeek Harness 窗口缩成右下角置顶卡片,结束后自动恢复原尺寸、位置和最大化 / 最小化状态(也可选最小化或不动)。卡片只给你看:AI 的截图里看到的是卡片下面的内容(通过 Windows 放大镜接口截图时把卡片排除在外,不闪烁;该接口不可用时退回为截图瞬间让卡片透明约 20 毫秒),点击和滚动也直接穿透卡片,卡片不会挪位置。卡片默认 80% 不透明,可以透过它看清下面的操作过程;鼠标在卡片上停一下就变回不透明,方便阅读和点击(透明度可在设置里调) |
24
24
  | 暂停与停止 | 你亲手按 **Esc** 暂停(AI 停在下一步之前),再按 Esc 或点“继续”恢复,对话不会被中断;点“停止”才结束本轮。插件自己发出的 Esc 不会误触发 |
@@ -84,7 +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
+ | 操作时不深度思考(Beta) | 关 | 试验功能,一般不用开。开始操作电脑后,本轮改用模型的最低思考强度,每一步快约 1 秒;下一轮恢复会话里选的思考强度。不思考时模型更容易出错、多走几步;工具参数写坏时会自动重发那一步,为此本轮的回复文字整段出现而不是逐字流出。目前只在 DeepSeek 官方模型上有效 |
88
88
  | 检测到你在操作时让出控制 | 开 | 键盘输入暂停、窗口被切换时重新看屏幕 |
89
89
  | 文字输入方式 | 流式 | 流式(长文本逐段出现)/ 逐字输入(最像打字,最慢)/ 一次粘贴(最快) |
90
90
  | 键盘静止多久后恢复 | 1500 ms | |
package/lib/client.js CHANGED
@@ -1228,8 +1228,8 @@ window.__ModuleLoader__.load({
1228
1228
  ...S.hint,
1229
1229
  fontWeight: 400
1230
1230
  } }, "短文字都会逐字打出来。长文本逐字输入在 Typora、Obsidian、Word 等编辑器里可能被自动补全括号、自动续列表打乱;流式按段落粘贴,既看得到过程又不会乱。")))), h("section", { style: S.card }, h("h3", { style: S.cardTitle }, "速度"), h(ToggleRow, {
1231
- title: "操作时不深度思考",
1232
- hint: "正在操作电脑的那几轮(看截图、决定下一步点哪里)改用模型的最低思考强度,每一步明显更快、动作更连贯;任务开头的规划和其他对话仍按会话里选的思考强度。模型不支持调整思考强度时不起作用。",
1231
+ title: "操作时不深度思考(Beta)",
1232
+ hint: "试验功能,一般不用开。开始操作电脑后,本轮改用模型的最低思考强度,每一步快约 1 秒;任务开头的规划和之后的对话仍按会话里选的思考强度。代价:不思考时模型更容易出错、多走几步,本轮的回复文字会整段出现而不是逐字流出。目前只在 DeepSeek 官方模型上有效。",
1233
1233
  checked: draft.quickSteps,
1234
1234
  disabled,
1235
1235
  onChange: (value) => edit("quickSteps", value)
package/lib/index.js CHANGED
@@ -1580,6 +1580,13 @@ const FINISH_HOLD_MS = 4e3;
1580
1580
  * starts of any plugin count, so a slow shell command does not end the run.
1581
1581
  */
1582
1582
  const IDLE_HIDE_MS = 6e5;
1583
+ /**
1584
+ * The agent stays busy but has stopped operating the computer (it looked at the screen once and went on with
1585
+ * other tools): the glow and the card go after this long without a computer action, or sooner once it has
1586
+ * started this many tools of other plugins in a row. The next computer action brings them back.
1587
+ */
1588
+ const UNUSED_HIDE_MS = 9e4;
1589
+ const UNUSED_AFTER_TOOLS = 3;
1583
1590
  /** A pause longer than this ends the tool call with a message for the model. */
1584
1591
  const MAX_PAUSE_MS = 15e5;
1585
1592
  /** Card rectangle in the bottom-right corner of a display's work area. */
@@ -1603,6 +1610,8 @@ var OverlayController = class {
1603
1610
  agent;
1604
1611
  visible = false;
1605
1612
  idleTimer;
1613
+ unusedTimer;
1614
+ otherTools = 0;
1606
1615
  hostWindows = [];
1607
1616
  stopping = false;
1608
1617
  /** Progress card lines: the reply as it streams, and what the agent is doing. */
@@ -1676,6 +1685,7 @@ var OverlayController = class {
1676
1685
  async begin(agent, status) {
1677
1686
  if (agent) this.agent = agent;
1678
1687
  this.armIdle();
1688
+ this.armUnused();
1679
1689
  const settings = this.settings();
1680
1690
  if (!this.visible) {
1681
1691
  this.visible = true;
@@ -1714,6 +1724,7 @@ var OverlayController = class {
1714
1724
  async status(status) {
1715
1725
  const settings = this.settings();
1716
1726
  if (!this.visible) return;
1727
+ this.armUnused();
1717
1728
  if (settings.hostWindow === "pet") {
1718
1729
  this.step(status);
1719
1730
  return;
@@ -1759,7 +1770,14 @@ var OverlayController = class {
1759
1770
  /** A tool of another plugin started (computer-use tools report their own steps). */
1760
1771
  toolStarted(agent, name, detail) {
1761
1772
  if (agent !== this.streamAgent) return;
1762
- if (this.visible && agent === this.agent) this.armIdle();
1773
+ if (this.visible && agent === this.agent) {
1774
+ this.armIdle();
1775
+ if (++this.otherTools >= UNUSED_AFTER_TOOLS && !this.paused) {
1776
+ this.log("computer use not used for a while (other tools running): overlay released");
1777
+ this.end();
1778
+ return;
1779
+ }
1780
+ }
1763
1781
  this.step(`${TOOL_NAMES[name] ?? name}${detail ? `:${detail}` : ""}`);
1764
1782
  }
1765
1783
  schedulePush() {
@@ -1781,6 +1799,9 @@ var OverlayController = class {
1781
1799
  if (agent !== void 0 && this.agent !== void 0 && agent !== this.agent) return;
1782
1800
  if (this.idleTimer) clearTimeout(this.idleTimer);
1783
1801
  this.idleTimer = void 0;
1802
+ if (this.unusedTimer) clearTimeout(this.unusedTimer);
1803
+ this.unusedTimer = void 0;
1804
+ this.otherTools = 0;
1784
1805
  this.agent = void 0;
1785
1806
  this.paused = false;
1786
1807
  if (!this.visible) return;
@@ -1810,6 +1831,20 @@ var OverlayController = class {
1810
1831
  this.stopping = false;
1811
1832
  });
1812
1833
  }
1834
+ /** Counted from the last computer action only: model output and other tools do not keep the overlay up. */
1835
+ armUnused() {
1836
+ this.otherTools = 0;
1837
+ if (this.unusedTimer) clearTimeout(this.unusedTimer);
1838
+ this.unusedTimer = setTimeout(() => {
1839
+ if (this.paused) {
1840
+ this.armUnused();
1841
+ return;
1842
+ }
1843
+ this.log("computer use not used for a while: overlay released");
1844
+ this.end();
1845
+ }, UNUSED_HIDE_MS);
1846
+ this.unusedTimer.unref();
1847
+ }
1813
1848
  armIdle() {
1814
1849
  if (this.idleTimer) clearTimeout(this.idleTimer);
1815
1850
  this.idleTimer = setTimeout(() => {
@@ -2208,6 +2243,26 @@ function lowestEffort(efforts) {
2208
2243
  const pick = LOWEST.find((id) => ids.has(id));
2209
2244
  return pick === void 0 ? void 0 : efforts.find((effort) => String(effort.id).toLowerCase() === pick).id;
2210
2245
  }
2246
+ /**
2247
+ * Without deliberation the model now and then writes a tool call whose
2248
+ * arguments are not valid JSON, which the adapter raises as
2249
+ * MALFORMED_RESPONSE and which would end the turn. Such a reply is thrown
2250
+ * away and asked for again. The reply is held back until it is complete, as
2251
+ * events already passed on could not be taken back.
2252
+ */
2253
+ async function* retryMalformed(run, attempts = 3) {
2254
+ for (let attempt = 1;; attempt++) {
2255
+ const events = [];
2256
+ try {
2257
+ for await (const event of run()) events.push(event);
2258
+ } catch (error) {
2259
+ if (attempt < attempts && error?.code === "MALFORMED_RESPONSE") continue;
2260
+ throw error;
2261
+ }
2262
+ yield* events;
2263
+ return;
2264
+ }
2265
+ }
2211
2266
  //#endregion
2212
2267
  //#region lib/types/routes.js
2213
2268
  const STATUS_ROUTE = "/api/dsh-computer-use/status";
@@ -8946,8 +9001,8 @@ const Config = z.object({
8946
9001
  "en-US": { $description: "How text is entered" }
8947
9002
  }),
8948
9003
  quickSteps: z.boolean().default(false).volatile().i18n({
8949
- "zh-CN": { $description: "操作电脑的那几轮请求用模型的最低思考强度(每步更快);其余请求沿用会话的思考强度" },
8950
- "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" }
9004
+ "zh-CN": { $description: "(Beta)操作电脑的那一轮用模型的最低思考强度(每步更快);其余沿用会话的思考强度" },
9005
+ "en-US": { $description: "(Beta) 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" }
8951
9006
  }),
8952
9007
  autoScreenshot: z.boolean().default(true).volatile().i18n({
8953
9008
  "zh-CN": { $description: "每次操作后自动回传截图(省去一轮调用)" },
@@ -9114,7 +9169,8 @@ function apply(ctx, config = {}) {
9114
9169
  reasoningEffort: effort
9115
9170
  });
9116
9171
  lowered.add(copy);
9117
- yield* llmCtx.llm.stream(copy);
9172
+ const llm = llmCtx.llm;
9173
+ yield* retryMalformed(() => llm.stream(copy));
9118
9174
  })();
9119
9175
  }), { global: true }), "computer-use: quick steps");
9120
9176
  });
@@ -22,3 +22,11 @@ export declare function isOperating(messages: readonly unknown[], ownTools: Read
22
22
  export declare function lowestEffort(efforts: readonly {
23
23
  id: string;
24
24
  }[] | undefined): string | undefined;
25
+ /**
26
+ * Without deliberation the model now and then writes a tool call whose
27
+ * arguments are not valid JSON, which the adapter raises as
28
+ * MALFORMED_RESPONSE and which would end the turn. Such a reply is thrown
29
+ * away and asked for again. The reply is held back until it is complete, as
30
+ * events already passed on could not be taken back.
31
+ */
32
+ export declare function retryMalformed<T>(run: () => AsyncIterable<T>, attempts?: number): AsyncGenerator<T>;
@@ -51,6 +51,8 @@ export declare class OverlayController {
51
51
  private agent;
52
52
  private visible;
53
53
  private idleTimer;
54
+ private unusedTimer;
55
+ private otherTools;
54
56
  private hostWindows;
55
57
  private stopping;
56
58
  /** Progress card lines: the reply as it streams, and what the agent is doing. */
@@ -100,6 +102,8 @@ export declare class OverlayController {
100
102
  /** Agent finished (idle), was cancelled, or the plugin is stopping. */
101
103
  end(agent?: CancellableAgent): Promise<void>;
102
104
  private stop;
105
+ /** Counted from the last computer action only: model output and other tools do not keep the overlay up. */
106
+ private armUnused;
103
107
  private armIdle;
104
108
  /** Card: shrink the DSH window to an always-on-top corner card; minimize: get it out of the way. */
105
109
  private shrinkHost;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@copylee/dsh-computer-use",
3
- "version": "0.7.2",
3
+ "version": "0.7.4",
4
4
  "description": "DeepSeek Harness Computer Use 插件(Windows):让 AI 看屏幕、点鼠标、敲键盘操控电脑;控制时屏幕泛起橙色光晕并显示“DeepSeek Harness 正在操控你的电脑”,按 Esc 暂停 / 继续。",
5
5
  "type": "module",
6
6
  "author": "copylee",