@docmana/sdk 0.28.1 → 0.36.0-hitl.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,7 +1,77 @@
1
1
  # @docmana/sdk
2
2
 
3
+ The HITL pilot uses the explicit prerelease `0.36.0-hitl.2` and the npm `hitl`
4
+ distribution tag. Install the exact version for reproducible pilot builds:
5
+
6
+ ```sh
7
+ npm install --save-exact @docmana/sdk@0.36.0-hitl.2
8
+ ```
9
+
10
+ The stable default remains on `latest`; the prerelease does not select a native
11
+ API. Configure the SDK's Consumer base URL on the application server.
12
+
13
+ ## Real formula node progress (local HITL pilot)
14
+
15
+ `sdk.executionEvents.list(executionId, { organization, after: 0, limit: 100, signal })`
16
+ reads a non-consuming metadata journal, including formulas without human review.
17
+ Follow `nextAfter` while non-null; order by `sequence`, deduplicate `eventId`, and
18
+ honor `truncated` when the cursor predates retained history. The native journal
19
+ keeps at most 2,000 events with the execution. No PDF or final-result retention
20
+ is added. Older APIs can return 404; show confirmed status without inventing
21
+ progress. Never turn a journal failure into a call to another backend.
22
+
23
+ The four new names are `execution.node.started`, `execution.node.completed`,
24
+ `execution.node.failed`, and `execution.node.reused`. Events identify a node,
25
+ document keys, revision and attempt. A reused output does not imply a new LLM
26
+ call. Completion of a node is technical completion, not a positive business
27
+ verdict or final execution completion. `occurredAt` is the real action time;
28
+ `publishedAt` is optional broker time, present on signed callbacks.
29
+
30
+ `verifyExecutionEventCallback` and `parseExecutionEventCallback` accept both the
31
+ new node metadata and the four existing review events. Existing review-only
32
+ verification helpers remain strict and unchanged. Final execution callbacks and
33
+ result ownership keep their existing contract; there are no pipeline events.
34
+
35
+ ## Review event callbacks
36
+
37
+ SDK 0.33.0 adds server-side `verifyReviewEventCallback`, `parseReviewEventCallback`
38
+ and the `ReviewEventCallback` type for Consumer's opt-in review event relay.
39
+ This is independent from `runFlowAsync({ callbackUrl })`, which still receives only
40
+ the final result. No Service Bus connection is required in your application.
41
+
42
+ ```ts
43
+ import { verifyReviewEventCallback } from "@docmana/sdk";
44
+ const event = verifyReviewEventCallback({
45
+ body: rawUtf8Body,
46
+ signature: request.headers.get("x-docmana-event-signature"),
47
+ timestamp: request.headers.get("x-docmana-event-timestamp"),
48
+ secret: serverConfiguredSecret, // at least 32 characters; never sent to a browser
49
+ organization: expectedOrganization,
50
+ });
51
+ await persistOnce(event.organization, event.eventId, event);
52
+ // Only now return 2xx. Never finalize an execution from a review notification.
53
+ ```
54
+
55
+ Supported types are `execution.awaiting_review`, `execution.review_done`,
56
+ `execution.review_closed` and `execution.review_expired`. `review_done` means the
57
+ decision is recorded, not that the execution is finished. `review_closed` also
58
+ describes the review rather than the execution. `publishedAt` is the broker's
59
+ publication time. The metadata excludes document names, values, notes and results.
60
+ Signatures use HMAC-SHA256 over `timestamp + "." + rawBody` with header `v1=<hex>`;
61
+ verification accepts a five-minute clock difference. Broker retries are re-signed
62
+ but retain the event ID; store it durably for deduplication. An event notification
63
+ never consumes the final result. Source publication is best-effort: reconcile
64
+ current review state separately after a missed notification.
65
+
3
66
  Official Docmana SDK for calling `docmana-consumer-edge-api`.
4
67
 
68
+ SDK 0.32.0 adds native formula authoring, assisted conversations and revision-pinned
69
+ document-trial preparation. Deploy Consumer authoring support before publishing
70
+ and adopting this version. DocMana API main supports the ordinary Mongo path;
71
+ assisted document trials run in DocMana Flows. A local development tarball is not
72
+ an npm release. Optional Git/projection types remain POC contracts, not proof of
73
+ support by API main.
74
+
5
75
  The SDK sends documents to Consumer, starts an async flow, polls Consumer for
