@far-world-labs/verblets 0.6.3 → 0.7.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 +98 -11
- package/dist/index.browser.js +206 -206
- package/dist/index.js +668 -645
- package/dist/shared-Dc73O74G.js +12507 -0
- package/package.json +2 -2
- package/dist/shared-BSAzZOFX.js +0 -11644
package/dist/index.js
CHANGED
|
@@ -1,34 +1,33 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
1
|
+
import pe from "dotenv";
|
|
2
|
+
import { i as de, n as B, c as M, g as se, E as q, a as me, O as D, w as V, r as W, j as U, b as he, D as O, d as C, e as T, s as ae, f as ge, h as fe, k as be, l as ye, p as we } from "./shared-Dc73O74G.js";
|
|
3
|
+
import { cJ as Nt, L as $t, I as Bt, M as Mt, bX as Ut, aI as Ot, bV as zt, aE as _t, K as jt, J as qt, cH as Vt, bZ as Wt, b_ as Gt, an as Ht, cG as Jt, c0 as Kt, c1 as Xt, Q as Yt, a_ as Qt, b$ as Zt, b1 as es, bY as ts, bP as ss, bi as as, bd as ns, be as rs, bO as os, a4 as is, a3 as cs, bg as ls, u as us, aB as ps, bf as ds, aa as ms, F as hs, H as gs, G as fs, aA as bs, bb as ys, a6 as ws, a7 as vs, co as xs, bJ as Ss, x as ks, m as Cs, bU as Is, aC as As, bH as Es, aD as Ps, cp as Ts, b3 as Rs, cL as Ds, t as Ls, aF as Fs, cq as Ns, bL as $s, N as Bs, W as Ms, v as Us, bK as Os, U as zs, a8 as _s, a9 as js, ao as qs, aG as Vs, aJ as Ws, aL as Gs, bo as Hs, bF as Js, bp as Ks, bD as Xs, bq as Ys, bt as Qs, bu as Zs, bE as ea, bx as ta, bC as sa, bB as aa, cE as na, bw as ra, bA as oa, bG as ia, by as ca, bz as la, br as ua, ad as pa, ac as da, a1 as ma, a2 as ha, X as ga, bh as fa, ae as ba, ab as ya, cf as wa, aU as va, aM as xa, af as Sa, aN as ka, c8 as Ca, ag as Ia, c9 as Aa, al as Ea, aH as Pa, S as Ta, T as Ra, ah as Da, ai as La, cb as Fa, cK as Na, bj as $a, aj as Ba, aO as Ma, cr as Ua, ak as Oa, am as za, ap as _a, bk as ja, bl as qa, aq as Va, c7 as Wa, ay as Ga, aP as Ha, aQ as Ja, bR as Ka, bM as Xa, y as Ya, z as Qa, P as Za, R as en, cs as tn, c3 as sn, c4 as an, c6 as nn, c2 as rn, c5 as on, bN as cn, cn as ln, aW as un, aX as pn, aR as dn, bl as mn, ct as hn, cz as gn, aS as fn, cC as bn, cD as yn, cA as wn, aT as vn, bI as xn, ca as Sn, aY as kn, aV as Cn, cI as In, cF as An, o as En, bW as Pn, C as Tn, A as Rn, B as Dn, aZ as Ln, cB as Fn, ba as Nn, ar as $n, bv as Bn, au as Mn, at as Un, as as On, bm as zn, bs as _n, q as jn, bn as qn, cy as Vn, aK as Wn, bT as Gn, a$ as Hn, bc as Jn, av as Kn, cu as Xn, b0 as Yn, ch as Qn, cg as Zn, a5 as er, az as tr, aw as sr, ax as ar, b2 as nr, Z as rr, _ as or, Y as ir, a0 as cr, bS as lr, bQ as ur, b4 as pr, b5 as dr, ci as mr, ck as hr, cl as gr, cj as fr, cm as br, b6 as yr, b7 as wr, cv as vr, $ as xr, V as Sr, cw as kr, b9 as Cr, b8 as Ir, cc as Ar, cd as Er, ce as Pr, cx as Tr } from "./shared-Dc73O74G.js";
|
|
4
|
+
import * as J from "playwright-core";
|
|
5
|
+
import k from "node:fs";
|
|
6
|
+
import "node:path";
|
|
7
7
|
import "glob";
|
|
8
|
-
import
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
})[t], O = (t) => () => {
|
|
8
|
+
import ve from "node:fs/promises";
|
|
9
|
+
const z = 60, xe = (t) => ({
|
|
10
|
+
low: { width: 300, quality: z, format: "jpeg" },
|
|
11
|
+
med: { width: 100, quality: z, format: "jpeg" },
|
|
12
|
+
high: { width: 50, quality: z, format: "jpeg" }
|
|
13
|
+
})[t], G = (t) => () => {
|
|
15
14
|
throw new Error(`${t} is not available in browser environment`);
|
|
16
|
-
},
|
|
15
|
+
}, Et = G("resizeImage"), Pt = G("tileImages"), Tt = G("imageToBase64"), Rt = () => {
|
|
17
16
|
throw new Error("webScrape is not available in browser environment");
|
|
18
|
-
},
|
|
17
|
+
}, Se = async (t, a) => (await t.evaluate(() => {
|
|
19
18
|
const s = /* @__PURE__ */ new Set();
|
|
20
19
|
return [...document.querySelectorAll("a[href]")].map((n) => {
|
|
21
|
-
const
|
|
22
|
-
if (s.has(
|
|
23
|
-
s.add(
|
|
24
|
-
const
|
|
20
|
+
const o = n.href;
|
|
21
|
+
if (s.has(o)) return;
|
|
22
|
+
s.add(o);
|
|
23
|
+
const i = n.getBoundingClientRect();
|
|
25
24
|
return {
|
|
26
|
-
href:
|
|
25
|
+
href: o,
|
|
27
26
|
text: n.textContent?.trim()?.slice(0, 120) || "",
|
|
28
27
|
ariaLabel: n.getAttribute("aria-label") || "",
|
|
29
28
|
rel: n.getAttribute("rel") || "",
|
|
30
29
|
target: n.getAttribute("target") || "",
|
|
31
|
-
isVisible:
|
|
30
|
+
isVisible: i.width > 0 && i.height > 0,
|
|
32
31
|
classes: n.className?.slice?.(0, 120) || "",
|
|
33
32
|
dataAttrs: Object.fromEntries(
|
|
34
33
|
[...n.attributes].filter((r) => r.name.startsWith("data-")).map((r) => [r.name, r.value?.slice(0, 80)])
|
|
@@ -43,7 +42,7 @@ const he = (t) => {
|
|
|
43
42
|
isExternal: !s.href.startsWith(a),
|
|
44
43
|
isSameDomain: s.href.startsWith(a),
|
|
45
44
|
isAnchor: s.href.includes("#") && new URL(s.href).pathname === new URL(t.url()).pathname
|
|
46
|
-
})),
|
|
45
|
+
})), ke = (t) => t.evaluate(
|
|
47
46
|
() => [...document.querySelectorAll("form")].map((a) => ({
|
|
48
47
|
action: a.action || "",
|
|
49
48
|
method: (a.method || "GET").toUpperCase(),
|
|
@@ -68,7 +67,7 @@ const he = (t) => {
|
|
|
68
67
|
})) : void 0
|
|
69
68
|
}))
|
|
70
69
|
}))
|
|
71
|
-
),
|
|
70
|
+
), Ce = (t) => t.evaluate(() => {
|
|
72
71
|
const a = [
|
|
73
72
|
...document.querySelectorAll(
|
|
74
73
|
'button, [role="button"], input[type="button"], input[type="submit"]'
|
|
@@ -77,7 +76,7 @@ const he = (t) => {
|
|
|
77
76
|
...document.querySelectorAll("[onclick], [data-action], [data-toggle], [data-target]")
|
|
78
77
|
];
|
|
79
78
|
return [.../* @__PURE__ */ new Set([...a, ...e])].map((n) => {
|
|
80
|
-
const
|
|
79
|
+
const o = n.getBoundingClientRect();
|
|
81
80
|
return {
|
|
82
81
|
tag: n.tagName.toLowerCase(),
|
|
83
82
|
type: n.type || "",
|
|
@@ -85,16 +84,16 @@ const he = (t) => {
|
|
|
85
84
|
id: n.id || "",
|
|
86
85
|
classes: (typeof n.className == "string" ? n.className : n.className?.baseVal || "").slice(0, 120),
|
|
87
86
|
ariaLabel: n.getAttribute("aria-label") || "",
|
|
88
|
-
isVisible:
|
|
87
|
+
isVisible: o.width > 0 && o.height > 0,
|
|
89
88
|
disabled: n.disabled || n.getAttribute("aria-disabled") === "true",
|
|
90
89
|
hasOnclick: !!n.getAttribute("onclick"),
|
|
91
90
|
onclick: n.getAttribute("onclick")?.slice(0, 120) || "",
|
|
92
91
|
dataAttrs: Object.fromEntries(
|
|
93
|
-
[...n.attributes].filter((
|
|
92
|
+
[...n.attributes].filter((i) => i.name.startsWith("data-")).map((i) => [i.name, i.value?.slice(0, 80)])
|
|
94
93
|
)
|
|
95
94
|
};
|
|
96
95
|
});
|
|
97
|
-
}),
|
|
96
|
+
}), Ie = (t) => t.evaluate(() => [...document.querySelectorAll("script")].map((e) => ({
|
|
98
97
|
src: e.src || "",
|
|
99
98
|
type: e.type || "",
|
|
100
99
|
isModule: e.type === "module",
|
|
@@ -102,7 +101,7 @@ const he = (t) => {
|
|
|
102
101
|
size: e.textContent?.length || 0,
|
|
103
102
|
// First 200 chars of inline scripts to identify patterns
|
|
104
103
|
preview: e.src ? "" : e.textContent?.trim()?.slice(0, 200)
|
|
105
|
-
}))),
|
|
104
|
+
}))), Ae = (t) => t.evaluate(() => {
|
|
106
105
|
const a = (e) => document.querySelector(`meta[name="${e}"], meta[property="${e}"]`)?.content || "";
|
|
107
106
|
return {
|
|
108
107
|
title: document.title || "",
|
|
@@ -129,7 +128,7 @@ const he = (t) => {
|
|
|
129
128
|
content: e.content?.slice(0, 120)
|
|
130
129
|
}))
|
|
131
130
|
};
|
|
132
|
-
}),
|
|
131
|
+
}), Ee = (t) => t.evaluate(() => {
|
|
133
132
|
const a = [...document.querySelectorAll("h1, h2, h3, h4, h5, h6")].slice(0, 30).map((l) => ({
|
|
134
133
|
level: parseInt(l.tagName[1], 10),
|
|
135
134
|
text: l.textContent?.trim()?.slice(0, 100)
|
|
@@ -144,18 +143,18 @@ const he = (t) => {
|
|
|
144
143
|
classes: (typeof l.className == "string" ? l.className : l.className?.baseVal || "").slice(0, 80)
|
|
145
144
|
})), s = /* @__PURE__ */ new Set();
|
|
146
145
|
document.querySelectorAll("*").forEach((l) => {
|
|
147
|
-
[...l.attributes].filter((
|
|
146
|
+
[...l.attributes].filter((p) => p.name.startsWith("data-")).forEach((p) => s.add(p.name));
|
|
148
147
|
});
|
|
149
|
-
const n = [...document.querySelectorAll('link[rel="stylesheet"]')].map((l) => l.href),
|
|
150
|
-
const
|
|
151
|
-
return typeof
|
|
148
|
+
const n = [...document.querySelectorAll('link[rel="stylesheet"]')].map((l) => l.href), o = /* @__PURE__ */ new Set(), i = (l) => {
|
|
149
|
+
const p = l.className;
|
|
150
|
+
return typeof p == "string" ? p : p?.baseVal || "";
|
|
152
151
|
};
|
|
153
152
|
document.querySelectorAll("[class]").forEach((l) => {
|
|
154
|
-
|
|
155
|
-
|
|
153
|
+
i(l).split(/\s+/).slice(0, 5).forEach((p) => {
|
|
154
|
+
p && o.add(p);
|
|
156
155
|
});
|
|
157
156
|
});
|
|
158
|
-
const r = [...
|
|
157
|
+
const r = [...o].slice(0, 200), c = {}, u = [
|
|
159
158
|
"jQuery",
|
|
160
159
|
"$",
|
|
161
160
|
"React",
|
|
@@ -183,12 +182,12 @@ const he = (t) => {
|
|
|
183
182
|
for (const l of u)
|
|
184
183
|
try {
|
|
185
184
|
if (window[l] !== void 0) {
|
|
186
|
-
const
|
|
187
|
-
c[l] = typeof
|
|
185
|
+
const p = window[l];
|
|
186
|
+
c[l] = typeof p == "function" ? p.fn?.jquery || p.version || "present" : typeof p == "object" ? "present" : String(p).slice(0, 40);
|
|
188
187
|
}
|
|
189
188
|
} catch {
|
|
190
189
|
}
|
|
191
|
-
const
|
|
190
|
+
const d = /* @__PURE__ */ new Set(), m = [
|
|
192
191
|
"onclick",
|
|
193
192
|
"onsubmit",
|
|
194
193
|
"onchange",
|
|
@@ -199,109 +198,118 @@ const he = (t) => {
|
|
|
199
198
|
"onkeyup",
|
|
200
199
|
"onkeydown"
|
|
201
200
|
];
|
|
202
|
-
for (const l of
|
|
203
|
-
document.querySelectorAll(`[${l}]`).length > 0 &&
|
|
201
|
+
for (const l of m)
|
|
202
|
+
document.querySelectorAll(`[${l}]`).length > 0 && d.add(l);
|
|
204
203
|
return {
|
|
205
204
|
headings: a,
|
|
206
205
|
landmarks: e,
|
|
207
|
-
dataAttributes:
|
|
206
|
+
dataAttributes: Array.from(s).toSorted().slice(0, 100),
|
|
208
207
|
stylesheets: n.slice(0, 20),
|
|
209
208
|
sampleClasses: r,
|
|
210
209
|
globals: c,
|
|
211
|
-
inlineHandlers: [...
|
|
210
|
+
inlineHandlers: [...d],
|
|
212
211
|
iframeCount: document.querySelectorAll("iframe").length,
|
|
213
212
|
shadowRootCount: [...document.querySelectorAll("*")].filter((l) => l.shadowRoot).length
|
|
214
213
|
};
|
|
215
|
-
}),
|
|
216
|
-
const a = t.url(), e = new URL(a).origin, [s, n,
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
214
|
+
}), Pe = async (t) => {
|
|
215
|
+
const a = t.url(), e = new URL(a).origin, [s, n, o, i, r, c] = await Promise.all([
|
|
216
|
+
Se(t, e),
|
|
217
|
+
ke(t),
|
|
218
|
+
Ce(t),
|
|
219
|
+
Ie(t),
|
|
220
|
+
Ae(t),
|
|
221
|
+
Ee(t)
|
|
223
222
|
]);
|
|
224
|
-
return { url: a, links: s, forms: n, buttons:
|
|
225
|
-
},
|
|
223
|
+
return { url: a, links: s, forms: n, buttons: o, scripts: i, meta: r, structure: c };
|
|
224
|
+
}, _ = (t) => {
|
|
226
225
|
const a = new URL(t);
|
|
227
226
|
a.hash = "";
|
|
228
|
-
const e =
|
|
227
|
+
const e = Array.from(a.searchParams.entries()).toSorted(([n], [o]) => n.localeCompare(o));
|
|
229
228
|
a.search = new URLSearchParams(e).toString();
|
|
230
229
|
const s = a.toString();
|
|
231
230
|
return s.endsWith("/") && a.pathname !== "/" ? s.slice(0, -1) : s;
|
|
232
|
-
},
|
|
233
|
-
const e = new URL(t).origin, s = a.sameDomain !== !1, n = a.maxDepth ?? 10,
|
|
234
|
-
return
|
|
235
|
-
addLinks: (b,
|
|
236
|
-
let
|
|
237
|
-
for (const
|
|
238
|
-
const
|
|
239
|
-
if (c.has(
|
|
240
|
-
if (c.add(
|
|
241
|
-
r.set(
|
|
231
|
+
}, Te = (t, a = 2) => `/${new URL(t).pathname.split("/").filter(Boolean).slice(0, a).join("/")}`, Re = (t, a = {}) => {
|
|
232
|
+
const e = new URL(t).origin, s = a.sameDomain !== !1, n = a.maxDepth ?? 10, o = [], i = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Set(), u = _(t);
|
|
233
|
+
return o.push({ url: t, normalized: u, depth: 0, source: "(start)" }), c.add(u), {
|
|
234
|
+
addLinks: (b, w, h) => {
|
|
235
|
+
let y = 0;
|
|
236
|
+
for (const f of b) {
|
|
237
|
+
const v = f.href || f, x = _(v);
|
|
238
|
+
if (c.has(x)) continue;
|
|
239
|
+
if (c.add(x), s && !v.startsWith(e)) {
|
|
240
|
+
r.set(x, "external");
|
|
242
241
|
continue;
|
|
243
242
|
}
|
|
244
|
-
if (
|
|
245
|
-
r.set(
|
|
243
|
+
if (w + 1 > n) {
|
|
244
|
+
r.set(x, "max-depth");
|
|
246
245
|
continue;
|
|
247
246
|
}
|
|
248
|
-
const
|
|
249
|
-
if (/\.(png|jpg|jpeg|gif|svg|ico|css|js|woff2?|ttf|eot|pdf|zip|mp[34])$/i.test(
|
|
250
|
-
r.set(
|
|
247
|
+
const E = new URL(v).pathname;
|
|
248
|
+
if (/\.(png|jpg|jpeg|gif|svg|ico|css|js|woff2?|ttf|eot|pdf|zip|mp[34])$/i.test(E)) {
|
|
249
|
+
r.set(x, "resource");
|
|
251
250
|
continue;
|
|
252
251
|
}
|
|
253
|
-
if (/^(mailto|tel|javascript):/i.test(
|
|
254
|
-
r.set(
|
|
252
|
+
if (/^(mailto|tel|javascript):/i.test(v)) {
|
|
253
|
+
r.set(x, "scheme");
|
|
255
254
|
continue;
|
|
256
255
|
}
|
|
257
|
-
|
|
256
|
+
o.push({ url: v, normalized: x, depth: w + 1, source: h }), y++;
|
|
258
257
|
}
|
|
259
|
-
return
|
|
258
|
+
return y;
|
|
260
259
|
},
|
|
261
260
|
next: () => {
|
|
262
|
-
const b =
|
|
263
|
-
return b &&
|
|
261
|
+
const b = o.shift();
|
|
262
|
+
return b && i.set(b.normalized, {
|
|
264
263
|
url: b.url,
|
|
265
264
|
depth: b.depth,
|
|
266
265
|
source: b.source
|
|
267
266
|
}), b;
|
|
268
267
|
},
|
|
269
|
-
skip: (b,
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
268
|
+
skip: (b, w) => {
|
|
269
|
+
const h = /* @__PURE__ */ new Set();
|
|
270
|
+
for (const v of b) {
|
|
271
|
+
const x = _(v);
|
|
272
|
+
r.set(x, w), h.add(x);
|
|
273
273
|
}
|
|
274
|
-
const y =
|
|
275
|
-
return
|
|
274
|
+
const y = o.length, f = o.filter((v) => !h.has(v.normalized));
|
|
275
|
+
return o.splice(0, o.length, ...f), y - f.length;
|
|
276
276
|
},
|
|
277
277
|
pendingByPrefix: (b = 2) => {
|
|
278
|
-
const
|
|
279
|
-
for (const
|
|
280
|
-
const
|
|
281
|
-
|
|
278
|
+
const w = /* @__PURE__ */ new Map();
|
|
279
|
+
for (const h of o) {
|
|
280
|
+
const y = Te(h.url, b), f = w.get(y) || [];
|
|
281
|
+
f.push(h), w.set(y, f);
|
|
282
282
|
}
|
|
283
|
-
return
|
|
283
|
+
return w;
|
|
284
284
|
},
|
|
285
|
-
size: () =>
|
|
286
|
-
visitedCount: () =>
|
|
287
|
-
isEmpty: () =>
|
|
285
|
+
size: () => o.length,
|
|
286
|
+
visitedCount: () => i.size,
|
|
287
|
+
isEmpty: () => o.length === 0,
|
|
288
288
|
summary: () => ({
|
|
289
|
-
pending:
|
|
290
|
-
visited:
|
|
289
|
+
pending: o.length,
|
|
290
|
+
visited: i.size,
|
|
291
291
|
skipped: r.size,
|
|
292
292
|
seen: c.size
|
|
293
293
|
}),
|
|
294
|
-
visitedUrls: () => [...
|
|
294
|
+
visitedUrls: () => [...i.entries()].map(([b, w]) => ({
|
|
295
295
|
normalized: b,
|
|
296
|
-
...
|
|
296
|
+
...w
|
|
297
297
|
})),
|
|
298
|
-
skippedUrls: () => [...r.entries()].map(([b,
|
|
298
|
+
skippedUrls: () => [...r.entries()].map(([b, w]) => ({
|
|
299
299
|
url: b,
|
|
300
|
-
reason:
|
|
300
|
+
reason: w
|
|
301
301
|
})),
|
|
302
302
|
origin: e
|
|
303
303
|
};
|
|
304
|
-
},
|
|
304
|
+
}, I = Object.freeze({
|
|
305
|
+
tick: "cooldown:tick",
|
|
306
|
+
visitError: "cooldown:visitError",
|
|
307
|
+
blockCheckError: "cooldown:blockCheckError",
|
|
308
|
+
exhausted: "cooldown:exhausted",
|
|
309
|
+
start: "cooldown:start",
|
|
310
|
+
retry: "cooldown:retry",
|
|
311
|
+
heartbeat: "heartbeat"
|
|
312
|
+
}), ne = {
|
|
305
313
|
baseDelay: 5e3,
|
|
306
314
|
// 5s initial wait
|
|
307
315
|
maxDelay: 3e5,
|
|
@@ -312,77 +320,88 @@ const he = (t) => {
|
|
|
312
320
|
// up to 6 retries (~5m20s total at 2x backoff from 5s)
|
|
313
321
|
jitter: 0.2
|
|
314
322
|
// ±20% randomization to avoid thundering herd
|
|
315
|
-
},
|
|
323
|
+
}, De = async (t) => {
|
|
316
324
|
const a = t.url(), e = await t.evaluate(() => document.body?.innerText?.slice(0, 500)).catch(() => "");
|
|
317
325
|
if (e.includes("Access Denied")) return "access-denied";
|
|
318
326
|
if (e.includes("Rate limit") || e.includes("Too many requests")) return "rate-limit";
|
|
319
327
|
if (e.includes("Please verify you are a human")) return "captcha";
|
|
320
328
|
if (e.includes("Checking your browser")) return "challenge";
|
|
321
329
|
if (a.includes("errors.edgesuite.net")) return "akamai-block";
|
|
322
|
-
},
|
|
330
|
+
}, Le = (t, a) => {
|
|
323
331
|
const e = t * a;
|
|
324
332
|
return t + (Math.random() * 2 - 1) * e;
|
|
325
|
-
},
|
|
333
|
+
}, Fe = (t, a) => {
|
|
326
334
|
const e = a.baseDelay * Math.pow(a.backoffFactor, t), s = Math.min(e, a.maxDelay);
|
|
327
|
-
return Math.round(
|
|
328
|
-
},
|
|
329
|
-
const n = Date.now(),
|
|
330
|
-
let
|
|
331
|
-
for (;
|
|
332
|
-
const r = t -
|
|
333
|
-
await new Promise((u) => setTimeout(u, c)),
|
|
334
|
-
event:
|
|
335
|
-
elapsedMs:
|
|
336
|
-
remainingMs: Math.max(0,
|
|
335
|
+
return Math.round(Le(s, a.jitter));
|
|
336
|
+
}, Ne = async (t, a, e, s) => {
|
|
337
|
+
const n = Date.now(), o = n + t;
|
|
338
|
+
let i = 0;
|
|
339
|
+
for (; i < t; ) {
|
|
340
|
+
const r = t - i, c = Math.min(e, r);
|
|
341
|
+
await new Promise((u) => setTimeout(u, c)), i = Date.now() - n, a.emit({
|
|
342
|
+
event: I.tick,
|
|
343
|
+
elapsedMs: i,
|
|
344
|
+
remainingMs: Math.max(0, o - Date.now()),
|
|
337
345
|
totalMs: t,
|
|
338
346
|
...s
|
|
339
347
|
});
|
|
340
348
|
}
|
|
341
|
-
},
|
|
342
|
-
const r = { ...
|
|
349
|
+
}, $e = async (t, a, e, s, n, o, i) => {
|
|
350
|
+
const r = { ...ne, ...n };
|
|
343
351
|
let c = 0;
|
|
344
352
|
for (let u = 0; u <= r.maxRetries; u++) {
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
353
|
+
let d;
|
|
354
|
+
try {
|
|
355
|
+
d = await t(a, e);
|
|
356
|
+
} catch (p) {
|
|
357
|
+
throw s.emit({ event: I.visitError, url: e, attempt: u, error: p.message }), p;
|
|
358
|
+
}
|
|
359
|
+
let m;
|
|
360
|
+
try {
|
|
361
|
+
m = await o(a);
|
|
362
|
+
} catch (p) {
|
|
363
|
+
throw s.emit({ event: I.blockCheckError, url: e, attempt: u, error: p.message }), p;
|
|
364
|
+
}
|
|
365
|
+
if (!m)
|
|
366
|
+
return { pageData: d, retries: u, totalCooldownMs: c };
|
|
348
367
|
if (u >= r.maxRetries)
|
|
349
368
|
return s.emit({
|
|
350
|
-
event:
|
|
369
|
+
event: I.exhausted,
|
|
351
370
|
url: e,
|
|
352
|
-
reason:
|
|
371
|
+
reason: m,
|
|
353
372
|
attempts: u + 1,
|
|
354
373
|
totalCooldownMs: c
|
|
355
|
-
}), { pageData:
|
|
356
|
-
const l =
|
|
374
|
+
}), { pageData: d, retries: u, totalCooldownMs: c, blocked: m };
|
|
375
|
+
const l = Fe(u, r);
|
|
357
376
|
c += l, s.emit({
|
|
358
|
-
event:
|
|
377
|
+
event: I.start,
|
|
359
378
|
url: e,
|
|
360
|
-
reason:
|
|
379
|
+
reason: m,
|
|
361
380
|
attempt: u + 1,
|
|
362
381
|
maxRetries: r.maxRetries,
|
|
363
382
|
delayMs: l,
|
|
364
383
|
totalCooldownMs: c
|
|
365
|
-
}), await
|
|
384
|
+
}), await Ne(l, s, i, {
|
|
366
385
|
url: e,
|
|
367
|
-
reason:
|
|
386
|
+
reason: m,
|
|
368
387
|
attempt: u + 1
|
|
369
388
|
}), s.emit({
|
|
370
|
-
event:
|
|
389
|
+
event: I.retry,
|
|
371
390
|
url: e,
|
|
372
391
|
attempt: u + 1
|
|
373
392
|
});
|
|
374
393
|
}
|
|
375
|
-
},
|
|
394
|
+
}, Be = (t, a, e) => {
|
|
376
395
|
const s = setInterval(() => {
|
|
377
396
|
t.emit({
|
|
378
|
-
event:
|
|
397
|
+
event: I.heartbeat,
|
|
379
398
|
...e()
|
|
380
399
|
});
|
|
381
400
|
}, a);
|
|
382
401
|
return {
|
|
383
402
|
stop: () => clearInterval(s)
|
|
384
403
|
};
|
|
385
|
-
},
|
|
404
|
+
}, K = "site-crawl", Me = "Browser support is disabled. Call init({ browser: true }) to enable.", Ue = (t, a) => {
|
|
386
405
|
const e = a.summary(), s = t.map((n) => `${new URL(n.url).pathname} — ${n.meta.title || "(no title)"} [${n.links.length} links, ${n.forms.length} forms, ${n.buttons.length} buttons]`);
|
|
387
406
|
return [
|
|
388
407
|
`Crawled ${e.visited} pages, ${e.pending} pending, ${e.skipped} skipped.`,
|
|
@@ -391,11 +410,11 @@ const he = (t) => {
|
|
|
391
410
|
...s.map((n) => ` ${n}`)
|
|
392
411
|
].join(`
|
|
393
412
|
`);
|
|
394
|
-
},
|
|
413
|
+
}, Oe = (t, a, e) => {
|
|
395
414
|
const s = [];
|
|
396
|
-
for (const [n,
|
|
397
|
-
const
|
|
398
|
-
s.push(` ${n} (${
|
|
415
|
+
for (const [n, o] of t) {
|
|
416
|
+
const i = o.slice(0, 5).map((c) => ` ${c.url}`), r = o.length > 5 ? ` ... and ${o.length - 5} more` : "";
|
|
417
|
+
s.push(` ${n} (${o.length} URLs):`), s.push(...i), r && s.push(r);
|
|
399
418
|
}
|
|
400
419
|
return [
|
|
401
420
|
"You are a site crawler deciding which URL branches to explore next.",
|
|
@@ -413,7 +432,7 @@ const he = (t) => {
|
|
|
413
432
|
"Skip groups that are clearly non-functional (help/support, legal, marketing pages)."
|
|
414
433
|
].join(`
|
|
415
434
|
`);
|
|
416
|
-
},
|
|
435
|
+
}, ze = U("crawl_gate", {
|
|
417
436
|
type: "object",
|
|
418
437
|
properties: {
|
|
419
438
|
decisions: {
|
|
@@ -440,58 +459,58 @@ const he = (t) => {
|
|
|
440
459
|
},
|
|
441
460
|
required: ["decisions"],
|
|
442
461
|
additionalProperties: !1
|
|
443
|
-
}),
|
|
462
|
+
}), _e = async (t, a, e, s) => {
|
|
444
463
|
const n = t.pendingByPrefix(2);
|
|
445
464
|
if (n.size === 0) return { explore: [], skip: [], decisions: [] };
|
|
446
|
-
const
|
|
465
|
+
const o = Ue(a, t), i = Oe(n, o, e), c = (await W(i, {
|
|
447
466
|
...s,
|
|
448
|
-
|
|
467
|
+
responseFormat: ze,
|
|
449
468
|
temperature: 0.2
|
|
450
|
-
}))?.decisions || [], u = [],
|
|
451
|
-
for (const
|
|
452
|
-
const l = n.get(
|
|
469
|
+
}))?.decisions || [], u = [], d = [];
|
|
470
|
+
for (const m of c) {
|
|
471
|
+
const l = n.get(m.prefix);
|
|
453
472
|
if (l)
|
|
454
|
-
if (
|
|
455
|
-
|
|
473
|
+
if (m.action === "skip")
|
|
474
|
+
d.push(...l.map((p) => p.url));
|
|
456
475
|
else {
|
|
457
|
-
const
|
|
458
|
-
u.push(...l.slice(0,
|
|
476
|
+
const p = Math.min(m.maxFromGroup || 3, 5, l.length);
|
|
477
|
+
u.push(...l.slice(0, p).map((g) => g.url)), l.length > p && d.push(...l.slice(p).map((g) => g.url));
|
|
459
478
|
}
|
|
460
479
|
}
|
|
461
|
-
for (const [
|
|
462
|
-
c.some((g) => g.prefix ===
|
|
463
|
-
return { explore: u, skip:
|
|
464
|
-
},
|
|
480
|
+
for (const [m, l] of n)
|
|
481
|
+
c.some((g) => g.prefix === m) || (u.push(l[0].url), l.length > 1 && d.push(...l.slice(1).map((g) => g.url)));
|
|
482
|
+
return { explore: u, skip: d, decisions: c };
|
|
483
|
+
}, je = async (t, a, e, s, n, o) => {
|
|
465
484
|
await t.goto(a, { waitUntil: "domcontentloaded", timeout: 3e4 }), await t.waitForTimeout(1500);
|
|
466
|
-
const
|
|
485
|
+
const i = await Pe(t);
|
|
467
486
|
if (n.screenshots) {
|
|
468
487
|
const c = `${s.dir}/crawl-${Date.now()}.png`;
|
|
469
488
|
if (await t.screenshot({ path: c, fullPage: !1 }), s.track(c), n.imageShrink) {
|
|
470
|
-
const u = await
|
|
489
|
+
const u = await he(c, {
|
|
471
490
|
...n.imageShrink,
|
|
472
491
|
outputDir: s.dir
|
|
473
492
|
});
|
|
474
|
-
s.track(u.path),
|
|
493
|
+
s.track(u.path), i.screenshot = u.path;
|
|
475
494
|
} else
|
|
476
|
-
|
|
495
|
+
i.screenshot = c;
|
|
477
496
|
}
|
|
478
497
|
const r = e.responses();
|
|
479
|
-
return
|
|
498
|
+
return i.apis = r.filter((c) => {
|
|
480
499
|
const u = c.url();
|
|
481
500
|
return u.includes("/api/") || u.includes("/v1/") || u.includes("/v2/") || u.includes("/graphql");
|
|
482
501
|
}).map((c) => ({
|
|
483
502
|
url: c.url(),
|
|
484
503
|
status: c.status(),
|
|
485
504
|
method: c.request().method()
|
|
486
|
-
})), e.clear(),
|
|
487
|
-
},
|
|
505
|
+
})), e.clear(), i;
|
|
506
|
+
}, qe = (t) => {
|
|
488
507
|
const a = {};
|
|
489
508
|
for (const e of t) {
|
|
490
509
|
const s = e.links.filter((n) => n.isSameDomain && !n.isAnchor).map((n) => n.href);
|
|
491
510
|
a[e.url] = [...new Set(s)];
|
|
492
511
|
}
|
|
493
512
|
return a;
|
|
494
|
-
},
|
|
513
|
+
}, Ve = (t) => {
|
|
495
514
|
const a = /* @__PURE__ */ new Map();
|
|
496
515
|
for (const e of t)
|
|
497
516
|
for (const s of e.apis || []) {
|
|
@@ -499,100 +518,100 @@ const he = (t) => {
|
|
|
499
518
|
a.has(n) ? a.get(n).seenOn.push(e.url) : a.set(n, { ...s, seenOn: [e.url] });
|
|
500
519
|
}
|
|
501
520
|
return [...a.values()];
|
|
502
|
-
},
|
|
503
|
-
if (!
|
|
504
|
-
const e =
|
|
521
|
+
}, We = async (t, a = {}) => {
|
|
522
|
+
if (!de()) throw new Error(Me);
|
|
523
|
+
const e = B(K, a), s = M(K, e.onProgress, e);
|
|
505
524
|
s.start();
|
|
506
|
-
const n = await
|
|
525
|
+
const n = await se(e, {
|
|
507
526
|
maxPages: 20,
|
|
508
527
|
maxDepth: 5,
|
|
509
528
|
sameDomain: !0,
|
|
510
529
|
gateInterval: 5,
|
|
511
530
|
headless: !0,
|
|
512
531
|
screenshots: !1,
|
|
513
|
-
errorPosture:
|
|
514
|
-
imageShrink:
|
|
532
|
+
errorPosture: q.resilient,
|
|
533
|
+
imageShrink: V(xe),
|
|
515
534
|
heartbeatInterval: 1e3
|
|
516
|
-
}),
|
|
535
|
+
}), o = { ...ne, ...e.cooldown }, i = e.isBlocked || De, r = Re(t, {
|
|
517
536
|
sameDomain: n.sameDomain,
|
|
518
537
|
maxDepth: n.maxDepth
|
|
519
|
-
}), c = await
|
|
538
|
+
}), c = await me("site-crawl", e.outputDir), d = await (e.browserEngine ? J[e.browserEngine] : J.chromium).launch({
|
|
520
539
|
headless: n.headless,
|
|
521
540
|
...e.launchOptions
|
|
522
541
|
});
|
|
523
542
|
s.emit({ event: "browser", headless: n.headless });
|
|
524
543
|
try {
|
|
525
|
-
const
|
|
544
|
+
const m = await d.newContext(e.contextOptions);
|
|
526
545
|
if (e.setup) {
|
|
527
|
-
const
|
|
528
|
-
await e.setup(
|
|
546
|
+
const h = await m.newPage();
|
|
547
|
+
await e.setup(h), await h.close(), s.emit({ event: "setup" });
|
|
529
548
|
}
|
|
530
|
-
const l = await
|
|
531
|
-
const
|
|
532
|
-
return l.on("response", (y) =>
|
|
533
|
-
responses: () => [...
|
|
549
|
+
const l = await m.newPage(), p = (() => {
|
|
550
|
+
const h = [];
|
|
551
|
+
return l.on("response", (y) => h.push(y)), {
|
|
552
|
+
responses: () => [...h],
|
|
534
553
|
clear: () => {
|
|
535
|
-
|
|
554
|
+
h.length = 0;
|
|
536
555
|
}
|
|
537
556
|
};
|
|
538
557
|
})(), g = [];
|
|
539
|
-
let
|
|
540
|
-
const P =
|
|
558
|
+
let S = 0, A = t;
|
|
559
|
+
const P = Be(s, n.heartbeatInterval, () => ({
|
|
541
560
|
pagesVisited: g.length,
|
|
542
561
|
maxPages: n.maxPages,
|
|
543
562
|
pending: r.size(),
|
|
544
|
-
currentUrl:
|
|
563
|
+
currentUrl: A,
|
|
545
564
|
...r.summary()
|
|
546
|
-
}));
|
|
565
|
+
})), L = s.batch(n.maxPages);
|
|
547
566
|
try {
|
|
548
567
|
for (; !r.isEmpty() && g.length < n.maxPages; ) {
|
|
549
568
|
if (g.length > 0 && g.length % n.gateInterval === 0 && r.size() > 0) {
|
|
550
569
|
const y = n.maxPages - g.length;
|
|
551
570
|
s.emit({ event: "gate:start", pending: r.size(), budget: y });
|
|
552
|
-
const f = await
|
|
553
|
-
|
|
571
|
+
const f = await _e(r, g, y, e);
|
|
572
|
+
S++, f.skip.length > 0 && r.skip(f.skip, "llm-gate"), s.emit({
|
|
554
573
|
event: "gate:complete",
|
|
555
574
|
explored: f.explore.length,
|
|
556
575
|
skipped: f.skip.length,
|
|
557
576
|
decisions: f.decisions.length
|
|
558
577
|
});
|
|
559
578
|
}
|
|
560
|
-
const
|
|
561
|
-
if (!
|
|
562
|
-
|
|
579
|
+
const h = r.next();
|
|
580
|
+
if (!h) break;
|
|
581
|
+
A = h.url, s.emit({
|
|
563
582
|
event: "page:start",
|
|
564
|
-
url:
|
|
565
|
-
depth:
|
|
583
|
+
url: h.url,
|
|
584
|
+
depth: h.depth,
|
|
566
585
|
pageNumber: g.length + 1,
|
|
567
586
|
maxPages: n.maxPages
|
|
568
587
|
});
|
|
569
588
|
try {
|
|
570
|
-
const y = (
|
|
589
|
+
const y = (E, ue) => je(E, ue, p, c, n, s), { pageData: f, blocked: v } = await $e(
|
|
571
590
|
y,
|
|
572
591
|
l,
|
|
573
|
-
|
|
592
|
+
h.url,
|
|
574
593
|
s,
|
|
575
|
-
i,
|
|
576
594
|
o,
|
|
595
|
+
i,
|
|
577
596
|
n.heartbeatInterval
|
|
578
597
|
);
|
|
579
|
-
f.depth =
|
|
580
|
-
const x =
|
|
581
|
-
f.links.filter((
|
|
582
|
-
|
|
583
|
-
|
|
598
|
+
f.depth = h.depth, f.source = h.source, v && (f.blocked = v), g.push(f);
|
|
599
|
+
const x = v ? 0 : r.addLinks(
|
|
600
|
+
f.links.filter((E) => E.isSameDomain && !E.isAnchor),
|
|
601
|
+
h.depth,
|
|
602
|
+
h.url
|
|
584
603
|
);
|
|
585
604
|
s.emit({
|
|
586
605
|
event: "page:complete",
|
|
587
|
-
url:
|
|
606
|
+
url: h.url,
|
|
588
607
|
links: f.links.length,
|
|
589
608
|
forms: f.forms.length,
|
|
590
609
|
newUrls: x,
|
|
591
610
|
pending: r.size(),
|
|
592
|
-
blocked:
|
|
593
|
-
});
|
|
611
|
+
blocked: v
|
|
612
|
+
}), L(1);
|
|
594
613
|
} catch (y) {
|
|
595
|
-
if (s.emit({ event: "page:error", url:
|
|
614
|
+
if (s.emit({ event: "page:error", url: h.url, error: y.message }), n.errorPosture === q.strict) throw y;
|
|
596
615
|
}
|
|
597
616
|
}
|
|
598
617
|
} finally {
|
|
@@ -600,39 +619,41 @@ const he = (t) => {
|
|
|
600
619
|
}
|
|
601
620
|
if (await l.close(), e.teardown) {
|
|
602
621
|
try {
|
|
603
|
-
const
|
|
604
|
-
await e.teardown(
|
|
622
|
+
const h = await m.newPage();
|
|
623
|
+
await e.teardown(h), await h.close();
|
|
605
624
|
} catch {
|
|
606
625
|
}
|
|
607
626
|
s.emit({ event: "teardown" });
|
|
608
627
|
}
|
|
609
|
-
await
|
|
610
|
-
const
|
|
628
|
+
await m.close();
|
|
629
|
+
const H = qe(g), b = Ve(g), w = {
|
|
611
630
|
pages: g,
|
|
612
|
-
graph:
|
|
613
|
-
apis:
|
|
631
|
+
graph: H,
|
|
632
|
+
apis: b,
|
|
614
633
|
frontier: r.summary(),
|
|
615
634
|
skipped: r.skippedUrls(),
|
|
616
|
-
gateCallCount:
|
|
635
|
+
gateCallCount: S,
|
|
617
636
|
cleanup: () => c.cleanup()
|
|
618
637
|
};
|
|
619
638
|
return s.complete({
|
|
620
|
-
outcome:
|
|
639
|
+
outcome: D.success,
|
|
621
640
|
pagesVisited: g.length,
|
|
622
|
-
apisFound:
|
|
623
|
-
gateCallCount:
|
|
641
|
+
apisFound: b.length,
|
|
642
|
+
gateCallCount: S,
|
|
624
643
|
...r.summary()
|
|
625
|
-
}),
|
|
626
|
-
} catch (
|
|
627
|
-
throw s.error(
|
|
644
|
+
}), w;
|
|
645
|
+
} catch (m) {
|
|
646
|
+
throw s.error(m, { pagesVisited: 0 }), m;
|
|
628
647
|
} finally {
|
|
629
|
-
await
|
|
648
|
+
await d.close();
|
|
630
649
|
}
|
|
631
|
-
}
|
|
650
|
+
};
|
|
651
|
+
We.knownTexts = [];
|
|
652
|
+
const re = 1, F = 20, N = 5, Ge = 0.5, He = 5, X = 8e3, j = 5, $ = {
|
|
632
653
|
INDIVIDUAL: "individual",
|
|
633
654
|
BULK: "bulk"
|
|
634
|
-
},
|
|
635
|
-
function
|
|
655
|
+
}, Je = (t) => t === void 0 ? F : typeof t == "number" ? t : { small: 10, med: F, large: 40 }[t] ?? F, Ke = (t) => t === void 0 ? N : typeof t == "number" ? t : { low: 2, med: N, high: 10 }[t] ?? N;
|
|
656
|
+
function Xe(t, a) {
|
|
636
657
|
const e = [];
|
|
637
658
|
for (let s = 0; s < t.length; s += a)
|
|
638
659
|
e.push({
|
|
@@ -642,7 +663,7 @@ function qe(t, a) {
|
|
|
642
663
|
});
|
|
643
664
|
return e;
|
|
644
665
|
}
|
|
645
|
-
function
|
|
666
|
+
function Y(t, a, e, s, n, o) {
|
|
646
667
|
return {
|
|
647
668
|
chunkIndex: t.index,
|
|
648
669
|
totalChunks: a,
|
|
@@ -651,118 +672,106 @@ function W(t, a, e, s, n, i) {
|
|
|
651
672
|
status: s,
|
|
652
673
|
bulkSize: n.bulkSize,
|
|
653
674
|
maxConcurrency: n.maxConcurrency,
|
|
654
|
-
processingMode:
|
|
675
|
+
processingMode: o,
|
|
655
676
|
parallelMode: !0
|
|
656
677
|
};
|
|
657
678
|
}
|
|
658
|
-
async function
|
|
679
|
+
async function Ye(t, a, e, s, n, o = {}) {
|
|
659
680
|
try {
|
|
660
|
-
const
|
|
681
|
+
const i = e.map((d) => ce(d(t))).filter(Boolean).join(`
|
|
661
682
|
|
|
662
|
-
`), r = [a,
|
|
683
|
+
`), r = [a, i].filter(Boolean).join(`
|
|
663
684
|
|
|
664
|
-
`), c =
|
|
665
|
-
...
|
|
666
|
-
|
|
667
|
-
type: "json_schema",
|
|
668
|
-
json_schema: {
|
|
669
|
-
name: "arch_result",
|
|
670
|
-
schema: Qe
|
|
671
|
-
}
|
|
672
|
-
}
|
|
685
|
+
`), c = ct(r, t, s, n === "files"), u = await W(c, {
|
|
686
|
+
...o,
|
|
687
|
+
responseFormat: U("arch_result", rt)
|
|
673
688
|
});
|
|
674
689
|
return { item: t, ...u, error: void 0 };
|
|
675
|
-
} catch (
|
|
676
|
-
return { item: t, passed: !1, reason: `Analysis failed: ${
|
|
690
|
+
} catch (i) {
|
|
691
|
+
return { item: t, passed: !1, reason: `Analysis failed: ${i.message}`, error: i };
|
|
677
692
|
}
|
|
678
693
|
}
|
|
679
|
-
function
|
|
680
|
-
const n = [],
|
|
681
|
-
let
|
|
694
|
+
function Qe(t, a, e, s) {
|
|
695
|
+
const n = [], o = [];
|
|
696
|
+
let i = s;
|
|
682
697
|
for (const r of t)
|
|
683
|
-
if (n.push(r), r.passed || (
|
|
698
|
+
if (n.push(r), r.passed || (i++, o.push(r.error || new Error(r.reason))), !a && i >= e)
|
|
684
699
|
break;
|
|
685
700
|
return {
|
|
686
701
|
results: n,
|
|
687
|
-
errors:
|
|
688
|
-
failures:
|
|
689
|
-
shouldStop: !a &&
|
|
702
|
+
errors: o,
|
|
703
|
+
failures: i,
|
|
704
|
+
shouldStop: !a && i >= e
|
|
690
705
|
};
|
|
691
706
|
}
|
|
692
|
-
function
|
|
707
|
+
function R(t, a, e, s) {
|
|
693
708
|
t && t(a, e, s);
|
|
694
709
|
}
|
|
695
|
-
async function
|
|
696
|
-
|
|
710
|
+
async function oe(t, a, e, s, n, o = {}) {
|
|
711
|
+
R(s, t, void 0, {
|
|
697
712
|
...n,
|
|
698
|
-
status:
|
|
713
|
+
status: T.start
|
|
699
714
|
});
|
|
700
715
|
try {
|
|
701
|
-
const
|
|
702
|
-
...
|
|
703
|
-
responseFormat:
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
},
|
|
710
|
-
onProgress: Q(i.onProgress, "reduce")
|
|
711
|
-
}, c = await ue(t, o, r), u = c.results || c;
|
|
712
|
-
let m = [];
|
|
713
|
-
Array.isArray(u) ? m = u : m = t.map((d) => ({
|
|
714
|
-
path: d,
|
|
716
|
+
const i = lt(a, t, e), r = {
|
|
717
|
+
...o,
|
|
718
|
+
responseFormat: U("arch_bulk_result", ot),
|
|
719
|
+
onProgress: ae(s, "reduce")
|
|
720
|
+
}, c = await ge(t, i, r), u = c.results || c;
|
|
721
|
+
let d = [];
|
|
722
|
+
Array.isArray(u) ? d = u : d = t.map((p) => ({
|
|
723
|
+
path: p,
|
|
715
724
|
passed: !1,
|
|
716
725
|
reason: "Invalid response format"
|
|
717
726
|
}));
|
|
718
|
-
const
|
|
719
|
-
return
|
|
727
|
+
const m = d.filter((p) => !p.passed).length, l = d.length - m;
|
|
728
|
+
return R(
|
|
720
729
|
s,
|
|
721
730
|
t,
|
|
722
|
-
|
|
731
|
+
m > 0 ? new Error(`${m} items failed`) : void 0,
|
|
723
732
|
{
|
|
724
733
|
...n,
|
|
725
|
-
status:
|
|
734
|
+
status: T.complete,
|
|
726
735
|
passed: l,
|
|
727
|
-
failed:
|
|
736
|
+
failed: m
|
|
728
737
|
}
|
|
729
|
-
),
|
|
730
|
-
} catch (
|
|
738
|
+
), d;
|
|
739
|
+
} catch (i) {
|
|
731
740
|
const r = t.map((c) => ({
|
|
732
741
|
path: c,
|
|
733
742
|
passed: !1,
|
|
734
|
-
reason: `Processing error: ${
|
|
743
|
+
reason: `Processing error: ${i.message}`
|
|
735
744
|
}));
|
|
736
|
-
return
|
|
745
|
+
return R(s, t, i, {
|
|
737
746
|
...n,
|
|
738
|
-
status:
|
|
747
|
+
status: T.error
|
|
739
748
|
}), r;
|
|
740
749
|
}
|
|
741
750
|
}
|
|
742
|
-
function
|
|
743
|
-
const e = a.filter((r) => r.passed).length, s = a.length - e, n = s === 0,
|
|
751
|
+
function Ze(t, a) {
|
|
752
|
+
const e = a.filter((r) => r.passed).length, s = a.length - e, n = s === 0, o = a.length < t.length, i = a.filter((r) => !r.passed);
|
|
744
753
|
return {
|
|
745
754
|
passed: e,
|
|
746
755
|
failed: s,
|
|
747
756
|
allPassed: n,
|
|
748
|
-
stoppedEarly:
|
|
749
|
-
failures:
|
|
757
|
+
stoppedEarly: o,
|
|
758
|
+
failures: i,
|
|
750
759
|
total: t.length,
|
|
751
760
|
processed: a.length
|
|
752
761
|
};
|
|
753
762
|
}
|
|
754
|
-
function
|
|
763
|
+
function et(t, a, e) {
|
|
755
764
|
if (t.allPassed)
|
|
756
765
|
return `All ${t.processed}/${t.total} items satisfy: ${a}`;
|
|
757
|
-
const s = t.failures.slice(0,
|
|
758
|
-
`), n = t.failures.length >
|
|
759
|
-
... and ${t.failures.length -
|
|
760
|
-
return `${t.failed}/${t.processed} items failed: ${a}${t.stoppedEarly && e !==
|
|
766
|
+
const s = t.failures.slice(0, j).map((o) => ` • ${o.item}: ${o.reason || "Failed"}`).join(`
|
|
767
|
+
`), n = t.failures.length > j ? `
|
|
768
|
+
... and ${t.failures.length - j} more failures` : "";
|
|
769
|
+
return `${t.failed}/${t.processed} items failed: ${a}${t.stoppedEarly && e !== re ? ` (stopped after ${e} failures)` : ""}
|
|
761
770
|
|
|
762
771
|
Failures:
|
|
763
772
|
${s}${n}`;
|
|
764
773
|
}
|
|
765
|
-
function
|
|
774
|
+
function tt(t, a) {
|
|
766
775
|
return {
|
|
767
776
|
passed: t.allPassed,
|
|
768
777
|
message: a,
|
|
@@ -775,23 +784,23 @@ function Je(t, a) {
|
|
|
775
784
|
}
|
|
776
785
|
};
|
|
777
786
|
}
|
|
778
|
-
function
|
|
779
|
-
const n = a || e.length > 0 || s <=
|
|
787
|
+
function st(t, a, e, s) {
|
|
788
|
+
const n = a || e.length > 0 || s <= He;
|
|
780
789
|
return {
|
|
781
|
-
mode: n ?
|
|
790
|
+
mode: n ? $.INDIVIDUAL : $.BULK,
|
|
782
791
|
batchSize: n ? t.maxConcurrency : t.bulkSize,
|
|
783
|
-
processor: n ? (
|
|
784
|
-
|
|
785
|
-
|
|
792
|
+
processor: n ? (o, i, r) => ie(o, i, r) : (o, i, r) => oe(
|
|
793
|
+
o.items,
|
|
794
|
+
i,
|
|
786
795
|
r.description,
|
|
787
796
|
r.onProgress,
|
|
788
797
|
r.metadata
|
|
789
798
|
)
|
|
790
799
|
};
|
|
791
800
|
}
|
|
792
|
-
|
|
801
|
+
function ie(t, a, e) {
|
|
793
802
|
const s = t.items.map(
|
|
794
|
-
(n) =>
|
|
803
|
+
(n) => Ye(
|
|
795
804
|
n,
|
|
796
805
|
a,
|
|
797
806
|
e.itemContextFns,
|
|
@@ -800,11 +809,11 @@ async function se(t, a, e) {
|
|
|
800
809
|
e.runConfig
|
|
801
810
|
)
|
|
802
811
|
);
|
|
803
|
-
return
|
|
812
|
+
return Promise.all(s);
|
|
804
813
|
}
|
|
805
|
-
function
|
|
806
|
-
if (a ===
|
|
807
|
-
const { results: s, errors: n, failures:
|
|
814
|
+
function at(t, a, e) {
|
|
815
|
+
if (a === $.INDIVIDUAL) {
|
|
816
|
+
const { results: s, errors: n, failures: o, shouldStop: i } = Qe(
|
|
808
817
|
t,
|
|
809
818
|
e.isCoverageTest,
|
|
810
819
|
e.maxFailures,
|
|
@@ -813,8 +822,8 @@ function Ke(t, a, e) {
|
|
|
813
822
|
return {
|
|
814
823
|
results: s,
|
|
815
824
|
errors: n,
|
|
816
|
-
failures:
|
|
817
|
-
shouldStop:
|
|
825
|
+
failures: o,
|
|
826
|
+
shouldStop: i,
|
|
818
827
|
progressData: {
|
|
819
828
|
passed: s.filter((r) => r.passed).length,
|
|
820
829
|
failed: n.length
|
|
@@ -838,27 +847,27 @@ function Ke(t, a, e) {
|
|
|
838
847
|
};
|
|
839
848
|
}
|
|
840
849
|
}
|
|
841
|
-
async function
|
|
842
|
-
const n =
|
|
843
|
-
let
|
|
850
|
+
async function nt(t, a, e, s) {
|
|
851
|
+
const n = Xe(t, e.batchSize), o = [];
|
|
852
|
+
let i = 0;
|
|
844
853
|
for (const r of n) {
|
|
845
|
-
if (!s.isCoverageTest &&
|
|
854
|
+
if (!s.isCoverageTest && i >= s.maxFailures)
|
|
846
855
|
break;
|
|
847
|
-
const c =
|
|
856
|
+
const c = Y(
|
|
848
857
|
r,
|
|
849
858
|
n.length,
|
|
850
859
|
t.length,
|
|
851
|
-
|
|
860
|
+
T.start,
|
|
852
861
|
s,
|
|
853
862
|
e.mode
|
|
854
863
|
);
|
|
855
|
-
|
|
864
|
+
R(s.onChunkProcessed, r.items, void 0, c);
|
|
856
865
|
let u;
|
|
857
|
-
e.mode ===
|
|
866
|
+
e.mode === $.INDIVIDUAL ? u = await ie(r, a, {
|
|
858
867
|
itemContextFns: s.itemContextFns,
|
|
859
868
|
description: s.description,
|
|
860
869
|
targetType: s.targetType
|
|
861
|
-
}) : u = await
|
|
870
|
+
}) : u = await oe(
|
|
862
871
|
r.items,
|
|
863
872
|
a,
|
|
864
873
|
s.description,
|
|
@@ -866,38 +875,38 @@ async function Ye(t, a, e, s) {
|
|
|
866
875
|
c,
|
|
867
876
|
s.runConfig
|
|
868
877
|
);
|
|
869
|
-
const
|
|
878
|
+
const d = at(u, e.mode, {
|
|
870
879
|
...s,
|
|
871
|
-
currentFailures:
|
|
880
|
+
currentFailures: i
|
|
872
881
|
});
|
|
873
|
-
if (
|
|
882
|
+
if (o.push(...d.results), i = d.failures, R(
|
|
874
883
|
s.onChunkProcessed,
|
|
875
884
|
r.items,
|
|
876
|
-
|
|
885
|
+
d.errors.length > 0 ? d.errors[0] : void 0,
|
|
877
886
|
{
|
|
878
|
-
...
|
|
887
|
+
...Y(
|
|
879
888
|
r,
|
|
880
889
|
n.length,
|
|
881
890
|
t.length,
|
|
882
|
-
|
|
891
|
+
T.complete,
|
|
883
892
|
s,
|
|
884
893
|
e.mode
|
|
885
894
|
),
|
|
886
|
-
...
|
|
895
|
+
...d.progressData
|
|
887
896
|
}
|
|
888
|
-
),
|
|
897
|
+
), d.shouldStop)
|
|
889
898
|
break;
|
|
890
899
|
}
|
|
891
|
-
return
|
|
900
|
+
return o;
|
|
892
901
|
}
|
|
893
|
-
const
|
|
902
|
+
const rt = {
|
|
894
903
|
type: "object",
|
|
895
904
|
properties: {
|
|
896
905
|
passed: { type: "boolean" },
|
|
897
906
|
reason: { type: "string" }
|
|
898
907
|
},
|
|
899
908
|
required: ["passed", "reason"]
|
|
900
|
-
},
|
|
909
|
+
}, ot = {
|
|
901
910
|
type: "object",
|
|
902
911
|
properties: {
|
|
903
912
|
results: {
|
|
@@ -915,61 +924,60 @@ const Qe = {
|
|
|
915
924
|
},
|
|
916
925
|
required: ["results"]
|
|
917
926
|
};
|
|
918
|
-
function
|
|
927
|
+
function ce(t) {
|
|
919
928
|
switch (t.type) {
|
|
920
929
|
case "file":
|
|
921
|
-
return
|
|
922
|
-
${I.readFileSync(t.filePath, "utf8")}
|
|
923
|
-
</${t.name}>` : "";
|
|
930
|
+
return k.existsSync(t.filePath) ? C(k.readFileSync(t.filePath, "utf8"), { tag: t.name }) : "";
|
|
924
931
|
case "json": {
|
|
925
|
-
if (!
|
|
926
|
-
const a = JSON.parse(
|
|
927
|
-
return
|
|
928
|
-
${JSON.stringify(a, void 0, 2)}
|
|
929
|
-
</${t.name}>`;
|
|
932
|
+
if (!k.existsSync(t.filePath)) return "";
|
|
933
|
+
const a = JSON.parse(k.readFileSync(t.filePath, "utf8"));
|
|
934
|
+
return C(JSON.stringify(a, void 0, 2), { tag: t.name });
|
|
930
935
|
}
|
|
931
936
|
case "data": {
|
|
932
937
|
const a = typeof t.data == "string" ? t.data : JSON.stringify(t.data, void 0, 2);
|
|
933
|
-
return
|
|
934
|
-
${a}
|
|
935
|
-
</${t.name}>`;
|
|
938
|
+
return C(a, { tag: t.name });
|
|
936
939
|
}
|
|
937
940
|
default:
|
|
938
941
|
return "";
|
|
939
942
|
}
|
|
940
943
|
}
|
|
941
|
-
function
|
|
942
|
-
if (!
|
|
943
|
-
if (
|
|
944
|
-
return
|
|
944
|
+
function it(t) {
|
|
945
|
+
if (!k.existsSync(t)) return "Item does not exist";
|
|
946
|
+
if (k.statSync(t).isDirectory())
|
|
947
|
+
return k.readdirSync(t).join(", ");
|
|
945
948
|
{
|
|
946
|
-
const e =
|
|
947
|
-
return e.length >
|
|
949
|
+
const e = k.readFileSync(t, "utf8");
|
|
950
|
+
return e.length > X ? `${e.substring(0, X)}
|
|
948
951
|
... (truncated)` : e;
|
|
949
952
|
}
|
|
950
953
|
}
|
|
951
|
-
function
|
|
952
|
-
const n =
|
|
953
|
-
return
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
954
|
+
function ct(t, a, e, s) {
|
|
955
|
+
const n = it(a);
|
|
956
|
+
return [
|
|
957
|
+
t,
|
|
958
|
+
`Analyze this ${s ? "file" : "directory"}: ${a}`,
|
|
959
|
+
C(n, { tag: "content" }),
|
|
960
|
+
C(e, { tag: "description" }),
|
|
961
|
+
'Return JSON with "passed" (boolean) and "reason" (string).'
|
|
962
|
+
].filter(Boolean).join(`
|
|
960
963
|
|
|
961
|
-
|
|
964
|
+
`);
|
|
962
965
|
}
|
|
963
|
-
function
|
|
964
|
-
return
|
|
965
|
-
|
|
966
|
-
|
|
966
|
+
function lt(t, a, e) {
|
|
967
|
+
return [
|
|
968
|
+
t,
|
|
969
|
+
"Analyze each item and determine if it satisfies the given description.",
|
|
970
|
+
C(e, { tag: "description" }),
|
|
971
|
+
C(a.join(`
|
|
972
|
+
`), { tag: "items" }),
|
|
973
|
+
'Return JSON with "results" array containing objects with "path", "passed" (boolean), and "reason" (string).'
|
|
974
|
+
].filter(Boolean).join(`
|
|
967
975
|
|
|
968
|
-
|
|
976
|
+
`);
|
|
969
977
|
}
|
|
970
|
-
class
|
|
978
|
+
class ut {
|
|
971
979
|
constructor(a, e = {}) {
|
|
972
|
-
this.target = a, this.options = e, this.contexts = [], this.itemContextFns = [], this.maxFailures = e.maxFailures ||
|
|
980
|
+
this.target = a, this.options = e, this.contexts = [], this.itemContextFns = [], this.maxFailures = e.maxFailures || re, this.bulkSize = e.bulkSize || F, this.maxConcurrency = e.maxConcurrency || N, this.onChunkProcessed = void 0, this.description = void 0, this.threshold = void 0, this.isCoverageTest = !1;
|
|
973
981
|
}
|
|
974
982
|
withContext(a) {
|
|
975
983
|
return this.contexts.push(a), this;
|
|
@@ -982,29 +990,29 @@ class at {
|
|
|
982
990
|
return this.description = a, this;
|
|
983
991
|
}
|
|
984
992
|
// Set up for a coverage test
|
|
985
|
-
coverage(a =
|
|
993
|
+
coverage(a = Ge) {
|
|
986
994
|
return this.threshold = a, this.isCoverageTest = !0, this;
|
|
987
995
|
}
|
|
988
996
|
// Start processing - this is the fluent terminator
|
|
989
997
|
async start() {
|
|
990
|
-
const a =
|
|
991
|
-
e.start();
|
|
998
|
+
const a = B("ai-arch-expect", this.options), e = M("ai-arch-expect", a.onProgress, a);
|
|
999
|
+
e.start(), e.emit({ event: O.input, value: this.description });
|
|
992
1000
|
try {
|
|
993
1001
|
if (!this.description)
|
|
994
1002
|
throw new Error("Must call satisfies() before start()");
|
|
995
|
-
const s = await this.target.resolve(), n = this.contexts.map(
|
|
1003
|
+
const s = await this.target.resolve(), n = this.contexts.map(ce).filter(Boolean).join(`
|
|
996
1004
|
|
|
997
|
-
`),
|
|
1005
|
+
`), o = st(
|
|
998
1006
|
this,
|
|
999
1007
|
this.onChunkProcessed,
|
|
1000
1008
|
this.itemContextFns,
|
|
1001
1009
|
s.length
|
|
1002
|
-
), { bulkSize:
|
|
1003
|
-
bulkSize:
|
|
1004
|
-
maxConcurrency:
|
|
1010
|
+
), { bulkSize: i, maxConcurrency: r, maxFailures: c } = await se(a, {
|
|
1011
|
+
bulkSize: V(Je),
|
|
1012
|
+
maxConcurrency: V(Ke),
|
|
1005
1013
|
maxFailures: this.maxFailures
|
|
1006
1014
|
}), u = {
|
|
1007
|
-
bulkSize:
|
|
1015
|
+
bulkSize: i,
|
|
1008
1016
|
maxConcurrency: r,
|
|
1009
1017
|
description: this.description,
|
|
1010
1018
|
onChunkProcessed: this.onChunkProcessed,
|
|
@@ -1013,33 +1021,39 @@ class at {
|
|
|
1013
1021
|
maxFailures: c,
|
|
1014
1022
|
isCoverageTest: this.isCoverageTest,
|
|
1015
1023
|
runConfig: a
|
|
1016
|
-
},
|
|
1017
|
-
if (m
|
|
1018
|
-
const
|
|
1019
|
-
if (!
|
|
1020
|
-
throw new Error(
|
|
1021
|
-
|
|
1024
|
+
}, d = e.batch(s.length), m = await nt(s, n, o, u);
|
|
1025
|
+
if (d(m.length), this.isCoverageTest) {
|
|
1026
|
+
const p = m.filter((L) => L.passed).length, g = s.length > 0 ? p / s.length : 0, S = g >= this.threshold, A = `Coverage: ${p}/${s.length} (${(g * 100).toFixed(1)}%) - ${S ? "meets" : "below"} ${(this.threshold * 100).toFixed(1)}% threshold`;
|
|
1027
|
+
if (!S)
|
|
1028
|
+
throw new Error(A);
|
|
1029
|
+
const P = { passed: S, coverage: g, message: A };
|
|
1030
|
+
return e.emit({ event: O.output, value: P }), e.complete({ outcome: D.success, coverage: g, total: s.length }), P;
|
|
1022
1031
|
}
|
|
1023
|
-
const l = this.summarize(s,
|
|
1024
|
-
return e.
|
|
1032
|
+
const l = this.summarize(s, m);
|
|
1033
|
+
return e.emit({ event: O.output, value: l }), e.complete({
|
|
1034
|
+
outcome: D.success,
|
|
1035
|
+
total: s.length,
|
|
1036
|
+
passed: l.details.passed
|
|
1037
|
+
}), l;
|
|
1025
1038
|
} catch (s) {
|
|
1026
1039
|
throw e.error(s), s;
|
|
1027
1040
|
}
|
|
1028
1041
|
}
|
|
1029
1042
|
summarize(a, e) {
|
|
1030
|
-
const s =
|
|
1043
|
+
const s = Ze(a, e), n = et(s, this.description, this.maxFailures);
|
|
1031
1044
|
if (!s.allPassed)
|
|
1032
1045
|
throw new Error(n);
|
|
1033
|
-
return
|
|
1046
|
+
return tt(s, n);
|
|
1034
1047
|
}
|
|
1035
1048
|
}
|
|
1036
|
-
function
|
|
1037
|
-
return new
|
|
1049
|
+
function pt(t, a = {}) {
|
|
1050
|
+
return new ut(t, a);
|
|
1038
1051
|
}
|
|
1039
|
-
|
|
1052
|
+
pt.knownTexts = [];
|
|
1053
|
+
function Dt() {
|
|
1040
1054
|
return console.warn("scanJS is not available in browser environment"), Promise.resolve({});
|
|
1041
1055
|
}
|
|
1042
|
-
const
|
|
1056
|
+
const Q = {
|
|
1043
1057
|
name: "test_analysis_result",
|
|
1044
1058
|
schema: {
|
|
1045
1059
|
type: "object",
|
|
@@ -1060,14 +1074,17 @@ const G = {
|
|
|
1060
1074
|
required: ["hasIssues", "issues"],
|
|
1061
1075
|
additionalProperties: !1
|
|
1062
1076
|
}
|
|
1063
|
-
},
|
|
1064
|
-
async function
|
|
1065
|
-
|
|
1066
|
-
n
|
|
1077
|
+
}, Z = "test";
|
|
1078
|
+
async function le(t, a, e) {
|
|
1079
|
+
[a, e] = fe(a, e);
|
|
1080
|
+
const { text: s, context: n } = be(a, []), o = B(Z, e), i = M(Z, o.onProgress, o);
|
|
1081
|
+
i.start();
|
|
1067
1082
|
try {
|
|
1068
|
-
const
|
|
1083
|
+
const r = await ve.readFile(t, "utf-8"), c = n ? `
|
|
1084
|
+
|
|
1085
|
+
${n}` : "", u = `Analyze this code and ${s}:
|
|
1069
1086
|
|
|
1070
|
-
${
|
|
1087
|
+
${C(r, { tag: "code-to-analyze" })}
|
|
1071
1088
|
|
|
1072
1089
|
Return a JSON object with:
|
|
1073
1090
|
- "hasIssues": boolean indicating if any issues were found
|
|
@@ -1078,296 +1095,302 @@ GUIDELINES:
|
|
|
1078
1095
|
- Provide specific line numbers or code references when possible
|
|
1079
1096
|
- Suggest concrete fixes for each issue identified
|
|
1080
1097
|
- Be concise but clear in your feedback
|
|
1081
|
-
- If no issues are found, return {"hasIssues": false, "issues": []}`,
|
|
1082
|
-
() =>
|
|
1083
|
-
...
|
|
1084
|
-
|
|
1098
|
+
- If no issues are found, return {"hasIssues": false, "issues": []}${c}`, d = await ye(
|
|
1099
|
+
() => W(u, {
|
|
1100
|
+
...o,
|
|
1101
|
+
responseFormat: U(Q.name, Q.schema)
|
|
1085
1102
|
}),
|
|
1086
1103
|
{
|
|
1087
1104
|
label: "test chain",
|
|
1088
|
-
config:
|
|
1105
|
+
config: o
|
|
1089
1106
|
}
|
|
1090
|
-
),
|
|
1091
|
-
return
|
|
1092
|
-
} catch (
|
|
1093
|
-
throw
|
|
1107
|
+
), m = d.hasIssues ? d.issues : [];
|
|
1108
|
+
return i.complete({ outcome: D.success }), m;
|
|
1109
|
+
} catch (r) {
|
|
1110
|
+
throw i.error(r), r;
|
|
1094
1111
|
}
|
|
1095
1112
|
}
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1113
|
+
le.knownTexts = [];
|
|
1114
|
+
const ee = "test-advice", dt = "Run the code with 5 boundary value test cases and report any that fail", mt = "Identify 5 passing scenarios and significant boundary conditions in this code. Provide minimal input examples for each scenario to demonstrate correctness.", ht = "Identify 5 failing scenarios and significant boundary conditions in this code. Provide minimal input examples for each scenario to demonstrate the failure. Assume DBC, and don't complain when types are specified in jsDoc.", gt = "Identify 5 defects in this code. Provide minimal input examples to demonstrate each defect.", ft = "Suggest 5 best practices improvements for this code.", bt = 'Suggest 5 "clean code" improvements for this code.', yt = "Identify 5 specific issues related to code quality, readability, and maintainability.", wt = "Suggest 5 refactors that would most improve the composibility of this code.", te = [
|
|
1115
|
+
dt,
|
|
1116
|
+
mt,
|
|
1117
|
+
ht,
|
|
1118
|
+
gt,
|
|
1119
|
+
ft,
|
|
1120
|
+
bt,
|
|
1121
|
+
yt,
|
|
1122
|
+
wt
|
|
1105
1123
|
];
|
|
1106
|
-
async function
|
|
1107
|
-
const e =
|
|
1124
|
+
async function vt(t, a = {}) {
|
|
1125
|
+
const e = B(ee, a), s = M(ee, e.onProgress, e);
|
|
1108
1126
|
s.start();
|
|
1109
1127
|
try {
|
|
1110
|
-
const n = s.batch(
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1128
|
+
const n = s.batch(te.length), i = (await we(
|
|
1129
|
+
te,
|
|
1130
|
+
async (r) => {
|
|
1131
|
+
const c = await le(t, r, {
|
|
1132
|
+
...e,
|
|
1133
|
+
onProgress: ae(e.onProgress, "test-advice:test")
|
|
1134
|
+
});
|
|
1135
|
+
return n(1), c;
|
|
1136
|
+
},
|
|
1137
|
+
{
|
|
1138
|
+
maxParallel: 3,
|
|
1139
|
+
errorPosture: q.resilient,
|
|
1140
|
+
abortSignal: e.abortSignal,
|
|
1141
|
+
label: "test-advice:instructions"
|
|
1142
|
+
}
|
|
1143
|
+
)).flat();
|
|
1144
|
+
return s.complete({ outcome: D.success, totalIssues: i.length }), i;
|
|
1119
1145
|
} catch (n) {
|
|
1120
1146
|
throw s.error(n), n;
|
|
1121
1147
|
}
|
|
1122
1148
|
}
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
he(JSON.parse(re(ie(process.cwd(), ".verblets.json"), "utf8")));
|
|
1126
|
-
} catch {
|
|
1127
|
-
}
|
|
1149
|
+
vt.knownTexts = [];
|
|
1150
|
+
pe.config();
|
|
1128
1151
|
export {
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
$a as
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
Tn as
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
Un as
|
|
1322
|
-
On as
|
|
1152
|
+
Nt as CAPABILITY_KEYS,
|
|
1153
|
+
$t as COMPLIANCE,
|
|
1154
|
+
Bt as CONTEXT_KINDS,
|
|
1155
|
+
Mt as COST_POSTURE,
|
|
1156
|
+
Ut as ChainEvent,
|
|
1157
|
+
Ot as ChainTree,
|
|
1158
|
+
zt as ContextBudget,
|
|
1159
|
+
_t as Conversation,
|
|
1160
|
+
jt as DOMAIN,
|
|
1161
|
+
O as DomainEvent,
|
|
1162
|
+
qt as ENVIRONMENT,
|
|
1163
|
+
Vt as EmbeddingService,
|
|
1164
|
+
Wt as Kind,
|
|
1165
|
+
Gt as Level,
|
|
1166
|
+
Ht as ListStyle,
|
|
1167
|
+
Jt as ModelService,
|
|
1168
|
+
Kt as ModelSource,
|
|
1169
|
+
T as OpEvent,
|
|
1170
|
+
Xt as OptionSource,
|
|
1171
|
+
Yt as QUALITY_INTENT,
|
|
1172
|
+
Qt as SocraticMethod,
|
|
1173
|
+
Zt as StatusCode,
|
|
1174
|
+
es as SummaryMap,
|
|
1175
|
+
ts as TelemetryEvent,
|
|
1176
|
+
ss as TimedAbortController,
|
|
1177
|
+
pt as aiArchExpect,
|
|
1178
|
+
as as aiExpect,
|
|
1179
|
+
ns as analyzeImage,
|
|
1180
|
+
rs as analyzeImageMapDetail,
|
|
1181
|
+
os as anySignal,
|
|
1182
|
+
is as applyAllTargetingRules,
|
|
1183
|
+
cs as applyFirstTargetingRule,
|
|
1184
|
+
ls as auto,
|
|
1185
|
+
us as bool,
|
|
1186
|
+
ps as buildSeedGenerationPrompt,
|
|
1187
|
+
ds as buildVisionPrompt,
|
|
1188
|
+
ms as calculateStatistics,
|
|
1189
|
+
hs as calibrate,
|
|
1190
|
+
gs as calibrateInstructions,
|
|
1191
|
+
fs as calibrateSpec,
|
|
1192
|
+
bs as categorySamples,
|
|
1193
|
+
ys as causalFramePrompt,
|
|
1194
|
+
ws as centralTendency,
|
|
1195
|
+
vs as centralTendencyLines,
|
|
1196
|
+
xs as chunk,
|
|
1197
|
+
Ss as chunkSentences,
|
|
1198
|
+
ks as classify,
|
|
1199
|
+
Cs as cleanupPaths,
|
|
1200
|
+
Is as collectEventsWith,
|
|
1201
|
+
As as collectTerms,
|
|
1202
|
+
Es as combinations,
|
|
1203
|
+
Ps as commonalities,
|
|
1204
|
+
Ts as compact,
|
|
1205
|
+
Rs as computeTagStatistics,
|
|
1206
|
+
Ds as config,
|
|
1207
|
+
Ls as constants,
|
|
1208
|
+
Fs as conversationTurnReduce,
|
|
1209
|
+
Ns as cosineSimilarity,
|
|
1210
|
+
$s as createBatches,
|
|
1211
|
+
Bs as createContextBuilder,
|
|
1212
|
+
M as createProgressEmitter,
|
|
1213
|
+
me as createTempDir,
|
|
1214
|
+
Ms as createTraceCollector,
|
|
1215
|
+
Us as date,
|
|
1216
|
+
Os as debug,
|
|
1217
|
+
W as default,
|
|
1218
|
+
zs as descriptorToSchema,
|
|
1219
|
+
_s as detectPatterns,
|
|
1220
|
+
js as detectThreshold,
|
|
1221
|
+
qs as determineStyle,
|
|
1222
|
+
Vs as disambiguate,
|
|
1223
|
+
Ws as dismantle,
|
|
1224
|
+
Gs as documentShrink,
|
|
1225
|
+
Hs as embed,
|
|
1226
|
+
Js as embedAssembleSpan,
|
|
1227
|
+
Ks as embedBatch,
|
|
1228
|
+
Xs as embedBuildIndex,
|
|
1229
|
+
Ys as embedChunked,
|
|
1230
|
+
Qs as embedImage,
|
|
1231
|
+
Zs as embedImageBatch,
|
|
1232
|
+
ea as embedMergeRanges,
|
|
1233
|
+
ta as embedMultiQuery,
|
|
1234
|
+
sa as embedNeighborChunks,
|
|
1235
|
+
aa as embedNormalizeText,
|
|
1236
|
+
na as embedObject,
|
|
1237
|
+
ra as embedRewriteQuery,
|
|
1238
|
+
oa as embedRewriteToOutputDoc,
|
|
1239
|
+
ia as embedStandaloneSpan,
|
|
1240
|
+
ca as embedStepBack,
|
|
1241
|
+
la as embedSubquestions,
|
|
1242
|
+
ua as embedWarmup,
|
|
1243
|
+
pa as entityInstructions,
|
|
1244
|
+
da as entitySpec,
|
|
1245
|
+
ma as evaluateTargetingClause,
|
|
1246
|
+
ha as evaluateTargetingRule,
|
|
1247
|
+
ga as eventToTrace,
|
|
1248
|
+
fa as expect,
|
|
1249
|
+
ba as extractBlocks,
|
|
1250
|
+
Ce as extractButtons,
|
|
1251
|
+
ya as extractEntities,
|
|
1252
|
+
ke as extractForms,
|
|
1253
|
+
wa as extractJson,
|
|
1254
|
+
Se as extractLinks,
|
|
1255
|
+
Ae as extractMeta,
|
|
1256
|
+
Pe as extractPage,
|
|
1257
|
+
va as extractRelations,
|
|
1258
|
+
Ie as extractScripts,
|
|
1259
|
+
Ee as extractStructure,
|
|
1260
|
+
xa as fillMissing,
|
|
1261
|
+
Sa as filter,
|
|
1262
|
+
ka as filterAmbiguous,
|
|
1263
|
+
Ca as filterEach,
|
|
1264
|
+
Ia as find,
|
|
1265
|
+
Aa as findEach,
|
|
1266
|
+
Ea as generateList,
|
|
1267
|
+
Pa as getMeanings,
|
|
1268
|
+
Ta as getOption,
|
|
1269
|
+
Ra as getOptionDetail,
|
|
1270
|
+
se as getOptions,
|
|
1271
|
+
Da as glossary,
|
|
1272
|
+
La as group,
|
|
1273
|
+
Fa as groupEach,
|
|
1274
|
+
Tt as imageToBase64,
|
|
1275
|
+
Na as init,
|
|
1276
|
+
$a as intent,
|
|
1277
|
+
Ba as intersections,
|
|
1278
|
+
Ma as join,
|
|
1279
|
+
U as jsonSchema,
|
|
1280
|
+
Ua as last,
|
|
1281
|
+
Oa as list,
|
|
1282
|
+
za as listBatch,
|
|
1283
|
+
_a as listExpand,
|
|
1284
|
+
W as llm,
|
|
1285
|
+
ja as llmLogger,
|
|
1286
|
+
qa as makePrompt,
|
|
1287
|
+
Va as map,
|
|
1288
|
+
Wa as mapEach,
|
|
1289
|
+
xe as mapImageShrink,
|
|
1290
|
+
Ga as mapTags,
|
|
1291
|
+
Ha as name,
|
|
1292
|
+
Ja as nameSimilarTo,
|
|
1293
|
+
B as nameStep,
|
|
1294
|
+
Ka as normalizeInstruction,
|
|
1295
|
+
Xa as normalizeLlm,
|
|
1296
|
+
Ya as number,
|
|
1297
|
+
Qa as numberWithUnits,
|
|
1298
|
+
Za as observeApplication,
|
|
1299
|
+
en as observeProviders,
|
|
1300
|
+
tn as omit,
|
|
1301
|
+
sn as pFilter,
|
|
1302
|
+
an as pFind,
|
|
1303
|
+
nn as pGroup,
|
|
1304
|
+
rn as pMap,
|
|
1305
|
+
on as pReduce,
|
|
1306
|
+
we as parallel,
|
|
1307
|
+
cn as parallelMap,
|
|
1308
|
+
ln as parseLLMList,
|
|
1309
|
+
un as parseRDFLiteral,
|
|
1310
|
+
pn as parseRelations,
|
|
1311
|
+
dn as people,
|
|
1312
|
+
mn as phailForge,
|
|
1313
|
+
hn as pick,
|
|
1314
|
+
gn as pipe,
|
|
1315
|
+
fn as popReference,
|
|
1316
|
+
bn as promptCache,
|
|
1317
|
+
yn as promptPiece,
|
|
1318
|
+
wn as prompts,
|
|
1319
|
+
vn as questions,
|
|
1320
|
+
xn as rangeCombinations,
|
|
1321
|
+
ge as reduce,
|
|
1322
|
+
Sn as reduceEach,
|
|
1323
|
+
kn as relationInstructions,
|
|
1324
|
+
Cn as relationSpec,
|
|
1325
|
+
Et as resizeImage,
|
|
1326
|
+
fe as resolveArgs,
|
|
1327
|
+
In as resolveEmbedding,
|
|
1328
|
+
An as resolveModel,
|
|
1329
|
+
En as resolveOutputDir,
|
|
1330
|
+
be as resolveTexts,
|
|
1331
|
+
ye as retry,
|
|
1332
|
+
Pn as ringBuffer,
|
|
1333
|
+
Tn as scaleInstructions,
|
|
1334
|
+
Rn as scaleItem,
|
|
1335
|
+
Dn as scaleSpec,
|
|
1336
|
+
Dt as scanJS,
|
|
1337
|
+
Ln as schemaOrg,
|
|
1338
|
+
Fn as schemas,
|
|
1339
|
+
Nn as scientificFramingPrompt,
|
|
1340
|
+
ae as scopePhase,
|
|
1341
|
+
$n as score,
|
|
1342
|
+
Bn as scoreChunksByProbes,
|
|
1343
|
+
Mn as scoreInstructions,
|
|
1344
|
+
Un as scoreItem,
|
|
1345
|
+
On as scoreSpec,
|
|
1346
|
+
zn as sentiment,
|
|
1347
|
+
_n as setEmbedEnabled,
|
|
1323
1348
|
jn as setImageProcessingEnabled,
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
Xn as
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
ir as
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
dr as
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
Tr as
|
|
1371
|
-
B as withPolicy,
|
|
1372
|
-
Er as zipWith
|
|
1349
|
+
qn as setInterval,
|
|
1350
|
+
Vn as shuffle,
|
|
1351
|
+
Wn as simplifyTree,
|
|
1352
|
+
We as siteCrawl,
|
|
1353
|
+
Gn as slot,
|
|
1354
|
+
Hn as socratic,
|
|
1355
|
+
Jn as softCoverPrompt,
|
|
1356
|
+
Kn as sort,
|
|
1357
|
+
Xn as sortBy,
|
|
1358
|
+
Yn as split,
|
|
1359
|
+
Qn as stripNumeric,
|
|
1360
|
+
Zn as stripResponse,
|
|
1361
|
+
er as suggestTargetingRules,
|
|
1362
|
+
tr as tagInstructions,
|
|
1363
|
+
sr as tagItem,
|
|
1364
|
+
ar as tagSpec,
|
|
1365
|
+
nr as tagVocabulary,
|
|
1366
|
+
rr as targetingClause,
|
|
1367
|
+
or as targetingRule,
|
|
1368
|
+
ir as targetingRuleOps,
|
|
1369
|
+
cr as targetingRuleSchema,
|
|
1370
|
+
lr as templateBuilder,
|
|
1371
|
+
ur as templateReplace,
|
|
1372
|
+
le as test,
|
|
1373
|
+
vt as testAdvice,
|
|
1374
|
+
pr as themes,
|
|
1375
|
+
Pt as tileImages,
|
|
1376
|
+
dr as timeline,
|
|
1377
|
+
mr as toBool,
|
|
1378
|
+
hr as toDate,
|
|
1379
|
+
gr as toEnum,
|
|
1380
|
+
fr as toNumber,
|
|
1381
|
+
br as toNumberWithUnits,
|
|
1382
|
+
yr as toObject,
|
|
1383
|
+
wr as truncate,
|
|
1384
|
+
vr as unionBy,
|
|
1385
|
+
xr as validateTargetingRules,
|
|
1386
|
+
Sr as valueArbitrate,
|
|
1387
|
+
kr as vectorSearch,
|
|
1388
|
+
Cr as veiledVariantStrategies,
|
|
1389
|
+
Ir as veiledVariants,
|
|
1390
|
+
Ar as version,
|
|
1391
|
+
Rt as webScrape,
|
|
1392
|
+
Er as windowFor,
|
|
1393
|
+
Pr as withInactivityTimeout,
|
|
1394
|
+
V as withPolicy,
|
|
1395
|
+
Tr as zipWith
|
|
1373
1396
|
};
|