@claritylabs/cl-sdk 3.1.2 → 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 +748 -371
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +746 -371
- 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(),
|
|
@@ -3757,15 +3767,6 @@ function sourceIds(nodes) {
|
|
|
3757
3767
|
sourceSpanIds: [...new Set(nodes.flatMap((node) => node.sourceSpanIds))]
|
|
3758
3768
|
};
|
|
3759
3769
|
}
|
|
3760
|
-
function relabelGenericTerm(term, label) {
|
|
3761
|
-
const cleanLabel = cleanValue(label);
|
|
3762
|
-
if (!cleanLabel || !/^column\s+\d+$/i.test(term.label)) return term;
|
|
3763
|
-
return {
|
|
3764
|
-
...term,
|
|
3765
|
-
kind: termKind(cleanLabel, term.value),
|
|
3766
|
-
label: cleanLabel
|
|
3767
|
-
};
|
|
3768
|
-
}
|
|
3769
3770
|
function termFromCell(params) {
|
|
3770
3771
|
const value = cleanCoverageTermValue(params.value);
|
|
3771
3772
|
if (!value) return void 0;
|
|
@@ -3915,8 +3916,7 @@ function coverageFromEndorsement(endorsement, children) {
|
|
|
3915
3916
|
const terms = uniqueTerms(rows.flatMap(
|
|
3916
3917
|
(row) => termsFromRow(row, children).map((term) => {
|
|
3917
3918
|
const appliesTo = nameFromRow(row, children);
|
|
3918
|
-
|
|
3919
|
-
return appliesTo && labelled.label !== appliesTo ? { ...labelled, appliesTo } : labelled;
|
|
3919
|
+
return appliesTo && term.label !== appliesTo ? { ...term, appliesTo } : term;
|
|
3920
3920
|
})
|
|
3921
3921
|
));
|
|
3922
3922
|
if (terms.length === 0) return void 0;
|
|
@@ -5027,6 +5027,17 @@ function getCoveredReasons(memory) {
|
|
|
5027
5027
|
}
|
|
5028
5028
|
|
|
5029
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
|
+
}
|
|
5030
5041
|
function stringValue(value) {
|
|
5031
5042
|
return typeof value === "string" && value.trim() ? value : void 0;
|
|
5032
5043
|
}
|
|
@@ -5047,36 +5058,38 @@ function promoteRawFields(raw, mappings) {
|
|
|
5047
5058
|
}
|
|
5048
5059
|
function promoteCarrierFields(doc) {
|
|
5049
5060
|
const raw = doc;
|
|
5061
|
+
const provenance = sourceProvenance(raw);
|
|
5050
5062
|
promoteRawFields(raw, [
|
|
5051
5063
|
{ from: "naicNumber", to: "carrierNaicNumber" },
|
|
5052
5064
|
{ from: "amBestRating", to: "carrierAmBestRating" },
|
|
5053
5065
|
{ from: "admittedStatus", to: "carrierAdmittedStatus" }
|
|
5054
5066
|
]);
|
|
5055
|
-
if (!raw.insurer && raw.carrierLegalName) {
|
|
5067
|
+
if (!raw.insurer && raw.carrierLegalName && provenance) {
|
|
5056
5068
|
raw.insurer = {
|
|
5057
5069
|
legalName: raw.carrierLegalName,
|
|
5058
5070
|
...raw.carrierNaicNumber ? { naicNumber: raw.carrierNaicNumber } : {},
|
|
5059
5071
|
...raw.carrierAmBestRating ? { amBestRating: raw.carrierAmBestRating } : {},
|
|
5060
|
-
...raw.carrierAdmittedStatus ? { admittedStatus: raw.carrierAdmittedStatus } : {}
|
|
5072
|
+
...raw.carrierAdmittedStatus ? { admittedStatus: raw.carrierAdmittedStatus } : {},
|
|
5073
|
+
...provenance
|
|
5061
5074
|
};
|
|
5062
5075
|
}
|
|
5063
5076
|
}
|
|
5064
5077
|
function promoteBroker(doc) {
|
|
5065
5078
|
const raw = doc;
|
|
5079
|
+
const provenance = sourceProvenance(raw);
|
|
5066
5080
|
const brokerAgency = findRawString(raw, ["brokerAgency"]);
|
|
5067
5081
|
const brokerContact = findRawString(raw, ["brokerContactName"]);
|
|
5068
5082
|
const brokerLicense = findRawString(raw, ["brokerLicenseNumber"]);
|
|
5069
5083
|
const brokerPhone = findRawString(raw, ["brokerPhone"]);
|
|
5070
5084
|
const brokerEmail = findRawString(raw, ["brokerEmail"]);
|
|
5071
|
-
|
|
5072
|
-
if (!raw.producer && brokerAgency) {
|
|
5085
|
+
if (!raw.producer && brokerAgency && provenance) {
|
|
5073
5086
|
raw.producer = {
|
|
5074
5087
|
agencyName: brokerAgency,
|
|
5075
5088
|
...brokerContact ? { contactName: brokerContact } : {},
|
|
5076
5089
|
...brokerLicense ? { licenseNumber: brokerLicense } : {},
|
|
5077
5090
|
...brokerPhone ? { phone: brokerPhone } : {},
|
|
5078
5091
|
...brokerEmail ? { email: brokerEmail } : {},
|
|
5079
|
-
...
|
|
5092
|
+
...provenance
|
|
5080
5093
|
};
|
|
5081
5094
|
}
|
|
5082
5095
|
}
|
|
@@ -8030,16 +8043,19 @@ Return JSON only.`;
|
|
|
8030
8043
|
|
|
8031
8044
|
// src/prompts/extractors/named-insured.ts
|
|
8032
8045
|
var import_zod27 = require("zod");
|
|
8033
|
-
var
|
|
8034
|
-
|
|
8035
|
-
|
|
8036
|
-
|
|
8037
|
-
|
|
8038
|
-
|
|
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);
|
|
8039
8055
|
var NamedInsuredSchema2 = import_zod27.z.object({
|
|
8040
8056
|
insuredName: import_zod27.z.string().describe("Name of primary named insured"),
|
|
8041
8057
|
insuredDba: import_zod27.z.string().optional().describe("Doing-business-as name"),
|
|
8042
|
-
insuredAddress:
|
|
8058
|
+
insuredAddress: SourceBackedAddressSchema.optional().describe("Primary insured mailing address"),
|
|
8043
8059
|
insuredEntityType: import_zod27.z.enum([
|
|
8044
8060
|
"corporation",
|
|
8045
8061
|
"llc",
|
|
@@ -8056,25 +8072,9 @@ var NamedInsuredSchema2 = import_zod27.z.object({
|
|
|
8056
8072
|
insuredFein: import_zod27.z.string().optional().describe("Federal Employer Identification Number"),
|
|
8057
8073
|
insuredSicCode: import_zod27.z.string().optional().describe("SIC code"),
|
|
8058
8074
|
insuredNaicsCode: import_zod27.z.string().optional().describe("NAICS code"),
|
|
8059
|
-
additionalNamedInsureds: import_zod27.z.array(
|
|
8060
|
-
|
|
8061
|
-
|
|
8062
|
-
relationship: import_zod27.z.string().optional().describe("e.g. subsidiary, affiliate"),
|
|
8063
|
-
address: AddressSchema2.optional()
|
|
8064
|
-
})
|
|
8065
|
-
).optional().describe("Additional named insureds listed on the policy"),
|
|
8066
|
-
lossPayees: import_zod27.z.array(
|
|
8067
|
-
import_zod27.z.object({
|
|
8068
|
-
name: import_zod27.z.string(),
|
|
8069
|
-
address: AddressSchema2.optional()
|
|
8070
|
-
})
|
|
8071
|
-
).optional().describe("Loss payees listed on the policy"),
|
|
8072
|
-
mortgageHolders: import_zod27.z.array(
|
|
8073
|
-
import_zod27.z.object({
|
|
8074
|
-
name: import_zod27.z.string(),
|
|
8075
|
-
address: AddressSchema2.optional()
|
|
8076
|
-
})
|
|
8077
|
-
).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")
|
|
8078
8078
|
});
|
|
8079
8079
|
function buildNamedInsuredPrompt() {
|
|
8080
8080
|
return `You are an expert insurance document analyst. Extract all named insured information from this document.
|
|
@@ -8091,6 +8091,7 @@ Focus on:
|
|
|
8091
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.
|
|
8092
8092
|
|
|
8093
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.
|
|
8094
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.
|
|
8095
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.
|
|
8096
8097
|
- If a row combines the insured name with a mailing address, put the legal name in insuredName and the mailing address in insuredAddress.
|
|
@@ -8554,13 +8555,6 @@ Return JSON only.`;
|
|
|
8554
8555
|
|
|
8555
8556
|
// src/prompts/extractors/supplementary.ts
|
|
8556
8557
|
var import_zod36 = require("zod");
|
|
8557
|
-
var ContactSchema2 = import_zod36.z.object({
|
|
8558
|
-
name: import_zod36.z.string().optional().describe("Organization or person name"),
|
|
8559
|
-
phone: import_zod36.z.string().optional().describe("Phone number"),
|
|
8560
|
-
email: import_zod36.z.string().optional().describe("Email address"),
|
|
8561
|
-
address: import_zod36.z.string().optional().describe("Mailing address"),
|
|
8562
|
-
type: import_zod36.z.string().optional().describe("Contact type, e.g. 'State Department of Insurance'")
|
|
8563
|
-
});
|
|
8564
8558
|
var AuxiliaryFactSchema2 = import_zod36.z.object({
|
|
8565
8559
|
key: import_zod36.z.string().describe("Normalized machine-readable fact key, e.g. 'policyholder_age' or 'insured_name'"),
|
|
8566
8560
|
value: import_zod36.z.string().describe("Concrete extracted fact value"),
|
|
@@ -8568,9 +8562,9 @@ var AuxiliaryFactSchema2 = import_zod36.z.object({
|
|
|
8568
8562
|
context: import_zod36.z.string().optional().describe("Short disambiguating context, such as 'Driver Schedule' or 'Named Insured'")
|
|
8569
8563
|
});
|
|
8570
8564
|
var SupplementarySchema = import_zod36.z.object({
|
|
8571
|
-
regulatoryContacts: import_zod36.z.array(
|
|
8572
|
-
claimsContacts: import_zod36.z.array(
|
|
8573
|
-
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"),
|
|
8574
8568
|
cancellationNoticeDays: import_zod36.z.number().optional().describe("Required notice period for cancellation in days"),
|
|
8575
8569
|
nonrenewalNoticeDays: import_zod36.z.number().optional().describe("Required notice period for nonrenewal in days"),
|
|
8576
8570
|
auxiliaryFacts: import_zod36.z.array(AuxiliaryFactSchema2).optional().describe("Additional retrieval-only facts that do not fit the strict primary schema")
|
|
@@ -8585,7 +8579,7 @@ ${alreadyExtractedSummary}
|
|
|
8585
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.
|
|
8586
8580
|
${exclusionBlock}
|
|
8587
8581
|
Focus on:
|
|
8588
|
-
- 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
|
|
8589
8583
|
- Claims contacts: how to report claims, claims department contact info, hours of operation
|
|
8590
8584
|
- Third-party administrators (TPAs) for claims handling
|
|
8591
8585
|
- Cancellation notice period in days
|
|
@@ -8596,6 +8590,8 @@ Focus on:
|
|
|
8596
8590
|
|
|
8597
8591
|
Look for regulatory notices, complaint contact sections, claims reporting instructions, and cancellation/nonrenewal provisions throughout the document.
|
|
8598
8592
|
|
|
8593
|
+
Every regulatoryContacts, claimsContacts, and thirdPartyAdministrators row must include sourceSpanIds from the source evidence. Omit contacts when source spans are unavailable.
|
|
8594
|
+
|
|
8599
8595
|
For auxiliaryFacts:
|
|
8600
8596
|
- ONLY capture facts that are NOT already present in the structured extraction results above.
|
|
8601
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.
|
|
@@ -10111,7 +10107,343 @@ function groundExtractionMemoryWithSourceSpans(memory, sourceSpans) {
|
|
|
10111
10107
|
}
|
|
10112
10108
|
|
|
10113
10109
|
// src/extraction/source-tree-extractor.ts
|
|
10110
|
+
var import_zod42 = require("zod");
|
|
10111
|
+
|
|
10112
|
+
// src/extraction/operational-profile-cleanup.ts
|
|
10114
10113
|
var import_zod41 = require("zod");
|
|
10114
|
+
var OPERATIONAL_COVERAGE_TERM_KINDS2 = [
|
|
10115
|
+
"each_claim_limit",
|
|
10116
|
+
"each_occurrence_limit",
|
|
10117
|
+
"each_loss_limit",
|
|
10118
|
+
"aggregate_limit",
|
|
10119
|
+
"sublimit",
|
|
10120
|
+
"retention",
|
|
10121
|
+
"deductible",
|
|
10122
|
+
"retroactive_date",
|
|
10123
|
+
"premium",
|
|
10124
|
+
"other"
|
|
10125
|
+
];
|
|
10126
|
+
var OperationalCoverageTermKindSchema = import_zod41.z.enum(OPERATIONAL_COVERAGE_TERM_KINDS2);
|
|
10127
|
+
var OperationalProfileCleanupSchema = import_zod41.z.object({
|
|
10128
|
+
coverageDecisions: import_zod41.z.array(import_zod41.z.object({
|
|
10129
|
+
coverageIndex: import_zod41.z.number().int().nonnegative(),
|
|
10130
|
+
action: import_zod41.z.enum(["keep", "drop", "update"]),
|
|
10131
|
+
reason: import_zod41.z.string().optional(),
|
|
10132
|
+
name: import_zod41.z.string().optional(),
|
|
10133
|
+
limit: import_zod41.z.string().nullable().optional(),
|
|
10134
|
+
deductible: import_zod41.z.string().nullable().optional(),
|
|
10135
|
+
premium: import_zod41.z.string().nullable().optional(),
|
|
10136
|
+
retroactiveDate: import_zod41.z.string().nullable().optional(),
|
|
10137
|
+
coverageOrigin: import_zod41.z.enum(["core", "endorsement"]).optional(),
|
|
10138
|
+
sourceNodeIds: import_zod41.z.array(import_zod41.z.string()).optional(),
|
|
10139
|
+
sourceSpanIds: import_zod41.z.array(import_zod41.z.string()).optional(),
|
|
10140
|
+
termDecisions: import_zod41.z.array(import_zod41.z.object({
|
|
10141
|
+
termIndex: import_zod41.z.number().int().nonnegative(),
|
|
10142
|
+
action: import_zod41.z.enum(["keep", "drop", "update"]),
|
|
10143
|
+
reason: import_zod41.z.string().optional(),
|
|
10144
|
+
kind: OperationalCoverageTermKindSchema.optional(),
|
|
10145
|
+
label: import_zod41.z.string().optional(),
|
|
10146
|
+
value: import_zod41.z.string().optional(),
|
|
10147
|
+
amount: import_zod41.z.number().nullable().optional(),
|
|
10148
|
+
appliesTo: import_zod41.z.string().nullable().optional(),
|
|
10149
|
+
sourceNodeIds: import_zod41.z.array(import_zod41.z.string()).optional(),
|
|
10150
|
+
sourceSpanIds: import_zod41.z.array(import_zod41.z.string()).optional()
|
|
10151
|
+
})).optional()
|
|
10152
|
+
})).default([]),
|
|
10153
|
+
warnings: import_zod41.z.array(import_zod41.z.string()).default([])
|
|
10154
|
+
});
|
|
10155
|
+
function compactNode(node, maxText = 700) {
|
|
10156
|
+
return {
|
|
10157
|
+
id: node.id,
|
|
10158
|
+
kind: node.kind,
|
|
10159
|
+
title: node.title,
|
|
10160
|
+
path: node.path,
|
|
10161
|
+
pageStart: node.pageStart,
|
|
10162
|
+
pageEnd: node.pageEnd,
|
|
10163
|
+
sourceSpanIds: node.sourceSpanIds.slice(0, 8),
|
|
10164
|
+
text: (node.textExcerpt ?? node.description).slice(0, maxText)
|
|
10165
|
+
};
|
|
10166
|
+
}
|
|
10167
|
+
function compactCoverageForCleanup(coverage, coverageIndex) {
|
|
10168
|
+
return {
|
|
10169
|
+
coverageIndex,
|
|
10170
|
+
name: coverage.name,
|
|
10171
|
+
limit: coverage.limit,
|
|
10172
|
+
deductible: coverage.deductible,
|
|
10173
|
+
premium: coverage.premium,
|
|
10174
|
+
retroactiveDate: coverage.retroactiveDate,
|
|
10175
|
+
coverageOrigin: coverage.coverageOrigin,
|
|
10176
|
+
sourceNodeIds: coverage.sourceNodeIds,
|
|
10177
|
+
sourceSpanIds: coverage.sourceSpanIds,
|
|
10178
|
+
terms: coverage.limits.map((term, termIndex) => ({
|
|
10179
|
+
termIndex,
|
|
10180
|
+
kind: term.kind,
|
|
10181
|
+
label: term.label,
|
|
10182
|
+
value: term.value,
|
|
10183
|
+
amount: term.amount,
|
|
10184
|
+
appliesTo: term.appliesTo,
|
|
10185
|
+
sourceNodeIds: term.sourceNodeIds,
|
|
10186
|
+
sourceSpanIds: term.sourceSpanIds
|
|
10187
|
+
}))
|
|
10188
|
+
};
|
|
10189
|
+
}
|
|
10190
|
+
function buildOperationalProfileCleanupPrompt(sourceTree, profile) {
|
|
10191
|
+
const nodes = sourceTree.filter((node) => node.kind !== "document").slice(0, 320).map((node) => compactNode(node, node.kind === "page" ? 900 : 700));
|
|
10192
|
+
const candidate = {
|
|
10193
|
+
documentType: profile.documentType,
|
|
10194
|
+
policyTypes: profile.policyTypes,
|
|
10195
|
+
coverageTypes: profile.coverageTypes,
|
|
10196
|
+
coverages: profile.coverages.map(compactCoverageForCleanup)
|
|
10197
|
+
};
|
|
10198
|
+
return `Review and clean a source-backed operational profile projection for an insurance policy.
|
|
10199
|
+
|
|
10200
|
+
Task:
|
|
10201
|
+
- Inspect the candidate coverage projection against the source nodes.
|
|
10202
|
+
- Return cleanup decisions only for coverage rows or terms that are malformed, unsupported, mismatched, or misleading.
|
|
10203
|
+
- If the projection is already acceptable, return an empty coverageDecisions array.
|
|
10204
|
+
|
|
10205
|
+
Projection defects to look for:
|
|
10206
|
+
- Generic labels such as "Column 3" that should be renamed from nearby row/header evidence.
|
|
10207
|
+
- Declaration or section headers projected as coverage names when the row evidence is actually a specific coverage, sub-limit, deductible, retention, retroactive date, or premium.
|
|
10208
|
+
- Dangling continuation punctuation such as a trailing "/" copied into values.
|
|
10209
|
+
- Item references such as "shown in Item 7" or bare item numbers treated as money amounts.
|
|
10210
|
+
- Policy wording, exclusions, or unsupported prose copied into operational limit/deductible fields.
|
|
10211
|
+
- Header/value splits where "Limit of Liability", "Deductible", "Retroactive Date", "Aggregate", "Each Claim", or similar terms are attached to the wrong coverage row.
|
|
10212
|
+
- Repeated schedule headings projected as separate coverages when they only introduce the next coverage group.
|
|
10213
|
+
|
|
10214
|
+
Rules:
|
|
10215
|
+
- Use internal reasoning, but return JSON decisions only.
|
|
10216
|
+
- Do not invent policy facts. Keep, drop, or update only existing coverageIndex and termIndex entries.
|
|
10217
|
+
- Use sourceNodeIds and sourceSpanIds only from the provided source nodes or from the existing candidate entry.
|
|
10218
|
+
- Prefer dropping a malformed fact over speculative rewriting.
|
|
10219
|
+
- Keep a coverage when it is a real operational coverage/benefit even if only one term needs cleanup.
|
|
10220
|
+
- When changing a term's semantic meaning, set kind to the corrected normalized term kind.
|
|
10221
|
+
- Do not add new coverage rows or new terms; this pass cleans the existing projection.
|
|
10222
|
+
- Keep reasons concise and factual.
|
|
10223
|
+
|
|
10224
|
+
Candidate projection:
|
|
10225
|
+
${JSON.stringify(candidate, null, 2)}
|
|
10226
|
+
|
|
10227
|
+
Source nodes:
|
|
10228
|
+
${JSON.stringify(nodes, null, 2)}
|
|
10229
|
+
|
|
10230
|
+
Return JSON with coverageDecisions and warnings only.`;
|
|
10231
|
+
}
|
|
10232
|
+
function hasOwn(object, key) {
|
|
10233
|
+
return Object.prototype.hasOwnProperty.call(object, key);
|
|
10234
|
+
}
|
|
10235
|
+
function uniqueStrings(values) {
|
|
10236
|
+
return [...new Set(values.filter((value) => value.length > 0))];
|
|
10237
|
+
}
|
|
10238
|
+
function cleanProfileValue(value) {
|
|
10239
|
+
if (typeof value !== "string") return void 0;
|
|
10240
|
+
const cleaned = value.replace(/\s+\/\s*$/, "").replace(/\s+/g, " ").replace(/^[\s:;#-]+|[\s;,.]+$/g, "").trim();
|
|
10241
|
+
return cleaned || void 0;
|
|
10242
|
+
}
|
|
10243
|
+
function validIds(ids, valid) {
|
|
10244
|
+
return uniqueStrings((ids ?? []).filter((id) => valid.has(id)));
|
|
10245
|
+
}
|
|
10246
|
+
function cleanupIds(ids, valid, fallback) {
|
|
10247
|
+
if (ids === void 0) return validIds(fallback, valid);
|
|
10248
|
+
const next = validIds(ids, valid);
|
|
10249
|
+
return next.length > 0 ? next : validIds(fallback, valid);
|
|
10250
|
+
}
|
|
10251
|
+
function amountFromOperationalValue(value) {
|
|
10252
|
+
const match = value.match(/\$\s*([0-9][0-9,]*(?:\.\d+)?)/) ?? value.match(/\b([0-9][0-9,]*(?:\.\d+)?)\s*%/);
|
|
10253
|
+
if (!match) return void 0;
|
|
10254
|
+
const amount = Number(match[1].replace(/,/g, ""));
|
|
10255
|
+
return Number.isFinite(amount) ? amount : void 0;
|
|
10256
|
+
}
|
|
10257
|
+
function normalizedTermText(term) {
|
|
10258
|
+
return `${term.kind} ${term.label} ${term.value}`.toLowerCase();
|
|
10259
|
+
}
|
|
10260
|
+
function isLimitTerm(term) {
|
|
10261
|
+
return ["each_claim_limit", "each_occurrence_limit", "each_loss_limit", "aggregate_limit", "sublimit"].includes(term.kind) || term.kind === "other" && /\b(limit|aggregate|claim|occurrence|loss|proceeding)\b/i.test(normalizedTermText(term));
|
|
10262
|
+
}
|
|
10263
|
+
function isDeductibleTerm(term) {
|
|
10264
|
+
return term.kind === "deductible" || term.kind === "retention" || /\b(deductible|retention|sir)\b/i.test(normalizedTermText(term));
|
|
10265
|
+
}
|
|
10266
|
+
function isPremiumTerm(term) {
|
|
10267
|
+
return term.kind === "premium" || /\bpremium\b/i.test(normalizedTermText(term));
|
|
10268
|
+
}
|
|
10269
|
+
function isRetroactiveDateTerm(term) {
|
|
10270
|
+
return term.kind === "retroactive_date" || /\bretroactive\b/i.test(normalizedTermText(term));
|
|
10271
|
+
}
|
|
10272
|
+
function primaryLimitFromTerms(terms) {
|
|
10273
|
+
return terms.find(isLimitTerm)?.value;
|
|
10274
|
+
}
|
|
10275
|
+
function deductibleFromTerms(terms) {
|
|
10276
|
+
return terms.find(isDeductibleTerm)?.value;
|
|
10277
|
+
}
|
|
10278
|
+
function premiumFromTerms(terms) {
|
|
10279
|
+
return terms.find(isPremiumTerm)?.value;
|
|
10280
|
+
}
|
|
10281
|
+
function retroactiveDateFromTerms(terms) {
|
|
10282
|
+
return terms.find(isRetroactiveDateTerm)?.value;
|
|
10283
|
+
}
|
|
10284
|
+
function termDecisionTouches(coverage, decision, predicate) {
|
|
10285
|
+
const existing = coverage.limits[decision.termIndex];
|
|
10286
|
+
if (existing && predicate(existing)) return true;
|
|
10287
|
+
if (!decision.kind && !decision.label && !decision.value) return false;
|
|
10288
|
+
return predicate({
|
|
10289
|
+
kind: decision.kind ?? existing?.kind ?? "other",
|
|
10290
|
+
label: cleanProfileValue(decision.label) ?? existing?.label ?? "",
|
|
10291
|
+
value: cleanProfileValue(decision.value) ?? existing?.value ?? ""
|
|
10292
|
+
});
|
|
10293
|
+
}
|
|
10294
|
+
function applyTermCleanupDecision(term, decision, validNodeIds, validSpanIds) {
|
|
10295
|
+
if (!decision || decision.action === "keep") return term;
|
|
10296
|
+
if (decision.action === "drop") return void 0;
|
|
10297
|
+
const label = cleanProfileValue(decision.label) ?? term.label;
|
|
10298
|
+
const value = cleanProfileValue(decision.value) ?? term.value;
|
|
10299
|
+
if (!label || !value) return term;
|
|
10300
|
+
const next = {
|
|
10301
|
+
...term,
|
|
10302
|
+
kind: decision.kind ?? term.kind,
|
|
10303
|
+
label,
|
|
10304
|
+
value,
|
|
10305
|
+
sourceNodeIds: cleanupIds(decision.sourceNodeIds, validNodeIds, term.sourceNodeIds),
|
|
10306
|
+
sourceSpanIds: cleanupIds(decision.sourceSpanIds, validSpanIds, term.sourceSpanIds)
|
|
10307
|
+
};
|
|
10308
|
+
if (next.sourceNodeIds.length === 0 && next.sourceSpanIds.length === 0) return term;
|
|
10309
|
+
if (hasOwn(decision, "amount")) {
|
|
10310
|
+
if (typeof decision.amount === "number" && Number.isFinite(decision.amount)) next.amount = decision.amount;
|
|
10311
|
+
else delete next.amount;
|
|
10312
|
+
} else if (decision.value || decision.kind) {
|
|
10313
|
+
const amount = next.kind === "retroactive_date" ? void 0 : amountFromOperationalValue(next.value);
|
|
10314
|
+
if (amount === void 0) delete next.amount;
|
|
10315
|
+
else next.amount = amount;
|
|
10316
|
+
}
|
|
10317
|
+
if (hasOwn(decision, "appliesTo")) {
|
|
10318
|
+
const appliesTo = cleanProfileValue(decision.appliesTo);
|
|
10319
|
+
if (appliesTo) next.appliesTo = appliesTo;
|
|
10320
|
+
else delete next.appliesTo;
|
|
10321
|
+
}
|
|
10322
|
+
return next;
|
|
10323
|
+
}
|
|
10324
|
+
function termDecisionsTouch(coverage, decisions, predicate) {
|
|
10325
|
+
return decisions.filter((decision) => decision.action !== "keep").some((decision) => termDecisionTouches(coverage, decision, predicate));
|
|
10326
|
+
}
|
|
10327
|
+
function applyCoverageCleanupDecision(coverage, decision, validNodeIds, validSpanIds) {
|
|
10328
|
+
if (!decision || decision.action === "keep") return coverage;
|
|
10329
|
+
if (decision.action === "drop") return void 0;
|
|
10330
|
+
const next = {
|
|
10331
|
+
...coverage,
|
|
10332
|
+
limits: [...coverage.limits],
|
|
10333
|
+
sourceNodeIds: cleanupIds(decision.sourceNodeIds, validNodeIds, coverage.sourceNodeIds),
|
|
10334
|
+
sourceSpanIds: cleanupIds(decision.sourceSpanIds, validSpanIds, coverage.sourceSpanIds)
|
|
10335
|
+
};
|
|
10336
|
+
const name = cleanProfileValue(decision.name);
|
|
10337
|
+
if (name) next.name = name;
|
|
10338
|
+
if (decision.coverageOrigin) next.coverageOrigin = decision.coverageOrigin;
|
|
10339
|
+
if (hasOwn(decision, "limit")) {
|
|
10340
|
+
const value = cleanProfileValue(decision.limit);
|
|
10341
|
+
if (value) next.limit = value;
|
|
10342
|
+
else delete next.limit;
|
|
10343
|
+
}
|
|
10344
|
+
if (hasOwn(decision, "deductible")) {
|
|
10345
|
+
const value = cleanProfileValue(decision.deductible);
|
|
10346
|
+
if (value) next.deductible = value;
|
|
10347
|
+
else delete next.deductible;
|
|
10348
|
+
}
|
|
10349
|
+
if (hasOwn(decision, "premium")) {
|
|
10350
|
+
const value = cleanProfileValue(decision.premium);
|
|
10351
|
+
if (value) next.premium = value;
|
|
10352
|
+
else delete next.premium;
|
|
10353
|
+
}
|
|
10354
|
+
if (hasOwn(decision, "retroactiveDate")) {
|
|
10355
|
+
const value = cleanProfileValue(decision.retroactiveDate);
|
|
10356
|
+
if (value) next.retroactiveDate = value;
|
|
10357
|
+
else delete next.retroactiveDate;
|
|
10358
|
+
}
|
|
10359
|
+
const termDecisions = (decision.termDecisions ?? []).filter((termDecision) => termDecision.termIndex < coverage.limits.length);
|
|
10360
|
+
const termDecisionByIndex = new Map(termDecisions.map((termDecision) => [termDecision.termIndex, termDecision]));
|
|
10361
|
+
next.limits = coverage.limits.map((term, index) => applyTermCleanupDecision(term, termDecisionByIndex.get(index), validNodeIds, validSpanIds)).filter((term) => Boolean(term));
|
|
10362
|
+
if (termDecisions.length > 0) {
|
|
10363
|
+
if (!hasOwn(decision, "limit") && termDecisionsTouch(coverage, termDecisions, isLimitTerm)) {
|
|
10364
|
+
const value = primaryLimitFromTerms(next.limits);
|
|
10365
|
+
if (value) next.limit = value;
|
|
10366
|
+
else delete next.limit;
|
|
10367
|
+
}
|
|
10368
|
+
if (!hasOwn(decision, "deductible") && termDecisionsTouch(coverage, termDecisions, isDeductibleTerm)) {
|
|
10369
|
+
const value = deductibleFromTerms(next.limits);
|
|
10370
|
+
if (value) next.deductible = value;
|
|
10371
|
+
else delete next.deductible;
|
|
10372
|
+
}
|
|
10373
|
+
if (!hasOwn(decision, "premium") && termDecisionsTouch(coverage, termDecisions, isPremiumTerm)) {
|
|
10374
|
+
const value = premiumFromTerms(next.limits);
|
|
10375
|
+
if (value) next.premium = value;
|
|
10376
|
+
else delete next.premium;
|
|
10377
|
+
}
|
|
10378
|
+
if (!hasOwn(decision, "retroactiveDate") && termDecisionsTouch(coverage, termDecisions, isRetroactiveDateTerm)) {
|
|
10379
|
+
const value = retroactiveDateFromTerms(next.limits);
|
|
10380
|
+
if (value) next.retroactiveDate = value;
|
|
10381
|
+
else delete next.retroactiveDate;
|
|
10382
|
+
}
|
|
10383
|
+
}
|
|
10384
|
+
next.sourceNodeIds = uniqueStrings([
|
|
10385
|
+
...next.sourceNodeIds,
|
|
10386
|
+
...next.limits.flatMap((term) => term.sourceNodeIds)
|
|
10387
|
+
]);
|
|
10388
|
+
next.sourceSpanIds = uniqueStrings([
|
|
10389
|
+
...next.sourceSpanIds,
|
|
10390
|
+
...next.limits.flatMap((term) => term.sourceSpanIds)
|
|
10391
|
+
]);
|
|
10392
|
+
return next.name ? next : coverage;
|
|
10393
|
+
}
|
|
10394
|
+
function sourceIdsFromOperationalProfile(profile) {
|
|
10395
|
+
const backedValues = [
|
|
10396
|
+
profile.policyNumber,
|
|
10397
|
+
profile.namedInsured,
|
|
10398
|
+
profile.insurer,
|
|
10399
|
+
profile.broker,
|
|
10400
|
+
profile.effectiveDate,
|
|
10401
|
+
profile.expirationDate,
|
|
10402
|
+
profile.retroactiveDate,
|
|
10403
|
+
profile.premium
|
|
10404
|
+
].filter(Boolean);
|
|
10405
|
+
return {
|
|
10406
|
+
sourceNodeIds: uniqueStrings([
|
|
10407
|
+
...backedValues.flatMap((value) => value?.sourceNodeIds ?? []),
|
|
10408
|
+
...profile.coverages.flatMap((coverage) => coverage.sourceNodeIds),
|
|
10409
|
+
...profile.coverages.flatMap((coverage) => coverage.limits.flatMap((term) => term.sourceNodeIds)),
|
|
10410
|
+
...profile.parties.flatMap((party) => party.sourceNodeIds),
|
|
10411
|
+
...profile.endorsementSupport.flatMap((support) => support.sourceNodeIds)
|
|
10412
|
+
]),
|
|
10413
|
+
sourceSpanIds: uniqueStrings([
|
|
10414
|
+
...backedValues.flatMap((value) => value?.sourceSpanIds ?? []),
|
|
10415
|
+
...profile.coverages.flatMap((coverage) => coverage.sourceSpanIds),
|
|
10416
|
+
...profile.coverages.flatMap((coverage) => coverage.limits.flatMap((term) => term.sourceSpanIds)),
|
|
10417
|
+
...profile.parties.flatMap((party) => party.sourceSpanIds),
|
|
10418
|
+
...profile.endorsementSupport.flatMap((support) => support.sourceSpanIds)
|
|
10419
|
+
])
|
|
10420
|
+
};
|
|
10421
|
+
}
|
|
10422
|
+
function applyOperationalProfileCleanup(profile, cleanup, validNodeIds, validSpanIds) {
|
|
10423
|
+
const coverageDecisionByIndex = /* @__PURE__ */ new Map();
|
|
10424
|
+
for (const decision of cleanup.coverageDecisions) {
|
|
10425
|
+
if (decision.coverageIndex < profile.coverages.length) coverageDecisionByIndex.set(decision.coverageIndex, decision);
|
|
10426
|
+
}
|
|
10427
|
+
const coverages = profile.coverages.map(
|
|
10428
|
+
(coverage, index) => applyCoverageCleanupDecision(coverage, coverageDecisionByIndex.get(index), validNodeIds, validSpanIds)
|
|
10429
|
+
).filter((coverage) => Boolean(coverage));
|
|
10430
|
+
const cleanupWarnings = cleanup.warnings.map((warning) => cleanProfileValue(warning)).filter((warning) => Boolean(warning));
|
|
10431
|
+
const nextProfile = {
|
|
10432
|
+
...profile,
|
|
10433
|
+
coverages,
|
|
10434
|
+
coverageTypes: uniqueStrings(coverages.map((coverage) => coverage.name)),
|
|
10435
|
+
warnings: uniqueStrings([
|
|
10436
|
+
...profile.warnings,
|
|
10437
|
+
...cleanupWarnings.map((warning) => `Operational profile cleanup warning: ${warning}`)
|
|
10438
|
+
])
|
|
10439
|
+
};
|
|
10440
|
+
return PolicyOperationalProfileSchema.parse({
|
|
10441
|
+
...nextProfile,
|
|
10442
|
+
...sourceIdsFromOperationalProfile(nextProfile)
|
|
10443
|
+
});
|
|
10444
|
+
}
|
|
10445
|
+
|
|
10446
|
+
// src/extraction/source-tree-extractor.ts
|
|
10115
10447
|
var ORGANIZABLE_KINDS = [
|
|
10116
10448
|
"page_group",
|
|
10117
10449
|
"form",
|
|
@@ -10124,10 +10456,10 @@ var ORGANIZATION_TOP_LEVEL_BATCH_SIZE = 80;
|
|
|
10124
10456
|
var ORGANIZER_MAX_SOURCE_SPANS = 400;
|
|
10125
10457
|
var ORGANIZER_MAX_TOP_LEVEL_NODES = 18;
|
|
10126
10458
|
var OUTLINE_CLEANUP_MAX_TOP_LEVEL_NODES = 80;
|
|
10127
|
-
var SourceTreeOrganizationSchema =
|
|
10128
|
-
labels:
|
|
10129
|
-
nodeId:
|
|
10130
|
-
kind:
|
|
10459
|
+
var SourceTreeOrganizationSchema = import_zod42.z.object({
|
|
10460
|
+
labels: import_zod42.z.array(import_zod42.z.object({
|
|
10461
|
+
nodeId: import_zod42.z.string(),
|
|
10462
|
+
kind: import_zod42.z.enum([
|
|
10131
10463
|
"document",
|
|
10132
10464
|
"page_group",
|
|
10133
10465
|
"page",
|
|
@@ -10141,26 +10473,26 @@ var SourceTreeOrganizationSchema = import_zod41.z.object({
|
|
|
10141
10473
|
"table_cell",
|
|
10142
10474
|
"text"
|
|
10143
10475
|
]).optional(),
|
|
10144
|
-
title:
|
|
10145
|
-
description:
|
|
10476
|
+
title: import_zod42.z.string().optional(),
|
|
10477
|
+
description: import_zod42.z.string().optional()
|
|
10146
10478
|
})),
|
|
10147
|
-
groups:
|
|
10148
|
-
kind:
|
|
10149
|
-
title:
|
|
10150
|
-
description:
|
|
10151
|
-
childNodeIds:
|
|
10479
|
+
groups: import_zod42.z.array(import_zod42.z.object({
|
|
10480
|
+
kind: import_zod42.z.enum(ORGANIZABLE_KINDS),
|
|
10481
|
+
title: import_zod42.z.string(),
|
|
10482
|
+
description: import_zod42.z.string().optional(),
|
|
10483
|
+
childNodeIds: import_zod42.z.array(import_zod42.z.string()).min(1)
|
|
10152
10484
|
}))
|
|
10153
10485
|
});
|
|
10154
|
-
var SourceBackedValueForPromptSchema =
|
|
10155
|
-
value:
|
|
10156
|
-
normalizedValue:
|
|
10157
|
-
confidence:
|
|
10158
|
-
sourceNodeIds:
|
|
10159
|
-
sourceSpanIds:
|
|
10486
|
+
var SourceBackedValueForPromptSchema = import_zod42.z.object({
|
|
10487
|
+
value: import_zod42.z.string(),
|
|
10488
|
+
normalizedValue: import_zod42.z.string().optional(),
|
|
10489
|
+
confidence: import_zod42.z.enum(["low", "medium", "high"]).optional(),
|
|
10490
|
+
sourceNodeIds: import_zod42.z.array(import_zod42.z.string()),
|
|
10491
|
+
sourceSpanIds: import_zod42.z.array(import_zod42.z.string())
|
|
10160
10492
|
});
|
|
10161
|
-
var OperationalProfilePromptSchema =
|
|
10162
|
-
documentType:
|
|
10163
|
-
policyTypes:
|
|
10493
|
+
var OperationalProfilePromptSchema = import_zod42.z.object({
|
|
10494
|
+
documentType: import_zod42.z.enum(["policy", "quote"]).optional(),
|
|
10495
|
+
policyTypes: import_zod42.z.array(import_zod42.z.string()).optional(),
|
|
10164
10496
|
policyNumber: SourceBackedValueForPromptSchema.optional(),
|
|
10165
10497
|
namedInsured: SourceBackedValueForPromptSchema.optional(),
|
|
10166
10498
|
insurer: SourceBackedValueForPromptSchema.optional(),
|
|
@@ -10169,43 +10501,32 @@ var OperationalProfilePromptSchema = import_zod41.z.object({
|
|
|
10169
10501
|
expirationDate: SourceBackedValueForPromptSchema.optional(),
|
|
10170
10502
|
retroactiveDate: SourceBackedValueForPromptSchema.optional(),
|
|
10171
10503
|
premium: SourceBackedValueForPromptSchema.optional(),
|
|
10172
|
-
coverageTypes:
|
|
10173
|
-
coverages:
|
|
10174
|
-
name:
|
|
10175
|
-
coverageCode:
|
|
10176
|
-
limit:
|
|
10177
|
-
deductible:
|
|
10178
|
-
premium:
|
|
10179
|
-
retroactiveDate:
|
|
10180
|
-
formNumber:
|
|
10181
|
-
sectionRef:
|
|
10182
|
-
coverageOrigin:
|
|
10183
|
-
endorsementNumber:
|
|
10184
|
-
limits:
|
|
10185
|
-
kind:
|
|
10186
|
-
|
|
10187
|
-
|
|
10188
|
-
|
|
10189
|
-
|
|
10190
|
-
|
|
10191
|
-
|
|
10192
|
-
"deductible",
|
|
10193
|
-
"retroactive_date",
|
|
10194
|
-
"premium",
|
|
10195
|
-
"other"
|
|
10196
|
-
]).optional(),
|
|
10197
|
-
label: import_zod41.z.string(),
|
|
10198
|
-
value: import_zod41.z.string(),
|
|
10199
|
-
amount: import_zod41.z.number().optional(),
|
|
10200
|
-
appliesTo: import_zod41.z.string().optional(),
|
|
10201
|
-
sourceNodeIds: import_zod41.z.array(import_zod41.z.string()),
|
|
10202
|
-
sourceSpanIds: import_zod41.z.array(import_zod41.z.string())
|
|
10504
|
+
coverageTypes: import_zod42.z.array(import_zod42.z.string()).optional(),
|
|
10505
|
+
coverages: import_zod42.z.array(import_zod42.z.object({
|
|
10506
|
+
name: import_zod42.z.string(),
|
|
10507
|
+
coverageCode: import_zod42.z.string().optional(),
|
|
10508
|
+
limit: import_zod42.z.string().optional(),
|
|
10509
|
+
deductible: import_zod42.z.string().optional(),
|
|
10510
|
+
premium: import_zod42.z.string().optional(),
|
|
10511
|
+
retroactiveDate: import_zod42.z.string().optional(),
|
|
10512
|
+
formNumber: import_zod42.z.string().optional(),
|
|
10513
|
+
sectionRef: import_zod42.z.string().optional(),
|
|
10514
|
+
coverageOrigin: import_zod42.z.enum(["core", "endorsement"]).optional(),
|
|
10515
|
+
endorsementNumber: import_zod42.z.string().optional(),
|
|
10516
|
+
limits: import_zod42.z.array(import_zod42.z.object({
|
|
10517
|
+
kind: OperationalCoverageTermKindSchema.optional(),
|
|
10518
|
+
label: import_zod42.z.string(),
|
|
10519
|
+
value: import_zod42.z.string(),
|
|
10520
|
+
amount: import_zod42.z.number().optional(),
|
|
10521
|
+
appliesTo: import_zod42.z.string().optional(),
|
|
10522
|
+
sourceNodeIds: import_zod42.z.array(import_zod42.z.string()),
|
|
10523
|
+
sourceSpanIds: import_zod42.z.array(import_zod42.z.string())
|
|
10203
10524
|
})).optional(),
|
|
10204
|
-
sourceNodeIds:
|
|
10205
|
-
sourceSpanIds:
|
|
10525
|
+
sourceNodeIds: import_zod42.z.array(import_zod42.z.string()),
|
|
10526
|
+
sourceSpanIds: import_zod42.z.array(import_zod42.z.string())
|
|
10206
10527
|
})).optional(),
|
|
10207
|
-
sourceNodeIds:
|
|
10208
|
-
sourceSpanIds:
|
|
10528
|
+
sourceNodeIds: import_zod42.z.array(import_zod42.z.string()).optional(),
|
|
10529
|
+
sourceSpanIds: import_zod42.z.array(import_zod42.z.string()).optional()
|
|
10209
10530
|
});
|
|
10210
10531
|
function formatFormHintsForPrompt(forms) {
|
|
10211
10532
|
const usable = forms.filter((form) => typeof form.pageStart === "number" && typeof form.pageEnd === "number").slice(0, 120).map((form) => ({
|
|
@@ -11197,7 +11518,7 @@ function applyEndorsementGrouping(sourceTree) {
|
|
|
11197
11518
|
}
|
|
11198
11519
|
return normalizeSemanticHierarchy(nextTree);
|
|
11199
11520
|
}
|
|
11200
|
-
function
|
|
11521
|
+
function compactNode2(node, maxText = 700) {
|
|
11201
11522
|
return {
|
|
11202
11523
|
id: node.id,
|
|
11203
11524
|
kind: node.kind,
|
|
@@ -11287,7 +11608,7 @@ function mergeOrganizationResults(results) {
|
|
|
11287
11608
|
};
|
|
11288
11609
|
}
|
|
11289
11610
|
function buildOrganizationPrompt(batch, formHints) {
|
|
11290
|
-
const nodes = batch.nodes.map((node) =>
|
|
11611
|
+
const nodes = batch.nodes.map((node) => compactNode2(node, node.kind === "page" ? 900 : 320));
|
|
11291
11612
|
return `You organize an insurance document source tree.
|
|
11292
11613
|
|
|
11293
11614
|
Scope:
|
|
@@ -11329,7 +11650,7 @@ function shouldRunOutlineCleanup(sourceTree) {
|
|
|
11329
11650
|
}
|
|
11330
11651
|
function buildOutlineCleanupPrompt(sourceTree, formHints) {
|
|
11331
11652
|
const topLevel = rootChildren(sourceTree).slice(0, OUTLINE_CLEANUP_MAX_TOP_LEVEL_NODES);
|
|
11332
|
-
const nodes = topLevel.map((node) =>
|
|
11653
|
+
const nodes = topLevel.map((node) => compactNode2(node, 900));
|
|
11333
11654
|
return `You clean a top-level source outline for an insurance policy.
|
|
11334
11655
|
|
|
11335
11656
|
Expected product-facing order:
|
|
@@ -11358,7 +11679,7 @@ ${JSON.stringify(nodes, null, 2)}
|
|
|
11358
11679
|
Return JSON with labels and groups only.`;
|
|
11359
11680
|
}
|
|
11360
11681
|
function buildOperationalProfilePrompt(sourceTree, fallback) {
|
|
11361
|
-
const nodes = sourceTree.filter((node) => node.kind !== "document").slice(0, 240).map(
|
|
11682
|
+
const nodes = sourceTree.filter((node) => node.kind !== "document").slice(0, 240).map(compactNode2);
|
|
11362
11683
|
return `Extract a source-backed operational profile for an insurance policy or quote.
|
|
11363
11684
|
|
|
11364
11685
|
Return only high-value operational facts needed for policy lists, Q&A, compliance, and certificate generation:
|
|
@@ -11485,6 +11806,13 @@ function valueOf(profile, key) {
|
|
|
11485
11806
|
}
|
|
11486
11807
|
return String(value.value);
|
|
11487
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
|
+
}
|
|
11488
11816
|
function materializeDocument(params) {
|
|
11489
11817
|
const profile = params.operationalProfile;
|
|
11490
11818
|
const policyNumber = valueOf(profile, "policyNumber") ?? "Unknown";
|
|
@@ -11493,6 +11821,9 @@ function materializeDocument(params) {
|
|
|
11493
11821
|
const effectiveDate = valueOf(profile, "effectiveDate") ?? "Unknown";
|
|
11494
11822
|
const expirationDate = valueOf(profile, "expirationDate") ?? "Unknown";
|
|
11495
11823
|
const premium = valueOf(profile, "premium");
|
|
11824
|
+
const insurerProvenance = provenanceOf(profile.insurer);
|
|
11825
|
+
const broker = valueOf(profile, "broker");
|
|
11826
|
+
const brokerProvenance = provenanceOf(profile.broker);
|
|
11496
11827
|
const coverages = profile.coverages.map((coverage) => ({
|
|
11497
11828
|
name: coverage.name,
|
|
11498
11829
|
coverageCode: coverage.coverageCode,
|
|
@@ -11544,6 +11875,11 @@ function materializeDocument(params) {
|
|
|
11544
11875
|
security: carrier,
|
|
11545
11876
|
insuredName,
|
|
11546
11877
|
premium,
|
|
11878
|
+
...insurerProvenance ? { insurer: { legalName: carrier, ...insurerProvenance } } : {},
|
|
11879
|
+
...broker && brokerProvenance ? {
|
|
11880
|
+
brokerAgency: broker,
|
|
11881
|
+
producer: { agencyName: broker, ...brokerProvenance }
|
|
11882
|
+
} : {},
|
|
11547
11883
|
policyTypes: profile.policyTypes,
|
|
11548
11884
|
formInventory: params.formInventory.filter((form) => typeof form.formNumber === "string" && form.formNumber.trim().length > 0).map((form) => ({
|
|
11549
11885
|
formNumber: form.formNumber,
|
|
@@ -11722,6 +12058,45 @@ async function runSourceTreeExtraction(params) {
|
|
|
11722
12058
|
} catch (error) {
|
|
11723
12059
|
warnings.push(`Operational profile model pass failed; deterministic profile used (${error instanceof Error ? error.message : String(error)})`);
|
|
11724
12060
|
}
|
|
12061
|
+
if (operationalProfile.coverages.length > 0) {
|
|
12062
|
+
try {
|
|
12063
|
+
const validNodeIds = new Set(sourceTree.map((node) => node.id));
|
|
12064
|
+
const validSpanIds = new Set(sourceSpans.map((span) => span.id));
|
|
12065
|
+
const budget = params.resolveBudget("extraction_operational_profile", 4096);
|
|
12066
|
+
const startedAt = Date.now();
|
|
12067
|
+
const response = await safeGenerateObject(
|
|
12068
|
+
params.generateObject,
|
|
12069
|
+
{
|
|
12070
|
+
prompt: buildOperationalProfileCleanupPrompt(sourceTree, operationalProfile),
|
|
12071
|
+
schema: OperationalProfileCleanupSchema,
|
|
12072
|
+
maxTokens: budget.maxTokens,
|
|
12073
|
+
taskKind: "extraction_operational_profile",
|
|
12074
|
+
budgetDiagnostics: budget,
|
|
12075
|
+
providerOptions: params.providerOptions
|
|
12076
|
+
},
|
|
12077
|
+
{
|
|
12078
|
+
fallback: { coverageDecisions: [], warnings: [] },
|
|
12079
|
+
log: params.log
|
|
12080
|
+
}
|
|
12081
|
+
);
|
|
12082
|
+
localTrack(response.usage, {
|
|
12083
|
+
taskKind: "extraction_operational_profile",
|
|
12084
|
+
label: "operational_profile_cleanup",
|
|
12085
|
+
maxTokens: budget.maxTokens,
|
|
12086
|
+
durationMs: Date.now() - startedAt
|
|
12087
|
+
});
|
|
12088
|
+
operationalProfile = applyOperationalProfileCleanup(
|
|
12089
|
+
operationalProfile,
|
|
12090
|
+
response.object,
|
|
12091
|
+
validNodeIds,
|
|
12092
|
+
validSpanIds
|
|
12093
|
+
);
|
|
12094
|
+
} catch (error) {
|
|
12095
|
+
warnings.push(`Operational profile cleanup pass failed; uncleaned profile used (${error instanceof Error ? error.message : String(error)})`);
|
|
12096
|
+
}
|
|
12097
|
+
} else {
|
|
12098
|
+
await params.log?.("Operational profile has no coverage rows; skipped model cleanup");
|
|
12099
|
+
}
|
|
11725
12100
|
const document = materializeDocument({
|
|
11726
12101
|
id: params.id,
|
|
11727
12102
|
sourceTree,
|
|
@@ -13048,8 +13423,8 @@ Respond with JSON only:
|
|
|
13048
13423
|
}`;
|
|
13049
13424
|
|
|
13050
13425
|
// src/schemas/application.ts
|
|
13051
|
-
var
|
|
13052
|
-
var FieldTypeSchema =
|
|
13426
|
+
var import_zod43 = require("zod");
|
|
13427
|
+
var FieldTypeSchema = import_zod43.z.enum([
|
|
13053
13428
|
"text",
|
|
13054
13429
|
"numeric",
|
|
13055
13430
|
"currency",
|
|
@@ -13058,223 +13433,223 @@ var FieldTypeSchema = import_zod42.z.enum([
|
|
|
13058
13433
|
"table",
|
|
13059
13434
|
"declaration"
|
|
13060
13435
|
]);
|
|
13061
|
-
var ApplicationFieldSchema =
|
|
13062
|
-
id:
|
|
13063
|
-
label:
|
|
13064
|
-
section:
|
|
13436
|
+
var ApplicationFieldSchema = import_zod43.z.object({
|
|
13437
|
+
id: import_zod43.z.string(),
|
|
13438
|
+
label: import_zod43.z.string(),
|
|
13439
|
+
section: import_zod43.z.string(),
|
|
13065
13440
|
fieldType: FieldTypeSchema,
|
|
13066
|
-
required:
|
|
13067
|
-
options:
|
|
13068
|
-
columns:
|
|
13069
|
-
requiresExplanationIfYes:
|
|
13070
|
-
condition:
|
|
13071
|
-
dependsOn:
|
|
13072
|
-
whenValue:
|
|
13441
|
+
required: import_zod43.z.boolean(),
|
|
13442
|
+
options: import_zod43.z.array(import_zod43.z.string()).optional(),
|
|
13443
|
+
columns: import_zod43.z.array(import_zod43.z.string()).optional(),
|
|
13444
|
+
requiresExplanationIfYes: import_zod43.z.boolean().optional(),
|
|
13445
|
+
condition: import_zod43.z.object({
|
|
13446
|
+
dependsOn: import_zod43.z.string(),
|
|
13447
|
+
whenValue: import_zod43.z.string()
|
|
13073
13448
|
}).optional(),
|
|
13074
|
-
value:
|
|
13075
|
-
source:
|
|
13076
|
-
confidence:
|
|
13077
|
-
sourceSpanIds:
|
|
13078
|
-
userSourceSpanIds:
|
|
13079
|
-
pageNumber:
|
|
13080
|
-
fieldAnchorId:
|
|
13081
|
-
acroFormName:
|
|
13082
|
-
validationStatus:
|
|
13449
|
+
value: import_zod43.z.string().optional(),
|
|
13450
|
+
source: import_zod43.z.string().optional().describe("Where the value came from: auto-fill, user, lookup"),
|
|
13451
|
+
confidence: import_zod43.z.enum(["confirmed", "high", "medium", "low"]).optional(),
|
|
13452
|
+
sourceSpanIds: import_zod43.z.array(import_zod43.z.string()).optional().describe("Stable source spans that support the field value or field anchor"),
|
|
13453
|
+
userSourceSpanIds: import_zod43.z.array(import_zod43.z.string()).optional().describe("Message or attachment spans that support user-provided values"),
|
|
13454
|
+
pageNumber: import_zod43.z.number().int().positive().optional().describe("Application page where the field label or anchor appears"),
|
|
13455
|
+
fieldAnchorId: import_zod43.z.string().optional().describe("Stable field anchor ID derived from page, section, label, and form metadata"),
|
|
13456
|
+
acroFormName: import_zod43.z.string().optional().describe("Native PDF AcroForm field name when available"),
|
|
13457
|
+
validationStatus: import_zod43.z.enum(["valid", "needs_review", "unsupported", "missing"]).optional()
|
|
13083
13458
|
});
|
|
13084
|
-
var ApplicationQuestionConditionSchema =
|
|
13085
|
-
dependsOn:
|
|
13086
|
-
operator:
|
|
13087
|
-
value:
|
|
13088
|
-
whenValue:
|
|
13089
|
-
values:
|
|
13459
|
+
var ApplicationQuestionConditionSchema = import_zod43.z.object({
|
|
13460
|
+
dependsOn: import_zod43.z.string(),
|
|
13461
|
+
operator: import_zod43.z.enum(["equals", "not_equals", "in", "not_in", "exists"]).optional(),
|
|
13462
|
+
value: import_zod43.z.string().optional(),
|
|
13463
|
+
whenValue: import_zod43.z.string().optional(),
|
|
13464
|
+
values: import_zod43.z.array(import_zod43.z.string()).optional()
|
|
13090
13465
|
});
|
|
13091
|
-
var ApplicationRepeatSchema =
|
|
13092
|
-
min:
|
|
13093
|
-
max:
|
|
13094
|
-
label:
|
|
13466
|
+
var ApplicationRepeatSchema = import_zod43.z.object({
|
|
13467
|
+
min: import_zod43.z.number().int().nonnegative().optional(),
|
|
13468
|
+
max: import_zod43.z.number().int().positive().optional(),
|
|
13469
|
+
label: import_zod43.z.string().optional()
|
|
13095
13470
|
});
|
|
13096
|
-
var ApplicationQuestionNodeSchema =
|
|
13097
|
-
() =>
|
|
13098
|
-
id:
|
|
13099
|
-
nodeType:
|
|
13100
|
-
fieldId:
|
|
13101
|
-
fieldPath:
|
|
13102
|
-
parentId:
|
|
13103
|
-
order:
|
|
13104
|
-
label:
|
|
13105
|
-
section:
|
|
13471
|
+
var ApplicationQuestionNodeSchema = import_zod43.z.lazy(
|
|
13472
|
+
() => import_zod43.z.object({
|
|
13473
|
+
id: import_zod43.z.string(),
|
|
13474
|
+
nodeType: import_zod43.z.enum(["group", "question", "repeat_group", "table"]),
|
|
13475
|
+
fieldId: import_zod43.z.string().optional(),
|
|
13476
|
+
fieldPath: import_zod43.z.string().optional(),
|
|
13477
|
+
parentId: import_zod43.z.string().optional(),
|
|
13478
|
+
order: import_zod43.z.number().int().nonnegative().optional(),
|
|
13479
|
+
label: import_zod43.z.string(),
|
|
13480
|
+
section: import_zod43.z.string().optional(),
|
|
13106
13481
|
fieldType: FieldTypeSchema.optional(),
|
|
13107
|
-
required:
|
|
13108
|
-
prompt:
|
|
13109
|
-
options:
|
|
13110
|
-
columns:
|
|
13482
|
+
required: import_zod43.z.boolean().optional(),
|
|
13483
|
+
prompt: import_zod43.z.string().optional(),
|
|
13484
|
+
options: import_zod43.z.array(import_zod43.z.string()).optional(),
|
|
13485
|
+
columns: import_zod43.z.array(import_zod43.z.string()).optional(),
|
|
13111
13486
|
condition: ApplicationQuestionConditionSchema.optional(),
|
|
13112
13487
|
repeat: ApplicationRepeatSchema.optional(),
|
|
13113
|
-
children:
|
|
13488
|
+
children: import_zod43.z.array(ApplicationQuestionNodeSchema).optional()
|
|
13114
13489
|
})
|
|
13115
13490
|
);
|
|
13116
|
-
var ApplicationQuestionGraphSchema =
|
|
13117
|
-
id:
|
|
13118
|
-
version:
|
|
13119
|
-
title:
|
|
13120
|
-
applicationType:
|
|
13121
|
-
source:
|
|
13122
|
-
rootNodeIds:
|
|
13123
|
-
nodes:
|
|
13491
|
+
var ApplicationQuestionGraphSchema = import_zod43.z.object({
|
|
13492
|
+
id: import_zod43.z.string(),
|
|
13493
|
+
version: import_zod43.z.string(),
|
|
13494
|
+
title: import_zod43.z.string().optional(),
|
|
13495
|
+
applicationType: import_zod43.z.string().nullable().optional(),
|
|
13496
|
+
source: import_zod43.z.enum(["pdf", "manual", "imported", "generated"]).default("generated"),
|
|
13497
|
+
rootNodeIds: import_zod43.z.array(import_zod43.z.string()).optional(),
|
|
13498
|
+
nodes: import_zod43.z.array(ApplicationQuestionNodeSchema)
|
|
13124
13499
|
});
|
|
13125
|
-
var ApplicationTemplateSchema =
|
|
13126
|
-
id:
|
|
13127
|
-
version:
|
|
13128
|
-
title:
|
|
13129
|
-
applicationType:
|
|
13500
|
+
var ApplicationTemplateSchema = import_zod43.z.object({
|
|
13501
|
+
id: import_zod43.z.string(),
|
|
13502
|
+
version: import_zod43.z.string(),
|
|
13503
|
+
title: import_zod43.z.string(),
|
|
13504
|
+
applicationType: import_zod43.z.string().nullable().optional(),
|
|
13130
13505
|
questionGraph: ApplicationQuestionGraphSchema,
|
|
13131
|
-
fields:
|
|
13506
|
+
fields: import_zod43.z.array(ApplicationFieldSchema).optional()
|
|
13132
13507
|
});
|
|
13133
|
-
var ApplicationClassifyResultSchema =
|
|
13134
|
-
isApplication:
|
|
13135
|
-
confidence:
|
|
13136
|
-
applicationType:
|
|
13508
|
+
var ApplicationClassifyResultSchema = import_zod43.z.object({
|
|
13509
|
+
isApplication: import_zod43.z.boolean(),
|
|
13510
|
+
confidence: import_zod43.z.number().min(0).max(1),
|
|
13511
|
+
applicationType: import_zod43.z.string().nullable()
|
|
13137
13512
|
});
|
|
13138
|
-
var FieldExtractionResultSchema =
|
|
13139
|
-
fields:
|
|
13513
|
+
var FieldExtractionResultSchema = import_zod43.z.object({
|
|
13514
|
+
fields: import_zod43.z.array(ApplicationFieldSchema)
|
|
13140
13515
|
});
|
|
13141
|
-
var AutoFillMatchSchema =
|
|
13142
|
-
fieldId:
|
|
13143
|
-
value:
|
|
13144
|
-
confidence:
|
|
13145
|
-
contextKey:
|
|
13516
|
+
var AutoFillMatchSchema = import_zod43.z.object({
|
|
13517
|
+
fieldId: import_zod43.z.string(),
|
|
13518
|
+
value: import_zod43.z.string(),
|
|
13519
|
+
confidence: import_zod43.z.enum(["confirmed"]),
|
|
13520
|
+
contextKey: import_zod43.z.string()
|
|
13146
13521
|
});
|
|
13147
|
-
var AutoFillResultSchema =
|
|
13148
|
-
matches:
|
|
13522
|
+
var AutoFillResultSchema = import_zod43.z.object({
|
|
13523
|
+
matches: import_zod43.z.array(AutoFillMatchSchema)
|
|
13149
13524
|
});
|
|
13150
|
-
var QuestionBatchResultSchema =
|
|
13151
|
-
batches:
|
|
13525
|
+
var QuestionBatchResultSchema = import_zod43.z.object({
|
|
13526
|
+
batches: import_zod43.z.array(import_zod43.z.array(import_zod43.z.string()).describe("Array of field IDs in this batch"))
|
|
13152
13527
|
});
|
|
13153
|
-
var LookupRequestSchema =
|
|
13154
|
-
type:
|
|
13155
|
-
description:
|
|
13156
|
-
url:
|
|
13157
|
-
targetFieldIds:
|
|
13528
|
+
var LookupRequestSchema = import_zod43.z.object({
|
|
13529
|
+
type: import_zod43.z.string().describe("Type of lookup: 'records', 'website', 'policy'"),
|
|
13530
|
+
description: import_zod43.z.string(),
|
|
13531
|
+
url: import_zod43.z.string().optional(),
|
|
13532
|
+
targetFieldIds: import_zod43.z.array(import_zod43.z.string())
|
|
13158
13533
|
});
|
|
13159
|
-
var ReplyIntentSchema =
|
|
13160
|
-
primaryIntent:
|
|
13161
|
-
hasAnswers:
|
|
13162
|
-
questionText:
|
|
13163
|
-
questionFieldIds:
|
|
13164
|
-
lookupRequests:
|
|
13534
|
+
var ReplyIntentSchema = import_zod43.z.object({
|
|
13535
|
+
primaryIntent: import_zod43.z.enum(["answers_only", "question", "lookup_request", "mixed"]),
|
|
13536
|
+
hasAnswers: import_zod43.z.boolean(),
|
|
13537
|
+
questionText: import_zod43.z.string().optional(),
|
|
13538
|
+
questionFieldIds: import_zod43.z.array(import_zod43.z.string()).optional(),
|
|
13539
|
+
lookupRequests: import_zod43.z.array(LookupRequestSchema).optional()
|
|
13165
13540
|
});
|
|
13166
|
-
var ParsedAnswerSchema =
|
|
13167
|
-
fieldId:
|
|
13168
|
-
value:
|
|
13169
|
-
explanation:
|
|
13541
|
+
var ParsedAnswerSchema = import_zod43.z.object({
|
|
13542
|
+
fieldId: import_zod43.z.string(),
|
|
13543
|
+
value: import_zod43.z.string(),
|
|
13544
|
+
explanation: import_zod43.z.string().optional()
|
|
13170
13545
|
});
|
|
13171
|
-
var AnswerParsingResultSchema =
|
|
13172
|
-
answers:
|
|
13173
|
-
unanswered:
|
|
13546
|
+
var AnswerParsingResultSchema = import_zod43.z.object({
|
|
13547
|
+
answers: import_zod43.z.array(ParsedAnswerSchema),
|
|
13548
|
+
unanswered: import_zod43.z.array(import_zod43.z.string()).describe("Field IDs that were not answered")
|
|
13174
13549
|
});
|
|
13175
|
-
var LookupFillSchema =
|
|
13176
|
-
fieldId:
|
|
13177
|
-
value:
|
|
13178
|
-
source:
|
|
13179
|
-
sourceSpanIds:
|
|
13550
|
+
var LookupFillSchema = import_zod43.z.object({
|
|
13551
|
+
fieldId: import_zod43.z.string(),
|
|
13552
|
+
value: import_zod43.z.string(),
|
|
13553
|
+
source: import_zod43.z.string().describe("Specific citable reference, e.g. 'GL Policy #POL-12345 (Hartford)'"),
|
|
13554
|
+
sourceSpanIds: import_zod43.z.array(import_zod43.z.string()).optional()
|
|
13180
13555
|
});
|
|
13181
|
-
var LookupFillResultSchema =
|
|
13182
|
-
fills:
|
|
13183
|
-
unfillable:
|
|
13184
|
-
explanation:
|
|
13556
|
+
var LookupFillResultSchema = import_zod43.z.object({
|
|
13557
|
+
fills: import_zod43.z.array(LookupFillSchema),
|
|
13558
|
+
unfillable: import_zod43.z.array(import_zod43.z.string()),
|
|
13559
|
+
explanation: import_zod43.z.string().optional()
|
|
13185
13560
|
});
|
|
13186
|
-
var FlatPdfPlacementSchema =
|
|
13187
|
-
fieldId:
|
|
13188
|
-
page:
|
|
13189
|
-
x:
|
|
13190
|
-
y:
|
|
13191
|
-
text:
|
|
13192
|
-
fontSize:
|
|
13193
|
-
isCheckmark:
|
|
13561
|
+
var FlatPdfPlacementSchema = import_zod43.z.object({
|
|
13562
|
+
fieldId: import_zod43.z.string(),
|
|
13563
|
+
page: import_zod43.z.number(),
|
|
13564
|
+
x: import_zod43.z.number().describe("Percentage from left edge (0-100)"),
|
|
13565
|
+
y: import_zod43.z.number().describe("Percentage from top edge (0-100)"),
|
|
13566
|
+
text: import_zod43.z.string(),
|
|
13567
|
+
fontSize: import_zod43.z.number().optional(),
|
|
13568
|
+
isCheckmark: import_zod43.z.boolean().optional()
|
|
13194
13569
|
});
|
|
13195
|
-
var AcroFormMappingSchema =
|
|
13196
|
-
fieldId:
|
|
13197
|
-
acroFormName:
|
|
13198
|
-
value:
|
|
13570
|
+
var AcroFormMappingSchema = import_zod43.z.object({
|
|
13571
|
+
fieldId: import_zod43.z.string(),
|
|
13572
|
+
acroFormName: import_zod43.z.string(),
|
|
13573
|
+
value: import_zod43.z.string()
|
|
13199
13574
|
});
|
|
13200
|
-
var QualityGateStatusSchema =
|
|
13201
|
-
var QualitySeveritySchema =
|
|
13202
|
-
var ApplicationQualityIssueSchema =
|
|
13203
|
-
code:
|
|
13575
|
+
var QualityGateStatusSchema = import_zod43.z.enum(["passed", "warning", "failed"]);
|
|
13576
|
+
var QualitySeveritySchema = import_zod43.z.enum(["info", "warning", "blocking"]);
|
|
13577
|
+
var ApplicationQualityIssueSchema = import_zod43.z.object({
|
|
13578
|
+
code: import_zod43.z.string(),
|
|
13204
13579
|
severity: QualitySeveritySchema,
|
|
13205
|
-
message:
|
|
13206
|
-
fieldId:
|
|
13580
|
+
message: import_zod43.z.string(),
|
|
13581
|
+
fieldId: import_zod43.z.string().optional()
|
|
13207
13582
|
});
|
|
13208
|
-
var ApplicationQualityRoundSchema =
|
|
13209
|
-
round:
|
|
13210
|
-
kind:
|
|
13583
|
+
var ApplicationQualityRoundSchema = import_zod43.z.object({
|
|
13584
|
+
round: import_zod43.z.number(),
|
|
13585
|
+
kind: import_zod43.z.string(),
|
|
13211
13586
|
status: QualityGateStatusSchema,
|
|
13212
|
-
summary:
|
|
13587
|
+
summary: import_zod43.z.string().optional()
|
|
13213
13588
|
});
|
|
13214
|
-
var ApplicationQualityArtifactSchema =
|
|
13215
|
-
kind:
|
|
13216
|
-
label:
|
|
13217
|
-
itemCount:
|
|
13589
|
+
var ApplicationQualityArtifactSchema = import_zod43.z.object({
|
|
13590
|
+
kind: import_zod43.z.string(),
|
|
13591
|
+
label: import_zod43.z.string().optional(),
|
|
13592
|
+
itemCount: import_zod43.z.number().optional()
|
|
13218
13593
|
});
|
|
13219
|
-
var ApplicationEmailReviewSchema =
|
|
13220
|
-
issues:
|
|
13594
|
+
var ApplicationEmailReviewSchema = import_zod43.z.object({
|
|
13595
|
+
issues: import_zod43.z.array(ApplicationQualityIssueSchema),
|
|
13221
13596
|
qualityGateStatus: QualityGateStatusSchema
|
|
13222
13597
|
});
|
|
13223
|
-
var ApplicationQualityReportSchema =
|
|
13224
|
-
issues:
|
|
13225
|
-
rounds:
|
|
13226
|
-
artifacts:
|
|
13598
|
+
var ApplicationQualityReportSchema = import_zod43.z.object({
|
|
13599
|
+
issues: import_zod43.z.array(ApplicationQualityIssueSchema),
|
|
13600
|
+
rounds: import_zod43.z.array(ApplicationQualityRoundSchema).optional(),
|
|
13601
|
+
artifacts: import_zod43.z.array(ApplicationQualityArtifactSchema).optional(),
|
|
13227
13602
|
emailReview: ApplicationEmailReviewSchema.optional(),
|
|
13228
13603
|
qualityGateStatus: QualityGateStatusSchema
|
|
13229
13604
|
});
|
|
13230
|
-
var ApplicationContextProposalSchema =
|
|
13231
|
-
id:
|
|
13232
|
-
fieldId:
|
|
13233
|
-
key:
|
|
13234
|
-
value:
|
|
13235
|
-
category:
|
|
13236
|
-
source:
|
|
13237
|
-
confidence:
|
|
13238
|
-
sourceSpanIds:
|
|
13239
|
-
userSourceSpanIds:
|
|
13605
|
+
var ApplicationContextProposalSchema = import_zod43.z.object({
|
|
13606
|
+
id: import_zod43.z.string(),
|
|
13607
|
+
fieldId: import_zod43.z.string().optional(),
|
|
13608
|
+
key: import_zod43.z.string(),
|
|
13609
|
+
value: import_zod43.z.string(),
|
|
13610
|
+
category: import_zod43.z.string(),
|
|
13611
|
+
source: import_zod43.z.enum(["application", "user", "lookup", "policy", "email", "chat", "imessage", "mcp"]),
|
|
13612
|
+
confidence: import_zod43.z.enum(["confirmed", "high", "medium", "low"]),
|
|
13613
|
+
sourceSpanIds: import_zod43.z.array(import_zod43.z.string()).optional(),
|
|
13614
|
+
userSourceSpanIds: import_zod43.z.array(import_zod43.z.string()).optional()
|
|
13240
13615
|
});
|
|
13241
|
-
var ApplicationPacketAnswerSchema =
|
|
13242
|
-
fieldId:
|
|
13243
|
-
label:
|
|
13244
|
-
section:
|
|
13245
|
-
value:
|
|
13246
|
-
source:
|
|
13247
|
-
confidence:
|
|
13248
|
-
sourceSpanIds:
|
|
13249
|
-
userSourceSpanIds:
|
|
13616
|
+
var ApplicationPacketAnswerSchema = import_zod43.z.object({
|
|
13617
|
+
fieldId: import_zod43.z.string(),
|
|
13618
|
+
label: import_zod43.z.string(),
|
|
13619
|
+
section: import_zod43.z.string(),
|
|
13620
|
+
value: import_zod43.z.string(),
|
|
13621
|
+
source: import_zod43.z.string(),
|
|
13622
|
+
confidence: import_zod43.z.enum(["confirmed", "high", "medium", "low"]).optional(),
|
|
13623
|
+
sourceSpanIds: import_zod43.z.array(import_zod43.z.string()).optional(),
|
|
13624
|
+
userSourceSpanIds: import_zod43.z.array(import_zod43.z.string()).optional()
|
|
13250
13625
|
});
|
|
13251
|
-
var ApplicationPacketSchema =
|
|
13252
|
-
id:
|
|
13253
|
-
applicationId:
|
|
13254
|
-
title:
|
|
13255
|
-
status:
|
|
13256
|
-
answers:
|
|
13257
|
-
missingFieldIds:
|
|
13626
|
+
var ApplicationPacketSchema = import_zod43.z.object({
|
|
13627
|
+
id: import_zod43.z.string(),
|
|
13628
|
+
applicationId: import_zod43.z.string(),
|
|
13629
|
+
title: import_zod43.z.string(),
|
|
13630
|
+
status: import_zod43.z.enum(["draft", "broker_ready", "submitted"]),
|
|
13631
|
+
answers: import_zod43.z.array(ApplicationPacketAnswerSchema),
|
|
13632
|
+
missingFieldIds: import_zod43.z.array(import_zod43.z.string()),
|
|
13258
13633
|
qualityReport: ApplicationQualityReportSchema,
|
|
13259
|
-
submissionNotes:
|
|
13260
|
-
createdAt:
|
|
13634
|
+
submissionNotes: import_zod43.z.string().optional(),
|
|
13635
|
+
createdAt: import_zod43.z.number()
|
|
13261
13636
|
});
|
|
13262
|
-
var ApplicationStateSchema =
|
|
13263
|
-
id:
|
|
13264
|
-
pdfBase64:
|
|
13265
|
-
templateId:
|
|
13266
|
-
templateVersion:
|
|
13637
|
+
var ApplicationStateSchema = import_zod43.z.object({
|
|
13638
|
+
id: import_zod43.z.string(),
|
|
13639
|
+
pdfBase64: import_zod43.z.string().optional().describe("Original PDF, omitted after extraction"),
|
|
13640
|
+
templateId: import_zod43.z.string().optional(),
|
|
13641
|
+
templateVersion: import_zod43.z.string().optional(),
|
|
13267
13642
|
templateSnapshot: ApplicationTemplateSchema.optional(),
|
|
13268
|
-
title:
|
|
13269
|
-
applicationType:
|
|
13643
|
+
title: import_zod43.z.string().optional(),
|
|
13644
|
+
applicationType: import_zod43.z.string().nullable().optional(),
|
|
13270
13645
|
questionGraph: ApplicationQuestionGraphSchema.optional(),
|
|
13271
|
-
fields:
|
|
13272
|
-
batches:
|
|
13273
|
-
currentBatchIndex:
|
|
13274
|
-
contextProposals:
|
|
13646
|
+
fields: import_zod43.z.array(ApplicationFieldSchema),
|
|
13647
|
+
batches: import_zod43.z.array(import_zod43.z.array(import_zod43.z.string())).optional(),
|
|
13648
|
+
currentBatchIndex: import_zod43.z.number().default(0),
|
|
13649
|
+
contextProposals: import_zod43.z.array(ApplicationContextProposalSchema).optional(),
|
|
13275
13650
|
packet: ApplicationPacketSchema.optional(),
|
|
13276
13651
|
qualityReport: ApplicationQualityReportSchema.optional(),
|
|
13277
|
-
status:
|
|
13652
|
+
status: import_zod43.z.enum([
|
|
13278
13653
|
"classifying",
|
|
13279
13654
|
"extracting",
|
|
13280
13655
|
"auto_filling",
|
|
@@ -13288,8 +13663,8 @@ var ApplicationStateSchema = import_zod42.z.object({
|
|
|
13288
13663
|
"cancelled",
|
|
13289
13664
|
"complete"
|
|
13290
13665
|
]),
|
|
13291
|
-
createdAt:
|
|
13292
|
-
updatedAt:
|
|
13666
|
+
createdAt: import_zod43.z.number(),
|
|
13667
|
+
updatedAt: import_zod43.z.number()
|
|
13293
13668
|
});
|
|
13294
13669
|
|
|
13295
13670
|
// src/application/agents/classifier.ts
|
|
@@ -15023,106 +15398,106 @@ Respond with the final answer, deduplicated citations array, overall confidence
|
|
|
15023
15398
|
}
|
|
15024
15399
|
|
|
15025
15400
|
// src/schemas/query.ts
|
|
15026
|
-
var
|
|
15027
|
-
var QueryIntentSchema =
|
|
15401
|
+
var import_zod44 = require("zod");
|
|
15402
|
+
var QueryIntentSchema = import_zod44.z.enum([
|
|
15028
15403
|
"policy_question",
|
|
15029
15404
|
"coverage_comparison",
|
|
15030
15405
|
"document_search",
|
|
15031
15406
|
"claims_inquiry",
|
|
15032
15407
|
"general_knowledge"
|
|
15033
15408
|
]);
|
|
15034
|
-
var QueryAttachmentKindSchema =
|
|
15035
|
-
var QueryAttachmentSchema =
|
|
15036
|
-
id:
|
|
15409
|
+
var QueryAttachmentKindSchema = import_zod44.z.enum(["image", "pdf", "text"]);
|
|
15410
|
+
var QueryAttachmentSchema = import_zod44.z.object({
|
|
15411
|
+
id: import_zod44.z.string().optional().describe("Optional stable attachment ID from the caller"),
|
|
15037
15412
|
kind: QueryAttachmentKindSchema,
|
|
15038
|
-
name:
|
|
15039
|
-
mimeType:
|
|
15040
|
-
base64:
|
|
15041
|
-
text:
|
|
15042
|
-
description:
|
|
15413
|
+
name: import_zod44.z.string().optional().describe("Original filename or user-facing label"),
|
|
15414
|
+
mimeType: import_zod44.z.string().optional().describe("MIME type such as image/jpeg or application/pdf"),
|
|
15415
|
+
base64: import_zod44.z.string().optional().describe("Base64-encoded file content for image/pdf attachments"),
|
|
15416
|
+
text: import_zod44.z.string().optional().describe("Plain-text attachment content when available"),
|
|
15417
|
+
description: import_zod44.z.string().optional().describe("Caller-provided description of the attachment")
|
|
15043
15418
|
});
|
|
15044
|
-
var QueryRetrievalModeSchema =
|
|
15419
|
+
var QueryRetrievalModeSchema = import_zod44.z.enum([
|
|
15045
15420
|
"graph_only",
|
|
15046
15421
|
"source_rag",
|
|
15047
15422
|
"long_context",
|
|
15048
15423
|
"hybrid"
|
|
15049
15424
|
]);
|
|
15050
|
-
var SubQuestionSchema =
|
|
15051
|
-
question:
|
|
15425
|
+
var SubQuestionSchema = import_zod44.z.object({
|
|
15426
|
+
question: import_zod44.z.string().describe("Atomic sub-question to retrieve and answer independently"),
|
|
15052
15427
|
intent: QueryIntentSchema,
|
|
15053
|
-
chunkTypes:
|
|
15054
|
-
documentFilters:
|
|
15055
|
-
type:
|
|
15056
|
-
carrier:
|
|
15057
|
-
insuredName:
|
|
15058
|
-
policyNumber:
|
|
15059
|
-
quoteNumber:
|
|
15060
|
-
policyTypes:
|
|
15428
|
+
chunkTypes: import_zod44.z.array(import_zod44.z.string()).optional().describe("Chunk types to filter retrieval (e.g. coverage, endorsement, declaration)"),
|
|
15429
|
+
documentFilters: import_zod44.z.object({
|
|
15430
|
+
type: import_zod44.z.enum(["policy", "quote"]).optional(),
|
|
15431
|
+
carrier: import_zod44.z.string().optional(),
|
|
15432
|
+
insuredName: import_zod44.z.string().optional(),
|
|
15433
|
+
policyNumber: import_zod44.z.string().optional(),
|
|
15434
|
+
quoteNumber: import_zod44.z.string().optional(),
|
|
15435
|
+
policyTypes: import_zod44.z.array(PolicyTypeSchema).optional().describe("Filter by policy type (e.g. homeowners_ho3, renters_ho4, pet) to avoid mixing up similar policies")
|
|
15061
15436
|
}).optional().describe("Structured filters to narrow document lookup")
|
|
15062
15437
|
});
|
|
15063
|
-
var QueryClassifyResultSchema =
|
|
15438
|
+
var QueryClassifyResultSchema = import_zod44.z.object({
|
|
15064
15439
|
intent: QueryIntentSchema,
|
|
15065
|
-
subQuestions:
|
|
15066
|
-
requiresDocumentLookup:
|
|
15067
|
-
requiresChunkSearch:
|
|
15068
|
-
requiresConversationHistory:
|
|
15440
|
+
subQuestions: import_zod44.z.array(SubQuestionSchema).min(1).describe("Decomposed atomic sub-questions"),
|
|
15441
|
+
requiresDocumentLookup: import_zod44.z.boolean().describe("Whether structured document lookup is needed"),
|
|
15442
|
+
requiresChunkSearch: import_zod44.z.boolean().describe("Whether semantic chunk search is needed"),
|
|
15443
|
+
requiresConversationHistory: import_zod44.z.boolean().describe("Whether conversation history is relevant"),
|
|
15069
15444
|
retrievalMode: QueryRetrievalModeSchema.optional().describe("Preferred retrieval strategy for the query when source-span retrieval is available")
|
|
15070
15445
|
});
|
|
15071
|
-
var EvidenceItemSchema =
|
|
15072
|
-
source:
|
|
15073
|
-
chunkId:
|
|
15074
|
-
sourceNodeId:
|
|
15075
|
-
sourceSpanId:
|
|
15076
|
-
documentId:
|
|
15077
|
-
turnId:
|
|
15078
|
-
attachmentId:
|
|
15079
|
-
text:
|
|
15080
|
-
relevance:
|
|
15446
|
+
var EvidenceItemSchema = import_zod44.z.object({
|
|
15447
|
+
source: import_zod44.z.enum(["chunk", "document", "conversation", "attachment", "source_span", "source_node"]),
|
|
15448
|
+
chunkId: import_zod44.z.string().optional(),
|
|
15449
|
+
sourceNodeId: import_zod44.z.string().optional(),
|
|
15450
|
+
sourceSpanId: import_zod44.z.string().optional(),
|
|
15451
|
+
documentId: import_zod44.z.string().optional(),
|
|
15452
|
+
turnId: import_zod44.z.string().optional(),
|
|
15453
|
+
attachmentId: import_zod44.z.string().optional(),
|
|
15454
|
+
text: import_zod44.z.string().describe("Text excerpt from the source"),
|
|
15455
|
+
relevance: import_zod44.z.number().min(0).max(1),
|
|
15081
15456
|
retrievalMode: QueryRetrievalModeSchema.optional(),
|
|
15082
15457
|
sourceLocation: SourceSpanLocationSchema.optional(),
|
|
15083
|
-
metadata:
|
|
15458
|
+
metadata: import_zod44.z.array(import_zod44.z.object({ key: import_zod44.z.string(), value: import_zod44.z.string() })).optional()
|
|
15084
15459
|
});
|
|
15085
|
-
var AttachmentInterpretationSchema =
|
|
15086
|
-
summary:
|
|
15087
|
-
extractedFacts:
|
|
15088
|
-
recommendedFocus:
|
|
15089
|
-
confidence:
|
|
15460
|
+
var AttachmentInterpretationSchema = import_zod44.z.object({
|
|
15461
|
+
summary: import_zod44.z.string().describe("Concise summary of what the attachment shows or contains"),
|
|
15462
|
+
extractedFacts: import_zod44.z.array(import_zod44.z.string()).describe("Specific observable or document facts grounded in the attachment"),
|
|
15463
|
+
recommendedFocus: import_zod44.z.array(import_zod44.z.string()).describe("Important details to incorporate when answering follow-up questions"),
|
|
15464
|
+
confidence: import_zod44.z.number().min(0).max(1)
|
|
15090
15465
|
});
|
|
15091
|
-
var RetrievalResultSchema =
|
|
15092
|
-
subQuestion:
|
|
15093
|
-
evidence:
|
|
15466
|
+
var RetrievalResultSchema = import_zod44.z.object({
|
|
15467
|
+
subQuestion: import_zod44.z.string(),
|
|
15468
|
+
evidence: import_zod44.z.array(EvidenceItemSchema)
|
|
15094
15469
|
});
|
|
15095
|
-
var CitationSchema =
|
|
15096
|
-
index:
|
|
15097
|
-
chunkId:
|
|
15098
|
-
sourceNodeId:
|
|
15099
|
-
sourceSpanId:
|
|
15100
|
-
documentId:
|
|
15101
|
-
documentType:
|
|
15102
|
-
field:
|
|
15103
|
-
quote:
|
|
15104
|
-
relevance:
|
|
15470
|
+
var CitationSchema = import_zod44.z.object({
|
|
15471
|
+
index: import_zod44.z.number().describe("Citation number [1], [2], etc."),
|
|
15472
|
+
chunkId: import_zod44.z.string().optional().describe("Source chunk ID, e.g. doc-123:coverage:2"),
|
|
15473
|
+
sourceNodeId: import_zod44.z.string().optional().describe("Source tree node ID when available"),
|
|
15474
|
+
sourceSpanId: import_zod44.z.string().optional().describe("Precise source span ID when available"),
|
|
15475
|
+
documentId: import_zod44.z.string(),
|
|
15476
|
+
documentType: import_zod44.z.enum(["policy", "quote"]).optional(),
|
|
15477
|
+
field: import_zod44.z.string().optional().describe("Specific field path, e.g. coverages[0].deductible"),
|
|
15478
|
+
quote: import_zod44.z.string().describe("Exact text from source that supports the claim"),
|
|
15479
|
+
relevance: import_zod44.z.number().min(0).max(1),
|
|
15105
15480
|
retrievalMode: QueryRetrievalModeSchema.optional(),
|
|
15106
15481
|
sourceLocation: SourceSpanLocationSchema.optional()
|
|
15107
15482
|
});
|
|
15108
|
-
var SubAnswerSchema =
|
|
15109
|
-
subQuestion:
|
|
15110
|
-
answer:
|
|
15111
|
-
citations:
|
|
15112
|
-
confidence:
|
|
15113
|
-
needsMoreContext:
|
|
15483
|
+
var SubAnswerSchema = import_zod44.z.object({
|
|
15484
|
+
subQuestion: import_zod44.z.string(),
|
|
15485
|
+
answer: import_zod44.z.string(),
|
|
15486
|
+
citations: import_zod44.z.array(CitationSchema),
|
|
15487
|
+
confidence: import_zod44.z.number().min(0).max(1),
|
|
15488
|
+
needsMoreContext: import_zod44.z.boolean().describe("True if evidence was insufficient to answer fully")
|
|
15114
15489
|
});
|
|
15115
|
-
var VerifyResultSchema =
|
|
15116
|
-
approved:
|
|
15117
|
-
issues:
|
|
15118
|
-
retrySubQuestions:
|
|
15490
|
+
var VerifyResultSchema = import_zod44.z.object({
|
|
15491
|
+
approved: import_zod44.z.boolean().describe("Whether all sub-answers are adequately grounded"),
|
|
15492
|
+
issues: import_zod44.z.array(import_zod44.z.string()).describe("Specific grounding or consistency issues found"),
|
|
15493
|
+
retrySubQuestions: import_zod44.z.array(import_zod44.z.string()).optional().describe("Sub-questions that need additional retrieval or re-reasoning")
|
|
15119
15494
|
});
|
|
15120
|
-
var QueryResultSchema =
|
|
15121
|
-
answer:
|
|
15122
|
-
citations:
|
|
15495
|
+
var QueryResultSchema = import_zod44.z.object({
|
|
15496
|
+
answer: import_zod44.z.string(),
|
|
15497
|
+
citations: import_zod44.z.array(CitationSchema),
|
|
15123
15498
|
intent: QueryIntentSchema,
|
|
15124
|
-
confidence:
|
|
15125
|
-
followUp:
|
|
15499
|
+
confidence: import_zod44.z.number().min(0).max(1),
|
|
15500
|
+
followUp: import_zod44.z.string().optional().describe("Suggested follow-up question if applicable")
|
|
15126
15501
|
});
|
|
15127
15502
|
|
|
15128
15503
|
// src/query/retriever.ts
|
|
@@ -16189,7 +16564,7 @@ ${sa.answer}`).join("\n\n"),
|
|
|
16189
16564
|
}
|
|
16190
16565
|
|
|
16191
16566
|
// src/pce/index.ts
|
|
16192
|
-
var
|
|
16567
|
+
var import_zod45 = require("zod");
|
|
16193
16568
|
|
|
16194
16569
|
// src/prompts/pce/index.ts
|
|
16195
16570
|
function buildPceNormalizePrompt(input) {
|
|
@@ -16223,11 +16598,11 @@ ${input.openQuestions.map((question) => `- ${question.id}${question.fieldPath ?
|
|
|
16223
16598
|
}
|
|
16224
16599
|
|
|
16225
16600
|
// src/pce/index.ts
|
|
16226
|
-
var ReplyAnswersSchema =
|
|
16227
|
-
answers:
|
|
16228
|
-
questionId:
|
|
16229
|
-
fieldPath:
|
|
16230
|
-
answer:
|
|
16601
|
+
var ReplyAnswersSchema = import_zod45.z.object({
|
|
16602
|
+
answers: import_zod45.z.array(import_zod45.z.object({
|
|
16603
|
+
questionId: import_zod45.z.string().optional(),
|
|
16604
|
+
fieldPath: import_zod45.z.string().optional(),
|
|
16605
|
+
answer: import_zod45.z.string()
|
|
16231
16606
|
}))
|
|
16232
16607
|
});
|
|
16233
16608
|
function createPceAgent(config = {}) {
|
|
@@ -17188,9 +17563,11 @@ var AGENT_TOOLS = [
|
|
|
17188
17563
|
ScheduledItemCategorySchema,
|
|
17189
17564
|
SectionSchema,
|
|
17190
17565
|
SharedLimitSchema,
|
|
17566
|
+
SourceBackedAddressSchema,
|
|
17191
17567
|
SourceBackedValueSchema,
|
|
17192
17568
|
SourceChunkSchema,
|
|
17193
17569
|
SourceKindSchema,
|
|
17570
|
+
SourceProvenanceSchema,
|
|
17194
17571
|
SourceSpanBBoxSchema,
|
|
17195
17572
|
SourceSpanKindSchema,
|
|
17196
17573
|
SourceSpanLocationSchema,
|