@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
|
@@ -1,25 +1,29 @@
|
|
|
1
1
|
import {
|
|
2
|
+
DESKTOP_SCRIPT_SURFACE2,
|
|
2
3
|
uiScriptRegistry2,
|
|
3
4
|
NAME_PATTERN2,
|
|
4
5
|
uiScriptSchema2,
|
|
5
6
|
MAX_DESK_SELECTOR_STRING2,
|
|
6
|
-
MAX_DESK_TEXT_TARGET2,
|
|
7
7
|
desktopUiScriptRegistry2,
|
|
8
8
|
desktopUiScriptSchema2,
|
|
9
9
|
canonicalJson2,
|
|
10
10
|
soleRoleMethod,
|
|
11
11
|
uiStepFingerprint2,
|
|
12
|
+
withDesktopFingerprint2,
|
|
12
13
|
UiScriptError2,
|
|
13
|
-
parseUiScript2
|
|
14
|
-
|
|
14
|
+
parseUiScript2,
|
|
15
|
+
parseDesktopUiScript2,
|
|
16
|
+
isApplicationName2
|
|
17
|
+
} from "./index-zj3zhbac.js";
|
|
15
18
|
import {
|
|
16
19
|
maskUrl2,
|
|
17
|
-
sha256Hex2,
|
|
18
20
|
RecordingError2,
|
|
19
21
|
parseRecording2
|
|
20
22
|
} from "./index-dcs2pe49.js";
|
|
21
23
|
import {
|
|
22
|
-
|
|
24
|
+
platformRole2
|
|
25
|
+
} from "./index-0ps53dhe.js";
|
|
26
|
+
import {
|
|
23
27
|
MAX_SCRIPT_STEPS2,
|
|
24
28
|
MAX_SCRIPT_INPUTS2,
|
|
25
29
|
MAX_FRAME_DEPTH2,
|
|
@@ -37,19 +41,9 @@ import {
|
|
|
37
41
|
LEGACY_MAX_STEP_TIMEOUT_MS2,
|
|
38
42
|
jsonByteLength2
|
|
39
43
|
} from "./index-20bbwwc9.js";
|
|
40
|
-
import {
|
|
41
|
-
walkSteps2,
|
|
42
|
-
stepTargets2
|
|
43
|
-
} from "./index-axph39g0.js";
|
|
44
44
|
import {
|
|
45
45
|
containsCredential
|
|
46
46
|
} from "./index-mgztm37r.js";
|
|
47
|
-
// src/script/hash.ts
|
|
48
|
-
var UI_SCRIPT_SCHEMA_HASH2 = "e6860649ad1cba906fb704ce4b62b3ea4380203e6628c809571602f4d0947884";
|
|
49
|
-
var DESKTOP_SCRIPT_SCHEMA_HASH2 = "a1c55895922b0389e04931ba4a2b4f6f9c487e553890ff987ba4527cf9897fce";
|
|
50
|
-
function schemaHashOf2(jsonSchema) {
|
|
51
|
-
return sha256Hex2(canonicalJson2(jsonSchema));
|
|
52
|
-
}
|
|
53
47
|
// src/script/json-schema.ts
|
|
54
48
|
import { z } from "zod";
|
|
55
49
|
var UI_SCRIPT_SCHEMA_TITLE2 = "FluidGrids UI script v1";
|
|
@@ -74,416 +68,6 @@ function desktopUiScriptJsonSchema2() {
|
|
|
74
68
|
const { $schema, ...rest } = generated;
|
|
75
69
|
return { $schema, title: UI_DESKTOP_SCRIPT_SCHEMA_TITLE2, ...rest };
|
|
76
70
|
}
|
|
77
|
-
// src/script/desktop-capabilities.ts
|
|
78
|
-
var DESKTOP_DESK_CONTRACT_VERSION2 = 3;
|
|
79
|
-
var DESK_ACTION_NAMES2 = [
|
|
80
|
-
"screenshot",
|
|
81
|
-
"snapshot",
|
|
82
|
-
"click",
|
|
83
|
-
"type",
|
|
84
|
-
"secret_fill",
|
|
85
|
-
"key",
|
|
86
|
-
"scroll",
|
|
87
|
-
"navigate",
|
|
88
|
-
"focus_window",
|
|
89
|
-
"shell",
|
|
90
|
-
"read_file",
|
|
91
|
-
"write_file",
|
|
92
|
-
"find",
|
|
93
|
-
"get",
|
|
94
|
-
"invoke",
|
|
95
|
-
"set_value",
|
|
96
|
-
"toggle",
|
|
97
|
-
"select",
|
|
98
|
-
"expand",
|
|
99
|
-
"list_windows",
|
|
100
|
-
"open_app",
|
|
101
|
-
"close_app",
|
|
102
|
-
"window_state",
|
|
103
|
-
"highlight"
|
|
104
|
-
];
|
|
105
|
-
var DESK_TARGET_KIND_NAMES2 = ["ref", "point", "window", "selector", "image", "text"];
|
|
106
|
-
var DESK_SELECTOR_PLATFORM_NAMES2 = ["uia", "ax", "atspi", "css"];
|
|
107
|
-
var DESK_SHELL_ACTIONS2 = ["runCommand", "fileWrite", "fileCopy", "fileDelete", "openApp"];
|
|
108
|
-
var COMMAND_INTERPRETER_APPS2 = [
|
|
109
|
-
"bash",
|
|
110
|
-
"cmd",
|
|
111
|
-
"cscript",
|
|
112
|
-
"dash",
|
|
113
|
-
"fish",
|
|
114
|
-
"gnome-terminal",
|
|
115
|
-
"konsole",
|
|
116
|
-
"mshta",
|
|
117
|
-
"node",
|
|
118
|
-
"osascript",
|
|
119
|
-
"perl",
|
|
120
|
-
"powershell",
|
|
121
|
-
"powershell_ise",
|
|
122
|
-
"pwsh",
|
|
123
|
-
"python",
|
|
124
|
-
"python3",
|
|
125
|
-
"rundll32",
|
|
126
|
-
"ruby",
|
|
127
|
-
"sh",
|
|
128
|
-
"terminal",
|
|
129
|
-
"wscript",
|
|
130
|
-
"wt",
|
|
131
|
-
"xterm",
|
|
132
|
-
"zsh",
|
|
133
|
-
"com.apple.terminal",
|
|
134
|
-
"com.googlecode.iterm2",
|
|
135
|
-
"org.gnome.terminal"
|
|
136
|
-
];
|
|
137
|
-
function isCommandInterpreterApp2(app) {
|
|
138
|
-
const base = app.trim().toLowerCase().replace(/\.(exe|app|desktop)$/, "");
|
|
139
|
-
return COMMAND_INTERPRETER_APPS2.includes(base);
|
|
140
|
-
}
|
|
141
|
-
var MESSAGE_SHORTFALLS = 5;
|
|
142
|
-
function deskFeaturesOfMethod2(method) {
|
|
143
|
-
switch (method.kind) {
|
|
144
|
-
case "role":
|
|
145
|
-
case "fuzzy":
|
|
146
|
-
case "anchor":
|
|
147
|
-
return ["action:snapshot", "target:ref"];
|
|
148
|
-
case "css":
|
|
149
|
-
return method.selector.length <= MAX_DESK_SELECTOR_STRING2 ? ["target:selector", "platform:css"] : undefined;
|
|
150
|
-
case "testId":
|
|
151
|
-
return testIdSelectorLength(method.value, method.attribute) <= MAX_DESK_SELECTOR_STRING2 ? ["target:selector", "platform:css"] : undefined;
|
|
152
|
-
case "uia":
|
|
153
|
-
case "ax":
|
|
154
|
-
case "atspi":
|
|
155
|
-
return ["target:selector", `platform:${method.kind}`];
|
|
156
|
-
case "image":
|
|
157
|
-
return ["target:image"];
|
|
158
|
-
case "text":
|
|
159
|
-
return method.text.length <= MAX_DESK_TEXT_TARGET2 ? ["target:text"] : undefined;
|
|
160
|
-
case "ocr":
|
|
161
|
-
return ["target:text"];
|
|
162
|
-
default:
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
function testIdSelectorLength(value, attribute = "data-testid") {
|
|
167
|
-
return attribute.length + value.length + 6;
|
|
168
|
-
}
|
|
169
|
-
function deskHasFeature2(capabilities, feature) {
|
|
170
|
-
const [kind, value] = splitFeature(feature);
|
|
171
|
-
if (kind === "action")
|
|
172
|
-
return capabilities.actions.includes(value);
|
|
173
|
-
if (kind === "target")
|
|
174
|
-
return capabilities.targetKinds.includes(value);
|
|
175
|
-
return capabilities.selectorPlatforms.includes(value);
|
|
176
|
-
}
|
|
177
|
-
function splitFeature(feature) {
|
|
178
|
-
const colon = feature.indexOf(":");
|
|
179
|
-
const kind = feature.slice(0, colon);
|
|
180
|
-
const value = feature.slice(colon + 1);
|
|
181
|
-
return [kind === "action" || kind === "target" ? kind : "platform", value];
|
|
182
|
-
}
|
|
183
|
-
function one(action) {
|
|
184
|
-
return [[`action:${action}`]];
|
|
185
|
-
}
|
|
186
|
-
function byInput(method, direct, hardware) {
|
|
187
|
-
if (method === "direct")
|
|
188
|
-
return one(direct);
|
|
189
|
-
if (method === "hardware")
|
|
190
|
-
return one(hardware);
|
|
191
|
-
return [[`action:${direct}`], [`action:${hardware}`]];
|
|
192
|
-
}
|
|
193
|
-
var NO_DESK = {
|
|
194
|
-
pageNavigation: "desks have no back, reload or close-tab action; use navigate",
|
|
195
|
-
hover: "desks have no pointer-move action",
|
|
196
|
-
pageHtml: "desks do not return page HTML",
|
|
197
|
-
login: "Browser Login sign-in runs only on remote browsers",
|
|
198
|
-
list: "desks do not read repeated items inside a list yet; use for each over elements with get",
|
|
199
|
-
url: "desks do not report the page URL",
|
|
200
|
-
screenshot: "a desk screenshot is the whole screen; element and full-page screenshots are web only",
|
|
201
|
-
fileList: "desk contract v3 has no action that lists a folder",
|
|
202
|
-
fileDelete: "desk contract v3 has no action that deletes a file",
|
|
203
|
-
call: "a call to a shared sequence must be inlined before the script is checked or dispatched"
|
|
204
|
-
};
|
|
205
|
-
function none(reason) {
|
|
206
|
-
return { anyOf: [], reason };
|
|
207
|
-
}
|
|
208
|
-
function actionNeeds(step, inputMethod) {
|
|
209
|
-
const action = (need) => [{ field: "action", ...need }];
|
|
210
|
-
const actions = (anyOf) => [{ field: "action", anyOf }];
|
|
211
|
-
switch (step.action) {
|
|
212
|
-
case "navigate":
|
|
213
|
-
return actions(one("navigate"));
|
|
214
|
-
case "goBack":
|
|
215
|
-
case "reload":
|
|
216
|
-
case "closeTab":
|
|
217
|
-
return action(none(NO_DESK.pageNavigation));
|
|
218
|
-
case "hover":
|
|
219
|
-
return action(none(NO_DESK.hover));
|
|
220
|
-
case "getPageHtml":
|
|
221
|
-
return action(none(NO_DESK.pageHtml));
|
|
222
|
-
case "login":
|
|
223
|
-
return action(none(NO_DESK.login));
|
|
224
|
-
case "extractList":
|
|
225
|
-
return action(none(NO_DESK.list));
|
|
226
|
-
case "click":
|
|
227
|
-
return actions(step.button === "right" ? one("click") : byInput(inputMethod, "invoke", "click"));
|
|
228
|
-
case "doubleClick":
|
|
229
|
-
return actions(one("click"));
|
|
230
|
-
case "type": {
|
|
231
|
-
const typing = step.target === undefined || step.delayMs !== undefined || step.clear === false;
|
|
232
|
-
const needs = actions(typing ? one("type") : byInput(inputMethod, "set_value", "type"));
|
|
233
|
-
if (step.pressEnter === true)
|
|
234
|
-
needs.push({ field: "pressEnter", anyOf: one("key") });
|
|
235
|
-
return needs;
|
|
236
|
-
}
|
|
237
|
-
case "typeSecret":
|
|
238
|
-
return actions(one("secret_fill"));
|
|
239
|
-
case "clear":
|
|
240
|
-
case "setValue":
|
|
241
|
-
return actions(one("set_value"));
|
|
242
|
-
case "select":
|
|
243
|
-
return actions(one("select"));
|
|
244
|
-
case "check":
|
|
245
|
-
case "toggle":
|
|
246
|
-
return actions(one("toggle"));
|
|
247
|
-
case "pressKey":
|
|
248
|
-
return actions(step.target === undefined ? one("key") : [["action:click", "action:key"]]);
|
|
249
|
-
case "scroll":
|
|
250
|
-
return actions(one("scroll"));
|
|
251
|
-
case "waitFor":
|
|
252
|
-
if (step.target !== undefined)
|
|
253
|
-
return actions(one("find"));
|
|
254
|
-
if (step.text !== undefined)
|
|
255
|
-
return actions([["action:find", "target:text"]]);
|
|
256
|
-
if (step.urlContains !== undefined)
|
|
257
|
-
return action(none(NO_DESK.url));
|
|
258
|
-
return [];
|
|
259
|
-
case "extract":
|
|
260
|
-
case "getText":
|
|
261
|
-
case "getValue":
|
|
262
|
-
case "getAttribute":
|
|
263
|
-
case "get":
|
|
264
|
-
return actions(one("get"));
|
|
265
|
-
case "elementExists":
|
|
266
|
-
return actions(one("find"));
|
|
267
|
-
case "getPageText":
|
|
268
|
-
return actions(one("snapshot"));
|
|
269
|
-
case "screenshot":
|
|
270
|
-
return step.target !== undefined || step.fullPage === true ? action(none(NO_DESK.screenshot)) : actions(one("screenshot"));
|
|
271
|
-
case "focusWindow":
|
|
272
|
-
return actions(one("focus_window"));
|
|
273
|
-
case "openApp":
|
|
274
|
-
return actions(one("open_app"));
|
|
275
|
-
case "closeApp":
|
|
276
|
-
return actions(one("close_app"));
|
|
277
|
-
case "windowState":
|
|
278
|
-
return actions(one("window_state"));
|
|
279
|
-
case "listWindows":
|
|
280
|
-
return actions(one("list_windows"));
|
|
281
|
-
case "invoke":
|
|
282
|
-
return actions(one("invoke"));
|
|
283
|
-
case "expand":
|
|
284
|
-
return actions(one("expand"));
|
|
285
|
-
case "runCommand":
|
|
286
|
-
return actions(one("shell"));
|
|
287
|
-
case "fileRead":
|
|
288
|
-
return actions(one("read_file"));
|
|
289
|
-
case "fileWrite":
|
|
290
|
-
return actions(one("write_file"));
|
|
291
|
-
case "fileCopy":
|
|
292
|
-
return actions([["action:read_file", "action:write_file"]]);
|
|
293
|
-
case "fileList":
|
|
294
|
-
return action(none(NO_DESK.fileList));
|
|
295
|
-
case "fileDelete":
|
|
296
|
-
return action(none(NO_DESK.fileDelete));
|
|
297
|
-
case "if":
|
|
298
|
-
case "while":
|
|
299
|
-
return step.elementExists === undefined ? [] : actions(one("find"));
|
|
300
|
-
case "forEach":
|
|
301
|
-
return step.elements === undefined ? [] : actions(one("find"));
|
|
302
|
-
case "call":
|
|
303
|
-
return action(none(NO_DESK.call));
|
|
304
|
-
default:
|
|
305
|
-
return [];
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
function verifyNeeds(step) {
|
|
309
|
-
switch (step.verify?.kind) {
|
|
310
|
-
case "elementVisible":
|
|
311
|
-
case "elementGone":
|
|
312
|
-
return [{ field: "verify", anyOf: one("find") }];
|
|
313
|
-
case "textPresent":
|
|
314
|
-
return [{ field: "verify", anyOf: [["action:find", "target:text"]] }];
|
|
315
|
-
case "valueEquals":
|
|
316
|
-
return [{ field: "verify", anyOf: one("get") }];
|
|
317
|
-
case "urlContains":
|
|
318
|
-
return [{ field: "verify", ...none(NO_DESK.url) }];
|
|
319
|
-
default:
|
|
320
|
-
return [];
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
function targetNeed(field, target) {
|
|
324
|
-
if (target.frame !== undefined)
|
|
325
|
-
return { field, ...none("desks do not follow a web frame or shadow-root chain") };
|
|
326
|
-
const methods = target.methods.filter((method) => method.enabled !== false);
|
|
327
|
-
if (methods.length === 0)
|
|
328
|
-
return;
|
|
329
|
-
const anyOf = methods.map((method) => deskFeaturesOfMethod2(method)).filter((features) => features !== undefined);
|
|
330
|
-
if (anyOf.length > 0)
|
|
331
|
-
return { field, anyOf };
|
|
332
|
-
return { field, ...none(`no desk resolves a target by ${methods.map((method) => method.kind).join(", ")}`) };
|
|
333
|
-
}
|
|
334
|
-
function* activeSteps(script) {
|
|
335
|
-
const skipped = [];
|
|
336
|
-
for (const { step, path } of walkSteps2(script)) {
|
|
337
|
-
if (step.disabled === true)
|
|
338
|
-
skipped.push(`${path}.`);
|
|
339
|
-
if (step.disabled === true || skipped.some((prefix) => path.startsWith(prefix)))
|
|
340
|
-
continue;
|
|
341
|
-
yield { step, path };
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
function desktopScriptDeskNeeds2(script) {
|
|
345
|
-
const elements = script.elements ?? {};
|
|
346
|
-
const needs = [];
|
|
347
|
-
for (const { step, path } of activeSteps(script)) {
|
|
348
|
-
const inputMethod = step.inputMethod ?? script.settings?.inputMethod ?? "auto";
|
|
349
|
-
const partial = [...actionNeeds(step, inputMethod), ...verifyNeeds(step)];
|
|
350
|
-
for (const [field, ref] of stepTargets2(step)) {
|
|
351
|
-
const target = "element" in ref ? elements[ref.element]?.target : ref;
|
|
352
|
-
const need = target ? targetNeed(field, target) : undefined;
|
|
353
|
-
if (need)
|
|
354
|
-
partial.push(need);
|
|
355
|
-
}
|
|
356
|
-
for (const need of partial)
|
|
357
|
-
needs.push({ path, stepId: step.id, action: step.action, ...need });
|
|
358
|
-
}
|
|
359
|
-
return needs;
|
|
360
|
-
}
|
|
361
|
-
function shellAction(step) {
|
|
362
|
-
switch (step.action) {
|
|
363
|
-
case "runCommand":
|
|
364
|
-
case "fileWrite":
|
|
365
|
-
case "fileCopy":
|
|
366
|
-
case "fileDelete":
|
|
367
|
-
return step.action;
|
|
368
|
-
case "openApp":
|
|
369
|
-
return step.args !== undefined || isCommandInterpreterApp2(step.app) ? step.action : undefined;
|
|
370
|
-
default:
|
|
371
|
-
return;
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
function desktopShellSteps2(script) {
|
|
375
|
-
const steps = [];
|
|
376
|
-
for (const { step, path } of activeSteps(script)) {
|
|
377
|
-
const action = shellAction(step);
|
|
378
|
-
if (action)
|
|
379
|
-
steps.push({ path, stepId: step.id, action });
|
|
380
|
-
}
|
|
381
|
-
return steps;
|
|
382
|
-
}
|
|
383
|
-
function describeSteps(steps) {
|
|
384
|
-
return steps.map((step) => `step ${step.stepId} (${step.action})`).join(", ");
|
|
385
|
-
}
|
|
386
|
-
function checkDesktopScriptShell2(script, allowShell) {
|
|
387
|
-
const steps = desktopShellSteps2(script);
|
|
388
|
-
if (allowShell || steps.length === 0)
|
|
389
|
-
return { ok: true };
|
|
390
|
-
return {
|
|
391
|
-
ok: false,
|
|
392
|
-
code: "SHELL_NOT_ALLOWED",
|
|
393
|
-
message: `This pool does not allow Run command and file steps: ${describeSteps(steps)}`,
|
|
394
|
-
steps
|
|
395
|
-
};
|
|
396
|
-
}
|
|
397
|
-
function deskLevelShortfalls(capabilities, schemaHash) {
|
|
398
|
-
if (!capabilities) {
|
|
399
|
-
return [
|
|
400
|
-
{
|
|
401
|
-
field: "capabilities",
|
|
402
|
-
missing: [],
|
|
403
|
-
reason: "the desk reports no capabilities (a desk contract version 2 desk cannot run scripts)"
|
|
404
|
-
}
|
|
405
|
-
];
|
|
406
|
-
}
|
|
407
|
-
const problems = [];
|
|
408
|
-
if (capabilities.deskContractVersion !== DESKTOP_DESK_CONTRACT_VERSION2) {
|
|
409
|
-
problems.push({
|
|
410
|
-
field: "deskContractVersion",
|
|
411
|
-
missing: [],
|
|
412
|
-
reason: `the desk speaks desk contract ${capabilities.deskContractVersion}, not ${DESKTOP_DESK_CONTRACT_VERSION2}`
|
|
413
|
-
});
|
|
414
|
-
}
|
|
415
|
-
if (!capabilities.scriptVersions.includes(UI_SCRIPT_VERSION2)) {
|
|
416
|
-
problems.push({
|
|
417
|
-
field: "scriptVersions",
|
|
418
|
-
missing: [],
|
|
419
|
-
reason: `the desk does not read script version ${UI_SCRIPT_VERSION2}`
|
|
420
|
-
});
|
|
421
|
-
}
|
|
422
|
-
if (!capabilities.scriptSchemaHashes.includes(schemaHash)) {
|
|
423
|
-
problems.push({
|
|
424
|
-
field: "scriptSchemaHashes",
|
|
425
|
-
missing: [],
|
|
426
|
-
reason: `the desk does not accept the desktop script schema ${schemaHash.slice(0, 12)}`
|
|
427
|
-
});
|
|
428
|
-
}
|
|
429
|
-
return problems;
|
|
430
|
-
}
|
|
431
|
-
function stepShortfall(need, capabilities) {
|
|
432
|
-
const base = { path: need.path, stepId: need.stepId, action: need.action, field: need.field };
|
|
433
|
-
if (need.anyOf.length === 0)
|
|
434
|
-
return { ...base, missing: [], reason: need.reason ?? "no desk can do this" };
|
|
435
|
-
let closest;
|
|
436
|
-
for (const alternative of need.anyOf) {
|
|
437
|
-
const missing = alternative.filter((feature) => !deskHasFeature2(capabilities, feature));
|
|
438
|
-
if (missing.length === 0)
|
|
439
|
-
return;
|
|
440
|
-
if (!closest || missing.length < closest.length)
|
|
441
|
-
closest = missing;
|
|
442
|
-
}
|
|
443
|
-
const missing = closest ?? [];
|
|
444
|
-
return { ...base, missing, reason: `the desk lacks ${missing.join(", ")}` };
|
|
445
|
-
}
|
|
446
|
-
function describeShortfalls(shortfalls) {
|
|
447
|
-
const listed = shortfalls.slice(0, MESSAGE_SHORTFALLS).map((shortfall) => {
|
|
448
|
-
const where = shortfall.stepId === undefined ? "" : `step ${shortfall.stepId} (${shortfall.action ?? ""})`;
|
|
449
|
-
const field = shortfall.field === "action" || shortfall.stepId === undefined ? "" : ` ${shortfall.field}`;
|
|
450
|
-
return where ? `${where}${field}: ${shortfall.reason}` : shortfall.reason;
|
|
451
|
-
});
|
|
452
|
-
const more = shortfalls.length - listed.length;
|
|
453
|
-
return `${listed.join("; ")}${more > 0 ? `; and ${more} more` : ""}`;
|
|
454
|
-
}
|
|
455
|
-
function checkDesktopScriptForDesk2(script, capabilities, options = {}) {
|
|
456
|
-
const shortfalls = deskLevelShortfalls(capabilities, options.schemaHash ?? DESKTOP_SCRIPT_SCHEMA_HASH2);
|
|
457
|
-
if (capabilities) {
|
|
458
|
-
for (const need of desktopScriptDeskNeeds2(script)) {
|
|
459
|
-
const shortfall = stepShortfall(need, capabilities);
|
|
460
|
-
if (shortfall)
|
|
461
|
-
shortfalls.push(shortfall);
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
if (shortfalls.length > 0) {
|
|
465
|
-
return {
|
|
466
|
-
ok: false,
|
|
467
|
-
code: "UNSUPPORTED_ON_DESK",
|
|
468
|
-
message: `The desk cannot run this script: ${describeShortfalls(shortfalls)}`,
|
|
469
|
-
shortfalls
|
|
470
|
-
};
|
|
471
|
-
}
|
|
472
|
-
const steps = desktopShellSteps2(script);
|
|
473
|
-
if (steps.length === 0)
|
|
474
|
-
return { ok: true };
|
|
475
|
-
if (options.allowShell === false)
|
|
476
|
-
return checkDesktopScriptShell2(script, false);
|
|
477
|
-
if (capabilities && !capabilities.allowShell) {
|
|
478
|
-
return {
|
|
479
|
-
ok: false,
|
|
480
|
-
code: "SHELL_NOT_ALLOWED",
|
|
481
|
-
message: `This computer does not allow Run command and file steps (desk.allow-shell is off): ${describeSteps(steps)}`,
|
|
482
|
-
steps
|
|
483
|
-
};
|
|
484
|
-
}
|
|
485
|
-
return { ok: true };
|
|
486
|
-
}
|
|
487
71
|
// src/script/adapters/browser-action-contract.ts
|
|
488
72
|
var BROWSER_STEP_ACTIONS2 = [
|
|
489
73
|
"navigate",
|
|
@@ -1250,6 +834,97 @@ function toRecordedStep(step, fallbackIntent) {
|
|
|
1250
834
|
return stop2();
|
|
1251
835
|
}
|
|
1252
836
|
}
|
|
837
|
+
// src/script/adapters/recording-desktop.ts
|
|
838
|
+
function fits(text) {
|
|
839
|
+
return text === undefined || text.length >= 1 && text.length <= MAX_DESK_SELECTOR_STRING2;
|
|
840
|
+
}
|
|
841
|
+
function selectorMethodOfRecordedTarget2(target, platform) {
|
|
842
|
+
const role = platformRole2(target.role, platform);
|
|
843
|
+
if (target.nth !== 0 || role === undefined)
|
|
844
|
+
return;
|
|
845
|
+
if (!fits(target.name) || !fits(target.window) || !fits(target.app))
|
|
846
|
+
return;
|
|
847
|
+
if (target.app !== undefined && !isApplicationName2(target.app))
|
|
848
|
+
return;
|
|
849
|
+
return {
|
|
850
|
+
kind: platform,
|
|
851
|
+
...target.app === undefined ? {} : { app: target.app },
|
|
852
|
+
...target.window === undefined ? {} : { window: { title: target.window } },
|
|
853
|
+
path: [{ role, name: target.name }]
|
|
854
|
+
};
|
|
855
|
+
}
|
|
856
|
+
function roleMethodOf(target) {
|
|
857
|
+
return {
|
|
858
|
+
kind: "role",
|
|
859
|
+
role: target.role,
|
|
860
|
+
name: target.name,
|
|
861
|
+
nth: target.nth,
|
|
862
|
+
...target.app === undefined ? {} : { app: target.app },
|
|
863
|
+
...target.window === undefined ? {} : { window: target.window }
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
function desktopTargetOfRecordedTarget2(target, platform) {
|
|
867
|
+
const strict = selectorMethodOfRecordedTarget2(target, platform);
|
|
868
|
+
return { methods: strict ? [roleMethodOf(target), strict] : [roleMethodOf(target)] };
|
|
869
|
+
}
|
|
870
|
+
function fromRecordedStep2(step, platform) {
|
|
871
|
+
const base = {
|
|
872
|
+
id: step.id,
|
|
873
|
+
intent: step.intent,
|
|
874
|
+
...step.screenshotRef === undefined ? {} : { screenshotRef: step.screenshotRef }
|
|
875
|
+
};
|
|
876
|
+
const target = (recorded) => desktopTargetOfRecordedTarget2(recorded, platform);
|
|
877
|
+
switch (step.action) {
|
|
878
|
+
case "click": {
|
|
879
|
+
const button = step.button === "right" ? { button: "right" } : {};
|
|
880
|
+
return step.count === 2 ? { ...base, action: "doubleClick", target: target(step.target), ...button } : { ...base, action: "click", target: target(step.target), ...button };
|
|
881
|
+
}
|
|
882
|
+
case "type":
|
|
883
|
+
return {
|
|
884
|
+
...base,
|
|
885
|
+
action: "type",
|
|
886
|
+
...step.target ? { target: target(step.target) } : {},
|
|
887
|
+
...step.text === undefined ? {} : { text: step.text },
|
|
888
|
+
masked: step.masked
|
|
889
|
+
};
|
|
890
|
+
case "secret_fill":
|
|
891
|
+
return {
|
|
892
|
+
...base,
|
|
893
|
+
action: "typeSecret",
|
|
894
|
+
target: target(step.target),
|
|
895
|
+
secretRef: step.secretRef,
|
|
896
|
+
expectedOrigin: step.expectedOrigin
|
|
897
|
+
};
|
|
898
|
+
case "key":
|
|
899
|
+
return { ...base, action: "pressKey", keys: step.keys };
|
|
900
|
+
case "scroll":
|
|
901
|
+
return {
|
|
902
|
+
...base,
|
|
903
|
+
action: "scroll",
|
|
904
|
+
...step.target ? { target: target(step.target) } : {},
|
|
905
|
+
dx: step.dx,
|
|
906
|
+
dy: step.dy
|
|
907
|
+
};
|
|
908
|
+
case "navigate":
|
|
909
|
+
return { ...base, action: "navigate", url: step.url };
|
|
910
|
+
default:
|
|
911
|
+
return {
|
|
912
|
+
...base,
|
|
913
|
+
action: "focusWindow",
|
|
914
|
+
app: step.app,
|
|
915
|
+
...step.title === undefined ? {} : { title: step.title }
|
|
916
|
+
};
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
function fromRecordingForDesk2(value, options) {
|
|
920
|
+
const recording = parseRecording2(value);
|
|
921
|
+
const steps = recording.steps.map((step) => withDesktopFingerprint2(fromRecordedStep2(step, options.platform)));
|
|
922
|
+
return parseDesktopUiScript2({
|
|
923
|
+
scriptVersion: 1,
|
|
924
|
+
surface: DESKTOP_SCRIPT_SURFACE2,
|
|
925
|
+
steps
|
|
926
|
+
});
|
|
927
|
+
}
|
|
1253
928
|
// src/script/adapters/from-computer-use.ts
|
|
1254
929
|
var COMPUTER_USE_ACTIONS2 = [
|
|
1255
930
|
"screenshot",
|
|
@@ -1727,4 +1402,4 @@ function propose(state, target, fingerprint, stepId, screenshotFileId) {
|
|
|
1727
1402
|
...fileId ? { screenshotFileId: fileId } : {}
|
|
1728
1403
|
});
|
|
1729
1404
|
}
|
|
1730
|
-
export {
|
|
1405
|
+
export { UI_SCRIPT_SCHEMA_TITLE2, uiScriptJsonSchema2, UI_DESKTOP_SCRIPT_SCHEMA_TITLE2, desktopUiScriptJsonSchema2, BROWSER_STEP_ACTIONS2, fromBrowserActionSteps2, toBrowserActionSteps2, targetFromPlaywrightSelector2, fromRemoteBrowserSteps2, fromRecording2, toRecording2, selectorMethodOfRecordedTarget2, desktopTargetOfRecordedTarget2, fromRecordingForDesk2, COMPUTER_USE_ACTIONS2, MAX_COMPUTER_USE_ACTIONS2, COMPUTER_USE_MAX_WAIT_MS2, COMPUTER_USE_DEFAULT_WAIT_MS2, DEFAULT_LOGIN_SECRET_REFS2, COMPUTER_USE_SKIP_REASONS2, targetFromUiFingerprint2, scriptFromComputerUseActions2 };
|
|
@@ -187,46 +187,4 @@ class UiDriverError2 extends Error {
|
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
-
|
|
191
|
-
function abortError() {
|
|
192
|
-
const error = new Error("The run was cancelled");
|
|
193
|
-
error.name = "AbortError";
|
|
194
|
-
return error;
|
|
195
|
-
}
|
|
196
|
-
var realClock2 = {
|
|
197
|
-
now: () => Date.now(),
|
|
198
|
-
sleep: (ms, signal) => new Promise((resolve, reject) => {
|
|
199
|
-
if (signal?.aborted) {
|
|
200
|
-
reject(abortError());
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
const timer = setTimeout(() => {
|
|
204
|
-
signal?.removeEventListener("abort", onAbort);
|
|
205
|
-
resolve();
|
|
206
|
-
}, Math.max(0, ms));
|
|
207
|
-
const onAbort = () => {
|
|
208
|
-
clearTimeout(timer);
|
|
209
|
-
reject(abortError());
|
|
210
|
-
};
|
|
211
|
-
signal?.addEventListener("abort", onAbort, { once: true });
|
|
212
|
-
})
|
|
213
|
-
};
|
|
214
|
-
function createVirtualClock2(start = 0) {
|
|
215
|
-
let time = start;
|
|
216
|
-
return {
|
|
217
|
-
now: () => time,
|
|
218
|
-
sleep: async (ms, signal) => {
|
|
219
|
-
if (signal?.aborted)
|
|
220
|
-
throw abortError();
|
|
221
|
-
time += Math.max(0, ms);
|
|
222
|
-
await Promise.resolve();
|
|
223
|
-
if (signal?.aborted)
|
|
224
|
-
throw abortError();
|
|
225
|
-
},
|
|
226
|
-
advance: (ms) => {
|
|
227
|
-
time += Math.max(0, ms);
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
export { UI_ERROR_FAMILIES2, UI_ERROR_CODES2, UI_ERROR_CODE_LIST2, isUiErrorCode2, errorFamilyOf2, isRetryableInScript2, UiRunError2, UiDriverError2, realClock2, createVirtualClock2 };
|
|
190
|
+
export { UI_ERROR_FAMILIES2, UI_ERROR_CODES2, UI_ERROR_CODE_LIST2, isUiErrorCode2, errorFamilyOf2, isRetryableInScript2, UiRunError2, UiDriverError2 };
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
REDACTED2,
|
|
3
|
-
containsCredential,
|
|
4
|
-
decodeUriText,
|
|
5
|
-
containsCredentialInUrl
|
|
6
|
-
} from "./index-mgztm37r.js";
|
|
7
|
-
|
|
8
1
|
// src/target/markers.ts
|
|
9
2
|
var SENSITIVE_MARKERS2 = ["data-fg-sensitive", "data-sensitive", "data-private"];
|
|
10
3
|
function hasSensitiveMarker2(element) {
|
|
@@ -173,57 +166,4 @@ function clip2(value, max) {
|
|
|
173
166
|
return value.length <= max ? value : `${value.slice(0, Math.max(0, max - 1))}…`;
|
|
174
167
|
}
|
|
175
168
|
|
|
176
|
-
|
|
177
|
-
var MAX_URL_TEXT = 500;
|
|
178
|
-
var RESET_SEGMENT = /reset|recover|verify|verification|magic|confirm|activate|invite|unsubscribe/i;
|
|
179
|
-
function decodeSegment(segment) {
|
|
180
|
-
let current = segment;
|
|
181
|
-
for (let round = 0;round < 3; round += 1) {
|
|
182
|
-
const next = decodeUriText(current);
|
|
183
|
-
if (next === current)
|
|
184
|
-
break;
|
|
185
|
-
current = next;
|
|
186
|
-
}
|
|
187
|
-
return current;
|
|
188
|
-
}
|
|
189
|
-
function resetPrefix(decoded) {
|
|
190
|
-
const parts = decoded.split(/[/?#;]/);
|
|
191
|
-
const index = parts.findIndex((part) => RESET_SEGMENT.test(part));
|
|
192
|
-
const kept = parts.slice(0, index + 1).map((part) => containsCredential(part) ? REDACTED2 : part);
|
|
193
|
-
return kept.join("/");
|
|
194
|
-
}
|
|
195
|
-
function snapshotUrl2(raw) {
|
|
196
|
-
const value = raw.trim();
|
|
197
|
-
if (value === "")
|
|
198
|
-
return null;
|
|
199
|
-
const absolute = /^[a-z][a-z0-9+.-]*:/i.test(value) || value.startsWith("//");
|
|
200
|
-
let origin = "";
|
|
201
|
-
let path;
|
|
202
|
-
if (absolute) {
|
|
203
|
-
let url;
|
|
204
|
-
try {
|
|
205
|
-
url = new URL(value.startsWith("//") ? `https:${value}` : value);
|
|
206
|
-
} catch {
|
|
207
|
-
return null;
|
|
208
|
-
}
|
|
209
|
-
if (url.protocol !== "http:" && url.protocol !== "https:")
|
|
210
|
-
return null;
|
|
211
|
-
origin = value.startsWith("//") ? `//${url.host}` : url.origin;
|
|
212
|
-
path = url.pathname;
|
|
213
|
-
} else {
|
|
214
|
-
path = value.split(/[?#]/)[0] ?? "";
|
|
215
|
-
}
|
|
216
|
-
const segments = path.split("/");
|
|
217
|
-
const decoded = segments.map(decodeSegment);
|
|
218
|
-
const reset = decoded.findIndex((segment) => RESET_SEGMENT.test(segment));
|
|
219
|
-
const kept = reset >= 0 ? segments.slice(0, reset + 1) : segments;
|
|
220
|
-
const cleaned = kept.map((segment, index) => {
|
|
221
|
-
const plain = decoded[index] ?? segment;
|
|
222
|
-
if (index === reset)
|
|
223
|
-
return resetPrefix(plain);
|
|
224
|
-
return containsCredential(plain) || containsCredentialInUrl(segment) ? REDACTED2 : segment;
|
|
225
|
-
}).join("/");
|
|
226
|
-
return clip2(`${origin}${cleaned}`, MAX_URL_TEXT);
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
export { SENSITIVE_MARKERS2, hasSensitiveMarker2, assignedSlotOf, containerOf, isMarkedSensitive, INPUT_ROLES, TAG_ROLES, NAME_FROM_CONTENT, MAX_COMPARED_TEXT2, normaliseText2, sameText2, containsText2, editDistance2, textSimilarity2, clip2, snapshotUrl2 };
|
|
169
|
+
export { SENSITIVE_MARKERS2, hasSensitiveMarker2, assignedSlotOf, containerOf, isMarkedSensitive, INPUT_ROLES, TAG_ROLES, NAME_FROM_CONTENT, MAX_COMPARED_TEXT2, normaliseText2, sameText2, containsText2, editDistance2, textSimilarity2, clip2 };
|