@reticlehq/core 2.2.0 → 2.3.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 (99) hide show
  1. package/dist/brand.d.ts +0 -1
  2. package/dist/brand.js +0 -1
  3. package/dist/consequence.d.ts +0 -1
  4. package/dist/consequence.js +0 -1
  5. package/dist/constants.d.ts +30 -25
  6. package/dist/constants.js +33 -23
  7. package/dist/daemon-registry.d.ts +0 -1
  8. package/dist/daemon-registry.js +0 -1
  9. package/dist/desktop-contract.cjs +11 -0
  10. package/dist/desktop-contract.d.cts +6 -0
  11. package/dist/desktop-contract.d.ts +58 -0
  12. package/dist/desktop-contract.js +59 -0
  13. package/dist/event-payloads.d.ts +60 -3
  14. package/dist/event-payloads.js +35 -4
  15. package/dist/event-priority.d.ts +25 -0
  16. package/dist/event-priority.js +45 -0
  17. package/dist/findings.d.ts +124 -0
  18. package/dist/findings.js +122 -0
  19. package/dist/flow-constants.d.ts +0 -1
  20. package/dist/flow-constants.js +0 -1
  21. package/dist/flow-types.d.ts +9 -1
  22. package/dist/flow-types.js +0 -1
  23. package/dist/index.d.ts +8 -1
  24. package/dist/index.js +8 -1
  25. package/dist/journal.d.ts +0 -1
  26. package/dist/journal.js +0 -1
  27. package/dist/messages.d.ts +16 -11
  28. package/dist/messages.js +0 -1
  29. package/dist/net.d.ts +41 -0
  30. package/dist/net.js +40 -0
  31. package/dist/notices.d.ts +0 -1
  32. package/dist/notices.js +0 -1
  33. package/dist/redaction.d.ts +0 -1
  34. package/dist/redaction.js +1 -2
  35. package/dist/schema/event-message.json +3 -1
  36. package/dist/schema/event-type.json +3 -1
  37. package/dist/schema/reticle-event.json +3 -1
  38. package/dist/schema/reticle-message.json +3 -1
  39. package/dist/security.d.ts +20 -1
  40. package/dist/security.js +45 -1
  41. package/dist/session-constants.d.ts +0 -1
  42. package/dist/session-constants.js +0 -1
  43. package/dist/state-select.d.ts +0 -1
  44. package/dist/state-select.js +32 -1
  45. package/dist/telemetry-feedback.d.ts +265 -0
  46. package/dist/telemetry-feedback.js +163 -0
  47. package/dist/telemetry-session.d.ts +524 -0
  48. package/dist/telemetry-session.js +245 -0
  49. package/dist/telemetry.d.ts +1463 -0
  50. package/dist/telemetry.js +375 -0
  51. package/dist/toon.d.ts +0 -1
  52. package/dist/toon.js +0 -1
  53. package/dist/types.d.ts +9 -2
  54. package/dist/types.js +0 -1
  55. package/dist/upgrade.d.ts +16 -3
  56. package/dist/upgrade.js +14 -2
  57. package/dist/verification-run.d.ts +4 -5
  58. package/dist/verification-run.js +0 -1
  59. package/dist/verified-constants.d.ts +104 -0
  60. package/dist/verified-constants.js +102 -0
  61. package/package.json +7 -3
  62. package/dist/brand.d.ts.map +0 -1
  63. package/dist/brand.js.map +0 -1
  64. package/dist/consequence.d.ts.map +0 -1
  65. package/dist/consequence.js.map +0 -1
  66. package/dist/constants.d.ts.map +0 -1
  67. package/dist/constants.js.map +0 -1
  68. package/dist/daemon-registry.d.ts.map +0 -1
  69. package/dist/daemon-registry.js.map +0 -1
  70. package/dist/event-payloads.d.ts.map +0 -1
  71. package/dist/event-payloads.js.map +0 -1
  72. package/dist/flow-constants.d.ts.map +0 -1
  73. package/dist/flow-constants.js.map +0 -1
  74. package/dist/flow-types.d.ts.map +0 -1
  75. package/dist/flow-types.js.map +0 -1
  76. package/dist/index.d.ts.map +0 -1
  77. package/dist/index.js.map +0 -1
  78. package/dist/journal.d.ts.map +0 -1
  79. package/dist/journal.js.map +0 -1
  80. package/dist/messages.d.ts.map +0 -1
  81. package/dist/messages.js.map +0 -1
  82. package/dist/notices.d.ts.map +0 -1
  83. package/dist/notices.js.map +0 -1
  84. package/dist/redaction.d.ts.map +0 -1
  85. package/dist/redaction.js.map +0 -1
  86. package/dist/security.d.ts.map +0 -1
  87. package/dist/security.js.map +0 -1
  88. package/dist/session-constants.d.ts.map +0 -1
  89. package/dist/session-constants.js.map +0 -1
  90. package/dist/state-select.d.ts.map +0 -1
  91. package/dist/state-select.js.map +0 -1
  92. package/dist/toon.d.ts.map +0 -1
  93. package/dist/toon.js.map +0 -1
  94. package/dist/types.d.ts.map +0 -1
  95. package/dist/types.js.map +0 -1
  96. package/dist/upgrade.d.ts.map +0 -1
  97. package/dist/upgrade.js.map +0 -1
  98. package/dist/verification-run.d.ts.map +0 -1
  99. package/dist/verification-run.js.map +0 -1
package/dist/brand.d.ts CHANGED
@@ -47,4 +47,3 @@ export declare const asFlowName: (value: string) => FlowName;
47
47
  /** Mint a SessionId — call ONLY behind isValidSessionId, or on a literal in a test. */
48
48
  export declare const asSessionId: (value: string) => SessionId;
49
49
  export {};
