@burdenoff/ui-engine 2026.1127.3 → 2026.1127.5

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.
Files changed (65) hide show
  1. package/README.md +71 -5
  2. package/dist/analyze/analyze.d.ts +19 -0
  3. package/dist/analyze/context.d.ts +40 -0
  4. package/dist/analyze/index.d.ts +10 -0
  5. package/dist/analyze/messages.d.ts +39 -0
  6. package/dist/analyze/rules/fixed-wait.d.ts +6 -0
  7. package/dist/analyze/rules/hardware-input.d.ts +2 -0
  8. package/dist/analyze/rules/index.d.ts +3 -0
  9. package/dist/analyze/rules/inline-target.d.ts +2 -0
  10. package/dist/analyze/rules/masked-value.d.ts +8 -0
  11. package/dist/analyze/rules/no-cleanup.d.ts +2 -0
  12. package/dist/analyze/rules/plain-text-secret.d.ts +2 -0
  13. package/dist/analyze/rules/rule.d.ts +15 -0
  14. package/dist/analyze/rules/secret-origin.d.ts +7 -0
  15. package/dist/analyze/rules/sensitive-screenshot.d.ts +2 -0
  16. package/dist/analyze/rules/single-method-target.d.ts +2 -0
  17. package/dist/analyze/rules/unknown-variable.d.ts +2 -0
  18. package/dist/analyze/rules/unused-value.d.ts +2 -0
  19. package/dist/analyze/sensitive.d.ts +14 -0
  20. package/dist/analyze/types.d.ts +66 -0
  21. package/dist/analyze.d.ts +2 -0
  22. package/dist/analyze.js +26 -0
  23. package/dist/dom-runtime.iife.js +1 -1
  24. package/dist/dom-runtime.js +27 -532
  25. package/dist/drivers/dom-driver.d.ts +44 -0
  26. package/dist/drivers/index.d.ts +7 -0
  27. package/dist/drivers/snapshot-driver.d.ts +59 -0
  28. package/dist/drivers.d.ts +2 -0
  29. package/dist/drivers.js +172 -0
  30. package/dist/index-21hvbvx1.js +340 -0
  31. package/dist/{index-q1b0j9yr.js → index-5k26keah.js} +58 -592
  32. package/dist/index-77pcz6n3.js +303 -0
  33. package/dist/index-8w0f6rsz.js +402 -0
  34. package/dist/index-9s5nphx0.js +99 -0
  35. package/dist/index-c88tvyj1.js +743 -0
  36. package/dist/index-ct2xctrq.js +229 -0
  37. package/dist/index-g7724awk.js +224 -0
  38. package/dist/index-gvavb597.js +195 -0
  39. package/dist/index-r2a9rftv.js +1740 -0
  40. package/dist/index-s7qdecev.js +489 -0
  41. package/dist/index-vg8r40y7.js +220 -0
  42. package/dist/index-xner4tgb.js +810 -0
  43. package/dist/index-ycs2bz1a.js +589 -0
  44. package/dist/index.d.ts +2 -0
  45. package/dist/index.js +163 -49
  46. package/dist/interpret/compile.d.ts +58 -0
  47. package/dist/interpret/driver.d.ts +171 -0
  48. package/dist/interpret/errors.d.ts +194 -0
  49. package/dist/interpret/events.d.ts +73 -0
  50. package/dist/interpret/expr.d.ts +35 -0
  51. package/dist/interpret/index.d.ts +13 -0
  52. package/dist/interpret/run.d.ts +77 -0
  53. package/dist/interpret.d.ts +2 -0
  54. package/dist/interpret.js +84 -0
  55. package/dist/script/adapters/browser-action-contract.d.ts +5 -2
  56. package/dist/script/limits.d.ts +2 -0
  57. package/dist/script.js +60 -50
  58. package/dist/target/index.d.ts +1 -1
  59. package/dist/target/resolve.d.ts +18 -1
  60. package/dist/target.js +23 -19
  61. package/dist/testing/fake-web-driver.d.ts +28 -0
  62. package/dist/testing/index.d.ts +3 -2
  63. package/dist/testing.js +55 -0
  64. package/package.json +15 -3
  65. package/dist/index-zwrxw3zp.js +0 -1988
package/dist/index.js CHANGED
@@ -31,14 +31,103 @@ import {
31
31
  replayReasons2
32
32
  } from "./index-2kgsgn1c.js";
