@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/README.md CHANGED
@@ -14,7 +14,7 @@ bun add @burdenoff/ui-engine zod
14
14
 
15
15
  ## Modules
16
16
 
17
- Each module is a subpath export. The root entry re-exports the data and planning modules (`recording` to `script`); the DOM modules (`target`, `dom-runtime`, `testing`) are subpath-only, so a consumer without DOM types, such as a service, never loads them through the root.
17
+ Each module is a subpath export. The root entry re-exports the data and planning modules (`recording` to `script`, `interpret` and `analyze`); the DOM modules (`target`, `dom-runtime`, `drivers`, `testing`) are subpath-only, so a consumer without DOM types, such as a service, never loads them through the root.
18
18
 
19
19
  | Import | What it holds |
20
20
  |---|---|
@@ -24,10 +24,13 @@ Each module is a subpath export. The root entry re-exports the data and planning
24
24
  | `@burdenoff/ui-engine/replay` | The pure replay planner: `replayStateFrom`, `planReplay`, `afterReplayCall`, `finishFallback`, `markFallbackAsked`, `replayReasons`, `readReplayState` |
25
25
  | `@burdenoff/ui-engine/script` | UI script v1: types, `uiScriptSchema`, `parseUiScript`, `UI_SCRIPT_SCHEMA_HASH`, `requiredCapabilities`, the adapters and `describeStep` (see below) |
26
26
  | `@burdenoff/ui-engine/schema/ui-script-v1.schema.json` | The JSON Schema (draft 2020-12) of UI script v1 |
27
- | `@burdenoff/ui-engine/target` | The multi-method web target resolver (`resolveWebTarget`), accessible role and name helpers, and value-free tree snapshots (`serializeTreeSnapshot`, `hydrateTreeSnapshot`) |
27
+ | `@burdenoff/ui-engine/target` | The multi-method web target resolver (`resolveWebTarget`, and `resolveAllWebTargets` for reads of every match), accessible role and name helpers, and value-free tree snapshots (`serializeTreeSnapshot`, `hydrateTreeSnapshot`) |
28
28
  | `@burdenoff/ui-engine/dom-runtime` | The DOM runtime a desk injects into a page (`createDomRuntime`, `installDomRuntime`): resolve, act, highlight, snapshot |
29
29
  | `@burdenoff/ui-engine/dom-runtime.iife.js` | The same runtime as one self-contained script (at most 60 KB minified) that installs itself on `globalThis.__burdenoffUiRuntime` |
