@flowdrop/flowdrop 1.15.0 → 2.0.0-beta.10

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 (323) hide show
  1. package/CHANGELOG.md +648 -0
  2. package/MIGRATION-2.0.md +642 -0
  3. package/README.md +28 -28
  4. package/dist/adapters/WorkflowAdapter.d.ts +1 -1
  5. package/dist/adapters/WorkflowAdapter.js +18 -13
  6. package/dist/adapters/agentspec/AgentSpecAdapter.js +10 -10
  7. package/dist/adapters/agentspec/defaultNodeTypes.js +9 -9
  8. package/dist/api/enhanced-client.js +6 -11
  9. package/dist/chat/batchFeedback.d.ts +39 -0
  10. package/dist/chat/batchFeedback.js +51 -0
  11. package/dist/commands/executor.js +66 -27
  12. package/dist/commands/storeIntegration.svelte.d.ts +4 -1
  13. package/dist/commands/storeIntegration.svelte.js +36 -21
  14. package/dist/commands/types.d.ts +2 -0
  15. package/dist/commands/types.js +5 -5
  16. package/dist/components/App.svelte +696 -565
  17. package/dist/components/App.svelte.d.ts +63 -16
  18. package/dist/components/Button.stories.svelte +65 -0
  19. package/dist/components/Button.stories.svelte.d.ts +19 -0
  20. package/dist/components/Button.svelte +62 -0
  21. package/dist/components/Button.svelte.d.ts +24 -0
  22. package/dist/components/CanvasIconButton.svelte +76 -0
  23. package/dist/components/CanvasIconButton.svelte.d.ts +18 -0
  24. package/dist/components/ConfigForm.svelte +181 -552
  25. package/dist/components/ConfigForm.svelte.d.ts +24 -7
  26. package/dist/components/ConfigModal.svelte +16 -3
  27. package/dist/components/ConfigPanel.svelte +234 -15
  28. package/dist/components/ConfigPanel.svelte.d.ts +6 -0
  29. package/dist/components/ConnectionLine.svelte +4 -2
  30. package/dist/components/EditorStatusBar.stories.svelte +44 -0
  31. package/dist/components/EditorStatusBar.stories.svelte.d.ts +27 -0
  32. package/dist/components/EditorStatusBar.svelte +99 -0
  33. package/dist/components/EditorStatusBar.svelte.d.ts +15 -0
  34. package/dist/components/IconButton.svelte +80 -0
  35. package/dist/components/IconButton.svelte.d.ts +30 -0
  36. package/dist/components/Input.svelte +74 -0
  37. package/dist/components/Input.svelte.d.ts +17 -0
  38. package/dist/components/LogoWordmark.svelte +113 -0
  39. package/dist/components/LogoWordmark.svelte.d.ts +26 -0
  40. package/dist/components/Navbar.svelte +78 -64
  41. package/dist/components/Navbar.svelte.d.ts +3 -0
  42. package/dist/components/NodeSidebar.svelte +48 -171
  43. package/dist/components/NodeStatusOverlay.svelte +94 -6
  44. package/dist/components/NodeSwapPicker.svelte +22 -38
  45. package/dist/components/PipelineStatus.svelte +22 -68
  46. package/dist/components/PipelineStatus.svelte.d.ts +3 -0
  47. package/dist/components/PortCoordinateTracker.svelte +5 -6
  48. package/dist/components/PortMappingRow.svelte +0 -2
  49. package/dist/components/SchemaForm.stories.svelte +1 -3
  50. package/dist/components/SchemaForm.svelte +22 -39
  51. package/dist/components/SchemaForm.svelte.d.ts +0 -8
  52. package/dist/components/Select.svelte +53 -0
  53. package/dist/components/Select.svelte.d.ts +15 -0
  54. package/dist/components/SettingsModal.svelte +8 -8
  55. package/dist/components/SettingsPanel.svelte +44 -10
  56. package/dist/components/SwapMappingEditor.svelte +67 -49
  57. package/dist/components/SwapMappingEditor.svelte.d.ts +0 -2
  58. package/dist/components/Textarea.svelte +39 -0
  59. package/dist/components/Textarea.svelte.d.ts +12 -0
  60. package/dist/components/ThemeToggle.svelte +15 -94
  61. package/dist/components/UniversalNode.svelte +45 -11
  62. package/dist/components/UniversalNode.svelte.d.ts +1 -1
  63. package/dist/components/WorkflowEditor.svelte +183 -162
  64. package/dist/components/WorkflowEditor.svelte.d.ts +39 -10
  65. package/dist/components/chat/AIChatPanel.svelte +99 -90
  66. package/dist/components/chat/AIChatPanel.svelte.d.ts +0 -4
  67. package/dist/components/chat/CommandPreview.svelte +2 -1
  68. package/dist/components/console/CommandConsole.svelte +7 -5
  69. package/dist/components/console/ConsoleAutocomplete.svelte +11 -12
  70. package/dist/components/console/ConsoleAutocomplete.svelte.d.ts +6 -0
  71. package/dist/components/console/ConsoleInput.svelte +18 -9
  72. package/dist/components/console/ConsoleOutput.svelte +4 -3
  73. package/dist/components/form/FormArray.svelte +42 -182
  74. package/dist/components/form/FormArray.svelte.d.ts +2 -1
  75. package/dist/components/form/FormAutocomplete.svelte +26 -21
  76. package/dist/components/form/FormCheckboxGroup.svelte +1 -5
  77. package/dist/components/form/FormCodeEditor.svelte +9 -7
  78. package/dist/components/form/FormField.svelte +22 -44
  79. package/dist/components/form/FormFieldLight.svelte +56 -50
  80. package/dist/components/form/FormFieldLight.svelte.d.ts +12 -0
  81. package/dist/components/form/FormFieldset.svelte +45 -11
  82. package/dist/components/form/FormMarkdownEditor.svelte +17 -9
  83. package/dist/components/form/FormNumberField.svelte +4 -36
  84. package/dist/components/form/FormPorts.svelte +262 -0
  85. package/dist/components/form/FormPorts.svelte.d.ts +13 -0
  86. package/dist/components/form/FormRangeField.svelte +62 -30
  87. package/dist/components/form/FormSelect.svelte +13 -75
  88. package/dist/components/form/FormTemplateEditor.svelte +17 -7
  89. package/dist/components/form/FormTextField.svelte +3 -35
  90. package/dist/components/form/FormTextarea.svelte +4 -39
  91. package/dist/components/form/FormToggle.svelte +5 -16
  92. package/dist/components/form/FormToggle.svelte.d.ts +4 -2
  93. package/dist/components/form/FormUISchemaRenderer.svelte +3 -1
  94. package/dist/components/form/resolveFieldType.d.ts +24 -0
  95. package/dist/components/form/resolveFieldType.js +55 -0
  96. package/dist/components/form/templateAutocomplete.js +1 -5
  97. package/dist/components/form/types.d.ts +1 -14
  98. package/dist/components/icons/CloseIcon.svelte +6 -0
  99. package/dist/components/icons/CloseIcon.svelte.d.ts +26 -0
  100. package/dist/components/icons/CommandLineIcon.svelte +15 -0
  101. package/dist/components/icons/CommandLineIcon.svelte.d.ts +26 -0
  102. package/dist/components/icons/MenuIcon.svelte +4 -0
  103. package/dist/components/icons/MenuIcon.svelte.d.ts +26 -0
  104. package/dist/components/icons/MenuOpenIcon.svelte +6 -0
  105. package/dist/components/icons/MenuOpenIcon.svelte.d.ts +26 -0
  106. package/dist/components/interrupt/ChoicePrompt.svelte +0 -10
  107. package/dist/components/interrupt/ConfirmationPrompt.svelte +0 -5
  108. package/dist/components/interrupt/FormPrompt.svelte +3 -2
  109. package/dist/components/interrupt/InterruptBubble.svelte +25 -27
  110. package/dist/components/interrupt/ReviewPrompt.svelte +10 -23
  111. package/dist/components/interrupt/TextInputPrompt.svelte +2 -7
  112. package/dist/components/layouts/MainLayout.svelte +24 -18
  113. package/dist/components/layouts/MainLayout.svelte.d.ts +4 -0
  114. package/dist/components/nodes/AtomNode.svelte +70 -72
  115. package/dist/components/nodes/AtomNode.svelte.d.ts +1 -1
  116. package/dist/components/nodes/GatewayNode.svelte +134 -172
  117. package/dist/components/nodes/GatewayNode.svelte.d.ts +1 -1
  118. package/dist/components/nodes/IdeaNode.svelte +79 -98
  119. package/dist/components/nodes/IdeaNode.svelte.d.ts +8 -4
  120. package/dist/components/nodes/NodeConfigButton.svelte +86 -0
  121. package/dist/components/nodes/NodeConfigButton.svelte.d.ts +15 -0
  122. package/dist/components/nodes/NotesNode.svelte +76 -85
  123. package/dist/components/nodes/NotesNode.svelte.d.ts +8 -4
  124. package/dist/components/nodes/SimpleNode.svelte +68 -137
  125. package/dist/components/nodes/SimpleNode.svelte.d.ts +4 -4
  126. package/dist/components/nodes/SquareNode.svelte +122 -169
  127. package/dist/components/nodes/SquareNode.svelte.d.ts +4 -4
  128. package/dist/components/nodes/TerminalNode.svelte +70 -127
  129. package/dist/components/nodes/TerminalNode.svelte.d.ts +4 -4
  130. package/dist/components/nodes/ToolNode.svelte +99 -104
  131. package/dist/components/nodes/ToolNode.svelte.d.ts +6 -6
  132. package/dist/components/nodes/WorkflowNode.svelte +145 -195
  133. package/dist/components/nodes/WorkflowNode.svelte.d.ts +1 -1
  134. package/dist/components/playground/ChatInput.svelte +11 -15
  135. package/dist/components/playground/ChatPanel.svelte +6 -49
  136. package/dist/components/playground/ChatPanel.svelte.d.ts +0 -14
  137. package/dist/components/playground/ControlPanel.svelte +134 -123
  138. package/dist/components/playground/ControlPanel.svelte.d.ts +3 -0
  139. package/dist/components/playground/ExecutionLogs.svelte +11 -9
  140. package/dist/components/playground/InputCollector.svelte +22 -57
  141. package/dist/components/playground/MessageStream.svelte +17 -23
  142. package/dist/components/playground/PipelineKanbanView.svelte +69 -8
  143. package/dist/components/playground/PipelineKanbanView.svelte.d.ts +2 -0
  144. package/dist/components/playground/PipelinePanel.svelte +31 -8
  145. package/dist/components/playground/PipelinePanel.svelte.d.ts +2 -0
  146. package/dist/components/playground/PipelineTableView.svelte +188 -44
  147. package/dist/components/playground/PipelineTableView.svelte.d.ts +2 -0
  148. package/dist/components/playground/Playground.svelte +154 -105
  149. package/dist/components/playground/Playground.svelte.d.ts +5 -0
  150. package/dist/components/playground/PlaygroundApp.svelte +12 -2
  151. package/dist/components/playground/PlaygroundApp.svelte.d.ts +6 -0
  152. package/dist/components/playground/PlaygroundModal.svelte +18 -3
  153. package/dist/components/playground/PlaygroundModal.svelte.d.ts +6 -0
  154. package/dist/components/playground/PlaygroundStudio.svelte +40 -37
  155. package/dist/components/playground/PlaygroundStudio.svelte.d.ts +6 -0
  156. package/dist/components/playground/SessionManager.svelte +9 -12
  157. package/dist/components/playground/pipelineViewUtils.svelte.d.ts +30 -1
  158. package/dist/components/playground/pipelineViewUtils.svelte.js +40 -3
  159. package/dist/components/surfaces/SurfaceOverlay.svelte +153 -0
  160. package/dist/components/surfaces/SurfaceOverlay.svelte.d.ts +14 -0
  161. package/dist/components/surfaces/TabbedSurface.svelte +133 -0
  162. package/dist/components/surfaces/TabbedSurface.svelte.d.ts +27 -0
  163. package/dist/config/endpoints.d.ts +23 -7
  164. package/dist/config/endpoints.js +30 -10
  165. package/dist/core/index.d.ts +6 -7
  166. package/dist/core/index.js +8 -12
  167. package/dist/display/index.d.ts +6 -3
  168. package/dist/display/index.js +7 -5
  169. package/dist/editor/index.d.ts +20 -21
  170. package/dist/editor/index.js +26 -36
  171. package/dist/form/code.d.ts +25 -15
  172. package/dist/form/code.js +44 -41
  173. package/dist/form/fieldRegistry.d.ts +17 -13
  174. package/dist/form/fieldRegistry.js +32 -12
  175. package/dist/form/full.d.ts +19 -14
  176. package/dist/form/full.js +26 -28
  177. package/dist/form/index.d.ts +3 -4
  178. package/dist/form/index.js +6 -5
  179. package/dist/form/markdown.d.ts +13 -8
  180. package/dist/form/markdown.js +22 -23
  181. package/dist/helpers/proximityConnect.d.ts +3 -2
  182. package/dist/helpers/proximityConnect.js +2 -5
  183. package/dist/helpers/workflowEditorHelper.d.ts +14 -5
  184. package/dist/helpers/workflowEditorHelper.js +32 -30
  185. package/dist/index.d.ts +28 -24
  186. package/dist/index.js +27 -50
  187. package/dist/messages/defaults.d.ts +2 -5
  188. package/dist/messages/defaults.js +3 -6
  189. package/dist/messages/index.d.ts +1 -2
  190. package/dist/messages/index.js +1 -2
  191. package/dist/mocks/app-forms.d.ts +6 -2
  192. package/dist/mocks/app-forms.js +11 -4
  193. package/dist/openapi/v1/openapi.yaml +38 -26
  194. package/dist/playground/index.d.ts +4 -5
  195. package/dist/playground/index.js +4 -32
  196. package/dist/playground/mount.d.ts +34 -5
  197. package/dist/playground/mount.js +58 -24
  198. package/dist/registry/{BaseRegistry.d.ts → BaseRegistry.svelte.d.ts} +22 -1
  199. package/dist/registry/{BaseRegistry.js → BaseRegistry.svelte.js} +37 -1
  200. package/dist/registry/builtinFormats.d.ts +9 -18
  201. package/dist/registry/builtinFormats.js +9 -39
  202. package/dist/registry/builtinNodeTypes.d.ts +53 -0
  203. package/dist/registry/builtinNodeTypes.js +67 -0
  204. package/dist/registry/builtinNodes.d.ts +2 -64
  205. package/dist/registry/builtinNodes.js +7 -103
  206. package/dist/registry/index.d.ts +3 -4
  207. package/dist/registry/index.js +4 -6
  208. package/dist/registry/nodeComponentRegistry.d.ts +184 -16
  209. package/dist/registry/nodeComponentRegistry.js +235 -17
  210. package/dist/registry/workflowFormatRegistry.d.ts +14 -9
  211. package/dist/registry/workflowFormatRegistry.js +24 -8
  212. package/dist/{schema → schemas}/index.d.ts +2 -2
  213. package/dist/{schema → schemas}/index.js +2 -2
  214. package/dist/schemas/v1/workflow.schema.json +19 -17
  215. package/dist/services/agentSpecExecutionService.d.ts +0 -2
  216. package/dist/services/agentSpecExecutionService.js +0 -3
  217. package/dist/services/apiVariableService.d.ts +2 -1
  218. package/dist/services/apiVariableService.js +16 -47
  219. package/dist/services/autoSaveService.d.ts +7 -0
  220. package/dist/services/autoSaveService.js +6 -4
  221. package/dist/services/categoriesApi.js +3 -6
  222. package/dist/services/chatService.d.ts +9 -4
  223. package/dist/services/chatService.js +23 -28
  224. package/dist/services/draftStorage.d.ts +129 -13
  225. package/dist/services/draftStorage.js +185 -37
  226. package/dist/services/dynamicSchemaService.d.ts +33 -5
  227. package/dist/services/dynamicSchemaService.js +67 -55
  228. package/dist/services/globalSave.d.ts +13 -12
  229. package/dist/services/globalSave.js +29 -51
  230. package/dist/services/historyService.d.ts +39 -11
  231. package/dist/services/historyService.js +60 -18
  232. package/dist/services/interruptService.d.ts +15 -9
  233. package/dist/services/interruptService.js +35 -37
  234. package/dist/services/nodeExecutionService.d.ts +18 -3
  235. package/dist/services/nodeExecutionService.js +71 -45
  236. package/dist/services/playgroundService.d.ts +16 -10
  237. package/dist/services/playgroundService.js +42 -43
  238. package/dist/services/portConfigApi.js +3 -6
  239. package/dist/services/settingsService.d.ts +9 -4
  240. package/dist/services/settingsService.js +23 -12
  241. package/dist/services/variableService.d.ts +2 -1
  242. package/dist/services/variableService.js +2 -2
  243. package/dist/services/workflowStorage.js +6 -6
  244. package/dist/skins/drafter.d.ts +30 -0
  245. package/dist/skins/drafter.js +198 -0
  246. package/dist/skins/index.d.ts +2 -1
  247. package/dist/skins/index.js +4 -2
  248. package/dist/stores/apiContext.d.ts +56 -0
  249. package/dist/stores/apiContext.js +80 -0
  250. package/dist/stores/categoriesStore.svelte.d.ts +28 -23
  251. package/dist/stores/categoriesStore.svelte.js +69 -64
  252. package/dist/stores/getInstance.svelte.d.ts +39 -0
  253. package/dist/stores/getInstance.svelte.js +65 -0
  254. package/dist/stores/historyStore.svelte.d.ts +89 -91
  255. package/dist/stores/historyStore.svelte.js +159 -158
  256. package/dist/stores/instanceContainer.svelte.d.ts +111 -0
  257. package/dist/stores/instanceContainer.svelte.js +119 -0
  258. package/dist/stores/interruptStore.svelte.d.ts +112 -82
  259. package/dist/stores/interruptStore.svelte.js +253 -226
  260. package/dist/stores/pipelinePanelStore.svelte.d.ts +27 -3
  261. package/dist/stores/pipelinePanelStore.svelte.js +61 -14
  262. package/dist/stores/playgroundStore.svelte.d.ts +169 -222
  263. package/dist/stores/playgroundStore.svelte.js +513 -580
  264. package/dist/stores/portCoordinateStore.svelte.d.ts +57 -51
  265. package/dist/stores/portCoordinateStore.svelte.js +109 -98
  266. package/dist/stores/settingsStore.svelte.d.ts +17 -1
  267. package/dist/stores/settingsStore.svelte.js +79 -12
  268. package/dist/stores/workflowStore.svelte.d.ts +212 -210
  269. package/dist/stores/workflowStore.svelte.js +527 -502
  270. package/dist/stories/EdgeDecorator.svelte +5 -2
  271. package/dist/stories/NodeDecorator.svelte +5 -3
  272. package/dist/styles/base.css +285 -14
  273. package/dist/styles/tokens.css +60 -2
  274. package/dist/svelte-app.d.ts +78 -11
  275. package/dist/svelte-app.js +210 -141
  276. package/dist/themes/drafter.d.ts +2 -0
  277. package/dist/themes/drafter.js +15 -0
  278. package/dist/themes/index.d.ts +2 -1
  279. package/dist/themes/index.js +8 -2
  280. package/dist/types/auth.d.ts +9 -51
  281. package/dist/types/auth.js +4 -54
  282. package/dist/types/events.d.ts +24 -3
  283. package/dist/types/events.js +2 -1
  284. package/dist/types/index.d.ts +117 -32
  285. package/dist/types/index.js +0 -1
  286. package/dist/types/navbar.d.ts +7 -0
  287. package/dist/types/playground.d.ts +18 -3
  288. package/dist/types/settings.d.ts +30 -1
  289. package/dist/types/settings.js +5 -2
  290. package/dist/types/skin.d.ts +1 -1
  291. package/dist/types/theme.d.ts +16 -2
  292. package/dist/types/uischema.d.ts +5 -0
  293. package/dist/utils/colors.d.ts +74 -21
  294. package/dist/utils/colors.js +92 -68
  295. package/dist/utils/connections.d.ts +9 -15
  296. package/dist/utils/connections.js +33 -88
  297. package/dist/utils/duration.d.ts +13 -0
  298. package/dist/utils/duration.js +45 -0
  299. package/dist/utils/edgeStyling.js +9 -5
  300. package/dist/utils/fetchWithAuth.d.ts +36 -15
  301. package/dist/utils/fetchWithAuth.js +53 -23
  302. package/dist/utils/icons.d.ts +5 -2
  303. package/dist/utils/icons.js +6 -5
  304. package/dist/utils/nodeIds.d.ts +1 -1
  305. package/dist/utils/nodeIds.js +1 -1
  306. package/dist/utils/nodeSwap.d.ts +6 -2
  307. package/dist/utils/nodeSwap.js +62 -129
  308. package/dist/utils/nodeTypes.d.ts +17 -8
  309. package/dist/utils/nodeTypes.js +27 -20
  310. package/dist/utils/performanceUtils.js +7 -0
  311. package/dist/utils/portUtils.d.ts +47 -11
  312. package/dist/utils/portUtils.js +67 -14
  313. package/dist/utils/portal.d.ts +18 -0
  314. package/dist/utils/portal.js +34 -0
  315. package/dist/utils/schemaMerge.d.ts +25 -0
  316. package/dist/utils/schemaMerge.js +61 -0
  317. package/package.json +7 -5
  318. package/dist/messages/deprecation.d.ts +0 -20
  319. package/dist/messages/deprecation.js +0 -33
  320. package/dist/registry/plugin.d.ts +0 -215
  321. package/dist/registry/plugin.js +0 -249
  322. package/dist/services/api.d.ts +0 -129
  323. package/dist/services/api.js +0 -217
