@copylee/dsh-computer-use 0.9.0 → 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.
@@ -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;
@@ -5,11 +5,14 @@ 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
7
  export type AutoScreenshotDetail = 'standard' | 'compact';
8
+ export type SessionMode = 'off' | 'on' | 'always';
8
9
  export interface Settings {
9
10
  /** Web GUI origin, inferred from the local web server unless configured. */
10
11
  harnessUrl?: string | undefined;
11
12
  accessMode: AccessMode;
12
- /** Whether new sessions start with computer-use tools enabled (default false; toggle per session in composer). */
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. */
13
16
  defaultSessionEnabled: boolean;
14
17
  blockedApps: string[];
15
18
  overlay: boolean;
@@ -101,6 +104,25 @@ export interface ClickResult {
101
104
  count?: number;
102
105
  repeat?: number;
103
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
+ }
104
126
  /** Text returned instead of an identical screenshot. */
105
127
  export declare const UNCHANGED_TEXT = "The screen looks exactly as in your previous screenshot: the action had no visible effect.";
106
128
  /** Longest adaptive wait for the screen to settle after an action. */
@@ -210,7 +232,13 @@ export declare class Computer {
210
232
  * more on a file dialog, and the control is nearly always in the window.
211
233
  */
212
234
  elements(where?: 'window' | 'popups', hwnd?: number): Promise<UiElement[]>;
213
- /** Look for a named control in the window, and only if it is not there in its popups. */
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
+ */
214
242
  private find;
215
243
  /**
216
244
  * Where a named control is. It may still be appearing (the menu just
@@ -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;
@@ -1,14 +1,18 @@
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 AutoScreenshotDetail, 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' */
12
16
  defaultSessionEnabled?: boolean;
13
17
  overlay?: boolean;
14
18
  overlayLabel?: string;
@@ -5,6 +5,7 @@
5
5
  import type { IncomingMessage, ServerResponse } from 'node:http';
6
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';
@@ -16,6 +17,7 @@ export declare const SCREENSHOTS_ROUTE = "/api/dsh-computer-use/screenshots";
16
17
  export declare const SCREENSHOTS_CLEAN_ROUTE = "/api/dsh-computer-use/screenshots/clean";
17
18
  export declare const SKILLS_ROUTE = "/api/dsh-computer-use/skills";
18
19
  export declare const SESSION_ROUTE = "/api/dsh-computer-use/session";
20
+ export declare const DIAGNOSTICS_ROUTE = "/api/dsh-computer-use/diagnostics";
19
21
  type Handler = (req: IncomingMessage, res: ServerResponse) => Promise<void>;
20
22
  export interface StatusBody {
21
23
  ok: true;
@@ -39,4 +41,8 @@ export declare function screenshotsCleanRoute(cache: ScreenshotCache): Handler;
39
41
  export declare function skillsRoute(skills: SkillStore): Handler;
40
42
  /** Per-session computer-use toggle: GET ?sessionId=... reads resolved state; POST { sessionId, enabled } updates and syncs live agents. */
41
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;
42
48
  export {};
@@ -1,5 +1,6 @@
1
1
  export interface SessionResolveOptions {
2
2
  defaultEnabled?: boolean;
3
+ alwaysOn?: boolean;
3
4
  parentIds?: readonly string[];
4
5
  }
5
6
  export interface SessionToggleStatus {
@@ -8,6 +9,7 @@ export interface SessionToggleStatus {
8
9
  explicit: boolean;
9
10
  inherited: boolean;
10
11
  defaultEnabled: boolean;
12
+ alwaysOn: boolean;
11
13
  }
12
14
  export interface AgentLineageLike {
13
15
  readonly id?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@copylee/dsh-computer-use",
3
- "version": "0.9.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",