@reticlehq/core 2.5.0 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -73,6 +73,14 @@ export declare const ReticleEnv: {
73
73
  * killing live runs mid-install. Derived from the base when unset.
74
74
  */
75
75
  readonly IDLE_ATTACHED: "RETICLE_IDLE_ATTACHED_MS";
76
+ /**
77
+ * How often the daemon writes `reticle_daemon_alive`, so a GAP in its log is evidence it died.
78
+ *
79
+ * Overridable for the same reason the idle windows are: a spec that has to prove "a killed daemon
80
+ * is distinguishable from a tidy one" cannot wait 30 seconds per beat, and a spec that instead
81
+ * re-implements the cadence is insensitive to the thing it claims to guard.
82
+ */
83
+ readonly HEARTBEAT: "RETICLE_HEARTBEAT_MS";
76
84
  /** Directory holding the auto-provisioned pairing token. Defaults to ~/.reticle; relocatable for CI. */
77
85
  readonly PAIRING_TOKEN_DIR: "RETICLE_PAIRING_TOKEN_DIR";
78
86
  /** Force the durable causal journal off (`0`/`false`/`off`) or on (`1`/`true`/`on`); default on. */
@@ -404,6 +412,14 @@ export declare const InputModeReason: {
404
412
  readonly DRAG_TARGET_UNRESOLVED: "drag-target-unresolved";
405
413
  readonly PROVIDER_DECLINED: "provider-declined";
406
414
  readonly PROVIDER_ERROR: "provider-error";
415
+ /**
416
+ * No real-input provider is configured at all, and the caller explicitly asked for one with
417
+ * `native:true`. Only emitted on that explicit ask: without a provider EVERY action is synthetic,
418
+ * so annotating all of them would put a reason on the most-used tool in the product for no gain.
419
+ * An agent that asked for a trusted click, though, has an expectation to correct — and this is
420
+ * permanent for the session, not a transient downgrade, so it should stop asking.
421
+ */
422
+ readonly NOT_CONFIGURED: "real-input-not-configured-for-this-session";
407
423
  };
408
424
  export type InputModeReason = (typeof InputModeReason)[keyof typeof InputModeReason];
409
425
  /** Best-effort caveats attached to action results so the agent can interpret a no-op. */
package/dist/constants.js CHANGED
@@ -75,6 +75,14 @@ export const ReticleEnv = {
75
75
  * killing live runs mid-install. Derived from the base when unset.
76
76
  */
77
77
  IDLE_ATTACHED: 'RETICLE_IDLE_ATTACHED_MS',
78
+ /**
79
+ * How often the daemon writes `reticle_daemon_alive`, so a GAP in its log is evidence it died.
80
+ *
81
+ * Overridable for the same reason the idle windows are: a spec that has to prove "a killed daemon
82
+ * is distinguishable from a tidy one" cannot wait 30 seconds per beat, and a spec that instead
83
+ * re-implements the cadence is insensitive to the thing it claims to guard.
84
+ */
85
+ HEARTBEAT: 'RETICLE_HEARTBEAT_MS',
78
86
  /** Directory holding the auto-provisioned pairing token. Defaults to ~/.reticle; relocatable for CI. */
79
87
  PAIRING_TOKEN_DIR: 'RETICLE_PAIRING_TOKEN_DIR',
80
88
  /** Force the durable causal journal off (`0`/`false`/`off`) or on (`1`/`true`/`on`); default on. */
@@ -403,6 +411,14 @@ export const InputModeReason = {
403
411
  DRAG_TARGET_UNRESOLVED: 'drag-target-unresolved', // drag toRef missing or not locatable
404
412
  PROVIDER_DECLINED: 'provider-declined', // provider chose not to perform
405
413
  PROVIDER_ERROR: 'provider-error', // provider threw → fell back to synthetic
414
+ /**
415
+ * No real-input provider is configured at all, and the caller explicitly asked for one with
416
+ * `native:true`. Only emitted on that explicit ask: without a provider EVERY action is synthetic,
417
+ * so annotating all of them would put a reason on the most-used tool in the product for no gain.
418
+ * An agent that asked for a trusted click, though, has an expectation to correct — and this is
419
+ * permanent for the session, not a transient downgrade, so it should stop asking.
420
+ */
421
+ NOT_CONFIGURED: 'real-input-not-configured-for-this-session',
406
422
  };
407
423
  /** Best-effort caveats attached to action results so the agent can interpret a no-op. */
408
424
  export const ActionWarning = {
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The high-volume, low-signal floor. These fire continuously on any live page and are the ONLY
3
+ * thing that should be sacrificed when a buffer is full. Everything else is scarce evidence a
4
+ * verdict depends on. Shared by the browser transport queue and the server ring buffer so both
5
+ * eviction policies agree on what to sacrifice.
6
+ */
7
+ export declare const CHURN_TYPES: ReadonlySet<string>;
@@ -0,0 +1,15 @@
1
+ import { EventType } from './constants.js';
2
+ /**
3
+ * The high-volume, low-signal floor. These fire continuously on any live page and are the ONLY
4
+ * thing that should be sacrificed when a buffer is full. Everything else is scarce evidence a
5
+ * verdict depends on. Shared by the browser transport queue and the server ring buffer so both
6
+ * eviction policies agree on what to sacrifice.
7
+ */
8
+ export const CHURN_TYPES = new Set([
9
+ EventType.DOM_TEXT,
10
+ EventType.ANIM_START,
11
+ EventType.ANIM_END,
12
+ EventType.RENDER_COMMIT,
13
+ EventType.PAGE_HEALTH,
14
+ EventType.SCROLL_POSITION,
15
+ ]);
@@ -110,6 +110,37 @@ export declare const ContradictionKind: {
110
110
  readonly ROUTE_RENDERED_NOTHING: "route-rendered-nothing";
111
111
  };
112
112
  export type ContradictionKind = (typeof ContradictionKind)[keyof typeof ContradictionKind];
113
+ /**
114
+ * Contradictions inferred from the ABSENCE of evidence in a window whose end Reticle itself chose.
115
+ *
116
+ * The distinction is not cosmetic — it decides whether Reticle is entitled to say an action FAILED.
117
+ * The other kinds are things we positively observed: a request came back 500 while the UI advanced,
118
+ * a signal fired carrying data that disagrees with the DOM, a written field echoed a different
119
+ * value. Those are evidence AGAINST the action, and they must keep outranking a passing assertion,
120
+ * because a green assertion sitting on top of a failed write is the entire bug class this product
121
+ * exists to catch.
122
+ *
123
+ * These five are different. Each says "the thing I expected to see had not happened YET when I
124
+ * stopped looking" — and the window closes the moment the predicate first passes, which on an app
125
+ * that navigates optimistically is routinely before the network drains. Reproduced on the bench app:
126
+ * `auth:granted` fired WITH matching data, application state changed, the token was stored, capture
127
+ * integrity was clean and the honesty grade was `signal` — our strongest evidence class — and the
128
+ * verdict was still `no`, because one POST had not settled. A timing observation overruled a
129
+ * consequence observation, which inverts the grade hierarchy the verifier is built on.
130
+ *
131
+ * A false negative is not the mirror of a false positive here. A false positive stops an agent
132
+ * early; a false NEGATIVE makes it redo work that already succeeded, or stop trusting the verdict
133
+ * channel — and the verdict channel is the product. `bug.attribution` was deleted for exactly this
134
+ * reason: every `attribution: 'app'` on `request-never-settled` turned out to be a misattribution.
135
+ * We removed the field and left the verdict.
136
+ *
137
+ * So these downgrade a verdict to UNKNOWN rather than asserting NO. The finding is still reported in
138
+ * `contradictions` either way — nothing is hidden, and an agent that wants to wait and re-check has
139
+ * everything it needs to.
140
+ */
141
+ export declare const ABSENCE_DERIVED_CONTRADICTIONS: ReadonlySet<ContradictionKind>;
142
+ /** True when this kind was inferred from absence rather than positively observed. */
143
+ export declare function isAbsenceDerived(kind: string): boolean;
113
144
  /**
114
145
  * HTTP methods that CHANGE server state. Several contradiction rules are restricted to these on
115
146
  * purpose: a GET that fires without moving the UI is a prefetch, but a POST that does is a lost
package/dist/findings.js CHANGED
@@ -109,6 +109,45 @@ export const ContradictionKind = {
109
109
  */
110
110
  ROUTE_RENDERED_NOTHING: 'route-rendered-nothing',
111
111
  };
112
+ /**
113
+ * Contradictions inferred from the ABSENCE of evidence in a window whose end Reticle itself chose.
114
+ *
115
+ * The distinction is not cosmetic — it decides whether Reticle is entitled to say an action FAILED.
116
+ * The other kinds are things we positively observed: a request came back 500 while the UI advanced,
117
+ * a signal fired carrying data that disagrees with the DOM, a written field echoed a different
118
+ * value. Those are evidence AGAINST the action, and they must keep outranking a passing assertion,
119
+ * because a green assertion sitting on top of a failed write is the entire bug class this product
120
+ * exists to catch.
121
+ *
122
+ * These five are different. Each says "the thing I expected to see had not happened YET when I
123
+ * stopped looking" — and the window closes the moment the predicate first passes, which on an app
124
+ * that navigates optimistically is routinely before the network drains. Reproduced on the bench app:
125
+ * `auth:granted` fired WITH matching data, application state changed, the token was stored, capture
126
+ * integrity was clean and the honesty grade was `signal` — our strongest evidence class — and the
127
+ * verdict was still `no`, because one POST had not settled. A timing observation overruled a
128
+ * consequence observation, which inverts the grade hierarchy the verifier is built on.
129
+ *
130
+ * A false negative is not the mirror of a false positive here. A false positive stops an agent
131
+ * early; a false NEGATIVE makes it redo work that already succeeded, or stop trusting the verdict
132
+ * channel — and the verdict channel is the product. `bug.attribution` was deleted for exactly this
133
+ * reason: every `attribution: 'app'` on `request-never-settled` turned out to be a misattribution.
134
+ * We removed the field and left the verdict.
135
+ *
136
+ * So these downgrade a verdict to UNKNOWN rather than asserting NO. The finding is still reported in
137
+ * `contradictions` either way — nothing is hidden, and an agent that wants to wait and re-check has
138
+ * everything it needs to.
139
+ */
140
+ export const ABSENCE_DERIVED_CONTRADICTIONS = new Set([
141
+ ContradictionKind.REQUEST_NEVER_SETTLED,
142
+ ContradictionKind.RESPONSE_IGNORED,
143
+ ContradictionKind.ROUTE_RENDERED_NOTHING,
144
+ ContradictionKind.ACTION_HAD_NO_EFFECT,
145
+ ContradictionKind.DUPLICATE_REQUEST,
146
+ ]);
147
+ /** True when this kind was inferred from absence rather than positively observed. */
148
+ export function isAbsenceDerived(kind) {
149
+ return ABSENCE_DERIVED_CONTRADICTIONS.has(kind);
150
+ }
112
151
  /**
113
152
  * HTTP methods that CHANGE server state. Several contradiction rules are restricted to these on
114
153
  * purpose: a GET that fires without moving the UI is a prefetch, but a POST that does is a lost
package/dist/index.d.ts CHANGED
@@ -9,6 +9,7 @@
9
9
  */
10
10
  export * from './constants.js';
11
11
  export * from './source-constants.js';
12
+ export * from './event-classification.js';
12
13
  export * from './verified-constants.js';
13
14
  export * from './session-constants.js';
14
15
  export * from './messages.js';
package/dist/index.js CHANGED
@@ -10,6 +10,7 @@
10
10
  // ── STABLE public surface: the wire/domain contract ──────────────────────────────────────────────
11
11
  export * from './constants.js'; // EventType, ActionType, wire constants, TRANSPORT_LIMITS, …
12
12
  export * from './source-constants.js'; // DATA_RETICLE_SOURCE_ATTR, RETICLE_ROOT_GLOBAL
13
+ export * from './event-classification.js'; // CHURN_TYPES — shared eviction priority for buffer/queue
13
14
  export * from './verified-constants.js'; // Verified — the one field an agent gates on
14
15
  export * from './session-constants.js';
15
16
  export * from './messages.js'; // ReticleEvent + the message schemas
@@ -289,6 +289,16 @@ 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>>;
292
302
  /**
293
303
  * Tool calls that failed because there was no app to reach — no session connected, no session by
294
304
  * that id, or several with none named.
@@ -341,8 +351,100 @@ export declare const SessionSummarySchema: z.ZodObject<{
341
351
  }>>;
342
352
  /** Distinct MCP clients seen (`claude-code`, `cursor`), so multi-agent use is visible. */
343
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. In the field most users who attached an agent 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
+ * In the field most 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>;
344
433
  /** Was this a clean shutdown, or a periodic flush of a still-running session? */
345
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. In the field the large
439
+ * majority of `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"]>>;
346
448
  }, "strip", z.ZodTypeAny, {
347
449
  durationMs: number;
348
450
  toolCalls: number;
@@ -350,6 +452,7 @@ export declare const SessionSummarySchema: z.ZodObject<{
350
452
  toolErrors: number;
351
453
  verifications: number;
352
454
  final: boolean;
455
+ surface?: string | undefined;
353
456
  errors?: {
354
457
  message: string;
355
458
  count: number;
@@ -380,6 +483,7 @@ export declare const SessionSummarySchema: z.ZodObject<{
380
483
  browserCommands?: number | undefined;
381
484
  peakConcurrentTools?: number | undefined;
382
485
  unknownToolCalls?: number | undefined;
486
+ unknownTools?: Record<string, number> | undefined;
383
487
  noSessionErrors?: number | undefined;
384
488
  consecutiveRepeats?: Record<string, number> | undefined;
385
489
  abandonedActions?: number | undefined;
@@ -392,6 +496,15 @@ export declare const SessionSummarySchema: z.ZodObject<{
392
496
  cpuCount: number;
393
497
  } | undefined;
394
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;
395
508
  }, {
396
509
  durationMs: number;
397
510
  toolCalls: number;
@@ -399,6 +512,7 @@ export declare const SessionSummarySchema: z.ZodObject<{
399
512
  toolErrors: number;
400
513
  verifications: number;
401
514
  final: boolean;
515
+ surface?: string | undefined;
402
516
  errors?: {
403
517
  message: string;
404
518
  count: number;
@@ -429,6 +543,7 @@ export declare const SessionSummarySchema: z.ZodObject<{
429
543
  browserCommands?: number | undefined;
430
544
  peakConcurrentTools?: number | undefined;
431
545
  unknownToolCalls?: number | undefined;
546
+ unknownTools?: Record<string, number> | undefined;
432
547
  noSessionErrors?: number | undefined;
433
548
  consecutiveRepeats?: Record<string, number> | undefined;
434
549
  abandonedActions?: number | undefined;
@@ -441,6 +556,15 @@ export declare const SessionSummarySchema: z.ZodObject<{
441
556
  cpuCount: number;
442
557
  } | undefined;
443
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;
444
568
  }>;
445
569
  export type SessionSummary = z.infer<typeof SessionSummarySchema>;
446
570
  /**
@@ -466,6 +590,19 @@ export type ProjectSize = (typeof ProjectSize)[keyof typeof ProjectSize];
466
590
  export declare const ProjectProfileSchema: z.ZodObject<{
467
591
  /** Framework detected from package.json (`next`, `vite`, `vue`, `astro`, …). */
468
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
+ * Before discovery existed here, stack was detected on **none of the projects where Reticle was
602
+ * demonstrably set up**, and none of the large ones either. A detector
603
+ * that reads one directory reports nothing precisely where the real repos are.
604
+ */
605
+ stackSource: z.ZodOptional<z.ZodEnum<["cwd", "workspace"]>>;
469
606
  /** Its MAJOR version only — "breaks on React 19" is a work item, a full semver is a fingerprint. */
470
607
  stackMajor: z.ZodOptional<z.ZodNumber>;
471
608
  size: z.ZodOptional<z.ZodNativeEnum<{
@@ -530,6 +667,7 @@ export declare const ProjectProfileSchema: z.ZodObject<{
530
667
  featureDepth: number;
531
668
  stack?: string | undefined;
532
669
  stackMajor?: number | undefined;
670
+ stackSource?: "cwd" | "workspace" | undefined;
533
671
  size?: "medium" | "tiny" | "small" | "large" | "huge" | undefined;
534
672
  monorepo?: boolean | undefined;
535
673
  forge?: "github" | "gitlab" | "bitbucket" | "azure" | "sourcehut" | "codeberg" | "self_hosted" | undefined;
@@ -546,6 +684,7 @@ export declare const ProjectProfileSchema: z.ZodObject<{
546
684
  featureDepth: number;
547
685
  stack?: string | undefined;
548
686
  stackMajor?: number | undefined;
687
+ stackSource?: "cwd" | "workspace" | undefined;
549
688
  size?: "medium" | "tiny" | "small" | "large" | "huge" | undefined;
550
689
  monorepo?: boolean | undefined;
551
690
  forge?: "github" | "gitlab" | "bitbucket" | "azure" | "sourcehut" | "codeberg" | "self_hosted" | undefined;
@@ -182,6 +182,16 @@ 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(),
185
195
  /**
186
196
  * Tool calls that failed because there was no app to reach — no session connected, no session by
187
197
  * that id, or several with none named.
@@ -210,8 +220,100 @@ export const SessionSummarySchema = z.object({
210
220
  machine: MachineSnapshotSchema.optional(),
211
221
  /** Distinct MCP clients seen (`claude-code`, `cursor`), so multi-agent use is visible. */
212
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. In the field most users who attached an agent 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
+ * In the field most 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(),
213
302
  /** Was this a clean shutdown, or a periodic flush of a still-running session? */
214
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. In the field the large
308
+ * majority of `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(),
215
317
  });
216
318
  /**
217
319
  * Coarse size buckets. A bucket answers "is this a toy or a real codebase" — which is the actual
@@ -235,6 +337,19 @@ export const ProjectSize = {
235
337
  export const ProjectProfileSchema = z.object({
236
338
  /** Framework detected from package.json (`next`, `vite`, `vue`, `astro`, …). */
237
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
+ * Before discovery existed here, stack was detected on **none of the projects where Reticle was
349
+ * demonstrably set up**, and none of the large ones either. A detector
350
+ * that reads one directory reports nothing precisely where the real repos are.
351
+ */
352
+ stackSource: z.enum(['cwd', 'workspace']).optional(),
238
353
  /** Its MAJOR version only — "breaks on React 19" is a work item, a full semver is a fingerprint. */
239
354
  stackMajor: z.number().int().nonnegative().optional(),
240
355
  size: z.nativeEnum(ProjectSize).optional(),