@foresthubai/workflow-builder 0.3.0

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 (496) hide show
  1. package/LICENSE +661 -0
  2. package/NOTICE +16 -0
  3. package/README.md +93 -0
  4. package/dist/BuilderLayout.d.ts +34 -0
  5. package/dist/BuilderLayout.d.ts.map +1 -0
  6. package/dist/BuilderLayout.js +172 -0
  7. package/dist/BuilderLayout.js.map +1 -0
  8. package/dist/Canvas.d.ts +23 -0
  9. package/dist/Canvas.d.ts.map +1 -0
  10. package/dist/Canvas.js +141 -0
  11. package/dist/Canvas.js.map +1 -0
  12. package/dist/CanvasEditor.d.ts +46 -0
  13. package/dist/CanvasEditor.d.ts.map +1 -0
  14. package/dist/CanvasEditor.js +57 -0
  15. package/dist/CanvasEditor.js.map +1 -0
  16. package/dist/CanvasTabsToolbar.d.ts +11 -0
  17. package/dist/CanvasTabsToolbar.d.ts.map +1 -0
  18. package/dist/CanvasTabsToolbar.js +101 -0
  19. package/dist/CanvasTabsToolbar.js.map +1 -0
  20. package/dist/RightConfigPanel.d.ts +27 -0
  21. package/dist/RightConfigPanel.d.ts.map +1 -0
  22. package/dist/RightConfigPanel.js +102 -0
  23. package/dist/RightConfigPanel.js.map +1 -0
  24. package/dist/WorkflowBuilder.d.ts +62 -0
  25. package/dist/WorkflowBuilder.d.ts.map +1 -0
  26. package/dist/WorkflowBuilder.js +275 -0
  27. package/dist/WorkflowBuilder.js.map +1 -0
  28. package/dist/cn.d.ts +3 -0
  29. package/dist/cn.d.ts.map +1 -0
  30. package/dist/cn.js +6 -0
  31. package/dist/cn.js.map +1 -0
  32. package/dist/components/ui/add-button.d.ts +16 -0
  33. package/dist/components/ui/add-button.d.ts.map +1 -0
  34. package/dist/components/ui/add-button.js +21 -0
  35. package/dist/components/ui/add-button.js.map +1 -0
  36. package/dist/components/ui/alert-dialog.d.ts +21 -0
  37. package/dist/components/ui/alert-dialog.d.ts.map +1 -0
  38. package/dist/components/ui/alert-dialog.js +30 -0
  39. package/dist/components/ui/alert-dialog.js.map +1 -0
  40. package/dist/components/ui/alert.d.ts +9 -0
  41. package/dist/components/ui/alert.d.ts.map +1 -0
  42. package/dist/components/ui/alert.js +23 -0
  43. package/dist/components/ui/alert.js.map +1 -0
  44. package/dist/components/ui/badge.d.ts +10 -0
  45. package/dist/components/ui/badge.d.ts.map +1 -0
  46. package/dist/components/ui/badge.js +21 -0
  47. package/dist/components/ui/badge.js.map +1 -0
  48. package/dist/components/ui/button.d.ts +13 -0
  49. package/dist/components/ui/button.d.ts.map +1 -0
  50. package/dist/components/ui/button.js +40 -0
  51. package/dist/components/ui/button.js.map +1 -0
  52. package/dist/components/ui/card.d.ts +9 -0
  53. package/dist/components/ui/card.d.ts.map +1 -0
  54. package/dist/components/ui/card.js +17 -0
  55. package/dist/components/ui/card.js.map +1 -0
  56. package/dist/components/ui/checkbox.d.ts +5 -0
  57. package/dist/components/ui/checkbox.d.ts.map +1 -0
  58. package/dist/components/ui/checkbox.js +9 -0
  59. package/dist/components/ui/checkbox.js.map +1 -0
  60. package/dist/components/ui/collapsible.d.ts +6 -0
  61. package/dist/components/ui/collapsible.d.ts.map +1 -0
  62. package/dist/components/ui/collapsible.js +6 -0
  63. package/dist/components/ui/collapsible.js.map +1 -0
  64. package/dist/components/ui/command.d.ts +82 -0
  65. package/dist/components/ui/command.d.ts.map +1 -0
  66. package/dist/components/ui/command.js +29 -0
  67. package/dist/components/ui/command.js.map +1 -0
  68. package/dist/components/ui/delete-button.d.ts +11 -0
  69. package/dist/components/ui/delete-button.d.ts.map +1 -0
  70. package/dist/components/ui/delete-button.js +14 -0
  71. package/dist/components/ui/delete-button.js.map +1 -0
  72. package/dist/components/ui/dialog.d.ts +22 -0
  73. package/dist/components/ui/dialog.d.ts.map +1 -0
  74. package/dist/components/ui/dialog.js +27 -0
  75. package/dist/components/ui/dialog.js.map +1 -0
  76. package/dist/components/ui/dropdown-menu.d.ts +28 -0
  77. package/dist/components/ui/dropdown-menu.d.ts.map +1 -0
  78. package/dist/components/ui/dropdown-menu.js +36 -0
  79. package/dist/components/ui/dropdown-menu.js.map +1 -0
  80. package/dist/components/ui/input.d.ts +13 -0
  81. package/dist/components/ui/input.d.ts.map +1 -0
  82. package/dist/components/ui/input.js +34 -0
  83. package/dist/components/ui/input.js.map +1 -0
  84. package/dist/components/ui/label.d.ts +6 -0
  85. package/dist/components/ui/label.d.ts.map +1 -0
  86. package/dist/components/ui/label.js +10 -0
  87. package/dist/components/ui/label.js.map +1 -0
  88. package/dist/components/ui/readonly-banner.d.ts +7 -0
  89. package/dist/components/ui/readonly-banner.d.ts.map +1 -0
  90. package/dist/components/ui/readonly-banner.js +12 -0
  91. package/dist/components/ui/readonly-banner.js.map +1 -0
  92. package/dist/components/ui/resizable.d.ts +24 -0
  93. package/dist/components/ui/resizable.d.ts.map +1 -0
  94. package/dist/components/ui/resizable.js +9 -0
  95. package/dist/components/ui/resizable.js.map +1 -0
  96. package/dist/components/ui/scroll-area.d.ts +45 -0
  97. package/dist/components/ui/scroll-area.d.ts.map +1 -0
  98. package/dist/components/ui/scroll-area.js +27 -0
  99. package/dist/components/ui/scroll-area.js.map +1 -0
  100. package/dist/components/ui/select.d.ts +14 -0
  101. package/dist/components/ui/select.d.ts.map +1 -0
  102. package/dist/components/ui/select.js +30 -0
  103. package/dist/components/ui/select.js.map +1 -0
  104. package/dist/components/ui/separator.d.ts +5 -0
  105. package/dist/components/ui/separator.d.ts.map +1 -0
  106. package/dist/components/ui/separator.js +8 -0
  107. package/dist/components/ui/separator.js.map +1 -0
  108. package/dist/components/ui/switch.d.ts +5 -0
  109. package/dist/components/ui/switch.d.ts.map +1 -0
  110. package/dist/components/ui/switch.js +8 -0
  111. package/dist/components/ui/switch.js.map +1 -0
  112. package/dist/components/ui/textarea.d.ts +12 -0
  113. package/dist/components/ui/textarea.d.ts.map +1 -0
  114. package/dist/components/ui/textarea.js +34 -0
  115. package/dist/components/ui/textarea.js.map +1 -0
  116. package/dist/components/ui/toast.d.ts +16 -0
  117. package/dist/components/ui/toast.d.ts.map +1 -0
  118. package/dist/components/ui/toast.js +34 -0
  119. package/dist/components/ui/toast.js.map +1 -0
  120. package/dist/components/ui/toaster.d.ts +2 -0
  121. package/dist/components/ui/toaster.d.ts.map +1 -0
  122. package/dist/components/ui/toaster.js +10 -0
  123. package/dist/components/ui/toaster.js.map +1 -0
  124. package/dist/components/ui/toggle-group.d.ts +13 -0
  125. package/dist/components/ui/toggle-group.d.ts.map +1 -0
  126. package/dist/components/ui/toggle-group.js +21 -0
  127. package/dist/components/ui/toggle-group.js.map +1 -0
  128. package/dist/components/ui/toggle.d.ts +13 -0
  129. package/dist/components/ui/toggle.d.ts.map +1 -0
  130. package/dist/components/ui/toggle.js +26 -0
  131. package/dist/components/ui/toggle.js.map +1 -0
  132. package/dist/components/ui/tooltip.d.ts +8 -0
  133. package/dist/components/ui/tooltip.d.ts.map +1 -0
  134. package/dist/components/ui/tooltip.js +14 -0
  135. package/dist/components/ui/tooltip.js.map +1 -0
  136. package/dist/dialogs/NodePickerDialog.d.ts +10 -0
  137. package/dist/dialogs/NodePickerDialog.d.ts.map +1 -0
  138. package/dist/dialogs/NodePickerDialog.js +39 -0
  139. package/dist/dialogs/NodePickerDialog.js.map +1 -0
  140. package/dist/dialogs/ValidationDialog.d.ts +17 -0
  141. package/dist/dialogs/ValidationDialog.d.ts.map +1 -0
  142. package/dist/dialogs/ValidationDialog.js +29 -0
  143. package/dist/dialogs/ValidationDialog.js.map +1 -0
  144. package/dist/graph/BaseNode.d.ts +9 -0
  145. package/dist/graph/BaseNode.d.ts.map +1 -0
  146. package/dist/graph/BaseNode.js +318 -0
  147. package/dist/graph/BaseNode.js.map +1 -0
  148. package/dist/graph/CustomEdge.d.ts +14 -0
  149. package/dist/graph/CustomEdge.d.ts.map +1 -0
  150. package/dist/graph/CustomEdge.js +107 -0
  151. package/dist/graph/CustomEdge.js.map +1 -0
  152. package/dist/graph/CustomNode.d.ts +3 -0
  153. package/dist/graph/CustomNode.d.ts.map +1 -0
  154. package/dist/graph/CustomNode.js +15 -0
  155. package/dist/graph/CustomNode.js.map +1 -0
  156. package/dist/graph/FunctionCallNode.d.ts +3 -0
  157. package/dist/graph/FunctionCallNode.d.ts.map +1 -0
  158. package/dist/graph/FunctionCallNode.js +25 -0
  159. package/dist/graph/FunctionCallNode.js.map +1 -0
  160. package/dist/graph/PortHandle.d.ts +21 -0
  161. package/dist/graph/PortHandle.d.ts.map +1 -0
  162. package/dist/graph/PortHandle.js +113 -0
  163. package/dist/graph/PortHandle.js.map +1 -0
  164. package/dist/graph/reactFlowRegistry.d.ts +65 -0
  165. package/dist/graph/reactFlowRegistry.d.ts.map +1 -0
  166. package/dist/graph/reactFlowRegistry.js +24 -0
  167. package/dist/graph/reactFlowRegistry.js.map +1 -0
  168. package/dist/hooks/use-toast.d.ts +47 -0
  169. package/dist/hooks/use-toast.d.ts.map +1 -0
  170. package/dist/hooks/use-toast.js +95 -0
  171. package/dist/hooks/use-toast.js.map +1 -0
  172. package/dist/hooks/useAvailableVariables.d.ts +12 -0
  173. package/dist/hooks/useAvailableVariables.d.ts.map +1 -0
  174. package/dist/hooks/useAvailableVariables.js +16 -0
  175. package/dist/hooks/useAvailableVariables.js.map +1 -0
  176. package/dist/hooks/useCanvasHistory.d.ts +14 -0
  177. package/dist/hooks/useCanvasHistory.d.ts.map +1 -0
  178. package/dist/hooks/useCanvasHistory.js +20 -0
  179. package/dist/hooks/useCanvasHistory.js.map +1 -0
  180. package/dist/hooks/useCanvasTabs.d.ts +23 -0
  181. package/dist/hooks/useCanvasTabs.d.ts.map +1 -0
  182. package/dist/hooks/useCanvasTabs.js +136 -0
  183. package/dist/hooks/useCanvasTabs.js.map +1 -0
  184. package/dist/hooks/useFunctionDiagnosticsSync.d.ts +14 -0
  185. package/dist/hooks/useFunctionDiagnosticsSync.d.ts.map +1 -0
  186. package/dist/hooks/useFunctionDiagnosticsSync.js +38 -0
  187. package/dist/hooks/useFunctionDiagnosticsSync.js.map +1 -0
  188. package/dist/hooks/useFunctionRegistry.d.ts +15 -0
  189. package/dist/hooks/useFunctionRegistry.d.ts.map +1 -0
  190. package/dist/hooks/useFunctionRegistry.js +22 -0
  191. package/dist/hooks/useFunctionRegistry.js.map +1 -0
  192. package/dist/hooks/useFunctions.d.ts +15 -0
  193. package/dist/hooks/useFunctions.d.ts.map +1 -0
  194. package/dist/hooks/useFunctions.js +34 -0
  195. package/dist/hooks/useFunctions.js.map +1 -0
  196. package/dist/hooks/useGraph.d.ts +40 -0
  197. package/dist/hooks/useGraph.d.ts.map +1 -0
  198. package/dist/hooks/useGraph.js +102 -0
  199. package/dist/hooks/useGraph.js.map +1 -0
  200. package/dist/hooks/useNodeDefinitions.d.ts +17 -0
  201. package/dist/hooks/useNodeDefinitions.d.ts.map +1 -0
  202. package/dist/hooks/useNodeDefinitions.js +65 -0
  203. package/dist/hooks/useNodeDefinitions.js.map +1 -0
  204. package/dist/hooks/useParamErrors.d.ts +12 -0
  205. package/dist/hooks/useParamErrors.d.ts.map +1 -0
  206. package/dist/hooks/useParamErrors.js +28 -0
  207. package/dist/hooks/useParamErrors.js.map +1 -0
  208. package/dist/hooks/useResolvedTheme.d.ts +10 -0
  209. package/dist/hooks/useResolvedTheme.d.ts.map +1 -0
  210. package/dist/hooks/useResolvedTheme.js +29 -0
  211. package/dist/hooks/useResolvedTheme.js.map +1 -0
  212. package/dist/hooks/useResourceDiagnosticsSync.d.ts +40 -0
  213. package/dist/hooks/useResourceDiagnosticsSync.d.ts.map +1 -0
  214. package/dist/hooks/useResourceDiagnosticsSync.js +39 -0
  215. package/dist/hooks/useResourceDiagnosticsSync.js.map +1 -0
  216. package/dist/hooks/useSuppressThemeTransition.d.ts +32 -0
  217. package/dist/hooks/useSuppressThemeTransition.d.ts.map +1 -0
  218. package/dist/hooks/useSuppressThemeTransition.js +75 -0
  219. package/dist/hooks/useSuppressThemeTransition.js.map +1 -0
  220. package/dist/hooks/useWorkflowSerialization.d.ts +24 -0
  221. package/dist/hooks/useWorkflowSerialization.d.ts.map +1 -0
  222. package/dist/hooks/useWorkflowSerialization.js +113 -0
  223. package/dist/hooks/useWorkflowSerialization.js.map +1 -0
  224. package/dist/i18n/index.d.ts +4 -0
  225. package/dist/i18n/index.d.ts.map +1 -0
  226. package/dist/i18n/index.js +46 -0
  227. package/dist/i18n/index.js.map +1 -0
  228. package/dist/i18n/locales/de.json +501 -0
  229. package/dist/i18n/locales/en.json +557 -0
  230. package/dist/index.d.ts +9 -0
  231. package/dist/index.d.ts.map +1 -0
  232. package/dist/index.js +12 -0
  233. package/dist/index.js.map +1 -0
  234. package/dist/inputs/ExpressionInput.d.ts +12 -0
  235. package/dist/inputs/ExpressionInput.d.ts.map +1 -0
  236. package/dist/inputs/ExpressionInput.js +203 -0
  237. package/dist/inputs/ExpressionInput.js.map +1 -0
  238. package/dist/inputs/ParameterEditor.d.ts +13 -0
  239. package/dist/inputs/ParameterEditor.d.ts.map +1 -0
  240. package/dist/inputs/ParameterEditor.js +204 -0
  241. package/dist/inputs/ParameterEditor.js.map +1 -0
  242. package/dist/inputs/PortSection.d.ts +31 -0
  243. package/dist/inputs/PortSection.d.ts.map +1 -0
  244. package/dist/inputs/PortSection.js +26 -0
  245. package/dist/inputs/PortSection.js.map +1 -0
  246. package/dist/panels/BuilderSidebar.d.ts +24 -0
  247. package/dist/panels/BuilderSidebar.d.ts.map +1 -0
  248. package/dist/panels/BuilderSidebar.js +202 -0
  249. package/dist/panels/BuilderSidebar.js.map +1 -0
  250. package/dist/panels/ChannelConfigPanel.d.ts +8 -0
  251. package/dist/panels/ChannelConfigPanel.d.ts.map +1 -0
  252. package/dist/panels/ChannelConfigPanel.js +26 -0
  253. package/dist/panels/ChannelConfigPanel.js.map +1 -0
  254. package/dist/panels/ChannelsPanel.d.ts +2 -0
  255. package/dist/panels/ChannelsPanel.d.ts.map +1 -0
  256. package/dist/panels/ChannelsPanel.js +16 -0
  257. package/dist/panels/ChannelsPanel.js.map +1 -0
  258. package/dist/panels/DebugConsolePanel.d.ts +2 -0
  259. package/dist/panels/DebugConsolePanel.d.ts.map +1 -0
  260. package/dist/panels/DebugConsolePanel.js +32 -0
  261. package/dist/panels/DebugConsolePanel.js.map +1 -0
  262. package/dist/panels/DebugContextPanel.d.ts +2 -0
  263. package/dist/panels/DebugContextPanel.d.ts.map +1 -0
  264. package/dist/panels/DebugContextPanel.js +32 -0
  265. package/dist/panels/DebugContextPanel.js.map +1 -0
  266. package/dist/panels/DebugExternalIOPanel.d.ts +9 -0
  267. package/dist/panels/DebugExternalIOPanel.d.ts.map +1 -0
  268. package/dist/panels/DebugExternalIOPanel.js +66 -0
  269. package/dist/panels/DebugExternalIOPanel.js.map +1 -0
  270. package/dist/panels/DiagnosticsPanel.d.ts +8 -0
  271. package/dist/panels/DiagnosticsPanel.d.ts.map +1 -0
  272. package/dist/panels/DiagnosticsPanel.js +86 -0
  273. package/dist/panels/DiagnosticsPanel.js.map +1 -0
  274. package/dist/panels/EdgeConfigPanel.d.ts +14 -0
  275. package/dist/panels/EdgeConfigPanel.d.ts.map +1 -0
  276. package/dist/panels/EdgeConfigPanel.js +34 -0
  277. package/dist/panels/EdgeConfigPanel.js.map +1 -0
  278. package/dist/panels/FunctionConfigPanel.d.ts +16 -0
  279. package/dist/panels/FunctionConfigPanel.d.ts.map +1 -0
  280. package/dist/panels/FunctionConfigPanel.js +62 -0
  281. package/dist/panels/FunctionConfigPanel.js.map +1 -0
  282. package/dist/panels/FunctionListPanel.d.ts +14 -0
  283. package/dist/panels/FunctionListPanel.d.ts.map +1 -0
  284. package/dist/panels/FunctionListPanel.js +25 -0
  285. package/dist/panels/FunctionListPanel.js.map +1 -0
  286. package/dist/panels/MemoryConfigPanel.d.ts +8 -0
  287. package/dist/panels/MemoryConfigPanel.d.ts.map +1 -0
  288. package/dist/panels/MemoryConfigPanel.js +22 -0
  289. package/dist/panels/MemoryConfigPanel.js.map +1 -0
  290. package/dist/panels/MemoryPanel.d.ts +2 -0
  291. package/dist/panels/MemoryPanel.d.ts.map +1 -0
  292. package/dist/panels/MemoryPanel.js +25 -0
  293. package/dist/panels/MemoryPanel.js.map +1 -0
  294. package/dist/panels/ModelConfigPanel.d.ts +8 -0
  295. package/dist/panels/ModelConfigPanel.d.ts.map +1 -0
  296. package/dist/panels/ModelConfigPanel.js +14 -0
  297. package/dist/panels/ModelConfigPanel.js.map +1 -0
  298. package/dist/panels/ModelsPanel.d.ts +8 -0
  299. package/dist/panels/ModelsPanel.d.ts.map +1 -0
  300. package/dist/panels/ModelsPanel.js +24 -0
  301. package/dist/panels/ModelsPanel.js.map +1 -0
  302. package/dist/panels/NodeConfigPanel.d.ts +16 -0
  303. package/dist/panels/NodeConfigPanel.d.ts.map +1 -0
  304. package/dist/panels/NodeConfigPanel.js +248 -0
  305. package/dist/panels/NodeConfigPanel.js.map +1 -0
  306. package/dist/panels/NodeLibrary.d.ts +16 -0
  307. package/dist/panels/NodeLibrary.d.ts.map +1 -0
  308. package/dist/panels/NodeLibrary.js +125 -0
  309. package/dist/panels/NodeLibrary.js.map +1 -0
  310. package/dist/panels/ResourceConfigPanel.d.ts +37 -0
  311. package/dist/panels/ResourceConfigPanel.d.ts.map +1 -0
  312. package/dist/panels/ResourceConfigPanel.js +35 -0
  313. package/dist/panels/ResourceConfigPanel.js.map +1 -0
  314. package/dist/panels/ResourceListPanel.d.ts +35 -0
  315. package/dist/panels/ResourceListPanel.d.ts.map +1 -0
  316. package/dist/panels/ResourceListPanel.js +35 -0
  317. package/dist/panels/ResourceListPanel.js.map +1 -0
  318. package/dist/panels/VariableConfigPanel.d.ts +9 -0
  319. package/dist/panels/VariableConfigPanel.d.ts.map +1 -0
  320. package/dist/panels/VariableConfigPanel.js +50 -0
  321. package/dist/panels/VariableConfigPanel.js.map +1 -0
  322. package/dist/panels/VariablesPanel.d.ts +7 -0
  323. package/dist/panels/VariablesPanel.d.ts.map +1 -0
  324. package/dist/panels/VariablesPanel.js +56 -0
  325. package/dist/panels/VariablesPanel.js.map +1 -0
  326. package/dist/stores/canvasStore.d.ts +41 -0
  327. package/dist/stores/canvasStore.d.ts.map +1 -0
  328. package/dist/stores/canvasStore.js +187 -0
  329. package/dist/stores/canvasStore.js.map +1 -0
  330. package/dist/stores/debugStore.d.ts +42 -0
  331. package/dist/stores/debugStore.d.ts.map +1 -0
  332. package/dist/stores/debugStore.js +22 -0
  333. package/dist/stores/debugStore.js.map +1 -0
  334. package/dist/stores/diagnosticsStore.d.ts +41 -0
  335. package/dist/stores/diagnosticsStore.d.ts.map +1 -0
  336. package/dist/stores/diagnosticsStore.js +67 -0
  337. package/dist/stores/diagnosticsStore.js.map +1 -0
  338. package/dist/stores/editorStore.d.ts +76 -0
  339. package/dist/stores/editorStore.d.ts.map +1 -0
  340. package/dist/stores/editorStore.js +116 -0
  341. package/dist/stores/editorStore.js.map +1 -0
  342. package/dist/utils/categoryConstants.d.ts +4 -0
  343. package/dist/utils/categoryConstants.d.ts.map +1 -0
  344. package/dist/utils/categoryConstants.js +24 -0
  345. package/dist/utils/categoryConstants.js.map +1 -0
  346. package/dist/utils/channelOperations.d.ts +21 -0
  347. package/dist/utils/channelOperations.d.ts.map +1 -0
  348. package/dist/utils/channelOperations.js +84 -0
  349. package/dist/utils/channelOperations.js.map +1 -0
  350. package/dist/utils/connectionRules.d.ts +15 -0
  351. package/dist/utils/connectionRules.d.ts.map +1 -0
  352. package/dist/utils/connectionRules.js +113 -0
  353. package/dist/utils/connectionRules.js.map +1 -0
  354. package/dist/utils/functionOperations.d.ts +27 -0
  355. package/dist/utils/functionOperations.d.ts.map +1 -0
  356. package/dist/utils/functionOperations.js +140 -0
  357. package/dist/utils/functionOperations.js.map +1 -0
  358. package/dist/utils/graphOperations.d.ts +54 -0
  359. package/dist/utils/graphOperations.d.ts.map +1 -0
  360. package/dist/utils/graphOperations.js +461 -0
  361. package/dist/utils/graphOperations.js.map +1 -0
  362. package/dist/utils/history.d.ts +76 -0
  363. package/dist/utils/history.d.ts.map +1 -0
  364. package/dist/utils/history.js +93 -0
  365. package/dist/utils/history.js.map +1 -0
  366. package/dist/utils/memoryOperations.d.ts +14 -0
  367. package/dist/utils/memoryOperations.d.ts.map +1 -0
  368. package/dist/utils/memoryOperations.js +55 -0
  369. package/dist/utils/memoryOperations.js.map +1 -0
  370. package/dist/utils/migrateFunctionNodes.d.ts +9 -0
  371. package/dist/utils/migrateFunctionNodes.d.ts.map +1 -0
  372. package/dist/utils/migrateFunctionNodes.js +89 -0
  373. package/dist/utils/migrateFunctionNodes.js.map +1 -0
  374. package/dist/utils/modelOperations.d.ts +13 -0
  375. package/dist/utils/modelOperations.d.ts.map +1 -0
  376. package/dist/utils/modelOperations.js +53 -0
  377. package/dist/utils/modelOperations.js.map +1 -0
  378. package/dist/utils/paramDisplay.d.ts +12 -0
  379. package/dist/utils/paramDisplay.d.ts.map +1 -0
  380. package/dist/utils/paramDisplay.js +56 -0
  381. package/dist/utils/paramDisplay.js.map +1 -0
  382. package/dist/utils/resourceHelpers.d.ts +17 -0
  383. package/dist/utils/resourceHelpers.d.ts.map +1 -0
  384. package/dist/utils/resourceHelpers.js +32 -0
  385. package/dist/utils/resourceHelpers.js.map +1 -0
  386. package/dist/utils/translation.d.ts +20 -0
  387. package/dist/utils/translation.d.ts.map +1 -0
  388. package/dist/utils/translation.js +23 -0
  389. package/dist/utils/translation.js.map +1 -0
  390. package/dist/utils/variableOperations.d.ts +15 -0
  391. package/dist/utils/variableOperations.d.ts.map +1 -0
  392. package/dist/utils/variableOperations.js +71 -0
  393. package/dist/utils/variableOperations.js.map +1 -0
  394. package/package.json +79 -0
  395. package/src/BuilderLayout.tsx +345 -0
  396. package/src/Canvas.tsx +261 -0
  397. package/src/CanvasEditor.tsx +142 -0
  398. package/src/CanvasTabsToolbar.tsx +176 -0
  399. package/src/RightConfigPanel.tsx +266 -0
  400. package/src/WorkflowBuilder.tsx +412 -0
  401. package/src/cn.ts +6 -0
  402. package/src/components/ui/add-button.tsx +39 -0
  403. package/src/components/ui/alert-dialog.tsx +141 -0
  404. package/src/components/ui/alert.tsx +59 -0
  405. package/src/components/ui/badge.tsx +36 -0
  406. package/src/components/ui/button.tsx +85 -0
  407. package/src/components/ui/card.tsx +79 -0
  408. package/src/components/ui/checkbox.tsx +28 -0
  409. package/src/components/ui/collapsible.tsx +9 -0
  410. package/src/components/ui/command.tsx +153 -0
  411. package/src/components/ui/delete-button.tsx +23 -0
  412. package/src/components/ui/dialog.tsx +125 -0
  413. package/src/components/ui/dropdown-menu.tsx +198 -0
  414. package/src/components/ui/input.tsx +55 -0
  415. package/src/components/ui/label.tsx +24 -0
  416. package/src/components/ui/readonly-banner.tsx +15 -0
  417. package/src/components/ui/resizable.tsx +43 -0
  418. package/src/components/ui/scroll-area.tsx +102 -0
  419. package/src/components/ui/select.tsx +160 -0
  420. package/src/components/ui/separator.tsx +29 -0
  421. package/src/components/ui/switch.tsx +27 -0
  422. package/src/components/ui/textarea.tsx +51 -0
  423. package/src/components/ui/toast.tsx +127 -0
  424. package/src/components/ui/toaster.tsx +33 -0
  425. package/src/components/ui/toggle-group.tsx +59 -0
  426. package/src/components/ui/toggle.tsx +43 -0
  427. package/src/components/ui/tooltip.tsx +32 -0
  428. package/src/dialogs/NodePickerDialog.tsx +84 -0
  429. package/src/dialogs/ValidationDialog.tsx +184 -0
  430. package/src/graph/BaseNode.tsx +557 -0
  431. package/src/graph/CustomEdge.tsx +185 -0
  432. package/src/graph/CustomNode.tsx +16 -0
  433. package/src/graph/FunctionCallNode.tsx +30 -0
  434. package/src/graph/PortHandle.tsx +189 -0
  435. package/src/graph/reactFlowRegistry.ts +26 -0
  436. package/src/hooks/use-toast.ts +125 -0
  437. package/src/hooks/useAvailableVariables.ts +20 -0
  438. package/src/hooks/useCanvasHistory.ts +22 -0
  439. package/src/hooks/useCanvasTabs.ts +168 -0
  440. package/src/hooks/useFunctionDiagnosticsSync.ts +40 -0
  441. package/src/hooks/useFunctionRegistry.ts +26 -0
  442. package/src/hooks/useFunctions.ts +44 -0
  443. package/src/hooks/useGraph.ts +161 -0
  444. package/src/hooks/useNodeDefinitions.ts +82 -0
  445. package/src/hooks/useParamErrors.ts +26 -0
  446. package/src/hooks/useResolvedTheme.ts +30 -0
  447. package/src/hooks/useResourceDiagnosticsSync.ts +58 -0
  448. package/src/hooks/useSuppressThemeTransition.ts +79 -0
  449. package/src/hooks/useWorkflowSerialization.ts +127 -0
  450. package/src/i18n/index.ts +53 -0
  451. package/src/i18n/locales/de.json +501 -0
  452. package/src/i18n/locales/en.json +557 -0
  453. package/src/index.ts +27 -0
  454. package/src/inputs/ExpressionInput.tsx +297 -0
  455. package/src/inputs/ParameterEditor.tsx +515 -0
  456. package/src/inputs/PortSection.tsx +144 -0
  457. package/src/panels/BuilderSidebar.tsx +301 -0
  458. package/src/panels/ChannelConfigPanel.tsx +49 -0
  459. package/src/panels/ChannelsPanel.tsx +28 -0
  460. package/src/panels/DebugConsolePanel.tsx +73 -0
  461. package/src/panels/DebugContextPanel.tsx +77 -0
  462. package/src/panels/DebugExternalIOPanel.tsx +180 -0
  463. package/src/panels/DiagnosticsPanel.tsx +170 -0
  464. package/src/panels/EdgeConfigPanel.tsx +104 -0
  465. package/src/panels/FunctionConfigPanel.tsx +179 -0
  466. package/src/panels/FunctionListPanel.tsx +45 -0
  467. package/src/panels/MemoryConfigPanel.tsx +55 -0
  468. package/src/panels/MemoryPanel.tsx +40 -0
  469. package/src/panels/ModelConfigPanel.tsx +41 -0
  470. package/src/panels/ModelsPanel.tsx +36 -0
  471. package/src/panels/NodeConfigPanel.tsx +630 -0
  472. package/src/panels/NodeLibrary.tsx +288 -0
  473. package/src/panels/ResourceConfigPanel.tsx +132 -0
  474. package/src/panels/ResourceListPanel.tsx +113 -0
  475. package/src/panels/VariableConfigPanel.tsx +161 -0
  476. package/src/panels/VariablesPanel.tsx +145 -0
  477. package/src/stores/canvasStore.test.ts +44 -0
  478. package/src/stores/canvasStore.ts +245 -0
  479. package/src/stores/debugStore.ts +74 -0
  480. package/src/stores/diagnosticsStore.ts +130 -0
  481. package/src/stores/editorStore.ts +202 -0
  482. package/src/styles/index.css +526 -0
  483. package/src/utils/categoryConstants.ts +26 -0
  484. package/src/utils/channelOperations.ts +86 -0
  485. package/src/utils/connectionRules.ts +137 -0
  486. package/src/utils/functionOperations.ts +179 -0
  487. package/src/utils/graphOperations.ts +550 -0
  488. package/src/utils/history.ts +207 -0
  489. package/src/utils/memoryOperations.ts +57 -0
  490. package/src/utils/migrateFunctionNodes.ts +107 -0
  491. package/src/utils/modelOperations.ts +55 -0
  492. package/src/utils/paramDisplay.ts +71 -0
  493. package/src/utils/resourceHelpers.ts +32 -0
  494. package/src/utils/translation.ts +28 -0
  495. package/src/utils/variableOperations.ts +75 -0
  496. package/tailwind-preset.ts +166 -0
