@copylee/dsh-computer-use 0.8.1 → 0.8.3

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.
@@ -0,0 +1,19 @@
1
+ import type { HelperLike } from './helper-client.js';
2
+ import type { Rect } from './coords.js';
3
+ interface BrowserWindow {
4
+ hwnd: number;
5
+ pid: number;
6
+ exe: string;
7
+ }
8
+ export interface BrowserTab {
9
+ url?: string;
10
+ tab?: string;
11
+ content?: Rect;
12
+ contentFocused?: boolean;
13
+ }
14
+ export declare function isBrowser(win: BrowserWindow): boolean;
15
+ export declare function httpOrigin(value: string): string | undefined;
16
+ export declare function isHarnessAddress(address: string | undefined, harnessUrl: string): boolean;
17
+ export declare function readBrowserTab(helper: HelperLike, win: BrowserWindow, details?: boolean): Promise<BrowserTab | undefined>;
18
+ export declare function safeSharedBrowserKeys(combos: number[][]): boolean;
19
+ export {};
@@ -1,9 +1,12 @@
1
1
  import { type AccessControl, type AccessMode, type WindowLike } from './access.js';
2
+ import { type BrowserTab } from './browser-host.js';
2
3
  import { type Display, type Point, type Size } from './coords.js';
3
4
  import type { HelperLike } from './helper-client.js';
4
5
  import { type UiElement } from './target.js';
5
6
  import type { CancellableAgent, HostWindowMode, OverlayController } from './overlay.js';
