@calliopelabs/ui 0.7.0 → 0.12.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 (124) hide show
  1. package/README.md +266 -3
  2. package/dist/appearance/AppearancePicker.js +4 -2
  3. package/dist/appearance/AppearanceProvider.d.ts +10 -2
  4. package/dist/appearance/AppearanceProvider.js +6 -2
  5. package/dist/appearance/AppearanceScript.d.ts +15 -4
  6. package/dist/appearance/AppearanceScript.js +11 -5
  7. package/dist/appearance/appearance.js +1 -1
  8. package/dist/appearance/boot.d.ts +13 -2
  9. package/dist/appearance/boot.js +35 -5
  10. package/dist/appearance/product.d.ts +13 -0
  11. package/dist/appearance/product.js +2 -2
  12. package/dist/appearance/runtime-brand.d.ts +106 -0
  13. package/dist/appearance/runtime-brand.js +420 -0
  14. package/dist/css/appearance.js +147 -0
  15. package/dist/css/calliope.css +1221 -0
  16. package/dist/css/components.css +729 -0
  17. package/dist/css/tokens.css +491 -0
  18. package/dist/data/DefinitionList.d.ts +16 -0
  19. package/dist/data/DefinitionList.js +9 -0
  20. package/dist/data/Stat.d.ts +25 -0
  21. package/dist/data/Stat.js +19 -0
  22. package/dist/data/Tag.d.ts +21 -0
  23. package/dist/data/Tag.js +18 -0
  24. package/dist/data/types.d.ts +3 -2
  25. package/dist/data/use-local-table.d.ts +36 -0
  26. package/dist/data/use-local-table.js +127 -0
  27. package/dist/index.d.ts +44 -3
  28. package/dist/index.js +40 -1
  29. package/dist/nav/Nav.d.ts +2 -1
  30. package/dist/nav/Nav.js +34 -15
  31. package/dist/nav/model.d.ts +21 -0
  32. package/dist/page/PageHeader.d.ts +5 -3
  33. package/dist/page/PageHeader.js +5 -4
  34. package/dist/page/Panel.d.ts +19 -0
  35. package/dist/page/Panel.js +12 -0
  36. package/dist/primitives/Avatar.d.ts +37 -0
  37. package/dist/primitives/Avatar.js +43 -0
  38. package/dist/primitives/Field.d.ts +33 -0
  39. package/dist/primitives/Field.js +30 -0
  40. package/dist/primitives/Segmented.d.ts +30 -0
  41. package/dist/primitives/Segmented.js +20 -0
  42. package/dist/primitives/Select.d.ts +40 -0
  43. package/dist/primitives/Select.js +47 -0
  44. package/dist/primitives/Switch.d.ts +7 -0
  45. package/dist/primitives/Switch.js +8 -0
  46. package/dist/primitives/Textarea.d.ts +3 -0
  47. package/dist/primitives/Textarea.js +6 -0
  48. package/dist/provider/messages.d.ts +430 -0
  49. package/dist/provider/messages.js +666 -0
  50. package/dist/shell/BrandMark.d.ts +25 -3
  51. package/dist/shell/BrandMark.js +34 -4
  52. package/dist/shell/RailPanel.js +2 -2
  53. package/dist/shell/RailTree.js +2 -2
  54. package/dist/shell/Sidebar.d.ts +9 -2
  55. package/dist/shell/Sidebar.js +10 -4
  56. package/dist/shell/UserMenu.d.ts +3 -1
  57. package/dist/shell/UserMenu.js +3 -11
  58. package/dist/shell/rail-boot.d.ts +28 -0
  59. package/dist/shell/rail-boot.js +45 -0
  60. package/dist/shell/rail-state.d.ts +6 -1
  61. package/dist/shell/rail-state.js +18 -2
  62. package/dist/styles/preset.css +4 -0
  63. package/dist/styles/theme.css +36 -13
  64. package/dist/theme/css-layer.d.ts +19 -0
  65. package/dist/theme/css-layer.js +171 -0
  66. package/dist/theme/css.d.ts +1 -0
  67. package/dist/theme/css.js +45 -9
  68. package/dist/workflow/ArtifactCard.d.ts +47 -0
  69. package/dist/workflow/ArtifactCard.js +45 -0
  70. package/dist/workflow/DocumentReview.d.ts +74 -0
  71. package/dist/workflow/DocumentReview.js +54 -0
  72. package/dist/workflow/FormReview.d.ts +53 -0
  73. package/dist/workflow/FormReview.js +83 -0
  74. package/dist/workflow/GateBadge.d.ts +11 -0
  75. package/dist/workflow/GateBadge.js +14 -0
  76. package/dist/workflow/MediaReview.d.ts +63 -0
  77. package/dist/workflow/MediaReview.js +166 -0
  78. package/dist/workflow/ReviewPanel.d.ts +41 -0
  79. package/dist/workflow/ReviewPanel.js +59 -0
  80. package/dist/workflow/RunTimeline.d.ts +25 -0
  81. package/dist/workflow/RunTimeline.js +56 -0
  82. package/dist/workflow/WorkflowCard.d.ts +39 -0
  83. package/dist/workflow/WorkflowCard.js +56 -0
  84. package/dist/workflow/WorkflowGallery.d.ts +43 -0
  85. package/dist/workflow/WorkflowGallery.js +69 -0
  86. package/dist/workflow/WorkflowQuestionCard.d.ts +18 -0
  87. package/dist/workflow/WorkflowQuestionCard.js +78 -0
  88. package/dist/workflow/canvas/WorkflowCanvas.d.ts +39 -0
  89. package/dist/workflow/canvas/WorkflowCanvas.js +648 -0
  90. package/dist/workflow/definition.d.ts +408 -0
  91. package/dist/workflow/definition.js +411 -0
  92. package/dist/workflow/editor/WorkflowDiff.d.ts +17 -0
  93. package/dist/workflow/editor/WorkflowDiff.js +25 -0
  94. package/dist/workflow/editor/WorkflowImportPreview.d.ts +19 -0
  95. package/dist/workflow/editor/WorkflowImportPreview.js +50 -0
  96. package/dist/workflow/editor/WorkflowInspector.d.ts +40 -0
  97. package/dist/workflow/editor/WorkflowInspector.js +349 -0
  98. package/dist/workflow/editor/WorkflowJsonView.d.ts +16 -0
  99. package/dist/workflow/editor/WorkflowJsonView.js +40 -0
  100. package/dist/workflow/editor/WorkflowPalette.d.ts +16 -0
  101. package/dist/workflow/editor/WorkflowPalette.js +36 -0
  102. package/dist/workflow/editor/WorkflowProblems.d.ts +20 -0
  103. package/dist/workflow/editor/WorkflowProblems.js +51 -0
  104. package/dist/workflow/editor/WorkflowWorkspace.d.ts +49 -0
  105. package/dist/workflow/editor/WorkflowWorkspace.js +154 -0
  106. package/dist/workflow/gallery.d.ts +21 -0
  107. package/dist/workflow/gallery.js +29 -0
  108. package/dist/workflow/layout.d.ts +49 -0
  109. package/dist/workflow/layout.js +162 -0
  110. package/dist/workflow/model.d.ts +50 -0
  111. package/dist/workflow/model.js +7 -0
  112. package/dist/workflow/palette.d.ts +34 -0
  113. package/dist/workflow/palette.js +70 -0
  114. package/dist/workflow/portable.d.ts +162 -0
  115. package/dist/workflow/portable.js +547 -0
  116. package/dist/workflow/problems.d.ts +38 -0
  117. package/dist/workflow/problems.js +409 -0
  118. package/dist/workflow/question.d.ts +26 -0
  119. package/dist/workflow/question.js +1 -0
  120. package/dist/workflow/run.d.ts +94 -0
  121. package/dist/workflow/run.js +31 -0
  122. package/dist/workflow/workspace.d.ts +33 -0
  123. package/dist/workflow/workspace.js +17 -0
  124. package/package.json +6 -1
