@claritylabs/cl-sdk. For type definitions, see the Types Reference. For storage interface contracts, see the Storage Overview.
Extraction
createExtractor(config)
Returns an extractor instance with a single extract method. The extractor uses your generateObject callback and optional sourceStore to produce grounded ExtractionResult objects.
input accepts:
string— base64-encoded PDFURL— publicly accessible PDF URLUint8Array— raw PDF bytes{ fileId: string }— provider file ID (e.g. Anthropic Files API){ kind: "docling_document", document: DoclingDocument, sourceKind?: string }— pre-parsed Docling document
options (ExtractOptions):
SourceSpan[]
Pre-built source spans to use for this document. When provided, the extractor uses these spans directly instead of deriving spans from the PDF.
boolean
default:"false"
Enables a second-pass recovery step that attempts to fill gaps in coverage extraction using broader source windows.
string
Stable identifier for this document. Used as the
documentId on all generated source spans.Query Agent
createQueryAgent(config)
Returns a query agent that answers natural language questions about insurance documents using grounded retrieval.
Application Pipeline
createApplicationPipeline(config)
Returns a stateful pipeline for multi-round insurance application intake over email or chat.
PCE Agent
createPceAgent(config)
Returns a Policy Change Endorsement agent that processes change requests and produces submission packets with grounded evidence.
string
default:"auto"
Controls PCE planning strategy.
"auto" selects the best mode based on request complexity. "deterministic_tree" follows a fixed decision tree. "market_eval" evaluates multiple carrier interpretations. "hybrid" combines tree and eval passes.Source Grounding Builders
buildPageSourceSpans(pages)
Builds one SourceSpan per page from an array of page input objects. The best default for most PDF documents.
buildSectionSourceSpans(pages, options?)
Splits page text at insurance heading boundaries to produce finer-grained section spans.
buildTextSourceSpans(input, options?)
Builds overlapping text spans from long free-text sources (emails, notes, HTML).
chunkSourceSpans(spans, options?)
Combines spans into larger retrieval chunks respecting span boundaries.
orderSourceEvidence(evidence[])
Deduplicates and sorts a mixed array of retrieval results by descending relevance, then stable source identifier.
Storage
createSqliteStore({ path, embed })
Creates a local SQLite-backed store for development and testing.
Agent Prompts
buildAgentSystemPrompt(ctx)
Composes a full insurance agent system prompt from the provided AgentContext. Returns a plain string.
buildClassifyMessagePrompt(platform)
Returns a system prompt for classifying inbound messages by intent, document references, and request type.
PCE Helpers
buildPceSubmissionPacket(state, createdAt)
Assembles a PceSubmissionPacket from a completed PCE agent state and a creation timestamp.
collectPceEvidenceSources(input, config?)
Collects all PceEvidenceSource objects relevant to a change request from the configured source retriever.
validatePceItems(items, sources)
Validates a list of PolicyChangeItem objects against their evidence sources. Returns CaseValidationIssue[] for any items with insufficient or contradictory evidence.
selectPceExecutionMode(params)
Heuristically selects the best PceExecutionMode for a given change request based on complexity signals.
buildPceQualityReport(state)
Produces a PceQualityReport summarizing evidence coverage, validation issues, and confidence scores across all change items in a PCE state.
stablePolicyChangeItemId(item)
Derives a stable, deterministic ID for a PolicyChangeItem based on its content. Identical items across submissions produce the same ID.
Case Workflow Helpers
validateQuotedEvidence(params)
Validates that quoted evidence in a case proposal matches the referenced source spans. Returns CaseValidationIssue[].
evaluateCaseProposals(proposals)
Scores and ranks an array of CaseProposal objects by evidence strength, returning them in descending order of confidence.