@reticlehq/core 3.1.0 → 3.3.0

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 (82) hide show
  1. package/dist/artifacts/flow-composition.d.ts +3 -2
  2. package/dist/artifacts/flow-constants.d.ts +59 -2
  3. package/dist/artifacts/flow-constants.js +63 -3
  4. package/dist/artifacts/flow-expect-flat.d.ts +260 -0
  5. package/dist/artifacts/flow-expect-flat.js +284 -0
  6. package/dist/artifacts/flow-mutation-target.d.ts +0 -1
  7. package/dist/artifacts/flow-mutation-target.js +26 -2
  8. package/dist/artifacts/flow-step-tool.d.ts +2 -0
  9. package/dist/artifacts/flow-types.d.ts +1071 -1225
  10. package/dist/artifacts/flow-types.js +96 -140
  11. package/dist/artifacts/impact.d.ts +200 -20
  12. package/dist/artifacts/impact.js +72 -0
  13. package/dist/artifacts/journal.d.ts +85 -6
  14. package/dist/artifacts/journal.js +51 -1
  15. package/dist/hooks/hook-events.d.ts +18 -18
  16. package/dist/hud-entry.d.ts +9 -0
  17. package/dist/hud-entry.js +9 -0
  18. package/dist/identity/brand.d.ts +46 -0
  19. package/dist/identity/brand.js +7 -0
  20. package/dist/identity/source-constants.d.ts +11 -0
  21. package/dist/identity/source-constants.js +11 -0
  22. package/dist/index.d.ts +9 -0
  23. package/dist/index.js +26 -2
  24. package/dist/onboarding.d.ts +2 -2
  25. package/dist/realm/registry.d.ts +0 -8
  26. package/dist/realm/registry.js +1 -11
  27. package/dist/schema/event-message.json +3 -1
  28. package/dist/schema/event-payloads.json +74 -1
  29. package/dist/schema/event-type.json +3 -1
  30. package/dist/schema/reticle-event.json +3 -1
  31. package/dist/schema/reticle-message.json +3 -1
  32. package/dist/source-constants.cjs +1 -0
  33. package/dist/source-constants.d.cts +1 -0
  34. package/dist/telemetry-feedback.d.ts +6 -6
  35. package/dist/telemetry-refusal.d.ts +2 -2
  36. package/dist/telemetry-session.d.ts +25 -2
  37. package/dist/telemetry-session.js +13 -0
  38. package/dist/telemetry.d.ts +184 -102
  39. package/dist/telemetry.js +29 -1
  40. package/dist/verdict/consequence.d.ts +10 -0
  41. package/dist/verdict/consequence.js +13 -0
  42. package/dist/verdict/intent.d.ts +36 -12
  43. package/dist/verdict/intent.js +66 -10
  44. package/dist/verdict/predicate-tree.d.ts +47 -0
  45. package/dist/verdict/predicate-tree.js +146 -0
  46. package/dist/verdict/predicate.d.ts +129 -0
  47. package/dist/verdict/predicate.js +394 -0
  48. package/dist/verdict/property-assertion.d.ts +191 -0
  49. package/dist/verdict/property-assertion.js +42 -0
  50. package/dist/verdict/security.js +16 -4
  51. package/dist/verdict/verdict-attribution.d.ts +52 -0
  52. package/dist/verdict/verdict-attribution.js +87 -0
  53. package/dist/verdict/verification-run.d.ts +98 -84
  54. package/dist/verdict/verification-run.js +8 -1
  55. package/dist/verdict/verified-constants.d.ts +18 -0
  56. package/dist/verdict/verified-constants.js +18 -0
  57. package/dist/wire/constants/constants.d.ts +108 -98
  58. package/dist/wire/constants/constants.js +116 -97
  59. package/dist/wire/constants/discovery.d.ts +25 -0
  60. package/dist/wire/constants/discovery.js +25 -0
  61. package/dist/wire/constants/event-types.d.ts +122 -0
  62. package/dist/wire/constants/event-types.js +121 -0
  63. package/dist/wire/constants/hud-controls.d.ts +19 -0
  64. package/dist/wire/constants/hud-controls.js +95 -0
  65. package/dist/wire/constants/hud-use.d.ts +27 -0
  66. package/dist/wire/constants/hud-use.js +24 -0
  67. package/dist/wire/constants/session-constants.d.ts +24 -0
  68. package/dist/wire/constants/session-constants.js +24 -0
  69. package/dist/wire/event-payloads.d.ts +70 -10
  70. package/dist/wire/event-payloads.js +20 -1
  71. package/dist/wire/messages.d.ts +90 -48
  72. package/dist/wire/messages.js +17 -0
  73. package/dist/wire/net.d.ts +42 -0
  74. package/dist/wire/net.js +48 -0
  75. package/dist/wire/snapshot-tree.d.ts +33 -0
  76. package/dist/wire/snapshot-tree.js +43 -0
  77. package/dist/wire/state-select.d.ts +2 -1
  78. package/dist/wire/state-select.js +56 -3
  79. package/dist/wire/toon.js +28 -7
  80. package/dist/wire/types.d.ts +91 -66
  81. package/dist/wire/types.js +23 -1
  82. package/package.json +5 -1
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ import { HudPanel, HudToggle, HudView } from './constants/hud-use.js';
2
3
  import { EventAttribution, EventType, RETICLE_MIN_PROTOCOL_VERSION, RETICLE_PROTOCOL_VERSION, MessageKind, TRANSPORT_LIMITS, } from './constants/constants.js';
