@vertesia/common 1.5.0-dev.20260714.072725Z → 1.5.0-dev.20260722.120446Z

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 (127) hide show
  1. package/lib/apikey.d.ts +1 -0
  2. package/lib/apikey.d.ts.map +1 -1
  3. package/lib/apikey.js.map +1 -1
  4. package/lib/apps.d.ts +500 -34
  5. package/lib/apps.d.ts.map +1 -1
  6. package/lib/apps.js +63 -70
  7. package/lib/apps.js.map +1 -1
  8. package/lib/audit-trail.d.ts +61 -1
  9. package/lib/audit-trail.d.ts.map +1 -1
  10. package/lib/audit-trail.js +15 -0
  11. package/lib/audit-trail.js.map +1 -1
  12. package/lib/data-platform.d.ts +121 -5
  13. package/lib/data-platform.d.ts.map +1 -1
  14. package/lib/index.d.ts +7 -0
  15. package/lib/index.d.ts.map +1 -1
  16. package/lib/index.js +7 -0
  17. package/lib/index.js.map +1 -1
  18. package/lib/interaction.d.ts +19 -1
  19. package/lib/interaction.d.ts.map +1 -1
  20. package/lib/interaction.js.map +1 -1
  21. package/lib/json-schema.d.ts +1 -1
  22. package/lib/json-schema.d.ts.map +1 -1
  23. package/lib/platform-event.d.ts +79 -3
  24. package/lib/platform-event.d.ts.map +1 -1
  25. package/lib/platform-event.js.map +1 -1
  26. package/lib/project.d.ts +119 -20
  27. package/lib/project.d.ts.map +1 -1
  28. package/lib/project.js +65 -0
  29. package/lib/project.js.map +1 -1
  30. package/lib/query.d.ts +6 -0
  31. package/lib/query.d.ts.map +1 -1
  32. package/lib/refs.d.ts +1 -0
  33. package/lib/refs.d.ts.map +1 -1
  34. package/lib/schema-for-extraction.d.ts +21 -0
  35. package/lib/schema-for-extraction.d.ts.map +1 -0
  36. package/lib/schema-for-extraction.js +205 -0
  37. package/lib/schema-for-extraction.js.map +1 -0
  38. package/lib/store/agent-run.d.ts +2 -0
  39. package/lib/store/agent-run.d.ts.map +1 -1
  40. package/lib/store/conversation-state.d.ts +39 -0
  41. package/lib/store/conversation-state.d.ts.map +1 -1
  42. package/lib/store/conversation-state.js +3 -0
  43. package/lib/store/conversation-state.js.map +1 -1
  44. package/lib/store/doc-analyzer.d.ts +10 -67
  45. package/lib/store/doc-analyzer.d.ts.map +1 -1
  46. package/lib/store/dsl-workflow.d.ts +1 -0
  47. package/lib/store/dsl-workflow.d.ts.map +1 -1
  48. package/lib/store/dsl-workflow.js.map +1 -1
  49. package/lib/store/grounded-extraction.d.ts +146 -0
  50. package/lib/store/grounded-extraction.d.ts.map +1 -0
  51. package/lib/store/grounded-extraction.js +8 -0
  52. package/lib/store/grounded-extraction.js.map +1 -0
  53. package/lib/store/index.d.ts +1 -0
  54. package/lib/store/index.d.ts.map +1 -1
  55. package/lib/store/index.js +1 -0
  56. package/lib/store/index.js.map +1 -1
  57. package/lib/store/store.d.ts +307 -1
  58. package/lib/store/store.d.ts.map +1 -1
  59. package/lib/store/store.js +438 -0
  60. package/lib/store/store.js.map +1 -1
  61. package/lib/store/workflow.d.ts +3 -0
  62. package/lib/store/workflow.d.ts.map +1 -1
  63. package/lib/store/workflow.js.map +1 -1
  64. package/lib/user.d.ts +14 -0
  65. package/lib/user.d.ts.map +1 -1
  66. package/lib/user.js +31 -0
  67. package/lib/user.js.map +1 -1
  68. package/lib/vertesia-common.js +2 -2
  69. package/lib/vertesia-common.js.map +1 -1
  70. package/lib/view-configuration-validation.d.ts +15 -0
  71. package/lib/view-configuration-validation.d.ts.map +1 -0
  72. package/lib/view-configuration-validation.js +63 -0
  73. package/lib/view-configuration-validation.js.map +1 -0
  74. package/lib/view-query-validation.d.ts +13 -0
  75. package/lib/view-query-validation.d.ts.map +1 -0
  76. package/lib/view-query-validation.js +266 -0
  77. package/lib/view-query-validation.js.map +1 -0
  78. package/lib/view-validation-helpers.d.ts +15 -0
  79. package/lib/view-validation-helpers.d.ts.map +1 -0
  80. package/lib/view-validation-helpers.js +25 -0
  81. package/lib/view-validation-helpers.js.map +1 -0
  82. package/lib/views-schema.d.ts +1992 -0
  83. package/lib/views-schema.d.ts.map +1 -0
  84. package/lib/views-schema.js +674 -0
  85. package/lib/views-schema.js.map +1 -0
  86. package/lib/views-validation.d.ts +21 -0
  87. package/lib/views-validation.d.ts.map +1 -0
  88. package/lib/views-validation.js +164 -0
  89. package/lib/views-validation.js.map +1 -0
  90. package/lib/views.d.ts +381 -0
  91. package/lib/views.d.ts.map +1 -0
  92. package/lib/views.js +41 -0
  93. package/lib/views.js.map +1 -0
  94. package/package.json +5 -4
  95. package/src/apikey.ts +1 -0
  96. package/src/apps.test.ts +9 -1
  97. package/src/apps.ts +583 -90
  98. package/src/audit-trail.ts +83 -0
  99. package/src/data-platform.ts +129 -5
  100. package/src/index.ts +12 -0
  101. package/src/interaction.ts +20 -1
  102. package/src/json-schema.ts +0 -1
  103. package/src/platform-event.ts +92 -2
  104. package/src/project.test.ts +44 -0
  105. package/src/project.ts +205 -22
  106. package/src/query.ts +6 -0
  107. package/src/refs.ts +1 -0
  108. package/src/roles.test.ts +32 -0
  109. package/src/schema-for-extraction.test.ts +191 -0
  110. package/src/schema-for-extraction.ts +231 -0
  111. package/src/store/agent-run.ts +2 -0
  112. package/src/store/conversation-state.ts +47 -0
  113. package/src/store/doc-analyzer.ts +10 -76
  114. package/src/store/dsl-workflow.ts +1 -0
  115. package/src/store/grounded-extraction.ts +154 -0
  116. package/src/store/index.ts +1 -0
  117. package/src/store/store.ts +778 -1
  118. package/src/store/workflow.ts +3 -0
  119. package/src/user.ts +46 -0
  120. package/src/view-configuration-validation.ts +74 -0
  121. package/src/view-query-validation.test.ts +21 -0
  122. package/src/view-query-validation.ts +319 -0
  123. package/src/view-validation-helpers.ts +28 -0
  124. package/src/views-schema.test.ts +364 -0
  125. package/src/views-schema.ts +689 -0
  126. package/src/views-validation.ts +234 -0
  127. package/src/views.ts +484 -0
