vibecode-anything 0.3.0 → 0.4.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/README.md +239 -67
- package/dist/cli.js +2140 -73
- package/dist/core/adapters.d.ts +26 -3
- package/dist/core/adapters.js +411 -25
- package/dist/core/agent-adapter.d.ts +67 -0
- package/dist/core/agent-adapter.js +312 -0
- package/dist/core/anti-cheat.d.ts +6 -0
- package/dist/core/anti-cheat.js +372 -0
- package/dist/core/badge.d.ts +18 -0
- package/dist/core/badge.js +360 -0
- package/dist/core/cache.d.ts +47 -0
- package/dist/core/cache.js +403 -0
- package/dist/core/ci-export.d.ts +35 -0
- package/dist/core/ci-export.js +796 -0
- package/dist/core/ci-formats.d.ts +21 -0
- package/dist/core/ci-formats.js +388 -0
- package/dist/core/client-codegen.d.ts +36 -0
- package/dist/core/client-codegen.js +2538 -0
- package/dist/core/compose.d.ts +71 -0
- package/dist/core/compose.js +1088 -0
- package/dist/core/docs-export.d.ts +37 -0
- package/dist/core/docs-export.js +2706 -0
- package/dist/core/doctor.d.ts +21 -1
- package/dist/core/doctor.js +234 -21
- package/dist/core/exec.d.ts +26 -2
- package/dist/core/exec.js +235 -8
- package/dist/core/fixtures.d.ts +153 -0
- package/dist/core/fixtures.js +2245 -0
- package/dist/core/format.d.ts +77 -0
- package/dist/core/format.js +632 -0
- package/dist/core/fs-snapshot.d.ts +37 -0
- package/dist/core/fs-snapshot.js +216 -0
- package/dist/core/graphql-export.d.ts +34 -0
- package/dist/core/graphql-export.js +2482 -0
- package/dist/core/har-export.d.ts +29 -0
- package/dist/core/har-export.js +988 -0
- package/dist/core/html-report.d.ts +27 -0
- package/dist/core/html-report.js +1535 -0
- package/dist/core/http-export.d.ts +31 -0
- package/dist/core/http-export.js +726 -0
- package/dist/core/impact.d.ts +80 -0
- package/dist/core/impact.js +1412 -0
- package/dist/core/lint.d.ts +38 -0
- package/dist/core/lint.js +1111 -0
- package/dist/core/load-export.d.ts +37 -0
- package/dist/core/load-export.js +1813 -0
- package/dist/core/mcp-export.d.ts +35 -0
- package/dist/core/mcp-export.js +1736 -0
- package/dist/core/mock-server.d.ts +47 -0
- package/dist/core/mock-server.js +1722 -0
- package/dist/core/openapi-export.d.ts +44 -0
- package/dist/core/openapi-export.js +1074 -0
- package/dist/core/parity.d.ts +6 -1
- package/dist/core/parity.js +36 -1
- package/dist/core/playwright-exporter.d.ts +23 -0
- package/dist/core/playwright-exporter.js +1343 -0
- package/dist/core/png.js +45 -9
- package/dist/core/regression.d.ts +54 -0
- package/dist/core/regression.js +529 -0
- package/dist/core/responsive.d.ts +86 -0
- package/dist/core/responsive.js +606 -0
- package/dist/core/run.d.ts +74 -0
- package/dist/core/run.js +696 -0
- package/dist/core/scheduler.d.ts +24 -0
- package/dist/core/scheduler.js +162 -0
- package/dist/core/schema-export.d.ts +29 -0
- package/dist/core/schema-export.js +2215 -0
- package/dist/core/schema.d.ts +3 -2
- package/dist/core/schema.js +460 -17
- package/dist/core/security.d.ts +233 -0
- package/dist/core/security.js +1839 -0
- package/dist/core/server-export.d.ts +38 -0
- package/dist/core/server-export.js +3198 -0
- package/dist/core/spec-writer.d.ts +9 -0
- package/dist/core/spec-writer.js +1202 -0
- package/dist/core/store.d.ts +11 -2
- package/dist/core/store.js +128 -8
- package/dist/core/target-map.d.ts +34 -0
- package/dist/core/target-map.js +262 -0
- package/dist/core/test-exporter.d.ts +25 -0
- package/dist/core/test-exporter.js +1918 -0
- package/dist/core/types.d.ts +182 -14
- package/dist/core/visual-semantic.d.ts +67 -0
- package/dist/core/visual-semantic.js +673 -0
- package/dist/core/visual.js +65 -16
- package/dist/core/watch.d.ts +28 -3
- package/dist/core/watch.js +222 -12
- package/dist/core/yaml.d.ts +5 -0
- package/dist/core/yaml.js +1009 -0
- package/dist/diagnostics/diagnose.d.ts +53 -0
- package/dist/diagnostics/diagnose.js +1083 -0
- package/dist/diagnostics/flake.d.ts +71 -0
- package/dist/diagnostics/flake.js +608 -0
- package/dist/diagnostics/mutation-audit.d.ts +69 -0
- package/dist/diagnostics/mutation-audit.js +769 -0
- package/dist/diagnostics/spatial.d.ts +42 -0
- package/dist/diagnostics/spatial.js +346 -0
- package/dist/diagnostics/trends.d.ts +122 -0
- package/dist/diagnostics/trends.js +1190 -0
- package/dist/discovery/discover.d.ts +111 -0
- package/dist/discovery/discover.js +2017 -0
- package/dist/discovery/lock.d.ts +116 -0
- package/dist/discovery/lock.js +1505 -0
- package/dist/discovery/routes.d.ts +36 -0
- package/dist/discovery/routes.js +1494 -0
- package/dist/discovery/test-importer.d.ts +92 -0
- package/dist/discovery/test-importer.js +4952 -0
- package/dist/index.d.ts +123 -0
- package/dist/index.js +99 -0
- package/dist/ingestors/api-collections.d.ts +28 -0
- package/dist/ingestors/api-collections.js +2335 -0
- package/dist/ingestors/api-repo.d.ts +2 -1
- package/dist/ingestors/api-repo.js +483 -85
- package/dist/ingestors/asyncapi.d.ts +26 -0
- package/dist/ingestors/asyncapi.js +2105 -0
- package/dist/ingestors/bridges.d.ts +2 -0
- package/dist/ingestors/bridges.js +702 -0
- package/dist/ingestors/cli.d.ts +2 -1
- package/dist/ingestors/cli.js +234 -46
- package/dist/ingestors/curl.d.ts +14 -0
- package/dist/ingestors/curl.js +1024 -0
- package/dist/ingestors/graphql.d.ts +56 -0
- package/dist/ingestors/graphql.js +1852 -0
- package/dist/ingestors/http-file.d.ts +20 -0
- package/dist/ingestors/http-file.js +923 -0
- package/dist/ingestors/index.js +486 -6
- package/dist/ingestors/openrpc.d.ts +29 -0
- package/dist/ingestors/openrpc.js +1807 -0
- package/dist/ingestors/proto.d.ts +47 -0
- package/dist/ingestors/proto.js +2690 -0
- package/dist/ingestors/trace.d.ts +10 -0
- package/dist/ingestors/trace.js +599 -0
- package/dist/ingestors/video.d.ts +4 -1
- package/dist/ingestors/video.js +86 -36
- package/dist/ingestors/web.d.ts +16 -1
- package/dist/ingestors/web.js +474 -32
- package/dist/mcp/server.js +3532 -67
- package/dist/oracles/api-repo.js +102 -30
- package/dist/oracles/cli.js +65 -17
- package/dist/oracles/http-workflow.d.ts +68 -0
- package/dist/oracles/http-workflow.js +828 -0
- package/dist/oracles/image.js +178 -28
- package/dist/oracles/index.d.ts +3 -1
- package/dist/oracles/index.js +243 -14
- package/dist/oracles/perf-budget.d.ts +90 -0
- package/dist/oracles/perf-budget.js +1329 -0
- package/dist/oracles/stream.d.ts +94 -0
- package/dist/oracles/stream.js +1268 -0
- package/dist/oracles/ui-states.d.ts +49 -0
- package/dist/oracles/ui-states.js +894 -0
- package/dist/oracles/video.d.ts +1 -1
- package/dist/oracles/video.js +232 -16
- package/dist/oracles/web.js +464 -73
- package/dist/plugins/builtins.d.ts +12 -0
- package/dist/plugins/builtins.js +1052 -0
- package/dist/plugins/registry.d.ts +86 -0
- package/dist/plugins/registry.js +554 -0
- package/dist/setup/index.js +145 -33
- package/package.json +56 -47
- package/skills/vibecode-anything/SKILL.md +75 -52
package/dist/ingestors/web.js
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import { VibecodeError, errorMessage } from "../core/errors.js";
|
|
2
|
-
import { loadPlaywright } from "../core/adapters.js";
|
|
3
|
-
import { saveArtifact, ensureDir, resolveWorkspace } from "../core/store.js";
|
|
2
|
+
import { loadPlaywright, launchBrowser } from "../core/adapters.js";
|
|
3
|
+
import { artifactPath, saveArtifact, ensureDir, resolveWorkspace } from "../core/store.js";
|
|
4
|
+
import { decodeImage, extractPalette } from "../core/visual.js";
|
|
5
|
+
import { filterRuntimeHeaders, redactHeaders } from "./trace.js";
|
|
4
6
|
const LANDMARK_TAGS = ["header", "nav", "main", "footer", "h1", "h2", "form", "table", "ul"];
|
|
7
|
+
export const INTERACTIVE_LANDMARK_SELECTOR = 'button, a[href], input, select, textarea, [role="button"], [role="link"], [role="navigation"], [role="main"], [role="dialog"], [role="tablist"]';
|
|
5
8
|
const PLAYWRIGHT_INSTALL_HINT = "npm install -D playwright && npx playwright install chromium";
|
|
9
|
+
const MAX_CRAWL_ROUTES = 12;
|
|
10
|
+
const MAX_VISUAL_ROUTES = 3;
|
|
11
|
+
const NOT_FOUND_PROBE_PATH = "/__vibecode_not_found_probe__";
|
|
12
|
+
const STATIC_ASSET_RE = /\.(css|js|mjs|png|jpg|jpeg|webp|svg|ico|woff2?|pdf)$/i;
|
|
6
13
|
function isObject(v) {
|
|
7
14
|
return v !== null && typeof v === "object" && !Array.isArray(v);
|
|
8
15
|
}
|
|
@@ -31,6 +38,15 @@ function extractAllLandmarks(html) {
|
|
|
31
38
|
landmarks.push({ tag, text: stripTags(m[1]).slice(0, 120) });
|
|
32
39
|
}
|
|
33
40
|
}
|
|
41
|
+
if (landmarks.length === 0) {
|
|
42
|
+
const pRe = /<p\b[^>]*>([\s\S]*?)<\/p>/gi;
|
|
43
|
+
let m;
|
|
44
|
+
while ((m = pRe.exec(html)) !== null) {
|
|
45
|
+
const text = stripTags(m[1]).slice(0, 120);
|
|
46
|
+
if (text)
|
|
47
|
+
landmarks.push({ tag: "p", text });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
34
50
|
return landmarks;
|
|
35
51
|
}
|
|
36
52
|
function extractLandmarks(html) {
|
|
@@ -46,6 +62,14 @@ function extractLandmarks(html) {
|
|
|
46
62
|
entry.textContains = text;
|
|
47
63
|
landmarks.push(entry);
|
|
48
64
|
}
|
|
65
|
+
if (landmarks.length === 0) {
|
|
66
|
+
const pMatch = /<p\b[^>]*>([\s\S]*?)<\/p>/i.exec(html);
|
|
67
|
+
if (pMatch) {
|
|
68
|
+
const text = stripTags(pMatch[1]).slice(0, 80);
|
|
69
|
+
if (text)
|
|
70
|
+
landmarks.push({ tag: "p", required: true, textContains: text });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
49
73
|
return landmarks;
|
|
50
74
|
}
|
|
51
75
|
function normalizeRoute(route) {
|
|
@@ -72,11 +96,16 @@ function buildUrl(base, routePath) {
|
|
|
72
96
|
const baseUrl = /^https?:\/\//i.test(base) ? base : `http://${base}`;
|
|
73
97
|
return new URL(routePath, baseUrl).toString();
|
|
74
98
|
}
|
|
75
|
-
async function fetchRoute(url, _viewport, timeoutMs = 15000) {
|
|
99
|
+
async function fetchRoute(url, _viewport, timeoutMs = 15000, headers) {
|
|
76
100
|
const ctrl = new AbortController();
|
|
77
101
|
const t = setTimeout(() => ctrl.abort(), timeoutMs);
|
|
102
|
+
const cleanHeaders = filterRuntimeHeaders(headers);
|
|
78
103
|
try {
|
|
79
|
-
const res = await fetch(url, {
|
|
104
|
+
const res = await fetch(url, {
|
|
105
|
+
signal: ctrl.signal,
|
|
106
|
+
redirect: "follow",
|
|
107
|
+
...(Object.keys(cleanHeaders).length > 0 ? { headers: cleanHeaders } : {})
|
|
108
|
+
});
|
|
80
109
|
const html = await res.text();
|
|
81
110
|
return {
|
|
82
111
|
status: res.status,
|
|
@@ -93,6 +122,51 @@ async function fetchRoute(url, _viewport, timeoutMs = 15000) {
|
|
|
93
122
|
function slugify(text) {
|
|
94
123
|
return String(text).replace(/[^A-Za-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 80) || "route";
|
|
95
124
|
}
|
|
125
|
+
function dedupeId(baseId, usedIds) {
|
|
126
|
+
if (!usedIds.has(baseId)) {
|
|
127
|
+
usedIds.add(baseId);
|
|
128
|
+
return baseId;
|
|
129
|
+
}
|
|
130
|
+
let n = 2;
|
|
131
|
+
while (usedIds.has(`${baseId}-${n}`))
|
|
132
|
+
n += 1;
|
|
133
|
+
const unique = `${baseId}-${n}`;
|
|
134
|
+
usedIds.add(unique);
|
|
135
|
+
return unique;
|
|
136
|
+
}
|
|
137
|
+
function allocateSlug(routePath, usedSlugs) {
|
|
138
|
+
return dedupeId(slugify(routePath), usedSlugs);
|
|
139
|
+
}
|
|
140
|
+
export function normalizeSameOriginHref(href, baseUrl) {
|
|
141
|
+
const trimmed = String(href).trim();
|
|
142
|
+
if (!trimmed || trimmed.startsWith("#") || /^(?:mailto|javascript|tel|data):/i.test(trimmed)) {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
try {
|
|
146
|
+
const base = new URL(/^https?:\/\//i.test(baseUrl) ? baseUrl : `http://${baseUrl}`);
|
|
147
|
+
const resolved = new URL(trimmed, base);
|
|
148
|
+
if (resolved.origin !== base.origin)
|
|
149
|
+
return null;
|
|
150
|
+
const pathname = resolved.pathname || "/";
|
|
151
|
+
if (pathname === "/favicon.ico" || STATIC_ASSET_RE.test(pathname))
|
|
152
|
+
return null;
|
|
153
|
+
return pathname;
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
export function extractHtmlHrefs(html) {
|
|
160
|
+
const hrefs = [];
|
|
161
|
+
const re = /<a\b[^>]*\bhref\s*=\s*(?:"([^"'#]+)"|'([^"'#]+)')/gi;
|
|
162
|
+
let m;
|
|
163
|
+
while ((m = re.exec(html)) !== null) {
|
|
164
|
+
const href = (m[1] ?? m[2] ?? "").trim();
|
|
165
|
+
if (href)
|
|
166
|
+
hrefs.push(href);
|
|
167
|
+
}
|
|
168
|
+
return hrefs;
|
|
169
|
+
}
|
|
96
170
|
function resolvePlaywright(candidate) {
|
|
97
171
|
if (!candidate || typeof candidate !== "object")
|
|
98
172
|
return null;
|
|
@@ -105,13 +179,175 @@ function resolvePlaywright(candidate) {
|
|
|
105
179
|
}
|
|
106
180
|
return null;
|
|
107
181
|
}
|
|
108
|
-
async function getPlaywright(deps) {
|
|
182
|
+
async function getPlaywright(deps, cwd) {
|
|
109
183
|
const explicit = Object.prototype.hasOwnProperty.call(deps, "playwright") ? deps.playwright : undefined;
|
|
110
184
|
if (explicit === null)
|
|
111
185
|
return null;
|
|
112
|
-
const loaded = explicit !== undefined ? explicit : await loadPlaywright(deps);
|
|
186
|
+
const loaded = explicit !== undefined ? explicit : await loadPlaywright(cwd ? { ...deps, cwd } : deps);
|
|
113
187
|
return resolvePlaywright(loaded);
|
|
114
188
|
}
|
|
189
|
+
export async function openBrowserPage(browser, options = {}) {
|
|
190
|
+
const cleanHeaders = filterRuntimeHeaders(options.headers);
|
|
191
|
+
const hasHeaders = Object.keys(cleanHeaders).length > 0;
|
|
192
|
+
const storageState = typeof options.storageState === "string" && options.storageState.trim()
|
|
193
|
+
? options.storageState.trim()
|
|
194
|
+
: undefined;
|
|
195
|
+
if (typeof browser.newContext === "function" && (hasHeaders || storageState)) {
|
|
196
|
+
const contextOpts = {
|
|
197
|
+
...(options.viewport ? { viewport: options.viewport } : {}),
|
|
198
|
+
...(hasHeaders ? { extraHTTPHeaders: cleanHeaders } : {}),
|
|
199
|
+
...(storageState ? { storageState } : {})
|
|
200
|
+
};
|
|
201
|
+
const context = await browser.newContext(contextOpts);
|
|
202
|
+
let page;
|
|
203
|
+
try {
|
|
204
|
+
page = await context.newPage();
|
|
205
|
+
}
|
|
206
|
+
catch (err) {
|
|
207
|
+
try {
|
|
208
|
+
await context.close();
|
|
209
|
+
}
|
|
210
|
+
catch { /* ignore */ }
|
|
211
|
+
throw err;
|
|
212
|
+
}
|
|
213
|
+
return {
|
|
214
|
+
page,
|
|
215
|
+
async close() {
|
|
216
|
+
try {
|
|
217
|
+
await page.close?.();
|
|
218
|
+
}
|
|
219
|
+
catch { /* ignore */ }
|
|
220
|
+
try {
|
|
221
|
+
await context.close();
|
|
222
|
+
}
|
|
223
|
+
catch { /* ignore */ }
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
const page = await browser.newPage(options.viewport ? { viewport: options.viewport } : undefined);
|
|
228
|
+
if (hasHeaders && typeof page.setExtraHTTPHeaders === "function") {
|
|
229
|
+
try {
|
|
230
|
+
await page.setExtraHTTPHeaders(cleanHeaders);
|
|
231
|
+
}
|
|
232
|
+
catch (err) {
|
|
233
|
+
try {
|
|
234
|
+
await page.close?.();
|
|
235
|
+
}
|
|
236
|
+
catch { /* ignore */ }
|
|
237
|
+
throw err;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return {
|
|
241
|
+
page,
|
|
242
|
+
async close() {
|
|
243
|
+
try {
|
|
244
|
+
await page.close?.();
|
|
245
|
+
}
|
|
246
|
+
catch { /* ignore */ }
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
export async function gotoWithSpaFallback(page, url, waitUntil, timeoutMs) {
|
|
251
|
+
try {
|
|
252
|
+
return await page.goto(url, { waitUntil, timeout: timeoutMs });
|
|
253
|
+
}
|
|
254
|
+
catch (err) {
|
|
255
|
+
if (waitUntil !== "load" && /\btimeout\b|timed out/i.test(errorMessage(err))) {
|
|
256
|
+
const fallback = await page.goto(url, { waitUntil: "load", timeout: timeoutMs });
|
|
257
|
+
if (typeof page.waitForLoadState === "function") {
|
|
258
|
+
await page.waitForLoadState("networkidle", { timeout: 2500 }).catch(() => { });
|
|
259
|
+
}
|
|
260
|
+
return fallback;
|
|
261
|
+
}
|
|
262
|
+
throw err;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
export async function extractInteractiveLandmarks(page) {
|
|
266
|
+
const raw = await page
|
|
267
|
+
.$$eval(INTERACTIVE_LANDMARK_SELECTOR, (nodes) => {
|
|
268
|
+
const interactiveTags = new Set(["button", "a", "input", "select", "textarea"]);
|
|
269
|
+
const allowedRoles = new Set(["button", "link", "navigation", "main", "dialog", "tablist"]);
|
|
270
|
+
const out = [];
|
|
271
|
+
const seen = new Set();
|
|
272
|
+
for (const el of nodes) {
|
|
273
|
+
if (!el || typeof el.getAttribute !== "function")
|
|
274
|
+
continue;
|
|
275
|
+
const tag = String(el.tagName || "").toLowerCase();
|
|
276
|
+
const roleAttr = String(el.getAttribute("role") || "").trim().toLowerCase();
|
|
277
|
+
if (!interactiveTags.has(tag) && !allowedRoles.has(roleAttr))
|
|
278
|
+
continue;
|
|
279
|
+
if (tag === "input" && String(el.getAttribute("type") || "").trim().toLowerCase() === "hidden")
|
|
280
|
+
continue;
|
|
281
|
+
if (String(el.getAttribute("aria-hidden") || "").trim().toLowerCase() === "true")
|
|
282
|
+
continue;
|
|
283
|
+
if (el.getAttribute("hidden") !== null)
|
|
284
|
+
continue;
|
|
285
|
+
if (typeof window !== "undefined" && typeof window.getComputedStyle === "function") {
|
|
286
|
+
try {
|
|
287
|
+
const style = window.getComputedStyle(el);
|
|
288
|
+
if (style && (style.display === "none" || style.visibility === "hidden"))
|
|
289
|
+
continue;
|
|
290
|
+
}
|
|
291
|
+
catch {
|
|
292
|
+
// ignore style errors on partial DOM mocks
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
if (typeof el.getBoundingClientRect === "function") {
|
|
296
|
+
try {
|
|
297
|
+
const rect = el.getBoundingClientRect();
|
|
298
|
+
if (rect && rect.width <= 0 && rect.height <= 0)
|
|
299
|
+
continue;
|
|
300
|
+
}
|
|
301
|
+
catch {
|
|
302
|
+
// ignore bounding box errors on partial DOM mocks
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
let role = allowedRoles.has(roleAttr) ? roleAttr : "";
|
|
306
|
+
if (!role) {
|
|
307
|
+
if (tag === "button")
|
|
308
|
+
role = "button";
|
|
309
|
+
else if (tag === "a")
|
|
310
|
+
role = "link";
|
|
311
|
+
else if (tag === "select")
|
|
312
|
+
role = "combobox";
|
|
313
|
+
else if (tag === "textarea")
|
|
314
|
+
role = "textbox";
|
|
315
|
+
else if (tag === "input") {
|
|
316
|
+
const inputType = String(el.getAttribute("type") || "text").trim().toLowerCase();
|
|
317
|
+
if (inputType === "submit" || inputType === "button" || inputType === "reset")
|
|
318
|
+
role = "button";
|
|
319
|
+
else if (inputType === "checkbox")
|
|
320
|
+
role = "checkbox";
|
|
321
|
+
else if (inputType === "radio")
|
|
322
|
+
role = "radio";
|
|
323
|
+
else
|
|
324
|
+
role = "textbox";
|
|
325
|
+
}
|
|
326
|
+
else {
|
|
327
|
+
role = tag;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
const rawName = el.getAttribute("aria-label") ||
|
|
331
|
+
el.textContent ||
|
|
332
|
+
el.getAttribute("placeholder") ||
|
|
333
|
+
el.getAttribute("name") ||
|
|
334
|
+
el.getAttribute("value") ||
|
|
335
|
+
el.getAttribute("title") ||
|
|
336
|
+
"";
|
|
337
|
+
const name = String(rawName).replace(/\s+/g, " ").trim().slice(0, 80);
|
|
338
|
+
const key = `${role}|${tag}|${name.toLowerCase()}`;
|
|
339
|
+
if (seen.has(key))
|
|
340
|
+
continue;
|
|
341
|
+
seen.add(key);
|
|
342
|
+
out.push(name ? { role, tag, name } : { role, tag });
|
|
343
|
+
if (out.length >= 20)
|
|
344
|
+
break;
|
|
345
|
+
}
|
|
346
|
+
return out;
|
|
347
|
+
})
|
|
348
|
+
.catch(() => []);
|
|
349
|
+
return Array.isArray(raw) ? raw : [];
|
|
350
|
+
}
|
|
115
351
|
function isValidBBox(box) {
|
|
116
352
|
if (!isObject(box))
|
|
117
353
|
return false;
|
|
@@ -144,6 +380,10 @@ export async function ingest(options = {}, deps = {}) {
|
|
|
144
380
|
if (!source || typeof source !== "string") {
|
|
145
381
|
throw new VibecodeError("TARGET_MISSING", "Web ingestor requires --source <url>");
|
|
146
382
|
}
|
|
383
|
+
const crawlDepth = options.crawlDepth === undefined ? 1 : options.crawlDepth;
|
|
384
|
+
if (typeof crawlDepth !== "number" || !Number.isInteger(crawlDepth) || crawlDepth < 1 || crawlDepth > 3) {
|
|
385
|
+
throw new VibecodeError("CONTRACT_INVALID", "crawlDepth must be an integer between 1 and 3");
|
|
386
|
+
}
|
|
147
387
|
const cwd = options.cwd || process.cwd();
|
|
148
388
|
const { artifactsDir } = resolveWorkspace(cwd);
|
|
149
389
|
ensureDir(artifactsDir);
|
|
@@ -161,8 +401,32 @@ export async function ingest(options = {}, deps = {}) {
|
|
|
161
401
|
defaultRoute = p;
|
|
162
402
|
}
|
|
163
403
|
catch { /* keep "/" */ }
|
|
164
|
-
const
|
|
165
|
-
const
|
|
404
|
+
const rawInitialRoutes = (Array.isArray(options.routes) && options.routes.length ? options.routes : [defaultRoute]).map(normalizeRoute);
|
|
405
|
+
const initialRoutes = [];
|
|
406
|
+
const visited = new Set();
|
|
407
|
+
const queue = [];
|
|
408
|
+
for (const route of rawInitialRoutes) {
|
|
409
|
+
if (visited.has(route.path))
|
|
410
|
+
continue;
|
|
411
|
+
visited.add(route.path);
|
|
412
|
+
initialRoutes.push(route);
|
|
413
|
+
queue.push({ route, depth: 0 });
|
|
414
|
+
}
|
|
415
|
+
const explicitVisualPaths = new Set(initialRoutes.slice(0, MAX_VISUAL_ROUTES).map((r) => r.path));
|
|
416
|
+
const crawledPaths = [];
|
|
417
|
+
const usedIds = new Set();
|
|
418
|
+
const usedRouteSlugs = new Set();
|
|
419
|
+
const pw = await getPlaywright(deps, cwd);
|
|
420
|
+
const liveHeaders = filterRuntimeHeaders(options.headers);
|
|
421
|
+
const hasLiveHeaders = Object.keys(liveHeaders).length > 0;
|
|
422
|
+
const persistedHeaders = redactHeaders(liveHeaders, "strip");
|
|
423
|
+
const persistedStorageState = typeof options.storageState === "string" && options.storageState.trim()
|
|
424
|
+
? options.storageState.trim()
|
|
425
|
+
: undefined;
|
|
426
|
+
const persistedAuthInput = {
|
|
427
|
+
...(Object.keys(persistedHeaders).length > 0 ? { headers: persistedHeaders } : {}),
|
|
428
|
+
...(persistedStorageState ? { storageState: persistedStorageState } : {})
|
|
429
|
+
};
|
|
166
430
|
let browser = null;
|
|
167
431
|
let playwrightActive = false;
|
|
168
432
|
let launchFailureMessage = null;
|
|
@@ -171,7 +435,7 @@ export async function ingest(options = {}, deps = {}) {
|
|
|
171
435
|
try {
|
|
172
436
|
if (pw) {
|
|
173
437
|
try {
|
|
174
|
-
browser = await pw
|
|
438
|
+
browser = await launchBrowser(pw, { headless: true, featureName: "web ingestion" });
|
|
175
439
|
playwrightActive = true;
|
|
176
440
|
}
|
|
177
441
|
catch (err) {
|
|
@@ -181,11 +445,18 @@ export async function ingest(options = {}, deps = {}) {
|
|
|
181
445
|
}
|
|
182
446
|
}
|
|
183
447
|
if (browser) {
|
|
184
|
-
|
|
448
|
+
while (queue.length > 0) {
|
|
449
|
+
const { route, depth } = queue.shift();
|
|
450
|
+
crawledPaths.push(route.path);
|
|
185
451
|
const url = buildUrl(source, route.path);
|
|
186
452
|
const viewport = route.viewport || { width: 1280, height: 720 };
|
|
187
453
|
const timeoutMs = route.timeoutMs ?? defaultTimeoutMs;
|
|
188
|
-
const
|
|
454
|
+
const pageHandle = await openBrowserPage(browser, {
|
|
455
|
+
viewport,
|
|
456
|
+
headers: liveHeaders,
|
|
457
|
+
storageState: persistedStorageState
|
|
458
|
+
});
|
|
459
|
+
const { page } = pageHandle;
|
|
189
460
|
try {
|
|
190
461
|
const network = [];
|
|
191
462
|
const consoleErrors = [];
|
|
@@ -212,7 +483,7 @@ export async function ingest(options = {}, deps = {}) {
|
|
|
212
483
|
}
|
|
213
484
|
let response = null;
|
|
214
485
|
try {
|
|
215
|
-
response = await page
|
|
486
|
+
response = await gotoWithSpaFallback(page, url, route.waitUntil, timeoutMs);
|
|
216
487
|
}
|
|
217
488
|
catch (err) {
|
|
218
489
|
warnings.push({ code: "EXEC_ERROR", message: `Navigation failed for ${url}: ${errorMessage(err)}` });
|
|
@@ -220,6 +491,7 @@ export async function ingest(options = {}, deps = {}) {
|
|
|
220
491
|
}
|
|
221
492
|
const title = await page.title();
|
|
222
493
|
const landmarks = await page.$$eval(LANDMARK_TAGS.map((t) => t).join(","), (nodes) => nodes.map((n) => ({ tag: n.tagName.toLowerCase(), text: (n.textContent || "").trim().slice(0, 80) }))).catch(() => []);
|
|
494
|
+
const interactiveLandmarks = await extractInteractiveLandmarks(page);
|
|
223
495
|
const boundingBoxes = [];
|
|
224
496
|
const seenBoxTags = new Set();
|
|
225
497
|
for (const lm of landmarks) {
|
|
@@ -235,7 +507,21 @@ export async function ingest(options = {}, deps = {}) {
|
|
|
235
507
|
if (isValidBBox(box))
|
|
236
508
|
boundingBoxes.push({ selector: lm.tag, bbox: box });
|
|
237
509
|
}
|
|
238
|
-
|
|
510
|
+
if (depth < crawlDepth - 1 && visited.size < MAX_CRAWL_ROUTES) {
|
|
511
|
+
const hrefs = await page
|
|
512
|
+
.$$eval("a[href]", (els) => els.map((el) => el.getAttribute("href") || ""))
|
|
513
|
+
.catch(() => []);
|
|
514
|
+
for (const href of hrefs) {
|
|
515
|
+
if (visited.size >= MAX_CRAWL_ROUTES)
|
|
516
|
+
break;
|
|
517
|
+
const nextPath = normalizeSameOriginHref(href, url);
|
|
518
|
+
if (!nextPath || visited.has(nextPath))
|
|
519
|
+
continue;
|
|
520
|
+
visited.add(nextPath);
|
|
521
|
+
queue.push({ route: normalizeRoute(nextPath), depth: depth + 1 });
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
const slug = allocateSlug(route.path, usedRouteSlugs);
|
|
239
525
|
const shotName = `web/${slug}.png`;
|
|
240
526
|
try {
|
|
241
527
|
const buf = await page.screenshot({ fullPage: false });
|
|
@@ -245,14 +531,14 @@ export async function ingest(options = {}, deps = {}) {
|
|
|
245
531
|
catch { /* screenshot optional */ }
|
|
246
532
|
const titleVal = route.titleContains || (title ? title : undefined);
|
|
247
533
|
const routeInv = {
|
|
248
|
-
id: route.id || `inv-web-${slug}`,
|
|
534
|
+
id: dedupeId(route.id || `inv-web-${slug}`, usedIds),
|
|
249
535
|
domain: "web",
|
|
250
536
|
type: "web_route",
|
|
251
537
|
severity: "hard",
|
|
252
538
|
description: `Route ${route.path} returns expected status and landmarks`,
|
|
253
539
|
tags: ["web", "route", "hard"],
|
|
254
540
|
sourceId: "src-1",
|
|
255
|
-
input: { path: route.path, viewport, waitUntil: route.waitUntil },
|
|
541
|
+
input: { path: route.path, viewport, waitUntil: route.waitUntil, ...persistedAuthInput },
|
|
256
542
|
expected: {
|
|
257
543
|
status: response?.status() ?? 200,
|
|
258
544
|
...(titleVal ? { titleContains: titleVal } : {}),
|
|
@@ -260,46 +546,64 @@ export async function ingest(options = {}, deps = {}) {
|
|
|
260
546
|
tag: lm.tag,
|
|
261
547
|
required: true,
|
|
262
548
|
...(lm.tag === "h1" || lm.tag === "h2" ? { textContains: lm.text } : {})
|
|
263
|
-
}))
|
|
549
|
+
})),
|
|
550
|
+
...(interactiveLandmarks.length > 0 ? { interactiveLandmarks } : {})
|
|
264
551
|
},
|
|
265
552
|
tolerance: {}
|
|
266
553
|
};
|
|
267
554
|
invariants.push(routeInv);
|
|
268
555
|
if (boundingBoxes.length) {
|
|
269
556
|
invariants.push({
|
|
270
|
-
id: `inv-web-${slug}-layout`,
|
|
557
|
+
id: dedupeId(`inv-web-${slug}-layout`, usedIds),
|
|
271
558
|
domain: "web",
|
|
272
559
|
type: "web_route",
|
|
273
560
|
severity: "soft",
|
|
274
561
|
description: `Route ${route.path} preserves landmark layout`,
|
|
275
562
|
tags: ["web", "layout", "soft"],
|
|
276
563
|
sourceId: "src-1",
|
|
277
|
-
input: { path: route.path, viewport, waitUntil: route.waitUntil },
|
|
564
|
+
input: { path: route.path, viewport, waitUntil: route.waitUntil, ...persistedAuthInput },
|
|
278
565
|
expected: { status: response?.status() ?? 200, boundingBoxes },
|
|
279
566
|
tolerance: { minLayoutIoU: 0.75 }
|
|
280
567
|
});
|
|
281
568
|
}
|
|
569
|
+
if (artifacts.files[`web-${slug}`] && explicitVisualPaths.has(route.path)) {
|
|
570
|
+
try {
|
|
571
|
+
const absFile = artifactPath(artifacts.files[`web-${slug}`], cwd);
|
|
572
|
+
const img = await decodeImage(absFile, { sharp: deps.sharp });
|
|
573
|
+
const palette = extractPalette(img);
|
|
574
|
+
invariants.push({
|
|
575
|
+
id: dedupeId(`inv-web-visual-${slug}`, usedIds),
|
|
576
|
+
domain: "web",
|
|
577
|
+
type: "image_perceptual",
|
|
578
|
+
severity: "soft",
|
|
579
|
+
description: `Route ${route.path} preserves visual appearance`,
|
|
580
|
+
tags: ["web", "visual", "soft"],
|
|
581
|
+
sourceId: "src-1",
|
|
582
|
+
input: { referenceArtifact: `web-${slug}`, urlPath: route.path },
|
|
583
|
+
expected: { dimensions: { width: img.width, height: img.height }, nonBlank: true, palette },
|
|
584
|
+
tolerance: { minSSIM: 0.85, maxPixelDiffRatio: 0.25 }
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
catch { /* ignore dummy non-PNG mock buffers */ }
|
|
588
|
+
}
|
|
282
589
|
const normalizedNet = (page.__networkCalls || network).map(normalizeNetworkEntry);
|
|
283
590
|
if (normalizedNet.length) {
|
|
284
591
|
invariants.push({
|
|
285
|
-
id: `inv-web-${slug}-network`,
|
|
592
|
+
id: dedupeId(`inv-web-${slug}-network`, usedIds),
|
|
286
593
|
domain: "web",
|
|
287
594
|
type: "web_network",
|
|
288
595
|
severity: "hard",
|
|
289
596
|
description: `Route ${route.path} issues expected network calls`,
|
|
290
597
|
tags: ["web", "network", "hard"],
|
|
291
598
|
sourceId: "src-1",
|
|
292
|
-
input: { triggerPath: route.path, viewport, waitUntil: route.waitUntil },
|
|
599
|
+
input: { triggerPath: route.path, viewport, waitUntil: route.waitUntil, ...persistedAuthInput },
|
|
293
600
|
expected: { networkCalls: normalizedNet },
|
|
294
601
|
tolerance: {}
|
|
295
602
|
});
|
|
296
603
|
}
|
|
297
604
|
}
|
|
298
605
|
finally {
|
|
299
|
-
|
|
300
|
-
await page.close?.();
|
|
301
|
-
}
|
|
302
|
-
catch { /* ignore */ }
|
|
606
|
+
await pageHandle.close();
|
|
303
607
|
}
|
|
304
608
|
}
|
|
305
609
|
}
|
|
@@ -312,27 +616,44 @@ export async function ingest(options = {}, deps = {}) {
|
|
|
312
616
|
adapter: "playwright",
|
|
313
617
|
installHint: PLAYWRIGHT_INSTALL_HINT
|
|
314
618
|
});
|
|
315
|
-
|
|
619
|
+
while (queue.length > 0) {
|
|
620
|
+
const { route, depth } = queue.shift();
|
|
621
|
+
crawledPaths.push(route.path);
|
|
316
622
|
const url = buildUrl(source, route.path);
|
|
317
623
|
let obs;
|
|
318
624
|
try {
|
|
319
|
-
|
|
625
|
+
const timeout = route.timeoutMs ?? defaultTimeoutMs;
|
|
626
|
+
obs = hasLiveHeaders
|
|
627
|
+
? await (deps.fetchRoute || fetchRoute)(url, route.viewport, timeout, liveHeaders)
|
|
628
|
+
: await (deps.fetchRoute || fetchRoute)(url, route.viewport, timeout);
|
|
320
629
|
}
|
|
321
630
|
catch (err) {
|
|
322
631
|
warnings.push({ code: "EXEC_ERROR", message: `Fetch failed for ${url}: ${errorMessage(err)}` });
|
|
323
632
|
continue;
|
|
324
633
|
}
|
|
325
|
-
|
|
634
|
+
if (depth < crawlDepth - 1 && visited.size < MAX_CRAWL_ROUTES) {
|
|
635
|
+
const hrefs = extractHtmlHrefs(obs.html || "");
|
|
636
|
+
for (const href of hrefs) {
|
|
637
|
+
if (visited.size >= MAX_CRAWL_ROUTES)
|
|
638
|
+
break;
|
|
639
|
+
const nextPath = normalizeSameOriginHref(href, url);
|
|
640
|
+
if (!nextPath || visited.has(nextPath))
|
|
641
|
+
continue;
|
|
642
|
+
visited.add(nextPath);
|
|
643
|
+
queue.push({ route: normalizeRoute(nextPath), depth: depth + 1 });
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
const slug = allocateSlug(route.path, usedRouteSlugs);
|
|
326
647
|
const titleVal = route.titleContains || (obs.title ? obs.title : undefined);
|
|
327
648
|
invariants.push({
|
|
328
|
-
id: route.id || `inv-web-${slug}`,
|
|
649
|
+
id: dedupeId(route.id || `inv-web-${slug}`, usedIds),
|
|
329
650
|
domain: "web",
|
|
330
651
|
type: "web_route",
|
|
331
652
|
severity: "hard",
|
|
332
653
|
description: `Route ${route.path} returns expected status and landmarks (fetch fallback)`,
|
|
333
654
|
tags: ["web", "route", "hard", "fetch-fallback"],
|
|
334
655
|
sourceId: "src-1",
|
|
335
|
-
input: { path: route.path, waitUntil: "networkidle" },
|
|
656
|
+
input: { path: route.path, waitUntil: "networkidle", ...persistedAuthInput },
|
|
336
657
|
expected: {
|
|
337
658
|
status: obs.status,
|
|
338
659
|
...(titleVal ? { titleContains: titleVal } : {}),
|
|
@@ -342,6 +663,101 @@ export async function ingest(options = {}, deps = {}) {
|
|
|
342
663
|
});
|
|
343
664
|
}
|
|
344
665
|
}
|
|
666
|
+
// Explicit holdoutRoutes (emit only web_route holdout invariants, never layout/network/visual)
|
|
667
|
+
const rawHoldouts = Array.isArray(options.holdoutRoutes) ? options.holdoutRoutes : [];
|
|
668
|
+
const seenHoldouts = new Set();
|
|
669
|
+
for (const rawHoldout of rawHoldouts) {
|
|
670
|
+
if (typeof rawHoldout !== "string")
|
|
671
|
+
continue;
|
|
672
|
+
const trimmed = rawHoldout.trim();
|
|
673
|
+
if (!trimmed)
|
|
674
|
+
continue;
|
|
675
|
+
const routePath = trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
|
|
676
|
+
if (seenHoldouts.has(routePath))
|
|
677
|
+
continue;
|
|
678
|
+
seenHoldouts.add(routePath);
|
|
679
|
+
const url = buildUrl(source, routePath);
|
|
680
|
+
const holdoutId = dedupeId(`inv-web-holdout-${slugify(routePath)}`, usedIds);
|
|
681
|
+
const holdoutHint = `Holdout route ${routePath}`;
|
|
682
|
+
if (browser) {
|
|
683
|
+
const viewport = { width: 1280, height: 720 };
|
|
684
|
+
const pageHandle = await openBrowserPage(browser, {
|
|
685
|
+
viewport,
|
|
686
|
+
headers: liveHeaders,
|
|
687
|
+
storageState: persistedStorageState
|
|
688
|
+
});
|
|
689
|
+
const { page } = pageHandle;
|
|
690
|
+
try {
|
|
691
|
+
let response = null;
|
|
692
|
+
try {
|
|
693
|
+
response = await gotoWithSpaFallback(page, url, "networkidle", defaultTimeoutMs);
|
|
694
|
+
}
|
|
695
|
+
catch (err) {
|
|
696
|
+
warnings.push({ code: "EXEC_ERROR", message: `Navigation failed for ${url}: ${errorMessage(err)}` });
|
|
697
|
+
continue;
|
|
698
|
+
}
|
|
699
|
+
const title = await page.title();
|
|
700
|
+
const landmarks = await page.$$eval(LANDMARK_TAGS.join(","), (nodes) => nodes.map((n) => ({ tag: n.tagName.toLowerCase(), text: (n.textContent || "").trim().slice(0, 80) }))).catch(() => []);
|
|
701
|
+
const interactiveLandmarks = await extractInteractiveLandmarks(page);
|
|
702
|
+
invariants.push({
|
|
703
|
+
id: holdoutId,
|
|
704
|
+
domain: "web",
|
|
705
|
+
type: "web_route",
|
|
706
|
+
severity: "hard",
|
|
707
|
+
holdout: true,
|
|
708
|
+
holdoutHint,
|
|
709
|
+
description: `Holdout route ${routePath} returns expected status and landmarks`,
|
|
710
|
+
tags: ["web", "route", "hard", "holdout"],
|
|
711
|
+
sourceId: "src-1",
|
|
712
|
+
input: { path: routePath, viewport, waitUntil: "networkidle", ...persistedAuthInput },
|
|
713
|
+
expected: {
|
|
714
|
+
status: response?.status() ?? 200,
|
|
715
|
+
...(title ? { titleContains: title } : {}),
|
|
716
|
+
landmarks: landmarks.map((lm) => ({
|
|
717
|
+
tag: lm.tag,
|
|
718
|
+
required: true,
|
|
719
|
+
...(lm.tag === "h1" || lm.tag === "h2" ? { textContains: lm.text } : {})
|
|
720
|
+
})),
|
|
721
|
+
...(interactiveLandmarks.length > 0 ? { interactiveLandmarks } : {})
|
|
722
|
+
},
|
|
723
|
+
tolerance: {}
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
finally {
|
|
727
|
+
await pageHandle.close();
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
else {
|
|
731
|
+
let obs;
|
|
732
|
+
try {
|
|
733
|
+
obs = hasLiveHeaders
|
|
734
|
+
? await (deps.fetchRoute || fetchRoute)(url, undefined, defaultTimeoutMs, liveHeaders)
|
|
735
|
+
: await (deps.fetchRoute || fetchRoute)(url, undefined, defaultTimeoutMs);
|
|
736
|
+
}
|
|
737
|
+
catch (err) {
|
|
738
|
+
warnings.push({ code: "EXEC_ERROR", message: `Fetch failed for ${url}: ${errorMessage(err)}` });
|
|
739
|
+
continue;
|
|
740
|
+
}
|
|
741
|
+
invariants.push({
|
|
742
|
+
id: holdoutId,
|
|
743
|
+
domain: "web",
|
|
744
|
+
type: "web_route",
|
|
745
|
+
severity: "hard",
|
|
746
|
+
holdout: true,
|
|
747
|
+
holdoutHint,
|
|
748
|
+
description: `Holdout route ${routePath} returns expected status and landmarks`,
|
|
749
|
+
tags: ["web", "route", "hard", "holdout"],
|
|
750
|
+
sourceId: "src-1",
|
|
751
|
+
input: { path: routePath, waitUntil: "networkidle", ...persistedAuthInput },
|
|
752
|
+
expected: {
|
|
753
|
+
status: obs.status,
|
|
754
|
+
...(obs.title ? { titleContains: obs.title } : {}),
|
|
755
|
+
landmarks: obs.landmarks
|
|
756
|
+
},
|
|
757
|
+
tolerance: {}
|
|
758
|
+
});
|
|
759
|
+
}
|
|
760
|
+
}
|
|
345
761
|
// web flow from CLI --flow <file.json>
|
|
346
762
|
if (options.flow && typeof options.flow === "object" && !Array.isArray(options.flow)) {
|
|
347
763
|
const flow = options.flow;
|
|
@@ -357,7 +773,7 @@ export async function ingest(options = {}, deps = {}) {
|
|
|
357
773
|
}
|
|
358
774
|
else {
|
|
359
775
|
invariants.push({
|
|
360
|
-
id: flow.id || "inv-web-flow",
|
|
776
|
+
id: dedupeId(flow.id || "inv-web-flow", usedIds),
|
|
361
777
|
domain: "web",
|
|
362
778
|
type: "web_flow",
|
|
363
779
|
severity: "hard",
|
|
@@ -367,13 +783,39 @@ export async function ingest(options = {}, deps = {}) {
|
|
|
367
783
|
input: {
|
|
368
784
|
startPath: flow.startPath || "/",
|
|
369
785
|
viewport: flow.viewport || { width: 1280, height: 720 },
|
|
370
|
-
steps: Array.isArray(flow.steps) ? flow.steps : []
|
|
786
|
+
steps: Array.isArray(flow.steps) ? flow.steps : [],
|
|
787
|
+
...persistedAuthInput
|
|
371
788
|
},
|
|
372
789
|
expected: isObject(flow.expected) ? flow.expected : {},
|
|
373
790
|
tolerance: {}
|
|
374
791
|
});
|
|
375
792
|
}
|
|
376
793
|
}
|
|
794
|
+
// Auto 404 holdout probe via HTTP fetch (never open a Playwright page for this probe)
|
|
795
|
+
try {
|
|
796
|
+
const probeUrl = buildUrl(source, NOT_FOUND_PROBE_PATH);
|
|
797
|
+
const probeTimeout = Math.min(defaultTimeoutMs, 5000);
|
|
798
|
+
const probeObs = hasLiveHeaders
|
|
799
|
+
? await (deps.fetchRoute || fetchRoute)(probeUrl, undefined, probeTimeout, liveHeaders)
|
|
800
|
+
: await (deps.fetchRoute || fetchRoute)(probeUrl, undefined, probeTimeout);
|
|
801
|
+
if (probeObs.status === 404) {
|
|
802
|
+
invariants.push({
|
|
803
|
+
id: dedupeId("inv-web-holdout-404", usedIds),
|
|
804
|
+
domain: "web",
|
|
805
|
+
type: "web_route",
|
|
806
|
+
severity: "hard",
|
|
807
|
+
holdout: true,
|
|
808
|
+
holdoutHint: "404 Not Found status handling",
|
|
809
|
+
description: "Unknown route returns HTTP 404",
|
|
810
|
+
tags: ["web", "route", "hard", "holdout", "404"],
|
|
811
|
+
sourceId: "src-1",
|
|
812
|
+
input: { path: NOT_FOUND_PROBE_PATH, waitUntil: "networkidle", ...persistedAuthInput },
|
|
813
|
+
expected: { status: 404 },
|
|
814
|
+
tolerance: {}
|
|
815
|
+
});
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
catch { /* ignore unreachable mock URL */ }
|
|
377
819
|
}
|
|
378
820
|
finally {
|
|
379
821
|
if (browser) {
|
|
@@ -388,7 +830,7 @@ export async function ingest(options = {}, deps = {}) {
|
|
|
388
830
|
}
|
|
389
831
|
return {
|
|
390
832
|
domain: "web",
|
|
391
|
-
sources: [{ id: "src-1", kind: "web", ref: source, meta: { routes:
|
|
833
|
+
sources: [{ id: "src-1", kind: "web", ref: source, meta: { routes: crawledPaths, playwright: playwrightActive } }],
|
|
392
834
|
artifacts,
|
|
393
835
|
invariants,
|
|
394
836
|
warnings
|