3
4
  import { HumanControlKind, MarkAnchorStrategy } from './constants/session-constants.js';
4
5
  import { MAX_WIRE_REDACT_KEYS, MAX_WIRE_REDACT_KEY_LENGTH } from './redaction.js';
@@ -17,6 +18,22 @@ export const HumanControlDataSchema = z.object({
17
18
  kind: z.nativeEnum(HumanControlKind),
18
19
  text: z.string().optional(),
19
20
  });
21
+ /**
22
+ * The narrowed payload of a HUD_USED event: a control pressed, or where the HUD now sits.
23
+ *
24
+ * The shape of a control id only. Membership in HUD_CONTROLS is checked where it is counted, in the
25
+ * daemon, so the list stays out of the bytes every page downloads on load.
26
+ */
27
+ export const HudUseDataSchema = z.object({
28
+ control: z
29
+ .string()
30
+ .max(48)
31
+ .regex(/^[a-z][a-zA-Z-]*(\.[a-zA-Z-]+)?$/)
32
+ .optional(),
33
+ toggle: z.nativeEnum(HudToggle).optional(),
34
+ view: z.nativeEnum(HudView).optional(),
35
+ panel: z.nativeEnum(HudPanel).optional(),
36
+ });
20
37
  /**
21
38
  * Human review: the narrowed payload of a HUMAN_MARK event. A human flagged a mistake pinned to an
22
39
  * element on the running page; the server safeParses `event.data` against this at the inbound
@@ -137,6 +137,24 @@ export declare function isDevToolingUrl(url: string | undefined): boolean;
137
137
  * caller who cannot say which page is under test gets exactly the behaviour it had before this.
138
138
  */
139
139
  export declare function isThirdPartyUrl(url: string | undefined, appUrl: string | undefined): boolean;
140
+ /**
141
+ * Is this the app's OWN background traffic — telemetry, a heartbeat — that the project declared?
142
+ *
143
+ * The same-origin half of the question `isThirdPartyUrl` answers by structure. `POST
144
+ * /api/analytics/events` on the app's own host looks exactly like the app's work, so nothing is
145
+ * inferred: a project names these in `.reticle.json` `background`, matched the way `urlContains`
146
+ * is. Nothing declared, nothing excluded. It never hides a request from a predicate that names it —
147
+ * it only stops the request holding a settle window open or contradicting an unrelated claim.
148
+ */
149
+ export declare function isOwnBackgroundTraffic(url: string | undefined, declared: readonly string[]): boolean;
150
+ /**
151
+ * Is this request somebody else's business — not the app's work under test?
152
+ *
153
+ * The ONE answer to "whose traffic counts", asked by the settle wait and by the contradiction rules
154
+ * alike. It used to be the same `||` written in two packages, and two copies of a rule are how one
155
+ * path starts judging traffic the other ignores.
156
+ */
157
+ export declare function isForeignTraffic(url: string | undefined, appUrl: string | undefined, background: readonly string[]): boolean;
140
158
  /**
141
159
  * The unredacted URL, kept so a grader can match `urlContains` against the path the app actually
142
160
  * requested. `url` is what is rendered to the agent and stored as the displayed value; this field
@@ -152,3 +170,27 @@ export declare const URL_RAW = "urlRaw";
152
170
  * otherwise the displayed (possibly redacted) `url`.
153
171
  */
