@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 CHANGED
@@ -333,29 +333,40 @@ function toStrictSchema(schema) {
333
333
  const fieldType = fieldDef?.type ?? field.type;
334
334
  if (fieldType === "optional") {
335
335
  const innerType = fieldDef?.innerType;
336
+ const description = field.description ?? fieldDef?.description ?? field._zod?.def?.description;
336
337
  if (innerType) {
337
338
  const transformed = toStrictSchema(innerType);
338
- newShape[key] = import_zod.z.nullable(transformed);
339
+ let nullable = import_zod.z.nullable(transformed);
340
+ if (description) nullable = nullable.describe(description);
341
+ newShape[key] = nullable;
339
342
  } else {
340
- newShape[key] = import_zod.z.nullable(field);
343
+ let nullable = import_zod.z.nullable(field);
344
+ if (description) nullable = nullable.describe(description);
345
+ newShape[key] = nullable;
341
346
  }
342
347
  } else {
343
348
  newShape[key] = toStrictSchema(field);
344
349
  }
345
350
  }
346
- return import_zod.z.object(newShape);
351
+ const objDesc = schema.description ?? def?.description ?? schema._zod?.def?.description;
352
+ const result = import_zod.z.object(newShape);
353
+ return objDesc ? result.describe(objDesc) : result;
347
354
  }
348
355
  if (typeName === "array") {
349
356
  const element = def?.element ?? schema.element;
350
357
  if (element) {
351
- return import_zod.z.array(toStrictSchema(element));
358
+ const arrDesc = schema.description ?? def?.description ?? schema._zod?.def?.description;
359
+ const result = import_zod.z.array(toStrictSchema(element));
360
+ return arrDesc ? result.describe(arrDesc) : result;
352
361
  }
353
362
  return schema;
354
363
  }
355
364
  if (typeName === "nullable") {
356
365
  const innerType = def?.innerType;
357
366
  if (innerType) {
358
- return import_zod.z.nullable(toStrictSchema(innerType));
367
+ const nullDesc = schema.description ?? def?.description ?? schema._zod?.def?.description;
368
+ const result = import_zod.z.nullable(toStrictSchema(innerType));
369
+ return nullDesc ? result.describe(nullDesc) : result;
359
370
  }
360
371
  return schema;
361
372
  }
@@ -3079,27 +3090,71 @@ var import_zod24 = require("zod");
3079
3090
  var EndorsementsSchema = import_zod24.z.object({
3080
3091
  endorsements: import_zod24.z.array(
3081
3092
  import_zod24.z.object({
3082
- formNumber: import_zod24.z.string().optional().describe("Form number, e.g. 'CG 21 47'"),
3083
- title: import_zod24.z.string().optional().describe("Endorsement title"),
3084
- type: import_zod24.z.enum(["broadening", "restrictive", "informational"]).optional().describe("Effect type: broadening adds coverage, restrictive limits it"),
3085
- content: import_zod24.z.string().optional().describe("Full verbatim text of the endorsement"),
3093
+ formNumber: import_zod24.z.string().describe("Form number, e.g. 'CG 21 47'"),
3094
+ editionDate: import_zod24.z.string().optional().describe("Edition date, e.g. '12 07'"),
3095
+ title: import_zod24.z.string().describe("Endorsement title"),
3096
+ endorsementType: import_zod24.z.enum([
3097
+ "additional_insured",
3098
+ "waiver_of_subrogation",
3099
+ "primary_noncontributory",
3100
+ "blanket_additional_insured",
3101
+ "loss_payee",
3102
+ "mortgage_holder",
3103
+ "broadening",
3104
+ "restriction",
3105
+ "exclusion",
3106
+ "amendatory",
3107
+ "notice_of_cancellation",
3108
+ "designated_premises",
3109
+ "classification_change",
3110
+ "schedule_update",
3111
+ "deductible_change",
3112
+ "limit_change",
3113
+ "territorial_extension",
3114
+ "other"
3115
+ ]).describe("Endorsement type classification"),
3086
3116
  effectiveDate: import_zod24.z.string().optional().describe("Endorsement effective date"),
3087
- premium: import_zod24.z.string().optional().describe("Additional premium or credit"),
3088
- parties: import_zod24.z.array(import_zod24.z.string()).optional().describe("Named parties (additional insureds, loss payees, etc.)")
3117
+ affectedCoverageParts: import_zod24.z.array(import_zod24.z.string()).optional().describe("Coverage parts affected by this endorsement"),
3118
+ namedParties: import_zod24.z.array(
3119
+ import_zod24.z.object({
3120
+ name: import_zod24.z.string().describe("Party name"),
3121
+ role: import_zod24.z.enum([
3122
+ "additional_insured",
3123
+ "loss_payee",
3124
+ "mortgage_holder",
3125
+ "certificate_holder",
3126
+ "waiver_beneficiary",
3127
+ "designated_person",
3128
+ "other"
3129
+ ]).describe("Party role"),
3130
+ relationship: import_zod24.z.string().optional().describe("Relationship to insured"),
3131
+ scope: import_zod24.z.string().optional().describe("Scope of coverage for this party")
3132
+ })
3133
+ ).optional().describe("Named parties (additional insureds, loss payees, etc.)"),
3134
+ keyTerms: import_zod24.z.array(import_zod24.z.string()).optional().describe("Key terms or notable provisions in the endorsement"),
3135
+ premiumImpact: import_zod24.z.string().optional().describe("Additional premium or credit"),
3136
+ content: import_zod24.z.string().describe("Full verbatim text of the endorsement"),
3137
+ pageStart: import_zod24.z.number().describe("Starting page number of this endorsement"),
3138
+ pageEnd: import_zod24.z.number().optional().describe("Ending page number of this endorsement")
3089
3139
  })
3090
3140
  ).describe("All endorsements found in the document")
3091
3141
  });