6
7
  export interface Settings {
8
+ /** Web GUI origin, inferred from the local web server unless configured. */
9
+ harnessUrl?: string | undefined;
7
10
  accessMode: AccessMode;
8
11
  blockedApps: string[];
9
12
  overlay: boolean;
@@ -155,9 +158,11 @@ export declare class Computer {
155
158
  cursor(): Promise<Point>;
156
159
  /** Short description of the frontmost window, for result text. */
157
160
  describeForeground(): Promise<string>;
158
- private assertAllowed;
161
+ assertAllowed(call: CallContext, win: WindowInfo | undefined, verb: string): Promise<BrowserTab | undefined>;
162
+ private checkWebContent;
159
163
  private checkPointer;
160
164
  private checkKeyboard;
165
+ private sendKeys;
161
166
  /** Overlay status line for an action (Chinese, shown to the user). */
162
167
  static statusOf(input: ActionInput): string;
163
168
  /**
@@ -166,7 +171,7 @@ export declare class Computer {
166
171
  * own). They are read separately because scanning both costs a second or
167
172
  * more on a file dialog, and the control is nearly always in the window.
168
173
  */
169
- elements(where?: 'window' | 'popups'): Promise<UiElement[]>;
174
+ elements(where?: 'window' | 'popups', hwnd?: number): Promise<UiElement[]>;
170
175
  /** Look for a named control in the window, and only if it is not there in its popups. */
171
176
  private find;
172
177
  /**
@@ -177,9 +182,14 @@ export declare class Computer {
177
182
  locate(target: string, signal: AbortSignal, waitMs?: number): Promise<{
178
183
  point: Point;
179
184
  element: UiElement;
185
+ window: WindowInfo;
180
186
  }>;
181
187
  /** The point an action aims at: a named control, a coordinate, or nothing (the cursor). */
182
188
  private aim;
189
+ private checkNamed;
190
+ private checkNamedPoint;
191
+ private semanticAction;
192
+ private namedClickPoint;
183
193
  /** wait with `until`: done as soon as the window or control is there (or gone). */
184
194
  private waitUntil;
185
195
  /** Run one action. Returns text plus an image for screenshot/zoom. */
@@ -36,4 +36,4 @@ export declare function toScreenshot(point: Point, display: Display, shot: Size)
36
36
  /** Screenshot-space region [x1, y1, x2, y2] → physical rect clamped to the display. */
37
37
  export declare function regionToPhysical(region: readonly number[], display: Display, shot: Size): Rect;
38
38
  /** Is a physical point on this display? */
39
- export declare function contains(display: Display, point: Point): boolean;
39
+ export declare function contains(display: Rect, point: Point): boolean;
@@ -7,6 +7,7 @@ export { DEFAULTS, ENTRY_ID, resolveConfig } from './settings.js';
7
7
  export declare const name = "@copylee/dsh-computer-use";
8
8
  export declare const inject: string[];
9
9
  export interface Config {
10
+ harnessUrl?: string;
10
11
  accessMode?: AccessMode;
11
12
  overlay?: boolean;
12
13
  overlayLabel?: string;
@@ -17,12 +17,26 @@ export interface StreamFrame {
17
17
  /** Markdown reduced to one plain line for the progress card. */
18
18
  export declare function plainLine(text: string): string;
19
19
  export interface OverlaySettings {
20
+ harnessUrl?: string | undefined;
20
21
  overlay: boolean;
21
22
  overlayLabel: string;
22
23
  hostWindow: HostWindowMode;
23
24
  cardOpacity: number;
24
25
  userIdleMs: number;
25
26
  }
27
+ interface WindowRow {
28
+ hwnd: number;
29
+ pid: number;
30
+ exe: string;
31
+ title: string;
32
+ minimized: boolean;
33
+ maximized?: boolean;
34
+ foreground?: boolean;
35
+ x: number;
36
+ y: number;
37
+ width: number;
38
+ height: number;
39
+ }
26
40
  interface DisplayRow {
27
41
  x: number;
28
42
  y: number;
@@ -54,21 +68,23 @@ export declare class OverlayController {
54
68
  private unusedTimer;
55
69
  private otherTools;
56
70
  private hostWindows;
71
+ private returnTo;
72
+ private ending;
73
+ private workTab;
74
+ private starting;
57
75
  private stopping;
58
- /** Progress card lines: the reply as it streams, and what the agent is doing. */
76
+ /** Progress card lines: host-provided reasoning and recent operations. */
59
77
  private streamAgent;
60
- private text;
61
78
  private thinking;
62
79
  /** Recent steps (tool actions), oldest first. */
63
80
  private steps;
64
- /** Whether the agent is thinking now (newer than the last step). */
65
- private thinkingLatest;
66
- private freshAttempt;
81
+ private resume;
67
82
  private pushTimer;
68
83
  /** An instruction the user typed into the progress card. */
69
84
  onMessage: ((agent: CancellableAgent, text: string) => void) | undefined;
70
85
  /** Called when control starts (before the first action), e.g. to remember the window layout. */
71
86
  onStart: (() => Promise<void>) | undefined;
87
+ onRelease: (() => Promise<void>) | undefined;
72
88
  /** Opacity the card was last given, to apply setting changes while it floats. */
73
89
  private cardOpacity;
74
90
  /** Paused by Esc or the pill; actions wait until resumed. */
@@ -91,6 +107,7 @@ export declare class OverlayController {
91
107
  yieldToUser(signal: AbortSignal, waitForTyping: boolean): Promise<boolean>;
92
108
  /** Called before every action: shows the overlay once and updates its status line. */
93
109
  begin(agent: CancellableAgent | undefined, status: string): Promise<void>;
110
+ private start;
94
111
  status(status: string): Promise<void>;
95
112
  /** One more step on the card's timeline. */
96
113
  private step;
@@ -100,7 +117,20 @@ export declare class OverlayController {
100
117
  toolStarted(agent: unknown, name: string, detail: string): void;
101
118
  private schedulePush;
102
119
  /** Agent finished (idle), was cancelled, or the plugin is stopping. */
103
- end(agent?: CancellableAgent): Promise<void>;
120
+ end(agent?: CancellableAgent, replying?: boolean): Promise<void>;
121
+ isRememberedWebWindow(win: {
122
+ hwnd: number;
123
+ pid: number;
124
+ }): boolean;
125
+ forgetResume(agent: unknown): void;
126
+ rememberWorkTab(win: {
127
+ hwnd: number;
128
+ pid: number;
129
+ }, tab: string): void;
130
+ rememberWebHost(win: WindowRow, tab: string): void;
131
+ isWorkTab(tab: string): boolean;
132
+ private rememberHost;
133
+ private focusRememberedHost;
104
134
  private stop;
105
135
  /** Counted from the last computer action only: model output and other tools do not keep the overlay up. */
106
136
  private armUnused;
@@ -17,6 +17,9 @@ export interface UiElement {
17
17
  focusable?: boolean;
18
18
  /** True for web contenteditable composers (ProseMirror/tiptap/CodeMirror...). */
19
19
  editable?: boolean;
20
+ /** Internal UIA identity used to verify a live named target before dispatch. */
21
+ runtimeId?: string;
22
+ windowHwnd?: number;
20
23
  x: number;
21
24
  y: number;
22
25
  width: number;
@@ -26,6 +29,8 @@ export interface TargetQuery {
26
29
  /** UI Automation control type, when the target named one ("按钮:保存"). */
27
30
  role?: string;
28
31
  name: string;
32
+ /** Explicit AutomationId, when the target was "id:<AutomationId>" or "#<AutomationId>". */
33
+ automationId?: string;
29
34
  }
30
35
  export type TargetMatch = {
31
36
  kind: 'found';
@@ -37,7 +42,8 @@ export type TargetMatch = {
37
42
  kind: 'missing';
38
43
  suggestions: string[];
39
44
  };
40
- /** "按钮:保存" → Button named 保存; a colon that is not after a known role stays part of the name. */
45
+ /** "按钮:保存" → Button named 保存; a colon that is not after a known role stays part of the name.
46
+ * "id:NavTasksButton" / "#NavTasksButton" → match the UIA AutomationId instead of the name. */
41
47
  export declare function parseTarget(target: string): TargetQuery & {
42
48
  roles?: string[];
43
49
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@copylee/dsh-computer-use",
3
- "version": "0.8.1",
3
+ "version": "0.8.3",
4
4
  "description": "DeepSeek Harness Computer Use 插件(Windows):让 AI 看屏幕、点鼠标、敲键盘操控电脑;控制时屏幕泛起橙色光晕并显示“DeepSeek Harness 正在操控你的电脑”,按 Esc 暂停 / 继续。",
5
5
  "type": "module",
6
6
  "author": "copylee",