@reticlehq/core 2.5.0 → 2.7.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.
package/dist/telemetry.js CHANGED
@@ -18,7 +18,7 @@
18
18
  import { z } from 'zod';
19
19
  import { MachineSnapshotSchema, ProjectProfileSchema, SessionSummarySchema, } from './telemetry-session.js';
20
20
  import { BrowserBrand, FeedbackSchema } from './telemetry-feedback.js';
21
- import { VerifiedReason } from './verified-constants.js';
21
+ import { CaptureLoss, VerifiedReason } from './verified-constants.js';
22
22
  import { IdentitySchema } from './telemetry-feedback.js';
23
23
  /** Bump when the event shape changes so the analytics side can segment old senders. */
24
24
  export const TELEMETRY_EVENT_VERSION = 3;
@@ -108,6 +108,26 @@ export const TelemetryEventKind = {
108
108
  * identical to healthy usage in every other metric.
109
109
  */
110
110
  MCP_CLIENT_CONNECTED: 'mcp_client_connected',
111
+ /**
112
+ * An app carrying the SDK connected to this daemon for the first time in its life.
113
+ *
114
+ * THE funnel step, and the one nothing could measure. Reticle's install has two halves — register
115
+ * the MCP server so the agent has the tools, and get the SDK into a running page so there is
116
+ * something for those tools to look at — and they are done at different times, by different
117
+ * commands, often in different directories. Almost everyone completes the first. The second is
118
+ * where the users go.
119
+ *
120
+ * Everything that existed before answered a different question. `daemon_started` and
121
+ * `mcp_client_connected` describe the agent half only. `session_appConnects` describes the app
122
+ * half but is a WINDOW counter: it resets on every flush, so a user whose app connected in one
123
+ * window reads zero in every other, and the population it under-counts is exactly the population
124
+ * being measured. A funnel built on it reported fewer instrumented users than there were users
125
+ * calling tools, which is impossible on its face and was the first sign the field was unusable.
126
+ *
127
+ * Fired ONCE per daemon run, on the first connect only — so `daemon_started` → `app_instrumented`
128
+ * is a real rate rather than an inference, and a reconnecting page cannot inflate it.
129
+ */
130
+ APP_INSTRUMENTED: 'app_instrumented',
111
131
  /**
112
132
  * The agent LOST its Reticle tools — the worst thing this product does to anyone, and until now
113
133
  * completely invisible in the field.
@@ -160,6 +180,7 @@ const SESSION_SCOPED = new Set([
160
180
  TelemetryEventKind.DAEMON_STOPPED,
161
181
  TelemetryEventKind.SESSION_PROGRESS,
162
182
  TelemetryEventKind.MCP_CLIENT_CONNECTED,
183
+ TelemetryEventKind.APP_INSTRUMENTED,
163
184
  TelemetryEventKind.PROJECT_PROFILED,
164
185
  TelemetryEventKind.VERIFICATION_COMPLETED,
165
186
  TelemetryEventKind.BUG_FOUND,
@@ -186,14 +207,24 @@ export const TelemetryActor = {
186
207
  * What `projectId` was derived from — and therefore whether it is comparable ACROSS machines.
187
208
  *
188
209
  * This is the field that keeps "how many users share this project" from silently lying. A
189
- * cwd-derived id is unique per machine, so those rows always show exactly one user per project. Left
210
+ * path-derived id is unique per machine, so those rows always show exactly one user per project. Left
190
211
  * unlabelled they would drag the average toward 1 and hide real team adoption; labelled, the
191
212
  * analytics can restrict that question to `git_origin` rows, where it is a real measurement.
213
+ *
214
+ * The three non-origin sources are ordered by how stable they are WITHIN one machine, which is the
215
+ * property the funnel actually needs: `init` runs in the app directory and the daemon is spawned from
216
+ * wherever the agent's client happens to sit, so an id that changes with the working directory
217
+ * severs the two halves of the funnel. Only `cwd` has that defect, and it is now the last resort
218
+ * rather than the first fallback — the field showed many ids minted for a single project.
192
219
  */
193
220
  export const ProjectIdSource = {
194
221
  /** Hash of the shared git origin — the same on every clone, so cross-machine counting is valid. */
195
222
  GIT_ORIGIN: 'git_origin',
196
- /** Hash of the local directory path — unique per machine; NOT comparable across users. */
223
+ /** Hash of the repo ROOT path — machine-local, but the same for every directory inside the repo. */
224
+ GIT_ROOT: 'git_root',
225
+ /** Hash of the nearest package.json's directory — machine-local; used when there is no git at all. */
226
+ PACKAGE_ROOT: 'package_root',
227
+ /** Hash of the raw working directory — the last resort, and the only source that is NOT stable. */
197
228
  CWD: 'cwd',
198
229
  };
199
230
  /**
@@ -257,6 +288,18 @@ export const VerificationSchema = z.object({
257
288
  * no clause behind it, and an older SDK reports none. Absent means unclassified, never guessed.
258
289
  */
259
290
  reason: z.nativeEnum(VerifiedReason).optional(),
291
+ /**
292
+ * WHAT was lost, when `reason` is `unclean_capture` — see `CaptureLoss`.
293
+ *
294
+ * The three causes belong to three different owners and need three different fixes, and without
295
+ * this they are one bar. The one time we had to answer it the data could not, and the answer
296
+ * turned out to be that our own eviction counter was miscounting.
297
+ *
298
+ * ONE value, not a list: `losses` can hold several and a multi-value property is not something a
299
+ * dashboard can group by, so the FIRST is sent and the order in the producers is the order of
300
+ * ownership — ours before the page's. Absent on every verdict whose capture was clean.
301
+ */
302
+ uncleanLoss: z.nativeEnum(CaptureLoss).optional(),
260
303
  });