@@ -1,290 +1,292 @@
1
1
  /**
2
2
  * Workflow Store for FlowDrop (Svelte 5 Runes)
3
3
  *
4
- * Provides global state management for workflows with dirty state tracking
5
- * and undo/redo history integration.
4
+ * Provides per-instance state management for workflows with dirty state
5
+ * tracking and undo/redo history integration.
6
6
  *
7
- * **Important: Single-instance only.** This store uses module-level singletons.
8
- * Only one FlowDrop editor instance per page is supported. Mounting multiple
9
- * FlowDrop editors on the same page will cause them to share workflow state.
7
+ * The reactive state lives in the {@link WorkflowStore} class — one per
8
+ * FlowDrop instance, created by `createFlowDropInstance()` and resolved in
9
+ * components via `getInstance().workflow`.
10
10
  *
11
11
  * @module stores/workflowStore
12
12
  */
13
13
  import type { Workflow, WorkflowNode, WorkflowEdge } from '../types';
14
14
  import type { WorkflowChangeType } from '../types/events.js';
15
- type WorkflowMetadata = NonNullable<Workflow['metadata']>;
15
+ import type { HistoryService } from '../services/historyService.js';
16
+ type WorkflowMetadata = Workflow['metadata'];
16
17
  /**
17
- * Get the current workflow store value reactively
18
- *
19
- * @returns The current workflow or null
20
- */
21
- export declare function getWorkflowStore(): Workflow | null;
22
- /**
23
- * Get the current dirty state reactively
24
- *
25
- * Reads both _editVersion and _savedVersion, so Svelte tracks them
26
- * as reactive dependencies — any component using this will re-render
27
- * when dirty state changes.
28
- *
29
- * @returns true if there are unsaved changes
30
- */
31
- export declare function getIsDirty(): boolean;
32
- /**
33
- * Get the workflow ID reactively
34
- *
35
- * @returns The workflow ID or null
36
- */
37
- export declare function getWorkflowId(): string | null;
38
- /**
39
- * Get the workflow name reactively
40
- *
41
- * @returns The workflow name or 'Untitled Workflow'
42
- */
43
- export declare function getWorkflowName(): string;
44
- /**
45
- * Get the workflow nodes reactively
46
- *
47
- * @returns Array of workflow nodes
48
- */
49
- export declare function getWorkflowNodes(): WorkflowNode[];
50
- /**
51
- * Get the workflow edges reactively
52
- *
53
- * @returns Array of workflow edges
54
- */
55
- export declare function getWorkflowEdges(): WorkflowEdge[];
56
- /**
57
- * Get the workflow metadata reactively
58
- *
59
- * @returns The workflow metadata with defaults
60
- */
61
- export declare function getWorkflowMetadata(): WorkflowMetadata;
62
- /**
63
- * Get the current workflow format reactively
64
- *
65
- * @returns The workflow format string
66
- */
67
- export declare function getWorkflowFormat(): string;
68
- /**
69
- * Get workflow change summary reactively (useful for triggering saves)
70
- *
71
- * @returns Object with nodes, edges, and name
72
- */
73
- export declare function getWorkflowChanged(): {
74
- nodes: WorkflowNode[];
75
- edges: WorkflowEdge[];
76
- name: string;
77
- };
78
- /**
79
- * Get workflow validation state reactively
80
- *
81
- * @returns Validation info object
82
- */
83
- export declare function getWorkflowValidation(): {
84
- hasNodes: boolean;
85
- hasEdges: boolean;
86
- nodeCount: number;
87
- edgeCount: number;
88
- isValid: boolean;
89
- };
90
- /**
91
- * Get workflow metadata change summary reactively
92
- *
93
- * @returns Metadata change info
18
+ * Loosely-typed shape a workflow may arrive in before healing — a 1.x document
19
+ * may have no `metadata`, or metadata carrying the legacy `version` key instead
20
+ * of `schemaVersion`.
94
21
  */
