@claritylabs/cl-sdk 0.17.1 → 0.18.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 +30 -6
- package/dist/index.d.mts +3543 -282
- package/dist/index.d.ts +3543 -282
- package/dist/index.js +2898 -659
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2836 -659
- package/dist/index.mjs.map +1 -1
- package/dist/storage-sqlite.d.mts +430 -1
- package/dist/storage-sqlite.d.ts +430 -1
- package/dist/storage-sqlite.js +346 -8
- package/dist/storage-sqlite.js.map +1 -1
- package/dist/storage-sqlite.mjs +343 -8
- package/dist/storage-sqlite.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# CL-SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Deterministic insurance intelligence primitives for regulated AI agents. Pure TypeScript, provider-agnostic — bring any LLM, any embedding model, any storage backend.
|
|
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,11 +12,14 @@ npm install @claritylabs/cl-sdk pdf-lib zod
|
|
|
12
12
|
|
|
13
13
|
## What It Does
|
|
14
14
|
|
|
15
|
-
- **Document Extraction** —
|
|
16
|
-
- **
|
|
17
|
-
- **
|
|
18
|
-
- **
|
|
19
|
-
- **
|
|
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)
|
|
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
|
+
- **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
|
+
- **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
|
+
- **Policy Change Endorsements** — PCE intake, evidence collection, missing-info handling, quality gates, execution mode selection, and reviewable submission packets
|
|
20
|
+
- **Case Workflows** — Shared primitives for evidence-backed proposals, missing information, validation issues, stable IDs, and packet artifacts
|
|
21
|
+
- **Agent System** — Composable prompt modules for building insurance-aware agents across email, chat, SMS, Slack, and Discord with human-reviewable behavior
|
|
22
|
+
- **Storage** — DocumentStore, MemoryStore, SourceStore, and ApplicationStore interfaces with reference implementations where appropriate
|
|
20
23
|
|
|
21
24
|
## Quick Start
|
|
22
25
|
|
|
@@ -38,9 +41,28 @@ const extractor = createExtractor({
|
|
|
38
41
|
const result = await extractor.extract(pdfBase64);
|
|
39
42
|
console.log(result.document); // Typed InsuranceDocument
|
|
40
43
|
console.log(result.chunks); // DocumentChunk[] for vector storage
|
|
44
|
+
console.log(result.sourceSpans); // SourceSpan[] when supplied by the host
|
|
41
45
|
console.log(result.reviewReport); // Quality gate results
|
|
42
46
|
```
|
|
43
47
|
|
|
48
|
+
## Source Grounding
|
|
49
|
+
|
|
50
|
+
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:
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
import { buildPageSourceSpans, MemorySourceStore, createExtractor } from "@claritylabs/cl-sdk";
|
|
54
|
+
|
|
55
|
+
const pageOneText = "..."; // text from your PDF text/OCR pipeline
|
|
56
|
+
const sourceSpans = buildPageSourceSpans([
|
|
57
|
+
{ documentId: "policy-123", sourceKind: "policy_pdf", pageNumber: 1, text: pageOneText },
|
|
58
|
+
]);
|
|
59
|
+
|
|
60
|
+
const sourceStore = new MemorySourceStore();
|
|
61
|
+
const extractor = createExtractor({ generateText, generateObject, sourceStore });
|
|
62
|
+
|
|
63
|
+
const result = await extractor.extract(pdfBase64, "policy-123", { sourceSpans });
|
|
64
|
+
```
|
|
65
|
+
|
|
44
66
|
See the [full documentation](https://cl-sdk.claritylabs.inc/docs) for architecture, provider setup, API reference, and more.
|
|
45
67
|
|
|
46
68
|
## Multimodal Querying
|
|
@@ -59,6 +81,7 @@ const agent = createQueryAgent({
|
|
|
59
81
|
generateObject,
|
|
60
82
|
documentStore,
|
|
61
83
|
memoryStore,
|
|
84
|
+
sourceRetriever,
|
|
62
85
|
});
|
|
63
86
|
|
|
64
87
|
const result = await agent.query({
|
|
@@ -88,6 +111,7 @@ Important: your `generateObject` callback must actually forward multimodal paylo
|
|
|
88
111
|
- `providerOptions.attachments` for generic image/pdf/text inputs
|
|
89
112
|
- `providerOptions.pdfBase64` for PDF inputs
|
|
90
113
|
- `providerOptions.images` for image inputs
|
|
114
|
+
- `providerOptions.sourceSpans` and `providerOptions.sourceChunks` for source evidence when your host passes them through
|
|
91
115
|
|
|
92
116
|
If your callback ignores those fields, the model will only see the text prompt.
|
|
93
117
|
|