@flowdrop/flowdrop 1.14.0 → 2.0.0-beta.1

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 (218) hide show
  1. package/CHANGELOG.md +475 -0
  2. package/MIGRATION-2.0.md +472 -0
  3. package/README.md +23 -23
  4. package/dist/adapters/WorkflowAdapter.d.ts +1 -1
  5. package/dist/adapters/WorkflowAdapter.js +14 -8
  6. package/dist/adapters/agentspec/AgentSpecAdapter.js +7 -7
  7. package/dist/chat/batchFeedback.d.ts +39 -0
  8. package/dist/chat/batchFeedback.js +51 -0
  9. package/dist/commands/executor.js +15 -1
  10. package/dist/commands/storeIntegration.svelte.d.ts +4 -1
  11. package/dist/commands/storeIntegration.svelte.js +26 -21
  12. package/dist/commands/types.d.ts +2 -0
  13. package/dist/components/App.svelte +162 -192
  14. package/dist/components/App.svelte.d.ts +47 -8
  15. package/dist/components/ConfigForm.svelte +110 -66
  16. package/dist/components/ConfigModal.svelte +7 -2
  17. package/dist/components/ConnectionLine.svelte +4 -2
  18. package/dist/components/Navbar.svelte +61 -1
  19. package/dist/components/NodeSidebar.svelte +27 -45
  20. package/dist/components/NodeStatusOverlay.svelte +94 -6
  21. package/dist/components/NodeSwapPicker.svelte +10 -8
  22. package/dist/components/PipelineStatus.svelte +16 -67
  23. package/dist/components/PortCoordinateTracker.svelte +5 -6
  24. package/dist/components/SchemaForm.stories.svelte +1 -3
  25. package/dist/components/SchemaForm.svelte +45 -40
  26. package/dist/components/SchemaForm.svelte.d.ts +0 -8
  27. package/dist/components/SettingsModal.svelte +8 -3
  28. package/dist/components/SettingsPanel.svelte +20 -4
  29. package/dist/components/SwapMappingEditor.svelte +67 -49
  30. package/dist/components/SwapMappingEditor.svelte.d.ts +0 -2
  31. package/dist/components/UniversalNode.svelte +9 -7
  32. package/dist/components/WorkflowEditor.svelte +118 -111
  33. package/dist/components/WorkflowEditor.svelte.d.ts +18 -10
  34. package/dist/components/chat/AIChatPanel.svelte +93 -89
  35. package/dist/components/chat/AIChatPanel.svelte.d.ts +0 -4
  36. package/dist/components/chat/CommandPreview.svelte +2 -1
  37. package/dist/components/console/CommandConsole.svelte +7 -5
  38. package/dist/components/console/ConsoleAutocomplete.svelte +10 -11
  39. package/dist/components/console/ConsoleAutocomplete.svelte.d.ts +6 -0
  40. package/dist/components/console/ConsoleInput.svelte +15 -6
  41. package/dist/components/console/ConsoleOutput.svelte +2 -1
  42. package/dist/components/form/FormArray.svelte +5 -9
  43. package/dist/components/form/FormArray.svelte.d.ts +2 -1
  44. package/dist/components/form/FormAutocomplete.svelte +29 -13
  45. package/dist/components/form/FormField.svelte +4 -2
  46. package/dist/components/form/FormFieldLight.svelte +4 -2
  47. package/dist/components/form/FormMarkdownEditor.svelte +9 -4
  48. package/dist/components/form/FormRangeField.svelte +1 -0
  49. package/dist/components/form/FormTemplateEditor.svelte +11 -3
  50. package/dist/components/form/FormToggle.svelte +5 -12
  51. package/dist/components/form/FormToggle.svelte.d.ts +4 -2
  52. package/dist/components/form/templateAutocomplete.js +1 -5
  53. package/dist/components/form/types.d.ts +1 -14
  54. package/dist/components/interrupt/FormPrompt.svelte +3 -2
  55. package/dist/components/interrupt/InterruptBubble.svelte +16 -17
  56. package/dist/components/interrupt/ReviewPrompt.svelte +10 -3
  57. package/dist/components/interrupt/TextInputPrompt.svelte +2 -1
  58. package/dist/components/layouts/MainLayout.svelte +20 -13
  59. package/dist/components/layouts/MainLayout.svelte.d.ts +4 -0
  60. package/dist/components/nodes/AtomNode.svelte +292 -0
  61. package/dist/components/nodes/AtomNode.svelte.d.ts +26 -0
  62. package/dist/components/nodes/GatewayNode.svelte +19 -10
  63. package/dist/components/nodes/IdeaNode.svelte +7 -0
  64. package/dist/components/nodes/SimpleNode.svelte +11 -6
  65. package/dist/components/nodes/SquareNode.svelte +15 -8
  66. package/dist/components/nodes/TerminalNode.svelte +9 -4
  67. package/dist/components/nodes/ToolNode.svelte +7 -1
  68. package/dist/components/nodes/WorkflowNode.svelte +16 -7
  69. package/dist/components/playground/ChatInput.svelte +11 -14
  70. package/dist/components/playground/ChatPanel.svelte +6 -49
  71. package/dist/components/playground/ChatPanel.svelte.d.ts +0 -14
  72. package/dist/components/playground/ControlPanel.svelte +134 -123
  73. package/dist/components/playground/ControlPanel.svelte.d.ts +3 -0
  74. package/dist/components/playground/ExecutionLogs.svelte +11 -9
  75. package/dist/components/playground/InputCollector.svelte +11 -9
  76. package/dist/components/playground/MessageStream.svelte +17 -23
  77. package/dist/components/playground/PipelineKanbanView.svelte +65 -6
  78. package/dist/components/playground/PipelinePanel.svelte +11 -5
  79. package/dist/components/playground/PipelineTableView.svelte +186 -44
  80. package/dist/components/playground/Playground.svelte +95 -92
  81. package/dist/components/playground/Playground.svelte.d.ts +2 -0
  82. package/dist/components/playground/PlaygroundApp.svelte +6 -1
  83. package/dist/components/playground/PlaygroundApp.svelte.d.ts +3 -0
  84. package/dist/components/playground/PlaygroundModal.svelte +13 -3
  85. package/dist/components/playground/PlaygroundModal.svelte.d.ts +3 -0
  86. package/dist/components/playground/PlaygroundStudio.svelte +34 -32
  87. package/dist/components/playground/PlaygroundStudio.svelte.d.ts +3 -0
  88. package/dist/components/playground/SessionManager.svelte +9 -12
  89. package/dist/components/playground/pipelineViewUtils.svelte.d.ts +28 -0
  90. package/dist/components/playground/pipelineViewUtils.svelte.js +38 -1
  91. package/dist/config/endpoints.d.ts +0 -7
  92. package/dist/config/endpoints.js +2 -10
  93. package/dist/core/index.d.ts +4 -4
  94. package/dist/core/index.js +6 -6
  95. package/dist/display/index.d.ts +0 -2
  96. package/dist/display/index.js +0 -6
  97. package/dist/editor/index.d.ts +19 -20
  98. package/dist/editor/index.js +25 -35
  99. package/dist/form/code.d.ts +25 -15
  100. package/dist/form/code.js +44 -41
  101. package/dist/form/fieldRegistry.d.ts +17 -13
  102. package/dist/form/fieldRegistry.js +32 -12
  103. package/dist/form/full.d.ts +17 -13
  104. package/dist/form/full.js +22 -27
  105. package/dist/form/index.d.ts +3 -3
  106. package/dist/form/index.js +3 -3
  107. package/dist/form/markdown.d.ts +13 -8
  108. package/dist/form/markdown.js +22 -23
  109. package/dist/helpers/proximityConnect.d.ts +7 -3
  110. package/dist/helpers/proximityConnect.js +19 -6
  111. package/dist/helpers/workflowEditorHelper.d.ts +12 -5
  112. package/dist/helpers/workflowEditorHelper.js +27 -25
  113. package/dist/index.d.ts +28 -24
  114. package/dist/index.js +27 -50
  115. package/dist/messages/defaults.d.ts +2 -5
  116. package/dist/messages/defaults.js +3 -6
  117. package/dist/messages/index.d.ts +0 -1
  118. package/dist/messages/index.js +0 -1
  119. package/dist/mocks/app-forms.d.ts +6 -2
  120. package/dist/mocks/app-forms.js +11 -4
  121. package/dist/openapi/v1/openapi.yaml +227 -164
  122. package/dist/playground/index.d.ts +2 -3
  123. package/dist/playground/index.js +2 -30
  124. package/dist/playground/mount.d.ts +15 -0
  125. package/dist/playground/mount.js +46 -20
  126. package/dist/registry/{BaseRegistry.d.ts → BaseRegistry.svelte.d.ts} +22 -1
  127. package/dist/registry/{BaseRegistry.js → BaseRegistry.svelte.js} +37 -1
  128. package/dist/registry/builtinFormats.d.ts +9 -18
  129. package/dist/registry/builtinFormats.js +9 -39
  130. package/dist/registry/builtinNodes.d.ts +1 -26
  131. package/dist/registry/builtinNodes.js +14 -50
  132. package/dist/registry/index.d.ts +3 -4
  133. package/dist/registry/index.js +4 -6
  134. package/dist/registry/nodeComponentRegistry.d.ts +182 -15
  135. package/dist/registry/nodeComponentRegistry.js +235 -17
  136. package/dist/registry/workflowFormatRegistry.d.ts +14 -9
  137. package/dist/registry/workflowFormatRegistry.js +24 -8
  138. package/dist/{schema → schemas}/index.d.ts +2 -2
  139. package/dist/{schema → schemas}/index.js +2 -2
  140. package/dist/schemas/v1/workflow.schema.json +53 -6
  141. package/dist/services/agentSpecExecutionService.js +0 -1
  142. package/dist/services/apiVariableService.d.ts +2 -1
  143. package/dist/services/apiVariableService.js +5 -22
  144. package/dist/services/autoSaveService.d.ts +7 -0
  145. package/dist/services/autoSaveService.js +6 -4
  146. package/dist/services/chatService.d.ts +8 -4
  147. package/dist/services/chatService.js +15 -15
  148. package/dist/services/draftStorage.d.ts +129 -13
  149. package/dist/services/draftStorage.js +185 -37
  150. package/dist/services/dynamicSchemaService.d.ts +2 -1
  151. package/dist/services/dynamicSchemaService.js +5 -22
  152. package/dist/services/globalSave.d.ts +13 -12
  153. package/dist/services/globalSave.js +29 -51
  154. package/dist/services/historyService.d.ts +9 -3
  155. package/dist/services/historyService.js +9 -3
  156. package/dist/services/interruptService.d.ts +14 -9
  157. package/dist/services/interruptService.js +27 -27
  158. package/dist/services/nodeExecutionService.d.ts +18 -3
  159. package/dist/services/nodeExecutionService.js +71 -45
  160. package/dist/services/playgroundService.d.ts +14 -9
  161. package/dist/services/playgroundService.js +31 -30
  162. package/dist/services/variableService.d.ts +2 -1
  163. package/dist/services/variableService.js +2 -2
  164. package/dist/services/workflowStorage.js +6 -6
  165. package/dist/stores/apiContext.d.ts +45 -0
  166. package/dist/stores/apiContext.js +65 -0
  167. package/dist/stores/categoriesStore.svelte.d.ts +28 -23
  168. package/dist/stores/categoriesStore.svelte.js +70 -64
  169. package/dist/stores/getInstance.svelte.d.ts +39 -0
  170. package/dist/stores/getInstance.svelte.js +65 -0
  171. package/dist/stores/historyStore.svelte.d.ts +77 -93
  172. package/dist/stores/historyStore.svelte.js +134 -160
  173. package/dist/stores/instanceContainer.svelte.d.ts +111 -0
  174. package/dist/stores/instanceContainer.svelte.js +114 -0
  175. package/dist/stores/interruptStore.svelte.d.ts +112 -82
  176. package/dist/stores/interruptStore.svelte.js +253 -226
  177. package/dist/stores/pipelinePanelStore.svelte.d.ts +27 -3
  178. package/dist/stores/pipelinePanelStore.svelte.js +61 -14
  179. package/dist/stores/playgroundStore.svelte.d.ts +169 -216
  180. package/dist/stores/playgroundStore.svelte.js +515 -572
  181. package/dist/stores/portCoordinateStore.svelte.d.ts +57 -51
  182. package/dist/stores/portCoordinateStore.svelte.js +109 -98
  183. package/dist/stores/settingsStore.svelte.d.ts +4 -1
  184. package/dist/stores/settingsStore.svelte.js +47 -12
  185. package/dist/stores/workflowStore.svelte.d.ts +178 -213
  186. package/dist/stores/workflowStore.svelte.js +449 -501
  187. package/dist/stories/EdgeDecorator.svelte +5 -2
  188. package/dist/stories/NodeDecorator.svelte +5 -3
  189. package/dist/svelte-app.d.ts +60 -10
  190. package/dist/svelte-app.js +157 -53
  191. package/dist/types/events.d.ts +6 -3
  192. package/dist/types/index.d.ts +71 -6
  193. package/dist/types/navbar.d.ts +7 -0
  194. package/dist/types/playground.d.ts +18 -3
  195. package/dist/types/settings.d.ts +13 -0
  196. package/dist/types/settings.js +1 -0
  197. package/dist/utils/colors.d.ts +47 -21
  198. package/dist/utils/colors.js +69 -68
  199. package/dist/utils/connections.d.ts +9 -15
  200. package/dist/utils/connections.js +13 -32
  201. package/dist/utils/duration.d.ts +13 -0
  202. package/dist/utils/duration.js +45 -0
  203. package/dist/utils/formMerge.d.ts +36 -0
  204. package/dist/utils/formMerge.js +70 -0
  205. package/dist/utils/icons.d.ts +5 -2
  206. package/dist/utils/icons.js +6 -5
  207. package/dist/utils/nodeSwap.d.ts +6 -2
  208. package/dist/utils/nodeSwap.js +62 -126
  209. package/dist/utils/nodeTypes.d.ts +17 -8
  210. package/dist/utils/nodeTypes.js +27 -19
  211. package/dist/utils/performanceUtils.js +7 -0
  212. package/package.json +6 -5
  213. package/dist/messages/deprecation.d.ts +0 -20
  214. package/dist/messages/deprecation.js +0 -33
  215. package/dist/registry/plugin.d.ts +0 -215
  216. package/dist/registry/plugin.js +0 -249
  217. package/dist/services/api.d.ts +0 -129
  218. package/dist/services/api.js +0 -217
