@reticlehq/core 3.1.0 → 3.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 (82) hide show
  1. package/dist/artifacts/flow-composition.d.ts +3 -2
  2. package/dist/artifacts/flow-constants.d.ts +59 -2
  3. package/dist/artifacts/flow-constants.js +63 -3
  4. package/dist/artifacts/flow-expect-flat.d.ts +260 -0
  5. package/dist/artifacts/flow-expect-flat.js +284 -0
  6. package/dist/artifacts/flow-mutation-target.d.ts +0 -1
  7. package/dist/artifacts/flow-mutation-target.js +26 -2
  8. package/dist/artifacts/flow-step-tool.d.ts +2 -0
  9. package/dist/artifacts/flow-types.d.ts +1071 -1225
  10. package/dist/artifacts/flow-types.js +96 -140
  11. package/dist/artifacts/impact.d.ts +200 -20
  12. package/dist/artifacts/impact.js +72 -0
  13. package/dist/artifacts/journal.d.ts +85 -6
  14. package/dist/artifacts/journal.js +51 -1
  15. package/dist/hooks/hook-events.d.ts +18 -18
  16. package/dist/hud-entry.d.ts +9 -0
  17. package/dist/hud-entry.js +9 -0
  18. package/dist/identity/brand.d.ts +46 -0
  19. package/dist/identity/brand.js +7 -0
  20. package/dist/identity/source-constants.d.ts +11 -0
  21. package/dist/identity/source-constants.js +11 -0
  22. package/dist/index.d.ts +9 -0
  23. package/dist/index.js +26 -2
  24. package/dist/onboarding.d.ts +2 -2
  25. package/dist/realm/registry.d.ts +0 -8
  26. package/dist/realm/registry.js +1 -11
  27. package/dist/schema/event-message.json +3 -1
  28. package/dist/schema/event-payloads.json +74 -1
  29. package/dist/schema/event-type.json +3 -1
  30. package/dist/schema/reticle-event.json +3 -1
  31. package/dist/schema/reticle-message.json +3 -1
  32. package/dist/source-constants.cjs +1 -0
  33. package/dist/source-constants.d.cts +1 -0
  34. package/dist/telemetry-feedback.d.ts +6 -6
  35. package/dist/telemetry-refusal.d.ts +2 -2
  36. package/dist/telemetry-session.d.ts +25 -2
  37. package/dist/telemetry-session.js +13 -0
  38. package/dist/telemetry.d.ts +184 -102
  39. package/dist/telemetry.js +29 -1
  40. package/dist/verdict/consequence.d.ts +10 -0
  41. package/dist/verdict/consequence.js +13 -0
  42. package/dist/verdict/intent.d.ts +36 -12
  43. package/dist/verdict/intent.js +66 -10
  44. package/dist/verdict/predicate-tree.d.ts +47 -0
  45. package/dist/verdict/predicate-tree.js +146 -0
  46. package/dist/verdict/predicate.d.ts +129 -0
  47. package/dist/verdict/predicate.js +394 -0
  48. package/dist/verdict/property-assertion.d.ts +191 -0
  49. package/dist/verdict/property-assertion.js +42 -0
  50. package/dist/verdict/security.js +16 -4
  51. package/dist/verdict/verdict-attribution.d.ts +52 -0
  52. package/dist/verdict/verdict-attribution.js +87 -0
  53. package/dist/verdict/verification-run.d.ts +98 -84
  54. package/dist/verdict/verification-run.js +8 -1
  55. package/dist/verdict/verified-constants.d.ts +18 -0
  56. package/dist/verdict/verified-constants.js +18 -0
  57. package/dist/wire/constants/constants.d.ts +108 -98
  58. package/dist/wire/constants/constants.js +116 -97
  59. package/dist/wire/constants/discovery.d.ts +25 -0
  60. package/dist/wire/constants/discovery.js +25 -0
  61. package/dist/wire/constants/event-types.d.ts +122 -0
  62. package/dist/wire/constants/event-types.js +121 -0
  63. package/dist/wire/constants/hud-controls.d.ts +19 -0
  64. package/dist/wire/constants/hud-controls.js +95 -0
  65. package/dist/wire/constants/hud-use.d.ts +27 -0
  66. package/dist/wire/constants/hud-use.js +24 -0
  67. package/dist/wire/constants/session-constants.d.ts +24 -0
  68. package/dist/wire/constants/session-constants.js +24 -0
  69. package/dist/wire/event-payloads.d.ts +70 -10
  70. package/dist/wire/event-payloads.js +20 -1
  71. package/dist/wire/messages.d.ts +90 -48
  72. package/dist/wire/messages.js +17 -0
  73. package/dist/wire/net.d.ts +42 -0
  74. package/dist/wire/net.js +48 -0
  75. package/dist/wire/snapshot-tree.d.ts +33 -0
  76. package/dist/wire/snapshot-tree.js +43 -0
  77. package/dist/wire/state-select.d.ts +2 -1
  78. package/dist/wire/state-select.js +56 -3
  79. package/dist/wire/toon.js +28 -7
  80. package/dist/wire/types.d.ts +91 -66
  81. package/dist/wire/types.js +23 -1
  82. package/package.json +5 -1
@@ -202,7 +202,14 @@ export const RunFlowResultSchema = z.object({
202
202
  });
203
203
  /** A standalone assertion not tied to a flow. `evidence` is opaque (narrowed per kind by the caller). */
