@reticlehq/core 3.7.0 → 3.8.1

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 (138) hide show
  1. package/dist/activation-entry.d.ts +9 -0
  2. package/dist/activation-entry.js +9 -0
  3. package/dist/artifacts/drive-script.d.ts +84 -1217
  4. package/dist/artifacts/drive-script.js +1 -1
  5. package/dist/artifacts/flow-constants.d.ts +15 -0
  6. package/dist/artifacts/flow-constants.js +15 -0
  7. package/dist/artifacts/flow-expect-flat.d.ts +8 -192
  8. package/dist/artifacts/flow-expect-flat.js +2 -2
  9. package/dist/artifacts/flow-results.d.ts +26 -0
  10. package/dist/artifacts/flow-types.d.ts +212 -2295
  11. package/dist/artifacts/flow-types.js +14 -2
  12. package/dist/artifacts/harness-credits.d.ts +6 -3
  13. package/dist/artifacts/harness-credits.js +9 -6
  14. package/dist/artifacts/harness-map.d.ts +8 -69
  15. package/dist/artifacts/harness-map.js +1 -1
  16. package/dist/artifacts/hud-notices.d.ts +8 -82
  17. package/dist/artifacts/hud-notices.js +1 -1
  18. package/dist/artifacts/impact.d.ts +104 -1665
  19. package/dist/artifacts/impact.js +38 -21
  20. package/dist/artifacts/journal.d.ts +15 -231
  21. package/dist/artifacts/journal.js +15 -2
  22. package/dist/artifacts/prompt-context.d.ts +7 -33
  23. package/dist/artifacts/prompt-context.js +15 -4
  24. package/dist/artifacts/screenshot-upload.d.ts +3 -26
  25. package/dist/artifacts/screenshot-upload.js +1 -1
  26. package/dist/graph/app-graph.d.ts +137 -0
  27. package/dist/graph/app-graph.js +498 -0
  28. package/dist/hooks/hook-events.d.ts +15 -171
  29. package/dist/hooks/hook-events.js +1 -1
  30. package/dist/hud-entry.js +1 -1
  31. package/dist/identity/checkout.d.ts +41 -0
  32. package/dist/identity/checkout.js +118 -0
  33. package/dist/identity/state-dir.d.ts +23 -0
  34. package/dist/identity/state-dir.js +43 -0
  35. package/dist/index.d.ts +10 -0
  36. package/dist/index.js +10 -0
  37. package/dist/onboarding.d.ts +23 -52
  38. package/dist/onboarding.js +20 -1
  39. package/dist/registry/daemon-registry.d.ts +2 -14
  40. package/dist/registry/daemon-registry.js +1 -1
  41. package/dist/registry/dev-server-registry.d.ts +2 -31
  42. package/dist/registry/dev-server-registry.js +1 -1
  43. package/dist/registry/project-registry.d.ts +4 -32
  44. package/dist/registry/project-registry.js +1 -1
  45. package/dist/schema/command-message.json +65 -68
  46. package/dist/schema/command-name.json +29 -33
  47. package/dist/schema/command-result.json +25 -30
  48. package/dist/schema/event-message.json +104 -101
  49. package/dist/schema/event-payloads.json +246 -108
  50. package/dist/schema/event-type.json +47 -48
  51. package/dist/schema/hello-message.json +150 -133
  52. package/dist/schema/reticle-event.json +98 -94
  53. package/dist/schema/reticle-message.json +338 -310
  54. package/dist/telemetry-bug.d.ts +4 -75
  55. package/dist/telemetry-bug.js +1 -1
  56. package/dist/telemetry-entry.d.ts +1 -1
  57. package/dist/telemetry-entry.js +1 -1
  58. package/dist/telemetry-feedback.d.ts +17 -91
  59. package/dist/telemetry-feedback.js +20 -1
  60. package/dist/telemetry-refusal.d.ts +4 -31
  61. package/dist/telemetry-refusal.js +1 -1
  62. package/dist/telemetry-session.d.ts +45 -624
  63. package/dist/telemetry-session.js +25 -12
  64. package/dist/telemetry-signals.d.ts +211 -86
  65. package/dist/telemetry-signals.js +100 -2
  66. package/dist/telemetry.d.ts +321 -1691
  67. package/dist/telemetry.js +72 -6
  68. package/dist/verdict/check-sentence.d.ts +34 -0
  69. package/dist/verdict/check-sentence.js +228 -0
  70. package/dist/verdict/compare-source.d.ts +1 -1
  71. package/dist/verdict/compare-source.js +1 -1
  72. package/dist/verdict/consequence.d.ts +15 -0
  73. package/dist/verdict/consequence.js +11 -0
  74. package/dist/verdict/disparity.d.ts +8 -56
  75. package/dist/verdict/disparity.js +1 -1
  76. package/dist/verdict/findings.d.ts +10 -0
  77. package/dist/verdict/findings.js +13 -0
  78. package/dist/verdict/instrumentation-coverage.d.ts +6 -37
  79. package/dist/verdict/instrumentation-coverage.js +15 -59
  80. package/dist/verdict/instrumentation-gap.d.ts +72 -0
  81. package/dist/verdict/instrumentation-gap.js +64 -0
  82. package/dist/verdict/intent.d.ts +25 -224
  83. package/dist/verdict/intent.js +1 -1
  84. package/dist/verdict/predicate-tree.d.ts +2 -0
  85. package/dist/verdict/predicate-tree.js +16 -0
  86. package/dist/verdict/predicate.d.ts +3 -2
  87. package/dist/verdict/predicate.js +107 -16
  88. package/dist/verdict/property-assertion.d.ts +23 -101
  89. package/dist/verdict/property-assertion.js +1 -1
  90. package/dist/verdict/run-report.d.ts +71 -0
  91. package/dist/verdict/run-report.js +53 -0
  92. package/dist/verdict/security.d.ts +48 -2
  93. package/dist/verdict/security.js +185 -18
  94. package/dist/verdict/verification-run.d.ts +124 -1623
  95. package/dist/verdict/verification-run.js +37 -6
  96. package/dist/verdict/verify-progress.d.ts +22 -64
  97. package/dist/verdict/verify-progress.js +1 -1
  98. package/dist/wire/constants/constants.d.ts +56 -141
  99. package/dist/wire/constants/constants.js +64 -144
  100. package/dist/wire/constants/discovery.d.ts +4 -4
  101. package/dist/wire/constants/discovery.js +4 -4
  102. package/dist/wire/constants/event-types.d.ts +37 -1
  103. package/dist/wire/constants/event-types.js +35 -1
  104. package/dist/wire/constants/hud-controls.js +0 -2
  105. package/dist/wire/constants/hud-use.d.ts +4 -0
  106. package/dist/wire/constants/hud-use.js +4 -0
  107. package/dist/wire/constants/mcp-wire.d.ts +16 -0
  108. package/dist/wire/constants/mcp-wire.js +16 -0
  109. package/dist/wire/constants/response-body-reason.d.ts +19 -0
  110. package/dist/wire/constants/response-body-reason.js +18 -0
  111. package/dist/wire/constants/reticle-env.d.ts +140 -0
  112. package/dist/wire/constants/reticle-env.js +140 -0
  113. package/dist/wire/constants/session-constants.d.ts +11 -0
  114. package/dist/wire/constants/session-constants.js +11 -0
  115. package/dist/wire/event-payloads.d.ts +173 -629
  116. package/dist/wire/event-payloads.js +107 -23
  117. package/dist/wire/event-priority.js +1 -0
  118. package/dist/wire/messages.d.ts +90 -713
  119. package/dist/wire/messages.js +19 -3
  120. package/dist/wire/narrow.d.ts +6 -0
  121. package/dist/wire/narrow.js +26 -0
  122. package/dist/wire/next-step.d.ts +50 -0
  123. package/dist/wire/next-step.js +37 -0
  124. package/dist/wire/platform-link.d.ts +7 -0
  125. package/dist/wire/platform-link.js +14 -8
  126. package/dist/wire/production/activation-ticket.d.ts +64 -0
  127. package/dist/wire/production/activation-ticket.js +148 -0
  128. package/dist/wire/production/hello-mode.d.ts +35 -0
  129. package/dist/wire/production/hello-mode.js +32 -0
  130. package/dist/wire/production/production-policy.d.ts +92 -0
  131. package/dist/wire/production/production-policy.js +133 -0
  132. package/dist/wire/tool-names.d.ts +2 -0
  133. package/dist/wire/tool-names.js +2 -0
  134. package/dist/wire/types.d.ts +102 -700
  135. package/dist/wire/types.js +5 -5
  136. package/dist/words/upgrade.d.ts +3 -13
  137. package/dist/words/upgrade.js +1 -1
  138. package/package.json +7 -4
