@reticlehq/core 2.1.0 → 2.2.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 (65) hide show
  1. package/LICENSE +201 -112
  2. package/NOTICE +5 -0
  3. package/dist/brand.d.ts +32 -3
  4. package/dist/brand.d.ts.map +1 -1
  5. package/dist/brand.js +9 -4
  6. package/dist/brand.js.map +1 -1
  7. package/dist/constants.d.ts +140 -5
  8. package/dist/constants.d.ts.map +1 -1
  9. package/dist/constants.js +136 -5
  10. package/dist/constants.js.map +1 -1
  11. package/dist/daemon-registry.d.ts +5 -5
  12. package/dist/daemon-registry.d.ts.map +1 -1
  13. package/dist/daemon-registry.js +5 -5
  14. package/dist/daemon-registry.js.map +1 -1
  15. package/dist/event-payloads.d.ts +502 -0
  16. package/dist/event-payloads.d.ts.map +1 -0
  17. package/dist/event-payloads.js +138 -0
  18. package/dist/event-payloads.js.map +1 -0
  19. package/dist/flow-constants.d.ts +2 -2
  20. package/dist/flow-constants.js +7 -7
  21. package/dist/flow-constants.js.map +1 -1
  22. package/dist/flow-types.d.ts +155 -32
  23. package/dist/flow-types.d.ts.map +1 -1
  24. package/dist/flow-types.js +23 -1
  25. package/dist/flow-types.js.map +1 -1
  26. package/dist/index.d.ts +19 -7
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +26 -12
  29. package/dist/index.js.map +1 -1
  30. package/dist/journal.d.ts +90 -0
  31. package/dist/journal.d.ts.map +1 -0
  32. package/dist/journal.js +38 -0
  33. package/dist/journal.js.map +1 -0
  34. package/dist/messages.d.ts +112 -16
  35. package/dist/messages.d.ts.map +1 -1
  36. package/dist/messages.js +15 -2
  37. package/dist/messages.js.map +1 -1
  38. package/dist/notices.d.ts +4 -4
  39. package/dist/notices.js +4 -4
  40. package/dist/redaction.d.ts +4 -0
  41. package/dist/redaction.d.ts.map +1 -0
  42. package/dist/redaction.js +33 -0
  43. package/dist/redaction.js.map +1 -0
  44. package/dist/schema/event-message.json +21 -1
  45. package/dist/schema/event-type.json +8 -1
  46. package/dist/schema/reticle-event.json +21 -1
  47. package/dist/schema/reticle-message.json +21 -1
  48. package/dist/session-constants.d.ts +2 -2
  49. package/dist/session-constants.js +2 -2
  50. package/dist/state-select.d.ts.map +1 -1
  51. package/dist/state-select.js +21 -5
  52. package/dist/state-select.js.map +1 -1
  53. package/dist/toon.d.ts +10 -10
  54. package/dist/toon.d.ts.map +1 -1
  55. package/dist/toon.js +34 -18
  56. package/dist/toon.js.map +1 -1
  57. package/dist/types.d.ts +70 -12
  58. package/dist/types.d.ts.map +1 -1
  59. package/dist/types.js +5 -0
  60. package/dist/types.js.map +1 -1
  61. package/dist/upgrade.d.ts +5 -5
  62. package/dist/upgrade.js +3 -3
  63. package/dist/verification-run.d.ts +23 -23
  64. package/dist/verification-run.js +1 -1
  65. package/package.json +6 -2
@@ -29,18 +29,25 @@
29
29
  "console.log",
30
30
  "console.warn",
31
31
  "console.error",
32
+ "console.info",
33
+ "console.debug",
32
34
  "error.uncaught",
33
35
  "visible.shown",
34
- "visible.hidden",
35
36
  "anim.start",
36
37
  "anim.end",
37
38
  "scroll.position",
38
39
  "reveal.shown",
39
40
  "signal",
40
41
  "state.change",
42
+ "storage.change",
41
43
  "page.health",
44
+ "render.commit",
45
+ "focus.change",
42
46
  "flow.recorded",
43
47
  "transport.overflow",
48
+ "truncated",
49
+ "blind-spot",
50
+ "net.detail",
44
51
  "human.control",
45
52
  "human.mark"
46
53
  ]
@@ -54,6 +61,19 @@
54
61
  "type": "string",
55
62
  "maxLength": 128
56
63
  },