@@ -0,0 +1,408 @@
1
+ /**
2
+ * The workflow definition the editor edits: flows of nodes and edges, and the
3
+ * registry the host supplies beside it. Module-neutral: a step is whatever a
4
+ * module's preset says it is, a port carries whatever type the module names,
5
+ * and the run facts, gate kinds and condition operators a definition may use
6
+ * come from the host. Nothing here assumes tickets, repositories or code.
7
+ * Pure: no hooks, no browser APIs.
8
+ */
9
+ import type { WorkflowAvailability, WorkflowModule } from "./model.js";
10
+ /** The definition format this package reads and writes. */
11
+ export declare const WORKFLOW_DEFINITION_VERSION = 1;
12
+ /** Every kind of node a flow is built from. */
13
+ export declare const WORKFLOW_NODE_KINDS: readonly ["step", "subflow", "gate", "condition", "goto", "fanout", "join", "variants", "evaluator", "classifier", "check"];
14
+ export type WorkflowNodeKind = (typeof WORKFLOW_NODE_KINDS)[number];
15
+ /** A choice the host offers in a picker: a role, a member, a model, a harness, an effort. */
16
+ export interface WorkflowOption {
17
+ id: string;
18
+ label: string;
19
+ hint?: string;
20
+ }
21
+ /**
22
+ * A typed port: what a step takes in or gives out. `type` is a data type id
23
+ * the registry names ("video", "contract", "form"); `"any"` takes anything.
24
+ */
25
+ export interface WorkflowPort {
26
+ id: string;
27
+ label: string;
28
+ type: string;
29
+ /** An input the step can run without. */
30
+ optional?: boolean;
31
+ }
32
+ /** A data type a module names. `extends` lets a contract go where a document is wanted. */
33
+ export interface WorkflowDataType {
34
+ id: string;
35
+ label: string;
36
+ extends?: readonly string[];
37
+ }
38
+ /** One building block a module offers: a step with its contract. */
39
+ export interface WorkflowStepPreset {
40
+ /** Unique within its module ("transcode", "redline", "extract-fields"). */
41
+ id: string;
42
+ label: string;
43
+ hint?: string;
44
+ inputs: readonly WorkflowPort[];
45
+ outputs: readonly WorkflowPort[];
46
+ /** Capabilities the destination must have to run it, by display name. */
47
+ capabilities?: readonly string[];
48
+ /** Whether the step takes a model, harness and effort (agent work does; a transcode does not). */
49
+ agent?: boolean;
50
+ }
51
+ /** A module as the registry knows it: its label and version, presets and types. */
52
+ export interface WorkflowModuleSpec extends WorkflowModule {
53
+ presets: readonly WorkflowStepPreset[];
54
+ types?: readonly WorkflowDataType[];
55
+ /** Whether this factory runs the module. Omitted means available. */
56
+ availability?: WorkflowAvailability;
57
+ }
58
+ export type WorkflowFactType = "string" | "number" | "boolean" | "enum";
59
+ /** A run fact a condition or a loop exit can test, as the host names it. */
60
+ export interface WorkflowFact {
61
+ id: string;
62
+ label: string;
63
+ type: WorkflowFactType;
64
+ /** An enum's values. */
65
+ values?: readonly WorkflowOption[];
66
+ /**
67
+ * The fact belongs to a node ("score of", "passed"): the condition names one.
68
+ * `true` takes any node; a list takes only those kinds.
69
+ */
70
+ node?: boolean | readonly WorkflowNodeKind[];
71
+ }
72
+ /** A comparison the host's runtime evaluates. */
73
+ export interface WorkflowOperator {
74
+ id: string;
75
+ label: string;
76
+ /** The fact types it applies to. */
77
+ types: readonly WorkflowFactType[];
78
+ /** Takes no value ("is set", "is empty"). */
79
+ unary?: boolean;
80
+ }
81
+ /** What a gate of some kind is configured with. */
82
+ export type WorkflowGateField = "approvers" | "threshold" | "rule" | "timeout";
83
+ /** A kind of gate the host's runtime knows: people approve, a score clears, a window opens. */
84
+ export interface WorkflowGateKind {
85
+ id: string;
86
+ label: string;
87
+ hint?: string;
88
+ /** The fields the gate needs: `approvers` (roles, members, quorum), a `threshold`, a `rule`, a `timeout`. */
89
+ fields: readonly WorkflowGateField[];
90
+ capabilities?: readonly string[];
91
+ availability?: WorkflowAvailability;
92
+ }
93
+ /**
94
+ * Everything the host tells the editor about where the definition will run:
95
+ * the installed modules and their presets, the run facts, operators and gate
96
+ * kinds the runtime knows, the capabilities present, which node kinds it
97
+ * runs, and the choices its pickers offer. The library ships none of these.
98
+ */
99
+ export interface WorkflowRegistry {
100
+ modules: readonly WorkflowModuleSpec[];
101
+ facts: readonly WorkflowFact[];
102
+ operators: readonly WorkflowOperator[];
103
+ gateKinds: readonly WorkflowGateKind[];
104
+ /** Data types beyond the modules' own. */
105
+ types?: readonly WorkflowDataType[];
106
+ /** Capabilities this destination has. Omitted: capabilities are not checked. */
107
+ capabilities?: readonly string[];
108
+ /** Whether the runtime runs each node kind. Omitted kinds are available. */
109
+ nodeKinds?: Partial<Record<WorkflowNodeKind, WorkflowAvailability>>;
110
+ roles?: readonly WorkflowOption[];
111
+ members?: readonly WorkflowOption[];
112
+ models?: readonly WorkflowOption[];
113
+ harnesses?: readonly WorkflowOption[];
114
+ efforts?: readonly WorkflowOption[];
115
+ }
116
+ export interface WorkflowPosition {
117
+ x: number;
118
+ y: number;
119
+ }
120
+ /** A comparison on a run fact. */
121
+ export interface WorkflowCondition {
122
+ fact: string;
123
+ /** The node the fact belongs to, when the fact is a node's. */
124
+ node?: string;
125
+ op: string;
126
+ value?: string | number | boolean;
127
+ }
128
+ /** Who approves a gate, and how long they have. */
129
+ export interface WorkflowGatePolicy {
130
+ roles?: readonly string[];
131
+ members?: readonly string[];
132
+ /** Approvals needed; one when omitted. */
133
+ quorum?: number;
134
+ timeoutHours?: number;
135
+ onTimeout?: "fail" | "escalate";
136
+ }
137
+ interface NodeBase {
138
+ id: string;
139
+ label: string;
140
+ /** Where it sits on the canvas; laid out when omitted. */
141
+ at?: WorkflowPosition;
142
+ note?: string;
143
+ }
144
+ /** One unit of work: a module's preset, or a custom step with its own ports. */
145
+ export interface WorkflowStepNode extends NodeBase {
146
+ kind: "step";
147
+ /** The preset, by module and id. */
148
+ preset?: {
149
+ module: string;
150
+ id: string;
151
+ };
152
+ /** A custom step's ports; a preset's come from the registry. */
153
+ inputs?: readonly WorkflowPort[];
154
+ outputs?: readonly WorkflowPort[];
155
+ model?: string;
156
+ harness?: string;
157
+ effort?: string;
158
+ }
159
+ /** Runs another flow of the definition in its place, once or once per item. */
160
+ export interface WorkflowSubflowNode extends NodeBase {
161
+ kind: "subflow";
162
+ flow: string;
163
+ /** Runs the flow once per item of this input. */
164
+ each?: string;
165
+ }
166
+ export interface WorkflowGateNode extends NodeBase {
167
+ kind: "gate";
168
+ /** A gate kind id from the registry. */
169
+ gate: string;
170
+ policy?: WorkflowGatePolicy;
171
+ /** Pass at or above, 0 to 1. */
172
+ threshold?: number;
173
+ rule?: string;
174
+ }
175
+ export interface WorkflowCase {
176
+ id: string;
177
+ label: string;
178
+ when: WorkflowCondition;
179
+ }
180
+ /** If or switch on run facts: each case is an exit, then else. */
181
+ export interface WorkflowConditionNode extends NodeBase {
182
+ kind: "condition";
183
+ cases: readonly WorkflowCase[];
184
+ }
185
+ /** Jumps back to a named node, at most `max` times. */
186
+ export interface WorkflowGotoNode extends NodeBase {
187
+ kind: "goto";
188
+ target: string;
189
+ max?: number;
190
+ }
191
+ export interface WorkflowFanoutNode extends NodeBase {
192
+ kind: "fanout";
193
+ }
194
+ export interface WorkflowJoinNode extends NodeBase {
195
+ kind: "join";
196
+ wait: "all" | "any" | "n";
197
+ n?: number;
198
+ }
199
+ export interface WorkflowVariant {
200
+ id: string;
201
+ label: string;
202
+ model?: string;
203
+ harness?: string;
204
+ effort?: string;
205
+ }
206
+ export declare const WORKFLOW_SELECTORS: readonly ["evaluator", "first-passing", "cheapest-passing", "person"];
207
+ export type WorkflowSelector = (typeof WORKFLOW_SELECTORS)[number];
208
+ /** Runs one preset several ways side by side and keeps a winner. */
209
+ export interface WorkflowVariantsNode extends NodeBase {
210
+ kind: "variants";
211
+ preset?: {
212
+ module: string;
213
+ id: string;
214
+ };
215
+ variants: readonly WorkflowVariant[];
216
+ select?: WorkflowSelector;
217
+ /** The evaluator whose score picks, when `select` is `evaluator`. */
218
+ evaluator?: string;
219
+ }
220
+ /** Scores its subject on a rubric; routes on pass and fail when `routes`. */
221
+ export interface WorkflowEvaluatorNode extends NodeBase {
222
+ kind: "evaluator";
223
+ question?: string;
224
+ /** The rubric, lowest level first. */
225
+ levels: readonly string[];
226
+ threshold?: number;
227
+ routes: boolean;
228
+ /** Below this confidence a person decides. */
229
+ minConfidence?: number;
230
+ }
231
+ export interface WorkflowClassifierOption {
232
+ id: string;
233
+ label: string;
234
+ description?: string;
235
+ }
236
+ /** Labels its subject; each label is an exit, with `other` and else. */
237
+ export interface WorkflowClassifierNode extends NodeBase {
238
+ kind: "classifier";
239
+ question?: string;
240
+ options: readonly WorkflowClassifierOption[];
241
+ other: boolean;
242
+ minConfidence?: number;
243
+ }
244
+ /** A yes or no question about its subject, routed on the answer. */
245
+ export interface WorkflowCheckNode extends NodeBase {
246
+ kind: "check";
247
+ question: string;
248
+ /** Yes at or above this probability. */
249
+ threshold: number;
250
+ }
251
+ export type WorkflowNode = WorkflowStepNode | WorkflowSubflowNode | WorkflowGateNode | WorkflowConditionNode | WorkflowGotoNode | WorkflowFanoutNode | WorkflowJoinNode | WorkflowVariantsNode | WorkflowEvaluatorNode | WorkflowClassifierNode | WorkflowCheckNode;
252
+ export type WorkflowNodeOf<K extends WorkflowNodeKind> = Extract<WorkflowNode, {
253
+ kind: K;
254
+ }>;
255
+ /**
256
+ * `next` carries the run on from an exit (`port`, `out` when omitted) to a
257
+ * node. `loop` goes back to an earlier node until `until` holds, at most
258
+ * `max` times. `data` hands an output (`port`) to an input (`input`).
259
+ */
260
+ export interface WorkflowEdge {
261
+ kind: "next" | "loop" | "data";
262
+ from: string;
263
+ to: string;
264
+ port?: string;
265
+ input?: string;
266
+ label?: string;
267
+ max?: number;
268
+ until?: WorkflowCondition;
269
+ }
270
+ export interface WorkflowFlow {
271
+ label?: string;
272
+ /** What the flow starts with: a run's inputs for the main flow, the caller's for a sub-flow. */
273
+ inputs?: readonly WorkflowPort[];
274
+ /** What a sub-flow hands back to its caller. */
275
+ outputs?: readonly WorkflowPort[];
276
+ nodes: readonly WorkflowNode[];
277
+ edges: readonly WorkflowEdge[];
278
+ }
279
+ /** A whole workflow definition: named flows, one of them the main. */
280
+ export interface WorkflowDefinition {
281
+ version: typeof WORKFLOW_DEFINITION_VERSION;
282
+ name: string;
283
+ description?: string;
284
+ /** The module it belongs to, by id. */
285
+ module?: string;
286
+ main: string;
287
+ flows: Readonly<Record<string, WorkflowFlow>>;
288
+ }
289
+ export declare function findPreset(registry: WorkflowRegistry, ref: {
290
+ module: string;
291
+ id: string;
292
+ } | undefined): {
293
+ module: WorkflowModuleSpec;
294
+ preset: WorkflowStepPreset;
295
+ } | null;
296
+ export declare function findFact(registry: WorkflowRegistry, id: string): WorkflowFact | undefined;
297
+ export declare function findGateKind(registry: WorkflowRegistry, id: string): WorkflowGateKind | undefined;
298
+ /** The operators that fit a fact's type. */
299
+ export declare function operatorsFor(registry: WorkflowRegistry, fact: WorkflowFact | undefined): WorkflowOperator[];
300
+ /** Every data type the registry names: the modules' own, then the host's. */
301
+ export declare function dataTypes(registry: WorkflowRegistry): WorkflowDataType[];
302
+ /** Whether a value of type `given` can go where `wanted` is asked for. */
303
+ export declare function typeAccepts(registry: WorkflowRegistry, given: string, wanted: string): boolean;
304
+ /** The judges: nodes that read a subject and route on what they make of it. */
305
+ export type WorkflowJudgeNode = WorkflowEvaluatorNode | WorkflowClassifierNode | WorkflowCheckNode;
306
+ export declare const isJudge: (n: WorkflowNode) => n is WorkflowJudgeNode;
307
+ /**
308
+ * A node's typed inputs: a preset's, a custom step's own, a sub-flow's
309
+ * flow's, and a judge's subject (what it reads; the latest output when unbound).
310
+ */
311
+ export declare function inputsOf(node: WorkflowNode, registry: WorkflowRegistry, definition?: WorkflowDefinition): readonly WorkflowPort[];
312
+ /** A node's typed outputs. Gates, logic and judges pass work on but make nothing. */
313
+ export declare function outputsOf(node: WorkflowNode, registry: WorkflowRegistry, definition?: WorkflowDefinition): readonly WorkflowPort[];
314
+ /** The way on from a node with one exit. */
315
+ export declare const OUT = "out";
316
+ /** The handle a loop leaves from, and the one it comes back into. */
317
+ export declare const LOOP_OUT = "back";
318
+ export declare const LOOP_IN = "back-in";
319
+ /** The handle work comes into. */
320
+ export declare const IN = "in";
321
+ /**
322
+ * The exits a node offers for `next` edges, in order: a condition's cases and
323
+ * else, a check's yes and no, a classifier's labels, other and else, a routing
324
+ * evaluator's pass and fail. A go-to has none: it jumps.
325
+ */
326
+ export declare function exitsOf(node: WorkflowNode): string[];
327
+ /**
328
+ * An exit as the node names it: a case's or a label's own words; the fixed
329
+ * exits (`else`, `yes`, `no`, `other`, `pass`, `fail`, `out`) come back as
330
+ * themselves for the caller's copy to name.
331
+ */
332
+ export declare function exitLabel(node: WorkflowNode, exit: string): string;
333
+ export declare const portOf: (e: WorkflowEdge) => string;
334
+ /** A stable id for an edge: its kind, ends and ports. */
335
+ export declare const edgeId: (e: WorkflowEdge) => string;
336
+ /** Ids reachable from `from` over next edges. */
337
+ export declare function downstream(flow: WorkflowFlow, from: string): Set<string>;
338
+ /** Ids with a path of next edges to `to`. */
339
+ export declare function upstream(flow: WorkflowFlow, to: string): Set<string>;
340
+ /** The node a flow starts at: the first with no next edge coming in. */
341
+ export declare function startOf(flow: WorkflowFlow): string | null;
342
+ /**
343
+ * A drag (or its keyboard equivalent) from a source handle to a target
344
+ * handle. Source handles: an exit, `back` for a loop, `output:<id>` for data.
345
+ * Target handles: `in`, `back-in`, `input:<id>`.
346
+ */
347
+ export interface WorkflowConnection {
348
+ from: string;
349
+ source: string;
350
+ to: string;
351
+ target: string;
352
+ }
353
+ /** Why a connection is refused. The editor's copy names each one. */
354
+ export type WorkflowConnectReason = "missing-node" | "self" | "loop-target" | "loop-not-back" | "loop-exists" | "next-target" | "no-exit" | "exit-taken" | "exists" | "cycle" | "no-output" | "no-input" | "data-target" | "type-mismatch" | "data-order" | "input-taken";
355
+ export type WorkflowConnectResult = {
356
+ ok: true;
357
+ edge: WorkflowEdge;
358
+ } | {
359
+ ok: false;
360
+ reason: WorkflowConnectReason;
361
+ /** What the reason names: the node's label, the exit, the two types. */
362
+ values: Record<string, string>;
363
+ };
364
+ /**
365
+ * Whether a connection makes a legal edge, and the edge when it does. Next
366
+ * edges go from an exit into `in`, one per exit (a fan-out excepted), and
367
+ * never close a cycle. Loops go from `back` into an earlier node's `back-in`.
368
+ * Data goes from an output to an input of a type it fits, on a node that runs
369
+ * after it, one source per input. The canvas only lands what this accepts.
370
+ */
371
+ export declare function canConnect(flow: WorkflowFlow, c: WorkflowConnection, registry: WorkflowRegistry, definition?: WorkflowDefinition): WorkflowConnectResult;
372
+ /** A fresh node id from a label, not taken. */
373
+ export declare function freshId(label: string, taken: Iterable<string>): string;
374
+ /** What the palette adds: a kind, and for a step or variants a preset, for a gate its kind. */
375
+ export interface WorkflowNodeTemplate {
376
+ kind: WorkflowNodeKind;
377
+ preset?: {
378
+ module: string;
379
+ id: string;
380
+ };
381
+ gate?: string;
382
+ /** The label to start with; the kind's or the preset's when omitted. */
383
+ label?: string;
384
+ }
385
+ /**
386
+ * A new node with workable defaults. Labels come from the preset or gate kind
387
+ * when there is one, else from `label` (the caller's copy for the kind).
388
+ */
389
+ export declare function createNode(template: WorkflowNodeTemplate, id: string, registry: WorkflowRegistry, label: string): WorkflowNode;
390
+ /** Adds a node, chained after `after` (or the last node) when an exit there is free. */
391
+ export declare function addNode(flow: WorkflowFlow, node: WorkflowNode, after?: string | null): WorkflowFlow;
392
+ /** Removes a node and every edge touching it; a go-to or a condition pointing at it loses the reference. */
393
+ export declare function removeNode(flow: WorkflowFlow, id: string): WorkflowFlow;
394
+ /** Replaces a node's fields, then drops next edges from exits it no longer has. */
395
+ export declare function updateNode(flow: WorkflowFlow, id: string, patch: Partial<WorkflowNode>): WorkflowFlow;
396
+ /** Moves a node; positions are part of the document. */
397
+ export declare function moveNode(flow: WorkflowFlow, id: string, at: WorkflowPosition): WorkflowFlow;
398
+ export declare function removeEdge(flow: WorkflowFlow, id: string): WorkflowFlow;
399
+ export declare function updateEdge(flow: WorkflowFlow, id: string, patch: Partial<WorkflowEdge>): WorkflowFlow;
400
+ /** The definition with one flow replaced. */
401
+ export declare function withFlow(definition: WorkflowDefinition, name: string, flow: WorkflowFlow): WorkflowDefinition;
402
+ /** What is selected in the editor: a node or an edge (by `edgeId`) of one flow. */
403
+ export interface WorkflowSelection {
404
+ type: "node" | "edge";
405
+ flow: string;
406
+ id: string;
407
+ }
408
+ export {};