@copylee/dsh-computer-use 0.11.0 → 0.12.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/lib/index.js CHANGED
@@ -1548,6 +1548,31 @@ var Computer = class Computer {
1548
1548
  await setTimeout$1(POLL_MS, void 0, { signal });
1549
1549
  }
1550
1550
  }
1551
+ /** Drain buffered physical user actions and format them in screenshot coordinates for the model. */
1552
+ async drainUserActionNotes() {
1553
+ if (!this.settings().reportUserActions) return "";
1554
+ return this.formatUserActions(this.overlay.drainUserActions?.() ?? []);
1555
+ }
1556
+ /** Format physical user takeover actions into concise screenshot-coordinate context for the model. */
1557
+ async formatUserActions(actions) {
1558
+ if (actions.length === 0) return "";
1559
+ const lines = [];
1560
+ for (const [index, a] of actions.entries()) {
1561
+ const coord = a.x !== void 0 && a.y !== void 0 ? await this.toModel({
1562
+ x: a.x,
1563
+ y: a.y
1564
+ }).then((p) => ` at (${p.x}, ${p.y})${p.offscreen ? " (other display)" : ""}`).catch(() => "") : "";
1565
+ const win = a.exe ? ` in ${a.exe}${a.title ? ` ("${a.title.slice(0, 50)}")` : ""}` : "";
1566
+ const target = a.password ? "PasswordField" : a.role && a.name ? `${a.role} "${a.name}"` : a.name ? `"${a.name}"` : a.role ?? "";
1567
+ let desc;
1568
+ if (a.kind === "double_click") desc = `Double-clicked${target ? ` ${target}` : ""}${coord}${win}`;
1569
+ else if (a.kind === "click") desc = `${a.button === "right" ? "Right-clicked" : a.button === "middle" ? "Middle-clicked" : "Left-clicked"}${target ? ` ${target}` : ""}${coord}${win}`;
1570
+ else if (a.kind === "scroll") desc = `Scrolled ${a.direction ?? "down"}${coord}${win}`;
1571
+ else desc = `Typed${a.keys && a.keys > 1 ? ` (${a.keys} keys)` : ""}${target ? ` into ${target}` : ""}${win}`;
1572
+ lines.push(`${index + 1}. ${desc}`);
1573
+ }
1574
+ return `\nRecent user actions during takeover (screenshot coordinates):\n${lines.join("\n")}\nRespect what the user just did and adapt your plan accordingly (do not undo or overwrite their changes).`;
1575
+ }
1551
1576
  /** Run one action. Returns text plus an image for screenshot/zoom. */
