@flowdrop/flowdrop 1.15.0 → 2.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (235) hide show
  1. package/CHANGELOG.md +508 -0
  2. package/MIGRATION-2.0.md +629 -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/api/enhanced-client.js +6 -11
  8. package/dist/chat/batchFeedback.d.ts +39 -0
  9. package/dist/chat/batchFeedback.js +51 -0
  10. package/dist/commands/executor.js +15 -1
  11. package/dist/commands/storeIntegration.svelte.d.ts +4 -1
  12. package/dist/commands/storeIntegration.svelte.js +26 -21
  13. package/dist/commands/types.d.ts +2 -0
  14. package/dist/components/App.svelte +163 -192
  15. package/dist/components/App.svelte.d.ts +47 -8
  16. package/dist/components/ConfigForm.svelte +77 -49
  17. package/dist/components/ConfigModal.svelte +7 -2
  18. package/dist/components/ConnectionLine.svelte +4 -2
  19. package/dist/components/Navbar.svelte +61 -1
  20. package/dist/components/NodeSidebar.svelte +27 -45
  21. package/dist/components/NodeStatusOverlay.svelte +94 -6
  22. package/dist/components/NodeSwapPicker.svelte +10 -8
  23. package/dist/components/PipelineStatus.svelte +22 -68
  24. package/dist/components/PipelineStatus.svelte.d.ts +3 -0
  25. package/dist/components/PortCoordinateTracker.svelte +5 -6
  26. package/dist/components/SchemaForm.stories.svelte +1 -3
  27. package/dist/components/SchemaForm.svelte +22 -27
  28. package/dist/components/SchemaForm.svelte.d.ts +0 -8
  29. package/dist/components/SettingsModal.svelte +8 -3
  30. package/dist/components/SettingsPanel.svelte +20 -4
  31. package/dist/components/SwapMappingEditor.svelte +67 -49
  32. package/dist/components/SwapMappingEditor.svelte.d.ts +0 -2
  33. package/dist/components/UniversalNode.svelte +9 -7
  34. package/dist/components/WorkflowEditor.svelte +121 -111
  35. package/dist/components/WorkflowEditor.svelte.d.ts +21 -10
  36. package/dist/components/chat/AIChatPanel.svelte +98 -89
  37. package/dist/components/chat/AIChatPanel.svelte.d.ts +0 -4
  38. package/dist/components/chat/CommandPreview.svelte +2 -1
  39. package/dist/components/console/CommandConsole.svelte +7 -5
  40. package/dist/components/console/ConsoleAutocomplete.svelte +10 -11
  41. package/dist/components/console/ConsoleAutocomplete.svelte.d.ts +6 -0
  42. package/dist/components/console/ConsoleInput.svelte +15 -6
  43. package/dist/components/console/ConsoleOutput.svelte +2 -1
  44. package/dist/components/form/FormArray.svelte +5 -9
  45. package/dist/components/form/FormArray.svelte.d.ts +2 -1
  46. package/dist/components/form/FormAutocomplete.svelte +16 -15
  47. package/dist/components/form/FormField.svelte +4 -2
  48. package/dist/components/form/FormFieldLight.svelte +34 -3
  49. package/dist/components/form/FormFieldLight.svelte.d.ts +12 -0
  50. package/dist/components/form/FormMarkdownEditor.svelte +9 -4
  51. package/dist/components/form/FormRangeField.svelte +1 -0
  52. package/dist/components/form/FormTemplateEditor.svelte +11 -3
  53. package/dist/components/form/FormToggle.svelte +5 -12
  54. package/dist/components/form/FormToggle.svelte.d.ts +4 -2
  55. package/dist/components/form/FormUISchemaRenderer.svelte +3 -1
  56. package/dist/components/form/templateAutocomplete.js +1 -5
  57. package/dist/components/form/types.d.ts +1 -14
  58. package/dist/components/interrupt/FormPrompt.svelte +3 -2
  59. package/dist/components/interrupt/InterruptBubble.svelte +25 -17
  60. package/dist/components/interrupt/ReviewPrompt.svelte +10 -3
  61. package/dist/components/interrupt/TextInputPrompt.svelte +2 -1
  62. package/dist/components/layouts/MainLayout.svelte +20 -13
  63. package/dist/components/layouts/MainLayout.svelte.d.ts +4 -0
  64. package/dist/components/nodes/AtomNode.svelte +17 -5
  65. package/dist/components/nodes/GatewayNode.svelte +19 -10
  66. package/dist/components/nodes/IdeaNode.svelte +7 -0
  67. package/dist/components/nodes/SimpleNode.svelte +11 -6
  68. package/dist/components/nodes/SquareNode.svelte +15 -8
  69. package/dist/components/nodes/TerminalNode.svelte +9 -4
  70. package/dist/components/nodes/ToolNode.svelte +7 -1
  71. package/dist/components/nodes/WorkflowNode.svelte +16 -7
  72. package/dist/components/playground/ChatInput.svelte +11 -14
  73. package/dist/components/playground/ChatPanel.svelte +6 -49
  74. package/dist/components/playground/ChatPanel.svelte.d.ts +0 -14
  75. package/dist/components/playground/ControlPanel.svelte +134 -123
  76. package/dist/components/playground/ControlPanel.svelte.d.ts +3 -0
  77. package/dist/components/playground/ExecutionLogs.svelte +11 -9
  78. package/dist/components/playground/InputCollector.svelte +11 -9
  79. package/dist/components/playground/MessageStream.svelte +17 -23
  80. package/dist/components/playground/PipelineKanbanView.svelte +69 -8
  81. package/dist/components/playground/PipelineKanbanView.svelte.d.ts +2 -0
  82. package/dist/components/playground/PipelinePanel.svelte +31 -8
  83. package/dist/components/playground/PipelinePanel.svelte.d.ts +2 -0
  84. package/dist/components/playground/PipelineTableView.svelte +188 -44
  85. package/dist/components/playground/PipelineTableView.svelte.d.ts +2 -0
  86. package/dist/components/playground/Playground.svelte +154 -105
  87. package/dist/components/playground/Playground.svelte.d.ts +5 -0
  88. package/dist/components/playground/PlaygroundApp.svelte +11 -1
  89. package/dist/components/playground/PlaygroundApp.svelte.d.ts +6 -0
  90. package/dist/components/playground/PlaygroundModal.svelte +18 -3
  91. package/dist/components/playground/PlaygroundModal.svelte.d.ts +6 -0
  92. package/dist/components/playground/PlaygroundStudio.svelte +40 -32
  93. package/dist/components/playground/PlaygroundStudio.svelte.d.ts +6 -0
  94. package/dist/components/playground/SessionManager.svelte +9 -12
  95. package/dist/components/playground/pipelineViewUtils.svelte.d.ts +30 -1
  96. package/dist/components/playground/pipelineViewUtils.svelte.js +40 -3
  97. package/dist/config/endpoints.d.ts +23 -7
  98. package/dist/config/endpoints.js +30 -10
  99. package/dist/core/index.d.ts +5 -6
  100. package/dist/core/index.js +8 -12
  101. package/dist/display/index.d.ts +6 -3
  102. package/dist/display/index.js +7 -5
  103. package/dist/editor/index.d.ts +20 -21
  104. package/dist/editor/index.js +26 -36
  105. package/dist/form/code.d.ts +25 -15
  106. package/dist/form/code.js +44 -41
  107. package/dist/form/fieldRegistry.d.ts +17 -13
  108. package/dist/form/fieldRegistry.js +32 -12
  109. package/dist/form/full.d.ts +19 -14
  110. package/dist/form/full.js +26 -28
  111. package/dist/form/index.d.ts +3 -4
  112. package/dist/form/index.js +6 -5
  113. package/dist/form/markdown.d.ts +13 -8
  114. package/dist/form/markdown.js +22 -23
  115. package/dist/helpers/proximityConnect.d.ts +3 -2
  116. package/dist/helpers/proximityConnect.js +2 -5
  117. package/dist/helpers/workflowEditorHelper.d.ts +14 -5
  118. package/dist/helpers/workflowEditorHelper.js +28 -25
  119. package/dist/index.d.ts +28 -24
  120. package/dist/index.js +27 -50
  121. package/dist/messages/defaults.d.ts +2 -5
  122. package/dist/messages/defaults.js +3 -6
  123. package/dist/messages/index.d.ts +0 -1
  124. package/dist/messages/index.js +0 -1
  125. package/dist/mocks/app-forms.d.ts +6 -2
  126. package/dist/mocks/app-forms.js +11 -4
  127. package/dist/openapi/v1/openapi.yaml +3 -3
  128. package/dist/playground/index.d.ts +4 -5
  129. package/dist/playground/index.js +4 -32
  130. package/dist/playground/mount.d.ts +25 -0
  131. package/dist/playground/mount.js +50 -20
  132. package/dist/registry/{BaseRegistry.d.ts → BaseRegistry.svelte.d.ts} +22 -1
  133. package/dist/registry/{BaseRegistry.js → BaseRegistry.svelte.js} +37 -1
  134. package/dist/registry/builtinFormats.d.ts +9 -18
  135. package/dist/registry/builtinFormats.js +9 -39
  136. package/dist/registry/builtinNodeTypes.d.ts +53 -0
  137. package/dist/registry/builtinNodeTypes.js +67 -0
  138. package/dist/registry/builtinNodes.d.ts +2 -64
  139. package/dist/registry/builtinNodes.js +7 -103
  140. package/dist/registry/index.d.ts +3 -4
  141. package/dist/registry/index.js +4 -6
  142. package/dist/registry/nodeComponentRegistry.d.ts +182 -15
  143. package/dist/registry/nodeComponentRegistry.js +235 -17
  144. package/dist/registry/workflowFormatRegistry.d.ts +14 -9
  145. package/dist/registry/workflowFormatRegistry.js +24 -8
  146. package/dist/{schema → schemas}/index.d.ts +2 -2
  147. package/dist/{schema → schemas}/index.js +2 -2
  148. package/dist/schemas/v1/workflow.schema.json +3 -3
  149. package/dist/services/agentSpecExecutionService.d.ts +0 -2
  150. package/dist/services/agentSpecExecutionService.js +0 -3
  151. package/dist/services/apiVariableService.d.ts +2 -1
  152. package/dist/services/apiVariableService.js +16 -47
  153. package/dist/services/autoSaveService.d.ts +7 -0
  154. package/dist/services/autoSaveService.js +6 -4
  155. package/dist/services/categoriesApi.js +3 -6
  156. package/dist/services/chatService.d.ts +9 -4
  157. package/dist/services/chatService.js +23 -28
  158. package/dist/services/draftStorage.d.ts +129 -13
  159. package/dist/services/draftStorage.js +185 -37
  160. package/dist/services/dynamicSchemaService.d.ts +2 -1
  161. package/dist/services/dynamicSchemaService.js +5 -22
  162. package/dist/services/globalSave.d.ts +13 -12
  163. package/dist/services/globalSave.js +29 -51
  164. package/dist/services/historyService.d.ts +9 -3
  165. package/dist/services/historyService.js +9 -3
  166. package/dist/services/interruptService.d.ts +15 -9
  167. package/dist/services/interruptService.js +35 -37
  168. package/dist/services/nodeExecutionService.d.ts +18 -3
  169. package/dist/services/nodeExecutionService.js +71 -45
  170. package/dist/services/playgroundService.d.ts +16 -10
  171. package/dist/services/playgroundService.js +42 -43
  172. package/dist/services/portConfigApi.js +3 -6
  173. package/dist/services/settingsService.d.ts +9 -4
  174. package/dist/services/settingsService.js +23 -12
  175. package/dist/services/variableService.d.ts +2 -1
  176. package/dist/services/variableService.js +2 -2
  177. package/dist/services/workflowStorage.js +6 -6
  178. package/dist/stores/apiContext.d.ts +56 -0
  179. package/dist/stores/apiContext.js +80 -0
  180. package/dist/stores/categoriesStore.svelte.d.ts +28 -23
  181. package/dist/stores/categoriesStore.svelte.js +69 -64
  182. package/dist/stores/getInstance.svelte.d.ts +39 -0
  183. package/dist/stores/getInstance.svelte.js +65 -0
  184. package/dist/stores/historyStore.svelte.d.ts +77 -93
  185. package/dist/stores/historyStore.svelte.js +134 -160
  186. package/dist/stores/instanceContainer.svelte.d.ts +111 -0
  187. package/dist/stores/instanceContainer.svelte.js +114 -0
  188. package/dist/stores/interruptStore.svelte.d.ts +112 -82
  189. package/dist/stores/interruptStore.svelte.js +253 -226
  190. package/dist/stores/pipelinePanelStore.svelte.d.ts +27 -3
  191. package/dist/stores/pipelinePanelStore.svelte.js +61 -14
  192. package/dist/stores/playgroundStore.svelte.d.ts +169 -222
  193. package/dist/stores/playgroundStore.svelte.js +513 -580
  194. package/dist/stores/portCoordinateStore.svelte.d.ts +57 -51
  195. package/dist/stores/portCoordinateStore.svelte.js +109 -98
  196. package/dist/stores/settingsStore.svelte.d.ts +4 -1
  197. package/dist/stores/settingsStore.svelte.js +47 -12
  198. package/dist/stores/workflowStore.svelte.d.ts +178 -213
  199. package/dist/stores/workflowStore.svelte.js +449 -501
  200. package/dist/stories/EdgeDecorator.svelte +5 -2
  201. package/dist/stories/NodeDecorator.svelte +5 -3
  202. package/dist/svelte-app.d.ts +60 -10
  203. package/dist/svelte-app.js +159 -54
  204. package/dist/types/auth.d.ts +9 -51
  205. package/dist/types/auth.js +4 -54
  206. package/dist/types/events.d.ts +6 -3
  207. package/dist/types/index.d.ts +37 -5
  208. package/dist/types/index.js +0 -1
  209. package/dist/types/navbar.d.ts +7 -0
  210. package/dist/types/playground.d.ts +18 -3
  211. package/dist/types/settings.d.ts +13 -0
  212. package/dist/types/settings.js +1 -0
  213. package/dist/utils/colors.d.ts +47 -21
  214. package/dist/utils/colors.js +69 -68
  215. package/dist/utils/connections.d.ts +9 -15
  216. package/dist/utils/connections.js +13 -32
  217. package/dist/utils/duration.d.ts +13 -0
  218. package/dist/utils/duration.js +45 -0
  219. package/dist/utils/edgeStyling.js +9 -5
  220. package/dist/utils/fetchWithAuth.d.ts +36 -15
  221. package/dist/utils/fetchWithAuth.js +53 -23
  222. package/dist/utils/icons.d.ts +5 -2
  223. package/dist/utils/icons.js +6 -5
  224. package/dist/utils/nodeSwap.d.ts +6 -2
  225. package/dist/utils/nodeSwap.js +62 -126
  226. package/dist/utils/nodeTypes.d.ts +17 -8
  227. package/dist/utils/nodeTypes.js +27 -20
  228. package/dist/utils/performanceUtils.js +7 -0
  229. package/package.json +7 -5
  230. package/dist/messages/deprecation.d.ts +0 -20
  231. package/dist/messages/deprecation.js +0 -33
  232. package/dist/registry/plugin.d.ts +0 -215
  233. package/dist/registry/plugin.js +0 -249
  234. package/dist/services/api.d.ts +0 -129
  235. package/dist/services/api.js +0 -217
