@vertesia/common 1.5.0-dev.20260717.131047Z → 1.5.0-dev.20260725.083715Z

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 (123) hide show
  1. package/lib/apps.d.ts +184 -48
  2. package/lib/apps.d.ts.map +1 -1
  3. package/lib/apps.js +21 -9
  4. package/lib/apps.js.map +1 -1
  5. package/lib/audit-trail.d.ts +61 -1
  6. package/lib/audit-trail.d.ts.map +1 -1
  7. package/lib/audit-trail.js +15 -0
  8. package/lib/audit-trail.js.map +1 -1
  9. package/lib/environment.d.ts +2 -0
  10. package/lib/environment.d.ts.map +1 -1
  11. package/lib/environment.js.map +1 -1
  12. package/lib/index.d.ts +7 -0
  13. package/lib/index.d.ts.map +1 -1
  14. package/lib/index.js +7 -0
  15. package/lib/index.js.map +1 -1
  16. package/lib/interaction.d.ts +77 -1
  17. package/lib/interaction.d.ts.map +1 -1
  18. package/lib/interaction.js +48 -0
  19. package/lib/interaction.js.map +1 -1
  20. package/lib/platform-event.d.ts +37 -3
  21. package/lib/platform-event.d.ts.map +1 -1
  22. package/lib/platform-event.js.map +1 -1
  23. package/lib/project.d.ts +119 -20
  24. package/lib/project.d.ts.map +1 -1
  25. package/lib/project.js +65 -0
  26. package/lib/project.js.map +1 -1
  27. package/lib/query.d.ts +6 -0
  28. package/lib/query.d.ts.map +1 -1
  29. package/lib/refs.d.ts +1 -0
  30. package/lib/refs.d.ts.map +1 -1
  31. package/lib/schema-for-extraction.d.ts +21 -0
  32. package/lib/schema-for-extraction.d.ts.map +1 -0
  33. package/lib/schema-for-extraction.js +205 -0
  34. package/lib/schema-for-extraction.js.map +1 -0
  35. package/lib/store/agent-run.d.ts +23 -1
  36. package/lib/store/agent-run.d.ts.map +1 -1
  37. package/lib/store/conversation-state.d.ts +3 -1
  38. package/lib/store/conversation-state.d.ts.map +1 -1
  39. package/lib/store/conversation-state.js.map +1 -1
  40. package/lib/store/doc-analyzer.d.ts +10 -67
  41. package/lib/store/doc-analyzer.d.ts.map +1 -1
  42. package/lib/store/dsl-workflow.d.ts +1 -0
  43. package/lib/store/dsl-workflow.d.ts.map +1 -1
  44. package/lib/store/dsl-workflow.js.map +1 -1
  45. package/lib/store/grounded-extraction.d.ts +146 -0
  46. package/lib/store/grounded-extraction.d.ts.map +1 -0
  47. package/lib/store/grounded-extraction.js +8 -0
  48. package/lib/store/grounded-extraction.js.map +1 -0
  49. package/lib/store/index.d.ts +1 -0
  50. package/lib/store/index.d.ts.map +1 -1
  51. package/lib/store/index.js +1 -0
  52. package/lib/store/index.js.map +1 -1
  53. package/lib/store/store.d.ts +314 -1
  54. package/lib/store/store.d.ts.map +1 -1
  55. package/lib/store/store.js +451 -0
  56. package/lib/store/store.js.map +1 -1
  57. package/lib/store/workflow.d.ts +8 -1
  58. package/lib/store/workflow.d.ts.map +1 -1
  59. package/lib/store/workflow.js +5 -0
  60. package/lib/store/workflow.js.map +1 -1
  61. package/lib/user.d.ts +14 -0
  62. package/lib/user.d.ts.map +1 -1
  63. package/lib/user.js +31 -0
  64. package/lib/user.js.map +1 -1
  65. package/lib/vertesia-common.js +2 -2
  66. package/lib/vertesia-common.js.map +1 -1
  67. package/lib/view-configuration-validation.d.ts +15 -0
  68. package/lib/view-configuration-validation.d.ts.map +1 -0
  69. package/lib/view-configuration-validation.js +63 -0
  70. package/lib/view-configuration-validation.js.map +1 -0
  71. package/lib/view-query-validation.d.ts +13 -0
  72. package/lib/view-query-validation.d.ts.map +1 -0
  73. package/lib/view-query-validation.js +266 -0
  74. package/lib/view-query-validation.js.map +1 -0
  75. package/lib/view-validation-helpers.d.ts +15 -0
  76. package/lib/view-validation-helpers.d.ts.map +1 -0
  77. package/lib/view-validation-helpers.js +25 -0
  78. package/lib/view-validation-helpers.js.map +1 -0
  79. package/lib/views-schema.d.ts +1992 -0
  80. package/lib/views-schema.d.ts.map +1 -0
  81. package/lib/views-schema.js +674 -0
  82. package/lib/views-schema.js.map +1 -0
  83. package/lib/views-validation.d.ts +21 -0
  84. package/lib/views-validation.d.ts.map +1 -0
  85. package/lib/views-validation.js +164 -0
  86. package/lib/views-validation.js.map +1 -0
  87. package/lib/views.d.ts +381 -0
  88. package/lib/views.d.ts.map +1 -0
  89. package/lib/views.js +41 -0
  90. package/lib/views.js.map +1 -0
  91. package/package.json +5 -5
  92. package/src/agent-resources.test.ts +100 -0
  93. package/src/apps.test.ts +9 -1
  94. package/src/apps.ts +220 -73
  95. package/src/audit-trail.ts +83 -0
  96. package/src/environment.ts +2 -0
  97. package/src/index.ts +12 -0
  98. package/src/interaction.ts +135 -1
  99. package/src/platform-event.ts +39 -2
  100. package/src/project.test.ts +44 -0
  101. package/src/project.ts +205 -22
  102. package/src/query.ts +6 -0
  103. package/src/refs.ts +1 -0
  104. package/src/schema-for-extraction.test.ts +191 -0
  105. package/src/schema-for-extraction.ts +231 -0
  106. package/src/store/agent-run.ts +29 -0
  107. package/src/store/content-type-editing.test.ts +17 -0
  108. package/src/store/conversation-state.ts +4 -1
  109. package/src/store/doc-analyzer.ts +10 -76
  110. package/src/store/dsl-workflow.ts +1 -0
  111. package/src/store/grounded-extraction.ts +154 -0
  112. package/src/store/index.ts +1 -0
  113. package/src/store/store.ts +800 -1
  114. package/src/store/workflow.ts +12 -0
  115. package/src/user.ts +46 -0
  116. package/src/view-configuration-validation.ts +74 -0
  117. package/src/view-query-validation.test.ts +21 -0
  118. package/src/view-query-validation.ts +319 -0
  119. package/src/view-validation-helpers.ts +28 -0
  120. package/src/views-schema.test.ts +364 -0
  121. package/src/views-schema.ts +689 -0
  122. package/src/views-validation.ts +234 -0
  123. package/src/views.ts +484 -0