50
- //# sourceMappingURL=brand.d.ts.map
package/dist/brand.js CHANGED
@@ -18,4 +18,3 @@ export const asRef = (value) => value;
18
18
  export const asFlowName = (value) => value;
19
19
  /** Mint a SessionId — call ONLY behind isValidSessionId, or on a literal in a test. */
20
20
  export const asSessionId = (value) => value;
21
- //# sourceMappingURL=brand.js.map
@@ -28,4 +28,3 @@ export declare function isPresenceKind(kind: string): boolean;
28
28
  export declare function flowExpectHasConsequence(expect: FlowExpect | undefined): boolean;
29
29
  /** True when a FlowExpect checks ONLY element presence — no consequence field is set. */
30
30
  export declare function flowExpectIsPresenceOnly(expect: FlowExpect | undefined): boolean;
31
- //# sourceMappingURL=consequence.d.ts.map
@@ -42,4 +42,3 @@ export function flowExpectHasConsequence(expect) {
42
42
  export function flowExpectIsPresenceOnly(expect) {
43
43
  return expect !== undefined && expect.element !== undefined && !flowExpectHasConsequence(expect);
44
44
  }
45
- //# sourceMappingURL=consequence.js.map
@@ -47,6 +47,14 @@ export declare const ReticleEnv: {
47
47
  readonly CDP_URL: "RETICLE_CDP_URL";
48
48
  /** Max simultaneous leased headless contexts in the browser pool (resource cap). */
49
49
  readonly MAX_CONTEXTS: "RETICLE_MAX_CONTEXTS";
50
+ /**
51
+ * Inbound events per second before the bridge starts SAMPLING (never disconnecting).
52
+ *
53
+ * Raise it for a legitimately busy app — a streaming dashboard, a live grid — rather than accept
54
+ * partial coverage. Free and local: the daemon runs on the same machine, so a higher ceiling costs
55
+ * nothing to anyone.
56
+ */
57
+ readonly MAX_MESSAGES_PER_SECOND: "RETICLE_MAX_MESSAGES_PER_SECOND";
50
58
  /** Bearer token required by the optional `reticle serve --http` verify endpoint. */
51
59
  readonly VERIFY_TOKEN: "RETICLE_VERIFY_TOKEN";
52
60
  /** Ms of continuous idleness (no agent, no browser session, no lease) before the daemon self-exits;
@@ -146,6 +154,7 @@ export declare const VisualReason: {
146
154
  readonly CAPTURE_FAILED: "capture-failed";
147
155
  readonly BASELINE_MISSING: "baseline-missing";
148
156
  readonly DIMENSION_MISMATCH: "dimension-mismatch";
157
+ readonly FULL_PAGE_UNSUPPORTED: "full-page-unsupported";
149
158
  };
150
159
  export type VisualReason = (typeof VisualReason)[keyof typeof VisualReason];
151
160
  /** Actionable companion to NO_PROVIDER — the visual layer needs a driven browser. */
@@ -156,12 +165,6 @@ export declare const VISUAL_PIXEL_THRESHOLD = 0.1;
156
165
  * Autonomous "smart monkey" anomaly classes reticle_crawl reports after clicking a
157
166
  * reachable control. Named so the agent (and tests) branch on cause, never on message text.
158
167
  */
159
- export declare const CrawlAnomalyKind: {
160
- readonly CONSOLE_ERROR: "console-error";
161
- readonly FAILED_REQUEST: "failed-request";
162
- readonly DEAD_CONTROL: "dead-control";
163
- };
164
- export type CrawlAnomalyKind = (typeof CrawlAnomalyKind)[keyof typeof CrawlAnomalyKind];
165
168
  /**
166
169
  * Bounds for reticle_scroll_to — how many viewport scrolls to try before giving up on
167
170
  * a virtualized/windowed list (which only renders visible rows, so a plain reticle_query misses
@@ -254,6 +257,9 @@ export declare const EventType: {
254
257
  * implies it saw everything.
255
258
  */
256
259
  readonly BLIND_SPOT: "blind-spot";
260
+ /** synthetic: the SDK ITSELF failed (an observer threw). `data: { site, message, errorType }`.
261
+ * Rides the existing bridge — no outbound request. See browser/observers/sdk-failure.ts. */
262
+ readonly SDK_FAILED: "sdk.failed";
257
263
  /**
258
264
  * synthetic (driven only): CDP/Playwright-authoritative network detail for a response the in-page
259
265
  * fetch/XHR wrapper also saw — full response headers + authoritative status/mimeType the page-side
@@ -273,6 +279,13 @@ export declare const EventType: {
273
279
  * the agent that drains the mark knows exactly which element and which source to fix.
274
280
  */
275
281
  readonly HUMAN_MARK: "human.mark";
282
+ /**
283
+ * The app produced a FILE — a Blob handed to `URL.createObjectURL`, usually saved by clicking an
284
+ * anchor with `download`. `data: { filename?, mimeType, bytes, lines?, preview? }`. The one artifact
285
+ * class no outside-the-browser tool can inspect: it never crosses the network, so there is no
286
+ * request to intercept. See `observers/download.ts` for the defect that motivated it.
287
+ */
288
+ readonly DOWNLOAD: "download";
276
289
  };
277
290
  export type EventType = (typeof EventType)[keyof typeof EventType];
278
291
  /**
@@ -302,6 +315,8 @@ export declare const RETICLE_HYDRATION_SIGNAL = "reticle:hydration-complete";
302
315
  * stop the SDK's owned-store matching.
303
316
  */
304
317
  export declare const RETICLE_RENDERS_STORE = "__reticle_renders";
318
+ /** Global the render pre-hook parks its commit buffer on (see the vite plugin's RENDER_PREHOOK_SOURCE). */
319
+ export declare const RETICLE_RENDER_PREHOOK = "__reticleRenderPreHook";
305
320
  /**
306
321
  * Signal the React adapter fires when an error boundary catches (dev-only). Carried on the signal channel
307
322
  * (the SDK's public emit surface) so the server sees a boundary that swallowed — the purest "looks fine,
@@ -321,24 +336,6 @@ export declare const TruncationChannel: {
321
336
  readonly DOM: "dom";
322
337
  };
323
338
  export type TruncationChannel = (typeof TruncationChannel)[keyof typeof TruncationChannel];
324
- /**
325
- * A region the SDK cannot see into — surfaced (never hidden) so a result's coverage reads honestly.
326
- * Crosses the wire in a BLIND_SPOT event's `kind`, so it lives in core (the contract), not the server.
327
- */
328
- export declare const BlindSpotKind: {
329
- readonly CLOSED_SHADOW_ROOT: "closed-shadow-root";
330
- readonly CROSS_ORIGIN_IFRAME: "cross-origin-iframe";
331
- readonly VIRTUALIZED_UNMOUNTED: "virtualized-unmounted";
332
- /**
333
- * Something wrapped `fetch` before we did, so the request we record is not necessarily the request
334
- * that leaves. Wrappers chain outermost-first: anything installed EARLIER sits below us and mutates
335
- * after we have read `init.body`. An interceptor initialised before connect(), or a polyfill, does
336
- * exactly that. Unfixable from inside the page — there is no "patch last" primitive — so it is
337
- * declared instead, and a verdict over it reports partial coverage rather than implying we saw the wire.
338
- */
339
- readonly WRAPPED_NETWORK: "wrapped-network";
340
- };
341
- export type BlindSpotKind = (typeof BlindSpotKind)[keyof typeof BlindSpotKind];
342
339
  /**
343
340
  * How an event was linked to the action it is attributed to. `window` means the SDK stamped the
344
341
  * currently-active action's id onto every event observed between that action's dispatch and its
@@ -497,6 +494,15 @@ export declare const ReticleCommand: {
497
494
  * AGENT-driven pause/end keeps the presenter in sync. `args: { state, text? }`.
498
495
  */
499
496
  readonly PRESENTER: "presenter";
497
+ /**
498
+ * Ask the DESKTOP shell to photograph its own window and return `{ png: <base64> }`.
499
+ *
500
+ * A desktop webview has no CDP endpoint, so pixels must come from the runtime itself. Electron's
501
+ * `webContents.capturePage()` reads the window's backing store, which is why this beats capturing
502
+ * a screen region: it is correct even when the window is behind the editor, and needs no
503
+ * screen-recording permission. Answered only when the app installed the capture helper.
504
+ */
505
+ readonly CAPTURE: "capture";
500
506
  /** Navigate the page to a new URL. `args: { url: string }`. */
501
507
  readonly NAVIGATE: "navigate";
502
508
  /** Reload the page. `args: { hard?: boolean }` — hard clears the cache via location replace trick. */
@@ -531,4 +537,3 @@ export declare const MessageKind: {
531
537
  readonly EVENT: "event";
532
538
  };
533
539
  export type MessageKind = (typeof MessageKind)[keyof typeof MessageKind];
534
- //# sourceMappingURL=constants.d.ts.map
package/dist/constants.js CHANGED
@@ -49,6 +49,14 @@ export const ReticleEnv = {
49
49
  CDP_URL: 'RETICLE_CDP_URL',
50
50
  /** Max simultaneous leased headless contexts in the browser pool (resource cap). */
51
51
  MAX_CONTEXTS: 'RETICLE_MAX_CONTEXTS',
52
+ /**
53
+ * Inbound events per second before the bridge starts SAMPLING (never disconnecting).
54
+ *
55
+ * Raise it for a legitimately busy app — a streaming dashboard, a live grid — rather than accept
56
+ * partial coverage. Free and local: the daemon runs on the same machine, so a higher ceiling costs
57
+ * nothing to anyone.
58
+ */
59
+ MAX_MESSAGES_PER_SECOND: 'RETICLE_MAX_MESSAGES_PER_SECOND',
52
60
  /** Bearer token required by the optional `reticle serve --http` verify endpoint. */
53
61
  VERIFY_TOKEN: 'RETICLE_VERIFY_TOKEN',
54
62
  /** Ms of continuous idleness (no agent, no browser session, no lease) before the daemon self-exits;
@@ -148,6 +156,10 @@ export const VisualReason = {
148
156
  CAPTURE_FAILED: 'capture-failed', // the page could not be screenshotted
149
157
  BASELINE_MISSING: 'baseline-missing', // reticle_visual_diff with no saved baseline of that name
150
158
  DIMENSION_MISMATCH: 'dimension-mismatch', // current vs baseline differ in size — can't pixel-diff
159
+ // { fullPage } asked of a shell that can only photograph the viewport. Reported rather than
160
+ // quietly downgraded: a caller who asked for the whole scroll height and silently got the visible
161
+ // part would bank a baseline that says nothing about the content below the fold.
162
+ FULL_PAGE_UNSUPPORTED: 'full-page-unsupported',
151
163
  };
152
164
  /** Actionable companion to NO_PROVIDER — the visual layer needs a driven browser. */
153
165
  export const VISUAL_NO_PROVIDER_RECOMMENDATION = 'visual capture needs a driven browser — start with `reticle drive <url>` or set RETICLE_CDP_URL; the always-on SDK does not ship a screenshotter';
@@ -157,11 +169,6 @@ export const VISUAL_PIXEL_THRESHOLD = 0.1;
157
169
  * Autonomous "smart monkey" anomaly classes reticle_crawl reports after clicking a
158
170
  * reachable control. Named so the agent (and tests) branch on cause, never on message text.
159
171
  */
160
- export const CrawlAnomalyKind = {
161
- CONSOLE_ERROR: 'console-error', // the click logged a console.error / uncaught error
162
- FAILED_REQUEST: 'failed-request', // it fired a request that returned >= 400
163
- DEAD_CONTROL: 'dead-control', // it dispatched but the app did NOTHING (no DOM/net/route/signal)
164
- };
165
172
  /**
166
173
  * Bounds for reticle_scroll_to — how many viewport scrolls to try before giving up on
167
174
  * a virtualized/windowed list (which only renders visible rows, so a plain reticle_query misses
@@ -253,6 +260,9 @@ export const EventType = {
253
260
  * implies it saw everything.
254
261
  */
255
262
  BLIND_SPOT: 'blind-spot',
263
+ /** synthetic: the SDK ITSELF failed (an observer threw). `data: { site, message, errorType }`.
264
+ * Rides the existing bridge — no outbound request. See browser/observers/sdk-failure.ts. */
265
+ SDK_FAILED: 'sdk.failed',
256
266
  /**
257
267
  * synthetic (driven only): CDP/Playwright-authoritative network detail for a response the in-page
258
268
  * fetch/XHR wrapper also saw — full response headers + authoritative status/mimeType the page-side
@@ -272,6 +282,13 @@ export const EventType = {
272
282
  * the agent that drains the mark knows exactly which element and which source to fix.
273
283
  */
274
284
  HUMAN_MARK: 'human.mark',
285
+ /**
286
+ * The app produced a FILE — a Blob handed to `URL.createObjectURL`, usually saved by clicking an
287
+ * anchor with `download`. `data: { filename?, mimeType, bytes, lines?, preview? }`. The one artifact
288
+ * class no outside-the-browser tool can inspect: it never crosses the network, so there is no
289
+ * request to intercept. See `observers/download.ts` for the defect that motivated it.
290
+ */
291
+ DOWNLOAD: 'download',
275
292
  };
276
293
  /**
277
294
  * Named phenomena the perception layer detects deterministically over the journal — capsules and
@@ -299,6 +316,8 @@ export const RETICLE_HYDRATION_SIGNAL = 'reticle:hydration-complete';
299
316
  * stop the SDK's owned-store matching.
300
317
  */
301
318
  export const RETICLE_RENDERS_STORE = '__reticle_renders';
319
+ /** Global the render pre-hook parks its commit buffer on (see the vite plugin's RENDER_PREHOOK_SOURCE). */
320
+ export const RETICLE_RENDER_PREHOOK = '__reticleRenderPreHook';
302
321
  /**
303
322
  * Signal the React adapter fires when an error boundary catches (dev-only). Carried on the signal channel
304
323
  * (the SDK's public emit surface) so the server sees a boundary that swallowed — the purest "looks fine,
@@ -317,23 +336,6 @@ export const RETICLE_HYDRATION_ERROR_SIGNAL = 'reticle:hydration-error';
317
336
  export const TruncationChannel = {
318
337
  DOM: 'dom',
319
338
  };
320
- /**
321
- * A region the SDK cannot see into — surfaced (never hidden) so a result's coverage reads honestly.
322
- * Crosses the wire in a BLIND_SPOT event's `kind`, so it lives in core (the contract), not the server.
323
- */
324
- export const BlindSpotKind = {
325
- CLOSED_SHADOW_ROOT: 'closed-shadow-root',
326
- CROSS_ORIGIN_IFRAME: 'cross-origin-iframe',
327
- VIRTUALIZED_UNMOUNTED: 'virtualized-unmounted',
328
- /**
329
- * Something wrapped `fetch` before we did, so the request we record is not necessarily the request
330
- * that leaves. Wrappers chain outermost-first: anything installed EARLIER sits below us and mutates
331
- * after we have read `init.body`. An interceptor initialised before connect(), or a polyfill, does
332
- * exactly that. Unfixable from inside the page — there is no "patch last" primitive — so it is
333
- * declared instead, and a verdict over it reports partial coverage rather than implying we saw the wire.
334
- */
335
- WRAPPED_NETWORK: 'wrapped-network',
336
- };
337
339
  /**
338
340
  * How an event was linked to the action it is attributed to. `window` means the SDK stamped the
339
341
  * currently-active action's id onto every event observed between that action's dispatch and its
@@ -470,6 +472,15 @@ export const ReticleCommand = {
470
472
  * AGENT-driven pause/end keeps the presenter in sync. `args: { state, text? }`.
471
473
  */
472
474
  PRESENTER: 'presenter',
475
+ /**
476
+ * Ask the DESKTOP shell to photograph its own window and return `{ png: <base64> }`.
477
+ *
478
+ * A desktop webview has no CDP endpoint, so pixels must come from the runtime itself. Electron's
479
+ * `webContents.capturePage()` reads the window's backing store, which is why this beats capturing
480
+ * a screen region: it is correct even when the window is behind the editor, and needs no
481
+ * screen-recording permission. Answered only when the app installed the capture helper.
482
+ */
483
+ CAPTURE: 'capture',
473
484
  /** Navigate the page to a new URL. `args: { url: string }`. */
474
485
  NAVIGATE: 'navigate',
475
486
  /** Reload the page. `args: { hard?: boolean }` — hard clears the cache via location replace trick. */
@@ -500,4 +511,3 @@ export const MessageKind = {
500
511
  COMMAND_RESULT: 'command_result',
501
512
  EVENT: 'event',
502
513
  };
503
- //# sourceMappingURL=constants.js.map
@@ -33,4 +33,3 @@ export type DaemonRegistryEntry = z.infer<typeof DaemonRegistryEntrySchema>;
33
33
  * mismatched daemon — a wrong auto-connect is worse than the honest default).