@@ -27,7 +27,13 @@
27
27
  * permission flag — and a guard that fires on a control it was never written to catch trains agents
28
28
  * to route around it, which generalises to the buttons that DO matter.
29
29
  */
30
- const DANGEROUS_ACTION = /\b(delete|remove|destroy|erase|drop|terminate|revoke|reset|close account|cancel subscription|purchase|buy|pay|payment|place order|confirm order|send money|send funds|transfer|withdraw|refund)\b/i;
30
+ const DESTROY_WORDS = 'delete|remove|destroy|erase|drop|terminate|revoke|reset|close account|cancel subscription';
31
+ const MONEY_WORDS = 'purchase|buy|pay|payment|place order|confirm order|send money|send funds|transfer|withdraw|refund';
32
+ const DANGEROUS_ACTION = new RegExp(`\\b(${DESTROY_WORDS}|${MONEY_WORDS})\\b`, 'i');
33
+ /** Only the words that destroy something. A link target is judged by these, not by money words. */
34
+ const DESTROY_ACTION = new RegExp(`\\b(${DESTROY_WORDS})\\b`, 'i');
35
+ /** Underscores and hyphens join words in names and paths: `delete_account`, `close-account`. */
36
+ const WORD_JOINERS = /[_-]+/g;
31
37
  /**
32
38
  * Roles that pick a VALUE, not perform an action. Selecting "Payment" as a document type is not a
33
39
  * payment, and choosing "Refund" from a reason group is not a refund -- the act those choices feed
@@ -47,25 +53,43 @@ const DANGEROUS_ACTION = /\b(delete|remove|destroy|erase|drop|terminate|revoke|r
47
53
  const VALUE_PICKER_ROLES = new Set(['option', 'radio']);
48
54
  /** The hostnames that ARE loopback outright, with no parsing: the name, and IPv6 ::1 both ways. */
