@claritylabs/cl-sdk 1.1.0 → 1.3.1
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 +18 -3
- package/dist/index.d.mts +322 -84
- package/dist/index.d.ts +322 -84
- package/dist/index.js +503 -144
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +498 -144
- package/dist/index.mjs.map +1 -1
- package/dist/storage-sqlite.d.mts +96 -34
- package/dist/storage-sqlite.d.ts +96 -34
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# CL-SDK
|
|
2
2
|
|
|
3
|
-
Deterministic insurance intelligence primitives for regulated AI agents.
|
|
3
|
+
Deterministic insurance intelligence primitives for regulated AI agents.
|
|
4
4
|
|
|
5
5
|
**[Documentation](https://cl-sdk.claritylabs.inc/docs)** | **[npm](https://www.npmjs.com/package/@claritylabs/cl-sdk)** | **[GitHub](https://github.com/claritylabs-inc/cl-sdk)**
|
|
6
6
|
|
|
@@ -12,7 +12,7 @@ npm install @claritylabs/cl-sdk pdf-lib zod
|
|
|
12
12
|
|
|
13
13
|
## What It Does
|
|
14
14
|
|
|
15
|
-
- **Document Extraction** — Deterministic extraction pipeline with focused model calls that turns insurance PDFs into structured data with page-level provenance, quality gates, first-class definitions and covered reasons, referential coverage resolution, cost-aware formatting, and automatic declarations-to-schema promotion (limits, deductibles, locations, broker, loss payees, premium, taxes/fees, summary)
|
|
15
|
+
- **Document Extraction** — Deterministic extraction pipeline with focused model calls that turns insurance PDFs or host-provided Docling documents into structured data with page-level provenance, quality gates, first-class definitions and covered reasons, referential coverage resolution, cost-aware formatting, and automatic declarations-to-schema promotion (limits, deductibles, locations, broker, loss payees, premium, taxes/fees, summary)
|
|
16
16
|
- **Source Grounding** — Shared source spans, source chunks, source stores, quoted evidence validation, and deterministic evidence ordering across extraction, query, application, PCE, and case workflows
|
|
17
17
|
- **Query Agent** — Citation-backed question answering over stored documents, source spans, and inbound photos/PDFs/text with sub-question decomposition, bounded retrieval planning, attachment-only reasoning when retrieval is unnecessary, and grounding verification
|
|
18
18
|
- **Application Processing** — Bounded workflows handle intake with deterministic planning — field extraction, prior-answer backfill, context auto-fill, document lookup gating, topic-based question batching, reply parsing, source-backed field provenance, and PDF mapping
|
|
@@ -50,6 +50,18 @@ console.log(result.sourceSpans); // SourceSpan[] when supplied by the host
|
|
|
50
50
|
console.log(result.reviewReport); // Quality gate results
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
+
### Optional Docling input
|
|
54
|
+
|
|
55
|
+
If your host pre-processes a PDF with [Docling](https://github.com/docling-project/docling), pass the serialized `DoclingDocument` JSON instead of a PDF. CL-SDK does not install or run Python Docling; it consumes the parsed document, builds source spans, and runs the same focused structuring pipeline over Docling page text.
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
const result = await extractor.extract({
|
|
59
|
+
kind: "docling_document",
|
|
60
|
+
document: doclingDocumentJson,
|
|
61
|
+
sourceKind: "policy_pdf",
|
|
62
|
+
}, "policy-123");
|
|
63
|
+
```
|
|
64
|
+
|
|
53
65
|
## Source Grounding
|
|
54
66
|
|
|
55
67
|
Source spans are the v1 evidence layer. Build spans from PDF text, OCR, emails, attachments, or structured fields, then pass them into extraction and downstream workflows:
|
|
@@ -68,6 +80,8 @@ const extractor = createExtractor({ generateText, generateObject, sourceStore })
|
|
|
68
80
|
const result = await extractor.extract(pdfBase64, "policy-123", { sourceSpans });
|
|
69
81
|
```
|
|
70
82
|
|
|
83
|
+
When source spans are available, section and endorsement extraction returns a compact index with page ranges, short excerpts, and `sourceSpanIds`/`sourceTextHash` instead of asking the model to reproduce full policy wording. Store `result.sourceSpans`/source chunks as the canonical evidence corpus for Q&A and source viewers; use `result.chunks` for structured facts and navigation metadata.
|
|
84
|
+
|
|
71
85
|
See the [full documentation](https://cl-sdk.claritylabs.inc/docs) for architecture, provider setup, API reference, and more.
|
|
72
86
|
|
|
73
87
|
## Multimodal Querying
|
|
@@ -116,13 +130,14 @@ Important: your `generateObject` callback must actually forward multimodal paylo
|
|
|
116
130
|
- `providerOptions.attachments` for generic image/pdf/text inputs
|
|
117
131
|
- `providerOptions.pdfBase64` for PDF inputs
|
|
118
132
|
- `providerOptions.images` for image inputs
|
|
133
|
+
- `providerOptions.doclingText` for host-provided Docling document inputs
|
|
119
134
|
- `providerOptions.sourceSpans` and `providerOptions.sourceChunks` for source evidence when your host passes them through
|
|
120
135
|
|
|
121
136
|
If your callback ignores those fields, the model will only see the text prompt.
|
|
122
137
|
|
|
123
138
|
## Model routing metadata
|
|
124
139
|
|
|
125
|
-
Every SDK model callback may receive `taskKind` and `
|
|
140
|
+
Every SDK model callback may receive `taskKind`, `budgetDiagnostics`, and `trace`. Hosts can use these provider-agnostic fields for cheap-first routing, fallback, and telemetry without the SDK hardcoding model names. Example task kinds include `extraction_classify`, `extraction_focused`, `extraction_review`, `query_reason`, `application_extract_fields`, and `pce_impact_analysis`. `budgetDiagnostics` includes the resolved max-token budget and truncation-risk warnings for the current subtask. `trace` identifies the current extractor, page range, format batch, or source-backed call so host logs can show what was being generated instead of a generic model-call label.
|
|
126
141
|
|
|
127
142
|
## Bounded Agentic Workflows
|
|
128
143
|
|