@reticlehq/core 2.7.0 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -105,7 +105,30 @@ export declare const ReticleEnv: {
105
105
  /** Hard transport bounds shared by the browser and bridge. */
106
106
  export declare const TRANSPORT_LIMITS: {
107
107
  readonly MAX_MESSAGE_BYTES: number;
108
- readonly MAX_MESSAGES_PER_SECOND: 1000;
108
+ /**
109
+ * Inbound events per second before the bridge SAMPLES rather than records everything.
110
+ *
111
+ * This was 1000, and an ordinary React app with an active query cache blew through it: the
112
+ * reporter's FIRST `act_and_wait` of the session came back `unknown` with `unclean_capture` and a
113
+ * four-figure drop count, and setting the env override to twenty times the default fixed it (#316).
114
+ * Reticle was right to refuse the verdict — a sampled window cannot support one, and the guard that
115
+ * catches false greens is blindest exactly there — but landing that on the first drive after an
116
+ * install, recoverable only by knowing an environment variable exists and inventing a number for
117
+ * it, is the worst possible place to spend the honesty.
118
+ *
119
+ * 20000 is the value that was measured to work on the page that reported it. The cap exists to stop
120
+ * a PATHOLOGICAL page (an animation loop firing DOM mutations every frame), not to throttle a busy
121
+ * one, and the ceiling it has to defend is cheap: the daemon is on the same machine and a typical
122
+ * event is a few hundred bytes, so this is single-digit MB/s over loopback.
123
+ *
124
+ * Raising it does not raise what a runaway page can make the bridge HOLD, and that separation is
125
+ * what makes the change safe. Memory is bounded independently by the ring buffer, which evicts on
126
+ * `RING_BUFFER_DEFAULTS.MAX_BYTES` (this same constant, reached through that alias) as well as on
127
+ * a count and an age. Grep for `MAX_BUFFER_BYTES` alone and it looks like a constant nobody reads,
128
+ * which is exactly the wrong conclusion to draw before touching this number: the rate cap defends
129
+ * parse cost, the ring buffer defends memory, and they are not substitutes.
130
+ */
131
+ readonly MAX_MESSAGES_PER_SECOND: 20000;
109
132
  readonly MAX_SESSIONS: 32;
110
133
  readonly MAX_PENDING_CONNECTIONS: 16;
111
134
  readonly HELLO_TIMEOUT_MS: 5000;
@@ -191,6 +214,7 @@ export declare const VisualReason: {
191
214
  readonly BASELINE_MISSING: "baseline-missing";
192
215
  readonly DIMENSION_MISMATCH: "dimension-mismatch";
193
216
  readonly FULL_PAGE_UNSUPPORTED: "full-page-unsupported";
217
+ readonly NOT_COMPOSITED: "window-not-composited";
194
218
  };
195
219
  export type VisualReason = (typeof VisualReason)[keyof typeof VisualReason];
196
220
  /** Actionable companion to NO_PROVIDER — the visual layer needs a driven browser. */
package/dist/constants.js CHANGED
@@ -107,7 +107,30 @@ export const ReticleEnv = {
107
107
  /** Hard transport bounds shared by the browser and bridge. */
108
108
  export const TRANSPORT_LIMITS = {
109
109
  MAX_MESSAGE_BYTES: 1024 * 1024,
110
- MAX_MESSAGES_PER_SECOND: 1000,
110
+ /**
111
+ * Inbound events per second before the bridge SAMPLES rather than records everything.
112
+ *
113
+ * This was 1000, and an ordinary React app with an active query cache blew through it: the
114
+ * reporter's FIRST `act_and_wait` of the session came back `unknown` with `unclean_capture` and a
115
+ * four-figure drop count, and setting the env override to twenty times the default fixed it (#316).
116
+ * Reticle was right to refuse the verdict — a sampled window cannot support one, and the guard that
117
+ * catches false greens is blindest exactly there — but landing that on the first drive after an
118
+ * install, recoverable only by knowing an environment variable exists and inventing a number for
119
+ * it, is the worst possible place to spend the honesty.
120
+ *
121
+ * 20000 is the value that was measured to work on the page that reported it. The cap exists to stop
122
+ * a PATHOLOGICAL page (an animation loop firing DOM mutations every frame), not to throttle a busy
123
+ * one, and the ceiling it has to defend is cheap: the daemon is on the same machine and a typical
124
+ * event is a few hundred bytes, so this is single-digit MB/s over loopback.
125
+ *
126
+ * Raising it does not raise what a runaway page can make the bridge HOLD, and that separation is
127
+ * what makes the change safe. Memory is bounded independently by the ring buffer, which evicts on
128
+ * `RING_BUFFER_DEFAULTS.MAX_BYTES` (this same constant, reached through that alias) as well as on
129
+ * a count and an age. Grep for `MAX_BUFFER_BYTES` alone and it looks like a constant nobody reads,
130
+ * which is exactly the wrong conclusion to draw before touching this number: the rate cap defends
131
+ * parse cost, the ring buffer defends memory, and they are not substitutes.
132
+ */
133
+ MAX_MESSAGES_PER_SECOND: 20000,
111
134
  MAX_SESSIONS: 32,
112
135
  MAX_PENDING_CONNECTIONS: 16,
113
136
  HELLO_TIMEOUT_MS: 5000,
@@ -196,6 +219,12 @@ export const VisualReason = {
196
219
  // quietly downgraded: a caller who asked for the whole scroll height and silently got the visible
197
220
  // part would bank a baseline that says nothing about the content below the fold.
198
221
  FULL_PAGE_UNSUPPORTED: 'full-page-unsupported',
222
+ // The shell answered, and the window had no composited frame to photograph yet. Distinct from
223
+ // CAPTURE_FAILED on purpose: the capture ran and the window was empty, which is a timing fact
224
+ // about the window rather than a failure of the capture path. Electron's `capturePage()` returns
225
+ // an empty image rather than an error in that state, so without a name of its own it arrived as
226
+ // an unexplained no-image and read identically to a dead window and to a thrown error.
227
+ NOT_COMPOSITED: 'window-not-composited',
199
228
  };
200
229
  /** Actionable companion to NO_PROVIDER — the visual layer needs a driven browser. */
201
230
  export const VISUAL_NO_PROVIDER_RECOMMENDATION = 'visual capture needs a driven browser — start with `reticle drive <url>` or set RETICLE_CDP_URL; the always-on SDK does not ship a screenshotter';
@@ -8,4 +8,5 @@ exports.RETICLE_CAPTURE_CHANNEL = "__reticle:capture";
8
8
  exports.RETICLE_CAPTURE_FILE_PREFIX = "reticle-capture-";
9
9
  exports.RETICLE_TAURI_CAPTURE_COMMAND = "reticle_capture";
10
10
  exports.RETICLE_FULL_PAGE_UNSUPPORTED = "full-page-unsupported";
11
+ exports.RETICLE_NOT_COMPOSITED = "window-not-composited";
11
12
  Object.freeze(exports);
@@ -4,3 +4,4 @@ export declare const RETICLE_CAPTURE_CHANNEL: "__reticle:capture";
4
4
  export declare const RETICLE_CAPTURE_FILE_PREFIX: "reticle-capture-";
5
5
  export declare const RETICLE_TAURI_CAPTURE_COMMAND: "reticle_capture";
6
6
  export declare const RETICLE_FULL_PAGE_UNSUPPORTED: "full-page-unsupported";
7
+ export declare const RETICLE_NOT_COMPOSITED: "window-not-composited";
@@ -43,6 +43,15 @@ export declare const RETICLE_TAURI_CAPTURE_COMMAND = "reticle_capture";
43
43
  * preload (CommonJS) and the daemon must agree on it without sharing a module graph.
44
44
  */
45
45
  export declare const RETICLE_FULL_PAGE_UNSUPPORTED: string;
46
+ /**
47
+ * What a shell answers when the window had no composited frame to photograph.
48
+ *
49
+ * Electron's `capturePage()` returns an EMPTY image in that state rather than an error, and the
50
+ * handler used to turn that into the same bare null it returned for a dead window and for any thrown
51
+ * error. Three different problems, one silence: the tool reported no bytes and no reason, which cost
52
+ * a CI investigation and gives a user hitting it nothing to act on.
53
+ */
54
+ export declare const RETICLE_NOT_COMPOSITED: string;
46
55
  /**
47
56
  * Every value the generated CommonJS shim must expose, as `name → value`.
48
57
  *
@@ -55,4 +64,5 @@ export declare const DESKTOP_CONTRACT: {
55
64
  readonly RETICLE_CAPTURE_FILE_PREFIX: "reticle-capture-";
56
65
  readonly RETICLE_TAURI_CAPTURE_COMMAND: "reticle_capture";
57
66
  readonly RETICLE_FULL_PAGE_UNSUPPORTED: string;
67
+ readonly RETICLE_NOT_COMPOSITED: string;
58
68
  };
@@ -44,6 +44,15 @@ export const RETICLE_TAURI_CAPTURE_COMMAND = 'reticle_capture';
44
44
  * preload (CommonJS) and the daemon must agree on it without sharing a module graph.
45
45
  */
46
46
  export const RETICLE_FULL_PAGE_UNSUPPORTED = VisualReason.FULL_PAGE_UNSUPPORTED;
47
+ /**
48
+ * What a shell answers when the window had no composited frame to photograph.
49
+ *
50
+ * Electron's `capturePage()` returns an EMPTY image in that state rather than an error, and the
51
+ * handler used to turn that into the same bare null it returned for a dead window and for any thrown
52
+ * error. Three different problems, one silence: the tool reported no bytes and no reason, which cost
53
+ * a CI investigation and gives a user hitting it nothing to act on.
54
+ */
55
+ export const RETICLE_NOT_COMPOSITED = VisualReason.NOT_COMPOSITED;
47
56
  /**
48
57
  * Every value the generated CommonJS shim must expose, as `name → value`.
49
58
  *
@@ -56,4 +65,5 @@ export const DESKTOP_CONTRACT = {
56
65
  RETICLE_CAPTURE_FILE_PREFIX,
57
66
  RETICLE_TAURI_CAPTURE_COMMAND,
58
67
  RETICLE_FULL_PAGE_UNSUPPORTED,
68
+ RETICLE_NOT_COMPOSITED,
59
69
  };
@@ -44,6 +44,8 @@ export declare const PROJECT_RUN_CAP: {
44
44
  readonly PER_NAME: 50;
45
45
  readonly TOTAL: 200;
46
46
  };
47
+ /** Maximum distinct route identities retained in project.json. */
48
+ export declare const PROJECT_ROUTE_CAP = 200;
47
49
  /** Schema version stamped onto on-disk flow files (.reticle/flows/<name>.json). */
48
50
  export declare const FLOW_FILE_VERSION = 1;
49
51
  /** How a flow step is anchored to the live DOM at replay time (semantic, never a volatile ref). */
@@ -41,6 +41,8 @@ export const PROJECT_RUN_CAP = {
41
41
  PER_NAME: 50,
42
42
  TOTAL: 200,
43
43
  };
44
+ /** Maximum distinct route identities retained in project.json. */
45
+ export const PROJECT_ROUTE_CAP = 200;
44
46
  /** Schema version stamped onto on-disk flow files (.reticle/flows/<name>.json). */
45
47
  export const FLOW_FILE_VERSION = 1;
46
48
  /** How a flow step is anchored to the live DOM at replay time (semantic, never a volatile ref). */
package/dist/notices.d.ts CHANGED
@@ -25,7 +25,7 @@ export declare function isPresenterTone(value: unknown): value is PresenterTone;
25
25
  * eviction may be "I dropped the evidence", not "it never happened" — widen the buffer / grade
26
26
  * sooner. Rides in a `buffer` block only when `dropped > 0` (silence ⇒ nothing lost).
27
27
  */
28
- export declare const BUFFER_EVICTION_WARNING = "event buffer evicted older events (age/size cap) \u2014 a negative result here may be a false negative; the evidence may have expired. Grade sooner or widen the buffer.";
28
+ export declare const BUFFER_EVICTION_WARNING = "event buffer evicted older events (age/size cap): a negative result here may be a false negative; the evidence may have expired. Grade sooner or widen the buffer.";
29
29
  /**
30
30
  * Thrown when a tool needs a live browser session and none is connected. Names the #1 real cause in a
31
31
  * multi-repo / multi-agent setup — a PORT MISMATCH between the app's SDK and the daemon — so the agent
@@ -33,7 +33,7 @@ export declare const BUFFER_EVICTION_WARNING = "event buffer evicted older event
33
33
  */
34
34
  export declare const NO_SESSION_CONNECTED_ERROR = "no browser session connected. Two things to check: (1) your app is running with @reticlehq/browser enabled, and (2) it points at THIS daemon's port \u2014 a mismatch between the app's reticle({ port }) / VITE_RETICLE_WS_URL and the daemon's RETICLE_PORT is the usual cause. reticle_wait_ready blocks briefly for a session to appear.";
35
35
  /** Surfaced on act/assert results when the target tab is throttled. */
36
- export declare const THROTTLED_WARNING = "tab throttled; timer/rAF/pointer gestures may silently no-op \u2014 refocus before driving";
36
+ export declare const THROTTLED_WARNING = "tab throttled; timer/rAF/pointer gestures may silently no-op; refocus before driving";
37
37
  /**
38
38
  * Pushed to the panel when the last agent's MCP connection drops — the agent (any of
39
39
  * Codex/OpenCode/Claude/Hermes) has stopped or is waiting on you. Tells the human, who is
package/dist/notices.js CHANGED
@@ -29,7 +29,7 @@ export function isPresenterTone(value) {
29
29
  * eviction may be "I dropped the evidence", not "it never happened" — widen the buffer / grade
30
30
  * sooner. Rides in a `buffer` block only when `dropped > 0` (silence ⇒ nothing lost).
31
31
  */
32
- export const BUFFER_EVICTION_WARNING = 'event buffer evicted older events (age/size cap) — a negative result here may be a false negative; the evidence may have expired. Grade sooner or widen the buffer.';
32
+ export const BUFFER_EVICTION_WARNING = 'event buffer evicted older events (age/size cap): a negative result here may be a false negative; the evidence may have expired. Grade sooner or widen the buffer.';
33
33
  /**
34
34
  * Thrown when a tool needs a live browser session and none is connected. Names the #1 real cause in a
35
35
  * multi-repo / multi-agent setup — a PORT MISMATCH between the app's SDK and the daemon — so the agent
@@ -37,7 +37,7 @@ export const BUFFER_EVICTION_WARNING = 'event buffer evicted older events (age/s
37
37
  */
38
38
  export const NO_SESSION_CONNECTED_ERROR = "no browser session connected. Two things to check: (1) your app is running with @reticlehq/browser enabled, and (2) it points at THIS daemon's port — a mismatch between the app's reticle({ port }) / VITE_RETICLE_WS_URL and the daemon's RETICLE_PORT is the usual cause. reticle_wait_ready blocks briefly for a session to appear.";
39
39
  /** Surfaced on act/assert results when the target tab is throttled. */
40
- export const THROTTLED_WARNING = 'tab throttled; timer/rAF/pointer gestures may silently no-op — refocus before driving';
40
+ export const THROTTLED_WARNING = 'tab throttled; timer/rAF/pointer gestures may silently no-op; refocus before driving';
41
41
  /**
42
42
  * Pushed to the panel when the last agent's MCP connection drops — the agent (any of
43
43
  * Codex/OpenCode/Claude/Hermes) has stopped or is waiting on you. Tells the human, who is
@@ -430,6 +430,20 @@ export declare const SessionSummarySchema: z.ZodObject<{
430
430
  errorsRecovered: z.ZodOptional<z.ZodNumber>;
431
431
  /** Errors whose very next call failed again — the message did not land. */
432
432
  errorsRepeated: z.ZodOptional<z.ZodNumber>;
433
+ /**
434
+ * Did this session ever produce a verdict? Absent on a periodic flush — nothing has ended yet.
435
+ *
436
+ * This is the release's headline metric and it was the one thing in the payload that had to be
437
+ * COMPUTED rather than read: `verifications > 0` over the lifetime counters, which are windowed on
438
+ * every other event in the stream, so the obvious query over `session_progress` answers a
439
+ * different question and looks like it answers this one. A metric that requires a correct
440
+ * subtraction to read is a metric that gets read wrong, and this one decides what the product is
441
+ * allowed to claim.
442
+ *
443
+ * ALWAYS present on a final summary, including `false`: a session that drove an app and never
444
+ * asked whether it worked is the finding, so absence and `false` must not look alike.
445
+ */
446
+ endedWithVerdict: z.ZodOptional<z.ZodBoolean>;
433
447
  /** Was this a clean shutdown, or a periodic flush of a still-running session? */
434
448
  final: z.ZodBoolean;
435
449
  /**
@@ -504,6 +518,7 @@ export declare const SessionSummarySchema: z.ZodObject<{
504
518
  errorClasses?: Record<string, number> | undefined;
505
519
  errorsRecovered?: number | undefined;
506
520
  errorsRepeated?: number | undefined;
521
+ endedWithVerdict?: boolean | undefined;
507
522
  exit?: "signal" | "idle" | "unknown" | undefined;
508
523
  }, {
509
524
  durationMs: number;
@@ -564,6 +579,7 @@ export declare const SessionSummarySchema: z.ZodObject<{
564
579
  errorClasses?: Record<string, number> | undefined;
565
580
  errorsRecovered?: number | undefined;
566
581
  errorsRepeated?: number | undefined;
582
+ endedWithVerdict?: boolean | undefined;
567
583
  exit?: "signal" | "idle" | "unknown" | undefined;
568
584
  }>;
569
585
  export type SessionSummary = z.infer<typeof SessionSummarySchema>;
@@ -299,6 +299,20 @@ export const SessionSummarySchema = z.object({
299
299
  errorsRecovered: z.number().int().nonnegative().optional(),
300
300
  /** Errors whose very next call failed again — the message did not land. */
301
301
  errorsRepeated: z.number().int().nonnegative().optional(),
302
+ /**
303
+ * Did this session ever produce a verdict? Absent on a periodic flush — nothing has ended yet.
304
+ *
305
+ * This is the release's headline metric and it was the one thing in the payload that had to be
306
+ * COMPUTED rather than read: `verifications > 0` over the lifetime counters, which are windowed on
307
+ * every other event in the stream, so the obvious query over `session_progress` answers a
308
+ * different question and looks like it answers this one. A metric that requires a correct
309
+ * subtraction to read is a metric that gets read wrong, and this one decides what the product is
310
+ * allowed to claim.
311
+ *
312
+ * ALWAYS present on a final summary, including `false`: a session that drove an app and never
313
+ * asked whether it worked is the finding, so absence and `false` must not look alike.
314
+ */
315
+ endedWithVerdict: z.boolean().optional(),
302
316
  /** Was this a clean shutdown, or a periodic flush of a still-running session? */
303
317
  final: z.boolean(),
304
318
  /**
@@ -159,6 +159,19 @@ export declare const TelemetryEventKind: {
159
159
  * human watching the screen would have caught" is the argument.
160
160
  */
161
161
  readonly BUG_FOUND: "bug_found";
162
+ /**
163
+ * A tool could not do what was asked, and said so.
164
+ *
165
+ * The refusal path already computes a precise diagnosis, hands it to the agent as prose, and then
166
+ * throws it away. So the largest cohort in the funnel — the users who connect an agent and never
167
+ * drive — is visible only by subtraction, and the three genuinely different situations behind it
168
+ * (nothing was ever wired here, the app is not running, a session was lost) arrive as one silence.
169
+ *
170
+ * `noSessionErrors` on the session summary counts one of those causes and only at the end of a
171
+ * session, without the tool, without the discriminator, and without whether the agent tried again.
172
+ * This carries the fact at the moment it happens. See issue #172.
173
+ */
174
+ readonly TOOL_REFUSED: "tool_refused";
162
175
  };
163
176
  export type TelemetryEventKind = (typeof TelemetryEventKind)[keyof typeof TelemetryEventKind];
164
177
  /** True when this event happened inside a daemon run, so a `sessionId` on it means something. */
@@ -532,15 +545,23 @@ export type BugSource = (typeof BugSource)[keyof typeof BugSource];
532
545
  * WHOSE fault the defect was.
533
546
  *
534
547
  * `bugsFound` is the number this product would most like to publish, and it is not publishable
535
- * without this. Measured over one real session: 8 `bug_found` events, of which **one** was a defect
536
- * in the app under test. The other seven were the agent's own bad predicates (a store path that
537
- * never existed, an impossible selector) and one empty ref, all published as defects in the
538
- * customer's product. A founder steering on that number is steering on noise.
548
+ * without this. It shipped twice and was wrong both times: across two full real drives EVERY
549
+ * `attribution: 'app'` was a misattribution, so a single session would have published defects
550
+ * against a customer's product that did not exist. A metric confidently wrong about whose fault
551
+ * something is, is worse than no metric — it is the number a founder steers on, and it points at the
552
+ * customer. It was removed, and an ABSENT field then made "nobody classified this" and "we looked
553
+ * and could not tell" the same fact, which is the other half of the same problem.
554
+ *
555
+ * So it is back with two rules, and both are what the earlier versions lacked:
539
556
  *
540
- * Deliberately OMITTED rather than guessed when the evidence does not say. A failed `element.present`
541
- * covers "the button is missing", "the API is down" and "the agent mistyped a testid" identically,
542
- * and inventing an owner for it would put a guess into the one number we intend to publish — the
543
- * same mistake `brand` refuses to make by being absent rather than `"unknown"`.
557
+ * 1. **Always present.** `UNCLASSIFIED` is a value, not a gap. Absence would mean an old sender or a
558
+ * path that forgot; a value means the classifier ran and declined.
559
+ * 2. **`APP` requires POSITIVE evidence** — something the app itself did: a request that came back
560
+ * failed, a signal the app fired carrying data that disagrees with its own screen, a written
561
+ * field echoed back changed. Never "nothing else explained it". Core already draws exactly this
562
+ * line for the verdict, in `ABSENCE_DERIVED_CONTRADICTIONS`, and that is the line reused rather
563
+ * than a second judgement invented next to it — every one of the historical misattributions was
564
+ * an absence-derived kind, so this rule produces zero of them on the same data.
544
565
  */
545
566
  export declare const BugAttribution: {
546
567
  /** A defect in the app under test — the only bucket that belongs in a published defect count. */
@@ -549,6 +570,15 @@ export declare const BugAttribution: {
549
570
  readonly REQUEST: "request";
550
571
  /** Reticle could not see or could not drive. Our bug, or our configuration. Ship a fix. */
551
572
  readonly RETICLE: "reticle";
573
+ /**
574
+ * The classifier looked and the evidence could not say.
575
+ *
576
+ * The honest majority, and it must stay a value rather than becoming a gap: a failed
577
+ * `element.present` covers "the button is missing", "the API is down" and "the agent mistyped a
578
+ * testid" identically, and an owner invented for it would put a guess into the one number we
579
+ * intend to publish. Exclude it from a defect count; never fold it into `app`.
580
+ */
581
+ readonly UNCLASSIFIED: "unclassified";
552
582
  };
553
583
  export type BugAttribution = (typeof BugAttribution)[keyof typeof BugAttribution];
554
584
  /**
@@ -603,33 +633,111 @@ export declare const BugFoundSchema: z.ZodObject<{
603
633
  */
604
634
  repeat: z.ZodBoolean;
605
635
  /**
606
- * Whose fault it was — `app` | `request` | `reticle`. ABSENT when the evidence cannot say; see
607
- * `BugAttribution`. Count `attribution: 'app'` for defects found in anybody's product.
636
+ * Whose fault it was, ALWAYS present — `unclassified` when the evidence cannot say, never absent.
637
+ *
638
+ * Absence and "we looked and could not tell" are different facts, and only one of them is a
639
+ * measurement. Count `attribution: 'app'` for defects found in anybody's product; see
640
+ * `BugAttribution` for why `app` needs positive evidence.
608
641
  */
609
- attribution: z.ZodOptional<z.ZodNativeEnum<{
642
+ attribution: z.ZodNativeEnum<{
610
643
  /** A defect in the app under test — the only bucket that belongs in a published defect count. */
611
644
  readonly APP: "app";
612
645
  /** The agent's own call was wrong: a path, store or target that never existed. Teach the agent. */
613
646
  readonly REQUEST: "request";
614
647
  /** Reticle could not see or could not drive. Our bug, or our configuration. Ship a fix. */
615
648
  readonly RETICLE: "reticle";
616
- }>>;
649
+ /**
650
+ * The classifier looked and the evidence could not say.
651
+ *
652
+ * The honest majority, and it must stay a value rather than becoming a gap: a failed
653
+ * `element.present` covers "the button is missing", "the API is down" and "the agent mistyped a
654
+ * testid" identically, and an owner invented for it would put a guess into the one number we
655
+ * intend to publish. Exclude it from a defect count; never fold it into `app`.
656
+ */
657
+ readonly UNCLASSIFIED: "unclassified";
658
+ }>;
617
659
  }, "strip", z.ZodTypeAny, {
618
660
  kind: string;
619
661
  source: "replay" | "contradiction" | "crawl" | "assertion";
662
+ attribution: "app" | "reticle" | "request" | "unclassified";
620
663
  falseGreen: boolean;
621
664
  repeat: boolean;
622
- attribution?: "app" | "reticle" | "request" | undefined;
623
665
  tool?: string | undefined;
624
666
  }, {
625
667
  kind: string;
626
668
  source: "replay" | "contradiction" | "crawl" | "assertion";
669
+ attribution: "app" | "reticle" | "request" | "unclassified";
627
670
  falseGreen: boolean;
628
671
  repeat: boolean;
629
- attribution?: "app" | "reticle" | "request" | undefined;
630
672
  tool?: string | undefined;
631
673
  }>;
632
674
  export type BugFound = z.infer<typeof BugFoundSchema>;
675
+ /**
676
+ * WHY a tool could not do what was asked.
677
+ *
678
+ * Derived from the refusal paths that actually exist rather than invented: every member below is a
679
+ * bucket over `error-recovery.ts`'s recovery table, which is the single place a thrown message is
680
+ * turned into a next action. That table is the vocabulary; this is its coarse grouping, and a new
681
+ * entry there cannot compile without being classified here.
682
+ *
683
+ * The five that matter belong to four different owners, which is the whole reason for splitting
684
+ * them: `no_session` is the install's second half never happening, `bad_args` is the agent's own
685
+ * call, `not_ready` is the environment, and `no_match` / `unsupported` are the app and our own
686
+ * capability surface. One undifferentiated "the agent stopped" number cannot be acted on by anyone.
687
+ */
688
+ export declare const RefusalReason: {
689
+ /** There was no app to reach: nothing connected, no session by that id, or several with none named. */
690
+ readonly NO_SESSION: "no_session";
691
+ /** The target did not exist: a stale ref, a missing baseline, an option value the select has not got. */
692
+ readonly NO_MATCH: "no_match";
693
+ /** Reticle refuses to pretend: a rich-text surface, a disabled field, a destructive control. */
694
+ readonly UNSUPPORTED: "unsupported";
695
+ /** The call did not match the schema, or named a value our own validators reject. */
696
+ readonly BAD_ARGS: "bad_args";
697
+ /** Nothing is wrong with the call; the world is not ready — a throttled tab, a timeout, no browser. */
698
+ readonly NOT_READY: "not_ready";
699
+ /** A refusal this list does not name. A classifier that cannot say "I don't know" lies instead. */
700
+ readonly OTHER: "other";
701
+ };
702
+ export type RefusalReason = (typeof RefusalReason)[keyof typeof RefusalReason];
703
+ /** One tool call that could not be served. */
704
+ export declare const ToolRefusalSchema: z.ZodObject<{
705
+ /** Which tool. A name from our own fixed namespace, never app data. */
706
+ tool: z.ZodString;
707
+ reason: z.ZodNativeEnum<{
708
+ /** There was no app to reach: nothing connected, no session by that id, or several with none named. */
709
+ readonly NO_SESSION: "no_session";
710
+ /** The target did not exist: a stale ref, a missing baseline, an option value the select has not got. */
711
+ readonly NO_MATCH: "no_match";
712
+ /** Reticle refuses to pretend: a rich-text surface, a disabled field, a destructive control. */
713
+ readonly UNSUPPORTED: "unsupported";
714
+ /** The call did not match the schema, or named a value our own validators reject. */
715
+ readonly BAD_ARGS: "bad_args";
716
+ /** Nothing is wrong with the call; the world is not ready — a throttled tab, a timeout, no browser. */
717
+ readonly NOT_READY: "not_ready";
718
+ /** A refusal this list does not name. A classifier that cannot say "I don't know" lies instead. */
719
+ readonly OTHER: "other";
720
+ }>;
721
+ /**
722
+ * TRUE when the call immediately before this one was the SAME tool, also refused.
723
+ *
724
+ * Reported on the RETRY rather than on the first refusal, because the first refusal has to be sent
725
+ * at the moment it happens: deferring it until the next call is known would lose it entirely for
726
+ * the agent that gives up, and that agent is the whole population this event exists to describe.
727
+ * So count `retried: true` for retries; the ratio against all refusals is whether our diagnosis
728
+ * gets anybody unstuck.
729
+ */
730
+ retried: z.ZodBoolean;
731
+ }, "strip", z.ZodTypeAny, {
732
+ reason: "other" | "no_session" | "no_match" | "unsupported" | "bad_args" | "not_ready";
733
+ tool: string;
734
+ retried: boolean;
735
+ }, {
736
+ reason: "other" | "no_session" | "no_match" | "unsupported" | "bad_args" | "not_ready";
737
+ tool: string;
738
+ retried: boolean;
739
+ }>;
740
+ export type ToolRefusal = z.infer<typeof ToolRefusalSchema>;
633
741
  /** An MCP client attaching. Separates "installed and running" from "someone is actually using it". */
634
742
  export declare const McpConnectionSchema: z.ZodObject<{
635
743
  /** False the first time a client attaches to this daemon; true for every attach after. */
@@ -761,6 +869,76 @@ export declare const McpOutageSchema: z.ZodObject<{
761
869
  pendingLost?: number | undefined;
762
870
  }>;
763
871
  export type McpOutage = z.infer<typeof McpOutageSchema>;
872
+ /**
873
+ * WHICH published route brought this install in.
874
+ *
875
+ * Four routes ship at once — the SKILL.md paste URL, an `npx skills add` package, a Claude Code
876
+ * plugin, and docs.reticle.sh — and not one install can be attributed to any of them today. Every
877
+ * decision about where to spend effort on distribution is therefore made blind.
878
+ *
879
+ * The value is NEVER inferred. It is read from a single explicit marker (`RETICLE_INSTALL_SOURCE`)
880
+ * that a channel sets on itself, narrowed against this list, and anything else reports `UNKNOWN`.
881
+ * That is deliberate and it means `unknown` will stay large: a guessed attribution is worse than no
882
+ * attribution, because a distribution decision made on a guess is indistinguishable from one made on
883
+ * a measurement. Read a small `unknown` as a marker that spread, never as success.
884
+ *
885
+ * What the marker CANNOT be derived from, and why nothing here tries:
886
+ * - `npm_config_user_agent` says npm/pnpm ran us. Every one of these routes runs through npx, so it
887
+ * separates none of them.
888
+ * - The presence of `.claude-plugin/` or an installed skill directory says a plugin or a skill is
889
+ * present in the repo, not that it is the thing that ran `init` — and both are present at once on
890
+ * any machine that has tried more than one route.
891
+ * - A first-run heuristic on which command ran first says nothing about who told the user to run it.
892
+ */
893
+ export declare const InstallSource: {
894
+ /** The canonical SKILL.md paste URL — the marker is in the command SKILL.md tells the agent to run. */
895
+ readonly SKILL_FILE: "skill_file";
896
+ /** The `npx skills add` package, which ships its own copy of the skill carrying its own marker. */
897
+ readonly NPX_SKILL: "npx_skill";
898
+ /** The Claude Code plugin, which sets the marker in the `env` of the MCP server it registers. */
899
+ readonly PLUGIN: "plugin";
900
+ /** docs.reticle.sh, whose install snippets carry the marker. */
901
+ readonly DOCS_SITE: "docs_site";
902
+ /** The repository README's install snippet. */
903
+ readonly README: "readme";
904
+ /** Somebody typed the command with no channel in front of it. Only ever self-declared. */
905
+ readonly CLI_DIRECT: "cli_direct";
906
+ /** No marker, or one this list does not name. The honest answer, and expected to dominate. */
907
+ readonly UNKNOWN: "unknown";
908
+ };
909
+ export type InstallSource = (typeof InstallSource)[keyof typeof InstallSource];
910
+ /**
911
+ * Why a run LOOKS automated, when `CI` alone does not say so.
912
+ *
913
+ * Advisory only — see the `automation` field on the event and `automation-hint.ts` for what these
914
+ * are and, more importantly, what they are not allowed to be used for.
915
+ */
916
+ export declare const AutomationHint: {
917
+ /** A container runtime marker is present at the filesystem root. */
918
+ readonly CONTAINER: "container";
919
+ /** A hosted dev environment declared itself (Codespaces, Gitpod, Cloud Shell, dev container). */
920
+ readonly HOSTED_WORKSPACE: "hosted_workspace";
921
+ /** Neither end of the process is attached to a terminal. The weakest of the three. */
922
+ readonly NO_TTY: "no_tty";
923
+ };
924
+ export type AutomationHint = (typeof AutomationHint)[keyof typeof AutomationHint];
925
+ /**
926
+ * What `init` SAW after it finished writing, when it stayed to look.
927
+ *
928
+ * The install has two halves — register the MCP server so the agent has the tools, and get the SDK
929
+ * into a running page so there is something to look at — and nothing joined "init finished" to "an
930
+ * app connected". `init` exited 0 having written files, and the second half was completed by far
931
+ * fewer people than the first with no event able to tell the two apart.
932
+ */
933
+ export declare const InitConfirmation: {
934
+ /** An app carrying the SDK reached the daemon while `init` watched. This is what installed means. */
935
+ readonly CONNECTED: "connected";
936
+ /** Nothing was listening on the bridge port, so no session could arrive. Not a failed install. */
937
+ readonly NO_DAEMON: "no_daemon";
938
+ /** A daemon was up and no app connected inside the window — the dev server is the outstanding step. */
939
+ readonly NO_SESSION: "no_session";
940
+ };
941
+ export type InitConfirmation = (typeof InitConfirmation)[keyof typeof InitConfirmation];
764
942
  /** How `reticle init` went. The onboarding funnel, which had no instrumentation whatsoever. */
765
943
  export declare const InitOutcomeSchema: z.ZodObject<{
766
944
  ok: z.ZodBoolean;
@@ -770,16 +948,33 @@ export declare const InitOutcomeSchema: z.ZodObject<{
770
948
  stack: z.ZodOptional<z.ZodString>;
771
949
  /** Whether the MCP registration step succeeded — the step most likely to fail silently. */
772
950
  mcpRegistered: z.ZodOptional<z.ZodBoolean>;
951
+ /**
952
+ * What `init` saw when it waited for an app to connect.
953
+ *
954
+ * ABSENT means it never looked, which is the honest answer for every scripted run: `init` only
955
+ * waits when a human is at the terminal. Read an absent value as "not measured", never as a
956
+ * failure to connect, or the funnel reads scripted installs as losses.
957
+ */
958
+ confirmation: z.ZodOptional<z.ZodNativeEnum<{
959
+ /** An app carrying the SDK reached the daemon while `init` watched. This is what installed means. */
960
+ readonly CONNECTED: "connected";
961
+ /** Nothing was listening on the bridge port, so no session could arrive. Not a failed install. */
962
+ readonly NO_DAEMON: "no_daemon";
963
+ /** A daemon was up and no app connected inside the window — the dev server is the outstanding step. */
964
+ readonly NO_SESSION: "no_session";
965
+ }>>;
773
966
  }, "strip", z.ZodTypeAny, {
774
967
  ok: boolean;
775
968
  stack?: string | undefined;
776
969
  reason?: string | undefined;
777
970
  mcpRegistered?: boolean | undefined;
971
+ confirmation?: "no_session" | "connected" | "no_daemon" | undefined;
778
972
  }, {
779
973
  ok: boolean;
780
974
  stack?: string | undefined;
781
975
  reason?: string | undefined;
782
976
  mcpRegistered?: boolean | undefined;
977
+ confirmation?: "no_session" | "connected" | "no_daemon" | undefined;
783
978
  }>;
784
979
  export type InitOutcome = z.infer<typeof InitOutcomeSchema>;
785
980
  /**
@@ -934,6 +1129,19 @@ export declare const TelemetryEventSchema: z.ZodObject<{
934
1129
  * human watching the screen would have caught" is the argument.
935
1130
  */
936
1131
  readonly BUG_FOUND: "bug_found";
1132
+ /**
1133
+ * A tool could not do what was asked, and said so.
1134
+ *
1135
+ * The refusal path already computes a precise diagnosis, hands it to the agent as prose, and then
1136
+ * throws it away. So the largest cohort in the funnel — the users who connect an agent and never
1137
+ * drive — is visible only by subtraction, and the three genuinely different situations behind it
1138
+ * (nothing was ever wired here, the app is not running, a session was lost) arrive as one silence.
1139
+ *
1140
+ * `noSessionErrors` on the session summary counts one of those causes and only at the end of a
1141
+ * session, without the tool, without the discriminator, and without whether the agent tried again.
1142
+ * This carries the fact at the moment it happens. See issue #172.
1143
+ */
1144
+ readonly TOOL_REFUSED: "tool_refused";
937
1145
  }>;
938
1146
  /** Client epoch-ms when the event happened (the server also stamps its own receive time). */
939
1147
  ts: z.ZodNumber;
@@ -941,6 +1149,23 @@ export declare const TelemetryEventSchema: z.ZodObject<{
941
1149
  version: z.ZodString;
942
1150
  /** Runs inside CI? Separates real human DAU from pipeline traffic (both matter, differently). */
943
1151
  ci: z.ZodBoolean;
1152
+ /**
1153
+ * ADVISORY hint that this run looks automated, when something beyond `CI` suggests it.
1154
+ *
1155
+ * `ci` reads one environment variable, which is right for a GitHub Actions runner and blind to a
1156
+ * cloud agent sandbox — our own gate has landed in the user data with `ci: false`. This is the
1157
+ * second angle, and it is NEVER a filter: people work in containers, in Codespaces, and over ssh
1158
+ * with no terminal. Never exclude a row because this is set; absent means nothing looked
1159
+ * automated, not that a human was present. See automation-hint.ts for the rejected signals.
1160
+ */
1161
+ automation: z.ZodOptional<z.ZodNativeEnum<{
1162
+ /** A container runtime marker is present at the filesystem root. */
1163
+ readonly CONTAINER: "container";
1164
+ /** A hosted dev environment declared itself (Codespaces, Gitpod, Cloud Shell, dev container). */
1165
+ readonly HOSTED_WORKSPACE: "hosted_workspace";
1166
+ /** Neither end of the process is attached to a terminal. The weakest of the three. */
1167
+ readonly NO_TTY: "no_tty";
1168
+ }>>;
944
1169
  /**
945
1170
  * What `projectId` was derived from. On EVERY event, not just the profile, because the core
946
1171
  * counting questions ("users per project", "projects per user") run over all events and need to
@@ -1166,6 +1391,7 @@ export declare const TelemetryEventSchema: z.ZodObject<{
1166
1391
  errorClasses: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
1167
1392
  errorsRecovered: z.ZodOptional<z.ZodNumber>;
1168
1393
  errorsRepeated: z.ZodOptional<z.ZodNumber>;
1394
+ endedWithVerdict: z.ZodOptional<z.ZodBoolean>;
1169
1395
  final: z.ZodBoolean;
1170
1396
  exit: z.ZodOptional<z.ZodEnum<["idle", "signal", "unknown"]>>;
1171
1397
  }, "strip", z.ZodTypeAny, {
@@ -1227,6 +1453,7 @@ export declare const TelemetryEventSchema: z.ZodObject<{
1227
1453
  errorClasses?: Record<string, number> | undefined;
1228
1454
  errorsRecovered?: number | undefined;
1229
1455
  errorsRepeated?: number | undefined;
1456
+ endedWithVerdict?: boolean | undefined;
1230
1457
  exit?: "signal" | "idle" | "unknown" | undefined;
1231
1458
  }, {
1232
1459
  durationMs: number;
@@ -1287,6 +1514,7 @@ export declare const TelemetryEventSchema: z.ZodObject<{
1287
1514
  errorClasses?: Record<string, number> | undefined;
1288
1515
  errorsRecovered?: number | undefined;
1289
1516
  errorsRepeated?: number | undefined;
1517
+ endedWithVerdict?: boolean | undefined;
1290
1518
  exit?: "signal" | "idle" | "unknown" | undefined;
1291
1519
  }>>;
1292
1520
  /** Only on `project_profiled`: the shape and depth-of-use of the project. */
@@ -1682,16 +1910,33 @@ export declare const TelemetryEventSchema: z.ZodObject<{
1682
1910
  stack: z.ZodOptional<z.ZodString>;
1683
1911
  /** Whether the MCP registration step succeeded — the step most likely to fail silently. */
1684
1912
  mcpRegistered: z.ZodOptional<z.ZodBoolean>;
1913
+ /**
1914
+ * What `init` saw when it waited for an app to connect.
1915
+ *
1916
+ * ABSENT means it never looked, which is the honest answer for every scripted run: `init` only
1917
+ * waits when a human is at the terminal. Read an absent value as "not measured", never as a
1918
+ * failure to connect, or the funnel reads scripted installs as losses.
1919
+ */
1920
+ confirmation: z.ZodOptional<z.ZodNativeEnum<{
1921
+ /** An app carrying the SDK reached the daemon while `init` watched. This is what installed means. */
1922
+ readonly CONNECTED: "connected";
1923
+ /** Nothing was listening on the bridge port, so no session could arrive. Not a failed install. */
1924
+ readonly NO_DAEMON: "no_daemon";
1925
+ /** A daemon was up and no app connected inside the window — the dev server is the outstanding step. */
1926
+ readonly NO_SESSION: "no_session";
1927
+ }>>;
1685
1928
  }, "strip", z.ZodTypeAny, {
1686
1929
  ok: boolean;
1687
1930
  stack?: string | undefined;
1688
1931
  reason?: string | undefined;
1689
1932
  mcpRegistered?: boolean | undefined;
1933
+ confirmation?: "no_session" | "connected" | "no_daemon" | undefined;
1690
1934
  }, {
1691
1935
  ok: boolean;
1692
1936
  stack?: string | undefined;
1693
1937
  reason?: string | undefined;
1694
1938
  mcpRegistered?: boolean | undefined;
1939
+ confirmation?: "no_session" | "connected" | "no_daemon" | undefined;
1695
1940
  }>>;
1696
1941
  /** Only on `bug_found`. */
1697
1942
  bug: z.ZodOptional<z.ZodObject<{
@@ -1739,32 +1984,81 @@ export declare const TelemetryEventSchema: z.ZodObject<{
1739
1984
  */
1740
1985
  repeat: z.ZodBoolean;
1741
1986
  /**
1742
- * Whose fault it was — `app` | `request` | `reticle`. ABSENT when the evidence cannot say; see
1743
- * `BugAttribution`. Count `attribution: 'app'` for defects found in anybody's product.
1987
+ * Whose fault it was, ALWAYS present — `unclassified` when the evidence cannot say, never absent.
1988
+ *
1989
+ * Absence and "we looked and could not tell" are different facts, and only one of them is a
1990
+ * measurement. Count `attribution: 'app'` for defects found in anybody's product; see
1991
+ * `BugAttribution` for why `app` needs positive evidence.
1744
1992
  */
1745
- attribution: z.ZodOptional<z.ZodNativeEnum<{
1993
+ attribution: z.ZodNativeEnum<{
1746
1994
  /** A defect in the app under test — the only bucket that belongs in a published defect count. */
1747
1995
  readonly APP: "app";
1748
1996
  /** The agent's own call was wrong: a path, store or target that never existed. Teach the agent. */
1749
1997
  readonly REQUEST: "request";
1750
1998
  /** Reticle could not see or could not drive. Our bug, or our configuration. Ship a fix. */
1751
1999
  readonly RETICLE: "reticle";
1752
- }>>;
2000
+ /**
2001
+ * The classifier looked and the evidence could not say.
2002
+ *
2003
+ * The honest majority, and it must stay a value rather than becoming a gap: a failed
2004
+ * `element.present` covers "the button is missing", "the API is down" and "the agent mistyped a
2005
+ * testid" identically, and an owner invented for it would put a guess into the one number we
2006
+ * intend to publish. Exclude it from a defect count; never fold it into `app`.
2007
+ */
2008
+ readonly UNCLASSIFIED: "unclassified";
2009
+ }>;
1753
2010
  }, "strip", z.ZodTypeAny, {
1754
2011
  kind: string;
1755
2012
  source: "replay" | "contradiction" | "crawl" | "assertion";
2013
+ attribution: "app" | "reticle" | "request" | "unclassified";
1756
2014
  falseGreen: boolean;
1757
2015
  repeat: boolean;
1758
- attribution?: "app" | "reticle" | "request" | undefined;
1759
2016
  tool?: string | undefined;
1760
2017
  }, {
1761
2018
  kind: string;
1762
2019
  source: "replay" | "contradiction" | "crawl" | "assertion";
2020
+ attribution: "app" | "reticle" | "request" | "unclassified";
1763
2021
  falseGreen: boolean;
1764
2022
  repeat: boolean;
1765
- attribution?: "app" | "reticle" | "request" | undefined;
1766
2023
  tool?: string | undefined;
1767
2024
  }>>;
2025
+ /** Only on `tool_refused`: which tool, why, and whether the agent tried the same thing again. */
2026
+ refusal: z.ZodOptional<z.ZodObject<{
2027
+ /** Which tool. A name from our own fixed namespace, never app data. */
2028
+ tool: z.ZodString;
2029
+ reason: z.ZodNativeEnum<{
2030
+ /** There was no app to reach: nothing connected, no session by that id, or several with none named. */
2031
+ readonly NO_SESSION: "no_session";
2032
+ /** The target did not exist: a stale ref, a missing baseline, an option value the select has not got. */
2033
+ readonly NO_MATCH: "no_match";
2034
+ /** Reticle refuses to pretend: a rich-text surface, a disabled field, a destructive control. */
2035
+ readonly UNSUPPORTED: "unsupported";
2036
+ /** The call did not match the schema, or named a value our own validators reject. */
2037
+ readonly BAD_ARGS: "bad_args";
2038
+ /** Nothing is wrong with the call; the world is not ready — a throttled tab, a timeout, no browser. */
2039
+ readonly NOT_READY: "not_ready";
2040
+ /** A refusal this list does not name. A classifier that cannot say "I don't know" lies instead. */
2041
+ readonly OTHER: "other";
2042
+ }>;
2043
+ /**
2044
+ * TRUE when the call immediately before this one was the SAME tool, also refused.
2045
+ *
2046
+ * Reported on the RETRY rather than on the first refusal, because the first refusal has to be sent
2047
+ * at the moment it happens: deferring it until the next call is known would lose it entirely for
2048
+ * the agent that gives up, and that agent is the whole population this event exists to describe.
2049
+ * So count `retried: true` for retries; the ratio against all refusals is whether our diagnosis
2050
+ * gets anybody unstuck.
2051
+ */
2052
+ retried: z.ZodBoolean;
2053
+ }, "strip", z.ZodTypeAny, {
2054
+ reason: "other" | "no_session" | "no_match" | "unsupported" | "bad_args" | "not_ready";
2055
+ tool: string;
2056
+ retried: boolean;
2057
+ }, {
2058
+ reason: "other" | "no_session" | "no_match" | "unsupported" | "bad_args" | "not_ready";
2059
+ tool: string;
2060
+ retried: boolean;
2061
+ }>>;
1768
2062
  /** Only on `mcp_connection_lost`: which stage of the outage, why, and after how many retries. */
1769
2063
  outage: z.ZodOptional<z.ZodObject<{
1770
2064
  stage: z.ZodNativeEnum<{
@@ -1827,8 +2121,30 @@ export declare const TelemetryEventSchema: z.ZodObject<{
1827
2121
  initialized: boolean;
1828
2122
  agentAttached: boolean;
1829
2123
  }>>;
2124
+ /**
2125
+ * Only on `reticle_installed` / `init_completed`: which published route brought this install in.
2126
+ *
2127
+ * A scalar rather than a block because it belongs to two different events that have no payload in
2128
+ * common, and because there is exactly one fact to carry. Absent on every other kind.
2129
+ */
2130
+ installSource: z.ZodOptional<z.ZodNativeEnum<{
2131
+ /** The canonical SKILL.md paste URL — the marker is in the command SKILL.md tells the agent to run. */
2132
+ readonly SKILL_FILE: "skill_file";
2133
+ /** The `npx skills add` package, which ships its own copy of the skill carrying its own marker. */
2134
+ readonly NPX_SKILL: "npx_skill";
2135
+ /** The Claude Code plugin, which sets the marker in the `env` of the MCP server it registers. */
2136
+ readonly PLUGIN: "plugin";
2137
+ /** docs.reticle.sh, whose install snippets carry the marker. */
2138
+ readonly DOCS_SITE: "docs_site";
2139
+ /** The repository README's install snippet. */
2140
+ readonly README: "readme";
2141
+ /** Somebody typed the command with no channel in front of it. Only ever self-declared. */
2142
+ readonly CLI_DIRECT: "cli_direct";
2143
+ /** No marker, or one this list does not name. The honest answer, and expected to dominate. */
2144
+ readonly UNKNOWN: "unknown";
2145
+ }>>;
1830
2146
  }, "strip", z.ZodTypeAny, {
1831
- event: "reticle_installed" | "cli_command_run" | "daemon_started" | "daemon_stopped" | "session_progress" | "verification_completed" | "project_profiled" | "version_changed" | "runtime_crashed" | "feedback_submitted" | "identified" | "mcp_client_connected" | "app_instrumented" | "mcp_connection_lost" | "init_completed" | "bug_found";
2147
+ event: "reticle_installed" | "cli_command_run" | "daemon_started" | "daemon_stopped" | "session_progress" | "verification_completed" | "project_profiled" | "version_changed" | "runtime_crashed" | "feedback_submitted" | "identified" | "mcp_client_connected" | "app_instrumented" | "mcp_connection_lost" | "init_completed" | "bug_found" | "tool_refused";
1832
2148
  version: string;
1833
2149
  ci: boolean;
1834
2150
  v: 3;
@@ -1841,9 +2157,9 @@ export declare const TelemetryEventSchema: z.ZodObject<{
1841
2157
  bug?: {
1842
2158
  kind: string;
1843
2159
  source: "replay" | "contradiction" | "crawl" | "assertion";
2160
+ attribution: "app" | "reticle" | "request" | "unclassified";
1844
2161
  falseGreen: boolean;
1845
2162
  repeat: boolean;
1846
- attribution?: "app" | "reticle" | "request" | undefined;
1847
2163
  tool?: string | undefined;
1848
2164
  } | undefined;
1849
2165
  project?: {
@@ -1923,8 +2239,10 @@ export declare const TelemetryEventSchema: z.ZodObject<{
1923
2239
  errorClasses?: Record<string, number> | undefined;
1924
2240
  errorsRecovered?: number | undefined;
1925
2241
  errorsRepeated?: number | undefined;
2242
+ endedWithVerdict?: boolean | undefined;
1926
2243
  exit?: "signal" | "idle" | "unknown" | undefined;
1927
2244
  } | undefined;
2245
+ automation?: "container" | "hosted_workspace" | "no_tty" | undefined;
1928
2246
  projectIdSource?: "cwd" | "git_origin" | "git_root" | "package_root" | undefined;
1929
2247
  tzOffsetMin?: number | undefined;
1930
2248
  feedback?: {
@@ -2004,6 +2322,12 @@ export declare const TelemetryEventSchema: z.ZodObject<{
2004
2322
  stack?: string | undefined;
2005
2323
  reason?: string | undefined;
2006
2324
  mcpRegistered?: boolean | undefined;
2325
+ confirmation?: "no_session" | "connected" | "no_daemon" | undefined;
2326
+ } | undefined;
2327
+ refusal?: {
2328
+ reason: "other" | "no_session" | "no_match" | "unsupported" | "bad_args" | "not_ready";
2329
+ tool: string;
2330
+ retried: boolean;
2007
2331
  } | undefined;
2008
2332
  outage?: {
2009
2333
  reason: "other" | "sse_ended" | "sse_error" | "sse_aborted" | "sse_closed" | "connect_error";
@@ -2016,8 +2340,9 @@ export declare const TelemetryEventSchema: z.ZodObject<{
2016
2340
  initialized: boolean;
2017
2341
  agentAttached: boolean;
2018
2342
  } | undefined;
2343
+ installSource?: "unknown" | "skill_file" | "npx_skill" | "plugin" | "docs_site" | "readme" | "cli_direct" | undefined;
2019
2344
  }, {
2020
- event: "reticle_installed" | "cli_command_run" | "daemon_started" | "daemon_stopped" | "session_progress" | "verification_completed" | "project_profiled" | "version_changed" | "runtime_crashed" | "feedback_submitted" | "identified" | "mcp_client_connected" | "app_instrumented" | "mcp_connection_lost" | "init_completed" | "bug_found";
2345
+ event: "reticle_installed" | "cli_command_run" | "daemon_started" | "daemon_stopped" | "session_progress" | "verification_completed" | "project_profiled" | "version_changed" | "runtime_crashed" | "feedback_submitted" | "identified" | "mcp_client_connected" | "app_instrumented" | "mcp_connection_lost" | "init_completed" | "bug_found" | "tool_refused";
2021
2346
  version: string;
2022
2347
  ci: boolean;
2023
2348
  v: 3;
@@ -2030,9 +2355,9 @@ export declare const TelemetryEventSchema: z.ZodObject<{
2030
2355
  bug?: {
2031
2356
  kind: string;
2032
2357
  source: "replay" | "contradiction" | "crawl" | "assertion";
2358
+ attribution: "app" | "reticle" | "request" | "unclassified";
2033
2359
  falseGreen: boolean;
2034
2360
  repeat: boolean;
2035
- attribution?: "app" | "reticle" | "request" | undefined;
2036
2361
  tool?: string | undefined;
2037
2362
  } | undefined;
2038
2363
  project?: {
@@ -2112,8 +2437,10 @@ export declare const TelemetryEventSchema: z.ZodObject<{
2112
2437
  errorClasses?: Record<string, number> | undefined;
2113
2438
  errorsRecovered?: number | undefined;
2114
2439
  errorsRepeated?: number | undefined;
2440
+ endedWithVerdict?: boolean | undefined;
2115
2441
  exit?: "signal" | "idle" | "unknown" | undefined;
2116
2442
  } | undefined;
2443
+ automation?: "container" | "hosted_workspace" | "no_tty" | undefined;
2117
2444
  projectIdSource?: "cwd" | "git_origin" | "git_root" | "package_root" | undefined;
2118
2445
  tzOffsetMin?: number | undefined;
2119
2446
  feedback?: {
@@ -2193,6 +2520,12 @@ export declare const TelemetryEventSchema: z.ZodObject<{
2193
2520
  stack?: string | undefined;
2194
2521
  reason?: string | undefined;
2195
2522
  mcpRegistered?: boolean | undefined;
2523
+ confirmation?: "no_session" | "connected" | "no_daemon" | undefined;
2524
+ } | undefined;
2525
+ refusal?: {
2526
+ reason: "other" | "no_session" | "no_match" | "unsupported" | "bad_args" | "not_ready";
2527
+ tool: string;
2528
+ retried: boolean;
2196
2529
  } | undefined;
2197
2530
  outage?: {
2198
2531
  reason: "other" | "sse_ended" | "sse_error" | "sse_aborted" | "sse_closed" | "connect_error";
@@ -2205,5 +2538,6 @@ export declare const TelemetryEventSchema: z.ZodObject<{
2205
2538
  initialized: boolean;
2206
2539
  agentAttached: boolean;
2207
2540
  } | undefined;
2541
+ installSource?: "unknown" | "skill_file" | "npx_skill" | "plugin" | "docs_site" | "readme" | "cli_direct" | undefined;
2208
2542
  }>;
2209
2543
  export type TelemetryEvent = z.infer<typeof TelemetryEventSchema>;
package/dist/telemetry.js CHANGED
@@ -163,6 +163,19 @@ export const TelemetryEventKind = {
163
163
  * human watching the screen would have caught" is the argument.
164
164
  */
165
165
  BUG_FOUND: 'bug_found',
166
+ /**
167
+ * A tool could not do what was asked, and said so.
168
+ *
169
+ * The refusal path already computes a precise diagnosis, hands it to the agent as prose, and then
170
+ * throws it away. So the largest cohort in the funnel — the users who connect an agent and never
171
+ * drive — is visible only by subtraction, and the three genuinely different situations behind it
172
+ * (nothing was ever wired here, the app is not running, a session was lost) arrive as one silence.
173
+ *
174
+ * `noSessionErrors` on the session summary counts one of those causes and only at the end of a
175
+ * session, without the tool, without the discriminator, and without whether the agent tried again.
176
+ * This carries the fact at the moment it happens. See issue #172.
177
+ */
178
+ TOOL_REFUSED: 'tool_refused',
166
179
  };
167
180
  /**
168
181
  * Events that belong to a DAEMON RUN, and therefore carry `sessionId`.
@@ -186,6 +199,7 @@ const SESSION_SCOPED = new Set([
186
199
  TelemetryEventKind.BUG_FOUND,
187
200
  TelemetryEventKind.RUNTIME_CRASHED,
188
201
  TelemetryEventKind.FEEDBACK_SUBMITTED,
202
+ TelemetryEventKind.TOOL_REFUSED,
189
203
  ]);
190
204
  /** True when this event happened inside a daemon run, so a `sessionId` on it means something. */
191
205
  export function isSessionScoped(kind) {
@@ -428,15 +442,23 @@ export const BugSource = {
428
442
  * WHOSE fault the defect was.
429
443
  *
430
444
  * `bugsFound` is the number this product would most like to publish, and it is not publishable
431
- * without this. Measured over one real session: 8 `bug_found` events, of which **one** was a defect
432
- * in the app under test. The other seven were the agent's own bad predicates (a store path that
433
- * never existed, an impossible selector) and one empty ref, all published as defects in the
434
- * customer's product. A founder steering on that number is steering on noise.
445
+ * without this. It shipped twice and was wrong both times: across two full real drives EVERY
446
+ * `attribution: 'app'` was a misattribution, so a single session would have published defects
447
+ * against a customer's product that did not exist. A metric confidently wrong about whose fault
448
+ * something is, is worse than no metric — it is the number a founder steers on, and it points at the
449
+ * customer. It was removed, and an ABSENT field then made "nobody classified this" and "we looked
450
+ * and could not tell" the same fact, which is the other half of the same problem.
451
+ *
452
+ * So it is back with two rules, and both are what the earlier versions lacked:
435
453
  *
436
- * Deliberately OMITTED rather than guessed when the evidence does not say. A failed `element.present`
437
- * covers "the button is missing", "the API is down" and "the agent mistyped a testid" identically,
438
- * and inventing an owner for it would put a guess into the one number we intend to publish — the
439
- * same mistake `brand` refuses to make by being absent rather than `"unknown"`.
454
+ * 1. **Always present.** `UNCLASSIFIED` is a value, not a gap. Absence would mean an old sender or a
455
+ * path that forgot; a value means the classifier ran and declined.
456
+ * 2. **`APP` requires POSITIVE evidence** — something the app itself did: a request that came back
457
+ * failed, a signal the app fired carrying data that disagrees with its own screen, a written
458
+ * field echoed back changed. Never "nothing else explained it". Core already draws exactly this
459
+ * line for the verdict, in `ABSENCE_DERIVED_CONTRADICTIONS`, and that is the line reused rather
460
+ * than a second judgement invented next to it — every one of the historical misattributions was
461
+ * an absence-derived kind, so this rule produces zero of them on the same data.
440
462
  */
441
463
  export const BugAttribution = {
442
464
  /** A defect in the app under test — the only bucket that belongs in a published defect count. */
@@ -445,6 +467,15 @@ export const BugAttribution = {
445
467
  REQUEST: 'request',
446
468
  /** Reticle could not see or could not drive. Our bug, or our configuration. Ship a fix. */
447
469
  RETICLE: 'reticle',
470
+ /**
471
+ * The classifier looked and the evidence could not say.
472
+ *
473
+ * The honest majority, and it must stay a value rather than becoming a gap: a failed
474
+ * `element.present` covers "the button is missing", "the API is down" and "the agent mistyped a
475
+ * testid" identically, and an owner invented for it would put a guess into the one number we
476
+ * intend to publish. Exclude it from a defect count; never fold it into `app`.
477
+ */
478
+ UNCLASSIFIED: 'unclassified',
448
479
  };
449
480
  /**
450
481
  * One defect Reticle found in the app under test.
@@ -489,10 +520,56 @@ export const BugFoundSchema = z.object({
489
520
  */
490
521
  repeat: z.boolean(),
491
522
  /**
492
- * Whose fault it was — `app` | `request` | `reticle`. ABSENT when the evidence cannot say; see
493
- * `BugAttribution`. Count `attribution: 'app'` for defects found in anybody's product.
523
+ * Whose fault it was, ALWAYS present — `unclassified` when the evidence cannot say, never absent.
524
+ *
525
+ * Absence and "we looked and could not tell" are different facts, and only one of them is a
526
+ * measurement. Count `attribution: 'app'` for defects found in anybody's product; see
527
+ * `BugAttribution` for why `app` needs positive evidence.
494
528
  */
495
- attribution: z.nativeEnum(BugAttribution).optional(),
529
+ attribution: z.nativeEnum(BugAttribution),
530
+ });
531
+ /**
532
+ * WHY a tool could not do what was asked.
533
+ *
534
+ * Derived from the refusal paths that actually exist rather than invented: every member below is a
535
+ * bucket over `error-recovery.ts`'s recovery table, which is the single place a thrown message is
536
+ * turned into a next action. That table is the vocabulary; this is its coarse grouping, and a new
537
+ * entry there cannot compile without being classified here.
538
+ *
539
+ * The five that matter belong to four different owners, which is the whole reason for splitting
540
+ * them: `no_session` is the install's second half never happening, `bad_args` is the agent's own
541
+ * call, `not_ready` is the environment, and `no_match` / `unsupported` are the app and our own
542
+ * capability surface. One undifferentiated "the agent stopped" number cannot be acted on by anyone.
543
+ */
544
+ export const RefusalReason = {
545
+ /** There was no app to reach: nothing connected, no session by that id, or several with none named. */
546
+ NO_SESSION: 'no_session',
547
+ /** The target did not exist: a stale ref, a missing baseline, an option value the select has not got. */
548
+ NO_MATCH: 'no_match',
549
+ /** Reticle refuses to pretend: a rich-text surface, a disabled field, a destructive control. */
550
+ UNSUPPORTED: 'unsupported',
551
+ /** The call did not match the schema, or named a value our own validators reject. */
552
+ BAD_ARGS: 'bad_args',
553
+ /** Nothing is wrong with the call; the world is not ready — a throttled tab, a timeout, no browser. */
554
+ NOT_READY: 'not_ready',
555
+ /** A refusal this list does not name. A classifier that cannot say "I don't know" lies instead. */
556
+ OTHER: 'other',
557
+ };
558
+ /** One tool call that could not be served. */
559
+ export const ToolRefusalSchema = z.object({
560
+ /** Which tool. A name from our own fixed namespace, never app data. */
561
+ tool: z.string().min(1).max(64),
562
+ reason: z.nativeEnum(RefusalReason),
563
+ /**
564
+ * TRUE when the call immediately before this one was the SAME tool, also refused.
565
+ *
566
+ * Reported on the RETRY rather than on the first refusal, because the first refusal has to be sent
567
+ * at the moment it happens: deferring it until the next call is known would lose it entirely for
568
+ * the agent that gives up, and that agent is the whole population this event exists to describe.
569
+ * So count `retried: true` for retries; the ratio against all refusals is whether our diagnosis
570
+ * gets anybody unstuck.
571
+ */
572
+ retried: z.boolean(),
496
573
  });
497
574
  /** An MCP client attaching. Separates "installed and running" from "someone is actually using it". */
498
575
  export const McpConnectionSchema = z.object({
@@ -578,6 +655,73 @@ export const McpOutageSchema = z.object({
578
655
  */
579
656
  pendingLost: z.number().int().nonnegative().optional(),
580
657
  });
658
+ /**
659
+ * WHICH published route brought this install in.
660
+ *
661
+ * Four routes ship at once — the SKILL.md paste URL, an `npx skills add` package, a Claude Code
662
+ * plugin, and docs.reticle.sh — and not one install can be attributed to any of them today. Every
663
+ * decision about where to spend effort on distribution is therefore made blind.
664
+ *
665
+ * The value is NEVER inferred. It is read from a single explicit marker (`RETICLE_INSTALL_SOURCE`)
666
+ * that a channel sets on itself, narrowed against this list, and anything else reports `UNKNOWN`.
667
+ * That is deliberate and it means `unknown` will stay large: a guessed attribution is worse than no
668
+ * attribution, because a distribution decision made on a guess is indistinguishable from one made on
669
+ * a measurement. Read a small `unknown` as a marker that spread, never as success.
670
+ *
671
+ * What the marker CANNOT be derived from, and why nothing here tries:
672
+ * - `npm_config_user_agent` says npm/pnpm ran us. Every one of these routes runs through npx, so it
673
+ * separates none of them.
674
+ * - The presence of `.claude-plugin/` or an installed skill directory says a plugin or a skill is
675
+ * present in the repo, not that it is the thing that ran `init` — and both are present at once on
676
+ * any machine that has tried more than one route.
677
+ * - A first-run heuristic on which command ran first says nothing about who told the user to run it.
678
+ */
679
+ export const InstallSource = {
680
+ /** The canonical SKILL.md paste URL — the marker is in the command SKILL.md tells the agent to run. */
681
+ SKILL_FILE: 'skill_file',
682
+ /** The `npx skills add` package, which ships its own copy of the skill carrying its own marker. */
683
+ NPX_SKILL: 'npx_skill',
684
+ /** The Claude Code plugin, which sets the marker in the `env` of the MCP server it registers. */
685
+ PLUGIN: 'plugin',
686
+ /** docs.reticle.sh, whose install snippets carry the marker. */
687
+ DOCS_SITE: 'docs_site',
688
+ /** The repository README's install snippet. */
689
+ README: 'readme',
690
+ /** Somebody typed the command with no channel in front of it. Only ever self-declared. */
691
+ CLI_DIRECT: 'cli_direct',
692
+ /** No marker, or one this list does not name. The honest answer, and expected to dominate. */
693
+ UNKNOWN: 'unknown',
694
+ };
695
+ /**
696
+ * Why a run LOOKS automated, when `CI` alone does not say so.
697
+ *
698
+ * Advisory only — see the `automation` field on the event and `automation-hint.ts` for what these
699
+ * are and, more importantly, what they are not allowed to be used for.
700
+ */
701
+ export const AutomationHint = {
702
+ /** A container runtime marker is present at the filesystem root. */
703
+ CONTAINER: 'container',
704
+ /** A hosted dev environment declared itself (Codespaces, Gitpod, Cloud Shell, dev container). */
705
+ HOSTED_WORKSPACE: 'hosted_workspace',
706
+ /** Neither end of the process is attached to a terminal. The weakest of the three. */
707
+ NO_TTY: 'no_tty',
708
+ };
709
+ /**
710
+ * What `init` SAW after it finished writing, when it stayed to look.
711
+ *
712
+ * The install has two halves — register the MCP server so the agent has the tools, and get the SDK
713
+ * into a running page so there is something to look at — and nothing joined "init finished" to "an
714
+ * app connected". `init` exited 0 having written files, and the second half was completed by far
715
+ * fewer people than the first with no event able to tell the two apart.
716
+ */
717
+ export const InitConfirmation = {
718
+ /** An app carrying the SDK reached the daemon while `init` watched. This is what installed means. */
719
+ CONNECTED: 'connected',
720
+ /** Nothing was listening on the bridge port, so no session could arrive. Not a failed install. */
721
+ NO_DAEMON: 'no_daemon',
722
+ /** A daemon was up and no app connected inside the window — the dev server is the outstanding step. */
723
+ NO_SESSION: 'no_session',
724
+ };
581
725
  /** How `reticle init` went. The onboarding funnel, which had no instrumentation whatsoever. */
582
726
  export const InitOutcomeSchema = z.object({
583
727
  ok: z.boolean(),
@@ -587,6 +731,14 @@ export const InitOutcomeSchema = z.object({
587
731
  stack: z.string().max(64).optional(),
588
732
  /** Whether the MCP registration step succeeded — the step most likely to fail silently. */
589
733
  mcpRegistered: z.boolean().optional(),
734
+ /**
735
+ * What `init` saw when it waited for an app to connect.
736
+ *
737
+ * ABSENT means it never looked, which is the honest answer for every scripted run: `init` only
738
+ * waits when a human is at the terminal. Read an absent value as "not measured", never as a
739
+ * failure to connect, or the funnel reads scripted installs as losses.
740
+ */
741
+ confirmation: z.nativeEnum(InitConfirmation).optional(),
590
742
  });
591
743
  /**
592
744
  * One anonymous telemetry event. `anonymousId` and the optional hashed `projectId` are the only
@@ -620,6 +772,16 @@ export const TelemetryEventSchema = z.object({
620
772
  version: z.string().min(1).max(64),
621
773
  /** Runs inside CI? Separates real human DAU from pipeline traffic (both matter, differently). */
622
774
  ci: z.boolean(),
775
+ /**
776
+ * ADVISORY hint that this run looks automated, when something beyond `CI` suggests it.
777
+ *
778
+ * `ci` reads one environment variable, which is right for a GitHub Actions runner and blind to a
779
+ * cloud agent sandbox — our own gate has landed in the user data with `ci: false`. This is the
780
+ * second angle, and it is NEVER a filter: people work in containers, in Codespaces, and over ssh
781
+ * with no terminal. Never exclude a row because this is set; absent means nothing looked
782
+ * automated, not that a human was present. See automation-hint.ts for the rejected signals.
783
+ */
784
+ automation: z.nativeEnum(AutomationHint).optional(),
623
785
  /**
624
786
  * What `projectId` was derived from. On EVERY event, not just the profile, because the core
625
787
  * counting questions ("users per project", "projects per user") run over all events and need to
@@ -666,8 +828,17 @@ export const TelemetryEventSchema = z.object({
666
828
  init: InitOutcomeSchema.optional(),
667
829
  /** Only on `bug_found`. */
668
830
  bug: BugFoundSchema.optional(),
831
+ /** Only on `tool_refused`: which tool, why, and whether the agent tried the same thing again. */
832
+ refusal: ToolRefusalSchema.optional(),
669
833
  /** Only on `mcp_connection_lost`: which stage of the outage, why, and after how many retries. */
670
834
  outage: McpOutageSchema.optional(),
671
835
  /** Only on `app_instrumented`: the install's second half finally happening. */
672
836
  instrumentation: AppInstrumentationSchema.optional(),
837
+ /**
838
+ * Only on `reticle_installed` / `init_completed`: which published route brought this install in.
839
+ *
840
+ * A scalar rather than a block because it belongs to two different events that have no payload in
841
+ * common, and because there is exactly one fact to carry. Absent on every other kind.
842
+ */
843
+ installSource: z.nativeEnum(InstallSource).optional(),
673
844
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reticlehq/core",
3
- "version": "2.7.0",
3
+ "version": "2.8.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",