49
55
  const LOOPBACK_HOSTNAMES = ['localhost', '::1', '0:0:0:0:0:0:0:1'];
56
+ /** The suffix of a name RFC 6761 reserves for loopback (`app.localhost`, `feat.app.localhost`). */
57
+ const LOCALHOST_SUFFIX = '.localhost';
50
58
  /** IPv4 loopback is the whole 127.0.0.0/8 block, so the first octet is the entire test. */
51
59
  const IPV4_LOOPBACK_FIRST_OCTET = '127';
52
60
  const IPV4_OCTET_COUNT = 4;
53
61
  const IPV4_OCTET_MAX = 255;
54
- /** True only for literal loopback hosts, never lookalike DNS names such as 127.example.com. */
62
+ /**
63
+ * True only for literal loopback hosts and `localhost`, never a lookalike DNS name such as
64
+ * 127.example.com. Names under `.localhost` are not included: this is the guard against DNS
65
+ * rebinding, and a browser that sends those names to DNS lets a hostile network answer them.
66
+ */
55
67
  export function isLoopbackHostname(hostname) {
56
68
  const normalized = hostname.toLowerCase().replace(/^\[|\]$/g, '');
57
- if (LOOPBACK_HOSTNAMES.includes(normalized))
69
+ if (LOOPBACK_HOSTNAMES.includes(normalized)) {
58
70
  return true;
71
+ }
59
72
  const octets = normalized.split('.');
60
73
  return (IPV4_OCTET_COUNT === octets.length &&
61
74
  IPV4_LOOPBACK_FIRST_OCTET === octets[0] &&
62
75
  octets.every((octet) => {
63
- if (!/^\d{1,3}$/.test(octet))
76
+ if (!/^\d{1,3}$/.test(octet)) {
64
77
  return false;
78
+ }
65
79
  const value = Number(octet);
66
80
  return value >= 0 && value <= IPV4_OCTET_MAX;
67
81
  }));
68
82
  }
