@copylee/dsh-computer-use 0.8.8 → 0.10.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 +657 -23
- package/lib/client.js +325 -4
- package/lib/index.js +931 -74
- package/lib/native-worker.js +41 -8
- package/lib/types/access.d.ts +5 -0
- package/lib/types/client/composer-pill.d.ts +19 -0
- package/lib/types/computer.d.ts +78 -12
- package/lib/types/coords.d.ts +12 -0
- package/lib/types/diagnostics.d.ts +71 -0
- package/lib/types/index.d.ts +7 -1
- package/lib/types/routes.d.ts +13 -5
- package/lib/types/sessions.d.ts +58 -0
- package/package.json +1 -1
package/lib/native-worker.js
CHANGED
|
@@ -228,12 +228,33 @@ function buttonFlags(button) {
|
|
|
228
228
|
function vkList(value) {
|
|
229
229
|
return Array.isArray(value) ? value.filter((v) => typeof v === "number") : [];
|
|
230
230
|
}
|
|
231
|
+
const clickHistory = [];
|
|
232
|
+
function noteClick(x, y) {
|
|
233
|
+
const now = Date.now();
|
|
234
|
+
while (clickHistory.length > 0 && now - clickHistory[0].at > 12e4) clickHistory.shift();
|
|
235
|
+
clickHistory.push({
|
|
236
|
+
x,
|
|
237
|
+
y,
|
|
238
|
+
at: now
|
|
239
|
+
});
|
|
240
|
+
let count = 0;
|
|
241
|
+
for (const item of clickHistory) if (Math.abs(item.x - x) <= 24 && Math.abs(item.y - y) <= 24) count++;
|
|
242
|
+
return count;
|
|
243
|
+
}
|
|
231
244
|
function click(args) {
|
|
245
|
+
let x, y;
|
|
232
246
|
if (typeof args.x === "number") {
|
|
233
|
-
|
|
247
|
+
x = int(args, "x", 0);
|
|
248
|
+
y = int(args, "y", 0);
|
|
249
|
+
move(x, y);
|
|
234
250
|
sleep(30);
|
|
251
|
+
} else {
|
|
252
|
+
const pos = cursor();
|
|
253
|
+
x = pos.x;
|
|
254
|
+
y = pos.y;
|
|
235
255
|
}
|
|
236
|
-
const
|
|
256
|
+
const button = args.button === "right" || args.button === "middle" ? args.button : "left";
|
|
257
|
+
const [down, up] = buttonFlags(button);
|
|
237
258
|
const count = Math.max(1, Math.min(3, int(args, "count", 1)));
|
|
238
259
|
const mods = vkList(args.modifiers);
|
|
239
260
|
send(mods.map((vk) => key(vk, false)));
|
|
@@ -247,7 +268,13 @@ function click(args) {
|
|
|
247
268
|
} finally {
|
|
248
269
|
send([...mods].reverse().map((vk) => key(vk, true)));
|
|
249
270
|
}
|
|
250
|
-
return
|
|
271
|
+
return {
|
|
272
|
+
x,
|
|
273
|
+
y,
|
|
274
|
+
button,
|
|
275
|
+
count,
|
|
276
|
+
repeat: noteClick(x, y)
|
|
277
|
+
};
|
|
251
278
|
}
|
|
252
279
|
function keys(args) {
|
|
253
280
|
const combos = Array.isArray(args.combos) ? args.combos.map(vkList) : [];
|
|
@@ -549,8 +576,7 @@ function changed(a, b) {
|
|
|
549
576
|
for (let i = 0; i < a.length; i += 3) if (Math.abs(a[i] - b[i]) + Math.abs(a[i + 1] - b[i + 1]) + Math.abs(a[i + 2] - b[i + 2]) > 30) diff++;
|
|
550
577
|
return a.length === 0 ? 0 : diff / (a.length / 3);
|
|
551
578
|
}
|
|
552
|
-
|
|
553
|
-
let markedRect = "";
|
|
579
|
+
const markedBySlot = /* @__PURE__ */ new Map();
|
|
554
580
|
/** Encode a GDI+ image to JPEG in memory and return the bytes. */
|
|
555
581
|
function encodeJpeg(image, quality) {
|
|
556
582
|
const value = koffi.alloc("uint32_t", 1);
|
|
@@ -612,12 +638,19 @@ function screenshot(args) {
|
|
|
612
638
|
GdiFlush();
|
|
613
639
|
const compare = args.compare === true;
|
|
614
640
|
if (args.mark === true || compare) {
|
|
641
|
+
const slot = typeof args.slot === "string" && args.slot.trim() !== "" ? args.slot : "full";
|
|
615
642
|
const key = `${x},${y},${w},${h}`;
|
|
616
643
|
const now = sample(bits[0], w, h);
|
|
617
644
|
const threshold = typeof args.threshold === "number" ? args.threshold : 5e-4;
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
645
|
+
const outPixels = ow * oh;
|
|
646
|
+
const prev = markedBySlot.get(slot);
|
|
647
|
+
if (compare && prev && prev.rect === key && outPixels <= prev.outPixels && quality <= prev.quality && changed(prev.sample, now) < threshold) return { unchanged: true };
|
|
648
|
+
markedBySlot.set(slot, {
|
|
649
|
+
rect: key,
|
|
650
|
+
sample: now,
|
|
651
|
+
outPixels,
|
|
652
|
+
quality
|
|
653
|
+
});
|
|
621
654
|
}
|
|
622
655
|
const source = [0n];
|
|
623
656
|
check(GdipCreateBitmapFromScan0(w, h, w * 4, 139273, bits[0], source), "GdipCreateBitmapFromScan0");
|
package/lib/types/access.d.ts
CHANGED
|
@@ -11,6 +11,11 @@ export interface WindowLike {
|
|
|
11
11
|
}
|
|
12
12
|
/** The DSH desktop host: the agent must never type into its own chat. */
|
|
13
13
|
export declare const HOST_EXES: string[];
|
|
14
|
+
/**
|
|
15
|
+
* True when an open_application target refers to a command interpreter or
|
|
16
|
+
* script host (with or without path/extension/arguments).
|
|
17
|
+
*/
|
|
18
|
+
export declare function isCommandInterpreter(target: string): boolean;
|
|
14
19
|
export declare function normalizeApp(name: string): string;
|
|
15
20
|
/** Do two app names refer to the same program ("explorer" and "文件资源管理器")? */
|
|
16
21
|
export declare function sameApp(a: string, b: string): boolean;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-session computer-use toggle pill rendered in the conversation composer's
|
|
3
|
+
* left tool row (`conversation.input.left`). Clicking turns computer-use tools
|
|
4
|
+
* and system-prompt guidance on or off for the current session without restart.
|
|
5
|
+
*/
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
export interface ComposerPillProps {
|
|
8
|
+
sessionId?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function createComposerPill(subscribeSettings?: (listener: () => void) => (() => void) | undefined): (props: ComposerPillProps) => React.DetailedReactHTMLElement<{
|
|
11
|
+
type: string;
|
|
12
|
+
className: string;
|
|
13
|
+
'data-active': string;
|
|
14
|
+
'aria-pressed': boolean;
|
|
15
|
+
'aria-label': string;
|
|
16
|
+
title: string;
|
|
17
|
+
disabled: boolean;
|
|
18
|
+
onClick: () => void;
|
|
19
|
+
}, HTMLElement> | null;
|
package/lib/types/computer.d.ts
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import { type AccessControl, type AccessMode, type WindowLike } from './access.js';
|
|
2
2
|
import { type BrowserTab } from './browser-host.js';
|
|
3
|
-
import { type Display, type Point, type Size } from './coords.js';
|
|
3
|
+
import { type Display, type Point, type ScreenshotDetail, type Size } from './coords.js';
|
|
4
4
|
import type { HelperLike } from './helper-client.js';
|
|
5
5
|
import { type UiElement } from './target.js';
|
|
6
6
|
import type { CancellableAgent, HostWindowMode, OverlayController } from './overlay.js';
|
|
7
|
+
export type AutoScreenshotDetail = 'standard' | 'compact';
|
|
8
|
+
export type SessionMode = 'off' | 'on' | 'always';
|
|
7
9
|
export interface Settings {
|
|
8
10
|
/** Web GUI origin, inferred from the local web server unless configured. */
|
|
9
11
|
harnessUrl?: string | undefined;
|
|
10
12
|
accessMode: AccessMode;
|
|
13
|
+
/** Per-session activation mode: off (per-session pill, default off), on (default on with pill), always (always on, hide composer pill). */
|
|
14
|
+
sessionMode: SessionMode;
|
|
15
|
+
/** Derived convenience flag (`sessionMode !== 'off'`); kept for backwards compatibility. */
|
|
16
|
+
defaultSessionEnabled: boolean;
|
|
11
17
|
blockedApps: string[];
|
|
12
18
|
overlay: boolean;
|
|
13
19
|
overlayLabel: string;
|
|
@@ -18,6 +24,8 @@ export interface Settings {
|
|
|
18
24
|
maxPixels: number;
|
|
19
25
|
jpegQuality: number;
|
|
20
26
|
autoScreenshot: boolean;
|
|
27
|
+
/** Detail tier for automatic post-action screenshots: standard or compact (smaller/cheaper). */
|
|
28
|
+
autoScreenshotDetail: AutoScreenshotDetail;
|
|
21
29
|
settleMs: number;
|
|
22
30
|
/** Pause while the user types on the physical keyboard. */
|
|
23
31
|
pauseOnUserInput: boolean;
|
|
@@ -77,14 +85,44 @@ export interface ActionInput {
|
|
|
77
85
|
until?: string;
|
|
78
86
|
/** wait: wait for it to disappear instead. */
|
|
79
87
|
gone?: boolean;
|
|
88
|
+
/** screenshot / zoom: capture even when pixels match the previous image. */
|
|
89
|
+
force?: boolean;
|
|
90
|
+
/** Screenshot detail: 'high' uses full configured limits; 'low' uses a compact budget for quick checks. */
|
|
91
|
+
detail?: ScreenshotDetail;
|
|
80
92
|
}
|
|
81
93
|
export interface ActionOutcome {
|
|
82
94
|
text: string;
|
|
83
|
-
/** A screenshot or zoom image to return to the model. */
|
|
84
|
-
image?: Shot;
|
|
95
|
+
/** A screenshot or zoom image to return to the model, or 'unchanged' when deduplicated. */
|
|
96
|
+
image?: Shot | 'unchanged';
|
|
85
97
|
/** The action was not performed because the user took over the keyboard. */
|
|
86
98
|
skipped?: boolean;
|
|
87
99
|
}
|
|
100
|
+
export interface ClickResult {
|
|
101
|
+
x?: number;
|
|
102
|
+
y?: number;
|
|
103
|
+
button?: string;
|
|
104
|
+
count?: number;
|
|
105
|
+
repeat?: number;
|
|
106
|
+
}
|
|
107
|
+
export interface OcrBox {
|
|
108
|
+
text: string;
|
|
109
|
+
x: number;
|
|
110
|
+
y: number;
|
|
111
|
+
width: number;
|
|
112
|
+
height: number;
|
|
113
|
+
}
|
|
114
|
+
export interface OcrLine extends OcrBox {
|
|
115
|
+
words: OcrBox[];
|
|
116
|
+
}
|
|
117
|
+
export interface OcrResult extends Partial<WindowInfo> {
|
|
118
|
+
language: string;
|
|
119
|
+
text: string;
|
|
120
|
+
x: number;
|
|
121
|
+
y: number;
|
|
122
|
+
width: number;
|
|
123
|
+
height: number;
|
|
124
|
+
lines: OcrLine[];
|
|
125
|
+
}
|
|
88
126
|
/** Text returned instead of an identical screenshot. */
|
|
89
127
|
export declare const UNCHANGED_TEXT = "The screen looks exactly as in your previous screenshot: the action had no visible effect.";
|
|
90
128
|
/** Longest adaptive wait for the screen to settle after an action. */
|
|
@@ -97,6 +135,10 @@ export declare class Computer {
|
|
|
97
135
|
private displays;
|
|
98
136
|
private displayIndex;
|
|
99
137
|
private heldButton;
|
|
138
|
+
/** Dimensions of the latest full-display screenshot shown to the model (keeps coordinate conversion exact across detail modes). */
|
|
139
|
+
private lastShot;
|
|
140
|
+
/** Recent click locations (fallback repeat counter when helper does not report repeat). */
|
|
141
|
+
private readonly clickHistory;
|
|
100
142
|
/** The agent that last wrote the clipboard; when it goes idle the user's clipboard comes back. */
|
|
101
143
|
clipboardAgent: CancellableAgent | undefined;
|
|
102
144
|
constructor(helper: HelperLike, access: AccessControl, overlay: OverlayController, settings: () => Settings);
|
|
@@ -104,18 +146,31 @@ export declare class Computer {
|
|
|
104
146
|
display(): Promise<Display>;
|
|
105
147
|
selectDisplay(index: number): Promise<Display>;
|
|
106
148
|
get currentIndex(): number;
|
|
107
|
-
|
|
149
|
+
private shotBudget;
|
|
150
|
+
shotSize(display: Display, detail?: ScreenshotDetail): Size;
|
|
151
|
+
/** Coordinate space of the latest full screenshot of `display` (or its default full size before any capture). */
|
|
152
|
+
coordSize(display: Display): Size;
|
|
108
153
|
private point;
|
|
109
154
|
toModel(point: Point): Promise<Point & {
|
|
110
155
|
offscreen: boolean;
|
|
111
156
|
}>;
|
|
112
|
-
screenshot()
|
|
157
|
+
/** Unconditional full screenshot (used when the model must see a fresh frame, e.g. after pause/switch). */
|
|
158
|
+
screenshot(detail?: ScreenshotDetail): Promise<Shot>;
|
|
113
159
|
/**
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
* visible effect).
|
|
160
|
+
* Explicit model-requested screenshot: deduplicates against the last full
|
|
161
|
+
* screenshot shown to the model unless `force: true` or higher detail is asked.
|
|
117
162
|
*/
|
|
118
|
-
|
|
163
|
+
takeScreenshot(options?: {
|
|
164
|
+
force?: boolean;
|
|
165
|
+
detail?: ScreenshotDetail;
|
|
166
|
+
}): Promise<Shot | 'unchanged'>;
|
|
167
|
+
/**
|
|
168
|
+
* A fresh post-action screenshot, or 'unchanged' when the screen looks the
|
|
169
|
+
* same as in the last one the model saw (saves an image and tells it the
|
|
170
|
+
* action had no visible effect). Respects `autoScreenshotDetail` unless
|
|
171
|
+
* overridden by an explicit `detail`.
|
|
172
|
+
*/
|
|
173
|
+
freshShot(detail?: ScreenshotDetail): Promise<Shot | 'unchanged'>;
|
|
119
174
|
/** The foreground window as of the model's latest look at the screen. */
|
|
120
175
|
private seen;
|
|
121
176
|
/** The latest foreground window that was not DeepSeek Harness itself. */
|
|
@@ -129,7 +184,12 @@ export declare class Computer {
|
|
|
129
184
|
*/
|
|
130
185
|
private foregroundChanged;
|
|
131
186
|
private capture;
|
|
132
|
-
zoom(region: number[] | undefined
|
|
187
|
+
zoom(region: number[] | undefined, options?: {
|
|
188
|
+
force?: boolean;
|
|
189
|
+
detail?: ScreenshotDetail;
|
|
190
|
+
}): Promise<Shot | 'unchanged'>;
|
|
191
|
+
/** Record a physical click position and return how many times this spot (±24 px) was clicked in the last 2 minutes. */
|
|
192
|
+
private noteClick;
|
|
133
193
|
foreground(): Promise<WindowInfo | undefined>;
|
|
134
194
|
/**
|
|
135
195
|
* The user clicked into the DeepSeek Harness card (to read or scroll the
|
|
@@ -172,7 +232,13 @@ export declare class Computer {
|
|
|
172
232
|
* more on a file dialog, and the control is nearly always in the window.
|
|
173
233
|
*/
|
|
174
234
|
elements(where?: 'window' | 'popups', hwnd?: number): Promise<UiElement[]>;
|
|
175
|
-
/**
|
|
235
|
+
/** Read visible text and physical bounding boxes via built-in Windows OCR. */
|
|
236
|
+
ocr(hwnd?: number): Promise<OcrResult>;
|
|
237
|
+
/**
|
|
238
|
+
* Look for a named control in the window, then its popups, and when the UIA
|
|
239
|
+
* tree is empty or sparse (<= 20 controls, e.g. canvas/WebView/game/custom
|
|
240
|
+
* UIs), fall back to built-in Windows OCR so `target` still finds visible text.
|
|
241
|
+
*/
|
|
176
242
|
private find;
|
|
177
243
|
/**
|
|
178
244
|
* Where a named control is. It may still be appearing (the menu just
|
|
@@ -210,7 +276,7 @@ export declare class Computer {
|
|
|
210
276
|
* (vision models only). A wait already waited, so it is captured at once:
|
|
211
277
|
* "wait, then look" should be one step, not two.
|
|
212
278
|
*/
|
|
213
|
-
after(inputs: readonly ActionInput[], call: CallContext): Promise<Shot | 'unchanged' | undefined>;
|
|
279
|
+
after(inputs: readonly ActionInput[], call: CallContext, detail?: ScreenshotDetail): Promise<Shot | 'unchanged' | undefined>;
|
|
214
280
|
/** Bring a window forward and verify it is the foreground window. */
|
|
215
281
|
focus(win: WindowInfo): Promise<WindowInfo & {
|
|
216
282
|
focused: boolean;
|
package/lib/types/coords.d.ts
CHANGED
|
@@ -17,6 +17,14 @@ export interface ScreenshotLimits {
|
|
|
17
17
|
maxLongEdge: number;
|
|
18
18
|
maxPixels: number;
|
|
19
19
|
}
|
|
20
|
+
export interface ScreenshotBudget extends ScreenshotLimits {
|
|
21
|
+
jpegQuality: number;
|
|
22
|
+
}
|
|
23
|
+
export type ScreenshotDetail = 'high' | 'low';
|
|
24
|
+
export interface ScreenshotSizeInfo extends Size {
|
|
25
|
+
megapixels: number;
|
|
26
|
+
limitedBy: 'none' | 'longEdge' | 'pixels';
|
|
27
|
+
}
|
|
20
28
|
export interface Size {
|
|
21
29
|
width: number;
|
|
22
30
|
height: number;
|
|
@@ -29,6 +37,10 @@ export interface Rect extends Point, Size {
|
|
|
29
37
|
}
|
|
30
38
|
/** Screenshot size for a display: fit both limits, keep aspect, never upscale. */
|
|
31
39
|
export declare function screenshotSize(display: Size, limits: ScreenshotLimits): Size;
|
|
40
|
+
/** Output size together with which limit (`longEdge`, `pixels`, or neither) actually constrained it. */
|
|
41
|
+
export declare function describeScreenshotSize(display: Size, limits: ScreenshotLimits): ScreenshotSizeInfo;
|
|
42
|
+
/** Lower-cost screenshot budget for quick confirmation shots (~30–40% fewer bytes). */
|
|
43
|
+
export declare function compactLimits(budget: ScreenshotBudget): ScreenshotBudget;
|
|
32
44
|
/** Screenshot pixels → physical virtual-screen pixels. Throws when outside the image. */
|
|
33
45
|
export declare function toPhysical(point: Point, display: Display, shot: Size): Point;
|
|
34
46
|
/** Physical virtual-screen pixels → screenshot pixels (may fall outside for other displays). */
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { describeScreenshotSize, type Display } from './coords.js';
|
|
2
|
+
import type { Settings } from './computer.js';
|
|
3
|
+
export interface DiagnosticCall {
|
|
4
|
+
at: string;
|
|
5
|
+
tool: string;
|
|
6
|
+
action?: string;
|
|
7
|
+
durationMs: number;
|
|
8
|
+
ok: boolean;
|
|
9
|
+
error?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface DiagnosticSnapshot {
|
|
12
|
+
generatedAt: string;
|
|
13
|
+
pluginVersion: string;
|
|
14
|
+
nodeVersion: string;
|
|
15
|
+
os: string;
|
|
16
|
+
helper: {
|
|
17
|
+
status: 'ready' | 'error';
|
|
18
|
+
nativeAvailable: boolean;
|
|
19
|
+
error?: string;
|
|
20
|
+
};
|
|
21
|
+
displays: Array<{
|
|
22
|
+
index: number;
|
|
23
|
+
primary: boolean;
|
|
24
|
+
width: number;
|
|
25
|
+
height: number;
|
|
26
|
+
dpi: number;
|
|
27
|
+
shot: ReturnType<typeof describeScreenshotSize>;
|
|
28
|
+
compactShot: ReturnType<typeof describeScreenshotSize>;
|
|
29
|
+
}>;
|
|
30
|
+
settings: {
|
|
31
|
+
accessMode: Settings['accessMode'];
|
|
32
|
+
sessionMode: Settings['sessionMode'];
|
|
33
|
+
defaultSessionEnabled: boolean;
|
|
34
|
+
overlay: boolean;
|
|
35
|
+
hostWindow: Settings['hostWindow'];
|
|
36
|
+
cardOpacity: number;
|
|
37
|
+
typingMode: Settings['typingMode'];
|
|
38
|
+
quickSteps: boolean;
|
|
39
|
+
autoScreenshot: boolean;
|
|
40
|
+
autoScreenshotDetail: Settings['autoScreenshotDetail'];
|
|
41
|
+
settleMs: number;
|
|
42
|
+
maxLongEdge: number;
|
|
43
|
+
maxPixels: number;
|
|
44
|
+
jpegQuality: number;
|
|
45
|
+
pauseOnUserInput: boolean;
|
|
46
|
+
userIdleMs: number;
|
|
47
|
+
nativeHelper: boolean;
|
|
48
|
+
blockedAppsCount: number;
|
|
49
|
+
hasCustomHarnessUrl: boolean;
|
|
50
|
+
};
|
|
51
|
+
recentCalls: readonly DiagnosticCall[];
|
|
52
|
+
}
|
|
53
|
+
export declare class DiagnosticsLog {
|
|
54
|
+
private readonly calls;
|
|
55
|
+
record(entry: Omit<DiagnosticCall, 'at'> & {
|
|
56
|
+
at?: string;
|
|
57
|
+
}): void;
|
|
58
|
+
recent(): readonly DiagnosticCall[];
|
|
59
|
+
}
|
|
60
|
+
/** Extract a safe short action summary from tool arguments without leaking typed/clipboard text. */
|
|
61
|
+
export declare function summarizeToolAction(tool: string, rawArgs: unknown): string | undefined;
|
|
62
|
+
export declare function buildDiagnosticSnapshot(options: {
|
|
63
|
+
pluginVersion: string;
|
|
64
|
+
settings: Settings;
|
|
65
|
+
displays: readonly Display[];
|
|
66
|
+
helperStatus: 'ready' | 'error';
|
|
67
|
+
helperError?: string;
|
|
68
|
+
nativeAvailable: boolean;
|
|
69
|
+
recentCalls: readonly DiagnosticCall[];
|
|
70
|
+
}): DiagnosticSnapshot;
|
|
71
|
+
export declare function formatDiagnosticText(snap: DiagnosticSnapshot): string;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import type { Context } from '@deepseek-ai/cordis';
|
|
2
2
|
import z from '@deepseek-ai/schemastery';
|
|
3
3
|
import { type AccessMode } from './access.js';
|
|
4
|
-
import { type TypingMode } from './computer.js';
|
|
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
8
|
export { DEFAULTS, ENTRY_ID, resolveConfig } from './settings.js';
|
|
7
9
|
export declare const name = "@copylee/dsh-computer-use";
|
|
8
10
|
export declare const inject: string[];
|
|
9
11
|
export interface Config {
|
|
10
12
|
harnessUrl?: string;
|
|
11
13
|
accessMode?: AccessMode;
|
|
14
|
+
sessionMode?: SessionMode;
|
|
15
|
+
/** @deprecated replaced by sessionMode: 'on' */
|
|
16
|
+
defaultSessionEnabled?: boolean;
|
|
12
17
|
overlay?: boolean;
|
|
13
18
|
overlayLabel?: string;
|
|
14
19
|
hostWindow?: HostWindowMode;
|
|
@@ -16,6 +21,7 @@ export interface Config {
|
|
|
16
21
|
/** @deprecated replaced by hostWindow: 'minimize' */
|
|
17
22
|
minimizeHostWindow?: boolean;
|
|
18
23
|
autoScreenshot?: boolean;
|
|
24
|
+
autoScreenshotDetail?: AutoScreenshotDetail;
|
|
19
25
|
settleMs?: number;
|
|
20
26
|
maxLongEdge?: number;
|
|
21
27
|
maxPixels?: number;
|
package/lib/types/routes.d.ts
CHANGED
|
@@ -3,17 +3,21 @@
|
|
|
3
3
|
* resulting screenshot size) and a short overlay preview.
|
|
4
4
|
*/
|
|
5
5
|
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
6
|
-
import { type Display } from './coords.js';
|
|
6
|
+
import { type Display, type ScreenshotSizeInfo } from './coords.js';
|
|
7
7
|
import type { Settings } from './computer.js';
|
|
8
|
+
import { type DiagnosticsLog } from './diagnostics.js';
|
|
8
9
|
import type { HelperLike } from './helper-client.js';
|
|
9
10
|
import type { OverlayController } from './overlay.js';
|
|
10
11
|
import type { ScreenshotCache } from './screenshots.js';
|
|
12
|
+
import type { SessionGate } from './sessions.js';
|
|
11
13
|
import type { SkillStore } from './skills.js';
|
|
12
14
|
export declare const STATUS_ROUTE = "/api/dsh-computer-use/status";
|
|
13
15
|
export declare const PREVIEW_ROUTE = "/api/dsh-computer-use/preview";
|
|
14
16
|
export declare const SCREENSHOTS_ROUTE = "/api/dsh-computer-use/screenshots";
|
|
15
17
|
export declare const SCREENSHOTS_CLEAN_ROUTE = "/api/dsh-computer-use/screenshots/clean";
|
|
16
18
|
export declare const SKILLS_ROUTE = "/api/dsh-computer-use/skills";
|
|
19
|
+
export declare const SESSION_ROUTE = "/api/dsh-computer-use/session";
|
|
20
|
+
export declare const DIAGNOSTICS_ROUTE = "/api/dsh-computer-use/diagnostics";
|
|
17
21
|
type Handler = (req: IncomingMessage, res: ServerResponse) => Promise<void>;
|
|
18
22
|
export interface StatusBody {
|
|
19
23
|
ok: true;
|
|
@@ -21,10 +25,8 @@ export interface StatusBody {
|
|
|
21
25
|
helper: 'ready' | 'error';
|
|
22
26
|
error?: string;
|
|
23
27
|
displays: Array<Display & {
|
|
24
|
-
shot:
|
|
25
|
-
|
|
26
|
-
height: number;
|
|
27
|
-
};
|
|
28
|
+
shot: ScreenshotSizeInfo;
|
|
29
|
+
compactShot: ScreenshotSizeInfo;
|
|
28
30
|
}>;
|
|
29
31
|
controlling: boolean;
|
|
30
32
|
}
|
|
@@ -37,4 +39,10 @@ export declare function screenshotsRoute(cache: ScreenshotCache): Handler;
|
|
|
37
39
|
export declare function screenshotsCleanRoute(cache: ScreenshotCache): Handler;
|
|
38
40
|
/** App skills for the settings page: GET lists them; POST { op: 'save' | 'delete' | 'reset', ... } changes one. */
|
|
39
41
|
export declare function skillsRoute(skills: SkillStore): Handler;
|
|
42
|
+
/** Per-session computer-use toggle: GET ?sessionId=... reads resolved state; POST { sessionId, enabled } updates and syncs live agents. */
|
|
43
|
+
export declare function sessionRoute(gate: SessionGate, settings: () => Settings, parentIdsFor: (sessionId: string) => readonly string[], sync: () => void): Handler;
|
|
44
|
+
/** Export a sanitized diagnostic report (plain text by default, or JSON with ?format=json). */
|
|
45
|
+
export declare function diagnosticsRoute(helper: HelperLike & {
|
|
46
|
+
available?: boolean;
|
|
47
|
+
}, settings: () => Settings, diagnostics: DiagnosticsLog, pluginVersion: string): Handler;
|
|
40
48
|
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export interface SessionResolveOptions {
|
|
2
|
+
defaultEnabled?: boolean;
|
|
3
|
+
alwaysOn?: boolean;
|
|
4
|
+
parentIds?: readonly string[];
|
|
5
|
+
}
|
|
6
|
+
export interface SessionToggleStatus {
|
|
7
|
+
sessionId: string;
|
|
8
|
+
enabled: boolean;
|
|
9
|
+
explicit: boolean;
|
|
10
|
+
inherited: boolean;
|
|
11
|
+
defaultEnabled: boolean;
|
|
12
|
+
alwaysOn: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface AgentLineageLike {
|
|
15
|
+
readonly id?: string;
|
|
16
|
+
readonly session: {
|
|
17
|
+
readonly id: string;
|
|
18
|
+
readonly header?: {
|
|
19
|
+
readonly parentSession?: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export interface AgentRegistryLike {
|
|
24
|
+
get?(id: string): AgentLineageLike | undefined;
|
|
25
|
+
list?(): readonly AgentLineageLike[];
|
|
26
|
+
isOwnedBy?(id: string, owner: AgentLineageLike): boolean;
|
|
27
|
+
}
|
|
28
|
+
export declare function defaultSessionsFile(): string;
|
|
29
|
+
/**
|
|
30
|
+
* Walk an agent's parent chain (nearest ancestor first), combining durable
|
|
31
|
+
* `session.header.parentSession` with runtime parent ownership for subagents.
|
|
32
|
+
*/
|
|
33
|
+
export declare function parentSessionChain(agent: AgentLineageLike | undefined, registry?: AgentRegistryLike): string[];
|
|
34
|
+
export declare class SessionGate {
|
|
35
|
+
/** Disk path for persistence; pass `null` for an in-memory store (tests). */
|
|
36
|
+
private readonly storeFile;
|
|
37
|
+
private readonly log;
|
|
38
|
+
private readonly entries;
|
|
39
|
+
private saving;
|
|
40
|
+
constructor(
|
|
41
|
+
/** Disk path for persistence; pass `null` for an in-memory store (tests). */
|
|
42
|
+
storeFile?: string | null, log?: (message: string) => void);
|
|
43
|
+
/** Explicit decision stored for `sessionId`, or undefined when unset. */
|
|
44
|
+
explicit(sessionId: string): boolean | undefined;
|
|
45
|
+
/** Effective enabled state for `sessionId`, inheriting ancestors before falling back to `defaultEnabled`. */
|
|
46
|
+
isEnabled(sessionId: string | undefined, options?: SessionResolveOptions): boolean;
|
|
47
|
+
/** Inspect the resolved state plus whether it came from an explicit choice or ancestor inheritance. */
|
|
48
|
+
status(sessionId: string, options?: SessionResolveOptions): SessionToggleStatus;
|
|
49
|
+
/** Persist an explicit on/off choice for `sessionId`. */
|
|
50
|
+
set(sessionId: string, enabled: boolean): void;
|
|
51
|
+
/** Remove an explicit choice so the session falls back to inheritance / default. */
|
|
52
|
+
clear(sessionId: string): void;
|
|
53
|
+
/** Wait for any pending write to settle (used by tests). */
|
|
54
|
+
flush(): Promise<void>;
|
|
55
|
+
private trim;
|
|
56
|
+
private loadSync;
|
|
57
|
+
private persist;
|
|
58
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@copylee/dsh-computer-use",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "DeepSeek Harness Computer Use 插件(Windows):让 AI 看屏幕、点鼠标、敲键盘操控电脑;控制时屏幕泛起橙色光晕并显示“DeepSeek Harness 正在操控你的电脑”,按 Esc 暂停 / 继续。",
|
|
5
5
|
"icon": "assets/icon.svg",
|
|
6
6
|
"type": "module",
|