@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.
- package/CHANGELOG.md +172 -0
- package/LICENSE +661 -0
- package/NOTICE +12 -0
- package/README.md +196 -2
- package/dist/cli.d.ts +43 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +771 -0
- package/dist/cli.js.map +1 -0
- package/dist/diff/index.d.ts +78 -0
- package/dist/diff/index.d.ts.map +1 -0
- package/dist/diff/index.js +119 -0
- package/dist/diff/index.js.map +1 -0
- package/dist/events.d.ts +66 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +77 -0
- package/dist/events.js.map +1 -0
- package/dist/explorer/index.d.ts +54 -0
- package/dist/explorer/index.d.ts.map +1 -0
- package/dist/explorer/index.js +491 -0
- package/dist/explorer/index.js.map +1 -0
- package/dist/explorer/queue.d.ts +94 -0
- package/dist/explorer/queue.d.ts.map +1 -0
- package/dist/explorer/queue.js +277 -0
- package/dist/explorer/queue.js.map +1 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/llm/index.d.ts +79 -0
- package/dist/llm/index.d.ts.map +1 -0
- package/dist/llm/index.js +392 -0
- package/dist/llm/index.js.map +1 -0
- package/dist/llm/presets.d.ts +61 -0
- package/dist/llm/presets.d.ts.map +1 -0
- package/dist/llm/presets.js +101 -0
- package/dist/llm/presets.js.map +1 -0
- package/dist/monkey.d.ts +151 -0
- package/dist/monkey.d.ts.map +1 -0
- package/dist/monkey.js +323 -0
- package/dist/monkey.js.map +1 -0
- package/dist/persistence/index.d.ts +118 -0
- package/dist/persistence/index.d.ts.map +1 -0
- package/dist/persistence/index.js +196 -0
- package/dist/persistence/index.js.map +1 -0
- package/dist/planner/faults.d.ts +24 -0
- package/dist/planner/faults.d.ts.map +1 -0
- package/dist/planner/faults.js +128 -0
- package/dist/planner/faults.js.map +1 -0
- package/dist/planner/forms.d.ts +33 -0
- package/dist/planner/forms.d.ts.map +1 -0
- package/dist/planner/forms.js +163 -0
- package/dist/planner/forms.js.map +1 -0
- package/dist/planner/index.d.ts +31 -0
- package/dist/planner/index.d.ts.map +1 -0
- package/dist/planner/index.js +250 -0
- package/dist/planner/index.js.map +1 -0
- package/dist/planner/salvage.d.ts +16 -0
- package/dist/planner/salvage.d.ts.map +1 -0
- package/dist/planner/salvage.js +89 -0
- package/dist/planner/salvage.js.map +1 -0
- package/dist/runner/actions.d.ts +85 -0
- package/dist/runner/actions.d.ts.map +1 -0
- package/dist/runner/actions.js +610 -0
- package/dist/runner/actions.js.map +1 -0
- package/dist/runner/evidence.d.ts +37 -0
- package/dist/runner/evidence.d.ts.map +1 -0
- package/dist/runner/evidence.js +122 -0
- package/dist/runner/evidence.js.map +1 -0
- package/dist/runner/http5xx.d.ts +40 -0
- package/dist/runner/http5xx.d.ts.map +1 -0
- package/dist/runner/http5xx.js +189 -0
- package/dist/runner/http5xx.js.map +1 -0
- package/dist/runner/index.d.ts +88 -0
- package/dist/runner/index.d.ts.map +1 -0
- package/dist/runner/index.js +597 -0
- package/dist/runner/index.js.map +1 -0
- package/dist/runner/replay.d.ts +42 -0
- package/dist/runner/replay.d.ts.map +1 -0
- package/dist/runner/replay.js +440 -0
- package/dist/runner/replay.js.map +1 -0
- package/dist/runner/timeout.d.ts +16 -0
- package/dist/runner/timeout.d.ts.map +1 -0
- package/dist/runner/timeout.js +38 -0
- package/dist/runner/timeout.js.map +1 -0
- package/dist/trace/fingerprint.d.ts +78 -0
- package/dist/trace/fingerprint.d.ts.map +1 -0
- package/dist/trace/fingerprint.js +273 -0
- package/dist/trace/fingerprint.js.map +1 -0
- package/dist/trace/serialize.d.ts +15 -0
- package/dist/trace/serialize.d.ts.map +1 -0
- package/dist/trace/serialize.js +86 -0
- package/dist/trace/serialize.js.map +1 -0
- package/dist/triager/index.d.ts +64 -0
- package/dist/triager/index.d.ts.map +1 -0
- package/dist/triager/index.js +301 -0
- package/dist/triager/index.js.map +1 -0
- package/dist/types.d.ts +491 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +10 -0
- package/dist/types.js.map +1 -0
- package/dist/verify/index.d.ts +52 -0
- package/dist/verify/index.d.ts.map +1 -0
- package/dist/verify/index.js +140 -0
- package/dist/verify/index.js.map +1 -0
- package/dist/verify/verdict.d.ts +34 -0
- package/dist/verify/verdict.d.ts.map +1 -0
- package/dist/verify/verdict.js +89 -0
- package/dist/verify/verdict.js.map +1 -0
- package/package.json +90 -4
|
@@ -0,0 +1,491 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Explorer phase
|
|
3
|
+
*
|
|
4
|
+
* Drives Playwright through the site, capturing the structural skeleton of
|
|
5
|
+
* each page (title, headings, forms, buttons, links). The LLM is used per
|
|
6
|
+
* page to:
|
|
7
|
+
* - write a one-sentence summary of what the page is for
|
|
8
|
+
* - call out the salient interactive elements
|
|
9
|
+
* - guess whether the page is auth-gated
|
|
10
|
+
*
|
|
11
|
+
* After all pages are visited (or the budget is exhausted) the LLM does one
|
|
12
|
+
* final whole-site summary that names the site type ("ecommerce",
|
|
13
|
+
* "saas dashboard", etc.).
|
|
14
|
+
*
|
|
15
|
+
* Link order is still breadth-first, but a few slots are reserved for
|
|
16
|
+
* form / help / contact / support / about pages the crawl actually saw.
|
|
17
|
+
* A shop homepage full of product links cannot spend the whole `maxPages`
|
|
18
|
+
* budget before `/help` is visited. URLs that were never linked are not
|
|
19
|
+
* invented.
|
|
20
|
+
*
|
|
21
|
+
* Crawl scope is the site, not a single `URL.origin`. `http://shop.example/`
|
|
22
|
+
* and `https://www.shop.example/help` are the same site. Another host,
|
|
23
|
+
* another subdomain, or another explicit port is not. A redirect that stays
|
|
24
|
+
* on the site is recorded as the URL the browser landed on.
|
|
25
|
+
*
|
|
26
|
+
* What the explorer is NOT:
|
|
27
|
+
* - It does not log in. Auth-gated flows are surfaced to the planner so
|
|
28
|
+
* they can be flagged as `auth_required` later.
|
|
29
|
+
* - It does not click destructive buttons. The visit is read-only.
|
|
30
|
+
*/
|
|
31
|
+
import { chromium } from 'playwright';
|
|
32
|
+
import { basename } from 'node:path';
|
|
33
|
+
import { mkdirSync } from 'node:fs';
|
|
34
|
+
import { join, resolve } from 'node:path';
|
|
35
|
+
import { z } from 'zod';
|
|
36
|
+
import { noopBus } from '../events.js';
|
|
37
|
+
import { canonicalPageUrl, crawledPageUrl, enqueueLinks, FORM_SURFACE_PATH_SOURCE, FORM_SURFACE_TEXT_SOURCE, isFormSurfaceLink, linksOnCrawlSite, pickNextCrawlUrl, rememberVisited, selectOutboundLinks, wasVisited, } from './queue.js';
|
|
38
|
+
export async function explore(startUrl, llm, opts = {}) {
|
|
39
|
+
const maxPages = opts.maxPages ?? 8;
|
|
40
|
+
const timeout = opts.pageTimeoutMs ?? 20_000;
|
|
41
|
+
const headless = opts.headless ?? true;
|
|
42
|
+
const events = opts.events ?? noopBus();
|
|
43
|
+
const visited = new Set();
|
|
44
|
+
const start = canonicalPageUrl(startUrl);
|
|
45
|
+
const queue = [{ url: start, surface: isFormSurfaceLink({ url: start }) }];
|
|
46
|
+
const pages = [];
|
|
47
|
+
const failures = [];
|
|
48
|
+
let authUrlsQueued = 0;
|
|
49
|
+
let surfaceVisited = 0;
|
|
50
|
+
const screenshotsDir = opts.screenshotsDir ? resolve(opts.screenshotsDir) : null;
|
|
51
|
+
if (screenshotsDir) {
|
|
52
|
+
mkdirSync(screenshotsDir, { recursive: true });
|
|
53
|
+
}
|
|
54
|
+
events.emit({
|
|
55
|
+
phase: 'explorer', type: 'explore.start',
|
|
56
|
+
message: `Crawling ${startUrl}…`,
|
|
57
|
+
data: { startUrl, maxPages },
|
|
58
|
+
});
|
|
59
|
+
const browser = await chromium.launch({ headless });
|
|
60
|
+
try {
|
|
61
|
+
const context = await browser.newContext({
|
|
62
|
+
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 13_0) AppleWebKit/537.36 '
|
|
63
|
+
+ '(KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 monkeytest.ai',
|
|
64
|
+
viewport: { width: 1280, height: 800 },
|
|
65
|
+
});
|
|
66
|
+
while (queue.length > 0 && pages.length < maxPages) {
|
|
67
|
+
const index = pickNextCrawlUrl(queue, {
|
|
68
|
+
pagesVisited: pages.length,
|
|
69
|
+
maxPages,
|
|
70
|
+
surfaceVisited,
|
|
71
|
+
});
|
|
72
|
+
if (index < 0)
|
|
73
|
+
break;
|
|
74
|
+
const next = queue.splice(index, 1)[0];
|
|
75
|
+
if (!next || wasVisited(visited, next.url))
|
|
76
|
+
continue;
|
|
77
|
+
const requestedUrl = next.url;
|
|
78
|
+
rememberVisited(visited, requestedUrl);
|
|
79
|
+
const page = await context.newPage();
|
|
80
|
+
try {
|
|
81
|
+
await page.goto(requestedUrl, { waitUntil: 'domcontentloaded', timeout });
|
|
82
|
+
const url = crawledPageUrl(requestedUrl, page.url(), startUrl);
|
|
83
|
+
rememberVisited(visited, url);
|
|
84
|
+
// SPAs (CRA, Next dev, Vite) often keep a websocket open for HMR so
|
|
85
|
+
// networkidle never settles. We give it a brief shot, then fall back
|
|
86
|
+
// to a `waitForFunction` that polls for actual rendered content.
|
|
87
|
+
await page.waitForLoadState('networkidle', { timeout: 5_000 }).catch(() => { });
|
|
88
|
+
await page.waitForFunction(() => (document.body?.innerText || '').replace(/\s+/g, '').length > 30, undefined, { timeout: 8_000 }).catch(() => { });
|
|
89
|
+
const skeleton = await scrapePageSkeleton(page);
|
|
90
|
+
// Screenshot each visited page if a directory was provided. Filename
|
|
91
|
+
// is a deterministic, filesystem-safe hash of the URL so subsequent
|
|
92
|
+
// runs can reference the same path.
|
|
93
|
+
let screenshotPath;
|
|
94
|
+
if (screenshotsDir) {
|
|
95
|
+
const filename = `page-${pages.length + 1}-${slugifyUrl(url)}.png`;
|
|
96
|
+
const fullPath = join(screenshotsDir, filename);
|
|
97
|
+
try {
|
|
98
|
+
await page.screenshot({ path: fullPath, fullPage: false });
|
|
99
|
+
screenshotPath = fullPath;
|
|
100
|
+
events.emit({
|
|
101
|
+
phase: 'explorer', type: 'explore.screenshot',
|
|
102
|
+
message: `Captured screenshot of ${url}`,
|
|
103
|
+
data: { url, screenshot: basename(fullPath) },
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
catch (err) {
|
|
107
|
+
// Don't fail the crawl just because a screenshot didn't save.
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// The LLM summarisation is best-effort. If it fails (404 model id,
|
|
111
|
+
// 503, schema mismatch, …) we still want the page recorded with the
|
|
112
|
+
// skeleton we already scraped — losing a screenshot + the entire page
|
|
113
|
+
// because the LLM returned malformed JSON is overkill.
|
|
114
|
+
let summary;
|
|
115
|
+
try {
|
|
116
|
+
summary = await summarisePageWithLLM(llm, url, skeleton);
|
|
117
|
+
}
|
|
118
|
+
catch (err) {
|
|
119
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
120
|
+
opts.onPage?.({
|
|
121
|
+
url,
|
|
122
|
+
title: skeleton.title,
|
|
123
|
+
summary: `(LLM summary unavailable: ${reason.slice(0, 120)})`,
|
|
124
|
+
interactive: [],
|
|
125
|
+
outboundLinks: [],
|
|
126
|
+
authGated: false,
|
|
127
|
+
});
|
|
128
|
+
summary = {
|
|
129
|
+
summary: skeleton.title || `Page at ${url} (LLM summary unavailable)`,
|
|
130
|
+
interactive: [],
|
|
131
|
+
authGated: false,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
const forms = skeleton.forms.filter(form => form.action || form.fields.length > 0 || form.submitLabel);
|
|
135
|
+
const controls = skeleton.controls.filter(control => control.label);
|
|
136
|
+
const outbound = selectOutboundLinks(linksOnCrawlSite(skeleton.links, startUrl));
|
|
137
|
+
const sm = {
|
|
138
|
+
url,
|
|
139
|
+
title: skeleton.title,
|
|
140
|
+
summary: summary.summary,
|
|
141
|
+
interactive: withScrapedForm(summary.interactive, forms),
|
|
142
|
+
outboundLinks: outbound.map(link => link.url),
|
|
143
|
+
...(forms.length ? { forms } : {}),
|
|
144
|
+
...(controls.length ? { controls } : {}),
|
|
145
|
+
authGated: summary.authGated,
|
|
146
|
+
...(screenshotPath ? { screenshotPath } : {}),
|
|
147
|
+
};
|
|
148
|
+
pages.push(sm);
|
|
149
|
+
if (isFormSurfaceLink({ url: sm.url, text: sm.title }))
|
|
150
|
+
surfaceVisited += 1;
|
|
151
|
+
opts.onPage?.(sm);
|
|
152
|
+
events.emit({
|
|
153
|
+
phase: 'explorer', type: 'explore.page_visited',
|
|
154
|
+
message: `Explored ${url}`,
|
|
155
|
+
data: {
|
|
156
|
+
url,
|
|
157
|
+
title: sm.title,
|
|
158
|
+
summary: sm.summary,
|
|
159
|
+
screenshot: screenshotPath ? basename(screenshotPath) : undefined,
|
|
160
|
+
authGated: sm.authGated,
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
// Auth walls eat crawl budget and produce login-only test plans.
|
|
164
|
+
// Cap obvious auth URLs at one visit so the planner still knows a
|
|
165
|
+
// login surface exists. Form/help links stay in the queue and are
|
|
166
|
+
// pulled forward while the surface reserve is unfilled.
|
|
167
|
+
if (!sm.authGated) {
|
|
168
|
+
authUrlsQueued = enqueueLinks(queue, visited, outbound, authUrlsQueued);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
catch (err) {
|
|
172
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
173
|
+
failures.push({ url: requestedUrl, reason });
|
|
174
|
+
events.emit({
|
|
175
|
+
phase: 'explorer', type: 'explore.page_failed',
|
|
176
|
+
message: `Failed to load ${requestedUrl}`,
|
|
177
|
+
data: { url: requestedUrl, reason },
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
finally {
|
|
181
|
+
await page.close().catch(() => { });
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
const overall = await summariseSiteWithLLM(llm, startUrl, pages);
|
|
185
|
+
events.emit({
|
|
186
|
+
phase: 'explorer', type: 'explore.complete',
|
|
187
|
+
message: `Crawl complete: ${pages.length} page${pages.length === 1 ? '' : 's'} visited`
|
|
188
|
+
+ (failures.length ? `, ${failures.length} failed.` : '.'),
|
|
189
|
+
data: {
|
|
190
|
+
siteType: overall.siteType,
|
|
191
|
+
pagesVisited: pages.length,
|
|
192
|
+
pagesFailed: failures.length,
|
|
193
|
+
},
|
|
194
|
+
});
|
|
195
|
+
return {
|
|
196
|
+
startUrl,
|
|
197
|
+
siteType: overall.siteType,
|
|
198
|
+
summary: overall.summary,
|
|
199
|
+
productName: overall.productName ?? undefined,
|
|
200
|
+
publicJourneys: overall.publicJourneys ?? undefined,
|
|
201
|
+
authSurfaces: overall.authSurfaces ?? undefined,
|
|
202
|
+
pages,
|
|
203
|
+
pendingUrls: queue.map(item => item.url),
|
|
204
|
+
failedUrls: failures,
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
finally {
|
|
208
|
+
await browser.close().catch(() => { });
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
async function scrapePageSkeleton(page) {
|
|
212
|
+
const url = page.url();
|
|
213
|
+
const title = await page.title().catch(() => '');
|
|
214
|
+
// Use page.evaluate for one cheap round-trip to collect everything we need.
|
|
215
|
+
// Keep every form/help-style anchor, plus the first 80 ordinary ones, so a
|
|
216
|
+
// long product grid cannot drop a footer "Help" link before it leaves the page.
|
|
217
|
+
const collected = await page.evaluate(({ pathSource, textSource }) => {
|
|
218
|
+
function txt(el) {
|
|
219
|
+
return (el.textContent || '').trim().replace(/\s+/g, ' ');
|
|
220
|
+
}
|
|
221
|
+
const headings = Array.from(document.querySelectorAll('h1, h2, h3'))
|
|
222
|
+
.map(txt)
|
|
223
|
+
.filter(Boolean)
|
|
224
|
+
.slice(0, 20);
|
|
225
|
+
const pathRe = new RegExp(pathSource, 'i');
|
|
226
|
+
const textRe = new RegExp(textSource, 'i');
|
|
227
|
+
const anchors = Array.from(document.querySelectorAll('a[href]'))
|
|
228
|
+
.map(a => ({
|
|
229
|
+
url: a.href,
|
|
230
|
+
text: txt(a).slice(0, 80),
|
|
231
|
+
}))
|
|
232
|
+
.filter(link => link.url);
|
|
233
|
+
const surfaceUrls = new Set();
|
|
234
|
+
const ordinaryUrls = new Set();
|
|
235
|
+
for (const link of anchors) {
|
|
236
|
+
let path = link.url;
|
|
237
|
+
try {
|
|
238
|
+
const parsed = new URL(link.url);
|
|
239
|
+
path = `${parsed.pathname}${parsed.search}`;
|
|
240
|
+
}
|
|
241
|
+
catch { /* keep the raw href */ }
|
|
242
|
+
const surface = pathRe.test(path) || (link.text ? textRe.test(link.text) : false);
|
|
243
|
+
if (surface)
|
|
244
|
+
surfaceUrls.add(link.url);
|
|
245
|
+
else if (ordinaryUrls.size < 80)
|
|
246
|
+
ordinaryUrls.add(link.url);
|
|
247
|
+
}
|
|
248
|
+
const seen = new Set();
|
|
249
|
+
const links = anchors.filter(link => {
|
|
250
|
+
if (seen.has(link.url))
|
|
251
|
+
return false;
|
|
252
|
+
if (!surfaceUrls.has(link.url) && !ordinaryUrls.has(link.url))
|
|
253
|
+
return false;
|
|
254
|
+
seen.add(link.url);
|
|
255
|
+
return true;
|
|
256
|
+
});
|
|
257
|
+
function fieldLabel(el) {
|
|
258
|
+
const control = el;
|
|
259
|
+
if (control.id) {
|
|
260
|
+
const byFor = document.querySelector(`label[for="${CSS.escape(control.id)}"]`);
|
|
261
|
+
if (byFor) {
|
|
262
|
+
const text = txt(byFor);
|
|
263
|
+
if (text)
|
|
264
|
+
return text.slice(0, 80);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
const aria = control.getAttribute('aria-label');
|
|
268
|
+
if (aria && aria.trim())
|
|
269
|
+
return aria.trim().replace(/\s+/g, ' ').slice(0, 80);
|
|
270
|
+
const labelledBy = control.getAttribute('aria-labelledby');
|
|
271
|
+
if (labelledBy) {
|
|
272
|
+
const text = labelledBy.split(/\s+/).map(id => {
|
|
273
|
+
const node = document.getElementById(id);
|
|
274
|
+
return node ? txt(node) : '';
|
|
275
|
+
}).filter(Boolean).join(' ').trim();
|
|
276
|
+
if (text)
|
|
277
|
+
return text.slice(0, 80);
|
|
278
|
+
}
|
|
279
|
+
const parent = control.closest('label');
|
|
280
|
+
if (parent) {
|
|
281
|
+
const clone = parent.cloneNode(true);
|
|
282
|
+
clone.querySelectorAll('input, textarea, select').forEach(node => node.remove());
|
|
283
|
+
const text = txt(clone);
|
|
284
|
+
if (text)
|
|
285
|
+
return text.slice(0, 80);
|
|
286
|
+
}
|
|
287
|
+
return '';
|
|
288
|
+
}
|
|
289
|
+
const forms = Array.from(document.querySelectorAll('form')).slice(0, 10).map(f => {
|
|
290
|
+
const form = f;
|
|
291
|
+
const controls = Array.from(form.querySelectorAll('input, textarea, select')).flatMap(i => {
|
|
292
|
+
const el = i;
|
|
293
|
+
const type = (el.type || el.tagName || '').toLowerCase();
|
|
294
|
+
if (type === 'hidden' || type === 'submit' || type === 'button' || type === 'image' || type === 'reset')
|
|
295
|
+
return [];
|
|
296
|
+
const name = el.name || '';
|
|
297
|
+
const placeholder = el.placeholder || '';
|
|
298
|
+
const label = fieldLabel(el);
|
|
299
|
+
const token = name || placeholder || type;
|
|
300
|
+
if (!token)
|
|
301
|
+
return [];
|
|
302
|
+
return [{
|
|
303
|
+
token,
|
|
304
|
+
...(name ? { name } : {}),
|
|
305
|
+
...(label ? { label } : {}),
|
|
306
|
+
...(placeholder ? { placeholder } : {}),
|
|
307
|
+
...(type ? { type } : {}),
|
|
308
|
+
}];
|
|
309
|
+
});
|
|
310
|
+
const submit = form.querySelector('button[type="submit"], input[type="submit"], button:not([type])');
|
|
311
|
+
const submitLabel = submit ? (txt(submit) || submit.value || '') : '';
|
|
312
|
+
return {
|
|
313
|
+
action: form.action || '',
|
|
314
|
+
method: (form.method || 'get').toLowerCase(),
|
|
315
|
+
fields: controls.map(control => control.token),
|
|
316
|
+
...(controls.length ? {
|
|
317
|
+
inputs: controls.map(control => ({
|
|
318
|
+
...(control.name ? { name: control.name } : {}),
|
|
319
|
+
...(control.label ? { label: control.label } : {}),
|
|
320
|
+
...(control.placeholder ? { placeholder: control.placeholder } : {}),
|
|
321
|
+
...(control.type ? { type: control.type } : {}),
|
|
322
|
+
})),
|
|
323
|
+
} : {}),
|
|
324
|
+
...(submitLabel ? { submitLabel: submitLabel.slice(0, 80) } : {}),
|
|
325
|
+
};
|
|
326
|
+
});
|
|
327
|
+
const buttonControls = Array.from(document.querySelectorAll('button, [role="button"], input[type="submit"], input[type="button"]'))
|
|
328
|
+
.map(b => {
|
|
329
|
+
const label = (txt(b) || b.value || '').slice(0, 80);
|
|
330
|
+
const disabled = Boolean(b.disabled) || b.getAttribute('aria-disabled') === 'true';
|
|
331
|
+
return { kind: 'button', label, ...(disabled ? { disabled: true } : {}) };
|
|
332
|
+
})
|
|
333
|
+
.filter(control => control.label);
|
|
334
|
+
const buttons = [
|
|
335
|
+
...buttonControls.filter(control => control.disabled),
|
|
336
|
+
...buttonControls.filter(control => !control.disabled),
|
|
337
|
+
].slice(0, 40);
|
|
338
|
+
const linkControls = links
|
|
339
|
+
.filter(link => link.text)
|
|
340
|
+
.slice(0, 40)
|
|
341
|
+
.map(link => ({ kind: 'link', label: link.text.slice(0, 80), href: link.url }));
|
|
342
|
+
const visibleText = (document.body?.innerText || '').replace(/\s+/g, ' ').trim().slice(0, 2200);
|
|
343
|
+
return { headings, links, forms, buttons: buttons.map(control => control.label), controls: [...buttons, ...linkControls], visibleText };
|
|
344
|
+
}, {
|
|
345
|
+
pathSource: FORM_SURFACE_PATH_SOURCE,
|
|
346
|
+
textSource: FORM_SURFACE_TEXT_SOURCE,
|
|
347
|
+
});
|
|
348
|
+
return {
|
|
349
|
+
url,
|
|
350
|
+
title,
|
|
351
|
+
headings: collected.headings,
|
|
352
|
+
visibleText: collected.visibleText,
|
|
353
|
+
links: collected.links,
|
|
354
|
+
forms: collected.forms,
|
|
355
|
+
buttons: collected.buttons,
|
|
356
|
+
controls: collected.controls,
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
/* ── LLM: per-page summary ────────────────────────────────────────────── */
|
|
360
|
+
const PageSummarySchema = z.object({
|
|
361
|
+
summary: z.string().min(3),
|
|
362
|
+
authGated: z.boolean(),
|
|
363
|
+
interactive: z.array(z.object({
|
|
364
|
+
kind: z.enum(['form', 'button', 'link', 'input', 'menu']),
|
|
365
|
+
label: z.string().min(1),
|
|
366
|
+
selector: z.string().optional(),
|
|
367
|
+
})).optional(),
|
|
368
|
+
});
|
|
369
|
+
async function summarisePageWithLLM(llm, url, skeleton) {
|
|
370
|
+
const prompt = `
|
|
371
|
+
You are a QA analyst inspecting a single web page during an exploratory crawl.
|
|
372
|
+
Based on the page metadata below, return JSON with three fields:
|
|
373
|
+
|
|
374
|
+
- "summary": one sentence (max 30 words) naming the page's job for a visitor (e.g. "CRED marketing homepage promoting credit-card rewards").
|
|
375
|
+
- "authGated": boolean — true if the page is a login/OTP wall, or clearly requires an existing session. A marketing page that merely links to Sign in is NOT auth-gated.
|
|
376
|
+
- "interactive": up to 10 of the most important interactive elements a tester should care about (primary CTAs first). Each item has:
|
|
377
|
+
kind — one of "form" | "button" | "link" | "input" | "menu"
|
|
378
|
+
label — the human-readable label or visible text (max 60 chars)
|
|
379
|
+
selector — optional CSS selector if you can confidently infer one (otherwise omit)
|
|
380
|
+
|
|
381
|
+
URL: ${url}
|
|
382
|
+
Title: ${skeleton.title}
|
|
383
|
+
|
|
384
|
+
Headings:
|
|
385
|
+
${skeleton.headings.map(h => ` - ${h}`).join('\n') || ' (none)'}
|
|
386
|
+
|
|
387
|
+
Buttons:
|
|
388
|
+
${skeleton.buttons.map(b => ` - ${b}`).join('\n') || ' (none)'}
|
|
389
|
+
|
|
390
|
+
Forms:
|
|
391
|
+
${skeleton.forms.map((f, i) => ` ${i + 1}. method=${f.method || 'get'} action=${f.action || '(none)'} submit=${f.submitLabel || '(none)'} fields=[${f.fields.join(', ')}]`).join('\n') || ' (none)'}
|
|
392
|
+
|
|
393
|
+
Visible text (excerpt):
|
|
394
|
+
${skeleton.visibleText || '(empty)'}
|
|
395
|
+
|
|
396
|
+
Reply with JSON only.
|
|
397
|
+
`;
|
|
398
|
+
const parsed = await llm.generateJSON({
|
|
399
|
+
label: 'explorer.summarisePage',
|
|
400
|
+
prompt,
|
|
401
|
+
schema: PageSummarySchema,
|
|
402
|
+
});
|
|
403
|
+
return {
|
|
404
|
+
summary: parsed.summary,
|
|
405
|
+
authGated: parsed.authGated,
|
|
406
|
+
interactive: parsed.interactive ?? [],
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
/* ── LLM: whole-site summary ──────────────────────────────────────────── */
|
|
410
|
+
const SiteSummarySchema = z.object({
|
|
411
|
+
siteType: z.string().min(2),
|
|
412
|
+
summary: z.string().min(3),
|
|
413
|
+
productName: z.string().min(1).nullish(),
|
|
414
|
+
publicJourneys: z.array(z.string().min(3)).max(6).nullish(),
|
|
415
|
+
authSurfaces: z.array(z.string().min(2)).max(6).nullish(),
|
|
416
|
+
});
|
|
417
|
+
async function summariseSiteWithLLM(llm, startUrl, pages) {
|
|
418
|
+
if (pages.length === 0) {
|
|
419
|
+
return { siteType: 'unknown', summary: 'No pages were successfully visited.' };
|
|
420
|
+
}
|
|
421
|
+
const prompt = `
|
|
422
|
+
You just finished exploring a website as an anonymous visitor (you never logged in).
|
|
423
|
+
Understand the product, then describe it so a QA architect can design real user tests.
|
|
424
|
+
|
|
425
|
+
Return JSON:
|
|
426
|
+
- "siteType": short category, e.g. "ecommerce", "fintech consumer app", "saas marketing site",
|
|
427
|
+
"blog", "documentation", "marketplace", "internal tool", "other".
|
|
428
|
+
- "productName": brand or product name if obvious, else omit.
|
|
429
|
+
- "summary": 2–3 sentences (max 90 words): what the product does, who the visitor is,
|
|
430
|
+
and which jobs they can complete WITHOUT an account.
|
|
431
|
+
- "publicJourneys": up to 5 concrete anonymous journeys grounded in the pages below
|
|
432
|
+
(e.g. "Read credit-card benefits and open Apply"). Do not invent pages.
|
|
433
|
+
- "authSurfaces": login / signup / OTP walls you noticed. Empty array if none.
|
|
434
|
+
|
|
435
|
+
Start URL: ${startUrl}
|
|
436
|
+
|
|
437
|
+
Pages visited:
|
|
438
|
+
${pages.map(p => ` - ${p.url}\n title: ${p.title}\n auth-gated: ${p.authGated}\n summary: ${p.summary}\n interactive: ${p.interactive.map(i => i.label).join(', ') || '(none)'}`).join('\n')}
|
|
439
|
+
|
|
440
|
+
Reply with JSON only.
|
|
441
|
+
`;
|
|
442
|
+
const parsed = await llm.generateJSON({
|
|
443
|
+
label: 'explorer.summariseSite',
|
|
444
|
+
prompt,
|
|
445
|
+
schema: SiteSummarySchema,
|
|
446
|
+
});
|
|
447
|
+
return {
|
|
448
|
+
siteType: parsed.siteType,
|
|
449
|
+
summary: parsed.summary,
|
|
450
|
+
productName: parsed.productName ?? undefined,
|
|
451
|
+
publicJourneys: parsed.publicJourneys ?? undefined,
|
|
452
|
+
authSurfaces: parsed.authSurfaces ?? undefined,
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
/* ── Helpers ──────────────────────────────────────────────────────────── */
|
|
456
|
+
/**
|
|
457
|
+
* Filesystem-safe filename slug derived from a URL. Caps length so we don't
|
|
458
|
+
* blow past OS path limits on deep URLs.
|
|
459
|
+
*/
|
|
460
|
+
function slugifyUrl(u) {
|
|
461
|
+
try {
|
|
462
|
+
const url = new URL(u);
|
|
463
|
+
const raw = (url.hostname + url.pathname + url.search)
|
|
464
|
+
.toLowerCase()
|
|
465
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
466
|
+
.replace(/^-+|-+$/g, '');
|
|
467
|
+
return raw.slice(0, 80) || 'page';
|
|
468
|
+
}
|
|
469
|
+
catch {
|
|
470
|
+
return 'page';
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
function withScrapedForm(interactive, forms) {
|
|
474
|
+
if (forms.length === 0 || interactive.some(item => item.kind === 'form'))
|
|
475
|
+
return interactive;
|
|
476
|
+
const form = [...forms].sort((a, b) => scrapedFormRank(b) - scrapedFormRank(a))[0];
|
|
477
|
+
const label = (form.submitLabel || form.fields.slice(0, 3).join(', ') || 'form').slice(0, 60);
|
|
478
|
+
return [...interactive, { kind: 'form', label }];
|
|
479
|
+
}
|
|
480
|
+
/** Header search boxes sort below a POST form so the planner sees the contact control. */
|
|
481
|
+
function scrapedFormRank(form) {
|
|
482
|
+
let score = 0;
|
|
483
|
+
if ((form.method || 'get').toLowerCase() === 'post')
|
|
484
|
+
score += 2;
|
|
485
|
+
if (form.submitLabel)
|
|
486
|
+
score += 1;
|
|
487
|
+
if (/\/search(?:\/|$|\?)/i.test(form.action || ''))
|
|
488
|
+
score -= 2;
|
|
489
|
+
return score;
|
|
490
|
+
}
|
|
491
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/explorer/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,QAAQ,EAA2B,MAAM,YAAY,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAiB,OAAO,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,wBAAwB,EACxB,wBAAwB,EACxB,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,UAAU,GAGX,MAAM,YAAY,CAAC;AAsBpB,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,QAAgB,EAChB,GAAQ,EACR,OAAuB,EAAE;IAGzB,MAAM,QAAQ,GAA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EAAE,CAAC,eAAe,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACnF,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC9F,OAAO,CAAC,GAAG,WAAW,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;AACnD,CAAC;AAED,0FAA0F;AAC1F,SAAS,eAAe,CAAC,IAAiB;IACxC,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC,WAAW,EAAE,KAAK,MAAM;QAAE,KAAK,IAAI,CAAC,CAAC;IAChE,IAAI,IAAI,CAAC,WAAW;QAAE,KAAK,IAAI,CAAC,CAAC;IACjC,IAAI,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;QAAE,KAAK,IAAI,CAAC,CAAC;IAC/D,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Crawl-order helpers.
|
|
3
|
+
*
|
|
4
|
+
* The explorer used to walk links FIFO. On a shop homepage the first links
|
|
5
|
+
* are category and product URLs, so a small `maxPages` never reaches the
|
|
6
|
+
* contact form in the header or footer. These helpers keep that BFS, but
|
|
7
|
+
* reserve a few slots for form / help / contact / support / about pages the
|
|
8
|
+
* crawl actually saw. They never invent URLs.
|
|
9
|
+
*
|
|
10
|
+
* Scope is the site. `http://shop.example/` and `https://www.shop.example/help`
|
|
11
|
+
* are the same site. Another subdomain, another host, or another explicit
|
|
12
|
+
* port is not enqueued.
|
|
13
|
+
*/
|
|
14
|
+
export interface DiscoveredLink {
|
|
15
|
+
url: string;
|
|
16
|
+
text?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface CrawlQueueItem {
|
|
19
|
+
url: string;
|
|
20
|
+
/** True when the URL or its anchor text looks like a public form surface. */
|
|
21
|
+
surface: boolean;
|
|
22
|
+
}
|
|
23
|
+
/** Passed into the page so the scraper can keep footer/help links past a long product grid. */
|
|
24
|
+
export declare const FORM_SURFACE_PATH_SOURCE: string;
|
|
25
|
+
export declare const FORM_SURFACE_TEXT_SOURCE: string;
|
|
26
|
+
export declare function canonicalPageUrl(value: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* Identity of a page inside one crawl. `www` and the apex host are the same
|
|
29
|
+
* page. `http` and `https` are the same page. An explicit port stays
|
|
30
|
+
* distinct, so `:8080` is not `:80`.
|
|
31
|
+
*
|
|
32
|
+
* This is wider than the runner's HTTP 5xx host check on purpose. A start
|
|
33
|
+
* URL of `http://shop.example/` often redirects to `https://www.shop.example/`,
|
|
34
|
+
* and the crawl has to follow that. A 5xx on a different scheme is still a
|
|
35
|
+
* different listener, so the oracle does not use this key.
|
|
36
|
+
*/
|
|
37
|
+
export declare function crawlPathKey(value: string): string | undefined;
|
|
38
|
+
/** True when both URLs are the same path on the same crawl site. */
|
|
39
|
+
export declare function sameCrawlPage(a: string, b: string): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* True when `href` is an http(s) document on the same site as `scope`.
|
|
42
|
+
* `www` and the apex host match. `http` and `https` match. A non-default
|
|
43
|
+
* port must match. Other subdomains, other hosts, `mailto:`, and common
|
|
44
|
+
* asset types are not crawl targets.
|
|
45
|
+
*/
|
|
46
|
+
export declare function isSameCrawlSite(href: string, scope: string): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Links the explorer may enqueue. Off-site, asset, and non-http URLs are
|
|
49
|
+
* dropped. The returned URL is canonical. Anchor text is kept so a footer
|
|
50
|
+
* "Help" link is still recognised as a form surface.
|
|
51
|
+
*/
|
|
52
|
+
export declare function linksOnCrawlSite(links: DiscoveredLink[], scope: string): DiscoveredLink[];
|
|
53
|
+
/**
|
|
54
|
+
* URL to record after navigation. Prefer the URL the browser settled on
|
|
55
|
+
* when the redirect stayed on this site (`http://apex` → `https://www`).
|
|
56
|
+
* An open redirect to another host keeps the URL we asked for, and its
|
|
57
|
+
* links are not followed.
|
|
58
|
+
*/
|
|
59
|
+
export declare function crawledPageUrl(requested: string, landed: string, scope: string): string;
|
|
60
|
+
/** Record a URL and its scheme/www-insensitive path so the twin is not crawled again. */
|
|
61
|
+
export declare function rememberVisited(visited: Set<string>, url: string): void;
|
|
62
|
+
export declare function wasVisited(visited: ReadonlySet<string>, url: string): boolean;
|
|
63
|
+
export declare function looksLikeAuthUrl(value: string): boolean;
|
|
64
|
+
/** Public form / help / contact / about style link. Auth walls are not surfaces. */
|
|
65
|
+
export declare function isFormSurfaceLink(link: DiscoveredLink): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* How many visited pages should be form/help surfaces before the crawl goes
|
|
68
|
+
* back to ordinary BFS. `maxPages` of 1 can only be the start URL.
|
|
69
|
+
*/
|
|
70
|
+
export declare function formReserveCount(maxPages: number): number;
|
|
71
|
+
/**
|
|
72
|
+
* Keep every form-surface link (so a footer "Help" past a long product grid
|
|
73
|
+
* is not dropped) plus the first `cap` ordinary links, in document order.
|
|
74
|
+
*/
|
|
75
|
+
export declare function selectOutboundLinks(links: DiscoveredLink[], cap?: number): DiscoveredLink[];
|
|
76
|
+
/** Index to visit next. Form surfaces jump the queue until the reserve is filled. */
|
|
77
|
+
export declare function pickNextCrawlUrl(queue: CrawlQueueItem[], opts: {
|
|
78
|
+
pagesVisited: number;
|
|
79
|
+
maxPages: number;
|
|
80
|
+
surfaceVisited: number;
|
|
81
|
+
}): number;
|
|
82
|
+
export declare function enqueueLinks(queue: CrawlQueueItem[], visited: ReadonlySet<string>, links: DiscoveredLink[], authUrlsQueued: number, authLimit?: number): number;
|
|
83
|
+
/**
|
|
84
|
+
* Pure stand-in for the explorer loop. `edges` maps a visited URL to the
|
|
85
|
+
* links discovered on that page. Off-site links are dropped with the same
|
|
86
|
+
* site rule `explore` uses, so an `http://` apex start whose anchors were
|
|
87
|
+
* rewritten to `https://www` still reaches `/help`.
|
|
88
|
+
*/
|
|
89
|
+
export declare function planCrawlOrder(input: {
|
|
90
|
+
startUrl: string;
|
|
91
|
+
maxPages: number;
|
|
92
|
+
edges: Record<string, DiscoveredLink[]>;
|
|
93
|
+
}): string[];
|
|
94
|
+
//# sourceMappingURL=queue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../src/explorer/queue.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,6EAA6E;IAC7E,OAAO,EAAE,OAAO,CAAC;CAClB;AAMD,+FAA+F;AAC/F,eAAO,MAAM,wBAAwB,QAAsB,CAAC;AAC5D,eAAO,MAAM,wBAAwB,QAAsB,CAAC;AAI5D,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAWtD;AAID;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAU9D;AAED,oEAAoE;AACpE,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAK3D;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAcpE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,cAAc,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,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