bem-ai-sdk 0.28.0 → 0.29.0

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.
Files changed (126) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/client.d.mts +10 -10
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +10 -10
  5. package/client.d.ts.map +1 -1
  6. package/client.js.map +1 -1
  7. package/client.mjs.map +1 -1
  8. package/package.json +1 -1
  9. package/resources/buckets.d.mts +9 -113
  10. package/resources/buckets.d.mts.map +1 -1
  11. package/resources/buckets.d.ts +9 -113
  12. package/resources/buckets.d.ts.map +1 -1
  13. package/resources/buckets.js +3 -3
  14. package/resources/buckets.js.map +1 -1
  15. package/resources/buckets.mjs +3 -3
  16. package/resources/buckets.mjs.map +1 -1
  17. package/resources/entities/entities.d.mts +52 -103
  18. package/resources/entities/entities.d.mts.map +1 -1
  19. package/resources/entities/entities.d.ts +52 -103
  20. package/resources/entities/entities.d.ts.map +1 -1
  21. package/resources/entities/entities.js.map +1 -1
  22. package/resources/entities/entities.mjs.map +1 -1
  23. package/resources/entities/index.d.mts +1 -1
  24. package/resources/entities/index.d.mts.map +1 -1
  25. package/resources/entities/index.d.ts +1 -1
  26. package/resources/entities/index.d.ts.map +1 -1
  27. package/resources/entities/index.js.map +1 -1
  28. package/resources/entities/index.mjs.map +1 -1
  29. package/resources/entity-types/entity-types.d.mts +8 -124
  30. package/resources/entity-types/entity-types.d.mts.map +1 -1
  31. package/resources/entity-types/entity-types.d.ts +8 -124
  32. package/resources/entity-types/entity-types.d.ts.map +1 -1
  33. package/resources/entity-types/entity-types.js.map +1 -1
  34. package/resources/entity-types/entity-types.mjs.map +1 -1
  35. package/resources/entity-types/index.d.mts +2 -2
  36. package/resources/entity-types/index.d.mts.map +1 -1
  37. package/resources/entity-types/index.d.ts +2 -2
  38. package/resources/entity-types/index.d.ts.map +1 -1
  39. package/resources/entity-types/index.js.map +1 -1
  40. package/resources/entity-types/index.mjs.map +1 -1
  41. package/resources/entity-types/reviewers.d.mts +10 -39
  42. package/resources/entity-types/reviewers.d.mts.map +1 -1
  43. package/resources/entity-types/reviewers.d.ts +10 -39
  44. package/resources/entity-types/reviewers.d.ts.map +1 -1
  45. package/resources/entity-types/reviewers.js +1 -1
  46. package/resources/entity-types/reviewers.js.map +1 -1
  47. package/resources/entity-types/reviewers.mjs +1 -1
  48. package/resources/entity-types/reviewers.mjs.map +1 -1
  49. package/resources/eval/eval.d.mts +2 -2
  50. package/resources/eval/eval.d.mts.map +1 -1
  51. package/resources/eval/eval.d.ts +2 -2
  52. package/resources/eval/eval.d.ts.map +1 -1
  53. package/resources/eval/eval.js.map +1 -1
  54. package/resources/eval/eval.mjs.map +1 -1
  55. package/resources/eval/index.d.mts +1 -1
  56. package/resources/eval/index.d.mts.map +1 -1
  57. package/resources/eval/index.d.ts +1 -1
  58. package/resources/eval/index.d.ts.map +1 -1
  59. package/resources/eval/index.js.map +1 -1
  60. package/resources/eval/index.mjs.map +1 -1
  61. package/resources/eval/score.d.mts +60 -219
  62. package/resources/eval/score.d.mts.map +1 -1
  63. package/resources/eval/score.d.ts +60 -219
  64. package/resources/eval/score.d.ts.map +1 -1
  65. package/resources/eval/score.js +2 -2
  66. package/resources/eval/score.js.map +1 -1
  67. package/resources/eval/score.mjs +2 -2
  68. package/resources/eval/score.mjs.map +1 -1
  69. package/resources/functions/functions.d.mts +364 -1095
  70. package/resources/functions/functions.d.mts.map +1 -1
  71. package/resources/functions/functions.d.ts +364 -1095
  72. package/resources/functions/functions.d.ts.map +1 -1
  73. package/resources/functions/functions.js.map +1 -1
  74. package/resources/functions/functions.mjs.map +1 -1
  75. package/resources/functions/index.d.mts +1 -1
  76. package/resources/functions/index.d.mts.map +1 -1
  77. package/resources/functions/index.d.ts +1 -1
  78. package/resources/functions/index.d.ts.map +1 -1
  79. package/resources/functions/index.js.map +1 -1
  80. package/resources/functions/index.mjs.map +1 -1
  81. package/resources/functions/versions.d.mts +2 -108
  82. package/resources/functions/versions.d.mts.map +1 -1
  83. package/resources/functions/versions.d.ts +2 -108
  84. package/resources/functions/versions.d.ts.map +1 -1
  85. package/resources/index.d.mts +5 -5
  86. package/resources/index.d.mts.map +1 -1
  87. package/resources/index.d.ts +5 -5
  88. package/resources/index.d.ts.map +1 -1
  89. package/resources/index.js.map +1 -1
  90. package/resources/index.mjs.map +1 -1
  91. package/resources/outputs.d.mts +1 -1
  92. package/resources/outputs.d.mts.map +1 -1
  93. package/resources/outputs.d.ts +1 -1
  94. package/resources/outputs.d.ts.map +1 -1
  95. package/resources/views.d.mts +97 -745
  96. package/resources/views.d.mts.map +1 -1
  97. package/resources/views.d.ts +97 -745
  98. package/resources/views.d.ts.map +1 -1
  99. package/resources/workflows/workflows.d.mts +2 -19
  100. package/resources/workflows/workflows.d.mts.map +1 -1
  101. package/resources/workflows/workflows.d.ts +2 -19
  102. package/resources/workflows/workflows.d.ts.map +1 -1
  103. package/resources/workflows/workflows.js.map +1 -1
  104. package/resources/workflows/workflows.mjs.map +1 -1
  105. package/src/client.ts +38 -18
  106. package/src/resources/buckets.ts +9 -137
  107. package/src/resources/entities/entities.ts +61 -118
  108. package/src/resources/entities/index.ts +2 -0
  109. package/src/resources/entity-types/entity-types.ts +8 -151
  110. package/src/resources/entity-types/index.ts +2 -4
  111. package/src/resources/entity-types/reviewers.ts +11 -49
  112. package/src/resources/eval/eval.ts +8 -4
  113. package/src/resources/eval/index.ts +4 -2
  114. package/src/resources/eval/score.ts +66 -263
  115. package/src/resources/functions/functions.ts +411 -1249
  116. package/src/resources/functions/index.ts +8 -0
  117. package/src/resources/functions/versions.ts +2 -118
  118. package/src/resources/index.ts +19 -9
  119. package/src/resources/outputs.ts +1 -0
  120. package/src/resources/views.ts +118 -936
  121. package/src/resources/workflows/workflows.ts +2 -21
  122. package/src/version.ts +1 -1
  123. package/version.d.mts +1 -1
  124. package/version.d.ts +1 -1
  125. package/version.js +1 -1
  126. package/version.mjs +1 -1
@@ -658,7 +658,7 @@ export namespace CreateFunction {
658
658
  * Extract / Join — separated from `parseConfig` so the per-call Parse output shape
659
659
  * stays distinct from operator-level execution flags.
660
660
  */
661
- extraConfig?: ParseFunction.ExtraConfig;
661
+ extraConfig?: FunctionsAPI.ParseExtraFunctionConfig;
662
662
 
663
663
  /**
664
664
  * Per-version configuration for a Parse function.
@@ -675,26 +675,6 @@ export namespace CreateFunction {
675
675
  tags?: Array<string>;
676
676
  }
677
677
 
678
- export namespace ParseFunction {
679
- /**
680
- * Cross-cutting toggles for Parse functions. Mirrors the `extraConfig` surface on
681
- * Extract / Join — separated from `parseConfig` so the per-call Parse output shape
682
- * stays distinct from operator-level execution flags.
683
- */
684
- export interface ExtraConfig {
685
- /**
686
- * When true, return per-section and per-entity-mention coordinates in the parse
687
- * event's `fieldBoundingBoxes` map (same shape as Extract: JSON Pointer key →
688
- * array of `{page, left, top, width, height}` with coordinates normalized to [0,
689
- * 1]). Keys are `/sections/{N}` and `/entities/{N}/occurrences/{M}` into the parse
690
- * output. Only applies to the open-ended discovery path (no `schema`) and to
691
- * vision input types. Bedrock-backed parse functions silently return an empty map
692
- * (no native bbox support). Defaults to false.
693
- */
694
- enableBoundingBoxes?: boolean;
695
- }
696
- }
697
-
698
678
  export interface RenderFunction {
699
679
  /**
700
680
  * Name of function. Must be UNIQUE on a per-environment basis.
@@ -708,7 +688,7 @@ export namespace CreateFunction {
708
688
  * never submit `placeholders` or `styleIds`. The response shape (`RenderConfig`)
709
689
  * returns the derived contract.
710
690
  */
711
- renderConfig: RenderFunction.RenderConfig;
691
+ renderConfig: FunctionsAPI.RenderConfigInput;
712
692
 
713
693
  type: 'render';
714
694
 
@@ -722,35 +702,6 @@ export namespace CreateFunction {
722
702
  */
723
703
  tags?: Array<string>;
724
704
  }
725
-
726
- export namespace RenderFunction {
727
- /**
728
- * Request-side render configuration. Carries the template document as
729
- * base64-encoded `.docx` bytes: the server validates them, stores the template,
730
- * and derives the placeholder/style-id contract at create/update time, so clients
731
- * never submit `placeholders` or `styleIds`. The response shape (`RenderConfig`)
732
- * returns the derived contract.
733
- */
734
- export interface RenderConfig {
735
- template: RenderConfig.Template;
736
- }
737
-
738
- export namespace RenderConfig {
739
- export interface Template {
740
- /**
741
- * Base64-encoded `.docx` bytes. In the Bem CLI, use `@path/to/file` to embed it
742
- * automatically.
743
- */
744
- base64: string;
745
-
746
- /**
747
- * Original upload filename (e.g. `contract.docx`), stored for display only. Does
748
- * not affect where the template is stored.
749
- */
750
- name?: string;
751
- }
752
- }
753
- }
754
705
  }
