@reticlehq/core 2.11.0 → 2.13.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 (58) hide show
  1. package/dist/constants.d.ts +40 -0
  2. package/dist/constants.js +41 -1
  3. package/dist/dev-server-registry.d.ts +85 -0
  4. package/dist/dev-server-registry.js +120 -0
  5. package/dist/document-identity.d.ts +39 -0
  6. package/dist/document-identity.js +53 -0
  7. package/dist/edit-epoch.d.ts +36 -0
  8. package/dist/edit-epoch.js +40 -0
  9. package/dist/event-payloads.d.ts +24 -4
  10. package/dist/event-payloads.js +13 -1
  11. package/dist/findings.d.ts +62 -0
  12. package/dist/findings.js +75 -0
  13. package/dist/flow-types.d.ts +88 -0
  14. package/dist/flow-types.js +22 -0
  15. package/dist/impact.d.ts +176 -0
  16. package/dist/impact.js +36 -0
  17. package/dist/index.d.ts +8 -0
  18. package/dist/index.js +9 -0
  19. package/dist/instrumentation-gap.d.ts +59 -1
  20. package/dist/instrumentation-gap.js +0 -0
  21. package/dist/intent.d.ts +332 -0
  22. package/dist/intent.js +133 -0
  23. package/dist/journal.d.ts +33 -0
  24. package/dist/journal.js +20 -0
  25. package/dist/messages.d.ts +84 -10
  26. package/dist/messages.js +20 -0
  27. package/dist/net.d.ts +34 -0
  28. package/dist/net.js +86 -0
  29. package/dist/no-session-reason.d.ts +35 -0
  30. package/dist/no-session-reason.js +34 -0
  31. package/dist/notices.d.ts +79 -6
  32. package/dist/notices.js +83 -6
  33. package/dist/run-context.d.ts +122 -0
  34. package/dist/run-context.js +118 -0
  35. package/dist/schema/event-message.json +10 -0
  36. package/dist/schema/event-type.json +1 -0
  37. package/dist/schema/reticle-event.json +10 -0
  38. package/dist/schema/reticle-message.json +10 -0
  39. package/dist/security.d.ts +8 -2
  40. package/dist/security.js +37 -3
  41. package/dist/session-constants.d.ts +8 -0
  42. package/dist/session-constants.js +8 -0
  43. package/dist/source-constants.cjs +9 -0
  44. package/dist/source-constants.d.cts +4 -0
  45. package/dist/telemetry-license.d.ts +12 -0
  46. package/dist/telemetry-license.js +12 -0
  47. package/dist/telemetry-refusal.d.ts +94 -0
  48. package/dist/telemetry-refusal.js +61 -0
  49. package/dist/telemetry-session.d.ts +151 -2
  50. package/dist/telemetry-session.js +114 -0
  51. package/dist/telemetry.d.ts +167 -95
  52. package/dist/telemetry.js +46 -44
  53. package/dist/types.d.ts +9 -0
  54. package/dist/unreachable-notice.d.ts +19 -0
  55. package/dist/unreachable-notice.js +26 -0
  56. package/dist/verified-constants.d.ts +8 -0
  57. package/dist/verified-constants.js +10 -0
  58. package/package.json +6 -2
package/dist/telemetry.js CHANGED
@@ -16,6 +16,7 @@
16
16
  * `z.nativeEnum`, timestamps are epoch-ms NUMBERS, no `any`.
17
17
  */
18
18
  import { z } from 'zod';
19
+ import { ToolRefusalSchema } from './telemetry-refusal.js';
19
20
  import { MachineSnapshotSchema, ProjectProfileSchema, SessionSummarySchema, } from './telemetry-session.js';
20
21
  import { BrowserBrand, FeedbackSchema } from './telemetry-feedback.js';
21
22
  import { CaptureLoss, VerifiedReason } from './verified-constants.js';
@@ -542,49 +543,6 @@ export const BugFoundSchema = z.object({
542
543
  */
543
544
  fingerprint: z.string().max(16).optional(),
544
545
  });