83
+ /**
84
+ * True for a name under `.localhost`, such as the `<branch>.<app>.localhost` a dev proxy serves for
85
+ * each git worktree. RFC 6761 reserves these names for loopback, and browsers resolve them locally.
86
+ */
87
+ export function isLocalhostSubdomain(hostname) {
88
+ const normalized = hostname.toLowerCase();
89
+ return (normalized.endsWith(LOCALHOST_SUFFIX) &&
90
+ normalized.length > LOCALHOST_SUFFIX.length &&
91
+ !normalized.startsWith('.'));
92
+ }
69
93
  /**
70
94
  * Page protocols that mean "this document IS a local desktop app", not a website. A packaged
71
95
  * Electron renderer loads over `file:` (or a registered `app:` protocol); a Tauri webview loads over
@@ -73,11 +97,6 @@ export function isLoopbackHostname(hostname) {
73
97
  * origin to serve them from — so a page on one is as local as `http://localhost`.
74
98
  */
75
99
  const LOCAL_APP_PROTOCOLS = ['file:', 'app:', 'tauri:'];
76
- /**
77
- * The hostname Tauri v2 uses on Windows (and Android), where the webview needs a real http origin.
78
- * `.localhost` is reserved for loopback by RFC 6761, so this can never resolve to a remote host.
79
- */
80
- const TAURI_HTTP_HOSTNAME = 'tauri.localhost';
81
100
  /**
82
101
  * True when the page is local: an ordinary loopback document, or a desktop webview.
83
102
  *
@@ -86,11 +105,11 @@ const TAURI_HTTP_HOSTNAME = 'tauri.localhost';
86
105
  * remote is what made Reticle refuse to start inside a packaged Electron or Tauri app.
87
106
  */
88
107
  export function isLocalPage(protocol, hostname) {
89
- if (isLoopbackHostname(hostname))
108
+ // `isLocalhostSubdomain` also covers `tauri.localhost`, the http origin Tauri v2 uses on Windows.
109
+ if (isLoopbackHostname(hostname) || isLocalhostSubdomain(hostname)) {
90
110
  return true;
91
- if (LOCAL_APP_PROTOCOLS.includes(protocol.toLowerCase()))
92
- return true;
93
- return hostname.toLowerCase() === TAURI_HTTP_HOSTNAME;
111
+ }
112
+ return LOCAL_APP_PROTOCOLS.includes(protocol.toLowerCase());
94
113
  }
