@reticlehq/core 3.2.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 (77) hide show
  1. package/dist/artifacts/flow-composition.d.ts +3 -2
  2. package/dist/artifacts/flow-constants.d.ts +49 -2
  3. package/dist/artifacts/flow-constants.js +49 -2
  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 +1074 -1228
  10. package/dist/artifacts/flow-types.js +96 -140
  11. package/dist/artifacts/impact.d.ts +48 -20
  12. package/dist/artifacts/impact.js +11 -0
  13. package/dist/artifacts/journal.d.ts +33 -6
  14. package/dist/artifacts/journal.js +13 -0
  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/source-constants.d.ts +11 -0
  19. package/dist/identity/source-constants.js +11 -0
  20. package/dist/index.d.ts +8 -0
  21. package/dist/index.js +24 -1
  22. package/dist/onboarding.d.ts +2 -2
  23. package/dist/realm/registry.d.ts +0 -8
  24. package/dist/realm/registry.js +1 -11
  25. package/dist/schema/event-message.json +3 -1
  26. package/dist/schema/event-payloads.json +69 -0
  27. package/dist/schema/event-type.json +3 -1
  28. package/dist/schema/reticle-event.json +3 -1
  29. package/dist/schema/reticle-message.json +3 -1
  30. package/dist/source-constants.cjs +1 -0
  31. package/dist/source-constants.d.cts +1 -0
  32. package/dist/telemetry-feedback.d.ts +6 -6
  33. package/dist/telemetry-refusal.d.ts +2 -2
  34. package/dist/telemetry-session.d.ts +25 -2
  35. package/dist/telemetry-session.js +13 -0
  36. package/dist/telemetry.d.ts +121 -94
  37. package/dist/verdict/consequence.d.ts +10 -0
  38. package/dist/verdict/consequence.js +13 -0
  39. package/dist/verdict/intent.d.ts +36 -12
  40. package/dist/verdict/intent.js +66 -10
  41. package/dist/verdict/predicate-tree.d.ts +47 -0
  42. package/dist/verdict/predicate-tree.js +146 -0
  43. package/dist/verdict/predicate.d.ts +129 -0
  44. package/dist/verdict/predicate.js +394 -0
  45. package/dist/verdict/property-assertion.d.ts +191 -0
  46. package/dist/verdict/property-assertion.js +42 -0
  47. package/dist/verdict/security.js +16 -4
  48. package/dist/verdict/verdict-attribution.d.ts +52 -0
  49. package/dist/verdict/verdict-attribution.js +87 -0
  50. package/dist/verdict/verification-run.d.ts +98 -84
  51. package/dist/verdict/verification-run.js +8 -1
  52. package/dist/verdict/verified-constants.d.ts +9 -0
  53. package/dist/verdict/verified-constants.js +9 -0
  54. package/dist/wire/constants/constants.d.ts +20 -98
  55. package/dist/wire/constants/constants.js +22 -97
  56. package/dist/wire/constants/discovery.d.ts +25 -0
  57. package/dist/wire/constants/discovery.js +25 -0
  58. package/dist/wire/constants/event-types.d.ts +122 -0
  59. package/dist/wire/constants/event-types.js +121 -0
  60. package/dist/wire/constants/hud-controls.d.ts +19 -0
  61. package/dist/wire/constants/hud-controls.js +95 -0
  62. package/dist/wire/constants/hud-use.d.ts +27 -0
  63. package/dist/wire/constants/hud-use.js +24 -0
  64. package/dist/wire/constants/session-constants.d.ts +10 -0
  65. package/dist/wire/constants/session-constants.js +10 -0
  66. package/dist/wire/event-payloads.d.ts +66 -10
  67. package/dist/wire/event-payloads.js +18 -1
  68. package/dist/wire/messages.d.ts +89 -48
  69. package/dist/wire/messages.js +17 -0
  70. package/dist/wire/net.d.ts +18 -0
  71. package/dist/wire/net.js +24 -0
  72. package/dist/wire/state-select.d.ts +2 -1
  73. package/dist/wire/state-select.js +56 -3
  74. package/dist/wire/toon.js +28 -7
  75. package/dist/wire/types.d.ts +91 -66
  76. package/dist/wire/types.js +23 -1
  77. package/package.json +5 -1
