Skip to main content
All types below are exported from @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.
(params: GenerateTextParams) => Promise<GenerateTextResult>
Calls your LLM provider to generate a text completion. Used by query agents, application pipeline, and classification prompts.
(params: GenerateObjectParams<T>) => Promise<{ object: T }>
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.
(text: string) => Promise<number[]>
Calls your embedding provider to produce a vector representation of a text string. Required by createSqliteStore and any SourceStore that uses vector search.
{ inputTokens: number; outputTokens: number }
Reported by the onTokenUsage callback passed to factory functions. Track costs per extraction or query call.
(message: string) => Promise<void>
Optional async logging callback accepted by factory functions. Wire it to your application logger.

Core Extraction Types

object
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.
object
Options passed to extractor.extract(). Includes sourceSpans, documentId, and coverageRecovery.
object
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.
object
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

PolicyDocument | QuoteDocument
Top-level union type for all extracted documents. Discriminated by the type field: "policy" or "quote".
object
A bound insurance policy. Includes id, type: 'policy', metadata, coverages, endorsements, exclusions, conditions, and operationalProfile.
object
An insurance quote. Includes id, type: 'quote', metadata, coverages, and operationalProfile. Quote documents may have incomplete coverage details.
object
Represents a single coverage line. Includes type (ACORD LOB code), limit, deductible, retention, description, and sourceSpanId.
object
Common metadata fields: carrier, insuredName, policyNumber, quoteNumber, effectiveDate, expirationDate, formNumbers, and namedInsureds.
object
A node in the document’s structural hierarchy (form, endorsement, section, schedule). Used by the parser-grounded source node tree.

Source Grounding Types

object
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.
object
A retrieval window produced by chunkSourceSpans. Fields: id, documentId, text, spanIds (source span IDs included in this chunk), pageStart, pageEnd.
object
A node in the parser-grounded document hierarchy. Fields: id, documentId, parentId, kind, title, description, textExcerpt, sourceSpanIds, pageStart, pageEnd, bbox, order, path, metadata.
string enum
One of: "document" | "page_group" | "page" | "form" | "endorsement" | "section" | "schedule" | "clause" | "table" | "table_row" | "table_cell" | "text"

Storage Interfaces

interface
save, get, query, delete. See Storage Overview for the full interface.
interface
addChunks, search, addTurn, getHistory, searchHistory. Handles document chunks and conversation history.
interface extends SourceRetriever
addSourceSpans, addSourceChunks, getSourceSpan, getSourceSpansByDocument, getSourceChunksByDocument, deleteDocumentSource, plus all SourceRetriever methods.
object
A chunk of document text stored in MemoryStore. Fields: id, documentId, text, pageStart, pageEnd, metadata.
object
A single conversational exchange stored in MemoryStore. Fields: id, conversationId, role ("user" | "assistant" | "tool"), content, toolName, toolResult, timestamp.

Agent Types

object
Configuration for buildAgentSystemPrompt. See the System Prompt page for all fields.
string enum
"email" | "chat" | "sms" | "slack" | "discord"
string enum
"direct" | "mediated" | "observed"
object
Schema-only tool definition compatible with Claude tool_use. Fields: name, description, input_schema ({ type: "object", properties, required? }).

PCE Types

object
Mutable state object managed by createPceAgent. Holds the list of PolicyChangeItem objects, retrieval evidence, validation issues, and the current execution phase.
object
A single endorsed change: id, changeType, description, evidence (PceEvidenceSource[]), validationIssues, and confidence.
object
The final output of a PCE workflow. Fields: caseId, createdAt, changeItems, evidenceSources, qualityReport, and submissionNarrative.
string enum
"auto" | "deterministic_tree" | "market_eval" | "hybrid"

Case Types

object
A validation issue produced by validatePceItems or validateQuotedEvidence. Fields: severity ("error" | "warning" | "info"), code, message, spanId, itemId.
object
A quoted citation linking a case finding to a source span. Fields: spanId, quote, pageStart, pageEnd, sectionId.
object
A question generated when required information is absent from the source evidence. Fields: id, question, context, requiredFor, priority.