@absolutejs/rag 0.15.0 → 0.15.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/CHANGELOG.md CHANGED
@@ -6,6 +6,12 @@ This file is generated by `absolute-changelog` from the entries in
6
6
  `changelog/`. Edit an entry, not this file — and add new ones under
7
7
  `changelog/unreleased/`.
8
8
 
9
+ ## 0.15.1 — 2026-09-20
10
+
11
+ ### Fixed
12
+
13
+ - **Preserve all sections of public websites instead of extracting one article fragment, and retain labeled image evidence in source-bound documents.** (`readRAGWebpage`, `readRAGWebsite`)
14
+
9
15
  ## 0.15.0 — 2026-09-18
10
16
 
11
17
  ### Added
package/changelog.json CHANGED
@@ -2,6 +2,20 @@
2
2
  "contract": 1,
3
3
  "name": "@absolutejs/rag",
4
4
  "releases": [
5
+ {
6
+ "changes": [
7
+ {
8
+ "kind": "fixed",
9
+ "summary": "Preserve all sections of public websites instead of extracting one article fragment, and retain labeled image evidence in source-bound documents.",
10
+ "symbols": [
11
+ "readRAGWebpage",
12
+ "readRAGWebsite"
13
+ ]
14
+ }
15
+ ],
16
+ "date": "2026-09-20",
17
+ "version": "0.15.1"
18
+ },
5
19
  {
6
20
  "changes": [
7
21
  {
@@ -0,0 +1,2 @@
1
+ /** Website research needs the whole page, not the highest-scoring article fragment. */
2
+ export declare const websiteHtmlText: (html: string) => string;
package/dist/web/index.js CHANGED
@@ -11256,6 +11256,34 @@ var hasIncompleteAppContent = (html) => {
11256
11256
  return text.length < 100 || /^(?:loading|please wait)(?:[.\s]|$)/iu.test(text);
11257
11257
  };
11258
11258
 
11259
+ // src/web/text.ts
11260
+ var websiteHtmlText = (html) => {
11261
+ const { document } = parseHTML(html);
11262
+ document.querySelectorAll("script,style,template,noscript,svg,[hidden],[aria-hidden=true]").forEach((element) => element.remove());
11263
+ const root = document.body?.textContent?.trim() ? document.body : document.documentElement;
11264
+ const parts = [];
11265
+ const blocks = /^(?:ADDRESS|ARTICLE|ASIDE|BLOCKQUOTE|BR|DIV|DL|DT|DD|FIGCAPTION|FIGURE|FOOTER|H[1-6]|HEADER|HR|LI|MAIN|NAV|OL|P|SECTION|TABLE|TD|TH|TR|UL)$/u;
11266
+ const walk = (node2) => {
11267
+ if (node2.nodeType === 3) {
11268
+ parts.push((node2.textContent ?? "").replace(/\s+/gu, " "));
11269
+ return;
11270
+ }
11271
+ const block = blocks.test(node2.nodeName);
11272
+ if (block)
11273
+ parts.push(`
11274
+ `);
11275
+ node2.childNodes.forEach(walk);
11276
+ if (block)
11277
+ parts.push(`
11278
+ `);
11279
+ };
11280
+ if (root)
11281
+ walk(root);
11282
+ return parts.join("").split(`
11283
+ `).map((line) => line.trim()).filter(Boolean).join(`
11284
+ `);
11285
+ };
11286
+
11259
11287
  // src/ingestion/ingestion.ts
11260
11288
  import { readdir, readFile } from "fs/promises";
11261
11289
  import { basename, extname, join, relative, resolve } from "path";
@@ -17803,13 +17831,22 @@ var readRAGWebsite = async (options) => {
17803
17831
  const page = pages.find((item) => item.finalUrl === source.url && item.text);
17804
17832
  if (!page || remainingDocumentChars <= 0)
17805
17833
  return [];
17806
- const text = page.text.slice(0, remainingDocumentChars);
17834
+ const imageLabels = page.evidence.images.filter((image) => image.label).map((image) => `${image.context ? `${image.context}: ` : ""}${image.label}`);
17835
+ const fullText = [
17836
+ page.text,
17837
+ ...imageLabels.length ? [
17838
+ "Image labels supplied by the website (not independently verified customer relationships):",
17839
+ ...imageLabels
17840
+ ] : []
17841
+ ].join(`
17842
+ `);
17843
+ const text = fullText.slice(0, remainingDocumentChars);
17807
17844
  remainingDocumentChars -= text.length;
17808
17845
  return [
17809
17846
  {
17810
17847
  sourceId: source.id,
17811
17848
  text,
17812
- truncated: page.truncated || text.length < page.text.length
17849
+ truncated: page.truncated || text.length < fullText.length
17813
17850
  }
17814
17851
  ];
17815
17852
  });
@@ -17856,7 +17893,7 @@ ${page.text}`).join(`
17856
17893
  // src/web/index.ts
17857
17894
  var messageFor = (error) => error instanceof Error ? error.message : "Website retrieval failed.";
17858
17895
  var codeFor = (error) => error instanceof WebReadError ? error.code : error instanceof Error && /^(?:AbortError|TimeoutError)$/u.test(error.name) ? "timeout" : "fetch_failed";
17859
- var cleanHtml = (html) => prepareRAGDocument({ text: html, format: "html" }).normalizedText;
17896
+ var cleanHtml = websiteHtmlText;
17860
17897
  var titleOf = (html) => {
17861
17898
  const title = /<title\b[^>]*>([\s\S]*?)<\/title>/iu.exec(html)?.[1];
17862
17899
  return title ? prepareRAGDocument({ text: title, format: "html" }).normalizedText : null;
@@ -18025,5 +18062,5 @@ export {
18025
18062
  validatePublicWebUrl
18026
18063
  };
18027
18064
 
18028
- //# debugId=3F4B779525714ED064756E2164756E21
18065
+ //# debugId=64305FA75E0E709664756E2164756E21
18029
18066
  //# sourceMappingURL=index.js.map