@reticlehq/core 2.3.0 → 2.5.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 (45) hide show
  1. package/dist/consequence.d.ts +27 -0
  2. package/dist/consequence.js +26 -0
  3. package/dist/constants.d.ts +52 -8
  4. package/dist/constants.js +49 -8
  5. package/dist/contract-fingerprint.d.ts +29 -0
  6. package/dist/contract-fingerprint.js +56 -0
  7. package/dist/daemon-registry.js +1 -1
  8. package/dist/event-payloads.d.ts +50 -2
  9. package/dist/event-payloads.js +12 -1
  10. package/dist/flow-constants.d.ts +8 -0
  11. package/dist/flow-constants.js +12 -0
  12. package/dist/flow-types.d.ts +40 -1
  13. package/dist/index.d.ts +3 -0
  14. package/dist/index.js +3 -0
  15. package/dist/journal.d.ts +2 -2
  16. package/dist/messages.d.ts +72 -0
  17. package/dist/messages.js +34 -0
  18. package/dist/net.d.ts +40 -0
  19. package/dist/net.js +44 -0
  20. package/dist/project-id.d.ts +28 -0
  21. package/dist/project-id.js +51 -0
  22. package/dist/redaction.d.ts +64 -0
  23. package/dist/redaction.js +118 -1
  24. package/dist/schema/hello-message.json +17 -0
  25. package/dist/schema/reticle-message.json +17 -0
  26. package/dist/security.js +10 -5
  27. package/dist/source-constants.d.ts +32 -0
  28. package/dist/source-constants.js +32 -0
  29. package/dist/state-select.d.ts +24 -2
  30. package/dist/state-select.js +102 -22
  31. package/dist/telemetry-feedback.d.ts +32 -10
  32. package/dist/telemetry-feedback.js +21 -0
  33. package/dist/telemetry-session.d.ts +30 -0
  34. package/dist/telemetry-session.js +24 -0
  35. package/dist/telemetry.d.ts +491 -81
  36. package/dist/telemetry.js +188 -2
  37. package/dist/toon.d.ts +2 -1
  38. package/dist/toon.js +37 -37
  39. package/dist/types.d.ts +54 -6
  40. package/dist/types.js +12 -0
  41. package/dist/upgrade.js +1 -1
  42. package/dist/verification-run.d.ts +38 -38
  43. package/dist/verified-constants.d.ts +37 -0
  44. package/dist/verified-constants.js +36 -0
  45. package/package.json +5 -3
@@ -20,6 +20,33 @@ export declare const PresenceKind: {
20
20
  readonly TEXT: "text";
21
21
  };
22
22
  export type PresenceKind = (typeof PresenceKind)[keyof typeof PresenceKind];
23
+ /**
24
+ * Every predicate discriminant, in one place — the five graded above plus the ungraded rest.
25
+ *
26
+ * Composed from ConsequenceKind/PresenceKind rather than respelling them, which is the whole point:
27
+ * these strings are what an agent types into `until:`/`expect:`, what zod discriminates on, and what
28
+ * a dozen files across flows, capsules and oracles switch on. A second spelling of 'signal' is
29
+ * exactly the drift this file exists to prevent, and a typo in a free-string branch is not a compile
30
+ * error anywhere — it is a case that silently never matches.
31
+ *
32
+ * The remaining kinds are neither consequence nor presence: they observe context (route, console),
33
+ * timing (animation, settled), or combine other predicates (allOf/anyOf/not).
34
+ */
35
+ export declare const PredicateKind: {
36
+ readonly ELEMENT: "element";
37
+ readonly TEXT: "text";
38
+ readonly SIGNAL: "signal";
39
+ readonly NET: "net";
40
+ readonly STATE: "state";
41
+ readonly ROUTE: "route";
42
+ readonly CONSOLE: "console";
43
+ readonly ANIMATION: "animation";
44
+ readonly SETTLED: "settled";
45
+ readonly ALL_OF: "allOf";
46
+ readonly ANY_OF: "anyOf";
47
+ readonly NOT: "not";
48
+ };
49
+ export type PredicateKind = (typeof PredicateKind)[keyof typeof PredicateKind];
23
50
  /** True when `kind` (a predicate/expect kind) asserts a consequence (signal/net/state). */
24
51
  export declare function isConsequenceKind(kind: string): boolean;
25
52
  /** True when `kind` is a weak presence check (element/text). */
@@ -17,6 +17,32 @@ export const PresenceKind = {
17
17
  ELEMENT: 'element',
18
18
  TEXT: 'text',
19
19
  };
