@claritylabs/cl-sdk 2.0.1 → 3.0.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 +12 -11
- package/dist/index.d.mts +692 -20
- package/dist/index.d.ts +692 -20
- package/dist/index.js +1385 -253
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1374 -253
- package/dist/index.mjs.map +1 -1
- package/dist/storage-sqlite.d.mts +104 -0
- package/dist/storage-sqlite.d.ts +104 -0
- package/dist/storage-sqlite.js +80 -0
- package/dist/storage-sqlite.js.map +1 -1
- package/dist/storage-sqlite.mjs +80 -0
- package/dist/storage-sqlite.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -12,9 +12,9 @@ npm install @claritylabs/cl-sdk pdf-lib zod
|
|
|
12
12
|
|
|
13
13
|
## What It Does
|
|
14
14
|
|
|
15
|
-
- **Document Extraction** —
|
|
16
|
-
- **Source Grounding** — Shared source spans, hierarchical table row/cell evidence, source
|
|
17
|
-
- **Query Agent** — Citation-backed question answering over stored
|
|
15
|
+
- **Document Extraction** — Source-tree extraction that turns parser-provided PDF spans into a canonical hierarchy of document, page group, form, endorsement, section, schedule, clause, table, row, cell, and text nodes. Operational policy facts are source-backed projections from that tree, not the canonical source of truth.
|
|
16
|
+
- **Source Grounding** — Shared source spans, source nodes, hierarchical table row/cell evidence, source stores, quoted evidence validation, and deterministic evidence ordering across extraction, query, application, PCE, and case workflows.
|
|
17
|
+
- **Query Agent** — Citation-backed question answering over stored source nodes, exact 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
|
|
19
19
|
- **Policy Change Endorsements** — PCE intake, evidence collection, missing-info handling, quality gates, execution mode selection, and reviewable submission packets
|
|
20
20
|
- **Case Workflows** — Shared primitives for evidence-backed proposals, missing information, validation issues, stable IDs, and packet artifacts
|
|
@@ -44,15 +44,16 @@ const extractor = createExtractor({
|
|
|
44
44
|
});
|
|
45
45
|
|
|
46
46
|
const result = await extractor.extract(pdfBase64);
|
|
47
|
-
console.log(result.
|
|
48
|
-
console.log(result.
|
|
49
|
-
console.log(result.
|
|
50
|
-
console.log(result.
|
|
47
|
+
console.log(result.sourceTree); // DocumentSourceNode[] canonical hierarchy
|
|
48
|
+
console.log(result.sourceSpans); // SourceSpan[] smallest PDF evidence units
|
|
49
|
+
console.log(result.operationalProfile); // Source-backed facts for policy lists, COIs, compliance
|
|
50
|
+
console.log(result.document); // Compatibility InsuranceDocument projection
|
|
51
|
+
console.log(result.chunks); // [] on v3 source-tree extraction paths
|
|
51
52
|
```
|
|
52
53
|
|
|
53
54
|
### Optional Docling input
|
|
54
55
|
|
|
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,
|
|
56
|
+
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, constructs the same source tree, and projects operational facts from cited nodes. Docling tables are represented as table, row, and cell source spans; row spans are treated as the canonical evidence for extracted table facts.
|
|
56
57
|
|
|
57
58
|
```typescript
|
|
58
59
|
const result = await extractor.extract({
|
|
@@ -64,7 +65,7 @@ const result = await extractor.extract({
|
|
|
64
65
|
|
|
65
66
|
## Source Grounding
|
|
66
67
|
|
|
67
|
-
Source spans are the
|
|
68
|
+
Source spans are the smallest evidence layer. Build spans from PDF text, OCR, emails, attachments, or structured fields, then pass them into extraction and downstream workflows. The v3 extractor builds `DocumentSourceNode` hierarchy from those spans and returns an `operationalProfile` for product-critical facts:
|
|
68
69
|
|
|
69
70
|
```typescript
|
|
70
71
|
import { buildPageSourceSpans, MemorySourceStore, createExtractor } from "@claritylabs/cl-sdk";
|
|
@@ -80,9 +81,9 @@ const extractor = createExtractor({ generateText, generateObject, sourceStore })
|
|
|
80
81
|
const result = await extractor.extract(pdfBase64, "policy-123", { sourceSpans });
|
|
81
82
|
```
|
|
82
83
|
|
|
83
|
-
When source spans are available,
|
|
84
|
+
When source spans are available, extraction returns `sourceTree`, `sourceSpans`, `operationalProfile`, `warnings`, `tokenUsage`, and `performanceReport`. The source tree is canonical for policy wording and hierarchy. The operational profile contains policy metadata, parties, coverage lines, limits, deductibles, premiums, key dates, and endorsement-support facts, each with `sourceNodeIds` and `sourceSpanIds`.
|
|
84
85
|
|
|
85
|
-
|
|
86
|
+
Store `result.sourceTree` in a retrievable node index and embed node `description` values for search. Keep `result.sourceSpans` as the exact PDF highlighting layer. `result.document` and its `documentOutline` remain compatibility projections for existing host screens; do not treat broad structured policy JSON as canonical extraction truth.
|
|
86
87
|
|
|
87
88
|
See the [full documentation](https://cl-sdk.claritylabs.inc/docs) for architecture, provider setup, API reference, and more.
|
|
88
89
|
|