@monkeytestai/monkeytester 0.0.0-stage → 0.5.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 (109) hide show
  1. package/CHANGELOG.md +172 -0
  2. package/LICENSE +661 -0
  3. package/NOTICE +12 -0
  4. package/README.md +196 -2
  5. package/dist/cli.d.ts +43 -0
  6. package/dist/cli.d.ts.map +1 -0
  7. package/dist/cli.js +771 -0
  8. package/dist/cli.js.map +1 -0
  9. package/dist/diff/index.d.ts +78 -0
  10. package/dist/diff/index.d.ts.map +1 -0
  11. package/dist/diff/index.js +119 -0
  12. package/dist/diff/index.js.map +1 -0
  13. package/dist/events.d.ts +66 -0
  14. package/dist/events.d.ts.map +1 -0
  15. package/dist/events.js +77 -0
  16. package/dist/events.js.map +1 -0
  17. package/dist/explorer/index.d.ts +54 -0
  18. package/dist/explorer/index.d.ts.map +1 -0
  19. package/dist/explorer/index.js +491 -0
  20. package/dist/explorer/index.js.map +1 -0
  21. package/dist/explorer/queue.d.ts +94 -0
  22. package/dist/explorer/queue.d.ts.map +1 -0
  23. package/dist/explorer/queue.js +277 -0
  24. package/dist/explorer/queue.js.map +1 -0
  25. package/dist/index.d.ts +36 -0
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +22 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/llm/index.d.ts +79 -0
  30. package/dist/llm/index.d.ts.map +1 -0
  31. package/dist/llm/index.js +392 -0
  32. package/dist/llm/index.js.map +1 -0
  33. package/dist/llm/presets.d.ts +61 -0
  34. package/dist/llm/presets.d.ts.map +1 -0
  35. package/dist/llm/presets.js +101 -0
  36. package/dist/llm/presets.js.map +1 -0
  37. package/dist/monkey.d.ts +151 -0
  38. package/dist/monkey.d.ts.map +1 -0
  39. package/dist/monkey.js +323 -0
  40. package/dist/monkey.js.map +1 -0
  41. package/dist/persistence/index.d.ts +118 -0
  42. package/dist/persistence/index.d.ts.map +1 -0
  43. package/dist/persistence/index.js +196 -0
  44. package/dist/persistence/index.js.map +1 -0
  45. package/dist/planner/faults.d.ts +24 -0
  46. package/dist/planner/faults.d.ts.map +1 -0
  47. package/dist/planner/faults.js +128 -0
  48. package/dist/planner/faults.js.map +1 -0
  49. package/dist/planner/forms.d.ts +33 -0
  50. package/dist/planner/forms.d.ts.map +1 -0
  51. package/dist/planner/forms.js +163 -0
  52. package/dist/planner/forms.js.map +1 -0
  53. package/dist/planner/index.d.ts +31 -0
  54. package/dist/planner/index.d.ts.map +1 -0
  55. package/dist/planner/index.js +250 -0
  56. package/dist/planner/index.js.map +1 -0
  57. package/dist/planner/salvage.d.ts +16 -0
  58. package/dist/planner/salvage.d.ts.map +1 -0
  59. package/dist/planner/salvage.js +89 -0
  60. package/dist/planner/salvage.js.map +1 -0
  61. package/dist/runner/actions.d.ts +85 -0
  62. package/dist/runner/actions.d.ts.map +1 -0
  63. package/dist/runner/actions.js +610 -0
  64. package/dist/runner/actions.js.map +1 -0
  65. package/dist/runner/evidence.d.ts +37 -0
  66. package/dist/runner/evidence.d.ts.map +1 -0
  67. package/dist/runner/evidence.js +122 -0
  68. package/dist/runner/evidence.js.map +1 -0
  69. package/dist/runner/http5xx.d.ts +40 -0
  70. package/dist/runner/http5xx.d.ts.map +1 -0
  71. package/dist/runner/http5xx.js +189 -0
  72. package/dist/runner/http5xx.js.map +1 -0
  73. package/dist/runner/index.d.ts +88 -0
  74. package/dist/runner/index.d.ts.map +1 -0
  75. package/dist/runner/index.js +597 -0
  76. package/dist/runner/index.js.map +1 -0
  77. package/dist/runner/replay.d.ts +42 -0
  78. package/dist/runner/replay.d.ts.map +1 -0
  79. package/dist/runner/replay.js +440 -0
  80. package/dist/runner/replay.js.map +1 -0
  81. package/dist/runner/timeout.d.ts +16 -0
  82. package/dist/runner/timeout.d.ts.map +1 -0
  83. package/dist/runner/timeout.js +38 -0
  84. package/dist/runner/timeout.js.map +1 -0
  85. package/dist/trace/fingerprint.d.ts +78 -0
  86. package/dist/trace/fingerprint.d.ts.map +1 -0
  87. package/dist/trace/fingerprint.js +273 -0
  88. package/dist/trace/fingerprint.js.map +1 -0
  89. package/dist/trace/serialize.d.ts +15 -0
  90. package/dist/trace/serialize.d.ts.map +1 -0
  91. package/dist/trace/serialize.js +86 -0
  92. package/dist/trace/serialize.js.map +1 -0
  93. package/dist/triager/index.d.ts +64 -0
  94. package/dist/triager/index.d.ts.map +1 -0
  95. package/dist/triager/index.js +301 -0
  96. package/dist/triager/index.js.map +1 -0
  97. package/dist/types.d.ts +491 -0
  98. package/dist/types.d.ts.map +1 -0
  99. package/dist/types.js +10 -0
  100. package/dist/types.js.map +1 -0
  101. package/dist/verify/index.d.ts +52 -0
  102. package/dist/verify/index.d.ts.map +1 -0
  103. package/dist/verify/index.js +140 -0
  104. package/dist/verify/index.js.map +1 -0
  105. package/dist/verify/verdict.d.ts +34 -0
  106. package/dist/verify/verdict.d.ts.map +1 -0
  107. package/dist/verify/verdict.js +89 -0
  108. package/dist/verify/verdict.js.map +1 -0
  109. package/package.json +90 -4
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Replay a recorded action trace without asking the LLM.
3
+ *
4
+ * Each step is executed from the stored locator (test id, then role+name,
5
+ * label, placeholder, text, then the CSS fallback). `--heal` is the only
6
+ * path that calls the model: when every recorded locator misses, the step's
7
+ * original instruction is re-resolved and the result is marked `healed`.
8
+ */
9
+ import { type Browser } from 'playwright';
10
+ import type { LLM } from '../llm/index.js';
11
+ import type { FlowTrace, RunResult } from '../types.js';
12
+ export interface ReplayOptions {
13
+ screenshotsDir: string;
14
+ stepTimeoutMs?: number;
15
+ flowTimeoutMs?: number;
16
+ headless?: boolean;
17
+ /** Default true. Tests turn this off; video is not required to replay. */
18
+ recordVideo?: boolean;
19
+ /**
20
+ * Same switch as `RunnerOptions.strictOracles`. Default false so a library
21
+ * replay does not grow new bugs. The CLI passes true.
22
+ */
23
+ strictOracles?: boolean;
24
+ /**
25
+ * Same switch as `RunnerOptions.failOn5xx`. Default false. The CLI passes
26
+ * the value of `--fail-on-5xx` (on unless `--no-fail-on-5xx`).
27
+ */
28
+ failOn5xx?: boolean;
29
+ /**
30
+ * Reuse a browser across calls. The caller owns its lifecycle; replay will
31
+ * not close it. `verify` uses this so N repeats share one Chromium.
32
+ */
33
+ browser?: Browser;
34
+ /**
35
+ * When a recorded locator matches nothing, ask `llm` to re-resolve that
36
+ * step from its original instruction. The step is marked `healed`.
37
+ */
38
+ heal?: boolean;
39
+ llm?: LLM;
40
+ }
41
+ export declare function replayTraces(traces: FlowTrace[], opts: ReplayOptions): Promise<RunResult>;
42
+ //# sourceMappingURL=replay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replay.d.ts","sourceRoot":"","sources":["../../src/runner/replay.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAY,KAAK,OAAO,EAAkC,MAAM,YAAY,CAAC;AAGpF,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,EAGV,SAAS,EACT,SAAS,EAKV,MAAM,aAAa,CAAC;AAarB,MAAM,WAAW,aAAa;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,0EAA0E;IAC1E,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,GAAG,CAAC,EAAE,GAAG,CAAC;CACX;AAED,wBAAsB,YAAY,CAChC,MAAM,EAAE,SAAS,EAAE,EACnB,IAAI,EAAE,aAAa,GAClB,OAAO,CAAC,SAAS,CAAC,CA6BpB"}
@@ -0,0 +1,440 @@
1
+ /**
2
+ * Replay a recorded action trace without asking the LLM.
3
+ *
4
+ * Each step is executed from the stored locator (test id, then role+name,
5
+ * label, placeholder, text, then the CSS fallback). `--heal` is the only
6
+ * path that calls the model: when every recorded locator misses, the step's
7
+ * original instruction is re-resolved and the result is marked `healed`.
8
+ */
9
+ import { chromium } from 'playwright';
10
+ import { mkdirSync } from 'node:fs';
11
+ import { join, resolve } from 'node:path';
12
+ import { buildLocator, captureLocator, executeAction, resolveAction, skeletonForLLM, } from './actions.js';
13
+ import { createFlowTimeout } from './timeout.js';
14
+ import { applyPassedOracles, attachStepEvidence, flushStepEvents } from './evidence.js';
15
+ import { collectOrigins, outcomeWithSameOrigin5xx, promoteRecordedSteps } from './http5xx.js';
16
+ export async function replayTraces(traces, opts) {
17
+ const screenshotsDir = resolve(opts.screenshotsDir);
18
+ mkdirSync(screenshotsDir, { recursive: true });
19
+ const startedAt = new Date().toISOString();
20
+ const flows = [];
21
+ if (traces.length === 0) {
22
+ return emptyReplay(startedAt);
23
+ }
24
+ const owned = !opts.browser;
25
+ const browser = opts.browser ?? await chromium.launch({ headless: opts.headless ?? true });
26
+ try {
27
+ for (const trace of traces) {
28
+ flows.push(await runOneTrace(browser, trace, { ...opts, screenshotsDir }));
29
+ }
30
+ }
31
+ finally {
32
+ if (owned)
33
+ await browser.close().catch(() => { });
34
+ }
35
+ return {
36
+ startUrl: traces[0]?.startUrl || '',
37
+ startedAt,
38
+ finishedAt: new Date().toISOString(),
39
+ flows,
40
+ bugs: [],
41
+ stats: aggregate(flows),
42
+ };
43
+ }
44
+ async function runOneTrace(browser, trace, opts) {
45
+ const started = Date.now();
46
+ const timeoutMs = opts.flowTimeoutMs ?? 180_000;
47
+ const abort = new AbortController();
48
+ const timeout = createFlowTimeout(trace.name || trace.flowId, timeoutMs, () => abort.abort());
49
+ const work = replayFlow(browser, trace, opts, abort.signal);
50
+ // If the timeout wins the race, replayFlow may still reject once the
51
+ // context closes. Observe that rejection so it cannot surface later.
52
+ work.catch(() => { });
53
+ try {
54
+ // `timeout.promise` rejects when the budget is hit and only resolves if
55
+ // `cancel()` runs — which is the `finally` below, after this race.
56
+ const winner = await Promise.race([work, timeout.promise]);
57
+ if (!winner || !('flowId' in winner)) {
58
+ throw new Error(`flow "${trace.name || trace.flowId}" exceeded ${timeoutMs}ms`);
59
+ }
60
+ return winner;
61
+ }
62
+ catch (err) {
63
+ abort.abort();
64
+ return {
65
+ flowId: trace.flowId,
66
+ name: trace.name || trace.flowId,
67
+ description: trace.description || '',
68
+ kind: trace.kind || 'happy_path',
69
+ startUrl: trace.startUrl,
70
+ status: 'error',
71
+ failureReason: err instanceof Error ? err.message : String(err),
72
+ steps: [],
73
+ durationMs: Date.now() - started,
74
+ bugIds: [],
75
+ };
76
+ }
77
+ finally {
78
+ timeout.cancel();
79
+ }
80
+ }
81
+ async function replayFlow(browser, trace, opts, signal) {
82
+ const started = Date.now();
83
+ const stepTimeout = opts.stepTimeoutMs ?? 15_000;
84
+ const context = await openContext(browser, opts);
85
+ const onAbort = () => { void context.close().catch(() => { }); };
86
+ if (signal.aborted) {
87
+ await context.close().catch(() => { });
88
+ throw new Error('flow aborted');
89
+ }
90
+ signal.addEventListener('abort', onAbort, { once: true });
91
+ const page = await context.newPage();
92
+ const evidence = attachStepEvidence(page);
93
+ const origins = collectOrigins([trace.startUrl]);
94
+ const steps = [];
95
+ const traceSteps = [];
96
+ let failed = false;
97
+ let failureReason;
98
+ try {
99
+ for (const recorded of trace.steps) {
100
+ if (signal.aborted)
101
+ throw new Error('flow aborted');
102
+ evidence.stepIndex = recorded.index;
103
+ if (failed) {
104
+ const blocked = blockedResult(recorded, 'Earlier step failed; not attempted.');
105
+ blocked.screenshotPath = await shot(page, opts.screenshotsDir, trace.flowId, recorded.index, 'blocked');
106
+ steps.push(blocked);
107
+ continue;
108
+ }
109
+ const urlBefore = page.url();
110
+ const startedAt = new Date().toISOString();
111
+ const stepStart = Date.now();
112
+ const played = await playStep(page, trace, recorded, opts, stepTimeout);
113
+ if (opts.strictOracles) {
114
+ played.outcome = await applyPassedOracles(page, evidence, recorded.index, played.outcome);
115
+ }
116
+ if (opts.failOn5xx) {
117
+ if (!opts.strictOracles)
118
+ await flushStepEvents(page);
119
+ played.outcome = outcomeWithSameOrigin5xx(played.outcome, evidence.networkByStep.get(recorded.index), origins);
120
+ }
121
+ const urlAfter = safeUrl(page);
122
+ const result = {
123
+ index: recorded.index,
124
+ action: recorded.action || played.action.tool,
125
+ expectation: recorded.expectation,
126
+ status: played.outcome.status,
127
+ observation: played.outcome.observation,
128
+ tool: played.action.tool,
129
+ target: played.action.target,
130
+ locator: played.locator,
131
+ resolution: played.resolution,
132
+ durationMs: Date.now() - stepStart,
133
+ screenshotPath: await shot(page, opts.screenshotsDir, trace.flowId, recorded.index, played.outcome.status),
134
+ consoleErrors: evidence.consoleByStep.get(recorded.index),
135
+ networkFailures: evidence.networkByStep.get(recorded.index),
136
+ ...(played.outcome.error ? { error: played.outcome.error } : {}),
137
+ };
138
+ steps.push(result);
139
+ traceSteps.push({
140
+ index: recorded.index,
141
+ action: recorded.action,
142
+ expectation: recorded.expectation,
143
+ tool: played.action.tool,
144
+ locator: played.locator,
145
+ value: played.action.value,
146
+ urlBefore,
147
+ urlAfter,
148
+ startedAt,
149
+ durationMs: result.durationMs,
150
+ status: result.status,
151
+ observation: result.observation,
152
+ error: result.error,
153
+ screenshotPath: result.screenshotPath,
154
+ consoleErrors: result.consoleErrors,
155
+ networkFailures: result.networkFailures,
156
+ resolution: played.resolution,
157
+ });
158
+ if (result.status === 'failed') {
159
+ failed = true;
160
+ failureReason = result.error || result.observation;
161
+ }
162
+ }
163
+ if (opts.failOn5xx)
164
+ await flushStepEvents(page);
165
+ }
166
+ finally {
167
+ signal.removeEventListener('abort', onAbort);
168
+ await context.close().catch(() => { });
169
+ }
170
+ if (opts.failOn5xx) {
171
+ const promoted = promoteRecordedSteps(steps, traceSteps, origins);
172
+ if (promoted.changed) {
173
+ steps.splice(0, steps.length, ...promoted.steps);
174
+ traceSteps.splice(0, traceSteps.length, ...promoted.traceSteps);
175
+ if (promoted.failed) {
176
+ failed = true;
177
+ failureReason = failureReason || promoted.failureReason;
178
+ }
179
+ }
180
+ }
181
+ const status = failed ? 'failed' : 'passed';
182
+ return {
183
+ flowId: trace.flowId,
184
+ name: trace.name || trace.flowId,
185
+ description: trace.description || '',
186
+ kind: trace.kind || 'happy_path',
187
+ startUrl: trace.startUrl,
188
+ status,
189
+ failureReason,
190
+ steps,
191
+ durationMs: Date.now() - started,
192
+ bugIds: [],
193
+ trace: {
194
+ version: 1,
195
+ flowId: trace.flowId,
196
+ name: trace.name || trace.flowId,
197
+ description: trace.description,
198
+ kind: trace.kind,
199
+ startUrl: trace.startUrl,
200
+ expectation: trace.expectation,
201
+ steps: traceSteps,
202
+ },
203
+ };
204
+ }
205
+ async function playStep(page, trace, recorded, opts, timeoutMs) {
206
+ if (!needsElement(recorded)) {
207
+ const action = actionFromRecorded(recorded);
208
+ const outcome = await executeAction(page, action, timeoutMs, { strictOracles: opts.strictOracles });
209
+ return { action, locator: recorded.locator, outcome, resolution: 'recorded' };
210
+ }
211
+ const matched = await firstMatch(page, recorded);
212
+ if (matched) {
213
+ const outcome = await executeAction(page, matched, timeoutMs, { strictOracles: opts.strictOracles });
214
+ const locator = await captureLocator(page, matched).catch(() => recorded.locator);
215
+ return { action: matched, locator: locator || recorded.locator, outcome, resolution: 'recorded' };
216
+ }
217
+ if (opts.heal && opts.llm && recorded.action) {
218
+ const healed = await healStep(page, trace, recorded, opts.llm);
219
+ const outcome = await executeAction(page, healed, timeoutMs, { strictOracles: opts.strictOracles });
220
+ const locator = await captureLocator(page, healed).catch(() => undefined);
221
+ return {
222
+ action: healed,
223
+ locator,
224
+ outcome: {
225
+ ...outcome,
226
+ observation: `Healed (recorded locator missed). ${outcome.observation}`,
227
+ },
228
+ resolution: 'healed',
229
+ };
230
+ }
231
+ // The original run already continued past this step. A locator miss here
232
+ // must not become a hard failure, or verify never reaches the later bug
233
+ // (a placeholder fill that timed out, then a form POST that returned 500).
234
+ // A step that originally passed or failed still stops the flow.
235
+ if (recorded.status === 'skipped') {
236
+ return {
237
+ action: actionFromRecorded(recorded),
238
+ locator: recorded.locator,
239
+ resolution: 'recorded',
240
+ outcome: {
241
+ status: 'skipped',
242
+ observation: `Recorded step was skipped and its locator still does not match for ${recorded.tool} (${describeLocator(recorded)}). Left skipped so later steps still run.`,
243
+ },
244
+ };
245
+ }
246
+ return {
247
+ action: actionFromRecorded(recorded),
248
+ locator: recorded.locator,
249
+ resolution: 'recorded',
250
+ outcome: {
251
+ status: 'failed',
252
+ observation: `Recorded locator no longer matches for ${recorded.tool} (${describeLocator(recorded)}).`,
253
+ error: 'locator_mismatch',
254
+ },
255
+ };
256
+ }
257
+ async function healStep(page, trace, recorded, llm) {
258
+ const flow = {
259
+ id: trace.flowId,
260
+ name: trace.name || trace.flowId,
261
+ description: trace.description || '',
262
+ kind: trace.kind || 'happy_path',
263
+ startUrl: trace.startUrl,
264
+ expectation: trace.expectation || '',
265
+ severityIfFails: 'major',
266
+ steps: trace.steps
267
+ .filter(step => step.action)
268
+ .map(step => ({ action: step.action, expectation: step.expectation })),
269
+ };
270
+ const step = { action: recorded.action || '', expectation: recorded.expectation };
271
+ const skeleton = await skeletonForLLM(page);
272
+ return resolveAction(llm, flow, step, skeleton);
273
+ }
274
+ function needsElement(step) {
275
+ if (step.tool === 'goto' || step.tool === 'noop' || step.tool === 'assert_text')
276
+ return false;
277
+ if (step.tool === 'press' && !step.locator)
278
+ return false;
279
+ return true;
280
+ }
281
+ function actionFromRecorded(step) {
282
+ if (step.tool === 'goto') {
283
+ return { tool: 'goto', target: step.locator?.target || step.urlAfter || '' };
284
+ }
285
+ if (step.tool === 'assert_text') {
286
+ return { tool: 'assert_text', target: step.locator?.target || step.action };
287
+ }
288
+ if (step.tool === 'noop') {
289
+ return { tool: 'noop', rationale: step.observation };
290
+ }
291
+ if (step.tool === 'press' && !step.locator) {
292
+ return { tool: 'press', value: step.value };
293
+ }
294
+ const locator = step.locator;
295
+ return {
296
+ tool: step.tool,
297
+ locator: locator?.strategy === 'testid' ? 'testid' : (locator?.strategy || 'css'),
298
+ target: locator?.target || '',
299
+ value: step.value,
300
+ };
301
+ }
302
+ async function firstMatch(page, step) {
303
+ const locator = step.locator;
304
+ if (!locator)
305
+ return null;
306
+ const candidates = [];
307
+ const push = (action) => {
308
+ const key = `${action.locator}|${action.target}`;
309
+ if (candidates.some(existing => `${existing.locator}|${existing.target}` === key))
310
+ return;
311
+ candidates.push(action);
312
+ };
313
+ if (locator.testId)
314
+ push({ tool: step.tool, locator: 'testid', target: locator.testId, value: step.value });
315
+ if (locator.role && (locator.name || locator.target)) {
316
+ const name = locator.name || locator.target;
317
+ push({ tool: step.tool, locator: 'role', target: `${locator.role}:${name}`, value: step.value });
318
+ }
319
+ if (locator.label)
320
+ push({ tool: step.tool, locator: 'label', target: locator.label, value: step.value });
321
+ if (locator.placeholder)
322
+ push({ tool: step.tool, locator: 'placeholder', target: locator.placeholder, value: step.value });
323
+ if (locator.text)
324
+ push({ tool: step.tool, locator: 'text', target: locator.text, value: step.value });
325
+ if (locator.css)
326
+ push({ tool: step.tool, locator: 'css', target: locator.css, value: step.value });
327
+ if (locator.strategy === 'css' && locator.target && locator.target !== locator.css) {
328
+ push({ tool: step.tool, locator: 'css', target: locator.target, value: step.value });
329
+ }
330
+ if (locator.strategy && locator.strategy !== 'css' && locator.target) {
331
+ push({
332
+ tool: step.tool,
333
+ locator: locator.strategy,
334
+ target: locator.strategy === 'role' && locator.role && locator.name
335
+ ? `${locator.role}:${locator.name}`
336
+ : locator.target,
337
+ value: step.value,
338
+ });
339
+ }
340
+ for (const candidate of candidates) {
341
+ try {
342
+ const count = await buildLocator(page, candidate).count();
343
+ if (count > 0)
344
+ return candidate;
345
+ }
346
+ catch {
347
+ /* a stale CSS selector can throw on parse; try the next candidate */
348
+ }
349
+ }
350
+ return null;
351
+ }
352
+ function describeLocator(step) {
353
+ const locator = step.locator;
354
+ if (!locator)
355
+ return 'no locator';
356
+ const bits = [
357
+ locator.testId && `testid=${locator.testId}`,
358
+ locator.role && `role=${locator.role}`,
359
+ locator.name && `name=${locator.name}`,
360
+ locator.css && `css=${locator.css}`,
361
+ ].filter(Boolean);
362
+ return bits.join(' ') || `${locator.strategy}:${locator.target}`;
363
+ }
364
+ function blockedResult(recorded, observation) {
365
+ return {
366
+ index: recorded.index,
367
+ action: recorded.action || recorded.tool,
368
+ expectation: recorded.expectation,
369
+ status: 'blocked',
370
+ observation,
371
+ resolution: 'recorded',
372
+ };
373
+ }
374
+ async function openContext(browser, opts) {
375
+ return browser.newContext({
376
+ userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 13_0) AppleWebKit/537.36 '
377
+ + '(KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 monkeytest.ai',
378
+ viewport: { width: 1280, height: 800 },
379
+ ...(opts.recordVideo === false ? {} : {
380
+ recordVideo: { dir: opts.screenshotsDir, size: { width: 1280, height: 800 } },
381
+ }),
382
+ });
383
+ }
384
+ async function shot(page, dir, flowId, index, status) {
385
+ const filename = `replay-${slug(flowId)}-step-${String(index).padStart(2, '0')}-${status}.png`;
386
+ const fullPath = join(dir, filename);
387
+ try {
388
+ await page.screenshot({ path: fullPath, fullPage: false });
389
+ return fullPath;
390
+ }
391
+ catch {
392
+ return undefined;
393
+ }
394
+ }
395
+ function safeUrl(page) {
396
+ try {
397
+ return page.url();
398
+ }
399
+ catch {
400
+ return undefined;
401
+ }
402
+ }
403
+ function slug(s) {
404
+ return s.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '').slice(0, 60) || 'flow';
405
+ }
406
+ function aggregate(flows) {
407
+ let stepsTotal = 0, stepsPassed = 0, stepsFailed = 0;
408
+ for (const flow of flows) {
409
+ for (const step of flow.steps) {
410
+ stepsTotal++;
411
+ if (step.status === 'passed')
412
+ stepsPassed++;
413
+ if (step.status === 'failed')
414
+ stepsFailed++;
415
+ }
416
+ }
417
+ return {
418
+ flowsTotal: flows.length,
419
+ flowsPassed: flows.filter(flow => flow.status === 'passed').length,
420
+ flowsFailed: flows.filter(flow => flow.status === 'failed' || flow.status === 'error').length,
421
+ flowsBlocked: flows.filter(flow => flow.status === 'blocked').length,
422
+ stepsTotal, stepsPassed, stepsFailed,
423
+ bugsCritical: 0, bugsMajor: 0, bugsMinor: 0,
424
+ };
425
+ }
426
+ function emptyReplay(startedAt) {
427
+ return {
428
+ startUrl: '',
429
+ startedAt,
430
+ finishedAt: new Date().toISOString(),
431
+ flows: [],
432
+ bugs: [],
433
+ stats: {
434
+ flowsTotal: 0, flowsPassed: 0, flowsFailed: 0, flowsBlocked: 0,
435
+ stepsTotal: 0, stepsPassed: 0, stepsFailed: 0,
436
+ bugsCritical: 0, bugsMajor: 0, bugsMinor: 0,
437
+ },
438
+ };
439
+ }
440
+ //# sourceMappingURL=replay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replay.js","sourceRoot":"","sources":["../../src/runner/replay.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,QAAQ,EAAgD,MAAM,YAAY,CAAC;AACpF,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAY1C,OAAO,EACL,YAAY,EACZ,cAAc,EACd,aAAa,EACb,aAAa,EACb,cAAc,GAEf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAgC9F,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAAmB,EAC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E,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC;YAC7C,YAAY,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC;SAC5C;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Wall-clock guard for a single flow.
3
+ *
4
+ * The previous guard was a bare `setTimeout` inside `Promise.race`. When the
5
+ * flow finished first the timer kept running (and could reject with nobody
6
+ * listening). When the timer won, the Playwright context was left open until
7
+ * the whole browser closed. `cancel()` clears the timer, and `onFire` is how
8
+ * the runner aborts the context the moment the budget is exceeded.
9
+ */
10
+ export interface FlowTimeout {
11
+ promise: Promise<void>;
12
+ /** Stop the timer. Safe to call more than once, including after it fired. */
13
+ cancel: () => void;
14
+ }
15
+ export declare function createFlowTimeout(flowName: string, timeoutMs: number, onFire?: () => void): FlowTimeout;
16
+ //# sourceMappingURL=timeout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeout.d.ts","sourceRoot":"","sources":["../../src/runner/timeout.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,6EAA6E;IAC7E,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAED,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,MAAM,IAAI,GAClB,WAAW,CA2Bb"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Wall-clock guard for a single flow.
3
+ *
4
+ * The previous guard was a bare `setTimeout` inside `Promise.race`. When the
5
+ * flow finished first the timer kept running (and could reject with nobody
6
+ * listening). When the timer won, the Playwright context was left open until
7
+ * the whole browser closed. `cancel()` clears the timer, and `onFire` is how
8
+ * the runner aborts the context the moment the budget is exceeded.
9
+ */
10
+ export function createFlowTimeout(flowName, timeoutMs, onFire) {
11
+ let timer;
12
+ let settle;
13
+ const promise = new Promise((resolve, reject) => {
14
+ settle = resolve;
15
+ timer = setTimeout(() => {
16
+ timer = undefined;
17
+ try {
18
+ onFire?.();
19
+ }
20
+ catch { /* closing the context must not mask the timeout */ }
21
+ reject(new Error(`flow "${flowName}" exceeded ${timeoutMs}ms`));
22
+ }, timeoutMs);
23
+ });
24
+ return {
25
+ promise,
26
+ cancel() {
27
+ if (timer !== undefined) {
28
+ clearTimeout(timer);
29
+ timer = undefined;
30
+ }
31
+ // Settle so a cancelled guard cannot reject later and is not left pending.
32
+ const resolve = settle;
33
+ settle = undefined;
34
+ resolve?.();
35
+ },
36
+ };
37
+ }
38
+ //# sourceMappingURL=timeout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeout.js","sourceRoot":"","sources":["../../src/runner/timeout.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAQH,MAAM,UAAU,iBAAiB,CAC/B,QAAgB,EAChB,SAAiB,EACjB,MAAmB;IAEnB,IAAI,KAAgD,CAAC;IACrD,IAAI,MAAgC,CAAC;IAErC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACpD,MAAM,GAAG,OAAO,CAAC;QACjB,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;YACtB,KAAK,GAAG,SAAS,CAAC;YAClB,IAAI,CAAC;gBAAC,MAAM,EAAE,EAAE,CAAC;YAAC,CAAC;YACnB,MAAM,CAAC,CAAC,mDAAmD,CAAC,CAAC;YAC7D,MAAM,CAAC,IAAI,KAAK,CAAC,SAAS,QAAQ,cAAc,SAAS,IAAI,CAAC,CAAC,CAAC;QAClE,CAAC,EAAE,SAAS,CAAC,CAAC;IAChB,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,OAAO;QACP,MAAM;YACJ,IAAI,KAAK,KAAK,SAAS,EAAC,CAAC;gBACvB,YAAY,CAAC,KAAK,CAAC,CAAC;gBACpB,KAAK,GAAG,SAAS,CAAC;YACpB,CAAC;YACD,2EAA2E;YAC3E,MAAM,OAAO,GAAG,MAAM,CAAC;YACvB,MAAM,GAAG,SAAS,CAAC;YACnB,OAAO,EAAE,EAAE,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Stable bug fingerprints (v2).
3
+ *
4
+ * The hash is sha1 of five fields, never the LLM's tool choice and never
5
+ * raw error prose:
6
+ *
7
+ * category | location | role | name | errorSignal
8
+ *
9
+ * category — which oracle failed (navigation, interaction, assertion, …)
10
+ * location — URL template; ids, uuids, and timestamps replaced
11
+ * role, name — accessible role + name of the target element
12
+ * errorSignal — coarse error class; numbers, ids, and timestamps stripped
13
+ *
14
+ * `BugReport.fingerprint` stays the legacy v1 hash (action text + tool + a
15
+ * small error code), byte-for-byte with older engines, so a stored bug still
16
+ * matches after upgrade. The stable hash is the additive `fingerprintV2`.
17
+ * `diffRuns` uses v2 only when both runs carry it, and uses v1 otherwise.
18
+ */
19
+ import type { FingerprintParts, TraceLocator } from '../types.js';
20
+ export declare const FINGERPRINT_VERSION: 2;
21
+ /** Coarse failure class. Volatile digits, ids, and timestamps are removed. */
22
+ export declare function normaliseErrorSignal(error: string | undefined): string;
23
+ /**
24
+ * Lowercase, collapse whitespace, and replace tokens that change between
25
+ * runs (uuids, long ids, timestamps). Short numbers stay — "page 2" is a
26
+ * real label, "order 18482931" is not.
27
+ */
28
+ export declare function normaliseLabel(raw: string | undefined): string;
29
+ /** Turn a concrete URL into a page key. Query order is normalised. */
30
+ export declare function normaliseLocation(raw: string | undefined): string;
31
+ export declare function failureCategory(input: {
32
+ tool?: string;
33
+ error?: string;
34
+ observation?: string;
35
+ networkStatus?: number;
36
+ errorSignal?: string;
37
+ }): string;
38
+ export declare function targetIdentity(locator: TraceLocator | undefined, target: string | undefined, tool: string | undefined): {
39
+ role: string;
40
+ name: string;
41
+ };
42
+ export declare function failureLocation(input: {
43
+ tool?: string;
44
+ locatorTarget?: string;
45
+ urlBefore?: string;
46
+ urlAfter?: string;
47
+ fallback?: string;
48
+ }): string;
49
+ export interface FingerprintInput {
50
+ /** Step instruction. Required for a byte-identical v1 `fingerprint`. */
51
+ action?: string;
52
+ tool?: string;
53
+ error?: string;
54
+ observation?: string;
55
+ location?: string;
56
+ locator?: TraceLocator;
57
+ /** Legacy `StepResult.target` (`button:Sign in`, a CSS selector, …). */
58
+ target?: string;
59
+ networkStatus?: number;
60
+ }
61
+ export declare function fingerprintFromParts(parts: FingerprintParts): string;
62
+ /**
63
+ * Legacy v1 hash. This is the algorithm shipped before stable fingerprints:
64
+ * sha1 of `action | tool | errorCode`, first 16 hex chars. Do not change it.
65
+ * Stored bugs only have this string, so they cannot be re-hashed.
66
+ */
67
+ export declare function legacyFingerprint(step: {
68
+ action: string;
69
+ tool?: string;
70
+ error?: string;
71
+ }): string;
72
+ /** Build both hashes. `fingerprint` is v1; `fingerprintV2` ignores the tool name. */
73
+ export declare function fingerprintFailure(input: FingerprintInput): {
74
+ fingerprint: string;
75
+ fingerprintV2: string;
76
+ parts: FingerprintParts;
77
+ };
78
+ //# sourceMappingURL=fingerprint.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fingerprint.d.ts","sourceRoot":"","sources":["../../src/trace/fingerprint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAElE,eAAO,MAAM,mBAAmB,EAAG,CAAU,CAAC;AAU9C,8EAA8E;AAC9E,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAqDtE;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAG9D;AAED,sEAAsE;AACtE,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAA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