@anyformat/sdk 0.2.3 → 1.0.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -319,6 +319,51 @@ interface TDataShape {
319
319
  type OmitKeys<T, K> = Pick<T, Exclude<keyof T, K>>;
320
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'>);
321
321
 
322
+ /**
323
+ * AllOfCheck
324
+ *
325
+ * AND combinator — passes iff every sub-check passes.
326
+ *
327
+ * Tri-state: FAIL if any child fails; else INCONCLUSIVE if any child is
328
+ * inconclusive; else PASS. Children are the same closed ``Check`` union
329
+ * (mutual recursion via forward ref) so combinators nest by construction —
330
+ * the CheckBuilder UI restricts nesting to a single level for MVP.
331
+ *
332
+ * ``max_length=32`` bounds runaway fan-out per combinator. Practical rules
333
+ * stay well below the cap; a legitimate use case wanting more should motivate
334
+ * the raise rather than land silently. Nesting-depth is bounded by pydantic's
335
+ * own recursion during parse.
336
+ */
337
+ type AllOfCheck = {
338
+ /**
339
+ * Checks
340
+ */
341
+ checks: Array<RangeCheck | DateCheck | ArithmeticCheck | ComparisonCheck | OneOfCheck | RegexCheck | RequiredCheck | ConfidenceCheck | ExpressionCheck | ValidationCheck | AllOfCheck | AnyOfCheck>;
342
+ /**
343
+ * Type
344
+ */
345
+ type: 'all_of';
346
+ };
347
+ /**
348
+ * AnyOfCheck
349
+ *
350
+ * OR combinator — passes iff any sub-check passes.
351
+ *
352
+ * Tri-state: PASS if any child passes; else INCONCLUSIVE if any child is
353
+ * inconclusive; else FAIL.
354
+ *
355
+ * ``max_length=32`` — see :class:`AllOfCheck` for the rationale.
356
+ */
357
+ type AnyOfCheck = {
358
+ /**
359
+ * Checks
360
+ */
361
+ checks: Array<RangeCheck | DateCheck | ArithmeticCheck | ComparisonCheck | OneOfCheck | RegexCheck | RequiredCheck | ConfidenceCheck | ExpressionCheck | ValidationCheck | AllOfCheck | AnyOfCheck>;
362
+ /**
363
+ * Type
364
+ */
365
+ type: 'any_of';
366
+ };
322
367
  /**
323
368
  * ArithmeticCheck
324
369
  */
@@ -326,13 +371,13 @@ type ArithmeticCheck = {
326
371
  /**
327
372
  * Equals
328
373
  *
329
- * persistent_id whose value the result must equal.
374
+ * The field whose value the result must equal. Either the field's ``persistent_id`` (Studio field-picker path) or its ``sanitized_name`` as it appears in the extraction response (SDK/API/assistant path) — the executor resolves both.
330
375
  */
331
376
  equals: string;
332
377
  /**
333
378
  * Operands
334
379
  *
335
- * persistent_ids combined by `operator`.
380
+ * The fields combined by `operator`. Either the field's ``persistent_id`` (Studio field-picker path) or its ``sanitized_name`` as it appears in the extraction response (SDK/API/assistant path) — the executor resolves both.
336
381
  */
337
382
  operands: Array<string>;
338
383
  /**
@@ -398,9 +443,9 @@ type Block = {
398
443
  /**
399
444
  * Layout Confidence
400
445
  *
401
- * 0-100 YOLO layout detection confidence for this block.
446
+ * 0-1 layout detection confidence for this block. `null` when no layout detector ran — the `lite` tier gets its layout from the OCR response, which reports no confidence in the type it assigned.
402
447
  */
403
- layout_confidence: number;
448
+ layout_confidence?: number | null;
404
449
  /**
405
450
  * Page
406
451
  *
@@ -413,6 +458,12 @@ type Block = {
413
458
  * 0-100 parse confidence calibrated from LLM logprobs. `null` when logprobs were unavailable (e.g. text-bytes strategy).
414
459
  */
415
460
  parse_confidence?: number | null;
461
+ /**
462
+ * Regions
463
+ *
464
+ * The layout detections this block is made of, each with the words printed inside it. A block the detector reported as one box has one region, that box. Empty only for a block parsed before detections were reported, or one that has no box at all.
465
+ */
466
+ regions?: Array<Detection>;
416
467
  /**
417
468
  * Rows
418
469
  *
@@ -442,10 +493,6 @@ type BooleanField = {
442
493
  * Free-form description shown to the extraction model.
443
494
  */
444
495
  description?: string;
445
- /**
446
- * Lookup
447
- */
448
- lookup?: boolean;
449
496
  /**
450
497
  * Name
451
498
  *
@@ -455,9 +502,15 @@ type BooleanField = {
455
502
  /**
456
503
  * Persistent Id
457
504
  *
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.
505
+ * 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 only for genuinely new fields: there is no matching by name, so a field sent without one is always treated as new and minted a fresh id, silently detaching that field's metrics, ground truth and analytics.
459
506
  */
460
507
  persistent_id?: string | null;
508
+ /**
509
+ * Source
510
+ *
511
+ * How the field gets its value: extraction (from the document), smart_lookup (from the lookup file, always overwrites) or lookup_if_missing (extracted too; the lookup only fills it where extraction left no value).
512
+ */
513
+ source?: 'extraction' | 'smart_lookup' | 'lookup_if_missing';
461
514
  };
462
515
  /**
463
516
  * ClassificationResult
@@ -474,9 +527,9 @@ type ClassificationResult = {
474
527
  /**
475
528
  * Confidence
476
529
  *
477
- * 0-100 model confidence in the verdict.
530
+ * 0-100 model confidence in the verdict. `null` when the verdict carries no score, because nothing was measured.
478
531
  */
479
- confidence: number;
532
+ confidence: number | null;
480
533
  /**
481
534
  * Evidence
482
535
  *
@@ -539,7 +592,7 @@ type ComparisonCheck = {
539
592
  /**
540
593
  * Left
541
594
  *
542
- * persistent_id of the left-hand field.
595
+ * The left-hand field. Either the field's ``persistent_id`` (Studio field-picker path) or its ``sanitized_name`` as it appears in the extraction response (SDK/API/assistant path) — the executor resolves both.
543
596
  */
544
597
  left: string;
545
598
  /**
@@ -559,6 +612,84 @@ type ComparisonCheck = {
559
612
  */
560
613
  type: 'comparison';
561
614
  };
615
+ /**
616
+ * ConfidenceCheck
617
+ */
618
+ type ConfidenceCheck = {
619
+ /**
620
+ * Field
621
+ *
622
+ * The field whose extraction confidence to compare. Either the field's ``persistent_id`` (Studio field-picker path) or its ``sanitized_name`` as it appears in the extraction response (SDK/API/assistant path) — the executor resolves both.
623
+ */
624
+ field: string;
625
+ /**
626
+ * Op
627
+ */
628
+ op: '<' | '<=' | '>' | '>=' | '==' | '!=';
629
+ /**
630
+ * Threshold
631
+ *
632
+ * Confidence percentile 0..100.
633
+ */
634
+ threshold: number;
635
+ /**
636
+ * Type
637
+ */
638
+ type: 'confidence';
639
+ };
640
+ /**
641
+ * DatasetUploadFileV3
642
+ *
643
+ * Per-file entry in a dataset-upload response.
644
+ */
645
+ type DatasetUploadFileV3 = {
646
+ /**
647
+ * Id
648
+ *
649
+ * Unique identifier of the file (hyphenated UUID).
650
+ */
651
+ id: string;
652
+ /**
653
+ * Name
654
+ *
655
+ * Filename the file is stored under.
656
+ */
657
+ name: string;
658
+ /**
659
+ * Original Name
660
+ *
661
+ * The name you uploaded, present only when the file was auto-renamed (`on_conflict=rename` resolving a collision). `null` when the stored `name` is the name you sent.
662
+ */
663
+ original_name?: string | null;
664
+ };
665
+ /**
666
+ * DatasetUploadResponseV3
667
+ *
668
+ * Response for `POST /v3/workflows/{workflow_id}/dataset/upload/`.
669
+ *
670
+ * One dataset document packet, all-or-nothing. `document_packet_id` is the
671
+ * stable handle for the deferred ground-truth-edit follow-up.
672
+ */
673
+ type DatasetUploadResponseV3 = {
674
+ /**
675
+ * Document Packet Id
676
+ *
677
+ * Unique identifier of the created dataset document packet (hyphenated UUID).
678
+ */
679
+ document_packet_id: string;
680
+ /**
681
+ * Files
682
+ *
683
+ * Files in the packet, in the order they were provided.
684
+ */
685
+ files: Array<DatasetUploadFileV3>;
686
+ /**
687
+ * Ground Truth Saved
688
+ *
689
+ * Whether ground truth was supplied and saved for this document packet.
690
+ */
691
+ ground_truth_saved: boolean;
692
+ };
562
693
  /**
563
694
  * DateCheck
564
695
  */
@@ -570,7 +701,7 @@ type DateCheck = {
570
701
  /**
571
702
  * Field
572
703
  *
573
- * persistent_id of the date field.
704
+ * The date field. Either the field's ``persistent_id`` (Studio field-picker path) or its ``sanitized_name`` as it appears in the extraction response (SDK/API/assistant path) — the executor resolves both.
574
705
  */
575
706
  field: string;
576
707
  /**
@@ -596,10 +727,6 @@ type DateField = {
596
727
  * Free-form description shown to the extraction model.
597
728
  */
598
729
  description?: string;
599
- /**
600
- * Lookup
601
- */
602
- lookup?: boolean;
603
730
  /**
604
731
  * Name
605
732
  *
@@ -609,9 +736,15 @@ type DateField = {
609
736
  /**
610
737
  * Persistent Id
611
738
  *
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.
739
+ * 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 only for genuinely new fields: there is no matching by name, so a field sent without one is always treated as new and minted a fresh id, silently detaching that field's metrics, ground truth and analytics.
613
740
  */
614
741
  persistent_id?: string | null;
742
+ /**
743
+ * Source
744
+ *
745
+ * How the field gets its value: extraction (from the document), smart_lookup (from the lookup file, always overwrites) or lookup_if_missing (extracted too; the lookup only fills it where extraction left no value).
746
+ */
747
+ source?: 'extraction' | 'smart_lookup' | 'lookup_if_missing';
615
748
  };
616
749
  /**
617
750
  * DatetimeField
@@ -627,10 +760,6 @@ type DatetimeField = {
627
760
  * Free-form description shown to the extraction model.
628
761
  */
629
762
  description?: string;
630
- /**
631
- * Lookup
632
- */
633
- lookup?: boolean;
634
763
  /**
635
764
  * Name
636
765
  *
@@ -640,217 +769,438 @@ type DatetimeField = {
640
769
  /**
641
770
  * Persistent Id
642
771
  *
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.
772
+ * 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 only for genuinely new fields: there is no matching by name, so a field sent without one is always treated as new and minted a fresh id, silently detaching that field's metrics, ground truth and analytics.
644
773
  */
645
774
  persistent_id?: string | null;
775
+ /**
776
+ * Source
777
+ *
778
+ * How the field gets its value: extraction (from the document), smart_lookup (from the lookup file, always overwrites) or lookup_if_missing (extracted too; the lookup only fills it where extraction left no value).
779
+ */
780
+ source?: 'extraction' | 'smart_lookup' | 'lookup_if_missing';
646
781
  };
647
782
  /**
648
- * Edge
783
+ * Detection
649
784
  *
650
- * A directed edge between two nodes. ``branch`` carries the source-port label
651
- * used for routing out of ``classify`` (category id) or ``splitter`` (rule id) nodes.
785
+ * One layout detection a block is made of: where it is and what is printed inside it.
786
+ *
787
+ * A block is often the fusion of several detections, and a consumer that has to point at what
788
+ * the page prints needs the parts, not only their union.
652
789
  */
