@absolutejs/rag 0.22.12 → 0.22.14

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.
@@ -35,6 +35,16 @@ export type ResearchResult<T = unknown> = {
35
35
  text: string;
36
36
  originalChars: number;
37
37
  }>;
38
+ sourceFailures?: Array<{
39
+ url: string;
40
+ code: string;
41
+ message: string;
42
+ }>;
43
+ coverage?: {
44
+ requested: number;
45
+ supported: number;
46
+ complete: boolean;
47
+ };
38
48
  id: string;
39
49
  status: "reviewed" | "partial" | "empty" | "unavailable";
40
50
  /** Only populated when every primitive field passed evidence review. */
@@ -53,6 +63,12 @@ export type ResearchResult<T = unknown> = {
53
63
  };
54
64
  export type ResearchTask<S extends ResearchSchema = ResearchSchema> = {
55
65
  schema: S;
66
+ /** Count only items whose required fields passed evidence review. JSON pointer to an array. */
67
+ collection?: {
68
+ path: string;
69
+ minimum: number;
70
+ requiredFields: string[];
71
+ };
56
72
  instructions?: string;
57
73
  };
58
74
  export type ResearchInput = {
@@ -3,7 +3,7 @@ import type { WebRedirect } from "./transport";
3
3
  export type { WebEvidence, WebLink, WebImage, WebMedia } from "./evidence";
4
4
  export type { WebRedirect } from "./transport";
5
5
  import { fetchPublicWebResource } from "./transport";
6
- export { fetchPublicWebResource, validatePublicWebUrl, isPublicWebAddress, WebReadError, } from "./transport";
6
+ export { fetchPublicWebResource, validatePublicWebUrl, isPublicWebAddress, WebReadError, isWebReadError, } from "./transport";
7
7
  export type { WebFetchResult, WebFetchOptions } from "./transport";
8
8
  export type WebReadAttempt = {
9
9
  method: "http" | "browser";
@@ -1,7 +1,10 @@
1
+ declare const WEB_READ_ERROR: unique symbol;
1
2
  export declare class WebReadError extends Error {
2
3
  code: string;
4
+ readonly [WEB_READ_ERROR] = true;
3
5
  constructor(code: string, message: string);
4
6
  }
7
+ export declare const isWebReadError: (error: unknown) => error is WebReadError;
5
8
  export declare const isPublicWebAddress: (address: string) => boolean;
6
9
  export type WebRedirect = {
7
10
  from: string;
@@ -27,3 +30,4 @@ export type WebFetchOptions = {
27
30
  export declare const validatePublicWebUrl: (raw: string) => URL;
28
31
  /** Pin the validated DNS answer into the connection, including every redirect. */
29
32
  export declare const fetchPublicWebResource: (raw: string, options?: WebFetchOptions) => Promise<WebFetchResult>;
33
+ export {};
package/dist/web/index.js CHANGED
@@ -111008,15 +111008,18 @@ import {
111008
111008
  import { lookup } from "dns/promises";
111009
111009
  import { isIP } from "net";
111010
111010
  import { brotliDecompressSync, gunzipSync, inflateSync } from "zlib";
111011
+ var WEB_READ_ERROR = Symbol.for("@absolutejs/rag/WebReadError");
111011
111012
 
111012
111013
  class WebReadError extends Error {
111013
111014
  code;
111015
+ [WEB_READ_ERROR] = true;
111014
111016
  constructor(code, message) {
111015
111017
  super(message);
111016
111018
  this.code = code;
111017
111019
  this.name = "WebReadError";
111018
111020
  }
111019
111021
  }
111022
+ var isWebReadError = (error) => error instanceof Error && Reflect.get(error, WEB_READ_ERROR) === true && typeof Reflect.get(error, "code") === "string";
111020
111023
  var isPublicWebAddress = (address) => isPublicNetworkAddress(address);
111021
111024
  var validatePublicWebUrl = (raw) => {
111022
111025
  let url;
@@ -117886,7 +117889,7 @@ var createWebpageReaderClient = (options) => {
117886
117889
  });
117887
117890
  if (result.status === "error") {
117888
117891
  const error = result.error;
117889
- throw new Error(error?.message ?? "Isolated page read failed");
117892
+ throw new WebReadError(error?.code ?? "reader_unavailable", error?.message ?? "Isolated page read failed");
117890
117893
  }
117891
117894
  const documents = result.documents;
117892
117895
  const sources = result.sources;
@@ -117920,7 +117923,7 @@ var createWebpageReaderClient = (options) => {
117920
117923
 
117921
117924
  // src/web/index.ts
117922
117925
  var messageFor = (error) => error instanceof Error ? error.message : "Website retrieval failed.";
117923
- var codeFor = (error) => error instanceof WebReadError ? error.code : error instanceof Error && /^(?:AbortError|TimeoutError)$/u.test(error.name) ? "timeout" : "fetch_failed";
117926
+ var codeFor = (error) => isWebReadError(error) ? error.code : error instanceof Error && /^(?:AbortError|TimeoutError)$/u.test(error.name) ? "timeout" : "fetch_failed";
117924
117927
  var cleanHtml = websiteHtmlText;
117925
117928
  var titleOf = (html) => {
117926
117929
  const title = /<title\b[^>]*>([\s\S]*?)<\/title>/iu.exec(html)?.[1];
@@ -117967,7 +117970,7 @@ var readRAGWebpage = async (options) => {
117967
117970
  response = await (options.fetchResource ?? fetchPublicWebResource)(options.url, { signal, maxBytes: 5000000 });
117968
117971
  } catch (error) {
117969
117972
  attempts.push({ method: "http", status: codeFor(error) });
117970
- if (error instanceof WebReadError && error.code === "blocked_url")
117973
+ if (isWebReadError(error) && error.code === "blocked_url")
117971
117974
  throw error;
117972
117975
  if (!options.render)
117973
117976
  throw error;
@@ -118089,11 +118092,12 @@ export {
118089
118092
  createWebsiteReaderClient,
118090
118093
  fetchPublicWebResource,
118091
118094
  isPublicWebAddress,
118095
+ isWebReadError,
118092
118096
  parseWebsiteServiceResult,
118093
118097
  readRAGWebpage,
118094
118098
  readRAGWebsite,
118095
118099
  validatePublicWebUrl
118096
118100
  };
118097
118101
 
118098
- //# debugId=ED6DDC20D653823F64756E2164756E21
118102
+ //# debugId=1563C3DC46ACBE2864756E2164756E21
118099
118103
  //# sourceMappingURL=index.js.map