95
114
  /**
96
115
  * What `URL.origin` yields for a scheme that has no tuple origin — and what a browser puts in the
@@ -111,6 +130,86 @@ export function isOpaqueOrigin(origin) {
111
130
  return true;
112
131
  }
113
132
  }
133
+ /** The extensions a filename token can end in, as a set for the scan below. */
134
+ const FILENAME_EXTENSIONS = new Set([
135
+ 'webm',
136
+ 'mp4',
137
+ 'mov',
138
+ 'mkv',
139
+ 'avi',
140
+ 'mp3',
141
+ 'wav',
142
+ 'ogg',
143
+ 'flac',
144
+ 'png',
145
+ 'jpg',
146
+ 'jpeg',
147
+ 'gif',
148
+ 'webp',
149
+ 'svg',
150
+ 'avif',
151
+ 'bmp',
152
+ 'pdf',
153
+ 'zip',
154
+ 'tar',
155
+ 'gz',
156
+ 'txt',
157
+ 'csv',
158
+ 'json',
159
+ 'xml',
160
+ 'doc',
161
+ 'docx',
162
+ 'xls',
163
+ 'xlsx',
164
+ 'ppt',
165
+ 'pptx',
166
+ ]);
167
+ /** One maximal run of filename characters in a label: a token, or a token with a tail. */
168
+ const FILENAME_RUN = /[\w.-]+/g;
169
+ /** One character of a file extension. Extensions are letters and digits: `mp4`, `mp3`. */
170
+ const EXTENSION_CHARACTER = /[a-zA-Z0-9]/;
171
+ /**
172
+ * The end of the filename token at the start of `run`, or 0 when the run starts with no
173
+ * filename token. Try the last dot first, the way a greedy match does: the longest name
174
+ * part that still ends in a known extension wins. The extension must end at a word
175
+ * boundary: the end of the run, a dot, or a hyphen. So `report.pdf.backup` starts with
176
+ * the token `report.pdf`, and its tail stays in the text.
177
+ */
178
+ function filenameTokenEnd(run) {
179
+ for (let dot = run.lastIndexOf('.'); 1 <= dot; dot = run.lastIndexOf('.', dot - 1)) {
180
+ let end = dot + 1;
181
+ let extension = '';
182
+ while (end < run.length && EXTENSION_CHARACTER.test(run.charAt(end))) {
183
+ extension += run.charAt(end).toLowerCase();
184
+ end += 1;
185
+ }
186
+ if (!FILENAME_EXTENSIONS.has(extension)) {
187
+ continue;
188
+ }
189
+ const after = run.charAt(end);
190
+ if ('' === after || '.' === after || '-' === after) {
191
+ return end;
192
+ }
193
+ }
194
+ return 0;
195
+ }
196
+ /**
197
+ * Strip filename-like tokens from text before the text is classified.
198
+ * Callers apply this to a control's name, text and value only: an href or a form action is a
199
+ * target, not words on the control, and its destination must be read whole.
200
+ *
201
+ * The scan walks each maximal run of filename characters once and checks that run's dots
202
+ * once, so a label costs time in proportion to its length. The one-pattern version this
203
+ * replaces took about 97 seconds on a 100,000 hyphen label in a local check; the scan
204
+ * takes milliseconds on the same label, and a fuzz comparison over 20,000 generated
205
+ * labels found no difference in what it strips.
206
+ */
207
+ export function withoutFilenameTokens(text) {
208
+ return text.replace(FILENAME_RUN, (run) => {
209
+ const end = filenameTokenEnd(run);
210
+ return 0 === end ? run : ` ${run.slice(end)}`;
211
+ });
212
+ }
114
213
  /**
115
214
  * Best-effort classifier for labels and tool names that can trigger irreversible effects.
116
215
  *
@@ -119,9 +218,24 @@ export function isOpaqueOrigin(origin) {
119
218
  * role (a tool name, a click with no role on the descriptor) omit it and the text decides.
120
219
  */
