dsh-click 0.1.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/CHANGELOG.md +27 -0
- package/LICENSE +201 -0
- package/README.es.md +174 -0
- package/README.hi.md +174 -0
- package/README.md +174 -0
- package/README.pt.md +174 -0
- package/README.zh.md +174 -0
- package/SECURITY.md +38 -0
- package/THIRD_PARTY_NOTICES.md +20 -0
- package/cordis.patch.yml +53 -0
- package/lib/index.js +1810 -0
- package/lib/types/actions.d.ts +94 -0
- package/lib/types/actions.d.ts.map +1 -0
- package/lib/types/config.d.ts +119 -0
- package/lib/types/config.d.ts.map +1 -0
- package/lib/types/events.d.ts +111 -0
- package/lib/types/events.d.ts.map +1 -0
- package/lib/types/index.d.ts +39 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/observe.d.ts +76 -0
- package/lib/types/observe.d.ts.map +1 -0
- package/lib/types/platform/runner.d.ts +40 -0
- package/lib/types/platform/runner.d.ts.map +1 -0
- package/lib/types/platform/selection.d.ts +44 -0
- package/lib/types/platform/selection.d.ts.map +1 -0
- package/lib/types/platform/types.d.ts +220 -0
- package/lib/types/platform/types.d.ts.map +1 -0
- package/lib/types/sanitize.d.ts +45 -0
- package/lib/types/sanitize.d.ts.map +1 -0
- package/lib/types/tools.d.ts +113 -0
- package/lib/types/tools.d.ts.map +1 -0
- package/lib/types/version.d.ts +13 -0
- package/lib/types/version.d.ts.map +1 -0
- package/lib/types/vision.d.ts +22 -0
- package/lib/types/vision.d.ts.map +1 -0
- package/native/win32/dsh-click-helper.ps1 +870 -0
- package/package.json +143 -0
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wire vocabulary shared by the harness-side backends and the native helper
|
|
3
|
+
* process (the platform seam). Every `DesktopBackend` implementation — the
|
|
4
|
+
* Windows helper runner today, reserved macOS/Linux backends later — speaks
|
|
5
|
+
* these types; helper JSON responses are validated against them at the wire
|
|
6
|
+
* boundary because they cross a process trust line.
|
|
7
|
+
*
|
|
8
|
+
* @module dsh-click/platform/types
|
|
9
|
+
*/
|
|
10
|
+
import type { ProcessFacts } from '../events.ts';
|
|
11
|
+
/** Error with a stable machine-routing code, model-readable message included. */
|
|
12
|
+
export declare class DshClickError extends Error {
|
|
13
|
+
readonly code: string;
|
|
14
|
+
/** @param message - human- and model-readable failure text. */
|
|
15
|
+
/** @param code - stable code for policy and diagnostics. */
|
|
16
|
+
constructor(message: string, code: string);
|
|
17
|
+
}
|
|
18
|
+
/** How a window may be addressed in an observation request. */
|
|
19
|
+
export interface WindowRef {
|
|
20
|
+
/** Native window handle (HWND on Windows). */
|
|
21
|
+
windowId?: number;
|
|
22
|
+
/** Window title; the helper matches the first visible window containing it. */
|
|
23
|
+
windowTitle?: string;
|
|
24
|
+
/** Owning process id. */
|
|
25
|
+
processId?: number;
|
|
26
|
+
}
|
|
27
|
+
/** Screen-space rectangle, integer pixel coordinates. */
|
|
28
|
+
export interface Rect {
|
|
29
|
+
x: number;
|
|
30
|
+
y: number;
|
|
31
|
+
width: number;
|
|
32
|
+
height: number;
|
|
33
|
+
}
|
|
34
|
+
/** One top-level application window. */
|
|
35
|
+
export interface WindowInfo {
|
|
36
|
+
windowId: number;
|
|
37
|
+
processId: number | null;
|
|
38
|
+
title: string;
|
|
39
|
+
className: string;
|
|
40
|
+
rect: Rect;
|
|
41
|
+
executablePath: string | null;
|
|
42
|
+
visible: boolean;
|
|
43
|
+
}
|
|
44
|
+
/** One accessibility element inside the observed window. */
|
|
45
|
+
export interface ElementInfo {
|
|
46
|
+
/** Stable per-instance element id (UIA runtime id on Windows). */
|
|
47
|
+
elementId: string;
|
|
48
|
+
/** Control type, e.g. "Button" or "Edit". */
|
|
49
|
+
controlType: string;
|
|
50
|
+
/** Accessibility name; empty when unnamed. */
|
|
51
|
+
name: string;
|
|
52
|
+
/** Automation id; empty when unset. */
|
|
53
|
+
automationId: string;
|
|
54
|
+
/** Bounding rectangle in screen coordinates. */
|
|
55
|
+
rect: Rect;
|
|
56
|
+
/** Whether the element is enabled. */
|
|
57
|
+
enabled: boolean;
|
|
58
|
+
/** Patterns the element supports (value/invoke/scroll), so the model can pick the right action. */
|
|
59
|
+
patterns: string[];
|
|
60
|
+
}
|
|
61
|
+
/** One pixel-location hint: a labeled point and its observed color. */
|
|
62
|
+
export interface PixelHint {
|
|
63
|
+
/** Element or region label the hint describes. */
|
|
64
|
+
label: string;
|
|
65
|
+
/** Screen x coordinate. */
|
|
66
|
+
x: number;
|
|
67
|
+
/** Screen y coordinate. */
|
|
68
|
+
y: number;
|
|
69
|
+
/** RGB color at the point, like "rgb(12, 34, 56)". */
|
|
70
|
+
color: string;
|
|
71
|
+
}
|
|
72
|
+
/** Fresh identity + content hashes for one window, captured at observation time. */
|
|
73
|
+
export interface WindowSnapshot {
|
|
74
|
+
windowId: number;
|
|
75
|
+
processId: number;
|
|
76
|
+
executablePath: string | null;
|
|
77
|
+
title: string;
|
|
78
|
+
className: string;
|
|
79
|
+
rect: Rect;
|
|
80
|
+
/** True when the window currently owns the foreground. */
|
|
81
|
+
foreground: boolean;
|
|
82
|
+
/** Hash of the accessibility subtree (element ids, rects, names, types). */
|
|
83
|
+
treeHash: string;
|
|
84
|
+
/** Hash of the window's current pixels. */
|
|
85
|
+
shotHash: string;
|
|
86
|
+
/** Number of elements the tree walk captured. */
|
|
87
|
+
elementCount: number;
|
|
88
|
+
}
|
|
89
|
+
/** A captured screenshot plus the snapshot facts it was taken with. */
|
|
90
|
+
export interface Screenshot {
|
|
91
|
+
/** PNG bytes, base64-encoded. */
|
|
92
|
+
pngBase64: string;
|
|
93
|
+
width: number;
|
|
94
|
+
height: number;
|
|
95
|
+
snapshot: WindowSnapshot;
|
|
96
|
+
}
|
|
97
|
+
/** An accessibility tree read plus pixel hints. */
|
|
98
|
+
export interface Tree {
|
|
99
|
+
snapshot: WindowSnapshot;
|
|
100
|
+
elements: ElementInfo[];
|
|
101
|
+
pixels: PixelHint[];
|
|
102
|
+
}
|
|
103
|
+
/** One running desktop application. */
|
|
104
|
+
export interface AppInfo {
|
|
105
|
+
processId: number;
|
|
106
|
+
name: string;
|
|
107
|
+
executablePath: string | null;
|
|
108
|
+
windows: WindowInfo[];
|
|
109
|
+
}
|
|
110
|
+
/** A click request: exactly one of element id or coordinates. */
|
|
111
|
+
export interface ClickRequest {
|
|
112
|
+
windowId: number;
|
|
113
|
+
elementId?: string;
|
|
114
|
+
x?: number;
|
|
115
|
+
y?: number;
|
|
116
|
+
button: 'left' | 'right';
|
|
117
|
+
}
|
|
118
|
+
/** A type request addressed to a value-pattern element. */
|
|
119
|
+
export interface TypeRequest {
|
|
120
|
+
windowId: number;
|
|
121
|
+
elementId: string;
|
|
122
|
+
text: string;
|
|
123
|
+
/** Whether the helper backs up and restores the control text on failure. */
|
|
124
|
+
rollback: boolean;
|
|
125
|
+
}
|
|
126
|
+
/** A scroll request. */
|
|
127
|
+
export interface ScrollRequest {
|
|
128
|
+
windowId: number;
|
|
129
|
+
elementId?: string;
|
|
130
|
+
direction: 'up' | 'down' | 'page-up' | 'page-down';
|
|
131
|
+
/** Number of increments; positive only. */
|
|
132
|
+
amount: number;
|
|
133
|
+
}
|
|
134
|
+
/** A key-combination request (e.g. "Ctrl+S", "Enter"). */
|
|
135
|
+
export interface KeyRequest {
|
|
136
|
+
windowId: number;
|
|
137
|
+
keys: string;
|
|
138
|
+
}
|
|
139
|
+
/** The settled outcome of one mutating action, as reported by the helper. */
|
|
140
|
+
export interface ActionOutcome {
|
|
141
|
+
windowId: number;
|
|
142
|
+
/** Which action ran, for the audit trail. */
|
|
143
|
+
action: string;
|
|
144
|
+
/** Delivery mechanism actually used. */
|
|
145
|
+
delivered: 'uia' | 'posted' | 'none';
|
|
146
|
+
processBefore: ProcessFacts;
|
|
147
|
+
processAfter: ProcessFacts;
|
|
148
|
+
/** Present on `type`: whether failed typing restored the original text. */
|
|
149
|
+
restored?: boolean;
|
|
150
|
+
/** Short helper-side detail. */
|
|
151
|
+
detail?: string;
|
|
152
|
+
}
|
|
153
|
+
/** The settled outcome of an app launch. */
|
|
154
|
+
export interface LaunchOutcome {
|
|
155
|
+
processId: number;
|
|
156
|
+
executablePath: string | null;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* The platform abstraction every desktop backend implements. Backends must
|
|
160
|
+
* never move input focus themselves; the `focusFallback` flag is the ONLY
|
|
161
|
+
* sanctioned escape hatch and stays `false` by default.
|
|
162
|
+
*/
|
|
163
|
+
export interface DesktopBackend {
|
|
164
|
+
/** Platform id this backend serves (`win32`, reserved `darwin`/`linux`). */
|
|
165
|
+
readonly platform: string;
|
|
166
|
+
/** Whether the backend can run at all (services mounted, platform supported). */
|
|
167
|
+
readonly available: boolean;
|
|
168
|
+
/** Why the backend is unavailable, when it is. */
|
|
169
|
+
readonly unavailableReason?: string;
|
|
170
|
+
/** List every visible top-level window across running applications. */
|
|
171
|
+
listWindows(signal?: AbortSignal): Promise<WindowInfo[]>;
|
|
172
|
+
/** Capture a screenshot of the addressed window (or the primary screen). */
|
|
173
|
+
shot(ref: WindowRef, maxSide: number, signal?: AbortSignal): Promise<Screenshot>;
|
|
174
|
+
/** Read the accessibility tree plus pixel hints of the addressed window. */
|
|
175
|
+
tree(ref: WindowRef, maxElements: number, maxDepth: number, includePixels: boolean, signal?: AbortSignal): Promise<Tree>;
|
|
176
|
+
/** Re-capture fresh identity + hashes for one window (the stale check). */
|
|
177
|
+
snapshot(windowId: number, signal?: AbortSignal): Promise<WindowSnapshot>;
|
|
178
|
+
/** Perform a click inside the target window. */
|
|
179
|
+
click(request: ClickRequest, focusFallback: boolean, signal?: AbortSignal): Promise<ActionOutcome>;
|
|
180
|
+
/** Type text into the target element. */
|
|
181
|
+
type(request: TypeRequest, focusFallback: boolean, signal?: AbortSignal): Promise<ActionOutcome>;
|
|
182
|
+
/** Scroll the target element or window. */
|
|
183
|
+
scroll(request: ScrollRequest, focusFallback: boolean, signal?: AbortSignal): Promise<ActionOutcome>;
|
|
184
|
+
/** Send a key combination to the target window. */
|
|
185
|
+
key(request: KeyRequest, focusFallback: boolean, signal?: AbortSignal): Promise<ActionOutcome>;
|
|
186
|
+
/** List running desktop applications. */
|
|
187
|
+
apps(signal?: AbortSignal): Promise<AppInfo[]>;
|
|
188
|
+
/** Launch one application by name or path. */
|
|
189
|
+
launch(name: string, args: readonly string[], signal?: AbortSignal): Promise<LaunchOutcome>;
|
|
190
|
+
}
|
|
191
|
+
/** The JSON request the harness writes to the helper's stdin. */
|
|
192
|
+
export interface HelperRequest {
|
|
193
|
+
protocol: number;
|
|
194
|
+
pluginVersion: string;
|
|
195
|
+
requestId: string;
|
|
196
|
+
op: string;
|
|
197
|
+
args: Record<string, unknown>;
|
|
198
|
+
}
|
|
199
|
+
/** The JSON response the helper writes to stdout: either a result or an error. */
|
|
200
|
+
export type HelperResponse = {
|
|
201
|
+
ok: true;
|
|
202
|
+
result: unknown;
|
|
203
|
+
} | {
|
|
204
|
+
ok: false;
|
|
205
|
+
error: {
|
|
206
|
+
code: string;
|
|
207
|
+
message: string;
|
|
208
|
+
};
|
|
209
|
+
};
|
|
210
|
+
/** Assert one helper response field is a finite number; throws on violation. */
|
|
211
|
+
export declare function expectNumber(record: Record<string, unknown>, field: string, op: string): number;
|
|
212
|
+
/** Assert one helper response field is a string; throws on violation. */
|
|
213
|
+
export declare function expectString(record: Record<string, unknown>, field: string, op: string): string;
|
|
214
|
+
/** Assert one helper response field is a plain record; throws on violation. */
|
|
215
|
+
export declare function expectRecord(record: Record<string, unknown>, field: string, op: string): Record<string, unknown>;
|
|
216
|
+
/** Assert an entire helper payload is a plain record; throws on violation. */
|
|
217
|
+
export declare function expectRecordValue(value: unknown, op: string): Record<string, unknown>;
|
|
218
|
+
/** Parse the helper's `processBefore`/`processAfter` facts at the wire boundary. */
|
|
219
|
+
export declare function expectProcessFacts(value: unknown, op: string): ProcessFacts;
|
|
220
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
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AAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAMhH;AAED,8EAA8E;AAC9E,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAKrF;AAED,oFAAoF;AACpF,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,GAAG,YAAY,CAW3E"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure display/audit redaction for everything dsh-click shows to the model or
|
|
3
|
+
* writes to a session log: window titles, executable paths, and free text that
|
|
4
|
+
* may contain credentials. Every function is pure and total on string input;
|
|
5
|
+
* extreme cases are covered by `tests/sanitize.spec.ts`.
|
|
6
|
+
*
|
|
7
|
+
* @module dsh-click/sanitize
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Strip control characters and truncate to `maxLength`.
|
|
11
|
+
*
|
|
12
|
+
* @param text - the raw string.
|
|
13
|
+
* @param maxLength - maximum returned length (including the truncation marker).
|
|
14
|
+
* @returns the sanitized string.
|
|
15
|
+
*/
|
|
16
|
+
export declare function sanitizeText(text: string, maxLength: number): string;
|
|
17
|
+
/**
|
|
18
|
+
* Sanitize a filesystem path for display: control characters removed, and the
|
|
19
|
+
* TAIL (filename side) preserved when truncating, since the head is the part
|
|
20
|
+
* that usually repeats.
|
|
21
|
+
*
|
|
22
|
+
* @param path - the raw path.
|
|
23
|
+
* @param maxLength - maximum returned length (including the truncation marker).
|
|
24
|
+
* @returns the sanitized path.
|
|
25
|
+
*/
|
|
26
|
+
export declare function sanitizePath(path: string, maxLength: number): string;
|
|
27
|
+
/**
|
|
28
|
+
* Redact credential-shaped fragments from free text before it reaches a log or
|
|
29
|
+
* display surface: `key=`/`key:` assignments, JWTs, and bearer tokens.
|
|
30
|
+
*
|
|
31
|
+
* @param text - the raw text.
|
|
32
|
+
* @returns the redacted text.
|
|
33
|
+
*/
|
|
34
|
+
export declare function redactSensitive(text: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* The one entry point for model-visible strings: redact first (secret values
|
|
37
|
+
* stop at control characters), then sanitize (control characters removed,
|
|
38
|
+
* tabs collapsed, length capped).
|
|
39
|
+
*
|
|
40
|
+
* @param text - the raw string.
|
|
41
|
+
* @param maxLength - truncation length.
|
|
42
|
+
* @returns the sanitized, redacted string.
|
|
43
|
+
*/
|
|
44
|
+
export declare function sanitizeVisible(text: string, maxLength: number): string;
|
|
45
|
+
//# sourceMappingURL=sanitize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sanitize.d.ts","sourceRoot":"","sources":["../../src/sanitize.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAiBH;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAIpE;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAIpE;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKpD;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAEvE"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The eight model tools dsh-click registers: two observers
|
|
3
|
+
* (`screen_shot`, `screen_read`), four window-scoped actions
|
|
4
|
+
* (`click`, `type`, `scroll`, `key`), and two application tools
|
|
5
|
+
* (`app_list`, `app_launch`). Observers are read-only; every action crosses
|
|
6
|
+
* {@link ActionExecutor} — freshness check, approval gate, process-identity
|
|
7
|
+
* check — before anything happens. Tool outputs are canonical JSON plus a
|
|
8
|
+
* pure text renderer; `screen_shot` additionally emits an image content block
|
|
9
|
+
* when the model accepts images (vision routing).
|
|
10
|
+
*
|
|
11
|
+
* @module dsh-click/tools
|
|
12
|
+
*/
|
|
13
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
14
|
+
import { ActionExecutor } from './actions.ts';
|
|
15
|
+
import type { ResolvedConfig } from './config.ts';
|
|
16
|
+
import { ObservationStore } from './observe.ts';
|
|
17
|
+
import type { DesktopBackend, Rect } from './platform/types.ts';
|
|
18
|
+
/** Everything one tool needs at runtime; injected by `src/index.ts`. */
|
|
19
|
+
export interface ToolServices {
|
|
20
|
+
/** The mounting context. */
|
|
21
|
+
readonly ctx: Context;
|
|
22
|
+
/** Resolved plugin config. */
|
|
23
|
+
readonly config: ResolvedConfig;
|
|
24
|
+
/** The active desktop backend. */
|
|
25
|
+
readonly backend: DesktopBackend;
|
|
26
|
+
/** The observation cache. */
|
|
27
|
+
readonly observations: ObservationStore;
|
|
28
|
+
/** The action executor. */
|
|
29
|
+
readonly actions: ActionExecutor;
|
|
30
|
+
}
|
|
31
|
+
/** The sanitized, model-visible window facts shared by observer outputs. */
|
|
32
|
+
export interface ObservedWindowValue {
|
|
33
|
+
windowId: number;
|
|
34
|
+
processId: number;
|
|
35
|
+
title: string;
|
|
36
|
+
className: string;
|
|
37
|
+
executablePath: string | null;
|
|
38
|
+
rect: Rect;
|
|
39
|
+
foreground: boolean;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* `screen_shot` — capture the addressed window (or the primary screen).
|
|
43
|
+
* In `imageMode: 'auto'` the result carries an image attachment when the
|
|
44
|
+
* current model accepts images; otherwise a text description keeps text-only
|
|
45
|
+
* models working.
|
|
46
|
+
*
|
|
47
|
+
* @param services - runtime services.
|
|
48
|
+
* @returns the tool definition.
|
|
49
|
+
*/
|
|
50
|
+
export declare function screenShotTool(services: ToolServices): import("@deepseek-ai/dsh-tools").ToolDefinition;
|
|
51
|
+
/**
|
|
52
|
+
* `screen_read` — the structured observation for text-only models: the
|
|
53
|
+
* window's accessibility tree plus pixel-location hints. The returned
|
|
54
|
+
* elementIds are what click/type/scroll address.
|
|
55
|
+
*
|
|
56
|
+
* @param services - runtime services.
|
|
57
|
+
* @returns the tool definition.
|
|
58
|
+
*/
|
|
59
|
+
export declare function screenReadTool(services: ToolServices): import("@deepseek-ai/dsh-tools").ToolDefinition;
|
|
60
|
+
/**
|
|
61
|
+
* `click` — click an element (by elementId) or a coordinate inside the
|
|
62
|
+
* observed window. Never steals foreground focus; delivery is UIA invoke
|
|
63
|
+
* where possible, posted window messages otherwise.
|
|
64
|
+
*
|
|
65
|
+
* @param services - runtime services.
|
|
66
|
+
* @returns the tool definition.
|
|
67
|
+
*/
|
|
68
|
+
export declare function clickTool(services: ToolServices): import("@deepseek-ai/dsh-tools").ToolDefinition;
|
|
69
|
+
/**
|
|
70
|
+
* `type` — type text into a value-pattern element. The helper backs up the
|
|
71
|
+
* control text first and restores it when the action fails (config
|
|
72
|
+
* `rollbackEnabled`).
|
|
73
|
+
*
|
|
74
|
+
* @param services - runtime services.
|
|
75
|
+
* @returns the tool definition.
|
|
76
|
+
*/
|
|
77
|
+
export declare function typeTool(services: ToolServices): import("@deepseek-ai/dsh-tools").ToolDefinition;
|
|
78
|
+
/**
|
|
79
|
+
* `scroll` — scroll an element (scroll pattern) or the observed window
|
|
80
|
+
* (posted wheel messages). Never steals foreground focus.
|
|
81
|
+
*
|
|
82
|
+
* @param services - runtime services.
|
|
83
|
+
* @returns the tool definition.
|
|
84
|
+
*/
|
|
85
|
+
export declare function scrollTool(services: ToolServices): import("@deepseek-ai/dsh-tools").ToolDefinition;
|
|
86
|
+
/**
|
|
87
|
+
* `key` — send a key combination to the observed window as posted window
|
|
88
|
+
* messages. Never steals foreground focus; apps that ignore posted input
|
|
89
|
+
* fail with a clear error.
|
|
90
|
+
*
|
|
91
|
+
* @param services - runtime services.
|
|
92
|
+
* @returns the tool definition.
|
|
93
|
+
*/
|
|
94
|
+
export declare function keyTool(services: ToolServices): import("@deepseek-ai/dsh-tools").ToolDefinition;
|
|
95
|
+
/**
|
|
96
|
+
* `app_list` — enumerate running desktop applications and their windows.
|
|
97
|
+
* Read-only: never needs approval.
|
|
98
|
+
*
|
|
99
|
+
* @param services - runtime services.
|
|
100
|
+
* @returns the tool definition.
|
|
101
|
+
*/
|
|
102
|
+
export declare function appListTool(services: ToolServices): import("@deepseek-ai/dsh-tools").ToolDefinition;
|
|
103
|
+
/**
|
|
104
|
+
* `app_launch` — launch one application by name or path. Gated by approval
|
|
105
|
+
* (allowlist matching applies against the requested name/path).
|
|
106
|
+
*
|
|
107
|
+
* @param services - runtime services.
|
|
108
|
+
* @returns the tool definition.
|
|
109
|
+
*/
|
|
110
|
+
export declare function appLaunchTool(services: ToolServices): import("@deepseek-ai/dsh-tools").ToolDefinition;
|
|
111
|
+
/** Every tool definition, in registration order. */
|
|
112
|
+
export declare function allTools(services: ToolServices): import("@deepseek-ai/dsh-tools").ToolDefinition[];
|
|
113
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAKlD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAG/C,OAAO,KAAK,EAAE,cAAc,EAA0B,IAAI,EAAyC,MAAM,qBAAqB,CAAA;AAE9H,wEAAwE;AACxE,MAAM,WAAW,YAAY;IAC3B,4BAA4B;IAC5B,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAA;IACrB,8BAA8B;IAC9B,QAAQ,CAAC,MAAM,EAAE,cA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` or released helpers
|
|
4
|
+
* report a stale plugin. Bumping `package.json` without touching this file
|
|
5
|
+
* fails `tests/version.spec.ts`, and `scripts/release.mjs` bumps both.
|
|
6
|
+
*
|
|
7
|
+
* @module dsh-click/version
|
|
8
|
+
*/
|
|
9
|
+
/** Plugin version advertised in the helper-protocol handshake. */
|
|
10
|
+
export declare const VERSION = "0.1.0";
|
|
11
|
+
/** The helper protocol revision; bump only on incompatible wire changes. */
|
|
12
|
+
export declare const HELPER_PROTOCOL_VERSION = 1;
|
|
13
|
+
//# sourceMappingURL=version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,kEAAkE;AAClE,eAAO,MAAM,OAAO,UAAU,CAAA;AAE9B,4EAA4E;AAC5E,eAAO,MAAM,uBAAuB,IAAI,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vision routing: whether the calling agent's model accepts image input.
|
|
3
|
+
* `screen_shot` uses this in `imageMode: 'auto'` to decide between an image
|
|
4
|
+
* block (vision model) and a text description (text-only model). Every
|
|
5
|
+
* failure — no agent, no llm service, no provider/model on the agent, adapter
|
|
6
|
+
* errors — resolves to `false`, so the text fallback is the fail-closed
|
|
7
|
+
* default.
|
|
8
|
+
*
|
|
9
|
+
* @module dsh-click/vision
|
|
10
|
+
*/
|
|
11
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
12
|
+
import type { Agent } from '@deepseek-ai/dsh-agent';
|
|
13
|
+
/**
|
|
14
|
+
* Resolve whether the calling agent's current model declares image input.
|
|
15
|
+
*
|
|
16
|
+
* @param agent - the calling agent (may be undefined).
|
|
17
|
+
* @param ctx - the mounting context.
|
|
18
|
+
* @param signal - cancellation for the model-info lookup.
|
|
19
|
+
* @returns true only when the resolved model declares the `image` modality.
|
|
20
|
+
*/
|
|
21
|
+
export declare function sessionAcceptsImages(agent: Agent | undefined, ctx: Context, signal?: AbortSignal): Promise<boolean>;
|
|
22
|
+
//# sourceMappingURL=vision.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vision.d.ts","sourceRoot":"","sources":["../../src/vision.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAGnD;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,CAazH"}
|