dsh-windows-parallel-mcp 0.8.2 → 0.9.0-rc.2
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.de.md +444 -419
- package/CHANGELOG.es.md +444 -419
- package/CHANGELOG.fr.md +444 -419
- package/CHANGELOG.it.md +444 -419
- package/CHANGELOG.ja.md +444 -419
- package/CHANGELOG.ko.md +444 -419
- package/CHANGELOG.md +965 -940
- package/CHANGELOG.pt.md +444 -419
- package/CHANGELOG.ru.md +444 -419
- package/CHANGELOG.zh.md +444 -419
- package/INSTALL.de.md +126 -126
- package/INSTALL.es.md +126 -126
- package/INSTALL.fr.md +126 -126
- package/INSTALL.it.md +126 -126
- package/INSTALL.ja.md +126 -126
- package/INSTALL.ko.md +126 -126
- package/INSTALL.md +122 -122
- package/INSTALL.pt.md +126 -126
- package/INSTALL.ru.md +126 -126
- package/INSTALL.zh.md +126 -126
- package/README.de.md +684 -684
- package/README.es.md +684 -684
- package/README.fr.md +684 -684
- package/README.it.md +684 -684
- package/README.ja.md +684 -684
- package/README.ko.md +684 -684
- package/README.md +680 -680
- package/README.pt.md +684 -684
- package/README.ru.md +684 -684
- package/README.zh.md +684 -684
- package/cordis.patch.yml +15 -15
- package/docs/refusals.md +90 -90
- package/docs/takeover.md +128 -128
- package/dsh.plugin.json +18 -18
- package/lib/config.js +275 -275
- package/lib/engine.js +252 -252
- package/lib/host-tools.js +365 -338
- package/lib/index.js +1275 -1249
- package/lib/peers-schemastery.js +23 -23
- package/lib/peers-tools.js +15 -15
- package/lib/proof-window.mjs +427 -427
- package/package.json +122 -122
- package/server.json +110 -110
- package/src/engine/decide.ps1 +356 -356
- package/src/engine/engine.ps1 +1208 -1208
- package/src/engine/hud.ps1 +411 -411
- package/src/engine/input-inject.ps1 +176 -176
- package/src/engine/overlay.ps1 +389 -389
- package/src/engine/takeover.ps1 +144 -144
- package/src/engine/win.ps1 +1881 -1881
- package/src/engine/worker.ps1 +310 -310
- package/src/schema/tools.json +533 -533
- package/types/index.d.ts +190 -187
package/lib/host-tools.js
CHANGED
|
@@ -1,338 +1,365 @@
|
|
|
1
|
-
// host-tools.js — the one host-provided helper this plugin needs, with a fallback that is not a lie.
|
|
2
|
-
//
|
|
3
|
-
// WHY A FALLBACK AT ALL. `defineTool` lives in `@deepseek-ai/dsh-tools`, a peer the host provides.
|
|
4
|
-
// Peer resolution for a plugin loaded out of the profile's node_modules is the host's business, not
|
|
5
|
-
// the plugin's, and it is not something this package can verify from inside itself: a static import
|
|
6
|
-
// turns "the host resolves peers differently than I assumed" into "the plugin fails to load, with no
|
|
7
|
-
// tool and no message". So the import is dynamic, and when it fails the local shim takes over.
|
|
8
|
-
//
|
|
9
|
-
// WHAT THE SHIM IS AND IS NOT. It is NOT a reimplementation of the host's tool runtime: it builds the
|
|
10
|
-
// same registry-ready shape from the same simplified parameter spec (per-field `type` / `description`
|
|
11
|
-
// / `enum` / `required: true`, exactly the shape dsh-bash-terminal-ts passes) and validates arguments
|
|
12
|
-
// against it, because a schema that nothing validates is a description, not a contract. What it does
|
|
13
|
-
// not do is the host's own error branding and presentation hooks; those are additive.
|
|
14
|
-
//
|
|
15
|
-
// REFUSALS ARE NOT ERRORS HERE. The engine answers refusals as normal results carrying a code
|
|
16
|
-
// (decide.ps1's closed set). This layer must not convert them into thrown exceptions -- a thrown
|
|
17
|
-
// error would reach the model as a tool failure, and the whole point of the refusal vocabulary is
|
|
18
|
-
// that the caller can branch on the code and read the next step.
|
|
19
|
-
export const TOOL_NAME = 'wpm';
|
|
20
|
-
|
|
21
|
-
/** The eleven actions, in the order the contract lists them. */
|
|
22
|
-
export const ACTIONS = ['windows', 'click', 'type', 'focus', 'status', 'snapshot', 'screenshot', 'preview',
|
|
23
|
-
'launch', 'clipboard', 'window'];
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* One field of the simplified parameter spec -- the shape the host's `defineTool` consumes and the
|
|
27
|
-
* shape `parametersToJsonSchema` translates. `required` is optional HERE and mandatory in the
|
|
28
|
-
* registered JSON Schema, which is the whole reason `parametersToJsonSchema` destructures it out:
|
|
29
|
-
* spelling that with a per-field object literal instead would make `field.required` a property that
|
|
30
|
-
* does not exist on most members (TS2339), i.e. the checker saying what the data already says.
|
|
31
|
-
* @typedef {object} ParamSpec
|
|
32
|
-
* @property {'string'|'number'|'boolean'} type
|
|
33
|
-
* @property {string} [description]
|
|
34
|
-
* @property {string[]} [enum]
|
|
35
|
-
* @property {boolean} [required]
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
*
|
|
40
|
-
* @
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
*
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
+ '
|
|
62
|
-
+ '
|
|
63
|
-
+ '
|
|
64
|
-
+ '
|
|
65
|
-
+ '
|
|
66
|
-
+ '
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
'
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
'
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
type: '
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
},
|
|
158
|
-
|
|
159
|
-
type: '
|
|
160
|
-
description:
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
description:
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
description:
|
|
224
|
-
'
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
*
|
|
256
|
-
*
|
|
257
|
-
* @param {
|
|
258
|
-
* @returns {
|
|
259
|
-
*/
|
|
260
|
-
export function
|
|
261
|
-
/** @type {string
|
|
262
|
-
const
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
1
|
+
// host-tools.js — the one host-provided helper this plugin needs, with a fallback that is not a lie.
|
|
2
|
+
//
|
|
3
|
+
// WHY A FALLBACK AT ALL. `defineTool` lives in `@deepseek-ai/dsh-tools`, a peer the host provides.
|
|
4
|
+
// Peer resolution for a plugin loaded out of the profile's node_modules is the host's business, not
|
|
5
|
+
// the plugin's, and it is not something this package can verify from inside itself: a static import
|
|
6
|
+
// turns "the host resolves peers differently than I assumed" into "the plugin fails to load, with no
|
|
7
|
+
// tool and no message". So the import is dynamic, and when it fails the local shim takes over.
|
|
8
|
+
//
|
|
9
|
+
// WHAT THE SHIM IS AND IS NOT. It is NOT a reimplementation of the host's tool runtime: it builds the
|
|
10
|
+
// same registry-ready shape from the same simplified parameter spec (per-field `type` / `description`
|
|
11
|
+
// / `enum` / `required: true`, exactly the shape dsh-bash-terminal-ts passes) and validates arguments
|
|
12
|
+
// against it, because a schema that nothing validates is a description, not a contract. What it does
|
|
13
|
+
// not do is the host's own error branding and presentation hooks; those are additive.
|
|
14
|
+
//
|
|
15
|
+
// REFUSALS ARE NOT ERRORS HERE. The engine answers refusals as normal results carrying a code
|
|
16
|
+
// (decide.ps1's closed set). This layer must not convert them into thrown exceptions -- a thrown
|
|
17
|
+
// error would reach the model as a tool failure, and the whole point of the refusal vocabulary is
|
|
18
|
+
// that the caller can branch on the code and read the next step.
|
|
19
|
+
export const TOOL_NAME = 'wpm';
|
|
20
|
+
|
|
21
|
+
/** The eleven actions, in the order the contract lists them. */
|
|
22
|
+
export const ACTIONS = ['windows', 'click', 'type', 'focus', 'status', 'snapshot', 'screenshot', 'preview',
|
|
23
|
+
'launch', 'clipboard', 'window'];
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* One field of the simplified parameter spec -- the shape the host's `defineTool` consumes and the
|
|
27
|
+
* shape `parametersToJsonSchema` translates. `required` is optional HERE and mandatory in the
|
|
28
|
+
* registered JSON Schema, which is the whole reason `parametersToJsonSchema` destructures it out:
|
|
29
|
+
* spelling that with a per-field object literal instead would make `field.required` a property that
|
|
30
|
+
* does not exist on most members (TS2339), i.e. the checker saying what the data already says.
|
|
31
|
+
* @typedef {object} ParamSpec
|
|
32
|
+
* @property {'string'|'number'|'boolean'} type
|
|
33
|
+
* @property {string} [description]
|
|
34
|
+
* @property {string[]} [enum]
|
|
35
|
+
* @property {boolean} [required]
|
|
36
|
+
* @property {boolean} [integer] whole numbers only -- `type` stays 'number' because that is all the
|
|
37
|
+
* host's simplified spec names, so this flag is what tells the validator (and the model) that a
|
|
38
|
+
* fraction is a violation rather than something to round on the caller's behalf.
|
|
39
|
+
* @property {number} [minimum]
|
|
40
|
+
* @property {number} [maximum]
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The JSON Schema this plugin registers, as `parametersToJsonSchema` builds it.
|
|
45
|
+
* @typedef {object} SimplifiedSchema
|
|
46
|
+
* @property {string} [type]
|
|
47
|
+
* @property {Record<string, ParamSpec>} [properties]
|
|
48
|
+
* @property {string[]} [required]
|
|
49
|
+
* @property {boolean} [additionalProperties]
|
|
50
|
+
*/
|
|
51
|
+
|
|
52
|
+
/** Simplified parameter spec — the same shape the host's `defineTool` consumes. */
|
|
53
|
+
/** @type {Record<string, ParamSpec>} */
|
|
54
|
+
export const PARAMETERS = {
|
|
55
|
+
action: {
|
|
56
|
+
type: 'string',
|
|
57
|
+
enum: ACTIONS,
|
|
58
|
+
required: true,
|
|
59
|
+
description:
|
|
60
|
+
'windows: list live windows that can be driven (hwnd, title, class, pid, rect). '
|
|
61
|
+
+ 'status: read the focus table (foreground window, focused control, last human input age, paused flag). '
|
|
62
|
+
+ 'click: click at a screen coordinate inside the target. type: write text into the target. '
|
|
63
|
+
+ 'focus: move keyboard focus to a named control inside the target. '
|
|
64
|
+
+ 'snapshot: read the accessibility tree as a numbered element table (labels you can act on). '
|
|
65
|
+
+ 'screenshot: capture the target rect to a PNG and return its coordinate mapping as data. '
|
|
66
|
+
+ 'preview: draw the marker at a point and report the element under it, without clicking. '
|
|
67
|
+
+ 'launch: start a program by name or path (needs appLaunchAllowed AND an exact whitelist entry; '
|
|
68
|
+
+ 'refused with app_launch_denied before any worker call otherwise). '
|
|
69
|
+
+ 'clipboard: read or write the system clipboard (read reports lengths, never contents). '
|
|
70
|
+
+ 'window: minimize/restore/move/resize/topmost ONE window named by hwnd, verified by reading its '
|
|
71
|
+
+ 'real state back.',
|
|
72
|
+
},
|
|
73
|
+
hwnd: {
|
|
74
|
+
type: 'string',
|
|
75
|
+
description: 'Target top-level window handle from action=windows. Required by click, type and focus.',
|
|
76
|
+
},
|
|
77
|
+
x: { type: 'number', integer: true, description: 'Screen X coordinate, whole physical pixels (click/preview/window). Must resolve to a child of the target, or the action is refused.' },
|
|
78
|
+
y: { type: 'number', integer: true, description: 'Screen Y coordinate, whole physical pixels (click/preview/window).' },
|
|
79
|
+
text: { type: 'string', description: 'Text to write (type only). The message tier inserts at the control\'s caret (position 0 when it was never focused); replace:true rewrites the whole value instead. An empty string is refused: it cannot be distinguished from a channel that silently did nothing.' },
|
|
80
|
+
elementName: {
|
|
81
|
+
type: 'string',
|
|
82
|
+
description:
|
|
83
|
+
'UIA Name or AutomationId of the control to address (type/focus). Naming an element forces the UIA tier, '
|
|
84
|
+
+ 'because a window message cannot address "the control called X".',
|
|
85
|
+
},
|
|
86
|
+
replace: { type: 'boolean', description: 'Replace the existing value instead of appending (type only).' },
|
|
87
|
+
// ---- 0.6.0: where the caret goes, and what the engine reads back afterwards ------------------
|
|
88
|
+
// The description names the syscall because the parameter is a syscall argument, and it names the
|
|
89
|
+
// measured exception because '-1 means the end' is a documentation sentence that WinForms EDIT does
|
|
90
|
+
// not honour (findings 8.2). A caller reading this should be able to predict the result exactly.
|
|
91
|
+
caretPosition: {
|
|
92
|
+
type: 'string',
|
|
93
|
+
enum: ['idle', 'start', 'end'],
|
|
94
|
+
description:
|
|
95
|
+
'type only, message door: where the caret sits before the characters are sent. "idle" (default) touches nothing -- ' +
|
|
96
|
+
'the caret is where the control left it, which for a never-focused field is position 0 (measured), so "idle" is not "start". ' +
|
|
97
|
+
'"start" is EM_SETSEL(0,0); "end" is EM_SETSEL(len,len) with len read from the control, because the documented -1 form is a no-op ' +
|
|
98
|
+
'on WinForms EDIT. On a buffer containing newlines the numeric end can land inside the text, so the result reports the requested ' +
|
|
99
|
+
'and the applied pair (caret=end asked=6 applied=4,4) and the readback decides. The UIA value channel replaces the whole value and ' +
|
|
100
|
+
'has no caret to move -- it answers caretIgnored=value-pattern instead of pretending it honoured this.',
|
|
101
|
+
},
|
|
102
|
+
settleMs: { type: 'number', integer: true, minimum: 0, maximum: 2000, description: 'How long to let the app commit its state before the effect is judged (0-2000, default 350).' },
|
|
103
|
+
// ---- R3. Every one of these costs the owner something real, so each description says so: a caller
|
|
104
|
+
// that asks for takeover has to know it moves the pointer and needs the HUD up.
|
|
105
|
+
takeover: {
|
|
106
|
+
type: 'boolean',
|
|
107
|
+
description:
|
|
108
|
+
'Take the takeover tier: the REAL cursor moves to the action point (so the owner can see where the '
|
|
109
|
+
+ 'agent is pointing) and is always restored afterwards, the focus is held until the action ends, '
|
|
110
|
+
+ 'and a three-phase HUD is shown with a stop button and a global abort key. Requires the '
|
|
111
|
+
+ 'takeoverAllowed setting, otherwise it is refused with takeover_unavailable (it never degrades '
|
|
112
|
+
+ 'silently into the quiet tier). Interruptible three ways: HUD button, abort key, host cancellation.',
|
|
113
|
+
},
|
|
114
|
+
takeoverMaxMs: {
|
|
115
|
+
type: 'number',
|
|
116
|
+
integer: true,
|
|
117
|
+
minimum: 500,
|
|
118
|
+
maximum: 60000,
|
|
119
|
+
description: 'Takeover only: how long the action may hold the cursor/focus (500-60000, default 10000). The HUD counts up to it.',
|
|
120
|
+
},
|
|
121
|
+
keyInput: {
|
|
122
|
+
type: 'string',
|
|
123
|
+
enum: ['none', 'inject'],
|
|
124
|
+
description:
|
|
125
|
+
'Takeover only: "inject" types the text with synthetic KEYBOARD input (SendInput, Unicode) into the '
|
|
126
|
+
+ 'foreground window, for targets with no message door and no UIA pattern (terminals). Requires '
|
|
127
|
+
+ 'takeover:true and the keyInjectAllowed setting; the target must be the foreground window or the '
|
|
128
|
+
+ 'call is refused with keyinject_unavailable. Never moves the mouse, never clicks. The result '
|
|
129
|
+
+ 'reports effect=reported-by-send, not "verified".',
|
|
130
|
+
},
|
|
131
|
+
// ---- 0.5.0: the frame / label / image-coordinate surface -----------------------------------
|
|
132
|
+
// Every description below says what the field costs or what it refuses, because each one exists to
|
|
133
|
+
// remove a way for the caller to silently act on the wrong thing.
|
|
134
|
+
label: {
|
|
135
|
+
type: 'number',
|
|
136
|
+
integer: true,
|
|
137
|
+
minimum: 1,
|
|
138
|
+
description:
|
|
139
|
+
'Element number from action=snapshot (click/type/focus). The label is resolved back to the UIA '
|
|
140
|
+
+ 'ELEMENT by RuntimeId, so the action still takes the silent pattern path instead of degrading to '
|
|
141
|
+
+ 'a coordinate click. For click, x/y stay required and must fall inside the labelled element, so '
|
|
142
|
+
+ '"the point is the contract" remains true.',
|
|
143
|
+
},
|
|
144
|
+
snapId: {
|
|
145
|
+
type: 'string',
|
|
146
|
+
description:
|
|
147
|
+
'The snapId the label came from. A label whose snapId has been superseded is refused with '
|
|
148
|
+
+ 'stale_ref: element numbers only mean something in the frame that printed them.',
|
|
149
|
+
},
|
|
150
|
+
space: {
|
|
151
|
+
type: 'string',
|
|
152
|
+
enum: ['screen', 'image'],
|
|
153
|
+
description:
|
|
154
|
+
'Coordinate space of click x/y. "screen" (default) is physical screen pixels. "image" means image '
|
|
155
|
+
+ 'pixels from the screenshot named by shotId -- the ENGINE converts them, so the caller never '
|
|
156
|
+
+ 'multiplies a scale factor; the point-ownership assertion still runs after conversion.',
|
|
157
|
+
},
|
|
158
|
+
shotId: {
|
|
159
|
+
type: 'string',
|
|
160
|
+
description:
|
|
161
|
+
'The shotId from action=screenshot. Required when space="image" (refused before any worker call); '
|
|
162
|
+
+ 'an id that was already cleaned up by the retention policy is refused with stale_ref.',
|
|
163
|
+
},
|
|
164
|
+
maxElements: {
|
|
165
|
+
type: 'number',
|
|
166
|
+
integer: true,
|
|
167
|
+
minimum: 1,
|
|
168
|
+
maximum: 5000,
|
|
169
|
+
description: 'snapshot only: hard cap on returned elements (1-5000, default 300). The text then says "truncated at N of M" and truncated is true.',
|
|
170
|
+
},
|
|
171
|
+
interactableOnly: {
|
|
172
|
+
type: 'boolean',
|
|
173
|
+
description: 'snapshot only (default true): return only elements exposing a usable UIA pattern. false returns the whole visible tree.',
|
|
174
|
+
},
|
|
175
|
+
sinceSnapId: {
|
|
176
|
+
type: 'string',
|
|
177
|
+
description: 'snapshot only: return an added/removed/changed diff against this earlier snapId instead of the whole table. An unchanged tree yields an empty delta.',
|
|
178
|
+
},
|
|
179
|
+
intent: {
|
|
180
|
+
type: 'string',
|
|
181
|
+
description: 'snapshot only: what this frame is FOR. It travels with the frame so a deciding subagent can answer with a single label.',
|
|
182
|
+
},
|
|
183
|
+
fullScreen: {
|
|
184
|
+
type: 'boolean',
|
|
185
|
+
description: 'screenshot only (default false): capture the whole virtual screen instead of one window. Off by default so the owner\'s desktop is never captured silently.',
|
|
186
|
+
},
|
|
187
|
+
maxWidth: {
|
|
188
|
+
type: 'number',
|
|
189
|
+
integer: true,
|
|
190
|
+
minimum: 0,
|
|
191
|
+
maximum: 7680,
|
|
192
|
+
description: 'screenshot only: downscale the saved image to at most this width (0 = no scaling, default). Scaling changes the coordinate system, so it must be asked for explicitly and is reported as scale.',
|
|
193
|
+
},
|
|
194
|
+
// ---- 0.7.0 desktop actions -----------------------------------------------------------------
|
|
195
|
+
// Every description states the gate it falls under, because these three are the first actions whose
|
|
196
|
+
// refusal is about a SETTING rather than about the target, and a caller that cannot see which gate
|
|
197
|
+
// blocked it will retry forever.
|
|
198
|
+
target: {
|
|
199
|
+
type: 'string',
|
|
200
|
+
description:
|
|
201
|
+
'launch only: the program to start -- an exact name on the appLaunchAllow whitelist ("notepad") or an '
|
|
202
|
+
+ 'absolute exe path that appears in the list verbatim. Matched case-insensitively and IN FULL: '
|
|
203
|
+
+ '"notepad" does not authorise "notepad-helper.exe", and no wildcard exists. Refused with '
|
|
204
|
+
+ 'app_launch_denied when appLaunchAllowed is off or the name is not listed, before any worker request.',
|
|
205
|
+
},
|
|
206
|
+
args: {
|
|
207
|
+
type: 'string',
|
|
208
|
+
description:
|
|
209
|
+
'launch only: one command line for the program, passed through as given. It is NOT parsed by the '
|
|
210
|
+
+ 'whitelist -- listing a program does not vouch for its arguments, which is why every launch is '
|
|
211
|
+
+ 'written to the audit log with its arguments attached.',
|
|
212
|
+
},
|
|
213
|
+
waitMs: {
|
|
214
|
+
type: 'number',
|
|
215
|
+
integer: true,
|
|
216
|
+
minimum: 0,
|
|
217
|
+
maximum: 30000,
|
|
218
|
+
description: 'launch only: how long to wait for the started process to publish a top-level window (0-30000, default 3000). A window that has not appeared answers ok:true with hwnd="" and detail=window-not-yet -- the program DID start, and pretending otherwise would be a different lie.',
|
|
219
|
+
},
|
|
220
|
+
op: {
|
|
221
|
+
type: 'string',
|
|
222
|
+
enum: ['read', 'write', 'minimize', 'restore', 'move', 'resize', 'topmost'],
|
|
223
|
+
description:
|
|
224
|
+
'clipboard: "read" or "write". window: "minimize", "restore", "move", "resize", "topmost". Each op is ' +
|
|
225
|
+
'verified by reading the window back (IsIconic / the rect / the ex-style), not by the call\'s return ' +
|
|
226
|
+
'value, so a syscall that said yes while the window said no is reported as verified=false.',
|
|
227
|
+
},
|
|
228
|
+
format: {
|
|
229
|
+
type: 'string',
|
|
230
|
+
enum: ['text', 'image'],
|
|
231
|
+
description: 'clipboard only (default text). "image" read returns a PNG under %LOCALAPPDATA%\\wpm\\clipboard and reports its size; "image" write takes a shotId from action=screenshot. Text reads are capped at 64 KB and a longer payload says truncated.',
|
|
232
|
+
},
|
|
233
|
+
width: { type: 'number', integer: true, minimum: 1, description: 'window only: the width to resize to (resize). The result reports what the window actually became, which may be a clamp.' },
|
|
234
|
+
height: { type: 'number', integer: true, minimum: 1, description: 'window only: the height to resize to (resize).' },
|
|
235
|
+
// ---- 0.7.0 the escape hatch on the idle check ------------------------------------------------
|
|
236
|
+
// It exists because an unattended run is the case that MUST still work, and because a caller that is
|
|
237
|
+
// blocked with no way forward will simply look for a way around the plugin. Making the override an
|
|
238
|
+
// explicit argument rather than a hidden retry keeps it visible: it is written to the audit log with
|
|
239
|
+
// forced=true, so a run that typed over someone's keyboard is attributable afterwards.
|
|
240
|
+
forceUserActive: {
|
|
241
|
+
type: 'boolean',
|
|
242
|
+
description:
|
|
243
|
+
'Override the idle check (user_active) for THIS call: "start it even though the owner is at the keyboard". '
|
|
244
|
+
+ 'Has an effect only on actions that need the takeover tier (takeover:true, keyInput:"inject", launch). '
|
|
245
|
+
+ 'It does NOT bypass policy, takeoverAllowed, keyInjectAllowed or the launch whitelist, and the audit '
|
|
246
|
+
+ 'line records forced:true, so an interruption you caused on purpose stays distinguishable from one '
|
|
247
|
+
+ 'the plugin caused by accident.',
|
|
248
|
+
},
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Build a JSON Schema from the simplified spec.
|
|
253
|
+
*
|
|
254
|
+
* Kept separate and exported so test/schema-test.mjs can compare the shape this plugin registers
|
|
255
|
+
* against src/schema/tools.json: the contract file is the source of truth, and a divergence between
|
|
256
|
+
* "what the model is told" and "what the registry accepts" is invisible until a call is rejected.
|
|
257
|
+
* @param {Record<string, ParamSpec>} [spec]
|
|
258
|
+
* @returns {SimplifiedSchema}
|
|
259
|
+
*/
|
|
260
|
+
export function parametersToJsonSchema(spec = PARAMETERS) {
|
|
261
|
+
/** @type {Record<string, any>} */
|
|
262
|
+
const properties = {};
|
|
263
|
+
/** @type {string[]} */
|
|
264
|
+
const required = [];
|
|
265
|
+
for (const [name, field] of Object.entries(spec)) {
|
|
266
|
+
const { required: isRequired, ...rest } = field;
|
|
267
|
+
properties[name] = rest;
|
|
268
|
+
if (isRequired) required.push(name);
|
|
269
|
+
}
|
|
270
|
+
return { type: 'object', properties, required, additionalProperties: false };
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Minimal argument validation. Returns a list of human-readable violations, empty when valid.
|
|
275
|
+
* @param {SimplifiedSchema} schema
|
|
276
|
+
* @param {any} args
|
|
277
|
+
* @returns {string[]}
|
|
278
|
+
*/
|
|
279
|
+
export function validateArguments(schema, args) {
|
|
280
|
+
/** @type {string[]} */
|
|
281
|
+
const problems = [];
|
|
282
|
+
if (args === null || typeof args !== 'object' || Array.isArray(args)) return ['arguments must be an object'];
|
|
283
|
+
for (const name of schema.required ?? []) {
|
|
284
|
+
if (args[name] === undefined || args[name] === null) problems.push(`missing required argument '${name}'`);
|
|
285
|
+
}
|
|
286
|
+
for (const [name, value] of Object.entries(args)) {
|
|
287
|
+
const field = schema.properties?.[name];
|
|
288
|
+
if (!field) {
|
|
289
|
+
problems.push(`unknown argument '${name}'`);
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
292
|
+
if (value === undefined || value === null) continue;
|
|
293
|
+
if (field.type === 'string' && typeof value !== 'string') problems.push(`'${name}' must be a string`);
|
|
294
|
+
if (field.type === 'number' && typeof value !== 'number') problems.push(`'${name}' must be a number`);
|
|
295
|
+
if (field.type === 'boolean' && typeof value !== 'boolean') problems.push(`'${name}' must be a boolean`);
|
|
296
|
+
// Range and integer checks ride the same schema the model is shown: an out-of-range argument that
|
|
297
|
+
// gets silently clamped (maxElements: 99999 -> 5000) or rounded (label: 2.7 -> 3) is the caller
|
|
298
|
+
// acting on a value it never asked for -- a violation names the got-value instead.
|
|
299
|
+
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
300
|
+
if (field.integer === true && !Number.isInteger(value)) problems.push(`'${name}' must be a whole number (got ${value})`);
|
|
301
|
+
if (field.minimum !== undefined && value < field.minimum) problems.push(`'${name}' must be >= ${field.minimum} (got ${value})`);
|
|
302
|
+
if (field.maximum !== undefined && value > field.maximum) problems.push(`'${name}' must be <= ${field.maximum} (got ${value})`);
|
|
303
|
+
}
|
|
304
|
+
if (Array.isArray(field.enum) && !field.enum.includes(value)) {
|
|
305
|
+
problems.push(`'${name}' must be one of ${field.enum.join(', ')}`);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
return problems;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* The local shim: same input, same registry-ready output shape.
|
|
313
|
+
* @param {{name: string, description: string, parameters: Record<string, ParamSpec>,
|
|
314
|
+
* output: {schema: any, render: any}, execute: (args: any, exec: any) => any}} options
|
|
315
|
+
* @returns {any}
|
|
316
|
+
*/
|
|
317
|
+
export function localDefineTool(options) {
|
|
318
|
+
const parameters = parametersToJsonSchema(options.parameters);
|
|
319
|
+
const userExecute = options.execute;
|
|
320
|
+
return {
|
|
321
|
+
name: options.name,
|
|
322
|
+
description: options.description,
|
|
323
|
+
parameters,
|
|
324
|
+
output: {
|
|
325
|
+
schema: options.output.schema,
|
|
326
|
+
render: options.output.render,
|
|
327
|
+
},
|
|
328
|
+
// THE SECOND ARGUMENT IS THE CALL CONTEXT, and dropping it silently disables cancellation: the plugin
|
|
329
|
+
// asks the host for `exec.signal` to abort a takeover in flight, and a wrapper that forwards only
|
|
330
|
+
// `args` makes that code path unreachable -- the abort arrives, nothing is listening, and the call
|
|
331
|
+
// runs to completion. Measured: the first version of this shim did exactly that, and test/signal-test.mjs
|
|
332
|
+
// caught it as "the cancellation was not reported" while everything else looked green.
|
|
333
|
+
/** @param {any} args @param {any} exec @returns {Promise<any>} */
|
|
334
|
+
async execute(args, exec) {
|
|
335
|
+
const problems = validateArguments(parameters, args);
|
|
336
|
+
if (problems.length) {
|
|
337
|
+
const err = new Error(`${options.name}: ${problems.join('; ')}`);
|
|
338
|
+
err.name = 'ToolArgsError';
|
|
339
|
+
throw err;
|
|
340
|
+
}
|
|
341
|
+
return userExecute(args, exec);
|
|
342
|
+
},
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Resolve the host's `defineTool`, falling back to the local shim.
|
|
348
|
+
* Returns `{ defineTool, source }` so the plugin can log which one it got -- a silent fallback is how
|
|
349
|
+
* "runs on my machine" diverges from "runs on the host".
|
|
350
|
+
*/
|
|
351
|
+
export async function resolveDefineTool() {
|
|
352
|
+
// The peer is reached through ./peers-tools.js with a STATIC import -- the host's loader resolves
|
|
353
|
+
// the bare specifier there, while a dynamic `import('@deepseek-ai/dsh-tools')` from a
|
|
354
|
+
// `link:`-installed package resolves upward from the link target and never reaches the profile's
|
|
355
|
+
// node_modules. peers-tools.js throwing means dsh-tools genuinely is not installed (this desktop
|
|
356
|
+
// profile: it is not): the shim takes over and `source` says so. See peers-schemastery.js for why
|
|
357
|
+
// the two peers have separate bridges.
|
|
358
|
+
try {
|
|
359
|
+
const mod = await import('./peers-tools.js');
|
|
360
|
+
if (mod && typeof mod.defineTool === 'function') return { defineTool: mod.defineTool, source: '@deepseek-ai/dsh-tools' };
|
|
361
|
+
} catch {
|
|
362
|
+
// Documented fallback, reported via `source`.
|
|
363
|
+
}
|
|
364
|
+
return { defineTool: localDefineTool, source: 'local-shim' };
|
|
365
|
+
}
|