@anyformat/sdk 0.2.1 → 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 +75 -7
- package/dist/index.cjs +354 -67
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +578 -143
- package/dist/index.d.ts +578 -143
- package/dist/index.js +345 -67
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
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,7 +740,7 @@ type Evidence = {
|
|
|
628
740
|
*/
|
|
629
741
|
type ExtractNode = {
|
|
630
742
|
/**
|
|
631
|
-
* Schema for the fields this node extracts. Required.
|
|
743
|
+
* Schema for the fields this node extracts. Required.
|
|
632
744
|
*/
|
|
633
745
|
extraction_schema: ExtractionSchema;
|
|
634
746
|
/**
|
|
@@ -640,7 +752,7 @@ type ExtractNode = {
|
|
|
640
752
|
/**
|
|
641
753
|
* Lookup File Uploads
|
|
642
754
|
*
|
|
643
|
-
* 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.
|
|
644
756
|
*/
|
|
645
757
|
lookup_file_uploads?: Array<LookupFileUpload>;
|
|
646
758
|
/**
|
|
@@ -649,30 +761,18 @@ type ExtractNode = {
|
|
|
649
761
|
* Smart-lookup reference document URIs persisted on the extract node.
|
|
650
762
|
*/
|
|
651
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;
|
|
652
770
|
/**
|
|
653
771
|
* Lookup Schema
|
|
654
772
|
*
|
|
655
|
-
* Typed schema of fields the smart-lookup pass should produce.
|
|
656
|
-
*/
|
|
657
|
-
lookup_schema?: Array<
|
|
658
|
-
data_type: 'string';
|
|
659
|
-
} & StringField) | ({
|
|
660
|
-
data_type: 'integer';
|
|
661
|
-
} & IntegerField) | ({
|
|
662
|
-
data_type: 'float';
|
|
663
|
-
} & FloatField) | ({
|
|
664
|
-
data_type: 'boolean';
|
|
665
|
-
} & BooleanField) | ({
|
|
666
|
-
data_type: 'date';
|
|
667
|
-
} & DateField) | ({
|
|
668
|
-
data_type: 'datetime';
|
|
669
|
-
} & DatetimeField) | ({
|
|
670
|
-
data_type: 'enum';
|
|
671
|
-
} & EnumField) | ({
|
|
672
|
-
data_type: 'multi_select';
|
|
673
|
-
} & MultiSelectField) | ({
|
|
674
|
-
data_type: 'object';
|
|
675
|
-
} & 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>;
|
|
676
776
|
/**
|
|
677
777
|
* Lookup Suggestion
|
|
678
778
|
*
|
|
@@ -681,14 +781,30 @@ type ExtractNode = {
|
|
|
681
781
|
lookup_suggestion?: string | null;
|
|
682
782
|
/**
|
|
683
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.
|
|
684
786
|
*/
|
|
685
|
-
mode?: 'standard' | 'agentic';
|
|
787
|
+
mode?: 'standard' | 'agentic' | 'max' | 'lite';
|
|
788
|
+
/**
|
|
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).
|
|
792
|
+
*/
|
|
793
|
+
page_sum_verification_enabled?: boolean;
|
|
794
|
+
/**
|
|
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).
|
|
798
|
+
*/
|
|
799
|
+
row_extractor_enabled?: boolean;
|
|
686
800
|
/**
|
|
687
801
|
* Type
|
|
688
802
|
*/
|
|
689
803
|
type: 'extract';
|
|
690
804
|
/**
|
|
691
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.
|
|
692
808
|
*/
|
|
693
809
|
use_images?: boolean;
|
|
694
810
|
};
|
|
@@ -697,7 +813,7 @@ type ExtractNode = {
|
|
|
697
813
|
*
|
|
698
814
|
* One extracted field's value, confidence, and supporting evidence.
|
|
699
815
|
*/
|
|
700
|
-
type ExtractedField = {
|
|
816
|
+
type ExtractedField$1 = {
|
|
701
817
|
/**
|
|
702
818
|
* Confidence
|
|
703
819
|
*
|
|
@@ -744,8 +860,8 @@ type Extraction = {
|
|
|
744
860
|
* Extracted fields keyed by field name. Same shape as the legacy top-level `extraction`.
|
|
745
861
|
*/
|
|
746
862
|
fields: {
|
|
747
|
-
[key: string]: ExtractedField | Array<{
|
|
748
|
-
[key: string]: ExtractedField;
|
|
863
|
+
[key: string]: ExtractedField$1 | Array<{
|
|
864
|
+
[key: string]: ExtractedField$1;
|
|
749
865
|
}>;
|
|
750
866
|
};
|
|
751
867
|
/**
|
|
@@ -764,16 +880,11 @@ type Extraction = {
|
|
|
764
880
|
/**
|
|
765
881
|
* ExtractionSchema
|
|
766
882
|
*
|
|
767
|
-
* Schema describing what an extract node produces.
|
|
768
|
-
* object (not a bare ``list[AnyField]``) so metadata can be added later
|
|
769
|
-
* (versioning, derived flags, output-shape hints) without another
|
|
770
|
-
* wire-format break.
|
|
883
|
+
* Schema describing what an extract node produces.
|
|
771
884
|
*
|
|
772
|
-
*
|
|
773
|
-
*
|
|
774
|
-
*
|
|
775
|
-
* any assigned fields are skipped at the executor layer rather than
|
|
776
|
-
* 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.
|
|
777
888
|
*/
|
|
778
889
|
type ExtractionSchema = {
|
|
779
890
|
/**
|
|
@@ -781,25 +892,7 @@ type ExtractionSchema = {
|
|
|
781
892
|
*
|
|
782
893
|
* Field definitions making up this extract's output.
|
|
783
894
|
*/
|
|
784
|
-
fields: Array<
|
|
785
|
-
data_type: 'string';
|
|
786
|
-
} & StringField) | ({
|
|
787
|
-
data_type: 'integer';
|
|
788
|
-
} & IntegerField) | ({
|
|
789
|
-
data_type: 'float';
|
|
790
|
-
} & FloatField) | ({
|
|
791
|
-
data_type: 'boolean';
|
|
792
|
-
} & BooleanField) | ({
|
|
793
|
-
data_type: 'date';
|
|
794
|
-
} & DateField) | ({
|
|
795
|
-
data_type: 'datetime';
|
|
796
|
-
} & DatetimeField) | ({
|
|
797
|
-
data_type: 'enum';
|
|
798
|
-
} & EnumField) | ({
|
|
799
|
-
data_type: 'multi_select';
|
|
800
|
-
} & MultiSelectField) | ({
|
|
801
|
-
data_type: 'object';
|
|
802
|
-
} & ObjectField)>;
|
|
895
|
+
fields: Array<StringField | IntegerField | FloatField | BooleanField | DateField | DatetimeField | EnumField | MultiSelectField | ObjectField>;
|
|
803
896
|
};
|
|
804
897
|
/**
|
|
805
898
|
* FilePages
|
|
@@ -839,7 +932,7 @@ type FloatField = {
|
|
|
839
932
|
*
|
|
840
933
|
* Free-form description shown to the extraction model.
|
|
841
934
|
*/
|
|
842
|
-
description
|
|
935
|
+
description?: string;
|
|
843
936
|
/**
|
|
844
937
|
* Lookup
|
|
845
938
|
*/
|
|
@@ -850,6 +943,12 @@ type FloatField = {
|
|
|
850
943
|
* Field name. Used as the key in the extraction response.
|
|
851
944
|
*/
|
|
852
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;
|
|
853
952
|
};
|
|
854
953
|
/**
|
|
855
954
|
* Hyperlink
|
|
@@ -883,7 +982,7 @@ type IntegerField = {
|
|
|
883
982
|
*
|
|
884
983
|
* Free-form description shown to the extraction model.
|
|
885
984
|
*/
|
|
886
|
-
description
|
|
985
|
+
description?: string;
|
|
887
986
|
/**
|
|
888
987
|
* Lookup
|
|
889
988
|
*/
|
|
@@ -894,6 +993,12 @@ type IntegerField = {
|
|
|
894
993
|
* Field name. Used as the key in the extraction response.
|
|
895
994
|
*/
|
|
896
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;
|
|
897
1002
|
};
|
|
898
1003
|
/**
|
|
899
1004
|
* LookupFileUpload
|
|
@@ -901,9 +1006,9 @@ type IntegerField = {
|
|
|
901
1006
|
* Inline lookup-file content carried on the typed create call.
|
|
902
1007
|
*
|
|
903
1008
|
* The backend reads ``filename`` + ``content`` (base64-encoded bytes),
|
|
904
|
-
* uploads the file
|
|
905
|
-
*
|
|
906
|
-
*
|
|
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.
|
|
907
1012
|
*/
|
|
908
1013
|
type LookupFileUpload = {
|
|
909
1014
|
/**
|
|
@@ -930,7 +1035,7 @@ type MultiSelectField = {
|
|
|
930
1035
|
*
|
|
931
1036
|
* Free-form description shown to the extraction model.
|
|
932
1037
|
*/
|
|
933
|
-
description
|
|
1038
|
+
description?: string;
|
|
934
1039
|
/**
|
|
935
1040
|
* Enum Options
|
|
936
1041
|
*/
|
|
@@ -945,6 +1050,12 @@ type MultiSelectField = {
|
|
|
945
1050
|
* Field name. Used as the key in the extraction response.
|
|
946
1051
|
*/
|
|
947
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;
|
|
948
1059
|
};
|
|
949
1060
|
/**
|
|
950
1061
|
* ObjectField
|
|
@@ -959,7 +1070,7 @@ type ObjectField = {
|
|
|
959
1070
|
*
|
|
960
1071
|
* Free-form description shown to the extraction model.
|
|
961
1072
|
*/
|
|
962
|
-
description
|
|
1073
|
+
description?: string;
|
|
963
1074
|
/**
|
|
964
1075
|
* Lookup
|
|
965
1076
|
*/
|
|
@@ -972,35 +1083,66 @@ type ObjectField = {
|
|
|
972
1083
|
name: string;
|
|
973
1084
|
/**
|
|
974
1085
|
* Nested Fields
|
|
1086
|
+
*
|
|
1087
|
+
* Child fields of this object. Only one level of nesting is supported — an object field's children must be non-object types.
|
|
975
1088
|
*/
|
|
976
|
-
nested_fields: Array<
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
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';
|
|
995
1117
|
};
|
|
996
1118
|
/**
|
|
997
1119
|
* ParseNode
|
|
998
1120
|
*/
|
|
999
1121
|
type ParseNode = {
|
|
1122
|
+
/**
|
|
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.
|
|
1126
|
+
*/
|
|
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';
|
|
1000
1134
|
/**
|
|
1001
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).
|
|
1002
1138
|
*/
|
|
1003
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;
|
|
1004
1146
|
/**
|
|
1005
1147
|
* Id
|
|
1006
1148
|
*
|
|
@@ -1009,14 +1151,46 @@ type ParseNode = {
|
|
|
1009
1151
|
id: string;
|
|
1010
1152
|
/**
|
|
1011
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.
|
|
1156
|
+
*/
|
|
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`.)
|
|
1012
1162
|
*/
|
|
1013
|
-
|
|
1163
|
+
ocr_effort?: 'medium' | 'high';
|
|
1014
1164
|
/**
|
|
1015
1165
|
* Prompt Hint
|
|
1016
1166
|
*
|
|
1017
|
-
* 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.
|
|
1018
1168
|
*/
|
|
1019
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;
|
|
1020
1194
|
/**
|
|
1021
1195
|
* Type
|
|
1022
1196
|
*/
|
|
@@ -1059,6 +1233,61 @@ type ParseResult = {
|
|
|
1059
1233
|
*/
|
|
1060
1234
|
text?: string | null;
|
|
1061
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
|
+
};
|
|
1062
1291
|
/**
|
|
1063
1292
|
* ResultsResponse
|
|
1064
1293
|
*
|
|
@@ -1088,8 +1317,8 @@ type ResultsResponse = {
|
|
|
1088
1317
|
* @deprecated
|
|
1089
1318
|
*/
|
|
1090
1319
|
extraction?: {
|
|
1091
|
-
[key: string]: ExtractedField | Array<{
|
|
1092
|
-
[key: string]: ExtractedField;
|
|
1320
|
+
[key: string]: ExtractedField$1 | Array<{
|
|
1321
|
+
[key: string]: ExtractedField$1;
|
|
1093
1322
|
}>;
|
|
1094
1323
|
} | null;
|
|
1095
1324
|
/**
|
|
@@ -1206,6 +1435,8 @@ type SplitterRule = {
|
|
|
1206
1435
|
name: string;
|
|
1207
1436
|
/**
|
|
1208
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.
|
|
1209
1440
|
*/
|
|
1210
1441
|
partition_key?: string;
|
|
1211
1442
|
};
|
|
@@ -1222,7 +1453,7 @@ type StringField = {
|
|
|
1222
1453
|
*
|
|
1223
1454
|
* Free-form description shown to the extraction model.
|
|
1224
1455
|
*/
|
|
1225
|
-
description
|
|
1456
|
+
description?: string;
|
|
1226
1457
|
/**
|
|
1227
1458
|
* Lookup
|
|
1228
1459
|
*/
|
|
@@ -1233,11 +1464,25 @@ type StringField = {
|
|
|
1233
1464
|
* Field name. Used as the key in the extraction response.
|
|
1234
1465
|
*/
|
|
1235
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;
|
|
1236
1473
|
};
|
|
1237
1474
|
/**
|
|
1238
1475
|
* ValidateNode
|
|
1239
1476
|
*/
|
|
1240
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;
|
|
1241
1486
|
/**
|
|
1242
1487
|
* Id
|
|
1243
1488
|
*
|
|
@@ -1257,26 +1502,54 @@ type ValidateNode = {
|
|
|
1257
1502
|
* ValidationRule
|
|
1258
1503
|
*/
|
|
1259
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;
|
|
1260
1525
|
/**
|
|
1261
1526
|
* Description
|
|
1262
1527
|
*
|
|
1263
|
-
* Natural-language description
|
|
1528
|
+
* Natural-language description sent to the LLM. Required when kind == 'ai'.
|
|
1264
1529
|
*/
|
|
1265
|
-
description
|
|
1530
|
+
description?: string | null;
|
|
1266
1531
|
/**
|
|
1267
1532
|
* Id
|
|
1268
1533
|
*
|
|
1269
|
-
* Stable rule id; round-trips through
|
|
1534
|
+
* Stable rule id; round-trips through validation results.
|
|
1270
1535
|
*/
|
|
1271
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';
|
|
1272
1543
|
/**
|
|
1273
1544
|
* Name
|
|
1274
1545
|
*
|
|
1275
|
-
* Optional human-readable rule name
|
|
1546
|
+
* Optional human-readable rule name. Round-trips through the config endpoint so renames are preserved.
|
|
1276
1547
|
*/
|
|
1277
1548
|
name?: string | null;
|
|
1278
1549
|
/**
|
|
1279
1550
|
* Severity
|
|
1551
|
+
*
|
|
1552
|
+
* How a failed rule is labelled in results. Display-level only — it never blocks the run.
|
|
1280
1553
|
*/
|
|
1281
1554
|
severity?: 'error' | 'warning';
|
|
1282
1555
|
/**
|
|
@@ -1289,7 +1562,12 @@ type ValidationRule = {
|
|
|
1289
1562
|
/**
|
|
1290
1563
|
* WorkflowCreateRequest
|
|
1291
1564
|
*
|
|
1292
|
-
* 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).
|
|
1293
1571
|
*
|
|
1294
1572
|
* Defined as a thin subclass so the FastAPI-generated OpenAPI components
|
|
1295
1573
|
* entry is named ``WorkflowCreateRequest`` (FastAPI uses the model's
|
|
@@ -1312,62 +1590,160 @@ type WorkflowCreateRequest = {
|
|
|
1312
1590
|
/**
|
|
1313
1591
|
* Nodes
|
|
1314
1592
|
*/
|
|
1315
|
-
nodes: Array<
|
|
1316
|
-
type: 'parse';
|
|
1317
|
-
} & ParseNode) | ({
|
|
1318
|
-
type: 'classify';
|
|
1319
|
-
} & ClassifyNode) | ({
|
|
1320
|
-
type: 'splitter';
|
|
1321
|
-
} & SplitterNode) | ({
|
|
1322
|
-
type: 'extract';
|
|
1323
|
-
} & ExtractNode) | ({
|
|
1324
|
-
type: 'validate';
|
|
1325
|
-
} & ValidateNode)>;
|
|
1593
|
+
nodes: Array<ParseNode | ClassifyNode | SplitterNode | ExtractNode | ValidateNode>;
|
|
1326
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;
|
|
1622
|
+
};
|
|
1623
|
+
|
|
1624
|
+
/**
|
|
1625
|
+
* Typed view over the parse node's output. Returned by `Result.parse` — readers
|
|
1626
|
+
* use it for `.markdown`, `.text`, `.blocks`, `.parseConfidence`, and
|
|
1627
|
+
* `.layoutConfidence` without having to walk `result.raw.parse`.
|
|
1628
|
+
*
|
|
1629
|
+
* No `.draw()` here: rasterising pages requires PDF rendering (pdfium); the
|
|
1630
|
+
* Python SDK ships that, the TS SDK does not.
|
|
1631
|
+
*/
|
|
1632
|
+
declare class ParseView {
|
|
1633
|
+
private readonly parse;
|
|
1634
|
+
/** @internal */
|
|
1635
|
+
constructor(parse: ParseResult);
|
|
1636
|
+
get markdown(): string | null;
|
|
1637
|
+
get text(): string | null;
|
|
1638
|
+
get blocks(): Block[];
|
|
1639
|
+
/**
|
|
1640
|
+
* Document-level confidence (0-100) in the parsed content. May be `null` for
|
|
1641
|
+
* some parse modes — fall back to `layoutConfidence`.
|
|
1642
|
+
*/
|
|
1643
|
+
get parseConfidence(): number | null;
|
|
1644
|
+
/**
|
|
1645
|
+
* Document-level confidence (0-100) in the page layout (block positions).
|
|
1646
|
+
* `null` when not available.
|
|
1647
|
+
*/
|
|
1648
|
+
get layoutConfidence(): number | null;
|
|
1649
|
+
}
|
|
1327
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
|
+
};
|
|
1328
1660
|
/** Typed wrapper over a completed run's results. */
|
|
1329
1661
|
declare class Result {
|
|
1330
1662
|
readonly raw: ResultsResponse;
|
|
1663
|
+
private _parse;
|
|
1331
1664
|
constructor(raw: ResultsResponse);
|
|
1332
1665
|
get collectionId(): string;
|
|
1333
1666
|
get extractions(): Extraction[];
|
|
1667
|
+
/**
|
|
1668
|
+
* Typed view over the parse node's output, or `null` when the workflow has
|
|
1669
|
+
* no parse node. Cached so repeated access doesn't re-wrap.
|
|
1670
|
+
*/
|
|
1671
|
+
get parse(): ParseView | null;
|
|
1334
1672
|
/**
|
|
1335
1673
|
* Convenience accessor for a top-level scalar field on the first
|
|
1336
1674
|
* extraction (linear workflows). Returns `undefined` for missing fields
|
|
1337
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`.
|
|
1338
1679
|
*/
|
|
1339
|
-
field(name: string): ExtractedField | undefined;
|
|
1680
|
+
field<T = unknown>(name: string): ExtractedField<T> | undefined;
|
|
1340
1681
|
}
|
|
1341
1682
|
|
|
1342
1683
|
interface WaitOptions {
|
|
1343
|
-
/** Overall budget before giving up. Default
|
|
1684
|
+
/** Overall budget before giving up. Default 300 000 ms (300s). */
|
|
1344
1685
|
timeoutMs?: number;
|
|
1345
|
-
/** Delay between result polls. Default
|
|
1686
|
+
/** Delay between result polls. Default 3 000 ms (3s). */
|
|
1346
1687
|
pollMs?: number;
|
|
1347
1688
|
}
|
|
1348
1689
|
/**
|
|
1349
|
-
* A
|
|
1350
|
-
*
|
|
1690
|
+
* A submitted run. `wait()` polls for completion. Created eagerly by
|
|
1691
|
+
* `Workflow.run()` — the workflow + file submission have already happened
|
|
1692
|
+
* by the time you hold a `Run`.
|
|
1351
1693
|
*/
|
|
1352
1694
|
declare class Run {
|
|
1353
1695
|
private readonly client;
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
private collectionId;
|
|
1359
|
-
constructor(client: Client, request: WorkflowCreateRequest, file: Blob | File | null, text: string | null);
|
|
1360
|
-
/**
|
|
1361
|
-
* Create the workflow and submit the document — exactly once per `Run`.
|
|
1362
|
-
* Memoized so that retrying `wait()` after an `SDKTimeout` resumes polling
|
|
1363
|
-
* the in-flight run instead of creating a duplicate workflow + submission.
|
|
1364
|
-
*/
|
|
1365
|
-
private submit;
|
|
1696
|
+
readonly workflowId: string;
|
|
1697
|
+
readonly id: string;
|
|
1698
|
+
/** @internal */
|
|
1699
|
+
constructor(client: Client, workflowId: string, id: string);
|
|
1366
1700
|
wait(opts?: WaitOptions): Promise<Result>;
|
|
1367
1701
|
}
|
|
1368
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
|
+
|
|
1719
|
+
/**
|
|
1720
|
+
* A persisted workflow on the server. Returned by `WorkflowBuilder.create()`.
|
|
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.
|
|
1724
|
+
*/
|
|
1725
|
+
declare class Workflow {
|
|
1726
|
+
private readonly client;
|
|
1727
|
+
readonly id: string;
|
|
1728
|
+
readonly name: string;
|
|
1729
|
+
/** @internal */
|
|
1730
|
+
constructor(client: Client, id: string, name: string);
|
|
1731
|
+
/** Submit a document against this workflow and return a pending `Run`. */
|
|
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>;
|
|
1738
|
+
}
|
|
1739
|
+
|
|
1369
1740
|
/** Any extraction field — the discriminated union on `data_type`. */
|
|
1370
1741
|
type Field = ExtractionSchema["fields"][number];
|
|
1742
|
+
/**
|
|
1743
|
+
* A field that may appear inside an object. Excludes `object`: only one
|
|
1744
|
+
* level of nesting is supported, so objects cannot contain objects.
|
|
1745
|
+
*/
|
|
1746
|
+
type NestedField = ObjectField["nested_fields"][number];
|
|
1371
1747
|
type LookupOpt = {
|
|
1372
1748
|
lookup?: boolean;
|
|
1373
1749
|
};
|
|
@@ -1385,24 +1761,49 @@ declare const Schema: {
|
|
|
1385
1761
|
datetime: (name: string, description: string, opts?: LookupOpt) => DatetimeField;
|
|
1386
1762
|
enum: (name: string, description: string, options: EnumOption[], opts?: LookupOpt) => EnumField;
|
|
1387
1763
|
multiSelect: (name: string, description: string, options: EnumOption[], opts?: LookupOpt) => MultiSelectField;
|
|
1388
|
-
object: (name: string, description: string, fields:
|
|
1764
|
+
object: (name: string, description: string, fields: NestedField[], opts?: LookupOpt) => ObjectField;
|
|
1389
1765
|
option: (name: string, description: string) => EnumOption;
|
|
1390
1766
|
};
|
|
1391
1767
|
|
|
1392
|
-
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";
|
|
1393
1773
|
/** Source-port label routing into an extract/validate node. */
|
|
1394
1774
|
type Branch = string | ClassifyCategory | SplitterRule;
|
|
1395
|
-
|
|
1396
|
-
|
|
1775
|
+
/** Knobs shared by every parse mode. */
|
|
1776
|
+
interface ParseOptionsBase {
|
|
1397
1777
|
promptHint?: string;
|
|
1398
1778
|
figureEnhancement?: boolean;
|
|
1779
|
+
cache?: boolean;
|
|
1399
1780
|
id?: string;
|
|
1400
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
|
+
});
|
|
1401
1801
|
/**
|
|
1402
1802
|
* Fluent assembler for a typed workflow graph — a faithful TS port of the
|
|
1403
1803
|
* Python `WorkflowBuilder`. `parse`/`classify`/`split` are singletons;
|
|
1404
1804
|
* `extract`/`validate` are repeatable and carry their edge metadata. Call
|
|
1405
|
-
* `build()` (or `create()
|
|
1805
|
+
* `build()` (or `create()`) to emit the wire request — submit with
|
|
1806
|
+
* `Workflow.run(file)` on the handle that `create()` returns.
|
|
1406
1807
|
*/
|
|
1407
1808
|
declare class WorkflowBuilder {
|
|
1408
1809
|
private readonly client;
|
|
@@ -1429,8 +1830,11 @@ declare class WorkflowBuilder {
|
|
|
1429
1830
|
extract(fields: Field[], opts?: {
|
|
1430
1831
|
branch?: Branch;
|
|
1431
1832
|
id?: string;
|
|
1833
|
+
mode?: ExtractMode;
|
|
1432
1834
|
lookupFiles?: string[];
|
|
1433
1835
|
lookupSuggestion?: string;
|
|
1836
|
+
lookupReasoningEffort?: RoutingEffort;
|
|
1837
|
+
useImages?: boolean;
|
|
1434
1838
|
}): this;
|
|
1435
1839
|
validate(rules: ValidationRule[], opts?: {
|
|
1436
1840
|
branch?: Branch;
|
|
@@ -1440,12 +1844,10 @@ declare class WorkflowBuilder {
|
|
|
1440
1844
|
private normalizeExtractBranch;
|
|
1441
1845
|
/** Assemble the wire request (branch-routed edges). Pure — no network. */
|
|
1442
1846
|
build(): WorkflowCreateRequest;
|
|
1443
|
-
/** Persist the workflow and return
|
|
1444
|
-
create(): Promise<
|
|
1445
|
-
/**
|
|
1446
|
-
|
|
1447
|
-
text?: string;
|
|
1448
|
-
}): Run;
|
|
1847
|
+
/** Persist the workflow and return a handle you can `.run(file)` on. */
|
|
1848
|
+
create(): Promise<Workflow>;
|
|
1849
|
+
/** Replace an existing workflow's definition and return a handle you can `.run(file)` on. */
|
|
1850
|
+
update(workflowId: string): Promise<Workflow>;
|
|
1449
1851
|
}
|
|
1450
1852
|
|
|
1451
1853
|
interface AnyformatOptions {
|
|
@@ -1459,6 +1861,27 @@ declare class Anyformat {
|
|
|
1459
1861
|
readonly _client: Client;
|
|
1460
1862
|
constructor(opts: AnyformatOptions);
|
|
1461
1863
|
workflow(name: string, description?: string): WorkflowBuilder;
|
|
1864
|
+
listWorkflows(opts?: {
|
|
1865
|
+
page?: number;
|
|
1866
|
+
pageSize?: number;
|
|
1867
|
+
status?: string;
|
|
1868
|
+
}): Promise<Workflow[]>;
|
|
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>;
|
|
1462
1885
|
}
|
|
1463
1886
|
|
|
1464
1887
|
declare class AnyformatError extends Error {
|
|
@@ -1468,22 +1891,34 @@ declare class APIError extends AnyformatError {
|
|
|
1468
1891
|
readonly body?: unknown | undefined;
|
|
1469
1892
|
constructor(status: number, message: string, body?: unknown | undefined);
|
|
1470
1893
|
}
|
|
1471
|
-
declare class
|
|
1894
|
+
declare class BadRequestError extends APIError {
|
|
1472
1895
|
}
|
|
1473
|
-
declare class
|
|
1896
|
+
declare class UnauthorizedError extends APIError {
|
|
1474
1897
|
}
|
|
1475
|
-
declare class
|
|
1898
|
+
declare class ForbiddenError extends APIError {
|
|
1476
1899
|
}
|
|
1477
|
-
declare class
|
|
1900
|
+
declare class NotFoundError extends APIError {
|
|
1478
1901
|
}
|
|
1479
|
-
declare class
|
|
1902
|
+
declare class RateLimitedError extends APIError {
|
|
1480
1903
|
}
|
|
1481
1904
|
declare class ServerError extends APIError {
|
|
1482
1905
|
}
|
|
1483
|
-
|
|
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 {
|
|
1484
1917
|
}
|
|
1918
|
+
/** @deprecated Use `SDKTimeoutError`. Alias for one minor release. */
|
|
1919
|
+
declare const SDKTimeout: typeof SDKTimeoutError;
|
|
1485
1920
|
/** Raised by the fluent `WorkflowBuilder` for builder-API misuse. */
|
|
1486
1921
|
declare class WorkflowBuilderError extends AnyformatError {
|
|
1487
1922
|
}
|
|
1488
1923
|
|
|
1489
|
-
export { APIError, Anyformat, AnyformatError, type AnyformatOptions, BadRequest, 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, NotFound, type ObjectField, RateLimited, Result, type ResultsResponse, Run, SDKTimeout, Schema, ServerError, type SplitterRule, type StringField, Unauthorized, type ValidationRule, type WaitOptions, 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 };
|