@reticlehq/core 3.7.0 → 3.8.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 (108) hide show
  1. package/dist/activation-entry.d.ts +9 -0
  2. package/dist/activation-entry.js +9 -0
  3. package/dist/artifacts/drive-script.d.ts +64 -64
  4. package/dist/artifacts/flow-constants.d.ts +15 -0
  5. package/dist/artifacts/flow-constants.js +15 -0
  6. package/dist/artifacts/flow-expect-flat.d.ts +8 -8
  7. package/dist/artifacts/flow-results.d.ts +11 -0
  8. package/dist/artifacts/flow-types.d.ts +164 -118
  9. package/dist/artifacts/flow-types.js +12 -0
  10. package/dist/artifacts/harness-credits.d.ts +6 -3
  11. package/dist/artifacts/harness-credits.js +9 -6
  12. package/dist/artifacts/harness-map.d.ts +6 -6
  13. package/dist/artifacts/impact.d.ts +77 -80
  14. package/dist/artifacts/impact.js +34 -17
  15. package/dist/artifacts/journal.d.ts +25 -6
  16. package/dist/artifacts/journal.js +13 -0
  17. package/dist/artifacts/prompt-context.d.ts +12 -0
  18. package/dist/artifacts/prompt-context.js +14 -3
  19. package/dist/graph/app-graph.d.ts +137 -0
  20. package/dist/graph/app-graph.js +498 -0
  21. package/dist/hooks/hook-events.d.ts +22 -22
  22. package/dist/hud-entry.js +1 -1
  23. package/dist/identity/checkout.d.ts +41 -0
  24. package/dist/identity/checkout.js +118 -0
  25. package/dist/identity/state-dir.d.ts +23 -0
  26. package/dist/identity/state-dir.js +43 -0
  27. package/dist/index.d.ts +10 -0
  28. package/dist/index.js +10 -0
  29. package/dist/onboarding.d.ts +22 -1
  30. package/dist/onboarding.js +19 -0
  31. package/dist/registry/dev-server-registry.d.ts +2 -2
  32. package/dist/schema/event-message.json +3 -1
  33. package/dist/schema/event-payloads.json +116 -1
  34. package/dist/schema/event-type.json +3 -1
  35. package/dist/schema/hello-message.json +21 -0
  36. package/dist/schema/reticle-event.json +3 -1
  37. package/dist/schema/reticle-message.json +24 -1
  38. package/dist/telemetry-bug.d.ts +6 -6
  39. package/dist/telemetry-entry.d.ts +1 -1
  40. package/dist/telemetry-entry.js +1 -1
  41. package/dist/telemetry-feedback.d.ts +14 -0
  42. package/dist/telemetry-feedback.js +19 -0
  43. package/dist/telemetry-refusal.d.ts +2 -2
  44. package/dist/telemetry-session.d.ts +23 -8
  45. package/dist/telemetry-session.js +15 -4
  46. package/dist/telemetry-signals.d.ts +227 -9
  47. package/dist/telemetry-signals.js +88 -1
  48. package/dist/telemetry.d.ts +379 -72
  49. package/dist/telemetry.js +71 -5
  50. package/dist/verdict/check-sentence.d.ts +34 -0
  51. package/dist/verdict/check-sentence.js +228 -0
  52. package/dist/verdict/consequence.d.ts +15 -0
  53. package/dist/verdict/consequence.js +11 -0
  54. package/dist/verdict/findings.d.ts +10 -0
  55. package/dist/verdict/findings.js +13 -0
  56. package/dist/verdict/instrumentation-coverage.d.ts +3 -34
  57. package/dist/verdict/instrumentation-coverage.js +14 -58
  58. package/dist/verdict/instrumentation-gap.d.ts +79 -0
  59. package/dist/verdict/instrumentation-gap.js +64 -0
  60. package/dist/verdict/predicate-tree.d.ts +2 -0
  61. package/dist/verdict/predicate-tree.js +16 -0
  62. package/dist/verdict/predicate.d.ts +2 -1
  63. package/dist/verdict/predicate.js +103 -12
  64. package/dist/verdict/property-assertion.d.ts +2 -2
  65. package/dist/verdict/run-report.d.ts +166 -0
  66. package/dist/verdict/run-report.js +53 -0
  67. package/dist/verdict/security.d.ts +36 -2
  68. package/dist/verdict/security.js +94 -14
  69. package/dist/verdict/verification-run.d.ts +95 -38
  70. package/dist/verdict/verification-run.js +33 -2
  71. package/dist/verdict/verify-progress.d.ts +6 -6
  72. package/dist/wire/constants/constants.d.ts +56 -141
  73. package/dist/wire/constants/constants.js +64 -144
  74. package/dist/wire/constants/discovery.d.ts +4 -4
  75. package/dist/wire/constants/discovery.js +4 -4
  76. package/dist/wire/constants/event-types.d.ts +35 -1
  77. package/dist/wire/constants/event-types.js +33 -1
  78. package/dist/wire/constants/hud-controls.js +0 -2
  79. package/dist/wire/constants/hud-use.d.ts +4 -0
  80. package/dist/wire/constants/hud-use.js +4 -0
  81. package/dist/wire/constants/mcp-wire.d.ts +16 -0
  82. package/dist/wire/constants/mcp-wire.js +16 -0
  83. package/dist/wire/constants/response-body-reason.d.ts +19 -0
  84. package/dist/wire/constants/response-body-reason.js +18 -0
  85. package/dist/wire/constants/reticle-env.d.ts +138 -0
  86. package/dist/wire/constants/reticle-env.js +138 -0
  87. package/dist/wire/constants/session-constants.d.ts +11 -0
  88. package/dist/wire/constants/session-constants.js +11 -0
  89. package/dist/wire/event-payloads.d.ts +150 -36
  90. package/dist/wire/event-payloads.js +83 -16
  91. package/dist/wire/messages.d.ts +102 -36
  92. package/dist/wire/messages.js +16 -0
  93. package/dist/wire/narrow.d.ts +6 -0
  94. package/dist/wire/narrow.js +26 -0
  95. package/dist/wire/next-step.d.ts +90 -0
  96. package/dist/wire/next-step.js +37 -0
  97. package/dist/wire/platform-link.d.ts +7 -0
  98. package/dist/wire/platform-link.js +12 -6
  99. package/dist/wire/production/activation-ticket.d.ts +64 -0
  100. package/dist/wire/production/activation-ticket.js +148 -0
  101. package/dist/wire/production/hello-mode.d.ts +35 -0
  102. package/dist/wire/production/hello-mode.js +32 -0
  103. package/dist/wire/production/production-policy.d.ts +138 -0
  104. package/dist/wire/production/production-policy.js +133 -0
  105. package/dist/wire/tool-names.d.ts +2 -0
  106. package/dist/wire/tool-names.js +2 -0
  107. package/dist/wire/types.d.ts +73 -48
  108. package/package.json +5 -1