@@ -19,6 +19,8 @@ export const AUDIT_ACTIONS = [
19
19
  'inference',
20
20
  'embedding',
21
21
  'image_generation',
22
+ // Content processing outcomes
23
+ 'document_processed',
22
24
  ] as const;
23
25
 
24
26
  export type KnownAuditAction = (typeof AUDIT_ACTIONS)[number];
@@ -113,3 +115,84 @@ export interface AuditTrailResponse {
113
115
  limit: number;
114
116
  offset: number;
115
117
  }
118
+
119
+ export const AUDIT_AGGREGATION_DIMENSIONS = [
120
+ 'time',
121
+ 'action',
122
+ 'resource_type',
123
+ 'event_category',
124
+ 'provider',
125
+ 'project_id',
126
+ 'details.pipeline',
127
+ 'details.verdict',
128
+ 'details.workflow_type',
129
+ 'details.rule_id',
130
+ 'model',
131
+ ] as const;
132
+
133
+ export type AuditAggregationDimension = (typeof AUDIT_AGGREGATION_DIMENSIONS)[number];
134
+ export type AuditAggregationResolution = 'hour' | 'day' | 'week' | 'month';
135
+ export type AuditAggregationDetailField = 'pipeline' | 'verdict' | 'workflow_type' | 'rule_id';
136
+ export type AuditAggregationOperation = 'count' | 'count_distinct' | 'sum_meter' | 'average_meter';
137
+ export type AuditAggregationDistinctField = 'resource_id' | 'request_id';
138
+
139
+ export interface AuditAggregationGroup {
140
+ dimension: AuditAggregationDimension;
141
+ /** Required for the time dimension; defaults to day. */
142
+ resolution?: AuditAggregationResolution;
143
+ }
144
+
145
+ export interface AuditAggregationMetric {
146
+ /** Stable key used in response rows. Must contain only letters, numbers, underscores, or hyphens. */
147
+ id: string;
148
+ operation: AuditAggregationOperation;
149
+ /** Required for count_distinct. */
150
+ field?: AuditAggregationDistinctField;
151
+ /** Required for meter operations. */
152
+ meterCategory?: string;
153
+ /** Required for meter operations. */
154
+ meterType?: string;
155
+ }
156
+
157
+ export interface AuditAggregationDetailFilter {
158
+ field: AuditAggregationDetailField;
159
+ values: string[];
160
+ }
161
+
162
+ export interface AuditAggregationFilter {
163
+ actions?: AuditAction[];
164
+ resourceTypes?: string[];
165
+ eventCategories?: EventCategory[];
166
+ providers?: string[];
167
+ success?: boolean;
168
+ details?: AuditAggregationDetailFilter[];
169
+ }
170
+
171
+ /**
172
+ * Safe audit aggregation query. The server always applies the authenticated account scope and,
173
+ * for project-scoped principals, replaces projectId with the authenticated project.
174
+ */
175
+ export interface AuditAggregationQuery {
176
+ /** Optional account-admin project filter. Ignored for project-scoped principals. */
177
+ projectId?: string;
178
+ /** Start time; defaults to 30 days before to. The server caps the range at 366 days. */
179
+ from?: string;
180
+ /** End time; defaults to the current time. */
181
+ to?: string;
182
+ filter?: AuditAggregationFilter;
183
+ groupBy?: AuditAggregationGroup[];
184
+ metrics: AuditAggregationMetric[];
185
+ /** Maximum groups returned (default 50, max 200). */
186
+ limit?: number;
187
+ }
188
+
189
+ export interface AuditAggregationRow {
190
+ dimensions: Partial<Record<AuditAggregationDimension, string | null>>;
191
+ metrics: Record<string, number>;
192
+ }
193
+
194
+ export interface AuditAggregationResponse {
195
+ rows: AuditAggregationRow[];
196
+ from: string;
197
+ to: string;
198
+ }
@@ -851,6 +851,99 @@ export interface DashboardQueryParameters {
851
851
  defaults: Record<string, string>;
852
852
  }
