@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.mjs
CHANGED
|
@@ -334,6 +334,10 @@ var PolicyTypeSchema = z2.enum([
|
|
|
334
334
|
"watercraft",
|
|
335
335
|
"recreational_vehicle",
|
|
336
336
|
"farm_ranch",
|
|
337
|
+
"life",
|
|
338
|
+
"critical_illness",
|
|
339
|
+
"disability",
|
|
340
|
+
"long_term_care",
|
|
337
341
|
"pet",
|
|
338
342
|
"travel",
|
|
339
343
|
"identity_theft",
|
|
@@ -2139,6 +2143,158 @@ var PolicyOperationalProfileSchema = z20.object({
|
|
|
2139
2143
|
warnings: z20.array(z20.string()).default([])
|
|
2140
2144
|
});
|
|
2141
2145
|
|
|
2146
|
+
// src/source/policy-types.ts
|
|
2147
|
+
var POLICY_TYPE_KEYS = new Set(POLICY_TYPES);
|
|
2148
|
+
var POLICY_TYPE_ALIASES = {
|
|
2149
|
+
"general liability": "general_liability",
|
|
2150
|
+
"commercial general liability": "general_liability",
|
|
2151
|
+
cgl: "general_liability",
|
|
2152
|
+
"commercial property": "commercial_property",
|
|
2153
|
+
property: "property",
|
|
2154
|
+
"property insurance": "commercial_property",
|
|
2155
|
+
"commercial auto": "commercial_auto",
|
|
2156
|
+
"commercial automobile": "commercial_auto",
|
|
2157
|
+
"business auto": "commercial_auto",
|
|
2158
|
+
"business automobile": "commercial_auto",
|
|
2159
|
+
"auto physical damage": "commercial_auto",
|
|
2160
|
+
"automobile physical damage": "commercial_auto",
|
|
2161
|
+
"hired non owned auto": "non_owned_auto",
|
|
2162
|
+
"hired non-owned auto": "non_owned_auto",
|
|
2163
|
+
"non owned auto": "non_owned_auto",
|
|
2164
|
+
"non-owned auto": "non_owned_auto",
|
|
2165
|
+
"workers comp": "workers_comp",
|
|
2166
|
+
"workers compensation": "workers_comp",
|
|
2167
|
+
"workers' compensation": "workers_comp",
|
|
2168
|
+
umbrella: "umbrella",
|
|
2169
|
+
"excess liability": "excess_liability",
|
|
2170
|
+
"professional liability": "professional_liability",
|
|
2171
|
+
"errors and omissions": "professional_liability",
|
|
2172
|
+
"e&o": "professional_liability",
|
|
2173
|
+
cyber: "cyber",
|
|
2174
|
+
"cyber liability": "cyber",
|
|
2175
|
+
"network security": "cyber",
|
|
2176
|
+
"privacy liability": "cyber",
|
|
2177
|
+
epli: "epli",
|
|
2178
|
+
"employment practices liability": "epli",
|
|
2179
|
+
"directors and officers": "directors_officers",
|
|
2180
|
+
"directors & officers": "directors_officers",
|
|
2181
|
+
"d&o": "directors_officers",
|
|
2182
|
+
"fiduciary liability insurance": "fiduciary_liability",
|
|
2183
|
+
"crime insurance": "crime_fidelity",
|
|
2184
|
+
"fidelity bond": "crime_fidelity",
|
|
2185
|
+
"inland marine insurance": "inland_marine",
|
|
2186
|
+
"motor truck cargo": "inland_marine",
|
|
2187
|
+
"motor truck cargo legal liability": "inland_marine",
|
|
2188
|
+
"builders risk insurance": "builders_risk",
|
|
2189
|
+
"pollution liability": "environmental",
|
|
2190
|
+
"premises pollution liability": "environmental",
|
|
2191
|
+
"environmental liability": "environmental",
|
|
2192
|
+
"ocean marine insurance": "ocean_marine",
|
|
2193
|
+
"surety bond": "surety",
|
|
2194
|
+
"product liability insurance": "product_liability",
|
|
2195
|
+
"life insurance": "life",
|
|
2196
|
+
"permanent life": "life",
|
|
2197
|
+
"term life": "life",
|
|
2198
|
+
"whole life": "life",
|
|
2199
|
+
"universal life": "life",
|
|
2200
|
+
"critical illness": "critical_illness",
|
|
2201
|
+
"critical illness insurance": "critical_illness",
|
|
2202
|
+
"disability insurance": "disability",
|
|
2203
|
+
"long term care": "long_term_care",
|
|
2204
|
+
"long-term care": "long_term_care"
|
|
2205
|
+
};
|
|
2206
|
+
var POLICY_TYPE_TEXT_PATTERNS = [
|
|
2207
|
+
{ type: "general_liability", pattern: /\b(?:commercial\s+)?general\s+liability\b|\bcgl\b/i },
|
|
2208
|
+
{ type: "commercial_property", pattern: /\bcommercial\s+property\b|\bproperty\s+insurance\b/i },
|
|
2209
|
+
{ type: "commercial_auto", pattern: /\bcommercial\s+auto(?:mobile)?\b|\bbusiness\s+auto(?:mobile)?\b|\bauto(?:mobile)?\s+physical\s+damage\b/i },
|
|
2210
|
+
{ type: "non_owned_auto", pattern: /\b(?:hired\s+(?:and\s+)?)?non[-\s]?owned\s+auto\b/i },
|
|
2211
|
+
{ type: "workers_comp", pattern: /\bworkers['’]?\s+comp(?:ensation)?\b/i },
|
|
2212
|
+
{ type: "umbrella", pattern: /\bcommercial\s+umbrella\b|\bumbrella\s+liability\b/i },
|
|
2213
|
+
{ type: "excess_liability", pattern: /\bexcess\s+liability\b/i },
|
|
2214
|
+
{ type: "professional_liability", pattern: /\bprofessional\s+liability\b|\berrors?\s*(?:and|&)\s*omissions?\b|\be&o\b/i },
|
|
2215
|
+
{ type: "cyber", pattern: /\bcyber\b|\bnetwork\s+security\b|\bprivacy\s+liability\b/i },
|
|
2216
|
+
{ type: "epli", pattern: /\bemployment\s+practices?\s+liability\b|\bepli\b/i },
|
|
2217
|
+
{ type: "directors_officers", pattern: /\bdirectors?\s*(?:and|&)\s*officers?\b|\bd&o\b/i },
|
|
2218
|
+
{ type: "fiduciary_liability", pattern: /\bfiduciary\s+liability\b/i },
|
|
2219
|
+
{ type: "crime_fidelity", pattern: /\bcrime\b|\bfidelity\b/i },
|
|
2220
|
+
{ type: "inland_marine", pattern: /\binland\s+marine\b|\bmotor\s+truck\s+cargo\b|\bcargo\s+legal\s+liability\b/i },
|
|
2221
|
+
{ type: "builders_risk", pattern: /\bbuilders?\s+risk\b/i },
|
|
2222
|
+
{ type: "environmental", pattern: /\bpollution\s+liability\b|\benvironmental\s+liability\b/i },
|
|
2223
|
+
{ type: "ocean_marine", pattern: /\bocean\s+marine\b/i },
|
|
2224
|
+
{ type: "surety", pattern: /\bsurety\b/i },
|
|
2225
|
+
{ type: "product_liability", pattern: /\bproduct\s+liability\b|\bproducts?\s+completed\s+operations\b/i },
|
|
2226
|
+
{ type: "bop", pattern: /\bbusiness\s*owners?\s+policy\b|\bbop\b/i },
|
|
2227
|
+
{ type: "homeowners_ho3", pattern: /\bhomeowners?\s*(?:ho[-\s]?3)?\b/i },
|
|
2228
|
+
{ type: "homeowners_ho5", pattern: /\bho[-\s]?5\b/i },
|
|
2229
|
+
{ type: "renters_ho4", pattern: /\brenters?\b|\bho[-\s]?4\b/i },
|
|
2230
|
+
{ type: "condo_ho6", pattern: /\bcondo(?:minium)?\b|\bho[-\s]?6\b/i },
|
|
2231
|
+
{ type: "dwelling_fire", pattern: /\bdwelling\s+fire\b/i },
|
|
2232
|
+
{ type: "personal_auto", pattern: /\bpersonal\s+auto\b/i },
|
|
2233
|
+
{ type: "personal_umbrella", pattern: /\bpersonal\s+umbrella\b/i },
|
|
2234
|
+
{ type: "flood_private", pattern: /\bflood\b/i },
|
|
2235
|
+
{ type: "earthquake", pattern: /\bearthquake\b/i },
|
|
2236
|
+
{ type: "personal_inland_marine", pattern: /\bpersonal\s+(?:articles|inland\s+marine)\b/i },
|
|
2237
|
+
{ type: "watercraft", pattern: /\bwatercraft\b|\bboat\s+insurance\b/i },
|
|
2238
|
+
{ type: "recreational_vehicle", pattern: /\brecreational\s+vehicle\b|\brv\s+insurance\b/i },
|
|
2239
|
+
{ type: "farm_ranch", pattern: /\bfarm\b|\branch\b/i },
|
|
2240
|
+
{ type: "life", pattern: /\blife\s+insurance\b|\bterm\s+life\b|\bwhole\s+life\b|\buniversal\s+life\b/i },
|
|
2241
|
+
{ type: "critical_illness", pattern: /\bcritical\s+illness\b/i },
|
|
2242
|
+
{ type: "disability", pattern: /\bdisability\s+insurance\b|\btotal\s+disability\b/i },
|
|
2243
|
+
{ type: "long_term_care", pattern: /\blong[-\s]?term\s+care\b/i },
|
|
2244
|
+
{ type: "pet", pattern: /\bpet\s+insurance\b/i },
|
|
2245
|
+
{ type: "travel", pattern: /\btravel\s+insurance\b/i },
|
|
2246
|
+
{ type: "identity_theft", pattern: /\bidentity\s+theft\b/i },
|
|
2247
|
+
{ type: "title", pattern: /\btitle\s+insurance\b/i }
|
|
2248
|
+
];
|
|
2249
|
+
function normalizeWhitespace(value) {
|
|
2250
|
+
return value.replace(/\s+/g, " ").trim();
|
|
2251
|
+
}
|
|
2252
|
+
function normalizeOperationalPolicyTypes(values) {
|
|
2253
|
+
const types = Array.isArray(values) ? values.filter((value) => typeof value === "string") : [];
|
|
2254
|
+
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));
|
|
2255
|
+
const unique = [...new Set(controlled)].slice(0, 6);
|
|
2256
|
+
return unique.length ? unique : ["other"];
|
|
2257
|
+
}
|
|
2258
|
+
function hasSpecificPolicyType(types) {
|
|
2259
|
+
return types.some((type) => type !== "other");
|
|
2260
|
+
}
|
|
2261
|
+
function policyTypesFromText(value) {
|
|
2262
|
+
const text = normalizeWhitespace(value ?? "");
|
|
2263
|
+
if (!text) return [];
|
|
2264
|
+
const aliasType = POLICY_TYPE_ALIASES[text.toLowerCase()];
|
|
2265
|
+
if (aliasType && POLICY_TYPE_KEYS.has(aliasType)) return [aliasType];
|
|
2266
|
+
return POLICY_TYPE_TEXT_PATTERNS.filter(({ pattern }) => pattern.test(text)).map(({ type }) => type).filter((type) => POLICY_TYPE_KEYS.has(type));
|
|
2267
|
+
}
|
|
2268
|
+
function inferPolicyTypesFromOperationalCoverages(coverages) {
|
|
2269
|
+
const inferred = [];
|
|
2270
|
+
for (const coverage of coverages) {
|
|
2271
|
+
const limits = coverage.limits ?? [];
|
|
2272
|
+
const text = [
|
|
2273
|
+
coverage.coverageCode,
|
|
2274
|
+
coverage.formNumber,
|
|
2275
|
+
coverage.name,
|
|
2276
|
+
...limits.flatMap((term) => [term.appliesTo, term.label])
|
|
2277
|
+
].filter((value) => typeof value === "string" && value.trim().length > 0);
|
|
2278
|
+
for (const value of text) {
|
|
2279
|
+
for (const type of policyTypesFromText(value)) {
|
|
2280
|
+
if (!inferred.includes(type)) inferred.push(type);
|
|
2281
|
+
}
|
|
2282
|
+
}
|
|
2283
|
+
}
|
|
2284
|
+
return inferred.slice(0, 6);
|
|
2285
|
+
}
|
|
2286
|
+
function resolveOperationalProfilePolicyTypes(params) {
|
|
2287
|
+
const inferred = inferPolicyTypesFromOperationalCoverages(params.coverages ?? []);
|
|
2288
|
+
if (inferred.length > 0) {
|
|
2289
|
+
return { policyTypes: inferred, source: "coverage" };
|
|
2290
|
+
}
|
|
2291
|
+
const controlled = normalizeOperationalPolicyTypes(params.profileTypes);
|
|
2292
|
+
if (hasSpecificPolicyType(controlled)) return { policyTypes: controlled, source: "profile_hint" };
|
|
2293
|
+
const existingControlled = normalizeOperationalPolicyTypes(params.existingTypes);
|
|
2294
|
+
if (hasSpecificPolicyType(existingControlled)) return { policyTypes: existingControlled, source: "existing_hint" };
|
|
2295
|
+
return { policyTypes: controlled, source: "default" };
|
|
2296
|
+
}
|
|
2297
|
+
|
|
2142
2298
|
// src/source/ids.ts
|
|
2143
2299
|
function normalizeText(text) {
|
|
2144
2300
|
return text.replace(/\s+/g, " ").trim();
|
|
@@ -2205,14 +2361,14 @@ function orderSourceEvidence(evidence) {
|
|
|
2205
2361
|
}
|
|
2206
2362
|
|
|
2207
2363
|
// src/source/extraction.ts
|
|
2208
|
-
function
|
|
2364
|
+
function normalizeWhitespace2(value) {
|
|
2209
2365
|
return value.replace(/\s+/g, " ").trim();
|
|
2210
2366
|
}
|
|
2211
2367
|
function sanitizeIdPart(value) {
|
|
2212
2368
|
return value.replace(/[^a-zA-Z0-9_.:-]/g, "_");
|
|
2213
2369
|
}
|
|
2214
2370
|
function buildSourceSpan(input, localIndex = 0) {
|
|
2215
|
-
const text =
|
|
2371
|
+
const text = normalizeWhitespace2(input.text);
|
|
2216
2372
|
const textHash = sourceSpanTextHash(text);
|
|
2217
2373
|
const pagePart = input.pageStart ?? "na";
|
|
2218
2374
|
const id = [
|
|
@@ -2247,7 +2403,7 @@ function buildSourceSpan(input, localIndex = 0) {
|
|
|
2247
2403
|
});
|
|
2248
2404
|
}
|
|
2249
2405
|
function buildPageSourceSpans(pages) {
|
|
2250
|
-
return pages.filter((page) =>
|
|
2406
|
+
return pages.filter((page) => normalizeWhitespace2(page.text).length > 0).map(
|
|
2251
2407
|
(page, index) => buildSourceSpan(
|
|
2252
2408
|
{
|
|
2253
2409
|
documentId: page.documentId,
|
|
@@ -2298,7 +2454,7 @@ function buildSectionSourceSpans(pages, options = {}) {
|
|
|
2298
2454
|
function buildTextSourceSpans(input, options = {}) {
|
|
2299
2455
|
const maxChars = options.maxChars ?? 4e3;
|
|
2300
2456
|
const overlapChars = Math.min(options.overlapChars ?? 0, Math.max(0, maxChars - 1));
|
|
2301
|
-
const text =
|
|
2457
|
+
const text = normalizeWhitespace2(input.text);
|
|
2302
2458
|
if (!text) return [];
|
|
2303
2459
|
const spans = [];
|
|
2304
2460
|
let cursor = 0;
|
|
@@ -2373,7 +2529,7 @@ function spanPage(span) {
|
|
|
2373
2529
|
}
|
|
2374
2530
|
function normalizeSourceSpanText(span) {
|
|
2375
2531
|
const unit = sourceUnit(span);
|
|
2376
|
-
const text =
|
|
2532
|
+
const text = normalizeWhitespace2(span.text);
|
|
2377
2533
|
if (!text) return void 0;
|
|
2378
2534
|
if (isDiscardableBoilerplate(text, unit)) return void 0;
|
|
2379
2535
|
const cleanedText = cleanBoilerplateLines(text);
|
|
@@ -2385,7 +2541,7 @@ function normalizeSourceSpanText(span) {
|
|
|
2385
2541
|
});
|
|
2386
2542
|
}
|
|
2387
2543
|
function isDiscardableBoilerplate(text, unit) {
|
|
2388
|
-
const cleaned =
|
|
2544
|
+
const cleaned = normalizeWhitespace2(text.replace(/\bColumn\s+\d+:\s*/gi, ""));
|
|
2389
2545
|
if (/^SPECIMEN POLICY\s+[-—]\s+FOR TESTING ONLY$/i.test(cleaned)) return true;
|
|
2390
2546
|
if (/^Page\s+\d+\s+of\s+\d+$/i.test(cleaned)) return true;
|
|
2391
2547
|
if (/^[A-Z]{2,}(?:-[A-Z0-9]{2,})+\s+\d{2}\s+\d{2}$/i.test(cleaned)) return true;
|
|
@@ -2394,24 +2550,24 @@ function isDiscardableBoilerplate(text, unit) {
|
|
|
2394
2550
|
return false;
|
|
2395
2551
|
}
|
|
2396
2552
|
function isBoilerplateLine(line) {
|
|
2397
|
-
const cleaned =
|
|
2553
|
+
const cleaned = normalizeWhitespace2(line.replace(/\bColumn\s+\d+:\s*/gi, ""));
|
|
2398
2554
|
return isDiscardableBoilerplate(cleaned) || /^THIS IS A CLAIMS-MADE AND REPORTED POLICY\.? PLEASE READ IT CAREFULLY\.?$/i.test(cleaned);
|
|
2399
2555
|
}
|
|
2400
2556
|
function removedBoilerplateLines(text) {
|
|
2401
|
-
return text.split(/\s{2,}|\r?\n/).map(
|
|
2557
|
+
return text.split(/\s{2,}|\r?\n/).map(normalizeWhitespace2).filter((line) => line && isBoilerplateLine(line));
|
|
2402
2558
|
}
|
|
2403
2559
|
function cleanBoilerplateLines(text) {
|
|
2404
2560
|
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, " ");
|
|
2405
2561
|
const lines = withoutInlineBoilerplate.split(/\r?\n/);
|
|
2406
|
-
const filtered = lines.map(
|
|
2407
|
-
return
|
|
2562
|
+
const filtered = lines.map(normalizeWhitespace2).filter((line) => line && !isBoilerplateLine(line));
|
|
2563
|
+
return normalizeWhitespace2(filtered.join(" "));
|
|
2408
2564
|
}
|
|
2409
2565
|
function shouldMergeTextSpan(left, right) {
|
|
2410
2566
|
if (sourceUnit(left) !== "text" || sourceUnit(right) !== "text") return false;
|
|
2411
2567
|
if (spanPage(left) !== spanPage(right)) return false;
|
|
2412
2568
|
if (left.metadata?.elementType === "title" || right.metadata?.elementType === "title") return false;
|
|
2413
|
-
const leftText =
|
|
2414
|
-
const rightText =
|
|
2569
|
+
const leftText = normalizeWhitespace2(left.text);
|
|
2570
|
+
const rightText = normalizeWhitespace2(right.text);
|
|
2415
2571
|
if (!leftText || !rightText) return false;
|
|
2416
2572
|
if (/[:.;!?)]$/.test(leftText)) return false;
|
|
2417
2573
|
if (/^(?:[A-Z][A-Z0-9 &/(),.-]{8,}|Item\s+\d+|Section\s+\d+|Part\s+[A-Z]\b)/.test(rightText)) return false;
|
|
@@ -2432,7 +2588,7 @@ function mergeTextRuns(spans) {
|
|
|
2432
2588
|
return result;
|
|
2433
2589
|
}
|
|
2434
2590
|
function mergeTextSpanPair(left, right) {
|
|
2435
|
-
const text =
|
|
2591
|
+
const text = normalizeWhitespace2(`${left.text} ${right.text}`);
|
|
2436
2592
|
const merged = retextSpan(left, text, {
|
|
2437
2593
|
mergedSourceSpanIds: [left.metadata?.mergedSourceSpanIds, left.id, right.id, right.metadata?.mergedSourceSpanIds].filter(Boolean).join(","),
|
|
2438
2594
|
sourceSpanNormalization: "merged_text_run"
|
|
@@ -2484,7 +2640,7 @@ function splitPageIntoSections(text, headingPattern, minSectionChars) {
|
|
|
2484
2640
|
if (current) sections.push(current);
|
|
2485
2641
|
const suffix = match[1]?.trim();
|
|
2486
2642
|
current = {
|
|
2487
|
-
title:
|
|
2643
|
+
title: normalizeWhitespace2(suffix ? `${line}` : line).slice(0, 120),
|
|
2488
2644
|
lines: [line]
|
|
2489
2645
|
};
|
|
2490
2646
|
continue;
|
|
@@ -2494,7 +2650,7 @@ function splitPageIntoSections(text, headingPattern, minSectionChars) {
|
|
|
2494
2650
|
if (current) sections.push(current);
|
|
2495
2651
|
return sections.map((section) => ({
|
|
2496
2652
|
title: section.title,
|
|
2497
|
-
text:
|
|
2653
|
+
text: normalizeWhitespace2(section.lines.join("\n"))
|
|
2498
2654
|
})).filter((section) => section.text.length >= minSectionChars);
|
|
2499
2655
|
}
|
|
2500
2656
|
function inferFormNumber(text) {
|
|
@@ -2595,14 +2751,14 @@ function matchesFilters(span, filters) {
|
|
|
2595
2751
|
}
|
|
2596
2752
|
|
|
2597
2753
|
// src/source/tree.ts
|
|
2598
|
-
function
|
|
2754
|
+
function normalizeWhitespace3(value) {
|
|
2599
2755
|
return value.replace(/\s+/g, " ").trim();
|
|
2600
2756
|
}
|
|
2601
2757
|
function sanitizeIdPart2(value) {
|
|
2602
2758
|
return value.replace(/[^a-zA-Z0-9_.:-]/g, "_");
|
|
2603
2759
|
}
|
|
2604
2760
|
function truncate(value, maxChars) {
|
|
2605
|
-
const text =
|
|
2761
|
+
const text = normalizeWhitespace3(value);
|
|
2606
2762
|
return text.length > maxChars ? `${text.slice(0, maxChars).trimEnd()}...` : text;
|
|
2607
2763
|
}
|
|
2608
2764
|
function pageStart(span) {
|
|
@@ -2696,7 +2852,7 @@ function isTitleContentNode(node) {
|
|
|
2696
2852
|
if (node.kind !== "text") return false;
|
|
2697
2853
|
const isMarkedTitle = metadataString(node.metadata, "elementType") === "title" || metadataString(node.metadata, "sourceUnit") === "title";
|
|
2698
2854
|
if (!isMarkedTitle) return false;
|
|
2699
|
-
const text =
|
|
2855
|
+
const text = normalizeWhitespace3(node.textExcerpt ?? node.title);
|
|
2700
2856
|
if (!text || text.length > 140) return false;
|
|
2701
2857
|
const words = text.split(/\s+/);
|
|
2702
2858
|
if (words.length > 14) return false;
|
|
@@ -3371,12 +3527,12 @@ function shouldFailQualityGate(mode, status) {
|
|
|
3371
3527
|
import { z as z22 } from "zod";
|
|
3372
3528
|
|
|
3373
3529
|
// src/source/operational-profile.ts
|
|
3374
|
-
function
|
|
3530
|
+
function normalizeWhitespace4(value) {
|
|
3375
3531
|
return value.replace(/\s+/g, " ").trim();
|
|
3376
3532
|
}
|
|
3377
3533
|
function cleanValue(value) {
|
|
3378
3534
|
if (!value) return void 0;
|
|
3379
|
-
return
|
|
3535
|
+
return normalizeWhitespace4(value.replace(/^[\s:;#-]+|[\s;,.]+$/g, ""));
|
|
3380
3536
|
}
|
|
3381
3537
|
var OPERATIONAL_COVERAGE_TERM_KINDS = /* @__PURE__ */ new Set([
|
|
3382
3538
|
"each_claim_limit",
|
|
@@ -3458,6 +3614,7 @@ function mergeOperationalProfile(base, candidate, validNodeIds, validSpanIds) {
|
|
|
3458
3614
|
...keepIds(record.sourceSpanIds, validSpanIds),
|
|
3459
3615
|
...limits.flatMap((term) => term.sourceSpanIds)
|
|
3460
3616
|
])];
|
|
3617
|
+
if (!name || sourceNodeIds2.length === 0 && sourceSpanIds2.length === 0) return void 0;
|
|
3461
3618
|
return {
|
|
3462
3619
|
name,
|
|
3463
3620
|
coverageCode: typeof record.coverageCode === "string" ? cleanValue(record.coverageCode) : void 0,
|
|
@@ -3472,7 +3629,7 @@ function mergeOperationalProfile(base, candidate, validNodeIds, validSpanIds) {
|
|
|
3472
3629
|
sourceNodeIds: sourceNodeIds2,
|
|
3473
3630
|
sourceSpanIds: sourceSpanIds2
|
|
3474
3631
|
};
|
|
3475
|
-
}).filter((coverage) =>
|
|
3632
|
+
}).filter((coverage) => Boolean(coverage)) : base.coverages;
|
|
3476
3633
|
const sourceBackedParty = (role, value) => value ? {
|
|
3477
3634
|
role,
|
|
3478
3635
|
name: value.normalizedValue ?? value.value,
|
|
@@ -3540,10 +3697,15 @@ function mergeOperationalProfile(base, candidate, validNodeIds, validSpanIds) {
|
|
|
3540
3697
|
...base.warnings,
|
|
3541
3698
|
...Array.isArray(candidate.warnings) ? candidate.warnings.filter((warning) => typeof warning === "string" && warning.trim().length > 0) : []
|
|
3542
3699
|
];
|
|
3700
|
+
const resolvedPolicyTypes = resolveOperationalProfilePolicyTypes({
|
|
3701
|
+
profileTypes: candidate.policyTypes,
|
|
3702
|
+
existingTypes: base.policyTypes,
|
|
3703
|
+
coverages
|
|
3704
|
+
});
|
|
3543
3705
|
return PolicyOperationalProfileSchema.parse({
|
|
3544
3706
|
...base,
|
|
3545
3707
|
documentType: candidate.documentType === "policy" ? "policy" : base.documentType,
|
|
3546
|
-
policyTypes:
|
|
3708
|
+
policyTypes: resolvedPolicyTypes.policyTypes,
|
|
3547
3709
|
policyNumber,
|
|
3548
3710
|
namedInsured,
|
|
3549
3711
|
insurer,
|
|
@@ -12775,6 +12937,7 @@ export {
|
|
|
12775
12937
|
getNextApplicationQuestions,
|
|
12776
12938
|
getPdfPageCount,
|
|
12777
12939
|
getTemplate,
|
|
12940
|
+
inferPolicyTypesFromOperationalCoverages,
|
|
12778
12941
|
isDoclingExtractionInput,
|
|
12779
12942
|
isFileReference,
|
|
12780
12943
|
mergeQuestionAnswers,
|
|
@@ -12783,6 +12946,7 @@ export {
|
|
|
12783
12946
|
normalizeDoclingDocument,
|
|
12784
12947
|
normalizeDocumentSourceTreePaths,
|
|
12785
12948
|
normalizeForMatch,
|
|
12949
|
+
normalizeOperationalPolicyTypes,
|
|
12786
12950
|
normalizeSourceSpans,
|
|
12787
12951
|
orderSourceEvidence,
|
|
12788
12952
|
overlayTextOnPdf,
|
|
@@ -12793,6 +12957,7 @@ export {
|
|
|
12793
12957
|
processReply,
|
|
12794
12958
|
proposeContextWrites,
|
|
12795
12959
|
resolveModelBudget,
|
|
12960
|
+
resolveOperationalProfilePolicyTypes,
|
|
12796
12961
|
safeGenerateObject,
|
|
12797
12962
|
sanitizeNulls,
|
|
12798
12963
|
scoreCaseProposal,
|