154
172
  export declare function urlForMatch(data: Record<string, unknown>): string;
173
+ /**
174
+ * The NET_REQUEST field carrying a DISCRIMINATOR for the request body.
175
+ *
176
+ * `duplicate-request` asks whether two writes in one action's window were the same write. Method
177
+ * plus URL cannot answer that — a command-bus API posts every mutation to one endpoint, and a
178
+ * submit that intentionally saves and then advances sends two different payloads to the same URL —
179
+ * and the body that could answer it is not on the record: capturing bodies by default would put
180
+ * passwords, tokens and customer data on the wire for every request an app makes.
181
+ *
182
+ * So the page sends a fingerprint of the body's SHAPE instead: key names, value types and the total
183
+ * length, hashed. It is equal for two identical payloads and different for two payloads that differ
184
+ * in structure or size, which is all the rule needs, and it is not a projection of the payload —
185
+ * no character of any value is ever read into it, so there is nothing in it to recover.
186
+ */
187
+ export declare const REQUEST_SHAPE_FIELD = "requestShape";
188
+ /**
189
+ * The fingerprint of a request that carried NO body.
190
+ *
191
+ * A KNOWN discriminator, not a missing one: two bodyless POSTs to one URL are indistinguishable to
192
+ * the server too, so they are allowed to be a duplicate. A body the page cannot read as text
193
+ * (FormData, Blob, a stream) omits the field ALTOGETHER, which is the same statement an older SDK
194
+ * makes by not sending it: a body may have existed and nothing about it is on the record.
195
+ */
196
+ export declare const REQUEST_SHAPE_NONE = "none";
package/dist/wire/net.js CHANGED
@@ -186,6 +186,30 @@ export function isThirdPartyUrl(url, appUrl) {
186
186
  return false;
187
187
  return registrableDomain(target) !== registrableDomain(app);
188
188
  }
