@reticlehq/core 2.4.0 → 2.6.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 (46) hide show
  1. package/dist/consequence.d.ts +27 -0
  2. package/dist/consequence.js +26 -0
  3. package/dist/constants.d.ts +68 -0
  4. package/dist/constants.js +65 -0
  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-classification.d.ts +7 -0
  9. package/dist/event-classification.js +15 -0
  10. package/dist/event-payloads.d.ts +48 -0
  11. package/dist/event-payloads.js +12 -1
  12. package/dist/flow-constants.d.ts +8 -0
  13. package/dist/flow-constants.js +12 -0
  14. package/dist/flow-types.d.ts +23 -0
  15. package/dist/index.d.ts +3 -0
  16. package/dist/index.js +3 -0
  17. package/dist/journal.d.ts +2 -2
  18. package/dist/messages.d.ts +48 -0
  19. package/dist/messages.js +20 -0
  20. package/dist/net.d.ts +40 -0
  21. package/dist/net.js +44 -0
  22. package/dist/project-id.d.ts +28 -0
  23. package/dist/project-id.js +51 -0
  24. package/dist/redaction.js +4 -4
  25. package/dist/schema/hello-message.json +8 -0
  26. package/dist/schema/reticle-message.json +8 -0
  27. package/dist/security.js +10 -5
  28. package/dist/source-constants.d.ts +6 -0
  29. package/dist/source-constants.js +6 -0
  30. package/dist/state-select.d.ts +14 -2
  31. package/dist/state-select.js +77 -14
  32. package/dist/telemetry-feedback.d.ts +32 -10
  33. package/dist/telemetry-feedback.js +21 -0
  34. package/dist/telemetry-session.d.ts +169 -0
  35. package/dist/telemetry-session.js +139 -0
  36. package/dist/telemetry.d.ts +706 -92
  37. package/dist/telemetry.js +251 -4
  38. package/dist/toon.d.ts +2 -1
  39. package/dist/toon.js +37 -37
  40. package/dist/types.d.ts +48 -0
  41. package/dist/types.js +12 -0
  42. package/dist/upgrade.js +1 -1
  43. package/dist/verification-run.d.ts +28 -28
  44. package/dist/verified-constants.d.ts +53 -0
  45. package/dist/verified-constants.js +52 -0
  46. 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,43 @@ 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";
76
+ /**
77
+ * How often the daemon writes `reticle_daemon_alive`, so a GAP in its log is evidence it died.
78
+ *
79
+ * Overridable for the same reason the idle windows are: a spec that has to prove "a killed daemon
80
+ * is distinguishable from a tidy one" cannot wait 30 seconds per beat, and a spec that instead
81
+ * re-implements the cadence is insensitive to the thing it claims to guard.
82
+ */
83
+ readonly HEARTBEAT: "RETICLE_HEARTBEAT_MS";
63
84
  /** Directory holding the auto-provisioned pairing token. Defaults to ~/.reticle; relocatable for CI. */
64
85
  readonly PAIRING_TOKEN_DIR: "RETICLE_PAIRING_TOKEN_DIR";
65
86
  /** Force the durable causal journal off (`0`/`false`/`off`) or on (`1`/`true`/`on`); default on. */
66
87
  readonly JOURNAL: "RETICLE_JOURNAL";
88
+ /**
89
+ * Verbose internal flow tracing for people working ON Reticle (`1`/`true`/`on`); default off.
90
+ *
91
+ * Distinct from the journal, which records what the AGENT did to the app. This records what
92
+ * RETICLE did to answer it: one line per internal stage, with its duration and nesting, so a
93
+ * developer can see which code a tool call actually went through and where the time went.
94
+ * Off by default and free when off — a trace on every tool call is a cost on the hot path.
95
+ */
96
+ readonly TRACE: "RETICLE_TRACE";
97
+ /**
98
+ * How many consecutive reconnects the MCP proxy attempts before it stops retrying and goes
99
+ * dormant. Overridable for the same reason the idle windows are: the real budget takes MINUTES to
100
+ * exhaust, so the one spec that proves the proxy SURVIVES exhaustion could not run at all without
101
+ * shortening it. A budget nobody can reach in a test is a budget nobody tests.
102
+ */
103
+ readonly RECONNECT_ATTEMPTS: "RETICLE_RECONNECT_ATTEMPTS";
67
104
  };
