@absolutejs/rag 0.22.1 → 0.22.2

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.
@@ -111452,6 +111452,15 @@ var hasIncompleteAppContent = (html) => {
111452
111452
  const text = compact(main.textContent);
111453
111453
  return text.length < 100 || /^(?:loading|please wait)(?:[.\s]|$)/iu.test(text);
111454
111454
  };
111455
+ var hasEmptyAppRoot = (html) => {
111456
+ const { document: document2 } = parseHTML(html);
111457
+ return Array.from(document2.querySelectorAll("div,main,section")).some((element) => {
111458
+ const attributes = Array.from(element.attributes);
111459
+ const id = attributes.find((attribute2) => attribute2.name.toLowerCase() === "id")?.value.toLowerCase();
111460
+ const classes = attributes.find((attribute2) => attribute2.name.toLowerCase() === "class")?.value.toLowerCase().split(/\s+/u) ?? [];
111461
+ return (id !== undefined && ["root", "app", "__next"].includes(id) || classes.includes("todoapp")) && element.children.length === 0 && !element.textContent?.trim();
111462
+ });
111463
+ };
111455
111464
 
111456
111465
  // src/web/text.ts
111457
111466
  var websiteHtmlText = (html) => {
@@ -118080,8 +118089,8 @@ var parseWebsiteServiceResult = (value) => {
118080
118089
  return row;
118081
118090
  };
118082
118091
  var createWebsiteReaderClient = (options) => async (input) => {
118083
- const timeoutMs = options.timeoutMs ?? 85000, reserveMs = options.fallbackReserveMs ?? 15000;
118084
- if (!(reserveMs > 0 && timeoutMs > reserveMs))
118092
+ const timeoutMs = options.timeoutMs ?? 85000, reserveMs = options.fallback ? options.fallbackReserveMs ?? 15000 : 0;
118093
+ if (!(reserveMs >= 0 && timeoutMs > reserveMs))
118085
118094
  throw new Error("Reader deadline must reserve fallback time");
118086
118095
  const signal = AbortSignal.any([
118087
118096
  ...input.signal ? [input.signal] : [],
@@ -118122,6 +118131,15 @@ var createWebsiteReaderClient = (options) => async (input) => {
118122
118131
  return result;
118123
118132
  } catch (error) {
118124
118133
  signal.throwIfAborted();
118134
+ if (!options.fallback)
118135
+ return {
118136
+ status: "error",
118137
+ text: "",
118138
+ error: {
118139
+ code: "reader_unavailable",
118140
+ message: "Website reader unavailable. Retry shortly; no website evidence was retrieved."
118141
+ }
118142
+ };
118125
118143
  const result = parseWebsiteServiceResult(await options.fallback({ ...request, signal }));
118126
118144
  signal.throwIfAborted();
118127
118145
  return {
@@ -118181,7 +118199,7 @@ var titleOf = (html) => {
118181
118199
  const title = /<title\b[^>]*>([\s\S]*?)<\/title>/iu.exec(html)?.[1];
118182
118200
  return title ? prepareRAGDocument({ text: title, format: "html" }).normalizedText : null;
118183
118201
  };
118184
- var isShell = (html, text) => text.length < 300 || hasIncompleteAppContent(html) || /(?:enable|requires?|turn on)\s+javascript|javascript\s+(?:is\s+)?(?:disabled|required)/iu.test(text) || /<(?:div|main|section)[^>]*(?:id=["'](?:root|app|__next)["']|class=["']todoapp["'])[^>]*>\s*<\//iu.test(html);
118202
+ var isShell = (html, text) => text.length < 300 || hasIncompleteAppContent(html) || /(?:enable|requires?|turn on)\s+javascript|javascript\s+(?:is\s+)?(?:disabled|required)/iu.test(text) || hasEmptyAppRoot(html);
118185
118203
  var isChallenge = (text) => /verify (?:that )?you are human|checking your browser|just a moment|enable javascript and cookies to continue|access denied/iu.test(text.slice(0, 1000));
118186
118204
  var readRAGWebpage = async (options) => {
118187
118205
  const attempts = [];
@@ -125954,5 +125972,5 @@ export {
125954
125972
  webIndexPostgresSchemaSql
125955
125973
  };
125956
125974
 
125957
- //# debugId=A13572243F640B2064756E2164756E21
125975
+ //# debugId=A17D9EDD6D999CCB64756E2164756E21
125958
125976
  //# sourceMappingURL=index.js.map