1552
1577
  async run(input, call) {
1553
1578
  if (call.signal.aborted) throw new Error("Cancelled.");
@@ -1557,8 +1582,20 @@ var Computer = class Computer {
1557
1582
  const wasPaused = this.overlay.paused;
1558
1583
  if (await this.overlay.yieldToUser(call.signal, s.pauseOnUserInput && INPUT.has(action)) && INPUT.has(action)) {
1559
1584
  await this.overlay.begin(call.agent, Computer.statusOf(input));
1585
+ const drained = s.reportUserActions ? this.overlay.drainUserActions?.() ?? [] : [];
1586
+ const userNotes = await this.formatUserActions(drained);
1587
+ return {
1588
+ text: `Not done: ${wasPaused ? "the user paused computer use (Esc) and has now resumed" : drained.some((a) => a.kind === "click" || a.kind === "double_click" || a.kind === "scroll") ? "the user took over with mouse/keyboard, so you waited until they finished" : "the user was typing on the keyboard, so you were paused until they stopped"}. ${action} was NOT performed.${userNotes}\nLook at the new screenshot and re-plan before acting.`,
1589
+ ...call.vision ? { image: await this.screenshot() } : {},
1590
+ skipped: true
1591
+ };
1592
+ }
1593
+ if (s.pauseOnUserInput && s.reportUserActions && INPUT.has(action) && this.overlay.hasUserActions?.()) {
1594
+ const drained = this.overlay.drainUserActions?.() ?? [];
1595
+ const userNotes = await this.formatUserActions(drained);
1596
+ await this.overlay.status("检测到你刚操作了桌面,同步给 AI");
1560
1597
  return {
1561
- text: `Not done: ${wasPaused ? "the user paused computer use (Esc) and has now resumed" : "the user was typing on the keyboard, so you were paused until they stopped"}. ${action} was NOT performed. Look at the new screenshot and re-plan before acting.`,
1598
+ text: `Not done: the user intervened on the desktop before this step. ${action} was NOT performed.${userNotes}\nLook at the new screenshot and re-plan before acting.`,
1562
1599
  ...call.vision ? { image: await this.screenshot() } : {},
1563
1600
  skipped: true
1564
1601
  };
@@ -1567,10 +1604,12 @@ var Computer = class Computer {
1567
1604
  const changed = await this.foregroundChanged();
1568
1605
  if (changed && !isHostWindow(changed) && !isTransientShell(changed)) {
1569
1606
  await this.overlay.status("检测到窗口切换,重新查看屏幕");
1607
+ const drained = s.reportUserActions ? this.overlay.drainUserActions?.() ?? [] : [];
1608
+ const userNotes = await this.formatUserActions(drained);
1570
1609
  const image = call.vision ? await this.screenshot() : void 0;
1571
1610
  if (!image) this.seen = changed;
1572
1611
  return {
1573
- text: `Not done: since your last look the foreground window changed to ${changed.exe} ("${changed.title.slice(0, 60)}") without you acting, most likely the user opened it. ${action} was NOT performed. Look at the new screenshot and decide whether to continue there, switch back, or ask the user.`,
1612
+ text: `Not done: since your last look the foreground window changed to ${changed.exe} ("${changed.title.slice(0, 60)}") without you acting, most likely the user opened it. ${action} was NOT performed.${userNotes}\nLook at the new screenshot and decide whether to continue there, switch back, or ask the user.`,
1574
1613
  ...image ? { image } : {},
1575
1614
  skipped: true
1576
1615
  };
@@ -1580,13 +1619,15 @@ var Computer = class Computer {
1580
1619
  if (KEYBOARD.has(action)) await this.refocusFromHost();
1581
1620
  switch (action) {
1582
1621
  case "screenshot": {
1622
+ const drained = s.reportUserActions ? this.overlay.drainUserActions?.() ?? [] : [];
1623
+ const userNotes = await this.formatUserActions(drained);
1583
1624
  const shot = await this.takeScreenshot({
1584
- force: input.force === true,
1625
+ force: input.force === true || drained.length > 0,
1585
1626
  ...input.detail ? { detail: input.detail } : {}
1586
1627
  });
1587
- if (shot === "unchanged") return { text: `Screenshot unchanged for display ${this.currentIndex}: the screen looks identical to your previous screenshot (pass force: true to capture anyway).` };
1628
+ if (shot === "unchanged") return { text: `Screenshot unchanged for display ${this.currentIndex}: the screen looks identical to your previous screenshot (pass force: true to capture anyway).${userNotes}` };
1588
1629
  return {
1589
- text: `Screenshot ${shot.width}x${shot.height} of display ${this.currentIndex}.`,
1630
+ text: `Screenshot ${shot.width}x${shot.height} of display ${this.currentIndex}.${userNotes}`,
1590
1631
  image: shot
1591
1632
  };
1592
1633
  }
@@ -1936,6 +1977,7 @@ function buildDiagnosticSnapshot(options) {
1936
1977
  defaultSessionEnabled: s.defaultSessionEnabled,
1937
1978
  overlay: s.overlay,
1938
1979
  hostWindow: s.hostWindow,
1980
+ petSize: s.petSize,
1939
1981
  cardOpacity: s.cardOpacity,
1940
1982
  typingMode: s.typingMode,
1941
1983
  quickSteps: s.quickSteps,
@@ -1946,6 +1988,7 @@ function buildDiagnosticSnapshot(options) {
1946
1988
  maxPixels: s.maxPixels,
1947
1989
  jpegQuality: s.jpegQuality,
1948
1990
  pauseOnUserInput: s.pauseOnUserInput,
1991
+ reportUserActions: s.reportUserActions,
1949
1992
  userIdleMs: s.userIdleMs,
1950
1993
  nativeHelper: s.nativeHelper,
1951
1994
  elementFirstClick: s.elementFirstClick,
@@ -2241,7 +2284,8 @@ var HelperClient = class HelperClient {
2241
2284
  for (const listener of this.listeners) try {
2242
2285
  listener({
2243
2286
  event: message.event,
2244
- ...message.reason === void 0 ? {} : { reason: message.reason }
2287
+ ...message.reason === void 0 ? {} : { reason: message.reason },
2288
+ ...message.data !== void 0 && message.data !== null && typeof message.data === "object" ? { data: message.data } : {}
2245
2289
  });
2246
2290
  } catch {}
2247
2291
  return;
@@ -2554,6 +2598,33 @@ var NativeHelper = class {
2554
2598
  * agent, and typing on the keyboard makes the agent wait. While controlling,
2555
2599
  * the DeepSeek Harness window can shrink into an always-on-top card.
2556
2600
  */
2601
+ const MAX_USER_ACTIONS = 20;
2602
+ function parseUserAction(raw) {
2603
+ const kind = raw.kind;
2604
+ if (kind !== "click" && kind !== "double_click" && kind !== "scroll" && kind !== "type") return void 0;
2605
+ const out = {
2606
+ at: Date.now(),
2607
+ kind
2608
+ };
2609
+ if (raw.button === "left" || raw.button === "right" || raw.button === "middle") out.button = raw.button;
2610
+ if (raw.direction === "up" || raw.direction === "down" || raw.direction === "left" || raw.direction === "right") out.direction = raw.direction;
2611
+ if (typeof raw.x === "number" && Number.isFinite(raw.x)) out.x = Math.round(raw.x);
2612
+ if (typeof raw.y === "number" && Number.isFinite(raw.y)) out.y = Math.round(raw.y);
2613
+ if (typeof raw.exe === "string" && raw.exe.trim() !== "") out.exe = raw.exe.trim();
2614
+ if (typeof raw.title === "string" && raw.title.trim() !== "") out.title = raw.title.trim().slice(0, 80);
2615
+ if (typeof raw.role === "string" && raw.role.trim() !== "") out.role = raw.role.trim();
2616
+ if (typeof raw.name === "string" && raw.name.trim() !== "") out.name = raw.name.trim().slice(0, 60);
2617
+ if (raw.password === true) out.password = true;
2618
+ if (typeof raw.keys === "number" && Number.isFinite(raw.keys)) out.keys = Math.max(1, Math.round(raw.keys));
2619
+ return out;
2620
+ }
2621
+ function userActionCardSummary(a) {
2622
+ const target = a.password ? "密码框" : a.name ? `「${a.name.slice(0, 16)}」` : a.role ? a.role : a.exe ?? "桌面";
2623
+ if (a.kind === "double_click") return `你双击了 ${target}`;
2624
+ if (a.kind === "click") return `你${a.button === "right" ? "右键" : a.button === "middle" ? "中键" : "点击"}了 ${target}`;
2625
+ if (a.kind === "scroll") return `你滚动了 ${a.exe ?? "页面"}`;
2626
+ return `你在 ${target} 输入了文字`;
2627
+ }
2557
2628
  /** Markdown reduced to one plain line for the progress card. */
2558
2629
  function plainLine(text) {
2559
2630
  return text.replace(/```[\s\S]*?(```|$)/g, " ").replace(/!\[[^\]]*\]\([^)]*\)/g, " ").replace(/\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/^\s{0,3}(#{1,6}|>|[-*+]|\d+[.)])\s+/gm, "").replace(/(\*\*|__|`|~~)/g, "").replace(/\s+/g, " ");
@@ -2639,10 +2710,12 @@ var OverlayController = class {
2639
2710
  cardOpacity = 100;
2640
2711
  /** Paused by Esc or the pill; actions wait until resumed. */
2641
2712
  paused = false;
2642
- /** When the user last typed on the physical keyboard while the overlay was up (ms epoch). */
2713
+ /** When the user last typed or clicked physically while the overlay was up (ms epoch). */
2643
2714
  lastUserInput = 0;
2644
- /** Which physical key that was (helper reason, e.g. "vk=0x41"), for the log. */
2715
+ /** Which physical key/action that was, for the log. */
2645
2716
  lastUserKey = "";
2717
+ /** Bounded sanitized ring buffer of physical user actions since the model last saw them. */
2718
+ userActions = [];
2646
2719
  constructor(helper, settings, log, iconPath = "") {
2647
2720
  this.helper = helper;
2648
2721
  this.settings = settings;
@@ -2655,6 +2728,13 @@ var OverlayController = class {
2655
2728
  else if (event.event === "user_input") {
2656
2729
  this.lastUserInput = Date.now();
2657
2730
  this.lastUserKey = event.reason ?? "";
2731
+ } else if (event.event === "user_action" && event.data) {
2732
+ const parsed = parseUserAction(event.data);
2733
+ if (!parsed) return;
2734
+ this.lastUserInput = parsed.at;
2735
+ this.lastUserKey = parsed.kind;
2736
+ this.recordUserAction(parsed);
2737
+ this.step(userActionCardSummary(parsed));
2658
2738
  } else if (event.event === "message" && event.reason) {
2659
2739
  const agent = this.agent;
2660
2740
  if (!agent) return;
@@ -2663,6 +2743,31 @@ var OverlayController = class {
2663
2743
  }
2664
2744
  });
2665
2745
  }
2746
+ recordUserAction(action) {
2747
+ const prev = this.userActions.at(-1);
2748
+ if (action.kind === "type" && prev?.kind === "type" && prev.exe === action.exe && prev.role === action.role && prev.name === action.name && action.at - prev.at < 8e3) {
2749
+ prev.keys = (prev.keys ?? 1) + (action.keys ?? 1);
2750
+ prev.at = action.at;
2751
+ return;
2752
+ }
2753
+ if (action.kind === "double_click" && prev?.kind === "click" && prev.button === "left" && action.at - prev.at <= 700 && prev.x !== void 0 && action.x !== void 0 && Math.abs(prev.x - action.x) <= 8 && prev.y !== void 0 && action.y !== void 0 && Math.abs(prev.y - action.y) <= 8) {
2754
+ this.userActions[this.userActions.length - 1] = action;
2755
+ return;
2756
+ }
2757
+ this.userActions.push(action);
2758
+ if (this.userActions.length > MAX_USER_ACTIONS) this.userActions.shift();
2759
+ }
2760
+ /** Whether the user has performed physical mouse/keyboard actions not yet reported to the model. */
2761
+ hasUserActions() {
2762
+ return this.userActions.length > 0;
2763
+ }
2764
+ /** Return and clear buffered user takeover actions so the model receives them once. */
2765
+ drainUserActions() {
2766
+ if (this.userActions.length === 0) return [];
2767
+ const items = this.userActions;
2768
+ this.userActions = [];
2769
+ return items;
2770
+ }
2666
2771
  /** The agent currently driving the computer, if any. */
2667
2772
  get controller() {
2668
2773
  return this.agent;
@@ -2699,6 +2804,7 @@ var OverlayController = class {
2699
2804
  if (!this.visible) {
2700
2805
  this.visible = true;
2701
2806
  this.paused = false;
2807
+ this.userActions = [];
2702
2808
  this.starting = this.start(agent, status, settings);
2703
2809
  try {
2704
2810
  await this.starting;
@@ -2747,6 +2853,7 @@ var OverlayController = class {
2747
2853
  idleMs: settings.userIdleMs,
2748
2854
  glow: settings.overlay,
2749
2855
  pet,
2856
+ petSize: settings.petSize,
2750
2857
  petOpacity: settings.cardOpacity,
2751
2858
  thinking: this.thinking
2752
2859
  }).catch((error) => this.log(`overlay: ${String(error)}`));
@@ -3052,7 +3159,7 @@ ${mode === "per-app" ? "- Before acting on an app, call request_access once with
3052
3159
  - 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.
3053
3160
  - 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.
3054
3161
  - 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.
3055
- - The user sees an orange border and can press Esc to pause you at any time. If they pause, type on the keyboard or switch windows, you wait; when an action reports it was not performed, re-check the screen instead of repeating it blindly.`;
3162
+ - The user sees an orange border and can press Esc to pause you at any time, or intervene directly with mouse clicks, scrolling, or typing. When an action reports the user intervened (along with a list of recent user actions such as which button/tab they clicked and where), inspect the new screenshot, respect their intent, and adapt your plan instead of undoing or repeating over what they just did.`;
3056
3163
  }
3057
3164
  //#endregion
3058
3165
  //#region lib/types/skills.js
@@ -3267,6 +3374,7 @@ const DEFAULTS = {
3267
3374
  overlay: true,
3268
3375
  overlayLabel: "DeepSeek Harness",
3269
3376
  hostWindow: "pet",
3377
+ petSize: "standard",
3270
3378
  cardOpacity: 80,
3271
3379
  autoScreenshot: true,
3272
3380
  autoScreenshotDetail: "standard",
@@ -3276,6 +3384,7 @@ const DEFAULTS = {
3276
3384
  jpegQuality: 70,
3277
3385
  blockedApps: [],
3278
3386
  pauseOnUserInput: true,
3387
+ reportUserActions: true,
3279
3388
  userIdleMs: 1500,
3280
3389
  typingMode: "stream",
3281
3390
  quickSteps: false,
@@ -3304,6 +3413,7 @@ function resolveConfig(raw) {
3304
3413
  overlay: bool("overlay"),
3305
3414
  overlayLabel: typeof out.overlayLabel === "string" && out.overlayLabel.trim() !== "" ? out.overlayLabel.trim().slice(0, 40) : DEFAULTS.overlayLabel,
3306
3415
  hostWindow: out.hostWindow === "pet" || out.hostWindow === "card" || out.hostWindow === "minimize" || out.hostWindow === "keep" ? out.hostWindow : out.minimizeHostWindow === true ? "minimize" : DEFAULTS.hostWindow,
3416
+ petSize: out.petSize === "compact" || out.petSize === "standard" || out.petSize === "detailed" ? out.petSize : DEFAULTS.petSize,
3307
3417
  cardOpacity: num("cardOpacity", 30, 100),
3308
3418
  autoScreenshot: bool("autoScreenshot"),
3309
3419
  autoScreenshotDetail: out.autoScreenshotDetail === "compact" || out.autoScreenshotDetail === "standard" ? out.autoScreenshotDetail : DEFAULTS.autoScreenshotDetail,
@@ -3312,6 +3422,7 @@ function resolveConfig(raw) {
3312
3422
  maxPixels: num("maxPixels", 3e5, 8e6),
3313
3423
  jpegQuality: num("jpegQuality", 30, 100),
3314
3424
  pauseOnUserInput: bool("pauseOnUserInput"),
3425
+ reportUserActions: bool("reportUserActions"),
3315
3426
  userIdleMs: num("userIdleMs", 300, 1e4),
3316
3427
  quickSteps: bool("quickSteps"),
3317
3428
  nativeHelper: bool("nativeHelper"),
@@ -3542,6 +3653,7 @@ function previewRoute(helper, settings, overlay, iconPath) {
3542
3653
  idleMs: s.userIdleMs,
3543
3654
  glow: s.overlay,
3544
3655
  pet,
3656
+ petSize: s.petSize,
3545
3657
  petOpacity: s.cardOpacity
3546
3658
  });
3547
3659
  if (pet) await helper.call("pet_update", {
@@ -10203,13 +10315,15 @@ function createTools(host) {
10203
10315
  zoomed = outcome.image;
10204
10316
  }
10205
10317
  if (outcome.skipped) {
10206
- failure = `#${index + 1} ${input.action} skipped: the user was typing on the keyboard. Re-check the screen before continuing.`;
10318
+ failure = `#${index + 1} ${input.action} skipped: ${outcome.text}`;
10207
10319
  break;
10208
10320
  }
10209
10321
  lines.push(`#${index + 1} ${outcome.text}`);
10210
10322
  await setTimeout$1(60, void 0, { signal: call.signal });
10211
- if (computer.settings().pauseOnUserInput && computer.overlay.userTypedSince(stepStart - 1)) {
10212
- failure = `#${index + 1} done, but the user typed on the keyboard meanwhile; remaining actions stopped. Re-check the screen before continuing.`;
10323
+ if (computer.settings().pauseOnUserInput && (computer.overlay.userTypedSince(stepStart - 1) || computer.overlay.hasUserActions?.())) {
10324
+ const notes = await computer.drainUserActionNotes();
10325
+ const kind = notes ? "intervened with mouse/keyboard" : "typed on the keyboard";
10326
+ failure = `#${index + 1} done, but the user ${kind} meanwhile; remaining actions stopped.${notes} Re-check the screen before continuing.`;
10213
10327
  break;
10214
10328
  }
10215
10329
  } catch (error) {
@@ -10885,6 +10999,23 @@ const Config = z.object({
10885
10999
  "zh-CN": { $description: "操控期间 DeepSeek Harness 窗口怎么摆放(结束后自动恢复原尺寸和位置)" },
10886
11000
  "en-US": { $description: "What to do with the DeepSeek Harness window while controlling (restored afterwards)" }
10887
11001
  }),
11002
+ petSize: z.union([
11003
+ z.const("compact").i18n({
11004
+ "zh-CN": { $description: "紧凑小卡片(最省视野,单行当前操作)" },
11005
+ "en-US": { $description: "Compact (minimal footprint, current action line only)" }
11006
+ }),
11007
+ z.const("standard").i18n({
11008
+ "zh-CN": { $description: "标准卡片(单行思考 + 操作进度,推荐)" },
11009
+ "en-US": { $description: "Standard (one-line thinking + action breadcrumb, recommended)" }
11010
+ }),
11011
+ z.const("detailed").i18n({
11012
+ "zh-CN": { $description: "详情大卡片(双行思考 + 最近 3 步时间线)" },
11013
+ "en-US": { $description: "Detailed (two-line thinking + recent 3-step timeline)" }
11014
+ })
11015
+ ]).default("standard").volatile().i18n({
11016
+ "zh-CN": { $description: "迷你进度卡片尺寸与默认展示的信息量" },
11017
+ "en-US": { $description: "Size and default information density of the mini progress card" }
11018
+ }),
10888
11019
  cardOpacity: z.natural().min(30).max(100).default(80).volatile().i18n({
10889
11020
  "zh-CN": { $description: "悬浮卡片不透明度(%):调低可透过卡片看清下面的操作过程;鼠标停在卡片上时变为不透明" },
10890
11021
  "en-US": { $description: "Card opacity (%): lower lets you watch the work underneath; it turns opaque while the pointer rests on it" }
@@ -10941,8 +11072,12 @@ const Config = z.object({
10941
11072
  "en-US": { $description: "Screenshot JPEG quality" }
10942
11073
  }),
10943
11074
  pauseOnUserInput: z.boolean().default(true).volatile().i18n({
10944
- "zh-CN": { $description: "检测到你在操作时让出控制:你用键盘打字时暂停、停手后继续;你切换或打开了新窗口时,AI 重新看屏幕再决定(鼠标移动不会触发)" },
10945
- "en-US": { $description: "Yield to you: pause while you type, and re-check the screen when you bring up another window (mouse movement is ignored)" }
11075
+ "zh-CN": { $description: "检测到你在操作时让出控制:你用键盘打字或点击鼠标/滚轮时暂停、停手后继续;你切换或打开了新窗口时,AI 重新看屏幕再决定(纯鼠标移动不会触发)" },
11076
+ "en-US": { $description: "Yield to you: pause while you type or click/scroll physically, and re-check the screen when you switch windows (pure mouse movement is ignored)" }
11077
+ }),
11078
+ reportUserActions: z.boolean().default(true).volatile().i18n({
11079
+ "zh-CN": { $description: "将你接管期间的脱敏操作摘要(点击了哪个窗口的哪个控件与坐标、滚动或按键输入,绝不记录输入明文与密码)反馈给模型,帮助它理解你的意图" },
11080
+ "en-US": { $description: "Report sanitized summaries of your physical clicks/scrolls/typing (window, control name & screenshot coords; never typed text or passwords) back to the model so it understands your intent" }
10946
11081
  }),
10947
11082
  userIdleMs: z.natural().min(300).max(1e4).default(1500).volatile().i18n({
10948
11083
  "zh-CN": { $description: "键盘停止多少毫秒后恢复操作" },
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  /** Menu appearance and fixed-position behavior follow dsh-free-search / dsh-proxy. */
3
- export declare const selectCss = "\n.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,.3));border-radius:var(--dsw-radius-md,8px);background:var(--dsw-alias-bg-layer-3,transparent);color:inherit;font:inherit;font-size:13px;cursor:pointer}\n.dshcu-select:hover{border-color:var(--dsw-alias-border-l3,#888)}\n.dshcu-select:focus-visible,.dshcu-select[aria-expanded=true]{outline:2px solid var(--cl-accent,#D97757);outline-offset:2px}\n.dshcu-select:disabled{opacity:.5;cursor:default}\n.dshcu-menu{position:fixed;z-index:1100;box-sizing:border-box;padding:4px;overflow-y:auto;overscroll-behavior:contain;border-radius:var(--dsw-radius-lg,12px);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 10px 32px rgba(0,0,0,.16),0 0 0 .5px rgba(0,0,0,.1))}\n.dshcu-option{display:flex;align-items:center;gap:8px;min-height:34px;padding:6px 8px;box-sizing:border-box;border-radius:var(--dsw-radius-md,8px);font-size:13px;line-height:20px;cursor:pointer;user-select:none}\n.dshcu-option[data-active=true]{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.12))}\n";
3
+ export declare const selectCss = "\n@keyframes dshcu-menu-in{from{opacity:0;transform:translateY(-4px) scale(.985)}to{opacity:1;transform:translateY(0) scale(1)}}\n.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}\n.dshcu-select:hover:not(:disabled){border-color:color-mix(in srgb,var(--cl-accent,#D97757) 55%,var(--dsw-alias-border-l3,#888));background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.05))}\n.dshcu-select:focus-visible,.dshcu-select[aria-expanded=true]{outline:none;border-color:var(--cl-accent,#D97757);box-shadow:0 0 0 3px color-mix(in srgb,var(--cl-accent,#D97757) 20%,transparent)}\n.dshcu-select:disabled{opacity:.48;cursor:default}\n.dshcu-select svg{flex:none;transition:transform .2s cubic-bezier(.22,1,.36,1)}\n.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)}\n.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}\n.dshcu-option[data-active=true]{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.11))}\n.dshcu-option[aria-selected=true]{font-weight:500;color:var(--cl-accent,#D97757)}\n";
4
4
  export declare function Select<V extends string>({ options, value, disabled, label, onChange }: {
5
5
  options: {
6
6
  value: V;
@@ -3,7 +3,7 @@ import { type BrowserTab } from './browser-host.js';
3
3
  import { type Display, type Point, type ScreenshotDetail, type Size } from './coords.js';
4
4
  import type { HelperLike } from './helper-client.js';
5
5
  import { type UiElement } from './target.js';
6
- import type { CancellableAgent, HostWindowMode, OverlayController } from './overlay.js';
6
+ import type { CancellableAgent, HostWindowMode, OverlayController, PetCardSize } from './overlay.js';
7
7
  export type AutoScreenshotDetail = 'standard' | 'compact';
8
8
  export type SessionMode = 'off' | 'on' | 'always';
9
9
  export interface Settings {
@@ -18,6 +18,8 @@ export interface Settings {
18
18
  overlay: boolean;
19
19
  overlayLabel: string;
20
20
  hostWindow: HostWindowMode;
21
+ /** Size tier for the mini progress card: compact, standard, or detailed. */
22
+ petSize: PetCardSize;
21
23
  /** Card opacity in percent while controlling (it turns opaque when the pointer rests on it). */
22
24
  cardOpacity: number;
23
25
  maxLongEdge: number;
@@ -27,8 +29,10 @@ export interface Settings {
27
29
  /** Detail tier for automatic post-action screenshots: standard or compact (smaller/cheaper). */
28
30
  autoScreenshotDetail: AutoScreenshotDetail;
29
31
  settleMs: number;
30
- /** Pause while the user types on the physical keyboard. */
32
+ /** Pause while the user types or clicks physically. */
31
33
  pauseOnUserInput: boolean;
34
+ /** Feed sanitized summaries of user physical clicks/scrolls/typing back to the model when the user intervenes. */
35
+ reportUserActions: boolean;
32
36
  /** How long the keyboard must be quiet before resuming. */
33
37
  userIdleMs: number;
34
38
  /** How text is entered: stream = paste block by block, type = key by key, paste = at once. */
@@ -280,6 +284,10 @@ export declare class Computer {
280
284
  private namedClickPoint;
281
285
  /** wait with `until`: done as soon as the window or control is there (or gone). */
282
286
  private waitUntil;
287
+ /** Drain buffered physical user actions and format them in screenshot coordinates for the model. */
288
+ drainUserActionNotes(): Promise<string>;
289
+ /** Format physical user takeover actions into concise screenshot-coordinate context for the model. */
290
+ private formatUserActions;
283
291
  /** Run one action. Returns text plus an image for screenshot/zoom. */
284
292
  run(input: ActionInput, call: CallContext): Promise<ActionOutcome>;
285
293
  /**
@@ -33,6 +33,7 @@ export interface DiagnosticSnapshot {
33
33
  defaultSessionEnabled: boolean;
34
34
  overlay: boolean;
35
35
  hostWindow: Settings['hostWindow'];
36
+ petSize: Settings['petSize'];
36
37
  cardOpacity: number;
37
38
  typingMode: Settings['typingMode'];
38
39
  quickSteps: boolean;
@@ -43,6 +44,7 @@ export interface DiagnosticSnapshot {
43
44
  maxPixels: number;
44
45
  jpegQuality: number;
45
46
  pauseOnUserInput: boolean;
47
+ reportUserActions: boolean;
46
48
  userIdleMs: number;
47
49
  nativeHelper: boolean;
48
50
  elementFirstClick: boolean;
@@ -1,6 +1,7 @@
1
1
  export interface HelperEvent {
2
2
  event: string;
3
3
  reason?: string;
4
+ data?: Record<string, unknown>;
4
5
  }
5
6
  export interface HelperLike {
6
7
  call<T = unknown>(cmd: string, args?: Record<string, unknown>, timeoutMs?: number): Promise<T>;
@@ -2,7 +2,7 @@ import type { Context } from '@deepseek-ai/cordis';
2
2
  import z from '@deepseek-ai/schemastery';
3
3
  import { type AccessMode } from './access.js';
4
4
  import { type AutoScreenshotDetail, type SessionMode, type TypingMode } from './computer.js';
5
- import { type HostWindowMode } from './overlay.js';
5
+ import { type HostWindowMode, type PetCardSize } from './overlay.js';
6
6
  /** Parse `/cu [on|off|toggle|status|reset|stop|revoke <app>]` arguments into an action. */
7
7
  export declare function parseCuCommand(rawInput: string): 'on' | 'off' | 'toggle' | 'status' | 'reset' | 'stop' | 'revoke' | 'invalid';
8
8
  /** Extract the app name argument after `/cu revoke ...` (empty means all granted apps). */
@@ -19,6 +19,7 @@ export interface Config {
19
19
  overlay?: boolean;
20
20
  overlayLabel?: string;
21
21
  hostWindow?: HostWindowMode;
22
+ petSize?: PetCardSize;
22
23
  cardOpacity?: number;
23
24
  /** @deprecated replaced by hostWindow: 'minimize' */
24
25
  minimizeHostWindow?: boolean;
@@ -30,6 +31,7 @@ export interface Config {
30
31
  jpegQuality?: number;
31
32
  blockedApps?: string[];
32
33
  pauseOnUserInput?: boolean;
34
+ reportUserActions?: boolean;
33
35
  userIdleMs?: number;
34
36
  typingMode?: TypingMode;
35
37
  quickSteps?: boolean;
@@ -5,6 +5,22 @@ export interface CancellableAgent {
5
5
  }): void;
6
6
  }
7
7
  export type HostWindowMode = 'pet' | 'card' | 'minimize' | 'keep';
8
+ export type PetCardSize = 'compact' | 'standard' | 'detailed';
9
+ /** Sanitized semantic summary of a physical user takeover action during computer control. */
10
+ export interface UserActionEvent {
11
+ at: number;
12
+ kind: 'click' | 'double_click' | 'scroll' | 'type';
13
+ button?: 'left' | 'right' | 'middle';
14
+ direction?: 'up' | 'down' | 'left' | 'right';
15
+ x?: number;
16
+ y?: number;
17
+ exe?: string;
18
+ title?: string;
19
+ role?: string;
20
+ name?: string;
21
+ password?: boolean;
22
+ keys?: number;
23
+ }
8
24
  /** The slice of a DSH assistant-stream frame the progress card reads. */
9
25
  export interface StreamFrame {
10
26
  type: string;
@@ -21,6 +37,7 @@ export interface OverlaySettings {
21
37
  overlay: boolean;
22
38
  overlayLabel: string;
23
39
  hostWindow: HostWindowMode;
40
+ petSize: PetCardSize;
24
41
  cardOpacity: number;
25
42
  userIdleMs: number;
26
43
  }
@@ -89,13 +106,20 @@ export declare class OverlayController {
89
106
  private cardOpacity;
90
107
  /** Paused by Esc or the pill; actions wait until resumed. */
91
108
  paused: boolean;
92
- /** When the user last typed on the physical keyboard while the overlay was up (ms epoch). */
109
+ /** When the user last typed or clicked physically while the overlay was up (ms epoch). */
93
110
  lastUserInput: number;
94
- /** Which physical key that was (helper reason, e.g. "vk=0x41"), for the log. */
111
+ /** Which physical key/action that was, for the log. */
95
112
  private lastUserKey;
113
+ /** Bounded sanitized ring buffer of physical user actions since the model last saw them. */
114
+ private userActions;
96
115
  constructor(helper: HelperLike, settings: () => OverlaySettings, log: (message: string) => void,
97
116
  /** Absolute path of the pill icon (PNG). */
98
117
  iconPath?: string);
118
+ private recordUserAction;
119
+ /** Whether the user has performed physical mouse/keyboard actions not yet reported to the model. */
120
+ hasUserActions(): boolean;
121
+ /** Return and clear buffered user takeover actions so the model receives them once. */
122
+ drainUserActions(): UserActionEvent[];
99
123
  /** The agent currently driving the computer, if any. */
100
124
  get controller(): CancellableAgent | undefined;
101
125
  /** Did the user type after `since`? */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@copylee/dsh-computer-use",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "DeepSeek Harness Computer Use 插件(Windows):让 AI 看屏幕、点鼠标、敲键盘操控电脑;控制时屏幕泛起橙色光晕并显示“DeepSeek Harness 正在操控你的电脑”,按 Esc 暂停 / 继续。",
5
5
  "icon": "assets/icon.svg",
6
6
  "type": "module",