3092
3142
  function buildEndorsementsPrompt() {
3093
3143
  return `You are an expert insurance document analyst. Extract ALL endorsements from this document. Preserve original language verbatim.
3094
3144
 
3095
- Focus on:
3096
- - Every endorsement listed in the forms schedule or endorsement schedule
3097
- - Standalone endorsements modifying the base policy
3098
- - Form number and edition date (e.g. "CG 21 47 12 07")
3099
- - Endorsement title and full verbatim content
3100
- - Effect type: "broadening" if it adds or expands coverage, "restrictive" if it limits or excludes coverage, "informational" if it changes administrative terms only
3101
- - Additional premium or credit shown on the endorsement
3102
- - Named parties: additional insureds, loss payees, certificate holders, mortgagees
3145
+ For EACH endorsement, extract:
3146
+ - formNumber: the form identifier (e.g. "CG 21 47") \u2014 REQUIRED
3147
+ - editionDate: the edition date if present (e.g. "12 07")
3148
+ - title: endorsement title \u2014 REQUIRED
3149
+ - 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
3150
+ - effectiveDate: endorsement effective date if shown
3151
+ - affectedCoverageParts: which coverage parts are modified
3152
+ - namedParties: for each party, extract name, role (additional_insured, loss_payee, mortgage_holder, certificate_holder, waiver_beneficiary, designated_person, other), relationship, and scope
3153
+ - keyTerms: notable provisions or key terms
3154
+ - premiumImpact: additional premium or credit if shown
3155
+ - content: full verbatim text \u2014 REQUIRED
3156
+ - pageStart: page number where endorsement begins \u2014 REQUIRED
3157
+ - pageEnd: page number where endorsement ends
3103
3158
 
3104
3159
  PERSONAL LINES ENDORSEMENT RECOGNITION:
3105
3160
  - HO 04 XX series: homeowners endorsements
@@ -3115,23 +3170,39 @@ var import_zod25 = require("zod");
3115
3170
  var ExclusionsSchema = import_zod25.z.object({
3116
3171
  exclusions: import_zod25.z.array(
3117
3172
  import_zod25.z.object({
3118
- title: import_zod25.z.string().describe("Exclusion title or short description"),
3119
- content: import_zod25.z.string().optional().describe("Full verbatim exclusion text"),
3173
+ name: import_zod25.z.string().describe("Exclusion title or short description"),
3120
3174
  formNumber: import_zod25.z.string().optional().describe("Form number if part of a named endorsement"),
3121
- appliesTo: import_zod25.z.string().optional().describe("Coverage type this exclusion applies to")
3175
+ excludedPerils: import_zod25.z.array(import_zod25.z.string()).optional().describe("Specific perils excluded"),
3176
+ isAbsolute: import_zod25.z.boolean().optional().describe("Whether the exclusion is absolute (no exceptions)"),
3177
+ exceptions: import_zod25.z.array(import_zod25.z.string()).optional().describe("Exceptions to the exclusion, if any"),
3178
+ buybackAvailable: import_zod25.z.boolean().optional().describe("Whether coverage can be bought back via endorsement"),
3179
+ buybackEndorsement: import_zod25.z.string().optional().describe("Form number of the buyback endorsement if available"),
3180
+ appliesTo: import_zod25.z.array(import_zod25.z.string()).optional().describe("Coverage types this exclusion applies to"),
3181
+ content: import_zod25.z.string().describe("Full verbatim exclusion text"),
3182
+ pageNumber: import_zod25.z.number().optional().describe("Page number where exclusion appears")
3122
3183
  })
3123
3184
  ).describe("All exclusions found in the document")
3124
3185
  });
3125
3186
  function buildExclusionsPrompt() {
3126
3187
  return `You are an expert insurance document analyst. Extract ALL exclusions from this document. Preserve original language verbatim.
3127
3188
 
3189
+ For EACH exclusion, extract:
3190
+ - name: exclusion title or short description \u2014 REQUIRED
3191
+ - formNumber: form number if the exclusion is part of a named endorsement
3192
+ - excludedPerils: specific perils being excluded
3193
+ - isAbsolute: true if the exclusion has no exceptions, false if exceptions exist
3194
+ - exceptions: any exceptions to the exclusion (things still covered despite the exclusion)
3195
+ - buybackAvailable: whether coverage can be purchased back via endorsement
3196
+ - buybackEndorsement: the form number of the buyback endorsement if known
3197
+ - appliesTo: which coverage types or lines this exclusion applies to (as an array)
3198
+ - content: full verbatim exclusion text \u2014 REQUIRED
3199
+ - pageNumber: page number where the exclusion appears
3200
+
3128
3201
  Focus on:
3129
3202
  - Named exclusions from exclusion schedules
3130
3203
  - Exclusions embedded within endorsements
3131
3204
  - Exclusions within insuring agreements or conditions if clearly labeled
3132
3205
  - Full verbatim exclusion text \u2014 do not summarize
3133
- - Form number if the exclusion is part of a named endorsement
3134
- - Which coverage line the exclusion applies to, if specific
3135
3206
 
3136
3207
  Common personal lines exclusion patterns: animal liability, business pursuits, home daycare, watercraft, aircraft.
3137
3208
 
@@ -3143,43 +3214,62 @@ var import_zod26 = require("zod");
3143
3214
  var ConditionsSchema = import_zod26.z.object({
3144
3215
  conditions: import_zod26.z.array(
3145
3216
  import_zod26.z.object({
3146
- type: import_zod26.z.enum([
3217
+ name: import_zod26.z.string().describe("Condition title"),
3218
+ conditionType: import_zod26.z.enum([
3147
3219
  "duties_after_loss",
3148
- "cooperation",
3220
+ "notice_requirements",
3221
+ "other_insurance",
3149
3222
  "cancellation",
3150
3223
  "nonrenewal",
3151
- "subrogation",
3152
- "other_insurance",
3153
3224
  "transfer_of_rights",
3154
- "examination_under_oath",
3155
- "arbitration",
3156
- "suit_against_us",
3157
3225
  "liberalization",
3226
+ "arbitration",
3227
+ "concealment_fraud",
3228
+ "examination_under_oath",
3229
+ "legal_action",
3230
+ "loss_payment",
3231
+ "appraisal",
3232
+ "mortgage_holders",
3233
+ "policy_territory",
3234
+ "separation_of_insureds",
3158
3235
  "other"
3159
- ]).optional().describe("Condition category"),
3160
- title: import_zod26.z.string().describe("Condition title"),
3161
- content: import_zod26.z.string().optional().describe("Full verbatim condition text"),
3162
- noticeDays: import_zod26.z.number().optional().describe("Notice period in days if specified (e.g. cancellation notice)")
3236
+ ]).describe("Condition category"),
3237
+ content: import_zod26.z.string().describe("Full verbatim condition text"),
3238
+ keyValues: import_zod26.z.array(
3239
+ import_zod26.z.object({
3240
+ key: import_zod26.z.string().describe("Key name (e.g. 'noticePeriod', 'suitDeadline')"),
3241
+ value: import_zod26.z.string().describe("Value (e.g. '30 days', '2 years')")
3242
+ })
3243
+ ).optional().describe("Key values extracted from the condition (notice periods, deadlines, etc.)"),
3244
+ pageNumber: import_zod26.z.number().optional().describe("Page number where condition appears")
3163
3245
  })
3164
3246
  ).describe("All policy conditions found in the document")
3165
3247
  });
3166
3248
  function buildConditionsPrompt() {
3167
3249
  return `You are an expert insurance document analyst. Extract ALL policy conditions from this document. Preserve original language verbatim.
3168
3250
 
3251
+ For EACH condition, extract:
3252
+ - name: condition title \u2014 REQUIRED
3253
+ - 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
3254
+ - content: full verbatim condition text \u2014 REQUIRED
3255
+ - keyValues: extract specific values as key-value pairs (e.g. noticePeriod: "30 days", suitDeadline: "2 years")
3256
+ - pageNumber: page number where the condition appears
3257
+
3169
3258
  Focus on:
3170
3259
  - Duties after loss / notice of occurrence conditions
3171
- - Cooperation clause
3172
- - Cancellation and nonrenewal conditions (extract notice period in days)
3173
- - Subrogation / transfer of rights
3260
+ - Notice requirements (extract notice period as keyValue)
3261
+ - Cancellation and nonrenewal conditions (extract notice period in days as keyValue)
3174
3262
  - Other insurance clause
3263
+ - Subrogation / transfer of rights
3175
3264
  - Examination under oath
3176
3265
  - Arbitration or appraisal provisions
3177
3266
  - Suit against us / legal action conditions
3178
3267
  - Liberalization clause
3268
+ - Concealment or fraud clause
3269
+ - Loss payment conditions
3270
+ - Mortgage holders clause
3179
3271
  - Any other named conditions
3180
3272
 
3181
- For cancellation and nonrenewal conditions, extract the specific notice period in days if stated.
3182
-
3183
3273
  Return JSON only.`;
3184
3274
  }
3185
3275