@@ -1,283 +1,248 @@
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
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`.
54
21
  */
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;
22
+ type LegacyWorkflow = Omit<Workflow, 'metadata'> & {
23
+ metadata?: (Partial<WorkflowMetadata> & {
24
+ version?: string;
25
+ }) | null;
77
26
  };
78
27
  /**
79
- * Get workflow validation state reactively
28
+ * Normalize workflow metadata at load time (the only back-compat path we keep,
29
+ * mirroring the storage-key migration in commit 8fab9157).
80
30
  *
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
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
92
35
  *
93
- * @returns Metadata change info
36
+ * Idempotent: re-running on an already-healed workflow returns equivalent
37
+ * metadata (round-trip stable).
94
38
  */
95
- export declare function getWorkflowMetadataChanged(): {
96
- createdAt: string;
97
- updatedAt: string;
98
- version: string;
99
- };
39
+ export declare function normalizeWorkflowMetadata(workflow: LegacyWorkflow): Workflow;
100
40
  /**
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.
41
+ * Mutation actions for a {@link WorkflowStore}.
105
42
  *
106
- * @example
107
- * ```typescript
108
- * import { getConnectedHandles } from './workflowStore.svelte.js';
109
- *
110
- * // Check if a specific handle is connected
111
- * const isConnected = getConnectedHandles().has('node-1-input-data');
112
- * ```
43
+ * Bound facade — safe to detach (`onclick={fd.workflow.actions.undo}`)
44
+ * because every entry is bound to its store in the constructor.
113
45
  */
114
- export declare function getConnectedHandles(): Set<string>;
115
- /**
116
- * Set the dirty state change callback
117
- *
118
- * @param callback - Function to call when dirty state changes
119
- */
120
- export declare function setOnDirtyStateChange(callback: ((isDirty: boolean) => void) | null): void;
121
- /**
122
- * Set the workflow change callback
123
- *
124
- * @param callback - Function to call when workflow changes
125
- */
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
+ clear: () => void;
59
+ updateMetadata: (metadata: Partial<Workflow['metadata']>) => void;
60
+ batchUpdate: (updates: {
61
+ nodes?: WorkflowNode[];
62
+ edges?: WorkflowEdge[];
63
+ name?: string;
64
+ description?: string;
65
+ metadata?: Partial<Workflow['metadata']>;
66
+ config?: Record<string, unknown>;
67
+ }) => void;
68
+ swapNode: (updates: {
69
+ nodes: WorkflowNode[];
70
+ edges: WorkflowEdge[];
71
+ description?: string;
72
+ }) => void;
73
+ pushHistory: (description?: string, workflow?: Workflow) => void;
74
+ }
181
75
  /**
182
- * Actions for updating the workflow
76
+ * Per-instance workflow state with dirty tracking and history integration.
183
77
  *
184
- * All actions that modify the workflow will trigger dirty state updates
185
- * and emit change events.
78
+ * All reads go through getters backed by `$state`, so reading them inside a
79
+ * component template or `$derived` tracks reactively, exactly like the
80
+ * legacy module-level functions did.
186
81
  */
187
- export declare const workflowActions: {
82
+ export declare class WorkflowStore {
83
+ #private;
84
+ /** Bound mutation facade — see {@link WorkflowStoreActions}. */
85
+ readonly actions: WorkflowStoreActions;
86
+ constructor(history: HistoryService);
87
+ /** The current workflow, or null when none is loaded. */
88
+ get current(): Workflow | null;
188
89
  /**
189
- * Initialize workflow (from load or new)
90
+ * Whether there are unsaved changes.
190
91
  *
191
- * This sets the initial saved snapshot, clears dirty state, and initializes history.
192
- */
193
- initialize: (workflow: Workflow) => void;
194
- /**
195
- * Update the entire workflow
92
+ * Reads both #editVersion and #savedVersion, so Svelte tracks them as
93
+ * reactive dependencies — any component using this re-renders when dirty
94
+ * state changes.
95
+ */
96
+ get isDirty(): boolean;
97
+ /** The workflow ID, or null. */
98
+ get id(): string | null;
99
+ /** The workflow name, or 'Untitled Workflow'. */
100
+ get name(): string;
101
+ /** The workflow nodes. */
102
+ get nodes(): WorkflowNode[];
103
+ /** The workflow edges. */
104
+ get edges(): WorkflowEdge[];
105
+ /** The workflow metadata, with defaults. */
106
+ get metadata(): WorkflowMetadata;
107
+ /** The workflow format string. */
108
+ get format(): string;
109
+ /** Workflow change summary (useful for triggering saves). */
110
+ get changeSummary(): {
111
+ nodes: WorkflowNode[];
112
+ edges: WorkflowEdge[];
113
+ name: string;
114
+ };
115
+ /** Workflow validation state. */
116
+ get validation(): {
117
+ hasNodes: boolean;
118
+ hasEdges: boolean;
119
+ nodeCount: number;
120
+ edgeCount: number;
121
+ isValid: boolean;
122
+ };
123
+ /** Workflow metadata change summary. */
124
+ get metadataChangeSummary(): {
125
+ createdAt: string;
126
+ updatedAt: string;
127
+ schemaVersion: string;
128
+ };
129
+ /**
130
+ * Set of all handle IDs currently connected to edges.
196
131
  *
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.
132
+ * Used by node components to implement hideUnconnectedHandles.
199
133
  */
200
- updateWorkflow: (workflow: Workflow) => void;
134
+ get connectedHandles(): Set<string>;
201
135
  /**
202
- * Restore workflow from history (undo/redo)
136
+ * The current monotonic edit version.
203
137
  *
204
- * This bypasses history recording to prevent recursive loops.
138
+ * Use this for the save verification protocol:
139
+ * 1. Before save: `const v = store.editVersion`
140
+ * 2. Include `v` in the save request payload
141
+ * 3. Backend echoes `v` in the response
142
+ * 4. If echoed version matches: `store.markAsSaved()`
143
+ * 5. If not: the save didn't persist the version you submitted — reset from backend response
144
+ */
145
+ get editVersion(): number;
146
+ /** Whether history recording is enabled. */
147
+ get historyEnabled(): boolean;
148
+ /** Enable or disable history recording (e.g. for bulk operations). */
149
+ set historyEnabled(enabled: boolean);
150
+ /** Set the dirty state change callback. */
151
+ setOnDirtyStateChange(callback: ((isDirty: boolean) => void) | null): void;
152
+ /** Set the workflow change callback. */
153
+ setOnWorkflowChange(callback: ((workflow: Workflow, changeType: WorkflowChangeType) => void) | null): void;
154
+ /**
155
+ * Mark the current workflow state as saved.
156
+ *
157
+ * Captures the current edit version so isDirty becomes false.
158
+ * Call this after a successful backend save.
205
159
  */
206
- restoreFromHistory: (workflow: Workflow) => void;
160
+ markAsSaved(): void;
207
161
  /**
208
- * Update nodes
162
+ * Set the restoring from history flag.
163
+ *
164
+ * Used internally by the history store when performing undo/redo.
209
165
  */
210
- updateNodes: (nodes: WorkflowNode[]) => void;
166
+ setRestoringFromHistory(restoring: boolean): void;
211
167
  /**
212
- * Update edges
168
+ * Initialize workflow (from load or new).
169
+ *
170
+ * This sets the initial saved snapshot, clears dirty state, and initializes history.
213
171
  */
214
- updateEdges: (edges: WorkflowEdge[]) => void;
172
+ initialize(workflow: Workflow): void;
215
173
  /**
216
- * Update workflow name
174
+ * Update the entire workflow.
175
+ *
176
+ * Note: This is typically called from SvelteFlow sync and should not push to history
177
+ * for every small change. History is pushed by specific actions or drag handlers.
217
178
  */
218
- updateName: (name: string) => void;
179
+ updateWorkflow(workflow: Workflow): void;
219
180
  /**
220
- * Add a node
181
+ * Restore workflow from history (undo/redo).
182
+ *
183
+ * This bypasses history recording to prevent recursive loops.
221
184
  */
222
- addNode: (node: WorkflowNode) => void;
223
- /**
224
- * Remove a node
185
+ restoreFromHistory(workflow: Workflow): void;
186
+ /** Update nodes. */
187
+ updateNodes(nodes: WorkflowNode[]): void;
188
+ /** Update edges. */
189
+ updateEdges(edges: WorkflowEdge[]): void;
190
+ /** Update workflow name. */
191
+ updateName(name: string): void;
192
+ /** Add a node. */
193
+ addNode(node: WorkflowNode): void;
194
+ /**
195
+ * Remove a node.
225
196
  *
226
197
  * This is an atomic operation that also removes connected edges.
227
198
  * A single undo will restore both the node and its edges.
228
199
  */
229
- removeNode: (nodeId: string) => void;
230
- /**
231
- * Add an edge
232
- */
233
- addEdge: (edge: WorkflowEdge) => void;
234
- /**
235
- * Remove an edge
236
- */
237
- removeEdge: (edgeId: string) => void;
200
+ removeNode(nodeId: string): void;
201
+ /** Add an edge. */
202
+ addEdge(edge: WorkflowEdge): void;
203
+ /** Remove an edge. */
204
+ removeEdge(edgeId: string): void;
238
205
  /**
239
- * Update a specific node
206
+ * Update a specific node.
240
207
  *
241
208
  * Used for config changes. Pushes to history for undo support.
242
209
  */
243
- updateNode: (nodeId: string, updates: Partial<WorkflowNode>) => void;
210
+ updateNode(nodeId: string, updates: Partial<WorkflowNode>): void;
244
211
  /**
245
- * Clear the workflow
212
+ * Clear the workflow.
246
213
  *
247
214
  * Resets the workflow and clears history.
248
215
  */
249
- clear: () => void;
250
- /**
251
- * Update workflow metadata
252
- */
253
- updateMetadata: (metadata: Partial<Workflow["metadata"]>) => void;
216
+ clear(): void;
217
+ /** Update workflow metadata. */
218
+ updateMetadata(metadata: Partial<Workflow['metadata']>): void;
254
219
  /**
255
- * Batch update nodes and edges
220
+ * Batch update nodes and edges.
256
221
  *
257
222
  * Useful for complex operations that update multiple things at once.
258
223
  * Creates a single history entry for the entire batch.
259
224
  */
260
- batchUpdate: (updates: {
225
+ batchUpdate(updates: {
261
226
  nodes?: WorkflowNode[];
262
227
  edges?: WorkflowEdge[];
263
228
  name?: string;
264
229
  description?: string;
265
- metadata?: Partial<Workflow["metadata"]>;
230
+ metadata?: Partial<Workflow['metadata']>;
266
231
  config?: Record<string, unknown>;
267
- }) => void;
232
+ }): void;
268
233
  /**
269
234
  * Swap a node — atomically replaces nodes and edges with a descriptive history entry.
270
235
  *
271
236
  * Unlike batchUpdate, this uses `"node_swap"` as the change type and
272
237
  * records a meaningful description for the undo history.
273
238
  */
274
- swapNode: (updates: {
239
+ swapNode(updates: {
275
240
  nodes: WorkflowNode[];
276
241
  edges: WorkflowEdge[];
277
242
  description?: string;
278
- }) => void;
243
+ }): void;
279
244
  /**
280
- * Push current state to history manually
245
+ * Push current state to history manually.
281
246
  *
282
247
  * Use this before operations that modify the workflow through other means
283
248
  * (e.g., drag operations handled by SvelteFlow directly).
@@ -285,6 +250,6 @@ export declare const workflowActions: {
285
250
  * @param description - Description of the upcoming change
286
251
  * @param workflow - Optional workflow to push (uses store state if not provided)
287
252
  */
288
- pushHistory: (description?: string, workflow?: Workflow) => void;
289
- };
253
+ pushHistory(description?: string, workflow?: Workflow): void;
254
+ }
290
255
  export {};