@absolutejs/rag 0.24.2 → 0.24.4

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.
@@ -16,6 +16,23 @@ export declare const ReviewSchema: import("@sinclair/typebox").TObject<{
16
16
  }>;
17
17
  }>>;
18
18
  }>;
19
+ /** Make the tool contract match this batch rather than inviting a full-draft review. */
20
+ export declare const reviewSchemaForPaths: (paths: string[]) => import("@sinclair/typebox").TObject<{
21
+ fields: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
22
+ path: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<string>[]>;
23
+ reason: import("@sinclair/typebox").TString;
24
+ citations: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
25
+ passageId: import("@sinclair/typebox").TString;
26
+ }>>;
27
+ verdict: import("@sinclair/typebox").TUnion<import("@sinclair/typebox").TLiteral<"unknown" | "supported" | "unsupported" | "conflicting">[]>;
28
+ checks: import("@sinclair/typebox").TObject<{
29
+ answersQuestion: import("@sinclair/typebox").TBoolean;
30
+ correctEntity: import("@sinclair/typebox").TBoolean;
31
+ correctTime: import("@sinclair/typebox").TBoolean;
32
+ preservesScope: import("@sinclair/typebox").TBoolean;
33
+ }>;
34
+ }>>;
35
+ }>;
19
36
  export declare const researchLeaves: (value: unknown, maxFields?: number) => Pick<ResearchField, "value" | "path">[];
20
37
  /** A model review is fallible. Citation validation proves provenance, not truth. */
21
38
  export declare const bindResearchReview: (leaves: ReturnType<typeof researchLeaves>, reviews: {
@@ -123408,6 +123408,16 @@ var ReviewSchema = Type.Object({
123408
123408
  })
123409
123409
  }), { maxItems: 256 })
123410
123410
  });
