@copylee/dsh-computer-use 0.11.0 → 0.13.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/README.md +31 -9
- package/helper/Capture.cs +682 -0
- package/helper/Input.cs +500 -0
- package/helper/Native.cs +136 -0
- package/helper/Overlay.cs +1685 -0
- package/helper/Program.cs +244 -0
- package/helper/Uia.cs +882 -0
- package/helper/Windows.cs +761 -0
- package/lib/client.js +191 -114
- package/lib/index.js +940 -368
- package/lib/types/access.d.ts +7 -0
- package/lib/types/cdp.d.ts +14 -3
- package/lib/types/client/select.d.ts +1 -1
- package/lib/types/computer.d.ts +25 -5
- package/lib/types/diagnostics.d.ts +3 -0
- package/lib/types/helper-client.d.ts +5 -2
- package/lib/types/index.d.ts +4 -1
- package/lib/types/lease.d.ts +30 -0
- package/lib/types/overlay.d.ts +26 -2
- package/lib/types/ui-diff.d.ts +28 -0
- package/package.json +3 -2
- package/helper/CuHelper.cs +0 -4414
package/lib/types/access.d.ts
CHANGED
|
@@ -39,6 +39,13 @@ export declare class AccessControl {
|
|
|
39
39
|
/** Remove matching app grants (or all grants when `name` is "all" / "*"). Returns revoked entries. */
|
|
40
40
|
revoke(session: string, name: string): string[];
|
|
41
41
|
forget(session: string): void;
|
|
42
|
+
/**
|
|
43
|
+
* Why reading/observing `win` is refused, or undefined when allowed.
|
|
44
|
+
* Always blocks DeepSeek Harness and blocked apps (password managers, user-blocked apps).
|
|
45
|
+
* When `requireGrant` is true (e.g. CDP DOM inspection or clipboard read), also enforces
|
|
46
|
+
* per-app session grants.
|
|
47
|
+
*/
|
|
48
|
+
readDenial(session: string, win: WindowLike | undefined, mode: AccessMode, blocked: readonly string[], action: string, requireGrant?: boolean): string | undefined;
|
|
42
49
|
/**
|
|
43
50
|
* Why input may not go to `win`, or undefined when it may. `action` is a
|
|
44
51
|
* short verb for the message ("click", "type into").
|
package/lib/types/cdp.d.ts
CHANGED
|
@@ -23,28 +23,39 @@ export interface CdpSnapshot {
|
|
|
23
23
|
url: string;
|
|
24
24
|
elements: CdpDomElement[];
|
|
25
25
|
}
|
|
26
|
-
/**
|
|
26
|
+
/** Strip common browser window title suffixes so Chrome/Edge window titles match CDP page titles cleanly. */
|
|
27
|
+
export declare function normalizeBrowserTitle(title: string): string;
|
|
28
|
+
/** Verify a CDP WebSocket URL points strictly to the loopback interface on the expected port. */
|
|
29
|
+
export declare function isLocalCdpWsUrl(wsUrl: string, expectedPort?: number): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Probe candidate localhost debugging ports and return the matching visible page target.
|
|
32
|
+
* Never falls back to an unrelated tab (`pages[0]`) when `titleHint` fails to match or multiple
|
|
33
|
+
* tabs are ambiguous — callers fall back to UIA / OCR instead of leaking another tab's DOM.
|
|
34
|
+
*/
|
|
27
35
|
export declare function findCdpTarget(options?: {
|
|
28
36
|
ports?: readonly number[];
|
|
29
37
|
titleHint?: string;
|
|
38
|
+
urlHint?: string;
|
|
30
39
|
harnessUrl?: string;
|
|
31
40
|
timeoutMs?: number;
|
|
32
41
|
}): Promise<{
|
|
33
42
|
port: number;
|
|
34
43
|
target: CdpTarget;
|
|
35
44
|
} | undefined>;
|
|
36
|
-
/** Execute one CDP `Runtime.evaluate` returning JSON on a debugger WebSocket URL. */
|
|
37
|
-
export declare function evalCdpJson<T>(wsUrl: string, expression: string, timeoutMs?: number): Promise<T | undefined>;
|
|
45
|
+
/** Execute one CDP `Runtime.evaluate` returning JSON on a validated local debugger WebSocket URL. */
|
|
46
|
+
export declare function evalCdpJson<T>(wsUrl: string, expression: string, timeoutMs?: number, expectedPort?: number): Promise<T | undefined>;
|
|
38
47
|
/** Read visible interactive DOM controls from a local CDP-enabled browser tab. */
|
|
39
48
|
export declare function readCdpElements(options?: {
|
|
40
49
|
ports?: readonly number[];
|
|
41
50
|
titleHint?: string;
|
|
51
|
+
urlHint?: string;
|
|
42
52
|
harnessUrl?: string;
|
|
43
53
|
}): Promise<CdpSnapshot | undefined>;
|
|
44
54
|
/** Read visible innerText from a local CDP-enabled browser tab (excluding password inputs). */
|
|
45
55
|
export declare function readCdpText(options?: {
|
|
46
56
|
ports?: readonly number[];
|
|
47
57
|
titleHint?: string;
|
|
58
|
+
urlHint?: string;
|
|
48
59
|
harnessUrl?: string;
|
|
49
60
|
tail?: number;
|
|
50
61
|
}): Promise<{
|
|
@@ -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
|
+
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;
|
package/lib/types/computer.d.ts
CHANGED
|
@@ -2,8 +2,10 @@ import { type AccessControl, type AccessMode, type WindowLike } from './access.j
|
|
|
2
2
|
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
|
+
import { DesktopLease } from './lease.js';
|
|
5
6
|
import { type UiElement } from './target.js';
|
|
6
|
-
import
|
|
7
|
+
import { UiDiffTracker } from './ui-diff.js';
|
|
8
|
+
import type { CancellableAgent, HostWindowMode, OverlayController, PetCardSize } from './overlay.js';
|
|
7
9
|
export type AutoScreenshotDetail = 'standard' | 'compact';
|
|
8
10
|
export type SessionMode = 'off' | 'on' | 'always';
|
|
9
11
|
export interface Settings {
|
|
@@ -18,6 +20,8 @@ export interface Settings {
|
|
|
18
20
|
overlay: boolean;
|
|
19
21
|
overlayLabel: string;
|
|
20
22
|
hostWindow: HostWindowMode;
|
|
23
|
+
/** Size tier for the mini progress card: compact, standard, or detailed. */
|
|
24
|
+
petSize: PetCardSize;
|
|
21
25
|
/** Card opacity in percent while controlling (it turns opaque when the pointer rests on it). */
|
|
22
26
|
cardOpacity: number;
|
|
23
27
|
maxLongEdge: number;
|
|
@@ -27,8 +31,10 @@ export interface Settings {
|
|
|
27
31
|
/** Detail tier for automatic post-action screenshots: standard or compact (smaller/cheaper). */
|
|
28
32
|
autoScreenshotDetail: AutoScreenshotDetail;
|
|
29
33
|
settleMs: number;
|
|
30
|
-
/** Pause while the user types
|
|
34
|
+
/** Pause while the user types or clicks physically. */
|
|
31
35
|
pauseOnUserInput: boolean;
|
|
36
|
+
/** Feed sanitized summaries of user physical clicks/scrolls/typing back to the model when the user intervenes. */
|
|
37
|
+
reportUserActions: boolean;
|
|
32
38
|
/** How long the keyboard must be quiet before resuming. */
|
|
33
39
|
userIdleMs: number;
|
|
34
40
|
/** How text is entered: stream = paste block by block, type = key by key, paste = at once. */
|
|
@@ -45,7 +51,9 @@ export interface Settings {
|
|
|
45
51
|
protectPasswords: boolean;
|
|
46
52
|
/** Guard coordinate clicks/drags when the foreground window moved/resized or is occluded since the last screenshot. */
|
|
47
53
|
windowChangeGuard: boolean;
|
|
48
|
-
/**
|
|
54
|
+
/** Explicitly enable the optional local Chromium CDP browser fast-lane (off by default unless enabled or cdpPort > 0). */
|
|
55
|
+
cdpEnabled: boolean;
|
|
56
|
+
/** Optional local Chromium remote debugging port for CDP fast-lane (0 = default port 9222 when cdpEnabled is true). */
|
|
49
57
|
cdpPort: number;
|
|
50
58
|
}
|
|
51
59
|
export type TypingMode = 'stream' | 'type' | 'paste';
|
|
@@ -153,7 +161,11 @@ export declare class Computer {
|
|
|
153
161
|
private readonly clickHistory;
|
|
154
162
|
/** The agent that last wrote the clipboard; when it goes idle the user's clipboard comes back. */
|
|
155
163
|
clipboardAgent: CancellableAgent | undefined;
|
|
156
|
-
|
|
164
|
+
/** Single-machine desktop control lease preventing concurrent sessions from colliding. */
|
|
165
|
+
readonly lease: DesktopLease;
|
|
166
|
+
/** Per-window UI Automation tree snapshot tracker for incremental `diff: true` queries. */
|
|
167
|
+
readonly uiDiff: UiDiffTracker;
|
|
168
|
+
constructor(helper: HelperLike, access: AccessControl, overlay: OverlayController, settings: () => Settings, lease?: DesktopLease);
|
|
157
169
|
refreshDisplays(): Promise<Display[]>;
|
|
158
170
|
display(): Promise<Display>;
|
|
159
171
|
selectDisplay(index: number): Promise<Display>;
|
|
@@ -187,12 +199,14 @@ export declare class Computer {
|
|
|
187
199
|
private seen;
|
|
188
200
|
/** Snapshot of the foreground window geometry captured during the latest screenshot/marks look. */
|
|
189
201
|
private lastShotWindow;
|
|
190
|
-
/** Most recent Set-of-Marks element list so `target: "#12"` resolves directly. */
|
|
202
|
+
/** Most recent Set-of-Marks element list so `target: "#12"` resolves directly until the screen mutates. */
|
|
191
203
|
private lastMarks;
|
|
192
204
|
/** The latest foreground window that was not DeepSeek Harness itself. */
|
|
193
205
|
private lastTarget;
|
|
194
206
|
/** A new turn starts: the user may have rearranged things while chatting. */
|
|
195
207
|
resetLook(): void;
|
|
208
|
+
/** Drop cached Set-of-Marks indices whenever the screen or foreground state mutates. */
|
|
209
|
+
invalidateMarks(): void;
|
|
196
210
|
private remember;
|
|
197
211
|
/**
|
|
198
212
|
* Did another window come to the front since the model last looked, without
|
|
@@ -234,6 +248,8 @@ export declare class Computer {
|
|
|
234
248
|
cursor(): Promise<Point>;
|
|
235
249
|
/** Short description of the frontmost window, for result text. */
|
|
236
250
|
describeForeground(): Promise<string>;
|
|
251
|
+
/** Enforce access control for read/observe surfaces (UIA, OCR, Set-of-Marks, CDP, clipboard). */
|
|
252
|
+
assertReadable(call: CallContext, win: WindowInfo | undefined, verb?: string, requireGrant?: boolean): void;
|
|
237
253
|
assertAllowed(call: CallContext, win: WindowInfo | undefined, verb: string): Promise<BrowserTab | undefined>;
|
|
238
254
|
private checkWebContent;
|
|
239
255
|
private checkPointer;
|
|
@@ -280,6 +296,10 @@ export declare class Computer {
|
|
|
280
296
|
private namedClickPoint;
|
|
281
297
|
/** wait with `until`: done as soon as the window or control is there (or gone). */
|
|
282
298
|
private waitUntil;
|
|
299
|
+
/** Drain buffered physical user actions and format them in screenshot coordinates for the model. */
|
|
300
|
+
drainUserActionNotes(): Promise<string>;
|
|
301
|
+
/** Format physical user takeover actions into concise screenshot-coordinate context for the model. */
|
|
302
|
+
private formatUserActions;
|
|
283
303
|
/** Run one action. Returns text plus an image for screenshot/zoom. */
|
|
284
304
|
run(input: ActionInput, call: CallContext): Promise<ActionOutcome>;
|
|
285
305
|
/**
|
|
@@ -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,12 +44,14 @@ 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;
|
|
49
51
|
restorePointer: boolean;
|
|
50
52
|
protectPasswords: boolean;
|
|
51
53
|
windowChangeGuard: boolean;
|
|
54
|
+
cdpEnabled: boolean;
|
|
52
55
|
cdpPort: number;
|
|
53
56
|
blockedAppsCount: number;
|
|
54
57
|
hasCustomHarnessUrl: 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>;
|
|
@@ -10,8 +11,10 @@ export interface HelperLike {
|
|
|
10
11
|
/** A file in helper/ at the package root: one level up from lib/ or src/, two from lib/types/. */
|
|
11
12
|
export declare function helperAssetPath(name: string): string;
|
|
12
13
|
export declare function helperSourcePath(): string;
|
|
13
|
-
/**
|
|
14
|
-
export declare function
|
|
14
|
+
/** All modular C# 5 source files under `helper/` compiled together into `cu-helper.exe`. */
|
|
15
|
+
export declare function helperSourceFiles(): string[];
|
|
16
|
+
/** Compile the helper if this source set has no cached exe yet; returns the exe path. */
|
|
17
|
+
export declare function ensureHelperExe(sources?: string | readonly string[]): Promise<string>;
|
|
15
18
|
/** For the smoke script: run the helper inside powershell.exe from the start. */
|
|
16
19
|
export declare function useHostedHelper(on?: boolean): void;
|
|
17
20
|
export declare class HelperClient implements HelperLike {
|
package/lib/types/index.d.ts
CHANGED
|
@@ -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;
|
|
@@ -38,6 +40,7 @@ export interface Config {
|
|
|
38
40
|
restorePointer?: boolean;
|
|
39
41
|
protectPasswords?: boolean;
|
|
40
42
|
windowChangeGuard?: boolean;
|
|
43
|
+
cdpEnabled?: boolean;
|
|
41
44
|
cdpPort?: number;
|
|
42
45
|
}
|
|
43
46
|
export declare const Config: z<Config>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single-machine desktop control lease: prevents concurrent sessions / subagents
|
|
3
|
+
* from fighting over the mouse, keyboard, or shared Computer state (`lastMarks`,
|
|
4
|
+
* `seen`, `lastShot`). A session acquires the lease while acting and releases it
|
|
5
|
+
* immediately when its turn ends (or after `idleExpiryMs` of inactivity).
|
|
6
|
+
*/
|
|
7
|
+
export interface LeaseHolder {
|
|
8
|
+
session: string;
|
|
9
|
+
activeCalls: number;
|
|
10
|
+
acquiredAt: number;
|
|
11
|
+
lastActiveAt: number;
|
|
12
|
+
}
|
|
13
|
+
export declare class DesktopLease {
|
|
14
|
+
private readonly idleExpiryMs;
|
|
15
|
+
private readonly waitTimeoutMs;
|
|
16
|
+
private holder;
|
|
17
|
+
private readonly waiters;
|
|
18
|
+
private tail;
|
|
19
|
+
constructor(idleExpiryMs?: number, waitTimeoutMs?: number);
|
|
20
|
+
private expireIfIdle;
|
|
21
|
+
/** Current active lease holder (if not expired). */
|
|
22
|
+
current(): Readonly<LeaseHolder> | undefined;
|
|
23
|
+
/** Explicitly release the lease held by `session` (e.g. when a turn finishes). */
|
|
24
|
+
release(session: string): void;
|
|
25
|
+
/** Acquire the desktop lease for `session`, waiting briefly if another session is finishing up. */
|
|
26
|
+
acquire(session: string, signal?: AbortSignal): Promise<void>;
|
|
27
|
+
/** Run `fn` exclusively under `session`'s desktop lease, serializing overlapping calls. */
|
|
28
|
+
withLease<T>(session: string, signal: AbortSignal | undefined, fn: () => Promise<T>): Promise<T>;
|
|
29
|
+
private wakeNext;
|
|
30
|
+
}
|
package/lib/types/overlay.d.ts
CHANGED
|
@@ -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
|
|
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
|
|
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`? */
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
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.
|
|
5
|
+
*/
|
|
6
|
+
import type { UiElement } from './target.js';
|
|
7
|
+
export interface UiElementChange {
|
|
8
|
+
element: UiElement;
|
|
9
|
+
changes: string[];
|
|
10
|
+
}
|
|
11
|
+
export interface UiDiffResult {
|
|
12
|
+
isBaseline: boolean;
|
|
13
|
+
titleChanged: boolean;
|
|
14
|
+
previousTitle?: string;
|
|
15
|
+
added: UiElement[];
|
|
16
|
+
changed: UiElementChange[];
|
|
17
|
+
removed: UiElement[];
|
|
18
|
+
unchangedCount: number;
|
|
19
|
+
}
|
|
20
|
+
export declare class UiDiffTracker {
|
|
21
|
+
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;
|
|
26
|
+
clear(hwnd?: number): void;
|
|
27
|
+
private store;
|
|
28
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@copylee/dsh-computer-use",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "DeepSeek Harness Computer Use 插件(Windows):让 AI 看屏幕、点鼠标、敲键盘操控电脑;控制时屏幕泛起橙色光晕并显示“DeepSeek Harness 正在操控你的电脑”,按 Esc 暂停 / 继续。",
|
|
5
5
|
"icon": "assets/icon.svg",
|
|
6
6
|
"type": "module",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"lib/native-worker.js",
|
|
35
35
|
"lib/client.js",
|
|
36
36
|
"lib/types/**/*.d.ts",
|
|
37
|
-
"helper
|
|
37
|
+
"helper/*.cs",
|
|
38
38
|
"helper/host.ps1",
|
|
39
39
|
"helper/deepseek-white.png",
|
|
40
40
|
"helper/deepseek-black.png",
|
|
@@ -68,6 +68,7 @@
|
|
|
68
68
|
"build": "tsc && tsdown",
|
|
69
69
|
"prepare": "pnpm run build",
|
|
70
70
|
"test": "vitest run",
|
|
71
|
+
"bench": "node scripts/benchmark.mjs",
|
|
71
72
|
"pack:check": "pnpm pack --dry-run",
|
|
72
73
|
"smoke": "node scripts/helper-smoke.mjs"
|
|
73
74
|
},
|