@claritylabs/cl-sdk 0.14.2 → 0.15.0

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/dist/index.js CHANGED
@@ -2476,10 +2476,13 @@ function chunkDocument(doc) {
2476
2476
  };
2477
2477
  const chunks = [];
2478
2478
  const docId = doc.id;
2479
+ const policyTypesStr = doc.policyTypes?.length ? doc.policyTypes.join(",") : void 0;
2479
2480
  function stringMetadata(entries) {
2480
- return Object.fromEntries(
2481
+ const base = Object.fromEntries(
2481
2482
  Object.entries(entries).filter(([, value]) => value !== void 0 && value !== null && String(value).length > 0).map(([key, value]) => [key, String(value)])
2482
2483
  );
2484
+ if (policyTypesStr) base.policyTypes = policyTypesStr;
2485
+ return base;
2483
2486
  }
2484
2487
  chunks.push({
2485
2488
  id: `${docId}:carrier_info:0`,
@@ -2840,13 +2843,16 @@ ${exc.content}`.trim(),
2840
2843
  }
2841
2844
  }
2842
2845
  if (declLines.length > 0) {
2846
+ const declMeta = { documentType: doc.type };
2847
+ if (typeof decl.formType === "string") declMeta.formType = decl.formType;
2848
+ if (typeof decl.line === "string") declMeta.declarationLine = decl.line;
2843
2849
  chunks.push({
2844
2850
  id: `${docId}:declaration:0`,
2845
2851
  documentId: docId,
2846
2852
  type: "declaration",
2847
2853
  text: `Declarations
2848
2854
  ${declLines.join("\n")}`,
2849
- metadata: stringMetadata({ documentType: doc.type })
2855
+ metadata: stringMetadata(declMeta)
2850
2856
  });
2851
2857
  }
2852
2858
  }
@@ -4267,11 +4273,30 @@ COMMERCIAL LINES \u2014 match these values:
4267
4273
  - "property" \u2014 standalone property
4268
4274
 
4269
4275
  PERSONAL LINES \u2014 match these values:
4270
- - "homeowners_ho3" \u2014 HO-3, special form homeowners
4271
- - "homeowners_ho5" \u2014 HO-5, comprehensive form homeowners
4272
- - "renters_ho4" \u2014 HO-4, renters insurance
4273
- - "condo_ho6" \u2014 HO-6, condo unit-owners
4274
- - "dwelling_fire" \u2014 DP-1, DP-3, dwelling fire
4276
+
4277
+ HOMEOWNER FORM CLASSIFICATION \u2014 pay close attention to these distinctions:
4278
+ - "homeowners_ho3" \u2014 HO-3 Special Form. Standard homeowner policy for OWNER-OCCUPIED dwellings.
4279
+ Key indicators: Coverage A (Dwelling) present, open-peril dwelling coverage, named-peril personal property,
4280
+ references to "special form", "HO 00 03", or "HO-3". The insured OWNS the home.
4281
+ - "homeowners_ho5" \u2014 HO-5 Comprehensive Form. Premium homeowner policy for OWNER-OCCUPIED dwellings.
4282
+ Key indicators: Coverage A (Dwelling) present, BOTH dwelling AND personal property on open-peril basis,
4283
+ references to "comprehensive form", "HO 00 05", or "HO-5". Higher coverage than HO-3.
4284
+ - "renters_ho4" \u2014 HO-4 Contents Broad Form. Renters/tenants insurance \u2014 NO dwelling coverage.
4285
+ Key indicators: NO Coverage A (Dwelling), only Coverage C (Personal Property) and Coverage E/F (Liability/Medical),
4286
+ references to "contents broad form", "HO 00 04", "HO-4", "renters", "tenants". The insured RENTS, does not own.
4287
+ - "condo_ho6" \u2014 HO-6 Unit-Owners Form. Condo/co-op unit-owner insurance.
4288
+ Key indicators: Coverage A applies to interior walls/improvements only (not full structure),
4289
+ references to "unit-owners form", "HO 00 06", "HO-6", "condominium", "co-op unit". The building's
4290
+ master policy covers the structure; HO-6 covers the unit interior, personal property, and liability.
4291
+
4292
+ DISAMBIGUATION RULES for homeowner forms:
4293
+ 1. If the document has Coverage A (Dwelling) with full structure coverage \u2192 HO-3 or HO-5 (check if open-peril on personal property \u2192 HO-5, named-peril \u2192 HO-3)
4294
+ 2. If NO Coverage A / no dwelling coverage and the insured is a renter/tenant \u2192 renters_ho4
4295
+ 3. If Coverage A covers only unit interior/improvements and mentions condo/co-op \u2192 condo_ho6
4296
+ 4. Look for the actual form number (HO 00 03, HO 00 04, HO 00 05, HO 00 06) on the declarations page \u2014 this is the most reliable indicator
4297
+ 5. Do NOT default to homeowners_ho3 when uncertain \u2014 check for the distinguishing signals above
4298
+
4299
+ - "dwelling_fire" \u2014 DP-1, DP-3, dwelling fire (non-owner-occupied or investment property)
4275
4300
  - "mobile_home" \u2014 mobile home, manufactured home
4276
4301
  - "personal_auto" \u2014 personal auto, PAP
4277
4302
  - "personal_umbrella" \u2014 personal umbrella
@@ -4282,7 +4307,10 @@ PERSONAL LINES \u2014 match these values:
4282
4307
  - "watercraft" \u2014 watercraft, boat
4283
4308
  - "recreational_vehicle" \u2014 RV, recreational vehicle, ATV
4284
4309
  - "farm_ranch" \u2014 farm, ranch
4285
- - "pet" \u2014 pet insurance
4310
+ - "pet" \u2014 standalone pet insurance policy. Key indicators: named pet, species/breed, accident/illness coverage,
4311
+ wellness plans, per-incident or annual limits for veterinary costs. Do NOT confuse with pet liability endorsements
4312
+ on a homeowners policy \u2014 those are still homeowner policies (ho3/ho4/ho5/ho6), not "pet".
4313
+ Only classify as "pet" when the ENTIRE policy is dedicated to pet health/accident coverage.
4286
4314
  - "travel" \u2014 travel insurance
4287
4315
  - "identity_theft" \u2014 identity theft
4288
4316
  - "title" \u2014 title insurance
@@ -5138,6 +5166,338 @@ function getExtractor(name) {
5138
5166
  return EXTRACTORS[name];
5139
5167
  }
5140
5168
 
5169
+ // src/extraction/resolve-referential.ts
5170
+ var import_zod35 = require("zod");
5171
+
5172
+ // src/prompts/extractors/referential-lookup.ts
5173
+ var import_zod34 = require("zod");
5174
+ var ReferentialLookupSchema = import_zod34.z.object({
5175
+ resolvedCoverages: import_zod34.z.array(
5176
+ import_zod34.z.object({
5177
+ coverageName: import_zod34.z.string().describe("The coverage name that was referenced"),
5178
+ resolvedLimit: import_zod34.z.string().optional().describe("The concrete limit value found, if any"),
5179
+ resolvedLimitValueType: CoverageValueTypeSchema.optional(),
5180
+ resolvedDeductible: import_zod34.z.string().optional().describe("The concrete deductible value found, if any"),
5181
+ resolvedDeductibleValueType: CoverageValueTypeSchema.optional(),
5182
+ pageNumber: import_zod34.z.number().optional().describe("Page where the resolved value was found"),
5183
+ originalContent: import_zod34.z.string().optional().describe("Verbatim source text for the resolved value"),
5184
+ confidence: import_zod34.z.enum(["high", "medium", "low"]).describe("Confidence in the resolution")
5185
+ })
5186
+ )
5187
+ });
5188
+ function buildReferentialLookupPrompt(coverages) {
5189
+ const coverageList = coverages.map((c, i) => {
5190
+ const parts = [` ${i + 1}. Coverage: "${c.name}" \u2014 Limit: "${c.limit}"`];
5191
+ if (c.deductible) {
5192
+ parts.push(` Deductible: "${c.deductible}"`);
5193
+ }
5194
+ if (c.sectionRef) {
5195
+ parts.push(` Referenced section: "${c.sectionRef}"`);
5196
+ }
5197
+ return parts.join("\n");
5198
+ }).join("\n");
5199
+ return `You are an expert insurance document analyst. You are looking at a specific section of an insurance document to resolve referential coverage limits.
5200
+
5201
+ The following coverages had referential limits or deductibles (e.g. "As stated in Policy", "As stated in Section 4 of Policy", "See Declarations") instead of concrete values:
5202
+
5203
+ ${coverageList}
5204
+
5205
+ Your task:
5206
+ - Find the concrete/actual limit and deductible values for each coverage listed above.
5207
+ - Search the declarations page, coverage schedules, and any referenced sections for the real numeric or defined values.
5208
+ - Only return values you can actually find in the document \u2014 do not guess or infer values that are not explicitly stated.
5209
+ - For each resolved coverage, include:
5210
+ - pageNumber: the page where the resolved value appears
5211
+ - originalContent: the verbatim text snippet containing the resolved value
5212
+ - confidence: "high" if the value is clearly and unambiguously stated, "medium" if it requires interpretation, "low" if uncertain
5213
+ - If a coverage cannot be resolved (no concrete value found), still include it with confidence "low" and omit the resolved fields.
5214
+ - Classify resolvedLimitValueType and resolvedDeductibleValueType as numeric, included, not_included, as_stated, waiting_period, referential, or other.
5215
+
5216
+ Return JSON only.`;
5217
+ }
5218
+
5219
+ // src/extraction/resolve-referential.ts
5220
+ function looksReferential(value) {
5221
+ if (typeof value !== "string") return false;
5222
+ const normalized = value.toLowerCase();
5223
+ return normalized.includes("shown in the declarations") || normalized.includes("shown in declarations") || normalized.includes("shown in the schedule") || normalized.includes("as stated") || normalized.includes("if applicable");
5224
+ }
5225
+ function parseReferenceTarget(text) {
5226
+ if (typeof text !== "string") return void 0;
5227
+ const normalized = text.trim();
5228
+ if (!normalized) return void 0;
5229
+ const sectionMatch = normalized.match(/\b(Section\s+\d+[A-Za-z]?)/i);
5230
+ if (sectionMatch) return sectionMatch[1];
5231
+ if (/declarations/i.test(normalized)) return "Declarations";
5232
+ const scheduleMatch = normalized.match(/\b(Schedule(?:\s+of\s+[A-Za-z ]+)?)/i);
5233
+ if (scheduleMatch) return scheduleMatch[1].trim();
5234
+ const asStatedMatch = normalized.match(/(?:as\s+stated\s+in|see|shown\s+in(?:\s+the)?)\s+(.+)/i);
5235
+ if (asStatedMatch) {
5236
+ let target = asStatedMatch[1].trim().replace(/\s+of\s+the\s+policy$/i, "").trim();
5237
+ target = target.replace(/\.+$/, "").trim();
5238
+ if (target) return target;
5239
+ }
5240
+ if (/if applicable/i.test(normalized)) return void 0;
5241
+ return void 0;
5242
+ }
5243
+ var PageLocationSchema = import_zod35.z.object({
5244
+ startPage: import_zod35.z.number(),
5245
+ endPage: import_zod35.z.number()
5246
+ });
5247
+ async function findReferencedPages(params) {
5248
+ const {
5249
+ referenceTarget,
5250
+ sections,
5251
+ formInventory,
5252
+ pdfBase64,
5253
+ pageCount,
5254
+ generateObject,
5255
+ providerOptions,
5256
+ log
5257
+ } = params;
5258
+ const targetLower = referenceTarget.toLowerCase();
5259
+ for (const section of sections) {
5260
+ if (section.title && section.pageStart != null && section.title.toLowerCase().includes(targetLower)) {
5261
+ return {
5262
+ startPage: section.pageStart,
5263
+ endPage: section.pageEnd ?? section.pageStart
5264
+ };
5265
+ }
5266
+ }
5267
+ for (const form of formInventory) {
5268
+ const titleMatch = form.title && form.title.toLowerCase().includes(targetLower);
5269
+ const typeMatch = form.formType && form.formType.toLowerCase().includes(targetLower);
5270
+ if ((titleMatch || typeMatch) && form.pageStart != null) {
5271
+ return {
5272
+ startPage: form.pageStart,
5273
+ endPage: form.pageEnd ?? form.pageStart
5274
+ };
5275
+ }
5276
+ }
5277
+ try {
5278
+ const result = await safeGenerateObject(
5279
+ generateObject,
5280
+ {
5281
+ prompt: `You are analyzing an insurance document (${pageCount} pages total).
5282
+
5283
+ Find the pages that contain the section or area referenced as "${referenceTarget}".
5284
+
5285
+ Return the page range (1-indexed) where this section is located. If the section spans a single page, startPage and endPage should be the same.
5286
+
5287
+ If you cannot find the section, return startPage: 0 and endPage: 0.
5288
+
5289
+ Return JSON only.`,
5290
+ schema: PageLocationSchema,
5291
+ maxTokens: 256,
5292
+ providerOptions: { ...providerOptions, pdfBase64 }
5293
+ },
5294
+ {
5295
+ fallback: { startPage: 0, endPage: 0 },
5296
+ maxRetries: 1,
5297
+ log,
5298
+ onError: (err, attempt) => log?.(
5299
+ `Page location attempt ${attempt + 1} failed for "${referenceTarget}": ${err instanceof Error ? err.message : String(err)}`
5300
+ )
5301
+ }
5302
+ );
5303
+ if (result.object.startPage > 0 && result.object.endPage > 0) {
5304
+ return {
5305
+ startPage: result.object.startPage,
5306
+ endPage: result.object.endPage
5307
+ };
5308
+ }
5309
+ } catch (error) {
5310
+ await log?.(
5311
+ `Failed to locate pages for "${referenceTarget}": ${error instanceof Error ? error.message : String(error)}`
5312
+ );
5313
+ }
5314
+ return void 0;
5315
+ }
5316
+ async function resolveReferentialCoverages(params) {
5317
+ const {
5318
+ memory,
5319
+ pdfBase64,
5320
+ pageCount,
5321
+ generateObject,
5322
+ convertPdfToImages,
5323
+ concurrency = 2,
5324
+ providerOptions,
5325
+ log,
5326
+ onProgress
5327
+ } = params;
5328
+ const limit = pLimit(concurrency);
5329
+ let totalUsage = { inputTokens: 0, outputTokens: 0 };
5330
+ function trackUsage(usage) {
5331
+ if (usage) {
5332
+ totalUsage.inputTokens += usage.inputTokens;
5333
+ totalUsage.outputTokens += usage.outputTokens;
5334
+ }
5335
+ }
5336
+ const coverageData = memory.get("coverage_limits");
5337
+ const coverages = coverageData?.coverages ?? [];
5338
+ const referentialCoverages = coverages.filter((cov) => {
5339
+ const limitType = cov.limitValueType;
5340
+ const deductibleType = cov.deductibleValueType;
5341
+ return limitType === "referential" || limitType === "as_stated" || deductibleType === "referential" || deductibleType === "as_stated" || looksReferential(cov.limit) || looksReferential(cov.deductible);
5342
+ });
5343
+ const attempts = referentialCoverages.length;
5344
+ if (attempts === 0) {
5345
+ return {
5346
+ resolved: 0,
5347
+ unresolved: 0,
5348
+ attempts: 0,
5349
+ usage: totalUsage,
5350
+ details: []
5351
+ };
5352
+ }
5353
+ onProgress?.(
5354
+ `Found ${attempts} referential coverage(s) to resolve...`
5355
+ );
5356
+ const targetGroups = /* @__PURE__ */ new Map();
5357
+ for (let i = 0; i < referentialCoverages.length; i++) {
5358
+ const cov = referentialCoverages[i];
5359
+ const refString = (looksReferential(cov.limit) ? cov.limit : void 0) ?? (looksReferential(cov.deductible) ? cov.deductible : void 0) ?? cov.limit ?? "";
5360
+ const target = parseReferenceTarget(refString) ?? "unknown";
5361
+ const group = targetGroups.get(target) ?? [];
5362
+ group.push({ coverage: cov, index: i });
5363
+ targetGroups.set(target, group);
5364
+ }
5365
+ const sectionsData = memory.get("sections");
5366
+ const sections = sectionsData?.sections ?? [];
5367
+ const formInventoryData = memory.get("form_inventory");
5368
+ const formInventory = formInventoryData?.forms ?? [];
5369
+ const details = [];
5370
+ let resolved = 0;
5371
+ let unresolved = 0;
5372
+ const targetEntries = Array.from(targetGroups.entries());
5373
+ await Promise.all(
5374
+ targetEntries.map(
5375
+ ([target, group]) => limit(async () => {
5376
+ const pageRange = await findReferencedPages({
5377
+ referenceTarget: target,
5378
+ sections,
5379
+ formInventory,
5380
+ pdfBase64,
5381
+ pageCount,
5382
+ generateObject,
5383
+ providerOptions,
5384
+ log
5385
+ });
5386
+ if (!pageRange) {
5387
+ await log?.(
5388
+ `Could not locate pages for reference target "${target}"`
5389
+ );
5390
+ for (const { coverage } of group) {
5391
+ details.push({
5392
+ coverageName: String(coverage.name ?? "unknown"),
5393
+ referenceTarget: target === "unknown" ? void 0 : target,
5394
+ status: "pages_not_found"
5395
+ });
5396
+ unresolved++;
5397
+ }
5398
+ return;
5399
+ }
5400
+ onProgress?.(
5401
+ `Resolving "${target}" from pages ${pageRange.startPage}-${pageRange.endPage}...`
5402
+ );
5403
+ const promptCoverages = group.map(({ coverage }) => ({
5404
+ name: String(coverage.name ?? "unknown"),
5405
+ limit: String(coverage.limit ?? ""),
5406
+ deductible: coverage.deductible ? String(coverage.deductible) : void 0,
5407
+ sectionRef: coverage.sectionRef ? String(coverage.sectionRef) : void 0
5408
+ }));
5409
+ try {
5410
+ const result = await runExtractor({
5411
+ name: "referential_lookup",
5412
+ prompt: buildReferentialLookupPrompt(promptCoverages),
5413
+ schema: ReferentialLookupSchema,
5414
+ pdfBase64,
5415
+ startPage: pageRange.startPage,
5416
+ endPage: pageRange.endPage,
5417
+ generateObject,
5418
+ convertPdfToImages,
5419
+ maxTokens: 4096,
5420
+ providerOptions
5421
+ });
5422
+ trackUsage(result.usage);
5423
+ const resolvedMap = /* @__PURE__ */ new Map();
5424
+ for (const rc of result.data.resolvedCoverages) {
5425
+ resolvedMap.set(rc.coverageName.toLowerCase(), rc);
5426
+ }
5427
+ for (const { coverage } of group) {
5428
+ const covName = String(coverage.name ?? "unknown");
5429
+ const rc = resolvedMap.get(covName.toLowerCase());
5430
+ if (!rc) {
5431
+ details.push({
5432
+ coverageName: covName,
5433
+ referenceTarget: target === "unknown" ? void 0 : target,
5434
+ status: "unresolved"
5435
+ });
5436
+ unresolved++;
5437
+ continue;
5438
+ }
5439
+ const limitResolved = rc.resolvedLimit && rc.resolvedLimitValueType !== "referential" && rc.resolvedLimitValueType !== "as_stated" && !looksReferential(rc.resolvedLimit);
5440
+ const deductibleResolved = rc.resolvedDeductible && rc.resolvedDeductibleValueType !== "referential" && rc.resolvedDeductibleValueType !== "as_stated" && !looksReferential(rc.resolvedDeductible);
5441
+ if (limitResolved || deductibleResolved) {
5442
+ if (limitResolved) {
5443
+ coverage.limit = rc.resolvedLimit;
5444
+ coverage.limitValueType = rc.resolvedLimitValueType ?? "numeric";
5445
+ }
5446
+ if (deductibleResolved) {
5447
+ coverage.deductible = rc.resolvedDeductible;
5448
+ coverage.deductibleValueType = rc.resolvedDeductibleValueType ?? "numeric";
5449
+ }
5450
+ if (rc.pageNumber != null) {
5451
+ coverage.resolvedFromPage = rc.pageNumber;
5452
+ }
5453
+ if (rc.originalContent) {
5454
+ coverage.resolvedOriginalContent = rc.originalContent;
5455
+ }
5456
+ details.push({
5457
+ coverageName: covName,
5458
+ referenceTarget: target === "unknown" ? void 0 : target,
5459
+ resolvedLimit: limitResolved ? rc.resolvedLimit : void 0,
5460
+ resolvedDeductible: deductibleResolved ? rc.resolvedDeductible : void 0,
5461
+ status: "resolved"
5462
+ });
5463
+ resolved++;
5464
+ } else {
5465
+ details.push({
5466
+ coverageName: covName,
5467
+ referenceTarget: target === "unknown" ? void 0 : target,
5468
+ status: "unresolved"
5469
+ });
5470
+ unresolved++;
5471
+ }
5472
+ }
5473
+ } catch (error) {
5474
+ await log?.(
5475
+ `Referential lookup extraction failed for target "${target}": ${error instanceof Error ? error.message : String(error)}`
5476
+ );
5477
+ for (const { coverage } of group) {
5478
+ details.push({
5479
+ coverageName: String(coverage.name ?? "unknown"),
5480
+ referenceTarget: target === "unknown" ? void 0 : target,
5481
+ status: "unresolved"
5482
+ });
5483
+ unresolved++;
5484
+ }
5485
+ }
5486
+ })
5487
+ )
5488
+ );
5489
+ onProgress?.(
5490
+ `Referential resolution complete: ${resolved} resolved, ${unresolved} unresolved out of ${attempts} attempts.`
5491
+ );
5492
+ return {
5493
+ resolved,
5494
+ unresolved,
5495
+ attempts,
5496
+ usage: totalUsage,
5497
+ details
5498
+ };
5499
+ }
5500
+
5141
5501
  // src/core/quality.ts
5142
5502
  function evaluateQualityGate(params) {
5143
5503
  const { issues, hasRoundWarnings = false } = params;
@@ -5174,7 +5534,7 @@ function addFormEntry(inventory, formNumber, source, extra) {
5174
5534
  sources: [source]
5175
5535
  });
5176
5536
  }
5177
- function looksReferential(value) {
5537
+ function looksReferential2(value) {
5178
5538
  if (typeof value !== "string") return false;
5179
5539
  const normalized = value.toLowerCase();
5180
5540
  return normalized.includes("shown in the declarations") || normalized.includes("shown in declarations") || normalized.includes("shown in the schedule") || normalized.includes("as stated") || normalized.includes("if applicable");
@@ -5298,7 +5658,7 @@ function buildExtractionReviewReport(params) {
5298
5658
  itemName: typeof coverage.name === "string" ? coverage.name : void 0
5299
5659
  });
5300
5660
  }
5301
- if (looksReferential(coverage.limit) || looksReferential(coverage.deductible)) {
5661
+ if (looksReferential2(coverage.limit) || looksReferential2(coverage.deductible)) {
5302
5662
  deterministicIssues.push({
5303
5663
  code: "coverage_referential_value",
5304
5664
  severity: "warning",
@@ -5420,7 +5780,8 @@ function buildExtractionReviewReport(params) {
5420
5780
  }));
5421
5781
  const artifacts = [
5422
5782
  { kind: "form_inventory", label: "Form Inventory", itemCount: formInventory.length },
5423
- { kind: "page_map", label: "Page Map", itemCount: params.pageAssignments.length }
5783
+ { kind: "page_map", label: "Page Map", itemCount: params.pageAssignments.length },
5784
+ { kind: "referential_resolution", label: "Referential Resolution", itemCount: coverages.filter((c) => c.limitValueType === "referential" || c.limitValueType === "as_stated" || c.deductibleValueType === "referential" || c.deductibleValueType === "as_stated").length }
5424
5785
  ];
5425
5786
  const qualityGateStatus = evaluateQualityGate({
5426
5787
  issues: deterministicIssues,
@@ -5907,6 +6268,37 @@ function createExtractor(config) {
5907
6268
  memory: Object.fromEntries(memory)
5908
6269
  });
5909
6270
  }
6271
+ if (!pipelineCtx.isPhaseComplete("resolve_referential")) {
6272
+ onProgress?.("Resolving referential coverage limits...");
6273
+ try {
6274
+ const resolution = await resolveReferentialCoverages({
6275
+ memory,
6276
+ pdfBase64,
6277
+ pageCount,
6278
+ generateObject,
6279
+ convertPdfToImages,
6280
+ concurrency,
6281
+ providerOptions,
6282
+ log,
6283
+ onProgress
6284
+ });
6285
+ trackUsage(resolution.usage);
6286
+ if (resolution.attempts > 0) {
6287
+ await log?.(`Referential resolution: ${resolution.resolved}/${resolution.attempts} resolved, ${resolution.unresolved} unresolved`);
6288
+ }
6289
+ } catch (error) {
6290
+ await log?.(`Referential resolution failed, continuing: ${error instanceof Error ? error.message : String(error)}`);
6291
+ }
6292
+ await pipelineCtx.save("resolve_referential", {
6293
+ id,
6294
+ pageCount,
6295
+ classifyResult,
6296
+ formInventory,
6297
+ pageAssignments,
6298
+ plan,
6299
+ memory: Object.fromEntries(memory)
6300
+ });
6301
+ }
5910
6302
  let reviewRounds = resumed?.reviewReport?.reviewRoundRecords ?? [];
5911
6303
  let reviewReport = resumed?.reviewReport;
5912
6304
  if (!pipelineCtx.isPhaseComplete("review")) {
@@ -6282,8 +6674,8 @@ Respond with JSON only:
6282
6674
  }`;
6283
6675
 
6284
6676
  // src/schemas/application.ts
6285
- var import_zod34 = require("zod");
6286
- var FieldTypeSchema = import_zod34.z.enum([
6677
+ var import_zod36 = require("zod");
6678
+ var FieldTypeSchema = import_zod36.z.enum([
6287
6679
  "text",
6288
6680
  "numeric",
6289
6681
  "currency",
@@ -6292,131 +6684,131 @@ var FieldTypeSchema = import_zod34.z.enum([
6292
6684
  "table",
6293
6685
  "declaration"
6294
6686
  ]);
6295
- var ApplicationFieldSchema = import_zod34.z.object({
6296
- id: import_zod34.z.string(),
6297
- label: import_zod34.z.string(),
6298
- section: import_zod34.z.string(),
6687
+ var ApplicationFieldSchema = import_zod36.z.object({
6688
+ id: import_zod36.z.string(),
6689
+ label: import_zod36.z.string(),
6690
+ section: import_zod36.z.string(),
6299
6691
  fieldType: FieldTypeSchema,
6300
- required: import_zod34.z.boolean(),
6301
- options: import_zod34.z.array(import_zod34.z.string()).optional(),
6302
- columns: import_zod34.z.array(import_zod34.z.string()).optional(),
6303
- requiresExplanationIfYes: import_zod34.z.boolean().optional(),
6304
- condition: import_zod34.z.object({
6305
- dependsOn: import_zod34.z.string(),
6306
- whenValue: import_zod34.z.string()
6692
+ required: import_zod36.z.boolean(),
6693
+ options: import_zod36.z.array(import_zod36.z.string()).optional(),
6694
+ columns: import_zod36.z.array(import_zod36.z.string()).optional(),
6695
+ requiresExplanationIfYes: import_zod36.z.boolean().optional(),
6696
+ condition: import_zod36.z.object({
6697
+ dependsOn: import_zod36.z.string(),
6698
+ whenValue: import_zod36.z.string()
6307
6699
  }).optional(),
6308
- value: import_zod34.z.string().optional(),
6309
- source: import_zod34.z.string().optional().describe("Where the value came from: auto-fill, user, lookup"),
6310
- confidence: import_zod34.z.enum(["confirmed", "high", "medium", "low"]).optional()
6700
+ value: import_zod36.z.string().optional(),
6701
+ source: import_zod36.z.string().optional().describe("Where the value came from: auto-fill, user, lookup"),
6702
+ confidence: import_zod36.z.enum(["confirmed", "high", "medium", "low"]).optional()
6311
6703
  });
6312
- var ApplicationClassifyResultSchema = import_zod34.z.object({
6313
- isApplication: import_zod34.z.boolean(),
6314
- confidence: import_zod34.z.number().min(0).max(1),
6315
- applicationType: import_zod34.z.string().nullable()
6704
+ var ApplicationClassifyResultSchema = import_zod36.z.object({
6705
+ isApplication: import_zod36.z.boolean(),
6706
+ confidence: import_zod36.z.number().min(0).max(1),
6707
+ applicationType: import_zod36.z.string().nullable()
6316
6708
  });
6317
- var FieldExtractionResultSchema = import_zod34.z.object({
6318
- fields: import_zod34.z.array(ApplicationFieldSchema)
6709
+ var FieldExtractionResultSchema = import_zod36.z.object({
6710
+ fields: import_zod36.z.array(ApplicationFieldSchema)
6319
6711
  });
6320
- var AutoFillMatchSchema = import_zod34.z.object({
6321
- fieldId: import_zod34.z.string(),
6322
- value: import_zod34.z.string(),
6323
- confidence: import_zod34.z.enum(["confirmed"]),
6324
- contextKey: import_zod34.z.string()
6712
+ var AutoFillMatchSchema = import_zod36.z.object({
6713
+ fieldId: import_zod36.z.string(),
6714
+ value: import_zod36.z.string(),
6715
+ confidence: import_zod36.z.enum(["confirmed"]),
6716
+ contextKey: import_zod36.z.string()
6325
6717
  });
6326
- var AutoFillResultSchema = import_zod34.z.object({
6327
- matches: import_zod34.z.array(AutoFillMatchSchema)
6718
+ var AutoFillResultSchema = import_zod36.z.object({
6719
+ matches: import_zod36.z.array(AutoFillMatchSchema)
6328
6720
  });
6329
- var QuestionBatchResultSchema = import_zod34.z.object({
6330
- batches: import_zod34.z.array(import_zod34.z.array(import_zod34.z.string()).describe("Array of field IDs in this batch"))
6721
+ var QuestionBatchResultSchema = import_zod36.z.object({
6722
+ batches: import_zod36.z.array(import_zod36.z.array(import_zod36.z.string()).describe("Array of field IDs in this batch"))
6331
6723
  });
6332
- var LookupRequestSchema = import_zod34.z.object({
6333
- type: import_zod34.z.string().describe("Type of lookup: 'records', 'website', 'policy'"),
6334
- description: import_zod34.z.string(),
6335
- url: import_zod34.z.string().optional(),
6336
- targetFieldIds: import_zod34.z.array(import_zod34.z.string())
6724
+ var LookupRequestSchema = import_zod36.z.object({
6725
+ type: import_zod36.z.string().describe("Type of lookup: 'records', 'website', 'policy'"),
6726
+ description: import_zod36.z.string(),
6727
+ url: import_zod36.z.string().optional(),
6728
+ targetFieldIds: import_zod36.z.array(import_zod36.z.string())
6337
6729
  });
6338
- var ReplyIntentSchema = import_zod34.z.object({
6339
- primaryIntent: import_zod34.z.enum(["answers_only", "question", "lookup_request", "mixed"]),
6340
- hasAnswers: import_zod34.z.boolean(),
6341
- questionText: import_zod34.z.string().optional(),
6342
- questionFieldIds: import_zod34.z.array(import_zod34.z.string()).optional(),
6343
- lookupRequests: import_zod34.z.array(LookupRequestSchema).optional()
6730
+ var ReplyIntentSchema = import_zod36.z.object({
6731
+ primaryIntent: import_zod36.z.enum(["answers_only", "question", "lookup_request", "mixed"]),
6732
+ hasAnswers: import_zod36.z.boolean(),
6733
+ questionText: import_zod36.z.string().optional(),
6734
+ questionFieldIds: import_zod36.z.array(import_zod36.z.string()).optional(),
6735
+ lookupRequests: import_zod36.z.array(LookupRequestSchema).optional()
6344
6736
  });
6345
- var ParsedAnswerSchema = import_zod34.z.object({
6346
- fieldId: import_zod34.z.string(),
6347
- value: import_zod34.z.string(),
6348
- explanation: import_zod34.z.string().optional()
6737
+ var ParsedAnswerSchema = import_zod36.z.object({
6738
+ fieldId: import_zod36.z.string(),
6739
+ value: import_zod36.z.string(),
6740
+ explanation: import_zod36.z.string().optional()
6349
6741
  });
6350
- var AnswerParsingResultSchema = import_zod34.z.object({
6351
- answers: import_zod34.z.array(ParsedAnswerSchema),
6352
- unanswered: import_zod34.z.array(import_zod34.z.string()).describe("Field IDs that were not answered")
6742
+ var AnswerParsingResultSchema = import_zod36.z.object({
6743
+ answers: import_zod36.z.array(ParsedAnswerSchema),
6744
+ unanswered: import_zod36.z.array(import_zod36.z.string()).describe("Field IDs that were not answered")
6353
6745
  });
6354
- var LookupFillSchema = import_zod34.z.object({
6355
- fieldId: import_zod34.z.string(),
6356
- value: import_zod34.z.string(),
6357
- source: import_zod34.z.string().describe("Specific citable reference, e.g. 'GL Policy #POL-12345 (Hartford)'")
6746
+ var LookupFillSchema = import_zod36.z.object({
6747
+ fieldId: import_zod36.z.string(),
6748
+ value: import_zod36.z.string(),
6749
+ source: import_zod36.z.string().describe("Specific citable reference, e.g. 'GL Policy #POL-12345 (Hartford)'")
6358
6750
  });
6359
- var LookupFillResultSchema = import_zod34.z.object({
6360
- fills: import_zod34.z.array(LookupFillSchema),
6361
- unfillable: import_zod34.z.array(import_zod34.z.string()),
6362
- explanation: import_zod34.z.string().optional()
6751
+ var LookupFillResultSchema = import_zod36.z.object({
6752
+ fills: import_zod36.z.array(LookupFillSchema),
6753
+ unfillable: import_zod36.z.array(import_zod36.z.string()),
6754
+ explanation: import_zod36.z.string().optional()
6363
6755
  });
6364
- var FlatPdfPlacementSchema = import_zod34.z.object({
6365
- fieldId: import_zod34.z.string(),
6366
- page: import_zod34.z.number(),
6367
- x: import_zod34.z.number().describe("Percentage from left edge (0-100)"),
6368
- y: import_zod34.z.number().describe("Percentage from top edge (0-100)"),
6369
- text: import_zod34.z.string(),
6370
- fontSize: import_zod34.z.number().optional(),
6371
- isCheckmark: import_zod34.z.boolean().optional()
6756
+ var FlatPdfPlacementSchema = import_zod36.z.object({
6757
+ fieldId: import_zod36.z.string(),
6758
+ page: import_zod36.z.number(),
6759
+ x: import_zod36.z.number().describe("Percentage from left edge (0-100)"),
6760
+ y: import_zod36.z.number().describe("Percentage from top edge (0-100)"),
6761
+ text: import_zod36.z.string(),
6762
+ fontSize: import_zod36.z.number().optional(),
6763
+ isCheckmark: import_zod36.z.boolean().optional()
6372
6764
  });
6373
- var AcroFormMappingSchema = import_zod34.z.object({
6374
- fieldId: import_zod34.z.string(),
6375
- acroFormName: import_zod34.z.string(),
6376
- value: import_zod34.z.string()
6765
+ var AcroFormMappingSchema = import_zod36.z.object({
6766
+ fieldId: import_zod36.z.string(),
6767
+ acroFormName: import_zod36.z.string(),
6768
+ value: import_zod36.z.string()
6377
6769
  });
6378
- var QualityGateStatusSchema = import_zod34.z.enum(["passed", "warning", "failed"]);
6379
- var QualitySeveritySchema = import_zod34.z.enum(["info", "warning", "blocking"]);
6380
- var ApplicationQualityIssueSchema = import_zod34.z.object({
6381
- code: import_zod34.z.string(),
6770
+ var QualityGateStatusSchema = import_zod36.z.enum(["passed", "warning", "failed"]);
6771
+ var QualitySeveritySchema = import_zod36.z.enum(["info", "warning", "blocking"]);
6772
+ var ApplicationQualityIssueSchema = import_zod36.z.object({
6773
+ code: import_zod36.z.string(),
6382
6774
  severity: QualitySeveritySchema,
6383
- message: import_zod34.z.string(),
6384
- fieldId: import_zod34.z.string().optional()
6775
+ message: import_zod36.z.string(),
6776
+ fieldId: import_zod36.z.string().optional()
6385
6777
  });
6386
- var ApplicationQualityRoundSchema = import_zod34.z.object({
6387
- round: import_zod34.z.number(),
6388
- kind: import_zod34.z.string(),
6778
+ var ApplicationQualityRoundSchema = import_zod36.z.object({
6779
+ round: import_zod36.z.number(),
6780
+ kind: import_zod36.z.string(),
6389
6781
  status: QualityGateStatusSchema,
6390
- summary: import_zod34.z.string().optional()
6782
+ summary: import_zod36.z.string().optional()
6391
6783
  });
6392
- var ApplicationQualityArtifactSchema = import_zod34.z.object({
6393
- kind: import_zod34.z.string(),
6394
- label: import_zod34.z.string().optional(),
6395
- itemCount: import_zod34.z.number().optional()
6784
+ var ApplicationQualityArtifactSchema = import_zod36.z.object({
6785
+ kind: import_zod36.z.string(),
6786
+ label: import_zod36.z.string().optional(),
6787
+ itemCount: import_zod36.z.number().optional()
6396
6788
  });
6397
- var ApplicationEmailReviewSchema = import_zod34.z.object({
6398
- issues: import_zod34.z.array(ApplicationQualityIssueSchema),
6789
+ var ApplicationEmailReviewSchema = import_zod36.z.object({
6790
+ issues: import_zod36.z.array(ApplicationQualityIssueSchema),
6399
6791
  qualityGateStatus: QualityGateStatusSchema
6400
6792
  });
6401
- var ApplicationQualityReportSchema = import_zod34.z.object({
6402
- issues: import_zod34.z.array(ApplicationQualityIssueSchema),
6403
- rounds: import_zod34.z.array(ApplicationQualityRoundSchema).optional(),
6404
- artifacts: import_zod34.z.array(ApplicationQualityArtifactSchema).optional(),
6793
+ var ApplicationQualityReportSchema = import_zod36.z.object({
6794
+ issues: import_zod36.z.array(ApplicationQualityIssueSchema),
6795
+ rounds: import_zod36.z.array(ApplicationQualityRoundSchema).optional(),
6796
+ artifacts: import_zod36.z.array(ApplicationQualityArtifactSchema).optional(),
6405
6797
  emailReview: ApplicationEmailReviewSchema.optional(),
6406
6798
  qualityGateStatus: QualityGateStatusSchema
6407
6799
  });
6408
- var ApplicationStateSchema = import_zod34.z.object({
6409
- id: import_zod34.z.string(),
6410
- pdfBase64: import_zod34.z.string().optional().describe("Original PDF, omitted after extraction"),
6411
- title: import_zod34.z.string().optional(),
6412
- applicationType: import_zod34.z.string().nullable().optional(),
6413
- fields: import_zod34.z.array(ApplicationFieldSchema),
6414
- batches: import_zod34.z.array(import_zod34.z.array(import_zod34.z.string())).optional(),
6415
- currentBatchIndex: import_zod34.z.number().default(0),
6800
+ var ApplicationStateSchema = import_zod36.z.object({
6801
+ id: import_zod36.z.string(),
6802
+ pdfBase64: import_zod36.z.string().optional().describe("Original PDF, omitted after extraction"),
6803
+ title: import_zod36.z.string().optional(),
6804
+ applicationType: import_zod36.z.string().nullable().optional(),
6805
+ fields: import_zod36.z.array(ApplicationFieldSchema),
6806
+ batches: import_zod36.z.array(import_zod36.z.array(import_zod36.z.string())).optional(),
6807
+ currentBatchIndex: import_zod36.z.number().default(0),
6416
6808
  qualityReport: ApplicationQualityReportSchema.optional(),
6417
- status: import_zod34.z.enum(["classifying", "extracting", "auto_filling", "batching", "collecting", "confirming", "mapping", "complete"]),
6418
- createdAt: import_zod34.z.number(),
6419
- updatedAt: import_zod34.z.number()
6809
+ status: import_zod36.z.enum(["classifying", "extracting", "auto_filling", "batching", "collecting", "confirming", "mapping", "complete"]),
6810
+ createdAt: import_zod36.z.number(),
6811
+ updatedAt: import_zod36.z.number()
6420
6812
  });
6421
6813
 
6422
6814
  // src/application/agents/classifier.ts
@@ -7553,90 +7945,91 @@ Respond with the final answer, deduplicated citations array, overall confidence
7553
7945
  }
7554
7946
 
7555
7947
  // src/schemas/query.ts
7556
- var import_zod35 = require("zod");
7557
- var QueryIntentSchema = import_zod35.z.enum([
7948
+ var import_zod37 = require("zod");
7949
+ var QueryIntentSchema = import_zod37.z.enum([
7558
7950
  "policy_question",
7559
7951
  "coverage_comparison",
7560
7952
  "document_search",
7561
7953
  "claims_inquiry",
7562
7954
  "general_knowledge"
7563
7955
  ]);
7564
- var QueryAttachmentKindSchema = import_zod35.z.enum(["image", "pdf", "text"]);
7565
- var QueryAttachmentSchema = import_zod35.z.object({
7566
- id: import_zod35.z.string().optional().describe("Optional stable attachment ID from the caller"),
7956
+ var QueryAttachmentKindSchema = import_zod37.z.enum(["image", "pdf", "text"]);
7957
+ var QueryAttachmentSchema = import_zod37.z.object({
7958
+ id: import_zod37.z.string().optional().describe("Optional stable attachment ID from the caller"),
7567
7959
  kind: QueryAttachmentKindSchema,
7568
- name: import_zod35.z.string().optional().describe("Original filename or user-facing label"),
7569
- mimeType: import_zod35.z.string().optional().describe("MIME type such as image/jpeg or application/pdf"),
7570
- base64: import_zod35.z.string().optional().describe("Base64-encoded file content for image/pdf attachments"),
7571
- text: import_zod35.z.string().optional().describe("Plain-text attachment content when available"),
7572
- description: import_zod35.z.string().optional().describe("Caller-provided description of the attachment")
7960
+ name: import_zod37.z.string().optional().describe("Original filename or user-facing label"),
7961
+ mimeType: import_zod37.z.string().optional().describe("MIME type such as image/jpeg or application/pdf"),
7962
+ base64: import_zod37.z.string().optional().describe("Base64-encoded file content for image/pdf attachments"),
7963
+ text: import_zod37.z.string().optional().describe("Plain-text attachment content when available"),
7964
+ description: import_zod37.z.string().optional().describe("Caller-provided description of the attachment")
7573
7965
  });
7574
- var SubQuestionSchema = import_zod35.z.object({
7575
- question: import_zod35.z.string().describe("Atomic sub-question to retrieve and answer independently"),
7966
+ var SubQuestionSchema = import_zod37.z.object({
7967
+ question: import_zod37.z.string().describe("Atomic sub-question to retrieve and answer independently"),
7576
7968
  intent: QueryIntentSchema,
7577
- chunkTypes: import_zod35.z.array(import_zod35.z.string()).optional().describe("Chunk types to filter retrieval (e.g. coverage, endorsement, declaration)"),
7578
- documentFilters: import_zod35.z.object({
7579
- type: import_zod35.z.enum(["policy", "quote"]).optional(),
7580
- carrier: import_zod35.z.string().optional(),
7581
- insuredName: import_zod35.z.string().optional(),
7582
- policyNumber: import_zod35.z.string().optional(),
7583
- quoteNumber: import_zod35.z.string().optional()
7969
+ chunkTypes: import_zod37.z.array(import_zod37.z.string()).optional().describe("Chunk types to filter retrieval (e.g. coverage, endorsement, declaration)"),
7970
+ documentFilters: import_zod37.z.object({
7971
+ type: import_zod37.z.enum(["policy", "quote"]).optional(),
7972
+ carrier: import_zod37.z.string().optional(),
7973
+ insuredName: import_zod37.z.string().optional(),
7974
+ policyNumber: import_zod37.z.string().optional(),
7975
+ quoteNumber: import_zod37.z.string().optional(),
7976
+ policyTypes: import_zod37.z.array(PolicyTypeSchema).optional().describe("Filter by policy type (e.g. homeowners_ho3, renters_ho4, pet) to avoid mixing up similar policies")
7584
7977
  }).optional().describe("Structured filters to narrow document lookup")
7585
7978
  });
7586
- var QueryClassifyResultSchema = import_zod35.z.object({
7979
+ var QueryClassifyResultSchema = import_zod37.z.object({
7587
7980
  intent: QueryIntentSchema,
7588
- subQuestions: import_zod35.z.array(SubQuestionSchema).min(1).describe("Decomposed atomic sub-questions"),
7589
- requiresDocumentLookup: import_zod35.z.boolean().describe("Whether structured document lookup is needed"),
7590
- requiresChunkSearch: import_zod35.z.boolean().describe("Whether semantic chunk search is needed"),
7591
- requiresConversationHistory: import_zod35.z.boolean().describe("Whether conversation history is relevant")
7981
+ subQuestions: import_zod37.z.array(SubQuestionSchema).min(1).describe("Decomposed atomic sub-questions"),
7982
+ requiresDocumentLookup: import_zod37.z.boolean().describe("Whether structured document lookup is needed"),
7983
+ requiresChunkSearch: import_zod37.z.boolean().describe("Whether semantic chunk search is needed"),
7984
+ requiresConversationHistory: import_zod37.z.boolean().describe("Whether conversation history is relevant")
7592
7985
  });
7593
- var EvidenceItemSchema = import_zod35.z.object({
7594
- source: import_zod35.z.enum(["chunk", "document", "conversation", "attachment"]),
7595
- chunkId: import_zod35.z.string().optional(),
7596
- documentId: import_zod35.z.string().optional(),
7597
- turnId: import_zod35.z.string().optional(),
7598
- attachmentId: import_zod35.z.string().optional(),
7599
- text: import_zod35.z.string().describe("Text excerpt from the source"),
7600
- relevance: import_zod35.z.number().min(0).max(1),
7601
- metadata: import_zod35.z.array(import_zod35.z.object({ key: import_zod35.z.string(), value: import_zod35.z.string() })).optional()
7986
+ var EvidenceItemSchema = import_zod37.z.object({
7987
+ source: import_zod37.z.enum(["chunk", "document", "conversation", "attachment"]),
7988
+ chunkId: import_zod37.z.string().optional(),
7989
+ documentId: import_zod37.z.string().optional(),
7990
+ turnId: import_zod37.z.string().optional(),
7991
+ attachmentId: import_zod37.z.string().optional(),
7992
+ text: import_zod37.z.string().describe("Text excerpt from the source"),
7993
+ relevance: import_zod37.z.number().min(0).max(1),
7994
+ metadata: import_zod37.z.array(import_zod37.z.object({ key: import_zod37.z.string(), value: import_zod37.z.string() })).optional()
7602
7995
  });
7603
- var AttachmentInterpretationSchema = import_zod35.z.object({
7604
- summary: import_zod35.z.string().describe("Concise summary of what the attachment shows or contains"),
7605
- extractedFacts: import_zod35.z.array(import_zod35.z.string()).describe("Specific observable or document facts grounded in the attachment"),
7606
- recommendedFocus: import_zod35.z.array(import_zod35.z.string()).describe("Important details to incorporate when answering follow-up questions"),
7607
- confidence: import_zod35.z.number().min(0).max(1)
7996
+ var AttachmentInterpretationSchema = import_zod37.z.object({
7997
+ summary: import_zod37.z.string().describe("Concise summary of what the attachment shows or contains"),
7998
+ extractedFacts: import_zod37.z.array(import_zod37.z.string()).describe("Specific observable or document facts grounded in the attachment"),
7999
+ recommendedFocus: import_zod37.z.array(import_zod37.z.string()).describe("Important details to incorporate when answering follow-up questions"),
8000
+ confidence: import_zod37.z.number().min(0).max(1)
7608
8001
  });
7609
- var RetrievalResultSchema = import_zod35.z.object({
7610
- subQuestion: import_zod35.z.string(),
7611
- evidence: import_zod35.z.array(EvidenceItemSchema)
8002
+ var RetrievalResultSchema = import_zod37.z.object({
8003
+ subQuestion: import_zod37.z.string(),
8004
+ evidence: import_zod37.z.array(EvidenceItemSchema)
7612
8005
  });
7613
- var CitationSchema = import_zod35.z.object({
7614
- index: import_zod35.z.number().describe("Citation number [1], [2], etc."),
7615
- chunkId: import_zod35.z.string().describe("Source chunk ID, e.g. doc-123:coverage:2"),
7616
- documentId: import_zod35.z.string(),
7617
- documentType: import_zod35.z.enum(["policy", "quote"]).optional(),
7618
- field: import_zod35.z.string().optional().describe("Specific field path, e.g. coverages[0].deductible"),
7619
- quote: import_zod35.z.string().describe("Exact text from source that supports the claim"),
7620
- relevance: import_zod35.z.number().min(0).max(1)
8006
+ var CitationSchema = import_zod37.z.object({
8007
+ index: import_zod37.z.number().describe("Citation number [1], [2], etc."),
8008
+ chunkId: import_zod37.z.string().describe("Source chunk ID, e.g. doc-123:coverage:2"),
8009
+ documentId: import_zod37.z.string(),
8010
+ documentType: import_zod37.z.enum(["policy", "quote"]).optional(),
8011
+ field: import_zod37.z.string().optional().describe("Specific field path, e.g. coverages[0].deductible"),
8012
+ quote: import_zod37.z.string().describe("Exact text from source that supports the claim"),
8013
+ relevance: import_zod37.z.number().min(0).max(1)
7621
8014
  });
7622
- var SubAnswerSchema = import_zod35.z.object({
7623
- subQuestion: import_zod35.z.string(),
7624
- answer: import_zod35.z.string(),
7625
- citations: import_zod35.z.array(CitationSchema),
7626
- confidence: import_zod35.z.number().min(0).max(1),
7627
- needsMoreContext: import_zod35.z.boolean().describe("True if evidence was insufficient to answer fully")
8015
+ var SubAnswerSchema = import_zod37.z.object({
8016
+ subQuestion: import_zod37.z.string(),
8017
+ answer: import_zod37.z.string(),
8018
+ citations: import_zod37.z.array(CitationSchema),
8019
+ confidence: import_zod37.z.number().min(0).max(1),
8020
+ needsMoreContext: import_zod37.z.boolean().describe("True if evidence was insufficient to answer fully")
7628
8021
  });
7629
- var VerifyResultSchema = import_zod35.z.object({
7630
- approved: import_zod35.z.boolean().describe("Whether all sub-answers are adequately grounded"),
7631
- issues: import_zod35.z.array(import_zod35.z.string()).describe("Specific grounding or consistency issues found"),
7632
- retrySubQuestions: import_zod35.z.array(import_zod35.z.string()).optional().describe("Sub-questions that need additional retrieval or re-reasoning")
8022
+ var VerifyResultSchema = import_zod37.z.object({
8023
+ approved: import_zod37.z.boolean().describe("Whether all sub-answers are adequately grounded"),
8024
+ issues: import_zod37.z.array(import_zod37.z.string()).describe("Specific grounding or consistency issues found"),
8025
+ retrySubQuestions: import_zod37.z.array(import_zod37.z.string()).optional().describe("Sub-questions that need additional retrieval or re-reasoning")
7633
8026
  });
7634
- var QueryResultSchema = import_zod35.z.object({
7635
- answer: import_zod35.z.string(),
7636
- citations: import_zod35.z.array(CitationSchema),
8027
+ var QueryResultSchema = import_zod37.z.object({
8028
+ answer: import_zod37.z.string(),
8029
+ citations: import_zod37.z.array(CitationSchema),
7637
8030
  intent: QueryIntentSchema,
7638
- confidence: import_zod35.z.number().min(0).max(1),
7639
- followUp: import_zod35.z.string().optional().describe("Suggested follow-up question if applicable")
8031
+ confidence: import_zod37.z.number().min(0).max(1),
8032
+ followUp: import_zod37.z.string().optional().describe("Suggested follow-up question if applicable")
7640
8033
  });
7641
8034
 
7642
8035
  // src/query/retriever.ts