@@ -0,0 +1,19 @@
1
+ /**
2
+ * What a person did with the in-page HUD, as names only.
3
+ *
4
+ * The HUD is where a human meets Reticle, and nothing measured it: which controls get used, which
5
+ * panel is open, whether the HUD spends its life as a bubble or open, which settings get changed.
6
+ * Every id is the name of a control Reticle rendered, never text from the page, a flow name or a
7
+ * URL: the telemetry contract's "names, never values". A control whose id is not listed here is
8
+ * dropped at the daemon rather than counted, so a new control cannot leak free text by accident;
9
+ * the browser test that walks the rendered HUD fails if any control has no id in this list.
10
+ */
11
+ /** The attributes whose value is part of the id. Read by the browser to build one. */
12
+ export declare const HUD_KEYED_ATTRS: readonly ["setting", "check", "settings-cycle", "theme", "tour-target", "link"];
13
+ /**
14
+ * Is this a control id the HUD renders?
15
+ *
16
+ * The set is built on first use rather than at module scope: core's root entry is on every page
17
+ * load, and a Set constructed at the top of a module is a side effect no bundler can drop.
18
+ */
19
+ export declare function isHudControl(id: string): boolean;
@@ -0,0 +1,95 @@
1
+ /**
2
+ * What a person did with the in-page HUD, as names only.
3
+ *
4
+ * The HUD is where a human meets Reticle, and nothing measured it: which controls get used, which
5
+ * panel is open, whether the HUD spends its life as a bubble or open, which settings get changed.
6
+ * Every id is the name of a control Reticle rendered, never text from the page, a flow name or a
7
+ * URL: the telemetry contract's "names, never values". A control whose id is not listed here is
8
+ * dropped at the daemon rather than counted, so a new control cannot leak free text by accident;
9
+ * the browser test that walks the rendered HUD fails if any control has no id in this list.
10
+ */
11
+ /** Controls whose id is the attribute name alone (`data-reticle-pause` -> `pause`). */
12
+ const PLAIN_CONTROLS = [
13
+ 'fab',
14
+ 'pause',
15
+ 'chat-toggle',
16
+ 'markers-btn',
17
+ 'end',
18
+ 'clear-marks',
19
+ 'copy-marks',
20
+ 'copy',
21
+ 'export',
22
+ 'annotate-btn',
23
+ 'report-btn',
24
+ 'settings-btn',
25
+ 'min-btn',
26
+ 'chat-min',
27
+ 'chat-pill',
28
+ 'replay',
29
+ 'carousel-dot',
30
+ 'carousel-close',
31
+ 'offer-claim',
32
+ 'talk-book',
33
+ 'account-signin',
34
+ 'account-trigger',
35
+ 'account-signout',
36
+ 'account-dashboard',
37
+ 'sync-now',
38
+ 'report-scope',
39
+ 'report-close',
40
+ 'share-x',
41
+ 'share-in',
42
+ 'share-copy',
43
+ 'refer',
44
+ 'settings-close',
45
+ 'settings-help',
46
+ 'settings-reset',
47
+ 'settings-mcp',
48
+ 'feedback-email',
49
+ 'feedback-call',
50
+ 'workspace-btn',
51
+ 'workspace-copy',
52
+ 'mark-cancel',
53
+ 'mark-send',
54
+ ];
55
+ /** The attributes whose value is part of the id. Read by the browser to build one. */
56
+ export const HUD_KEYED_ATTRS = [
57
+ 'setting',
58
+ 'check',
59
+ 'settings-cycle',
60
+ 'theme',
61
+ 'tour-target',
62
+ 'link',
63
+ ];
64
+ /** Controls whose id also carries a key Reticle authored (`data-reticle-setting="x"` -> `setting.x`). */
65
+ const KEYED_CONTROLS = {
66
+ setting: [
67
+ 'autoOpenChat',
68
+ 'showTimestamps',
69
+ 'showTally',
70
+ 'reactComponents',
71
+ 'hideUntilRestart',
72
+ 'harnessEnabled',
73
+ 'reduceMotion',
74
+ 'ambientGlow',
75
+ ],
76
+ check: ['blockPageInteractions', 'clearOnCopy'],
77
+ 'settings-cycle': ['outputDetail'],
78
+ theme: ['signal', 'traffic', 'mono', 'neon', 'ember'],
79
+ 'tour-target': ['copy', 'back', 'done', 'next', 'skip'],
80
+ link: ['docs', 'github', 'site', 'discord', 'defect', 'dashboard'],
81
+ };
82
+ let controls;
83
+ /**
84
+ * Is this a control id the HUD renders?
85
+ *
86
+ * The set is built on first use rather than at module scope: core's root entry is on every page
87
+ * load, and a Set constructed at the top of a module is a side effect no bundler can drop.
88
+ */
89
+ export function isHudControl(id) {
90
+ controls ??= new Set([
91
+ ...PLAIN_CONTROLS,
92
+ ...Object.entries(KEYED_CONTROLS).flatMap(([attr, keys]) => keys.map((k) => `${attr}.${k}`)),
93
+ ]);
94
+ return controls.has(id);
95
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Where the in-page HUD sits and what was switched, for HUD_USED events.
3
+ *
4
+ * Kept apart from the control list in `hud-controls.ts`: the wire schema needs these small enums on
5
+ * every page load, and the list is only needed by the HUD itself and by the daemon that counts it.
6
+ */
7
+ /** How the HUD sits on the page: the round bubble, the bare toolbar, or open on a panel. */
8
+ export declare const HudView: {
9
+ readonly BUBBLE: "bubble";
10
+ readonly COLLAPSED: "collapsed";
11
+ readonly EXPANDED: "expanded";
12
+ };
13
+ export type HudView = (typeof HudView)[keyof typeof HudView];
14
+ /** Which panel is showing, when the HUD is open. */
15
+ export declare const HudPanel: {
16
+ readonly CHAT: "chat";
17
+ readonly SETTINGS: "settings";
18
+ readonly REPORT: "report";
19
+ readonly NONE: "none";
20
+ };
21
+ export type HudPanel = (typeof HudPanel)[keyof typeof HudPanel];
22
+ /** What a toggle was switched to; absent for a plain press. */
23
+ export declare const HudToggle: {
24
+ readonly ON: "on";
25
+ readonly OFF: "off";
26
+ };
27
+ export type HudToggle = (typeof HudToggle)[keyof typeof HudToggle];
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Where the in-page HUD sits and what was switched, for HUD_USED events.
3
+ *
4
+ * Kept apart from the control list in `hud-controls.ts`: the wire schema needs these small enums on
5
+ * every page load, and the list is only needed by the HUD itself and by the daemon that counts it.
6
+ */
7
+ /** How the HUD sits on the page: the round bubble, the bare toolbar, or open on a panel. */
8
+ export const HudView = {
9
+ BUBBLE: 'bubble',
10
+ COLLAPSED: 'collapsed',
11
+ EXPANDED: 'expanded',
12
+ };
13
+ /** Which panel is showing, when the HUD is open. */
14
+ export const HudPanel = {
15
+ CHAT: 'chat',
16
+ SETTINGS: 'settings',
17
+ REPORT: 'report',
18
+ NONE: 'none',
19
+ };
20
+ /** What a toggle was switched to; absent for a plain press. */
21
+ export const HudToggle = {
22
+ ON: 'on',
23
+ OFF: 'off',
24
+ };
@@ -81,6 +81,16 @@ export declare const SESSION_HEALTH: {
81
81
  readonly HEARTBEAT_MS: 5000;
82
82
  /** lastSeenMs beyond this ⇒ throttled (≈ 2 missed heartbeats). */
83
83
  readonly STALE_THRESHOLD_MS: 12000;
84
+ /**
85
+ * Fraction of the event ledger's cap past which its size is reported on the health block.
86
+ *
87
+ * A quarter, not a near-miss threshold. The point is to be visible while there is still room to
88
+ * act: a ledger reported only at 90% of its cap tells an agent about a problem it can no longer
89
+ * do anything about, and the case this exists for (a repeating error writing as fast as it can) crosses
90
+ * the last tenth in minutes. Below a quarter the field is absent, so a healthy session carries
91
+ * nothing.
92
+ */
93
+ readonly LEDGER_NOTICE_FRACTION: 0.25;
84
94
  };
85
95
  /**
86
96
  * Server-authoritative session liveness. The browser-side idle timer is throttled in a backgrounded
@@ -79,6 +79,16 @@ export const SESSION_HEALTH = {
79
79
  HEARTBEAT_MS: 5_000,
80
80
  /** lastSeenMs beyond this ⇒ throttled (≈ 2 missed heartbeats). */
81
81
  STALE_THRESHOLD_MS: 12_000,
82
+ /**
83
+ * Fraction of the event ledger's cap past which its size is reported on the health block.
84
+ *
85
+ * A quarter, not a near-miss threshold. The point is to be visible while there is still room to
86
+ * act: a ledger reported only at 90% of its cap tells an agent about a problem it can no longer
87
+ * do anything about, and the case this exists for (a repeating error writing as fast as it can) crosses
88
+ * the last tenth in minutes. Below a quarter the field is absent, so a healthy session carries
89
+ * nothing.
90
+ */
91
+ LEDGER_NOTICE_FRACTION: 0.25,
82
92
  };