6
76
  status, and returns the mapped Consumer execution DTO.
7
77
 
@@ -11,6 +81,17 @@ status, and returns the mapped Consumer execution DTO.
11
81
  npm install @docmana/sdk
12
82
  ```
13
83
 
84
+ ### GitHub release recovery
85
+
86
+ The Release workflow publishes an existing `v<version>` tag. GitHub Actions are
87
+ pinned to full commit SHAs to satisfy the enterprise policy. If a tag-triggered
88
+ run fails before starting, merge the workflow correction first, then manually
89
+ run **Release** from `main` with that existing tag. The workflow checks out the
90
+ tag and verifies its package version before publishing; do not move a release
91
+ tag to repair a pipeline. Publication requires the existing npm publisher
92
+ credential or trusted-publishing configuration. Verify the version is available
93
+ in npm before updating a consumer's lockfile.
94
+
14
95
  Requires Node.js 20+.
15
96
 
16
97
  ## Quickstart
@@ -345,6 +426,9 @@ from the Bearer token.
345
426
  Every SDK error extends `DocmanaError`, which carries `.status`, `.code`, and an
346
427
  optional `.requestId` when available.
347
428
 
429
+ The optional `.apiCode` preserves the public API business code (for example,
430
+ `RULE_INTEGRITY_VIOLATION`). `.code` keeps its existing SDK error category.
431
+
348
432
  | Error | Thrown when |
349
433
  | -------------------------------- | ----------------------------------------------------------------------------------------------- |
350
434
  | `DocmanaRequestError` | `400` bad request. |
@@ -379,6 +463,186 @@ For a one-shot publish to the local yalc store:
379
463
  npm run yalc:publish
380
464
  ```
381
465
 