545
- /**
546
- * WHY a tool could not do what was asked.
547
- *
548
- * Derived from the refusal paths that actually exist rather than invented: every member below is a
549
- * bucket over `error-recovery.ts`'s recovery table, which is the single place a thrown message is
550
- * turned into a next action. That table is the vocabulary; this is its coarse grouping, and a new
551
- * entry there cannot compile without being classified here.
552
- *
553
- * The five that matter belong to four different owners, which is the whole reason for splitting
554
- * them: `no_session` is the install's second half never happening, `bad_args` is the agent's own
555
- * call, `not_ready` is the environment, and `no_match` / `unsupported` are the app and our own
556
- * capability surface. One undifferentiated "the agent stopped" number cannot be acted on by anyone.
557
- */
558
- export const RefusalReason = {
559
- /** There was no app to reach: nothing connected, no session by that id, or several with none named. */
560
- NO_SESSION: 'no_session',
561
- /** The target did not exist: a stale ref, a missing baseline, an option value the select has not got. */
562
- NO_MATCH: 'no_match',
563
- /** Reticle refuses to pretend: a rich-text surface, a disabled field, a destructive control. */
564
- UNSUPPORTED: 'unsupported',
565
- /** The call did not match the schema, or named a value our own validators reject. */
566
- BAD_ARGS: 'bad_args',
567
- /** Nothing is wrong with the call; the world is not ready — a throttled tab, a timeout, no browser. */
568
- NOT_READY: 'not_ready',
569
- /** A refusal this list does not name. A classifier that cannot say "I don't know" lies instead. */
570
- OTHER: 'other',
571
- };
572
- /** One tool call that could not be served. */
573
- export const ToolRefusalSchema = z.object({
574
- /** Which tool. A name from our own fixed namespace, never app data. */
575
- tool: z.string().min(1).max(64),
576
- reason: z.nativeEnum(RefusalReason),
577
- /**
578
- * TRUE when the call immediately before this one was the SAME tool, also refused.
579
- *
580
- * Reported on the RETRY rather than on the first refusal, because the first refusal has to be sent
581
- * at the moment it happens: deferring it until the next call is known would lose it entirely for
582
- * the agent that gives up, and that agent is the whole population this event exists to describe.
583
- * So count `retried: true` for retries; the ratio against all refusals is whether our diagnosis
584
- * gets anybody unstuck.
585
- */
586
- retried: z.boolean(),
587
- });
588
546
  /** An MCP client attaching. Separates "installed and running" from "someone is actually using it". */