@@ -3,9 +3,8 @@
3
3
  * Contains business logic for workflow operations
4
4
  */
5
5
  import { hasCycles, hasInvalidCycles } from '../utils/connections.js';
6
- import { workflowApi, nodeApi, setEndpointConfig } from '../services/api.js';
7
6
  import { v4 as uuidv4 } from 'uuid';
8
- import { workflowActions } from '../stores/workflowStore.svelte.js';
7
+ import { getDefaultInstance } from '../stores/instanceContainer.svelte.js';
9
8
  import { nodeExecutionService } from '../services/nodeExecutionService.js';
10
9
  import { WorkflowAdapter } from '../adapters/WorkflowAdapter.js';
11
10
  import { AgentSpecAdapter } from '../adapters/agentspec/AgentSpecAdapter.js';
@@ -49,14 +48,14 @@ export class NodeOperationsHelper {
49
48
  /**
50
49
  * Load nodes from API
51
50
  */
52
- static async loadNodesFromApi(providedNodes) {
51
+ static async loadNodesFromApi(api, providedNodes) {
53
52
  // If nodes are provided via props, use them
54
53
  if (providedNodes && providedNodes.length > 0) {
55
54
  return providedNodes;
56
55
  }
57
56
  // Otherwise, load from API
58
57
  try {
59
- const fetchedNodes = await nodeApi.getNodes();
58
+ const fetchedNodes = await api.client.getAvailableNodes();
60
59
  return fetchedNodes;
61
60
  }
62
61
  catch (error) {
@@ -89,7 +88,7 @@ export class NodeOperationsHelper {
89
88
  /**
90
89
  * Load node execution information for all nodes in the workflow
91
90
  */
92
- static async loadNodeExecutionInfo(workflow, pipelineId) {
91
+ static async loadNodeExecutionInfo(api, workflow, pipelineId) {
93
92
  if (!workflow?.nodes)
94
93
  return {};
95
94
  // Only load execution info if we have a pipelineId (for pipeline status mode)
@@ -97,7 +96,7 @@ export class NodeOperationsHelper {
97
96
  return {};
98
97
  try {
99
98
  const nodeIds = workflow.nodes.map((node) => node.id);
100
- const executionInfo = await nodeExecutionService.getMultipleNodeExecutionInfo(nodeIds, pipelineId);
99
+ const executionInfo = await nodeExecutionService.getMultipleNodeExecutionInfo(api.config, nodeIds, pipelineId);
101
100
  return executionInfo;
102
101
  }
103
102
  catch (error) {
@@ -160,7 +159,7 @@ export class WorkflowOperationsHelper {
160
159
  static generateMetadata(existingMetadata) {
161
160
  const now = new Date().toISOString();
162
161
  return {
163
- version: '1.0.0',
162
+ schemaVersion: '1.0.0',
164
163
  createdAt: now,
165
164
  ...(existingMetadata ?? {}),
166
165
  updatedAt: now,
@@ -217,38 +216,41 @@ export class WorkflowOperationsHelper {
217
216
  }
218
217
  /**
219
218
  * Save workflow to backend
219
+ *
220
+ * @param api - The instance's API context (endpoints + client)
221
+ * @param workflow - The workflow to save
222
+ * @param instance - The FlowDrop instance whose store should be synced when
223
+ * the server assigns a new ID; defaults to the page-default instance
220
224
  */
221
- static async saveWorkflow(workflow) {
225
+ static async saveWorkflow(api, workflow, instance) {
222
226
  if (!workflow) {
223
227
  logger.warn('No workflow data available to save');
224
228
  return null;
225
229
  }
226
230
  try {
227
- // Determine the workflow ID based on whether we have an existing workflow
228
- let workflowId;
229
- if (workflow.id) {
230
- // Use the existing workflow ID
231
- workflowId = workflow.id;
232
- }
233
- else {
234
- // Generate a new UUID for a new workflow
235
- workflowId = uuidv4();
236
- }
231
+ // Determine new vs existing BEFORE the uuidv4() fallback: a present id (any
232
+ // format) means the workflow came from a backend and must be updated. Only
233
+ // a missing id means "truly new".
234
+ const isExistingWorkflow = !!workflow.id;
235
+ const workflowId = workflow.id || uuidv4();
237
236
  const workflowToSave = {
238
237
  id: workflowId,
239
238
  name: workflow.name || 'Untitled Workflow',
240
239
  nodes: workflow.nodes || [],
241
240
  edges: workflow.edges || [],
242
241
  metadata: {
243
- version: '1.0.0',
242
+ schemaVersion: workflow.metadata?.schemaVersion || '1.0.0',
244
243
  createdAt: workflow.metadata?.createdAt || new Date().toISOString(),
245
244
  updatedAt: new Date().toISOString()
246
245
  }
247
246
  };
248
- const savedWorkflow = await workflowApi.saveWorkflow(workflowToSave);
247
+ const savedWorkflow = isExistingWorkflow
248
+ ? await api.client.updateWorkflow(workflowToSave.id, workflowToSave)
249
+ : await api.client.saveWorkflow(workflowToSave);
249
250
  // Update the workflow ID if it changed (new workflow)
250
251
  if (savedWorkflow.id && savedWorkflow.id !== workflowToSave.id) {
251
- workflowActions.batchUpdate({
252
+ const fd = instance ?? getDefaultInstance();
253
+ fd.workflow.batchUpdate({
252
254
  nodes: workflowToSave.nodes,
253
255
  edges: workflowToSave.edges,
254
256
  name: workflowToSave.name,
@@ -281,7 +283,7 @@ export class WorkflowOperationsHelper {
281
283
  nodes: workflow.nodes || [],
282
284
  edges: workflow.edges || [],
283
285
  metadata: {
284
- version: '1.0.0',
286
+ schemaVersion: workflow.metadata?.schemaVersion || '1.0.0',
285
287
  createdAt: workflow.metadata?.createdAt || new Date().toISOString(),
286
288
  updatedAt: new Date().toISOString()
287
289
  }
@@ -380,9 +382,10 @@ export class WorkflowOperationsHelper {
380
382
  */
381
383
  export class ConfigurationHelper {
382
384
  /**
383
- * Configure API endpoints
385
+ * Configure API endpoints (and optionally the auth provider) on the given
386
+ * instance's API context.
384
387
  */
385
- static configureEndpoints(config) {
386
- setEndpointConfig(config);
388
+ static configureEndpoints(api, config, authProvider) {
389
+ api.configure(config, authProvider);
387
390
  }
388
391
  }
package/dist/index.d.ts CHANGED
@@ -1,37 +1,41 @@
1
1
  /**
2
2
  * FlowDrop - Visual Workflow Editor Library
3
3
  *
4
- * A Svelte 5 component library built on @xyflow/svelte for creating node-based workflow editors.
4
+ * A Svelte 5 component library built on @xyflow/svelte for creating node-based
5
+ * workflow editors.
5
6
  *
6
- * ## Module Structure (Tree-Shakable)
7
+ * ## The main entry is a minimal front door
7
8
  *
8
- * For optimal bundle size, import from specific sub-modules:
9
+ * This entry point intentionally exposes only the small surface most apps need
10
+ * to get started: the `App` component, the `mountFlowDropApp` / `unmountFlowDropApp`
11
+ * mount helpers, instance plumbing (`createFlowDropInstance` / `getInstance` /
12
+ * `provideInstance`), endpoint + auth helpers, and the core public types. It does
13
+ * NOT re-export the entire library.
9
14
  *
10
- * - `@flowdrop/flowdrop/core` - Types and utilities only (no heavy deps)
11
- * - `@flowdrop/flowdrop/editor` - WorkflowEditor with @xyflow/svelte
15
+ * Everything else lives in focused sub-modules import from the one you need:
16
+ *
17
+ * - `@flowdrop/flowdrop/core` - Types, utilities, theme/skin, messages helpers (no heavy deps)
18
+ * - `@flowdrop/flowdrop/editor` - WorkflowEditor, registries, stores, services (adds @xyflow/svelte)
12
19
  * - `@flowdrop/flowdrop/form` - SchemaForm with basic fields
13
- * - `@flowdrop/flowdrop/form/code` - Code editor support (adds CodeMirror)
14
- * - `@flowdrop/flowdrop/form/markdown` - Markdown editor support (CodeMirror 6)
20
+ * - `@flowdrop/flowdrop/form/code` - Code editor field (adds CodeMirror)
21
+ * - `@flowdrop/flowdrop/form/markdown` - Markdown editor field (CodeMirror 6)
15
22
  * - `@flowdrop/flowdrop/display` - MarkdownDisplay (adds marked)
16
23
  * - `@flowdrop/flowdrop/playground` - Playground for interactive workflow testing
24
+ * - `@flowdrop/flowdrop/settings` - Settings stores, services, components
17
25
  * - `@flowdrop/flowdrop/styles` - CSS styles
18
26
  *
19
- * ## Legacy Import (Full Bundle)
20
- *
21
- * Importing from the main entry point includes everything:
22
- *
23
- * ```typescript
24
- * import { WorkflowEditor, SchemaForm } from "@flowdrop/flowdrop";
25
- * ```
26
- *
27
- * **Note**: This will bundle ALL dependencies including @xyflow/svelte,
28
- * CodeMirror and marked. For smaller bundles, use sub-modules.
29
- *
30
27
  * @module flowdrop
31
28
  */
32
- export * from './core/index.js';
33
- export * from './form/index.js';
34
- export * from './display/index.js';
35
- export * from './playground/index.js';
36
- export * from './editor/index.js';
37
- export * from './settings/index.js';
29
+ export { default as App } from './components/App.svelte';
30
+ export { mountFlowDropApp, unmountFlowDropApp } from './svelte-app.js';
31
+ export { createFlowDropInstance } from './stores/instanceContainer.svelte.js';
32
+ export { getInstance, provideInstance } from './stores/getInstance.svelte.js';
33
+ export { createEndpointConfig, defaultEndpointConfig } from './config/endpoints.js';
34
+ export { NoAuthProvider, StaticAuthProvider, CallbackAuthProvider } from './types/auth.js';
35
+ export type { Workflow, WorkflowNode, WorkflowEdge, NodeMetadata, ConfigSchema } from './types/index.js';
36
+ export type { EndpointConfig } from './config/endpoints.js';
37
+ export type { AuthProvider } from './types/auth.js';
38
+ export type { FlowDropInstance } from './stores/instanceContainer.svelte.js';
39
+ export type { FlowDropMountOptions, MountedFlowDropApp } from './svelte-app.js';
40
+ export type { FlowDropEventHandlers } from './types/events.js';
41
+ export type { Messages, MessagesOverride } from './messages/index.js';
package/dist/index.js CHANGED
@@ -1,64 +1,41 @@
1
1
  /**
2
2
  * FlowDrop - Visual Workflow Editor Library
3
3
  *
4
- * A Svelte 5 component library built on @xyflow/svelte for creating node-based workflow editors.
4
+ * A Svelte 5 component library built on @xyflow/svelte for creating node-based
5
+ * workflow editors.
5
6
  *
6
- * ## Module Structure (Tree-Shakable)
7
+ * ## The main entry is a minimal front door
7
8
  *
8
- * For optimal bundle size, import from specific sub-modules:
9
+ * This entry point intentionally exposes only the small surface most apps need
10
+ * to get started: the `App` component, the `mountFlowDropApp` / `unmountFlowDropApp`
11
+ * mount helpers, instance plumbing (`createFlowDropInstance` / `getInstance` /
12
+ * `provideInstance`), endpoint + auth helpers, and the core public types. It does
13
+ * NOT re-export the entire library.
9
14
  *
10
- * - `@flowdrop/flowdrop/core` - Types and utilities only (no heavy deps)
11
- * - `@flowdrop/flowdrop/editor` - WorkflowEditor with @xyflow/svelte
15
+ * Everything else lives in focused sub-modules import from the one you need:
16
+ *
17
+ * - `@flowdrop/flowdrop/core` - Types, utilities, theme/skin, messages helpers (no heavy deps)
18
+ * - `@flowdrop/flowdrop/editor` - WorkflowEditor, registries, stores, services (adds @xyflow/svelte)
12
19
  * - `@flowdrop/flowdrop/form` - SchemaForm with basic fields
13
- * - `@flowdrop/flowdrop/form/code` - Code editor support (adds CodeMirror)
14
- * - `@flowdrop/flowdrop/form/markdown` - Markdown editor support (CodeMirror 6)
20
+ * - `@flowdrop/flowdrop/form/code` - Code editor field (adds CodeMirror)
21
+ * - `@flowdrop/flowdrop/form/markdown` - Markdown editor field (CodeMirror 6)
15
22
  * - `@flowdrop/flowdrop/display` - MarkdownDisplay (adds marked)
16
23
  * - `@flowdrop/flowdrop/playground` - Playground for interactive workflow testing
24
+ * - `@flowdrop/flowdrop/settings` - Settings stores, services, components
17
25
  * - `@flowdrop/flowdrop/styles` - CSS styles
18
26
  *
19
- * ## Legacy Import (Full Bundle)
20
- *
21
- * Importing from the main entry point includes everything:
22
- *
23
- * ```typescript
24
- * import { WorkflowEditor, SchemaForm } from "@flowdrop/flowdrop";
25
- * ```
26
- *
27
- * **Note**: This will bundle ALL dependencies including @xyflow/svelte,
28
- * CodeMirror and marked. For smaller bundles, use sub-modules.
29
- *
30
27
  * @module flowdrop
31
28
  */
32
29
  // ============================================================================
33
- // IMPORTANT: This module re-exports from sub-modules for backward compatibility.
34
- // New code should import directly from sub-modules for better tree-shaking.
35
- //
36
- // The wildcard re-exports below are intentional: each sub-module barrel uses
37
- // explicit named exports, so the public API surface is fully controlled there.
38
- // ============================================================================
39
- // ============================================================================
40
- // Core Exports (Types & Utilities - No Heavy Dependencies)
41
- // ============================================================================
42
- export * from './core/index.js';
43
- // ============================================================================
44
- // Form Exports
45
- // ============================================================================
46
- export * from './form/index.js';
47
- // Note: Heavy form fields (code, markdown) are NOT auto-registered.
48
- // Users must import from form/code or form/markdown and register explicitly.
49
- // ============================================================================
50
- // Display Exports
51
- // ============================================================================
52
- export * from './display/index.js';
53
- // ============================================================================
54
- // Playground Exports
55
- // ============================================================================
56
- export * from './playground/index.js';
57
- // ============================================================================
58
- // Editor Exports (includes @xyflow/svelte and auto-registers builtin nodes)
59
- // ============================================================================
60
- export * from './editor/index.js';
61
- // ============================================================================
62
- // Settings Exports (stores, services, components, types)
63
- // ============================================================================
64
- export * from './settings/index.js';
30
+ // Values
31
+ // ============================================================================
32
+ // App component + vanilla-JS mount lifecycle.
33
+ export { default as App } from './components/App.svelte';
34
+ export { mountFlowDropApp, unmountFlowDropApp } from './svelte-app.js';
35
+ // Instance plumbing — per-instance state container + Svelte context helpers.
36
+ export { createFlowDropInstance } from './stores/instanceContainer.svelte.js';
37
+ export { getInstance, provideInstance } from './stores/getInstance.svelte.js';
38
+ // Endpoint configuration helpers.
39
+ export { createEndpointConfig, defaultEndpointConfig } from './config/endpoints.js';
40
+ // Authentication providers.
41
+ export { NoAuthProvider, StaticAuthProvider, CallbackAuthProvider } from './types/auth.js';
@@ -279,12 +279,8 @@ export declare const defaultMessages: {
279
279
  readonly predefinedRun: "Run workflow";
280
280
  };
281
281
  readonly states: {
282
- readonly viewOnlyTitle: "View only";
283
- readonly viewOnlyText: "This playground is in view-only mode. No inputs are available.";
284
282
  readonly newSessionTitle: "New session";
285
283
  readonly newSessionText: "Test your flow with a prompt";
286
- readonly readyTitle: "Ready to run";
287
- readonly readyText: "Click Run to execute your workflow";
288
284
  readonly processing: "Processing...";
289
285
  readonly viewOnlyHelp: "View-only mode. Workflow execution is controlled externally.";
290
286
  };
@@ -342,7 +338,7 @@ export declare const defaultMessages: {
342
338
  readonly newSession: "New session";
343
339
  };
344
340
  readonly controlPanel: {
345
- readonly sessionsLabel: "Sessions";
341
+ readonly sessionsLabel: "Session";
346
342
  readonly noSession: "No session";
347
343
  readonly switchSession: "Switch session";
348
344
  readonly newSession: "New session";
@@ -420,6 +416,7 @@ export declare const defaultMessages: {
420
416
  readonly lastRunLabel: "Last Run:";
421
417
  readonly durationLabel: "Duration:";
422
418
  readonly errorLabel: "Error:";
419
+ readonly historyLabel: "Runs:";
423
420
  };
424
421
  };
425
422
  };
@@ -258,12 +258,8 @@ export const defaultMessages = {
258
258
  predefinedRun: 'Run workflow'
259
259
  },
260
260
  states: {
261
- viewOnlyTitle: 'View only',
262
- viewOnlyText: 'This playground is in view-only mode. No inputs are available.',
263
261
  newSessionTitle: 'New session',
264
262
  newSessionText: 'Test your flow with a prompt',
265
- readyTitle: 'Ready to run',
266
- readyText: 'Click Run to execute your workflow',
267
263
  processing: 'Processing...',
268
264
  viewOnlyHelp: 'View-only mode. Workflow execution is controlled externally.'
269
265
  },
@@ -316,7 +312,7 @@ export const defaultMessages = {
316
312
  newSession: 'New session'
317
313
  },
318
314
  controlPanel: {
319
- sessionsLabel: 'Sessions',
315
+ sessionsLabel: 'Session',
320
316
  noSession: 'No session',
321
317
  switchSession: 'Switch session',
322
318
  newSession: 'New session',
@@ -380,7 +376,8 @@ export const defaultMessages = {
380
376
  executionsLabel: 'Executions:',
381
377
  lastRunLabel: 'Last Run:',
382
378
  durationLabel: 'Duration:',
383
- errorLabel: 'Error:'
379
+ errorLabel: 'Error:',
380
+ historyLabel: 'Runs:'
384
381
  }
385
382
  }
386
383
  };
@@ -7,5 +7,4 @@
7
7
  export { defaultMessages } from './defaults.js';
8
8
  export { mergeMessages } from './merge.js';
9
9
  export { setMessages, getMessages, m } from './context.js';
10
- export { warnDeprecatedProp, __resetDeprecationWarningsForTests } from './deprecation.js';
11
10
  export type { Messages, MessagesOverride, DeepPartial } from './types.js';
@@ -7,4 +7,3 @@
7
7
  export { defaultMessages } from './defaults.js';
8
8
  export { mergeMessages } from './merge.js';
9
9
  export { setMessages, getMessages, m } from './context.js';
10
- export { warnDeprecatedProp, __resetDeprecationWarningsForTests } from './deprecation.js';
@@ -1,2 +1,6 @@
1
- export function enhance(form: any, options?: {}): (event: any) => void;
2
- export function applyAction(action: any): any;
1
+ export function enhance(_form: HTMLFormElement, options?: {
2
+ onResult?: (result: {
3
+ type: string;
4
+ }) => void;
5
+ }): (event: SubmitEvent) => void;
6
+ export function applyAction(action: unknown): unknown;
@@ -1,11 +1,15 @@
1
- // @ts-nocheck
2
1
  /**
3
2
  * Mock for $app/forms
4
3
  * Provides minimal implementations for SvelteKit forms in library context
5
4
  */
6
5
 
7
- // Mock enhance function
8
- export const enhance = (form, options = {}) => {
6
+ /**
7
+ * Mock enhance function
8
+ * @param {HTMLFormElement} _form
9
+ * @param {{ onResult?: (result: { type: string }) => void }} [options]
10
+ */
11
+ export const enhance = (_form, options = {}) => {
12
+ /** @param {SubmitEvent} event */
9
13
  return (event) => {
10
14
  event.preventDefault();
11
15
  // Basic form handling for library context
@@ -15,7 +19,10 @@ export const enhance = (form, options = {}) => {
15
19
  };
16
20
  };
17
21
 
18
- // Mock applyAction function
22
+ /**
23
+ * Mock applyAction function
24
+ * @param {unknown} action
25
+ */
19
26
  export const applyAction = (action) => {
20
27
  // No-op for library context
21
28
  return action;
@@ -3923,9 +3923,9 @@ components:
3923
3923
  WorkflowMetadata:
3924
3924
  type: object
3925
3925
  properties:
3926
- version:
3926
+ schemaVersion:
3927
3927
  type: string
3928
- description: Workflow version
3928
+ description: Workflow schema format version — identifies the document format, not the workflow's own revision.
3929
3929
  example: 1.0.0
3930
3930
  createdAt:
3931
3931
  type: string
@@ -3963,7 +3963,7 @@ components:
3963
3963
  example: flowdrop
3964
3964
  default: flowdrop
3965
3965
  required:
3966
- - version
3966
+ - schemaVersion
3967
3967
  - createdAt
3968
3968
  - updatedAt
3969
3969
  Workflow:
@@ -126,15 +126,14 @@ export { default as InputCollector } from '../components/playground/InputCollect
126
126
  export { default as ExecutionLogs } from '../components/playground/ExecutionLogs.svelte';
127
127
  export { default as MessageBubble } from '../components/playground/MessageBubble.svelte';
128
128
  export { InterruptBubble, ConfirmationPrompt, ChoicePrompt, TextInputPrompt, FormPrompt, ReviewPrompt } from '../components/interrupt/index.js';
129
- export { PlaygroundService, playgroundService } from '../services/playgroundService.js';
130
- export { InterruptService, interruptService } from '../services/interruptService.js';
131
- export { getCurrentSession, getSessions, getMessages, getIsExecuting, getCanSendMessage, getIsLoading, getError as getPlaygroundError, getCurrentWorkflow, getLastPollSequenceNumber, getSessionStatus, getMessageCount, getChatMessages, getLogMessages, getLatestMessage, getInputFields, getHasChatInput, getSessionCount, getActiveExecutionId, getPinnedExecutionId, getLatestExecutionId, getShowLogs, playgroundActions, applyServerResponse, subscribeToSessionStatus, getCurrentSessionId, isSessionSelected, getMessagesSnapshot, getLatestSequenceNumber } from '../stores/playgroundStore.svelte.js';
132
- export { getPipelinePanelOpen, pipelinePanelActions } from '../stores/pipelinePanelStore.svelte.js';
129
+ export { PlaygroundService } from '../services/playgroundService.js';
130
+ export { InterruptService } from '../services/interruptService.js';
131
+ export { PlaygroundStore } from '../stores/playgroundStore.svelte.js';
133
132
  export type { PlaygroundSession, PlaygroundMessage, PlaygroundInputField, PlaygroundMessageRequest, PlaygroundMessagesResult, PlaygroundConfig, PlaygroundMode, PlaygroundSessionStatus, PlaygroundMessageRole, PlaygroundMessageLevel, PlaygroundMessageMetadata, PlaygroundApiResponse, PlaygroundSessionsResponse, PlaygroundSessionResponse, PlaygroundMessageResponse, PlaygroundMessagesApiResponse, PlaygroundExecution } from '../types/playground.js';
134
133
  export { isChatInputNode, CHAT_INPUT_PATTERNS, defaultShouldStopPolling, defaultIsTerminalStatus, DEFAULT_STOP_POLLING_STATUSES, DEFAULT_TERMINAL_STATUSES } from '../types/playground.js';
135
134
  export type { InterruptType, InterruptStatus, Interrupt, InterruptChoice, InterruptConfig, ConfirmationConfig, ChoiceConfig, TextConfig, FormConfig, ReviewConfig, ReviewChange, ReviewFieldDecision, ReviewResolution, InterruptResolution, InterruptApiResponse, InterruptListResponse, InterruptResponse, InterruptMessageMetadata, InterruptPollingConfig } from '../types/interrupt.js';
136
135
  export { isInterruptMetadata, extractInterruptMetadata, metadataToInterrupt, defaultInterruptPollingConfig } from '../types/interrupt.js';
137
- export { getInterruptsMap, getPendingInterruptIds, getPendingInterrupts, getPendingInterruptCount, getResolvedInterrupts, getIsAnySubmitting, interruptActions, getInterrupt, isInterruptPending, isInterruptSubmitting, getInterruptError, getInterruptByMessageId, interruptHasError } from '../stores/interruptStore.svelte.js';
136
+ export { InterruptStore } from '../stores/interruptStore.svelte.js';
138
137
  export type { InterruptWithState } from '../stores/interruptStore.svelte.js';
139
138
  export { mountPlayground, unmountPlayground, mountPlaygroundStudio, mountPlaygroundApp, type PlaygroundMountOptions, type PlaygroundStudioMountOptions, type PlaygroundAppMountOptions, type MountedPlayground } from './mount.js';
140
139
  export type { PipelineViewDef, PipelineViewProps } from '../types/index.js';
@@ -135,49 +135,21 @@ export { InterruptBubble, ConfirmationPrompt, ChoicePrompt, TextInputPrompt, For
135
135
  // ============================================================================
136
136
  // Playground Service
137
137
  // ============================================================================
138
- export { PlaygroundService, playgroundService } from '../services/playgroundService.js';
138
+ export { PlaygroundService } from '../services/playgroundService.js';
139
139
  // ============================================================================
140
140
  // Interrupt Service (Human-in-the-Loop)
141
141
  // ============================================================================
142
- export { InterruptService, interruptService } from '../services/interruptService.js';
142
+ export { InterruptService } from '../services/interruptService.js';
143
143
  // ============================================================================
144
144
  // Playground Store
145
145
  // ============================================================================
146
- export {
147
- // Core state getters
148
- getCurrentSession, getSessions, getMessages, getIsExecuting, getCanSendMessage, getIsLoading, getError as getPlaygroundError, getCurrentWorkflow, getLastPollSequenceNumber,
149
- // Derived getters
150
- getSessionStatus, getMessageCount, getChatMessages, getLogMessages, getLatestMessage, getInputFields, getHasChatInput, getSessionCount,
151
- // Execution getters (used with PipelinePanel / PlaygroundSplit)
152
- getActiveExecutionId, getPinnedExecutionId, getLatestExecutionId,
153
- // UI state
154
- getShowLogs,
155
- // Actions
156
- playgroundActions,
157
- // Server response application (single update path)
158
- applyServerResponse,
159
- // Subscription utility
160
- subscribeToSessionStatus,
161
- // Utilities
162
- getCurrentSessionId, isSessionSelected, getMessagesSnapshot, getLatestSequenceNumber } from '../stores/playgroundStore.svelte.js';
163
- // ============================================================================
164
- // Pipeline Panel Store (open/close state, persisted to localStorage)
165
- // ============================================================================
166
- export { getPipelinePanelOpen, pipelinePanelActions } from '../stores/pipelinePanelStore.svelte.js';
146
+ export { PlaygroundStore } from '../stores/playgroundStore.svelte.js';
167
147
  export { isChatInputNode, CHAT_INPUT_PATTERNS, defaultShouldStopPolling, defaultIsTerminalStatus, DEFAULT_STOP_POLLING_STATUSES, DEFAULT_TERMINAL_STATUSES } from '../types/playground.js';
168
148
  export { isInterruptMetadata, extractInterruptMetadata, metadataToInterrupt, defaultInterruptPollingConfig } from '../types/interrupt.js';
169
149
  // ============================================================================
170
150
  // Interrupt Store (Human-in-the-Loop)
171
151
  // ============================================================================
172
- export {
173
- // Core state accessor
174
- getInterruptsMap,
175
- // Getter functions (replace derived stores)
176
- getPendingInterruptIds, getPendingInterrupts, getPendingInterruptCount, getResolvedInterrupts, getIsAnySubmitting,
177
- // Actions
178
- interruptActions,
179
- // Utilities
180
- getInterrupt, isInterruptPending, isInterruptSubmitting, getInterruptError, getInterruptByMessageId, interruptHasError } from '../stores/interruptStore.svelte.js';
152
+ export { InterruptStore } from '../stores/interruptStore.svelte.js';
181
153
  // ============================================================================
182
154
  // Playground Mount Functions (for vanilla JS / Drupal / IIFE integration)
183
155
  // ============================================================================
@@ -45,6 +45,7 @@
45
45
  */
46
46
  import type { Workflow } from '../types/index.js';
47
47
  import type { EndpointConfig } from '../config/endpoints.js';
48
+ import type { AuthProvider } from '../types/auth.js';
48
49
  import type { PlaygroundMode, PlaygroundConfig, PlaygroundSession, PlaygroundMessagesApiResponse, PlaygroundSessionStatus } from '../types/playground.js';
49
50
  import type { PartialSettings, SettingsCategory } from '../types/settings.js';
50
51
  import type { NavbarAction } from '../types/navbar.js';
@@ -81,6 +82,15 @@ export interface PlaygroundMountOptions {
81
82
  * Use createEndpointConfig() to create this
82
83
  */
83
84
  endpointConfig?: EndpointConfig;
85
+ /**
86
+ * Authentication provider for API requests.
87
+ *
88
+ * Applied to this instance via `fd.api.configure()` so every request the
89
+ * playground makes (sessions, messages, polling, interrupts) carries the
90
+ * provider's headers — e.g. an `Authorization` bearer token or an
91
+ * `X-CSRF-Token`. Omit for unauthenticated backends.
92
+ */
93
+ authProvider?: AuthProvider;
84
94
  /**
85
95
  * Playground-specific configuration options
86
96
  */
@@ -114,6 +124,21 @@ export interface PlaygroundMountOptions {
114
124
  * `settings` option.
115
125
  */
116
126
  settings?: PartialSettings;
127
+ /**
128
+ * Identifier for this playground's FlowDrop instance.
129
+ *
130
+ * When omitted, the playground uses the page-default instance — matching
131
+ * the legacy behavior where all playground mounts (and the editor's
132
+ * built-in playground) shared one session/message store. Pass an explicit
133
+ * id to isolate this playground's session/message *state* from other
134
+ * FlowDrop instances on the page.
135
+ *
136
+ * Note: live polling is NOT isolated — `playgroundService` keeps one
137
+ * page-global polling timer, so only one playground can actively poll at
138
+ * a time regardless of instance. Use `pushMessages()` with your own
139
+ * transport if two playgrounds need concurrent live updates.
140
+ */
141
+ instanceId?: string;
117
142
  }
118
143
  /**
119
144
  * Return type for mounted Playground instance