@reticlehq/core 2.10.0 → 2.12.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 (43) hide show
  1. package/dist/constants.d.ts +22 -0
  2. package/dist/constants.js +23 -1
  3. package/dist/document-identity.d.ts +39 -0
  4. package/dist/document-identity.js +53 -0
  5. package/dist/edit-epoch.d.ts +36 -0
  6. package/dist/edit-epoch.js +40 -0
  7. package/dist/event-payloads.d.ts +18 -4
  8. package/dist/event-payloads.js +11 -1
  9. package/dist/findings.d.ts +62 -0
  10. package/dist/findings.js +75 -0
  11. package/dist/flow-types.d.ts +70 -0
  12. package/dist/flow-types.js +22 -0
  13. package/dist/index.d.ts +7 -0
  14. package/dist/index.js +7 -0
  15. package/dist/instrumentation-gap.d.ts +141 -0
  16. package/dist/instrumentation-gap.js +164 -0
  17. package/dist/intent.d.ts +332 -0
  18. package/dist/intent.js +133 -0
  19. package/dist/journal.d.ts +33 -0
  20. package/dist/journal.js +20 -0
  21. package/dist/messages.d.ts +84 -10
  22. package/dist/messages.js +20 -0
  23. package/dist/notices.d.ts +5 -3
  24. package/dist/notices.js +5 -3
  25. package/dist/project-registry.d.ts +86 -0
  26. package/dist/project-registry.js +66 -0
  27. package/dist/run-context.d.ts +122 -0
  28. package/dist/run-context.js +118 -0
  29. package/dist/schema/event-message.json +10 -0
  30. package/dist/schema/event-type.json +1 -0
  31. package/dist/schema/reticle-event.json +10 -0
  32. package/dist/schema/reticle-message.json +10 -0
  33. package/dist/security.js +17 -1
  34. package/dist/source-constants.cjs +9 -0
  35. package/dist/source-constants.d.cts +4 -0
  36. package/dist/telemetry-session.d.ts +2 -2
  37. package/dist/telemetry.d.ts +6 -98
  38. package/dist/telemetry.js +0 -41
  39. package/dist/types.d.ts +70 -0
  40. package/dist/types.js +14 -0
  41. package/dist/unreachable-notice.d.ts +19 -0
  42. package/dist/unreachable-notice.js +26 -0
  43. package/package.json +6 -2