83
93
  /**
84
94
  * Server-authoritative session liveness. The browser-side idle timer is throttled in a backgrounded
@@ -378,15 +378,15 @@ export declare const EVENT_PAYLOAD_SCHEMAS: {
378
378
  search: z.ZodString;
379
379
  hash: z.ZodString;
380
380
  }, "strip", z.ZodTypeAny, {
381
- pathname: string;
382
381
  from: string;
383
382
  to: string;
383
+ pathname: string;
384
384
  search: string;
385
385
  hash: string;
386
386
  }, {
387
- pathname: string;
388
387
  from: string;
389
388
  to: string;
389
+ pathname: string;
390
390
  search: string;
391
391
  hash: string;
392
392
  }>;
@@ -474,15 +474,15 @@ export declare const EVENT_PAYLOAD_SCHEMAS: {
474
474
  readonly DOWN: "down";
475
475
  }>;
476
476
  }, "strip", z.ZodTypeAny, {
477
+ percent: number;
477
478
  direction: "up" | "down";
478
479
  x: number;
479
480
  y: number;
480
- percent: number;
481
481
  }, {
482
+ percent: number;
482
483
  direction: "up" | "down";
483
484
  x: number;
484
485
  y: number;
485
- percent: number;
486
486
  }>;
487
487
  "reveal.shown": z.ZodObject<{
488
488
  role: z.ZodOptional<z.ZodString>;
@@ -698,6 +698,34 @@ export declare const EVENT_PAYLOAD_SCHEMAS: {
698
698
  from?: string | undefined;
699
699
  to?: string | undefined;
700
700
  }>;
701
+ "field.change": z.ZodObject<{
702
+ /** What an assertion would call this field: its testid, else its name, else its accessible name. */
703
+ field: z.ZodString;
704
+ /** `input` is a settled burst of keystrokes; `change` is the commit that ends one. */
705
+ kind: z.ZodEnum<["input", "change"]>;
706
+ /**
707
+ * The length of the REAL value, never of the clipped one, and present even when redacted.
708
+ *
709
+ * "It was wiped" is the assertion this event exists for, and a length says it while carrying
710
+ * nobody's password. A cap that shortened this would read exactly like the wipe.
711
+ */
712
+ length: z.ZodNumber;
713
+ /** Omitted for a password, a sensitive field name, or a payment autocomplete hint. */
714
+ value: z.ZodOptional<z.ZodString>;
715
+ redacted: z.ZodOptional<z.ZodLiteral<true>>;
716
+ }, "strip", z.ZodTypeAny, {
717
+ length: number;
718
+ kind: "input" | "change";
719
+ field: string;
720
+ value?: string | undefined;
721
+ redacted?: true | undefined;
722
+ }, {
723
+ length: number;
724
+ kind: "input" | "change";
725
+ field: string;
726
+ value?: string | undefined;
727
+ redacted?: true | undefined;
728
+ }>;
701
729
  "flow.recorded": z.ZodObject<{
702
730
  name: z.ZodString;
703
731
  flow: z.ZodUnknown;
@@ -791,10 +819,10 @@ export declare const EVENT_PAYLOAD_SCHEMAS: {
791
819
  }>;
792
820
  text: z.ZodOptional<z.ZodString>;
793
821
  }, "strip", z.ZodTypeAny, {
794
- kind: "message" | "pause" | "resume" | "end" | "replay" | "sync" | "harness";
822
+ kind: "message" | "harness" | "pause" | "resume" | "end" | "replay" | "sync";
795
823
  text?: string | undefined;
796
824
  }, {
797
- kind: "message" | "pause" | "resume" | "end" | "replay" | "sync" | "harness";
825
+ kind: "message" | "harness" | "pause" | "resume" | "end" | "replay" | "sync";
798
826
  text?: string | undefined;
799
827
  }>;