@@ -0,0 +1,154 @@
1
+ import type { InteractionExecutionConfiguration } from '../interaction.js';
2
+ import type { WorkflowRunStatus } from './workflow.js';
3
+
4
+ /**
5
+ * Document-level trust verdict for a grounded extraction. `good_to_go` means the
6
+ * extracted content (after any review corrections) can be used without a human
7
+ * check; `needs_review` means a human should verify it. This reflects content
8
+ * correctness, not how many citation boxes rendered.
9
+ */
10
+ export type GroundedExtractionVerdict = 'good_to_go' | 'needs_review';
11
+
12
+ /**
13
+ * Canonical workflow id for object-scoped grounded extraction. Every entry point
14
+ * must use this id so Temporal prevents overlapping extraction runs per object.
15
+ */
16
+ export function getGroundedExtractionWorkflowId(accountId: string, objectId: string): string {
17
+ return `${accountId.slice(0, 6)}:workflow_execution_request:${objectId}:grounded`;
18
+ }
19
+
20
+ /**
21
+ * Request body to start a grounded extraction on a content object. All fields are
22
+ * optional: with none set, the object's own content-type schema drives the
23
+ * extraction with default models and settings.
24
+ */
25
+ export interface GroundedExtractionRequest {
26
+ /** JSON schema describing the data to extract. Takes precedence over type_ref. */
27
+ schema?: Record<string, unknown>;
28
+ /** Content type id or catalog ref whose object_schema drives the extraction. */
29
+ type_ref?: string;
30
+ /** Interaction to use. Defaults to sys:ExtractInformationGrounded. */
31
+ interaction_name?: string;
32
+ /** Maximum number of pages to process. */
33
+ max_pages?: number;
34
+ /** Run OCR on every page even when a text layer exists. */
35
+ force_ocr?: boolean;
36
+ /** Re-run OCR on pages that need it instead of restoring the stored OCR result. */
37
+ refresh_ocr?: boolean;
38
+ /** Attach clean page images for layout/semantic context; direct-vision pages also receive checkerboards. */
39
+ use_vision?: boolean;
40
+ /**
41
+ * A1 locate-grid cell size in PDF points for vision pages (drives both the drawn
42
+ * grid and cell→box resolution). Smaller = finer grid / more cells. Default: 14.
43
+ */
44
+ grid_cell_pt?: number;
45
+ /**
46
+ * How to read pages that have no digital text layer (scans / image-only pages).
47
+ * 'vision' (default): read them off the page image with the extraction model,
48
+ * skipping OCR entirely. 'ocr': legacy path — OCR those pages and block-ground on
49
+ * the (lossy) OCR text. Set to 'ocr' to revert to the pre-vision behavior.
50
+ */
51
+ raster_mode?: 'vision' | 'ocr';
52
+ /** Maximum pages per extraction call; larger documents are split into sequential windows. */
53
+ window_pages?: number;
54
+ /**
55
+ * Extract with an autonomous agent (views the whole document at once) instead of
56
+ * the deterministic windowed pipeline. Sidesteps window-boundary splits on long
57
+ * documents. The workflow stages the artifacts into an agent space, runs a
58
+ * conversation agent that writes the extraction, then folds it back.
59
+ */
60
+ agentic_extraction?: boolean;
61
+ /** Agent interaction for agentic_extraction. Defaults to sys:GeneralAgent. */
62
+ extract_agent?: string;
63
+ /** Update the object's properties with the extracted data. Default: true. */
64
+ update_properties?: boolean;
65
+ /** LLM execution configuration (model, environment, ...) for the main pass. */
66
+ config?: InteractionExecutionConfiguration;
67
+ /** Execution configuration used instead of `config` on hard content (scans, handwriting). */
68
+ hard_config?: InteractionExecutionConfiguration;
69
+ /** Hardness score (0..1) at or above which `hard_config` is used. Default: 0.5. */
70
+ hardness_threshold?: number;
71
+ /** Execution configuration for the post-extraction review pass. No review runs when absent. */
72
+ review_config?: InteractionExecutionConfiguration;
73
+ /** Hardness score (0..1) at or above which the review runs. Defaults to hardness_threshold. */
74
+ review_threshold?: number;
75
+ /** Review triggers when any page's citation coverage falls below this floor. Default: 0.2. */
76
+ coverage_review_threshold?: number;
77
+ /** Run the model review even when every citation was digitally verified. Requires review_config. */
78
+ force_review?: boolean;
79
+ /**
80
+ * Free-text operator guidance folded into the extraction prompt to steer a
81
+ * (re-)extraction, e.g. "part numbers are in the third column; some line items
82
+ * wrap onto the next row".
83
+ */
84
+ operator_instructions?: string;
85
+ /** Interactive assistant only: the operator's opening message for the assistant conversation. */
86
+ user_prompt?: string;
87
+ }
88
+
89
+ /**
90
+ * Response from starting the interactive grounded extraction assistant. The agent
91
+ * run + conversation workflow are launched server-side (recordRun -> stage the
92
+ * document into the agent space -> launch the interactive conversation); the
93
+ * client renders the conversation with `agent_run_id`.
94
+ */
95
+ export interface GroundedAssistantResponse {
96
+ /** The AgentRun id to stream/render the conversation. */
97
+ agent_run_id: string;
98
+ /** The conversation workflow id backing the run. */
99
+ workflow_id: string;
100
+ /** The object the assistant is scoped to. */
101
+ object_id: string;
102
+ }
103
+
104
+ /**
105
+ * Status of a grounded extraction workflow. Carries the doc-level verdict once the
106
+ * run has completed and written its result.
107
+ */
108
+ export interface GroundedExtractionRunStatusResponse extends WorkflowRunStatus {
109
+ /** The trust verdict, present once the run has completed. */
110
+ verdict?: GroundedExtractionVerdict;
111
+ }
112
+
113
+ /**
114
+ * How each extracted value was verified. Two kinds, both trustworthy:
115
+ * digitally verified (matched the document's text — digital layer or OCR) and
116
+ * AI verified (the reviewer confirmed it against the page image — the primary
117
+ * signal for scanned or handwritten content, which has no text layer to match).
118
+ */
119
+ export interface GroundedVerificationBreakdown {
120
+ /** Total number of cited values. */
121
+ total: number;
122
+ /** Values matched verbatim against the document's text (digital layer or OCR). */
123
+ digitally_verified: number;
124
+ /** Values the reviewer model confirmed against the page image. */
125
+ ai_verified: number;
126
+ /** Values read from the image but neither text-matched nor reviewer-confirmed. */
127
+ unverified: number;
128
+ }
129
+
130
+ /**
131
+ * Completed grounded extraction result: the extracted data with its trust verdict
132
+ * and verification breakdown, plus a download URL for the full citations artifact.
133
+ */
134
+ export interface GroundedExtractionResultResponse {
135
+ object_id: string;
136
+ /** The extracted data, shaped by the requested schema. */
137
+ data: Record<string, unknown>;
138
+ /** Document-level trust verdict. */
139
+ verdict?: GroundedExtractionVerdict;
140
+ /** One-sentence rationale for the verdict. */
141
+ verdict_reason?: string;
142
+ /** Mean citation confidence in [0,1]. */
143
+ confidence?: number;
144
+ /** Per-value verification breakdown. */
145
+ verification: GroundedVerificationBreakdown;
146
+ /** Review outcome, when a review pass ran. */
147
+ review?: {
148
+ assessment: 'complete' | 'issues_found';
149
+ summary?: string;
150
+ corrections_applied?: number;
151
+ };
152
+ /** Signed download URL for the full grounded-extraction.json (data + citations + boxes). */
153
+ result_url?: string | null;
154
+ }
@@ -6,6 +6,7 @@ export * from './common.js';
6
6
  export * from './conversation-state.js';
7
7
  export * from './doc-analyzer.js';
8
8
  export * from './dsl-workflow.js';
9
+ export * from './grounded-extraction.js';
9
10
  export * from './hive-memory.js';
10
11
  export * from './object-types.js';
11
12
  export * from './process.js';