@copylee/dsh-computer-use 0.10.0 → 0.11.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/helper/CuHelper.cs +457 -20
- package/lib/client.js +202 -7
- package/lib/index.js +711 -45
- package/lib/types/access.d.ts +2 -0
- package/lib/types/cdp.d.ts +55 -0
- package/lib/types/client/index.d.ts +4 -0
- package/lib/types/client/window-refs.d.ts +37 -0
- package/lib/types/computer.d.ts +22 -0
- package/lib/types/diagnostics.d.ts +5 -0
- package/lib/types/index.d.ts +9 -2
- package/lib/types/macros.d.ts +30 -0
- package/lib/types/routes.d.ts +8 -1
- package/lib/types/target.d.ts +4 -0
- package/lib/types/tools.d.ts +3 -0
- package/lib/types/update-check.d.ts +15 -0
- package/package.json +1 -1
package/lib/types/access.d.ts
CHANGED
|
@@ -36,6 +36,8 @@ export declare class AccessControl {
|
|
|
36
36
|
isGranted(session: string, win: WindowLike): boolean;
|
|
37
37
|
/** Names from `names` the session has not been granted yet (aliases count). */
|
|
38
38
|
missing(session: string, names: readonly string[]): string[];
|
|
39
|
+
/** Remove matching app grants (or all grants when `name` is "all" / "*"). Returns revoked entries. */
|
|
40
|
+
revoke(session: string, name: string): string[];
|
|
39
41
|
forget(session: string): void;
|
|
40
42
|
/**
|
|
41
43
|
* Why input may not go to `win`, or undefined when it may. `action` is a
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export interface CdpTarget {
|
|
2
|
+
id: string;
|
|
3
|
+
type: string;
|
|
4
|
+
title: string;
|
|
5
|
+
url: string;
|
|
6
|
+
webSocketDebuggerUrl?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface CdpDomElement {
|
|
9
|
+
role: string;
|
|
10
|
+
name: string;
|
|
11
|
+
selector: string;
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
width: number;
|
|
15
|
+
height: number;
|
|
16
|
+
value?: string;
|
|
17
|
+
editable?: boolean;
|
|
18
|
+
password?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export interface CdpSnapshot {
|
|
21
|
+
port: number;
|
|
22
|
+
title: string;
|
|
23
|
+
url: string;
|
|
24
|
+
elements: CdpDomElement[];
|
|
25
|
+
}
|
|
26
|
+
/** Probe candidate localhost debugging ports and return the first matching visible page target. */
|
|
27
|
+
export declare function findCdpTarget(options?: {
|
|
28
|
+
ports?: readonly number[];
|
|
29
|
+
titleHint?: string;
|
|
30
|
+
harnessUrl?: string;
|
|
31
|
+
timeoutMs?: number;
|
|
32
|
+
}): Promise<{
|
|
33
|
+
port: number;
|
|
34
|
+
target: CdpTarget;
|
|
35
|
+
} | 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>;
|
|
38
|
+
/** Read visible interactive DOM controls from a local CDP-enabled browser tab. */
|
|
39
|
+
export declare function readCdpElements(options?: {
|
|
40
|
+
ports?: readonly number[];
|
|
41
|
+
titleHint?: string;
|
|
42
|
+
harnessUrl?: string;
|
|
43
|
+
}): Promise<CdpSnapshot | undefined>;
|
|
44
|
+
/** Read visible innerText from a local CDP-enabled browser tab (excluding password inputs). */
|
|
45
|
+
export declare function readCdpText(options?: {
|
|
46
|
+
ports?: readonly number[];
|
|
47
|
+
titleHint?: string;
|
|
48
|
+
harnessUrl?: string;
|
|
49
|
+
tail?: number;
|
|
50
|
+
}): Promise<{
|
|
51
|
+
port: number;
|
|
52
|
+
title: string;
|
|
53
|
+
url: string;
|
|
54
|
+
text: string;
|
|
55
|
+
} | undefined>;
|
|
@@ -15,6 +15,10 @@ interface NamespaceView {
|
|
|
15
15
|
}
|
|
16
16
|
interface ClientContext {
|
|
17
17
|
effect(execute: () => (() => void) | void, label?: string): void;
|
|
18
|
+
inject?(deps: string[], callback: (scope: {
|
|
19
|
+
effect(fn: () => (() => void) | void, label?: string): void;
|
|
20
|
+
inputTriggers?: unknown;
|
|
21
|
+
}) => void): void;
|
|
18
22
|
slots: {
|
|
19
23
|
inject(name: string, register: () => unknown): void;
|
|
20
24
|
register(meta: Record<string, unknown>, render: (props: unknown) => unknown): unknown;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Composer `@` reference source for running Windows application windows.
|
|
3
|
+
* Uses DSH's optional `inputTriggers` service (`ctx.inject(['inputTriggers'])`)
|
|
4
|
+
* and queries the passive read-only `/api/dsh-computer-use/windows` endpoint
|
|
5
|
+
* without ever lighting up the overlay or focusing any window.
|
|
6
|
+
*/
|
|
7
|
+
interface InputTriggersLike {
|
|
8
|
+
registerSource?(source: {
|
|
9
|
+
trigger: string;
|
|
10
|
+
name: string;
|
|
11
|
+
showGroupTitle?: boolean;
|
|
12
|
+
lexicon?: () => unknown[];
|
|
13
|
+
subscribeLexicon?: (session: unknown, listener: () => void) => () => void;
|
|
14
|
+
candidates: (session: unknown, request?: {
|
|
15
|
+
query?: string;
|
|
16
|
+
quoted?: boolean;
|
|
17
|
+
drilled?: boolean;
|
|
18
|
+
signal?: AbortSignal;
|
|
19
|
+
}) => Promise<unknown[]>;
|
|
20
|
+
onPick: (pick: {
|
|
21
|
+
candidate?: {
|
|
22
|
+
value?: unknown;
|
|
23
|
+
label?: string;
|
|
24
|
+
description?: string;
|
|
25
|
+
};
|
|
26
|
+
}) => unknown;
|
|
27
|
+
codec?: {
|
|
28
|
+
clipboardText?: (ref: string) => string;
|
|
29
|
+
serialize?: (ref: string, signal?: AbortSignal) => Promise<string>;
|
|
30
|
+
};
|
|
31
|
+
}): () => void;
|
|
32
|
+
}
|
|
33
|
+
export declare function registerWindowReferenceSource(scope: {
|
|
34
|
+
effect(fn: () => (() => void) | void, label?: string): void;
|
|
35
|
+
inputTriggers?: InputTriggersLike;
|
|
36
|
+
}): void;
|
|
37
|
+
export {};
|
package/lib/types/computer.d.ts
CHANGED
|
@@ -37,6 +37,16 @@ export interface Settings {
|
|
|
37
37
|
quickSteps: boolean;
|
|
38
38
|
/** Run screenshots, display / window queries and idle input in-process through DSH's koffi instead of the C# helper. */
|
|
39
39
|
nativeHelper: boolean;
|
|
40
|
+
/** Try background UIA semantic click at coordinate before falling back to a physical pointer click. */
|
|
41
|
+
elementFirstClick: boolean;
|
|
42
|
+
/** Restore the user's physical mouse position right after a physical click. */
|
|
43
|
+
restorePointer: boolean;
|
|
44
|
+
/** Refuse automated typing into password fields (UIA IsPassword / Win32 ES_PASSWORD) and mask values. */
|
|
45
|
+
protectPasswords: boolean;
|
|
46
|
+
/** Guard coordinate clicks/drags when the foreground window moved/resized or is occluded since the last screenshot. */
|
|
47
|
+
windowChangeGuard: boolean;
|
|
48
|
+
/** Optional local Chromium remote debugging port for CDP fast-lane (0 = auto-probe 9222/9229 on demand). */
|
|
49
|
+
cdpPort: number;
|
|
40
50
|
}
|
|
41
51
|
export type TypingMode = 'stream' | 'type' | 'paste';
|
|
42
52
|
export interface WindowInfo extends WindowLike {
|
|
@@ -89,6 +99,8 @@ export interface ActionInput {
|
|
|
89
99
|
force?: boolean;
|
|
90
100
|
/** Screenshot detail: 'high' uses full configured limits; 'low' uses a compact budget for quick checks. */
|
|
91
101
|
detail?: ScreenshotDetail;
|
|
102
|
+
/** type: select all (Ctrl+A) before entering replacement text. */
|
|
103
|
+
replace?: boolean;
|
|
92
104
|
}
|
|
93
105
|
export interface ActionOutcome {
|
|
94
106
|
text: string;
|
|
@@ -173,6 +185,10 @@ export declare class Computer {
|
|
|
173
185
|
freshShot(detail?: ScreenshotDetail): Promise<Shot | 'unchanged'>;
|
|
174
186
|
/** The foreground window as of the model's latest look at the screen. */
|
|
175
187
|
private seen;
|
|
188
|
+
/** Snapshot of the foreground window geometry captured during the latest screenshot/marks look. */
|
|
189
|
+
private lastShotWindow;
|
|
190
|
+
/** Most recent Set-of-Marks element list so `target: "#12"` resolves directly. */
|
|
191
|
+
private lastMarks;
|
|
176
192
|
/** The latest foreground window that was not DeepSeek Harness itself. */
|
|
177
193
|
private lastTarget;
|
|
178
194
|
/** A new turn starts: the user may have rearranged things while chatting. */
|
|
@@ -234,6 +250,12 @@ export declare class Computer {
|
|
|
234
250
|
elements(where?: 'window' | 'popups', hwnd?: number): Promise<UiElement[]>;
|
|
235
251
|
/** Read visible text and physical bounding boxes via built-in Windows OCR. */
|
|
236
252
|
ocr(hwnd?: number): Promise<OcrResult>;
|
|
253
|
+
/** Capture a Set-of-Marks annotated screenshot and cache indexed elements so `target: "#N"` works directly. */
|
|
254
|
+
marks(hwnd?: number, max?: number): Promise<{
|
|
255
|
+
window: Partial<WindowInfo>;
|
|
256
|
+
elements: UiElement[];
|
|
257
|
+
shot: Shot;
|
|
258
|
+
}>;
|
|
237
259
|
/**
|
|
238
260
|
* Look for a named control in the window, then its popups, and when the UIA
|
|
239
261
|
* tree is empty or sparse (<= 20 controls, e.g. canvas/WebView/game/custom
|
|
@@ -45,6 +45,11 @@ export interface DiagnosticSnapshot {
|
|
|
45
45
|
pauseOnUserInput: boolean;
|
|
46
46
|
userIdleMs: number;
|
|
47
47
|
nativeHelper: boolean;
|
|
48
|
+
elementFirstClick: boolean;
|
|
49
|
+
restorePointer: boolean;
|
|
50
|
+
protectPasswords: boolean;
|
|
51
|
+
windowChangeGuard: boolean;
|
|
52
|
+
cdpPort: number;
|
|
48
53
|
blockedAppsCount: number;
|
|
49
54
|
hasCustomHarnessUrl: boolean;
|
|
50
55
|
};
|
package/lib/types/index.d.ts
CHANGED
|
@@ -3,8 +3,10 @@ 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
5
|
import { type HostWindowMode } from './overlay.js';
|
|
6
|
-
/** Parse `/cu [on|off|toggle|status|reset]` arguments into an action. */
|
|
7
|
-
export declare function parseCuCommand(rawInput: string): 'on' | 'off' | 'toggle' | 'status' | 'reset' | 'invalid';
|
|
6
|
+
/** Parse `/cu [on|off|toggle|status|reset|stop|revoke <app>]` arguments into an action. */
|
|
7
|
+
export declare function parseCuCommand(rawInput: string): 'on' | 'off' | 'toggle' | 'status' | 'reset' | 'stop' | 'revoke' | 'invalid';
|
|
8
|
+
/** Extract the app name argument after `/cu revoke ...` (empty means all granted apps). */
|
|
9
|
+
export declare function parseCuRevokeTarget(rawInput: string): string;
|
|
8
10
|
export { DEFAULTS, ENTRY_ID, resolveConfig } from './settings.js';
|
|
9
11
|
export declare const name = "@copylee/dsh-computer-use";
|
|
10
12
|
export declare const inject: string[];
|
|
@@ -32,6 +34,11 @@ export interface Config {
|
|
|
32
34
|
typingMode?: TypingMode;
|
|
33
35
|
quickSteps?: boolean;
|
|
34
36
|
nativeHelper?: boolean;
|
|
37
|
+
elementFirstClick?: boolean;
|
|
38
|
+
restorePointer?: boolean;
|
|
39
|
+
protectPasswords?: boolean;
|
|
40
|
+
windowChangeGuard?: boolean;
|
|
41
|
+
cdpPort?: number;
|
|
35
42
|
}
|
|
36
43
|
export declare const Config: z<Config>;
|
|
37
44
|
export declare function apply(ctx: Context, config?: Config): void;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ActionInput } from './computer.js';
|
|
2
|
+
export declare const MAX_MACRO_ACTIONS = 30;
|
|
3
|
+
export interface ActionMacro {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
app?: string;
|
|
7
|
+
description: string;
|
|
8
|
+
params: string[];
|
|
9
|
+
actions: ActionInput[];
|
|
10
|
+
updatedAt: number;
|
|
11
|
+
}
|
|
12
|
+
export interface MacroInput {
|
|
13
|
+
name: string;
|
|
14
|
+
app?: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
actions: ActionInput[];
|
|
17
|
+
}
|
|
18
|
+
export declare function macroId(name: string): string;
|
|
19
|
+
/** Collect `{{param}}` placeholder names referenced across macro actions. */
|
|
20
|
+
export declare function extractMacroParams(actions: readonly ActionInput[]): string[];
|
|
21
|
+
/** Substitute `{{param}}` placeholders into a fresh copy of `actions`. */
|
|
22
|
+
export declare function renderMacroActions(actions: readonly ActionInput[], params?: Record<string, string | number | boolean>): ActionInput[];
|
|
23
|
+
export declare class MacroStore {
|
|
24
|
+
readonly dir: string;
|
|
25
|
+
constructor(dir?: string);
|
|
26
|
+
list(): ActionMacro[];
|
|
27
|
+
get(nameOrId: string): ActionMacro | undefined;
|
|
28
|
+
save(input: MacroInput): ActionMacro;
|
|
29
|
+
remove(nameOrId: string): boolean;
|
|
30
|
+
}
|
package/lib/types/routes.d.ts
CHANGED
|
@@ -18,9 +18,12 @@ export declare const SCREENSHOTS_CLEAN_ROUTE = "/api/dsh-computer-use/screenshot
|
|
|
18
18
|
export declare const SKILLS_ROUTE = "/api/dsh-computer-use/skills";
|
|
19
19
|
export declare const SESSION_ROUTE = "/api/dsh-computer-use/session";
|
|
20
20
|
export declare const DIAGNOSTICS_ROUTE = "/api/dsh-computer-use/diagnostics";
|
|
21
|
+
export declare const UPDATE_ROUTE = "/api/dsh-computer-use/update";
|
|
22
|
+
export declare const WINDOWS_ROUTE = "/api/dsh-computer-use/windows";
|
|
21
23
|
type Handler = (req: IncomingMessage, res: ServerResponse) => Promise<void>;
|
|
22
24
|
export interface StatusBody {
|
|
23
25
|
ok: true;
|
|
26
|
+
version: string;
|
|
24
27
|
platform: string;
|
|
25
28
|
helper: 'ready' | 'error';
|
|
26
29
|
error?: string;
|
|
@@ -30,7 +33,7 @@ export interface StatusBody {
|
|
|
30
33
|
}>;
|
|
31
34
|
controlling: boolean;
|
|
32
35
|
}
|
|
33
|
-
export declare function statusRoute(helper: HelperLike, settings: () => Settings, overlay: OverlayController): Handler;
|
|
36
|
+
export declare function statusRoute(helper: HelperLike, settings: () => Settings, overlay: OverlayController, pluginVersion?: string): Handler;
|
|
34
37
|
/** Show the overlay for a few seconds so the user can see how it looks (skipped while an agent is controlling). */
|
|
35
38
|
export declare function previewRoute(helper: HelperLike, settings: () => Settings, overlay: OverlayController, iconPath: string): Handler;
|
|
36
39
|
/** Screenshot cache size and how much of it is orphaned. */
|
|
@@ -45,4 +48,8 @@ export declare function sessionRoute(gate: SessionGate, settings: () => Settings
|
|
|
45
48
|
export declare function diagnosticsRoute(helper: HelperLike & {
|
|
46
49
|
available?: boolean;
|
|
47
50
|
}, settings: () => Settings, diagnostics: DiagnosticsLog, pluginVersion: string): Handler;
|
|
51
|
+
/** Check npmjs & npmmirror concurrently for a newer plugin version. */
|
|
52
|
+
export declare function updateRoute(pluginVersion: string): Handler;
|
|
53
|
+
/** Passive read-only window list for `@窗口` composer references (never triggers overlay or focus). */
|
|
54
|
+
export declare function windowsRoute(helper: HelperLike): Handler;
|
|
48
55
|
export {};
|
package/lib/types/target.d.ts
CHANGED
|
@@ -17,6 +17,10 @@ export interface UiElement {
|
|
|
17
17
|
focusable?: boolean;
|
|
18
18
|
/** True for web contenteditable composers (ProseMirror/tiptap/CodeMirror...). */
|
|
19
19
|
editable?: boolean;
|
|
20
|
+
/** True when the control is a password field (UIA IsPassword or Win32 ES_PASSWORD). */
|
|
21
|
+
password?: boolean;
|
|
22
|
+
/** 1-based Set-of-Marks badge number when returned by `ui_elements({ marks: true })`. */
|
|
23
|
+
mark?: number;
|
|
20
24
|
/** Internal UIA identity used to verify a live named target before dispatch. */
|
|
21
25
|
runtimeId?: string;
|
|
22
26
|
windowHwnd?: number;
|
package/lib/types/tools.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ImageAttachmentRef } from '@deepseek-ai/dsh-attachment';
|
|
2
2
|
import { defineTool } from '@deepseek-ai/dsh-tools';
|
|
3
|
+
import { type MacroStore } from './macros.js';
|
|
3
4
|
import { type SkillStore } from './skills.js';
|
|
4
5
|
import { Computer, type CallContext, type Shot } from './computer.js';
|
|
5
6
|
type ToolDefinition = ReturnType<typeof defineTool>;
|
|
@@ -11,6 +12,8 @@ export interface ToolHost {
|
|
|
11
12
|
context(exec: unknown): Promise<CallContext>;
|
|
12
13
|
/** Per-app notes the agent keeps (optional: tests run without). */
|
|
13
14
|
skills?: SkillStore;
|
|
15
|
+
/** Saved replayable action macros (optional: tests run without). */
|
|
16
|
+
macros?: MacroStore;
|
|
14
17
|
}
|
|
15
18
|
export declare function createTools(host: ToolHost): ToolDefinition[];
|
|
16
19
|
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Concurrent plugin update check probing both npmjs and npmmirror so users in
|
|
3
|
+
* mainland China and overseas both get fast, reliable latest-version feedback.
|
|
4
|
+
*/
|
|
5
|
+
export interface UpdateCheckResult {
|
|
6
|
+
current: string;
|
|
7
|
+
latest?: string;
|
|
8
|
+
hasUpdate: boolean;
|
|
9
|
+
source?: 'npmjs' | 'npmmirror';
|
|
10
|
+
error?: string;
|
|
11
|
+
}
|
|
12
|
+
/** Compare two semver strings (major.minor.patch); returns >0 when `a > b`. */
|
|
13
|
+
export declare function compareSemver(a: string, b: string): number;
|
|
14
|
+
/** Race npmjs & npmmirror concurrently and return the highest valid version found. */
|
|
15
|
+
export declare function checkForUpdate(current: string, fetchImpl?: typeof fetch, timeoutMs?: number): Promise<UpdateCheckResult>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@copylee/dsh-computer-use",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"description": "DeepSeek Harness Computer Use 插件(Windows):让 AI 看屏幕、点鼠标、敲键盘操控电脑;控制时屏幕泛起橙色光晕并显示“DeepSeek Harness 正在操控你的电脑”,按 Esc 暂停 / 继续。",
|
|
5
5
|
"icon": "assets/icon.svg",
|
|
6
6
|
"type": "module",
|