@@ -61,6 +61,38 @@ export declare const RouteChangeHow: {
61
61
  export type RouteChangeHow = (typeof RouteChangeHow)[keyof typeof RouteChangeHow];
62
62
  /** Wire field on `route.change` carrying a `RouteChangeHow`. */
63
63
  export declare const ROUTE_CHANGE_HOW_FIELD = "how";
64
+ /**
65
+ * Why a `field.change` was emitted.
66
+ *
67
+ * `input` is a burst of keystrokes and `change` is the commit that ends one — both are the user's
68
+ * own event, fired before a controlled component restores its DOM property. `settled` is a read of
69
+ * that property on the frame after the handlers ran. Only a settled read that differs from the
70
+ * pre-action value is evidence the screen moved.
71
+ */
72
+ export declare const FieldChangeKind: {
73
+ readonly INPUT: "input";
74
+ readonly CHANGE: "change";
75
+ readonly SETTLED: "settled";
76
+ };
77
+ export type FieldChangeKind = (typeof FieldChangeKind)[keyof typeof FieldChangeKind];
78
+ /**
79
+ * Wire fields on `field.change` beyond `field` / `kind` / `value` / `length`.
80
+ *
81
+ * `checked` is the property a checkbox or radio actually renders; `value` on those is the HTML
82
+ * value (`"on"`), which does not move when the box is toggled. `previous` and `previousChecked`
83
+ * are the same reading from before the action, present on a settled event so a consumer can tell
84
+ * a render from a restore.
85
+ */
86
+ export declare const FieldChangeField: {
87
+ readonly FIELD: "field";
88
+ readonly KIND: "kind";
89
+ readonly LENGTH: "length";
90
+ readonly VALUE: "value";
91
+ readonly REDACTED: "redacted";
92
+ readonly CHECKED: "checked";
93
+ readonly PREVIOUS: "previous";
94
+ readonly PREVIOUS_CHECKED: "previousChecked";
95
+ };
64
96
  /**
65
97
  * The three readable client-side storage areas.
66
98
  *
@@ -88,8 +120,8 @@ export declare const SeedCookieSchema: z.ZodObject<{
88
120
  sameSite: z.ZodOptional<z.ZodEnum<["Strict", "Lax", "None"]>>;
89
121
  expires: z.ZodOptional<z.ZodNumber>;
90
122
  }, "strip", z.ZodTypeAny, {
91
- value: string;
92
123
  name: string;
124
+ value: string;
93
125
  path?: string | undefined;
94
126
  url?: string | undefined;
95
127
  domain?: string | undefined;
@@ -98,8 +130,8 @@ export declare const SeedCookieSchema: z.ZodObject<{
98
130
  sameSite?: "Strict" | "Lax" | "None" | undefined;
99
131
  expires?: number | undefined;
100
132
  }, {
101
- value: string;
102
133
  name: string;
134
+ value: string;
103
135
  path?: string | undefined;
104
136
  url?: string | undefined;
105
137
  domain?: string | undefined;
@@ -120,8 +152,8 @@ export declare const SeedCookiesSchema: z.ZodUnion<[z.ZodRecord<z.ZodString, z.Z
120
152
  sameSite: z.ZodOptional<z.ZodEnum<["Strict", "Lax", "None"]>>;
121
153
  expires: z.ZodOptional<z.ZodNumber>;
122
154
  }, "strip", z.ZodTypeAny, {
123
- value: string;
124
155
  name: string;
156
+ value: string;
125
157
  path?: string | undefined;
126
158
  url?: string | undefined;
127
159
  domain?: string | undefined;
@@ -130,8 +162,8 @@ export declare const SeedCookiesSchema: z.ZodUnion<[z.ZodRecord<z.ZodString, z.Z
130
162
  sameSite?: "Strict" | "Lax" | "None" | undefined;
131
163
  expires?: number | undefined;
132
164
  }, {
133
- value: string;
134
165
  name: string;
166
+ value: string;
135
167
  path?: string | undefined;
136
168
  url?: string | undefined;
137
169
  domain?: string | undefined;
@@ -159,8 +191,8 @@ export declare const SeedStorageSchema: z.ZodObject<{
159
191
  sameSite: z.ZodOptional<z.ZodEnum<["Strict", "Lax", "None"]>>;
160
192
  expires: z.ZodOptional<z.ZodNumber>;
161
193
  }, "strip", z.ZodTypeAny, {
162
- value: string;
163
194
  name: string;
195
+ value: string;
164
196
  path?: string | undefined;
165
197
  url?: string | undefined;
166
198
  domain?: string | undefined;
@@ -169,8 +201,8 @@ export declare const SeedStorageSchema: z.ZodObject<{
169
201
  sameSite?: "Strict" | "Lax" | "None" | undefined;
170
202
  expires?: number | undefined;
171
203
  }, {
172
- value: string;
173
204
  name: string;
205
+ value: string;
174
206
  path?: string | undefined;
175
207
  url?: string | undefined;
176
208
  domain?: string | undefined;
@@ -183,8 +215,8 @@ export declare const SeedStorageSchema: z.ZodObject<{
183
215
  local?: Record<string, string> | undefined;
184
216
  session?: Record<string, string> | undefined;
185
217
  cookies?: Record<string, string> | {
186
- value: string;
187
218
  name: string;
219
+ value: string;
188
220
  path?: string | undefined;
189
221
  url?: string | undefined;
190
222
  domain?: string | undefined;
@@ -197,8 +229,8 @@ export declare const SeedStorageSchema: z.ZodObject<{
197
229
  local?: Record<string, string> | undefined;
198
230
  session?: Record<string, string> | undefined;
199
231
  cookies?: Record<string, string> | {
200
- value: string;
201
232
  name: string;
233
+ value: string;
202
234
  path?: string | undefined;
203
235
  url?: string | undefined;
204
236
  domain?: string | undefined;
@@ -218,21 +250,21 @@ export declare const EVENT_PAYLOAD_SCHEMAS: {
218
250
  role: z.ZodOptional<z.ZodString>;
219
251
  name: z.ZodOptional<z.ZodString>;
220
252
  }, "strip", z.ZodTypeAny, {
221
- role?: string | undefined;
222
253
  name?: string | undefined;
223
- }, {
224
254
  role?: string | undefined;
255
+ }, {
225
256
  name?: string | undefined;
257
+ role?: string | undefined;
226
258
  }>;
227
259
  "dom.removed": z.ZodObject<{
228
260
  role: z.ZodOptional<z.ZodString>;
229
261
  name: z.ZodOptional<z.ZodString>;
230
262
  }, "strip", z.ZodTypeAny, {
231
- role?: string | undefined;
232
263
  name?: string | undefined;
233
- }, {
234
264
  role?: string | undefined;
265
+ }, {
235
266
  name?: string | undefined;
267
+ role?: string | undefined;
236
268
  }>;
237
269
  "dom.attr": z.ZodObject<{
238
270
  attr: z.ZodString;
@@ -250,11 +282,22 @@ export declare const EVENT_PAYLOAD_SCHEMAS: {
250
282
  "dom.text": z.ZodObject<{
251
283
  text: z.ZodString;
252
284
  old: z.ZodOptional<z.ZodString>;
285
+ /**
286
+ * The `data-testid` of the element or its nearest ancestor, so a text change can be named and a
287
+ * stale one (a store field changed, the text that shows it did not) can be found.
288
+ */
289
+ testid: z.ZodOptional<z.ZodString>;
290
+ /** The text an element ARRIVED with, not a change: the baseline a later change is read against. */
291
+ initial: z.ZodOptional<z.ZodBoolean>;
253
292
  }, "strip", z.ZodTypeAny, {
254
293
  text: string;
294
+ testid?: string | undefined;
295
+ initial?: boolean | undefined;
255
296
  old?: string | undefined;
256
297
  }, {
257
298
  text: string;
299
+ testid?: string | undefined;
300
+ initial?: boolean | undefined;
258
301
  old?: string | undefined;
259
302
  }>;
