@far-world-labs/verblets 0.7.4 → 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/index.js CHANGED
@@ -1,20 +1,20 @@
1
- import pe from "dotenv";
2
- import { i as de, n as B, c as z, g as se, E as q, a as me, O as L, r as W, j as O, b as he, w as V, D as P, d as C, e as R, s as ae, f as ge, h as fe, k as be, l as ye, p as we } from "./shared-BuJg0Ijm.js";
3
- import { cP as Mt, L as Nt, I as $t, M as Bt, b$ as zt, aL as Ot, bZ as Ut, aH as _t, K as jt, J as qt, cN as Vt, c6 as Wt, c1 as Gt, c2 as Ht, an as Jt, cM as Kt, c4 as Xt, c5 as Qt, Q as Yt, c7 as Zt, b1 as es, c3 as ts, b4 as ss, c0 as as, bT as rs, bl as ns, bg as os, bh as is, bS as cs, a4 as ls, a3 as us, bj as ps, u as ds, aE as ms, bi as hs, aa as gs, F as fs, H as bs, G as ys, bP as ws, aD as vs, be as xs, a6 as Ss, a7 as ks, cu as Cs, bM as Is, x as As, m as Es, bY as Ps, aF as Ts, bK as Rs, aG as Ds, cv as Ls, b6 as Fs, cR as Ms, t as Ns, aI as $s, cw as Bs, bO as zs, N as Os, W as Us, v as _s, bN as js, U as qs, a8 as Vs, a9 as Ws, ao as Gs, aJ as Hs, aM as Js, aO as Ks, br as Xs, bI as Qs, bs as Ys, bG as Zs, bt as ea, bw as ta, bx as sa, bH as aa, bA as ra, bF as na, bE as oa, cK as ia, bz as ca, bD as la, bJ as ua, bB as pa, bC as da, bu as ma, ad as ha, ac as ga, a1 as fa, a2 as ba, X as ya, bk as wa, ae as va, ab as xa, cl as Sa, aX as ka, aP as Ca, af as Ia, aQ as Aa, ce as Ea, ag as Pa, cf as Ta, al as Ra, aK as Da, S as La, T as Fa, ah as Ma, ai as Na, ch as $a, cQ as Ba, bm as za, aj as Oa, aR as Ua, cx as _a, ak as ja, am as qa, ap as Va, bn as Wa, bo as Ga, aq as Ha, cd as Ja, aB as Ka, aS as Xa, aT as Qa, bV as Ya, bQ as Za, aw as er, y as tr, z as sr, P as ar, R as rr, cy as nr, c9 as or, ca as ir, cc as cr, c8 as lr, cb as ur, bR as pr, ct as dr, aZ as mr, a_ as hr, aU as gr, bo as fr, cz as br, cF as yr, aV as wr, cI as vr, cJ as xr, cG as Sr, aW as kr, bL as Cr, cg as Ir, a$ as Ar, aY as Er, cO as Pr, cL as Tr, o as Rr, b_ as Dr, C as Lr, A as Fr, B as Mr, b0 as Nr, cH as $r, bd as Br, ar as zr, by as Or, au as Ur, at as _r, av as jr, ax as qr, as as Vr, bp as Wr, bv as Gr, q as Hr, bq as Jr, cE as Kr, aN as Xr, bX as Qr, b2 as Yr, bf as Zr, ay as en, cA as tn, b3 as sn, cn as an, cm as rn, a5 as nn, aC as on, az as cn, aA as ln, b5 as un, Z as pn, _ as dn, Y as mn, a0 as hn, bW as gn, bU as fn, b7 as bn, b8 as yn, co as wn, cq as vn, cr as xn, cp as Sn, cs as kn, b9 as Cn, ba as In, cB as An, $ as En, V as Pn, cC as Tn, bc as Rn, bb as Dn, ci as Ln, cj as Fn, ck as Mn, cD as Nn } from "./shared-BuJg0Ijm.js";
4
- import * as J from "playwright-core";
1
+ import de from "dotenv";
2
+ import { i as pe, n as O, c as U, g as se, E as V, a as me, O as T, r as H, j as z, b as he, w as W, D as E, d as C, e as D, s as ae, f as ge, h as fe, k as be, l as ye, p as we } from "./shared-Bdek4t_n.js";
3
+ import { di as $t, Q as Mt, ce as Ft, M as Bt, S as Ot, cu as Ut, aY as zt, cs as _t, aU as jt, cf as qt, P as Vt, N as Wt, dg as Ht, cB as Gt, cw as Jt, cx as Xt, ax as Kt, df as Yt, cz as Qt, cA as Zt, R as es, cC as ts, bo as ss, cy as as, br as rs, cv as ns, cm as os, bI as is, cb as cs, bD as ls, bE as us, cl as ds, a8 as ps, a7 as ms, bG as hs, u as gs, aR as fs, bF as bs, ae as ys, L as ws, H as Ss, K as vs, ci as xs, aQ as ks, bB as Cs, aa as Is, ab as Ps, cZ as As, c7 as Es, x as Ts, m as Rs, cr as Ds, aS as Ls, c5 as Ns, aT as $s, c_ as Ms, bt as Fs, dk as Bs, t as Os, aV as Us, c$ as zs, ch as _s, T as js, _ as qs, v as Vs, cg as Ws, Y as Hs, ac as Gs, ad as Js, ay as Xs, aW as Ks, aZ as Ys, a$ as Qs, b3 as Zs, b2 as ea, bO as ta, c3 as sa, bP as aa, c1 as ra, bQ as na, bT as oa, bU as ia, c2 as ca, bX as la, c0 as ua, b$ as da, dd as pa, bW as ma, b_ as ha, c4 as ga, bY as fa, bZ as ba, bR as ya, aj as wa, af as Sa, ai as va, a5 as xa, a6 as ka, $ as Ca, bH as Ia, ak as Pa, cQ as Aa, b4 as Ea, al as Ta, b5 as Ra, cJ as Da, u as La, am as Na, an as $a, cK as Ma, u as Fa, ao as Ba, av as Oa, aX as Ua, W as za, X as _a, ap as ja, aq as qa, cM as Va, ar as Wa, as as Ha, c9 as Ga, dj as Ja, bJ as Xa, at as Ka, b6 as Ya, d0 as Qa, au as Za, aw as er, az as tr, bK as sr, bL as ar, aA as rr, I as nr, J as or, b1 as ir, cI as cr, ag as lr, ah as ur, aB as dr, b0 as pr, aC as mr, ba as hr, bb as gr, bd as fr, be as br, bh as yr, bi as wr, B as Sr, C as vr, aO as xr, ca as kr, b7 as Cr, b8 as Ir, co as Pr, cj as Ar, aJ as Er, y as Tr, z as Rr, U as Dr, V as Lr, d1 as Nr, cc as $r, cE as Mr, cF as Fr, cH as Br, cD as Or, cG as Ur, ck as zr, cY as _r, bk as jr, bl as qr, b9 as Vr, bL as Wr, d2 as Hr, d8 as Gr, bc as Jr, db as Xr, dc as Kr, d9 as Yr, bf as Qr, c6 as Zr, cL as en, aD as tn, bm as sn, bg as an, bj as rn, dh as nn, de as on, o as cn, ct as ln, G as un, A as dn, F as pn, bn as mn, da as hn, bA as gn, aE as fn, bV as bn, aH as yn, aG as wn, aI as Sn, aK as vn, aF as xn, c8 as kn, bM as Cn, bS as In, q as Pn, bN as An, d7 as En, a_ as Tn, cq as Rn, bp as Dn, bC as Ln, aL as Nn, d3 as $n, bq as Mn, cS as Fn, cR as Bn, a9 as On, aP as Un, aM as zn, aN as _n, bs as jn, a1 as qn, a2 as Vn, a0 as Wn, a4 as Hn, cp as Gn, cn as Jn, bu as Xn, bv as Kn, cT as Yn, cV as Qn, cW as Zn, cU as eo, cX as to, bw as so, bx as ao, cd as ro, d4 as no, a3 as oo, Z as io, d5 as co, bz as lo, by as uo, cN as po, cO as mo, cP as ho, d6 as go } from "./shared-Bdek4t_n.js";
4
+ import * as X from "playwright-core";
5
5
  import k from "node:fs";
6
6
  import "node:path";
7
7
  import "glob";