261
304
  /** Which way the installed version moved, and between which versions. */
262
305
  export const VersionChangeSchema = z.object({
@@ -283,6 +326,17 @@ export const VersionChangeSchema = z.object({
283
326
  * give the hash a meaning, while keeping the line that matters: our code and our failure, never the
284
327
  * user's code and never their data.
285
328
  */
329
+ /**
330
+ * Whether a failed connection was aimed at a port Reticle itself uses.
331
+ *
332
+ * An enum rather than the number, because the number is the reporter's and the answer is ours: all
333
+ * anyone needs to know is whose problem it is. Refused on a Reticle port is a lifecycle problem —
334
+ * a daemon that is not up; refused anywhere else is somebody else's service.
335
+ */
336
+ export const CrashPort = {
337
+ RETICLE: 'reticle',
338
+ OTHER: 'other',
339
+ };
286
340
  export const CrashSchema = z.object({
287
341
  /** `uncaught_exception` | `unhandled_rejection`. */
288
342
  kind: z.string().min(1).max(32),
@@ -325,6 +379,34 @@ export const CrashSchema = z.object({
325
379
  * trace and are completely different problems; this is what tells them apart.
326
380
  */
327
381
  machine: MachineSnapshotSchema.optional(),
382
+ /**
383
+ * The failing SYSCALL — `connect`, `write`, `open`. Already inside `message`; structured here so
384
+ * it can be grouped on rather than parsed back out of prose.
385
+ */
386
+ syscall: z.string().max(32).optional(),
387
+ /**
388
+ * The symbolic errno — `ECONNREFUSED`, `EPIPE`. The name, never the platform-specific number.
389
+ */
390
+ errno: z.string().max(32).optional(),
391
+ /**
392
+ * Was the target the machine it was running on?
393
+ *
394
+ * One bit, and it splits two populations that currently look identical and have different owners:
395
+ * refused ON loopback is a Reticle-lifecycle problem (no daemon), refused off-box is a network
396
+ * problem that is not ours.
397
+ */
398
+ loopback: z.boolean().optional(),
399
+ /** Whether the port was one of ours, as an enum. The number itself is never sent. */
400
+ port: z.enum([CrashPort.RETICLE, CrashPort.OTHER]).optional(),
401
+ /**
402
+ * The innermost frame naming NODE's own source — `node:net:1637`.
403
+ *
404
+ * Only present when the crash is a system error AND no Reticle frame survived, which is exactly
405
+ * the report that otherwise arrives with no location at all. It is a line in Node's published
406
+ * source: it says a connect failed rather than a DNS lookup, and carries nothing about the
407
+ * machine, the app, or anyone's directory layout.
408
+ */
409
+ internalFrame: z.string().max(64).optional(),
328
410
  });
329
411
  /**
330
412
  * How Reticle came to find a defect. Four routes, in descending order of "a human would have missed
@@ -425,6 +507,22 @@ export const McpConnectionSchema = z.object({
425
507
  /** Which client, from its own handshake (`claude-code`, `cursor`). */
426
508
  client: z.string().min(1).max(64).optional(),
427
509
  });
510
+ /**
511
+ * `app_instrumented`: an app carrying the SDK reached this daemon for the first time.
512
+ *
513
+ * The install has two halves — the MCP server registered so the agent has the tools, and the SDK
514
+ * loaded by a running page so there is something to look at — and this is the only signal for the
515
+ * second. Deliberately carries NO stack and no framework: `project_profiled` already reports both
516
+ * for the same daemon run, and the two join on `sessionId`.
517
+ */
518
+ export const AppInstrumentationSchema = z.object({
519
+ /** Whether `reticle init` had been run in this directory (a projectId is stamped). */
520
+ initialized: z.boolean(),
521
+ /** Whether an MCP client was already attached when the app arrived. */
522
+ agentAttached: z.boolean(),
523
+ /** How long the daemon had been up. Large values mean Reticle sat there with nothing wired. */
524
+ msToFirstApp: z.number().int().nonnegative(),
525
+ });
428
526
  /**
429
527
  * WHICH stage of an MCP outage this is. Reported at most twice per proxy process, and the two are
430
528
  * different facts: `first` says the session lost its tools at all, `budget_spent` says the proxy
@@ -467,6 +565,18 @@ export const McpOutageSchema = z.object({
467
565
  reason: z.nativeEnum(OutageReason),
468
566
  /** Consecutive reconnects tried when this was reported. `first` is near 1; a spent budget is high. */
469
567
  attempts: z.number().int().nonnegative(),
568
+ /**
569
+ * In-flight tool calls this drop actually killed — the only part an agent can FEEL.
570
+ *
571
+ * Without it every drop looks equally bad. In the field almost every outage was
572
+ * `stage: first` with `attempts: 1`** — the stream ended once and the proxy reconnected, which for
573
+ * an agent with nothing in flight is invisible. Reading that 321 as "the agent lost its tools 321
574
+ * times" overstates the problem by roughly the whole number, and buries the one drop that mattered.
575
+ *
576
+ * Zero means nobody noticed. Non-zero is the number of calls that came back `-32001` and the count
577
+ * worth driving down.
578
+ */
579
+ pendingLost: z.number().int().nonnegative().optional(),
470
580
  });
471
581
  /** How `reticle init` went. The onboarding funnel, which had no instrumentation whatsoever. */
472
582
  export const InitOutcomeSchema = z.object({
@@ -558,4 +668,6 @@ export const TelemetryEventSchema = z.object({
558
668
  bug: BugFoundSchema.optional(),
559
669
  /** Only on `mcp_connection_lost`: which stage of the outage, why, and after how many retries. */
560
670
  outage: McpOutageSchema.optional(),
671
+ /** Only on `app_instrumented`: the install's second half finally happening. */
672
+ instrumentation: AppInstrumentationSchema.optional(),
561
673
  });
package/dist/types.d.ts CHANGED
@@ -44,6 +44,16 @@ export declare const ElementQuerySchema: z.ZodObject<{
44
44
  }>>;
45
45
  /** CSS selector or ref to scope the search. */
46
46
  scope: z.ZodOptional<z.ZodString>;
47
+ /**
48
+ * Return the `scope` element ITSELF rather than searching inside it.
49
+ *
50
+ * Every other path excludes the scope root by construction, so a layout container with no role,
51
+ * name, testid or text of its own was unreachable — and that is routinely the element carrying the
52
+ * handler. Reported from the field: "click the empty region of this row" is an ordinary user
53
+ * action (dismiss, deselect, close, marquee-select) that could not be expressed at all, and the
54
+ * verification was handed back to the human. Requires `scope`.
55
+ */
56
+ self: z.ZodOptional<z.ZodBoolean>;
47
57
  }, "strip", z.ZodTypeAny, {
48
58
  testid?: string | undefined;
49
59
  role?: string | undefined;
@@ -62,6 +72,7 @@ export declare const ElementQuerySchema: z.ZodObject<{
62
72
  by?: "testid" | "role" | "component" | "text" | "label" | "placeholder" | "alt" | undefined;
63
73
  attrs?: string[] | undefined;
64
74
  scope?: string | undefined;
75
+ self?: boolean | undefined;
65
76
  }, {
66
77
  testid?: string | undefined;
67
78
  role?: string | undefined;
@@ -80,6 +91,7 @@ export declare const ElementQuerySchema: z.ZodObject<{
80
91
  by?: "testid" | "role" | "component" | "text" | "label" | "placeholder" | "alt" | undefined;
81
92
  attrs?: string[] | undefined;
82
93
  scope?: string | undefined;
94
+ self?: boolean | undefined;
83
95
  }>;
84
96
  export type ElementQuery = z.infer<typeof ElementQuerySchema>;
85
97
  /** Compact semantic descriptor of one element surfaced to the agent. */
package/dist/types.js CHANGED
@@ -26,6 +26,16 @@ export const ElementQuerySchema = z.object({
26
26
  .optional(),
27
27
  /** CSS selector or ref to scope the search. */
28
28
  scope: z.string().optional(),
29
+ /**
30
+ * Return the `scope` element ITSELF rather than searching inside it.
31
+ *
32
+ * Every other path excludes the scope root by construction, so a layout container with no role,
33
+ * name, testid or text of its own was unreachable — and that is routinely the element carrying the
34
+ * handler. Reported from the field: "click the empty region of this row" is an ordinary user
35
+ * action (dismiss, deselect, close, marquee-select) that could not be expressed at all, and the
36
+ * verification was handed back to the human. Requires `scope`.
37
+ */
38
+ self: z.boolean().optional(),
29
39
  });
30
40
  /** One named flow advertised by the app (mirrors the browser CapabilityFlow). */
31
41
  export const CapabilityFlowSchema = z.object({
@@ -24,7 +24,7 @@ export type Verified = (typeof Verified)[keyof typeof Verified];
24
24
  /**
25
25
  * WHY a verdict came out the way it did — the deciding clause of the rule, named.
26
26
  *
27
- * `Verified` has three values and the rule has ten clauses, so the wire collapsed opposite facts
27
+ * `Verified` has three values and the rule has eleven clauses, so the wire collapsed opposite facts
28
28
  * into one string. Measured over a real session: `unknown` covered "the agent malformed the call",
29
29
  * "the app answered 202 and has not finished", and "Reticle could not see the capture" — three
30
30
  * owners needing three opposite responses, one bar on a dashboard. `no` was no better: "channels
@@ -38,6 +38,22 @@ export type Verified = (typeof Verified)[keyof typeof Verified];
38
38
  export declare const VerifiedReason: {
39
39
  /** The assertion was never EVALUATED — under-specified call, or nothing instrumented to read. */
40
40
  readonly INCONCLUSIVE: "inconclusive";
41
+ /**
42
+ * The tab went away mid-wait, so the action's outcome was never observed. NOT a failure.
43
+ *
44
+ * This existed as a fact and had nowhere to go. `waitForPredicate` finishes a disconnected wait
45
+ * with `{ pass: false, failureReason: 'session disconnected' }`, and the only clause that took a
46
+ * false `pass` said ASSERTION_FAILED — so a reload during a wait produced, verbatim:
47
+ *
48
+ * verified: "no", verifiedReason: "assertion_failed",
49
+ * because: "the declared consequence did not hold", source: "src/components/Counter.tsx:18"
50
+ *
51
+ * The app was fine; the observer left. An agent reading that goes and edits Counter.tsx. Every
52
+ * other clause in this rule is tuned to avoid claiming more than was observed, and the absence of
53
+ * this member made the nearest available answer a false claim in the opposite direction — a false
54
+ * RED, from the layer whose entire job is not to produce one.
55
+ */
56
+ readonly OBSERVATION_LOST: "observation_lost";
41
57
  /** The declared consequence did not hold. */
42
58
  readonly ASSERTION_FAILED: "assertion_failed";
43
59
  /** Channels disagreed about the action — the false green this product exists to catch. */
@@ -58,6 +74,29 @@ export declare const VerifiedReason: {
58
74
  readonly PROVED: "proved";
59
75
  };
60
76
  export type VerifiedReason = (typeof VerifiedReason)[keyof typeof VerifiedReason];
77
+ /**
78
+ * WHAT made a capture unclean — the closed vocabulary behind `UNCLEAN_CAPTURE`.
79
+ *
80
+ * `unclean_capture` names three losses that belong to three different owners and need three
81
+ * different fixes: our server buffer, our browser transport, and a boundary in the page that nobody
82
+ * can see through. Until this existed they arrived as one value on a dashboard and as one sentence
83
+ * of free prose in `integrity.issues`, which is not something a query can group by.
84
+ *
85
+ * That cost real time. `unclean_capture` became a large share of all `unknown` verdicts in the
86
+ * field, and answering "which of the three?" took reading the eviction policy, because the data
87
+ * could not say. It was the first one, and it was a false alarm.
88
+ */
89
+ export declare const CaptureLoss: {
90
+ /** The server ring buffer evicted scarce evidence that belonged to the observation window. */
91
+ readonly BUFFER_LOSS: "buffer_loss";
92
+ /** The browser-side queue overflowed, so part of the window never reached the daemon at all. */
93
+ readonly TRANSPORT_GAP: "transport_gap";
94
+ /** A region the SDK cannot see through — a cross-origin frame, a closed shadow root. */
95
+ readonly BLIND_SPOT: "blind_spot";
96
+ /** A loss we have not classified. A classifier that cannot say "I don't know" lies instead. */
97
+ readonly OTHER: "other";
98
+ };
99
+ export type CaptureLoss = (typeof CaptureLoss)[keyof typeof CaptureLoss];
61
100
  /**
62
101
  * Actionable companion to NO_PROVIDER for the tools that genuinely intercept or capture through CDP
63
102
  * — network mocking and viewport control — which is NOT "visual capture".
@@ -23,7 +23,7 @@ export const Verified = {
23
23
  /**
24
24
  * WHY a verdict came out the way it did — the deciding clause of the rule, named.
25
25
  *
26
- * `Verified` has three values and the rule has ten clauses, so the wire collapsed opposite facts
26
+ * `Verified` has three values and the rule has eleven clauses, so the wire collapsed opposite facts
27
27
  * into one string. Measured over a real session: `unknown` covered "the agent malformed the call",
28
28
  * "the app answered 202 and has not finished", and "Reticle could not see the capture" — three
29
29
  * owners needing three opposite responses, one bar on a dashboard. `no` was no better: "channels
@@ -37,6 +37,22 @@ export const Verified = {
37
37
  export const VerifiedReason = {
38
38
  /** The assertion was never EVALUATED — under-specified call, or nothing instrumented to read. */
39
39
  INCONCLUSIVE: 'inconclusive',
40
+ /**
41
+ * The tab went away mid-wait, so the action's outcome was never observed. NOT a failure.
42
+ *
43
+ * This existed as a fact and had nowhere to go. `waitForPredicate` finishes a disconnected wait
44
+ * with `{ pass: false, failureReason: 'session disconnected' }`, and the only clause that took a
45
+ * false `pass` said ASSERTION_FAILED — so a reload during a wait produced, verbatim:
46
+ *
47
+ * verified: "no", verifiedReason: "assertion_failed",
48
+ * because: "the declared consequence did not hold", source: "src/components/Counter.tsx:18"
49
+ *
50
+ * The app was fine; the observer left. An agent reading that goes and edits Counter.tsx. Every
51
+ * other clause in this rule is tuned to avoid claiming more than was observed, and the absence of
52
+ * this member made the nearest available answer a false claim in the opposite direction — a false
53
+ * RED, from the layer whose entire job is not to produce one.
54
+ */
55
+ OBSERVATION_LOST: 'observation_lost',
40
56
  /** The declared consequence did not hold. */
41
57
  ASSERTION_FAILED: 'assertion_failed',
42
58
  /** Channels disagreed about the action — the false green this product exists to catch. */
@@ -56,6 +72,28 @@ export const VerifiedReason = {
56
72
  /** Held at a real grade over a clean capture with no channel disagreeing. */
57
73
  PROVED: 'proved',
58
74
  };
75
+ /**
76
+ * WHAT made a capture unclean — the closed vocabulary behind `UNCLEAN_CAPTURE`.
77
+ *
78
+ * `unclean_capture` names three losses that belong to three different owners and need three
79
+ * different fixes: our server buffer, our browser transport, and a boundary in the page that nobody
80
+ * can see through. Until this existed they arrived as one value on a dashboard and as one sentence
81
+ * of free prose in `integrity.issues`, which is not something a query can group by.
82
+ *
83
+ * That cost real time. `unclean_capture` became a large share of all `unknown` verdicts in the
84
+ * field, and answering "which of the three?" took reading the eviction policy, because the data
85
+ * could not say. It was the first one, and it was a false alarm.
86
+ */
87
+ export const CaptureLoss = {
88
+ /** The server ring buffer evicted scarce evidence that belonged to the observation window. */
89
+ BUFFER_LOSS: 'buffer_loss',
90
+ /** The browser-side queue overflowed, so part of the window never reached the daemon at all. */
91
+ TRANSPORT_GAP: 'transport_gap',
92
+ /** A region the SDK cannot see through — a cross-origin frame, a closed shadow root. */
93
+ BLIND_SPOT: 'blind_spot',
94
+ /** A loss we have not classified. A classifier that cannot say "I don't know" lies instead. */
95
+ OTHER: 'other',
96
+ };
59
97
  /**
60
98
  * Actionable companion to NO_PROVIDER for the tools that genuinely intercept or capture through CDP
61
99
  * — network mocking and viewport control — which is NOT "visual capture".
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reticlehq/core",
3
- "version": "2.5.0",
3
+ "version": "2.7.0",
4
4
  "description": "The Reticle foundation: the shared wire contract — types, zod schemas, constants, messages, and the isomorphic kernel that every Reticle package (browser SDK, server, kits, test harness) imports. Depends only on zod.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",