@claritylabs/cl-sdk 4.2.0 → 4.4.0
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 +2 -2
- package/dist/application.d.mts +1 -1
- package/dist/application.d.ts +1 -1
- package/dist/application.js +41 -0
- package/dist/application.js.map +1 -1
- package/dist/application.mjs +41 -0
- package/dist/application.mjs.map +1 -1
- package/dist/{index-C9XfOdmx.d.mts → index-CReSzyKJ.d.mts} +1855 -575
- package/dist/{index-C9XfOdmx.d.ts → index-CReSzyKJ.d.ts} +1855 -575
- package/dist/index.d.mts +370 -277
- package/dist/index.d.ts +370 -277
- package/dist/index.js +2207 -1219
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2200 -1219
- package/dist/index.mjs.map +1 -1
- package/dist/storage-sqlite.d.mts +538 -182
- package/dist/storage-sqlite.d.ts +538 -182
- package/dist/storage-sqlite.js +41 -0
- package/dist/storage-sqlite.js.map +1 -1
- package/dist/storage-sqlite.mjs +41 -0
- package/dist/storage-sqlite.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -179,10 +179,15 @@ __export(src_exports, {
|
|
|
179
179
|
NamedInsuredSchema: () => NamedInsuredSchema,
|
|
180
180
|
OperationalAddressSchema: () => OperationalAddressSchema,
|
|
181
181
|
OperationalCoverageLineSchema: () => OperationalCoverageLineSchema,
|
|
182
|
+
OperationalCoverageScheduleItemSchema: () => OperationalCoverageScheduleItemSchema,
|
|
183
|
+
OperationalCoverageScheduleSchema: () => OperationalCoverageScheduleSchema,
|
|
184
|
+
OperationalCoverageScheduleValueSchema: () => OperationalCoverageScheduleValueSchema,
|
|
182
185
|
OperationalCoverageTermSchema: () => OperationalCoverageTermSchema,
|
|
183
186
|
OperationalDeclarationFactSchema: () => OperationalDeclarationFactSchema,
|
|
184
187
|
OperationalEndorsementSupportSchema: () => OperationalEndorsementSupportSchema,
|
|
185
188
|
OperationalPartySchema: () => OperationalPartySchema,
|
|
189
|
+
OperationalPremiumLineSchema: () => OperationalPremiumLineSchema,
|
|
190
|
+
OperationalTaxFeeItemSchema: () => OperationalTaxFeeItemSchema,
|
|
186
191
|
PERSONAL_AUTO_USAGES: () => PERSONAL_AUTO_USAGES,
|
|
187
192
|
PERSONAL_LOB_CODES: () => PERSONAL_LOB_CODES,
|
|
188
193
|
PET_SPECIES: () => PET_SPECIES,
|
|
@@ -369,6 +374,8 @@ __export(src_exports, {
|
|
|
369
374
|
proposeContextWrites: () => proposeContextWrites,
|
|
370
375
|
resolveModelBudget: () => resolveModelBudget,
|
|
371
376
|
resolveOperationalProfileLinesOfBusiness: () => resolveOperationalProfileLinesOfBusiness,
|
|
377
|
+
runCoverageRecovery: () => runCoverageRecovery,
|
|
378
|
+
runSourceTreeExtraction: () => runSourceTreeExtraction,
|
|
372
379
|
safeGenerateObject: () => safeGenerateObject,
|
|
373
380
|
sanitizeNulls: () => sanitizeNulls,
|
|
374
381
|
scoreCaseProposal: () => scoreCaseProposal,
|
|
@@ -1451,7 +1458,8 @@ var InsurerInfoSchema = import_zod9.z.object({
|
|
|
1451
1458
|
amBestRating: import_zod9.z.string().optional(),
|
|
1452
1459
|
amBestNumber: import_zod9.z.string().optional(),
|
|
1453
1460
|
admittedStatus: AdmittedStatusSchema.optional(),
|
|
1454
|
-
stateOfDomicile: import_zod9.z.string().optional()
|
|
1461
|
+
stateOfDomicile: import_zod9.z.string().optional(),
|
|
1462
|
+
address: AddressSchema.optional()
|
|
1455
1463
|
}).merge(SourceProvenanceSchema);
|
|
1456
1464
|
var ProducerInfoSchema = import_zod9.z.object({
|
|
1457
1465
|
agencyName: import_zod9.z.string(),
|
|
@@ -2008,251 +2016,541 @@ var DeclarationsSchema = import_zod16.z.discriminatedUnion("line", [
|
|
|
2008
2016
|
]);
|
|
2009
2017
|
|
|
2010
2018
|
// src/schemas/document.ts
|
|
2019
|
+
var import_zod18 = require("zod");
|
|
2020
|
+
|
|
2021
|
+
// src/source/schemas.ts
|
|
2011
2022
|
var import_zod17 = require("zod");
|
|
2012
|
-
var
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
+
var SourceSpanKindSchema = import_zod17.z.enum([
|
|
2024
|
+
"pdf_text",
|
|
2025
|
+
"pdf_image",
|
|
2026
|
+
"html",
|
|
2027
|
+
"markdown",
|
|
2028
|
+
"plain_text",
|
|
2029
|
+
"structured_field"
|
|
2030
|
+
]);
|
|
2031
|
+
var SourceSpanUnitSchema = import_zod17.z.enum([
|
|
2032
|
+
"page",
|
|
2033
|
+
"section",
|
|
2034
|
+
"table",
|
|
2035
|
+
"table_row",
|
|
2036
|
+
"table_cell",
|
|
2037
|
+
"key_value",
|
|
2038
|
+
"text"
|
|
2039
|
+
]);
|
|
2040
|
+
var SourceKindSchema = import_zod17.z.enum([
|
|
2041
|
+
"policy_pdf",
|
|
2042
|
+
"application_pdf",
|
|
2043
|
+
"email",
|
|
2044
|
+
"attachment",
|
|
2045
|
+
"manual_note"
|
|
2046
|
+
]);
|
|
2047
|
+
var SourceSpanBBoxSchema = import_zod17.z.object({
|
|
2048
|
+
page: import_zod17.z.number().int().positive(),
|
|
2049
|
+
x: import_zod17.z.number(),
|
|
2050
|
+
y: import_zod17.z.number(),
|
|
2051
|
+
width: import_zod17.z.number(),
|
|
2052
|
+
height: import_zod17.z.number()
|
|
2053
|
+
});
|
|
2054
|
+
var SourceSpanLocationSchema = import_zod17.z.object({
|
|
2055
|
+
page: import_zod17.z.number().int().positive().optional(),
|
|
2056
|
+
startPage: import_zod17.z.number().int().positive().optional(),
|
|
2057
|
+
endPage: import_zod17.z.number().int().positive().optional(),
|
|
2058
|
+
charStart: import_zod17.z.number().int().nonnegative().optional(),
|
|
2059
|
+
charEnd: import_zod17.z.number().int().nonnegative().optional(),
|
|
2060
|
+
lineStart: import_zod17.z.number().int().positive().optional(),
|
|
2061
|
+
lineEnd: import_zod17.z.number().int().positive().optional(),
|
|
2062
|
+
fieldPath: import_zod17.z.string().optional()
|
|
2063
|
+
});
|
|
2064
|
+
var SourceSpanTableLocationSchema = import_zod17.z.object({
|
|
2065
|
+
tableId: import_zod17.z.string().optional(),
|
|
2066
|
+
rowIndex: import_zod17.z.number().int().nonnegative().optional(),
|
|
2067
|
+
columnIndex: import_zod17.z.number().int().nonnegative().optional(),
|
|
2068
|
+
columnName: import_zod17.z.string().optional(),
|
|
2069
|
+
rowSpanId: import_zod17.z.string().optional(),
|
|
2070
|
+
tableSpanId: import_zod17.z.string().optional(),
|
|
2071
|
+
isHeader: import_zod17.z.boolean().optional()
|
|
2072
|
+
});
|
|
2073
|
+
var SourceSpanSchema = import_zod17.z.object({
|
|
2074
|
+
id: import_zod17.z.string().min(1),
|
|
2075
|
+
documentId: import_zod17.z.string().min(1),
|
|
2076
|
+
sourceKind: SourceKindSchema.optional(),
|
|
2077
|
+
chunkId: import_zod17.z.string().optional(),
|
|
2078
|
+
kind: SourceSpanKindSchema,
|
|
2079
|
+
text: import_zod17.z.string(),
|
|
2080
|
+
hash: import_zod17.z.string().min(1),
|
|
2081
|
+
textHash: import_zod17.z.string().optional(),
|
|
2082
|
+
pageStart: import_zod17.z.number().int().positive().optional(),
|
|
2083
|
+
pageEnd: import_zod17.z.number().int().positive().optional(),
|
|
2084
|
+
sectionId: import_zod17.z.string().optional(),
|
|
2085
|
+
formNumber: import_zod17.z.string().optional(),
|
|
2086
|
+
sourceUnit: SourceSpanUnitSchema.optional(),
|
|
2087
|
+
parentSpanId: import_zod17.z.string().optional(),
|
|
2088
|
+
table: SourceSpanTableLocationSchema.optional(),
|
|
2089
|
+
bbox: import_zod17.z.array(SourceSpanBBoxSchema).optional(),
|
|
2090
|
+
location: SourceSpanLocationSchema.optional(),
|
|
2091
|
+
metadata: import_zod17.z.record(import_zod17.z.string(), import_zod17.z.string()).optional()
|
|
2092
|
+
});
|
|
2093
|
+
var SourceSpanRefSchema = import_zod17.z.object({
|
|
2094
|
+
sourceSpanId: import_zod17.z.string().min(1),
|
|
2095
|
+
documentId: import_zod17.z.string().min(1).optional(),
|
|
2096
|
+
chunkId: import_zod17.z.string().optional(),
|
|
2097
|
+
quote: import_zod17.z.string().optional(),
|
|
2098
|
+
hash: import_zod17.z.string().optional(),
|
|
2099
|
+
location: SourceSpanLocationSchema.optional()
|
|
2100
|
+
});
|
|
2101
|
+
var SourceChunkSchema = import_zod17.z.object({
|
|
2102
|
+
id: import_zod17.z.string().min(1),
|
|
2103
|
+
documentId: import_zod17.z.string().min(1),
|
|
2104
|
+
sourceSpanIds: import_zod17.z.array(import_zod17.z.string().min(1)),
|
|
2105
|
+
text: import_zod17.z.string(),
|
|
2106
|
+
textHash: import_zod17.z.string().min(1),
|
|
2107
|
+
pageStart: import_zod17.z.number().int().positive().optional(),
|
|
2108
|
+
pageEnd: import_zod17.z.number().int().positive().optional(),
|
|
2109
|
+
metadata: import_zod17.z.record(import_zod17.z.string(), import_zod17.z.string()).default({})
|
|
2110
|
+
});
|
|
2111
|
+
var DocumentSourceNodeKindSchema = import_zod17.z.enum([
|
|
2112
|
+
"document",
|
|
2113
|
+
"page_group",
|
|
2114
|
+
"page",
|
|
2115
|
+
"form",
|
|
2116
|
+
"endorsement",
|
|
2117
|
+
"section",
|
|
2118
|
+
"schedule",
|
|
2119
|
+
"clause",
|
|
2120
|
+
"table",
|
|
2121
|
+
"table_row",
|
|
2122
|
+
"table_cell",
|
|
2123
|
+
"text"
|
|
2124
|
+
]);
|
|
2125
|
+
var DocumentSourceNodeSchema = import_zod17.z.object({
|
|
2126
|
+
id: import_zod17.z.string().min(1),
|
|
2127
|
+
documentId: import_zod17.z.string().min(1),
|
|
2128
|
+
parentId: import_zod17.z.string().optional(),
|
|
2129
|
+
kind: DocumentSourceNodeKindSchema,
|
|
2023
2130
|
title: import_zod17.z.string(),
|
|
2024
|
-
sectionNumber: import_zod17.z.string().optional(),
|
|
2025
|
-
pageStart: import_zod17.z.number(),
|
|
2026
|
-
pageEnd: import_zod17.z.number().optional(),
|
|
2027
|
-
type: import_zod17.z.string(),
|
|
2028
|
-
coverageType: import_zod17.z.string().optional(),
|
|
2029
|
-
excerpt: import_zod17.z.string().optional(),
|
|
2030
|
-
content: import_zod17.z.string().optional(),
|
|
2031
|
-
subsections: import_zod17.z.array(SubsectionSchema).optional(),
|
|
2032
|
-
recordId: import_zod17.z.string().optional(),
|
|
2033
|
-
documentNodeId: import_zod17.z.string().optional(),
|
|
2034
|
-
sourceSpanIds: import_zod17.z.array(import_zod17.z.string()).optional(),
|
|
2035
|
-
sourceTextHash: import_zod17.z.string().optional()
|
|
2036
|
-
});
|
|
2037
|
-
var SubjectivitySchema = import_zod17.z.object({
|
|
2038
2131
|
description: import_zod17.z.string(),
|
|
2039
|
-
|
|
2132
|
+
textExcerpt: import_zod17.z.string().optional(),
|
|
2133
|
+
sourceSpanIds: import_zod17.z.array(import_zod17.z.string().min(1)),
|
|
2134
|
+
pageStart: import_zod17.z.number().int().positive().optional(),
|
|
2135
|
+
pageEnd: import_zod17.z.number().int().positive().optional(),
|
|
2136
|
+
bbox: import_zod17.z.array(SourceSpanBBoxSchema).optional(),
|
|
2137
|
+
order: import_zod17.z.number().int().nonnegative(),
|
|
2138
|
+
path: import_zod17.z.string(),
|
|
2139
|
+
metadata: import_zod17.z.record(import_zod17.z.string(), import_zod17.z.unknown()).optional()
|
|
2140
|
+
});
|
|
2141
|
+
var SourceBackedValueSchema = import_zod17.z.object({
|
|
2142
|
+
value: import_zod17.z.string(),
|
|
2143
|
+
normalizedValue: import_zod17.z.string().optional(),
|
|
2144
|
+
confidence: import_zod17.z.enum(["low", "medium", "high"]).default("medium"),
|
|
2145
|
+
sourceNodeIds: import_zod17.z.array(import_zod17.z.string().min(1)).default([]),
|
|
2146
|
+
sourceSpanIds: import_zod17.z.array(import_zod17.z.string().min(1)).default([])
|
|
2147
|
+
});
|
|
2148
|
+
var OperationalAddressSchema = import_zod17.z.object({
|
|
2149
|
+
street1: import_zod17.z.string().optional(),
|
|
2150
|
+
street2: import_zod17.z.string().optional(),
|
|
2151
|
+
city: import_zod17.z.string().optional(),
|
|
2152
|
+
state: import_zod17.z.string().optional(),
|
|
2153
|
+
zip: import_zod17.z.string().optional(),
|
|
2154
|
+
country: import_zod17.z.string().optional(),
|
|
2155
|
+
formatted: import_zod17.z.string().optional()
|
|
2156
|
+
});
|
|
2157
|
+
var OperationalDeclarationFactSchema = import_zod17.z.object({
|
|
2158
|
+
field: import_zod17.z.enum([
|
|
2159
|
+
"namedInsured",
|
|
2160
|
+
"mailingAddress",
|
|
2161
|
+
"dba",
|
|
2162
|
+
"entityType",
|
|
2163
|
+
"taxId",
|
|
2164
|
+
"additionalNamedInsured",
|
|
2165
|
+
"policyNumber",
|
|
2166
|
+
"insurer",
|
|
2167
|
+
"broker",
|
|
2168
|
+
"effectiveDate",
|
|
2169
|
+
"expirationDate",
|
|
2170
|
+
"premium",
|
|
2171
|
+
"other"
|
|
2172
|
+
]),
|
|
2173
|
+
label: import_zod17.z.string().optional(),
|
|
2174
|
+
value: import_zod17.z.string(),
|
|
2175
|
+
normalizedValue: import_zod17.z.string().optional(),
|
|
2176
|
+
valueKind: import_zod17.z.enum(["string", "number", "date", "money", "address", "list", "unknown"]).default("string"),
|
|
2177
|
+
address: OperationalAddressSchema.optional(),
|
|
2178
|
+
confidence: import_zod17.z.enum(["low", "medium", "high"]).default("medium"),
|
|
2179
|
+
sourceNodeIds: import_zod17.z.array(import_zod17.z.string().min(1)).default([]),
|
|
2180
|
+
sourceSpanIds: import_zod17.z.array(import_zod17.z.string().min(1)).default([])
|
|
2040
2181
|
});
|
|
2041
|
-
var
|
|
2042
|
-
|
|
2182
|
+
var OperationalCoverageTermSchema = import_zod17.z.object({
|
|
2183
|
+
kind: import_zod17.z.enum([
|
|
2184
|
+
"each_claim_limit",
|
|
2185
|
+
"each_occurrence_limit",
|
|
2186
|
+
"each_loss_limit",
|
|
2187
|
+
"aggregate_limit",
|
|
2188
|
+
"sublimit",
|
|
2189
|
+
"retention",
|
|
2190
|
+
"deductible",
|
|
2191
|
+
"retroactive_date",
|
|
2192
|
+
"premium",
|
|
2193
|
+
"other"
|
|
2194
|
+
]).default("other"),
|
|
2195
|
+
label: import_zod17.z.string(),
|
|
2196
|
+
value: import_zod17.z.string(),
|
|
2197
|
+
amount: import_zod17.z.number().optional(),
|
|
2198
|
+
appliesTo: import_zod17.z.string().optional(),
|
|
2199
|
+
sourceNodeIds: import_zod17.z.array(import_zod17.z.string().min(1)).default([]),
|
|
2200
|
+
sourceSpanIds: import_zod17.z.array(import_zod17.z.string().min(1)).default([])
|
|
2043
2201
|
});
|
|
2044
|
-
var
|
|
2202
|
+
var OperationalCoverageLineSchema = import_zod17.z.object({
|
|
2203
|
+
name: import_zod17.z.string(),
|
|
2204
|
+
lineOfBusiness: AcordLobCodeSchema.optional(),
|
|
2205
|
+
coverageCode: import_zod17.z.string().optional(),
|
|
2206
|
+
limit: import_zod17.z.string().optional(),
|
|
2207
|
+
deductible: import_zod17.z.string().optional(),
|
|
2208
|
+
premium: import_zod17.z.string().optional(),
|
|
2209
|
+
retroactiveDate: import_zod17.z.string().optional(),
|
|
2210
|
+
formNumber: import_zod17.z.string().optional(),
|
|
2211
|
+
sectionRef: import_zod17.z.string().optional(),
|
|
2212
|
+
endorsementNumber: import_zod17.z.string().optional(),
|
|
2213
|
+
limits: import_zod17.z.array(OperationalCoverageTermSchema).default([]),
|
|
2214
|
+
sourceNodeIds: import_zod17.z.array(import_zod17.z.string().min(1)).default([]),
|
|
2215
|
+
sourceSpanIds: import_zod17.z.array(import_zod17.z.string().min(1)).default([])
|
|
2216
|
+
});
|
|
2217
|
+
var OperationalCoverageScheduleValueSchema = import_zod17.z.object({
|
|
2218
|
+
label: import_zod17.z.string(),
|
|
2219
|
+
value: import_zod17.z.string()
|
|
2220
|
+
});
|
|
2221
|
+
var OperationalCoverageScheduleItemSchema = import_zod17.z.object({
|
|
2222
|
+
label: import_zod17.z.string(),
|
|
2223
|
+
description: import_zod17.z.string().optional(),
|
|
2224
|
+
values: import_zod17.z.array(OperationalCoverageScheduleValueSchema).default([]),
|
|
2225
|
+
sourceSpanIds: import_zod17.z.array(import_zod17.z.string().min(1)).default([])
|
|
2226
|
+
});
|
|
2227
|
+
var OperationalCoverageScheduleSchema = import_zod17.z.object({
|
|
2228
|
+
name: import_zod17.z.string(),
|
|
2229
|
+
kind: import_zod17.z.enum(["vehicle", "property", "location", "other"]),
|
|
2230
|
+
description: import_zod17.z.string().optional(),
|
|
2231
|
+
items: import_zod17.z.array(OperationalCoverageScheduleItemSchema).default([]),
|
|
2232
|
+
sourceSpanIds: import_zod17.z.array(import_zod17.z.string().min(1)).default([]),
|
|
2233
|
+
pageStart: import_zod17.z.number().int().positive().optional(),
|
|
2234
|
+
pageEnd: import_zod17.z.number().int().positive().optional()
|
|
2235
|
+
});
|
|
2236
|
+
var OperationalPremiumLineSchema = import_zod17.z.object({
|
|
2045
2237
|
line: import_zod17.z.string(),
|
|
2046
2238
|
amount: import_zod17.z.string(),
|
|
2047
2239
|
amountValue: import_zod17.z.number().optional(),
|
|
2048
|
-
|
|
2049
|
-
sourceSpanIds: import_zod17.z.array(import_zod17.z.string()).
|
|
2050
|
-
sourceTextHash: import_zod17.z.string().optional()
|
|
2240
|
+
sourceNodeIds: import_zod17.z.array(import_zod17.z.string().min(1)).default([]),
|
|
2241
|
+
sourceSpanIds: import_zod17.z.array(import_zod17.z.string().min(1)).default([])
|
|
2051
2242
|
});
|
|
2052
|
-
var
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
});
|
|
2061
|
-
var
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
sectionRef: import_zod17.z.string().optional(),
|
|
2068
|
-
originalContent: import_zod17.z.string().optional(),
|
|
2069
|
-
recordId: import_zod17.z.string().optional(),
|
|
2070
|
-
documentNodeId: import_zod17.z.string().optional(),
|
|
2071
|
-
sourceSpanIds: import_zod17.z.array(import_zod17.z.string()).optional(),
|
|
2072
|
-
sourceTextHash: import_zod17.z.string().optional()
|
|
2073
|
-
});
|
|
2074
|
-
var CoveredReasonSchema = import_zod17.z.object({
|
|
2075
|
-
coverageName: import_zod17.z.string(),
|
|
2076
|
-
reasonNumber: import_zod17.z.string().optional(),
|
|
2077
|
-
title: import_zod17.z.string().optional(),
|
|
2078
|
-
content: import_zod17.z.string(),
|
|
2079
|
-
conditions: import_zod17.z.array(import_zod17.z.string()).optional(),
|
|
2080
|
-
exceptions: import_zod17.z.array(import_zod17.z.string()).optional(),
|
|
2081
|
-
appliesTo: import_zod17.z.array(import_zod17.z.string()).optional(),
|
|
2082
|
-
pageNumber: import_zod17.z.number().optional(),
|
|
2083
|
-
formNumber: import_zod17.z.string().optional(),
|
|
2084
|
-
formTitle: import_zod17.z.string().optional(),
|
|
2085
|
-
sectionRef: import_zod17.z.string().optional(),
|
|
2086
|
-
originalContent: import_zod17.z.string().optional(),
|
|
2087
|
-
recordId: import_zod17.z.string().optional(),
|
|
2088
|
-
documentNodeId: import_zod17.z.string().optional(),
|
|
2089
|
-
sourceSpanIds: import_zod17.z.array(import_zod17.z.string()).optional(),
|
|
2090
|
-
sourceTextHash: import_zod17.z.string().optional()
|
|
2091
|
-
});
|
|
2092
|
-
var DocumentTableOfContentsEntrySchema = import_zod17.z.object({
|
|
2093
|
-
title: import_zod17.z.string(),
|
|
2094
|
-
level: import_zod17.z.number().int().positive().optional(),
|
|
2095
|
-
pageStart: import_zod17.z.number().optional(),
|
|
2096
|
-
pageEnd: import_zod17.z.number().optional(),
|
|
2097
|
-
documentNodeId: import_zod17.z.string().optional(),
|
|
2098
|
-
sourceSpanIds: import_zod17.z.array(import_zod17.z.string()).optional()
|
|
2099
|
-
});
|
|
2100
|
-
var DocumentPageMapEntrySchema = import_zod17.z.object({
|
|
2101
|
-
page: import_zod17.z.number().int().positive(),
|
|
2102
|
-
label: import_zod17.z.string().optional(),
|
|
2103
|
-
formNumber: import_zod17.z.string().optional(),
|
|
2104
|
-
formTitle: import_zod17.z.string().optional(),
|
|
2105
|
-
sectionTitle: import_zod17.z.string().optional(),
|
|
2106
|
-
extractorNames: import_zod17.z.array(import_zod17.z.string()).optional(),
|
|
2107
|
-
sourceSpanIds: import_zod17.z.array(import_zod17.z.string()).optional()
|
|
2243
|
+
var OperationalTaxFeeItemSchema = import_zod17.z.object({
|
|
2244
|
+
name: import_zod17.z.string(),
|
|
2245
|
+
amount: import_zod17.z.string(),
|
|
2246
|
+
amountValue: import_zod17.z.number().optional(),
|
|
2247
|
+
type: import_zod17.z.string().optional(),
|
|
2248
|
+
description: import_zod17.z.string().optional(),
|
|
2249
|
+
sourceNodeIds: import_zod17.z.array(import_zod17.z.string().min(1)).default([]),
|
|
2250
|
+
sourceSpanIds: import_zod17.z.array(import_zod17.z.string().min(1)).default([])
|
|
2251
|
+
});
|
|
2252
|
+
var OperationalPartySchema = import_zod17.z.object({
|
|
2253
|
+
role: import_zod17.z.string(),
|
|
2254
|
+
name: import_zod17.z.string(),
|
|
2255
|
+
address: OperationalAddressSchema.optional(),
|
|
2256
|
+
sourceNodeIds: import_zod17.z.array(import_zod17.z.string().min(1)).default([]),
|
|
2257
|
+
sourceSpanIds: import_zod17.z.array(import_zod17.z.string().min(1)).default([])
|
|
2108
2258
|
});
|
|
2109
|
-
var
|
|
2259
|
+
var OperationalEndorsementSupportSchema = import_zod17.z.object({
|
|
2110
2260
|
kind: import_zod17.z.string(),
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2261
|
+
status: import_zod17.z.enum(["supported", "excluded", "requires_review"]),
|
|
2262
|
+
summary: import_zod17.z.string(),
|
|
2263
|
+
sourceNodeIds: import_zod17.z.array(import_zod17.z.string().min(1)).default([]),
|
|
2264
|
+
sourceSpanIds: import_zod17.z.array(import_zod17.z.string().min(1)).default([])
|
|
2265
|
+
});
|
|
2266
|
+
function legacyOperationalProfileInput(value) {
|
|
2267
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return value;
|
|
2268
|
+
const record = value;
|
|
2269
|
+
if ("linesOfBusiness" in record) return value;
|
|
2270
|
+
if (!("policyTypes" in record)) return value;
|
|
2271
|
+
return {
|
|
2272
|
+
...record,
|
|
2273
|
+
linesOfBusiness: record.policyTypes
|
|
2274
|
+
};
|
|
2275
|
+
}
|
|
2276
|
+
var OperationalLinesOfBusinessSchema = import_zod17.z.preprocess(
|
|
2277
|
+
(value) => Array.isArray(value) ? toLobCodes(value.filter((item) => typeof item === "string")) : void 0,
|
|
2278
|
+
import_zod17.z.array(AcordLobCodeSchema).default(["UN"])
|
|
2279
|
+
);
|
|
2280
|
+
var PolicyOperationalProfileSchema = import_zod17.z.preprocess(
|
|
2281
|
+
legacyOperationalProfileInput,
|
|
2282
|
+
import_zod17.z.object({
|
|
2283
|
+
documentType: import_zod17.z.enum(["policy", "quote"]).default("policy"),
|
|
2284
|
+
linesOfBusiness: OperationalLinesOfBusinessSchema,
|
|
2285
|
+
policyNumber: SourceBackedValueSchema.optional(),
|
|
2286
|
+
namedInsured: SourceBackedValueSchema.optional(),
|
|
2287
|
+
insurer: SourceBackedValueSchema.optional(),
|
|
2288
|
+
broker: SourceBackedValueSchema.optional(),
|
|
2289
|
+
effectiveDate: SourceBackedValueSchema.optional(),
|
|
2290
|
+
expirationDate: SourceBackedValueSchema.optional(),
|
|
2291
|
+
retroactiveDate: SourceBackedValueSchema.optional(),
|
|
2292
|
+
premium: SourceBackedValueSchema.optional(),
|
|
2293
|
+
operationsDescription: SourceBackedValueSchema.optional(),
|
|
2294
|
+
declarationFacts: import_zod17.z.array(OperationalDeclarationFactSchema).default([]),
|
|
2295
|
+
coverages: import_zod17.z.array(OperationalCoverageLineSchema).default([]),
|
|
2296
|
+
coverageSchedules: import_zod17.z.array(OperationalCoverageScheduleSchema).optional(),
|
|
2297
|
+
premiumBreakdown: import_zod17.z.array(OperationalPremiumLineSchema).optional(),
|
|
2298
|
+
taxesAndFees: import_zod17.z.array(OperationalTaxFeeItemSchema).optional(),
|
|
2299
|
+
totalCost: SourceBackedValueSchema.optional(),
|
|
2300
|
+
parties: import_zod17.z.array(OperationalPartySchema).default([]),
|
|
2301
|
+
endorsementSupport: import_zod17.z.array(OperationalEndorsementSupportSchema).default([]),
|
|
2302
|
+
sourceNodeIds: import_zod17.z.array(import_zod17.z.string().min(1)).default([]),
|
|
2303
|
+
sourceSpanIds: import_zod17.z.array(import_zod17.z.string().min(1)).default([]),
|
|
2304
|
+
warnings: import_zod17.z.array(import_zod17.z.string()).default([])
|
|
2305
|
+
})
|
|
2306
|
+
);
|
|
2307
|
+
|
|
2308
|
+
// src/schemas/document.ts
|
|
2309
|
+
var SubsectionSchema = import_zod18.z.object({
|
|
2310
|
+
title: import_zod18.z.string(),
|
|
2311
|
+
sectionNumber: import_zod18.z.string().optional(),
|
|
2312
|
+
pageNumber: import_zod18.z.number().optional(),
|
|
2313
|
+
excerpt: import_zod18.z.string().optional(),
|
|
2314
|
+
content: import_zod18.z.string().optional(),
|
|
2315
|
+
documentNodeId: import_zod18.z.string().optional(),
|
|
2316
|
+
sourceSpanIds: import_zod18.z.array(import_zod18.z.string()).optional(),
|
|
2317
|
+
sourceTextHash: import_zod18.z.string().optional()
|
|
2318
|
+
});
|
|
2319
|
+
var SectionSchema = import_zod18.z.object({
|
|
2320
|
+
title: import_zod18.z.string(),
|
|
2321
|
+
sectionNumber: import_zod18.z.string().optional(),
|
|
2322
|
+
pageStart: import_zod18.z.number(),
|
|
2323
|
+
pageEnd: import_zod18.z.number().optional(),
|
|
2324
|
+
type: import_zod18.z.string(),
|
|
2325
|
+
coverageType: import_zod18.z.string().optional(),
|
|
2326
|
+
excerpt: import_zod18.z.string().optional(),
|
|
2327
|
+
content: import_zod18.z.string().optional(),
|
|
2328
|
+
subsections: import_zod18.z.array(SubsectionSchema).optional(),
|
|
2329
|
+
recordId: import_zod18.z.string().optional(),
|
|
2330
|
+
documentNodeId: import_zod18.z.string().optional(),
|
|
2331
|
+
sourceSpanIds: import_zod18.z.array(import_zod18.z.string()).optional(),
|
|
2332
|
+
sourceTextHash: import_zod18.z.string().optional()
|
|
2333
|
+
});
|
|
2334
|
+
var SubjectivitySchema = import_zod18.z.object({
|
|
2335
|
+
description: import_zod18.z.string(),
|
|
2336
|
+
category: import_zod18.z.string().optional()
|
|
2337
|
+
});
|
|
2338
|
+
var UnderwritingConditionSchema = import_zod18.z.object({
|
|
2339
|
+
description: import_zod18.z.string()
|
|
2340
|
+
});
|
|
2341
|
+
var PremiumLineSchema = import_zod18.z.object({
|
|
2342
|
+
line: import_zod18.z.string(),
|
|
2343
|
+
amount: import_zod18.z.string(),
|
|
2344
|
+
amountValue: import_zod18.z.number().optional(),
|
|
2345
|
+
documentNodeId: import_zod18.z.string().optional(),
|
|
2346
|
+
sourceSpanIds: import_zod18.z.array(import_zod18.z.string()).optional(),
|
|
2347
|
+
sourceTextHash: import_zod18.z.string().optional()
|
|
2348
|
+
});
|
|
2349
|
+
var AuxiliaryFactSchema = import_zod18.z.object({
|
|
2350
|
+
key: import_zod18.z.string(),
|
|
2351
|
+
value: import_zod18.z.string(),
|
|
2352
|
+
subject: import_zod18.z.string().optional(),
|
|
2353
|
+
context: import_zod18.z.string().optional(),
|
|
2354
|
+
documentNodeId: import_zod18.z.string().optional(),
|
|
2355
|
+
sourceSpanIds: import_zod18.z.array(import_zod18.z.string()).optional(),
|
|
2356
|
+
sourceTextHash: import_zod18.z.string().optional()
|
|
2357
|
+
});
|
|
2358
|
+
var DefinitionSchema = import_zod18.z.object({
|
|
2359
|
+
term: import_zod18.z.string(),
|
|
2360
|
+
definition: import_zod18.z.string(),
|
|
2361
|
+
pageNumber: import_zod18.z.number().optional(),
|
|
2362
|
+
formNumber: import_zod18.z.string().optional(),
|
|
2363
|
+
formTitle: import_zod18.z.string().optional(),
|
|
2364
|
+
sectionRef: import_zod18.z.string().optional(),
|
|
2365
|
+
originalContent: import_zod18.z.string().optional(),
|
|
2366
|
+
recordId: import_zod18.z.string().optional(),
|
|
2367
|
+
documentNodeId: import_zod18.z.string().optional(),
|
|
2368
|
+
sourceSpanIds: import_zod18.z.array(import_zod18.z.string()).optional(),
|
|
2369
|
+
sourceTextHash: import_zod18.z.string().optional()
|
|
2370
|
+
});
|
|
2371
|
+
var CoveredReasonSchema = import_zod18.z.object({
|
|
2372
|
+
coverageName: import_zod18.z.string(),
|
|
2373
|
+
reasonNumber: import_zod18.z.string().optional(),
|
|
2374
|
+
title: import_zod18.z.string().optional(),
|
|
2375
|
+
content: import_zod18.z.string(),
|
|
2376
|
+
conditions: import_zod18.z.array(import_zod18.z.string()).optional(),
|
|
2377
|
+
exceptions: import_zod18.z.array(import_zod18.z.string()).optional(),
|
|
2378
|
+
appliesTo: import_zod18.z.array(import_zod18.z.string()).optional(),
|
|
2379
|
+
pageNumber: import_zod18.z.number().optional(),
|
|
2380
|
+
formNumber: import_zod18.z.string().optional(),
|
|
2381
|
+
formTitle: import_zod18.z.string().optional(),
|
|
2382
|
+
sectionRef: import_zod18.z.string().optional(),
|
|
2383
|
+
originalContent: import_zod18.z.string().optional(),
|
|
2384
|
+
recordId: import_zod18.z.string().optional(),
|
|
2385
|
+
documentNodeId: import_zod18.z.string().optional(),
|
|
2386
|
+
sourceSpanIds: import_zod18.z.array(import_zod18.z.string()).optional(),
|
|
2387
|
+
sourceTextHash: import_zod18.z.string().optional()
|
|
2388
|
+
});
|
|
2389
|
+
var DocumentTableOfContentsEntrySchema = import_zod18.z.object({
|
|
2390
|
+
title: import_zod18.z.string(),
|
|
2391
|
+
level: import_zod18.z.number().int().positive().optional(),
|
|
2392
|
+
pageStart: import_zod18.z.number().optional(),
|
|
2393
|
+
pageEnd: import_zod18.z.number().optional(),
|
|
2394
|
+
documentNodeId: import_zod18.z.string().optional(),
|
|
2395
|
+
sourceSpanIds: import_zod18.z.array(import_zod18.z.string()).optional()
|
|
2396
|
+
});
|
|
2397
|
+
var DocumentPageMapEntrySchema = import_zod18.z.object({
|
|
2398
|
+
page: import_zod18.z.number().int().positive(),
|
|
2399
|
+
label: import_zod18.z.string().optional(),
|
|
2400
|
+
formNumber: import_zod18.z.string().optional(),
|
|
2401
|
+
formTitle: import_zod18.z.string().optional(),
|
|
2402
|
+
sectionTitle: import_zod18.z.string().optional(),
|
|
2403
|
+
extractorNames: import_zod18.z.array(import_zod18.z.string()).optional(),
|
|
2404
|
+
sourceSpanIds: import_zod18.z.array(import_zod18.z.string()).optional()
|
|
2405
|
+
});
|
|
2406
|
+
var DocumentAgentGuidanceSchema = import_zod18.z.object({
|
|
2407
|
+
kind: import_zod18.z.string(),
|
|
2408
|
+
title: import_zod18.z.string(),
|
|
2409
|
+
detail: import_zod18.z.string(),
|
|
2410
|
+
sourceSpanIds: import_zod18.z.array(import_zod18.z.string()).optional()
|
|
2411
|
+
});
|
|
2412
|
+
var DocumentMetadataSchema = import_zod18.z.object({
|
|
2413
|
+
sourceTreeVersion: import_zod18.z.string().optional(),
|
|
2414
|
+
sourceTreeCanonical: import_zod18.z.boolean().optional(),
|
|
2415
|
+
formInventory: import_zod18.z.array(FormReferenceSchema).optional(),
|
|
2416
|
+
tableOfContents: import_zod18.z.array(DocumentTableOfContentsEntrySchema).optional(),
|
|
2417
|
+
pageMap: import_zod18.z.array(DocumentPageMapEntrySchema).optional(),
|
|
2418
|
+
agentGuidance: import_zod18.z.array(DocumentAgentGuidanceSchema).optional()
|
|
2419
|
+
});
|
|
2420
|
+
var DocumentNodeSchema = import_zod18.z.lazy(
|
|
2421
|
+
() => import_zod18.z.object({
|
|
2422
|
+
id: import_zod18.z.string(),
|
|
2423
|
+
title: import_zod18.z.string(),
|
|
2424
|
+
originalTitle: import_zod18.z.string().optional(),
|
|
2425
|
+
type: import_zod18.z.string().optional(),
|
|
2426
|
+
label: import_zod18.z.string().optional(),
|
|
2427
|
+
level: import_zod18.z.number().int().positive().optional(),
|
|
2428
|
+
sectionNumber: import_zod18.z.string().optional(),
|
|
2429
|
+
pageStart: import_zod18.z.number().optional(),
|
|
2430
|
+
pageEnd: import_zod18.z.number().optional(),
|
|
2431
|
+
formNumber: import_zod18.z.string().optional(),
|
|
2432
|
+
formTitle: import_zod18.z.string().optional(),
|
|
2433
|
+
excerpt: import_zod18.z.string().optional(),
|
|
2434
|
+
content: import_zod18.z.string().optional(),
|
|
2435
|
+
interpretationLabels: import_zod18.z.array(import_zod18.z.string()).optional(),
|
|
2436
|
+
sourceSpanIds: import_zod18.z.array(import_zod18.z.string()).optional(),
|
|
2437
|
+
sourceTextHash: import_zod18.z.string().optional(),
|
|
2438
|
+
children: import_zod18.z.array(DocumentNodeSchema).optional()
|
|
2142
2439
|
})
|
|
2143
2440
|
);
|
|
2144
2441
|
var BaseDocumentFields = {
|
|
2145
|
-
id:
|
|
2146
|
-
carrier:
|
|
2147
|
-
security:
|
|
2148
|
-
insuredName:
|
|
2149
|
-
premium:
|
|
2150
|
-
premiumAmount:
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2442
|
+
id: import_zod18.z.string(),
|
|
2443
|
+
carrier: import_zod18.z.string(),
|
|
2444
|
+
security: import_zod18.z.string().optional(),
|
|
2445
|
+
insuredName: import_zod18.z.string(),
|
|
2446
|
+
premium: import_zod18.z.string().optional(),
|
|
2447
|
+
premiumAmount: import_zod18.z.number().optional(),
|
|
2448
|
+
premiumBreakdown: import_zod18.z.array(PremiumLineSchema).optional(),
|
|
2449
|
+
summary: import_zod18.z.string().optional(),
|
|
2450
|
+
linesOfBusiness: import_zod18.z.array(import_zod18.z.string()).optional(),
|
|
2451
|
+
coverages: import_zod18.z.array(CoverageSchema),
|
|
2154
2452
|
documentMetadata: DocumentMetadataSchema,
|
|
2155
|
-
documentOutline:
|
|
2156
|
-
sections:
|
|
2157
|
-
definitions:
|
|
2158
|
-
coveredReasons:
|
|
2453
|
+
documentOutline: import_zod18.z.array(DocumentNodeSchema),
|
|
2454
|
+
sections: import_zod18.z.array(SectionSchema).optional(),
|
|
2455
|
+
definitions: import_zod18.z.array(DefinitionSchema).optional(),
|
|
2456
|
+
coveredReasons: import_zod18.z.array(CoveredReasonSchema).optional(),
|
|
2159
2457
|
// Enriched fields (v1.2+)
|
|
2160
|
-
carrierLegalName:
|
|
2161
|
-
carrierNaicNumber:
|
|
2162
|
-
carrierAmBestRating:
|
|
2163
|
-
carrierAdmittedStatus:
|
|
2164
|
-
mga:
|
|
2165
|
-
underwriter:
|
|
2166
|
-
brokerAgency:
|
|
2167
|
-
brokerContactName:
|
|
2168
|
-
brokerLicenseNumber:
|
|
2169
|
-
priorPolicyNumber:
|
|
2170
|
-
programName:
|
|
2171
|
-
isRenewal:
|
|
2172
|
-
isPackage:
|
|
2173
|
-
insuredDba:
|
|
2458
|
+
carrierLegalName: import_zod18.z.string().optional(),
|
|
2459
|
+
carrierNaicNumber: import_zod18.z.string().optional(),
|
|
2460
|
+
carrierAmBestRating: import_zod18.z.string().optional(),
|
|
2461
|
+
carrierAdmittedStatus: import_zod18.z.string().optional(),
|
|
2462
|
+
mga: import_zod18.z.string().optional(),
|
|
2463
|
+
underwriter: import_zod18.z.string().optional(),
|
|
2464
|
+
brokerAgency: import_zod18.z.string().optional(),
|
|
2465
|
+
brokerContactName: import_zod18.z.string().optional(),
|
|
2466
|
+
brokerLicenseNumber: import_zod18.z.string().optional(),
|
|
2467
|
+
priorPolicyNumber: import_zod18.z.string().optional(),
|
|
2468
|
+
programName: import_zod18.z.string().optional(),
|
|
2469
|
+
isRenewal: import_zod18.z.boolean().optional(),
|
|
2470
|
+
isPackage: import_zod18.z.boolean().optional(),
|
|
2471
|
+
insuredDba: import_zod18.z.string().optional(),
|
|
2174
2472
|
insuredAddress: SourceBackedAddressSchema.optional(),
|
|
2175
2473
|
insuredEntityType: EntityTypeSchema.optional(),
|
|
2176
|
-
additionalNamedInsureds:
|
|
2177
|
-
insuredSicCode:
|
|
2178
|
-
insuredNaicsCode:
|
|
2179
|
-
insuredFein:
|
|
2180
|
-
enrichedCoverages:
|
|
2181
|
-
endorsements:
|
|
2182
|
-
exclusions:
|
|
2183
|
-
conditions:
|
|
2474
|
+
additionalNamedInsureds: import_zod18.z.array(NamedInsuredSchema).optional(),
|
|
2475
|
+
insuredSicCode: import_zod18.z.string().optional(),
|
|
2476
|
+
insuredNaicsCode: import_zod18.z.string().optional(),
|
|
2477
|
+
insuredFein: import_zod18.z.string().optional(),
|
|
2478
|
+
enrichedCoverages: import_zod18.z.array(EnrichedCoverageSchema).optional(),
|
|
2479
|
+
endorsements: import_zod18.z.array(EndorsementSchema).optional(),
|
|
2480
|
+
exclusions: import_zod18.z.array(ExclusionSchema).optional(),
|
|
2481
|
+
conditions: import_zod18.z.array(PolicyConditionSchema).optional(),
|
|
2184
2482
|
limits: LimitScheduleSchema.optional(),
|
|
2185
2483
|
deductibles: DeductibleScheduleSchema.optional(),
|
|
2186
|
-
locations:
|
|
2187
|
-
vehicles:
|
|
2188
|
-
classifications:
|
|
2189
|
-
|
|
2484
|
+
locations: import_zod18.z.array(InsuredLocationSchema).optional(),
|
|
2485
|
+
vehicles: import_zod18.z.array(InsuredVehicleSchema).optional(),
|
|
2486
|
+
classifications: import_zod18.z.array(ClassificationCodeSchema).optional(),
|
|
2487
|
+
coverageSchedules: import_zod18.z.array(OperationalCoverageScheduleSchema).optional(),
|
|
2488
|
+
formInventory: import_zod18.z.array(FormReferenceSchema).optional(),
|
|
2190
2489
|
declarations: DeclarationsSchema.optional(),
|
|
2191
2490
|
coverageForm: CoverageFormSchema.optional(),
|
|
2192
|
-
retroactiveDate:
|
|
2491
|
+
retroactiveDate: import_zod18.z.string().optional(),
|
|
2193
2492
|
extendedReportingPeriod: ExtendedReportingPeriodSchema.optional(),
|
|
2194
2493
|
insurer: InsurerInfoSchema.optional(),
|
|
2195
2494
|
producer: ProducerInfoSchema.optional(),
|
|
2196
|
-
claimsContacts:
|
|
2197
|
-
regulatoryContacts:
|
|
2198
|
-
thirdPartyAdministrators:
|
|
2199
|
-
additionalInsureds:
|
|
2200
|
-
lossPayees:
|
|
2201
|
-
mortgageHolders:
|
|
2202
|
-
taxesAndFees:
|
|
2203
|
-
totalCost:
|
|
2204
|
-
totalCostAmount:
|
|
2205
|
-
minimumPremium:
|
|
2206
|
-
minimumPremiumAmount:
|
|
2207
|
-
depositPremium:
|
|
2208
|
-
depositPremiumAmount:
|
|
2495
|
+
claimsContacts: import_zod18.z.array(ContactSchema).optional(),
|
|
2496
|
+
regulatoryContacts: import_zod18.z.array(ContactSchema).optional(),
|
|
2497
|
+
thirdPartyAdministrators: import_zod18.z.array(ContactSchema).optional(),
|
|
2498
|
+
additionalInsureds: import_zod18.z.array(EndorsementPartySchema).optional(),
|
|
2499
|
+
lossPayees: import_zod18.z.array(EndorsementPartySchema).optional(),
|
|
2500
|
+
mortgageHolders: import_zod18.z.array(EndorsementPartySchema).optional(),
|
|
2501
|
+
taxesAndFees: import_zod18.z.array(TaxFeeItemSchema).optional(),
|
|
2502
|
+
totalCost: import_zod18.z.string().optional(),
|
|
2503
|
+
totalCostAmount: import_zod18.z.number().optional(),
|
|
2504
|
+
minimumPremium: import_zod18.z.string().optional(),
|
|
2505
|
+
minimumPremiumAmount: import_zod18.z.number().optional(),
|
|
2506
|
+
depositPremium: import_zod18.z.string().optional(),
|
|
2507
|
+
depositPremiumAmount: import_zod18.z.number().optional(),
|
|
2209
2508
|
paymentPlan: PaymentPlanSchema.optional(),
|
|
2210
2509
|
auditType: AuditTypeSchema.optional(),
|
|
2211
|
-
ratingBasis:
|
|
2212
|
-
premiumByLocation:
|
|
2510
|
+
ratingBasis: import_zod18.z.array(RatingBasisSchema).optional(),
|
|
2511
|
+
premiumByLocation: import_zod18.z.array(LocationPremiumSchema).optional(),
|
|
2213
2512
|
lossSummary: LossSummarySchema.optional(),
|
|
2214
|
-
individualClaims:
|
|
2513
|
+
individualClaims: import_zod18.z.array(ClaimRecordSchema).optional(),
|
|
2215
2514
|
experienceMod: ExperienceModSchema.optional(),
|
|
2216
|
-
cancellationNoticeDays:
|
|
2217
|
-
nonrenewalNoticeDays:
|
|
2218
|
-
supplementaryFacts:
|
|
2515
|
+
cancellationNoticeDays: import_zod18.z.number().optional(),
|
|
2516
|
+
nonrenewalNoticeDays: import_zod18.z.number().optional(),
|
|
2517
|
+
supplementaryFacts: import_zod18.z.array(AuxiliaryFactSchema).optional()
|
|
2219
2518
|
};
|
|
2220
|
-
var PolicyDocumentSchema =
|
|
2519
|
+
var PolicyDocumentSchema = import_zod18.z.object({
|
|
2221
2520
|
...BaseDocumentFields,
|
|
2222
|
-
type:
|
|
2223
|
-
policyNumber:
|
|
2224
|
-
effectiveDate:
|
|
2225
|
-
expirationDate:
|
|
2521
|
+
type: import_zod18.z.literal("policy"),
|
|
2522
|
+
policyNumber: import_zod18.z.string(),
|
|
2523
|
+
effectiveDate: import_zod18.z.string(),
|
|
2524
|
+
expirationDate: import_zod18.z.string().optional(),
|
|
2226
2525
|
policyTermType: PolicyTermTypeSchema.optional(),
|
|
2227
|
-
nextReviewDate:
|
|
2228
|
-
effectiveTime:
|
|
2526
|
+
nextReviewDate: import_zod18.z.string().optional(),
|
|
2527
|
+
effectiveTime: import_zod18.z.string().optional()
|
|
2229
2528
|
});
|
|
2230
|
-
var QuoteDocumentSchema =
|
|
2529
|
+
var QuoteDocumentSchema = import_zod18.z.object({
|
|
2231
2530
|
...BaseDocumentFields,
|
|
2232
|
-
type:
|
|
2233
|
-
quoteNumber:
|
|
2234
|
-
proposedEffectiveDate:
|
|
2235
|
-
proposedExpirationDate:
|
|
2236
|
-
quoteExpirationDate:
|
|
2237
|
-
subjectivities:
|
|
2238
|
-
underwritingConditions:
|
|
2239
|
-
premiumBreakdown: import_zod17.z.array(PremiumLineSchema).optional(),
|
|
2531
|
+
type: import_zod18.z.literal("quote"),
|
|
2532
|
+
quoteNumber: import_zod18.z.string(),
|
|
2533
|
+
proposedEffectiveDate: import_zod18.z.string().optional(),
|
|
2534
|
+
proposedExpirationDate: import_zod18.z.string().optional(),
|
|
2535
|
+
quoteExpirationDate: import_zod18.z.string().optional(),
|
|
2536
|
+
subjectivities: import_zod18.z.array(SubjectivitySchema).optional(),
|
|
2537
|
+
underwritingConditions: import_zod18.z.array(UnderwritingConditionSchema).optional(),
|
|
2240
2538
|
// Enriched quote fields (v1.2+)
|
|
2241
|
-
enrichedSubjectivities:
|
|
2242
|
-
enrichedUnderwritingConditions:
|
|
2243
|
-
warrantyRequirements:
|
|
2244
|
-
lossControlRecommendations:
|
|
2539
|
+
enrichedSubjectivities: import_zod18.z.array(EnrichedSubjectivitySchema).optional(),
|
|
2540
|
+
enrichedUnderwritingConditions: import_zod18.z.array(EnrichedUnderwritingConditionSchema).optional(),
|
|
2541
|
+
warrantyRequirements: import_zod18.z.array(import_zod18.z.string()).optional(),
|
|
2542
|
+
lossControlRecommendations: import_zod18.z.array(import_zod18.z.string()).optional(),
|
|
2245
2543
|
bindingAuthority: BindingAuthoritySchema.optional()
|
|
2246
2544
|
});
|
|
2247
|
-
var InsuranceDocumentSchema =
|
|
2545
|
+
var InsuranceDocumentSchema = import_zod18.z.discriminatedUnion("type", [
|
|
2248
2546
|
PolicyDocumentSchema,
|
|
2249
2547
|
QuoteDocumentSchema
|
|
2250
2548
|
]);
|
|
2251
2549
|
|
|
2252
2550
|
// src/schemas/platform.ts
|
|
2253
|
-
var
|
|
2254
|
-
var PlatformSchema =
|
|
2255
|
-
var CommunicationIntentSchema =
|
|
2551
|
+
var import_zod19 = require("zod");
|
|
2552
|
+
var PlatformSchema = import_zod19.z.enum(["email", "chat", "sms", "slack", "discord"]);
|
|
2553
|
+
var CommunicationIntentSchema = import_zod19.z.enum(["direct", "mediated", "observed"]);
|
|
2256
2554
|
var PLATFORM_CONFIGS = {
|
|
2257
2555
|
email: {
|
|
2258
2556
|
supportsMarkdown: false,
|
|
@@ -2285,65 +2583,65 @@ var PLATFORM_CONFIGS = {
|
|
|
2285
2583
|
};
|
|
2286
2584
|
|
|
2287
2585
|
// src/schemas/pce.ts
|
|
2288
|
-
var
|
|
2586
|
+
var import_zod21 = require("zod");
|
|
2289
2587
|
|
|
2290
2588
|
// src/case/index.ts
|
|
2291
|
-
var
|
|
2292
|
-
var CaseEvidenceSourceSchema =
|
|
2293
|
-
id:
|
|
2294
|
-
label:
|
|
2295
|
-
documentId:
|
|
2296
|
-
page:
|
|
2297
|
-
fieldPath:
|
|
2298
|
-
text:
|
|
2299
|
-
metadata:
|
|
2300
|
-
});
|
|
2301
|
-
var CaseCitationSchema =
|
|
2302
|
-
sourceId:
|
|
2303
|
-
quote:
|
|
2304
|
-
page:
|
|
2305
|
-
fieldPath:
|
|
2306
|
-
});
|
|
2307
|
-
var ValidationIssueSeveritySchema =
|
|
2308
|
-
var CaseValidationIssueSchema =
|
|
2309
|
-
code:
|
|
2589
|
+
var import_zod20 = require("zod");
|
|
2590
|
+
var CaseEvidenceSourceSchema = import_zod20.z.object({
|
|
2591
|
+
id: import_zod20.z.string(),
|
|
2592
|
+
label: import_zod20.z.string().optional(),
|
|
2593
|
+
documentId: import_zod20.z.string().optional(),
|
|
2594
|
+
page: import_zod20.z.number().optional(),
|
|
2595
|
+
fieldPath: import_zod20.z.string().optional(),
|
|
2596
|
+
text: import_zod20.z.string().describe("Source text available for span validation and citation"),
|
|
2597
|
+
metadata: import_zod20.z.record(import_zod20.z.string(), import_zod20.z.string()).optional()
|
|
2598
|
+
});
|
|
2599
|
+
var CaseCitationSchema = import_zod20.z.object({
|
|
2600
|
+
sourceId: import_zod20.z.string(),
|
|
2601
|
+
quote: import_zod20.z.string(),
|
|
2602
|
+
page: import_zod20.z.number().optional(),
|
|
2603
|
+
fieldPath: import_zod20.z.string().optional()
|
|
2604
|
+
});
|
|
2605
|
+
var ValidationIssueSeveritySchema = import_zod20.z.enum(["info", "warning", "blocking"]);
|
|
2606
|
+
var CaseValidationIssueSchema = import_zod20.z.object({
|
|
2607
|
+
code: import_zod20.z.string(),
|
|
2310
2608
|
severity: ValidationIssueSeveritySchema,
|
|
2311
|
-
message:
|
|
2312
|
-
itemId:
|
|
2313
|
-
fieldPath:
|
|
2314
|
-
sourceId:
|
|
2315
|
-
});
|
|
2316
|
-
var MissingInfoQuestionSchema =
|
|
2317
|
-
id:
|
|
2318
|
-
itemId:
|
|
2319
|
-
fieldPath:
|
|
2320
|
-
question:
|
|
2321
|
-
reason:
|
|
2322
|
-
answer:
|
|
2323
|
-
});
|
|
2324
|
-
var CasePacketArtifactKindSchema =
|
|
2609
|
+
message: import_zod20.z.string(),
|
|
2610
|
+
itemId: import_zod20.z.string().optional(),
|
|
2611
|
+
fieldPath: import_zod20.z.string().optional(),
|
|
2612
|
+
sourceId: import_zod20.z.string().optional()
|
|
2613
|
+
});
|
|
2614
|
+
var MissingInfoQuestionSchema = import_zod20.z.object({
|
|
2615
|
+
id: import_zod20.z.string(),
|
|
2616
|
+
itemId: import_zod20.z.string().optional(),
|
|
2617
|
+
fieldPath: import_zod20.z.string().optional(),
|
|
2618
|
+
question: import_zod20.z.string(),
|
|
2619
|
+
reason: import_zod20.z.string(),
|
|
2620
|
+
answer: import_zod20.z.string().optional()
|
|
2621
|
+
});
|
|
2622
|
+
var CasePacketArtifactKindSchema = import_zod20.z.enum([
|
|
2325
2623
|
"underwriter_summary",
|
|
2326
2624
|
"carrier_email",
|
|
2327
2625
|
"missing_info_request",
|
|
2328
2626
|
"json_packet",
|
|
2329
2627
|
"validation_report"
|
|
2330
2628
|
]);
|
|
2331
|
-
var CasePacketArtifactSchema =
|
|
2332
|
-
id:
|
|
2629
|
+
var CasePacketArtifactSchema = import_zod20.z.object({
|
|
2630
|
+
id: import_zod20.z.string(),
|
|
2333
2631
|
kind: CasePacketArtifactKindSchema,
|
|
2334
|
-
title:
|
|
2335
|
-
content:
|
|
2336
|
-
citations:
|
|
2337
|
-
});
|
|
2338
|
-
var CaseSubmissionPacketSchema =
|
|
2339
|
-
id:
|
|
2340
|
-
caseId:
|
|
2341
|
-
artifacts:
|
|
2342
|
-
validationIssues:
|
|
2343
|
-
missingInfoQuestions:
|
|
2344
|
-
createdAt:
|
|
2345
|
-
});
|
|
2346
|
-
var CaseActionSchema =
|
|
2632
|
+
title: import_zod20.z.string(),
|
|
2633
|
+
content: import_zod20.z.string(),
|
|
2634
|
+
citations: import_zod20.z.array(CaseCitationSchema).default([])
|
|
2635
|
+
});
|
|
2636
|
+
var CaseSubmissionPacketSchema = import_zod20.z.object({
|
|
2637
|
+
id: import_zod20.z.string(),
|
|
2638
|
+
caseId: import_zod20.z.string(),
|
|
2639
|
+
artifacts: import_zod20.z.array(CasePacketArtifactSchema),
|
|
2640
|
+
validationIssues: import_zod20.z.array(CaseValidationIssueSchema),
|
|
2641
|
+
missingInfoQuestions: import_zod20.z.array(MissingInfoQuestionSchema),
|
|
2642
|
+
createdAt: import_zod20.z.number()
|
|
2643
|
+
});
|
|
2644
|
+
var CaseActionSchema = import_zod20.z.enum([
|
|
2347
2645
|
"inspect_attachments",
|
|
2348
2646
|
"retrieve_policy_evidence",
|
|
2349
2647
|
"retrieve_prior_applications",
|
|
@@ -2356,23 +2654,23 @@ var CaseActionSchema = import_zod19.z.enum([
|
|
|
2356
2654
|
"generate_packet",
|
|
2357
2655
|
"answer_field_or_case_question"
|
|
2358
2656
|
]);
|
|
2359
|
-
var AgenticExecutionModeSchema =
|
|
2360
|
-
var CaseProposalScoreSchema =
|
|
2361
|
-
grounding:
|
|
2362
|
-
completeness:
|
|
2363
|
-
consistency:
|
|
2364
|
-
determinism:
|
|
2365
|
-
risk:
|
|
2366
|
-
cost:
|
|
2367
|
-
});
|
|
2368
|
-
var CaseProposalSchema =
|
|
2369
|
-
id:
|
|
2370
|
-
sourceSpanIds:
|
|
2371
|
-
confidence:
|
|
2372
|
-
missingInfo:
|
|
2373
|
-
validationIssues:
|
|
2374
|
-
estimatedRisk:
|
|
2375
|
-
estimatedCost:
|
|
2657
|
+
var AgenticExecutionModeSchema = import_zod20.z.enum(["deterministic_tree", "market_eval", "hybrid"]);
|
|
2658
|
+
var CaseProposalScoreSchema = import_zod20.z.object({
|
|
2659
|
+
grounding: import_zod20.z.number().min(0).max(1),
|
|
2660
|
+
completeness: import_zod20.z.number().min(0).max(1),
|
|
2661
|
+
consistency: import_zod20.z.number().min(0).max(1),
|
|
2662
|
+
determinism: import_zod20.z.number().min(0).max(1),
|
|
2663
|
+
risk: import_zod20.z.number().min(0).max(1),
|
|
2664
|
+
cost: import_zod20.z.number().min(0).max(1)
|
|
2665
|
+
});
|
|
2666
|
+
var CaseProposalSchema = import_zod20.z.object({
|
|
2667
|
+
id: import_zod20.z.string(),
|
|
2668
|
+
sourceSpanIds: import_zod20.z.array(import_zod20.z.string()).default([]),
|
|
2669
|
+
confidence: import_zod20.z.number().min(0).max(1),
|
|
2670
|
+
missingInfo: import_zod20.z.array(import_zod20.z.string()).default([]),
|
|
2671
|
+
validationIssues: import_zod20.z.array(CaseValidationIssueSchema).default([]),
|
|
2672
|
+
estimatedRisk: import_zod20.z.number().min(0).max(1).default(0.5),
|
|
2673
|
+
estimatedCost: import_zod20.z.number().min(0).max(1).default(0.5),
|
|
2376
2674
|
score: CaseProposalScoreSchema.optional()
|
|
2377
2675
|
});
|
|
2378
2676
|
function stableCaseId(prefix, parts) {
|
|
@@ -2491,8 +2789,8 @@ function totalProposalScore(score) {
|
|
|
2491
2789
|
}
|
|
2492
2790
|
|
|
2493
2791
|
// src/schemas/pce.ts
|
|
2494
|
-
var PolicyChangeActionSchema =
|
|
2495
|
-
var PolicyChangeKindSchema =
|
|
2792
|
+
var PolicyChangeActionSchema = import_zod21.z.enum(["add", "remove", "update", "replace", "clarify"]);
|
|
2793
|
+
var PolicyChangeKindSchema = import_zod21.z.enum([
|
|
2496
2794
|
"named_insured_change",
|
|
2497
2795
|
"additional_insured_change",
|
|
2498
2796
|
"coverage_change",
|
|
@@ -2506,70 +2804,70 @@ var PolicyChangeKindSchema = import_zod20.z.enum([
|
|
|
2506
2804
|
"renewal_submission_update",
|
|
2507
2805
|
"general_endorsement"
|
|
2508
2806
|
]);
|
|
2509
|
-
var PolicyChangeConfidenceSchema =
|
|
2510
|
-
var PolicyChangeStatusSchema =
|
|
2511
|
-
var PolicyChangeItemSchema =
|
|
2512
|
-
id:
|
|
2807
|
+
var PolicyChangeConfidenceSchema = import_zod21.z.enum(["high", "medium", "low"]);
|
|
2808
|
+
var PolicyChangeStatusSchema = import_zod21.z.enum(["draft", "needs_info", "ready", "blocked"]);
|
|
2809
|
+
var PolicyChangeItemSchema = import_zod21.z.object({
|
|
2810
|
+
id: import_zod21.z.string(),
|
|
2513
2811
|
kind: PolicyChangeKindSchema.default("general_endorsement"),
|
|
2514
2812
|
action: PolicyChangeActionSchema,
|
|
2515
|
-
affectedPolicyId:
|
|
2516
|
-
fieldPath:
|
|
2517
|
-
label:
|
|
2518
|
-
beforeValue:
|
|
2519
|
-
afterValue:
|
|
2520
|
-
requestedValue:
|
|
2521
|
-
effectiveDate:
|
|
2522
|
-
reason:
|
|
2523
|
-
sourceIds:
|
|
2524
|
-
sourceSpanIds:
|
|
2525
|
-
userSourceSpanIds:
|
|
2526
|
-
citations:
|
|
2813
|
+
affectedPolicyId: import_zod21.z.string().default("unknown"),
|
|
2814
|
+
fieldPath: import_zod21.z.string().describe("Stable policy field path or business field name"),
|
|
2815
|
+
label: import_zod21.z.string(),
|
|
2816
|
+
beforeValue: import_zod21.z.string().optional().describe("Existing policy value, when cited from policy evidence"),
|
|
2817
|
+
afterValue: import_zod21.z.string().optional().describe("Requested new value"),
|
|
2818
|
+
requestedValue: import_zod21.z.string().optional().describe("Alias for afterValue used by policy-change workflows"),
|
|
2819
|
+
effectiveDate: import_zod21.z.string().optional(),
|
|
2820
|
+
reason: import_zod21.z.string().optional(),
|
|
2821
|
+
sourceIds: import_zod21.z.array(import_zod21.z.string()).default([]),
|
|
2822
|
+
sourceSpanIds: import_zod21.z.array(import_zod21.z.string()).default([]),
|
|
2823
|
+
userSourceSpanIds: import_zod21.z.array(import_zod21.z.string()).optional(),
|
|
2824
|
+
citations: import_zod21.z.array(CaseCitationSchema).default([]),
|
|
2527
2825
|
confidence: PolicyChangeConfidenceSchema.default("medium"),
|
|
2528
|
-
confidenceScore:
|
|
2826
|
+
confidenceScore: import_zod21.z.number().min(0).max(1).optional(),
|
|
2529
2827
|
status: PolicyChangeStatusSchema.default("ready")
|
|
2530
2828
|
});
|
|
2531
|
-
var PceNormalizationResultSchema =
|
|
2532
|
-
summary:
|
|
2533
|
-
items:
|
|
2534
|
-
id:
|
|
2829
|
+
var PceNormalizationResultSchema = import_zod21.z.object({
|
|
2830
|
+
summary: import_zod21.z.string(),
|
|
2831
|
+
items: import_zod21.z.array(PolicyChangeItemSchema.omit({ id: true, status: true }).extend({
|
|
2832
|
+
id: import_zod21.z.string().optional(),
|
|
2535
2833
|
status: PolicyChangeStatusSchema.optional()
|
|
2536
2834
|
})),
|
|
2537
|
-
missingInfoQuestions:
|
|
2538
|
-
id:
|
|
2835
|
+
missingInfoQuestions: import_zod21.z.array(MissingInfoQuestionSchema.omit({ id: true }).extend({
|
|
2836
|
+
id: import_zod21.z.string().optional()
|
|
2539
2837
|
})).default([])
|
|
2540
2838
|
});
|
|
2541
|
-
var PolicyChangeImpactSchema =
|
|
2542
|
-
itemId:
|
|
2543
|
-
beforeValue:
|
|
2544
|
-
requestedValue:
|
|
2545
|
-
likelyEndorsementRequired:
|
|
2546
|
-
carrierApprovalLikelyRequired:
|
|
2547
|
-
affectedCoverageForms:
|
|
2548
|
-
sourceSpanIds:
|
|
2549
|
-
});
|
|
2550
|
-
var PceCaseStateSchema =
|
|
2551
|
-
id:
|
|
2552
|
-
requestText:
|
|
2553
|
-
summary:
|
|
2839
|
+
var PolicyChangeImpactSchema = import_zod21.z.object({
|
|
2840
|
+
itemId: import_zod21.z.string(),
|
|
2841
|
+
beforeValue: import_zod21.z.string().optional(),
|
|
2842
|
+
requestedValue: import_zod21.z.string().optional(),
|
|
2843
|
+
likelyEndorsementRequired: import_zod21.z.boolean().default(true),
|
|
2844
|
+
carrierApprovalLikelyRequired: import_zod21.z.boolean().default(true),
|
|
2845
|
+
affectedCoverageForms: import_zod21.z.array(import_zod21.z.string()).default([]),
|
|
2846
|
+
sourceSpanIds: import_zod21.z.array(import_zod21.z.string()).default([])
|
|
2847
|
+
});
|
|
2848
|
+
var PceCaseStateSchema = import_zod21.z.object({
|
|
2849
|
+
id: import_zod21.z.string(),
|
|
2850
|
+
requestText: import_zod21.z.string(),
|
|
2851
|
+
summary: import_zod21.z.string(),
|
|
2554
2852
|
executionMode: AgenticExecutionModeSchema.default("deterministic_tree"),
|
|
2555
|
-
items:
|
|
2556
|
-
impacts:
|
|
2557
|
-
evidenceSources:
|
|
2558
|
-
validationIssues:
|
|
2559
|
-
missingInfoQuestions:
|
|
2560
|
-
createdAt:
|
|
2561
|
-
updatedAt:
|
|
2562
|
-
});
|
|
2563
|
-
var PolicyChangeRequestSchema =
|
|
2564
|
-
id:
|
|
2565
|
-
text:
|
|
2853
|
+
items: import_zod21.z.array(PolicyChangeItemSchema),
|
|
2854
|
+
impacts: import_zod21.z.array(PolicyChangeImpactSchema),
|
|
2855
|
+
evidenceSources: import_zod21.z.array(CaseEvidenceSourceSchema),
|
|
2856
|
+
validationIssues: import_zod21.z.array(CaseValidationIssueSchema),
|
|
2857
|
+
missingInfoQuestions: import_zod21.z.array(MissingInfoQuestionSchema),
|
|
2858
|
+
createdAt: import_zod21.z.number(),
|
|
2859
|
+
updatedAt: import_zod21.z.number()
|
|
2860
|
+
});
|
|
2861
|
+
var PolicyChangeRequestSchema = import_zod21.z.object({
|
|
2862
|
+
id: import_zod21.z.string(),
|
|
2863
|
+
text: import_zod21.z.string(),
|
|
2566
2864
|
executionMode: AgenticExecutionModeSchema.optional(),
|
|
2567
|
-
userSourceSpanIds:
|
|
2568
|
-
createdAt:
|
|
2865
|
+
userSourceSpanIds: import_zod21.z.array(import_zod21.z.string()).optional(),
|
|
2866
|
+
createdAt: import_zod21.z.number().optional()
|
|
2569
2867
|
});
|
|
2570
2868
|
var PceSubmissionPacketSchema = CaseSubmissionPacketSchema.extend({
|
|
2571
2869
|
pceCase: PceCaseStateSchema,
|
|
2572
|
-
artifacts:
|
|
2870
|
+
artifacts: import_zod21.z.array(CasePacketArtifactSchema)
|
|
2573
2871
|
});
|
|
2574
2872
|
|
|
2575
2873
|
// src/schemas/context-keys.ts
|
|
@@ -2624,252 +2922,6 @@ var CONTEXT_KEY_MAP = [
|
|
|
2624
2922
|
{ extractedField: "declarations.breed", category: "pet_info", contextKey: "pet_breed", description: "Pet breed" }
|
|
2625
2923
|
];
|
|
2626
2924
|
|
|
2627
|
-
// src/source/schemas.ts
|
|
2628
|
-
var import_zod21 = require("zod");
|
|
2629
|
-
var SourceSpanKindSchema = import_zod21.z.enum([
|
|
2630
|
-
"pdf_text",
|
|
2631
|
-
"pdf_image",
|
|
2632
|
-
"html",
|
|
2633
|
-
"markdown",
|
|
2634
|
-
"plain_text",
|
|
2635
|
-
"structured_field"
|
|
2636
|
-
]);
|
|
2637
|
-
var SourceSpanUnitSchema = import_zod21.z.enum([
|
|
2638
|
-
"page",
|
|
2639
|
-
"section",
|
|
2640
|
-
"table",
|
|
2641
|
-
"table_row",
|
|
2642
|
-
"table_cell",
|
|
2643
|
-
"key_value",
|
|
2644
|
-
"text"
|
|
2645
|
-
]);
|
|
2646
|
-
var SourceKindSchema = import_zod21.z.enum([
|
|
2647
|
-
"policy_pdf",
|
|
2648
|
-
"application_pdf",
|
|
2649
|
-
"email",
|
|
2650
|
-
"attachment",
|
|
2651
|
-
"manual_note"
|
|
2652
|
-
]);
|
|
2653
|
-
var SourceSpanBBoxSchema = import_zod21.z.object({
|
|
2654
|
-
page: import_zod21.z.number().int().positive(),
|
|
2655
|
-
x: import_zod21.z.number(),
|
|
2656
|
-
y: import_zod21.z.number(),
|
|
2657
|
-
width: import_zod21.z.number(),
|
|
2658
|
-
height: import_zod21.z.number()
|
|
2659
|
-
});
|
|
2660
|
-
var SourceSpanLocationSchema = import_zod21.z.object({
|
|
2661
|
-
page: import_zod21.z.number().int().positive().optional(),
|
|
2662
|
-
startPage: import_zod21.z.number().int().positive().optional(),
|
|
2663
|
-
endPage: import_zod21.z.number().int().positive().optional(),
|
|
2664
|
-
charStart: import_zod21.z.number().int().nonnegative().optional(),
|
|
2665
|
-
charEnd: import_zod21.z.number().int().nonnegative().optional(),
|
|
2666
|
-
lineStart: import_zod21.z.number().int().positive().optional(),
|
|
2667
|
-
lineEnd: import_zod21.z.number().int().positive().optional(),
|
|
2668
|
-
fieldPath: import_zod21.z.string().optional()
|
|
2669
|
-
});
|
|
2670
|
-
var SourceSpanTableLocationSchema = import_zod21.z.object({
|
|
2671
|
-
tableId: import_zod21.z.string().optional(),
|
|
2672
|
-
rowIndex: import_zod21.z.number().int().nonnegative().optional(),
|
|
2673
|
-
columnIndex: import_zod21.z.number().int().nonnegative().optional(),
|
|
2674
|
-
columnName: import_zod21.z.string().optional(),
|
|
2675
|
-
rowSpanId: import_zod21.z.string().optional(),
|
|
2676
|
-
tableSpanId: import_zod21.z.string().optional(),
|
|
2677
|
-
isHeader: import_zod21.z.boolean().optional()
|
|
2678
|
-
});
|
|
2679
|
-
var SourceSpanSchema = import_zod21.z.object({
|
|
2680
|
-
id: import_zod21.z.string().min(1),
|
|
2681
|
-
documentId: import_zod21.z.string().min(1),
|
|
2682
|
-
sourceKind: SourceKindSchema.optional(),
|
|
2683
|
-
chunkId: import_zod21.z.string().optional(),
|
|
2684
|
-
kind: SourceSpanKindSchema,
|
|
2685
|
-
text: import_zod21.z.string(),
|
|
2686
|
-
hash: import_zod21.z.string().min(1),
|
|
2687
|
-
textHash: import_zod21.z.string().optional(),
|
|
2688
|
-
pageStart: import_zod21.z.number().int().positive().optional(),
|
|
2689
|
-
pageEnd: import_zod21.z.number().int().positive().optional(),
|
|
2690
|
-
sectionId: import_zod21.z.string().optional(),
|
|
2691
|
-
formNumber: import_zod21.z.string().optional(),
|
|
2692
|
-
sourceUnit: SourceSpanUnitSchema.optional(),
|
|
2693
|
-
parentSpanId: import_zod21.z.string().optional(),
|
|
2694
|
-
table: SourceSpanTableLocationSchema.optional(),
|
|
2695
|
-
bbox: import_zod21.z.array(SourceSpanBBoxSchema).optional(),
|
|
2696
|
-
location: SourceSpanLocationSchema.optional(),
|
|
2697
|
-
metadata: import_zod21.z.record(import_zod21.z.string(), import_zod21.z.string()).optional()
|
|
2698
|
-
});
|
|
2699
|
-
var SourceSpanRefSchema = import_zod21.z.object({
|
|
2700
|
-
sourceSpanId: import_zod21.z.string().min(1),
|
|
2701
|
-
documentId: import_zod21.z.string().min(1).optional(),
|
|
2702
|
-
chunkId: import_zod21.z.string().optional(),
|
|
2703
|
-
quote: import_zod21.z.string().optional(),
|
|
2704
|
-
hash: import_zod21.z.string().optional(),
|
|
2705
|
-
location: SourceSpanLocationSchema.optional()
|
|
2706
|
-
});
|
|
2707
|
-
var SourceChunkSchema = import_zod21.z.object({
|
|
2708
|
-
id: import_zod21.z.string().min(1),
|
|
2709
|
-
documentId: import_zod21.z.string().min(1),
|
|
2710
|
-
sourceSpanIds: import_zod21.z.array(import_zod21.z.string().min(1)),
|
|
2711
|
-
text: import_zod21.z.string(),
|
|
2712
|
-
textHash: import_zod21.z.string().min(1),
|
|
2713
|
-
pageStart: import_zod21.z.number().int().positive().optional(),
|
|
2714
|
-
pageEnd: import_zod21.z.number().int().positive().optional(),
|
|
2715
|
-
metadata: import_zod21.z.record(import_zod21.z.string(), import_zod21.z.string()).default({})
|
|
2716
|
-
});
|
|
2717
|
-
var DocumentSourceNodeKindSchema = import_zod21.z.enum([
|
|
2718
|
-
"document",
|
|
2719
|
-
"page_group",
|
|
2720
|
-
"page",
|
|
2721
|
-
"form",
|
|
2722
|
-
"endorsement",
|
|
2723
|
-
"section",
|
|
2724
|
-
"schedule",
|
|
2725
|
-
"clause",
|
|
2726
|
-
"table",
|
|
2727
|
-
"table_row",
|
|
2728
|
-
"table_cell",
|
|
2729
|
-
"text"
|
|
2730
|
-
]);
|
|
2731
|
-
var DocumentSourceNodeSchema = import_zod21.z.object({
|
|
2732
|
-
id: import_zod21.z.string().min(1),
|
|
2733
|
-
documentId: import_zod21.z.string().min(1),
|
|
2734
|
-
parentId: import_zod21.z.string().optional(),
|
|
2735
|
-
kind: DocumentSourceNodeKindSchema,
|
|
2736
|
-
title: import_zod21.z.string(),
|
|
2737
|
-
description: import_zod21.z.string(),
|
|
2738
|
-
textExcerpt: import_zod21.z.string().optional(),
|
|
2739
|
-
sourceSpanIds: import_zod21.z.array(import_zod21.z.string().min(1)),
|
|
2740
|
-
pageStart: import_zod21.z.number().int().positive().optional(),
|
|
2741
|
-
pageEnd: import_zod21.z.number().int().positive().optional(),
|
|
2742
|
-
bbox: import_zod21.z.array(SourceSpanBBoxSchema).optional(),
|
|
2743
|
-
order: import_zod21.z.number().int().nonnegative(),
|
|
2744
|
-
path: import_zod21.z.string(),
|
|
2745
|
-
metadata: import_zod21.z.record(import_zod21.z.string(), import_zod21.z.unknown()).optional()
|
|
2746
|
-
});
|
|
2747
|
-
var SourceBackedValueSchema = import_zod21.z.object({
|
|
2748
|
-
value: import_zod21.z.string(),
|
|
2749
|
-
normalizedValue: import_zod21.z.string().optional(),
|
|
2750
|
-
confidence: import_zod21.z.enum(["low", "medium", "high"]).default("medium"),
|
|
2751
|
-
sourceNodeIds: import_zod21.z.array(import_zod21.z.string().min(1)).default([]),
|
|
2752
|
-
sourceSpanIds: import_zod21.z.array(import_zod21.z.string().min(1)).default([])
|
|
2753
|
-
});
|
|
2754
|
-
var OperationalAddressSchema = import_zod21.z.object({
|
|
2755
|
-
street1: import_zod21.z.string().optional(),
|
|
2756
|
-
street2: import_zod21.z.string().optional(),
|
|
2757
|
-
city: import_zod21.z.string().optional(),
|
|
2758
|
-
state: import_zod21.z.string().optional(),
|
|
2759
|
-
zip: import_zod21.z.string().optional(),
|
|
2760
|
-
country: import_zod21.z.string().optional(),
|
|
2761
|
-
formatted: import_zod21.z.string().optional()
|
|
2762
|
-
});
|
|
2763
|
-
var OperationalDeclarationFactSchema = import_zod21.z.object({
|
|
2764
|
-
field: import_zod21.z.enum([
|
|
2765
|
-
"namedInsured",
|
|
2766
|
-
"mailingAddress",
|
|
2767
|
-
"dba",
|
|
2768
|
-
"entityType",
|
|
2769
|
-
"taxId",
|
|
2770
|
-
"additionalNamedInsured",
|
|
2771
|
-
"policyNumber",
|
|
2772
|
-
"insurer",
|
|
2773
|
-
"broker",
|
|
2774
|
-
"effectiveDate",
|
|
2775
|
-
"expirationDate",
|
|
2776
|
-
"premium",
|
|
2777
|
-
"other"
|
|
2778
|
-
]),
|
|
2779
|
-
label: import_zod21.z.string().optional(),
|
|
2780
|
-
value: import_zod21.z.string(),
|
|
2781
|
-
normalizedValue: import_zod21.z.string().optional(),
|
|
2782
|
-
valueKind: import_zod21.z.enum(["string", "number", "date", "money", "address", "list", "unknown"]).default("string"),
|
|
2783
|
-
address: OperationalAddressSchema.optional(),
|
|
2784
|
-
confidence: import_zod21.z.enum(["low", "medium", "high"]).default("medium"),
|
|
2785
|
-
sourceNodeIds: import_zod21.z.array(import_zod21.z.string().min(1)).default([]),
|
|
2786
|
-
sourceSpanIds: import_zod21.z.array(import_zod21.z.string().min(1)).default([])
|
|
2787
|
-
});
|
|
2788
|
-
var OperationalCoverageTermSchema = import_zod21.z.object({
|
|
2789
|
-
kind: import_zod21.z.enum([
|
|
2790
|
-
"each_claim_limit",
|
|
2791
|
-
"each_occurrence_limit",
|
|
2792
|
-
"each_loss_limit",
|
|
2793
|
-
"aggregate_limit",
|
|
2794
|
-
"sublimit",
|
|
2795
|
-
"retention",
|
|
2796
|
-
"deductible",
|
|
2797
|
-
"retroactive_date",
|
|
2798
|
-
"premium",
|
|
2799
|
-
"other"
|
|
2800
|
-
]).default("other"),
|
|
2801
|
-
label: import_zod21.z.string(),
|
|
2802
|
-
value: import_zod21.z.string(),
|
|
2803
|
-
amount: import_zod21.z.number().optional(),
|
|
2804
|
-
appliesTo: import_zod21.z.string().optional(),
|
|
2805
|
-
sourceNodeIds: import_zod21.z.array(import_zod21.z.string().min(1)).default([]),
|
|
2806
|
-
sourceSpanIds: import_zod21.z.array(import_zod21.z.string().min(1)).default([])
|
|
2807
|
-
});
|
|
2808
|
-
var OperationalCoverageLineSchema = import_zod21.z.object({
|
|
2809
|
-
name: import_zod21.z.string(),
|
|
2810
|
-
lineOfBusiness: AcordLobCodeSchema.optional(),
|
|
2811
|
-
coverageCode: import_zod21.z.string().optional(),
|
|
2812
|
-
limit: import_zod21.z.string().optional(),
|
|
2813
|
-
deductible: import_zod21.z.string().optional(),
|
|
2814
|
-
premium: import_zod21.z.string().optional(),
|
|
2815
|
-
retroactiveDate: import_zod21.z.string().optional(),
|
|
2816
|
-
formNumber: import_zod21.z.string().optional(),
|
|
2817
|
-
sectionRef: import_zod21.z.string().optional(),
|
|
2818
|
-
endorsementNumber: import_zod21.z.string().optional(),
|
|
2819
|
-
limits: import_zod21.z.array(OperationalCoverageTermSchema).default([]),
|
|
2820
|
-
sourceNodeIds: import_zod21.z.array(import_zod21.z.string().min(1)).default([]),
|
|
2821
|
-
sourceSpanIds: import_zod21.z.array(import_zod21.z.string().min(1)).default([])
|
|
2822
|
-
});
|
|
2823
|
-
var OperationalPartySchema = import_zod21.z.object({
|
|
2824
|
-
role: import_zod21.z.string(),
|
|
2825
|
-
name: import_zod21.z.string(),
|
|
2826
|
-
sourceNodeIds: import_zod21.z.array(import_zod21.z.string().min(1)).default([]),
|
|
2827
|
-
sourceSpanIds: import_zod21.z.array(import_zod21.z.string().min(1)).default([])
|
|
2828
|
-
});
|
|
2829
|
-
var OperationalEndorsementSupportSchema = import_zod21.z.object({
|
|
2830
|
-
kind: import_zod21.z.string(),
|
|
2831
|
-
status: import_zod21.z.enum(["supported", "excluded", "requires_review"]),
|
|
2832
|
-
summary: import_zod21.z.string(),
|
|
2833
|
-
sourceNodeIds: import_zod21.z.array(import_zod21.z.string().min(1)).default([]),
|
|
2834
|
-
sourceSpanIds: import_zod21.z.array(import_zod21.z.string().min(1)).default([])
|
|
2835
|
-
});
|
|
2836
|
-
function legacyOperationalProfileInput(value) {
|
|
2837
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) return value;
|
|
2838
|
-
const record = value;
|
|
2839
|
-
if ("linesOfBusiness" in record) return value;
|
|
2840
|
-
if (!("policyTypes" in record)) return value;
|
|
2841
|
-
return {
|
|
2842
|
-
...record,
|
|
2843
|
-
linesOfBusiness: record.policyTypes
|
|
2844
|
-
};
|
|
2845
|
-
}
|
|
2846
|
-
var OperationalLinesOfBusinessSchema = import_zod21.z.preprocess(
|
|
2847
|
-
(value) => Array.isArray(value) ? toLobCodes(value.filter((item) => typeof item === "string")) : void 0,
|
|
2848
|
-
import_zod21.z.array(AcordLobCodeSchema).default(["UN"])
|
|
2849
|
-
);
|
|
2850
|
-
var PolicyOperationalProfileSchema = import_zod21.z.preprocess(
|
|
2851
|
-
legacyOperationalProfileInput,
|
|
2852
|
-
import_zod21.z.object({
|
|
2853
|
-
documentType: import_zod21.z.enum(["policy", "quote"]).default("policy"),
|
|
2854
|
-
linesOfBusiness: OperationalLinesOfBusinessSchema,
|
|
2855
|
-
policyNumber: SourceBackedValueSchema.optional(),
|
|
2856
|
-
namedInsured: SourceBackedValueSchema.optional(),
|
|
2857
|
-
insurer: SourceBackedValueSchema.optional(),
|
|
2858
|
-
broker: SourceBackedValueSchema.optional(),
|
|
2859
|
-
effectiveDate: SourceBackedValueSchema.optional(),
|
|
2860
|
-
expirationDate: SourceBackedValueSchema.optional(),
|
|
2861
|
-
retroactiveDate: SourceBackedValueSchema.optional(),
|
|
2862
|
-
premium: SourceBackedValueSchema.optional(),
|
|
2863
|
-
declarationFacts: import_zod21.z.array(OperationalDeclarationFactSchema).default([]),
|
|
2864
|
-
coverages: import_zod21.z.array(OperationalCoverageLineSchema).default([]),
|
|
2865
|
-
parties: import_zod21.z.array(OperationalPartySchema).default([]),
|
|
2866
|
-
endorsementSupport: import_zod21.z.array(OperationalEndorsementSupportSchema).default([]),
|
|
2867
|
-
sourceNodeIds: import_zod21.z.array(import_zod21.z.string().min(1)).default([]),
|
|
2868
|
-
sourceSpanIds: import_zod21.z.array(import_zod21.z.string().min(1)).default([]),
|
|
2869
|
-
warnings: import_zod21.z.array(import_zod21.z.string()).default([])
|
|
2870
|
-
})
|
|
2871
|
-
);
|
|
2872
|
-
|
|
2873
2925
|
// src/source/policy-types.ts
|
|
2874
2926
|
var LOB_TEXT_PATTERNS = [
|
|
2875
2927
|
{ codes: ["CGL"], pattern: /\b(?:commercial\s+)?general\s+liability\b|\bcgl\b/i },
|
|
@@ -4220,7 +4272,7 @@ function shouldFailQualityGate(mode, status) {
|
|
|
4220
4272
|
}
|
|
4221
4273
|
|
|
4222
4274
|
// src/extraction/source-tree-extractor.ts
|
|
4223
|
-
var
|
|
4275
|
+
var import_zod24 = require("zod");
|
|
4224
4276
|
|
|
4225
4277
|
// src/source/operational-profile.ts
|
|
4226
4278
|
function normalizeWhitespace4(value) {
|
|
@@ -4238,6 +4290,34 @@ function cleanCoverageLineOfBusiness(value) {
|
|
|
4238
4290
|
function normalizedFactValue(value) {
|
|
4239
4291
|
return value.toLowerCase().replace(/&/g, " and ").replace(/[.,#]/g, " ").replace(/\s+/g, " ").trim();
|
|
4240
4292
|
}
|
|
4293
|
+
var OPERATIONAL_ADDRESS_FIELDS = [
|
|
4294
|
+
"street1",
|
|
4295
|
+
"street2",
|
|
4296
|
+
"city",
|
|
4297
|
+
"state",
|
|
4298
|
+
"zip",
|
|
4299
|
+
"country",
|
|
4300
|
+
"formatted"
|
|
4301
|
+
];
|
|
4302
|
+
function normalizeOperationalAddress(value) {
|
|
4303
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
4304
|
+
const record = value;
|
|
4305
|
+
const address = Object.fromEntries(
|
|
4306
|
+
OPERATIONAL_ADDRESS_FIELDS.flatMap((field) => {
|
|
4307
|
+
const cleaned = typeof record[field] === "string" ? cleanValue(record[field]) : void 0;
|
|
4308
|
+
return cleaned ? [[field, cleaned]] : [];
|
|
4309
|
+
})
|
|
4310
|
+
);
|
|
4311
|
+
return Object.keys(address).length > 0 ? address : void 0;
|
|
4312
|
+
}
|
|
4313
|
+
function normalizeOperationalPartyRole(value) {
|
|
4314
|
+
const normalized = value.toLowerCase().replace(/[\s-]+/g, "_");
|
|
4315
|
+
if (normalized === "namedinsured" || normalized === "insured") return "named_insured";
|
|
4316
|
+
if (normalized === "managing_general_agent") return "mga";
|
|
4317
|
+
if (normalized === "managing_general_underwriter") return "mga";
|
|
4318
|
+
if (normalized === "third_party_administrator") return "administrator";
|
|
4319
|
+
return normalized;
|
|
4320
|
+
}
|
|
4241
4321
|
var OPERATIONAL_COVERAGE_TERM_KINDS = /* @__PURE__ */ new Set([
|
|
4242
4322
|
"each_claim_limit",
|
|
4243
4323
|
"each_occurrence_limit",
|
|
@@ -4336,6 +4416,7 @@ function mergeOperationalProfile(base, candidate, validNodeIds, validSpanIds) {
|
|
|
4336
4416
|
const expirationDate = mergeValue(base.expirationDate, candidate.expirationDate);
|
|
4337
4417
|
const retroactiveDate = mergeValue(base.retroactiveDate, candidate.retroactiveDate);
|
|
4338
4418
|
const premium = mergeValue(base.premium, candidate.premium);
|
|
4419
|
+
const operationsDescription = mergeValue(base.operationsDescription, candidate.operationsDescription);
|
|
4339
4420
|
const candidateDeclarationFacts = Array.isArray(candidate.declarationFacts) ? candidate.declarationFacts.map(mergeDeclarationFact).filter((fact) => Boolean(fact)) : [];
|
|
4340
4421
|
const declarationFacts = [
|
|
4341
4422
|
...base.declarationFacts,
|
|
@@ -4360,7 +4441,8 @@ function mergeOperationalProfile(base, candidate, validNodeIds, validSpanIds) {
|
|
|
4360
4441
|
effectiveDate,
|
|
4361
4442
|
expirationDate,
|
|
4362
4443
|
retroactiveDate,
|
|
4363
|
-
premium
|
|
4444
|
+
premium,
|
|
4445
|
+
operationsDescription
|
|
4364
4446
|
].filter((value) => Boolean(value));
|
|
4365
4447
|
const coverages = base.coverages.length > 0 ? base.coverages : Array.isArray(candidate.coverages) ? candidate.coverages.map((coverage) => {
|
|
4366
4448
|
const record = coverage;
|
|
@@ -4419,14 +4501,21 @@ function mergeOperationalProfile(base, candidate, validNodeIds, validSpanIds) {
|
|
|
4419
4501
|
const record = party;
|
|
4420
4502
|
const role = typeof record.role === "string" ? cleanValue(record.role) : void 0;
|
|
4421
4503
|
const name = typeof record.name === "string" ? cleanValue(record.name) : void 0;
|
|
4504
|
+
const address = normalizeOperationalAddress(record.address);
|
|
4422
4505
|
const sourceNodeIds2 = keepIds(record.sourceNodeIds, validNodeIds);
|
|
4423
4506
|
const sourceSpanIds2 = keepIds(record.sourceSpanIds, validSpanIds);
|
|
4424
4507
|
if (!role || !name || sourceNodeIds2.length === 0 && sourceSpanIds2.length === 0) return [];
|
|
4425
|
-
return [{
|
|
4508
|
+
return [{
|
|
4509
|
+
role: normalizeOperationalPartyRole(role),
|
|
4510
|
+
name,
|
|
4511
|
+
address,
|
|
4512
|
+
sourceNodeIds: sourceNodeIds2,
|
|
4513
|
+
sourceSpanIds: sourceSpanIds2
|
|
4514
|
+
}];
|
|
4426
4515
|
}) : [];
|
|
4427
4516
|
const parties = [
|
|
4428
|
-
...base.parties,
|
|
4429
4517
|
...candidateParties,
|
|
4518
|
+
...base.parties,
|
|
4430
4519
|
sourceBackedParty("named_insured", namedInsured),
|
|
4431
4520
|
sourceBackedParty("insurer", insurer),
|
|
4432
4521
|
sourceBackedParty("broker", broker)
|
|
@@ -4500,6 +4589,7 @@ function mergeOperationalProfile(base, candidate, validNodeIds, validSpanIds) {
|
|
|
4500
4589
|
expirationDate,
|
|
4501
4590
|
retroactiveDate,
|
|
4502
4591
|
premium,
|
|
4592
|
+
operationsDescription,
|
|
4503
4593
|
declarationFacts,
|
|
4504
4594
|
coverages: annotatedCoverages,
|
|
4505
4595
|
parties,
|
|
@@ -4944,96 +5034,812 @@ function applyCoverageCleanupDecision(coverage, decision, validNodeIds, validSpa
|
|
|
4944
5034
|
if (value) next.premium = value;
|
|
4945
5035
|
else delete next.premium;
|
|
4946
5036
|
}
|
|
4947
|
-
if (decision.retroactiveDate == null && termDecisionsTouch(coverage, termDecisions, isRetroactiveDateTerm)) {
|
|
4948
|
-
const value = retroactiveDateFromTerms(next.limits);
|
|
4949
|
-
if (value) next.retroactiveDate = value;
|
|
4950
|
-
else delete next.retroactiveDate;
|
|
5037
|
+
if (decision.retroactiveDate == null && termDecisionsTouch(coverage, termDecisions, isRetroactiveDateTerm)) {
|
|
5038
|
+
const value = retroactiveDateFromTerms(next.limits);
|
|
5039
|
+
if (value) next.retroactiveDate = value;
|
|
5040
|
+
else delete next.retroactiveDate;
|
|
5041
|
+
}
|
|
5042
|
+
}
|
|
5043
|
+
const termLimit = primaryLimitFromTerms(next.limits);
|
|
5044
|
+
if (termLimit && shouldUseTermLimitDisplay(next.limit, termLimit)) {
|
|
5045
|
+
next.limit = termLimit;
|
|
5046
|
+
}
|
|
5047
|
+
next.sourceNodeIds = uniqueStrings([
|
|
5048
|
+
...next.sourceNodeIds,
|
|
5049
|
+
...next.limits.flatMap((term) => term.sourceNodeIds)
|
|
5050
|
+
]);
|
|
5051
|
+
next.sourceSpanIds = uniqueStrings([
|
|
5052
|
+
...next.sourceSpanIds,
|
|
5053
|
+
...next.limits.flatMap((term) => term.sourceSpanIds)
|
|
5054
|
+
]);
|
|
5055
|
+
return next.name ? next : coverage;
|
|
5056
|
+
}
|
|
5057
|
+
function sourceIdsFromOperationalProfile(profile) {
|
|
5058
|
+
const backedValues = [
|
|
5059
|
+
profile.policyNumber,
|
|
5060
|
+
profile.namedInsured,
|
|
5061
|
+
profile.insurer,
|
|
5062
|
+
profile.broker,
|
|
5063
|
+
profile.effectiveDate,
|
|
5064
|
+
profile.expirationDate,
|
|
5065
|
+
profile.retroactiveDate,
|
|
5066
|
+
profile.premium,
|
|
5067
|
+
profile.totalCost,
|
|
5068
|
+
profile.operationsDescription
|
|
5069
|
+
].filter(Boolean);
|
|
5070
|
+
return {
|
|
5071
|
+
sourceNodeIds: uniqueStrings([
|
|
5072
|
+
...backedValues.flatMap((value) => value?.sourceNodeIds ?? []),
|
|
5073
|
+
...profile.coverages.flatMap((coverage) => coverage.sourceNodeIds),
|
|
5074
|
+
...profile.coverages.flatMap((coverage) => coverage.limits.flatMap((term) => term.sourceNodeIds)),
|
|
5075
|
+
...(profile.premiumBreakdown ?? []).flatMap((row) => row.sourceNodeIds),
|
|
5076
|
+
...(profile.taxesAndFees ?? []).flatMap((row) => row.sourceNodeIds),
|
|
5077
|
+
...profile.parties.flatMap((party) => party.sourceNodeIds),
|
|
5078
|
+
...profile.endorsementSupport.flatMap((support) => support.sourceNodeIds)
|
|
5079
|
+
]),
|
|
5080
|
+
sourceSpanIds: uniqueStrings([
|
|
5081
|
+
...backedValues.flatMap((value) => value?.sourceSpanIds ?? []),
|
|
5082
|
+
...profile.coverages.flatMap((coverage) => coverage.sourceSpanIds),
|
|
5083
|
+
...profile.coverages.flatMap((coverage) => coverage.limits.flatMap((term) => term.sourceSpanIds)),
|
|
5084
|
+
...(profile.coverageSchedules ?? []).flatMap((schedule) => [
|
|
5085
|
+
...schedule.sourceSpanIds,
|
|
5086
|
+
...schedule.items.flatMap((item) => item.sourceSpanIds)
|
|
5087
|
+
]),
|
|
5088
|
+
...(profile.premiumBreakdown ?? []).flatMap((row) => row.sourceSpanIds),
|
|
5089
|
+
...(profile.taxesAndFees ?? []).flatMap((row) => row.sourceSpanIds),
|
|
5090
|
+
...profile.parties.flatMap((party) => party.sourceSpanIds),
|
|
5091
|
+
...profile.endorsementSupport.flatMap((support) => support.sourceSpanIds)
|
|
5092
|
+
])
|
|
5093
|
+
};
|
|
5094
|
+
}
|
|
5095
|
+
function applyOperationalProfileCleanup(profile, cleanup, validNodeIds, validSpanIds) {
|
|
5096
|
+
const coverageDecisionByIndex = /* @__PURE__ */ new Map();
|
|
5097
|
+
for (const decision of cleanup.coverageDecisions) {
|
|
5098
|
+
if (decision.coverageIndex < profile.coverages.length) coverageDecisionByIndex.set(decision.coverageIndex, decision);
|
|
5099
|
+
}
|
|
5100
|
+
const coverages = profile.coverages.map(
|
|
5101
|
+
(coverage, index) => applyCoverageCleanupDecision(coverage, coverageDecisionByIndex.get(index), validNodeIds, validSpanIds)
|
|
5102
|
+
).filter((coverage) => Boolean(coverage));
|
|
5103
|
+
const cleanupWarnings = cleanup.warnings.map((warning) => cleanProfileValue(warning)).filter((warning) => Boolean(warning));
|
|
5104
|
+
const nextProfile = {
|
|
5105
|
+
...profile,
|
|
5106
|
+
coverages,
|
|
5107
|
+
warnings: uniqueStrings([
|
|
5108
|
+
...profile.warnings,
|
|
5109
|
+
...cleanupWarnings.map((warning) => `Operational profile cleanup warning: ${warning}`)
|
|
5110
|
+
])
|
|
5111
|
+
};
|
|
5112
|
+
return PolicyOperationalProfileSchema.parse({
|
|
5113
|
+
...nextProfile,
|
|
5114
|
+
...sourceIdsFromOperationalProfile(nextProfile)
|
|
5115
|
+
});
|
|
5116
|
+
}
|
|
5117
|
+
|
|
5118
|
+
// src/extraction/coverage-recovery.ts
|
|
5119
|
+
var import_zod23 = require("zod");
|
|
5120
|
+
var COVERAGE_RECOVERY_VERSION = "coverage-recovery-v2";
|
|
5121
|
+
var DISCOVERY_PAGE_BATCH_SIZE = 32;
|
|
5122
|
+
var REGION_PAGE_BATCH_SIZE = 4;
|
|
5123
|
+
var RECOVERY_EVIDENCE_CHAR_LIMIT = 42e3;
|
|
5124
|
+
var RecoveryRegionSchema = import_zod23.z.object({
|
|
5125
|
+
pageStart: import_zod23.z.number().int().positive(),
|
|
5126
|
+
pageEnd: import_zod23.z.number().int().positive(),
|
|
5127
|
+
reason: import_zod23.z.string(),
|
|
5128
|
+
priorContext: import_zod23.z.string().optional(),
|
|
5129
|
+
sourceNodeIds: import_zod23.z.array(import_zod23.z.string()).default([]),
|
|
5130
|
+
sourceSpanIds: import_zod23.z.array(import_zod23.z.string()).default([])
|
|
5131
|
+
});
|
|
5132
|
+
var RecoveryRegionDiscoverySchema = import_zod23.z.object({
|
|
5133
|
+
regions: import_zod23.z.array(RecoveryRegionSchema).default([]),
|
|
5134
|
+
warnings: import_zod23.z.array(import_zod23.z.string()).default([])
|
|
5135
|
+
});
|
|
5136
|
+
var CoverageRecoveryCandidateSchema = import_zod23.z.object({
|
|
5137
|
+
coverages: import_zod23.z.array(OperationalCoverageLineSchema).default([]),
|
|
5138
|
+
coverageSchedules: import_zod23.z.array(OperationalCoverageScheduleSchema).default([]),
|
|
5139
|
+
premiumBreakdown: import_zod23.z.array(OperationalPremiumLineSchema).default([]),
|
|
5140
|
+
taxesAndFees: import_zod23.z.array(OperationalTaxFeeItemSchema).default([]),
|
|
5141
|
+
totalCost: SourceBackedValueSchema.optional(),
|
|
5142
|
+
warnings: import_zod23.z.array(import_zod23.z.string()).default([])
|
|
5143
|
+
});
|
|
5144
|
+
function cleanText(value) {
|
|
5145
|
+
if (typeof value !== "string") return void 0;
|
|
5146
|
+
const text = value.replace(/\s+/g, " ").trim();
|
|
5147
|
+
return text || void 0;
|
|
5148
|
+
}
|
|
5149
|
+
function uniqueStrings2(values) {
|
|
5150
|
+
return [...new Set(values.filter((value) => Boolean(value)))];
|
|
5151
|
+
}
|
|
5152
|
+
function spanPageStart(span) {
|
|
5153
|
+
return span.pageStart ?? span.location?.startPage ?? span.location?.page;
|
|
5154
|
+
}
|
|
5155
|
+
function spanPageEnd(span) {
|
|
5156
|
+
return span.pageEnd ?? span.location?.endPage ?? span.location?.page ?? spanPageStart(span);
|
|
5157
|
+
}
|
|
5158
|
+
function spanSourceUnit(span) {
|
|
5159
|
+
return span.sourceUnit ?? span.metadata?.sourceUnit;
|
|
5160
|
+
}
|
|
5161
|
+
function overlapsPageRange(value, pageStart2, pageEnd2) {
|
|
5162
|
+
const start = value.pageStart ?? value.pageEnd;
|
|
5163
|
+
const end = value.pageEnd ?? value.pageStart;
|
|
5164
|
+
return typeof start === "number" && typeof end === "number" && start <= pageEnd2 && end >= pageStart2;
|
|
5165
|
+
}
|
|
5166
|
+
function chunkValues(values, size) {
|
|
5167
|
+
const chunks = [];
|
|
5168
|
+
for (let index = 0; index < values.length; index += size) {
|
|
5169
|
+
chunks.push(values.slice(index, index + size));
|
|
5170
|
+
}
|
|
5171
|
+
return chunks;
|
|
5172
|
+
}
|
|
5173
|
+
function evenlySample(values, limit) {
|
|
5174
|
+
if (values.length <= limit) return values;
|
|
5175
|
+
if (limit <= 1) return [values[0]];
|
|
5176
|
+
return Array.from(
|
|
5177
|
+
{ length: limit },
|
|
5178
|
+
(_, index) => values[Math.round(index * (values.length - 1) / (limit - 1))]
|
|
5179
|
+
);
|
|
5180
|
+
}
|
|
5181
|
+
function sourceNodeIdsBySpanId(sourceTree) {
|
|
5182
|
+
const result = /* @__PURE__ */ new Map();
|
|
5183
|
+
for (const node of sourceTree) {
|
|
5184
|
+
for (const sourceSpanId of node.sourceSpanIds) {
|
|
5185
|
+
const ids = result.get(sourceSpanId) ?? [];
|
|
5186
|
+
ids.push(node.id);
|
|
5187
|
+
result.set(sourceSpanId, ids);
|
|
5188
|
+
}
|
|
5189
|
+
}
|
|
5190
|
+
return result;
|
|
5191
|
+
}
|
|
5192
|
+
function documentPages(sourceTree, sourceSpans) {
|
|
5193
|
+
const pages = /* @__PURE__ */ new Set();
|
|
5194
|
+
for (const span of sourceSpans) {
|
|
5195
|
+
const start = spanPageStart(span);
|
|
5196
|
+
const end = spanPageEnd(span) ?? start;
|
|
5197
|
+
if (!start || !end) continue;
|
|
5198
|
+
for (let page = start; page <= end; page += 1) pages.add(page);
|
|
5199
|
+
}
|
|
5200
|
+
for (const node of sourceTree) {
|
|
5201
|
+
if (node.pageStart) pages.add(node.pageStart);
|
|
5202
|
+
if (node.pageEnd) pages.add(node.pageEnd);
|
|
5203
|
+
}
|
|
5204
|
+
return [...pages].sort((left, right) => left - right);
|
|
5205
|
+
}
|
|
5206
|
+
function pageSketch(page, sourceTree, sourceSpans) {
|
|
5207
|
+
const pageNodes = sourceTree.filter((node) => node.kind !== "document" && overlapsPageRange(node, page, page)).sort((left, right) => left.order - right.order || left.id.localeCompare(right.id));
|
|
5208
|
+
const pageSpans = sourceSpans.filter((span) => overlapsPageRange({ pageStart: spanPageStart(span), pageEnd: spanPageEnd(span) }, page, page)).sort(
|
|
5209
|
+
(left, right) => (left.location?.charStart ?? Number.MAX_SAFE_INTEGER) - (right.location?.charStart ?? Number.MAX_SAFE_INTEGER) || left.id.localeCompare(right.id)
|
|
5210
|
+
);
|
|
5211
|
+
const tableIds = uniqueStrings2(pageSpans.map((span) => span.table?.tableId ?? span.metadata?.tableId));
|
|
5212
|
+
const units = pageSpans.reduce((counts, span) => {
|
|
5213
|
+
const unit = spanSourceUnit(span) ?? "unknown";
|
|
5214
|
+
counts[unit] = (counts[unit] ?? 0) + 1;
|
|
5215
|
+
return counts;
|
|
5216
|
+
}, {});
|
|
5217
|
+
const textSamples = evenlySample(
|
|
5218
|
+
pageSpans.filter((span) => cleanText(span.text)).map((span) => ({
|
|
5219
|
+
sourceSpanId: span.id,
|
|
5220
|
+
sourceUnit: spanSourceUnit(span),
|
|
5221
|
+
tableId: span.table?.tableId ?? span.metadata?.tableId,
|
|
5222
|
+
rowIndex: span.table?.rowIndex,
|
|
5223
|
+
columnIndex: span.table?.columnIndex,
|
|
5224
|
+
columnName: span.table?.columnName,
|
|
5225
|
+
bbox: span.bbox?.[0],
|
|
5226
|
+
text: cleanText(span.text)?.slice(0, 280)
|
|
5227
|
+
})),
|
|
5228
|
+
18
|
|
5229
|
+
);
|
|
5230
|
+
return {
|
|
5231
|
+
page,
|
|
5232
|
+
forms: uniqueStrings2(pageSpans.map((span) => span.formNumber)),
|
|
5233
|
+
structure: evenlySample(pageNodes.map((node) => ({
|
|
5234
|
+
id: node.id,
|
|
5235
|
+
kind: node.kind,
|
|
5236
|
+
title: node.title,
|
|
5237
|
+
path: node.path,
|
|
5238
|
+
sourceSpanIds: node.sourceSpanIds.slice(0, 6)
|
|
5239
|
+
})), 20),
|
|
5240
|
+
layout: {
|
|
5241
|
+
units,
|
|
5242
|
+
tableCount: tableIds.length,
|
|
5243
|
+
rowCount: pageSpans.filter((span) => spanSourceUnit(span) === "table_row").length,
|
|
5244
|
+
cellCount: pageSpans.filter((span) => spanSourceUnit(span) === "table_cell").length
|
|
5245
|
+
},
|
|
5246
|
+
textSamples
|
|
5247
|
+
};
|
|
5248
|
+
}
|
|
5249
|
+
function discoveryPrompt(sketches) {
|
|
5250
|
+
return `Discover every document region that may contain policy-specific coverage facts, asset schedules, or financial facts.
|
|
5251
|
+
|
|
5252
|
+
This is semantic region discovery, not keyword or heading matching. Inspect the layout and source-tree sketch for every supplied page, including unusual terminology and late-document schedules.
|
|
5253
|
+
|
|
5254
|
+
Select regions containing or continuing any of:
|
|
5255
|
+
- coverage, benefit, insuring-agreement, limit, sublimit, deductible, retention, or per-asset terms
|
|
5256
|
+
- covered-auto, vehicle, property, location, building, equipment, or similar asset schedules
|
|
5257
|
+
- premium breakdowns, taxes, fees, surcharges, assessments, or total payable
|
|
5258
|
+
- declarations, forms, endorsements, options, exclusions, or cross-references that establish the status or scope of those facts
|
|
5259
|
+
|
|
5260
|
+
Continuation rules:
|
|
5261
|
+
- A repeated heading is not required. Carry prior section and table-header context onto continuation pages.
|
|
5262
|
+
- Continue through compatible row numbering, column geometry, form identity, and table shape.
|
|
5263
|
+
- Stop at a new form, incompatible table structure, terminal language, or unrelated section.
|
|
5264
|
+
- Include declined, excluded, and unselected-option regions so the extraction pass can keep them out of active coverage rows.
|
|
5265
|
+
|
|
5266
|
+
Use only page numbers and source IDs from the sketches. Return no region for pages that contain no relevant policy-specific evidence.
|
|
5267
|
+
|
|
5268
|
+
Page sketches:
|
|
5269
|
+
${JSON.stringify(sketches, null, 2)}`;
|
|
5270
|
+
}
|
|
5271
|
+
function normalizeRegions(regions, pages) {
|
|
5272
|
+
if (pages.length === 0) return [];
|
|
5273
|
+
const minPage = pages[0];
|
|
5274
|
+
const maxPage = pages[pages.length - 1];
|
|
5275
|
+
const normalized = regions.flatMap((region) => {
|
|
5276
|
+
const start = Math.max(minPage, Math.min(maxPage, region.pageStart));
|
|
5277
|
+
const end = Math.max(start, Math.min(maxPage, region.pageEnd));
|
|
5278
|
+
if (!pages.some((page) => page >= start && page <= end)) return [];
|
|
5279
|
+
return [{ ...region, pageStart: start, pageEnd: end }];
|
|
5280
|
+
});
|
|
5281
|
+
normalized.sort((left, right) => left.pageStart - right.pageStart || left.pageEnd - right.pageEnd);
|
|
5282
|
+
return normalized.reduce((rows, region) => {
|
|
5283
|
+
const previous = rows[rows.length - 1];
|
|
5284
|
+
if (!previous || region.pageStart > previous.pageEnd + 1) {
|
|
5285
|
+
rows.push(region);
|
|
5286
|
+
return rows;
|
|
5287
|
+
}
|
|
5288
|
+
previous.pageEnd = Math.max(previous.pageEnd, region.pageEnd);
|
|
5289
|
+
previous.reason = uniqueStrings2([previous.reason, region.reason]).join("; ");
|
|
5290
|
+
previous.priorContext = uniqueStrings2([previous.priorContext, region.priorContext]).join("; ") || void 0;
|
|
5291
|
+
previous.sourceNodeIds = uniqueStrings2([...previous.sourceNodeIds, ...region.sourceNodeIds]);
|
|
5292
|
+
previous.sourceSpanIds = uniqueStrings2([...previous.sourceSpanIds, ...region.sourceSpanIds]);
|
|
5293
|
+
return rows;
|
|
5294
|
+
}, []);
|
|
5295
|
+
}
|
|
5296
|
+
function splitRegions(regions) {
|
|
5297
|
+
return regions.flatMap((region) => {
|
|
5298
|
+
const result = [];
|
|
5299
|
+
for (let page = region.pageStart; page <= region.pageEnd; page += REGION_PAGE_BATCH_SIZE) {
|
|
5300
|
+
result.push({
|
|
5301
|
+
...region,
|
|
5302
|
+
pageStart: page,
|
|
5303
|
+
pageEnd: Math.min(region.pageEnd, page + REGION_PAGE_BATCH_SIZE - 1)
|
|
5304
|
+
});
|
|
5305
|
+
}
|
|
5306
|
+
return result;
|
|
5307
|
+
});
|
|
5308
|
+
}
|
|
5309
|
+
function priorStructuralContext(region, sourceTree, sourceSpans) {
|
|
5310
|
+
const precedingNodes = sourceTree.filter((node) => node.kind !== "document" && (node.pageStart ?? 0) <= region.pageStart).filter((node) => ["page_group", "form", "endorsement", "section", "schedule", "table"].includes(node.kind)).sort(
|
|
5311
|
+
(left, right) => (right.pageStart ?? 0) - (left.pageStart ?? 0) || right.order - left.order
|
|
5312
|
+
).slice(0, 12).map((node) => ({
|
|
5313
|
+
id: node.id,
|
|
5314
|
+
kind: node.kind,
|
|
5315
|
+
title: node.title,
|
|
5316
|
+
path: node.path,
|
|
5317
|
+
pageStart: node.pageStart,
|
|
5318
|
+
pageEnd: node.pageEnd,
|
|
5319
|
+
sourceSpanIds: node.sourceSpanIds.slice(0, 8)
|
|
5320
|
+
}));
|
|
5321
|
+
const headerSpans = sourceSpans.filter((span) => {
|
|
5322
|
+
const page = spanPageStart(span);
|
|
5323
|
+
return typeof page === "number" && page >= Math.max(1, region.pageStart - 2) && page <= region.pageStart && (span.table?.isHeader || span.table?.columnName || span.metadata?.isHeader === "true");
|
|
5324
|
+
}).map((span) => ({
|
|
5325
|
+
sourceSpanId: span.id,
|
|
5326
|
+
pageStart: spanPageStart(span),
|
|
5327
|
+
table: span.table,
|
|
5328
|
+
text: cleanText(span.text)?.slice(0, 600)
|
|
5329
|
+
}));
|
|
5330
|
+
return { priorContext: region.priorContext, precedingNodes, tableHeaders: headerSpans };
|
|
5331
|
+
}
|
|
5332
|
+
function regionEvidence(region, sourceTree, sourceSpans) {
|
|
5333
|
+
const nodeIdsBySpanId = sourceNodeIdsBySpanId(sourceTree);
|
|
5334
|
+
const spans = sourceSpans.filter((span) => overlapsPageRange(
|
|
5335
|
+
{ pageStart: spanPageStart(span), pageEnd: spanPageEnd(span) },
|
|
5336
|
+
region.pageStart,
|
|
5337
|
+
region.pageEnd
|
|
5338
|
+
)).sort(
|
|
5339
|
+
(left, right) => (spanPageStart(left) ?? Number.MAX_SAFE_INTEGER) - (spanPageStart(right) ?? Number.MAX_SAFE_INTEGER) || (left.location?.charStart ?? Number.MAX_SAFE_INTEGER) - (right.location?.charStart ?? Number.MAX_SAFE_INTEGER) || left.id.localeCompare(right.id)
|
|
5340
|
+
);
|
|
5341
|
+
return spans.flatMap((span) => {
|
|
5342
|
+
const text = cleanText(span.text);
|
|
5343
|
+
if (!text) return [];
|
|
5344
|
+
const parts = text.match(/[\s\S]{1,1400}/g) ?? [text];
|
|
5345
|
+
return parts.map((part) => ({
|
|
5346
|
+
sourceSpanId: span.id,
|
|
5347
|
+
sourceNodeIds: (nodeIdsBySpanId.get(span.id) ?? []).slice(0, 6),
|
|
5348
|
+
pageStart: spanPageStart(span),
|
|
5349
|
+
pageEnd: spanPageEnd(span),
|
|
5350
|
+
sourceUnit: spanSourceUnit(span),
|
|
5351
|
+
formNumber: span.formNumber,
|
|
5352
|
+
table: span.table,
|
|
5353
|
+
text: part
|
|
5354
|
+
}));
|
|
5355
|
+
});
|
|
5356
|
+
}
|
|
5357
|
+
function evidenceBatches(entries) {
|
|
5358
|
+
const batches = [];
|
|
5359
|
+
let current = [];
|
|
5360
|
+
let chars = 0;
|
|
5361
|
+
for (const entry of entries) {
|
|
5362
|
+
const size = entry.text.length + 260;
|
|
5363
|
+
if (current.length > 0 && chars + size > RECOVERY_EVIDENCE_CHAR_LIMIT) {
|
|
5364
|
+
batches.push(current);
|
|
5365
|
+
current = [];
|
|
5366
|
+
chars = 0;
|
|
5367
|
+
}
|
|
5368
|
+
current.push(entry);
|
|
5369
|
+
chars += size;
|
|
5370
|
+
}
|
|
5371
|
+
if (current.length > 0) batches.push(current);
|
|
5372
|
+
return batches;
|
|
5373
|
+
}
|
|
5374
|
+
function recoveryPrompt(params) {
|
|
5375
|
+
return `Recover missing source-backed policy coverage, schedule, and financial facts from one semantically selected document region.
|
|
5376
|
+
|
|
5377
|
+
Region: pages ${params.region.pageStart}-${params.region.pageEnd}
|
|
5378
|
+
Reason: ${params.region.reason}
|
|
5379
|
+
Evidence batch: ${params.batchIndex}/${params.batchCount}
|
|
5380
|
+
|
|
5381
|
+
Rules:
|
|
5382
|
+
- Preserve the source's coverage terminology as coverages[].name. ACORD lineOfBusiness and coverageCode may supplement it but may not replace it with unsupported wording.
|
|
5383
|
+
- A repeated heading is not required. Use the prior section and table-header context to interpret compatible continuation rows.
|
|
5384
|
+
- Keep declaration/core-form and endorsement facts separate when their source scopes differ, even if names match.
|
|
5385
|
+
- Put per occurrence, per claim, aggregate, per vehicle, per location, retention, deductible, sublimit, and similar values in coverages[].limits with the source label preserved.
|
|
5386
|
+
- Do not emit premium, taxes, fees, surcharges, assessments, rating bases, insured values, or exposures as coverage rows or coverage terms.
|
|
5387
|
+
- Do not emit declined, excluded, not-covered, or optional-unselected entries as active coverages.
|
|
5388
|
+
- Store covered-auto, vehicle, property, location, building, and equipment listings in coverageSchedules. Partial or redacted items are allowed there.
|
|
5389
|
+
- Put premium rows in premiumBreakdown, taxes/fees/surcharges/assessments in taxesAndFees, and total payable in totalCost.
|
|
5390
|
+
- Every returned fact must cite existing sourceSpanIds or sourceNodeIds from the supplied evidence. Prefer exact row/cell sourceSpanIds.
|
|
5391
|
+
- Numeric, monetary, percentage, date, VIN, form, and policy identifiers must be copied exactly enough to appear in their cited evidence after punctuation and spacing normalization.
|
|
5392
|
+
- Omit ambiguous or unsupported facts. Do not replace or rewrite source values.
|
|
5393
|
+
|
|
5394
|
+
Prior structural context:
|
|
5395
|
+
${JSON.stringify(params.context, null, 2)}
|
|
5396
|
+
|
|
5397
|
+
Source evidence:
|
|
5398
|
+
${JSON.stringify(params.evidence, null, 2)}`;
|
|
5399
|
+
}
|
|
5400
|
+
function normalizedText(value) {
|
|
5401
|
+
return value.toLowerCase().replace(/[^a-z0-9]+/g, "");
|
|
5402
|
+
}
|
|
5403
|
+
function mechanicallyCheckableTokens(value) {
|
|
5404
|
+
const numeric = [...value.matchAll(/\d[\d,./:%-]*/g)].map((match) => match[0].replace(/^0+(?=\d)/, "").replace(/[^0-9a-z]/gi, "")).filter((token) => token.length >= 2);
|
|
5405
|
+
const identifiers = [...value.matchAll(/\b(?=[A-Z0-9-]*\d)[A-Z0-9-]{5,}\b/gi)].map((match) => normalizedText(match[0]));
|
|
5406
|
+
return uniqueStrings2([...numeric, ...identifiers]);
|
|
5407
|
+
}
|
|
5408
|
+
function valueGroundedInText(value, evidenceText) {
|
|
5409
|
+
if (!value) return true;
|
|
5410
|
+
const tokens = mechanicallyCheckableTokens(value);
|
|
5411
|
+
if (tokens.length === 0) return true;
|
|
5412
|
+
const normalizedEvidence = normalizedText(evidenceText);
|
|
5413
|
+
return tokens.every((token) => normalizedEvidence.includes(normalizedText(token)));
|
|
5414
|
+
}
|
|
5415
|
+
function citedText(ids, spansById) {
|
|
5416
|
+
return ids.map((id) => spansById.get(id)?.text ?? "").join(" ");
|
|
5417
|
+
}
|
|
5418
|
+
function validIds2(ids, valid) {
|
|
5419
|
+
return uniqueStrings2(ids.filter((id) => valid.has(id)));
|
|
5420
|
+
}
|
|
5421
|
+
function validateCandidate(candidate, sourceTree, sourceSpans) {
|
|
5422
|
+
const validNodeIds = new Set(sourceTree.map((node) => node.id));
|
|
5423
|
+
const validSpanIds = new Set(sourceSpans.map((span) => span.id));
|
|
5424
|
+
const spansById = new Map(sourceSpans.map((span) => [span.id, span]));
|
|
5425
|
+
let citationRejectionCount = 0;
|
|
5426
|
+
const validateCitation = (sourceNodeIds, sourceSpanIds, values) => {
|
|
5427
|
+
const nodes = validIds2(sourceNodeIds, validNodeIds);
|
|
5428
|
+
const spans = validIds2(sourceSpanIds, validSpanIds);
|
|
5429
|
+
if (nodes.length === 0 && spans.length === 0) {
|
|
5430
|
+
citationRejectionCount += 1;
|
|
5431
|
+
return void 0;
|
|
5432
|
+
}
|
|
5433
|
+
const evidenceText = citedText(spans, spansById);
|
|
5434
|
+
if (values.some((value) => !valueGroundedInText(value, evidenceText))) {
|
|
5435
|
+
citationRejectionCount += 1;
|
|
5436
|
+
return void 0;
|
|
5437
|
+
}
|
|
5438
|
+
return { sourceNodeIds: nodes, sourceSpanIds: spans };
|
|
5439
|
+
};
|
|
5440
|
+
const coverages = candidate.coverages.flatMap((coverage) => {
|
|
5441
|
+
const coverageCitation = validateCitation(
|
|
5442
|
+
coverage.sourceNodeIds,
|
|
5443
|
+
coverage.sourceSpanIds,
|
|
5444
|
+
[coverage.name, coverage.limit, coverage.deductible, coverage.premium, coverage.retroactiveDate, coverage.formNumber, coverage.endorsementNumber]
|
|
5445
|
+
);
|
|
5446
|
+
if (!coverageCitation) return [];
|
|
5447
|
+
if (/\b(?:declined|excluded|not covered|not selected|optional\s*[-:]?\s*no)\b/i.test(coverage.name)) return [];
|
|
5448
|
+
if (/\b(?:premium|tax|fee|surcharge|assessment|rating basis|exposure|insured value)\b/i.test(coverage.name) && coverage.limits.length === 0 && !coverage.limit && !coverage.deductible) return [];
|
|
5449
|
+
const limits = coverage.limits.flatMap((term) => {
|
|
5450
|
+
if (term.kind === "premium") return [];
|
|
5451
|
+
const citation = validateCitation(
|
|
5452
|
+
term.sourceNodeIds,
|
|
5453
|
+
term.sourceSpanIds,
|
|
5454
|
+
[term.label, term.value, term.appliesTo]
|
|
5455
|
+
);
|
|
5456
|
+
return citation ? [{ ...term, ...citation }] : [];
|
|
5457
|
+
});
|
|
5458
|
+
const hasCoverageFact = limits.length > 0 || coverage.limit || coverage.deductible || coverage.retroactiveDate || coverage.formNumber || coverage.endorsementNumber;
|
|
5459
|
+
return hasCoverageFact ? [{ ...coverage, ...coverageCitation, limits }] : [];
|
|
5460
|
+
});
|
|
5461
|
+
const coverageSchedules = candidate.coverageSchedules.flatMap((schedule) => {
|
|
5462
|
+
const sourceSpanIds = validIds2(schedule.sourceSpanIds, validSpanIds);
|
|
5463
|
+
if (sourceSpanIds.length === 0 || !valueGroundedInText(schedule.name, citedText(sourceSpanIds, spansById))) {
|
|
5464
|
+
citationRejectionCount += 1;
|
|
5465
|
+
return [];
|
|
5466
|
+
}
|
|
5467
|
+
const items = schedule.items.flatMap((item) => {
|
|
5468
|
+
const itemSpanIds = validIds2(item.sourceSpanIds, validSpanIds);
|
|
5469
|
+
if (itemSpanIds.length === 0) {
|
|
5470
|
+
citationRejectionCount += 1;
|
|
5471
|
+
return [];
|
|
5472
|
+
}
|
|
5473
|
+
const evidenceText = citedText(itemSpanIds, spansById);
|
|
5474
|
+
const values = item.values.filter((value) => {
|
|
5475
|
+
const valid = valueGroundedInText(value.value, evidenceText);
|
|
5476
|
+
if (!valid) citationRejectionCount += 1;
|
|
5477
|
+
return valid;
|
|
5478
|
+
});
|
|
5479
|
+
return values.length > 0 && valueGroundedInText(item.label, evidenceText) ? [{ ...item, values, sourceSpanIds: itemSpanIds }] : [];
|
|
5480
|
+
});
|
|
5481
|
+
return items.length > 0 ? [{ ...schedule, items, sourceSpanIds }] : [];
|
|
5482
|
+
});
|
|
5483
|
+
const premiumBreakdown = candidate.premiumBreakdown.flatMap((row) => {
|
|
5484
|
+
const citation = validateCitation(row.sourceNodeIds, row.sourceSpanIds, [row.line, row.amount]);
|
|
5485
|
+
return citation ? [{ ...row, ...citation }] : [];
|
|
5486
|
+
});
|
|
5487
|
+
const taxesAndFees = candidate.taxesAndFees.flatMap((row) => {
|
|
5488
|
+
const citation = validateCitation(row.sourceNodeIds, row.sourceSpanIds, [row.name, row.amount]);
|
|
5489
|
+
return citation ? [{ ...row, ...citation }] : [];
|
|
5490
|
+
});
|
|
5491
|
+
const totalCostCitation = candidate.totalCost ? validateCitation(candidate.totalCost.sourceNodeIds, candidate.totalCost.sourceSpanIds, [candidate.totalCost.value]) : void 0;
|
|
5492
|
+
return {
|
|
5493
|
+
candidate: {
|
|
5494
|
+
...candidate,
|
|
5495
|
+
coverages,
|
|
5496
|
+
coverageSchedules,
|
|
5497
|
+
premiumBreakdown,
|
|
5498
|
+
taxesAndFees,
|
|
5499
|
+
totalCost: candidate.totalCost && totalCostCitation ? { ...candidate.totalCost, ...totalCostCitation } : void 0
|
|
5500
|
+
},
|
|
5501
|
+
citationRejectionCount
|
|
5502
|
+
};
|
|
5503
|
+
}
|
|
5504
|
+
function normalizedLabel(value) {
|
|
5505
|
+
return value.toLowerCase().replace(/&/g, " and ").replace(/[^a-z0-9]+/g, " ").trim();
|
|
5506
|
+
}
|
|
5507
|
+
function sourcePages(ids, spansById) {
|
|
5508
|
+
const pages = ids.flatMap((id) => {
|
|
5509
|
+
const span = spansById.get(id);
|
|
5510
|
+
const start = span ? spanPageStart(span) : void 0;
|
|
5511
|
+
const end = span ? spanPageEnd(span) : void 0;
|
|
5512
|
+
return [start, end].filter((page) => typeof page === "number");
|
|
5513
|
+
});
|
|
5514
|
+
return pages.length > 0 ? [Math.min(...pages), Math.max(...pages)] : void 0;
|
|
5515
|
+
}
|
|
5516
|
+
function sameCoverageScope(primary, recovery, spansById) {
|
|
5517
|
+
if (normalizedLabel(primary.name) !== normalizedLabel(recovery.name)) return false;
|
|
5518
|
+
if (primary.lineOfBusiness && recovery.lineOfBusiness && primary.lineOfBusiness !== recovery.lineOfBusiness) return false;
|
|
5519
|
+
for (const key of ["formNumber", "sectionRef", "endorsementNumber"]) {
|
|
5520
|
+
const left = cleanText(primary[key]);
|
|
5521
|
+
const right = cleanText(recovery[key]);
|
|
5522
|
+
if (left && right && normalizedLabel(left) !== normalizedLabel(right)) return false;
|
|
5523
|
+
if (key === "endorsementNumber" && Boolean(left) !== Boolean(right)) return false;
|
|
5524
|
+
}
|
|
5525
|
+
const primaryPages = sourcePages(primary.sourceSpanIds, spansById);
|
|
5526
|
+
const recoveryPages = sourcePages(recovery.sourceSpanIds, spansById);
|
|
5527
|
+
if (!primaryPages || !recoveryPages) return true;
|
|
5528
|
+
return primaryPages[0] <= recoveryPages[1] + 1 && recoveryPages[0] <= primaryPages[1] + 1;
|
|
5529
|
+
}
|
|
5530
|
+
function termIdentity(term) {
|
|
5531
|
+
return [term.kind, normalizedLabel(term.label), normalizedLabel(term.value), normalizedLabel(term.appliesTo ?? "")].join("|");
|
|
5532
|
+
}
|
|
5533
|
+
function mergeCoverage(primary, recovery, warnings) {
|
|
5534
|
+
const limits = [...primary.limits];
|
|
5535
|
+
const identities = new Set(limits.map(termIdentity));
|
|
5536
|
+
for (const term of recovery.limits) {
|
|
5537
|
+
const identity = termIdentity(term);
|
|
5538
|
+
if (identities.has(identity)) continue;
|
|
5539
|
+
const conflict = limits.find(
|
|
5540
|
+
(current) => current.kind === term.kind && normalizedLabel(current.label) === normalizedLabel(term.label) && normalizedLabel(current.appliesTo ?? "") === normalizedLabel(term.appliesTo ?? "") && normalizedLabel(current.value) !== normalizedLabel(term.value)
|
|
5541
|
+
);
|
|
5542
|
+
if (conflict) {
|
|
5543
|
+
warnings.push(`Coverage recovery preserved conflicting cited ${term.label} terms for ${primary.name}.`);
|
|
4951
5544
|
}
|
|
5545
|
+
limits.push(term);
|
|
5546
|
+
identities.add(identity);
|
|
4952
5547
|
}
|
|
4953
|
-
|
|
4954
|
-
|
|
4955
|
-
|
|
5548
|
+
return {
|
|
5549
|
+
...recovery,
|
|
5550
|
+
...primary,
|
|
5551
|
+
limit: primary.limit ?? recovery.limit,
|
|
5552
|
+
deductible: primary.deductible ?? recovery.deductible,
|
|
5553
|
+
premium: primary.premium ?? recovery.premium,
|
|
5554
|
+
retroactiveDate: primary.retroactiveDate ?? recovery.retroactiveDate,
|
|
5555
|
+
formNumber: primary.formNumber ?? recovery.formNumber,
|
|
5556
|
+
sectionRef: primary.sectionRef ?? recovery.sectionRef,
|
|
5557
|
+
endorsementNumber: primary.endorsementNumber ?? recovery.endorsementNumber,
|
|
5558
|
+
limits,
|
|
5559
|
+
sourceNodeIds: uniqueStrings2([...primary.sourceNodeIds, ...recovery.sourceNodeIds]),
|
|
5560
|
+
sourceSpanIds: uniqueStrings2([...primary.sourceSpanIds, ...recovery.sourceSpanIds])
|
|
5561
|
+
};
|
|
5562
|
+
}
|
|
5563
|
+
function appendUnique(primary, additions, key) {
|
|
5564
|
+
const result = [...primary];
|
|
5565
|
+
const seen = new Set(primary.map(key));
|
|
5566
|
+
for (const value of additions) {
|
|
5567
|
+
const identity = key(value);
|
|
5568
|
+
if (seen.has(identity)) continue;
|
|
5569
|
+
seen.add(identity);
|
|
5570
|
+
result.push(value);
|
|
4956
5571
|
}
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
5572
|
+
return result;
|
|
5573
|
+
}
|
|
5574
|
+
function mergeRecoveryCandidate(profile, candidate, sourceSpans) {
|
|
5575
|
+
const warnings = [...candidate.warnings];
|
|
5576
|
+
const spansById = new Map(sourceSpans.map((span) => [span.id, span]));
|
|
5577
|
+
const coverages = [...profile.coverages];
|
|
5578
|
+
let recoveredCoverageCount = 0;
|
|
5579
|
+
let recoveredTermCount = 0;
|
|
5580
|
+
for (const recovery of candidate.coverages) {
|
|
5581
|
+
const matchIndex = coverages.findIndex((primary) => sameCoverageScope(primary, recovery, spansById));
|
|
5582
|
+
if (matchIndex < 0) {
|
|
5583
|
+
coverages.push(recovery);
|
|
5584
|
+
recoveredCoverageCount += 1;
|
|
5585
|
+
recoveredTermCount += recovery.limits.length;
|
|
5586
|
+
continue;
|
|
5587
|
+
}
|
|
5588
|
+
const before = coverages[matchIndex].limits.length;
|
|
5589
|
+
coverages[matchIndex] = mergeCoverage(coverages[matchIndex], recovery, warnings);
|
|
5590
|
+
recoveredTermCount += coverages[matchIndex].limits.length - before;
|
|
5591
|
+
}
|
|
5592
|
+
const coverageSchedules = appendUnique(
|
|
5593
|
+
profile.coverageSchedules ?? [],
|
|
5594
|
+
candidate.coverageSchedules,
|
|
5595
|
+
(schedule) => `${schedule.kind}|${normalizedLabel(schedule.name)}|${schedule.pageStart ?? ""}|${schedule.pageEnd ?? ""}`
|
|
5596
|
+
);
|
|
5597
|
+
const premiumBreakdown = appendUnique(
|
|
5598
|
+
profile.premiumBreakdown ?? [],
|
|
5599
|
+
candidate.premiumBreakdown,
|
|
5600
|
+
(row) => `${normalizedLabel(row.line)}|${normalizedLabel(row.amount)}|${row.sourceSpanIds.join(",")}`
|
|
5601
|
+
);
|
|
5602
|
+
const taxesAndFees = appendUnique(
|
|
5603
|
+
profile.taxesAndFees ?? [],
|
|
5604
|
+
candidate.taxesAndFees,
|
|
5605
|
+
(row) => `${normalizedLabel(row.name)}|${normalizedLabel(row.amount)}|${row.sourceSpanIds.join(",")}`
|
|
5606
|
+
);
|
|
5607
|
+
const totalCost = profile.totalCost ?? candidate.totalCost;
|
|
5608
|
+
const sourceNodeIds = uniqueStrings2([
|
|
5609
|
+
...profile.sourceNodeIds,
|
|
5610
|
+
...coverages.flatMap((coverage) => [
|
|
5611
|
+
...coverage.sourceNodeIds,
|
|
5612
|
+
...coverage.limits.flatMap((term) => term.sourceNodeIds)
|
|
5613
|
+
]),
|
|
5614
|
+
...premiumBreakdown.flatMap((row) => row.sourceNodeIds),
|
|
5615
|
+
...taxesAndFees.flatMap((row) => row.sourceNodeIds),
|
|
5616
|
+
...totalCost?.sourceNodeIds ?? []
|
|
4960
5617
|
]);
|
|
4961
|
-
|
|
4962
|
-
...
|
|
4963
|
-
...
|
|
5618
|
+
const sourceSpanIds = uniqueStrings2([
|
|
5619
|
+
...profile.sourceSpanIds,
|
|
5620
|
+
...coverages.flatMap((coverage) => [
|
|
5621
|
+
...coverage.sourceSpanIds,
|
|
5622
|
+
...coverage.limits.flatMap((term) => term.sourceSpanIds)
|
|
5623
|
+
]),
|
|
5624
|
+
...coverageSchedules.flatMap((schedule) => [
|
|
5625
|
+
...schedule.sourceSpanIds,
|
|
5626
|
+
...schedule.items.flatMap((item) => item.sourceSpanIds)
|
|
5627
|
+
]),
|
|
5628
|
+
...premiumBreakdown.flatMap((row) => row.sourceSpanIds),
|
|
5629
|
+
...taxesAndFees.flatMap((row) => row.sourceSpanIds),
|
|
5630
|
+
...totalCost?.sourceSpanIds ?? []
|
|
4964
5631
|
]);
|
|
4965
|
-
return
|
|
5632
|
+
return {
|
|
5633
|
+
operationalProfile: {
|
|
5634
|
+
...profile,
|
|
5635
|
+
coverages,
|
|
5636
|
+
coverageSchedules,
|
|
5637
|
+
premiumBreakdown,
|
|
5638
|
+
taxesAndFees,
|
|
5639
|
+
totalCost,
|
|
5640
|
+
sourceNodeIds,
|
|
5641
|
+
sourceSpanIds,
|
|
5642
|
+
warnings: uniqueStrings2([...profile.warnings, ...warnings])
|
|
5643
|
+
},
|
|
5644
|
+
warnings,
|
|
5645
|
+
recoveredCoverageCount,
|
|
5646
|
+
recoveredTermCount,
|
|
5647
|
+
recoveredScheduleCount: coverageSchedules.length - (profile.coverageSchedules?.length ?? 0),
|
|
5648
|
+
recoveredFinancialFactCount: premiumBreakdown.length - (profile.premiumBreakdown?.length ?? 0) + taxesAndFees.length - (profile.taxesAndFees?.length ?? 0) + (!profile.totalCost && totalCost ? 1 : 0)
|
|
5649
|
+
};
|
|
4966
5650
|
}
|
|
4967
|
-
function
|
|
4968
|
-
const backedValues = [
|
|
4969
|
-
profile.policyNumber,
|
|
4970
|
-
profile.namedInsured,
|
|
4971
|
-
profile.insurer,
|
|
4972
|
-
profile.broker,
|
|
4973
|
-
profile.effectiveDate,
|
|
4974
|
-
profile.expirationDate,
|
|
4975
|
-
profile.retroactiveDate,
|
|
4976
|
-
profile.premium
|
|
4977
|
-
].filter(Boolean);
|
|
5651
|
+
function emptyDiagnostics(status) {
|
|
4978
5652
|
return {
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
...profile.coverages.flatMap((coverage) => coverage.limits.flatMap((term) => term.sourceSpanIds)),
|
|
4990
|
-
...profile.parties.flatMap((party) => party.sourceSpanIds),
|
|
4991
|
-
...profile.endorsementSupport.flatMap((support) => support.sourceSpanIds)
|
|
4992
|
-
])
|
|
5653
|
+
version: COVERAGE_RECOVERY_VERSION,
|
|
5654
|
+
status,
|
|
5655
|
+
regionCount: 0,
|
|
5656
|
+
modelCallCount: 0,
|
|
5657
|
+
recoveredCoverageCount: 0,
|
|
5658
|
+
recoveredTermCount: 0,
|
|
5659
|
+
recoveredScheduleCount: 0,
|
|
5660
|
+
recoveredFinancialFactCount: 0,
|
|
5661
|
+
citationRejectionCount: 0,
|
|
5662
|
+
warnings: []
|
|
4993
5663
|
};
|
|
4994
5664
|
}
|
|
4995
|
-
function
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
5665
|
+
function disabledCoverageRecoveryDiagnostics() {
|
|
5666
|
+
return emptyDiagnostics("disabled");
|
|
5667
|
+
}
|
|
5668
|
+
async function recoverOperationalProfileCoverage(params) {
|
|
5669
|
+
const diagnostics = emptyDiagnostics("succeeded");
|
|
5670
|
+
try {
|
|
5671
|
+
const pages = documentPages(params.sourceTree, params.sourceSpans);
|
|
5672
|
+
const discoveredRegions = [];
|
|
5673
|
+
for (const [batchIndex, pageBatch] of chunkValues(pages, DISCOVERY_PAGE_BATCH_SIZE).entries()) {
|
|
5674
|
+
const sketches = pageBatch.map((page) => pageSketch(page, params.sourceTree, params.sourceSpans));
|
|
5675
|
+
const budget = params.resolveBudget("extraction_coverage_recovery", 8192);
|
|
5676
|
+
const startedAt = Date.now();
|
|
5677
|
+
diagnostics.modelCallCount += 1;
|
|
5678
|
+
const response = await safeGenerateObject(
|
|
5679
|
+
params.generateObject,
|
|
5680
|
+
{
|
|
5681
|
+
prompt: discoveryPrompt(sketches),
|
|
5682
|
+
schema: RecoveryRegionDiscoverySchema,
|
|
5683
|
+
maxTokens: budget.maxTokens,
|
|
5684
|
+
taskKind: "extraction_coverage_recovery",
|
|
5685
|
+
budgetDiagnostics: budget,
|
|
5686
|
+
providerOptions: params.providerOptions,
|
|
5687
|
+
trace: {
|
|
5688
|
+
phase: "coverage_recovery_discovery",
|
|
5689
|
+
label: "coverage_recovery_discovery",
|
|
5690
|
+
startPage: pageBatch[0],
|
|
5691
|
+
endPage: pageBatch[pageBatch.length - 1],
|
|
5692
|
+
batchIndex: batchIndex + 1,
|
|
5693
|
+
batchCount: Math.ceil(pages.length / DISCOVERY_PAGE_BATCH_SIZE),
|
|
5694
|
+
sourceBacked: true
|
|
5695
|
+
}
|
|
5696
|
+
},
|
|
5697
|
+
{ maxRetries: 0, log: params.log, retry: false }
|
|
5698
|
+
);
|
|
5699
|
+
params.trackUsage(response.usage, {
|
|
5700
|
+
taskKind: "extraction_coverage_recovery",
|
|
5701
|
+
label: "coverage_recovery_discovery",
|
|
5702
|
+
maxTokens: budget.maxTokens,
|
|
5703
|
+
durationMs: Date.now() - startedAt
|
|
5704
|
+
});
|
|
5705
|
+
const discovery = response.object;
|
|
5706
|
+
discoveredRegions.push(...discovery.regions);
|
|
5707
|
+
diagnostics.warnings.push(...discovery.warnings);
|
|
5708
|
+
}
|
|
5709
|
+
const regions = splitRegions(normalizeRegions(discoveredRegions, pages));
|
|
5710
|
+
diagnostics.regionCount = regions.length;
|
|
5711
|
+
let operationalProfile = params.operationalProfile;
|
|
5712
|
+
for (const [regionIndex, region] of regions.entries()) {
|
|
5713
|
+
const evidence = regionEvidence(region, params.sourceTree, params.sourceSpans);
|
|
5714
|
+
const batches = evidenceBatches(evidence);
|
|
5715
|
+
const context = priorStructuralContext(region, params.sourceTree, params.sourceSpans);
|
|
5716
|
+
for (const [batchIndex, batch] of batches.entries()) {
|
|
5717
|
+
const budget = params.resolveBudget("extraction_coverage_recovery", 12288);
|
|
5718
|
+
const startedAt = Date.now();
|
|
5719
|
+
diagnostics.modelCallCount += 1;
|
|
5720
|
+
const response = await safeGenerateObject(
|
|
5721
|
+
params.generateObject,
|
|
5722
|
+
{
|
|
5723
|
+
prompt: recoveryPrompt({
|
|
5724
|
+
region,
|
|
5725
|
+
context,
|
|
5726
|
+
evidence: batch,
|
|
5727
|
+
batchIndex: batchIndex + 1,
|
|
5728
|
+
batchCount: batches.length
|
|
5729
|
+
}),
|
|
5730
|
+
schema: CoverageRecoveryCandidateSchema,
|
|
5731
|
+
maxTokens: budget.maxTokens,
|
|
5732
|
+
taskKind: "extraction_coverage_recovery",
|
|
5733
|
+
budgetDiagnostics: budget,
|
|
5734
|
+
providerOptions: params.providerOptions,
|
|
5735
|
+
trace: {
|
|
5736
|
+
phase: "coverage_recovery",
|
|
5737
|
+
label: "coverage_recovery",
|
|
5738
|
+
startPage: region.pageStart,
|
|
5739
|
+
endPage: region.pageEnd,
|
|
5740
|
+
batchIndex: batchIndex + 1,
|
|
5741
|
+
batchCount: batches.length,
|
|
5742
|
+
sourceBacked: true
|
|
5743
|
+
}
|
|
5744
|
+
},
|
|
5745
|
+
{ maxRetries: 0, log: params.log, retry: false }
|
|
5746
|
+
);
|
|
5747
|
+
params.trackUsage(response.usage, {
|
|
5748
|
+
taskKind: "extraction_coverage_recovery",
|
|
5749
|
+
label: `coverage_recovery_${regionIndex + 1}`,
|
|
5750
|
+
maxTokens: budget.maxTokens,
|
|
5751
|
+
durationMs: Date.now() - startedAt
|
|
5752
|
+
});
|
|
5753
|
+
const validated = validateCandidate(
|
|
5754
|
+
response.object,
|
|
5755
|
+
params.sourceTree,
|
|
5756
|
+
params.sourceSpans
|
|
5757
|
+
);
|
|
5758
|
+
diagnostics.citationRejectionCount += validated.citationRejectionCount;
|
|
5759
|
+
const merged = mergeRecoveryCandidate(operationalProfile, validated.candidate, params.sourceSpans);
|
|
5760
|
+
operationalProfile = merged.operationalProfile;
|
|
5761
|
+
diagnostics.recoveredCoverageCount += merged.recoveredCoverageCount;
|
|
5762
|
+
diagnostics.recoveredTermCount += merged.recoveredTermCount;
|
|
5763
|
+
diagnostics.recoveredScheduleCount += merged.recoveredScheduleCount;
|
|
5764
|
+
diagnostics.recoveredFinancialFactCount += merged.recoveredFinancialFactCount;
|
|
5765
|
+
diagnostics.warnings.push(...merged.warnings);
|
|
5766
|
+
}
|
|
5767
|
+
}
|
|
5768
|
+
diagnostics.warnings = uniqueStrings2(diagnostics.warnings);
|
|
5769
|
+
return { operationalProfile, diagnostics };
|
|
5770
|
+
} catch (error) {
|
|
5771
|
+
diagnostics.status = "failed";
|
|
5772
|
+
diagnostics.warnings = uniqueStrings2([
|
|
5773
|
+
...diagnostics.warnings,
|
|
5774
|
+
`Coverage recovery failed: ${error instanceof Error ? error.message : String(error)}`
|
|
5775
|
+
]);
|
|
5776
|
+
await params.log?.(diagnostics.warnings[diagnostics.warnings.length - 1]);
|
|
5777
|
+
return { operationalProfile: params.operationalProfile, diagnostics };
|
|
4999
5778
|
}
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
const
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
coverages,
|
|
5007
|
-
warnings: uniqueStrings([
|
|
5008
|
-
...profile.warnings,
|
|
5009
|
-
...cleanupWarnings.map((warning) => `Operational profile cleanup warning: ${warning}`)
|
|
5010
|
-
])
|
|
5779
|
+
}
|
|
5780
|
+
async function runCoverageRecovery(params) {
|
|
5781
|
+
const tokenUsage = { inputTokens: 0, outputTokens: 0 };
|
|
5782
|
+
const performanceReport = {
|
|
5783
|
+
modelCalls: [],
|
|
5784
|
+
totalModelCallDurationMs: 0
|
|
5011
5785
|
};
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5786
|
+
const recovery = await recoverOperationalProfileCoverage({
|
|
5787
|
+
sourceTree: params.sourceTree,
|
|
5788
|
+
sourceSpans: params.sourceSpans,
|
|
5789
|
+
operationalProfile: params.operationalProfile,
|
|
5790
|
+
generateObject: params.generateObject,
|
|
5791
|
+
providerOptions: params.providerOptions,
|
|
5792
|
+
resolveBudget: (taskKind, hintTokens) => resolveModelBudget({
|
|
5793
|
+
taskKind,
|
|
5794
|
+
hintTokens,
|
|
5795
|
+
modelCapabilities: params.modelCapabilities,
|
|
5796
|
+
constraint: params.modelBudgetConstraint
|
|
5797
|
+
}),
|
|
5798
|
+
trackUsage: (usage, report) => {
|
|
5799
|
+
if (usage) {
|
|
5800
|
+
tokenUsage.inputTokens += usage.inputTokens;
|
|
5801
|
+
tokenUsage.outputTokens += usage.outputTokens;
|
|
5802
|
+
params.onTokenUsage?.(usage);
|
|
5803
|
+
}
|
|
5804
|
+
if (report) {
|
|
5805
|
+
performanceReport.modelCalls.push({
|
|
5806
|
+
...report,
|
|
5807
|
+
usage,
|
|
5808
|
+
usageReported: Boolean(usage)
|
|
5809
|
+
});
|
|
5810
|
+
if (report.durationMs != null) {
|
|
5811
|
+
performanceReport.totalModelCallDurationMs += report.durationMs;
|
|
5812
|
+
}
|
|
5813
|
+
}
|
|
5814
|
+
},
|
|
5815
|
+
log: params.log
|
|
5015
5816
|
});
|
|
5817
|
+
return {
|
|
5818
|
+
...recovery,
|
|
5819
|
+
tokenUsage,
|
|
5820
|
+
performanceReport
|
|
5821
|
+
};
|
|
5016
5822
|
}
|
|
5017
5823
|
|
|
5018
5824
|
// src/extraction/source-tree-extractor.ts
|
|
5019
|
-
var SourceBackedValueForPromptSchema =
|
|
5020
|
-
value:
|
|
5021
|
-
normalizedValue:
|
|
5022
|
-
confidence:
|
|
5023
|
-
sourceNodeIds:
|
|
5024
|
-
sourceSpanIds:
|
|
5025
|
-
});
|
|
5026
|
-
var OperationalAddressForPromptSchema =
|
|
5027
|
-
street1:
|
|
5028
|
-
street2:
|
|
5029
|
-
city:
|
|
5030
|
-
state:
|
|
5031
|
-
zip:
|
|
5032
|
-
country:
|
|
5033
|
-
formatted:
|
|
5034
|
-
});
|
|
5035
|
-
var OperationalDeclarationFactForPromptSchema =
|
|
5036
|
-
field:
|
|
5825
|
+
var SourceBackedValueForPromptSchema = import_zod24.z.object({
|
|
5826
|
+
value: import_zod24.z.string(),
|
|
5827
|
+
normalizedValue: import_zod24.z.string().optional(),
|
|
5828
|
+
confidence: import_zod24.z.enum(["low", "medium", "high"]).optional(),
|
|
5829
|
+
sourceNodeIds: import_zod24.z.array(import_zod24.z.string()),
|
|
5830
|
+
sourceSpanIds: import_zod24.z.array(import_zod24.z.string())
|
|
5831
|
+
});
|
|
5832
|
+
var OperationalAddressForPromptSchema = import_zod24.z.object({
|
|
5833
|
+
street1: import_zod24.z.string().optional(),
|
|
5834
|
+
street2: import_zod24.z.string().optional(),
|
|
5835
|
+
city: import_zod24.z.string().optional(),
|
|
5836
|
+
state: import_zod24.z.string().optional(),
|
|
5837
|
+
zip: import_zod24.z.string().optional(),
|
|
5838
|
+
country: import_zod24.z.string().optional(),
|
|
5839
|
+
formatted: import_zod24.z.string().optional()
|
|
5840
|
+
});
|
|
5841
|
+
var OperationalDeclarationFactForPromptSchema = import_zod24.z.object({
|
|
5842
|
+
field: import_zod24.z.enum([
|
|
5037
5843
|
"namedInsured",
|
|
5038
5844
|
"mailingAddress",
|
|
5039
5845
|
"dba",
|
|
@@ -5048,18 +5854,33 @@ var OperationalDeclarationFactForPromptSchema = import_zod23.z.object({
|
|
|
5048
5854
|
"premium",
|
|
5049
5855
|
"other"
|
|
5050
5856
|
]),
|
|
5051
|
-
label:
|
|
5052
|
-
value:
|
|
5053
|
-
normalizedValue:
|
|
5054
|
-
valueKind:
|
|
5857
|
+
label: import_zod24.z.string().optional(),
|
|
5858
|
+
value: import_zod24.z.string(),
|
|
5859
|
+
normalizedValue: import_zod24.z.string().optional(),
|
|
5860
|
+
valueKind: import_zod24.z.enum(["string", "number", "date", "money", "address", "list", "unknown"]).optional(),
|
|
5861
|
+
address: OperationalAddressForPromptSchema.optional(),
|
|
5862
|
+
confidence: import_zod24.z.enum(["low", "medium", "high"]).optional(),
|
|
5863
|
+
sourceNodeIds: import_zod24.z.array(import_zod24.z.string()),
|
|
5864
|
+
sourceSpanIds: import_zod24.z.array(import_zod24.z.string())
|
|
5865
|
+
});
|
|
5866
|
+
var OperationalPartyForPromptSchema = import_zod24.z.object({
|
|
5867
|
+
role: import_zod24.z.enum([
|
|
5868
|
+
"named_insured",
|
|
5869
|
+
"producer",
|
|
5870
|
+
"broker",
|
|
5871
|
+
"insurer",
|
|
5872
|
+
"carrier",
|
|
5873
|
+
"mga",
|
|
5874
|
+
"administrator"
|
|
5875
|
+
]),
|
|
5876
|
+
name: import_zod24.z.string(),
|
|
5055
5877
|
address: OperationalAddressForPromptSchema.optional(),
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
sourceSpanIds: import_zod23.z.array(import_zod23.z.string())
|
|
5878
|
+
sourceNodeIds: import_zod24.z.array(import_zod24.z.string()),
|
|
5879
|
+
sourceSpanIds: import_zod24.z.array(import_zod24.z.string())
|
|
5059
5880
|
});
|
|
5060
|
-
var OperationalProfilePromptSchema =
|
|
5061
|
-
documentType:
|
|
5062
|
-
linesOfBusiness:
|
|
5881
|
+
var OperationalProfilePromptSchema = import_zod24.z.object({
|
|
5882
|
+
documentType: import_zod24.z.enum(["policy", "quote"]).optional(),
|
|
5883
|
+
linesOfBusiness: import_zod24.z.array(import_zod24.z.string()).optional(),
|
|
5063
5884
|
policyNumber: SourceBackedValueForPromptSchema.optional(),
|
|
5064
5885
|
namedInsured: SourceBackedValueForPromptSchema.optional(),
|
|
5065
5886
|
insurer: SourceBackedValueForPromptSchema.optional(),
|
|
@@ -5068,39 +5889,41 @@ var OperationalProfilePromptSchema = import_zod23.z.object({
|
|
|
5068
5889
|
expirationDate: SourceBackedValueForPromptSchema.optional(),
|
|
5069
5890
|
retroactiveDate: SourceBackedValueForPromptSchema.optional(),
|
|
5070
5891
|
premium: SourceBackedValueForPromptSchema.optional(),
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
|
|
5892
|
+
operationsDescription: SourceBackedValueForPromptSchema.optional(),
|
|
5893
|
+
declarationFacts: import_zod24.z.array(OperationalDeclarationFactForPromptSchema).optional(),
|
|
5894
|
+
parties: import_zod24.z.array(OperationalPartyForPromptSchema).optional(),
|
|
5895
|
+
coverages: import_zod24.z.array(import_zod24.z.object({
|
|
5896
|
+
name: import_zod24.z.string(),
|
|
5897
|
+
lineOfBusiness: import_zod24.z.string().optional(),
|
|
5898
|
+
coverageCode: import_zod24.z.string().optional(),
|
|
5899
|
+
limit: import_zod24.z.string().optional(),
|
|
5900
|
+
deductible: import_zod24.z.string().optional(),
|
|
5901
|
+
premium: import_zod24.z.string().optional(),
|
|
5902
|
+
retroactiveDate: import_zod24.z.string().optional(),
|
|
5903
|
+
formNumber: import_zod24.z.string().optional(),
|
|
5904
|
+
sectionRef: import_zod24.z.string().optional(),
|
|
5905
|
+
endorsementNumber: import_zod24.z.string().optional(),
|
|
5906
|
+
limits: import_zod24.z.array(import_zod24.z.object({
|
|
5084
5907
|
kind: OperationalCoverageTermKindSchema.optional(),
|
|
5085
|
-
label:
|
|
5086
|
-
value:
|
|
5087
|
-
amount:
|
|
5088
|
-
appliesTo:
|
|
5089
|
-
sourceNodeIds:
|
|
5090
|
-
sourceSpanIds:
|
|
5908
|
+
label: import_zod24.z.string(),
|
|
5909
|
+
value: import_zod24.z.string(),
|
|
5910
|
+
amount: import_zod24.z.number().optional(),
|
|
5911
|
+
appliesTo: import_zod24.z.string().optional(),
|
|
5912
|
+
sourceNodeIds: import_zod24.z.array(import_zod24.z.string()),
|
|
5913
|
+
sourceSpanIds: import_zod24.z.array(import_zod24.z.string())
|
|
5091
5914
|
})).optional(),
|
|
5092
|
-
sourceNodeIds:
|
|
5093
|
-
sourceSpanIds:
|
|
5915
|
+
sourceNodeIds: import_zod24.z.array(import_zod24.z.string()),
|
|
5916
|
+
sourceSpanIds: import_zod24.z.array(import_zod24.z.string())
|
|
5094
5917
|
})).optional(),
|
|
5095
|
-
sourceNodeIds:
|
|
5096
|
-
sourceSpanIds:
|
|
5918
|
+
sourceNodeIds: import_zod24.z.array(import_zod24.z.string()).optional(),
|
|
5919
|
+
sourceSpanIds: import_zod24.z.array(import_zod24.z.string()).optional()
|
|
5097
5920
|
});
|
|
5098
|
-
function
|
|
5921
|
+
function cleanText2(value, fallback) {
|
|
5099
5922
|
const text = value?.replace(/\s+/g, " ").trim();
|
|
5100
5923
|
return text || fallback;
|
|
5101
5924
|
}
|
|
5102
5925
|
function simplifyOrganizerTitle(value, fallback, kind) {
|
|
5103
|
-
const title =
|
|
5926
|
+
const title = cleanText2(value, fallback);
|
|
5104
5927
|
if (/^declarations\b/i.test(title)) return "Declarations";
|
|
5105
5928
|
if (/^policy\s+form\b/i.test(title)) return "Policy Form";
|
|
5106
5929
|
if (/^definitions\b/i.test(title)) return "Definitions";
|
|
@@ -5113,23 +5936,23 @@ function simplifyOrganizerTitle(value, fallback, kind) {
|
|
|
5113
5936
|
return title;
|
|
5114
5937
|
}
|
|
5115
5938
|
function endorsementReference(value) {
|
|
5116
|
-
const text =
|
|
5939
|
+
const text = cleanText2(value, "");
|
|
5117
5940
|
const explicit = text.match(/\bendorsement\s+(?:no\.?|number|#)?\s*([A-Z0-9][A-Z0-9.-]*)\b/i)?.[1]?.toUpperCase();
|
|
5118
5941
|
if (explicit) return explicit;
|
|
5119
5942
|
return text.match(/\b(?:[A-Z]{2,}-)?END\s+0*([0-9]{1,4})\b/i)?.[1]?.toUpperCase();
|
|
5120
5943
|
}
|
|
5121
5944
|
function endorsementTitle(value) {
|
|
5122
|
-
const text =
|
|
5945
|
+
const text = cleanText2(value, "");
|
|
5123
5946
|
const explicit = text.match(/\bendorsement\s+(?:no\.?|number|#)\s*([A-Z0-9][A-Z0-9.-]*)\b/i)?.[1]?.toUpperCase();
|
|
5124
5947
|
const number = explicit ?? text.match(/\b(?:[A-Z]{2,}-)?END\s+0*([0-9]{1,4})\b/i)?.[1]?.toUpperCase();
|
|
5125
5948
|
return number ? `Endorsement No. ${number}` : void 0;
|
|
5126
5949
|
}
|
|
5127
5950
|
function sourceNodeText(node) {
|
|
5128
|
-
return
|
|
5951
|
+
return cleanText2([node.title, node.description, node.textExcerpt].filter(Boolean).join(" "), "");
|
|
5129
5952
|
}
|
|
5130
5953
|
function looksLikeEndorsementStart(node) {
|
|
5131
|
-
const title =
|
|
5132
|
-
const body =
|
|
5954
|
+
const title = cleanText2(node.title, "");
|
|
5955
|
+
const body = cleanText2([node.textExcerpt, node.description].filter(Boolean).join(" "), "");
|
|
5133
5956
|
const start = body.slice(0, 260);
|
|
5134
5957
|
if (/\bthis endorsement changes the policy\b/i.test(start) && endorsementReference(start)) return true;
|
|
5135
5958
|
if (/^(?:[A-Z]{2,}-)?END\s+0*[0-9]{1,4}\b/i.test(start)) return true;
|
|
@@ -5138,7 +5961,7 @@ function looksLikeEndorsementStart(node) {
|
|
|
5138
5961
|
}
|
|
5139
5962
|
function looksLikeEndorsementContinuation(node) {
|
|
5140
5963
|
if (looksLikeEndorsementStart(node)) return false;
|
|
5141
|
-
const title =
|
|
5964
|
+
const title = cleanText2(node.title, "");
|
|
5142
5965
|
const text = sourceNodeText(node);
|
|
5143
5966
|
return /\bendorsement\b/i.test(text) || /\bcontinuation\b/i.test(title) || /\ball\s+other\s+terms\s+and\s+conditions\b/i.test(text);
|
|
5144
5967
|
}
|
|
@@ -5146,7 +5969,7 @@ function endorsementStartTitle(node) {
|
|
|
5146
5969
|
return looksLikeEndorsementStart(node) ? endorsementTitle(sourceNodeText(node)) : void 0;
|
|
5147
5970
|
}
|
|
5148
5971
|
function endorsementDescription(title, node) {
|
|
5149
|
-
return
|
|
5972
|
+
return cleanText2(
|
|
5150
5973
|
[title, "endorsement", node.pageStart ? `page ${node.pageStart}` : void 0].filter(Boolean).join(" | "),
|
|
5151
5974
|
title
|
|
5152
5975
|
);
|
|
@@ -5154,7 +5977,7 @@ function endorsementDescription(title, node) {
|
|
|
5154
5977
|
function endorsementTitleKey(node) {
|
|
5155
5978
|
const title = endorsementTitle(sourceNodeText(node));
|
|
5156
5979
|
if (title) return title.toLowerCase();
|
|
5157
|
-
const fallback =
|
|
5980
|
+
const fallback = cleanText2(node.title, "");
|
|
5158
5981
|
return fallback ? fallback.toLowerCase() : void 0;
|
|
5159
5982
|
}
|
|
5160
5983
|
function nodePageEnd2(node) {
|
|
@@ -5198,17 +6021,17 @@ function semanticGroupNodeId(documentId, kind, title, childNodeIds) {
|
|
|
5198
6021
|
childNodeIds.join("_").replace(/[^a-zA-Z0-9_.:-]/g, "_").slice(0, 80)
|
|
5199
6022
|
].join(":");
|
|
5200
6023
|
}
|
|
5201
|
-
function
|
|
6024
|
+
function spanPageStart2(span) {
|
|
5202
6025
|
return span.pageStart ?? span.location?.page ?? span.location?.startPage;
|
|
5203
6026
|
}
|
|
5204
|
-
function
|
|
5205
|
-
return span.pageEnd ?? span.location?.endPage ??
|
|
6027
|
+
function spanPageEnd2(span) {
|
|
6028
|
+
return span.pageEnd ?? span.location?.endPage ?? spanPageStart2(span);
|
|
5206
6029
|
}
|
|
5207
|
-
function
|
|
6030
|
+
function spanSourceUnit2(span) {
|
|
5208
6031
|
return span.sourceUnit ?? span.metadata?.sourceUnit ?? span.metadata?.elementType;
|
|
5209
6032
|
}
|
|
5210
6033
|
function pageHeadingTitleFromText(text, fallback) {
|
|
5211
|
-
const normalized =
|
|
6034
|
+
const normalized = cleanText2(text, "");
|
|
5212
6035
|
const headingText = normalized.replace(/^page\s+\d+\s*(?:\|\s*page\s*\|\s*page\s+\d+\s*\|?)?/i, "").slice(0, 700);
|
|
5213
6036
|
const patterns = [
|
|
5214
6037
|
/\bIMPORTANT NOTICE\s+[—-]\s+HOW TO REPORT A CLAIM\b/i,
|
|
@@ -5222,7 +6045,7 @@ function pageHeadingTitleFromText(text, fallback) {
|
|
|
5222
6045
|
];
|
|
5223
6046
|
for (const pattern of patterns) {
|
|
5224
6047
|
const match = headingText.match(pattern)?.[0];
|
|
5225
|
-
if (match) return
|
|
6048
|
+
if (match) return cleanText2(match, fallback);
|
|
5226
6049
|
}
|
|
5227
6050
|
return fallback;
|
|
5228
6051
|
}
|
|
@@ -5230,12 +6053,12 @@ function hasSubstantiveDeclarationsScheduleText(text) {
|
|
|
5230
6053
|
return /\bitem\s+\d+\.?\s*(?:named insured|policy number|policy period|renewal|form of business|coverage parts?|limits?|premium|extended reporting|producer|forms? and endorsements?)\b/i.test(text) || /\bforms? and endorsements attached at inception\b/i.test(text) || /\bcoverage parts?,?\s+limits? of liability,?\s+deductibles?,?\s+and retroactive dates\b/i.test(text) || /\bannual premium\s*\(all coverage parts?\)\b/i.test(text) || /\berp option\b/i.test(text) || /\bproducer\b[\s\S]{0,240}\blicense\b/i.test(text);
|
|
5231
6054
|
}
|
|
5232
6055
|
function looksLikeDeclarationsStart(node) {
|
|
5233
|
-
const title =
|
|
6056
|
+
const title = cleanText2(node.title, "");
|
|
5234
6057
|
const text = sourceNodeText(node);
|
|
5235
6058
|
if (/\b(important notice|privacy notice|ofac advisory|terrorism risk insurance act|how to report a claim)\b/i.test(text)) {
|
|
5236
6059
|
return false;
|
|
5237
6060
|
}
|
|
5238
|
-
return /^declarations?$/i.test(title) || /\bdeclarations?\s+(page|schedule|section)\b/i.test(text) || /^declarations?\b/i.test(
|
|
6061
|
+
return /^declarations?$/i.test(title) || /\bdeclarations?\s+(page|schedule|section)\b/i.test(text) || /^declarations?\b/i.test(cleanText2(node.textExcerpt, ""));
|
|
5239
6062
|
}
|
|
5240
6063
|
function looksLikeDeclarationsContinuation(node) {
|
|
5241
6064
|
const text = sourceNodeText(node);
|
|
@@ -5243,7 +6066,7 @@ function looksLikeDeclarationsContinuation(node) {
|
|
|
5243
6066
|
}
|
|
5244
6067
|
function looksLikePolicyFormStart(node) {
|
|
5245
6068
|
const text = sourceNodeText(node);
|
|
5246
|
-
const excerpt =
|
|
6069
|
+
const excerpt = cleanText2(node.textExcerpt, "");
|
|
5247
6070
|
if (isAdministrativeNoticeNode(node) || looksLikeDeclarationsStart(node)) return false;
|
|
5248
6071
|
return /\bpolicy form\b/i.test(node.title) || /^policy\s+form\b/i.test(excerpt) || /\btechnology errors?\s*&?\s*omissions\b/i.test(text) && /\bplease read this entire policy carefully\b/i.test(text) || /\bsection\s+[IVX0-9]+\s*[—-]\s*(insuring agreements?|definitions?|exclusions?|conditions?)\b/i.test(text) || /\bform\s+[A-Z]{2,}-[A-Z0-9-]+\s+\d{2}\s+\d{2}\b/i.test(text);
|
|
5249
6072
|
}
|
|
@@ -5332,7 +6155,7 @@ function applySemanticPageGrouping(sourceTree) {
|
|
|
5332
6155
|
return {
|
|
5333
6156
|
...nextNode,
|
|
5334
6157
|
title: "Declarations",
|
|
5335
|
-
description:
|
|
6158
|
+
description: cleanText2([nextNode.description, "Declarations"].join(" "), "Declarations"),
|
|
5336
6159
|
metadata: { ...nextNode.metadata, organizerRepair: "semantic_page_grouping" }
|
|
5337
6160
|
};
|
|
5338
6161
|
}
|
|
@@ -5340,7 +6163,7 @@ function applySemanticPageGrouping(sourceTree) {
|
|
|
5340
6163
|
return {
|
|
5341
6164
|
...nextNode,
|
|
5342
6165
|
title: "Policy Form",
|
|
5343
|
-
description:
|
|
6166
|
+
description: cleanText2([nextNode.description, "Policy Form"].join(" "), "Policy Form"),
|
|
5344
6167
|
metadata: { ...nextNode.metadata, organizerRepair: "semantic_page_grouping" }
|
|
5345
6168
|
};
|
|
5346
6169
|
}
|
|
@@ -5608,7 +6431,7 @@ function isTitleBlockNode(node) {
|
|
|
5608
6431
|
return metadataText(node, "organizer") === "title_block" || metadataText(node, "elementType") === "title" || metadataText(node, "sourceUnit") === "title";
|
|
5609
6432
|
}
|
|
5610
6433
|
function isRejectableSectionHeading(text, container) {
|
|
5611
|
-
const normalized =
|
|
6434
|
+
const normalized = cleanText2(text, "");
|
|
5612
6435
|
if (!normalized) return true;
|
|
5613
6436
|
if (normalized.length > 160) return true;
|
|
5614
6437
|
if (/^page\s+\d+$/i.test(normalized)) return true;
|
|
@@ -5624,7 +6447,7 @@ function isRejectableSectionHeading(text, container) {
|
|
|
5624
6447
|
}
|
|
5625
6448
|
function sectionHeadingTitle(node, container) {
|
|
5626
6449
|
if (!isTitleBlockNode(node)) return void 0;
|
|
5627
|
-
const text =
|
|
6450
|
+
const text = cleanText2(node.title || node.textExcerpt, "");
|
|
5628
6451
|
if (isRejectableSectionHeading(text, container)) return void 0;
|
|
5629
6452
|
const words = text.split(/\s+/);
|
|
5630
6453
|
if (words.length > 18) return void 0;
|
|
@@ -5698,7 +6521,7 @@ function applyTitleSectionHierarchy(sourceTree) {
|
|
|
5698
6521
|
parentId: container.id,
|
|
5699
6522
|
kind: sectionKindForTitle(heading),
|
|
5700
6523
|
title: heading,
|
|
5701
|
-
description: descriptionWithPages(
|
|
6524
|
+
description: descriptionWithPages(cleanText2([heading, "section"].join(" "), heading), [current, ...descendants]),
|
|
5702
6525
|
metadata: {
|
|
5703
6526
|
...current.metadata,
|
|
5704
6527
|
organizer: "title_section",
|
|
@@ -5746,7 +6569,7 @@ function applyEndorsementGrouping(sourceTree) {
|
|
|
5746
6569
|
return {
|
|
5747
6570
|
...node,
|
|
5748
6571
|
kind: "page",
|
|
5749
|
-
title: node.pageStart ? `Page ${node.pageStart}` :
|
|
6572
|
+
title: node.pageStart ? `Page ${node.pageStart}` : cleanText2(node.title, "Page"),
|
|
5750
6573
|
metadata: {
|
|
5751
6574
|
...node.metadata,
|
|
5752
6575
|
organizerRepair: "demote_incidental_endorsement_reference"
|
|
@@ -5776,7 +6599,7 @@ function applyEndorsementGrouping(sourceTree) {
|
|
|
5776
6599
|
...node,
|
|
5777
6600
|
kind: "page_group",
|
|
5778
6601
|
title: "Endorsements",
|
|
5779
|
-
description: descriptionWithPages(
|
|
6602
|
+
description: descriptionWithPages(cleanText2(node.description, "Endorsement forms grouped by source order"), byParent.get(node.id) ?? [node]),
|
|
5780
6603
|
metadata: {
|
|
5781
6604
|
...node.metadata,
|
|
5782
6605
|
sourceTreeVersion: "v3",
|
|
@@ -5955,7 +6778,7 @@ function nodesByParent(sourceTree) {
|
|
|
5955
6778
|
}
|
|
5956
6779
|
return byParent;
|
|
5957
6780
|
}
|
|
5958
|
-
function
|
|
6781
|
+
function sourceNodeIdsBySpanId2(sourceTree) {
|
|
5959
6782
|
const bySpan = /* @__PURE__ */ new Map();
|
|
5960
6783
|
for (const node of sourceTree) {
|
|
5961
6784
|
for (const spanId of node.sourceSpanIds) {
|
|
@@ -5967,7 +6790,7 @@ function sourceNodeIdsBySpanId(sourceTree) {
|
|
|
5967
6790
|
return bySpan;
|
|
5968
6791
|
}
|
|
5969
6792
|
function operationalEvidenceScore(span) {
|
|
5970
|
-
const text =
|
|
6793
|
+
const text = cleanText2([
|
|
5971
6794
|
span.text,
|
|
5972
6795
|
span.formNumber,
|
|
5973
6796
|
span.sourceUnit,
|
|
@@ -5980,6 +6803,9 @@ function operationalEvidenceScore(span) {
|
|
|
5980
6803
|
if (span.metadata?.elementType === "title") score += 4;
|
|
5981
6804
|
if (span.sourceUnit === "page") score -= 3;
|
|
5982
6805
|
if (/\b(policy\s*(number|period|term)|effective date|expiration date|expiry date|named insured|insurer|carrier|security|broker|producer|premium|total due)\b/i.test(text)) score += 12;
|
|
6806
|
+
if (/\b(mailing address|business address|address|managing general (?:agent|underwriter)|mga|administrator|description of operations|operations description|nature of business|business description)\b/i.test(text)) score += 12;
|
|
6807
|
+
if (/\b\d{1,6}\s+[A-Z0-9][^\n,]{1,80}\b(?:street|st|avenue|ave|road|rd|boulevard|blvd|drive|dr|lane|ln|way|court|ct|highway|hwy)\b/i.test(text)) score += 10;
|
|
6808
|
+
if (/\b[A-Za-z][A-Za-z .'-]+,\s*[A-Z]{2}\s+\d{5}(?:-\d{4})?\b/.test(text)) score += 10;
|
|
5983
6809
|
if (/\b(coverage part|limit(?:s)? of liability|deductible|retention|retroactive date|aggregate|sublimit|sub-limit|each claim|each loss|each occurrence|coinsurance)\b/i.test(text)) score += 14;
|
|
5984
6810
|
if (/\bendorsement\s+(?:no\.?|number|#)?\s*[A-Z0-9]|forms? and endorsements?|attached at inception|schedule\b/i.test(text)) score += 8;
|
|
5985
6811
|
if (/\bitem\s+\d+\.?\s*(?:named insured|policy number|policy period|renewal|form of business|coverage parts?|premium|extended reporting|producer|forms? and endorsements?)\b/i.test(text)) score += 10;
|
|
@@ -5990,19 +6816,22 @@ function spanTableId(span) {
|
|
|
5990
6816
|
return span.table?.tableId ?? span.metadata?.tableId;
|
|
5991
6817
|
}
|
|
5992
6818
|
function isTableCellSpan(span) {
|
|
5993
|
-
return
|
|
6819
|
+
return spanSourceUnit2(span) === "table_cell";
|
|
5994
6820
|
}
|
|
5995
6821
|
function isOperationalEvidenceAnchor(span) {
|
|
5996
|
-
const sourceUnit3 =
|
|
6822
|
+
const sourceUnit3 = spanSourceUnit2(span);
|
|
5997
6823
|
if (sourceUnit3 === "table_cell") return false;
|
|
5998
6824
|
if (sourceUnit3 === "table" || sourceUnit3 === "table_row") return true;
|
|
5999
|
-
const text =
|
|
6825
|
+
const text = cleanText2([span.text, span.formNumber].filter(Boolean).join(" "), "");
|
|
6000
6826
|
if (!text) return false;
|
|
6001
6827
|
if (sourceUnit3 === "page") {
|
|
6002
|
-
return hasSubstantiveDeclarationsScheduleText(text) || /\b(declarations?|named insured|policy number|policy period|effective date|expiration date|premium|total due|producer)\b/i.test(text);
|
|
6828
|
+
return hasSubstantiveDeclarationsScheduleText(text) || /\b(declarations?|named insured|policy number|policy period|effective date|expiration date|premium|total due|producer|mailing address|mga|administrator|description of operations|nature of business|business description)\b/i.test(text);
|
|
6003
6829
|
}
|
|
6004
6830
|
if (/\bitem\s+\d+\.?\s*(?:named insured|policy number|policy period|renewal|form of business|coverage parts?|premium|extended reporting|producer|forms? and endorsements?)\b/i.test(text)) return true;
|
|
6005
6831
|
if (/\b(policy\s*(number|period)|effective date|expiration date|expiry date|named insured|insurer|carrier|broker|producer|premium|total due)\b/i.test(text)) return true;
|
|
6832
|
+
if (/\b(mailing address|business address|address|managing general (?:agent|underwriter)|mga|administrator|description of operations|operations description|nature of business|business description)\b/i.test(text)) return true;
|
|
6833
|
+
if (/\b\d{1,6}\s+[A-Z0-9][^\n,]{1,80}\b(?:street|st|avenue|ave|road|rd|boulevard|blvd|drive|dr|lane|ln|way|court|ct|highway|hwy)\b/i.test(text)) return true;
|
|
6834
|
+
if (/\b[A-Za-z][A-Za-z .'-]+,\s*[A-Z]{2}\s+\d{5}(?:-\d{4})?\b/.test(text)) return true;
|
|
6006
6835
|
if (/\b(coverage part|forms? and endorsements?|attached at inception|endorsement\s+(?:no\.?|number|#)?\s*[A-Z0-9])\b/i.test(text)) return true;
|
|
6007
6836
|
if (/\$[\d,.]+|[0-9]{1,2}\/[0-9]{1,2}\/[0-9]{2,4}|[0-9]{1,2}\s+[A-Za-z]{3,9}\s+[0-9]{4}/.test(text)) return true;
|
|
6008
6837
|
return false;
|
|
@@ -6010,9 +6839,9 @@ function isOperationalEvidenceAnchor(span) {
|
|
|
6010
6839
|
function operationalEvidencePages(sourceSpans) {
|
|
6011
6840
|
const scores = /* @__PURE__ */ new Map();
|
|
6012
6841
|
for (const span of sourceSpans) {
|
|
6013
|
-
const page =
|
|
6842
|
+
const page = spanPageStart2(span);
|
|
6014
6843
|
if (typeof page !== "number") continue;
|
|
6015
|
-
const text =
|
|
6844
|
+
const text = cleanText2([span.text, span.formNumber, spanSourceUnit2(span)].filter(Boolean).join(" "), "");
|
|
6016
6845
|
if (!text) continue;
|
|
6017
6846
|
let score = Math.max(0, operationalEvidenceScore(span));
|
|
6018
6847
|
if (/\bdeclarations?\s+(page|schedule)?\b/i.test(text)) score += 24;
|
|
@@ -6020,6 +6849,7 @@ function operationalEvidencePages(sourceSpans) {
|
|
|
6020
6849
|
if (/\bcoverage parts?,?\s+limits? of liability,?\s+deductibles?,?\s+and retroactive dates\b/i.test(text)) score += 24;
|
|
6021
6850
|
if (/\b(policy\s*(number|period|term)|effective date|expiration date|expiry date|named insured|insurer|carrier|security)\b/i.test(text)) score += 12;
|
|
6022
6851
|
if (/\b(premium|total due|tax|fee|producer|broker)\b/i.test(text)) score += 10;
|
|
6852
|
+
if (/\b(mailing address|business address|managing general (?:agent|underwriter)|mga|administrator|description of operations|operations description|nature of business|business description)\b/i.test(text)) score += 16;
|
|
6023
6853
|
if (/\b(endorsement\s+(?:no\.?|number|#)?\s*[A-Z0-9]|attached at inception|forms? and endorsements?)\b/i.test(text)) score += 8;
|
|
6024
6854
|
if (/\b(definitions?|exclusions?|conditions?|duties in the event|action against|cancellation by)\b/i.test(text)) score -= 12;
|
|
6025
6855
|
if (score > 0) scores.set(page, (scores.get(page) ?? 0) + score);
|
|
@@ -6030,7 +6860,7 @@ function operationalEvidencePages(sourceSpans) {
|
|
|
6030
6860
|
}
|
|
6031
6861
|
function operationalProfileEvidence(sourceTree, sourceSpans) {
|
|
6032
6862
|
const sorted = [...sourceSpans].sort(
|
|
6033
|
-
(left, right) => (
|
|
6863
|
+
(left, right) => (spanPageStart2(left) ?? Number.MAX_SAFE_INTEGER) - (spanPageStart2(right) ?? Number.MAX_SAFE_INTEGER) || (left.location?.charStart ?? Number.MAX_SAFE_INTEGER) - (right.location?.charStart ?? Number.MAX_SAFE_INTEGER) || left.id.localeCompare(right.id)
|
|
6034
6864
|
);
|
|
6035
6865
|
const selectedPages = operationalEvidencePages(sorted);
|
|
6036
6866
|
const selected = /* @__PURE__ */ new Set();
|
|
@@ -6040,7 +6870,7 @@ function operationalProfileEvidence(sourceTree, sourceSpans) {
|
|
|
6040
6870
|
const score = operationalEvidenceScore(span);
|
|
6041
6871
|
if (score < 8) continue;
|
|
6042
6872
|
if (!isOperationalEvidenceAnchor(span)) continue;
|
|
6043
|
-
const page =
|
|
6873
|
+
const page = spanPageStart2(span);
|
|
6044
6874
|
if (selectedPages.size > 0 && typeof page === "number" && !selectedPages.has(page) && score < 30) continue;
|
|
6045
6875
|
const tableId2 = spanTableId(span);
|
|
6046
6876
|
if (tableId2 && !isTableCellSpan(span)) selectedTableIds.add(tableId2);
|
|
@@ -6048,9 +6878,9 @@ function operationalProfileEvidence(sourceTree, sourceSpans) {
|
|
|
6048
6878
|
for (let offset = -neighborWindow; offset <= neighborWindow; offset += 1) {
|
|
6049
6879
|
const neighborIndex = index + offset;
|
|
6050
6880
|
const neighbor = sorted[neighborIndex];
|
|
6051
|
-
if (!neighbor ||
|
|
6881
|
+
if (!neighbor || spanPageStart2(neighbor) !== page) continue;
|
|
6052
6882
|
if (selectedPages.size > 0 && typeof page === "number" && !selectedPages.has(page) && operationalEvidenceScore(neighbor) < 30) continue;
|
|
6053
|
-
const neighborText =
|
|
6883
|
+
const neighborText = cleanText2(neighbor.text, "");
|
|
6054
6884
|
if (!neighborText || neighborText.length > 3e3) continue;
|
|
6055
6885
|
selected.add(neighborIndex);
|
|
6056
6886
|
}
|
|
@@ -6059,31 +6889,31 @@ function operationalProfileEvidence(sourceTree, sourceSpans) {
|
|
|
6059
6889
|
sorted.forEach((span, index) => {
|
|
6060
6890
|
const tableId2 = spanTableId(span);
|
|
6061
6891
|
if (!tableId2 || !selectedTableIds.has(tableId2) || isTableCellSpan(span)) return;
|
|
6062
|
-
const text =
|
|
6892
|
+
const text = cleanText2(span.text, "");
|
|
6063
6893
|
if (text && text.length <= 3e3) selected.add(index);
|
|
6064
6894
|
});
|
|
6065
6895
|
}
|
|
6066
|
-
const nodeIdsBySpanId =
|
|
6896
|
+
const nodeIdsBySpanId = sourceNodeIdsBySpanId2(sourceTree);
|
|
6067
6897
|
const seenText = /* @__PURE__ */ new Set();
|
|
6068
6898
|
const entries = [...selected].sort((left, right) => left - right).map((index) => sorted[index]).filter((span) => !isTableCellSpan(span)).flatMap((span) => {
|
|
6069
|
-
const text =
|
|
6899
|
+
const text = cleanText2(span.text, "");
|
|
6070
6900
|
if (!text) return [];
|
|
6071
|
-
const key = `${
|
|
6901
|
+
const key = `${spanPageStart2(span) ?? "na"}:${text.toLowerCase().slice(0, 240)}`;
|
|
6072
6902
|
if (seenText.has(key)) return [];
|
|
6073
6903
|
seenText.add(key);
|
|
6074
6904
|
return [{
|
|
6075
6905
|
sourceSpanId: span.id,
|
|
6076
6906
|
sourceNodeIds: [...new Set(nodeIdsBySpanId.get(span.id) ?? [])].slice(0, 4),
|
|
6077
|
-
pageStart:
|
|
6078
|
-
pageEnd:
|
|
6079
|
-
sourceUnit:
|
|
6907
|
+
pageStart: spanPageStart2(span),
|
|
6908
|
+
pageEnd: spanPageEnd2(span),
|
|
6909
|
+
sourceUnit: spanSourceUnit2(span),
|
|
6080
6910
|
formNumber: span.formNumber,
|
|
6081
6911
|
text: text.slice(0, span.sourceUnit === "page" ? 900 : 700)
|
|
6082
6912
|
}];
|
|
6083
6913
|
});
|
|
6084
6914
|
const detailEntries = entries.filter((entry) => entry.sourceUnit !== "page");
|
|
6085
6915
|
const pageEntries = entries.filter((entry) => entry.sourceUnit === "page");
|
|
6086
|
-
return [...detailEntries
|
|
6916
|
+
return [...detailEntries, ...pageEntries];
|
|
6087
6917
|
}
|
|
6088
6918
|
function sourceTreeRootId(sourceTree) {
|
|
6089
6919
|
return sourceTree.find((node) => node.kind === "document")?.id;
|
|
@@ -6094,7 +6924,7 @@ function operationalProfilePromptNodes(sourceTree) {
|
|
|
6094
6924
|
return true;
|
|
6095
6925
|
}
|
|
6096
6926
|
const text = [node.title, node.path, node.description, node.textExcerpt].filter(Boolean).join(" ");
|
|
6097
|
-
return /\b(policy\s*(number|period)|named insured|insurer|carrier|broker|producer|premium|coverage|limit|liability|deductible|retention|retroactive|aggregate|sublimit|sub-limit|endorsement)\b/i.test(text);
|
|
6927
|
+
return /\b(policy\s*(number|period)|named insured|insurer|carrier|broker|producer|managing general (?:agent|underwriter)|mga|administrator|mailing address|description of operations|operations description|nature of business|business description|premium|coverage|limit|liability|deductible|retention|retroactive|aggregate|sublimit|sub-limit|endorsement)\b/i.test(text);
|
|
6098
6928
|
}).slice(0, 420);
|
|
6099
6929
|
}
|
|
6100
6930
|
function emptyOperationalProfile() {
|
|
@@ -6103,6 +6933,9 @@ function emptyOperationalProfile() {
|
|
|
6103
6933
|
linesOfBusiness: ["UN"],
|
|
6104
6934
|
declarationFacts: [],
|
|
6105
6935
|
coverages: [],
|
|
6936
|
+
coverageSchedules: [],
|
|
6937
|
+
premiumBreakdown: [],
|
|
6938
|
+
taxesAndFees: [],
|
|
6106
6939
|
parties: [],
|
|
6107
6940
|
endorsementSupport: [],
|
|
6108
6941
|
sourceNodeIds: [],
|
|
@@ -6118,7 +6951,8 @@ function buildOperationalProfilePrompt(sourceTree, sourceSpans) {
|
|
|
6118
6951
|
return `Extract a source-backed operational profile for an insurance policy.
|
|
6119
6952
|
|
|
6120
6953
|
Return only high-value operational facts needed for policy lists, Q&A, compliance, and certificate generation:
|
|
6121
|
-
- policy number, named insured, insurer/carrier/security, broker/producer, policy period, retroactive date, premium
|
|
6954
|
+
- policy number, named insured, insurer/carrier/security, broker/producer, policy period, retroactive date, premium, and the insured's description of operations
|
|
6955
|
+
- parties[] rows for named insured, producer/broker, insurer/carrier, and MGA/administrator identities and their mailing addresses
|
|
6122
6956
|
- source-backed declarationFacts for named-insured identity details: named insured, mailing address, DBA, entity type, tax ID/FEIN, additional named insureds, and other durable declaration-page identity facts
|
|
6123
6957
|
- coverage units with their own nested limit terms, deductibles/retentions, retroactive dates, premiums, and form references
|
|
6124
6958
|
- coverage type labels
|
|
@@ -6130,6 +6964,9 @@ Rules:
|
|
|
6130
6964
|
- If a value is not directly supported, omit it.
|
|
6131
6965
|
- Prefer declarations, schedules, premium tables, and endorsement schedules over generic policy wording.
|
|
6132
6966
|
- Put named-insured mailing address in declarationFacts[] with field "mailingAddress", valueKind "address", a user-facing value string, and structured address fields when present. Do not put producer, broker, insurer, mortgagee, loss-payee, or certificate-holder addresses in mailingAddress.
|
|
6967
|
+
- Put every source-backed policy party in parties[] using only these canonical roles: "named_insured", "producer", "broker", "insurer", "carrier", "mga", or "administrator". Keep producer/broker, insurer/carrier, and MGA/administrator addresses policy-scoped in parties[]; never represent them as the named-insured mailingAddress declaration fact.
|
|
6968
|
+
- When a party's address is present, return its available street1, street2, city, state, zip, country, and formatted parts under parties[].address. Partial addresses are allowed in parties[], but never guess a missing component. The party row must cite the source node or source span that supports both the identity and address.
|
|
6969
|
+
- Put the insured's directly stated business or operations description in operationsDescription. Do not synthesize it from coverages, industry inference, website research, or generic policy wording.
|
|
6133
6970
|
- Put DBA or trade name in declarationFacts[] with field "dba"; entity/legal form in field "entityType"; FEIN/tax ID in field "taxId"; each additional named insured in field "additionalNamedInsured".
|
|
6134
6971
|
- For effective, expiration, retroactive, and other date fields, return a normalized YYYY-MM-DD value when the source date is unambiguous, including month-name dates such as "20 Feb 2026". Do not emit fragmented date text such as "20 2 2026".
|
|
6135
6972
|
- For broker/producer, extract the agency or company legal name, not the license role, credential, or type. In a block like "Bayshore Insurance Brokers, LLC" followed by "Surplus Lines Broker - CA License No. ...", broker.value must be "Bayshore Insurance Brokers, LLC"; the surplus-lines role and license number are not the broker name.
|
|
@@ -6199,13 +7036,6 @@ function valueOf(profile, key) {
|
|
|
6199
7036
|
}
|
|
6200
7037
|
return String(value.value);
|
|
6201
7038
|
}
|
|
6202
|
-
function provenanceOf(value) {
|
|
6203
|
-
if (!value?.sourceSpanIds.length) return void 0;
|
|
6204
|
-
return {
|
|
6205
|
-
sourceSpanIds: value.sourceSpanIds,
|
|
6206
|
-
...value.sourceNodeIds[0] ? { documentNodeId: value.sourceNodeIds[0] } : {}
|
|
6207
|
-
};
|
|
6208
|
-
}
|
|
6209
7039
|
function provenanceFromIds(sourceSpanIds, sourceNodeIds) {
|
|
6210
7040
|
if (sourceSpanIds.length === 0) return void 0;
|
|
6211
7041
|
return {
|
|
@@ -6213,6 +7043,33 @@ function provenanceFromIds(sourceSpanIds, sourceNodeIds) {
|
|
|
6213
7043
|
...sourceNodeIds[0] ? { documentNodeId: sourceNodeIds[0] } : {}
|
|
6214
7044
|
};
|
|
6215
7045
|
}
|
|
7046
|
+
function combinedProvenance(...values) {
|
|
7047
|
+
const sourceSpanIds = [...new Set(values.flatMap((value) => value?.sourceSpanIds ?? []))];
|
|
7048
|
+
const sourceNodeIds = [...new Set(values.flatMap((value) => value?.sourceNodeIds ?? []))];
|
|
7049
|
+
return provenanceFromIds(sourceSpanIds, sourceNodeIds);
|
|
7050
|
+
}
|
|
7051
|
+
function firstOperationalParty(profile, roles) {
|
|
7052
|
+
const candidates = roles.flatMap(
|
|
7053
|
+
(role) => profile.parties.filter((candidate) => candidate.role === role && candidate.name.trim())
|
|
7054
|
+
);
|
|
7055
|
+
return candidates.find((candidate) => candidate.address) ?? candidates[0];
|
|
7056
|
+
}
|
|
7057
|
+
function completeOperationalAddress(address) {
|
|
7058
|
+
if (!address?.street1 || !address.city || !address.state || !address.zip) return void 0;
|
|
7059
|
+
return {
|
|
7060
|
+
street1: address.street1,
|
|
7061
|
+
street2: address.street2,
|
|
7062
|
+
city: address.city,
|
|
7063
|
+
state: address.state,
|
|
7064
|
+
zip: address.zip,
|
|
7065
|
+
country: address.country
|
|
7066
|
+
};
|
|
7067
|
+
}
|
|
7068
|
+
function sourceBackedAddressFromParty(party) {
|
|
7069
|
+
const address = completeOperationalAddress(party?.address);
|
|
7070
|
+
const provenance = party ? provenanceFromIds(party.sourceSpanIds, party.sourceNodeIds) : void 0;
|
|
7071
|
+
return address && provenance ? { ...address, ...provenance } : void 0;
|
|
7072
|
+
}
|
|
6216
7073
|
function declarationFactsByField(profile, field) {
|
|
6217
7074
|
return profile.declarationFacts.filter((fact) => fact.field === field && fact.value.trim());
|
|
6218
7075
|
}
|
|
@@ -6234,7 +7091,7 @@ function sourceBackedAddressFromFact(fact) {
|
|
|
6234
7091
|
};
|
|
6235
7092
|
}
|
|
6236
7093
|
function normalizedEntityType(value) {
|
|
6237
|
-
const normalized =
|
|
7094
|
+
const normalized = cleanText2(value, "").toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
6238
7095
|
if (normalized === "inc" || normalized === "incorporated" || normalized === "c_corporation" || normalized === "s_corporation") {
|
|
6239
7096
|
return "corporation";
|
|
6240
7097
|
}
|
|
@@ -6260,19 +7117,83 @@ function declarationFieldName(fact) {
|
|
|
6260
7117
|
if (fact.field === "additionalNamedInsured") return "additionalNamedInsured";
|
|
6261
7118
|
return fact.field;
|
|
6262
7119
|
}
|
|
7120
|
+
function scheduleValueMap(item) {
|
|
7121
|
+
return new Map(item.values.map((value) => [
|
|
7122
|
+
value.label.toLowerCase().replace(/[^a-z0-9]+/g, " ").trim(),
|
|
7123
|
+
value.value
|
|
7124
|
+
]));
|
|
7125
|
+
}
|
|
7126
|
+
function firstScheduleValue(values, labels) {
|
|
7127
|
+
for (const label of labels) {
|
|
7128
|
+
const direct = values.get(label);
|
|
7129
|
+
if (direct) return direct;
|
|
7130
|
+
const match = [...values.entries()].find(([key]) => key.includes(label));
|
|
7131
|
+
if (match?.[1]) return match[1];
|
|
7132
|
+
}
|
|
7133
|
+
return void 0;
|
|
7134
|
+
}
|
|
7135
|
+
function positiveInteger2(value) {
|
|
7136
|
+
const parsed = Number.parseInt(value?.match(/\d+/)?.[0] ?? "", 10);
|
|
7137
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : void 0;
|
|
7138
|
+
}
|
|
7139
|
+
function structuredVehicles(profile) {
|
|
7140
|
+
return (profile.coverageSchedules ?? []).filter((schedule) => schedule.kind === "vehicle").flatMap((schedule) => schedule.items).flatMap((item, index) => {
|
|
7141
|
+
const values = scheduleValueMap(item);
|
|
7142
|
+
const year = positiveInteger2(firstScheduleValue(values, ["year", "model year"]));
|
|
7143
|
+
const make = firstScheduleValue(values, ["make"]);
|
|
7144
|
+
const model = firstScheduleValue(values, ["model"]);
|
|
7145
|
+
const vin = firstScheduleValue(values, ["vin", "vehicle identification number"]);
|
|
7146
|
+
if (!year || !make || !model || !vin) return [];
|
|
7147
|
+
return [{
|
|
7148
|
+
number: positiveInteger2(item.label) ?? index + 1,
|
|
7149
|
+
year,
|
|
7150
|
+
make,
|
|
7151
|
+
model,
|
|
7152
|
+
vin
|
|
7153
|
+
}];
|
|
7154
|
+
});
|
|
7155
|
+
}
|
|
7156
|
+
function structuredLocations(profile) {
|
|
7157
|
+
return (profile.coverageSchedules ?? []).filter((schedule) => schedule.kind === "location" || schedule.kind === "property").flatMap((schedule) => schedule.items).flatMap((item, index) => {
|
|
7158
|
+
const values = scheduleValueMap(item);
|
|
7159
|
+
const street1 = firstScheduleValue(values, ["street 1", "street address", "address"]);
|
|
7160
|
+
const city = firstScheduleValue(values, ["city"]);
|
|
7161
|
+
const state = firstScheduleValue(values, ["state", "province"]);
|
|
7162
|
+
const zip = firstScheduleValue(values, ["zip", "postal code"]);
|
|
7163
|
+
if (!street1 || !city || !state || !zip) return [];
|
|
7164
|
+
return [{
|
|
7165
|
+
number: positiveInteger2(item.label) ?? index + 1,
|
|
7166
|
+
address: {
|
|
7167
|
+
street1,
|
|
7168
|
+
city,
|
|
7169
|
+
state,
|
|
7170
|
+
zip,
|
|
7171
|
+
country: firstScheduleValue(values, ["country"])
|
|
7172
|
+
},
|
|
7173
|
+
description: item.description,
|
|
7174
|
+
buildingValue: firstScheduleValue(values, ["building value", "building"]),
|
|
7175
|
+
contentsValue: firstScheduleValue(values, ["contents value", "contents"])
|
|
7176
|
+
}];
|
|
7177
|
+
});
|
|
7178
|
+
}
|
|
6263
7179
|
function materializeDocument(params) {
|
|
6264
7180
|
const profile = params.operationalProfile;
|
|
6265
7181
|
const policyNumber = valueOf(profile, "policyNumber") ?? "Unknown";
|
|
6266
|
-
const
|
|
6267
|
-
const
|
|
7182
|
+
const namedInsuredParty = firstOperationalParty(profile, ["named_insured"]);
|
|
7183
|
+
const insurerParty = firstOperationalParty(profile, ["insurer", "carrier"]);
|
|
7184
|
+
const producerParty = firstOperationalParty(profile, ["producer", "broker"]);
|
|
7185
|
+
const insuredName = valueOf(profile, "namedInsured") ?? namedInsuredParty?.name ?? "Unknown";
|
|
7186
|
+
const carrier = valueOf(profile, "insurer") ?? insurerParty?.name ?? "Unknown";
|
|
6268
7187
|
const effectiveDate = valueOf(profile, "effectiveDate") ?? "Unknown";
|
|
6269
7188
|
const expirationDate = valueOf(profile, "expirationDate") ?? "Unknown";
|
|
6270
7189
|
const premium = valueOf(profile, "premium");
|
|
6271
|
-
const insurerProvenance =
|
|
6272
|
-
const
|
|
6273
|
-
const
|
|
7190
|
+
const insurerProvenance = combinedProvenance(profile.insurer, insurerParty);
|
|
7191
|
+
const insurerAddress = completeOperationalAddress(insurerParty?.address);
|
|
7192
|
+
const broker = valueOf(profile, "broker") ?? producerParty?.name;
|
|
7193
|
+
const brokerProvenance = combinedProvenance(profile.broker, producerParty);
|
|
7194
|
+
const producerAddress = completeOperationalAddress(producerParty?.address);
|
|
6274
7195
|
const mailingAddressFact = firstDeclarationFact(profile, "mailingAddress");
|
|
6275
|
-
const insuredAddress = sourceBackedAddressFromFact(mailingAddressFact);
|
|
7196
|
+
const insuredAddress = sourceBackedAddressFromParty(namedInsuredParty) ?? sourceBackedAddressFromFact(mailingAddressFact);
|
|
6276
7197
|
const insuredDba = firstDeclarationFact(profile, "dba")?.value;
|
|
6277
7198
|
const insuredEntityType = normalizedEntityType(firstDeclarationFact(profile, "entityType")?.value);
|
|
6278
7199
|
const insuredFein = firstDeclarationFact(profile, "taxId")?.value;
|
|
@@ -6299,6 +7220,30 @@ function materializeDocument(params) {
|
|
|
6299
7220
|
...coverage.limits?.length ? coverage.limits.map((term) => `${term.label}: ${term.value}`) : [coverage.limit, coverage.deductible, coverage.premium]
|
|
6300
7221
|
].filter(Boolean).join(" | ")
|
|
6301
7222
|
}));
|
|
7223
|
+
const coverageSchedules = (profile.coverageSchedules ?? []).map((schedule) => ({
|
|
7224
|
+
...schedule,
|
|
7225
|
+
items: schedule.items.map((item) => ({ ...item }))
|
|
7226
|
+
}));
|
|
7227
|
+
const premiumBreakdown = (profile.premiumBreakdown ?? []).map((row) => ({
|
|
7228
|
+
line: row.line,
|
|
7229
|
+
amount: row.amount,
|
|
7230
|
+
amountValue: row.amountValue,
|
|
7231
|
+
documentNodeId: row.sourceNodeIds[0],
|
|
7232
|
+
sourceSpanIds: row.sourceSpanIds
|
|
7233
|
+
}));
|
|
7234
|
+
const taxesAndFees = (profile.taxesAndFees ?? []).map((row) => ({
|
|
7235
|
+
name: row.name,
|
|
7236
|
+
amount: row.amount,
|
|
7237
|
+
amountValue: row.amountValue,
|
|
7238
|
+
type: row.type,
|
|
7239
|
+
description: row.description,
|
|
7240
|
+
documentNodeId: row.sourceNodeIds[0],
|
|
7241
|
+
sourceSpanIds: row.sourceSpanIds
|
|
7242
|
+
}));
|
|
7243
|
+
const totalCost = valueOf(profile, "totalCost");
|
|
7244
|
+
const totalCostAmount = totalCost ? Number(totalCost.replace(/[^0-9.-]/g, "")) : void 0;
|
|
7245
|
+
const vehicles = structuredVehicles(profile);
|
|
7246
|
+
const locations = structuredLocations(profile);
|
|
6302
7247
|
const documentOutline = sourceTreeToOutline(params.sourceTree);
|
|
6303
7248
|
const documentMetadata = {
|
|
6304
7249
|
sourceTreeVersion: "v3",
|
|
@@ -6331,15 +7276,29 @@ function materializeDocument(params) {
|
|
|
6331
7276
|
security: carrier,
|
|
6332
7277
|
insuredName,
|
|
6333
7278
|
premium,
|
|
7279
|
+
...premiumBreakdown.length > 0 ? { premiumBreakdown } : {},
|
|
7280
|
+
...taxesAndFees.length > 0 ? { taxesAndFees } : {},
|
|
7281
|
+
...totalCost ? { totalCost } : {},
|
|
7282
|
+
...typeof totalCostAmount === "number" && Number.isFinite(totalCostAmount) ? { totalCostAmount } : {},
|
|
6334
7283
|
insuredDba,
|
|
6335
7284
|
insuredAddress,
|
|
6336
7285
|
insuredEntityType,
|
|
6337
7286
|
insuredFein,
|
|
6338
7287
|
...additionalNamedInsureds.length > 0 ? { additionalNamedInsureds } : {},
|
|
6339
|
-
...insurerProvenance ? {
|
|
7288
|
+
...insurerProvenance ? {
|
|
7289
|
+
insurer: {
|
|
7290
|
+
legalName: carrier,
|
|
7291
|
+
...insurerAddress ? { address: insurerAddress } : {},
|
|
7292
|
+
...insurerProvenance
|
|
7293
|
+
}
|
|
7294
|
+
} : {},
|
|
6340
7295
|
...broker && brokerProvenance ? {
|
|
6341
7296
|
brokerAgency: broker,
|
|
6342
|
-
producer: {
|
|
7297
|
+
producer: {
|
|
7298
|
+
agencyName: broker,
|
|
7299
|
+
...producerAddress ? { address: producerAddress } : {},
|
|
7300
|
+
...brokerProvenance
|
|
7301
|
+
}
|
|
6343
7302
|
} : {},
|
|
6344
7303
|
linesOfBusiness: profile.linesOfBusiness,
|
|
6345
7304
|
formInventory: params.formInventory.filter((form) => typeof form.formNumber === "string" && form.formNumber.trim().length > 0).map((form) => ({
|
|
@@ -6351,6 +7310,9 @@ function materializeDocument(params) {
|
|
|
6351
7310
|
pageEnd: form.pageEnd
|
|
6352
7311
|
})),
|
|
6353
7312
|
coverages,
|
|
7313
|
+
...coverageSchedules.length > 0 ? { coverageSchedules } : {},
|
|
7314
|
+
...vehicles.length > 0 ? { vehicles } : {},
|
|
7315
|
+
...locations.length > 0 ? { locations } : {},
|
|
6354
7316
|
documentMetadata,
|
|
6355
7317
|
documentOutline,
|
|
6356
7318
|
declarations: {
|
|
@@ -6482,6 +7444,7 @@ async function runSourceTreeExtraction(params) {
|
|
|
6482
7444
|
};
|
|
6483
7445
|
const emptyProfile = emptyOperationalProfile();
|
|
6484
7446
|
let operationalProfile = emptyProfile;
|
|
7447
|
+
let coverageRecovery = disabledCoverageRecoveryDiagnostics();
|
|
6485
7448
|
try {
|
|
6486
7449
|
const validNodeIds = new Set(sourceTree.map((node) => node.id));
|
|
6487
7450
|
const validSpanIds = new Set(sourceSpans.map((span) => span.id));
|
|
@@ -6519,6 +7482,21 @@ async function runSourceTreeExtraction(params) {
|
|
|
6519
7482
|
} catch (error) {
|
|
6520
7483
|
warnings.push(`Operational profile model pass failed; coverage rows omitted (${error instanceof Error ? error.message : String(error)})`);
|
|
6521
7484
|
}
|
|
7485
|
+
if (params.coverageRecovery?.enabled) {
|
|
7486
|
+
const recovery = await recoverOperationalProfileCoverage({
|
|
7487
|
+
sourceTree,
|
|
7488
|
+
sourceSpans,
|
|
7489
|
+
operationalProfile,
|
|
7490
|
+
generateObject: params.generateObject,
|
|
7491
|
+
providerOptions: params.providerOptions,
|
|
7492
|
+
resolveBudget: params.resolveBudget,
|
|
7493
|
+
trackUsage: localTrack,
|
|
7494
|
+
log: params.log
|
|
7495
|
+
});
|
|
7496
|
+
operationalProfile = recovery.operationalProfile;
|
|
7497
|
+
coverageRecovery = recovery.diagnostics;
|
|
7498
|
+
warnings.push(...coverageRecovery.warnings);
|
|
7499
|
+
}
|
|
6522
7500
|
if (operationalProfile.coverages.length > 0) {
|
|
6523
7501
|
try {
|
|
6524
7502
|
const cleanup = await cleanupOperationalCoverageSchedules({
|
|
@@ -6551,6 +7529,7 @@ async function runSourceTreeExtraction(params) {
|
|
|
6551
7529
|
sourceChunks: chunkSourceSpans(sourceSpans),
|
|
6552
7530
|
formInventory: formHints,
|
|
6553
7531
|
operationalProfile,
|
|
7532
|
+
coverageRecovery,
|
|
6554
7533
|
document,
|
|
6555
7534
|
chunks: [],
|
|
6556
7535
|
warnings: [...warnings, ...operationalProfile.warnings],
|
|
@@ -6653,7 +7632,8 @@ function createExtractor(config) {
|
|
|
6653
7632
|
providerOptions: activeProviderOptions,
|
|
6654
7633
|
resolveBudget,
|
|
6655
7634
|
trackUsage,
|
|
6656
|
-
log
|
|
7635
|
+
log,
|
|
7636
|
+
coverageRecovery: options?.coverageRecovery
|
|
6657
7637
|
});
|
|
6658
7638
|
const sourceTreeFormInventory = v3.formInventory.flatMap((form) => {
|
|
6659
7639
|
const formNumber = typeof form.formNumber === "string" ? form.formNumber.trim() : "";
|
|
@@ -6693,6 +7673,7 @@ function createExtractor(config) {
|
|
|
6693
7673
|
sourceChunks: v3.sourceChunks,
|
|
6694
7674
|
sourceTree: v3.sourceTree,
|
|
6695
7675
|
operationalProfile: v3.operationalProfile,
|
|
7676
|
+
coverageRecovery: v3.coverageRecovery,
|
|
6696
7677
|
warnings: v3.warnings,
|
|
6697
7678
|
tokenUsage: v3.tokenUsage,
|
|
6698
7679
|
usageReporting: v3.usageReporting,
|
|
@@ -8099,8 +9080,8 @@ Respond with JSON only:
|
|
|
8099
9080
|
}`;
|
|
8100
9081
|
|
|
8101
9082
|
// src/schemas/application.ts
|
|
8102
|
-
var
|
|
8103
|
-
var FieldTypeSchema =
|
|
9083
|
+
var import_zod25 = require("zod");
|
|
9084
|
+
var FieldTypeSchema = import_zod25.z.enum([
|
|
8104
9085
|
"text",
|
|
8105
9086
|
"numeric",
|
|
8106
9087
|
"currency",
|
|
@@ -8109,223 +9090,223 @@ var FieldTypeSchema = import_zod24.z.enum([
|
|
|
8109
9090
|
"table",
|
|
8110
9091
|
"declaration"
|
|
8111
9092
|
]);
|
|
8112
|
-
var ApplicationFieldSchema =
|
|
8113
|
-
id:
|
|
8114
|
-
label:
|
|
8115
|
-
section:
|
|
9093
|
+
var ApplicationFieldSchema = import_zod25.z.object({
|
|
9094
|
+
id: import_zod25.z.string(),
|
|
9095
|
+
label: import_zod25.z.string(),
|
|
9096
|
+
section: import_zod25.z.string(),
|
|
8116
9097
|
fieldType: FieldTypeSchema,
|
|
8117
|
-
required:
|
|
8118
|
-
options:
|
|
8119
|
-
columns:
|
|
8120
|
-
requiresExplanationIfYes:
|
|
8121
|
-
condition:
|
|
8122
|
-
dependsOn:
|
|
8123
|
-
whenValue:
|
|
9098
|
+
required: import_zod25.z.boolean(),
|
|
9099
|
+
options: import_zod25.z.array(import_zod25.z.string()).optional(),
|
|
9100
|
+
columns: import_zod25.z.array(import_zod25.z.string()).optional(),
|
|
9101
|
+
requiresExplanationIfYes: import_zod25.z.boolean().optional(),
|
|
9102
|
+
condition: import_zod25.z.object({
|
|
9103
|
+
dependsOn: import_zod25.z.string(),
|
|
9104
|
+
whenValue: import_zod25.z.string()
|
|
8124
9105
|
}).optional(),
|
|
8125
|
-
value:
|
|
8126
|
-
source:
|
|
8127
|
-
confidence:
|
|
8128
|
-
sourceSpanIds:
|
|
8129
|
-
userSourceSpanIds:
|
|
8130
|
-
pageNumber:
|
|
8131
|
-
fieldAnchorId:
|
|
8132
|
-
acroFormName:
|
|
8133
|
-
validationStatus:
|
|
8134
|
-
});
|
|
8135
|
-
var ApplicationQuestionConditionSchema =
|
|
8136
|
-
dependsOn:
|
|
8137
|
-
operator:
|
|
8138
|
-
value:
|
|
8139
|
-
whenValue:
|
|
8140
|
-
values:
|
|
8141
|
-
});
|
|
8142
|
-
var ApplicationRepeatSchema =
|
|
8143
|
-
min:
|
|
8144
|
-
max:
|
|
8145
|
-
label:
|
|
8146
|
-
});
|
|
8147
|
-
var ApplicationQuestionNodeSchema =
|
|
8148
|
-
() =>
|
|
8149
|
-
id:
|
|
8150
|
-
nodeType:
|
|
8151
|
-
fieldId:
|
|
8152
|
-
fieldPath:
|
|
8153
|
-
parentId:
|
|
8154
|
-
order:
|
|
8155
|
-
label:
|
|
8156
|
-
section:
|
|
9106
|
+
value: import_zod25.z.string().optional(),
|
|
9107
|
+
source: import_zod25.z.string().optional().describe("Where the value came from: auto-fill, user, lookup"),
|
|
9108
|
+
confidence: import_zod25.z.enum(["confirmed", "high", "medium", "low"]).optional(),
|
|
9109
|
+
sourceSpanIds: import_zod25.z.array(import_zod25.z.string()).optional().describe("Stable source spans that support the field value or field anchor"),
|
|
9110
|
+
userSourceSpanIds: import_zod25.z.array(import_zod25.z.string()).optional().describe("Message or attachment spans that support user-provided values"),
|
|
9111
|
+
pageNumber: import_zod25.z.number().int().positive().optional().describe("Application page where the field label or anchor appears"),
|
|
9112
|
+
fieldAnchorId: import_zod25.z.string().optional().describe("Stable field anchor ID derived from page, section, label, and form metadata"),
|
|
9113
|
+
acroFormName: import_zod25.z.string().optional().describe("Native PDF AcroForm field name when available"),
|
|
9114
|
+
validationStatus: import_zod25.z.enum(["valid", "needs_review", "unsupported", "missing"]).optional()
|
|
9115
|
+
});
|
|
9116
|
+
var ApplicationQuestionConditionSchema = import_zod25.z.object({
|
|
9117
|
+
dependsOn: import_zod25.z.string(),
|
|
9118
|
+
operator: import_zod25.z.enum(["equals", "not_equals", "in", "not_in", "exists"]).optional(),
|
|
9119
|
+
value: import_zod25.z.string().optional(),
|
|
9120
|
+
whenValue: import_zod25.z.string().optional(),
|
|
9121
|
+
values: import_zod25.z.array(import_zod25.z.string()).optional()
|
|
9122
|
+
});
|
|
9123
|
+
var ApplicationRepeatSchema = import_zod25.z.object({
|
|
9124
|
+
min: import_zod25.z.number().int().nonnegative().optional(),
|
|
9125
|
+
max: import_zod25.z.number().int().positive().optional(),
|
|
9126
|
+
label: import_zod25.z.string().optional()
|
|
9127
|
+
});
|
|
9128
|
+
var ApplicationQuestionNodeSchema = import_zod25.z.lazy(
|
|
9129
|
+
() => import_zod25.z.object({
|
|
9130
|
+
id: import_zod25.z.string(),
|
|
9131
|
+
nodeType: import_zod25.z.enum(["group", "question", "repeat_group", "table"]),
|
|
9132
|
+
fieldId: import_zod25.z.string().optional(),
|
|
9133
|
+
fieldPath: import_zod25.z.string().optional(),
|
|
9134
|
+
parentId: import_zod25.z.string().optional(),
|
|
9135
|
+
order: import_zod25.z.number().int().nonnegative().optional(),
|
|
9136
|
+
label: import_zod25.z.string(),
|
|
9137
|
+
section: import_zod25.z.string().optional(),
|
|
8157
9138
|
fieldType: FieldTypeSchema.optional(),
|
|
8158
|
-
required:
|
|
8159
|
-
prompt:
|
|
8160
|
-
options:
|
|
8161
|
-
columns:
|
|
9139
|
+
required: import_zod25.z.boolean().optional(),
|
|
9140
|
+
prompt: import_zod25.z.string().optional(),
|
|
9141
|
+
options: import_zod25.z.array(import_zod25.z.string()).optional(),
|
|
9142
|
+
columns: import_zod25.z.array(import_zod25.z.string()).optional(),
|
|
8162
9143
|
condition: ApplicationQuestionConditionSchema.optional(),
|
|
8163
9144
|
repeat: ApplicationRepeatSchema.optional(),
|
|
8164
|
-
children:
|
|
9145
|
+
children: import_zod25.z.array(ApplicationQuestionNodeSchema).optional()
|
|
8165
9146
|
})
|
|
8166
9147
|
);
|
|
8167
|
-
var ApplicationQuestionGraphSchema =
|
|
8168
|
-
id:
|
|
8169
|
-
version:
|
|
8170
|
-
title:
|
|
8171
|
-
applicationType:
|
|
8172
|
-
source:
|
|
8173
|
-
rootNodeIds:
|
|
8174
|
-
nodes:
|
|
8175
|
-
});
|
|
8176
|
-
var ApplicationTemplateSchema =
|
|
8177
|
-
id:
|
|
8178
|
-
version:
|
|
8179
|
-
title:
|
|
8180
|
-
applicationType:
|
|
9148
|
+
var ApplicationQuestionGraphSchema = import_zod25.z.object({
|
|
9149
|
+
id: import_zod25.z.string(),
|
|
9150
|
+
version: import_zod25.z.string(),
|
|
9151
|
+
title: import_zod25.z.string().optional(),
|
|
9152
|
+
applicationType: import_zod25.z.string().nullable().optional(),
|
|
9153
|
+
source: import_zod25.z.enum(["pdf", "manual", "imported", "generated"]).default("generated"),
|
|
9154
|
+
rootNodeIds: import_zod25.z.array(import_zod25.z.string()).optional(),
|
|
9155
|
+
nodes: import_zod25.z.array(ApplicationQuestionNodeSchema)
|
|
9156
|
+
});
|
|
9157
|
+
var ApplicationTemplateSchema = import_zod25.z.object({
|
|
9158
|
+
id: import_zod25.z.string(),
|
|
9159
|
+
version: import_zod25.z.string(),
|
|
9160
|
+
title: import_zod25.z.string(),
|
|
9161
|
+
applicationType: import_zod25.z.string().nullable().optional(),
|
|
8181
9162
|
questionGraph: ApplicationQuestionGraphSchema,
|
|
8182
|
-
fields:
|
|
8183
|
-
});
|
|
8184
|
-
var ApplicationClassifyResultSchema = import_zod24.z.object({
|
|
8185
|
-
isApplication: import_zod24.z.boolean(),
|
|
8186
|
-
confidence: import_zod24.z.number().min(0).max(1),
|
|
8187
|
-
applicationType: import_zod24.z.string().nullable()
|
|
8188
|
-
});
|
|
8189
|
-
var FieldExtractionResultSchema = import_zod24.z.object({
|
|
8190
|
-
fields: import_zod24.z.array(ApplicationFieldSchema)
|
|
8191
|
-
});
|
|
8192
|
-
var AutoFillMatchSchema = import_zod24.z.object({
|
|
8193
|
-
fieldId: import_zod24.z.string(),
|
|
8194
|
-
value: import_zod24.z.string(),
|
|
8195
|
-
confidence: import_zod24.z.enum(["confirmed"]),
|
|
8196
|
-
contextKey: import_zod24.z.string()
|
|
8197
|
-
});
|
|
8198
|
-
var AutoFillResultSchema = import_zod24.z.object({
|
|
8199
|
-
matches: import_zod24.z.array(AutoFillMatchSchema)
|
|
8200
|
-
});
|
|
8201
|
-
var QuestionBatchResultSchema = import_zod24.z.object({
|
|
8202
|
-
batches: import_zod24.z.array(import_zod24.z.array(import_zod24.z.string()).describe("Array of field IDs in this batch"))
|
|
8203
|
-
});
|
|
8204
|
-
var LookupRequestSchema = import_zod24.z.object({
|
|
8205
|
-
type: import_zod24.z.string().describe("Type of lookup: 'records', 'website', 'policy'"),
|
|
8206
|
-
description: import_zod24.z.string(),
|
|
8207
|
-
url: import_zod24.z.string().optional(),
|
|
8208
|
-
targetFieldIds: import_zod24.z.array(import_zod24.z.string())
|
|
8209
|
-
});
|
|
8210
|
-
var ReplyIntentSchema = import_zod24.z.object({
|
|
8211
|
-
primaryIntent: import_zod24.z.enum(["answers_only", "question", "lookup_request", "mixed"]),
|
|
8212
|
-
hasAnswers: import_zod24.z.boolean(),
|
|
8213
|
-
questionText: import_zod24.z.string().optional(),
|
|
8214
|
-
questionFieldIds: import_zod24.z.array(import_zod24.z.string()).optional(),
|
|
8215
|
-
lookupRequests: import_zod24.z.array(LookupRequestSchema).optional()
|
|
8216
|
-
});
|
|
8217
|
-
var ParsedAnswerSchema = import_zod24.z.object({
|
|
8218
|
-
fieldId: import_zod24.z.string(),
|
|
8219
|
-
value: import_zod24.z.string(),
|
|
8220
|
-
explanation: import_zod24.z.string().optional()
|
|
8221
|
-
});
|
|
8222
|
-
var AnswerParsingResultSchema = import_zod24.z.object({
|
|
8223
|
-
answers: import_zod24.z.array(ParsedAnswerSchema),
|
|
8224
|
-
unanswered: import_zod24.z.array(import_zod24.z.string()).describe("Field IDs that were not answered")
|
|
8225
|
-
});
|
|
8226
|
-
var LookupFillSchema = import_zod24.z.object({
|
|
8227
|
-
fieldId: import_zod24.z.string(),
|
|
8228
|
-
value: import_zod24.z.string(),
|
|
8229
|
-
source: import_zod24.z.string().describe("Specific citable reference, e.g. 'GL Policy #POL-12345 (Hartford)'"),
|
|
8230
|
-
sourceSpanIds: import_zod24.z.array(import_zod24.z.string()).optional()
|
|
9163
|
+
fields: import_zod25.z.array(ApplicationFieldSchema).optional()
|
|
8231
9164
|
});
|
|
8232
|
-
var
|
|
8233
|
-
|
|
8234
|
-
|
|
8235
|
-
|
|
8236
|
-
});
|
|
8237
|
-
var
|
|
8238
|
-
|
|
8239
|
-
|
|
8240
|
-
|
|
8241
|
-
|
|
8242
|
-
|
|
8243
|
-
|
|
8244
|
-
|
|
8245
|
-
});
|
|
8246
|
-
var
|
|
8247
|
-
|
|
8248
|
-
|
|
8249
|
-
|
|
8250
|
-
|
|
8251
|
-
|
|
8252
|
-
var
|
|
8253
|
-
|
|
8254
|
-
|
|
9165
|
+
var ApplicationClassifyResultSchema = import_zod25.z.object({
|
|
9166
|
+
isApplication: import_zod25.z.boolean(),
|
|
9167
|
+
confidence: import_zod25.z.number().min(0).max(1),
|
|
9168
|
+
applicationType: import_zod25.z.string().nullable()
|
|
9169
|
+
});
|
|
9170
|
+
var FieldExtractionResultSchema = import_zod25.z.object({
|
|
9171
|
+
fields: import_zod25.z.array(ApplicationFieldSchema)
|
|
9172
|
+
});
|
|
9173
|
+
var AutoFillMatchSchema = import_zod25.z.object({
|
|
9174
|
+
fieldId: import_zod25.z.string(),
|
|
9175
|
+
value: import_zod25.z.string(),
|
|
9176
|
+
confidence: import_zod25.z.enum(["confirmed"]),
|
|
9177
|
+
contextKey: import_zod25.z.string()
|
|
9178
|
+
});
|
|
9179
|
+
var AutoFillResultSchema = import_zod25.z.object({
|
|
9180
|
+
matches: import_zod25.z.array(AutoFillMatchSchema)
|
|
9181
|
+
});
|
|
9182
|
+
var QuestionBatchResultSchema = import_zod25.z.object({
|
|
9183
|
+
batches: import_zod25.z.array(import_zod25.z.array(import_zod25.z.string()).describe("Array of field IDs in this batch"))
|
|
9184
|
+
});
|
|
9185
|
+
var LookupRequestSchema = import_zod25.z.object({
|
|
9186
|
+
type: import_zod25.z.string().describe("Type of lookup: 'records', 'website', 'policy'"),
|
|
9187
|
+
description: import_zod25.z.string(),
|
|
9188
|
+
url: import_zod25.z.string().optional(),
|
|
9189
|
+
targetFieldIds: import_zod25.z.array(import_zod25.z.string())
|
|
9190
|
+
});
|
|
9191
|
+
var ReplyIntentSchema = import_zod25.z.object({
|
|
9192
|
+
primaryIntent: import_zod25.z.enum(["answers_only", "question", "lookup_request", "mixed"]),
|
|
9193
|
+
hasAnswers: import_zod25.z.boolean(),
|
|
9194
|
+
questionText: import_zod25.z.string().optional(),
|
|
9195
|
+
questionFieldIds: import_zod25.z.array(import_zod25.z.string()).optional(),
|
|
9196
|
+
lookupRequests: import_zod25.z.array(LookupRequestSchema).optional()
|
|
9197
|
+
});
|
|
9198
|
+
var ParsedAnswerSchema = import_zod25.z.object({
|
|
9199
|
+
fieldId: import_zod25.z.string(),
|
|
9200
|
+
value: import_zod25.z.string(),
|
|
9201
|
+
explanation: import_zod25.z.string().optional()
|
|
9202
|
+
});
|
|
9203
|
+
var AnswerParsingResultSchema = import_zod25.z.object({
|
|
9204
|
+
answers: import_zod25.z.array(ParsedAnswerSchema),
|
|
9205
|
+
unanswered: import_zod25.z.array(import_zod25.z.string()).describe("Field IDs that were not answered")
|
|
9206
|
+
});
|
|
9207
|
+
var LookupFillSchema = import_zod25.z.object({
|
|
9208
|
+
fieldId: import_zod25.z.string(),
|
|
9209
|
+
value: import_zod25.z.string(),
|
|
9210
|
+
source: import_zod25.z.string().describe("Specific citable reference, e.g. 'GL Policy #POL-12345 (Hartford)'"),
|
|
9211
|
+
sourceSpanIds: import_zod25.z.array(import_zod25.z.string()).optional()
|
|
9212
|
+
});
|
|
9213
|
+
var LookupFillResultSchema = import_zod25.z.object({
|
|
9214
|
+
fills: import_zod25.z.array(LookupFillSchema),
|
|
9215
|
+
unfillable: import_zod25.z.array(import_zod25.z.string()),
|
|
9216
|
+
explanation: import_zod25.z.string().optional()
|
|
9217
|
+
});
|
|
9218
|
+
var FlatPdfPlacementSchema = import_zod25.z.object({
|
|
9219
|
+
fieldId: import_zod25.z.string(),
|
|
9220
|
+
page: import_zod25.z.number(),
|
|
9221
|
+
x: import_zod25.z.number().describe("Percentage from left edge (0-100)"),
|
|
9222
|
+
y: import_zod25.z.number().describe("Percentage from top edge (0-100)"),
|
|
9223
|
+
text: import_zod25.z.string(),
|
|
9224
|
+
fontSize: import_zod25.z.number().optional(),
|
|
9225
|
+
isCheckmark: import_zod25.z.boolean().optional()
|
|
9226
|
+
});
|
|
9227
|
+
var AcroFormMappingSchema = import_zod25.z.object({
|
|
9228
|
+
fieldId: import_zod25.z.string(),
|
|
9229
|
+
acroFormName: import_zod25.z.string(),
|
|
9230
|
+
value: import_zod25.z.string()
|
|
9231
|
+
});
|
|
9232
|
+
var QualityGateStatusSchema = import_zod25.z.enum(["passed", "warning", "failed"]);
|
|
9233
|
+
var QualitySeveritySchema = import_zod25.z.enum(["info", "warning", "blocking"]);
|
|
9234
|
+
var ApplicationQualityIssueSchema = import_zod25.z.object({
|
|
9235
|
+
code: import_zod25.z.string(),
|
|
8255
9236
|
severity: QualitySeveritySchema,
|
|
8256
|
-
message:
|
|
8257
|
-
fieldId:
|
|
9237
|
+
message: import_zod25.z.string(),
|
|
9238
|
+
fieldId: import_zod25.z.string().optional()
|
|
8258
9239
|
});
|
|
8259
|
-
var ApplicationQualityRoundSchema =
|
|
8260
|
-
round:
|
|
8261
|
-
kind:
|
|
9240
|
+
var ApplicationQualityRoundSchema = import_zod25.z.object({
|
|
9241
|
+
round: import_zod25.z.number(),
|
|
9242
|
+
kind: import_zod25.z.string(),
|
|
8262
9243
|
status: QualityGateStatusSchema,
|
|
8263
|
-
summary:
|
|
9244
|
+
summary: import_zod25.z.string().optional()
|
|
8264
9245
|
});
|
|
8265
|
-
var ApplicationQualityArtifactSchema =
|
|
8266
|
-
kind:
|
|
8267
|
-
label:
|
|
8268
|
-
itemCount:
|
|
9246
|
+
var ApplicationQualityArtifactSchema = import_zod25.z.object({
|
|
9247
|
+
kind: import_zod25.z.string(),
|
|
9248
|
+
label: import_zod25.z.string().optional(),
|
|
9249
|
+
itemCount: import_zod25.z.number().optional()
|
|
8269
9250
|
});
|
|
8270
|
-
var ApplicationEmailReviewSchema =
|
|
8271
|
-
issues:
|
|
9251
|
+
var ApplicationEmailReviewSchema = import_zod25.z.object({
|
|
9252
|
+
issues: import_zod25.z.array(ApplicationQualityIssueSchema),
|
|
8272
9253
|
qualityGateStatus: QualityGateStatusSchema
|
|
8273
9254
|
});
|
|
8274
|
-
var ApplicationQualityReportSchema =
|
|
8275
|
-
issues:
|
|
8276
|
-
rounds:
|
|
8277
|
-
artifacts:
|
|
9255
|
+
var ApplicationQualityReportSchema = import_zod25.z.object({
|
|
9256
|
+
issues: import_zod25.z.array(ApplicationQualityIssueSchema),
|
|
9257
|
+
rounds: import_zod25.z.array(ApplicationQualityRoundSchema).optional(),
|
|
9258
|
+
artifacts: import_zod25.z.array(ApplicationQualityArtifactSchema).optional(),
|
|
8278
9259
|
emailReview: ApplicationEmailReviewSchema.optional(),
|
|
8279
9260
|
qualityGateStatus: QualityGateStatusSchema
|
|
8280
9261
|
});
|
|
8281
|
-
var ApplicationContextProposalSchema =
|
|
8282
|
-
id:
|
|
8283
|
-
fieldId:
|
|
8284
|
-
key:
|
|
8285
|
-
value:
|
|
8286
|
-
category:
|
|
8287
|
-
source:
|
|
8288
|
-
confidence:
|
|
8289
|
-
sourceSpanIds:
|
|
8290
|
-
userSourceSpanIds:
|
|
8291
|
-
});
|
|
8292
|
-
var ApplicationPacketAnswerSchema =
|
|
8293
|
-
fieldId:
|
|
8294
|
-
label:
|
|
8295
|
-
section:
|
|
8296
|
-
value:
|
|
8297
|
-
source:
|
|
8298
|
-
confidence:
|
|
8299
|
-
sourceSpanIds:
|
|
8300
|
-
userSourceSpanIds:
|
|
8301
|
-
});
|
|
8302
|
-
var ApplicationPacketSchema =
|
|
8303
|
-
id:
|
|
8304
|
-
applicationId:
|
|
8305
|
-
title:
|
|
8306
|
-
status:
|
|
8307
|
-
answers:
|
|
8308
|
-
missingFieldIds:
|
|
9262
|
+
var ApplicationContextProposalSchema = import_zod25.z.object({
|
|
9263
|
+
id: import_zod25.z.string(),
|
|
9264
|
+
fieldId: import_zod25.z.string().optional(),
|
|
9265
|
+
key: import_zod25.z.string(),
|
|
9266
|
+
value: import_zod25.z.string(),
|
|
9267
|
+
category: import_zod25.z.string(),
|
|
9268
|
+
source: import_zod25.z.enum(["application", "user", "lookup", "policy", "email", "chat", "imessage", "mcp"]),
|
|
9269
|
+
confidence: import_zod25.z.enum(["confirmed", "high", "medium", "low"]),
|
|
9270
|
+
sourceSpanIds: import_zod25.z.array(import_zod25.z.string()).optional(),
|
|
9271
|
+
userSourceSpanIds: import_zod25.z.array(import_zod25.z.string()).optional()
|
|
9272
|
+
});
|
|
9273
|
+
var ApplicationPacketAnswerSchema = import_zod25.z.object({
|
|
9274
|
+
fieldId: import_zod25.z.string(),
|
|
9275
|
+
label: import_zod25.z.string(),
|
|
9276
|
+
section: import_zod25.z.string(),
|
|
9277
|
+
value: import_zod25.z.string(),
|
|
9278
|
+
source: import_zod25.z.string(),
|
|
9279
|
+
confidence: import_zod25.z.enum(["confirmed", "high", "medium", "low"]).optional(),
|
|
9280
|
+
sourceSpanIds: import_zod25.z.array(import_zod25.z.string()).optional(),
|
|
9281
|
+
userSourceSpanIds: import_zod25.z.array(import_zod25.z.string()).optional()
|
|
9282
|
+
});
|
|
9283
|
+
var ApplicationPacketSchema = import_zod25.z.object({
|
|
9284
|
+
id: import_zod25.z.string(),
|
|
9285
|
+
applicationId: import_zod25.z.string(),
|
|
9286
|
+
title: import_zod25.z.string(),
|
|
9287
|
+
status: import_zod25.z.enum(["draft", "broker_ready", "submitted"]),
|
|
9288
|
+
answers: import_zod25.z.array(ApplicationPacketAnswerSchema),
|
|
9289
|
+
missingFieldIds: import_zod25.z.array(import_zod25.z.string()),
|
|
8309
9290
|
qualityReport: ApplicationQualityReportSchema,
|
|
8310
|
-
submissionNotes:
|
|
8311
|
-
createdAt:
|
|
8312
|
-
});
|
|
8313
|
-
var ApplicationStateSchema =
|
|
8314
|
-
id:
|
|
8315
|
-
pdfBase64:
|
|
8316
|
-
templateId:
|
|
8317
|
-
templateVersion:
|
|
9291
|
+
submissionNotes: import_zod25.z.string().optional(),
|
|
9292
|
+
createdAt: import_zod25.z.number()
|
|
9293
|
+
});
|
|
9294
|
+
var ApplicationStateSchema = import_zod25.z.object({
|
|
9295
|
+
id: import_zod25.z.string(),
|
|
9296
|
+
pdfBase64: import_zod25.z.string().optional().describe("Original PDF, omitted after extraction"),
|
|
9297
|
+
templateId: import_zod25.z.string().optional(),
|
|
9298
|
+
templateVersion: import_zod25.z.string().optional(),
|
|
8318
9299
|
templateSnapshot: ApplicationTemplateSchema.optional(),
|
|
8319
|
-
title:
|
|
8320
|
-
applicationType:
|
|
9300
|
+
title: import_zod25.z.string().optional(),
|
|
9301
|
+
applicationType: import_zod25.z.string().nullable().optional(),
|
|
8321
9302
|
questionGraph: ApplicationQuestionGraphSchema.optional(),
|
|
8322
|
-
fields:
|
|
8323
|
-
batches:
|
|
8324
|
-
currentBatchIndex:
|
|
8325
|
-
contextProposals:
|
|
9303
|
+
fields: import_zod25.z.array(ApplicationFieldSchema),
|
|
9304
|
+
batches: import_zod25.z.array(import_zod25.z.array(import_zod25.z.string())).optional(),
|
|
9305
|
+
currentBatchIndex: import_zod25.z.number().default(0),
|
|
9306
|
+
contextProposals: import_zod25.z.array(ApplicationContextProposalSchema).optional(),
|
|
8326
9307
|
packet: ApplicationPacketSchema.optional(),
|
|
8327
9308
|
qualityReport: ApplicationQualityReportSchema.optional(),
|
|
8328
|
-
status:
|
|
9309
|
+
status: import_zod25.z.enum([
|
|
8329
9310
|
"classifying",
|
|
8330
9311
|
"extracting",
|
|
8331
9312
|
"auto_filling",
|
|
@@ -8339,8 +9320,8 @@ var ApplicationStateSchema = import_zod24.z.object({
|
|
|
8339
9320
|
"cancelled",
|
|
8340
9321
|
"complete"
|
|
8341
9322
|
]),
|
|
8342
|
-
createdAt:
|
|
8343
|
-
updatedAt:
|
|
9323
|
+
createdAt: import_zod25.z.number(),
|
|
9324
|
+
updatedAt: import_zod25.z.number()
|
|
8344
9325
|
});
|
|
8345
9326
|
|
|
8346
9327
|
// src/application/agents/classifier.ts
|
|
@@ -10074,106 +11055,106 @@ Respond with the final answer, deduplicated citations array, overall confidence
|
|
|
10074
11055
|
}
|
|
10075
11056
|
|
|
10076
11057
|
// src/schemas/query.ts
|
|
10077
|
-
var
|
|
10078
|
-
var QueryIntentSchema =
|
|
11058
|
+
var import_zod26 = require("zod");
|
|
11059
|
+
var QueryIntentSchema = import_zod26.z.enum([
|
|
10079
11060
|
"policy_question",
|
|
10080
11061
|
"coverage_comparison",
|
|
10081
11062
|
"document_search",
|
|
10082
11063
|
"claims_inquiry",
|
|
10083
11064
|
"general_knowledge"
|
|
10084
11065
|
]);
|
|
10085
|
-
var QueryAttachmentKindSchema =
|
|
10086
|
-
var QueryAttachmentSchema =
|
|
10087
|
-
id:
|
|
11066
|
+
var QueryAttachmentKindSchema = import_zod26.z.enum(["image", "pdf", "text"]);
|
|
11067
|
+
var QueryAttachmentSchema = import_zod26.z.object({
|
|
11068
|
+
id: import_zod26.z.string().optional().describe("Optional stable attachment ID from the caller"),
|
|
10088
11069
|
kind: QueryAttachmentKindSchema,
|
|
10089
|
-
name:
|
|
10090
|
-
mimeType:
|
|
10091
|
-
base64:
|
|
10092
|
-
text:
|
|
10093
|
-
description:
|
|
11070
|
+
name: import_zod26.z.string().optional().describe("Original filename or user-facing label"),
|
|
11071
|
+
mimeType: import_zod26.z.string().optional().describe("MIME type such as image/jpeg or application/pdf"),
|
|
11072
|
+
base64: import_zod26.z.string().optional().describe("Base64-encoded file content for image/pdf attachments"),
|
|
11073
|
+
text: import_zod26.z.string().optional().describe("Plain-text attachment content when available"),
|
|
11074
|
+
description: import_zod26.z.string().optional().describe("Caller-provided description of the attachment")
|
|
10094
11075
|
});
|
|
10095
|
-
var QueryRetrievalModeSchema =
|
|
11076
|
+
var QueryRetrievalModeSchema = import_zod26.z.enum([
|
|
10096
11077
|
"graph_only",
|
|
10097
11078
|
"source_rag",
|
|
10098
11079
|
"long_context",
|
|
10099
11080
|
"hybrid"
|
|
10100
11081
|
]);
|
|
10101
|
-
var SubQuestionSchema =
|
|
10102
|
-
question:
|
|
11082
|
+
var SubQuestionSchema = import_zod26.z.object({
|
|
11083
|
+
question: import_zod26.z.string().describe("Atomic sub-question to retrieve and answer independently"),
|
|
10103
11084
|
intent: QueryIntentSchema,
|
|
10104
|
-
chunkTypes:
|
|
10105
|
-
documentFilters:
|
|
10106
|
-
type:
|
|
10107
|
-
carrier:
|
|
10108
|
-
insuredName:
|
|
10109
|
-
policyNumber:
|
|
10110
|
-
quoteNumber:
|
|
10111
|
-
linesOfBusiness:
|
|
11085
|
+
chunkTypes: import_zod26.z.array(import_zod26.z.string()).optional().describe("Chunk types to filter retrieval (e.g. coverage, endorsement, declaration)"),
|
|
11086
|
+
documentFilters: import_zod26.z.object({
|
|
11087
|
+
type: import_zod26.z.enum(["policy", "quote"]).optional(),
|
|
11088
|
+
carrier: import_zod26.z.string().optional(),
|
|
11089
|
+
insuredName: import_zod26.z.string().optional(),
|
|
11090
|
+
policyNumber: import_zod26.z.string().optional(),
|
|
11091
|
+
quoteNumber: import_zod26.z.string().optional(),
|
|
11092
|
+
linesOfBusiness: import_zod26.z.array(AcordLobCodeSchema).optional().describe("Filter by ACORD line of business code (e.g. HOME, AUTOP, DISAB) to avoid mixing up similar policies")
|
|
10112
11093
|
}).optional().describe("Structured filters to narrow document lookup")
|
|
10113
11094
|
});
|
|
10114
|
-
var QueryClassifyResultSchema =
|
|
11095
|
+
var QueryClassifyResultSchema = import_zod26.z.object({
|
|
10115
11096
|
intent: QueryIntentSchema,
|
|
10116
|
-
subQuestions:
|
|
10117
|
-
requiresDocumentLookup:
|
|
10118
|
-
requiresChunkSearch:
|
|
10119
|
-
requiresConversationHistory:
|
|
11097
|
+
subQuestions: import_zod26.z.array(SubQuestionSchema).min(1).describe("Decomposed atomic sub-questions"),
|
|
11098
|
+
requiresDocumentLookup: import_zod26.z.boolean().describe("Whether structured document lookup is needed"),
|
|
11099
|
+
requiresChunkSearch: import_zod26.z.boolean().describe("Whether semantic chunk search is needed"),
|
|
11100
|
+
requiresConversationHistory: import_zod26.z.boolean().describe("Whether conversation history is relevant"),
|
|
10120
11101
|
retrievalMode: QueryRetrievalModeSchema.optional().describe("Preferred retrieval strategy for the query when source-span retrieval is available")
|
|
10121
11102
|
});
|
|
10122
|
-
var EvidenceItemSchema =
|
|
10123
|
-
source:
|
|
10124
|
-
chunkId:
|
|
10125
|
-
sourceNodeId:
|
|
10126
|
-
sourceSpanId:
|
|
10127
|
-
documentId:
|
|
10128
|
-
turnId:
|
|
10129
|
-
attachmentId:
|
|
10130
|
-
text:
|
|
10131
|
-
relevance:
|
|
11103
|
+
var EvidenceItemSchema = import_zod26.z.object({
|
|
11104
|
+
source: import_zod26.z.enum(["chunk", "document", "conversation", "attachment", "source_span", "source_node"]),
|
|
11105
|
+
chunkId: import_zod26.z.string().optional(),
|
|
11106
|
+
sourceNodeId: import_zod26.z.string().optional(),
|
|
11107
|
+
sourceSpanId: import_zod26.z.string().optional(),
|
|
11108
|
+
documentId: import_zod26.z.string().optional(),
|
|
11109
|
+
turnId: import_zod26.z.string().optional(),
|
|
11110
|
+
attachmentId: import_zod26.z.string().optional(),
|
|
11111
|
+
text: import_zod26.z.string().describe("Text excerpt from the source"),
|
|
11112
|
+
relevance: import_zod26.z.number().min(0).max(1),
|
|
10132
11113
|
retrievalMode: QueryRetrievalModeSchema.optional(),
|
|
10133
11114
|
sourceLocation: SourceSpanLocationSchema.optional(),
|
|
10134
|
-
metadata:
|
|
10135
|
-
});
|
|
10136
|
-
var AttachmentInterpretationSchema =
|
|
10137
|
-
summary:
|
|
10138
|
-
extractedFacts:
|
|
10139
|
-
recommendedFocus:
|
|
10140
|
-
confidence:
|
|
10141
|
-
});
|
|
10142
|
-
var RetrievalResultSchema =
|
|
10143
|
-
subQuestion:
|
|
10144
|
-
evidence:
|
|
10145
|
-
});
|
|
10146
|
-
var CitationSchema =
|
|
10147
|
-
index:
|
|
10148
|
-
chunkId:
|
|
10149
|
-
sourceNodeId:
|
|
10150
|
-
sourceSpanId:
|
|
10151
|
-
documentId:
|
|
10152
|
-
documentType:
|
|
10153
|
-
field:
|
|
10154
|
-
quote:
|
|
10155
|
-
relevance:
|
|
11115
|
+
metadata: import_zod26.z.array(import_zod26.z.object({ key: import_zod26.z.string(), value: import_zod26.z.string() })).optional()
|
|
11116
|
+
});
|
|
11117
|
+
var AttachmentInterpretationSchema = import_zod26.z.object({
|
|
11118
|
+
summary: import_zod26.z.string().describe("Concise summary of what the attachment shows or contains"),
|
|
11119
|
+
extractedFacts: import_zod26.z.array(import_zod26.z.string()).describe("Specific observable or document facts grounded in the attachment"),
|
|
11120
|
+
recommendedFocus: import_zod26.z.array(import_zod26.z.string()).describe("Important details to incorporate when answering follow-up questions"),
|
|
11121
|
+
confidence: import_zod26.z.number().min(0).max(1)
|
|
11122
|
+
});
|
|
11123
|
+
var RetrievalResultSchema = import_zod26.z.object({
|
|
11124
|
+
subQuestion: import_zod26.z.string(),
|
|
11125
|
+
evidence: import_zod26.z.array(EvidenceItemSchema)
|
|
11126
|
+
});
|
|
11127
|
+
var CitationSchema = import_zod26.z.object({
|
|
11128
|
+
index: import_zod26.z.number().describe("Citation number [1], [2], etc."),
|
|
11129
|
+
chunkId: import_zod26.z.string().optional().describe("Source chunk ID, e.g. doc-123:coverage:2"),
|
|
11130
|
+
sourceNodeId: import_zod26.z.string().optional().describe("Source tree node ID when available"),
|
|
11131
|
+
sourceSpanId: import_zod26.z.string().optional().describe("Precise source span ID when available"),
|
|
11132
|
+
documentId: import_zod26.z.string(),
|
|
11133
|
+
documentType: import_zod26.z.enum(["policy", "quote"]).optional(),
|
|
11134
|
+
field: import_zod26.z.string().optional().describe("Specific field path, e.g. coverages[0].deductible"),
|
|
11135
|
+
quote: import_zod26.z.string().describe("Exact text from source that supports the claim"),
|
|
11136
|
+
relevance: import_zod26.z.number().min(0).max(1),
|
|
10156
11137
|
retrievalMode: QueryRetrievalModeSchema.optional(),
|
|
10157
11138
|
sourceLocation: SourceSpanLocationSchema.optional()
|
|
10158
11139
|
});
|
|
10159
|
-
var SubAnswerSchema =
|
|
10160
|
-
subQuestion:
|
|
10161
|
-
answer:
|
|
10162
|
-
citations:
|
|
10163
|
-
confidence:
|
|
10164
|
-
needsMoreContext:
|
|
10165
|
-
});
|
|
10166
|
-
var VerifyResultSchema =
|
|
10167
|
-
approved:
|
|
10168
|
-
issues:
|
|
10169
|
-
retrySubQuestions:
|
|
10170
|
-
});
|
|
10171
|
-
var QueryResultSchema =
|
|
10172
|
-
answer:
|
|
10173
|
-
citations:
|
|
11140
|
+
var SubAnswerSchema = import_zod26.z.object({
|
|
11141
|
+
subQuestion: import_zod26.z.string(),
|
|
11142
|
+
answer: import_zod26.z.string(),
|
|
11143
|
+
citations: import_zod26.z.array(CitationSchema),
|
|
11144
|
+
confidence: import_zod26.z.number().min(0).max(1),
|
|
11145
|
+
needsMoreContext: import_zod26.z.boolean().describe("True if evidence was insufficient to answer fully")
|
|
11146
|
+
});
|
|
11147
|
+
var VerifyResultSchema = import_zod26.z.object({
|
|
11148
|
+
approved: import_zod26.z.boolean().describe("Whether all sub-answers are adequately grounded"),
|
|
11149
|
+
issues: import_zod26.z.array(import_zod26.z.string()).describe("Specific grounding or consistency issues found"),
|
|
11150
|
+
retrySubQuestions: import_zod26.z.array(import_zod26.z.string()).optional().describe("Sub-questions that need additional retrieval or re-reasoning")
|
|
11151
|
+
});
|
|
11152
|
+
var QueryResultSchema = import_zod26.z.object({
|
|
11153
|
+
answer: import_zod26.z.string(),
|
|
11154
|
+
citations: import_zod26.z.array(CitationSchema),
|
|
10174
11155
|
intent: QueryIntentSchema,
|
|
10175
|
-
confidence:
|
|
10176
|
-
followUp:
|
|
11156
|
+
confidence: import_zod26.z.number().min(0).max(1),
|
|
11157
|
+
followUp: import_zod26.z.string().optional().describe("Suggested follow-up question if applicable")
|
|
10177
11158
|
});
|
|
10178
11159
|
|
|
10179
11160
|
// src/query/retriever.ts
|
|
@@ -11240,7 +12221,7 @@ ${sa.answer}`).join("\n\n"),
|
|
|
11240
12221
|
}
|
|
11241
12222
|
|
|
11242
12223
|
// src/pce/index.ts
|
|
11243
|
-
var
|
|
12224
|
+
var import_zod27 = require("zod");
|
|
11244
12225
|
|
|
11245
12226
|
// src/prompts/pce/index.ts
|
|
11246
12227
|
function buildPceNormalizePrompt(input) {
|
|
@@ -11274,11 +12255,11 @@ ${input.openQuestions.map((question) => `- ${question.id}${question.fieldPath ?
|
|
|
11274
12255
|
}
|
|
11275
12256
|
|
|
11276
12257
|
// src/pce/index.ts
|
|
11277
|
-
var ReplyAnswersSchema =
|
|
11278
|
-
answers:
|
|
11279
|
-
questionId:
|
|
11280
|
-
fieldPath:
|
|
11281
|
-
answer:
|
|
12258
|
+
var ReplyAnswersSchema = import_zod27.z.object({
|
|
12259
|
+
answers: import_zod27.z.array(import_zod27.z.object({
|
|
12260
|
+
questionId: import_zod27.z.string().optional(),
|
|
12261
|
+
fieldPath: import_zod27.z.string().optional(),
|
|
12262
|
+
answer: import_zod27.z.string()
|
|
11282
12263
|
}))
|
|
11283
12264
|
});
|
|
11284
12265
|
function createPceAgent(config = {}) {
|
|
@@ -12032,23 +13013,23 @@ var AGENT_TOOLS = [
|
|
|
12032
13013
|
];
|
|
12033
13014
|
|
|
12034
13015
|
// src/prompts/extractors/carrier-info.ts
|
|
12035
|
-
var
|
|
12036
|
-
var CarrierInfoSchema =
|
|
12037
|
-
carrierName:
|
|
12038
|
-
carrierLegalName:
|
|
12039
|
-
naicNumber:
|
|
12040
|
-
amBestRating:
|
|
12041
|
-
admittedStatus:
|
|
12042
|
-
mga:
|
|
12043
|
-
underwriter:
|
|
12044
|
-
brokerAgency:
|
|
12045
|
-
brokerContactName:
|
|
12046
|
-
brokerLicenseNumber:
|
|
12047
|
-
policyNumber:
|
|
12048
|
-
effectiveDate:
|
|
12049
|
-
expirationDate:
|
|
12050
|
-
quoteNumber:
|
|
12051
|
-
proposedEffectiveDate:
|
|
13016
|
+
var import_zod28 = require("zod");
|
|
13017
|
+
var CarrierInfoSchema = import_zod28.z.object({
|
|
13018
|
+
carrierName: import_zod28.z.string().describe("Primary insurance company name for display"),
|
|
13019
|
+
carrierLegalName: import_zod28.z.string().optional().describe("Legal entity name of insurer"),
|
|
13020
|
+
naicNumber: import_zod28.z.string().optional().describe("NAIC company code"),
|
|
13021
|
+
amBestRating: import_zod28.z.string().optional().describe("AM Best rating, e.g. 'A+ XV'"),
|
|
13022
|
+
admittedStatus: import_zod28.z.enum(["admitted", "non_admitted", "surplus_lines"]).optional().describe("Admitted status of the carrier"),
|
|
13023
|
+
mga: import_zod28.z.string().optional().describe("Managing General Agent or Program Administrator name"),
|
|
13024
|
+
underwriter: import_zod28.z.string().optional().describe("Named individual underwriter"),
|
|
13025
|
+
brokerAgency: import_zod28.z.string().optional().describe("Broker or producer agency name"),
|
|
13026
|
+
brokerContactName: import_zod28.z.string().optional().describe("Broker or producer contact person name"),
|
|
13027
|
+
brokerLicenseNumber: import_zod28.z.string().optional().describe("Broker or producer license number"),
|
|
13028
|
+
policyNumber: import_zod28.z.string().optional().describe("Policy or quote reference number"),
|
|
13029
|
+
effectiveDate: import_zod28.z.string().optional().describe("Policy effective date (MM/DD/YYYY)"),
|
|
13030
|
+
expirationDate: import_zod28.z.string().optional().describe("Policy expiration date (MM/DD/YYYY)"),
|
|
13031
|
+
quoteNumber: import_zod28.z.string().optional().describe("Quote or proposal reference number"),
|
|
13032
|
+
proposedEffectiveDate: import_zod28.z.string().optional().describe("Proposed effective date for quotes (MM/DD/YYYY)")
|
|
12052
13033
|
});
|
|
12053
13034
|
function buildCarrierInfoPrompt() {
|
|
12054
13035
|
return `You are an expert insurance document analyst. Extract carrier and policy identification information from this document.
|
|
@@ -12071,21 +13052,21 @@ Return JSON only.`;
|
|
|
12071
13052
|
}
|
|
12072
13053
|
|
|
12073
13054
|
// src/prompts/extractors/named-insured.ts
|
|
12074
|
-
var
|
|
12075
|
-
var AdditionalNamedInsuredSchema =
|
|
12076
|
-
name:
|
|
12077
|
-
relationship:
|
|
13055
|
+
var import_zod29 = require("zod");
|
|
13056
|
+
var AdditionalNamedInsuredSchema = import_zod29.z.object({
|
|
13057
|
+
name: import_zod29.z.string(),
|
|
13058
|
+
relationship: import_zod29.z.string().optional().describe("e.g. subsidiary, affiliate"),
|
|
12078
13059
|
address: SourceBackedAddressSchema.optional()
|
|
12079
13060
|
}).merge(SourceProvenanceSchema);
|
|
12080
|
-
var ScheduledPartySchema =
|
|
12081
|
-
name:
|
|
13061
|
+
var ScheduledPartySchema = import_zod29.z.object({
|
|
13062
|
+
name: import_zod29.z.string(),
|
|
12082
13063
|
address: SourceBackedAddressSchema.optional()
|
|
12083
13064
|
}).merge(SourceProvenanceSchema);
|
|
12084
|
-
var NamedInsuredSchema2 =
|
|
12085
|
-
insuredName:
|
|
12086
|
-
insuredDba:
|
|
13065
|
+
var NamedInsuredSchema2 = import_zod29.z.object({
|
|
13066
|
+
insuredName: import_zod29.z.string().describe("Name of primary named insured"),
|
|
13067
|
+
insuredDba: import_zod29.z.string().optional().describe("Doing-business-as name"),
|
|
12087
13068
|
insuredAddress: SourceBackedAddressSchema.optional().describe("Primary insured mailing address"),
|
|
12088
|
-
insuredEntityType:
|
|
13069
|
+
insuredEntityType: import_zod29.z.enum([
|
|
12089
13070
|
"corporation",
|
|
12090
13071
|
"llc",
|
|
12091
13072
|
"partnership",
|
|
@@ -12098,12 +13079,12 @@ var NamedInsuredSchema2 = import_zod28.z.object({
|
|
|
12098
13079
|
"married_couple",
|
|
12099
13080
|
"other"
|
|
12100
13081
|
]).optional().describe("Legal entity type of the insured"),
|
|
12101
|
-
insuredFein:
|
|
12102
|
-
insuredSicCode:
|
|
12103
|
-
insuredNaicsCode:
|
|
12104
|
-
additionalNamedInsureds:
|
|
12105
|
-
lossPayees:
|
|
12106
|
-
mortgageHolders:
|
|
13082
|
+
insuredFein: import_zod29.z.string().optional().describe("Federal Employer Identification Number"),
|
|
13083
|
+
insuredSicCode: import_zod29.z.string().optional().describe("SIC code"),
|
|
13084
|
+
insuredNaicsCode: import_zod29.z.string().optional().describe("NAICS code"),
|
|
13085
|
+
additionalNamedInsureds: import_zod29.z.array(AdditionalNamedInsuredSchema).optional().describe("Additional named insureds listed on the policy"),
|
|
13086
|
+
lossPayees: import_zod29.z.array(ScheduledPartySchema).optional().describe("Loss payees listed on the policy"),
|
|
13087
|
+
mortgageHolders: import_zod29.z.array(ScheduledPartySchema).optional().describe("Mortgage holders / lienholders listed on the policy")
|
|
12107
13088
|
});
|
|
12108
13089
|
function buildNamedInsuredPrompt() {
|
|
12109
13090
|
return `You are an expert insurance document analyst. Extract all named insured information from this document.
|
|
@@ -12130,14 +13111,14 @@ Return JSON only.`;
|
|
|
12130
13111
|
}
|
|
12131
13112
|
|
|
12132
13113
|
// src/prompts/extractors/coverage-limits.ts
|
|
12133
|
-
var
|
|
13114
|
+
var import_zod30 = require("zod");
|
|
12134
13115
|
var ExtractorCoverageSchema = CoverageSchema.extend({
|
|
12135
|
-
coverageCode:
|
|
13116
|
+
coverageCode: import_zod30.z.string().optional().describe("Coverage code or class code")
|
|
12136
13117
|
});
|
|
12137
|
-
var CoverageLimitsSchema =
|
|
12138
|
-
coverages:
|
|
12139
|
-
coverageForm:
|
|
12140
|
-
retroactiveDate:
|
|
13118
|
+
var CoverageLimitsSchema = import_zod30.z.object({
|
|
13119
|
+
coverages: import_zod30.z.array(ExtractorCoverageSchema).describe("All coverages with their limits"),
|
|
13120
|
+
coverageForm: import_zod30.z.enum(["occurrence", "claims_made", "accident"]).optional().describe("Primary coverage trigger type"),
|
|
13121
|
+
retroactiveDate: import_zod30.z.string().optional().describe("Retroactive date for claims-made policies (MM/DD/YYYY)")
|
|
12141
13122
|
});
|
|
12142
13123
|
function buildCoverageLimitsPrompt() {
|
|
12143
13124
|
return `You are an expert insurance document analyst. Extract all coverage limits and deductibles from this document.
|
|
@@ -12179,14 +13160,14 @@ Return JSON only.`;
|
|
|
12179
13160
|
}
|
|
12180
13161
|
|
|
12181
13162
|
// src/prompts/extractors/endorsements.ts
|
|
12182
|
-
var
|
|
12183
|
-
var EndorsementsSchema =
|
|
12184
|
-
endorsements:
|
|
12185
|
-
|
|
12186
|
-
formNumber:
|
|
12187
|
-
editionDate:
|
|
12188
|
-
title:
|
|
12189
|
-
endorsementType:
|
|
13163
|
+
var import_zod31 = require("zod");
|
|
13164
|
+
var EndorsementsSchema = import_zod31.z.object({
|
|
13165
|
+
endorsements: import_zod31.z.array(
|
|
13166
|
+
import_zod31.z.object({
|
|
13167
|
+
formNumber: import_zod31.z.string().describe("Form number, e.g. 'CG 21 47'"),
|
|
13168
|
+
editionDate: import_zod31.z.string().optional().describe("Edition date, e.g. '12 07'"),
|
|
13169
|
+
title: import_zod31.z.string().describe("Endorsement title"),
|
|
13170
|
+
endorsementType: import_zod31.z.enum([
|
|
12190
13171
|
"additional_insured",
|
|
12191
13172
|
"waiver_of_subrogation",
|
|
12192
13173
|
"primary_noncontributory",
|
|
@@ -12206,12 +13187,12 @@ var EndorsementsSchema = import_zod30.z.object({
|
|
|
12206
13187
|
"territorial_extension",
|
|
12207
13188
|
"other"
|
|
12208
13189
|
]).describe("Endorsement type classification"),
|
|
12209
|
-
effectiveDate:
|
|
12210
|
-
affectedCoverageParts:
|
|
12211
|
-
namedParties:
|
|
12212
|
-
|
|
12213
|
-
name:
|
|
12214
|
-
role:
|
|
13190
|
+
effectiveDate: import_zod31.z.string().optional().describe("Endorsement effective date"),
|
|
13191
|
+
affectedCoverageParts: import_zod31.z.array(import_zod31.z.string()).optional().describe("Coverage parts affected by this endorsement"),
|
|
13192
|
+
namedParties: import_zod31.z.array(
|
|
13193
|
+
import_zod31.z.object({
|
|
13194
|
+
name: import_zod31.z.string().describe("Party name"),
|
|
13195
|
+
role: import_zod31.z.enum([
|
|
12215
13196
|
"additional_insured",
|
|
12216
13197
|
"loss_payee",
|
|
12217
13198
|
"mortgage_holder",
|
|
@@ -12220,18 +13201,18 @@ var EndorsementsSchema = import_zod30.z.object({
|
|
|
12220
13201
|
"designated_person",
|
|
12221
13202
|
"other"
|
|
12222
13203
|
]).describe("Party role"),
|
|
12223
|
-
relationship:
|
|
12224
|
-
scope:
|
|
13204
|
+
relationship: import_zod31.z.string().optional().describe("Relationship to insured"),
|
|
13205
|
+
scope: import_zod31.z.string().optional().describe("Scope of coverage for this party")
|
|
12225
13206
|
})
|
|
12226
13207
|
).optional().describe("Named parties (additional insureds, loss payees, etc.)"),
|
|
12227
|
-
keyTerms:
|
|
12228
|
-
premiumImpact:
|
|
12229
|
-
excerpt:
|
|
12230
|
-
content:
|
|
12231
|
-
pageStart:
|
|
12232
|
-
pageEnd:
|
|
12233
|
-
sourceSpanIds:
|
|
12234
|
-
sourceTextHash:
|
|
13208
|
+
keyTerms: import_zod31.z.array(import_zod31.z.string()).optional().describe("Key terms or notable provisions in the endorsement"),
|
|
13209
|
+
premiumImpact: import_zod31.z.string().optional().describe("Additional premium or credit"),
|
|
13210
|
+
excerpt: import_zod31.z.string().optional().describe("Short source excerpt, not full verbatim text"),
|
|
13211
|
+
content: import_zod31.z.string().optional().describe("Legacy fallback only; do not return full text when sourceSpanIds are available"),
|
|
13212
|
+
pageStart: import_zod31.z.number().describe("Starting page number of this endorsement"),
|
|
13213
|
+
pageEnd: import_zod31.z.number().optional().describe("Ending page number of this endorsement"),
|
|
13214
|
+
sourceSpanIds: import_zod31.z.array(import_zod31.z.string()).optional().describe("Source span IDs grounding this endorsement"),
|
|
13215
|
+
sourceTextHash: import_zod31.z.string().optional().describe("Hash of the source text when available")
|
|
12235
13216
|
})
|
|
12236
13217
|
).describe("All endorsements found in the document")
|
|
12237
13218
|
});
|
|
@@ -12269,20 +13250,20 @@ Return JSON only.`;
|
|
|
12269
13250
|
}
|
|
12270
13251
|
|
|
12271
13252
|
// src/prompts/extractors/exclusions.ts
|
|
12272
|
-
var
|
|
12273
|
-
var ExclusionsSchema =
|
|
12274
|
-
exclusions:
|
|
12275
|
-
|
|
12276
|
-
name:
|
|
12277
|
-
formNumber:
|
|
12278
|
-
excludedPerils:
|
|
12279
|
-
isAbsolute:
|
|
12280
|
-
exceptions:
|
|
12281
|
-
buybackAvailable:
|
|
12282
|
-
buybackEndorsement:
|
|
12283
|
-
appliesTo:
|
|
12284
|
-
content:
|
|
12285
|
-
pageNumber:
|
|
13253
|
+
var import_zod32 = require("zod");
|
|
13254
|
+
var ExclusionsSchema = import_zod32.z.object({
|
|
13255
|
+
exclusions: import_zod32.z.array(
|
|
13256
|
+
import_zod32.z.object({
|
|
13257
|
+
name: import_zod32.z.string().describe("Exclusion title or short description"),
|
|
13258
|
+
formNumber: import_zod32.z.string().optional().describe("Form number if part of a named endorsement"),
|
|
13259
|
+
excludedPerils: import_zod32.z.array(import_zod32.z.string()).optional().describe("Specific perils excluded"),
|
|
13260
|
+
isAbsolute: import_zod32.z.boolean().optional().describe("Whether the exclusion is absolute (no exceptions)"),
|
|
13261
|
+
exceptions: import_zod32.z.array(import_zod32.z.string()).optional().describe("Exceptions to the exclusion, if any"),
|
|
13262
|
+
buybackAvailable: import_zod32.z.boolean().optional().describe("Whether coverage can be bought back via endorsement"),
|
|
13263
|
+
buybackEndorsement: import_zod32.z.string().optional().describe("Form number of the buyback endorsement if available"),
|
|
13264
|
+
appliesTo: import_zod32.z.array(import_zod32.z.string()).optional().describe("Policy types this exclusion applies to"),
|
|
13265
|
+
content: import_zod32.z.string().describe("Full verbatim exclusion text"),
|
|
13266
|
+
pageNumber: import_zod32.z.number().optional().describe("Page number where exclusion appears")
|
|
12286
13267
|
})
|
|
12287
13268
|
).describe("All exclusions found in the document")
|
|
12288
13269
|
});
|
|
@@ -12318,12 +13299,12 @@ Return JSON only.`;
|
|
|
12318
13299
|
}
|
|
12319
13300
|
|
|
12320
13301
|
// src/prompts/extractors/conditions.ts
|
|
12321
|
-
var
|
|
12322
|
-
var ConditionsSchema =
|
|
12323
|
-
conditions:
|
|
12324
|
-
|
|
12325
|
-
name:
|
|
12326
|
-
conditionType:
|
|
13302
|
+
var import_zod33 = require("zod");
|
|
13303
|
+
var ConditionsSchema = import_zod33.z.object({
|
|
13304
|
+
conditions: import_zod33.z.array(
|
|
13305
|
+
import_zod33.z.object({
|
|
13306
|
+
name: import_zod33.z.string().describe("Condition title"),
|
|
13307
|
+
conditionType: import_zod33.z.enum([
|
|
12327
13308
|
"duties_after_loss",
|
|
12328
13309
|
"notice_requirements",
|
|
12329
13310
|
"other_insurance",
|
|
@@ -12342,14 +13323,14 @@ var ConditionsSchema = import_zod32.z.object({
|
|
|
12342
13323
|
"separation_of_insureds",
|
|
12343
13324
|
"other"
|
|
12344
13325
|
]).describe("Condition category"),
|
|
12345
|
-
content:
|
|
12346
|
-
keyValues:
|
|
12347
|
-
|
|
12348
|
-
key:
|
|
12349
|
-
value:
|
|
13326
|
+
content: import_zod33.z.string().describe("Full verbatim condition text"),
|
|
13327
|
+
keyValues: import_zod33.z.array(
|
|
13328
|
+
import_zod33.z.object({
|
|
13329
|
+
key: import_zod33.z.string().describe("Key name (e.g. 'noticePeriod', 'suitDeadline')"),
|
|
13330
|
+
value: import_zod33.z.string().describe("Value (e.g. '30 days', '2 years')")
|
|
12350
13331
|
})
|
|
12351
13332
|
).optional().describe("Key values extracted from the condition (notice periods, deadlines, etc.)"),
|
|
12352
|
-
pageNumber:
|
|
13333
|
+
pageNumber: import_zod33.z.number().optional().describe("Page number where condition appears")
|
|
12353
13334
|
})
|
|
12354
13335
|
).describe("All policy conditions found in the document")
|
|
12355
13336
|
});
|
|
@@ -12387,34 +13368,34 @@ Return JSON only.`;
|
|
|
12387
13368
|
}
|
|
12388
13369
|
|
|
12389
13370
|
// src/prompts/extractors/premium-breakdown.ts
|
|
12390
|
-
var
|
|
12391
|
-
var PremiumBreakdownSchema =
|
|
12392
|
-
premium:
|
|
12393
|
-
premiumAmount:
|
|
12394
|
-
totalCost:
|
|
12395
|
-
totalCostAmount:
|
|
12396
|
-
premiumBreakdown:
|
|
12397
|
-
|
|
12398
|
-
line:
|
|
12399
|
-
amount:
|
|
12400
|
-
amountValue:
|
|
13371
|
+
var import_zod34 = require("zod");
|
|
13372
|
+
var PremiumBreakdownSchema = import_zod34.z.object({
|
|
13373
|
+
premium: import_zod34.z.string().optional().describe("Total premium amount, e.g. '$5,000'"),
|
|
13374
|
+
premiumAmount: import_zod34.z.number().optional().describe("Total premium as a plain number with no currency symbols or commas"),
|
|
13375
|
+
totalCost: import_zod34.z.string().optional().describe("Total cost including taxes and fees, e.g. '$5,250'"),
|
|
13376
|
+
totalCostAmount: import_zod34.z.number().optional().describe("Total cost as a plain number with no currency symbols or commas"),
|
|
13377
|
+
premiumBreakdown: import_zod34.z.array(
|
|
13378
|
+
import_zod34.z.object({
|
|
13379
|
+
line: import_zod34.z.string().describe("Coverage line name"),
|
|
13380
|
+
amount: import_zod34.z.string().describe("Premium amount for this line"),
|
|
13381
|
+
amountValue: import_zod34.z.number().optional().describe("Premium amount as a plain number with no currency symbols or commas")
|
|
12401
13382
|
})
|
|
12402
13383
|
).optional().describe("Per-coverage-line premium breakdown"),
|
|
12403
|
-
taxesAndFees:
|
|
12404
|
-
|
|
12405
|
-
name:
|
|
12406
|
-
amount:
|
|
12407
|
-
amountValue:
|
|
12408
|
-
type:
|
|
13384
|
+
taxesAndFees: import_zod34.z.array(
|
|
13385
|
+
import_zod34.z.object({
|
|
13386
|
+
name: import_zod34.z.string().describe("Fee or tax name"),
|
|
13387
|
+
amount: import_zod34.z.string().describe("Dollar amount"),
|
|
13388
|
+
amountValue: import_zod34.z.number().optional().describe("Fee or tax amount as a plain number with no currency symbols or commas"),
|
|
13389
|
+
type: import_zod34.z.enum(["tax", "fee", "surcharge", "assessment"]).optional().describe("Fee category")
|
|
12409
13390
|
})
|
|
12410
13391
|
).optional().describe("Taxes, fees, surcharges, and assessments"),
|
|
12411
|
-
minimumPremium:
|
|
12412
|
-
minimumPremiumAmount:
|
|
12413
|
-
depositPremium:
|
|
12414
|
-
depositPremiumAmount:
|
|
12415
|
-
paymentPlan:
|
|
12416
|
-
auditType:
|
|
12417
|
-
ratingBasis:
|
|
13392
|
+
minimumPremium: import_zod34.z.string().optional().describe("Minimum premium if stated"),
|
|
13393
|
+
minimumPremiumAmount: import_zod34.z.number().optional().describe("Minimum premium as a plain number when the source states a fixed amount"),
|
|
13394
|
+
depositPremium: import_zod34.z.string().optional().describe("Deposit premium if stated"),
|
|
13395
|
+
depositPremiumAmount: import_zod34.z.number().optional().describe("Deposit premium as a plain number when the source states a fixed amount"),
|
|
13396
|
+
paymentPlan: import_zod34.z.string().optional().describe("Payment plan description"),
|
|
13397
|
+
auditType: import_zod34.z.enum(["annual", "semi_annual", "quarterly", "monthly", "final", "self"]).optional().describe("Premium audit type"),
|
|
13398
|
+
ratingBasis: import_zod34.z.string().optional().describe("Rating basis, e.g. payroll, revenue, area, units")
|
|
12418
13399
|
});
|
|
12419
13400
|
function buildPremiumBreakdownPrompt() {
|
|
12420
13401
|
return `You are an expert insurance document analyst. Extract all premium and cost information from this document.
|
|
@@ -12436,14 +13417,14 @@ Return JSON only.`;
|
|
|
12436
13417
|
}
|
|
12437
13418
|
|
|
12438
13419
|
// src/prompts/extractors/declarations.ts
|
|
12439
|
-
var
|
|
12440
|
-
var DeclarationsFieldSchema =
|
|
12441
|
-
field:
|
|
12442
|
-
value:
|
|
12443
|
-
section:
|
|
13420
|
+
var import_zod35 = require("zod");
|
|
13421
|
+
var DeclarationsFieldSchema = import_zod35.z.object({
|
|
13422
|
+
field: import_zod35.z.string().describe("Descriptive field name (e.g. 'policyNumber', 'effectiveDate', 'coverageALimit')"),
|
|
13423
|
+
value: import_zod35.z.string().describe("Extracted value exactly as it appears in the document"),
|
|
13424
|
+
section: import_zod35.z.string().optional().describe("Section or grouping this field belongs to (e.g. 'Coverage Limits', 'Vehicle Schedule')")
|
|
12444
13425
|
});
|
|
12445
|
-
var DeclarationsExtractSchema =
|
|
12446
|
-
fields:
|
|
13426
|
+
var DeclarationsExtractSchema = import_zod35.z.object({
|
|
13427
|
+
fields: import_zod35.z.array(DeclarationsFieldSchema).describe("All declarations page fields extracted as key-value pairs. Structure varies by line of business.")
|
|
12447
13428
|
});
|
|
12448
13429
|
function buildDeclarationsPrompt() {
|
|
12449
13430
|
return `You are an expert insurance document analyst. Extract all declarations page data from this document into a flexible key-value structure.
|
|
@@ -12483,21 +13464,21 @@ Preserve original values exactly as they appear. Return JSON only.`;
|
|
|
12483
13464
|
}
|
|
12484
13465
|
|
|
12485
13466
|
// src/prompts/extractors/loss-history.ts
|
|
12486
|
-
var
|
|
12487
|
-
var LossHistorySchema =
|
|
12488
|
-
lossSummary:
|
|
12489
|
-
individualClaims:
|
|
12490
|
-
|
|
12491
|
-
date:
|
|
12492
|
-
type:
|
|
12493
|
-
description:
|
|
12494
|
-
amountPaid:
|
|
12495
|
-
amountReserved:
|
|
12496
|
-
status:
|
|
12497
|
-
claimNumber:
|
|
13467
|
+
var import_zod36 = require("zod");
|
|
13468
|
+
var LossHistorySchema = import_zod36.z.object({
|
|
13469
|
+
lossSummary: import_zod36.z.string().optional().describe("Summary of loss history, e.g. '3 claims in past 5 years totaling $125,000'"),
|
|
13470
|
+
individualClaims: import_zod36.z.array(
|
|
13471
|
+
import_zod36.z.object({
|
|
13472
|
+
date: import_zod36.z.string().optional().describe("Date of loss or claim"),
|
|
13473
|
+
type: import_zod36.z.string().optional().describe("Type of claim, e.g. 'property damage', 'bodily injury'"),
|
|
13474
|
+
description: import_zod36.z.string().optional().describe("Brief description of the claim"),
|
|
13475
|
+
amountPaid: import_zod36.z.string().optional().describe("Amount paid"),
|
|
13476
|
+
amountReserved: import_zod36.z.string().optional().describe("Amount reserved"),
|
|
13477
|
+
status: import_zod36.z.enum(["open", "closed", "reopened"]).optional().describe("Claim status"),
|
|
13478
|
+
claimNumber: import_zod36.z.string().optional().describe("Claim reference number")
|
|
12498
13479
|
})
|
|
12499
13480
|
).optional().describe("Individual claim records"),
|
|
12500
|
-
experienceMod:
|
|
13481
|
+
experienceMod: import_zod36.z.string().optional().describe("Experience modification factor for workers comp, e.g. '0.85'")
|
|
12501
13482
|
});
|
|
12502
13483
|
function buildLossHistoryPrompt() {
|
|
12503
13484
|
return `You are an expert insurance document analyst. Extract all loss history and claims information from this document.
|
|
@@ -12514,21 +13495,21 @@ Return JSON only.`;
|
|
|
12514
13495
|
}
|
|
12515
13496
|
|
|
12516
13497
|
// src/prompts/extractors/sections.ts
|
|
12517
|
-
var
|
|
12518
|
-
var SubsectionSchema2 =
|
|
12519
|
-
title:
|
|
12520
|
-
sectionNumber:
|
|
12521
|
-
pageNumber:
|
|
12522
|
-
excerpt:
|
|
12523
|
-
content:
|
|
12524
|
-
sourceSpanIds:
|
|
12525
|
-
sourceTextHash:
|
|
12526
|
-
});
|
|
12527
|
-
var SectionsSchema =
|
|
12528
|
-
sections:
|
|
12529
|
-
|
|
12530
|
-
title:
|
|
12531
|
-
type:
|
|
13498
|
+
var import_zod37 = require("zod");
|
|
13499
|
+
var SubsectionSchema2 = import_zod37.z.object({
|
|
13500
|
+
title: import_zod37.z.string().describe("Subsection title"),
|
|
13501
|
+
sectionNumber: import_zod37.z.string().optional().describe("Subsection number"),
|
|
13502
|
+
pageNumber: import_zod37.z.number().optional().describe("Page number"),
|
|
13503
|
+
excerpt: import_zod37.z.string().optional().describe("Short source excerpt, not full verbatim text"),
|
|
13504
|
+
content: import_zod37.z.string().optional().describe("Legacy fallback only; do not return full text when sourceSpanIds are available"),
|
|
13505
|
+
sourceSpanIds: import_zod37.z.array(import_zod37.z.string()).optional().describe("Source span IDs grounding this subsection"),
|
|
13506
|
+
sourceTextHash: import_zod37.z.string().optional().describe("Hash of the source text when available")
|
|
13507
|
+
});
|
|
13508
|
+
var SectionsSchema = import_zod37.z.object({
|
|
13509
|
+
sections: import_zod37.z.array(
|
|
13510
|
+
import_zod37.z.object({
|
|
13511
|
+
title: import_zod37.z.string().describe("Section title"),
|
|
13512
|
+
type: import_zod37.z.enum([
|
|
12532
13513
|
"declarations",
|
|
12533
13514
|
"insuring_agreement",
|
|
12534
13515
|
"policy_form",
|
|
@@ -12543,13 +13524,13 @@ var SectionsSchema = import_zod36.z.object({
|
|
|
12543
13524
|
"regulatory",
|
|
12544
13525
|
"other"
|
|
12545
13526
|
]).describe("Section type classification"),
|
|
12546
|
-
excerpt:
|
|
12547
|
-
content:
|
|
12548
|
-
pageStart:
|
|
12549
|
-
pageEnd:
|
|
12550
|
-
sourceSpanIds:
|
|
12551
|
-
sourceTextHash:
|
|
12552
|
-
subsections:
|
|
13527
|
+
excerpt: import_zod37.z.string().optional().describe("Short source excerpt, not full verbatim text"),
|
|
13528
|
+
content: import_zod37.z.string().optional().describe("Legacy fallback only; do not return full text when sourceSpanIds are available"),
|
|
13529
|
+
pageStart: import_zod37.z.number().describe("Starting page number"),
|
|
13530
|
+
pageEnd: import_zod37.z.number().optional().describe("Ending page number"),
|
|
13531
|
+
sourceSpanIds: import_zod37.z.array(import_zod37.z.string()).optional().describe("Source span IDs grounding this section"),
|
|
13532
|
+
sourceTextHash: import_zod37.z.string().optional().describe("Hash of the source text when available"),
|
|
13533
|
+
subsections: import_zod37.z.array(SubsectionSchema2).optional().describe("Subsections within this section")
|
|
12553
13534
|
})
|
|
12554
13535
|
).describe("All document sections")
|
|
12555
13536
|
});
|
|
@@ -12583,20 +13564,20 @@ Return JSON only.`;
|
|
|
12583
13564
|
}
|
|
12584
13565
|
|
|
12585
13566
|
// src/prompts/extractors/supplementary.ts
|
|
12586
|
-
var
|
|
12587
|
-
var AuxiliaryFactSchema2 =
|
|
12588
|
-
key:
|
|
12589
|
-
value:
|
|
12590
|
-
subject:
|
|
12591
|
-
context:
|
|
12592
|
-
});
|
|
12593
|
-
var SupplementarySchema =
|
|
12594
|
-
regulatoryContacts:
|
|
12595
|
-
claimsContacts:
|
|
12596
|
-
thirdPartyAdministrators:
|
|
12597
|
-
cancellationNoticeDays:
|
|
12598
|
-
nonrenewalNoticeDays:
|
|
12599
|
-
auxiliaryFacts:
|
|
13567
|
+
var import_zod38 = require("zod");
|
|
13568
|
+
var AuxiliaryFactSchema2 = import_zod38.z.object({
|
|
13569
|
+
key: import_zod38.z.string().describe("Normalized machine-readable fact key, e.g. 'policyholder_age' or 'insured_name'"),
|
|
13570
|
+
value: import_zod38.z.string().describe("Concrete extracted fact value"),
|
|
13571
|
+
subject: import_zod38.z.string().optional().describe("Person, entity, vehicle, property, or schedule item this fact belongs to"),
|
|
13572
|
+
context: import_zod38.z.string().optional().describe("Short disambiguating context, such as 'Driver Schedule' or 'Named Insured'")
|
|
13573
|
+
});
|
|
13574
|
+
var SupplementarySchema = import_zod38.z.object({
|
|
13575
|
+
regulatoryContacts: import_zod38.z.array(ContactSchema).optional().describe("Regulatory body contacts (state department of insurance, ombudsman)"),
|
|
13576
|
+
claimsContacts: import_zod38.z.array(ContactSchema).optional().describe("Claims reporting contacts and instructions"),
|
|
13577
|
+
thirdPartyAdministrators: import_zod38.z.array(ContactSchema).optional().describe("Third-party administrators for claims handling"),
|
|
13578
|
+
cancellationNoticeDays: import_zod38.z.number().optional().describe("Required notice period for cancellation in days"),
|
|
13579
|
+
nonrenewalNoticeDays: import_zod38.z.number().optional().describe("Required notice period for nonrenewal in days"),
|
|
13580
|
+
auxiliaryFacts: import_zod38.z.array(AuxiliaryFactSchema2).optional().describe("Additional retrieval-only facts that do not fit the strict primary schema")
|
|
12600
13581
|
});
|
|
12601
13582
|
function buildSupplementaryPrompt(alreadyExtractedSummary) {
|
|
12602
13583
|
const exclusionBlock = alreadyExtractedSummary ? `
|
|
@@ -12636,17 +13617,17 @@ Return JSON only.`;
|
|
|
12636
13617
|
}
|
|
12637
13618
|
|
|
12638
13619
|
// src/prompts/extractors/definitions.ts
|
|
12639
|
-
var
|
|
12640
|
-
var DefinitionsSchema =
|
|
12641
|
-
definitions:
|
|
12642
|
-
|
|
12643
|
-
term:
|
|
12644
|
-
definition:
|
|
12645
|
-
pageNumber:
|
|
12646
|
-
formNumber:
|
|
12647
|
-
formTitle:
|
|
12648
|
-
sectionRef:
|
|
12649
|
-
originalContent:
|
|
13620
|
+
var import_zod39 = require("zod");
|
|
13621
|
+
var DefinitionsSchema = import_zod39.z.object({
|
|
13622
|
+
definitions: import_zod39.z.array(
|
|
13623
|
+
import_zod39.z.object({
|
|
13624
|
+
term: import_zod39.z.string().describe("Defined term exactly as shown in the document"),
|
|
13625
|
+
definition: import_zod39.z.string().describe("Full verbatim definition text, preserving original wording"),
|
|
13626
|
+
pageNumber: import_zod39.z.number().optional().describe("Original document page number"),
|
|
13627
|
+
formNumber: import_zod39.z.string().optional().describe("Form number where this definition appears"),
|
|
13628
|
+
formTitle: import_zod39.z.string().optional().describe("Form title where this definition appears"),
|
|
13629
|
+
sectionRef: import_zod39.z.string().optional().describe("Definition section heading or subsection reference"),
|
|
13630
|
+
originalContent: import_zod39.z.string().optional().describe("Short verbatim source snippet containing the term and definition")
|
|
12650
13631
|
})
|
|
12651
13632
|
).describe("All substantive insurance definitions found in the document")
|
|
12652
13633
|
});
|
|
@@ -12680,22 +13661,22 @@ Return JSON only.`;
|
|
|
12680
13661
|
}
|
|
12681
13662
|
|
|
12682
13663
|
// src/prompts/extractors/covered-reasons.ts
|
|
12683
|
-
var
|
|
12684
|
-
var CoveredReasonsSchema =
|
|
12685
|
-
coveredReasons:
|
|
12686
|
-
|
|
12687
|
-
coverageName:
|
|
12688
|
-
reasonNumber:
|
|
12689
|
-
title:
|
|
12690
|
-
content:
|
|
12691
|
-
conditions:
|
|
12692
|
-
exceptions:
|
|
12693
|
-
appliesTo:
|
|
12694
|
-
pageNumber:
|
|
12695
|
-
formNumber:
|
|
12696
|
-
formTitle:
|
|
12697
|
-
sectionRef:
|
|
12698
|
-
originalContent:
|
|
13664
|
+
var import_zod40 = require("zod");
|
|
13665
|
+
var CoveredReasonsSchema = import_zod40.z.object({
|
|
13666
|
+
coveredReasons: import_zod40.z.array(
|
|
13667
|
+
import_zod40.z.object({
|
|
13668
|
+
coverageName: import_zod40.z.string().describe("Coverage, coverage part, or form this covered reason belongs to"),
|
|
13669
|
+
reasonNumber: import_zod40.z.string().optional().describe("Source number or letter for the covered reason, if shown"),
|
|
13670
|
+
title: import_zod40.z.string().optional().describe("Covered reason title, peril, cause of loss, trigger, or short name"),
|
|
13671
|
+
content: import_zod40.z.string().describe("Full verbatim covered-reason or insuring-agreement text"),
|
|
13672
|
+
conditions: import_zod40.z.array(import_zod40.z.string()).optional().describe("Conditions, timing rules, documentation requirements, or prerequisites attached to this covered reason"),
|
|
13673
|
+
exceptions: import_zod40.z.array(import_zod40.z.string()).optional().describe("Exceptions or limitations attached to this covered reason"),
|
|
13674
|
+
appliesTo: import_zod40.z.array(import_zod40.z.string()).optional().describe("Covered property, persons, autos, locations, operations, or coverage parts this reason applies to"),
|
|
13675
|
+
pageNumber: import_zod40.z.number().optional().describe("Original document page number"),
|
|
13676
|
+
formNumber: import_zod40.z.string().optional().describe("Form number where this covered reason appears"),
|
|
13677
|
+
formTitle: import_zod40.z.string().optional().describe("Form title where this covered reason appears"),
|
|
13678
|
+
sectionRef: import_zod40.z.string().optional().describe("Section heading where this covered reason appears"),
|
|
13679
|
+
originalContent: import_zod40.z.string().optional().describe("Short verbatim source snippet used for this covered reason")
|
|
12699
13680
|
})
|
|
12700
13681
|
).describe("Covered causes, perils, triggers, or reasons that affirmatively grant coverage")
|
|
12701
13682
|
});
|
|
@@ -13688,10 +14669,15 @@ function getTemplate(policyType) {
|
|
|
13688
14669
|
NamedInsuredSchema,
|
|
13689
14670
|
OperationalAddressSchema,
|
|
13690
14671
|
OperationalCoverageLineSchema,
|
|
14672
|
+
OperationalCoverageScheduleItemSchema,
|
|
14673
|
+
OperationalCoverageScheduleSchema,
|
|
14674
|
+
OperationalCoverageScheduleValueSchema,
|
|
13691
14675
|
OperationalCoverageTermSchema,
|
|
13692
14676
|
OperationalDeclarationFactSchema,
|
|
13693
14677
|
OperationalEndorsementSupportSchema,
|
|
13694
14678
|
OperationalPartySchema,
|
|
14679
|
+
OperationalPremiumLineSchema,
|
|
14680
|
+
OperationalTaxFeeItemSchema,
|
|
13695
14681
|
PERSONAL_AUTO_USAGES,
|
|
13696
14682
|
PERSONAL_LOB_CODES,
|
|
13697
14683
|
PET_SPECIES,
|
|
@@ -13878,6 +14864,8 @@ function getTemplate(policyType) {
|
|
|
13878
14864
|
proposeContextWrites,
|
|
13879
14865
|
resolveModelBudget,
|
|
13880
14866
|
resolveOperationalProfileLinesOfBusiness,
|
|
14867
|
+
runCoverageRecovery,
|
|
14868
|
+
runSourceTreeExtraction,
|
|
13881
14869
|
safeGenerateObject,
|
|
13882
14870
|
sanitizeNulls,
|
|
13883
14871
|
scoreCaseProposal,
|