64
+ "seq": {
65
+ "type": "integer",
66
+ "minimum": 0
67
+ },
68
+ "actionId": {
69
+ "$ref": "#/definitions/EventMessage/properties/event/properties/ref"
70
+ },
71
+ "attribution": {
72
+ "type": "string",
73
+ "enum": [
74
+ "window"
75
+ ]
76
+ },
57
77
  "data": {
58
78
  "type": "object",
59
79
  "additionalProperties": {},
@@ -16,18 +16,25 @@
16
16
  "console.log",
17
17
  "console.warn",
18
18
  "console.error",
19
+ "console.info",
20
+ "console.debug",
19
21
  "error.uncaught",
20
22
  "visible.shown",
21
- "visible.hidden",
22
23
  "anim.start",
23
24
  "anim.end",
24
25
  "scroll.position",
25
26
  "reveal.shown",
26
27
  "signal",
27
28
  "state.change",
29
+ "storage.change",
28
30
  "page.health",
31
+ "render.commit",
32
+ "focus.change",
29
33
  "flow.recorded",
30
34
  "transport.overflow",
35
+ "truncated",
36
+ "blind-spot",
37
+ "net.detail",
31
38
  "human.control",
32
39
  "human.mark"
33
40
  ]
@@ -22,18 +22,25 @@
22
22
  "console.log",
23
23
  "console.warn",
24
24
  "console.error",
25
+ "console.info",
26
+ "console.debug",
25
27
  "error.uncaught",
26
28
  "visible.shown",
27
- "visible.hidden",
28
29
  "anim.start",
29
30
  "anim.end",
30
31
  "scroll.position",
31
32
  "reveal.shown",
32
33
  "signal",
33
34
  "state.change",
35
+ "storage.change",
34
36
  "page.health",
37
+ "render.commit",
38
+ "focus.change",
35
39
  "flow.recorded",
36
40
  "transport.overflow",
41
+ "truncated",
42
+ "blind-spot",
43
+ "net.detail",
37
44
  "human.control",
38
45
  "human.mark"
39
46
  ]
@@ -47,6 +54,19 @@
47
54
  "type": "string",
48
55
  "maxLength": 128
49
56
  },
57
+ "seq": {
58
+ "type": "integer",
59
+ "minimum": 0
60
+ },
61
+ "actionId": {
62
+ "$ref": "#/definitions/ReticleEvent/properties/ref"
63
+ },
64
+ "attribution": {
65
+ "type": "string",
66
+ "enum": [
67
+ "window"
68
+ ]
69
+ },
50
70
  "data": {
51
71
  "type": "object",
52
72
  "additionalProperties": {},
@@ -145,18 +145,25 @@
145
145
  "console.log",
146
146
  "console.warn",
147
147
  "console.error",
148
+ "console.info",
149
+ "console.debug",
148
150
  "error.uncaught",
149
151
  "visible.shown",
150
- "visible.hidden",
151
152
  "anim.start",
152
153
  "anim.end",
153
154
  "scroll.position",
154
155
  "reveal.shown",
155
156
  "signal",
156
157
  "state.change",
158
+ "storage.change",
157
159
  "page.health",
160
+ "render.commit",
161
+ "focus.change",
158
162
  "flow.recorded",
159
163
  "transport.overflow",
164
+ "truncated",
165
+ "blind-spot",
166
+ "net.detail",
160
167
  "human.control",
161
168
  "human.mark"
162
169
  ]
@@ -168,6 +175,19 @@
168
175
  "type": "string",
169
176
  "maxLength": 128
170
177
  },