755
706
 
756
707
  /**
@@ -851,9 +802,9 @@ export namespace EnrichConfig {
851
802
  * Natural-language instructions for LLM agent reasoning.
852
803
  *
853
804
  * When set, the candidates fetched from the endpoint are passed to an LLM with
854
- * these instructions, which selects the best match(es) and returns them with
855
- * confidence scores. Each injected result has the shape
856
- * `{ data, confidence, reasoning? }`.
805
+ * these instructions, which selects the best match(es) and returns them ranked
806
+ * best-first. Each injected result has the shape
807
+ * `{ data, rank, confidence, reasoning? }` (rank is 1-based, 1 = best).
857
808
  *
858
809
  * When omitted, the raw fetched value is injected without any LLM involvement.
859
810
  */
@@ -974,10 +925,30 @@ export namespace EnrichConfig {
974
925
  * - `exact`: Exact keyword matching — best for SKU numbers, IDs, routing numbers
975
926
  * - `hybrid`: Combined semantic + keyword search — best for tags and categories
976
927
  *
977
- * **Result Format (collection source):**
928
+ * **Result Format (collection source, exact mode — no re-ranking):**
978
929
  *
979
930
  * - Always an array sorted by relevance (best match first)
980
- * - Each element: `{ data, cosineDistance? }` or `{ data, hybridScore? }`
931
+ * - Each element: `{ data, cosine_distance? }` or `{ data, hybrid_score? }`
932
+ *
933
+ * **Result Format (collection source, semantic/hybrid — re-ranking always on):**
934
+ *
935
+ * - Re-ranking uses a fixed, built-in instruction to the LLM (rank the candidates
936
+ * by how well each matches the source value); it is not configurable per step
937
+ * - Array of matches, best first:
938
+ * `[{ data, rank, confidence?, reasoning?, score?, scoreType?, cosine_distance?, hybrid_score? }, ...]`
939
+ * - `rank` is 1-based (1 = best)
940
+ * - `confidence` is the LLM's 0–1 score. It is present only for entries the LLM
941
+ * ranked and **omitted** for backfilled entries (see below) — a missing
942
+ * `confidence` means "not ranked by the LLM", not a score of 0
943
+ * - `score` is the original retrieval score and `scoreType` says which metric it
944
+ * is (`"cosineDistance"` for semantic search, `"hybridScore"` for hybrid); both
945
+ * included only when `includeScore` is set
946
+ * - `cosine_distance` (semantic) and `hybrid_score` (hybrid) are **deprecated**
947
+ * (use `score` + `scoreType`): each mirrors `score` under the pre-rerank field
948
+ * name for backward compatibility; exactly one is present, matching `scoreType`
949
+ * - Length is `min(candidates surviving the scoreThreshold filter, topK)`. The LLM
950
+ * re-orders the survivors; if it ranks fewer than that length, the remaining
951
+ * survivors are backfilled in retrieval (score) order with `confidence` omitted
981
952
  *
982
953
  * **Result Format (endpoint source, no matchInstructions):**
983
954
  *
@@ -985,7 +956,9 @@ export namespace EnrichConfig {
985
956
  *
986
957
  * **Result Format (endpoint source, with matchInstructions):**
987
958
  *
988
- * - Array of LLM-ranked matches: `[{ data, confidence, reasoning? }, ...]`
959
+ * - Array of LLM-ranked matches, best first:
960
+ * `[{ data, rank, confidence, reasoning? }, ...]`
961
+ * - `rank` is 1-based (1 = best); `confidence` is the LLM's 0–1 score
989
962
  * - Length capped by `enrichEndpoint.matchTopK` (default 1)
990
963
  */
991
964
  export interface EnrichStep {
@@ -1090,6 +1063,11 @@ export interface EnrichStep {
1090
1063
  *
1091
1064
  * - 1: Returns array with single best match: `[{...}]`
1092
1065
  * - > 1: Returns array with multiple matches: `[{...}, {...}, ...]`
1066
+ *
1067
+ * When re-ranking is on (the default for `semantic`/`hybrid`), `topK` is still the
1068
+ * number of results returned — re-ranking changes their order, not the count. The
1069
+ * candidate pool the LLM chooses from is widened internally to at least 5, so even
1070
+ * `topK: 1` re-ranks a real pool and returns the single best match.
1093
1071
  */
1094
1072
  topK?: number;
1095
1073
  }
@@ -1727,7 +1705,7 @@ export namespace Function {
1727
1705
  * Extract / Join — separated from `parseConfig` so the per-call Parse output shape
1728
1706
  * stays distinct from operator-level execution flags.
1729
1707
  */
1730
- extraConfig?: ParseFunction.ExtraConfig;
1708
+ extraConfig?: FunctionsAPI.ParseExtraFunctionConfig;
1731
1709
 
1732
1710
  /**
1733
1711
  * Per-version configuration for a Parse function.
@@ -1749,26 +1727,6 @@ export namespace Function {
1749
1727
  usedInWorkflows?: Array<FunctionsAPI.WorkflowUsageInfo>;
1750
1728
  }
1751
1729
 
1752
- export namespace ParseFunction {
1753
- /**
1754
- * Cross-cutting toggles for Parse functions. Mirrors the `extraConfig` surface on
1755
- * Extract / Join — separated from `parseConfig` so the per-call Parse output shape
1756
- * stays distinct from operator-level execution flags.
1757
- */
1758
- export interface ExtraConfig {
1759
- /**
1760
- * When true, return per-section and per-entity-mention coordinates in the parse
1761
- * event's `fieldBoundingBoxes` map (same shape as Extract: JSON Pointer key →
1762
- * array of `{page, left, top, width, height}` with coordinates normalized to [0,
1763
- * 1]). Keys are `/sections/{N}` and `/entities/{N}/occurrences/{M}` into the parse
1764
- * output. Only applies to the open-ended discovery path (no `schema`) and to
1765
- * vision input types. Bedrock-backed parse functions silently return an empty map
1766
- * (no native bbox support). Defaults to false.
1767
- */
1768
- enableBoundingBoxes?: boolean;
1769
- }
1770
- }
1771
-
1772
1730
  export interface RenderFunction {
1773
1731
  /**
1774
1732
  * Unique identifier of function.
@@ -1806,7 +1764,7 @@ export namespace Function {
1806
1764
  * the ML service against the bundled core schema; no customer-supplied schema
1807
1765
  * rides this surface.
1808
1766
  */
1809
- renderConfig?: RenderFunction.RenderConfig;
1767
+ renderConfig?: FunctionsAPI.RenderConfig;
1810
1768
 
1811
1769
  /**
1812
1770
  * Array of tags to categorize and organize functions.
@@ -1818,102 +1776,6 @@ export namespace Function {
1818
1776
  */
1819
1777
  usedInWorkflows?: Array<FunctionsAPI.WorkflowUsageInfo>;
1820
1778
  }
1821
-
1822
- export namespace RenderFunction {
1823
- /**
1824
- * Per-version configuration for a Render function.
1825
- *
1826
- * Render emits a `.docx` from schema-typed JSON by composing the JSON into a
1827
- * `.docx` template. The template document is stored server-side; this response
1828
- * exposes only the contract derived from it. Schema validation runs internally in
1829
- * the ML service against the bundled core schema; no customer-supplied schema
1830
- * rides this surface.
1831
- */
1832
- export interface RenderConfig {
1833
- /**
1834
- * The uploaded template: its filename, a short-lived presigned download URL, and
1835
- * the placeholder/style contract derived from it. Absent on configs created before
1836
- * template capture existed.
1837
- */
1838
- template?: RenderConfig.Template;
1839
- }
1840
-
1841
- export namespace RenderConfig {
1842
- /**
1843
- * The uploaded template: its filename, a short-lived presigned download URL, and
1844
- * the placeholder/style contract derived from it. Absent on configs created before
1845
- * template capture existed.
1846
- */
1847
- export interface Template {
1848
- /**
1849
- * Short-lived presigned URL to download the stored `.docx`. The private storage
1850
- * location is never exposed.
1851
- */
1852
- downloadURL?: string;
1853
-
1854
- /**
1855
- * Supported list kinds (`decimal`, `bullet`) the template's `numbering.xml`
1856
- * defines an `abstractNum` for. Empty means the template can hold no list, so any
1857
- * list primitive will fail at render.
1858
- */
1859
- listKinds?: Array<'decimal' | 'bullet'>;
1860
-
1861
- /**
1862
- * Original filename of the uploaded template (e.g. `contract.docx`), echoed back
1863
- * for display. Absent on templates uploaded before the filename was captured.
1864
- */
1865
- name?: string;
1866
-
1867
- /**
1868
- * The placeholder contract a Render template declares, grouped by how each
1869
- * placeholder is filled. Derived from the template at create/update time by
1870
- * scanning its `docxtpl` tags; not user-supplied.
1871
- *
1872
- * - `stringKeys`: bare string placeholders (`{{ key }}`) filled with a single
1873
- * value.
1874
- * - `blockKeys`: wrapped-primitive placeholders (`{{p key }}`) — bind one core
1875
- * primitive (paragraph, table, image, or list). The placeholder's own paragraph
1876
- * dissolves and is replaced by the rendered subdocument's blocks, rather than
1877
- * substituting text inline.
1878
- */
1879
- placeholders?: Template.Placeholders;
1880
-
1881
- /**
1882
- * Paragraph/character style IDs the uploaded template defines and the rendered
1883
- * output can reference. Derived from the template's `styles.xml` at create/update
1884
- * time.
1885
- */
1886
- styleIds?: Array<string>;
1887
-
1888
- /**
1889
- * Style IDs whose type is table — the styles a `table` primitive's required
1890
- * `styleId` can name. Empty means the template defines no table style, so any
1891
- * table primitive will fail at render.
1892
- */
1893
- tableStyleIds?: Array<string>;
1894
- }
1895
-
1896
- export namespace Template {
1897
- /**
1898
- * The placeholder contract a Render template declares, grouped by how each
1899
- * placeholder is filled. Derived from the template at create/update time by
1900
- * scanning its `docxtpl` tags; not user-supplied.
1901
- *
1902
- * - `stringKeys`: bare string placeholders (`{{ key }}`) filled with a single
1903
- * value.
1904
- * - `blockKeys`: wrapped-primitive placeholders (`{{p key }}`) — bind one core
1905
- * primitive (paragraph, table, image, or list). The placeholder's own paragraph
1906
- * dissolves and is replaced by the rendered subdocument's blocks, rather than
1907
- * substituting text inline.
1908
- */
1909
- export interface Placeholders {
1910
- blockKeys: Array<string>;
1911
-
1912
- stringKeys: Array<string>;
1913
- }
1914
- }
1915
- }
1916
- }
1917
1779
  }
1918
1780
 
1919
1781
  export interface FunctionAudit {
@@ -1973,6 +1835,143 @@ export interface ListFunctionsResponse {
1973
1835
  totalCount?: number;
1974
1836
  }
1975
1837
 
1838
+ /**
1839
+ * Comparison of a single metric between two versions
1840
+ */
1841
+ export interface MetricComparison {
1842
+ /**
1843
+ * Value in baseline version (null if not available)
1844
+ */
1845
+ baselineValue?: number | null;
1846
+
1847
+ /**
1848
+ * Value in comparison version (null if not available)
1849
+ */
1850
+ comparisonValue?: number | null;
1851
+
1852
+ /**
1853
+ * Absolute difference (comparisonValue - baselineValue)
1854
+ */
1855
+ difference?: number | null;
1856
+
1857
+ /**
1858
+ * **Percentage change from baseline to comparison**
1859
+ *
1860
+ * Formula: ((comparisonValue - baselineValue) / baselineValue) \* 100
1861
+ *
1862
+ * - Positive values indicate improvement
1863
+ * - Negative values indicate regression
1864
+ */
1865
+ liftPercent?: number | null;
1866
+ }
1867
+
1868
+ /**
1869
+ * Comprehensive performance metrics
1870
+ */
1871
+ export interface Metrics {
1872
+ /**
1873
+ * Overall accuracy
1874
+ */
1875
+ accuracy?: number | null;
1876
+
1877
+ /**
1878
+ * F1 Score (harmonic mean of precision and recall)
1879
+ */
1880
+ f1Score?: number | null;
1881
+
1882
+ /**
1883
+ * False Negatives
1884
+ */
1885
+ fn?: number;
1886
+
1887
+ /**
1888
+ * False Positives
1889
+ */
1890
+ fp?: number;
1891
+
1892
+ /**
1893
+ * Precision (TP / (TP + FP))
1894
+ */
1895
+ precision?: number | null;
1896
+
1897
+ /**
1898
+ * Recall (TP / (TP + FN))
1899
+ */
1900
+ recall?: number | null;
1901
+
1902
+ /**
1903
+ * True Negatives
1904
+ */
1905
+ tn?: number;
1906
+
1907
+ /**
1908
+ * True Positives
1909
+ */
1910
+ tp?: number;
1911
+ }
1912
+
1913
+ /**
1914
+ * Comparison of metrics between two versions
1915
+ */
1916
+ export interface MetricsComparison {
1917
+ /**
1918
+ * Comparison of a single metric between two versions
1919
+ */
1920
+ accuracy?: MetricComparison;
1921
+
1922
+ /**
1923
+ * Comparison of a single metric between two versions
1924
+ */
1925
+ f1Score?: MetricComparison;
1926
+
1927
+ /**
1928
+ * Comparison of a single metric between two versions
1929
+ */
1930
+ precision?: MetricComparison;
1931
+
1932
+ /**
1933
+ * Comparison of a single metric between two versions
1934
+ */
1935
+ recall?: MetricComparison;
1936
+ }
1937
+
1938
+ /**
1939
+ * Detailed performance metrics and analysis
1940
+ */
1941
+ export interface MetricsDetails {
1942
+ /**
1943
+ * Comprehensive performance metrics
1944
+ */
1945
+ aggregateMetrics?: Metrics;
1946
+
1947
+ /**
1948
+ * Enhanced field metrics with comprehensive analytics
1949
+ */
1950
+ fieldMetrics?: Array<MetricsDetails.FieldMetric>;
1951
+
1952
+ /**
1953
+ * Area Under the Precision-Recall Curve
1954
+ */
1955
+ precisionRecallAuc?: number;
1956
+ }
1957
+
1958
+ export namespace MetricsDetails {
1959
+ /**
1960
+ * Enhanced field metrics with comprehensive analytics
1961
+ */
1962
+ export interface FieldMetric {
1963
+ /**
1964
+ * JSON path to the field
1965
+ */
1966
+ fieldPath: string;
1967
+
1968
+ /**
1969
+ * Comprehensive performance metrics
1970
+ */
1971
+ metrics?: FunctionsAPI.Metrics;
1972
+ }
1973
+ }
1974
+
1976
1975
  /**
1977
1976
  * Per-version configuration for a Parse function.
1978
1977
  *
@@ -2014,6 +2013,181 @@ export interface ParseConfig {
2014
2013
  schema?: unknown;
2015
2014
  }
2016
2015
 
2016
+ /**
2017
+ * Cross-cutting toggles for Parse functions. Mirrors the `extraConfig` surface on
2018
+ * Extract / Join — separated from `parseConfig` so the per-call Parse output shape
2019
+ * stays distinct from operator-level execution flags.
2020
+ */
2021
+ export interface ParseExtraFunctionConfig {
2022
+ /**
2023
+ * When true, return per-section and per-entity-mention coordinates in the parse
2024
+ * event's `fieldBoundingBoxes` map (same shape as Extract: JSON Pointer key →
2025
+ * array of `{page, left, top, width, height}` with coordinates normalized to [0,
2026
+ * 1]). Keys are `/sections/{N}` and `/entities/{N}/occurrences/{M}` into the parse
2027
+ * output. Only applies to the open-ended discovery path (no `schema`) and to
2028
+ * vision input types. Bedrock-backed parse functions silently return an empty map
2029
+ * (no native bbox support). Defaults to false.
2030
+ */
2031
+ enableBoundingBoxes?: boolean;
2032
+ }
2033
+
2034
+ /**
2035
+ * Confidence interval for a rate/proportion using Wald (normal approximation)
2036
+ * method by default.
2037
+ *
2038
+ * Wald confidence intervals use the normal approximation to the binomial
2039
+ * distribution. For extreme rates or small sample sizes, Wilson confidence
2040
+ * intervals may be more appropriate.
2041
+ */
2042
+ export interface RateConfidenceInterval {
2043
+ /**
2044
+ * Current number of samples/observations available
2045
+ */
2046
+ currentSample: number;
2047
+
2048
+ /**
2049
+ * Minimum number of samples needed for reliable confidence interval calculation
2050
+ */
2051
+ sampleNeeded: number;
2052
+
2053
+ /**
2054
+ * Lower bound of the confidence interval (null if insufficient sample size)
2055
+ */
2056
+ ciLower?: number | null;
2057
+
2058
+ /**
2059
+ * Upper bound of the confidence interval (null if insufficient sample size)
2060
+ */
2061
+ ciUpper?: number | null;
2062
+
2063
+ /**
2064
+ * Point estimate (observed rate) at the center of the interval (null if
2065
+ * insufficient sample size)
2066
+ */
2067
+ mid?: number | null;
2068
+ }
2069
+
2070
+ /**
2071
+ * Per-version configuration for a Render function.
2072
+ *
2073
+ * Render emits a `.docx` from schema-typed JSON by composing the JSON into a
2074
+ * `.docx` template. The template document is stored server-side; this response
2075
+ * exposes only the contract derived from it. Schema validation runs internally in
2076
+ * the ML service against the bundled core schema; no customer-supplied schema
2077
+ * rides this surface.
2078
+ */
2079
+ export interface RenderConfig {
2080
+ /**
2081
+ * The uploaded template: its filename, a short-lived presigned download URL, and
2082
+ * the placeholder/style contract derived from it. Absent on configs created before
2083
+ * template capture existed.
2084
+ */
2085
+ template?: RenderConfig.Template;
2086
+ }
2087
+
2088
+ export namespace RenderConfig {
2089
+ /**
2090
+ * The uploaded template: its filename, a short-lived presigned download URL, and
2091
+ * the placeholder/style contract derived from it. Absent on configs created before
2092
+ * template capture existed.
2093
+ */
2094
+ export interface Template {
2095
+ /**
2096
+ * Short-lived presigned URL to download the stored `.docx`. The private storage
2097
+ * location is never exposed.
2098
+ */
2099
+ downloadURL?: string;
2100
+
2101
+ /**
2102
+ * Supported list kinds (`decimal`, `bullet`) the template's `numbering.xml`
2103
+ * defines an `abstractNum` for. Empty means the template can hold no list, so any
2104
+ * list primitive will fail at render.
2105
+ */
2106
+ listKinds?: Array<'decimal' | 'bullet'>;
2107
+
2108
+ /**
2109
+ * Original filename of the uploaded template (e.g. `contract.docx`), echoed back
2110
+ * for display. Absent on templates uploaded before the filename was captured.
2111
+ */
2112
+ name?: string;
2113
+
2114
+ /**
2115
+ * The placeholder contract a Render template declares, grouped by how each
2116
+ * placeholder is filled. Derived from the template at create/update time by
2117
+ * scanning its `docxtpl` tags; not user-supplied.
2118
+ *
2119
+ * - `stringKeys`: bare string placeholders (`{{ key }}`) filled with a single
2120
+ * value.
2121
+ * - `blockKeys`: wrapped-primitive placeholders (`{{p key }}`) — bind one core
2122
+ * primitive (paragraph, table, image, or list). The placeholder's own paragraph
2123
+ * dissolves and is replaced by the rendered subdocument's blocks, rather than
2124
+ * substituting text inline.
2125
+ */
2126
+ placeholders?: Template.Placeholders;
2127
+
2128
+ /**
2129
+ * Paragraph/character style IDs the uploaded template defines and the rendered
2130
+ * output can reference. Derived from the template's `styles.xml` at create/update
2131
+ * time.
2132
+ */
2133
+ styleIds?: Array<string>;
2134
+
2135
+ /**
2136
+ * Style IDs whose type is table — the styles a `table` primitive's required
2137
+ * `styleId` can name. Empty means the template defines no table style, so any
2138
+ * table primitive will fail at render.
2139
+ */
2140
+ tableStyleIds?: Array<string>;
2141
+ }
2142
+
2143
+ export namespace Template {
2144
+ /**
2145
+ * The placeholder contract a Render template declares, grouped by how each
2146
+ * placeholder is filled. Derived from the template at create/update time by
2147
+ * scanning its `docxtpl` tags; not user-supplied.
2148
+ *
2149
+ * - `stringKeys`: bare string placeholders (`{{ key }}`) filled with a single
2150
+ * value.
2151
+ * - `blockKeys`: wrapped-primitive placeholders (`{{p key }}`) — bind one core
2152
+ * primitive (paragraph, table, image, or list). The placeholder's own paragraph
2153
+ * dissolves and is replaced by the rendered subdocument's blocks, rather than
2154
+ * substituting text inline.
2155
+ */
2156
+ export interface Placeholders {
2157
+ blockKeys: Array<string>;
2158
+
2159
+ stringKeys: Array<string>;
2160
+ }
2161
+ }
2162
+ }
2163
+
2164
+ /**
2165
+ * Request-side render configuration. Carries the template document as
2166
+ * base64-encoded `.docx` bytes: the server validates them, stores the template,
2167
+ * and derives the placeholder/style-id contract at create/update time, so clients
2168
+ * never submit `placeholders` or `styleIds`. The response shape (`RenderConfig`)
2169
+ * returns the derived contract.
2170
+ */
2171
+ export interface RenderConfigInput {
2172
+ template: RenderConfigInput.Template;
2173
+ }
2174
+
2175
+ export namespace RenderConfigInput {
2176
+ export interface Template {
2177
+ /**
2178
+ * Base64-encoded `.docx` bytes. In the Bem CLI, use `@path/to/file` to embed it
2179
+ * automatically.
2180
+ */
2181
+ base64: string;
2182
+
2183
+ /**
2184
+ * Original upload filename (e.g. `contract.docx`), stored for display only. Does
2185
+ * not affect where the template is stored.
2186
+ */
2187
+ name?: string;
2188
+ }
2189
+ }
2190
+
2017
2191
  /**
2018
2192
  * Destination type for a Send function.
2019
2193
  */
@@ -2375,7 +2549,7 @@ export namespace UpdateFunction {
2375
2549
  * Extract / Join — separated from `parseConfig` so the per-call Parse output shape
2376
2550
  * stays distinct from operator-level execution flags.
2377
2551
  */
2378
- extraConfig?: ParseFunction.ExtraConfig;
2552
+ extraConfig?: FunctionsAPI.ParseExtraFunctionConfig;
2379
2553
 
2380
2554
  /**
2381
2555
  * Name of function. Must be UNIQUE on a per-environment basis.
@@ -2397,26 +2571,6 @@ export namespace UpdateFunction {
2397
2571
  tags?: Array<string>;
2398
2572
  }
2399
2573
 
2400
- export namespace ParseFunction {
2401
- /**
2402
- * Cross-cutting toggles for Parse functions. Mirrors the `extraConfig` surface on
2403
- * Extract / Join — separated from `parseConfig` so the per-call Parse output shape
2404
- * stays distinct from operator-level execution flags.
2405
- */
2406
- export interface ExtraConfig {
2407
- /**
2408
- * When true, return per-section and per-entity-mention coordinates in the parse
2409
- * event's `fieldBoundingBoxes` map (same shape as Extract: JSON Pointer key →
2410
- * array of `{page, left, top, width, height}` with coordinates normalized to [0,
2411
- * 1]). Keys are `/sections/{N}` and `/entities/{N}/occurrences/{M}` into the parse
2412
- * output. Only applies to the open-ended discovery path (no `schema`) and to
2413
- * vision input types. Bedrock-backed parse functions silently return an empty map
2414
- * (no native bbox support). Defaults to false.
2415
- */
2416
- enableBoundingBoxes?: boolean;
2417
- }
2418
- }
2419
-
2420
2574
  export interface RenderFunction {
2421
2575
  type: 'render';
2422
2576
 
@@ -2437,43 +2591,14 @@ export namespace UpdateFunction {
2437
2591
  * never submit `placeholders` or `styleIds`. The response shape (`RenderConfig`)
2438
2592
  * returns the derived contract.
2439
2593
  */
2440
- renderConfig?: RenderFunction.RenderConfig;
2594
+ renderConfig?: FunctionsAPI.RenderConfigInput;
2441
2595
 
2442
2596
  /**
2443
2597
  * Array of tags to categorize and organize functions.
2444
2598
  */
2445
2599
  tags?: Array<string>;
2446
2600
  }
2447
-
2448
- export namespace RenderFunction {
2449
- /**
2450
- * Request-side render configuration. Carries the template document as
2451
- * base64-encoded `.docx` bytes: the server validates them, stores the template,
2452
- * and derives the placeholder/style-id contract at create/update time, so clients
2453
- * never submit `placeholders` or `styleIds`. The response shape (`RenderConfig`)
2454
- * returns the derived contract.
2455
- */
2456
- export interface RenderConfig {
2457
- template: RenderConfig.Template;
2458
- }
2459
-
2460
- export namespace RenderConfig {
2461
- export interface Template {
2462
- /**
2463
- * Base64-encoded `.docx` bytes. In the Bem CLI, use `@path/to/file` to embed it
2464
- * automatically.
2465
- */
2466
- base64: string;
2467
-
2468
- /**
2469
- * Original upload filename (e.g. `contract.docx`), stored for display only. Does
2470
- * not affect where the template is stored.
2471
- */
2472
- name?: string;
2473
- }
2474
- }
2475
- }
2476
- }
2601
+ }
2477
2602
 
2478
2603
  export interface UserActionSummary {
2479
2604
  /**
@@ -2555,609 +2680,55 @@ export interface FunctionCompareMetricsResponse {
2555
2680
  /**
2556
2681
  * Comparison of metrics between two versions
2557
2682
  */
2558
- aggregateComparison?: FunctionCompareMetricsResponse.AggregateComparison;
2559
-
2560
- /**
2561
- * Detailed performance metrics and analysis
2562
- */
2563
- baselineMetrics?: FunctionCompareMetricsResponse.BaselineMetrics;
2564
-
2565
- /**
2566
- * Number of transformations used to calculate baseline metrics
2567
- */
2568
- baselineTransformationCount?: number;
2569
-
2570
- /**
2571
- * Detailed performance metrics and analysis
2572
- */
2573
- comparisonMetrics?: FunctionCompareMetricsResponse.ComparisonMetrics;
2574
-
2575
- /**
2576
- * Number of transformations used to calculate comparison metrics
2577
- */
2578
- comparisonTransformationCount?: number;
2579
-
2580
- /**
2581
- * **Field-level metrics that changed significantly**
2582
- *
2583
- * Only includes fields where metrics changed by more than 1%.
2584
- */
2585
- fieldMetricsChanges?: Array<FunctionCompareMetricsResponse.FieldMetricsChange>;
2586
-
2587
- /**
2588
- * Optional message with additional details
2589
- */
2590
- message?: string;
2591
- }
2592
-
2593
- export namespace FunctionCompareMetricsResponse {
2594
- /**
2595
- * Comparison of metrics between two versions
2596
- */
2597
- export interface AggregateComparison {
2598
- /**
2599
- * Comparison of a single metric between two versions
2600
- */
2601
- accuracy?: AggregateComparison.Accuracy;
2602
-
2603
- /**
2604
- * Comparison of a single metric between two versions
2605
- */
2606
- f1Score?: AggregateComparison.F1Score;
2607
-
2608
- /**
2609
- * Comparison of a single metric between two versions
2610
- */
2611
- precision?: AggregateComparison.Precision;
2612
-
2613
- /**
2614
- * Comparison of a single metric between two versions
2615
- */
2616
- recall?: AggregateComparison.Recall;
2617
- }
2618
-
2619
- export namespace AggregateComparison {
2620
- /**
2621
- * Comparison of a single metric between two versions
2622
- */
2623
- export interface Accuracy {
2624
- /**
2625
- * Value in baseline version (null if not available)
2626
- */
2627
- baselineValue?: number | null;
2628
-
2629
- /**
2630
- * Value in comparison version (null if not available)
2631
- */
2632
- comparisonValue?: number | null;
2633
-
2634
- /**
2635
- * Absolute difference (comparisonValue - baselineValue)
2636
- */
2637
- difference?: number | null;
2638
-
2639
- /**
2640
- * **Percentage change from baseline to comparison**
2641
- *
2642
- * Formula: ((comparisonValue - baselineValue) / baselineValue) \* 100
2643
- *
2644
- * - Positive values indicate improvement
2645
- * - Negative values indicate regression
2646
- */
2647
- liftPercent?: number | null;
2648
- }
2649
-
2650
- /**
2651
- * Comparison of a single metric between two versions
2652
- */
2653
- export interface F1Score {
2654
- /**
2655
- * Value in baseline version (null if not available)
2656
- */
2657
- baselineValue?: number | null;
2658
-
2659
- /**
2660
- * Value in comparison version (null if not available)
2661
- */
2662
- comparisonValue?: number | null;
2663
-
2664
- /**
2665
- * Absolute difference (comparisonValue - baselineValue)
2666
- */
2667
- difference?: number | null;
2668
-
2669
- /**
2670
- * **Percentage change from baseline to comparison**
2671
- *
2672
- * Formula: ((comparisonValue - baselineValue) / baselineValue) \* 100
2673
- *
2674
- * - Positive values indicate improvement
2675
- * - Negative values indicate regression
2676
- */
2677
- liftPercent?: number | null;
2678
- }
2679
-
2680
- /**
2681
- * Comparison of a single metric between two versions
2682
- */
2683
- export interface Precision {
2684
- /**
2685
- * Value in baseline version (null if not available)
2686
- */
2687
- baselineValue?: number | null;
2688
-
2689
- /**
2690
- * Value in comparison version (null if not available)
2691
- */
2692
- comparisonValue?: number | null;
2693
-
2694
- /**
2695
- * Absolute difference (comparisonValue - baselineValue)
2696
- */
2697
- difference?: number | null;
2698
-
2699
- /**
2700
- * **Percentage change from baseline to comparison**
2701
- *
2702
- * Formula: ((comparisonValue - baselineValue) / baselineValue) \* 100
2703
- *
2704
- * - Positive values indicate improvement
2705
- * - Negative values indicate regression
2706
- */
2707
- liftPercent?: number | null;
2708
- }
2709
-
2710
- /**
2711
- * Comparison of a single metric between two versions
2712
- */
2713
- export interface Recall {
2714
- /**
2715
- * Value in baseline version (null if not available)
2716
- */
2717
- baselineValue?: number | null;
2718
-
2719
- /**
2720
- * Value in comparison version (null if not available)
2721
- */
2722
- comparisonValue?: number | null;
2723
-
2724
- /**
2725
- * Absolute difference (comparisonValue - baselineValue)
2726
- */
2727
- difference?: number | null;
2728
-
2729
- /**
2730
- * **Percentage change from baseline to comparison**
2731
- *
2732
- * Formula: ((comparisonValue - baselineValue) / baselineValue) \* 100
2733
- *
2734
- * - Positive values indicate improvement
2735
- * - Negative values indicate regression
2736
- */
2737
- liftPercent?: number | null;
2738
- }
2739
- }
2740
-
2741
- /**
2742
- * Detailed performance metrics and analysis
2743
- */
2744
- export interface BaselineMetrics {
2745
- /**
2746
- * Comprehensive performance metrics
2747
- */
2748
- aggregateMetrics?: BaselineMetrics.AggregateMetrics;
2749
-
2750
- /**
2751
- * Enhanced field metrics with comprehensive analytics
2752
- */
2753
- fieldMetrics?: Array<BaselineMetrics.FieldMetric>;
2754
-
2755
- /**
2756
- * Area Under the Precision-Recall Curve
2757
- */
2758
- precisionRecallAuc?: number;
2759
- }
2760
-
2761
- export namespace BaselineMetrics {
2762
- /**
2763
- * Comprehensive performance metrics
2764
- */
2765
- export interface AggregateMetrics {
2766
- /**
2767
- * Overall accuracy
2768
- */
2769
- accuracy?: number | null;
2770
-
2771
- /**
2772
- * F1 Score (harmonic mean of precision and recall)
2773
- */
2774
- f1Score?: number | null;
2775
-
2776
- /**
2777
- * False Negatives
2778
- */
2779
- fn?: number;
2780
-
2781
- /**
2782
- * False Positives
2783
- */
2784
- fp?: number;
2785
-
2786
- /**
2787
- * Precision (TP / (TP + FP))
2788
- */
2789
- precision?: number | null;
2790
-
2791
- /**
2792
- * Recall (TP / (TP + FN))
2793
- */
2794
- recall?: number | null;
2795
-
2796
- /**
2797
- * True Negatives
2798
- */
2799
- tn?: number;
2800
-
2801
- /**
2802
- * True Positives
2803
- */
2804
- tp?: number;
2805
- }
2806
-
2807
- /**
2808
- * Enhanced field metrics with comprehensive analytics
2809
- */
2810
- export interface FieldMetric {
2811
- /**
2812
- * JSON path to the field
2813
- */
2814
- fieldPath: string;
2815
-
2816
- /**
2817
- * Comprehensive performance metrics
2818
- */
2819
- metrics?: FieldMetric.Metrics;
2820
- }
2821
-
2822
- export namespace FieldMetric {
2823
- /**
2824
- * Comprehensive performance metrics
2825
- */
2826
- export interface Metrics {
2827
- /**
2828
- * Overall accuracy
2829
- */
2830
- accuracy?: number | null;
2831
-
2832
- /**
2833
- * F1 Score (harmonic mean of precision and recall)
2834
- */
2835
- f1Score?: number | null;
2836
-
2837
- /**
2838
- * False Negatives
2839
- */
2840
- fn?: number;
2841
-
2842
- /**
2843
- * False Positives
2844
- */
2845
- fp?: number;
2846
-
2847
- /**
2848
- * Precision (TP / (TP + FP))
2849
- */
2850
- precision?: number | null;
2851
-
2852
- /**
2853
- * Recall (TP / (TP + FN))
2854
- */
2855
- recall?: number | null;
2856
-
2857
- /**
2858
- * True Negatives
2859
- */
2860
- tn?: number;
2861
-
2862
- /**
2863
- * True Positives
2864
- */
2865
- tp?: number;
2866
- }
2867
- }
2868
- }
2869
-
2870
- /**
2871
- * Detailed performance metrics and analysis
2872
- */
2873
- export interface ComparisonMetrics {
2874
- /**
2875
- * Comprehensive performance metrics
2876
- */
2877
- aggregateMetrics?: ComparisonMetrics.AggregateMetrics;
2878
-
2879
- /**
2880
- * Enhanced field metrics with comprehensive analytics
2881
- */
2882
- fieldMetrics?: Array<ComparisonMetrics.FieldMetric>;
2883
-
2884
- /**
2885
- * Area Under the Precision-Recall Curve
2886
- */
2887
- precisionRecallAuc?: number;
2888
- }
2889
-
2890
- export namespace ComparisonMetrics {
2891
- /**
2892
- * Comprehensive performance metrics
2893
- */
2894
- export interface AggregateMetrics {
2895
- /**
2896
- * Overall accuracy
2897
- */
2898
- accuracy?: number | null;
2899
-
2900
- /**
2901
- * F1 Score (harmonic mean of precision and recall)
2902
- */
2903
- f1Score?: number | null;
2904
-
2905
- /**
2906
- * False Negatives
2907
- */
2908
- fn?: number;
2909
-
2910
- /**
2911
- * False Positives
2912
- */
2913
- fp?: number;
2914
-
2915
- /**
2916
- * Precision (TP / (TP + FP))
2917
- */
2918
- precision?: number | null;
2919
-
2920
- /**
2921
- * Recall (TP / (TP + FN))
2922
- */
2923
- recall?: number | null;
2924
-
2925
- /**
2926
- * True Negatives
2927
- */
2928
- tn?: number;
2929
-
2930
- /**
2931
- * True Positives
2932
- */
2933
- tp?: number;
2934
- }
2935
-
2936
- /**
2937
- * Enhanced field metrics with comprehensive analytics
2938
- */
2939
- export interface FieldMetric {
2940
- /**
2941
- * JSON path to the field
2942
- */
2943
- fieldPath: string;
2944
-
2945
- /**
2946
- * Comprehensive performance metrics
2947
- */
2948
- metrics?: FieldMetric.Metrics;
2949
- }
2950
-
2951
- export namespace FieldMetric {
2952
- /**
2953
- * Comprehensive performance metrics
2954
- */
2955
- export interface Metrics {
2956
- /**
2957
- * Overall accuracy
2958
- */
2959
- accuracy?: number | null;
2960
-
2961
- /**
2962
- * F1 Score (harmonic mean of precision and recall)
2963
- */
2964
- f1Score?: number | null;
2965
-
2966
- /**
2967
- * False Negatives
2968
- */
2969
- fn?: number;
2970
-
2971
- /**
2972
- * False Positives
2973
- */
2974
- fp?: number;
2975
-
2976
- /**
2977
- * Precision (TP / (TP + FP))
2978
- */
2979
- precision?: number | null;
2980
-
2981
- /**
2982
- * Recall (TP / (TP + FN))
2983
- */
2984
- recall?: number | null;
2985
-
2986
- /**
2987
- * True Negatives
2988
- */
2989
- tn?: number;
2990
-
2991
- /**
2992
- * True Positives
2993
- */
2994
- tp?: number;
2995
- }
2996
- }
2997
- }
2998
-
2999
- /**
3000
- * Comparison of field-level metrics
3001
- */
3002
- export interface FieldMetricsChange {
3003
- /**
3004
- * Comparison of metrics between two versions
3005
- */
3006
- comparison: FieldMetricsChange.Comparison;
3007
-
3008
- /**
3009
- * JSON pointer path to the field
3010
- */
3011
- fieldPath: string;
3012
- }
3013
-
3014
- export namespace FieldMetricsChange {
3015
- /**
3016
- * Comparison of metrics between two versions
3017
- */
3018
- export interface Comparison {
3019
- /**
3020
- * Comparison of a single metric between two versions
3021
- */
3022
- accuracy?: Comparison.Accuracy;
3023
-
3024
- /**
3025
- * Comparison of a single metric between two versions
3026
- */
3027
- f1Score?: Comparison.F1Score;
3028
-
3029
- /**
3030
- * Comparison of a single metric between two versions
3031
- */
3032
- precision?: Comparison.Precision;
3033
-
3034
- /**
3035
- * Comparison of a single metric between two versions
3036
- */
3037
- recall?: Comparison.Recall;
3038
- }
3039
-
3040
- export namespace Comparison {
3041
- /**
3042
- * Comparison of a single metric between two versions
3043
- */
3044
- export interface Accuracy {
3045
- /**
3046
- * Value in baseline version (null if not available)
3047
- */
3048
- baselineValue?: number | null;
3049
-
3050
- /**
3051
- * Value in comparison version (null if not available)
3052
- */
3053
- comparisonValue?: number | null;
3054
-
3055
- /**
3056
- * Absolute difference (comparisonValue - baselineValue)
3057
- */
3058
- difference?: number | null;
3059
-
3060
- /**
3061
- * **Percentage change from baseline to comparison**
3062
- *
3063
- * Formula: ((comparisonValue - baselineValue) / baselineValue) \* 100
3064
- *
3065
- * - Positive values indicate improvement
3066
- * - Negative values indicate regression
3067
- */
3068
- liftPercent?: number | null;
3069
- }
3070
-
3071
- /**
3072
- * Comparison of a single metric between two versions
3073
- */
3074
- export interface F1Score {
3075
- /**
3076
- * Value in baseline version (null if not available)
3077
- */
3078
- baselineValue?: number | null;
3079
-
3080
- /**
3081
- * Value in comparison version (null if not available)
3082
- */
3083
- comparisonValue?: number | null;
3084
-
3085
- /**
3086
- * Absolute difference (comparisonValue - baselineValue)
3087
- */
3088
- difference?: number | null;
3089
-
3090
- /**
3091
- * **Percentage change from baseline to comparison**
3092
- *
3093
- * Formula: ((comparisonValue - baselineValue) / baselineValue) \* 100
3094
- *
3095
- * - Positive values indicate improvement
3096
- * - Negative values indicate regression
3097
- */
3098
- liftPercent?: number | null;
3099
- }
2683
+ aggregateComparison?: MetricsComparison;
3100
2684
 
3101
- /**
3102
- * Comparison of a single metric between two versions
3103
- */
3104
- export interface Precision {
3105
- /**
3106
- * Value in baseline version (null if not available)
3107
- */
3108
- baselineValue?: number | null;
2685
+ /**
2686
+ * Detailed performance metrics and analysis
2687
+ */
2688
+ baselineMetrics?: MetricsDetails;
3109
2689
 
3110
- /**
3111
- * Value in comparison version (null if not available)
3112
- */
3113
- comparisonValue?: number | null;
2690
+ /**
2691
+ * Number of transformations used to calculate baseline metrics
2692
+ */
2693
+ baselineTransformationCount?: number;
3114
2694
 
3115
- /**
3116
- * Absolute difference (comparisonValue - baselineValue)
3117
- */
3118
- difference?: number | null;
2695
+ /**
2696
+ * Detailed performance metrics and analysis
2697
+ */
2698
+ comparisonMetrics?: MetricsDetails;
3119
2699
 
3120
- /**
3121
- * **Percentage change from baseline to comparison**
3122
- *
3123
- * Formula: ((comparisonValue - baselineValue) / baselineValue) \* 100
3124
- *
3125
- * - Positive values indicate improvement
3126
- * - Negative values indicate regression
3127
- */
3128
- liftPercent?: number | null;
3129
- }
2700
+ /**
2701
+ * Number of transformations used to calculate comparison metrics
2702
+ */
2703
+ comparisonTransformationCount?: number;
3130
2704
 
3131
- /**
3132
- * Comparison of a single metric between two versions
3133
- */
3134
- export interface Recall {
3135
- /**
3136
- * Value in baseline version (null if not available)
3137
- */
3138
- baselineValue?: number | null;
2705
+ /**
2706
+ * **Field-level metrics that changed significantly**
2707
+ *
2708
+ * Only includes fields where metrics changed by more than 1%.
2709
+ */
2710
+ fieldMetricsChanges?: Array<FunctionCompareMetricsResponse.FieldMetricsChange>;
3139
2711
 
3140
- /**
3141
- * Value in comparison version (null if not available)
3142
- */
3143
- comparisonValue?: number | null;
2712
+ /**
2713
+ * Optional message with additional details
2714
+ */
2715
+ message?: string;
2716
+ }
3144
2717
 
3145
- /**
3146
- * Absolute difference (comparisonValue - baselineValue)
3147
- */
3148
- difference?: number | null;
2718
+ export namespace FunctionCompareMetricsResponse {
2719
+ /**
2720
+ * Comparison of field-level metrics
2721
+ */
2722
+ export interface FieldMetricsChange {
2723
+ /**
2724
+ * Comparison of metrics between two versions
2725
+ */
2726
+ comparison: FunctionsAPI.MetricsComparison;
3149
2727
 
3150
- /**
3151
- * **Percentage change from baseline to comparison**
3152
- *
3153
- * Formula: ((comparisonValue - baselineValue) / baselineValue) \* 100
3154
- *
3155
- * - Positive values indicate improvement
3156
- * - Negative values indicate regression
3157
- */
3158
- liftPercent?: number | null;
3159
- }
3160
- }
2728
+ /**
2729
+ * JSON pointer path to the field
2730
+ */
2731
+ fieldPath: string;
3161
2732
  }
3162
2733
  }
3163
2734
 
@@ -3183,7 +2754,7 @@ export interface FunctionEstimateReviewRequirementsResponse {
3183
2754
  /**
3184
2755
  * Detailed performance metrics and analysis
3185
2756
  */
3186
- metrics?: FunctionEstimateReviewRequirementsResponse.Metrics;
2757
+ metrics?: MetricsDetails;
3187
2758
  }
3188
2759
 
3189
2760
  export namespace FunctionEstimateReviewRequirementsResponse {
@@ -3312,45 +2883,7 @@ export namespace FunctionEstimateReviewRequirementsResponse {
3312
2883
  * distribution. For extreme rates or small sample sizes, Wilson confidence
3313
2884
  * intervals may be more appropriate.
3314
2885
  */
3315
- '95'?: AccuracyAboveThreshold._95;
3316
- }
3317
-
3318
- export namespace AccuracyAboveThreshold {
3319
- /**
3320
- * Confidence interval for a rate/proportion using Wald (normal approximation)
3321
- * method by default.
3322
- *
3323
- * Wald confidence intervals use the normal approximation to the binomial
3324
- * distribution. For extreme rates or small sample sizes, Wilson confidence
3325
- * intervals may be more appropriate.
3326
- */
3327
- export interface _95 {
3328
- /**
3329
- * Current number of samples/observations available
3330
- */
3331
- currentSample: number;
3332
-
3333
- /**
3334
- * Minimum number of samples needed for reliable confidence interval calculation
3335
- */
3336
- sampleNeeded: number;
3337
-
3338
- /**
3339
- * Lower bound of the confidence interval (null if insufficient sample size)
3340
- */
3341
- ciLower?: number | null;
3342
-
3343
- /**
3344
- * Upper bound of the confidence interval (null if insufficient sample size)
3345
- */
3346
- ciUpper?: number | null;
3347
-
3348
- /**
3349
- * Point estimate (observed rate) at the center of the interval (null if
3350
- * insufficient sample size)
3351
- */
3352
- mid?: number | null;
3353
- }
2886
+ '95'?: FunctionsAPI.RateConfidenceInterval;
3354
2887
  }
3355
2888
 
3356
2889
  /**
@@ -3367,45 +2900,7 @@ export namespace FunctionEstimateReviewRequirementsResponse {
3367
2900
  * distribution. For extreme rates or small sample sizes, Wilson confidence
3368
2901
  * intervals may be more appropriate.
3369
2902
  */
3370
- '95'?: FalseDiscoveryRate._95;
3371
- }
3372
-
3373
- export namespace FalseDiscoveryRate {
3374
- /**
3375
- * Confidence interval for a rate/proportion using Wald (normal approximation)
3376
- * method by default.
3377
- *
3378
- * Wald confidence intervals use the normal approximation to the binomial
3379
- * distribution. For extreme rates or small sample sizes, Wilson confidence
3380
- * intervals may be more appropriate.
3381
- */
3382
- export interface _95 {
3383
- /**
3384
- * Current number of samples/observations available
3385
- */
3386
- currentSample: number;
3387
-
3388
- /**
3389
- * Minimum number of samples needed for reliable confidence interval calculation
3390
- */
3391
- sampleNeeded: number;
3392
-
3393
- /**
3394
- * Lower bound of the confidence interval (null if insufficient sample size)
3395
- */
3396
- ciLower?: number | null;
3397
-
3398
- /**
3399
- * Upper bound of the confidence interval (null if insufficient sample size)
3400
- */
3401
- ciUpper?: number | null;
3402
-
3403
- /**
3404
- * Point estimate (observed rate) at the center of the interval (null if
3405
- * insufficient sample size)
3406
- */
3407
- mid?: number | null;
3408
- }
2903
+ '95'?: FunctionsAPI.RateConfidenceInterval;
3409
2904
  }
3410
2905
 
3411
2906
  /**
@@ -3422,45 +2917,7 @@ export namespace FunctionEstimateReviewRequirementsResponse {
3422
2917
  * distribution. For extreme rates or small sample sizes, Wilson confidence
3423
2918
  * intervals may be more appropriate.
3424
2919
  */
3425
- '95'?: FalsePositiveRate._95;
3426
- }
3427
-
3428
- export namespace FalsePositiveRate {
3429
- /**
3430
- * Confidence interval for a rate/proportion using Wald (normal approximation)
3431
- * method by default.
3432
- *
3433
- * Wald confidence intervals use the normal approximation to the binomial
3434
- * distribution. For extreme rates or small sample sizes, Wilson confidence
3435
- * intervals may be more appropriate.
3436
- */
3437
- export interface _95 {
3438
- /**
3439
- * Current number of samples/observations available
3440
- */
3441
- currentSample: number;
3442
-
3443
- /**
3444
- * Minimum number of samples needed for reliable confidence interval calculation
3445
- */
3446
- sampleNeeded: number;
3447
-
3448
- /**
3449
- * Lower bound of the confidence interval (null if insufficient sample size)
3450
- */
3451
- ciLower?: number | null;
3452
-
3453
- /**
3454
- * Upper bound of the confidence interval (null if insufficient sample size)
3455
- */
3456
- ciUpper?: number | null;
3457
-
3458
- /**
3459
- * Point estimate (observed rate) at the center of the interval (null if
3460
- * insufficient sample size)
3461
- */
3462
- mid?: number | null;
3463
- }
2920
+ '95'?: FunctionsAPI.RateConfidenceInterval;
3464
2921
  }
3465
2922
 
3466
2923
  /**
@@ -3476,45 +2933,7 @@ export namespace FunctionEstimateReviewRequirementsResponse {
3476
2933
  * distribution. For extreme rates or small sample sizes, Wilson confidence
3477
2934
  * intervals may be more appropriate.
3478
2935
  */
3479
- '95'?: Precision._95;
3480
- }
3481
-
3482
- export namespace Precision {
3483
- /**
3484
- * Confidence interval for a rate/proportion using Wald (normal approximation)
3485
- * method by default.
3486
- *
3487
- * Wald confidence intervals use the normal approximation to the binomial
3488
- * distribution. For extreme rates or small sample sizes, Wilson confidence
3489
- * intervals may be more appropriate.
3490
- */
3491
- export interface _95 {
3492
- /**
3493
- * Current number of samples/observations available
3494
- */
3495
- currentSample: number;
3496
-
3497
- /**
3498
- * Minimum number of samples needed for reliable confidence interval calculation
3499
- */
3500
- sampleNeeded: number;
3501
-
3502
- /**
3503
- * Lower bound of the confidence interval (null if insufficient sample size)
3504
- */
3505
- ciLower?: number | null;
3506
-
3507
- /**
3508
- * Upper bound of the confidence interval (null if insufficient sample size)
3509
- */
3510
- ciUpper?: number | null;
3511
-
3512
- /**
3513
- * Point estimate (observed rate) at the center of the interval (null if
3514
- * insufficient sample size)
3515
- */
3516
- mid?: number | null;
3517
- }
2936
+ '95'?: FunctionsAPI.RateConfidenceInterval;
3518
2937
  }
3519
2938
 
3520
2939
  /**
@@ -3530,174 +2949,7 @@ export namespace FunctionEstimateReviewRequirementsResponse {
3530
2949
  * distribution. For extreme rates or small sample sizes, Wilson confidence
3531
2950
  * intervals may be more appropriate.
3532
2951
  */
3533
- '95'?: Recall._95;
3534
- }
3535
-
3536
- export namespace Recall {
3537
- /**
3538
- * Confidence interval for a rate/proportion using Wald (normal approximation)
3539
- * method by default.
3540
- *
3541
- * Wald confidence intervals use the normal approximation to the binomial
3542
- * distribution. For extreme rates or small sample sizes, Wilson confidence
3543
- * intervals may be more appropriate.
3544
- */
3545
- export interface _95 {
3546
- /**
3547
- * Current number of samples/observations available
3548
- */
3549
- currentSample: number;
3550
-
3551
- /**
3552
- * Minimum number of samples needed for reliable confidence interval calculation
3553
- */
3554
- sampleNeeded: number;
3555
-
3556
- /**
3557
- * Lower bound of the confidence interval (null if insufficient sample size)
3558
- */
3559
- ciLower?: number | null;
3560
-
3561
- /**
3562
- * Upper bound of the confidence interval (null if insufficient sample size)
3563
- */
3564
- ciUpper?: number | null;
3565
-
3566
- /**
3567
- * Point estimate (observed rate) at the center of the interval (null if
3568
- * insufficient sample size)
3569
- */
3570
- mid?: number | null;
3571
- }
3572
- }
3573
- }
3574
- }
3575
-
3576
- /**
3577
- * Detailed performance metrics and analysis
3578
- */
3579
- export interface Metrics {
3580
- /**
3581
- * Comprehensive performance metrics
3582
- */
3583
- aggregateMetrics?: Metrics.AggregateMetrics;
3584
-
3585
- /**
3586
- * Enhanced field metrics with comprehensive analytics
3587
- */
3588
- fieldMetrics?: Array<Metrics.FieldMetric>;
3589
-
3590
- /**
3591
- * Area Under the Precision-Recall Curve
3592
- */
3593
- precisionRecallAuc?: number;
3594
- }
3595
-
3596
- export namespace Metrics {
3597
- /**
3598
- * Comprehensive performance metrics
3599
- */
3600
- export interface AggregateMetrics {
3601
- /**
3602
- * Overall accuracy
3603
- */
3604
- accuracy?: number | null;
3605
-
3606
- /**
3607
- * F1 Score (harmonic mean of precision and recall)
3608
- */
3609
- f1Score?: number | null;
3610
-
3611
- /**
3612
- * False Negatives
3613
- */
3614
- fn?: number;
3615
-
3616
- /**
3617
- * False Positives
3618
- */
3619
- fp?: number;
3620
-
3621
- /**
3622
- * Precision (TP / (TP + FP))
3623
- */
3624
- precision?: number | null;
3625
-
3626
- /**
3627
- * Recall (TP / (TP + FN))
3628
- */
3629
- recall?: number | null;
3630
-
3631
- /**
3632
- * True Negatives
3633
- */
3634
- tn?: number;
3635
-
3636
- /**
3637
- * True Positives
3638
- */
3639
- tp?: number;
3640
- }
3641
-
3642
- /**
3643
- * Enhanced field metrics with comprehensive analytics
3644
- */
3645
- export interface FieldMetric {
3646
- /**
3647
- * JSON path to the field
3648
- */
3649
- fieldPath: string;
3650
-
3651
- /**
3652
- * Comprehensive performance metrics
3653
- */
3654
- metrics?: FieldMetric.Metrics;
3655
- }
3656
-
3657
- export namespace FieldMetric {
3658
- /**
3659
- * Comprehensive performance metrics
3660
- */
3661
- export interface Metrics {
3662
- /**
3663
- * Overall accuracy
3664
- */
3665
- accuracy?: number | null;
3666
-
3667
- /**
3668
- * F1 Score (harmonic mean of precision and recall)
3669
- */
3670
- f1Score?: number | null;
3671
-
3672
- /**
3673
- * False Negatives
3674
- */
3675
- fn?: number;
3676
-
3677
- /**
3678
- * False Positives
3679
- */
3680
- fp?: number;
3681
-
3682
- /**
3683
- * Precision (TP / (TP + FP))
3684
- */
3685
- precision?: number | null;
3686
-
3687
- /**
3688
- * Recall (TP / (TP + FN))
3689
- */
3690
- recall?: number | null;
3691
-
3692
- /**
3693
- * True Negatives
3694
- */
3695
- tn?: number;
3696
-
3697
- /**
3698
- * True Positives
3699
- */
3700
- tp?: number;
2952
+ '95'?: FunctionsAPI.RateConfidenceInterval;
3701
2953
  }
3702
2954
  }
3703
2955
  }