853
853
 
854
+ /**
855
+ * Elasticsearch DSL supported by dashboard data sources.
856
+ * Queries execute through Vertesia Store, so project/security filtering remains server-side.
857
+ */
858
+ export interface DashboardElasticsearchDsl {
859
+ query?: Record<string, unknown>;
860
+ aggs?: Record<string, unknown>;
861
+ size?: number;
862
+ from?: number;
863
+ sort?: Array<Record<string, unknown>>;
864
+ }
865
+
866
+ /**
867
+ * How an Elasticsearch DSL result should be converted into Vega rows.
868
+ */
869
+ export type DashboardElasticsearchResultMapping =
870
+ | {
871
+ type: 'hits';
872
+ }
873
+ | {
874
+ type: 'aggregation_buckets';
875
+ /** Dot path under `aggregations` that contains a `buckets` array. */
876
+ path: string;
877
+ /** Output field name for bucket key. Defaults to `key`. */
878
+ keyField?: string;
879
+ /** Output field name for doc count. Defaults to `doc_count`. */
880
+ countField?: string;
881
+ };
882
+
883
+ /**
884
+ * Dashboard data source backed by a Data Platform SQL query.
885
+ */
886
+ export interface DashboardSqlDataSource {
887
+ kind: 'data_sql';
888
+ /** SQL query that returns all rows for the dashboard. */
889
+ query: string;
890
+ /** Maximum rows to return from the query. */
891
+ queryLimit?: number;
892
+ /** Default values for SQL {{param}} placeholders. */
893
+ queryParameters?: Record<string, string>;
894
+ }
895
+
896
+ /**
897
+ * Dashboard data source backed by Vertesia Store Elasticsearch DSL.
898
+ */
899
+ export interface DashboardStoreElasticsearchDataSource {
900
+ kind: 'store_es_dsl';
901
+ /** Elasticsearch DSL query executed through the secured Store query API. */
902
+ dsl: DashboardElasticsearchDsl;
903
+ /** Result mapping. Defaults to `hits`. */
904
+ result?: DashboardElasticsearchResultMapping;
905
+ }
906
+
907
+ /**
908
+ * Data source for a Vega dashboard.
909
+ */
910
+ export type DashboardDataSource = DashboardSqlDataSource | DashboardStoreElasticsearchDataSource;
911
+
912
+ /**
913
+ * Dashboard definition contributed by an app package.
914
+ *
915
+ * App dashboard IDs are local to the app. The platform exposes them as
916
+ * `app:<app_name>:<id>` when listing or retrieving dashboards.
917
+ */
918
+ export interface AppDashboardDefinition {
919
+ /** Local app dashboard ID. */
920
+ id: string;
921
+ /** Machine-friendly dashboard name. Defaults to `id`. */
922
+ name?: string;
923
+ /** Display title. Defaults to `name` or `id`. */
924
+ title?: string;
925
+ /** User-facing description. */
926
+ description?: string;
927
+ /** Tags for discovery and filtering. */
928
+ tags?: string[];
929
+ /** Data source used to populate Vega `data.values`. */
930
+ dataSource?: DashboardDataSource;
931
+ /** SQL query shortcut for app dashboards backed by data stores. */
932
+ query?: string;
933
+ /** Maximum SQL rows to return. */
934
+ queryLimit?: number;
935
+ /** Default values for SQL {{param}} placeholders. */
936
+ queryParameters?: Record<string, string>;
937
+ /** Complete Vega-Lite specification for the dashboard. */
938
+ spec?: Record<string, unknown>;
939
+ /** Legacy named SQL queries. */
940
+ queries?: DashboardQuery[];
941
+ /** Legacy panel definitions. */
942
+ panels?: DashboardPanel[];
943
+ /** Legacy dashboard layout. */
944
+ layout?: DashboardLayout;
945
+ }
946
+
854
947
  /**
855
948
  * Summary view of a dashboard (for listings).
856
949
  */
