@claritylabs/cl-sdk 4.1.0 → 4.2.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/application.d.mts +1 -1
- package/dist/application.d.ts +1 -1
- package/dist/application.js +1 -0
- package/dist/application.js.map +1 -1
- package/dist/application.mjs +1 -0
- package/dist/application.mjs.map +1 -1
- package/dist/{index-BzrY6OMD.d.mts → index-C9XfOdmx.d.mts} +9 -0
- package/dist/{index-BzrY6OMD.d.ts → index-C9XfOdmx.d.ts} +9 -0
- package/dist/index.d.mts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +80 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +78 -12
- package/dist/index.mjs.map +1 -1
- package/dist/storage-sqlite.js +1 -0
- package/dist/storage-sqlite.js.map +1 -1
- package/dist/storage-sqlite.mjs +1 -0
- package/dist/storage-sqlite.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2416,6 +2416,7 @@ var OperationalCoverageTermSchema = z21.object({
|
|
|
2416
2416
|
});
|
|
2417
2417
|
var OperationalCoverageLineSchema = z21.object({
|
|
2418
2418
|
name: z21.string(),
|
|
2419
|
+
lineOfBusiness: AcordLobCodeSchema.optional(),
|
|
2419
2420
|
coverageCode: z21.string().optional(),
|
|
2420
2421
|
limit: z21.string().optional(),
|
|
2421
2422
|
deductible: z21.string().optional(),
|
|
@@ -2525,6 +2526,9 @@ function normalizeWhitespace(value) {
|
|
|
2525
2526
|
function hasSpecificLineOfBusiness(codes) {
|
|
2526
2527
|
return codes.some((code) => code !== "UN");
|
|
2527
2528
|
}
|
|
2529
|
+
function specificLineOfBusinessCodes(codes) {
|
|
2530
|
+
return Array.from(new Set(codes.filter((code) => code !== "UN")));
|
|
2531
|
+
}
|
|
2528
2532
|
function linesOfBusinessFromText(value) {
|
|
2529
2533
|
const text = normalizeWhitespace(value ?? "");
|
|
2530
2534
|
if (!text) return [];
|
|
@@ -2533,20 +2537,53 @@ function linesOfBusinessFromText(value) {
|
|
|
2533
2537
|
const inferred = LOB_TEXT_PATTERNS.flatMap(({ codes, pattern }) => pattern.test(text) ? codes : []);
|
|
2534
2538
|
return Array.from(new Set(inferred));
|
|
2535
2539
|
}
|
|
2540
|
+
function coverageLineOfBusinessCandidates(coverage) {
|
|
2541
|
+
const limits = coverage.limits ?? [];
|
|
2542
|
+
const text = [
|
|
2543
|
+
coverage.coverageCode,
|
|
2544
|
+
coverage.formNumber,
|
|
2545
|
+
coverage.sectionRef,
|
|
2546
|
+
coverage.name,
|
|
2547
|
+
...limits.map((term) => term.appliesTo)
|
|
2548
|
+
].filter((value) => typeof value === "string" && value.trim().length > 0);
|
|
2549
|
+
const inferred = [];
|
|
2550
|
+
for (const value of text) {
|
|
2551
|
+
for (const code of linesOfBusinessFromText(value)) {
|
|
2552
|
+
if (code !== "UN" && !inferred.includes(code)) inferred.push(code);
|
|
2553
|
+
}
|
|
2554
|
+
}
|
|
2555
|
+
return inferred;
|
|
2556
|
+
}
|
|
2557
|
+
function explicitCoverageLineOfBusiness(coverage) {
|
|
2558
|
+
if (!coverage.lineOfBusiness) return void 0;
|
|
2559
|
+
const [code] = normalizeOperationalLinesOfBusiness([coverage.lineOfBusiness]);
|
|
2560
|
+
return code && code !== "UN" ? code : void 0;
|
|
2561
|
+
}
|
|
2562
|
+
function inferLineOfBusinessForOperationalCoverage(coverage, profileLinesOfBusiness) {
|
|
2563
|
+
const explicit = explicitCoverageLineOfBusiness(coverage);
|
|
2564
|
+
if (explicit) return explicit;
|
|
2565
|
+
const inferred = coverageLineOfBusinessCandidates(coverage);
|
|
2566
|
+
if (inferred.length === 1) return inferred[0];
|
|
2567
|
+
if (inferred.length > 1) return void 0;
|
|
2568
|
+
const fallback = specificLineOfBusinessCodes(normalizeOperationalLinesOfBusiness(profileLinesOfBusiness));
|
|
2569
|
+
return fallback.length === 1 ? fallback[0] : void 0;
|
|
2570
|
+
}
|
|
2571
|
+
function annotateOperationalCoverageLinesOfBusiness(coverages, profileLinesOfBusiness) {
|
|
2572
|
+
return coverages.map((coverage) => {
|
|
2573
|
+
const lineOfBusiness = inferLineOfBusinessForOperationalCoverage(coverage, profileLinesOfBusiness);
|
|
2574
|
+
if (lineOfBusiness) return { ...coverage, lineOfBusiness };
|
|
2575
|
+
const next = { ...coverage };
|
|
2576
|
+
delete next.lineOfBusiness;
|
|
2577
|
+
return next;
|
|
2578
|
+
});
|
|
2579
|
+
}
|
|
2536
2580
|
function inferLinesOfBusinessFromOperationalCoverages(coverages) {
|
|
2537
2581
|
const inferred = [];
|
|
2538
2582
|
for (const coverage of coverages) {
|
|
2539
|
-
const
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
coverage.name,
|
|
2544
|
-
...limits.flatMap((term) => [term.appliesTo, term.label])
|
|
2545
|
-
].filter((value) => typeof value === "string" && value.trim().length > 0);
|
|
2546
|
-
for (const value of text) {
|
|
2547
|
-
for (const code of linesOfBusinessFromText(value)) {
|
|
2548
|
-
if (!inferred.includes(code)) inferred.push(code);
|
|
2549
|
-
}
|
|
2583
|
+
const explicit = explicitCoverageLineOfBusiness(coverage);
|
|
2584
|
+
if (explicit && !inferred.includes(explicit)) inferred.push(explicit);
|
|
2585
|
+
for (const code of coverageLineOfBusinessCandidates(coverage)) {
|
|
2586
|
+
if (!inferred.includes(code)) inferred.push(code);
|
|
2550
2587
|
}
|
|
2551
2588
|
}
|
|
2552
2589
|
return inferred.slice(0, 6);
|
|
@@ -3802,6 +3839,11 @@ function cleanValue(value) {
|
|
|
3802
3839
|
if (!value) return void 0;
|
|
3803
3840
|
return normalizeWhitespace4(value.replace(/^[\s:;#-]+|[\s;,.]+$/g, ""));
|
|
3804
3841
|
}
|
|
3842
|
+
function cleanCoverageLineOfBusiness(value) {
|
|
3843
|
+
if (typeof value !== "string" || !value.trim()) return void 0;
|
|
3844
|
+
const [code] = normalizeOperationalLinesOfBusiness([value]);
|
|
3845
|
+
return code && code !== "UN" ? code : void 0;
|
|
3846
|
+
}
|
|
3805
3847
|
function normalizedFactValue(value) {
|
|
3806
3848
|
return value.toLowerCase().replace(/&/g, " and ").replace(/[.,#]/g, " ").replace(/\s+/g, " ").trim();
|
|
3807
3849
|
}
|
|
@@ -3961,6 +4003,7 @@ function mergeOperationalProfile(base, candidate, validNodeIds, validSpanIds) {
|
|
|
3961
4003
|
if (!name || sourceNodeIds2.length === 0 && sourceSpanIds2.length === 0) return void 0;
|
|
3962
4004
|
return {
|
|
3963
4005
|
name,
|
|
4006
|
+
lineOfBusiness: cleanCoverageLineOfBusiness(record.lineOfBusiness),
|
|
3964
4007
|
coverageCode: typeof record.coverageCode === "string" ? cleanValue(record.coverageCode) : void 0,
|
|
3965
4008
|
limit: typeof record.limit === "string" ? cleanValue(record.limit) : void 0,
|
|
3966
4009
|
deductible: typeof record.deductible === "string" ? cleanValue(record.deductible) : void 0,
|
|
@@ -4050,6 +4093,10 @@ function mergeOperationalProfile(base, candidate, validNodeIds, validSpanIds) {
|
|
|
4050
4093
|
existingLinesOfBusiness: baseLinesOfBusiness,
|
|
4051
4094
|
coverages
|
|
4052
4095
|
});
|
|
4096
|
+
const annotatedCoverages = annotateOperationalCoverageLinesOfBusiness(
|
|
4097
|
+
coverages,
|
|
4098
|
+
resolvedLinesOfBusiness.linesOfBusiness
|
|
4099
|
+
);
|
|
4053
4100
|
return PolicyOperationalProfileSchema.parse({
|
|
4054
4101
|
...base,
|
|
4055
4102
|
documentType: candidate.documentType === "policy" ? "policy" : base.documentType,
|
|
@@ -4063,7 +4110,7 @@ function mergeOperationalProfile(base, candidate, validNodeIds, validSpanIds) {
|
|
|
4063
4110
|
retroactiveDate,
|
|
4064
4111
|
premium,
|
|
4065
4112
|
declarationFacts,
|
|
4066
|
-
coverages,
|
|
4113
|
+
coverages: annotatedCoverages,
|
|
4067
4114
|
parties,
|
|
4068
4115
|
endorsementSupport,
|
|
4069
4116
|
sourceNodeIds,
|
|
@@ -4093,6 +4140,7 @@ var OperationalProfileCleanupSchema = z22.object({
|
|
|
4093
4140
|
action: z22.enum(["keep", "drop", "update"]),
|
|
4094
4141
|
reason: z22.string().optional(),
|
|
4095
4142
|
name: z22.string().optional(),
|
|
4143
|
+
lineOfBusiness: z22.string().nullable().optional(),
|
|
4096
4144
|
limit: z22.string().nullable().optional(),
|
|
4097
4145
|
deductible: z22.string().nullable().optional(),
|
|
4098
4146
|
premium: z22.string().nullable().optional(),
|
|
@@ -4137,6 +4185,7 @@ function compactCoverageForCleanup(coverage, coverageIndex) {
|
|
|
4137
4185
|
return {
|
|
4138
4186
|
coverageIndex,
|
|
4139
4187
|
name: coverage.name,
|
|
4188
|
+
lineOfBusiness: coverage.lineOfBusiness,
|
|
4140
4189
|
limit: coverage.limit,
|
|
4141
4190
|
deductible: coverage.deductible,
|
|
4142
4191
|
premium: coverage.premium,
|
|
@@ -4166,6 +4215,7 @@ function nodeTextForSelection(node) {
|
|
|
4166
4215
|
function coverageTextForSelection(coverage) {
|
|
4167
4216
|
return [
|
|
4168
4217
|
coverage.name,
|
|
4218
|
+
coverage.lineOfBusiness,
|
|
4169
4219
|
coverage.coverageCode,
|
|
4170
4220
|
coverage.limit,
|
|
4171
4221
|
coverage.deductible,
|
|
@@ -4459,6 +4509,15 @@ function applyCoverageCleanupDecision(coverage, decision, validNodeIds, validSpa
|
|
|
4459
4509
|
};
|
|
4460
4510
|
const name = cleanProfileValue(decision.name);
|
|
4461
4511
|
if (name) next.name = name;
|
|
4512
|
+
if (decision.lineOfBusiness != null) {
|
|
4513
|
+
const value = cleanProfileValue(decision.lineOfBusiness);
|
|
4514
|
+
if (value) {
|
|
4515
|
+
const parsed = AcordLobCodeSchema.safeParse(value);
|
|
4516
|
+
if (parsed.success && parsed.data !== "UN") next.lineOfBusiness = parsed.data;
|
|
4517
|
+
} else {
|
|
4518
|
+
delete next.lineOfBusiness;
|
|
4519
|
+
}
|
|
4520
|
+
}
|
|
4462
4521
|
if (decision.limit != null) {
|
|
4463
4522
|
const value = cleanProfileValue(decision.limit);
|
|
4464
4523
|
if (value) next.limit = value;
|
|
@@ -4621,6 +4680,7 @@ var OperationalProfilePromptSchema = z23.object({
|
|
|
4621
4680
|
declarationFacts: z23.array(OperationalDeclarationFactForPromptSchema).optional(),
|
|
4622
4681
|
coverages: z23.array(z23.object({
|
|
4623
4682
|
name: z23.string(),
|
|
4683
|
+
lineOfBusiness: z23.string().optional(),
|
|
4624
4684
|
coverageCode: z23.string().optional(),
|
|
4625
4685
|
limit: z23.string().optional(),
|
|
4626
4686
|
deductible: z23.string().optional(),
|
|
@@ -5671,6 +5731,7 @@ Return only high-value operational facts needed for policy lists, Q&A, complianc
|
|
|
5671
5731
|
- source-backed declarationFacts for named-insured identity details: named insured, mailing address, DBA, entity type, tax ID/FEIN, additional named insureds, and other durable declaration-page identity facts
|
|
5672
5732
|
- coverage units with their own nested limit terms, deductibles/retentions, retroactive dates, premiums, and form references
|
|
5673
5733
|
- coverage type labels
|
|
5734
|
+
- coverage lineOfBusiness ACORD codes when a coverage unit can be assigned to one specific line
|
|
5674
5735
|
|
|
5675
5736
|
Rules:
|
|
5676
5737
|
- Every returned value must include sourceNodeIds or sourceSpanIds from the provided evidence.
|
|
@@ -5684,6 +5745,8 @@ Rules:
|
|
|
5684
5745
|
- On declarations pages, treat "Item N" labels as section boundaries. Use Item 6 or equivalent coverage-schedule rows for coverage limits, deductibles, aggregate terms, and retroactive dates; do not merge Item 7 premium, Item 8 ERP, Item 9 producer, or Item 10 forms into Item 6 coverage facts.
|
|
5685
5746
|
- Premium, tax, fee, payment-plan, rating, exposure, and reporting-value schedules are billing evidence, not coverage schedules. Extract the total policy premium into premium when supported, but do not create coverages[] entries from premium-only or fee-only rows, and never use Total Premium, MGA Fee, tax, stamping fee, reporting values, or exposure annual rate as a coverage limit.
|
|
5686
5747
|
- A coverage schedule row's coverage name should come from the "Coverage Part" or equivalent row label. Limit, deductible, aggregate, sublimit, retention, and retroactive-date values belong as nested terms under that coverage, not in the coverage title.
|
|
5748
|
+
- Put the ACORD line of business code for each coverage unit in coverages[].lineOfBusiness only when the row belongs to one specific line, such as CGL, AUTOB, WORK, UMBRC, EXLIA, EO, OLIB, EPLI, DO, FIDUC, CRIME, INMRC, COMAR, PROPC, PROP, BOP, HOME, DFIRE, FLOOD, or GARAG. Do not use limit labels such as Each Occurrence, Aggregate, Products-Completed Operations Aggregate, deductible, retention, retroactive date, or sublimit as lines of business.
|
|
5749
|
+
- If a package or multi-line row cannot be assigned to exactly one ACORD line, omit coverages[].lineOfBusiness for that coverage.
|
|
5687
5750
|
- If a coverage schedule continues onto the next page before the next item marker, include the continuation rows in the same coverage or declaration item.
|
|
5688
5751
|
- If one schedule row or continuation row states the same amount with multiple bases, such as "$1,000,000 Each Claim / Aggregate", return separate limit terms for each basis using the same value instead of one combined "Each Claim / Aggregate" term.
|
|
5689
5752
|
- LiteParse text can fragment visual table cells into adjacent lines. Before extracting coverage terms, mentally join adjacent lines in the same declaration item or schedule row. For example, "$2,000,000 Policy Each Claim" followed immediately by "Aggregate" means "$2,000,000 Policy Aggregate"; a line ending with "/" followed by "Aggregate ..." means the limit cell continues, not a new coverage.
|
|
@@ -5828,6 +5891,7 @@ function materializeDocument(params) {
|
|
|
5828
5891
|
});
|
|
5829
5892
|
const coverages = profile.coverages.map((coverage) => ({
|
|
5830
5893
|
name: coverage.name,
|
|
5894
|
+
lineOfBusiness: coverage.lineOfBusiness,
|
|
5831
5895
|
coverageCode: coverage.coverageCode,
|
|
5832
5896
|
limit: coverage.limit,
|
|
5833
5897
|
deductible: coverage.deductible,
|
|
@@ -13338,6 +13402,7 @@ export {
|
|
|
13338
13402
|
VerifyResultSchema,
|
|
13339
13403
|
WatercraftDeclarationsSchema,
|
|
13340
13404
|
WorkersCompDeclarationsSchema,
|
|
13405
|
+
annotateOperationalCoverageLinesOfBusiness,
|
|
13341
13406
|
applyApplicationAnswers,
|
|
13342
13407
|
buildAcroFormMappingPrompt,
|
|
13343
13408
|
buildAgentSystemPrompt,
|
|
@@ -13404,6 +13469,7 @@ export {
|
|
|
13404
13469
|
getNextApplicationQuestions,
|
|
13405
13470
|
getPdfPageCount,
|
|
13406
13471
|
getTemplate,
|
|
13472
|
+
inferLineOfBusinessForOperationalCoverage,
|
|
13407
13473
|
inferLinesOfBusinessFromOperationalCoverages,
|
|
13408
13474
|
isDoclingExtractionInput,
|
|
13409
13475
|
isFileReference,
|