@claritylabs/cl-sdk 3.1.3 → 3.1.5
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-2WYX6Agm.d.mts} +2456 -800
- package/dist/{index-D23NUbxr.d.ts → index-2WYX6Agm.d.ts} +2456 -800
- package/dist/index.d.mts +474 -107
- package/dist/index.d.ts +474 -107
- package/dist/index.js +127 -94
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +125 -94
- 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,
|
|
@@ -456,53 +458,70 @@ function sanitizeNulls(obj) {
|
|
|
456
458
|
|
|
457
459
|
// src/core/strict-schema.ts
|
|
458
460
|
var import_zod = require("zod");
|
|
461
|
+
function schemaDef(schema) {
|
|
462
|
+
return schema._zod?.def ?? schema._def ?? {};
|
|
463
|
+
}
|
|
464
|
+
function schemaKind(schema) {
|
|
465
|
+
const def = schemaDef(schema);
|
|
466
|
+
const raw = typeof def.type === "string" ? def.type : typeof def.typeName === "string" ? def.typeName : typeof schema.type === "string" ? schema.type : void 0;
|
|
467
|
+
return raw?.replace(/^Zod/, "").toLowerCase();
|
|
468
|
+
}
|
|
469
|
+
function schemaDescription(schema) {
|
|
470
|
+
const def = schemaDef(schema);
|
|
471
|
+
return schema.description ?? def.description;
|
|
472
|
+
}
|
|
473
|
+
function objectShape(schema) {
|
|
474
|
+
const def = schemaDef(schema);
|
|
475
|
+
const shape = schema.shape ?? def.shape;
|
|
476
|
+
return typeof shape === "function" ? shape() : shape;
|
|
477
|
+
}
|
|
478
|
+
function withDescription(schema, description) {
|
|
479
|
+
return description ? schema.describe(description) : schema;
|
|
480
|
+
}
|
|
459
481
|
function toStrictSchema(schema) {
|
|
460
|
-
const
|
|
461
|
-
const
|
|
462
|
-
if (
|
|
463
|
-
const shape = schema
|
|
482
|
+
const kind = schemaKind(schema);
|
|
483
|
+
const def = schemaDef(schema);
|
|
484
|
+
if (kind === "object") {
|
|
485
|
+
const shape = objectShape(schema);
|
|
464
486
|
if (!shape) return schema;
|
|
465
487
|
const newShape = {};
|
|
466
488
|
for (const [key, value] of Object.entries(shape)) {
|
|
467
489
|
const field = value;
|
|
468
|
-
const fieldDef = field
|
|
469
|
-
const
|
|
470
|
-
if (
|
|
490
|
+
const fieldDef = schemaDef(field);
|
|
491
|
+
const fieldKind = schemaKind(field);
|
|
492
|
+
if (fieldKind === "optional") {
|
|
471
493
|
const innerType = fieldDef?.innerType;
|
|
472
|
-
const description = field
|
|
494
|
+
const description = schemaDescription(field);
|
|
473
495
|
if (innerType) {
|
|
474
496
|
const transformed = toStrictSchema(innerType);
|
|
475
|
-
|
|
476
|
-
if (description) nullable = nullable.describe(description);
|
|
477
|
-
newShape[key] = nullable;
|
|
497
|
+
newShape[key] = withDescription(import_zod.z.nullable(transformed), description);
|
|
478
498
|
} else {
|
|
479
|
-
|
|
480
|
-
if (description) nullable = nullable.describe(description);
|
|
481
|
-
newShape[key] = nullable;
|
|
499
|
+
newShape[key] = withDescription(import_zod.z.nullable(field), description);
|
|
482
500
|
}
|
|
483
501
|
} else {
|
|
484
502
|
newShape[key] = toStrictSchema(field);
|
|
485
503
|
}
|
|
486
504
|
}
|
|
487
|
-
|
|
488
|
-
const result = import_zod.z.object(newShape);
|
|
489
|
-
return objDesc ? result.describe(objDesc) : result;
|
|
505
|
+
return withDescription(import_zod.z.object(newShape), schemaDescription(schema));
|
|
490
506
|
}
|
|
491
|
-
if (
|
|
492
|
-
const element = def
|
|
507
|
+
if (kind === "array") {
|
|
508
|
+
const element = def.element ?? def.type ?? schema.element;
|
|
493
509
|
if (element) {
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
510
|
+
return withDescription(import_zod.z.array(toStrictSchema(element)), schemaDescription(schema));
|
|
511
|
+
}
|
|
512
|
+
return schema;
|
|
513
|
+
}
|
|
514
|
+
if (kind === "nullable") {
|
|
515
|
+
const innerType = def?.innerType;
|
|
516
|
+
if (innerType) {
|
|
517
|
+
return withDescription(import_zod.z.nullable(toStrictSchema(innerType)), schemaDescription(schema));
|
|
497
518
|
}
|
|
498
519
|
return schema;
|
|
499
520
|
}
|
|
500
|
-
if (
|
|
521
|
+
if (kind === "default") {
|
|
501
522
|
const innerType = def?.innerType;
|
|
502
523
|
if (innerType) {
|
|
503
|
-
|
|
504
|
-
const result = import_zod.z.nullable(toStrictSchema(innerType));
|
|
505
|
-
return nullDesc ? result.describe(nullDesc) : result;
|
|
524
|
+
return withDescription(import_zod.z.nullable(toStrictSchema(innerType)), schemaDescription(schema));
|
|
506
525
|
}
|
|
507
526
|
return schema;
|
|
508
527
|
}
|
|
@@ -922,6 +941,13 @@ var PET_SPECIES = PetSpeciesSchema.options;
|
|
|
922
941
|
|
|
923
942
|
// src/schemas/shared.ts
|
|
924
943
|
var import_zod3 = require("zod");
|
|
944
|
+
var SourceProvenanceSchema = import_zod3.z.object({
|
|
945
|
+
sourceSpanIds: import_zod3.z.array(import_zod3.z.string().min(1)).min(1),
|
|
946
|
+
documentNodeId: import_zod3.z.string().optional(),
|
|
947
|
+
sourceTextHash: import_zod3.z.string().optional(),
|
|
948
|
+
pageStart: import_zod3.z.number().int().positive().optional(),
|
|
949
|
+
pageEnd: import_zod3.z.number().int().positive().optional()
|
|
950
|
+
});
|
|
925
951
|
var AddressSchema = import_zod3.z.object({
|
|
926
952
|
street1: import_zod3.z.string(),
|
|
927
953
|
street2: import_zod3.z.string().optional(),
|
|
@@ -930,6 +956,7 @@ var AddressSchema = import_zod3.z.object({
|
|
|
930
956
|
zip: import_zod3.z.string(),
|
|
931
957
|
country: import_zod3.z.string().optional()
|
|
932
958
|
});
|
|
959
|
+
var SourceBackedAddressSchema = AddressSchema.merge(SourceProvenanceSchema);
|
|
933
960
|
var ContactSchema = import_zod3.z.object({
|
|
934
961
|
name: import_zod3.z.string().optional(),
|
|
935
962
|
title: import_zod3.z.string().optional(),
|
|
@@ -939,7 +966,7 @@ var ContactSchema = import_zod3.z.object({
|
|
|
939
966
|
email: import_zod3.z.string().optional(),
|
|
940
967
|
address: AddressSchema.optional(),
|
|
941
968
|
hours: import_zod3.z.string().optional()
|
|
942
|
-
});
|
|
969
|
+
}).merge(SourceProvenanceSchema);
|
|
943
970
|
var FormReferenceSchema = import_zod3.z.object({
|
|
944
971
|
formNumber: import_zod3.z.string(),
|
|
945
972
|
editionDate: import_zod3.z.string().optional(),
|
|
@@ -986,7 +1013,7 @@ var NamedInsuredSchema = import_zod3.z.object({
|
|
|
986
1013
|
name: import_zod3.z.string(),
|
|
987
1014
|
relationship: import_zod3.z.string().optional(),
|
|
988
1015
|
address: AddressSchema.optional()
|
|
989
|
-
});
|
|
1016
|
+
}).merge(SourceProvenanceSchema);
|
|
990
1017
|
|
|
991
1018
|
// src/schemas/coverage.ts
|
|
992
1019
|
var import_zod4 = require("zod");
|
|
@@ -1058,7 +1085,7 @@ var EndorsementPartySchema = import_zod5.z.object({
|
|
|
1058
1085
|
address: AddressSchema.optional(),
|
|
1059
1086
|
relationship: import_zod5.z.string().optional(),
|
|
1060
1087
|
scope: import_zod5.z.string().optional()
|
|
1061
|
-
});
|
|
1088
|
+
}).merge(SourceProvenanceSchema);
|
|
1062
1089
|
var EndorsementSchema = import_zod5.z.object({
|
|
1063
1090
|
formNumber: import_zod5.z.string(),
|
|
1064
1091
|
editionDate: import_zod5.z.string().optional(),
|
|
@@ -1125,7 +1152,7 @@ var InsurerInfoSchema = import_zod8.z.object({
|
|
|
1125
1152
|
amBestNumber: import_zod8.z.string().optional(),
|
|
1126
1153
|
admittedStatus: AdmittedStatusSchema.optional(),
|
|
1127
1154
|
stateOfDomicile: import_zod8.z.string().optional()
|
|
1128
|
-
});
|
|
1155
|
+
}).merge(SourceProvenanceSchema);
|
|
1129
1156
|
var ProducerInfoSchema = import_zod8.z.object({
|
|
1130
1157
|
agencyName: import_zod8.z.string(),
|
|
1131
1158
|
contactName: import_zod8.z.string().optional(),
|
|
@@ -1133,7 +1160,7 @@ var ProducerInfoSchema = import_zod8.z.object({
|
|
|
1133
1160
|
phone: import_zod8.z.string().optional(),
|
|
1134
1161
|
email: import_zod8.z.string().optional(),
|
|
1135
1162
|
address: AddressSchema.optional()
|
|
1136
|
-
});
|
|
1163
|
+
}).merge(SourceProvenanceSchema);
|
|
1137
1164
|
|
|
1138
1165
|
// src/schemas/financial.ts
|
|
1139
1166
|
var import_zod9 = require("zod");
|
|
@@ -1844,7 +1871,7 @@ var BaseDocumentFields = {
|
|
|
1844
1871
|
isRenewal: import_zod16.z.boolean().optional(),
|
|
1845
1872
|
isPackage: import_zod16.z.boolean().optional(),
|
|
1846
1873
|
insuredDba: import_zod16.z.string().optional(),
|
|
1847
|
-
insuredAddress:
|
|
1874
|
+
insuredAddress: SourceBackedAddressSchema.optional(),
|
|
1848
1875
|
insuredEntityType: EntityTypeSchema.optional(),
|
|
1849
1876
|
additionalNamedInsureds: import_zod16.z.array(NamedInsuredSchema).optional(),
|
|
1850
1877
|
insuredSicCode: import_zod16.z.string().optional(),
|
|
@@ -5017,6 +5044,17 @@ function getCoveredReasons(memory) {
|
|
|
5017
5044
|
}
|
|
5018
5045
|
|
|
5019
5046
|
// src/extraction/promote.ts
|
|
5047
|
+
function sourceProvenance(raw) {
|
|
5048
|
+
const sourceSpanIds = Array.isArray(raw.sourceSpanIds) ? raw.sourceSpanIds.filter((id) => typeof id === "string" && id.trim().length > 0) : [];
|
|
5049
|
+
if (sourceSpanIds.length === 0) return void 0;
|
|
5050
|
+
return {
|
|
5051
|
+
sourceSpanIds,
|
|
5052
|
+
...typeof raw.documentNodeId === "string" ? { documentNodeId: raw.documentNodeId } : {},
|
|
5053
|
+
...typeof raw.sourceTextHash === "string" ? { sourceTextHash: raw.sourceTextHash } : {},
|
|
5054
|
+
...typeof raw.pageStart === "number" ? { pageStart: raw.pageStart } : {},
|
|
5055
|
+
...typeof raw.pageEnd === "number" ? { pageEnd: raw.pageEnd } : {}
|
|
5056
|
+
};
|
|
5057
|
+
}
|
|
5020
5058
|
function stringValue(value) {
|
|
5021
5059
|
return typeof value === "string" && value.trim() ? value : void 0;
|
|
5022
5060
|
}
|
|
@@ -5037,36 +5075,38 @@ function promoteRawFields(raw, mappings) {
|
|
|
5037
5075
|
}
|
|
5038
5076
|
function promoteCarrierFields(doc) {
|
|
5039
5077
|
const raw = doc;
|
|
5078
|
+
const provenance = sourceProvenance(raw);
|
|
5040
5079
|
promoteRawFields(raw, [
|
|
5041
5080
|
{ from: "naicNumber", to: "carrierNaicNumber" },
|
|
5042
5081
|
{ from: "amBestRating", to: "carrierAmBestRating" },
|
|
5043
5082
|
{ from: "admittedStatus", to: "carrierAdmittedStatus" }
|
|
5044
5083
|
]);
|
|
5045
|
-
if (!raw.insurer && raw.carrierLegalName) {
|
|
5084
|
+
if (!raw.insurer && raw.carrierLegalName && provenance) {
|
|
5046
5085
|
raw.insurer = {
|
|
5047
5086
|
legalName: raw.carrierLegalName,
|
|
5048
5087
|
...raw.carrierNaicNumber ? { naicNumber: raw.carrierNaicNumber } : {},
|
|
5049
5088
|
...raw.carrierAmBestRating ? { amBestRating: raw.carrierAmBestRating } : {},
|
|
5050
|
-
...raw.carrierAdmittedStatus ? { admittedStatus: raw.carrierAdmittedStatus } : {}
|
|
5089
|
+
...raw.carrierAdmittedStatus ? { admittedStatus: raw.carrierAdmittedStatus } : {},
|
|
5090
|
+
...provenance
|
|
5051
5091
|
};
|
|
5052
5092
|
}
|
|
5053
5093
|
}
|
|
5054
5094
|
function promoteBroker(doc) {
|
|
5055
5095
|
const raw = doc;
|
|
5096
|
+
const provenance = sourceProvenance(raw);
|
|
5056
5097
|
const brokerAgency = findRawString(raw, ["brokerAgency"]);
|
|
5057
5098
|
const brokerContact = findRawString(raw, ["brokerContactName"]);
|
|
5058
5099
|
const brokerLicense = findRawString(raw, ["brokerLicenseNumber"]);
|
|
5059
5100
|
const brokerPhone = findRawString(raw, ["brokerPhone"]);
|
|
5060
5101
|
const brokerEmail = findRawString(raw, ["brokerEmail"]);
|
|
5061
|
-
|
|
5062
|
-
if (!raw.producer && brokerAgency) {
|
|
5102
|
+
if (!raw.producer && brokerAgency && provenance) {
|
|
5063
5103
|
raw.producer = {
|
|
5064
5104
|
agencyName: brokerAgency,
|
|
5065
5105
|
...brokerContact ? { contactName: brokerContact } : {},
|
|
5066
5106
|
...brokerLicense ? { licenseNumber: brokerLicense } : {},
|
|
5067
5107
|
...brokerPhone ? { phone: brokerPhone } : {},
|
|
5068
5108
|
...brokerEmail ? { email: brokerEmail } : {},
|
|
5069
|
-
...
|
|
5109
|
+
...provenance
|
|
5070
5110
|
};
|
|
5071
5111
|
}
|
|
5072
5112
|
}
|
|
@@ -8020,16 +8060,19 @@ Return JSON only.`;
|
|
|
8020
8060
|
|
|
8021
8061
|
// src/prompts/extractors/named-insured.ts
|
|
8022
8062
|
var import_zod27 = require("zod");
|
|
8023
|
-
var
|
|
8024
|
-
|
|
8025
|
-
|
|
8026
|
-
|
|
8027
|
-
|
|
8028
|
-
|
|
8063
|
+
var AdditionalNamedInsuredSchema = import_zod27.z.object({
|
|
8064
|
+
name: import_zod27.z.string(),
|
|
8065
|
+
relationship: import_zod27.z.string().optional().describe("e.g. subsidiary, affiliate"),
|
|
8066
|
+
address: SourceBackedAddressSchema.optional()
|
|
8067
|
+
}).merge(SourceProvenanceSchema);
|
|
8068
|
+
var ScheduledPartySchema = import_zod27.z.object({
|
|
8069
|
+
name: import_zod27.z.string(),
|
|
8070
|
+
address: SourceBackedAddressSchema.optional()
|
|
8071
|
+
}).merge(SourceProvenanceSchema);
|
|
8029
8072
|
var NamedInsuredSchema2 = import_zod27.z.object({
|
|
8030
8073
|
insuredName: import_zod27.z.string().describe("Name of primary named insured"),
|
|
8031
8074
|
insuredDba: import_zod27.z.string().optional().describe("Doing-business-as name"),
|
|
8032
|
-
insuredAddress:
|
|
8075
|
+
insuredAddress: SourceBackedAddressSchema.optional().describe("Primary insured mailing address"),
|
|
8033
8076
|
insuredEntityType: import_zod27.z.enum([
|
|
8034
8077
|
"corporation",
|
|
8035
8078
|
"llc",
|
|
@@ -8046,25 +8089,9 @@ var NamedInsuredSchema2 = import_zod27.z.object({
|
|
|
8046
8089
|
insuredFein: import_zod27.z.string().optional().describe("Federal Employer Identification Number"),
|
|
8047
8090
|
insuredSicCode: import_zod27.z.string().optional().describe("SIC code"),
|
|
8048
8091
|
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")
|
|
8092
|
+
additionalNamedInsureds: import_zod27.z.array(AdditionalNamedInsuredSchema).optional().describe("Additional named insureds listed on the policy"),
|
|
8093
|
+
lossPayees: import_zod27.z.array(ScheduledPartySchema).optional().describe("Loss payees listed on the policy"),
|
|
8094
|
+
mortgageHolders: import_zod27.z.array(ScheduledPartySchema).optional().describe("Mortgage holders / lienholders listed on the policy")
|
|
8068
8095
|
});
|
|
8069
8096
|
function buildNamedInsuredPrompt() {
|
|
8070
8097
|
return `You are an expert insurance document analyst. Extract all named insured information from this document.
|
|
@@ -8081,6 +8108,7 @@ Focus on:
|
|
|
8081
8108
|
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
8109
|
|
|
8083
8110
|
Critical rules:
|
|
8111
|
+
- 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
8112
|
- 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
8113
|
- 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
8114
|
- 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 +8572,6 @@ Return JSON only.`;
|
|
|
8544
8572
|
|
|
8545
8573
|
// src/prompts/extractors/supplementary.ts
|
|
8546
8574
|
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
8575
|
var AuxiliaryFactSchema2 = import_zod36.z.object({
|
|
8555
8576
|
key: import_zod36.z.string().describe("Normalized machine-readable fact key, e.g. 'policyholder_age' or 'insured_name'"),
|
|
8556
8577
|
value: import_zod36.z.string().describe("Concrete extracted fact value"),
|
|
@@ -8558,9 +8579,9 @@ var AuxiliaryFactSchema2 = import_zod36.z.object({
|
|
|
8558
8579
|
context: import_zod36.z.string().optional().describe("Short disambiguating context, such as 'Driver Schedule' or 'Named Insured'")
|
|
8559
8580
|
});
|
|
8560
8581
|
var SupplementarySchema = import_zod36.z.object({
|
|
8561
|
-
regulatoryContacts: import_zod36.z.array(
|
|
8562
|
-
claimsContacts: import_zod36.z.array(
|
|
8563
|
-
thirdPartyAdministrators: import_zod36.z.array(
|
|
8582
|
+
regulatoryContacts: import_zod36.z.array(ContactSchema).optional().describe("Regulatory body contacts (state department of insurance, ombudsman)"),
|
|
8583
|
+
claimsContacts: import_zod36.z.array(ContactSchema).optional().describe("Claims reporting contacts and instructions"),
|
|
8584
|
+
thirdPartyAdministrators: import_zod36.z.array(ContactSchema).optional().describe("Third-party administrators for claims handling"),
|
|
8564
8585
|
cancellationNoticeDays: import_zod36.z.number().optional().describe("Required notice period for cancellation in days"),
|
|
8565
8586
|
nonrenewalNoticeDays: import_zod36.z.number().optional().describe("Required notice period for nonrenewal in days"),
|
|
8566
8587
|
auxiliaryFacts: import_zod36.z.array(AuxiliaryFactSchema2).optional().describe("Additional retrieval-only facts that do not fit the strict primary schema")
|
|
@@ -8575,7 +8596,7 @@ ${alreadyExtractedSummary}
|
|
|
8575
8596
|
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
8597
|
${exclusionBlock}
|
|
8577
8598
|
Focus on:
|
|
8578
|
-
- Regulatory contacts: state department of insurance, regulatory bodies, ombudsman offices \u2014 with phone, email, address
|
|
8599
|
+
- Regulatory contacts: state department of insurance, regulatory bodies, ombudsman offices \u2014 with phone, email, structured address
|
|
8579
8600
|
- Claims contacts: how to report claims, claims department contact info, hours of operation
|
|
8580
8601
|
- Third-party administrators (TPAs) for claims handling
|
|
8581
8602
|
- Cancellation notice period in days
|
|
@@ -8586,6 +8607,8 @@ Focus on:
|
|
|
8586
8607
|
|
|
8587
8608
|
Look for regulatory notices, complaint contact sections, claims reporting instructions, and cancellation/nonrenewal provisions throughout the document.
|
|
8588
8609
|
|
|
8610
|
+
Every regulatoryContacts, claimsContacts, and thirdPartyAdministrators row must include sourceSpanIds from the source evidence. Omit contacts when source spans are unavailable.
|
|
8611
|
+
|
|
8589
8612
|
For auxiliaryFacts:
|
|
8590
8613
|
- ONLY capture facts that are NOT already present in the structured extraction results above.
|
|
8591
8614
|
- 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.
|
|
@@ -10213,6 +10236,8 @@ Rules:
|
|
|
10213
10236
|
- Keep a coverage when it is a real operational coverage/benefit even if only one term needs cleanup.
|
|
10214
10237
|
- When changing a term's semantic meaning, set kind to the corrected normalized term kind.
|
|
10215
10238
|
- Do not add new coverage rows or new terms; this pass cleans the existing projection.
|
|
10239
|
+
- 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.
|
|
10240
|
+
- For each coverage decision, always include termDecisions. Use [] when no terms need cleanup.
|
|
10216
10241
|
- Keep reasons concise and factual.
|
|
10217
10242
|
|
|
10218
10243
|
Candidate projection:
|
|
@@ -10223,9 +10248,6 @@ ${JSON.stringify(nodes, null, 2)}
|
|
|
10223
10248
|
|
|
10224
10249
|
Return JSON with coverageDecisions and warnings only.`;
|
|
10225
10250
|
}
|
|
10226
|
-
function hasOwn(object, key) {
|
|
10227
|
-
return Object.prototype.hasOwnProperty.call(object, key);
|
|
10228
|
-
}
|
|
10229
10251
|
function uniqueStrings(values) {
|
|
10230
10252
|
return [...new Set(values.filter((value) => value.length > 0))];
|
|
10231
10253
|
}
|
|
@@ -10300,18 +10322,16 @@ function applyTermCleanupDecision(term, decision, validNodeIds, validSpanIds) {
|
|
|
10300
10322
|
sourceSpanIds: cleanupIds(decision.sourceSpanIds, validSpanIds, term.sourceSpanIds)
|
|
10301
10323
|
};
|
|
10302
10324
|
if (next.sourceNodeIds.length === 0 && next.sourceSpanIds.length === 0) return term;
|
|
10303
|
-
if (
|
|
10304
|
-
|
|
10305
|
-
else delete next.amount;
|
|
10325
|
+
if (typeof decision.amount === "number" && Number.isFinite(decision.amount)) {
|
|
10326
|
+
next.amount = decision.amount;
|
|
10306
10327
|
} else if (decision.value || decision.kind) {
|
|
10307
10328
|
const amount = next.kind === "retroactive_date" ? void 0 : amountFromOperationalValue(next.value);
|
|
10308
10329
|
if (amount === void 0) delete next.amount;
|
|
10309
10330
|
else next.amount = amount;
|
|
10310
10331
|
}
|
|
10311
|
-
if (
|
|
10332
|
+
if (decision.appliesTo != null) {
|
|
10312
10333
|
const appliesTo = cleanProfileValue(decision.appliesTo);
|
|
10313
10334
|
if (appliesTo) next.appliesTo = appliesTo;
|
|
10314
|
-
else delete next.appliesTo;
|
|
10315
10335
|
}
|
|
10316
10336
|
return next;
|
|
10317
10337
|
}
|
|
@@ -10330,46 +10350,42 @@ function applyCoverageCleanupDecision(coverage, decision, validNodeIds, validSpa
|
|
|
10330
10350
|
const name = cleanProfileValue(decision.name);
|
|
10331
10351
|
if (name) next.name = name;
|
|
10332
10352
|
if (decision.coverageOrigin) next.coverageOrigin = decision.coverageOrigin;
|
|
10333
|
-
if (
|
|
10353
|
+
if (decision.limit != null) {
|
|
10334
10354
|
const value = cleanProfileValue(decision.limit);
|
|
10335
10355
|
if (value) next.limit = value;
|
|
10336
|
-
else delete next.limit;
|
|
10337
10356
|
}
|
|
10338
|
-
if (
|
|
10357
|
+
if (decision.deductible != null) {
|
|
10339
10358
|
const value = cleanProfileValue(decision.deductible);
|
|
10340
10359
|
if (value) next.deductible = value;
|
|
10341
|
-
else delete next.deductible;
|
|
10342
10360
|
}
|
|
10343
|
-
if (
|
|
10361
|
+
if (decision.premium != null) {
|
|
10344
10362
|
const value = cleanProfileValue(decision.premium);
|
|
10345
10363
|
if (value) next.premium = value;
|
|
10346
|
-
else delete next.premium;
|
|
10347
10364
|
}
|
|
10348
|
-
if (
|
|
10365
|
+
if (decision.retroactiveDate != null) {
|
|
10349
10366
|
const value = cleanProfileValue(decision.retroactiveDate);
|
|
10350
10367
|
if (value) next.retroactiveDate = value;
|
|
10351
|
-
else delete next.retroactiveDate;
|
|
10352
10368
|
}
|
|
10353
10369
|
const termDecisions = (decision.termDecisions ?? []).filter((termDecision) => termDecision.termIndex < coverage.limits.length);
|
|
10354
10370
|
const termDecisionByIndex = new Map(termDecisions.map((termDecision) => [termDecision.termIndex, termDecision]));
|
|
10355
10371
|
next.limits = coverage.limits.map((term, index) => applyTermCleanupDecision(term, termDecisionByIndex.get(index), validNodeIds, validSpanIds)).filter((term) => Boolean(term));
|
|
10356
10372
|
if (termDecisions.length > 0) {
|
|
10357
|
-
if (
|
|
10373
|
+
if (decision.limit == null && termDecisionsTouch(coverage, termDecisions, isLimitTerm)) {
|
|
10358
10374
|
const value = primaryLimitFromTerms(next.limits);
|
|
10359
10375
|
if (value) next.limit = value;
|
|
10360
10376
|
else delete next.limit;
|
|
10361
10377
|
}
|
|
10362
|
-
if (
|
|
10378
|
+
if (decision.deductible == null && termDecisionsTouch(coverage, termDecisions, isDeductibleTerm)) {
|
|
10363
10379
|
const value = deductibleFromTerms(next.limits);
|
|
10364
10380
|
if (value) next.deductible = value;
|
|
10365
10381
|
else delete next.deductible;
|
|
10366
10382
|
}
|
|
10367
|
-
if (
|
|
10383
|
+
if (decision.premium == null && termDecisionsTouch(coverage, termDecisions, isPremiumTerm)) {
|
|
10368
10384
|
const value = premiumFromTerms(next.limits);
|
|
10369
10385
|
if (value) next.premium = value;
|
|
10370
10386
|
else delete next.premium;
|
|
10371
10387
|
}
|
|
10372
|
-
if (
|
|
10388
|
+
if (decision.retroactiveDate == null && termDecisionsTouch(coverage, termDecisions, isRetroactiveDateTerm)) {
|
|
10373
10389
|
const value = retroactiveDateFromTerms(next.limits);
|
|
10374
10390
|
if (value) next.retroactiveDate = value;
|
|
10375
10391
|
else delete next.retroactiveDate;
|
|
@@ -11800,6 +11816,13 @@ function valueOf(profile, key) {
|
|
|
11800
11816
|
}
|
|
11801
11817
|
return String(value.value);
|
|
11802
11818
|
}
|
|
11819
|
+
function provenanceOf(value) {
|
|
11820
|
+
if (!value?.sourceSpanIds.length) return void 0;
|
|
11821
|
+
return {
|
|
11822
|
+
sourceSpanIds: value.sourceSpanIds,
|
|
11823
|
+
...value.sourceNodeIds[0] ? { documentNodeId: value.sourceNodeIds[0] } : {}
|
|
11824
|
+
};
|
|
11825
|
+
}
|
|
11803
11826
|
function materializeDocument(params) {
|
|
11804
11827
|
const profile = params.operationalProfile;
|
|
11805
11828
|
const policyNumber = valueOf(profile, "policyNumber") ?? "Unknown";
|
|
@@ -11808,6 +11831,9 @@ function materializeDocument(params) {
|
|
|
11808
11831
|
const effectiveDate = valueOf(profile, "effectiveDate") ?? "Unknown";
|
|
11809
11832
|
const expirationDate = valueOf(profile, "expirationDate") ?? "Unknown";
|
|
11810
11833
|
const premium = valueOf(profile, "premium");
|
|
11834
|
+
const insurerProvenance = provenanceOf(profile.insurer);
|
|
11835
|
+
const broker = valueOf(profile, "broker");
|
|
11836
|
+
const brokerProvenance = provenanceOf(profile.broker);
|
|
11811
11837
|
const coverages = profile.coverages.map((coverage) => ({
|
|
11812
11838
|
name: coverage.name,
|
|
11813
11839
|
coverageCode: coverage.coverageCode,
|
|
@@ -11859,6 +11885,11 @@ function materializeDocument(params) {
|
|
|
11859
11885
|
security: carrier,
|
|
11860
11886
|
insuredName,
|
|
11861
11887
|
premium,
|
|
11888
|
+
...insurerProvenance ? { insurer: { legalName: carrier, ...insurerProvenance } } : {},
|
|
11889
|
+
...broker && brokerProvenance ? {
|
|
11890
|
+
brokerAgency: broker,
|
|
11891
|
+
producer: { agencyName: broker, ...brokerProvenance }
|
|
11892
|
+
} : {},
|
|
11862
11893
|
policyTypes: profile.policyTypes,
|
|
11863
11894
|
formInventory: params.formInventory.filter((form) => typeof form.formNumber === "string" && form.formNumber.trim().length > 0).map((form) => ({
|
|
11864
11895
|
formNumber: form.formNumber,
|
|
@@ -17542,9 +17573,11 @@ var AGENT_TOOLS = [
|
|
|
17542
17573
|
ScheduledItemCategorySchema,
|
|
17543
17574
|
SectionSchema,
|
|
17544
17575
|
SharedLimitSchema,
|
|
17576
|
+
SourceBackedAddressSchema,
|
|
17545
17577
|
SourceBackedValueSchema,
|
|
17546
17578
|
SourceChunkSchema,
|
|
17547
17579
|
SourceKindSchema,
|
|
17580
|
+
SourceProvenanceSchema,
|
|
17548
17581
|
SourceSpanBBoxSchema,
|
|
17549
17582
|
SourceSpanKindSchema,
|
|
17550
17583
|
SourceSpanLocationSchema,
|