@copylee/dsh-computer-use 0.13.1 → 0.14.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.
@@ -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. */
@@ -227,8 +234,11 @@ export declare class Computer {
227
234
  * in front instead of refusing.
228
235
  */
229
236
  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>;
237
+ /** Wait at most `maxMs`, returning once the screen has been still for ~0.8 s or the user clicks "跳过等待". */
238
+ waitForQuiet(maxMs: number, signal: AbortSignal, wait?: WaitHandle): Promise<{
239
+ ms: number;
240
+ skipped: boolean;
241
+ }>;
232
242
  /** Wait until the screen stops changing (bounded), instead of a fixed delay. */
233
243
  settle(signal: AbortSignal): Promise<void>;
234
244
  windowAt(point: Point): Promise<WindowInfo | undefined>;
@@ -272,10 +282,21 @@ export declare class Computer {
272
282
  elements: UiElement[];
273
283
  shot: Shot;
274
284
  }>;
285
+ /** Targeted C#-side UIA lookup; returns undefined if helper does not support `ui_find`. */
286
+ findElements(options: {
287
+ hwnd?: number;
288
+ automationId?: string;
289
+ role?: string;
290
+ name?: string;
291
+ query?: string;
292
+ maxMatches?: number;
293
+ }): Promise<(Partial<WindowInfo> & {
294
+ elements: UiElement[];
295
+ }) | undefined>;
275
296
  /**
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.
297
+ * Look for a named control via fast C#-side targeted UIA query when possible,
298
+ * then full window UIA, then popups, and finally built-in Windows OCR when
299
+ * the UIA tree is empty or sparse (<= 20 controls).
279
300
  */
280
301
  private find;
281
302
  /**
@@ -294,7 +315,7 @@ export declare class Computer {
294
315
  private checkNamedPoint;
295
316
  private semanticAction;
296
317
  private namedClickPoint;
297
- /** wait with `until`: done as soon as the window or control is there (or gone). */
318
+ /** wait with `until`: done as soon as the window or control is there (or gone), or the user clicks "跳过等待". */
298
319
  private waitUntil;
299
320
  /** Drain buffered physical user actions and format them in screenshot coordinates for the model. */
300
321
  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.0",
4
4
  "description": "DeepSeek Harness Computer Use 插件(Windows):让 AI 看屏幕、点鼠标、敲键盘操控电脑;控制时屏幕泛起橙色光晕并显示“DeepSeek Harness 正在操控你的电脑”,按 Esc 暂停 / 继续。",
5
5
  "icon": "assets/icon.svg",
6
6
  "type": "module",