@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.
- package/CHANGELOG.md +648 -0
- package/MIGRATION-2.0.md +642 -0
- package/README.md +28 -28
- package/dist/adapters/WorkflowAdapter.d.ts +1 -1
- package/dist/adapters/WorkflowAdapter.js +18 -13
- package/dist/adapters/agentspec/AgentSpecAdapter.js +10 -10
- package/dist/adapters/agentspec/defaultNodeTypes.js +9 -9
- package/dist/api/enhanced-client.js +6 -11
- package/dist/chat/batchFeedback.d.ts +39 -0
- package/dist/chat/batchFeedback.js +51 -0
- package/dist/commands/executor.js +66 -27
- package/dist/commands/storeIntegration.svelte.d.ts +4 -1
- package/dist/commands/storeIntegration.svelte.js +36 -21
- package/dist/commands/types.d.ts +2 -0
- package/dist/commands/types.js +5 -5
- package/dist/components/App.svelte +696 -565
- package/dist/components/App.svelte.d.ts +63 -16
- package/dist/components/Button.stories.svelte +65 -0
- package/dist/components/Button.stories.svelte.d.ts +19 -0
- package/dist/components/Button.svelte +62 -0
- package/dist/components/Button.svelte.d.ts +24 -0
- package/dist/components/CanvasIconButton.svelte +76 -0
- package/dist/components/CanvasIconButton.svelte.d.ts +18 -0
- package/dist/components/ConfigForm.svelte +181 -552
- package/dist/components/ConfigForm.svelte.d.ts +24 -7
- package/dist/components/ConfigModal.svelte +16 -3
- package/dist/components/ConfigPanel.svelte +234 -15
- package/dist/components/ConfigPanel.svelte.d.ts +6 -0
- package/dist/components/ConnectionLine.svelte +4 -2
- package/dist/components/EditorStatusBar.stories.svelte +44 -0
- package/dist/components/EditorStatusBar.stories.svelte.d.ts +27 -0
- package/dist/components/EditorStatusBar.svelte +99 -0
- package/dist/components/EditorStatusBar.svelte.d.ts +15 -0
- package/dist/components/IconButton.svelte +80 -0
- package/dist/components/IconButton.svelte.d.ts +30 -0
- package/dist/components/Input.svelte +74 -0
- package/dist/components/Input.svelte.d.ts +17 -0
- package/dist/components/LogoWordmark.svelte +113 -0
- package/dist/components/LogoWordmark.svelte.d.ts +26 -0
- package/dist/components/Navbar.svelte +78 -64
- package/dist/components/Navbar.svelte.d.ts +3 -0
- package/dist/components/NodeSidebar.svelte +48 -171
- package/dist/components/NodeStatusOverlay.svelte +94 -6
- package/dist/components/NodeSwapPicker.svelte +22 -38
- package/dist/components/PipelineStatus.svelte +22 -68
- package/dist/components/PipelineStatus.svelte.d.ts +3 -0
- package/dist/components/PortCoordinateTracker.svelte +5 -6
- package/dist/components/PortMappingRow.svelte +0 -2
- package/dist/components/SchemaForm.stories.svelte +1 -3
- package/dist/components/SchemaForm.svelte +22 -39
- package/dist/components/SchemaForm.svelte.d.ts +0 -8
- package/dist/components/Select.svelte +53 -0
- package/dist/components/Select.svelte.d.ts +15 -0
- package/dist/components/SettingsModal.svelte +8 -8
- package/dist/components/SettingsPanel.svelte +44 -10
- package/dist/components/SwapMappingEditor.svelte +67 -49
- package/dist/components/SwapMappingEditor.svelte.d.ts +0 -2
- package/dist/components/Textarea.svelte +39 -0
- package/dist/components/Textarea.svelte.d.ts +12 -0
- package/dist/components/ThemeToggle.svelte +15 -94
- package/dist/components/UniversalNode.svelte +45 -11
- package/dist/components/UniversalNode.svelte.d.ts +1 -1
- package/dist/components/WorkflowEditor.svelte +183 -162
- package/dist/components/WorkflowEditor.svelte.d.ts +39 -10
- package/dist/components/chat/AIChatPanel.svelte +99 -90
- package/dist/components/chat/AIChatPanel.svelte.d.ts +0 -4
- package/dist/components/chat/CommandPreview.svelte +2 -1
- package/dist/components/console/CommandConsole.svelte +7 -5
- package/dist/components/console/ConsoleAutocomplete.svelte +11 -12
- package/dist/components/console/ConsoleAutocomplete.svelte.d.ts +6 -0
- package/dist/components/console/ConsoleInput.svelte +18 -9
- package/dist/components/console/ConsoleOutput.svelte +4 -3
- package/dist/components/form/FormArray.svelte +42 -182
- package/dist/components/form/FormArray.svelte.d.ts +2 -1
- package/dist/components/form/FormAutocomplete.svelte +26 -21
- package/dist/components/form/FormCheckboxGroup.svelte +1 -5
- package/dist/components/form/FormCodeEditor.svelte +9 -7
- package/dist/components/form/FormField.svelte +22 -44
- package/dist/components/form/FormFieldLight.svelte +56 -50
- package/dist/components/form/FormFieldLight.svelte.d.ts +12 -0
- package/dist/components/form/FormFieldset.svelte +45 -11
- package/dist/components/form/FormMarkdownEditor.svelte +17 -9
- package/dist/components/form/FormNumberField.svelte +4 -36
- package/dist/components/form/FormPorts.svelte +262 -0
- package/dist/components/form/FormPorts.svelte.d.ts +13 -0
- package/dist/components/form/FormRangeField.svelte +62 -30
- package/dist/components/form/FormSelect.svelte +13 -75
- package/dist/components/form/FormTemplateEditor.svelte +17 -7
- package/dist/components/form/FormTextField.svelte +3 -35
- package/dist/components/form/FormTextarea.svelte +4 -39
- package/dist/components/form/FormToggle.svelte +5 -16
- package/dist/components/form/FormToggle.svelte.d.ts +4 -2
- package/dist/components/form/FormUISchemaRenderer.svelte +3 -1
- package/dist/components/form/resolveFieldType.d.ts +24 -0
- package/dist/components/form/resolveFieldType.js +55 -0
- package/dist/components/form/templateAutocomplete.js +1 -5
- package/dist/components/form/types.d.ts +1 -14
- package/dist/components/icons/CloseIcon.svelte +6 -0
- package/dist/components/icons/CloseIcon.svelte.d.ts +26 -0
- package/dist/components/icons/CommandLineIcon.svelte +15 -0
- package/dist/components/icons/CommandLineIcon.svelte.d.ts +26 -0
- package/dist/components/icons/MenuIcon.svelte +4 -0
- package/dist/components/icons/MenuIcon.svelte.d.ts +26 -0
- package/dist/components/icons/MenuOpenIcon.svelte +6 -0
- package/dist/components/icons/MenuOpenIcon.svelte.d.ts +26 -0
- package/dist/components/interrupt/ChoicePrompt.svelte +0 -10
- package/dist/components/interrupt/ConfirmationPrompt.svelte +0 -5
- package/dist/components/interrupt/FormPrompt.svelte +3 -2
- package/dist/components/interrupt/InterruptBubble.svelte +25 -27
- package/dist/components/interrupt/ReviewPrompt.svelte +10 -23
- package/dist/components/interrupt/TextInputPrompt.svelte +2 -7
- package/dist/components/layouts/MainLayout.svelte +24 -18
- package/dist/components/layouts/MainLayout.svelte.d.ts +4 -0
- package/dist/components/nodes/AtomNode.svelte +70 -72
- package/dist/components/nodes/AtomNode.svelte.d.ts +1 -1
- package/dist/components/nodes/GatewayNode.svelte +134 -172
- package/dist/components/nodes/GatewayNode.svelte.d.ts +1 -1
- package/dist/components/nodes/IdeaNode.svelte +79 -98
- package/dist/components/nodes/IdeaNode.svelte.d.ts +8 -4
- package/dist/components/nodes/NodeConfigButton.svelte +86 -0
- package/dist/components/nodes/NodeConfigButton.svelte.d.ts +15 -0
- package/dist/components/nodes/NotesNode.svelte +76 -85
- package/dist/components/nodes/NotesNode.svelte.d.ts +8 -4
- package/dist/components/nodes/SimpleNode.svelte +68 -137
- package/dist/components/nodes/SimpleNode.svelte.d.ts +4 -4
- package/dist/components/nodes/SquareNode.svelte +122 -169
- package/dist/components/nodes/SquareNode.svelte.d.ts +4 -4
- package/dist/components/nodes/TerminalNode.svelte +70 -127
- package/dist/components/nodes/TerminalNode.svelte.d.ts +4 -4
- package/dist/components/nodes/ToolNode.svelte +99 -104
- package/dist/components/nodes/ToolNode.svelte.d.ts +6 -6
- package/dist/components/nodes/WorkflowNode.svelte +145 -195
- package/dist/components/nodes/WorkflowNode.svelte.d.ts +1 -1
- package/dist/components/playground/ChatInput.svelte +11 -15
- package/dist/components/playground/ChatPanel.svelte +6 -49
- package/dist/components/playground/ChatPanel.svelte.d.ts +0 -14
- package/dist/components/playground/ControlPanel.svelte +134 -123
- package/dist/components/playground/ControlPanel.svelte.d.ts +3 -0
- package/dist/components/playground/ExecutionLogs.svelte +11 -9
- package/dist/components/playground/InputCollector.svelte +22 -57
- package/dist/components/playground/MessageStream.svelte +17 -23
- package/dist/components/playground/PipelineKanbanView.svelte +69 -8
- package/dist/components/playground/PipelineKanbanView.svelte.d.ts +2 -0
- package/dist/components/playground/PipelinePanel.svelte +31 -8
- package/dist/components/playground/PipelinePanel.svelte.d.ts +2 -0
- package/dist/components/playground/PipelineTableView.svelte +188 -44
- package/dist/components/playground/PipelineTableView.svelte.d.ts +2 -0
- package/dist/components/playground/Playground.svelte +154 -105
- package/dist/components/playground/Playground.svelte.d.ts +5 -0
- package/dist/components/playground/PlaygroundApp.svelte +12 -2
- package/dist/components/playground/PlaygroundApp.svelte.d.ts +6 -0
- package/dist/components/playground/PlaygroundModal.svelte +18 -3
- package/dist/components/playground/PlaygroundModal.svelte.d.ts +6 -0
- package/dist/components/playground/PlaygroundStudio.svelte +40 -37
- package/dist/components/playground/PlaygroundStudio.svelte.d.ts +6 -0
- package/dist/components/playground/SessionManager.svelte +9 -12
- package/dist/components/playground/pipelineViewUtils.svelte.d.ts +30 -1
- package/dist/components/playground/pipelineViewUtils.svelte.js +40 -3
- package/dist/components/surfaces/SurfaceOverlay.svelte +153 -0
- package/dist/components/surfaces/SurfaceOverlay.svelte.d.ts +14 -0
- package/dist/components/surfaces/TabbedSurface.svelte +133 -0
- package/dist/components/surfaces/TabbedSurface.svelte.d.ts +27 -0
- package/dist/config/endpoints.d.ts +23 -7
- package/dist/config/endpoints.js +30 -10
- package/dist/core/index.d.ts +6 -7
- package/dist/core/index.js +8 -12
- package/dist/display/index.d.ts +6 -3
- package/dist/display/index.js +7 -5
- package/dist/editor/index.d.ts +20 -21
- package/dist/editor/index.js +26 -36
- package/dist/form/code.d.ts +25 -15
- package/dist/form/code.js +44 -41
- package/dist/form/fieldRegistry.d.ts +17 -13
- package/dist/form/fieldRegistry.js +32 -12
- package/dist/form/full.d.ts +19 -14
- package/dist/form/full.js +26 -28
- package/dist/form/index.d.ts +3 -4
- package/dist/form/index.js +6 -5
- package/dist/form/markdown.d.ts +13 -8
- package/dist/form/markdown.js +22 -23
- package/dist/helpers/proximityConnect.d.ts +3 -2
- package/dist/helpers/proximityConnect.js +2 -5
- package/dist/helpers/workflowEditorHelper.d.ts +14 -5
- package/dist/helpers/workflowEditorHelper.js +32 -30
- package/dist/index.d.ts +28 -24
- package/dist/index.js +27 -50
- package/dist/messages/defaults.d.ts +2 -5
- package/dist/messages/defaults.js +3 -6
- package/dist/messages/index.d.ts +1 -2
- package/dist/messages/index.js +1 -2
- package/dist/mocks/app-forms.d.ts +6 -2
- package/dist/mocks/app-forms.js +11 -4
- package/dist/openapi/v1/openapi.yaml +38 -26
- package/dist/playground/index.d.ts +4 -5
- package/dist/playground/index.js +4 -32
- package/dist/playground/mount.d.ts +34 -5
- package/dist/playground/mount.js +58 -24
- package/dist/registry/{BaseRegistry.d.ts → BaseRegistry.svelte.d.ts} +22 -1
- package/dist/registry/{BaseRegistry.js → BaseRegistry.svelte.js} +37 -1
- package/dist/registry/builtinFormats.d.ts +9 -18
- package/dist/registry/builtinFormats.js +9 -39
- package/dist/registry/builtinNodeTypes.d.ts +53 -0
- package/dist/registry/builtinNodeTypes.js +67 -0
- package/dist/registry/builtinNodes.d.ts +2 -64
- package/dist/registry/builtinNodes.js +7 -103
- package/dist/registry/index.d.ts +3 -4
- package/dist/registry/index.js +4 -6
- package/dist/registry/nodeComponentRegistry.d.ts +184 -16
- package/dist/registry/nodeComponentRegistry.js +235 -17
- package/dist/registry/workflowFormatRegistry.d.ts +14 -9
- package/dist/registry/workflowFormatRegistry.js +24 -8
- package/dist/{schema → schemas}/index.d.ts +2 -2
- package/dist/{schema → schemas}/index.js +2 -2
- package/dist/schemas/v1/workflow.schema.json +19 -17
- package/dist/services/agentSpecExecutionService.d.ts +0 -2
- package/dist/services/agentSpecExecutionService.js +0 -3
- package/dist/services/apiVariableService.d.ts +2 -1
- package/dist/services/apiVariableService.js +16 -47
- package/dist/services/autoSaveService.d.ts +7 -0
- package/dist/services/autoSaveService.js +6 -4
- package/dist/services/categoriesApi.js +3 -6
- package/dist/services/chatService.d.ts +9 -4
- package/dist/services/chatService.js +23 -28
- package/dist/services/draftStorage.d.ts +129 -13
- package/dist/services/draftStorage.js +185 -37
- package/dist/services/dynamicSchemaService.d.ts +33 -5
- package/dist/services/dynamicSchemaService.js +67 -55
- package/dist/services/globalSave.d.ts +13 -12
- package/dist/services/globalSave.js +29 -51
- package/dist/services/historyService.d.ts +39 -11
- package/dist/services/historyService.js +60 -18
- package/dist/services/interruptService.d.ts +15 -9
- package/dist/services/interruptService.js +35 -37
- package/dist/services/nodeExecutionService.d.ts +18 -3
- package/dist/services/nodeExecutionService.js +71 -45
- package/dist/services/playgroundService.d.ts +16 -10
- package/dist/services/playgroundService.js +42 -43
- package/dist/services/portConfigApi.js +3 -6
- package/dist/services/settingsService.d.ts +9 -4
- package/dist/services/settingsService.js +23 -12
- package/dist/services/variableService.d.ts +2 -1
- package/dist/services/variableService.js +2 -2
- package/dist/services/workflowStorage.js +6 -6
- package/dist/skins/drafter.d.ts +30 -0
- package/dist/skins/drafter.js +198 -0
- package/dist/skins/index.d.ts +2 -1
- package/dist/skins/index.js +4 -2
- package/dist/stores/apiContext.d.ts +56 -0
- package/dist/stores/apiContext.js +80 -0
- package/dist/stores/categoriesStore.svelte.d.ts +28 -23
- package/dist/stores/categoriesStore.svelte.js +69 -64
- package/dist/stores/getInstance.svelte.d.ts +39 -0
- package/dist/stores/getInstance.svelte.js +65 -0
- package/dist/stores/historyStore.svelte.d.ts +89 -91
- package/dist/stores/historyStore.svelte.js +159 -158
- package/dist/stores/instanceContainer.svelte.d.ts +111 -0
- package/dist/stores/instanceContainer.svelte.js +119 -0
- package/dist/stores/interruptStore.svelte.d.ts +112 -82
- package/dist/stores/interruptStore.svelte.js +253 -226
- package/dist/stores/pipelinePanelStore.svelte.d.ts +27 -3
- package/dist/stores/pipelinePanelStore.svelte.js +61 -14
- package/dist/stores/playgroundStore.svelte.d.ts +169 -222
- package/dist/stores/playgroundStore.svelte.js +513 -580
- package/dist/stores/portCoordinateStore.svelte.d.ts +57 -51
- package/dist/stores/portCoordinateStore.svelte.js +109 -98
- package/dist/stores/settingsStore.svelte.d.ts +17 -1
- package/dist/stores/settingsStore.svelte.js +79 -12
- package/dist/stores/workflowStore.svelte.d.ts +212 -210
- package/dist/stores/workflowStore.svelte.js +527 -502
- package/dist/stories/EdgeDecorator.svelte +5 -2
- package/dist/stories/NodeDecorator.svelte +5 -3
- package/dist/styles/base.css +285 -14
- package/dist/styles/tokens.css +60 -2
- package/dist/svelte-app.d.ts +78 -11
- package/dist/svelte-app.js +210 -141
- package/dist/themes/drafter.d.ts +2 -0
- package/dist/themes/drafter.js +15 -0
- package/dist/themes/index.d.ts +2 -1
- package/dist/themes/index.js +8 -2
- package/dist/types/auth.d.ts +9 -51
- package/dist/types/auth.js +4 -54
- package/dist/types/events.d.ts +24 -3
- package/dist/types/events.js +2 -1
- package/dist/types/index.d.ts +117 -32
- package/dist/types/index.js +0 -1
- package/dist/types/navbar.d.ts +7 -0
- package/dist/types/playground.d.ts +18 -3
- package/dist/types/settings.d.ts +30 -1
- package/dist/types/settings.js +5 -2
- package/dist/types/skin.d.ts +1 -1
- package/dist/types/theme.d.ts +16 -2
- package/dist/types/uischema.d.ts +5 -0
- package/dist/utils/colors.d.ts +74 -21
- package/dist/utils/colors.js +92 -68
- package/dist/utils/connections.d.ts +9 -15
- package/dist/utils/connections.js +33 -88
- package/dist/utils/duration.d.ts +13 -0
- package/dist/utils/duration.js +45 -0
- package/dist/utils/edgeStyling.js +9 -5
- package/dist/utils/fetchWithAuth.d.ts +36 -15
- package/dist/utils/fetchWithAuth.js +53 -23
- package/dist/utils/icons.d.ts +5 -2
- package/dist/utils/icons.js +6 -5
- package/dist/utils/nodeIds.d.ts +1 -1
- package/dist/utils/nodeIds.js +1 -1
- package/dist/utils/nodeSwap.d.ts +6 -2
- package/dist/utils/nodeSwap.js +62 -129
- package/dist/utils/nodeTypes.d.ts +17 -8
- package/dist/utils/nodeTypes.js +27 -20
- package/dist/utils/performanceUtils.js +7 -0
- package/dist/utils/portUtils.d.ts +47 -11
- package/dist/utils/portUtils.js +67 -14
- package/dist/utils/portal.d.ts +18 -0
- package/dist/utils/portal.js +34 -0
- package/dist/utils/schemaMerge.d.ts +25 -0
- package/dist/utils/schemaMerge.js +61 -0
- package/package.json +7 -5
- package/dist/messages/deprecation.d.ts +0 -20
- package/dist/messages/deprecation.js +0 -33
- package/dist/registry/plugin.d.ts +0 -215
- package/dist/registry/plugin.js +0 -249
- package/dist/services/api.d.ts +0 -129
- package/dist/services/api.js +0 -217
|
@@ -76,7 +76,7 @@ function executeAddNode(command, context) {
|
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
78
|
const position = command.position ?? computeAutoPosition(workflow.nodes);
|
|
79
|
-
const nodeId = generateNodeId(metadata.
|
|
79
|
+
const nodeId = generateNodeId(metadata.node_type_id, workflow.nodes);
|
|
80
80
|
const config = extractConfigDefaults(metadata.configSchema);
|
|
81
81
|
const node = {
|
|
82
82
|
id: nodeId,
|
|
@@ -86,8 +86,7 @@ function executeAddNode(command, context) {
|
|
|
86
86
|
data: {
|
|
87
87
|
label: metadata.name,
|
|
88
88
|
config,
|
|
89
|
-
metadata
|
|
90
|
-
nodeId
|
|
89
|
+
metadata
|
|
91
90
|
}
|
|
92
91
|
};
|
|
93
92
|
context.dispatch.addNode(node);
|
|
@@ -357,7 +356,7 @@ function executeInfo(command, context) {
|
|
|
357
356
|
const resultData = {
|
|
358
357
|
nodeId: shortId,
|
|
359
358
|
label: node.data.label ?? metadata?.name ?? '',
|
|
360
|
-
type: metadata?.
|
|
359
|
+
type: metadata?.node_type_id ? toShortTypeId(metadata.node_type_id) : '',
|
|
361
360
|
position: node.position,
|
|
362
361
|
config: node.data.config ?? {},
|
|
363
362
|
inputs,
|
|
@@ -379,38 +378,49 @@ function executeInfo(command, context) {
|
|
|
379
378
|
*/
|
|
380
379
|
function findPort(node, portId, preferDirection) {
|
|
381
380
|
const metadata = node.data?.metadata;
|
|
382
|
-
|
|
381
|
+
const config = node.data?.config;
|
|
382
|
+
if (!metadata && !config)
|
|
383
383
|
return null;
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
if (
|
|
390
|
-
return
|
|
391
|
-
|
|
392
|
-
|
|
384
|
+
// Resolve an output port from static metadata or config-driven ports. The
|
|
385
|
+
// latter are not in metadata.outputs: gateway branches live in config.branches
|
|
386
|
+
// and user-defined handles live in config.dynamicOutputs (both keyed by name).
|
|
387
|
+
const resolveOutput = () => {
|
|
388
|
+
const meta = metadata?.outputs?.find((p) => p.id === portId);
|
|
389
|
+
if (meta)
|
|
390
|
+
return meta;
|
|
391
|
+
const branch = config?.branches?.find((b) => b.name === portId);
|
|
392
|
+
if (branch)
|
|
393
|
+
return { id: portId, name: branch.label ?? portId, dataType: 'trigger' };
|
|
394
|
+
const dynamic = config?.dynamicOutputs?.find((p) => p.name === portId);
|
|
395
|
+
if (dynamic)
|
|
396
|
+
return { id: portId, name: dynamic.label ?? portId, dataType: dynamic.dataType };
|
|
397
|
+
return null;
|
|
398
|
+
};
|
|
399
|
+
// Resolve an input port from static metadata or config.dynamicInputs.
|
|
400
|
+
const resolveInput = () => {
|
|
401
|
+
const meta = metadata?.inputs?.find((p) => p.id === portId);
|
|
402
|
+
if (meta)
|
|
403
|
+
return meta;
|
|
404
|
+
const dynamic = config?.dynamicInputs?.find((p) => p.name === portId);
|
|
405
|
+
if (dynamic)
|
|
406
|
+
return { id: portId, name: dynamic.label ?? portId, dataType: dynamic.dataType };
|
|
407
|
+
return null;
|
|
408
|
+
};
|
|
409
|
+
const outputPort = resolveOutput();
|
|
410
|
+
const inputPort = resolveInput();
|
|
411
|
+
if (preferDirection === 'input') {
|
|
393
412
|
if (inputPort)
|
|
394
413
|
return { port: inputPort, direction: 'input' };
|
|
395
414
|
if (outputPort)
|
|
396
415
|
return { port: outputPort, direction: 'output' };
|
|
397
416
|
}
|
|
398
417
|
else {
|
|
418
|
+
// Default and explicit 'output' both prefer the output port first.
|
|
399
419
|
if (outputPort)
|
|
400
420
|
return { port: outputPort, direction: 'output' };
|
|
401
421
|
if (inputPort)
|
|
402
422
|
return { port: inputPort, direction: 'input' };
|
|
403
423
|
}
|
|
404
|
-
// Gateway nodes have dynamic branch ports stored in config.branches, not metadata.outputs
|
|
405
|
-
if (metadata.type === 'gateway') {
|
|
406
|
-
const branches = node.data.config?.branches;
|
|
407
|
-
if (branches?.some((b) => b.name === portId)) {
|
|
408
|
-
return {
|
|
409
|
-
port: { id: portId, name: portId, dataType: 'trigger' },
|
|
410
|
-
direction: 'output'
|
|
411
|
-
};
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
424
|
return null;
|
|
415
425
|
}
|
|
416
426
|
function executeConnect(command, context) {
|
|
@@ -484,6 +494,21 @@ function executeConnect(command, context) {
|
|
|
484
494
|
const targetHandle = buildHandleId(targetNode.id, 'input', command.targetPort);
|
|
485
495
|
// Generate edge ID
|
|
486
496
|
const edgeId = `${sourceNode.id}-${sourceHandle}-${targetNode.id}-${targetHandle}`;
|
|
497
|
+
// Idempotency guard: re-applying the same connection (e.g. a second
|
|
498
|
+
// AI-assistant Apply that re-emits an existing edge) must not append a
|
|
499
|
+
// duplicate. Two edges sharing an id crash the canvas with Svelte's
|
|
500
|
+
// `each_key_duplicate`. Treat an existing identical connection as a no-op.
|
|
501
|
+
const alreadyConnected = workflow.edges.some((e) => e.id === edgeId ||
|
|
502
|
+
(e.source === sourceNode.id &&
|
|
503
|
+
e.target === targetNode.id &&
|
|
504
|
+
e.sourceHandle === sourceHandle &&
|
|
505
|
+
e.targetHandle === targetHandle));
|
|
506
|
+
if (alreadyConnected) {
|
|
507
|
+
return {
|
|
508
|
+
ok: true,
|
|
509
|
+
message: `Already connected ${toShortId(sourceNode.id)}:${command.sourcePort} → ${toShortId(targetNode.id)}:${command.targetPort}`
|
|
510
|
+
};
|
|
511
|
+
}
|
|
487
512
|
// Build edge
|
|
488
513
|
const edge = {
|
|
489
514
|
id: edgeId,
|
|
@@ -578,7 +603,7 @@ function executeListNodes(context) {
|
|
|
578
603
|
const nodes = workflow.nodes.map((n) => ({
|
|
579
604
|
nodeId: toShortId(n.id),
|
|
580
605
|
label: n.data.label ?? n.data.metadata?.name ?? '',
|
|
581
|
-
type: n.data.metadata?.
|
|
606
|
+
type: n.data.metadata?.node_type_id ? toShortTypeId(n.data.metadata.node_type_id) : ''
|
|
582
607
|
}));
|
|
583
608
|
const resultData = { nodes };
|
|
584
609
|
return {
|
|
@@ -610,7 +635,7 @@ function executeListEdges(context) {
|
|
|
610
635
|
}
|
|
611
636
|
function executeListTypes(context) {
|
|
612
637
|
const types = context.nodeTypes.map((m) => ({
|
|
613
|
-
typeId: toShortTypeId(m.
|
|
638
|
+
typeId: toShortTypeId(m.node_type_id),
|
|
614
639
|
name: m.name,
|
|
615
640
|
category: m.category
|
|
616
641
|
}));
|
|
@@ -888,17 +913,31 @@ function executeSwapNode(command, context) {
|
|
|
888
913
|
edges: swapResult.updatedEdges
|
|
889
914
|
});
|
|
890
915
|
}
|
|
916
|
+
// Name each dropped edge so the user can see exactly what was lost
|
|
917
|
+
const droppedEdgeDetails = preview.droppedEdges.map(({ edge }) => {
|
|
918
|
+
const sourcePort = extractPortId(edge.sourceHandle ?? undefined) ?? '?';
|
|
919
|
+
const targetPort = extractPortId(edge.targetHandle ?? undefined) ?? '?';
|
|
920
|
+
return `${toShortId(edge.source)}:${sourcePort} → ${toShortId(edge.target)}:${targetPort}`;
|
|
921
|
+
});
|
|
891
922
|
const resultData = {
|
|
892
923
|
oldNodeId: toShortId(node.id),
|
|
893
924
|
newNodeId: toShortId(preview.newNodeId),
|
|
894
925
|
newType: command.newTypeId,
|
|
895
926
|
keptEdges: preview.keptEdges.length,
|
|
896
927
|
droppedEdges: preview.droppedEdges.length,
|
|
928
|
+
droppedEdgeDetails,
|
|
897
929
|
hasDataLoss: preview.hasDataLoss,
|
|
898
930
|
configCarriedOver: preview.configCarriedOver,
|
|
899
931
|
configReset: preview.configReset
|
|
900
932
|
};
|
|
901
|
-
|
|
933
|
+
// Cap the inline list — a badly mismatched swap can drop dozens of edges,
|
|
934
|
+
// and the full list is always available in resultData.droppedEdgeDetails
|
|
935
|
+
const MAX_NAMED_DROPPED_EDGES = 5;
|
|
936
|
+
const namedDropped = droppedEdgeDetails.slice(0, MAX_NAMED_DROPPED_EDGES);
|
|
937
|
+
const unnamedCount = droppedEdgeDetails.length - namedDropped.length;
|
|
938
|
+
const droppedMsg = preview.droppedEdges.length > 0
|
|
939
|
+
? ` (${preview.droppedEdges.length} edge(s) dropped: ${namedDropped.join(', ')}${unnamedCount > 0 ? `, … and ${unnamedCount} more` : ''})`
|
|
940
|
+
: '';
|
|
902
941
|
return {
|
|
903
942
|
ok: true,
|
|
904
943
|
message: `Swapped ${toShortId(node.id)} → ${toShortId(preview.newNodeId)} (${command.newTypeId})${droppedMsg}`,
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Bridges the command system to the live Svelte stores.
|
|
5
5
|
* This is the only Svelte-coupled file in commands/.
|
|
6
6
|
*/
|
|
7
|
+
import { type FlowDropInstance } from '../stores/instanceContainer.svelte.js';
|
|
7
8
|
import { type CommandContext, type UIAction } from './types.js';
|
|
8
9
|
import type { NodeMetadata } from '../types/index.js';
|
|
9
10
|
/**
|
|
@@ -11,6 +12,8 @@ import type { NodeMetadata } from '../types/index.js';
|
|
|
11
12
|
*
|
|
12
13
|
* @param nodeTypes - Available node type definitions
|
|
13
14
|
* @param onUIAction - Optional callback for UI-side actions (open config panel, select node)
|
|
15
|
+
* @param instance - The FlowDrop instance to operate on; defaults to the
|
|
16
|
+
* page-default instance when omitted
|
|
14
17
|
* @returns CommandContext connected to live stores, or null if no workflow is loaded
|
|
15
18
|
*/
|
|
16
|
-
export declare function createStoreCommandContext(nodeTypes: NodeMetadata[], onUIAction?: (action: UIAction) => void): CommandContext | null;
|
|
19
|
+
export declare function createStoreCommandContext(nodeTypes: NodeMetadata[], onUIAction?: (action: UIAction) => void, instance?: FlowDropInstance): CommandContext | null;
|
|
@@ -4,62 +4,77 @@
|
|
|
4
4
|
* Bridges the command system to the live Svelte stores.
|
|
5
5
|
* This is the only Svelte-coupled file in commands/.
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
8
|
-
import { historyService } from '../services/historyService.js';
|
|
7
|
+
import { getDefaultInstance } from '../stores/instanceContainer.svelte.js';
|
|
9
8
|
import { buildTypeMap } from './types.js';
|
|
10
9
|
/**
|
|
11
10
|
* Creates a CommandContext that bridges the command system to the live Svelte stores.
|
|
12
11
|
*
|
|
13
12
|
* @param nodeTypes - Available node type definitions
|
|
14
13
|
* @param onUIAction - Optional callback for UI-side actions (open config panel, select node)
|
|
14
|
+
* @param instance - The FlowDrop instance to operate on; defaults to the
|
|
15
|
+
* page-default instance when omitted
|
|
15
16
|
* @returns CommandContext connected to live stores, or null if no workflow is loaded
|
|
16
17
|
*/
|
|
17
|
-
export function createStoreCommandContext(nodeTypes, onUIAction) {
|
|
18
|
-
const
|
|
18
|
+
export function createStoreCommandContext(nodeTypes, onUIAction, instance) {
|
|
19
|
+
const fd = instance ?? getDefaultInstance();
|
|
20
|
+
const readWorkflow = () => fd.workflow.current;
|
|
21
|
+
const actions = fd.workflow.actions;
|
|
22
|
+
const history = fd.history;
|
|
23
|
+
const workflow = readWorkflow();
|
|
19
24
|
if (!workflow) {
|
|
20
25
|
return null;
|
|
21
26
|
}
|
|
22
27
|
const dispatch = {
|
|
23
|
-
addNode: (node) =>
|
|
24
|
-
removeNode: (nodeId) =>
|
|
25
|
-
updateNode: (nodeId, updates) =>
|
|
26
|
-
addEdge: (edge) =>
|
|
27
|
-
removeEdge: (edgeId) =>
|
|
28
|
-
batchUpdate: (updates) =>
|
|
28
|
+
addNode: (node) => actions.addNode(node),
|
|
29
|
+
removeNode: (nodeId) => actions.removeNode(nodeId),
|
|
30
|
+
updateNode: (nodeId, updates) => actions.updateNode(nodeId, updates),
|
|
31
|
+
addEdge: (edge) => actions.addEdge(edge),
|
|
32
|
+
removeEdge: (edgeId) => actions.removeEdge(edgeId),
|
|
33
|
+
batchUpdate: (updates) => actions.batchUpdate(updates),
|
|
29
34
|
undo: () => {
|
|
30
|
-
|
|
35
|
+
// Flush a pending edit session into a committed step before undoing it.
|
|
36
|
+
actions.finalizeNodeConfig();
|
|
37
|
+
const previousState = history.undo();
|
|
31
38
|
if (previousState) {
|
|
32
|
-
|
|
39
|
+
actions.restoreFromHistory(previousState);
|
|
33
40
|
return true;
|
|
34
41
|
}
|
|
35
42
|
return false;
|
|
36
43
|
},
|
|
37
44
|
redo: () => {
|
|
38
|
-
|
|
45
|
+
actions.finalizeNodeConfig();
|
|
46
|
+
const nextState = history.redo();
|
|
39
47
|
if (nextState) {
|
|
40
|
-
|
|
48
|
+
actions.restoreFromHistory(nextState);
|
|
41
49
|
return true;
|
|
42
50
|
}
|
|
43
51
|
return false;
|
|
44
52
|
},
|
|
45
53
|
startTransaction: (description) => {
|
|
46
|
-
const currentWorkflow =
|
|
54
|
+
const currentWorkflow = readWorkflow();
|
|
47
55
|
if (currentWorkflow) {
|
|
48
|
-
|
|
56
|
+
history.startTransaction(currentWorkflow, description);
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
// Commit the transaction's post-change (current) state so one undo reverts
|
|
60
|
+
// the whole batch and redo restores its result (issue #39).
|
|
61
|
+
commitTransaction: () => {
|
|
62
|
+
const currentWorkflow = readWorkflow();
|
|
63
|
+
if (currentWorkflow) {
|
|
64
|
+
history.commitTransaction(currentWorkflow);
|
|
49
65
|
}
|
|
50
66
|
},
|
|
51
|
-
commitTransaction: () => historyService.commitTransaction(),
|
|
52
67
|
cancelTransaction: () => {
|
|
53
|
-
const snapshot =
|
|
68
|
+
const snapshot = history.cancelTransaction();
|
|
54
69
|
if (snapshot) {
|
|
55
|
-
|
|
70
|
+
actions.restoreFromHistory(snapshot);
|
|
56
71
|
}
|
|
57
72
|
},
|
|
58
73
|
emitUIAction: onUIAction,
|
|
59
|
-
swapNode: (updates) =>
|
|
74
|
+
swapNode: (updates) => actions.swapNode(updates)
|
|
60
75
|
};
|
|
61
76
|
return {
|
|
62
|
-
getWorkflow: () =>
|
|
77
|
+
getWorkflow: () => readWorkflow(),
|
|
63
78
|
nodeTypes,
|
|
64
79
|
typeMap: buildTypeMap(nodeTypes),
|
|
65
80
|
dispatch
|
package/dist/commands/types.d.ts
CHANGED
|
@@ -244,6 +244,8 @@ export interface SwapNodeResultData {
|
|
|
244
244
|
newType: string;
|
|
245
245
|
keptEdges: number;
|
|
246
246
|
droppedEdges: number;
|
|
247
|
+
/** Human-readable descriptions of each dropped edge, e.g. "node.1:text → node.2:message" */
|
|
248
|
+
droppedEdgeDetails: string[];
|
|
247
249
|
hasDataLoss: boolean;
|
|
248
250
|
configCarriedOver: string[];
|
|
249
251
|
configReset: string[];
|
package/dist/commands/types.js
CHANGED
|
@@ -24,18 +24,18 @@ export function buildTypeMap(nodeTypes) {
|
|
|
24
24
|
const shortIdCounts = new Map();
|
|
25
25
|
// First pass: register full IDs and count short ID occurrences
|
|
26
26
|
for (const metadata of nodeTypes) {
|
|
27
|
-
map.set(metadata.
|
|
28
|
-
const dotIndex = metadata.
|
|
27
|
+
map.set(metadata.node_type_id, metadata);
|
|
28
|
+
const dotIndex = metadata.node_type_id.indexOf('.');
|
|
29
29
|
if (dotIndex !== -1) {
|
|
30
|
-
const shortId = metadata.
|
|
30
|
+
const shortId = metadata.node_type_id.substring(dotIndex + 1);
|
|
31
31
|
shortIdCounts.set(shortId, (shortIdCounts.get(shortId) ?? 0) + 1);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
// Second pass: register unique short IDs
|
|
35
35
|
for (const metadata of nodeTypes) {
|
|
36
|
-
const dotIndex = metadata.
|
|
36
|
+
const dotIndex = metadata.node_type_id.indexOf('.');
|
|
37
37
|
if (dotIndex !== -1) {
|
|
38
|
-
const shortId = metadata.
|
|
38
|
+
const shortId = metadata.node_type_id.substring(dotIndex + 1);
|
|
39
39
|
if (shortIdCounts.get(shortId) === 1) {
|
|
40
40
|
map.set(shortId, metadata);
|
|
41
41
|
}
|