189
+ /**
190
+ * Is this the app's OWN background traffic — telemetry, a heartbeat — that the project declared?
191
+ *
192
+ * The same-origin half of the question `isThirdPartyUrl` answers by structure. `POST
193
+ * /api/analytics/events` on the app's own host looks exactly like the app's work, so nothing is
194
+ * inferred: a project names these in `.reticle.json` `background`, matched the way `urlContains`
195
+ * is. Nothing declared, nothing excluded. It never hides a request from a predicate that names it —
196
+ * it only stops the request holding a settle window open or contradicting an unrelated claim.
197
+ */
198
+ export function isOwnBackgroundTraffic(url, declared) {
199
+ if (url === undefined)
200
+ return false;
201
+ return declared.some((pattern) => url.includes(pattern));
202
+ }
203
+ /**
204
+ * Is this request somebody else's business — not the app's work under test?
205
+ *
206
+ * The ONE answer to "whose traffic counts", asked by the settle wait and by the contradiction rules
207
+ * alike. It used to be the same `||` written in two packages, and two copies of a rule are how one
208
+ * path starts judging traffic the other ignores.
209
+ */
210
+ export function isForeignTraffic(url, appUrl, background) {
211
+ return isThirdPartyUrl(url, appUrl) || isOwnBackgroundTraffic(url, background);
212
+ }
189
213
  /**
190
214
  * The unredacted URL, kept so a grader can match `urlContains` against the path the app actually
191
215
  * requested. `url` is what is rendered to the agent and stored as the displayed value; this field
@@ -207,3 +231,27 @@ export function urlForMatch(data) {
207
231
  const url = data['url'];
208
232
  return 'string' === typeof url ? url : '';
209
233
  }
234
+ /**
235
+ * The NET_REQUEST field carrying a DISCRIMINATOR for the request body.
236
+ *
237
+ * `duplicate-request` asks whether two writes in one action's window were the same write. Method
238
+ * plus URL cannot answer that — a command-bus API posts every mutation to one endpoint, and a
239
+ * submit that intentionally saves and then advances sends two different payloads to the same URL —
240
+ * and the body that could answer it is not on the record: capturing bodies by default would put
241
+ * passwords, tokens and customer data on the wire for every request an app makes.
242
+ *
243
+ * So the page sends a fingerprint of the body's SHAPE instead: key names, value types and the total
244
+ * length, hashed. It is equal for two identical payloads and different for two payloads that differ
245
+ * in structure or size, which is all the rule needs, and it is not a projection of the payload —
246
+ * no character of any value is ever read into it, so there is nothing in it to recover.
247
+ */
248
+ export const REQUEST_SHAPE_FIELD = 'requestShape';
249
+ /**
250
+ * The fingerprint of a request that carried NO body.
251
+ *
252
+ * A KNOWN discriminator, not a missing one: two bodyless POSTs to one URL are indistinguishable to
253
+ * the server too, so they are allowed to be a duplicate. A body the page cannot read as text
254
+ * (FormData, Blob, a stream) omits the field ALTOGETHER, which is the same statement an older SDK
255
+ * makes by not sending it: a body may have existed and nothing about it is on the record.
256
+ */
257
+ export const REQUEST_SHAPE_NONE = 'none';
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Reading the snapshot tree — the one line-per-element text format the browser emits.
3
+ *
4
+ * It lives in core because it is a WIRE format: the browser writes it, and several things on the
5
+ * Node side read it back. It was previously a helper beside the MCP tool handlers, which made every
6
+ * other reader import from the tool surface to parse a string the tool surface does not own — and a
7
+ * directory guard caught exactly that the moment a second layer needed it.
8
+ *
9
+ * A line looks like:
10
+ *
11
+ * - button "Pay $42.00" (ref=e4) [disabled]
12
+ *
13
+ * Only elements carrying a `ref` can be acted on, so only those are returned.
14
+ */
15
+ /** One interactive element: its ref, and the line it came from with the ref taken out. */
16
+ export interface InteractiveItem {
17
+ ref: string;
18
+ desc: string;
19
+ }
20
+ /**
21
+ * Parse interactive elements (those with refs) out of a snapshot tree.
22
+ *
23
+ * The description used to be built with a SECOND regex, `/\s*\(ref=e\d+\)/`, whose leading `\s*`
24
+ * made it quadratic: on a line with a long run of whitespace the engine retries the unbounded
25
+ * prefix at every position before failing the literal that follows. The tree is page-derived, so
26
+ * that run is app-controlled, and CodeQL flagged it as a polynomial ReDoS on the release branch.
27
+ *
28
+ * `REF` has already located the token, so the description is the line with that exact span cut
29
+ * out. The `\s*` was NOT redundant -- it ate the gap left behind when a ref sits mid-line, and two
30
+ * pinned tests failed when it was dropped outright -- so the prefix is trimmed instead. `trimEnd`
31
+ * is a string method: same result, linear, and one fewer regex to keep in step with the first.
32
+ */
33
+ export declare function parseInteractive(tree: string): InteractiveItem[];
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Reading the snapshot tree — the one line-per-element text format the browser emits.
3
+ *
4
+ * It lives in core because it is a WIRE format: the browser writes it, and several things on the
5
+ * Node side read it back. It was previously a helper beside the MCP tool handlers, which made every
6
+ * other reader import from the tool surface to parse a string the tool surface does not own — and a
7
+ * directory guard caught exactly that the moment a second layer needed it.
8
+ *
9
+ * A line looks like:
10
+ *
11
+ * - button "Pay $42.00" (ref=e4) [disabled]
12
+ *
13
+ * Only elements carrying a `ref` can be acted on, so only those are returned.
14
+ */
15
+ const REF = /\(ref=(e\d+)\)/;
16
+ /**
17
+ * Parse interactive elements (those with refs) out of a snapshot tree.
18
+ *
19
+ * The description used to be built with a SECOND regex, `/\s*\(ref=e\d+\)/`, whose leading `\s*`
20
+ * made it quadratic: on a line with a long run of whitespace the engine retries the unbounded
21
+ * prefix at every position before failing the literal that follows. The tree is page-derived, so
22
+ * that run is app-controlled, and CodeQL flagged it as a polynomial ReDoS on the release branch.
23
+ *
24
+ * `REF` has already located the token, so the description is the line with that exact span cut
25
+ * out. The `\s*` was NOT redundant -- it ate the gap left behind when a ref sits mid-line, and two
26
+ * pinned tests failed when it was dropped outright -- so the prefix is trimmed instead. `trimEnd`
27
+ * is a string method: same result, linear, and one fewer regex to keep in step with the first.
28
+ */
29
+ export function parseInteractive(tree) {
30
+ const items = [];
31
+ for (const line of tree.split('\n')) {
32
+ const match = REF.exec(line);
33
+ if (match !== null) {
34
+ const token = match[0];
35
+ const at = line.indexOf(token);
36
+ items.push({
37
+ ref: match[1] ?? '',
38
+ desc: `${line.slice(0, at).trimEnd()}${line.slice(at + token.length)}`.trim(),
39
+ });
40
+ }
41
+ }
42
+ return items;
43
+ }
@@ -25,7 +25,8 @@ export interface PathSelection {
25
25
  }