30
- | `@burdenoff/ui-engine/testing` | Copies of the RPA playground fixture pages (`RPA_FIXTURES`) and `mountFixture` for test DOMs |
30
+ | `@burdenoff/ui-engine/interpret` | The UI script interpreter (`runUiScript`), the compiler a worker runs before it parks a node (`compileUiScript`, `applyPins`, `inlineCalls`, `stripBreakpoints`), the expression evaluator, the desk driver interface and every run-time error code with its node error family (`UI_ERROR_CODES`) |
31
+ | `@burdenoff/ui-engine/analyze` | The UI script analyzer: `analyzeUiScript`, the 11 rules of v1 (`UI_ANALYZER_RULES`), problem message keys under `fluidgrids.builder.uiScript.problem.*` with English templates (`UI_SCRIPT_PROBLEM_MESSAGES`), and `stepNumber` (see below) |
32
+ | `@burdenoff/ui-engine/drivers` | Desk drivers over a DOM: `createDomDriver` (the DOM runtime in the interpreter's own world) and `createSnapshotDriver` with `replayUiScriptOnSnapshot` (snapshot replay with no browser) |
33
+ | `@burdenoff/ui-engine/testing` | Copies of the RPA playground fixture pages (`RPA_FIXTURES`), `mountFixture` for test DOMs, and `createFakeWebDriver`, a fake web desk over them |
31
34
 
32
35
  ## UI script v1
33
36
 
@@ -57,7 +60,7 @@ A UI script is the portable form of a UI sequence that a desk runs: a paired bro
57
60
  |---|---|---|
58
61
  | `fromRecording`, `toRecording` | Stewards saved-step recording v1 | Lossless both ways, fingerprints included; `toRecording` returns null for a script a recording cannot express |
59
62
  | `fromBrowserActionSteps` | Run in Browser steps (`internal:browser-action`) | Keeps every field a 0.3.0 extension reads |
60
- | `toBrowserActionSteps` | Lowering to Run in Browser steps | Null unless the script fits the legacy contract: at most 100 steps and 256 KB, only the 14 legacy actions, one CSS selector per target (or one text for click and wait), literal or supplied input values, no script wait or screenshot settings beyond the defaults, and no flow steps, verification, retries or breakpoints |
63
+ | `toBrowserActionSteps` | Lowering to Run in Browser steps | Null unless the script fits the legacy contract: at most 100 steps and 256 KB, only the 14 legacy actions, one CSS selector per target (or one text for click and wait), step waits of at most 60 s (the legacy extension's cap), literal or supplied input values, no script wait or screenshot settings beyond the defaults, and no flow steps, verification, retries or breakpoints |
61
64
  | `fromRemoteBrowserSteps` | Remote Browser `runSteps` (`store/remotebrowser` 1.0.0) | Playwright `css=`, `text=`, `xpath=`, `id=` and `data-testid=` selectors; other engines are refused |
62
65
 
63
66
  **Descriptions.** `describeStep(step, elements)` returns `{ key, vars, fallback }`, with keys under `fluidgrids.uiScript.step.*` for `tr(key, vars)` and an English fallback; `UI_SCRIPT_STEP_MESSAGES` holds every English template.
@@ -76,7 +79,7 @@ The resolver and the runtime implement spec 05 section 3 for web pages (plan P1-
76
79
  | `ELEMENT_AMBIGUOUS` | A method matched several elements and no later method found one | up to 5, from the first ambiguous method |
77
80
  | `ELEMENT_NOT_INTERACTABLE` | Elements matched but none is visible and enabled (disabled, inside a disabled control or fieldset, `inert`, `aria-disabled`, hidden, or in a hidden or inert frame); for a pointer action also `reason` `covered`, `offscreen` (still outside the viewport after scrolling into view) or `noPointerEvents` | up to 5 |
78
81
 
79
- A candidate carries `role`, `name` (cut to 200 characters; empty for sensitive elements; for typed content, an editor or a text area or anything inside one, only the name its labels give), `bounds` (CSS pixels in the top viewport) and the matching `method` and `methodIndex`. The interpreter (P1-02) maps the codes to node error families.
82
+ A candidate carries `role`, `name` (cut to 200 characters; empty for sensitive elements; for typed content, an editor or a text area or anything inside one, only the name its labels give), `bounds` (CSS pixels in the top viewport) and the matching `method` and `methodIndex`. The interpreter maps the codes to node error families (see below).
80
83
 
81
84
  **Methods on the web.** `role` compares the computed role and accessible name (a compact accname subset; form fields never take a name from their value) after NFKC, whitespace and case normalisation; `app` and `window` are desktop fields and are ignored. `css` and `xpath` use the page's engines (`xpath` is `unsupported` where the DOM has none). `testId` compares an attribute (default `data-testid`). `fuzzy` scores the edit-distance similarity of names (threshold 0.8 by default, never below 0.5). `anchor` finds a text or role anchor, then the element `inside` it (or inside the heading's container) or the nearest element `leftOf`, `rightOf`, `above`, `below` or on the `sameRow`, from element bounds. `text` matches the innermost element whose visible text contains (or, with `exact`, equals) the text.
82
85
 
@@ -88,6 +91,69 @@ The runtime must be injected into an isolated world (a content script, or a CDP
88
91
 
89
92
  **Fixtures.** `@burdenoff/ui-engine/testing` holds copies of the playground pages (`invoices`, `invoices-v2` with renamed ids and moved elements, `invoices-v3` with slightly changed wording, `ambiguous` with two identical Save buttons and a counter, `iframe`, `shadow`, `login`) for the same pages the live suites use (plan P0-08); `mountFixture(document, name)` loads one into a test DOM, attaching declarative shadow roots and filling `srcdoc` frames where the DOM does not.
90
93
 
94
+ ## The interpreter
95
+
96
+ `runUiScript(script, driver, options)` runs a compiled UI script on a desk and reports step events (plan P1-02, BOFF-17167). It never throws for a script problem: the result carries `status` (`succeeded`, `failed`, `cancelled`, `stopped`), `outputs`, `results` (every `saveAs` value), a `stepLog`, the `error` (`code`, `family`, `message`, `stepPath`, `stepId`), `lastCompletedStepPath` (the checkpoint after the last action step that passed) and event counts.
97
+
98
+ **Compile first.** A worker compiles a stored script with `compileUiScript(script, { elements, sequences, mode, capabilities })`: it fills each pinned element's target from `workerResolveUiAssets`, inlines every shared-sequence `call` (the call becomes a one-attempt retry scope with the call's id, so no other step's path moves; the sequence's names get the reserved prefix `__c<n>_`, which the run leaves out of `results`), removes breakpoints unless `mode` is `test`, and parses the result with `resolved: true`. Problems are `UiRunError` with `INVALID_SCRIPT` or `UNSUPPORTED_ON_DESK`.
99
+
100
+ **Semantics.**
101
+
102
+ - *Preflight*: the run parses the script with `resolved: true`, checks the driver's capabilities, the step range and the inputs, and refuses a masked `type` step without a value (a disabled step, or one inside a disabled block, never runs and is not checked). A problem ends the run before any step runs, with only a FINISHED event.
103
+ - *Waits*: a step that needs a target polls the driver (every 250 ms) until the target resolves to exactly one element in the required state or the wait runs out: the step's `timeoutMs`, else `settings.firstWaitMs` (30 s) for the first targeted step on a screen and `settings.waitMs` (10 s) afterwards. An ambiguous target is never acted on. Action problems (`NOT_EDITABLE` and the others) and sensitive reads end the wait at once.
104
+ - *Retries and verification*: `retry.attempts` more attempts after a failure (default delay 1 s); a failed `verify` fails the attempt with `VERIFY_FAILED`. Failures of the VALIDATION, AUTHORIZATION and CANCELLED families are not retried. `onError: continue` records the failure, stores null under `saveAs` and goes on.
105
+ - *Flow*: `if` (a condition, or an element that exists once), `forEach` (a list, or the visible text of every element a target matches; `max` caps it), `while` (stops at `maxIterations` with a warning), `retryScope`, `set` and `log` (messages pass through `redactCredentials`). Reads that may legitimately be empty (`elementExists`, the first page of `extractList`) wait only when the step sets `timeoutMs`. Existence checks fail with `ELEMENT_AMBIGUOUS` when several elements match, like the runtime's `exists`: make the target match one element. A `waitFor` with `state: hidden` and a `verify` of `elementGone` count an element that is still in the page but hidden as gone; `state: detached` needs it removed.
106
+ - *Clean-up*: `cleanup` steps run when the main steps end, after a failure, a cancel or a STOP too (`skipCleanupOnCancel` skips them after a cancel). A failing clean-up step fails a run that had succeeded, and never hides an earlier failure.
107
+ - *TEST runs*: with `mode: 'test'` and `waitForCommand`, the run pauses before a step with `breakpoint` (and before the first step with `stepThrough`), emits PAUSED, and follows NEXT (run the step, pause again), SKIP, CONTINUE and STOP (`STOPPED_BY_USER`, also during clean-up). A `waitForCommand` that rejects fails that step with `DRIVER_ERROR`, and the clean-up still runs. A production run never pauses.
108
+ - *Step ranges*: `startAt` and `stopAfter` are step paths. Steps before `startAt` are skipped with STEP_SKIPPED (`reason: outsideRange`); a block around it is entered (an `if` takes the branch that holds it without evaluating the condition, a loop skips the earlier steps in its first pass only); the run ends after `stopAfter` completes. The window is in walk order, so the clean-up block runs only when the range reaches it. A range whose start is never reached (a disabled block, a loop with no pass) fails `INVALID_STEP_RANGE` instead of succeeding. Variables earlier steps would have set must be given as inputs.
109
+ - *Cancel*: `signal` aborts waits and pauses; the run ends `CANCELLED`.
110
+
111
+ **Events** have the contract's `UiTaskEventInput` shape: `seq` from 1, `kind` (`STEP_STARTED`, `STEP_PASSED`, `STEP_FAILED`, `STEP_SKIPPED`, `PAUSED`, `RESUMED`, `LOG`, `FINISHED`), `stepPath`, `stepId`, `action`, `resolvedBy`, `durationMs`, `errorCode`, `message`, `screenshotFileId`, `detail` and `at`. A failure's `detail` holds what was looked for: `waitedMs`, the method `attempts`, up to five `candidates` with `candidateCount`, the frame problem, `reason` or the desk `problem`, and `stepAttempts`. Events never carry typed text, read values or secrets. After `maxEvents - 1` events (default 10,000) one LOG summary with `detail.truncated` is emitted and the rest are dropped, except FINISHED. The `stepLog` keeps at most 500 entries of `path`, `stepId`, `action`, `status`, `method`, `durationMs`, `elementId`, `screenshotFileId` and the short `error` code.
112
+
113
+ **Error codes.** Every code and its node error family is in `UI_ERROR_CODES` (`errors.ts`):
114
+
115
+ | Family | Codes |
116
+ |---|---|
117
+ | DEPENDENCY | `ELEMENT_NOT_FOUND`, `ELEMENT_AMBIGUOUS`, `WINDOW_NOT_FOUND`, `UNEXPECTED_WINDOW`, `ACTION_FAILED` (the desk problem in `detail.problem`), `SECRET_UNAVAILABLE` |
118
+ | TRANSIENT | `ELEMENT_NOT_INTERACTABLE`, `VERIFY_FAILED`, `NAVIGATION_TIMEOUT`, `NAVIGATION_FAILED`, `WAIT_TIMEOUT`, `APPLICATION_NOT_RESPONDING`, `ROBOT_LOST`, `INTERRUPTED`, `DRIVER_ERROR` |
119
+ | VALIDATION | `UNSUPPORTED_ON_DESK`, `INVALID_SCRIPT`, `INVALID_INPUT` and `INVALID_STEP_RANGE` (all four before any step runs), `EXPRESSION_ERROR`, `SENSITIVE_ELEMENT`, `URL_NOT_ALLOWED` |
120
+ | AUTHORIZATION | `LOGIN_FAILED` |
121
+ | DISPATCH_FAILED | `DESK_UNAVAILABLE` |
122
+ | CANCELLED | `CANCELLED`, `STOPPED_BY_USER` |
123
+
124
+ `ELEMENT_AMBIGUOUS` is DEPENDENCY, not VALIDATION: ambiguity is observed on the live page at run time, like `ELEMENT_NOT_FOUND`, and is never raised before a step runs (BOFF-17109).
125
+
126
+ **Drivers.** A desk implements `UiDriver` (`driver.ts`): `resolve`, `act`, `read`, `readAll`, `listItems`, `pressKeys`, navigation, page text and HTML, `scrollPage`, and optionally `typeSecret`, `login` and `screenshot`, plus its `capabilities` and an optional `clock`. A driver makes one attempt per call; the interpreter owns waiting. A desk failure is a thrown `UiDriverError` with an engine code; anything else becomes `DRIVER_ERROR`. `createDomDriver` never reads a sensitive element, and its page text and HTML leave sensitive content, scripts, handlers and field values out. Its `readAll` and `listItems` return the resolution of the method that found the elements, so extract and extract-list steps report `resolvedBy`.
127
+
128
+ **Snapshot replay.** `replayUiScriptOnSnapshot(script, { document, snapshot, stepPath?, elementKeys? })` rebuilds a tree snapshot into an empty, inert document and replays a resolved script on it with a dry-run DOM driver, a virtual clock and one attempt per target. Verification, paging and waits that are not for a target to appear are skipped. A run snapshot taken at a step checks only that step; an element version's snapshot checks the steps that use the given element keys. It returns `{ passed, failedStepPath, errorCode, steps: [{ stepPath, verdict, resolvedBy }] }` with verdicts `passed`, `failed`, `skipped` and `unchecked` (contract `UiSnapshotReplay`).
129
+
130
+ **Expressions.** `evaluateExpression` implements every operator of `UI_EXPRESSION_OPS`. Comparison of two texts is by code unit, otherwise by number; `add`, `sub`, `mul`, `div`, `mod` take numbers or numeric text; `concat` joins text; `replace` replaces every literal occurrence (no regular expressions); `join` uses `,` by default; dates are ISO 8601 text in UTC (`formatDate` tokens `YYYY`, `MM`, `DD`, `HH`, `mm`, `ss`). Results are bounded (1,000,000 characters, 10,000 list items, finite numbers), and errors are `EXPRESSION_ERROR` with messages that name the operator, never a value.
131
+
132
+ ## The analyzer
133
+
134
+ `analyzeUiScript(script, options?)` reads a parsed UI script (call `parseUiScript` first) and returns the problems an author should know about before it runs (spec 14 section 3). It is pure, browser-safe and service-safe, never throws for a script that parsed, and gives the same problems in the builder and in the workflow service. Every problem is advice: the builder shows it on save and never blocks a save (spec 19, M1), and the service reports it as a validation warning. A script that cannot run fails to parse instead, so there is no error severity.
135
+
136
+ A problem is `{ rule, group, severity, messageKey, vars, message, path?, stepId?, field? }`. `messageKey` sits under `fluidgrids.builder.uiScript.problem.*`; the front end translates it with `tr(messageKey, vars)`, and the service, the CLI and logs use the English `message`. `vars.step` is the step number as an author reads it (`stepNumber`: `"5.then.1"` reads `6.2`, `"5.else.0"` reads `6.else.1`, `"cleanup.0"` reads `cleanup.1`), and `vars.target` a quoted target description. Problems are listed with the whole script's first, then each step's in document order (main steps, then clean-up), then the outputs'; within one step, in rule order. Disabled steps, and every step inside a disabled block, are skipped.
137
+
138
+ | Rule | Group | Default | Reports |
139
+ |---|---|---|---|
140
+ | `fixedWait` | reliability | warning | A Wait step that waits a fixed time instead of for an element, a text or an address |
141
+ | `singleMethodTarget` | reliability | warning | A target with only one method switched on (`singleMethodTarget`) or none (`noEnabledMethod`); a library element is reported once, at its first use |
142
+ | `hardwareInput` | reliability | warning | Hardware input for the whole script (`hardwareInputSettings`, only when a running page step inherits it) or for one step |
143
+ | `unknownVariable` | reliability | warning | A variable that a step (`unknownVariable`), an output (`unknownVariableOutput`), a variable's initial value (`unknownVariableInitial`) or an input's default (`unknownVariableDefault`) reads, but that no running step sets and the script does not declare (it reads as empty) |
144
+ | `maskedValue` | reliability | warning | A Type step whose value was masked during recording (`maskedValue`, the run stops with `INVALID_SCRIPT`) or that has no value at all (`typeWithoutValue`) |
145
+ | `noCleanup` | reliability | warning | A script that signs in or types a secret with no clean-up step that runs, once, at the first sign-in |
146
+ | `plainTextSecret` | security | warning | A plain Type step into a field whose name, label, selector or library element name reads like a password or code field (the capture rule's word list, with the short words otp, token, secret, verification and recovery matched as whole words, plus `type=password` selectors) |
147
+ | `secretOrigin` | security | warning | A Type secret step without `expectedOrigin` |
148
+ | `sensitiveScreenshot` | security | warning | A step that signs in or types a secret and takes a screenshot every time, by its own policy (`sensitiveScreenshot`) or by the script's `everyStep` (`sensitiveScreenshotSettings`); a step that sets `never` or `onFailure` is not reported |
149
+ | `inlineTarget` | maintainability | info | A step's first inline target, which could be an Element library element |
150
+ | `unusedValue` | maintainability | info | A declared variable nothing reads (`unusedVariable`), and a `set` or `saveAs` value no step, output or later node reads (`unusedValue`). A `set` or `saveAs` value is a key of the node's results, so it is reported only when `externalReads` is given, except a `__` name, which never reaches the results |
151
+
152
+ Options:
153
+
154
+ - `severity`: a workspace's setting per rule, `warning`, `info` or `off` (drops the rule's problems). Any other stored value is ignored and the rule keeps its default. `UI_ANALYZER_DEFAULT_SEVERITY` holds the defaults.
155
+ - `externalReads`: the result names other nodes of the workflow read. A `set` or `saveAs` value is a key of the node's results, so without this list it is never reported as unused; the builder passes it, the service may leave it out.
156
+
91
157
  ## Compatibility with Stewards
92
158
 
93
159
  The modules were copied from `wspace-botmanor-svc` `src/modules/stewards/teach/` at commit `6558d8b` (BOFF-16873). The differences are:
@@ -0,0 +1,19 @@
1
+ /**
2
+ * `analyzeUiScript`: runs every analyzer rule over a parsed UI script
3
+ * (spec 14 section 3, plan P1-02b).
4
+ *
5
+ * The analyzer is pure: it reads the script and nothing else, never throws
6
+ * for a script `parseUiScript` accepted, and returns the same problems in the
7
+ * browser (the builder) and on the server (the workflow service validator).
8
+ * Problems are advice; none blocks a save.
9
+ */
10
+ import type { UiScript } from '../script/types.js';
11
+ import { type UiAnalyzeOptions, type UiAnalyzerRuleId, type UiProblemSeverity, type UiScriptProblem } from './types.js';
12
+ /** The default severity of every rule, by id. */
13
+ export declare const UI_ANALYZER_DEFAULT_SEVERITY: Readonly<Record<UiAnalyzerRuleId, UiProblemSeverity>>;
14
+ /**
15
+ * The problems of a script, in document order: problems of the whole script
16
+ * first, then each step's (main steps, then clean-up), then the outputs';
17
+ * within one place, in rule order. Pass the script `parseUiScript` returned.
18
+ */
19
+ export declare function analyzeUiScript(script: UiScript, options?: UiAnalyzeOptions): UiScriptProblem[];
@@ -0,0 +1,40 @@
1
+ import type { UiExpression, UiScript, UiScriptElement, UiStep, UiTarget, UiTargetRef } from '../script/types.js';
2
+ import type { UiAnalyzeOptions } from './types.js';
3
+ /** A step that runs (not disabled, and not inside a disabled block), with where it sits. */
4
+ export interface ActiveStep {
5
+ step: UiStep;
6
+ path: string;
7
+ /** The step's number as an author reads it (`stepNumber`). */
8
+ number: string;
9
+ /** The step's index among every step in document order, disabled ones included; problems sort by it. */
10
+ order: number;
11
+ }
12
+ export interface AnalyzeContext {
13
+ script: UiScript;
14
+ options: UiAnalyzeOptions;
15
+ elements: Readonly<Record<string, UiScriptElement>>;
16
+ /** The steps that run, in document order: the main steps, then the clean-up block. */
17
+ steps: readonly ActiveStep[];
18
+ /** Every step, disabled ones included; outputs sort after the last. */
19
+ totalSteps: number;
20
+ /** The target a reference stands for: the inline target, or the pinned element's target when the script carries it. */
21
+ targetOf(ref: UiTargetRef): UiTarget | undefined;
22
+ /** A quoted, short description of a target, for messages. */
23
+ describeTarget(ref: UiTargetRef): string;
24
+ }
25
+ /**
26
+ * The number of a step as an author reads it: positions count from 1, the
27
+ * `then` and `steps` blocks add a level, an `else` block adds `else`, and the
28
+ * clean-up block starts with `cleanup`. `"5.then.1"` is `"6.2"`,
29
+ * `"5.else.0"` is `"6.else.1"` and `"cleanup.0"` is `"cleanup.1"`.
30
+ */
31
+ export declare function stepNumber(path: string): string;
32
+ export declare function createContext(script: UiScript, options: UiAnalyzeOptions): AnalyzeContext;
33
+ /** The names of the variables an expression reads. */
34
+ export declare function variablesRead(expression: UiExpression): string[];
35
+ /** The variables a step reads through its own expressions (its nested blocks excluded). */
36
+ export declare function stepVariablesRead(step: UiStep): string[];
37
+ /** The variable names a step sets: its `saveAs`, a `set` name, and a for-each item and index. */
38
+ export declare function stepVariablesSet(step: UiStep): string[];
39
+ /** True for a step that signs in: a sign-in step or a secret typed into a field. */
40
+ export declare function signsIn(step: UiStep): boolean;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * The UI script analyzer (plan P1-02b): `analyzeUiScript`, the rules of v1,
3
+ * their message keys under `fluidgrids.builder.uiScript.problem.*` and the
4
+ * English templates.
5
+ */
6
+ export { UI_ANALYZER_DEFAULT_SEVERITY, analyzeUiScript } from './analyze.js';
7
+ export { UI_ANALYZER_RULE_GROUPS, UI_ANALYZER_RULE_IDS, UI_PROBLEM_SEVERITIES, type UiAnalyzeOptions, type UiAnalyzerRuleGroup, type UiAnalyzerRuleId, type UiProblemSeverity, type UiProblemSeveritySetting, type UiRuleFinding, type UiScriptProblem, } from './types.js';
8
+ export { UI_SCRIPT_PROBLEM_KEY_PREFIX, UI_SCRIPT_PROBLEM_MESSAGES, type UiScriptProblemMessageKey, type UiScriptProblemMessageName, problemMessage, problemMessageKey, } from './messages.js';
9
+ export { UI_ANALYZER_RULES, type UiAnalyzerRule } from './rules/index.js';
10
+ export { type ActiveStep, type AnalyzeContext, stepNumber } from './context.js';
@@ -0,0 +1,39 @@
1
+ /**
2
+ * The analyzer's messages (plan P1-02b).
3
+ *
4
+ * Each problem carries a message key under `fluidgrids.builder.uiScript.problem.*`,
5
+ * its variables, and an English fallback. The builder translates the key with
6
+ * `tr(key, vars)` so `i18n:extract` sees it; the service, the CLI and logs use
7
+ * the fallback. `{{step}}` is the step's number as an author reads it
8
+ * (`stepNumber`), `{{target}}` a quoted target description (`describeTarget`).
9
+ */
10
+ /** The prefix of every problem message key. */
11
+ export declare const UI_SCRIPT_PROBLEM_KEY_PREFIX = "fluidgrids.builder.uiScript.problem.";
12
+ /** English templates of every problem message, by name; the key is the prefix plus the name. */
13
+ export declare const UI_SCRIPT_PROBLEM_MESSAGES: {
14
+ readonly fixedWait: "Step {{step}} waits a fixed {{milliseconds}} ms. Wait for an element, a text or an address instead, so the step neither fails on a slow page nor wastes time on a fast one.";
15
+ readonly singleMethodTarget: "Step {{step}} finds {{target}} by one method only. Add another method so a page change does not break the step.";
16
+ readonly noEnabledMethod: "Step {{step}} has every method of {{target}} switched off, so it can never find the element. Switch a method on.";
17
+ readonly hardwareInput: "Step {{step}} uses hardware input, which needs the browser window in front and the screen unlocked. Use automatic input unless the page refuses it.";
18
+ readonly hardwareInputSettings: "The script uses hardware input for every step, which needs the browser window in front and the screen unlocked. Use automatic input unless a page refuses it.";
19
+ readonly unknownVariable: "Step {{step}} reads {{name}}, but no step sets it and the script does not declare it, so it is empty when the step runs.";
20
+ readonly unknownVariableOutput: "The output {{output}} reads {{name}}, but no step sets it and the script does not declare it, so the output is always empty.";
21
+ readonly unknownVariableInitial: "The initial value of the variable {{variable}} reads {{name}}, but no step sets it and the script does not declare it, so it reads as empty.";
22
+ readonly unknownVariableDefault: "The default of the input {{input}} reads {{name}}, but no step sets it and the script does not declare it, so it reads as empty.";
23
+ readonly maskedValue: "Step {{step}} types a value that was hidden during recording. Give it a value, such as a workflow input, or the run stops at this step.";
24
+ readonly typeWithoutValue: "Step {{step}} has no value to type, so it types nothing. Give it a value or remove the step.";
25
+ readonly noCleanup: "The script signs in at step {{step}} but has no clean-up steps. Add clean-up steps that sign out or close the tab, so a failed run does not leave the session open.";
26
+ readonly plainTextSecret: "Step {{step}} types into {{target}}, which looks like a password or code field, with a plain Type step. Use Type secret with a connection so the value is never stored or shown.";
27
+ readonly secretOrigin: "Step {{step}} types a secret without an expected site. Set the site the secret may be typed into, so it is never typed into another page.";
28
+ readonly sensitiveScreenshot: "Step {{step}} signs in or types a secret and takes a screenshot every time it runs. Take screenshots of this step on failure only.";
29
+ readonly sensitiveScreenshotSettings: "The script takes a screenshot of every step, including step {{step}}, which signs in or types a secret. Take screenshots on failure only, or turn them off for that step.";
30
+ readonly inlineTarget: "Step {{step}} uses an inline target. Add it to the Element library so other workflows can reuse it.";
31
+ readonly unusedValue: "Step {{step}} stores {{name}}, but no step, output or later node reads it.";
32
+ readonly unusedVariable: "The variable {{name}} is declared, but no step reads it.";
33
+ };
34
+ export type UiScriptProblemMessageName = keyof typeof UI_SCRIPT_PROBLEM_MESSAGES;
35
+ export type UiScriptProblemMessageKey = `fluidgrids.builder.uiScript.problem.${UiScriptProblemMessageName}`;
36
+ /** The full message key of a problem message name. */
37
+ export declare function problemMessageKey(name: UiScriptProblemMessageName): UiScriptProblemMessageKey;
38
+ /** The English sentence of a message with its variables filled in. */
39
+ export declare function problemMessage(name: UiScriptProblemMessageName, vars: Record<string, string | number>): string;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Reliability: a fixed wait where a wait for an element would do (spec 05,
3
+ * "the analyzer flags fixed waits"; spec 14 section 3).
4
+ */
5
+ import type { UiAnalyzerRule } from './rule.js';
6
+ export declare const fixedWaitRule: UiAnalyzerRule;
@@ -0,0 +1,2 @@
1
+ import type { UiAnalyzerRule } from './rule.js';
2
+ export declare const hardwareInputRule: UiAnalyzerRule;
@@ -0,0 +1,3 @@
1
+ import type { UiAnalyzerRule } from './rule.js';
2
+ export type { UiAnalyzerRule } from './rule.js';
3
+ export declare const UI_ANALYZER_RULES: readonly UiAnalyzerRule[];
@@ -0,0 +1,2 @@
1
+ import type { UiAnalyzerRule } from './rule.js';
2
+ export declare const inlineTargetRule: UiAnalyzerRule;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Reliability: a Type step with no value. A value the recorder masked stops
3
+ * the run with `INVALID_SCRIPT` until an author gives it a value; a step with
4
+ * neither a value nor the mask (possible in a Stewards recording) types
5
+ * nothing at all.
6
+ */
7
+ import type { UiAnalyzerRule } from './rule.js';
8
+ export declare const maskedValueRule: UiAnalyzerRule;
@@ -0,0 +1,2 @@
1
+ import type { UiAnalyzerRule } from './rule.js';
2
+ export declare const noCleanupRule: UiAnalyzerRule;
@@ -0,0 +1,2 @@
1
+ import type { UiAnalyzerRule } from './rule.js';
2
+ export declare const plainTextSecretRule: UiAnalyzerRule;
@@ -0,0 +1,15 @@
1
+ /** The shape every analyzer rule has, and the helpers rules share. */
2
+ import type { ActiveStep, AnalyzeContext } from '../context.js';
3
+ import type { UiScriptProblemMessageName } from '../messages.js';
4
+ import type { UiAnalyzerRuleGroup, UiAnalyzerRuleId, UiProblemSeverity, UiRuleFinding } from '../types.js';
5
+ export interface UiAnalyzerRule {
6
+ id: UiAnalyzerRuleId;
7
+ group: UiAnalyzerRuleGroup;
8
+ /** The severity a workspace gets unless it sets another. */
9
+ severity: UiProblemSeverity;
10
+ /** What the rule looks for, in one sentence (for documentation and the CLI). */
11
+ description: string;
12
+ check(context: AnalyzeContext): UiRuleFinding[];
13
+ }
14
+ /** A finding on one step; the step's number is added to the variables as `step`. */
15
+ export declare function stepFinding(active: ActiveStep, message: UiScriptProblemMessageName, vars?: Record<string, string | number>, field?: string): UiRuleFinding;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Security: a Type secret step with no expected site. Sign-in stays bound to
3
+ * an origin (spec 05 section 8): with `expectedOrigin` set, a desk refuses to
4
+ * type the secret into any other page, such as one a redirect landed on.
5
+ */
6
+ import type { UiAnalyzerRule } from './rule.js';
7
+ export declare const secretOriginRule: UiAnalyzerRule;
@@ -0,0 +1,2 @@
1
+ import type { UiAnalyzerRule } from './rule.js';
2
+ export declare const sensitiveScreenshotRule: UiAnalyzerRule;
@@ -0,0 +1,2 @@
1
+ import type { UiAnalyzerRule } from './rule.js';
2
+ export declare const singleMethodTargetRule: UiAnalyzerRule;
@@ -0,0 +1,2 @@
1
+ import type { UiAnalyzerRule } from './rule.js';
2
+ export declare const unknownVariableRule: UiAnalyzerRule;
@@ -0,0 +1,2 @@
1
+ import type { UiAnalyzerRule } from './rule.js';
2
+ export declare const unusedValueRule: UiAnalyzerRule;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Whether a stored target reads like a password or code field, from its
3
+ * words alone (no page): the analyzer's form of the capture rule for field
4
+ * names (`./capture`, and `isSecretFieldName` in `./target`). A test keeps
5
+ * the word list in step with the DOM rule. The short words (otp, token,
6
+ * secret, verification, recovery) must stand alone here, because the analyzer
7
+ * reads whole selectors and labels, where they also occur inside other words
8
+ * ("footprint", "hotpot", "secretary").
9
+ */
10
+ import type { UiTarget } from '../script/types.js';
11
+ /** True when a name, label or selector reads like a secret field. */
12
+ export declare function readsLikeSecret(text: string): boolean;
13
+ /** True when a target, or the library element's name, reads like a password or code field. */
14
+ export declare function looksLikeSecretField(target: UiTarget | undefined, elementName?: string): boolean;
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Types of the UI script analyzer (spec 14 section 3, plan P1-02b).
3
+ *
4
+ * The analyzer reads a parsed UI script and reports problems an author should
5
+ * know about before the script runs. Every problem is advice: the builder
6
+ * shows it on save and never blocks a save (spec 19, M1), and the workflow
7
+ * service reports it as a validation warning (plan P1-08).
8
+ */
9
+ import type { UiScriptProblemMessageKey, UiScriptProblemMessageName } from './messages.js';
10
+ /** How much a problem matters. Analyzer v1 never reports an error: a script that cannot run fails to parse instead. */
11
+ export declare const UI_PROBLEM_SEVERITIES: readonly ["warning", "info"];
12
+ export type UiProblemSeverity = (typeof UI_PROBLEM_SEVERITIES)[number];
13
+ /** A workspace's setting for one rule: a severity, or `off` to drop the rule's problems. */
14
+ export type UiProblemSeveritySetting = UiProblemSeverity | 'off';
15
+ /** The rule groups of spec 14 section 3 that v1 covers. */
16
+ export declare const UI_ANALYZER_RULE_GROUPS: readonly ["reliability", "security", "maintainability"];
17
+ export type UiAnalyzerRuleGroup = (typeof UI_ANALYZER_RULE_GROUPS)[number];
18
+ /** The rules of analyzer v1, in the order their problems are listed within one step. */
19
+ export declare const UI_ANALYZER_RULE_IDS: readonly ["fixedWait", "singleMethodTarget", "hardwareInput", "unknownVariable", "maskedValue", "noCleanup", "plainTextSecret", "secretOrigin", "sensitiveScreenshot", "inlineTarget", "unusedValue"];
20
+ export type UiAnalyzerRuleId = (typeof UI_ANALYZER_RULE_IDS)[number];
21
+ /** One problem the analyzer found. */
22
+ export interface UiScriptProblem {
23
+ rule: UiAnalyzerRuleId;
24
+ group: UiAnalyzerRuleGroup;
25
+ severity: UiProblemSeverity;
26
+ /** The message key under `fluidgrids.builder.uiScript.problem.*`; the front end translates it with `tr(key, vars)`. */
27
+ messageKey: UiScriptProblemMessageKey;
28
+ /** The values the message's `{{name}}` placeholders take. */
29
+ vars: Record<string, string | number>;
30
+ /** The English sentence, for consumers that do not translate (logs, the service, the CLI). */
31
+ message: string;
32
+ /** The step's path (as `walkSteps` gives it), when the problem belongs to a step. */
33
+ path?: string;
34
+ /** The step's id, when the problem belongs to a step. */
35
+ stepId?: string;
36
+ /** The field of the step or the script the problem points at, such as `target` or `settings.inputMethod`. */
37
+ field?: string;
38
+ }
39
+ /** Options of `analyzeUiScript`. */
40
+ export interface UiAnalyzeOptions {
41
+ /**
42
+ * Per-rule severity, as a workspace sets it (spec 14 section 3). A rule
43
+ * left out keeps its default severity; `off` drops its problems.
44
+ */
45
+ severity?: Partial<Record<UiAnalyzerRuleId, UiProblemSeveritySetting>>;
46
+ /**
47
+ * The names of the node's results (`set` and `saveAs` names) that other
48
+ * nodes of the workflow read. The builder knows them; the service may not.
49
+ * When this is left out, a `set` or `saveAs` value is never reported as
50
+ * unused (unless its name starts with `__`), because a later node may read it.
51
+ */
52
+ externalReads?: readonly string[];
53
+ }
54
+ /** A problem as a rule reports it, before the analyzer adds the severity and the message. */
55
+ export interface UiRuleFinding {
56
+ message: UiScriptProblemMessageName;
57
+ vars: Record<string, string | number>;
58
+ path?: string;
59
+ stepId?: string;
60
+ field?: string;
61
+ /**
62
+ * Where the problem sorts: the step's index in document order, -1 for a
63
+ * problem of the whole script, or past the last step for an output.
64
+ */
65
+ order: number;
66
+ }
@@ -0,0 +1,2 @@
1
+ /** `@burdenoff/ui-engine/analyze`: the UI script analyzer (rules, problems, message keys). */
2
+ export * from './analyze/index.js';
@@ -0,0 +1,26 @@
1
+ import {
2
+ stepNumber2,
3
+ UI_SCRIPT_PROBLEM_KEY_PREFIX2,
4
+ UI_SCRIPT_PROBLEM_MESSAGES2,
5
+ problemMessageKey2,
6
+ problemMessage2,
7
+ UI_ANALYZER_RULES2,
8
+ UI_PROBLEM_SEVERITIES2,
9
+ UI_ANALYZER_RULE_GROUPS2,
10
+ UI_ANALYZER_RULE_IDS2,
11
+ UI_ANALYZER_DEFAULT_SEVERITY2,
12
+ analyzeUiScript2
13
+ } from "./index-s7qdecev.js";
14
+ export {
15
+ UI_ANALYZER_DEFAULT_SEVERITY2 as UI_ANALYZER_DEFAULT_SEVERITY,
16
+ UI_ANALYZER_RULES2 as UI_ANALYZER_RULES,
17
+ UI_ANALYZER_RULE_GROUPS2 as UI_ANALYZER_RULE_GROUPS,
18
+ UI_ANALYZER_RULE_IDS2 as UI_ANALYZER_RULE_IDS,
19
+ UI_PROBLEM_SEVERITIES2 as UI_PROBLEM_SEVERITIES,
20
+ UI_SCRIPT_PROBLEM_KEY_PREFIX2 as UI_SCRIPT_PROBLEM_KEY_PREFIX,
21
+ UI_SCRIPT_PROBLEM_MESSAGES2 as UI_SCRIPT_PROBLEM_MESSAGES,
22
+ analyzeUiScript2 as analyzeUiScript,
23
+ problemMessage2 as problemMessage,
24
+ problemMessageKey2 as problemMessageKey,
25
+ stepNumber2 as stepNumber
26
+ };