@@ -0,0 +1,207 @@
1
+ import { StateCreator, StoreMutatorIdentifier } from "zustand";
2
+
3
+ // Opaque type for exporting/importing history state
4
+ export interface HistoryData {
5
+ past: HistoryFrame<unknown>[];
6
+ future: HistoryFrame<unknown>[];
7
+ }
8
+
9
+ // Public interface - only actions
10
+ export interface History {
11
+ /**
12
+ * Manually saves the current state as an undo checkpoint.
13
+ * Must be called BEFORE a state change that should be undoable.
14
+ */
15
+ takeCheckpoint: () => void;
16
+
17
+ /**
18
+ * Run the given operation and save a checkpoint if the state did change.
19
+ * Good to wrap multiple state changes in a single undoable action.
20
+ * If the operation throws, no checkpoint is saved and the error is propagated.
21
+ * @param operation Function that may perform a state change.
22
+ * @returns The result of the operation.
23
+ */
24
+ withCheckpoint: <R>(operation: () => R) => R;
25
+
26
+ /**
27
+ * Reverts the state to the previous snapshot in the undo history, if available.
28
+ * Moves the current state to the redo history.
29
+ */
30
+ undo: () => void;
31
+
32
+ /**
33
+ * Reapplies the most recently undone state from the redo history, if available.
34
+ * Moves the current state to the undo history.
35
+ */
36
+ redo: () => void;
37
+
38
+ /**
39
+ * Clears both the undo and redo history, but does not affect the current state.
40
+ */
41
+ clearHistory: () => void;
42
+
43
+ /**
44
+ * Returns true if there is at least one state in the undo history.
45
+ */
46
+ canUndo: () => boolean;
47
+
48
+ /**
49
+ * Returns true if there is at least one state in the redo history.
50
+ */
51
+ canRedo: () => boolean;
52
+
53
+ /**
54
+ * Exports the current undo/redo history as an opaque blob.
55
+ */
56
+ exportHistory: () => HistoryData;
57
+
58
+ /**
59
+ * Restores a previously exported history blob.
60
+ */
61
+ importHistory: (data: HistoryData) => void;
62
+ }
63
+
64
+ // A single frame in history
65
+ interface HistoryFrame<T> {
66
+ state: T;
67
+ timestamp: number;
68
+ }
69
+
70
+ // Internal state - not exposed publicly
71
+ interface HistoryState<T> {
72
+ _history_past: HistoryFrame<T>[];
73
+ _history_future: HistoryFrame<T>[];
74
+ }
75
+
76
+ /**
77
+ * Public, opaque change signal: a monotonic counter the middleware bumps on every
78
+ * history transition (checkpoint, undo, redo, clear, import). Subscribe to it to
79
+ * detect domain mutations and undo/redo in O(1). It never ticks on selection or
80
+ * drag — those mutate state without a checkpoint. Mirrors editorStore's counter
81
+ * of the same name for project-scoped (channel/memory/model) mutations.
82
+ */
83
+ export interface MutationCount {
84
+ readonly mutationCount: number;
85
+ }
86
+
87
+ // Configuration for history middleware
88
+ interface HistoryConfig<T> {
89
+ limit?: number;
90
+ partialize?: (state: T) => Partial<T>;
91
+ equality?: (before: Partial<T>, after: Partial<T>) => boolean;
92
+ }
93
+
94
+ export const history =
95
+ <T>(config: HistoryConfig<T> = {}) =>
96
+ <Mps extends [StoreMutatorIdentifier, unknown][] = [], Mcs extends [StoreMutatorIdentifier, unknown][] = []>(
97
+ storeInitializer: StateCreator<T, Mps, Mcs>,
98
+ ): StateCreator<T & HistoryState<T> & History & MutationCount, Mps, Mcs> => {
99
+ const {
100
+ limit = 50,
101
+ partialize = (state) => state,
102
+ equality = (before, after) => JSON.stringify(before) !== JSON.stringify(after),
103
+ } = config;
104
+
105
+ return (set, get, store) => {
106
+ type FullState = T & HistoryState<T> & History & MutationCount;
107
+
108
+ const initialState = storeInitializer(
109
+ set as Parameters<StateCreator<T, Mps, Mcs>>[0],
110
+ get as Parameters<StateCreator<T, Mps, Mcs>>[1],
111
+ store as Parameters<StateCreator<T, Mps, Mcs>>[2],
112
+ );
113
+
114
+ return {
115
+ ...initialState,
116
+ _history_past: [],
117
+ _history_future: [],
118
+ mutationCount: 0,
119
+
120
+ takeCheckpoint: () => {
121
+ const currentState = partialize(get() as T);
122
+ set((state: FullState) => ({
123
+ ...state,
124
+ _history_past: [...state._history_past, { state: currentState as T, timestamp: Date.now() }].slice(-limit),
125
+ _history_future: [],
126
+ mutationCount: state.mutationCount + 1,
127
+ }));
128
+ },
129
+
130
+ withCheckpoint: <R>(operation: () => R): R => {
131
+ const beforeState = partialize(get() as T);
132
+ // Execute operation and capture result to return later to caller
133
+ const result = operation();
134
+ const afterState = partialize(get() as T);
135
+ // Compare using provided equality function
136
+ const areEqual = equality(beforeState, afterState);
137
+ if (!areEqual) {
138
+ set((state: FullState) => ({
139
+ ...state,
140
+ _history_past: [...state._history_past, { state: beforeState as T, timestamp: Date.now() }].slice(-limit),
141
+ _history_future: [],
142
+ mutationCount: state.mutationCount + 1,
143
+ }));
144
+ }
145
+ return result;
146
+ },
147
+
148
+ undo: () => {
149
+ const state = get();
150
+ if (state._history_past.length === 0) return;
151
+ const past = [...state._history_past];
152
+ const previousFrame = past.pop()!;
153
+ // Save current state to future before restoring
154
+ const currentState = partialize(state as T);
155
+ set({
156
+ ...state,
157
+ ...previousFrame.state,
158
+ _history_past: past,
159
+ _history_future: [...state._history_future, { state: currentState as T, timestamp: Date.now() }],
160
+ mutationCount: state.mutationCount + 1,
161
+ } as FullState);
162
+ },
163
+
164
+ redo: () => {
165
+ const state = get();
166
+ if (state._history_future.length === 0) return;
167
+ const future = [...state._history_future];
168
+ const nextFrame = future.pop()!;
169
+ // Save current state to past before restoring
170
+ const currentState = partialize(state as T);
171
+ set({
172
+ ...state,
173
+ ...nextFrame.state,
174
+ _history_past: [...state._history_past, { state: currentState as T, timestamp: Date.now() }].slice(-limit),
175
+ _history_future: future,
176
+ mutationCount: state.mutationCount + 1,
177
+ } as FullState);
178
+ },
179
+
180
+ clearHistory: () => {
181
+ set((state: FullState) => ({
182
+ ...state,
183
+ _history_past: [],
184
+ _history_future: [],
185
+ mutationCount: state.mutationCount + 1,
186
+ }));
187
+ },
188
+
189
+ canUndo: () => (get() as FullState)._history_past.length > 0,
190
+ canRedo: () => (get() as FullState)._history_future.length > 0,
191
+
192
+ exportHistory: () => ({
193
+ past: [...(get() as FullState)._history_past],
194
+ future: [...(get() as FullState)._history_future],
195
+ }),
196
+
197
+ importHistory: (data: HistoryData) => {
198
+ set((state: FullState) => ({
199
+ ...state,
200
+ _history_past: [...data.past] as HistoryFrame<T>[],
201
+ _history_future: [...data.future] as HistoryFrame<T>[],
202
+ mutationCount: state.mutationCount + 1,
203
+ }));
204
+ },
205
+ } as FullState;
206
+ };
207
+ };
@@ -0,0 +1,57 @@
1
+ import { MemoryRegistry, type MemoryType, type Memory } from "@foresthubai/workflow-core/memory";
2
+ import { useEditorStore } from "../stores/editorStore";
3
+ import { generateId } from "@foresthubai/workflow-core/id";
4
+ import { seedDefaultArguments, uniqueName } from "./resourceHelpers";
5
+
6
+ /** Default label prefix per memory type. */
7
+ const LABEL_PREFIX: Record<MemoryType, string> = {
8
+ MemoryFile: "memory",
9
+ VectorDatabase: "vectordb",
10
+ };
11
+
12
+ /** Create a new memory primitive of the given type in the editor store. Returns the new instance. */
13
+ export function addMemory(type: MemoryType): Memory {
14
+ const id = generateId();
15
+ const existing = Object.values(useEditorStore.getState().memory).map((m) => m.label);
16
+ const instance: Memory = {
17
+ id,
18
+ label: uniqueName(LABEL_PREFIX[type], existing),
19
+ type,
20
+ arguments: seedDefaultArguments(MemoryRegistry.getByType(type)?.parameters ?? []),
21
+ };
22
+ useEditorStore.getState().setMemory((mem) => ({ ...mem, [id]: instance }));
23
+ return instance;
24
+ }
25
+
26
+ /**
27
+ * Apply a partial patch to a memory primitive. Top-level `label` and the
28
+ * `arguments` record are merged separately. The `type` discriminator is fixed
29
+ * at creation (the user picks a type when adding), so it is never patched here.
30
+ */
31
+ export function updateMemory(id: string, patch: { label?: string; arguments?: Record<string, unknown> }): void {
32
+ const key = id;
33
+ useEditorStore.getState().setMemory((mem) => {
34
+ const existing = mem[key];
35
+ if (!existing) return mem;
36
+ return {
37
+ ...mem,
38
+ [key]: {
39
+ ...existing,
40
+ ...(patch.label !== undefined ? { label: patch.label } : {}),
41
+ ...(patch.arguments ? { arguments: { ...existing.arguments, ...patch.arguments } } : {}),
42
+ },
43
+ };
44
+ });
45
+ }
46
+
47
+ export function deleteMemory(id: string): void {
48
+ const key = id;
49
+ useEditorStore.getState().setMemory((mem) => {
50
+ const { [key]: _drop, ...rest } = mem;
51
+ return rest;
52
+ });
53
+ const sel = useEditorStore.getState().selection;
54
+ if (sel.kind === "memory" && sel.id === id) {
55
+ useEditorStore.getState().clearSelection();
56
+ }
57
+ }
@@ -0,0 +1,107 @@
1
+ import type { OutputBinding, FunctionCallNode } from "@foresthubai/workflow-core/node";
2
+ import type { Expression } from "@foresthubai/workflow-core";
3
+ import { toast } from "../hooks/use-toast";
4
+ import i18n from "../i18n";
5
+ import { getAllCanvasStores } from "../stores/canvasStore";
6
+ import { useEditorStore } from "../stores/editorStore";
7
+ import { toFunctionInfo, type FunctionInfo } from "@foresthubai/workflow-core/function";
8
+ import { paramKey } from "@foresthubai/workflow-core/variable";
9
+ import { updateNodeInStore } from "./graphOperations";
10
+
11
+ // ============================================================================
12
+ // Single-Node Migration — builds the update payload for updateNodeInStore
13
+ // ============================================================================
14
+
15
+ function buildMigrationUpdate(
16
+ node: FunctionCallNode,
17
+ latest: FunctionInfo,
18
+ ): { arguments: Record<string, unknown>; functionInfo: FunctionInfo } {
19
+ const oldArgs = node.arguments;
20
+ const newArgs: Record<string, Expression | OutputBinding> = {};
21
+
22
+ // Preserve existing input expressions where uid matches; default empty otherwise.
23
+ // Always update dataType to match the latest function definition.
24
+ for (const arg of latest.arguments) {
25
+ const key = paramKey(arg);
26
+ const existing = oldArgs[key] as Expression | undefined;
27
+ newArgs[key] = existing ? { ...existing, dataType: arg.dataType } : { expression: "", references: [], dataType: arg.dataType };
28
+ }
29
+
30
+ // Preserve existing output bindings where uid matches; default emit for new returns.
31
+ for (const ret of latest.returns) {
32
+ const key = paramKey(ret);
33
+ const existing = oldArgs[key] as OutputBinding | undefined;
34
+ newArgs[key] = existing ?? { active: true, mode: "emit", name: ret.name };
35
+ }
36
+
37
+ return {
38
+ functionInfo: { ...latest },
39
+ arguments: newArgs,
40
+ };
41
+ }
42
+
43
+ // ============================================================================
44
+ // All-Canvas Migration
45
+ // ============================================================================
46
+
47
+ /**
48
+ * Iterate all canvas stores and migrate any stale FunctionCallNodes
49
+ * to match the latest function definitions.
50
+ *
51
+ * Does NOT create undo history entries — migration is automatic and transparent.
52
+ * Uses updateNodeInStore for proper store reactivity.
53
+ */
54
+ export function migrateFunctionCallNodes(): void {
55
+ const allStores = getAllCanvasStores();
56
+
57
+ // Latest call-site signatures come from the project-scoped declarations, projected
58
+ // to the flat snapshot form a FunctionCall stores (expressions dropped).
59
+ const latestFunctions: Record<string, FunctionInfo> = {};
60
+ for (const [id, def] of Object.entries(useEditorStore.getState().functions)) {
61
+ latestFunctions[id] = toFunctionInfo(def);
62
+ }
63
+
64
+ // Iterate all canvases and migrate stale FunctionCallNodes
65
+ let totalMigrated = 0;
66
+
67
+ for (const [, store] of Object.entries(allStores)) {
68
+ const nodes = store.getState().nodes;
69
+
70
+ for (const node of nodes) {
71
+ if (node.data.type !== "FunctionCall") continue;
72
+
73
+ const fnNode = node.data as FunctionCallNode;
74
+ const latest = latestFunctions[fnNode.functionInfo.id];
75
+ if (!latest) continue;
76
+
77
+ // Check if migration is needed (version or name change)
78
+ if (fnNode.functionInfo.version === latest.version && fnNode.functionInfo.name === latest.name) {
79
+ continue;
80
+ }
81
+
82
+ updateNodeInStore(store, node.id, buildMigrationUpdate(fnNode, latest));
83
+ totalMigrated++;
84
+ }
85
+ }
86
+
87
+ if (totalMigrated > 0) {
88
+ toast({
89
+ title: i18n.t("functionCallNodesMigrated"),
90
+ description: i18n.t("functionCallNodesMigratedDesc", { count: totalMigrated }),
91
+ });
92
+ }
93
+ }
94
+
95
+ // ============================================================================
96
+ // Module-Level Subscription
97
+ // ============================================================================
98
+
99
+ // Automatically migrate FunctionCallNodes whenever a function declaration changes.
100
+ // Declarations are non-undo-tracked editorStore edits, so this is a forward-only
101
+ // reconcile — no undo can revert a definition out from under its call sites.
102
+ let prevFunctions = useEditorStore.getState().functions;
103
+ useEditorStore.subscribe((state) => {
104
+ if (state.functions === prevFunctions) return;
105
+ prevFunctions = state.functions;
106
+ migrateFunctionCallNodes();
107
+ });
@@ -0,0 +1,55 @@
1
+ import { ModelRegistry, type ModelType, type Model } from "@foresthubai/workflow-core/model";
2
+ import { useEditorStore } from "../stores/editorStore";
3
+ import { generateId } from "@foresthubai/workflow-core/id";
4
+ import { seedDefaultArguments, uniqueName } from "./resourceHelpers";
5
+
6
+ /** Default label prefix per model type. */
7
+ const LABEL_PREFIX: Record<ModelType, string> = {
8
+ LLMModel: "model",
9
+ };
10
+
11
+ /** Create a new declared (custom) model of the given type. Returns the new instance. */
12
+ export function addModel(type: ModelType): Model {
13
+ const id = generateId();
14
+ const existing = Object.values(useEditorStore.getState().models).map((m) => m.label);
15
+ const instance: Model = {
16
+ id,
17
+ label: uniqueName(LABEL_PREFIX[type], existing),
18
+ type,
19
+ arguments: seedDefaultArguments(ModelRegistry.getByType(type)?.parameters ?? []),
20
+ };
21
+ useEditorStore.getState().setModels((models) => ({ ...models, [id]: instance }));
22
+ return instance;
23
+ }
24
+
25
+ /**
26
+ * Apply a partial patch to a declared model. Top-level `label` and the
27
+ * `arguments` record merge separately. `type` is fixed at creation.
28
+ */
29
+ export function updateModel(id: string, patch: { label?: string; arguments?: Record<string, unknown> }): void {
30
+ const key = id;
31
+ useEditorStore.getState().setModels((models) => {
32
+ const existing = models[key];
33
+ if (!existing) return models;
34
+ return {
35
+ ...models,
36
+ [key]: {
37
+ ...existing,
38
+ ...(patch.label !== undefined ? { label: patch.label } : {}),
39
+ ...(patch.arguments ? { arguments: { ...existing.arguments, ...patch.arguments } } : {}),
40
+ },
41
+ };
42
+ });
43
+ }
44
+
45
+ export function deleteModel(id: string): void {
46
+ const key = id;
47
+ useEditorStore.getState().setModels((models) => {
48
+ const { [key]: _drop, ...rest } = models;
49
+ return rest;
50
+ });
51
+ const sel = useEditorStore.getState().selection;
52
+ if (sel.kind === "model" && sel.id === id) {
53
+ useEditorStore.getState().clearSelection();
54
+ }
55
+ }
@@ -0,0 +1,71 @@
1
+ // Presentation-only formatters for inline node display. These render domain
2
+ // values to human-readable text; they live in the builder (not headless
3
+ // workflow-core) because formatting for display is an editor concern.
4
+ import type { Parameter } from "@foresthubai/workflow-core/parameter";
5
+ import type { Reference } from "@foresthubai/workflow-core";
6
+ import { refToLookupKey, type Variable } from "@foresthubai/workflow-core/variable";
7
+ import type { ResolvedExpr } from "@foresthubai/workflow-core/expression";
8
+
9
+ export interface ParamDisplayResult {
10
+ text: string;
11
+ isInvalid?: boolean;
12
+ }
13
+
14
+ /** Format a non-expression parameter value for inline display on the node. */
15
+ export function formatParamDisplay(
16
+ param: Parameter,
17
+ value: unknown,
18
+ variables: Record<string, Variable>,
19
+ channelLabels?: Record<string, string>,
20
+ memoryLabels?: Record<string, string>,
21
+ modelLabels?: Record<string, string>,
22
+ ): ParamDisplayResult {
23
+ switch (param.type) {
24
+ case "variableSelect": {
25
+ const ref = value as Reference | undefined;
26
+ if (!ref?.varId) return { text: "" };
27
+ const v = variables[refToLookupKey(ref)];
28
+ return v ? { text: v.name } : { text: "unknown", isInvalid: true };
29
+ }
30
+ case "bool":
31
+ return { text: (value as boolean) ? "true" : "false" };
32
+ case "weekdays": {
33
+ const days = value as string[] | undefined;
34
+ return { text: !days?.length ? "every day" : days.join(", ") };
35
+ }
36
+ case "selection": {
37
+ const option = param.options.find((o) => o.value === value);
38
+ return { text: option?.label ?? String(value ?? "") };
39
+ }
40
+ case "memorySelect": {
41
+ const memoryId = value as string | undefined;
42
+ if (!memoryId) return { text: "" };
43
+ return memoryLabels?.[memoryId] ? { text: memoryLabels[memoryId] } : { text: "unknown", isInvalid: true };
44
+ }
45
+ case "channelSelect": {
46
+ const channelId = value as string | undefined;
47
+ if (!channelId) return { text: "" };
48
+ return channelLabels?.[channelId] ? { text: channelLabels[channelId] } : { text: "unknown", isInvalid: true };
49
+ }
50
+ case "modelSelect": {
51
+ // A ModelID is human-meaningful (e.g. "claude-opus-4-7"); show the catalog/
52
+ // custom label when known, otherwise the id itself. Staleness is surfaced
53
+ // by diagnostics, not inline, since the catalog isn't available headlessly.
54
+ const modelId = value as string | undefined;
55
+ if (!modelId) return { text: "" };
56
+ return { text: modelLabels?.[modelId] ?? modelId };
57
+ }
58
+ default:
59
+ return { text: String(value ?? "") };
60
+ }
61
+ }
62
+
63
+ /** Format an expression for display by replacing variable-reference placeholders with their names. */
64
+ export function displayValue(expr: ResolvedExpr): string {
65
+ let result = expr.expression;
66
+ // Replace each variable reference placeholder with its name
67
+ expr.variables.forEach((variable) => {
68
+ result = result.replace(/\$\{\}/, variable?.name || "unknown");
69
+ });
70
+ return result;
71
+ }
@@ -0,0 +1,32 @@
1
+ import type { Parameter } from "@foresthubai/workflow-core/parameter";
2
+
3
+ /**
4
+ * Build the initial `arguments` record for a new resource instance: each
5
+ * parameter that declares a `default` gets seeded. Defaults are `structuredClone`d
6
+ * so two instances never share a mutable reference (objects/arrays).
7
+ *
8
+ * Shared by the registry-backed project primitives (memory, model). Channels
9
+ * have conditional, activation-rule parameters and seed inside `channelOperations`
10
+ * instead.
11
+ */
12
+ export function seedDefaultArguments(params: Parameter[]): Record<string, unknown> {
13
+ const args: Record<string, unknown> = {};
14
+ for (const param of params) {
15
+ if ("default" in param && param.default !== undefined) {
16
+ args[param.id] = structuredClone(param.default);
17
+ }
18
+ }
19
+ return args;
20
+ }
21
+
22
+ /**
23
+ * Return `desired` if it's free, otherwise append 2, 3, 4… until the result
24
+ * doesn't collide with `existing`.
25
+ */
26
+ export function uniqueName(desired: string, existing: Iterable<string>): string {
27
+ const taken = existing instanceof Set ? existing : new Set(existing);
28
+ if (!taken.has(desired)) return desired;
29
+ let i = 2;
30
+ while (taken.has(`${desired}${i}`)) i++;
31
+ return `${desired}${i}`;
32
+ }
@@ -0,0 +1,28 @@
1
+ import type { TFunction } from "i18next";
2
+ import type { NodeDefinition } from "@foresthubai/workflow-core/node";
3
+ import type { Parameter } from "@foresthubai/workflow-core/parameter";
4
+
5
+ /**
6
+ * Convention-based i18n helpers for description strings only.
7
+ *
8
+ * Keys follow the pattern:
9
+ * nodes.<NodeType>.description
10
+ * edges.<EdgeType>.description
11
+ * <prefix>.params.<paramId>.description
12
+ *
13
+ * Labels, categories, port names, and option labels stay as raw English code values.
14
+ * Only natural-language descriptions are translated.
15
+ */
16
+
17
+ export function getNodeDescription(t: TFunction, def: NodeDefinition): string {
18
+ return t(`nodes.${def.type}.description`, { defaultValue: def.description });
19
+ }
20
+
21
+ export function getParamDescription(t: TFunction, translationPrefix: string, param: Parameter): string {
22
+ if (!param.description) return "";
23
+ return t(`${translationPrefix}.params.${param.id}.description`, { defaultValue: param.description });
24
+ }
25
+
26
+ export function getEdgeDescription(t: TFunction, def: { description: string }, portType: string): string {
27
+ return t(`edges.${portType}.description`, { defaultValue: def.description });
28
+ }
@@ -0,0 +1,75 @@
1
+ import { declaredVarKey, type DeclaredVariable } from "@foresthubai/workflow-core/variable";
2
+ import type { DataType } from "@foresthubai/workflow-core";
3
+ import { getOrCreateCanvasStore } from "../stores/canvasStore";
4
+ import { useEditorStore } from "../stores/editorStore";
5
+ import { generateId } from "@foresthubai/workflow-core/id";
6
+
7
+ /**
8
+ * Per-canvas mutation helpers for declared variables. Mirrors
9
+ * utils/modelOperations.ts, but declared variables are canvas-scoped (they live
10
+ * in canvasStore.variables, not editorStore), so every helper takes a canvasId.
11
+ *
12
+ * Each write takes a history checkpoint first, matching the inline editor it
13
+ * replaces, so a single edit is one undo step.
14
+ */
15
+
16
+ /** Pick a fresh `var<N>` name that doesn't collide with existing declared variables. */
17
+ function nextDefaultName(existingNames: string[]): string {
18
+ let counter = 1;
19
+ while (existingNames.includes(`var${counter}`)) counter++;
20
+ return `var${counter}`;
21
+ }
22
+
23
+ /** Create a new declared variable on the given canvas. Returns its uid. */
24
+ export function addDeclaredVariable(canvasId: string): string {
25
+ const store = getOrCreateCanvasStore(canvasId);
26
+ store.takeCheckpoint();
27
+ const existingNames = Object.values(store.getState().variables)
28
+ .filter((v): v is DeclaredVariable => v.kind === "declared")
29
+ .map((v) => v.name);
30
+ const uid = generateId();
31
+ const newVar: DeclaredVariable = {
32
+ kind: "declared",
33
+ uid,
34
+ name: nextDefaultName(existingNames),
35
+ dataType: "int",
36
+ };
37
+ store.getState().setVariables((vars) => ({ ...vars, [declaredVarKey(uid)]: newVar }));
38
+ return uid;
39
+ }
40
+
41
+ /** Apply a partial patch to a declared variable. `kind`/`uid` are fixed. */
42
+ export function updateDeclaredVariable(canvasId: string, uid: string, updates: Partial<Omit<DeclaredVariable, "kind" | "uid">>): void {
43
+ const store = getOrCreateCanvasStore(canvasId);
44
+ store.takeCheckpoint();
45
+ const key = declaredVarKey(uid);
46
+ store.getState().setVariables((vars) => {
47
+ const existing = vars[key];
48
+ if (!existing || existing.kind !== "declared") return vars;
49
+ return { ...vars, [key]: { ...existing, ...updates } };
50
+ });
51
+ }
52
+
53
+ /**
54
+ * Change a declared variable's dataType. The previous initialValue is dropped —
55
+ * a value entered for one type rarely makes sense for another, so we reset
56
+ * rather than attempt a lossy coercion.
57
+ */
58
+ export function setDeclaredVariableType(canvasId: string, uid: string, dataType: DataType): void {
59
+ updateDeclaredVariable(canvasId, uid, { dataType, initialValue: undefined });
60
+ }
61
+
62
+ /** Delete a declared variable and clear its selection if it was open. */
63
+ export function deleteDeclaredVariable(canvasId: string, uid: string): void {
64
+ const store = getOrCreateCanvasStore(canvasId);
65
+ store.takeCheckpoint();
66
+ const key = declaredVarKey(uid);
67
+ store.getState().setVariables((vars) => {
68
+ const { [key]: _drop, ...rest } = vars;
69
+ return rest;
70
+ });
71
+ const sel = useEditorStore.getState().selection;
72
+ if (sel.kind === "variable" && sel.uid === uid) {
73
+ useEditorStore.getState().clearSelection();
74
+ }
75
+ }