@absolutejs/rag 0.22.7 → 0.22.9

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.
@@ -0,0 +1,3 @@
1
+ /** Full sources remain stored; reuse AI's exact-passage retrieval to build only
2
+ * the model-facing view. Search covers the entire document, including its tail. */
3
+ export declare const selectResearchExcerpts: (text: string, budget: number, query: string) => string[];
@@ -28,6 +28,13 @@ export type ResearchField = {
28
28
  };
29
29
  };
30
30
  export type ResearchResult<T = unknown> = {
31
+ /** Complete fetched text retained separately from model-facing excerpts. */
32
+ documents?: Array<{
33
+ sourceId: string;
34
+ url: string;
35
+ text: string;
36
+ originalChars: number;
37
+ }>;
31
38
  id: string;
32
39
  status: "reviewed" | "partial" | "empty" | "unavailable";
33
40
  /** Only populated when every primitive field passed evidence review. */
@@ -17,6 +17,9 @@ export type WebReadResult = {
17
17
  finalUrl: string;
18
18
  title: string | null;
19
19
  text: string;
20
+ /** Complete extracted source, independent of the model-facing preview budget. */
21
+ fullText?: string;
22
+ originalChars?: number;
20
23
  method: "http" | "browser";
21
24
  truncated: boolean;
22
25
  attempts: WebReadAttempt[];
@@ -3,6 +3,7 @@ import { type ReadWebpageOptions, type WebReadResult } from "./index";
3
3
  export declare const readRAGWebsite: (options: ReadWebpageOptions & {
4
4
  maxPages?: number;
5
5
  }) => Promise<{
6
+ fullText: undefined;
6
7
  status: WebReadResult["status"];
7
8
  text: string;
8
9
  truncated: boolean;
@@ -11,6 +12,7 @@ export declare const readRAGWebsite: (options: ReadWebpageOptions & {
11
12
  url: string;
12
13
  finalUrl: string;
13
14
  title: string | null;
15
+ originalChars?: number;
14
16
  method: "http" | "browser";
15
17
  truncated: boolean;
16
18
  attempts: import("./index").WebReadAttempt[];
@@ -49,6 +51,7 @@ export declare const readRAGWebsite: (options: ReadWebpageOptions & {
49
51
  url: string;
50
52
  finalUrl: string;
51
53
  title: string | null;
54
+ originalChars?: number;
52
55
  method: "http" | "browser";
53
56
  attempts: import("./index").WebReadAttempt[];
54
57
  error?: {
@@ -63,6 +66,9 @@ export declare const readRAGWebsite: (options: ReadWebpageOptions & {
63
66
  documents: {
64
67
  sourceId: string;
65
68
  text: string;
69
+ fullText: string;
70
+ originalChars: number;
71
+ sourceTruncated: boolean;
66
72
  truncated: boolean;
67
73
  }[];
68
74
  sources: {
package/dist/web/index.js CHANGED
@@ -117670,7 +117670,7 @@ var readRAGWebsite = async (options) => {
117670
117670
  const page = await readRAGWebpage({
117671
117671
  ...options,
117672
117672
  url: next.url,
117673
- maxChars: Math.min(maxChars, 12000),
117673
+ maxChars,
117674
117674
  signal: AbortSignal.any([signal, AbortSignal.timeout(30000)])
117675
117675
  });
117676
117676
  pages.push(page);
@@ -117726,24 +117726,27 @@ var readRAGWebsite = async (options) => {
117726
117726
  let remainingDocumentChars = maxChars;
117727
117727
  const documents = sources.flatMap((source) => {
117728
117728
  const page = pages.find((item) => item.finalUrl === source.url && item.text);
117729
- if (!page || remainingDocumentChars <= 0)
117729
+ if (!page)
117730
117730
  return [];
117731
117731
  const imageLabels = page.evidence.images.filter((image) => image.label).map((image) => `${image.context ? `${image.context}: ` : ""}${image.label}`);
117732
117732
  const fullText = [
117733
- page.text,
117733
+ page.fullText ?? page.text,
117734
117734
  ...imageLabels.length ? [
117735
117735
  "Image labels supplied by the website (not independently verified customer relationships):",
117736
117736
  ...imageLabels
117737
117737
  ] : []
117738
117738
  ].join(`
117739
117739
  `);
117740
- const text = fullText.slice(0, remainingDocumentChars);
117740
+ const text = fullText.slice(0, Math.max(0, remainingDocumentChars));
117741
117741
  remainingDocumentChars -= text.length;
117742
117742
  return [
117743
117743
  {
117744
117744
  sourceId: source.id,
117745
117745
  text,
117746
- truncated: page.truncated || text.length < fullText.length
117746
+ fullText,
117747
+ originalChars: fullText.length,
117748
+ sourceTruncated: page.status !== "ok" || page.fullText === undefined && page.truncated,
117749
+ truncated: page.fullText === undefined && page.truncated || text.length < fullText.length
117747
117750
  }
117748
117751
  ];
117749
117752
  });
@@ -117762,10 +117765,11 @@ ${page.text}`).join(`
117762
117765
  sources,
117763
117766
  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.",
117764
117767
  ...first,
117768
+ fullText: undefined,
117765
117769
  status: readable.length ? incomplete ? "partial" : "ok" : "error",
117766
117770
  text: evidenceText.slice(0, maxChars),
117767
117771
  truncated: evidenceText.length > maxChars || pages.some((page) => page.truncated),
117768
- pages: pages.map(({ text: _text, ...page }) => page),
117772
+ pages: pages.map(({ text: _text, fullText: _fullText, ...page }) => page),
117769
117773
  captionEvidence,
117770
117774
  coverage: {
117771
117775
  pagesRead: pages.length,
@@ -117776,10 +117780,10 @@ ${page.text}`).join(`
117776
117780
  deadlineReached: signal.aborted,
117777
117781
  exhaustive: false,
117778
117782
  stopReason: signal.aborted ? "deadline" : unvisited.length ? "page_limit" : "links_exhausted",
117779
- incompleteReads: pages.filter((page) => page.status !== "ok" || page.truncated).map((page) => ({
117783
+ incompleteReads: pages.filter((page) => page.status !== "ok" || page.fullText === undefined && page.truncated).map((page) => ({
117780
117784
  url: page.finalUrl,
117781
117785
  status: page.status,
117782
- truncated: page.truncated,
117786
+ truncated: page.fullText === undefined && page.truncated,
117783
117787
  error: page.error
117784
117788
  }))
117785
117789
  },
@@ -117894,12 +117898,15 @@ var createWebpageReaderClient = (options) => {
117894
117898
  if (![evidence.links, evidence.images, evidence.media].every(Array.isArray))
117895
117899
  throw new Error("Invalid page evidence");
117896
117900
  const limit = Math.max(1000, Math.min(input.maxChars ?? 24000, 1e5));
117901
+ const fullText = typeof document2.fullText === "string" ? document2.fullText : document2.text;
117897
117902
  return {
117898
117903
  status: result.status,
117899
117904
  url: input.url,
117900
117905
  finalUrl: result.finalUrl,
117901
117906
  title: typeof result.title === "string" ? result.title : null,
117902
- text: document2.text.slice(0, limit),
117907
+ text: fullText.slice(0, limit),
117908
+ fullText,
117909
+ originalChars: fullText.length,
117903
117910
  method: result.method,
117904
117911
  truncated: result.truncated === true || document2.truncated === true || document2.text.length > limit,
117905
117912
  fetchedAt: result.fetchedAt,
@@ -117942,6 +117949,8 @@ var readRAGWebpage = async (options) => {
117942
117949
  finalUrl,
117943
117950
  title,
117944
117951
  text: text.slice(0, maxChars),
117952
+ fullText: text,
117953
+ originalChars: text.length,
117945
117954
  method,
117946
117955
  truncated: text.length > maxChars,
117947
117956
  attempts,
@@ -118086,5 +118095,5 @@ export {
118086
118095
  validatePublicWebUrl
118087
118096
  };
118088
118097
 
118089
- //# debugId=74A5ADE3508DAED464756E2164756E21
118098
+ //# debugId=ED6DDC20D653823F64756E2164756E21
118090
118099
  //# sourceMappingURL=index.js.map