34
34
  */
35
35
  export declare function pickDaemonPort(entries: readonly DaemonRegistryEntry[], projectId: string | undefined, isAlive: (pid: number) => boolean): number | null;
36
- //# sourceMappingURL=daemon-registry.d.ts.map
@@ -45,4 +45,3 @@ export function pickDaemonPort(entries, projectId, isAlive) {
45
45
  .sort((a, b) => a - b);
46
46
  return matches[0] ?? null;
47
47
  }
48
- //# sourceMappingURL=daemon-registry.js.map
@@ -0,0 +1,11 @@
1
+ // GENERATED by scripts/gen-desktop-contract.mjs — do not edit.
2
+ //
3
+ // The CommonJS view of the desktop wiring contract, for an Electron preload/main process that
4
+ // cannot import the ESM build. Edit src/desktop-contract.ts and rebuild @reticlehq/core.
5
+ 'use strict';
6
+ exports.RETICLE_IPC_GLOBAL = "__reticleIpc";
7
+ exports.RETICLE_CAPTURE_CHANNEL = "__reticle:capture";
8
+ exports.RETICLE_CAPTURE_FILE_PREFIX = "reticle-capture-";
9
+ exports.RETICLE_TAURI_CAPTURE_COMMAND = "reticle_capture";
10
+ exports.RETICLE_FULL_PAGE_UNSUPPORTED = "full-page-unsupported";
11
+ Object.freeze(exports);
@@ -0,0 +1,6 @@
1
+ // GENERATED by scripts/gen-desktop-contract.mjs — do not edit.
2
+ export declare const RETICLE_IPC_GLOBAL: "__reticleIpc";
3
+ export declare const RETICLE_CAPTURE_CHANNEL: "__reticle:capture";
4
+ export declare const RETICLE_CAPTURE_FILE_PREFIX: "reticle-capture-";
5
+ export declare const RETICLE_TAURI_CAPTURE_COMMAND: "reticle_capture";
6
+ export declare const RETICLE_FULL_PAGE_UNSUPPORTED: "full-page-unsupported";
@@ -0,0 +1,58 @@
1
+ /**
2
+ * The desktop wiring contract — the single source of truth for the strings that let an Electron
3
+ * app's three worlds recognise each other.
4
+ *
5
+ * Those worlds cannot share a module graph. A sandboxed Electron preload is CommonJS and cannot load
6
+ * the ESM SDK build; the daemon runs in a separate process entirely. So these values were previously
7
+ * hand-copied into six files, and a rename in any one of them broke desktop SILENTLY — IPC stopped
8
+ * being observed, or screenshots stopped working, and every test still passed.
9
+ *
10
+ * They live here because `@reticlehq/core` is where anything crossing the browser ↔ bridge ↔ agent
11
+ * boundary is defined. The CommonJS side does not copy them: `scripts/gen-desktop-contract.mjs`
12
+ * emits `dist/desktop-contract.cjs` from THIS file at build time, so the preload requires the same
13
+ * values it would have imported. One definition, two module systems, no drift possible.
14
+ */
15
+ /**
16
+ * The `window` property the Electron preload exposes and the renderer-side SDK reads.
17
+ *
18
+ * Namespaced and underscore-prefixed so it cannot collide with an app's own globals.
19
+ */
20
+ export declare const RETICLE_IPC_GLOBAL = "__reticleIpc";
21
+ /** The ipcMain channel the capture helper answers, invoked by the preload on the SDK's behalf. */
22
+ export declare const RETICLE_CAPTURE_CHANNEL = "__reticle:capture";
23
+ /**
24
+ * Filename prefix for a screenshot the main process writes to the OS temp directory.
25
+ *
26
+ * The daemon refuses to read a capture whose path does not sit in the temp dir AND carry this
27
+ * prefix — the path arrives from the page, and the daemon must not become a file-read oracle for
28
+ * whatever a compromised renderer names.
29
+ */
30
+ export declare const RETICLE_CAPTURE_FILE_PREFIX = "reticle-capture-";
31
+ /**
32
+ * The Tauri command name `reticle-tauri` registers, invoked by the SDK when no preload is present.
33
+ *
34
+ * Tauri has no preload stage — there is no place to install a capture global before app code runs.
35
+ * So the SDK invokes this command directly through Tauri's own internals, which means a Tauri app
36
+ * gets screenshots by adding ONE Rust command and nothing at all on the JavaScript side.
37
+ */
38
+ export declare const RETICLE_TAURI_CAPTURE_COMMAND = "reticle_capture";
39
+ /**
40
+ * What a shell answers when asked for `fullPage` it cannot produce.
41
+ *
42
+ * Shared with `VisualReason.FULL_PAGE_UNSUPPORTED` rather than re-spelled, because the Electron
43
+ * preload (CommonJS) and the daemon must agree on it without sharing a module graph.
44
+ */
45
+ export declare const RETICLE_FULL_PAGE_UNSUPPORTED: string;
46
+ /**
47
+ * Every value the generated CommonJS shim must expose, as `name → value`.
48
+ *
49
+ * The generator walks THIS record rather than a hand-written list, so adding a constant above and
50
+ * exporting it here is all it takes for the preload to see it — there is no second place to update.
51
+ */
52
+ export declare const DESKTOP_CONTRACT: {
53
+ readonly RETICLE_IPC_GLOBAL: "__reticleIpc";
54
+ readonly RETICLE_CAPTURE_CHANNEL: "__reticle:capture";
55
+ readonly RETICLE_CAPTURE_FILE_PREFIX: "reticle-capture-";
56
+ readonly RETICLE_TAURI_CAPTURE_COMMAND: "reticle_capture";
57
+ readonly RETICLE_FULL_PAGE_UNSUPPORTED: string;
58
+ };
@@ -0,0 +1,59 @@
1
+ import { VisualReason } from './constants.js';
2
+ /**
3
+ * The desktop wiring contract — the single source of truth for the strings that let an Electron
4
+ * app's three worlds recognise each other.
5
+ *
6
+ * Those worlds cannot share a module graph. A sandboxed Electron preload is CommonJS and cannot load
7
+ * the ESM SDK build; the daemon runs in a separate process entirely. So these values were previously
8
+ * hand-copied into six files, and a rename in any one of them broke desktop SILENTLY — IPC stopped
9
+ * being observed, or screenshots stopped working, and every test still passed.
10
+ *
11
+ * They live here because `@reticlehq/core` is where anything crossing the browser ↔ bridge ↔ agent
12
+ * boundary is defined. The CommonJS side does not copy them: `scripts/gen-desktop-contract.mjs`
13
+ * emits `dist/desktop-contract.cjs` from THIS file at build time, so the preload requires the same
14
+ * values it would have imported. One definition, two module systems, no drift possible.
15
+ */
16
+ /**
17
+ * The `window` property the Electron preload exposes and the renderer-side SDK reads.
18
+ *
19
+ * Namespaced and underscore-prefixed so it cannot collide with an app's own globals.
20
+ */
21
+ export const RETICLE_IPC_GLOBAL = '__reticleIpc';
22
+ /** The ipcMain channel the capture helper answers, invoked by the preload on the SDK's behalf. */
23
+ export const RETICLE_CAPTURE_CHANNEL = '__reticle:capture';
24
+ /**
25
+ * Filename prefix for a screenshot the main process writes to the OS temp directory.
26
+ *
27
+ * The daemon refuses to read a capture whose path does not sit in the temp dir AND carry this
28
+ * prefix — the path arrives from the page, and the daemon must not become a file-read oracle for
29
+ * whatever a compromised renderer names.
30
+ */
31
+ export const RETICLE_CAPTURE_FILE_PREFIX = 'reticle-capture-';
32
+ /**
33
+ * The Tauri command name `reticle-tauri` registers, invoked by the SDK when no preload is present.
34
+ *
35
+ * Tauri has no preload stage — there is no place to install a capture global before app code runs.
36
+ * So the SDK invokes this command directly through Tauri's own internals, which means a Tauri app
37
+ * gets screenshots by adding ONE Rust command and nothing at all on the JavaScript side.
38
+ */
39
+ export const RETICLE_TAURI_CAPTURE_COMMAND = 'reticle_capture';
40
+ /**
41
+ * What a shell answers when asked for `fullPage` it cannot produce.
42
+ *
43
+ * Shared with `VisualReason.FULL_PAGE_UNSUPPORTED` rather than re-spelled, because the Electron
44
+ * preload (CommonJS) and the daemon must agree on it without sharing a module graph.
45
+ */
46
+ export const RETICLE_FULL_PAGE_UNSUPPORTED = VisualReason.FULL_PAGE_UNSUPPORTED;
47
+ /**
48
+ * Every value the generated CommonJS shim must expose, as `name → value`.
49
+ *
50
+ * The generator walks THIS record rather than a hand-written list, so adding a constant above and
51
+ * exporting it here is all it takes for the preload to see it — there is no second place to update.
52
+ */
53
+ export const DESKTOP_CONTRACT = {
54
+ RETICLE_IPC_GLOBAL,
55
+ RETICLE_CAPTURE_CHANNEL,
56
+ RETICLE_CAPTURE_FILE_PREFIX,
57
+ RETICLE_TAURI_CAPTURE_COMMAND,
58
+ RETICLE_FULL_PAGE_UNSUPPORTED,
59
+ };
@@ -19,15 +19,26 @@ import { EventType } from './constants.js';
19
19
  * object — the browser imports the members, the schema derives its z.nativeEnum from the same object —
