@eigenpal/cli 0.20.26 → 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.
@@ -35,8 +35,8 @@ the catalog tells you what fields it takes.
35
35
 
36
36
  | Use case | Step |
37
37
  | --------------------------------- | ------------------------------------------------- |
38
- | Read a PDF / DOCX / image (native-first) | `ai.parse` with `parseMode: native` or `native-or-ocr` |
39
- | Read a PDF / DOCX / image (full OCR/vision) | `ai.parse` with `parseMode: ocr` or `vision` |
38
+ | Read a PDF / DOCX / image | `ai.parse-v2` with defaults (automatic native/OCR/vision) |
39
+ | Restrict document reading | `ai.parse-v2` with `policy.native` and `policy.imageReading.order` |
40
40
  | Pull a typed object from text | `ai.extract` with `config.schema` |
41
41
  | Pick one label from a fixed set | `ai.classify` with `config.labels` |
42
42
  | Reject bad inputs with a 4xx code | `control.fail` (often after `ai.classify`) |
@@ -475,7 +475,1258 @@ _Generated from `STEP_SCHEMAS` in `@eigenpal/types/src/workflow/step-configs.ts`
475
475
 
476
476
  ### AI steps — model-backed processing
477
477
 
478
- #### `ai.parse` — Parse Document
478
+ #### `ai.parse-v2` — Parse Document
479
+
480
+ Automatically read native, scanned, and mixed documents with capability-aware OCR/vision fallback and explicit completeness.
481
+
482
+ **Behavior and examples:** `eigenpal docs read steps/ai/parse-v2`
483
+
484
+ **Durable retry:** Provider request retries are separate; the workflow engine does not durably retry this step.
485
+
486
+ **Config** (in `step.with`):
487
+
488
+ | Field | Type | Required | Default | Description |
489
+ | --- | --- | --- | --- | --- |
490
+ | `policy` | object | yes | | |
491
+ | `providers` | object | yes | | |
492
+ | `output` | object | yes | | |
493
+ | `enrichment` | object | yes | | |
494
+ | `advanced` | object | yes | | |
495
+ | `input` | string | yes | | File reference or template expression for the document |
496
+
497
+ **Output:** `object`
498
+
499
+ | Field | Type | Required | Default | Description |
500
+ | --- | --- | --- | --- | --- |
501
+ | `document` | object | yes | | |
502
+ | `usage` | object | yes | | |
503
+ | `pages` | array<object> | yes | | |
504
+ | `text` | string | yes | | Combined text from all pages |
505
+ | `parserType` | `"plaintext"` \| `"office"` \| `"llm-vision"` \| `"ocr"` | yes | | |
506
+ | `parserVersion` | `"2"` | yes | | |
507
+ | `model` | string | no | | Model used (for LLM/OCR parsers) |
508
+ | `processingStrategy` | `"native"` \| `"ocr"` \| `"vision"` \| `"hybrid"` | no | | How this result was produced: `native` (local PDF text only), `ocr`, `vision`, or `hybrid` (native pages merged with OCR on fallback pages). |
509
+ | `structured` | record<string, unknown> | no | | Canonical structured document with ordered blocks, regions, bounding boxes, tables, figures, and chunks when supported by the parser |
510
+ | `completeness` | object | yes | | |
511
+
512
+ ##### Complete machine-readable schemas
513
+
514
+ Config schema:
515
+
516
+ ```json
517
+ {
518
+ "$schema": "http://json-schema.org/draft-07/schema#",
519
+ "type": "object",
520
+ "properties": {
521
+ "policy": {
522
+ "type": "object",
523
+ "properties": {
524
+ "native": {
525
+ "default": "prefer",
526
+ "description": "Prefer local text extraction, require local text extraction with no image transcription, or skip native PDF extraction. Figure enrichment is independent.",
527
+ "type": "string",
528
+ "enum": [
529
+ "prefer",
530
+ "require",
531
+ "skip"
532
+ ]
533
+ },
534
+ "imageReading": {
535
+ "type": "object",
536
+ "properties": {
537
+ "order": {
538
+ "default": [
539
+ "ocr",
540
+ "vision"
541
+ ],
542
+ "description": "Ordered allowed backends. A single entry prohibits the other backend.",
543
+ "minItems": 1,
544
+ "maxItems": 2,
545
+ "type": "array",
546
+ "items": {
547
+ "type": "string",
548
+ "enum": [
549
+ "ocr",
550
+ "vision"
551
+ ]
552
+ }
553
+ }
554
+ },
555
+ "required": [
556
+ "order"
557
+ ],
558
+ "additionalProperties": false
559
+ }
560
+ },
561
+ "required": [
562
+ "native",
563
+ "imageReading"
564
+ ],
565
+ "additionalProperties": false
566
+ },
567
+ "providers": {
568
+ "type": "object",
569
+ "properties": {
570
+ "ocr": {
571
+ "description": "Exact configured OCR provider ID. Missing pins fail; they never resolve to another provider.",
572
+ "type": "string",
573
+ "minLength": 1
574
+ },
575
+ "vision": {
576
+ "description": "Exact configured vision provider ID. Otherwise uses the deployment parsing default or vision role.",
577
+ "type": "string",
578
+ "minLength": 1
579
+ }
580
+ },
581
+ "additionalProperties": false
582
+ },
583
+ "output": {
584
+ "type": "object",
585
+ "properties": {
586
+ "textFormat": {
587
+ "default": "markdown",
588
+ "type": "string",
589
+ "enum": [
590
+ "plain",
591
+ "markdown",
592
+ "html",
593
+ "djot"
594
+ ]
595
+ },
596
+ "includeCellMetadata": {
597
+ "default": false,
598
+ "description": "Include spreadsheet cell evidence in pages[].spreadsheet and annotate text for downstream extraction. Preserves raw/displayed values and workbook date system.",
599
+ "type": "boolean"
600
+ },
601
+ "nativeWhitespace": {
602
+ "default": "reading-order",
603
+ "description": "Spatial preserves native PDF column spacing. It does not promise OCR/vision coordinates.",
604
+ "type": "string",
605
+ "enum": [
606
+ "reading-order",
607
+ "spatial"
608
+ ]
609
+ },
610
+ "require": {
611
+ "default": [],
612
+ "description": "Required evidence capabilities on nonblank pages. Backends unable to satisfy them are rejected.",
613
+ "type": "array",
614
+ "items": {
615
+ "type": "string",
616
+ "enum": [
617
+ "wordCoordinates",
618
+ "tables"
619
+ ]
620
+ }
621
+ }
622
+ },
623
+ "required": [
624
+ "textFormat",
625
+ "includeCellMetadata",
626
+ "nativeWhitespace",
627
+ "require"
628
+ ],
629
+ "additionalProperties": false
630
+ },
631
+ "enrichment": {
632
+ "type": "object",
633
+ "properties": {
634
+ "figures": {
635
+ "type": "object",
636
+ "properties": {
637
+ "enabled": {
638
+ "default": false,
639
+ "type": "boolean"
640
+ },
641
+ "provider": {
642
+ "type": "string",
643
+ "minLength": 1
644
+ },
645
+ "instructions": {
646
+ "type": "string"
647
+ },
648
+ "reasoningEffort": {
649
+ "type": "string",
650
+ "enum": [
651
+ "none",
652
+ "minimal",
653
+ "low",
654
+ "medium",
655
+ "high",
656
+ "xhigh",
657
+ "max"
658
+ ]
659
+ }
660
+ },
661
+ "required": [
662
+ "enabled"
663
+ ],
664
+ "additionalProperties": false
665
+ }
666
+ },
667
+ "required": [
668
+ "figures"
669
+ ],
670
+ "additionalProperties": false
671
+ },
672
+ "advanced": {
673
+ "type": "object",
674
+ "properties": {
675
+ "vision": {
676
+ "type": "object",
677
+ "properties": {
678
+ "maxConcurrency": {
679
+ "default": 3,
680
+ "type": "integer",
681
+ "minimum": 1,
682
+ "maximum": 10
683
+ },
684
+ "pagesPerBatch": {
685
+ "default": 5,
686
+ "type": "integer",
687
+ "minimum": 1,
688
+ "maximum": 20
689
+ },
690
+ "renderScale": {
691
+ "default": 2,
692
+ "type": "number",
693
+ "minimum": 1,
694
+ "maximum": 4
695
+ },
696
+ "imageQuality": {
697
+ "default": 85,
698
+ "type": "integer",
699
+ "minimum": 1,
700
+ "maximum": 100
701
+ },
702
+ "instructions": {
703
+ "description": "Transcription instructions, never document-specific extraction/schema instructions.",
704
+ "type": "string"
705
+ },
706
+ "reasoningEffort": {
707
+ "type": "string",
708
+ "enum": [
709
+ "none",
710
+ "minimal",
711
+ "low",
712
+ "medium",
713
+ "high",
714
+ "xhigh",
715
+ "max"
716
+ ]
717
+ }
718
+ },
719
+ "required": [
720
+ "maxConcurrency",
721
+ "pagesPerBatch",
722
+ "renderScale",
723
+ "imageQuality"
724
+ ],
725
+ "additionalProperties": false
726
+ },
727
+ "languages": {
728
+ "type": "array",
729
+ "items": {
730
+ "type": "string",
731
+ "minLength": 1
732
+ }
733
+ },
734
+ "allowPartial": {
735
+ "default": false,
736
+ "description": "Return unresolved pages explicitly instead of failing. Default false.",
737
+ "type": "boolean"
738
+ },
739
+ "cache": {
740
+ "default": false,
741
+ "type": "boolean"
742
+ }
743
+ },
744
+ "required": [
745
+ "vision",
746
+ "allowPartial",
747
+ "cache"
748
+ ],
749
+ "additionalProperties": false
750
+ },
751
+ "input": {
752
+ "type": "string",
753
+ "minLength": 1,
754
+ "description": "File reference or template expression for the document"
755
+ }
756
+ },
757
+ "required": [
758
+ "policy",
759
+ "providers",
760
+ "output",
761
+ "enrichment",
762
+ "advanced",
763
+ "input"
764
+ ],
765
+ "additionalProperties": false
766
+ }
767
+ ```
768
+
769
+
770
+ Output schema:
771
+
772
+ ```json
773
+ {
774
+ "$schema": "http://json-schema.org/draft-07/schema#",
775
+ "type": "object",
776
+ "properties": {
777
+ "document": {
778
+ "type": "object",
779
+ "properties": {
780
+ "filename": {
781
+ "type": "string"
782
+ },
783
+ "mimeType": {
784
+ "type": "string"
785
+ },
786
+ "size": {
787
+ "type": "number",
788
+ "description": "File size in bytes"
789
+ },
790
+ "storageRef": {
791
+ "description": "Storage reference for the original file",
792
+ "type": "string"
793
+ }
794
+ },
795
+ "required": [
796
+ "filename",
797
+ "mimeType",
798
+ "size"
799
+ ],
800
+ "additionalProperties": false
801
+ },
802
+ "usage": {
803
+ "type": "object",
804
+ "properties": {
805
+ "pageCount": {
806
+ "type": "number"
807
+ },
808
+ "processingTimeMs": {
809
+ "type": "number"
810
+ },
811
+ "ocrPagesProcessed": {
812
+ "type": "integer",
813
+ "minimum": 0,
814
+ "maximum": 9007199254740991
815
+ },
816
+ "visionPagesProcessed": {
817
+ "type": "integer",
818
+ "minimum": 0,
819
+ "maximum": 9007199254740991
820
+ },
821
+ "visionPromptTokens": {
822
+ "type": "integer",
823
+ "minimum": 0,
824
+ "maximum": 9007199254740991
825
+ },
826
+ "visionCompletionTokens": {
827
+ "type": "integer",
828
+ "minimum": 0,
829
+ "maximum": 9007199254740991
830
+ },
831
+ "cached": {
832
+ "type": "boolean"
833
+ }
834
+ },
835
+ "required": [
836
+ "pageCount",
837
+ "visionPagesProcessed"
838
+ ],
839
+ "additionalProperties": false
840
+ },
841
+ "pages": {
842
+ "type": "array",
843
+ "items": {
844
+ "type": "object",
845
+ "properties": {
846
+ "spreadsheet": {
847
+ "description": "Opt-in original spreadsheet cell evidence",
848
+ "type": "object",
849
+ "properties": {
850
+ "dateSystem": {
851
+ "type": "string",
852
+ "enum": [
853
+ "1900",
854
+ "1904"
855
+ ]
856
+ },
857
+ "declaredRange": {
858
+ "type": "string"
859
+ },
860
+ "cells": {
861
+ "type": "array",
862
+ "items": {
863
+ "type": "object",
864
+ "properties": {
865
+ "address": {
866
+ "type": "string",
867
+ "description": "Original A1 cell address"
868
+ },
869
+ "type": {
870
+ "type": "string",
871
+ "description": "Excel storage type: n=number, s=string, b=boolean, e=error, d=date, z=blank. A numeric date remains type n."
872
+ },
873
+ "rawValue": {
874
+ "description": "Stored cached value; formulas are never evaluated",
875
+ "anyOf": [
876
+ {
877
+ "type": "string"
878
+ },
879
+ {
880
+ "type": "number"
881
+ },
882
+ {
883
+ "type": "boolean"
884
+ },
885
+ {
886
+ "type": "null"
887
+ }
888
+ ]
889
+ },
890
+ "displayedValue": {
891
+ "type": "string",
892
+ "description": "Value formatted using the workbook number format and date system"
893
+ },
894
+ "numberFormat": {
895
+ "type": "string"
896
+ },
897
+ "formula": {
898
+ "type": "string"
899
+ },
900
+ "dateValue": {
901
+ "description": "Calendar rendering for a valid date-formatted serial, without a timezone. Evidence of Excel formatting, not a business classification.",
902
+ "type": "string"
903
+ },
904
+ "excelLeapDay": {
905
+ "description": "True for the fictitious 1900-02-29 in the Excel 1900 date system",
906
+ "type": "boolean"
907
+ }
908
+ },
909
+ "required": [
910
+ "address",
911
+ "type",
912
+ "displayedValue"
913
+ ],
914
+ "additionalProperties": false
915
+ }
916
+ }
917
+ },
918
+ "required": [
919
+ "dateSystem",
920
+ "cells"
921
+ ],
922
+ "additionalProperties": false
923
+ },
924
+ "pageIndex": {
925
+ "type": "number",
926
+ "description": "0-based page index"
927
+ },
928
+ "text": {
929
+ "type": "string",
930
+ "description": "Extracted page text (markdown/HTML/plain, or spatial layout text)"
931
+ },
932
+ "pageName": {
933
+ "description": "Page/sheet name (e.g., Excel sheet name)",
934
+ "type": "string"
935
+ },
936
+ "layoutElements": {
937
+ "description": "Semantic layout elements in reading order",
938
+ "type": "array",
939
+ "items": {
940
+ "type": "object",
941
+ "properties": {
942
+ "type": {
943
+ "type": "string",
944
+ "enum": [
945
+ "paragraph",
946
+ "title",
947
+ "sectionHeading",
948
+ "pageHeader",
949
+ "pageFooter",
950
+ "pageNumber",
951
+ "footnote",
952
+ "table",
953
+ "figure",
954
+ "formulaBlock"
955
+ ]
956
+ },
957
+ "content": {
958
+ "type": "string"
959
+ },
960
+ "table": {
961
+ "type": "object",
962
+ "properties": {
963
+ "cells": {
964
+ "type": "array",
965
+ "items": {
966
+ "type": "object",
967
+ "properties": {
968
+ "content": {
969
+ "type": "string"
970
+ },
971
+ "rowIndex": {
972
+ "type": "number"
973
+ },
974
+ "columnIndex": {
975
+ "type": "number"
976
+ },
977
+ "rowSpan": {
978
+ "default": 1,
979
+ "type": "number"
980
+ },
981
+ "columnSpan": {
982
+ "default": 1,
983
+ "type": "number"
984
+ },
985
+ "boundingRegion": {
986
+ "type": "object",
987
+ "properties": {
988
+ "polygon": {
989
+ "minItems": 3,
990
+ "type": "array",
991
+ "items": {
992
+ "type": "object",
993
+ "properties": {
994
+ "x": {
995
+ "type": "number"
996
+ },
997
+ "y": {
998
+ "type": "number"
999
+ }
1000
+ },
1001
+ "required": [
1002
+ "x",
1003
+ "y"
1004
+ ],
1005
+ "additionalProperties": false
1006
+ }
1007
+ },
1008
+ "unit": {
1009
+ "type": "string",
1010
+ "enum": [
1011
+ "pixel",
1012
+ "inch",
1013
+ "point",
1014
+ "normalized"
1015
+ ]
1016
+ },
1017
+ "pageIndex": {
1018
+ "type": "number"
1019
+ }
1020
+ },
1021
+ "required": [
1022
+ "polygon",
1023
+ "unit",
1024
+ "pageIndex"
1025
+ ],
1026
+ "additionalProperties": false
1027
+ }
1028
+ },
1029
+ "required": [
1030
+ "content",
1031
+ "rowIndex",
1032
+ "columnIndex",
1033
+ "rowSpan",
1034
+ "columnSpan"
1035
+ ],
1036
+ "additionalProperties": false
1037
+ }
1038
+ },
1039
+ "rowCount": {
1040
+ "type": "number"
1041
+ },
1042
+ "columnCount": {
1043
+ "type": "number"
1044
+ },
1045
+ "boundingRegion": {
1046
+ "type": "object",
1047
+ "properties": {
1048
+ "polygon": {
1049
+ "minItems": 3,
1050
+ "type": "array",
1051
+ "items": {
1052
+ "type": "object",
1053
+ "properties": {
1054
+ "x": {
1055
+ "type": "number"
1056
+ },
1057
+ "y": {
1058
+ "type": "number"
1059
+ }
1060
+ },
1061
+ "required": [
1062
+ "x",
1063
+ "y"
1064
+ ],
1065
+ "additionalProperties": false
1066
+ }
1067
+ },
1068
+ "unit": {
1069
+ "type": "string",
1070
+ "enum": [
1071
+ "pixel",
1072
+ "inch",
1073
+ "point",
1074
+ "normalized"
1075
+ ]
1076
+ },
1077
+ "pageIndex": {
1078
+ "type": "number"
1079
+ }
1080
+ },
1081
+ "required": [
1082
+ "polygon",
1083
+ "unit",
1084
+ "pageIndex"
1085
+ ],
1086
+ "additionalProperties": false
1087
+ }
1088
+ },
1089
+ "required": [
1090
+ "cells",
1091
+ "rowCount",
1092
+ "columnCount"
1093
+ ],
1094
+ "additionalProperties": false
1095
+ },
1096
+ "caption": {
1097
+ "type": "string"
1098
+ },
1099
+ "figureId": {
1100
+ "type": "string"
1101
+ },
1102
+ "boundingRegion": {
1103
+ "type": "object",
1104
+ "properties": {
1105
+ "polygon": {
1106
+ "minItems": 3,
1107
+ "type": "array",
1108
+ "items": {
1109
+ "type": "object",
1110
+ "properties": {
1111
+ "x": {
1112
+ "type": "number"
1113
+ },
1114
+ "y": {
1115
+ "type": "number"
1116
+ }
1117
+ },
1118
+ "required": [
1119
+ "x",
1120
+ "y"
1121
+ ],
1122
+ "additionalProperties": false
1123
+ }
1124
+ },
1125
+ "unit": {
1126
+ "type": "string",
1127
+ "enum": [
1128
+ "pixel",
1129
+ "inch",
1130
+ "point",
1131
+ "normalized"
1132
+ ]
1133
+ },
1134
+ "pageIndex": {
1135
+ "type": "number"
1136
+ }
1137
+ },
1138
+ "required": [
1139
+ "polygon",
1140
+ "unit",
1141
+ "pageIndex"
1142
+ ],
1143
+ "additionalProperties": false
1144
+ }
1145
+ },
1146
+ "required": [
1147
+ "type",
1148
+ "content"
1149
+ ],
1150
+ "additionalProperties": false
1151
+ }
1152
+ },
1153
+ "words": {
1154
+ "description": "Word-level positions",
1155
+ "type": "array",
1156
+ "items": {
1157
+ "type": "object",
1158
+ "properties": {
1159
+ "text": {
1160
+ "type": "string"
1161
+ },
1162
+ "confidence": {
1163
+ "type": "number",
1164
+ "minimum": 0,
1165
+ "maximum": 1
1166
+ },
1167
+ "boundingRegion": {
1168
+ "type": "object",
1169
+ "properties": {
1170
+ "polygon": {
1171
+ "minItems": 3,
1172
+ "type": "array",
1173
+ "items": {
1174
+ "type": "object",
1175
+ "properties": {
1176
+ "x": {
1177
+ "type": "number"
1178
+ },
1179
+ "y": {
1180
+ "type": "number"
1181
+ }
1182
+ },
1183
+ "required": [
1184
+ "x",
1185
+ "y"
1186
+ ],
1187
+ "additionalProperties": false
1188
+ }
1189
+ },
1190
+ "unit": {
1191
+ "type": "string",
1192
+ "enum": [
1193
+ "pixel",
1194
+ "inch",
1195
+ "point",
1196
+ "normalized"
1197
+ ]
1198
+ },
1199
+ "pageIndex": {
1200
+ "type": "number"
1201
+ }
1202
+ },
1203
+ "required": [
1204
+ "polygon",
1205
+ "unit",
1206
+ "pageIndex"
1207
+ ],
1208
+ "additionalProperties": false
1209
+ }
1210
+ },
1211
+ "required": [
1212
+ "text"
1213
+ ],
1214
+ "additionalProperties": false
1215
+ }
1216
+ },
1217
+ "lines": {
1218
+ "description": "Line-level positions",
1219
+ "type": "array",
1220
+ "items": {
1221
+ "type": "object",
1222
+ "properties": {
1223
+ "text": {
1224
+ "type": "string"
1225
+ },
1226
+ "confidence": {
1227
+ "type": "number",
1228
+ "minimum": 0,
1229
+ "maximum": 1
1230
+ },
1231
+ "boundingRegion": {
1232
+ "type": "object",
1233
+ "properties": {
1234
+ "polygon": {
1235
+ "minItems": 3,
1236
+ "type": "array",
1237
+ "items": {
1238
+ "type": "object",
1239
+ "properties": {
1240
+ "x": {
1241
+ "type": "number"
1242
+ },
1243
+ "y": {
1244
+ "type": "number"
1245
+ }
1246
+ },
1247
+ "required": [
1248
+ "x",
1249
+ "y"
1250
+ ],
1251
+ "additionalProperties": false
1252
+ }
1253
+ },
1254
+ "unit": {
1255
+ "type": "string",
1256
+ "enum": [
1257
+ "pixel",
1258
+ "inch",
1259
+ "point",
1260
+ "normalized"
1261
+ ]
1262
+ },
1263
+ "pageIndex": {
1264
+ "type": "number"
1265
+ }
1266
+ },
1267
+ "required": [
1268
+ "polygon",
1269
+ "unit",
1270
+ "pageIndex"
1271
+ ],
1272
+ "additionalProperties": false
1273
+ }
1274
+ },
1275
+ "required": [
1276
+ "text"
1277
+ ],
1278
+ "additionalProperties": false
1279
+ }
1280
+ },
1281
+ "tables": {
1282
+ "description": "Extracted tables",
1283
+ "type": "array",
1284
+ "items": {
1285
+ "type": "object",
1286
+ "properties": {
1287
+ "cells": {
1288
+ "type": "array",
1289
+ "items": {
1290
+ "type": "object",
1291
+ "properties": {
1292
+ "content": {
1293
+ "type": "string"
1294
+ },
1295
+ "rowIndex": {
1296
+ "type": "number"
1297
+ },
1298
+ "columnIndex": {
1299
+ "type": "number"
1300
+ },
1301
+ "rowSpan": {
1302
+ "default": 1,
1303
+ "type": "number"
1304
+ },
1305
+ "columnSpan": {
1306
+ "default": 1,
1307
+ "type": "number"
1308
+ },
1309
+ "boundingRegion": {
1310
+ "type": "object",
1311
+ "properties": {
1312
+ "polygon": {
1313
+ "minItems": 3,
1314
+ "type": "array",
1315
+ "items": {
1316
+ "type": "object",
1317
+ "properties": {
1318
+ "x": {
1319
+ "type": "number"
1320
+ },
1321
+ "y": {
1322
+ "type": "number"
1323
+ }
1324
+ },
1325
+ "required": [
1326
+ "x",
1327
+ "y"
1328
+ ],
1329
+ "additionalProperties": false
1330
+ }
1331
+ },
1332
+ "unit": {
1333
+ "type": "string",
1334
+ "enum": [
1335
+ "pixel",
1336
+ "inch",
1337
+ "point",
1338
+ "normalized"
1339
+ ]
1340
+ },
1341
+ "pageIndex": {
1342
+ "type": "number"
1343
+ }
1344
+ },
1345
+ "required": [
1346
+ "polygon",
1347
+ "unit",
1348
+ "pageIndex"
1349
+ ],
1350
+ "additionalProperties": false
1351
+ }
1352
+ },
1353
+ "required": [
1354
+ "content",
1355
+ "rowIndex",
1356
+ "columnIndex",
1357
+ "rowSpan",
1358
+ "columnSpan"
1359
+ ],
1360
+ "additionalProperties": false
1361
+ }
1362
+ },
1363
+ "rowCount": {
1364
+ "type": "number"
1365
+ },
1366
+ "columnCount": {
1367
+ "type": "number"
1368
+ },
1369
+ "boundingRegion": {
1370
+ "type": "object",
1371
+ "properties": {
1372
+ "polygon": {
1373
+ "minItems": 3,
1374
+ "type": "array",
1375
+ "items": {
1376
+ "type": "object",
1377
+ "properties": {
1378
+ "x": {
1379
+ "type": "number"
1380
+ },
1381
+ "y": {
1382
+ "type": "number"
1383
+ }
1384
+ },
1385
+ "required": [
1386
+ "x",
1387
+ "y"
1388
+ ],
1389
+ "additionalProperties": false
1390
+ }
1391
+ },
1392
+ "unit": {
1393
+ "type": "string",
1394
+ "enum": [
1395
+ "pixel",
1396
+ "inch",
1397
+ "point",
1398
+ "normalized"
1399
+ ]
1400
+ },
1401
+ "pageIndex": {
1402
+ "type": "number"
1403
+ }
1404
+ },
1405
+ "required": [
1406
+ "polygon",
1407
+ "unit",
1408
+ "pageIndex"
1409
+ ],
1410
+ "additionalProperties": false
1411
+ }
1412
+ },
1413
+ "required": [
1414
+ "cells",
1415
+ "rowCount",
1416
+ "columnCount"
1417
+ ],
1418
+ "additionalProperties": false
1419
+ }
1420
+ },
1421
+ "width": {
1422
+ "description": "Page width",
1423
+ "type": "number"
1424
+ },
1425
+ "height": {
1426
+ "description": "Page height",
1427
+ "type": "number"
1428
+ },
1429
+ "unit": {
1430
+ "description": "Unit for width/height and bounding regions",
1431
+ "type": "string",
1432
+ "enum": [
1433
+ "pixel",
1434
+ "inch",
1435
+ "point",
1436
+ "normalized"
1437
+ ]
1438
+ },
1439
+ "confidence": {
1440
+ "description": "Overall page confidence",
1441
+ "type": "number",
1442
+ "minimum": 0,
1443
+ "maximum": 1
1444
+ },
1445
+ "nativeTextQuality": {
1446
+ "description": "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.",
1447
+ "type": "object",
1448
+ "properties": {
1449
+ "status": {
1450
+ "type": "string",
1451
+ "enum": [
1452
+ "clean",
1453
+ "empty",
1454
+ "suspect"
1455
+ ]
1456
+ },
1457
+ "reasons": {
1458
+ "type": "array",
1459
+ "items": {
1460
+ "type": "string",
1461
+ "enum": [
1462
+ "empty",
1463
+ "replacement-character",
1464
+ "lone-surrogate",
1465
+ "forbidden-control",
1466
+ "unassigned",
1467
+ "noncharacter",
1468
+ "private-use"
1469
+ ]
1470
+ }
1471
+ },
1472
+ "counts": {
1473
+ "type": "object",
1474
+ "properties": {
1475
+ "codePoints": {
1476
+ "type": "integer",
1477
+ "minimum": 0,
1478
+ "maximum": 9007199254740991
1479
+ },
1480
+ "nonWhitespace": {
1481
+ "type": "integer",
1482
+ "minimum": 0,
1483
+ "maximum": 9007199254740991
1484
+ },
1485
+ "replacement": {
1486
+ "type": "integer",
1487
+ "minimum": 0,
1488
+ "maximum": 9007199254740991
1489
+ },
1490
+ "loneSurrogate": {
1491
+ "type": "integer",
1492
+ "minimum": 0,
1493
+ "maximum": 9007199254740991
1494
+ },
1495
+ "forbiddenControl": {
1496
+ "type": "integer",
1497
+ "minimum": 0,
1498
+ "maximum": 9007199254740991
1499
+ },
1500
+ "unassigned": {
1501
+ "type": "integer",
1502
+ "minimum": 0,
1503
+ "maximum": 9007199254740991
1504
+ },
1505
+ "noncharacter": {
1506
+ "type": "integer",
1507
+ "minimum": 0,
1508
+ "maximum": 9007199254740991
1509
+ },
1510
+ "privateUse": {
1511
+ "type": "integer",
1512
+ "minimum": 0,
1513
+ "maximum": 9007199254740991
1514
+ }
1515
+ },
1516
+ "required": [
1517
+ "codePoints",
1518
+ "nonWhitespace",
1519
+ "replacement",
1520
+ "loneSurrogate",
1521
+ "forbiddenControl",
1522
+ "unassigned",
1523
+ "noncharacter",
1524
+ "privateUse"
1525
+ ],
1526
+ "additionalProperties": false
1527
+ },
1528
+ "profile": {
1529
+ "type": "object",
1530
+ "properties": {
1531
+ "replacementRatio": {
1532
+ "type": "number",
1533
+ "minimum": 0
1534
+ },
1535
+ "loneSurrogateRatio": {
1536
+ "type": "number",
1537
+ "minimum": 0
1538
+ },
1539
+ "forbiddenControlRatio": {
1540
+ "type": "number",
1541
+ "minimum": 0
1542
+ },
1543
+ "unassignedRatio": {
1544
+ "type": "number",
1545
+ "minimum": 0
1546
+ },
1547
+ "noncharacterRatio": {
1548
+ "type": "number",
1549
+ "minimum": 0
1550
+ },
1551
+ "privateUseRatio": {
1552
+ "type": "number",
1553
+ "minimum": 0
1554
+ }
1555
+ },
1556
+ "required": [
1557
+ "replacementRatio",
1558
+ "loneSurrogateRatio",
1559
+ "forbiddenControlRatio",
1560
+ "unassignedRatio",
1561
+ "noncharacterRatio",
1562
+ "privateUseRatio"
1563
+ ],
1564
+ "additionalProperties": false
1565
+ }
1566
+ },
1567
+ "required": [
1568
+ "status",
1569
+ "reasons",
1570
+ "counts",
1571
+ "profile"
1572
+ ],
1573
+ "additionalProperties": false
1574
+ },
1575
+ "provenance": {
1576
+ "type": "object",
1577
+ "properties": {
1578
+ "source": {
1579
+ "type": "string",
1580
+ "enum": [
1581
+ "native",
1582
+ "ocr",
1583
+ "vision"
1584
+ ]
1585
+ },
1586
+ "provider": {
1587
+ "type": "string"
1588
+ },
1589
+ "model": {
1590
+ "type": "string"
1591
+ },
1592
+ "reason": {
1593
+ "type": "string"
1594
+ },
1595
+ "textFormat": {
1596
+ "type": "string",
1597
+ "enum": [
1598
+ "plain",
1599
+ "markdown",
1600
+ "html",
1601
+ "djot"
1602
+ ]
1603
+ },
1604
+ "capabilities": {
1605
+ "type": "array",
1606
+ "items": {
1607
+ "type": "string",
1608
+ "enum": [
1609
+ "wordCoordinates",
1610
+ "tables"
1611
+ ]
1612
+ }
1613
+ }
1614
+ },
1615
+ "required": [
1616
+ "source",
1617
+ "reason",
1618
+ "textFormat",
1619
+ "capabilities"
1620
+ ],
1621
+ "additionalProperties": false
1622
+ },
1623
+ "status": {
1624
+ "type": "string",
1625
+ "enum": [
1626
+ "complete",
1627
+ "blank",
1628
+ "no-text",
1629
+ "unresolved"
1630
+ ]
1631
+ },
1632
+ "warnings": {
1633
+ "default": [],
1634
+ "type": "array",
1635
+ "items": {
1636
+ "type": "string"
1637
+ }
1638
+ }
1639
+ },
1640
+ "required": [
1641
+ "pageIndex",
1642
+ "text",
1643
+ "provenance",
1644
+ "status",
1645
+ "warnings"
1646
+ ],
1647
+ "additionalProperties": false
1648
+ }
1649
+ },
1650
+ "text": {
1651
+ "type": "string",
1652
+ "description": "Combined text from all pages"
1653
+ },
1654
+ "parserType": {
1655
+ "type": "string",
1656
+ "enum": [
1657
+ "plaintext",
1658
+ "office",
1659
+ "llm-vision",
1660
+ "ocr"
1661
+ ]
1662
+ },
1663
+ "parserVersion": {
1664
+ "type": "string",
1665
+ "const": "2"
1666
+ },
1667
+ "model": {
1668
+ "description": "Model used (for LLM/OCR parsers)",
1669
+ "type": "string"
1670
+ },
1671
+ "processingStrategy": {
1672
+ "description": "How this result was produced: `native` (local PDF text only), `ocr`, `vision`, or `hybrid` (native pages merged with OCR on fallback pages).",
1673
+ "type": "string",
1674
+ "enum": [
1675
+ "native",
1676
+ "ocr",
1677
+ "vision",
1678
+ "hybrid"
1679
+ ]
1680
+ },
1681
+ "structured": {
1682
+ "description": "Canonical structured document with ordered blocks, regions, bounding boxes, tables, figures, and chunks when supported by the parser",
1683
+ "type": "object",
1684
+ "propertyNames": {
1685
+ "type": "string"
1686
+ },
1687
+ "additionalProperties": {}
1688
+ },
1689
+ "completeness": {
1690
+ "type": "object",
1691
+ "properties": {
1692
+ "status": {
1693
+ "type": "string",
1694
+ "enum": [
1695
+ "complete",
1696
+ "partial"
1697
+ ]
1698
+ },
1699
+ "unresolvedPageIndexes": {
1700
+ "type": "array",
1701
+ "items": {
1702
+ "type": "integer",
1703
+ "minimum": 0,
1704
+ "maximum": 9007199254740991
1705
+ }
1706
+ }
1707
+ },
1708
+ "required": [
1709
+ "status",
1710
+ "unresolvedPageIndexes"
1711
+ ],
1712
+ "additionalProperties": false
1713
+ }
1714
+ },
1715
+ "required": [
1716
+ "document",
1717
+ "usage",
1718
+ "pages",
1719
+ "text",
1720
+ "parserType",
1721
+ "parserVersion",
1722
+ "completeness"
1723
+ ],
1724
+ "additionalProperties": false
1725
+ }
1726
+ ```
1727
+
1728
+
1729
+ #### `ai.parse` — Parse Document — legacy
479
1730
 