@@ -4076,7 +3328,7 @@ export declare namespace FunctionCreateParams {
4076
3328
  * Extract / Join — separated from `parseConfig` so the per-call Parse output shape
4077
3329
  * stays distinct from operator-level execution flags.
4078
3330
  */
4079
- extraConfig?: CreateParseFunction.ExtraConfig;
3331
+ extraConfig?: ParseExtraFunctionConfig;
4080
3332
 
4081
3333
  /**
4082
3334
  * Per-version configuration for a Parse function.
@@ -4093,26 +3345,6 @@ export declare namespace FunctionCreateParams {
4093
3345
  tags?: Array<string>;
4094
3346
  }
4095
3347
 
4096
- export namespace CreateParseFunction {
4097
- /**
4098
- * Cross-cutting toggles for Parse functions. Mirrors the `extraConfig` surface on
4099
- * Extract / Join — separated from `parseConfig` so the per-call Parse output shape
4100
- * stays distinct from operator-level execution flags.
4101
- */
4102
- export interface ExtraConfig {
4103
- /**
4104
- * When true, return per-section and per-entity-mention coordinates in the parse
4105
- * event's `fieldBoundingBoxes` map (same shape as Extract: JSON Pointer key →
4106
- * array of `{page, left, top, width, height}` with coordinates normalized to [0,
4107
- * 1]). Keys are `/sections/{N}` and `/entities/{N}/occurrences/{M}` into the parse
4108
- * output. Only applies to the open-ended discovery path (no `schema`) and to
4109
- * vision input types. Bedrock-backed parse functions silently return an empty map
4110
- * (no native bbox support). Defaults to false.
4111
- */
4112
- enableBoundingBoxes?: boolean;
4113
- }
4114
- }
4115
-
4116
3348
  export interface CreateRenderFunction {
4117
3349
  /**
4118
3350
  * Name of function. Must be UNIQUE on a per-environment basis.
@@ -4126,7 +3358,7 @@ export declare namespace FunctionCreateParams {
4126
3358
  * never submit `placeholders` or `styleIds`. The response shape (`RenderConfig`)
4127
3359
  * returns the derived contract.
4128
3360
  */
4129
- renderConfig: CreateRenderFunction.RenderConfig;
3361
+ renderConfig: RenderConfigInput;
4130
3362
 
4131
3363
  type: 'render';
4132
3364
 
@@ -4140,35 +3372,6 @@ export declare namespace FunctionCreateParams {
4140
3372
  */
4141
3373
  tags?: Array<string>;
4142
3374
  }
4143
-
4144
- export namespace CreateRenderFunction {
4145
- /**
4146
- * Request-side render configuration. Carries the template document as
4147
- * base64-encoded `.docx` bytes: the server validates them, stores the template,
4148
- * and derives the placeholder/style-id contract at create/update time, so clients
4149
- * never submit `placeholders` or `styleIds`. The response shape (`RenderConfig`)
4150
- * returns the derived contract.
4151
- */
4152
- export interface RenderConfig {
4153
- template: RenderConfig.Template;
4154
- }
4155
-
4156
- export namespace RenderConfig {
4157
- export interface Template {
4158
- /**
4159
- * Base64-encoded `.docx` bytes. In the Bem CLI, use `@path/to/file` to embed it
4160
- * automatically.
4161
- */
4162
- base64: string;
4163
-
4164
- /**
4165
- * Original upload filename (e.g. `contract.docx`), stored for display only. Does
4166
- * not affect where the template is stored.
4167
- */
4168
- name?: string;
4169
- }
4170
- }
4171
- }
4172
3375
  }
