@reticlehq/core 2.13.1 → 2.14.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 (54) hide show
  1. package/dist/artifacts-entry.d.ts +20 -0
  2. package/dist/artifacts-entry.js +20 -0
  3. package/dist/consequence.d.ts +8 -1
  4. package/dist/consequence.js +11 -2
  5. package/dist/constants.d.ts +33 -0
  6. package/dist/constants.js +32 -0
  7. package/dist/dev-server-registry.d.ts +2 -2
  8. package/dist/event-payloads.d.ts +167 -10
  9. package/dist/event-payloads.js +40 -0
  10. package/dist/findings.d.ts +61 -0
  11. package/dist/findings.js +67 -0
  12. package/dist/flow-constants.d.ts +8 -0
  13. package/dist/flow-constants.js +8 -0
  14. package/dist/flow-types.d.ts +371 -133
  15. package/dist/flow-types.js +55 -3
  16. package/dist/global-press.d.ts +30 -0
  17. package/dist/global-press.js +54 -0
  18. package/dist/impact-savings.d.ts +7 -3
  19. package/dist/impact-savings.js +27 -4
  20. package/dist/impact.d.ts +96 -44
  21. package/dist/impact.js +21 -0
  22. package/dist/index.d.ts +16 -2
  23. package/dist/index.js +16 -2
  24. package/dist/instrumentation-gap.d.ts +15 -0
  25. package/dist/instrumentation-gap.js +16 -0
  26. package/dist/intent.d.ts +24 -24
  27. package/dist/journal.d.ts +7 -7
  28. package/dist/messages.d.ts +107 -46
  29. package/dist/messages.js +25 -0
  30. package/dist/net.d.ts +40 -0
  31. package/dist/net.js +40 -0
  32. package/dist/notices.d.ts +16 -0
  33. package/dist/notices.js +19 -0
  34. package/dist/redaction.d.ts +30 -0
  35. package/dist/redaction.js +127 -2
  36. package/dist/schema/event-message.json +1 -0
  37. package/dist/schema/event-type.json +1 -0
  38. package/dist/schema/hello-message.json +6 -0
  39. package/dist/schema/reticle-event.json +1 -0
  40. package/dist/schema/reticle-message.json +7 -0
  41. package/dist/telemetry-entry.d.ts +15 -0
  42. package/dist/telemetry-entry.js +15 -0
  43. package/dist/telemetry-feedback.d.ts +2 -2
  44. package/dist/telemetry-session.d.ts +2 -2
  45. package/dist/telemetry.d.ts +52 -50
  46. package/dist/types.d.ts +83 -44
  47. package/dist/types.js +20 -1
  48. package/dist/upgrade.d.ts +2 -2
  49. package/dist/verification-run.d.ts +36 -36
  50. package/dist/verified-constants.d.ts +11 -0
  51. package/dist/verified-constants.js +11 -0
  52. package/dist/verify-progress.d.ts +133 -0
  53. package/dist/verify-progress.js +78 -0
  54. package/package.json +9 -1
@@ -46,8 +46,17 @@ export const FlowAnchorSchema = z.discriminatedUnion('kind', [
46
46
  name: z.string().optional(),
47
47
  }),
48
48
  ]);
