@anyformat/sdk 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -7
- package/dist/index.cjs +232 -38
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +491 -126
- package/dist/index.d.ts +491 -126
- package/dist/index.js +225 -38
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,13 @@ interface Auth {
|
|
|
6
6
|
* @default 'header'
|
|
7
7
|
*/
|
|
8
8
|
in?: 'header' | 'query' | 'cookie';
|
|
9
|
+
/**
|
|
10
|
+
* A unique identifier for the security scheme.
|
|
11
|
+
*
|
|
12
|
+
* Defined only when there are multiple security schemes whose `Auth`
|
|
13
|
+
* shape would otherwise be identical.
|
|
14
|
+
*/
|
|
15
|
+
key?: string;
|
|
9
16
|
/**
|
|
10
17
|
* Header or query parameter name.
|
|
11
18
|
*
|
|
@@ -312,6 +319,37 @@ interface TDataShape {
|
|
|
312
319
|
type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
|
|
313
320
|
type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown, TResponseStyle extends ResponseStyle = 'fields'> = OmitKeys<RequestOptions<TResponse, TResponseStyle, ThrowOnError>, 'body' | 'path' | 'query' | 'url'> & ([TData] extends [never] ? unknown : Omit<TData, 'url'>);
|
|
314
321
|
|
|
322
|
+
/**
|
|
323
|
+
* ArithmeticCheck
|
|
324
|
+
*/
|
|
325
|
+
type ArithmeticCheck = {
|
|
326
|
+
/**
|
|
327
|
+
* Equals
|
|
328
|
+
*
|
|
329
|
+
* persistent_id whose value the result must equal.
|
|
330
|
+
*/
|
|
331
|
+
equals: string;
|
|
332
|
+
/**
|
|
333
|
+
* Operands
|
|
334
|
+
*
|
|
335
|
+
* persistent_ids combined by `operator`.
|
|
336
|
+
*/
|
|
337
|
+
operands: Array<string>;
|
|
338
|
+
/**
|
|
339
|
+
* Operator
|
|
340
|
+
*/
|
|
341
|
+
operator?: 'sum' | 'subtract' | 'product';
|
|
342
|
+
/**
|
|
343
|
+
* Tolerance
|
|
344
|
+
*
|
|
345
|
+
* Absolute slack allowed around `equals`.
|
|
346
|
+
*/
|
|
347
|
+
tolerance?: number;
|
|
348
|
+
/**
|
|
349
|
+
* Type
|
|
350
|
+
*/
|
|
351
|
+
type: 'arithmetic';
|
|
352
|
+
};
|
|
315
353
|
/**
|
|
316
354
|
* Block
|
|
317
355
|
*
|
|
@@ -403,7 +441,7 @@ type BooleanField = {
|
|
|
403
441
|
*
|
|
404
442
|
* Free-form description shown to the extraction model.
|
|
405
443
|
*/
|
|
406
|
-
description
|
|
444
|
+
description?: string;
|
|
407
445
|
/**
|
|
408
446
|
* Lookup
|
|
409
447
|
*/
|
|
@@ -414,6 +452,12 @@ type BooleanField = {
|
|
|
414
452
|
* Field name. Used as the key in the extraction response.
|
|
415
453
|
*/
|
|
416
454
|
name: string;
|
|
455
|
+
/**
|
|
456
|
+
* Persistent Id
|
|
457
|
+
*
|
|
458
|
+
* Server-assigned stable field identity (UUID), emitted by GET /definition/. Echo it back on updates — including across renames — to keep quality metrics, ground-truth links and analytics attached to the field. Matching is scoped to the field's nesting level in the immediately-prior version; an id that matches nothing at its level, appears on more than one field, or is sent at workflow creation is rejected with 400. Omit for new fields; when omitted on an update, the server matches the field to the prior version by name.
|
|
459
|
+
*/
|
|
460
|
+
persistent_id?: string | null;
|
|
417
461
|
};
|
|
418
462
|
/**
|
|
419
463
|
* ClassificationResult
|
|
@@ -459,7 +503,7 @@ type ClassifyCategory = {
|
|
|
459
503
|
/**
|
|
460
504
|
* Name
|
|
461
505
|
*
|
|
462
|
-
* Display name shown to the LLM.
|
|
506
|
+
* Display name shown to the LLM; classification and routing key off it, so it must be unique across categories.
|
|
463
507
|
*/
|
|
464
508
|
name: string;
|
|
465
509
|
};
|
|
@@ -484,10 +528,60 @@ type ClassifyNode = {
|
|
|
484
528
|
/**
|
|
485
529
|
* User Prompt
|
|
486
530
|
*
|
|
487
|
-
* Optional
|
|
531
|
+
* Optional extra instructions inserted between the classifier's system prompt and the document text.
|
|
488
532
|
*/
|
|
489
533
|
user_prompt?: string | null;
|
|
490
534
|
};
|
|
535
|
+
/**
|
|
536
|
+
* ComparisonCheck
|
|
537
|
+
*/
|
|
538
|
+
type ComparisonCheck = {
|
|
539
|
+
/**
|
|
540
|
+
* Left
|
|
541
|
+
*
|
|
542
|
+
* persistent_id of the left-hand field.
|
|
543
|
+
*/
|
|
544
|
+
left: string;
|
|
545
|
+
/**
|
|
546
|
+
* Op
|
|
547
|
+
*/
|
|
548
|
+
op: '==' | '!=' | '>' | '>=' | '<' | '<=';
|
|
549
|
+
/**
|
|
550
|
+
* Right
|
|
551
|
+
*/
|
|
552
|
+
right: ({
|
|
553
|
+
source: 'field';
|
|
554
|
+
} & FieldOperand) | ({
|
|
555
|
+
source: 'literal';
|
|
556
|
+
} & LiteralOperand);
|
|
557
|
+
/**
|
|
558
|
+
* Type
|
|
559
|
+
*/
|
|
560
|
+
type: 'comparison';
|
|
561
|
+
};
|
|
562
|
+
/**
|
|
563
|
+
* DateCheck
|
|
564
|
+
*/
|
|
565
|
+
type DateCheck = {
|
|
566
|
+
/**
|
|
567
|
+
* Earliest
|
|
568
|
+
*/
|
|
569
|
+
earliest?: string | null;
|
|
570
|
+
/**
|
|
571
|
+
* Field
|
|
572
|
+
*
|
|
573
|
+
* persistent_id of the date field.
|
|
574
|
+
*/
|
|
575
|
+
field: string;
|
|
576
|
+
/**
|
|
577
|
+
* Latest
|
|
578
|
+
*/
|
|
579
|
+
latest?: string | null;
|
|
580
|
+
/**
|
|
581
|
+
* Type
|
|
582
|
+
*/
|
|
583
|
+
type: 'date';
|
|
584
|
+
};
|
|
491
585
|
/**
|
|
492
586
|
* DateField
|
|
493
587
|
*/
|
|
@@ -501,7 +595,7 @@ type DateField = {
|
|
|
501
595
|
*
|
|
502
596
|
* Free-form description shown to the extraction model.
|
|
503
597
|
*/
|
|
504
|
-
description
|
|
598
|
+
description?: string;
|
|
505
599
|
/**
|
|
506
600
|
* Lookup
|
|
507
601
|
*/
|
|
@@ -512,6 +606,12 @@ type DateField = {
|
|
|
512
606
|
* Field name. Used as the key in the extraction response.
|
|
513
607
|
*/
|
|
514
608
|
name: string;
|
|
609
|
+
/**
|
|
610
|
+
* Persistent Id
|
|
611
|
+
*
|
|
612
|
+
* Server-assigned stable field identity (UUID), emitted by GET /definition/. Echo it back on updates — including across renames — to keep quality metrics, ground-truth links and analytics attached to the field. Matching is scoped to the field's nesting level in the immediately-prior version; an id that matches nothing at its level, appears on more than one field, or is sent at workflow creation is rejected with 400. Omit for new fields; when omitted on an update, the server matches the field to the prior version by name.
|
|
613
|
+
*/
|
|
614
|
+
persistent_id?: string | null;
|
|
515
615
|
};
|
|
516
616
|
/**
|
|
517
617
|
* DatetimeField
|
|
@@ -526,7 +626,7 @@ type DatetimeField = {
|
|
|
526
626
|
*
|
|
527
627
|
* Free-form description shown to the extraction model.
|
|
528
628
|
*/
|
|
529
|
-
description
|
|
629
|
+
description?: string;
|
|
530
630
|
/**
|
|
531
631
|
* Lookup
|
|
532
632
|
*/
|
|
@@ -537,6 +637,12 @@ type DatetimeField = {
|
|
|
537
637
|
* Field name. Used as the key in the extraction response.
|
|
538
638
|
*/
|
|
539
639
|
name: string;
|
|
640
|
+
/**
|
|
641
|
+
* Persistent Id
|
|
642
|
+
*
|
|
643
|
+
* Server-assigned stable field identity (UUID), emitted by GET /definition/. Echo it back on updates — including across renames — to keep quality metrics, ground-truth links and analytics attached to the field. Matching is scoped to the field's nesting level in the immediately-prior version; an id that matches nothing at its level, appears on more than one field, or is sent at workflow creation is rejected with 400. Omit for new fields; when omitted on an update, the server matches the field to the prior version by name.
|
|
644
|
+
*/
|
|
645
|
+
persistent_id?: string | null;
|
|
540
646
|
};
|
|
541
647
|
/**
|
|
542
648
|
* Edge
|
|
@@ -573,7 +679,7 @@ type EnumField = {
|
|
|
573
679
|
*
|
|
574
680
|
* Free-form description shown to the extraction model.
|
|
575
681
|
*/
|
|
576
|
-
description
|
|
682
|
+
description?: string;
|
|
577
683
|
/**
|
|
578
684
|
* Enum Options
|
|
579
685
|
*/
|
|
@@ -588,6 +694,12 @@ type EnumField = {
|
|
|
588
694
|
* Field name. Used as the key in the extraction response.
|
|
589
695
|
*/
|
|
590
696
|
name: string;
|
|
697
|
+
/**
|
|
698
|
+
* Persistent Id
|
|
699
|
+
*
|
|
700
|
+
* Server-assigned stable field identity (UUID), emitted by GET /definition/. Echo it back on updates — including across renames — to keep quality metrics, ground-truth links and analytics attached to the field. Matching is scoped to the field's nesting level in the immediately-prior version; an id that matches nothing at its level, appears on more than one field, or is sent at workflow creation is rejected with 400. Omit for new fields; when omitted on an update, the server matches the field to the prior version by name.
|
|
701
|
+
*/
|
|
702
|
+
persistent_id?: string | null;
|
|
591
703
|
};
|
|
592
704
|
/**
|
|
593
705
|
* EnumOption
|
|
@@ -628,11 +740,7 @@ type Evidence = {
|
|
|
628
740
|
*/
|
|
629
741
|
type ExtractNode = {
|
|
630
742
|
/**
|
|
631
|
-
*
|
|
632
|
-
*/
|
|
633
|
-
context_tracker?: string;
|
|
634
|
-
/**
|
|
635
|
-
* Schema for the fields this node extracts. Required. The backend executor populates this from the ORM field tree before constructing the typed node; nothing else should be able to build an ExtractNode without it.
|
|
743
|
+
* Schema for the fields this node extracts. Required.
|
|
636
744
|
*/
|
|
637
745
|
extraction_schema: ExtractionSchema;
|
|
638
746
|
/**
|
|
@@ -644,7 +752,7 @@ type ExtractNode = {
|
|
|
644
752
|
/**
|
|
645
753
|
* Lookup File Uploads
|
|
646
754
|
*
|
|
647
|
-
* Inline lookup-file content for the typed create call.
|
|
755
|
+
* Inline lookup-file content for the typed create call. Each entry is uploaded and the resulting URI is appended to ``lookup_files``; this field is create-input only.
|
|
648
756
|
*/
|
|
649
757
|
lookup_file_uploads?: Array<LookupFileUpload>;
|
|
650
758
|
/**
|
|
@@ -653,30 +761,18 @@ type ExtractNode = {
|
|
|
653
761
|
* Smart-lookup reference document URIs persisted on the extract node.
|
|
654
762
|
*/
|
|
655
763
|
lookup_files?: Array<string>;
|
|
764
|
+
/**
|
|
765
|
+
* Lookup Reasoning Effort
|
|
766
|
+
*
|
|
767
|
+
* Reasoning effort for the smart-lookup matcher (gpt-5 family): minimal | low | medium | high. None = model default. Higher effort improves match reliability on noisy join keys at higher latency/cost.
|
|
768
|
+
*/
|
|
769
|
+
lookup_reasoning_effort?: 'minimal' | 'low' | 'medium' | 'high' | null;
|
|
656
770
|
/**
|
|
657
771
|
* Lookup Schema
|
|
658
772
|
*
|
|
659
|
-
* Typed schema of fields the smart-lookup pass should produce.
|
|
660
|
-
*/
|
|
661
|
-
lookup_schema?: Array<
|
|
662
|
-
data_type: 'string';
|
|
663
|
-
} & StringField) | ({
|
|
664
|
-
data_type: 'integer';
|
|
665
|
-
} & IntegerField) | ({
|
|
666
|
-
data_type: 'float';
|
|
667
|
-
} & FloatField) | ({
|
|
668
|
-
data_type: 'boolean';
|
|
669
|
-
} & BooleanField) | ({
|
|
670
|
-
data_type: 'date';
|
|
671
|
-
} & DateField) | ({
|
|
672
|
-
data_type: 'datetime';
|
|
673
|
-
} & DatetimeField) | ({
|
|
674
|
-
data_type: 'enum';
|
|
675
|
-
} & EnumField) | ({
|
|
676
|
-
data_type: 'multi_select';
|
|
677
|
-
} & MultiSelectField) | ({
|
|
678
|
-
data_type: 'object';
|
|
679
|
-
} & ObjectField)>;
|
|
773
|
+
* Typed schema of fields the smart-lookup pass should produce. Derived server-side from the workflow's smart-lookup fields; default empty for nodes without any.
|
|
774
|
+
*/
|
|
775
|
+
lookup_schema?: Array<StringField | IntegerField | FloatField | BooleanField | DateField | DatetimeField | EnumField | MultiSelectField | ObjectField>;
|
|
680
776
|
/**
|
|
681
777
|
* Lookup Suggestion
|
|
682
778
|
*
|
|
@@ -685,14 +781,20 @@ type ExtractNode = {
|
|
|
685
781
|
lookup_suggestion?: string | null;
|
|
686
782
|
/**
|
|
687
783
|
* Mode
|
|
784
|
+
*
|
|
785
|
+
* Extraction tier. 'standard' (default): single-pass extraction — the best balance for simple documents and layouts. 'agentic': multi-step extraction that maps every table to the schema and reasons across sections — for dense or cross-page tables; extra cost per page. 'max' (feature-gated): extracts table rows page by page with cross-page context tracking, then independently verifies row sums against document totals and re-extracts pages that don't reconcile — for multi-page invoices with complex row grouping. 'lite' (shown as 'Fast' in the app): standard extraction, faster and cheaper; quality may vary on complex layouts.
|
|
688
786
|
*/
|
|
689
|
-
mode?: 'standard' | 'agentic' | 'max';
|
|
787
|
+
mode?: 'standard' | 'agentic' | 'max' | 'lite';
|
|
690
788
|
/**
|
|
691
789
|
* Page Sum Verification Enabled
|
|
790
|
+
*
|
|
791
|
+
* After row extraction, independently re-check each page's rows against document totals and re-extract pages that don't reconcile ('max' mode implies this).
|
|
692
792
|
*/
|
|
693
793
|
page_sum_verification_enabled?: boolean;
|
|
694
794
|
/**
|
|
695
795
|
* Row Extractor Enabled
|
|
796
|
+
*
|
|
797
|
+
* Extract table rows page by page, carrying context across page breaks so rows stay in their group ('max' mode implies this).
|
|
696
798
|
*/
|
|
697
799
|
row_extractor_enabled?: boolean;
|
|
698
800
|
/**
|
|
@@ -701,6 +803,8 @@ type ExtractNode = {
|
|
|
701
803
|
type: 'extract';
|
|
702
804
|
/**
|
|
703
805
|
* Use Images
|
|
806
|
+
*
|
|
807
|
+
* Standard/lite modes: send each PDF page's rendered image alongside its parsed text so the model can read layout the text missed — adds vision cost on every page. No effect in agentic/max modes or on non-PDF sources.
|
|
704
808
|
*/
|
|
705
809
|
use_images?: boolean;
|
|
706
810
|
};
|
|
@@ -709,7 +813,7 @@ type ExtractNode = {
|
|
|
709
813
|
*
|
|
710
814
|
* One extracted field's value, confidence, and supporting evidence.
|
|
711
815
|
*/
|
|
712
|
-
type ExtractedField = {
|
|
816
|
+
type ExtractedField$1 = {
|
|
713
817
|
/**
|
|
714
818
|
* Confidence
|
|
715
819
|
*
|
|
@@ -756,8 +860,8 @@ type Extraction = {
|
|
|
756
860
|
* Extracted fields keyed by field name. Same shape as the legacy top-level `extraction`.
|
|
757
861
|
*/
|
|
758
862
|
fields: {
|
|
759
|
-
[key: string]: ExtractedField | Array<{
|
|
760
|
-
[key: string]: ExtractedField;
|
|
863
|
+
[key: string]: ExtractedField$1 | Array<{
|
|
864
|
+
[key: string]: ExtractedField$1;
|
|
761
865
|
}>;
|
|
762
866
|
};
|
|
763
867
|
/**
|
|
@@ -776,16 +880,11 @@ type Extraction = {
|
|
|
776
880
|
/**
|
|
777
881
|
* ExtractionSchema
|
|
778
882
|
*
|
|
779
|
-
* Schema describing what an extract node produces.
|
|
780
|
-
* object (not a bare ``list[AnyField]``) so metadata can be added later
|
|
781
|
-
* (versioning, derived flags, output-shape hints) without another
|
|
782
|
-
* wire-format break.
|
|
883
|
+
* Schema describing what an extract node produces.
|
|
783
884
|
*
|
|
784
|
-
*
|
|
785
|
-
*
|
|
786
|
-
*
|
|
787
|
-
* any assigned fields are skipped at the executor layer rather than
|
|
788
|
-
* sent to the worker with an empty schema.
|
|
885
|
+
* Modeled as a typed object (not a bare ``list[AnyField]``) so metadata
|
|
886
|
+
* can be added later (versioning, derived flags, output-shape hints)
|
|
887
|
+
* without another wire-format break. At least one field is required.
|
|
789
888
|
*/
|
|
790
889
|
type ExtractionSchema = {
|
|
791
890
|
/**
|
|
@@ -793,25 +892,7 @@ type ExtractionSchema = {
|
|
|
793
892
|
*
|
|
794
893
|
* Field definitions making up this extract's output.
|
|
795
894
|
*/
|
|
796
|
-
fields: Array<
|
|
797
|
-
data_type: 'string';
|
|
798
|
-
} & StringField) | ({
|
|
799
|
-
data_type: 'integer';
|
|
800
|
-
} & IntegerField) | ({
|
|
801
|
-
data_type: 'float';
|
|
802
|
-
} & FloatField) | ({
|
|
803
|
-
data_type: 'boolean';
|
|
804
|
-
} & BooleanField) | ({
|
|
805
|
-
data_type: 'date';
|
|
806
|
-
} & DateField) | ({
|
|
807
|
-
data_type: 'datetime';
|
|
808
|
-
} & DatetimeField) | ({
|
|
809
|
-
data_type: 'enum';
|
|
810
|
-
} & EnumField) | ({
|
|
811
|
-
data_type: 'multi_select';
|
|
812
|
-
} & MultiSelectField) | ({
|
|
813
|
-
data_type: 'object';
|
|
814
|
-
} & ObjectField)>;
|
|
895
|
+
fields: Array<StringField | IntegerField | FloatField | BooleanField | DateField | DatetimeField | EnumField | MultiSelectField | ObjectField>;
|
|
815
896
|
};
|
|
816
897
|
/**
|
|
817
898
|
* FilePages
|
|
@@ -851,7 +932,7 @@ type FloatField = {
|
|
|
851
932
|
*
|
|
852
933
|
* Free-form description shown to the extraction model.
|
|
853
934
|
*/
|
|
854
|
-
description
|
|
935
|
+
description?: string;
|
|
855
936
|
/**
|
|
856
937
|
* Lookup
|
|
857
938
|
*/
|
|
@@ -862,6 +943,12 @@ type FloatField = {
|
|
|
862
943
|
* Field name. Used as the key in the extraction response.
|
|
863
944
|
*/
|
|
864
945
|
name: string;
|
|
946
|
+
/**
|
|
947
|
+
* Persistent Id
|
|
948
|
+
*
|
|
949
|
+
* Server-assigned stable field identity (UUID), emitted by GET /definition/. Echo it back on updates — including across renames — to keep quality metrics, ground-truth links and analytics attached to the field. Matching is scoped to the field's nesting level in the immediately-prior version; an id that matches nothing at its level, appears on more than one field, or is sent at workflow creation is rejected with 400. Omit for new fields; when omitted on an update, the server matches the field to the prior version by name.
|
|
950
|
+
*/
|
|
951
|
+
persistent_id?: string | null;
|
|
865
952
|
};
|
|
866
953
|
/**
|
|
867
954
|
* Hyperlink
|
|
@@ -895,7 +982,7 @@ type IntegerField = {
|
|
|
895
982
|
*
|
|
896
983
|
* Free-form description shown to the extraction model.
|
|
897
984
|
*/
|
|
898
|
-
description
|
|
985
|
+
description?: string;
|
|
899
986
|
/**
|
|
900
987
|
* Lookup
|
|
901
988
|
*/
|
|
@@ -906,6 +993,12 @@ type IntegerField = {
|
|
|
906
993
|
* Field name. Used as the key in the extraction response.
|
|
907
994
|
*/
|
|
908
995
|
name: string;
|
|
996
|
+
/**
|
|
997
|
+
* Persistent Id
|
|
998
|
+
*
|
|
999
|
+
* Server-assigned stable field identity (UUID), emitted by GET /definition/. Echo it back on updates — including across renames — to keep quality metrics, ground-truth links and analytics attached to the field. Matching is scoped to the field's nesting level in the immediately-prior version; an id that matches nothing at its level, appears on more than one field, or is sent at workflow creation is rejected with 400. Omit for new fields; when omitted on an update, the server matches the field to the prior version by name.
|
|
1000
|
+
*/
|
|
1001
|
+
persistent_id?: string | null;
|
|
909
1002
|
};
|
|
910
1003
|
/**
|
|
911
1004
|
* LookupFileUpload
|
|
@@ -913,9 +1006,9 @@ type IntegerField = {
|
|
|
913
1006
|
* Inline lookup-file content carried on the typed create call.
|
|
914
1007
|
*
|
|
915
1008
|
* The backend reads ``filename`` + ``content`` (base64-encoded bytes),
|
|
916
|
-
* uploads the file
|
|
917
|
-
*
|
|
918
|
-
*
|
|
1009
|
+
* uploads the file, and stores the resulting URI in
|
|
1010
|
+
* ``ExtractNode.lookup_files``. Create-input only — not persisted on
|
|
1011
|
+
* the node after upload.
|
|
919
1012
|
*/
|
|
920
1013
|
type LookupFileUpload = {
|
|
921
1014
|
/**
|
|
@@ -942,7 +1035,7 @@ type MultiSelectField = {
|
|
|
942
1035
|
*
|
|
943
1036
|
* Free-form description shown to the extraction model.
|
|
944
1037
|
*/
|
|
945
|
-
description
|
|
1038
|
+
description?: string;
|
|
946
1039
|
/**
|
|
947
1040
|
* Enum Options
|
|
948
1041
|
*/
|
|
@@ -957,6 +1050,12 @@ type MultiSelectField = {
|
|
|
957
1050
|
* Field name. Used as the key in the extraction response.
|
|
958
1051
|
*/
|
|
959
1052
|
name: string;
|
|
1053
|
+
/**
|
|
1054
|
+
* Persistent Id
|
|
1055
|
+
*
|
|
1056
|
+
* Server-assigned stable field identity (UUID), emitted by GET /definition/. Echo it back on updates — including across renames — to keep quality metrics, ground-truth links and analytics attached to the field. Matching is scoped to the field's nesting level in the immediately-prior version; an id that matches nothing at its level, appears on more than one field, or is sent at workflow creation is rejected with 400. Omit for new fields; when omitted on an update, the server matches the field to the prior version by name.
|
|
1057
|
+
*/
|
|
1058
|
+
persistent_id?: string | null;
|
|
960
1059
|
};
|
|
961
1060
|
/**
|
|
962
1061
|
* ObjectField
|
|
@@ -971,7 +1070,7 @@ type ObjectField = {
|
|
|
971
1070
|
*
|
|
972
1071
|
* Free-form description shown to the extraction model.
|
|
973
1072
|
*/
|
|
974
|
-
description
|
|
1073
|
+
description?: string;
|
|
975
1074
|
/**
|
|
976
1075
|
* Lookup
|
|
977
1076
|
*/
|
|
@@ -987,23 +1086,34 @@ type ObjectField = {
|
|
|
987
1086
|
*
|
|
988
1087
|
* Child fields of this object. Only one level of nesting is supported — an object field's children must be non-object types.
|
|
989
1088
|
*/
|
|
990
|
-
nested_fields: Array<
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1089
|
+
nested_fields: Array<StringField | IntegerField | FloatField | BooleanField | DateField | DatetimeField | EnumField | MultiSelectField>;
|
|
1090
|
+
/**
|
|
1091
|
+
* Persistent Id
|
|
1092
|
+
*
|
|
1093
|
+
* Server-assigned stable field identity (UUID), emitted by GET /definition/. Echo it back on updates — including across renames — to keep quality metrics, ground-truth links and analytics attached to the field. Matching is scoped to the field's nesting level in the immediately-prior version; an id that matches nothing at its level, appears on more than one field, or is sent at workflow creation is rejected with 400. Omit for new fields; when omitted on an update, the server matches the field to the prior version by name.
|
|
1094
|
+
*/
|
|
1095
|
+
persistent_id?: string | null;
|
|
1096
|
+
};
|
|
1097
|
+
/**
|
|
1098
|
+
* OneOfCheck
|
|
1099
|
+
*/
|
|
1100
|
+
type OneOfCheck = {
|
|
1101
|
+
/**
|
|
1102
|
+
* Allowed
|
|
1103
|
+
*/
|
|
1104
|
+
allowed: Array<string>;
|
|
1105
|
+
/**
|
|
1106
|
+
* Case Sensitive
|
|
1107
|
+
*/
|
|
1108
|
+
case_sensitive?: boolean;
|
|
1109
|
+
/**
|
|
1110
|
+
* Field
|
|
1111
|
+
*/
|
|
1112
|
+
field: string;
|
|
1113
|
+
/**
|
|
1114
|
+
* Type
|
|
1115
|
+
*/
|
|
1116
|
+
type: 'one_of';
|
|
1007
1117
|
};
|
|
1008
1118
|
/**
|
|
1009
1119
|
* ParseNode
|
|
@@ -1011,12 +1121,28 @@ type ObjectField = {
|
|
|
1011
1121
|
type ParseNode = {
|
|
1012
1122
|
/**
|
|
1013
1123
|
* Cache
|
|
1124
|
+
*
|
|
1125
|
+
* Reuse parsed output when the same file was already parsed with the same mode and settings — a hit skips the whole parse. Disable to force a fresh parse.
|
|
1014
1126
|
*/
|
|
1015
1127
|
cache?: boolean;
|
|
1128
|
+
/**
|
|
1129
|
+
* Effort
|
|
1130
|
+
*
|
|
1131
|
+
* Agentic mode: quality/cost preset. 'low' = several times cheaper but more errors on dense or low-contrast tables, 'mid' (default) = balanced, 'accurate' = highest fidelity. (Distinct from lite `ocr_effort`.)
|
|
1132
|
+
*/
|
|
1133
|
+
effort?: 'low' | 'mid' | 'accurate';
|
|
1016
1134
|
/**
|
|
1017
1135
|
* Figure Enhancement
|
|
1136
|
+
*
|
|
1137
|
+
* Standard mode: extract structured data from charts and images — extra processing per figure. Ignored in agentic (figures are already handled) and in lite (use `figures` instead).
|
|
1018
1138
|
*/
|
|
1019
1139
|
figure_enhancement?: boolean;
|
|
1140
|
+
/**
|
|
1141
|
+
* Figures
|
|
1142
|
+
*
|
|
1143
|
+
* Lite mode: the correction pass reads data points off charts/figures and reconstructs them as HTML tables (extra work on figure pages; needs skip_routing_review=False).
|
|
1144
|
+
*/
|
|
1145
|
+
figures?: boolean;
|
|
1020
1146
|
/**
|
|
1021
1147
|
* Id
|
|
1022
1148
|
*
|
|
@@ -1025,14 +1151,46 @@ type ParseNode = {
|
|
|
1025
1151
|
id: string;
|
|
1026
1152
|
/**
|
|
1027
1153
|
* Mode
|
|
1154
|
+
*
|
|
1155
|
+
* Parse tier. 'standard' (default): page-by-page parsing with reading-order correction — the best quality/speed balance for most documents and tables. 'agentic': adaptive parsing that works hardest on dense tables (50+ rows, many columns) — highest fidelity on complex documents; extra cost per page. 'lite' (shown as 'Fast' in the app): OCR-first tier, fastest and cheapest — accurate OCR by default; set skip_routing_review=False to add a correction pass when reading order, figures, or text formatting matter.
|
|
1028
1156
|
*/
|
|
1029
|
-
mode?: 'standard' | 'agentic';
|
|
1157
|
+
mode?: 'standard' | 'agentic' | 'lite';
|
|
1158
|
+
/**
|
|
1159
|
+
* Ocr Effort
|
|
1160
|
+
*
|
|
1161
|
+
* Lite mode: 'high' (default) = the strongest OCR — best accuracy on complex layouts, tables, and handwriting, and usually all a document needs. 'medium' = faster and cheaper, for clean digital documents. (Distinct from agentic `effort`.)
|
|
1162
|
+
*/
|
|
1163
|
+
ocr_effort?: 'medium' | 'high';
|
|
1030
1164
|
/**
|
|
1031
1165
|
* Prompt Hint
|
|
1032
1166
|
*
|
|
1033
|
-
* Free-form hint
|
|
1167
|
+
* Free-form hint that biases the parse output. In lite mode it guides the correction pass, so it requires skip_routing_review=False.
|
|
1034
1168
|
*/
|
|
1035
1169
|
prompt_hint?: string | null;
|
|
1170
|
+
/**
|
|
1171
|
+
* Region
|
|
1172
|
+
*
|
|
1173
|
+
* Lite mode: OCR data-residency. 'eu' keeps processing in-region; 'global' uses the hosted endpoint. Feature-flagged.
|
|
1174
|
+
*/
|
|
1175
|
+
region?: 'eu' | 'global';
|
|
1176
|
+
/**
|
|
1177
|
+
* Routing Effort
|
|
1178
|
+
*
|
|
1179
|
+
* Lite mode: effort of the correction pass's reading-order analysis — its dominant latency knob (None = the highest). Lower it to cut latency on simple layouts.
|
|
1180
|
+
*/
|
|
1181
|
+
routing_effort?: 'minimal' | 'low' | 'medium' | 'high' | null;
|
|
1182
|
+
/**
|
|
1183
|
+
* Skip Routing Review
|
|
1184
|
+
*
|
|
1185
|
+
* Lite mode: emit the OCR output as-is (the default — fastest and cheapest). Set False to add a correction pass that fixes reading order and OCR errors and rebuilds broken tables; while True, figures/text_formatting/routing_effort/prompt_hint are inert.
|
|
1186
|
+
*/
|
|
1187
|
+
skip_routing_review?: boolean;
|
|
1188
|
+
/**
|
|
1189
|
+
* Text Formatting
|
|
1190
|
+
*
|
|
1191
|
+
* Lite mode: the correction pass restores inline styling (bold/italic/superscript), code, and LaTeX math in text blocks (needs skip_routing_review=False).
|
|
1192
|
+
*/
|
|
1193
|
+
text_formatting?: boolean;
|
|
1036
1194
|
/**
|
|
1037
1195
|
* Type
|
|
1038
1196
|
*/
|
|
@@ -1075,6 +1233,61 @@ type ParseResult = {
|
|
|
1075
1233
|
*/
|
|
1076
1234
|
text?: string | null;
|
|
1077
1235
|
};
|
|
1236
|
+
/**
|
|
1237
|
+
* RangeCheck
|
|
1238
|
+
*/
|
|
1239
|
+
type RangeCheck = {
|
|
1240
|
+
/**
|
|
1241
|
+
* Field
|
|
1242
|
+
*
|
|
1243
|
+
* persistent_id of the bounded numeric field.
|
|
1244
|
+
*/
|
|
1245
|
+
field: string;
|
|
1246
|
+
/**
|
|
1247
|
+
* Max
|
|
1248
|
+
*/
|
|
1249
|
+
max?: number | null;
|
|
1250
|
+
/**
|
|
1251
|
+
* Min
|
|
1252
|
+
*/
|
|
1253
|
+
min?: number | null;
|
|
1254
|
+
/**
|
|
1255
|
+
* Type
|
|
1256
|
+
*/
|
|
1257
|
+
type: 'range';
|
|
1258
|
+
};
|
|
1259
|
+
/**
|
|
1260
|
+
* RegexCheck
|
|
1261
|
+
*/
|
|
1262
|
+
type RegexCheck = {
|
|
1263
|
+
/**
|
|
1264
|
+
* Field
|
|
1265
|
+
*/
|
|
1266
|
+
field: string;
|
|
1267
|
+
/**
|
|
1268
|
+
* Pattern
|
|
1269
|
+
*
|
|
1270
|
+
* Evaluated with google-re2 (linear time); never stdlib re.
|
|
1271
|
+
*/
|
|
1272
|
+
pattern: string;
|
|
1273
|
+
/**
|
|
1274
|
+
* Type
|
|
1275
|
+
*/
|
|
1276
|
+
type: 'regex';
|
|
1277
|
+
};
|
|
1278
|
+
/**
|
|
1279
|
+
* RequiredCheck
|
|
1280
|
+
*/
|
|
1281
|
+
type RequiredCheck = {
|
|
1282
|
+
/**
|
|
1283
|
+
* Field
|
|
1284
|
+
*/
|
|
1285
|
+
field: string;
|
|
1286
|
+
/**
|
|
1287
|
+
* Type
|
|
1288
|
+
*/
|
|
1289
|
+
type: 'required';
|
|
1290
|
+
};
|
|
1078
1291
|
/**
|
|
1079
1292
|
* ResultsResponse
|
|
1080
1293
|
*
|
|
@@ -1104,8 +1317,8 @@ type ResultsResponse = {
|
|
|
1104
1317
|
* @deprecated
|
|
1105
1318
|
*/
|
|
1106
1319
|
extraction?: {
|
|
1107
|
-
[key: string]: ExtractedField | Array<{
|
|
1108
|
-
[key: string]: ExtractedField;
|
|
1320
|
+
[key: string]: ExtractedField$1 | Array<{
|
|
1321
|
+
[key: string]: ExtractedField$1;
|
|
1109
1322
|
}>;
|
|
1110
1323
|
} | null;
|
|
1111
1324
|
/**
|
|
@@ -1222,6 +1435,8 @@ type SplitterRule = {
|
|
|
1222
1435
|
name: string;
|
|
1223
1436
|
/**
|
|
1224
1437
|
* Partition Key
|
|
1438
|
+
*
|
|
1439
|
+
* Field that further partitions this category into separate sub-documents (e.g. invoice_number): each distinct value becomes its own split, extracted independently. Empty = routing-only, the whole category flows on as one document.
|
|
1225
1440
|
*/
|
|
1226
1441
|
partition_key?: string;
|
|
1227
1442
|
};
|
|
@@ -1238,7 +1453,7 @@ type StringField = {
|
|
|
1238
1453
|
*
|
|
1239
1454
|
* Free-form description shown to the extraction model.
|
|
1240
1455
|
*/
|
|
1241
|
-
description
|
|
1456
|
+
description?: string;
|
|
1242
1457
|
/**
|
|
1243
1458
|
* Lookup
|
|
1244
1459
|
*/
|
|
@@ -1249,11 +1464,25 @@ type StringField = {
|
|
|
1249
1464
|
* Field name. Used as the key in the extraction response.
|
|
1250
1465
|
*/
|
|
1251
1466
|
name: string;
|
|
1467
|
+
/**
|
|
1468
|
+
* Persistent Id
|
|
1469
|
+
*
|
|
1470
|
+
* Server-assigned stable field identity (UUID), emitted by GET /definition/. Echo it back on updates — including across renames — to keep quality metrics, ground-truth links and analytics attached to the field. Matching is scoped to the field's nesting level in the immediately-prior version; an id that matches nothing at its level, appears on more than one field, or is sent at workflow creation is rejected with 400. Omit for new fields; when omitted on an update, the server matches the field to the prior version by name.
|
|
1471
|
+
*/
|
|
1472
|
+
persistent_id?: string | null;
|
|
1252
1473
|
};
|
|
1253
1474
|
/**
|
|
1254
1475
|
* ValidateNode
|
|
1255
1476
|
*/
|
|
1256
1477
|
type ValidateNode = {
|
|
1478
|
+
/**
|
|
1479
|
+
* Field Index
|
|
1480
|
+
*
|
|
1481
|
+
* Executor-injected at run time (persistent_id → field name); never set by callers or persisted.
|
|
1482
|
+
*/
|
|
1483
|
+
field_index?: {
|
|
1484
|
+
[key: string]: string;
|
|
1485
|
+
} | null;
|
|
1257
1486
|
/**
|
|
1258
1487
|
* Id
|
|
1259
1488
|
*
|
|
@@ -1273,26 +1502,54 @@ type ValidateNode = {
|
|
|
1273
1502
|
* ValidationRule
|
|
1274
1503
|
*/
|
|
1275
1504
|
type ValidationRule = {
|
|
1505
|
+
/**
|
|
1506
|
+
* Check
|
|
1507
|
+
*
|
|
1508
|
+
* Structured deterministic check. Required when kind == 'deterministic'.
|
|
1509
|
+
*/
|
|
1510
|
+
check?: ({
|
|
1511
|
+
type: 'range';
|
|
1512
|
+
} & RangeCheck) | ({
|
|
1513
|
+
type: 'date';
|
|
1514
|
+
} & DateCheck) | ({
|
|
1515
|
+
type: 'arithmetic';
|
|
1516
|
+
} & ArithmeticCheck) | ({
|
|
1517
|
+
type: 'comparison';
|
|
1518
|
+
} & ComparisonCheck) | ({
|
|
1519
|
+
type: 'one_of';
|
|
1520
|
+
} & OneOfCheck) | ({
|
|
1521
|
+
type: 'regex';
|
|
1522
|
+
} & RegexCheck) | ({
|
|
1523
|
+
type: 'required';
|
|
1524
|
+
} & RequiredCheck) | null;
|
|
1276
1525
|
/**
|
|
1277
1526
|
* Description
|
|
1278
1527
|
*
|
|
1279
|
-
* Natural-language description
|
|
1528
|
+
* Natural-language description sent to the LLM. Required when kind == 'ai'.
|
|
1280
1529
|
*/
|
|
1281
|
-
description
|
|
1530
|
+
description?: string | null;
|
|
1282
1531
|
/**
|
|
1283
1532
|
* Id
|
|
1284
1533
|
*
|
|
1285
|
-
* Stable rule id; round-trips through
|
|
1534
|
+
* Stable rule id; round-trips through validation results.
|
|
1286
1535
|
*/
|
|
1287
1536
|
id: string;
|
|
1537
|
+
/**
|
|
1538
|
+
* Kind
|
|
1539
|
+
*
|
|
1540
|
+
* 'deterministic' = a structured check run in code — instant, free, reproducible; 'ai' = a model judges the rule description against the extraction. Prefer deterministic whenever the condition is exact and testable.
|
|
1541
|
+
*/
|
|
1542
|
+
kind?: 'ai' | 'deterministic';
|
|
1288
1543
|
/**
|
|
1289
1544
|
* Name
|
|
1290
1545
|
*
|
|
1291
|
-
* Optional human-readable rule name
|
|
1546
|
+
* Optional human-readable rule name. Round-trips through the config endpoint so renames are preserved.
|
|
1292
1547
|
*/
|
|
1293
1548
|
name?: string | null;
|
|
1294
1549
|
/**
|
|
1295
1550
|
* Severity
|
|
1551
|
+
*
|
|
1552
|
+
* How a failed rule is labelled in results. Display-level only — it never blocks the run.
|
|
1296
1553
|
*/
|
|
1297
1554
|
severity?: 'error' | 'warning';
|
|
1298
1555
|
/**
|
|
@@ -1305,7 +1562,12 @@ type ValidationRule = {
|
|
|
1305
1562
|
/**
|
|
1306
1563
|
* WorkflowCreateRequest
|
|
1307
1564
|
*
|
|
1308
|
-
* Public-surface workflow create body — typed graph of parse / classify / splitter / extract nodes.
|
|
1565
|
+
* Public-surface workflow create body — typed graph of parse / classify / splitter / extract / validate nodes.
|
|
1566
|
+
*
|
|
1567
|
+
* A ``validate`` node carries ``rules``; each rule is either AI-evaluated
|
|
1568
|
+
* (``kind="ai"`` + a natural-language ``description``) or deterministic
|
|
1569
|
+
* (``kind="deterministic"`` + a structured ``check``, evaluated in pure
|
|
1570
|
+
* Python with no model call).
|
|
1309
1571
|
*
|
|
1310
1572
|
* Defined as a thin subclass so the FastAPI-generated OpenAPI components
|
|
1311
1573
|
* entry is named ``WorkflowCreateRequest`` (FastAPI uses the model's
|
|
@@ -1328,17 +1590,35 @@ type WorkflowCreateRequest = {
|
|
|
1328
1590
|
/**
|
|
1329
1591
|
* Nodes
|
|
1330
1592
|
*/
|
|
1331
|
-
nodes: Array<
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1593
|
+
nodes: Array<ParseNode | ClassifyNode | SplitterNode | ExtractNode | ValidateNode>;
|
|
1594
|
+
};
|
|
1595
|
+
/**
|
|
1596
|
+
* _FieldOperand
|
|
1597
|
+
*/
|
|
1598
|
+
type FieldOperand = {
|
|
1599
|
+
/**
|
|
1600
|
+
* Field
|
|
1601
|
+
*
|
|
1602
|
+
* persistent_id of the compared field.
|
|
1603
|
+
*/
|
|
1604
|
+
field: string;
|
|
1605
|
+
/**
|
|
1606
|
+
* Source
|
|
1607
|
+
*/
|
|
1608
|
+
source: 'field';
|
|
1609
|
+
};
|
|
1610
|
+
/**
|
|
1611
|
+
* _LiteralOperand
|
|
1612
|
+
*/
|
|
1613
|
+
type LiteralOperand = {
|
|
1614
|
+
/**
|
|
1615
|
+
* Source
|
|
1616
|
+
*/
|
|
1617
|
+
source: 'literal';
|
|
1618
|
+
/**
|
|
1619
|
+
* Value
|
|
1620
|
+
*/
|
|
1621
|
+
value: number | string | boolean;
|
|
1342
1622
|
};
|
|
1343
1623
|
|
|
1344
1624
|
/**
|
|
@@ -1368,6 +1648,15 @@ declare class ParseView {
|
|
|
1368
1648
|
get layoutConfidence(): number | null;
|
|
1369
1649
|
}
|
|
1370
1650
|
|
|
1651
|
+
/**
|
|
1652
|
+
* One extracted field — generic over the value type so callers get real
|
|
1653
|
+
* types at the access site (`result.field<number>("total").value` is
|
|
1654
|
+
* `number | null`, not `unknown`). Wire shape identical to the codegen type.
|
|
1655
|
+
*/
|
|
1656
|
+
type ExtractedField<T = unknown> = Omit<ExtractedField$1, "value" | "value_override"> & {
|
|
1657
|
+
value: T | null;
|
|
1658
|
+
value_override?: T | null;
|
|
1659
|
+
};
|
|
1371
1660
|
/** Typed wrapper over a completed run's results. */
|
|
1372
1661
|
declare class Result {
|
|
1373
1662
|
readonly raw: ResultsResponse;
|
|
@@ -1384,8 +1673,11 @@ declare class Result {
|
|
|
1384
1673
|
* Convenience accessor for a top-level scalar field on the first
|
|
1385
1674
|
* extraction (linear workflows). Returns `undefined` for missing fields
|
|
1386
1675
|
* or list-valued fields — read `extractions` directly for those.
|
|
1676
|
+
*
|
|
1677
|
+
* Parameterise with the declared schema type to type `.value`:
|
|
1678
|
+
* `result.field<number>("total").value` is `number | null`.
|
|
1387
1679
|
*/
|
|
1388
|
-
field(name: string): ExtractedField | undefined;
|
|
1680
|
+
field<T = unknown>(name: string): ExtractedField<T> | undefined;
|
|
1389
1681
|
}
|
|
1390
1682
|
|
|
1391
1683
|
interface WaitOptions {
|
|
@@ -1408,10 +1700,27 @@ declare class Run {
|
|
|
1408
1700
|
wait(opts?: WaitOptions): Promise<Result>;
|
|
1409
1701
|
}
|
|
1410
1702
|
|
|
1703
|
+
/**
|
|
1704
|
+
* A document staged in a workflow but not yet run. Returned by
|
|
1705
|
+
* `Workflow.upload()`. Call `run()` to start extraction — uploading alone
|
|
1706
|
+
* spends no credits.
|
|
1707
|
+
*/
|
|
1708
|
+
declare class Upload {
|
|
1709
|
+
private readonly client;
|
|
1710
|
+
readonly workflowId: string;
|
|
1711
|
+
readonly collectionId: string;
|
|
1712
|
+
readonly fileId: string | null;
|
|
1713
|
+
/** @internal */
|
|
1714
|
+
constructor(client: Client, workflowId: string, collectionId: string, fileId: string | null);
|
|
1715
|
+
/** Trigger extraction on the staged file and return a pending `Run`. */
|
|
1716
|
+
run(): Promise<Run>;
|
|
1717
|
+
}
|
|
1718
|
+
|
|
1411
1719
|
/**
|
|
1412
1720
|
* A persisted workflow on the server. Returned by `WorkflowBuilder.create()`.
|
|
1413
|
-
* `run(file
|
|
1414
|
-
*
|
|
1721
|
+
* `run(file)` submits a document and returns a `Run` you can `.wait()` on.
|
|
1722
|
+
* `upload(file)` stages a document without running it; call `.run()` on the
|
|
1723
|
+
* returned `Upload` to extract.
|
|
1415
1724
|
*/
|
|
1416
1725
|
declare class Workflow {
|
|
1417
1726
|
private readonly client;
|
|
@@ -1420,9 +1729,12 @@ declare class Workflow {
|
|
|
1420
1729
|
/** @internal */
|
|
1421
1730
|
constructor(client: Client, id: string, name: string);
|
|
1422
1731
|
/** Submit a document against this workflow and return a pending `Run`. */
|
|
1423
|
-
run(file?: File | null
|
|
1424
|
-
|
|
1425
|
-
|
|
1732
|
+
run(file?: File | null): Promise<Run>;
|
|
1733
|
+
/**
|
|
1734
|
+
* Stage a document in this workflow WITHOUT running it (no credits spent).
|
|
1735
|
+
* Returns an `Upload`; call `.run()` on it to start extraction.
|
|
1736
|
+
*/
|
|
1737
|
+
upload(file?: File | null): Promise<Upload>;
|
|
1426
1738
|
}
|
|
1427
1739
|
|
|
1428
1740
|
/** Any extraction field — the discriminated union on `data_type`. */
|
|
@@ -1453,16 +1765,39 @@ declare const Schema: {
|
|
|
1453
1765
|
option: (name: string, description: string) => EnumOption;
|
|
1454
1766
|
};
|
|
1455
1767
|
|
|
1456
|
-
type
|
|
1768
|
+
type ExtractMode = "standard" | "agentic" | "max" | "lite";
|
|
1769
|
+
type AgenticEffort = "low" | "mid" | "accurate";
|
|
1770
|
+
type OcrEffort = "medium" | "high";
|
|
1771
|
+
type OcrRegion = "eu" | "global";
|
|
1772
|
+
type RoutingEffort = "minimal" | "low" | "medium" | "high";
|
|
1457
1773
|
/** Source-port label routing into an extract/validate node. */
|
|
1458
1774
|
type Branch = string | ClassifyCategory | SplitterRule;
|
|
1459
|
-
|
|
1460
|
-
|
|
1775
|
+
/** Knobs shared by every parse mode. */
|
|
1776
|
+
interface ParseOptionsBase {
|
|
1461
1777
|
promptHint?: string;
|
|
1462
1778
|
figureEnhancement?: boolean;
|
|
1463
1779
|
cache?: boolean;
|
|
1464
1780
|
id?: string;
|
|
1465
1781
|
}
|
|
1782
|
+
/**
|
|
1783
|
+
* Parse options as a `mode`-discriminated union: each mode only accepts its own knobs, so a lite
|
|
1784
|
+
* knob on `{ mode: "standard" }` is a compile-time error rather than a silent no-op. `mode` is
|
|
1785
|
+
* optional only on the standard variant (the default), required on agentic/lite.
|
|
1786
|
+
*/
|
|
1787
|
+
type ParseOptions = (ParseOptionsBase & {
|
|
1788
|
+
mode?: "standard";
|
|
1789
|
+
}) | (ParseOptionsBase & {
|
|
1790
|
+
mode: "agentic";
|
|
1791
|
+
effort?: AgenticEffort;
|
|
1792
|
+
}) | (ParseOptionsBase & {
|
|
1793
|
+
mode: "lite";
|
|
1794
|
+
ocrEffort?: OcrEffort;
|
|
1795
|
+
region?: OcrRegion;
|
|
1796
|
+
skipRoutingReview?: boolean;
|
|
1797
|
+
figures?: boolean;
|
|
1798
|
+
textFormatting?: boolean;
|
|
1799
|
+
routingEffort?: RoutingEffort;
|
|
1800
|
+
});
|
|
1466
1801
|
/**
|
|
1467
1802
|
* Fluent assembler for a typed workflow graph — a faithful TS port of the
|
|
1468
1803
|
* Python `WorkflowBuilder`. `parse`/`classify`/`split` are singletons;
|
|
@@ -1495,8 +1830,11 @@ declare class WorkflowBuilder {
|
|
|
1495
1830
|
extract(fields: Field[], opts?: {
|
|
1496
1831
|
branch?: Branch;
|
|
1497
1832
|
id?: string;
|
|
1833
|
+
mode?: ExtractMode;
|
|
1498
1834
|
lookupFiles?: string[];
|
|
1499
1835
|
lookupSuggestion?: string;
|
|
1836
|
+
lookupReasoningEffort?: RoutingEffort;
|
|
1837
|
+
useImages?: boolean;
|
|
1500
1838
|
}): this;
|
|
1501
1839
|
validate(rules: ValidationRule[], opts?: {
|
|
1502
1840
|
branch?: Branch;
|
|
@@ -1529,6 +1867,21 @@ declare class Anyformat {
|
|
|
1529
1867
|
status?: string;
|
|
1530
1868
|
}): Promise<Workflow[]>;
|
|
1531
1869
|
deleteWorkflow(workflowId: string): Promise<string>;
|
|
1870
|
+
/** Stage a document in a workflow without running it. Returns an `Upload`. */
|
|
1871
|
+
upload(workflowId: string, file?: File | null): Promise<Upload>;
|
|
1872
|
+
/** Trigger extraction on already-uploaded files. Returns a pending `Run` per file_id. */
|
|
1873
|
+
runWorkflow(workflowId: string, fileIds: string[]): Promise<Run[]>;
|
|
1874
|
+
/**
|
|
1875
|
+
* Parse a document with the platform's atomic `/parse` operation (fast lite
|
|
1876
|
+
* parse). Returns an opaque `jobId`; poll `getParseMarkdown(jobId)` for the
|
|
1877
|
+
* parsed markdown.
|
|
1878
|
+
*/
|
|
1879
|
+
parse(file: Blob | File): Promise<string>;
|
|
1880
|
+
/**
|
|
1881
|
+
* Poll a parse job. Returns the parsed markdown once the job is done, or
|
|
1882
|
+
* `null` while it is still processing.
|
|
1883
|
+
*/
|
|
1884
|
+
getParseMarkdown(jobId: string): Promise<string | null>;
|
|
1532
1885
|
}
|
|
1533
1886
|
|
|
1534
1887
|
declare class AnyformatError extends Error {
|
|
@@ -1538,22 +1891,34 @@ declare class APIError extends AnyformatError {
|
|
|
1538
1891
|
readonly body?: unknown | undefined;
|
|
1539
1892
|
constructor(status: number, message: string, body?: unknown | undefined);
|
|
1540
1893
|
}
|
|
1541
|
-
declare class
|
|
1894
|
+
declare class BadRequestError extends APIError {
|
|
1542
1895
|
}
|
|
1543
|
-
declare class
|
|
1896
|
+
declare class UnauthorizedError extends APIError {
|
|
1544
1897
|
}
|
|
1545
|
-
declare class
|
|
1898
|
+
declare class ForbiddenError extends APIError {
|
|
1546
1899
|
}
|
|
1547
|
-
declare class
|
|
1900
|
+
declare class NotFoundError extends APIError {
|
|
1548
1901
|
}
|
|
1549
|
-
declare class
|
|
1902
|
+
declare class RateLimitedError extends APIError {
|
|
1550
1903
|
}
|
|
1551
1904
|
declare class ServerError extends APIError {
|
|
1552
1905
|
}
|
|
1553
|
-
|
|
1906
|
+
/** @deprecated Use `BadRequestError`. Alias for one minor release. */
|
|
1907
|
+
declare const BadRequest: typeof BadRequestError;
|
|
1908
|
+
/** @deprecated Use `UnauthorizedError`. Alias for one minor release. */
|
|
1909
|
+
declare const Unauthorized: typeof UnauthorizedError;
|
|
1910
|
+
/** @deprecated Use `ForbiddenError`. Alias for one minor release. */
|
|
1911
|
+
declare const Forbidden: typeof ForbiddenError;
|
|
1912
|
+
/** @deprecated Use `NotFoundError`. Alias for one minor release. */
|
|
1913
|
+
declare const NotFound: typeof NotFoundError;
|
|
1914
|
+
/** @deprecated Use `RateLimitedError`. Alias for one minor release. */
|
|
1915
|
+
declare const RateLimited: typeof RateLimitedError;
|
|
1916
|
+
declare class SDKTimeoutError extends AnyformatError {
|
|
1554
1917
|
}
|
|
1918
|
+
/** @deprecated Use `SDKTimeoutError`. Alias for one minor release. */
|
|
1919
|
+
declare const SDKTimeout: typeof SDKTimeoutError;
|
|
1555
1920
|
/** Raised by the fluent `WorkflowBuilder` for builder-API misuse. */
|
|
1556
1921
|
declare class WorkflowBuilderError extends AnyformatError {
|
|
1557
1922
|
}
|
|
1558
1923
|
|
|
1559
|
-
export { APIError, Anyformat, AnyformatError, type AnyformatOptions, BadRequest, type Block, type BooleanField, type Branch, type ClassifyCategory, type DateField, type DatetimeField, type EnumField, type EnumOption, type ExtractedField, type Extraction, type ExtractionSchema, type Field, type FloatField, Forbidden, type IntegerField, type MultiSelectField, type NestedField, NotFound, type ObjectField, ParseView, RateLimited, Result, type ResultsResponse, Run, SDKTimeout, Schema, ServerError, type SplitterRule, type StringField, Unauthorized, type ValidationRule, type WaitOptions, Workflow, WorkflowBuilder, WorkflowBuilderError, type WorkflowCreateRequest };
|
|
1924
|
+
export { APIError, Anyformat, AnyformatError, type AnyformatOptions, type ArithmeticCheck, BadRequest, BadRequestError, type Block, type BooleanField, type Branch, type ClassifyCategory, type ComparisonCheck, type DateCheck, type DateField, type DatetimeField, type EnumField, type EnumOption, type ExtractedField, type Extraction, type ExtractionSchema, type Field, type FloatField, Forbidden, ForbiddenError, type IntegerField, type MultiSelectField, type NestedField, NotFound, NotFoundError, type ObjectField, type OneOfCheck, ParseView, type RangeCheck, RateLimited, RateLimitedError, type RegexCheck, type RequiredCheck, Result, type ResultsResponse, Run, SDKTimeout, SDKTimeoutError, Schema, ServerError, type SplitterRule, type StringField, Unauthorized, UnauthorizedError, Upload, type ValidationRule, type WaitOptions, Workflow, WorkflowBuilder, WorkflowBuilderError, type WorkflowCreateRequest };
|