@reticlehq/core 2.4.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/consequence.d.ts +27 -0
  2. package/dist/consequence.js +26 -0
  3. package/dist/constants.d.ts +68 -0
  4. package/dist/constants.js +65 -0
  5. package/dist/contract-fingerprint.d.ts +29 -0
  6. package/dist/contract-fingerprint.js +56 -0
  7. package/dist/daemon-registry.js +1 -1
  8. package/dist/event-classification.d.ts +7 -0
  9. package/dist/event-classification.js +15 -0
  10. package/dist/event-payloads.d.ts +48 -0
  11. package/dist/event-payloads.js +12 -1
  12. package/dist/flow-constants.d.ts +8 -0
  13. package/dist/flow-constants.js +12 -0
  14. package/dist/flow-types.d.ts +23 -0
  15. package/dist/index.d.ts +3 -0
  16. package/dist/index.js +3 -0
  17. package/dist/journal.d.ts +2 -2
  18. package/dist/messages.d.ts +48 -0
  19. package/dist/messages.js +20 -0
  20. package/dist/net.d.ts +40 -0
  21. package/dist/net.js +44 -0
  22. package/dist/project-id.d.ts +28 -0
  23. package/dist/project-id.js +51 -0
  24. package/dist/redaction.js +4 -4
  25. package/dist/schema/hello-message.json +8 -0
  26. package/dist/schema/reticle-message.json +8 -0
  27. package/dist/security.js +10 -5
  28. package/dist/source-constants.d.ts +6 -0
  29. package/dist/source-constants.js +6 -0
  30. package/dist/state-select.d.ts +14 -2
  31. package/dist/state-select.js +77 -14
  32. package/dist/telemetry-feedback.d.ts +32 -10
  33. package/dist/telemetry-feedback.js +21 -0
  34. package/dist/telemetry-session.d.ts +169 -0
  35. package/dist/telemetry-session.js +139 -0
  36. package/dist/telemetry.d.ts +706 -92
  37. package/dist/telemetry.js +251 -4
  38. package/dist/toon.d.ts +2 -1
  39. package/dist/toon.js +37 -37
  40. package/dist/types.d.ts +48 -0
  41. package/dist/types.js +12 -0
  42. package/dist/upgrade.js +1 -1
  43. package/dist/verification-run.d.ts +28 -28
  44. package/dist/verified-constants.d.ts +53 -0
  45. package/dist/verified-constants.js +52 -0
  46. package/package.json +5 -3
@@ -67,6 +67,28 @@ export declare const BrowserEngine: {
67
67
  readonly WEBKIT: "webkit";
68
68
  };
69
69
  export type BrowserEngine = (typeof BrowserEngine)[keyof typeof BrowserEngine];
70
+ /**
71
+ * The browser BRAND behind the connected page — the axis `engine` cannot answer.
72
+ *
73
+ * Chrome, Edge, Arc, Dia, Brave and Opera are all `blink`, and the most common mode by far is
74
+ * `attached`: Reticle launched nothing, so the page itself is the only thing that knows which
75
+ * browser it is. A CLOSED list on purpose — the raw UA string and a raw `userAgentData` brand are
76
+ * both unbounded and fingerprintable, so anything unrecognised reports `OTHER` rather than
77
+ * forwarding a name we have never seen.
78
+ */
79
+ export declare const BrowserBrand: {
80
+ readonly CHROME: "chrome";
81
+ readonly EDGE: "edge";
82
+ readonly ARC: "arc";
83
+ readonly DIA: "dia";
84
+ readonly BRAVE: "brave";
85
+ readonly OPERA: "opera";
86
+ readonly FIREFOX: "firefox";
87
+ readonly SAFARI: "safari";
88
+ /** Anything we do not recognise — including a Chromium that names no brand at all. */
89
+ readonly OTHER: "other";
90
+ };
91
+ export type BrowserBrand = (typeof BrowserBrand)[keyof typeof BrowserBrand];
70
92
  /** How Reticle reaches the page: a driven CDP browser, or the SDK inside the human's own browser. */