95
- export declare function getWorkflowMetadataChanged(): {
96
- createdAt: string;
97
- updatedAt: string;
98
- version: string;
22
+ type LegacyWorkflow = Omit<Workflow, 'metadata'> & {
23
+ metadata?: (Partial<WorkflowMetadata> & {
24
+ version?: string;
25
+ }) | null;
99
26
  };
100
27
  /**
101
- * Get connected handles reactively
102
- *
103
- * Provides a Set of all handle IDs that are currently connected to edges.
104
- * Used by node components to implement hideUnconnectedHandles functionality.
105
- *
106
- * @example
107
- * ```typescript
108
- * import { getConnectedHandles } from './workflowStore.svelte.js';
28
+ * Normalize workflow metadata at load time (the only back-compat path we keep,
29
+ * mirroring the storage-key migration in commit 8fab9157).
109
30
  *
110
- * // Check if a specific handle is connected
111
- * const isConnected = getConnectedHandles().has('node-1-input-data');
112
- * ```
113
- */
114
- export declare function getConnectedHandles(): Set<string>;
115
- /**
116
- * Set the dirty state change callback
31
+ * Rules:
32
+ * - missing `metadata` → `buildMetadata(undefined)` (fresh required defaults)
33
+ * - legacy `version` key present → copied to `schemaVersion` when absent, then
34
+ * the legacy key is dropped
117
35
  *
118
- * @param callback - Function to call when dirty state changes
36
+ * Idempotent: re-running on an already-healed workflow returns equivalent
37
+ * metadata (round-trip stable).
119
38
  */
120
- export declare function setOnDirtyStateChange(callback: ((isDirty: boolean) => void) | null): void;
39
+ export declare function normalizeWorkflowMetadata(workflow: LegacyWorkflow): Workflow;
121
40
  /**
122
- * Set the workflow change callback
41
+ * Mutation actions for a {@link WorkflowStore}.
123
42
  *
124
- * @param callback - Function to call when workflow changes
43
+ * Bound facade — safe to detach (`onclick={fd.workflow.actions.undo}`)
44
+ * because every entry is bound to its store in the constructor.
125
45
  */
126
- export declare function setOnWorkflowChange(callback: ((workflow: Workflow, changeType: WorkflowChangeType) => void) | null): void;
127
- /**
128
- * Mark the current workflow state as saved.
129
- *
130
- * Captures the current edit version so isDirty becomes false.
131
- * Call this after a successful backend save.
132
- */
133
- export declare function markAsSaved(): void;
134
- /**
135
- * Check if there are unsaved changes (non-reactive version for plain TS)
136
- *
137
- * @returns true if there are unsaved changes
138
- */
139
- export declare function isDirty(): boolean;
140
- /**
141
- * Get the current edit version.
142
- *
143
- * Use this for the save verification protocol:
144
- * 1. Before save: `const v = getEditVersion()`
145
- * 2. Include `v` in the save request payload
146
- * 3. Backend echoes `v` in the response
147
- * 4. If echoed version matches: `markAsSaved()`
148
- * 5. If not: the save didn't persist the version you submitted — reset from backend response
149
- *
150
- * @returns The current monotonic edit version
151
- */
152
- export declare function getEditVersion(): number;
153
- /**
154
- * Enable or disable history recording
155
- *
156
- * Useful for bulk operations where you don't want individual history entries.
157
- *
158
- * @param enabled - Whether history should be recorded
159
- */
160
- export declare function setHistoryEnabled(enabled: boolean): void;
161
- /**
162
- * Check if history recording is enabled
163
- *
164
- * @returns true if history is being recorded
165
- */
166
- export declare function isHistoryEnabled(): boolean;
167
- /**
168
- * Set the restoring from history flag
169
- *
170
- * Used internally by the history store when performing undo/redo.
171
- *
172
- * @param restoring - Whether we're currently restoring from history
173
- */
174
- export declare function setRestoringFromHistory(restoring: boolean): void;
175
- /**
176
- * Get the current workflow (non-reactive version for plain TS)
177
- *
178
- * @returns The current workflow or null
179
- */
180
- export declare function getWorkflow(): Workflow | null;
46
+ export interface WorkflowStoreActions {
47
+ initialize: (workflow: Workflow) => void;
48
+ updateWorkflow: (workflow: Workflow) => void;
49
+ restoreFromHistory: (workflow: Workflow) => void;
50
+ updateNodes: (nodes: WorkflowNode[]) => void;
51
+ updateEdges: (edges: WorkflowEdge[]) => void;
52
+ updateName: (name: string) => void;
53
+ addNode: (node: WorkflowNode) => void;
54
+ removeNode: (nodeId: string) => void;
55
+ addEdge: (edge: WorkflowEdge) => void;
56
+ removeEdge: (edgeId: string) => void;
57
+ updateNode: (nodeId: string, updates: Partial<WorkflowNode>) => void;
58
+ updateNodeConfig: (nodeId: string, updates: Partial<WorkflowNode>, opts?: {
59
+ fieldKey?: string;
60
+ }) => void;
61
+ finalizeNodeConfig: (changeType?: WorkflowChangeType) => void;
62
+ clear: () => void;
63
+ updateMetadata: (metadata: Partial<Workflow['metadata']>) => void;
64
+ batchUpdate: (updates: {
65
+ nodes?: WorkflowNode[];
66
+ edges?: WorkflowEdge[];
67
+ name?: string;
68
+ description?: string;
69
+ metadata?: Partial<Workflow['metadata']>;
70
+ config?: Record<string, unknown>;
71
+ }) => void;
72
+ swapNode: (updates: {
73
+ nodes: WorkflowNode[];
74
+ edges: WorkflowEdge[];
75
+ description?: string;
76
+ }) => void;
77
+ pushHistory: (description?: string, workflow?: Workflow) => void;
78
+ }
181
79
  /**
182
- * Actions for updating the workflow
80
+ * Per-instance workflow state with dirty tracking and history integration.
183
81
  *
184
- * All actions that modify the workflow will trigger dirty state updates
185
- * and emit change events.
82
+ * All reads go through getters backed by `$state`, so reading them inside a
83
+ * component template or `$derived` tracks reactively, exactly like the
84
+ * legacy module-level functions did.
186
85
  */
187
- export declare const workflowActions: {
86
+ export declare class WorkflowStore {
87
+ #private;
88
+ /** Bound mutation facade — see {@link WorkflowStoreActions}. */
89
+ readonly actions: WorkflowStoreActions;
90
+ constructor(history: HistoryService);
91
+ /** The current workflow, or null when none is loaded. */
92
+ get current(): Workflow | null;
188
93
  /**
189
- * Initialize workflow (from load or new)
94
+ * Whether there are unsaved changes.
190
95
  *
191
- * This sets the initial saved snapshot, clears dirty state, and initializes history.
96
+ * Reads both #editVersion and #savedVersion, so Svelte tracks them as
97
+ * reactive dependencies — any component using this re-renders when dirty
98
+ * state changes.
192
99
  */
193
- initialize: (workflow: Workflow) => void;
100
+ get isDirty(): boolean;
101
+ /** The workflow ID, or null. */
102
+ get id(): string | null;
103
+ /** The workflow name, or 'Untitled Workflow'. */
104
+ get name(): string;
105
+ /** The workflow nodes. */
106
+ get nodes(): WorkflowNode[];
107
+ /** The workflow edges. */
108
+ get edges(): WorkflowEdge[];
109
+ /** The workflow metadata, with defaults. */
110
+ get metadata(): WorkflowMetadata;
111
+ /** The workflow format string. */
112
+ get format(): string;
113
+ /** Workflow change summary (useful for triggering saves). */
114
+ get changeSummary(): {
115
+ nodes: WorkflowNode[];
116
+ edges: WorkflowEdge[];
117
+ name: string;
118
+ };
119
+ /** Workflow validation state. */
120
+ get validation(): {
121
+ hasNodes: boolean;
122
+ hasEdges: boolean;
123
+ nodeCount: number;
124
+ edgeCount: number;
125
+ isValid: boolean;
126
+ };
127
+ /** Workflow metadata change summary. */
128
+ get metadataChangeSummary(): {
129
+ createdAt: string;
130
+ updatedAt: string;
131
+ schemaVersion: string;
132
+ };
194
133
  /**
195
- * Update the entire workflow
134
+ * Set of all handle IDs currently connected to edges.
196
135
  *
197
- * Note: This is typically called from SvelteFlow sync and should not push to history
198
- * for every small change. History is pushed by specific actions or drag handlers.
136
+ * Handle IDs are formatted `{nodeId}-{direction}-{portId}`.
199
137
  */
200
- updateWorkflow: (workflow: Workflow) => void;
138
+ get connectedHandles(): Set<string>;
201
139
  /**
202
- * Restore workflow from history (undo/redo)
140
+ * The current monotonic edit version.
203
141
  *
204
- * This bypasses history recording to prevent recursive loops.
142
+ * Use this for the save verification protocol:
143
+ * 1. Before save: `const v = store.editVersion`
144
+ * 2. Include `v` in the save request payload
145
+ * 3. Backend echoes `v` in the response
146
+ * 4. If echoed version matches: `store.markAsSaved()`
147
+ * 5. If not: the save didn't persist the version you submitted — reset from backend response
205
148
  */
206
- restoreFromHistory: (workflow: Workflow) => void;
149
+ get editVersion(): number;
150
+ /** Whether history recording is enabled. */
151
+ get historyEnabled(): boolean;
152
+ /** Enable or disable history recording (e.g. for bulk operations). */
153
+ set historyEnabled(enabled: boolean);
154
+ /** Set the dirty state change callback. */
155
+ setOnDirtyStateChange(callback: ((isDirty: boolean) => void) | null): void;
156
+ /** Set the workflow change callback. */
157
+ setOnWorkflowChange(callback: ((workflow: Workflow, changeType: WorkflowChangeType) => void) | null): void;
207
158
  /**
208
- * Update nodes
159
+ * Mark the current workflow state as saved.
160
+ *
161
+ * Captures the current edit version so isDirty becomes false.
162
+ * Call this after a successful backend save.
209
163
  */
210
- updateNodes: (nodes: WorkflowNode[]) => void;
164
+ markAsSaved(): void;
211
165
  /**
212
- * Update edges
166
+ * Set the restoring from history flag.
167
+ *
168
+ * Used internally by the history store when performing undo/redo.
213
169
  */
214
- updateEdges: (edges: WorkflowEdge[]) => void;
170
+ setRestoringFromHistory(restoring: boolean): void;
215
171
  /**
216
- * Update workflow name
172
+ * Initialize workflow (from load or new).
173
+ *
174
+ * This sets the initial saved snapshot, clears dirty state, and initializes history.
217
175
  */
218
- updateName: (name: string) => void;
176
+ initialize(workflow: Workflow): void;
177
+ /**
178
+ * Update the entire workflow.
179
+ *
180
+ * Note: This is typically called from SvelteFlow sync and should not push to history
181
+ * for every small change. History is pushed by specific actions or drag handlers.
182
+ */
183
+ updateWorkflow(workflow: Workflow): void;
219
184
  /**
220
- * Add a node
185
+ * Restore workflow from history (undo/redo).
186
+ *
187
+ * This bypasses history recording to prevent recursive loops.
221
188
  */
222
- addNode: (node: WorkflowNode) => void;
189
+ restoreFromHistory(workflow: Workflow): void;
190
+ /** Update nodes. */
191
+ updateNodes(nodes: WorkflowNode[]): void;
192
+ /** Update edges. */
193
+ updateEdges(edges: WorkflowEdge[]): void;
194
+ /** Update workflow name. */
195
+ updateName(name: string): void;
196
+ /** Add a node. */
197
+ addNode(node: WorkflowNode): void;
223
198
  /**
224
- * Remove a node
199
+ * Remove a node.
225
200
  *
226
201
  * This is an atomic operation that also removes connected edges.
227
202
  * A single undo will restore both the node and its edges.
228
203
  */
229
- removeNode: (nodeId: string) => void;
204
+ removeNode(nodeId: string): void;
205
+ /** Add an edge. */
206
+ addEdge(edge: WorkflowEdge): void;
207
+ /** Remove an edge. */
208
+ removeEdge(edgeId: string): void;
230
209
  /**
231
- * Add an edge
210
+ * Update a specific node.
211
+ *
212
+ * Used for config changes. Pushes to history for undo support.
232
213
  */
233
- addEdge: (edge: WorkflowEdge) => void;
214
+ updateNode(nodeId: string, updates: Partial<WorkflowNode>): void;
234
215
  /**
235
- * Remove an edge
216
+ * Apply a live config edit to a node.
217
+ *
218
+ * Unlike {@link updateNode}, this is cheap enough to call on every keystroke:
219
+ * it does NOT snapshot the workflow to history and does NOT fire the external
220
+ * change event per call. Instead it opens (lazily) a single history
221
+ * transaction for the field-editing session and defers the change event to
222
+ * {@link finalizeNodeConfig}. Editing a different node or field first
223
+ * finalizes the previous session, so undo granularity is one step per field.
224
+ *
225
+ * The store always reflects the latest value immediately (the mutation and
226
+ * version bump happen here), so a save mid-session persists the current
227
+ * value even if the session hasn't been finalized yet.
228
+ *
229
+ * @param nodeId - Node whose config is being edited
230
+ * @param updates - Partial node updates (typically `{ data }`)
231
+ * @param opts.fieldKey - The config field being edited; drives per-field
232
+ * session boundaries. Omit to treat the whole node as one session.
236
233
  */
237
- removeEdge: (edgeId: string) => void;
234
+ updateNodeConfig(nodeId: string, updates: Partial<WorkflowNode>, opts?: {
235
+ fieldKey?: string;
236
+ }): void;
238
237
  /**
239
- * Update a specific node
238
+ * Finalize the in-progress config-edit session, if any.
240
239
  *
241
- * Used for config changes. Pushes to history for undo support.
240
+ * Commits the session's history transaction (one undo step for the whole
241
+ * session) and fires the external change event once. Idempotent: a no-op
242
+ * when no session is open. Call on blur, panel close, node switch, and before
243
+ * save. Undo/redo call this first (via the history facade / command dispatch)
244
+ * so a session becomes a committed step before it is undone.
242
245
  */
243
- updateNode: (nodeId: string, updates: Partial<WorkflowNode>) => void;
246
+ finalizeNodeConfig(changeType?: WorkflowChangeType): void;
244
247
  /**
245
- * Clear the workflow
248
+ * Clear the workflow.
246
249
  *
247
250
  * Resets the workflow and clears history.
248
251
  */
249
- clear: () => void;
250
- /**
251
- * Update workflow metadata
252
- */
253
- updateMetadata: (metadata: Partial<Workflow["metadata"]>) => void;
252
+ clear(): void;
253
+ /** Update workflow metadata. */
254
+ updateMetadata(metadata: Partial<Workflow['metadata']>): void;
254
255
  /**
255
- * Batch update nodes and edges
256
+ * Batch update nodes and edges.
256
257
  *
257
258
  * Useful for complex operations that update multiple things at once.
258
259
  * Creates a single history entry for the entire batch.
259
260
  */
260
- batchUpdate: (updates: {
261
+ batchUpdate(updates: {
261
262
  nodes?: WorkflowNode[];
262
263
  edges?: WorkflowEdge[];
263
264
  name?: string;
264
265
  description?: string;
265
- metadata?: Partial<Workflow["metadata"]>;
266
+ metadata?: Partial<Workflow['metadata']>;
266
267
  config?: Record<string, unknown>;
267
- }) => void;
268
+ }): void;
268
269
  /**
269
270
  * Swap a node — atomically replaces nodes and edges with a descriptive history entry.
270
271
  *
271
272
  * Unlike batchUpdate, this uses `"node_swap"` as the change type and
272
273
  * records a meaningful description for the undo history.
273
274
  */
274
- swapNode: (updates: {
275
+ swapNode(updates: {
275
276
  nodes: WorkflowNode[];
276
277
  edges: WorkflowEdge[];
277
278
  description?: string;
278
- }) => void;
279
+ }): void;
279
280
  /**
280
- * Push current state to history manually
281
+ * Push the current (post-change) state to history manually.
281
282
  *
282
- * Use this before operations that modify the workflow through other means
283
- * (e.g., drag operations handled by SvelteFlow directly).
283
+ * Use this AFTER operations that modify the workflow through other means
284
+ * (e.g., drag operations handled by SvelteFlow directly), passing the
285
+ * resulting state so undo returns to the state before the operation.
284
286
  *
285
- * @param description - Description of the upcoming change
287
+ * @param description - Description of the change that was just made
286
288
  * @param workflow - Optional workflow to push (uses store state if not provided)
287
289
  */
288
- pushHistory: (description?: string, workflow?: Workflow) => void;
289
- };
290
+ pushHistory(description?: string, workflow?: Workflow): void;
291
+ }
290
292
  export {};