@copylee/dsh-computer-use 0.13.1 → 0.14.1

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.
@@ -5,7 +5,7 @@ import type { HelperLike } from './helper-client.js';
5
5
  import { DesktopLease } from './lease.js';
6
6
  import { type UiElement } from './target.js';
7
7
  import { UiDiffTracker } from './ui-diff.js';
8
- import type { CancellableAgent, HostWindowMode, OverlayController, PetCardSize } from './overlay.js';
8
+ import { type CancellableAgent, type HostWindowMode, type OverlayController, type PetCardSize, type WaitHandle } from './overlay.js';
9
9
  export type AutoScreenshotDetail = 'standard' | 'compact';
10
10
  export type SessionMode = 'off' | 'on' | 'always';
11
11
  export interface Settings {
@@ -85,8 +85,9 @@ export interface CallContext {
85
85
  /** The session never prompts for approval (full access / auto review): access requests are granted as they come. */
86
86
  autoApprove?: boolean;
87
87
  }
88
- 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"];
88
+ 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", "ui_action"];
89
89
  export type Action = typeof ACTIONS[number];
90
+ export type UiSemanticOperation = 'invoke' | 'focus' | 'set_checked' | 'expand' | 'collapse' | 'select' | 'set_value';
90
91
  export interface ActionInput {
91
92
  action: Action;
92
93
  coordinate?: number[];
@@ -99,6 +100,12 @@ export interface ActionInput {
99
100
  region?: number[];
100
101
  /** A control named by what it says, instead of a coordinate. */
101
102
  target?: string;
103
+ /** ui_action: deterministic UIA Control Pattern operation on `target`. */
104
+ operation?: UiSemanticOperation;
105
+ /** ui_action (set_checked): desired idempotent checked state (true/false). */
106
+ checked?: boolean;
107
+ /** ui_action (set_value): value to set directly via ValuePattern. */
108
+ value?: string;
102
109
  /** wait: what to wait for ("window:记事本", "target:保存"). */
103
110
  until?: string;
104
111
  /** wait: wait for it to disappear instead. */
@@ -157,7 +164,7 @@ export declare class Computer {
157
164
  private heldButton;
158
165
  /** Dimensions of the latest full-display screenshot shown to the model (keeps coordinate conversion exact across detail modes). */
159
166
  private lastShot;
160
- /** Recent click locations (fallback repeat counter when helper does not report repeat). */
167
+ /** Recent click locations (repeat counter + auto physical-click fallback if a UIA invoke had no effect). */
161
168
  private readonly clickHistory;
162
169
  /** The agent that last wrote the clipboard; when it goes idle the user's clipboard comes back. */
163
170
  clipboardAgent: CancellableAgent | undefined;
@@ -218,8 +225,10 @@ export declare class Computer {
218
225
  force?: boolean;
219
226
  detail?: ScreenshotDetail;
220
227
  }): Promise<Shot | 'unchanged'>;
221
- /** Record a physical click position and return how many times this spot (±24 px) was clicked in the last 2 minutes. */
228
+ /** Record a click position and return how many times this spot (±24 px) was clicked in the last 2 minutes. */
222
229
  private noteClick;
230
+ /** Whether this spot (±24 px) was already clicked via background UIA invoke recently (so a retry should use a real physical click). */
231
+ private hadRecentUiaClickAt;
223
232
  foreground(): Promise<WindowInfo | undefined>;
224
233
  /**
225
234
  * The user clicked into the DeepSeek Harness card (to read or scroll the
@@ -227,8 +236,13 @@ export declare class Computer {
227
236
  * in front instead of refusing.
228
237
  */
229
238
  private refocusFromHost;
230
- /** Wait at most `maxMs`, returning once the screen has been still for ~0.8 s. Returns the time waited. */
231
- waitForQuiet(maxMs: number, signal: AbortSignal): Promise<number>;
239
+ /** Wait at most `maxMs`, returning once the screen settles (for waits ≥ 4s, waits for a real visual update first and emits progress checkpoints if still changing so AI can act early or wait again). */
240
+ waitForQuiet(maxMs: number, signal: AbortSignal, wait?: WaitHandle): Promise<{
241
+ ms: number;
242
+ skipped: boolean;
243
+ changed?: boolean;
244
+ checkpoint?: boolean;
245
+ }>;
232
246
  /** Wait until the screen stops changing (bounded), instead of a fixed delay. */
233
247
  settle(signal: AbortSignal): Promise<void>;
234
248
  windowAt(point: Point): Promise<WindowInfo | undefined>;
@@ -272,10 +286,21 @@ export declare class Computer {
272
286
  elements: UiElement[];
273
287
  shot: Shot;
274
288
  }>;
289
+ /** Targeted C#-side UIA lookup; returns undefined if helper does not support `ui_find`. */
290
+ findElements(options: {
291
+ hwnd?: number;
292
+ automationId?: string;
293
+ role?: string;
294
+ name?: string;
295
+ query?: string;
296
+ maxMatches?: number;
297
+ }): Promise<(Partial<WindowInfo> & {
298
+ elements: UiElement[];
299
+ }) | undefined>;
275
300
  /**
276
- * Look for a named control in the window, then its popups, and when the UIA
277
- * tree is empty or sparse (<= 20 controls, e.g. canvas/WebView/game/custom
278
- * UIs), fall back to built-in Windows OCR so `target` still finds visible text.
301
+ * Look for a named control via fast C#-side targeted UIA query when possible,
302
+ * then full window UIA, then popups, and finally built-in Windows OCR when
303
+ * the UIA tree is empty or sparse (<= 20 controls).
279
304
  */
280
305
  private find;
281
306
  /**
@@ -294,7 +319,7 @@ export declare class Computer {
294
319
  private checkNamedPoint;
295
320
  private semanticAction;
296
321
  private namedClickPoint;
297
- /** wait with `until`: done as soon as the window or control is there (or gone). */
322
+ /** wait with `until`: done as soon as the window or control is there (or gone), or the user clicks "跳过等待". */
298
323
  private waitUntil;
299
324
  /** Drain buffered physical user actions and format them in screenshot coordinates for the model. */
300
325
  drainUserActionNotes(): Promise<string>;
@@ -73,6 +73,13 @@ export declare function cardRect(display: DisplayRow): {
73
73
  width: number;
74
74
  height: number;
75
75
  };
76
+ export declare const CONTROL_STOPPED_MESSAGE = "The user stopped computer control and returned to DeepSeek Harness. Do not perform further desktop actions unless the user asks again; summarize your progress and reply in DeepSeek Harness.";
77
+ export interface WaitHandle {
78
+ readonly signal: AbortSignal;
79
+ skipped(): boolean;
80
+ controlStopped(): boolean;
81
+ done(): void;
82
+ }
76
83
  export declare class OverlayController {
77
84
  private readonly helper;
78
85
  private readonly settings;
@@ -90,6 +97,9 @@ export declare class OverlayController {
90
97
  private workTab;
91
98
  private starting;
92
99
  private stopping;
100
+ private readonly waitSkippers;
101
+ private readonly stoppedAgents;
102
+ private controlAbort;
93
103
  /** Progress card lines: host-provided reasoning, brief mid-turn reply, and recent operations. */
94
104
  private streamAgent;
95
105
  private thinking;
@@ -116,6 +126,14 @@ export declare class OverlayController {
116
126
  constructor(helper: HelperLike, settings: () => OverlaySettings, log: (message: string) => void,
117
127
  /** Absolute path of the pill icon (PNG). */
118
128
  iconPath?: string);
129
+ /** Whether the user stopped computer control for this agent's current turn. */
130
+ isControlStopped(agent: unknown): boolean;
131
+ /** Clear the per-turn control-stopped guard once the agent finishes its turn. */
132
+ clearControlStopped(agent: unknown): void;
133
+ /** Wake any active `wait` action early when the user clicks "跳过等待". */
134
+ private skipActiveWaits;
135
+ /** Register an active wait so the Pet card / pill exposes the "跳过等待" button. */
136
+ beginWait(signal: AbortSignal): WaitHandle;
119
137
  private recordUserAction;
120
138
  /** Whether the user has performed physical mouse/keyboard actions not yet reported to the model. */
121
139
  hasUserActions(): boolean;
@@ -156,7 +174,13 @@ export declare class OverlayController {
156
174
  isWorkTab(tab: string): boolean;
157
175
  private rememberHost;
158
176
  private focusRememberedHost;
159
- private stop;
177
+ /**
178
+ * Stop computer control and hand focus back to DeepSeek Harness without
179
+ * cancelling the whole conversation turn. Any in-flight wait exits at once
180
+ * and subsequent desktop tool calls in this turn are refused cleanly until
181
+ * the agent finishes its turn (goes idle).
182
+ */
183
+ private stopControl;
160
184
  /** Counted from the last computer action only: model output and other tools do not keep the overlay up. */
161
185
  private armUnused;
162
186
  private armIdle;
@@ -1,3 +1,5 @@
1
1
  /** System-prompt guidance for driving the desktop. No `{{` sequences: the host interpolates them. */
2
2
  import type { AccessMode } from './access.js';
3
- export declare function promptText(mode: AccessMode): string;
3
+ export declare function promptText(mode: AccessMode, options?: {
4
+ hasOfficePlugin?: boolean;
5
+ }): string;
@@ -14,6 +14,8 @@ export interface ToolHost {
14
14
  skills?: SkillStore;
15
15
  /** Saved replayable action macros (optional: tests run without). */
16
16
  macros?: MacroStore;
17
+ /** True when the sibling `@copylee/dsh-office` COM plugin is active in DSH. */
18
+ hasOfficePlugin?: () => boolean;
17
19
  }
18
20
  export declare function createTools(host: ToolHost): ToolDefinition[];
19
21
  export {};
@@ -1,13 +1,20 @@
1
1
  /**
2
2
  * Incremental UI Automation tree diffing: caches the previous element snapshot
3
- * per window HWND so repeated `ui_elements({ diff: true })` inspections send
4
- * only added, changed, and removed controls — saving 70-90% tokens on long tasks.
3
+ * scoped by (sessionId, hwnd, pid, queryProfile) so concurrent sessions or
4
+ * differing query parameters never cross-contaminate diffs, and prefers UIA
5
+ * runtimeId for stable element identity — saving 70-94% tokens on long tasks.
5
6
  */
6
7
  import type { UiElement } from './target.js';
7
8
  export interface UiElementChange {
8
9
  element: UiElement;
9
10
  changes: string[];
10
11
  }
12
+ export interface UiDiffScope {
13
+ sessionId: string;
14
+ hwnd: number;
15
+ pid?: number | undefined;
16
+ queryProfile?: string | undefined;
17
+ }
11
18
  export interface UiDiffResult {
12
19
  isBaseline: boolean;
13
20
  titleChanged: boolean;
@@ -19,10 +26,12 @@ export interface UiDiffResult {
19
26
  }
20
27
  export declare class UiDiffTracker {
21
28
  private readonly snapshots;
22
- /** Record a full snapshot as the latest baseline for `hwnd` without computing a diff. */
23
- record(hwnd: number, title: string, elements: readonly UiElement[]): void;
24
- /** Compute the incremental delta against the last snapshot of `hwnd`, updating the stored baseline. */
25
- diff(hwnd: number, title: string, elements: readonly UiElement[]): UiDiffResult;
29
+ /** Record a full snapshot as the latest baseline for `scope` without computing a diff. */
30
+ record(scope: UiDiffScope | number, title: string, elements: readonly UiElement[]): void;
31
+ /** Compute the incremental delta against the last snapshot of `scope`, updating the stored baseline. */
32
+ diff(scope: UiDiffScope | number, title: string, elements: readonly UiElement[]): UiDiffResult;
33
+ /** Remove cached snapshots for a disposed session so memory stays bounded. */
34
+ clearSession(sessionId: string): void;
26
35
  clear(hwnd?: number): void;
27
36
  private store;
28
37
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@copylee/dsh-computer-use",
3
- "version": "0.13.1",
3
+ "version": "0.14.1",
4
4
  "description": "DeepSeek Harness Computer Use 插件(Windows):让 AI 看屏幕、点鼠标、敲键盘操控电脑;控制时屏幕泛起橙色光晕并显示“DeepSeek Harness 正在操控你的电脑”,按 Esc 暂停 / 继续。",
5
5
  "icon": "assets/icon.svg",
6
6
  "type": "module",