20
20
  * so emitter and validator are one source. Co-located with the schemas (kept constants.ts under its cap).
21
21
  */
22
+ /**
23
+ * `FETCH` is a response whose BODY is still arriving after the request itself resolved.
24
+ *
25
+ * `fetch` settles at HEADERS, so a streamed response is reported complete while the server is still
26
+ * writing. Measured on a Next.js App Router page: the RSC payload's NET_REQUEST landed 16 ms in, the
27
+ * shell rendered, and the Suspense boundary's content arrived 889 ms later — a window in which
28
+ * nothing at all was observed, so `settled` passed while the fallback was still on screen.
29
+ */
22
30
  export declare const StreamTransport: {
23
31
  readonly SSE: "sse";
24
32
  readonly WS: "ws";
33
+ readonly FETCH: "fetch";
25
34
  };
26
35
  export type StreamTransport = (typeof StreamTransport)[keyof typeof StreamTransport];
36
+ /** `CLOSE` pairs with `OPEN`: until it arrives, the body is still being written. */
27
37
  export declare const StreamDirection: {
28
38
  readonly OPEN: "open";
29
39
  readonly IN: "in";
30
40
  readonly OUT: "out";
41
+ readonly CLOSE: "close";
31
42
  };
32
43
  export type StreamDirection = (typeof StreamDirection)[keyof typeof StreamDirection];
