@absolutejs/rag 0.14.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,18 @@ 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
+
15
+ ## 0.15.0 — 2026-09-18
16
+
17
+ ### Added
18
+
19
+ - **Expose bounded website documents bound to source IDs and compact inline citation links for native MCP evidence presentation.** (`readRAGWebsite`)
20
+
9
21
  ## 0.14.0 — 2026-09-18
10
22
 
11
23
  ### Added
package/README.md CHANGED
@@ -191,3 +191,9 @@ evidence text. Failed pages and unvisited links are not citable source entries.
191
191
  `citationRequirements` asks consumers to place links beside supported claims,
192
192
  avoid unsupported exclusions or ownership relationships, and keep verified brand
193
193
  changes brief. Host applications still control their generated final answers.
194
+
195
+ `kind: "website_evidence"` identifies a website research result. `documents`
196
+ binds each bounded text excerpt to a source ID, while source entries provide
197
+ compact numbered `inlineCitation` links. This lets adapters present source-local
198
+ evidence without dumping raw retrieval metadata into a model's response context.
199
+ The combined document text respects `maxChars`; truncated excerpts are marked.
package/changelog.json CHANGED
@@ -2,6 +2,33 @@
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
+ },
19
+ {
20
+ "changes": [
21
+ {
22
+ "kind": "added",
23
+ "summary": "Expose bounded website documents bound to source IDs and compact inline citation links for native MCP evidence presentation.",
24
+ "symbols": [
25
+ "readRAGWebsite"
26
+ ]
27
+ }
28
+ ],
29
+ "date": "2026-09-18",
30
+ "version": "0.15.0"
31
+ },
5
32
  {
6
33
  "changes": [
7
34
  {
@@ -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;
@@ -59,10 +59,18 @@ export declare const readRAGWebsite: (options: ReadWebpageOptions & {
59
59
  redirects: import("./transport").WebRedirect[];
60
60
  evidence: import("./evidence").WebEvidence;
61
61
  limitations: string[];
62
+ kind: "website_evidence";
63
+ documents: {
64
+ sourceId: string;
65
+ text: string;
66
+ truncated: boolean;
67
+ }[];
62
68
  sources: {
69
+ id: string;
63
70
  title: string;
64
71
  url: string;
65
72
  citation: string;
73
+ inlineCitation: string;
66
74
  }[];
67
75
  citationRequirements: string;
68
76
  }>;
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";
@@ -17786,11 +17814,41 @@ var readRAGWebsite = async (options) => {
17786
17814
  });
17787
17815
  }
17788
17816
  }
17789
- const sources = pages.filter((page) => page.status !== "error" && page.text).map((page) => {
17817
+ const sources = pages.filter((page) => page.status !== "error" && page.text).map((page, index) => {
17790
17818
  const title = (page.title || new URL(page.finalUrl).hostname).replace(/\s+/gu, " ").trim();
17791
17819
  const label = title.replace(/[\\[\]]/gu, "\\$&");
17792
17820
  const href = page.finalUrl.replace(/[<>]/gu, encodeURIComponent);
17793
- return { title, url: page.finalUrl, citation: `[${label}](<${href}>)` };
17821
+ return {
17822
+ id: `source-${index + 1}`,
17823
+ title,
17824
+ url: page.finalUrl,
17825
+ citation: `[${label}](<${href}>)`,
17826
+ inlineCitation: `[${index + 1}](<${href}>)`
17827
+ };
17828
+ });
17829
+ let remainingDocumentChars = maxChars;
17830
+ const documents = sources.flatMap((source) => {
17831
+ const page = pages.find((item) => item.finalUrl === source.url && item.text);
17832
+ if (!page || remainingDocumentChars <= 0)
17833
+ return [];
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);
17844
+ remainingDocumentChars -= text.length;
17845
+ return [
17846
+ {
17847
+ sourceId: source.id,
17848
+ text,
17849
+ truncated: page.truncated || text.length < fullText.length
17850
+ }
17851
+ ];
17794
17852
  });
17795
17853
  const evidenceText = pages.filter((page) => page.status !== "error").map((page) => `SOURCE: ${page.finalUrl}
17796
17854
  CITATION: ${sources.find((source) => source.url === page.finalUrl)?.citation ?? page.finalUrl}
@@ -17802,6 +17860,8 @@ ${page.text}`).join(`
17802
17860
  const incomplete = pages.some((page) => page.status !== "ok") || signal.aborted;
17803
17861
  const unvisited = queue.filter((link) => !visited.has(link.url.split("#")[0]));
17804
17862
  return {
17863
+ kind: "website_evidence",
17864
+ documents,
17805
17865
  sources,
17806
17866
  citationRequirements: "The final answer must contain clickable Markdown source links, not just source names or bare domain mentions. Reuse sources[].citation beside the factual paragraph, list or table row it supports. Cite the actual supporting page, not the homepage for everything. Every factual section needs its supporting links. Do not invent sources or use unread links as evidence. Before responding, check that company facts, service descriptions, customer examples and numerical claims have supporting links; retrieve or omit unsupported claims. A list of large customers does not prove smaller customers are excluded. Preserve the brands actually named in the evidence; do not append parent companies, ownership relationships, current-account status, market rankings or rebrand history from memory. Label reasoned inferences as such. A verified brand change needs at most one short, cited sentence unless the user asks for its history.",
17807
17867
  ...first,
@@ -17833,7 +17893,7 @@ ${page.text}`).join(`
17833
17893
  // src/web/index.ts
17834
17894
  var messageFor = (error) => error instanceof Error ? error.message : "Website retrieval failed.";
17835
17895
  var codeFor = (error) => error instanceof WebReadError ? error.code : error instanceof Error && /^(?:AbortError|TimeoutError)$/u.test(error.name) ? "timeout" : "fetch_failed";
17836
- var cleanHtml = (html) => prepareRAGDocument({ text: html, format: "html" }).normalizedText;
17896
+ var cleanHtml = websiteHtmlText;
17837
17897
  var titleOf = (html) => {
17838
17898
  const title = /<title\b[^>]*>([\s\S]*?)<\/title>/iu.exec(html)?.[1];
17839
17899
  return title ? prepareRAGDocument({ text: title, format: "html" }).normalizedText : null;
@@ -18002,5 +18062,5 @@ export {
18002
18062
  validatePublicWebUrl
18003
18063
  };
18004
18064
 
18005
- //# debugId=C770BC61DAD3A78A64756E2164756E21
18065
+ //# debugId=64305FA75E0E709664756E2164756E21
18006
18066
  //# sourceMappingURL=index.js.map