@claritylabs/cl-sdk 3.2.2 → 3.2.3
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 +24 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3918,7 +3918,7 @@ function mergeOperationalProfile(base, candidate, validNodeIds, validSpanIds) {
|
|
|
3918
3918
|
];
|
|
3919
3919
|
return PolicyOperationalProfileSchema.parse({
|
|
3920
3920
|
...base,
|
|
3921
|
-
documentType: candidate.documentType === "
|
|
3921
|
+
documentType: candidate.documentType === "policy" ? "policy" : base.documentType,
|
|
3922
3922
|
policyTypes: Array.isArray(candidate.policyTypes) && candidate.policyTypes.length > 0 ? candidate.policyTypes : base.policyTypes,
|
|
3923
3923
|
policyNumber,
|
|
3924
3924
|
namedInsured,
|
|
@@ -5575,14 +5575,23 @@ function operationalEvidenceScore(span) {
|
|
|
5575
5575
|
if (/\$[\d,.]+|[0-9]{1,2}\/[0-9]{1,2}\/[0-9]{2,4}|[0-9]{1,2}\s+[A-Za-z]{3,9}\s+[0-9]{4}/.test(text)) score += 3;
|
|
5576
5576
|
return score;
|
|
5577
5577
|
}
|
|
5578
|
+
function spanTableId(span) {
|
|
5579
|
+
return span.table?.tableId ?? span.metadata?.tableId;
|
|
5580
|
+
}
|
|
5581
|
+
function isTableCellSpan(span) {
|
|
5582
|
+
return spanSourceUnit(span) === "table_cell";
|
|
5583
|
+
}
|
|
5578
5584
|
function operationalProfileEvidence(sourceTree, sourceSpans) {
|
|
5579
5585
|
const sorted = [...sourceSpans].sort(
|
|
5580
5586
|
(left, right) => (spanPageStart(left) ?? Number.MAX_SAFE_INTEGER) - (spanPageStart(right) ?? Number.MAX_SAFE_INTEGER) || (left.location?.charStart ?? Number.MAX_SAFE_INTEGER) - (right.location?.charStart ?? Number.MAX_SAFE_INTEGER) || left.id.localeCompare(right.id)
|
|
5581
5587
|
);
|
|
5582
5588
|
const selected = /* @__PURE__ */ new Set();
|
|
5589
|
+
const selectedTableIds = /* @__PURE__ */ new Set();
|
|
5583
5590
|
for (let index = 0; index < sorted.length; index += 1) {
|
|
5584
5591
|
const score = operationalEvidenceScore(sorted[index]);
|
|
5585
5592
|
if (score < 8) continue;
|
|
5593
|
+
const tableId2 = spanTableId(sorted[index]);
|
|
5594
|
+
if (tableId2 && !isTableCellSpan(sorted[index])) selectedTableIds.add(tableId2);
|
|
5586
5595
|
const page = spanPageStart(sorted[index]);
|
|
5587
5596
|
for (let offset = -2; offset <= 2; offset += 1) {
|
|
5588
5597
|
const neighborIndex = index + offset;
|
|
@@ -5593,9 +5602,17 @@ function operationalProfileEvidence(sourceTree, sourceSpans) {
|
|
|
5593
5602
|
selected.add(neighborIndex);
|
|
5594
5603
|
}
|
|
5595
5604
|
}
|
|
5605
|
+
if (selectedTableIds.size > 0) {
|
|
5606
|
+
sorted.forEach((span, index) => {
|
|
5607
|
+
const tableId2 = spanTableId(span);
|
|
5608
|
+
if (!tableId2 || !selectedTableIds.has(tableId2) || isTableCellSpan(span)) return;
|
|
5609
|
+
const text = cleanText(span.text, "");
|
|
5610
|
+
if (text && text.length <= 5e3) selected.add(index);
|
|
5611
|
+
});
|
|
5612
|
+
}
|
|
5596
5613
|
const nodeIdsBySpanId = sourceNodeIdsBySpanId(sourceTree);
|
|
5597
5614
|
const seenText = /* @__PURE__ */ new Set();
|
|
5598
|
-
|
|
5615
|
+
const entries = [...selected].sort((left, right) => left - right).map((index) => sorted[index]).filter((span) => !isTableCellSpan(span)).flatMap((span) => {
|
|
5599
5616
|
const text = cleanText(span.text, "");
|
|
5600
5617
|
if (!text) return [];
|
|
5601
5618
|
const key = `${spanPageStart(span) ?? "na"}:${text.toLowerCase().slice(0, 240)}`;
|
|
@@ -5610,7 +5627,10 @@ function operationalProfileEvidence(sourceTree, sourceSpans) {
|
|
|
5610
5627
|
formNumber: span.formNumber,
|
|
5611
5628
|
text: text.slice(0, span.sourceUnit === "page" ? 1200 : 900)
|
|
5612
5629
|
}];
|
|
5613
|
-
})
|
|
5630
|
+
});
|
|
5631
|
+
const detailEntries = entries.filter((entry) => entry.sourceUnit !== "page");
|
|
5632
|
+
const pageEntries = entries.filter((entry) => entry.sourceUnit === "page");
|
|
5633
|
+
return (detailEntries.length >= 20 ? detailEntries : [...detailEntries, ...pageEntries]).slice(0, 180);
|
|
5614
5634
|
}
|
|
5615
5635
|
function sourceTreeRootId(sourceTree) {
|
|
5616
5636
|
return sourceTree.find((node) => node.kind === "document")?.id;
|
|
@@ -5641,7 +5661,7 @@ function buildOperationalProfilePrompt(sourceTree, sourceSpans) {
|
|
|
5641
5661
|
const fallbackNodes = evidence.length ? [] : operationalProfilePromptNodes(sourceTree).map(
|
|
5642
5662
|
(node) => compactNode2(node, node.kind === "page" || node.kind === "endorsement" ? 900 : 700)
|
|
5643
5663
|
);
|
|
5644
|
-
return `Extract a source-backed operational profile for an insurance policy
|
|
5664
|
+
return `Extract a source-backed operational profile for an insurance policy.
|
|
5645
5665
|
|
|
5646
5666
|
Return only high-value operational facts needed for policy lists, Q&A, compliance, and certificate generation:
|
|
5647
5667
|
- policy number, named insured, insurer/carrier/security, broker/producer, policy period, retroactive date, premium
|