@blazediff/agent 0.7.0 → 0.8.1
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/dist/cli.js +73 -28
- package/dist/index.d.mts +18 -1
- package/dist/index.d.ts +18 -1
- package/dist/index.js +31 -15
- package/dist/index.mjs +31 -15
- package/package.json +2 -2
package/dist/cli.js
CHANGED
|
@@ -51,7 +51,7 @@ var treeKill__default = /*#__PURE__*/_interopDefault(treeKill);
|
|
|
51
51
|
|
|
52
52
|
// package.json
|
|
53
53
|
var package_default = {
|
|
54
|
-
version: "0.
|
|
54
|
+
version: "0.8.1"};
|
|
55
55
|
var FROZEN_NOW = Date.UTC(2025, 0, 1, 0, 0, 0);
|
|
56
56
|
var STABILITY_CSS = `
|
|
57
57
|
*,*::before,*::after{
|
|
@@ -3686,38 +3686,54 @@ async function crawlRoutes(opts) {
|
|
|
3686
3686
|
const visited = /* @__PURE__ */ new Set(["/"]);
|
|
3687
3687
|
const queue = [{ url: "/", depth: 0 }];
|
|
3688
3688
|
const discovered = [];
|
|
3689
|
+
const recorded = /* @__PURE__ */ new Set();
|
|
3690
|
+
const record = (path30) => {
|
|
3691
|
+
if (recorded.has(path30)) return;
|
|
3692
|
+
recorded.add(path30);
|
|
3693
|
+
discovered.push({ url: path30, source: "crawl" });
|
|
3694
|
+
};
|
|
3689
3695
|
const handle = await acquireStableContext(CRAWL_VIEWPORT);
|
|
3690
3696
|
const fetchOne = async () => {
|
|
3691
3697
|
while (queue.length && discovered.length < maxRoutes) {
|
|
3692
3698
|
const item = queue.shift();
|
|
3693
3699
|
if (!item) return;
|
|
3694
3700
|
if (discovered.length >= maxRoutes) return;
|
|
3695
|
-
discovered.push({ url: item.url, source: "crawl" });
|
|
3696
|
-
if (item.depth >= maxDepth) continue;
|
|
3697
3701
|
const page = await handle.context.newPage();
|
|
3702
|
+
const requested = new URL(item.url, base).toString();
|
|
3703
|
+
let finalPath = item.url;
|
|
3704
|
+
let resolved = requested;
|
|
3705
|
+
let hrefs = [];
|
|
3698
3706
|
try {
|
|
3699
|
-
|
|
3700
|
-
await page.goto(target, {
|
|
3707
|
+
await page.goto(requested, {
|
|
3701
3708
|
waitUntil: "domcontentloaded",
|
|
3702
3709
|
timeout: 15e3
|
|
3703
3710
|
});
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3711
|
+
const finalUrl = new URL(page.url());
|
|
3712
|
+
if (finalUrl.origin === base.origin) {
|
|
3713
|
+
resolved = finalUrl.toString();
|
|
3714
|
+
finalPath = finalUrl.pathname + finalUrl.search;
|
|
3715
|
+
}
|
|
3716
|
+
if (item.depth < maxDepth) {
|
|
3717
|
+
await page.waitForLoadState("networkidle", { timeout: 5e3 }).catch(() => {
|
|
3718
|
+
});
|
|
3719
|
+
hrefs = await page.evaluate(
|
|
3720
|
+
() => Array.from(
|
|
3721
|
+
document.querySelectorAll("a[href]")
|
|
3722
|
+
).map((a) => a.getAttribute("href") ?? "")
|
|
3723
|
+
);
|
|
3715
3724
|
}
|
|
3716
3725
|
} catch {
|
|
3717
3726
|
} finally {
|
|
3718
3727
|
await page.close().catch(() => {
|
|
3719
3728
|
});
|
|
3720
3729
|
}
|
|
3730
|
+
record(finalPath);
|
|
3731
|
+
if (item.depth >= maxDepth) continue;
|
|
3732
|
+
for (const p of extractInternalLinks(base, resolved, hrefs)) {
|
|
3733
|
+
if (visited.has(p)) continue;
|
|
3734
|
+
visited.add(p);
|
|
3735
|
+
queue.push({ url: p, depth: item.depth + 1 });
|
|
3736
|
+
}
|
|
3721
3737
|
}
|
|
3722
3738
|
};
|
|
3723
3739
|
try {
|
|
@@ -3762,6 +3778,17 @@ function collapseTemplates(routes, { threshold, samples } = DEFAULT_SAMPLING) {
|
|
|
3762
3778
|
}
|
|
3763
3779
|
|
|
3764
3780
|
// src/discover/index.ts
|
|
3781
|
+
function resolveSampling(discovery) {
|
|
3782
|
+
if (discovery?.sampleTemplates === false) return false;
|
|
3783
|
+
const { sampleThreshold, samplesPerTemplate } = discovery ?? {};
|
|
3784
|
+
if (sampleThreshold === void 0 && samplesPerTemplate === void 0) {
|
|
3785
|
+
return true;
|
|
3786
|
+
}
|
|
3787
|
+
return {
|
|
3788
|
+
threshold: sampleThreshold ?? DEFAULT_SAMPLE_THRESHOLD,
|
|
3789
|
+
samples: samplesPerTemplate ?? DEFAULT_SAMPLES_PER_TEMPLATE
|
|
3790
|
+
};
|
|
3791
|
+
}
|
|
3765
3792
|
function normalizePath(url) {
|
|
3766
3793
|
const [pathPart, query = ""] = url.split("?", 2);
|
|
3767
3794
|
const trimmed = pathPart.replace(/\/+$/, "");
|
|
@@ -3806,18 +3833,19 @@ function registerDiscover(program, out) {
|
|
|
3806
3833
|
"--sample-threshold <n>",
|
|
3807
3834
|
"group size at which template sampling kicks in",
|
|
3808
3835
|
String(DEFAULT_SAMPLE_THRESHOLD)
|
|
3809
|
-
).action(async (opts) => {
|
|
3810
|
-
const
|
|
3836
|
+
).action(async (opts, command) => {
|
|
3837
|
+
const config = await loadConfig();
|
|
3838
|
+
const baseUrl = resolveBaseUrl(config, opts.baseUrl);
|
|
3839
|
+
const fromCli = (name) => command.getOptionValueSource(name) === "cli";
|
|
3840
|
+
const d = config?.discovery;
|
|
3841
|
+
const maxRoutes = fromCli("maxRoutes") ? Number(opts.maxRoutes) : d?.maxRoutes ?? Number(opts.maxRoutes);
|
|
3842
|
+
const sampleOn = fromCli("sampleTemplates") ? opts.sampleTemplates : d?.sampleTemplates ?? true;
|
|
3843
|
+
const threshold = fromCli("sampleThreshold") ? posInt(opts.sampleThreshold, DEFAULT_SAMPLE_THRESHOLD) : d?.sampleThreshold ?? DEFAULT_SAMPLE_THRESHOLD;
|
|
3844
|
+
const samples = fromCli("samplesPerTemplate") ? posInt(opts.samplesPerTemplate, DEFAULT_SAMPLES_PER_TEMPLATE) : d?.samplesPerTemplate ?? DEFAULT_SAMPLES_PER_TEMPLATE;
|
|
3811
3845
|
const routes = await discover({
|
|
3812
3846
|
baseUrl,
|
|
3813
|
-
maxRoutes
|
|
3814
|
-
sampleTemplates:
|
|
3815
|
-
threshold: posInt(opts.sampleThreshold, DEFAULT_SAMPLE_THRESHOLD),
|
|
3816
|
-
samples: posInt(
|
|
3817
|
-
opts.samplesPerTemplate,
|
|
3818
|
-
DEFAULT_SAMPLES_PER_TEMPLATE
|
|
3819
|
-
)
|
|
3820
|
-
}
|
|
3847
|
+
maxRoutes,
|
|
3848
|
+
sampleTemplates: sampleOn && { threshold, samples }
|
|
3821
3849
|
});
|
|
3822
3850
|
await closeBrowser();
|
|
3823
3851
|
out.emit(
|
|
@@ -4712,7 +4740,11 @@ async function captureBaselines(config, baseUrl) {
|
|
|
4712
4740
|
startedByUs = true;
|
|
4713
4741
|
}
|
|
4714
4742
|
try {
|
|
4715
|
-
const discovered = await discover({
|
|
4743
|
+
const discovered = await discover({
|
|
4744
|
+
baseUrl,
|
|
4745
|
+
maxRoutes: config.discovery?.maxRoutes,
|
|
4746
|
+
sampleTemplates: resolveSampling(config.discovery)
|
|
4747
|
+
});
|
|
4716
4748
|
const routes = toCaptureRoutes(discovered);
|
|
4717
4749
|
if (routes.length === 0) return { captured: 0, routes: 0 };
|
|
4718
4750
|
const report = await runCaptures({
|
|
@@ -4762,7 +4794,10 @@ function registerOnboard(program, out) {
|
|
|
4762
4794
|
).option("--dev-command <cmd>", "override detected dev-server command").option("--port <n>", "override detected port").option(
|
|
4763
4795
|
"--dev-script <name>",
|
|
4764
4796
|
"select a dev script by name when multiple candidates exist"
|
|
4765
|
-
).option("--no-browsers", "skip the Chromium install step").option("--no-capture", "skip the baseline-capture step").option(
|
|
4797
|
+
).option("--no-browsers", "skip the Chromium install step").option("--no-capture", "skip the baseline-capture step").option(
|
|
4798
|
+
"--no-sample-templates",
|
|
4799
|
+
"capture every reachable route; don't collapse large list/detail groups (persisted to config.discovery)"
|
|
4800
|
+
).option("--yes", "accept all prompts (capture baselines, install Chromium)").action(async (opts) => {
|
|
4766
4801
|
const cwd = process.cwd();
|
|
4767
4802
|
const interactive = out.isTTY() && !out.isJson();
|
|
4768
4803
|
const lines = [];
|
|
@@ -4784,6 +4819,16 @@ function registerOnboard(program, out) {
|
|
|
4784
4819
|
throw err;
|
|
4785
4820
|
}
|
|
4786
4821
|
}
|
|
4822
|
+
if (config && opts.sampleTemplates === false && config.discovery?.sampleTemplates !== false) {
|
|
4823
|
+
config = {
|
|
4824
|
+
...config,
|
|
4825
|
+
discovery: { ...config.discovery, sampleTemplates: false }
|
|
4826
|
+
};
|
|
4827
|
+
await saveConfig(config, cwd);
|
|
4828
|
+
lines.push(
|
|
4829
|
+
"discovery: template sampling disabled (config.discovery.sampleTemplates=false)"
|
|
4830
|
+
);
|
|
4831
|
+
}
|
|
4787
4832
|
let chromium2 = {
|
|
4788
4833
|
installed: true,
|
|
4789
4834
|
skipped: true
|
package/dist/index.d.mts
CHANGED
|
@@ -132,6 +132,21 @@ interface DevServerConfig {
|
|
|
132
132
|
cwd?: string;
|
|
133
133
|
readyTimeoutMs?: number;
|
|
134
134
|
}
|
|
135
|
+
/** Route-discovery tuning, honored by both `discover` and `onboard` captures. */
|
|
136
|
+
interface DiscoveryConfig {
|
|
137
|
+
/** cap on routes returned (default 50) */
|
|
138
|
+
maxRoutes?: number;
|
|
139
|
+
/**
|
|
140
|
+
* Collapse large list/detail template groups (e.g. /blog/:slug) down to a
|
|
141
|
+
* few representatives. Set `false` for content sites where sibling routes are
|
|
142
|
+
* distinct pages you want fully covered (default true).
|
|
143
|
+
*/
|
|
144
|
+
sampleTemplates?: boolean;
|
|
145
|
+
/** representatives kept per sampled group (default 2) */
|
|
146
|
+
samplesPerTemplate?: number;
|
|
147
|
+
/** group size at which sampling kicks in (default 5) */
|
|
148
|
+
sampleThreshold?: number;
|
|
149
|
+
}
|
|
135
150
|
interface AgentConfig {
|
|
136
151
|
devServer: DevServerConfig | null;
|
|
137
152
|
framework?: string;
|
|
@@ -139,6 +154,8 @@ interface AgentConfig {
|
|
|
139
154
|
baseUrl?: string;
|
|
140
155
|
/** default judge backend for `check`, set by `onboard --stack` */
|
|
141
156
|
judge?: JudgeBackend;
|
|
157
|
+
/** route-discovery tuning for `discover` and `onboard` captures */
|
|
158
|
+
discovery?: DiscoveryConfig;
|
|
142
159
|
}
|
|
143
160
|
interface CaptureOptions {
|
|
144
161
|
id: string;
|
|
@@ -493,4 +510,4 @@ declare function approveEntry(id: string, cwd?: string): Promise<ReviewEntry | n
|
|
|
493
510
|
*/
|
|
494
511
|
declare function rejectEntry(id: string, cwd?: string): Promise<ReviewEntry | null>;
|
|
495
512
|
|
|
496
|
-
export { type AgentConfig, type ApplyJudgmentsResult, type BrowsersInstallOptions, type BrowsersInstallResult, type CaptureOptions, type CaptureRouteInput, type CaptureRouteResult, type CheckOptions, type CheckReport, type CheckResult, type DevServerConfig, type DiffOptions, type DiffOutcome, type DiscoveredRoute, type Harness, type HarnessContext, HarnessError, type HarnessRef, type Judge, type JudgeBackend, type JudgeInput, type JudgeOutput, type JudgmentRequest, type JudgmentRequestRegion, type Manifest, type ManifestEntry, type RegionSummary, type ResumeMap, type ResumeOptions, type ReviewEntry, type ReviewPayload, type ReviewRegion, type ReviewRunMeta, type ReviewStatus, type RunCapturesOptions, type RunCapturesReport, type RunEvent, type RunOptions, STABILITY_HOOKS_VERSION, type Verdict, type VerdictAction, type VerdictLabel, type Viewport, type WaitFor, type WaitForSelector, applyJudgments, approveEntry, assertLeftLoginPage, captureScreenshot, configHash, diffEntry, discover, installBrowsers, loadConfig, loadEnvFiles, loadHarness, loadManifest, paths, readReport, rejectEntry, resolveBaseUrl, resolveHarnessFile, resolveJudge, resumeGraph, runCaptures, runCheck, runGraph, saveConfig, saveManifest, threadIdFor, writeReport };
|
|
513
|
+
export { type AgentConfig, type ApplyJudgmentsResult, type BrowsersInstallOptions, type BrowsersInstallResult, type CaptureOptions, type CaptureRouteInput, type CaptureRouteResult, type CheckOptions, type CheckReport, type CheckResult, type DevServerConfig, type DiffOptions, type DiffOutcome, type DiscoveredRoute, type DiscoveryConfig, type Harness, type HarnessContext, HarnessError, type HarnessRef, type Judge, type JudgeBackend, type JudgeInput, type JudgeOutput, type JudgmentRequest, type JudgmentRequestRegion, type Manifest, type ManifestEntry, type RegionSummary, type ResumeMap, type ResumeOptions, type ReviewEntry, type ReviewPayload, type ReviewRegion, type ReviewRunMeta, type ReviewStatus, type RunCapturesOptions, type RunCapturesReport, type RunEvent, type RunOptions, STABILITY_HOOKS_VERSION, type Verdict, type VerdictAction, type VerdictLabel, type Viewport, type WaitFor, type WaitForSelector, applyJudgments, approveEntry, assertLeftLoginPage, captureScreenshot, configHash, diffEntry, discover, installBrowsers, loadConfig, loadEnvFiles, loadHarness, loadManifest, paths, readReport, rejectEntry, resolveBaseUrl, resolveHarnessFile, resolveJudge, resumeGraph, runCaptures, runCheck, runGraph, saveConfig, saveManifest, threadIdFor, writeReport };
|
package/dist/index.d.ts
CHANGED
|
@@ -132,6 +132,21 @@ interface DevServerConfig {
|
|
|
132
132
|
cwd?: string;
|
|
133
133
|
readyTimeoutMs?: number;
|
|
134
134
|
}
|
|
135
|
+
/** Route-discovery tuning, honored by both `discover` and `onboard` captures. */
|
|
136
|
+
interface DiscoveryConfig {
|
|
137
|
+
/** cap on routes returned (default 50) */
|
|
138
|
+
maxRoutes?: number;
|
|
139
|
+
/**
|
|
140
|
+
* Collapse large list/detail template groups (e.g. /blog/:slug) down to a
|
|
141
|
+
* few representatives. Set `false` for content sites where sibling routes are
|
|
142
|
+
* distinct pages you want fully covered (default true).
|
|
143
|
+
*/
|
|
144
|
+
sampleTemplates?: boolean;
|
|
145
|
+
/** representatives kept per sampled group (default 2) */
|
|
146
|
+
samplesPerTemplate?: number;
|
|
147
|
+
/** group size at which sampling kicks in (default 5) */
|
|
148
|
+
sampleThreshold?: number;
|
|
149
|
+
}
|
|
135
150
|
interface AgentConfig {
|
|
136
151
|
devServer: DevServerConfig | null;
|
|
137
152
|
framework?: string;
|
|
@@ -139,6 +154,8 @@ interface AgentConfig {
|
|
|
139
154
|
baseUrl?: string;
|
|
140
155
|
/** default judge backend for `check`, set by `onboard --stack` */
|
|
141
156
|
judge?: JudgeBackend;
|
|
157
|
+
/** route-discovery tuning for `discover` and `onboard` captures */
|
|
158
|
+
discovery?: DiscoveryConfig;
|
|
142
159
|
}
|
|
143
160
|
interface CaptureOptions {
|
|
144
161
|
id: string;
|
|
@@ -493,4 +510,4 @@ declare function approveEntry(id: string, cwd?: string): Promise<ReviewEntry | n
|
|
|
493
510
|
*/
|
|
494
511
|
declare function rejectEntry(id: string, cwd?: string): Promise<ReviewEntry | null>;
|
|
495
512
|
|
|
496
|
-
export { type AgentConfig, type ApplyJudgmentsResult, type BrowsersInstallOptions, type BrowsersInstallResult, type CaptureOptions, type CaptureRouteInput, type CaptureRouteResult, type CheckOptions, type CheckReport, type CheckResult, type DevServerConfig, type DiffOptions, type DiffOutcome, type DiscoveredRoute, type Harness, type HarnessContext, HarnessError, type HarnessRef, type Judge, type JudgeBackend, type JudgeInput, type JudgeOutput, type JudgmentRequest, type JudgmentRequestRegion, type Manifest, type ManifestEntry, type RegionSummary, type ResumeMap, type ResumeOptions, type ReviewEntry, type ReviewPayload, type ReviewRegion, type ReviewRunMeta, type ReviewStatus, type RunCapturesOptions, type RunCapturesReport, type RunEvent, type RunOptions, STABILITY_HOOKS_VERSION, type Verdict, type VerdictAction, type VerdictLabel, type Viewport, type WaitFor, type WaitForSelector, applyJudgments, approveEntry, assertLeftLoginPage, captureScreenshot, configHash, diffEntry, discover, installBrowsers, loadConfig, loadEnvFiles, loadHarness, loadManifest, paths, readReport, rejectEntry, resolveBaseUrl, resolveHarnessFile, resolveJudge, resumeGraph, runCaptures, runCheck, runGraph, saveConfig, saveManifest, threadIdFor, writeReport };
|
|
513
|
+
export { type AgentConfig, type ApplyJudgmentsResult, type BrowsersInstallOptions, type BrowsersInstallResult, type CaptureOptions, type CaptureRouteInput, type CaptureRouteResult, type CheckOptions, type CheckReport, type CheckResult, type DevServerConfig, type DiffOptions, type DiffOutcome, type DiscoveredRoute, type DiscoveryConfig, type Harness, type HarnessContext, HarnessError, type HarnessRef, type Judge, type JudgeBackend, type JudgeInput, type JudgeOutput, type JudgmentRequest, type JudgmentRequestRegion, type Manifest, type ManifestEntry, type RegionSummary, type ResumeMap, type ResumeOptions, type ReviewEntry, type ReviewPayload, type ReviewRegion, type ReviewRunMeta, type ReviewStatus, type RunCapturesOptions, type RunCapturesReport, type RunEvent, type RunOptions, STABILITY_HOOKS_VERSION, type Verdict, type VerdictAction, type VerdictLabel, type Viewport, type WaitFor, type WaitForSelector, applyJudgments, approveEntry, assertLeftLoginPage, captureScreenshot, configHash, diffEntry, discover, installBrowsers, loadConfig, loadEnvFiles, loadHarness, loadManifest, paths, readReport, rejectEntry, resolveBaseUrl, resolveHarnessFile, resolveJudge, resumeGraph, runCaptures, runCheck, runGraph, saveConfig, saveManifest, threadIdFor, writeReport };
|
package/dist/index.js
CHANGED
|
@@ -895,38 +895,54 @@ async function crawlRoutes(opts) {
|
|
|
895
895
|
const visited = /* @__PURE__ */ new Set(["/"]);
|
|
896
896
|
const queue = [{ url: "/", depth: 0 }];
|
|
897
897
|
const discovered = [];
|
|
898
|
+
const recorded = /* @__PURE__ */ new Set();
|
|
899
|
+
const record = (path22) => {
|
|
900
|
+
if (recorded.has(path22)) return;
|
|
901
|
+
recorded.add(path22);
|
|
902
|
+
discovered.push({ url: path22, source: "crawl" });
|
|
903
|
+
};
|
|
898
904
|
const handle = await acquireStableContext(CRAWL_VIEWPORT);
|
|
899
905
|
const fetchOne = async () => {
|
|
900
906
|
while (queue.length && discovered.length < maxRoutes) {
|
|
901
907
|
const item = queue.shift();
|
|
902
908
|
if (!item) return;
|
|
903
909
|
if (discovered.length >= maxRoutes) return;
|
|
904
|
-
discovered.push({ url: item.url, source: "crawl" });
|
|
905
|
-
if (item.depth >= maxDepth) continue;
|
|
906
910
|
const page = await handle.context.newPage();
|
|
911
|
+
const requested = new URL(item.url, base).toString();
|
|
912
|
+
let finalPath = item.url;
|
|
913
|
+
let resolved = requested;
|
|
914
|
+
let hrefs = [];
|
|
907
915
|
try {
|
|
908
|
-
|
|
909
|
-
await page.goto(target, {
|
|
916
|
+
await page.goto(requested, {
|
|
910
917
|
waitUntil: "domcontentloaded",
|
|
911
918
|
timeout: 15e3
|
|
912
919
|
});
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
920
|
+
const finalUrl = new URL(page.url());
|
|
921
|
+
if (finalUrl.origin === base.origin) {
|
|
922
|
+
resolved = finalUrl.toString();
|
|
923
|
+
finalPath = finalUrl.pathname + finalUrl.search;
|
|
924
|
+
}
|
|
925
|
+
if (item.depth < maxDepth) {
|
|
926
|
+
await page.waitForLoadState("networkidle", { timeout: 5e3 }).catch(() => {
|
|
927
|
+
});
|
|
928
|
+
hrefs = await page.evaluate(
|
|
929
|
+
() => Array.from(
|
|
930
|
+
document.querySelectorAll("a[href]")
|
|
931
|
+
).map((a) => a.getAttribute("href") ?? "")
|
|
932
|
+
);
|
|
924
933
|
}
|
|
925
934
|
} catch {
|
|
926
935
|
} finally {
|
|
927
936
|
await page.close().catch(() => {
|
|
928
937
|
});
|
|
929
938
|
}
|
|
939
|
+
record(finalPath);
|
|
940
|
+
if (item.depth >= maxDepth) continue;
|
|
941
|
+
for (const p of extractInternalLinks(base, resolved, hrefs)) {
|
|
942
|
+
if (visited.has(p)) continue;
|
|
943
|
+
visited.add(p);
|
|
944
|
+
queue.push({ url: p, depth: item.depth + 1 });
|
|
945
|
+
}
|
|
930
946
|
}
|
|
931
947
|
};
|
|
932
948
|
try {
|
package/dist/index.mjs
CHANGED
|
@@ -867,38 +867,54 @@ async function crawlRoutes(opts) {
|
|
|
867
867
|
const visited = /* @__PURE__ */ new Set(["/"]);
|
|
868
868
|
const queue = [{ url: "/", depth: 0 }];
|
|
869
869
|
const discovered = [];
|
|
870
|
+
const recorded = /* @__PURE__ */ new Set();
|
|
871
|
+
const record = (path22) => {
|
|
872
|
+
if (recorded.has(path22)) return;
|
|
873
|
+
recorded.add(path22);
|
|
874
|
+
discovered.push({ url: path22, source: "crawl" });
|
|
875
|
+
};
|
|
870
876
|
const handle = await acquireStableContext(CRAWL_VIEWPORT);
|
|
871
877
|
const fetchOne = async () => {
|
|
872
878
|
while (queue.length && discovered.length < maxRoutes) {
|
|
873
879
|
const item = queue.shift();
|
|
874
880
|
if (!item) return;
|
|
875
881
|
if (discovered.length >= maxRoutes) return;
|
|
876
|
-
discovered.push({ url: item.url, source: "crawl" });
|
|
877
|
-
if (item.depth >= maxDepth) continue;
|
|
878
882
|
const page = await handle.context.newPage();
|
|
883
|
+
const requested = new URL(item.url, base).toString();
|
|
884
|
+
let finalPath = item.url;
|
|
885
|
+
let resolved = requested;
|
|
886
|
+
let hrefs = [];
|
|
879
887
|
try {
|
|
880
|
-
|
|
881
|
-
await page.goto(target, {
|
|
888
|
+
await page.goto(requested, {
|
|
882
889
|
waitUntil: "domcontentloaded",
|
|
883
890
|
timeout: 15e3
|
|
884
891
|
});
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
892
|
+
const finalUrl = new URL(page.url());
|
|
893
|
+
if (finalUrl.origin === base.origin) {
|
|
894
|
+
resolved = finalUrl.toString();
|
|
895
|
+
finalPath = finalUrl.pathname + finalUrl.search;
|
|
896
|
+
}
|
|
897
|
+
if (item.depth < maxDepth) {
|
|
898
|
+
await page.waitForLoadState("networkidle", { timeout: 5e3 }).catch(() => {
|
|
899
|
+
});
|
|
900
|
+
hrefs = await page.evaluate(
|
|
901
|
+
() => Array.from(
|
|
902
|
+
document.querySelectorAll("a[href]")
|
|
903
|
+
).map((a) => a.getAttribute("href") ?? "")
|
|
904
|
+
);
|
|
896
905
|
}
|
|
897
906
|
} catch {
|
|
898
907
|
} finally {
|
|
899
908
|
await page.close().catch(() => {
|
|
900
909
|
});
|
|
901
910
|
}
|
|
911
|
+
record(finalPath);
|
|
912
|
+
if (item.depth >= maxDepth) continue;
|
|
913
|
+
for (const p of extractInternalLinks(base, resolved, hrefs)) {
|
|
914
|
+
if (visited.has(p)) continue;
|
|
915
|
+
visited.add(p);
|
|
916
|
+
queue.push({ url: p, depth: item.depth + 1 });
|
|
917
|
+
}
|
|
902
918
|
}
|
|
903
919
|
};
|
|
904
920
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blazediff/agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "Agentic visual regression for BlazeDiff. Auto-discovers routes, captures deterministic screenshots, runs CI checks.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"sharp": "^0.34.0",
|
|
49
49
|
"tree-kill": "^1.2.2",
|
|
50
50
|
"zod": "^3.25.32",
|
|
51
|
-
"@blazediff/core-native": "5.
|
|
51
|
+
"@blazediff/core-native": "5.2.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@huggingface/transformers": "^4.2.0"
|