123411
+ var reviewSchemaForPaths = (paths) => Type.Object({
123412
+ fields: Type.Array(Type.Object({
123413
+ ...ReviewSchema.properties.fields.items.properties,
123414
+ path: Type.Union(paths.map((path) => Type.Literal(path))),
123415
+ reason: Type.String({ maxLength: 180 }),
123416
+ citations: Type.Array(Type.Object({ passageId: Type.String() }), {
123417
+ maxItems: 4
123418
+ })
123419
+ }, { additionalProperties: false }), { minItems: paths.length, maxItems: paths.length })
123420
+ }, { additionalProperties: false });
123411
123421
  var researchLeaves = (value, maxFields = 128) => {
123412
123422
  const fields = [];
123413
123423
  const visit = (item, path, depth) => {
@@ -123971,9 +123981,17 @@ Correct the previous schema-invalid response using the validation diagnostics. T
123971
123981
  if (!continuing)
123972
123982
  result.fields = [];
123973
123983
  await persistReview(pass, continuing ? resumed.nextField : 0, false, data);
123974
- const leaves = researchLeaves(data, Number.MAX_SAFE_INTEGER);
123975
- if (continuing && (resumed.nextField > leaves.length || result.fields.length !== resumed.nextField || result.fields.some((field, index) => field.path !== leaves[index]?.path || field.value !== leaves[index]?.value)))
123976
- throw new Error("Review checkpoint fields do not match draft");
123984
+ let leaves = researchLeaves(data, Number.MAX_SAFE_INTEGER);
123985
+ if (continuing) {
123986
+ const byPath = new Map(leaves.map((field) => [field.path, field]));
123987
+ const completedPaths = new Set(result.fields.map((field) => field.path));
123988
+ if (resumed.nextField > leaves.length || result.fields.length !== resumed.nextField || completedPaths.size !== result.fields.length || result.fields.some((field) => !byPath.has(field.path) || byPath.get(field.path).value !== field.value))
123989
+ throw new Error("Review checkpoint fields do not match draft");
123990
+ leaves = [
123991
+ ...result.fields.map(({ path, value }) => ({ path, value })),
123992
+ ...leaves.filter((field) => !completedPaths.has(field.path))
123993
+ ];
123994
+ }
123977
123995
  if (!leaves.length) {
123978
123996
  result.data = data;
123979
123997
  result.status = result.limitations.length ? "partial" : "empty";
@@ -123992,7 +124010,7 @@ Correct the previous schema-invalid response using the validation diagnostics. T
123992
124010
  await persistReview(pass, offset, true, data);
123993
124011
  let reviewed;
123994
124012
  try {
123995
- reviewed = await generate("review", ReviewSchema, "Independently review EVERY JSON pointer and its value. supported requires exact quotes establishing the entire fact for the correct entity and time. A name mention or publication date is insufficient to establish employment, event date, ownership, or buying intent. Check all sources for actual factual contradictions. Complementary details from different sources are not a conflict; a price from one source and a term from another can jointly support a claim. Use conflicting only when sources make incompatible factual statements, unsupported for contradicted claims, unknown for missing support. Match the requested event period: an August release is not a September event even when published in September. Quoted wording must be verbatim; a paraphrase cannot be placed in quotation marks. Vendor claims about first/best status and performance metrics must remain explicitly attributed in the answer itself, not just in your reason. Null is unknown. Cite only supplied passage IDs; their text will be copied verbatim by the runtime. For each field, explicitly check answersQuestion (directly answers query/schema/instructions, not background or a non-answer), correctEntity, correctTime, and preservesScope. Read surrounding context and headings, not only the matching quote. A benefit/trial condition is not a program-wide rule; customer conditions are not partner conditions; eligible is not approved or automatic. Preserve exceptions, qualifiers and marketing attribution. Every check must pass for supported. A leader\u2019s education or career history does not answer who currently leads a team. Keep each reason under 25 words. Cite only the minimum passages needed to establish the entire field, at most four. Do not invent passage IDs. Read adjacent passages for conditions and exceptions, even when citing only one. Return each pointer once. Never treat this review as independent real-world verification.", {
124013
+ reviewed = await generate("review", reviewSchemaForPaths(batch.map((field) => field.path)), "Review ONLY the JSON pointers supplied in fields for this batch. The full answer schema is context, not a request to review other fields or reconstruct the extraction. Return exactly one verdict per supplied pointer and nothing else. supported requires exact quotes establishing the entire fact for the correct entity and time. A name mention or publication date is insufficient to establish employment, event date, ownership, or buying intent. Check all sources for actual factual contradictions. Complementary details from different sources are not a conflict; a price from one source and a term from another can jointly support a claim. Use conflicting only when sources make incompatible factual statements, unsupported for contradicted claims, unknown for missing support. Match the requested event period: an August release is not a September event even when published in September. Quoted wording must be verbatim; a paraphrase cannot be placed in quotation marks. Vendor claims about first/best status and performance metrics must remain explicitly attributed in the answer itself, not just in your reason. Null is unknown. Cite only supplied passage IDs; their text will be copied verbatim by the runtime. For each field, explicitly check answersQuestion (directly answers query/schema/instructions, not background or a non-answer), correctEntity, correctTime, and preservesScope. Read surrounding context and headings, not only the matching quote. A benefit/trial condition is not a program-wide rule; customer conditions are not partner conditions; eligible is not approved or automatic. Preserve exceptions, qualifiers and marketing attribution. Every check must pass for supported. A leader\u2019s education or career history does not answer who currently leads a team. Keep each reason under 25 words. Cite only the minimum passages needed to establish the entire field, at most four. Do not invent passage IDs. Read adjacent passages for conditions and exceptions, even when citing only one. Return each pointer once. Never treat this review as independent real-world verification.", {
123996
124014
  query: input.query,
123997
124015
  asOf: result.generatedAt,
123998
124016
  instructions: task.instructions,
@@ -124203,5 +124221,5 @@ export {
124203
124221
  webIndexPostgresSchemaSql
124204
124222
  };
124205
124223
 
124206
- //# debugId=A5E570BDB36F03C864756E2164756E21
124224
+ //# debugId=C3BB7096412E826B64756E2164756E21
124207
124225
  //# sourceMappingURL=index.js.map