@claritylabs/cl-sdk 3.2.11 → 3.2.13
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/application.d.mts +1 -1
- package/dist/application.d.ts +1 -1
- package/dist/application.js +276 -0
- package/dist/application.js.map +1 -1
- package/dist/application.mjs +276 -0
- package/dist/application.mjs.map +1 -1
- package/dist/{index-BGyy2VS6.d.mts → index-WjheX6Dt.d.mts} +1 -1
- package/dist/{index-BGyy2VS6.d.ts → index-WjheX6Dt.d.ts} +1 -1
- package/dist/index.d.mts +29 -17
- package/dist/index.d.ts +29 -17
- package/dist/index.js +190 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +187 -22
- package/dist/index.mjs.map +1 -1
- package/dist/storage-sqlite.js +276 -0
- package/dist/storage-sqlite.js.map +1 -1
- package/dist/storage-sqlite.mjs +276 -0
- package/dist/storage-sqlite.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -337,6 +337,7 @@ __export(src_exports, {
|
|
|
337
337
|
getNextApplicationQuestions: () => getNextApplicationQuestions,
|
|
338
338
|
getPdfPageCount: () => getPdfPageCount,
|
|
339
339
|
getTemplate: () => getTemplate,
|
|
340
|
+
inferPolicyTypesFromOperationalCoverages: () => inferPolicyTypesFromOperationalCoverages,
|
|
340
341
|
isDoclingExtractionInput: () => isDoclingExtractionInput,
|
|
341
342
|
isFileReference: () => isFileReference,
|
|
342
343
|
mergeQuestionAnswers: () => mergeQuestionAnswers,
|
|
@@ -345,6 +346,7 @@ __export(src_exports, {
|
|
|
345
346
|
normalizeDoclingDocument: () => normalizeDoclingDocument,
|
|
346
347
|
normalizeDocumentSourceTreePaths: () => normalizeDocumentSourceTreePaths,
|
|
347
348
|
normalizeForMatch: () => normalizeForMatch,
|
|
349
|
+
normalizeOperationalPolicyTypes: () => normalizeOperationalPolicyTypes,
|
|
348
350
|
normalizeSourceSpans: () => normalizeSourceSpans,
|
|
349
351
|
orderSourceEvidence: () => orderSourceEvidence,
|
|
350
352
|
overlayTextOnPdf: () => overlayTextOnPdf,
|
|
@@ -355,6 +357,7 @@ __export(src_exports, {
|
|
|
355
357
|
processReply: () => processReply,
|
|
356
358
|
proposeContextWrites: () => proposeContextWrites,
|
|
357
359
|
resolveModelBudget: () => resolveModelBudget,
|
|
360
|
+
resolveOperationalProfilePolicyTypes: () => resolveOperationalProfilePolicyTypes,
|
|
358
361
|
safeGenerateObject: () => safeGenerateObject,
|
|
359
362
|
sanitizeNulls: () => sanitizeNulls,
|
|
360
363
|
scoreCaseProposal: () => scoreCaseProposal,
|
|
@@ -710,6 +713,10 @@ var PolicyTypeSchema = import_zod2.z.enum([
|
|
|
710
713
|
"watercraft",
|
|
711
714
|
"recreational_vehicle",
|
|
712
715
|
"farm_ranch",
|
|
716
|
+
"life",
|
|
717
|
+
"critical_illness",
|
|
718
|
+
"disability",
|
|
719
|
+
"long_term_care",
|
|
713
720
|
"pet",
|
|
714
721
|
"travel",
|
|
715
722
|
"identity_theft",
|
|
@@ -2515,6 +2522,158 @@ var PolicyOperationalProfileSchema = import_zod20.z.object({
|
|
|
2515
2522
|
warnings: import_zod20.z.array(import_zod20.z.string()).default([])
|
|
2516
2523
|
});
|
|
2517
2524
|
|
|
2525
|
+
// src/source/policy-types.ts
|
|
2526
|
+
var POLICY_TYPE_KEYS = new Set(POLICY_TYPES);
|
|
2527
|
+
var POLICY_TYPE_ALIASES = {
|
|
2528
|
+
"general liability": "general_liability",
|
|
2529
|
+
"commercial general liability": "general_liability",
|
|
2530
|
+
cgl: "general_liability",
|
|
2531
|
+
"commercial property": "commercial_property",
|
|
2532
|
+
property: "property",
|
|
2533
|
+
"property insurance": "commercial_property",
|
|
2534
|
+
"commercial auto": "commercial_auto",
|
|
2535
|
+
"commercial automobile": "commercial_auto",
|
|
2536
|
+
"business auto": "commercial_auto",
|
|
2537
|
+
"business automobile": "commercial_auto",
|
|
2538
|
+
"auto physical damage": "commercial_auto",
|
|
2539
|
+
"automobile physical damage": "commercial_auto",
|
|
2540
|
+
"hired non owned auto": "non_owned_auto",
|
|
2541
|
+
"hired non-owned auto": "non_owned_auto",
|
|
2542
|
+
"non owned auto": "non_owned_auto",
|
|
2543
|
+
"non-owned auto": "non_owned_auto",
|
|
2544
|
+
"workers comp": "workers_comp",
|
|
2545
|
+
"workers compensation": "workers_comp",
|
|
2546
|
+
"workers' compensation": "workers_comp",
|
|
2547
|
+
umbrella: "umbrella",
|
|
2548
|
+
"excess liability": "excess_liability",
|
|
2549
|
+
"professional liability": "professional_liability",
|
|
2550
|
+
"errors and omissions": "professional_liability",
|
|
2551
|
+
"e&o": "professional_liability",
|
|
2552
|
+
cyber: "cyber",
|
|
2553
|
+
"cyber liability": "cyber",
|
|
2554
|
+
"network security": "cyber",
|
|
2555
|
+
"privacy liability": "cyber",
|
|
2556
|
+
epli: "epli",
|
|
2557
|
+
"employment practices liability": "epli",
|
|
2558
|
+
"directors and officers": "directors_officers",
|
|
2559
|
+
"directors & officers": "directors_officers",
|
|
2560
|
+
"d&o": "directors_officers",
|
|
2561
|
+
"fiduciary liability insurance": "fiduciary_liability",
|
|
2562
|
+
"crime insurance": "crime_fidelity",
|
|
2563
|
+
"fidelity bond": "crime_fidelity",
|
|
2564
|
+
"inland marine insurance": "inland_marine",
|
|
2565
|
+
"motor truck cargo": "inland_marine",
|
|
2566
|
+
"motor truck cargo legal liability": "inland_marine",
|
|
2567
|
+
"builders risk insurance": "builders_risk",
|
|
2568
|
+
"pollution liability": "environmental",
|
|
2569
|
+
"premises pollution liability": "environmental",
|
|
2570
|
+
"environmental liability": "environmental",
|
|
2571
|
+
"ocean marine insurance": "ocean_marine",
|
|
2572
|
+
"surety bond": "surety",
|
|
2573
|
+
"product liability insurance": "product_liability",
|
|
2574
|
+
"life insurance": "life",
|
|
2575
|
+
"permanent life": "life",
|
|
2576
|
+
"term life": "life",
|
|
2577
|
+
"whole life": "life",
|
|
2578
|
+
"universal life": "life",
|
|
2579
|
+
"critical illness": "critical_illness",
|
|
2580
|
+
"critical illness insurance": "critical_illness",
|
|
2581
|
+
"disability insurance": "disability",
|
|
2582
|
+
"long term care": "long_term_care",
|
|
2583
|
+
"long-term care": "long_term_care"
|
|
2584
|
+
};
|
|
2585
|
+
var POLICY_TYPE_TEXT_PATTERNS = [
|
|
2586
|
+
{ type: "general_liability", pattern: /\b(?:commercial\s+)?general\s+liability\b|\bcgl\b/i },
|
|
2587
|
+
{ type: "commercial_property", pattern: /\bcommercial\s+property\b|\bproperty\s+insurance\b/i },
|
|
2588
|
+
{ type: "commercial_auto", pattern: /\bcommercial\s+auto(?:mobile)?\b|\bbusiness\s+auto(?:mobile)?\b|\bauto(?:mobile)?\s+physical\s+damage\b/i },
|
|
2589
|
+
{ type: "non_owned_auto", pattern: /\b(?:hired\s+(?:and\s+)?)?non[-\s]?owned\s+auto\b/i },
|
|
2590
|
+
{ type: "workers_comp", pattern: /\bworkers['’]?\s+comp(?:ensation)?\b/i },
|
|
2591
|
+
{ type: "umbrella", pattern: /\bcommercial\s+umbrella\b|\bumbrella\s+liability\b/i },
|
|
2592
|
+
{ type: "excess_liability", pattern: /\bexcess\s+liability\b/i },
|
|
2593
|
+
{ type: "professional_liability", pattern: /\bprofessional\s+liability\b|\berrors?\s*(?:and|&)\s*omissions?\b|\be&o\b/i },
|
|
2594
|
+
{ type: "cyber", pattern: /\bcyber\b|\bnetwork\s+security\b|\bprivacy\s+liability\b/i },
|
|
2595
|
+
{ type: "epli", pattern: /\bemployment\s+practices?\s+liability\b|\bepli\b/i },
|
|
2596
|
+
{ type: "directors_officers", pattern: /\bdirectors?\s*(?:and|&)\s*officers?\b|\bd&o\b/i },
|
|
2597
|
+
{ type: "fiduciary_liability", pattern: /\bfiduciary\s+liability\b/i },
|
|
2598
|
+
{ type: "crime_fidelity", pattern: /\bcrime\b|\bfidelity\b/i },
|
|
2599
|
+
{ type: "inland_marine", pattern: /\binland\s+marine\b|\bmotor\s+truck\s+cargo\b|\bcargo\s+legal\s+liability\b/i },
|
|
2600
|
+
{ type: "builders_risk", pattern: /\bbuilders?\s+risk\b/i },
|
|
2601
|
+
{ type: "environmental", pattern: /\bpollution\s+liability\b|\benvironmental\s+liability\b/i },
|
|
2602
|
+
{ type: "ocean_marine", pattern: /\bocean\s+marine\b/i },
|
|
2603
|
+
{ type: "surety", pattern: /\bsurety\b/i },
|
|
2604
|
+
{ type: "product_liability", pattern: /\bproduct\s+liability\b|\bproducts?\s+completed\s+operations\b/i },
|
|
2605
|
+
{ type: "bop", pattern: /\bbusiness\s*owners?\s+policy\b|\bbop\b/i },
|
|
2606
|
+
{ type: "homeowners_ho3", pattern: /\bhomeowners?\s*(?:ho[-\s]?3)?\b/i },
|
|
2607
|
+
{ type: "homeowners_ho5", pattern: /\bho[-\s]?5\b/i },
|
|
2608
|
+
{ type: "renters_ho4", pattern: /\brenters?\b|\bho[-\s]?4\b/i },
|
|
2609
|
+
{ type: "condo_ho6", pattern: /\bcondo(?:minium)?\b|\bho[-\s]?6\b/i },
|
|
2610
|
+
{ type: "dwelling_fire", pattern: /\bdwelling\s+fire\b/i },
|
|
2611
|
+
{ type: "personal_auto", pattern: /\bpersonal\s+auto\b/i },
|
|
2612
|
+
{ type: "personal_umbrella", pattern: /\bpersonal\s+umbrella\b/i },
|
|
2613
|
+
{ type: "flood_private", pattern: /\bflood\b/i },
|
|
2614
|
+
{ type: "earthquake", pattern: /\bearthquake\b/i },
|
|
2615
|
+
{ type: "personal_inland_marine", pattern: /\bpersonal\s+(?:articles|inland\s+marine)\b/i },
|
|
2616
|
+
{ type: "watercraft", pattern: /\bwatercraft\b|\bboat\s+insurance\b/i },
|
|
2617
|
+
{ type: "recreational_vehicle", pattern: /\brecreational\s+vehicle\b|\brv\s+insurance\b/i },
|
|
2618
|
+
{ type: "farm_ranch", pattern: /\bfarm\b|\branch\b/i },
|
|
2619
|
+
{ type: "life", pattern: /\blife\s+insurance\b|\bterm\s+life\b|\bwhole\s+life\b|\buniversal\s+life\b/i },
|
|
2620
|
+
{ type: "critical_illness", pattern: /\bcritical\s+illness\b/i },
|
|
2621
|
+
{ type: "disability", pattern: /\bdisability\s+insurance\b|\btotal\s+disability\b/i },
|
|
2622
|
+
{ type: "long_term_care", pattern: /\blong[-\s]?term\s+care\b/i },
|
|
2623
|
+
{ type: "pet", pattern: /\bpet\s+insurance\b/i },
|
|
2624
|
+
{ type: "travel", pattern: /\btravel\s+insurance\b/i },
|
|
2625
|
+
{ type: "identity_theft", pattern: /\bidentity\s+theft\b/i },
|
|
2626
|
+
{ type: "title", pattern: /\btitle\s+insurance\b/i }
|
|
2627
|
+
];
|
|
2628
|
+
function normalizeWhitespace(value) {
|
|
2629
|
+
return value.replace(/\s+/g, " ").trim();
|
|
2630
|
+
}
|
|
2631
|
+
function normalizeOperationalPolicyTypes(values) {
|
|
2632
|
+
const types = Array.isArray(values) ? values.filter((value) => typeof value === "string") : [];
|
|
2633
|
+
const controlled = types.map((type) => type.trim().toLowerCase().replace(/\s+/g, " ")).map((type) => POLICY_TYPE_ALIASES[type] ?? type.replace(/[\s-]+/g, "_")).filter((type) => POLICY_TYPE_KEYS.has(type));
|
|
2634
|
+
const unique = [...new Set(controlled)].slice(0, 6);
|
|
2635
|
+
return unique.length ? unique : ["other"];
|
|
2636
|
+
}
|
|
2637
|
+
function hasSpecificPolicyType(types) {
|
|
2638
|
+
return types.some((type) => type !== "other");
|
|
2639
|
+
}
|
|
2640
|
+
function policyTypesFromText(value) {
|
|
2641
|
+
const text = normalizeWhitespace(value ?? "");
|
|
2642
|
+
if (!text) return [];
|
|
2643
|
+
const aliasType = POLICY_TYPE_ALIASES[text.toLowerCase()];
|
|
2644
|
+
if (aliasType && POLICY_TYPE_KEYS.has(aliasType)) return [aliasType];
|
|
2645
|
+
return POLICY_TYPE_TEXT_PATTERNS.filter(({ pattern }) => pattern.test(text)).map(({ type }) => type).filter((type) => POLICY_TYPE_KEYS.has(type));
|
|
2646
|
+
}
|
|
2647
|
+
function inferPolicyTypesFromOperationalCoverages(coverages) {
|
|
2648
|
+
const inferred = [];
|
|
2649
|
+
for (const coverage of coverages) {
|
|
2650
|
+
const limits = coverage.limits ?? [];
|
|
2651
|
+
const text = [
|
|
2652
|
+
coverage.coverageCode,
|
|
2653
|
+
coverage.formNumber,
|
|
2654
|
+
coverage.name,
|
|
2655
|
+
...limits.flatMap((term) => [term.appliesTo, term.label])
|
|
2656
|
+
].filter((value) => typeof value === "string" && value.trim().length > 0);
|
|
2657
|
+
for (const value of text) {
|
|
2658
|
+
for (const type of policyTypesFromText(value)) {
|
|
2659
|
+
if (!inferred.includes(type)) inferred.push(type);
|
|
2660
|
+
}
|
|
2661
|
+
}
|
|
2662
|
+
}
|
|
2663
|
+
return inferred.slice(0, 6);
|
|
2664
|
+
}
|
|
2665
|
+
function resolveOperationalProfilePolicyTypes(params) {
|
|
2666
|
+
const inferred = inferPolicyTypesFromOperationalCoverages(params.coverages ?? []);
|
|
2667
|
+
if (inferred.length > 0) {
|
|
2668
|
+
return { policyTypes: inferred, source: "coverage" };
|
|
2669
|
+
}
|
|
2670
|
+
const controlled = normalizeOperationalPolicyTypes(params.profileTypes);
|
|
2671
|
+
if (hasSpecificPolicyType(controlled)) return { policyTypes: controlled, source: "profile_hint" };
|
|
2672
|
+
const existingControlled = normalizeOperationalPolicyTypes(params.existingTypes);
|
|
2673
|
+
if (hasSpecificPolicyType(existingControlled)) return { policyTypes: existingControlled, source: "existing_hint" };
|
|
2674
|
+
return { policyTypes: controlled, source: "default" };
|
|
2675
|
+
}
|
|
2676
|
+
|
|
2518
2677
|
// src/source/ids.ts
|
|
2519
2678
|
function normalizeText(text) {
|
|
2520
2679
|
return text.replace(/\s+/g, " ").trim();
|
|
@@ -2581,14 +2740,14 @@ function orderSourceEvidence(evidence) {
|
|
|
2581
2740
|
}
|
|
2582
2741
|
|
|
2583
2742
|
// src/source/extraction.ts
|
|
2584
|
-
function
|
|
2743
|
+
function normalizeWhitespace2(value) {
|
|
2585
2744
|
return value.replace(/\s+/g, " ").trim();
|
|
2586
2745
|
}
|
|
2587
2746
|
function sanitizeIdPart(value) {
|
|
2588
2747
|
return value.replace(/[^a-zA-Z0-9_.:-]/g, "_");
|
|
2589
2748
|
}
|
|
2590
2749
|
function buildSourceSpan(input, localIndex = 0) {
|
|
2591
|
-
const text =
|
|
2750
|
+
const text = normalizeWhitespace2(input.text);
|
|
2592
2751
|
const textHash = sourceSpanTextHash(text);
|
|
2593
2752
|
const pagePart = input.pageStart ?? "na";
|
|
2594
2753
|
const id = [
|
|
@@ -2623,7 +2782,7 @@ function buildSourceSpan(input, localIndex = 0) {
|
|
|
2623
2782
|
});
|
|
2624
2783
|
}
|
|
2625
2784
|
function buildPageSourceSpans(pages) {
|
|
2626
|
-
return pages.filter((page) =>
|
|
2785
|
+
return pages.filter((page) => normalizeWhitespace2(page.text).length > 0).map(
|
|
2627
2786
|
(page, index) => buildSourceSpan(
|
|
2628
2787
|
{
|
|
2629
2788
|
documentId: page.documentId,
|
|
@@ -2674,7 +2833,7 @@ function buildSectionSourceSpans(pages, options = {}) {
|
|
|
2674
2833
|
function buildTextSourceSpans(input, options = {}) {
|
|
2675
2834
|
const maxChars = options.maxChars ?? 4e3;
|
|
2676
2835
|
const overlapChars = Math.min(options.overlapChars ?? 0, Math.max(0, maxChars - 1));
|
|
2677
|
-
const text =
|
|
2836
|
+
const text = normalizeWhitespace2(input.text);
|
|
2678
2837
|
if (!text) return [];
|
|
2679
2838
|
const spans = [];
|
|
2680
2839
|
let cursor = 0;
|
|
@@ -2749,7 +2908,7 @@ function spanPage(span) {
|
|
|
2749
2908
|
}
|
|
2750
2909
|
function normalizeSourceSpanText(span) {
|
|
2751
2910
|
const unit = sourceUnit(span);
|
|
2752
|
-
const text =
|
|
2911
|
+
const text = normalizeWhitespace2(span.text);
|
|
2753
2912
|
if (!text) return void 0;
|
|
2754
2913
|
if (isDiscardableBoilerplate(text, unit)) return void 0;
|
|
2755
2914
|
const cleanedText = cleanBoilerplateLines(text);
|
|
@@ -2761,7 +2920,7 @@ function normalizeSourceSpanText(span) {
|
|
|
2761
2920
|
});
|
|
2762
2921
|
}
|
|
2763
2922
|
function isDiscardableBoilerplate(text, unit) {
|
|
2764
|
-
const cleaned =
|
|
2923
|
+
const cleaned = normalizeWhitespace2(text.replace(/\bColumn\s+\d+:\s*/gi, ""));
|
|
2765
2924
|
if (/^SPECIMEN POLICY\s+[-—]\s+FOR TESTING ONLY$/i.test(cleaned)) return true;
|
|
2766
2925
|
if (/^Page\s+\d+\s+of\s+\d+$/i.test(cleaned)) return true;
|
|
2767
2926
|
if (/^[A-Z]{2,}(?:-[A-Z0-9]{2,})+\s+\d{2}\s+\d{2}$/i.test(cleaned)) return true;
|
|
@@ -2770,24 +2929,24 @@ function isDiscardableBoilerplate(text, unit) {
|
|
|
2770
2929
|
return false;
|
|
2771
2930
|
}
|
|
2772
2931
|
function isBoilerplateLine(line) {
|
|
2773
|
-
const cleaned =
|
|
2932
|
+
const cleaned = normalizeWhitespace2(line.replace(/\bColumn\s+\d+:\s*/gi, ""));
|
|
2774
2933
|
return isDiscardableBoilerplate(cleaned) || /^THIS IS A CLAIMS-MADE AND REPORTED POLICY\.? PLEASE READ IT CAREFULLY\.?$/i.test(cleaned);
|
|
2775
2934
|
}
|
|
2776
2935
|
function removedBoilerplateLines(text) {
|
|
2777
|
-
return text.split(/\s{2,}|\r?\n/).map(
|
|
2936
|
+
return text.split(/\s{2,}|\r?\n/).map(normalizeWhitespace2).filter((line) => line && isBoilerplateLine(line));
|
|
2778
2937
|
}
|
|
2779
2938
|
function cleanBoilerplateLines(text) {
|
|
2780
2939
|
const withoutInlineBoilerplate = text.replace(/\b(?:Column\s+\d+:\s*)?[A-Z]{2,}(?:-[A-Z0-9]{2,})+\s+\d{2}\s+\d{2}\s+(?:\|\s*)?(?:Column\s+\d+:\s*)?Page\s+\d+\s+of\s+\d+\b/gi, " ").replace(/\bSPECIMEN POLICY\s+[-—]\s+FOR TESTING ONLY\b/gi, " ").replace(/\bPage\s+\d+\s+of\s+\d+\b/gi, " ");
|
|
2781
2940
|
const lines = withoutInlineBoilerplate.split(/\r?\n/);
|
|
2782
|
-
const filtered = lines.map(
|
|
2783
|
-
return
|
|
2941
|
+
const filtered = lines.map(normalizeWhitespace2).filter((line) => line && !isBoilerplateLine(line));
|
|
2942
|
+
return normalizeWhitespace2(filtered.join(" "));
|
|
2784
2943
|
}
|
|
2785
2944
|
function shouldMergeTextSpan(left, right) {
|
|
2786
2945
|
if (sourceUnit(left) !== "text" || sourceUnit(right) !== "text") return false;
|
|
2787
2946
|
if (spanPage(left) !== spanPage(right)) return false;
|
|
2788
2947
|
if (left.metadata?.elementType === "title" || right.metadata?.elementType === "title") return false;
|
|
2789
|
-
const leftText =
|
|
2790
|
-
const rightText =
|
|
2948
|
+
const leftText = normalizeWhitespace2(left.text);
|
|
2949
|
+
const rightText = normalizeWhitespace2(right.text);
|
|
2791
2950
|
if (!leftText || !rightText) return false;
|
|
2792
2951
|
if (/[:.;!?)]$/.test(leftText)) return false;
|
|
2793
2952
|
if (/^(?:[A-Z][A-Z0-9 &/(),.-]{8,}|Item\s+\d+|Section\s+\d+|Part\s+[A-Z]\b)/.test(rightText)) return false;
|
|
@@ -2808,7 +2967,7 @@ function mergeTextRuns(spans) {
|
|
|
2808
2967
|
return result;
|
|
2809
2968
|
}
|
|
2810
2969
|
function mergeTextSpanPair(left, right) {
|
|
2811
|
-
const text =
|
|
2970
|
+
const text = normalizeWhitespace2(`${left.text} ${right.text}`);
|
|
2812
2971
|
const merged = retextSpan(left, text, {
|
|
2813
2972
|
mergedSourceSpanIds: [left.metadata?.mergedSourceSpanIds, left.id, right.id, right.metadata?.mergedSourceSpanIds].filter(Boolean).join(","),
|
|
2814
2973
|
sourceSpanNormalization: "merged_text_run"
|
|
@@ -2860,7 +3019,7 @@ function splitPageIntoSections(text, headingPattern, minSectionChars) {
|
|
|
2860
3019
|
if (current) sections.push(current);
|
|
2861
3020
|
const suffix = match[1]?.trim();
|
|
2862
3021
|
current = {
|
|
2863
|
-
title:
|
|
3022
|
+
title: normalizeWhitespace2(suffix ? `${line}` : line).slice(0, 120),
|
|
2864
3023
|
lines: [line]
|
|
2865
3024
|
};
|
|
2866
3025
|
continue;
|
|
@@ -2870,7 +3029,7 @@ function splitPageIntoSections(text, headingPattern, minSectionChars) {
|
|
|
2870
3029
|
if (current) sections.push(current);
|
|
2871
3030
|
return sections.map((section) => ({
|
|
2872
3031
|
title: section.title,
|
|
2873
|
-
text:
|
|
3032
|
+
text: normalizeWhitespace2(section.lines.join("\n"))
|
|
2874
3033
|
})).filter((section) => section.text.length >= minSectionChars);
|
|
2875
3034
|
}
|
|
2876
3035
|
function inferFormNumber(text) {
|
|
@@ -2971,14 +3130,14 @@ function matchesFilters(span, filters) {
|
|
|
2971
3130
|
}
|
|
2972
3131
|
|
|
2973
3132
|
// src/source/tree.ts
|
|
2974
|
-
function
|
|
3133
|
+
function normalizeWhitespace3(value) {
|
|
2975
3134
|
return value.replace(/\s+/g, " ").trim();
|
|
2976
3135
|
}
|
|
2977
3136
|
function sanitizeIdPart2(value) {
|
|
2978
3137
|
return value.replace(/[^a-zA-Z0-9_.:-]/g, "_");
|
|
2979
3138
|
}
|
|
2980
3139
|
function truncate(value, maxChars) {
|
|
2981
|
-
const text =
|
|
3140
|
+
const text = normalizeWhitespace3(value);
|
|
2982
3141
|
return text.length > maxChars ? `${text.slice(0, maxChars).trimEnd()}...` : text;
|
|
2983
3142
|
}
|
|
2984
3143
|
function pageStart(span) {
|
|
@@ -3072,7 +3231,7 @@ function isTitleContentNode(node) {
|
|
|
3072
3231
|
if (node.kind !== "text") return false;
|
|
3073
3232
|
const isMarkedTitle = metadataString(node.metadata, "elementType") === "title" || metadataString(node.metadata, "sourceUnit") === "title";
|
|
3074
3233
|
if (!isMarkedTitle) return false;
|
|
3075
|
-
const text =
|
|
3234
|
+
const text = normalizeWhitespace3(node.textExcerpt ?? node.title);
|
|
3076
3235
|
if (!text || text.length > 140) return false;
|
|
3077
3236
|
const words = text.split(/\s+/);
|
|
3078
3237
|
if (words.length > 14) return false;
|
|
@@ -3747,12 +3906,12 @@ function shouldFailQualityGate(mode, status) {
|
|
|
3747
3906
|
var import_zod22 = require("zod");
|
|
3748
3907
|
|
|
3749
3908
|
// src/source/operational-profile.ts
|
|
3750
|
-
function
|
|
3909
|
+
function normalizeWhitespace4(value) {
|
|
3751
3910
|
return value.replace(/\s+/g, " ").trim();
|
|
3752
3911
|
}
|
|
3753
3912
|
function cleanValue(value) {
|
|
3754
3913
|
if (!value) return void 0;
|
|
3755
|
-
return
|
|
3914
|
+
return normalizeWhitespace4(value.replace(/^[\s:;#-]+|[\s;,.]+$/g, ""));
|
|
3756
3915
|
}
|
|
3757
3916
|
var OPERATIONAL_COVERAGE_TERM_KINDS = /* @__PURE__ */ new Set([
|
|
3758
3917
|
"each_claim_limit",
|
|
@@ -3834,6 +3993,7 @@ function mergeOperationalProfile(base, candidate, validNodeIds, validSpanIds) {
|
|
|
3834
3993
|
...keepIds(record.sourceSpanIds, validSpanIds),
|
|
3835
3994
|
...limits.flatMap((term) => term.sourceSpanIds)
|
|
3836
3995
|
])];
|
|
3996
|
+
if (!name || sourceNodeIds2.length === 0 && sourceSpanIds2.length === 0) return void 0;
|
|
3837
3997
|
return {
|
|
3838
3998
|
name,
|
|
3839
3999
|
coverageCode: typeof record.coverageCode === "string" ? cleanValue(record.coverageCode) : void 0,
|
|
@@ -3848,7 +4008,7 @@ function mergeOperationalProfile(base, candidate, validNodeIds, validSpanIds) {
|
|
|
3848
4008
|
sourceNodeIds: sourceNodeIds2,
|
|
3849
4009
|
sourceSpanIds: sourceSpanIds2
|
|
3850
4010
|
};
|
|
3851
|
-
}).filter((coverage) =>
|
|
4011
|
+
}).filter((coverage) => Boolean(coverage)) : base.coverages;
|
|
3852
4012
|
const sourceBackedParty = (role, value) => value ? {
|
|
3853
4013
|
role,
|
|
3854
4014
|
name: value.normalizedValue ?? value.value,
|
|
@@ -3916,10 +4076,15 @@ function mergeOperationalProfile(base, candidate, validNodeIds, validSpanIds) {
|
|
|
3916
4076
|
...base.warnings,
|
|
3917
4077
|
...Array.isArray(candidate.warnings) ? candidate.warnings.filter((warning) => typeof warning === "string" && warning.trim().length > 0) : []
|
|
3918
4078
|
];
|
|
4079
|
+
const resolvedPolicyTypes = resolveOperationalProfilePolicyTypes({
|
|
4080
|
+
profileTypes: candidate.policyTypes,
|
|
4081
|
+
existingTypes: base.policyTypes,
|
|
4082
|
+
coverages
|
|
4083
|
+
});
|
|
3919
4084
|
return PolicyOperationalProfileSchema.parse({
|
|
3920
4085
|
...base,
|
|
3921
4086
|
documentType: candidate.documentType === "policy" ? "policy" : base.documentType,
|
|
3922
|
-
policyTypes:
|
|
4087
|
+
policyTypes: resolvedPolicyTypes.policyTypes,
|
|
3923
4088
|
policyNumber,
|
|
3924
4089
|
namedInsured,
|
|
3925
4090
|
insurer,
|
|
@@ -13144,6 +13309,7 @@ function getTemplate(policyType) {
|
|
|
13144
13309
|
getNextApplicationQuestions,
|
|
13145
13310
|
getPdfPageCount,
|
|
13146
13311
|
getTemplate,
|
|
13312
|
+
inferPolicyTypesFromOperationalCoverages,
|
|
13147
13313
|
isDoclingExtractionInput,
|
|
13148
13314
|
isFileReference,
|
|
13149
13315
|
mergeQuestionAnswers,
|
|
@@ -13152,6 +13318,7 @@ function getTemplate(policyType) {
|
|
|
13152
13318
|
normalizeDoclingDocument,
|
|
13153
13319
|
normalizeDocumentSourceTreePaths,
|
|
13154
13320
|
normalizeForMatch,
|
|
13321
|
+
normalizeOperationalPolicyTypes,
|
|
13155
13322
|
normalizeSourceSpans,
|
|
13156
13323
|
orderSourceEvidence,
|
|
13157
13324
|
overlayTextOnPdf,
|
|
@@ -13162,6 +13329,7 @@ function getTemplate(policyType) {
|
|
|
13162
13329
|
processReply,
|
|
13163
13330
|
proposeContextWrites,
|
|
13164
13331
|
resolveModelBudget,
|
|
13332
|
+
resolveOperationalProfilePolicyTypes,
|
|
13165
13333
|
safeGenerateObject,
|
|
13166
13334
|
sanitizeNulls,
|
|
13167
13335
|
scoreCaseProposal,
|