@foresthubai/workflow-builder 0.4.3 → 0.4.5
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/LICENSE +661 -661
- package/NOTICE +16 -16
- package/README.md +110 -110
- package/dist/BuilderLayout.d.ts.map +1 -1
- package/dist/BuilderLayout.js +52 -61
- package/dist/BuilderLayout.js.map +1 -1
- package/dist/Canvas.d.ts.map +1 -1
- package/dist/Canvas.js +10 -3
- package/dist/Canvas.js.map +1 -1
- package/dist/CanvasEditor.d.ts.map +1 -1
- package/dist/CanvasEditor.js.map +1 -1
- package/dist/CanvasTabsToolbar.d.ts.map +1 -1
- package/dist/CanvasTabsToolbar.js +3 -0
- package/dist/CanvasTabsToolbar.js.map +1 -1
- package/dist/RightConfigPanel.d.ts.map +1 -1
- package/dist/RightConfigPanel.js +3 -0
- package/dist/RightConfigPanel.js.map +1 -1
- package/dist/WorkflowBuilder.d.ts +7 -13
- package/dist/WorkflowBuilder.d.ts.map +1 -1
- package/dist/WorkflowBuilder.js +25 -13
- package/dist/WorkflowBuilder.js.map +1 -1
- package/dist/cn.d.ts.map +1 -1
- package/dist/cn.js +3 -0
- package/dist/cn.js.map +1 -1
- package/dist/components/ui/add-button.d.ts.map +1 -1
- package/dist/components/ui/add-button.js +3 -0
- package/dist/components/ui/add-button.js.map +1 -1
- package/dist/components/ui/alert-dialog.d.ts.map +1 -1
- package/dist/components/ui/alert-dialog.js +3 -0
- package/dist/components/ui/alert-dialog.js.map +1 -1
- package/dist/components/ui/alert.d.ts.map +1 -1
- package/dist/components/ui/alert.js +3 -0
- package/dist/components/ui/alert.js.map +1 -1
- package/dist/components/ui/badge.d.ts.map +1 -1
- package/dist/components/ui/badge.js.map +1 -1
- package/dist/components/ui/button.d.ts.map +1 -1
- package/dist/components/ui/button.js +3 -0
- package/dist/components/ui/button.js.map +1 -1
- package/dist/components/ui/card.d.ts.map +1 -1
- package/dist/components/ui/card.js +3 -0
- package/dist/components/ui/card.js.map +1 -1
- package/dist/components/ui/checkbox.d.ts.map +1 -1
- package/dist/components/ui/checkbox.js +3 -0
- package/dist/components/ui/checkbox.js.map +1 -1
- package/dist/components/ui/collapsible.d.ts.map +1 -1
- package/dist/components/ui/collapsible.js +3 -0
- package/dist/components/ui/collapsible.js.map +1 -1
- package/dist/components/ui/command.d.ts +2 -2
- package/dist/components/ui/command.d.ts.map +1 -1
- package/dist/components/ui/command.js +3 -0
- package/dist/components/ui/command.js.map +1 -1
- package/dist/components/ui/delete-button.d.ts.map +1 -1
- package/dist/components/ui/delete-button.js +3 -0
- package/dist/components/ui/delete-button.js.map +1 -1
- package/dist/components/ui/dialog.d.ts.map +1 -1
- package/dist/components/ui/dialog.js +3 -0
- package/dist/components/ui/dialog.js.map +1 -1
- package/dist/components/ui/dropdown-menu.d.ts.map +1 -1
- package/dist/components/ui/dropdown-menu.js +3 -0
- package/dist/components/ui/dropdown-menu.js.map +1 -1
- package/dist/components/ui/input.d.ts +1 -1
- package/dist/components/ui/input.d.ts.map +1 -1
- package/dist/components/ui/input.js +3 -0
- package/dist/components/ui/input.js.map +1 -1
- package/dist/components/ui/label.d.ts.map +1 -1
- package/dist/components/ui/label.js +3 -0
- package/dist/components/ui/label.js.map +1 -1
- package/dist/components/ui/readonly-banner.d.ts.map +1 -1
- package/dist/components/ui/readonly-banner.js +3 -0
- package/dist/components/ui/readonly-banner.js.map +1 -1
- package/dist/components/ui/resizable.d.ts +1 -1
- package/dist/components/ui/resizable.d.ts.map +1 -1
- package/dist/components/ui/resizable.js +3 -0
- package/dist/components/ui/resizable.js.map +1 -1
- package/dist/components/ui/scroll-area.d.ts.map +1 -1
- package/dist/components/ui/scroll-area.js +3 -0
- package/dist/components/ui/scroll-area.js.map +1 -1
- package/dist/components/ui/select.d.ts.map +1 -1
- package/dist/components/ui/select.js +3 -0
- package/dist/components/ui/select.js.map +1 -1
- package/dist/components/ui/separator.d.ts.map +1 -1
- package/dist/components/ui/separator.js +3 -0
- package/dist/components/ui/separator.js.map +1 -1
- package/dist/components/ui/switch.d.ts.map +1 -1
- package/dist/components/ui/switch.js +3 -0
- package/dist/components/ui/switch.js.map +1 -1
- package/dist/components/ui/textarea.d.ts +1 -1
- package/dist/components/ui/textarea.d.ts.map +1 -1
- package/dist/components/ui/textarea.js +3 -0
- package/dist/components/ui/textarea.js.map +1 -1
- package/dist/components/ui/toast.d.ts.map +1 -1
- package/dist/components/ui/toast.js +3 -0
- package/dist/components/ui/toast.js.map +1 -1
- package/dist/components/ui/toaster.d.ts.map +1 -1
- package/dist/components/ui/toaster.js +3 -0
- package/dist/components/ui/toaster.js.map +1 -1
- package/dist/components/ui/toggle-group.d.ts.map +1 -1
- package/dist/components/ui/toggle-group.js +3 -0
- package/dist/components/ui/toggle-group.js.map +1 -1
- package/dist/components/ui/toggle.d.ts.map +1 -1
- package/dist/components/ui/toggle.js +3 -0
- package/dist/components/ui/toggle.js.map +1 -1
- package/dist/components/ui/tooltip.d.ts.map +1 -1
- package/dist/components/ui/tooltip.js +3 -0
- package/dist/components/ui/tooltip.js.map +1 -1
- package/dist/dialogs/NodePickerDialog.d.ts.map +1 -1
- package/dist/dialogs/NodePickerDialog.js +3 -0
- package/dist/dialogs/NodePickerDialog.js.map +1 -1
- package/dist/dialogs/ValidationDialog.d.ts.map +1 -1
- package/dist/dialogs/ValidationDialog.js +3 -0
- package/dist/dialogs/ValidationDialog.js.map +1 -1
- package/dist/graph/BaseNode.d.ts.map +1 -1
- package/dist/graph/BaseNode.js +21 -16
- package/dist/graph/BaseNode.js.map +1 -1
- package/dist/graph/CustomEdge.d.ts.map +1 -1
- package/dist/graph/CustomEdge.js +4 -1
- package/dist/graph/CustomEdge.js.map +1 -1
- package/dist/graph/CustomNode.d.ts.map +1 -1
- package/dist/graph/CustomNode.js +3 -0
- package/dist/graph/CustomNode.js.map +1 -1
- package/dist/graph/FunctionCallNode.d.ts.map +1 -1
- package/dist/graph/FunctionCallNode.js.map +1 -1
- package/dist/graph/PortHandle.d.ts.map +1 -1
- package/dist/graph/PortHandle.js.map +1 -1
- package/dist/graph/reactFlowRegistry.d.ts.map +1 -1
- package/dist/graph/reactFlowRegistry.js +3 -0
- package/dist/graph/reactFlowRegistry.js.map +1 -1
- package/dist/hooks/use-toast.d.ts.map +1 -1
- package/dist/hooks/use-toast.js +3 -0
- package/dist/hooks/use-toast.js.map +1 -1
- package/dist/hooks/useAvailableVariables.d.ts.map +1 -1
- package/dist/hooks/useAvailableVariables.js +3 -0
- package/dist/hooks/useAvailableVariables.js.map +1 -1
- package/dist/hooks/useCanvasHistory.d.ts.map +1 -1
- package/dist/hooks/useCanvasHistory.js +3 -0
- package/dist/hooks/useCanvasHistory.js.map +1 -1
- package/dist/hooks/useCanvasTabs.d.ts.map +1 -1
- package/dist/hooks/useCanvasTabs.js +3 -0
- package/dist/hooks/useCanvasTabs.js.map +1 -1
- package/dist/hooks/useFunctionDiagnosticsSync.d.ts.map +1 -1
- package/dist/hooks/useFunctionDiagnosticsSync.js +3 -0
- package/dist/hooks/useFunctionDiagnosticsSync.js.map +1 -1
- package/dist/hooks/useFunctionRegistry.d.ts.map +1 -1
- package/dist/hooks/useFunctionRegistry.js +3 -0
- package/dist/hooks/useFunctionRegistry.js.map +1 -1
- package/dist/hooks/useFunctions.d.ts.map +1 -1
- package/dist/hooks/useFunctions.js +3 -0
- package/dist/hooks/useFunctions.js.map +1 -1
- package/dist/hooks/useGraph.d.ts.map +1 -1
- package/dist/hooks/useGraph.js +3 -0
- package/dist/hooks/useGraph.js.map +1 -1
- package/dist/hooks/useNodeDefinitions.d.ts.map +1 -1
- package/dist/hooks/useNodeDefinitions.js +3 -0
- package/dist/hooks/useNodeDefinitions.js.map +1 -1
- package/dist/hooks/useParamErrors.d.ts.map +1 -1
- package/dist/hooks/useParamErrors.js +3 -0
- package/dist/hooks/useParamErrors.js.map +1 -1
- package/dist/hooks/useResolvedTheme.d.ts.map +1 -1
- package/dist/hooks/useResolvedTheme.js +3 -0
- package/dist/hooks/useResolvedTheme.js.map +1 -1
- package/dist/hooks/useResourceDiagnosticsSync.d.ts.map +1 -1
- package/dist/hooks/useResourceDiagnosticsSync.js +3 -0
- package/dist/hooks/useResourceDiagnosticsSync.js.map +1 -1
- package/dist/hooks/useSuppressThemeTransition.d.ts.map +1 -1
- package/dist/hooks/useSuppressThemeTransition.js +3 -0
- package/dist/hooks/useSuppressThemeTransition.js.map +1 -1
- package/dist/hooks/useWorkflowSerialization.d.ts.map +1 -1
- package/dist/hooks/useWorkflowSerialization.js +3 -0
- package/dist/hooks/useWorkflowSerialization.js.map +1 -1
- package/dist/i18n/index.d.ts.map +1 -1
- package/dist/i18n/index.js +3 -0
- package/dist/i18n/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/inputs/ExpressionInput.d.ts.map +1 -1
- package/dist/inputs/ExpressionInput.js +3 -0
- package/dist/inputs/ExpressionInput.js.map +1 -1
- package/dist/inputs/ParameterEditor.d.ts.map +1 -1
- package/dist/inputs/ParameterEditor.js +3 -0
- package/dist/inputs/ParameterEditor.js.map +1 -1
- package/dist/inputs/PortSection.d.ts.map +1 -1
- package/dist/inputs/PortSection.js.map +1 -1
- package/dist/mode.d.ts +11 -0
- package/dist/mode.d.ts.map +1 -0
- package/dist/mode.js +8 -0
- package/dist/mode.js.map +1 -0
- package/dist/panels/BuilderSidebar.d.ts.map +1 -1
- package/dist/panels/BuilderSidebar.js +3 -0
- package/dist/panels/BuilderSidebar.js.map +1 -1
- package/dist/panels/ChannelConfigPanel.d.ts.map +1 -1
- package/dist/panels/ChannelConfigPanel.js +3 -0
- package/dist/panels/ChannelConfigPanel.js.map +1 -1
- package/dist/panels/ChannelsPanel.d.ts.map +1 -1
- package/dist/panels/ChannelsPanel.js +3 -0
- package/dist/panels/ChannelsPanel.js.map +1 -1
- package/dist/panels/DebugConsolePanel.d.ts.map +1 -1
- package/dist/panels/DebugConsolePanel.js +3 -0
- package/dist/panels/DebugConsolePanel.js.map +1 -1
- package/dist/panels/DebugContextPanel.d.ts.map +1 -1
- package/dist/panels/DebugContextPanel.js +3 -0
- package/dist/panels/DebugContextPanel.js.map +1 -1
- package/dist/panels/DebugExternalIOPanel.d.ts.map +1 -1
- package/dist/panels/DebugExternalIOPanel.js +3 -0
- package/dist/panels/DebugExternalIOPanel.js.map +1 -1
- package/dist/panels/DiagnosticsPanel.d.ts.map +1 -1
- package/dist/panels/DiagnosticsPanel.js +3 -0
- package/dist/panels/DiagnosticsPanel.js.map +1 -1
- package/dist/panels/EdgeConfigPanel.d.ts.map +1 -1
- package/dist/panels/EdgeConfigPanel.js +4 -1
- package/dist/panels/EdgeConfigPanel.js.map +1 -1
- package/dist/panels/FunctionConfigPanel.d.ts.map +1 -1
- package/dist/panels/FunctionConfigPanel.js +4 -1
- package/dist/panels/FunctionConfigPanel.js.map +1 -1
- package/dist/panels/FunctionListPanel.d.ts.map +1 -1
- package/dist/panels/FunctionListPanel.js +3 -0
- package/dist/panels/FunctionListPanel.js.map +1 -1
- package/dist/panels/MemoryConfigPanel.d.ts.map +1 -1
- package/dist/panels/MemoryConfigPanel.js +3 -0
- package/dist/panels/MemoryConfigPanel.js.map +1 -1
- package/dist/panels/MemoryPanel.d.ts.map +1 -1
- package/dist/panels/MemoryPanel.js +3 -0
- package/dist/panels/MemoryPanel.js.map +1 -1
- package/dist/panels/ModelConfigPanel.d.ts.map +1 -1
- package/dist/panels/ModelConfigPanel.js +3 -0
- package/dist/panels/ModelConfigPanel.js.map +1 -1
- package/dist/panels/ModelsPanel.d.ts.map +1 -1
- package/dist/panels/ModelsPanel.js +3 -0
- package/dist/panels/ModelsPanel.js.map +1 -1
- package/dist/panels/NodeConfigPanel.d.ts.map +1 -1
- package/dist/panels/NodeConfigPanel.js +4 -1
- package/dist/panels/NodeConfigPanel.js.map +1 -1
- package/dist/panels/NodeLibrary.d.ts.map +1 -1
- package/dist/panels/NodeLibrary.js +4 -1
- package/dist/panels/NodeLibrary.js.map +1 -1
- package/dist/panels/ResourceConfigPanel.d.ts.map +1 -1
- package/dist/panels/ResourceConfigPanel.js +4 -1
- package/dist/panels/ResourceConfigPanel.js.map +1 -1
- package/dist/panels/ResourceListPanel.d.ts.map +1 -1
- package/dist/panels/ResourceListPanel.js +4 -1
- package/dist/panels/ResourceListPanel.js.map +1 -1
- package/dist/panels/VariableConfigPanel.d.ts.map +1 -1
- package/dist/panels/VariableConfigPanel.js +4 -1
- package/dist/panels/VariableConfigPanel.js.map +1 -1
- package/dist/panels/VariablesPanel.d.ts.map +1 -1
- package/dist/panels/VariablesPanel.js +4 -1
- package/dist/panels/VariablesPanel.js.map +1 -1
- package/dist/stores/canvasStore.d.ts.map +1 -1
- package/dist/stores/canvasStore.js +3 -0
- package/dist/stores/canvasStore.js.map +1 -1
- package/dist/stores/debugStore.d.ts.map +1 -1
- package/dist/stores/debugStore.js +3 -0
- package/dist/stores/debugStore.js.map +1 -1
- package/dist/stores/diagnosticsStore.d.ts.map +1 -1
- package/dist/stores/diagnosticsStore.js +3 -0
- package/dist/stores/diagnosticsStore.js.map +1 -1
- package/dist/stores/editorStore.d.ts +1 -1
- package/dist/stores/editorStore.d.ts.map +1 -1
- package/dist/stores/editorStore.js +3 -0
- package/dist/stores/editorStore.js.map +1 -1
- package/dist/utils/categoryConstants.d.ts.map +1 -1
- package/dist/utils/categoryConstants.js +3 -0
- package/dist/utils/categoryConstants.js.map +1 -1
- package/dist/utils/channelOperations.d.ts.map +1 -1
- package/dist/utils/channelOperations.js +3 -0
- package/dist/utils/channelOperations.js.map +1 -1
- package/dist/utils/connectionRules.d.ts +3 -1
- package/dist/utils/connectionRules.d.ts.map +1 -1
- package/dist/utils/connectionRules.js +11 -16
- package/dist/utils/connectionRules.js.map +1 -1
- package/dist/utils/functionOperations.d.ts.map +1 -1
- package/dist/utils/functionOperations.js +3 -0
- package/dist/utils/functionOperations.js.map +1 -1
- package/dist/utils/graphOperations.d.ts.map +1 -1
- package/dist/utils/graphOperations.js +3 -0
- package/dist/utils/graphOperations.js.map +1 -1
- package/dist/utils/history.d.ts.map +1 -1
- package/dist/utils/history.js +4 -1
- package/dist/utils/history.js.map +1 -1
- package/dist/utils/memoryOperations.d.ts.map +1 -1
- package/dist/utils/memoryOperations.js +3 -0
- package/dist/utils/memoryOperations.js.map +1 -1
- package/dist/utils/migrateFunctionNodes.d.ts.map +1 -1
- package/dist/utils/migrateFunctionNodes.js +3 -0
- package/dist/utils/migrateFunctionNodes.js.map +1 -1
- package/dist/utils/modelOperations.d.ts.map +1 -1
- package/dist/utils/modelOperations.js +3 -0
- package/dist/utils/modelOperations.js.map +1 -1
- package/dist/utils/paramDisplay.d.ts.map +1 -1
- package/dist/utils/paramDisplay.js +3 -0
- package/dist/utils/paramDisplay.js.map +1 -1
- package/dist/utils/resourceHelpers.d.ts.map +1 -1
- package/dist/utils/resourceHelpers.js +3 -0
- package/dist/utils/resourceHelpers.js.map +1 -1
- package/dist/utils/translation.d.ts.map +1 -1
- package/dist/utils/translation.js +3 -0
- package/dist/utils/translation.js.map +1 -1
- package/dist/utils/variableOperations.d.ts.map +1 -1
- package/dist/utils/variableOperations.js +3 -0
- package/dist/utils/variableOperations.js.map +1 -1
- package/package.json +2 -2
- package/src/BuilderLayout.tsx +338 -345
- package/src/Canvas.tsx +270 -261
- package/src/CanvasEditor.tsx +146 -142
- package/src/CanvasTabsToolbar.tsx +180 -176
- package/src/RightConfigPanel.tsx +270 -266
- package/src/WorkflowBuilder.tsx +423 -408
- package/src/cn.ts +10 -6
- package/src/components/ui/add-button.tsx +43 -39
- package/src/components/ui/alert-dialog.tsx +145 -141
- package/src/components/ui/alert.tsx +63 -59
- package/src/components/ui/badge.tsx +40 -36
- package/src/components/ui/button.tsx +89 -85
- package/src/components/ui/card.tsx +83 -79
- package/src/components/ui/checkbox.tsx +32 -28
- package/src/components/ui/collapsible.tsx +13 -9
- package/src/components/ui/command.tsx +157 -153
- package/src/components/ui/delete-button.tsx +27 -23
- package/src/components/ui/dialog.tsx +129 -125
- package/src/components/ui/dropdown-menu.tsx +202 -198
- package/src/components/ui/input.tsx +59 -55
- package/src/components/ui/label.tsx +28 -24
- package/src/components/ui/readonly-banner.tsx +19 -15
- package/src/components/ui/resizable.tsx +47 -43
- package/src/components/ui/scroll-area.tsx +106 -102
- package/src/components/ui/select.tsx +164 -160
- package/src/components/ui/separator.tsx +33 -29
- package/src/components/ui/switch.tsx +31 -27
- package/src/components/ui/textarea.tsx +55 -51
- package/src/components/ui/toast.tsx +131 -127
- package/src/components/ui/toaster.tsx +37 -33
- package/src/components/ui/toggle-group.tsx +63 -59
- package/src/components/ui/toggle.tsx +47 -43
- package/src/components/ui/tooltip.tsx +36 -32
- package/src/dialogs/NodePickerDialog.tsx +88 -84
- package/src/dialogs/ValidationDialog.tsx +188 -184
- package/src/graph/BaseNode.tsx +563 -557
- package/src/graph/CustomEdge.tsx +189 -185
- package/src/graph/CustomNode.tsx +20 -16
- package/src/graph/FunctionCallNode.tsx +34 -30
- package/src/graph/PortHandle.tsx +193 -189
- package/src/graph/reactFlowRegistry.ts +30 -26
- package/src/hooks/use-toast.ts +129 -125
- package/src/hooks/useAvailableVariables.ts +24 -20
- package/src/hooks/useCanvasHistory.ts +26 -22
- package/src/hooks/useCanvasTabs.ts +172 -168
- package/src/hooks/useFunctionDiagnosticsSync.ts +44 -40
- package/src/hooks/useFunctionRegistry.ts +30 -26
- package/src/hooks/useFunctions.ts +48 -44
- package/src/hooks/useGraph.ts +165 -161
- package/src/hooks/useNodeDefinitions.ts +86 -82
- package/src/hooks/useParamErrors.ts +30 -26
- package/src/hooks/useResolvedTheme.ts +34 -30
- package/src/hooks/useResourceDiagnosticsSync.ts +62 -58
- package/src/hooks/useSuppressThemeTransition.ts +83 -79
- package/src/hooks/useWorkflowSerialization.ts +145 -141
- package/src/i18n/index.ts +57 -53
- package/src/i18n/locales/de.json +501 -501
- package/src/i18n/locales/en.json +557 -557
- package/src/index.ts +31 -27
- package/src/inputs/ExpressionInput.tsx +301 -297
- package/src/inputs/ParameterEditor.tsx +519 -515
- package/src/inputs/PortSection.tsx +148 -144
- package/src/mode.ts +15 -0
- package/src/panels/BuilderSidebar.tsx +305 -301
- package/src/panels/ChannelConfigPanel.tsx +53 -49
- package/src/panels/ChannelsPanel.tsx +32 -28
- package/src/panels/DebugConsolePanel.tsx +77 -73
- package/src/panels/DebugContextPanel.tsx +81 -77
- package/src/panels/DebugExternalIOPanel.tsx +184 -180
- package/src/panels/DiagnosticsPanel.tsx +174 -170
- package/src/panels/EdgeConfigPanel.tsx +108 -104
- package/src/panels/FunctionConfigPanel.tsx +183 -179
- package/src/panels/FunctionListPanel.tsx +49 -45
- package/src/panels/MemoryConfigPanel.tsx +59 -55
- package/src/panels/MemoryPanel.tsx +44 -40
- package/src/panels/ModelConfigPanel.tsx +45 -41
- package/src/panels/ModelsPanel.tsx +40 -36
- package/src/panels/NodeConfigPanel.tsx +634 -630
- package/src/panels/NodeLibrary.tsx +292 -288
- package/src/panels/ResourceConfigPanel.tsx +136 -132
- package/src/panels/ResourceListPanel.tsx +117 -113
- package/src/panels/VariableConfigPanel.tsx +165 -161
- package/src/panels/VariablesPanel.tsx +149 -145
- package/src/stores/canvasStore.test.ts +48 -44
- package/src/stores/canvasStore.ts +249 -245
- package/src/stores/debugStore.ts +78 -74
- package/src/stores/diagnosticsStore.ts +134 -130
- package/src/stores/editorStore.ts +194 -190
- package/src/styles/index.css +526 -526
- package/src/utils/categoryConstants.ts +30 -26
- package/src/utils/channelOperations.ts +90 -86
- package/src/utils/connectionRules.ts +140 -137
- package/src/utils/functionOperations.ts +183 -179
- package/src/utils/graphOperations.ts +554 -550
- package/src/utils/history.test.ts +92 -0
- package/src/utils/history.ts +211 -207
- package/src/utils/memoryOperations.ts +61 -57
- package/src/utils/migrateFunctionNodes.ts +111 -107
- package/src/utils/modelOperations.ts +59 -55
- package/src/utils/paramDisplay.ts +75 -71
- package/src/utils/resourceHelpers.ts +36 -32
- package/src/utils/translation.ts +32 -28
- package/src/utils/variableOperations.ts +79 -75
- package/tailwind-preset.ts +170 -166
- package/dist/lib/utils.d.ts +0 -3
- package/dist/lib/utils.d.ts.map +0 -1
- package/dist/lib/utils.js +0 -6
- package/dist/lib/utils.js.map +0 -1
- package/dist/toolbars/CanvasTabsToolbar.d.ts +0 -11
- package/dist/toolbars/CanvasTabsToolbar.d.ts.map +0 -1
- package/dist/toolbars/CanvasTabsToolbar.js +0 -101
- package/dist/toolbars/CanvasTabsToolbar.js.map +0 -1
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
2
|
+
// Copyright (c) 2026 ForestHub. All rights reserved.
|
|
3
|
+
// For commercial licensing, contact root@foresthub.ai
|
|
4
|
+
|
|
5
|
+
import { describe, it, expect, beforeEach } from "vitest";
|
|
6
|
+
import { create } from "zustand";
|
|
7
|
+
import { history } from "./history";
|
|
8
|
+
|
|
9
|
+
interface CounterState {
|
|
10
|
+
count: number;
|
|
11
|
+
label: string;
|
|
12
|
+
setCount: (n: number) => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// A store on DEFAULT config — no custom equality/partialize — so the default
|
|
16
|
+
// equality path is what's under test.
|
|
17
|
+
function makeStore() {
|
|
18
|
+
return create(
|
|
19
|
+
history<CounterState>()((set) => ({
|
|
20
|
+
count: 0,
|
|
21
|
+
label: "a",
|
|
22
|
+
setCount: (n) => set((s) => ({ ...s, count: n })),
|
|
23
|
+
})),
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
describe("history middleware (default config)", () => {
|
|
28
|
+
let store: ReturnType<typeof makeStore>;
|
|
29
|
+
beforeEach(() => {
|
|
30
|
+
store = makeStore();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("withCheckpoint records a checkpoint when the operation changes state", () => {
|
|
34
|
+
store.getState().withCheckpoint(() => store.getState().setCount(1));
|
|
35
|
+
expect(store.getState().count).toBe(1);
|
|
36
|
+
expect(store.getState().canUndo()).toBe(true);
|
|
37
|
+
|
|
38
|
+
store.getState().undo();
|
|
39
|
+
expect(store.getState().count).toBe(0);
|
|
40
|
+
expect(store.getState().canRedo()).toBe(true);
|
|
41
|
+
|
|
42
|
+
store.getState().redo();
|
|
43
|
+
expect(store.getState().count).toBe(1);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("withCheckpoint does NOT record a checkpoint for a no-op", () => {
|
|
47
|
+
store.getState().withCheckpoint(() => {});
|
|
48
|
+
expect(store.getState().canUndo()).toBe(false);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("a no-op withCheckpoint preserves the redo stack", () => {
|
|
52
|
+
store.getState().withCheckpoint(() => store.getState().setCount(1));
|
|
53
|
+
store.getState().undo();
|
|
54
|
+
expect(store.getState().canRedo()).toBe(true);
|
|
55
|
+
|
|
56
|
+
store.getState().withCheckpoint(() => {});
|
|
57
|
+
expect(store.getState().canRedo()).toBe(true);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("a real change clears the redo stack", () => {
|
|
61
|
+
store.getState().withCheckpoint(() => store.getState().setCount(1));
|
|
62
|
+
store.getState().undo();
|
|
63
|
+
store.getState().withCheckpoint(() => store.getState().setCount(7));
|
|
64
|
+
expect(store.getState().canRedo()).toBe(false);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("withCheckpoint returns the operation's result and propagates throws without a checkpoint", () => {
|
|
68
|
+
expect(store.getState().withCheckpoint(() => 42)).toBe(42);
|
|
69
|
+
expect(() =>
|
|
70
|
+
store.getState().withCheckpoint(() => {
|
|
71
|
+
throw new Error("boom");
|
|
72
|
+
}),
|
|
73
|
+
).toThrow("boom");
|
|
74
|
+
expect(store.getState().canUndo()).toBe(false);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("mutationCount ticks on checkpointed changes only", () => {
|
|
78
|
+
const before = store.getState().mutationCount;
|
|
79
|
+
store.getState().withCheckpoint(() => {});
|
|
80
|
+
expect(store.getState().mutationCount).toBe(before);
|
|
81
|
+
store.getState().withCheckpoint(() => store.getState().setCount(5));
|
|
82
|
+
expect(store.getState().mutationCount).toBe(before + 1);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("takeCheckpoint always records, and clearHistory empties both stacks", () => {
|
|
86
|
+
store.getState().takeCheckpoint();
|
|
87
|
+
expect(store.getState().canUndo()).toBe(true);
|
|
88
|
+
store.getState().clearHistory();
|
|
89
|
+
expect(store.getState().canUndo()).toBe(false);
|
|
90
|
+
expect(store.getState().canRedo()).toBe(false);
|
|
91
|
+
});
|
|
92
|
+
});
|
package/src/utils/history.ts
CHANGED
|
@@ -1,207 +1,211 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
*
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
*
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
<T
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
2
|
+
// Copyright (c) 2026 ForestHub. All rights reserved.
|
|
3
|
+
// For commercial licensing, contact root@foresthub.ai
|
|
4
|
+
|
|
5
|
+
import { StateCreator, StoreMutatorIdentifier } from "zustand";
|
|
6
|
+
|
|
7
|
+
// Opaque type for exporting/importing history state
|
|
8
|
+
export interface HistoryData {
|
|
9
|
+
past: HistoryFrame<unknown>[];
|
|
10
|
+
future: HistoryFrame<unknown>[];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Public interface - only actions
|
|
14
|
+
export interface History {
|
|
15
|
+
/**
|
|
16
|
+
* Manually saves the current state as an undo checkpoint.
|
|
17
|
+
* Must be called BEFORE a state change that should be undoable.
|
|
18
|
+
*/
|
|
19
|
+
takeCheckpoint: () => void;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Run the given operation and save a checkpoint if the state did change.
|
|
23
|
+
* Good to wrap multiple state changes in a single undoable action.
|
|
24
|
+
* If the operation throws, no checkpoint is saved and the error is propagated.
|
|
25
|
+
* @param operation Function that may perform a state change.
|
|
26
|
+
* @returns The result of the operation.
|
|
27
|
+
*/
|
|
28
|
+
withCheckpoint: <R>(operation: () => R) => R;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Reverts the state to the previous snapshot in the undo history, if available.
|
|
32
|
+
* Moves the current state to the redo history.
|
|
33
|
+
*/
|
|
34
|
+
undo: () => void;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Reapplies the most recently undone state from the redo history, if available.
|
|
38
|
+
* Moves the current state to the undo history.
|
|
39
|
+
*/
|
|
40
|
+
redo: () => void;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Clears both the undo and redo history, but does not affect the current state.
|
|
44
|
+
*/
|
|
45
|
+
clearHistory: () => void;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Returns true if there is at least one state in the undo history.
|
|
49
|
+
*/
|
|
50
|
+
canUndo: () => boolean;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Returns true if there is at least one state in the redo history.
|
|
54
|
+
*/
|
|
55
|
+
canRedo: () => boolean;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Exports the current undo/redo history as an opaque blob.
|
|
59
|
+
*/
|
|
60
|
+
exportHistory: () => HistoryData;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Restores a previously exported history blob.
|
|
64
|
+
*/
|
|
65
|
+
importHistory: (data: HistoryData) => void;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// A single frame in history
|
|
69
|
+
interface HistoryFrame<T> {
|
|
70
|
+
state: T;
|
|
71
|
+
timestamp: number;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Internal state - not exposed publicly
|
|
75
|
+
interface HistoryState<T> {
|
|
76
|
+
_history_past: HistoryFrame<T>[];
|
|
77
|
+
_history_future: HistoryFrame<T>[];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Public, opaque change signal: a monotonic counter the middleware bumps on every
|
|
82
|
+
* history transition (checkpoint, undo, redo, clear, import). Subscribe to it to
|
|
83
|
+
* detect domain mutations and undo/redo in O(1). It never ticks on selection or
|
|
84
|
+
* drag — those mutate state without a checkpoint. Mirrors editorStore's counter
|
|
85
|
+
* of the same name for project-scoped (channel/memory/model) mutations.
|
|
86
|
+
*/
|
|
87
|
+
export interface MutationCount {
|
|
88
|
+
readonly mutationCount: number;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Configuration for history middleware
|
|
92
|
+
interface HistoryConfig<T> {
|
|
93
|
+
limit?: number;
|
|
94
|
+
partialize?: (state: T) => Partial<T>;
|
|
95
|
+
equality?: (before: Partial<T>, after: Partial<T>) => boolean;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export const history =
|
|
99
|
+
<T>(config: HistoryConfig<T> = {}) =>
|
|
100
|
+
<Mps extends [StoreMutatorIdentifier, unknown][] = [], Mcs extends [StoreMutatorIdentifier, unknown][] = []>(
|
|
101
|
+
storeInitializer: StateCreator<T, Mps, Mcs>,
|
|
102
|
+
): StateCreator<T & HistoryState<T> & History & MutationCount, Mps, Mcs> => {
|
|
103
|
+
const {
|
|
104
|
+
limit = 50,
|
|
105
|
+
partialize = (state) => state,
|
|
106
|
+
equality = (before, after) => JSON.stringify(before) === JSON.stringify(after),
|
|
107
|
+
} = config;
|
|
108
|
+
|
|
109
|
+
return (set, get, store) => {
|
|
110
|
+
type FullState = T & HistoryState<T> & History & MutationCount;
|
|
111
|
+
|
|
112
|
+
const initialState = storeInitializer(
|
|
113
|
+
set as Parameters<StateCreator<T, Mps, Mcs>>[0],
|
|
114
|
+
get as Parameters<StateCreator<T, Mps, Mcs>>[1],
|
|
115
|
+
store as Parameters<StateCreator<T, Mps, Mcs>>[2],
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
return {
|
|
119
|
+
...initialState,
|
|
120
|
+
_history_past: [],
|
|
121
|
+
_history_future: [],
|
|
122
|
+
mutationCount: 0,
|
|
123
|
+
|
|
124
|
+
takeCheckpoint: () => {
|
|
125
|
+
const currentState = partialize(get() as T);
|
|
126
|
+
set((state: FullState) => ({
|
|
127
|
+
...state,
|
|
128
|
+
_history_past: [...state._history_past, { state: currentState as T, timestamp: Date.now() }].slice(-limit),
|
|
129
|
+
_history_future: [],
|
|
130
|
+
mutationCount: state.mutationCount + 1,
|
|
131
|
+
}));
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
withCheckpoint: <R>(operation: () => R): R => {
|
|
135
|
+
const beforeState = partialize(get() as T);
|
|
136
|
+
// Execute operation and capture result to return later to caller
|
|
137
|
+
const result = operation();
|
|
138
|
+
const afterState = partialize(get() as T);
|
|
139
|
+
// Compare using provided equality function
|
|
140
|
+
const areEqual = equality(beforeState, afterState);
|
|
141
|
+
if (!areEqual) {
|
|
142
|
+
set((state: FullState) => ({
|
|
143
|
+
...state,
|
|
144
|
+
_history_past: [...state._history_past, { state: beforeState as T, timestamp: Date.now() }].slice(-limit),
|
|
145
|
+
_history_future: [],
|
|
146
|
+
mutationCount: state.mutationCount + 1,
|
|
147
|
+
}));
|
|
148
|
+
}
|
|
149
|
+
return result;
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
undo: () => {
|
|
153
|
+
const state = get();
|
|
154
|
+
if (state._history_past.length === 0) return;
|
|
155
|
+
const past = [...state._history_past];
|
|
156
|
+
const previousFrame = past.pop()!;
|
|
157
|
+
// Save current state to future before restoring
|
|
158
|
+
const currentState = partialize(state as T);
|
|
159
|
+
set({
|
|
160
|
+
...state,
|
|
161
|
+
...previousFrame.state,
|
|
162
|
+
_history_past: past,
|
|
163
|
+
_history_future: [...state._history_future, { state: currentState as T, timestamp: Date.now() }],
|
|
164
|
+
mutationCount: state.mutationCount + 1,
|
|
165
|
+
} as FullState);
|
|
166
|
+
},
|
|
167
|
+
|
|
168
|
+
redo: () => {
|
|
169
|
+
const state = get();
|
|
170
|
+
if (state._history_future.length === 0) return;
|
|
171
|
+
const future = [...state._history_future];
|
|
172
|
+
const nextFrame = future.pop()!;
|
|
173
|
+
// Save current state to past before restoring
|
|
174
|
+
const currentState = partialize(state as T);
|
|
175
|
+
set({
|
|
176
|
+
...state,
|
|
177
|
+
...nextFrame.state,
|
|
178
|
+
_history_past: [...state._history_past, { state: currentState as T, timestamp: Date.now() }].slice(-limit),
|
|
179
|
+
_history_future: future,
|
|
180
|
+
mutationCount: state.mutationCount + 1,
|
|
181
|
+
} as FullState);
|
|
182
|
+
},
|
|
183
|
+
|
|
184
|
+
clearHistory: () => {
|
|
185
|
+
set((state: FullState) => ({
|
|
186
|
+
...state,
|
|
187
|
+
_history_past: [],
|
|
188
|
+
_history_future: [],
|
|
189
|
+
mutationCount: state.mutationCount + 1,
|
|
190
|
+
}));
|
|
191
|
+
},
|
|
192
|
+
|
|
193
|
+
canUndo: () => (get() as FullState)._history_past.length > 0,
|
|
194
|
+
canRedo: () => (get() as FullState)._history_future.length > 0,
|
|
195
|
+
|
|
196
|
+
exportHistory: () => ({
|
|
197
|
+
past: [...(get() as FullState)._history_past],
|
|
198
|
+
future: [...(get() as FullState)._history_future],
|
|
199
|
+
}),
|
|
200
|
+
|
|
201
|
+
importHistory: (data: HistoryData) => {
|
|
202
|
+
set((state: FullState) => ({
|
|
203
|
+
...state,
|
|
204
|
+
_history_past: [...data.past] as HistoryFrame<T>[],
|
|
205
|
+
_history_future: [...data.future] as HistoryFrame<T>[],
|
|
206
|
+
mutationCount: state.mutationCount + 1,
|
|
207
|
+
}));
|
|
208
|
+
},
|
|
209
|
+
} as FullState;
|
|
210
|
+
};
|
|
211
|
+
};
|
|
@@ -1,57 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
2
|
+
// Copyright (c) 2026 ForestHub. All rights reserved.
|
|
3
|
+
// For commercial licensing, contact root@foresthub.ai
|
|
4
|
+
|
|
5
|
+
import { MemoryRegistry, type MemoryType, type Memory } from "@foresthubai/workflow-core/memory";
|
|
6
|
+
import { useEditorStore } from "../stores/editorStore";
|
|
7
|
+
import { generateId } from "@foresthubai/workflow-core/id";
|
|
8
|
+
import { seedDefaultArguments, uniqueName } from "./resourceHelpers";
|
|
9
|
+
|
|
10
|
+
/** Default label prefix per memory type. */
|
|
11
|
+
const LABEL_PREFIX: Record<MemoryType, string> = {
|
|
12
|
+
MemoryFile: "memory",
|
|
13
|
+
VectorDatabase: "vectordb",
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/** Create a new memory primitive of the given type in the editor store. Returns the new instance. */
|
|
17
|
+
export function addMemory(type: MemoryType): Memory {
|
|
18
|
+
const id = generateId();
|
|
19
|
+
const existing = Object.values(useEditorStore.getState().memory).map((m) => m.label);
|
|
20
|
+
const instance: Memory = {
|
|
21
|
+
id,
|
|
22
|
+
label: uniqueName(LABEL_PREFIX[type], existing),
|
|
23
|
+
type,
|
|
24
|
+
arguments: seedDefaultArguments(MemoryRegistry.getByType(type)?.parameters ?? []),
|
|
25
|
+
};
|
|
26
|
+
useEditorStore.getState().setMemory((mem) => ({ ...mem, [id]: instance }));
|
|
27
|
+
return instance;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Apply a partial patch to a memory primitive. Top-level `label` and the
|
|
32
|
+
* `arguments` record are merged separately. The `type` discriminator is fixed
|
|
33
|
+
* at creation (the user picks a type when adding), so it is never patched here.
|
|
34
|
+
*/
|
|
35
|
+
export function updateMemory(id: string, patch: { label?: string; arguments?: Record<string, unknown> }): void {
|
|
36
|
+
const key = id;
|
|
37
|
+
useEditorStore.getState().setMemory((mem) => {
|
|
38
|
+
const existing = mem[key];
|
|
39
|
+
if (!existing) return mem;
|
|
40
|
+
return {
|
|
41
|
+
...mem,
|
|
42
|
+
[key]: {
|
|
43
|
+
...existing,
|
|
44
|
+
...(patch.label !== undefined ? { label: patch.label } : {}),
|
|
45
|
+
...(patch.arguments ? { arguments: { ...existing.arguments, ...patch.arguments } } : {}),
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function deleteMemory(id: string): void {
|
|
52
|
+
const key = id;
|
|
53
|
+
useEditorStore.getState().setMemory((mem) => {
|
|
54
|
+
const { [key]: _drop, ...rest } = mem;
|
|
55
|
+
return rest;
|
|
56
|
+
});
|
|
57
|
+
const sel = useEditorStore.getState().selection;
|
|
58
|
+
if (sel.kind === "memory" && sel.id === id) {
|
|
59
|
+
useEditorStore.getState().clearSelection();
|
|
60
|
+
}
|
|
61
|
+
}
|