windmill-components 1.677.1 → 1.695.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 (552) hide show
  1. package/package/components/AppConnectInner.svelte +6 -0
  2. package/package/components/ArgInput.svelte +2 -0
  3. package/package/components/AutoscalingConfigEditor.svelte +18 -4
  4. package/package/components/CiTestResults.svelte +64 -0
  5. package/package/components/CiTestResults.svelte.d.ts +7 -0
  6. package/package/components/CompareWorkspaces.svelte +741 -484
  7. package/package/components/DBManager.svelte +35 -4
  8. package/package/components/DBManager.svelte.d.ts +2 -0
  9. package/package/components/DBManagerContent.svelte +3 -1
  10. package/package/components/DBManagerContent.svelte.d.ts +3 -0
  11. package/package/components/DBManagerDrawer.svelte +145 -3
  12. package/package/components/DBTableEditor.svelte +14 -4
  13. package/package/components/DatatablePicker.svelte +2 -5
  14. package/package/components/DatatableSchemaDiff.svelte +531 -0
  15. package/package/components/DatatableSchemaDiff.svelte.d.ts +29 -0
  16. package/package/components/DedicatedWorkersSelector.svelte +4 -2
  17. package/package/components/DefaultTagsInner.svelte +42 -2
  18. package/package/components/DeployWorkspaceDrawer.svelte +1 -1
  19. package/package/components/Dev.svelte +407 -74
  20. package/package/components/EditableSchemaForm.svelte +4 -0
  21. package/package/components/Editor.svelte +1 -1
  22. package/package/components/EditorBar.svelte +1 -1
  23. package/package/components/EditorBar.svelte.d.ts +1 -1
  24. package/package/components/ErrorOrRecoveryHandler.svelte +2 -2
  25. package/package/components/FlowPreviewContent.svelte +32 -30
  26. package/package/components/FlowRestartButton.svelte +143 -61
  27. package/package/components/FlowRestartButton.svelte.d.ts +37 -0
  28. package/package/components/FlowStatusViewer.svelte +15 -1
  29. package/package/components/FlowStatusViewer.svelte.d.ts +10 -2
  30. package/package/components/FlowStatusViewerInner.svelte +270 -222
  31. package/package/components/FlowStatusViewerInner.svelte.d.ts +6 -2
  32. package/package/components/FlowTimeline.svelte +1 -1
  33. package/package/components/FolderEditor.svelte +189 -4
  34. package/package/components/ForkConflictModal.svelte +57 -0
  35. package/package/components/ForkConflictModal.svelte.d.ts +3 -0
  36. package/package/components/ForkWorkspaceBanner.svelte +82 -11
  37. package/package/components/GitRepoViewer.svelte +251 -97
  38. package/package/components/GlobalUserOffboardingModal.svelte +293 -0
  39. package/package/components/GlobalUserOffboardingModal.svelte.d.ts +10 -0
  40. package/package/components/InputTransformSchemaForm.svelte +1 -1
  41. package/package/components/InstanceSettings.svelte +58 -19
  42. package/package/components/Login.svelte +133 -36
  43. package/package/components/Login.svelte.d.ts +1 -0
  44. package/package/components/ModuleTest.svelte +2 -1
  45. package/package/components/NoMainFuncBadge.svelte +1 -1
  46. package/package/components/OffboardItemsBox.svelte +56 -0
  47. package/package/components/OffboardItemsBox.svelte.d.ts +12 -0
  48. package/package/components/OffboardReassignControls.svelte +47 -0
  49. package/package/components/OffboardReassignControls.svelte.d.ts +20 -0
  50. package/package/components/OffboardWorkspaceSection.svelte +110 -0
  51. package/package/components/OffboardWorkspaceSection.svelte.d.ts +24 -0
  52. package/package/components/OnBehalfOfSelector.svelte +21 -3
  53. package/package/components/OnBehalfOfSelector.svelte.d.ts +7 -0
  54. package/package/components/Path.svelte +7 -1
  55. package/package/components/Path.svelte.d.ts +1 -1
  56. package/package/components/QueueAlerts.svelte +10 -10
  57. package/package/components/ResourcePicker.svelte +2 -2
  58. package/package/components/RunsPage.svelte +2 -1
  59. package/package/components/S3FilePickerInner.svelte +89 -89
  60. package/package/components/ScriptBuilder.svelte +52 -11
  61. package/package/components/ScriptEditor.svelte +19 -8
  62. package/package/components/ScriptEditor.svelte.d.ts +1 -1
  63. package/package/components/ShareModal.svelte +236 -98
  64. package/package/components/ShareModal.svelte.d.ts +1 -1
  65. package/package/components/SuperadminSettingsInner.svelte +362 -315
  66. package/package/components/UserOffboardingModal.svelte +238 -0
  67. package/package/components/UserOffboardingModal.svelte.d.ts +10 -0
  68. package/package/components/WorkspaceDeployLayout.svelte +3 -3
  69. package/package/components/WorkspaceDeployLayout.svelte.d.ts +1 -0
  70. package/package/components/apps/components/helpers/RunnableComponent.svelte.d.ts +3 -0
  71. package/package/components/apps/components/helpers/executeRunnable.js +2 -1
  72. package/package/components/apps/editor/AppReportsDrawerInner.svelte +1 -1
  73. package/package/components/apps/editor/appPolicy.js +2 -1
  74. package/package/components/apps/editor/commonAppUtils.d.ts +3 -0
  75. package/package/components/apps/editor/inlineScriptsPanel/CacheTtlPopup.svelte +1 -1
  76. package/package/components/apps/editor/inlineScriptsPanel/InlineScriptEditor.svelte +7 -0
  77. package/package/components/apps/editor/inlineScriptsPanel/InlineScriptRunnableByPath.svelte +4 -2
  78. package/package/components/apps/editor/inlineScriptsPanel/TagPopup.svelte +49 -0
  79. package/package/components/apps/editor/inlineScriptsPanel/TagPopup.svelte.d.ts +9 -0
  80. package/package/components/apps/editor/settingsPanel/mainInput/RunnableSelector.svelte +12 -0
  81. package/package/components/apps/inputType.d.ts +1 -0
  82. package/package/components/apps/sharedTypes.d.ts +1 -0
  83. package/package/components/assets/AssetsDropdownButton.svelte +1 -1
  84. package/package/components/auditLogs/AuditLogsFilters.svelte +8 -3
  85. package/package/components/common/confirmationModal/ConfirmationModal.svelte +1 -1
  86. package/package/components/common/fileUpload/S3ArgInput.svelte +12 -10
  87. package/package/components/common/fileUpload/S3ArgInput.svelte.d.ts +2 -0
  88. package/package/components/common/table/AppRow.svelte +3 -3
  89. package/package/components/common/table/FlowRow.svelte +3 -3
  90. package/package/components/common/table/RawAppRow.svelte +4 -4
  91. package/package/components/common/table/Row.svelte +6 -2
  92. package/package/components/common/table/ScriptRow.svelte +11 -3
  93. package/package/components/copilot/chat/AIChatDisplay.svelte +5 -36
  94. package/package/components/copilot/chat/AIChatInput.svelte +56 -47
  95. package/package/components/copilot/chat/AIChatManager.svelte.js +50 -48
  96. package/package/components/copilot/chat/ContextElementBadge.svelte +6 -4
  97. package/package/components/copilot/chat/anthropic.d.ts +7 -1
  98. package/package/components/copilot/chat/anthropic.js +5 -2
  99. package/package/components/copilot/chat/app/core.d.ts +12 -20
  100. package/package/components/copilot/chat/app/core.js +230 -159
  101. package/package/components/copilot/chat/app/core.test.js +417 -0
  102. package/package/components/copilot/chat/chatLoop.d.ts +3 -0
  103. package/package/components/copilot/chat/chatLoop.js +13 -5
  104. package/package/components/copilot/chat/context.js +44 -0
  105. package/package/components/copilot/chat/flow/FlowAIChat.svelte +57 -76
  106. package/package/components/copilot/chat/flow/core.d.ts +14 -3
  107. package/package/components/copilot/chat/flow/core.js +494 -116
  108. package/package/components/copilot/chat/flow/helperUtils.d.ts +22 -0
  109. package/package/components/copilot/chat/flow/helperUtils.js +100 -0
  110. package/package/components/copilot/chat/flow/helperUtils.test.js +231 -0
  111. package/package/components/copilot/chat/flow/inlineScriptsUtils.d.ts +5 -24
  112. package/package/components/copilot/chat/flow/inlineScriptsUtils.js +30 -55
  113. package/package/components/copilot/chat/flow/openFlow.json +1 -1
  114. package/package/components/copilot/chat/flow/openFlowZod.gen.js +24 -0
  115. package/package/components/copilot/chat/flow/utils.test.js +59 -0
  116. package/package/components/copilot/chat/openai-responses.d.ts +7 -1
  117. package/package/components/copilot/chat/openai-responses.js +5 -2
  118. package/package/components/copilot/chat/script/core.js +3 -0
  119. package/package/components/copilot/chat/shared.d.ts +7 -2
  120. package/package/components/copilot/chat/shared.js +116 -53
  121. package/package/components/copilot/chat/shared.test.d.ts +1 -0
  122. package/package/components/copilot/chat/shared.test.js +412 -0
  123. package/package/components/copilot/chat/tokenUsage.d.ts +23 -0
  124. package/package/components/copilot/chat/tokenUsage.js +42 -0
  125. package/package/components/copilot/chat/workspaceTools.d.ts +7 -0
  126. package/package/components/copilot/chat/workspaceTools.js +239 -0
  127. package/package/components/copilot/chat/workspaceToolsZod.gen.d.ts +1295 -0
  128. package/package/components/copilot/chat/workspaceToolsZod.gen.js +424 -0
  129. package/package/components/copilot/lib.d.ts +5 -1
  130. package/package/components/copilot/lib.js +24 -6
  131. package/package/components/copilot/lib.test.d.ts +1 -0
  132. package/package/components/copilot/lib.test.js +19 -0
  133. package/package/components/copilot/modelConfig.d.ts +3 -0
  134. package/package/components/copilot/modelConfig.js +10 -0
  135. package/package/components/deploymentRequest/DeploymentRequestPanel.svelte +337 -0
  136. package/package/components/deploymentRequest/DeploymentRequestPanel.svelte.d.ts +15 -0
  137. package/package/components/details/CopyableCodeBlock.svelte +18 -8
  138. package/package/components/details/CopyableCodeBlock.svelte.d.ts +1 -0
  139. package/package/components/flows/FlowAssetsHandler.svelte +19 -21
  140. package/package/components/flows/FlowProgressBar.svelte +5 -2
  141. package/package/components/flows/agentToolTree.d.ts +17 -0
  142. package/package/components/flows/agentToolTree.js +114 -0
  143. package/package/components/flows/agentToolTree.test.d.ts +1 -0
  144. package/package/components/flows/agentToolTree.test.js +86 -0
  145. package/package/components/flows/agentToolUtils.d.ts +0 -5
  146. package/package/components/flows/agentToolUtils.js +0 -49
  147. package/package/components/flows/content/FlowLoop.svelte +7 -4
  148. package/package/components/flows/content/FlowModuleComponent.svelte +636 -599
  149. package/package/components/flows/content/FlowModuleDeleteAfterUse.svelte +15 -7
  150. package/package/components/flows/content/FlowSettings.svelte +29 -0
  151. package/package/components/flows/conversations/FlowChatManager.svelte.js +21 -10
  152. package/package/components/flows/dfs.d.ts +6 -2
  153. package/package/components/flows/dfs.js +19 -11
  154. package/package/components/flows/flowDeleteController.d.ts +32 -0
  155. package/package/components/flows/flowDeleteController.js +54 -0
  156. package/package/components/flows/flowDeleteController.test.d.ts +1 -0
  157. package/package/components/flows/flowDeleteController.test.js +121 -0
  158. package/package/components/flows/flowDeleteUtils.d.ts +48 -0
  159. package/package/components/flows/flowDeleteUtils.js +150 -0
  160. package/package/components/flows/flowDeleteUtils.test.d.ts +1 -0
  161. package/package/components/flows/flowDeleteUtils.test.js +131 -0
  162. package/package/components/flows/flowDiff.d.ts +2 -47
  163. package/package/components/flows/flowDiff.js +16 -293
  164. package/package/components/flows/flowDiff.testUtils.d.ts +8 -0
  165. package/package/components/flows/flowDiff.testUtils.js +26 -0
  166. package/package/components/flows/flowDiffManager.svelte.js +20 -75
  167. package/package/components/flows/flowDiffManager.svelte.test.js +103 -2
  168. package/package/components/flows/flowExplorer.d.ts +4 -0
  169. package/package/components/flows/flowExplorer.js +7 -30
  170. package/package/components/flows/flowState.d.ts +1 -0
  171. package/package/components/flows/flowStateUtils.svelte.js +11 -2
  172. package/package/components/flows/flowTree.d.ts +91 -0
  173. package/package/components/flows/flowTree.js +326 -0
  174. package/package/components/flows/flowTree.test.d.ts +1 -0
  175. package/package/components/flows/flowTree.test.js +236 -0
  176. package/package/components/flows/map/FlowJobsMenu.svelte +36 -30
  177. package/package/components/flows/map/FlowModuleSchemaItem.svelte +1 -1
  178. package/package/components/flows/map/FlowModuleSchemaMap.svelte +73 -229
  179. package/package/components/flows/map/FlowModuleSchemaMap.svelte.d.ts +1 -2
  180. package/package/components/flows/pickers/PickHubScriptQuick.svelte +2 -2
  181. package/package/components/flows/previousResults.js +13 -41
  182. package/package/components/flows/previousResults.test.d.ts +1 -0
  183. package/package/components/flows/previousResults.test.js +65 -0
  184. package/package/components/flows/propPicker/OutputPicker.svelte +2 -1
  185. package/package/components/flows/propPicker/OutputPickerInner.svelte +41 -4
  186. package/package/components/flows/propPicker/StepHistory.svelte +9 -1
  187. package/package/components/git_sync/GitSyncContext.svelte.js +11 -7
  188. package/package/components/git_sync/GitSyncRepositoryCard.svelte +2 -29
  189. package/package/components/git_sync/PullWorkspaceModal.svelte +6 -7
  190. package/package/components/graph/FlowGraphV2.svelte +8 -4
  191. package/package/components/graph/FlowGraphV2.svelte.d.ts +2 -0
  192. package/package/components/graph/groupedModulesProxy.svelte.d.ts +10 -0
  193. package/package/components/graph/groupedModulesProxy.svelte.js +17 -1
  194. package/package/components/graph/renderers/triggers/TriggersBadge.svelte +8 -2
  195. package/package/components/home/HomeConnectDrawer.svelte +125 -0
  196. package/package/components/home/HomeConnectDrawer.svelte.d.ts +5 -0
  197. package/package/components/home/deploy_ui.js +1 -1
  198. package/package/components/icons/AzureIcon.svelte +12 -25
  199. package/package/components/icons/AzureIcon.svelte.d.ts +3 -2
  200. package/package/components/icons/GithubIcon.svelte +4 -4
  201. package/package/components/icons/GithubIcon.svelte.d.ts +5 -2
  202. package/package/components/instanceSettings/ExternalJwtTokens.svelte +85 -0
  203. package/package/components/instanceSettings/ExternalJwtTokens.svelte.d.ts +12 -0
  204. package/package/components/instanceSettings/GhesAppSettings.svelte +17 -0
  205. package/package/components/instanceSettings/IndexerMemorySettings.svelte +56 -29
  206. package/package/components/instanceSettings/SecretBackendConfig.svelte +9 -2
  207. package/package/components/instanceSettings.d.ts +1 -0
  208. package/package/components/instanceSettings.js +66 -8
  209. package/package/components/mcp/McpScopeSelector.svelte +119 -9
  210. package/package/components/mcp/McpScopeSelector.svelte.d.ts +1 -0
  211. package/package/components/offboarding-utils.d.ts +11 -0
  212. package/package/components/offboarding-utils.js +102 -0
  213. package/package/components/progressBar/ProgressBar.svelte +9 -5
  214. package/package/components/progressBar/ProgressBar.svelte.d.ts +1 -0
  215. package/package/components/raw_apps/DeleteAfterUsePopup.svelte +52 -0
  216. package/package/components/raw_apps/DeleteAfterUsePopup.svelte.d.ts +9 -0
  217. package/package/components/raw_apps/RawAppBackgroundRunner.svelte +5 -1
  218. package/package/components/raw_apps/RawAppDataTableDrawer.svelte +1 -1
  219. package/package/components/raw_apps/RawAppEditor.svelte +186 -102
  220. package/package/components/raw_apps/RawAppEditorHeader.svelte +6 -1
  221. package/package/components/raw_apps/RawAppEditorHeader.svelte.d.ts +1 -0
  222. package/package/components/raw_apps/RawAppInlineScriptEditor.svelte +9 -3
  223. package/package/components/raw_apps/RawAppInlineScriptEditor.svelte.d.ts +2 -1
  224. package/package/components/raw_apps/RawAppInlineScriptRunnable.svelte +1 -0
  225. package/package/components/raw_apps/RawAppInlineScriptRunnable.svelte.d.ts +1 -0
  226. package/package/components/raw_apps/RawAppInputsSpecEditor.svelte +48 -5
  227. package/package/components/raw_apps/RawAppSharedUiDrawer.svelte +129 -0
  228. package/package/components/raw_apps/RawAppSharedUiDrawer.svelte.d.ts +5 -0
  229. package/package/components/raw_apps/RawAppSidebar.svelte +12 -0
  230. package/package/components/raw_apps/RawAppYamlEditor.svelte +81 -0
  231. package/package/components/raw_apps/RawAppYamlEditor.svelte.d.ts +20 -0
  232. package/package/components/raw_apps/dataTableRefUtils.d.ts +7 -0
  233. package/package/components/raw_apps/dataTableRefUtils.js +34 -0
  234. package/package/components/raw_apps/dataTableRefUtils.test.d.ts +1 -0
  235. package/package/components/raw_apps/dataTableRefUtils.test.js +29 -0
  236. package/package/components/raw_apps/datatableUtils.svelte.js +1 -1
  237. package/package/components/raw_apps/rawAppPolicy.d.ts +1 -0
  238. package/package/components/raw_apps/rawAppPolicy.js +17 -2
  239. package/package/components/resources/resourceTypesFilter.d.ts +19 -0
  240. package/package/components/resources/resourceTypesFilter.js +21 -0
  241. package/package/components/restartFromStepPath.d.ts +39 -0
  242. package/package/components/restartFromStepPath.js +89 -0
  243. package/package/components/runs/JobDetailFieldConfig.d.ts +1 -0
  244. package/package/components/runs/JobDetailFieldConfig.js +57 -10
  245. package/package/components/runs/JobDetailHeader.svelte +24 -3
  246. package/package/components/runs/runsFilter.d.ts +1 -1
  247. package/package/components/schema/FlowPropertyEditor.svelte +30 -1
  248. package/package/components/schema/FlowPropertyEditor.svelte.d.ts +5 -2
  249. package/package/components/script_builder.d.ts +1 -1
  250. package/package/components/search/GlobalSearchModal.svelte +8 -1
  251. package/package/components/select/Select.svelte +3 -2
  252. package/package/components/select/Select.svelte.d.ts +1 -0
  253. package/package/components/settings/CreateToken.svelte +91 -71
  254. package/package/components/settings/CreateToken.svelte.d.ts +3 -0
  255. package/package/components/settings/EditTokenScopesModal.svelte +57 -0
  256. package/package/components/settings/EditTokenScopesModal.svelte.d.ts +10 -0
  257. package/package/components/settings/ScopesPicker.svelte +43 -0
  258. package/package/components/settings/ScopesPicker.svelte.d.ts +11 -0
  259. package/package/components/settings/TokensTable.svelte +51 -15
  260. package/package/components/settings/WorkspaceUserSettings.svelte +34 -28
  261. package/package/components/sidebar/OperatorMenu.svelte +6 -0
  262. package/package/components/sidebar/SidebarContent.svelte +68 -2
  263. package/package/components/sidebar/WorkspaceMenu.svelte +8 -4
  264. package/package/components/triggers/AddTriggersButton.svelte +17 -0
  265. package/package/components/triggers/CaptureWrapper.svelte +19 -1
  266. package/package/components/triggers/PermissionedAsLine.svelte +37 -3
  267. package/package/components/triggers/PermissionedAsLine.svelte.d.ts +6 -0
  268. package/package/components/triggers/TriggerEditorToolbar.svelte.d.ts +1 -1
  269. package/package/components/triggers/TriggerModeToggle.svelte +36 -7
  270. package/package/components/triggers/TriggerModeToggle.svelte.d.ts +1 -1
  271. package/package/components/triggers/TriggerSuspendedJobsModal.svelte.d.ts +1 -1
  272. package/package/components/triggers/TriggersEditor.svelte +10 -2
  273. package/package/components/triggers/TriggersWrapper.svelte +20 -0
  274. package/package/components/triggers/azure/AzureCapture.svelte +41 -0
  275. package/package/components/triggers/azure/AzureCapture.svelte.d.ts +44 -0
  276. package/package/components/triggers/azure/AzureTriggerEditor.svelte +20 -0
  277. package/package/components/triggers/azure/AzureTriggerEditor.svelte.d.ts +9 -0
  278. package/package/components/triggers/azure/AzureTriggerEditorConfigSection.svelte +301 -0
  279. package/package/components/triggers/azure/AzureTriggerEditorConfigSection.svelte.d.ts +16 -0
  280. package/package/components/triggers/azure/AzureTriggerEditorInner.svelte +422 -0
  281. package/package/components/triggers/azure/AzureTriggerEditorInner.svelte.d.ts +25 -0
  282. package/package/components/triggers/azure/AzureTriggerPanel.svelte +55 -0
  283. package/package/components/triggers/azure/AzureTriggerPanel.svelte.d.ts +10 -0
  284. package/{dist/sharedUtils/components/triggers/kafka → package/components/triggers/azure}/utils.d.ts +1 -1
  285. package/package/components/triggers/azure/utils.js +56 -0
  286. package/package/components/triggers/email/EmailTriggerEditorInner.svelte +15 -11
  287. package/package/components/triggers/gcp/GcpTriggerEditorInner.svelte +22 -14
  288. package/package/components/triggers/http/RouteEditorConfigSection.svelte +15 -7
  289. package/package/components/triggers/http/RouteEditorInner.svelte +16 -14
  290. package/package/components/triggers/http/RoutesGenerator.svelte +6 -1
  291. package/package/components/triggers/http/RoutesPanel.svelte +1 -1
  292. package/package/components/triggers/http/utils.d.ts +1 -1
  293. package/package/components/triggers/http/utils.js +2 -2
  294. package/package/components/triggers/kafka/KafkaTriggerEditorInner.svelte +22 -14
  295. package/package/components/triggers/mqtt/MqttTriggerEditorInner.svelte +22 -14
  296. package/package/components/triggers/native/NativeTriggerEditor.svelte +3 -0
  297. package/package/components/triggers/native/services/github/GitHubTriggerForm.svelte +118 -0
  298. package/package/components/triggers/native/services/github/GitHubTriggerForm.svelte.d.ts +17 -0
  299. package/package/components/triggers/native/utils.js +14 -0
  300. package/package/components/triggers/nats/NatsTriggerEditor.svelte.d.ts +4 -3
  301. package/package/components/triggers/nats/NatsTriggerEditorInner.svelte +22 -14
  302. package/package/components/triggers/postgres/PostgresTriggerEditor.svelte.d.ts +4 -3
  303. package/package/components/triggers/postgres/PostgresTriggerEditorInner.svelte +22 -14
  304. package/package/components/triggers/schedules/ScheduleEditorInner.svelte +22 -14
  305. package/package/components/triggers/sqs/SqsTriggerEditor.svelte.d.ts +4 -3
  306. package/package/components/triggers/sqs/SqsTriggerEditorInner.svelte +22 -14
  307. package/package/components/triggers/triggers.svelte.d.ts +1 -0
  308. package/package/components/triggers/triggers.svelte.js +24 -1
  309. package/package/components/triggers/utils.js +47 -6
  310. package/package/components/triggers/websocket/WebsocketTriggerEditorInner.svelte +22 -14
  311. package/package/components/triggers.d.ts +1 -1
  312. package/package/components/useFolderDefaultPermissionedAs.svelte.d.ts +13 -0
  313. package/package/components/useFolderDefaultPermissionedAs.svelte.js +63 -0
  314. package/package/components/useNestedRestartState.svelte.d.ts +56 -0
  315. package/package/components/useNestedRestartState.svelte.js +320 -0
  316. package/package/components/workspaceSettings/CreateWorkspace.svelte +16 -677
  317. package/package/components/workspaceSettings/CreateWorkspaceInner.svelte +604 -0
  318. package/package/components/workspaceSettings/CreateWorkspaceInner.svelte.d.ts +7 -0
  319. package/package/components/workspaceSettings/CustomInstanceDbSelect.svelte +27 -25
  320. package/package/components/workspaceSettings/CustomInstanceDbWizardModal.svelte +46 -8
  321. package/package/components/workspaceSettings/DataTableSettings.svelte +27 -22
  322. package/package/components/workspaceSettings/DucklakeSettings.svelte +1 -1
  323. package/package/components/workspaceSettings/ForkDatatableSection.svelte +228 -0
  324. package/package/components/workspaceSettings/ForkDatatableSection.svelte.d.ts +28 -0
  325. package/package/components/workspaceSettings/GitSyncFilterSettings.svelte +8 -2
  326. package/package/components/workspaceSettings/RulesetEditor.svelte +27 -2
  327. package/package/components/workspaceSettings/SharedUiSettings.svelte +175 -0
  328. package/package/components/workspaceSettings/SharedUiSettings.svelte.d.ts +3 -0
  329. package/package/components/workspaceSettings/VolumeStorageSettings.svelte +1 -1
  330. package/package/components/workspaceSettings/WorkspaceIntegrations.svelte +17 -1
  331. package/package/consts.d.ts +3 -0
  332. package/package/consts.js +10 -0
  333. package/package/gen/core/OpenAPI.js +1 -1
  334. package/package/gen/schemas.gen.d.ts +795 -59
  335. package/package/gen/schemas.gen.js +801 -60
  336. package/package/gen/services.gen.d.ts +475 -5
  337. package/package/gen/services.gen.js +976 -23
  338. package/package/gen/types.gen.d.ts +1865 -75
  339. package/package/githubApp.js +5 -1
  340. package/package/hubPaths.json +2 -8
  341. package/package/infer.d.ts +1 -1
  342. package/package/infer.js +50 -52
  343. package/package/infer.svelte.js +10 -1
  344. package/package/mcpEndpointTools.js +60 -4
  345. package/package/monaco_workers/sqlTypePlugin.worker.d.ts +10 -0
  346. package/package/monaco_workers/sqlTypePlugin.worker.js +39 -0
  347. package/package/script_helpers.d.ts +8 -2
  348. package/package/script_helpers.js +31 -0
  349. package/package/stores.d.ts +11 -0
  350. package/package/stores.js +6 -0
  351. package/package/system_prompts/index.d.ts +1 -0
  352. package/package/system_prompts/index.js +8 -0
  353. package/package/system_prompts/prompts.d.ts +17 -13
  354. package/package/system_prompts/prompts.js +921 -61
  355. package/package/templates/ci_test_bun.ts.template +27 -0
  356. package/package/templates/ci_test_python.py.template +26 -0
  357. package/package/utils/forkConflict.d.ts +26 -0
  358. package/package/utils/forkConflict.js +56 -0
  359. package/package/utils_deployable.d.ts +164 -121
  360. package/package/utils_deployable.js +61 -11
  361. package/package/utils_workspace_deploy.d.ts +8 -8
  362. package/package/utils_workspace_deploy.js +89 -421
  363. package/package.json +30 -6
  364. package/dist/sharedUtils/assets/tokens/colorTokensConfig.d.ts +0 -2
  365. package/dist/sharedUtils/base.d.ts +0 -1
  366. package/dist/sharedUtils/cloud.d.ts +0 -1
  367. package/dist/sharedUtils/common.d.ts +0 -111
  368. package/dist/sharedUtils/components/apps/components/display/dbtable/queries/count.d.ts +0 -5
  369. package/dist/sharedUtils/components/apps/components/display/dbtable/queries/delete.d.ts +0 -5
  370. package/dist/sharedUtils/components/apps/components/display/dbtable/queries/insert.d.ts +0 -5
  371. package/dist/sharedUtils/components/apps/components/display/dbtable/queries/select.d.ts +0 -13
  372. package/dist/sharedUtils/components/apps/components/display/dbtable/queries/update.d.ts +0 -11
  373. package/dist/sharedUtils/components/apps/components/display/dbtable/utils.d.ts +0 -95
  374. package/dist/sharedUtils/components/apps/editor/appPolicy.d.ts +0 -6
  375. package/dist/sharedUtils/components/apps/editor/appUtilsCore.d.ts +0 -7
  376. package/dist/sharedUtils/components/apps/editor/appUtilsS3.d.ts +0 -33
  377. package/dist/sharedUtils/components/apps/editor/commonAppUtils.d.ts +0 -10
  378. package/dist/sharedUtils/components/apps/editor/component/components.d.ts +0 -5371
  379. package/dist/sharedUtils/components/apps/editor/component/default-codes.d.ts +0 -3
  380. package/dist/sharedUtils/components/apps/editor/component/index.d.ts +0 -3
  381. package/dist/sharedUtils/components/apps/editor/component/sets.d.ts +0 -7
  382. package/dist/sharedUtils/components/apps/editor/componentsPanel/componentDefaultProps.d.ts +0 -3
  383. package/dist/sharedUtils/components/apps/gridUtils.d.ts +0 -14
  384. package/dist/sharedUtils/components/apps/inputType.d.ts +0 -178
  385. package/dist/sharedUtils/components/apps/rx.d.ts +0 -29
  386. package/dist/sharedUtils/components/apps/sharedTypes.d.ts +0 -21
  387. package/dist/sharedUtils/components/apps/types.d.ts +0 -274
  388. package/dist/sharedUtils/components/assets/lib.d.ts +0 -25
  389. package/dist/sharedUtils/components/common/alert/model.d.ts +0 -2
  390. package/dist/sharedUtils/components/common/badge/model.d.ts +0 -8
  391. package/dist/sharedUtils/components/common/button/model.d.ts +0 -45
  392. package/dist/sharedUtils/components/common/fileInput/model.d.ts +0 -1
  393. package/dist/sharedUtils/components/common/index.d.ts +0 -24
  394. package/dist/sharedUtils/components/common/skeleton/model.d.ts +0 -21
  395. package/dist/sharedUtils/components/dbTypes.d.ts +0 -14
  396. package/dist/sharedUtils/components/diff_drawer.d.ts +0 -26
  397. package/dist/sharedUtils/components/ducklake.d.ts +0 -1
  398. package/dist/sharedUtils/components/flows/scheduleUtils.d.ts +0 -7
  399. package/dist/sharedUtils/components/icons/index.d.ts +0 -101
  400. package/dist/sharedUtils/components/random_positive_adjetive.d.ts +0 -1
  401. package/dist/sharedUtils/components/raw_apps/rawAppPolicy.d.ts +0 -10
  402. package/dist/sharedUtils/components/raw_apps/utils.d.ts +0 -15
  403. package/dist/sharedUtils/components/triggers/email/utils.d.ts +0 -4
  404. package/dist/sharedUtils/components/triggers/gcp/utils.d.ts +0 -2
  405. package/dist/sharedUtils/components/triggers/http/utils.d.ts +0 -11
  406. package/dist/sharedUtils/components/triggers/mqtt/utils.d.ts +0 -2
  407. package/dist/sharedUtils/components/triggers/nats/utils.d.ts +0 -2
  408. package/dist/sharedUtils/components/triggers/postgres/utils.d.ts +0 -8
  409. package/dist/sharedUtils/components/triggers/sqs/utils.d.ts +0 -2
  410. package/dist/sharedUtils/components/triggers/triggers.svelte.d.ts +0 -32
  411. package/dist/sharedUtils/components/triggers/utils.d.ts +0 -80
  412. package/dist/sharedUtils/components/triggers/websocket/utils.d.ts +0 -2
  413. package/dist/sharedUtils/components/triggers.d.ts +0 -20
  414. package/dist/sharedUtils/gen/core/ApiError.d.ts +0 -10
  415. package/dist/sharedUtils/gen/core/ApiRequestOptions.d.ts +0 -13
  416. package/dist/sharedUtils/gen/core/ApiResult.d.ts +0 -7
  417. package/dist/sharedUtils/gen/core/CancelablePromise.d.ts +0 -26
  418. package/dist/sharedUtils/gen/core/OpenAPI.d.ts +0 -27
  419. package/dist/sharedUtils/gen/core/request.d.ts +0 -29
  420. package/dist/sharedUtils/gen/index.d.ts +0 -6
  421. package/dist/sharedUtils/gen/schemas.gen.d.ts +0 -7036
  422. package/dist/sharedUtils/gen/services.gen.d.ts +0 -6047
  423. package/dist/sharedUtils/gen/types.gen.d.ts +0 -21881
  424. package/dist/sharedUtils/history.svelte.d.ts +0 -9
  425. package/dist/sharedUtils/hub.d.ts +0 -49
  426. package/dist/sharedUtils/jsr.json +0 -6
  427. package/dist/sharedUtils/lib.d.ts +0 -5
  428. package/dist/sharedUtils/lib.es.js +0 -1588
  429. package/dist/sharedUtils/package.json +0 -12
  430. package/dist/sharedUtils/schema.d.ts +0 -3
  431. package/dist/sharedUtils/stores.d.ts +0 -97
  432. package/dist/sharedUtils/svelte5Utils.svelte.d.ts +0 -80
  433. package/dist/sharedUtils/toast.d.ts +0 -8
  434. package/dist/sharedUtils/utils.d.ts +0 -265
  435. package/package/components/copilot/chat/__tests__/app/appChat.eval.test.js +0 -153
  436. package/package/components/copilot/chat/__tests__/app/appEvalComparison.d.ts +0 -21
  437. package/package/components/copilot/chat/__tests__/app/appEvalComparison.js +0 -136
  438. package/package/components/copilot/chat/__tests__/app/appEvalHelpers.d.ts +0 -15
  439. package/package/components/copilot/chat/__tests__/app/appEvalHelpers.js +0 -107
  440. package/package/components/copilot/chat/__tests__/app/appEvalRunner.d.ts +0 -50
  441. package/package/components/copilot/chat/__tests__/app/appEvalRunner.js +0 -93
  442. package/package/components/copilot/chat/__tests__/app/appFixtureLoader.d.ts +0 -29
  443. package/package/components/copilot/chat/__tests__/app/appFixtureLoader.js +0 -134
  444. package/package/components/copilot/chat/__tests__/app/appResultsWriter.d.ts +0 -30
  445. package/package/components/copilot/chat/__tests__/app/appResultsWriter.js +0 -197
  446. package/package/components/copilot/chat/__tests__/app/initial/file_manager/backend/createFolder/main.d.ts +0 -10
  447. package/package/components/copilot/chat/__tests__/app/initial/file_manager/backend/createFolder/main.js +0 -9
  448. package/package/components/copilot/chat/__tests__/app/initial/file_manager/backend/createFolder/meta.json +0 -4
  449. package/package/components/copilot/chat/__tests__/app/initial/file_manager/backend/deleteItem/main.d.ts +0 -6
  450. package/package/components/copilot/chat/__tests__/app/initial/file_manager/backend/deleteItem/main.js +0 -5
  451. package/package/components/copilot/chat/__tests__/app/initial/file_manager/backend/deleteItem/meta.json +0 -4
  452. package/package/components/copilot/chat/__tests__/app/initial/file_manager/backend/listFiles/main.d.ts +0 -12
  453. package/package/components/copilot/chat/__tests__/app/initial/file_manager/backend/listFiles/main.js +0 -14
  454. package/package/components/copilot/chat/__tests__/app/initial/file_manager/backend/listFiles/meta.json +0 -4
  455. package/package/components/copilot/chat/__tests__/app/initial/file_manager/backend/listFolders/main.d.ts +0 -8
  456. package/package/components/copilot/chat/__tests__/app/initial/file_manager/backend/listFolders/main.js +0 -25
  457. package/package/components/copilot/chat/__tests__/app/initial/file_manager/backend/listFolders/meta.json +0 -4
  458. package/package/components/copilot/chat/__tests__/app/initial/file_manager/backend/moveItem/main.d.ts +0 -7
  459. package/package/components/copilot/chat/__tests__/app/initial/file_manager/backend/moveItem/main.js +0 -5
  460. package/package/components/copilot/chat/__tests__/app/initial/file_manager/backend/moveItem/meta.json +0 -4
  461. package/package/components/copilot/chat/__tests__/app/initial/file_manager/backend/renameItem/main.d.ts +0 -8
  462. package/package/components/copilot/chat/__tests__/app/initial/file_manager/backend/renameItem/main.js +0 -5
  463. package/package/components/copilot/chat/__tests__/app/initial/file_manager/backend/renameItem/meta.json +0 -4
  464. package/package/components/copilot/chat/__tests__/app/initial/file_manager/frontend/components/Breadcrumb.d.ts +0 -10
  465. package/package/components/copilot/chat/__tests__/app/initial/file_manager/frontend/components/Breadcrumb.tsx +0 -26
  466. package/package/components/copilot/chat/__tests__/app/initial/file_manager/frontend/components/FileItem.d.ts +0 -10
  467. package/package/components/copilot/chat/__tests__/app/initial/file_manager/frontend/components/FileItem.tsx +0 -79
  468. package/package/components/copilot/chat/__tests__/app/initial/file_manager/frontend/components/FileList.d.ts +0 -10
  469. package/package/components/copilot/chat/__tests__/app/initial/file_manager/frontend/components/FileList.tsx +0 -46
  470. package/package/components/copilot/chat/__tests__/app/initial/file_manager/frontend/components/FolderTree.d.ts +0 -10
  471. package/package/components/copilot/chat/__tests__/app/initial/file_manager/frontend/components/FolderTree.tsx +0 -56
  472. package/package/components/copilot/chat/__tests__/app/initial/file_manager/frontend/components/Toolbar.d.ts +0 -6
  473. package/package/components/copilot/chat/__tests__/app/initial/file_manager/frontend/components/Toolbar.tsx +0 -59
  474. package/package/components/copilot/chat/__tests__/app/initial/file_manager/frontend/index.d.ts +0 -16
  475. package/package/components/copilot/chat/__tests__/app/initial/file_manager/frontend/index.tsx +0 -119
  476. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/backend/addToCart/main.d.ts +0 -15
  477. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/backend/addToCart/main.js +0 -14
  478. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/backend/addToCart/meta.json +0 -4
  479. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/backend/calculateTotal/main.d.ts +0 -14
  480. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/backend/calculateTotal/main.js +0 -5
  481. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/backend/calculateTotal/meta.json +0 -4
  482. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/backend/getProducts/main.d.ts +0 -6
  483. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/backend/getProducts/main.js +0 -41
  484. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/backend/getProducts/meta.json +0 -4
  485. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/backend/removeFromCart/main.d.ts +0 -15
  486. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/backend/removeFromCart/main.js +0 -3
  487. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/backend/removeFromCart/meta.json +0 -4
  488. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/frontend/components/Cart.d.ts +0 -9
  489. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/frontend/components/Cart.tsx +0 -51
  490. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/frontend/components/ProductCard.d.ts +0 -8
  491. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/frontend/components/ProductCard.tsx +0 -27
  492. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/frontend/components/ProductList.d.ts +0 -8
  493. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/frontend/components/ProductList.tsx +0 -18
  494. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/frontend/index.d.ts +0 -12
  495. package/package/components/copilot/chat/__tests__/app/initial/shopping_cart/frontend/index.tsx +0 -81
  496. package/package/components/copilot/chat/__tests__/app/initial/test1_counter_app/backend/decrementCounter/main.d.ts +0 -3
  497. package/package/components/copilot/chat/__tests__/app/initial/test1_counter_app/backend/decrementCounter/main.js +0 -3
  498. package/package/components/copilot/chat/__tests__/app/initial/test1_counter_app/backend/decrementCounter/meta.json +0 -4
  499. package/package/components/copilot/chat/__tests__/app/initial/test1_counter_app/backend/incrementCounter/main.d.ts +0 -3
  500. package/package/components/copilot/chat/__tests__/app/initial/test1_counter_app/backend/incrementCounter/main.js +0 -3
  501. package/package/components/copilot/chat/__tests__/app/initial/test1_counter_app/backend/incrementCounter/meta.json +0 -4
  502. package/package/components/copilot/chat/__tests__/app/initial/test1_counter_app/frontend/index.d.ts +0 -2
  503. package/package/components/copilot/chat/__tests__/app/initial/test1_counter_app/frontend/index.tsx +0 -38
  504. package/package/components/copilot/chat/__tests__/app/variants/baseline.d.ts +0 -6
  505. package/package/components/copilot/chat/__tests__/app/variants/baseline.js +0 -10
  506. package/package/components/copilot/chat/__tests__/app/variants/index.d.ts +0 -3
  507. package/package/components/copilot/chat/__tests__/app/variants/index.js +0 -3
  508. package/package/components/copilot/chat/__tests__/app/variants/streamlined.d.ts +0 -6
  509. package/package/components/copilot/chat/__tests__/app/variants/streamlined.js +0 -137
  510. package/package/components/copilot/chat/__tests__/flow/expected/test1.json +0 -134
  511. package/package/components/copilot/chat/__tests__/flow/expected/test2.json +0 -183
  512. package/package/components/copilot/chat/__tests__/flow/expected/test3.json +0 -204
  513. package/package/components/copilot/chat/__tests__/flow/expected/test4.json +0 -175
  514. package/package/components/copilot/chat/__tests__/flow/expected/test5_modify_simple.json +0 -68
  515. package/package/components/copilot/chat/__tests__/flow/expected/test6_modify_medium.json +0 -142
  516. package/package/components/copilot/chat/__tests__/flow/expected/test7_modify_complex.json +0 -136
  517. package/package/components/copilot/chat/__tests__/flow/flowChat.eval.test.js +0 -294
  518. package/package/components/copilot/chat/__tests__/flow/flowEvalComparison.d.ts +0 -17
  519. package/package/components/copilot/chat/__tests__/flow/flowEvalComparison.js +0 -49
  520. package/package/components/copilot/chat/__tests__/flow/flowEvalHelpers.d.ts +0 -12
  521. package/package/components/copilot/chat/__tests__/flow/flowEvalHelpers.js +0 -79
  522. package/package/components/copilot/chat/__tests__/flow/flowEvalRunner.d.ts +0 -50
  523. package/package/components/copilot/chat/__tests__/flow/flowEvalRunner.js +0 -102
  524. package/package/components/copilot/chat/__tests__/flow/initial/test5_initial.json +0 -53
  525. package/package/components/copilot/chat/__tests__/flow/initial/test6_initial.json +0 -68
  526. package/package/components/copilot/chat/__tests__/flow/initial/test7_initial.json +0 -120
  527. package/package/components/copilot/chat/__tests__/flow/variants/baseline.d.ts +0 -6
  528. package/package/components/copilot/chat/__tests__/flow/variants/baseline.js +0 -10
  529. package/package/components/copilot/chat/__tests__/flow/variants/index.d.ts +0 -3
  530. package/package/components/copilot/chat/__tests__/flow/variants/index.js +0 -3
  531. package/package/components/copilot/chat/__tests__/flow/variants/minimal-single-tool.d.ts +0 -15
  532. package/package/components/copilot/chat/__tests__/flow/variants/minimal-single-tool.js +0 -388
  533. package/package/components/copilot/chat/__tests__/shared/baseEvalRunner.d.ts +0 -45
  534. package/package/components/copilot/chat/__tests__/shared/baseEvalRunner.js +0 -121
  535. package/package/components/copilot/chat/__tests__/shared/baseLLMEvaluator.d.ts +0 -28
  536. package/package/components/copilot/chat/__tests__/shared/baseLLMEvaluator.js +0 -96
  537. package/package/components/copilot/chat/__tests__/shared/baseResultsWriter.d.ts +0 -32
  538. package/package/components/copilot/chat/__tests__/shared/baseResultsWriter.js +0 -130
  539. package/package/components/copilot/chat/__tests__/shared/baseVariants.d.ts +0 -45
  540. package/package/components/copilot/chat/__tests__/shared/baseVariants.js +0 -57
  541. package/package/components/copilot/chat/__tests__/shared/index.d.ts +0 -10
  542. package/package/components/copilot/chat/__tests__/shared/index.js +0 -5
  543. package/package/components/copilot/chat/__tests__/shared/types.d.ts +0 -105
  544. package/package/components/copilot/chat/__tests__/shared/types.js +0 -9
  545. package/package/components/copilot/chat/flow/openFlowZod.js +0 -24
  546. package/package/components/copilot/chat/flow/utils.d.ts +0 -14
  547. package/package/components/copilot/chat/flow/utils.js +0 -108
  548. package/package/components/flows/agentToolUtils.test.js +0 -55
  549. /package/package/components/copilot/chat/{__tests__/app/appChat.eval.test.d.ts → app/core.test.d.ts} +0 -0
  550. /package/package/components/copilot/chat/{__tests__/flow/flowChat.eval.test.d.ts → flow/helperUtils.test.d.ts} +0 -0
  551. /package/package/components/copilot/chat/flow/{openFlowZod.d.ts → openFlowZod.gen.d.ts} +0 -0
  552. /package/package/components/{flows/agentToolUtils.test.d.ts → copilot/chat/flow/utils.test.d.ts} +0 -0