@@ -867,15 +960,22 @@ export interface DashboardItem extends BaseObject {
867
960
  last_rendered_at?: string;
868
961
  /** Tags for organization */
869
962
  tags: string[];
963
+ /** Source of the dashboard definition. Defaults to stored dashboards. */
964
+ source?: 'stored' | 'app';
965
+ /** App name when `source` is `app`. */
966
+ app_name?: string;
967
+ /** App dashboards are read-only until cloned into a stored dashboard. */
968
+ readonly?: boolean;
870
969
  }
871
970
 
872
971
  /**
873
972
  * Full dashboard with SQL query and Vega-Lite specification.
874
973
  *
875
974
  * **New architecture (v2):**
876
- * - Single `query` field with SQL (use JOINs/CTEs for complex data needs)
975
+ * - `dataSource` field with either SQL or Store Elasticsearch DSL
877
976
  * - Single `spec` field with complete Vega-Lite spec (vconcat/hconcat for multiple panels)
878
977
  * - Cross-panel interactivity via Vega selections
978
+ * - Legacy top-level `query` fields are treated as a SQL data source
879
979
  *
880
980
  * **Legacy architecture (v1, deprecated):**
881
981
  * - Multiple `queries` with named data sources
@@ -885,18 +985,26 @@ export interface DashboardItem extends BaseObject {
885
985
  */
