windmill-components 1.677.1 → 1.687.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 (354) hide show
  1. package/package/components/AppConnectInner.svelte +6 -0
  2. package/package/components/CiTestResults.svelte +64 -0
  3. package/package/components/CiTestResults.svelte.d.ts +7 -0
  4. package/package/components/CompareWorkspaces.svelte +626 -418
  5. package/package/components/DBManager.svelte +35 -4
  6. package/package/components/DBManager.svelte.d.ts +2 -0
  7. package/package/components/DBManagerContent.svelte +3 -1
  8. package/package/components/DBManagerContent.svelte.d.ts +3 -0
  9. package/package/components/DBManagerDrawer.svelte +145 -3
  10. package/package/components/DBTableEditor.svelte +14 -4
  11. package/package/components/DatatablePicker.svelte +2 -5
  12. package/package/components/DatatableSchemaDiff.svelte +531 -0
  13. package/package/components/DatatableSchemaDiff.svelte.d.ts +29 -0
  14. package/package/components/DedicatedWorkersSelector.svelte +4 -2
  15. package/package/components/DefaultTagsInner.svelte +42 -2
  16. package/package/components/DeployWorkspaceDrawer.svelte +1 -1
  17. package/package/components/Dev.svelte +20 -3
  18. package/package/components/Editor.svelte +1 -1
  19. package/package/components/EditorBar.svelte +1 -1
  20. package/package/components/EditorBar.svelte.d.ts +1 -1
  21. package/package/components/FlowStatusViewerInner.svelte +269 -220
  22. package/package/components/FlowTimeline.svelte +1 -1
  23. package/package/components/FolderEditor.svelte +189 -4
  24. package/package/components/ForkWorkspaceBanner.svelte +82 -11
  25. package/package/components/GlobalUserOffboardingModal.svelte +293 -0
  26. package/package/components/GlobalUserOffboardingModal.svelte.d.ts +10 -0
  27. package/package/components/InstanceSettings.svelte +22 -3
  28. package/package/components/Login.svelte +22 -10
  29. package/package/components/ModuleTest.svelte +2 -1
  30. package/package/components/NoMainFuncBadge.svelte +1 -1
  31. package/package/components/OffboardItemsBox.svelte +56 -0
  32. package/package/components/OffboardItemsBox.svelte.d.ts +12 -0
  33. package/package/components/OffboardReassignControls.svelte +47 -0
  34. package/package/components/OffboardReassignControls.svelte.d.ts +20 -0
  35. package/package/components/OffboardWorkspaceSection.svelte +110 -0
  36. package/package/components/OffboardWorkspaceSection.svelte.d.ts +24 -0
  37. package/package/components/OnBehalfOfSelector.svelte +21 -3
  38. package/package/components/OnBehalfOfSelector.svelte.d.ts +7 -0
  39. package/package/components/QueueAlerts.svelte +10 -10
  40. package/package/components/ResourcePicker.svelte +2 -2
  41. package/package/components/ScriptBuilder.svelte +52 -11
  42. package/package/components/ScriptEditor.svelte +1 -3
  43. package/package/components/ScriptEditor.svelte.d.ts +1 -1
  44. package/package/components/ShareModal.svelte +236 -98
  45. package/package/components/SuperadminSettingsInner.svelte +362 -315
  46. package/package/components/UserOffboardingModal.svelte +238 -0
  47. package/package/components/UserOffboardingModal.svelte.d.ts +10 -0
  48. package/package/components/WorkspaceDeployLayout.svelte +3 -3
  49. package/package/components/WorkspaceDeployLayout.svelte.d.ts +1 -0
  50. package/package/components/apps/editor/inlineScriptsPanel/InlineScriptRunnableByPath.svelte +4 -2
  51. package/package/components/apps/editor/settingsPanel/mainInput/RunnableSelector.svelte +12 -0
  52. package/package/components/assets/AssetsDropdownButton.svelte +1 -1
  53. package/package/components/common/confirmationModal/ConfirmationModal.svelte +1 -1
  54. package/package/components/common/table/AppRow.svelte +3 -3
  55. package/package/components/common/table/FlowRow.svelte +3 -3
  56. package/package/components/common/table/RawAppRow.svelte +4 -4
  57. package/package/components/common/table/Row.svelte +6 -2
  58. package/package/components/common/table/ScriptRow.svelte +11 -3
  59. package/package/components/copilot/chat/AIChatManager.svelte.js +2 -2
  60. package/package/components/copilot/chat/anthropic.d.ts +7 -1
  61. package/package/components/copilot/chat/anthropic.js +5 -2
  62. package/package/components/copilot/chat/app/core.js +129 -1
  63. package/package/components/copilot/chat/app/core.test.js +192 -0
  64. package/package/components/copilot/chat/chatLoop.d.ts +3 -0
  65. package/package/components/copilot/chat/chatLoop.js +13 -5
  66. package/package/components/copilot/chat/flow/FlowAIChat.svelte +55 -76
  67. package/package/components/copilot/chat/flow/core.d.ts +13 -3
  68. package/package/components/copilot/chat/flow/core.js +467 -116
  69. package/package/components/copilot/chat/flow/helperUtils.d.ts +19 -0
  70. package/package/components/copilot/chat/flow/helperUtils.js +68 -0
  71. package/package/components/copilot/chat/flow/helperUtils.test.js +116 -0
  72. package/package/components/copilot/chat/flow/inlineScriptsUtils.d.ts +5 -24
  73. package/package/components/copilot/chat/flow/inlineScriptsUtils.js +30 -55
  74. package/package/components/copilot/chat/flow/utils.test.js +59 -0
  75. package/package/components/copilot/chat/openai-responses.d.ts +7 -1
  76. package/package/components/copilot/chat/openai-responses.js +5 -2
  77. package/package/components/copilot/chat/shared.d.ts +1 -2
  78. package/package/components/copilot/chat/shared.js +94 -52
  79. package/package/components/copilot/chat/tokenUsage.d.ts +23 -0
  80. package/package/components/copilot/chat/tokenUsage.js +42 -0
  81. package/package/components/copilot/lib.d.ts +5 -1
  82. package/package/components/copilot/lib.js +21 -5
  83. package/package/components/deploymentRequest/DeploymentRequestPanel.svelte +337 -0
  84. package/package/components/deploymentRequest/DeploymentRequestPanel.svelte.d.ts +15 -0
  85. package/package/components/details/CopyableCodeBlock.svelte +18 -8
  86. package/package/components/details/CopyableCodeBlock.svelte.d.ts +1 -0
  87. package/package/components/flows/FlowAssetsHandler.svelte +19 -21
  88. package/package/components/flows/agentToolTree.d.ts +17 -0
  89. package/package/components/flows/agentToolTree.js +114 -0
  90. package/package/components/flows/agentToolTree.test.d.ts +1 -0
  91. package/package/components/flows/agentToolTree.test.js +86 -0
  92. package/package/components/flows/agentToolUtils.d.ts +0 -5
  93. package/package/components/flows/agentToolUtils.js +0 -49
  94. package/package/components/flows/content/FlowLoop.svelte +7 -4
  95. package/package/components/flows/content/FlowModuleDeleteAfterUse.svelte +15 -7
  96. package/package/components/flows/content/FlowSettings.svelte +29 -0
  97. package/package/components/flows/dfs.d.ts +6 -2
  98. package/package/components/flows/dfs.js +19 -11
  99. package/package/components/flows/flowDeleteController.d.ts +32 -0
  100. package/package/components/flows/flowDeleteController.js +54 -0
  101. package/package/components/flows/flowDeleteController.test.d.ts +1 -0
  102. package/package/components/flows/flowDeleteController.test.js +121 -0
  103. package/package/components/flows/flowDeleteUtils.d.ts +48 -0
  104. package/package/components/flows/flowDeleteUtils.js +150 -0
  105. package/package/components/flows/flowDeleteUtils.test.d.ts +1 -0
  106. package/package/components/flows/flowDeleteUtils.test.js +131 -0
  107. package/package/components/flows/flowDiff.d.ts +2 -47
  108. package/package/components/flows/flowDiff.js +16 -293
  109. package/package/components/flows/flowDiff.testUtils.d.ts +8 -0
  110. package/package/components/flows/flowDiff.testUtils.js +26 -0
  111. package/package/components/flows/flowDiffManager.svelte.js +20 -75
  112. package/package/components/flows/flowDiffManager.svelte.test.js +103 -2
  113. package/package/components/flows/flowExplorer.d.ts +4 -0
  114. package/package/components/flows/flowExplorer.js +7 -30
  115. package/package/components/flows/flowState.d.ts +1 -0
  116. package/package/components/flows/flowStateUtils.svelte.js +6 -1
  117. package/package/components/flows/flowTree.d.ts +91 -0
  118. package/package/components/flows/flowTree.js +326 -0
  119. package/package/components/flows/flowTree.test.d.ts +1 -0
  120. package/package/components/flows/flowTree.test.js +236 -0
  121. package/package/components/flows/map/FlowJobsMenu.svelte +36 -30
  122. package/package/components/flows/map/FlowModuleSchemaItem.svelte +1 -1
  123. package/package/components/flows/map/FlowModuleSchemaMap.svelte +70 -227
  124. package/package/components/flows/map/FlowModuleSchemaMap.svelte.d.ts +0 -2
  125. package/package/components/flows/pickers/PickHubScriptQuick.svelte +2 -2
  126. package/package/components/flows/previousResults.js +13 -41
  127. package/package/components/flows/previousResults.test.d.ts +1 -0
  128. package/package/components/flows/previousResults.test.js +65 -0
  129. package/package/components/flows/propPicker/OutputPicker.svelte +2 -1
  130. package/package/components/flows/propPicker/OutputPickerInner.svelte +41 -4
  131. package/package/components/flows/propPicker/StepHistory.svelte +9 -1
  132. package/package/components/git_sync/GitSyncContext.svelte.js +11 -5
  133. package/package/components/git_sync/GitSyncRepositoryCard.svelte +2 -29
  134. package/package/components/git_sync/PullWorkspaceModal.svelte +6 -7
  135. package/package/components/graph/FlowGraphV2.svelte +2 -2
  136. package/package/components/graph/FlowGraphV2.svelte.d.ts +1 -0
  137. package/package/components/graph/groupedModulesProxy.svelte.d.ts +10 -0
  138. package/package/components/graph/groupedModulesProxy.svelte.js +17 -1
  139. package/package/components/graph/renderers/triggers/TriggersBadge.svelte +5 -2
  140. package/package/components/home/HomeConnectDrawer.svelte +125 -0
  141. package/package/components/home/HomeConnectDrawer.svelte.d.ts +5 -0
  142. package/package/components/icons/GithubIcon.svelte +4 -4
  143. package/package/components/icons/GithubIcon.svelte.d.ts +5 -2
  144. package/package/components/instanceSettings/ExternalJwtTokens.svelte +85 -0
  145. package/package/components/instanceSettings/ExternalJwtTokens.svelte.d.ts +12 -0
  146. package/package/components/instanceSettings/GhesAppSettings.svelte +17 -0
  147. package/package/components/instanceSettings/IndexerMemorySettings.svelte +56 -29
  148. package/package/components/instanceSettings/SecretBackendConfig.svelte +9 -2
  149. package/package/components/instanceSettings.d.ts +1 -0
  150. package/package/components/instanceSettings.js +42 -8
  151. package/package/components/offboarding-utils.d.ts +11 -0
  152. package/package/components/offboarding-utils.js +100 -0
  153. package/package/components/raw_apps/RawAppDataTableDrawer.svelte +1 -1
  154. package/package/components/raw_apps/RawAppEditor.svelte +27 -0
  155. package/package/components/raw_apps/RawAppEditorHeader.svelte +6 -1
  156. package/package/components/raw_apps/RawAppEditorHeader.svelte.d.ts +1 -0
  157. package/package/components/raw_apps/RawAppYamlEditor.svelte +81 -0
  158. package/package/components/raw_apps/RawAppYamlEditor.svelte.d.ts +20 -0
  159. package/package/components/raw_apps/datatableUtils.svelte.js +1 -1
  160. package/package/components/runs/runsFilter.d.ts +1 -1
  161. package/package/components/script_builder.d.ts +1 -1
  162. package/package/components/select/Select.svelte +2 -1
  163. package/package/components/select/Select.svelte.d.ts +1 -0
  164. package/package/components/settings/CreateToken.svelte +113 -64
  165. package/package/components/settings/CreateToken.svelte.d.ts +3 -0
  166. package/package/components/settings/WorkspaceUserSettings.svelte +34 -28
  167. package/package/components/sidebar/SidebarContent.svelte +58 -2
  168. package/package/components/sidebar/WorkspaceMenu.svelte +8 -4
  169. package/package/components/triggers/AddTriggersButton.svelte +11 -0
  170. package/package/components/triggers/PermissionedAsLine.svelte +37 -3
  171. package/package/components/triggers/PermissionedAsLine.svelte.d.ts +6 -0
  172. package/package/components/triggers/TriggersEditor.svelte +5 -1
  173. package/package/components/triggers/TriggersWrapper.svelte +10 -0
  174. package/package/components/triggers/email/EmailTriggerEditorInner.svelte +13 -11
  175. package/package/components/triggers/gcp/GcpTriggerEditorInner.svelte +13 -11
  176. package/package/components/triggers/http/RouteEditorConfigSection.svelte +15 -7
  177. package/package/components/triggers/http/RouteEditorInner.svelte +14 -14
  178. package/package/components/triggers/http/RoutesGenerator.svelte +6 -1
  179. package/package/components/triggers/http/RoutesPanel.svelte +1 -1
  180. package/package/components/triggers/http/utils.d.ts +1 -1
  181. package/package/components/triggers/http/utils.js +2 -2
  182. package/package/components/triggers/kafka/KafkaTriggerEditorInner.svelte +13 -11
  183. package/package/components/triggers/mqtt/MqttTriggerEditorInner.svelte +13 -11
  184. package/package/components/triggers/native/NativeTriggerEditor.svelte +3 -0
  185. package/package/components/triggers/native/services/github/GitHubTriggerForm.svelte +118 -0
  186. package/package/components/triggers/native/services/github/GitHubTriggerForm.svelte.d.ts +17 -0
  187. package/package/components/triggers/native/utils.js +14 -0
  188. package/package/components/triggers/nats/NatsTriggerEditor.svelte.d.ts +4 -3
  189. package/package/components/triggers/nats/NatsTriggerEditorInner.svelte +13 -11
  190. package/package/components/triggers/postgres/PostgresTriggerEditor.svelte.d.ts +4 -3
  191. package/package/components/triggers/postgres/PostgresTriggerEditorInner.svelte +13 -11
  192. package/package/components/triggers/schedules/ScheduleEditorInner.svelte +13 -11
  193. package/package/components/triggers/sqs/SqsTriggerEditor.svelte.d.ts +4 -3
  194. package/package/components/triggers/sqs/SqsTriggerEditorInner.svelte +13 -11
  195. package/package/components/triggers/triggers.svelte.js +1 -0
  196. package/package/components/triggers/utils.js +27 -6
  197. package/package/components/triggers/websocket/WebsocketTriggerEditorInner.svelte +13 -11
  198. package/package/components/triggers.d.ts +1 -1
  199. package/package/components/useFolderDefaultPermissionedAs.svelte.d.ts +13 -0
  200. package/package/components/useFolderDefaultPermissionedAs.svelte.js +63 -0
  201. package/package/components/workspaceSettings/CreateWorkspace.svelte +16 -677
  202. package/package/components/workspaceSettings/CreateWorkspaceInner.svelte +604 -0
  203. package/package/components/workspaceSettings/CreateWorkspaceInner.svelte.d.ts +7 -0
  204. package/package/components/workspaceSettings/CustomInstanceDbSelect.svelte +27 -25
  205. package/package/components/workspaceSettings/CustomInstanceDbWizardModal.svelte +46 -8
  206. package/package/components/workspaceSettings/DataTableSettings.svelte +27 -22
  207. package/package/components/workspaceSettings/DucklakeSettings.svelte +1 -1
  208. package/package/components/workspaceSettings/ForkDatatableSection.svelte +228 -0
  209. package/package/components/workspaceSettings/ForkDatatableSection.svelte.d.ts +28 -0
  210. package/package/components/workspaceSettings/GitSyncFilterSettings.svelte +8 -2
  211. package/package/components/workspaceSettings/RulesetEditor.svelte +27 -2
  212. package/package/components/workspaceSettings/VolumeStorageSettings.svelte +1 -1
  213. package/package/components/workspaceSettings/WorkspaceIntegrations.svelte +17 -1
  214. package/package/consts.d.ts +3 -0
  215. package/package/consts.js +10 -0
  216. package/package/gen/core/OpenAPI.js +1 -1
  217. package/package/gen/schemas.gen.d.ts +485 -19
  218. package/package/gen/schemas.gen.js +489 -20
  219. package/package/gen/services.gen.d.ts +229 -2
  220. package/package/gen/services.gen.js +463 -1
  221. package/package/gen/types.gen.d.ts +866 -29
  222. package/package/githubApp.js +5 -1
  223. package/package/hubPaths.json +1 -4
  224. package/package/infer.js +13 -1
  225. package/package/infer.svelte.js +10 -1
  226. package/package/monaco_workers/sqlTypePlugin.worker.d.ts +10 -0
  227. package/package/monaco_workers/sqlTypePlugin.worker.js +39 -0
  228. package/package/script_helpers.d.ts +8 -2
  229. package/package/script_helpers.js +14 -0
  230. package/package/stores.d.ts +4 -0
  231. package/package/stores.js +1 -0
  232. package/package/system_prompts/prompts.d.ts +4 -3
  233. package/package/system_prompts/prompts.js +270 -20
  234. package/package/templates/ci_test_bun.ts.template +19 -0
  235. package/package/templates/ci_test_python.py.template +18 -0
  236. package/package/utils_workspace_deploy.d.ts +8 -8
  237. package/package/utils_workspace_deploy.js +86 -420
  238. package/package.json +3 -3
  239. package/package/components/copilot/chat/__tests__/app/appChat.eval.test.js +0 -153
  240. package/package/components/copilot/chat/__tests__/app/appEvalComparison.d.ts +0 -21
  241. package/package/components/copilot/chat/__tests__/app/appEvalComparison.js +0 -136
  242. package/package/components/copilot/chat/__tests__/app/appEvalHelpers.d.ts +0 -15
  243. package/package/components/copilot/chat/__tests__/app/appEvalHelpers.js +0 -107
  244. package/package/components/copilot/chat/__tests__/app/appEvalRunner.d.ts +0 -50
  245. package/package/components/copilot/chat/__tests__/app/appEvalRunner.js +0 -93
  246. package/package/components/copilot/chat/__tests__/app/appFixtureLoader.d.ts +0 -29
  247. package/package/components/copilot/chat/__tests__/app/appFixtureLoader.js +0 -134
  248. package/package/components/copilot/chat/__tests__/app/appResultsWriter.d.ts +0 -30
  249. package/package/components/copilot/chat/__tests__/app/appResultsWriter.js +0 -197
  250. package/package/components/copilot/chat/__tests__/app/initial/file_manager/backend/createFolder/main.d.ts +0 -10
  251. package/package/components/copilot/chat/__tests__/app/initial/file_manager/backend/createFolder/main.js +0 -9
  252. package/package/components/copilot/chat/__tests__/app/initial/file_manager/backend/createFolder/meta.json +0 -4
  253. package/package/components/copilot/chat/__tests__/app/initial/file_manager/backend/deleteItem/main.d.ts +0 -6
  254. package/package/components/copilot/chat/__tests__/app/initial/file_manager/backend/deleteItem/main.js +0 -5
  255. package/package/components/copilot/chat/__tests__/app/initial/file_manager/backend/deleteItem/meta.json +0 -4
  256. package/package/components/copilot/chat/__tests__/app/initial/file_manager/backend/listFiles/main.d.ts +0 -12
  257. package/package/components/copilot/chat/__tests__/app/initial/file_manager/backend/listFiles/main.js +0 -14
  258. package/package/components/copilot/chat/__tests__/app/initial/file_manager/backend/listFiles/meta.json +0 -4
  259. package/package/components/copilot/chat/__tests__/app/initial/file_manager/backend/listFolders/main.d.ts +0 -8
  260. package/package/components/copilot/chat/__tests__/app/initial/file_manager/backend/listFolders/main.js +0 -25
  261. package/package/components/copilot/chat/__tests__/app/initial/file_manager/backend/listFolders/meta.json +0 -4
  262. package/package/components/copilot/chat/__tests__/app/initial/file_manager/backend/moveItem/main.d.ts +0 -7
  263. package/package/components/copilot/chat/__tests__/app/initial/file_manager/backend/moveItem/main.js +0 -5
  264. package/package/components/copilot/chat/__tests__/app/initial/file_manager/backend/moveItem/meta.json +0 -4
  265. package/package/components/copilot/chat/__tests__/app/initial/file_manager/backend/renameItem/main.d.ts +0 -8
  266. package/package/components/copilot/chat/__tests__/app/initial/file_manager/backend/renameItem/main.js +0 -5
  267. package/package/components/copilot/chat/__tests__/app/initial/file_manager/backend/renameItem/meta.json +0 -4
  268. package/package/components/copilot/chat/__tests__/app/initial/file_manager/frontend/components/Breadcrumb.d.ts +0 -10
  269. package/package/components/copilot/chat/__tests__/app/initial/file_manager/frontend/components/Breadcrumb.tsx +0 -26
  270. package/package/components/copilot/chat/__tests__/app/initial/file_manager/frontend/components/FileItem.d.ts +0 -10
  271. package/package/components/copilot/chat/__tests__/app/initial/file_manager/frontend/components/FileItem.tsx +0 -79
  272. package/package/components/copilot/chat/__tests__/app/initial/file_manager/frontend/components/FileList.d.ts +0 -10
  273. package/package/components/copilot/chat/__tests__/app/initial/file_manager/frontend/components/FileList.tsx +0 -46
  274. package/package/components/copilot/chat/__tests__/app/initial/file_manager/frontend/components/FolderTree.d.ts +0 -10
  275. package/package/components/copilot/chat/__tests__/app/initial/file_manager/frontend/components/FolderTree.tsx +0 -56
  276. package/package/components/copilot/chat/__tests__/app/initial/file_manager/frontend/components/Toolbar.d.ts +0 -6
  277. package/package/components/copilot/chat/__tests__/app/initial/file_manager/frontend/components/Toolbar.tsx +0 -59
  278. package/package/components/copilot/chat/__tests__/app/initial/file_manager/frontend/index.d.ts +0 -16
  279. package/package/components/copilot/chat/__tests__/app/initial/file_manager/frontend/index.tsx +0 -119
  280. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/backend/addToCart/main.d.ts +0 -15
  281. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/backend/addToCart/main.js +0 -14
  282. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/backend/addToCart/meta.json +0 -4
  283. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/backend/calculateTotal/main.d.ts +0 -14
  284. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/backend/calculateTotal/main.js +0 -5
  285. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/backend/calculateTotal/meta.json +0 -4
  286. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/backend/getProducts/main.d.ts +0 -6
  287. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/backend/getProducts/main.js +0 -41
  288. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/backend/getProducts/meta.json +0 -4
  289. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/backend/removeFromCart/main.d.ts +0 -15
  290. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/backend/removeFromCart/main.js +0 -3
  291. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/backend/removeFromCart/meta.json +0 -4
  292. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/frontend/components/Cart.d.ts +0 -9
  293. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/frontend/components/Cart.tsx +0 -51
  294. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/frontend/components/ProductCard.d.ts +0 -8
  295. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/frontend/components/ProductCard.tsx +0 -27
  296. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/frontend/components/ProductList.d.ts +0 -8
  297. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/frontend/components/ProductList.tsx +0 -18
  298. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/frontend/index.d.ts +0 -12
  299. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/frontend/index.tsx +0 -81
  300. package/package/components/copilot/chat/__tests__/app/initial/test1_counter_app/backend/decrementCounter/main.d.ts +0 -3
  301. package/package/components/copilot/chat/__tests__/app/initial/test1_counter_app/backend/decrementCounter/main.js +0 -3
  302. package/package/components/copilot/chat/__tests__/app/initial/test1_counter_app/backend/decrementCounter/meta.json +0 -4
  303. package/package/components/copilot/chat/__tests__/app/initial/test1_counter_app/backend/incrementCounter/main.d.ts +0 -3
  304. package/package/components/copilot/chat/__tests__/app/initial/test1_counter_app/backend/incrementCounter/main.js +0 -3
  305. package/package/components/copilot/chat/__tests__/app/initial/test1_counter_app/backend/incrementCounter/meta.json +0 -4
  306. package/package/components/copilot/chat/__tests__/app/initial/test1_counter_app/frontend/index.d.ts +0 -2
  307. package/package/components/copilot/chat/__tests__/app/initial/test1_counter_app/frontend/index.tsx +0 -38
  308. package/package/components/copilot/chat/__tests__/app/variants/baseline.d.ts +0 -6
  309. package/package/components/copilot/chat/__tests__/app/variants/baseline.js +0 -10
  310. package/package/components/copilot/chat/__tests__/app/variants/index.d.ts +0 -3
  311. package/package/components/copilot/chat/__tests__/app/variants/index.js +0 -3
  312. package/package/components/copilot/chat/__tests__/app/variants/streamlined.d.ts +0 -6
  313. package/package/components/copilot/chat/__tests__/app/variants/streamlined.js +0 -137
  314. package/package/components/copilot/chat/__tests__/flow/expected/test1.json +0 -134
  315. package/package/components/copilot/chat/__tests__/flow/expected/test2.json +0 -183
  316. package/package/components/copilot/chat/__tests__/flow/expected/test3.json +0 -204
  317. package/package/components/copilot/chat/__tests__/flow/expected/test4.json +0 -175
  318. package/package/components/copilot/chat/__tests__/flow/expected/test5_modify_simple.json +0 -68
  319. package/package/components/copilot/chat/__tests__/flow/expected/test6_modify_medium.json +0 -142
  320. package/package/components/copilot/chat/__tests__/flow/expected/test7_modify_complex.json +0 -136
  321. package/package/components/copilot/chat/__tests__/flow/flowChat.eval.test.js +0 -294
  322. package/package/components/copilot/chat/__tests__/flow/flowEvalComparison.d.ts +0 -17
  323. package/package/components/copilot/chat/__tests__/flow/flowEvalComparison.js +0 -49
  324. package/package/components/copilot/chat/__tests__/flow/flowEvalHelpers.d.ts +0 -12
  325. package/package/components/copilot/chat/__tests__/flow/flowEvalHelpers.js +0 -79
  326. package/package/components/copilot/chat/__tests__/flow/flowEvalRunner.d.ts +0 -50
  327. package/package/components/copilot/chat/__tests__/flow/flowEvalRunner.js +0 -102
  328. package/package/components/copilot/chat/__tests__/flow/initial/test5_initial.json +0 -53
  329. package/package/components/copilot/chat/__tests__/flow/initial/test6_initial.json +0 -68
  330. package/package/components/copilot/chat/__tests__/flow/initial/test7_initial.json +0 -120
  331. package/package/components/copilot/chat/__tests__/flow/variants/baseline.d.ts +0 -6
  332. package/package/components/copilot/chat/__tests__/flow/variants/baseline.js +0 -10
  333. package/package/components/copilot/chat/__tests__/flow/variants/index.d.ts +0 -3
  334. package/package/components/copilot/chat/__tests__/flow/variants/index.js +0 -3
  335. package/package/components/copilot/chat/__tests__/flow/variants/minimal-single-tool.d.ts +0 -15
  336. package/package/components/copilot/chat/__tests__/flow/variants/minimal-single-tool.js +0 -388
  337. package/package/components/copilot/chat/__tests__/shared/baseEvalRunner.d.ts +0 -45
  338. package/package/components/copilot/chat/__tests__/shared/baseEvalRunner.js +0 -121
  339. package/package/components/copilot/chat/__tests__/shared/baseLLMEvaluator.d.ts +0 -28
  340. package/package/components/copilot/chat/__tests__/shared/baseLLMEvaluator.js +0 -96
  341. package/package/components/copilot/chat/__tests__/shared/baseResultsWriter.d.ts +0 -32
  342. package/package/components/copilot/chat/__tests__/shared/baseResultsWriter.js +0 -130
  343. package/package/components/copilot/chat/__tests__/shared/baseVariants.d.ts +0 -45
  344. package/package/components/copilot/chat/__tests__/shared/baseVariants.js +0 -57
  345. package/package/components/copilot/chat/__tests__/shared/index.d.ts +0 -10
  346. package/package/components/copilot/chat/__tests__/shared/index.js +0 -5
  347. package/package/components/copilot/chat/__tests__/shared/types.d.ts +0 -105
  348. package/package/components/copilot/chat/__tests__/shared/types.js +0 -9
  349. package/package/components/copilot/chat/flow/utils.d.ts +0 -14
  350. package/package/components/copilot/chat/flow/utils.js +0 -108
  351. package/package/components/flows/agentToolUtils.test.js +0 -55
  352. /package/package/components/copilot/chat/{__tests__/app/appChat.eval.test.d.ts → app/core.test.d.ts} +0 -0
  353. /package/package/components/copilot/chat/{__tests__/flow/flowChat.eval.test.d.ts → flow/helperUtils.test.d.ts} +0 -0
  354. /package/package/components/{flows/agentToolUtils.test.d.ts → copilot/chat/flow/utils.test.d.ts} +0 -0
