@burdenoff/ui-engine 2026.1204.1 → 2026.1204.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/README.md +20 -2
- package/dist/analyze/analyze.d.ts +10 -0
- package/dist/analyze/context.d.ts +25 -9
- package/dist/analyze/index.d.ts +3 -2
- package/dist/analyze/messages.d.ts +2 -0
- package/dist/analyze/rules/run-command-from-variable.d.ts +2 -0
- package/dist/analyze/rules/single-method-image-target.d.ts +7 -0
- package/dist/analyze/sensitive.d.ts +2 -2
- package/dist/analyze/types.d.ts +6 -2
- package/dist/analyze.js +4 -2
- package/dist/desk.d.ts +13 -0
- package/dist/desk.js +29 -0
- package/dist/dom-runtime.iife.js +1 -1
- package/dist/dom-runtime.js +2 -2
- package/dist/drivers/desk-backend.d.ts +40 -0
- package/dist/drivers/desk-driver.d.ts +41 -0
- package/dist/drivers/desk-errors.d.ts +19 -0
- package/dist/drivers/desk-tree.d.ts +28 -0
- package/dist/drivers/desk-wire.d.ts +237 -0
- package/dist/drivers/index.d.ts +3 -1
- package/dist/drivers.js +10 -7
- package/dist/heal.js +5 -5
- package/dist/index-0ps53dhe.js +85 -0
- package/dist/{index-ptrmf779.js → index-2q0hh6we.js} +3 -3
- package/dist/index-552x2bnm.js +56 -0
- package/dist/index-6m0chbhq.js +64 -0
- package/dist/{index-dwp10g62.js → index-7gfzv5n8.js} +96 -53
- package/dist/{index-gvavb597.js → index-93hfbk5c.js} +10 -0
- package/dist/index-a8s39bse.js +920 -0
- package/dist/index-b5a306v7.js +43 -0
- package/dist/index-bx4bsvg0.js +458 -0
- package/dist/{index-9xgz8dxt.js → index-cc49ykn5.js} +4 -4
- package/dist/{index-vpm1gnmy.js → index-e557vzdd.js} +219 -34
- package/dist/{index-vnv9tp11.js → index-e7pgqd60.js} +2 -2
- package/dist/index-hdq3y007.js +246 -0
- package/dist/{index-zagmp5ya.js → index-n3nfhjrj.js} +2 -2
- package/dist/{index-wnch00m6.js → index-nmsg2wze.js} +2 -2
- package/dist/{index-zhbwhdya.js → index-q2jbva7c.js} +5 -3
- package/dist/{index-n7ah1jn7.js → index-rbem2yms.js} +16 -243
- package/dist/{index-mhv6a02p.js → index-reef7e8m.js} +1 -1
- package/dist/{index-3r2y0mnc.js → index-wdbn4xjc.js} +5 -5
- package/dist/{index-8eb4xd1j.js → index-x8fc4r4h.js} +101 -426
- package/dist/{index-0tfzfxx9.js → index-yhzykhdj.js} +1 -43
- package/dist/{index-t55wvhvh.js → index-z2v8prer.js} +1 -61
- package/dist/{index-5pv673wd.js → index-zj3zhbac.js} +2 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +79 -31
- package/dist/interpret/driver.d.ts +109 -18
- package/dist/interpret/events.d.ts +5 -2
- package/dist/interpret/index.d.ts +4 -3
- package/dist/interpret/run.d.ts +28 -1
- package/dist/interpret.js +16 -9
- package/dist/script/adapters/recording-desktop.d.ts +52 -0
- package/dist/script/describe.d.ts +7 -2
- package/dist/script/desk-roles.d.ts +33 -0
- package/dist/script/desktop-capabilities.d.ts +7 -2
- package/dist/script/desktop-schema.d.ts +2 -0
- package/dist/script/index.d.ts +3 -1
- package/dist/script.js +35 -19
- package/dist/target/types.d.ts +10 -4
- package/dist/target.js +20 -16
- package/dist/testing.js +5 -3
- package/package.json +7 -3
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// src/interpret/driver.ts
|
|
2
|
+
function abortError() {
|
|
3
|
+
const error = new Error("The run was cancelled");
|
|
4
|
+
error.name = "AbortError";
|
|
5
|
+
return error;
|
|
6
|
+
}
|
|
7
|
+
var realClock2 = {
|
|
8
|
+
now: () => Date.now(),
|
|
9
|
+
sleep: (ms, signal) => new Promise((resolve, reject) => {
|
|
10
|
+
if (signal?.aborted) {
|
|
11
|
+
reject(abortError());
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const timer = setTimeout(() => {
|
|
15
|
+
signal?.removeEventListener("abort", onAbort);
|
|
16
|
+
resolve();
|
|
17
|
+
}, Math.max(0, ms));
|
|
18
|
+
const onAbort = () => {
|
|
19
|
+
clearTimeout(timer);
|
|
20
|
+
reject(abortError());
|
|
21
|
+
};
|
|
22
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
23
|
+
})
|
|
24
|
+
};
|
|
25
|
+
function createVirtualClock2(start = 0) {
|
|
26
|
+
let time = start;
|
|
27
|
+
return {
|
|
28
|
+
now: () => time,
|
|
29
|
+
sleep: async (ms, signal) => {
|
|
30
|
+
if (signal?.aborted)
|
|
31
|
+
throw abortError();
|
|
32
|
+
time += Math.max(0, ms);
|
|
33
|
+
await Promise.resolve();
|
|
34
|
+
if (signal?.aborted)
|
|
35
|
+
throw abortError();
|
|
36
|
+
},
|
|
37
|
+
advance: (ms) => {
|
|
38
|
+
time += Math.max(0, ms);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { realClock2, createVirtualClock2 };
|
|
@@ -0,0 +1,458 @@
|
|
|
1
|
+
import {
|
|
2
|
+
sha256Hex2
|
|
3
|
+
} from "./index-dcs2pe49.js";
|
|
4
|
+
import {
|
|
5
|
+
MAX_DESK_SELECTOR_STRING2,
|
|
6
|
+
MAX_DESK_TEXT_TARGET2,
|
|
7
|
+
canonicalJson2
|
|
8
|
+
} from "./index-zj3zhbac.js";
|
|
9
|
+
import {
|
|
10
|
+
UI_SCRIPT_VERSION2
|
|
11
|
+
} from "./index-20bbwwc9.js";
|
|
12
|
+
import {
|
|
13
|
+
walkSteps2,
|
|
14
|
+
stepTargets2
|
|
15
|
+
} from "./index-axph39g0.js";
|
|
16
|
+
|
|
17
|
+
// src/script/hash.ts
|
|
18
|
+
var UI_SCRIPT_SCHEMA_HASH2 = "e6860649ad1cba906fb704ce4b62b3ea4380203e6628c809571602f4d0947884";
|
|
19
|
+
var DESKTOP_SCRIPT_SCHEMA_HASH2 = "a1c55895922b0389e04931ba4a2b4f6f9c487e553890ff987ba4527cf9897fce";
|
|
20
|
+
function schemaHashOf2(jsonSchema) {
|
|
21
|
+
return sha256Hex2(canonicalJson2(jsonSchema));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// src/script/desktop-capabilities.ts
|
|
25
|
+
var DESKTOP_DESK_CONTRACT_VERSION2 = 3;
|
|
26
|
+
var DESK_ACTION_NAMES2 = [
|
|
27
|
+
"screenshot",
|
|
28
|
+
"snapshot",
|
|
29
|
+
"click",
|
|
30
|
+
"type",
|
|
31
|
+
"secret_fill",
|
|
32
|
+
"key",
|
|
33
|
+
"scroll",
|
|
34
|
+
"navigate",
|
|
35
|
+
"focus_window",
|
|
36
|
+
"shell",
|
|
37
|
+
"read_file",
|
|
38
|
+
"write_file",
|
|
39
|
+
"find",
|
|
40
|
+
"get",
|
|
41
|
+
"invoke",
|
|
42
|
+
"set_value",
|
|
43
|
+
"toggle",
|
|
44
|
+
"select",
|
|
45
|
+
"expand",
|
|
46
|
+
"list_windows",
|
|
47
|
+
"open_app",
|
|
48
|
+
"close_app",
|
|
49
|
+
"window_state",
|
|
50
|
+
"highlight"
|
|
51
|
+
];
|
|
52
|
+
var DESK_TARGET_KIND_NAMES2 = ["ref", "point", "window", "selector", "image", "text"];
|
|
53
|
+
var DESK_SELECTOR_PLATFORM_NAMES2 = ["uia", "ax", "atspi", "css"];
|
|
54
|
+
var DESK_SHELL_ACTIONS2 = ["runCommand", "fileWrite", "fileCopy", "fileDelete", "openApp"];
|
|
55
|
+
var COMMAND_INTERPRETER_APPS2 = [
|
|
56
|
+
"bash",
|
|
57
|
+
"cmd",
|
|
58
|
+
"cscript",
|
|
59
|
+
"dash",
|
|
60
|
+
"fish",
|
|
61
|
+
"gnome-terminal",
|
|
62
|
+
"konsole",
|
|
63
|
+
"mshta",
|
|
64
|
+
"node",
|
|
65
|
+
"osascript",
|
|
66
|
+
"perl",
|
|
67
|
+
"powershell",
|
|
68
|
+
"powershell_ise",
|
|
69
|
+
"pwsh",
|
|
70
|
+
"python",
|
|
71
|
+
"python3",
|
|
72
|
+
"rundll32",
|
|
73
|
+
"ruby",
|
|
74
|
+
"sh",
|
|
75
|
+
"terminal",
|
|
76
|
+
"wscript",
|
|
77
|
+
"wt",
|
|
78
|
+
"xterm",
|
|
79
|
+
"zsh",
|
|
80
|
+
"com.apple.terminal",
|
|
81
|
+
"com.googlecode.iterm2",
|
|
82
|
+
"org.gnome.terminal"
|
|
83
|
+
];
|
|
84
|
+
function isCommandInterpreterApp2(app) {
|
|
85
|
+
const base = app.trim().toLowerCase().replace(/\.(exe|app|desktop)$/, "");
|
|
86
|
+
return COMMAND_INTERPRETER_APPS2.includes(base);
|
|
87
|
+
}
|
|
88
|
+
var MESSAGE_SHORTFALLS = 5;
|
|
89
|
+
function hasRoleMethod(target) {
|
|
90
|
+
return target?.methods.some((method) => method.kind === "role" && method.enabled !== false) === true;
|
|
91
|
+
}
|
|
92
|
+
function deskFeaturesOfMethod2(method, target) {
|
|
93
|
+
switch (method.kind) {
|
|
94
|
+
case "role":
|
|
95
|
+
case "fuzzy":
|
|
96
|
+
case "anchor":
|
|
97
|
+
return ["action:snapshot", "target:ref"];
|
|
98
|
+
case "css":
|
|
99
|
+
return method.selector.length <= MAX_DESK_SELECTOR_STRING2 && (target === undefined || hasRoleMethod(target)) ? ["action:find", "target:selector", "platform:css"] : undefined;
|
|
100
|
+
case "testId": {
|
|
101
|
+
const attribute = method.attribute ?? "data-testid";
|
|
102
|
+
const usable = (attribute === "data-testid" || attribute === "id") && (target === undefined || hasRoleMethod(target));
|
|
103
|
+
return usable && testIdSelectorLength(method.value, method.attribute) <= MAX_DESK_SELECTOR_STRING2 ? ["action:find", "target:selector", "platform:css"] : undefined;
|
|
104
|
+
}
|
|
105
|
+
case "uia":
|
|
106
|
+
case "ax":
|
|
107
|
+
case "atspi":
|
|
108
|
+
return ["action:find", "target:selector", `platform:${method.kind}`];
|
|
109
|
+
case "image":
|
|
110
|
+
return ["action:find", "target:image"];
|
|
111
|
+
case "text":
|
|
112
|
+
return method.text.length <= MAX_DESK_TEXT_TARGET2 ? ["action:find", "target:text"] : undefined;
|
|
113
|
+
case "ocr":
|
|
114
|
+
return ["action:find", "target:text"];
|
|
115
|
+
default:
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
function testIdSelectorLength(value, attribute = "data-testid") {
|
|
120
|
+
return attribute.length + value.length + 6;
|
|
121
|
+
}
|
|
122
|
+
function deskHasFeature2(capabilities, feature) {
|
|
123
|
+
const [kind, value] = splitFeature(feature);
|
|
124
|
+
if (kind === "action")
|
|
125
|
+
return capabilities.actions.includes(value);
|
|
126
|
+
if (kind === "target")
|
|
127
|
+
return capabilities.targetKinds.includes(value);
|
|
128
|
+
return capabilities.selectorPlatforms.includes(value);
|
|
129
|
+
}
|
|
130
|
+
function splitFeature(feature) {
|
|
131
|
+
const colon = feature.indexOf(":");
|
|
132
|
+
const kind = feature.slice(0, colon);
|
|
133
|
+
const value = feature.slice(colon + 1);
|
|
134
|
+
return [kind === "action" || kind === "target" ? kind : "platform", value];
|
|
135
|
+
}
|
|
136
|
+
function one(action) {
|
|
137
|
+
return [[`action:${action}`]];
|
|
138
|
+
}
|
|
139
|
+
function byInput(method, direct, hardware) {
|
|
140
|
+
if (method === "direct")
|
|
141
|
+
return one(direct);
|
|
142
|
+
if (method === "hardware")
|
|
143
|
+
return one(hardware);
|
|
144
|
+
return [[`action:${direct}`], [`action:${hardware}`]];
|
|
145
|
+
}
|
|
146
|
+
var NO_DESK = {
|
|
147
|
+
pageNavigation: "desks have no back, reload or close-tab action; use navigate",
|
|
148
|
+
hover: "desks have no pointer-move action",
|
|
149
|
+
pageHtml: "desks do not return page HTML",
|
|
150
|
+
login: "Browser Login sign-in runs only on remote browsers",
|
|
151
|
+
list: "desks do not read repeated items inside a list yet; use for each over elements with get",
|
|
152
|
+
url: "desks do not report the page URL",
|
|
153
|
+
screenshot: "a desk screenshot is the whole screen; element and full-page screenshots are web only",
|
|
154
|
+
fileList: "desk contract v3 has no action that lists a folder",
|
|
155
|
+
fileDelete: "desk contract v3 has no action that deletes a file",
|
|
156
|
+
call: "a call to a shared sequence must be inlined before the script is checked or dispatched",
|
|
157
|
+
scrollTo: "desks scroll by an offset; scrolling to the top or the end is web only"
|
|
158
|
+
};
|
|
159
|
+
function none(reason) {
|
|
160
|
+
return { anyOf: [], reason };
|
|
161
|
+
}
|
|
162
|
+
function textSearch(text) {
|
|
163
|
+
return typeof text === "string" && text.length > MAX_DESK_TEXT_TARGET2 ? [["action:snapshot"]] : [["action:find", "target:text"]];
|
|
164
|
+
}
|
|
165
|
+
function actionNeeds(step, inputMethod) {
|
|
166
|
+
const action = (need) => [{ field: "action", ...need }];
|
|
167
|
+
const actions = (anyOf) => [{ field: "action", anyOf }];
|
|
168
|
+
switch (step.action) {
|
|
169
|
+
case "navigate":
|
|
170
|
+
return actions(one("navigate"));
|
|
171
|
+
case "goBack":
|
|
172
|
+
case "reload":
|
|
173
|
+
case "closeTab":
|
|
174
|
+
return action(none(NO_DESK.pageNavigation));
|
|
175
|
+
case "hover":
|
|
176
|
+
return action(none(NO_DESK.hover));
|
|
177
|
+
case "getPageHtml":
|
|
178
|
+
return action(none(NO_DESK.pageHtml));
|
|
179
|
+
case "login":
|
|
180
|
+
return action(none(NO_DESK.login));
|
|
181
|
+
case "extractList":
|
|
182
|
+
return action(none(NO_DESK.list));
|
|
183
|
+
case "click":
|
|
184
|
+
return actions(step.button === "right" ? one("click") : byInput(inputMethod, "invoke", "click"));
|
|
185
|
+
case "doubleClick":
|
|
186
|
+
return actions(one("click"));
|
|
187
|
+
case "type": {
|
|
188
|
+
let anyOf;
|
|
189
|
+
if (step.target === undefined || step.clear === false)
|
|
190
|
+
anyOf = one("type");
|
|
191
|
+
else if ((step.delayMs ?? 0) > 0 || inputMethod === "hardware")
|
|
192
|
+
anyOf = [["action:set_value", "action:type"]];
|
|
193
|
+
else
|
|
194
|
+
anyOf = one("set_value");
|
|
195
|
+
const needs = actions(anyOf);
|
|
196
|
+
if (step.pressEnter === true) {
|
|
197
|
+
needs.push({
|
|
198
|
+
field: "pressEnter",
|
|
199
|
+
anyOf: step.target === undefined ? one("key") : [["action:click", "action:key"]]
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
return needs;
|
|
203
|
+
}
|
|
204
|
+
case "typeSecret":
|
|
205
|
+
return actions(one("secret_fill"));
|
|
206
|
+
case "clear":
|
|
207
|
+
case "setValue":
|
|
208
|
+
return actions(one("set_value"));
|
|
209
|
+
case "select":
|
|
210
|
+
return actions(one("select"));
|
|
211
|
+
case "check":
|
|
212
|
+
case "toggle":
|
|
213
|
+
return actions(one("toggle"));
|
|
214
|
+
case "pressKey":
|
|
215
|
+
return actions(step.target === undefined ? one("key") : [["action:click", "action:key"]]);
|
|
216
|
+
case "scroll":
|
|
217
|
+
return step.to === undefined ? actions(one("scroll")) : action(none(NO_DESK.scrollTo));
|
|
218
|
+
case "waitFor":
|
|
219
|
+
if (step.target !== undefined)
|
|
220
|
+
return actions(one("find"));
|
|
221
|
+
if (step.text !== undefined)
|
|
222
|
+
return actions(textSearch(step.text));
|
|
223
|
+
if (step.urlContains !== undefined)
|
|
224
|
+
return action(none(NO_DESK.url));
|
|
225
|
+
return [];
|
|
226
|
+
case "extract":
|
|
227
|
+
if (step.fields.some((field) => field.attribute === "html"))
|
|
228
|
+
return action(none(NO_DESK.pageHtml));
|
|
229
|
+
return actions(one("get"));
|
|
230
|
+
case "getText":
|
|
231
|
+
case "getValue":
|
|
232
|
+
case "getAttribute":
|
|
233
|
+
case "get":
|
|
234
|
+
return actions(one("get"));
|
|
235
|
+
case "elementExists":
|
|
236
|
+
return actions(one("find"));
|
|
237
|
+
case "getPageText":
|
|
238
|
+
return actions(one("snapshot"));
|
|
239
|
+
case "screenshot":
|
|
240
|
+
return step.target !== undefined || step.fullPage === true ? action(none(NO_DESK.screenshot)) : actions(one("screenshot"));
|
|
241
|
+
case "focusWindow":
|
|
242
|
+
return actions(one("focus_window"));
|
|
243
|
+
case "openApp":
|
|
244
|
+
return actions(one("open_app"));
|
|
245
|
+
case "closeApp":
|
|
246
|
+
return actions(one("close_app"));
|
|
247
|
+
case "windowState":
|
|
248
|
+
return actions(one("window_state"));
|
|
249
|
+
case "listWindows":
|
|
250
|
+
return actions(one("list_windows"));
|
|
251
|
+
case "invoke":
|
|
252
|
+
return actions(one("invoke"));
|
|
253
|
+
case "expand":
|
|
254
|
+
return actions(one("expand"));
|
|
255
|
+
case "runCommand":
|
|
256
|
+
return actions(one("shell"));
|
|
257
|
+
case "fileRead":
|
|
258
|
+
return actions(one("read_file"));
|
|
259
|
+
case "fileWrite":
|
|
260
|
+
return actions(one("write_file"));
|
|
261
|
+
case "fileCopy":
|
|
262
|
+
return actions([["action:read_file", "action:write_file"]]);
|
|
263
|
+
case "fileList":
|
|
264
|
+
return action(none(NO_DESK.fileList));
|
|
265
|
+
case "fileDelete":
|
|
266
|
+
return action(none(NO_DESK.fileDelete));
|
|
267
|
+
case "if":
|
|
268
|
+
case "while":
|
|
269
|
+
return step.elementExists === undefined ? [] : actions(one("find"));
|
|
270
|
+
case "forEach":
|
|
271
|
+
return step.elements === undefined ? [] : actions(one("find"));
|
|
272
|
+
case "call":
|
|
273
|
+
return action(none(NO_DESK.call));
|
|
274
|
+
default:
|
|
275
|
+
return [];
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
function verifyNeeds(step) {
|
|
279
|
+
switch (step.verify?.kind) {
|
|
280
|
+
case "elementVisible":
|
|
281
|
+
case "elementGone":
|
|
282
|
+
return [{ field: "verify", anyOf: one("find") }];
|
|
283
|
+
case "textPresent":
|
|
284
|
+
return [{ field: "verify", anyOf: textSearch(step.verify.text) }];
|
|
285
|
+
case "valueEquals":
|
|
286
|
+
return [{ field: "verify", anyOf: one("get") }];
|
|
287
|
+
case "urlContains":
|
|
288
|
+
return [{ field: "verify", ...none(NO_DESK.url) }];
|
|
289
|
+
default:
|
|
290
|
+
return [];
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
function targetNeed(field, target) {
|
|
294
|
+
if (target.frame !== undefined)
|
|
295
|
+
return { field, ...none("desks do not follow a web frame or shadow-root chain") };
|
|
296
|
+
const methods = target.methods.filter((method) => method.enabled !== false);
|
|
297
|
+
if (methods.length === 0)
|
|
298
|
+
return;
|
|
299
|
+
const anyOf = methods.map((method) => deskFeaturesOfMethod2(method, target)).filter((features) => features !== undefined);
|
|
300
|
+
if (anyOf.length > 0)
|
|
301
|
+
return { field, anyOf };
|
|
302
|
+
return { field, ...none(`no desk resolves a target by ${methods.map((method) => method.kind).join(", ")}`) };
|
|
303
|
+
}
|
|
304
|
+
function* activeSteps(script) {
|
|
305
|
+
const skipped = [];
|
|
306
|
+
for (const { step, path } of walkSteps2(script)) {
|
|
307
|
+
if (step.disabled === true)
|
|
308
|
+
skipped.push(`${path}.`);
|
|
309
|
+
if (step.disabled === true || skipped.some((prefix) => path.startsWith(prefix)))
|
|
310
|
+
continue;
|
|
311
|
+
yield { step, path };
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
function desktopScriptDeskNeeds2(script) {
|
|
315
|
+
const elements = script.elements ?? {};
|
|
316
|
+
const needs = [];
|
|
317
|
+
for (const { step, path } of activeSteps(script)) {
|
|
318
|
+
const inputMethod = step.inputMethod ?? script.settings?.inputMethod ?? "auto";
|
|
319
|
+
const partial = [...actionNeeds(step, inputMethod), ...verifyNeeds(step)];
|
|
320
|
+
for (const [field, ref] of stepTargets2(step)) {
|
|
321
|
+
const target = "element" in ref ? elements[ref.element]?.target : ref;
|
|
322
|
+
const need = target ? targetNeed(field, target) : undefined;
|
|
323
|
+
if (need)
|
|
324
|
+
partial.push(need);
|
|
325
|
+
}
|
|
326
|
+
for (const need of partial)
|
|
327
|
+
needs.push({ path, stepId: step.id, action: step.action, ...need });
|
|
328
|
+
}
|
|
329
|
+
return needs;
|
|
330
|
+
}
|
|
331
|
+
function shellAction(step) {
|
|
332
|
+
switch (step.action) {
|
|
333
|
+
case "runCommand":
|
|
334
|
+
case "fileWrite":
|
|
335
|
+
case "fileCopy":
|
|
336
|
+
case "fileDelete":
|
|
337
|
+
return step.action;
|
|
338
|
+
case "openApp":
|
|
339
|
+
return step.args !== undefined || isCommandInterpreterApp2(step.app) ? step.action : undefined;
|
|
340
|
+
default:
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
function desktopShellSteps2(script) {
|
|
345
|
+
const steps = [];
|
|
346
|
+
for (const { step, path } of activeSteps(script)) {
|
|
347
|
+
const action = shellAction(step);
|
|
348
|
+
if (action)
|
|
349
|
+
steps.push({ path, stepId: step.id, action });
|
|
350
|
+
}
|
|
351
|
+
return steps;
|
|
352
|
+
}
|
|
353
|
+
function describeSteps(steps) {
|
|
354
|
+
return steps.map((step) => `step ${step.stepId} (${step.action})`).join(", ");
|
|
355
|
+
}
|
|
356
|
+
function checkDesktopScriptShell2(script, allowShell) {
|
|
357
|
+
const steps = desktopShellSteps2(script);
|
|
358
|
+
if (allowShell || steps.length === 0)
|
|
359
|
+
return { ok: true };
|
|
360
|
+
return {
|
|
361
|
+
ok: false,
|
|
362
|
+
code: "SHELL_NOT_ALLOWED",
|
|
363
|
+
message: `This pool does not allow Run command and file steps: ${describeSteps(steps)}`,
|
|
364
|
+
steps
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
function deskLevelShortfalls(capabilities, schemaHash) {
|
|
368
|
+
if (!capabilities) {
|
|
369
|
+
return [
|
|
370
|
+
{
|
|
371
|
+
field: "capabilities",
|
|
372
|
+
missing: [],
|
|
373
|
+
reason: "the desk reports no capabilities (a desk contract version 2 desk cannot run scripts)"
|
|
374
|
+
}
|
|
375
|
+
];
|
|
376
|
+
}
|
|
377
|
+
const problems = [];
|
|
378
|
+
if (capabilities.deskContractVersion !== DESKTOP_DESK_CONTRACT_VERSION2) {
|
|
379
|
+
problems.push({
|
|
380
|
+
field: "deskContractVersion",
|
|
381
|
+
missing: [],
|
|
382
|
+
reason: `the desk speaks desk contract ${capabilities.deskContractVersion}, not ${DESKTOP_DESK_CONTRACT_VERSION2}`
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
if (!capabilities.scriptVersions.includes(UI_SCRIPT_VERSION2)) {
|
|
386
|
+
problems.push({
|
|
387
|
+
field: "scriptVersions",
|
|
388
|
+
missing: [],
|
|
389
|
+
reason: `the desk does not read script version ${UI_SCRIPT_VERSION2}`
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
if (!capabilities.scriptSchemaHashes.includes(schemaHash)) {
|
|
393
|
+
problems.push({
|
|
394
|
+
field: "scriptSchemaHashes",
|
|
395
|
+
missing: [],
|
|
396
|
+
reason: `the desk does not accept the desktop script schema ${schemaHash.slice(0, 12)}`
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
return problems;
|
|
400
|
+
}
|
|
401
|
+
function stepShortfall(need, capabilities) {
|
|
402
|
+
const base = { path: need.path, stepId: need.stepId, action: need.action, field: need.field };
|
|
403
|
+
if (need.anyOf.length === 0)
|
|
404
|
+
return { ...base, missing: [], reason: need.reason ?? "no desk can do this" };
|
|
405
|
+
let closest;
|
|
406
|
+
for (const alternative of need.anyOf) {
|
|
407
|
+
const missing = alternative.filter((feature) => !deskHasFeature2(capabilities, feature));
|
|
408
|
+
if (missing.length === 0)
|
|
409
|
+
return;
|
|
410
|
+
if (!closest || missing.length < closest.length)
|
|
411
|
+
closest = missing;
|
|
412
|
+
}
|
|
413
|
+
const missing = closest ?? [];
|
|
414
|
+
return { ...base, missing, reason: `the desk lacks ${missing.join(", ")}` };
|
|
415
|
+
}
|
|
416
|
+
function describeShortfalls(shortfalls) {
|
|
417
|
+
const listed = shortfalls.slice(0, MESSAGE_SHORTFALLS).map((shortfall) => {
|
|
418
|
+
const where = shortfall.stepId === undefined ? "" : `step ${shortfall.stepId} (${shortfall.action ?? ""})`;
|
|
419
|
+
const field = shortfall.field === "action" || shortfall.stepId === undefined ? "" : ` ${shortfall.field}`;
|
|
420
|
+
return where ? `${where}${field}: ${shortfall.reason}` : shortfall.reason;
|
|
421
|
+
});
|
|
422
|
+
const more = shortfalls.length - listed.length;
|
|
423
|
+
return `${listed.join("; ")}${more > 0 ? `; and ${more} more` : ""}`;
|
|
424
|
+
}
|
|
425
|
+
function checkDesktopScriptForDesk2(script, capabilities, options = {}) {
|
|
426
|
+
const shortfalls = deskLevelShortfalls(capabilities, options.schemaHash ?? DESKTOP_SCRIPT_SCHEMA_HASH2);
|
|
427
|
+
if (capabilities) {
|
|
428
|
+
for (const need of desktopScriptDeskNeeds2(script)) {
|
|
429
|
+
const shortfall = stepShortfall(need, capabilities);
|
|
430
|
+
if (shortfall)
|
|
431
|
+
shortfalls.push(shortfall);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
if (shortfalls.length > 0) {
|
|
435
|
+
return {
|
|
436
|
+
ok: false,
|
|
437
|
+
code: "UNSUPPORTED_ON_DESK",
|
|
438
|
+
message: `The desk cannot run this script: ${describeShortfalls(shortfalls)}`,
|
|
439
|
+
shortfalls
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
const steps = desktopShellSteps2(script);
|
|
443
|
+
if (steps.length === 0)
|
|
444
|
+
return { ok: true };
|
|
445
|
+
if (options.allowShell === false)
|
|
446
|
+
return checkDesktopScriptShell2(script, false);
|
|
447
|
+
if (capabilities && !capabilities.allowShell) {
|
|
448
|
+
return {
|
|
449
|
+
ok: false,
|
|
450
|
+
code: "SHELL_NOT_ALLOWED",
|
|
451
|
+
message: `This computer does not allow Run command and file steps (desk.allow-shell is off): ${describeSteps(steps)}`,
|
|
452
|
+
steps
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
return { ok: true };
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
export { UI_SCRIPT_SCHEMA_HASH2, DESKTOP_SCRIPT_SCHEMA_HASH2, schemaHashOf2, DESKTOP_DESK_CONTRACT_VERSION2, DESK_ACTION_NAMES2, DESK_TARGET_KIND_NAMES2, DESK_SELECTOR_PLATFORM_NAMES2, DESK_SHELL_ACTIONS2, COMMAND_INTERPRETER_APPS2, isCommandInterpreterApp2, deskFeaturesOfMethod2, deskHasFeature2, desktopScriptDeskNeeds2, desktopShellSteps2, checkDesktopScriptShell2, checkDesktopScriptForDesk2 };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
compatibleRoles2,
|
|
3
3
|
ACTIONABLE_ROLES
|
|
4
|
-
} from "./index-
|
|
4
|
+
} from "./index-7gfzv5n8.js";
|
|
5
5
|
import {
|
|
6
6
|
describeTarget2
|
|
7
|
-
} from "./index-
|
|
7
|
+
} from "./index-93hfbk5c.js";
|
|
8
8
|
import {
|
|
9
9
|
MAX_TARGET_METHODS2,
|
|
10
10
|
MAX_SELECTOR_LENGTH2,
|
|
@@ -19,11 +19,11 @@ import {
|
|
|
19
19
|
indexSnapshot2,
|
|
20
20
|
snapshotName2,
|
|
21
21
|
snapshotHosts2
|
|
22
|
-
} from "./index-
|
|
22
|
+
} from "./index-q2jbva7c.js";
|
|
23
23
|
import {
|
|
24
24
|
textSimilarity2,
|
|
25
25
|
clip2
|
|
26
|
-
} from "./index-
|
|
26
|
+
} from "./index-z2v8prer.js";
|
|
27
27
|
// src/heal/question.ts
|
|
28
28
|
var MAX_HEAL_QUESTION_NODES2 = 400;
|
|
29
29
|
var MAX_HEAL_NODE_NAME2 = 100;
|