886
986
  export interface Dashboard extends DashboardItem {
887
987
  // ============= New architecture (v2) =============
988
+ /**
989
+ * Data source used to populate Vega `data.values`.
990
+ * When omitted, top-level `query` is treated as a SQL data source for backwards compatibility.
991
+ */
992
+ dataSource?: DashboardDataSource;
888
993
  /**
889
994
  * SQL query that returns all data for the dashboard.
890
995
  * Use JOINs, CTEs, or UNION ALL to combine data from multiple tables.
891
996
  * Can include {{param_name}} placeholders for dynamic values.
997
+ * @deprecated Use `dataSource: { kind: 'data_sql', query }` instead.
892
998
  */
893
999
  query?: string;
894
1000
  /**
895
1001
  * Maximum rows to return from the query (default: 10000).
1002
+ * @deprecated Use `dataSource.queryLimit` instead.
896
1003
  */
897
1004
  queryLimit?: number;
898
1005
  /**
899
1006
  * Default values for SQL parameters.
1007
+ * @deprecated Use `dataSource.queryParameters` instead.
900
1008
  */
901
1009
  queryParameters?: Record<string, string>;
902
1010
  /**
@@ -930,15 +1038,17 @@ export interface Dashboard extends DashboardItem {
930
1038
 
931
1039
  /**
932
1040
  * Payload for creating a new dashboard.
933
- * Requires query (SQL) and spec (Vega-Lite).
1041
+ * Requires a data source and spec (Vega-Lite).
934
1042
  */
935
1043
  export interface CreateDashboardPayload {
936
1044
  /** Dashboard name (unique within store) */
937
1045
  name: string;
938
1046
  /** Dashboard summary */
939
1047
  summary?: string;
940
- /** SQL query that returns all data for the dashboard */
941
- query: string;
1048
+ /** Data source used to populate Vega `data.values`. */
1049
+ dataSource?: DashboardDataSource;
1050
+ /** SQL query that returns all data for the dashboard. Deprecated shortcut for a SQL data source. */
1051
+ query?: string;
942
1052
  /** Maximum rows to return from the query (default: 10000) */
943
1053
  queryLimit?: number;
944
1054
  /** Default values for SQL {{param}} placeholders */
@@ -955,7 +1065,9 @@ export interface UpdateDashboardPayload {
955
1065
  name?: string;
956
1066
  /** Dashboard summary */
957
1067
  summary?: string;
958
- /** SQL query that returns all data for the dashboard */
1068
+ /** Data source used to populate Vega `data.values`. */
1069
+ dataSource?: DashboardDataSource;
1070
+ /** SQL query that returns all data for the dashboard. Deprecated shortcut for a SQL data source. */
959
1071
  query?: string;
960
1072
  /** Maximum rows to return from the query (default: 10000) */
961
1073
  queryLimit?: number;
@@ -972,6 +1084,8 @@ export interface UpdateDashboardPayload {
972
1084
  */
973
1085
  export interface PreviewDashboardPayload {
974
1086
  // ============= New architecture (v2) =============
1087
+ /** Data source used to populate Vega `data.values`. */
1088
+ dataSource?: DashboardDataSource;
975
1089
  /** SQL query that returns all data for the dashboard */
976
1090
  query?: string;
977
1091
  /** Maximum rows to return from the query (default: 10000) */
@@ -1035,6 +1149,16 @@ export interface DashboardVersion {
1035
1149
  version_number: number;
1036
1150
  /** Commit message describing the change */
1037
1151
  message: string;
1152
+ /** Snapshot of v2 data source at this version */
1153
+ dataSource?: DashboardDataSource;
1154
+ /** Snapshot of v2 SQL query at this version */
1155
+ query?: string;
1156
+ /** Snapshot of v2 query limit at this version */
1157
+ queryLimit?: number;
1158
+ /** Snapshot of v2 query parameters at this version */
1159
+ queryParameters?: Record<string, string>;
1160
+ /** Snapshot of v2 Vega-Lite spec at this version */
1161
+ spec?: Record<string, unknown>;
1038
1162
  /** Snapshot of queries at this version */
1039
1163
  queries: DashboardQuery[];
1040
1164
  /** Snapshot of panels at this version */
package/src/index.ts CHANGED
@@ -37,6 +37,7 @@ export * from './rate-limiter.js';
37
37
  export * from './refs.js';
38
38
  export * from './roles/types.js';
39
39
  export * from './runs.js';
40
+ export * from './schema-for-extraction.js';
40
41
  export * from './secrets.js';
41
42
  export * from './skill.js';
42
43
  export * from './store/index.js';
@@ -74,4 +75,15 @@ export * from './utils/auth.js';
74
75
  export * from './utils/schemas.js';
75
76
  export type * from './utils/type-helpers.js';
76
77
  export * from './versions.js';
78
+ export * from './view-configuration-validation.js';
79
+ export * from './view-query-validation.js';
80
+ export * from './view-validation-helpers.js';
81
+ export * from './views.js';
82
+ export * from './views-schema.js';
83
+ export {
84
+ type AppViewExperienceId,
85
+ parseAppViewExperienceId,
86
+ type ViewValidationIssue,
87
+ validateViewExperienceId,
88
+ } from './views-validation.js';
77
89
  export * from './workflow-analytics.js';
@@ -26,7 +26,7 @@ import type {
26
26
  } from './prompt.js';
27
27
  import type { ExecutionRunDocRef } from './runs.js';
28
28
  import type { AgentToolApprovalMode } from './store/agent-approval.js';
29
- import type { ConversationState } from './store/conversation-state.js';
29
+ import type { ConversationState, TextArtifactReference } from './store/conversation-state.js';
30
30
  import type { AccountRef } from './user.js';
31
31
  import type { LlmCallType } from './workflow-analytics.js';
32
32
 
@@ -895,6 +895,8 @@ export interface ResultStorageOptions {
895
895
  // - Otherwise → text/markdown or text/plain
896
896
  }
897
897
 
898
+ export type AsyncCompletionMode = 'conversation_state' | 'text';
899
+
898
900
  /**
899
901
  * Streaming-specific options (only needed when stream=true)
900
902
  */
@@ -950,6 +952,13 @@ export interface AsyncCompletionOptions {
950
952
  * after inference completes (before completing the Temporal activity).
951
953
  */
952
954
  result_storage?: ResultStorageOptions;
955
+ /**
956
+ * Controls the value used to complete the Temporal activity.
957
+ * Defaults to `conversation_state` for agent resume/continuation calls.
958
+ * Use `text` for one-shot helper calls, such as checkpoint summaries,
959
+ * that need the model's text result instead of merged conversation state.
960
+ */
961
+ completion_mode?: AsyncCompletionMode;
953
962
  }
954
963
 
955
964
  interface ResumeConversationPayload {
@@ -966,6 +975,12 @@ interface ResumeConversationPayload {
966
975
 
967
976
  export interface ToolResultContent {
968
977
  content: string;
978
+ /**
979
+ * Reference to text content stored outside Temporal/API payloads. Servers that
980
+ * execute the next model turn should resolve this before constructing the
981
+ * provider prompt.
982
+ */
983
+ content_ref?: TextArtifactReference;
969
984
  is_error: boolean;
970
985
  files?: string[];
971
986
  /**
@@ -1181,6 +1196,10 @@ export interface InteractionExecutionConfiguration {
1181
1196
  run_data?: RunDataStorageLevel;
1182
1197
  configMode?: ConfigModes;
1183
1198
  model_options?: ModelOptions;
1199
+ /** Stable provider-side routing key for automatic prompt caching. */
1200
+ prompt_cache_key?: string;
1201
+ /** Put the result schema after the cached prefix; Vertesia still validates the returned JSON against it. */
1202
+ prompt_cache_schema_suffix?: boolean;
1184
1203
  /** Per-run HTTP timeouts for upstream LLM-provider calls. */
1185
1204
  http_timeout?: HttpTimeoutOptions;
1186
1205
  }
@@ -2,7 +2,6 @@ export type {
2
2
  JSONSchema,
3
3
  JSONSchemaArray,
4
4
  JSONSchemaObject,
5
- JSONSchemaProperties,
6
5
  JSONSchemaType,
7
6
  JSONSchemaTypeName,
8
7
  } from '@llumiverse/common';
@@ -3,6 +3,7 @@ import type { ConversationVisibility, InteractionExecutionConfiguration } from '
3
3
  import type { SystemRoles } from './project.js';
4
4
  import type {
5
5
  AgentRunStatus,
6
+ GroundedVerificationBreakdown,
6
7
  JsonLogicRule,
7
8
  ProcessDefinitionBody,
8
9
  ProcessRunType,
@@ -81,12 +82,44 @@ export interface PlatformEvent extends EventRef {
81
82
  */
82
83
  export type WorkflowLifecycleAction = 'workflow_completed' | 'workflow_failed';
83
84
 
85
+ export interface DocumentProcessingModelUsage {
86
+ role: 'extraction' | 'review';
87
+ run_id: string;
88
+ model?: string;
89
+ environment_id?: string;
90
+ provider?: string;
91
+ }
92
+
93
+ /** Compact, content-free operational summary emitted after grounded IDP completes. */
94
+ export interface DocumentProcessedEventData {
95
+ schema_version: 1;
96
+ pipeline: 'grounded_extraction';
97
+ object_id: string;
98
+ page_count: number;
99
+ ocr_page_count: number;
100
+ vision_page_count: number;
101
+ property_count: number;
102
+ citation_count: number;
103
+ verification: GroundedVerificationBreakdown;
104
+ result_path: string;
105
+ confidence?: number;
106
+ coverage_min?: number;
107
+ hardness?: number;
108
+ escalated?: boolean;
109
+ reviewed?: boolean;
110
+ review_issue_count?: number;
111
+ verdict?: 'good_to_go' | 'needs_review';
112
+ verdict_reason?: string;
113
+ models_used?: DocumentProcessingModelUsage[];
114
+ review_agent_run_id?: string;
115
+ }
116
+
84
117
  /**
85
118
  * Resource flavor of a workflow lifecycle event, derived from the Temporal workflow type:
86
119
  * ExecuteConversationWorkflow -> agent_run, ExecuteProcessWorkflow -> process_run,
87
- * anything else -> workflow_run.
120
+ * document-scoped workflows may use content_object, and anything else -> workflow_run.
88
121
  */
89
- export type WorkflowLifecycleResourceType = 'workflow_run' | 'agent_run' | 'process_run';
122
+ export type WorkflowLifecycleResourceType = 'workflow_run' | 'agent_run' | 'process_run' | 'content_object';
90
123
 
91
124
  /**
92
125
  * Body of POST /internal/events/publish (zeno-server, workload-identity gated). Sent by Temporal
@@ -98,6 +131,8 @@ export interface PublishWorkflowLifecycleEventRequest {
98
131
  project_id: string;
99
132
  action: WorkflowLifecycleAction;
100
133
  resource_type: WorkflowLifecycleResourceType;
134
+ /** Domain resource the workflow acted on. Defaults to workflow_id for workflow-scoped events. */
135
+ resource_id?: string;
101
136
  workflow_id: string;
102
137
  workflow_run_id: string;
103
138
  workflow_type: string;
@@ -110,6 +145,8 @@ export interface PublishWorkflowLifecycleEventRequest {
110
145
  error?: string;
111
146
  /** EventRef of the event that started the workflow (payload.vars.event_ref), if any. */
112
147
  caused_by?: EventRef;
148
+ /** Optional IDP outcome published as a separate, subscribable content event. */
149
+ document_processed?: DocumentProcessedEventData;
113
150
  }
114
151
 
115
152
  /**
@@ -489,6 +526,59 @@ export interface ListEventDeliveriesResponse {
489
526
  deliveries: EventDeliverySummary[];
490
527
  }
491
528
 
529
+ export interface StreamEventDeliveriesQuery {
530
+ limit?: number;
531
+ event_id?: string;
532
+ resource_id?: string;
533
+ resource_type?: string[];
534
+ event_category?: EventCategory[];
535
+ action?: string[];
536
+ outbox_status?: EventOutboxStatus[];
537
+ since_event_id?: string;
538
+ since_created_at?: string;
539
+ include_event?: boolean;
540
+ poll_interval_ms?: number;
541
+ }
542
+
543
+ export interface EventDeliveryStreamItem {
544
+ cursor: string;
545
+ delivery: EventDeliverySummary;
546
+ event?: PlatformEvent;
547
+ }
548
+
549
+ export interface EventDeliveryStreamSnapshot {
550
+ type: 'snapshot';
551
+ emitted_at: string;
552
+ cursor?: string;
553
+ deliveries: EventDeliveryStreamItem[];
554
+ }
555
+
556
+ export interface EventDeliveryStreamUpdate {
557
+ type: 'event';
558
+ emitted_at: string;
559
+ cursor: string;
560
+ item: EventDeliveryStreamItem;
561
+ }
562
+
563
+ export interface EventDeliveryStreamHeartbeat {
564
+ type: 'heartbeat';
565
+ emitted_at: string;
566
+ cursor?: string;
567
+ }
568
+
569
+ export interface EventDeliveryStreamError {
570
+ type: 'error';
571
+ emitted_at: string;
572
+ cursor?: string;
573
+ error: string;
574
+ }
575
+
576
+ export type EventDeliveryStreamEnvelope =
577
+ | EventDeliveryStreamSnapshot
578
+ | EventDeliveryStreamUpdate
579
+ | EventDeliveryStreamHeartbeat
580
+ | EventDeliveryStreamError;
581
+
492
582
  export type EventSubscriptionSortField = 'name' | 'scope' | 'target_type' | 'enabled' | 'updated_at';
493
583
 
494
584
  export interface ListEventSubscriptionsQuery {
@@ -0,0 +1,44 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { validateProjectSearchPropertyMappings } from './project.js';
3
+
4
+ describe('validateProjectSearchPropertyMappings', () => {
5
+ it('accepts supported leaf mappings on relative property paths', () => {
6
+ expect(
7
+ validateProjectSearchPropertyMappings({
8
+ order_total: { type: 'double', ignore_malformed: true },
9
+ release_date: {
10
+ type: 'date',
11
+ format: 'strict_date_optional_time||yyyy-MM-dd',
12
+ ignore_malformed: true,
13
+ },
14
+ 'customer.account_number': { type: 'keyword', ignore_above: 128 },
15
+ }),
16
+ ).toEqual([]);
17
+ });
18
+
19
+ it('rejects unsupported mapping options and types', () => {
20
+ const issues = validateProjectSearchPropertyMappings({
21
+ order_total: { type: 'scaled_float', scaling_factor: 100 },
22
+ release_date: { type: 'keyword', format: 'yyyy-MM-dd' },
23
+ customer: { type: 'keyword', ignore_malformed: true },
24
+ });
25
+
26
+ expect(issues).toEqual(
27
+ expect.arrayContaining([
28
+ expect.stringContaining('unsupported option(s): scaling_factor'),
29
+ expect.stringContaining('type must be one of'),
30
+ expect.stringContaining('format is supported only for date mappings'),
31
+ expect.stringContaining('ignore_malformed is supported only for long, double, and date mappings'),
32
+ ]),
33
+ );
34
+ });
35
+
36
+ it('allows parent and child leaf mappings for subobjects:false indexes', () => {
37
+ expect(
38
+ validateProjectSearchPropertyMappings({
39
+ customer: { type: 'keyword' },
40
+ 'customer.name': { type: 'keyword' },
41
+ }),
42
+ ).toEqual([]);
43
+ });
44
+ });