260
303
  "net.request": z.ZodObject<{
@@ -394,16 +437,16 @@ export declare const EVENT_PAYLOAD_SCHEMAS: {
394
437
  selector: string;
395
438
  }>>;
396
439
  }, "strip", z.ZodTypeAny, {
397
- value: number;
398
440
  at: number;
441
+ value: number;
399
442
  metric: "lcp" | "cls" | "longtask";
400
443
  shifted?: {
401
444
  ref: string;
402
445
  selector: string;
403
446
  } | undefined;
404
447
  }, {
405
- value: number;
406
448
  at: number;
449
+ value: number;
407
450
  metric: "lcp" | "cls" | "longtask";
408
451
  shifted?: {
409
452
  ref: string;
@@ -421,20 +464,24 @@ export declare const EVENT_PAYLOAD_SCHEMAS: {
421
464
  readonly REPLACE: "replace";
422
465
  readonly POP: "pop";
423
466
  }>;
467
+ /** The app's own route pattern for the screen reached (`/personas/:personaId`), when known. */
468
+ pattern: z.ZodOptional<z.ZodString>;
424
469
  }, "strip", z.ZodTypeAny, {
470
+ search: string;
425
471
  from: string;
426
472
  to: string;
427
473
  pathname: string;
428
- how: "pop" | "push" | "replace";
429
- search: string;
474
+ how: "replace" | "pop" | "push";
430
475
  hash: string;
476
+ pattern?: string | undefined;
431
477
  }, {
478
+ search: string;
432
479
  from: string;
433
480
  to: string;
434
481
  pathname: string;
435
- how: "pop" | "push" | "replace";
436
- search: string;
482
+ how: "replace" | "pop" | "push";
437
483
  hash: string;
484
+ pattern?: string | undefined;
438
485
  }>;
439
486
  "console.log": z.ZodObject<{
440
487
  message: z.ZodString;
@@ -491,11 +538,11 @@ export declare const EVENT_PAYLOAD_SCHEMAS: {
491
538
  role: z.ZodOptional<z.ZodString>;
492
539
  name: z.ZodOptional<z.ZodString>;
493
540
  }, "strip", z.ZodTypeAny, {
494
- role?: string | undefined;
495
541
  name?: string | undefined;
496
- }, {
497
542
  role?: string | undefined;
543
+ }, {
498
544
  name?: string | undefined;
545
+ role?: string | undefined;
499
546
  }>;
500
547
  "anim.start": z.ZodObject<{
501
548
  name: z.ZodString;
@@ -757,32 +804,36 @@ export declare const EVENT_PAYLOAD_SCHEMAS: {
757
804
  to?: string | undefined;
758
805
  }>;
759
806
  "field.change": z.ZodObject<{
760
- /** What an assertion would call this field: its testid, else its name, else its accessible name. */
761
807
  field: z.ZodString;
762
- /** `input` is a settled burst of keystrokes; `change` is the commit that ends one. */
763
- kind: z.ZodEnum<["input", "change"]>;
764
- /**
765
- * The length of the REAL value, never of the clipped one, and present even when redacted.
766
- *
767
- * "It was wiped" is the assertion this event exists for, and a length says it while carrying
768
- * nobody's password. A cap that shortened this would read exactly like the wipe.
769
- */
808
+ kind: z.ZodNativeEnum<{
809
+ readonly INPUT: "input";
810
+ readonly CHANGE: "change";
811
+ readonly SETTLED: "settled";
812
+ }>;
770
813
  length: z.ZodNumber;
771
- /** Omitted for a password, a sensitive field name, or a payment autocomplete hint. */
772
814
  value: z.ZodOptional<z.ZodString>;
773
815
  redacted: z.ZodOptional<z.ZodLiteral<true>>;
816
+ checked: z.ZodOptional<z.ZodBoolean>;
817
+ previous: z.ZodOptional<z.ZodString>;
818
+ previousChecked: z.ZodOptional<z.ZodBoolean>;
774
819
  }, "strip", z.ZodTypeAny, {
775
- kind: "input" | "change";
776
820
  length: number;
821
+ kind: "settled" | "input" | "change";
777
822
  field: string;
823
+ checked?: boolean | undefined;
778
824
  value?: string | undefined;
779
825
  redacted?: true | undefined;
826
+ previous?: string | undefined;
827
+ previousChecked?: boolean | undefined;
780
828
  }, {
781
- kind: "input" | "change";
782
829
  length: number;
830
+ kind: "settled" | "input" | "change";
783
831
  field: string;
832
+ checked?: boolean | undefined;
784
833
  value?: string | undefined;
785
834
  redacted?: true | undefined;
835
+ previous?: string | undefined;
836
+ previousChecked?: boolean | undefined;
786
837
  }>;
787
838
  "flow.recorded": z.ZodObject<{
788
839
  name: z.ZodString;
@@ -805,11 +856,11 @@ export declare const EVENT_PAYLOAD_SCHEMAS: {
805
856
  channel: z.ZodString;
806
857
  dropped: z.ZodNumber;
807
858
  }, "strip", z.ZodTypeAny, {
808
- dropped: number;
809
859
  channel: string;
810
- }, {
811
860
  dropped: number;
861
+ }, {
812
862
  channel: string;
863
+ dropped: number;
813
864
  }>;
814
865
  "blind-spot": z.ZodObject<{
815
866
  kind: z.ZodNativeEnum<{
@@ -881,10 +932,10 @@ export declare const EVENT_PAYLOAD_SCHEMAS: {
881
932
  }>;
882
933
  text: z.ZodOptional<z.ZodString>;
883
934
  }, "strip", z.ZodTypeAny, {
884
- kind: "message" | "harness" | "pause" | "resume" | "end" | "replay" | "sync" | "signin" | "harness-run" | "harness-stop" | "harness-link";
935
+ kind: "pause" | "message" | "harness" | "resume" | "end" | "replay" | "sync" | "signin" | "harness-run" | "harness-stop" | "harness-link";
885
936
  text?: string | undefined;
886
937
  }, {
887
- kind: "message" | "harness" | "pause" | "resume" | "end" | "replay" | "sync" | "signin" | "harness-run" | "harness-stop" | "harness-link";
938
+ kind: "pause" | "message" | "harness" | "resume" | "end" | "replay" | "sync" | "signin" | "harness-run" | "harness-stop" | "harness-link";
888
939
  text?: string | undefined;
889
940
  }>;
890
941
  "human.mark": z.ZodObject<{
@@ -971,6 +1022,69 @@ export declare const EVENT_PAYLOAD_SCHEMAS: {
971
1022
  slide?: string | undefined;
972
1023
  prompt?: "harness" | "rail" | "header" | undefined;
973
1024
  }>;
1025
+ "media.state": z.ZodObject<{
1026
+ event: z.ZodNativeEnum<{
1027
+ readonly PLAY: "play";
1028
+ readonly PLAYING: "playing";
1029
+ readonly PAUSE: "pause";
1030
+ readonly SEEKED: "seeked";
1031
+ readonly ENDED: "ended";
1032
+ readonly LOADED_DATA: "loadeddata";
1033
+ readonly CAN_PLAY: "canplay";
1034
+ readonly WAITING: "waiting";
1035
+ readonly ERROR: "error";
1036
+ }>;
1037
+ tag: z.ZodEnum<["video", "audio"]>;
1038
+ /** Seconds into the media, as the element reports it. */
1039
+ currentTime: z.ZodNumber;
1040
+ /** Absent while unknown (NaN) or endless (a live stream). */
1041
+ duration: z.ZodOptional<z.ZodNumber>;
1042
+ /** HTMLMediaElement.readyState, 0–4. */
1043
+ readyState: z.ZodNumber;
1044
+ paused: z.ZodBoolean;
1045
+ }, "strip", z.ZodTypeAny, {
1046
+ event: "error" | "play" | "playing" | "pause" | "seeked" | "ended" | "loadeddata" | "canplay" | "waiting";
1047
+ paused: boolean;
1048
+ tag: "video" | "audio";
1049
+ currentTime: number;
1050
+ readyState: number;
1051
+ duration?: number | undefined;
1052
+ }, {
1053
+ event: "error" | "play" | "playing" | "pause" | "seeked" | "ended" | "loadeddata" | "canplay" | "waiting";
1054
+ paused: boolean;
1055
+ tag: "video" | "audio";
1056
+ currentTime: number;
1057
+ readyState: number;
1058
+ duration?: number | undefined;
1059
+ }>;
1060
+ "canvas.digest": z.ZodObject<{
1061
+ /** A hash of a 16x16 sample of the canvas pixels: changes when what it shows changes. */
1062
+ digest: z.ZodString;
1063
+ width: z.ZodNumber;
1064
+ height: z.ZodNumber;
1065
+ /** The sample's mean colour, `[r, g, b]` 0–255: a coarse "what colour is it" a reader can check. */
1066
+ mean: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
1067
+ /**
1068
+ * `act` when an act's end took it, inside the act's window and sent even if nothing changed;
1069
+ * `poll` when the timer did. Absent from an SDK older than the field.
1070
+ */
1071
+ trigger: z.ZodOptional<z.ZodNativeEnum<{
1072
+ readonly POLL: "poll";
1073
+ readonly ACT: "act";
1074
+ }>>;
1075
+ }, "strip", z.ZodTypeAny, {
1076
+ width: number;
1077
+ height: number;
1078
+ digest: string;
1079
+ mean: [number, number, number];
1080
+ trigger?: "act" | "poll" | undefined;
1081
+ }, {
1082
+ width: number;
1083
+ height: number;
1084
+ digest: string;
1085
+ mean: [number, number, number];
1086
+ trigger?: "act" | "poll" | undefined;
1087
+ }>;
974
1088
  };
975
1089
  /** Narrow an event's `data` against its type's payload schema. Unknown in, typed-or-error out. */
976
1090
  export declare function parseEventPayload(type: EventType, data: unknown): z.SafeParseReturnType<unknown, unknown>;
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { EventType, PerfMetric } from './constants/constants.js';
2
+ import { CanvasTrigger, EventType, MediaEvent, PerfMetric } from './constants/constants.js';
3
3
  import { BlindSpotKind } from '../verdict/verified-constants.js';
4
4
  import { BrowserBrand } from '../telemetry-feedback.js';
5
5
  import { HudUseDataSchema, HumanControlDataSchema, HumanMarkDataSchema } from './messages.js';
@@ -49,6 +49,37 @@ export const RouteChangeHow = {
49
49
  };
50
50
  /** Wire field on `route.change` carrying a `RouteChangeHow`. */
51
51
  export const ROUTE_CHANGE_HOW_FIELD = 'how';
52
+ /**
53
+ * Why a `field.change` was emitted.
54
+ *
55
+ * `input` is a burst of keystrokes and `change` is the commit that ends one — both are the user's
56
+ * own event, fired before a controlled component restores its DOM property. `settled` is a read of
57
+ * that property on the frame after the handlers ran. Only a settled read that differs from the
58
+ * pre-action value is evidence the screen moved.
59
+ */
60
+ export const FieldChangeKind = {
61
+ INPUT: 'input',
62
+ CHANGE: 'change',
63
+ SETTLED: 'settled',
64
+ };
65
+ /**
66
+ * Wire fields on `field.change` beyond `field` / `kind` / `value` / `length`.
67
+ *
68
+ * `checked` is the property a checkbox or radio actually renders; `value` on those is the HTML
69
+ * value (`"on"`), which does not move when the box is toggled. `previous` and `previousChecked`
70
+ * are the same reading from before the action, present on a settled event so a consumer can tell
71
+ * a render from a restore.
72
+ */
73
+ export const FieldChangeField = {
74
+ FIELD: 'field',
75
+ KIND: 'kind',
76
+ LENGTH: 'length',
77
+ VALUE: 'value',
78
+ REDACTED: 'redacted',
79
+ CHECKED: 'checked',
80
+ PREVIOUS: 'previous',
81
+ PREVIOUS_CHECKED: 'previousChecked',
82
+ };
52
83
  /**
53
84
  * The three readable client-side storage areas.
54
85
  *
@@ -144,7 +175,17 @@ export const EVENT_PAYLOAD_SCHEMAS = {
144
175
  [EventType.DOM_ATTR]: z
145
176
  .object({ attr: z.string(), value: z.string().optional(), old: z.string().optional() })
146
177
  .passthrough(),
147
- [EventType.DOM_TEXT]: z.object({ text: z.string(), old: z.string().optional() }),
178
+ [EventType.DOM_TEXT]: z.object({
179
+ text: z.string(),
180
+ old: z.string().optional(),
181
+ /**
182
+ * The `data-testid` of the element or its nearest ancestor, so a text change can be named and a
183
+ * stale one (a store field changed, the text that shows it did not) can be found.
184
+ */
185
+ testid: z.string().optional(),
186
+ /** The text an element ARRIVED with, not a change: the baseline a later change is read against. */
187
+ initial: z.boolean().optional(),
188
+ }),
148
189
  [EventType.NET_REQUEST]: netRequestSchema,
149
190
  [EventType.NET_PENDING]: z.object({
150
191
  id: z.string(),
@@ -169,6 +210,8 @@ export const EVENT_PAYLOAD_SCHEMAS = {
169
210
  search: z.string(),
170
211
  hash: z.string(),
171
212
  [ROUTE_CHANGE_HOW_FIELD]: z.nativeEnum(RouteChangeHow),
213
+ /** The app's own route pattern for the screen reached (`/personas/:personaId`), when known. */
214
+ pattern: z.string().optional(),
172
215
  }),
173
216
  [EventType.CONSOLE_LOG]: consoleSchema,
174
217
  [EventType.CONSOLE_WARN]: consoleSchema,
@@ -255,21 +298,21 @@ export const EVENT_PAYLOAD_SCHEMAS = {
255
298
  from: z.string().optional(),
256
299
  toBody: z.boolean(),
257
300
  }),
301
+ // Keys are FieldChangeField so the wire names exist once. `kind` is FieldChangeKind:
302
+ // input/change are the user's event; settled is the post-handler read. `length` is the REAL
303
+ // value's length, never the clipped one, and present even when redacted — a cap must never read
304
+ // as a wipe. `value` is omitted for a password, a sensitive name, or a payment autocomplete hint.
305
+ // `checked` is the checkbox/radio property (`value` there does not move). `previous` /
306
+ // `previousChecked` ride on a settled read so a restore is distinguishable from a render.
258
307
  [EventType.FIELD_CHANGE]: z.object({
259
- /** What an assertion would call this field: its testid, else its name, else its accessible name. */
260
- field: z.string(),
261
- /** `input` is a settled burst of keystrokes; `change` is the commit that ends one. */
262
- kind: z.enum(['input', 'change']),
263
- /**
264
- * The length of the REAL value, never of the clipped one, and present even when redacted.
265
- *
266
- * "It was wiped" is the assertion this event exists for, and a length says it while carrying
267
- * nobody's password. A cap that shortened this would read exactly like the wipe.
268
- */
269
- length: z.number().int().nonnegative(),
270
- /** Omitted for a password, a sensitive field name, or a payment autocomplete hint. */
271
- value: z.string().optional(),
272
- redacted: z.literal(true).optional(),
308
+ [FieldChangeField.FIELD]: z.string(),
309
+ [FieldChangeField.KIND]: z.nativeEnum(FieldChangeKind),
310
+ [FieldChangeField.LENGTH]: z.number().int().nonnegative(),
311
+ [FieldChangeField.VALUE]: z.string().optional(),
312
+ [FieldChangeField.REDACTED]: z.literal(true).optional(),
313
+ [FieldChangeField.CHECKED]: z.boolean().optional(),
314
+ [FieldChangeField.PREVIOUS]: z.string().optional(),
315
+ [FieldChangeField.PREVIOUS_CHECKED]: z.boolean().optional(),
273
316
  }),
274
317
  [EventType.FLOW_RECORDED]: z.object({ name: z.string(), flow: z.unknown() }),
275
318
  [EventType.TRANSPORT_OVERFLOW]: z.object({ dropped: z.number() }),
@@ -294,6 +337,30 @@ export const EVENT_PAYLOAD_SCHEMAS = {
294
337
  [EventType.HUMAN_CONTROL]: HumanControlDataSchema,
295
338
  [EventType.HUMAN_MARK]: HumanMarkDataSchema,
296
339
  [EventType.HUD_USED]: HudUseDataSchema,
340
+ [EventType.MEDIA_STATE]: z.object({
341
+ event: z.nativeEnum(MediaEvent),
342
+ tag: z.enum(['video', 'audio']),
343
+ /** Seconds into the media, as the element reports it. */
344
+ currentTime: z.number(),
345
+ /** Absent while unknown (NaN) or endless (a live stream). */
346
+ duration: z.number().optional(),
347
+ /** HTMLMediaElement.readyState, 0–4. */
348
+ readyState: z.number().int().min(0).max(4),
349
+ paused: z.boolean(),
350
+ }),
351
+ [EventType.CANVAS_DIGEST]: z.object({
352
+ /** A hash of a 16x16 sample of the canvas pixels: changes when what it shows changes. */
353
+ digest: z.string(),
354
+ width: z.number().int().nonnegative(),
355
+ height: z.number().int().nonnegative(),
356
+ /** The sample's mean colour, `[r, g, b]` 0–255: a coarse "what colour is it" a reader can check. */
357
+ mean: z.tuple([z.number(), z.number(), z.number()]),
358
+ /**
359
+ * `act` when an act's end took it, inside the act's window and sent even if nothing changed;
360
+ * `poll` when the timer did. Absent from an SDK older than the field.
361
+ */
362
+ trigger: z.nativeEnum(CanvasTrigger).optional(),
363
+ }),
297
364
  };
298
365
  /** Narrow an event's `data` against its type's payload schema. Unknown in, typed-or-error out. */
299
366
  export function parseEventPayload(type, data) {