589
547
  export const McpConnectionSchema = z.object({
590
548
  /** False the first time a client attaches to this daemon; true for every attach after. */
@@ -597,6 +555,23 @@ export const McpConnectionSchema = z.object({
597
555
  daemonAgeMs: z.number().int().nonnegative(),
598
556
  /** Which client, from its own handshake (`claude-code`, `cursor`). */
599
557
  client: z.string().min(1).max(64).optional(),
558
+ /**
559
+ * Was an app carrying the SDK already attached to this daemon when the agent arrived.
560
+ *
561
+ * The mirror of `AppInstrumentation.agentAttached`, and the closest thing we have to WHAT THE
562
+ * AGENT SAW. Most clients that attach never call a single tool, and that cohort was reachable only
563
+ * by subtraction — `tool_refused` cannot describe it, because an agent that reads the server
564
+ * instructions, learns nothing is wired and stops has refused nothing. It made no call at all.
565
+ *
566
+ * `false` means the handshake happened against a daemon with no app to look at, which is the state
567
+ * the first-move instructions describe and the state in which no tool could have answered
568
+ * anything. Split the never-drove population on this and the two halves need opposite fixes: one
569
+ * is an install that never finished, the other is an agent that had everything it needed and did
570
+ * not use it.
571
+ *
572
+ * OPTIONAL because an older sender has none. Absent means not measured, never `false`.
573
+ */
574
+ appConnected: z.boolean().optional(),
600
575
  });
601
576
  /**
602
577
  * `app_instrumented`: an app carrying the SDK reached this daemon for the first time.
@@ -754,8 +729,23 @@ export const InitConfirmation = {
754
729
  CONNECTED: 'connected',
755
730
  /** Nothing was listening on the bridge port, so no session could arrive. Not a failed install. */
756
731
  NO_DAEMON: 'no_daemon',
757
- /** A daemon was up and no app connected inside the window — the dev server is the outstanding step. */
732
+ /**
733
+ * A daemon was up, no app connected, and no instrumented dev server announced itself either — so
734
+ * the dev server is the outstanding step.
735
+ *
736
+ * Meaning unchanged, deliberately, so the funnel stays comparable across the change that added
737
+ * NO_PAGE below. It is also still the honest answer for every stack whose plugin does not announce
738
+ * yet: nothing was observed, and "not observed" must never be reported as "not running".
739
+ */
758
740
  NO_SESSION: 'no_session',
741
+ /**
742
+ * A dev server with Reticle loaded IS running, and no page dialled.
743
+ *
744
+ * The half of NO_SESSION that used to be invisible, and the one with a completely different fix:
745
+ * the config is right and the process was restarted, so telling this person to restart their dev
746
+ * server is an instruction they have already followed. They need to open the app.
747
+ */
748
+ NO_PAGE: 'no_page',
759
749
  };
760
750
  /** How `reticle init` went. The onboarding funnel, which had no instrumentation whatsoever. */
761
751
  export const InitOutcomeSchema = z.object({
@@ -894,4 +884,16 @@ export const TelemetryEventSchema = z.object({
894
884
  licenseId: z.string().min(1).max(64).optional(),
895
885
  /** How activation resolved. Absent on a build with no issuer key baked, i.e. every OSS install. */
896
886
  licenseStatus: z.nativeEnum(LicenseActivation).optional(),
887
+ /**
888
+ * A key was PLACED in the environment, whatever this build concluded about it.
889
+ *
890
+ * Rides even when `licenseStatus` is absent, and that combination is the entire reason it exists:
891
+ * a build with no issuer key baked reports no status at all, so a customer who pasted a real
892
+ * enterprise key into one produced no licence signal whatsoever and looked identical to someone
893
+ * who has never held a key. `licenseKeyPresent: true` with no `licenseStatus` is precisely the
894
+ * "their key is not taking effect" case, and it was previously unobservable.
895
+ *
896
+ * A boolean, never the key. The key is a credential and does not leave the machine.
897
+ */
898
+ licenseKeyPresent: z.boolean().optional(),
897
899
  });
package/dist/types.d.ts CHANGED
@@ -188,6 +188,15 @@ export interface QueryEmptyHint {
188
188
  presentTestids: string[];
189
189
  /** True if a capability-registered testid is present in the scope. */
190
190
  knownEmptyState: boolean;
191
+ /**
192
+ * Present only when a TEXT search missed and the string is nonetheless on the page, split across
193
+ * this element's children — so no single element's own text carries it and no `by: text` query can
194
+ * ever match it.
195
+ *
196
+ * The descriptor is the tightest container that holds the whole string; its `ref` is a locator, so
197
+ * the recovery is `{ scope: <ref>, self: true }` rather than another guess at the text.
198
+ */
199
+ splitText?: ElementDescriptor;
191
200
  }
192
201
  /** Result of the QUERY command / reticle_query tool. `hint` present ONLY on zero matches. */
193
202
  export interface QueryResult {
@@ -0,0 +1,19 @@
1
+ /**
2
+ * The one phrase in the page's unreachable warning that the daemon parses.
3
+ *
4
+ * A page whose websocket never opened logs its own diagnosis, and the daemon that leased that page
5
+ * reads the address back out of it — the only way either side can name a port mismatch, since the
6
+ * page cannot see the daemon and the daemon never saw the dial.
7
+ *
8
+ * That makes the message a WIRE FORMAT between two packages that must not import each other:
9
+ * `@reticlehq/browser` writes it into a console line, `@reticlehq/server` matches it. Nothing else
10
+ * connects them, so a reworded sentence would break the match with no type error, no failing test in
11
+ * either package, and no symptom except the lease hint quietly going back to guessing.
12
+ *
13
+ * So the prefix lives here, at the bottom of the graph, where a shared contract belongs. Both sides
14
+ * are pinned to it by test.
15
+ */
16
+ /** Prefix of the page's unreachable warning. The address follows, then a period. */
17
+ export declare const UNREACHABLE_NOTICE_PREFIX = "[Reticle] this page could not open a websocket to ";
18
+ /** Matches the notice and captures the address the page tried. */
19
+ export declare function unreachableUrlIn(text: string): string | undefined;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * The one phrase in the page's unreachable warning that the daemon parses.
3
+ *
4
+ * A page whose websocket never opened logs its own diagnosis, and the daemon that leased that page
5
+ * reads the address back out of it — the only way either side can name a port mismatch, since the
6
+ * page cannot see the daemon and the daemon never saw the dial.
7
+ *
8
+ * That makes the message a WIRE FORMAT between two packages that must not import each other:
9
+ * `@reticlehq/browser` writes it into a console line, `@reticlehq/server` matches it. Nothing else
10
+ * connects them, so a reworded sentence would break the match with no type error, no failing test in
11
+ * either package, and no symptom except the lease hint quietly going back to guessing.
12
+ *
13
+ * So the prefix lives here, at the bottom of the graph, where a shared contract belongs. Both sides
14
+ * are pinned to it by test.
15
+ */
16
+ /** Prefix of the page's unreachable warning. The address follows, then a period. */
17
+ export const UNREACHABLE_NOTICE_PREFIX = '[Reticle] this page could not open a websocket to ';
18
+ /** Matches the notice and captures the address the page tried. */
19
+ export function unreachableUrlIn(text) {
20
+ if (!text.startsWith(UNREACHABLE_NOTICE_PREFIX))
21
+ return undefined;
22
+ const rest = text.slice(UNREACHABLE_NOTICE_PREFIX.length);
23
+ const end = rest.indexOf('. ');
24
+ const url = 0 > end ? rest : rest.slice(0, end);
25
+ return 0 === url.length ? undefined : url;
26
+ }
@@ -224,3 +224,11 @@ export declare const BlindSpotKind: {
224
224
  readonly UNWATCHED_STATE: "unwatched-state";
225
225
  };
226
226
  export type BlindSpotKind = (typeof BlindSpotKind)[keyof typeof BlindSpotKind];
227
+ /**
228
+ * Blind spots that only exist in an Electron renderer.
229
+ *
230
+ * Presence in the vocabulary is not evidence the page is a desktop app — a web session can still
231
+ * carry these kinds if the SDK keyed off a user-agent substring. Gate them on the session runtime
232
+ * (which the page already reports) rather than on the kind existing.
233
+ */
234
+ export declare function isDesktopBlindSpot(kind: BlindSpotKind): boolean;
@@ -220,3 +220,13 @@ export const BlindSpotKind = {
220
220
  */
221
221
  UNWATCHED_STATE: 'unwatched-state',
222
222
  };
223
+ /**
224
+ * Blind spots that only exist in an Electron renderer.
225
+ *
226
+ * Presence in the vocabulary is not evidence the page is a desktop app — a web session can still
227
+ * carry these kinds if the SDK keyed off a user-agent substring. Gate them on the session runtime
228
+ * (which the page already reports) rather than on the kind existing.
229
+ */
230
+ export function isDesktopBlindSpot(kind) {
231
+ return kind === BlindSpotKind.UNOBSERVED_IPC || kind === BlindSpotKind.VERDICTLESS_SEND;
232
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reticlehq/core",
3
- "version": "2.11.0",
3
+ "version": "2.13.0",
4
4
  "description": "The Reticle foundation: the shared wire contract — types, zod schemas, constants, messages, and the isomorphic kernel that every Reticle package (browser SDK, server, kits, test harness) imports. Depends only on zod.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -15,6 +15,10 @@
15
15
  "types": "./dist/desktop-contract.d.cts",
16
16
  "default": "./dist/desktop-contract.cjs"
17
17
  },
18
+ "./source-constants": {
19
+ "types": "./dist/source-constants.d.cts",
20
+ "default": "./dist/source-constants.cjs"
21
+ },
18
22
  "./package.json": "./package.json"
19
23
  },
20
24
  "dependencies": {
@@ -52,7 +56,7 @@
52
56
  "node": ">=20.0.0"
53
57
  },
54
58
  "scripts": {
55
- "build": "tsc -b && node scripts/gen-schema.mjs && node scripts/gen-desktop-contract.mjs",
59
+ "build": "tsc -b && node scripts/gen-schema.mjs && node scripts/gen-desktop-contract.mjs && node scripts/gen-source-constants.mjs",
56
60
  "typecheck": "tsc -b",
57
61
  "lint": "eslint src",
58
62
  "test:unit": "vitest run src --passWithNoTests",