@claritylabs/cl-sdk 3.1.5 → 3.1.6
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/dist/application.d.mts +1 -1
- package/dist/application.d.ts +1 -1
- package/dist/{index-2WYX6Agm.d.mts → index-C-jIqJru.d.mts} +1 -1
- package/dist/{index-2WYX6Agm.d.ts → index-C-jIqJru.d.ts} +1 -1
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +361 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +361 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/application.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { s as AcroFormMapping, t as AcroFormMappingSchema, u as AnswerParsingResult, v as AnswerParsingResultSchema, w as ApplicationClassifyResult, x as ApplicationClassifyResultSchema, y as ApplicationContextProposal, z as ApplicationContextProposalSchema, E as ApplicationEmailReviewSchema, F as ApplicationField, H as ApplicationFieldSchema, J as ApplicationListFilters, K as ApplicationNextQuestions, N as ApplicationPacket, O as ApplicationPacketAnswer, R as ApplicationPacketAnswerSchema, V as ApplicationPacketSchema, W as ApplicationPipelineConfig, X as ApplicationQualityArtifactSchema, Y as ApplicationQualityIssueSchema, Z as ApplicationQualityReportSchema, _ as ApplicationQualityRoundSchema, $ as ApplicationQuestionCondition, a0 as ApplicationQuestionConditionSchema, a1 as ApplicationQuestionGraph, a2 as ApplicationQuestionGraphSchema, a3 as ApplicationQuestionNode, a4 as ApplicationQuestionNodeSchema, a5 as ApplicationRepeat, a6 as ApplicationRepeatSchema, a7 as ApplicationState, a8 as ApplicationStateSchema, a9 as ApplicationStore, aa as ApplicationTemplate, ab as ApplicationTemplateListFilters, ac as ApplicationTemplateSchema, ad as ApplicationTemplateStore, ae as AutoFillMatch, af as AutoFillMatchSchema, ag as AutoFillResult, ah as AutoFillResultSchema, ak as BackfillProvider, al as BuildApplicationPacketInput, am as BuildApplicationPacketResult, aq as ContextProposalResult, au as CreateApplicationRunInput, aM as FieldExtractionResult, aN as FieldExtractionResultSchema, aO as FieldType, aP as FieldTypeSchema, aQ as FlatPdfPlacement, aR as FlatPdfPlacementSchema, aT as LookupFill, aU as LookupFillResult, aV as LookupFillResultSchema, aW as LookupFillSchema, aX as LookupRequest, aY as LookupRequestSchema, b7 as ParsedAnswer, b8 as ParsedAnswerSchema, bg as PriorAnswer, bh as ProcessApplicationInput, bi as ProcessApplicationResult, bj as ProcessReplyInput, bk as ProcessReplyResult, bl as QuestionBatchResult, bm as QuestionBatchResultSchema, bp as ReplyIntent, bq as ReplyIntentSchema, bN as applyApplicationAnswers, bO as buildApplicationPacket, bP as buildQuestionGraphFromFields, bQ as createApplicationPipeline, bR as createApplicationRun, bS as extractQuestionGraphFromFields, bT as flattenQuestionGraph, bU as getActiveApplicationFields, bV as getNextApplicationQuestions, bW as normalizeApplicationQuestionGraph, bX as planNextApplicationQuestions, bY as proposeContextWrites, b_ as validateApplicationPacket } from './index-C-jIqJru.mjs';
|
|
2
2
|
import 'zod';
|
package/dist/application.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { s as AcroFormMapping, t as AcroFormMappingSchema, u as AnswerParsingResult, v as AnswerParsingResultSchema, w as ApplicationClassifyResult, x as ApplicationClassifyResultSchema, y as ApplicationContextProposal, z as ApplicationContextProposalSchema, E as ApplicationEmailReviewSchema, F as ApplicationField, H as ApplicationFieldSchema, J as ApplicationListFilters, K as ApplicationNextQuestions, N as ApplicationPacket, O as ApplicationPacketAnswer, R as ApplicationPacketAnswerSchema, V as ApplicationPacketSchema, W as ApplicationPipelineConfig, X as ApplicationQualityArtifactSchema, Y as ApplicationQualityIssueSchema, Z as ApplicationQualityReportSchema, _ as ApplicationQualityRoundSchema, $ as ApplicationQuestionCondition, a0 as ApplicationQuestionConditionSchema, a1 as ApplicationQuestionGraph, a2 as ApplicationQuestionGraphSchema, a3 as ApplicationQuestionNode, a4 as ApplicationQuestionNodeSchema, a5 as ApplicationRepeat, a6 as ApplicationRepeatSchema, a7 as ApplicationState, a8 as ApplicationStateSchema, a9 as ApplicationStore, aa as ApplicationTemplate, ab as ApplicationTemplateListFilters, ac as ApplicationTemplateSchema, ad as ApplicationTemplateStore, ae as AutoFillMatch, af as AutoFillMatchSchema, ag as AutoFillResult, ah as AutoFillResultSchema, ak as BackfillProvider, al as BuildApplicationPacketInput, am as BuildApplicationPacketResult, aq as ContextProposalResult, au as CreateApplicationRunInput, aM as FieldExtractionResult, aN as FieldExtractionResultSchema, aO as FieldType, aP as FieldTypeSchema, aQ as FlatPdfPlacement, aR as FlatPdfPlacementSchema, aT as LookupFill, aU as LookupFillResult, aV as LookupFillResultSchema, aW as LookupFillSchema, aX as LookupRequest, aY as LookupRequestSchema, b7 as ParsedAnswer, b8 as ParsedAnswerSchema, bg as PriorAnswer, bh as ProcessApplicationInput, bi as ProcessApplicationResult, bj as ProcessReplyInput, bk as ProcessReplyResult, bl as QuestionBatchResult, bm as QuestionBatchResultSchema, bp as ReplyIntent, bq as ReplyIntentSchema, bN as applyApplicationAnswers, bO as buildApplicationPacket, bP as buildQuestionGraphFromFields, bQ as createApplicationPipeline, bR as createApplicationRun, bS as extractQuestionGraphFromFields, bT as flattenQuestionGraph, bU as getActiveApplicationFields, bV as getNextApplicationQuestions, bW as normalizeApplicationQuestionGraph, bX as planNextApplicationQuestions, bY as proposeContextWrites, b_ as validateApplicationPacket } from './index-C-jIqJru.js';
|
|
2
2
|
import 'zod';
|
|
@@ -30636,4 +30636,4 @@ declare function flattenQuestionGraph(graph: ApplicationQuestionGraph): Applicat
|
|
|
30636
30636
|
declare function getActiveApplicationFields(state: Pick<ApplicationState, "fields" | "questionGraph">): ApplicationField[];
|
|
30637
30637
|
declare function getNextApplicationQuestions(state: Pick<ApplicationState, "fields" | "questionGraph" | "batches" | "currentBatchIndex">, limit?: number): ApplicationField[];
|
|
30638
30638
|
|
|
30639
|
-
export {
|
|
30639
|
+
export { type ApplicationQuestionCondition as $, type AgentContext as A, type BaseQualityIssue as B, type ConvertPdfToImagesFn as C, type DocumentSourceNode as D, ApplicationEmailReviewSchema as E, type ApplicationField as F, type GenerateObject as G, ApplicationFieldSchema as H, type InsuranceDocument as I, type ApplicationListFilters as J, type ApplicationNextQuestions as K, type LogFn as L, type ModelTaskKind as M, type ApplicationPacket as N, type ApplicationPacketAnswer as O, type PolicyOperationalProfile as P, type QualityGateStatus as Q, ApplicationPacketAnswerSchema as R, type SourceSpanLocation as S, type TokenUsage as T, type UnifiedQualityReport as U, ApplicationPacketSchema as V, type ApplicationPipelineConfig as W, ApplicationQualityArtifactSchema as X, ApplicationQualityIssueSchema as Y, ApplicationQualityReportSchema as Z, ApplicationQualityRoundSchema as _, type ModelBudgetResolution as a, OperationalCoverageLineSchema as a$, ApplicationQuestionConditionSchema as a0, type ApplicationQuestionGraph as a1, ApplicationQuestionGraphSchema as a2, type ApplicationQuestionNode as a3, ApplicationQuestionNodeSchema as a4, type ApplicationRepeat as a5, ApplicationRepeatSchema as a6, type ApplicationState as a7, ApplicationStateSchema as a8, type ApplicationStore as a9, type DocumentMetadata as aA, DocumentMetadataSchema as aB, type DocumentNode as aC, DocumentNodeSchema as aD, type DocumentPageMapEntry as aE, DocumentPageMapEntrySchema as aF, type DocumentSourceNodeKind as aG, DocumentSourceNodeKindSchema as aH, DocumentSourceNodeSchema as aI, type DocumentTableOfContentsEntry as aJ, DocumentTableOfContentsEntrySchema as aK, type EmbedText as aL, type FieldExtractionResult as aM, FieldExtractionResultSchema as aN, type FieldType as aO, FieldTypeSchema as aP, type FlatPdfPlacement as aQ, FlatPdfPlacementSchema as aR, InsuranceDocumentSchema as aS, type LookupFill as aT, type LookupFillResult as aU, LookupFillResultSchema as aV, LookupFillSchema as aW, type LookupRequest as aX, LookupRequestSchema as aY, type ModelCallReport as aZ, type OperationalCoverageLine as a_, type ApplicationTemplate as aa, type ApplicationTemplateListFilters as ab, ApplicationTemplateSchema as ac, type ApplicationTemplateStore as ad, type AutoFillMatch as ae, AutoFillMatchSchema as af, type AutoFillResult as ag, AutoFillResultSchema as ah, type AuxiliaryFact as ai, AuxiliaryFactSchema as aj, type BackfillProvider as ak, type BuildApplicationPacketInput as al, type BuildApplicationPacketResult as am, type ChunkFilter as an, type CommunicationIntent as ao, CommunicationIntentSchema as ap, type ContextProposalResult as aq, type ConversationTurn as ar, type CoveredReason as as, CoveredReasonSchema as at, type CreateApplicationRunInput as au, type Definition as av, DefinitionSchema as aw, type DocumentAgentGuidance as ax, DocumentAgentGuidanceSchema as ay, type DocumentFilters as az, type ModelCallTrace as b, type OperationalCoverageTerm as b0, OperationalCoverageTermSchema as b1, type OperationalEndorsementSupport as b2, OperationalEndorsementSupportSchema as b3, type OperationalParty as b4, OperationalPartySchema as b5, PLATFORM_CONFIGS as b6, type ParsedAnswer as b7, ParsedAnswerSchema as b8, type PlatformConfig as b9, SourceSpanKindSchema as bA, SourceSpanLocationSchema as bB, type SourceSpanRef as bC, SourceSpanRefSchema as bD, SourceSpanSchema as bE, SourceSpanTableLocationSchema as bF, SourceSpanUnitSchema as bG, type Subjectivity as bH, SubjectivitySchema as bI, type Subsection as bJ, SubsectionSchema as bK, type UnderwritingCondition as bL, UnderwritingConditionSchema as bM, applyApplicationAnswers as bN, buildApplicationPacket as bO, buildQuestionGraphFromFields as bP, createApplicationPipeline as bQ, createApplicationRun as bR, extractQuestionGraphFromFields as bS, flattenQuestionGraph as bT, getActiveApplicationFields as bU, getNextApplicationQuestions as bV, normalizeApplicationQuestionGraph as bW, planNextApplicationQuestions as bX, proposeContextWrites as bY, resolveModelBudget as bZ, validateApplicationPacket as b_, PlatformSchema as ba, type PolicyDocument as bb, PolicyDocumentSchema as bc, PolicyOperationalProfileSchema as bd, type PremiumLine as be, PremiumLineSchema as bf, type PriorAnswer as bg, type ProcessApplicationInput as bh, type ProcessApplicationResult as bi, type ProcessReplyInput as bj, type ProcessReplyResult as bk, type QuestionBatchResult as bl, QuestionBatchResultSchema as bm, type QuoteDocument as bn, QuoteDocumentSchema as bo, type ReplyIntent as bp, ReplyIntentSchema as bq, type ResolveModelBudgetParams as br, type Section as bs, SectionSchema as bt, type SourceBackedValue as bu, SourceBackedValueSchema as bv, SourceChunkSchema as bw, SourceKindSchema as bx, SourceSpanBBoxSchema as by, type SourceSpanKind as bz, type SourceSpan as c, type SourceKind as d, type SourceSpanUnit as e, type SourceSpanTableLocation as f, type SourceChunk as g, type SourceSpanBBox as h, type PdfInput as i, type DocumentChunk as j, type PerformanceReport as k, type GenerateText as l, type QualityGateMode as m, type ModelCapabilities as n, type ModelBudgetConstraint as o, type DocumentStore as p, type MemoryStore as q, type Platform as r, type AcroFormMapping as s, AcroFormMappingSchema as t, type AnswerParsingResult as u, AnswerParsingResultSchema as v, type ApplicationClassifyResult as w, ApplicationClassifyResultSchema as x, type ApplicationContextProposal as y, ApplicationContextProposalSchema as z };
|
|
@@ -30636,4 +30636,4 @@ declare function flattenQuestionGraph(graph: ApplicationQuestionGraph): Applicat
|
|
|
30636
30636
|
declare function getActiveApplicationFields(state: Pick<ApplicationState, "fields" | "questionGraph">): ApplicationField[];
|
|
30637
30637
|
declare function getNextApplicationQuestions(state: Pick<ApplicationState, "fields" | "questionGraph" | "batches" | "currentBatchIndex">, limit?: number): ApplicationField[];
|
|
30638
30638
|
|
|
30639
|
-
export {
|
|
30639
|
+
export { type ApplicationQuestionCondition as $, type AgentContext as A, type BaseQualityIssue as B, type ConvertPdfToImagesFn as C, type DocumentSourceNode as D, ApplicationEmailReviewSchema as E, type ApplicationField as F, type GenerateObject as G, ApplicationFieldSchema as H, type InsuranceDocument as I, type ApplicationListFilters as J, type ApplicationNextQuestions as K, type LogFn as L, type ModelTaskKind as M, type ApplicationPacket as N, type ApplicationPacketAnswer as O, type PolicyOperationalProfile as P, type QualityGateStatus as Q, ApplicationPacketAnswerSchema as R, type SourceSpanLocation as S, type TokenUsage as T, type UnifiedQualityReport as U, ApplicationPacketSchema as V, type ApplicationPipelineConfig as W, ApplicationQualityArtifactSchema as X, ApplicationQualityIssueSchema as Y, ApplicationQualityReportSchema as Z, ApplicationQualityRoundSchema as _, type ModelBudgetResolution as a, OperationalCoverageLineSchema as a$, ApplicationQuestionConditionSchema as a0, type ApplicationQuestionGraph as a1, ApplicationQuestionGraphSchema as a2, type ApplicationQuestionNode as a3, ApplicationQuestionNodeSchema as a4, type ApplicationRepeat as a5, ApplicationRepeatSchema as a6, type ApplicationState as a7, ApplicationStateSchema as a8, type ApplicationStore as a9, type DocumentMetadata as aA, DocumentMetadataSchema as aB, type DocumentNode as aC, DocumentNodeSchema as aD, type DocumentPageMapEntry as aE, DocumentPageMapEntrySchema as aF, type DocumentSourceNodeKind as aG, DocumentSourceNodeKindSchema as aH, DocumentSourceNodeSchema as aI, type DocumentTableOfContentsEntry as aJ, DocumentTableOfContentsEntrySchema as aK, type EmbedText as aL, type FieldExtractionResult as aM, FieldExtractionResultSchema as aN, type FieldType as aO, FieldTypeSchema as aP, type FlatPdfPlacement as aQ, FlatPdfPlacementSchema as aR, InsuranceDocumentSchema as aS, type LookupFill as aT, type LookupFillResult as aU, LookupFillResultSchema as aV, LookupFillSchema as aW, type LookupRequest as aX, LookupRequestSchema as aY, type ModelCallReport as aZ, type OperationalCoverageLine as a_, type ApplicationTemplate as aa, type ApplicationTemplateListFilters as ab, ApplicationTemplateSchema as ac, type ApplicationTemplateStore as ad, type AutoFillMatch as ae, AutoFillMatchSchema as af, type AutoFillResult as ag, AutoFillResultSchema as ah, type AuxiliaryFact as ai, AuxiliaryFactSchema as aj, type BackfillProvider as ak, type BuildApplicationPacketInput as al, type BuildApplicationPacketResult as am, type ChunkFilter as an, type CommunicationIntent as ao, CommunicationIntentSchema as ap, type ContextProposalResult as aq, type ConversationTurn as ar, type CoveredReason as as, CoveredReasonSchema as at, type CreateApplicationRunInput as au, type Definition as av, DefinitionSchema as aw, type DocumentAgentGuidance as ax, DocumentAgentGuidanceSchema as ay, type DocumentFilters as az, type ModelCallTrace as b, type OperationalCoverageTerm as b0, OperationalCoverageTermSchema as b1, type OperationalEndorsementSupport as b2, OperationalEndorsementSupportSchema as b3, type OperationalParty as b4, OperationalPartySchema as b5, PLATFORM_CONFIGS as b6, type ParsedAnswer as b7, ParsedAnswerSchema as b8, type PlatformConfig as b9, SourceSpanKindSchema as bA, SourceSpanLocationSchema as bB, type SourceSpanRef as bC, SourceSpanRefSchema as bD, SourceSpanSchema as bE, SourceSpanTableLocationSchema as bF, SourceSpanUnitSchema as bG, type Subjectivity as bH, SubjectivitySchema as bI, type Subsection as bJ, SubsectionSchema as bK, type UnderwritingCondition as bL, UnderwritingConditionSchema as bM, applyApplicationAnswers as bN, buildApplicationPacket as bO, buildQuestionGraphFromFields as bP, createApplicationPipeline as bQ, createApplicationRun as bR, extractQuestionGraphFromFields as bS, flattenQuestionGraph as bT, getActiveApplicationFields as bU, getNextApplicationQuestions as bV, normalizeApplicationQuestionGraph as bW, planNextApplicationQuestions as bX, proposeContextWrites as bY, resolveModelBudget as bZ, validateApplicationPacket as b_, PlatformSchema as ba, type PolicyDocument as bb, PolicyDocumentSchema as bc, PolicyOperationalProfileSchema as bd, type PremiumLine as be, PremiumLineSchema as bf, type PriorAnswer as bg, type ProcessApplicationInput as bh, type ProcessApplicationResult as bi, type ProcessReplyInput as bj, type ProcessReplyResult as bk, type QuestionBatchResult as bl, QuestionBatchResultSchema as bm, type QuoteDocument as bn, QuoteDocumentSchema as bo, type ReplyIntent as bp, ReplyIntentSchema as bq, type ResolveModelBudgetParams as br, type Section as bs, SectionSchema as bt, type SourceBackedValue as bu, SourceBackedValueSchema as bv, SourceChunkSchema as bw, SourceKindSchema as bx, SourceSpanBBoxSchema as by, type SourceSpanKind as bz, type SourceSpan as c, type SourceKind as d, type SourceSpanUnit as e, type SourceSpanTableLocation as f, type SourceChunk as g, type SourceSpanBBox as h, type PdfInput as i, type DocumentChunk as j, type PerformanceReport as k, type GenerateText as l, type QualityGateMode as m, type ModelCapabilities as n, type ModelBudgetConstraint as o, type DocumentStore as p, type MemoryStore as q, type Platform as r, type AcroFormMapping as s, AcroFormMappingSchema as t, type AnswerParsingResult as u, AnswerParsingResultSchema as v, type ApplicationClassifyResult as w, ApplicationClassifyResultSchema as x, type ApplicationContextProposal as y, ApplicationContextProposalSchema as z };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as LogFn, M as ModelTaskKind, a as ModelBudgetResolution, G as GenerateObject, T as TokenUsage, S as SourceSpanLocation,
|
|
2
|
-
export {
|
|
1
|
+
import { L as LogFn, M as ModelTaskKind, a as ModelBudgetResolution, b as ModelCallTrace, G as GenerateObject, T as TokenUsage, S as SourceSpanLocation, c as SourceSpan, D as DocumentSourceNode, d as SourceKind, e as SourceSpanUnit, f as SourceSpanTableLocation, g as SourceChunk, P as PolicyOperationalProfile, h as SourceSpanBBox, U as UnifiedQualityReport, B as BaseQualityIssue, Q as QualityGateStatus, I as InsuranceDocument, i as PdfInput, j as DocumentChunk, k as PerformanceReport, l as GenerateText, C as ConvertPdfToImagesFn, m as QualityGateMode, n as ModelCapabilities, o as ModelBudgetConstraint, A as AgentContext, p as DocumentStore, q as MemoryStore, r as Platform } from './index-C-jIqJru.mjs';
|
|
2
|
+
export { s as AcroFormMapping, t as AcroFormMappingSchema, u as AnswerParsingResult, v as AnswerParsingResultSchema, w as ApplicationClassifyResult, x as ApplicationClassifyResultSchema, y as ApplicationContextProposal, z as ApplicationContextProposalSchema, E as ApplicationEmailReviewSchema, F as ApplicationField, H as ApplicationFieldSchema, J as ApplicationListFilters, K as ApplicationNextQuestions, N as ApplicationPacket, O as ApplicationPacketAnswer, R as ApplicationPacketAnswerSchema, V as ApplicationPacketSchema, W as ApplicationPipelineConfig, X as ApplicationQualityArtifactSchema, Y as ApplicationQualityIssueSchema, Z as ApplicationQualityReportSchema, _ as ApplicationQualityRoundSchema, $ as ApplicationQuestionCondition, a0 as ApplicationQuestionConditionSchema, a1 as ApplicationQuestionGraph, a2 as ApplicationQuestionGraphSchema, a3 as ApplicationQuestionNode, a4 as ApplicationQuestionNodeSchema, a5 as ApplicationRepeat, a6 as ApplicationRepeatSchema, a7 as ApplicationState, a8 as ApplicationStateSchema, a9 as ApplicationStore, aa as ApplicationTemplate, ab as ApplicationTemplateListFilters, ac as ApplicationTemplateSchema, ad as ApplicationTemplateStore, ae as AutoFillMatch, af as AutoFillMatchSchema, ag as AutoFillResult, ah as AutoFillResultSchema, ai as AuxiliaryFact, aj as AuxiliaryFactSchema, ak as BackfillProvider, al as BuildApplicationPacketInput, am as BuildApplicationPacketResult, an as ChunkFilter, ao as CommunicationIntent, ap as CommunicationIntentSchema, aq as ContextProposalResult, ar as ConversationTurn, as as CoveredReason, at as CoveredReasonSchema, au as CreateApplicationRunInput, av as Definition, aw as DefinitionSchema, ax as DocumentAgentGuidance, ay as DocumentAgentGuidanceSchema, az as DocumentFilters, aA as DocumentMetadata, aB as DocumentMetadataSchema, aC as DocumentNode, aD as DocumentNodeSchema, aE as DocumentPageMapEntry, aF as DocumentPageMapEntrySchema, aG as DocumentSourceNodeKind, aH as DocumentSourceNodeKindSchema, aI as DocumentSourceNodeSchema, aJ as DocumentTableOfContentsEntry, aK as DocumentTableOfContentsEntrySchema, aL as EmbedText, aM as FieldExtractionResult, aN as FieldExtractionResultSchema, aO as FieldType, aP as FieldTypeSchema, aQ as FlatPdfPlacement, aR as FlatPdfPlacementSchema, aS as InsuranceDocumentSchema, aT as LookupFill, aU as LookupFillResult, aV as LookupFillResultSchema, aW as LookupFillSchema, aX as LookupRequest, aY as LookupRequestSchema, aZ as ModelCallReport, a_ as OperationalCoverageLine, a$ as OperationalCoverageLineSchema, b0 as OperationalCoverageTerm, b1 as OperationalCoverageTermSchema, b2 as OperationalEndorsementSupport, b3 as OperationalEndorsementSupportSchema, b4 as OperationalParty, b5 as OperationalPartySchema, b6 as PLATFORM_CONFIGS, b7 as ParsedAnswer, b8 as ParsedAnswerSchema, b9 as PlatformConfig, ba as PlatformSchema, bb as PolicyDocument, bc as PolicyDocumentSchema, bd as PolicyOperationalProfileSchema, be as PremiumLine, bf as PremiumLineSchema, bg as PriorAnswer, bh as ProcessApplicationInput, bi as ProcessApplicationResult, bj as ProcessReplyInput, bk as ProcessReplyResult, bl as QuestionBatchResult, bm as QuestionBatchResultSchema, bn as QuoteDocument, bo as QuoteDocumentSchema, bp as ReplyIntent, bq as ReplyIntentSchema, br as ResolveModelBudgetParams, bs as Section, bt as SectionSchema, bu as SourceBackedValue, bv as SourceBackedValueSchema, bw as SourceChunkSchema, bx as SourceKindSchema, by as SourceSpanBBoxSchema, bz as SourceSpanKind, bA as SourceSpanKindSchema, bB as SourceSpanLocationSchema, bC as SourceSpanRef, bD as SourceSpanRefSchema, bE as SourceSpanSchema, bF as SourceSpanTableLocationSchema, bG as SourceSpanUnitSchema, bH as Subjectivity, bI as SubjectivitySchema, bJ as Subsection, bK as SubsectionSchema, bL as UnderwritingCondition, bM as UnderwritingConditionSchema, bN as applyApplicationAnswers, bO as buildApplicationPacket, bP as buildQuestionGraphFromFields, bQ as createApplicationPipeline, bR as createApplicationRun, bS as extractQuestionGraphFromFields, bT as flattenQuestionGraph, bU as getActiveApplicationFields, bV as getNextApplicationQuestions, bW as normalizeApplicationQuestionGraph, bX as planNextApplicationQuestions, bY as proposeContextWrites, bZ as resolveModelBudget, b_ as validateApplicationPacket } from './index-C-jIqJru.mjs';
|
|
3
3
|
import * as zod from 'zod';
|
|
4
4
|
import { ZodTypeAny, z, ZodSchema } from 'zod';
|
|
5
5
|
import { PDFDocument } from 'pdf-lib';
|
|
@@ -38,6 +38,7 @@ interface SafeGenerateParams {
|
|
|
38
38
|
maxTokens: number;
|
|
39
39
|
taskKind?: ModelTaskKind;
|
|
40
40
|
budgetDiagnostics?: ModelBudgetResolution;
|
|
41
|
+
trace?: ModelCallTrace;
|
|
41
42
|
providerOptions?: Record<string, unknown>;
|
|
42
43
|
}
|
|
43
44
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { L as LogFn, M as ModelTaskKind, a as ModelBudgetResolution, G as GenerateObject, T as TokenUsage, S as SourceSpanLocation,
|
|
2
|
-
export {
|
|
1
|
+
import { L as LogFn, M as ModelTaskKind, a as ModelBudgetResolution, b as ModelCallTrace, G as GenerateObject, T as TokenUsage, S as SourceSpanLocation, c as SourceSpan, D as DocumentSourceNode, d as SourceKind, e as SourceSpanUnit, f as SourceSpanTableLocation, g as SourceChunk, P as PolicyOperationalProfile, h as SourceSpanBBox, U as UnifiedQualityReport, B as BaseQualityIssue, Q as QualityGateStatus, I as InsuranceDocument, i as PdfInput, j as DocumentChunk, k as PerformanceReport, l as GenerateText, C as ConvertPdfToImagesFn, m as QualityGateMode, n as ModelCapabilities, o as ModelBudgetConstraint, A as AgentContext, p as DocumentStore, q as MemoryStore, r as Platform } from './index-C-jIqJru.js';
|
|
2
|
+
export { s as AcroFormMapping, t as AcroFormMappingSchema, u as AnswerParsingResult, v as AnswerParsingResultSchema, w as ApplicationClassifyResult, x as ApplicationClassifyResultSchema, y as ApplicationContextProposal, z as ApplicationContextProposalSchema, E as ApplicationEmailReviewSchema, F as ApplicationField, H as ApplicationFieldSchema, J as ApplicationListFilters, K as ApplicationNextQuestions, N as ApplicationPacket, O as ApplicationPacketAnswer, R as ApplicationPacketAnswerSchema, V as ApplicationPacketSchema, W as ApplicationPipelineConfig, X as ApplicationQualityArtifactSchema, Y as ApplicationQualityIssueSchema, Z as ApplicationQualityReportSchema, _ as ApplicationQualityRoundSchema, $ as ApplicationQuestionCondition, a0 as ApplicationQuestionConditionSchema, a1 as ApplicationQuestionGraph, a2 as ApplicationQuestionGraphSchema, a3 as ApplicationQuestionNode, a4 as ApplicationQuestionNodeSchema, a5 as ApplicationRepeat, a6 as ApplicationRepeatSchema, a7 as ApplicationState, a8 as ApplicationStateSchema, a9 as ApplicationStore, aa as ApplicationTemplate, ab as ApplicationTemplateListFilters, ac as ApplicationTemplateSchema, ad as ApplicationTemplateStore, ae as AutoFillMatch, af as AutoFillMatchSchema, ag as AutoFillResult, ah as AutoFillResultSchema, ai as AuxiliaryFact, aj as AuxiliaryFactSchema, ak as BackfillProvider, al as BuildApplicationPacketInput, am as BuildApplicationPacketResult, an as ChunkFilter, ao as CommunicationIntent, ap as CommunicationIntentSchema, aq as ContextProposalResult, ar as ConversationTurn, as as CoveredReason, at as CoveredReasonSchema, au as CreateApplicationRunInput, av as Definition, aw as DefinitionSchema, ax as DocumentAgentGuidance, ay as DocumentAgentGuidanceSchema, az as DocumentFilters, aA as DocumentMetadata, aB as DocumentMetadataSchema, aC as DocumentNode, aD as DocumentNodeSchema, aE as DocumentPageMapEntry, aF as DocumentPageMapEntrySchema, aG as DocumentSourceNodeKind, aH as DocumentSourceNodeKindSchema, aI as DocumentSourceNodeSchema, aJ as DocumentTableOfContentsEntry, aK as DocumentTableOfContentsEntrySchema, aL as EmbedText, aM as FieldExtractionResult, aN as FieldExtractionResultSchema, aO as FieldType, aP as FieldTypeSchema, aQ as FlatPdfPlacement, aR as FlatPdfPlacementSchema, aS as InsuranceDocumentSchema, aT as LookupFill, aU as LookupFillResult, aV as LookupFillResultSchema, aW as LookupFillSchema, aX as LookupRequest, aY as LookupRequestSchema, aZ as ModelCallReport, a_ as OperationalCoverageLine, a$ as OperationalCoverageLineSchema, b0 as OperationalCoverageTerm, b1 as OperationalCoverageTermSchema, b2 as OperationalEndorsementSupport, b3 as OperationalEndorsementSupportSchema, b4 as OperationalParty, b5 as OperationalPartySchema, b6 as PLATFORM_CONFIGS, b7 as ParsedAnswer, b8 as ParsedAnswerSchema, b9 as PlatformConfig, ba as PlatformSchema, bb as PolicyDocument, bc as PolicyDocumentSchema, bd as PolicyOperationalProfileSchema, be as PremiumLine, bf as PremiumLineSchema, bg as PriorAnswer, bh as ProcessApplicationInput, bi as ProcessApplicationResult, bj as ProcessReplyInput, bk as ProcessReplyResult, bl as QuestionBatchResult, bm as QuestionBatchResultSchema, bn as QuoteDocument, bo as QuoteDocumentSchema, bp as ReplyIntent, bq as ReplyIntentSchema, br as ResolveModelBudgetParams, bs as Section, bt as SectionSchema, bu as SourceBackedValue, bv as SourceBackedValueSchema, bw as SourceChunkSchema, bx as SourceKindSchema, by as SourceSpanBBoxSchema, bz as SourceSpanKind, bA as SourceSpanKindSchema, bB as SourceSpanLocationSchema, bC as SourceSpanRef, bD as SourceSpanRefSchema, bE as SourceSpanSchema, bF as SourceSpanTableLocationSchema, bG as SourceSpanUnitSchema, bH as Subjectivity, bI as SubjectivitySchema, bJ as Subsection, bK as SubsectionSchema, bL as UnderwritingCondition, bM as UnderwritingConditionSchema, bN as applyApplicationAnswers, bO as buildApplicationPacket, bP as buildQuestionGraphFromFields, bQ as createApplicationPipeline, bR as createApplicationRun, bS as extractQuestionGraphFromFields, bT as flattenQuestionGraph, bU as getActiveApplicationFields, bV as getNextApplicationQuestions, bW as normalizeApplicationQuestionGraph, bX as planNextApplicationQuestions, bY as proposeContextWrites, bZ as resolveModelBudget, b_ as validateApplicationPacket } from './index-C-jIqJru.js';
|
|
3
3
|
import * as zod from 'zod';
|
|
4
4
|
import { ZodTypeAny, z, ZodSchema } from 'zod';
|
|
5
5
|
import { PDFDocument } from 'pdf-lib';
|
|
@@ -38,6 +38,7 @@ interface SafeGenerateParams {
|
|
|
38
38
|
maxTokens: number;
|
|
39
39
|
taskKind?: ModelTaskKind;
|
|
40
40
|
budgetDiagnostics?: ModelBudgetResolution;
|
|
41
|
+
trace?: ModelCallTrace;
|
|
41
42
|
providerOptions?: Record<string, unknown>;
|
|
42
43
|
}
|
|
43
44
|
/**
|
package/dist/index.js
CHANGED
|
@@ -3174,8 +3174,30 @@ function sortSpans(left, right) {
|
|
|
3174
3174
|
const leftCol = left.table?.columnIndex ?? Number(left.metadata?.columnIndex ?? 0);
|
|
3175
3175
|
const rightCol = right.table?.columnIndex ?? Number(right.metadata?.columnIndex ?? 0);
|
|
3176
3176
|
if (leftCol !== rightCol) return leftCol - rightCol;
|
|
3177
|
+
if (tableId(left) && tableId(left) === tableId(right)) {
|
|
3178
|
+
const leftUnitRank = sourceUnitSortRank(left);
|
|
3179
|
+
const rightUnitRank = sourceUnitSortRank(right);
|
|
3180
|
+
if (leftUnitRank !== rightUnitRank) return leftUnitRank - rightUnitRank;
|
|
3181
|
+
}
|
|
3177
3182
|
return left.id.localeCompare(right.id);
|
|
3178
3183
|
}
|
|
3184
|
+
function sourceUnitSortRank(span) {
|
|
3185
|
+
switch (sourceUnit2(span)) {
|
|
3186
|
+
case "page":
|
|
3187
|
+
return 0;
|
|
3188
|
+
case "table":
|
|
3189
|
+
return 1;
|
|
3190
|
+
case "table_row":
|
|
3191
|
+
return 2;
|
|
3192
|
+
case "table_cell":
|
|
3193
|
+
return 3;
|
|
3194
|
+
case "section":
|
|
3195
|
+
case "key_value":
|
|
3196
|
+
case "text":
|
|
3197
|
+
default:
|
|
3198
|
+
return 4;
|
|
3199
|
+
}
|
|
3200
|
+
}
|
|
3179
3201
|
function normalizeDocumentSourceTreePaths(nodes) {
|
|
3180
3202
|
const byParent = /* @__PURE__ */ new Map();
|
|
3181
3203
|
for (const node of nodes) {
|
|
@@ -10493,6 +10515,23 @@ var SourceTreeOrganizationSchema = import_zod42.z.object({
|
|
|
10493
10515
|
childNodeIds: import_zod42.z.array(import_zod42.z.string()).min(1)
|
|
10494
10516
|
}))
|
|
10495
10517
|
});
|
|
10518
|
+
var SourceTreeVisualTableRepairSchema = import_zod42.z.object({
|
|
10519
|
+
tables: import_zod42.z.array(import_zod42.z.object({
|
|
10520
|
+
tableNodeId: import_zod42.z.string(),
|
|
10521
|
+
columnLabels: import_zod42.z.array(import_zod42.z.object({
|
|
10522
|
+
columnIndex: import_zod42.z.number().int().nonnegative(),
|
|
10523
|
+
label: import_zod42.z.string()
|
|
10524
|
+
})).default([]),
|
|
10525
|
+
continuationRows: import_zod42.z.array(import_zod42.z.object({
|
|
10526
|
+
sourceRowNodeId: import_zod42.z.string(),
|
|
10527
|
+
targetRowNodeId: import_zod42.z.string(),
|
|
10528
|
+
targetColumnIndex: import_zod42.z.number().int().nonnegative().optional(),
|
|
10529
|
+
targetColumnLabel: import_zod42.z.string().optional(),
|
|
10530
|
+
reason: import_zod42.z.string().optional()
|
|
10531
|
+
})).default([])
|
|
10532
|
+
})).default([]),
|
|
10533
|
+
warnings: import_zod42.z.array(import_zod42.z.string()).default([])
|
|
10534
|
+
});
|
|
10496
10535
|
var SourceBackedValueForPromptSchema = import_zod42.z.object({
|
|
10497
10536
|
value: import_zod42.z.string(),
|
|
10498
10537
|
normalizedValue: import_zod42.z.string().optional(),
|
|
@@ -11715,6 +11754,319 @@ ${JSON.stringify(nodes, null, 2)}
|
|
|
11715
11754
|
|
|
11716
11755
|
Return JSON for the operational profile.`;
|
|
11717
11756
|
}
|
|
11757
|
+
var VISUAL_TABLE_REPAIR_MAX_TABLES = 4;
|
|
11758
|
+
var VISUAL_TABLE_REPAIR_MAX_ROWS = 28;
|
|
11759
|
+
var VISUAL_TABLE_REPAIR_MAX_CELLS = 140;
|
|
11760
|
+
var VISUAL_TABLE_REPAIR_KEYWORDS = /\b(coverage|limit|limits?|deductible|retroactive|premium|tax|fee|sublimit|sub-limit|aggregate|claim|occurrence|retention|declarations?)\b/i;
|
|
11761
|
+
function isSourceTreeHeaderRow(row) {
|
|
11762
|
+
return row.metadata?.isHeader === true || row.metadata?.isHeader === "true";
|
|
11763
|
+
}
|
|
11764
|
+
function tableCellText(cell) {
|
|
11765
|
+
return cleanText(cell.textExcerpt ?? cell.description ?? cell.title, "");
|
|
11766
|
+
}
|
|
11767
|
+
function tableRowTextForPrompt(row, cells) {
|
|
11768
|
+
return cleanText(
|
|
11769
|
+
cells.length ? cells.map(tableCellText).filter(Boolean).join(" | ") : row.textExcerpt ?? row.description ?? row.title,
|
|
11770
|
+
row.title
|
|
11771
|
+
);
|
|
11772
|
+
}
|
|
11773
|
+
function tableCellColumnIndex(cell, fallbackIndex) {
|
|
11774
|
+
const metadataIndex = cell.metadata?.columnIndex;
|
|
11775
|
+
return typeof metadataIndex === "number" && Number.isInteger(metadataIndex) ? metadataIndex : fallbackIndex;
|
|
11776
|
+
}
|
|
11777
|
+
function isGenericColumnTitle(value) {
|
|
11778
|
+
const title = cleanText(value, "");
|
|
11779
|
+
return !title || /^(?:column\s+\d+|table cell|value)$/i.test(title);
|
|
11780
|
+
}
|
|
11781
|
+
function bboxSummary(node) {
|
|
11782
|
+
const box = node.bbox?.[0];
|
|
11783
|
+
if (!box) return void 0;
|
|
11784
|
+
const round = (value) => Math.round(value * 10) / 10;
|
|
11785
|
+
return {
|
|
11786
|
+
page: box.page,
|
|
11787
|
+
x: round(box.x),
|
|
11788
|
+
y: round(box.y),
|
|
11789
|
+
width: round(box.width),
|
|
11790
|
+
height: round(box.height)
|
|
11791
|
+
};
|
|
11792
|
+
}
|
|
11793
|
+
function tableRowsWithCells(table, byParent) {
|
|
11794
|
+
return (byParent.get(table.id) ?? []).filter((node) => node.kind === "table_row").map((row) => ({
|
|
11795
|
+
row,
|
|
11796
|
+
cells: (byParent.get(row.id) ?? []).filter((child) => child.kind === "table_cell").sort(
|
|
11797
|
+
(left, right) => tableCellColumnIndex(left, 0) - tableCellColumnIndex(right, 0) || left.order - right.order || left.id.localeCompare(right.id)
|
|
11798
|
+
)
|
|
11799
|
+
})).sort((left, right) => left.row.order - right.row.order || left.row.id.localeCompare(right.row.id));
|
|
11800
|
+
}
|
|
11801
|
+
function primaryHeaderColumnCount(rows) {
|
|
11802
|
+
const header = rows.find(({ row, cells }) => isSourceTreeHeaderRow(row) && cells.length > 1);
|
|
11803
|
+
if (header) return header.cells.length;
|
|
11804
|
+
return Math.max(0, ...rows.map(({ cells }) => cells.length));
|
|
11805
|
+
}
|
|
11806
|
+
function shouldRepairVisualTable(candidate) {
|
|
11807
|
+
const rows = candidate.rows;
|
|
11808
|
+
if (rows.length < 3) return false;
|
|
11809
|
+
const tableText = rows.map(({ row, cells }) => tableRowTextForPrompt(row, cells)).join(" ");
|
|
11810
|
+
if (!VISUAL_TABLE_REPAIR_KEYWORDS.test(tableText)) return false;
|
|
11811
|
+
const headerCount = primaryHeaderColumnCount(rows);
|
|
11812
|
+
if (headerCount < 2) return false;
|
|
11813
|
+
const firstHeaderIndex = rows.findIndex(({ row, cells }) => isSourceTreeHeaderRow(row) && cells.length > 1);
|
|
11814
|
+
const repeatedHeader = firstHeaderIndex >= 0 && rows.some(({ row }, index) => index > firstHeaderIndex && isSourceTreeHeaderRow(row));
|
|
11815
|
+
const shortContinuation = rows.some(
|
|
11816
|
+
({ row, cells }, index) => index > 0 && !isSourceTreeHeaderRow(row) && cells.length > 0 && cells.length < headerCount && !/^(?:item\s+\d+|[A-Z]\.)\b/i.test(tableCellText(cells[0]))
|
|
11817
|
+
);
|
|
11818
|
+
const genericDataLabels = rows.some(
|
|
11819
|
+
({ row, cells }) => !isSourceTreeHeaderRow(row) && cells.length >= 2 && cells.some((cell) => isGenericColumnTitle(cell.title))
|
|
11820
|
+
);
|
|
11821
|
+
const danglingSlash = rows.some(
|
|
11822
|
+
({ row, cells }) => !isSourceTreeHeaderRow(row) && /\/\s*$/.test(tableRowTextForPrompt(row, cells))
|
|
11823
|
+
);
|
|
11824
|
+
return repeatedHeader || shortContinuation || genericDataLabels || danglingSlash;
|
|
11825
|
+
}
|
|
11826
|
+
function visualTableCandidates(sourceTree) {
|
|
11827
|
+
const byParent = nodesByParent(sourceTree);
|
|
11828
|
+
return sourceTree.filter((node) => node.kind === "table" && typeof node.pageStart === "number").map((table) => ({
|
|
11829
|
+
table,
|
|
11830
|
+
page: table.pageStart,
|
|
11831
|
+
rows: tableRowsWithCells(table, byParent)
|
|
11832
|
+
})).filter(shouldRepairVisualTable).sort(
|
|
11833
|
+
(left, right) => left.page - right.page || left.table.order - right.table.order || left.table.id.localeCompare(right.table.id)
|
|
11834
|
+
).slice(0, VISUAL_TABLE_REPAIR_MAX_TABLES);
|
|
11835
|
+
}
|
|
11836
|
+
function compactVisualTableCandidate(candidate) {
|
|
11837
|
+
let cellCount = 0;
|
|
11838
|
+
const rows = candidate.rows.slice(0, VISUAL_TABLE_REPAIR_MAX_ROWS).map(({ row, cells }) => {
|
|
11839
|
+
const compactCells = cells.slice(0, Math.max(0, VISUAL_TABLE_REPAIR_MAX_CELLS - cellCount)).map((cell, index) => ({
|
|
11840
|
+
cellNodeId: cell.id,
|
|
11841
|
+
columnIndex: tableCellColumnIndex(cell, index),
|
|
11842
|
+
currentColumnName: cell.title,
|
|
11843
|
+
text: tableCellText(cell),
|
|
11844
|
+
bbox: bboxSummary(cell)
|
|
11845
|
+
}));
|
|
11846
|
+
cellCount += compactCells.length;
|
|
11847
|
+
return {
|
|
11848
|
+
rowNodeId: row.id,
|
|
11849
|
+
order: row.order,
|
|
11850
|
+
isHeader: isSourceTreeHeaderRow(row),
|
|
11851
|
+
text: tableRowTextForPrompt(row, cells),
|
|
11852
|
+
bbox: bboxSummary(row),
|
|
11853
|
+
cells: compactCells
|
|
11854
|
+
};
|
|
11855
|
+
});
|
|
11856
|
+
return {
|
|
11857
|
+
tableNodeId: candidate.table.id,
|
|
11858
|
+
page: candidate.page,
|
|
11859
|
+
title: candidate.table.title,
|
|
11860
|
+
bbox: bboxSummary(candidate.table),
|
|
11861
|
+
rows
|
|
11862
|
+
};
|
|
11863
|
+
}
|
|
11864
|
+
function buildVisualTableRepairPrompt(candidate) {
|
|
11865
|
+
return `Compare a parsed insurance source table against the original page visual layout.
|
|
11866
|
+
|
|
11867
|
+
If a page image is attached, use it as the primary reference. If no image is available, use the bbox coordinates below as the visual layout reference.
|
|
11868
|
+
|
|
11869
|
+
Task:
|
|
11870
|
+
- Identify rows that are not real standalone rows because they are visually wrapped continuation text for a nearby row.
|
|
11871
|
+
- Identify the primary printed column labels for the table.
|
|
11872
|
+
|
|
11873
|
+
Rules:
|
|
11874
|
+
- Return only high-confidence repairs.
|
|
11875
|
+
- Use only rowNodeId/tableNodeId/cellNodeId values from the provided JSON.
|
|
11876
|
+
- Do not invent policy facts, values, row text, source spans, or page numbers.
|
|
11877
|
+
- continuationRows.sourceRowNodeId must be a parsed row that should be removed as a standalone row.
|
|
11878
|
+
- continuationRows.targetRowNodeId must be the row that visually owns that wrapped text, usually the immediately previous non-header row.
|
|
11879
|
+
- targetColumnIndex/targetColumnLabel should point to the visual column that owns the wrapped text, usually the limit/amount/value column.
|
|
11880
|
+
- Do not mark actual data rows as continuations when they begin a new item, coverage part, endorsement, form, location, person, or premium/tax row.
|
|
11881
|
+
- columnLabels should be the primary visual header labels, not later wrapped cell text that the parser misread as a header.
|
|
11882
|
+
|
|
11883
|
+
Parsed table with visual coordinates:
|
|
11884
|
+
${JSON.stringify(compactVisualTableCandidate(candidate), null, 2)}
|
|
11885
|
+
|
|
11886
|
+
Return JSON with tables[].columnLabels and tables[].continuationRows. Return empty arrays if no repair is needed.`;
|
|
11887
|
+
}
|
|
11888
|
+
function sourceSpanIdsForNodes(nodes) {
|
|
11889
|
+
return [...new Set(nodes.flatMap((node) => node.sourceSpanIds))];
|
|
11890
|
+
}
|
|
11891
|
+
function appendDistinctText(base, addition) {
|
|
11892
|
+
const current = cleanText(base, "");
|
|
11893
|
+
const next = cleanText(addition, "");
|
|
11894
|
+
if (!current) return next || void 0;
|
|
11895
|
+
if (!next) return current;
|
|
11896
|
+
if (current.toLowerCase().includes(next.toLowerCase())) return current;
|
|
11897
|
+
const delimiter = /(?:[/(:;-]|,\s*)$/.test(current) ? " " : " / ";
|
|
11898
|
+
return cleanText(`${current}${delimiter}${next}`, current);
|
|
11899
|
+
}
|
|
11900
|
+
function mergedBbox(nodes) {
|
|
11901
|
+
const boxes = nodes.flatMap((node) => node.bbox ?? []);
|
|
11902
|
+
return boxes.length ? boxes.slice(0, 12) : void 0;
|
|
11903
|
+
}
|
|
11904
|
+
function normalizedRepairLabel(value) {
|
|
11905
|
+
const label = cleanText(value, "");
|
|
11906
|
+
if (!label || label.length > 80) return void 0;
|
|
11907
|
+
if (/^(?:source|page|row|table)$/i.test(label)) return void 0;
|
|
11908
|
+
return label;
|
|
11909
|
+
}
|
|
11910
|
+
function findCellForContinuation(params) {
|
|
11911
|
+
if (typeof params.targetColumnIndex === "number") {
|
|
11912
|
+
const byIndex = params.cells.find(
|
|
11913
|
+
(cell, index) => tableCellColumnIndex(cell, index) === params.targetColumnIndex
|
|
11914
|
+
);
|
|
11915
|
+
if (byIndex) return byIndex;
|
|
11916
|
+
}
|
|
11917
|
+
const label = normalizedRepairLabel(params.targetColumnLabel);
|
|
11918
|
+
if (label) {
|
|
11919
|
+
const byLabel = params.cells.find(
|
|
11920
|
+
(cell) => cleanText(cell.title, "").toLowerCase() === label.toLowerCase()
|
|
11921
|
+
);
|
|
11922
|
+
if (byLabel) return byLabel;
|
|
11923
|
+
}
|
|
11924
|
+
return params.cells[1] ?? params.cells[params.cells.length - 1];
|
|
11925
|
+
}
|
|
11926
|
+
function applyVisualTableRepair(sourceTree, repair) {
|
|
11927
|
+
if (repair.tables.length === 0) return sourceTree;
|
|
11928
|
+
const byId = new Map(sourceTree.map((node) => [node.id, node]));
|
|
11929
|
+
const byParent = nodesByParent(sourceTree);
|
|
11930
|
+
const updates = /* @__PURE__ */ new Map();
|
|
11931
|
+
const removeIds = /* @__PURE__ */ new Set();
|
|
11932
|
+
const currentNode = (id) => updates.get(id) ?? byId.get(id);
|
|
11933
|
+
for (const tableRepair of repair.tables) {
|
|
11934
|
+
const table = byId.get(tableRepair.tableNodeId);
|
|
11935
|
+
if (!table || table.kind !== "table") continue;
|
|
11936
|
+
const rows = tableRowsWithCells(table, byParent);
|
|
11937
|
+
const rowIds = new Set(rows.map(({ row }) => row.id));
|
|
11938
|
+
const rowOrder = new Map(rows.map(({ row }, index) => [row.id, index]));
|
|
11939
|
+
const columnLabels = /* @__PURE__ */ new Map();
|
|
11940
|
+
for (const label of tableRepair.columnLabels) {
|
|
11941
|
+
const normalized = normalizedRepairLabel(label.label);
|
|
11942
|
+
if (normalized) columnLabels.set(label.columnIndex, normalized);
|
|
11943
|
+
}
|
|
11944
|
+
if (columnLabels.size > 0) {
|
|
11945
|
+
for (const { row, cells } of rows) {
|
|
11946
|
+
if (removeIds.has(row.id)) continue;
|
|
11947
|
+
for (const [fallbackIndex, cell] of cells.entries()) {
|
|
11948
|
+
const columnIndex = tableCellColumnIndex(cell, fallbackIndex);
|
|
11949
|
+
const label = columnLabels.get(columnIndex);
|
|
11950
|
+
if (!label || cell.title === label) continue;
|
|
11951
|
+
updates.set(cell.id, {
|
|
11952
|
+
...currentNode(cell.id) ?? cell,
|
|
11953
|
+
title: label,
|
|
11954
|
+
metadata: {
|
|
11955
|
+
...cell.metadata ?? {},
|
|
11956
|
+
visualTableRepairColumnLabel: label
|
|
11957
|
+
}
|
|
11958
|
+
});
|
|
11959
|
+
}
|
|
11960
|
+
}
|
|
11961
|
+
}
|
|
11962
|
+
for (const continuation of tableRepair.continuationRows) {
|
|
11963
|
+
if (!rowIds.has(continuation.sourceRowNodeId) || !rowIds.has(continuation.targetRowNodeId)) continue;
|
|
11964
|
+
if (continuation.sourceRowNodeId === continuation.targetRowNodeId) continue;
|
|
11965
|
+
const sourceIndex = rowOrder.get(continuation.sourceRowNodeId);
|
|
11966
|
+
const targetIndex = rowOrder.get(continuation.targetRowNodeId);
|
|
11967
|
+
if (sourceIndex === void 0 || targetIndex === void 0) continue;
|
|
11968
|
+
if (Math.abs(sourceIndex - targetIndex) > 3) continue;
|
|
11969
|
+
const sourceRow = currentNode(continuation.sourceRowNodeId);
|
|
11970
|
+
const targetRow = currentNode(continuation.targetRowNodeId);
|
|
11971
|
+
if (!sourceRow || !targetRow || sourceRow.kind !== "table_row" || targetRow.kind !== "table_row") continue;
|
|
11972
|
+
if (isSourceTreeHeaderRow(targetRow)) continue;
|
|
11973
|
+
const sourceCells = (byParent.get(sourceRow.id) ?? []).filter((node) => node.kind === "table_cell").map((node) => currentNode(node.id) ?? node);
|
|
11974
|
+
const targetCells = (byParent.get(targetRow.id) ?? []).filter((node) => node.kind === "table_cell").map((node) => currentNode(node.id) ?? node);
|
|
11975
|
+
const sourceText = tableRowTextForPrompt(sourceRow, sourceCells);
|
|
11976
|
+
if (!sourceText) continue;
|
|
11977
|
+
const targetCell = findCellForContinuation({
|
|
11978
|
+
cells: targetCells,
|
|
11979
|
+
targetColumnIndex: continuation.targetColumnIndex,
|
|
11980
|
+
targetColumnLabel: continuation.targetColumnLabel
|
|
11981
|
+
});
|
|
11982
|
+
const sourceNodes = [sourceRow, ...sourceCells];
|
|
11983
|
+
const sourceSpanIds = sourceSpanIdsForNodes(sourceNodes);
|
|
11984
|
+
if (targetCell) {
|
|
11985
|
+
const nextCellText = appendDistinctText(tableCellText(targetCell), sourceText);
|
|
11986
|
+
if (nextCellText) {
|
|
11987
|
+
const mergedNodes = [targetCell, ...sourceNodes];
|
|
11988
|
+
updates.set(targetCell.id, {
|
|
11989
|
+
...currentNode(targetCell.id) ?? targetCell,
|
|
11990
|
+
textExcerpt: nextCellText,
|
|
11991
|
+
description: cleanText([targetCell.title, nextCellText].filter(Boolean).join(" | "), targetCell.description),
|
|
11992
|
+
sourceSpanIds: [.../* @__PURE__ */ new Set([...targetCell.sourceSpanIds, ...sourceSpanIds])],
|
|
11993
|
+
bbox: mergedBbox(mergedNodes),
|
|
11994
|
+
metadata: {
|
|
11995
|
+
...targetCell.metadata ?? {},
|
|
11996
|
+
visualTableRepair: "merged_continuation"
|
|
11997
|
+
}
|
|
11998
|
+
});
|
|
11999
|
+
}
|
|
12000
|
+
}
|
|
12001
|
+
const nextRowText = appendDistinctText(targetRow.textExcerpt ?? targetRow.description, sourceText);
|
|
12002
|
+
updates.set(targetRow.id, {
|
|
12003
|
+
...currentNode(targetRow.id) ?? targetRow,
|
|
12004
|
+
textExcerpt: nextRowText,
|
|
12005
|
+
description: cleanText([targetRow.title, nextRowText].filter(Boolean).join(" | "), targetRow.description),
|
|
12006
|
+
sourceSpanIds: [.../* @__PURE__ */ new Set([...targetRow.sourceSpanIds, ...sourceSpanIds])],
|
|
12007
|
+
bbox: mergedBbox([targetRow, ...sourceNodes]),
|
|
12008
|
+
metadata: {
|
|
12009
|
+
...targetRow.metadata ?? {},
|
|
12010
|
+
visualTableRepair: "merged_continuation"
|
|
12011
|
+
}
|
|
12012
|
+
});
|
|
12013
|
+
removeIds.add(sourceRow.id);
|
|
12014
|
+
for (const sourceCell of sourceCells) removeIds.add(sourceCell.id);
|
|
12015
|
+
}
|
|
12016
|
+
}
|
|
12017
|
+
if (updates.size === 0 && removeIds.size === 0) return sourceTree;
|
|
12018
|
+
const repaired = sourceTree.filter((node) => !removeIds.has(node.id)).map((node) => updates.get(node.id) ?? node);
|
|
12019
|
+
return normalizeDocumentSourceTreePaths(normalizeContainerEvidenceFromChildren(repaired));
|
|
12020
|
+
}
|
|
12021
|
+
async function runVisualTableRepair(params) {
|
|
12022
|
+
const candidates = visualTableCandidates(params.sourceTree);
|
|
12023
|
+
if (candidates.length === 0) return { sourceTree: params.sourceTree, warnings: [] };
|
|
12024
|
+
let sourceTree = params.sourceTree;
|
|
12025
|
+
const warnings = [];
|
|
12026
|
+
for (const [index, candidate] of candidates.entries()) {
|
|
12027
|
+
try {
|
|
12028
|
+
const budget = params.resolveBudget("extraction_source_tree", 1800);
|
|
12029
|
+
const maxTokens = Math.min(budget.maxTokens, 2400);
|
|
12030
|
+
const startedAt = Date.now();
|
|
12031
|
+
const response = await safeGenerateObject(
|
|
12032
|
+
params.generateObject,
|
|
12033
|
+
{
|
|
12034
|
+
prompt: buildVisualTableRepairPrompt(candidate),
|
|
12035
|
+
schema: SourceTreeVisualTableRepairSchema,
|
|
12036
|
+
maxTokens,
|
|
12037
|
+
taskKind: "extraction_source_tree",
|
|
12038
|
+
budgetDiagnostics: { ...budget, maxTokens },
|
|
12039
|
+
trace: {
|
|
12040
|
+
label: `source_tree_visual_table_repair_p${candidate.page}`,
|
|
12041
|
+
startPage: candidate.page,
|
|
12042
|
+
endPage: candidate.page,
|
|
12043
|
+
batchIndex: index + 1,
|
|
12044
|
+
batchCount: candidates.length,
|
|
12045
|
+
sourceBacked: true
|
|
12046
|
+
}
|
|
12047
|
+
},
|
|
12048
|
+
{
|
|
12049
|
+
fallback: { tables: [], warnings: [] },
|
|
12050
|
+
log: params.log
|
|
12051
|
+
}
|
|
12052
|
+
);
|
|
12053
|
+
params.trackUsage(response.usage, {
|
|
12054
|
+
taskKind: "extraction_source_tree",
|
|
12055
|
+
label: `source_tree_visual_table_repair_p${candidate.page}`,
|
|
12056
|
+
maxTokens,
|
|
12057
|
+
durationMs: Date.now() - startedAt
|
|
12058
|
+
});
|
|
12059
|
+
const repair = response.object;
|
|
12060
|
+
sourceTree = applyVisualTableRepair(sourceTree, repair);
|
|
12061
|
+
warnings.push(...repair.warnings.map(
|
|
12062
|
+
(warning) => `Visual table repair warning on page ${candidate.page}: ${warning}`
|
|
12063
|
+
));
|
|
12064
|
+
} catch (error) {
|
|
12065
|
+
warnings.push(`Visual table repair skipped on page ${candidate.page}; parsed table kept (${error instanceof Error ? error.message : String(error)})`);
|
|
12066
|
+
}
|
|
12067
|
+
}
|
|
12068
|
+
return { sourceTree, warnings };
|
|
12069
|
+
}
|
|
11718
12070
|
function groupNodeId(documentId, group) {
|
|
11719
12071
|
return [
|
|
11720
12072
|
documentId.replace(/[^a-zA-Z0-9_.:-]/g, "_"),
|
|
@@ -12028,6 +12380,15 @@ async function runSourceTreeExtraction(params) {
|
|
|
12028
12380
|
warnings.push(`Source-tree outline cleanup failed; deterministic tree used (${error instanceof Error ? error.message : String(error)})`);
|
|
12029
12381
|
}
|
|
12030
12382
|
}
|
|
12383
|
+
const visualTableRepair = await runVisualTableRepair({
|
|
12384
|
+
sourceTree,
|
|
12385
|
+
generateObject: params.generateObject,
|
|
12386
|
+
resolveBudget: params.resolveBudget,
|
|
12387
|
+
trackUsage: localTrack,
|
|
12388
|
+
log: params.log
|
|
12389
|
+
});
|
|
12390
|
+
sourceTree = visualTableRepair.sourceTree;
|
|
12391
|
+
warnings.push(...visualTableRepair.warnings);
|
|
12031
12392
|
const deterministicProfile = buildDeterministicOperationalProfile({
|
|
12032
12393
|
sourceTree,
|
|
12033
12394
|
sourceSpans
|