@claritylabs/cl-sdk 0.7.3 → 0.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +130 -40
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +130 -40
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -92,29 +92,40 @@ function toStrictSchema(schema) {
|
|
|
92
92
|
const fieldType = fieldDef?.type ?? field.type;
|
|
93
93
|
if (fieldType === "optional") {
|
|
94
94
|
const innerType = fieldDef?.innerType;
|
|
95
|
+
const description = field.description ?? fieldDef?.description ?? field._zod?.def?.description;
|
|
95
96
|
if (innerType) {
|
|
96
97
|
const transformed = toStrictSchema(innerType);
|
|
97
|
-
|
|
98
|
+
let nullable = z.nullable(transformed);
|
|
99
|
+
if (description) nullable = nullable.describe(description);
|
|
100
|
+
newShape[key] = nullable;
|
|
98
101
|
} else {
|
|
99
|
-
|
|
102
|
+
let nullable = z.nullable(field);
|
|
103
|
+
if (description) nullable = nullable.describe(description);
|
|
104
|
+
newShape[key] = nullable;
|
|
100
105
|
}
|
|
101
106
|
} else {
|
|
102
107
|
newShape[key] = toStrictSchema(field);
|
|
103
108
|
}
|
|
104
109
|
}
|
|
105
|
-
|
|
110
|
+
const objDesc = schema.description ?? def?.description ?? schema._zod?.def?.description;
|
|
111
|
+
const result = z.object(newShape);
|
|
112
|
+
return objDesc ? result.describe(objDesc) : result;
|
|
106
113
|
}
|
|
107
114
|
if (typeName === "array") {
|
|
108
115
|
const element = def?.element ?? schema.element;
|
|
109
116
|
if (element) {
|
|
110
|
-
|
|
117
|
+
const arrDesc = schema.description ?? def?.description ?? schema._zod?.def?.description;
|
|
118
|
+
const result = z.array(toStrictSchema(element));
|
|
119
|
+
return arrDesc ? result.describe(arrDesc) : result;
|
|
111
120
|
}
|
|
112
121
|
return schema;
|
|
113
122
|
}
|
|
114
123
|
if (typeName === "nullable") {
|
|
115
124
|
const innerType = def?.innerType;
|
|
116
125
|
if (innerType) {
|
|
117
|
-
|
|
126
|
+
const nullDesc = schema.description ?? def?.description ?? schema._zod?.def?.description;
|
|
127
|
+
const result = z.nullable(toStrictSchema(innerType));
|
|
128
|
+
return nullDesc ? result.describe(nullDesc) : result;
|
|
118
129
|
}
|
|
119
130
|
return schema;
|
|
120
131
|
}
|
|
@@ -2846,27 +2857,71 @@ import { z as z24 } from "zod";
|
|
|
2846
2857
|
var EndorsementsSchema = z24.object({
|
|
2847
2858
|
endorsements: z24.array(
|
|
2848
2859
|
z24.object({
|
|
2849
|
-
formNumber: z24.string().
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2860
|
+
formNumber: z24.string().describe("Form number, e.g. 'CG 21 47'"),
|
|
2861
|
+
editionDate: z24.string().optional().describe("Edition date, e.g. '12 07'"),
|
|
2862
|
+
title: z24.string().describe("Endorsement title"),
|
|
2863
|
+
endorsementType: z24.enum([
|
|
2864
|
+
"additional_insured",
|
|
2865
|
+
"waiver_of_subrogation",
|
|
2866
|
+
"primary_noncontributory",
|
|
2867
|
+
"blanket_additional_insured",
|
|
2868
|
+
"loss_payee",
|
|
2869
|
+
"mortgage_holder",
|
|
2870
|
+
"broadening",
|
|
2871
|
+
"restriction",
|
|
2872
|
+
"exclusion",
|
|
2873
|
+
"amendatory",
|
|
2874
|
+
"notice_of_cancellation",
|
|
2875
|
+
"designated_premises",
|
|
2876
|
+
"classification_change",
|
|
2877
|
+
"schedule_update",
|
|
2878
|
+
"deductible_change",
|
|
2879
|
+
"limit_change",
|
|
2880
|
+
"territorial_extension",
|
|
2881
|
+
"other"
|
|
2882
|
+
]).describe("Endorsement type classification"),
|
|
2853
2883
|
effectiveDate: z24.string().optional().describe("Endorsement effective date"),
|
|
2854
|
-
|
|
2855
|
-
|
|
2884
|
+
affectedCoverageParts: z24.array(z24.string()).optional().describe("Coverage parts affected by this endorsement"),
|
|
2885
|
+
namedParties: z24.array(
|
|
2886
|
+
z24.object({
|
|
2887
|
+
name: z24.string().describe("Party name"),
|
|
2888
|
+
role: z24.enum([
|
|
2889
|
+
"additional_insured",
|
|
2890
|
+
"loss_payee",
|
|
2891
|
+
"mortgage_holder",
|
|
2892
|
+
"certificate_holder",
|
|
2893
|
+
"waiver_beneficiary",
|
|
2894
|
+
"designated_person",
|
|
2895
|
+
"other"
|
|
2896
|
+
]).describe("Party role"),
|
|
2897
|
+
relationship: z24.string().optional().describe("Relationship to insured"),
|
|
2898
|
+
scope: z24.string().optional().describe("Scope of coverage for this party")
|
|
2899
|
+
})
|
|
2900
|
+
).optional().describe("Named parties (additional insureds, loss payees, etc.)"),
|
|
2901
|
+
keyTerms: z24.array(z24.string()).optional().describe("Key terms or notable provisions in the endorsement"),
|
|
2902
|
+
premiumImpact: z24.string().optional().describe("Additional premium or credit"),
|
|
2903
|
+
content: z24.string().describe("Full verbatim text of the endorsement"),
|
|
2904
|
+
pageStart: z24.number().describe("Starting page number of this endorsement"),
|
|
2905
|
+
pageEnd: z24.number().optional().describe("Ending page number of this endorsement")
|
|
2856
2906
|
})
|
|
2857
2907
|
).describe("All endorsements found in the document")
|
|
2858
2908
|
});
|
|
2859
2909
|
function buildEndorsementsPrompt() {
|
|
2860
2910
|
return `You are an expert insurance document analyst. Extract ALL endorsements from this document. Preserve original language verbatim.
|
|
2861
2911
|
|
|
2862
|
-
|
|
2863
|
-
-
|
|
2864
|
-
-
|
|
2865
|
-
-
|
|
2866
|
-
-
|
|
2867
|
-
-
|
|
2868
|
-
-
|
|
2869
|
-
-
|
|
2912
|
+
For EACH endorsement, extract:
|
|
2913
|
+
- formNumber: the form identifier (e.g. "CG 21 47") \u2014 REQUIRED
|
|
2914
|
+
- editionDate: the edition date if present (e.g. "12 07")
|
|
2915
|
+
- title: endorsement title \u2014 REQUIRED
|
|
2916
|
+
- endorsementType: classify as one of: additional_insured, waiver_of_subrogation, primary_noncontributory, blanket_additional_insured, loss_payee, mortgage_holder, broadening, restriction, exclusion, amendatory, notice_of_cancellation, designated_premises, classification_change, schedule_update, deductible_change, limit_change, territorial_extension, other
|
|
2917
|
+
- effectiveDate: endorsement effective date if shown
|
|
2918
|
+
- affectedCoverageParts: which coverage parts are modified
|
|
2919
|
+
- namedParties: for each party, extract name, role (additional_insured, loss_payee, mortgage_holder, certificate_holder, waiver_beneficiary, designated_person, other), relationship, and scope
|
|
2920
|
+
- keyTerms: notable provisions or key terms
|
|
2921
|
+
- premiumImpact: additional premium or credit if shown
|
|
2922
|
+
- content: full verbatim text \u2014 REQUIRED
|
|
2923
|
+
- pageStart: page number where endorsement begins \u2014 REQUIRED
|
|
2924
|
+
- pageEnd: page number where endorsement ends
|
|
2870
2925
|
|
|
2871
2926
|
PERSONAL LINES ENDORSEMENT RECOGNITION:
|
|
2872
2927
|
- HO 04 XX series: homeowners endorsements
|
|
@@ -2882,23 +2937,39 @@ import { z as z25 } from "zod";
|
|
|
2882
2937
|
var ExclusionsSchema = z25.object({
|
|
2883
2938
|
exclusions: z25.array(
|
|
2884
2939
|
z25.object({
|
|
2885
|
-
|
|
2886
|
-
content: z25.string().optional().describe("Full verbatim exclusion text"),
|
|
2940
|
+
name: z25.string().describe("Exclusion title or short description"),
|
|
2887
2941
|
formNumber: z25.string().optional().describe("Form number if part of a named endorsement"),
|
|
2888
|
-
|
|
2942
|
+
excludedPerils: z25.array(z25.string()).optional().describe("Specific perils excluded"),
|
|
2943
|
+
isAbsolute: z25.boolean().optional().describe("Whether the exclusion is absolute (no exceptions)"),
|
|
2944
|
+
exceptions: z25.array(z25.string()).optional().describe("Exceptions to the exclusion, if any"),
|
|
2945
|
+
buybackAvailable: z25.boolean().optional().describe("Whether coverage can be bought back via endorsement"),
|
|
2946
|
+
buybackEndorsement: z25.string().optional().describe("Form number of the buyback endorsement if available"),
|
|
2947
|
+
appliesTo: z25.array(z25.string()).optional().describe("Coverage types this exclusion applies to"),
|
|
2948
|
+
content: z25.string().describe("Full verbatim exclusion text"),
|
|
2949
|
+
pageNumber: z25.number().optional().describe("Page number where exclusion appears")
|
|
2889
2950
|
})
|
|
2890
2951
|
).describe("All exclusions found in the document")
|
|
2891
2952
|
});
|
|
2892
2953
|
function buildExclusionsPrompt() {
|
|
2893
2954
|
return `You are an expert insurance document analyst. Extract ALL exclusions from this document. Preserve original language verbatim.
|
|
2894
2955
|
|
|
2956
|
+
For EACH exclusion, extract:
|
|
2957
|
+
- name: exclusion title or short description \u2014 REQUIRED
|
|
2958
|
+
- formNumber: form number if the exclusion is part of a named endorsement
|
|
2959
|
+
- excludedPerils: specific perils being excluded
|
|
2960
|
+
- isAbsolute: true if the exclusion has no exceptions, false if exceptions exist
|
|
2961
|
+
- exceptions: any exceptions to the exclusion (things still covered despite the exclusion)
|
|
2962
|
+
- buybackAvailable: whether coverage can be purchased back via endorsement
|
|
2963
|
+
- buybackEndorsement: the form number of the buyback endorsement if known
|
|
2964
|
+
- appliesTo: which coverage types or lines this exclusion applies to (as an array)
|
|
2965
|
+
- content: full verbatim exclusion text \u2014 REQUIRED
|
|
2966
|
+
- pageNumber: page number where the exclusion appears
|
|
2967
|
+
|
|
2895
2968
|
Focus on:
|
|
2896
2969
|
- Named exclusions from exclusion schedules
|
|
2897
2970
|
- Exclusions embedded within endorsements
|
|
2898
2971
|
- Exclusions within insuring agreements or conditions if clearly labeled
|
|
2899
2972
|
- Full verbatim exclusion text \u2014 do not summarize
|
|
2900
|
-
- Form number if the exclusion is part of a named endorsement
|
|
2901
|
-
- Which coverage line the exclusion applies to, if specific
|
|
2902
2973
|
|
|
2903
2974
|
Common personal lines exclusion patterns: animal liability, business pursuits, home daycare, watercraft, aircraft.
|
|
2904
2975
|
|
|
@@ -2910,43 +2981,62 @@ import { z as z26 } from "zod";
|
|
|
2910
2981
|
var ConditionsSchema = z26.object({
|
|
2911
2982
|
conditions: z26.array(
|
|
2912
2983
|
z26.object({
|
|
2913
|
-
|
|
2984
|
+
name: z26.string().describe("Condition title"),
|
|
2985
|
+
conditionType: z26.enum([
|
|
2914
2986
|
"duties_after_loss",
|
|
2915
|
-
"
|
|
2987
|
+
"notice_requirements",
|
|
2988
|
+
"other_insurance",
|
|
2916
2989
|
"cancellation",
|
|
2917
2990
|
"nonrenewal",
|
|
2918
|
-
"subrogation",
|
|
2919
|
-
"other_insurance",
|
|
2920
2991
|
"transfer_of_rights",
|
|
2921
|
-
"examination_under_oath",
|
|
2922
|
-
"arbitration",
|
|
2923
|
-
"suit_against_us",
|
|
2924
2992
|
"liberalization",
|
|
2993
|
+
"arbitration",
|
|
2994
|
+
"concealment_fraud",
|
|
2995
|
+
"examination_under_oath",
|
|
2996
|
+
"legal_action",
|
|
2997
|
+
"loss_payment",
|
|
2998
|
+
"appraisal",
|
|
2999
|
+
"mortgage_holders",
|
|
3000
|
+
"policy_territory",
|
|
3001
|
+
"separation_of_insureds",
|
|
2925
3002
|
"other"
|
|
2926
|
-
]).
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
3003
|
+
]).describe("Condition category"),
|
|
3004
|
+
content: z26.string().describe("Full verbatim condition text"),
|
|
3005
|
+
keyValues: z26.array(
|
|
3006
|
+
z26.object({
|
|
3007
|
+
key: z26.string().describe("Key name (e.g. 'noticePeriod', 'suitDeadline')"),
|
|
3008
|
+
value: z26.string().describe("Value (e.g. '30 days', '2 years')")
|
|
3009
|
+
})
|
|
3010
|
+
).optional().describe("Key values extracted from the condition (notice periods, deadlines, etc.)"),
|
|
3011
|
+
pageNumber: z26.number().optional().describe("Page number where condition appears")
|
|
2930
3012
|
})
|
|
2931
3013
|
).describe("All policy conditions found in the document")
|
|
2932
3014
|
});
|
|
2933
3015
|
function buildConditionsPrompt() {
|
|
2934
3016
|
return `You are an expert insurance document analyst. Extract ALL policy conditions from this document. Preserve original language verbatim.
|
|
2935
3017
|
|
|
3018
|
+
For EACH condition, extract:
|
|
3019
|
+
- name: condition title \u2014 REQUIRED
|
|
3020
|
+
- conditionType: classify as one of: duties_after_loss, notice_requirements, other_insurance, cancellation, nonrenewal, transfer_of_rights, liberalization, arbitration, concealment_fraud, examination_under_oath, legal_action, loss_payment, appraisal, mortgage_holders, policy_territory, separation_of_insureds, other \u2014 REQUIRED
|
|
3021
|
+
- content: full verbatim condition text \u2014 REQUIRED
|
|
3022
|
+
- keyValues: extract specific values as key-value pairs (e.g. noticePeriod: "30 days", suitDeadline: "2 years")
|
|
3023
|
+
- pageNumber: page number where the condition appears
|
|
3024
|
+
|
|
2936
3025
|
Focus on:
|
|
2937
3026
|
- Duties after loss / notice of occurrence conditions
|
|
2938
|
-
-
|
|
2939
|
-
- Cancellation and nonrenewal conditions (extract notice period in days)
|
|
2940
|
-
- Subrogation / transfer of rights
|
|
3027
|
+
- Notice requirements (extract notice period as keyValue)
|
|
3028
|
+
- Cancellation and nonrenewal conditions (extract notice period in days as keyValue)
|
|
2941
3029
|
- Other insurance clause
|
|
3030
|
+
- Subrogation / transfer of rights
|
|
2942
3031
|
- Examination under oath
|
|
2943
3032
|
- Arbitration or appraisal provisions
|
|
2944
3033
|
- Suit against us / legal action conditions
|
|
2945
3034
|
- Liberalization clause
|
|
3035
|
+
- Concealment or fraud clause
|
|
3036
|
+
- Loss payment conditions
|
|
3037
|
+
- Mortgage holders clause
|
|
2946
3038
|
- Any other named conditions
|
|
2947
3039
|
|
|
2948
|
-
For cancellation and nonrenewal conditions, extract the specific notice period in days if stated.
|
|
2949
|
-
|
|
2950
3040
|
Return JSON only.`;
|
|
2951
3041
|
}
|
|
2952
3042
|
|