480
1731
  Extract text from documents (PDF, DOCX, images) using native extraction, OCR, or vision models
481
1732
 
@@ -705,6 +1956,21 @@ Output schema:
705
1956
  "minimum": 0,
706
1957
  "maximum": 9007199254740991
707
1958
  },
1959
+ "visionPagesProcessed": {
1960
+ "type": "integer",
1961
+ "minimum": 0,
1962
+ "maximum": 9007199254740991
1963
+ },
1964
+ "visionPromptTokens": {
1965
+ "type": "integer",
1966
+ "minimum": 0,
1967
+ "maximum": 9007199254740991
1968
+ },
1969
+ "visionCompletionTokens": {
1970
+ "type": "integer",
1971
+ "minimum": 0,
1972
+ "maximum": 9007199254740991
1973
+ },
708
1974
  "cached": {
709
1975
  "type": "boolean"
710
1976
  }
@@ -719,6 +1985,84 @@ Output schema:
719
1985
  "items": {
720
1986
  "type": "object",
721
1987
  "properties": {
1988
+ "spreadsheet": {
1989
+ "description": "Opt-in original spreadsheet cell evidence",
1990
+ "type": "object",
1991
+ "properties": {
1992
+ "dateSystem": {
1993
+ "type": "string",
1994
+ "enum": [
1995
+ "1900",
1996
+ "1904"
1997
+ ]
1998
+ },
1999
+ "declaredRange": {
2000
+ "type": "string"
2001
+ },
2002
+ "cells": {
2003
+ "type": "array",
2004
+ "items": {
2005
+ "type": "object",
2006
+ "properties": {
2007
+ "address": {
2008
+ "type": "string",
2009
+ "description": "Original A1 cell address"
2010
+ },
2011
+ "type": {
2012
+ "type": "string",
2013
+ "description": "Excel storage type: n=number, s=string, b=boolean, e=error, d=date, z=blank. A numeric date remains type n."
2014
+ },
2015
+ "rawValue": {
2016
+ "description": "Stored cached value; formulas are never evaluated",
2017
+ "anyOf": [
2018
+ {
2019
+ "type": "string"
2020
+ },
2021
+ {
2022
+ "type": "number"
2023
+ },
2024
+ {
2025
+ "type": "boolean"
2026
+ },
2027
+ {
2028
+ "type": "null"
2029
+ }
2030
+ ]
2031
+ },
2032
+ "displayedValue": {
2033
+ "type": "string",
2034
+ "description": "Value formatted using the workbook number format and date system"
2035
+ },
2036
+ "numberFormat": {
2037
+ "type": "string"
2038
+ },
2039
+ "formula": {
2040
+ "type": "string"
2041
+ },
2042
+ "dateValue": {
2043
+ "description": "Calendar rendering for a valid date-formatted serial, without a timezone. Evidence of Excel formatting, not a business classification.",
2044
+ "type": "string"
2045
+ },
2046
+ "excelLeapDay": {
2047
+ "description": "True for the fictitious 1900-02-29 in the Excel 1900 date system",
2048
+ "type": "boolean"
2049
+ }
2050
+ },
2051
+ "required": [
2052
+ "address",
2053
+ "type",
2054
+ "displayedValue"
2055
+ ],
2056
+ "additionalProperties": false
2057
+ }
2058
+ }
2059
+ },
2060
+ "required": [
2061
+ "dateSystem",
2062
+ "cells"
2063
+ ],
2064
+ "additionalProperties": false
2065
+ },
722
2066
  "pageIndex": {
723
2067
  "type": "number",
724
2068
  "description": "0-based page index"
@@ -4258,8 +5602,9 @@ Convert an XLS or XLSX spreadsheet to a JSON array of row objects. Supports head
4258
5602
  | --- | --- | --- | --- | --- |
4259
5603
  | `input` | string | yes | | File input - template expression e.g. {{input.document}} resolving to a scoped $file artifact at runtime |
4260
5604
  | `sheet` | integer \| string | no | | Sheet to read: 0-based index or exact sheet name. Omit for the first sheet. |
4261
- | `outputCsv` | boolean | no | `false` | 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. |
4262
- | `includeMetadata` | boolean | no | `false` | 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. |
5605
+ | `outputCsv` | boolean | no | `false` | 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. |
5606
+ | `includeCellMetadata` | boolean | no | `false` | 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. |
5607
+ | `includeMetadata` | boolean | no | `false` | 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. |
4263
5608
  | `outputFilename` | string | no | | Output CSV filename when outputCsv is true - supports LiquidJS e.g. {{filename}}.csv |
4264
5609
  | `headerRow` | `false` \| integer | no | | 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. |
4265
5610
  | `columns` | array<object> | no | | 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. |
@@ -4273,10 +5618,11 @@ Convert an XLS or XLSX spreadsheet to a JSON array of row objects. Supports head
4273
5618
 
4274
5619
  | Field | Type | Required | Default | Description |
4275
5620
  | --- | --- | --- | --- | --- |
5621
+ | `cellMetadata` | array<object> | no | | Evidence for nonblank projected data cells, linked to rows by outputRowIndex and key. Present when includeCellMetadata is true. |
4276
5622
  | `rows` | array<record<string, unknown>> | yes | | Array of row objects (first row = headers as keys unless headerRow is false) |
4277
5623
  | `fileId` | string | no | | File ID of stored CSV when outputCsv is true |
4278
- | `sheet` | object | no | | Selected sheet metadata after projection. Present only when includeMetadata is true. |
4279
- | `diagnostics` | array<object> | no | | Non-fatal warnings collected while reading the sheet. Present only when includeMetadata is true. Warnings are still logged when metadata is omitted. |
5624
+ | `sheet` | object | no | | Selected sheet metadata after projection. Present when includeMetadata or includeCellMetadata is true. |
5625
+ | `diagnostics` | array<object> | no | | Non-fatal warnings collected while reading the sheet. Present when includeMetadata or includeCellMetadata is true. Warnings are still logged when metadata is omitted. |
4280
5626
 
4281
5627
  ##### Complete machine-readable schemas
4282
5628
 
@@ -4306,12 +5652,17 @@ Config schema:
4306
5652
  ]
4307
5653
  },
4308
5654
  "outputCsv": {
4309
- "description": "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.",
5655
+ "description": "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.",
5656
+ "default": false,
5657
+ "type": "boolean"
5658
+ },
5659
+ "includeCellMetadata": {
5660
+ "description": "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.",
4310
5661
  "default": false,
4311
5662
  "type": "boolean"
4312
5663
  },
4313
5664
  "includeMetadata": {
4314
- "description": "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.",
5665
+ "description": "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.",
4315
5666
  "default": false,
4316
5667
  "type": "boolean"
4317
5668
  },
@@ -4449,6 +5800,74 @@ Output schema:
4449
5800
  "$schema": "http://json-schema.org/draft-07/schema#",
4450
5801
  "type": "object",
4451
5802
  "properties": {
5803
+ "cellMetadata": {
5804
+ "description": "Evidence for nonblank projected data cells, linked to rows by outputRowIndex and key. Present when includeCellMetadata is true.",
5805
+ "type": "array",
5806
+ "items": {
5807
+ "type": "object",
5808
+ "properties": {
5809
+ "address": {
5810
+ "type": "string",
5811
+ "description": "Original A1 cell address"
5812
+ },
5813
+ "type": {
5814
+ "type": "string",
5815
+ "description": "Excel storage type: n=number, s=string, b=boolean, e=error, d=date, z=blank. A numeric date remains type n."
5816
+ },
5817
+ "rawValue": {
5818
+ "description": "Stored cached value; formulas are never evaluated",
5819
+ "anyOf": [
5820
+ {
5821
+ "type": "string"
5822
+ },
5823
+ {
5824
+ "type": "number"
5825
+ },
5826
+ {
5827
+ "type": "boolean"
5828
+ },
5829
+ {
5830
+ "type": "null"
5831
+ }
5832
+ ]
5833
+ },
5834
+ "displayedValue": {
5835
+ "type": "string",
5836
+ "description": "Value formatted using the workbook number format and date system"
5837
+ },
5838
+ "numberFormat": {
5839
+ "type": "string"
5840
+ },
5841
+ "formula": {
5842
+ "type": "string"
5843
+ },
5844
+ "dateValue": {
5845
+ "description": "Calendar rendering for a valid date-formatted serial, without a timezone. Evidence of Excel formatting, not a business classification.",
5846
+ "type": "string"
5847
+ },
5848
+ "excelLeapDay": {
5849
+ "description": "True for the fictitious 1900-02-29 in the Excel 1900 date system",
5850
+ "type": "boolean"
5851
+ },
5852
+ "key": {
5853
+ "type": "string"
5854
+ },
5855
+ "outputRowIndex": {
5856
+ "type": "integer",
5857
+ "minimum": 0,
5858
+ "maximum": 9007199254740991
5859
+ }
5860
+ },
5861
+ "required": [
5862
+ "address",
5863
+ "type",
5864
+ "displayedValue",
5865
+ "key",
5866
+ "outputRowIndex"
5867
+ ],
5868
+ "additionalProperties": false
5869
+ }
5870
+ },
4452
5871
  "rows": {
4453
5872
  "type": "array",
4454
5873
  "items": {
@@ -4465,13 +5884,25 @@ Output schema:
4465
5884
  "type": "string"
4466
5885
  },
4467
5886
  "sheet": {
4468
- "description": "Selected sheet metadata after projection. Present only when includeMetadata is true.",
5887
+ "description": "Selected sheet metadata after projection. Present when includeMetadata or includeCellMetadata is true.",
4469
5888
  "type": "object",
4470
5889
  "properties": {
4471
5890
  "name": {
4472
5891
  "type": "string",
4473
5892
  "description": "Selected sheet name"
4474
5893
  },
5894
+ "declaredRange": {
5895
+ "description": "Worksheet declared extent before empty trailing rows/columns were removed",
5896
+ "type": "string"
5897
+ },
5898
+ "dateSystem": {
5899
+ "description": "Workbook Excel date system",
5900
+ "type": "string",
5901
+ "enum": [
5902
+ "1900",
5903
+ "1904"
5904
+ ]
5905
+ },
4475
5906
  "index": {
4476
5907
  "type": "integer",
4477
5908
  "minimum": 0,
@@ -4506,7 +5937,7 @@ Output schema:
4506
5937
  "additionalProperties": false
4507
5938
  },
4508
5939
  "diagnostics": {
4509
- "description": "Non-fatal warnings collected while reading the sheet. Present only when includeMetadata is true. Warnings are still logged when metadata is omitted.",
5940
+ "description": "Non-fatal warnings collected while reading the sheet. Present when includeMetadata or includeCellMetadata is true. Warnings are still logged when metadata is omitted.",
4510
5941
  "type": "array",
4511
5942
  "items": {
4512
5943
  "type": "object",