49
- /** A post-condition a step asserts (compiled from a structured annotation; optional). */
50
- export const FlowExpectSchema = z.object({
49
+ /**
50
+ * A post-condition a step asserts (compiled from a structured annotation; optional).
51
+ *
52
+ * Strict, at every nesting level: an unrecognized key (a typo, or a predicate kind this schema
53
+ * doesn't model, e.g. `allOf`, or a typo'd `net`/`console`/`element`/`state` sub-field) must fail
54
+ * to parse instead of being silently dropped. A loose z.object() here would quietly discard the
55
+ * extra key and leave the step with a weaker (or empty) assertion than its author wrote — the
56
+ * flow then replays green against nothing, having proved no real regression.
57
+ */
58
+ export const FlowExpectSchema = z
59
+ .object({
51
60
  signal: z.string().optional(),
52
61
  /**
53
62
  * Optional payload shape an `assert-signal` annotation requires the signal
@@ -75,6 +84,7 @@ export const FlowExpectSchema = z.object({
75
84
  */
76
85
  count: z.number().int().nonnegative().optional(),
77
86
  })
87
+ .strict()
78
88
  .optional(),
79
89
  /**
80
90
  * Console golden end-condition: assert the action logged (or, with absent:true, did NOT log) a
@@ -87,6 +97,7 @@ export const FlowExpectSchema = z.object({
87
97
  level: z.string().optional(),
88
98
  absent: z.boolean().optional(),
89
99
  })
100
+ .strict()
90
101
  .optional(),
91
102
  element: z
92
103
  .object({
@@ -94,6 +105,35 @@ export const FlowExpectSchema = z.object({
94
105
  role: z.string().optional(),
95
106
  name: z.string().optional(),
96
107
  })
108
+ .strict()
109
+ .optional(),
110
+ /**
111
+ * Rendered text as an end-condition, using the shapes the assert surface already accepts.
112
+ *
113
+ * The gap this closes: an app with no testids, no `reticle.signal`, no registrable store and no
114
+ * network call on the interaction under test -- a discount price computed and rendered, a
115
+ * formatted total, a derived label -- could not produce an asserted flow AT ALL. Everything the
116
+ * vocabulary offered needed a channel that app does not have, so the only honest outcome was
117
+ * `assertion-free`, which is a permanent green (#811).
118
+ *
119
+ * Derived-DOM rendering is a large share of what actually breaks in a UI, and it was the share
120
+ * that could not be pinned.
121
+ *
122
+ * Classified PRESENCE, not consequence, and that is not a technicality: text is read from the
123
+ * DOM, so a locator healed to the wrong element can still satisfy it. It earns `presence-only`,
124
+ * which is a real grade above `assertion-free` and honestly below `signal`/`net`/`state`.
125
+ */
126
+ text: z
127
+ .object({
128
+ contains: z.string().min(1),
129
+ /** Narrow the search to a container, exactly as the `text` predicate's `scope` does. */
130
+ scope: z.string().optional(),
131
+ /** Assert the text is GONE — the regression check for a cleared error or a dismissed toast. */
132
+ absent: z.boolean().optional(),
133
+ /** Require the match to be visible, not merely present in the DOM. */
134
+ visible: z.boolean().optional(),
135
+ })
136
+ .strict()
97
137
  .optional(),
98
138
  /**
99
139
  * Assert a registered store's value — the source of truth no DOM/network read can reach. Compiles
@@ -113,8 +153,10 @@ export const FlowExpectSchema = z.object({
113
153
  */
114
154
  hold: z.boolean().optional(),
115
155
  })
156
+ .strict()
116
157
  .optional(),