121
220
  export function isDangerousActionText(text, role) {
122
- if (role !== undefined && VALUE_PICKER_ROLES.has(role.trim().toLowerCase()))
221
+ if (role !== undefined && VALUE_PICKER_ROLES.has(role.trim().toLowerCase())) {
123
222
  return false;
124
- return DANGEROUS_ACTION.test(text.replace(/[_-]+/g, ' '));
223
+ }
224
+ return DANGEROUS_ACTION.test(text.replace(WORD_JOINERS, ' '));
225
+ }
226
+ /**
227
+ * Is following a link to this href destructive? A link that navigates is a GET: opening a page moves
228
+ * no money, so a money word in a same-app path (`/billing/payment`) is not a reason to refuse it.
229
+ * Typing card details has its own guard. The href is dangerous when its path destroys something
230
+ * (`/account/delete`), or when it goes to a payment provider.
231
+ */
232
+ /** An href that goes nowhere (`#…`, `javascript:`): the link is a button, judged by its words. */
233
+ const INERT_HREF = /^\s*(#.*|javascript:.*)?$/i;
234
+ export function isInertHref(href) {
235
+ return INERT_HREF.test(href);
236
+ }
237
+ export function isDangerousNavigation(href) {
238
+ return isPaymentProviderUrl(href) || DESTROY_ACTION.test(href.replace(WORD_JOINERS, ' '));
125
239
  }
126
240
  // ── What the Harness may press ────────────────────────────────────────────────────────────────
127
241
  /*
@@ -174,12 +288,65 @@ const OUTWARD_WORDS = [
174
288
  /\b(?:reassign|reassigns|reopen|reopens|re-open|archive|archives|unarchive|approve|approves|reject|rejects|mark as (?:fixed|resolved|done|closed))\b/i,
175
289
  ],
176
290
  ];
177
- /** The outward action a control would take, from its text and role; value pickers take none. */
291
+ /*
292
+ * The payment boundary. "Start free trial" was refused as "would need to pay" on 3 of 4 explores:
293
+ * the words on a button (trial, upgrade, subscribe, checkout) say nothing about whether money moves
294
+ * on an app under test. Money moves when somebody types card or bank details, or leaves for a payment
295
+ * provider, so those are the two things a Harness drive that was not asked to pay refuses.
296
+ */
297
+ /** The origins of the payment providers an app sends a buyer to. A host or any subdomain of it. */
298
+ export const PAYMENT_PROVIDER_HOSTS = [
299
+ 'stripe.com',
300
+ 'checkout.dodopayments.com',
301
+ 'paddle.com',
302
+ 'lemonsqueezy.com',
303
+ 'paypal.com',
304
+ 'razorpay.com',
305
+ 'braintreegateway.com',
306
+ ];
307
+ /** Is this an absolute URL on a payment provider's origin? A relative URL stays on the app. */
308
+ export function isPaymentProviderUrl(url) {
309
+ let host;
310
+ try {
311
+ host = new URL(url).hostname.toLowerCase();
312
+ }
313
+ catch {
314
+ return false;
315
+ }
316
+ return PAYMENT_PROVIDER_HOSTS.some((h) => host === h || host.endsWith(`.${h}`));
317
+ }
318
+ /** The autocomplete tokens of a card: number, security code, expiry. */
319
+ const CARD_AUTOCOMPLETE = /\bcc-(?:number|csc|exp(?:-month|-year)?)\b/i;
320
+ /** A card or bank field by its name, id or label. */
321
+ const PAYMENT_FIELD_WORDS = /card ?(?:number|no\b)|\bcc ?num|\b(?:cvc|cvv|csc|cvc2|cvv2)\b|security code|card ?code|\bexpir(?:y|ation|es)\b|\bexp ?date\b|\bmm ?\/ ?yy\b|\biban\b|account ?number|routing ?number|sort ?code/i;
322
+ /**
323
+ * Is this a field for card or bank details? `inputMode` alone decides nothing (a quantity is numeric
324
+ * too); it travels in the facts so a numeric field named "cvv" still reads as one.
325
+ */
326
+ export function isPaymentField(facts) {
327
+ if (CARD_AUTOCOMPLETE.test(facts.autocomplete ?? '')) {
328
+ return true;
329
+ }
330
+ const words = [facts.name, facts.id, facts.label]
331
+ .map((w) => (w ?? '').replace(/([a-z])([A-Z])/g, '$1 $2').replace(/[_-]+/g, ' '))
332
+ .join(' ');
333
+ return PAYMENT_FIELD_WORDS.test(words);
334
+ }
335
+ /**
336
+ * The outward action a control would take, from its text and role; value pickers take none.
337
+ *
338
+ * Paying is never read from a control's words, only from where it goes: a link or form in `text`
339
+ * that points at a payment provider. `PAY` stays in the journey vocabulary, so "she pays" allows it.
340
+ */
178
341
  export function outwardActionOf(text, role) {
179
- if (role !== undefined && VALUE_PICKER_ROLES.has(role.trim().toLowerCase()))
342
+ if (role !== undefined && VALUE_PICKER_ROLES.has(role.trim().toLowerCase())) {
180
343
  return undefined;
344
+ }
345
+ if (text.split(/\s+/).some(isPaymentProviderUrl)) {
346
+ return OutwardAction.PAY;
347
+ }
181
348
  const words = text.replace(/[_-]+/g, ' ');
182
- return OUTWARD_WORDS.find(([, pattern]) => pattern.test(words))?.[0];
349
+ return OUTWARD_WORDS.find(([action, pattern]) => action !== OutwardAction.PAY && pattern.test(words))?.[0];
183
350
  }
184
351
  /** A word that turns the action after it into one the journey forbids: "does not send". */
185
352
  const NEGATION = /\b(?:not|no|never|without|nor|avoid|avoids|don't|doesn't|won't|didn't)\b/i;