26
26
  /**
27
27
  * Walk `path` (e.g. "captionCache.v3.0.text") into `root`. Empty path returns root unchanged.
28
- * Segments are own keys, canonical array indices, Map keys, or `length` on an array/string.
28
+ * Segments are own keys, canonical array indices, Map keys, Set members, `length` on an
29
+ * array/string, or `size` on a Set/Map.
29
30
  */
30
31
  export declare function selectPath(root: unknown, path: string): PathSelection;
31
32
  /**
@@ -20,6 +20,19 @@ const LENGTH_SEGMENT = 'length';
20
20
  function hasIntrinsicLength(value) {
21
21
  return Array.isArray(value) || 'string' === typeof value;
22
22
  }
23
+ /**
24
+ * `size` is the second closed name, for the two collections that count with it instead of `length`.
25
+ *
26
+ * The same argument that admitted `length` admits this one: `selectedIds.size` is what an app with a
27
+ * `Set` actually holds, and refusing it reported `found: false` with `availableKeys: []` -- not "I
28
+ * cannot read this", but "the collection is empty", which is a claim about the app and a wrong one
29
+ * (#944).
30
+ *
31
+ * A closed NAME, not a property read, for exactly the reason `length` is. `size` is an accessor on
32
+ * `Set.prototype`/`Map.prototype`, so reaching it by prototype traversal would put `add`, `delete`,
33
+ * `clear`, `constructor` and `__proto__` back on the path grammar in the same move.
34
+ */
35
+ const SIZE_SEGMENT = 'size';
23
36
  /** The keys at a level, as a bounded sample plus the true count when the sample is short. */