@@ -108,6 +108,7 @@ export declare const ReticleEventSchema: z.ZodObject<{
108
108
  readonly STATE_CHANGE: "state.change";
109
109
  readonly STORAGE_CHANGE: "storage.change";
110
110
  readonly PAGE_HEALTH: "page.health";
111
+ readonly CONTEXT_OPENED: "context.opened";
111
112
  readonly RENDER_COMMIT: "render.commit";
112
113
  readonly FOCUS_CHANGE: "focus.change";
113
114
  readonly FLOW_RECORDED: "flow.recorded";
@@ -138,10 +139,27 @@ export declare const ReticleEventSchema: z.ZodObject<{
138
139
  attribution: z.ZodOptional<z.ZodNativeEnum<{
139
140
  readonly WINDOW: "window";
140
141
  }>>;
142
+ /**
143
+ * The document this was observed under. Minted once per real document; a full navigation replaces
144
+ * both. Lets evidence from a superseded document be excluded rather than counted against an action
145
+ * taken now. Optional for back-compat with SDKs that predate it, which is why absence is read as
146
+ * "current" rather than "foreign" — see `isSameDocument`.
147
+ */
148
+ documentId: z.ZodOptional<z.ZodString>;
149
+ /**
150
+ * The round of source edits this was observed under — a counter the SDK advances once per applied
151
+ * hot update. A hot update replaces modules and re-renders INSIDE the same document, so
152
+ * `documentId` cannot see it; this is the edit-shaped half of the same question.
153
+ *
154
+ * Optional, and absent while nothing has hot-updated, which is why absence is read as "current"
155
+ * rather than "foreign" — see `isSameEditEpoch`. Most pages have no channel that could report an
156
+ * update at all, so a stamp of `NO_EDITS_OBSERVED` would be wire spent on the word "unknown".
157
+ */
158
+ editEpoch: z.ZodOptional<z.ZodNumber>;
141
159
  /** Event-type-specific payload. Kept open here; refined per observer at the edges. */
142
160
  data: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
143
161
  }, "strip", z.ZodTypeAny, {
144
- type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "render.commit" | "focus.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download";
162
+ type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "context.opened" | "render.commit" | "focus.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download";
145
163
  t: number;
146
164
  sessionId: string;
147
165
  data: Record<string, unknown>;
@@ -149,14 +167,18 @@ export declare const ReticleEventSchema: z.ZodObject<{
149
167
  seq?: number | undefined;
150
168
  actionId?: string | undefined;
151
169
  attribution?: "window" | undefined;
170
+ documentId?: string | undefined;
171
+ editEpoch?: number | undefined;
152
172
  }, {
153
- type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "render.commit" | "focus.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download";
173
+ type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "context.opened" | "render.commit" | "focus.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download";
154
174
  t: number;
155
175
  sessionId: string;
156
176
  ref?: string | undefined;
157
177
  seq?: number | undefined;
158
178
  actionId?: string | undefined;
159
179
  attribution?: "window" | undefined;
180
+ documentId?: string | undefined;
181
+ editEpoch?: number | undefined;
160
182
  data?: Record<string, unknown> | undefined;
161
183
  }>;
162
184
  export type ReticleEvent = z.infer<typeof ReticleEventSchema>;
@@ -309,6 +331,7 @@ export declare const EventMessageSchema: z.ZodObject<{
309
331
  readonly STATE_CHANGE: "state.change";
310
332
  readonly STORAGE_CHANGE: "storage.change";
311
333
  readonly PAGE_HEALTH: "page.health";
334
+ readonly CONTEXT_OPENED: "context.opened";
312
335
  readonly RENDER_COMMIT: "render.commit";
313
336
  readonly FOCUS_CHANGE: "focus.change";
314
337
  readonly FLOW_RECORDED: "flow.recorded";
@@ -339,10 +362,27 @@ export declare const EventMessageSchema: z.ZodObject<{
339
362
  attribution: z.ZodOptional<z.ZodNativeEnum<{
340
363
  readonly WINDOW: "window";
341
364
  }>>;
365
+ /**
366
+ * The document this was observed under. Minted once per real document; a full navigation replaces
367
+ * both. Lets evidence from a superseded document be excluded rather than counted against an action
368
+ * taken now. Optional for back-compat with SDKs that predate it, which is why absence is read as
369
+ * "current" rather than "foreign" — see `isSameDocument`.
370
+ */
371
+ documentId: z.ZodOptional<z.ZodString>;
372
+ /**
373
+ * The round of source edits this was observed under — a counter the SDK advances once per applied
374
+ * hot update. A hot update replaces modules and re-renders INSIDE the same document, so
375
+ * `documentId` cannot see it; this is the edit-shaped half of the same question.
376
+ *
377
+ * Optional, and absent while nothing has hot-updated, which is why absence is read as "current"
378
+ * rather than "foreign" — see `isSameEditEpoch`. Most pages have no channel that could report an
379
+ * update at all, so a stamp of `NO_EDITS_OBSERVED` would be wire spent on the word "unknown".
380
+ */
381
+ editEpoch: z.ZodOptional<z.ZodNumber>;
342
382
  /** Event-type-specific payload. Kept open here; refined per observer at the edges. */
343
383
  data: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
344
384
  }, "strip", z.ZodTypeAny, {
345
- type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "render.commit" | "focus.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download";
385
+ type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "context.opened" | "render.commit" | "focus.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download";
346
386
  t: number;
347
387
  sessionId: string;
348
388
  data: Record<string, unknown>;
@@ -350,19 +390,23 @@ export declare const EventMessageSchema: z.ZodObject<{
350
390
  seq?: number | undefined;
351
391
  actionId?: string | undefined;
352
392
  attribution?: "window" | undefined;
393
+ documentId?: string | undefined;
394
+ editEpoch?: number | undefined;
353
395
  }, {
354
- type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "render.commit" | "focus.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download";
396
+ type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "context.opened" | "render.commit" | "focus.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download";
355
397
  t: number;
356
398
  sessionId: string;
357
399
  ref?: string | undefined;
358
400
  seq?: number | undefined;
359
401
  actionId?: string | undefined;
360
402
  attribution?: "window" | undefined;
403
+ documentId?: string | undefined;
404
+ editEpoch?: number | undefined;
361
405
  data?: Record<string, unknown> | undefined;
362
406
  }>;
363
407
  }, "strip", z.ZodTypeAny, {
364
408
  event: {
365
- type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "render.commit" | "focus.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download";
409
+ type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "context.opened" | "render.commit" | "focus.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download";
366
410
  t: number;
367
411
  sessionId: string;
368
412
  data: Record<string, unknown>;
@@ -370,17 +414,21 @@ export declare const EventMessageSchema: z.ZodObject<{
370
414
  seq?: number | undefined;
371
415
  actionId?: string | undefined;
372
416
  attribution?: "window" | undefined;
417
+ documentId?: string | undefined;
418
+ editEpoch?: number | undefined;
373
419
  };
374
420
  kind: "event";
375
421
  }, {
376
422
  event: {
377
- type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "render.commit" | "focus.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download";
423
+ type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "context.opened" | "render.commit" | "focus.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download";
378
424
  t: number;
379
425
  sessionId: string;
380
426
  ref?: string | undefined;
381
427
  seq?: number | undefined;
382
428
  actionId?: string | undefined;
383
429
  attribution?: "window" | undefined;
430
+ documentId?: string | undefined;
431
+ editEpoch?: number | undefined;
384
432
  data?: Record<string, unknown> | undefined;
385
433
  };
386
434
  kind: "event";
@@ -525,6 +573,7 @@ export declare const ReticleMessageSchema: z.ZodDiscriminatedUnion<"kind", [z.Zo
525
573
  readonly STATE_CHANGE: "state.change";
526
574
  readonly STORAGE_CHANGE: "storage.change";
527
575
  readonly PAGE_HEALTH: "page.health";
576
+ readonly CONTEXT_OPENED: "context.opened";
528
577
  readonly RENDER_COMMIT: "render.commit";
529
578
  readonly FOCUS_CHANGE: "focus.change";
530
579
  readonly FLOW_RECORDED: "flow.recorded";
@@ -555,10 +604,27 @@ export declare const ReticleMessageSchema: z.ZodDiscriminatedUnion<"kind", [z.Zo
555
604
  attribution: z.ZodOptional<z.ZodNativeEnum<{
556
605
  readonly WINDOW: "window";
557
606
  }>>;
607
+ /**
608
+ * The document this was observed under. Minted once per real document; a full navigation replaces
609
+ * both. Lets evidence from a superseded document be excluded rather than counted against an action
610
+ * taken now. Optional for back-compat with SDKs that predate it, which is why absence is read as
611
+ * "current" rather than "foreign" — see `isSameDocument`.
612
+ */
613
+ documentId: z.ZodOptional<z.ZodString>;
614
+ /**
615
+ * The round of source edits this was observed under — a counter the SDK advances once per applied
616
+ * hot update. A hot update replaces modules and re-renders INSIDE the same document, so
617
+ * `documentId` cannot see it; this is the edit-shaped half of the same question.
618
+ *
619
+ * Optional, and absent while nothing has hot-updated, which is why absence is read as "current"
620
+ * rather than "foreign" — see `isSameEditEpoch`. Most pages have no channel that could report an
621
+ * update at all, so a stamp of `NO_EDITS_OBSERVED` would be wire spent on the word "unknown".
622
+ */
623
+ editEpoch: z.ZodOptional<z.ZodNumber>;
558
624
  /** Event-type-specific payload. Kept open here; refined per observer at the edges. */
559
625
  data: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
560
626
  }, "strip", z.ZodTypeAny, {
561
- type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "render.commit" | "focus.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download";
627
+ type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "context.opened" | "render.commit" | "focus.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download";
562
628
  t: number;
563
629
  sessionId: string;
564
630
  data: Record<string, unknown>;
@@ -566,19 +632,23 @@ export declare const ReticleMessageSchema: z.ZodDiscriminatedUnion<"kind", [z.Zo
566
632
  seq?: number | undefined;
567
633
  actionId?: string | undefined;
568
634
  attribution?: "window" | undefined;
635
+ documentId?: string | undefined;
636
+ editEpoch?: number | undefined;
569
637
  }, {
570
- type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "render.commit" | "focus.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download";
638
+ type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "context.opened" | "render.commit" | "focus.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download";
571
639
  t: number;
572
640
  sessionId: string;
573
641
  ref?: string | undefined;
574
642
  seq?: number | undefined;
575
643
  actionId?: string | undefined;
576
644
  attribution?: "window" | undefined;
645
+ documentId?: string | undefined;
646
+ editEpoch?: number | undefined;
577
647
  data?: Record<string, unknown> | undefined;
578
648
  }>;
579
649
  }, "strip", z.ZodTypeAny, {
580
650
  event: {
581
- type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "render.commit" | "focus.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download";
651
+ type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "context.opened" | "render.commit" | "focus.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download";
582
652
  t: number;
583
653
  sessionId: string;
584
654
  data: Record<string, unknown>;
@@ -586,17 +656,21 @@ export declare const ReticleMessageSchema: z.ZodDiscriminatedUnion<"kind", [z.Zo
586
656
  seq?: number | undefined;
587
657
  actionId?: string | undefined;
588
658
  attribution?: "window" | undefined;
659
+ documentId?: string | undefined;
660
+ editEpoch?: number | undefined;
589
661
  };
590
662
  kind: "event";
591
663
  }, {
592
664
  event: {
593
- type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "render.commit" | "focus.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download";
665
+ type: "signal" | "dom.added" | "dom.removed" | "dom.attr" | "dom.text" | "net.request" | "net.pending" | "net.stream" | "perf" | "route.change" | "console.log" | "console.warn" | "console.error" | "console.info" | "console.debug" | "error.uncaught" | "visible.shown" | "anim.start" | "anim.end" | "scroll.position" | "reveal.shown" | "state.change" | "storage.change" | "page.health" | "context.opened" | "render.commit" | "focus.change" | "flow.recorded" | "transport.overflow" | "truncated" | "blind-spot" | "sdk.failed" | "net.detail" | "human.control" | "human.mark" | "download";
594
666
  t: number;
595
667
  sessionId: string;
596
668
  ref?: string | undefined;
597
669
  seq?: number | undefined;
598
670
  actionId?: string | undefined;
599
671
  attribution?: "window" | undefined;
672
+ documentId?: string | undefined;
673
+ editEpoch?: number | undefined;
600
674
  data?: Record<string, unknown> | undefined;
601
675
  };
602
676
  kind: "event";
package/dist/messages.js CHANGED
@@ -2,8 +2,11 @@ import { z } from 'zod';
2
2
  import { EventAttribution, EventType, RETICLE_PROTOCOL_VERSION, MessageKind, TRANSPORT_LIMITS, } from './constants.js';
3
3
  import { HumanControlKind, MarkAnchorStrategy } from './session-constants.js';
4
4
  import { MAX_WIRE_REDACT_KEYS, MAX_WIRE_REDACT_KEY_LENGTH } from './redaction.js';
5
+ import { DOCUMENT_ID_LENGTH } from './document-identity.js';
6
+ import { NO_EDITS_OBSERVED } from './edit-epoch.js';
5
7
  const sessionIdSchema = z.string().min(1).max(TRANSPORT_LIMITS.MAX_SESSION_ID_LENGTH);
6
8
  const refSchema = z.string().max(TRANSPORT_LIMITS.MAX_REF_LENGTH);
9
+ const documentIdSchema = z.string().min(1).max(DOCUMENT_ID_LENGTH);
7
10
  /**
8
11
  * Live-control: the narrowed payload of a HUMAN_CONTROL event. The server safeParses
9
12
  * `event.data` against this at the inbound boundary (unknown → narrowed; never `any`).
@@ -62,6 +65,23 @@ export const ReticleEventSchema = z.object({
62
65
  actionId: refSchema.optional(),
63
66
  /** How `actionId` was derived. Present iff `actionId` is. */
64
67
  attribution: z.nativeEnum(EventAttribution).optional(),
68
+ /**
69
+ * The document this was observed under. Minted once per real document; a full navigation replaces
70
+ * both. Lets evidence from a superseded document be excluded rather than counted against an action
71
+ * taken now. Optional for back-compat with SDKs that predate it, which is why absence is read as
72
+ * "current" rather than "foreign" — see `isSameDocument`.
73
+ */
74
+ documentId: documentIdSchema.optional(),
75
+ /**
76
+ * The round of source edits this was observed under — a counter the SDK advances once per applied
77
+ * hot update. A hot update replaces modules and re-renders INSIDE the same document, so
78
+ * `documentId` cannot see it; this is the edit-shaped half of the same question.
79
+ *
80
+ * Optional, and absent while nothing has hot-updated, which is why absence is read as "current"
81
+ * rather than "foreign" — see `isSameEditEpoch`. Most pages have no channel that could report an
82
+ * update at all, so a stamp of `NO_EDITS_OBSERVED` would be wire spent on the word "unknown".
83
+ */
84
+ editEpoch: z.number().int().min(NO_EDITS_OBSERVED).optional(),
65
85
  /** Event-type-specific payload. Kept open here; refined per observer at the edges. */
66
86
  data: z.record(z.unknown()).default({}),
67
87
  });
package/dist/notices.d.ts CHANGED
@@ -65,7 +65,9 @@ export declare const YIELD_WITHOUT_SESSION_NOTE: string;
65
65
  /**
66
66
  * Actionable companion to THROTTLED_WARNING. Surfaced on act/assert results and
67
67
  * reticle_sessions rows when a tab is hidden/throttled and may be un-focusable/un-recoverable from
68
- * the in-page SDK + CDP path. Points at the `reticle drive` escape hatch (a guaranteed scriptable
69
- * context). Reticle cannot bring such a tab to front or recover it, so it names the limit instead.
68
+ * the in-page SDK + CDP path. Names the escape hatch the AGENT can take first (`reticle_lease`
69
+ * through `reticle_run`, since lease is not on the default surface) and leaves `reticle drive` as
70
+ * the human-side equivalent: an MCP-only agent has no shell, so a CLI sentence is advice it cannot
71
+ * follow. Reticle cannot bring such a tab to front or recover it, so it names the limit instead.
70
72
  */
71
- export declare const UNSCRIPTABLE_TAB_RECOMMENDATION = "tab hidden/throttled and may be un-focusable from here; refocus it, or run `reticle drive <url>` for a guaranteed scriptable context";
73
+ export declare const UNSCRIPTABLE_TAB_RECOMMENDATION = "tab hidden/throttled and may be un-focusable from here; refocus it, or acquire a guaranteed scriptable context yourself with `reticle_run { tool: \"reticle_lease\", action: \"acquire\", url }` (a human can equivalently run `reticle drive <url>`)";
package/dist/notices.js CHANGED
@@ -70,7 +70,9 @@ export const YIELD_WITHOUT_SESSION_NOTE = 'No browser session was connected, so
70
70
  /**
71
71
  * Actionable companion to THROTTLED_WARNING. Surfaced on act/assert results and
72
72
  * reticle_sessions rows when a tab is hidden/throttled and may be un-focusable/un-recoverable from
73
- * the in-page SDK + CDP path. Points at the `reticle drive` escape hatch (a guaranteed scriptable
74
- * context). Reticle cannot bring such a tab to front or recover it, so it names the limit instead.
73
+ * the in-page SDK + CDP path. Names the escape hatch the AGENT can take first (`reticle_lease`
74
+ * through `reticle_run`, since lease is not on the default surface) and leaves `reticle drive` as
75
+ * the human-side equivalent: an MCP-only agent has no shell, so a CLI sentence is advice it cannot
76
+ * follow. Reticle cannot bring such a tab to front or recover it, so it names the limit instead.
75
77
  */
76
- export const UNSCRIPTABLE_TAB_RECOMMENDATION = 'tab hidden/throttled and may be un-focusable from here; refocus it, or run `reticle drive <url>` for a guaranteed scriptable context';
78
+ export const UNSCRIPTABLE_TAB_RECOMMENDATION = 'tab hidden/throttled and may be un-focusable from here; refocus it, or acquire a guaranteed scriptable context yourself with `reticle_run { tool: "reticle_lease", action: "acquire", url }` (a human can equivalently run `reticle drive <url>`)';
@@ -0,0 +1,86 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Which directory a projectId lives in, on this machine.
4
+ *
5
+ * Config discovery answers the same question by walking out from the daemon's own working directory,
6
+ * which is right whenever the daemon and the app share a tree. It cannot answer it at all when they
7
+ * do not — a daemon started in one repo, driving an app in a sibling checkout, will never find that
8
+ * app's `.reticle.json` however far it walks. That is not an edge case: an editor starts a
9
+ * user-scoped MCP server wherever it likes, so it is the default arrangement.
10
+ *
11
+ * `init` holds both halves at the moment it runs — the directory it is initialising and the
12
+ * projectId it has just written into that directory's `.reticle.json`. Recording the pair once makes
13
+ * every later session resolvable from anywhere on the machine.
14
+ *
15
+ * This is a CACHE, not a source of truth. `.reticle.json` on disk remains the authority; an entry
16
+ * here is a hint about where to look. So every operation fails soft: a malformed file is an empty
17
+ * registry, never a throw, because taking a daemon down over a stale cache would trade a small
18
+ * problem for a large one.
19
+ *
20
+ * The contract lives in core for the same reason the daemon registry does — it is shared by a writer
21
+ * (`init`, the CLI) and a reader (the daemon's artifact-root resolution), and a filename or a shape
22
+ * that drifts between the two is a defect neither side can see.
23
+ */
24
+ /** Sibling of `daemon-<port>.json` in `~/.reticle`. One file, all projects. */
25
+ export declare const PROJECT_REGISTRY_FILE = "projects.json";
26
+ export declare const ProjectRegistryEntrySchema: z.ZodObject<{
27
+ /** Absolute path to the directory whose `.reticle.json` declares this project. */
28
+ directory: z.ZodString;
29
+ /** When this pairing was last confirmed. Lets a future prune drop entries nobody has opened. */
30
+ lastSeenAt: z.ZodNumber;
31
+ }, "strip", z.ZodTypeAny, {
32
+ directory: string;
33
+ lastSeenAt: number;
34
+ }, {
35
+ directory: string;
36
+ lastSeenAt: number;
37
+ }>;
38
+ export type ProjectRegistryEntry = z.infer<typeof ProjectRegistryEntrySchema>;
39
+ export declare const ProjectRegistrySchema: z.ZodObject<{
40
+ version: z.ZodLiteral<1>;
41
+ projects: z.ZodRecord<z.ZodString, z.ZodObject<{
42
+ /** Absolute path to the directory whose `.reticle.json` declares this project. */
43
+ directory: z.ZodString;
44
+ /** When this pairing was last confirmed. Lets a future prune drop entries nobody has opened. */
45
+ lastSeenAt: z.ZodNumber;
46
+ }, "strip", z.ZodTypeAny, {
47
+ directory: string;
48
+ lastSeenAt: number;
49
+ }, {
50
+ directory: string;
51
+ lastSeenAt: number;
52
+ }>>;
53
+ }, "strip", z.ZodTypeAny, {
54
+ version: 1;
55
+ projects: Record<string, {
56
+ directory: string;
57
+ lastSeenAt: number;
58
+ }>;
59
+ }, {
60
+ version: 1;
61
+ projects: Record<string, {
62
+ directory: string;
63
+ lastSeenAt: number;
64
+ }>;
65
+ }>;
66
+ export type ProjectRegistry = z.infer<typeof ProjectRegistrySchema>;
67
+ /** A project the resolver may consider. Structurally identical to config discovery's `FoundConfig`
68
+ * on purpose: both sources feed one code path, so neither becomes the privileged one. */
69
+ export interface ProjectCandidate {
70
+ projectId: string;
71
+ directory: string;
72
+ }
73
+ export declare function emptyProjectRegistry(): ProjectRegistry;
74
+ /**
75
+ * Record where a project lives. Pure — returns a new registry, takes its clock as an argument.
76
+ *
77
+ * Keyed on the id, so a project that moved (renamed, re-cloned, moved to another disk) replaces its
78
+ * old path rather than leaving it behind as a competing answer. A second stale answer is exactly
79
+ * what makes the resolver refuse, so letting them accumulate would break resolution for the project
80
+ * that moved most recently — the one most likely to be in use.
81
+ */
82
+ export declare function rememberProject(registry: ProjectRegistry, projectId: string, directory: string, now: number): ProjectRegistry;
83
+ /** Every remembered project, in the shape the artifact-root resolver consumes. */
84
+ export declare function projectCandidates(registry: ProjectRegistry): ProjectCandidate[];
85
+ /** Parse a registry file's contents, failing soft to empty. Never throws. */
86
+ export declare function parseProjectRegistry(raw: unknown): ProjectRegistry;
@@ -0,0 +1,66 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Which directory a projectId lives in, on this machine.
4
+ *
5
+ * Config discovery answers the same question by walking out from the daemon's own working directory,
6
+ * which is right whenever the daemon and the app share a tree. It cannot answer it at all when they
7
+ * do not — a daemon started in one repo, driving an app in a sibling checkout, will never find that
8
+ * app's `.reticle.json` however far it walks. That is not an edge case: an editor starts a
9
+ * user-scoped MCP server wherever it likes, so it is the default arrangement.
10
+ *
11
+ * `init` holds both halves at the moment it runs — the directory it is initialising and the
12
+ * projectId it has just written into that directory's `.reticle.json`. Recording the pair once makes
13
+ * every later session resolvable from anywhere on the machine.
14
+ *
15
+ * This is a CACHE, not a source of truth. `.reticle.json` on disk remains the authority; an entry
16
+ * here is a hint about where to look. So every operation fails soft: a malformed file is an empty
17
+ * registry, never a throw, because taking a daemon down over a stale cache would trade a small
18
+ * problem for a large one.
19
+ *
20
+ * The contract lives in core for the same reason the daemon registry does — it is shared by a writer
21
+ * (`init`, the CLI) and a reader (the daemon's artifact-root resolution), and a filename or a shape
22
+ * that drifts between the two is a defect neither side can see.
23
+ */
24
+ /** Sibling of `daemon-<port>.json` in `~/.reticle`. One file, all projects. */
25
+ export const PROJECT_REGISTRY_FILE = 'projects.json';
26
+ export const ProjectRegistryEntrySchema = z.object({
27
+ /** Absolute path to the directory whose `.reticle.json` declares this project. */
28
+ directory: z.string().min(1),
29
+ /** When this pairing was last confirmed. Lets a future prune drop entries nobody has opened. */
30
+ lastSeenAt: z.number(),
31
+ });
32
+ export const ProjectRegistrySchema = z.object({
33
+ version: z.literal(1),
34
+ projects: z.record(z.string(), ProjectRegistryEntrySchema),
35
+ });
36
+ export function emptyProjectRegistry() {
37
+ return { version: 1, projects: {} };
38
+ }
39
+ /**
40
+ * Record where a project lives. Pure — returns a new registry, takes its clock as an argument.
41
+ *
42
+ * Keyed on the id, so a project that moved (renamed, re-cloned, moved to another disk) replaces its
43
+ * old path rather than leaving it behind as a competing answer. A second stale answer is exactly
44
+ * what makes the resolver refuse, so letting them accumulate would break resolution for the project
45
+ * that moved most recently — the one most likely to be in use.
46
+ */
47
+ export function rememberProject(registry, projectId, directory, now) {
48
+ if (0 === projectId.length || 0 === directory.length)
49
+ return registry;
50
+ return {
51
+ version: 1,
52
+ projects: { ...registry.projects, [projectId]: { directory, lastSeenAt: now } },
53
+ };
54
+ }
55
+ /** Every remembered project, in the shape the artifact-root resolver consumes. */
56
+ export function projectCandidates(registry) {
57
+ return Object.entries(registry.projects).map(([projectId, entry]) => ({
58
+ projectId,
59
+ directory: entry.directory,
60
+ }));
61
+ }
62
+ /** Parse a registry file's contents, failing soft to empty. Never throws. */
63
+ export function parseProjectRegistry(raw) {
64
+ const parsed = ProjectRegistrySchema.safeParse(raw);
65
+ return parsed.success ? parsed.data : emptyProjectRegistry();
66
+ }
@@ -0,0 +1,122 @@
1
+ /**
2
+ * What a run has established, held so the agent can ASK for it back.
3
+ *
4
+ * Verification is multi-step, and the only thing holding the thread together is the agent's own
5
+ * context window. When that compacts, or the turn ends, or a sub-agent takes over, the thread is
6
+ * gone and the work restarts. The shape of that shows in the field without needing the theory: long
7
+ * runs of the same read-only call, an agent searching by exhaustion because it no longer remembers
8
+ * what it already saw.
9
+ *
10
+ * ## Pulled, never pushed
11
+ *
12
+ * An earlier version of this rode along on every tool response. It cost +136% on a verdict and was
13
+ * cut, because the agent still had most of that context most of the time: we paid on every call to
14
+ * duplicate what it already knew. The asymmetry that makes the feature work is not that Reticle
15
+ * remembers MORE, it is that Reticle's copy does not degrade at the moment the agent's does. So the
16
+ * agent asks, at the moment it knows its own memory is gone, and pays once.
17
+ *
18
+ * That inversion is why nothing here returns `undefined` for an empty run. A push had to stay silent
19
+ * when it had nothing to say; a pull was asked a question, and "nothing established yet" is the
20
+ * answer the asker needs.
21
+ *
22
+ * ## Two rules stop it becoming the thing it prevents
23
+ *
24
+ * **It must shrink, not grow.** Superseding facts REPLACE rather than append, and both blocks are
25
+ * capped. A context object that accumulates is a token bomb, and read-only payloads are already the
26
+ * largest thing this product emits.
27
+ *
28
+ * **Memory that can be wrong is worse than no memory.** A stale established fact is precisely the
29
+ * false-green mechanism this product exists to prevent, and stale refs are already the most common
30
+ * error an agent sees from us. So every fact carries the document AND the edit epoch it was observed
31
+ * under, and is dropped the moment either moves: no grace period, no probably-fine. The comparison
32
+ * is `isSameDocument`/`isSameEditEpoch` rather than a third rule written beside them.
33
+ *
34
+ * ## What may never go in
35
+ *
36
+ * Only what Reticle OBSERVED. Never what the agent intends, plans, or believes: that is not ours to
37
+ * hold, it is unbounded, and a verification tool that remembers what an agent was thinking is
38
+ * inventing evidence. `remaining` is the one forward-looking field and it is derived mechanically
39
+ * from declared bindings, so it remains a report of a fact — which bindings are undischarged — and
40
+ * not a prediction.
41
+ */
42
+ import { type Intent } from './intent.js';
43
+ import type { Verified } from './verified-constants.js';
44
+ /**
45
+ * How many rows either block may carry.
46
+ *
47
+ * A decision written down in one place, because the whole feature is a bet that this answer costs
48
+ * fewer tokens than the re-derivation it prevents, and a cap that drifts makes that bet
49
+ * unmeasurable. Twelve is enough to hold the refs, routes and verdicts a single verification thread
50
+ * works with, and small enough that the answer stays a briefing rather than a second payload.
51
+ *
52
+ * One number for both blocks on purpose: two caps is two things to keep in step, and nothing has
53
+ * ever suggested proofs and observations deserve different budgets.
54
+ */
55
+ export declare const RUN_ESTABLISHED_CAP = 12;
56
+ /**
57
+ * Evidence scoped to the page and the source revision it was taken under.
58
+ *
59
+ * Both fields are optional and absence means "current", exactly as `isSameDocument` and
60
+ * `isSameEditEpoch` already rule: an SDK predating either stamps nothing, and a page with no
61
+ * hot-update channel never stamps an epoch at all.
62
+ */
63
+ interface ScopedEvidence {
64
+ /** The document this was seen under. Absent only from evidence predating document identity. */
65
+ readonly doc?: string | undefined;
66
+ /** The edit epoch this was seen under. Absent where no hot update could ever be observed. */
67
+ readonly epoch?: number | undefined;
68
+ }
69
+ /**
70
+ * One thing this run established, with the page state it was true under.
71
+ *
72
+ * `key` is the SUBJECT — re-establishing the same subject supersedes rather than appends. `fact` is
73
+ * the conclusion in prose, never the transcript it came from: "e12 is the Submit button", not the
74
+ * snapshot that revealed it.
75
+ */
76
+ export interface EstablishedFact extends ScopedEvidence {
77
+ readonly key: string;
78
+ readonly fact: string;
79
+ /** Where in the source this was about, `file:line`, when the run observed one. */
80
+ readonly source?: string | undefined;
81
+ }
82
+ /**
83
+ * One claim a verdict already settled.
84
+ *
85
+ * The claim IS the subject: proving the same thing twice is one row, the newer one. An agent that
86
+ * has forgotten it proved something either re-proves it, which is slow, or assumes it, which is a
87
+ * false green — and both are the failure this block exists to stop, so `verified` travels with the
88
+ * claim rather than being flattened to a boolean.
89
+ */
90
+ export interface ProvenClaim extends ScopedEvidence {
91
+ readonly claim: string;
92
+ readonly verified: Verified;
93
+ readonly source?: string | undefined;
94
+ }
95
+ /** What this run has established, what it has proved, and what nothing has discharged. */
96
+ export interface RunContext {
97
+ readonly step: number;
98
+ readonly established: readonly EstablishedFact[];
99
+ readonly proven: readonly ProvenClaim[];
100
+ readonly remaining: readonly string[];
101
+ }
102
+ /** Fold new observations into the established set. See `foldScoped`. */
103
+ export declare function foldEstablished(existing: readonly EstablishedFact[], incoming: readonly EstablishedFact[], currentDocumentId: string | undefined, currentEditEpoch: number | undefined): EstablishedFact[];
104
+ /** Fold new verdicts into the proven set, keyed on the claim. See `foldScoped`. */
105
+ export declare function foldProven(existing: readonly ProvenClaim[], incoming: readonly ProvenClaim[], currentDocumentId: string | undefined, currentEditEpoch: number | undefined): ProvenClaim[];
106
+ /**
107
+ * The declared intents no verdict has discharged yet.
108
+ *
109
+ * Derived, never inferred. This reports a property of the ledger — which bindings remain unproved —
110
+ * and says nothing about what the agent means to do next.
111
+ */
112
+ export declare function remainingFor(intents: readonly Intent[]): string[];
113
+ /** Assemble the answer. Always answers: an empty run has an empty context, and that is the truth. */
114
+ export declare function buildRunContext(input: {
115
+ step: number;
116
+ intents: readonly Intent[];
117
+ established: readonly EstablishedFact[];
118
+ proven: readonly ProvenClaim[];
119
+ currentDocumentId: string | undefined;
120
+ currentEditEpoch: number | undefined;
121
+ }): RunContext;
122
+ export {};