71
93
  export declare const PageDriver: {
72
94
  readonly CDP: "cdp";
@@ -196,39 +218,39 @@ export declare const FeedbackSchema: z.ZodObject<{
196
218
  }, "strip", z.ZodTypeAny, {
197
219
  text: string;
198
220
  kind: "bug" | "gap" | "ambiguity" | "feature_request" | "improvement" | "experience";
199
- source: "human" | "agent";
200
- model?: string | undefined;
201
- stack?: string | undefined;
202
- stackMajor?: number | undefined;
221
+ source: "agent" | "human";
203
222
  trace?: string | undefined;
204
223
  rating?: number | undefined;
205
224
  need?: string | undefined;
206
225
  impact?: string | undefined;
207
226
  currentApproach?: string | undefined;
227
+ model?: string | undefined;
208
228
  clientVersion?: string | undefined;
229
+ stack?: string | undefined;
230
+ stackMajor?: number | undefined;
209
231
  runtime?: "web" | "electron" | "tauri" | undefined;
210
232
  engine?: "blink" | "gecko" | "webkit" | undefined;
211
233
  driver?: "cdp" | "sdk" | undefined;
212
234
  client?: string | undefined;
213
- mcpScope?: "project" | "user" | undefined;
235
+ mcpScope?: "user" | "project" | undefined;
214
236
  }, {
215
237
  text: string;
216
238
  kind: "bug" | "gap" | "ambiguity" | "feature_request" | "improvement" | "experience";
217
- source: "human" | "agent";
218
- model?: string | undefined;
219
- stack?: string | undefined;
220
- stackMajor?: number | undefined;
239
+ source: "agent" | "human";
221
240
  trace?: string | undefined;
222
241
  rating?: number | undefined;
223
242
  need?: string | undefined;
224
243
  impact?: string | undefined;
225
244
  currentApproach?: string | undefined;
245
+ model?: string | undefined;
226
246
  clientVersion?: string | undefined;
247
+ stack?: string | undefined;
248
+ stackMajor?: number | undefined;
227
249
  runtime?: "web" | "electron" | "tauri" | undefined;
228
250
  engine?: "blink" | "gecko" | "webkit" | undefined;
229
251
  driver?: "cdp" | "sdk" | undefined;
230
252
  client?: string | undefined;
231
- mcpScope?: "project" | "user" | undefined;
253
+ mcpScope?: "user" | "project" | undefined;
232
254
  }>;
233
255
  export type Feedback = z.infer<typeof FeedbackSchema>;
234
256
  /** What Reticle is being used for. Self-declared; never inferred. */
@@ -63,6 +63,27 @@ export const BrowserEngine = {
63
63
  GECKO: 'gecko',
64
64
  WEBKIT: 'webkit',
65
65
  };
66
+ /**
67
+ * The browser BRAND behind the connected page — the axis `engine` cannot answer.
68
+ *
69
+ * Chrome, Edge, Arc, Dia, Brave and Opera are all `blink`, and the most common mode by far is
70
+ * `attached`: Reticle launched nothing, so the page itself is the only thing that knows which
71
+ * browser it is. A CLOSED list on purpose — the raw UA string and a raw `userAgentData` brand are
72
+ * both unbounded and fingerprintable, so anything unrecognised reports `OTHER` rather than
73
+ * forwarding a name we have never seen.
74
+ */
75
+ export const BrowserBrand = {
76
+ CHROME: 'chrome',
77
+ EDGE: 'edge',
78
+ ARC: 'arc',
79
+ DIA: 'dia',
80
+ BRAVE: 'brave',
81
+ OPERA: 'opera',
82
+ FIREFOX: 'firefox',
83
+ SAFARI: 'safari',
84
+ /** Anything we do not recognise — including a Chromium that names no brand at all. */
85
+ OTHER: 'other',
86
+ };
66
87
  /** How Reticle reaches the page: a driven CDP browser, or the SDK inside the human's own browser. */
67
88
  export const PageDriver = {
68
89
  CDP: 'cdp',
@@ -289,6 +289,40 @@ export declare const SessionSummarySchema: z.ZodObject<{
289
289
  peakConcurrentTools: z.ZodOptional<z.ZodNumber>;
290
290
  /** Calls for a tool name that does not exist. A non-zero value means our surface is confusing. */
291
291
  unknownToolCalls: z.ZodOptional<z.ZodNumber>;
292
+ /**
293
+ * WHICH tools the agent reached for that do not exist, with counts.
294
+ *
295
+ * The count alone said "our surface confused someone" and could never say what they wanted. The
296
+ * name is a feature request in the agent's own vocabulary — and it is a NAME, from our own tool
297
+ * namespace, carrying no app data, so it is safe under the send-names-never-values rule.
298
+ *
299
+ * Bounded and truncated: a guess is a short identifier, and anything longer is not one.
300
+ */
301
+ unknownTools: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
302
+ /**
303
+ * Tool calls that failed because there was no app to reach — no session connected, no session by
304
+ * that id, or several with none named.
305
+ *
306
+ * The single biggest drop-off in the funnel, and it used to be reachable only by unpacking
307
+ * `errors[]` in HogQL. 74% of daemons never call a tool at all, and of the sessions that made
308
+ * exactly one call, most bounced on precisely this. Absent when it never happened, so the field's
309
+ * PRESENCE is the signal.
310
+ */
311
+ noSessionErrors: z.ZodOptional<z.ZodNumber>;
312
+ /**
313
+ * Longest back-to-back run per tool name — the shape of a retry loop.
314
+ *
315
+ * `toolCounts` reports five useful calls and five retries of one failing call identically, and
316
+ * those are opposite facts: engagement versus an agent stuck. Only tools actually repeated appear.
317
+ */
318
+ consecutiveRepeats: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
319
+ /**
320
+ * Actions driven with no verdict after them — the signature of the loop breaking mid-task.
321
+ *
322
+ * An agent that acts and then verifies is the product working; one that acts and wanders off has
323
+ * either given up or lost the thread, and nothing distinguished the two before.
324
+ */
325
+ abandonedActions: z.ZodOptional<z.ZodNumber>;
292
326
  /** The machine at shutdown — was it starved while all this was happening? */
293
327
  machine: z.ZodOptional<z.ZodObject<{
294
328
  /** Resident set size of the daemon itself — our footprint, the one we can actually fix. */
@@ -317,8 +351,100 @@ export declare const SessionSummarySchema: z.ZodObject<{
317
351
  }>>;
318
352
  /** Distinct MCP clients seen (`claude-code`, `cursor`), so multi-agent use is visible. */
319
353
  clients: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
354
+ /**
355
+ * Client name -> version. The other half of `clients`, and the half that explains regressions.
356
+ *
357
+ * MCP's `clientInfo` carries a name AND a version; we read both at the handshake and kept only
358
+ * the name. A product whose users are agents needs to slice every rate by which agent, on which
359
+ * build — a single global figure hides the finding entirely.
360
+ *
361
+ * NOT the model: `clientInfo` has no concept of one, so the transport genuinely cannot report it.
362
+ * Agents self-report it on feedback, which is the only mechanism there is.
363
+ */
364
+ clientVersions: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
365
+ /**
366
+ * Which tool surface was live. The 18-tool default and the 48-tool full surface are different
367
+ * products from inside an agent's context window, and comparing outcomes across them is how we
368
+ * learn whether the trim helps or hurts.
369
+ */
370
+ surface: z.ZodOptional<z.ZodString>;
371
+ /**
372
+ * How many times an app's SDK dialled this daemon. **Session-lifetime, never windowed.**
373
+ *
374
+ * Zero here is the single most diagnostic number in the payload: the daemon ran and no app ever
375
+ * connected, which is a BROKEN INSTALL. Non-zero with no tool calls is the opposite problem — the
376
+ * install works and the agent never asked. Before this field those two were the same row, and
377
+ * they have opposite fixes. Measured 2026-08-10/11: 88 of 116 users attached an agent and never
378
+ * drove, and we could not say which case any of them was.
379
+ *
380
+ * A counter rather than an event because the SDK reconnects on every page reload — an event per
381
+ * connect would be high volume for a question one number answers.
382
+ */
383
+ appConnects: z.ZodOptional<z.ZodNumber>;
384
+ /**
385
+ * Milliseconds from daemon start to the FIRST app connecting. Absent when none ever did.
386
+ *
387
+ * Separates "the app was already running" from "the human had to go start it", which is the
388
+ * difference between a smooth install and one that needed a second step nobody documented.
389
+ */
390
+ msToFirstApp: z.ZodOptional<z.ZodNumber>;
391
+ /**
392
+ * What state the AGENT's work was in when the session ended. Absent on a periodic flush.
393
+ *
394
+ * Distinct from `exit`, which says why the PROCESS ended. A daemon can exit tidily on idle while
395
+ * the agent's work was abandoned mid-task, and those are different findings.
396
+ *
397
+ * Measured 2026-08-10/11: 20 of the 28 agents that drove an app produced no verdict, and nothing
398
+ * could say whether that was a product failure or a task that simply ended.
399
+ *
400
+ * Most of this is derivable at query time from `toolCalls` / `verifications` /
401
+ * `abandonedActions`. The part that is NOT derivable is `client_left` — whether the agent
402
+ * detached or simply stopped asking — which is why the daemon records it rather than leaving the
403
+ * whole thing to a query.
404
+ */
405
+ endReason: z.ZodOptional<z.ZodEnum<["never_used", "explored", "abandoned", "verified", "client_left"]>>;
406
+ /**
407
+ * How often Reticle invited the agent to send feedback.
408
+ *
409
+ * The denominator for `feedback_submitted`. A prompt nobody acts on is decoration, and without
410
+ * this we could never tell the difference between "agents have nothing to report" and "our
411
+ * invitation is invisible". Instrumenting our own nudge is what makes it a designed system
412
+ * rather than a hope.
413
+ */
414
+ feedbackPrompted: z.ZodOptional<z.ZodNumber>;
415
+ /**
416
+ * Tool errors bucketed by WHOSE defect they are: `schema` (our grammar failed to explain itself),
417
+ * `state` (the world moved), `refusal` (we said no on purpose), `other` (a blind spot).
418
+ *
419
+ * `toolErrors` is one number over three failures with three different fixes. Only the `schema`
420
+ * bucket is fixable by writing better descriptions, and it was indistinguishable from the rest.
421
+ */
422
+ errorClasses: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodNumber>>;
423
+ /**
424
+ * Errors after which the agent's NEXT call succeeded — the message worked.
425
+ *
426
+ * The best measure of an error message is what the agent does next, and we had the loop
427
+ * (`consecutiveRepeats`) and the shape (`errors[]`) but never the join. This is the most
428
+ * agent-specific metric in the payload: a human would sigh, a log would show nothing.
429
+ */
430
+ errorsRecovered: z.ZodOptional<z.ZodNumber>;
431
+ /** Errors whose very next call failed again — the message did not land. */
432
+ errorsRepeated: z.ZodOptional<z.ZodNumber>;
320
433
  /** Was this a clean shutdown, or a periodic flush of a still-running session? */
321
434
  final: z.ZodBoolean;
435
+ /**
436
+ * WHY the daemon exited. Absent on a periodic flush (`final: false`) — nothing exited.
437
+ *
438
+ * Without this, a designed exit and a real failure are the same row. Measured 2026-08-10/11: 299
439
+ * of 321 `mcp_connection_lost` events were `sse_ended` — the stream the daemon closes on its own
440
+ * scheduled idle shutdown — so the metric meant to say "the agent lost its tools" was mostly
441
+ * counting the daemon going to sleep as designed, and a genuine outage was invisible inside it.
442
+ *
443
+ * The daemon has always known this (`recordExitReason`); it simply never put it on an event. The
444
+ * proxy that emits the outage cannot know it — it only sees a socket end — so the join is made
445
+ * here, on the one event that fires at the same moment and already carries the session.
446
+ */
447
+ exit: z.ZodOptional<z.ZodEnum<["idle", "signal", "unknown"]>>;
322
448
  }, "strip", z.ZodTypeAny, {
323
449
  durationMs: number;
324
450
  toolCalls: number;
@@ -326,6 +452,7 @@ export declare const SessionSummarySchema: z.ZodObject<{
326
452
  toolErrors: number;
327
453
  verifications: number;
328
454
  final: boolean;
455
+ surface?: string | undefined;
329
456
  errors?: {
330
457
  message: string;
331
458
  count: number;
@@ -356,6 +483,10 @@ export declare const SessionSummarySchema: z.ZodObject<{
356
483
  browserCommands?: number | undefined;
357
484
  peakConcurrentTools?: number | undefined;
358
485
  unknownToolCalls?: number | undefined;
486
+ unknownTools?: Record<string, number> | undefined;
487
+ noSessionErrors?: number | undefined;
488
+ consecutiveRepeats?: Record<string, number> | undefined;
489
+ abandonedActions?: number | undefined;
359
490
  machine?: {
360
491
  rssMb: number;
361
492
  heapUsedMb: number;
@@ -365,6 +496,15 @@ export declare const SessionSummarySchema: z.ZodObject<{
365
496
  cpuCount: number;
366
497
  } | undefined;
367
498
  clients?: string[] | undefined;
499
+ clientVersions?: Record<string, string> | undefined;
500
+ appConnects?: number | undefined;
501
+ msToFirstApp?: number | undefined;
502
+ endReason?: "never_used" | "explored" | "abandoned" | "verified" | "client_left" | undefined;
503
+ feedbackPrompted?: number | undefined;
504
+ errorClasses?: Record<string, number> | undefined;
505
+ errorsRecovered?: number | undefined;
506
+ errorsRepeated?: number | undefined;
507
+ exit?: "signal" | "idle" | "unknown" | undefined;
368
508
  }, {
369
509
  durationMs: number;
370
510
  toolCalls: number;
@@ -372,6 +512,7 @@ export declare const SessionSummarySchema: z.ZodObject<{
372
512
  toolErrors: number;
373
513
  verifications: number;
374
514
  final: boolean;
515
+ surface?: string | undefined;
375
516
  errors?: {
376
517
  message: string;
377
518
  count: number;
@@ -402,6 +543,10 @@ export declare const SessionSummarySchema: z.ZodObject<{
402
543
  browserCommands?: number | undefined;
403
544
  peakConcurrentTools?: number | undefined;
404
545
  unknownToolCalls?: number | undefined;
546
+ unknownTools?: Record<string, number> | undefined;
547
+ noSessionErrors?: number | undefined;
548
+ consecutiveRepeats?: Record<string, number> | undefined;
549
+ abandonedActions?: number | undefined;
405
550
  machine?: {
406
551
  rssMb: number;
407
552
  heapUsedMb: number;
@@ -411,6 +556,15 @@ export declare const SessionSummarySchema: z.ZodObject<{
411
556
  cpuCount: number;
412
557
  } | undefined;
413
558
  clients?: string[] | undefined;
559
+ clientVersions?: Record<string, string> | undefined;
560
+ appConnects?: number | undefined;
561
+ msToFirstApp?: number | undefined;
562
+ endReason?: "never_used" | "explored" | "abandoned" | "verified" | "client_left" | undefined;
563
+ feedbackPrompted?: number | undefined;
564
+ errorClasses?: Record<string, number> | undefined;
565
+ errorsRecovered?: number | undefined;
566
+ errorsRepeated?: number | undefined;
567
+ exit?: "signal" | "idle" | "unknown" | undefined;
414
568
  }>;
415
569
  export type SessionSummary = z.infer<typeof SessionSummarySchema>;
416
570
  /**
@@ -436,6 +590,19 @@ export type ProjectSize = (typeof ProjectSize)[keyof typeof ProjectSize];
436
590
  export declare const ProjectProfileSchema: z.ZodObject<{
437
591
  /** Framework detected from package.json (`next`, `vite`, `vue`, `astro`, …). */
438
592
  stack: z.ZodOptional<z.ZodString>;
593
+ /**
594
+ * WHERE the stack was found — and therefore how much to trust the absence of one.
595
+ *
596
+ * `cwd` means the daemon was sitting in the app. `workspace` means it was not, and discovery had
597
+ * to walk down to find it. The split is the diagnostic: it says how often our inference needs
598
+ * help, which is the question that decides whether an agent-correction surface is worth building
599
+ * at all.
600
+ *
601
+ * Measured 2026-08-10/11, before discovery existed here: stack was detected on **0 of the 77
602
+ * projects where Reticle was demonstrably set up**, and 0 of 166 `size: huge` ones. A detector
603
+ * that reads one directory reports nothing precisely where the real repos are.
604
+ */
605
+ stackSource: z.ZodOptional<z.ZodEnum<["cwd", "workspace"]>>;
439
606
  /** Its MAJOR version only — "breaks on React 19" is a work item, a full semver is a fingerprint. */
440
607
  stackMajor: z.ZodOptional<z.ZodNumber>;
441
608
  size: z.ZodOptional<z.ZodNativeEnum<{
@@ -500,6 +667,7 @@ export declare const ProjectProfileSchema: z.ZodObject<{
500
667
  featureDepth: number;
501
668
  stack?: string | undefined;
502
669
  stackMajor?: number | undefined;
670
+ stackSource?: "cwd" | "workspace" | undefined;
503
671
  size?: "medium" | "tiny" | "small" | "large" | "huge" | undefined;
504
672
  monorepo?: boolean | undefined;
505
673
  forge?: "github" | "gitlab" | "bitbucket" | "azure" | "sourcehut" | "codeberg" | "self_hosted" | undefined;
@@ -516,6 +684,7 @@ export declare const ProjectProfileSchema: z.ZodObject<{
516
684
  featureDepth: number;
517
685
  stack?: string | undefined;
518
686
  stackMajor?: number | undefined;
687
+ stackSource?: "cwd" | "workspace" | undefined;
519
688
  size?: "medium" | "tiny" | "small" | "large" | "huge" | undefined;
520
689
  monorepo?: boolean | undefined;
521
690
  forge?: "github" | "gitlab" | "bitbucket" | "azure" | "sourcehut" | "codeberg" | "self_hosted" | undefined;
@@ -182,12 +182,138 @@ export const SessionSummarySchema = z.object({
182
182
  peakConcurrentTools: z.number().int().nonnegative().optional(),
183
183
  /** Calls for a tool name that does not exist. A non-zero value means our surface is confusing. */
184
184
  unknownToolCalls: z.number().int().nonnegative().optional(),
185
+ /**
186
+ * WHICH tools the agent reached for that do not exist, with counts.
187
+ *
188
+ * The count alone said "our surface confused someone" and could never say what they wanted. The
189
+ * name is a feature request in the agent's own vocabulary — and it is a NAME, from our own tool
190
+ * namespace, carrying no app data, so it is safe under the send-names-never-values rule.
191
+ *
192
+ * Bounded and truncated: a guess is a short identifier, and anything longer is not one.
193
+ */
194
+ unknownTools: z.record(z.string().max(64), z.number().int().nonnegative()).optional(),
195
+ /**
196
+ * Tool calls that failed because there was no app to reach — no session connected, no session by
197
+ * that id, or several with none named.
198
+ *
199
+ * The single biggest drop-off in the funnel, and it used to be reachable only by unpacking
200
+ * `errors[]` in HogQL. 74% of daemons never call a tool at all, and of the sessions that made
201
+ * exactly one call, most bounced on precisely this. Absent when it never happened, so the field's
202
+ * PRESENCE is the signal.
203
+ */
204
+ noSessionErrors: z.number().int().nonnegative().optional(),
205
+ /**
206
+ * Longest back-to-back run per tool name — the shape of a retry loop.
207
+ *
208
+ * `toolCounts` reports five useful calls and five retries of one failing call identically, and
209
+ * those are opposite facts: engagement versus an agent stuck. Only tools actually repeated appear.
210
+ */
211
+ consecutiveRepeats: z.record(z.number().int().positive()).optional(),
212
+ /**
213
+ * Actions driven with no verdict after them — the signature of the loop breaking mid-task.
214
+ *
215
+ * An agent that acts and then verifies is the product working; one that acts and wanders off has
216
+ * either given up or lost the thread, and nothing distinguished the two before.
217
+ */
218
+ abandonedActions: z.number().int().nonnegative().optional(),
185
219
  /** The machine at shutdown — was it starved while all this was happening? */
186
220
  machine: MachineSnapshotSchema.optional(),
187
221
  /** Distinct MCP clients seen (`claude-code`, `cursor`), so multi-agent use is visible. */
188
222
  clients: z.array(z.string().max(64)).max(8).optional(),
223
+ /**
224
+ * Client name -> version. The other half of `clients`, and the half that explains regressions.
225
+ *
226
+ * MCP's `clientInfo` carries a name AND a version; we read both at the handshake and kept only
227
+ * the name. A product whose users are agents needs to slice every rate by which agent, on which
228
+ * build — a single global figure hides the finding entirely.
229
+ *
230
+ * NOT the model: `clientInfo` has no concept of one, so the transport genuinely cannot report it.
231
+ * Agents self-report it on feedback, which is the only mechanism there is.
232
+ */
233
+ clientVersions: z.record(z.string().max(64), z.string().max(32)).optional(),
234
+ /**
235
+ * Which tool surface was live. The 18-tool default and the 48-tool full surface are different
236
+ * products from inside an agent's context window, and comparing outcomes across them is how we
237
+ * learn whether the trim helps or hurts.
238
+ */
239
+ surface: z.string().max(32).optional(),
240
+ /**
241
+ * How many times an app's SDK dialled this daemon. **Session-lifetime, never windowed.**
242
+ *
243
+ * Zero here is the single most diagnostic number in the payload: the daemon ran and no app ever
244
+ * connected, which is a BROKEN INSTALL. Non-zero with no tool calls is the opposite problem — the
245
+ * install works and the agent never asked. Before this field those two were the same row, and
246
+ * they have opposite fixes. Measured 2026-08-10/11: 88 of 116 users attached an agent and never
247
+ * drove, and we could not say which case any of them was.
248
+ *
249
+ * A counter rather than an event because the SDK reconnects on every page reload — an event per
250
+ * connect would be high volume for a question one number answers.
251
+ */
252
+ appConnects: z.number().int().nonnegative().optional(),
253
+ /**
254
+ * Milliseconds from daemon start to the FIRST app connecting. Absent when none ever did.
255
+ *
256
+ * Separates "the app was already running" from "the human had to go start it", which is the
257
+ * difference between a smooth install and one that needed a second step nobody documented.
258
+ */
259
+ msToFirstApp: z.number().int().nonnegative().optional(),
260
+ /**
261
+ * What state the AGENT's work was in when the session ended. Absent on a periodic flush.
262
+ *
263
+ * Distinct from `exit`, which says why the PROCESS ended. A daemon can exit tidily on idle while
264
+ * the agent's work was abandoned mid-task, and those are different findings.
265
+ *
266
+ * Measured 2026-08-10/11: 20 of the 28 agents that drove an app produced no verdict, and nothing
267
+ * could say whether that was a product failure or a task that simply ended.
268
+ *
269
+ * Most of this is derivable at query time from `toolCalls` / `verifications` /
270
+ * `abandonedActions`. The part that is NOT derivable is `client_left` — whether the agent
271
+ * detached or simply stopped asking — which is why the daemon records it rather than leaving the
272
+ * whole thing to a query.
273
+ */
274
+ endReason: z.enum(['never_used', 'explored', 'abandoned', 'verified', 'client_left']).optional(),
275
+ /**
276
+ * How often Reticle invited the agent to send feedback.
277
+ *
278
+ * The denominator for `feedback_submitted`. A prompt nobody acts on is decoration, and without
279
+ * this we could never tell the difference between "agents have nothing to report" and "our
280
+ * invitation is invisible". Instrumenting our own nudge is what makes it a designed system
281
+ * rather than a hope.
282
+ */
283
+ feedbackPrompted: z.number().int().nonnegative().optional(),
284
+ /**
285
+ * Tool errors bucketed by WHOSE defect they are: `schema` (our grammar failed to explain itself),
286
+ * `state` (the world moved), `refusal` (we said no on purpose), `other` (a blind spot).
287
+ *
288
+ * `toolErrors` is one number over three failures with three different fixes. Only the `schema`
289
+ * bucket is fixable by writing better descriptions, and it was indistinguishable from the rest.
290
+ */
291
+ errorClasses: z.record(z.string().max(16), z.number().int().nonnegative()).optional(),
292
+ /**
293
+ * Errors after which the agent's NEXT call succeeded — the message worked.
294
+ *
295
+ * The best measure of an error message is what the agent does next, and we had the loop
296
+ * (`consecutiveRepeats`) and the shape (`errors[]`) but never the join. This is the most
297
+ * agent-specific metric in the payload: a human would sigh, a log would show nothing.
298
+ */
299
+ errorsRecovered: z.number().int().nonnegative().optional(),
300
+ /** Errors whose very next call failed again — the message did not land. */
301
+ errorsRepeated: z.number().int().nonnegative().optional(),
189
302
  /** Was this a clean shutdown, or a periodic flush of a still-running session? */
190
303
  final: z.boolean(),
304
+ /**
305
+ * WHY the daemon exited. Absent on a periodic flush (`final: false`) — nothing exited.
306
+ *
307
+ * Without this, a designed exit and a real failure are the same row. Measured 2026-08-10/11: 299
308
+ * of 321 `mcp_connection_lost` events were `sse_ended` — the stream the daemon closes on its own
309
+ * scheduled idle shutdown — so the metric meant to say "the agent lost its tools" was mostly
310
+ * counting the daemon going to sleep as designed, and a genuine outage was invisible inside it.
311
+ *
312
+ * The daemon has always known this (`recordExitReason`); it simply never put it on an event. The
313
+ * proxy that emits the outage cannot know it — it only sees a socket end — so the join is made
314
+ * here, on the one event that fires at the same moment and already carries the session.
315
+ */
316
+ exit: z.enum(['idle', 'signal', 'unknown']).optional(),
191
317
  });
192
318
  /**
193
319
  * Coarse size buckets. A bucket answers "is this a toy or a real codebase" — which is the actual
@@ -211,6 +337,19 @@ export const ProjectSize = {
211
337
  export const ProjectProfileSchema = z.object({
212
338
  /** Framework detected from package.json (`next`, `vite`, `vue`, `astro`, …). */
213
339
  stack: z.string().min(1).max(64).optional(),
340
+ /**
341
+ * WHERE the stack was found — and therefore how much to trust the absence of one.
342
+ *
343
+ * `cwd` means the daemon was sitting in the app. `workspace` means it was not, and discovery had
344
+ * to walk down to find it. The split is the diagnostic: it says how often our inference needs
345
+ * help, which is the question that decides whether an agent-correction surface is worth building
346
+ * at all.
347
+ *
348
+ * Measured 2026-08-10/11, before discovery existed here: stack was detected on **0 of the 77
349
+ * projects where Reticle was demonstrably set up**, and 0 of 166 `size: huge` ones. A detector
350
+ * that reads one directory reports nothing precisely where the real repos are.
351
+ */
352
+ stackSource: z.enum(['cwd', 'workspace']).optional(),
214
353
  /** Its MAJOR version only — "breaks on React 19" is a work item, a full semver is a fingerprint. */
215
354
  stackMajor: z.number().int().nonnegative().optional(),
216
355
  size: z.nativeEnum(ProjectSize).optional(),