33
44
  export declare const ScrollDirection: {
@@ -134,36 +145,64 @@ export declare const EVENT_PAYLOAD_SCHEMAS: {
134
145
  transport: z.ZodNativeEnum<{
135
146
  readonly SSE: "sse";
136
147
  readonly WS: "ws";
148
+ readonly FETCH: "fetch";
137
149
  }>;
138
150
  direction: z.ZodNativeEnum<{
139
151
  readonly OPEN: "open";
140
152
  readonly IN: "in";
141
153
  readonly OUT: "out";
154
+ readonly CLOSE: "close";
142
155
  }>;
143
156
  url: z.ZodString;
144
157
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
145
158
  transport: z.ZodNativeEnum<{
146
159
  readonly SSE: "sse";
147
160
  readonly WS: "ws";
161
+ readonly FETCH: "fetch";
148
162
  }>;
149
163
  direction: z.ZodNativeEnum<{
150
164
  readonly OPEN: "open";
151
165
  readonly IN: "in";
152
166
  readonly OUT: "out";
167
+ readonly CLOSE: "close";
153
168
  }>;
154
169
  url: z.ZodString;
155
170
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
156
171
  transport: z.ZodNativeEnum<{
157
172
  readonly SSE: "sse";
158
173
  readonly WS: "ws";
174
+ readonly FETCH: "fetch";
159
175
  }>;
160
176
  direction: z.ZodNativeEnum<{
161
177
  readonly OPEN: "open";
162
178
  readonly IN: "in";
163
179
  readonly OUT: "out";
180
+ readonly CLOSE: "close";
164
181
  }>;
165
182
  url: z.ZodString;
166
183
  }, z.ZodTypeAny, "passthrough">>;
184
+ download: z.ZodObject<{
185
+ mimeType: z.ZodString;
186
+ bytes: z.ZodNumber;
187
+ filename: z.ZodOptional<z.ZodString>;
188
+ lines: z.ZodOptional<z.ZodNumber>;
189
+ preview: z.ZodOptional<z.ZodString>;
190
+ previewTruncated: z.ZodOptional<z.ZodBoolean>;
191
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
192
+ mimeType: z.ZodString;
193
+ bytes: z.ZodNumber;
194
+ filename: z.ZodOptional<z.ZodString>;
195
+ lines: z.ZodOptional<z.ZodNumber>;
196
+ preview: z.ZodOptional<z.ZodString>;
197
+ previewTruncated: z.ZodOptional<z.ZodBoolean>;
198
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
199
+ mimeType: z.ZodString;
200
+ bytes: z.ZodNumber;
201
+ filename: z.ZodOptional<z.ZodString>;
202
+ lines: z.ZodOptional<z.ZodNumber>;
203
+ preview: z.ZodOptional<z.ZodString>;
204
+ previewTruncated: z.ZodOptional<z.ZodBoolean>;
205
+ }, z.ZodTypeAny, "passthrough">>;
167
206
  perf: z.ZodObject<{
168
207
  metric: z.ZodNativeEnum<{
169
208
  readonly LCP: "lcp";
@@ -407,18 +446,37 @@ export declare const EVENT_PAYLOAD_SCHEMAS: {
407
446
  "blind-spot": z.ZodObject<{
408
447
  kind: z.ZodNativeEnum<{
409
448
  readonly CLOSED_SHADOW_ROOT: "closed-shadow-root";
449
+ readonly RATE_LIMITED: "rate-limited";
410
450
  readonly CROSS_ORIGIN_IFRAME: "cross-origin-iframe";
451
+ readonly UNINSTRUMENTED_FRAME: "uninstrumented-frame";
411
452
  readonly VIRTUALIZED_UNMOUNTED: "virtualized-unmounted";
412
453
  readonly WRAPPED_NETWORK: "wrapped-network";
454
+ readonly UNOBSERVED_IPC: "unobserved-ipc";
455
+ readonly VERDICTLESS_SEND: "verdictless-send";
413
456
  }>;
414
457
  count: z.ZodNumber;
415
458
  }, "strip", z.ZodTypeAny, {
416
- kind: "closed-shadow-root" | "cross-origin-iframe" | "virtualized-unmounted" | "wrapped-network";
459
+ kind: "closed-shadow-root" | "rate-limited" | "cross-origin-iframe" | "uninstrumented-frame" | "virtualized-unmounted" | "wrapped-network" | "unobserved-ipc" | "verdictless-send";
417
460
  count: number;
418
461
  }, {
419
- kind: "closed-shadow-root" | "cross-origin-iframe" | "virtualized-unmounted" | "wrapped-network";
462
+ kind: "closed-shadow-root" | "rate-limited" | "cross-origin-iframe" | "uninstrumented-frame" | "virtualized-unmounted" | "wrapped-network" | "unobserved-ipc" | "verdictless-send";
420
463
  count: number;
421
464
  }>;
465
+ "sdk.failed": z.ZodObject<{
466
+ /** WHERE in the SDK — a fixed vocabulary of our own module names, never a user path. */
467
+ site: z.ZodString;
468
+ /** The error message. Stripped of variables server-side before it is ever reported onward. */
469
+ message: z.ZodString;
470
+ errorType: z.ZodOptional<z.ZodString>;
471
+ }, "strip", z.ZodTypeAny, {
472
+ message: string;
473
+ site: string;
474
+ errorType?: string | undefined;
475
+ }, {
476
+ message: string;
477
+ site: string;
478
+ errorType?: string | undefined;
479
+ }>;
422
480
  "net.detail": z.ZodObject<{
423
481
  url: z.ZodString;
424
482
  method: z.ZodOptional<z.ZodString>;
@@ -499,4 +557,3 @@ export declare const EVENT_PAYLOAD_SCHEMAS: {
499
557
  };
500
558
  /** Narrow an event's `data` against its type's payload schema. Unknown in, typed-or-error out. */
501
559
  export declare function parseEventPayload(type: EventType, data: unknown): z.SafeParseReturnType<unknown, unknown>;
502
- //# sourceMappingURL=event-payloads.d.ts.map
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
- import { EventType, PerfMetric, BlindSpotKind } from './constants.js';
2
+ import { EventType, PerfMetric } from './constants.js';
3
+ import { BlindSpotKind } from './verified-constants.js';
3
4
  import { HumanControlDataSchema, HumanMarkDataSchema } from './messages.js';
4
5
  /**
5
6
  * Per-event-type payload schemas — the typed replacement for the envelope's open `data` record.
@@ -20,11 +21,34 @@ import { HumanControlDataSchema, HumanMarkDataSchema } from './messages.js';
20
21
  * object — the browser imports the members, the schema derives its z.nativeEnum from the same object —
21
22
  * so emitter and validator are one source. Co-located with the schemas (kept constants.ts under its cap).
22
23
  */
23
- export const StreamTransport = { SSE: 'sse', WS: 'ws' };
24
- export const StreamDirection = { OPEN: 'open', IN: 'in', OUT: 'out' };
24
+ /**
25
+ * `FETCH` is a response whose BODY is still arriving after the request itself resolved.
26
+ *
27
+ * `fetch` settles at HEADERS, so a streamed response is reported complete while the server is still
28
+ * writing. Measured on a Next.js App Router page: the RSC payload's NET_REQUEST landed 16 ms in, the
29
+ * shell rendered, and the Suspense boundary's content arrived 889 ms later — a window in which
30
+ * nothing at all was observed, so `settled` passed while the fallback was still on screen.
31
+ */
32
+ export const StreamTransport = { SSE: 'sse', WS: 'ws', FETCH: 'fetch' };
33
+ /** `CLOSE` pairs with `OPEN`: until it arrives, the body is still being written. */
34
+ export const StreamDirection = { OPEN: 'open', IN: 'in', OUT: 'out', CLOSE: 'close' };
25
35
  export const ScrollDirection = { UP: 'up', DOWN: 'down' };
26
36
  export const StorageArea = { LOCAL: 'local', SESSION: 'session', COOKIE: 'cookie' };
27
37
  const elementLabel = z.object({ role: z.string().optional(), name: z.string().optional() });
38
+ /**
39
+ * A file the app produced. `preview`/`lines` are present only when body capture is on, for the same
40
+ * reason request bodies are gated: an export is exactly where a customer list lives.
41
+ */
42
+ const downloadSchema = z
43
+ .object({
44
+ mimeType: z.string(),
45
+ bytes: z.number(),
46
+ filename: z.string().optional(),
47
+ lines: z.number().optional(),
48
+ preview: z.string().optional(),
49
+ previewTruncated: z.boolean().optional(),
50
+ })
51
+ .passthrough();
28
52
  const netStreamSchema = z
29
53
  .object({
30
54
  transport: z.nativeEnum(StreamTransport),
@@ -63,6 +87,7 @@ export const EVENT_PAYLOAD_SCHEMAS = {
63
87
  initiator: z.string(),
64
88
  }),
65
89
  [EventType.NET_STREAM]: netStreamSchema,
90
+ [EventType.DOWNLOAD]: downloadSchema,
66
91
  [EventType.PERF]: z.object({
67
92
  metric: z.nativeEnum(PerfMetric),
68
93
  value: z.number(),
@@ -119,6 +144,13 @@ export const EVENT_PAYLOAD_SCHEMAS = {
119
144
  [EventType.TRANSPORT_OVERFLOW]: z.object({ dropped: z.number() }),
120
145
  [EventType.TRUNCATED]: z.object({ channel: z.string(), dropped: z.number() }),
121
146
  [EventType.BLIND_SPOT]: z.object({ kind: z.nativeEnum(BlindSpotKind), count: z.number() }),
147
+ [EventType.SDK_FAILED]: z.object({
148
+ /** WHERE in the SDK — a fixed vocabulary of our own module names, never a user path. */
149
+ site: z.string().max(64),
150
+ /** The error message. Stripped of variables server-side before it is ever reported onward. */
151
+ message: z.string().max(500),
152
+ errorType: z.string().max(64).optional(),
153
+ }),
122
154
  [EventType.NET_DETAIL]: z
123
155
  .object({
124
156
  url: z.string(),
@@ -135,4 +167,3 @@ export const EVENT_PAYLOAD_SCHEMAS = {
135
167
  export function parseEventPayload(type, data) {
136
168
  return EVENT_PAYLOAD_SCHEMAS[type].safeParse(data);
137
169
  }
138
- //# sourceMappingURL=event-payloads.js.map
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Which events survive the bridge's rate cap.
3
+ *
4
+ * The cap exists because a busy app can emit faster than the bridge can absorb. But dropping
5
+ * indiscriminately is the wrong sampling policy: event volume is inversely correlated with event
6
+ * value. A React commit storm emits thousands of `render.commit`/`dom.*` per second, while the events
7
+ * an assertion actually turns on — a network call, an uncaught error, a route change — are rare.
8
+ * First-come-first-dropped therefore spends the whole budget on churn and loses exactly the signal
9
+ * the agent asked about.
10
+ *
11
+ * Measured on a react-admin renderer with a render loop: 11,138 events dropped in one window, and the
12
+ * single IPC call under test was among them. The assertion came back `unknown` — honest, but blind.
13
+ *
14
+ * So over the cap we drop the high-volume/low-value kinds first and keep a reserve for these. The
15
+ * reserve is bounded (see RATE_CAP_HIGH_VALUE_RESERVE_RATIO) — a flood of errors is still a flood,
16
+ * and going unbounded here would just move the overload rather than shed it.
17
+ */
18
+ export declare const HIGH_VALUE_EVENT_TYPES: ReadonlySet<string>;
19
+ /**
20
+ * The over-cap reserve for high-value events, as a multiple of the cap. Total admitted per second is
21
+ * therefore bounded at `cap * (1 + ratio)` — still a hard bound, just one that spends its last slots
22
+ * on the events worth keeping.
23
+ */
24
+ export declare const RATE_CAP_HIGH_VALUE_RESERVE_RATIO = 1;
25
+ export declare function isHighValueEvent(type: string): boolean;