@@ -1,11 +1,14 @@
1
1
  import { ScriptService, JobService } from '../../../../gen';
2
2
  import { z } from 'zod';
3
3
  import { createDbSchemaTool, getFormattedResourceTypes, getLangContext, SUPPORTED_CHAT_SCRIPT_LANGUAGES } from '../script/core';
4
- import { createSearchHubScriptsTool, createToolDef, executeTestRun, buildSchemaForTool, buildTestRunArgs, buildContextString, applyCodePiecesToFlowModules, findModuleById, SPECIAL_MODULE_IDS, formatScriptLintResult, createSearchWorkspaceTool, createGetRunnableDetailsTool } from '../shared';
5
- import { inlineScriptStore, extractAndReplaceInlineScripts } from './inlineScriptsUtils';
6
- import { flowModulesSchema } from './openFlowZod';
7
- import { collectAllModuleIdsFromArray } from './utils';
8
- import { getFlowPrompt } from '../../../../system_prompts';
4
+ import { createSearchHubScriptsTool, createToolDef, executeTestRun, buildSchemaForTool, buildTestRunArgs, buildContextString, applyCodePiecesToFlowModules, SPECIAL_MODULE_IDS, formatScriptLintResult, createSearchWorkspaceTool, createGetRunnableDetailsTool } from '../shared';
5
+ import { createWorkspaceMutationTools } from '../workspaceTools';
6
+ import { findModuleInFlow, findModuleInModules } from '../../../flows/flowTree';
7
+ import { createInlineScriptSession } from './inlineScriptsUtils';
8
+ import { validateFlowGroups } from './helperUtils';
9
+ import { flowModuleSchema, flowModulesSchema } from './openFlowZod.gen';
10
+ import { collectAllFlowModuleIdsFromModules } from '../../../flows/flowTree';
11
+ import { FLOW_CHAT_SPECIAL_MODULES, getFlowPrompt } from '../../../../system_prompts';
9
12
  /**
10
13
  * Navigate to a schema at a given path, handling arrays, objects, unions, and wrappers.
11
14
  * Uses Zod 4 internal structure.
@@ -181,6 +184,181 @@ function getExpectedFormat(schema) {
181
184
  }
182
185
  return null;
183
186
  }
187
+ function countExactMatches(content, search) {
188
+ if (search.length === 0) {
189
+ return 0;
190
+ }
191
+ let count = 0;
192
+ let index = 0;
193
+ while ((index = content.indexOf(search, index)) !== -1) {
194
+ count++;
195
+ index += search.length;
196
+ }
197
+ return count;
198
+ }
199
+ function replaceFirstExactMatch(content, search, replace) {
200
+ const index = content.indexOf(search);
201
+ if (index === -1) {
202
+ return content;
203
+ }
204
+ return content.slice(0, index) + replace + content.slice(index + search.length);
205
+ }
206
+ function formatEmptyInlineScriptWarning({ emptyInlineScriptModuleIds }) {
207
+ if (emptyInlineScriptModuleIds.length === 0) {
208
+ return '';
209
+ }
210
+ const moduleList = emptyInlineScriptModuleIds.map((id) => `'${id}'`).join(', ');
211
+ return ` Warning: inline scripts ${moduleList} are empty for now. Use set_module_code to fill them in.`;
212
+ }
213
+ function validateFlowModules(rawModules) {
214
+ if (!Array.isArray(rawModules)) {
215
+ throw new Error('Flow modules must be an array');
216
+ }
217
+ const parsedModules = rawModules;
218
+ const result = flowModulesSchema.safeParse(parsedModules);
219
+ if (!result.success) {
220
+ const errors = result.error.issues.slice(0, 5).map((e) => {
221
+ const path = e.path;
222
+ // Try to find module id for better context
223
+ const moduleIndex = typeof path[0] === 'number' ? path[0] : undefined;
224
+ const moduleId = moduleIndex !== undefined ? parsedModules[moduleIndex]?.id : undefined;
225
+ const fieldPath = path.slice(1).join('.');
226
+ let message = e.message;
227
+ if (e.code === 'invalid_type') {
228
+ // Zod 4 message already contains "expected X, received Y"
229
+ // Try to extract expected format from schema, passing actual data
230
+ // to help resolve discriminated unions correctly
231
+ const targetSchema = getSchemaAtPath(flowModulesSchema, path, parsedModules);
232
+ if (targetSchema) {
233
+ const expectedFormat = getExpectedFormat(targetSchema);
234
+ if (expectedFormat) {
235
+ message += `\n Expected format: ${expectedFormat}`;
236
+ }
237
+ }
238
+ }
239
+ if (moduleId) {
240
+ return `Module "${moduleId}" -> ${fieldPath}: ${message}`;
241
+ }
242
+ return `${path.join('.')}: ${message}`;
243
+ });
244
+ throw new Error(`Invalid flow modules:\n${errors.join('\n')}`);
245
+ }
246
+ const ids = collectAllFlowModuleIdsFromModules(parsedModules);
247
+ if (ids.length !== new Set(ids).size) {
248
+ throw new Error('Duplicate module IDs found in flow');
249
+ }
250
+ const reservedIds = ids.filter((id) => id === SPECIAL_MODULE_IDS.PREPROCESSOR || id === SPECIAL_MODULE_IDS.FAILURE);
251
+ if (reservedIds.length > 0) {
252
+ throw new Error('Special modules must be provided via preprocessor_module and failure_module, not inside modules');
253
+ }
254
+ return parsedModules;
255
+ }
256
+ function validateFlowSchema(rawSchema) {
257
+ if (rawSchema == null) {
258
+ return null;
259
+ }
260
+ if (typeof rawSchema !== 'object' || Array.isArray(rawSchema)) {
261
+ throw new Error('Flow schema must be an object or null');
262
+ }
263
+ return rawSchema;
264
+ }
265
+ function validateOptionalFlowModule(rawModule, fieldName) {
266
+ if (rawModule == null) {
267
+ return null;
268
+ }
269
+ const result = flowModuleSchema.safeParse(rawModule);
270
+ if (!result.success) {
271
+ const error = result.error.issues[0];
272
+ throw new Error(`Invalid ${fieldName}: ${error?.message ?? 'unknown error'}`);
273
+ }
274
+ return result.data;
275
+ }
276
+ function validateEditableFlowJson(rawFlow) {
277
+ if (!rawFlow || typeof rawFlow !== 'object' || Array.isArray(rawFlow)) {
278
+ throw new Error('Flow JSON must be an object');
279
+ }
280
+ const flow = rawFlow;
281
+ const modules = validateFlowModules(flow.modules);
282
+ const schema = validateFlowSchema(flow.schema);
283
+ const preprocessorModule = validateOptionalFlowModule(flow.preprocessor_module, 'preprocessor_module');
284
+ const failureModule = validateOptionalFlowModule(flow.failure_module, 'failure_module');
285
+ const groupModuleIds = new Set(collectAllFlowModuleIdsFromModules(modules));
286
+ const groups = validateFlowGroups(flow.groups, groupModuleIds);
287
+ if (preprocessorModule) {
288
+ if (preprocessorModule.id !== SPECIAL_MODULE_IDS.PREPROCESSOR) {
289
+ throw new Error(`Invalid preprocessor_module: id must be "${SPECIAL_MODULE_IDS.PREPROCESSOR}"`);
290
+ }
291
+ if (preprocessorModule.value.type !== 'rawscript' &&
292
+ preprocessorModule.value.type !== 'script') {
293
+ throw new Error('Invalid preprocessor_module: only "rawscript" and "script" modules are supported');
294
+ }
295
+ }
296
+ if (failureModule) {
297
+ if (failureModule.id !== SPECIAL_MODULE_IDS.FAILURE) {
298
+ throw new Error(`Invalid failure_module: id must be "${SPECIAL_MODULE_IDS.FAILURE}"`);
299
+ }
300
+ if (failureModule.value.type !== 'rawscript' && failureModule.value.type !== 'script') {
301
+ throw new Error('Invalid failure_module: only "rawscript" and "script" modules are supported');
302
+ }
303
+ }
304
+ const ids = new Set(collectAllFlowModuleIdsFromModules(modules));
305
+ if (preprocessorModule) {
306
+ if (ids.has(preprocessorModule.id)) {
307
+ throw new Error(`Duplicate module ID found in preprocessor_module: ${preprocessorModule.id}`);
308
+ }
309
+ ids.add(preprocessorModule.id);
310
+ }
311
+ if (failureModule && ids.has(failureModule.id)) {
312
+ throw new Error(`Duplicate module ID found in failure_module: ${failureModule.id}`);
313
+ }
314
+ return {
315
+ modules,
316
+ schema,
317
+ preprocessor_module: preprocessorModule,
318
+ failure_module: failureModule,
319
+ groups
320
+ };
321
+ }
322
+ function buildEditableFlowJson(flow, inlineScriptSession, selectedContext = []) {
323
+ const codePieces = selectedContext.filter((c) => c.type === 'flow_module_code_piece');
324
+ const optimizedModules = inlineScriptSession
325
+ ? inlineScriptSession.extractAndReplaceInlineScripts(flow.value.modules)
326
+ : flow.value.modules;
327
+ const modules = applyCodePiecesToFlowModules(codePieces, optimizedModules);
328
+ let preprocessorModule = flow.value.preprocessor_module;
329
+ if (preprocessorModule?.value?.type === 'rawscript' &&
330
+ preprocessorModule.value.content &&
331
+ inlineScriptSession) {
332
+ inlineScriptSession.set(preprocessorModule.id, preprocessorModule.value.content);
333
+ preprocessorModule = {
334
+ ...preprocessorModule,
335
+ value: {
336
+ ...preprocessorModule.value,
337
+ content: `inline_script.${preprocessorModule.id}`
338
+ }
339
+ };
340
+ }
341
+ let failureModule = flow.value.failure_module;
342
+ if (failureModule?.value?.type === 'rawscript' &&
343
+ failureModule.value.content &&
344
+ inlineScriptSession) {
345
+ inlineScriptSession.set(failureModule.id, failureModule.value.content);
346
+ failureModule = {
347
+ ...failureModule,
348
+ value: {
349
+ ...failureModule.value,
350
+ content: `inline_script.${failureModule.id}`
351
+ }
352
+ };
353
+ }
354
+ return {
355
+ modules,
356
+ schema: flow.schema ?? null,
357
+ preprocessor_module: preprocessorModule ?? null,
358
+ failure_module: failureModule ?? null,
359
+ groups: flow.value.groups ?? null
360
+ };
361
+ }
184
362
  const langSchema = z.enum(SUPPORTED_CHAT_SCRIPT_LANGUAGES);
185
363
  const resourceTypeToolSchema = z.object({
186
364
  query: z.string().describe('The query to search for, e.g. stripe, google, etc..'),
@@ -191,12 +369,87 @@ const getInstructionsForCodeGenerationToolSchema = z.object({
191
369
  language: langSchema.describe('The programming language the code will be written in')
192
370
  });
193
371
  const getInstructionsForCodeGenerationToolDef = createToolDef(getInstructionsForCodeGenerationToolSchema, 'get_instructions_for_code_generation', 'Get instructions for code generation for a raw script step');
372
+ const specialModuleToolArgSchema = z
373
+ .string()
374
+ .nullable()
375
+ .describe('JSON string containing the special module object. Use null to remove the special module.');
194
376
  // Using string for modules and schema because Gemini-2.5-flash performs better with strings (MALFORMED_FUNCTION_CALL errors happens more often with objects)
195
377
  const setFlowJsonToolSchema = z.object({
196
378
  modules: z.string().optional().nullable().describe('JSON string containing the flow modules'),
197
- schema: z.string().optional().nullable().describe('JSON string containing the flow input schema')
379
+ schema: z.string().optional().nullable().describe('JSON string containing the flow input schema'),
380
+ preprocessor_module: z
381
+ .string()
382
+ .optional()
383
+ .nullable()
384
+ .describe('JSON string containing the optional preprocessor module'),
385
+ failure_module: z
386
+ .string()
387
+ .optional()
388
+ .nullable()
389
+ .describe('JSON string containing the optional failure module'),
390
+ groups: z
391
+ .string()
392
+ .optional()
393
+ .nullable()
394
+ .describe('JSON string containing the optional array of semantic flow groups (summary, note, autocollapse, start_id, end_id, color). Pass null to clear groups.')
395
+ });
396
+ const setFlowJsonToolDef = createToolDef(setFlowJsonToolSchema, 'set_flow_json', 'Set the complete flow modules array and optionally the flow input schema, preprocessor module, failure module, and semantic groups.', { strict: false });
397
+ const setPreprocessorModuleToolSchema = z.object({
398
+ module: specialModuleToolArgSchema
198
399
  });
199
- const setFlowJsonToolDef = createToolDef(setFlowJsonToolSchema, 'set_flow_json', 'Set the entire flow by providing the complete flow object. This replaces all existing modules and schema.', { strict: false });
400
+ const setPreprocessorModuleToolDef = createToolDef(setPreprocessorModuleToolSchema, 'set_preprocessor_module', 'Set or replace the flow preprocessor module. Use this when the flow needs logic that runs before the main modules.');
401
+ const setFailureModuleToolSchema = z.object({
402
+ module: specialModuleToolArgSchema
403
+ });
404
+ const setFailureModuleToolDef = createToolDef(setFailureModuleToolSchema, 'set_failure_module', 'Set or replace the flow failure module. Use this when the flow needs a dedicated error handler.');
405
+ const specialFlowModuleFields = {
406
+ preprocessor_module: SPECIAL_MODULE_IDS.PREPROCESSOR,
407
+ failure_module: SPECIAL_MODULE_IDS.FAILURE
408
+ };
409
+ function parseOptionalJsonArg(value, field) {
410
+ if (value === undefined || value === null) {
411
+ return value;
412
+ }
413
+ try {
414
+ return typeof value === 'string' ? JSON.parse(value) : value;
415
+ }
416
+ catch (e) {
417
+ const errorMessage = e instanceof Error ? e.message : String(e);
418
+ throw new Error(`Invalid JSON for ${field}: ${errorMessage}`);
419
+ }
420
+ }
421
+ function validateSpecialFlowModule(module, field) {
422
+ if (module === undefined || module === null) {
423
+ return module;
424
+ }
425
+ const result = flowModuleSchema.safeParse(module);
426
+ if (!result.success) {
427
+ const errors = result.error.issues.slice(0, 5).map((issue) => {
428
+ const path = issue.path.length > 0 ? issue.path.join('.') : field;
429
+ return `${path}: ${issue.message}`;
430
+ });
431
+ throw new Error(`Invalid ${field}:\n${errors.join('\n')}`);
432
+ }
433
+ const parsedModule = result.data;
434
+ const expectedId = specialFlowModuleFields[field];
435
+ if (parsedModule.id !== expectedId) {
436
+ throw new Error(`Invalid ${field}: id must be "${expectedId}"`);
437
+ }
438
+ if (parsedModule.value.type !== 'rawscript' && parsedModule.value.type !== 'script') {
439
+ throw new Error(`Invalid ${field}: only "rawscript" and "script" modules are supported`);
440
+ }
441
+ return parsedModule;
442
+ }
443
+ const patchFlowJsonSchema = z.object({
444
+ old_string: z.string().min(1).describe('Exact text to find in the current compact flow JSON'),
445
+ new_string: z.string().describe('Replacement JSON text'),
446
+ replace_all: z
447
+ .boolean()
448
+ .optional()
449
+ .default(false)
450
+ .describe('When true, replace every exact match. When false, the search text must match exactly once.')
451
+ });
452
+ const patchFlowJsonToolDef = createToolDef(patchFlowJsonSchema, 'patch_flow_json', 'Make a quick exact text edit in the current compact flow JSON. Prefer this for small localized changes; use set_flow_json for larger structural rewrites.');
200
453
  // Will be overridden by setSchema
201
454
  const testRunFlowSchema = z.object({
202
455
  args: z
@@ -233,6 +486,7 @@ export const flowTools = [
233
486
  createDbSchemaTool(),
234
487
  createSearchWorkspaceTool(),
235
488
  createGetRunnableDetailsTool(),
489
+ ...createWorkspaceMutationTools(),
236
490
  {
237
491
  def: resourceTypeToolDef,
238
492
  fn: async ({ args, toolId, workspace, toolCallbacks }) => {
@@ -312,15 +566,14 @@ export const flowTools = [
312
566
  }
313
567
  const stepId = args.stepId;
314
568
  const stepArgs = args.args || {};
315
- // Find the step in the flow
316
- const modules = helpers.getModules();
317
- let targetModule = findModuleById(modules, stepId);
569
+ // Find the step in the flow (includes preprocessor/failure modules)
570
+ let targetModule = findModuleInFlow(flow.value, stepId) ?? undefined;
318
571
  if (!targetModule) {
319
572
  toolCallbacks.setToolStatus(toolId, {
320
573
  content: `Step '${stepId}' not found in flow`,
321
574
  error: `Step with id '${stepId}' does not exist in the current flow`
322
575
  });
323
- throw new Error(`Step with id '${stepId}' not found in flow. Available steps: ${modules.map((m) => m.id).join(', ')}`);
576
+ throw new Error(`Step with id '${stepId}' not found in flow. Available steps: ${(flow.value.modules ?? []).map((m) => m.id).join(', ')}`);
324
577
  }
325
578
  const module = targetModule;
326
579
  const moduleValue = module.value;
@@ -402,13 +655,13 @@ export const flowTools = [
402
655
  },
403
656
  {
404
657
  def: inspectInlineScriptToolDef,
405
- fn: async ({ args, toolCallbacks, toolId }) => {
658
+ fn: async ({ args, helpers, toolCallbacks, toolId }) => {
406
659
  const parsedArgs = inspectInlineScriptSchema.parse(args);
407
660
  const moduleId = parsedArgs.moduleId;
408
661
  toolCallbacks.setToolStatus(toolId, {
409
662
  content: `Retrieving inline script content for module '${moduleId}'...`
410
663
  });
411
- const content = inlineScriptStore.get(moduleId);
664
+ const content = helpers.inlineScriptSession.get(moduleId);
412
665
  if (content === undefined) {
413
666
  toolCallbacks.setToolStatus(toolId, {
414
667
  content: `Module '${moduleId}' not found in inline script store`,
@@ -435,8 +688,6 @@ export const flowTools = [
435
688
  const parsedArgs = setModuleCodeSchema.parse(args);
436
689
  const { moduleId, code } = parsedArgs;
437
690
  toolCallbacks.setToolStatus(toolId, { content: `Setting code for module '${moduleId}'...` });
438
- // Update store to keep it coherent (for subsequent set_flow_json calls with references)
439
- inlineScriptStore.set(moduleId, code);
440
691
  // Update the flow directly via helper
441
692
  await helpers.setCode(moduleId, code);
442
693
  toolCallbacks.setToolStatus(toolId, {
@@ -446,78 +697,197 @@ export const flowTools = [
446
697
  return `Code for module '${moduleId}' has been updated successfully.`;
447
698
  }
448
699
  },
700
+ {
701
+ def: patchFlowJsonToolDef,
702
+ streamArguments: true,
703
+ showDetails: true,
704
+ showFade: true,
705
+ fn: async ({ args, helpers, toolId, toolCallbacks }) => {
706
+ const parsedArgs = patchFlowJsonSchema.parse(args);
707
+ const { old_string: oldString, new_string: newString, replace_all: replaceAll } = parsedArgs;
708
+ const { flow, selectedId } = helpers.getFlowAndSelectedId();
709
+ // Snapshot the current flow with a fresh session so the compact JSON matches what the model saw,
710
+ // then copy extracted inline scripts back into the helper session before applying the patch.
711
+ const inlineScriptSession = createInlineScriptSession();
712
+ const currentFlowJson = JSON.stringify(buildEditableFlowJson(flow, inlineScriptSession));
713
+ const matchCount = countExactMatches(currentFlowJson, oldString);
714
+ if (matchCount === 0) {
715
+ throw new Error('old_string was not found in the current flow JSON.');
716
+ }
717
+ if (!replaceAll && matchCount !== 1) {
718
+ throw new Error(`old_string matched ${matchCount} locations. Make it more specific or set replace_all to true.`);
719
+ }
720
+ toolCallbacks.setToolStatus(toolId, {
721
+ content: 'Applying JSON patch...'
722
+ });
723
+ const updatedFlowJson = replaceAll
724
+ ? currentFlowJson.split(oldString).join(newString)
725
+ : replaceFirstExactMatch(currentFlowJson, oldString, newString);
726
+ let parsedFlow;
727
+ try {
728
+ parsedFlow = validateEditableFlowJson(JSON.parse(updatedFlowJson));
729
+ }
730
+ catch (error) {
731
+ const message = error instanceof Error ? error.message : String(error);
732
+ throw new Error(`Invalid JSON after replacement: ${message}`);
733
+ }
734
+ for (const [moduleId, content] of Object.entries(inlineScriptSession.getAll())) {
735
+ helpers.inlineScriptSession.set(moduleId, content);
736
+ }
737
+ const updateResult = await helpers.setFlowJson({
738
+ modules: parsedFlow.modules,
739
+ schema: parsedFlow.schema,
740
+ preprocessorModule: parsedFlow.preprocessor_module,
741
+ failureModule: parsedFlow.failure_module,
742
+ groups: parsedFlow.groups
743
+ });
744
+ const warning = formatEmptyInlineScriptWarning(updateResult);
745
+ const selectedModule = findModuleInFlow(parsedFlow, selectedId) ?? undefined;
746
+ if (selectedModule &&
747
+ 'input_transforms' in selectedModule.value &&
748
+ selectedModule.value.input_transforms) {
749
+ helpers.updateExprsToSet(selectedId, selectedModule.value.input_transforms);
750
+ }
751
+ toolCallbacks.setToolStatus(toolId, {
752
+ content: `Updated flow JSON`,
753
+ result: 'Success'
754
+ });
755
+ return `Flow JSON updated.${warning}`;
756
+ }
757
+ },
758
+ {
759
+ def: setPreprocessorModuleToolDef,
760
+ streamArguments: true,
761
+ showDetails: true,
762
+ showFade: true,
763
+ fn: async ({ args, helpers, toolId, toolCallbacks }) => {
764
+ const parsedArgs = setPreprocessorModuleToolSchema.parse(args);
765
+ const parsedModule = validateSpecialFlowModule(parseOptionalJsonArg(parsedArgs.module, 'module'), 'preprocessor_module');
766
+ toolCallbacks.setToolStatus(toolId, {
767
+ content: parsedModule === null
768
+ ? 'Removing preprocessor module...'
769
+ : 'Setting preprocessor module...'
770
+ });
771
+ const updateResult = await helpers.setFlowJson({ preprocessorModule: parsedModule });
772
+ const warning = formatEmptyInlineScriptWarning(updateResult);
773
+ if (parsedModule &&
774
+ helpers.getFlowAndSelectedId().selectedId === SPECIAL_MODULE_IDS.PREPROCESSOR &&
775
+ 'input_transforms' in parsedModule.value &&
776
+ parsedModule.value.input_transforms) {
777
+ helpers.updateExprsToSet(parsedModule.id, parsedModule.value.input_transforms);
778
+ }
779
+ toolCallbacks.setToolStatus(toolId, {
780
+ content: parsedModule === null ? 'Preprocessor module removed' : 'Preprocessor module updated',
781
+ result: 'Success'
782
+ });
783
+ return parsedModule === null
784
+ ? 'Preprocessor module removed'
785
+ : `Preprocessor module updated successfully.${warning}`;
786
+ }
787
+ },
788
+ {
789
+ def: setFailureModuleToolDef,
790
+ streamArguments: true,
791
+ showDetails: true,
792
+ showFade: true,
793
+ fn: async ({ args, helpers, toolId, toolCallbacks }) => {
794
+ const parsedArgs = setFailureModuleToolSchema.parse(args);
795
+ const parsedModule = validateSpecialFlowModule(parseOptionalJsonArg(parsedArgs.module, 'module'), 'failure_module');
796
+ toolCallbacks.setToolStatus(toolId, {
797
+ content: parsedModule === null ? 'Removing failure module...' : 'Setting failure module...'
798
+ });
799
+ const updateResult = await helpers.setFlowJson({ failureModule: parsedModule });
800
+ const warning = formatEmptyInlineScriptWarning(updateResult);
801
+ if (parsedModule &&
802
+ helpers.getFlowAndSelectedId().selectedId === SPECIAL_MODULE_IDS.FAILURE &&
803
+ 'input_transforms' in parsedModule.value &&
804
+ parsedModule.value.input_transforms) {
805
+ helpers.updateExprsToSet(parsedModule.id, parsedModule.value.input_transforms);
806
+ }
807
+ toolCallbacks.setToolStatus(toolId, {
808
+ content: parsedModule === null ? 'Failure module removed' : 'Failure module updated',
809
+ result: 'Success'
810
+ });
811
+ return parsedModule === null
812
+ ? 'Failure module removed'
813
+ : `Failure module updated successfully.${warning}`;
814
+ }
815
+ },
449
816
  {
450
817
  def: setFlowJsonToolDef,
451
818
  streamArguments: true,
452
819
  showDetails: true,
453
820
  showFade: true,
454
821
  fn: async ({ args, helpers, toolId, toolCallbacks }) => {
455
- const { modules, schema } = args;
822
+ const { modules, schema, preprocessor_module, failure_module, groups } = args;
456
823
  let parsedModules;
457
824
  let parsedSchema;
825
+ let parsedPreprocessorModule;
826
+ let parsedFailureModule;
827
+ let parsedGroups;
458
828
  // Parse JSON strings
459
- try {
460
- parsedModules = modules
461
- ? typeof modules === 'string'
462
- ? JSON.parse(modules)
463
- : modules
464
- : undefined;
465
- parsedSchema = schema
466
- ? typeof schema === 'string'
467
- ? JSON.parse(schema)
468
- : schema
469
- : undefined;
470
- }
471
- catch (e) {
472
- const errorMessage = e instanceof Error ? e.message : String(e);
473
- throw new Error(`Invalid JSON: ${errorMessage}`);
474
- }
475
- // Validate modules against OpenFlow schema
476
- if (parsedModules) {
477
- const result = flowModulesSchema.safeParse(parsedModules);
478
- if (!result.success) {
479
- const errors = result.error.issues.slice(0, 5).map((e) => {
480
- const path = e.path;
481
- // Try to find module id for better context
482
- const moduleIndex = typeof path[0] === 'number' ? path[0] : undefined;
483
- const moduleId = moduleIndex !== undefined ? parsedModules[moduleIndex]?.id : undefined;
484
- const fieldPath = path.slice(1).join('.');
485
- let message = e.message;
486
- if (e.code === 'invalid_type') {
487
- // Zod 4 message already contains "expected X, received Y"
488
- // Try to extract expected format from schema, passing actual data
489
- // to help resolve discriminated unions correctly
490
- const targetSchema = getSchemaAtPath(flowModulesSchema, path, parsedModules);
491
- if (targetSchema) {
492
- const expectedFormat = getExpectedFormat(targetSchema);
493
- if (expectedFormat) {
494
- message += `\n Expected format: ${expectedFormat}`;
495
- }
496
- }
497
- }
498
- if (moduleId) {
499
- return `Module "${moduleId}" -> ${fieldPath}: ${message}`;
500
- }
501
- return `${path.join('.')}: ${message}`;
502
- });
503
- throw new Error(`Invalid flow modules:\n${errors.join('\n')}`);
504
- }
505
- else {
506
- // check for duplicate ids
507
- const ids = collectAllModuleIdsFromArray(parsedModules);
508
- if (ids.length !== new Set(ids).size) {
509
- throw new Error('Duplicate module IDs found in flow');
510
- }
829
+ parsedModules = parseOptionalJsonArg(modules, 'modules');
830
+ parsedSchema = parseOptionalJsonArg(schema, 'schema');
831
+ parsedPreprocessorModule = parseOptionalJsonArg(preprocessor_module, 'preprocessor_module');
832
+ parsedFailureModule = parseOptionalJsonArg(failure_module, 'failure_module');
833
+ parsedGroups = parseOptionalJsonArg(groups, 'groups');
834
+ if (parsedModules === null) {
835
+ parsedModules = undefined;
836
+ }
837
+ if (parsedSchema === null) {
838
+ parsedSchema = undefined;
839
+ }
840
+ if (parsedModules !== undefined) {
841
+ parsedModules = validateFlowModules(parsedModules);
842
+ const reservedIds = collectAllFlowModuleIdsFromModules(parsedModules).filter((id) => id === SPECIAL_MODULE_IDS.PREPROCESSOR || id === SPECIAL_MODULE_IDS.FAILURE);
843
+ if (reservedIds.length > 0) {
844
+ throw new Error('Special modules must be provided via preprocessor_module and failure_module, not inside modules');
511
845
  }
512
846
  }
847
+ if (parsedSchema !== undefined) {
848
+ parsedSchema = validateFlowSchema(parsedSchema);
849
+ }
850
+ parsedPreprocessorModule = validateSpecialFlowModule(parsedPreprocessorModule, 'preprocessor_module');
851
+ parsedFailureModule = validateSpecialFlowModule(parsedFailureModule, 'failure_module');
852
+ if (parsedGroups !== undefined) {
853
+ const effectiveModules = parsedModules ?? helpers.getFlowAndSelectedId().flow.value.modules ?? [];
854
+ const moduleIdsForGroups = new Set(collectAllFlowModuleIdsFromModules(effectiveModules));
855
+ parsedGroups = validateFlowGroups(parsedGroups, moduleIdsForGroups);
856
+ }
857
+ const ids = [
858
+ ...(parsedModules ? collectAllFlowModuleIdsFromModules(parsedModules) : []),
859
+ ...[parsedPreprocessorModule, parsedFailureModule]
860
+ .filter((module) => module !== undefined && module !== null)
861
+ .map((module) => module.id)
862
+ ];
863
+ if (ids.length !== new Set(ids).size) {
864
+ throw new Error('Duplicate module IDs found in flow');
865
+ }
513
866
  toolCallbacks.setToolStatus(toolId, {
514
867
  content: `Setting flow...`
515
868
  });
516
- await helpers.setFlowJson(parsedModules, parsedSchema);
869
+ const updateResult = await helpers.setFlowJson({
870
+ ...(parsedModules !== undefined ? { modules: parsedModules } : {}),
871
+ ...(parsedSchema !== undefined ? { schema: parsedSchema } : {}),
872
+ ...(parsedPreprocessorModule !== undefined
873
+ ? { preprocessorModule: parsedPreprocessorModule }
874
+ : {}),
875
+ ...(parsedFailureModule !== undefined ? { failureModule: parsedFailureModule } : {}),
876
+ ...(parsedGroups !== undefined ? { groups: parsedGroups } : {})
877
+ });
878
+ const warning = formatEmptyInlineScriptWarning(updateResult);
517
879
  // Update exprsToSet if the selected module has input_transforms
518
- if (parsedModules) {
880
+ if (parsedModules !== undefined ||
881
+ parsedPreprocessorModule !== undefined ||
882
+ parsedFailureModule !== undefined) {
519
883
  const { selectedId } = helpers.getFlowAndSelectedId();
520
- const selectedModule = findModuleById(parsedModules, selectedId);
884
+ const selectedModule = selectedId === SPECIAL_MODULE_IDS.PREPROCESSOR
885
+ ? (parsedPreprocessorModule ?? undefined)
886
+ : selectedId === SPECIAL_MODULE_IDS.FAILURE
887
+ ? (parsedFailureModule ?? undefined)
888
+ : parsedModules
889
+ ? findModuleInModules(parsedModules, selectedId)
890
+ : undefined;
521
891
  if (selectedModule &&
522
892
  'input_transforms' in selectedModule.value &&
523
893
  selectedModule.value.input_transforms) {
@@ -528,7 +898,7 @@ export const flowTools = [
528
898
  content: `Flow updated`,
529
899
  result: 'Success'
530
900
  });
531
- return `Flow updated`;
901
+ return `Flow updated.${warning}`;
532
902
  }
533
903
  },
534
904
  {
@@ -558,7 +928,10 @@ export function prepareFlowSystemMessage(customPrompt) {
558
928
  ## Tool Selection Guide
559
929
 
560
930
  **Flow Modification:**
561
- - **Create or modify the entire flow** → \`set_flow_json\` (provide complete modules array and optional schema)
931
+ - **Quick exact edits to current flow JSON** → \`patch_flow_json\` (provide \`old_string\` and \`new_string\`; default is one exact match)
932
+ - **Update only the preprocessor** → \`set_preprocessor_module\`
933
+ - **Update only the failure handler** → \`set_failure_module\`
934
+ - **Create or replace the full flow** → \`set_flow_json\`
562
935
 
563
936
  **Code & Scripts:**
564
937
  - **View existing inline script code** → \`inspect_inline_script\`
@@ -579,14 +952,43 @@ export function prepareFlowSystemMessage(customPrompt) {
579
952
  **Resources & Schema:**
580
953
  - **Search resource types** → \`resource_type\`
581
954
  - **Get database schema** → \`get_db_schema\`
955
+ - **Create a schedule for the current flow** → \`create_schedule\`
956
+ - **Create a trigger for the current flow** → \`create_trigger\`
957
+
958
+ ## Quick Edits with patch_flow_json
959
+
960
+ Use \`patch_flow_json\` for small, localized changes when you can target an exact snippet from the \`CURRENT FLOW JSON COMPACT\` block below.
961
+
962
+ Always copy the exact search text from the \`CURRENT FLOW JSON COMPACT\` block below.
963
+ The compact JSON is a single object with \`modules\`, \`schema\`, \`preprocessor_module\`, \`failure_module\`, and \`groups\` keys.
964
+
965
+ **Parameters:**
966
+ - \`old_string\`: Exact JSON text to find
967
+ - \`new_string\`: Replacement JSON text
968
+ - \`replace_all\`: Optional boolean. Leave false unless you intentionally want to replace every exact match.
969
+
970
+ **Example - Rename a referenced result:**
971
+ \`\`\`javascript
972
+ patch_flow_json({
973
+ old_string: "\"expr\":\"results.fetch_data\"",
974
+ new_string: "\"expr\":\"results.load_data\""
975
+ })
976
+ \`\`\`
977
+
978
+ Use \`set_flow_json\` instead when you need to do a larger rewrite, add many new modules, or change the flow schema.
979
+
980
+ ${FLOW_CHAT_SPECIAL_MODULES}
582
981
 
583
982
  ## Flow Modification with set_flow_json
584
983
 
585
- Use the \`set_flow_json\` tool to set the entire flow structure at once. Provide the complete modules array and optionally the flow input schema.
984
+ Use the \`set_flow_json\` tool to set the entire flow structure at once. Provide the complete modules array and optionally the flow input schema, \`preprocessor_module\`, \`failure_module\`, and \`groups\`.
586
985
 
587
986
  **Parameters:**
588
987
  - \`modules\`: Array of flow modules (required)
589
988
  - \`schema\`: Flow input schema in JSON Schema format (optional)
989
+ - \`preprocessor_module\`: Special module that runs before \`modules\` (optional, separate from \`modules\`)
990
+ - \`failure_module\`: Special module that runs on failure (optional, separate from \`modules\`)
991
+ - \`groups\`: Array of semantic groups for organizing modules in the editor (optional). Each group has \`summary\` (display name), \`note\` (markdown description shown below the group header — attached directly to the group, not a separate sticky note), \`autocollapse\`, \`start_id\`, \`end_id\`, and \`color\`. \`start_id\` and \`end_id\` must reference existing module IDs in the flow (not \`preprocessor\` or \`failure\`). Groups do not affect execution — they provide naming and collapsibility in the editor. Pass \`null\` to clear existing groups.
590
992
 
591
993
  **Example - Simple flow:**
592
994
  \`\`\`javascript
@@ -763,6 +1165,10 @@ To reduce token usage, rawscript content in the flow you receive is replaced wit
763
1165
  **To inspect existing code:**
764
1166
  - Use \`inspect_inline_script\` tool to view the current code: \`inspect_inline_script({ moduleId: "step_a" })\`
765
1167
 
1168
+ **If a flow update tool warns that inline scripts are empty:**
1169
+ - The module structure was created successfully, but the code is still empty
1170
+ - Immediately call \`set_module_code\` for each warned module ID
1171
+
766
1172
  ### Writing Code for Modules
767
1173
 
768
1174
  **IMPORTANT: Before writing any code for a rawscript module, you MUST call the \`get_instructions_for_code_generation\` tool with the target language.** This tool provides essential language-specific instructions.
@@ -771,14 +1177,15 @@ Example: Before writing TypeScript/Bun code, call \`get_instructions_for_code_ge
771
1177
 
772
1178
  ### Creating Flows
773
1179
 
774
- 1. **Search for existing scripts first** (unless user explicitly asks to write from scratch):
775
- - First: \`search_workspace\` to find workspace scripts and flows
776
- - Use \`get_runnable_details\` to inspect a specific script or flow (inputs, description, code)
1180
+ 1. **Search for existing scripts and flows first** (unless user explicitly asks to write from scratch):
1181
+ - First: \`search_workspace\` to find workspace scripts **and flows**. Existing flows can be reused as subflow steps — prefer this over rebuilding equivalent logic inline.
1182
+ - Use \`get_runnable_details\` to inspect a specific script or flow (inputs, description, code) so you know how to wire its \`input_transforms\`
777
1183
  - Then: \`search_hub_scripts\` (only consider highly relevant results)
778
- - Only create raw scripts if no suitable script is found
1184
+ - Only create raw scripts if no suitable script or flow is found
779
1185
 
780
1186
  2. **Build the complete flow using \`set_flow_json\`:**
781
- - If using existing script: use \`type: "script"\` with \`path\`
1187
+ - If using an existing script: use \`type: "script"\` with \`path\`
1188
+ - If using an existing flow as a subflow step: use \`type: "flow"\` with \`path\` (e.g. \`{ type: "flow", path: "f/flows/process_user", input_transforms: { ... } }\`). The step's \`input_transforms\` must cover the subflow's inputs.
782
1189
  - If creating rawscript: use \`type: "rawscript"\` with \`language\` and \`content\`
783
1190
  - **First call \`get_instructions_for_code_generation\` to get the correct code format**
784
1191
  - Always define \`input_transforms\` to connect parameters to flow inputs or previous step results
@@ -839,7 +1246,7 @@ You have access to the following contexts:
839
1246
  content
840
1247
  };
841
1248
  }
842
- export function prepareFlowUserMessage(instructions, flowAndSelectedId, selectedContext = []) {
1249
+ export function prepareFlowUserMessage(instructions, flowAndSelectedId, selectedContext = [], inlineScriptSession) {
843
1250
  const flow = flowAndSelectedId?.flow;
844
1251
  const selectedId = flowAndSelectedId?.selectedId;
845
1252
  // Handle context elements
@@ -852,43 +1259,14 @@ ${instructions}`;
852
1259
  content: userMessage
853
1260
  };
854
1261
  }
855
- const codePieces = selectedContext.filter((c) => c.type === 'flow_module_code_piece');
1262
+ const scriptSession = inlineScriptSession;
856
1263
  // Clear the inline script store and extract inline scripts for token optimization
857
- inlineScriptStore.clear();
858
- const optimizedModules = extractAndReplaceInlineScripts(flow.value.modules);
859
- // Apply code pieces to the optimized modules (returns YAML string)
860
- const flowModulesYaml = applyCodePiecesToFlowModules(codePieces, optimizedModules);
861
- // Handle preprocessor and failure modules
862
- let optimizedPreprocessor = flow.value.preprocessor_module;
863
- if (optimizedPreprocessor?.value?.type === 'rawscript' && optimizedPreprocessor.value.content) {
864
- inlineScriptStore.set(optimizedPreprocessor.id, optimizedPreprocessor.value.content);
865
- optimizedPreprocessor = {
866
- ...optimizedPreprocessor,
867
- value: {
868
- ...optimizedPreprocessor.value,
869
- content: `inline_script.${optimizedPreprocessor.id}`
870
- }
871
- };
872
- }
873
- let optimizedFailure = flow.value.failure_module;
874
- if (optimizedFailure?.value?.type === 'rawscript' && optimizedFailure.value.content) {
875
- inlineScriptStore.set(optimizedFailure.id, optimizedFailure.value.content);
876
- optimizedFailure = {
877
- ...optimizedFailure,
878
- value: {
879
- ...optimizedFailure.value,
880
- content: `inline_script.${optimizedFailure.id}`
881
- }
882
- };
883
- }
884
- const finalFlow = {
885
- schema: flow.schema,
886
- modules: flowModulesYaml,
887
- preprocessor_module: optimizedPreprocessor,
888
- failure_module: optimizedFailure
889
- };
890
- let flowContent = `## CURRENT FLOW JSON:
891
- ${JSON.stringify(finalFlow, null, 2)}
1264
+ scriptSession?.clear();
1265
+ const editableFlowJson = buildEditableFlowJson(flow, scriptSession, selectedContext);
1266
+ let flowContent = `## CURRENT FLOW JSON COMPACT:
1267
+ \`\`\`json
1268
+ ${JSON.stringify(editableFlowJson)}
1269
+ \`\`\`
892
1270
 
893
1271
  currently selected step:
894
1272
  ${selectedId}`;