@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,266 @@
1
+ import { useCallback, useMemo, type ReactNode } from "react";
2
+ import type { NodeData, NodeDefinition } from "@foresthubai/workflow-core/node";
3
+ import type { EdgeData, EdgeType } from "@foresthubai/workflow-core/edge";
4
+ import { isControlFlow } from "@foresthubai/workflow-core/edge";
5
+ import type { NodeCategory as NodeCategoryEnum } from "@foresthubai/workflow-core/node";
6
+
7
+ import { ScrollArea } from "./components/ui/scroll-area";
8
+ import { cn } from "./cn";
9
+ import { ChannelConfigPanel } from "./panels/ChannelConfigPanel";
10
+ import { DebugExternalIOPanel } from "./panels/DebugExternalIOPanel";
11
+ import { EdgeConfigPanel } from "./panels/EdgeConfigPanel";
12
+ import { FunctionConfigPanel } from "./panels/FunctionConfigPanel";
13
+ import { MemoryConfigPanel } from "./panels/MemoryConfigPanel";
14
+ import { ModelConfigPanel } from "./panels/ModelConfigPanel";
15
+ import { NodeConfigPanel } from "./panels/NodeConfigPanel";
16
+ import { VariableConfigPanel } from "./panels/VariableConfigPanel";
17
+ import { getOrCreateCanvasStore } from "./stores/canvasStore";
18
+ import { useEditorStore } from "./stores/editorStore";
19
+ import { declaredVarKey } from "@foresthubai/workflow-core/variable";
20
+
21
+ /**
22
+ * Right-side selection-routed config panel.
23
+ *
24
+ * Reads the current selection from editorStore (project-wide) and the
25
+ * selected node/edge from the active canvas store, then renders the
26
+ * appropriate config component. Receives graph mutation handlers from
27
+ * BuilderLayout — it never touches the canvas store directly for writes.
28
+ *
29
+ * Hidden while the user is mid selection-drag to avoid flicker.
30
+ */
31
+ export interface RightConfigPanelProps {
32
+ canvasId: string;
33
+ isDebugMode: boolean;
34
+ selectionDrag: boolean;
35
+
36
+ // Lookups
37
+ getNodeDef: (node: NodeData) => NodeDefinition | undefined;
38
+
39
+ // Mutation handlers (live in BuilderLayout, bound to active canvas)
40
+ onNodeUpdate: (nodeId: string, updates: Partial<NodeData>) => void;
41
+ onNodeDelete: (nodeId: string) => void;
42
+ onEdgeUpdate: (edgeId: string, updates: Partial<EdgeData>) => void;
43
+ onEdgeDelete: (edgeId: string) => void;
44
+ onClearSelection: () => void;
45
+
46
+ // Embedder-fulfilled
47
+ onTestNode?: (nodeId: string) => void;
48
+ onDebugStep?: (nodeId?: string) => void;
49
+ }
50
+
51
+ export const RightConfigPanel = ({
52
+ canvasId,
53
+ isDebugMode,
54
+ selectionDrag,
55
+ getNodeDef,
56
+ onNodeUpdate,
57
+ onNodeDelete,
58
+ onEdgeUpdate,
59
+ onEdgeDelete,
60
+ onClearSelection,
61
+ onTestNode,
62
+ onDebugStep,
63
+ }: RightConfigPanelProps) => {
64
+ const selection = useEditorStore((s) => s.selection);
65
+ const clearSelection = useEditorStore((s) => s.clearSelection);
66
+ const channels = useEditorStore((s) => s.channels);
67
+ const memory = useEditorStore((s) => s.memory);
68
+ const models = useEditorStore((s) => s.models);
69
+ const functions = useEditorStore((s) => s.functions);
70
+
71
+ const useStore = getOrCreateCanvasStore(canvasId);
72
+
73
+ const selectedNode = useStore(
74
+ useCallback(
75
+ (s) => {
76
+ if (selection.kind !== "graph" || selection.nodeIds.length !== 1) return null;
77
+ const node = s.nodes.find((n) => n.id === selection.nodeIds[0]);
78
+ return node?.data ?? null;
79
+ },
80
+ [selection],
81
+ ),
82
+ );
83
+
84
+ const selectedVariable = useStore(
85
+ useCallback(
86
+ (s) => {
87
+ if (selection.kind !== "variable") return null;
88
+ const v = s.variables[declaredVarKey(selection.uid)];
89
+ return v && v.kind === "declared" ? v : null;
90
+ },
91
+ [selection],
92
+ ),
93
+ );
94
+
95
+ const selectedEdgeRaw = useStore(
96
+ useCallback(
97
+ (s) => {
98
+ // Edge panel shows only for a lone edge (a node selection takes priority).
99
+ if (selection.kind !== "graph" || selection.edgeIds.length !== 1 || selection.nodeIds.length > 0) return null;
100
+ return s.edges.find((e) => e.id === selection.edgeIds[0]) ?? null;
101
+ },
102
+ [selection],
103
+ ),
104
+ );
105
+ const selectedEdge = selectedEdgeRaw
106
+ ? {
107
+ id: selectedEdgeRaw.id,
108
+ source: selectedEdgeRaw.source,
109
+ type: (selectedEdgeRaw.type ?? "control") as EdgeType,
110
+ data: (selectedEdgeRaw.data ?? {}) as EdgeData,
111
+ }
112
+ : null;
113
+
114
+ const sourceControlEdgeCount = useStore(
115
+ useCallback(
116
+ (s) => {
117
+ if (!selectedEdge) return 0;
118
+ return s.edges.filter((e) => e.source === selectedEdge.source && isControlFlow(e.type as EdgeType)).length;
119
+ },
120
+ // eslint-disable-next-line react-hooks/exhaustive-deps
121
+ [selectedEdge?.source],
122
+ ),
123
+ );
124
+
125
+ const selectedChannel = useMemo(
126
+ () => (selection.kind === "channel" ? (Object.values(channels).find((v) => v.id === selection.id) ?? null) : null),
127
+ [selection, channels],
128
+ );
129
+
130
+ const selectedMemory = useMemo(
131
+ () => (selection.kind === "memory" ? (Object.values(memory).find((m) => m.id === selection.id) ?? null) : null),
132
+ [selection, memory],
133
+ );
134
+
135
+ const selectedModel = useMemo(
136
+ () => (selection.kind === "model" ? (Object.values(models).find((m) => m.id === selection.id) ?? null) : null),
137
+ [selection, models],
138
+ );
139
+
140
+ const selectedFunction = useMemo(
141
+ () => (selection.kind === "function" ? (functions[selection.id] ?? null) : null),
142
+ [selection, functions],
143
+ );
144
+
145
+ const getNodeCategory = useCallback(
146
+ (node: NodeData) => getNodeDef(node)?.category as NodeCategoryEnum | undefined,
147
+ [getNodeDef],
148
+ );
149
+
150
+ const handleTestNode = useCallback((nodeId: string) => onTestNode?.(nodeId), [onTestNode]);
151
+
152
+ if (selectionDrag) return null;
153
+
154
+ if (isDebugMode) {
155
+ if (!selectedNode) return null;
156
+ return (
157
+ <Shell bg="bg-background" pad>
158
+ <DebugExternalIOPanel
159
+ canvasId={canvasId}
160
+ onStep={onDebugStep ?? (() => {})}
161
+ getNodeCategory={getNodeCategory}
162
+ />
163
+ </Shell>
164
+ );
165
+ }
166
+
167
+ if (selectedNode) {
168
+ return (
169
+ <Shell>
170
+ <NodeConfigPanel
171
+ canvasId={canvasId}
172
+ selectedNode={selectedNode}
173
+ onNodeUpdate={onNodeUpdate}
174
+ onNodeDelete={onNodeDelete}
175
+ onClose={onClearSelection}
176
+ onOpenTest={handleTestNode}
177
+ getNodeDef={getNodeDef}
178
+ />
179
+ </Shell>
180
+ );
181
+ }
182
+
183
+ if (selectedEdge) {
184
+ return (
185
+ <Shell>
186
+ <EdgeConfigPanel
187
+ canvasId={canvasId}
188
+ edgeId={selectedEdge.id}
189
+ edgeType={selectedEdge.type}
190
+ edgeData={selectedEdge.data}
191
+ sourceControlEdgeCount={sourceControlEdgeCount}
192
+ onEdgeUpdate={onEdgeUpdate}
193
+ onEdgeDelete={onEdgeDelete}
194
+ onClose={onClearSelection}
195
+ />
196
+ </Shell>
197
+ );
198
+ }
199
+
200
+ if (selectedVariable) {
201
+ return (
202
+ <Shell>
203
+ <VariableConfigPanel
204
+ canvasId={canvasId}
205
+ variable={selectedVariable}
206
+ onClose={clearSelection}
207
+ />
208
+ </Shell>
209
+ );
210
+ }
211
+
212
+ if (selectedChannel) {
213
+ return (
214
+ <Shell>
215
+ <ChannelConfigPanel channel={selectedChannel} onClose={clearSelection} />
216
+ </Shell>
217
+ );
218
+ }
219
+
220
+ if (selectedMemory) {
221
+ return (
222
+ <Shell>
223
+ <MemoryConfigPanel memory={selectedMemory} onClose={clearSelection} />
224
+ </Shell>
225
+ );
226
+ }
227
+
228
+ if (selectedModel) {
229
+ return (
230
+ <Shell>
231
+ <ModelConfigPanel model={selectedModel} onClose={clearSelection} />
232
+ </Shell>
233
+ );
234
+ }
235
+
236
+ if (selectedFunction) {
237
+ return (
238
+ <Shell>
239
+ <FunctionConfigPanel func={selectedFunction} onClose={clearSelection} />
240
+ </Shell>
241
+ );
242
+ }
243
+
244
+ return null;
245
+ };
246
+
247
+ /**
248
+ * Right-panel chrome — fixed-width column with the bordered card background
249
+ * and an overlay scrollbar. Extracted because all eight selection branches
250
+ * render the same shell; keeping them in lockstep by hand was an obvious
251
+ * drift risk. The debug variant overrides the surface and adds inner padding
252
+ * (other variants pad inside their own ConfigPanel).
253
+ */
254
+ const Shell = ({
255
+ bg = "bg-card",
256
+ pad = false,
257
+ children,
258
+ }: {
259
+ bg?: string;
260
+ pad?: boolean;
261
+ children: ReactNode;
262
+ }) => (
263
+ <ScrollArea className={cn("w-80 border-l border-border", bg)} viewportClassName={pad ? "p-3" : undefined}>
264
+ {children}
265
+ </ScrollArea>
266
+ );
@@ -0,0 +1,412 @@
1
+ import type { ApiWorkflow } from "@foresthubai/workflow-core/workflow";
2
+ import type { ModelInfo } from "@foresthubai/workflow-core/model";
3
+ import {
4
+ validateWorkflowState,
5
+ validateChannel,
6
+ validateMemory,
7
+ validateModel,
8
+ type Diagnostic,
9
+ type ValidationResult,
10
+ } from "@foresthubai/workflow-core/diagnostics";
11
+ import { forwardRef, useCallback, useEffect, useImperativeHandle, useLayoutEffect, useRef, useState } from "react";
12
+ import { I18nextProvider } from "react-i18next";
13
+
14
+ import i18n from "./i18n";
15
+ import { toast } from "./hooks/use-toast";
16
+ import ValidationDialog from "./dialogs/ValidationDialog";
17
+ import { BuilderLayout } from "./BuilderLayout";
18
+ import { TooltipProvider } from "./components/ui/tooltip";
19
+ import { Toaster } from "./components/ui/toaster";
20
+ import { useCanvasTabs } from "./hooks/useCanvasTabs";
21
+ import { useResourceDiagnosticsSync } from "./hooks/useResourceDiagnosticsSync";
22
+ import { useFunctionDiagnosticsSync } from "./hooks/useFunctionDiagnosticsSync";
23
+ import { useSuppressThemeTransition } from "./hooks/useSuppressThemeTransition";
24
+ import { useFunctions } from "./hooks/useFunctions";
25
+ import { useWorkflowSerialization, readStateFromStores } from "./hooks/useWorkflowSerialization";
26
+ import {
27
+ clearAllCanvasStores,
28
+ getAllCanvasStores,
29
+ getOrCreateCanvasStore,
30
+ subscribeCanvasRegistryChanges,
31
+ MAIN_CANVAS_ID,
32
+ type CanvasStore,
33
+ } from "./stores/canvasStore";
34
+ import { useDebugStore, type DebugSessionPhase } from "./stores/debugStore";
35
+ import { useEditorStore } from "./stores/editorStore";
36
+
37
+ /** BuilderMode steers the overall behavior of the workflow builder. */
38
+ export type BuilderMode = { type: "edit" } | { type: "preview" } | { type: "debug" };
39
+
40
+ /** True when canvas mutations should be blocked (preview or debug). */
41
+ export function isReadOnly(mode: BuilderMode): boolean {
42
+ return mode.type !== "edit";
43
+ }
44
+
45
+ /** Type guard for preview mode. */
46
+ export function isPreview(mode: BuilderMode): boolean {
47
+ return mode.type === "preview";
48
+ }
49
+
50
+ // ============================================================================
51
+ // Public contract
52
+ // ============================================================================
53
+
54
+ export interface WorkflowBuilderProps {
55
+ /** Workflow loaded on mount. If none is provided, an empty workflow is created. */
56
+ initialWorkflow?: ApiWorkflow;
57
+ /** Builder mode on mount. Defaults to { type: "edit" }. */
58
+ initialMode?: BuilderMode;
59
+ /**
60
+ * Static model catalog — the models the llmproxy supports. Shown as the
61
+ * built-in options in agent model pickers. Self-hosted/custom models are
62
+ * declared in the Models tab instead. Defaults to [] (empty dropdown).
63
+ */
64
+ models?: ModelInfo[];
65
+ /**
66
+ * UI language (e.g. "en", "de"). The host owns locale; the builder follows.
67
+ * Defaults to "en". The builder never auto-detects language.
68
+ */
69
+ language?: string;
70
+
71
+ // ── Embedder-fulfilled actions (builder asks, embedder does) ──
72
+ /** A node requested embedder-side testing (e.g. Agent "Test" button). */
73
+ onTestNode?: (nodeId: string) => void;
74
+ /** Step request from the in-builder debug panel — embedder forwards to the engine. */
75
+ onDebugStep?: (nodeId?: string) => void;
76
+
77
+ // ── Lifecycle events ──
78
+ /** Fires after any domain-state mutation. Pull current state via handle.exportWorkflow(). */
79
+ onChange?: () => void;
80
+ /**
81
+ * Undo/redo availability for the ACTIVE canvas changed — on history mutation,
82
+ * undo/redo, or a tab switch (each canvas has its own history). For wiring host
83
+ * undo/redo buttons.
84
+ */
85
+ onHistoryChange?: (state: { canUndo: boolean; canRedo: boolean }) => void;
86
+ /** Unexpected error during builder operations (e.g. failed load). */
87
+ onError?: (error: Error) => void;
88
+ }
89
+
90
+ export interface WorkflowBuilderHandle {
91
+ // State I/O
92
+ loadWorkflow: (workflow: ApiWorkflow) => void;
93
+ exportWorkflow: () => ApiWorkflow;
94
+ clear: () => void;
95
+
96
+ // Mode (replaces preview/debug entry-point props)
97
+ setMode: (mode: BuilderMode) => void;
98
+ getMode: () => BuilderMode;
99
+
100
+ // Initiate the in-builder validation process which will either show the validation dialog or a toast if clean.
101
+ validate: () => void;
102
+
103
+ // History (so embedder chrome can wire undo/redo buttons)
104
+ undo: () => void;
105
+ redo: () => void;
106
+
107
+ // Debug (embedder pushes engine events for visualization)
108
+ setDebugPhase: (phase: DebugSessionPhase) => void;
109
+ }
110
+
111
+ // ============================================================================
112
+ // Component — owns tabs/functions/dialogs; exposes the handle; delegates
113
+ // layout/canvas rendering to BuilderLayout.
114
+ // ============================================================================
115
+
116
+ export const WorkflowBuilder = forwardRef<WorkflowBuilderHandle, WorkflowBuilderProps>(
117
+ function WorkflowBuilder(props, ref) {
118
+ const {
119
+ initialWorkflow,
120
+ initialMode,
121
+ models,
122
+ language,
123
+ onTestNode,
124
+ onDebugStep,
125
+ onChange,
126
+ onHistoryChange,
127
+ onError,
128
+ } = props;
129
+
130
+ // Host drives locale. useLayoutEffect (not useEffect) so the language is set
131
+ // before paint — mounting with language="de" shows German on the first frame
132
+ // rather than flashing English. changeLanguage is sync here (bundled resources).
133
+ useLayoutEffect(() => {
134
+ if (language && i18n.language !== language) i18n.changeLanguage(language);
135
+ }, [language]);
136
+
137
+ const { importProject, exportProject } = useWorkflowSerialization();
138
+
139
+ // Color-mode toggles should snap, not fade — see hook docs.
140
+ useSuppressThemeTransition();
141
+
142
+ // Keep project-scoped (channel + memory + model) diagnostics in sync. Mounted
143
+ // once here at the root so badges survive sidebar tab open/close.
144
+ useResourceDiagnosticsSync({
145
+ selectItems: (s) => s.channels,
146
+ validate: validateChannel,
147
+ getStored: (d) => d.byChannelId,
148
+ set: (d, id, diags) => d.setChannelDiagnostics(id, diags),
149
+ clear: (d, id) => d.clearChannelDiagnostics(id),
150
+ });
151
+ useResourceDiagnosticsSync({
152
+ selectItems: (s) => s.memory,
153
+ validate: validateMemory,
154
+ getStored: (d) => d.byMemoryId,
155
+ set: (d, id, diags) => d.setMemoryDiagnostics(id, diags),
156
+ clear: (d, id) => d.clearMemoryDiagnostics(id),
157
+ });
158
+ useResourceDiagnosticsSync({
159
+ selectItems: (s) => s.models,
160
+ validate: validateModel,
161
+ getStored: (d) => d.byModelId,
162
+ set: (d, id, diags) => d.setModelDiagnostics(id, diags),
163
+ clear: (d, id) => d.clearModelDiagnostics(id),
164
+ });
165
+ // Functions are a FunctionDeclaration (not a flat resource bag), so they use a
166
+ // dedicated diagnostics sync.
167
+ useFunctionDiagnosticsSync();
168
+
169
+ // Push the embedder-supplied model catalog into the store so agent model
170
+ // pickers can read it. Catalog is config (not workflow content), so this
171
+ // never fires onChange.
172
+ useEffect(() => {
173
+ useEditorStore.getState().setAvailableModels(models ?? []);
174
+ }, [models]);
175
+
176
+ // Canvas tabs + functions live here because they survive canvas switches.
177
+ const canvasTabs = useCanvasTabs();
178
+ const functionsHook = useFunctions({ onOpenTab: canvasTabs.openTab });
179
+
180
+ // Built-in validation UX. validate() presents the result itself rather than
181
+ // returning it: a success toast when clean, else this dialog. Non-null = open.
182
+ const [validation, setValidation] = useState<ValidationResult | null>(null);
183
+
184
+ const runValidate = useCallback(() => {
185
+ const result = validateWorkflowState(readStateFromStores());
186
+ if (result.totalErrors === 0 && result.totalWarnings === 0) {
187
+ toast({ title: i18n.t("validationPassed") });
188
+ } else {
189
+ setValidation(result);
190
+ }
191
+ }, []);
192
+
193
+ // Jump to a diagnostic's target, then dismiss the dialog so it's visible.
194
+ const navigateToDiagnostic = useCallback(
195
+ (d: Diagnostic) => {
196
+ const editor = useEditorStore.getState();
197
+ // Project-scoped targets: open the matching sidebar tab AND select the item.
198
+ if (d.channelId) {
199
+ editor.setActiveSidebarTab("channels");
200
+ editor.selectChannel(d.channelId);
201
+ } else if (d.memoryId) {
202
+ editor.setActiveSidebarTab("memory");
203
+ editor.selectMemory(d.memoryId);
204
+ } else if (d.modelId) {
205
+ editor.setActiveSidebarTab("models");
206
+ editor.selectModel(d.modelId);
207
+ } else if (d.canvasId) {
208
+ // Switch first so selectGraph targets the right canvas, then select.
209
+ if (d.canvasId === MAIN_CANVAS_ID) editor.setActiveCanvas(MAIN_CANVAS_ID);
210
+ else functionsHook.openFunction(d.canvasId);
211
+ if (d.nodeId) editor.selectGraph([d.nodeId], []);
212
+ else if (d.edgeId) editor.selectGraph([], [d.edgeId]);
213
+ }
214
+ setValidation(null);
215
+ },
216
+ [functionsHook],
217
+ );
218
+
219
+ // Initial load (runs once, even under StrictMode double-mount).
220
+ const initialLoadDone = useRef(false);
221
+ useEffect(() => {
222
+ if (initialLoadDone.current) return;
223
+ initialLoadDone.current = true;
224
+ try {
225
+ if (initialMode) useEditorStore.getState().setBuilderMode(initialMode);
226
+ if (initialWorkflow) importProject(initialWorkflow);
227
+ } catch (e) {
228
+ onError?.(e instanceof Error ? e : new Error(String(e)));
229
+ }
230
+ // eslint-disable-next-line react-hooks/exhaustive-deps
231
+ }, []);
232
+
233
+ // ── Lifecycle subscriptions ────────────────────────────────────────────
234
+ // Stash latest callbacks in refs so the subscription effect runs once.
235
+ const onChangeRef = useRef(onChange);
236
+ const onHistoryChangeRef = useRef(onHistoryChange);
237
+ onChangeRef.current = onChange;
238
+ onHistoryChangeRef.current = onHistoryChange;
239
+
240
+ // onChange fires on any domain change. For canvas content we watch the
241
+ // history middleware's `mutationCount`, which bumps on checkpoints AND
242
+ // undo/redo but never on selection/drag (those go through setNodes without a
243
+ // checkpoint). That makes onChange honest for undo/redo and silent on
244
+ // view-state — the thing a raw store subscription can't do, since selection
245
+ // lives inside the nodes array. (editorStore exposes its own `mutationCount`
246
+ // for project-scoped channel/memory/model edits; watched separately below.)
247
+ useEffect(() => {
248
+ const subs: Array<() => void> = [];
249
+ const subscribedStores = new WeakSet<CanvasStore>();
250
+
251
+ function subscribeCanvas(store: CanvasStore) {
252
+ if (subscribedStores.has(store)) return;
253
+ subscribedStores.add(store);
254
+ let prev = store.getState().mutationCount;
255
+ const unsub = store.subscribe((state) => {
256
+ if (state.mutationCount !== prev) {
257
+ prev = state.mutationCount;
258
+ onChangeRef.current?.();
259
+ }
260
+ });
261
+ subs.push(unsub);
262
+ }
263
+
264
+ function subscribeAllCanvases() {
265
+ for (const store of Object.values(getAllCanvasStores())) {
266
+ subscribeCanvas(store);
267
+ }
268
+ }
269
+
270
+ subscribeAllCanvases();
271
+
272
+ // Canvas stores come and go (function add/delete, project load). Re-subscribe
273
+ // to the new set so newly created function bodies are watched. We do NOT fire
274
+ // onChange here: function add/delete/rename and all definition edits flow
275
+ // through editorStore.mutationCount (setFunctions), caught by the editor
276
+ // subscription below — so the change signal is covered without double-firing.
277
+ const unsubRegistry = subscribeCanvasRegistryChanges(() => {
278
+ subscribeAllCanvases();
279
+ });
280
+ subs.push(unsubRegistry);
281
+
282
+ // Project-scoped mutations (channels, memory, models, functions).
283
+ let prevEditorCount = useEditorStore.getState().mutationCount;
284
+ const unsubEditor = useEditorStore.subscribe((state) => {
285
+ if (state.mutationCount !== prevEditorCount) {
286
+ prevEditorCount = state.mutationCount;
287
+ onChangeRef.current?.();
288
+ }
289
+ });
290
+ subs.push(unsubEditor);
291
+
292
+ return () => {
293
+ for (const u of subs) u();
294
+ };
295
+ }, []);
296
+
297
+ // History-affordance subscription — emits the ACTIVE canvas's canUndo/canRedo
298
+ // so host chrome can drive undo/redo buttons. Distinct from onChange: a tab
299
+ // switch changes which history is active without being a domain mutation, so
300
+ // it must update buttons without marking the document dirty.
301
+ useEffect(() => {
302
+ let prevCanUndo: boolean | null = null;
303
+ let prevCanRedo: boolean | null = null;
304
+ let unsubActive: (() => void) | null = null;
305
+
306
+ const emit = () => {
307
+ const store = getOrCreateCanvasStore(useEditorStore.getState().activeCanvasId);
308
+ const canUndo = store.canUndo();
309
+ const canRedo = store.canRedo();
310
+ if (canUndo === prevCanUndo && canRedo === prevCanRedo) return;
311
+ prevCanUndo = canUndo;
312
+ prevCanRedo = canRedo;
313
+ onHistoryChangeRef.current?.({ canUndo, canRedo });
314
+ };
315
+
316
+ // Bind to the current active canvas (a) and emit. Re-run on tab switch (b)
317
+ // and on store-instance rebuilds from load/clear (c) — both can change which
318
+ // store, or store object, is active under us.
319
+ const bindActive = () => {
320
+ unsubActive?.();
321
+ unsubActive = getOrCreateCanvasStore(useEditorStore.getState().activeCanvasId).subscribe(emit);
322
+ emit();
323
+ };
324
+
325
+ bindActive();
326
+
327
+ let prevActive = useEditorStore.getState().activeCanvasId;
328
+ const unsubEditor = useEditorStore.subscribe((state) => {
329
+ if (state.activeCanvasId !== prevActive) {
330
+ prevActive = state.activeCanvasId;
331
+ bindActive(); // (b) tab switch
332
+ }
333
+ });
334
+ const unsubRegistry = subscribeCanvasRegistryChanges(bindActive); // (c) load/clear rebuild
335
+
336
+ return () => {
337
+ unsubActive?.();
338
+ unsubEditor();
339
+ unsubRegistry();
340
+ };
341
+ }, []);
342
+
343
+ // ── Imperative handle ─────────────────────────────────────────────────
344
+ useImperativeHandle(
345
+ ref,
346
+ (): WorkflowBuilderHandle => ({
347
+ loadWorkflow: (workflow) => {
348
+ try {
349
+ importProject(workflow);
350
+ } catch (e) {
351
+ onError?.(e instanceof Error ? e : new Error(String(e)));
352
+ }
353
+ },
354
+ exportWorkflow: () => exportProject(),
355
+ clear: () => {
356
+ clearAllCanvasStores();
357
+ // Function declarations are project-scoped (not in canvas stores), so reset
358
+ // them explicitly alongside the cleared bodies.
359
+ useEditorStore.getState().setFunctions(() => ({}));
360
+ useEditorStore.getState().clearSelection();
361
+ },
362
+ setMode: (mode) => useEditorStore.getState().setBuilderMode(mode),
363
+ getMode: () => useEditorStore.getState().builderMode,
364
+ validate: runValidate,
365
+ undo: () => getOrCreateCanvasStore(useEditorStore.getState().activeCanvasId).undo(),
366
+ redo: () => getOrCreateCanvasStore(useEditorStore.getState().activeCanvasId).redo(),
367
+ setDebugPhase: (phase) => useDebugStore.getState().setPhase(phase),
368
+ }),
369
+ [importProject, exportProject, onError, runValidate],
370
+ );
371
+
372
+ // I18nextProvider scopes the builder's PRIVATE i18n instance to this subtree,
373
+ // so the useTranslation() consumers read it (never the host's i18next).
374
+ //
375
+ // The `fh-builder` root carries the builder's OWN base look (font,
376
+ // text color, antialiasing) on its own element. The builder no longer styles
377
+ // the host's <body> — the host owns the page. `h-full w-full` makes the
378
+ // builder fill whatever container it's mounted in; it never assumes the
379
+ // viewport. TooltipProvider + Toaster live inside the package so the embedder
380
+ // doesn't need to know we use Radix tooltips or shadcn toasts internally.
381
+ return (
382
+ <I18nextProvider i18n={i18n}>
383
+ <TooltipProvider delayDuration={300}>
384
+ <div className="fh-builder h-full w-full bg-background text-foreground font-sans antialiased">
385
+ <BuilderLayout
386
+ functions={functionsHook.functions}
387
+ onOpenFunction={functionsHook.openFunction}
388
+ onCreateFunction={functionsHook.createFunction}
389
+ canvasTabs={canvasTabs.tabs}
390
+ onCanvasTabChange={canvasTabs.setActiveTabId}
391
+ onCanvasTabClose={canvasTabs.closeTab}
392
+ onCanvasTabReorder={canvasTabs.reorderTabs}
393
+ onTestNode={onTestNode}
394
+ onDebugStep={onDebugStep}
395
+ />
396
+ <Toaster />
397
+ {validation && (
398
+ <ValidationDialog
399
+ open
400
+ onOpenChange={(o) => {
401
+ if (!o) setValidation(null);
402
+ }}
403
+ validation={validation}
404
+ onSelectDiagnostic={navigateToDiagnostic}
405
+ />
406
+ )}
407
+ </div>
408
+ </TooltipProvider>
409
+ </I18nextProvider>
410
+ );
411
+ },
412
+ );
package/src/cn.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { clsx, type ClassValue } from "clsx"
2
+ import { twMerge } from "tailwind-merge"
3
+
4
+ export function cn(...inputs: ClassValue[]) {
5
+ return twMerge(clsx(inputs))
6
+ }