@reticlehq/core 2.11.0 → 2.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/security.js CHANGED
@@ -15,7 +15,23 @@
15
15
  * charge somebody's card — so this narrows the trigger without lowering money coverage. Both
16
16
  * directions are pinned in security.test.ts.
17
17
  */
18
- const DANGEROUS_ACTION = /\b(delete|remove|destroy|erase|drop|terminate|revoke|reset|logout|log out|sign out|close account|cancel subscription|purchase|buy|pay|payment|place order|confirm order|deploy|publish|send money|send funds|transfer|withdraw|refund)\b/i;
18
+ /**
19
+ * Labels that read as irreversible: something is destroyed, or money moves.
20
+ *
21
+ * `deploy` and `publish` were here and are not. The guard's contract — written at the top of
22
+ * act-danger.ts — is "a money-moving or destructive control", and a deploy is neither: nothing is
23
+ * destroyed, nothing is paid, and the thing it produces did not exist before. Consequential is a
24
+ * wider net than this list is allowed to be, or half the buttons in a dev tool sit behind a
25
+ * permission flag.
26
+ *
27
+ * Removed on measurement, not taste. Three benchmark runs against an app with a "New deploy" button
28
+ * lost their ENTIRE turn budget to the refusal. Improving its wording did not rescue the last one:
29
+ * the agent spent its remaining turns weighing a bug report about the block and looking for a
30
+ * webmcp workaround. A guard that costs a whole run on a control it was never written to catch is
31
+ * not protecting anybody — it is training agents to route around it, which is worse than not having
32
+ * it, because the routing-around generalises to the buttons that DO matter.
33
+ */
34
+ const DANGEROUS_ACTION = /\b(delete|remove|destroy|erase|drop|terminate|revoke|reset|logout|log out|sign out|close account|cancel subscription|purchase|buy|pay|payment|place order|confirm order|send money|send funds|transfer|withdraw|refund)\b/i;
19
35
  /** The hostnames that ARE loopback outright, with no parsing: the name, and IPv6 ::1 both ways. */
20
36
  const LOOPBACK_HOSTNAMES = ['localhost', '::1', '0:0:0:0:0:0:0:1'];
21
37
  /** IPv4 loopback is the whole 127.0.0.0/8 block, so the first octet is the entire test. */
@@ -0,0 +1,9 @@
1
+ // GENERATED by scripts/gen-source-constants.mjs — do not edit.
2
+ //
3
+ // The CommonJS view of source-constants, for build tooling (@reticlehq/babel-plugin) that
4
+ // cannot import the ESM build. Edit src/source-constants.ts and rebuild @reticlehq/core.
5
+ 'use strict';
6
+ exports.DATA_RETICLE_SOURCE_ATTR = "data-reticle-source";
7
+ exports.RETICLE_ROOT_GLOBAL = "__RETICLE_ROOT__";
8
+ exports.RETICLE_SDK_VERSION_GLOBAL = "__RETICLE_SDK_VERSION__";
9
+ Object.freeze(exports);
@@ -0,0 +1,4 @@
1
+ // GENERATED by scripts/gen-source-constants.mjs — do not edit.
2
+ export declare const DATA_RETICLE_SOURCE_ATTR: "data-reticle-source";
3
+ export declare const RETICLE_ROOT_GLOBAL: "__RETICLE_ROOT__";
4
+ export declare const RETICLE_SDK_VERSION_GLOBAL: "__RETICLE_SDK_VERSION__";
@@ -513,7 +513,7 @@ export declare const SessionSummarySchema: z.ZodObject<{
513
513
  clientVersions?: Record<string, string> | undefined;
514
514
  appConnects?: number | undefined;
515
515
  msToFirstApp?: number | undefined;
516
- endReason?: "never_used" | "explored" | "abandoned" | "verified" | "client_left" | undefined;
516
+ endReason?: "verified" | "never_used" | "explored" | "abandoned" | "client_left" | undefined;
517
517
  feedbackPrompted?: number | undefined;
518
518
  errorClasses?: Record<string, number> | undefined;
519
519
  errorsRecovered?: number | undefined;
@@ -574,7 +574,7 @@ export declare const SessionSummarySchema: z.ZodObject<{
574
574
  clientVersions?: Record<string, string> | undefined;
575
575
  appConnects?: number | undefined;
576
576
  msToFirstApp?: number | undefined;
577
- endReason?: "never_used" | "explored" | "abandoned" | "verified" | "client_left" | undefined;
577
+ endReason?: "verified" | "never_used" | "explored" | "abandoned" | "client_left" | undefined;
578
578
  feedbackPrompted?: number | undefined;
579
579
  errorClasses?: Record<string, number> | undefined;
580
580
  errorsRecovered?: number | undefined;
@@ -1508,7 +1508,7 @@ export declare const TelemetryEventSchema: z.ZodObject<{
1508
1508
  clientVersions?: Record<string, string> | undefined;
1509
1509
  appConnects?: number | undefined;
1510
1510
  msToFirstApp?: number | undefined;
1511
- endReason?: "never_used" | "explored" | "abandoned" | "verified" | "client_left" | undefined;
1511
+ endReason?: "verified" | "never_used" | "explored" | "abandoned" | "client_left" | undefined;
1512
1512
  feedbackPrompted?: number | undefined;
1513
1513
  errorClasses?: Record<string, number> | undefined;
1514
1514
  errorsRecovered?: number | undefined;
@@ -1569,7 +1569,7 @@ export declare const TelemetryEventSchema: z.ZodObject<{
1569
1569
  clientVersions?: Record<string, string> | undefined;
1570
1570
  appConnects?: number | undefined;
1571
1571
  msToFirstApp?: number | undefined;
1572
- endReason?: "never_used" | "explored" | "abandoned" | "verified" | "client_left" | undefined;
1572
+ endReason?: "verified" | "never_used" | "explored" | "abandoned" | "client_left" | undefined;
1573
1573
  feedbackPrompted?: number | undefined;
1574
1574
  errorClasses?: Record<string, number> | undefined;
1575
1575
  errorsRecovered?: number | undefined;
@@ -2358,7 +2358,7 @@ export declare const TelemetryEventSchema: z.ZodObject<{
2358
2358
  clientVersions?: Record<string, string> | undefined;
2359
2359
  appConnects?: number | undefined;
2360
2360
  msToFirstApp?: number | undefined;
2361
- endReason?: "never_used" | "explored" | "abandoned" | "verified" | "client_left" | undefined;
2361
+ endReason?: "verified" | "never_used" | "explored" | "abandoned" | "client_left" | undefined;
2362
2362
  feedbackPrompted?: number | undefined;
2363
2363
  errorClasses?: Record<string, number> | undefined;
2364
2364
  errorsRecovered?: number | undefined;
@@ -2559,7 +2559,7 @@ export declare const TelemetryEventSchema: z.ZodObject<{
2559
2559
  clientVersions?: Record<string, string> | undefined;
2560
2560
  appConnects?: number | undefined;
2561
2561
  msToFirstApp?: number | undefined;
2562
- endReason?: "never_used" | "explored" | "abandoned" | "verified" | "client_left" | undefined;
2562
+ endReason?: "verified" | "never_used" | "explored" | "abandoned" | "client_left" | undefined;
2563
2563
  feedbackPrompted?: number | undefined;
2564
2564
  errorClasses?: Record<string, number> | undefined;
2565
2565
  errorsRecovered?: number | undefined;
@@ -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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reticlehq/core",
3
- "version": "2.11.0",
3
+ "version": "2.12.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",