@monkeytestai/monkeytester 0.7.0-beta.3 → 0.7.0-beta.5
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/CHANGELOG.md +51 -0
- package/README.md +152 -133
- package/dist/automation/signatures.d.ts.map +1 -1
- package/dist/automation/signatures.js +10 -0
- package/dist/automation/signatures.js.map +1 -1
- package/dist/budget.d.ts +23 -0
- package/dist/budget.d.ts.map +1 -0
- package/dist/budget.js +30 -0
- package/dist/budget.js.map +1 -0
- package/dist/checks/axe.d.ts +6 -0
- package/dist/checks/axe.d.ts.map +1 -1
- package/dist/checks/axe.js +15 -0
- package/dist/checks/axe.js.map +1 -1
- package/dist/checks/console.d.ts +4 -0
- package/dist/checks/console.d.ts.map +1 -1
- package/dist/checks/console.js +16 -1
- package/dist/checks/console.js.map +1 -1
- package/dist/checks/execute.d.ts +17 -1
- package/dist/checks/execute.d.ts.map +1 -1
- package/dist/checks/execute.js +92 -36
- package/dist/checks/execute.js.map +1 -1
- package/dist/checks/meta.d.ts +7 -4
- package/dist/checks/meta.d.ts.map +1 -1
- package/dist/checks/meta.js +8 -6
- package/dist/checks/meta.js.map +1 -1
- package/dist/checks/mobile.d.ts +8 -0
- package/dist/checks/mobile.d.ts.map +1 -1
- package/dist/checks/mobile.js +10 -3
- package/dist/checks/mobile.js.map +1 -1
- package/dist/checks/party.d.ts +19 -0
- package/dist/checks/party.d.ts.map +1 -0
- package/dist/checks/party.js +56 -0
- package/dist/checks/party.js.map +1 -0
- package/dist/checks/plan.js +4 -4
- package/dist/checks/plan.js.map +1 -1
- package/dist/checks/ready.d.ts +10 -0
- package/dist/checks/ready.d.ts.map +1 -0
- package/dist/checks/ready.js +22 -0
- package/dist/checks/ready.js.map +1 -0
- package/dist/cli.js +26 -3
- package/dist/cli.js.map +1 -1
- package/dist/explorer/authRedirect.d.ts +41 -0
- package/dist/explorer/authRedirect.d.ts.map +1 -0
- package/dist/explorer/authRedirect.js +129 -0
- package/dist/explorer/authRedirect.js.map +1 -0
- package/dist/explorer/index.d.ts +3 -3
- package/dist/explorer/index.d.ts.map +1 -1
- package/dist/explorer/index.js +43 -8
- package/dist/explorer/index.js.map +1 -1
- package/dist/explorer/queue.d.ts +10 -3
- package/dist/explorer/queue.d.ts.map +1 -1
- package/dist/explorer/queue.js +12 -11
- package/dist/explorer/queue.js.map +1 -1
- package/dist/explorer/screens.d.ts +23 -0
- package/dist/explorer/screens.d.ts.map +1 -0
- package/dist/explorer/screens.js +41 -0
- package/dist/explorer/screens.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/llm/index.d.ts.map +1 -1
- package/dist/llm/index.js +16 -13
- package/dist/llm/index.js.map +1 -1
- package/dist/llm/prices.d.ts +28 -4
- package/dist/llm/prices.d.ts.map +1 -1
- package/dist/llm/prices.js +39 -11
- package/dist/llm/prices.js.map +1 -1
- package/dist/llm/temperature.d.ts +20 -0
- package/dist/llm/temperature.d.ts.map +1 -0
- package/dist/llm/temperature.js +47 -0
- package/dist/llm/temperature.js.map +1 -0
- package/dist/monkey.d.ts +1 -0
- package/dist/monkey.d.ts.map +1 -1
- package/dist/monkey.js +66 -11
- package/dist/monkey.js.map +1 -1
- package/dist/outcome/check.d.ts.map +1 -1
- package/dist/outcome/check.js +27 -9
- package/dist/outcome/check.js.map +1 -1
- package/dist/outcome.d.ts +1 -0
- package/dist/outcome.d.ts.map +1 -1
- package/dist/outcome.js +31 -1
- package/dist/outcome.js.map +1 -1
- package/dist/planner/forms.js +11 -1
- package/dist/planner/forms.js.map +1 -1
- package/dist/planner/index.d.ts.map +1 -1
- package/dist/planner/index.js +48 -12
- package/dist/planner/index.js.map +1 -1
- package/dist/planner/inventory.d.ts +6 -0
- package/dist/planner/inventory.d.ts.map +1 -1
- package/dist/planner/inventory.js +59 -0
- package/dist/planner/inventory.js.map +1 -1
- package/dist/runner/actions.d.ts +2 -0
- package/dist/runner/actions.d.ts.map +1 -1
- package/dist/runner/actions.js +181 -7
- package/dist/runner/actions.js.map +1 -1
- package/dist/runner/authNegative.d.ts.map +1 -1
- package/dist/runner/authNegative.js +81 -21
- package/dist/runner/authNegative.js.map +1 -1
- package/dist/runner/evidence.d.ts +27 -6
- package/dist/runner/evidence.d.ts.map +1 -1
- package/dist/runner/evidence.js +86 -10
- package/dist/runner/evidence.js.map +1 -1
- package/dist/runner/http5xx.d.ts.map +1 -1
- package/dist/runner/http5xx.js +1 -0
- package/dist/runner/http5xx.js.map +1 -1
- package/dist/runner/index.d.ts +10 -0
- package/dist/runner/index.d.ts.map +1 -1
- package/dist/runner/index.js +205 -113
- package/dist/runner/index.js.map +1 -1
- package/dist/runner/locate.d.ts.map +1 -1
- package/dist/runner/locate.js +101 -11
- package/dist/runner/locate.js.map +1 -1
- package/dist/runner/replay.d.ts +3 -0
- package/dist/runner/replay.d.ts.map +1 -1
- package/dist/runner/replay.js +4 -0
- package/dist/runner/replay.js.map +1 -1
- package/dist/runner/sensitive.d.ts +72 -0
- package/dist/runner/sensitive.d.ts.map +1 -0
- package/dist/runner/sensitive.js +348 -0
- package/dist/runner/sensitive.js.map +1 -0
- package/dist/signup/detect.d.ts +2 -0
- package/dist/signup/detect.d.ts.map +1 -1
- package/dist/signup/detect.js +14 -2
- package/dist/signup/detect.js.map +1 -1
- package/dist/signup/guard.d.ts.map +1 -1
- package/dist/signup/guard.js +53 -4
- package/dist/signup/guard.js.map +1 -1
- package/dist/signup/ledger.d.ts +4 -0
- package/dist/signup/ledger.d.ts.map +1 -1
- package/dist/signup/ledger.js +16 -4
- package/dist/signup/ledger.js.map +1 -1
- package/dist/signup/run.d.ts +2 -0
- package/dist/signup/run.d.ts.map +1 -1
- package/dist/signup/run.js +224 -51
- package/dist/signup/run.js.map +1 -1
- package/dist/signup/submit.d.ts +13 -0
- package/dist/signup/submit.d.ts.map +1 -0
- package/dist/signup/submit.js +40 -0
- package/dist/signup/submit.js.map +1 -0
- package/dist/trace/httpIdentity.d.ts +17 -0
- package/dist/trace/httpIdentity.d.ts.map +1 -0
- package/dist/trace/httpIdentity.js +61 -0
- package/dist/trace/httpIdentity.js.map +1 -0
- package/dist/trace/serialize.d.ts.map +1 -1
- package/dist/trace/serialize.js +2 -0
- package/dist/trace/serialize.js.map +1 -1
- package/dist/trace/stepLabel.d.ts +11 -0
- package/dist/trace/stepLabel.d.ts.map +1 -0
- package/dist/trace/stepLabel.js +49 -0
- package/dist/trace/stepLabel.js.map +1 -0
- package/dist/triager/index.d.ts +5 -1
- package/dist/triager/index.d.ts.map +1 -1
- package/dist/triager/index.js +146 -15
- package/dist/triager/index.js.map +1 -1
- package/dist/types.d.ts +133 -3
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -2
package/dist/runner/index.js
CHANGED
|
@@ -35,6 +35,7 @@ import { createFlowTimeout } from './timeout.js';
|
|
|
35
35
|
import { applyPassedOracles, attachStepEvidence, flushStepEvents } from './evidence.js';
|
|
36
36
|
import { collectOrigins, outcomeWithSameOrigin5xx, promoteRecordedSteps } from './http5xx.js';
|
|
37
37
|
import { serializeTrace, serializeTraceStep } from '../trace/serialize.js';
|
|
38
|
+
import { humanStepLabel } from '../trace/stepLabel.js';
|
|
38
39
|
import { resolveFlowStatus } from './flowStatus.js';
|
|
39
40
|
import { ENGINE_VERSION } from '../version.js';
|
|
40
41
|
import { isAuthNegativeFlowId } from '../planner/authNegative.js';
|
|
@@ -42,10 +43,14 @@ import { runAuthCheck } from './authNegative.js';
|
|
|
42
43
|
import { isPageCheckFlowId } from '../checks/plan.js';
|
|
43
44
|
import { executePageChecks } from '../checks/execute.js';
|
|
44
45
|
import { isSignupFlowId } from '../signup/plan.js';
|
|
46
|
+
/** Inbox sign-up waits up to 60s. The Quick pass flow cap must not cut that wait. */
|
|
47
|
+
export const SIGNUP_FLOW_TIMEOUT_MS = 75_000;
|
|
45
48
|
import { signupSubmitBlock } from '../signup/guard.js';
|
|
46
49
|
import { runSignupCheck } from '../signup/run.js';
|
|
47
|
-
import { emptySignupLedger, signupFields } from '../signup/ledger.js';
|
|
50
|
+
import { emptySignupLedger, noteSignup, signupFields } from '../signup/ledger.js';
|
|
48
51
|
import { evaluateOutcomeCheck, snapPage } from '../outcome/check.js';
|
|
52
|
+
import { authRedirectObservation, authRedirectSuggestion, classifyDocumentRedirect, isPageVisitFlow, waitForSettledLocation, } from '../explorer/authRedirect.js';
|
|
53
|
+
import { installDialogPolicy, installSubmissionGuards, setStepIntent } from './sensitive.js';
|
|
49
54
|
/* ── Public entry point ───────────────────────────────────────────────── */
|
|
50
55
|
export async function runPlan(plan, llm, opts) {
|
|
51
56
|
const screenshotsDir = resolve(opts.screenshotsDir);
|
|
@@ -64,58 +69,53 @@ export async function runPlan(plan, llm, opts) {
|
|
|
64
69
|
const browser = await chromium.launch({ headless });
|
|
65
70
|
try {
|
|
66
71
|
const checkFlows = plan.flows.filter(flow => isPageCheckFlowId(flow.id));
|
|
67
|
-
|
|
72
|
+
if (checkFlows.length > 0) {
|
|
73
|
+
const batch = await executePageChecks(browser, checkFlows, {
|
|
74
|
+
screenshotsDir,
|
|
75
|
+
stepTimeoutMs: stepTimeout,
|
|
76
|
+
deadlineAt: opts.deadlineAt,
|
|
77
|
+
onFlowStart: item => {
|
|
78
|
+
const index = plan.flows.findIndex(candidate => candidate.id === item.id);
|
|
79
|
+
opts.onEvent?.({ type: 'flow.start', flowId: item.id, flow: item });
|
|
80
|
+
events.emit({
|
|
81
|
+
phase: 'runner', type: 'run.flow_start',
|
|
82
|
+
message: `Flow ${index + 1}/${plan.flows.length}: ${item.name}`,
|
|
83
|
+
data: {
|
|
84
|
+
flowId: item.id,
|
|
85
|
+
flowIndex: index + 1,
|
|
86
|
+
flowsTotal: plan.flows.length,
|
|
87
|
+
name: item.name,
|
|
88
|
+
kind: item.kind,
|
|
89
|
+
startUrl: item.startUrl,
|
|
90
|
+
stepsTotal: item.steps.length,
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
onStep: (item, result) => {
|
|
95
|
+
opts.onEvent?.({ type: 'step.complete', flowId: item.id, index: result.index, result });
|
|
96
|
+
},
|
|
97
|
+
onFlowComplete: result => {
|
|
98
|
+
const index = plan.flows.findIndex(candidate => candidate.id === result.flowId);
|
|
99
|
+
opts.onEvent?.({ type: 'flow.complete', flowId: result.flowId, result });
|
|
100
|
+
events.emit({
|
|
101
|
+
phase: 'runner', type: 'run.flow_complete',
|
|
102
|
+
message: `Flow ${index + 1}/${plan.flows.length} ${result.status}: ${result.name}`,
|
|
103
|
+
data: {
|
|
104
|
+
flowId: result.flowId,
|
|
105
|
+
flowIndex: index + 1,
|
|
106
|
+
flowsTotal: plan.flows.length,
|
|
107
|
+
status: result.status,
|
|
108
|
+
failureReason: result.failureReason || null,
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
flows.push(...batch);
|
|
114
|
+
}
|
|
68
115
|
for (let fi = 0; fi < plan.flows.length; fi++) {
|
|
69
116
|
const flow = plan.flows[fi];
|
|
70
|
-
if (isPageCheckFlowId(flow.id))
|
|
71
|
-
if (checksRan.has(flow.id))
|
|
72
|
-
continue;
|
|
73
|
-
const pending = checkFlows.filter(item => !checksRan.has(item.id));
|
|
74
|
-
for (const item of pending)
|
|
75
|
-
checksRan.add(item.id);
|
|
76
|
-
const batch = await executePageChecks(browser, pending, {
|
|
77
|
-
screenshotsDir,
|
|
78
|
-
stepTimeoutMs: stepTimeout,
|
|
79
|
-
deadlineAt: opts.deadlineAt,
|
|
80
|
-
onFlowStart: item => {
|
|
81
|
-
const index = plan.flows.findIndex(candidate => candidate.id === item.id);
|
|
82
|
-
opts.onEvent?.({ type: 'flow.start', flowId: item.id, flow: item });
|
|
83
|
-
events.emit({
|
|
84
|
-
phase: 'runner', type: 'run.flow_start',
|
|
85
|
-
message: `Flow ${index + 1}/${plan.flows.length}: ${item.name}`,
|
|
86
|
-
data: {
|
|
87
|
-
flowId: item.id,
|
|
88
|
-
flowIndex: index + 1,
|
|
89
|
-
flowsTotal: plan.flows.length,
|
|
90
|
-
name: item.name,
|
|
91
|
-
kind: item.kind,
|
|
92
|
-
startUrl: item.startUrl,
|
|
93
|
-
stepsTotal: item.steps.length,
|
|
94
|
-
},
|
|
95
|
-
});
|
|
96
|
-
},
|
|
97
|
-
onStep: (item, result) => {
|
|
98
|
-
opts.onEvent?.({ type: 'step.complete', flowId: item.id, index: result.index, result });
|
|
99
|
-
},
|
|
100
|
-
onFlowComplete: result => {
|
|
101
|
-
const index = plan.flows.findIndex(candidate => candidate.id === result.flowId);
|
|
102
|
-
opts.onEvent?.({ type: 'flow.complete', flowId: result.flowId, result });
|
|
103
|
-
events.emit({
|
|
104
|
-
phase: 'runner', type: 'run.flow_complete',
|
|
105
|
-
message: `Flow ${index + 1}/${plan.flows.length} ${result.status}: ${result.name}`,
|
|
106
|
-
data: {
|
|
107
|
-
flowId: result.flowId,
|
|
108
|
-
flowIndex: index + 1,
|
|
109
|
-
flowsTotal: plan.flows.length,
|
|
110
|
-
status: result.status,
|
|
111
|
-
failureReason: result.failureReason || null,
|
|
112
|
-
},
|
|
113
|
-
});
|
|
114
|
-
},
|
|
115
|
-
});
|
|
116
|
-
flows.push(...batch);
|
|
117
|
+
if (isPageCheckFlowId(flow.id))
|
|
117
118
|
continue;
|
|
118
|
-
}
|
|
119
119
|
// auth_required flows aren't currently runnable — record a neat
|
|
120
120
|
// "blocked: needs credentials" entry instead of erroring out.
|
|
121
121
|
if (flow.kind === 'auth_required') {
|
|
@@ -147,20 +147,31 @@ export async function runPlan(plan, llm, opts) {
|
|
|
147
147
|
const abort = new AbortController();
|
|
148
148
|
// Firing the guard aborts the context immediately; cancel() after the
|
|
149
149
|
// race clears the timer so a finished flow cannot reject later.
|
|
150
|
-
const
|
|
150
|
+
const inboxSignup = isSignupFlowId(flow.id) && flow.steps.some(step => step.signupCheck === 'inbox_verify');
|
|
151
|
+
const thisFlowTimeout = inboxSignup ? Math.max(flowTimeout, SIGNUP_FLOW_TIMEOUT_MS) : flowTimeout;
|
|
152
|
+
const timeout = createFlowTimeout(flow.name, thisFlowTimeout, () => abort.abort());
|
|
151
153
|
const work = runFlow(browser, flow, llm, { ...opts, screenshotsDir, stepTimeoutMs: stepTimeout, events, signup, runId }, fi + 1, plan.flows.length, abort.signal);
|
|
152
154
|
work.catch(() => { });
|
|
153
155
|
let result;
|
|
154
156
|
try {
|
|
155
157
|
const winner = await Promise.race([work, timeout.promise]);
|
|
156
158
|
if (!winner || !('flowId' in winner)) {
|
|
157
|
-
throw new Error(`flow "${flow.name}" exceeded ${
|
|
159
|
+
throw new Error(`flow "${flow.name}" exceeded ${thisFlowTimeout}ms`);
|
|
158
160
|
}
|
|
159
161
|
result = winner;
|
|
160
162
|
}
|
|
161
163
|
catch (err) {
|
|
162
164
|
abort.abort();
|
|
163
|
-
|
|
165
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
166
|
+
result = errorFlowResult(flow, message, flowStarted);
|
|
167
|
+
if (inboxSignup && /exceeded \d+ms/.test(message)) {
|
|
168
|
+
noteSignup(signup, { saw: true, attempted: true, status: 'unverified', reason: 'timeout' });
|
|
169
|
+
result = {
|
|
170
|
+
...result,
|
|
171
|
+
outcome_reason: 'timeout',
|
|
172
|
+
outcome_detail: 'The sign-up wait was cut off (signup_reason timeout).',
|
|
173
|
+
};
|
|
174
|
+
}
|
|
164
175
|
}
|
|
165
176
|
finally {
|
|
166
177
|
timeout.cancel();
|
|
@@ -223,6 +234,8 @@ async function runFlow(browser, flow, llm, opts, flowIndex, flowsTotal, signal)
|
|
|
223
234
|
}
|
|
224
235
|
signal?.addEventListener('abort', onAbort, { once: true });
|
|
225
236
|
const page = await context.newPage();
|
|
237
|
+
await installSubmissionGuards(page, { inbox: Boolean(opts.inbox), allow: opts.allowSensitive });
|
|
238
|
+
installDialogPolicy(page);
|
|
226
239
|
// Per-flow buffers. Listeners attribute console, page errors, and network
|
|
227
240
|
// failures to whichever step index is current.
|
|
228
241
|
const evidence = attachStepEvidence(page);
|
|
@@ -231,7 +244,9 @@ async function runFlow(browser, flow, llm, opts, flowIndex, flowsTotal, signal)
|
|
|
231
244
|
let flowFailed = false;
|
|
232
245
|
let firstFailureReason;
|
|
233
246
|
let halted;
|
|
247
|
+
let guardedReason;
|
|
234
248
|
let beforeLast;
|
|
249
|
+
const flowSuggestions = [];
|
|
235
250
|
const authNeg = isAuthNegativeFlowId(flow.id);
|
|
236
251
|
const signupFlow = isSignupFlowId(flow.id);
|
|
237
252
|
const llmFallbacks = { used: 0 };
|
|
@@ -247,7 +262,7 @@ async function runFlow(browser, flow, llm, opts, flowIndex, flowsTotal, signal)
|
|
|
247
262
|
}
|
|
248
263
|
}
|
|
249
264
|
}
|
|
250
|
-
return finaliseFlow(flow, steps, flowFailed, firstFailureReason, flowStarted, videoPath, traceSteps, assertion ?? (halted ? 'blocked' : undefined));
|
|
265
|
+
return finaliseFlow(flow, steps, flowFailed, firstFailureReason, flowStarted, videoPath, traceSteps, assertion ?? (halted ? 'blocked' : undefined), flowSuggestions);
|
|
251
266
|
};
|
|
252
267
|
// 1. Initial navigation. Implicit "step 0" — if this fails, the whole
|
|
253
268
|
// flow is blocked before we even attempt the planned steps. The goto is
|
|
@@ -255,21 +270,38 @@ async function runFlow(browser, flow, llm, opts, flowIndex, flowsTotal, signal)
|
|
|
255
270
|
const navStarted = Date.now();
|
|
256
271
|
const navStartedAt = new Date().toISOString();
|
|
257
272
|
let navOracleError;
|
|
273
|
+
let navStatus;
|
|
258
274
|
try {
|
|
259
275
|
evidence.stepIndex = 0;
|
|
260
|
-
await page.goto(flow.startUrl, { waitUntil: 'domcontentloaded', timeout: opts.stepTimeoutMs });
|
|
276
|
+
const navResponse = await page.goto(flow.startUrl, { waitUntil: 'domcontentloaded', timeout: opts.stepTimeoutMs });
|
|
277
|
+
navStatus = navResponse?.status();
|
|
261
278
|
await settleSPA(page);
|
|
279
|
+
await waitForSettledLocation(page);
|
|
280
|
+
const landed = safePageUrl(page) || '';
|
|
281
|
+
const redirectKind = classifyDocumentRedirect({
|
|
282
|
+
requestedUrl: flow.startUrl,
|
|
283
|
+
landedUrl: landed,
|
|
284
|
+
statuses: navStatus === undefined ? undefined : [navStatus],
|
|
285
|
+
});
|
|
286
|
+
const signedOut = isPageVisitFlow(flow) && redirectKind === 'expected-auth';
|
|
287
|
+
if (signedOut)
|
|
288
|
+
flowSuggestions.push(authRedirectSuggestion(flow.startUrl, landed));
|
|
289
|
+
const opened = signedOut
|
|
290
|
+
? authRedirectObservation(flow.startUrl, landed)
|
|
291
|
+
: `Navigated to ${flow.startUrl}.`;
|
|
262
292
|
let nav = opts.strictOracles
|
|
263
293
|
? await applyPassedOracles(page, evidence, 0, {
|
|
264
294
|
status: 'passed',
|
|
265
|
-
observation:
|
|
295
|
+
observation: opened,
|
|
266
296
|
})
|
|
267
|
-
: { status: 'passed', observation:
|
|
297
|
+
: { status: 'passed', observation: opened, error: undefined };
|
|
268
298
|
if (opts.failOn5xx) {
|
|
269
299
|
if (!opts.strictOracles)
|
|
270
300
|
await flushStepEvents(page);
|
|
271
301
|
nav = outcomeWithSameOrigin5xx(nav, evidence.networkByStep.get(0), origins);
|
|
272
302
|
}
|
|
303
|
+
if (nav.suggestions?.length)
|
|
304
|
+
flowSuggestions.push(...nav.suggestions);
|
|
273
305
|
if (nav.status === 'failed') {
|
|
274
306
|
navOracleError = nav.error || nav.observation;
|
|
275
307
|
throw new Error(navOracleError);
|
|
@@ -283,65 +315,89 @@ async function runFlow(browser, flow, llm, opts, flowIndex, flowsTotal, signal)
|
|
|
283
315
|
startedAt: navStartedAt,
|
|
284
316
|
durationMs: Date.now() - navStarted,
|
|
285
317
|
status: 'passed',
|
|
286
|
-
observation:
|
|
318
|
+
observation: opened,
|
|
287
319
|
resolution: 'recorded',
|
|
288
320
|
}));
|
|
289
321
|
}
|
|
290
322
|
catch (err) {
|
|
291
323
|
const msg = navOracleError || (err instanceof Error ? err.message : String(err));
|
|
292
|
-
const
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
durationMs: Date.now() - navStarted,
|
|
314
|
-
status: 'failed',
|
|
315
|
-
observation: blockingStep.observation,
|
|
316
|
-
error: msg,
|
|
317
|
-
screenshotPath: blockingStep.screenshotPath,
|
|
318
|
-
consoleErrors: blockingStep.consoleErrors,
|
|
319
|
-
networkFailures: blockingStep.networkFailures,
|
|
320
|
-
resolution: 'recorded',
|
|
321
|
-
}));
|
|
322
|
-
flowFailed = true;
|
|
323
|
-
firstFailureReason = msg;
|
|
324
|
-
if (blockingStep.screenshotPath) {
|
|
325
|
-
events.emit({
|
|
326
|
-
phase: 'runner', type: 'run.screenshot',
|
|
327
|
-
message: `Screenshot captured (step 0 failed)`,
|
|
328
|
-
data: {
|
|
329
|
-
flowId: flow.id, flowIndex, flowsTotal,
|
|
330
|
-
stepIndex: 0, status: 'failed',
|
|
331
|
-
screenshot: basename(blockingStep.screenshotPath),
|
|
332
|
-
},
|
|
333
|
-
});
|
|
324
|
+
const landed = safePageUrl(page) || '';
|
|
325
|
+
const kind = classifyDocumentRedirect({
|
|
326
|
+
requestedUrl: flow.startUrl,
|
|
327
|
+
landedUrl: landed,
|
|
328
|
+
statuses: navStatus === undefined ? undefined : [navStatus],
|
|
329
|
+
});
|
|
330
|
+
const loop = /too many redirects|ERR_TOO_MANY_REDIRECTS|redirect.?loop/i.test(msg);
|
|
331
|
+
if (!navOracleError && !loop && isPageVisitFlow(flow) && kind === 'expected-auth') {
|
|
332
|
+
flowSuggestions.push(authRedirectSuggestion(flow.startUrl, landed));
|
|
333
|
+
traceSteps.push(serializeTraceStep({
|
|
334
|
+
index: 0,
|
|
335
|
+
action: `Open ${flow.startUrl}`,
|
|
336
|
+
tool: 'goto',
|
|
337
|
+
locator: { strategy: 'css', target: flow.startUrl },
|
|
338
|
+
urlAfter: landed,
|
|
339
|
+
startedAt: navStartedAt,
|
|
340
|
+
durationMs: Date.now() - navStarted,
|
|
341
|
+
status: 'passed',
|
|
342
|
+
observation: authRedirectObservation(flow.startUrl, landed),
|
|
343
|
+
resolution: 'recorded',
|
|
344
|
+
}));
|
|
334
345
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
346
|
+
else {
|
|
347
|
+
const blockingStep = {
|
|
348
|
+
index: 0,
|
|
349
|
+
action: `Open ${flow.startUrl}`,
|
|
350
|
+
status: 'failed',
|
|
351
|
+
observation: navOracleError
|
|
352
|
+
? `Opening ${flow.startUrl} failed: ${msg}.`
|
|
353
|
+
: `Could not load the starting page (${msg}).`,
|
|
354
|
+
tool: 'goto',
|
|
355
|
+
target: flow.startUrl,
|
|
356
|
+
error: msg,
|
|
357
|
+
screenshotPath: await safeShot(page, opts.screenshotsDir, flow.id, 0, 'failed'),
|
|
358
|
+
consoleErrors: evidence.consoleByStep.get(0),
|
|
359
|
+
networkFailures: evidence.networkByStep.get(0),
|
|
360
|
+
};
|
|
361
|
+
steps.push(blockingStep);
|
|
362
|
+
traceSteps.push(serializeTraceStep({
|
|
363
|
+
index: 0,
|
|
364
|
+
action: blockingStep.action,
|
|
365
|
+
tool: 'goto',
|
|
366
|
+
locator: { strategy: 'css', target: flow.startUrl },
|
|
367
|
+
startedAt: navStartedAt,
|
|
368
|
+
durationMs: Date.now() - navStarted,
|
|
369
|
+
status: 'failed',
|
|
370
|
+
observation: blockingStep.observation,
|
|
371
|
+
error: msg,
|
|
372
|
+
screenshotPath: blockingStep.screenshotPath,
|
|
373
|
+
consoleErrors: blockingStep.consoleErrors,
|
|
374
|
+
networkFailures: blockingStep.networkFailures,
|
|
375
|
+
resolution: 'recorded',
|
|
376
|
+
}));
|
|
377
|
+
flowFailed = true;
|
|
378
|
+
firstFailureReason = msg;
|
|
379
|
+
if (blockingStep.screenshotPath) {
|
|
380
|
+
events.emit({
|
|
381
|
+
phase: 'runner', type: 'run.screenshot',
|
|
382
|
+
message: `Screenshot captured (step 0 failed)`,
|
|
383
|
+
data: {
|
|
384
|
+
flowId: flow.id, flowIndex, flowsTotal,
|
|
385
|
+
stepIndex: 0, status: 'failed',
|
|
386
|
+
screenshot: basename(blockingStep.screenshotPath),
|
|
387
|
+
},
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
// Record the rest as blocked with screenshots too — evidence should be
|
|
391
|
+
// visible for every planned step, even when navigation failed early.
|
|
392
|
+
for (let i = 0; i < flow.steps.length; i++) {
|
|
393
|
+
const blocked = blockedStep(i + 1, flow.steps[i], 'Earlier step failed; not attempted.');
|
|
394
|
+
blocked.screenshotPath = await safeShot(page, opts.screenshotsDir, flow.id, i + 1, 'blocked');
|
|
395
|
+
steps.push(blocked);
|
|
396
|
+
}
|
|
397
|
+
signal?.removeEventListener('abort', onAbort);
|
|
398
|
+
await context.close().catch(() => { });
|
|
399
|
+
return finish();
|
|
341
400
|
}
|
|
342
|
-
signal?.removeEventListener('abort', onAbort);
|
|
343
|
-
await context.close().catch(() => { });
|
|
344
|
-
return finish();
|
|
345
401
|
}
|
|
346
402
|
// 2. Walk the planned steps.
|
|
347
403
|
for (let i = 0; i < flow.steps.length; i++) {
|
|
@@ -389,6 +445,8 @@ async function runFlow(browser, flow, llm, opts, flowIndex, flowsTotal, signal)
|
|
|
389
445
|
const stepStart = Date.now();
|
|
390
446
|
const startedAt = new Date().toISOString();
|
|
391
447
|
const urlBefore = page.url();
|
|
448
|
+
const upcoming = flow.steps.slice(i).map(item => `${item.action}\n${item.expectation || ''}`).join('\n');
|
|
449
|
+
setStepIntent(page, upcoming);
|
|
392
450
|
if (step.check) {
|
|
393
451
|
const outcome = await runAuthCheck(page, flow, step, evidence, stepIndex, {
|
|
394
452
|
timeoutMs: opts.stepTimeoutMs,
|
|
@@ -477,6 +535,7 @@ async function runFlow(browser, flow, llm, opts, flowIndex, flowsTotal, signal)
|
|
|
477
535
|
consoleErrors: evidence.consoleByStep.get(stepIndex),
|
|
478
536
|
networkFailures: evidence.networkByStep.get(stepIndex),
|
|
479
537
|
...(outcome.error ? { error: outcome.error } : {}),
|
|
538
|
+
...(outcome.phases?.length ? { signupPhases: outcome.phases } : {}),
|
|
480
539
|
};
|
|
481
540
|
steps.push(result);
|
|
482
541
|
traceSteps.push(serializeTraceStep({
|
|
@@ -625,6 +684,9 @@ async function runFlow(browser, flow, llm, opts, flowIndex, flowsTotal, signal)
|
|
|
625
684
|
await flushStepEvents(page);
|
|
626
685
|
exec = outcomeWithSameOrigin5xx(exec, evidence.networkByStep.get(stepIndex), origins);
|
|
627
686
|
}
|
|
687
|
+
if (exec.error === 'sensitive-submit' || exec.error === 'oauth-navigation') {
|
|
688
|
+
guardedReason = exec.observation;
|
|
689
|
+
}
|
|
628
690
|
const screenshotPath = await safeShot(page, opts.screenshotsDir, flow.id, stepIndex, exec.status);
|
|
629
691
|
const durationMs = Date.now() - stepStart;
|
|
630
692
|
const result = {
|
|
@@ -643,7 +705,10 @@ async function runFlow(browser, flow, llm, opts, flowIndex, flowsTotal, signal)
|
|
|
643
705
|
networkFailures: evidence.networkByStep.get(stepIndex),
|
|
644
706
|
...(exec.error ? { error: exec.error } : {}),
|
|
645
707
|
...(ring ? { element: ring } : {}),
|
|
708
|
+
...(exec.suggestions?.length ? { suggestions: exec.suggestions } : {}),
|
|
646
709
|
};
|
|
710
|
+
if (exec.suggestions?.length)
|
|
711
|
+
flowSuggestions.push(...exec.suggestions);
|
|
647
712
|
steps.push(result);
|
|
648
713
|
traceSteps.push(serializeTraceStep({
|
|
649
714
|
index: stepIndex,
|
|
@@ -697,7 +762,20 @@ async function runFlow(browser, flow, llm, opts, flowIndex, flowsTotal, signal)
|
|
|
697
762
|
assertion = oracleAssertion(steps);
|
|
698
763
|
}
|
|
699
764
|
else if (!flowFailed) {
|
|
700
|
-
const
|
|
765
|
+
const landedNow = safePageUrl(page) || '';
|
|
766
|
+
const redirectKind = classifyDocumentRedirect({
|
|
767
|
+
requestedUrl: flow.startUrl,
|
|
768
|
+
landedUrl: landedNow,
|
|
769
|
+
statuses: navStatus === undefined ? undefined : [navStatus],
|
|
770
|
+
});
|
|
771
|
+
const signedOutVisit = isPageVisitFlow(flow) && redirectKind === 'expected-auth';
|
|
772
|
+
let verdict = await evaluateOutcomeCheck(page, flow.outcomeCheck, { startUrl: flow.startUrl, before: beforeLast });
|
|
773
|
+
if (signedOutVisit && verdict.state !== 'verified') {
|
|
774
|
+
verdict = { state: 'verified', observation: authRedirectObservation(flow.startUrl, landedNow) };
|
|
775
|
+
if (!flowSuggestions.some(item => item.kind === 'auth-redirect')) {
|
|
776
|
+
flowSuggestions.push(authRedirectSuggestion(flow.startUrl, landedNow));
|
|
777
|
+
}
|
|
778
|
+
}
|
|
701
779
|
const unfinished = steps.some(step => step.index > 0 && (step.status === 'skipped' || step.status === 'blocked'));
|
|
702
780
|
assertion = verdict.state === 'verified'
|
|
703
781
|
? 'verified'
|
|
@@ -739,6 +817,17 @@ async function runFlow(browser, flow, llm, opts, flowIndex, flowsTotal, signal)
|
|
|
739
817
|
else {
|
|
740
818
|
assertion = 'unverifiable';
|
|
741
819
|
}
|
|
820
|
+
if (guardedReason) {
|
|
821
|
+
assertion = 'unverifiable';
|
|
822
|
+
const outcomeStep = steps.find(step => step.action === 'Check the expected outcome' && step.status === 'failed');
|
|
823
|
+
if (outcomeStep) {
|
|
824
|
+
outcomeStep.status = 'skipped';
|
|
825
|
+
delete outcomeStep.error;
|
|
826
|
+
}
|
|
827
|
+
flowFailed = steps.some(step => step.status === 'failed');
|
|
828
|
+
if (!flowFailed)
|
|
829
|
+
firstFailureReason = undefined;
|
|
830
|
+
}
|
|
742
831
|
// Grab the video path before closing — Playwright finalises the file on close.
|
|
743
832
|
let videoPathRaw = null;
|
|
744
833
|
try {
|
|
@@ -835,7 +924,9 @@ function oracleAssertion(steps) {
|
|
|
835
924
|
return 'verified';
|
|
836
925
|
return 'unverifiable';
|
|
837
926
|
}
|
|
838
|
-
function finaliseFlow(flow, steps, failed, failureReason, started, videoPath, traceSteps, assertion) {
|
|
927
|
+
function finaliseFlow(flow, steps, failed, failureReason, started, videoPath, traceSteps, assertion, suggestions = []) {
|
|
928
|
+
const labelled = steps.map(step => ({ ...step, label: humanStepLabel(step) }));
|
|
929
|
+
const labelledTrace = traceSteps.map(step => ({ ...step, label: step.label || humanStepLabel(step) }));
|
|
839
930
|
const decided = assertion ?? (flow.outcomeCheck ? 'missing' : 'missing');
|
|
840
931
|
const status = decided === 'blocked'
|
|
841
932
|
? 'blocked'
|
|
@@ -850,7 +941,7 @@ function finaliseFlow(flow, steps, failed, failureReason, started, videoPath, tr
|
|
|
850
941
|
expectation: flow.expectation,
|
|
851
942
|
severityIfFails: flow.severityIfFails,
|
|
852
943
|
outcomeCheck: flow.outcomeCheck,
|
|
853
|
-
steps:
|
|
944
|
+
steps: labelledTrace,
|
|
854
945
|
});
|
|
855
946
|
const reason = status === 'blocked'
|
|
856
947
|
? failureReason
|
|
@@ -867,11 +958,12 @@ function finaliseFlow(flow, steps, failed, failureReason, started, videoPath, tr
|
|
|
867
958
|
...(status === 'inconclusive' && decided === 'unverifiable' ? { outcome_reason: 'assertion_unverifiable' } : {}),
|
|
868
959
|
assertion: decided,
|
|
869
960
|
severityIfFails: flow.severityIfFails,
|
|
870
|
-
steps,
|
|
961
|
+
steps: labelled,
|
|
871
962
|
durationMs: Date.now() - started,
|
|
872
963
|
bugIds: [], // populated by triager
|
|
873
964
|
...(videoPath ? { videoPath } : {}),
|
|
874
965
|
trace,
|
|
966
|
+
...(suggestions.length ? { suggestions } : {}),
|
|
875
967
|
};
|
|
876
968
|
}
|
|
877
969
|
function emptyRun(plan, startedAt) {
|