466
+ ## Native formula authoring
467
+
468
+ SDK 0.30.0 adds the existing DocMana stateful assistant through
469
+ `authoring.openConversation({ flow_id, language, scope?, node_id?, messages? }, options)`,
470
+ `sendConversationMessage(conversationId, content, options)` and
471
+ `confirmConversation(conversationId, { rule_id?, document_type_rename? }, options)`.
472
+ All three require organization scope and accept an abort signal. Opening does
473
+ not call the LLM. Replies contain native context, suggestions and proposals;
474
+ the client must explicitly apply and save approved rules. Confirmation only
475
+ acknowledges acceptance; it does not save or publish. HTTP 410 means the session
476
+ expired: reopen with the prior transcript and resolved context, then send the
477
+ new message. Do not replay an uncertain network failure automatically.
478
+
479
+ `docmana.authoring` manages native formulas through Consumer Edge's
480
+ `/v1/authoring` endpoints. It requires the DOC-2385 Consumer deployment and the
481
+ DocMana API authoring endpoints. These methods do not manage Git or YAML.
482
+
483
+ ```ts
484
+ const options = { organization: "my-organization" };
485
+ const formulas = await docmana.authoring.list({ ...options, limit: 50, offset: 0 });
486
+ const snapshot = await docmana.authoring.get(formulas[0].id, options);
487
+ const command = {
488
+ operationId: crypto.randomUUID(),
489
+ expectedRevisions: snapshot.revisions,
490
+ flowPatch: { name: "Updated formula" },
491
+ };
492
+ const receipt = await docmana.authoring.save(snapshot.flow.id, command, options);
493
+ await docmana.authoring.validate(snapshot.flow.id, receipt.revisions, options);
494
+ // Publication is an explicit separate operation.
495
+ await docmana.authoring.publish(
496
+ snapshot.flow.id,
497
+ {
498
+ operationId: crypto.randomUUID(),
499
+ expectedRevisions: receipt.revisions,
500
+ },
501
+ options,
502
+ );
503
+ ```
504
+
505
+ Also available: `create`, `history(id, "snapshots" | "published", options)` and
506
+ `flags(options)`. Every call requires an organization and accepts an AbortSignal.
507
+ Lists return arrays; list limits are 1–200 and history limits are 1–100. List sorting is applied before pagination using `sort`: `id` (default), `name`, `newest`, `oldest`, `recentlyModified`, or `leastRecentlyModified`. Summaries include creation/modification dates and execution/document totals when available.
508
+ `get` returns the editable graph, assisted rules, revisions and history counts.
509
+ Create/save/publish return a receipt, not a reloaded graph. Reload with `get`
510
+ after a successful mutation when server-generated prompt/rule identities matter.
511
+
512
+ Retain the same operation ID **and identical body** when retrying an uncertain
513
+ mutation outcome. A 409 has `error.status === 409`: keep the user's draft and
514
+ resolve the conflict explicitly. The SDK never silently rebases or retries a
515
+ conflict. Native metadata remains opaque and must be preserved by editors;
516
+ server-owned identities, history and revisions are not patchable. Assisted
517
+ editing requires the organization's `assisted-flows` flag and backend roles.
518
+
519
+ Archive transfers use the existing DocMana `.docmana`/ZIP format, including
520
+ assisted rules. `exportArchive(id, options)` returns `Uint8Array` bytes.
521
+ `importArchive(blob, filename, options)` accepts one archive up to 10 MiB and
522
+ returns `imported` or `confirmation_required`. On a duplicate, obtain explicit
523
+ user confirmation before submitting the same file with `confirmOverwrite: true`.
524
+ `remove(id, options)` permanently deletes the formula and its authoring data;
525
+ confirm that action with the user. Import and deletion do not use operation IDs.
526
+
527
+ ## Human review of formula executions
528
+
529
+ Read calculation metadata repeatedly with
530
+ `client.reviews.calculation(executionId, { organization })`. It returns
531
+ `executionResultId`, normalized `executionStatus` and `calculation` (null for
532
+ legacy/unmarked runs). Calculation includes `status`, coherent `revision`
533
+ (0 before the first calculation), optional `targetRevision`, `provisional`,
534
+ review counts and computed/reused node counts for that revision. Node counts
535
+ are not individual model-call counts. Calculation revision is distinct from
536
+ `ReviewTask.version`, which remains required for decisions. A completed
537
+ calculation stays provisional until the persisted execution is terminal.
538
+ This read is available before the first review and after final callback delivery;
539
+ it never consumes the single-use final result or triggers pipelines/callbacks.
540
+
541
+ Requires Consumer's review routes and the compatible HITL Document API branch.
542
+ No pipelines are required. Start published manual formulas with `runFlowAsync`;
543
+ `AWAITING_REVIEW` is non-terminal. `runFlow` still waits for final completion and
544
+ retains its configured timeout, so do not hold an HTTP request open for human work.
545
+
546
+ ```ts
547
+ const scope = { organization: "your-organization", signal: controller.signal };
548
+ const { reviews, nextCursor } = await docmana.reviews.list({
549
+ ...scope,
550
+ status: "pending",
551
+ limit: 50,
552
+ });
553
+ const task = await docmana.reviews.get(reviews[0].executionResultId, scope);
554
+ await docmana.reviews.decide(
555
+ task.executionResultId,
556
+ {
557
+ decision: "continue",
558
+ version: task.version,
559
+ reviewer: authenticatedServerActor, // Never trust an identity from the browser.
560
+ corrections: [{ itemId: task.documents[0].items![0].itemId, value: false }],
561
+ },
562
+ scope,
563
+ );
564
+ // Preparation starts at import. Poll queued/processing; other states are terminal.
565
+ const preparation = await docmana.reviews.document(
566
+ task.executionResultId,
567
+ task.documents[0].docKey,
568
+ "preview",
569
+ {
570
+ ...scope,
571
+ version: task.reviewId,
572
+ },
573
+ );
574
+ const manifest = await preparation.json(); // DocumentPreviewManifest
575
+ // Only fetch numbers present in manifest.pages; page 1 precedes later batches.
576
+ // Original content remains available as the PDF fallback.
577
+ const page = await docmana.reviews.document(
578
+ task.executionResultId,
579
+ "doc01",
580
+ { page: 1 },
581
+ {
582
+ ...scope,
583
+ version: task.reviewId,
584
+ size: "thumb",
585
+ },
586
+ );
587
+ // page is a streaming Fetch Response. Consume or cancel its body; do not buffer a large PDF.
588
+ ```
589
+
590
+ `list` accepts `pending`, `submitted`, `resuming` and an opaque `cursor`. It lists
591
+ open tasks only. The `"*"` dossier entry is not a file. Use the returned item IDs
592
+ unchanged; JSON values preserve `null`, `false`, `0`, objects and arrays.
593
+ `document` also accepts `"content"` or `"locations"`, Range/If-Range and ETag
594
+ options. It returns 200/206/304/416 without consuming the body.
595
+
596
+ A decision receipt means **recorded and resume queued**, never final completion.
597
+ On 409 inspect `DocmanaError.reviewConflict` and `apiCode`, then re-read the task.
598
+ On 503 re-read first: the decision may already be recorded. The SDK does not retry
599
+ a decision after a conflict, 503 or uncertain transport outcome. The standard one-time
600
+ 401 token-refresh retry still applies. Keep the existing final callback/polling result owner;
601
+ opening a review must not consume the single-use execution result.
602
+
603
+ Release order: compatible Document API, Consumer, published SDK, then Arcana's
604
+ exact pinned dependency. This local 0.33.0 candidate is not published by these steps.
605
+
382
606
  ## License