33
33
  import {
34
- UI_EXPRESSION_OPS2,
35
- UI_ANCHOR_RELATIONS2,
36
- UI_TARGET_METHOD_KINDS2,
37
- UI_WEB_ACTIONS2,
38
- UI_DESKTOP_ACTIONS2,
39
- UI_FLOW_ACTIONS2,
40
- UI_STEP_ACTIONS2,
41
- UI_VALUE_TYPES2,
34
+ uiScriptRegistry2,
35
+ NAME_PATTERN2,
36
+ STEP_ID_PATTERN2,
37
+ ELEMENT_KEY_PATTERN2,
38
+ uiExpressionSchema2,
39
+ uiTargetMethodSchema2,
40
+ uiTargetSchema2,
41
+ uiTargetRefSchema2,
42
+ uiStepSchema2,
43
+ uiScriptSchema2,
44
+ canonicalJson2,
45
+ RECORDING_ACTION_OF2,
46
+ uiStepFingerprint2,
47
+ withFingerprint2,
48
+ UiScriptError2,
49
+ UI_EXPRESSION_ARITY2,
50
+ parseUiScript2,
51
+ safeParseUiScript2
52
+ } from "./index-c88tvyj1.js";
53
+ import {
54
+ UI_SCRIPT_SCHEMA_HASH2,
55
+ schemaHashOf2,
56
+ UI_SCRIPT_SCHEMA_TITLE2,
57
+ uiScriptJsonSchema2,
58
+ BROWSER_STEP_ACTIONS2,
59
+ fromBrowserActionSteps2,
60
+ toBrowserActionSteps2,
61
+ targetFromPlaywrightSelector2,
62
+ fromRemoteBrowserSteps2,
63
+ fromRecording2,
64
+ toRecording2
65
+ } from "./index-xner4tgb.js";
66
+ import {
67
+ MAX_CALL_DEPTH2,
68
+ COMPILED_NAME_PREFIX2,
69
+ applyPins2,
70
+ stripBreakpoints2,
71
+ inlineCalls2,
72
+ compileUiScript2
73
+ } from "./index-8w0f6rsz.js";
74
+ import {
75
+ stepNumber2,
76
+ UI_SCRIPT_PROBLEM_KEY_PREFIX2,
77
+ UI_SCRIPT_PROBLEM_MESSAGES2,
78
+ problemMessageKey2,
79
+ problemMessage2,
80
+ UI_ANALYZER_RULES2,
81
+ UI_PROBLEM_SEVERITIES2,
82
+ UI_ANALYZER_RULE_GROUPS2,
83
+ UI_ANALYZER_RULE_IDS2,
84
+ UI_ANALYZER_DEFAULT_SEVERITY2,
85
+ analyzeUiScript2
86
+ } from "./index-s7qdecev.js";
87
+ import {
88
+ MAX_VALUE_TEXT2,
89
+ MAX_VALUE_ITEMS2,
90
+ toUiValue2,
91
+ readPath2,
92
+ truthy2,
93
+ valuesEqual2,
94
+ toText2,
95
+ toNumber2,
96
+ evaluateExpression2,
97
+ UI_RUN_EVENT_KINDS2,
98
+ DEFAULT_MAX_EVENTS2,
99
+ MAX_STEP_LOG_ENTRIES2,
100
+ MAX_EVENT_MESSAGE2,
101
+ DEFAULT_FIRST_WAIT_MS2,
102
+ DEFAULT_WAIT_MS2,
103
+ DEFAULT_RETRY_DELAY_MS2,
104
+ DEFAULT_POLL_INTERVAL_MS2,
105
+ MAX_EVENTS_LIMIT2,
106
+ MAX_PAGE_TEXT2,
107
+ DEFAULT_LIST_ITEMS2,
108
+ runUiScript2
109
+ } from "./index-r2a9rftv.js";
110
+ import {
111
+ UI_ERROR_FAMILIES2,
112
+ UI_ERROR_CODES2,
113
+ UI_ERROR_CODE_LIST2,
114
+ isUiErrorCode2,
115
+ errorFamilyOf2,
116
+ isRetryableInScript2,
117
+ UiRunError2,
118
+ UiDriverError2,
119
+ realClock2,
120
+ createVirtualClock2
121
+ } from "./index-vg8r40y7.js";
122
+ import {
123
+ UI_SCRIPT_STEP_KEY_PREFIX2,
124
+ UI_SCRIPT_STEP_MESSAGES2,
125
+ stepMessageKey2,
126
+ describeTarget2,
127
+ describeExpression2,
128
+ describeStep2
129
+ } from "./index-gvavb597.js";
130
+ import {
42
131
  UI_SCRIPT_VERSION2,
43
132
  MAX_SCRIPT_STEPS2,
44
133
  MAX_SCRIPT_BYTES2,
@@ -69,54 +158,30 @@ import {
69
158
  MAX_NAME_LENGTH2,
70
159
  LEGACY_MAX_BROWSER_STEPS2,
71
160
  LEGACY_MAX_STEPS_BYTES2,
161
+ LEGACY_MAX_STEP_TIMEOUT_MS2,
72
162
  jsonByteLength2,
73
- uiScriptRegistry2,
74
- NAME_PATTERN2,
75
- STEP_ID_PATTERN2,
76
- ELEMENT_KEY_PATTERN2,
77
- uiExpressionSchema2,
78
- uiTargetMethodSchema2,
79
- uiTargetSchema2,
80
- uiTargetRefSchema2,
81
- uiStepSchema2,
82
- uiScriptSchema2,
83
- canonicalJson2,
163
+ CAPABILITY_IDS2,
164
+ SCRIPT_CAPABILITY2,
165
+ requiredCapabilities2,
166
+ missingCapabilities2
167
+ } from "./index-9s5nphx0.js";
168
+ import {
169
+ UI_EXPRESSION_OPS2,
170
+ UI_ANCHOR_RELATIONS2,
171
+ UI_TARGET_METHOD_KINDS2,
172
+ UI_WEB_ACTIONS2,
173
+ UI_DESKTOP_ACTIONS2,
174
+ UI_FLOW_ACTIONS2,
175
+ UI_STEP_ACTIONS2,
176
+ UI_VALUE_TYPES2,
84
177
  childBlocks2,
85
178
  walkSteps2,
86
179
  countSteps2,
87
180
  stepAtPath2,
88
181
  stepTargets2,
89
182
  stepExpressions2,
90
- visitExpression2,
91
- RECORDING_ACTION_OF2,
92
- uiStepFingerprint2,
93
- withFingerprint2,
94
- UiScriptError2,
95
- UI_EXPRESSION_ARITY2,
96
- parseUiScript2,
97
- safeParseUiScript2,
98
- UI_SCRIPT_SCHEMA_HASH2,
99
- schemaHashOf2,
100
- UI_SCRIPT_SCHEMA_TITLE2,
101
- uiScriptJsonSchema2,
102
- CAPABILITY_IDS2,
103
- SCRIPT_CAPABILITY2,
104
- requiredCapabilities2,
105
- missingCapabilities2,
106
- UI_SCRIPT_STEP_KEY_PREFIX2,
107
- UI_SCRIPT_STEP_MESSAGES2,
108
- stepMessageKey2,
109
- describeTarget2,
110
- describeExpression2,
111
- describeStep2,
112
- BROWSER_STEP_ACTIONS2,
113
- fromBrowserActionSteps2,
114
- toBrowserActionSteps2,
115
- targetFromPlaywrightSelector2,
116
- fromRemoteBrowserSteps2,
117
- fromRecording2,
118
- toRecording2
119
- } from "./index-zwrxw3zp.js";
183
+ visitExpression2
184
+ } from "./index-g7724awk.js";
120
185
  import {
121
186
  REDACTED2,
122
187
  redactCredentials2
@@ -124,10 +189,21 @@ import {
124
189
  export {
125
190
  BROWSER_STEP_ACTIONS2 as BROWSER_STEP_ACTIONS,
126
191
  CAPABILITY_IDS2 as CAPABILITY_IDS,
192
+ COMPILED_NAME_PREFIX2 as COMPILED_NAME_PREFIX,
193
+ DEFAULT_FIRST_WAIT_MS2 as DEFAULT_FIRST_WAIT_MS,
194
+ DEFAULT_LIST_ITEMS2 as DEFAULT_LIST_ITEMS,
195
+ DEFAULT_MAX_EVENTS2 as DEFAULT_MAX_EVENTS,
196
+ DEFAULT_POLL_INTERVAL_MS2 as DEFAULT_POLL_INTERVAL_MS,
197
+ DEFAULT_RETRY_DELAY_MS2 as DEFAULT_RETRY_DELAY_MS,
198
+ DEFAULT_WAIT_MS2 as DEFAULT_WAIT_MS,
127
199
  ELEMENT_KEY_PATTERN2 as ELEMENT_KEY_PATTERN,
128
200
  LEGACY_MAX_BROWSER_STEPS2 as LEGACY_MAX_BROWSER_STEPS,
129
201
  LEGACY_MAX_STEPS_BYTES2 as LEGACY_MAX_STEPS_BYTES,
202
+ LEGACY_MAX_STEP_TIMEOUT_MS2 as LEGACY_MAX_STEP_TIMEOUT_MS,
203
+ MAX_CALL_DEPTH2 as MAX_CALL_DEPTH,
130
204
  MAX_DELAY_MS2 as MAX_DELAY_MS,
205
+ MAX_EVENTS_LIMIT2 as MAX_EVENTS_LIMIT,
206
+ MAX_EVENT_MESSAGE2 as MAX_EVENT_MESSAGE,
131
207
  MAX_EXPRESSION_DEPTH2 as MAX_EXPRESSION_DEPTH,
132
208
  MAX_EXPRESSION_ITEMS2 as MAX_EXPRESSION_ITEMS,
133
209
  MAX_EXTRACT_FIELDS2 as MAX_EXTRACT_FIELDS,
@@ -141,6 +217,7 @@ export {
141
217
  MAX_LOOP_ITERATIONS2 as MAX_LOOP_ITERATIONS,
142
218
  MAX_NAME_LENGTH2 as MAX_NAME_LENGTH,
143
219
  MAX_OPERATOR_ARGS2 as MAX_OPERATOR_ARGS,
220
+ MAX_PAGE_TEXT2 as MAX_PAGE_TEXT,
144
221
  MAX_RECORDED_STEPS2 as MAX_RECORDED_STEPS,
145
222
  MAX_RETRY_ATTEMPTS2 as MAX_RETRY_ATTEMPTS,
146
223
  MAX_SCRIPT_BYTES2 as MAX_SCRIPT_BYTES,
@@ -152,10 +229,13 @@ export {
152
229
  MAX_SELECTOR_LENGTH2 as MAX_SELECTOR_LENGTH,
153
230
  MAX_SELECT_VALUES2 as MAX_SELECT_VALUES,
154
231
  MAX_SNAPSHOT_NODES2 as MAX_SNAPSHOT_NODES,
232
+ MAX_STEP_LOG_ENTRIES2 as MAX_STEP_LOG_ENTRIES,
155
233
  MAX_STEP_TIMEOUT_MS2 as MAX_STEP_TIMEOUT_MS,
156
234
  MAX_TARGET_METHODS2 as MAX_TARGET_METHODS,
157
235
  MAX_TEXT_LENGTH2 as MAX_TEXT_LENGTH,
158
236
  MAX_URL_LENGTH2 as MAX_URL_LENGTH,
237
+ MAX_VALUE_ITEMS2 as MAX_VALUE_ITEMS,
238
+ MAX_VALUE_TEXT2 as MAX_VALUE_TEXT,
159
239
  NAME_PATTERN2 as NAME_PATTERN,
160
240
  RECORDING_ACTION_OF2 as RECORDING_ACTION_OF,
161
241
  RECORDING_VERSION2 as RECORDING_VERSION,
@@ -165,11 +245,22 @@ export {
165
245
  SAVED_STEP_AUTHORS2 as SAVED_STEP_AUTHORS,
166
246
  SCRIPT_CAPABILITY2 as SCRIPT_CAPABILITY,
167
247
  STEP_ID_PATTERN2 as STEP_ID_PATTERN,
248
+ UI_ANALYZER_DEFAULT_SEVERITY2 as UI_ANALYZER_DEFAULT_SEVERITY,
249
+ UI_ANALYZER_RULES2 as UI_ANALYZER_RULES,
250
+ UI_ANALYZER_RULE_GROUPS2 as UI_ANALYZER_RULE_GROUPS,
251
+ UI_ANALYZER_RULE_IDS2 as UI_ANALYZER_RULE_IDS,
168
252
  UI_ANCHOR_RELATIONS2 as UI_ANCHOR_RELATIONS,
169
253
  UI_DESKTOP_ACTIONS2 as UI_DESKTOP_ACTIONS,
254
+ UI_ERROR_CODES2 as UI_ERROR_CODES,
255
+ UI_ERROR_CODE_LIST2 as UI_ERROR_CODE_LIST,
256
+ UI_ERROR_FAMILIES2 as UI_ERROR_FAMILIES,
170
257
  UI_EXPRESSION_ARITY2 as UI_EXPRESSION_ARITY,
171
258
  UI_EXPRESSION_OPS2 as UI_EXPRESSION_OPS,
172
259
  UI_FLOW_ACTIONS2 as UI_FLOW_ACTIONS,
260
+ UI_PROBLEM_SEVERITIES2 as UI_PROBLEM_SEVERITIES,
261
+ UI_RUN_EVENT_KINDS2 as UI_RUN_EVENT_KINDS,
262
+ UI_SCRIPT_PROBLEM_KEY_PREFIX2 as UI_SCRIPT_PROBLEM_KEY_PREFIX,
263
+ UI_SCRIPT_PROBLEM_MESSAGES2 as UI_SCRIPT_PROBLEM_MESSAGES,
173
264
  UI_SCRIPT_SCHEMA_HASH2 as UI_SCRIPT_SCHEMA_HASH,
174
265
  UI_SCRIPT_SCHEMA_TITLE2 as UI_SCRIPT_SCHEMA_TITLE,
175
266
  UI_SCRIPT_STEP_KEY_PREFIX2 as UI_SCRIPT_STEP_KEY_PREFIX,
@@ -179,20 +270,31 @@ export {
179
270
  UI_TARGET_METHOD_KINDS2 as UI_TARGET_METHOD_KINDS,
180
271
  UI_VALUE_TYPES2 as UI_VALUE_TYPES,
181
272
  UI_WEB_ACTIONS2 as UI_WEB_ACTIONS,
273
+ UiDriverError2 as UiDriverError,
274
+ UiRunError2 as UiRunError,
182
275
  UiScriptError2 as UiScriptError,
183
276
  afterReplayCall2 as afterReplayCall,
277
+ analyzeUiScript2 as analyzeUiScript,
278
+ applyPins2 as applyPins,
184
279
  canonicalJson2 as canonicalJson,
185
280
  captureRecording2 as captureRecording,
186
281
  childBlocks2 as childBlocks,
282
+ compileUiScript2 as compileUiScript,
187
283
  countSteps2 as countSteps,
284
+ createVirtualClock2 as createVirtualClock,
188
285
  describeExpression2 as describeExpression,
189
286
  describeStep2 as describeStep,
190
287
  describeTarget2 as describeTarget,
288
+ errorFamilyOf2 as errorFamilyOf,
289
+ evaluateExpression2 as evaluateExpression,
191
290
  finishFallback2 as finishFallback,
192
291
  fromBrowserActionSteps2 as fromBrowserActionSteps,
193
292
  fromRecording2 as fromRecording,
194
293
  fromRemoteBrowserSteps2 as fromRemoteBrowserSteps,
294
+ inlineCalls2 as inlineCalls,
295
+ isRetryableInScript2 as isRetryableInScript,
195
296
  isSavedStepAuthor2 as isSavedStepAuthor,
297
+ isUiErrorCode2 as isUiErrorCode,
196
298
  jsonByteLength2 as jsonByteLength,
197
299
  markFallbackAsked2 as markFallbackAsked,
198
300
  maskUrl2 as maskUrl,
@@ -200,8 +302,12 @@ export {
200
302
  parseRecording2 as parseRecording,
201
303
  parseUiScript2 as parseUiScript,
202
304
  planReplay2 as planReplay,
305
+ problemMessage2 as problemMessage,
306
+ problemMessageKey2 as problemMessageKey,
307
+ readPath2 as readPath,
203
308
  readReplayState2 as readReplayState,
204
309
  readSnapshotNodes2 as readSnapshotNodes,
310
+ realClock2 as realClock,
205
311
  recordedStepSchema2 as recordedStepSchema,
206
312
  recordedTargetSchema2 as recordedTargetSchema,
207
313
  recordingSchema2 as recordingSchema,
@@ -210,17 +316,24 @@ export {
210
316
  replayStateFrom2 as replayStateFrom,
211
317
  requiredCapabilities2 as requiredCapabilities,
212
318
  resolveTarget2 as resolveTarget,
319
+ runUiScript2 as runUiScript,
213
320
  safeParseUiScript2 as safeParseUiScript,
214
321
  schemaHashOf2 as schemaHashOf,
215
322
  sha256Hex2 as sha256Hex,
216
323
  stepAtPath2 as stepAtPath,
217
324
  stepExpressions2 as stepExpressions,
218
325
  stepMessageKey2 as stepMessageKey,
326
+ stepNumber2 as stepNumber,
219
327
  stepTargets2 as stepTargets,
328
+ stripBreakpoints2 as stripBreakpoints,
220
329
  targetFingerprint2 as targetFingerprint,
221
330
  targetFromPlaywrightSelector2 as targetFromPlaywrightSelector,
222
331
  toBrowserActionSteps2 as toBrowserActionSteps,
332
+ toNumber2 as toNumber,
223
333
  toRecording2 as toRecording,
334
+ toText2 as toText,
335
+ toUiValue2 as toUiValue,
336
+ truthy2 as truthy,
224
337
  uiExpressionSchema2 as uiExpressionSchema,
225
338
  uiScriptJsonSchema2 as uiScriptJsonSchema,
226
339
  uiScriptRegistry2 as uiScriptRegistry,
@@ -230,6 +343,7 @@ export {
230
343
  uiTargetMethodSchema2 as uiTargetMethodSchema,
231
344
  uiTargetRefSchema2 as uiTargetRefSchema,
232
345
  uiTargetSchema2 as uiTargetSchema,
346
+ valuesEqual2 as valuesEqual,
233
347
  visitExpression2 as visitExpression,
234
348
  walkSteps2 as walkSteps,
235
349
  withFingerprint2 as withFingerprint
@@ -0,0 +1,58 @@
1
+ import type { UiScript, UiScriptInput, UiScriptOutput, UiStep } from '../script/types.js';
2
+ /** A pinned element as `workerResolveUiAssets` returns it (`UiResolvedElement`). */
3
+ export interface ResolvedUiElement {
4
+ key: string;
5
+ elementId: string;
6
+ version: number;
7
+ name?: string;
8
+ /** A UI target of the engine schema (validated here). */
9
+ target: unknown;
10
+ }
11
+ /** A pinned shared sequence version as `workerResolveUiAssets` returns it (`UiResolvedSequence`). */
12
+ export interface ResolvedUiSequence {
13
+ sequenceId: string;
14
+ version: number;
15
+ /** `UiScriptInput[]`. */
16
+ arguments: readonly UiScriptInput[];
17
+ /** `UiScriptOutput[]`. */
18
+ outputs: readonly UiScriptOutput[];
19
+ /** `UiStep[]`; element references use the sequence's own keys. */
20
+ steps: readonly UiStep[];
21
+ elements: readonly ResolvedUiElement[];
22
+ }
23
+ /** Deepest chain of shared sequences calling shared sequences. */
24
+ export declare const MAX_CALL_DEPTH = 4;
25
+ /** The prefix of names the compiler gives a shared sequence's variables, arguments and elements. */
26
+ export declare const COMPILED_NAME_PREFIX = "__c";
27
+ /** A call the compiler inlined: the retry scope that replaced it keeps the call's step id. */
28
+ export interface InlinedCall {
29
+ stepId: string;
30
+ sequenceId: string;
31
+ version: number;
32
+ }
33
+ /** Fill the target (and the name, when absent) of every element the script pins. */
34
+ export declare function applyPins(script: UiScript, resolved: readonly ResolvedUiElement[]): UiScript;
35
+ /** The script without breakpoints (production runs never pause). */
36
+ export declare function stripBreakpoints(script: UiScript): UiScript;
37
+ /** Inline every `call` step, nested calls included (at most `MAX_CALL_DEPTH` deep). */
38
+ export declare function inlineCalls(script: UiScript, sequences: readonly ResolvedUiSequence[]): {
39
+ script: UiScript;
40
+ calls: InlinedCall[];
41
+ };
42
+ export interface CompileUiScriptOptions {
43
+ /** The pinned elements (`workerResolveUiAssets` `elements`). */
44
+ elements?: readonly ResolvedUiElement[];
45
+ /** The pinned shared sequences (`workerResolveUiAssets` `sequences`). */
46
+ sequences?: readonly ResolvedUiSequence[];
47
+ /** `test` keeps breakpoints; `production` (the default) removes them. */
48
+ mode?: 'test' | 'production';
49
+ /** The desk's capability ids; when given, a script the desk cannot run fails with `UNSUPPORTED_ON_DESK`. */
50
+ capabilities?: readonly string[];
51
+ }
52
+ export interface CompiledUiScript {
53
+ script: UiScript;
54
+ requiredCapabilities: string[];
55
+ calls: InlinedCall[];
56
+ }
57
+ /** Compile a stored script (an object or its JSON text) into the resolved script a desk runs. */
58
+ export declare function compileUiScript(value: unknown, options?: CompileUiScriptOptions): CompiledUiScript;
@@ -0,0 +1,171 @@
1
+ /**
2
+ * The desk driver interface (plan P1-02): what a desk implements so the
3
+ * interpreter can run a UI script on it. The paired browser (the extension,
4
+ * P1-09) forwards each call to the DOM runtime in the tab; the remote-browser
5
+ * executor (P1-07) forwards it over CDP to the runtime in an isolated world;
6
+ * the engine ships a DOM driver, a snapshot driver (P1-05 replay) and a fake
7
+ * web driver for tests (`@burdenoff/ui-engine/drivers`, `/testing`).
8
+ *
9
+ * A driver makes one attempt per call. The interpreter owns waiting: it polls
10
+ * a call until it succeeds, fails for good, or the step's wait runs out, so
11
+ * every desk waits the same way. Results are plain JSON; a driver never puts
12
+ * typed text or a secret in a result's report fields.
13
+ *
14
+ * A driver reports a desk failure (a navigation timeout, a lost tab) by
15
+ * throwing `UiDriverError` with an engine code. Anything else it throws is
16
+ * reported as `DRIVER_ERROR`.
17
+ */
18
+ import type { DomAction, DomActionProblem } from '../dom-runtime/actions.js';
19
+ import type { DomResolution } from '../dom-runtime/runtime.js';
20
+ import type { UiStepAction, UiTarget } from '../script/types.js';
21
+ import type { WebElementState, WebTargetErrorCode } from '../target/types.js';
22
+ /** Where the interpreter is when it calls the driver. */
23
+ export interface UiStepContext {
24
+ /** The step path (`"2"`, `"2.then.0"`, `"cleanup.0"`). */
25
+ path: string;
26
+ stepId: string;
27
+ action: UiStepAction;
28
+ /** 1 for the first attempt of the step, then 2, 3 for its retries. */
29
+ attempt: number;
30
+ /** Aborted when the run is cancelled; a driver that can stop a call early listens to it. */
31
+ signal?: AbortSignal;
32
+ }
33
+ /** Time as the interpreter sees it. A snapshot or test driver passes a virtual clock so waits take no real time. */
34
+ export interface UiClock {
35
+ /** Milliseconds since the epoch. */
36
+ now(): number;
37
+ /** Resolves after `ms` milliseconds, or rejects when the signal aborts. */
38
+ sleep(ms: number, signal?: AbortSignal): Promise<void>;
39
+ }
40
+ /** What a read takes from an element. `auto` is the value of a form control, otherwise the visible text. */
41
+ export type UiReadKind = {
42
+ kind: 'auto';
43
+ } | {
44
+ kind: 'text';
45
+ } | {
46
+ kind: 'value';
47
+ } | {
48
+ kind: 'html';
49
+ } | {
50
+ kind: 'attribute';
51
+ name: string;
52
+ };
53
+ /** A value a read returns. */
54
+ export type UiReadValue = string | boolean | null;
55
+ /** A failure of one driver call on a target. */
56
+ export interface UiDriverFailure {
57
+ ok: false;
58
+ code: WebTargetErrorCode | DomActionProblem;
59
+ resolution?: DomResolution;
60
+ reason?: 'covered' | 'noPointerEvents' | 'offscreen';
61
+ }
62
+ /**
63
+ * The result of an action or a read. The DOM runtime's `DomActResult` has
64
+ * this shape, so a driver can return the runtime's answer unchanged. A
65
+ * successful result without a resolution means the desk did not resolve a
66
+ * target for the call (an action on the focused element, or a step a
67
+ * snapshot replay does not check).
68
+ */
69
+ export type UiDriverResult = {
70
+ ok: true;
71
+ value?: UiReadValue;
72
+ resolution?: DomResolution;
73
+ } | UiDriverFailure;
74
+ /** The result of reading every element a target matches. */
75
+ export type UiDriverListResult<T> = {
76
+ ok: true;
77
+ items: T[];
78
+ resolution?: DomResolution;
79
+ } | UiDriverFailure;
80
+ /** One field of a list row: its target is searched inside each item. */
81
+ export interface UiListField {
82
+ name: string;
83
+ target: UiTarget;
84
+ read: UiReadKind;
85
+ /** Read every match inside the item as a list. */
86
+ all: boolean;
87
+ }
88
+ /** A row of an extracted list: field name to value. */
89
+ export type UiListRow = Record<string, UiReadValue | UiReadValue[]>;
90
+ /** The targets of a `login` step; absent targets use the desk's defaults. */
91
+ export interface UiLoginTargets {
92
+ username?: UiTarget;
93
+ password?: UiTarget;
94
+ submit?: UiTarget;
95
+ success?: UiTarget;
96
+ }
97
+ export interface UiDriver {
98
+ /** The capability ids this desk supports (`CAPABILITY_IDS` of the script module). */
99
+ readonly capabilities: readonly string[];
100
+ /** Absent means real time. */
101
+ readonly clock?: UiClock;
102
+ /**
103
+ * True when the page never changes between calls (a stored snapshot): the
104
+ * interpreter then makes one attempt instead of polling.
105
+ */
106
+ readonly staticPage?: boolean;
107
+ /**
108
+ * True for a snapshot replay: only targets are checked, so the interpreter
109
+ * skips verification, paging, and waits that are not for a target to appear.
110
+ */
111
+ readonly replay?: boolean;
112
+ /** Resolve a target once, in the given state. */
113
+ resolve(target: UiTarget, options: {
114
+ state: WebElementState;
115
+ }, context: UiStepContext): Promise<DomResolution>;
116
+ /** Act on the one element a target resolves to, or on the focused element when `target` is null. */
117
+ act(target: UiTarget | null, action: DomAction, options: {
118
+ state?: WebElementState;
119
+ }, context: UiStepContext): Promise<UiDriverResult>;
120
+ /** Read from the one element a target resolves to (it must be visible). */
121
+ read(target: UiTarget, read: UiReadKind, context: UiStepContext): Promise<UiDriverResult>;
122
+ /** Read from every visible element the first matching method finds, in document order. */
123
+ readAll(target: UiTarget, read: UiReadKind, context: UiStepContext): Promise<UiDriverListResult<UiReadValue>>;
124
+ /** Read up to `maxItems` rows: every element `item` matches, with each field searched inside it. */
125
+ listItems(item: UiTarget, fields: readonly UiListField[], maxItems: number, context: UiStepContext): Promise<UiDriverListResult<UiListRow>>;
126
+ /** Press keys together (one key, or modifiers and a key) on a target, or on the focused element when null. */
127
+ pressKeys(target: UiTarget | null, keys: readonly string[], context: UiStepContext): Promise<UiDriverResult>;
128
+ navigate(url: string, options: {
129
+ waitUntil: 'load' | 'domcontentloaded' | 'networkidle' | 'commit';
130
+ timeoutMs: number;
131
+ }, context: UiStepContext): Promise<void>;
132
+ goBack(options: {
133
+ timeoutMs: number;
134
+ }, context: UiStepContext): Promise<void>;
135
+ reload(options: {
136
+ timeoutMs: number;
137
+ }, context: UiStepContext): Promise<void>;
138
+ closeTab(context: UiStepContext): Promise<void>;
139
+ currentUrl(context: UiStepContext): Promise<string>;
140
+ /** The page's visible text. */
141
+ pageText(context: UiStepContext): Promise<string>;
142
+ pageHtml(context: UiStepContext): Promise<string>;
143
+ scrollPage(options: {
144
+ dx?: number;
145
+ dy?: number;
146
+ to?: 'top' | 'bottom';
147
+ }, context: UiStepContext): Promise<void>;
148
+ /** Type a secret the desk redeems itself; the value never reaches the interpreter. */
149
+ typeSecret?(target: UiTarget, secret: {
150
+ secretRef: string;
151
+ expectedOrigin?: string;
152
+ }, context: UiStepContext): Promise<UiDriverResult>;
153
+ /** Sign in through the node's Browser Login connection (remote browsers). Throws `LOGIN_FAILED`. */
154
+ login?(targets: UiLoginTargets, options: {
155
+ timeoutMs: number;
156
+ }, context: UiStepContext): Promise<void>;
157
+ /** Take a screenshot; returns a reference the host can store (a Files id), or null. */
158
+ screenshot?(options: {
159
+ target?: UiTarget;
160
+ fullPage?: boolean;
161
+ }, context: UiStepContext): Promise<string | null>;
162
+ }
163
+ /** Real time. */
164
+ export declare const realClock: UiClock;
165
+ /**
166
+ * A clock that moves only when the interpreter sleeps: a sleep advances it at
167
+ * once. Snapshot replays and tests use it so a 10-second wait costs nothing.
168
+ */
169
+ export declare function createVirtualClock(start?: number): UiClock & {
170
+ advance(ms: number): void;
171
+ };