653
- type Edge = {
790
+ type Detection = {
654
791
  /**
655
- * Branch
792
+ * Bbox
656
793
  *
657
- * Source-port label for branch routing. Required when leaving a classify or splitter node by category/rule.
794
+ * Normalised bounding box in [0, 1] page coordinates with keys `x0`/`y0`/`x1`/`y1`.
658
795
  */
659
- branch?: string | null;
796
+ bbox: {
797
+ [key: string]: number;
798
+ };
660
799
  /**
661
- * Source
800
+ * Text
801
+ *
802
+ * The words the page prints inside this box.
662
803
  */
663
- source: string;
804
+ text: string;
664
805
  /**
665
- * Target
806
+ * Type
807
+ *
808
+ * What the layout detector called this box.
666
809
  */
667
- target: string;
810
+ type: string;
668
811
  };
669
812
  /**
670
- * EnumField
813
+ * DocumentPacketDetailV3
814
+ *
815
+ * A packet with its per-file breakdown and latest run reference.
671
816
  */
672
- type EnumField = {
817
+ type DocumentPacketDetailV3 = {
673
818
  /**
674
- * Data Type
819
+ * Created At
820
+ *
821
+ * Timestamp when the packet was created (ISO 8601).
675
822
  */
676
- data_type: 'enum';
823
+ created_at?: string | null;
677
824
  /**
678
- * Description
825
+ * Files
679
826
  *
680
- * Free-form description shown to the extraction model.
827
+ * Files in this packet.
681
828
  */
682
- description?: string;
829
+ files: Array<DocumentPacketFileV3>;
683
830
  /**
684
- * Enum Options
831
+ * Id
832
+ *
833
+ * Unique identifier of the document packet (hyphenated UUID).
685
834
  */
686
- enum_options: Array<EnumOption>;
835
+ id: string;
687
836
  /**
688
- * Lookup
837
+ * Latest Run Id
838
+ *
839
+ * Id of the packet's most recent run (hyphenated UUID); `null` until the packet has been run.
689
840
  */
690
- lookup?: boolean;
841
+ latest_run_id?: string | null;
691
842
  /**
692
- * Name
843
+ * Metadata
693
844
  *
694
- * Field name. Used as the key in the extraction response.
845
+ * Free-form JSON supplied at packet creation. No schema is enforced; the extract operator may source datapoints from a top-level key whose name matches a schema field. `null` when no metadata was attached.
695
846
  */
696
- name: string;
847
+ metadata?: {
848
+ [key: string]: unknown;
849
+ } | null;
697
850
  /**
698
- * Persistent Id
851
+ * Name
699
852
  *
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.
853
+ * Human-readable name of the packet.
701
854
  */
702
- persistent_id?: string | null;
703
- };
704
- /**
705
- * EnumOption
706
- */
707
- type EnumOption = {
855
+ name?: string | null;
708
856
  /**
709
- * Description
857
+ * Processing status. Non-terminal: `not_started`, `queued`, `in_progress`. Terminal: `processed` (success), `error`, `cancelled`.
858
+ */
859
+ status: DocumentPacketStatus;
860
+ /**
861
+ * Updated At
710
862
  *
711
- * Free-form description shown to the model.
863
+ * Timestamp when the packet was last updated (ISO 8601).
712
864
  */
713
- description: string;
865
+ updated_at?: string | null;
714
866
  /**
715
- * Name
867
+ * Workflow Id
868
+ *
869
+ * The workflow this packet belongs to (hyphenated UUID).
716
870
  */
717
- name: string;
871
+ workflow_id: string;
718
872
  };
719
873
  /**
720
- * Evidence
874
+ * DocumentPacketFileV3
721
875
  *
722
- * A snippet of source text supporting an extracted value, with the page it came from.
876
+ * Slim per-file projection inside a packet.
723
877
  */
724
- type Evidence = {
878
+ type DocumentPacketFileV3 = {
725
879
  /**
726
- * Page Number
880
+ * Id
727
881
  *
728
- * 1-indexed page number where the snippet was found.
882
+ * Unique identifier of the file (hyphenated UUID).
729
883
  */
730
- page_number: number;
884
+ id: string;
731
885
  /**
732
- * Text
886
+ * Name
733
887
  *
734
- * The exact source-text snippet that supports the extracted value.
888
+ * Filename the file is stored under. Filenames are unique within a workflow: a name that collides with an existing file is auto-renamed by inserting a ` (n)` counter before the extension (e.g. `invoice.pdf` → `invoice (1).pdf`).
735
889
  */
736
- text: string;
890
+ name: string;
737
891
  };
738
892
  /**
739
- * ExtractNode
893
+ * DocumentPacketStatus
894
+ *
895
+ * Extraction lifecycle of a packet. Non-terminal: ``not_started``
896
+ * (no run yet), ``queued``, ``in_progress``. Terminal: ``processed``
897
+ * (success), ``error``, ``cancelled``.
898
+ */
899
+ type DocumentPacketStatus = 'not_started' | 'queued' | 'in_progress' | 'processed' | 'error' | 'cancelled';
900
+ /**
901
+ * DocumentPacketSummaryV3
902
+ *
903
+ * Slim packet projection returned by list pages.
740
904
  */
741
- type ExtractNode = {
905
+ type DocumentPacketSummaryV3 = {
742
906
  /**
743
- * Schema for the fields this node extracts. Required.
907
+ * Created At
908
+ *
909
+ * Timestamp when the packet was created (ISO 8601).
744
910
  */
745
- extraction_schema: ExtractionSchema;
911
+ created_at?: string | null;
746
912
  /**
747
913
  * Id
748
914
  *
749
- * Stable identifier for this node within the graph.
915
+ * Unique identifier of the document packet (hyphenated UUID).
750
916
  */
751
917
  id: string;
752
918
  /**
753
- * Lookup File Uploads
919
+ * Name
754
920
  *
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.
921
+ * Human-readable name of the packet.
756
922
  */
757
- lookup_file_uploads?: Array<LookupFileUpload>;
923
+ name?: string | null;
758
924
  /**
759
- * Lookup Files
760
- *
761
- * Smart-lookup reference document URIs persisted on the extract node.
925
+ * Processing status. Non-terminal: `not_started`, `queued`, `in_progress`. Terminal: `processed` (success), `error`, `cancelled`.
762
926
  */
763
- lookup_files?: Array<string>;
927
+ status: DocumentPacketStatus;
764
928
  /**
765
- * Lookup Reasoning Effort
929
+ * Updated At
766
930
  *
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.
931
+ * Timestamp when the packet was last updated (ISO 8601).
768
932
  */
769
- lookup_reasoning_effort?: 'minimal' | 'low' | 'medium' | 'high' | null;
933
+ updated_at?: string | null;
770
934
  /**
771
- * Lookup Schema
935
+ * Workflow Id
772
936
  *
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.
937
+ * The workflow this packet belongs to (hyphenated UUID).
774
938
  */
775
- lookup_schema?: Array<StringField | IntegerField | FloatField | BooleanField | DateField | DatetimeField | EnumField | MultiSelectField | ObjectField>;
939
+ workflow_id: string;
940
+ };
941
+ /**
942
+ * Edge
943
+ *
944
+ * A directed edge between two nodes. ``branch`` carries the source-port label
945
+ * used for routing out of ``classify`` (category id) or ``splitter`` (rule id) nodes.
946
+ */
947
+ type Edge = {
776
948
  /**
777
- * Lookup Suggestion
949
+ * Branch
778
950
  *
779
- * Free-form hint shown to the smart-lookup matcher.
951
+ * Source-port label for branch routing. Required when leaving a classify or splitter node by category/rule.
780
952
  */
781
- lookup_suggestion?: string | null;
953
+ branch?: string | null;
782
954
  /**
783
- * Mode
955
+ * Source
956
+ */
957
+ source: string;
958
+ /**
959
+ * Target
960
+ */
961
+ target: string;
962
+ };
963
+ /**
964
+ * Edit
965
+ *
966
+ * One edit node's filled form for one file of the collection: the values
967
+ * written into the document's fields, plus a short-lived link to the filled
968
+ * PDF. One entry per file the edit node processed.
969
+ */
970
+ type Edit = {
971
+ /**
972
+ * Download Url
784
973
  *
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.
974
+ * Presigned link to the filled PDF, valid for 15 minutes from the moment this response was built. Re-read the results endpoint for a fresh link. `null` when no filled PDF was stored.
786
975
  */
787
- mode?: 'standard' | 'agentic' | 'max' | 'lite';
976
+ download_url?: string | null;
788
977
  /**
789
- * Page Sum Verification Enabled
978
+ * Fields
790
979
  *
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).
980
+ * Every form field detected in the document, filled or not, in document order.
792
981
  */
793
- page_sum_verification_enabled?: boolean;
982
+ fields?: Array<EditFormField>;
794
983
  /**
795
- * Row Extractor Enabled
984
+ * File Id
796
985
  *
797
- * Extract table rows page by page, carrying context across page breaks so rows stay in their group ('max' mode implies this).
986
+ * The UUID of the file this form was filled from.
798
987
  */
799
- row_extractor_enabled?: boolean;
988
+ file_id: string;
800
989
  /**
801
- * Type
990
+ * File Name
991
+ *
992
+ * The file's display name.
802
993
  */
803
- type: 'extract';
994
+ file_name: string;
804
995
  /**
805
- * Use Images
996
+ * Unmatched Instructions
806
997
  *
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.
998
+ * Instruction fragments, quoted verbatim, that matched no field in this document.
808
999
  */
809
- use_images?: boolean;
1000
+ unmatched_instructions?: Array<string>;
810
1001
  };
811
1002
  /**
812
- * ExtractedField
1003
+ * EditFormField
813
1004
  *
814
- * One extracted field's value, confidence, and supporting evidence.
1005
+ * One form field the edit node detected, with the value it wrote in.
815
1006
  */
816
- type ExtractedField$1 = {
1007
+ type EditFormField = {
1008
+ /**
1009
+ * Bbox
1010
+ *
1011
+ * The field's fillable area as a normalised bounding box in [0, 1] page coordinates, keys `x0`/`y0`/`x1`/`y1`.
1012
+ */
1013
+ bbox: {
1014
+ [key: string]: number;
1015
+ };
817
1016
  /**
818
1017
  * Confidence
819
1018
  *
820
- * Model confidence in the extracted value, on a 0-100 scale. `null` when the backend did not produce a confidence (e.g. manual entry).
1019
+ * Raw, uncalibrated 0-100 match score for pairing an instruction with this field. It grades how surely the instruction addresses the field, not whether the written value is correct, and it is not a probability. `null` when no instruction addressed this field, because nothing was measured.
821
1020
  */
822
- confidence?: number | null;
1021
+ confidence: number | null;
823
1022
  /**
824
- * Evidence
1023
+ * Form Field Id
825
1024
  *
826
- * Source-text snippets the model used to derive this value.
1025
+ * Stable identifier for this form field within the document, in the form `p<page>_f<index>`.
827
1026
  */
828
- evidence?: Array<Evidence>;
1027
+ form_field_id: string;
829
1028
  /**
830
- * Value
1029
+ * Kind
831
1030
  *
832
- * The extracted value. Type depends on the field's `data_type` (string, number, date, etc.). `null` when extraction could not produce a value.
1031
+ * `checkbox` for a tick target, `text` for anything else.
833
1032
  */
834
- value: unknown | null;
1033
+ kind: string;
835
1034
  /**
836
- * Value Override
1035
+ * Label
837
1036
  *
838
- * A human-supplied override of the extracted `value`, if one was set during verification. `null` when no override exists.
1037
+ * The field's own printed caption, verbatim from the document.
839
1038
  */
840
- value_override?: unknown | null;
1039
+ label: string;
841
1040
  /**
842
- * Verification Status
1041
+ * Page
843
1042
  *
844
- * Verification state for this datapoint (e.g. `not_verified`, `verified`). `null` when not yet reviewed.
1043
+ * 1-indexed page number the field sits on.
845
1044
  */
846
- verification_status?: string | null;
847
- };
848
- /**
849
- * Extraction
850
- *
851
- * One unit of extracted data. For linear (parse->extract) workflows there
852
- * is exactly one entry with `split_name=null` and `partition=null`. For split
853
- * workflows there is one entry per (split, partition) pair; join with
1045
+ page: number;
1046
+ /**
1047
+ * State
1048
+ *
1049
+ * `empty` if the field was blank in the source document and therefore fillable, `prefilled` if the document already carried a value. Prefilled fields are never overwritten, so they always read back with `value: null`.
1050
+ */
1051
+ state: string;
1052
+ /**
1053
+ * Value
1054
+ *
1055
+ * The value written into the field — the literal string `true`/`false` for a `checkbox`. `null` when no instruction addressed this field.
1056
+ */
1057
+ value: string | null;
1058
+ };
1059
+ /**
1060
+ * EnumField
1061
+ */
1062
+ type EnumField = {
1063
+ /**
1064
+ * Data Type
1065
+ */
1066
+ data_type: 'enum';
1067
+ /**
1068
+ * Description
1069
+ *
1070
+ * Free-form description shown to the extraction model.
1071
+ */
1072
+ description?: string;
1073
+ /**
1074
+ * Enum Options
1075
+ */
1076
+ enum_options: Array<EnumOption>;
1077
+ /**
1078
+ * Name
1079
+ *
1080
+ * Field name. Used as the key in the extraction response.
1081
+ */
1082
+ name: string;
1083
+ /**
1084
+ * Persistent Id
1085
+ *
1086
+ * 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 only for genuinely new fields: there is no matching by name, so a field sent without one is always treated as new and minted a fresh id, silently detaching that field's metrics, ground truth and analytics.
1087
+ */
1088
+ persistent_id?: string | null;
1089
+ /**
1090
+ * Source
1091
+ *
1092
+ * How the field gets its value: extraction (from the document), smart_lookup (from the lookup file, always overwrites) or lookup_if_missing (extracted too; the lookup only fills it where extraction left no value).
1093
+ */
1094
+ source?: 'extraction' | 'smart_lookup' | 'lookup_if_missing';
1095
+ };
1096
+ /**
1097
+ * EnumOption
1098
+ */
1099
+ type EnumOption = {
1100
+ /**
1101
+ * Description
1102
+ *
1103
+ * Free-form description shown to the model.
1104
+ */
1105
+ description: string;
1106
+ /**
1107
+ * Name
1108
+ */
1109
+ name: string;
1110
+ };
1111
+ /**
1112
+ * Evidence
1113
+ *
1114
+ * A snippet of source text supporting an extracted value, with the page it came from.
1115
+ *
1116
+ * When ``text`` starts with ``metadata.``, the value was sourced from the
1117
+ * packet's caller-supplied metadata (not the document): the remainder is
1118
+ * the JSON path into that metadata, and ``page_number`` is ``0``. Encoded
1119
+ * in ``text`` on purpose — same wire shape as document evidence, no schema
1120
+ * change for SDK consumers.
1121
+ */
1122
+ type Evidence = {
1123
+ /**
1124
+ * Page Number
1125
+ *
1126
+ * 1-indexed page number where the snippet was found.
1127
+ */
1128
+ page_number: number;
1129
+ /**
1130
+ * Text
1131
+ *
1132
+ * The exact source-text snippet that supports the extracted value.
1133
+ */
1134
+ text: string;
1135
+ };
1136
+ /**
1137
+ * ExpressionCheck
1138
+ *
1139
+ * A CEL expression over the whole extraction, evaluated in a sandbox.
1140
+ *
1141
+ * The expression reads one root variable ``data`` and addresses fields by
1142
+ * extracted name (``data.total``, ``data.lineas.map(l, l.importe)``), never by
1143
+ * ``persistent_id`` — so ``field_ids`` returns ``[]`` for it, and a field
1144
+ * rename silently breaks the rule. An expression the evaluator cannot parse,
1145
+ * cannot answer with a boolean, or prices above its evaluation budget reports
1146
+ * ``inconclusive``.
1147
+ *
1148
+ * ADR platform/0036 records why the CEL parser stays out of this package, so
1149
+ * ``expression`` is unvalidated here.
1150
+ */
1151
+ type ExpressionCheck = {
1152
+ /**
1153
+ * Expression
1154
+ */
1155
+ expression: string;
1156
+ /**
1157
+ * Type
1158
+ */
1159
+ type: 'expression';
1160
+ };
1161
+ /**
1162
+ * ExtractedField
1163
+ *
1164
+ * One extracted field's value, confidence, and supporting evidence.
1165
+ */
1166
+ type ExtractedField$1 = {
1167
+ /**
1168
+ * Confidence
1169
+ *
1170
+ * Model confidence in the extracted value, on a 0-100 scale. `null` when the backend did not produce a confidence (e.g. manual entry).
1171
+ */
1172
+ confidence?: number | null;
1173
+ /**
1174
+ * Evidence
1175
+ *
1176
+ * Source-text snippets the model used to derive this value.
1177
+ */
1178
+ evidence?: Array<Evidence>;
1179
+ /**
1180
+ * Value
1181
+ *
1182
+ * The extracted value, always as a string — a field declared `integer` returns `"3"`, not `3`. Values are stored as text, so `data_type` governs how the field is extracted and validated, not the JSON type you get back; parse it yourself, minding that a document may write a number as `1.026,00`. `null` when extraction produced no value.
1183
+ */
1184
+ value: unknown | null;
1185
+ /**
1186
+ * Value Override
1187
+ *
1188
+ * A human-supplied override of the extracted `value`, if one was set during verification. `null` when no override exists.
1189
+ */
1190
+ value_override?: unknown | null;
1191
+ /**
1192
+ * Verification Status
1193
+ *
1194
+ * Verification state for this datapoint (e.g. `not_verified`, `verified`). `null` when not yet reviewed.
1195
+ */
1196
+ verification_status?: string | null;
1197
+ };
1198
+ /**
1199
+ * Extraction
1200
+ *
1201
+ * One unit of extracted data. For linear (parse->extract) workflows there
1202
+ * is exactly one entry with `split_name=null` and `partition=null`. For split
1203
+ * workflows there is one entry per (split, partition) pair; join with
854
1204
  * `splits[]` by `split_name` to look up geometry.
855
1205
  */
856
1206
  type Extraction = {
@@ -876,6 +1226,12 @@ type Extraction = {
876
1226
  * The split category this extraction belongs to. `null` for linear workflows.
877
1227
  */
878
1228
  split_name?: string | null;
1229
+ /**
1230
+ * Validations
1231
+ *
1232
+ * Configured validation verdicts and automatic extraction review warnings. Unresolved chunk fields have a null value and an inconclusive warning with candidate values and evidence, even without a validate node.
1233
+ */
1234
+ validations?: Array<Validation>;
879
1235
  };
880
1236
  /**
881
1237
  * ExtractionSchema
@@ -933,10 +1289,6 @@ type FloatField = {
933
1289
  * Free-form description shown to the extraction model.
934
1290
  */
935
1291
  description?: string;
936
- /**
937
- * Lookup
938
- */
939
- lookup?: boolean;
940
1292
  /**
941
1293
  * Name
942
1294
  *
@@ -946,9 +1298,15 @@ type FloatField = {
946
1298
  /**
947
1299
  * Persistent Id
948
1300
  *
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.
1301
+ * 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 only for genuinely new fields: there is no matching by name, so a field sent without one is always treated as new and minted a fresh id, silently detaching that field's metrics, ground truth and analytics.
950
1302
  */
951
1303
  persistent_id?: string | null;
1304
+ /**
1305
+ * Source
1306
+ *
1307
+ * How the field gets its value: extraction (from the document), smart_lookup (from the lookup file, always overwrites) or lookup_if_missing (extracted too; the lookup only fills it where extraction left no value).
1308
+ */
1309
+ source?: 'extraction' | 'smart_lookup' | 'lookup_if_missing';
952
1310
  };
953
1311
  /**
954
1312
  * Hyperlink
@@ -983,10 +1341,6 @@ type IntegerField = {
983
1341
  * Free-form description shown to the extraction model.
984
1342
  */
985
1343
  description?: string;
986
- /**
987
- * Lookup
988
- */
989
- lookup?: boolean;
990
1344
  /**
991
1345
  * Name
992
1346
  *
@@ -996,9 +1350,38 @@ type IntegerField = {
996
1350
  /**
997
1351
  * Persistent Id
998
1352
  *
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.
1353
+ * 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 only for genuinely new fields: there is no matching by name, so a field sent without one is always treated as new and minted a fresh id, silently detaching that field's metrics, ground truth and analytics.
1000
1354
  */
1001
1355
  persistent_id?: string | null;
1356
+ /**
1357
+ * Source
1358
+ *
1359
+ * How the field gets its value: extraction (from the document), smart_lookup (from the lookup file, always overwrites) or lookup_if_missing (extracted too; the lookup only fills it where extraction left no value).
1360
+ */
1361
+ source?: 'extraction' | 'smart_lookup' | 'lookup_if_missing';
1362
+ };
1363
+ /**
1364
+ * KnowledgeNode
1365
+ *
1366
+ * Terminal knowledge sink — its presence opts the workflow into the
1367
+ * knowledge base (priced separately, so absent by default).
1368
+ *
1369
+ * The backend reacts to parse callbacks by ingesting parsed markdown into
1370
+ * the workflow's navigable corpus; core never executes this node — the
1371
+ * execution builder keeps it and its edges off the worker message. Emits
1372
+ * nothing downstream.
1373
+ */
1374
+ type KnowledgeNode = {
1375
+ /**
1376
+ * Id
1377
+ *
1378
+ * Stable identifier for this node within the graph.
1379
+ */
1380
+ id: string;
1381
+ /**
1382
+ * Type
1383
+ */
1384
+ type: 'knowledge';
1002
1385
  };
1003
1386
  /**
1004
1387
  * LookupFileUpload
@@ -1040,10 +1423,6 @@ type MultiSelectField = {
1040
1423
  * Enum Options
1041
1424
  */
1042
1425
  enum_options: Array<EnumOption>;
1043
- /**
1044
- * Lookup
1045
- */
1046
- lookup?: boolean;
1047
1426
  /**
1048
1427
  * Name
1049
1428
  *
@@ -1053,12 +1432,23 @@ type MultiSelectField = {
1053
1432
  /**
1054
1433
  * Persistent Id
1055
1434
  *
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.
1435
+ * 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 only for genuinely new fields: there is no matching by name, so a field sent without one is always treated as new and minted a fresh id, silently detaching that field's metrics, ground truth and analytics.
1057
1436
  */
1058
1437
  persistent_id?: string | null;
1438
+ /**
1439
+ * Source
1440
+ *
1441
+ * How the field gets its value: extraction (from the document), smart_lookup (from the lookup file, always overwrites) or lookup_if_missing (extracted too; the lookup only fills it where extraction left no value).
1442
+ */
1443
+ source?: 'extraction' | 'smart_lookup' | 'lookup_if_missing';
1059
1444
  };
1060
1445
  /**
1061
1446
  * ObjectField
1447
+ *
1448
+ * A repeating group — the way a table or line-item list is modelled.
1449
+ *
1450
+ * There is no separate list type: one ``object`` field describes the shape of
1451
+ * a single row, and the extraction returns an array of those rows.
1062
1452
  */
1063
1453
  type ObjectField = {
1064
1454
  /**
@@ -1071,10 +1461,6 @@ type ObjectField = {
1071
1461
  * Free-form description shown to the extraction model.
1072
1462
  */
1073
1463
  description?: string;
1074
- /**
1075
- * Lookup
1076
- */
1077
- lookup?: boolean;
1078
1464
  /**
1079
1465
  * Name
1080
1466
  *
@@ -1084,15 +1470,21 @@ type ObjectField = {
1084
1470
  /**
1085
1471
  * Nested Fields
1086
1472
  *
1087
- * Child fields of this object. Only one level of nesting is supported — an object field's children must be non-object types.
1473
+ * Columns of one row. The extracted value is an array of objects with these keys, one entry per row found. Only one level of nesting is supported — an object field's children must be non-object types.
1088
1474
  */
1089
1475
  nested_fields: Array<StringField | IntegerField | FloatField | BooleanField | DateField | DatetimeField | EnumField | MultiSelectField>;
1090
1476
  /**
1091
1477
  * Persistent Id
1092
1478
  *
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.
1479
+ * 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 only for genuinely new fields: there is no matching by name, so a field sent without one is always treated as new and minted a fresh id, silently detaching that field's metrics, ground truth and analytics.
1094
1480
  */
1095
1481
  persistent_id?: string | null;
1482
+ /**
1483
+ * Source
1484
+ *
1485
+ * How the field gets its value: extraction (from the document), smart_lookup (from the lookup file, always overwrites) or lookup_if_missing (extracted too; the lookup only fills it where extraction left no value).
1486
+ */
1487
+ source?: 'extraction' | 'smart_lookup' | 'lookup_if_missing';
1096
1488
  };
1097
1489
  /**
1098
1490
  * OneOfCheck
@@ -1108,6 +1500,8 @@ type OneOfCheck = {
1108
1500
  case_sensitive?: boolean;
1109
1501
  /**
1110
1502
  * Field
1503
+ *
1504
+ * The field to test. Either the field's ``persistent_id`` (Studio field-picker path) or its ``sanitized_name`` as it appears in the extraction response (SDK/API/assistant path) — the executor resolves both.
1111
1505
  */
1112
1506
  field: string;
1113
1507
  /**
@@ -1116,122 +1510,291 @@ type OneOfCheck = {
1116
1510
  type: 'one_of';
1117
1511
  };
1118
1512
  /**
1119
- * ParseNode
1513
+ * ParseResult
1514
+ *
1515
+ * Parsed markdown for a file.
1120
1516
  */
1121
- type ParseNode = {
1517
+ type ParseResult = {
1122
1518
  /**
1123
- * Cache
1519
+ * Blocks
1124
1520
  *
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.
1521
+ * Structured per-block representation of the parsed document. One entry per `<a id></a>` anchor in document order, with type-specific structured data (`rows` for tables, `image_base64` for pictures) surfaced as first-class fields so consumers don't have to HTML-parse.
1126
1522
  */
1127
- cache?: boolean;
1523
+ blocks?: Array<Block>;
1128
1524
  /**
1129
- * Effort
1525
+ * Layout Confidence
1130
1526
  *
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`.)
1527
+ * Document-level YOLO layout confidence on a 0-1 scale, char-weighted mean across all blocks. `null` if no annotated sections.
1132
1528
  */
1133
- effort?: 'low' | 'mid' | 'accurate';
1529
+ layout_confidence?: number | null;
1134
1530
  /**
1135
- * Figure Enhancement
1531
+ * Markdown
1136
1532
  *
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).
1533
+ * Document content rendered as structured markdown. Each block is preceded by an empty `<a id="p{page}_b{idx}"></a>` anchor (invisible in any markdown renderer; the id joins to `blocks[].id` and can be used as an in-page link target). Image hydration for picture/figure blocks happens client-side. `null` if parsing failed.
1138
1534
  */
1139
- figure_enhancement?: boolean;
1535
+ markdown: string | null;
1140
1536
  /**
1141
- * Figures
1537
+ * Parse Confidence
1142
1538
  *
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).
1539
+ * Document-level parse confidence on a 0-100 scale, char-weighted mean of per-block LLM logprob scores. `null` when no blocks have logprob-based confidence.
1144
1540
  */
1145
- figures?: boolean;
1541
+ parse_confidence?: number | null;
1542
+ /**
1543
+ * Text
1544
+ *
1545
+ * `markdown` with `<img>` tags removed and runs of blank lines collapsed. Block anchors are deliberately kept, so on a document whose pictures are markdown images rather than `<img>` tags this is `markdown` verbatim — read one or the other, not both. `null` if `markdown` is null.
1546
+ */
1547
+ text?: string | null;
1548
+ };
1549
+ /**
1550
+ * PublicEditNode
1551
+ *
1552
+ * Terminal form-filler. ``reference_uris`` is resolved server-side at run
1553
+ * time from ``reference_document_ids`` — omitted here, and any client-supplied
1554
+ * value is discarded rather than trusted.
1555
+ */
1556
+ type PublicEditNode = {
1557
+ /**
1558
+ * Font
1559
+ *
1560
+ * Typeface the filled values are written in.
1561
+ */
1562
+ font?: 'sans' | 'serif' | 'mono';
1146
1563
  /**
1147
1564
  * Id
1148
1565
  *
1149
1566
  * Stable identifier for this node within the graph.
1150
1567
  */
1151
1568
  id: string;
1569
+ /**
1570
+ * Instructions
1571
+ *
1572
+ * Free-text values to map onto the fillable fields detected on the upstream parse's PDF, e.g. 'Name: ACME SL; Date: 2026-01-01; I accept the terms: yes'. Takes precedence over a reference document where both address the same field.
1573
+ */
1574
+ instructions?: string | null;
1575
+ /**
1576
+ * Output Mode
1577
+ *
1578
+ * 'flattened' paints the values on and the PDF is final. 'editable' leaves each value in a live form field a reviewer can correct in any PDF viewer.
1579
+ */
1580
+ output_mode?: 'flattened' | 'editable';
1581
+ /**
1582
+ * Reference Document Ids
1583
+ *
1584
+ * Ids of reference documents this node fills from, uploaded to the workflow beforehand. Every id must belong to this workflow and be fully resolved, or the run is refused rather than filled from a partial reference.
1585
+ */
1586
+ reference_document_ids?: Array<string>;
1587
+ /**
1588
+ * Type
1589
+ */
1590
+ type: 'edit';
1591
+ };
1592
+ /**
1593
+ * PublicExtractNode
1594
+ */
1595
+ type PublicExtractNode = {
1596
+ /**
1597
+ * Schema for the fields this node extracts. Required.
1598
+ */
1599
+ extraction_schema: ExtractionSchema;
1600
+ /**
1601
+ * Id
1602
+ *
1603
+ * Stable identifier for this node within the graph.
1604
+ */
1605
+ id: string;
1606
+ /**
1607
+ * Lookup File Uploads
1608
+ *
1609
+ * 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.
1610
+ */
1611
+ lookup_file_uploads?: Array<LookupFileUpload>;
1612
+ /**
1613
+ * Lookup Files
1614
+ *
1615
+ * Smart-lookup reference document URIs persisted on the extract node.
1616
+ */
1617
+ lookup_files?: Array<string>;
1618
+ /**
1619
+ * Lookup Reasoning Effort
1620
+ *
1621
+ * 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.
1622
+ */
1623
+ lookup_reasoning_effort?: 'minimal' | 'low' | 'medium' | 'high' | null;
1624
+ /**
1625
+ * Lookup Suggestion
1626
+ *
1627
+ * Free-form hint shown to the smart-lookup matcher.
1628
+ */
1629
+ lookup_suggestion?: string | null;
1152
1630
  /**
1153
1631
  * Mode
1154
1632
  *
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.
1633
+ * 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. 'lite' (shown as 'Fast' in the app): standard extraction, faster and cheaper; quality may vary on complex layouts.
1156
1634
  */
1157
1635
  mode?: 'standard' | 'agentic' | 'lite';
1158
1636
  /**
1159
- * Ocr Effort
1637
+ * Type
1638
+ */
1639
+ type: 'extract';
1640
+ /**
1641
+ * Use Images
1160
1642
  *
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`.)
1643
+ * 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.
1162
1644
  */
1163
- ocr_effort?: 'medium' | 'high';
1645
+ use_images?: boolean;
1646
+ };
1647
+ /**
1648
+ * PublicIfElseNode
1649
+ */
1650
+ type PublicIfElseNode = {
1164
1651
  /**
1165
- * Prompt Hint
1652
+ * Condition
1653
+ */
1654
+ condition: ({
1655
+ type: 'range';
1656
+ } & RangeCheck) | ({
1657
+ type: 'date';
1658
+ } & DateCheck) | ({
1659
+ type: 'arithmetic';
1660
+ } & ArithmeticCheck) | ({
1661
+ type: 'comparison';
1662
+ } & ComparisonCheck) | ({
1663
+ type: 'one_of';
1664
+ } & OneOfCheck) | ({
1665
+ type: 'regex';
1666
+ } & RegexCheck) | ({
1667
+ type: 'required';
1668
+ } & RequiredCheck) | ({
1669
+ type: 'confidence';
1670
+ } & ConfidenceCheck) | ({
1671
+ type: 'expression';
1672
+ } & ExpressionCheck) | ({
1673
+ type: 'validation';
1674
+ } & ValidationCheck) | ({
1675
+ type: 'all_of';
1676
+ } & AllOfCheck) | ({
1677
+ type: 'any_of';
1678
+ } & AnyOfCheck);
1679
+ /**
1680
+ * Id
1166
1681
  *
1167
- * Free-form hint that biases the parse output. In lite mode it guides the correction pass, so it requires skip_routing_review=False.
1682
+ * Stable identifier for this node within the graph.
1168
1683
  */
1169
- prompt_hint?: string | null;
1684
+ id: string;
1685
+ /**
1686
+ * Type
1687
+ */
1688
+ type: 'if_else';
1689
+ };
1690
+ /**
1691
+ * PublicParseNode
1692
+ */
1693
+ type PublicParseNode = {
1170
1694
  /**
1171
- * Region
1695
+ * Cache
1696
+ *
1697
+ * 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.
1698
+ */
1699
+ cache?: boolean;
1700
+ /**
1701
+ * Effort
1702
+ *
1703
+ * 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`.)
1704
+ */
1705
+ effort?: 'low' | 'mid' | 'accurate';
1706
+ /**
1707
+ * Figure Enhancement
1708
+ *
1709
+ * Standard mode: extract structured data from charts and images — extra processing per figure. Ignored in agentic and in lite.
1710
+ */
1711
+ figure_enhancement?: boolean;
1712
+ /**
1713
+ * Id
1714
+ *
1715
+ * Stable identifier for this node within the graph.
1716
+ */
1717
+ id: string;
1718
+ /**
1719
+ * Mode
1172
1720
  *
1173
- * Lite mode: OCR data-residency. 'eu' keeps processing in-region; 'global' uses the hosted endpoint. Feature-flagged.
1721
+ * 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-only tier — accurate OCR, no LLM call; use standard or agentic when the output needs LLM correction. 'flash': the PDF's own text layer plus layout grounding, no model call — the cheapest and fastest tier; a page with no text layer is OCR'd by default (see scanned_pages).
1174
1722
  */
1175
- region?: 'eu' | 'global';
1723
+ mode?: 'standard' | 'agentic' | 'lite' | 'flash';
1176
1724
  /**
1177
- * Routing Effort
1725
+ * Ocr Effort
1178
1726
  *
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.
1727
+ * Lite mode: 'high' (default) = the strongest OCR — best accuracy on complex layouts, tables, and handwriting. 'medium' = faster and cheaper, for clean digital documents. (Distinct from agentic `effort`.)
1180
1728
  */
1181
- routing_effort?: 'minimal' | 'low' | 'medium' | 'high' | null;
1729
+ ocr_effort?: 'medium' | 'high';
1182
1730
  /**
1183
- * Skip Routing Review
1731
+ * Prompt Hint
1184
1732
  *
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.
1733
+ * Free-form hint that biases the parse output. Standard and agentic modes only; ignored in lite.
1186
1734
  */
1187
- skip_routing_review?: boolean;
1735
+ prompt_hint?: string | null;
1188
1736
  /**
1189
- * Text Formatting
1737
+ * Scanned Pages
1190
1738
  *
1191
- * Lite mode: the correction pass restores inline styling (bold/italic/superscript), code, and LaTeX math in text blocks (needs skip_routing_review=False).
1739
+ * Flash mode: what to do with a page whose text layer produced no words. 'ocr' (default): OCR the page and parse it like any other, at no extra model cost. 'skip': serve it blank and flag it, don't fail the parse. 'fail': raise, naming the page numbers.
1192
1740
  */
1193
- text_formatting?: boolean;
1741
+ scanned_pages?: 'ocr' | 'skip' | 'fail';
1194
1742
  /**
1195
1743
  * Type
1196
1744
  */
1197
1745
  type: 'parse';
1198
1746
  };
1199
1747
  /**
1200
- * ParseResult
1748
+ * PublicSlackAlertNode
1201
1749
  *
1202
- * Parsed markdown for a file.
1750
+ * Terminal alert-sink. ``field_index`` is executor-injected — omitted here.
1203
1751
  */
1204
- type ParseResult = {
1752
+ type PublicSlackAlertNode = {
1753
+ /**
1754
+ * Channel Id
1755
+ */
1756
+ channel_id: string;
1757
+ /**
1758
+ * Channel Name
1759
+ */
1760
+ channel_name: string;
1761
+ /**
1762
+ * Id
1763
+ *
1764
+ * Stable identifier for this node within the graph.
1765
+ */
1766
+ id: string;
1767
+ /**
1768
+ * Message Template
1769
+ */
1770
+ message_template: string;
1205
1771
  /**
1206
- * Blocks
1207
- *
1208
- * Structured per-block representation of the parsed document. One entry per `<a id></a>` anchor in document order, with type-specific structured data (`rows` for tables, `image_base64` for pictures) surfaced as first-class fields so consumers don't have to HTML-parse.
1772
+ * Severity
1209
1773
  */
1210
- blocks?: Array<Block>;
1774
+ severity?: 'info' | 'warning' | 'critical';
1211
1775
  /**
1212
- * Layout Confidence
1213
- *
1214
- * Document-level YOLO layout confidence on a 0-100 scale, char-weighted mean across all blocks. `null` if no annotated sections.
1776
+ * Type
1215
1777
  */
1216
- layout_confidence?: number | null;
1778
+ type: 'slack_alert';
1779
+ };
1780
+ /**
1781
+ * PublicValidateNode
1782
+ */
1783
+ type PublicValidateNode = {
1217
1784
  /**
1218
- * Markdown
1785
+ * Id
1219
1786
  *
1220
- * Document content rendered as structured markdown. Each block is preceded by an empty `<a id="p{page}_b{idx}"></a>` anchor (invisible in any markdown renderer; the id joins to `blocks[].id` and can be used as an in-page link target). Image hydration for picture/figure blocks happens client-side. `null` if parsing failed.
1787
+ * Stable identifier for this node within the graph.
1221
1788
  */
1222
- markdown: string | null;
1789
+ id: string;
1223
1790
  /**
1224
- * Parse Confidence
1225
- *
1226
- * Document-level parse confidence on a 0-100 scale, char-weighted mean of per-block LLM logprob scores. `null` when no blocks have logprob-based confidence.
1791
+ * Rules
1227
1792
  */
1228
- parse_confidence?: number | null;
1793
+ rules: Array<ValidationRule>;
1229
1794
  /**
1230
- * Text
1231
- *
1232
- * Plain markdown with structural HTML removed — `<DOCUMENT>` framing, block anchors, `<img>` tags, and `<figure-content>` wrappers stripped. Useful when feeding the parsed output into an LLM or a search index that doesn't need the block-level metadata. `null` if `markdown` is null.
1795
+ * Type
1233
1796
  */
1234
- text?: string | null;
1797
+ type: 'validate';
1235
1798
  };
1236
1799
  /**
1237
1800
  * RangeCheck
@@ -1240,7 +1803,7 @@ type RangeCheck = {
1240
1803
  /**
1241
1804
  * Field
1242
1805
  *
1243
- * persistent_id of the bounded numeric field.
1806
+ * The bounded numeric field. Either the field's ``persistent_id`` (Studio field-picker path) or its ``sanitized_name`` as it appears in the extraction response (SDK/API/assistant path) — the executor resolves both.
1244
1807
  */
1245
1808
  field: string;
1246
1809
  /**
@@ -1262,6 +1825,8 @@ type RangeCheck = {
1262
1825
  type RegexCheck = {
1263
1826
  /**
1264
1827
  * Field
1828
+ *
1829
+ * The field to match. Either the field's ``persistent_id`` (Studio field-picker path) or its ``sanitized_name`` as it appears in the extraction response (SDK/API/assistant path) — the executor resolves both.
1265
1830
  */
1266
1831
  field: string;
1267
1832
  /**
@@ -1281,6 +1846,8 @@ type RegexCheck = {
1281
1846
  type RequiredCheck = {
1282
1847
  /**
1283
1848
  * Field
1849
+ *
1850
+ * The field that must be present. Either the field's ``persistent_id`` (Studio field-picker path) or its ``sanitized_name`` as it appears in the extraction response (SDK/API/assistant path) — the executor resolves both.
1284
1851
  */
1285
1852
  field: string;
1286
1853
  /**
@@ -1289,14 +1856,12 @@ type RequiredCheck = {
1289
1856
  type: 'required';
1290
1857
  };
1291
1858
  /**
1292
- * ResultsResponse
1859
+ * ResultsResponseV3
1293
1860
  *
1294
- * Canonical response shape for the file-collection results endpoint.
1295
- *
1296
- * Returned with HTTP 200 once processing completes. Returns 412 while processing is
1297
- * in progress; poll until 200, or use webhooks.
1861
+ * v3-scoped results envelope — same shape as ``ResultsResponse`` minus the
1862
+ * legacy ``collection_id`` alias. v3 emits only ``document_packet_id``.
1298
1863
  */
1299
- type ResultsResponse = {
1864
+ type ResultsResponseV3 = {
1300
1865
  /**
1301
1866
  * Classifications
1302
1867
  *
@@ -1304,11 +1869,17 @@ type ResultsResponse = {
1304
1869
  */
1305
1870
  classifications?: Array<ClassificationResult>;
1306
1871
  /**
1307
- * Collection Id
1872
+ * Document Packet Id
1873
+ *
1874
+ * The document packet's UUID — v3 canonical name for `collection_id`. Same value; both fields are always present.
1875
+ */
1876
+ document_packet_id: string;
1877
+ /**
1878
+ * Edits
1308
1879
  *
1309
- * The file collection's UUID. Same value as the `id` returned by `POST /v2/workflows/{wid}/run/`.
1880
+ * Filled-form output, one entry per file an edit node processed. Empty when the workflow has no edit node.
1310
1881
  */
1311
- collection_id: string;
1882
+ edits?: Array<Edit>;
1312
1883
  /**
1313
1884
  * Extraction
1314
1885
  *
@@ -1344,6 +1915,98 @@ type ResultsResponse = {
1344
1915
  */
1345
1916
  verification_url?: string | null;
1346
1917
  };
1918
+ /**
1919
+ * RunDetailV3
1920
+ *
1921
+ * Flat single-run read: lifecycle status plus results inline.
1922
+ *
1923
+ * `results` is `null` until the run reaches `processed`, then carries the
1924
+ * same results envelope `GET /v2/workflows/{id}/files/{id}/results/`
1925
+ * returns — no separate results endpoint, no 412 while in flight.
1926
+ */
1927
+ type RunDetailV3 = {
1928
+ /**
1929
+ * Created At
1930
+ *
1931
+ * Timestamp when the run was triggered (ISO 8601).
1932
+ */
1933
+ created_at?: string | null;
1934
+ /**
1935
+ * Document Packet Id
1936
+ *
1937
+ * The document packet the run executed on (hyphenated UUID).
1938
+ */
1939
+ document_packet_id: string;
1940
+ /**
1941
+ * Id
1942
+ *
1943
+ * Unique identifier of the run (hyphenated UUID).
1944
+ */
1945
+ id: string;
1946
+ /**
1947
+ * Extraction results envelope; `null` until `status` is `processed`. Same shape as the v2 results endpoint.
1948
+ */
1949
+ results?: ResultsResponseV3 | null;
1950
+ /**
1951
+ * Execution status. Non-terminal: `queued`, `in_progress`. Terminal: `processed` (success), `error`, `cancelled`.
1952
+ */
1953
+ status: RunStatus;
1954
+ /**
1955
+ * Updated At
1956
+ *
1957
+ * Timestamp of the run's last status change (ISO 8601).
1958
+ */
1959
+ updated_at?: string | null;
1960
+ /**
1961
+ * Workflow Id
1962
+ *
1963
+ * The workflow this run executed (hyphenated UUID).
1964
+ */
1965
+ workflow_id: string;
1966
+ };
1967
+ /**
1968
+ * RunStatus
1969
+ *
1970
+ * Execution lifecycle of a run. Non-terminal: ``queued``,
1971
+ * ``in_progress``. Terminal: ``processed`` (success), ``error``,
1972
+ * ``cancelled``.
1973
+ */
1974
+ type RunStatus = 'queued' | 'in_progress' | 'processed' | 'error' | 'cancelled';
1975
+ /**
1976
+ * RunSummaryV3
1977
+ *
1978
+ * Slim run projection returned by list pages.
1979
+ */
1980
+ type RunSummaryV3 = {
1981
+ /**
1982
+ * Created At
1983
+ *
1984
+ * Timestamp when the run was triggered (ISO 8601).
1985
+ */
1986
+ created_at?: string | null;
1987
+ /**
1988
+ * Document Packet Id
1989
+ *
1990
+ * The document packet the run executes on (hyphenated UUID).
1991
+ */
1992
+ document_packet_id: string;
1993
+ /**
1994
+ * Id
1995
+ *
1996
+ * Unique identifier of the run (hyphenated UUID).
1997
+ */
1998
+ id: string;
1999
+ /**
2000
+ * Execution status. Non-terminal: `queued`, `in_progress`. Terminal: `processed` (success), `error`, `cancelled`.
2001
+ */
2002
+ status: RunStatus;
2003
+ /**
2004
+ * Updated At
2005
+ *
2006
+ * Timestamp of the run's last status change (ISO 8601).
2007
+ */
2008
+ updated_at?: string | null;
2009
+ };
1347
2010
  /**
1348
2011
  * SplitPartition
1349
2012
  *
@@ -1353,9 +2016,9 @@ type SplitPartition = {
1353
2016
  /**
1354
2017
  * Confidence
1355
2018
  *
1356
- * 0-100 minimum confidence across the partition's ranges.
2019
+ * 0-100 minimum confidence across the partition's ranges. `null` when the partition holds no page, because nothing was measured.
1357
2020
  */
1358
- confidence: number;
2021
+ confidence: number | null;
1359
2022
  /**
1360
2023
  * Files
1361
2024
  */
@@ -1378,9 +2041,9 @@ type SplitResult = {
1378
2041
  /**
1379
2042
  * Confidence
1380
2043
  *
1381
- * 0-100 aggregate confidence (min across partitions).
2044
+ * 0-100 aggregate confidence (min across partitions). `null` when the category matched no page, because nothing was measured.
1382
2045
  */
1383
- confidence: number;
2046
+ confidence: number | null;
1384
2047
  /**
1385
2048
  * Files
1386
2049
  *
@@ -1454,10 +2117,6 @@ type StringField = {
1454
2117
  * Free-form description shown to the extraction model.
1455
2118
  */
1456
2119
  description?: string;
1457
- /**
1458
- * Lookup
1459
- */
1460
- lookup?: boolean;
1461
2120
  /**
1462
2121
  * Name
1463
2122
  *
@@ -1467,36 +2126,103 @@ type StringField = {
1467
2126
  /**
1468
2127
  * Persistent Id
1469
2128
  *
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.
2129
+ * 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 only for genuinely new fields: there is no matching by name, so a field sent without one is always treated as new and minted a fresh id, silently detaching that field's metrics, ground truth and analytics.
1471
2130
  */
1472
2131
  persistent_id?: string | null;
2132
+ /**
2133
+ * Source
2134
+ *
2135
+ * How the field gets its value: extraction (from the document), smart_lookup (from the lookup file, always overwrites) or lookup_if_missing (extracted too; the lookup only fills it where extraction left no value).
2136
+ */
2137
+ source?: 'extraction' | 'smart_lookup' | 'lookup_if_missing';
1473
2138
  };
1474
2139
  /**
1475
- * ValidateNode
2140
+ * Validation
2141
+ *
2142
+ * A configured rule verdict or an automatic extraction review warning.
1476
2143
  */
1477
- type ValidateNode = {
2144
+ type Validation = {
1478
2145
  /**
1479
- * Field Index
2146
+ * Compared Values
1480
2147
  *
1481
- * Executor-injected at run time (persistent_id → field name); never set by callers or persisted.
2148
+ * The field values the rule looked at, keyed by field name. `null` when nothing was compared.
1482
2149
  */
1483
- field_index?: {
1484
- [key: string]: string;
2150
+ compared_values?: {
2151
+ [key: string]: unknown;
1485
2152
  } | null;
1486
2153
  /**
1487
- * Id
2154
+ * Description
1488
2155
  *
1489
- * Stable identifier for this node within the graph.
2156
+ * The rule's natural-language description; empty for a deterministic rule.
1490
2157
  */
1491
- id: string;
2158
+ description?: string;
1492
2159
  /**
1493
- * Rules
2160
+ * Detail
2161
+ *
2162
+ * Human-readable explanation of the verdict.
1494
2163
  */
1495
- rules: Array<ValidationRule>;
2164
+ detail?: string;
2165
+ /**
2166
+ * Rule Id
2167
+ *
2168
+ * The configured rule ID, or an `extract.consolidation:` ID for an automatic review warning.
2169
+ */
2170
+ rule_id: string;
2171
+ /**
2172
+ * Severity
2173
+ *
2174
+ * `error` or `warning`, as declared on the rule.
2175
+ */
2176
+ severity: string;
2177
+ /**
2178
+ * Source Fields
2179
+ *
2180
+ * `persistent_id`s of the rule's inputs. Empty for automatic extraction warnings; field names are in `compared_values`.
2181
+ */
2182
+ source_fields?: Array<string>;
2183
+ /**
2184
+ * Status
2185
+ *
2186
+ * `pass`, `fail`, or `inconclusive` — the last one when the rule could not be evaluated (no data, an unanswerable expression).
2187
+ */
2188
+ status: string;
2189
+ };
2190
+ /**
2191
+ * ValidationCheck
2192
+ *
2193
+ * Routes on the outcome of a named validation rule already run upstream.
2194
+ *
2195
+ * Reads from ``state.validation_results`` (populated by an upstream
2196
+ * ``ValidateNode``), filtered to the current partition (``split_id``) so
2197
+ * per-partition IfElse routing matches per-partition rule outcomes. The
2198
+ * ``status`` values mirror the worker enum
2199
+ * (``anyformat_core.operations.validate_rules`` — ``pass`` / ``fail`` /
2200
+ * ``inconclusive``) verbatim: no translation layer, so template tokens
2201
+ * like ``${validation.<rule_id>.status}`` render the same three strings
2202
+ * the enum uses.
2203
+ *
2204
+ * Unlike every other ``Check`` variant this consumes no extracted fields
2205
+ * (``field_ids`` returns ``[]``); the rule identity is the entire input.
2206
+ * A ``rule_id`` with no matching entry evaluates to ``inconclusive`` — the
2207
+ * rule didn't run for this partition, so the outcome is unknown.
2208
+ */
2209
+ type ValidationCheck = {
2210
+ /**
2211
+ * Rule Id
2212
+ *
2213
+ * Stable id of the upstream ValidationRule to route on.
2214
+ */
2215
+ rule_id: string;
2216
+ /**
2217
+ * Status
2218
+ *
2219
+ * Outcome to match. ``fail`` (default) is the common case for routing to an alert branch.
2220
+ */
2221
+ status?: 'fail' | 'pass' | 'inconclusive';
1496
2222
  /**
1497
2223
  * Type
1498
2224
  */
1499
- type: 'validate';
2225
+ type: 'validation';
1500
2226
  };
1501
2227
  /**
1502
2228
  * ValidationRule
@@ -1521,7 +2247,17 @@ type ValidationRule = {
1521
2247
  type: 'regex';
1522
2248
  } & RegexCheck) | ({
1523
2249
  type: 'required';
1524
- } & RequiredCheck) | null;
2250
+ } & RequiredCheck) | ({
2251
+ type: 'confidence';
2252
+ } & ConfidenceCheck) | ({
2253
+ type: 'expression';
2254
+ } & ExpressionCheck) | ({
2255
+ type: 'validation';
2256
+ } & ValidationCheck) | ({
2257
+ type: 'all_of';
2258
+ } & AllOfCheck) | ({
2259
+ type: 'any_of';
2260
+ } & AnyOfCheck) | null;
1525
2261
  /**
1526
2262
  * Description
1527
2263
  *
@@ -1569,10 +2305,11 @@ type ValidationRule = {
1569
2305
  * (``kind="deterministic"`` + a structured ``check``, evaluated in pure
1570
2306
  * Python with no model call).
1571
2307
  *
1572
- * Defined as a thin subclass so the FastAPI-generated OpenAPI components
1573
- * entry is named ``WorkflowCreateRequest`` (FastAPI uses the model's
1574
- * ``__name__``). Behaviour is fully inherited from
1575
- * ``WorkflowDefinition`` in ``anyformat.workflow``.
2308
+ * Uses ``PublicNode`` (public request models with only the fields callers
2309
+ * may set); the domain ``AnyNode`` also carries ``filter`` (worker-only)
2310
+ * and executor-injected / staff-only fields, so the public bodies pin a
2311
+ * stricter node schema. Call :meth:`to_domain` before forwarding to the
2312
+ * backend.
1576
2313
  */
1577
2314
  type WorkflowCreateRequest = {
1578
2315
  /**
@@ -1590,7 +2327,96 @@ type WorkflowCreateRequest = {
1590
2327
  /**
1591
2328
  * Nodes
1592
2329
  */
1593
- nodes: Array<ParseNode | ClassifyNode | SplitterNode | ExtractNode | ValidateNode>;
2330
+ nodes: Array<PublicParseNode | ClassifyNode | SplitterNode | PublicExtractNode | PublicValidateNode | PublicIfElseNode | PublicSlackAlertNode | PublicEditNode | KnowledgeNode>;
2331
+ };
2332
+ /**
2333
+ * WorkflowDetailV3
2334
+ *
2335
+ * A workflow with its complete typed graph inline.
2336
+ *
2337
+ * ``{name, description, nodes, edges}`` is the exact shape
2338
+ * ``POST /v3/workflows/`` accepts — mutate it and feed it back to edit.
2339
+ */
2340
+ type WorkflowDetailV3 = {
2341
+ /**
2342
+ * Created At
2343
+ *
2344
+ * Timestamp when the workflow was created (ISO 8601).
2345
+ */
2346
+ created_at?: string | null;
2347
+ /**
2348
+ * Description
2349
+ *
2350
+ * Optional description of what this workflow extracts.
2351
+ */
2352
+ description?: string | null;
2353
+ /**
2354
+ * Edges
2355
+ *
2356
+ * Directed edges between the graph nodes.
2357
+ */
2358
+ edges?: Array<Edge>;
2359
+ /**
2360
+ * Id
2361
+ *
2362
+ * Unique identifier of the workflow (hyphenated UUID).
2363
+ */
2364
+ id: string;
2365
+ /**
2366
+ * Name
2367
+ *
2368
+ * Human-readable name of the workflow.
2369
+ */
2370
+ name: string;
2371
+ /**
2372
+ * Nodes
2373
+ *
2374
+ * Typed graph nodes (parse / classify / splitter / extract / validate / if_else).
2375
+ */
2376
+ nodes: Array<PublicParseNode | ClassifyNode | SplitterNode | PublicExtractNode | PublicValidateNode | PublicIfElseNode | PublicSlackAlertNode | PublicEditNode | KnowledgeNode>;
2377
+ /**
2378
+ * Updated At
2379
+ *
2380
+ * Timestamp when the workflow was last modified (ISO 8601).
2381
+ */
2382
+ updated_at?: string | null;
2383
+ };
2384
+ /**
2385
+ * WorkflowSummaryV3
2386
+ *
2387
+ * Slim workflow projection returned by create and list.
2388
+ */
2389
+ type WorkflowSummaryV3 = {
2390
+ /**
2391
+ * Created At
2392
+ *
2393
+ * Timestamp when the workflow was created (ISO 8601).
2394
+ */
2395
+ created_at?: string | null;
2396
+ /**
2397
+ * Description
2398
+ *
2399
+ * Optional description of what this workflow extracts.
2400
+ */
2401
+ description?: string | null;
2402
+ /**
2403
+ * Id
2404
+ *
2405
+ * Unique identifier of the workflow (hyphenated UUID).
2406
+ */
2407
+ id: string;
2408
+ /**
2409
+ * Name
2410
+ *
2411
+ * Human-readable name of the workflow.
2412
+ */
2413
+ name: string;
2414
+ /**
2415
+ * Updated At
2416
+ *
2417
+ * Timestamp when the workflow was last modified (ISO 8601).
2418
+ */
2419
+ updated_at?: string | null;
1594
2420
  };
1595
2421
  /**
1596
2422
  * _FieldOperand
@@ -1599,7 +2425,7 @@ type FieldOperand = {
1599
2425
  /**
1600
2426
  * Field
1601
2427
  *
1602
- * persistent_id of the compared field.
2428
+ * The compared field. Either the field's ``persistent_id`` (Studio field-picker path) or its ``sanitized_name`` as it appears in the extraction response (SDK/API/assistant path) — the executor resolves both.
1603
2429
  */
1604
2430
  field: string;
1605
2431
  /**
@@ -1657,12 +2483,18 @@ type ExtractedField<T = unknown> = Omit<ExtractedField$1, "value" | "value_overr
1657
2483
  value: T | null;
1658
2484
  value_override?: T | null;
1659
2485
  };
2486
+ /**
2487
+ * A list/object-array field (e.g. `line_items`): one entry per row, each row a
2488
+ * record of named `ExtractedField`s. This is the shape `field()` returns for a
2489
+ * non-scalar field.
2490
+ */
2491
+ type ExtractedRows = Array<Record<string, ExtractedField>>;
1660
2492
  /** Typed wrapper over a completed run's results. */
1661
2493
  declare class Result {
1662
- readonly raw: ResultsResponse;
2494
+ readonly raw: ResultsResponseV3;
1663
2495
  private _parse;
1664
- constructor(raw: ResultsResponse);
1665
- get collectionId(): string;
2496
+ constructor(raw: ResultsResponseV3);
2497
+ get documentPacketId(): string;
1666
2498
  get extractions(): Extraction[];
1667
2499
  /**
1668
2500
  * Typed view over the parse node's output, or `null` when the workflow has
@@ -1670,57 +2502,148 @@ declare class Result {
1670
2502
  */
1671
2503
  get parse(): ParseView | null;
1672
2504
  /**
1673
- * Convenience accessor for a top-level scalar field on the first
1674
- * extraction (linear workflows). Returns `undefined` for missing fields
1675
- * or list-valued fields — read `extractions` directly for those.
2505
+ * Convenience accessor for a top-level field on the untagged (linear)
2506
+ * extraction. Returns the scalar `ExtractedField` for a scalar field, or
2507
+ * the array of row records (`ExtractedRows`) for a list/object field such
2508
+ * as `line_items`. `undefined` only when the field is absent.
1676
2509
  *
1677
- * Parameterise with the declared schema type to type `.value`:
2510
+ * Parameterise with the declared schema type to type a scalar's `.value`:
1678
2511
  * `result.field<number>("total").value` is `number | null`.
1679
2512
  */
1680
- field<T = unknown>(name: string): ExtractedField<T> | undefined;
2513
+ field<T = unknown>(name: string): ExtractedField<T> | ExtractedRows | undefined;
1681
2514
  }
1682
2515
 
1683
2516
  interface WaitOptions {
1684
2517
  /** Overall budget before giving up. Default 300 000 ms (300s). */
1685
2518
  timeoutMs?: number;
1686
- /** Delay between result polls. Default 3 000 ms (3s). */
2519
+ /** Delay between status polls. Default 3 000 ms (3s). */
1687
2520
  pollMs?: number;
1688
2521
  }
1689
2522
  /**
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`.
2523
+ * One execution attempt of a workflow against a document packet. Created
2524
+ * eagerly by the run triggers — the extraction is already enqueued by the
2525
+ * time you hold a `Run`. `wait()` polls `GET /v3/runs/{run_id}/` until the
2526
+ * status is terminal and returns the inline results.
1693
2527
  */
1694
2528
  declare class Run {
1695
2529
  private readonly client;
1696
- readonly workflowId: string;
1697
2530
  readonly id: string;
2531
+ readonly workflowId: string;
2532
+ readonly documentPacketId: string;
2533
+ /** Status at trigger time, refreshed on every `wait()` poll. */
2534
+ status: RunStatus;
1698
2535
  /** @internal */
1699
- constructor(client: Client, workflowId: string, id: string);
2536
+ constructor(client: Client, id: string, workflowId: string, documentPacketId: string, status?: RunStatus);
1700
2537
  wait(opts?: WaitOptions): Promise<Result>;
1701
2538
  }
1702
2539
 
2540
+ interface RunTriggerOptions {
2541
+ /**
2542
+ * Caller-supplied key (Stripe convention). Retrying with the same key
2543
+ * returns the original run instead of triggering (and billing) a second
2544
+ * extraction.
2545
+ */
2546
+ idempotencyKey?: string;
2547
+ }
2548
+ /**
2549
+ * Options for the methods that stage an upload (`Workflow.run`,
2550
+ * `Workflow.upload`). Adds the filename-conflict policy on top of the
2551
+ * run-trigger options — it only applies where files are actually uploaded,
2552
+ * which is why the run-only paths (`Upload.run`, `Anyformat.runDocumentPacket`)
2553
+ * take {@link RunTriggerOptions} instead and don't accept it.
2554
+ */
2555
+ interface UploadOptions extends RunTriggerOptions {
2556
+ /**
2557
+ * How the server resolves an uploaded filename that already exists in the
2558
+ * workflow (filenames are unique within a workflow). `"error"` (the server
2559
+ * default) rejects the whole upload with `409`; `"rename"` auto-renames
2560
+ * (`invoice.pdf` → `invoice (1).pdf`). Omit to use the server default.
2561
+ */
2562
+ onConflict?: "error" | "rename";
2563
+ }
2564
+ /**
2565
+ * Options for URL imports. The server derives the filename from each URL, so
2566
+ * there is no idempotency key — only the conflict policy applies.
2567
+ */
2568
+ interface UploadFromUrlsOptions {
2569
+ /** See {@link UploadOptions.onConflict}. Omit to use the server default. */
2570
+ onConflict?: "error" | "rename";
2571
+ }
2572
+ /**
2573
+ * Options for a dataset upload (`Workflow.uploadToDataset`), mirroring the
2574
+ * regular upload's conflict policy.
2575
+ */
2576
+ interface DatasetUploadOptions {
2577
+ /**
2578
+ * The expected document (ground truth) for this document packet, as a plain
2579
+ * object — the SDK JSON-encodes it for the multipart field. Keys are the
2580
+ * workflow schema's field identifiers (advertise `persistent_id`); a scalar
2581
+ * field maps to `string | null`, a table/object field to an array of row
2582
+ * objects. Ground truth attaches to the workflow's current version.
2583
+ */
2584
+ groundTruth?: Record<string, unknown> | null;
2585
+ /**
2586
+ * Caller-supplied key (Stripe convention). Retrying with the same key
2587
+ * replays the original document packet instead of registering a duplicate
2588
+ * document.
2589
+ */
2590
+ idempotencyKey?: string;
2591
+ /**
2592
+ * Filename-collision policy. Omit to use the server default (`error`): a
2593
+ * colliding name fails with `409`. `rename` auto-renames the collision and
2594
+ * the returned file's `original_name` holds the name you sent.
2595
+ */
2596
+ onConflict?: "error" | "rename";
2597
+ }
2598
+ /**
2599
+ * One document for a bulk dataset upload: 1..100 files plus optional
2600
+ * ground truth. Mirrors the arguments of `Workflow.uploadToDataset`.
2601
+ */
2602
+ interface DatasetDocument {
2603
+ /** 1..10 named files forming ONE document (one document packet in the dataset). */
2604
+ files: File | File[];
2605
+ /** See {@link DatasetUploadOptions.groundTruth}. */
2606
+ groundTruth?: Record<string, unknown> | null;
2607
+ /** See {@link DatasetUploadOptions.idempotencyKey}. */
2608
+ idempotencyKey?: string;
2609
+ /** See {@link DatasetUploadOptions.onConflict}. */
2610
+ onConflict?: "error" | "rename";
2611
+ }
1703
2612
  /**
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.
2613
+ * One document registered into a workflow's dataset as one
2614
+ * document packet. Returned by `Workflow.uploadToDataset()`. `documentPacketId` is the
2615
+ * stable handle for the document; `groundTruthSaved` is `true` only when
2616
+ * ground truth was supplied and stored.
2617
+ */
2618
+ declare class DatasetUpload {
2619
+ readonly workflowId: string;
2620
+ readonly documentPacketId: string;
2621
+ readonly files: DatasetUploadFileV3[];
2622
+ readonly groundTruthSaved: boolean;
2623
+ /** @internal */
2624
+ constructor(workflowId: string, documentPacketId: string, files: DatasetUploadFileV3[], groundTruthSaved: boolean);
2625
+ }
2626
+ /**
2627
+ * A document packet staged in a workflow but not yet run. Returned by
2628
+ * `Workflow.upload()` / `Workflow.uploadFromUrls()`. Call `run()` to start
2629
+ * extraction — uploading alone spends no credits.
1707
2630
  */
1708
2631
  declare class Upload {
1709
2632
  private readonly client;
1710
2633
  readonly workflowId: string;
1711
- readonly collectionId: string;
1712
- readonly fileId: string | null;
2634
+ readonly documentPacketId: string;
2635
+ readonly files: DocumentPacketFileV3[];
1713
2636
  /** @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>;
2637
+ constructor(client: Client, workflowId: string, documentPacketId: string, files: DocumentPacketFileV3[]);
2638
+ /** Trigger extraction on the staged packet and return a pending `Run`. */
2639
+ run(opts?: RunTriggerOptions): Promise<Run>;
1717
2640
  }
1718
2641
 
1719
2642
  /**
1720
2643
  * 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.
2644
+ * `run(files)` uploads a document packet and starts extraction, returning a
2645
+ * `Run` you can `.wait()` on. `upload(files)` stages a packet without
2646
+ * running it; call `.run()` on the returned `Upload` to extract.
1724
2647
  */
1725
2648
  declare class Workflow {
1726
2649
  private readonly client;
@@ -1728,13 +2651,33 @@ declare class Workflow {
1728
2651
  readonly name: string;
1729
2652
  /** @internal */
1730
2653
  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>;
2654
+ /** Upload 1..100 files as one document packet and run it. Returns a pending `Run`. */
2655
+ run(files?: File | File[] | null, opts?: UploadOptions): Promise<Run>;
2656
+ /**
2657
+ * Stage 1..100 files as one document packet WITHOUT running it (no credits
2658
+ * spent). Returns an `Upload`; call `.run()` on it to start extraction.
2659
+ */
2660
+ upload(files?: File | File[] | null, opts?: UploadOptions): Promise<Upload>;
2661
+ /**
2662
+ * Upload 1..100 files as ONE document (+ optional ground truth) into the
2663
+ * workflow's dataset, as one document packet. Atomic: any rejected file or a
2664
+ * ground-truth failure fails the call and stores nothing. By default a
2665
+ * colliding filename fails with `409`; pass `onConflict: "rename"` to
2666
+ * auto-rename instead.
2667
+ */
2668
+ uploadToDataset(files?: File | File[] | null, opts?: DatasetUploadOptions): Promise<DatasetUpload>;
2669
+ /**
2670
+ * Client-orchestrated bulk dataset upload: one atomic call per document,
2671
+ * in order. There is no batch endpoint — each document is bounded and
2672
+ * independently retryable. On failure the call rejects; documents already
2673
+ * uploaded stay registered.
2674
+ */
2675
+ uploadDocumentsToDataset(documents: DatasetDocument[]): Promise<DatasetUpload[]>;
1733
2676
  /**
1734
- * Stage a document in this workflow WITHOUT running it (no credits spent).
2677
+ * Import 1..10 HTTPS URLs server-side into one document packet, atomically.
1735
2678
  * Returns an `Upload`; call `.run()` on it to start extraction.
1736
2679
  */
1737
- upload(file?: File | null): Promise<Upload>;
2680
+ uploadFromUrls(urls: string[], opts?: UploadFromUrlsOptions): Promise<Upload>;
1738
2681
  }
1739
2682
 
1740
2683
  /** Any extraction field — the discriminated union on `data_type`. */
@@ -1744,37 +2687,52 @@ type Field = ExtractionSchema["fields"][number];
1744
2687
  * level of nesting is supported, so objects cannot contain objects.
1745
2688
  */
1746
2689
  type NestedField = ObjectField["nested_fields"][number];
1747
- type LookupOpt = {
1748
- lookup?: boolean;
1749
- };
2690
+ interface FieldOpts {
2691
+ /**
2692
+ * How the field gets its value: `"extraction"` (from the document,
2693
+ * the default), `"smart_lookup"` (from the lookup file, always
2694
+ * overwrites) or `"lookup_if_missing"` (extracted too; the lookup only
2695
+ * fills it where extraction left no value).
2696
+ */
2697
+ source?: "extraction" | "smart_lookup" | "lookup_if_missing";
2698
+ /**
2699
+ * Server-assigned stable field identity from `GET /v3/workflows/{id}/`.
2700
+ * Echo it on updates — including across renames — to keep quality
2701
+ * metrics, ground truth and analytics attached to the field. Omit for
2702
+ * new fields.
2703
+ */
2704
+ persistentId?: string;
2705
+ }
1750
2706
  /**
1751
2707
  * Factory for extraction-schema fields — the TS mirror of the Python
1752
2708
  * `Schema` facade. Each method returns the typed wire model the API
1753
2709
  * validates against; the discriminator (`data_type`) is filled in for you.
1754
2710
  */
1755
2711
  declare const Schema: {
1756
- string: (name: string, description: string, opts?: LookupOpt) => StringField;
1757
- integer: (name: string, description: string, opts?: LookupOpt) => IntegerField;
1758
- float: (name: string, description: string, opts?: LookupOpt) => FloatField;
1759
- boolean: (name: string, description: string, opts?: LookupOpt) => BooleanField;
1760
- date: (name: string, description: string, opts?: LookupOpt) => DateField;
1761
- datetime: (name: string, description: string, opts?: LookupOpt) => DatetimeField;
1762
- enum: (name: string, description: string, options: EnumOption[], opts?: LookupOpt) => EnumField;
1763
- multiSelect: (name: string, description: string, options: EnumOption[], opts?: LookupOpt) => MultiSelectField;
1764
- object: (name: string, description: string, fields: NestedField[], opts?: LookupOpt) => ObjectField;
2712
+ string: (name: string, description: string, opts?: FieldOpts) => StringField;
2713
+ integer: (name: string, description: string, opts?: FieldOpts) => IntegerField;
2714
+ float: (name: string, description: string, opts?: FieldOpts) => FloatField;
2715
+ boolean: (name: string, description: string, opts?: FieldOpts) => BooleanField;
2716
+ date: (name: string, description: string, opts?: FieldOpts) => DateField;
2717
+ datetime: (name: string, description: string, opts?: FieldOpts) => DatetimeField;
2718
+ enum: (name: string, description: string, options: EnumOption[], opts?: FieldOpts) => EnumField;
2719
+ multiSelect: (name: string, description: string, options: EnumOption[], opts?: FieldOpts) => MultiSelectField;
2720
+ object: (name: string, description: string, fields: NestedField[], opts?: FieldOpts) => ObjectField;
1765
2721
  option: (name: string, description: string) => EnumOption;
1766
2722
  };
1767
2723
 
1768
- type ExtractMode = "standard" | "agentic" | "max" | "lite";
2724
+ type ExtractMode = "standard" | "agentic" | "lite";
1769
2725
  type AgenticEffort = "low" | "mid" | "accurate";
1770
- type OcrEffort = "medium" | "high";
1771
- type OcrRegion = "eu" | "global";
1772
- type RoutingEffort = "minimal" | "low" | "medium" | "high";
2726
+ type ScannedPages = "ocr" | "skip" | "fail";
2727
+ /** How much reasoning a node asks a model for. Taken from the generated wire types, which
2728
+ * follow the Python `ReasoningEffort` alias, so a new level needs no edit here.
2729
+ * The Python gives `ExtractNode.lookup_reasoning_effort`
2730
+ * that same alias, so one of the two fields derives the type for both. */
2731
+ type ReasoningEffort = NonNullable<PublicExtractNode["lookup_reasoning_effort"]>;
1773
2732
  /** Source-port label routing into an extract/validate node. */
1774
2733
  type Branch = string | ClassifyCategory | SplitterRule;
1775
2734
  /** Knobs shared by every parse mode. */
1776
2735
  interface ParseOptionsBase {
1777
- promptHint?: string;
1778
2736
  figureEnhancement?: boolean;
1779
2737
  cache?: boolean;
1780
2738
  id?: string;
@@ -1782,21 +2740,22 @@ interface ParseOptionsBase {
1782
2740
  /**
1783
2741
  * Parse options as a `mode`-discriminated union: each mode only accepts its own knobs, so a lite
1784
2742
  * 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.
2743
+ * optional only on the standard variant (the default), required on agentic/lite. Lite has no
2744
+ * knobs of its own — one recipe, OCR-only — and never reads `promptHint`.
1786
2745
  */
1787
2746
  type ParseOptions = (ParseOptionsBase & {
1788
2747
  mode?: "standard";
2748
+ promptHint?: string;
1789
2749
  }) | (ParseOptionsBase & {
1790
2750
  mode: "agentic";
1791
2751
  effort?: AgenticEffort;
2752
+ promptHint?: string;
1792
2753
  }) | (ParseOptionsBase & {
1793
2754
  mode: "lite";
1794
- ocrEffort?: OcrEffort;
1795
- region?: OcrRegion;
1796
- skipRoutingReview?: boolean;
1797
- figures?: boolean;
1798
- textFormatting?: boolean;
1799
- routingEffort?: RoutingEffort;
2755
+ }) | (ParseOptionsBase & {
2756
+ mode: "flash";
2757
+ scannedPages?: ScannedPages;
2758
+ promptHint?: string;
1800
2759
  });
1801
2760
  /**
1802
2761
  * Fluent assembler for a typed workflow graph — a faithful TS port of the
@@ -1833,7 +2792,7 @@ declare class WorkflowBuilder {
1833
2792
  mode?: ExtractMode;
1834
2793
  lookupFiles?: string[];
1835
2794
  lookupSuggestion?: string;
1836
- lookupReasoningEffort?: RoutingEffort;
2795
+ lookupReasoningEffort?: ReasoningEffort;
1837
2796
  useImages?: boolean;
1838
2797
  }): this;
1839
2798
  validate(rules: ValidationRule[], opts?: {
@@ -1844,9 +2803,9 @@ declare class WorkflowBuilder {
1844
2803
  private normalizeExtractBranch;
1845
2804
  /** Assemble the wire request (branch-routed edges). Pure — no network. */
1846
2805
  build(): WorkflowCreateRequest;
1847
- /** Persist the workflow and return a handle you can `.run(file)` on. */
2806
+ /** Persist the workflow and return a handle you can `.run(files)` on. */
1848
2807
  create(): Promise<Workflow>;
1849
- /** Replace an existing workflow's definition and return a handle you can `.run(file)` on. */
2808
+ /** Replace an existing workflow's typed graph and return a handle you can `.run(files)` on. */
1850
2809
  update(workflowId: string): Promise<Workflow>;
1851
2810
  }
1852
2811
 
@@ -1855,70 +2814,155 @@ interface AnyformatOptions {
1855
2814
  /** Override the API base URL (defaults to production). */
1856
2815
  baseUrl?: string;
1857
2816
  }
2817
+ /** One keyset page. Follow `nextCursor` (pass it as `cursor`) until it is `null`. */
2818
+ interface Page<T> {
2819
+ items: T[];
2820
+ nextCursor: string | null;
2821
+ }
2822
+ interface ListOptions {
2823
+ /** Page size, capped at 100 by the API. */
2824
+ limit?: number;
2825
+ /** Opaque token from a previous page's `nextCursor`. */
2826
+ cursor?: string;
2827
+ }
2828
+ interface IterOptions {
2829
+ /** Page size the auto-pager fetches per underlying request, capped at 100 by the API. */
2830
+ limit?: number;
2831
+ }
2832
+ /**
2833
+ * The editable sub-shape of a workflow: exactly what `GET /v3/workflows/{id}/`
2834
+ * returns minus the read-only fields, and exactly what PATCH accepts — so a
2835
+ * fetched `WorkflowDetailV3` can be mutated and sent back as-is.
2836
+ */
2837
+ type WorkflowDefinition = Pick<WorkflowDetailV3, "name" | "description" | "nodes" | "edges">;
1858
2838
  /** Entry point. `new Anyformat({ apiKey }).workflow("name").parse()...` */
1859
2839
  declare class Anyformat {
1860
2840
  /** @internal */
1861
2841
  readonly _client: Client;
1862
2842
  constructor(opts: AnyformatOptions);
1863
2843
  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[]>;
2844
+ listWorkflows(opts?: ListOptions): Promise<Page<Workflow>>;
2845
+ /** Retrieve a workflow with its complete typed graph inline (round-trippable into `updateWorkflow`). */
2846
+ getWorkflow(workflowId: string): Promise<WorkflowDetailV3>;
1874
2847
  /**
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.
2848
+ * Replace a workflow's typed graph (atomic). Accepts the shape `getWorkflow`
2849
+ * returns — echo each field's `persistent_id` unchanged (including across
2850
+ * renames) to keep the field's identity; omit it for new fields.
2851
+ */
2852
+ updateWorkflow(workflowId: string, definition: WorkflowDefinition): Promise<WorkflowDetailV3>;
2853
+ deleteWorkflow(workflowId: string): Promise<string>;
2854
+ /** Stage 1..100 files as one document packet without running it. Returns an `Upload`. */
2855
+ upload(workflowId: string, files: File | File[], opts?: UploadOptions): Promise<Upload>;
2856
+ /** Upload 1..100 files (+ optional ground truth) as one dataset collection. Returns a `DatasetUpload`. */
2857
+ uploadToDataset(workflowId: string, files: File | File[], opts?: DatasetUploadOptions): Promise<DatasetUpload>;
2858
+ /** Bulk-upload documents into a workflow's dataset, one atomic call per document. */
2859
+ uploadDocumentsToDataset(workflowId: string, documents: DatasetDocument[]): Promise<DatasetUpload[]>;
2860
+ getDocumentPacket(documentPacketId: string): Promise<DocumentPacketDetailV3>;
2861
+ /** Delete a document packet and all its files. Irreversible. */
2862
+ deleteDocumentPacket(documentPacketId: string): Promise<string>;
2863
+ /** Run (or re-run) a document packet on the latest version of its workflow. */
2864
+ runDocumentPacket(documentPacketId: string, opts?: RunTriggerOptions): Promise<Run>;
2865
+ listDocumentPackets(workflowId: string, opts?: ListOptions): Promise<Page<DocumentPacketSummaryV3>>;
2866
+ listRuns(workflowId: string, opts?: ListOptions): Promise<Page<RunSummaryV3>>;
2867
+ /**
2868
+ * Every workflow, following `nextCursor` across pages so no rows are silently
2869
+ * truncated. Lazy — each page is fetched on demand as the iterator advances.
2870
+ */
2871
+ iterWorkflows(opts?: IterOptions): AsyncIterableIterator<Workflow>;
2872
+ /** Every document packet of a workflow, following `nextCursor` across pages. Lazy. */
2873
+ iterDocumentPackets(workflowId: string, opts?: IterOptions): AsyncIterableIterator<DocumentPacketSummaryV3>;
2874
+ /** Every run of a workflow, following `nextCursor` across pages. Lazy. */
2875
+ iterRuns(workflowId: string, opts?: IterOptions): AsyncIterableIterator<RunSummaryV3>;
2876
+ /** Retrieve one run: lifecycle status plus results inline once `processed`. */
2877
+ getRun(runId: string): Promise<RunDetailV3>;
2878
+ /**
2879
+ * Parse a document with the platform's atomic parse operation (fast lite
2880
+ * parse). Returns the run id; poll `getParseMarkdown(runId)` for the parsed
2881
+ * markdown.
1878
2882
  */
1879
2883
  parse(file: Blob | File): Promise<string>;
1880
2884
  /**
1881
- * Poll a parse job. Returns the parsed markdown once the job is done, or
1882
- * `null` while it is still processing.
2885
+ * Poll a parse run. Returns the parsed markdown once the run is `processed`,
2886
+ * or `null` while it is still queued or in progress.
1883
2887
  */
1884
- getParseMarkdown(jobId: string): Promise<string | null>;
2888
+ getParseMarkdown(runId: string): Promise<string | null>;
1885
2889
  }
1886
2890
 
1887
2891
  declare class AnyformatError extends Error {
1888
2892
  }
2893
+ /** Any JSON value the envelope's free-shaped `detail` may carry. */
2894
+ type JsonValue = string | number | boolean | null | JsonValue[] | {
2895
+ [key: string]: JsonValue;
2896
+ };
2897
+ /** One field-level failure; the `detail` convention of validation errors. */
2898
+ interface ValidationItem {
2899
+ type: string;
2900
+ loc: (string | number)[];
2901
+ msg: string;
2902
+ }
2903
+ /** A `params` value: a scalar, `null`, or an array of those. */
2904
+ type ScalarOrList = string | number | boolean | null | (string | number | boolean | null)[];
1889
2905
  declare class APIError extends AnyformatError {
1890
2906
  readonly status: number;
1891
2907
  readonly body?: unknown | undefined;
2908
+ /** Stable identifier for programmatic handling, e.g. `PAYMENT_REQUIRED`. */
2909
+ readonly errorCode?: string;
2910
+ /** Developer-facing explanation; not surfaced in `message` (ADR platform/0053 §2). Often a `ValidationItem[]`. */
2911
+ readonly detail?: JsonValue;
2912
+ /** Named substitutions the `error` summary refers to, e.g. `{ required_scope }`. */
2913
+ readonly params?: Record<string, ScalarOrList>;
2914
+ /** Whether the API says retrying the same request can succeed. */
2915
+ readonly retryable?: boolean;
2916
+ /** Correlation id to quote in support requests. */
2917
+ readonly requestId?: string;
1892
2918
  constructor(status: number, message: string, body?: unknown | undefined);
1893
2919
  }
1894
2920
  declare class BadRequestError extends APIError {
1895
2921
  }
1896
2922
  declare class UnauthorizedError extends APIError {
1897
2923
  }
2924
+ declare class PaymentRequiredError extends APIError {
2925
+ }
1898
2926
  declare class ForbiddenError extends APIError {
1899
2927
  }
1900
2928
  declare class NotFoundError extends APIError {
1901
2929
  }
1902
2930
  declare class RateLimitedError extends APIError {
2931
+ /** Seconds the API asks the caller to wait, from the `Retry-After` header; `undefined` when absent. */
2932
+ readonly retryAfter?: number | undefined;
2933
+ constructor(status: number, message: string, body?: unknown,
2934
+ /** Seconds the API asks the caller to wait, from the `Retry-After` header; `undefined` when absent. */
2935
+ retryAfter?: number | undefined);
1903
2936
  }
1904
2937
  declare class ServerError extends APIError {
1905
2938
  }
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;
2939
+ /** The API key lacks the scope this call needs (`insufficient_api_key_scope`). */
2940
+ declare class InsufficientScopeError extends ForbiddenError {
2941
+ }
2942
+ /** The caller must accept the terms of service first (`terms_acceptance_required`). */
2943
+ declare class TermsAcceptanceRequiredError extends ForbiddenError {
2944
+ }
2945
+ /** A workflow with that name already exists (`WORKFLOW_NAME_CONFLICT`). */
2946
+ declare class WorkflowNameConflictError extends APIError {
2947
+ }
1916
2948
  declare class SDKTimeoutError extends AnyformatError {
1917
2949
  }
1918
- /** @deprecated Use `SDKTimeoutError`. Alias for one minor release. */
1919
- declare const SDKTimeout: typeof SDKTimeoutError;
2950
+ /** Thrown by `Run.wait()` when the run reaches a terminal failure status. */
2951
+ declare class RunFailedError extends AnyformatError {
2952
+ readonly runId: string;
2953
+ readonly status: "error" | "cancelled";
2954
+ constructor(runId: string, status: "error" | "cancelled");
2955
+ }
2956
+ /** The run ended in the terminal `error` status. */
2957
+ declare class ExtractionFailedError extends RunFailedError {
2958
+ constructor(runId: string);
2959
+ }
2960
+ /** The run ended in the terminal `cancelled` status. */
2961
+ declare class ExtractionCancelledError extends RunFailedError {
2962
+ constructor(runId: string);
2963
+ }
1920
2964
  /** Raised by the fluent `WorkflowBuilder` for builder-API misuse. */
1921
2965
  declare class WorkflowBuilderError extends AnyformatError {
1922
2966
  }
1923
2967
 
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 };
2968
+ export { APIError, type AllOfCheck, type AnyOfCheck, Anyformat, AnyformatError, type AnyformatOptions, type ArithmeticCheck, BadRequestError, type Block, type BooleanField, type Branch, type ClassifyCategory, type ComparisonCheck, type DatasetDocument, DatasetUpload, type DatasetUploadFileV3, type DatasetUploadOptions, type DatasetUploadResponseV3, type DateCheck, type DateField, type DatetimeField, type DocumentPacketDetailV3, type DocumentPacketFileV3, type DocumentPacketStatus, type DocumentPacketSummaryV3, type Edge, type EnumField, type EnumOption, type ExpressionCheck, type ExtractedField, type ExtractedRows, type Extraction, ExtractionCancelledError, ExtractionFailedError, type ExtractionSchema, type Field, type FloatField, ForbiddenError, InsufficientScopeError, type IntegerField, type IterOptions, type JsonValue, type ListOptions, type MultiSelectField, type NestedField, NotFoundError, type ObjectField, type OneOfCheck, type Page, type ParseResult, ParseView, PaymentRequiredError, type RangeCheck, RateLimitedError, type RegexCheck, type RequiredCheck, Result, type ResultsResponseV3, Run, type RunDetailV3, RunFailedError, type RunStatus, type RunSummaryV3, type RunTriggerOptions, SDKTimeoutError, type ScalarOrList, Schema, ServerError, type SplitterRule, type StringField, TermsAcceptanceRequiredError, UnauthorizedError, Upload, type UploadFromUrlsOptions, type UploadOptions, type ValidationItem, type ValidationRule, type WaitOptions, Workflow, WorkflowBuilder, WorkflowBuilderError, type WorkflowCreateRequest, type WorkflowDefinition, type WorkflowDetailV3, WorkflowNameConflictError, type WorkflowSummaryV3 };