383
607
 
384
608
  MIT
609
+
610
+ `authoring.editorCatalog(options)` retrieves organization-scoped models, tools, external-system field definitions, default prompts and feature flags for native node editors. External-system credentials are excluded. `authoring.generateMapping({ workflow_fields, expected_fields, current_mapping, user_instructions }, options)` returns `{ jsonataExpression }` from the native mapper; it does not save or publish the proposal.
611
+
612
+ ### Git publication provenance (local authoring POC)
613
+
614
+ The types preserve optional `authoringSource`, Git commit/artifact hashes and
615
+ projection fields for the POC contract. DocMana API main rejects these fields on
616
+ native create/save/publish, including an explicit `{kind: "mongo"}` discriminator;
617
+ omit them for ordinary Mongo authoring. The current Git POC uses the explicitly
618
+ local Mongo release adapter in DocMana Flows instead.
619
+
620
+ Optional response provenance remains lossless when a compatible backend provides
621
+ it. Consumer and the SDK do not synchronize repositories, verify a checkout,
622
+ compute a publication baseline or automatically publish newer commits. The
623
+ presence of a TypeScript field does not enable an unsupported backend capability.
624
+
625
+ ### Document trials
626
+
627
+ Use `authoring.trialDocument(fileBlob, filename, spec, { organization, signal })` for manual document-node trials. `spec` selects a saved native `flowId`, `expectedRevisions`, and either `node` or `allNodes`; alternatively it contains compiled YAML `nodes` with native prompts. Consumer calls the existing DocMana API test-fields/test-metadata endpoints. Temporary YAML prompts are removed in finally; abrupt process failure can leave one for administrator cleanup.
628
+
629
+ For assisted Mongo nodes, call `authoring.documentTrialDefinitions({ flowId, expectedRevisions, node | allNodes }, { organization, signal })`. This read-only preparation pins active node-owned rules and settings to the coherent native snapshot, checking revisions again after resolution. Pass the returned definition and uploaded file to the server-side `runAssistedDocumentTrial` library in `@docmana/docmana-flows`. Git callers use Flows' `prepareDocumentTrial` directly. Neither path requires `/extract/test-assisted` or a modified DocMana API. Calling the old native trial method with assisted nodes now fails before upload with HTTP 422.
630
+
631
+ Flows owns assisted IDP/model calls and requires its server-side provider configuration. It analyzes the file once and tries up to 100 compatible classification/extraction nodes independently, retaining evidence envelopes. Files are nonempty PDF/images up to 20 MiB. Definitions and uploads use disposable local storage, cleaned after completion; no formula, rule, reference expectation or publication is saved. These trials do not execute production routing, translate results, compare expectations or produce release approval evidence. Missing upstream context is rejected. Native API accounting and PromptShield are not implied by the Flows executor. No new CLI command is introduced.
632
+
633
+ ### Formula steps during human review
634
+
635
+ Task detail also preserves optional native `createdAt`, `submittedAt`, `resumingAt` and `closedAt` timestamps. Human waiting is bounded by task creation and native decision acceptance; review closure does not prove final execution completion. Older backends can omit these fields; clients must show an unavailable duration rather than infer it from callback delivery time.
636
+
637
+ Use client.reviews.outline(flowId, { organization }) to read the published nodes, edges, ordering and human-review marks through Consumer. Compare outline.version with the review flowVersion before displaying progress. This read never consumes an execution result and does not introduce pipelines.
638
+
639
+ ### Frozen review evidence (local HITL pilot)
640
+
641
+ `reviews.get()` optionally returns `documents[].assessments`: the stored node score (0–100), `scoreDescription`, `feedback`, `explanation` and `reasoning` from the same frozen snapshot as the items. These are read-only node-level evidence, not uncertain-field findings. Older backends may omit assessments or scores; do not infer missing scores. Decisions still send only editable item corrections through Consumer.
642
+
643
+ `ReviewTask.findings?: ReviewFinding[]` separately carries explicit field signals:
644
+ stable review-scoped `id`, `code`, `message`, resolved `itemIds`, and optional
645
+ `source` (`model` or `rule`). Consumers must not infer fields from node scores or
646
+ explanation text. Missing or empty findings preserve the existing presentation.
647
+ These are frozen evidence, not per-field decisions; editing a value does not
648
+ erase its finding. Continue using the same global, versioned decision call.
@@ -0,0 +1,317 @@
1
+ import type { HttpClient } from "./http/http-client.js";
2
+ /** Native editor data is lossless: unknown metadata is retained during edits. */
3
+ export type AuthoringData = Record<string, unknown>;
4
+ export interface AuthoringNode extends AuthoringData {
5
+ id: string;
6
+ type: string;
7
+ position: {
8
+ x: number;
9
+ y: number;
10
+ };
11
+ data: AuthoringData & {
12
+ label: string;
13
+ type: string;
14
+ enabled?: boolean;
15
+ };
16
+ parentId?: string;
17
+ }
18
+ export interface AuthoringEdge extends AuthoringData {
19
+ id: string;
20
+ source: string;
21
+ target: string;
22
+ }
23
+ export interface AuthoringRevisions {
24
+ flow: number;
25
+ nodes: Record<string, number>;
26
+ edges: Record<string, number>;
27
+ rules: Record<string, number>;
28
+ }
29
+ export type AuthoringSource = {
30
+ kind: "mongo";
31
+ } | {
32
+ kind: "git";
33
+ formulaId: string;
34
+ repository: string;
35
+ path: string;
36
+ ref: string;
37
+ };
38
+ export interface AuthoringGitPublication {
39
+ source: Extract<AuthoringSource, {
40
+ kind: "git";
41
+ }>;
42
+ commitSha: string;
43
+ publishedVersion: number;
44
+ mongoRevisions: AuthoringRevisions;
45
+ contentHash: string;
46
+ publishedAt: string;
47
+ artifactHash?: string | null;
48
+ toolingHash?: string | null;
49
+ }
50
+ export interface AuthoringGitProjection {
51
+ source: Extract<AuthoringSource, {
52
+ kind: "git";
53
+ }>;
54
+ commitSha: string;
55
+ artifactHash: string;
56
+ toolingHash: string;
57
+ operationId: string;
58
+ mongoRevisions: AuthoringRevisions;
59
+ contentHash: string;
60
+ projectedAt: string;
61
+ }
62
+ export interface AuthoringPublication {
63
+ operationId: string;
64
+ expectedRevisions: AuthoringRevisions;
65
+ gitCommitSha?: string;
66
+ gitArtifactHash?: string;
67
+ gitToolingHash?: string;
68
+ }
69
+ export interface AuthoringFlowSummary extends AuthoringData {
70
+ authoringSource?: AuthoringSource | null;
71
+ lastGitPublication?: AuthoringGitPublication | null;
72
+ lastGitProjection?: AuthoringGitProjection | null;
73
+ createdAt?: string;
74
+ updatedAt?: string;
75
+ executionStats?: {
76
+ totalExecutions: number;
77
+ totalDocuments: number;
78
+ };
79
+ id: string;
80
+ name: string;
81
+ type?: "manual" | "assisted";
82
+ state?: string;
83
+ isDirty?: boolean;
84
+ }
85
+ export interface AuthoringSnapshot {
86
+ gitPublicationState?: {
87
+ status: "not_published" | "unchanged" | "diverged" | "staged";
88
+ currentContentHash: string;
89
+ } | null;
90
+ flow: AuthoringFlowSummary & {
91
+ configs?: AuthoringData;
92
+ nodes: AuthoringNode[];
93
+ edges: AuthoringEdge[];
94
+ };
95
+ rules: AuthoringData[];
96
+ revisions: AuthoringRevisions;
97
+ historyCounts: {
98
+ snapshots: number;
99
+ published: number;
100
+ };
101
+ }
102
+ export interface AuthoringChanges {
103
+ create?: AuthoringData[];
104
+ update?: {
105
+ id: string;
106
+ patch: AuthoringData;
107
+ }[];
108
+ delete?: string[];
109
+ }
110
+ export interface AuthoringDraft {
111
+ gitProjection?: {
112
+ commitSha: string;
113
+ artifactHash: string;
114
+ toolingHash: string;
115
+ };
116
+ authoringSource?: AuthoringSource;
117
+ operationId: string;
118
+ expectedRevisions: AuthoringRevisions;
119
+ flowPatch?: AuthoringData;
120
+ nodes?: AuthoringChanges;
121
+ edges?: AuthoringChanges;
122
+ prompts?: {
123
+ create?: AuthoringData[];
124
+ updateForNode?: string[];
125
+ delete?: string[];
126
+ upsertForNode?: {
127
+ id: string;
128
+ prompt: AuthoringData;
129
+ }[];
130
+ };
131
+ rules?: AuthoringData[];
132
+ }
133
+ export interface AuthoringCreate {
134
+ authoringSource?: AuthoringSource;
135
+ operationId: string;
136
+ id: string;
137
+ name: string;
138
+ type: "manual" | "assisted";
139
+ configs?: AuthoringData;
140
+ nodes: AuthoringNode[];
141
+ edges: AuthoringEdge[];
142
+ }
143
+ export interface AuthoringReceipt {
144
+ success: boolean;
145
+ id?: string;
146
+ version?: number;
147
+ flowUpdatedAt: string;
148
+ revisions: AuthoringRevisions;
149
+ committedRuleIds?: Record<string, string>;
150
+ }
151
+ export interface AuthoringOptions {
152
+ organization: string;
153
+ signal?: AbortSignal;
154
+ }
155
+ export interface AuthoringDocumentTrialNode {
156
+ id: string;
157
+ name: string;
158
+ type: "classification" | "extraction" | "metadata-extraction";
159
+ prompt?: {
160
+ metadata: AuthoringData;
161
+ messages: AuthoringData[];
162
+ schemaDatas: AuthoringData;
163
+ };
164
+ /** Native assisted definition; mutually exclusive with a manual prompt. */
165
+ assisted?: {
166
+ metadata: AuthoringData;
167
+ rules: AuthoringData[];
168
+ configs: AuthoringData;
169
+ };
170
+ }
171
+ export type AuthoringDocumentTrialSpec = {
172
+ flowId: string;
173
+ expectedRevisions: AuthoringRevisions;
174
+ node?: string;
175
+ allNodes?: boolean;
176
+ } | {
177
+ nodes: AuthoringDocumentTrialNode[];
178
+ };
179
+ export interface AuthoringDocumentTrialReport {
180
+ executor?: "flows" | "docmana-api";
181
+ mode: "document-trial";
182
+ execution_scope: "isolated";
183
+ status: "completed" | "error";
184
+ rows: {
185
+ node: string;
186
+ name: string;
187
+ type: string;
188
+ status: "completed" | "error";
189
+ seconds: number;
190
+ output?: AuthoringData;
191
+ error?: string;
192
+ }[];
193
+ }
194
+ export interface AuthoringEditorCatalog {
195
+ capabilities?: {
196
+ canonicalProjection?: number;
197
+ runtimeEnvironment?: string;
198
+ };
199
+ models: {
200
+ default_model: string;
201
+ assisted_model?: string;
202
+ ai_provider: string;
203
+ models: {
204
+ model_name: string;
205
+ reasoning_effort_values?: string[] | null;
206
+ default_reasoning_effort?: string | null;
207
+ }[];
208
+ };
209
+ tools: (AuthoringData & {
210
+ tool_id: string;
211
+ tool_name?: string;
212
+ type?: string;
213
+ short_description_fr?: string;
214
+ short_description_en?: string;
215
+ })[];
216
+ systems: {
217
+ id: string;
218
+ name: string;
219
+ expectedFields?: AuthoringData[];
220
+ }[];
221
+ defaults: {
222
+ aggregator: string;
223
+ };
224
+ flags: {
225
+ flags: Record<string, boolean>;
226
+ };
227
+ }
228
+ export interface AuthoringConversationContext {
229
+ flow_id: string;
230
+ scope?: string | null;
231
+ node_id?: string | null;
232
+ node_label?: string | null;
233
+ }
234
+ export interface AuthoringConversation {
235
+ conversation_id: string;
236
+ expires_at: string;
237
+ context: AuthoringConversationContext;
238
+ }
239
+ export interface AuthoringConversationInput {
240
+ flow_id: string;
241
+ language: "fr" | "en";
242
+ scope?: string;
243
+ node_id?: string;
244
+ messages?: {
245
+ role: "user" | "assistant";
246
+ content: string;
247
+ }[];
248
+ }
249
+ export interface AuthoringConversationTurn {
250
+ assistant_message: string;
251
+ options?: unknown[] | null;
252
+ proposed_rule?: AuthoringData | null;
253
+ proposed_document_type_rename?: AuthoringData | null;
254
+ context: AuthoringConversationContext;
255
+ target_resolved: boolean;
256
+ expires_at: string;
257
+ }
258
+ export type AuthoringSort = "id" | "newest" | "oldest" | "recentlyModified" | "leastRecentlyModified" | "name";
259
+ export interface AuthoringPageOptions extends AuthoringOptions {
260
+ sort?: AuthoringSort;
261
+ offset?: number;
262
+ limit?: number;
263
+ }
264
+ /** Aggregate authoring only. Caller retains operation IDs when retrying mutations. */
265
+ export declare class FormulaAuthoring {
266
+ private readonly http;
267
+ constructor(http: HttpClient);
268
+ /** Read-only, revision-pinned definitions. Assisted execution belongs to the server-side Flows POC. */
269
+ documentTrialDefinitions(spec: {
270
+ flowId: string;
271
+ expectedRevisions: AuthoringRevisions;
272
+ node?: string;
273
+ allNodes?: boolean;
274
+ }, options: AuthoringOptions): Promise<{
275
+ nodes: AuthoringDocumentTrialNode[];
276
+ }>;
277
+ /** Native manual execution through Consumer Edge; assisted trials use definitions plus server-side Flows. */
278
+ trialDocument(file: Blob, filename: string, spec: AuthoringDocumentTrialSpec, options: AuthoringOptions): Promise<AuthoringDocumentTrialReport>;
279
+ editorCatalog(options: AuthoringOptions): Promise<AuthoringEditorCatalog>;
280
+ generateMapping(body: {
281
+ workflow_fields: AuthoringData[];
282
+ expected_fields: AuthoringData[];
283
+ current_mapping: string;
284
+ user_instructions: string;
285
+ }, options: AuthoringOptions): Promise<{
286
+ jsonataExpression: string;
287
+ }>;
288
+ openConversation(body: AuthoringConversationInput, options: AuthoringOptions): Promise<AuthoringConversation>;
289
+ sendConversationMessage(id: string, content: string, options: AuthoringOptions): Promise<AuthoringConversationTurn>;
290
+ confirmConversation(id: string, body: {
291
+ rule_id?: string;
292
+ document_type_rename?: boolean;
293
+ }, options: AuthoringOptions): Promise<{
294
+ expires_at: string;
295
+ }>;
296
+ private request;
297
+ list(options: AuthoringPageOptions): Promise<AuthoringFlowSummary[]>;
298
+ remove(id: string, options: AuthoringOptions): Promise<{
299
+ success: boolean;
300
+ }>;
301
+ exportArchive(id: string, options: AuthoringOptions): Promise<Uint8Array>;
302
+ importArchive(file: Blob, filename: string, options: AuthoringOptions & {
303
+ confirmOverwrite?: boolean;
304
+ }): Promise<{
305
+ status: "imported" | "confirmation_required";
306
+ flowName?: string;
307
+ }>;
308
+ get(id: string, options: AuthoringOptions): Promise<AuthoringSnapshot>;
309
+ create(body: AuthoringCreate, options: AuthoringOptions): Promise<AuthoringReceipt>;
310
+ save(id: string, body: AuthoringDraft, options: AuthoringOptions): Promise<AuthoringReceipt>;
311
+ validate(id: string, revisions: AuthoringRevisions, options: AuthoringOptions): Promise<AuthoringData>;
312
+ publish(id: string, body: AuthoringPublication, options: AuthoringOptions): Promise<AuthoringReceipt>;
313
+ history(id: string, kind: "snapshots" | "published", options: AuthoringPageOptions): Promise<AuthoringData[]>;
314
+ flags(options: AuthoringOptions): Promise<{
315
+ flags: Record<string, boolean>;
316
+ }>;
317
+ }