117
- });
158
+ })
159
+ .strict();
118
160
  const baseFlowStep = z.object({
119
161
  tool: z.string(),
120
162
  anchor: FlowAnchorSchema,
@@ -122,6 +164,7 @@ const baseFlowStep = z.object({
122
164
  args: z.record(z.unknown()).optional(),
123
165
  expect: FlowExpectSchema.optional(),
124
166
  degraded: z.boolean().optional(),
167
+ timeoutMs: z.number().int().positive().optional(),
125
168
  });
126
169
  export const FlowStepSchema = baseFlowStep.extend({
127
170
  steps: z.lazy(() => z.array(FlowStepSchema).optional()),
@@ -177,6 +220,15 @@ export const FlowFileSchema = z.object({
177
220
  /** From the injected clock (ms) — deterministic in tests, byte-stable on disk. */
178
221
  createdAt: z.number(),
179
222
  steps: z.array(FlowStepSchema),
223
+ /**
224
+ * How long every step of this flow waits for its declared consequence, in ms. A step's own
225
+ * `timeoutMs` wins over it; absent both, FLOW_SIGNAL_TIMEOUT_MS applies.
226
+ *
227
+ * Flow-level because slowness is usually a property of the APP, not of one control — a remote
228
+ * database, a model-backed endpoint, a cold container. Optional + back-compat: a flow without it
229
+ * replays exactly as before and the on-disk version stays FLOW_FILE_VERSION 1.
230
+ */
231
+ signalTimeoutMs: z.number().int().positive().optional(),
180
232
  success: FlowExpectSchema.optional(),
181
233
  /**
182
234
  * Anchors whose CONTENT must not be asserted (e.g. LLM output). Replay asserts
@@ -0,0 +1,30 @@
1
+ /**
2
+ * The key a `press` sends when neither `text` nor `key` was named.
3
+ *
4
+ * Enter is the historical default. It is also the one key that must NEVER be treated as a
5
+ * document key without a locator: on a focused field inside a form it submits it.
6
+ */
7
+ export declare const DEFAULT_PRESS_KEY = "Enter";
8
+ /**
9
+ * Keys a real user sends at the page, not at a control. Escape dismisses, Tab moves focus.
10
+ * A press of one of these with no ref is valid; a press of Enter or a letter is not.
11
+ */
12
+ export declare const GLOBAL_PRESS_KEYS: readonly ["Escape", "Tab"];
13
+ /**
14
+ * Which key a `press` is asking for.
15
+ *
16
+ * `text` FIRST, because that is what the tool description documents ("{ text } for type/press")
17
+ * and therefore what agents send. `key` still works — it is what anyone reading the source would
18
+ * have sent — and the default only applies when neither was named.
19
+ */
20
+ export declare function pressKeyFromArgs(args: Record<string, unknown>): string;
21
+ /**
22
+ * A press that is a document key, not an element action: Escape, Tab, or any key with modifiers
23
+ * (Cmd+K). Requiring a ref for these forced a snapshot just to name an element the keystroke is
24
+ * not about.
25
+ */
26
+ export declare function isGlobalPress(args: Record<string, unknown>): boolean;
27
+ /**
28
+ * The tool/step shape `{ action, args }` — a press of a document key, so no locator is required.
29
+ */
30
+ export declare function isGlobalPressCall(args: Record<string, unknown>): boolean;
@@ -0,0 +1,54 @@
1
+ import { ActionType } from './constants.js';
2
+ /**
3
+ * The key a `press` sends when neither `text` nor `key` was named.
4
+ *
5
+ * Enter is the historical default. It is also the one key that must NEVER be treated as a
6
+ * document key without a locator: on a focused field inside a form it submits it.
7
+ */
8
+ export const DEFAULT_PRESS_KEY = 'Enter';
9
+ /**
10
+ * Keys a real user sends at the page, not at a control. Escape dismisses, Tab moves focus.
11
+ * A press of one of these with no ref is valid; a press of Enter or a letter is not.
12
+ */
13
+ export const GLOBAL_PRESS_KEYS = ['Escape', 'Tab'];
14
+ const GLOBAL_PRESS_KEY_SET = new Set(GLOBAL_PRESS_KEYS.map((k) => k.toLowerCase()));
15
+ /**
16
+ * Which key a `press` is asking for.
17
+ *
18
+ * `text` FIRST, because that is what the tool description documents ("{ text } for type/press")
19
+ * and therefore what agents send. `key` still works — it is what anyone reading the source would
20
+ * have sent — and the default only applies when neither was named.
21
+ */
22
+ export function pressKeyFromArgs(args) {
23
+ const text = args['text'];
24
+ if ('string' === typeof text && 0 < text.length)
25
+ return text;
26
+ const key = args['key'];
27
+ if ('string' === typeof key && 0 < key.length)
28
+ return key;
29
+ return DEFAULT_PRESS_KEY;
30
+ }
31
+ function hasModifiers(args) {
32
+ const raw = args['modifiers'];
33
+ return Array.isArray(raw) && 0 < raw.length;
34
+ }
35
+ /**
36
+ * A press that is a document key, not an element action: Escape, Tab, or any key with modifiers
37
+ * (Cmd+K). Requiring a ref for these forced a snapshot just to name an element the keystroke is
38
+ * not about.
39
+ */
40
+ export function isGlobalPress(args) {
41
+ if (hasModifiers(args))
42
+ return true;
43
+ return GLOBAL_PRESS_KEY_SET.has(pressKeyFromArgs(args).toLowerCase());
44
+ }
45
+ /**
46
+ * The tool/step shape `{ action, args }` — a press of a document key, so no locator is required.
47
+ */
48
+ export function isGlobalPressCall(args) {
49
+ if (ActionType.PRESS !== args['action'])
50
+ return false;
51
+ const inner = args['args'];
52
+ const pressArgs = 'object' === typeof inner && null !== inner ? inner : {};
53
+ return isGlobalPress(pressArgs);
54
+ }
@@ -2,7 +2,7 @@ import type { ImpactCounts, ImpactSavings } from './impact.js';
2
2
  /** What the two numbers are measured against, shown beside them in the report. */
3
3
  export declare const IMPACT_BASIS: {
4
4
  readonly TOKENS: "vs an agent reading the app through screenshots";
5
- readonly MINUTES: "vs one re-prompt cycle per defect caught";
5
+ readonly MINUTES: "vs checking each consequence by hand, plus one re-prompt cycle per defect caught";
6
6
  };
7
7
  /**
8
8
  * Estimate what the recorded work saved.
@@ -11,7 +11,11 @@ export declare const IMPACT_BASIS: {
11
11
  * screenshot. The tokens Reticle actually returned are subtracted, so the figure is a NET saving
12
12
  * and can never exceed the modelled cost of the runs it replaced.
13
13
  *
14
- * Minutes: only DEFECTS count. A pass saves nothing by itself - the run was going to pass either
15
- * way; what a false green costs is the round trip, and that is what catching it returns.
14
+ * Minutes: two different counterfactuals, summed. EVERY verdict replaces a check somebody would
15
+ * otherwise have made by hand. A verdict that also caught a DEFECT saves the re-prompt round trip on
16
+ * top, because that is what a false green costs when it escapes.
17
+ *
18
+ * Decomposed rather than blended so the basis line can name both, and so changing the value of a
19
+ * pass never silently changes the value of a catch.
16
20
  */
17
21
  export declare function estimateImpactSavings(counts: ImpactCounts): ImpactSavings;
@@ -21,10 +21,27 @@ const TOKENS_PER_SCREENSHOT_LOOK = 1600;
21
21
  * short cycle, not the afternoon a shipped regression can take.
22
22
  */
23
23
  const MINUTES_PER_REPROMPT_CYCLE = 4;
24
+ /**
25
+ * Minutes a person spends confirming ONE consequence by hand: open the page, do the thing, look.
26
+ *
27
+ * This is the constant the model was missing, and its absence is why users reported spending more
28
+ * time in Reticle than it claimed to give back. The old reasoning was written down and was wrong -
29
+ * "a pass saves nothing by itself, the run was going to pass either way". The counterfactual is not
30
+ * "it passes anyway"; it is "somebody checks it by hand, or nobody checks it and a false green
31
+ * ships". A PROVEN pass replaces that check, and replacing it is the product.
32
+ *
33
+ * Counting only defects also inverted the incentive: the healthier the app, the less value Reticle
34
+ * appeared to deliver, when a healthy app being verified is the success case.
35
+ *
36
+ * Thirty seconds, and deliberately at the low end of what a manual check costs - a number nobody
37
+ * argues with is worth more than a flattering one. TUNE HERE: this is the single place the claim
38
+ * lives, and one line changes it everywhere.
39
+ */
40
+ const MINUTES_PER_MANUAL_CHECK = 0.5;
24
41
  /** What the two numbers are measured against, shown beside them in the report. */
25
42
  export const IMPACT_BASIS = {
26
43
  TOKENS: 'vs an agent reading the app through screenshots',
27
- MINUTES: 'vs one re-prompt cycle per defect caught',
44
+ MINUTES: 'vs checking each consequence by hand, plus one re-prompt cycle per defect caught',
28
45
  };
29
46
  /**
30
47
  * Estimate what the recorded work saved.
@@ -33,15 +50,21 @@ export const IMPACT_BASIS = {
33
50
  * screenshot. The tokens Reticle actually returned are subtracted, so the figure is a NET saving
34
51
  * and can never exceed the modelled cost of the runs it replaced.
35
52
  *
36
- * Minutes: only DEFECTS count. A pass saves nothing by itself - the run was going to pass either
37
- * way; what a false green costs is the round trip, and that is what catching it returns.
53
+ * Minutes: two different counterfactuals, summed. EVERY verdict replaces a check somebody would
54
+ * otherwise have made by hand. A verdict that also caught a DEFECT saves the re-prompt round trip on
55
+ * top, because that is what a false green costs when it escapes.
56
+ *
57
+ * Decomposed rather than blended so the basis line can name both, and so changing the value of a
58
+ * pass never silently changes the value of a catch.
38
59
  */
39
60
  export function estimateImpactSavings(counts) {
40
61
  const looksReplaced = counts.verdicts;
41
62
  const grossTokens = looksReplaced * TOKENS_PER_SCREENSHOT_LOOK;
42
63
  const netTokens = Math.max(0, grossTokens - counts.tokensReturned);
64
+ const checksReplaced = counts.verdicts * MINUTES_PER_MANUAL_CHECK;
65
+ const roundTripsAvoided = counts.failed * MINUTES_PER_REPROMPT_CYCLE;
43
66
  return {
44
67
  tokens: { value: netTokens, basis: IMPACT_BASIS.TOKENS },
45
- minutes: { value: counts.failed * MINUTES_PER_REPROMPT_CYCLE, basis: IMPACT_BASIS.MINUTES },
68
+ minutes: { value: checksReplaced + roundTripsAvoided, basis: IMPACT_BASIS.MINUTES },
46
69
  };
47
70
  }