@claritylabs/cl-sdk 3.2.8 → 3.2.9
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 +14 -81
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -81
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3576,16 +3576,6 @@ var OPERATIONAL_COVERAGE_TERM_KINDS2 = [
|
|
|
3576
3576
|
"other"
|
|
3577
3577
|
];
|
|
3578
3578
|
var OperationalCoverageTermKindSchema = z21.enum(OPERATIONAL_COVERAGE_TERM_KINDS2);
|
|
3579
|
-
var CleanupTermSchema = z21.object({
|
|
3580
|
-
kind: OperationalCoverageTermKindSchema,
|
|
3581
|
-
label: z21.string(),
|
|
3582
|
-
value: z21.string(),
|
|
3583
|
-
amount: z21.number().nullable().optional(),
|
|
3584
|
-
appliesTo: z21.string().nullable().optional(),
|
|
3585
|
-
sourceNodeIds: z21.array(z21.string()).optional(),
|
|
3586
|
-
sourceSpanIds: z21.array(z21.string()).optional(),
|
|
3587
|
-
reason: z21.string().optional()
|
|
3588
|
-
});
|
|
3589
3579
|
var OperationalProfileCleanupSchema = z21.object({
|
|
3590
3580
|
coverageDecisions: z21.array(z21.object({
|
|
3591
3581
|
coverageIndex: z21.number().int().nonnegative(),
|
|
@@ -3609,8 +3599,7 @@ var OperationalProfileCleanupSchema = z21.object({
|
|
|
3609
3599
|
appliesTo: z21.string().nullable().optional(),
|
|
3610
3600
|
sourceNodeIds: z21.array(z21.string()).optional(),
|
|
3611
3601
|
sourceSpanIds: z21.array(z21.string()).optional()
|
|
3612
|
-
})).optional()
|
|
3613
|
-
termAdditions: z21.array(CleanupTermSchema).optional()
|
|
3602
|
+
})).optional()
|
|
3614
3603
|
})).default([]),
|
|
3615
3604
|
warnings: z21.array(z21.string()).default([])
|
|
3616
3605
|
});
|
|
@@ -3618,7 +3607,6 @@ var CLEANUP_CANDIDATE_ID_LIMIT = 12;
|
|
|
3618
3607
|
var CLEANUP_SOURCE_NODE_LIMIT = 90;
|
|
3619
3608
|
var CLEANUP_SIBLING_WINDOW = 4;
|
|
3620
3609
|
var CLEANUP_KEYWORD = /\b(coverage|limit|liability|deductible|retention|retroactive|premium|aggregate|sublimit|sub-limit|claim|occurrence|loss|proceeding|endorsement|declarations?)\b|\$[0-9]/i;
|
|
3621
|
-
var CLEANUP_CONTINUATION_KEYWORD = /\b(coverage part|limit of liability|deductible|retention|retroactive date|aggregate|sublimit|sub-limit|each claim|each occurrence|each loss|each proceeding|coinsurance)\b|\$[0-9]/i;
|
|
3622
3610
|
function compactNode(node, maxText = 700) {
|
|
3623
3611
|
return {
|
|
3624
3612
|
id: node.id,
|
|
@@ -3747,15 +3735,11 @@ function selectCoverageCleanupNodes(sourceTree, coverages) {
|
|
|
3747
3735
|
const children = childrenByParent.get(selectedNode.id) ?? [];
|
|
3748
3736
|
for (const child of children.slice(0, 24)) addNode(child, 760);
|
|
3749
3737
|
}
|
|
3750
|
-
const continuationPages = new Set([...coveragePages].map((page) => page + 1));
|
|
3751
3738
|
for (const node of sourceTree) {
|
|
3752
3739
|
if (node.kind === "document") continue;
|
|
3753
|
-
if (
|
|
3754
|
-
const samePage = coveragePages.has(node.pageStart);
|
|
3755
|
-
const nearbyContinuationPage = continuationPages.has(node.pageStart);
|
|
3756
|
-
if (!samePage && !nearbyContinuationPage) continue;
|
|
3740
|
+
if (!node.pageStart || !coveragePages.has(node.pageStart)) continue;
|
|
3757
3741
|
const text = nodeTextForSelection(node);
|
|
3758
|
-
if (CLEANUP_KEYWORD.test(text) || nodeTextMatchesCoverage(node, coverageTerms)
|
|
3742
|
+
if (CLEANUP_KEYWORD.test(text) || nodeTextMatchesCoverage(node, coverageTerms)) {
|
|
3759
3743
|
addNode(node, 600);
|
|
3760
3744
|
}
|
|
3761
3745
|
}
|
|
@@ -3769,7 +3753,7 @@ function buildOperationalProfileCleanupPrompt(sourceTree, profile, options = {})
|
|
|
3769
3753
|
const coverageEntries = coverageCleanupEntries(profile, options.coverageIndexes);
|
|
3770
3754
|
const nodes = selectCoverageCleanupNodes(sourceTree, coverageEntries.map((entry) => entry.coverage)).map((node) => compactNode(
|
|
3771
3755
|
node,
|
|
3772
|
-
node.kind === "page" || node.kind === "page_group" ?
|
|
3756
|
+
node.kind === "page" || node.kind === "page_group" ? 260 : node.kind === "table_row" || node.kind === "table_cell" ? 520 : 360
|
|
3773
3757
|
));
|
|
3774
3758
|
const candidate = {
|
|
3775
3759
|
documentType: profile.documentType,
|
|
@@ -3793,23 +3777,20 @@ Projection defects to look for:
|
|
|
3793
3777
|
- Item references such as "shown in Item 7" or bare item numbers treated as money amounts.
|
|
3794
3778
|
- Policy wording, exclusions, or unsupported prose copied into operational limit/deductible fields.
|
|
3795
3779
|
- Header/value splits where "Limit of Liability", "Deductible", "Retroactive Date", "Aggregate", "Each Claim", or similar terms are attached to the wrong coverage row.
|
|
3796
|
-
- Collapsed combined bases where one candidate term says "Each Claim / Aggregate", "Each Loss / Aggregate", "Each Proceeding / Aggregate", or a continuation line supplies a separate policy aggregate, sub-limit, deductible, retention, retroactive date, or coinsurance term.
|
|
3797
3780
|
- Repeated schedule headings projected as separate coverages when they only introduce the next coverage group.
|
|
3798
3781
|
|
|
3799
3782
|
Rules:
|
|
3800
3783
|
- Use internal reasoning, but return JSON decisions only.
|
|
3801
|
-
- Do not invent policy facts. Keep, drop, or update only existing coverageIndex and termIndex entries
|
|
3784
|
+
- Do not invent policy facts. Keep, drop, or update only existing coverageIndex and termIndex entries.
|
|
3802
3785
|
- Use sourceNodeIds and sourceSpanIds only from the provided source nodes or from the existing candidate entry.
|
|
3803
3786
|
- Prefer dropping a malformed fact over speculative rewriting.
|
|
3804
3787
|
- Keep a coverage when it is a real operational coverage/benefit even if only one term needs cleanup.
|
|
3805
3788
|
- Never drop a declaration or schedule coverage row that names a coverage and states policy-specific amounts, dates, deductibles, retentions, premiums, or coverage terms. Repair its terms instead.
|
|
3806
3789
|
- When changing a term's semantic meaning, set kind to the corrected normalized term kind.
|
|
3807
|
-
- Do not add new coverage rows.
|
|
3808
|
-
-
|
|
3809
|
-
- When replacing one combined term with split terms, drop the combined term and add one term per basis. For example, "$1,000,000 Each Claim / Aggregate" should become one each_claim_limit term and one aggregate_limit term, both with value "$1,000,000".
|
|
3810
|
-
- When a schedule continues onto the next page before the next item marker, attach continuation terms such as "Aggregate", "Policy Aggregate", coinsurance, deductible, or retroactive date to the previous coverage row.
|
|
3790
|
+
- Do not add new coverage rows or new terms; this pass cleans the existing projection.
|
|
3791
|
+
- If one existing term combines multiple real limit bases, such as "Each Claim / Aggregate", keep the combined term unless another existing term already represents the other basis. Do not relabel it to only one basis and lose information.
|
|
3811
3792
|
- Include every JSON key in each decision. Use null for scalar fields you are not changing and [] for source ID lists you are not changing.
|
|
3812
|
-
- For each coverage decision, always include termDecisions
|
|
3793
|
+
- For each coverage decision, always include termDecisions. Use [] when no terms need cleanup.
|
|
3813
3794
|
- Keep reasons concise and factual.
|
|
3814
3795
|
|
|
3815
3796
|
Candidate projection:
|
|
@@ -3950,50 +3931,9 @@ function applyTermCleanupDecision(term, decision, validNodeIds, validSpanIds) {
|
|
|
3950
3931
|
}
|
|
3951
3932
|
return next;
|
|
3952
3933
|
}
|
|
3953
|
-
function termAdditionTouches(addition, predicate) {
|
|
3954
|
-
return predicate({
|
|
3955
|
-
kind: addition.kind,
|
|
3956
|
-
label: cleanProfileValue(addition.label) ?? "",
|
|
3957
|
-
value: cleanProfileValue(addition.value) ?? ""
|
|
3958
|
-
});
|
|
3959
|
-
}
|
|
3960
3934
|
function termDecisionsTouch(coverage, decisions, predicate) {
|
|
3961
3935
|
return decisions.filter((decision) => decision.action !== "keep").some((decision) => termDecisionTouches(coverage, decision, predicate));
|
|
3962
3936
|
}
|
|
3963
|
-
function termAdditionsTouch(additions, predicate) {
|
|
3964
|
-
return additions.some((addition) => termAdditionTouches(addition, predicate));
|
|
3965
|
-
}
|
|
3966
|
-
function termKey(term) {
|
|
3967
|
-
return [
|
|
3968
|
-
term.kind,
|
|
3969
|
-
cleanProfileValue(term.label)?.toLowerCase(),
|
|
3970
|
-
cleanProfileValue(term.value)?.toLowerCase()
|
|
3971
|
-
].join("|");
|
|
3972
|
-
}
|
|
3973
|
-
function applyTermAddition(addition, validNodeIds, validSpanIds) {
|
|
3974
|
-
const label = cleanProfileValue(addition.label);
|
|
3975
|
-
const value = cleanProfileValue(addition.value);
|
|
3976
|
-
if (!label || !value) return void 0;
|
|
3977
|
-
const sourceNodeIds = validIds(addition.sourceNodeIds, validNodeIds);
|
|
3978
|
-
const sourceSpanIds = validIds(addition.sourceSpanIds, validSpanIds);
|
|
3979
|
-
if (sourceNodeIds.length === 0 && sourceSpanIds.length === 0) return void 0;
|
|
3980
|
-
const term = {
|
|
3981
|
-
kind: addition.kind,
|
|
3982
|
-
label,
|
|
3983
|
-
value,
|
|
3984
|
-
sourceNodeIds,
|
|
3985
|
-
sourceSpanIds
|
|
3986
|
-
};
|
|
3987
|
-
if (typeof addition.amount === "number" && Number.isFinite(addition.amount)) {
|
|
3988
|
-
term.amount = addition.amount;
|
|
3989
|
-
} else if (term.kind !== "retroactive_date") {
|
|
3990
|
-
const amount = amountFromOperationalValue(value);
|
|
3991
|
-
if (amount !== void 0) term.amount = amount;
|
|
3992
|
-
}
|
|
3993
|
-
const appliesTo = cleanProfileValue(addition.appliesTo);
|
|
3994
|
-
if (appliesTo) term.appliesTo = appliesTo;
|
|
3995
|
-
return term;
|
|
3996
|
-
}
|
|
3997
3937
|
function applyCoverageCleanupDecision(coverage, decision, validNodeIds, validSpanIds) {
|
|
3998
3938
|
if (!decision || decision.action === "keep") return coverage;
|
|
3999
3939
|
if (decision.action === "drop") return void 0;
|
|
@@ -4024,31 +3964,23 @@ function applyCoverageCleanupDecision(coverage, decision, validNodeIds, validSpa
|
|
|
4024
3964
|
const termDecisions = (decision.termDecisions ?? []).filter((termDecision) => termDecision.termIndex < coverage.limits.length);
|
|
4025
3965
|
const termDecisionByIndex = new Map(termDecisions.map((termDecision) => [termDecision.termIndex, termDecision]));
|
|
4026
3966
|
next.limits = coverage.limits.map((term, index) => applyTermCleanupDecision(term, termDecisionByIndex.get(index), validNodeIds, validSpanIds)).filter((term) => Boolean(term));
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
for (const term of termAdditions) {
|
|
4030
|
-
const key = termKey(term);
|
|
4031
|
-
if (existingTermKeys.has(key)) continue;
|
|
4032
|
-
next.limits.push(term);
|
|
4033
|
-
existingTermKeys.add(key);
|
|
4034
|
-
}
|
|
4035
|
-
if (termDecisions.length > 0 || termAdditions.length > 0) {
|
|
4036
|
-
if (decision.limit == null && (termDecisionsTouch(coverage, termDecisions, isLimitTerm) || termAdditionsTouch(termAdditions, isLimitTerm))) {
|
|
3967
|
+
if (termDecisions.length > 0) {
|
|
3968
|
+
if (decision.limit == null && termDecisionsTouch(coverage, termDecisions, isLimitTerm)) {
|
|
4037
3969
|
const value = primaryLimitFromTerms(next.limits);
|
|
4038
3970
|
if (value) next.limit = value;
|
|
4039
3971
|
else delete next.limit;
|
|
4040
3972
|
}
|
|
4041
|
-
if (decision.deductible == null &&
|
|
3973
|
+
if (decision.deductible == null && termDecisionsTouch(coverage, termDecisions, isDeductibleTerm)) {
|
|
4042
3974
|
const value = deductibleFromTerms(next.limits);
|
|
4043
3975
|
if (value) next.deductible = value;
|
|
4044
3976
|
else delete next.deductible;
|
|
4045
3977
|
}
|
|
4046
|
-
if (decision.premium == null &&
|
|
3978
|
+
if (decision.premium == null && termDecisionsTouch(coverage, termDecisions, isPremiumTerm)) {
|
|
4047
3979
|
const value = premiumFromTerms(next.limits);
|
|
4048
3980
|
if (value) next.premium = value;
|
|
4049
3981
|
else delete next.premium;
|
|
4050
3982
|
}
|
|
4051
|
-
if (decision.retroactiveDate == null &&
|
|
3983
|
+
if (decision.retroactiveDate == null && termDecisionsTouch(coverage, termDecisions, isRetroactiveDateTerm)) {
|
|
4052
3984
|
const value = retroactiveDateFromTerms(next.limits);
|
|
4053
3985
|
if (value) next.retroactiveDate = value;
|
|
4054
3986
|
else delete next.retroactiveDate;
|
|
@@ -5388,6 +5320,7 @@ Rules:
|
|
|
5388
5320
|
- 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.
|
|
5389
5321
|
- 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.
|
|
5390
5322
|
- 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.
|
|
5323
|
+
- 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.
|
|
5391
5324
|
- Forms-and-endorsements schedules are operational form inventory evidence, not coverage limits. Do not turn form schedule rows into coverage units unless the row also states a coverage-specific limit or deductible.
|
|
5392
5325
|
- Keep each coverage unit tied to one evidence scope: a declaration/core schedule row, a core policy form section, or one specific endorsement schedule. Do not merge declaration facts and endorsement schedule facts into the same coverage unit, even when they use the same coverage name.
|
|
5393
5326
|
- If the declarations schedule and an endorsement schedule both list Network Security, Social Engineering Fraud, Regulatory Proceedings, or another same-named coverage, return separate coverage units for each supported source scope.
|