@heripo/model 0.1.25 → 0.1.27
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.cjs.map +1 -1
- package/dist/index.d.cts +199 -1
- package/dist/index.d.ts +199 -1
- package/package.json +5 -5
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
|
|
@@ -752,4 +760,194 @@ interface OcrStrategy {
|
|
|
752
760
|
koreanHanjaMixPages?: number[];
|
|
753
761
|
}
|
|
754
762
|
|
|
755
|
-
|
|
763
|
+
type ReviewAssistanceReportSchemaName = 'HeripoReviewAssistanceReport';
|
|
764
|
+
type ReviewAssistanceReportVersion = '1.0';
|
|
765
|
+
type ReviewAssistanceDisposition = 'auto_applied' | 'proposal' | 'skipped';
|
|
766
|
+
type ReviewAssistanceFailurePolicy = 'partial_page';
|
|
767
|
+
type ReviewAssistancePageStatus = 'succeeded' | 'failed';
|
|
768
|
+
type ReviewAssistanceIssueCategory = 'text' | 'table' | 'caption' | 'picture' | 'reading_order' | 'role' | 'text_integrity' | 'paragraph' | 'footnote' | 'bbox' | 'multi_page_table' | 'domain_pattern' | 'review_execution';
|
|
769
|
+
type ReviewAssistanceIssueSeverity = 'info' | 'warning' | 'error';
|
|
770
|
+
type ReviewAssistanceProgressSubstage = 'review-assistance:prepare' | 'review-assistance:page' | 'review-assistance:patch' | 'review-assistance:write-report';
|
|
771
|
+
type ReviewAssistanceProgressStatus = 'started' | 'progress' | 'completed' | 'failed';
|
|
772
|
+
interface ReviewAssistanceTableCell {
|
|
773
|
+
text: string;
|
|
774
|
+
bbox?: DoclingBBox;
|
|
775
|
+
rowSpan?: number;
|
|
776
|
+
colSpan?: number;
|
|
777
|
+
columnHeader?: boolean;
|
|
778
|
+
rowHeader?: boolean;
|
|
779
|
+
}
|
|
780
|
+
interface ReviewAssistanceImageRegion {
|
|
781
|
+
id?: string;
|
|
782
|
+
bbox: DoclingBBox;
|
|
783
|
+
imageUri?: string;
|
|
784
|
+
caption?: string;
|
|
785
|
+
}
|
|
786
|
+
type ReviewAssistanceCommand = {
|
|
787
|
+
op: 'replaceText';
|
|
788
|
+
textRef: string;
|
|
789
|
+
text: string;
|
|
790
|
+
} | {
|
|
791
|
+
op: 'addText';
|
|
792
|
+
pageNo: number;
|
|
793
|
+
bbox: DoclingBBox;
|
|
794
|
+
text: string;
|
|
795
|
+
label: string;
|
|
796
|
+
afterRef?: string;
|
|
797
|
+
} | {
|
|
798
|
+
op: 'updateTextRole';
|
|
799
|
+
textRef: string;
|
|
800
|
+
label: string;
|
|
801
|
+
} | {
|
|
802
|
+
op: 'removeText';
|
|
803
|
+
textRef: string;
|
|
804
|
+
} | {
|
|
805
|
+
op: 'mergeTexts';
|
|
806
|
+
textRefs: string[];
|
|
807
|
+
text: string;
|
|
808
|
+
keepRef: string;
|
|
809
|
+
} | {
|
|
810
|
+
op: 'splitText';
|
|
811
|
+
textRef: string;
|
|
812
|
+
parts: Array<{
|
|
813
|
+
text: string;
|
|
814
|
+
label?: string;
|
|
815
|
+
}>;
|
|
816
|
+
} | {
|
|
817
|
+
op: 'updateTableCell';
|
|
818
|
+
tableRef: string;
|
|
819
|
+
row: number;
|
|
820
|
+
col: number;
|
|
821
|
+
text: string;
|
|
822
|
+
} | {
|
|
823
|
+
op: 'replaceTable';
|
|
824
|
+
tableRef: string;
|
|
825
|
+
grid: ReviewAssistanceTableCell[][];
|
|
826
|
+
caption?: string;
|
|
827
|
+
} | {
|
|
828
|
+
op: 'linkContinuedTable';
|
|
829
|
+
sourceTableRef: string;
|
|
830
|
+
continuedTableRef: string;
|
|
831
|
+
relation: 'continues_on_next_page' | 'continued_from_previous_page';
|
|
832
|
+
} | {
|
|
833
|
+
op: 'updatePictureCaption';
|
|
834
|
+
pictureRef: string;
|
|
835
|
+
caption: string;
|
|
836
|
+
} | {
|
|
837
|
+
op: 'addPicture';
|
|
838
|
+
pageNo: number;
|
|
839
|
+
bbox: DoclingBBox;
|
|
840
|
+
imageUri: string;
|
|
841
|
+
caption?: string;
|
|
842
|
+
} | {
|
|
843
|
+
op: 'splitPicture';
|
|
844
|
+
pictureRef: string;
|
|
845
|
+
regions: ReviewAssistanceImageRegion[];
|
|
846
|
+
} | {
|
|
847
|
+
op: 'hidePicture';
|
|
848
|
+
pictureRef: string;
|
|
849
|
+
reason: string;
|
|
850
|
+
} | {
|
|
851
|
+
op: 'updateBbox';
|
|
852
|
+
targetRef: string;
|
|
853
|
+
bbox: DoclingBBox;
|
|
854
|
+
} | {
|
|
855
|
+
op: 'linkFootnote';
|
|
856
|
+
markerTextRef: string;
|
|
857
|
+
footnoteTextRef: string;
|
|
858
|
+
} | {
|
|
859
|
+
op: 'moveNode';
|
|
860
|
+
sourceRef: string;
|
|
861
|
+
targetRef: string;
|
|
862
|
+
position: 'before' | 'after';
|
|
863
|
+
};
|
|
864
|
+
interface ReviewAssistanceDecisionEvidence {
|
|
865
|
+
imageEvidence?: string;
|
|
866
|
+
textLayerEvidence?: string;
|
|
867
|
+
suspectReasons?: string[];
|
|
868
|
+
previousBbox?: DoclingBBox;
|
|
869
|
+
snappedBbox?: DoclingBBox;
|
|
870
|
+
generatedRefs?: string[];
|
|
871
|
+
}
|
|
872
|
+
interface ReviewAssistanceDecision {
|
|
873
|
+
id: string;
|
|
874
|
+
pageNo: number;
|
|
875
|
+
/** Present only when validation produced a normalized command. */
|
|
876
|
+
command?: ReviewAssistanceCommand;
|
|
877
|
+
/** Original op when validation rejected the payload before normalization. */
|
|
878
|
+
invalidOp?: string;
|
|
879
|
+
confidence: number;
|
|
880
|
+
disposition: ReviewAssistanceDisposition;
|
|
881
|
+
reasons: string[];
|
|
882
|
+
evidence?: ReviewAssistanceDecisionEvidence;
|
|
883
|
+
metadata?: Record<string, unknown>;
|
|
884
|
+
}
|
|
885
|
+
interface ReviewAssistanceIssue {
|
|
886
|
+
id: string;
|
|
887
|
+
pageNo: number;
|
|
888
|
+
category: ReviewAssistanceIssueCategory;
|
|
889
|
+
type: string;
|
|
890
|
+
severity: ReviewAssistanceIssueSeverity;
|
|
891
|
+
description: string;
|
|
892
|
+
confidence?: number;
|
|
893
|
+
refs?: string[];
|
|
894
|
+
bbox?: DoclingBBox;
|
|
895
|
+
reasons?: string[];
|
|
896
|
+
}
|
|
897
|
+
interface ReviewAssistancePageResult {
|
|
898
|
+
pageNo: number;
|
|
899
|
+
status: ReviewAssistancePageStatus;
|
|
900
|
+
decisions: ReviewAssistanceDecision[];
|
|
901
|
+
issues: ReviewAssistanceIssue[];
|
|
902
|
+
error?: {
|
|
903
|
+
message: string;
|
|
904
|
+
code?: string;
|
|
905
|
+
};
|
|
906
|
+
}
|
|
907
|
+
interface ReviewAssistanceReport {
|
|
908
|
+
schemaName: ReviewAssistanceReportSchemaName;
|
|
909
|
+
version: ReviewAssistanceReportVersion;
|
|
910
|
+
reportId: string;
|
|
911
|
+
source: {
|
|
912
|
+
doclingResult: 'result.json';
|
|
913
|
+
ocrOriginSnapshot?: 'result_ocr_origin.json';
|
|
914
|
+
originSnapshot?: 'result_review_origin.json';
|
|
915
|
+
};
|
|
916
|
+
options: {
|
|
917
|
+
enabled: true;
|
|
918
|
+
concurrency: number;
|
|
919
|
+
autoApplyThreshold: number;
|
|
920
|
+
proposalThreshold: number;
|
|
921
|
+
maxRetries: number;
|
|
922
|
+
temperature: number;
|
|
923
|
+
outputLanguage: string;
|
|
924
|
+
failurePolicy: ReviewAssistanceFailurePolicy;
|
|
925
|
+
};
|
|
926
|
+
summary: {
|
|
927
|
+
pageCount: number;
|
|
928
|
+
pagesSucceeded: number;
|
|
929
|
+
pagesFailed: number;
|
|
930
|
+
autoAppliedCount: number;
|
|
931
|
+
proposalCount: number;
|
|
932
|
+
skippedCount: number;
|
|
933
|
+
issueCount: number;
|
|
934
|
+
layoutIssueCount?: number;
|
|
935
|
+
textIntegrityIssueCount?: number;
|
|
936
|
+
};
|
|
937
|
+
pages: ReviewAssistancePageResult[];
|
|
938
|
+
}
|
|
939
|
+
interface ReviewAssistanceProgressEvent {
|
|
940
|
+
substage: ReviewAssistanceProgressSubstage;
|
|
941
|
+
status: ReviewAssistanceProgressStatus;
|
|
942
|
+
reportId: string;
|
|
943
|
+
pageNo?: number;
|
|
944
|
+
pageCount?: number;
|
|
945
|
+
completedPages?: number;
|
|
946
|
+
failedPages?: number;
|
|
947
|
+
commandCount?: number;
|
|
948
|
+
autoAppliedCount?: number;
|
|
949
|
+
proposalCount?: number;
|
|
950
|
+
message?: string;
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
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
|
|
@@ -752,4 +760,194 @@ interface OcrStrategy {
|
|
|
752
760
|
koreanHanjaMixPages?: number[];
|
|
753
761
|
}
|
|
754
762
|
|
|
755
|
-
|
|
763
|
+
type ReviewAssistanceReportSchemaName = 'HeripoReviewAssistanceReport';
|
|
764
|
+
type ReviewAssistanceReportVersion = '1.0';
|
|
765
|
+
type ReviewAssistanceDisposition = 'auto_applied' | 'proposal' | 'skipped';
|
|
766
|
+
type ReviewAssistanceFailurePolicy = 'partial_page';
|
|
767
|
+
type ReviewAssistancePageStatus = 'succeeded' | 'failed';
|
|
768
|
+
type ReviewAssistanceIssueCategory = 'text' | 'table' | 'caption' | 'picture' | 'reading_order' | 'role' | 'text_integrity' | 'paragraph' | 'footnote' | 'bbox' | 'multi_page_table' | 'domain_pattern' | 'review_execution';
|
|
769
|
+
type ReviewAssistanceIssueSeverity = 'info' | 'warning' | 'error';
|
|
770
|
+
type ReviewAssistanceProgressSubstage = 'review-assistance:prepare' | 'review-assistance:page' | 'review-assistance:patch' | 'review-assistance:write-report';
|
|
771
|
+
type ReviewAssistanceProgressStatus = 'started' | 'progress' | 'completed' | 'failed';
|
|
772
|
+
interface ReviewAssistanceTableCell {
|
|
773
|
+
text: string;
|
|
774
|
+
bbox?: DoclingBBox;
|
|
775
|
+
rowSpan?: number;
|
|
776
|
+
colSpan?: number;
|
|
777
|
+
columnHeader?: boolean;
|
|
778
|
+
rowHeader?: boolean;
|
|
779
|
+
}
|
|
780
|
+
interface ReviewAssistanceImageRegion {
|
|
781
|
+
id?: string;
|
|
782
|
+
bbox: DoclingBBox;
|
|
783
|
+
imageUri?: string;
|
|
784
|
+
caption?: string;
|
|
785
|
+
}
|
|
786
|
+
type ReviewAssistanceCommand = {
|
|
787
|
+
op: 'replaceText';
|
|
788
|
+
textRef: string;
|
|
789
|
+
text: string;
|
|
790
|
+
} | {
|
|
791
|
+
op: 'addText';
|
|
792
|
+
pageNo: number;
|
|
793
|
+
bbox: DoclingBBox;
|
|
794
|
+
text: string;
|
|
795
|
+
label: string;
|
|
796
|
+
afterRef?: string;
|
|
797
|
+
} | {
|
|
798
|
+
op: 'updateTextRole';
|
|
799
|
+
textRef: string;
|
|
800
|
+
label: string;
|
|
801
|
+
} | {
|
|
802
|
+
op: 'removeText';
|
|
803
|
+
textRef: string;
|
|
804
|
+
} | {
|
|
805
|
+
op: 'mergeTexts';
|
|
806
|
+
textRefs: string[];
|
|
807
|
+
text: string;
|
|
808
|
+
keepRef: string;
|
|
809
|
+
} | {
|
|
810
|
+
op: 'splitText';
|
|
811
|
+
textRef: string;
|
|
812
|
+
parts: Array<{
|
|
813
|
+
text: string;
|
|
814
|
+
label?: string;
|
|
815
|
+
}>;
|
|
816
|
+
} | {
|
|
817
|
+
op: 'updateTableCell';
|
|
818
|
+
tableRef: string;
|
|
819
|
+
row: number;
|
|
820
|
+
col: number;
|
|
821
|
+
text: string;
|
|
822
|
+
} | {
|
|
823
|
+
op: 'replaceTable';
|
|
824
|
+
tableRef: string;
|
|
825
|
+
grid: ReviewAssistanceTableCell[][];
|
|
826
|
+
caption?: string;
|
|
827
|
+
} | {
|
|
828
|
+
op: 'linkContinuedTable';
|
|
829
|
+
sourceTableRef: string;
|
|
830
|
+
continuedTableRef: string;
|
|
831
|
+
relation: 'continues_on_next_page' | 'continued_from_previous_page';
|
|
832
|
+
} | {
|
|
833
|
+
op: 'updatePictureCaption';
|
|
834
|
+
pictureRef: string;
|
|
835
|
+
caption: string;
|
|
836
|
+
} | {
|
|
837
|
+
op: 'addPicture';
|
|
838
|
+
pageNo: number;
|
|
839
|
+
bbox: DoclingBBox;
|
|
840
|
+
imageUri: string;
|
|
841
|
+
caption?: string;
|
|
842
|
+
} | {
|
|
843
|
+
op: 'splitPicture';
|
|
844
|
+
pictureRef: string;
|
|
845
|
+
regions: ReviewAssistanceImageRegion[];
|
|
846
|
+
} | {
|
|
847
|
+
op: 'hidePicture';
|
|
848
|
+
pictureRef: string;
|
|
849
|
+
reason: string;
|
|
850
|
+
} | {
|
|
851
|
+
op: 'updateBbox';
|
|
852
|
+
targetRef: string;
|
|
853
|
+
bbox: DoclingBBox;
|
|
854
|
+
} | {
|
|
855
|
+
op: 'linkFootnote';
|
|
856
|
+
markerTextRef: string;
|
|
857
|
+
footnoteTextRef: string;
|
|
858
|
+
} | {
|
|
859
|
+
op: 'moveNode';
|
|
860
|
+
sourceRef: string;
|
|
861
|
+
targetRef: string;
|
|
862
|
+
position: 'before' | 'after';
|
|
863
|
+
};
|
|
864
|
+
interface ReviewAssistanceDecisionEvidence {
|
|
865
|
+
imageEvidence?: string;
|
|
866
|
+
textLayerEvidence?: string;
|
|
867
|
+
suspectReasons?: string[];
|
|
868
|
+
previousBbox?: DoclingBBox;
|
|
869
|
+
snappedBbox?: DoclingBBox;
|
|
870
|
+
generatedRefs?: string[];
|
|
871
|
+
}
|
|
872
|
+
interface ReviewAssistanceDecision {
|
|
873
|
+
id: string;
|
|
874
|
+
pageNo: number;
|
|
875
|
+
/** Present only when validation produced a normalized command. */
|
|
876
|
+
command?: ReviewAssistanceCommand;
|
|
877
|
+
/** Original op when validation rejected the payload before normalization. */
|
|
878
|
+
invalidOp?: string;
|
|
879
|
+
confidence: number;
|
|
880
|
+
disposition: ReviewAssistanceDisposition;
|
|
881
|
+
reasons: string[];
|
|
882
|
+
evidence?: ReviewAssistanceDecisionEvidence;
|
|
883
|
+
metadata?: Record<string, unknown>;
|
|
884
|
+
}
|
|
885
|
+
interface ReviewAssistanceIssue {
|
|
886
|
+
id: string;
|
|
887
|
+
pageNo: number;
|
|
888
|
+
category: ReviewAssistanceIssueCategory;
|
|
889
|
+
type: string;
|
|
890
|
+
severity: ReviewAssistanceIssueSeverity;
|
|
891
|
+
description: string;
|
|
892
|
+
confidence?: number;
|
|
893
|
+
refs?: string[];
|
|
894
|
+
bbox?: DoclingBBox;
|
|
895
|
+
reasons?: string[];
|
|
896
|
+
}
|
|
897
|
+
interface ReviewAssistancePageResult {
|
|
898
|
+
pageNo: number;
|
|
899
|
+
status: ReviewAssistancePageStatus;
|
|
900
|
+
decisions: ReviewAssistanceDecision[];
|
|
901
|
+
issues: ReviewAssistanceIssue[];
|
|
902
|
+
error?: {
|
|
903
|
+
message: string;
|
|
904
|
+
code?: string;
|
|
905
|
+
};
|
|
906
|
+
}
|
|
907
|
+
interface ReviewAssistanceReport {
|
|
908
|
+
schemaName: ReviewAssistanceReportSchemaName;
|
|
909
|
+
version: ReviewAssistanceReportVersion;
|
|
910
|
+
reportId: string;
|
|
911
|
+
source: {
|
|
912
|
+
doclingResult: 'result.json';
|
|
913
|
+
ocrOriginSnapshot?: 'result_ocr_origin.json';
|
|
914
|
+
originSnapshot?: 'result_review_origin.json';
|
|
915
|
+
};
|
|
916
|
+
options: {
|
|
917
|
+
enabled: true;
|
|
918
|
+
concurrency: number;
|
|
919
|
+
autoApplyThreshold: number;
|
|
920
|
+
proposalThreshold: number;
|
|
921
|
+
maxRetries: number;
|
|
922
|
+
temperature: number;
|
|
923
|
+
outputLanguage: string;
|
|
924
|
+
failurePolicy: ReviewAssistanceFailurePolicy;
|
|
925
|
+
};
|
|
926
|
+
summary: {
|
|
927
|
+
pageCount: number;
|
|
928
|
+
pagesSucceeded: number;
|
|
929
|
+
pagesFailed: number;
|
|
930
|
+
autoAppliedCount: number;
|
|
931
|
+
proposalCount: number;
|
|
932
|
+
skippedCount: number;
|
|
933
|
+
issueCount: number;
|
|
934
|
+
layoutIssueCount?: number;
|
|
935
|
+
textIntegrityIssueCount?: number;
|
|
936
|
+
};
|
|
937
|
+
pages: ReviewAssistancePageResult[];
|
|
938
|
+
}
|
|
939
|
+
interface ReviewAssistanceProgressEvent {
|
|
940
|
+
substage: ReviewAssistanceProgressSubstage;
|
|
941
|
+
status: ReviewAssistanceProgressStatus;
|
|
942
|
+
reportId: string;
|
|
943
|
+
pageNo?: number;
|
|
944
|
+
pageCount?: number;
|
|
945
|
+
completedPages?: number;
|
|
946
|
+
failedPages?: number;
|
|
947
|
+
commandCount?: number;
|
|
948
|
+
autoAppliedCount?: number;
|
|
949
|
+
proposalCount?: number;
|
|
950
|
+
message?: string;
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
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.27",
|
|
6
6
|
"description": "Document models and type definitions for heripo engine",
|
|
7
7
|
"main": "dist/index.cjs",
|
|
8
8
|
"module": "dist/index.js",
|
|
@@ -52,12 +52,12 @@
|
|
|
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
|
-
"@heripo/
|
|
60
|
-
"@heripo/
|
|
59
|
+
"@heripo/vitest-config": "0.0.0",
|
|
60
|
+
"@heripo/tsup-config": "0.0.0"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
63
|
"clean": "rimraf dist",
|