@claritylabs/cl-sdk unless otherwise noted. Import them as named type imports to avoid bundling issues.
Provider Callback Types
These types define the function signatures your application must implement and pass to CL SDK factory functions. CL SDK is provider-agnostic — you supply the LLM and embedding calls.Calls your LLM provider to generate a text completion. Used by query agents, application pipeline, and classification prompts.
Calls your LLM provider to generate a structured JSON object conforming to schema
T. Used by the extractor, PCE agent, and all structured output steps.Calls your embedding provider to produce a vector representation of a text string. Required by
createSqliteStore and any SourceStore that uses vector search.Reported by the
onTokenUsage callback passed to factory functions. Track costs per extraction or query call.Optional async logging callback accepted by factory functions. Wire it to your application logger.
Core Extraction Types
Configuration passed to
createExtractor. Includes generateObject (required), sourceStore (optional), concurrency, onTokenUsage, and onProgress.string | URL | Uint8Array | { fileId: string } | { kind: 'docling_document'; document: DoclingDocument; sourceKind?: string }
Union type for all accepted extraction inputs. Strings are treated as base64-encoded PDFs.
Options passed to
extractor.extract(). Includes sourceSpans, documentId, and coverageRecovery.The output of a successful extraction. Includes the extracted
InsuranceDocument (compatibility projection), sourceSpans, sourceChunks, sourceTree (canonical source hierarchy), operationalProfile, optional coverageRecovery diagnostics, tokenUsage, performanceReport, and reviewReport.A source-backed projection of product-critical facts:
documentType, linesOfBusiness (ACORD codes), policyNumber, namedInsured, insurer, broker, effectiveDate, expirationDate, retroactiveDate, premium, operationsDescription, declarationFacts, coverages, coverageSchedules, premiumBreakdown, taxesAndFees, totalCost, parties, and endorsementSupport. Every value field is a SourceBackedValue.{ value: string; normalizedValue?: string; confidence?: 'low' | 'medium' | 'high'; sourceNodeIds: string[]; sourceSpanIds: string[] }
A wrapper type that pairs an extracted value with its source span and node IDs.
normalizedValue holds the display-safe canonical form for identity fields such as named insured, insurer, and policy number.Document Types
Top-level union type for all extracted documents. Discriminated by the
type field: "policy" or "quote".A bound insurance policy. Includes
id, type: 'policy', metadata, coverages, endorsements, exclusions, conditions, and operationalProfile.An insurance quote. Includes
id, type: 'quote', metadata, coverages, and operationalProfile. Quote documents may have incomplete coverage details.Represents a single coverage line. Includes
type (ACORD LOB code), limit, deductible, retention, description, and sourceSpanId.Common metadata fields:
carrier, insuredName, policyNumber, quoteNumber, effectiveDate, expirationDate, formNumbers, and namedInsureds.A node in the document’s structural hierarchy (form, endorsement, section, schedule). Used by the parser-grounded source node tree.
Source Grounding Types
The smallest addressable source unit. Fields:
id, documentId, sourceKind, kind, text, hash, pageStart, pageEnd, sectionId, formNumber, sourceUnit, parentSpanId, table, location, metadata. See the Source Spans page for the full schema.A retrieval window produced by
chunkSourceSpans. Fields: id, documentId, text, spanIds (source span IDs included in this chunk), pageStart, pageEnd.A node in the parser-grounded document hierarchy. Fields:
id, documentId, parentId, kind, title, description, textExcerpt, sourceSpanIds, pageStart, pageEnd, bbox, order, path, metadata.One of:
"document" | "page_group" | "page" | "form" | "endorsement" | "section" | "schedule" | "clause" | "table" | "table_row" | "table_cell" | "text"Storage Interfaces
save, get, query, delete. See Storage Overview for the full interface.addChunks, search, addTurn, getHistory, searchHistory. Handles document chunks and conversation history.addSourceSpans, addSourceChunks, getSourceSpan, getSourceSpansByDocument, getSourceChunksByDocument, deleteDocumentSource, plus all SourceRetriever methods.A chunk of document text stored in
MemoryStore. Fields: id, documentId, text, pageStart, pageEnd, metadata.A single conversational exchange stored in
MemoryStore. Fields: id, conversationId, role ("user" | "assistant" | "tool"), content, toolName, toolResult, timestamp.Agent Types
Configuration for
buildAgentSystemPrompt. See the System Prompt page for all fields.Schema-only tool definition compatible with Claude
tool_use. Fields: name, description, input_schema ({ type: "object", properties, required? }).PCE Types
Mutable state object managed by
createPceAgent. Holds the list of PolicyChangeItem objects, retrieval evidence, validation issues, and the current execution phase.A single endorsed change:
id, changeType, description, evidence (PceEvidenceSource[]), validationIssues, and confidence.The final output of a PCE workflow. Fields:
caseId, createdAt, changeItems, evidenceSources, qualityReport, and submissionNarrative.Case Types
A validation issue produced by
validatePceItems or validateQuotedEvidence. Fields: severity ("error" | "warning" | "info"), code, message, spanId, itemId.A quoted citation linking a case finding to a source span. Fields:
spanId, quote, pageStart, pageEnd, sectionId.