24
37
  function keysOf(value) {
25
38
  if (Array.isArray(value)) {
@@ -35,10 +48,27 @@ function keysOf(value) {
35
48
  let total = 0;
36
49
  for (const k of value.keys()) {
37
50
  total += 1;
38
- if ('string' === typeof k && keys.length < MAX_AVAILABLE_KEYS)
51
+ if ('string' === typeof k && keys.length < MAX_AVAILABLE_KEYS - 1)
39
52
  keys.push(k);
40
53
  }
41
- return { keys, total };
54
+ // `size` is listed for the reason `length` is listed on an array: it IS selectable here, and a
55
+ // diagnosis that omits it sends someone who wanted the count looking for a key that does not
56
+ // exist. Counted too, so `totalKeys` matches what a caller can actually reach. A Map that
57
+ // really holds a `size` key already lists it, and the explicit entry is what a read returns.
58
+ if (value.has(SIZE_SEGMENT))
59
+ return { keys, total };
60
+ return { keys: [...keys, SIZE_SEGMENT], total: total + 1 };
61
+ }
62
+ if (value instanceof Set) {
63
+ // Was falling through to `Object.keys`, which is `[]` for every Set -- so a miss reported
64
+ // `availableKeys: [], totalKeys: 0` and stated as a fact that the collection was empty. Its
65
+ // members are what is reachable here, plus `size`.
66
+ const keys = [];
67
+ for (const item of value) {
68
+ if ('string' === typeof item && keys.length < MAX_AVAILABLE_KEYS - 1)
69
+ keys.push(item);
70
+ }
71
+ return { keys: [...keys, SIZE_SEGMENT], total: value.size + 1 };
42
72
  }
43
73
  if ('object' === typeof value && value !== null) {
44
74
  const all = Object.keys(value);
@@ -58,7 +88,8 @@ function miss(value) {
58
88
  }
59
89
  /**
60
90
  * Walk `path` (e.g. "captionCache.v3.0.text") into `root`. Empty path returns root unchanged.
61
- * Segments are own keys, canonical array indices, Map keys, or `length` on an array/string.
91
+ * Segments are own keys, canonical array indices, Map keys, Set members, `length` on an
92
+ * array/string, or `size` on a Set/Map.
62
93
  */
63
94
  export function selectPath(root, path) {
64
95
  const segments = path.split('.').filter((s) => s.length > 0);
@@ -83,10 +114,32 @@ export function selectPath(root, path) {
83
114
  continue;
84
115
  }
85
116
  if (current instanceof Map) {
117
+ // An explicit entry wins over the intrinsic. A Map that really holds a key called `size` is
118
+ // answering about its own data, and reading its count instead would be a silent wrong answer
119
+ // on the one shape where both readings are plausible.
86
120
  if (current.has(segment)) {
87
121
  current = current.get(segment);
88
122
  continue;
89
123
  }
124
+ if (SIZE_SEGMENT === segment) {
125
+ current = current.size;
126
+ continue;
127
+ }
128
+ return miss(current);
129
+ }
130
+ if (current instanceof Set) {
131
+ if (SIZE_SEGMENT === segment) {
132
+ current = current.size;
133
+ continue;
134
+ }
135
+ // MEMBERSHIP, not indexing: a Set has no order to index by, so the only question a named
136
+ // segment can ask of one is whether it holds that item. A segment it does not hold is a MISS
137
+ // rather than `false`, which is how every other absent path behaves here -- and the miss then
138
+ // lists what the Set does hold, which a bare `false` could not.
139
+ if (current.has(segment)) {
140
+ current = true;
141
+ continue;
142
+ }
90
143
  return miss(current);
91
144
  }
92
145
  // `Object.hasOwn`, not `in`: `in` walks the prototype, so a path segment of `constructor`,
package/dist/wire/toon.js CHANGED
@@ -113,20 +113,41 @@ function toText(v) {
113
113
  return String(v);
114
114
  return ''; // undefined / null / object / symbol have no representable text on a wire field
115
115
  }
116
- function encodeName(name) {
117
- return `"${toText(name).replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
118
- }
119
- function encodeValue(val) {
120
- return `"${toText(val).replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
116
+ /**
117
+ * Quote a text field for a TOON line.
118
+ *
119
+ * Order matters. The backslash goes first, so the escapes added after it are not themselves
120
+ * re-escaped. Then the double quote, which would otherwise end the field early.
121
+ *
122
+ * Then the LINE BREAKS, which is the part a line-oriented format cannot do without. TOON states its
123
+ * own grammar as "one element per line", and a raw newline inside a quoted name split one element
124
+ * across two lines: the second line was not an element and matched no rule of the grammar, so a
125
+ * reader had nothing sane to do with it. Apps supply these routinely rather than exceptionally,
126
+ * because `val=` is the element's current value and a multi-line value is what a textarea holds.
127
+ *
128
+ * Only the two line terminators are escaped. Every other control character is ugly on a line but
129
+ * does not break the one invariant this format has, and this is a projection for an agent to read
130
+ * rather than a sanitiser.
131
+ *
132
+ * `encodeName` and `encodeValue` were byte-identical and are now one function: two copies of an
133
+ * escaping rule is how one of them ends up a character behind the other.
134
+ */
135
+ function quote(text) {
136
+ const escaped = toText(text)
137
+ .replace(/\\/g, '\\\\')
138
+ .replace(/"/g, '\\"')
139
+ .replace(/\n/g, '\\n')
140
+ .replace(/\r/g, '\\r');
141
+ return `"${escaped}"`;
121
142
  }
122
143
  function encodeLine(el, depth) {
123
144
  const indent = ' '.repeat(depth);
124
145
  const type = abbreviateRole(el.role);
125
146
  const states = encodeStates(Array.isArray(el.states) ? el.states : [], el.visible);
126
147
  const ref = toText(el.ref) || '?';
127
- const parts = [indent + type, ref, encodeName(el.name), ...(states ? [states] : [])];
148
+ const parts = [indent + type, ref, quote(el.name), ...(states ? [states] : [])];
128
149
  if ('string' === typeof el.value && el.value.length > 0)
129
- parts.push(`val=${encodeValue(el.value)}`);
150
+ parts.push(`val=${quote(el.value)}`);
130
151
  if (el.childCount !== undefined)
131
152
  parts.push(`count=${String(el.childCount)}`);
132
153
  return parts.join(' ');