800
828
  "human.mark": z.ZodObject<{
@@ -819,9 +847,9 @@ export declare const EVENT_PAYLOAD_SCHEMAS: {
819
847
  }>>;
820
848
  route: z.ZodOptional<z.ZodString>;
821
849
  }, "strip", z.ZodTypeAny, {
822
- anchor: string;
823
850
  note: string;
824
- strategy: "role" | "testid" | "component" | "position";
851
+ anchor: string;
852
+ strategy: "testid" | "role" | "component" | "position";
825
853
  label?: string | undefined;
826
854
  route?: string | undefined;
827
855
  source?: {
@@ -829,9 +857,9 @@ export declare const EVENT_PAYLOAD_SCHEMAS: {
829
857
  line: number;
830
858
  } | undefined;
831
859
  }, {
832
- anchor: string;
833
860
  note: string;
834
- strategy: "role" | "testid" | "component" | "position";
861
+ anchor: string;
862
+ strategy: "testid" | "role" | "component" | "position";
835
863
  label?: string | undefined;
836
864
  route?: string | undefined;
837
865
  source?: {
@@ -839,6 +867,34 @@ export declare const EVENT_PAYLOAD_SCHEMAS: {
839
867
  line: number;
840
868
  } | undefined;
841
869
  }>;
870
+ "hud.used": z.ZodObject<{
871
+ control: z.ZodOptional<z.ZodString>;
872
+ toggle: z.ZodOptional<z.ZodNativeEnum<{
873
+ readonly ON: "on";
874
+ readonly OFF: "off";
875
+ }>>;
876
+ view: z.ZodOptional<z.ZodNativeEnum<{
877
+ readonly BUBBLE: "bubble";
878
+ readonly COLLAPSED: "collapsed";
879
+ readonly EXPANDED: "expanded";
880
+ }>>;
881
+ panel: z.ZodOptional<z.ZodNativeEnum<{
882
+ readonly CHAT: "chat";
883
+ readonly SETTINGS: "settings";
884
+ readonly REPORT: "report";
885
+ readonly NONE: "none";
886
+ }>>;
887
+ }, "strip", z.ZodTypeAny, {
888
+ control?: string | undefined;
889
+ toggle?: "on" | "off" | undefined;
890
+ view?: "expanded" | "bubble" | "collapsed" | undefined;
891
+ panel?: "none" | "chat" | "settings" | "report" | undefined;
892
+ }, {
893
+ control?: string | undefined;
894
+ toggle?: "on" | "off" | undefined;
895
+ view?: "expanded" | "bubble" | "collapsed" | undefined;
896
+ panel?: "none" | "chat" | "settings" | "report" | undefined;
897
+ }>;
842
898
  };
843
899
  /** Narrow an event's `data` against its type's payload schema. Unknown in, typed-or-error out. */
844
900
  export declare function parseEventPayload(type: EventType, data: unknown): z.SafeParseReturnType<unknown, unknown>;
@@ -2,7 +2,7 @@ import { z } from 'zod';
2
2
  import { EventType, PerfMetric } from './constants/constants.js';
3
3
  import { BlindSpotKind } from '../verdict/verified-constants.js';
4
4
  import { BrowserBrand } from '../telemetry-feedback.js';
5
- import { HumanControlDataSchema, HumanMarkDataSchema } from './messages.js';
5
+ import { HudUseDataSchema, HumanControlDataSchema, HumanMarkDataSchema } from './messages.js';
6
6
  import { REQUEST_SHAPE_FIELD } from './net.js';
7
7
  /**
8
8
  * Per-event-type payload schemas — the typed replacement for the envelope's open `data` record.
@@ -223,6 +223,22 @@ export const EVENT_PAYLOAD_SCHEMAS = {
223
223
  from: z.string().optional(),
224
224
  toBody: z.boolean(),
225
225
  }),
226
+ [EventType.FIELD_CHANGE]: z.object({
227
+ /** What an assertion would call this field: its testid, else its name, else its accessible name. */
228
+ field: z.string(),
229
+ /** `input` is a settled burst of keystrokes; `change` is the commit that ends one. */
230
+ kind: z.enum(['input', 'change']),
231
+ /**
232
+ * The length of the REAL value, never of the clipped one, and present even when redacted.
233
+ *
234
+ * "It was wiped" is the assertion this event exists for, and a length says it while carrying
235
+ * nobody's password. A cap that shortened this would read exactly like the wipe.
236
+ */
237
+ length: z.number().int().nonnegative(),
238
+ /** Omitted for a password, a sensitive field name, or a payment autocomplete hint. */
239
+ value: z.string().optional(),
240
+ redacted: z.literal(true).optional(),
241
+ }),
226
242
  [EventType.FLOW_RECORDED]: z.object({ name: z.string(), flow: z.unknown() }),
227
243
  [EventType.TRANSPORT_OVERFLOW]: z.object({ dropped: z.number() }),
228
244
  [EventType.TRUNCATED]: z.object({ channel: z.string(), dropped: z.number() }),
@@ -245,6 +261,7 @@ export const EVENT_PAYLOAD_SCHEMAS = {
245
261
  .passthrough(),
246
262
  [EventType.HUMAN_CONTROL]: HumanControlDataSchema,
247
263
  [EventType.HUMAN_MARK]: HumanMarkDataSchema,
264
+ [EventType.HUD_USED]: HudUseDataSchema,
248
265
  };
249
266
  /** Narrow an event's `data` against its type's payload schema. Unknown in, typed-or-error out. */
250
267
  export function parseEventPayload(type, data) {