4173
3376
 
4174
3377
  export type FunctionUpdateParams =
@@ -4473,7 +3676,7 @@ export declare namespace FunctionUpdateParams {
4473
3676
  * Extract / Join — separated from `parseConfig` so the per-call Parse output shape
4474
3677
  * stays distinct from operator-level execution flags.
4475
3678
  */
4476
- extraConfig?: UpsertParseFunction.ExtraConfig;
3679
+ extraConfig?: ParseExtraFunctionConfig;
4477
3680
 
4478
3681
  /**
4479
3682
  * Name of function. Must be UNIQUE on a per-environment basis.
@@ -4495,26 +3698,6 @@ export declare namespace FunctionUpdateParams {
4495
3698
  tags?: Array<string>;
4496
3699
  }
4497
3700
 
4498
- export namespace UpsertParseFunction {
4499
- /**
4500
- * Cross-cutting toggles for Parse functions. Mirrors the `extraConfig` surface on
4501
- * Extract / Join — separated from `parseConfig` so the per-call Parse output shape
4502
- * stays distinct from operator-level execution flags.
4503
- */
4504
- export interface ExtraConfig {
4505
- /**
4506
- * When true, return per-section and per-entity-mention coordinates in the parse
4507
- * event's `fieldBoundingBoxes` map (same shape as Extract: JSON Pointer key →
4508
- * array of `{page, left, top, width, height}` with coordinates normalized to [0,
4509
- * 1]). Keys are `/sections/{N}` and `/entities/{N}/occurrences/{M}` into the parse
4510
- * output. Only applies to the open-ended discovery path (no `schema`) and to
4511
- * vision input types. Bedrock-backed parse functions silently return an empty map
4512
- * (no native bbox support). Defaults to false.
4513
- */
4514
- enableBoundingBoxes?: boolean;
4515
- }
4516
- }
4517
-
4518
3701
  export interface UpsertRenderFunction {
4519
3702
  type: 'render';
4520
3703
 
@@ -4535,42 +3718,13 @@ export declare namespace FunctionUpdateParams {
4535
3718
  * never submit `placeholders` or `styleIds`. The response shape (`RenderConfig`)
4536
3719
  * returns the derived contract.
4537
3720
  */
4538
- renderConfig?: UpsertRenderFunction.RenderConfig;
3721
+ renderConfig?: RenderConfigInput;
4539
3722
 
4540
3723
  /**
4541
3724
  * Array of tags to categorize and organize functions.
4542
3725
  */
4543
3726
  tags?: Array<string>;
4544
3727
  }
4545
-
4546
- export namespace UpsertRenderFunction {
4547
- /**
4548
- * Request-side render configuration. Carries the template document as
4549
- * base64-encoded `.docx` bytes: the server validates them, stores the template,
4550
- * and derives the placeholder/style-id contract at create/update time, so clients
4551
- * never submit `placeholders` or `styleIds`. The response shape (`RenderConfig`)
4552
- * returns the derived contract.
4553
- */
4554
- export interface RenderConfig {
4555
- template: RenderConfig.Template;
4556
- }
4557
-
4558
- export namespace RenderConfig {
4559
- export interface Template {
4560
- /**
4561
- * Base64-encoded `.docx` bytes. In the Bem CLI, use `@path/to/file` to embed it
4562
- * automatically.
4563
- */
4564
- base64: string;
4565
-
4566
- /**
4567
- * Original upload filename (e.g. `contract.docx`), stored for display only. Does
4568
- * not affect where the template is stored.
4569
- */
4570
- name?: string;
4571
- }
4572
- }
4573
- }
4574
3728
  }
4575
3729
 
4576
3730
  export interface FunctionListParams extends FunctionsPageParams {
@@ -4719,7 +3873,15 @@ export declare namespace Functions {
4719
3873
  type FunctionResponse as FunctionResponse,
4720
3874
  type FunctionType as FunctionType,
4721
3875
  type ListFunctionsResponse as ListFunctionsResponse,
3876
+ type MetricComparison as MetricComparison,
3877
+ type Metrics as Metrics,
3878
+ type MetricsComparison as MetricsComparison,
3879
+ type MetricsDetails as MetricsDetails,
4722
3880
  type ParseConfig as ParseConfig,
3881
+ type ParseExtraFunctionConfig as ParseExtraFunctionConfig,
3882
+ type RateConfidenceInterval as RateConfidenceInterval,
3883
+ type RenderConfig as RenderConfig,
3884
+ type RenderConfigInput as RenderConfigInput,
4723
3885
  type SendDestinationType as SendDestinationType,
4724
3886
  type SplitFunctionSemanticPageItemClass as SplitFunctionSemanticPageItemClass,
4725
3887
  type UpdateFunction as UpdateFunction,