@@ -1,5 +1,6 @@
1
- import { dfs } from './dfs';
2
1
  import { deepEqual } from 'fast-equals';
2
+ import { collectAllFlowModuleIds, collectFlowNodes, ensureModuleArrayByLocation, findModuleParent, getModuleArrayByLocation } from './flowTree';
3
+ export { findModuleInFlow, findModuleParent } from './flowTree';
3
4
  /** Prefix added to module IDs when the original module coexists with a replacement */
4
5
  export const DUPLICATE_MODULE_PREFIX = 'old__';
5
6
  /** Prefix added to new module IDs when restoring original during type change rejection */
@@ -103,21 +104,11 @@ export function computeFlowModuleDiff(beforeFlow, afterFlow, options = { markAsP
103
104
  */
104
105
  function getAllModulesMap(flow) {
105
106
  const moduleMap = new Map();
106
- // Get all regular modules
107
- const allModules = dfs(flow.modules ?? [], (m) => m);
108
- for (const module of allModules) {
107
+ for (const { module } of collectFlowNodes(flow)) {
109
108
  if (module?.id) {
110
109
  moduleMap.set(module.id, module);
111
110
  }
112
111
  }
113
- // Add failure module if it exists
114
- if (flow.failure_module?.id) {
115
- moduleMap.set(flow.failure_module.id, flow.failure_module);
116
- }
117
- // Add preprocessor module if it exists
118
- if (flow.preprocessor_module?.id) {
119
- moduleMap.set(flow.preprocessor_module.id, flow.preprocessor_module);
120
- }
121
112
  return moduleMap;
122
113
  }
123
114
  /**
@@ -125,28 +116,14 @@ function getAllModulesMap(flow) {
125
116
  */
126
117
  function getAllModulesWithLocation(flow) {
127
118
  const result = new Map();
128
- const allModules = dfs(flow.modules ?? [], (m) => m);
129
- for (const module of allModules) {
130
- if (module?.id) {
131
- const location = findModuleParent(flow, module.id);
132
- if (location) {
133
- result.set(module.id, { module, location });
134
- }
119
+ for (const entry of collectFlowNodes(flow)) {
120
+ if (entry.module?.id) {
121
+ result.set(entry.module.id, {
122
+ module: entry.module,
123
+ location: entry.location
124
+ });
135
125
  }
136
126
  }
137
- // Add special modules
138
- if (flow.failure_module?.id) {
139
- result.set(flow.failure_module.id, {
140
- module: flow.failure_module,
141
- location: { type: 'failure', index: -1 }
142
- });
143
- }
144
- if (flow.preprocessor_module?.id) {
145
- result.set(flow.preprocessor_module.id, {
146
- module: flow.preprocessor_module,
147
- location: { type: 'preprocessor', index: -1 }
148
- });
149
- }
150
127
  return result;
151
128
  }
152
129
  /**
@@ -177,95 +154,6 @@ export function locationsEqual(a, b) {
177
154
  return false;
178
155
  }
179
156
  }
180
- /**
181
- * Finds the parent location of a module in a flow
182
- */
183
- export function findModuleParent(flow, moduleId) {
184
- // Check special modules
185
- if (flow.failure_module?.id === moduleId) {
186
- return { type: 'failure', index: -1 };
187
- }
188
- if (flow.preprocessor_module?.id === moduleId) {
189
- return { type: 'preprocessor', index: -1 };
190
- }
191
- // Check root level
192
- const rootIndex = flow.modules?.findIndex((m) => m.id === moduleId);
193
- if (rootIndex !== undefined && rootIndex >= 0) {
194
- return { type: 'root', index: rootIndex };
195
- }
196
- // Recursively search nested modules
197
- function searchInModules(modules) {
198
- for (const module of modules) {
199
- // Check forloopflow
200
- if (module.value.type === 'forloopflow') {
201
- const index = module.value.modules.findIndex((m) => m.id === moduleId);
202
- if (index >= 0) {
203
- return { type: 'forloop', parentId: module.id, index };
204
- }
205
- const nested = searchInModules(module.value.modules);
206
- if (nested)
207
- return nested;
208
- }
209
- // Check whileloopflow
210
- if (module.value.type === 'whileloopflow') {
211
- const index = module.value.modules.findIndex((m) => m.id === moduleId);
212
- if (index >= 0) {
213
- return { type: 'whileloop', parentId: module.id, index };
214
- }
215
- const nested = searchInModules(module.value.modules);
216
- if (nested)
217
- return nested;
218
- }
219
- // Check branchone
220
- if (module.value.type === 'branchone') {
221
- // Check default branch
222
- const defaultIndex = module.value.default.findIndex((m) => m.id === moduleId);
223
- if (defaultIndex >= 0) {
224
- return { type: 'branchone-default', parentId: module.id, index: defaultIndex };
225
- }
226
- const nestedDefault = searchInModules(module.value.default);
227
- if (nestedDefault)
228
- return nestedDefault;
229
- // Check other branches
230
- for (let branchIndex = 0; branchIndex < module.value.branches.length; branchIndex++) {
231
- const branch = module.value.branches[branchIndex];
232
- const index = branch.modules.findIndex((m) => m.id === moduleId);
233
- if (index >= 0) {
234
- return { type: 'branchone-branch', parentId: module.id, branchIndex, index };
235
- }
236
- const nested = searchInModules(branch.modules);
237
- if (nested)
238
- return nested;
239
- }
240
- }
241
- // Check branchall
242
- if (module.value.type === 'branchall') {
243
- for (let branchIndex = 0; branchIndex < module.value.branches.length; branchIndex++) {
244
- const branch = module.value.branches[branchIndex];
245
- const index = branch.modules.findIndex((m) => m.id === moduleId);
246
- if (index >= 0) {
247
- return { type: 'branchall-branch', parentId: module.id, branchIndex, index };
248
- }
249
- const nested = searchInModules(branch.modules);
250
- if (nested)
251
- return nested;
252
- }
253
- }
254
- // Check aiagent
255
- if (module.value.type === 'aiagent' && module.value.tools) {
256
- const index = module.value.tools.findIndex((m) => m.id === moduleId);
257
- if (index >= 0) {
258
- return { type: 'aiagent', parentId: module.id, index };
259
- }
260
- const nested = searchInModules(module.value.tools);
261
- if (nested)
262
- return nested;
263
- }
264
- }
265
- return null;
266
- }
267
- return searchInModules(flow.modules ?? []);
268
- }
269
157
  /**
270
158
  * Deep clones a module to avoid mutation
271
159
  */
@@ -333,48 +221,8 @@ function prependModuleId(module, prefix) {
333
221
  }
334
222
  return newModule;
335
223
  }
336
- /**
337
- * Collects all module IDs from a flow structure recursively
338
- */
339
224
  function getAllModuleIds(flow) {
340
- const ids = new Set();
341
- function collectFromModules(modules) {
342
- for (const module of modules) {
343
- if (module.id) {
344
- ids.add(module.id);
345
- }
346
- // Recursively collect from nested modules
347
- if (module.value.type === 'forloopflow' || module.value.type === 'whileloopflow') {
348
- collectFromModules(module.value.modules);
349
- }
350
- else if (module.value.type === 'branchone') {
351
- collectFromModules(module.value.default);
352
- for (const branch of module.value.branches) {
353
- collectFromModules(branch.modules);
354
- }
355
- }
356
- else if (module.value.type === 'branchall') {
357
- for (const branch of module.value.branches) {
358
- collectFromModules(branch.modules);
359
- }
360
- }
361
- else if (module.value.type === 'aiagent' && module.value.tools) {
362
- collectFromModules(module.value.tools);
363
- }
364
- }
365
- }
366
- // Collect from root modules
367
- if (flow.modules) {
368
- collectFromModules(flow.modules);
369
- }
370
- // Collect from special modules
371
- if (flow.failure_module?.id) {
372
- ids.add(flow.failure_module.id);
373
- }
374
- if (flow.preprocessor_module?.id) {
375
- ids.add(flow.preprocessor_module.id);
376
- }
377
- return ids;
225
+ return new Set(collectAllFlowModuleIds(flow));
378
226
  }
379
227
  /**
380
228
  * Scans the merged flow for duplicate IDs and prefixes duplicates with 'old__'.
@@ -503,24 +351,7 @@ function reconstructMergedFlow(afterFlow, beforeFlow, beforeActions) {
503
351
  }
504
352
  // Track the newly added module ID
505
353
  mergedIds.add(clonedModule.id);
506
- // Insert based on parent location
507
- if (parentLocation.type === 'failure') {
508
- merged.failure_module = clonedModule;
509
- }
510
- else if (parentLocation.type === 'preprocessor') {
511
- merged.preprocessor_module = clonedModule;
512
- }
513
- else if (parentLocation.type === 'root') {
514
- // Find the best position to insert in root modules
515
- const insertIndex = findBestInsertPosition(merged.modules ?? [], beforeFlow.modules ?? [], parentLocation.index, removedId);
516
- if (!merged.modules)
517
- merged.modules = [];
518
- merged.modules.splice(insertIndex, 0, clonedModule);
519
- }
520
- else {
521
- // Find the parent module in merged flow and insert into it
522
- insertIntoNestedParent(merged, parentLocation, clonedModule, beforeFlow);
523
- }
354
+ insertModuleIntoFlow(merged, clonedModule, beforeFlow, removedId);
524
355
  }
525
356
  // Post-process: fix any duplicate IDs that may have been created
526
357
  // This handles the case where a module moved from one location to another
@@ -554,101 +385,6 @@ function findBestInsertPosition(targetModules, beforeModules, originalIndex, rem
554
385
  /**
555
386
  * Inserts a removed module into its nested parent in the merged flow
556
387
  */
557
- function insertIntoNestedParent(merged, parentLocation, moduleToInsert, beforeFlow) {
558
- if (parentLocation.type === 'root' ||
559
- parentLocation.type === 'failure' ||
560
- parentLocation.type === 'preprocessor') {
561
- return;
562
- }
563
- // Find the parent module in merged flow
564
- const parentModule = findModuleById(merged, parentLocation.parentId);
565
- if (!parentModule) {
566
- console.warn('Parent module not found', parentLocation);
567
- return;
568
- }
569
- // Get the before parent to know original ordering
570
- const beforeParent = findModuleById(beforeFlow, parentLocation.parentId);
571
- if (!beforeParent) {
572
- console.warn('Before parent module not found', parentLocation);
573
- return;
574
- }
575
- // Insert based on type
576
- if (parentLocation.type === 'forloop' && parentModule.value.type === 'forloopflow') {
577
- const beforeModules = beforeParent.value.modules ?? [];
578
- const insertIndex = findBestInsertPosition(parentModule.value.modules, beforeModules, parentLocation.index, moduleToInsert.id);
579
- parentModule.value.modules.splice(insertIndex, 0, moduleToInsert);
580
- }
581
- else if (parentLocation.type === 'whileloop' && parentModule.value.type === 'whileloopflow') {
582
- const beforeModules = beforeParent.value.modules ?? [];
583
- const insertIndex = findBestInsertPosition(parentModule.value.modules, beforeModules, parentLocation.index, moduleToInsert.id);
584
- parentModule.value.modules.splice(insertIndex, 0, moduleToInsert);
585
- }
586
- else if (parentLocation.type === 'branchone-default' &&
587
- parentModule.value.type === 'branchone') {
588
- const beforeModules = beforeParent.value.default ?? [];
589
- const insertIndex = findBestInsertPosition(parentModule.value.default, beforeModules, parentLocation.index, moduleToInsert.id);
590
- parentModule.value.default.splice(insertIndex, 0, moduleToInsert);
591
- }
592
- else if (parentLocation.type === 'branchone-branch' &&
593
- parentModule.value.type === 'branchone') {
594
- let branch = parentModule.value.branches[parentLocation.branchIndex];
595
- const beforeBranch = beforeParent.value.branches?.[parentLocation.branchIndex];
596
- // If the branch doesn't exist (entire branch was removed), recreate it from beforeFlow
597
- if (!branch && beforeBranch) {
598
- // Ensure we have enough branch slots
599
- while (parentModule.value.branches.length <= parentLocation.branchIndex) {
600
- parentModule.value.branches.push({ expr: '', modules: [] });
601
- }
602
- // Restore the branch with its original expr but empty modules (we'll add them)
603
- parentModule.value.branches[parentLocation.branchIndex] = {
604
- ...beforeBranch,
605
- modules: []
606
- };
607
- branch = parentModule.value.branches[parentLocation.branchIndex];
608
- }
609
- if (branch) {
610
- const beforeModules = beforeBranch?.modules ?? [];
611
- const insertIndex = findBestInsertPosition(branch.modules, beforeModules, parentLocation.index, moduleToInsert.id);
612
- branch.modules.splice(insertIndex, 0, moduleToInsert);
613
- }
614
- }
615
- else if (parentLocation.type === 'branchall-branch' &&
616
- parentModule.value.type === 'branchall') {
617
- let branch = parentModule.value.branches[parentLocation.branchIndex];
618
- const beforeBranch = beforeParent.value.branches?.[parentLocation.branchIndex];
619
- // If the branch doesn't exist (entire branch was removed), recreate it from beforeFlow
620
- if (!branch && beforeBranch) {
621
- // Ensure we have enough branch slots
622
- while (parentModule.value.branches.length <= parentLocation.branchIndex) {
623
- parentModule.value.branches.push({ modules: [] });
624
- }
625
- // Restore the branch with empty modules (we'll add them)
626
- parentModule.value.branches[parentLocation.branchIndex] = {
627
- ...beforeBranch,
628
- modules: []
629
- };
630
- branch = parentModule.value.branches[parentLocation.branchIndex];
631
- }
632
- if (branch) {
633
- const beforeModules = beforeBranch?.modules ?? [];
634
- const insertIndex = findBestInsertPosition(branch.modules, beforeModules, parentLocation.index, moduleToInsert.id);
635
- branch.modules.splice(insertIndex, 0, moduleToInsert);
636
- }
637
- }
638
- else if (parentLocation.type === 'aiagent' && parentModule.value.type === 'aiagent') {
639
- const tools = parentModule.value.tools ?? [];
640
- const beforeTools = beforeParent.value.tools ?? [];
641
- const insertIndex = findBestInsertPosition(tools, beforeTools, parentLocation.index, moduleToInsert.id);
642
- tools.splice(insertIndex, 0, moduleToInsert);
643
- }
644
- }
645
- /**
646
- * Finds a module by ID anywhere in the flow
647
- */
648
- function findModuleById(flow, moduleId) {
649
- const moduleMap = getAllModulesMap(flow);
650
- return moduleMap.get(moduleId) ?? null;
651
- }
652
388
  /**
653
389
  * Adjusts the after actions based on display mode and adds entries for prefixed IDs
654
390
  */
@@ -732,26 +468,13 @@ export function insertModuleIntoFlow(targetFlow, moduleToInsert, sourceFlow, mod
732
468
  targetFlow.preprocessor_module = moduleToInsert;
733
469
  return;
734
470
  }
735
- // Handle root level modules
736
- if (parentLocation.type === 'root') {
737
- const insertIndex = findBestInsertPosition(targetFlow.modules ?? [], sourceFlow.modules ?? [], parentLocation.index, moduleId);
738
- if (!targetFlow.modules)
739
- targetFlow.modules = [];
740
- targetFlow.modules.splice(insertIndex, 0, moduleToInsert);
471
+ const targetModules = ensureModuleArrayByLocation(targetFlow, parentLocation, sourceFlow);
472
+ const sourceModules = getModuleArrayByLocation(sourceFlow, parentLocation);
473
+ if (!targetModules || !sourceModules) {
741
474
  return;
742
475
  }
743
- // Handle nested modules
744
- insertIntoNestedParent(targetFlow, parentLocation, moduleToInsert, sourceFlow);
745
- }
746
- /**
747
- * Finds a module by ID anywhere in a flow (including nested modules, failure, and preprocessor)
748
- *
749
- * @param flow - The flow to search in
750
- * @param moduleId - The ID of the module to find
751
- * @returns The module if found, null otherwise
752
- */
753
- export function findModuleInFlow(flow, moduleId) {
754
- return findModuleById(flow, moduleId);
476
+ const insertIndex = findBestInsertPosition(targetModules, sourceModules, parentLocation.index, moduleId);
477
+ targetModules.splice(insertIndex, 0, moduleToInsert);
755
478
  }
756
479
  /**
757
480
  * Checks if the input schema has changed between two flow versions.
@@ -30,6 +30,14 @@ export declare function createBranchOneModule(id: string, defaultModules: FlowMo
30
30
  export declare function createBranchAllModule(id: string, branches: {
31
31
  modules: FlowModule[];
32
32
  }[]): FlowModule;
33
+ /**
34
+ * Wraps a FlowModule as an AI agent flowmodule tool.
35
+ */
36
+ export declare function createFlowModuleTool(module: FlowModule): FlowModule;
37
+ /**
38
+ * Creates an AI agent module with the provided tools.
39
+ */
40
+ export declare function createAiAgentModule(id: string, tools: FlowModule[]): FlowModule;
33
41
  /**
34
42
  * Creates a FlowValue with the given modules
35
43
  */
@@ -79,6 +79,32 @@ export function createBranchAllModule(id, branches) {
79
79
  }
80
80
  };
81
81
  }
82
+ /**
83
+ * Wraps a FlowModule as an AI agent flowmodule tool.
84
+ */
85
+ export function createFlowModuleTool(module) {
86
+ return {
87
+ id: module.id,
88
+ summary: module.summary,
89
+ value: {
90
+ tool_type: 'flowmodule',
91
+ ...module.value
92
+ }
93
+ };
94
+ }
95
+ /**
96
+ * Creates an AI agent module with the provided tools.
97
+ */
98
+ export function createAiAgentModule(id, tools) {
99
+ return {
100
+ id,
101
+ value: {
102
+ type: 'aiagent',
103
+ tools,
104
+ input_transforms: {}
105
+ }
106
+ };
107
+ }
82
108
  // ============================================================================
83
109
  // Flow Creation Helpers
84
110
  // ============================================================================
@@ -5,10 +5,9 @@
5
5
  * This decouples diff management from specific UI components (like AI chat) and makes it
6
6
  * available for any use case that needs to track and apply flow changes.
7
7
  */
8
- import { buildFlowTimeline, insertModuleIntoFlow, findModuleParent, locationsEqual, DUPLICATE_MODULE_PREFIX, NEW_MODULE_PREFIX } from './flowDiff';
8
+ import { buildFlowTimeline, insertModuleIntoFlow, locationsEqual, DUPLICATE_MODULE_PREFIX, NEW_MODULE_PREFIX } from './flowDiff';
9
+ import { findModuleInFlow, findModuleParent, removeFlowModule, replaceFlowModule } from './flowTree';
9
10
  import { refreshStateStore } from '../../svelte5Utils.svelte';
10
- import { getIndexInNestedModules } from '../copilot/chat/flow/utils';
11
- import { dfs } from './previousResults';
12
11
  import { SPECIAL_MODULE_IDS } from '../copilot/chat/shared';
13
12
  /**
14
13
  * Creates a flow diff manager instance
@@ -26,7 +25,7 @@ function createSkeletonModule(module) {
26
25
  clone.value.branches.forEach((b) => (b.modules = []));
27
26
  }
28
27
  else if (clone.value.type === 'aiagent') {
29
- clone.value.tools = [];
28
+ clone.value.tools = (clone.value.tools ?? []).filter((t) => t.value?.tool_type && t.value.tool_type !== 'flowmodule');
30
29
  }
31
30
  return clone;
32
31
  }
@@ -134,47 +133,12 @@ export function createFlowDiffManager({ testMode = false } = {}) {
134
133
  function setModuleActions(actions) {
135
134
  updateModuleActions(actions);
136
135
  }
137
- /**
138
- * Helper to get a module from a flow by ID
139
- */
140
- function getModuleFromFlow(id, flow) {
141
- if (flow.value.preprocessor_module?.id === id) {
142
- return flow.value.preprocessor_module;
143
- }
144
- else if (flow.value.failure_module?.id === id) {
145
- return flow.value.failure_module;
146
- }
147
- else {
148
- return dfs(id, flow, false)[0];
149
- }
150
- }
151
136
  /**
152
137
  * Internal helper to delete a module from a flow object
153
138
  * Returns true if the module was found and deleted, false otherwise
154
139
  */
155
140
  function deleteModuleInternal(id, flow) {
156
- if (flow.value.preprocessor_module?.id === id) {
157
- flow.value.preprocessor_module = undefined;
158
- return true;
159
- }
160
- else if (flow.value.failure_module?.id === id) {
161
- flow.value.failure_module = undefined;
162
- return true;
163
- }
164
- else {
165
- const result = getIndexInNestedModules(flow, id);
166
- if (!result) {
167
- // Module not found (may have been deleted along with a parent)
168
- return false;
169
- }
170
- const { modules } = result;
171
- const index = modules.findIndex((m) => m.id === id);
172
- if (index >= 0) {
173
- modules.splice(index, 1);
174
- return true;
175
- }
176
- return false;
177
- }
141
+ return removeFlowModule(flow.value, id) !== null;
178
142
  }
179
143
  /**
180
144
  * Helper to delete a module from the flow
@@ -221,7 +185,7 @@ export function createFlowDiffManager({ testMode = false } = {}) {
221
185
  parentLoc.type !== 'root' &&
222
186
  parentLoc.type !== 'failure' &&
223
187
  parentLoc.type !== 'preprocessor') {
224
- const parentInBefore = getModuleFromFlow(parentLoc.parentId, beforeFlow);
188
+ const parentInBefore = findModuleInFlow(beforeFlow.value, parentLoc.parentId) ?? undefined;
225
189
  if (!parentInBefore) {
226
190
  // Parent is missing in beforeFlow. It must be pending acceptance.
227
191
  // Accept as skeleton to avoid auto-accepting all siblings.
@@ -229,13 +193,10 @@ export function createFlowDiffManager({ testMode = false } = {}) {
229
193
  }
230
194
  }
231
195
  // Use insertModuleIntoFlow targeting beforeFlow, sourcing position from currentFlow
232
- let module = getModuleFromFlow(actualId, {
233
- value: currentFlow,
234
- summary: ''
235
- });
196
+ let module = findModuleInFlow(currentFlow, actualId) ?? undefined;
236
197
  if (module) {
237
198
  // Check if module already exists in beforeFlow (could be a skeleton from earlier acceptance)
238
- const existingModule = getModuleFromFlow(actualId, beforeFlow);
199
+ const existingModule = findModuleInFlow(beforeFlow.value, actualId) ?? undefined;
239
200
  if (existingModule) {
240
201
  // Module exists in beforeFlow - check if it's in the same location
241
202
  const beforeLocation = findModuleParent(beforeFlow.value, actualId);
@@ -245,8 +206,7 @@ export function createFlowDiffManager({ testMode = false } = {}) {
245
206
  if (sameLocation) {
246
207
  // Module is in the same location, update it in-place
247
208
  const moduleToApply = asSkeleton ? createSkeletonModule(module) : module;
248
- Object.keys(existingModule).forEach((k) => delete existingModule[k]);
249
- Object.assign(existingModule, $state.snapshot(moduleToApply));
209
+ replaceFlowModule(existingModule, $state.snapshot(moduleToApply));
250
210
  }
251
211
  else {
252
212
  // Module is being moved - insert at new location (the old copy will be removed when old__id is accepted)
@@ -263,14 +223,10 @@ export function createFlowDiffManager({ testMode = false } = {}) {
263
223
  }
264
224
  else if (info.action === 'modified') {
265
225
  // Modified: Apply modifications to beforeFlow module
266
- const beforeModule = getModuleFromFlow(actualId, beforeFlow);
267
- const afterModule = getModuleFromFlow(actualId, {
268
- value: currentFlow,
269
- summary: ''
270
- });
226
+ const beforeModule = findModuleInFlow(beforeFlow.value, actualId) ?? undefined;
227
+ const afterModule = findModuleInFlow(currentFlow, actualId) ?? undefined;
271
228
  if (beforeModule && afterModule) {
272
- Object.keys(beforeModule).forEach((k) => delete beforeModule[k]);
273
- Object.assign(beforeModule, $state.snapshot(afterModule));
229
+ replaceFlowModule(beforeModule, $state.snapshot(afterModule));
274
230
  }
275
231
  }
276
232
  }
@@ -303,11 +259,11 @@ export function createFlowDiffManager({ testMode = false } = {}) {
303
259
  else if (info.action === 'removed') {
304
260
  // Removed in after: Restore to flowStore (currentFlow)
305
261
  // Source from beforeFlow
306
- const oldModule = getModuleFromFlow(actualId, beforeFlow);
262
+ const oldModule = findModuleInFlow(beforeFlow.value, actualId) ?? undefined;
307
263
  if (oldModule) {
308
264
  // For type changes (old__ prefix), rename the new module to avoid ID conflict
309
265
  if (id.startsWith(DUPLICATE_MODULE_PREFIX)) {
310
- const existingNew = getModuleFromFlow(actualId, flowStore.val);
266
+ const existingNew = findModuleInFlow(flowStore.val.value, actualId) ?? undefined;
311
267
  if (existingNew) {
312
268
  existingNew.id = `${NEW_MODULE_PREFIX}${actualId}`;
313
269
  }
@@ -318,11 +274,10 @@ export function createFlowDiffManager({ testMode = false } = {}) {
318
274
  }
319
275
  else if (info.action === 'modified') {
320
276
  // Modified: Revert modifications in flowStore (currentFlow)
321
- const oldModule = getModuleFromFlow(actualId, beforeFlow);
322
- const newModule = getModuleFromFlow(actualId, flowStore.val);
277
+ const oldModule = findModuleInFlow(beforeFlow.value, actualId) ?? undefined;
278
+ const newModule = findModuleInFlow(flowStore.val.value, actualId) ?? undefined;
323
279
  if (oldModule && newModule) {
324
- Object.keys(newModule).forEach((k) => delete newModule[k]);
325
- Object.assign(newModule, $state.snapshot(oldModule));
280
+ replaceFlowModule(newModule, $state.snapshot(oldModule));
326
281
  }
327
282
  refreshStateStore(flowStore);
328
283
  }
@@ -391,20 +346,10 @@ export function createFlowDiffManager({ testMode = false } = {}) {
391
346
  }
392
347
  else {
393
348
  // Show module diff
394
- const beforeModule = getModuleFromFlow(moduleId, beforeFlow);
395
- // Need to check failure_module and preprocessor_module for currentFlow as well
396
- let afterModule = undefined;
397
- if (currentFlow) {
398
- if (currentFlow.preprocessor_module?.id === moduleId) {
399
- afterModule = currentFlow.preprocessor_module;
400
- }
401
- else if (currentFlow.failure_module?.id === moduleId) {
402
- afterModule = currentFlow.failure_module;
403
- }
404
- else {
405
- afterModule = dfs(moduleId, { value: currentFlow, summary: '' }, false)[0];
406
- }
407
- }
349
+ const beforeModule = findModuleInFlow(beforeFlow.value, moduleId) ?? undefined;
350
+ const afterModule = currentFlow
351
+ ? (findModuleInFlow(currentFlow, moduleId) ?? undefined)
352
+ : undefined;
408
353
  if (beforeModule && afterModule) {
409
354
  diffDrawer.openDrawer();
410
355
  diffDrawer.setDiff({