204
204
  export const RunCheckSchema = z.object({
205
- kind: z.preprocess((given) => ('string' === typeof given ? (OLD_CHECK_KIND_SPELLING[given] ?? given) : given), z.nativeEnum(PredicateKind)),
205
+ /**
206
+ * Which source of truth answering this claim required.
207
+ *
208
+ * Optional, because a check folded from a journal written before the kind was recorded has none,
209
+ * and the only alternatives are refusing the whole run or filling in a kind nobody observed. An
210
+ * absent field says nobody wrote it down; a present one is what the predicate actually read.
211
+ */
212
+ kind: z.preprocess((given) => ('string' === typeof given ? (OLD_CHECK_KIND_SPELLING[given] ?? given) : given), z.nativeEnum(PredicateKind).optional()),
206
213
  predicate: z.string(),
207
214
  status: z.preprocess((given) => ('string' === typeof given ? (OLD_CHECK_STATUS_SPELLING[given] ?? given) : given), z.nativeEnum(Verified)),
208
215
  evidence: z.unknown().optional(),
@@ -61,6 +61,15 @@ export declare const VerifiedReason: {
61
61
  * to produce the same empty answer. Saying `no` to the second blames the app for a gap in the
62
62
  * tooling, and is the confident wrong answer this whole mechanism exists to remove.
63
63
  */
64
+ /**
65
+ * The page SDK and the daemon are on different wire contracts, so the evidence behind this claim
66
+ * cannot be trusted -- `reticle_session` already warns that under skew "dispatched/settled may be
67
+ * silent no-ops", which is a statement about the EVIDENCE, not about the app.
68
+ *
69
+ * UNKNOWN rather than NO, because nothing was disproved. Reported from the field as a `yes` with
70
+ * exit 0 printed beside an evidence block that named the skew in the same payload.
71
+ */
72
+ readonly VERSION_SKEW: "version_skew";
64
73
  readonly CAPABILITY_ABSENT: "capability-absent";
65
74
  /** The assertion was never EVALUATED — under-specified call, or nothing instrumented to read. */
66
75
  readonly INCONCLUSIVE: "inconclusive";
@@ -147,6 +156,15 @@ export declare const CaptureLoss: {
147
156
  readonly TRANSPORT_GAP: "transport_gap";
148
157
  /** A region the SDK cannot see through — a cross-origin frame, a closed shadow root. */
149
158
  readonly BLIND_SPOT: "blind_spot";
159
+ /**
160
+ * The durable event ledger refused writes at its byte ceiling, so evidence is missing from DISK.
161
+ *
162
+ * A fourth owner, and the one whose loss does not heal. `buffer_loss` is a window that aged out of
163
+ * memory and `transport_gap` is a queue that overflowed for a moment; this one is a file that
164
+ * stopped accepting writes for the rest of the session. Folding it into `buffer_loss` would put
165
+ * "wait and re-drive" next to a condition no re-drive can fix.
166
+ */
167
+ readonly JOURNAL_LOSS: "journal_loss";
150
168
  /** A loss we have not classified. A classifier that cannot say "I don't know" lies instead. */
151
169
  readonly OTHER: "other";
152
170
  };
@@ -60,6 +60,15 @@ export const VerifiedReason = {
60
60
  * to produce the same empty answer. Saying `no` to the second blames the app for a gap in the
61
61
  * tooling, and is the confident wrong answer this whole mechanism exists to remove.
62
62
  */
63
+ /**
64
+ * The page SDK and the daemon are on different wire contracts, so the evidence behind this claim
65
+ * cannot be trusted -- `reticle_session` already warns that under skew "dispatched/settled may be
66
+ * silent no-ops", which is a statement about the EVIDENCE, not about the app.
67
+ *
68
+ * UNKNOWN rather than NO, because nothing was disproved. Reported from the field as a `yes` with
69
+ * exit 0 printed beside an evidence block that named the skew in the same payload.
70
+ */
71
+ VERSION_SKEW: 'version_skew',
63
72
  CAPABILITY_ABSENT: 'capability-absent',
64
73
  /** The assertion was never EVALUATED — under-specified call, or nothing instrumented to read. */
65
74
  INCONCLUSIVE: 'inconclusive',
@@ -145,6 +154,15 @@ export const CaptureLoss = {
145
154
  TRANSPORT_GAP: 'transport_gap',
146
155
  /** A region the SDK cannot see through — a cross-origin frame, a closed shadow root. */
147
156
  BLIND_SPOT: 'blind_spot',
157
+ /**
158
+ * The durable event ledger refused writes at its byte ceiling, so evidence is missing from DISK.
159
+ *
160
+ * A fourth owner, and the one whose loss does not heal. `buffer_loss` is a window that aged out of
161
+ * memory and `transport_gap` is a queue that overflowed for a moment; this one is a file that
162
+ * stopped accepting writes for the rest of the session. Folding it into `buffer_loss` would put
163
+ * "wait and re-drive" next to a condition no re-drive can fix.
164
+ */
165
+ JOURNAL_LOSS: 'journal_loss',
148
166
  /** A loss we have not classified. A classifier that cannot say "I don't know" lies instead. */
149
167
  OTHER: 'other',
150
168
  };
@@ -178,7 +178,59 @@ export declare const ReticleEnv: {
178
178
  readonly HARNESS_BASE_URL: "RETICLE_HARNESS_BASE_URL";
179
179
  /** Hard ceiling on harness model turns in one drive. Bounds cost, not value. */
180
180
  readonly HARNESS_MAX_STEPS: "RETICLE_HARNESS_MAX_STEPS";
181
+ /**
182
+ * Which model backs the harness driver: `anthropic` (the default) or `jev`.
183
+ *
184
+ * Two drivers exist because the driver's job turns out not to need a text generator. It picks the
185
+ * next action and says what it expects; the verdict is decided afterwards by the engine, with no
186
+ * model anywhere near it. A System One model answers typed questions against a state, which is
187
+ * exactly that job and none of the rest, so it can drive without being able to generate a
188
+ * sentence. Unset keeps the existing behaviour for everybody who has not asked for this.
189
+ */
190
+ readonly HARNESS_DRIVER: "RETICLE_HARNESS_DRIVER";
191
+ /**
192
+ * A direct Jev key, for this repo's own benchmarks and for anyone holding a TypeSafe account.
193
+ *
194
+ * Users are not expected to have one. The ordinary path is the key they already minted on the
195
+ * platform (`RETICLE_API_KEY`), which reaches Jev through the proxy at `RETICLE_CLOUD_URL` —
196
+ * this variable is the escape hatch that skips it, and it takes precedence when both are set so
197
+ * that a developer debugging the upstream is never silently talking to the proxy instead.
198
+ */
199
+ readonly HARNESS_JEV_KEY: "JEV_API_KEY";
200
+ /** Base URL for the Jev API, for a proxy or a gateway. Defaults to TypeSafe's own endpoint. */
201
+ readonly HARNESS_JEV_URL: "RETICLE_HARNESS_JEV_URL";
202
+ /** A direct OpenAI key. As with Jev, the ordinary path is the platform key and its proxy. */
203
+ readonly HARNESS_OPENAI_KEY: "OPENAI_API_KEY";
204
+ /** Model the OpenAI driver uses. Defaults to a small one — see `DEFAULT_OPENAI_MODEL`. */
205
+ readonly HARNESS_OPENAI_MODEL: "RETICLE_HARNESS_OPENAI_MODEL";
206
+ /**
207
+ * The API key minted on the platform, and the host it belongs to.
208
+ *
209
+ * Read through `apiKeyFrom()`, never directly — see the note on that function for why there are
210
+ * two names for one key and why neither may be dropped.
211
+ */
212
+ readonly API_KEY: "RETICLE_API_KEY";
213
+ /** The name this key had until 2026-09. Still honoured; see `apiKeyFrom()`. */
214
+ readonly CLOUD_KEY: "RETICLE_CLOUD_KEY";
215
+ readonly CLOUD_URL: "RETICLE_CLOUD_URL";
181
216
  };
217
+ /**
218
+ * The platform API key, whichever name it arrives under.
219
+ *
220
+ * `RETICLE_API_KEY` is the name. `RETICLE_CLOUD_KEY` is what it was called until 2026-09, and it
221
+ * keeps working — not out of politeness, but because the console printed that name to every user
222
+ * who ever connected a project, so it is exported in shells and CI configs we cannot see or edit.
223
+ * A rename that silently stops reading the old name does not look like a rename to those people;
224
+ * it looks like the product quietly losing their credentials.
225
+ *
226
+ * ONE function, because the alternative is each caller remembering both names and one of them
227
+ * forgetting. That is not hypothetical: this key was read inline in several places before it was
228
+ * named here at all, which is exactly how a rename half-lands.
229
+ *
230
+ * The new name wins when both are set, so a user migrating can export the new one and confirm it
231
+ * works before removing the old.
232
+ */
233
+ export declare function apiKeyFrom(env: Record<string, string | undefined>): string | undefined;
182
234
  /** Hard transport bounds shared by the browser and bridge. */
183
235
  export declare const TRANSPORT_LIMITS: {
184
236
  readonly MAX_MESSAGE_BYTES: number;
@@ -255,18 +307,53 @@ export declare const ReticleDir: {
255
307
  readonly IMPACT_FILE: "impact.json";
256
308
  /** what changes were SUPPOSED to make true —.reticle/intent.json (git-checked, reviewed) */
257
309
  readonly INTENT_FILE: "intent.json";
310
+ /**
311
+ * The sharded form of the same ledger —.reticle/intent/ (git-checked, for the same reason).
312
+ *
313
+ * Named here rather than inline at the store that writes it, because the partition guard over
314
+ * this object is what decides whether a name Reticle creates is committed or ignored. A directory
315
+ * spelled as a free string somewhere else is one the guard cannot see, so nobody ever makes that
316
+ * decision: `intent/` was written into users' repositories for that reason alone, neither
317
+ * classified nor ignored.
318
+ */
319
+ readonly INTENT_SUBDIR: "intent";
320
+ /**
321
+ * what a drive types into a field, keyed by the field's label —.reticle/fill-values.json.
322
+ *
323
+ * Git-checked on purpose. A generated value is paid for once and then belongs to the project: the
324
+ * next drive reuses it for free, a replay sends exactly what the recording sent, and a human who
325
+ * dislikes one can edit the file rather than argue with a model.
326
+ */
327
+ readonly FILL_VALUES_FILE: "fill-values.json";
258
328
  /** opt-in pixel baselines —.reticle/visual/<name>.png + <name>.diff.png. */
259
329
  readonly VISUAL_SUBDIR: "visual";
260
330
  /** verification-run artifacts —.reticle/runs/<runId>.json (the OEM/CI-consumable verdict). */
261
331
  readonly RUNS_SUBDIR: "runs";
262
332
  /** fail-to-pass bug capsules —.reticle/capsules/<id>.json (a minimal failing flow + its evidence). */
263
333
  readonly CAPSULES_SUBDIR: "capsules";
334
+ /**
335
+ * Where a feedback report refused delivery is copied — .reticle/feedback/.
336
+ *
337
+ * Named here rather than at the writer because the partition over this object is what decides
338
+ * whether a name Reticle creates is committed, ignored, or swept. It was spelled as a free string
339
+ * in three separate files, so the guard could not see it and nobody was ever asked.
340
+ */
341
+ readonly FEEDBACK_SUBDIR: "feedback";
264
342
  /** durable causal journal —.reticle/sessions/<id>/{events,actions}.jsonl (the substrate). */
265
343
  readonly SESSIONS_SUBDIR: "sessions";
266
344
  /** append-only event ledger inside a session dir (one ReticleEvent per line). */
267
345
  readonly JOURNAL_EVENTS_FILE: "events.jsonl";
268
346
  /** append-only action ledger inside a session dir (one JournalAction per line). */
269
347
  readonly JOURNAL_ACTIONS_FILE: "actions.jsonl";
348
+ /**
349
+ * the event ledger's closure report — .reticle/sessions/<id>/events.closed.json.
350
+ *
351
+ * Written once, when the byte ceiling refuses a batch, and never removed. Its PRESENCE is what
352
+ * makes the ceiling durable: a session id survives a reload, so the next connection reopens the
353
+ * same ledger with an empty memory, and a bound that lives only in one object's field is a bound
354
+ * per connection. Its CONTENTS are the loss report a time-windowed query cannot filter away.
355
+ */
356
+ readonly JOURNAL_EVENTS_CLOSED_FILE: "events.closed.json";
270
357
  /** learned expected-envelopes per route, accumulated across runs (the deviation-report baseline). */
271
358
  readonly ENVELOPES_FILE: "envelopes.json";
272
359
  /** learned ambient (action-less churn) region map — excluded from settle/summaries/envelopes. */
@@ -311,6 +398,16 @@ export declare const ReticleDir: {
311
398
  */
312
399
  readonly PAIRING_TOKEN_FILE: "pairing-token";
313
400
  };
401
+ /**
402
+ * The names INSIDE `.reticle/intent/` — kept apart from `ReticleDir`, which lists what `.reticle/`
403
+ * itself holds and is what the retention tiers classify.
404
+ */
405
+ export declare const IntentDir: {
406
+ /** One per subject: `.reticle/intent/<subject>/intent.json`. A flow's name is its subject. */
407
+ readonly SHARD_FILE: "intent.json";
408
+ /** Derived from the shards: `.reticle/intent/index.json`, one line per intent. */
409
+ readonly INDEX_FILE: "index.json";
410
+ };
314
411
  /**
315
412
  * Structured reasons a screenshot/visual-diff could not produce a verdict (never
316
413
  * thrown as free strings). The visual layer is OPT-IN and CDP/Playwright-driven — it is NEVER
@@ -366,110 +463,14 @@ export declare const ContractReadError: {
366
463
  readonly MALFORMED: "contract-malformed";
367
464
  };
368
465
  export type ContractReadError = (typeof ContractReadError)[keyof typeof ContractReadError];
466
+ import { EventType } from './event-types.js';
467
+ export { EventType };
369
468
  /** Bounds for the per-session ring buffer. */
370
469
  export declare const RING_BUFFER_DEFAULTS: {
371
470
  readonly MAX_EVENTS: 2000;
372
471
  readonly MAX_AGE_MS: 60000;
373
472
  readonly MAX_BYTES: number;
374
473
  };
375
- /** Normalized event types pushed into the ring buffer. */
376
- export declare const EventType: {
377
- readonly DOM_ADDED: "dom.added";
378
- readonly DOM_REMOVED: "dom.removed";
379
- readonly DOM_ATTR: "dom.attr";
380
- readonly DOM_TEXT: "dom.text";
381
- readonly NET_REQUEST: "net.request";
382
- readonly NET_PENDING: "net.pending";
383
- /** An SSE (EventSource) or WebSocket frame — a message on a long-lived streaming connection. */
384
- readonly NET_STREAM: "net.stream";
385
- /** A web-perf metric a screenshot can't verify: LCP, cumulative layout shift, or a long task. */
386
- readonly PERF: "perf";
387
- readonly ROUTE_CHANGE: "route.change";
388
- readonly CONSOLE_LOG: "console.log";
389
- readonly CONSOLE_WARN: "console.warn";
390
- readonly CONSOLE_ERROR: "console.error";
391
- readonly CONSOLE_INFO: "console.info";
392
- readonly CONSOLE_DEBUG: "console.debug";
393
- readonly ERROR_UNCAUGHT: "error.uncaught";
394
- readonly VISIBLE_SHOWN: "visible.shown";
395
- readonly ANIM_START: "anim.start";
396
- readonly ANIM_END: "anim.end";
397
- readonly SCROLL_POSITION: "scroll.position";
398
- readonly REVEAL_SHOWN: "reveal.shown";
399
- readonly SIGNAL: "signal";
400
- readonly STATE_CHANGE: "state.change";
401
- /** a write to localStorage/sessionStorage/cookies — `data: { area, key, old?, new? }` (values redacted). */
402
- readonly STORAGE_CHANGE: "storage.change";
403
- /** page-level visibility/focus health (distinct from element-level VISIBLE_*). */
404
- readonly PAGE_HEALTH: "page.health";
405
- /**
406
- * synthetic: the page called window.open, so the consequence of what was just clicked may live in
407
- * another browsing context this one cannot observe (an OAuth popup is the archetype).
408
- * `data: { href }` — the URL the page asked to open, when it named one.
409
- */
410
- readonly CONTEXT_OPENED: "context.opened";
411
- /**
412
- * The app opened a native `alert`/`confirm`/`prompt` while Reticle was driving it.
413
- *
414
- * Recorded because Reticle ANSWERS these rather than letting them block — a native dialog halts
415
- * the main thread, and the SDK's own message pump is on that thread, so one `confirm` behind a
416
- * driven click made the tab permanently unresponsive with no recovery from inside the session.
417
- * Answering silently would trade a wedge for an invisible one, so the question the app asked, and
418
- * the answer given, ride out as an event.
419
- */
420
- readonly DIALOG_OPENED: "dialog.opened";
421
- /** aggregated React commits over a throttle window (dev builds) — `data: { commits }`. Commit storms /
422
- * wasted re-renders show up here without a per-render flood. */
423
- readonly RENDER_COMMIT: "render.commit";
424
- /** element focus moved — `data: { to, from, toBody }`. Focus dropping to body after an act is a regression. */
425
- readonly FOCUS_CHANGE: "focus.change";
426
- /** browser → bridge: a human recording compiled in-page. */
427
- readonly FLOW_RECORDED: "flow.recorded";
428
- /** synthetic: browser transport queue overflowed; events were dropped. `data: { dropped: number }`. */
429
- readonly TRANSPORT_OVERFLOW: "transport.overflow";
430
- /**
431
- * synthetic: a per-channel cap truncated a batch (e.g. a DOM mutation flood). `data: { channel, dropped }`.
432
- * Marks downstream rollups/envelopes as built on incomplete data — a ledger that lies at scale is worse
433
- * than no ledger, so truncation is never silent.
434
- */
435
- readonly TRUNCATED: "truncated";
436
- /**
437
- * synthetic: the SDK detected a region it CANNOT observe (a cross-origin iframe, a closed shadow root).
438
- * `data: { kind: BlindSpotKind, count }`. Surfaced on results as `coverage: partial` so a green never
439
- * implies it saw everything.
440
- */
441
- readonly BLIND_SPOT: "blind-spot";
442
- /** synthetic: the SDK ITSELF failed (an observer threw). `data: { site, message, errorType }`.
443
- * Rides the existing bridge — no outbound request. See browser/observers/sdk-failure.ts. */
444
- readonly SDK_FAILED: "sdk.failed";
445
- /**
446
- * synthetic (driven only): CDP/Playwright-authoritative network detail for a response the in-page
447
- * fetch/XHR wrapper also saw — full response headers + authoritative status/mimeType the page-side
448
- * wrapper can't reach. `data: { url, method?, status, headers, resourceType? }`. Merged onto the
449
- * matching in-page NET_REQUEST so the driven view never loses fidelity to an outside-in tool.
450
- */
451
- readonly NET_DETAIL: "net.detail";
452
- /**
453
- * Live-control: browser → bridge. A human acted on the presenter panel.
454
- * `data: { kind: HumanControlKind; text?: string }`. Rides the existing EventMessage.
455
- */
456
- readonly HUMAN_CONTROL: "human.control";
457
- /**
458
- * Human review: browser → bridge. A human pinned a mistake to an element on the running page
459
- * (the "annotate the bug where you see it" loop). `data` narrows to HumanMarkDataSchema — a note
460
- * plus a re-resolvable element anchor (and its source file:line when the framework stamped one) so
461
- * the agent that drains the mark knows exactly which element and which source to fix.
462
- */
463
- readonly HUMAN_MARK: "human.mark";
464
- /**
465
- * The app produced a FILE — a Blob handed to `URL.createObjectURL`, usually saved by clicking an
466
- * anchor with `download`. `data: { filename?, mimeType, bytes, lines?, preview? }`. The one artifact
467
- * class no outside-the-browser tool can inspect: it never crosses the network, so there is no
468
- * request to intercept. See `observers/download.ts` for the defect that motivated it.
469
- */
470
- readonly DOWNLOAD: "download";
471
- };
472
- export type EventType = (typeof EventType)[keyof typeof EventType];
473
474
  /**
474
475
  * Named phenomena the perception layer detects deterministically over the journal — capsules and
475
476
  * deviation reports lead with these names, not raw events. The library grows in later releases; the
@@ -516,6 +517,15 @@ export declare const RETICLE_HYDRATION_ERROR_SIGNAL = "reticle:hydration-error";
516
517
  /** The observation channel a TRUNCATED event names, so downstream knows WHICH data is incomplete. */
517
518
  export declare const TruncationChannel: {
518
519
  readonly DOM: "dom";
520
+ /**
521
+ * The durable per-session event ledger stopped accepting writes at its byte ceiling.
522
+ *
523
+ * The only channel here that names a SERVER-side refusal rather than a browser-side batch cap, and
524
+ * the only one that is terminal: `dom` truncates one flood and keeps observing, while this says the
525
+ * file is closed and every event after it is absent from disk. A reader that finds it knows a
526
+ * negative answer drawn from the journal may be "the ledger was full", not "it never happened".
527
+ */
528
+ readonly JOURNAL: "journal";
519
529
  };
520
530
  export type TruncationChannel = (typeof TruncationChannel)[keyof typeof TruncationChannel];
521
531
  /**
@@ -180,7 +180,65 @@ export const ReticleEnv = {
180
180
  HARNESS_BASE_URL: 'RETICLE_HARNESS_BASE_URL',
181
181
  /** Hard ceiling on harness model turns in one drive. Bounds cost, not value. */
182
182
  HARNESS_MAX_STEPS: 'RETICLE_HARNESS_MAX_STEPS',
183
+ /**
184
+ * Which model backs the harness driver: `anthropic` (the default) or `jev`.
185
+ *
186
+ * Two drivers exist because the driver's job turns out not to need a text generator. It picks the
187
+ * next action and says what it expects; the verdict is decided afterwards by the engine, with no
188
+ * model anywhere near it. A System One model answers typed questions against a state, which is
189
+ * exactly that job and none of the rest, so it can drive without being able to generate a
190
+ * sentence. Unset keeps the existing behaviour for everybody who has not asked for this.
191
+ */
192
+ HARNESS_DRIVER: 'RETICLE_HARNESS_DRIVER',
193
+ /**
194
+ * A direct Jev key, for this repo's own benchmarks and for anyone holding a TypeSafe account.
195
+ *
196
+ * Users are not expected to have one. The ordinary path is the key they already minted on the
197
+ * platform (`RETICLE_API_KEY`), which reaches Jev through the proxy at `RETICLE_CLOUD_URL` —
198
+ * this variable is the escape hatch that skips it, and it takes precedence when both are set so
199
+ * that a developer debugging the upstream is never silently talking to the proxy instead.
200
+ */
201
+ HARNESS_JEV_KEY: 'JEV_API_KEY',
202
+ /** Base URL for the Jev API, for a proxy or a gateway. Defaults to TypeSafe's own endpoint. */
203
+ HARNESS_JEV_URL: 'RETICLE_HARNESS_JEV_URL',
204
+ /** A direct OpenAI key. As with Jev, the ordinary path is the platform key and its proxy. */
205
+ HARNESS_OPENAI_KEY: 'OPENAI_API_KEY',
206
+ /** Model the OpenAI driver uses. Defaults to a small one — see `DEFAULT_OPENAI_MODEL`. */
207
+ HARNESS_OPENAI_MODEL: 'RETICLE_HARNESS_OPENAI_MODEL',
208
+ /**
209
+ * The API key minted on the platform, and the host it belongs to.
210
+ *
211
+ * Read through `apiKeyFrom()`, never directly — see the note on that function for why there are
212
+ * two names for one key and why neither may be dropped.
213
+ */
214
+ API_KEY: 'RETICLE_API_KEY',
215
+ /** The name this key had until 2026-09. Still honoured; see `apiKeyFrom()`. */
216
+ CLOUD_KEY: 'RETICLE_CLOUD_KEY',
217
+ CLOUD_URL: 'RETICLE_CLOUD_URL',
183
218
  };
219
+ /**
220
+ * The platform API key, whichever name it arrives under.
221
+ *
222
+ * `RETICLE_API_KEY` is the name. `RETICLE_CLOUD_KEY` is what it was called until 2026-09, and it
223
+ * keeps working — not out of politeness, but because the console printed that name to every user
224
+ * who ever connected a project, so it is exported in shells and CI configs we cannot see or edit.
225
+ * A rename that silently stops reading the old name does not look like a rename to those people;
226
+ * it looks like the product quietly losing their credentials.
227
+ *
228
+ * ONE function, because the alternative is each caller remembering both names and one of them
229
+ * forgetting. That is not hypothetical: this key was read inline in several places before it was
230
+ * named here at all, which is exactly how a rename half-lands.
231
+ *
232
+ * The new name wins when both are set, so a user migrating can export the new one and confirm it
233
+ * works before removing the old.
234
+ */
235
+ export function apiKeyFrom(env) {
236
+ const current = env[ReticleEnv.API_KEY];
237
+ if (current !== undefined && 0 < current.length)
238
+ return current;
239
+ const legacy = env[ReticleEnv.CLOUD_KEY];
240
+ return legacy !== undefined && 0 < legacy.length ? legacy : undefined;
241
+ }
184
242
  /** Hard transport bounds shared by the browser and bridge. */
185
243
  export const TRANSPORT_LIMITS = {
186
244
  MAX_MESSAGE_BYTES: 1024 * 1024,
@@ -271,18 +329,53 @@ export const ReticleDir = {
271
329
  IMPACT_FILE: 'impact.json',
272
330
  /** what changes were SUPPOSED to make true —.reticle/intent.json (git-checked, reviewed) */
273
331
  INTENT_FILE: 'intent.json',
332
+ /**
333
+ * The sharded form of the same ledger —.reticle/intent/ (git-checked, for the same reason).
334
+ *
335
+ * Named here rather than inline at the store that writes it, because the partition guard over
336
+ * this object is what decides whether a name Reticle creates is committed or ignored. A directory
337
+ * spelled as a free string somewhere else is one the guard cannot see, so nobody ever makes that
338
+ * decision: `intent/` was written into users' repositories for that reason alone, neither
339
+ * classified nor ignored.
340
+ */
341
+ INTENT_SUBDIR: 'intent',
342
+ /**
343
+ * what a drive types into a field, keyed by the field's label —.reticle/fill-values.json.
344
+ *
345
+ * Git-checked on purpose. A generated value is paid for once and then belongs to the project: the
346
+ * next drive reuses it for free, a replay sends exactly what the recording sent, and a human who
347
+ * dislikes one can edit the file rather than argue with a model.
348
+ */
349
+ FILL_VALUES_FILE: 'fill-values.json',
274
350
  /** opt-in pixel baselines —.reticle/visual/<name>.png + <name>.diff.png. */
275
351
  VISUAL_SUBDIR: 'visual',
276
352
  /** verification-run artifacts —.reticle/runs/<runId>.json (the OEM/CI-consumable verdict). */
277
353
  RUNS_SUBDIR: 'runs',
278
354
  /** fail-to-pass bug capsules —.reticle/capsules/<id>.json (a minimal failing flow + its evidence). */
279
355
  CAPSULES_SUBDIR: 'capsules',
356
+ /**
357
+ * Where a feedback report refused delivery is copied — .reticle/feedback/.
358
+ *
359
+ * Named here rather than at the writer because the partition over this object is what decides
360
+ * whether a name Reticle creates is committed, ignored, or swept. It was spelled as a free string
361
+ * in three separate files, so the guard could not see it and nobody was ever asked.
362
+ */
363
+ FEEDBACK_SUBDIR: 'feedback',
280
364
  /** durable causal journal —.reticle/sessions/<id>/{events,actions}.jsonl (the substrate). */
281
365
  SESSIONS_SUBDIR: 'sessions',
282
366
  /** append-only event ledger inside a session dir (one ReticleEvent per line). */
283
367
  JOURNAL_EVENTS_FILE: 'events.jsonl',
284
368
  /** append-only action ledger inside a session dir (one JournalAction per line). */
285
369
  JOURNAL_ACTIONS_FILE: 'actions.jsonl',
370
+ /**
371
+ * the event ledger's closure report — .reticle/sessions/<id>/events.closed.json.
372
+ *
373
+ * Written once, when the byte ceiling refuses a batch, and never removed. Its PRESENCE is what
374
+ * makes the ceiling durable: a session id survives a reload, so the next connection reopens the
375
+ * same ledger with an empty memory, and a bound that lives only in one object's field is a bound
376
+ * per connection. Its CONTENTS are the loss report a time-windowed query cannot filter away.
377
+ */
378
+ JOURNAL_EVENTS_CLOSED_FILE: 'events.closed.json',
286
379
  /** learned expected-envelopes per route, accumulated across runs (the deviation-report baseline). */
287
380
  ENVELOPES_FILE: 'envelopes.json',
288
381
  /** learned ambient (action-less churn) region map — excluded from settle/summaries/envelopes. */
@@ -327,6 +420,16 @@ export const ReticleDir = {
327
420
  */
328
421
  PAIRING_TOKEN_FILE: 'pairing-token',
329
422
  };
423
+ /**
424
+ * The names INSIDE `.reticle/intent/` — kept apart from `ReticleDir`, which lists what `.reticle/`
425
+ * itself holds and is what the retention tiers classify.
426
+ */
427
+ export const IntentDir = {
428
+ /** One per subject: `.reticle/intent/<subject>/intent.json`. A flow's name is its subject. */
429
+ SHARD_FILE: 'intent.json',
430
+ /** Derived from the shards: `.reticle/intent/index.json`, one line per intent. */
431
+ INDEX_FILE: 'index.json',
432
+ };
330
433
  /**
331
434
  * Structured reasons a screenshot/visual-diff could not produce a verdict (never
332
435
  * thrown as free strings). The visual layer is OPT-IN and CDP/Playwright-driven — it is NEVER
@@ -388,109 +491,16 @@ export const ContractReadError = {
388
491
  MISSING: 'contract-missing', // no .reticle/contract.json on disk
389
492
  MALFORMED: 'contract-malformed', // present but not valid JSON / fails schema
390
493
  };
494
+ // The event vocabulary lives beside this file and is re-exported here, so `EventType` stays one
495
+ // import path for every consumer. See event-types.ts for why it moved.
496
+ import { EventType } from './event-types.js';
497
+ export { EventType };
391
498
  /** Bounds for the per-session ring buffer. */
392
499
  export const RING_BUFFER_DEFAULTS = {
393
500
  MAX_EVENTS: 2000,
394
501
  MAX_AGE_MS: 60_000,
395
502
  MAX_BYTES: TRANSPORT_LIMITS.MAX_BUFFER_BYTES,
396
503
  };
397
- /** Normalized event types pushed into the ring buffer. */
398
- export const EventType = {
399
- DOM_ADDED: 'dom.added',
400
- DOM_REMOVED: 'dom.removed',
401
- DOM_ATTR: 'dom.attr',
402
- DOM_TEXT: 'dom.text',
403
- NET_REQUEST: 'net.request',
404
- NET_PENDING: 'net.pending',
405
- /** An SSE (EventSource) or WebSocket frame — a message on a long-lived streaming connection. */
406
- NET_STREAM: 'net.stream',
407
- /** A web-perf metric a screenshot can't verify: LCP, cumulative layout shift, or a long task. */
408
- PERF: 'perf',
409
- ROUTE_CHANGE: 'route.change',
410
- CONSOLE_LOG: 'console.log',
411
- CONSOLE_WARN: 'console.warn',
412
- CONSOLE_ERROR: 'console.error',
413
- CONSOLE_INFO: 'console.info',
414
- CONSOLE_DEBUG: 'console.debug',
415
- ERROR_UNCAUGHT: 'error.uncaught',
416
- VISIBLE_SHOWN: 'visible.shown',
417
- ANIM_START: 'anim.start',
418
- ANIM_END: 'anim.end',
419
- SCROLL_POSITION: 'scroll.position',
420
- REVEAL_SHOWN: 'reveal.shown',
421
- SIGNAL: 'signal',
422
- STATE_CHANGE: 'state.change',
423
- /** a write to localStorage/sessionStorage/cookies — `data: { area, key, old?, new? }` (values redacted). */
424
- STORAGE_CHANGE: 'storage.change',
425
- /** page-level visibility/focus health (distinct from element-level VISIBLE_*). */
426
- PAGE_HEALTH: 'page.health',
427
- /**
428
- * synthetic: the page called window.open, so the consequence of what was just clicked may live in
429
- * another browsing context this one cannot observe (an OAuth popup is the archetype).
430
- * `data: { href }` — the URL the page asked to open, when it named one.
431
- */
432
- CONTEXT_OPENED: 'context.opened',
433
- /**
434
- * The app opened a native `alert`/`confirm`/`prompt` while Reticle was driving it.
435
- *
436
- * Recorded because Reticle ANSWERS these rather than letting them block — a native dialog halts
437
- * the main thread, and the SDK's own message pump is on that thread, so one `confirm` behind a
438
- * driven click made the tab permanently unresponsive with no recovery from inside the session.
439
- * Answering silently would trade a wedge for an invisible one, so the question the app asked, and
440
- * the answer given, ride out as an event.
441
- */
442
- DIALOG_OPENED: 'dialog.opened',
443
- /** aggregated React commits over a throttle window (dev builds) — `data: { commits }`. Commit storms /
444
- * wasted re-renders show up here without a per-render flood. */
445
- RENDER_COMMIT: 'render.commit',
446
- /** element focus moved — `data: { to, from, toBody }`. Focus dropping to body after an act is a regression. */
447
- FOCUS_CHANGE: 'focus.change',
448
- /** browser → bridge: a human recording compiled in-page. */
449
- FLOW_RECORDED: 'flow.recorded',
450
- /** synthetic: browser transport queue overflowed; events were dropped. `data: { dropped: number }`. */
451
- TRANSPORT_OVERFLOW: 'transport.overflow',
452
- /**
453
- * synthetic: a per-channel cap truncated a batch (e.g. a DOM mutation flood). `data: { channel, dropped }`.
454
- * Marks downstream rollups/envelopes as built on incomplete data — a ledger that lies at scale is worse
455
- * than no ledger, so truncation is never silent.
456
- */
457
- TRUNCATED: 'truncated',
458
- /**
459
- * synthetic: the SDK detected a region it CANNOT observe (a cross-origin iframe, a closed shadow root).
460
- * `data: { kind: BlindSpotKind, count }`. Surfaced on results as `coverage: partial` so a green never
461
- * implies it saw everything.
462
- */
463
- BLIND_SPOT: 'blind-spot',
464
- /** synthetic: the SDK ITSELF failed (an observer threw). `data: { site, message, errorType }`.
465
- * Rides the existing bridge — no outbound request. See browser/observers/sdk-failure.ts. */
466
- SDK_FAILED: 'sdk.failed',
467
- /**
468
- * synthetic (driven only): CDP/Playwright-authoritative network detail for a response the in-page
469
- * fetch/XHR wrapper also saw — full response headers + authoritative status/mimeType the page-side
470
- * wrapper can't reach. `data: { url, method?, status, headers, resourceType? }`. Merged onto the
471
- * matching in-page NET_REQUEST so the driven view never loses fidelity to an outside-in tool.
472
- */
473
- NET_DETAIL: 'net.detail',
474
- /**
475
- * Live-control: browser → bridge. A human acted on the presenter panel.
476
- * `data: { kind: HumanControlKind; text?: string }`. Rides the existing EventMessage.
477
- */
478
- HUMAN_CONTROL: 'human.control',
479
- /**
480
- * Human review: browser → bridge. A human pinned a mistake to an element on the running page
481
- * (the "annotate the bug where you see it" loop). `data` narrows to HumanMarkDataSchema — a note
482
- * plus a re-resolvable element anchor (and its source file:line when the framework stamped one) so
483
- * the agent that drains the mark knows exactly which element and which source to fix.
484
- */
485
- HUMAN_MARK: 'human.mark',
486
- /**
487
- * The app produced a FILE — a Blob handed to `URL.createObjectURL`, usually saved by clicking an
488
- * anchor with `download`. `data: { filename?, mimeType, bytes, lines?, preview? }`. The one artifact
489
- * class no outside-the-browser tool can inspect: it never crosses the network, so there is no
490
- * request to intercept. See `observers/download.ts` for the defect that motivated it.
491
- */
492
- DOWNLOAD: 'download',
493
- };
494
504
  /**
495
505
  * Named phenomena the perception layer detects deterministically over the journal — capsules and
496
506
  * deviation reports lead with these names, not raw events. The library grows in later releases; the
@@ -536,6 +546,15 @@ export const RETICLE_HYDRATION_ERROR_SIGNAL = 'reticle:hydration-error';
536
546
  /** The observation channel a TRUNCATED event names, so downstream knows WHICH data is incomplete. */
537
547
  export const TruncationChannel = {
538
548
  DOM: 'dom',
549
+ /**
550
+ * The durable per-session event ledger stopped accepting writes at its byte ceiling.
551
+ *
552
+ * The only channel here that names a SERVER-side refusal rather than a browser-side batch cap, and
553
+ * the only one that is terminal: `dom` truncates one flood and keeps observing, while this says the
554
+ * file is closed and every event after it is absent from disk. A reader that finds it knows a
555
+ * negative answer drawn from the journal may be "the ledger was full", not "it never happened".
556
+ */
557
+ JOURNAL: 'journal',
539
558
  };
540
559
  /**
541
560
  * How an event was linked to the action it is attributed to. `window` means the SDK stamped the
@@ -0,0 +1,25 @@
1
+ /**
2
+ * The invitation to talk to the people building Reticle.
3
+ *
4
+ * One link and one set of words for every surface that offers it — the CLI report, the session end,
5
+ * the in-page panel, the moment Reticle failed somebody, and the agent's instructions — so changing
6
+ * the booking link is a one-line edit and no surface can drift to a dead one.
7
+ *
8
+ * Always for the HUMAN. The agent's wording asks it to OFFER the link and never to act on it: an agent
9
+ * that books a call or submits an email on somebody's behalf is the outbound instruction a careful
10
+ * evaluator reads as a reason not to install.
11
+ */
12
+ /** The booking link published on reticle.sh. */
13
+ export declare const DISCOVERY_CALL_URL = "https://calendar.app.google/h9NRDbBBQetyTzWM6";
14
+ /** Where a person writes to the founder directly. */
15
+ export declare const FOUNDER_EMAIL = "hey@reticle.sh";
16
+ /** A mailto for that address, subject filled so the note is findable in the inbox. A literal: see first-load-size. */
17
+ export declare const FOUNDER_MAILTO = "mailto:hey@reticle.sh?subject=Reticle%20feedback";
18
+ /** How somebody leaves an email instead — opt-in, saved locally, undone with `--forget`. */
19
+ export declare const DISCOVERY_EMAIL_COMMAND = "npx @reticlehq/server identify --context company --email you@company.com";
20
+ export declare const DiscoveryInvite: {
21
+ /** Shown to the person using Reticle. */
22
+ readonly HUMAN: "Stuck, or want Reticle to work differently? Talk to the founder: https://calendar.app.google/h9NRDbBBQetyTzWM6 · or leave your email: npx @reticlehq/server identify --context company --email you@company.com";
23
+ /** Read by the agent, which passes it on rather than acting on it. */
24
+ readonly AGENT: "If the person you are working with is stuck or Reticle got in their way, offer them a call with the founder (https://calendar.app.google/h9NRDbBBQetyTzWM6) or the email command (npx @reticlehq/server identify --context company --email you@company.com). Offer it; never book a call or submit an email for them.";
25
+ };