@heripo/pdf-parser 0.1.26 → 0.1.28

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/index.d.cts CHANGED
@@ -1,9 +1,38 @@
1
1
  import { LoggerMethods } from '@heripo/logger';
2
- import { OcrStrategy, TokenUsageReport } from '@heripo/model';
2
+ import { OcrStrategy, TokenUsageReport, ReviewAssistanceProgressEvent } from '@heripo/model';
3
+ export { ReviewAssistanceProgressEvent, ReviewAssistanceProgressStatus, ReviewAssistanceProgressSubstage } from '@heripo/model';
3
4
  import { LanguageModel } from 'ai';
4
5
  import { ConversionOptions } from 'docling-sdk';
5
6
  import { LLMTokenUsageAggregator } from '@heripo/shared';
6
7
 
8
+ interface ReviewAssistanceOptions {
9
+ /** Enable page-level review assistance. Defaults to false. */
10
+ enabled?: boolean;
11
+ /** Minimum final confidence for direct mutation. Defaults to 0.85. */
12
+ autoApplyThreshold?: number;
13
+ /** Minimum final confidence for sidecar proposals. Defaults to 0.5. */
14
+ proposalThreshold?: number;
15
+ /** Maximum retries per page-level VLM call. Defaults to 3. */
16
+ maxRetries?: number;
17
+ /** VLM generation temperature. Defaults to 0. */
18
+ temperature?: number;
19
+ /** Language for human-readable review reasons. Defaults to English. */
20
+ outputLanguage?: string;
21
+ }
22
+ interface NormalizedReviewAssistanceOptions {
23
+ enabled: boolean;
24
+ concurrency: number;
25
+ autoApplyThreshold: number;
26
+ proposalThreshold: number;
27
+ maxRetries: number;
28
+ temperature: number;
29
+ outputLanguage: string;
30
+ }
31
+ type ReviewAssistanceOptionInput = boolean | ReviewAssistanceOptions | undefined;
32
+ declare const REVIEW_ASSISTANCE_DEFAULTS: NormalizedReviewAssistanceOptions;
33
+ declare function normalizeReviewAssistanceOptions(value: ReviewAssistanceOptionInput): NormalizedReviewAssistanceOptions;
34
+ declare function isReviewAssistanceEnabled(value: ReviewAssistanceOptionInput): boolean;
35
+
7
36
  /**
8
37
  * Callback function invoked after PDF conversion completes
9
38
  * @param outputPath Absolute path to the output directory containing result files
@@ -25,6 +54,11 @@ type PDFConvertOptions = Omit<ConversionOptions, 'to_formats' | 'image_export_mo
25
54
  vlmProcessorModel?: LanguageModel;
26
55
  /** Concurrency for VLM page processing (default: 1) */
27
56
  vlmConcurrency?: number;
57
+ /**
58
+ * Optional page-level review assistance.
59
+ * Boolean true enables defaults; object form still requires enabled: true.
60
+ */
61
+ reviewAssistance?: boolean | ReviewAssistanceOptions;
28
62
  /** Skip sampling and default to ocrmac */
29
63
  skipSampling?: boolean;
30
64
  /** Force a specific OCR method, bypassing sampling */
@@ -33,6 +67,8 @@ type PDFConvertOptions = Omit<ConversionOptions, 'to_formats' | 'image_export_mo
33
67
  aggregator?: LLMTokenUsageAggregator;
34
68
  /** Callback fired after each batch of VLM pages completes, with cumulative token usage */
35
69
  onTokenUsage?: (report: TokenUsageReport) => void;
70
+ /** Callback fired when Review Assistance advances through parser substages */
71
+ onReviewAssistanceProgress?: (event: ReviewAssistanceProgressEvent) => void;
36
72
  /** Document processing timeout in seconds for the Docling server (default: server default) */
37
73
  document_timeout?: number;
38
74
  /** Enable chunked conversion for large PDFs (local files only) */