68
105
  /** Hard transport bounds shared by the browser and bridge. */
69
106
  export declare const TRANSPORT_LIMITS: {
@@ -99,6 +136,13 @@ export declare const TRANSPORT_LIMITS: {
99
136
  export declare const REDACTED_VALUE = "[REDACTED]";
100
137
  /** Explicit opt-in argument required for potentially destructive actions. */
101
138
  export declare const DANGEROUS_ACTION_CONFIRM_ARG = "confirmDangerous";
139
+ /**
140
+ * Opt-in argument for a TRUSTED native click, for the handlers a synthetic one cannot satisfy —
141
+ * file pickers, clipboard, anything gated on `isTrusted`. Only `reticle_act` can honour it: the
142
+ * native driver is a pointer gesture at coordinates, and the act-then-wait tool drives the page
143
+ * through the SDK instead.
144
+ */
145
+ export declare const NATIVE_INPUT_ARG = "native";
102
146
  /** Schema version stamped onto compiled replay programs. */
103
147
  export declare const REPLAY_PROGRAM_VERSION = 1;
104
148
  /** The git-checked Reticle workspace directory + its layout. No free strings. */
@@ -368,6 +412,14 @@ export declare const InputModeReason: {
368
412
  readonly DRAG_TARGET_UNRESOLVED: "drag-target-unresolved";
369
413
  readonly PROVIDER_DECLINED: "provider-declined";
370
414
  readonly PROVIDER_ERROR: "provider-error";
415
+ /**
416
+ * No real-input provider is configured at all, and the caller explicitly asked for one with
417
+ * `native:true`. Only emitted on that explicit ask: without a provider EVERY action is synthetic,
418
+ * so annotating all of them would put a reason on the most-used tool in the product for no gain.
419
+ * An agent that asked for a trusted click, though, has an expectation to correct — and this is
420
+ * permanent for the session, not a transient downgrade, so it should stop asking.
421
+ */
422
+ readonly NOT_CONFIGURED: "real-input-not-configured-for-this-session";
371
423
  };
372
424
  export type InputModeReason = (typeof InputModeReason)[keyof typeof InputModeReason];
373
425
  /** Best-effort caveats attached to action results so the agent can interpret a no-op. */
@@ -393,6 +445,14 @@ export type DriveErrorCode = (typeof DriveErrorCode)[keyof typeof DriveErrorCode
393
445
  /** Human-facing message when the optional playwright dep is absent. */
394
446
  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";
395
447
  /** Actions the executor can perform against a ref (plan/03 + plan/05). */
448
+ /**
449
+ * The console levels an agent can filter by, DERIVED from the console EventTypes rather than
450
+ * retyped. `reticle_console { level }` matches by building `console.${level}`, so any list written
451
+ * out by hand is one rename away from filtering everything into an empty result — which reads as
452
+ * "no errors on this page".
453
+ */
454
+ export declare const CONSOLE_LEVEL_PREFIX = "console.";
455
+ export declare const CONSOLE_LEVELS: string[];
396
456
  export declare const ActionType: {
397
457
  readonly CLICK: "click";
398
458
  readonly DBLCLICK: "dblclick";
@@ -436,6 +496,14 @@ export interface ComponentStateResult {
436
496
  component?: string;
437
497
  /** Positional, JSON-safe hook states. */
438
498
  hooks?: unknown[];
499
+ /**
500
+ * Present ONLY when `hooks` is a PROJECTION — effect entries were removed. A trim is never silent:
501
+ * without this, a hook list short by three entries reads as the component's complete hook list.
502
+ */
503
+ truncation?: {
504
+ droppedItems: number;
505
+ note: string;
506
+ };
439
507
  }
440
508
  /** Element states the assertion engine can check (plan/06). */
441
509
  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,43 @@ 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',
78
+ /**
79
+ * How often the daemon writes `reticle_daemon_alive`, so a GAP in its log is evidence it died.
80
+ *
81
+ * Overridable for the same reason the idle windows are: a spec that has to prove "a killed daemon
82
+ * is distinguishable from a tidy one" cannot wait 30 seconds per beat, and a spec that instead
83
+ * re-implements the cadence is insensitive to the thing it claims to guard.
84
+ */
85
+ HEARTBEAT: 'RETICLE_HEARTBEAT_MS',
65
86
  /** Directory holding the auto-provisioned pairing token. Defaults to ~/.reticle; relocatable for CI. */
66
87
  PAIRING_TOKEN_DIR: 'RETICLE_PAIRING_TOKEN_DIR',
67
88
  /** Force the durable causal journal off (`0`/`false`/`off`) or on (`1`/`true`/`on`); default on. */
68
89
  JOURNAL: 'RETICLE_JOURNAL',
90
+ /**
91
+ * Verbose internal flow tracing for people working ON Reticle (`1`/`true`/`on`); default off.
92
+ *
93
+ * Distinct from the journal, which records what the AGENT did to the app. This records what
94
+ * RETICLE did to answer it: one line per internal stage, with its duration and nesting, so a
95
+ * developer can see which code a tool call actually went through and where the time went.
96
+ * Off by default and free when off — a trace on every tool call is a cost on the hot path.
97
+ */
98
+ TRACE: 'RETICLE_TRACE',
99
+ /**
100
+ * How many consecutive reconnects the MCP proxy attempts before it stops retrying and goes
101
+ * dormant. Overridable for the same reason the idle windows are: the real budget takes MINUTES to
102
+ * exhaust, so the one spec that proves the proxy SURVIVES exhaustion could not run at all without
103
+ * shortening it. A budget nobody can reach in a test is a budget nobody tests.
104
+ */
105
+ RECONNECT_ATTEMPTS: 'RETICLE_RECONNECT_ATTEMPTS',
69
106
  };
70
107
  /** Hard transport bounds shared by the browser and bridge. */
71
108
  export const TRANSPORT_LIMITS = {
@@ -101,6 +138,13 @@ export const TRANSPORT_LIMITS = {
101
138
  export const REDACTED_VALUE = '[REDACTED]';
102
139
  /** Explicit opt-in argument required for potentially destructive actions. */
103
140
  export const DANGEROUS_ACTION_CONFIRM_ARG = 'confirmDangerous';
141
+ /**
142
+ * Opt-in argument for a TRUSTED native click, for the handlers a synthetic one cannot satisfy —
143
+ * file pickers, clipboard, anything gated on `isTrusted`. Only `reticle_act` can honour it: the
144
+ * native driver is a pointer gesture at coordinates, and the act-then-wait tool drives the page
145
+ * through the SDK instead.
146
+ */
147
+ export const NATIVE_INPUT_ARG = 'native';
104
148
  /** Schema version stamped onto compiled replay programs. */
105
149
  export const REPLAY_PROGRAM_VERSION = 1;
106
150
  /** The git-checked Reticle workspace directory + its layout. No free strings. */
@@ -367,6 +411,14 @@ export const InputModeReason = {
367
411
  DRAG_TARGET_UNRESOLVED: 'drag-target-unresolved', // drag toRef missing or not locatable
368
412
  PROVIDER_DECLINED: 'provider-declined', // provider chose not to perform
369
413
  PROVIDER_ERROR: 'provider-error', // provider threw → fell back to synthetic
414
+ /**
415
+ * No real-input provider is configured at all, and the caller explicitly asked for one with
416
+ * `native:true`. Only emitted on that explicit ask: without a provider EVERY action is synthetic,
417
+ * so annotating all of them would put a reason on the most-used tool in the product for no gain.
418
+ * An agent that asked for a trusted click, though, has an expectation to correct — and this is
419
+ * permanent for the session, not a transient downgrade, so it should stop asking.
420
+ */
421
+ NOT_CONFIGURED: 'real-input-not-configured-for-this-session',
370
422
  };
371
423
  /** Best-effort caveats attached to action results so the agent can interpret a no-op. */
372
424
  export const ActionWarning = {
@@ -389,6 +441,19 @@ export const DriveErrorCode = {
389
441
  /** Human-facing message when the optional playwright dep is absent. */
390
442
  export const DRIVE_PLAYWRIGHT_MISSING_MSG = "reticle drive needs the optional 'playwright' package — install it: pnpm add -D playwright && npx playwright install chromium";
391
443
  /** Actions the executor can perform against a ref (plan/03 + plan/05). */
444
+ /**
445
+ * The console levels an agent can filter by, DERIVED from the console EventTypes rather than
446
+ * retyped. `reticle_console { level }` matches by building `console.${level}`, so any list written
447
+ * out by hand is one rename away from filtering everything into an empty result — which reads as
448
+ * "no errors on this page".
449
+ */
450
+ export const CONSOLE_LEVEL_PREFIX = 'console.';
451
+ export const CONSOLE_LEVELS = [
452
+ EventType.CONSOLE_LOG,
453
+ EventType.CONSOLE_WARN,
454
+ EventType.CONSOLE_ERROR,
455
+ EventType.CONSOLE_INFO,
456
+ ].map((type) => type.slice(CONSOLE_LEVEL_PREFIX.length));
392
457
  export const ActionType = {
393
458
  CLICK: 'click',
394
459
  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))
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The high-volume, low-signal floor. These fire continuously on any live page and are the ONLY
3
+ * thing that should be sacrificed when a buffer is full. Everything else is scarce evidence a
4
+ * verdict depends on. Shared by the browser transport queue and the server ring buffer so both
5
+ * eviction policies agree on what to sacrifice.
6
+ */
7
+ export declare const CHURN_TYPES: ReadonlySet<string>;
@@ -0,0 +1,15 @@
1
+ import { EventType } from './constants.js';
2
+ /**
3
+ * The high-volume, low-signal floor. These fire continuously on any live page and are the ONLY
4
+ * thing that should be sacrificed when a buffer is full. Everything else is scarce evidence a
5
+ * verdict depends on. Shared by the browser transport queue and the server ring buffer so both
6
+ * eviction policies agree on what to sacrifice.
7
+ */
8
+ export const CHURN_TYPES = new Set([
9
+ EventType.DOM_TEXT,
10
+ EventType.ANIM_START,
11
+ EventType.ANIM_END,
12
+ EventType.RENDER_COMMIT,
13
+ EventType.PAGE_HEALTH,
14
+ EventType.SCROLL_POSITION,
15
+ ]);
@@ -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;
@@ -1350,3 +1357,19 @@ export interface FlowHealResult {
1350
1357
  };
1351
1358
  }
1352
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
@@ -9,6 +9,7 @@
9
9
  */
10
10
  export * from './constants.js';
11
11
  export * from './source-constants.js';
12
+ export * from './event-classification.js';
12
13
  export * from './verified-constants.js';
13
14
  export * from './session-constants.js';
14
15
  export * from './messages.js';
@@ -22,6 +23,7 @@ export * from './net.js';
22
23
  export * from './findings.js';
23
24
  export * from './desktop-contract.js';
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
  export * from './daemon-registry.js';
@@ -33,3 +35,4 @@ export * from './upgrade.js';
33
35
  export * from './telemetry.js';
34
36
  export * from './telemetry-session.js';
35
37
  export * from './telemetry-feedback.js';
38
+ export { CONTRACT_FINGERPRINT, fingerprintOf } from './contract-fingerprint.js';
package/dist/index.js CHANGED
@@ -10,6 +10,7 @@
10
10
  // ── STABLE public surface: the wire/domain contract ──────────────────────────────────────────────
11
11
  export * from './constants.js'; // EventType, ActionType, wire constants, TRANSPORT_LIMITS, …
12
12
  export * from './source-constants.js'; // DATA_RETICLE_SOURCE_ATTR, RETICLE_ROOT_GLOBAL
13
+ export * from './event-classification.js'; // CHURN_TYPES — shared eviction priority for buffer/queue
13
14
  export * from './verified-constants.js'; // Verified — the one field an agent gates on
14
15
  export * from './session-constants.js';
15
16
  export * from './messages.js'; // ReticleEvent + the message schemas
@@ -23,6 +24,7 @@ export * from './net.js'; // NetInitiator / ipc:// scheme — network + desktop-
23
24
  export * from './findings.js'; // crawl anomalies + cross-channel contradictions
24
25
  export * from './desktop-contract.js'; // the Electron preload/main/renderer/daemon string contract
25
26
  export * from './consequence.js';
27
+ export * from './project-id.js';
26
28
  export * from './notices.js';
27
29
  export * from './journal.js';
28
30
  // ── INTERNAL cross-package plumbing (shared impl; not a stable outside API — may change in a minor) ─
@@ -35,3 +37,4 @@ export * from './upgrade.js'; // self-update policy shared by the CLI
35
37
  export * from './telemetry.js';
36
38
  export * from './telemetry-session.js'; // the session/project rollup payloads
37
39
  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)
40
+ 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;