20
+ /**
21
+ * Every predicate discriminant, in one place — the five graded above plus the ungraded rest.
22
+ *
23
+ * Composed from ConsequenceKind/PresenceKind rather than respelling them, which is the whole point:
24
+ * these strings are what an agent types into `until:`/`expect:`, what zod discriminates on, and what
25
+ * a dozen files across flows, capsules and oracles switch on. A second spelling of 'signal' is
26
+ * exactly the drift this file exists to prevent, and a typo in a free-string branch is not a compile
27
+ * error anywhere — it is a case that silently never matches.
28
+ *
29
+ * The remaining kinds are neither consequence nor presence: they observe context (route, console),
30
+ * timing (animation, settled), or combine other predicates (allOf/anyOf/not).
31
+ */
32
+ export const PredicateKind = {
33
+ ELEMENT: PresenceKind.ELEMENT,
34
+ TEXT: PresenceKind.TEXT,
35
+ SIGNAL: ConsequenceKind.SIGNAL,
36
+ NET: ConsequenceKind.NET,
37
+ STATE: ConsequenceKind.STATE,
38
+ ROUTE: 'route',
39
+ CONSOLE: 'console',
40
+ ANIMATION: 'animation',
41
+ SETTLED: 'settled',
42
+ ALL_OF: 'allOf',
43
+ ANY_OF: 'anyOf',
44
+ NOT: 'not',
45
+ };
20
46
  const CONSEQUENCE_KINDS = new Set(Object.values(ConsequenceKind));
21
47
  const PRESENCE_KINDS = new Set(Object.values(PresenceKind));
22
48
  /** True when `kind` (a predicate/expect kind) asserts a consequence (signal/net/state). */