@@ -194,7 +230,8 @@ declare class InvalidDocumentTypeError extends Error {
194
230
  * The DoclingDocumentAssembler converts these into a full DoclingDocument.
195
231
  */
196
232
  /** Allowed element types matching DoclingDocument text labels */
197
- type VlmElementType = 'text' | 'section_header' | 'caption' | 'footnote' | 'page_header' | 'page_footer' | 'list_item' | 'picture' | 'table';
233
+ declare const VLM_ELEMENT_TYPES: readonly ["text", "section_header", "caption", "footnote", "page_header", "page_footer", "list_item", "picture", "table"];
234
+ type VlmElementType = (typeof VLM_ELEMENT_TYPES)[number];
198
235
  /**
199
236
  * Normalized bounding box with coordinates in the range 0.0 to 1.0,
200
237
  * using top-left origin (standard image coordinates).
@@ -229,7 +266,8 @@ interface VlmPageElement {
229
266
  bbox?: VlmBBox;
230
267
  }
231
268
  /** Types of quality issues detected in VLM responses */
232
- type VlmQualityIssueType = 'placeholder_text' | 'script_anomaly' | 'meta_description' | 'repetitive_pattern';
269
+ declare const VLM_QUALITY_ISSUE_TYPES: readonly ["placeholder_text", "script_anomaly", "meta_description", "repetitive_pattern"];
270
+ type VlmQualityIssueType = (typeof VLM_QUALITY_ISSUE_TYPES)[number];
233
271
  /** Quality metadata for a processed page */
234
272
  interface VlmPageQuality {
235
273
  /** Whether the page passed quality validation (after possible retry) */
@@ -296,4 +334,4 @@ declare class VlmResponseValidator {
296
334
  private static detectRepetitivePattern;
297
335
  }
298
336
 
299
- export { type ConversionCompleteCallback, type ConvertWithStrategyResult, ImagePdfFallbackError, InvalidDocumentTypeError, type PDFConvertOptions, PDFParser, type VlmPageQuality, type VlmQualityIssue, type VlmQualityIssueType, VlmResponseValidator, type VlmValidationResult };
337
+ export { type ConversionCompleteCallback, type ConvertWithStrategyResult, ImagePdfFallbackError, InvalidDocumentTypeError, type NormalizedReviewAssistanceOptions, type PDFConvertOptions, PDFParser, REVIEW_ASSISTANCE_DEFAULTS, type ReviewAssistanceOptions, type VlmPageQuality, type VlmQualityIssue, type VlmQualityIssueType, VlmResponseValidator, type VlmValidationResult, isReviewAssistanceEnabled, normalizeReviewAssistanceOptions };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,38 @@
1
1
  import { LoggerMethods } from '@heripo/logger';
2
- import { OcrStrategy, TokenUsageReport } from '@heripo/model';
2
+ import { OcrStrategy, TokenUsageReport, ReviewAssistanceProgressEvent } from '@heripo/model';
3
+ export { ReviewAssistanceProgressEvent, ReviewAssistanceProgressStatus, ReviewAssistanceProgressSubstage } from '@heripo/model';
3
4
  import { LanguageModel } from 'ai';
4
5
  import { ConversionOptions } from 'docling-sdk';
5
6
  import { LLMTokenUsageAggregator } from '@heripo/shared';
6
7
 
8
+ interface ReviewAssistanceOptions {
9
+ /** Enable page-level review assistance. Defaults to false. */
10
+ enabled?: boolean;
11
+ /** Minimum final confidence for direct mutation. Defaults to 0.85. */
12
+ autoApplyThreshold?: number;
13
+ /** Minimum final confidence for sidecar proposals. Defaults to 0.5. */
14
+ proposalThreshold?: number;
15
+ /** Maximum retries per page-level VLM call. Defaults to 3. */
16
+ maxRetries?: number;
17
+ /** VLM generation temperature. Defaults to 0. */
18
+ temperature?: number;
19
+ /** Language for human-readable review reasons. Defaults to English. */
20
+ outputLanguage?: string;
21
+ }
22
+ interface NormalizedReviewAssistanceOptions {
23
+ enabled: boolean;
24
+ concurrency: number;
25
+ autoApplyThreshold: number;
26
+ proposalThreshold: number;
27
+ maxRetries: number;
28
+ temperature: number;
29
+ outputLanguage: string;
30
+ }
31
+ type ReviewAssistanceOptionInput = boolean | ReviewAssistanceOptions | undefined;
32
+ declare const REVIEW_ASSISTANCE_DEFAULTS: NormalizedReviewAssistanceOptions;
33
+ declare function normalizeReviewAssistanceOptions(value: ReviewAssistanceOptionInput): NormalizedReviewAssistanceOptions;
34
+ declare function isReviewAssistanceEnabled(value: ReviewAssistanceOptionInput): boolean;
35
+
7
36
  /**
8
37
  * Callback function invoked after PDF conversion completes
9
38
  * @param outputPath Absolute path to the output directory containing result files
@@ -25,6 +54,11 @@ type PDFConvertOptions = Omit<ConversionOptions, 'to_formats' | 'image_export_mo
25
54
  vlmProcessorModel?: LanguageModel;
26
55
  /** Concurrency for VLM page processing (default: 1) */
27
56
  vlmConcurrency?: number;
57
+ /**
58
+ * Optional page-level review assistance.
59
+ * Boolean true enables defaults; object form still requires enabled: true.
60
+ */
61
+ reviewAssistance?: boolean | ReviewAssistanceOptions;
28
62
  /** Skip sampling and default to ocrmac */
29
63
  skipSampling?: boolean;
30
64
  /** Force a specific OCR method, bypassing sampling */
@@ -33,6 +67,8 @@ type PDFConvertOptions = Omit<ConversionOptions, 'to_formats' | 'image_export_mo
33
67
  aggregator?: LLMTokenUsageAggregator;
34
68
  /** Callback fired after each batch of VLM pages completes, with cumulative token usage */
35
69
  onTokenUsage?: (report: TokenUsageReport) => void;
70
+ /** Callback fired when Review Assistance advances through parser substages */
71
+ onReviewAssistanceProgress?: (event: ReviewAssistanceProgressEvent) => void;
36
72
  /** Document processing timeout in seconds for the Docling server (default: server default) */
37
73
  document_timeout?: number;
38
74
  /** Enable chunked conversion for large PDFs (local files only) */
@@ -194,7 +230,8 @@ declare class InvalidDocumentTypeError extends Error {
194
230
  * The DoclingDocumentAssembler converts these into a full DoclingDocument.
195
231
  */
196
232
  /** Allowed element types matching DoclingDocument text labels */
197
- type VlmElementType = 'text' | 'section_header' | 'caption' | 'footnote' | 'page_header' | 'page_footer' | 'list_item' | 'picture' | 'table';
233
+ declare const VLM_ELEMENT_TYPES: readonly ["text", "section_header", "caption", "footnote", "page_header", "page_footer", "list_item", "picture", "table"];
234
+ type VlmElementType = (typeof VLM_ELEMENT_TYPES)[number];
198
235
  /**
199
236
  * Normalized bounding box with coordinates in the range 0.0 to 1.0,
200
237
  * using top-left origin (standard image coordinates).
@@ -229,7 +266,8 @@ interface VlmPageElement {
229
266
  bbox?: VlmBBox;
230
267
  }
231
268
  /** Types of quality issues detected in VLM responses */
232
- type VlmQualityIssueType = 'placeholder_text' | 'script_anomaly' | 'meta_description' | 'repetitive_pattern';
269
+ declare const VLM_QUALITY_ISSUE_TYPES: readonly ["placeholder_text", "script_anomaly", "meta_description", "repetitive_pattern"];
270
+ type VlmQualityIssueType = (typeof VLM_QUALITY_ISSUE_TYPES)[number];
233
271
  /** Quality metadata for a processed page */
234
272
  interface VlmPageQuality {
235
273
  /** Whether the page passed quality validation (after possible retry) */
@@ -296,4 +334,4 @@ declare class VlmResponseValidator {
296
334
  private static detectRepetitivePattern;
297
335
  }
298
336
 
299
- export { type ConversionCompleteCallback, type ConvertWithStrategyResult, ImagePdfFallbackError, InvalidDocumentTypeError, type PDFConvertOptions, PDFParser, type VlmPageQuality, type VlmQualityIssue, type VlmQualityIssueType, VlmResponseValidator, type VlmValidationResult };
337
+ export { type ConversionCompleteCallback, type ConvertWithStrategyResult, ImagePdfFallbackError, InvalidDocumentTypeError, type NormalizedReviewAssistanceOptions, type PDFConvertOptions, PDFParser, REVIEW_ASSISTANCE_DEFAULTS, type ReviewAssistanceOptions, type VlmPageQuality, type VlmQualityIssue, type VlmQualityIssueType, VlmResponseValidator, type VlmValidationResult, isReviewAssistanceEnabled, normalizeReviewAssistanceOptions };