@burdenoff/ui-engine 2026.1127.4 → 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 (38) hide show
  1. package/README.md +29 -3
  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/drivers.js +8 -6
  24. package/dist/{index-3f1j8386.js → index-21hvbvx1.js} +18 -12
  25. package/dist/{index-h88y5qgv.js → index-8w0f6rsz.js} +5 -3
  26. package/dist/index-9s5nphx0.js +99 -0
  27. package/dist/{index-895kscx3.js → index-c88tvyj1.js} +7 -5
  28. package/dist/{index-3jymbm5t.js → index-g7724awk.js} +1 -92
  29. package/dist/index-gvavb597.js +195 -0
  30. package/dist/{index-zzhysbkj.js → index-r2a9rftv.js} +14 -5
  31. package/dist/index-s7qdecev.js +489 -0
  32. package/dist/{index-pm13mvvc.js → index-xner4tgb.js} +3 -196
  33. package/dist/index.d.ts +1 -0
  34. package/dist/index.js +52 -24
  35. package/dist/interpret.js +3 -3
  36. package/dist/script.js +26 -22
  37. package/dist/testing.js +1 -1
  38. package/package.json +7 -3
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`, and `interpret`); 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.
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
  |---|---|
@@ -28,6 +28,7 @@ Each module is a subpath export. The root entry re-exports the data and planning
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
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) |
31
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) |
32
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 |
33
34
 
@@ -98,7 +99,7 @@ The runtime must be injected into an isolated world (a content script, or a CDP
98
99
 
99
100
  **Semantics.**
100
101
 
101
- - *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 problem ends the run before any step runs, with only a FINISHED event.
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.
102
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.
103
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.
104
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.
@@ -122,12 +123,37 @@ The runtime must be injected into an isolated world (a content script, or a CDP
122
123
 
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).
124
125
 
125
- **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.
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`.
126
127
 
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`).
128
129
 
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.
130
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
+
131
157
  ## Compatibility with Stewards
132
158
 
133
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
+ };
package/dist/drivers.js CHANGED
@@ -1,25 +1,27 @@
1
1
  import"./index-cs6acyjn.js";
2
2
  import {
3
3
  parseUiScript2
4
- } from "./index-895kscx3.js";
4
+ } from "./index-c88tvyj1.js";
5
5
  import {
6
6
  DOM_DRIVER_CAPABILITIES2,
7
7
  safePageText2,
8
8
  safePageHtml2,
9
9
  createDomDriver2
10
- } from "./index-3f1j8386.js";
10
+ } from "./index-21hvbvx1.js";
11
11
  import {
12
12
  runUiScript2
13
- } from "./index-zzhysbkj.js";
13
+ } from "./index-r2a9rftv.js";
14
14
  import {
15
15
  UiDriverError2,
16
16
  createVirtualClock2
17
17
  } from "./index-vg8r40y7.js";
18
18
  import {
19
- walkSteps2,
20
- stepTargets2,
21
19
  CAPABILITY_IDS2
22
- } from "./index-3jymbm5t.js";
20
+ } from "./index-9s5nphx0.js";
21
+ import {
22
+ walkSteps2,
23
+ stepTargets2
24
+ } from "./index-g7724awk.js";
23
25
  import {
24
26
  hydrateTreeSnapshot2
25
27
  } from "./index-5k26keah.js";
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  MAX_LIST_ITEMS2,
6
6
  CAPABILITY_IDS2
7
- } from "./index-3jymbm5t.js";
7
+ } from "./index-9s5nphx0.js";
8
8
  import {
9
9
  createDomRuntime2
10
10
  } from "./index-ct2xctrq.js";
@@ -126,6 +126,20 @@ function createDomDriver2(options) {
126
126
  };
127
127
  const runtime = createDomRuntime2(document, probe);
128
128
  const capabilities = options.capabilities ?? (options.screenshot ? [...DOM_DRIVER_CAPABILITIES2, "action:screenshot"].sort() : DOM_DRIVER_CAPABILITIES2);
129
+ const listResolution = (target, matches) => {
130
+ const first = matches.elements[0];
131
+ const method = target.methods[matches.methodIndex];
132
+ if (!first || !method)
133
+ return;
134
+ return {
135
+ status: "found",
136
+ method: matches.method,
137
+ methodIndex: matches.methodIndex,
138
+ fallback: matches.methodIndex !== target.methods.findIndex((item) => item.enabled !== false),
139
+ candidate: describeCandidate2(first, method, matches.methodIndex, { x: 0, y: 0, width: 0, height: 0 }, probe),
140
+ attempts: matches.attempts
141
+ };
142
+ };
129
143
  const fromOutcome = (outcome) => outcome.ok ? { ok: true, value: outcome.value ?? null } : { ok: false, problem: outcome.problem };
130
144
  const readElement = (element, read) => {
131
145
  if (isSensitiveElement2(element))
@@ -223,16 +237,7 @@ function createDomDriver2(options) {
223
237
  return { ok: false, code: value.problem };
224
238
  items.push(value.value);
225
239
  }
226
- const first = matches.elements[0];
227
- const method = target.methods[matches.methodIndex];
228
- const resolution = first && method ? {
229
- status: "found",
230
- method: matches.method,
231
- methodIndex: matches.methodIndex,
232
- fallback: matches.methodIndex !== target.methods.findIndex((item) => item.enabled !== false),
233
- candidate: describeCandidate2(first, method, matches.methodIndex, { x: 0, y: 0, width: 0, height: 0 }, probe),
234
- attempts: matches.attempts
235
- } : undefined;
240
+ const resolution = listResolution(target, matches);
236
241
  return { ok: true, items, ...resolution ? { resolution } : {} };
237
242
  },
238
243
  listItems: async (item, fields, maxItems) => {
@@ -271,7 +276,8 @@ function createDomDriver2(options) {
271
276
  }
272
277
  rows.push(row);
273
278
  }
274
- return { ok: true, items: rows };
279
+ const resolution = listResolution(item, matches);
280
+ return { ok: true, items: rows, ...resolution ? { resolution } : {} };
275
281
  },
276
282
  pressKeys: async (target, keys) => {
277
283
  if (!target) {
@@ -9,15 +9,17 @@ import {
9
9
  withFingerprint2,
10
10
  UiScriptError2,
11
11
  parseUiScript2
12
- } from "./index-895kscx3.js";
12
+ } from "./index-c88tvyj1.js";
13
13
  import {
14
14
  UiRunError2
15
15
  } from "./index-vg8r40y7.js";
16
16
  import {
17
- walkSteps2,
18
17
  requiredCapabilities2,
19
18
  missingCapabilities2
20
- } from "./index-3jymbm5t.js";
19
+ } from "./index-9s5nphx0.js";
20
+ import {
21
+ walkSteps2
22
+ } from "./index-g7724awk.js";
21
23
  // src/interpret/compile.ts
22
24
  var MAX_CALL_DEPTH2 = 4;
23
25
  var COMPILED_NAME_PREFIX2 = "__c";
@@ -0,0 +1,99 @@
1
+ import {
2
+ UI_TARGET_METHOD_KINDS2,
3
+ UI_STEP_ACTIONS2,
4
+ walkSteps2,
5
+ stepTargets2
6
+ } from "./index-g7724awk.js";
7
+
8
+ // src/script/limits.ts
9
+ var UI_SCRIPT_VERSION2 = 1;
10
+ var MAX_SCRIPT_STEPS2 = 500;
11
+ var MAX_SCRIPT_BYTES2 = 1024 * 1024;
12
+ var MAX_FLOW_DEPTH2 = 8;
13
+ var MAX_EXPRESSION_DEPTH2 = 16;
14
+ var MAX_EXPRESSION_ITEMS2 = 1000;
15
+ var MAX_OPERATOR_ARGS2 = 16;
16
+ var MAX_SCRIPT_INPUTS2 = 100;
17
+ var MAX_SCRIPT_OUTPUTS2 = 100;
18
+ var MAX_SCRIPT_VARIABLES2 = 100;
19
+ var MAX_SCRIPT_ELEMENTS2 = 500;
20
+ var MAX_TARGET_METHODS2 = 8;
21
+ var MAX_FRAME_DEPTH2 = 8;
22
+ var MAX_EXTRACT_FIELDS2 = 50;
23
+ var MAX_LIST_ITEMS2 = 5000;
24
+ var MAX_LIST_PAGES2 = 50;
25
+ var MAX_LOOP_ITERATIONS2 = 1e4;
26
+ var MAX_RETRY_ATTEMPTS2 = 10;
27
+ var MAX_STEP_TIMEOUT_MS2 = 600000;
28
+ var MAX_DELAY_MS2 = 60000;
29
+ var MAX_KEYS2 = 8;
30
+ var MAX_SELECT_VALUES2 = 50;
31
+ var MAX_SELECTOR_LENGTH2 = 500;
32
+ var MAX_URL_LENGTH2 = 4096;
33
+ var MAX_LABEL_LENGTH2 = 512;
34
+ var MAX_TEXT_LENGTH2 = 1e4;
35
+ var MAX_INTENT_LENGTH2 = 500;
36
+ var MAX_NAME_LENGTH2 = 64;
37
+ var LEGACY_MAX_BROWSER_STEPS2 = 100;
38
+ var LEGACY_MAX_STEPS_BYTES2 = 256 * 1024;
39
+ var LEGACY_MAX_STEP_TIMEOUT_MS2 = 60000;
40
+ function jsonByteLength2(value) {
41
+ return new TextEncoder().encode(JSON.stringify(value) ?? "").length;
42
+ }
43
+
44
+ // src/script/capabilities.ts
45
+ var CAPABILITY_IDS2 = [
46
+ "script:1",
47
+ ...UI_STEP_ACTIONS2.map((action) => `action:${action}`),
48
+ ...UI_TARGET_METHOD_KINDS2.map((kind) => `target:${kind}`),
49
+ "target:frame",
50
+ "step:verify",
51
+ "step:retry",
52
+ "step:breakpoint",
53
+ "input:direct",
54
+ "input:hardware"
55
+ ].sort();
56
+ var SCRIPT_CAPABILITY2 = "script:1";
57
+ function targetCapabilities(target, into) {
58
+ for (const method of target.methods)
59
+ if (method.enabled !== false)
60
+ into.add(`target:${method.kind}`);
61
+ if (target.frame)
62
+ into.add("target:frame");
63
+ }
64
+ function requiredCapabilities2(script) {
65
+ const required = new Set([SCRIPT_CAPABILITY2]);
66
+ const elements = script.elements ?? {};
67
+ const inputMethods = [script.settings?.inputMethod];
68
+ const skipped = [];
69
+ for (const { step, path } of walkSteps2(script)) {
70
+ if (step.disabled === true)
71
+ skipped.push(`${path}.`);
72
+ if (step.disabled === true || skipped.some((prefix) => path.startsWith(prefix)))
73
+ continue;
74
+ required.add(`action:${step.action}`);
75
+ for (const [, ref] of stepTargets2(step)) {
76
+ const target = "element" in ref ? elements[ref.element]?.target : ref;
77
+ if (target)
78
+ targetCapabilities(target, required);
79
+ }
80
+ if (step.verify)
81
+ required.add("step:verify");
82
+ if (step.retry)
83
+ required.add("step:retry");
84
+ if (step.breakpoint === true)
85
+ required.add("step:breakpoint");
86
+ inputMethods.push(step.inputMethod);
87
+ }
88
+ for (const method of inputMethods) {
89
+ if (method === "direct" || method === "hardware")
90
+ required.add(`input:${method}`);
91
+ }
92
+ return [...required].sort();
93
+ }
94
+ function missingCapabilities2(script, supported) {
95
+ const have = new Set(supported);
96
+ return requiredCapabilities2(script).filter((id) => !have.has(id));
97
+ }
98
+
99
+ export { UI_SCRIPT_VERSION2, MAX_SCRIPT_STEPS2, MAX_SCRIPT_BYTES2, MAX_FLOW_DEPTH2, MAX_EXPRESSION_DEPTH2, MAX_EXPRESSION_ITEMS2, MAX_OPERATOR_ARGS2, MAX_SCRIPT_INPUTS2, MAX_SCRIPT_OUTPUTS2, MAX_SCRIPT_VARIABLES2, MAX_SCRIPT_ELEMENTS2, MAX_TARGET_METHODS2, MAX_FRAME_DEPTH2, MAX_EXTRACT_FIELDS2, MAX_LIST_ITEMS2, MAX_LIST_PAGES2, MAX_LOOP_ITERATIONS2, MAX_RETRY_ATTEMPTS2, MAX_STEP_TIMEOUT_MS2, MAX_DELAY_MS2, MAX_KEYS2, MAX_SELECT_VALUES2, MAX_SELECTOR_LENGTH2, MAX_URL_LENGTH2, MAX_LABEL_LENGTH2, MAX_TEXT_LENGTH2, MAX_INTENT_LENGTH2, MAX_NAME_LENGTH2, LEGACY_MAX_BROWSER_STEPS2, LEGACY_MAX_STEPS_BYTES2, LEGACY_MAX_STEP_TIMEOUT_MS2, jsonByteLength2, CAPABILITY_IDS2, SCRIPT_CAPABILITY2, requiredCapabilities2, missingCapabilities2 };
@@ -3,9 +3,6 @@ import {
3
3
  targetFingerprint2
4
4
  } from "./index-cs6acyjn.js";
5
5
  import {
6
- UI_EXPRESSION_OPS2,
7
- UI_ANCHOR_RELATIONS2,
8
- UI_VALUE_TYPES2,
9
6
  UI_SCRIPT_VERSION2,
10
7
  MAX_SCRIPT_STEPS2,
11
8
  MAX_SCRIPT_BYTES2,
@@ -34,12 +31,17 @@ import {
34
31
  MAX_TEXT_LENGTH2,
35
32
  MAX_INTENT_LENGTH2,
36
33
  MAX_NAME_LENGTH2,
37
- jsonByteLength2,
34
+ jsonByteLength2
35
+ } from "./index-9s5nphx0.js";
36
+ import {
37
+ UI_EXPRESSION_OPS2,
38
+ UI_ANCHOR_RELATIONS2,
39
+ UI_VALUE_TYPES2,
38
40
  walkSteps2,
39
41
  stepTargets2,
40
42
  stepExpressions2,
41
43
  visitExpression2
42
- } from "./index-3jymbm5t.js";
44
+ } from "./index-g7724awk.js";
43
45
  import {
44
46
  containsCredential,
45
47
  containsCredentialInUrl