@heripo/model 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/README.ko.md +0 -1
- package/README.md +0 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +200 -4
- package/dist/index.d.ts +200 -4
- package/package.json +3 -3
package/README.ko.md
CHANGED
package/README.md
CHANGED
|
@@ -228,7 +228,6 @@ interface OcrStrategy {
|
|
|
228
228
|
reason: string; // Reason for strategy selection
|
|
229
229
|
sampledPages: number; // Number of sampled pages
|
|
230
230
|
totalPages: number; // Total pages in document
|
|
231
|
-
koreanHanjaMixPages?: number[]; // Pages with Korean-Hanja mixed script
|
|
232
231
|
}
|
|
233
232
|
```
|
|
234
233
|
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/language/bcp47-language-tag.ts","../src/language/language-display.ts"],"sourcesContent":["// Language utilities\nexport type * from './language/bcp47-language-tag';\nexport {\n BCP47_LANGUAGE_TAGS,\n BCP47_LANGUAGE_TAG_SET,\n isValidBcp47Tag,\n normalizeToBcp47,\n} from './language/bcp47-language-tag';\nexport {\n LANGUAGE_DISPLAY_NAMES,\n buildLanguageDescription,\n getLanguageDisplayName,\n} from './language/language-display';\n\n// Type definitions\nexport type * from './types/docling-document';\nexport type * from './types/document-process-result';\nexport type * from './types/ocr-strategy';\nexport type * from './types/processed-document';\nexport type * from './types/token-usage-report';\n","/**\n * Language tags supported by the ocrmac OCR engine (via docling-serve).\n * These are the only tags that can be passed to the Docling pipeline without\n * triggering \"Invalid language preference\" errors.\n */\nexport const BCP47_LANGUAGE_TAGS = [\n 'ar-SA',\n 'ars-SA',\n 'cs-CZ',\n 'da-DK',\n 'de-DE',\n 'en-US',\n 'es-ES',\n 'fr-FR',\n 'id-ID',\n 'it-IT',\n 'ja-JP',\n 'ko-KR',\n 'ms-MY',\n 'nb-NO',\n 'nl-NL',\n 'nn-NO',\n 'no-NO',\n 'pl-PL',\n 'pt-BR',\n 'ro-RO',\n 'ru-RU',\n 'sv-SE',\n 'th-TH',\n 'tr-TR',\n 'uk-UA',\n 'vi-VT',\n 'yue-Hans',\n 'yue-Hant',\n 'zh-Hans',\n 'zh-Hant',\n] as const;\n\n/** Union type of all supported BCP 47 language tags */\nexport type Bcp47LanguageTag = (typeof BCP47_LANGUAGE_TAGS)[number];\n\n/** Set for O(1) lookup of valid BCP 47 tags */\nexport const BCP47_LANGUAGE_TAG_SET: ReadonlySet<string> = new Set(\n BCP47_LANGUAGE_TAGS,\n);\n\n/** Check whether a string is a valid BCP 47 language tag */\nexport function isValidBcp47Tag(tag: string): tag is Bcp47LanguageTag {\n return BCP47_LANGUAGE_TAG_SET.has(tag);\n}\n\n/**\n * Maps bare language codes to their default BCP 47 tag.\n * Used when VLM returns only a language code without a region subtag.\n */\nconst DEFAULT_REGION_MAP: Record<string, Bcp47LanguageTag> = {\n ar: 'ar-SA',\n cs: 'cs-CZ',\n da: 'da-DK',\n de: 'de-DE',\n en: 'en-US',\n es: 'es-ES',\n fr: 'fr-FR',\n id: 'id-ID',\n it: 'it-IT',\n ja: 'ja-JP',\n ko: 'ko-KR',\n ms: 'ms-MY',\n nl: 'nl-NL',\n no: 'no-NO',\n pl: 'pl-PL',\n pt: 'pt-BR',\n ro: 'ro-RO',\n ru: 'ru-RU',\n sv: 'sv-SE',\n th: 'th-TH',\n tr: 'tr-TR',\n uk: 'uk-UA',\n vi: 'vi-VT',\n zh: 'zh-Hans',\n};\n\n/**\n * Normalize a language string to a valid BCP 47 tag.\n *\n * - If the input is already a valid full tag (e.g. \"en-US\"), return it as-is.\n * - If it is a bare language code (e.g. \"en\", \"ko\"), map it to the default region.\n * - Otherwise return null (e.g. \"und\", \"unknown\", empty string).\n */\nexport function normalizeToBcp47(tag: string): Bcp47LanguageTag | null {\n if (isValidBcp47Tag(tag)) {\n return tag;\n }\n\n const lower = tag.toLowerCase();\n const mapped = DEFAULT_REGION_MAP[lower];\n if (mapped) {\n return mapped;\n }\n\n return null;\n}\n","/** Language display names for prompt context (keyed by ISO 639-1 base language code) */\nexport const LANGUAGE_DISPLAY_NAMES: Record<string, string> = {\n ko: 'Korean (한국어)',\n ja: 'Japanese (日本語)',\n zh: 'Chinese (中文)',\n en: 'English',\n fr: 'French (Français)',\n de: 'German (Deutsch)',\n es: 'Spanish (Español)',\n pt: 'Portuguese (Português)',\n ru: 'Russian (Русский)',\n uk: 'Ukrainian (Українська)',\n it: 'Italian (Italiano)',\n};\n\n/**\n * Get human-readable display name for a BCP 47 or ISO 639-1 language code.\n */\nexport function getLanguageDisplayName(code?: string): string {\n if (!code) return 'unknown';\n const baseCode = code.split('-')[0];\n return LANGUAGE_DISPLAY_NAMES[baseCode] ?? code;\n}\n\n/**\n * Build language description string from document languages.\n * @returns e.g. \"primarily written in Korean (한국어), with English also present\"\n */\nexport function buildLanguageDescription(documentLanguages: string[]): string {\n const primaryName = getLanguageDisplayName(documentLanguages[0]);\n const otherNames = documentLanguages\n .slice(1)\n .map((code) => getLanguageDisplayName(code));\n return otherNames.length > 0\n ? `primarily written in ${primaryName}, with ${otherNames.join(', ')} also present`\n : `written in ${primaryName}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKO,IAAM,sBAAsB;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAMO,IAAM,yBAA8C,IAAI;AAAA,EAC7D;AACF;AAGO,SAAS,gBAAgB,KAAsC;AACpE,SAAO,uBAAuB,IAAI,GAAG;AACvC;AAMA,IAAM,qBAAuD;AAAA,EAC3D,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AASO,SAAS,iBAAiB,KAAsC;AACrE,MAAI,gBAAgB,GAAG,GAAG;AACxB,WAAO;AAAA,EACT;AAEA,QAAM,QAAQ,IAAI,YAAY;AAC9B,QAAM,SAAS,mBAAmB,KAAK;AACvC,MAAI,QAAQ;AACV,WAAO;AAAA,EACT;AAEA,SAAO;AACT;;;ACpGO,IAAM,yBAAiD;AAAA,EAC5D,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AAKO,SAAS,uBAAuB,MAAuB;AAC5D,MAAI,CAAC,KAAM,QAAO;AAClB,QAAM,WAAW,KAAK,MAAM,GAAG,EAAE,CAAC;AAClC,SAAO,uBAAuB,QAAQ,KAAK;AAC7C;AAMO,SAAS,yBAAyB,mBAAqC;AAC5E,QAAM,cAAc,uBAAuB,kBAAkB,CAAC,CAAC;AAC/D,QAAM,aAAa,kBAChB,MAAM,CAAC,EACP,IAAI,CAAC,SAAS,uBAAuB,IAAI,CAAC;AAC7C,SAAO,WAAW,SAAS,IACvB,wBAAwB,WAAW,UAAU,WAAW,KAAK,IAAI,CAAC,kBAClE,cAAc,WAAW;AAC/B;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/language/bcp47-language-tag.ts","../src/language/language-display.ts"],"sourcesContent":["// Language utilities\nexport type * from './language/bcp47-language-tag';\nexport {\n BCP47_LANGUAGE_TAGS,\n BCP47_LANGUAGE_TAG_SET,\n isValidBcp47Tag,\n normalizeToBcp47,\n} from './language/bcp47-language-tag';\nexport {\n LANGUAGE_DISPLAY_NAMES,\n buildLanguageDescription,\n getLanguageDisplayName,\n} from './language/language-display';\n\n// Type definitions\nexport type * from './types/docling-document';\nexport type * from './types/document-process-result';\nexport type * from './types/ocr-strategy';\nexport type * from './types/processed-document';\nexport type * from './types/review-assistance';\nexport type * from './types/token-usage-report';\n","/**\n * Language tags supported by the ocrmac OCR engine (via docling-serve).\n * These are the only tags that can be passed to the Docling pipeline without\n * triggering \"Invalid language preference\" errors.\n */\nexport const BCP47_LANGUAGE_TAGS = [\n 'ar-SA',\n 'ars-SA',\n 'cs-CZ',\n 'da-DK',\n 'de-DE',\n 'en-US',\n 'es-ES',\n 'fr-FR',\n 'id-ID',\n 'it-IT',\n 'ja-JP',\n 'ko-KR',\n 'ms-MY',\n 'nb-NO',\n 'nl-NL',\n 'nn-NO',\n 'no-NO',\n 'pl-PL',\n 'pt-BR',\n 'ro-RO',\n 'ru-RU',\n 'sv-SE',\n 'th-TH',\n 'tr-TR',\n 'uk-UA',\n 'vi-VT',\n 'yue-Hans',\n 'yue-Hant',\n 'zh-Hans',\n 'zh-Hant',\n] as const;\n\n/** Union type of all supported BCP 47 language tags */\nexport type Bcp47LanguageTag = (typeof BCP47_LANGUAGE_TAGS)[number];\n\n/** Set for O(1) lookup of valid BCP 47 tags */\nexport const BCP47_LANGUAGE_TAG_SET: ReadonlySet<string> = new Set(\n BCP47_LANGUAGE_TAGS,\n);\n\n/** Check whether a string is a valid BCP 47 language tag */\nexport function isValidBcp47Tag(tag: string): tag is Bcp47LanguageTag {\n return BCP47_LANGUAGE_TAG_SET.has(tag);\n}\n\n/**\n * Maps bare language codes to their default BCP 47 tag.\n * Used when VLM returns only a language code without a region subtag.\n */\nconst DEFAULT_REGION_MAP: Record<string, Bcp47LanguageTag> = {\n ar: 'ar-SA',\n cs: 'cs-CZ',\n da: 'da-DK',\n de: 'de-DE',\n en: 'en-US',\n es: 'es-ES',\n fr: 'fr-FR',\n id: 'id-ID',\n it: 'it-IT',\n ja: 'ja-JP',\n ko: 'ko-KR',\n ms: 'ms-MY',\n nl: 'nl-NL',\n no: 'no-NO',\n pl: 'pl-PL',\n pt: 'pt-BR',\n ro: 'ro-RO',\n ru: 'ru-RU',\n sv: 'sv-SE',\n th: 'th-TH',\n tr: 'tr-TR',\n uk: 'uk-UA',\n vi: 'vi-VT',\n zh: 'zh-Hans',\n};\n\n/**\n * Normalize a language string to a valid BCP 47 tag.\n *\n * - If the input is already a valid full tag (e.g. \"en-US\"), return it as-is.\n * - If it is a bare language code (e.g. \"en\", \"ko\"), map it to the default region.\n * - Otherwise return null (e.g. \"und\", \"unknown\", empty string).\n */\nexport function normalizeToBcp47(tag: string): Bcp47LanguageTag | null {\n if (isValidBcp47Tag(tag)) {\n return tag;\n }\n\n const lower = tag.toLowerCase();\n const mapped = DEFAULT_REGION_MAP[lower];\n if (mapped) {\n return mapped;\n }\n\n return null;\n}\n","/** Language display names for prompt context (keyed by ISO 639-1 base language code) */\nexport const LANGUAGE_DISPLAY_NAMES: Record<string, string> = {\n ko: 'Korean (한국어)',\n ja: 'Japanese (日本語)',\n zh: 'Chinese (中文)',\n en: 'English',\n fr: 'French (Français)',\n de: 'German (Deutsch)',\n es: 'Spanish (Español)',\n pt: 'Portuguese (Português)',\n ru: 'Russian (Русский)',\n uk: 'Ukrainian (Українська)',\n it: 'Italian (Italiano)',\n};\n\n/**\n * Get human-readable display name for a BCP 47 or ISO 639-1 language code.\n */\nexport function getLanguageDisplayName(code?: string): string {\n if (!code) return 'unknown';\n const baseCode = code.split('-')[0];\n return LANGUAGE_DISPLAY_NAMES[baseCode] ?? code;\n}\n\n/**\n * Build language description string from document languages.\n * @returns e.g. \"primarily written in Korean (한국어), with English also present\"\n */\nexport function buildLanguageDescription(documentLanguages: string[]): string {\n const primaryName = getLanguageDisplayName(documentLanguages[0]);\n const otherNames = documentLanguages\n .slice(1)\n .map((code) => getLanguageDisplayName(code));\n return otherNames.length > 0\n ? `primarily written in ${primaryName}, with ${otherNames.join(', ')} also present`\n : `written in ${primaryName}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKO,IAAM,sBAAsB;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAMO,IAAM,yBAA8C,IAAI;AAAA,EAC7D;AACF;AAGO,SAAS,gBAAgB,KAAsC;AACpE,SAAO,uBAAuB,IAAI,GAAG;AACvC;AAMA,IAAM,qBAAuD;AAAA,EAC3D,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AASO,SAAS,iBAAiB,KAAsC;AACrE,MAAI,gBAAgB,GAAG,GAAG;AACxB,WAAO;AAAA,EACT;AAEA,QAAM,QAAQ,IAAI,YAAY;AAC9B,QAAM,SAAS,mBAAmB,KAAK;AACvC,MAAI,QAAQ;AACV,WAAO;AAAA,EACT;AAEA,SAAO;AACT;;;ACpGO,IAAM,yBAAiD;AAAA,EAC5D,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AAKO,SAAS,uBAAuB,MAAuB;AAC5D,MAAI,CAAC,KAAM,QAAO;AAClB,QAAM,WAAW,KAAK,MAAM,GAAG,EAAE,CAAC;AAClC,SAAO,uBAAuB,QAAQ,KAAK;AAC7C;AAMO,SAAS,yBAAyB,mBAAqC;AAC5E,QAAM,cAAc,uBAAuB,kBAAkB,CAAC,CAAC;AAC/D,QAAM,aAAa,kBAChB,MAAM,CAAC,EACP,IAAI,CAAC,SAAS,uBAAuB,IAAI,CAAC;AAC7C,SAAO,WAAW,SAAS,IACvB,wBAAwB,WAAW,UAAU,WAAW,KAAK,IAAI,CAAC,kBAClE,cAAc,WAAW;AAC/B;","names":[]}
|
package/dist/index.d.cts
CHANGED
|
@@ -649,6 +649,12 @@ interface PhaseUsageReport {
|
|
|
649
649
|
* If only primary or only fallback is present, equals that model's usage.
|
|
650
650
|
*/
|
|
651
651
|
total: TokenUsageSummary;
|
|
652
|
+
/**
|
|
653
|
+
* Metadata for individual LLM calls aggregated into this phase.
|
|
654
|
+
*
|
|
655
|
+
* Examples: pageNo, commandCount, autoAppliedCount, proposalCount
|
|
656
|
+
*/
|
|
657
|
+
metadata?: TokenUsageMetadata[];
|
|
652
658
|
}
|
|
653
659
|
/**
|
|
654
660
|
* Detailed usage for a specific model
|
|
@@ -701,6 +707,8 @@ interface TokenUsageSummary {
|
|
|
701
707
|
*/
|
|
702
708
|
totalTokens: number;
|
|
703
709
|
}
|
|
710
|
+
type TokenUsageMetadataValue = string | number | boolean | null;
|
|
711
|
+
type TokenUsageMetadata = Record<string, TokenUsageMetadataValue>;
|
|
704
712
|
|
|
705
713
|
/**
|
|
706
714
|
* Result type for document processing operation
|
|
@@ -733,7 +741,7 @@ interface DocumentProcessResult {
|
|
|
733
741
|
/**
|
|
734
742
|
* Result of the OCR strategy sampling phase.
|
|
735
743
|
* Determines whether to use ocrmac (standard Docling pipeline)
|
|
736
|
-
* or VLM
|
|
744
|
+
* or VLM text correction for a given document.
|
|
737
745
|
*/
|
|
738
746
|
interface OcrStrategy {
|
|
739
747
|
/** Selected OCR method */
|
|
@@ -748,8 +756,196 @@ interface OcrStrategy {
|
|
|
748
756
|
sampledPages: number;
|
|
749
757
|
/** Total number of pages in the document */
|
|
750
758
|
totalPages: number;
|
|
751
|
-
/** 1-based page numbers where Korean-Hanja mixed script was detected in text layer */
|
|
752
|
-
koreanHanjaMixPages?: number[];
|
|
753
759
|
}
|
|
754
760
|
|
|
755
|
-
|
|
761
|
+
type ReviewAssistanceReportSchemaName = 'HeripoReviewAssistanceReport';
|
|
762
|
+
type ReviewAssistanceReportVersion = '1.0';
|
|
763
|
+
type ReviewAssistanceDisposition = 'auto_applied' | 'proposal' | 'skipped';
|
|
764
|
+
type ReviewAssistanceFailurePolicy = 'partial_page';
|
|
765
|
+
type ReviewAssistancePageStatus = 'succeeded' | 'failed';
|
|
766
|
+
type ReviewAssistanceIssueCategory = 'text' | 'table' | 'caption' | 'picture' | 'reading_order' | 'role' | 'text_integrity' | 'paragraph' | 'footnote' | 'bbox' | 'multi_page_table' | 'domain_pattern' | 'review_execution';
|
|
767
|
+
type ReviewAssistanceIssueSeverity = 'info' | 'warning' | 'error';
|
|
768
|
+
type ReviewAssistanceProgressSubstage = 'review-assistance:prepare' | 'review-assistance:page' | 'review-assistance:patch' | 'review-assistance:write-report';
|
|
769
|
+
type ReviewAssistanceProgressStatus = 'started' | 'progress' | 'completed' | 'failed';
|
|
770
|
+
interface ReviewAssistanceTableCell {
|
|
771
|
+
text: string;
|
|
772
|
+
bbox?: DoclingBBox;
|
|
773
|
+
rowSpan?: number;
|
|
774
|
+
colSpan?: number;
|
|
775
|
+
columnHeader?: boolean;
|
|
776
|
+
rowHeader?: boolean;
|
|
777
|
+
}
|
|
778
|
+
interface ReviewAssistanceImageRegion {
|
|
779
|
+
id?: string;
|
|
780
|
+
bbox: DoclingBBox;
|
|
781
|
+
imageUri?: string;
|
|
782
|
+
caption?: string;
|
|
783
|
+
}
|
|
784
|
+
type ReviewAssistanceCommand = {
|
|
785
|
+
op: 'replaceText';
|
|
786
|
+
textRef: string;
|
|
787
|
+
text: string;
|
|
788
|
+
} | {
|
|
789
|
+
op: 'addText';
|
|
790
|
+
pageNo: number;
|
|
791
|
+
bbox: DoclingBBox;
|
|
792
|
+
text: string;
|
|
793
|
+
label: string;
|
|
794
|
+
afterRef?: string;
|
|
795
|
+
} | {
|
|
796
|
+
op: 'updateTextRole';
|
|
797
|
+
textRef: string;
|
|
798
|
+
label: string;
|
|
799
|
+
} | {
|
|
800
|
+
op: 'removeText';
|
|
801
|
+
textRef: string;
|
|
802
|
+
} | {
|
|
803
|
+
op: 'mergeTexts';
|
|
804
|
+
textRefs: string[];
|
|
805
|
+
text: string;
|
|
806
|
+
keepRef: string;
|
|
807
|
+
} | {
|
|
808
|
+
op: 'splitText';
|
|
809
|
+
textRef: string;
|
|
810
|
+
parts: Array<{
|
|
811
|
+
text: string;
|
|
812
|
+
label?: string;
|
|
813
|
+
}>;
|
|
814
|
+
} | {
|
|
815
|
+
op: 'updateTableCell';
|
|
816
|
+
tableRef: string;
|
|
817
|
+
row: number;
|
|
818
|
+
col: number;
|
|
819
|
+
text: string;
|
|
820
|
+
} | {
|
|
821
|
+
op: 'replaceTable';
|
|
822
|
+
tableRef: string;
|
|
823
|
+
grid: ReviewAssistanceTableCell[][];
|
|
824
|
+
caption?: string;
|
|
825
|
+
} | {
|
|
826
|
+
op: 'linkContinuedTable';
|
|
827
|
+
sourceTableRef: string;
|
|
828
|
+
continuedTableRef: string;
|
|
829
|
+
relation: 'continues_on_next_page' | 'continued_from_previous_page';
|
|
830
|
+
} | {
|
|
831
|
+
op: 'updatePictureCaption';
|
|
832
|
+
pictureRef: string;
|
|
833
|
+
caption: string;
|
|
834
|
+
} | {
|
|
835
|
+
op: 'addPicture';
|
|
836
|
+
pageNo: number;
|
|
837
|
+
bbox: DoclingBBox;
|
|
838
|
+
imageUri: string;
|
|
839
|
+
caption?: string;
|
|
840
|
+
} | {
|
|
841
|
+
op: 'splitPicture';
|
|
842
|
+
pictureRef: string;
|
|
843
|
+
regions: ReviewAssistanceImageRegion[];
|
|
844
|
+
} | {
|
|
845
|
+
op: 'hidePicture';
|
|
846
|
+
pictureRef: string;
|
|
847
|
+
reason: string;
|
|
848
|
+
} | {
|
|
849
|
+
op: 'updateBbox';
|
|
850
|
+
targetRef: string;
|
|
851
|
+
bbox: DoclingBBox;
|
|
852
|
+
} | {
|
|
853
|
+
op: 'linkFootnote';
|
|
854
|
+
markerTextRef: string;
|
|
855
|
+
footnoteTextRef: string;
|
|
856
|
+
} | {
|
|
857
|
+
op: 'moveNode';
|
|
858
|
+
sourceRef: string;
|
|
859
|
+
targetRef: string;
|
|
860
|
+
position: 'before' | 'after';
|
|
861
|
+
};
|
|
862
|
+
interface ReviewAssistanceDecisionEvidence {
|
|
863
|
+
imageEvidence?: string;
|
|
864
|
+
textLayerEvidence?: string;
|
|
865
|
+
suspectReasons?: string[];
|
|
866
|
+
previousBbox?: DoclingBBox;
|
|
867
|
+
snappedBbox?: DoclingBBox;
|
|
868
|
+
generatedRefs?: string[];
|
|
869
|
+
}
|
|
870
|
+
interface ReviewAssistanceDecision {
|
|
871
|
+
id: string;
|
|
872
|
+
pageNo: number;
|
|
873
|
+
/** Present only when validation produced a normalized command. */
|
|
874
|
+
command?: ReviewAssistanceCommand;
|
|
875
|
+
/** Original op when validation rejected the payload before normalization. */
|
|
876
|
+
invalidOp?: string;
|
|
877
|
+
confidence: number;
|
|
878
|
+
disposition: ReviewAssistanceDisposition;
|
|
879
|
+
reasons: string[];
|
|
880
|
+
evidence?: ReviewAssistanceDecisionEvidence;
|
|
881
|
+
metadata?: Record<string, unknown>;
|
|
882
|
+
}
|
|
883
|
+
interface ReviewAssistanceIssue {
|
|
884
|
+
id: string;
|
|
885
|
+
pageNo: number;
|
|
886
|
+
category: ReviewAssistanceIssueCategory;
|
|
887
|
+
type: string;
|
|
888
|
+
severity: ReviewAssistanceIssueSeverity;
|
|
889
|
+
description: string;
|
|
890
|
+
confidence?: number;
|
|
891
|
+
refs?: string[];
|
|
892
|
+
bbox?: DoclingBBox;
|
|
893
|
+
reasons?: string[];
|
|
894
|
+
}
|
|
895
|
+
interface ReviewAssistancePageResult {
|
|
896
|
+
pageNo: number;
|
|
897
|
+
status: ReviewAssistancePageStatus;
|
|
898
|
+
decisions: ReviewAssistanceDecision[];
|
|
899
|
+
issues: ReviewAssistanceIssue[];
|
|
900
|
+
error?: {
|
|
901
|
+
message: string;
|
|
902
|
+
code?: string;
|
|
903
|
+
};
|
|
904
|
+
}
|
|
905
|
+
interface ReviewAssistanceReport {
|
|
906
|
+
schemaName: ReviewAssistanceReportSchemaName;
|
|
907
|
+
version: ReviewAssistanceReportVersion;
|
|
908
|
+
reportId: string;
|
|
909
|
+
source: {
|
|
910
|
+
doclingResult: 'result.json';
|
|
911
|
+
ocrOriginSnapshot?: 'result_ocr_origin.json';
|
|
912
|
+
originSnapshot?: 'result_review_origin.json';
|
|
913
|
+
};
|
|
914
|
+
options: {
|
|
915
|
+
enabled: true;
|
|
916
|
+
concurrency: number;
|
|
917
|
+
autoApplyThreshold: number;
|
|
918
|
+
proposalThreshold: number;
|
|
919
|
+
maxRetries: number;
|
|
920
|
+
temperature: number;
|
|
921
|
+
outputLanguage: string;
|
|
922
|
+
failurePolicy: ReviewAssistanceFailurePolicy;
|
|
923
|
+
};
|
|
924
|
+
summary: {
|
|
925
|
+
pageCount: number;
|
|
926
|
+
pagesSucceeded: number;
|
|
927
|
+
pagesFailed: number;
|
|
928
|
+
autoAppliedCount: number;
|
|
929
|
+
proposalCount: number;
|
|
930
|
+
skippedCount: number;
|
|
931
|
+
issueCount: number;
|
|
932
|
+
layoutIssueCount?: number;
|
|
933
|
+
textIntegrityIssueCount?: number;
|
|
934
|
+
};
|
|
935
|
+
pages: ReviewAssistancePageResult[];
|
|
936
|
+
}
|
|
937
|
+
interface ReviewAssistanceProgressEvent {
|
|
938
|
+
substage: ReviewAssistanceProgressSubstage;
|
|
939
|
+
status: ReviewAssistanceProgressStatus;
|
|
940
|
+
reportId: string;
|
|
941
|
+
pageNo?: number;
|
|
942
|
+
pageCount?: number;
|
|
943
|
+
completedPages?: number;
|
|
944
|
+
failedPages?: number;
|
|
945
|
+
commandCount?: number;
|
|
946
|
+
autoAppliedCount?: number;
|
|
947
|
+
proposalCount?: number;
|
|
948
|
+
message?: string;
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
export { BCP47_LANGUAGE_TAGS, BCP47_LANGUAGE_TAG_SET, type Bcp47LanguageTag, type Caption, type Chapter, type ComponentUsageReport, type DoclingBBox, type DoclingBaseNode, type DoclingBody, type DoclingDocument, type DoclingGroupItem, type DoclingOrigin, type DoclingPage, type DoclingPageImage, type DoclingPictureItem, type DoclingProv, type DoclingReference, type DoclingTableCell, type DoclingTableData, type DoclingTableItem, type DoclingTextItem, type DocumentProcessResult, LANGUAGE_DISPLAY_NAMES, type ModelUsageDetail, type OcrStrategy, type PageRange, type PhaseUsageReport, type ProcessedDocument, type ProcessedFootnote, type ProcessedImage, type ProcessedTable, type ProcessedTableCell, type ReviewAssistanceCommand, type ReviewAssistanceDecision, type ReviewAssistanceDecisionEvidence, type ReviewAssistanceDisposition, type ReviewAssistanceFailurePolicy, type ReviewAssistanceImageRegion, type ReviewAssistanceIssue, type ReviewAssistanceIssueCategory, type ReviewAssistanceIssueSeverity, type ReviewAssistancePageResult, type ReviewAssistancePageStatus, type ReviewAssistanceProgressEvent, type ReviewAssistanceProgressStatus, type ReviewAssistanceProgressSubstage, type ReviewAssistanceReport, type ReviewAssistanceReportSchemaName, type ReviewAssistanceReportVersion, type ReviewAssistanceTableCell, type TextBlock, type TokenUsageMetadata, type TokenUsageMetadataValue, type TokenUsageReport, type TokenUsageSummary, buildLanguageDescription, getLanguageDisplayName, isValidBcp47Tag, normalizeToBcp47 };
|
package/dist/index.d.ts
CHANGED
|
@@ -649,6 +649,12 @@ interface PhaseUsageReport {
|
|
|
649
649
|
* If only primary or only fallback is present, equals that model's usage.
|
|
650
650
|
*/
|
|
651
651
|
total: TokenUsageSummary;
|
|
652
|
+
/**
|
|
653
|
+
* Metadata for individual LLM calls aggregated into this phase.
|
|
654
|
+
*
|
|
655
|
+
* Examples: pageNo, commandCount, autoAppliedCount, proposalCount
|
|
656
|
+
*/
|
|
657
|
+
metadata?: TokenUsageMetadata[];
|
|
652
658
|
}
|
|
653
659
|
/**
|
|
654
660
|
* Detailed usage for a specific model
|
|
@@ -701,6 +707,8 @@ interface TokenUsageSummary {
|
|
|
701
707
|
*/
|
|
702
708
|
totalTokens: number;
|
|
703
709
|
}
|
|
710
|
+
type TokenUsageMetadataValue = string | number | boolean | null;
|
|
711
|
+
type TokenUsageMetadata = Record<string, TokenUsageMetadataValue>;
|
|
704
712
|
|
|
705
713
|
/**
|
|
706
714
|
* Result type for document processing operation
|
|
@@ -733,7 +741,7 @@ interface DocumentProcessResult {
|
|
|
733
741
|
/**
|
|
734
742
|
* Result of the OCR strategy sampling phase.
|
|
735
743
|
* Determines whether to use ocrmac (standard Docling pipeline)
|
|
736
|
-
* or VLM
|
|
744
|
+
* or VLM text correction for a given document.
|
|
737
745
|
*/
|
|
738
746
|
interface OcrStrategy {
|
|
739
747
|
/** Selected OCR method */
|
|
@@ -748,8 +756,196 @@ interface OcrStrategy {
|
|
|
748
756
|
sampledPages: number;
|
|
749
757
|
/** Total number of pages in the document */
|
|
750
758
|
totalPages: number;
|
|
751
|
-
/** 1-based page numbers where Korean-Hanja mixed script was detected in text layer */
|
|
752
|
-
koreanHanjaMixPages?: number[];
|
|
753
759
|
}
|
|
754
760
|
|
|
755
|
-
|
|
761
|
+
type ReviewAssistanceReportSchemaName = 'HeripoReviewAssistanceReport';
|
|
762
|
+
type ReviewAssistanceReportVersion = '1.0';
|
|
763
|
+
type ReviewAssistanceDisposition = 'auto_applied' | 'proposal' | 'skipped';
|
|
764
|
+
type ReviewAssistanceFailurePolicy = 'partial_page';
|
|
765
|
+
type ReviewAssistancePageStatus = 'succeeded' | 'failed';
|
|
766
|
+
type ReviewAssistanceIssueCategory = 'text' | 'table' | 'caption' | 'picture' | 'reading_order' | 'role' | 'text_integrity' | 'paragraph' | 'footnote' | 'bbox' | 'multi_page_table' | 'domain_pattern' | 'review_execution';
|
|
767
|
+
type ReviewAssistanceIssueSeverity = 'info' | 'warning' | 'error';
|
|
768
|
+
type ReviewAssistanceProgressSubstage = 'review-assistance:prepare' | 'review-assistance:page' | 'review-assistance:patch' | 'review-assistance:write-report';
|
|
769
|
+
type ReviewAssistanceProgressStatus = 'started' | 'progress' | 'completed' | 'failed';
|
|
770
|
+
interface ReviewAssistanceTableCell {
|
|
771
|
+
text: string;
|
|
772
|
+
bbox?: DoclingBBox;
|
|
773
|
+
rowSpan?: number;
|
|
774
|
+
colSpan?: number;
|
|
775
|
+
columnHeader?: boolean;
|
|
776
|
+
rowHeader?: boolean;
|
|
777
|
+
}
|
|
778
|
+
interface ReviewAssistanceImageRegion {
|
|
779
|
+
id?: string;
|
|
780
|
+
bbox: DoclingBBox;
|
|
781
|
+
imageUri?: string;
|
|
782
|
+
caption?: string;
|
|
783
|
+
}
|
|
784
|
+
type ReviewAssistanceCommand = {
|
|
785
|
+
op: 'replaceText';
|
|
786
|
+
textRef: string;
|
|
787
|
+
text: string;
|
|
788
|
+
} | {
|
|
789
|
+
op: 'addText';
|
|
790
|
+
pageNo: number;
|
|
791
|
+
bbox: DoclingBBox;
|
|
792
|
+
text: string;
|
|
793
|
+
label: string;
|
|
794
|
+
afterRef?: string;
|
|
795
|
+
} | {
|
|
796
|
+
op: 'updateTextRole';
|
|
797
|
+
textRef: string;
|
|
798
|
+
label: string;
|
|
799
|
+
} | {
|
|
800
|
+
op: 'removeText';
|
|
801
|
+
textRef: string;
|
|
802
|
+
} | {
|
|
803
|
+
op: 'mergeTexts';
|
|
804
|
+
textRefs: string[];
|
|
805
|
+
text: string;
|
|
806
|
+
keepRef: string;
|
|
807
|
+
} | {
|
|
808
|
+
op: 'splitText';
|
|
809
|
+
textRef: string;
|
|
810
|
+
parts: Array<{
|
|
811
|
+
text: string;
|
|
812
|
+
label?: string;
|
|
813
|
+
}>;
|
|
814
|
+
} | {
|
|
815
|
+
op: 'updateTableCell';
|
|
816
|
+
tableRef: string;
|
|
817
|
+
row: number;
|
|
818
|
+
col: number;
|
|
819
|
+
text: string;
|
|
820
|
+
} | {
|
|
821
|
+
op: 'replaceTable';
|
|
822
|
+
tableRef: string;
|
|
823
|
+
grid: ReviewAssistanceTableCell[][];
|
|
824
|
+
caption?: string;
|
|
825
|
+
} | {
|
|
826
|
+
op: 'linkContinuedTable';
|
|
827
|
+
sourceTableRef: string;
|
|
828
|
+
continuedTableRef: string;
|
|
829
|
+
relation: 'continues_on_next_page' | 'continued_from_previous_page';
|
|
830
|
+
} | {
|
|
831
|
+
op: 'updatePictureCaption';
|
|
832
|
+
pictureRef: string;
|
|
833
|
+
caption: string;
|
|
834
|
+
} | {
|
|
835
|
+
op: 'addPicture';
|
|
836
|
+
pageNo: number;
|
|
837
|
+
bbox: DoclingBBox;
|
|
838
|
+
imageUri: string;
|
|
839
|
+
caption?: string;
|
|
840
|
+
} | {
|
|
841
|
+
op: 'splitPicture';
|
|
842
|
+
pictureRef: string;
|
|
843
|
+
regions: ReviewAssistanceImageRegion[];
|
|
844
|
+
} | {
|
|
845
|
+
op: 'hidePicture';
|
|
846
|
+
pictureRef: string;
|
|
847
|
+
reason: string;
|
|
848
|
+
} | {
|
|
849
|
+
op: 'updateBbox';
|
|
850
|
+
targetRef: string;
|
|
851
|
+
bbox: DoclingBBox;
|
|
852
|
+
} | {
|
|
853
|
+
op: 'linkFootnote';
|
|
854
|
+
markerTextRef: string;
|
|
855
|
+
footnoteTextRef: string;
|
|
856
|
+
} | {
|
|
857
|
+
op: 'moveNode';
|
|
858
|
+
sourceRef: string;
|
|
859
|
+
targetRef: string;
|
|
860
|
+
position: 'before' | 'after';
|
|
861
|
+
};
|
|
862
|
+
interface ReviewAssistanceDecisionEvidence {
|
|
863
|
+
imageEvidence?: string;
|
|
864
|
+
textLayerEvidence?: string;
|
|
865
|
+
suspectReasons?: string[];
|
|
866
|
+
previousBbox?: DoclingBBox;
|
|
867
|
+
snappedBbox?: DoclingBBox;
|
|
868
|
+
generatedRefs?: string[];
|
|
869
|
+
}
|
|
870
|
+
interface ReviewAssistanceDecision {
|
|
871
|
+
id: string;
|
|
872
|
+
pageNo: number;
|
|
873
|
+
/** Present only when validation produced a normalized command. */
|
|
874
|
+
command?: ReviewAssistanceCommand;
|
|
875
|
+
/** Original op when validation rejected the payload before normalization. */
|
|
876
|
+
invalidOp?: string;
|
|
877
|
+
confidence: number;
|
|
878
|
+
disposition: ReviewAssistanceDisposition;
|
|
879
|
+
reasons: string[];
|
|
880
|
+
evidence?: ReviewAssistanceDecisionEvidence;
|
|
881
|
+
metadata?: Record<string, unknown>;
|
|
882
|
+
}
|
|
883
|
+
interface ReviewAssistanceIssue {
|
|
884
|
+
id: string;
|
|
885
|
+
pageNo: number;
|
|
886
|
+
category: ReviewAssistanceIssueCategory;
|
|
887
|
+
type: string;
|
|
888
|
+
severity: ReviewAssistanceIssueSeverity;
|
|
889
|
+
description: string;
|
|
890
|
+
confidence?: number;
|
|
891
|
+
refs?: string[];
|
|
892
|
+
bbox?: DoclingBBox;
|
|
893
|
+
reasons?: string[];
|
|
894
|
+
}
|
|
895
|
+
interface ReviewAssistancePageResult {
|
|
896
|
+
pageNo: number;
|
|
897
|
+
status: ReviewAssistancePageStatus;
|
|
898
|
+
decisions: ReviewAssistanceDecision[];
|
|
899
|
+
issues: ReviewAssistanceIssue[];
|
|
900
|
+
error?: {
|
|
901
|
+
message: string;
|
|
902
|
+
code?: string;
|
|
903
|
+
};
|
|
904
|
+
}
|
|
905
|
+
interface ReviewAssistanceReport {
|
|
906
|
+
schemaName: ReviewAssistanceReportSchemaName;
|
|
907
|
+
version: ReviewAssistanceReportVersion;
|
|
908
|
+
reportId: string;
|
|
909
|
+
source: {
|
|
910
|
+
doclingResult: 'result.json';
|
|
911
|
+
ocrOriginSnapshot?: 'result_ocr_origin.json';
|
|
912
|
+
originSnapshot?: 'result_review_origin.json';
|
|
913
|
+
};
|
|
914
|
+
options: {
|
|
915
|
+
enabled: true;
|
|
916
|
+
concurrency: number;
|
|
917
|
+
autoApplyThreshold: number;
|
|
918
|
+
proposalThreshold: number;
|
|
919
|
+
maxRetries: number;
|
|
920
|
+
temperature: number;
|
|
921
|
+
outputLanguage: string;
|
|
922
|
+
failurePolicy: ReviewAssistanceFailurePolicy;
|
|
923
|
+
};
|
|
924
|
+
summary: {
|
|
925
|
+
pageCount: number;
|
|
926
|
+
pagesSucceeded: number;
|
|
927
|
+
pagesFailed: number;
|
|
928
|
+
autoAppliedCount: number;
|
|
929
|
+
proposalCount: number;
|
|
930
|
+
skippedCount: number;
|
|
931
|
+
issueCount: number;
|
|
932
|
+
layoutIssueCount?: number;
|
|
933
|
+
textIntegrityIssueCount?: number;
|
|
934
|
+
};
|
|
935
|
+
pages: ReviewAssistancePageResult[];
|
|
936
|
+
}
|
|
937
|
+
interface ReviewAssistanceProgressEvent {
|
|
938
|
+
substage: ReviewAssistanceProgressSubstage;
|
|
939
|
+
status: ReviewAssistanceProgressStatus;
|
|
940
|
+
reportId: string;
|
|
941
|
+
pageNo?: number;
|
|
942
|
+
pageCount?: number;
|
|
943
|
+
completedPages?: number;
|
|
944
|
+
failedPages?: number;
|
|
945
|
+
commandCount?: number;
|
|
946
|
+
autoAppliedCount?: number;
|
|
947
|
+
proposalCount?: number;
|
|
948
|
+
message?: string;
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
export { BCP47_LANGUAGE_TAGS, BCP47_LANGUAGE_TAG_SET, type Bcp47LanguageTag, type Caption, type Chapter, type ComponentUsageReport, type DoclingBBox, type DoclingBaseNode, type DoclingBody, type DoclingDocument, type DoclingGroupItem, type DoclingOrigin, type DoclingPage, type DoclingPageImage, type DoclingPictureItem, type DoclingProv, type DoclingReference, type DoclingTableCell, type DoclingTableData, type DoclingTableItem, type DoclingTextItem, type DocumentProcessResult, LANGUAGE_DISPLAY_NAMES, type ModelUsageDetail, type OcrStrategy, type PageRange, type PhaseUsageReport, type ProcessedDocument, type ProcessedFootnote, type ProcessedImage, type ProcessedTable, type ProcessedTableCell, type ReviewAssistanceCommand, type ReviewAssistanceDecision, type ReviewAssistanceDecisionEvidence, type ReviewAssistanceDisposition, type ReviewAssistanceFailurePolicy, type ReviewAssistanceImageRegion, type ReviewAssistanceIssue, type ReviewAssistanceIssueCategory, type ReviewAssistanceIssueSeverity, type ReviewAssistancePageResult, type ReviewAssistancePageStatus, type ReviewAssistanceProgressEvent, type ReviewAssistanceProgressStatus, type ReviewAssistanceProgressSubstage, type ReviewAssistanceReport, type ReviewAssistanceReportSchemaName, type ReviewAssistanceReportVersion, type ReviewAssistanceTableCell, type TextBlock, type TokenUsageMetadata, type TokenUsageMetadataValue, type TokenUsageReport, type TokenUsageSummary, buildLanguageDescription, getLanguageDisplayName, isValidBcp47Tag, normalizeToBcp47 };
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@heripo/model",
|
|
3
3
|
"private": false,
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "0.1.
|
|
5
|
+
"version": "0.1.28",
|
|
6
6
|
"description": "Document models and type definitions for heripo engine",
|
|
7
7
|
"main": "dist/index.cjs",
|
|
8
8
|
"module": "dist/index.js",
|
|
@@ -52,9 +52,9 @@
|
|
|
52
52
|
"access": "public"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
-
"@vitest/coverage-v8": "^4.1.
|
|
55
|
+
"@vitest/coverage-v8": "^4.1.5",
|
|
56
56
|
"tsup": "^8.5.1",
|
|
57
|
-
"vitest": "^4.1.
|
|
57
|
+
"vitest": "^4.1.5",
|
|
58
58
|
"@heripo/tsconfig": "0.0.0",
|
|
59
59
|
"@heripo/tsup-config": "0.0.0",
|
|
60
60
|
"@heripo/vitest-config": "0.0.0"
|