@eigenpal/cli 0.20.27 → 0.20.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/cli.js CHANGED
@@ -6684,6 +6684,14 @@ function object(shape, params) {
6684
6684
  };
6685
6685
  return new ZodObject(def);
6686
6686
  }
6687
+ function strictObject(shape, params) {
6688
+ return new ZodObject({
6689
+ type: "object",
6690
+ shape,
6691
+ catchall: never(),
6692
+ ...normalizeParams(params)
6693
+ });
6694
+ }
6687
6695
  function union(options, params) {
6688
6696
  return new ZodUnion({
6689
6697
  type: "union",
@@ -7671,6 +7679,637 @@ var require_picocolors = __commonJS(function(exports, module) {
7671
7679
  module.exports.createColors = createColors;
7672
7680
  });
7673
7681
 
7682
+ // ../types/src/client/ai-client.ts
7683
+ var REASONING_EFFORTS, ReasoningEffortSchema, ModelReasoningConfigSchema;
7684
+ var init_ai_client = __esm(() => {
7685
+ init_zod();
7686
+ REASONING_EFFORTS = [
7687
+ "none",
7688
+ "minimal",
7689
+ "low",
7690
+ "medium",
7691
+ "high",
7692
+ "xhigh",
7693
+ "max"
7694
+ ];
7695
+ ReasoningEffortSchema = _enum(REASONING_EFFORTS);
7696
+ ModelReasoningConfigSchema = object({
7697
+ supportedEfforts: array(ReasoningEffortSchema).min(1),
7698
+ defaultEffort: ReasoningEffortSchema.optional()
7699
+ }).refine((config) => config.defaultEffort === undefined || config.supportedEfforts.includes(config.defaultEffort), {
7700
+ message: "defaultEffort must be included in supportedEfforts",
7701
+ path: ["defaultEffort"]
7702
+ }).strict();
7703
+ });
7704
+
7705
+ // ../types/src/parser/native-text-quality.ts
7706
+ var NativeTextQualityStatusSchema, NativeTextQualityReasonSchema, NativeTextQualityCountsSchema, NativeTextQualityProfileSchema, NativeTextQualitySchema;
7707
+ var init_native_text_quality = __esm(() => {
7708
+ init_zod();
7709
+ NativeTextQualityStatusSchema = _enum(["clean", "empty", "suspect"]);
7710
+ NativeTextQualityReasonSchema = _enum([
7711
+ "empty",
7712
+ "replacement-character",
7713
+ "lone-surrogate",
7714
+ "forbidden-control",
7715
+ "unassigned",
7716
+ "noncharacter",
7717
+ "private-use"
7718
+ ]);
7719
+ NativeTextQualityCountsSchema = object({
7720
+ codePoints: number2().int().nonnegative(),
7721
+ nonWhitespace: number2().int().nonnegative(),
7722
+ replacement: number2().int().nonnegative(),
7723
+ loneSurrogate: number2().int().nonnegative(),
7724
+ forbiddenControl: number2().int().nonnegative(),
7725
+ unassigned: number2().int().nonnegative(),
7726
+ noncharacter: number2().int().nonnegative(),
7727
+ privateUse: number2().int().nonnegative()
7728
+ });
7729
+ NativeTextQualityProfileSchema = object({
7730
+ replacementRatio: number2().nonnegative(),
7731
+ loneSurrogateRatio: number2().nonnegative(),
7732
+ forbiddenControlRatio: number2().nonnegative(),
7733
+ unassignedRatio: number2().nonnegative(),
7734
+ noncharacterRatio: number2().nonnegative(),
7735
+ privateUseRatio: number2().nonnegative()
7736
+ });
7737
+ NativeTextQualitySchema = object({
7738
+ status: NativeTextQualityStatusSchema,
7739
+ reasons: array(NativeTextQualityReasonSchema),
7740
+ counts: NativeTextQualityCountsSchema,
7741
+ profile: NativeTextQualityProfileSchema
7742
+ });
7743
+ });
7744
+
7745
+ // ../types/src/parser/spreadsheet-evidence.ts
7746
+ var SpreadsheetCellEvidenceSchema, SpreadsheetPageEvidenceSchema;
7747
+ var init_spreadsheet_evidence = __esm(() => {
7748
+ init_zod();
7749
+ SpreadsheetCellEvidenceSchema = object({
7750
+ address: string2().describe("Original A1 cell address"),
7751
+ type: string2().describe("Excel storage type: n=number, s=string, b=boolean, e=error, d=date, z=blank. A numeric date remains type n."),
7752
+ rawValue: union([string2(), number2(), boolean2(), _null3()]).optional().describe("Stored cached value; formulas are never evaluated"),
7753
+ displayedValue: string2().describe("Value formatted using the workbook number format and date system"),
7754
+ numberFormat: string2().optional(),
7755
+ formula: string2().optional(),
7756
+ dateValue: string2().optional().describe("Calendar rendering for a valid date-formatted serial, without a timezone. Evidence of Excel formatting, not a business classification."),
7757
+ excelLeapDay: boolean2().optional().describe("True for the fictitious 1900-02-29 in the Excel 1900 date system")
7758
+ });
7759
+ SpreadsheetPageEvidenceSchema = object({
7760
+ dateSystem: _enum(["1900", "1904"]),
7761
+ declaredRange: string2().optional(),
7762
+ cells: array(SpreadsheetCellEvidenceSchema)
7763
+ });
7764
+ });
7765
+
7766
+ // ../types/src/parser/parser.ts
7767
+ function refineNativeParseModeConflicts(config, ctx) {
7768
+ if (config.parseMode === "native" && config.describeFigures === true) {
7769
+ ctx.addIssue({
7770
+ code: ZodIssueCode.custom,
7771
+ path: ["describeFigures"],
7772
+ message: 'parseMode "native" cannot be combined with describeFigures because figure captions require vision egress'
7773
+ });
7774
+ }
7775
+ }
7776
+ function isNativeLayoutCompatible(config) {
7777
+ return config.parseMode === "native" || config.parseMode === "native-or-ocr";
7778
+ }
7779
+ function refineLayoutOutputFormat(config, ctx) {
7780
+ if (config.outputFormat !== "layout")
7781
+ return;
7782
+ if (isNativeLayoutCompatible(config))
7783
+ return;
7784
+ ctx.addIssue({
7785
+ code: ZodIssueCode.custom,
7786
+ path: ["outputFormat"],
7787
+ message: LAYOUT_OUTPUT_PARSE_MODE_ERROR
7788
+ });
7789
+ }
7790
+ function mimeTypeForExtension(extension) {
7791
+ return EXTENSION_TO_MIME[extension.replace(/^\./, "").toLowerCase()];
7792
+ }
7793
+ var OFFICE_MIME_TYPES, ParserCategory, ParserTypeSchema, ParseModeSchema, PARSE_OUTPUT_FORMATS, ParseOutputFormatSchema, PageProvenanceSourceSchema, PageProvenanceSchema, ProcessingStrategySchema, LAYOUT_OUTPUT_PARSE_MODE_ERROR = 'outputFormat "layout" is native PDF-only. Set parseMode to "native" or "native-or-ocr". Omitted parseMode, OCR, vision, and nativeText: true cannot request layout.', PARSE_OUTPUT_FORMAT_DESCRIPTION = "Format for extracted text. `markdown` (default) keeps structure; `plain` is unstyled text; `djot`/`html` preserve more markup. `layout` is native-PDF spatial text with column gaps preserved as spaces. It requires `parseMode: native` or `parseMode: native-or-ocr` and a PDF — omitted parseMode and `nativeText: true` are not enough. Native mode is layout-only and fail-closed. `native-or-ocr` keeps layout text on accepted native pages and uses OCR markdown on suspect or empty pages, so the document can mix fixed-width layout and markdown. Extractor failure never falls back to another parser. Office, plaintext, and images fail. OCR/vision cannot request `layout`.", DocumentMetadataSchema, ParseUsageSchema, StructuredDocumentSchema, CoordinateUnitSchema, PointSchema, BoundingRegionSchema, PositionedTextSchema, TableCellSchema, ExtractedTableSchema, LayoutElementTypeSchema, LayoutElementSchema, PageResultSchema, ParseResultSchema, ParseOptionsSchema, ParserInputSchema, EXTENSION_TO_MIME, MIME_TO_EXTENSION;
7794
+ var init_parser = __esm(() => {
7795
+ init_zod();
7796
+ init_ai_client();
7797
+ init_native_text_quality();
7798
+ init_spreadsheet_evidence();
7799
+ OFFICE_MIME_TYPES = [
7800
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
7801
+ "application/msword",
7802
+ "application/vnd.oasis.opendocument.text",
7803
+ "application/rtf",
7804
+ "text/rtf",
7805
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
7806
+ "application/vnd.ms-excel",
7807
+ "application/vnd.ms-excel.sheet.macroenabled.12",
7808
+ "application/vnd.ms-excel.sheet.binary.macroenabled.12",
7809
+ "application/vnd.oasis.opendocument.spreadsheet",
7810
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation",
7811
+ "application/vnd.openxmlformats-officedocument.presentationml.slideshow",
7812
+ "application/vnd.ms-powerpoint.presentation.macroenabled.12",
7813
+ "application/vnd.ms-powerpoint",
7814
+ "application/vnd.oasis.opendocument.presentation",
7815
+ "message/rfc822",
7816
+ "application/vnd.ms-outlook",
7817
+ "application/epub+zip"
7818
+ ];
7819
+ ParserCategory = {
7820
+ PLAINTEXT: [
7821
+ "text/plain",
7822
+ "text/markdown",
7823
+ "text/csv",
7824
+ "text/tab-separated-values",
7825
+ "text/html",
7826
+ "text/xml",
7827
+ "application/json",
7828
+ "application/x-yaml",
7829
+ "application/toml",
7830
+ "image/svg+xml",
7831
+ "text/x-rst",
7832
+ "text/x-org",
7833
+ "application/x-latex",
7834
+ "application/x-ipynb+json",
7835
+ "application/x-bibtex",
7836
+ "application/docbook+xml",
7837
+ "application/x-fictionbook+xml"
7838
+ ],
7839
+ OFFICE: [...OFFICE_MIME_TYPES],
7840
+ DOCUMENT: [
7841
+ "application/pdf",
7842
+ "image/png",
7843
+ "image/jpeg",
7844
+ "image/webp",
7845
+ "image/tiff",
7846
+ "image/gif",
7847
+ "image/bmp"
7848
+ ]
7849
+ };
7850
+ ParserTypeSchema = _enum([
7851
+ "plaintext",
7852
+ "office",
7853
+ "llm-vision",
7854
+ "ocr"
7855
+ ]);
7856
+ ParseModeSchema = _enum(["ocr", "vision", "native", "native-or-ocr"]);
7857
+ PARSE_OUTPUT_FORMATS = ["plain", "markdown", "djot", "html", "layout"];
7858
+ ParseOutputFormatSchema = _enum(PARSE_OUTPUT_FORMATS);
7859
+ PageProvenanceSourceSchema = _enum(["native", "ocr", "vision"]);
7860
+ PageProvenanceSchema = object({
7861
+ source: PageProvenanceSourceSchema
7862
+ });
7863
+ ProcessingStrategySchema = _enum(["native", "ocr", "vision", "hybrid"]);
7864
+ DocumentMetadataSchema = object({
7865
+ filename: string2(),
7866
+ mimeType: string2(),
7867
+ size: number2().describe("File size in bytes"),
7868
+ storageRef: string2().optional().describe("Storage reference for the original file")
7869
+ });
7870
+ ParseUsageSchema = object({
7871
+ pageCount: number2(),
7872
+ processingTimeMs: number2().optional(),
7873
+ ocrPagesProcessed: number2().int().nonnegative().optional(),
7874
+ visionPagesProcessed: number2().int().nonnegative().optional(),
7875
+ visionPromptTokens: number2().int().nonnegative().optional(),
7876
+ visionCompletionTokens: number2().int().nonnegative().optional(),
7877
+ cached: boolean2().optional()
7878
+ });
7879
+ StructuredDocumentSchema = record(string2(), unknown());
7880
+ CoordinateUnitSchema = _enum(["pixel", "inch", "point", "normalized"]);
7881
+ PointSchema = object({
7882
+ x: number2(),
7883
+ y: number2()
7884
+ });
7885
+ BoundingRegionSchema = object({
7886
+ polygon: array(PointSchema).min(3),
7887
+ unit: CoordinateUnitSchema,
7888
+ pageIndex: number2()
7889
+ });
7890
+ PositionedTextSchema = object({
7891
+ text: string2(),
7892
+ confidence: number2().min(0).max(1).optional(),
7893
+ boundingRegion: BoundingRegionSchema.optional()
7894
+ });
7895
+ TableCellSchema = object({
7896
+ content: string2(),
7897
+ rowIndex: number2(),
7898
+ columnIndex: number2(),
7899
+ rowSpan: number2().default(1),
7900
+ columnSpan: number2().default(1),
7901
+ boundingRegion: BoundingRegionSchema.optional()
7902
+ });
7903
+ ExtractedTableSchema = object({
7904
+ cells: array(TableCellSchema),
7905
+ rowCount: number2(),
7906
+ columnCount: number2(),
7907
+ boundingRegion: BoundingRegionSchema.optional()
7908
+ });
7909
+ LayoutElementTypeSchema = _enum([
7910
+ "paragraph",
7911
+ "title",
7912
+ "sectionHeading",
7913
+ "pageHeader",
7914
+ "pageFooter",
7915
+ "pageNumber",
7916
+ "footnote",
7917
+ "table",
7918
+ "figure",
7919
+ "formulaBlock"
7920
+ ]);
7921
+ LayoutElementSchema = object({
7922
+ type: LayoutElementTypeSchema,
7923
+ content: string2(),
7924
+ table: ExtractedTableSchema.optional(),
7925
+ caption: string2().optional(),
7926
+ figureId: string2().optional(),
7927
+ boundingRegion: BoundingRegionSchema.optional()
7928
+ });
7929
+ PageResultSchema = object({
7930
+ spreadsheet: SpreadsheetPageEvidenceSchema.optional().describe("Opt-in original spreadsheet cell evidence"),
7931
+ pageIndex: number2().describe("0-based page index"),
7932
+ text: string2().describe("Extracted page text (markdown/HTML/plain, or spatial layout text)"),
7933
+ pageName: string2().optional().describe("Page/sheet name (e.g., Excel sheet name)"),
7934
+ layoutElements: array(LayoutElementSchema).optional().describe("Semantic layout elements in reading order"),
7935
+ words: array(PositionedTextSchema).optional().describe("Word-level positions"),
7936
+ lines: array(PositionedTextSchema).optional().describe("Line-level positions"),
7937
+ tables: array(ExtractedTableSchema).optional().describe("Extracted tables"),
7938
+ width: number2().optional().describe("Page width"),
7939
+ height: number2().optional().describe("Page height"),
7940
+ unit: CoordinateUnitSchema.optional().describe("Unit for width/height and bounding regions"),
7941
+ confidence: number2().min(0).max(1).optional().describe("Overall page confidence"),
7942
+ nativeTextQuality: NativeTextQualitySchema.optional().describe('Per-page diagnosis of native-extracted text. Reports objectively detectable anomalies (empty, U+FFFD, forbidden controls, unassigned/noncharacter code points, heavy private-use). Does not certify semantic correctness — valid-looking wrong mappings and literal "?" cannot be distinguished from legitimate text.'),
7943
+ provenance: PageProvenanceSchema.optional().describe("Which extractor produced the final text/layout on this page")
7944
+ });
7945
+ ParseResultSchema = object({
7946
+ document: DocumentMetadataSchema,
7947
+ usage: ParseUsageSchema,
7948
+ pages: array(PageResultSchema),
7949
+ text: string2().describe("Combined text from all pages"),
7950
+ parserType: ParserTypeSchema,
7951
+ parserVersion: string2().optional(),
7952
+ model: string2().optional().describe("Model used (for LLM/OCR parsers)"),
7953
+ processingStrategy: ProcessingStrategySchema.optional().describe("How this result was produced: `native` (local PDF text only), `ocr`, `vision`, or `hybrid` (native pages merged with OCR on fallback pages)."),
7954
+ structured: StructuredDocumentSchema.optional().describe("Canonical structured document with ordered blocks, regions, bounding boxes, tables, figures, and chunks when supported by the parser"),
7955
+ rawResponse: unknown().optional()
7956
+ });
7957
+ ParseOptionsSchema = object({
7958
+ includeCellMetadata: boolean2().optional(),
7959
+ outputFormat: ParseOutputFormatSchema.default("markdown"),
7960
+ ocrProvider: string2().optional().describe("OCR provider ID to use"),
7961
+ includeWordPositions: boolean2().default(false),
7962
+ includeLinePositions: boolean2().default(false),
7963
+ extractTables: boolean2().default(true),
7964
+ provider: string2().optional().describe("LLM provider ID to use"),
7965
+ model: string2().optional(),
7966
+ reasoningEffort: ReasoningEffortSchema.optional(),
7967
+ maxConcurrency: number2().min(1).max(30).default(3),
7968
+ pagesPerBatch: number2().min(1).max(20).default(5),
7969
+ pdfRenderScale: number2().min(1).max(4).default(1).describe("Scale factor used when rendering PDF pages for VLM parsing"),
7970
+ imageQuality: number2().int().min(1).max(100).default(85).describe("JPEG quality used for PDF page images sent to VLM parsing"),
7971
+ prompt: string2().optional().describe("Custom prompt for LLM-based parsing"),
7972
+ languages: array(string2()).optional().describe("OCR language hints"),
7973
+ pages: array(number2().int().min(1)).optional().describe("1-indexed pages to OCR; omit or empty to analyze the whole document"),
7974
+ tenantId: string2().optional(),
7975
+ requireCompletePages: boolean2().optional()
7976
+ });
7977
+ ParserInputSchema = object({
7978
+ data: _instanceof(Buffer).or(_instanceof(Uint8Array)),
7979
+ filename: string2(),
7980
+ mimeType: string2(),
7981
+ options: ParseOptionsSchema.optional()
7982
+ });
7983
+ EXTENSION_TO_MIME = {
7984
+ docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
7985
+ doc: "application/msword",
7986
+ odt: "application/vnd.oasis.opendocument.text",
7987
+ rtf: "application/rtf",
7988
+ xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
7989
+ xls: "application/vnd.ms-excel",
7990
+ xlsm: "application/vnd.ms-excel.sheet.macroenabled.12",
7991
+ xlsb: "application/vnd.ms-excel.sheet.binary.macroenabled.12",
7992
+ ods: "application/vnd.oasis.opendocument.spreadsheet",
7993
+ pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
7994
+ ppsx: "application/vnd.openxmlformats-officedocument.presentationml.slideshow",
7995
+ pptm: "application/vnd.ms-powerpoint.presentation.macroenabled.12",
7996
+ ppt: "application/vnd.ms-powerpoint",
7997
+ odp: "application/vnd.oasis.opendocument.presentation",
7998
+ eml: "message/rfc822",
7999
+ msg: "application/vnd.ms-outlook",
8000
+ epub: "application/epub+zip",
8001
+ pdf: "application/pdf",
8002
+ png: "image/png",
8003
+ jpg: "image/jpeg",
8004
+ jpeg: "image/jpeg",
8005
+ webp: "image/webp",
8006
+ tiff: "image/tiff",
8007
+ tif: "image/tiff",
8008
+ gif: "image/gif",
8009
+ bmp: "image/bmp",
8010
+ svg: "image/svg+xml",
8011
+ txt: "text/plain",
8012
+ md: "text/markdown",
8013
+ markdown: "text/markdown",
8014
+ csv: "text/csv",
8015
+ tsv: "text/tab-separated-values",
8016
+ html: "text/html",
8017
+ htm: "text/html",
8018
+ xml: "text/xml",
8019
+ json: "application/json",
8020
+ yaml: "application/x-yaml",
8021
+ yml: "application/x-yaml",
8022
+ toml: "application/toml",
8023
+ rst: "text/x-rst",
8024
+ org: "text/x-org",
8025
+ tex: "application/x-latex",
8026
+ latex: "application/x-latex",
8027
+ ipynb: "application/x-ipynb+json",
8028
+ bib: "application/x-bibtex",
8029
+ dbk: "application/docbook+xml",
8030
+ docbook: "application/docbook+xml",
8031
+ fb2: "application/x-fictionbook+xml",
8032
+ zip: "application/zip"
8033
+ };
8034
+ MIME_TO_EXTENSION = Object.entries(EXTENSION_TO_MIME).reduce((acc, [ext, mime]) => {
8035
+ if (!(mime in acc))
8036
+ acc[mime] = ext;
8037
+ return acc;
8038
+ }, {});
8039
+ });
8040
+
8041
+ // ../types/src/files/runtime-file-ref.ts
8042
+ var DbFileRefSchema, LegacyFileIdInputSchema, LocalFileRefSchema, S3FileRefSchema, InlineFileRefSchema, RuntimeFileRefSchema, FilePathDescriptorSchema, ResolvedProcessorFileSchema;
8043
+ var init_runtime_file_ref = __esm(() => {
8044
+ init_zod();
8045
+ DbFileRefSchema = object({
8046
+ kind: literal("file"),
8047
+ fileId: string2().describe("File ID from files table"),
8048
+ filename: string2().optional().describe("Original filename"),
8049
+ mimeType: string2().optional().describe("MIME type")
8050
+ });
8051
+ LegacyFileIdInputSchema = object({
8052
+ kind: never().optional(),
8053
+ fileId: string2().describe("File ID from files table"),
8054
+ filename: string2().optional().describe("Original filename"),
8055
+ mimeType: string2().optional().describe("MIME type")
8056
+ });
8057
+ LocalFileRefSchema = object({
8058
+ kind: literal("local"),
8059
+ path: string2().describe("Absolute path to a file on disk"),
8060
+ filename: string2().describe("Original filename"),
8061
+ mimeType: string2().describe("MIME type of the file")
8062
+ });
8063
+ S3FileRefSchema = object({
8064
+ kind: literal("s3"),
8065
+ ref: string2().describe("Storage key (suffix-only, prefix added by adapter)"),
8066
+ filename: string2().describe("Original filename"),
8067
+ mimeType: string2().describe("MIME type of the file")
8068
+ });
8069
+ InlineFileRefSchema = object({
8070
+ kind: literal("inline"),
8071
+ base64: string2().describe("Base64-encoded file bytes"),
8072
+ filename: string2().describe("Original filename"),
8073
+ mimeType: string2().describe("MIME type of the file")
8074
+ });
8075
+ RuntimeFileRefSchema = discriminatedUnion("kind", [
8076
+ DbFileRefSchema,
8077
+ LocalFileRefSchema,
8078
+ S3FileRefSchema,
8079
+ InlineFileRefSchema
8080
+ ]);
8081
+ FilePathDescriptorSchema = discriminatedUnion("kind", [
8082
+ LocalFileRefSchema,
8083
+ S3FileRefSchema,
8084
+ InlineFileRefSchema
8085
+ ]);
8086
+ ResolvedProcessorFileSchema = object({
8087
+ __eigenpalFile: literal(true),
8088
+ source: _enum(["db", "tenant-s3", "local", "inline"]),
8089
+ filename: string2().describe("Display filename for processor logs and parser routing"),
8090
+ mimeType: string2().describe("MIME type for processor routing"),
8091
+ fileId: string2().optional().describe("Legacy files-table id for db-backed handles"),
8092
+ ref: string2().optional().describe("Tenant-scoped storage key suffix for S3-backed handles"),
8093
+ path: string2().optional().describe("Local filesystem path for headless/CLI handles"),
8094
+ base64: string2().optional().describe("Base64 bytes for inline handles"),
8095
+ size: number2().int().nonnegative().optional().describe("Byte size when a file-producing step recorded it")
8096
+ }).strict();
8097
+ });
8098
+
8099
+ // ../types/src/processor/configs/document-parser.ts
8100
+ var DocumentParserInputSchema, DocumentParserOutputSchema, DocumentParserConfigSchema;
8101
+ var init_document_parser = __esm(() => {
8102
+ init_zod();
8103
+ init_ai_client();
8104
+ init_runtime_file_ref();
8105
+ init_parser();
8106
+ DocumentParserInputSchema = ResolvedProcessorFileSchema;
8107
+ DocumentParserOutputSchema = ParseResultSchema;
8108
+ DocumentParserConfigSchema = object({
8109
+ parseMode: ParseModeSchema.optional().describe('Base parser for PDF/image inputs. OCR is the default. `native` extracts PDF text only (never OCR/vision). `native-or-ocr` requests OCR when pages have detectable native-text anomalies (empty, U+FFFD, lone surrogates, forbidden controls, unassigned/noncharacter, heavy PUA). Page selection, subset egress, and billing are provider-dependent. Valid-looking wrong text and literal "?" are not flagged.'),
8110
+ ocrModel: string2().optional().describe("OCR provider ID for PDF/image parsing"),
8111
+ llmModel: string2().optional().describe("LLM provider ID for vision-based parsing"),
8112
+ llmReasoningEffort: ReasoningEffortSchema.optional().describe("Reasoning effort for vision-based parsing. Omit to use the model default."),
8113
+ figureModel: string2().optional().describe("Vision model used only for the optional figure-description pass"),
8114
+ figureReasoningEffort: ReasoningEffortSchema.optional().describe("Reasoning effort for figure descriptions. Omit to use the model default."),
8115
+ maxConcurrency: number2().min(1).max(10).default(3).describe("Max concurrent VLM batch requests"),
8116
+ pagesPerBatch: number2().min(1).max(20).default(5).describe("Number of page images per VLM request"),
8117
+ pdfRenderScale: number2().min(1).max(4).default(1).optional().describe("Scale factor used when rendering PDF pages for VLM parsing"),
8118
+ imageQuality: number2().int().min(1).max(100).default(85).optional().describe("JPEG quality used for PDF page images sent to VLM parsing"),
8119
+ prompt: string2().optional().describe("Custom extraction prompt"),
8120
+ nativeText: boolean2().default(false).optional().describe("Use native text extraction for PDFs with embedded text (no OCR/VLM)"),
8121
+ describeFigures: boolean2().optional().describe("Opt-in (default off). After text extraction, detect figure pages with a layout model and caption them with a vision model, appending `<figure>description</figure>` to their text. Skipped for plaintext. The caption vision calls are billed."),
8122
+ figureInstructions: string2().optional().describe("Custom instruction for the figure-description pass."),
8123
+ languages: array(string2()).optional().describe('OCR language hints (e.g., ["en", "de"])'),
8124
+ outputFormat: ParseOutputFormatSchema.default("markdown").optional().describe(PARSE_OUTPUT_FORMAT_DESCRIPTION),
8125
+ cache: boolean2().default(false).optional().describe("When true, reuse a prior parse for identical file bytes and parse settings. Skips OCR/vision on cache hit. Stored in tenant blob storage with no automatic expiry (TTL/lifecycle is a follow-up). Default off.")
8126
+ }).superRefine(refineNativeParseModeConflicts).superRefine(refineLayoutOutputFormat).prefault({});
8127
+ });
8128
+
8129
+ // ../types/src/processor/configs/document-parser-v2.ts
8130
+ var ImageReadingBackendSchema, ParseV2TextFormatSchema, ParseV2SettingsSchema, DocumentParserV2ConfigSchema, AiParseV2ConfigSchema, ParseV2PageSchema, ParseV2ResultSchema, DocumentParserV2InputSchema;
8131
+ var init_document_parser_v2 = __esm(() => {
8132
+ init_zod();
8133
+ init_ai_client();
8134
+ init_parser();
8135
+ init_document_parser();
8136
+ ImageReadingBackendSchema = _enum(["ocr", "vision"]);
8137
+ ParseV2TextFormatSchema = _enum(["plain", "markdown", "html", "djot"]);
8138
+ ParseV2SettingsSchema = strictObject({
8139
+ policy: strictObject({
8140
+ native: _enum(["prefer", "require", "skip"]).default("prefer").describe("Prefer local text extraction, require local text extraction with no image transcription, or skip native PDF extraction. Figure enrichment is independent."),
8141
+ imageReading: strictObject({
8142
+ order: array(ImageReadingBackendSchema).min(1).max(2).refine((v) => new Set(v).size === v.length, "Backends must be unique").default(["ocr", "vision"]).describe("Ordered allowed backends. A single entry prohibits the other backend.")
8143
+ }).prefault({})
8144
+ }).prefault({}),
8145
+ providers: strictObject({
8146
+ ocr: string2().min(1).optional().describe("Exact configured OCR provider ID. Missing pins fail; they never resolve to another provider."),
8147
+ vision: string2().min(1).optional().describe("Exact configured vision provider ID. Otherwise uses the deployment parsing default or vision role.")
8148
+ }).prefault({}),
8149
+ output: strictObject({
8150
+ textFormat: ParseV2TextFormatSchema.default("markdown"),
8151
+ includeCellMetadata: boolean2().default(false).describe("Include spreadsheet cell evidence in pages[].spreadsheet and annotate text for downstream extraction. Preserves raw/displayed values and workbook date system."),
8152
+ nativeWhitespace: _enum(["reading-order", "spatial"]).default("reading-order").describe("Spatial preserves native PDF column spacing. It does not promise OCR/vision coordinates."),
8153
+ require: array(_enum(["wordCoordinates", "tables"])).default([]).describe("Required evidence capabilities on nonblank pages. Backends unable to satisfy them are rejected.")
8154
+ }).prefault({}),
8155
+ enrichment: strictObject({
8156
+ figures: strictObject({
8157
+ enabled: boolean2().default(false),
8158
+ provider: string2().min(1).optional(),
8159
+ instructions: string2().optional(),
8160
+ reasoningEffort: ReasoningEffortSchema.optional()
8161
+ }).prefault({})
8162
+ }).prefault({}),
8163
+ advanced: strictObject({
8164
+ vision: strictObject({
8165
+ maxConcurrency: number2().int().min(1).max(10).default(3),
8166
+ pagesPerBatch: number2().int().min(1).max(20).default(5),
8167
+ renderScale: number2().min(1).max(4).default(2),
8168
+ imageQuality: number2().int().min(1).max(100).default(85),
8169
+ instructions: string2().optional().describe("Transcription instructions, never document-specific extraction/schema instructions."),
8170
+ reasoningEffort: ReasoningEffortSchema.optional()
8171
+ }).prefault({}),
8172
+ languages: array(string2().min(1)).optional(),
8173
+ allowPartial: boolean2().default(false).describe("Return unresolved pages explicitly instead of failing. Default false."),
8174
+ cache: boolean2().default(false)
8175
+ }).prefault({})
8176
+ }).superRefine((config, ctx) => {
8177
+ if (config.output.nativeWhitespace === "spatial" && config.output.textFormat !== "plain") {
8178
+ ctx.addIssue({
8179
+ code: "custom",
8180
+ path: ["output"],
8181
+ message: "Spatial native whitespace requires textFormat: plain."
8182
+ });
8183
+ }
8184
+ });
8185
+ DocumentParserV2ConfigSchema = ParseV2SettingsSchema.prefault({});
8186
+ AiParseV2ConfigSchema = ParseV2SettingsSchema.safeExtend({
8187
+ input: string2().min(1).describe("File reference or template expression for the document")
8188
+ });
8189
+ ParseV2PageSchema = PageResultSchema.extend({
8190
+ provenance: object({
8191
+ source: _enum(["native", "ocr", "vision"]),
8192
+ provider: string2().optional(),
8193
+ model: string2().optional(),
8194
+ reason: string2(),
8195
+ textFormat: ParseV2TextFormatSchema,
8196
+ capabilities: array(_enum(["wordCoordinates", "tables"]))
8197
+ }),
8198
+ status: _enum(["complete", "blank", "no-text", "unresolved"]),
8199
+ warnings: array(string2()).default([])
8200
+ });
8201
+ ParseV2ResultSchema = ParseResultSchema.omit({ rawResponse: true }).extend({
8202
+ parserVersion: literal("2"),
8203
+ pages: array(ParseV2PageSchema),
8204
+ completeness: object({
8205
+ status: _enum(["complete", "partial"]),
8206
+ unresolvedPageIndexes: array(number2().int().nonnegative())
8207
+ }),
8208
+ usage: ParseResultSchema.shape.usage.extend({
8209
+ visionPagesProcessed: number2().int().nonnegative()
8210
+ })
8211
+ });
8212
+ DocumentParserV2InputSchema = DocumentParserInputSchema;
8213
+ });
8214
+
8215
+ // ../types/src/processor/configs/parse-v2-migration.ts
8216
+ function migrateWorkflowParsers(definition, policy) {
8217
+ const warnings = [];
8218
+ const migratedSteps = [];
8219
+ function walk(value) {
8220
+ if (Array.isArray(value))
8221
+ return value.map(walk);
8222
+ if (!value || typeof value !== "object")
8223
+ return value;
8224
+ const record = value;
8225
+ const result = { ...record };
8226
+ for (const key of ["steps", "then", "else", "branches", "cases", "default"])
8227
+ if (Array.isArray(record[key]))
8228
+ result[key] = walk(record[key]);
8229
+ if (record.type !== "ai.parse")
8230
+ return result;
8231
+ const name = String(record.name ?? "parse");
8232
+ const config = record.with ?? {};
8233
+ const unknown = Object.keys(config).filter((k) => !LEGACY_FIELDS.has(k));
8234
+ if (unknown.length)
8235
+ throw new Error(`Cannot migrate '${name}': unsupported settings ${unknown.join(", ")}. Review them before migrating.`);
8236
+ const mode = config.parseMode;
8237
+ let native = mode === "native" ? "require" : mode === "native-or-ocr" || config.nativeText === true ? "prefer" : "skip";
8238
+ if (mode !== undefined && !["native", "ocr", "vision", "native-or-ocr"].includes(String(mode)))
8239
+ throw new Error(`Cannot migrate '${name}': unknown legacy parseMode '${String(mode)}'.`);
8240
+ let order = mode === "vision" || !mode && !config.ocrModel && config.llmModel ? ["vision"] : ["ocr"];
8241
+ if (policy === "auto") {
8242
+ if (native === "require" || order.length === 1)
8243
+ warnings.push(`${name}: automatic policy broadens allowed image-reading backends; review egress and cost restrictions.`);
8244
+ native = "prefer";
8245
+ order = ["ocr", "vision"];
8246
+ }
8247
+ if (config.nativeText)
8248
+ warnings.push(`${name}: v2 checks every page; legacy document-wide nativeText success is intentionally not preserved.`);
8249
+ if (config.outputFormat === "layout")
8250
+ warnings.push(`${name}: layout becomes plain text with spatial native whitespace. Image-reading pages use plain transcription without invented geometry.`);
8251
+ warnings.push(`${name}: completeness validation may expose unread content; compare downstream outputs before publishing.`);
8252
+ const next = {
8253
+ input: config.input,
8254
+ policy: { native, imageReading: { order } },
8255
+ providers: { ocr: config.ocrModel, vision: config.llmModel },
8256
+ output: {
8257
+ textFormat: config.outputFormat === "layout" ? "plain" : config.outputFormat ?? "markdown",
8258
+ nativeWhitespace: config.outputFormat === "layout" ? "spatial" : "reading-order"
8259
+ },
8260
+ enrichment: {
8261
+ figures: {
8262
+ enabled: config.describeFigures ?? false,
8263
+ provider: config.figureModel ?? (mode === "vision" ? config.llmModel : undefined),
8264
+ instructions: config.figureInstructions,
8265
+ reasoningEffort: config.figureReasoningEffort
8266
+ }
8267
+ },
8268
+ advanced: {
8269
+ cache: config.cache ?? false,
8270
+ languages: config.languages,
8271
+ vision: {
8272
+ maxConcurrency: config.maxConcurrency,
8273
+ pagesPerBatch: config.pagesPerBatch,
8274
+ renderScale: config.pdfRenderScale,
8275
+ imageQuality: config.imageQuality,
8276
+ instructions: config.prompt,
8277
+ reasoningEffort: config.llmReasoningEffort
8278
+ }
8279
+ }
8280
+ };
8281
+ result.type = "ai.parse-v2";
8282
+ result.with = AiParseV2ConfigSchema.parse(next);
8283
+ migratedSteps.push(name);
8284
+ return result;
8285
+ }
8286
+ return { definition: walk(definition), migratedSteps, warnings };
8287
+ }
8288
+ var LEGACY_FIELDS;
8289
+ var init_parse_v2_migration = __esm(() => {
8290
+ init_document_parser_v2();
8291
+ LEGACY_FIELDS = new Set([
8292
+ "input",
8293
+ "parseMode",
8294
+ "nativeText",
8295
+ "ocrModel",
8296
+ "llmModel",
8297
+ "llmReasoningEffort",
8298
+ "figureModel",
8299
+ "figureReasoningEffort",
8300
+ "describeFigures",
8301
+ "figureInstructions",
8302
+ "maxConcurrency",
8303
+ "pagesPerBatch",
8304
+ "pdfRenderScale",
8305
+ "imageQuality",
8306
+ "prompt",
8307
+ "languages",
8308
+ "outputFormat",
8309
+ "cache"
8310
+ ]);
8311
+ });
8312
+
7674
8313
  // ../../node_modules/nanoid/index.js
7675
8314
  import { webcrypto as crypto } from "node:crypto";
7676
8315
  function fillPool(bytes) {
@@ -7825,6 +8464,7 @@ var init_ids = __esm(() => {
7825
8464
  PROCESSOR_IDS = {
7826
8465
  MERGE: "builtin/merge",
7827
8466
  DOCUMENT_PARSER: "builtin/parser",
8467
+ DOCUMENT_PARSER_V2: "builtin/parser-v2",
7828
8468
  EXTRACT: "builtin/extract",
7829
8469
  SPLIT: "builtin/split",
7830
8470
  SEGMENT: "builtin/segment",
@@ -15179,29 +15819,6 @@ var init_scoped_file_ref = __esm(() => {
15179
15819
  ]);
15180
15820
  });
15181
15821
 
15182
- // ../types/src/client/ai-client.ts
15183
- var REASONING_EFFORTS, ReasoningEffortSchema, ModelReasoningConfigSchema;
15184
- var init_ai_client = __esm(() => {
15185
- init_zod();
15186
- REASONING_EFFORTS = [
15187
- "none",
15188
- "minimal",
15189
- "low",
15190
- "medium",
15191
- "high",
15192
- "xhigh",
15193
- "max"
15194
- ];
15195
- ReasoningEffortSchema = _enum(REASONING_EFFORTS);
15196
- ModelReasoningConfigSchema = object({
15197
- supportedEfforts: array(ReasoningEffortSchema).min(1),
15198
- defaultEffort: ReasoningEffortSchema.optional()
15199
- }).refine((config) => config.defaultEffort === undefined || config.supportedEfforts.includes(config.defaultEffort), {
15200
- message: "defaultEffort must be included in supportedEfforts",
15201
- path: ["defaultEffort"]
15202
- }).strict();
15203
- });
15204
-
15205
15822
  // ../types/src/processor/configs/classify.ts
15206
15823
  var ClassifyInputSchema, ClassifyLabelSchema, ClassifyConfigSchema, ClassifyOutputSchema;
15207
15824
  var init_classify = __esm(() => {
@@ -15268,402 +15885,6 @@ var init_classify_pages = __esm(() => {
15268
15885
  });
15269
15886
  });
15270
15887
 
15271
- // ../types/src/files/runtime-file-ref.ts
15272
- var DbFileRefSchema, LegacyFileIdInputSchema, LocalFileRefSchema, S3FileRefSchema, InlineFileRefSchema, RuntimeFileRefSchema, FilePathDescriptorSchema, ResolvedProcessorFileSchema;
15273
- var init_runtime_file_ref = __esm(() => {
15274
- init_zod();
15275
- DbFileRefSchema = object({
15276
- kind: literal("file"),
15277
- fileId: string2().describe("File ID from files table"),
15278
- filename: string2().optional().describe("Original filename"),
15279
- mimeType: string2().optional().describe("MIME type")
15280
- });
15281
- LegacyFileIdInputSchema = object({
15282
- kind: never().optional(),
15283
- fileId: string2().describe("File ID from files table"),
15284
- filename: string2().optional().describe("Original filename"),
15285
- mimeType: string2().optional().describe("MIME type")
15286
- });
15287
- LocalFileRefSchema = object({
15288
- kind: literal("local"),
15289
- path: string2().describe("Absolute path to a file on disk"),
15290
- filename: string2().describe("Original filename"),
15291
- mimeType: string2().describe("MIME type of the file")
15292
- });
15293
- S3FileRefSchema = object({
15294
- kind: literal("s3"),
15295
- ref: string2().describe("Storage key (suffix-only, prefix added by adapter)"),
15296
- filename: string2().describe("Original filename"),
15297
- mimeType: string2().describe("MIME type of the file")
15298
- });
15299
- InlineFileRefSchema = object({
15300
- kind: literal("inline"),
15301
- base64: string2().describe("Base64-encoded file bytes"),
15302
- filename: string2().describe("Original filename"),
15303
- mimeType: string2().describe("MIME type of the file")
15304
- });
15305
- RuntimeFileRefSchema = discriminatedUnion("kind", [
15306
- DbFileRefSchema,
15307
- LocalFileRefSchema,
15308
- S3FileRefSchema,
15309
- InlineFileRefSchema
15310
- ]);
15311
- FilePathDescriptorSchema = discriminatedUnion("kind", [
15312
- LocalFileRefSchema,
15313
- S3FileRefSchema,
15314
- InlineFileRefSchema
15315
- ]);
15316
- ResolvedProcessorFileSchema = object({
15317
- __eigenpalFile: literal(true),
15318
- source: _enum(["db", "tenant-s3", "local", "inline"]),
15319
- filename: string2().describe("Display filename for processor logs and parser routing"),
15320
- mimeType: string2().describe("MIME type for processor routing"),
15321
- fileId: string2().optional().describe("Legacy files-table id for db-backed handles"),
15322
- ref: string2().optional().describe("Tenant-scoped storage key suffix for S3-backed handles"),
15323
- path: string2().optional().describe("Local filesystem path for headless/CLI handles"),
15324
- base64: string2().optional().describe("Base64 bytes for inline handles"),
15325
- size: number2().int().nonnegative().optional().describe("Byte size when a file-producing step recorded it")
15326
- }).strict();
15327
- });
15328
-
15329
- // ../types/src/parser/native-text-quality.ts
15330
- var NativeTextQualityStatusSchema, NativeTextQualityReasonSchema, NativeTextQualityCountsSchema, NativeTextQualityProfileSchema, NativeTextQualitySchema;
15331
- var init_native_text_quality = __esm(() => {
15332
- init_zod();
15333
- NativeTextQualityStatusSchema = _enum(["clean", "empty", "suspect"]);
15334
- NativeTextQualityReasonSchema = _enum([
15335
- "empty",
15336
- "replacement-character",
15337
- "lone-surrogate",
15338
- "forbidden-control",
15339
- "unassigned",
15340
- "noncharacter",
15341
- "private-use"
15342
- ]);
15343
- NativeTextQualityCountsSchema = object({
15344
- codePoints: number2().int().nonnegative(),
15345
- nonWhitespace: number2().int().nonnegative(),
15346
- replacement: number2().int().nonnegative(),
15347
- loneSurrogate: number2().int().nonnegative(),
15348
- forbiddenControl: number2().int().nonnegative(),
15349
- unassigned: number2().int().nonnegative(),
15350
- noncharacter: number2().int().nonnegative(),
15351
- privateUse: number2().int().nonnegative()
15352
- });
15353
- NativeTextQualityProfileSchema = object({
15354
- replacementRatio: number2().nonnegative(),
15355
- loneSurrogateRatio: number2().nonnegative(),
15356
- forbiddenControlRatio: number2().nonnegative(),
15357
- unassignedRatio: number2().nonnegative(),
15358
- noncharacterRatio: number2().nonnegative(),
15359
- privateUseRatio: number2().nonnegative()
15360
- });
15361
- NativeTextQualitySchema = object({
15362
- status: NativeTextQualityStatusSchema,
15363
- reasons: array(NativeTextQualityReasonSchema),
15364
- counts: NativeTextQualityCountsSchema,
15365
- profile: NativeTextQualityProfileSchema
15366
- });
15367
- });
15368
-
15369
- // ../types/src/parser/parser.ts
15370
- function refineNativeParseModeConflicts(config, ctx) {
15371
- if (config.parseMode === "native" && config.describeFigures === true) {
15372
- ctx.addIssue({
15373
- code: ZodIssueCode.custom,
15374
- path: ["describeFigures"],
15375
- message: 'parseMode "native" cannot be combined with describeFigures because figure captions require vision egress'
15376
- });
15377
- }
15378
- }
15379
- function isNativeLayoutCompatible(config) {
15380
- return config.parseMode === "native" || config.parseMode === "native-or-ocr";
15381
- }
15382
- function refineLayoutOutputFormat(config, ctx) {
15383
- if (config.outputFormat !== "layout")
15384
- return;
15385
- if (isNativeLayoutCompatible(config))
15386
- return;
15387
- ctx.addIssue({
15388
- code: ZodIssueCode.custom,
15389
- path: ["outputFormat"],
15390
- message: LAYOUT_OUTPUT_PARSE_MODE_ERROR
15391
- });
15392
- }
15393
- function mimeTypeForExtension(extension) {
15394
- return EXTENSION_TO_MIME[extension.replace(/^\./, "").toLowerCase()];
15395
- }
15396
- var OFFICE_MIME_TYPES, ParserCategory, ParserTypeSchema, ParseModeSchema, PARSE_OUTPUT_FORMATS, ParseOutputFormatSchema, PageProvenanceSourceSchema, PageProvenanceSchema, ProcessingStrategySchema, LAYOUT_OUTPUT_PARSE_MODE_ERROR = 'outputFormat "layout" is native PDF-only. Set parseMode to "native" or "native-or-ocr". Omitted parseMode, OCR, vision, and nativeText: true cannot request layout.', PARSE_OUTPUT_FORMAT_DESCRIPTION = "Format for extracted text. `markdown` (default) keeps structure; `plain` is unstyled text; `djot`/`html` preserve more markup. `layout` is native-PDF spatial text with column gaps preserved as spaces. It requires `parseMode: native` or `parseMode: native-or-ocr` and a PDF — omitted parseMode and `nativeText: true` are not enough. Native mode is layout-only and fail-closed. `native-or-ocr` keeps layout text on accepted native pages and uses OCR markdown on suspect or empty pages, so the document can mix fixed-width layout and markdown. Extractor failure never falls back to another parser. Office, plaintext, and images fail. OCR/vision cannot request `layout`.", DocumentMetadataSchema, ParseUsageSchema, StructuredDocumentSchema, CoordinateUnitSchema, PointSchema, BoundingRegionSchema, PositionedTextSchema, TableCellSchema, ExtractedTableSchema, LayoutElementTypeSchema, LayoutElementSchema, PageResultSchema, ParseResultSchema, ParseOptionsSchema, ParserInputSchema, EXTENSION_TO_MIME, MIME_TO_EXTENSION;
15397
- var init_parser = __esm(() => {
15398
- init_zod();
15399
- init_ai_client();
15400
- init_native_text_quality();
15401
- OFFICE_MIME_TYPES = [
15402
- "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
15403
- "application/msword",
15404
- "application/vnd.oasis.opendocument.text",
15405
- "application/rtf",
15406
- "text/rtf",
15407
- "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
15408
- "application/vnd.ms-excel",
15409
- "application/vnd.ms-excel.sheet.macroenabled.12",
15410
- "application/vnd.ms-excel.sheet.binary.macroenabled.12",
15411
- "application/vnd.oasis.opendocument.spreadsheet",
15412
- "application/vnd.openxmlformats-officedocument.presentationml.presentation",
15413
- "application/vnd.openxmlformats-officedocument.presentationml.slideshow",
15414
- "application/vnd.ms-powerpoint.presentation.macroenabled.12",
15415
- "application/vnd.ms-powerpoint",
15416
- "application/vnd.oasis.opendocument.presentation",
15417
- "message/rfc822",
15418
- "application/vnd.ms-outlook",
15419
- "application/epub+zip"
15420
- ];
15421
- ParserCategory = {
15422
- PLAINTEXT: [
15423
- "text/plain",
15424
- "text/markdown",
15425
- "text/csv",
15426
- "text/tab-separated-values",
15427
- "text/html",
15428
- "text/xml",
15429
- "application/json",
15430
- "application/x-yaml",
15431
- "application/toml",
15432
- "image/svg+xml",
15433
- "text/x-rst",
15434
- "text/x-org",
15435
- "application/x-latex",
15436
- "application/x-ipynb+json",
15437
- "application/x-bibtex",
15438
- "application/docbook+xml",
15439
- "application/x-fictionbook+xml"
15440
- ],
15441
- OFFICE: [...OFFICE_MIME_TYPES],
15442
- DOCUMENT: [
15443
- "application/pdf",
15444
- "image/png",
15445
- "image/jpeg",
15446
- "image/webp",
15447
- "image/tiff",
15448
- "image/gif",
15449
- "image/bmp"
15450
- ]
15451
- };
15452
- ParserTypeSchema = _enum([
15453
- "plaintext",
15454
- "office",
15455
- "llm-vision",
15456
- "ocr"
15457
- ]);
15458
- ParseModeSchema = _enum(["ocr", "vision", "native", "native-or-ocr"]);
15459
- PARSE_OUTPUT_FORMATS = ["plain", "markdown", "djot", "html", "layout"];
15460
- ParseOutputFormatSchema = _enum(PARSE_OUTPUT_FORMATS);
15461
- PageProvenanceSourceSchema = _enum(["native", "ocr", "vision"]);
15462
- PageProvenanceSchema = object({
15463
- source: PageProvenanceSourceSchema
15464
- });
15465
- ProcessingStrategySchema = _enum(["native", "ocr", "vision", "hybrid"]);
15466
- DocumentMetadataSchema = object({
15467
- filename: string2(),
15468
- mimeType: string2(),
15469
- size: number2().describe("File size in bytes"),
15470
- storageRef: string2().optional().describe("Storage reference for the original file")
15471
- });
15472
- ParseUsageSchema = object({
15473
- pageCount: number2(),
15474
- processingTimeMs: number2().optional(),
15475
- ocrPagesProcessed: number2().int().nonnegative().optional(),
15476
- cached: boolean2().optional()
15477
- });
15478
- StructuredDocumentSchema = record(string2(), unknown());
15479
- CoordinateUnitSchema = _enum(["pixel", "inch", "point", "normalized"]);
15480
- PointSchema = object({
15481
- x: number2(),
15482
- y: number2()
15483
- });
15484
- BoundingRegionSchema = object({
15485
- polygon: array(PointSchema).min(3),
15486
- unit: CoordinateUnitSchema,
15487
- pageIndex: number2()
15488
- });
15489
- PositionedTextSchema = object({
15490
- text: string2(),
15491
- confidence: number2().min(0).max(1).optional(),
15492
- boundingRegion: BoundingRegionSchema.optional()
15493
- });
15494
- TableCellSchema = object({
15495
- content: string2(),
15496
- rowIndex: number2(),
15497
- columnIndex: number2(),
15498
- rowSpan: number2().default(1),
15499
- columnSpan: number2().default(1),
15500
- boundingRegion: BoundingRegionSchema.optional()
15501
- });
15502
- ExtractedTableSchema = object({
15503
- cells: array(TableCellSchema),
15504
- rowCount: number2(),
15505
- columnCount: number2(),
15506
- boundingRegion: BoundingRegionSchema.optional()
15507
- });
15508
- LayoutElementTypeSchema = _enum([
15509
- "paragraph",
15510
- "title",
15511
- "sectionHeading",
15512
- "pageHeader",
15513
- "pageFooter",
15514
- "pageNumber",
15515
- "footnote",
15516
- "table",
15517
- "figure",
15518
- "formulaBlock"
15519
- ]);
15520
- LayoutElementSchema = object({
15521
- type: LayoutElementTypeSchema,
15522
- content: string2(),
15523
- table: ExtractedTableSchema.optional(),
15524
- caption: string2().optional(),
15525
- figureId: string2().optional(),
15526
- boundingRegion: BoundingRegionSchema.optional()
15527
- });
15528
- PageResultSchema = object({
15529
- pageIndex: number2().describe("0-based page index"),
15530
- text: string2().describe("Extracted page text (markdown/HTML/plain, or spatial layout text)"),
15531
- pageName: string2().optional().describe("Page/sheet name (e.g., Excel sheet name)"),
15532
- layoutElements: array(LayoutElementSchema).optional().describe("Semantic layout elements in reading order"),
15533
- words: array(PositionedTextSchema).optional().describe("Word-level positions"),
15534
- lines: array(PositionedTextSchema).optional().describe("Line-level positions"),
15535
- tables: array(ExtractedTableSchema).optional().describe("Extracted tables"),
15536
- width: number2().optional().describe("Page width"),
15537
- height: number2().optional().describe("Page height"),
15538
- unit: CoordinateUnitSchema.optional().describe("Unit for width/height and bounding regions"),
15539
- confidence: number2().min(0).max(1).optional().describe("Overall page confidence"),
15540
- nativeTextQuality: NativeTextQualitySchema.optional().describe('Per-page diagnosis of native-extracted text. Reports objectively detectable anomalies (empty, U+FFFD, forbidden controls, unassigned/noncharacter code points, heavy private-use). Does not certify semantic correctness — valid-looking wrong mappings and literal "?" cannot be distinguished from legitimate text.'),
15541
- provenance: PageProvenanceSchema.optional().describe("Which extractor produced the final text/layout on this page")
15542
- });
15543
- ParseResultSchema = object({
15544
- document: DocumentMetadataSchema,
15545
- usage: ParseUsageSchema,
15546
- pages: array(PageResultSchema),
15547
- text: string2().describe("Combined text from all pages"),
15548
- parserType: ParserTypeSchema,
15549
- parserVersion: string2().optional(),
15550
- model: string2().optional().describe("Model used (for LLM/OCR parsers)"),
15551
- processingStrategy: ProcessingStrategySchema.optional().describe("How this result was produced: `native` (local PDF text only), `ocr`, `vision`, or `hybrid` (native pages merged with OCR on fallback pages)."),
15552
- structured: StructuredDocumentSchema.optional().describe("Canonical structured document with ordered blocks, regions, bounding boxes, tables, figures, and chunks when supported by the parser"),
15553
- rawResponse: unknown().optional()
15554
- });
15555
- ParseOptionsSchema = object({
15556
- outputFormat: ParseOutputFormatSchema.default("markdown"),
15557
- ocrProvider: string2().optional().describe("OCR provider ID to use"),
15558
- includeWordPositions: boolean2().default(false),
15559
- includeLinePositions: boolean2().default(false),
15560
- extractTables: boolean2().default(true),
15561
- provider: string2().optional().describe("LLM provider ID to use"),
15562
- model: string2().optional(),
15563
- reasoningEffort: ReasoningEffortSchema.optional(),
15564
- maxConcurrency: number2().min(1).max(30).default(3),
15565
- pagesPerBatch: number2().min(1).max(20).default(5),
15566
- pdfRenderScale: number2().min(1).max(4).default(1).describe("Scale factor used when rendering PDF pages for VLM parsing"),
15567
- imageQuality: number2().int().min(1).max(100).default(85).describe("JPEG quality used for PDF page images sent to VLM parsing"),
15568
- prompt: string2().optional().describe("Custom prompt for LLM-based parsing"),
15569
- languages: array(string2()).optional().describe("OCR language hints"),
15570
- pages: array(number2().int().min(1)).optional().describe("1-indexed pages to OCR; omit or empty to analyze the whole document"),
15571
- tenantId: string2().optional()
15572
- });
15573
- ParserInputSchema = object({
15574
- data: _instanceof(Buffer).or(_instanceof(Uint8Array)),
15575
- filename: string2(),
15576
- mimeType: string2(),
15577
- options: ParseOptionsSchema.optional()
15578
- });
15579
- EXTENSION_TO_MIME = {
15580
- docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
15581
- doc: "application/msword",
15582
- odt: "application/vnd.oasis.opendocument.text",
15583
- rtf: "application/rtf",
15584
- xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
15585
- xls: "application/vnd.ms-excel",
15586
- xlsm: "application/vnd.ms-excel.sheet.macroenabled.12",
15587
- xlsb: "application/vnd.ms-excel.sheet.binary.macroenabled.12",
15588
- ods: "application/vnd.oasis.opendocument.spreadsheet",
15589
- pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
15590
- ppsx: "application/vnd.openxmlformats-officedocument.presentationml.slideshow",
15591
- pptm: "application/vnd.ms-powerpoint.presentation.macroenabled.12",
15592
- ppt: "application/vnd.ms-powerpoint",
15593
- odp: "application/vnd.oasis.opendocument.presentation",
15594
- eml: "message/rfc822",
15595
- msg: "application/vnd.ms-outlook",
15596
- epub: "application/epub+zip",
15597
- pdf: "application/pdf",
15598
- png: "image/png",
15599
- jpg: "image/jpeg",
15600
- jpeg: "image/jpeg",
15601
- webp: "image/webp",
15602
- tiff: "image/tiff",
15603
- tif: "image/tiff",
15604
- gif: "image/gif",
15605
- bmp: "image/bmp",
15606
- svg: "image/svg+xml",
15607
- txt: "text/plain",
15608
- md: "text/markdown",
15609
- markdown: "text/markdown",
15610
- csv: "text/csv",
15611
- tsv: "text/tab-separated-values",
15612
- html: "text/html",
15613
- htm: "text/html",
15614
- xml: "text/xml",
15615
- json: "application/json",
15616
- yaml: "application/x-yaml",
15617
- yml: "application/x-yaml",
15618
- toml: "application/toml",
15619
- rst: "text/x-rst",
15620
- org: "text/x-org",
15621
- tex: "application/x-latex",
15622
- latex: "application/x-latex",
15623
- ipynb: "application/x-ipynb+json",
15624
- bib: "application/x-bibtex",
15625
- dbk: "application/docbook+xml",
15626
- docbook: "application/docbook+xml",
15627
- fb2: "application/x-fictionbook+xml",
15628
- zip: "application/zip"
15629
- };
15630
- MIME_TO_EXTENSION = Object.entries(EXTENSION_TO_MIME).reduce((acc, [ext, mime]) => {
15631
- if (!(mime in acc))
15632
- acc[mime] = ext;
15633
- return acc;
15634
- }, {});
15635
- });
15636
-
15637
- // ../types/src/processor/configs/document-parser.ts
15638
- var DocumentParserInputSchema, DocumentParserOutputSchema, DocumentParserConfigSchema;
15639
- var init_document_parser = __esm(() => {
15640
- init_zod();
15641
- init_ai_client();
15642
- init_runtime_file_ref();
15643
- init_parser();
15644
- DocumentParserInputSchema = ResolvedProcessorFileSchema;
15645
- DocumentParserOutputSchema = ParseResultSchema;
15646
- DocumentParserConfigSchema = object({
15647
- parseMode: ParseModeSchema.optional().describe('Base parser for PDF/image inputs. OCR is the default. `native` extracts PDF text only (never OCR/vision). `native-or-ocr` requests OCR when pages have detectable native-text anomalies (empty, U+FFFD, lone surrogates, forbidden controls, unassigned/noncharacter, heavy PUA). Page selection, subset egress, and billing are provider-dependent. Valid-looking wrong text and literal "?" are not flagged.'),
15648
- ocrModel: string2().optional().describe("OCR provider ID for PDF/image parsing"),
15649
- llmModel: string2().optional().describe("LLM provider ID for vision-based parsing"),
15650
- llmReasoningEffort: ReasoningEffortSchema.optional().describe("Reasoning effort for vision-based parsing. Omit to use the model default."),
15651
- figureModel: string2().optional().describe("Vision model used only for the optional figure-description pass"),
15652
- figureReasoningEffort: ReasoningEffortSchema.optional().describe("Reasoning effort for figure descriptions. Omit to use the model default."),
15653
- maxConcurrency: number2().min(1).max(10).default(3).describe("Max concurrent VLM batch requests"),
15654
- pagesPerBatch: number2().min(1).max(20).default(5).describe("Number of page images per VLM request"),
15655
- pdfRenderScale: number2().min(1).max(4).default(1).optional().describe("Scale factor used when rendering PDF pages for VLM parsing"),
15656
- imageQuality: number2().int().min(1).max(100).default(85).optional().describe("JPEG quality used for PDF page images sent to VLM parsing"),
15657
- prompt: string2().optional().describe("Custom extraction prompt"),
15658
- nativeText: boolean2().default(false).optional().describe("Use native text extraction for PDFs with embedded text (no OCR/VLM)"),
15659
- describeFigures: boolean2().optional().describe("Opt-in (default off). After text extraction, detect figure pages with a layout model and caption them with a vision model, appending `<figure>description</figure>` to their text. Skipped for plaintext. The caption vision calls are billed."),
15660
- figureInstructions: string2().optional().describe("Custom instruction for the figure-description pass."),
15661
- languages: array(string2()).optional().describe('OCR language hints (e.g., ["en", "de"])'),
15662
- outputFormat: ParseOutputFormatSchema.default("markdown").optional().describe(PARSE_OUTPUT_FORMAT_DESCRIPTION),
15663
- cache: boolean2().default(false).optional().describe("When true, reuse a prior parse for identical file bytes and parse settings. Skips OCR/vision on cache hit. Stored in tenant blob storage with no automatic expiry (TTL/lifecycle is a follow-up). Default off.")
15664
- }).superRefine(refineNativeParseModeConflicts).superRefine(refineLayoutOutputFormat).prefault({});
15665
- });
15666
-
15667
15888
  // ../types/src/processor/configs/extract.ts
15668
15889
  var ExtractInputSchema, ExtractOutputSchema, ExtractConfigSchema;
15669
15890
  var init_extract = __esm(() => {
@@ -16044,6 +16265,7 @@ var XLSX_TO_JSON_DEFAULT_LIMITS, A1_RANGE_RE, XlsxToJsonColumnSchema, XlsxToJson
16044
16265
  var init_xlsx_to_json = __esm(() => {
16045
16266
  init_zod();
16046
16267
  init_runtime_file_ref();
16268
+ init_spreadsheet_evidence();
16047
16269
  XLSX_TO_JSON_DEFAULT_LIMITS = {
16048
16270
  maxInputBytes: 50 * 1024 * 1024,
16049
16271
  maxRows: 1e5,
@@ -16082,6 +16304,8 @@ var init_xlsx_to_json = __esm(() => {
16082
16304
  XlsxToJsonInputSchema = ResolvedProcessorFileSchema;
16083
16305
  XlsxToJsonSheetMetaSchema = object({
16084
16306
  name: string2().describe("Selected sheet name"),
16307
+ declaredRange: string2().optional().describe("Worksheet declared extent before empty trailing rows/columns were removed"),
16308
+ dateSystem: _enum(["1900", "1904"]).optional().describe("Workbook Excel date system"),
16085
16309
  index: number2().int().min(0).describe("0-based sheet index in the workbook"),
16086
16310
  range: string2().describe("Effective rectangular A1 range that was read"),
16087
16311
  rowCount: number2().int().min(0).describe("Number of data rows returned in rows"),
@@ -16096,15 +16320,20 @@ var init_xlsx_to_json = __esm(() => {
16096
16320
  column: number2().int().optional().describe("0-based worksheet column when applicable")
16097
16321
  });
16098
16322
  XlsxToJsonOutputSchema = object({
16323
+ cellMetadata: array(SpreadsheetCellEvidenceSchema.extend({
16324
+ key: string2(),
16325
+ outputRowIndex: number2().int().nonnegative()
16326
+ })).optional().describe("Evidence for nonblank projected data cells, linked to rows by outputRowIndex and key. Present when includeCellMetadata is true."),
16099
16327
  rows: array(record(string2(), unknown())).describe("Array of row objects (first row = headers as keys unless headerRow is false)"),
16100
16328
  fileId: string2().optional().describe("File ID of stored CSV when outputCsv is true"),
16101
- sheet: XlsxToJsonSheetMetaSchema.optional().describe("Selected sheet metadata after projection. Present only when includeMetadata is true."),
16102
- diagnostics: array(XlsxToJsonDiagnosticSchema).optional().describe("Non-fatal warnings collected while reading the sheet. Present only when includeMetadata is true. Warnings are still logged when metadata is omitted.")
16329
+ sheet: XlsxToJsonSheetMetaSchema.optional().describe("Selected sheet metadata after projection. Present when includeMetadata or includeCellMetadata is true."),
16330
+ diagnostics: array(XlsxToJsonDiagnosticSchema).optional().describe("Non-fatal warnings collected while reading the sheet. Present when includeMetadata or includeCellMetadata is true. Warnings are still logged when metadata is omitted.")
16103
16331
  });
16104
16332
  XlsxToJsonConfigSchema = object({
16105
16333
  sheet: union([number2().int().min(0), string2()]).optional().describe("Sheet to read: 0-based index or exact sheet name. Omit for the first sheet."),
16106
- outputCsv: boolean2().default(false).optional().describe("If true, also write CSV to storage and include fileId. Zero-config uses the historical full-sheet SheetJS CSV. When columns, range, headerRow, valueMode, blankCells, or blankRows are set, CSV matches that projection."),
16107
- includeMetadata: boolean2().default(false).optional().describe("If true, include sheet metadata and diagnostics in the step output. Omit to keep output as rows (and fileId when outputCsv is true). Warnings are still logged when this is false."),
16334
+ outputCsv: boolean2().default(false).optional().describe("If true, also write CSV to storage and include fileId. Zero-config uses SheetJS CSV of the effective sheet extent, excluding empty trailing rows and columns. When columns, range, headerRow, valueMode, blankCells, or blankRows are set, CSV matches that projection."),
16335
+ includeCellMetadata: boolean2().default(false).optional().describe("Include original cell address, type, raw/displayed value, number format and date rendering. Also includes sheet metadata with the workbook date system. Does not classify identifiers or clean names."),
16336
+ includeMetadata: boolean2().default(false).optional().describe("If true, include sheet metadata and diagnostics in the step output. includeCellMetadata also enables these. Omit to keep output as rows (and fileId when outputCsv is true). Warnings are still logged when this is false."),
16108
16337
  outputFilename: string2().optional().describe("Output CSV filename when outputCsv is true"),
16109
16338
  headerRow: union([literal(false), number2().int().min(1)]).optional().describe("Header row: a positive 1-based Excel row, or false to keep the first effective row as data. Omit to use the first effective row as the header. When range is set and this is omitted, the first range row is the header."),
16110
16339
  columns: array(XlsxToJsonColumnSchema).min(1).optional().superRefine(refineUniqueOutputKeys).describe("Ordered output columns. Each item needs a key and exactly one source: index (0-based absolute column) or header (exact displayed header text). Named header sources require a header row. Omit to keep every column in the effective range."),
@@ -16127,6 +16356,7 @@ var init_xlsx_to_json = __esm(() => {
16127
16356
  var PROCESSOR_SCHEMAS;
16128
16357
  var init_configs = __esm(() => {
16129
16358
  init_ids();
16359
+ init_document_parser_v2();
16130
16360
  init_classify();
16131
16361
  init_classify_pages();
16132
16362
  init_document_parser();
@@ -16141,6 +16371,7 @@ var init_configs = __esm(() => {
16141
16371
  init_classify();
16142
16372
  init_classify_pages();
16143
16373
  init_document_parser();
16374
+ init_document_parser_v2();
16144
16375
  init_extract();
16145
16376
  init_json_to_xlsx();
16146
16377
  init_merge();
@@ -16150,6 +16381,12 @@ var init_configs = __esm(() => {
16150
16381
  init_template();
16151
16382
  init_xlsx_to_json();
16152
16383
  PROCESSOR_SCHEMAS = {
16384
+ [PROCESSOR_IDS.DOCUMENT_PARSER_V2]: {
16385
+ id: PROCESSOR_IDS.DOCUMENT_PARSER_V2,
16386
+ inputSchema: DocumentParserV2InputSchema,
16387
+ outputSchema: ParseV2ResultSchema,
16388
+ configSchema: DocumentParserV2ConfigSchema
16389
+ },
16153
16390
  [PROCESSOR_IDS.EXTRACT]: {
16154
16391
  id: PROCESSOR_IDS.EXTRACT,
16155
16392
  inputSchema: ExtractInputSchema,
@@ -53805,7 +54042,7 @@ function describeUnsupportedType(nodeType) {
53805
54042
  function compileTypedScript(opts) {
53806
54043
  let ast;
53807
54044
  try {
53808
- ast = import_parser4.parse(opts.source, {
54045
+ ast = import_parser5.parse(opts.source, {
53809
54046
  sourceType: "script",
53810
54047
  plugins: ["typescript"],
53811
54048
  ranges: true
@@ -54058,9 +54295,9 @@ function stripCommentsAndStrings(s) {
54058
54295
  out = out.replace(/`(\\.|[^`\\])*`/g, "``");
54059
54296
  return out;
54060
54297
  }
54061
- var import_parser4, import_sucrase, EVALUATOR_FN_NAME = "scoreScript", EVALUATOR_PARAM_NAMES, TRANSFORM_FN_NAME = "script";
54298
+ var import_parser5, import_sucrase, EVALUATOR_FN_NAME = "scoreScript", EVALUATOR_PARAM_NAMES, TRANSFORM_FN_NAME = "script";
54062
54299
  var init_compile = __esm(() => {
54063
- import_parser4 = __toESM(require_lib(), 1);
54300
+ import_parser5 = __toESM(require_lib(), 1);
54064
54301
  import_sucrase = __toESM(require_dist3(), 1);
54065
54302
  EVALUATOR_PARAM_NAMES = ["expected", "actual"];
54066
54303
  });
@@ -54207,6 +54444,7 @@ var init_steps = __esm(() => {
54207
54444
  init_retry();
54208
54445
  AI_STEP_TYPES = [
54209
54446
  "ai.parse",
54447
+ "ai.parse-v2",
54210
54448
  "ai.extract",
54211
54449
  "ai.split",
54212
54450
  "ai.segment",
@@ -54381,6 +54619,7 @@ var init_step_configs = __esm(() => {
54381
54619
  init_email_servers();
54382
54620
  init_human_review();
54383
54621
  init_parser();
54622
+ init_document_parser_v2();
54384
54623
  init_json_to_xlsx();
54385
54624
  init_xlsx_to_json();
54386
54625
  init_typed_script();
@@ -55145,10 +55384,19 @@ var init_step_configs = __esm(() => {
55145
55384
  });
55146
55385
  ControlFailOutputSchema = never().describe("control.fail never produces output — it terminates the workflow when triggered.");
55147
55386
  STEP_SCHEMAS = {
55387
+ "ai.parse-v2": {
55388
+ type: "ai.parse-v2",
55389
+ category: "ai",
55390
+ name: "Parse Document",
55391
+ description: "Automatically read native, scanned, and mixed documents with capability-aware OCR/vision fallback and explicit completeness.",
55392
+ configSchema: AiParseV2ConfigSchema,
55393
+ outputSchema: ParseV2ResultSchema,
55394
+ configInWith: true
55395
+ },
55148
55396
  "ai.parse": {
55149
55397
  type: "ai.parse",
55150
55398
  category: "ai",
55151
- name: "Parse Document",
55399
+ name: "Parse Document — legacy",
55152
55400
  description: "Extract text from documents (PDF, DOCX, images) using native extraction, OCR, or vision models",
55153
55401
  configSchema: AiParseConfigSchema,
55154
55402
  outputSchema: AiParseOutputSchema,
@@ -56976,6 +57224,8 @@ var init_src = __esm(() => {
56976
57224
  init_execution_row();
56977
57225
  init_run_expand();
56978
57226
  init_execution_tags();
57227
+ init_document_parser_v2();
57228
+ init_parse_v2_migration();
56979
57229
  init_validation();
56980
57230
  init_workflow2();
56981
57231
  init_file_source();
@@ -56985,6 +57235,7 @@ var init_src = __esm(() => {
56985
57235
  init_email_servers();
56986
57236
  init_webhooks();
56987
57237
  init_typed_script();
57238
+ init_spreadsheet_evidence();
56988
57239
  });
56989
57240
 
56990
57241
  // node_modules/yaml/dist/nodes/identity.js
@@ -207035,7 +207286,7 @@ import { fileURLToPath as fileURLToPath8 } from "url";
207035
207286
  // package.json
207036
207287
  var package_default = {
207037
207288
  name: "@eigenpal/cli",
207038
- version: "0.20.27",
207289
+ version: "0.20.28",
207039
207290
  description: "Eigenpal CLI — author and run document workflows from your terminal. Agent-ready.",
207040
207291
  keywords: [
207041
207292
  "eigenpal",
@@ -243863,6 +244114,20 @@ var COLUMNS = [
243863
244114
  ];
243864
244115
  function registerModelsCommands(program) {
243865
244116
  const models = program.command("models").description("Inspect models and providers configured for the current tenant environment (text, vision, OCR).");
244117
+ addJsonFlag(withBaseUrl(models.command("parser-readiness").description("Inspect deployment-approved ai.parse-v2 defaults. Catalog state only; document smoke tests are required for live readiness."))).action(action(async (opts) => {
244118
+ const config = resolveConfig(opts);
244119
+ requireApiKey(config);
244120
+ const result = await new ApiClient(config).get("/api/v1/parsing/readiness");
244121
+ if (opts.json)
244122
+ console.log(JSON.stringify(result));
244123
+ else {
244124
+ console.log(`Image reading: ${result.imageReading}
244125
+ OCR: ${result.providers.ocr ?? "none"}
244126
+ Vision: ${result.providers.vision ?? "none"}`);
244127
+ for (const warning of result.warnings)
244128
+ console.error(warning);
244129
+ }
244130
+ }));
243866
244131
  addJsonFlag(withBaseUrl(models.command("list").description("List configured text, vision, and OCR models. This is a catalog inventory from the server, not a live provider health probe. `health` is `configured` or `unconfigured` from local credentials. Pair with `--json` for scripting.").option("--capability <kind>", "Filter to `text`, `vision`, or `ocr` (matches the API `capability` query).").addHelpText("after", `
243867
244132
  Health
243868
244133
  configured Credentials for this model are present in the environment.
@@ -247117,6 +247382,36 @@ async function deleteWorkflowFolder(pathOrId, opts) {
247117
247382
  success(`Deleted folder ${ui.bold(pathLabel)}`);
247118
247383
  }
247119
247384
 
247385
+ // src/commands/workflow/migrate-parser.ts
247386
+ init_src();
247387
+ import { readFile as readFile4, writeFile as writeFile3 } from "node:fs/promises";
247388
+ import { resolve as resolve9 } from "node:path";
247389
+ function registerParserMigrationCommand(workflow) {
247390
+ workflow.command("migrate-parser <file>").description("Write a reviewable ai.parse-v2 workflow migration to a new file. Never pushes or changes the source.").requiredOption("--policy <policy>", "preserve backend restrictions, or auto to adopt automatic native/OCR/vision parsing").requiredOption("--out <file>", "New YAML output file (must not already exist)").option("--json", "Emit migration summary as JSON").action(action(async (file, options) => {
247391
+ if (options.policy !== "preserve" && options.policy !== "auto")
247392
+ throw new Error("--policy must be preserve or auto");
247393
+ if (resolve9(file) === resolve9(options.out))
247394
+ throw new Error("Migration output must differ from the source");
247395
+ const source = $parse(await readFile4(file, "utf8"));
247396
+ if (!source || typeof source !== "object" || Array.isArray(source))
247397
+ throw new Error("Expected a workflow YAML object");
247398
+ const migration = migrateWorkflowParsers(source, options.policy);
247399
+ await writeFile3(options.out, $stringify(migration.definition), { flag: "wx" });
247400
+ const summary = {
247401
+ out: resolve9(options.out),
247402
+ migratedSteps: migration.migratedSteps,
247403
+ warnings: migration.warnings
247404
+ };
247405
+ if (options.json)
247406
+ console.log(JSON.stringify(summary));
247407
+ else {
247408
+ console.log(`Wrote ${summary.out}; migrated ${summary.migratedSteps.length} parser step(s). Review and test before publishing.`);
247409
+ for (const warning of summary.warnings)
247410
+ console.error(warning);
247411
+ }
247412
+ }));
247413
+ }
247414
+
247120
247415
  // src/commands/workflow/step-exec.ts
247121
247416
  init_src();
247122
247417
  var UNSUPPORTED_TYPE_EXIT = 2;
@@ -247146,7 +247441,7 @@ function registerStepExecCommands(workflow) {
247146
247441
  // src/commands/workflow/templates.ts
247147
247442
  init_src();
247148
247443
  import { existsSync as existsSync20, promises as fs20 } from "node:fs";
247149
- import { basename as basename4, resolve as resolve9 } from "node:path";
247444
+ import { basename as basename4, resolve as resolve10 } from "node:path";
247150
247445
  function buildClient5(opts) {
247151
247446
  const config = resolveConfig(opts);
247152
247447
  requireApiKey(config);
@@ -247158,11 +247453,11 @@ function printJson5(value) {
247158
247453
  async function readJsonFixtureFile(fixturePath) {
247159
247454
  let raw;
247160
247455
  try {
247161
- raw = await fs20.readFile(resolve9(fixturePath), "utf8");
247456
+ raw = await fs20.readFile(resolve10(fixturePath), "utf8");
247162
247457
  } catch (err) {
247163
247458
  const code = err && typeof err === "object" && "code" in err ? String(err.code) : "";
247164
247459
  if (code === "ENOENT") {
247165
- throw new Error(`JSON fixture file not found: ${resolve9(fixturePath)}`);
247460
+ throw new Error(`JSON fixture file not found: ${resolve10(fixturePath)}`);
247166
247461
  }
247167
247462
  throw err;
247168
247463
  }
@@ -247209,7 +247504,7 @@ function registerTemplateCommands(parent) {
247209
247504
  const templates = parent.command("templates").description("Manage workspace DOCX/XLSX templates (tmpl_…): upload, list, inspect, download, replace, delete, and smoke-fill.").addHelpText("after", TEMPLATES_EXAMPLES);
247210
247505
  const uploadCmd = templates.command("upload <file>").description("Upload a DOCX or XLSX file as a new tmpl_… resource with an immutable tmpr_… revision.").option("--name <name>", "Display name (defaults to the filename without extension)").option("--description <text>", "Optional description");
247211
247506
  addJsonFlag(withBaseUrl(uploadCmd)).action(action(async (file, opts) => {
247212
- const filePath = resolve9(file);
247507
+ const filePath = resolve10(file);
247213
247508
  const bytes = await fs20.readFile(filePath);
247214
247509
  const client = buildClient5(opts);
247215
247510
  const template = await uploadWorkspaceTemplate(client, {
@@ -247274,7 +247569,7 @@ function registerTemplateCommands(parent) {
247274
247569
  }));
247275
247570
  const replaceCmd = templates.command("replace <template-id> <file>").description("Append an immutable revision and advance the tmpl_… pointer.");
247276
247571
  addJsonFlag(withBaseUrl(replaceCmd)).action(action(async (templateId, file, opts) => {
247277
- const filePath = resolve9(file);
247572
+ const filePath = resolve10(file);
247278
247573
  const bytes = await fs20.readFile(filePath);
247279
247574
  const client = buildClient5(opts);
247280
247575
  const current = await getPublicTemplate(client, templateId);
@@ -247325,7 +247620,7 @@ function registerTemplateCommands(parent) {
247325
247620
  bytes = downloaded.bytes;
247326
247621
  filename = downloaded.filename;
247327
247622
  } else {
247328
- const filePath = resolve9(templateArg);
247623
+ const filePath = resolve10(templateArg);
247329
247624
  if (!existsSync20(filePath)) {
247330
247625
  throw new Error(`Template file not found: ${filePath}. Pass a local .docx/.xlsx path or a tmpl_… id.`);
247331
247626
  }
@@ -247369,7 +247664,7 @@ function registerTemplateCommands(parent) {
247369
247664
  // src/commands/workflow/validation.ts
247370
247665
  init_src();
247371
247666
  import { existsSync as existsSync22, readdirSync as readdirSync7, readFileSync as readFileSync19, statSync as statSync7 } from "fs";
247372
- import { join as join13, resolve as resolve10 } from "path";
247667
+ import { join as join13, resolve as resolve11 } from "path";
247373
247668
 
247374
247669
  // src/lib/template-diagnostics.ts
247375
247670
  init_src();
@@ -247986,7 +248281,7 @@ function parseDatasetFileRef(path, root) {
247986
248281
  return parts.join("/");
247987
248282
  }
247988
248283
  function rootDir(opts) {
247989
- return resolve10(opts.dir ?? process.cwd());
248284
+ return resolve11(opts.dir ?? process.cwd());
247990
248285
  }
247991
248286
  async function onlineInvokeIssues(yamlText, opts) {
247992
248287
  const config = resolveConfig(opts);
@@ -247996,7 +248291,7 @@ async function onlineInvokeIssues(yamlText, opts) {
247996
248291
  return res.issues ?? [];
247997
248292
  }
247998
248293
  function discoverWorkflowProjectRoots(rootPath) {
247999
- const root = resolve10(rootPath);
248294
+ const root = resolve11(rootPath);
248000
248295
  if (existsSync22(join13(root, "workflow.yaml")))
248001
248296
  return [root];
248002
248297
  const candidates = [
@@ -248043,8 +248338,8 @@ Note
248043
248338
  ` + ` project unless you pass --allow-external-templates.
248044
248339
  `);
248045
248340
  withBaseUrl(cmd).action(action(async (path, opts) => {
248046
- if (path && (!existsSync22(resolve10(path)) || !statSync7(resolve10(path)).isDirectory())) {
248047
- const target = resolve10(path);
248341
+ if (path && (!existsSync22(resolve11(path)) || !statSync7(resolve11(path)).isDirectory())) {
248342
+ const target = resolve11(path);
248048
248343
  const wfResult = validateWorkflowYaml(target);
248049
248344
  const wfOk = printIssues("workflow.yaml", target, wfResult.issues);
248050
248345
  if (wfOk) {
@@ -248060,7 +248355,7 @@ Note
248060
248355
  process.exit(1);
248061
248356
  return;
248062
248357
  }
248063
- const requestedRoot = path ? resolve10(path) : rootDir(opts);
248358
+ const requestedRoot = path ? resolve11(path) : rootDir(opts);
248064
248359
  const projects = discoverWorkflowProjectRoots(requestedRoot);
248065
248360
  if (projects.length === 0) {
248066
248361
  if (!await validateProjectRoot(requestedRoot, opts))
@@ -248082,14 +248377,14 @@ Note
248082
248377
  }
248083
248378
  function registerEvaluatorsValidateCommand(parent) {
248084
248379
  parent.command("validate [path]").description("Validate an evaluators YAML file against the EvalConfig schema. Defaults to ./evaluators.yaml.").action((path) => {
248085
- const target = resolve10(path ?? "evaluators.yaml");
248380
+ const target = resolve11(path ?? "evaluators.yaml");
248086
248381
  if (!printIssues("evaluators", target, validateEvaluatorsYaml(target)))
248087
248382
  process.exit(1);
248088
248383
  });
248089
248384
  }
248090
248385
  function registerDatasetValidateCommand(parent) {
248091
248386
  parent.command("validate [path]").description("Validate a dataset folder against the examples/<name>/{input,expected,meta} convention. Defaults to ./dataset/.").action((path) => {
248092
- const target = resolve10(path ?? "dataset");
248387
+ const target = resolve11(path ?? "dataset");
248093
248388
  if (!printIssues("dataset", target, validateDatasetFolder(target)))
248094
248389
  process.exit(1);
248095
248390
  });
@@ -248203,6 +248498,7 @@ YAML's \`name:\` field). Both:
248203
248498
  $ eigenpal workflow pull my-extraction
248204
248499
  `);
248205
248500
  registerWorkflowCoreCommands(workflow);
248501
+ registerParserMigrationCommand(workflow);
248206
248502
  registerWorkflowFolderCommands(workflow);
248207
248503
  registerEvaluatorsCommands(workflow);
248208
248504
  registerDatasetCommands2(workflow);