@absolutejs/rag 0.22.0 → 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.
- package/CHANGELOG.md +12 -0
- package/WEB_INDEX.md +2 -0
- package/changelog.json +28 -0
- package/dist/research/index.js +22 -4
- package/dist/research/index.js.map +5 -5
- package/dist/src/web/evidence.d.ts +2 -0
- package/dist/src/web/remote.d.ts +3 -1
- package/dist/web/index.js +22 -4
- package/dist/web/index.js.map +5 -5
- package/dist/web-index/index.js +26 -5
- package/dist/web-index/index.js.map +6 -6
- package/package.json +1 -1
|
@@ -22,3 +22,5 @@ export type WebEvidence = {
|
|
|
22
22
|
export declare const extractWebEvidence: (html: string, url: string) => WebEvidence;
|
|
23
23
|
/** Navigation/footer text alone must not mask an empty or loading app root. */
|
|
24
24
|
export declare const hasIncompleteAppContent: (html: string) => boolean;
|
|
25
|
+
/** Parse attributes once: overlapping HTML regex quantifiers can stall on repeated attributes. */
|
|
26
|
+
export declare const hasEmptyAppRoot: (html: string) => boolean;
|
package/dist/src/web/remote.d.ts
CHANGED
|
@@ -17,7 +17,9 @@ export declare const createWebsiteReaderClient: (options: {
|
|
|
17
17
|
fetch?: typeof fetch;
|
|
18
18
|
timeoutMs?: number;
|
|
19
19
|
fallbackReserveMs?: number;
|
|
20
|
-
fallback
|
|
20
|
+
/** Optional host fallback. Omit to preserve process isolation on service failure.
|
|
21
|
+
* A fallback must not run untrusted synchronous parsing on the application event loop. */
|
|
22
|
+
fallback?: (input: {
|
|
21
23
|
url: string;
|
|
22
24
|
maxPages: number;
|
|
23
25
|
mode: "auto" | "browser";
|
package/dist/web/index.js
CHANGED
|
@@ -111227,6 +111227,15 @@ var hasIncompleteAppContent = (html) => {
|
|
|
111227
111227
|
const text = compact(main.textContent);
|
|
111228
111228
|
return text.length < 100 || /^(?:loading|please wait)(?:[.\s]|$)/iu.test(text);
|
|
111229
111229
|
};
|
|
111230
|
+
var hasEmptyAppRoot = (html) => {
|
|
111231
|
+
const { document: document2 } = parseHTML(html);
|
|
111232
|
+
return Array.from(document2.querySelectorAll("div,main,section")).some((element) => {
|
|
111233
|
+
const attributes = Array.from(element.attributes);
|
|
111234
|
+
const id = attributes.find((attribute2) => attribute2.name.toLowerCase() === "id")?.value.toLowerCase();
|
|
111235
|
+
const classes = attributes.find((attribute2) => attribute2.name.toLowerCase() === "class")?.value.toLowerCase().split(/\s+/u) ?? [];
|
|
111236
|
+
return (id !== undefined && ["root", "app", "__next"].includes(id) || classes.includes("todoapp")) && element.children.length === 0 && !element.textContent?.trim();
|
|
111237
|
+
});
|
|
111238
|
+
};
|
|
111230
111239
|
|
|
111231
111240
|
// src/web/text.ts
|
|
111232
111241
|
var websiteHtmlText = (html) => {
|
|
@@ -117855,8 +117864,8 @@ var parseWebsiteServiceResult = (value) => {
|
|
|
117855
117864
|
return row;
|
|
117856
117865
|
};
|
|
117857
117866
|
var createWebsiteReaderClient = (options) => async (input) => {
|
|
117858
|
-
const timeoutMs = options.timeoutMs ?? 85000, reserveMs = options.fallbackReserveMs ?? 15000;
|
|
117859
|
-
if (!(reserveMs
|
|
117867
|
+
const timeoutMs = options.timeoutMs ?? 85000, reserveMs = options.fallback ? options.fallbackReserveMs ?? 15000 : 0;
|
|
117868
|
+
if (!(reserveMs >= 0 && timeoutMs > reserveMs))
|
|
117860
117869
|
throw new Error("Reader deadline must reserve fallback time");
|
|
117861
117870
|
const signal = AbortSignal.any([
|
|
117862
117871
|
...input.signal ? [input.signal] : [],
|
|
@@ -117897,6 +117906,15 @@ var createWebsiteReaderClient = (options) => async (input) => {
|
|
|
117897
117906
|
return result;
|
|
117898
117907
|
} catch (error) {
|
|
117899
117908
|
signal.throwIfAborted();
|
|
117909
|
+
if (!options.fallback)
|
|
117910
|
+
return {
|
|
117911
|
+
status: "error",
|
|
117912
|
+
text: "",
|
|
117913
|
+
error: {
|
|
117914
|
+
code: "reader_unavailable",
|
|
117915
|
+
message: "Website reader unavailable. Retry shortly; no website evidence was retrieved."
|
|
117916
|
+
}
|
|
117917
|
+
};
|
|
117900
117918
|
const result = parseWebsiteServiceResult(await options.fallback({ ...request, signal }));
|
|
117901
117919
|
signal.throwIfAborted();
|
|
117902
117920
|
return {
|
|
@@ -117956,7 +117974,7 @@ var titleOf = (html) => {
|
|
|
117956
117974
|
const title = /<title\b[^>]*>([\s\S]*?)<\/title>/iu.exec(html)?.[1];
|
|
117957
117975
|
return title ? prepareRAGDocument({ text: title, format: "html" }).normalizedText : null;
|
|
117958
117976
|
};
|
|
117959
|
-
var isShell = (html, text) => text.length < 300 || hasIncompleteAppContent(html) || /(?:enable|requires?|turn on)\s+javascript|javascript\s+(?:is\s+)?(?:disabled|required)/iu.test(text) ||
|
|
117977
|
+
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);
|
|
117960
117978
|
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));
|
|
117961
117979
|
var readRAGWebpage = async (options) => {
|
|
117962
117980
|
const attempts = [];
|
|
@@ -118123,5 +118141,5 @@ export {
|
|
|
118123
118141
|
validatePublicWebUrl
|
|
118124
118142
|
};
|
|
118125
118143
|
|
|
118126
|
-
//# debugId=
|
|
118144
|
+
//# debugId=7EA216DAE80952F864756E2164756E21
|
|
118127
118145
|
//# sourceMappingURL=index.js.map
|