8
- import ve from "node:fs/promises";
9
- const U = 60, xe = (t) => ({
10
- low: { width: 300, quality: U, format: "jpeg" },
11
- med: { width: 100, quality: U, format: "jpeg" },
12
- high: { width: 50, quality: U, format: "jpeg" }
8
+ import Se from "node:fs/promises";
9
+ const _ = 60, ve = (t) => ({
10
+ low: { width: 300, quality: _, format: "jpeg" },
11
+ med: { width: 100, quality: _, format: "jpeg" },
12
+ high: { width: 50, quality: _, format: "jpeg" }
13
13
  })[t], G = (t) => () => {
14
14
  throw new Error(`${t} is not available in browser environment`);
15
- }, Et = G("resizeImage"), Pt = G("tileImages"), Tt = G("imageToBase64"), Rt = () => {
15
+ }, At = G("resizeImage"), Et = G("tileImages"), Tt = G("imageToBase64"), Rt = () => {
16
16
  throw new Error("webScrape is not available in browser environment");
17
- }, Se = async (t, a) => (await t.evaluate(() => {
17
+ }, xe = async (t, a) => (await t.evaluate(() => {
18
18
  const s = /* @__PURE__ */ new Set();
19
19
  return [...document.querySelectorAll("a[href]")].map((r) => {
20
20
  const i = r.href;
@@ -101,7 +101,7 @@ const U = 60, xe = (t) => ({
101
101
  size: e.textContent?.length || 0,
102
102
  // First 200 chars of inline scripts to identify patterns
103
103
  preview: e.src ? "" : e.textContent?.trim()?.slice(0, 200)
104
- }))), Ae = (t) => t.evaluate(() => {
104
+ }))), Pe = (t) => t.evaluate(() => {
105
105
  const a = (e) => document.querySelector(`meta[name="${e}"], meta[property="${e}"]`)?.content || "";
106
106
  return {
107
107
  title: document.title || "",
@@ -128,7 +128,7 @@ const U = 60, xe = (t) => ({
128
128
  content: e.content?.slice(0, 120)
129
129
  }))
130
130
  };
131
- }), Ee = (t) => t.evaluate(() => {
131
+ }), Ae = (t) => t.evaluate(() => {
132
132
  const a = [...document.querySelectorAll("h1, h2, h3, h4, h5, h6")].slice(0, 30).map((l) => ({
133
133
  level: parseInt(l.tagName[1], 10),
134
134
  text: l.textContent?.trim()?.slice(0, 100)
@@ -143,15 +143,15 @@ const U = 60, xe = (t) => ({
143
143
  classes: (typeof l.className == "string" ? l.className : l.className?.baseVal || "").slice(0, 80)
144
144
  })), s = /* @__PURE__ */ new Set();
145
145
  document.querySelectorAll("*").forEach((l) => {
146
- [...l.attributes].filter((p) => p.name.startsWith("data-")).forEach((p) => s.add(p.name));
146
+ [...l.attributes].filter((d) => d.name.startsWith("data-")).forEach((d) => s.add(d.name));
147
147
  });
148
148
  const r = [...document.querySelectorAll('link[rel="stylesheet"]')].map((l) => l.href), i = /* @__PURE__ */ new Set(), o = (l) => {
149
- const p = l.className;
150
- return typeof p == "string" ? p : p?.baseVal || "";
149
+ const d = l.className;
150
+ return typeof d == "string" ? d : d?.baseVal || "";
151
151
  };
152
152
  document.querySelectorAll("[class]").forEach((l) => {
153
- o(l).split(/\s+/).slice(0, 5).forEach((p) => {
154
- p && i.add(p);
153
+ o(l).split(/\s+/).slice(0, 5).forEach((d) => {
154
+ d && i.add(d);
155
155
  });
156
156
  });
157
157
  const n = [...i].slice(0, 200), c = {}, u = [
@@ -182,12 +182,12 @@ const U = 60, xe = (t) => ({
182
182
  for (const l of u)
183
183
  try {
184
184
  if (window[l] !== void 0) {
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);
185
+ const d = window[l];
186
+ c[l] = typeof d == "function" ? d.fn?.jquery || d.version || "present" : typeof d == "object" ? "present" : String(d).slice(0, 40);
187
187
  }
188
188
  } catch {
189
189
  }
190
- const d = /* @__PURE__ */ new Set(), m = [
190
+ const p = /* @__PURE__ */ new Set(), m = [
191
191
  "onclick",
192
192
  "onsubmit",
193
193
  "onchange",
@@ -199,7 +199,7 @@ const U = 60, xe = (t) => ({
199
199
  "onkeydown"
200
200
  ];
201
201
  for (const l of m)
202
- document.querySelectorAll(`[${l}]`).length > 0 && d.add(l);
202
+ document.querySelectorAll(`[${l}]`).length > 0 && p.add(l);
203
203
  return {
204
204
  headings: a,
205
205
  landmarks: e,
@@ -207,21 +207,21 @@ const U = 60, xe = (t) => ({
207
207
  stylesheets: r.slice(0, 20),
208
208
  sampleClasses: n,
209
209
  globals: c,
210
- inlineHandlers: [...d],
210
+ inlineHandlers: [...p],
211
211
  iframeCount: document.querySelectorAll("iframe").length,
212
212
  shadowRootCount: [...document.querySelectorAll("*")].filter((l) => l.shadowRoot).length
213
213
  };
214
- }), Pe = async (t) => {
214
+ }), Ee = async (t) => {
215
215
  const a = t.url(), e = new URL(a).origin, [s, r, i, o, n, c] = await Promise.all([
216
- Se(t, e),
216
+ xe(t, e),
217
217
  ke(t),
218
218
  Ce(t),
219
219
  Ie(t),
220
- Ae(t),
221
- Ee(t)
220
+ Pe(t),
221
+ Ae(t)
222
222
  ]);
223
223
  return { url: a, links: s, forms: r, buttons: i, scripts: o, meta: n, structure: c };
224
- }, _ = (t) => {
224
+ }, j = (t) => {
225
225
  const a = new URL(t);
226
226
  a.hash = "";
227
227
  const e = Array.from(a.searchParams.entries()).toSorted(([r], [i]) => r.localeCompare(i));
@@ -229,31 +229,31 @@ const U = 60, xe = (t) => ({
229
229
  const s = a.toString();
230
230
  return s.endsWith("/") && a.pathname !== "/" ? s.slice(0, -1) : s;
231
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, r = a.maxDepth ?? 10, i = [], o = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Set(), u = _(t);
232
+ const e = new URL(t).origin, s = a.sameDomain !== !1, r = a.maxDepth ?? 10, i = [], o = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Set(), u = j(t);
233
233
  return i.push({ url: t, normalized: u, depth: 0, source: "(start)" }), c.add(u), {
234
234
  addLinks: (b, w, h) => {
235
235
  let y = 0;
236
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
- n.set(x, "external");
237
+ const S = f.href || f, v = j(S);
238
+ if (c.has(v)) continue;
239
+ if (c.add(v), s && !S.startsWith(e)) {
240
+ n.set(v, "external");
241
241
  continue;
242
242
  }
243
243
  if (w + 1 > r) {
244
- n.set(x, "max-depth");
244
+ n.set(v, "max-depth");
245
245
  continue;
246
246
  }
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
- n.set(x, "resource");
247
+ const A = new URL(S).pathname;
248
+ if (/\.(png|jpg|jpeg|gif|svg|ico|css|js|woff2?|ttf|eot|pdf|zip|mp[34])$/i.test(A)) {
249
+ n.set(v, "resource");
250
250
  continue;
251
251
  }
252
- if (/^(mailto|tel|javascript):/i.test(v)) {
253
- n.set(x, "scheme");
252
+ if (/^(mailto|tel|javascript):/i.test(S)) {
253
+ n.set(v, "scheme");
254
254
  continue;
255
255
  }
256
- i.push({ url: v, normalized: x, depth: w + 1, source: h }), y++;
256
+ i.push({ url: S, normalized: v, depth: w + 1, source: h }), y++;
257
257
  }
258
258
  return y;
259
259
  },
@@ -267,11 +267,11 @@ const U = 60, xe = (t) => ({
267
267
  },
268
268
  skip: (b, w) => {
269
269
  const h = /* @__PURE__ */ new Set();
270
- for (const v of b) {
271
- const x = _(v);
272
- n.set(x, w), h.add(x);
270
+ for (const S of b) {
271
+ const v = j(S);
272
+ n.set(v, w), h.add(v);
273
273
  }
274
- const y = i.length, f = i.filter((v) => !h.has(v.normalized));
274
+ const y = i.length, f = i.filter((S) => !h.has(S.normalized));
275
275
  return i.splice(0, i.length, ...f), y - f.length;
276
276
  },
277
277
  pendingByPrefix: (b = 2) => {
@@ -330,10 +330,10 @@ const U = 60, xe = (t) => ({
330
330
  }, Le = (t, a) => {
331
331
  const e = t * a;
332
332
  return t + (Math.random() * 2 - 1) * e;
333
- }, Fe = (t, a) => {
333
+ }, Ne = (t, a) => {
334
334
  const e = a.baseDelay * Math.pow(a.backoffFactor, t), s = Math.min(e, a.maxDelay);
335
335
  return Math.round(Le(s, a.jitter));
336
- }, Me = async (t, a, e, s) => {
336
+ }, $e = async (t, a, e, s) => {
337
337
  const r = Date.now(), i = r + t;
338
338
  let o = 0;
339
339
  for (; o < t; ) {
@@ -346,24 +346,24 @@ const U = 60, xe = (t) => ({
346
346
  ...s
347
347
  });
348
348
  }
349
- }, Ne = async (t, a, e, s, r, i, o) => {
349
+ }, Me = async (t, a, e, s, r, i, o) => {
350
350
  const n = { ...re, ...r };
351
351
  let c = 0;
352
352
  for (let u = 0; u <= n.maxRetries; u++) {
353
- let d;
353
+ let p;
354
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;
355
+ p = await t(a, e);
356
+ } catch (d) {
357
+ throw s.emit({ event: I.visitError, url: e, attempt: u, error: d.message }), d;
358
358
  }
359
359
  let m;
360
360
  try {
361
361
  m = await i(a);
362
- } catch (p) {
363
- throw s.emit({ event: I.blockCheckError, url: e, attempt: u, error: p.message }), p;
362
+ } catch (d) {
363
+ throw s.emit({ event: I.blockCheckError, url: e, attempt: u, error: d.message }), d;
364
364
  }
365
365
  if (!m)
366
- return { pageData: d, retries: u, totalCooldownMs: c };
366
+ return { pageData: p, retries: u, totalCooldownMs: c };
367
367
  if (u >= n.maxRetries)
368
368
  return s.emit({
369
369
  event: I.exhausted,
@@ -371,8 +371,8 @@ const U = 60, xe = (t) => ({
371
371
  reason: m,
372
372
  attempts: u + 1,
373
373
  totalCooldownMs: c
374
- }), { pageData: d, retries: u, totalCooldownMs: c, blocked: m };
375
- const l = Fe(u, n);
374
+ }), { pageData: p, retries: u, totalCooldownMs: c, blocked: m };
375
+ const l = Ne(u, n);
376
376
  c += l, s.emit({
377
377
  event: I.start,
378
378
  url: e,
@@ -381,7 +381,7 @@ const U = 60, xe = (t) => ({
381
381
  maxRetries: n.maxRetries,
382
382
  delayMs: l,
383
383
  totalCooldownMs: c
384
- }), await Me(l, s, o, {
384
+ }), await $e(l, s, o, {
385
385
  url: e,
386
386
  reason: m,
387
387
  attempt: u + 1
@@ -391,7 +391,7 @@ const U = 60, xe = (t) => ({
391
391
  attempt: u + 1
392
392
  });
393
393
  }
394
- }, $e = (t, a, e) => {
394
+ }, Fe = (t, a, e) => {
395
395
  const s = setInterval(() => {
396
396
  t.emit({
397
397
  event: I.heartbeat,
@@ -401,7 +401,7 @@ const U = 60, xe = (t) => ({
401
401
  return {
402
402
  stop: () => clearInterval(s)
403
403
  };
404
- }, K = "site-crawl", Be = "Browser support is disabled. Call init({ browser: true }) to enable.", ze = (t, a) => {
404
+ }, K = "site-crawl", Be = "Browser support is disabled. Call init({ browser: true }) to enable.", Oe = (t, a) => {
405
405
  const e = a.summary(), s = t.map((r) => `${new URL(r.url).pathname} — ${r.meta.title || "(no title)"} [${r.links.length} links, ${r.forms.length} forms, ${r.buttons.length} buttons]`);
406
406
  return [
407
407
  `Crawled ${e.visited} pages, ${e.pending} pending, ${e.skipped} skipped.`,
@@ -410,7 +410,7 @@ const U = 60, xe = (t) => ({
410
410
  ...s.map((r) => ` ${r}`)
411
411
  ].join(`
412
412
  `);
413
- }, Oe = (t, a, e) => {
413
+ }, Ue = (t, a, e) => {
414
414
  const s = [];
415
415
  for (const [r, i] of t) {
416
416
  const o = i.slice(0, 5).map((c) => ` ${c.url}`), n = i.length > 5 ? ` ... and ${i.length - 5} more` : "";
@@ -432,7 +432,7 @@ const U = 60, xe = (t) => ({
432
432
  "Skip groups that are clearly non-functional (help/support, legal, marketing pages)."
433
433
  ].join(`
434
434
  `);
435
- }, Ue = O("crawl_gate", {
435
+ }, ze = z("crawl_gate", {
436
436
  type: "object",
437
437
  properties: {
438
438
  decisions: {
@@ -462,27 +462,32 @@ const U = 60, xe = (t) => ({
462
462
  }), _e = async (t, a, e, s) => {
463
463
  const r = t.pendingByPrefix(2);
464
464
  if (r.size === 0) return { explore: [], skip: [], decisions: [] };
465
- const i = ze(a, t), o = Oe(r, i, e), c = (await W(o, {
465
+ const i = Oe(a, t), o = Ue(r, i, e), n = await H(o, {
466
466
  ...s,
467
- responseFormat: Ue,
467
+ responseFormat: ze,
468
468
  temperature: 0.2
469
- }))?.decisions || [], u = [], d = [];
469
+ });
470
+ if (!n || typeof n != "object" || !Array.isArray(n.decisions))
471
+ throw new Error(
472
+ `site-crawl: expected { decisions: [] } from gate LLM (got ${n === null ? "null" : typeof n})`
473
+ );
474
+ const { decisions: c } = n, u = [], p = [];
470
475
  for (const m of c) {
471
476
  const l = r.get(m.prefix);
472
477
  if (l)
473
478
  if (m.action === "skip")
474
- d.push(...l.map((p) => p.url));
479
+ p.push(...l.map((d) => d.url));
475
480
  else {
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));
481
+ const d = Math.min(m.maxFromGroup || 3, 5, l.length);
482
+ u.push(...l.slice(0, d).map((g) => g.url)), l.length > d && p.push(...l.slice(d).map((g) => g.url));
478
483
  }
479
484
  }
480
485
  for (const [m, l] of r)
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 };
486
+ c.some((g) => g.prefix === m) || (u.push(l[0].url), l.length > 1 && p.push(...l.slice(1).map((g) => g.url)));
487
+ return { explore: u, skip: p, decisions: c };
483
488
  }, je = async (t, a, e, s, r, i) => {
484
489
  await t.goto(a, { waitUntil: "domcontentloaded", timeout: 3e4 }), await t.waitForTimeout(1500);
485
- const o = await Pe(t);
490
+ const o = await Ee(t);
486
491
  if (r.screenshots) {
487
492
  const c = `${s.dir}/crawl-${Date.now()}.png`;
488
493
  if (await t.screenshot({ path: c, fullPage: !1 }), s.track(c), r.imageShrink) {
@@ -519,8 +524,8 @@ const U = 60, xe = (t) => ({
519
524
  }
520
525
  return [...a.values()];
521
526
  }, We = async (t, a = {}) => {
522
- if (!de()) throw new Error(Be);
523
- const e = B(K, a), s = z(K, e.onProgress, e);
527
+ if (!pe()) throw new Error(Be);
528
+ const e = O(K, a), s = U(K, e.onProgress, e);
524
529
  s.start();
525
530
  const r = await se(e, {
526
531
  maxPages: 20,
@@ -529,24 +534,24 @@ const U = 60, xe = (t) => ({
529
534
  gateInterval: 5,
530
535
  headless: !0,
531
536
  screenshots: !1,
532
- errorPosture: q.resilient,
533
- imageShrink: V(xe),
537
+ errorPosture: V.resilient,
538
+ imageShrink: W(ve),
534
539
  heartbeatInterval: 1e3
535
540
  }), i = { ...re, ...e.cooldown }, o = e.isBlocked || De, n = Re(t, {
536
541
  sameDomain: r.sameDomain,
537
542
  maxDepth: r.maxDepth
538
- }), c = await me("site-crawl", e.outputDir), d = await (e.browserEngine ? J[e.browserEngine] : J.chromium).launch({
543
+ }), c = await me("site-crawl", e.outputDir), p = await (e.browserEngine ? X[e.browserEngine] : X.chromium).launch({
539
544
  headless: r.headless,
540
545
  ...e.launchOptions
541
546
  });
542
547
  s.emit({ event: "browser", headless: r.headless });
543
548
  try {
544
- const m = await d.newContext(e.contextOptions);
549
+ const m = await p.newContext(e.contextOptions);
545
550
  if (e.setup) {
546
551
  const h = await m.newPage();
547
552
  await e.setup(h), await h.close(), s.emit({ event: "setup" });
548
553
  }
549
- const l = await m.newPage(), p = (() => {
554
+ const l = await m.newPage(), d = (() => {
550
555
  const h = [];
551
556
  return l.on("response", (y) => h.push(y)), {
552
557
  responses: () => [...h],
@@ -555,21 +560,21 @@ const U = 60, xe = (t) => ({
555
560
  }
556
561
  };
557
562
  })(), g = [];
558
- let S = 0, A = t;
559
- const T = $e(s, r.heartbeatInterval, () => ({
563
+ let x = 0, P = t;
564
+ const R = Fe(s, r.heartbeatInterval, () => ({
560
565
  pagesVisited: g.length,
561
566
  maxPages: r.maxPages,
562
567
  pending: n.size(),
563
- currentUrl: A,
568
+ currentUrl: P,
564
569
  ...n.summary()
565
- })), F = s.batch(r.maxPages);
570
+ })), N = s.batch(r.maxPages);
566
571
  try {
567
572
  for (; !n.isEmpty() && g.length < r.maxPages; ) {
568
573
  if (g.length > 0 && g.length % r.gateInterval === 0 && n.size() > 0) {
569
574
  const y = r.maxPages - g.length;
570
575
  s.emit({ event: "gate:start", pending: n.size(), budget: y });
571
576
  const f = await _e(n, g, y, e);
572
- S++, f.skip.length > 0 && n.skip(f.skip, "llm-gate"), s.emit({
577
+ x++, f.skip.length > 0 && n.skip(f.skip, "llm-gate"), s.emit({
573
578
  event: "gate:complete",
574
579
  explored: f.explore.length,
575
580
  skipped: f.skip.length,
@@ -578,7 +583,7 @@ const U = 60, xe = (t) => ({
578
583
  }
579
584
  const h = n.next();
580
585
  if (!h) break;
581
- A = h.url, s.emit({
586
+ P = h.url, s.emit({
582
587
  event: "page:start",
583
588
  url: h.url,
584
589
  depth: h.depth,
@@ -586,7 +591,7 @@ const U = 60, xe = (t) => ({
586
591
  maxPages: r.maxPages
587
592
  });
588
593
  try {
589
- const y = (E, ue) => je(E, ue, p, c, r, s), { pageData: f, blocked: v } = await Ne(
594
+ const y = (A, ue) => je(A, ue, d, c, r, s), { pageData: f, blocked: S } = await Me(
590
595
  y,
591
596
  l,
592
597
  h.url,
@@ -595,9 +600,9 @@ const U = 60, xe = (t) => ({
595
600
  o,
596
601
  r.heartbeatInterval
597
602
  );
598
- f.depth = h.depth, f.source = h.source, v && (f.blocked = v), g.push(f);
599
- const x = v ? 0 : n.addLinks(
600
- f.links.filter((E) => E.isSameDomain && !E.isAnchor),
603
+ f.depth = h.depth, f.source = h.source, S && (f.blocked = S), g.push(f);
604
+ const v = S ? 0 : n.addLinks(
605
+ f.links.filter((A) => A.isSameDomain && !A.isAnchor),
601
606
  h.depth,
602
607
  h.url
603
608
  );
@@ -606,16 +611,16 @@ const U = 60, xe = (t) => ({
606
611
  url: h.url,
607
612
  links: f.links.length,
608
613
  forms: f.forms.length,
609
- newUrls: x,
614
+ newUrls: v,
610
615
  pending: n.size(),
611
- blocked: v
612
- }), F(1);
616
+ blocked: S
617
+ }), N(1);
613
618
  } catch (y) {
614
- if (s.emit({ event: "page:error", url: h.url, error: y.message }), r.errorPosture === q.strict) throw y;
619
+ if (s.emit({ event: "page:error", url: h.url, error: y.message }), r.errorPosture === V.strict) throw y;
615
620
  }
616
621
  }
617
622
  } finally {
618
- T.stop();
623
+ R.stop();
619
624
  }
620
625
  if (await l.close(), e.teardown) {
621
626
  try {
@@ -626,34 +631,34 @@ const U = 60, xe = (t) => ({
626
631
  s.emit({ event: "teardown" });
627
632
  }
628
633
  await m.close();
629
- const H = qe(g), b = Ve(g), w = {
634
+ const J = qe(g), b = Ve(g), w = {
630
635
  pages: g,
631
- graph: H,
636
+ graph: J,
632
637
  apis: b,
633
638
  frontier: n.summary(),
634
639
  skipped: n.skippedUrls(),
635
- gateCallCount: S,
640
+ gateCallCount: x,
636
641
  cleanup: () => c.cleanup()
637
642
  };
638
643
  return s.complete({
639
- outcome: L.success,
644
+ outcome: T.success,
640
645
  pagesVisited: g.length,
641
646
  apisFound: b.length,
642
- gateCallCount: S,
647
+ gateCallCount: x,
643
648
  ...n.summary()
644
649
  }), w;
645
650
  } catch (m) {
646
651
  throw s.error(m, { pagesVisited: 0 }), m;
647
652
  } finally {
648
- await d.close();
653
+ await p.close();
649
654
  }
650
655
  };
651
656
  We.knownTexts = [];
652
- const ne = 1, M = 20, N = 5, Ge = 0.5, He = 5, X = 8e3, j = 5, $ = {
657
+ const ne = 1, M = 20, F = 5, He = 0.5, Ge = 5, Y = 8e3, q = 5, B = {
653
658
  INDIVIDUAL: "individual",
654
659
  BULK: "bulk"
655
- }, Je = (t) => t === void 0 ? M : typeof t == "number" ? t : { small: 10, med: M, large: 40 }[t] ?? M, Ke = (t) => t === void 0 ? N : typeof t == "number" ? t : { low: 2, med: N, high: 10 }[t] ?? N;
656
- function Xe(t, a) {
660
+ }, Je = (t) => t === void 0 ? M : typeof t == "number" ? t : { small: 10, med: M, large: 40 }[t] ?? M, Xe = (t) => t === void 0 ? F : typeof t == "number" ? t : { low: 2, med: F, high: 10 }[t] ?? F;
661
+ function Ke(t, a) {
657
662
  const e = [];
658
663
  for (let s = 0; s < t.length; s += a)
659
664
  e.push({
@@ -676,22 +681,22 @@ function Q(t, a, e, s, r, i) {
676
681
  parallelMode: !0
677
682
  };
678
683
  }
679
- async function Qe(t, a, e, s, r, i = {}) {
684
+ async function Ye(t, a, e, s, r, i = {}) {
680
685
  try {
681
- const o = e.map((d) => ce(d(t))).filter(Boolean).join(`
686
+ const o = e.map((p) => ce(p(t))).filter(Boolean).join(`
682
687
 
683
688
  `), n = [a, o].filter(Boolean).join(`
684
689
 
685
- `), c = ct(n, t, s, r === "files"), u = await W(c, {
690
+ `), c = ct(n, t, s, r === "files"), u = await H(c, {
686
691
  ...i,
687
- responseFormat: O("arch_result", nt)
692
+ responseFormat: z("arch_result", nt)
688
693
  });
689
694
  return { item: t, ...u, error: void 0 };
690
695
  } catch (o) {
691
696
  return { item: t, passed: !1, reason: `Analysis failed: ${o.message}`, error: o };
692
697
  }
693
698
  }
694
- function Ye(t, a, e, s) {
699
+ function Qe(t, a, e, s) {
695
700
  const r = [], i = [];
696
701
  let o = s;
697
702
  for (const n of t)
@@ -704,47 +709,52 @@ function Ye(t, a, e, s) {
704
709
  shouldStop: !a && o >= e
705
710
  };
706
711
  }
707
- function D(t, a, e, s) {
712
+ function L(t, a, e, s) {
708
713
  t && t(a, e, s);
709
714
  }
710
715
  async function oe(t, a, e, s, r, i = {}) {
711
- D(s, t, void 0, {
716
+ L(s, t, void 0, {
712
717
  ...r,
713
- status: R.start
718
+ status: D.start
714
719
  });
715
720
  try {
716
721
  const o = lt(a, t, e), n = {
717
722
  ...i,
718
- responseFormat: O("arch_bulk_result", ot),
723
+ responseFormat: z("arch_bulk_result", ot),
719
724
  onProgress: ae(s, "reduce")
720
- }, c = await ge(t, o, n), u = c.results || c;
721
- let d = [];
722
- Array.isArray(u) ? d = u : d = t.map((p) => ({
723
- path: p,
724
- passed: !1,
725
- reason: "Invalid response format"
726
- }));
727
- const m = d.filter((p) => !p.passed).length, l = d.length - m;
728
- return D(
725
+ }, c = await ge(t, o, n), u = Array.isArray(c) ? c : c?.results;
726
+ let p = [];
727
+ if (Array.isArray(u))
728
+ p = u;
729
+ else {
730
+ const d = c === null ? "null" : typeof c;
731
+ p = t.map((g) => ({
732
+ path: g,
733
+ passed: !1,
734
+ reason: `Invalid bulk response shape (expected array or { results: [] }, got ${d})`
735
+ }));
736
+ }
737
+ const m = p.filter((d) => !d.passed).length, l = p.length - m;
738
+ return L(
729
739
  s,
730
740
  t,
731
741
  m > 0 ? new Error(`${m} items failed`) : void 0,
732
742
  {
733
743
  ...r,
734
- status: R.complete,
744
+ status: D.complete,
735
745
  passed: l,
736
746
  failed: m
737
747
  }
738
- ), d;
748
+ ), p;
739
749
  } catch (o) {
740
750
  const n = t.map((c) => ({
741
751
  path: c,
742
752
  passed: !1,
743
753
  reason: `Processing error: ${o.message}`
744
754
  }));
745
- return D(s, t, o, {
755
+ return L(s, t, o, {
746
756
  ...r,
747
- status: R.error
757
+ status: D.error
748
758
  }), n;
749
759
  }
750
760
  }
@@ -763,9 +773,9 @@ function Ze(t, a) {
763
773
  function et(t, a, e) {
764
774
  if (t.allPassed)
765
775
  return `All ${t.processed}/${t.total} items satisfy: ${a}`;
766
- const s = t.failures.slice(0, j).map((i) => ` • ${i.item}: ${i.reason || "Failed"}`).join(`
767
- `), r = t.failures.length > j ? `
768
- ... and ${t.failures.length - j} more failures` : "";
776
+ const s = t.failures.slice(0, q).map((i) => ` • ${i.item}: ${i.reason || "Failed"}`).join(`
777
+ `), r = t.failures.length > q ? `
778
+ ... and ${t.failures.length - q} more failures` : "";
769
779
  return `${t.failed}/${t.processed} items failed: ${a}${t.stoppedEarly && e !== ne ? ` (stopped after ${e} failures)` : ""}
770
780
 
771
781
  Failures:
@@ -785,9 +795,9 @@ function tt(t, a) {
785
795
  };
786
796
  }
787
797
  function st(t, a, e, s) {
788
- const r = a || e.length > 0 || s <= He;
798
+ const r = a || e.length > 0 || s <= Ge;
789
799
  return {
790
- mode: r ? $.INDIVIDUAL : $.BULK,
800
+ mode: r ? B.INDIVIDUAL : B.BULK,
791
801
  batchSize: r ? t.maxConcurrency : t.bulkSize,
792
802
  processor: r ? (i, o, n) => ie(i, o, n) : (i, o, n) => oe(
793
803
  i.items,
@@ -800,7 +810,7 @@ function st(t, a, e, s) {
800
810
  }
801
811
  function ie(t, a, e) {
802
812
  const s = t.items.map(
803
- (r) => Qe(
813
+ (r) => Ye(
804
814
  r,
805
815
  a,
806
816
  e.itemContextFns,
@@ -812,8 +822,8 @@ function ie(t, a, e) {
812
822
  return Promise.all(s);
813
823
  }
814
824
  function at(t, a, e) {
815
- if (a === $.INDIVIDUAL) {
816
- const { results: s, errors: r, failures: i, shouldStop: o } = Ye(
825
+ if (a === B.INDIVIDUAL) {
826
+ const { results: s, errors: r, failures: i, shouldStop: o } = Qe(
817
827
  t,
818
828
  e.isCoverageTest,
819
829
  e.maxFailures,
@@ -848,7 +858,7 @@ function at(t, a, e) {
848
858
  }
849
859
  }
850
860
  async function rt(t, a, e, s) {
851
- const r = Xe(t, e.batchSize), i = [];
861
+ const r = Ke(t, e.batchSize), i = [];
852
862
  let o = 0;
853
863
  for (const n of r) {
854
864
  if (!s.isCoverageTest && o >= s.maxFailures)
@@ -857,13 +867,13 @@ async function rt(t, a, e, s) {
857
867
  n,
858
868
  r.length,
859
869
  t.length,
860
- R.start,
870
+ D.start,
861
871
  s,
862
872
  e.mode
863
873
  );
864
- D(s.onChunkProcessed, n.items, void 0, c);
874
+ L(s.onChunkProcessed, n.items, void 0, c);
865
875
  let u;
866
- e.mode === $.INDIVIDUAL ? u = await ie(n, a, {
876
+ e.mode === B.INDIVIDUAL ? u = await ie(n, a, {
867
877
  itemContextFns: s.itemContextFns,
868
878
  description: s.description,
869
879
  targetType: s.targetType
@@ -875,26 +885,26 @@ async function rt(t, a, e, s) {
875
885
  c,
876
886
  s.runConfig
877
887
  );
878
- const d = at(u, e.mode, {
888
+ const p = at(u, e.mode, {
879
889
  ...s,
880
890
  currentFailures: o
881
891
  });
882
- if (i.push(...d.results), o = d.failures, D(
892
+ if (i.push(...p.results), o = p.failures, L(
883
893
  s.onChunkProcessed,
884
894
  n.items,
885
- d.errors.length > 0 ? d.errors[0] : void 0,
895
+ p.errors.length > 0 ? p.errors[0] : void 0,
886
896
  {
887
897
  ...Q(
888
898
  n,
889
899
  r.length,
890
900
  t.length,
891
- R.complete,
901
+ D.complete,
892
902
  s,
893
903
  e.mode
894
904
  ),
895
- ...d.progressData
905
+ ...p.progressData
896
906
  }
897
- ), d.shouldStop)
907
+ ), p.shouldStop)
898
908
  break;
899
909
  }
900
910
  return i;
@@ -947,7 +957,7 @@ function it(t) {
947
957
  return k.readdirSync(t).join(", ");
948
958
  {
949
959
  const e = k.readFileSync(t, "utf8");
950
- return e.length > X ? `${e.substring(0, X)}
960
+ return e.length > Y ? `${e.substring(0, Y)}
951
961
  ... (truncated)` : e;
952
962
  }
953
963
  }
@@ -977,7 +987,7 @@ function lt(t, a, e) {
977
987
  }
978
988
  class ut {
979
989
  constructor(a, e = {}) {
980
- this.target = a, this.options = e, this.contexts = [], this.itemContextFns = [], this.maxFailures = e.maxFailures || ne, this.bulkSize = e.bulkSize || M, this.maxConcurrency = e.maxConcurrency || N, this.onChunkProcessed = void 0, this.description = void 0, this.threshold = void 0, this.isCoverageTest = !1;
990
+ this.target = a, this.options = e, this.contexts = [], this.itemContextFns = [], this.maxFailures = e.maxFailures || ne, this.bulkSize = e.bulkSize || M, this.maxConcurrency = e.maxConcurrency || F, this.onChunkProcessed = void 0, this.description = void 0, this.threshold = void 0, this.isCoverageTest = !1;
981
991
  }
982
992
  withContext(a) {
983
993
  return this.contexts.push(a), this;
@@ -990,13 +1000,13 @@ class ut {
990
1000
  return this.description = a, this;
991
1001
  }
992
1002
  // Set up for a coverage test
993
- coverage(a = Ge) {
1003
+ coverage(a = He) {
994
1004
  return this.threshold = a, this.isCoverageTest = !0, this;
995
1005
  }
996
1006
  // Start processing - this is the fluent terminator
997
1007
  async start() {
998
- const a = B("ai-arch-expect", this.options), e = z("ai-arch-expect", a.onProgress, a);
999
- e.start(), e.emit({ event: P.input, value: this.description });
1008
+ const a = O("ai-arch-expect", this.options), e = U("ai-arch-expect", a.onProgress, a);
1009
+ e.start(), e.emit({ event: E.input, value: this.description });
1000
1010
  try {
1001
1011
  if (!this.description)
1002
1012
  throw new Error("Must call satisfies() before start()");
@@ -1008,8 +1018,8 @@ class ut {
1008
1018
  this.itemContextFns,
1009
1019
  s.length
1010
1020
  ), { bulkSize: o, maxConcurrency: n, maxFailures: c } = await se(a, {
1011
- bulkSize: V(Je),
1012
- maxConcurrency: V(Ke),
1021
+ bulkSize: W(Je),
1022
+ maxConcurrency: W(Xe),
1013
1023
  maxFailures: this.maxFailures
1014
1024
  }), u = {
1015
1025
  bulkSize: o,
@@ -1021,17 +1031,17 @@ class ut {
1021
1031
  maxFailures: c,
1022
1032
  isCoverageTest: this.isCoverageTest,
1023
1033
  runConfig: a
1024
- }, d = e.batch(s.length), m = await rt(s, r, i, u);
1025
- if (d(m.length), this.isCoverageTest) {
1026
- const p = m.filter((F) => F.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 T = { passed: S, coverage: g, message: A };
1030
- return e.emit({ event: P.output, value: T }), e.complete({ outcome: L.success, coverage: g, total: s.length }), T;
1034
+ }, p = e.batch(s.length), m = await rt(s, r, i, u);
1035
+ if (p(m.length), this.isCoverageTest) {
1036
+ const d = m.filter((N) => N.passed).length, g = s.length > 0 ? d / s.length : 0, x = g >= this.threshold, P = `Coverage: ${d}/${s.length} (${(g * 100).toFixed(1)}%) - ${x ? "meets" : "below"} ${(this.threshold * 100).toFixed(1)}% threshold`;
1037
+ if (!x)
1038
+ throw new Error(P);
1039
+ const R = { passed: x, coverage: g, message: P };
1040
+ return e.emit({ event: E.output, value: R }), e.complete({ outcome: T.success, coverage: g, total: s.length }), R;
1031
1041
  }
1032
1042
  const l = this.summarize(s, m);
1033
- return e.emit({ event: P.output, value: l }), e.complete({
1034
- outcome: L.success,
1043
+ return e.emit({ event: E.output, value: l }), e.complete({
1044
+ outcome: T.success,
1035
1045
  total: s.length,
1036
1046
  passed: l.details.passed
1037
1047
  }), l;
@@ -1046,14 +1056,14 @@ class ut {
1046
1056
  return tt(s, r);
1047
1057
  }
1048
1058
  }
1049
- function pt(t, a = {}) {
1059
+ function dt(t, a = {}) {
1050
1060
  return new ut(t, a);
1051
1061
  }
1052
- pt.knownTexts = [];
1062
+ dt.knownTexts = [];
1053
1063
  function Dt() {
1054
1064
  return console.warn("scanJS is not available in browser environment"), Promise.resolve({});
1055
1065
  }
1056
- const Y = {
1066
+ const Z = {
1057
1067
  name: "test_analysis_result",
1058
1068
  schema: {
1059
1069
  type: "object",
@@ -1074,14 +1084,14 @@ const Y = {
1074
1084
  required: ["hasIssues", "issues"],
1075
1085
  additionalProperties: !1
1076
1086
  }
1077
- }, Z = "test";
1087
+ }, ee = "test";
1078
1088
  async function le(t, a, e) {
1079
1089
  [a, e] = fe(a, e);
1080
- const { text: s, context: r } = be(a, []), i = B(Z, e), o = z(Z, i.onProgress, i);
1090
+ const { text: s, context: r } = be(a, []), i = O(ee, e), o = U(ee, i.onProgress, i);
1081
1091
  o.start();
1082
1092
  try {
1083
- const n = await ve.readFile(t, "utf-8");
1084
- o.emit({ event: P.phase, phase: "file-read", path: t });
1093
+ const n = await Se.readFile(t, "utf-8");
1094
+ o.emit({ event: E.phase, phase: "file-read", path: t });
1085
1095
  const c = r ? `
1086
1096
 
1087
1097
  ${r}` : "", u = `Analyze this code and ${s}:
@@ -1098,29 +1108,29 @@ GUIDELINES:
1098
1108
  - Suggest concrete fixes for each issue identified
1099
1109
  - Be concise but clear in your feedback
1100
1110
  - If no issues are found, return {"hasIssues": false, "issues": []}${c}`;
1101
- o.emit({ event: P.phase, phase: "analyzing" });
1102
- const d = await ye(
1103
- () => W(u, {
1111
+ o.emit({ event: E.phase, phase: "analyzing" });
1112
+ const p = await ye(
1113
+ () => H(u, {
1104
1114
  ...i,
1105
- responseFormat: O(Y.name, Y.schema)
1115
+ responseFormat: z(Z.name, Z.schema)
1106
1116
  }),
1107
1117
  {
1108
1118
  label: "test chain",
1109
1119
  config: i
1110
1120
  }
1111
- ), m = d.hasIssues ? d.issues : [];
1121
+ ), m = p.hasIssues ? p.issues : [];
1112
1122
  return o.emit({
1113
- event: P.phase,
1123
+ event: E.phase,
1114
1124
  phase: "analysis-complete",
1115
1125
  issueCount: m.length
1116
- }), o.complete({ outcome: L.success }), m;
1126
+ }), o.complete({ outcome: T.success }), m;
1117
1127
  } catch (n) {
1118
1128
  throw o.error(n), n;
1119
1129
  }
1120
1130
  }
1121
1131
  le.knownTexts = [];
1122
- 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 = [
1123
- dt,
1132
+ const te = "test-advice", pt = "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.", $ = [
1133
+ pt,
1124
1134
  mt,
1125
1135
  ht,
1126
1136
  gt,
@@ -1129,282 +1139,326 @@ const ee = "test-advice", dt = "Run the code with 5 boundary value test cases an
1129
1139
  yt,
1130
1140
  wt
1131
1141
  ];
1132
- async function vt(t, a = {}) {
1133
- const e = B(ee, a), s = z(ee, e.onProgress, e);
1142
+ async function St(t, a = {}) {
1143
+ if (typeof t != "string" || t.length === 0)
1144
+ throw new Error(
1145
+ `test-advice: path must be a non-empty string (got ${t === null ? "null" : typeof t})`
1146
+ );
1147
+ const e = O(te, a), s = U(te, e.onProgress, e);
1134
1148
  s.start();
1135
1149
  try {
1136
- const r = s.batch(te.length), o = (await we(
1137
- te,
1138
- async (n) => {
1139
- const c = await le(t, n, {
1150
+ const r = s.batch($.length), o = (await we(
1151
+ $,
1152
+ async (u) => {
1153
+ const p = await le(t, u, {
1140
1154
  ...e,
1141
1155
  onProgress: ae(e.onProgress, "test-advice:test")
1142
1156
  });
1143
- return r(1), c;
1157
+ return r(1), p;
1144
1158
  },
1145
1159
  {
1146
1160
  maxParallel: 3,
1147
- errorPosture: q.resilient,
1161
+ errorPosture: V.resilient,
1148
1162
  abortSignal: e.abortSignal,
1149
1163
  label: "test-advice:instructions"
1150
1164
  }
1151
- )).filter(Array.isArray).flat();
1152
- return s.complete({ outcome: L.success, totalIssues: o.length }), o;
1165
+ )).filter(Array.isArray), n = $.length - o.length;
1166
+ if (o.length === 0)
1167
+ throw new Error(`test-advice: all ${$.length} instructions failed`);
1168
+ const c = o.flat();
1169
+ return s.complete({
1170
+ outcome: n > 0 ? T.partial : T.success,
1171
+ totalIssues: c.length,
1172
+ failedInstructions: n
1173
+ }), c;
1153
1174
  } catch (r) {
1154
1175
  throw s.error(r), r;
1155
1176
  }
1156
1177
  }
1157
- vt.knownTexts = [];
1158
- pe.config();
1178
+ St.knownTexts = [];
1179
+ de.config();
1159
1180
  export {
1160
- Mt as CAPABILITY_KEYS,
1161
- Nt as COMPLIANCE,
1162
- $t as CONTEXT_KINDS,
1163
- Bt as COST_POSTURE,
1164
- zt as ChainEvent,
1165
- Ot as ChainTree,
1166
- Ut as ContextBudget,
1167
- _t as Conversation,
1168
- jt as DOMAIN,
1169
- P as DomainEvent,
1170
- qt as ENVIRONMENT,
1171
- Vt as EmbeddingService,
1172
- Wt as ErrorCategory,
1173
- Gt as Kind,
1174
- Ht as Level,
1175
- Jt as ListStyle,
1176
- Kt as ModelService,
1177
- Xt as ModelSource,
1178
- R as OpEvent,
1179
- Qt as OptionSource,
1180
- Yt as QUALITY_INTENT,
1181
- Zt as RetryMode,
1182
- es as SocraticMethod,
1183
- ts as StatusCode,
1184
- ss as SummaryMap,
1185
- as as TelemetryEvent,
1186
- rs as TimedAbortController,
1187
- pt as aiArchExpect,
1188
- ns as aiExpect,
1189
- os as analyzeImage,
1190
- is as analyzeImageMapDetail,
1191
- cs as anySignal,
1192
- ls as applyAllTargetingRules,
1193
- us as applyFirstTargetingRule,
1194
- ps as auto,
1195
- ds as bool,
1196
- ms as buildSeedGenerationPrompt,
1197
- hs as buildVisionPrompt,
1198
- gs as calculateStatistics,
1199
- fs as calibrate,
1200
- bs as calibrateInstructions,
1201
- ys as calibrateSpec,
1202
- ws as callAgent,
1203
- vs as categorySamples,
1204
- xs as causalFramePrompt,
1205
- Ss as centralTendency,
1206
- ks as centralTendencyLines,
1207
- Cs as chunk,
1208
- Is as chunkSentences,
1209
- As as classify,
1210
- Es as cleanupPaths,
1211
- Ps as collectEventsWith,
1212
- Ts as collectTerms,
1213
- Rs as combinations,
1214
- Ds as commonalities,
1215
- Ls as compact,
1181
+ $t as CAPABILITY_KEYS,
1182
+ Mt as COMPLIANCE,
1183
+ Ft as CONTENT_TYPES,
1184
+ Bt as CONTEXT_KINDS,
1185
+ Ot as COST_POSTURE,
1186
+ Ut as ChainEvent,
1187
+ zt as ChainTree,
1188
+ _t as ContextBudget,
1189
+ jt as Conversation,
1190
+ qt as DEFAULT_HEADING_DETECTORS,
1191
+ Vt as DOMAIN,
1192
+ E as DomainEvent,
1193
+ Wt as ENVIRONMENT,
1194
+ Ht as EmbeddingService,
1195
+ Gt as ErrorCategory,
1196
+ Jt as Kind,
1197
+ Xt as Level,
1198
+ Kt as ListStyle,
1199
+ Yt as ModelService,
1200
+ Qt as ModelSource,
1201
+ D as OpEvent,
1202
+ Zt as OptionSource,
1203
+ es as QUALITY_INTENT,
1204
+ ts as RetryMode,
1205
+ ss as SocraticMethod,
1206
+ as as StatusCode,
1207
+ rs as SummaryMap,
1208
+ ns as TelemetryEvent,
1209
+ os as TimedAbortController,
1210
+ dt as aiArchExpect,
1211
+ is as aiExpect,
1212
+ cs as allCapsHeading,
1213
+ ls as analyzeImage,
1214
+ us as analyzeImageMapDetail,
1215
+ ds as anySignal,
1216
+ ps as applyAllTargetingRules,
1217
+ ms as applyFirstTargetingRule,
1218
+ hs as auto,
1219
+ gs as bool,
1220
+ fs as buildSeedGenerationPrompt,
1221
+ bs as buildVisionPrompt,
1222
+ ys as calculateStatistics,
1223
+ ws as calibrateInstructions,
1224
+ Ss as calibrateItem,
1225
+ vs as calibrateSpec,
1226
+ xs as callAgent,
1227
+ ks as categorySamples,
1228
+ Cs as causalFramePrompt,
1229
+ Is as centralTendency,
1230
+ Ps as centralTendencyLines,
1231
+ As as chunk,
1232
+ Es as chunkSentences,
1233
+ Ts as classify,
1234
+ Rs as cleanupPaths,
1235
+ Ds as collectEventsWith,
1236
+ Ls as collectTerms,
1237
+ Ns as combinations,
1238
+ $s as commonalities,
1239
+ Ms as compact,
1216
1240
  Fs as computeTagStatistics,
1217
- Ms as config,
1218
- Ns as constants,
1219
- $s as conversationTurnReduce,
1220
- Bs as cosineSimilarity,
1221
- zs as createBatches,
1222
- Os as createContextBuilder,
1223
- z as createProgressEmitter,
1241
+ Bs as config,
1242
+ Os as constants,
1243
+ Us as conversationTurnReduce,
1244
+ zs as cosineSimilarity,
1245
+ _s as createBatches,
1246
+ js as createContextBuilder,
1247
+ U as createProgressEmitter,
1224
1248
  me as createTempDir,
1225
- Us as createTraceCollector,
1226
- _s as date,
1227
- js as debug,
1228
- W as default,
1229
- qs as descriptorToSchema,
1230
- Vs as detectPatterns,
1231
- Ws as detectThreshold,
1232
- Gs as determineStyle,
1233
- Hs as disambiguate,
1234
- Js as dismantle,
1235
- Ks as documentShrink,
1236
- Xs as embed,
1237
- Qs as embedAssembleSpan,
1238
- Ys as embedBatch,
1239
- Zs as embedBuildIndex,
1240
- ea as embedChunked,
1241
- ta as embedImage,
1242
- sa as embedImageBatch,
1243
- aa as embedMergeRanges,
1244
- ra as embedMultiQuery,
1245
- na as embedNeighborChunks,
1246
- oa as embedNormalizeText,
1247
- ia as embedObject,
1248
- ca as embedRewriteQuery,
1249
- la as embedRewriteToOutputDoc,
1250
- ua as embedStandaloneSpan,
1251
- pa as embedStepBack,
1252
- da as embedSubquestions,
1253
- ma as embedWarmup,
1254
- ha as entityInstructions,
1255
- ga as entitySpec,
1256
- fa as evaluateTargetingClause,
1257
- ba as evaluateTargetingRule,
1258
- ya as eventToTrace,
1259
- wa as expect,
1260
- va as extractBlocks,
1249
+ qs as createTraceCollector,
1250
+ Vs as date,
1251
+ Ws as debug,
1252
+ H as default,
1253
+ Hs as descriptorToSchema,
1254
+ Gs as detectPatterns,
1255
+ Js as detectThreshold,
1256
+ Xs as determineStyle,
1257
+ Ks as disambiguate,
1258
+ Ys as dismantle,
1259
+ Qs as documentShrink,
1260
+ Zs as documentShrinkPrompts,
1261
+ ea as documentShrinkTuning,
1262
+ ta as embed,
1263
+ sa as embedAssembleSpan,
1264
+ aa as embedBatch,
1265
+ ra as embedBuildIndex,
1266
+ na as embedChunked,
1267
+ oa as embedImage,
1268
+ ia as embedImageBatch,
1269
+ ca as embedMergeRanges,
1270
+ la as embedMultiQuery,
1271
+ ua as embedNeighborChunks,
1272
+ da as embedNormalizeText,
1273
+ pa as embedObject,
1274
+ ma as embedRewriteQuery,
1275
+ ha as embedRewriteToOutputDoc,
1276
+ ga as embedStandaloneSpan,
1277
+ fa as embedStepBack,
1278
+ ba as embedSubquestions,
1279
+ ya as embedWarmup,
1280
+ wa as entityInstructions,
1281
+ Sa as entityItem,
1282
+ va as entitySpec,
1283
+ xa as evaluateTargetingClause,
1284
+ ka as evaluateTargetingRule,
1285
+ Ca as eventToTrace,
1286
+ Ia as expect,
1287
+ Pa as extractBlocks,
1261
1288
  Ce as extractButtons,
1262
- xa as extractEntities,
1263
1289
  ke as extractForms,
1264
- Sa as extractJson,
1265
- Se as extractLinks,
1266
- Ae as extractMeta,
1267
- Pe as extractPage,
1268
- ka as extractRelations,
1290
+ Aa as extractJson,
1291
+ xe as extractLinks,
1292
+ Pe as extractMeta,
1293
+ Ee as extractPage,
1269
1294
  Ie as extractScripts,
1270
- Ee as extractStructure,
1271
- Ca as fillMissing,
1272
- Ia as filter,
1273
- Aa as filterAmbiguous,
1274
- Ea as filterEach,
1275
- Pa as find,
1276
- Ta as findEach,
1277
- Ra as generateList,
1278
- Da as getMeanings,
1279
- La as getOption,
1280
- Fa as getOptionDetail,
1295
+ Ae as extractStructure,
1296
+ Ea as fillMissing,
1297
+ Ta as filter,
1298
+ Ra as filterAmbiguous,
1299
+ Da as filterEach,
1300
+ La as filterItem,
1301
+ Na as filterParallel,
1302
+ $a as find,
1303
+ Ma as findEach,
1304
+ Fa as findItem,
1305
+ Ba as findParallel,
1306
+ Oa as generateList,
1307
+ Ua as getMeanings,
1308
+ za as getOption,
1309
+ _a as getOptionDetail,
1281
1310
  se as getOptions,
1282
- Ma as glossary,
1283
- Na as group,
1284
- $a as groupEach,
1311
+ ja as glossary,
1312
+ qa as group,
1313
+ Va as groupEach,
1314
+ Wa as groupItem,
1315
+ Ha as groupParallel,
1316
+ Ga as hashHeading,
1285
1317
  Tt as imageToBase64,
1286
- Ba as init,
1287
- za as intent,
1288
- Oa as intersections,
1289
- Ua as join,
1290
- O as jsonSchema,
1291
- _a as last,
1292
- ja as list,
1293
- qa as listBatch,
1294
- Va as listExpand,
1295
- W as llm,
1296
- Wa as llmLogger,
1297
- Ga as makePrompt,
1298
- Ha as map,
1299
- Ja as mapEach,
1300
- xe as mapImageShrink,
1301
- Ka as mapTags,
1302
- Xa as name,
1303
- Qa as nameSimilarTo,
1304
- B as nameStep,
1305
- Ya as normalizeInstruction,
1306
- Za as normalizeLlm,
1307
- er as normalizeRubric,
1308
- tr as number,
1309
- sr as numberWithUnits,
1310
- ar as observeApplication,
1311
- rr as observeProviders,
1312
- nr as omit,
1313
- or as pFilter,
1314
- ir as pFind,
1315
- cr as pGroup,
1316
- lr as pMap,
1317
- ur as pReduce,
1318
+ Ja as init,
1319
+ Xa as intent,
1320
+ Ka as intersections,
1321
+ Ya as join,
1322
+ z as jsonSchema,
1323
+ Qa as last,
1324
+ Za as list,
1325
+ er as listBatch,
1326
+ tr as listExpand,
1327
+ H as llm,
1328
+ sr as llmLogger,
1329
+ ar as makePrompt,
1330
+ rr as map,
1331
+ nr as mapCalibrate,
1332
+ or as mapCalibrateParallel,
1333
+ ir as mapDetail,
1334
+ cr as mapEach,
1335
+ lr as mapEntities,
1336
+ ur as mapEntitiesParallel,
1337
+ ve as mapImageShrink,
1338
+ dr as mapItem,
1339
+ pr as mapMode,
1340
+ mr as mapParallel,
1341
+ hr as mapPeopleSet,
1342
+ gr as mapPeopleSetParallel,
1343
+ fr as mapPopReference,
1344
+ br as mapPopReferenceParallel,
1345
+ yr as mapRelations,
1346
+ wr as mapRelationsParallel,
1347
+ Sr as mapScale,
1348
+ vr as mapScaleParallel,
1349
+ xr as mapTags,
1350
+ kr as multiHashHeading,
1351
+ Cr as name,
1352
+ Ir as nameSimilarTo,
1353
+ O as nameStep,
1354
+ Pr as normalizeInstruction,
1355
+ Ar as normalizeLlm,
1356
+ Er as normalizeRubric,
1357
+ Tr as number,
1358
+ Rr as numberWithUnits,
1359
+ Dr as observeApplication,
1360
+ Lr as observeProviders,
1361
+ Nr as omit,
1362
+ $r as orgStarHeading,
1363
+ Mr as pFilter,
1364
+ Fr as pFind,
1365
+ Br as pGroup,
1366
+ Or as pMap,
1367
+ Ur as pReduce,
1318
1368
  we as parallel,
1319
- pr as parallelMap,
1320
- dr as parseLLMList,
1321
- mr as parseRDFLiteral,
1322
- hr as parseRelations,
1323
- gr as people,
1324
- fr as phailForge,
1325
- br as pick,
1326
- yr as pipe,
1327
- wr as popReference,
1328
- vr as promptCache,
1329
- xr as promptPiece,
1330
- Sr as prompts,
1331
- kr as questions,
1332
- Cr as rangeCombinations,
1369
+ zr as parallelMap,
1370
+ _r as parseLLMList,
1371
+ jr as parseRDFLiteral,
1372
+ qr as parseRelations,
1373
+ Vr as peopleSet,
1374
+ Wr as phailForge,
1375
+ Hr as pick,
1376
+ Gr as pipe,
1377
+ Jr as popReferenceItem,
1378
+ Xr as promptCache,
1379
+ Kr as promptPiece,
1380
+ Yr as prompts,
1381
+ Qr as questions,
1382
+ Zr as rangeCombinations,
1333
1383
  ge as reduce,
1334
- Ir as reduceEach,
1335
- Ar as relationInstructions,
1336
- Er as relationSpec,
1337
- Et as resizeImage,
1384
+ en as reduceEach,
1385
+ tn as reduceItem,
1386
+ sn as relationInstructions,
1387
+ an as relationItem,
1388
+ rn as relationSpec,
1389
+ At as resizeImage,
1338
1390
  fe as resolveArgs,
1339
- Pr as resolveEmbedding,
1340
- Tr as resolveModel,
1341
- Rr as resolveOutputDir,
1391
+ nn as resolveEmbedding,
1392
+ on as resolveModel,
1393
+ cn as resolveOutputDir,
1342
1394
  be as resolveTexts,
1343
1395
  ye as retry,
1344
- Dr as ringBuffer,
1345
- Lr as scaleInstructions,
1346
- Fr as scaleItem,
1347
- Mr as scaleSpec,
1396
+ ln as ringBuffer,
1397
+ un as scaleInstructions,
1398
+ dn as scaleItem,
1399
+ pn as scaleSpec,
1348
1400
  Dt as scanJS,
1349
- Nr as schemaOrg,
1350
- $r as schemas,
1351
- Br as scientificFramingPrompt,
1401
+ mn as schemaOrg,
1402
+ hn as schemas,
1403
+ gn as scientificFramingPrompt,
1352
1404
  ae as scopePhase,
1353
- zr as score,
1354
- Or as scoreChunksByProbes,
1355
- Ur as scoreInstructions,
1356
- _r as scoreItem,
1357
- jr as scoreMatrix,
1358
- qr as scoreMatrixInstructions,
1359
- Vr as scoreSpec,
1360
- Wr as sentiment,
1361
- Gr as setEmbedEnabled,
1362
- Hr as setImageProcessingEnabled,
1363
- Jr as setInterval,
1364
- Kr as shuffle,
1365
- Xr as simplifyTree,
1405
+ fn as score,
1406
+ bn as scoreChunksByProbes,
1407
+ yn as scoreInstructions,
1408
+ wn as scoreItem,
1409
+ Sn as scoreMatrix,
1410
+ vn as scoreMatrixInstructions,
1411
+ xn as scoreSpec,
1412
+ kn as segment,
1413
+ Cn as sentiment,
1414
+ In as setEmbedEnabled,
1415
+ Pn as setImageProcessingEnabled,
1416
+ An as setInterval,
1417
+ En as shuffle,
1418
+ Tn as simplifyTree,
1366
1419
  We as siteCrawl,
1367
- Qr as slot,
1368
- Yr as socratic,
1369
- Zr as softCoverPrompt,
1370
- en as sort,
1371
- tn as sortBy,
1372
- sn as split,
1373
- an as stripNumeric,
1374
- rn as stripResponse,
1375
- nn as suggestTargetingRules,
1376
- on as tagInstructions,
1377
- cn as tagItem,
1378
- ln as tagSpec,
1379
- un as tagVocabulary,
1380
- pn as targetingClause,
1381
- dn as targetingRule,
1382
- mn as targetingRuleOps,
1383
- hn as targetingRuleSchema,
1384
- gn as templateBuilder,
1385
- fn as templateReplace,
1420
+ Rn as slot,
1421
+ Dn as socratic,
1422
+ Ln as softCoverPrompt,
1423
+ Nn as sort,
1424
+ $n as sortBy,
1425
+ Mn as split,
1426
+ Fn as stripNumeric,
1427
+ Bn as stripResponse,
1428
+ On as suggestTargetingRules,
1429
+ Un as tagInstructions,
1430
+ zn as tagItem,
1431
+ _n as tagSpec,
1432
+ jn as tagVocabulary,
1433
+ qn as targetingClause,
1434
+ Vn as targetingRule,
1435
+ Wn as targetingRuleOps,
1436
+ Hn as targetingRuleSchema,
1437
+ Gn as templateBuilder,
1438
+ Jn as templateReplace,
1386
1439
  le as test,
1387
- vt as testAdvice,
1388
- bn as themes,
1389
- Pt as tileImages,
1390
- yn as timeline,
1391
- wn as toBool,
1392
- vn as toDate,
1393
- xn as toEnum,
1394
- Sn as toNumber,
1395
- kn as toNumberWithUnits,
1396
- Cn as toObject,
1397
- In as truncate,
1398
- An as unionBy,
1399
- En as validateTargetingRules,
1400
- Pn as valueArbitrate,
1401
- Tn as vectorSearch,
1402
- Rn as veiledVariantStrategies,
1403
- Dn as veiledVariants,
1404
- Ln as version,
1440
+ St as testAdvice,
1441
+ Xn as themes,
1442
+ Et as tileImages,
1443
+ Kn as timeline,
1444
+ Yn as toBool,
1445
+ Qn as toDate,
1446
+ Zn as toEnum,
1447
+ eo as toNumber,
1448
+ to as toNumberWithUnits,
1449
+ so as toObject,
1450
+ ao as truncate,
1451
+ ro as underlineHeading,
1452
+ no as unionBy,
1453
+ oo as validateTargetingRules,
1454
+ io as valueArbitrate,
1455
+ co as vectorSearch,
1456
+ lo as veiledVariantStrategies,
1457
+ uo as veiledVariants,
1458
+ po as version,
1405
1459
  Rt as webScrape,
1406
- Fn as windowFor,
1407
- Mn as withInactivityTimeout,
1408
- V as withPolicy,
1409
- Nn as zipWith
1460
+ mo as windowFor,
1461
+ ho as withInactivityTimeout,
1462
+ W as withPolicy,
1463
+ go as zipWith
1410
1464
  };