@burdenoff/ui-engine 2026.1129.2 → 2026.1201.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -65,12 +65,13 @@ A UI script is the portable form of a UI sequence that a desk runs: a paired bro
65
65
  | `fromRemoteBrowserSteps` | Remote Browser `runSteps` (`store/remotebrowser` 1.0.0) | Playwright `css=`, `text=`, `xpath=`, `id=` and `data-testid=` selectors; other engines are refused |
66
66
  | `scriptFromComputerUseActions` | The actions an AI Step took (computer-use tool calls with the worker's `_uiTarget` fingerprints), for Save as steps | Returns `{ script, elements, skipped }` and saves nothing. See below |
67
67
 
68
- **Save as steps.** `scriptFromComputerUseActions(actions, { name?, allowedHosts?, loginUrl?, loginSecretRefs?, inputDefaults? })` converts a recorded AI Step run (plan P4-06b, document 24 threats I3 and I7). Each record is the model's arguments (`action`, `url`, `x`, `y`, `text`, `key`, `deltaX`, `deltaY`, `milliseconds`, `ref`, directly or under `args`, as an object or JSON text; under `args` the worker fields are read only from the record) plus what the worker recorded (`ok`, `pageUrl`, `secretRef`, `screenshotFileId`, `_uiTarget` with `role`, `name`, `testId`, `cssPath`, `text`, `frameOrigin`, `frame`, `inFrame`, `editable`, `masked`, `inputType`). The rules:
68
+ **Save as steps.** `scriptFromComputerUseActions(actions, { name?, allowedHosts?, loginUrl?, loginSecretRefs?, inputDefaults?, trustFlatRecords? })` converts a recorded AI Step run (plan P4-06b, document 24 threats I3 and I7). Each record is the model's arguments (`action`, `url`, `x`, `y`, `text`, `key`, `deltaX`, `deltaY`, `milliseconds`, `ref`, directly or under `args`, as an object or JSON text; under `args` the worker fields are read only from the record) plus what the worker recorded (`ok`, `pageUrl`, `secretRef`, `screenshotFileId`, `_uiTarget` with `role`, `name`, `testId`, `cssPath`, `text`, `frameOrigin`, `frame`, `inFrame`, `editable`, `masked`, `inputType`). The rules:
69
69
 
70
+ - Pass the nested form, `{ args: <the model's tool-call arguments>, ok, pageUrl, secretRef, screenshotFileId, _uiTarget }`. A flat record (no `args`) cannot show which of its fields the model sent, so by default one that carries a worker field is skipped as `UNTRUSTED_RECORD`, and a flat record with only model arguments is read for those. `trustFlatRecords: true` reads flat records whole; use it only for records the caller built itself, because a model that can set `secretRef` or `_uiTarget` could send a sign-in secret to a field it picks (document 24 I3).
70
71
  - `navigate`, `click_ref`, `type_ref`, `key`, `scroll` and `wait` become steps; `click` and `double_click` become steps only with a recorded element. A target is built as test id, role and name, CSS path, then exact text (`targetFromUiFingerprint`).
71
72
  - Secrets are typed by reference only: `type_login_username` and `type_login_password` become `typeSecret` with `login:username` and `login:password` (or `loginSecretRefs`), and typing recorded with a `secretRef` keeps that reference. `expectedOrigin` is the field's frame origin.
72
73
  - Typed text becomes a declared input named after the field (`Invoice number` gives `invoiceNumber`), typed with `clear: false` as the tool does; with `inputDefaults` (default true) the typed value is the input's default. Text typed into a masked or password field, into a field nobody recorded, or that looks like a credential is skipped and never copied.
73
- - Skipped, with a reason code and no values: `ACTION_FAILED`, `FIELD_UNKNOWN`, `FRAME_NOT_ADDRESSABLE` (another origin's frame with no recorded frame chain), `HOST_NOT_ALLOWED`, `INVALID_ACTION`, `INVALID_URL`, `LOGIN_PAGE_UNKNOWN`, `NO_EFFECT`, `NO_ELEMENT` (a click at a position with no element), `OBSERVATION_ONLY` (screenshots), `SECRET_TARGET_UNKNOWN`, `SECRET_VALUE`, `TOO_MANY_INPUTS`, `UNKNOWN_ACTION`, `URL_CARRIES_SECRET`.
74
+ - Skipped, with a reason code and no values: `ACTION_FAILED`, `FIELD_UNKNOWN`, `FRAME_NOT_ADDRESSABLE` (another origin's frame with no recorded frame chain), `HOST_NOT_ALLOWED`, `INVALID_ACTION`, `INVALID_URL`, `LOGIN_PAGE_UNKNOWN`, `NO_EFFECT`, `NO_ELEMENT` (a click at a position with no element), `OBSERVATION_ONLY` (screenshots), `SECRET_TARGET_UNKNOWN`, `SECRET_VALUE`, `TOO_MANY_INPUTS`, `UNKNOWN_ACTION`, `UNTRUSTED_RECORD` (a flat record with worker fields, without `trustFlatRecords`), `URL_CARRIES_SECRET`.
74
75
  - Untargeted typing goes into the field that last took the focus (a click on an element that takes text, a `type_ref` or a login action); a key press, a navigation, a click elsewhere or a skipped action forgets it. An element in a child frame needs its recorded `frame` chain. A scroll with no recorded element becomes a page scroll.
75
76
  - `elements` lists each distinct target once, with a name, a key, the steps that use it and the first screenshot file, for the person to save to the element library. Steps keep inline targets.
76
77
  - It throws `UiScriptError` only for an unusable call (not a list, more than 2,000 actions, more than 500 converted steps, invalid options) or a whole-script parse limit such as `SCRIPT_TOO_LARGE`. The schema and its hash do not change.
@@ -856,6 +856,7 @@ var COMPUTER_USE_SKIP_REASONS2 = [
856
856
  "SECRET_VALUE",
857
857
  "TOO_MANY_INPUTS",
858
858
  "UNKNOWN_ACTION",
859
+ "UNTRUSTED_RECORD",
859
860
  "URL_CARRIES_SECRET"
860
861
  ];
861
862
  var SECRET_REF_PATTERN = /^[A-Za-z0-9][A-Za-z0-9:/._#-]{0,254}$/;
@@ -883,6 +884,7 @@ var MESSAGES = {
883
884
  SECRET_VALUE: "Typed text that is a secret is never saved; use a sign-in step instead.",
884
885
  TOO_MANY_INPUTS: `A script declares at most ${MAX_SCRIPT_INPUTS2} inputs.`,
885
886
  UNKNOWN_ACTION: "The action is not one Save as steps converts.",
887
+ UNTRUSTED_RECORD: "The record mixes the model arguments with the run fields, so the run fields cannot be trusted.",
886
888
  URL_CARRIES_SECRET: "The address carries a token or credential, so it is not saved."
887
889
  };
888
890
  function isRecord3(value) {
@@ -1009,22 +1011,29 @@ var MODEL_ARGUMENT_KEYS = [
1009
1011
  "ref"
1010
1012
  ];
1011
1013
  var WORKER_KEYS = ["ok", "pageUrl", "secretRef", "screenshotFileId", "_uiTarget"];
1012
- function readRecord(raw) {
1013
- if (!isRecord3(raw))
1014
- return;
1015
- const args = readArgs(raw.args);
1016
- if (args === undefined)
1017
- return raw;
1014
+ function modelArguments(source) {
1018
1015
  const record = {};
1019
1016
  for (const key of MODEL_ARGUMENT_KEYS)
1020
- if (key in args)
1021
- record[key] = args[key];
1017
+ if (key in source)
1018
+ record[key] = source[key];
1019
+ return record;
1020
+ }
1021
+ function readRecord(raw, trustFlat) {
1022
+ if (!isRecord3(raw))
1023
+ return { fields: undefined, untrusted: false };
1024
+ const args = readArgs(raw.args);
1025
+ if (args === undefined) {
1026
+ if (trustFlat)
1027
+ return { fields: raw, untrusted: false };
1028
+ return { fields: modelArguments(raw), untrusted: WORKER_KEYS.some((key) => (key in raw)) };
1029
+ }
1030
+ const record = modelArguments(args);
1022
1031
  if (!("action" in args) && "action" in raw)
1023
1032
  record.action = raw.action;
1024
1033
  for (const key of WORKER_KEYS)
1025
1034
  if (key in raw)
1026
1035
  record[key] = raw[key];
1027
- return record;
1036
+ return { fields: record, untrusted: false };
1028
1037
  }
1029
1038
  function readArgs(value) {
1030
1039
  if (isRecord3(value))
@@ -1063,8 +1072,9 @@ function scriptFromComputerUseActions2(actions, options = {}) {
1063
1072
  skipped: [],
1064
1073
  focused: undefined
1065
1074
  };
1075
+ const trustFlat = options.trustFlatRecords === true;
1066
1076
  actions.forEach((raw, index) => {
1067
- convertAction(state, readRecord(raw), index, {
1077
+ convertAction(state, readRecord(raw, trustFlat), index, {
1068
1078
  allowedHosts,
1069
1079
  secretRefs,
1070
1080
  loginUrl,
@@ -1091,7 +1101,8 @@ function checkLoginUrl(value) {
1091
1101
  }
1092
1102
  return url;
1093
1103
  }
1094
- function convertAction(state, record, index, context) {
1104
+ function convertAction(state, read, index, context) {
1105
+ const record = read.fields;
1095
1106
  const name = record && typeof record.action === "string" ? record.action.trim() : "";
1096
1107
  const action = isComputerUseAction(name) ? name : undefined;
1097
1108
  const skip = (reason) => {
@@ -1099,6 +1110,8 @@ function convertAction(state, record, index, context) {
1099
1110
  if (reason !== "OBSERVATION_ONLY" && reason !== "NO_EFFECT")
1100
1111
  state.focused = undefined;
1101
1112
  };
1113
+ if (read.untrusted)
1114
+ return skip("UNTRUSTED_RECORD");
1102
1115
  if (!record || !action)
1103
1116
  return skip("UNKNOWN_ACTION");
1104
1117
  if (record.ok === false)
package/dist/index.js CHANGED
@@ -70,7 +70,7 @@ import {
70
70
  COMPUTER_USE_SKIP_REASONS2,
71
71
  targetFromUiFingerprint2,
72
72
  scriptFromComputerUseActions2
73
- } from "./index-5cffktzd.js";
73
+ } from "./index-ntg7r3f3.js";
74
74
  import {
75
75
  UI_HEAL_MODES2,
76
76
  UI_HEAL_MODE_RANK2,
@@ -18,7 +18,7 @@ export declare const DEFAULT_LOGIN_SECRET_REFS: {
18
18
  readonly password: "login:password";
19
19
  };
20
20
  /** Why an action was not converted. */
21
- export declare const COMPUTER_USE_SKIP_REASONS: readonly ["ACTION_FAILED", "FIELD_UNKNOWN", "FRAME_NOT_ADDRESSABLE", "HOST_NOT_ALLOWED", "INVALID_ACTION", "INVALID_URL", "LOGIN_PAGE_UNKNOWN", "NO_EFFECT", "NO_ELEMENT", "OBSERVATION_ONLY", "SECRET_TARGET_UNKNOWN", "SECRET_VALUE", "TOO_MANY_INPUTS", "UNKNOWN_ACTION", "URL_CARRIES_SECRET"];
21
+ export declare const COMPUTER_USE_SKIP_REASONS: readonly ["ACTION_FAILED", "FIELD_UNKNOWN", "FRAME_NOT_ADDRESSABLE", "HOST_NOT_ALLOWED", "INVALID_ACTION", "INVALID_URL", "LOGIN_PAGE_UNKNOWN", "NO_EFFECT", "NO_ELEMENT", "OBSERVATION_ONLY", "SECRET_TARGET_UNKNOWN", "SECRET_VALUE", "TOO_MANY_INPUTS", "UNKNOWN_ACTION", "UNTRUSTED_RECORD", "URL_CARRIES_SECRET"];
22
22
  export type ComputerUseSkipReason = (typeof COMPUTER_USE_SKIP_REASONS)[number];
23
23
  /** The element an action touched, as the worker records it (`_uiTarget`). Every field is optional. */
24
24
  export interface ComputerUseUiTarget {
@@ -84,6 +84,13 @@ export interface ScriptFromComputerUseOptions {
84
84
  };
85
85
  /** Keep each typed value as its input's default. Absent means true. */
86
86
  inputDefaults?: boolean;
87
+ /**
88
+ * Read the worker fields (`ok`, `pageUrl`, `secretRef`, `screenshotFileId`, `_uiTarget`) of a
89
+ * flat record, one with no `args`. Only for records the caller built itself, where no worker
90
+ * field can have come from the model. Absent means false: such a record is skipped with
91
+ * `UNTRUSTED_RECORD`. The nested form is read the same either way.
92
+ */
93
+ trustFlatRecords?: boolean;
87
94
  }
88
95
  /** An element the script targets inline, which a person may save to the element library. */
89
96
  export interface ComputerUseProposedElement {
package/dist/script.js CHANGED
@@ -39,7 +39,7 @@ import {
39
39
  COMPUTER_USE_SKIP_REASONS2,
40
40
  targetFromUiFingerprint2,
41
41
  scriptFromComputerUseActions2
42
- } from "./index-5cffktzd.js";
42
+ } from "./index-ntg7r3f3.js";
43
43
  import"./index-bnvmt4wf.js";
44
44
  import {
45
45
  UI_SCRIPT_STEP_KEY_PREFIX2,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burdenoff/ui-engine",
3
- "version": "2026.1129.2",
3
+ "version": "2026.1201.1",
4
4
  "description": "Shared, browser-safe UI automation engine: recordings, capture-time masking, target resolution, replay, the UI script v1 contract, the multi-method web target resolver and DOM runtime, the UI script interpreter, the UI script analyzer and UI step healing for FluidGrids RPA and BotManor Stewards.",
5
5
  "license": "MIT",
6
6
  "author": "Burdenoff Consultancy Services Pvt. Ltd.",