@@ -43,6 +43,10 @@ export declare const ReticleEnv: {
43
43
  readonly ALLOWED_ORIGINS: "RETICLE_ALLOWED_ORIGINS";
44
44
  /** Bridge/daemon WS port override. */
45
45
  readonly PORT: "RETICLE_PORT";
46
+ /** Daemon state — pidfiles, discovery registry, logs. Defaults to `~/.reticle`. Overridable
47
+ * because a read-only $HOME (sandboxed agent, locked-down Windows profile, container) otherwise
48
+ * makes the daemon unstartable with a raw EACCES naming nothing. Reported by a Windows user. */
49
+ readonly STATE_DIR: "RETICLE_STATE_DIR";
46
50
  /** Attach to an already-running browser over CDP instead of launching one. */
47
51
  readonly CDP_URL: "RETICLE_CDP_URL";
48
52
  /** Max simultaneous leased headless contexts in the browser pool (resource cap). */
@@ -60,10 +64,35 @@ export declare const ReticleEnv: {
60
64
  /** Ms of continuous idleness (no agent, no browser session, no lease) before the daemon self-exits;
61
65
  * `0` disables. Keeps Reticle from lingering on a user's machine after the editor closes. */
62
66
  readonly IDLE_SHUTDOWN: "RETICLE_IDLE_SHUTDOWN_MS";
67
+ /** Idle re-check cadence (default 30s). Overridable so daemon-lifecycle-test can watch a full
68
+ * exit/wake cycle in seconds rather than minutes. */
69
+ readonly IDLE_CHECK: "RETICLE_IDLE_CHECK_MS";
70
+ /**
71
+ * Grace for a daemon with an agent ATTACHED. Longer than the base on purpose: quiet with a client
72
+ * present means a slow install or a thinking human, not an unwanted daemon — a flat 5 minutes was
73
+ * killing live runs mid-install. Derived from the base when unset.
74
+ */
75
+ readonly IDLE_ATTACHED: "RETICLE_IDLE_ATTACHED_MS";
63
76
  /** Directory holding the auto-provisioned pairing token. Defaults to ~/.reticle; relocatable for CI. */
64
77
  readonly PAIRING_TOKEN_DIR: "RETICLE_PAIRING_TOKEN_DIR";
65
78
  /** Force the durable causal journal off (`0`/`false`/`off`) or on (`1`/`true`/`on`); default on. */
66
79
  readonly JOURNAL: "RETICLE_JOURNAL";
80
+ /**
81
+ * Verbose internal flow tracing for people working ON Reticle (`1`/`true`/`on`); default off.
82
+ *
83
+ * Distinct from the journal, which records what the AGENT did to the app. This records what
84
+ * RETICLE did to answer it: one line per internal stage, with its duration and nesting, so a
85
+ * developer can see which code a tool call actually went through and where the time went.
86
+ * Off by default and free when off — a trace on every tool call is a cost on the hot path.
87
+ */
88
+ readonly TRACE: "RETICLE_TRACE";
89
+ /**
90
+ * How many consecutive reconnects the MCP proxy attempts before it stops retrying and goes
91
+ * dormant. Overridable for the same reason the idle windows are: the real budget takes MINUTES to
92
+ * exhaust, so the one spec that proves the proxy SURVIVES exhaustion could not run at all without
93
+ * shortening it. A budget nobody can reach in a test is a budget nobody tests.
94
+ */
95
+ readonly RECONNECT_ATTEMPTS: "RETICLE_RECONNECT_ATTEMPTS";
67
96
  };
68
97
  /** Hard transport bounds shared by the browser and bridge. */
69
98
  export declare const TRANSPORT_LIMITS: {
@@ -97,16 +126,15 @@ export declare const TRANSPORT_LIMITS: {
97
126
  };
98
127
  /** Replacement used when sensitive data is removed before crossing the bridge. */
99
128
  export declare const REDACTED_VALUE = "[REDACTED]";
100
- /**
101
- * The attribute the build plugin stamps on JSX host elements as `file:line:column`, so the browser SDK
102
- * and the React adapter can map a DOM node back to its source file (the source-pointer feature, needed
103
- * on React 19 which dropped _debugSource). Read here by both packages — it was duplicated as a local
104
- * const in dom/source.ts AND dom/query.ts and inlined as a literal in the React adapter. The stamper
105
- * (@reticlehq/babel-plugin, separate build tooling) stamps this same literal and MUST match it.
106
- */
107
- export declare const DATA_RETICLE_SOURCE_ATTR = "data-reticle-source";
108
129
  /** Explicit opt-in argument required for potentially destructive actions. */
109
130
  export declare const DANGEROUS_ACTION_CONFIRM_ARG = "confirmDangerous";
131
+ /**
132
+ * Opt-in argument for a TRUSTED native click, for the handlers a synthetic one cannot satisfy —
133
+ * file pickers, clipboard, anything gated on `isTrusted`. Only `reticle_act` can honour it: the
134
+ * native driver is a pointer gesture at coordinates, and the act-then-wait tool drives the page
135
+ * through the SDK instead.
136
+ */
137
+ export declare const NATIVE_INPUT_ARG = "native";
110
138
  /** Schema version stamped onto compiled replay programs. */
111
139
  export declare const REPLAY_PROGRAM_VERSION = 1;
112
140
  /** The git-checked Reticle workspace directory + its layout. No free strings. */
@@ -401,6 +429,14 @@ export type DriveErrorCode = (typeof DriveErrorCode)[keyof typeof DriveErrorCode
401
429
  /** Human-facing message when the optional playwright dep is absent. */
402
430
  export declare const DRIVE_PLAYWRIGHT_MISSING_MSG = "reticle drive needs the optional 'playwright' package \u2014 install it: pnpm add -D playwright && npx playwright install chromium";
403
431
  /** Actions the executor can perform against a ref (plan/03 + plan/05). */
432
+ /**
433
+ * The console levels an agent can filter by, DERIVED from the console EventTypes rather than
434
+ * retyped. `reticle_console { level }` matches by building `console.${level}`, so any list written
435
+ * out by hand is one rename away from filtering everything into an empty result — which reads as
436
+ * "no errors on this page".
437
+ */
438
+ export declare const CONSOLE_LEVEL_PREFIX = "console.";
439
+ export declare const CONSOLE_LEVELS: string[];
404
440
  export declare const ActionType: {
405
441
  readonly CLICK: "click";
406
442
  readonly DBLCLICK: "dblclick";
@@ -444,6 +480,14 @@ export interface ComponentStateResult {
444
480
  component?: string;
445
481
  /** Positional, JSON-safe hook states. */
446
482
  hooks?: unknown[];
483
+ /**
484
+ * Present ONLY when `hooks` is a PROJECTION — effect entries were removed. A trim is never silent:
485
+ * without this, a hook list short by three entries reads as the component's complete hook list.
486
+ */
487
+ truncation?: {
488
+ droppedItems: number;
489
+ note: string;
490
+ };
447
491
  }
448
492
  /** Element states the assertion engine can check (plan/06). */
449
493
  export declare const ElementState: {
package/dist/constants.js CHANGED
@@ -45,6 +45,10 @@ export const ReticleEnv = {
45
45
  ALLOWED_ORIGINS: 'RETICLE_ALLOWED_ORIGINS',
46
46
  /** Bridge/daemon WS port override. */
47
47
  PORT: 'RETICLE_PORT',
48
+ /** Daemon state — pidfiles, discovery registry, logs. Defaults to `~/.reticle`. Overridable
49
+ * because a read-only $HOME (sandboxed agent, locked-down Windows profile, container) otherwise
50
+ * makes the daemon unstartable with a raw EACCES naming nothing. Reported by a Windows user. */
51
+ STATE_DIR: 'RETICLE_STATE_DIR',
48
52
  /** Attach to an already-running browser over CDP instead of launching one. */
49
53
  CDP_URL: 'RETICLE_CDP_URL',
50
54
  /** Max simultaneous leased headless contexts in the browser pool (resource cap). */
@@ -62,10 +66,35 @@ export const ReticleEnv = {
62
66
  /** Ms of continuous idleness (no agent, no browser session, no lease) before the daemon self-exits;
63
67
  * `0` disables. Keeps Reticle from lingering on a user's machine after the editor closes. */
64
68
  IDLE_SHUTDOWN: 'RETICLE_IDLE_SHUTDOWN_MS',
69
+ /** Idle re-check cadence (default 30s). Overridable so daemon-lifecycle-test can watch a full
70
+ * exit/wake cycle in seconds rather than minutes. */
71
+ IDLE_CHECK: 'RETICLE_IDLE_CHECK_MS',
72
+ /**
73
+ * Grace for a daemon with an agent ATTACHED. Longer than the base on purpose: quiet with a client
74
+ * present means a slow install or a thinking human, not an unwanted daemon — a flat 5 minutes was
75
+ * killing live runs mid-install. Derived from the base when unset.
76
+ */
77
+ IDLE_ATTACHED: 'RETICLE_IDLE_ATTACHED_MS',
65
78
  /** Directory holding the auto-provisioned pairing token. Defaults to ~/.reticle; relocatable for CI. */
66
79
  PAIRING_TOKEN_DIR: 'RETICLE_PAIRING_TOKEN_DIR',
67
80
  /** Force the durable causal journal off (`0`/`false`/`off`) or on (`1`/`true`/`on`); default on. */
68
81
  JOURNAL: 'RETICLE_JOURNAL',
82
+ /**
83
+ * Verbose internal flow tracing for people working ON Reticle (`1`/`true`/`on`); default off.
84
+ *
85
+ * Distinct from the journal, which records what the AGENT did to the app. This records what
86
+ * RETICLE did to answer it: one line per internal stage, with its duration and nesting, so a
87
+ * developer can see which code a tool call actually went through and where the time went.
88
+ * Off by default and free when off — a trace on every tool call is a cost on the hot path.
89
+ */
90
+ TRACE: 'RETICLE_TRACE',
91
+ /**
92
+ * How many consecutive reconnects the MCP proxy attempts before it stops retrying and goes
93
+ * dormant. Overridable for the same reason the idle windows are: the real budget takes MINUTES to
94
+ * exhaust, so the one spec that proves the proxy SURVIVES exhaustion could not run at all without
95
+ * shortening it. A budget nobody can reach in a test is a budget nobody tests.
96
+ */
97
+ RECONNECT_ATTEMPTS: 'RETICLE_RECONNECT_ATTEMPTS',
69
98
  };
70
99
  /** Hard transport bounds shared by the browser and bridge. */
71
100
  export const TRANSPORT_LIMITS = {
@@ -99,16 +128,15 @@ export const TRANSPORT_LIMITS = {
99
128
  };
100
129
  /** Replacement used when sensitive data is removed before crossing the bridge. */
101
130
  export const REDACTED_VALUE = '[REDACTED]';
102
- /**
103
- * The attribute the build plugin stamps on JSX host elements as `file:line:column`, so the browser SDK
104
- * and the React adapter can map a DOM node back to its source file (the source-pointer feature, needed
105
- * on React 19 which dropped _debugSource). Read here by both packages — it was duplicated as a local
106
- * const in dom/source.ts AND dom/query.ts and inlined as a literal in the React adapter. The stamper
107
- * (@reticlehq/babel-plugin, separate build tooling) stamps this same literal and MUST match it.
108
- */
109
- export const DATA_RETICLE_SOURCE_ATTR = 'data-reticle-source';
110
131
  /** Explicit opt-in argument required for potentially destructive actions. */
111
132
  export const DANGEROUS_ACTION_CONFIRM_ARG = 'confirmDangerous';
133
+ /**
134
+ * Opt-in argument for a TRUSTED native click, for the handlers a synthetic one cannot satisfy —
135
+ * file pickers, clipboard, anything gated on `isTrusted`. Only `reticle_act` can honour it: the
136
+ * native driver is a pointer gesture at coordinates, and the act-then-wait tool drives the page
137
+ * through the SDK instead.
138
+ */
139
+ export const NATIVE_INPUT_ARG = 'native';
112
140
  /** Schema version stamped onto compiled replay programs. */
113
141
  export const REPLAY_PROGRAM_VERSION = 1;
114
142
  /** The git-checked Reticle workspace directory + its layout. No free strings. */
@@ -397,6 +425,19 @@ export const DriveErrorCode = {
397
425
  /** Human-facing message when the optional playwright dep is absent. */
398
426
  export const DRIVE_PLAYWRIGHT_MISSING_MSG = "reticle drive needs the optional 'playwright' package — install it: pnpm add -D playwright && npx playwright install chromium";
399
427
  /** Actions the executor can perform against a ref (plan/03 + plan/05). */
428
+ /**
429
+ * The console levels an agent can filter by, DERIVED from the console EventTypes rather than
430
+ * retyped. `reticle_console { level }` matches by building `console.${level}`, so any list written
431
+ * out by hand is one rename away from filtering everything into an empty result — which reads as
432
+ * "no errors on this page".
433
+ */
434
+ export const CONSOLE_LEVEL_PREFIX = 'console.';
435
+ export const CONSOLE_LEVELS = [
436
+ EventType.CONSOLE_LOG,
437
+ EventType.CONSOLE_WARN,
438
+ EventType.CONSOLE_ERROR,
439
+ EventType.CONSOLE_INFO,
440
+ ].map((type) => type.slice(CONSOLE_LEVEL_PREFIX.length));
400
441
  export const ActionType = {
401
442
  CLICK: 'click',
402
443
  DBLCLICK: 'dblclick',
@@ -0,0 +1,29 @@
1
+ /**
2
+ * A derived id for the wire contract this build speaks.
3
+ *
4
+ * Reticle is installed as separate pieces — the SDK in the page, the daemon, the MCP server the
5
+ * agent spawns — upgraded independently and therefore drifting constantly. The question that
6
+ * matters when they meet is not "are these the same release?" but "do these speak the same
7
+ * contract?", and package-version equality answers it wrongly in both directions: it fires on
8
+ * 2.4.0-vs-2.4.1 where nothing changed, and it stays silent for two different BUILDS of one version
9
+ * number, which is exactly what a stale daemon and a cached npx package are.
10
+ *
11
+ * So this hashes the vocabulary itself. Both sides compute it from their own copy of core, so equal
12
+ * hashes mean "we agree" whatever the version strings say, and a hash that moved means a name on the
13
+ * wire genuinely changed.
14
+ *
15
+ * Derived on purpose. A hand-maintained contract number is one somebody eventually forgets to bump,
16
+ * and a forgotten bump is silent skew — the failure this exists to end.
17
+ */
18
+ /**
19
+ * Hash a named vocabulary. Keys and values are sorted, so declaration order — which changes for
20
+ * cosmetic reasons — never moves the fingerprint, while a renamed, added or removed name always does.
21
+ */
22
+ export declare function fingerprintOf(vocabulary: Record<string, readonly string[]>): string;
23
+ /**
24
+ * The wire vocabulary two pieces must agree on to work together: the message kinds framing every
25
+ * exchange, the commands the daemon sends the page, the actions it can ask for, and the event types
26
+ * the page sends back. Everything else in core is shape, defaults or prose — it can change without
27
+ * either side misunderstanding the other.
28
+ */
29
+ export declare const CONTRACT_FINGERPRINT: string;
@@ -0,0 +1,56 @@
1
+ /**
2
+ * A derived id for the wire contract this build speaks.
3
+ *
4
+ * Reticle is installed as separate pieces — the SDK in the page, the daemon, the MCP server the
5
+ * agent spawns — upgraded independently and therefore drifting constantly. The question that
6
+ * matters when they meet is not "are these the same release?" but "do these speak the same
7
+ * contract?", and package-version equality answers it wrongly in both directions: it fires on
8
+ * 2.4.0-vs-2.4.1 where nothing changed, and it stays silent for two different BUILDS of one version
9
+ * number, which is exactly what a stale daemon and a cached npx package are.
10
+ *
11
+ * So this hashes the vocabulary itself. Both sides compute it from their own copy of core, so equal
12
+ * hashes mean "we agree" whatever the version strings say, and a hash that moved means a name on the
13
+ * wire genuinely changed.
14
+ *
15
+ * Derived on purpose. A hand-maintained contract number is one somebody eventually forgets to bump,
16
+ * and a forgotten bump is silent skew — the failure this exists to end.
17
+ */
18
+ import { ActionType, EventType, MessageKind, ReticleCommand } from './constants.js';
19
+ /**
20
+ * FNV-1a, 32-bit. Chosen over a crypto hash because this runs in the PAGE: `crypto.subtle` is async
21
+ * and unavailable on insecure origins, and a dependency is not worth 40 lines. Collisions do not
22
+ * matter here — the comparison is equality between two builds of the same project, not a security
23
+ * boundary.
24
+ */
25
+ function fnv1a(input) {
26
+ let hash = 0x811c9dc5;
27
+ for (let i = 0; i < input.length; i++) {
28
+ hash ^= input.charCodeAt(i);
29
+ // The FNV prime, as shifts: Math.imul keeps this in 32-bit space in every JS engine.
30
+ hash = Math.imul(hash, 0x01000193) >>> 0;
31
+ }
32
+ return hash.toString(16).padStart(8, '0');
33
+ }
34
+ /**
35
+ * Hash a named vocabulary. Keys and values are sorted, so declaration order — which changes for
36
+ * cosmetic reasons — never moves the fingerprint, while a renamed, added or removed name always does.
37
+ */
38
+ export function fingerprintOf(vocabulary) {
39
+ const canonical = Object.keys(vocabulary)
40
+ .sort()
41
+ .map((key) => `${key}:${[...(vocabulary[key] ?? [])].sort().join(',')}`)
42
+ .join('|');
43
+ return fnv1a(canonical);
44
+ }
45
+ /**
46
+ * The wire vocabulary two pieces must agree on to work together: the message kinds framing every
47
+ * exchange, the commands the daemon sends the page, the actions it can ask for, and the event types
48
+ * the page sends back. Everything else in core is shape, defaults or prose — it can change without
49
+ * either side misunderstanding the other.
50
+ */
51
+ export const CONTRACT_FINGERPRINT = fingerprintOf({
52
+ messageKinds: Object.values(MessageKind),
53
+ commands: Object.values(ReticleCommand),
54
+ actions: Object.values(ActionType),
55
+ events: Object.values(EventType),
56
+ });
@@ -37,7 +37,7 @@ export const DaemonRegistryEntrySchema = z.object({
37
37
  * mismatched daemon — a wrong auto-connect is worse than the honest default).
38
38
  */
39
39
  export function pickDaemonPort(entries, projectId, isAlive) {
40
- if (projectId === undefined || projectId.length === 0)
40
+ if (projectId === undefined || 0 === projectId.length)
41
41
  return null;
42
42
  const matches = entries
43
43
  .filter((e) => e.projectId === projectId && isAlive(e.pid))
@@ -212,12 +212,12 @@ export declare const EVENT_PAYLOAD_SCHEMAS: {
212
212
  value: z.ZodNumber;
213
213
  at: z.ZodNumber;
214
214
  }, "strip", z.ZodTypeAny, {
215
- value: number;
216
215
  at: number;
216
+ value: number;
217
217
  metric: "lcp" | "cls" | "longtask";
218
218
  }, {
219
- value: number;
220
219
  at: number;
220
+ value: number;
221
221
  metric: "lcp" | "cls" | "longtask";
222
222
  }>;
223
223
  "route.change": z.ZodObject<{
@@ -387,14 +387,62 @@ export declare const EVENT_PAYLOAD_SCHEMAS: {
387
387
  hidden: z.ZodBoolean;
388
388
  focused: z.ZodBoolean;
389
389
  reason: z.ZodOptional<z.ZodString>;
390
+ /**
391
+ * Which browser the page is, normalised in the SDK to a closed list before it is sent — never
392
+ * a UA string and never a raw `userAgentData` brand. Optional: an older SDK does not report
393
+ * one, and a desktop webview has no brand to report.
394
+ */
395
+ brand: z.ZodOptional<z.ZodNativeEnum<{
396
+ readonly CHROME: "chrome";
397
+ readonly EDGE: "edge";
398
+ readonly ARC: "arc";
399
+ readonly DIA: "dia";
400
+ readonly BRAVE: "brave";
401
+ readonly OPERA: "opera";
402
+ readonly FIREFOX: "firefox";
403
+ readonly SAFARI: "safari";
404
+ readonly OTHER: "other";
405
+ }>>;
390
406
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
391
407
  hidden: z.ZodBoolean;
392
408
  focused: z.ZodBoolean;
393
409
  reason: z.ZodOptional<z.ZodString>;
410
+ /**
411
+ * Which browser the page is, normalised in the SDK to a closed list before it is sent — never
412
+ * a UA string and never a raw `userAgentData` brand. Optional: an older SDK does not report
413
+ * one, and a desktop webview has no brand to report.
414
+ */
415
+ brand: z.ZodOptional<z.ZodNativeEnum<{
416
+ readonly CHROME: "chrome";
417
+ readonly EDGE: "edge";
418
+ readonly ARC: "arc";
419
+ readonly DIA: "dia";
420
+ readonly BRAVE: "brave";
421
+ readonly OPERA: "opera";
422
+ readonly FIREFOX: "firefox";
423
+ readonly SAFARI: "safari";
424
+ readonly OTHER: "other";
425
+ }>>;
394
426
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
395
427
  hidden: z.ZodBoolean;
396
428
  focused: z.ZodBoolean;
397
429
  reason: z.ZodOptional<z.ZodString>;
430
+ /**
431
+ * Which browser the page is, normalised in the SDK to a closed list before it is sent — never
432
+ * a UA string and never a raw `userAgentData` brand. Optional: an older SDK does not report
433
+ * one, and a desktop webview has no brand to report.
434
+ */
435
+ brand: z.ZodOptional<z.ZodNativeEnum<{
436
+ readonly CHROME: "chrome";
437
+ readonly EDGE: "edge";
438
+ readonly ARC: "arc";
439
+ readonly DIA: "dia";
440
+ readonly BRAVE: "brave";
441
+ readonly OPERA: "opera";
442
+ readonly FIREFOX: "firefox";
443
+ readonly SAFARI: "safari";
444
+ readonly OTHER: "other";
445
+ }>>;
398
446
  }, z.ZodTypeAny, "passthrough">>;
399
447
  "render.commit": z.ZodObject<{
400
448
  commits: z.ZodNumber;
@@ -1,6 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { EventType, PerfMetric } from './constants.js';
3
3
  import { BlindSpotKind } from './verified-constants.js';
4
+ import { BrowserBrand } from './telemetry-feedback.js';
4
5
  import { HumanControlDataSchema, HumanMarkDataSchema } from './messages.js';
5
6
  /**
6
7
  * Per-event-type payload schemas — the typed replacement for the envelope's open `data` record.
@@ -132,7 +133,17 @@ export const EVENT_PAYLOAD_SCHEMAS = {
132
133
  new: z.string().optional(),
133
134
  }),
134
135
  [EventType.PAGE_HEALTH]: z
135
- .object({ hidden: z.boolean(), focused: z.boolean(), reason: z.string().optional() })
136
+ .object({
137
+ hidden: z.boolean(),
138
+ focused: z.boolean(),
139
+ reason: z.string().optional(),
140
+ /**
141
+ * Which browser the page is, normalised in the SDK to a closed list before it is sent — never
142
+ * a UA string and never a raw `userAgentData` brand. Optional: an older SDK does not report
143
+ * one, and a desktop webview has no brand to report.
144
+ */
145
+ brand: z.nativeEnum(BrowserBrand).optional(),
146
+ })
136
147
  .passthrough(),
137
148
  [EventType.RENDER_COMMIT]: z.object({ commits: z.number() }),
138
149
  [EventType.FOCUS_CHANGE]: z.object({
@@ -91,6 +91,13 @@ export declare const DriftReason: {
91
91
  readonly SIGNAL_NOT_OBSERVED: "signal_not_observed";
92
92
  readonly COMPONENT_NOT_FOUND: "component_not_found";
93
93
  readonly STATE_MISMATCH: "state_mismatch";
94
+ /**
95
+ * The step carries DEGRADED_ANCHOR_ROLE — no anchor was ever resolvable, so nothing was queried.
96
+ * Distinct from TESTID_NOT_FOUND deliberately: "your element disappeared" and "this step never had
97
+ * an element bound to it" need different fixes, and reporting the second as the first sent heal
98
+ * hunting for the nearest testid to the literal word "unresolved".
99
+ */
100
+ readonly ANCHOR_DEGRADED: "anchor_degraded";
94
101
  };
95
102
  export type DriftReason = (typeof DriftReason)[keyof typeof DriftReason];
96
103
  /** Default timeout (ms) a signal anchor waits to be observed at replay. */
@@ -106,6 +113,7 @@ export declare const AnnotationKind: {
106
113
  readonly ASSERT_SIGNAL: "assert-signal";
107
114
  readonly ASSERT_VISIBLE: "assert-visible";
108
115
  readonly ASSERT_STATE: "assert-state";
116
+ readonly ASSERT_NET: "assert-net";
109
117
  readonly MARK_DYNAMIC: "mark-dynamic";
110
118
  readonly SUCCESS_STATE: "success-state";
111
119
  readonly INTENT: "intent";
@@ -85,6 +85,13 @@ export const DriftReason = {
85
85
  SIGNAL_NOT_OBSERVED: 'signal_not_observed', // a signal anchor never fired within the timeout
86
86
  COMPONENT_NOT_FOUND: 'component_not_found', // a component/source auto-anchor resolved to zero live elements
87
87
  STATE_MISMATCH: 'state_mismatch', // a step's expect.state assertion did not hold against the store
88
+ /**
89
+ * The step carries DEGRADED_ANCHOR_ROLE — no anchor was ever resolvable, so nothing was queried.
90
+ * Distinct from TESTID_NOT_FOUND deliberately: "your element disappeared" and "this step never had
91
+ * an element bound to it" need different fixes, and reporting the second as the first sent heal
92
+ * hunting for the nearest testid to the literal word "unresolved".
93
+ */
94
+ ANCHOR_DEGRADED: 'anchor_degraded',
88
95
  };
89
96
  /** Default timeout (ms) a signal anchor waits to be observed at replay. */
90
97
  export const FLOW_SIGNAL_TIMEOUT_MS = 4000;
@@ -99,6 +106,11 @@ export const AnnotationKind = {
99
106
  ASSERT_SIGNAL: 'assert-signal', // → step.expect.signal (invariant)
100
107
  ASSERT_VISIBLE: 'assert-visible', // → step.expect.element (invariant)
101
108
  ASSERT_STATE: 'assert-state', // → step.expect.state (store-truth invariant on the last step)
109
+ // → step.expect.net (the request the action must have caused, with an optional exact count).
110
+ // Documented in agent-cheatsheet.md long before it existed: an agent following that advice got
111
+ // `annotate_unknown_kind`, the annotation was dropped, and the flow stayed presence-only — able
112
+ // to pass while broken, which is the failure this whole product is pointed at.
113
+ ASSERT_NET: 'assert-net',
102
114
  MARK_DYNAMIC: 'mark-dynamic', // → flow.dynamic[] (don't assert words/content)
103
115
  SUCCESS_STATE: 'success-state', // → flow.success (golden end condition)
104
116
  INTENT: 'intent', // → flow.intent (the business goal this flow exists to verify)
@@ -346,6 +346,13 @@ export interface ReplayDecision {
346
346
  */
347
347
  export interface SuiteFlowResult {
348
348
  flow: string;
349
+ /**
350
+ * The flow never ran: its file failed to load, or its leased context never came up. Nothing was
351
+ * learned about the app, so this row is not a regression — it is Reticle reporting its own failure
352
+ * in the same array as the app's. Measured: one sweep emitted 8 `flow-regression` bug_found events
353
+ * off rows like these, from a suite where no flow ever executed.
354
+ */
355
+ couldNotRun?: boolean;
349
356
  verdict: 'pass' | 'drift' | 'fail';
350
357
  whatChanged?: string;
351
358
  whereInSource?: string;
@@ -357,13 +364,29 @@ export interface SuiteFlowResult {
357
364
  * failures carry detail (token-cheap). `status` is fail if any flow drifted or errored.
358
365
  */
359
366
  export interface SuiteVerdict {
360
- status: 'pass' | 'fail';
367
+ /**
368
+ * `unverifiable` means the suite contained flows that CANNOT FAIL, so "pass" would be a lie.
369
+ *
370
+ * A recorded flow with no steps, or one that asserts no observable consequence, replays green no
371
+ * matter what the app does. Reporting `pass` for it is a false green in the exact feature sold as
372
+ * the regression suite — measured: a flow saved as `{steps: [], intent: "..."}`, which `flow_save`
373
+ * had ALREADY graded assertion-free with a warning, came back "all 1 flow pass".
374
+ */
375
+ status: 'pass' | 'fail' | 'unverifiable';
361
376
  total: number;
362
377
  passed: number;
363
378
  failed: number;
364
379
  summary: string;
365
380
  /** Only the failing flows, with their decision (verdict, what changed, where, next action). */
366
381
  failures: SuiteFlowResult[];
382
+ /**
383
+ * Flows that replayed without error but assert nothing, so their green means nothing. Counted
384
+ * apart from `passed` — a number that includes them is not a count of anything verified.
385
+ */
386
+ unverifiable?: {
387
+ flow: string;
388
+ reason: string;
389
+ }[];
367
390
  /**
368
391
  * Flows that have both passed AND failed on UNCHANGED code — intermittent, not regressions.
369
392
  *
@@ -1334,3 +1357,19 @@ export interface FlowHealResult {
1334
1357
  };
1335
1358
  }
1336
1359
  export type RecordedFlow = z.infer<typeof RecordedFlowSchema>;
1360
+ /**
1361
+ * One replayable-flow chip on the in-page HUD.
1362
+ *
1363
+ * Crosses the bridge: the daemon builds these from the flows on disk and pushes them with
1364
+ * `ReticleCommand.FLOWS`; the presenter panel renders one ▶ button per chip. It lived as two
1365
+ * identical `interface FlowChip` declarations — one in the server, one in the browser — which is the
1366
+ * shape that drifts silently, because nothing links the two and no test crosses the boundary.
1367
+ *
1368
+ * A TYPE and not a zod schema on purpose: the browser SDK ships into the user's app and carries no
1369
+ * zod, so the receiving side narrows the raw wire value by hand. The type is what both ends agree on.
1370
+ */
1371
+ export interface FlowChip {
1372
+ name: string;
1373
+ /** The testid the flow's first step anchors to, when it has one — the panel hides chips that cannot start on the current page. */
1374
+ start?: string;
1375
+ }
package/dist/index.d.ts CHANGED
@@ -8,6 +8,7 @@
8
8
  * now the boundary is documented here.)
9
9
  */
10
10
  export * from './constants.js';
11
+ export * from './source-constants.js';
11
12
  export * from './verified-constants.js';
12
13
  export * from './session-constants.js';
13
14
  export * from './messages.js';
@@ -21,6 +22,7 @@ export * from './net.js';
21
22
  export * from './findings.js';
22
23
  export * from './desktop-contract.js';
23
24
  export * from './consequence.js';
25
+ export * from './project-id.js';
24
26
  export * from './notices.js';
25
27
  export * from './journal.js';
26
28
  export * from './daemon-registry.js';
@@ -32,3 +34,4 @@ export * from './upgrade.js';
32
34
  export * from './telemetry.js';
33
35
  export * from './telemetry-session.js';
34
36
  export * from './telemetry-feedback.js';
37
+ export { CONTRACT_FINGERPRINT, fingerprintOf } from './contract-fingerprint.js';
package/dist/index.js CHANGED
@@ -9,6 +9,7 @@
9
9
  */
10
10
  // ── STABLE public surface: the wire/domain contract ──────────────────────────────────────────────
11
11
  export * from './constants.js'; // EventType, ActionType, wire constants, TRANSPORT_LIMITS, …
12
+ export * from './source-constants.js'; // DATA_RETICLE_SOURCE_ATTR, RETICLE_ROOT_GLOBAL
12
13
  export * from './verified-constants.js'; // Verified — the one field an agent gates on
13
14
  export * from './session-constants.js';
14
15
  export * from './messages.js'; // ReticleEvent + the message schemas
@@ -22,6 +23,7 @@ export * from './net.js'; // NetInitiator / ipc:// scheme — network + desktop-
22
23
  export * from './findings.js'; // crawl anomalies + cross-channel contradictions
23
24
  export * from './desktop-contract.js'; // the Electron preload/main/renderer/daemon string contract
24
25
  export * from './consequence.js';
26
+ export * from './project-id.js';
25
27
  export * from './notices.js';
26
28
  export * from './journal.js';
27
29
  // ── INTERNAL cross-package plumbing (shared impl; not a stable outside API — may change in a minor) ─
@@ -34,3 +36,4 @@ export * from './upgrade.js'; // self-update policy shared by the CLI
34
36
  export * from './telemetry.js';
35
37
  export * from './telemetry-session.js'; // the session/project rollup payloads
36
38
  export * from './telemetry-feedback.js'; // the two things a PERSON writes: feedback + a self-declared identity // anonymous adoption telemetry wire contract (DAU/WAU/MAU/installs)
39
+ export { CONTRACT_FINGERPRINT, fingerprintOf } from './contract-fingerprint.js';
package/dist/journal.d.ts CHANGED
@@ -61,8 +61,8 @@ export declare const JournalActionSchema: z.ZodObject<{
61
61
  from: number;
62
62
  to: number;
63
63
  };
64
- effect?: unknown;
65
64
  settled?: boolean | undefined;
65
+ effect?: unknown;
66
66
  settledInMs?: number | undefined;
67
67
  seqRange?: {
68
68
  from: number;
@@ -78,8 +78,8 @@ export declare const JournalActionSchema: z.ZodObject<{
78
78
  to: number;
79
79
  };
80
80
  args?: Record<string, unknown> | undefined;
81
- effect?: unknown;
82
81
  settled?: boolean | undefined;
82
+ effect?: unknown;
83
83
  settledInMs?: number | undefined;
84
84
  seqRange?: {
85
85
  from: number;