178
+ "seq": {
179
+ "type": "integer",
180
+ "minimum": 0
181
+ },
182
+ "actionId": {
183
+ "$ref": "#/definitions/ReticleMessage/anyOf/3/properties/event/properties/ref"
184
+ },
185
+ "attribution": {
186
+ "type": "string",
187
+ "enum": [
188
+ "window"
189
+ ]
190
+ },
171
191
  "data": {
172
192
  "type": "object",
173
193
  "additionalProperties": {},
@@ -72,7 +72,7 @@ export declare const SESSION_HEALTH: {
72
72
  export declare const SESSION_LIFECYCLE: {
73
73
  /**
74
74
  * Default agent-idle window before the panel hands back to the human as WAITING. The agent signals
75
- * this IMMEDIATELY via reticle_yield; this reaper is only the slow backstop for a forgotten yield, so
75
+ * this IMMEDIATELY via reticle_session {action:"yield"}; this reaper is only the slow backstop for a forgotten yield, so
76
76
  * it's deliberately long (a short window would auto-end a session mid slow-step). reticle_session-tunable.
77
77
  */
78
78
  readonly IDLE_END_MS: 300000;
@@ -94,7 +94,7 @@ export declare const SESSION_LIFECYCLE: {
94
94
  };
95
95
  /**
96
96
  * Coding-agent session hygiene thresholds. Coding agents (Claude Code, Codex, Cursor) often
97
- * complete their task and close their context without calling reticle_end_session. These constants
97
+ * complete their task and close their context without calling reticle_session {action:"end"}. These constants
98
98
  * drive two passive reminder layers: a one-time session_lease on first call, and recurring
99
99
  * session_age_warning fields after WARN_AFTER_MS.
100
100
  */
@@ -70,7 +70,7 @@ export const SESSION_HEALTH = {
70
70
  export const SESSION_LIFECYCLE = {
71
71
  /**
72
72
  * Default agent-idle window before the panel hands back to the human as WAITING. The agent signals
73
- * this IMMEDIATELY via reticle_yield; this reaper is only the slow backstop for a forgotten yield, so
73
+ * this IMMEDIATELY via reticle_session {action:"yield"}; this reaper is only the slow backstop for a forgotten yield, so
74
74
  * it's deliberately long (a short window would auto-end a session mid slow-step). reticle_session-tunable.
75
75
  */
76
76
  IDLE_END_MS: 300_000,
@@ -92,7 +92,7 @@ export const SESSION_LIFECYCLE = {
92
92
  };
93
93
  /**
94
94
  * Coding-agent session hygiene thresholds. Coding agents (Claude Code, Codex, Cursor) often
95
- * complete their task and close their context without calling reticle_end_session. These constants
95
+ * complete their task and close their context without calling reticle_session {action:"end"}. These constants
96
96
  * drive two passive reminder layers: a one-time session_lease on first call, and recurring
97
97
  * session_age_warning fields after WARN_AFTER_MS.
98
98
  */
@@ -1 +1 @@
1
- {"version":3,"file":"state-select.d.ts","sourceRoot":"","sources":["../src/state-select.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,wGAAwG;AACxG,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,oGAAoG;IACpG,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAQD,kGAAkG;AAClG,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,aAAa,CAmBrE;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAelE"}
1
+ {"version":3,"file":"state-select.d.ts","sourceRoot":"","sources":["../src/state-select.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,wGAAwG;AACxG,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,oGAAoG;IACpG,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAaD,kGAAkG;AAClG,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,aAAa,CA+BrE;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAkBlE"}
@@ -5,11 +5,14 @@
5
5
  * array indices) and, on a miss, returns the keys that WERE available at the last good level so a wrong
6
6
  * path is diagnosable rather than a bare null. `capDepth` prunes deeply-nested values to a budget.
7
7
  */
8
+ /** Cap on how many near-miss keys travel in a failed selection — a 10k-key store must not return a
9
+ * 10k-entry array in the error payload (that was the token blowup the near-miss exists to avoid). */
10
+ const MAX_AVAILABLE_KEYS = 50;
8
11
  function keysOf(value) {
9
12
  if (Array.isArray(value))
10
- return value.map((_, i) => String(i));
13
+ return value.slice(0, MAX_AVAILABLE_KEYS).map((_, i) => String(i));
11
14
  if (typeof value === 'object' && value !== null)
12
- return Object.keys(value);
15
+ return Object.keys(value).slice(0, MAX_AVAILABLE_KEYS);
13
16
  return [];
14
17
  }
15
18
  /** Walk `path` (e.g. "captionCache.v3.0.text") into `root`. Empty path returns root unchanged. */
@@ -18,14 +21,24 @@ export function selectPath(root, path) {
18
21
  let current = root;
19
22
  for (const segment of segments) {
20
23
  if (Array.isArray(current)) {
24
+ // Require a CANONICAL index string. `Number('01')`/`Number('1e0')`/`Number(' 1')` all coerce to 1,
25
+ // so `items.01` silently read index 1 — an assertion on a path that doesn't exist quietly passed.
26
+ // `String(index) === segment` accepts only "0","1","2",… and rejects the coercion aliases.
21
27
  const index = Number(segment);
22
- if (!Number.isInteger(index) || index < 0 || index >= current.length) {
28
+ if (!Number.isInteger(index) ||
29
+ index < 0 ||
30
+ String(index) !== segment ||
31
+ index >= current.length) {
23
32
  return { found: false, value: null, availableKeys: keysOf(current) };
24
33
  }
25
34
  current = current[index];
26
35
  continue;
27
36
  }
28
- if (typeof current === 'object' && current !== null && segment in current) {
37
+ // `Object.hasOwn`, not `in`: `in` walks the prototype, so a path segment of `constructor`,
38
+ // `__proto__`, or `toString` reported found:true and returned a function from Object.prototype —
39
+ // a state assertion on a typo'd path silently passed against a builtin instead of failing with
40
+ // availableKeys. Only an OWN key is a real state path.
41
+ if (typeof current === 'object' && current !== null && Object.hasOwn(current, segment)) {
29
42
  current = current[segment];
30
43
  continue;
31
44
  }
@@ -50,7 +63,10 @@ export function capDepth(value, maxDepth) {
50
63
  const keys = Object.keys(value);
51
64
  if (maxDepth === 0)
52
65
  return `{…${String(keys.length)} keys}`;
53
- const out = {};
66
+ // Null-proto target: a wire object can carry an own `__proto__` key (via JSON.parse), and
67
+ // `out['__proto__'] = …` on a normal object writes the prototype slot instead of a key, losing
68
+ // that key from the projection. A prototype-less target makes every key an ordinary assignment.
69
+ const out = Object.create(null);
54
70
  for (const key of keys)
55
71
  out[key] = capDepth(value[key], maxDepth - 1);
56
72
  return out;
@@ -1 +1 @@
1
- {"version":3,"file":"state-select.js","sourceRoot":"","sources":["../src/state-select.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAUH,SAAS,MAAM,CAAC,KAAc;IAC5B,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;IAChE,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC3E,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,kGAAkG;AAClG,MAAM,UAAU,UAAU,CAAC,IAAa,EAAE,IAAY;IACpD,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAC7D,IAAI,OAAO,GAAY,IAAI,CAAC;IAC5B,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,IAAI,KAAK,C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,CAAC;IAC/B,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,IAAI,QAAQ,KAAK,CAAC;YAAE,OAAO,UAAU,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC;QAC9D,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC;IACrD,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAChC,IAAI,QAAQ,KAAK,CAAC;YAAE,OAAO,KAAK,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;QAC5D,0FAA0F;QAC1F,+FAA+F;QAC/F,gGAAgG;QAChG,MAAM,GAAG,GAA4B,MAAM,CAAC,MAAM,CAAC,IAAI,CAA4B,CAAC;QACpF,KAAK,MAAM,GAAG,IAAI,IAAI;YACpB,GAAG,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAE,KAAiC,CAAC,GAAG,CAAC,EAAE,QAAQ,GAAG,CAAC,CAAC,CAAC;QAC7E,OAAO,GAAG,CAAC;IACb,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
package/dist/toon.d.ts CHANGED
@@ -7,22 +7,22 @@
7
7
  * able to generate and read it reliably from its training data alone.
8
8
  *
9
9
  * Grammar (one element per line):
10
- * type ref "name" [states] key=value ...
10
+ * type ref "name" [states] key=value...
11
11
  *
12
12
  * Element types (abbreviated roles):
13
- * btn button inp textbox/input sel combobox/listbox chk checkbox
14
- * rad radio lnk link img img dlg dialog/alertdialog
15
- * nav navigation lst list/listbox tab tab/tabpanel hdr heading
16
- * frm form mn menu/menubar fld group/fieldset el (any other role)
13
+ * btn button inp textbox/input sel combobox/listbox chk checkbox
14
+ * rad radio lnk link img img dlg dialog/alertdialog
15
+ * nav navigation lst list/listbox tab tab/tabpanel hdr heading
16
+ * frm form mn menu/menubar fld group/fieldset el (any other role)
17
17
  *
18
18
  * State flags (inside []):
19
- * vis visible hid hidden en enabled dis disabled
20
- * chk checked uch unchecked exp expanded col collapsed focus
19
+ * vis visible hid hidden en enabled dis disabled
20
+ * chk checked uch unchecked exp expanded col collapsed focus
21
21
  *
22
22
  * Attributes (key=value, space-separated):
23
- * val="..." current value of the element
24
- * count=N child count (for containers, replaces expanding children)
25
- * ph="..." placeholder text
23
+ * val="..." current value of the element
24
+ * count=N child count (for containers, replaces expanding children)
25
+ * ph="..." placeholder text
26
26
  */
27
27
  /** Encode an ElementDescriptor to a TOON line. */
28
28
  export interface ToonElement {
@@ -1 +1 @@
1
- {"version":3,"file":"toon.d.ts","sourceRoot":"","sources":["../src/toon.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,kDAAkD;AAClD,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAgHD,wEAAwE;AACxE,wBAAgB,MAAM,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,MAAM,CAGtD;AAED,+EAA+E;AAC/E,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAIpE;AAED,sFAAsF;AACtF,wBAAgB,UAAU,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAOnD"}
1
+ {"version":3,"file":"toon.d.ts","sourceRoot":"","sources":["../src/toon.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,kDAAkD;AAClD,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AA+HD,wEAAwE;AACxE,wBAAgB,MAAM,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,MAAM,CAGtD;AAED,+EAA+E;AAC/E,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAIpE;AAED,sFAAsF;AACtF,wBAAgB,UAAU,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAOnD"}
package/dist/toon.js CHANGED
@@ -7,22 +7,22 @@
7
7
  * able to generate and read it reliably from its training data alone.
8
8
  *
9
9
  * Grammar (one element per line):
10
- * type ref "name" [states] key=value ...
10
+ * type ref "name" [states] key=value...
11
11
  *
12
12
  * Element types (abbreviated roles):
13
- * btn button inp textbox/input sel combobox/listbox chk checkbox
14
- * rad radio lnk link img img dlg dialog/alertdialog
15
- * nav navigation lst list/listbox tab tab/tabpanel hdr heading
16
- * frm form mn menu/menubar fld group/fieldset el (any other role)
13
+ * btn button inp textbox/input sel combobox/listbox chk checkbox
14
+ * rad radio lnk link img img dlg dialog/alertdialog
15
+ * nav navigation lst list/listbox tab tab/tabpanel hdr heading
16
+ * frm form mn menu/menubar fld group/fieldset el (any other role)
17
17
  *
18
18
  * State flags (inside []):
19
- * vis visible hid hidden en enabled dis disabled
20
- * chk checked uch unchecked exp expanded col collapsed focus
19
+ * vis visible hid hidden en enabled dis disabled
20
+ * chk checked uch unchecked exp expanded col collapsed focus
21
21
  *
22
22
  * Attributes (key=value, space-separated):
23
- * val="..." current value of the element
24
- * count=N child count (for containers, replaces expanding children)
25
- * ph="..." placeholder text
23
+ * val="..." current value of the element
24
+ * count=N child count (for containers, replaces expanding children)
25
+ * ph="..." placeholder text
26
26
  */
27
27
  const ROLE_MAP = {
28
28
  button: 'btn',
@@ -104,18 +104,28 @@ function encodeStates(states, visible) {
104
104
  }
105
105
  return flags.length > 0 ? `[${flags.join(',')}]` : '';
106
106
  }
107
+ /** Coerce a wire field to a string. resultToToon receives UNVALIDATED wire data cast to ToonElement,
108
+ * so a missing/numeric `name` must not make `.replace` throw and lose the whole encode. */
109
+ function toText(v) {
110
+ if (typeof v === 'string')
111
+ return v;
112
+ if (typeof v === 'number' || typeof v === 'boolean' || typeof v === 'bigint')
113
+ return String(v);
114
+ return ''; // undefined / null / object / symbol have no representable text on a wire field
115
+ }
107
116
  function encodeName(name) {
108
- return `"${name.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
117
+ return `"${toText(name).replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
109
118
  }
110
119
  function encodeValue(val) {
111
- return `"${val.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
120
+ return `"${toText(val).replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
112
121
  }
113
122
  function encodeLine(el, depth) {
114
123
  const indent = ' '.repeat(depth);
115
124
  const type = abbreviateRole(el.role);
116
- const states = encodeStates(el.states ?? [], el.visible);
117
- const parts = [indent + type, el.ref, encodeName(el.name), ...(states ? [states] : [])];
118
- if (el.value !== undefined && el.value.length > 0)
125
+ const states = encodeStates(Array.isArray(el.states) ? el.states : [], el.visible);
126
+ const ref = toText(el.ref) || '?';
127
+ const parts = [indent + type, ref, encodeName(el.name), ...(states ? [states] : [])];
128
+ if (typeof el.value === 'string' && el.value.length > 0)
119
129
  parts.push(`val=${encodeValue(el.value)}`);
120
130
  if (el.childCount !== undefined)
121
131
  parts.push(`count=${String(el.childCount)}`);
@@ -124,9 +134,15 @@ function encodeLine(el, depth) {
124
134
  function encodeTree(elements, depth = 0) {
125
135
  const lines = [];
126
136
  for (const el of elements) {
127
- lines.push(encodeLine(el, depth));
128
- if (el.children && el.children.length > 0) {
129
- lines.push(encodeTree(el.children, depth + 1));
137
+ // A single malformed element must not lose the rest of the tree — fall back to a placeholder line.
138
+ try {
139
+ lines.push(encodeLine(el, depth));
140
+ if (Array.isArray(el.children) && el.children.length > 0) {
141
+ lines.push(encodeTree(el.children, depth + 1));
142
+ }
143
+ }
144
+ catch {
145
+ lines.push(`${' '.repeat(depth)}el ? "[unencodable]"`);
130
146
  }
131
147
  }
132
148
  return lines.join('\n');
package/dist/toon.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"toon.js","sourceRoot":"","sources":["../src/toon.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAeH,MAAM,QAAQ,GAA2B;IACvC,MAAM,EAAE,KAAK;IACb,OAAO,EAAE,KAAK;IACd,MAAM,EAAE,KAAK;IACb,QAAQ,EAAE,KAAK;IACf,KAAK,EAAE,KAAK;IACZ,IAAI,EAAE,KAAK;IACX,GAAG,EAAE,KAAK;IACV,MAAM,EAAE,KAAK;IACb,WAAW,EAAE,KAAK;IAClB,UAAU,EAAE,KAAK;IACjB,IAAI,EAAE,KAAK;IACX,OAAO,EAAE,KAAK;IACd,QAAQ,EAAE,IAAI;IACd,QAAQ,EAAE,KAAK;IACf,MAAM,EAAE,KAAK;IACb,GAAG,EAAE,KAAK;IACV,QAAQ,EAAE,KAAK;IACf,OAAO,EAAE,KAAK;IACd,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,IAAI;IACV,OAAO,EAAE,IAAI;IACb,QAAQ,EA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AC;QAC1D,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,MAAM,CAAC,QAAuB;IAC5C,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,mBAAmB,CAAC;IACtD,OAAO,cAAc,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;AAC9C,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,YAAY,CAAC,MAA+B;IAC1D,MAAM,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC;IACpC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;QAAE,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC5D,OAAO,MAAM,CAAC,QAAyB,CAAC,CAAC;AAC3C,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,UAAU,CAAC,MAAe;IACxC,OAAO,CACL,OAAO,MAAM,KAAK,QAAQ;QAC1B,MAAM,KAAK,IAAI;QACf,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;QACtB,KAAK,CAAC,OAAO,CAAE,MAAkC,CAAC,UAAU,CAAC,CAAC,CAC/D,CAAC;AACJ,CAAC"}
package/dist/types.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { Ref } from './brand.js';
1
2
  import { z } from 'zod';
2
3
  import { type AnnotationErrorCode, type AnnotationTarget, ElementState } from './constants.js';
3
4
  import type { FlowExpect } from './flow-types.js';
@@ -22,6 +23,11 @@ export declare const ElementQuerySchema: z.ZodObject<{
22
23
  alt: z.ZodOptional<z.ZodString>;
23
24
  /** Component display name (auto-anchor resolution). The nearest enclosing component of the target. */
24
25
  component: z.ZodOptional<z.ZodString>;
26
+ /**
27
+ * Attribute names to project onto each match (e.g. `['href']` to inventory links, `['src']` for
28
+ * images). Without this the descriptor carries only semantics, so URLs are unreachable.
29
+ */
30
+ attrs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
25
31
  /** Source location of the target element (auto-anchor resolution) — the precise, granular match. */
26
32
  source: z.ZodOptional<z.ZodObject<{
27
33
  file: z.ZodString;
@@ -54,6 +60,7 @@ export declare const ElementQuerySchema: z.ZodObject<{
54
60
  } | undefined;
55
61
  name?: string | undefined;
56
62
  by?: "testid" | "role" | "component" | "text" | "label" | "placeholder" | "alt" | undefined;
63
+ attrs?: string[] | undefined;
57
64
  scope?: string | undefined;
58
65
  }, {
59
66
  testid?: string | undefined;
@@ -71,23 +78,64 @@ export declare const ElementQuerySchema: z.ZodObject<{
71
78
  } | undefined;
72
79
  name?: string | undefined;
73
80
  by?: "testid" | "role" | "component" | "text" | "label" | "placeholder" | "alt" | undefined;
81
+ attrs?: string[] | undefined;
74
82
  scope?: string | undefined;
75
83
  }>;
76
84
  export type ElementQuery = z.infer<typeof ElementQuerySchema>;
77
85
  /** Compact semantic descriptor of one element surfaced to the agent. */
78
86
  export interface ElementDescriptor {
79
- ref: string;
87
+ /** Branded: minted by the browser's ref registry, so it cannot be confused with another id kind. */
88
+ ref: Ref;
80
89
  role: string;
81
90
  name: string;
82
91
  value?: string;
83
92
  states: ElementState[];
84
93
  visible: boolean;
85
94
  text?: string;
95
+ /**
96
+ * Attributes explicitly requested via `ElementQuery.attrs`. Absent attributes are omitted (so
97
+ * "missing" and "present but blank" stay distinguishable) and credential-bearing names are redacted.
98
+ */
99
+ attrs?: Record<string, string>;
100
+ /**
101
+ * Where this element is written, as `file:line` — the nearest `data-reticle-source` stamped by the
102
+ * build plugin in dev. Absent in production builds and in apps that do not use the plugin, so an
103
+ * agent must treat it as a shortcut rather than a guarantee.
104
+ *
105
+ * A compact string rather than `{file, line}` because a descriptor can repeat hundreds of times in
106
+ * one response and every consumer either opens an editor or prints it.
107
+ */
108
+ source?: string;
109
+ /**
110
+ * Chart geometry faults found inside this element — PRESENT ONLY WHEN SOMETHING IS WRONG.
111
+ *
112
+ * A chart is the one dashboard surface where the store and the screen diverge invisibly: every
113
+ * other widget renders text a comparison can read, while a chart renders coordinates that a correct
114
+ * `series` can still turn into a blank or NaN-filled path. Reported on the descriptor rather than
115
+ * behind a new tool so it costs nothing to ask for — the agent already queries the chart element,
116
+ * and a healthy chart adds zero bytes because the field is omitted.
117
+ */
118
+ chart?: ChartFault[];
119
+ }
120
+ /** One chart geometry fault. `kind` is what an agent branches on; `sample` is bounded for the wire. */
121
+ export interface ChartFault {
122
+ kind: 'non-finite-coordinates' | 'empty-geometry' | 'degenerate-geometry';
123
+ tag: string;
124
+ attr: string;
125
+ sample: string;
86
126
  }
87
127
  export interface MatchResult {
88
128
  matched: boolean;
89
129
  count: number;
90
130
  elements: ElementDescriptor[];
131
+ /**
132
+ * True when a `scope` was given but resolved to nothing (the container was unmounted or the selector
133
+ * matched no element). The search returns zero matches WITHOUT falling back to the whole page, and
134
+ * this flag says why — so "element absent" and "scope vanished" stay distinguishable. Without it, a
135
+ * scoped assertion silently widened to the body (a phantom positive) or read a gone scope as a
136
+ * confirmed absence (a false negative); both are the false-green shape this tool exists to prevent.
137
+ */
138
+ scopeMissing?: boolean;
91
139
  }
92
140
  /**
93
141
  * A semantic cluster of interactive elements in the DOM — the replacement for the raw testid list
@@ -117,7 +165,17 @@ export interface QueryEmptyHint {
117
165
  /** Result of the QUERY command / reticle_query tool. `hint` present ONLY on zero matches. */
118
166
  export interface QueryResult {
119
167
  elements: ElementDescriptor[];
168
+ /**
169
+ * How many elements MATCHED, which is not the same as how many are in `elements`.
170
+ *
171
+ * Descriptors are expensive to build and the transport caps collections, so beyond a point matches
172
+ * are counted but not described. Reporting the count separately is what keeps "how many are there?"
173
+ * an exact answer instead of a description of the cap.
174
+ */
175
+ count: number;
120
176
  hint?: QueryEmptyHint;
177
+ /** See MatchResult.scopeMissing — a provided scope resolved to nothing; the search did not widen. */
178
+ scopeMissing?: boolean;
121
179
  }
122
180
  /** One named flow advertised by the app (mirrors the browser CapabilityFlow). */
123
181
  export declare const CapabilityFlowSchema: z.ZodObject<{
@@ -517,8 +575,8 @@ export declare const RunRecordSchema: z.ZodObject<{
517
575
  durationMs: z.ZodOptional<z.ZodNumber>;
518
576
  }, "strip", z.ZodTypeAny, {
519
577
  status: "pass" | "drift" | "error" | "fail";
520
- at: number;
521
578
  kind: "flow_replay" | "manual";
579
+ at: number;
522
580
  name: string;
523
581
  durationMs?: number | undefined;
524
582
  evidence?: {
@@ -529,8 +587,8 @@ export declare const RunRecordSchema: z.ZodObject<{
529
587
  summary?: string | undefined;
530
588
  }, {
531
589
  status: "pass" | "drift" | "error" | "fail";
532
- at: number;
533
590
  kind: "flow_replay" | "manual";
591
+ at: number;
534
592
  name: string;
535
593
  durationMs?: number | undefined;
536
594
  evidence?: {
@@ -596,8 +654,8 @@ export declare const ProjectFileSchema: z.ZodObject<{
596
654
  durationMs: z.ZodOptional<z.ZodNumber>;
597
655
  }, "strip", z.ZodTypeAny, {
598
656
  status: "pass" | "drift" | "error" | "fail";
599
- at: number;
600
657
  kind: "flow_replay" | "manual";
658
+ at: number;
601
659
  name: string;
602
660
  durationMs?: number | undefined;
603
661
  evidence?: {
@@ -608,8 +666,8 @@ export declare const ProjectFileSchema: z.ZodObject<{
608
666
  summary?: string | undefined;
609
667
  }, {
610
668
  status: "pass" | "drift" | "error" | "fail";
611
- at: number;
612
669
  kind: "flow_replay" | "manual";
670
+ at: number;
613
671
  name: string;
614
672
  durationMs?: number | undefined;
615
673
  evidence?: {
@@ -622,8 +680,8 @@ export declare const ProjectFileSchema: z.ZodObject<{
622
680
  }, "strip", z.ZodTypeAny, {
623
681
  runs: {
624
682
  status: "pass" | "drift" | "error" | "fail";
625
- at: number;
626
683
  kind: "flow_replay" | "manual";
684
+ at: number;
627
685
  name: string;
628
686
  durationMs?: number | undefined;
629
687
  evidence?: {
@@ -641,8 +699,8 @@ export declare const ProjectFileSchema: z.ZodObject<{
641
699
  }, {
642
700
  runs: {
643
701
  status: "pass" | "drift" | "error" | "fail";
644
- at: number;
645
702
  kind: "flow_replay" | "manual";
703
+ at: number;
646
704
  name: string;
647
705
  durationMs?: number | undefined;
648
706
  evidence?: {
@@ -731,13 +789,13 @@ export declare const AnnotationSchema: z.ZodDiscriminatedUnion<"kind", [z.ZodObj
731
789
  }, "strip", z.ZodTypeAny, {
732
790
  status?: number | undefined;
733
791
  method?: string | undefined;
734
- urlContains?: string | undefined;
735
792
  count?: number | undefined;
793
+ urlContains?: string | undefined;
736
794
  }, {
737
795
  status?: number | undefined;
738
796
  method?: string | undefined;
739
- urlContains?: string | undefined;
740
797
  count?: number | undefined;
798
+ urlContains?: string | undefined;
741
799
  }>>;
742
800
  console: z.ZodOptional<z.ZodObject<{
743
801
  level: z.ZodOptional<z.ZodString>;
@@ -756,8 +814,8 @@ export declare const AnnotationSchema: z.ZodDiscriminatedUnion<"kind", [z.ZodObj
756
814
  net?: {
757
815
  status?: number | undefined;
758
816
  method?: string | undefined;
759
- urlContains?: string | undefined;
760
817
  count?: number | undefined;
818
+ urlContains?: string | undefined;
761
819
  } | undefined;
762
820
  console?: {
763
821
  level?: string | undefined;
@@ -774,8 +832,8 @@ export declare const AnnotationSchema: z.ZodDiscriminatedUnion<"kind", [z.ZodObj
774
832
  net?: {
775
833
  status?: number | undefined;
776
834
  method?: string | undefined;
777
- urlContains?: string | undefined;
778
835
  count?: number | undefined;
836
+ urlContains?: string | undefined;
779
837
  } | undefined;
780
838
  console?: {
781
839
  level?: string | undefined;
@@ -815,7 +873,7 @@ export type AnnotateResult = {
815
873
  * (success-state). All optional; exactly the fields the compiled kind needs are set.
816
874
  */
817
875
  export interface AnnotatePatch {
818
- /** index of the step whose .expect is set (assert-signal / assert-visible). */
876
+ /** index of the step whose.expect is set (assert-signal / assert-visible). */
819
877
  stepIndex?: number;
820
878
  stepExpect?: FlowExpect;
821
879
  /** the testid pushed into flow.dynamic[] (mark-dynamic). */