@claritylabs/cl-sdk 3.1.3 → 3.1.4
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/README.md +1 -1
- package/dist/application.d.mts +1 -1
- package/dist/application.d.ts +1 -1
- package/dist/{index-D23NUbxr.d.mts → index-BbDPEnG9.d.mts} +2291 -635
- package/dist/{index-D23NUbxr.d.ts → index-BbDPEnG9.d.ts} +2291 -635
- package/dist/index.d.mts +418 -51
- package/dist/index.d.ts +418 -51
- package/dist/index.js +71 -48
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +69 -48
- package/dist/index.mjs.map +1 -1
- package/dist/storage-sqlite.d.mts +1114 -286
- package/dist/storage-sqlite.d.ts +1114 -286
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -237,9 +237,11 @@ __export(src_exports, {
|
|
|
237
237
|
ScheduledItemCategorySchema: () => ScheduledItemCategorySchema,
|
|
238
238
|
SectionSchema: () => SectionSchema,
|
|
239
239
|
SharedLimitSchema: () => SharedLimitSchema,
|
|
240
|
+
SourceBackedAddressSchema: () => SourceBackedAddressSchema,
|
|
240
241
|
SourceBackedValueSchema: () => SourceBackedValueSchema,
|
|
241
242
|
SourceChunkSchema: () => SourceChunkSchema,
|
|
242
243
|
SourceKindSchema: () => SourceKindSchema,
|
|
244
|
+
SourceProvenanceSchema: () => SourceProvenanceSchema,
|
|
243
245
|
SourceSpanBBoxSchema: () => SourceSpanBBoxSchema,
|
|
244
246
|
SourceSpanKindSchema: () => SourceSpanKindSchema,
|
|
245
247
|
SourceSpanLocationSchema: () => SourceSpanLocationSchema,
|
|
@@ -922,6 +924,13 @@ var PET_SPECIES = PetSpeciesSchema.options;
|
|
|
922
924
|
|
|
923
925
|
// src/schemas/shared.ts
|
|
924
926
|
var import_zod3 = require("zod");
|
|
927
|
+
var SourceProvenanceSchema = import_zod3.z.object({
|
|
928
|
+
sourceSpanIds: import_zod3.z.array(import_zod3.z.string().min(1)).min(1),
|
|
929
|
+
documentNodeId: import_zod3.z.string().optional(),
|
|
930
|
+
sourceTextHash: import_zod3.z.string().optional(),
|
|
931
|
+
pageStart: import_zod3.z.number().int().positive().optional(),
|
|
932
|
+
pageEnd: import_zod3.z.number().int().positive().optional()
|
|
933
|
+
});
|
|
925
934
|
var AddressSchema = import_zod3.z.object({
|
|
926
935
|
street1: import_zod3.z.string(),
|
|
927
936
|
street2: import_zod3.z.string().optional(),
|
|
@@ -930,6 +939,7 @@ var AddressSchema = import_zod3.z.object({
|
|
|
930
939
|
zip: import_zod3.z.string(),
|
|
931
940
|
country: import_zod3.z.string().optional()
|
|
932
941
|
});
|
|
942
|
+
var SourceBackedAddressSchema = AddressSchema.merge(SourceProvenanceSchema);
|
|
933
943
|
var ContactSchema = import_zod3.z.object({
|
|
934
944
|
name: import_zod3.z.string().optional(),
|
|
935
945
|
title: import_zod3.z.string().optional(),
|
|
@@ -939,7 +949,7 @@ var ContactSchema = import_zod3.z.object({
|
|
|
939
949
|
email: import_zod3.z.string().optional(),
|
|
940
950
|
address: AddressSchema.optional(),
|
|
941
951
|
hours: import_zod3.z.string().optional()
|
|
942
|
-
});
|
|
952
|
+
}).merge(SourceProvenanceSchema);
|
|
943
953
|
var FormReferenceSchema = import_zod3.z.object({
|
|
944
954
|
formNumber: import_zod3.z.string(),
|
|
945
955
|
editionDate: import_zod3.z.string().optional(),
|
|
@@ -986,7 +996,7 @@ var NamedInsuredSchema = import_zod3.z.object({
|
|
|
986
996
|
name: import_zod3.z.string(),
|
|
987
997
|
relationship: import_zod3.z.string().optional(),
|
|
988
998
|
address: AddressSchema.optional()
|
|
989
|
-
});
|
|
999
|
+
}).merge(SourceProvenanceSchema);
|
|
990
1000
|
|
|
991
1001
|
// src/schemas/coverage.ts
|
|
992
1002
|
var import_zod4 = require("zod");
|
|
@@ -1058,7 +1068,7 @@ var EndorsementPartySchema = import_zod5.z.object({
|
|
|
1058
1068
|
address: AddressSchema.optional(),
|
|
1059
1069
|
relationship: import_zod5.z.string().optional(),
|
|
1060
1070
|
scope: import_zod5.z.string().optional()
|
|
1061
|
-
});
|
|
1071
|
+
}).merge(SourceProvenanceSchema);
|
|
1062
1072
|
var EndorsementSchema = import_zod5.z.object({
|
|
1063
1073
|
formNumber: import_zod5.z.string(),
|
|
1064
1074
|
editionDate: import_zod5.z.string().optional(),
|
|
@@ -1125,7 +1135,7 @@ var InsurerInfoSchema = import_zod8.z.object({
|
|
|
1125
1135
|
amBestNumber: import_zod8.z.string().optional(),
|
|
1126
1136
|
admittedStatus: AdmittedStatusSchema.optional(),
|
|
1127
1137
|
stateOfDomicile: import_zod8.z.string().optional()
|
|
1128
|
-
});
|
|
1138
|
+
}).merge(SourceProvenanceSchema);
|
|
1129
1139
|
var ProducerInfoSchema = import_zod8.z.object({
|
|
1130
1140
|
agencyName: import_zod8.z.string(),
|
|
1131
1141
|
contactName: import_zod8.z.string().optional(),
|
|
@@ -1133,7 +1143,7 @@ var ProducerInfoSchema = import_zod8.z.object({
|
|
|
1133
1143
|
phone: import_zod8.z.string().optional(),
|
|
1134
1144
|
email: import_zod8.z.string().optional(),
|
|
1135
1145
|
address: AddressSchema.optional()
|
|
1136
|
-
});
|
|
1146
|
+
}).merge(SourceProvenanceSchema);
|
|
1137
1147
|
|
|
1138
1148
|
// src/schemas/financial.ts
|
|
1139
1149
|
var import_zod9 = require("zod");
|
|
@@ -1844,7 +1854,7 @@ var BaseDocumentFields = {
|
|
|
1844
1854
|
isRenewal: import_zod16.z.boolean().optional(),
|
|
1845
1855
|
isPackage: import_zod16.z.boolean().optional(),
|
|
1846
1856
|
insuredDba: import_zod16.z.string().optional(),
|
|
1847
|
-
insuredAddress:
|
|
1857
|
+
insuredAddress: SourceBackedAddressSchema.optional(),
|
|
1848
1858
|
insuredEntityType: EntityTypeSchema.optional(),
|
|
1849
1859
|
additionalNamedInsureds: import_zod16.z.array(NamedInsuredSchema).optional(),
|
|
1850
1860
|
insuredSicCode: import_zod16.z.string().optional(),
|
|
@@ -5017,6 +5027,17 @@ function getCoveredReasons(memory) {
|
|
|
5017
5027
|
}
|
|
5018
5028
|
|
|
5019
5029
|
// src/extraction/promote.ts
|
|
5030
|
+
function sourceProvenance(raw) {
|
|
5031
|
+
const sourceSpanIds = Array.isArray(raw.sourceSpanIds) ? raw.sourceSpanIds.filter((id) => typeof id === "string" && id.trim().length > 0) : [];
|
|
5032
|
+
if (sourceSpanIds.length === 0) return void 0;
|
|
5033
|
+
return {
|
|
5034
|
+
sourceSpanIds,
|
|
5035
|
+
...typeof raw.documentNodeId === "string" ? { documentNodeId: raw.documentNodeId } : {},
|
|
5036
|
+
...typeof raw.sourceTextHash === "string" ? { sourceTextHash: raw.sourceTextHash } : {},
|
|
5037
|
+
...typeof raw.pageStart === "number" ? { pageStart: raw.pageStart } : {},
|
|
5038
|
+
...typeof raw.pageEnd === "number" ? { pageEnd: raw.pageEnd } : {}
|
|
5039
|
+
};
|
|
5040
|
+
}
|
|
5020
5041
|
function stringValue(value) {
|
|
5021
5042
|
return typeof value === "string" && value.trim() ? value : void 0;
|
|
5022
5043
|
}
|
|
@@ -5037,36 +5058,38 @@ function promoteRawFields(raw, mappings) {
|
|
|
5037
5058
|
}
|
|
5038
5059
|
function promoteCarrierFields(doc) {
|
|
5039
5060
|
const raw = doc;
|
|
5061
|
+
const provenance = sourceProvenance(raw);
|
|
5040
5062
|
promoteRawFields(raw, [
|
|
5041
5063
|
{ from: "naicNumber", to: "carrierNaicNumber" },
|
|
5042
5064
|
{ from: "amBestRating", to: "carrierAmBestRating" },
|
|
5043
5065
|
{ from: "admittedStatus", to: "carrierAdmittedStatus" }
|
|
5044
5066
|
]);
|
|
5045
|
-
if (!raw.insurer && raw.carrierLegalName) {
|
|
5067
|
+
if (!raw.insurer && raw.carrierLegalName && provenance) {
|
|
5046
5068
|
raw.insurer = {
|
|
5047
5069
|
legalName: raw.carrierLegalName,
|
|
5048
5070
|
...raw.carrierNaicNumber ? { naicNumber: raw.carrierNaicNumber } : {},
|
|
5049
5071
|
...raw.carrierAmBestRating ? { amBestRating: raw.carrierAmBestRating } : {},
|
|
5050
|
-
...raw.carrierAdmittedStatus ? { admittedStatus: raw.carrierAdmittedStatus } : {}
|
|
5072
|
+
...raw.carrierAdmittedStatus ? { admittedStatus: raw.carrierAdmittedStatus } : {},
|
|
5073
|
+
...provenance
|
|
5051
5074
|
};
|
|
5052
5075
|
}
|
|
5053
5076
|
}
|
|
5054
5077
|
function promoteBroker(doc) {
|
|
5055
5078
|
const raw = doc;
|
|
5079
|
+
const provenance = sourceProvenance(raw);
|
|
5056
5080
|
const brokerAgency = findRawString(raw, ["brokerAgency"]);
|
|
5057
5081
|
const brokerContact = findRawString(raw, ["brokerContactName"]);
|
|
5058
5082
|
const brokerLicense = findRawString(raw, ["brokerLicenseNumber"]);
|
|
5059
5083
|
const brokerPhone = findRawString(raw, ["brokerPhone"]);
|
|
5060
5084
|
const brokerEmail = findRawString(raw, ["brokerEmail"]);
|
|
5061
|
-
|
|
5062
|
-
if (!raw.producer && brokerAgency) {
|
|
5085
|
+
if (!raw.producer && brokerAgency && provenance) {
|
|
5063
5086
|
raw.producer = {
|
|
5064
5087
|
agencyName: brokerAgency,
|
|
5065
5088
|
...brokerContact ? { contactName: brokerContact } : {},
|
|
5066
5089
|
...brokerLicense ? { licenseNumber: brokerLicense } : {},
|
|
5067
5090
|
...brokerPhone ? { phone: brokerPhone } : {},
|
|
5068
5091
|
...brokerEmail ? { email: brokerEmail } : {},
|
|
5069
|
-
...
|
|
5092
|
+
...provenance
|
|
5070
5093
|
};
|
|
5071
5094
|
}
|
|
5072
5095
|
}
|
|
@@ -8020,16 +8043,19 @@ Return JSON only.`;
|
|
|
8020
8043
|
|
|
8021
8044
|
// src/prompts/extractors/named-insured.ts
|
|
8022
8045
|
var import_zod27 = require("zod");
|
|
8023
|
-
var
|
|
8024
|
-
|
|
8025
|
-
|
|
8026
|
-
|
|
8027
|
-
|
|
8028
|
-
|
|
8046
|
+
var AdditionalNamedInsuredSchema = import_zod27.z.object({
|
|
8047
|
+
name: import_zod27.z.string(),
|
|
8048
|
+
relationship: import_zod27.z.string().optional().describe("e.g. subsidiary, affiliate"),
|
|
8049
|
+
address: SourceBackedAddressSchema.optional()
|
|
8050
|
+
}).merge(SourceProvenanceSchema);
|
|
8051
|
+
var ScheduledPartySchema = import_zod27.z.object({
|
|
8052
|
+
name: import_zod27.z.string(),
|
|
8053
|
+
address: SourceBackedAddressSchema.optional()
|
|
8054
|
+
}).merge(SourceProvenanceSchema);
|
|
8029
8055
|
var NamedInsuredSchema2 = import_zod27.z.object({
|
|
8030
8056
|
insuredName: import_zod27.z.string().describe("Name of primary named insured"),
|
|
8031
8057
|
insuredDba: import_zod27.z.string().optional().describe("Doing-business-as name"),
|
|
8032
|
-
insuredAddress:
|
|
8058
|
+
insuredAddress: SourceBackedAddressSchema.optional().describe("Primary insured mailing address"),
|
|
8033
8059
|
insuredEntityType: import_zod27.z.enum([
|
|
8034
8060
|
"corporation",
|
|
8035
8061
|
"llc",
|
|
@@ -8046,25 +8072,9 @@ var NamedInsuredSchema2 = import_zod27.z.object({
|
|
|
8046
8072
|
insuredFein: import_zod27.z.string().optional().describe("Federal Employer Identification Number"),
|
|
8047
8073
|
insuredSicCode: import_zod27.z.string().optional().describe("SIC code"),
|
|
8048
8074
|
insuredNaicsCode: import_zod27.z.string().optional().describe("NAICS code"),
|
|
8049
|
-
additionalNamedInsureds: import_zod27.z.array(
|
|
8050
|
-
|
|
8051
|
-
|
|
8052
|
-
relationship: import_zod27.z.string().optional().describe("e.g. subsidiary, affiliate"),
|
|
8053
|
-
address: AddressSchema2.optional()
|
|
8054
|
-
})
|
|
8055
|
-
).optional().describe("Additional named insureds listed on the policy"),
|
|
8056
|
-
lossPayees: import_zod27.z.array(
|
|
8057
|
-
import_zod27.z.object({
|
|
8058
|
-
name: import_zod27.z.string(),
|
|
8059
|
-
address: AddressSchema2.optional()
|
|
8060
|
-
})
|
|
8061
|
-
).optional().describe("Loss payees listed on the policy"),
|
|
8062
|
-
mortgageHolders: import_zod27.z.array(
|
|
8063
|
-
import_zod27.z.object({
|
|
8064
|
-
name: import_zod27.z.string(),
|
|
8065
|
-
address: AddressSchema2.optional()
|
|
8066
|
-
})
|
|
8067
|
-
).optional().describe("Mortgage holders / lienholders listed on the policy")
|
|
8075
|
+
additionalNamedInsureds: import_zod27.z.array(AdditionalNamedInsuredSchema).optional().describe("Additional named insureds listed on the policy"),
|
|
8076
|
+
lossPayees: import_zod27.z.array(ScheduledPartySchema).optional().describe("Loss payees listed on the policy"),
|
|
8077
|
+
mortgageHolders: import_zod27.z.array(ScheduledPartySchema).optional().describe("Mortgage holders / lienholders listed on the policy")
|
|
8068
8078
|
});
|
|
8069
8079
|
function buildNamedInsuredPrompt() {
|
|
8070
8080
|
return `You are an expert insurance document analyst. Extract all named insured information from this document.
|
|
@@ -8081,6 +8091,7 @@ Focus on:
|
|
|
8081
8091
|
Look on the declarations page, named insured schedule, loss payee schedule, mortgagee schedule, and any endorsements that add or modify named insureds, loss payees, or mortgage holders.
|
|
8082
8092
|
|
|
8083
8093
|
Critical rules:
|
|
8094
|
+
- Every insuredAddress, additionalNamedInsureds row, lossPayees row, and mortgageHolders row must include sourceSpanIds from the source evidence. Omit the row if source spans are unavailable.
|
|
8084
8095
|
- Prefer declaration-table labels such as "Named Insured", "Named Insured and Address", "Applicant", or "Insured" over contact blocks, notice contacts, authorized officers, licensing statements, signatures, and corporate-authority wording.
|
|
8085
8096
|
- Do not use an authorized officer, broker, producer, contact person, officer title, email address owner, or licensing/entity-status statement as the primary insured unless that exact person/entity is explicitly labeled as the named insured.
|
|
8086
8097
|
- If a row combines the insured name with a mailing address, put the legal name in insuredName and the mailing address in insuredAddress.
|
|
@@ -8544,13 +8555,6 @@ Return JSON only.`;
|
|
|
8544
8555
|
|
|
8545
8556
|
// src/prompts/extractors/supplementary.ts
|
|
8546
8557
|
var import_zod36 = require("zod");
|
|
8547
|
-
var ContactSchema2 = import_zod36.z.object({
|
|
8548
|
-
name: import_zod36.z.string().optional().describe("Organization or person name"),
|
|
8549
|
-
phone: import_zod36.z.string().optional().describe("Phone number"),
|
|
8550
|
-
email: import_zod36.z.string().optional().describe("Email address"),
|
|
8551
|
-
address: import_zod36.z.string().optional().describe("Mailing address"),
|
|
8552
|
-
type: import_zod36.z.string().optional().describe("Contact type, e.g. 'State Department of Insurance'")
|
|
8553
|
-
});
|
|
8554
8558
|
var AuxiliaryFactSchema2 = import_zod36.z.object({
|
|
8555
8559
|
key: import_zod36.z.string().describe("Normalized machine-readable fact key, e.g. 'policyholder_age' or 'insured_name'"),
|
|
8556
8560
|
value: import_zod36.z.string().describe("Concrete extracted fact value"),
|
|
@@ -8558,9 +8562,9 @@ var AuxiliaryFactSchema2 = import_zod36.z.object({
|
|
|
8558
8562
|
context: import_zod36.z.string().optional().describe("Short disambiguating context, such as 'Driver Schedule' or 'Named Insured'")
|
|
8559
8563
|
});
|
|
8560
8564
|
var SupplementarySchema = import_zod36.z.object({
|
|
8561
|
-
regulatoryContacts: import_zod36.z.array(
|
|
8562
|
-
claimsContacts: import_zod36.z.array(
|
|
8563
|
-
thirdPartyAdministrators: import_zod36.z.array(
|
|
8565
|
+
regulatoryContacts: import_zod36.z.array(ContactSchema).optional().describe("Regulatory body contacts (state department of insurance, ombudsman)"),
|
|
8566
|
+
claimsContacts: import_zod36.z.array(ContactSchema).optional().describe("Claims reporting contacts and instructions"),
|
|
8567
|
+
thirdPartyAdministrators: import_zod36.z.array(ContactSchema).optional().describe("Third-party administrators for claims handling"),
|
|
8564
8568
|
cancellationNoticeDays: import_zod36.z.number().optional().describe("Required notice period for cancellation in days"),
|
|
8565
8569
|
nonrenewalNoticeDays: import_zod36.z.number().optional().describe("Required notice period for nonrenewal in days"),
|
|
8566
8570
|
auxiliaryFacts: import_zod36.z.array(AuxiliaryFactSchema2).optional().describe("Additional retrieval-only facts that do not fit the strict primary schema")
|
|
@@ -8575,7 +8579,7 @@ ${alreadyExtractedSummary}
|
|
|
8575
8579
|
return `You are an expert insurance document analyst. Extract supplementary, retrieval-only information from this document that is NOT already captured in the structured extraction results.
|
|
8576
8580
|
${exclusionBlock}
|
|
8577
8581
|
Focus on:
|
|
8578
|
-
- Regulatory contacts: state department of insurance, regulatory bodies, ombudsman offices \u2014 with phone, email, address
|
|
8582
|
+
- Regulatory contacts: state department of insurance, regulatory bodies, ombudsman offices \u2014 with phone, email, structured address
|
|
8579
8583
|
- Claims contacts: how to report claims, claims department contact info, hours of operation
|
|
8580
8584
|
- Third-party administrators (TPAs) for claims handling
|
|
8581
8585
|
- Cancellation notice period in days
|
|
@@ -8586,6 +8590,8 @@ Focus on:
|
|
|
8586
8590
|
|
|
8587
8591
|
Look for regulatory notices, complaint contact sections, claims reporting instructions, and cancellation/nonrenewal provisions throughout the document.
|
|
8588
8592
|
|
|
8593
|
+
Every regulatoryContacts, claimsContacts, and thirdPartyAdministrators row must include sourceSpanIds from the source evidence. Omit contacts when source spans are unavailable.
|
|
8594
|
+
|
|
8589
8595
|
For auxiliaryFacts:
|
|
8590
8596
|
- ONLY capture facts that are NOT already present in the structured extraction results above.
|
|
8591
8597
|
- Do not duplicate information that has already been extracted \u2014 no policy numbers, insured names, addresses, coverage limits, deductibles, or any other field that appears in the already-extracted data.
|
|
@@ -11800,6 +11806,13 @@ function valueOf(profile, key) {
|
|
|
11800
11806
|
}
|
|
11801
11807
|
return String(value.value);
|
|
11802
11808
|
}
|
|
11809
|
+
function provenanceOf(value) {
|
|
11810
|
+
if (!value?.sourceSpanIds.length) return void 0;
|
|
11811
|
+
return {
|
|
11812
|
+
sourceSpanIds: value.sourceSpanIds,
|
|
11813
|
+
...value.sourceNodeIds[0] ? { documentNodeId: value.sourceNodeIds[0] } : {}
|
|
11814
|
+
};
|
|
11815
|
+
}
|
|
11803
11816
|
function materializeDocument(params) {
|
|
11804
11817
|
const profile = params.operationalProfile;
|
|
11805
11818
|
const policyNumber = valueOf(profile, "policyNumber") ?? "Unknown";
|
|
@@ -11808,6 +11821,9 @@ function materializeDocument(params) {
|
|
|
11808
11821
|
const effectiveDate = valueOf(profile, "effectiveDate") ?? "Unknown";
|
|
11809
11822
|
const expirationDate = valueOf(profile, "expirationDate") ?? "Unknown";
|
|
11810
11823
|
const premium = valueOf(profile, "premium");
|
|
11824
|
+
const insurerProvenance = provenanceOf(profile.insurer);
|
|
11825
|
+
const broker = valueOf(profile, "broker");
|
|
11826
|
+
const brokerProvenance = provenanceOf(profile.broker);
|
|
11811
11827
|
const coverages = profile.coverages.map((coverage) => ({
|
|
11812
11828
|
name: coverage.name,
|
|
11813
11829
|
coverageCode: coverage.coverageCode,
|
|
@@ -11859,6 +11875,11 @@ function materializeDocument(params) {
|
|
|
11859
11875
|
security: carrier,
|
|
11860
11876
|
insuredName,
|
|
11861
11877
|
premium,
|
|
11878
|
+
...insurerProvenance ? { insurer: { legalName: carrier, ...insurerProvenance } } : {},
|
|
11879
|
+
...broker && brokerProvenance ? {
|
|
11880
|
+
brokerAgency: broker,
|
|
11881
|
+
producer: { agencyName: broker, ...brokerProvenance }
|
|
11882
|
+
} : {},
|
|
11862
11883
|
policyTypes: profile.policyTypes,
|
|
11863
11884
|
formInventory: params.formInventory.filter((form) => typeof form.formNumber === "string" && form.formNumber.trim().length > 0).map((form) => ({
|
|
11864
11885
|
formNumber: form.formNumber,
|
|
@@ -17542,9 +17563,11 @@ var AGENT_TOOLS = [
|
|
|
17542
17563
|
ScheduledItemCategorySchema,
|
|
17543
17564
|
SectionSchema,
|
|
17544
17565
|
SharedLimitSchema,
|
|
17566
|
+
SourceBackedAddressSchema,
|
|
17545
17567
|
SourceBackedValueSchema,
|
|
17546
17568
|
SourceChunkSchema,
|
|
17547
17569
|
SourceKindSchema,
|
|
17570
|
+
SourceProvenanceSchema,
|
|
17548
17571
|
SourceSpanBBoxSchema,
|
|
17549
17572
|
SourceSpanKindSchema,
|
|
17550
17573
|
SourceSpanLocationSchema,
|