@fluidgrids/fe-sdk 0.0.0-stage → 2026.1203.8

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 (323) hide show
  1. package/README.md +564 -2
  2. package/dist/ActivityOptionsFields-C2u-hY2U.js +142 -0
  3. package/dist/AiStudioPage-B_hNTj-_.js +1137 -0
  4. package/dist/ApprovalInboxPage-ClITra3n.js +1312 -0
  5. package/dist/ChoiceSelect-LkK-uS9J.js +65 -0
  6. package/dist/ConfirmActionDialog-DHWTDRbp.js +31 -0
  7. package/dist/ConnectionFormDialog-C0kDgcrZ.js +153 -0
  8. package/dist/CreateFluidgridsTagDocument-Dtp9KPLJ.js +1055 -0
  9. package/dist/DataSinkDashboardPage-b4ezeqa6.js +278 -0
  10. package/dist/DataTablesPage-C1d9YGHz.js +5575 -0
  11. package/dist/DateTimeField-B1qR4ruo.js +51 -0
  12. package/dist/Disclosure-BNKij7-v.js +45 -0
  13. package/dist/ElementLibraryPage-8jNO6YmE.js +2256 -0
  14. package/dist/ElementLibrarySequenceDocument-B-W8SPzn.js +3979 -0
  15. package/dist/EnsureThemeProvider-BvlNjAd0.js +24 -0
  16. package/dist/EntityTagBadge-1OlP6p0c.js +25 -0
  17. package/dist/EntityTagPicker-BBrU5cE0.js +137 -0
  18. package/dist/ExecuteStepDocument-B4j1mdRT.js +189 -0
  19. package/dist/ExecutionDetailDocument-D6QuM-kp.js +875 -0
  20. package/dist/ExecutionDetailPage-D4CBtFdo.js +12217 -0
  21. package/dist/ExecutionDetailPage-DvQ667OE.d.ts +10 -0
  22. package/dist/ExecutionStatusBadge-BsDVor9t.js +221 -0
  23. package/dist/ExecutionsListDocument-Dan7ZiqB.js +459 -0
  24. package/dist/ExecutionsListPage-B3XT8ITL.js +4307 -0
  25. package/dist/FailureTriagePanel-DOJMaJ0n.js +1285 -0
  26. package/dist/FileDownloadUrlDocument-CVOYKcL5.js +92 -0
  27. package/dist/FluidGridsDocsLink-bX0Hnhxr.js +66 -0
  28. package/dist/FluidGridsMark-CE2blT7K.js +74 -0
  29. package/dist/HeldLoadRegion-BtTxbvOW.js +34 -0
  30. package/dist/HistoryPage-BLoRpJ1R.d.ts +6 -0
  31. package/dist/HistoryPage-BSBISXoj.js +2835 -0
  32. package/dist/Icon-BtQ0HXLh.js +160 -0
  33. package/dist/InsightsPage-D7ybj8N9.js +11245 -0
  34. package/dist/IsolationSetting-vy911E8b.js +1153 -0
  35. package/dist/LibraryParts-DOeNgR8A.js +413 -0
  36. package/dist/ManagedAiPolicyAuthority-BxwJ3ptd.js +40 -0
  37. package/dist/ManagedAiPolicyAuthority-DM3t3wNr.d.ts +18 -0
  38. package/dist/ManagedAiPolicyAuthorityContext-CNkxIOZ1.js +10 -0
  39. package/dist/McpTriggerServers-BCPCAOWB.js +459 -0
  40. package/dist/MissingNodesInstallModal-rO_SEDrC.js +224 -0
  41. package/dist/NavigationV2Provider-DCDt35eG.js +17 -0
  42. package/dist/NodeSchemaIntrospectionDocument-C1vAIcHd.js +95 -0
  43. package/dist/NodesPage-DEbnz9iU.d.ts +6 -0
  44. package/dist/NodesPage-O7KeeKtd.js +653 -0
  45. package/dist/OfflineIcon-TwMKYWjA.js +207 -0
  46. package/dist/OpenTemplateAsCodeButton-BhWJWIF3.js +94 -0
  47. package/dist/PaidTemplateConfirm-_G3ag6S4.js +28 -0
  48. package/dist/PublishCustomNodeAction-CIySbK4c.js +134 -0
  49. package/dist/RecordTaskDialog-BkpCDvhR.js +2078 -0
  50. package/dist/RunActionsMenu-DodOgIQm.js +59 -0
  51. package/dist/RunnerStatusPill-C1v967iq.js +24 -0
  52. package/dist/RunnersPage-dB0RSdY_.js +1929 -0
  53. package/dist/SandboxRuntimeExhaustedNotice-BFOIF93C.js +120 -0
  54. package/dist/SchedulesPage-DPWr1yvf.js +1607 -0
  55. package/dist/SearchBox-BGtYjvfs.js +49 -0
  56. package/dist/SequenceEditor-CFiHeHkR.js +497 -0
  57. package/dist/SettingsPage-0CQBNPZV.js +8695 -0
  58. package/dist/StewardPages-DAJhepen.js +47 -0
  59. package/dist/StewardRunImportPanel-Kva2DO0u.js +2844 -0
  60. package/dist/StoreTemplateCardCompact-CHn5kP7A.js +2166 -0
  61. package/dist/TagFilterSelect-CyA8QrS7.js +42 -0
  62. package/dist/TaskQueuesPage-DdnDCyat.js +3571 -0
  63. package/dist/TechnicalDetails-B0Oi4aZw.js +19 -0
  64. package/dist/TemplateConfigurationModal-CdvCYJLM.js +332 -0
  65. package/dist/TemplateDetailPanel-CbiKciuB.js +222 -0
  66. package/dist/TemplatePreview-cx7-NOeG.js +868 -0
  67. package/dist/TemplatesPage-BG3H-6v6.d.ts +10 -0
  68. package/dist/TemplatesPage-BVQpGYIV.js +3251 -0
  69. package/dist/TerminateExecutionDocument-B_HKNVrN.js +581 -0
  70. package/dist/TranslationBridge-Bd4aJKMs.d.ts +11 -0
  71. package/dist/TranslationBridge-Da-TPgQm.js +68 -0
  72. package/dist/TriggerWorkflowDocument-D9Km2Vv2.js +460 -0
  73. package/dist/UiSequencePickerSequenceDocument-BSYnSDV7.js +607 -0
  74. package/dist/UiStepScreenshot-Qh4QMyUp.js +146 -0
  75. package/dist/UsageTimeSeriesDocument-DcInx9-z.js +177 -0
  76. package/dist/VariablesPage-ChfGuW22.js +2243 -0
  77. package/dist/VersionDiffDialog-Bd2AeUwf.js +1702 -0
  78. package/dist/VersionLifecycleBar-BBeWVtz-.js +143 -0
  79. package/dist/WebhookDeliveriesPage-D66bua0j.js +1563 -0
  80. package/dist/WorkflowBuilder-B6wQD1TK.js +539 -0
  81. package/dist/WorkflowBuilder-DR4ku8Tr.js +1611 -0
  82. package/dist/WorkflowDefinitionDocument-DZLbTPUZ.js +321 -0
  83. package/dist/WorkflowEmbed-BXfFGy0i.js +708 -0
  84. package/dist/WorkflowEmbed-Cbqe1s1z.d.ts +6 -0
  85. package/dist/WorkflowPinnedDataDocument-BODT5omd.js +782 -0
  86. package/dist/WorkflowProposalCard-BruukdeF.js +96 -0
  87. package/dist/WorkflowProposalDocument-BdUbsrd0.js +620 -0
  88. package/dist/WorkflowSearchRedirect-C7zJ2MKH.js +40 -0
  89. package/dist/WorkflowSettingsDrawer-MVU1BKfY.d.ts +18 -0
  90. package/dist/WorkflowSettingsDrawer-gazs97WR.js +196 -0
  91. package/dist/WorkflowShareDialog-e8jJtLjU.js +469 -0
  92. package/dist/WorkflowVersionsDocument-DRVOp8Uj.js +3213 -0
  93. package/dist/WorkflowsList--hR2_8gf.js +4593 -0
  94. package/dist/WorkflowsList-CcNDQge5.d.ts +6 -0
  95. package/dist/WorkflowsListPageDocument-CnzcQm_o.js +934 -0
  96. package/dist/addonCatalog-CbZS4deh.js +58 -0
  97. package/dist/addonCatalog-sjlonAmR.d.ts +15 -0
  98. package/dist/addons.d.ts +3 -0
  99. package/dist/addons.js +4 -0
  100. package/dist/agent-form-Bfvm32j1.js +83 -0
  101. package/dist/agent-tools.d.ts +3 -0
  102. package/dist/agent-tools.js +5 -0
  103. package/dist/agentTools-CyL7DLOF.js +320 -0
  104. package/dist/ai-usage-BrxDgvdR.js +240 -0
  105. package/dist/aiCreditsBridge-BuE92tKo.js +49 -0
  106. package/dist/api-BKq-nIOZ.js +2286 -0
  107. package/dist/api-Ol7I8NxE.js +8289 -0
  108. package/dist/apollo-type-policies.d.ts +11 -0
  109. package/dist/apollo-type-policies.js +64 -0
  110. package/dist/askAboutBridge-ByYsQams.js +106 -0
  111. package/dist/askQuestions-Cmx7VnMm.js +742 -0
  112. package/dist/assert-rules-lfYEMc99.js +318 -0
  113. package/dist/assistant.d.ts +94 -0
  114. package/dist/assistant.js +99 -0
  115. package/dist/attach-node-helpers-HDKQOtrD.js +32 -0
  116. package/dist/badge-CXfPhoMH.js +26 -0
  117. package/dist/basil.generated-BK-EHbwN.js +10 -0
  118. package/dist/browser-steps-DMpS5TyB.js +533 -0
  119. package/dist/builderTimings-pvGnK1m-.js +510 -0
  120. package/dist/button-DG7y_FVJ.js +48 -0
  121. package/dist/canvasNoteTools-BxuP_AYO.js +137 -0
  122. package/dist/card-Bomy_1UG.js +44 -0
  123. package/dist/catalogGrid-BOrfMgi-.js +41 -0
  124. package/dist/channel-CPyQ1NR1.js +212 -0
  125. package/dist/chips-CvNrYJZa.js +27 -0
  126. package/dist/client-holder-C0M5Cfwl.js +68 -0
  127. package/dist/cn-QqidFIgr.js +10 -0
  128. package/dist/code-editor-diagnostics-Zr0cIcx1.js +46 -0
  129. package/dist/code-editor-field-x_JrY8KR.js +113 -0
  130. package/dist/codec-client-DPuD6mw7.js +515 -0
  131. package/dist/conditionBuilder-DwfEF0Q-.js +1144 -0
  132. package/dist/config-DO68jw5k.js +322 -0
  133. package/dist/constants-DgbVc24O.d.ts +296 -0
  134. package/dist/constants-DlRnHBfQ.js +217 -0
  135. package/dist/convert-browser-action-pfecelF7.js +347 -0
  136. package/dist/convert-dialog-B_o22NiJ.js +382 -0
  137. package/dist/create-workflow-first-Azg3JUdX.js +120 -0
  138. package/dist/definition-canvas-Bsda-rDT.js +31 -0
  139. package/dist/dialog-BVd152GS.js +94 -0
  140. package/dist/durable-nodes-BXyYCLxT.js +91 -0
  141. package/dist/duration-CDb7-mT_.js +33 -0
  142. package/dist/edge-mapper-wEAdGVU2.js +4477 -0
  143. package/dist/element-library-DkSlg_VE.js +727 -0
  144. package/dist/entities-I_0kio3q.js +38 -0
  145. package/dist/error-advice-QLr5NCm7.js +65 -0
  146. package/dist/errors-ClKb5sEt.js +188 -0
  147. package/dist/executions.d.ts +3 -0
  148. package/dist/executions.js +5 -0
  149. package/dist/feature-flags-B2qetXKd.js +385 -0
  150. package/dist/field-label-DPZRmE_B.js +153 -0
  151. package/dist/firstWorkflow-C_h0KMB2.js +133 -0
  152. package/dist/flags.d.ts +3 -0
  153. package/dist/flags.js +4 -0
  154. package/dist/flow-builder-DIvLOhz0.js +28038 -0
  155. package/dist/flow-store-holder-CUN7Terz.js +52 -0
  156. package/dist/fluent.generated-CA_e6-4l.js +14 -0
  157. package/dist/fluidgridsEvents-bbEQbwU6.js +175 -0
  158. package/dist/fluidgridsTheme-DUhvOgoy.js +297 -0
  159. package/dist/global-client-BQPuFrFa.js +433 -0
  160. package/dist/global-operations-BG6YgxrM.js +136 -0
  161. package/dist/graphql-types-UTYtujY9.js +21358 -0
  162. package/dist/history.d.ts +3 -0
  163. package/dist/history.js +4 -0
  164. package/dist/index-AoJAa5vU.d.ts +164958 -0
  165. package/dist/index-DEMT3iAM.d.ts +120 -0
  166. package/dist/index-ROZzNGyY.d.ts +76 -0
  167. package/dist/index.d.ts +20 -0
  168. package/dist/index.js +8123 -0
  169. package/dist/ion.generated-mbajjcAg.js +10 -0
  170. package/dist/label-Lzb8ZXf_.js +29 -0
  171. package/dist/labels-rXd9gYQz.js +1236 -0
  172. package/dist/liveCanvas-D5ytXDp8.js +103 -0
  173. package/dist/logos.generated-X6_0kjVR.js +21 -0
  174. package/dist/logs-panel-Cw0DkG0l.js +468 -0
  175. package/dist/lucide.generated-B6NVd3GT.js +29 -0
  176. package/dist/marksStore-a9oIMMot.js +175 -0
  177. package/dist/mcp-trigger-D0nRdvq5.js +307 -0
  178. package/dist/mdi.generated-D1BV74d6.js +292 -0
  179. package/dist/menus-CU3hDGYl.js +160 -0
  180. package/dist/mynaui.generated-DMWr5cXz.js +66 -0
  181. package/dist/navigation-v2.d.ts +3 -0
  182. package/dist/navigation-v2.js +5 -0
  183. package/dist/node-detail-view-Cgm5H1P-.js +1372 -0
  184. package/dist/node-editor-tab-body-CZ0fVuVP.js +187 -0
  185. package/dist/node-operation-selection-CdV3KI_V.js +3534 -0
  186. package/dist/node-registry-refresh-s3okf83X.js +27 -0
  187. package/dist/node-role-TMbnkmeP.js +132 -0
  188. package/dist/node-type-icon-BZa8n4iG.js +33 -0
  189. package/dist/nodes.d.ts +3 -0
  190. package/dist/nodes.js +4 -0
  191. package/dist/notesKey-5EaREBGA.js +12 -0
  192. package/dist/observability.d.ts +3 -0
  193. package/dist/observability.js +5 -0
  194. package/dist/offset-pages-zghoClB3.js +55 -0
  195. package/dist/operations-BBmT9ToP.js +663 -0
  196. package/dist/operations-WxRJWeqO.js +3133 -0
  197. package/dist/output-files-Ba8bu5lv.js +196 -0
  198. package/dist/page-operation-DrWuhd6Y.js +129 -0
  199. package/dist/page-twins.d.ts +13 -0
  200. package/dist/page-twins.js +186 -0
  201. package/dist/pageControlSpecs-DZJ9K37m.js +134 -0
  202. package/dist/pageControlsBridge-0pX9s-3k.js +54 -0
  203. package/dist/pageControlsBridge-DAuT3w7L.d.ts +36 -0
  204. package/dist/panels-PfBBAToE.js +346 -0
  205. package/dist/parts-B7fBcw-B.js +346 -0
  206. package/dist/popover-Dms9Vz3j.js +3389 -0
  207. package/dist/preloadable-lazy-Pp47mqQ9.js +65 -0
  208. package/dist/proactive.d.ts +66 -0
  209. package/dist/proactive.js +237 -0
  210. package/dist/quick-config-panel-DFd77xho.js +451 -0
  211. package/dist/quota-DeA_CJ2e.js +175 -0
  212. package/dist/quota.d.ts +3 -0
  213. package/dist/quota.js +4 -0
  214. package/dist/read-only-context-Dt9N9SIG.js +18 -0
  215. package/dist/relative-time-Dxt8ZIIu.js +55 -0
  216. package/dist/results-CwK_yDxK.js +325 -0
  217. package/dist/rolldown-runtime-hDbaFkMy.js +18 -0
  218. package/dist/route-data.d.ts +12 -0
  219. package/dist/route-data.js +69 -0
  220. package/dist/route-match-C-0_EnAt.d.ts +5 -0
  221. package/dist/route-match-DMkUICYV.js +41 -0
  222. package/dist/route-preload-C4DlGoCd.js +120 -0
  223. package/dist/run-display-UjLAoYqQ.js +81 -0
  224. package/dist/run-history-arGiHzGU.js +285 -0
  225. package/dist/run-list-links-DJn4Mf1T.js +98 -0
  226. package/dist/run-mode-USmM0-Uo.js +82 -0
  227. package/dist/run-parity-CWXqEJqM.js +144 -0
  228. package/dist/runsQuota-B6SyTbne.js +100 -0
  229. package/dist/runsQuota-DsniKiSg.d.ts +20 -0
  230. package/dist/safe-expression-Cw7-SCsm.js +1251 -0
  231. package/dist/save-status-store-C7nEYpfb.js +631 -0
  232. package/dist/schedule-panel-B4GYXzXQ.js +13774 -0
  233. package/dist/schedule-rules-ggVKRkBH.js +358 -0
  234. package/dist/secrets-Re_wSiE3.js +153 -0
  235. package/dist/settings.d.ts +4 -0
  236. package/dist/settings.js +6 -0
  237. package/dist/shared-DAWGGMSM.js +177 -0
  238. package/dist/sidebar-node-editor-6eSSgCzc.js +178 -0
  239. package/dist/solar.generated-CGYuUQAC.js +10 -0
  240. package/dist/stableTabbedDialog-BBhrfXGe.js +20 -0
  241. package/dist/start-url-CT6Yz96K.js +24 -0
  242. package/dist/status-CessxGpm.js +55 -0
  243. package/dist/store-icon-OctYp5zP.js +155 -0
  244. package/dist/styles-WGmTnZ2n.js +26 -0
  245. package/dist/styles.css +139 -0
  246. package/dist/svg-spinners.generated-CIPT7IhM.js +10 -0
  247. package/dist/template-code-CzN6JWNV.js +191 -0
  248. package/dist/template-graph-DLF9dygU.js +20 -0
  249. package/dist/template-preview-DcIIKOOL.js +32 -0
  250. package/dist/template-price-CdUHZRMF.js +40 -0
  251. package/dist/templates.d.ts +3 -0
  252. package/dist/templates.js +5 -0
  253. package/dist/theme-provider-CntfC4_i.js +23 -0
  254. package/dist/transient-DgZfhDfN.js +57 -0
  255. package/dist/typed-calls-C5tO03wq.js +26 -0
  256. package/dist/ui-script-By74Guk3.js +1094 -0
  257. package/dist/ui-script-editor-CqPu2bCN.js +2447 -0
  258. package/dist/ui-step-fix-8uM2_Hft.js +67 -0
  259. package/dist/ui-step-fix-store-CcO1FdRx.js +19 -0
  260. package/dist/ui-step-run-context-o7bLE6KP.js +46 -0
  261. package/dist/ui-target-editor-D2JhB_lD.js +673 -0
  262. package/dist/uiMarkTools-CSznnO1i.js +1054 -0
  263. package/dist/upgradePrompt-BAFBKKW5.js +72 -0
  264. package/dist/use-bare-node-registry-O6mKJO_n.js +11498 -0
  265. package/dist/use-browser-available-hj8wc3Kb.js +241 -0
  266. package/dist/use-edge-mapper-schemas-Bonofxow.js +496 -0
  267. package/dist/use-extension-bridge-B9ZreOkQ.js +608 -0
  268. package/dist/use-mobile-BTqCUjzS.js +27 -0
  269. package/dist/use-sdk-query-C697xZVv.js +116 -0
  270. package/dist/use-workflow-code-editor-CFoRFrZ5.js +753 -0
  271. package/dist/useActionParam-B2tU2BlY.js +85 -0
  272. package/dist/useAgentTokenStream-Bko_J0d0.js +4217 -0
  273. package/dist/useBrowserClients-3v95-gSh.js +103 -0
  274. package/dist/useCodeWorkflowInsights-w0tz9Ap_.js +600 -0
  275. package/dist/useConnections-DsgEJs05.js +439 -0
  276. package/dist/useDebouncedValue-BFekcv6n.js +18 -0
  277. package/dist/useDurableParity-8fnMZmBc.js +1787 -0
  278. package/dist/useEntityTags-D0spL6Ut.js +460 -0
  279. package/dist/useExecutions-2u5nGJJk.js +681 -0
  280. package/dist/useFluidGridsAnalytics-VM8lAi2x.js +238 -0
  281. package/dist/useGlobalStoreClient-BTdhkA2I.js +24 -0
  282. package/dist/useHumanRequests-zlYDp3l1.js +221 -0
  283. package/dist/useNavigationV2-C2WeqN7d.js +29 -0
  284. package/dist/useNavigationV2-DANUmg12.d.ts +9 -0
  285. package/dist/useObservability-BRlQ0tOA.js +285 -0
  286. package/dist/useRequestedProposal-B7uPXfZB.js +51 -0
  287. package/dist/useRunHistory-CXCMUPyf.js +2759 -0
  288. package/dist/useRunLive-D0JvVZT2.js +1060 -0
  289. package/dist/useRunnerList-Dbi59i1K.js +446 -0
  290. package/dist/useRunners-URUc5quU.js +173 -0
  291. package/dist/useRunsPage-DG656UCK.js +2709 -0
  292. package/dist/useVariables-BIelxcWr.js +463 -0
  293. package/dist/useVersionHistoryData-CTjqVw7l.js +292 -0
  294. package/dist/useWorkflowCodeExport-pqxyLHD1.js +522 -0
  295. package/dist/useWorkflowListExport-hcZNvTaB.js +232 -0
  296. package/dist/useWorkflowOrganization-CpBbOrs7.js +1772 -0
  297. package/dist/useWorkflowProposal-BH0VdNMA.js +3280 -0
  298. package/dist/useWorkflows-Cvg-Z_IE.js +1606 -0
  299. package/dist/utils-fvBb5qOD.js +89 -0
  300. package/dist/webhook-deliveries-AvQujaZy.js +99 -0
  301. package/dist/workflow-builder-CJygVkVv.d.ts +2 -0
  302. package/dist/workflow-builder.d.ts +3 -0
  303. package/dist/workflow-builder.js +8 -0
  304. package/dist/workflow-code-transfer-Bsy0JKAZ.js +323 -0
  305. package/dist/workflow-embed.d.ts +3 -0
  306. package/dist/workflow-embed.js +4 -0
  307. package/dist/workflow-git-sync--K9ZsPDC.js +263 -0
  308. package/dist/workflow-host.d.ts +6 -0
  309. package/dist/workflow-host.js +11 -0
  310. package/dist/workflow-pages-D-7ByLTB.d.ts +68 -0
  311. package/dist/workflow-pages.d.ts +3 -0
  312. package/dist/workflow-pages.js +115 -0
  313. package/dist/workflow-preview-canvas-CO8yzdE3.js +848 -0
  314. package/dist/workflow-preview.d.ts +65 -0
  315. package/dist/workflow-preview.js +4 -0
  316. package/dist/workflow-route.d.ts +33 -0
  317. package/dist/workflow-route.js +4 -0
  318. package/dist/workflow-save-state-D0l-DkLf.js +767 -0
  319. package/dist/workflow-transfer-CQnQC-ke.js +104 -0
  320. package/dist/workflowRouteData-BkfVOc-O.js +169 -0
  321. package/dist/workflows-list.d.ts +10 -0
  322. package/dist/workflows-list.js +5 -0
  323. package/package.json +320 -4
@@ -0,0 +1,2844 @@
1
+ "use client";
2
+ import { r as getFluidGridsConfig } from "./config-DO68jw5k.js";
3
+ import { s as throwIfResultError, t as describeOperationError } from "./errors-ClKb5sEt.js";
4
+ import { n as getFluidGridsClient } from "./client-holder-C0M5Cfwl.js";
5
+ import { r as useTr } from "./TranslationBridge-Da-TPgQm.js";
6
+ import { t as FlowBuilderPage } from "./flow-builder-DIvLOhz0.js";
7
+ import { D as buildOperationSeed, l as ensureNodeTypesLoaded } from "./use-bare-node-registry-O6mKJO_n.js";
8
+ import { i as CreateWorkflowRefusalDialog } from "./useWorkflowCodeExport-pqxyLHD1.js";
9
+ import { r as useCreateWorkflow } from "./useWorkflows-Cvg-Z_IE.js";
10
+ import { n as BILLING_PLANS_PATH } from "./quota-DeA_CJ2e.js";
11
+ import { Ja as BotmanorAgentStatus, Ya as BotmanorAgentType, lo as BotmanorStewardDeskKind, oo as BotmanorStewardAutonomy, vo as BotmanorStewardStatus } from "./graphql-types-UTYtujY9.js";
12
+ import { n as builderPathOf, r as classifyCreateRefusal } from "./create-workflow-first-Azg3JUdX.js";
13
+ import { s as useFluidGridsPermission, t as FLUIDGRIDS_PERMISSIONS } from "./constants-DlRnHBfQ.js";
14
+ import { t as useSdkQuery } from "./use-sdk-query-C697xZVv.js";
15
+ import { i as AI_DRAFT_MAX_PROMPT_LENGTH, o as draftToCanvas, s as enrichDraftNodes } from "./use-browser-available-hj8wc3Kb.js";
16
+ import { t as ThemeProvider } from "./theme-provider-CntfC4_i.js";
17
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
18
+ import { useNavigate } from "react-router";
19
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
20
+ import "@xyflow/react/dist/style.css";
21
+ import { CheckCircle2, Lightbulb, Pencil, ShieldCheck, SkipForward, Sparkles, TriangleAlert } from "lucide-react";
22
+ import { toast } from "sonner";
23
+ import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, Badge, Button, Card, CardContent, CardHeader, EmptyState, Input, Label, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, SpinnerIcon, Textarea } from "@burdenoff/fe-libs/ui";
24
+ import { ErrorBoundary } from "@burdenoff/fe-libs/shared/components";
25
+ import { v4 } from "uuid";
26
+
27
+ // src/generated/documents/wspace/CreateStewardDraftAgentDocument.ts
28
+ const CreateStewardDraftAgentDocument = {
29
+ "kind": "Document",
30
+ "definitions": [{
31
+ "kind": "OperationDefinition",
32
+ "operation": "mutation",
33
+ "name": {
34
+ "kind": "Name",
35
+ "value": "CreateStewardDraftAgent"
36
+ },
37
+ "variableDefinitions": [{
38
+ "kind": "VariableDefinition",
39
+ "variable": {
40
+ "kind": "Variable",
41
+ "name": {
42
+ "kind": "Name",
43
+ "value": "input"
44
+ }
45
+ },
46
+ "type": {
47
+ "kind": "NonNullType",
48
+ "type": {
49
+ "kind": "NamedType",
50
+ "name": {
51
+ "kind": "Name",
52
+ "value": "CreateBotmanorAgentInput"
53
+ }
54
+ }
55
+ },
56
+ "directives": []
57
+ }],
58
+ "directives": [],
59
+ "selectionSet": {
60
+ "kind": "SelectionSet",
61
+ "selections": [{
62
+ "kind": "Field",
63
+ "name": {
64
+ "kind": "Name",
65
+ "value": "createBotmanorAgent"
66
+ },
67
+ "arguments": [{
68
+ "kind": "Argument",
69
+ "name": {
70
+ "kind": "Name",
71
+ "value": "input"
72
+ },
73
+ "value": {
74
+ "kind": "Variable",
75
+ "name": {
76
+ "kind": "Name",
77
+ "value": "input"
78
+ }
79
+ }
80
+ }],
81
+ "directives": [],
82
+ "selectionSet": {
83
+ "kind": "SelectionSet",
84
+ "selections": [{
85
+ "kind": "Field",
86
+ "name": {
87
+ "kind": "Name",
88
+ "value": "id"
89
+ },
90
+ "arguments": [],
91
+ "directives": []
92
+ }, {
93
+ "kind": "Field",
94
+ "name": {
95
+ "kind": "Name",
96
+ "value": "name"
97
+ },
98
+ "arguments": [],
99
+ "directives": []
100
+ }]
101
+ }
102
+ }]
103
+ }
104
+ }]
105
+ };
106
+
107
+ // src/generated/documents/wspace/CreateStewardDraftDocument.ts
108
+ const CreateStewardDraftDocument = {
109
+ "kind": "Document",
110
+ "definitions": [{
111
+ "kind": "OperationDefinition",
112
+ "operation": "mutation",
113
+ "name": {
114
+ "kind": "Name",
115
+ "value": "CreateStewardDraft"
116
+ },
117
+ "variableDefinitions": [{
118
+ "kind": "VariableDefinition",
119
+ "variable": {
120
+ "kind": "Variable",
121
+ "name": {
122
+ "kind": "Name",
123
+ "value": "input"
124
+ }
125
+ },
126
+ "type": {
127
+ "kind": "NonNullType",
128
+ "type": {
129
+ "kind": "NamedType",
130
+ "name": {
131
+ "kind": "Name",
132
+ "value": "CreateBotmanorStewardInput"
133
+ }
134
+ }
135
+ },
136
+ "directives": []
137
+ }],
138
+ "directives": [],
139
+ "selectionSet": {
140
+ "kind": "SelectionSet",
141
+ "selections": [{
142
+ "kind": "Field",
143
+ "name": {
144
+ "kind": "Name",
145
+ "value": "createBotmanorSteward"
146
+ },
147
+ "arguments": [{
148
+ "kind": "Argument",
149
+ "name": {
150
+ "kind": "Name",
151
+ "value": "input"
152
+ },
153
+ "value": {
154
+ "kind": "Variable",
155
+ "name": {
156
+ "kind": "Name",
157
+ "value": "input"
158
+ }
159
+ }
160
+ }],
161
+ "directives": [],
162
+ "selectionSet": {
163
+ "kind": "SelectionSet",
164
+ "selections": [{
165
+ "kind": "FragmentSpread",
166
+ "name": {
167
+ "kind": "Name",
168
+ "value": "StewardDraftFields"
169
+ },
170
+ "directives": []
171
+ }]
172
+ }
173
+ }]
174
+ }
175
+ }, {
176
+ "kind": "FragmentDefinition",
177
+ "name": {
178
+ "kind": "Name",
179
+ "value": "StewardDraftFields"
180
+ },
181
+ "variableDefinitions": [],
182
+ "typeCondition": {
183
+ "kind": "NamedType",
184
+ "name": {
185
+ "kind": "Name",
186
+ "value": "BotmanorSteward"
187
+ }
188
+ },
189
+ "directives": [],
190
+ "selectionSet": {
191
+ "kind": "SelectionSet",
192
+ "selections": [
193
+ {
194
+ "kind": "Field",
195
+ "name": {
196
+ "kind": "Name",
197
+ "value": "id"
198
+ },
199
+ "arguments": [],
200
+ "directives": []
201
+ },
202
+ {
203
+ "kind": "Field",
204
+ "name": {
205
+ "kind": "Name",
206
+ "value": "agentId"
207
+ },
208
+ "arguments": [],
209
+ "directives": []
210
+ },
211
+ {
212
+ "kind": "Field",
213
+ "name": {
214
+ "kind": "Name",
215
+ "value": "status"
216
+ },
217
+ "arguments": [],
218
+ "directives": []
219
+ },
220
+ {
221
+ "kind": "Field",
222
+ "name": {
223
+ "kind": "Name",
224
+ "value": "agent"
225
+ },
226
+ "arguments": [],
227
+ "directives": [],
228
+ "selectionSet": {
229
+ "kind": "SelectionSet",
230
+ "selections": [{
231
+ "kind": "Field",
232
+ "name": {
233
+ "kind": "Name",
234
+ "value": "name"
235
+ },
236
+ "arguments": [],
237
+ "directives": []
238
+ }]
239
+ }
240
+ },
241
+ {
242
+ "kind": "Field",
243
+ "name": {
244
+ "kind": "Name",
245
+ "value": "charter"
246
+ },
247
+ "arguments": [],
248
+ "directives": [],
249
+ "selectionSet": {
250
+ "kind": "SelectionSet",
251
+ "selections": [
252
+ {
253
+ "kind": "Field",
254
+ "name": {
255
+ "kind": "Name",
256
+ "value": "autonomyLevel"
257
+ },
258
+ "arguments": [],
259
+ "directives": []
260
+ },
261
+ {
262
+ "kind": "Field",
263
+ "name": {
264
+ "kind": "Name",
265
+ "value": "charterText"
266
+ },
267
+ "arguments": [],
268
+ "directives": []
269
+ },
270
+ {
271
+ "kind": "Field",
272
+ "name": {
273
+ "kind": "Name",
274
+ "value": "charterVersion"
275
+ },
276
+ "arguments": [],
277
+ "directives": []
278
+ },
279
+ {
280
+ "kind": "Field",
281
+ "name": {
282
+ "kind": "Name",
283
+ "value": "allowedToolKeys"
284
+ },
285
+ "arguments": [],
286
+ "directives": []
287
+ },
288
+ {
289
+ "kind": "Field",
290
+ "name": {
291
+ "kind": "Name",
292
+ "value": "dryRunDefault"
293
+ },
294
+ "arguments": [],
295
+ "directives": []
296
+ },
297
+ {
298
+ "kind": "Field",
299
+ "name": {
300
+ "kind": "Name",
301
+ "value": "timezone"
302
+ },
303
+ "arguments": [],
304
+ "directives": []
305
+ },
306
+ {
307
+ "kind": "Field",
308
+ "name": {
309
+ "kind": "Name",
310
+ "value": "budgetPerRun"
311
+ },
312
+ "arguments": [],
313
+ "directives": [],
314
+ "selectionSet": {
315
+ "kind": "SelectionSet",
316
+ "selections": [
317
+ {
318
+ "kind": "Field",
319
+ "name": {
320
+ "kind": "Name",
321
+ "value": "credits"
322
+ },
323
+ "arguments": [],
324
+ "directives": []
325
+ },
326
+ {
327
+ "kind": "Field",
328
+ "name": {
329
+ "kind": "Name",
330
+ "value": "steps"
331
+ },
332
+ "arguments": [],
333
+ "directives": []
334
+ },
335
+ {
336
+ "kind": "Field",
337
+ "name": {
338
+ "kind": "Name",
339
+ "value": "wallSeconds"
340
+ },
341
+ "arguments": [],
342
+ "directives": []
343
+ }
344
+ ]
345
+ }
346
+ },
347
+ {
348
+ "kind": "Field",
349
+ "name": {
350
+ "kind": "Name",
351
+ "value": "budgetPerDay"
352
+ },
353
+ "arguments": [],
354
+ "directives": [],
355
+ "selectionSet": {
356
+ "kind": "SelectionSet",
357
+ "selections": [{
358
+ "kind": "Field",
359
+ "name": {
360
+ "kind": "Name",
361
+ "value": "credits"
362
+ },
363
+ "arguments": [],
364
+ "directives": []
365
+ }]
366
+ }
367
+ }
368
+ ]
369
+ }
370
+ }
371
+ ]
372
+ }
373
+ }]
374
+ };
375
+
376
+ // src/generated/documents/wspace/UpdateStewardDraftCharterDocument.ts
377
+ const UpdateStewardDraftCharterDocument = {
378
+ "kind": "Document",
379
+ "definitions": [{
380
+ "kind": "OperationDefinition",
381
+ "operation": "mutation",
382
+ "name": {
383
+ "kind": "Name",
384
+ "value": "UpdateStewardDraftCharter"
385
+ },
386
+ "variableDefinitions": [{
387
+ "kind": "VariableDefinition",
388
+ "variable": {
389
+ "kind": "Variable",
390
+ "name": {
391
+ "kind": "Name",
392
+ "value": "id"
393
+ }
394
+ },
395
+ "type": {
396
+ "kind": "NonNullType",
397
+ "type": {
398
+ "kind": "NamedType",
399
+ "name": {
400
+ "kind": "Name",
401
+ "value": "ID"
402
+ }
403
+ }
404
+ },
405
+ "directives": []
406
+ }, {
407
+ "kind": "VariableDefinition",
408
+ "variable": {
409
+ "kind": "Variable",
410
+ "name": {
411
+ "kind": "Name",
412
+ "value": "input"
413
+ }
414
+ },
415
+ "type": {
416
+ "kind": "NonNullType",
417
+ "type": {
418
+ "kind": "NamedType",
419
+ "name": {
420
+ "kind": "Name",
421
+ "value": "UpdateBotmanorStewardCharterInput"
422
+ }
423
+ }
424
+ },
425
+ "directives": []
426
+ }],
427
+ "directives": [],
428
+ "selectionSet": {
429
+ "kind": "SelectionSet",
430
+ "selections": [{
431
+ "kind": "Field",
432
+ "name": {
433
+ "kind": "Name",
434
+ "value": "updateBotmanorStewardCharter"
435
+ },
436
+ "arguments": [{
437
+ "kind": "Argument",
438
+ "name": {
439
+ "kind": "Name",
440
+ "value": "id"
441
+ },
442
+ "value": {
443
+ "kind": "Variable",
444
+ "name": {
445
+ "kind": "Name",
446
+ "value": "id"
447
+ }
448
+ }
449
+ }, {
450
+ "kind": "Argument",
451
+ "name": {
452
+ "kind": "Name",
453
+ "value": "input"
454
+ },
455
+ "value": {
456
+ "kind": "Variable",
457
+ "name": {
458
+ "kind": "Name",
459
+ "value": "input"
460
+ }
461
+ }
462
+ }],
463
+ "directives": [],
464
+ "selectionSet": {
465
+ "kind": "SelectionSet",
466
+ "selections": [{
467
+ "kind": "FragmentSpread",
468
+ "name": {
469
+ "kind": "Name",
470
+ "value": "StewardDraftFields"
471
+ },
472
+ "directives": []
473
+ }]
474
+ }
475
+ }]
476
+ }
477
+ }, {
478
+ "kind": "FragmentDefinition",
479
+ "name": {
480
+ "kind": "Name",
481
+ "value": "StewardDraftFields"
482
+ },
483
+ "variableDefinitions": [],
484
+ "typeCondition": {
485
+ "kind": "NamedType",
486
+ "name": {
487
+ "kind": "Name",
488
+ "value": "BotmanorSteward"
489
+ }
490
+ },
491
+ "directives": [],
492
+ "selectionSet": {
493
+ "kind": "SelectionSet",
494
+ "selections": [
495
+ {
496
+ "kind": "Field",
497
+ "name": {
498
+ "kind": "Name",
499
+ "value": "id"
500
+ },
501
+ "arguments": [],
502
+ "directives": []
503
+ },
504
+ {
505
+ "kind": "Field",
506
+ "name": {
507
+ "kind": "Name",
508
+ "value": "agentId"
509
+ },
510
+ "arguments": [],
511
+ "directives": []
512
+ },
513
+ {
514
+ "kind": "Field",
515
+ "name": {
516
+ "kind": "Name",
517
+ "value": "status"
518
+ },
519
+ "arguments": [],
520
+ "directives": []
521
+ },
522
+ {
523
+ "kind": "Field",
524
+ "name": {
525
+ "kind": "Name",
526
+ "value": "agent"
527
+ },
528
+ "arguments": [],
529
+ "directives": [],
530
+ "selectionSet": {
531
+ "kind": "SelectionSet",
532
+ "selections": [{
533
+ "kind": "Field",
534
+ "name": {
535
+ "kind": "Name",
536
+ "value": "name"
537
+ },
538
+ "arguments": [],
539
+ "directives": []
540
+ }]
541
+ }
542
+ },
543
+ {
544
+ "kind": "Field",
545
+ "name": {
546
+ "kind": "Name",
547
+ "value": "charter"
548
+ },
549
+ "arguments": [],
550
+ "directives": [],
551
+ "selectionSet": {
552
+ "kind": "SelectionSet",
553
+ "selections": [
554
+ {
555
+ "kind": "Field",
556
+ "name": {
557
+ "kind": "Name",
558
+ "value": "autonomyLevel"
559
+ },
560
+ "arguments": [],
561
+ "directives": []
562
+ },
563
+ {
564
+ "kind": "Field",
565
+ "name": {
566
+ "kind": "Name",
567
+ "value": "charterText"
568
+ },
569
+ "arguments": [],
570
+ "directives": []
571
+ },
572
+ {
573
+ "kind": "Field",
574
+ "name": {
575
+ "kind": "Name",
576
+ "value": "charterVersion"
577
+ },
578
+ "arguments": [],
579
+ "directives": []
580
+ },
581
+ {
582
+ "kind": "Field",
583
+ "name": {
584
+ "kind": "Name",
585
+ "value": "allowedToolKeys"
586
+ },
587
+ "arguments": [],
588
+ "directives": []
589
+ },
590
+ {
591
+ "kind": "Field",
592
+ "name": {
593
+ "kind": "Name",
594
+ "value": "dryRunDefault"
595
+ },
596
+ "arguments": [],
597
+ "directives": []
598
+ },
599
+ {
600
+ "kind": "Field",
601
+ "name": {
602
+ "kind": "Name",
603
+ "value": "timezone"
604
+ },
605
+ "arguments": [],
606
+ "directives": []
607
+ },
608
+ {
609
+ "kind": "Field",
610
+ "name": {
611
+ "kind": "Name",
612
+ "value": "budgetPerRun"
613
+ },
614
+ "arguments": [],
615
+ "directives": [],
616
+ "selectionSet": {
617
+ "kind": "SelectionSet",
618
+ "selections": [
619
+ {
620
+ "kind": "Field",
621
+ "name": {
622
+ "kind": "Name",
623
+ "value": "credits"
624
+ },
625
+ "arguments": [],
626
+ "directives": []
627
+ },
628
+ {
629
+ "kind": "Field",
630
+ "name": {
631
+ "kind": "Name",
632
+ "value": "steps"
633
+ },
634
+ "arguments": [],
635
+ "directives": []
636
+ },
637
+ {
638
+ "kind": "Field",
639
+ "name": {
640
+ "kind": "Name",
641
+ "value": "wallSeconds"
642
+ },
643
+ "arguments": [],
644
+ "directives": []
645
+ }
646
+ ]
647
+ }
648
+ },
649
+ {
650
+ "kind": "Field",
651
+ "name": {
652
+ "kind": "Name",
653
+ "value": "budgetPerDay"
654
+ },
655
+ "arguments": [],
656
+ "directives": [],
657
+ "selectionSet": {
658
+ "kind": "SelectionSet",
659
+ "selections": [{
660
+ "kind": "Field",
661
+ "name": {
662
+ "kind": "Name",
663
+ "value": "credits"
664
+ },
665
+ "arguments": [],
666
+ "directives": []
667
+ }]
668
+ }
669
+ }
670
+ ]
671
+ }
672
+ }
673
+ ]
674
+ }
675
+ }]
676
+ };
677
+
678
+ // src/generated/documents/wspace/SetStewardDraftStatusDocument.ts
679
+ const SetStewardDraftStatusDocument = {
680
+ "kind": "Document",
681
+ "definitions": [{
682
+ "kind": "OperationDefinition",
683
+ "operation": "mutation",
684
+ "name": {
685
+ "kind": "Name",
686
+ "value": "SetStewardDraftStatus"
687
+ },
688
+ "variableDefinitions": [{
689
+ "kind": "VariableDefinition",
690
+ "variable": {
691
+ "kind": "Variable",
692
+ "name": {
693
+ "kind": "Name",
694
+ "value": "id"
695
+ }
696
+ },
697
+ "type": {
698
+ "kind": "NonNullType",
699
+ "type": {
700
+ "kind": "NamedType",
701
+ "name": {
702
+ "kind": "Name",
703
+ "value": "ID"
704
+ }
705
+ }
706
+ },
707
+ "directives": []
708
+ }, {
709
+ "kind": "VariableDefinition",
710
+ "variable": {
711
+ "kind": "Variable",
712
+ "name": {
713
+ "kind": "Name",
714
+ "value": "status"
715
+ }
716
+ },
717
+ "type": {
718
+ "kind": "NonNullType",
719
+ "type": {
720
+ "kind": "NamedType",
721
+ "name": {
722
+ "kind": "Name",
723
+ "value": "BotmanorStewardStatus"
724
+ }
725
+ }
726
+ },
727
+ "directives": []
728
+ }],
729
+ "directives": [],
730
+ "selectionSet": {
731
+ "kind": "SelectionSet",
732
+ "selections": [{
733
+ "kind": "Field",
734
+ "name": {
735
+ "kind": "Name",
736
+ "value": "setBotmanorStewardStatus"
737
+ },
738
+ "arguments": [{
739
+ "kind": "Argument",
740
+ "name": {
741
+ "kind": "Name",
742
+ "value": "id"
743
+ },
744
+ "value": {
745
+ "kind": "Variable",
746
+ "name": {
747
+ "kind": "Name",
748
+ "value": "id"
749
+ }
750
+ }
751
+ }, {
752
+ "kind": "Argument",
753
+ "name": {
754
+ "kind": "Name",
755
+ "value": "status"
756
+ },
757
+ "value": {
758
+ "kind": "Variable",
759
+ "name": {
760
+ "kind": "Name",
761
+ "value": "status"
762
+ }
763
+ }
764
+ }],
765
+ "directives": [],
766
+ "selectionSet": {
767
+ "kind": "SelectionSet",
768
+ "selections": [{
769
+ "kind": "FragmentSpread",
770
+ "name": {
771
+ "kind": "Name",
772
+ "value": "StewardDraftFields"
773
+ },
774
+ "directives": []
775
+ }]
776
+ }
777
+ }]
778
+ }
779
+ }, {
780
+ "kind": "FragmentDefinition",
781
+ "name": {
782
+ "kind": "Name",
783
+ "value": "StewardDraftFields"
784
+ },
785
+ "variableDefinitions": [],
786
+ "typeCondition": {
787
+ "kind": "NamedType",
788
+ "name": {
789
+ "kind": "Name",
790
+ "value": "BotmanorSteward"
791
+ }
792
+ },
793
+ "directives": [],
794
+ "selectionSet": {
795
+ "kind": "SelectionSet",
796
+ "selections": [
797
+ {
798
+ "kind": "Field",
799
+ "name": {
800
+ "kind": "Name",
801
+ "value": "id"
802
+ },
803
+ "arguments": [],
804
+ "directives": []
805
+ },
806
+ {
807
+ "kind": "Field",
808
+ "name": {
809
+ "kind": "Name",
810
+ "value": "agentId"
811
+ },
812
+ "arguments": [],
813
+ "directives": []
814
+ },
815
+ {
816
+ "kind": "Field",
817
+ "name": {
818
+ "kind": "Name",
819
+ "value": "status"
820
+ },
821
+ "arguments": [],
822
+ "directives": []
823
+ },
824
+ {
825
+ "kind": "Field",
826
+ "name": {
827
+ "kind": "Name",
828
+ "value": "agent"
829
+ },
830
+ "arguments": [],
831
+ "directives": [],
832
+ "selectionSet": {
833
+ "kind": "SelectionSet",
834
+ "selections": [{
835
+ "kind": "Field",
836
+ "name": {
837
+ "kind": "Name",
838
+ "value": "name"
839
+ },
840
+ "arguments": [],
841
+ "directives": []
842
+ }]
843
+ }
844
+ },
845
+ {
846
+ "kind": "Field",
847
+ "name": {
848
+ "kind": "Name",
849
+ "value": "charter"
850
+ },
851
+ "arguments": [],
852
+ "directives": [],
853
+ "selectionSet": {
854
+ "kind": "SelectionSet",
855
+ "selections": [
856
+ {
857
+ "kind": "Field",
858
+ "name": {
859
+ "kind": "Name",
860
+ "value": "autonomyLevel"
861
+ },
862
+ "arguments": [],
863
+ "directives": []
864
+ },
865
+ {
866
+ "kind": "Field",
867
+ "name": {
868
+ "kind": "Name",
869
+ "value": "charterText"
870
+ },
871
+ "arguments": [],
872
+ "directives": []
873
+ },
874
+ {
875
+ "kind": "Field",
876
+ "name": {
877
+ "kind": "Name",
878
+ "value": "charterVersion"
879
+ },
880
+ "arguments": [],
881
+ "directives": []
882
+ },
883
+ {
884
+ "kind": "Field",
885
+ "name": {
886
+ "kind": "Name",
887
+ "value": "allowedToolKeys"
888
+ },
889
+ "arguments": [],
890
+ "directives": []
891
+ },
892
+ {
893
+ "kind": "Field",
894
+ "name": {
895
+ "kind": "Name",
896
+ "value": "dryRunDefault"
897
+ },
898
+ "arguments": [],
899
+ "directives": []
900
+ },
901
+ {
902
+ "kind": "Field",
903
+ "name": {
904
+ "kind": "Name",
905
+ "value": "timezone"
906
+ },
907
+ "arguments": [],
908
+ "directives": []
909
+ },
910
+ {
911
+ "kind": "Field",
912
+ "name": {
913
+ "kind": "Name",
914
+ "value": "budgetPerRun"
915
+ },
916
+ "arguments": [],
917
+ "directives": [],
918
+ "selectionSet": {
919
+ "kind": "SelectionSet",
920
+ "selections": [
921
+ {
922
+ "kind": "Field",
923
+ "name": {
924
+ "kind": "Name",
925
+ "value": "credits"
926
+ },
927
+ "arguments": [],
928
+ "directives": []
929
+ },
930
+ {
931
+ "kind": "Field",
932
+ "name": {
933
+ "kind": "Name",
934
+ "value": "steps"
935
+ },
936
+ "arguments": [],
937
+ "directives": []
938
+ },
939
+ {
940
+ "kind": "Field",
941
+ "name": {
942
+ "kind": "Name",
943
+ "value": "wallSeconds"
944
+ },
945
+ "arguments": [],
946
+ "directives": []
947
+ }
948
+ ]
949
+ }
950
+ },
951
+ {
952
+ "kind": "Field",
953
+ "name": {
954
+ "kind": "Name",
955
+ "value": "budgetPerDay"
956
+ },
957
+ "arguments": [],
958
+ "directives": [],
959
+ "selectionSet": {
960
+ "kind": "SelectionSet",
961
+ "selections": [{
962
+ "kind": "Field",
963
+ "name": {
964
+ "kind": "Name",
965
+ "value": "credits"
966
+ },
967
+ "arguments": [],
968
+ "directives": []
969
+ }]
970
+ }
971
+ }
972
+ ]
973
+ }
974
+ }
975
+ ]
976
+ }
977
+ }]
978
+ };
979
+
980
+ // src/generated/documents/wspace/StewardsForCrystalliseDocument.ts
981
+ const StewardsForCrystalliseDocument = {
982
+ "kind": "Document",
983
+ "definitions": [{
984
+ "kind": "OperationDefinition",
985
+ "operation": "query",
986
+ "name": {
987
+ "kind": "Name",
988
+ "value": "StewardsForCrystallise"
989
+ },
990
+ "variableDefinitions": [{
991
+ "kind": "VariableDefinition",
992
+ "variable": {
993
+ "kind": "Variable",
994
+ "name": {
995
+ "kind": "Name",
996
+ "value": "pagination"
997
+ }
998
+ },
999
+ "type": {
1000
+ "kind": "NamedType",
1001
+ "name": {
1002
+ "kind": "Name",
1003
+ "value": "PaginationInput"
1004
+ }
1005
+ },
1006
+ "directives": []
1007
+ }],
1008
+ "directives": [],
1009
+ "selectionSet": {
1010
+ "kind": "SelectionSet",
1011
+ "selections": [{
1012
+ "kind": "Field",
1013
+ "name": {
1014
+ "kind": "Name",
1015
+ "value": "listBotmanorStewards"
1016
+ },
1017
+ "arguments": [{
1018
+ "kind": "Argument",
1019
+ "name": {
1020
+ "kind": "Name",
1021
+ "value": "pagination"
1022
+ },
1023
+ "value": {
1024
+ "kind": "Variable",
1025
+ "name": {
1026
+ "kind": "Name",
1027
+ "value": "pagination"
1028
+ }
1029
+ }
1030
+ }],
1031
+ "directives": [],
1032
+ "selectionSet": {
1033
+ "kind": "SelectionSet",
1034
+ "selections": [
1035
+ {
1036
+ "kind": "Field",
1037
+ "name": {
1038
+ "kind": "Name",
1039
+ "value": "id"
1040
+ },
1041
+ "arguments": [],
1042
+ "directives": []
1043
+ },
1044
+ {
1045
+ "kind": "Field",
1046
+ "name": {
1047
+ "kind": "Name",
1048
+ "value": "status"
1049
+ },
1050
+ "arguments": [],
1051
+ "directives": []
1052
+ },
1053
+ {
1054
+ "kind": "Field",
1055
+ "name": {
1056
+ "kind": "Name",
1057
+ "value": "agent"
1058
+ },
1059
+ "arguments": [],
1060
+ "directives": [],
1061
+ "selectionSet": {
1062
+ "kind": "SelectionSet",
1063
+ "selections": [{
1064
+ "kind": "Field",
1065
+ "name": {
1066
+ "kind": "Name",
1067
+ "value": "id"
1068
+ },
1069
+ "arguments": [],
1070
+ "directives": []
1071
+ }, {
1072
+ "kind": "Field",
1073
+ "name": {
1074
+ "kind": "Name",
1075
+ "value": "name"
1076
+ },
1077
+ "arguments": [],
1078
+ "directives": []
1079
+ }]
1080
+ }
1081
+ }
1082
+ ]
1083
+ }
1084
+ }]
1085
+ }
1086
+ }]
1087
+ };
1088
+
1089
+ // src/generated/documents/wspace/StewardRunsForCrystalliseDocument.ts
1090
+ const StewardRunsForCrystalliseDocument = {
1091
+ "kind": "Document",
1092
+ "definitions": [{
1093
+ "kind": "OperationDefinition",
1094
+ "operation": "query",
1095
+ "name": {
1096
+ "kind": "Name",
1097
+ "value": "StewardRunsForCrystallise"
1098
+ },
1099
+ "variableDefinitions": [{
1100
+ "kind": "VariableDefinition",
1101
+ "variable": {
1102
+ "kind": "Variable",
1103
+ "name": {
1104
+ "kind": "Name",
1105
+ "value": "stewardId"
1106
+ }
1107
+ },
1108
+ "type": {
1109
+ "kind": "NonNullType",
1110
+ "type": {
1111
+ "kind": "NamedType",
1112
+ "name": {
1113
+ "kind": "Name",
1114
+ "value": "ID"
1115
+ }
1116
+ }
1117
+ },
1118
+ "directives": []
1119
+ }, {
1120
+ "kind": "VariableDefinition",
1121
+ "variable": {
1122
+ "kind": "Variable",
1123
+ "name": {
1124
+ "kind": "Name",
1125
+ "value": "pagination"
1126
+ }
1127
+ },
1128
+ "type": {
1129
+ "kind": "NamedType",
1130
+ "name": {
1131
+ "kind": "Name",
1132
+ "value": "PaginationInput"
1133
+ }
1134
+ },
1135
+ "directives": []
1136
+ }],
1137
+ "directives": [],
1138
+ "selectionSet": {
1139
+ "kind": "SelectionSet",
1140
+ "selections": [{
1141
+ "kind": "Field",
1142
+ "name": {
1143
+ "kind": "Name",
1144
+ "value": "listBotmanorStewardRuns"
1145
+ },
1146
+ "arguments": [{
1147
+ "kind": "Argument",
1148
+ "name": {
1149
+ "kind": "Name",
1150
+ "value": "filter"
1151
+ },
1152
+ "value": {
1153
+ "kind": "ObjectValue",
1154
+ "fields": [{
1155
+ "kind": "ObjectField",
1156
+ "name": {
1157
+ "kind": "Name",
1158
+ "value": "stewardId"
1159
+ },
1160
+ "value": {
1161
+ "kind": "Variable",
1162
+ "name": {
1163
+ "kind": "Name",
1164
+ "value": "stewardId"
1165
+ }
1166
+ }
1167
+ }, {
1168
+ "kind": "ObjectField",
1169
+ "name": {
1170
+ "kind": "Name",
1171
+ "value": "status"
1172
+ },
1173
+ "value": {
1174
+ "kind": "EnumValue",
1175
+ "value": "COMPLETED"
1176
+ }
1177
+ }]
1178
+ }
1179
+ }, {
1180
+ "kind": "Argument",
1181
+ "name": {
1182
+ "kind": "Name",
1183
+ "value": "pagination"
1184
+ },
1185
+ "value": {
1186
+ "kind": "Variable",
1187
+ "name": {
1188
+ "kind": "Name",
1189
+ "value": "pagination"
1190
+ }
1191
+ }
1192
+ }],
1193
+ "directives": [],
1194
+ "selectionSet": {
1195
+ "kind": "SelectionSet",
1196
+ "selections": [
1197
+ {
1198
+ "kind": "Field",
1199
+ "name": {
1200
+ "kind": "Name",
1201
+ "value": "id"
1202
+ },
1203
+ "arguments": [],
1204
+ "directives": []
1205
+ },
1206
+ {
1207
+ "kind": "Field",
1208
+ "name": {
1209
+ "kind": "Name",
1210
+ "value": "stewardId"
1211
+ },
1212
+ "arguments": [],
1213
+ "directives": []
1214
+ },
1215
+ {
1216
+ "kind": "Field",
1217
+ "name": {
1218
+ "kind": "Name",
1219
+ "value": "stepCount"
1220
+ },
1221
+ "arguments": [],
1222
+ "directives": []
1223
+ },
1224
+ {
1225
+ "kind": "Field",
1226
+ "name": {
1227
+ "kind": "Name",
1228
+ "value": "dryRun"
1229
+ },
1230
+ "arguments": [],
1231
+ "directives": []
1232
+ },
1233
+ {
1234
+ "kind": "Field",
1235
+ "name": {
1236
+ "kind": "Name",
1237
+ "value": "finishedAt"
1238
+ },
1239
+ "arguments": [],
1240
+ "directives": []
1241
+ },
1242
+ {
1243
+ "kind": "Field",
1244
+ "name": {
1245
+ "kind": "Name",
1246
+ "value": "createdAt"
1247
+ },
1248
+ "arguments": [],
1249
+ "directives": []
1250
+ }
1251
+ ]
1252
+ }
1253
+ }]
1254
+ }
1255
+ }]
1256
+ };
1257
+
1258
+ // src/generated/documents/wspace/StewardRunStepsDocument.ts
1259
+ const StewardRunStepsDocument = {
1260
+ "kind": "Document",
1261
+ "definitions": [{
1262
+ "kind": "OperationDefinition",
1263
+ "operation": "query",
1264
+ "name": {
1265
+ "kind": "Name",
1266
+ "value": "StewardRunSteps"
1267
+ },
1268
+ "variableDefinitions": [{
1269
+ "kind": "VariableDefinition",
1270
+ "variable": {
1271
+ "kind": "Variable",
1272
+ "name": {
1273
+ "kind": "Name",
1274
+ "value": "id"
1275
+ }
1276
+ },
1277
+ "type": {
1278
+ "kind": "NonNullType",
1279
+ "type": {
1280
+ "kind": "NamedType",
1281
+ "name": {
1282
+ "kind": "Name",
1283
+ "value": "ID"
1284
+ }
1285
+ }
1286
+ },
1287
+ "directives": []
1288
+ }, {
1289
+ "kind": "VariableDefinition",
1290
+ "variable": {
1291
+ "kind": "Variable",
1292
+ "name": {
1293
+ "kind": "Name",
1294
+ "value": "pagination"
1295
+ }
1296
+ },
1297
+ "type": {
1298
+ "kind": "NamedType",
1299
+ "name": {
1300
+ "kind": "Name",
1301
+ "value": "PaginationInput"
1302
+ }
1303
+ },
1304
+ "directives": []
1305
+ }],
1306
+ "directives": [],
1307
+ "selectionSet": {
1308
+ "kind": "SelectionSet",
1309
+ "selections": [{
1310
+ "kind": "Field",
1311
+ "name": {
1312
+ "kind": "Name",
1313
+ "value": "getBotmanorStewardRun"
1314
+ },
1315
+ "arguments": [{
1316
+ "kind": "Argument",
1317
+ "name": {
1318
+ "kind": "Name",
1319
+ "value": "id"
1320
+ },
1321
+ "value": {
1322
+ "kind": "Variable",
1323
+ "name": {
1324
+ "kind": "Name",
1325
+ "value": "id"
1326
+ }
1327
+ }
1328
+ }],
1329
+ "directives": [],
1330
+ "selectionSet": {
1331
+ "kind": "SelectionSet",
1332
+ "selections": [
1333
+ {
1334
+ "kind": "Field",
1335
+ "name": {
1336
+ "kind": "Name",
1337
+ "value": "id"
1338
+ },
1339
+ "arguments": [],
1340
+ "directives": []
1341
+ },
1342
+ {
1343
+ "kind": "Field",
1344
+ "name": {
1345
+ "kind": "Name",
1346
+ "value": "stewardId"
1347
+ },
1348
+ "arguments": [],
1349
+ "directives": []
1350
+ },
1351
+ {
1352
+ "kind": "Field",
1353
+ "name": {
1354
+ "kind": "Name",
1355
+ "value": "status"
1356
+ },
1357
+ "arguments": [],
1358
+ "directives": []
1359
+ },
1360
+ {
1361
+ "kind": "Field",
1362
+ "name": {
1363
+ "kind": "Name",
1364
+ "value": "dryRun"
1365
+ },
1366
+ "arguments": [],
1367
+ "directives": []
1368
+ },
1369
+ {
1370
+ "kind": "Field",
1371
+ "name": {
1372
+ "kind": "Name",
1373
+ "value": "stepCount"
1374
+ },
1375
+ "arguments": [],
1376
+ "directives": []
1377
+ },
1378
+ {
1379
+ "kind": "Field",
1380
+ "name": {
1381
+ "kind": "Name",
1382
+ "value": "steps"
1383
+ },
1384
+ "arguments": [{
1385
+ "kind": "Argument",
1386
+ "name": {
1387
+ "kind": "Name",
1388
+ "value": "pagination"
1389
+ },
1390
+ "value": {
1391
+ "kind": "Variable",
1392
+ "name": {
1393
+ "kind": "Name",
1394
+ "value": "pagination"
1395
+ }
1396
+ }
1397
+ }],
1398
+ "directives": [],
1399
+ "selectionSet": {
1400
+ "kind": "SelectionSet",
1401
+ "selections": [
1402
+ {
1403
+ "kind": "Field",
1404
+ "name": {
1405
+ "kind": "Name",
1406
+ "value": "id"
1407
+ },
1408
+ "arguments": [],
1409
+ "directives": []
1410
+ },
1411
+ {
1412
+ "kind": "Field",
1413
+ "name": {
1414
+ "kind": "Name",
1415
+ "value": "seq"
1416
+ },
1417
+ "arguments": [],
1418
+ "directives": []
1419
+ },
1420
+ {
1421
+ "kind": "Field",
1422
+ "name": {
1423
+ "kind": "Name",
1424
+ "value": "kind"
1425
+ },
1426
+ "arguments": [],
1427
+ "directives": []
1428
+ },
1429
+ {
1430
+ "kind": "Field",
1431
+ "name": {
1432
+ "kind": "Name",
1433
+ "value": "toolKey"
1434
+ },
1435
+ "arguments": [],
1436
+ "directives": []
1437
+ },
1438
+ {
1439
+ "kind": "Field",
1440
+ "name": {
1441
+ "kind": "Name",
1442
+ "value": "targetSummary"
1443
+ },
1444
+ "arguments": [],
1445
+ "directives": []
1446
+ },
1447
+ {
1448
+ "kind": "Field",
1449
+ "name": {
1450
+ "kind": "Name",
1451
+ "value": "argumentsRedacted"
1452
+ },
1453
+ "arguments": [],
1454
+ "directives": []
1455
+ },
1456
+ {
1457
+ "kind": "Field",
1458
+ "name": {
1459
+ "kind": "Name",
1460
+ "value": "verdict"
1461
+ },
1462
+ "arguments": [],
1463
+ "directives": []
1464
+ },
1465
+ {
1466
+ "kind": "Field",
1467
+ "name": {
1468
+ "kind": "Name",
1469
+ "value": "dryRun"
1470
+ },
1471
+ "arguments": [],
1472
+ "directives": []
1473
+ }
1474
+ ]
1475
+ }
1476
+ }
1477
+ ]
1478
+ }
1479
+ }]
1480
+ }
1481
+ }]
1482
+ };
1483
+
1484
+ // src/modules/ai-studio/components/DraftCanvas.tsx
1485
+ /**
1486
+ * The read-only canvas AI Studio draws a draft on (BOFF-4089), shared by the
1487
+ * workflow draft and the workflow built from a Steward run (BOFF-16146).
1488
+ */
1489
+ /** The read-only canvas for a draft, with the palette metadata a drop would give each node. */
1490
+ function DraftCanvas({ generationId, name, definitionJson }) {
1491
+ const tr = useTr();
1492
+ const [workflow, setWorkflow] = useState(null);
1493
+ useEffect(() => {
1494
+ let active = true;
1495
+ const build = (seeded) => {
1496
+ const canvas = draftToCanvas(definitionJson);
1497
+ return {
1498
+ id: generationId,
1499
+ workflowKey: generationId,
1500
+ version: "preview",
1501
+ name,
1502
+ nodes: seeded ? enrichDraftNodes(canvas.nodes, buildOperationSeed) : canvas.nodes,
1503
+ edges: canvas.edges,
1504
+ sidebar: {
1505
+ active: "none",
1506
+ panels: { nodeProperties: { selectedNode: null } }
1507
+ }
1508
+ };
1509
+ };
1510
+ ensureNodeTypesLoaded(draftToCanvas(definitionJson).nodes.map((node) => node.type)).then(() => {
1511
+ if (active) setWorkflow(build(true));
1512
+ }).catch(() => {
1513
+ if (active) setWorkflow(build(false));
1514
+ });
1515
+ return () => {
1516
+ active = false;
1517
+ };
1518
+ }, [
1519
+ definitionJson,
1520
+ generationId,
1521
+ name
1522
+ ]);
1523
+ if (!workflow) return /* @__PURE__ */ jsxs("div", {
1524
+ className: "flex h-full items-center justify-center gap-2 text-sm text-muted-foreground",
1525
+ children: [/* @__PURE__ */ jsx(SpinnerIcon, { className: "size-4 animate-spin" }), tr("fluidgrids.aiStudio.preview.loading", "Loading preview…")]
1526
+ });
1527
+ return /* @__PURE__ */ jsx(ThemeProvider, { children: /* @__PURE__ */ jsx(ErrorBoundary, {
1528
+ fallback: () => /* @__PURE__ */ jsx("div", {
1529
+ className: "flex h-full items-center justify-center p-6 text-center text-sm text-muted-foreground",
1530
+ children: tr("fluidgrids.aiStudio.preview.renderError", "The preview could not be drawn. The draft can still be opened in the builder.")
1531
+ }),
1532
+ children: /* @__PURE__ */ jsx(FlowBuilderPage, {
1533
+ workflow,
1534
+ readOnly: true
1535
+ })
1536
+ }) });
1537
+ }
1538
+
1539
+ // src/modules/ai-studio/lib/steward-crystallise.ts
1540
+ /** The catalog node a connector's tool keys (`node:<provider>:<operation>`) run on. */
1541
+ const STEWARD_CONNECTOR_NODES = {
1542
+ gmail: "store/gmail_reader",
1543
+ google_calendar: "store/google_calendar",
1544
+ slack: "store/slack",
1545
+ notion: "store/notion",
1546
+ jira: "store/jira",
1547
+ github: "store/github",
1548
+ hubspot: "store/hubspot",
1549
+ google_sheets: "store/google_sheets",
1550
+ linear: "store/linear",
1551
+ outlook: "store/microsoftoutlook"
1552
+ };
1553
+ /** What BotManor writes in place of a secret-looking value (`redactArguments`). */
1554
+ const REDACTED_VALUE = "••••";
1555
+ const TRUNCATED_SUFFIX = "[truncated]";
1556
+ const NODE_PREFIX = "node:";
1557
+ const TRIGGER_ID = "start";
1558
+ const STEP_SPACING_X = 320;
1559
+ /** Steps a Steward run records are at most this many; a workflow stays readable. */
1560
+ const CRYSTALLISE_MAX_NODES = 100;
1561
+ function isRecord$1(value) {
1562
+ return typeof value === "object" && value !== null && !Array.isArray(value);
1563
+ }
1564
+ /** Parse `node:<provider>:<operation>`; null for any other tool key. */
1565
+ function parseConnectorToolKey(toolKey) {
1566
+ if (!toolKey?.startsWith(NODE_PREFIX)) return null;
1567
+ const [provider, operation, ...rest] = toolKey.slice(5).split(":");
1568
+ if (!provider || !operation || rest.length > 0) return null;
1569
+ return {
1570
+ provider,
1571
+ operation
1572
+ };
1573
+ }
1574
+ function isLostValue(value) {
1575
+ if (value === REDACTED_VALUE) return true;
1576
+ return typeof value === "string" && value.endsWith(TRUNCATED_SUFFIX);
1577
+ }
1578
+ /** Does this value, or anything inside it, carry a redacted or cut marker? */
1579
+ function carriesLostValue(value) {
1580
+ if (isLostValue(value)) return true;
1581
+ if (Array.isArray(value)) return value.some(carriesLostValue);
1582
+ if (isRecord$1(value)) return Object.values(value).some(carriesLostValue);
1583
+ return false;
1584
+ }
1585
+ /**
1586
+ * The arguments a node can carry and the fields it cannot. A top-level field
1587
+ * with a redacted or cut value is left out, so the person fills it in the
1588
+ * builder instead of a mask being sent to the provider.
1589
+ */
1590
+ function splitArguments(value) {
1591
+ const state = {};
1592
+ const missing = [];
1593
+ if (!isRecord$1(value)) return {
1594
+ state,
1595
+ missing
1596
+ };
1597
+ for (const [field, argument] of Object.entries(value)) if (carriesLostValue(argument)) missing.push(field);
1598
+ else state[field] = argument;
1599
+ return {
1600
+ state,
1601
+ missing
1602
+ };
1603
+ }
1604
+ function skipReason(step, runDryRun) {
1605
+ if (step.kind !== "TOOL_CALL" && step.kind !== "DESK_ACTION") return null;
1606
+ if (step.verdict !== "ALLOWED" && step.verdict !== "APPROVED") return "not_performed";
1607
+ if (runDryRun || step.dryRun === true) return "dry_run";
1608
+ if (step.kind === "DESK_ACTION") return "desk_action";
1609
+ const parsed = parseConnectorToolKey(step.toolKey);
1610
+ if (!parsed) return "other_tool";
1611
+ return STEWARD_CONNECTOR_NODES[parsed.provider] ? null : "no_node";
1612
+ }
1613
+ /** A short label for a node: "searchEmails (gmail)". */
1614
+ function labelOf(provider, operation) {
1615
+ return `${operation} (${provider})`;
1616
+ }
1617
+ const EMPTY_REPORT = {
1618
+ included: [],
1619
+ skipped: [],
1620
+ missing: []
1621
+ };
1622
+ /**
1623
+ * Turn a finished run into a workflow definition: a manual trigger followed by
1624
+ * one node per replayable connector call, in the order the Steward made them.
1625
+ */
1626
+ function crystalliseRun(run, options) {
1627
+ if (run.status !== "COMPLETED") return {
1628
+ ok: false,
1629
+ refusal: "run_not_completed",
1630
+ report: EMPTY_REPORT
1631
+ };
1632
+ if (run.dryRun) return {
1633
+ ok: false,
1634
+ refusal: "dry_run",
1635
+ report: EMPTY_REPORT
1636
+ };
1637
+ const report = {
1638
+ included: [],
1639
+ skipped: [],
1640
+ missing: []
1641
+ };
1642
+ const nodes = [{
1643
+ id: TRIGGER_ID,
1644
+ type: "internal:api",
1645
+ label: "Start",
1646
+ operation_name: "onManualTrigger",
1647
+ position: {
1648
+ x: 0,
1649
+ y: 0
1650
+ },
1651
+ data: {
1652
+ label: "Start",
1653
+ args: { state: {} }
1654
+ }
1655
+ }];
1656
+ const edges = [];
1657
+ let previous = TRIGGER_ID;
1658
+ const steps = [...run.steps].sort((a, b) => a.seq - b.seq);
1659
+ for (const step of steps) {
1660
+ const reason = skipReason(step, run.dryRun);
1661
+ if (reason) {
1662
+ report.skipped.push({
1663
+ seq: step.seq,
1664
+ toolKey: step.toolKey ?? null,
1665
+ reason
1666
+ });
1667
+ continue;
1668
+ }
1669
+ const parsed = parseConnectorToolKey(step.toolKey);
1670
+ const nodeType = parsed ? STEWARD_CONNECTOR_NODES[parsed.provider] : null;
1671
+ if (!parsed || !nodeType) continue;
1672
+ if (report.included.length >= 100) {
1673
+ report.skipped.push({
1674
+ seq: step.seq,
1675
+ toolKey: step.toolKey ?? null,
1676
+ reason: "too_many"
1677
+ });
1678
+ continue;
1679
+ }
1680
+ const nodeId = `step-${step.seq}`;
1681
+ const { state, missing } = splitArguments(step.argumentsRedacted);
1682
+ const label = labelOf(parsed.provider, parsed.operation);
1683
+ nodes.push({
1684
+ id: nodeId,
1685
+ type: nodeType,
1686
+ label,
1687
+ operation_name: parsed.operation,
1688
+ position: {
1689
+ x: report.included.length + 1,
1690
+ y: 0
1691
+ },
1692
+ data: {
1693
+ label,
1694
+ operation_name: parsed.operation,
1695
+ args: { state }
1696
+ }
1697
+ });
1698
+ edges.push({
1699
+ id: `e-${previous}-${nodeId}`,
1700
+ source: previous,
1701
+ target: nodeId,
1702
+ type: "deletable"
1703
+ });
1704
+ previous = nodeId;
1705
+ report.included.push({
1706
+ seq: step.seq,
1707
+ nodeId,
1708
+ nodeType,
1709
+ operation: parsed.operation,
1710
+ fields: Object.keys(state)
1711
+ });
1712
+ for (const field of missing) report.missing.push({
1713
+ nodeId,
1714
+ operation: parsed.operation,
1715
+ field
1716
+ });
1717
+ }
1718
+ if (report.included.length === 0) return {
1719
+ ok: false,
1720
+ refusal: "nothing_to_replay",
1721
+ report
1722
+ };
1723
+ for (const node of nodes) node.position = {
1724
+ x: node.position.x * STEP_SPACING_X,
1725
+ y: 0
1726
+ };
1727
+ const description = `Replays ${report.included.length} saved step${report.included.length === 1 ? "" : "s"} of a Steward run, with no model call.`;
1728
+ return {
1729
+ ok: true,
1730
+ report,
1731
+ definitionJson: {
1732
+ key: options.key,
1733
+ name: options.name,
1734
+ description,
1735
+ data: {
1736
+ nodes,
1737
+ edges
1738
+ }
1739
+ }
1740
+ };
1741
+ }
1742
+
1743
+ // src/modules/ai-studio/lib/steward-draft.ts
1744
+ /** wspace-botmanor-svc refuses a longer charter or run prompt. */
1745
+ const STEWARD_CHARTER_MAX_LENGTH = 2e4;
1746
+ /** What the job description may hold: the charter keeps room for its rules. */
1747
+ const STEWARD_DESCRIPTION_MAX_LENGTH = 4e3;
1748
+ const NAME_MAX_LENGTH = 60;
1749
+ const SLUG_MAX_LENGTH = 48;
1750
+ const STEWARD_FALLBACK_NAME = "New Steward";
1751
+ const STEWARD_EXAMPLES = [{
1752
+ id: "inbox-triage",
1753
+ labelKey: "fluidgrids.aiStudio.steward.examples.inbox.label",
1754
+ label: "Inbox triage",
1755
+ descriptionKey: "fluidgrids.aiStudio.steward.examples.inbox.description",
1756
+ description: "Every morning, read the new emails in the support inbox, group them by topic and draft a reply for each one that asks a question. Never send anything: leave drafts for me."
1757
+ }, {
1758
+ id: "weekly-report",
1759
+ labelKey: "fluidgrids.aiStudio.steward.examples.report.label",
1760
+ label: "Weekly report",
1761
+ descriptionKey: "fluidgrids.aiStudio.steward.examples.report.description",
1762
+ description: "Each Friday, collect the issues closed this week from our tracker and write a short summary for the team channel. Ask me before posting it."
1763
+ }];
1764
+ /** A readable name from the first line of the description, cut at a word. */
1765
+ function stewardNameOf(description) {
1766
+ const cleaned = (description.split(/\r?\n/).map((part) => part.trim()).find((part) => part !== "") ?? "").replace(/\s+/g, " ").replace(/[.!?:;,\s]+$/, "");
1767
+ if (cleaned === "") return STEWARD_FALLBACK_NAME;
1768
+ if (cleaned.length <= NAME_MAX_LENGTH) return cleaned;
1769
+ const cut = cleaned.slice(0, NAME_MAX_LENGTH);
1770
+ const space = cut.lastIndexOf(" ");
1771
+ return (space > NAME_MAX_LENGTH / 2 ? cut.slice(0, space) : cut).trim();
1772
+ }
1773
+ /** A URL-safe agent slug: the name in lower case with `suffix` to keep it unique. */
1774
+ function stewardSlugOf(name, suffix) {
1775
+ const base = name.toLowerCase().normalize("NFKD").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, SLUG_MAX_LENGTH).replace(/-+$/, "");
1776
+ const tail = suffix.toLowerCase().replace(/[^a-z0-9]/g, "");
1777
+ return [base || "steward", tail].filter(Boolean).join("-");
1778
+ }
1779
+ /**
1780
+ * The first charter: the job in the person's words, then the two rules every
1781
+ * new Steward starts with. It is shown for review and edited before anything
1782
+ * goes live; the rules only say what the draft's `ASK` level already enforces.
1783
+ */
1784
+ function draftCharterText(description) {
1785
+ return [
1786
+ "Job",
1787
+ description.trim(),
1788
+ "",
1789
+ "Rules",
1790
+ "- Ask a person before doing anything that changes something outside BotManor.",
1791
+ "- If you are blocked or unsure, stop and say what you need instead of guessing."
1792
+ ].join("\n");
1793
+ }
1794
+ /** The agent a new Steward is, named after the job and set up to follow its charter. */
1795
+ function stewardAgentInput(name, description, workspaceId, slugSuffix) {
1796
+ return {
1797
+ name,
1798
+ slug: stewardSlugOf(name, slugSuffix),
1799
+ description: description.trim().slice(0, 500),
1800
+ type: "AUTOMATION",
1801
+ systemPrompt: "You are a Steward: an assistant that carries out one standing job for its owner. Follow your charter exactly and ask when it does not cover what you need to do.",
1802
+ status: "ACTIVE",
1803
+ workspaceId
1804
+ };
1805
+ }
1806
+ /** The Steward: cautious by default (asks first, no tools, no desk). Created as DRAFT. */
1807
+ function stewardCreateInput(agentId, charterText) {
1808
+ return {
1809
+ agentId,
1810
+ charterText,
1811
+ autonomyLevel: "ASK",
1812
+ allowedToolKeys: [],
1813
+ defaultDeskKind: "NONE"
1814
+ };
1815
+ }
1816
+ /** Why a charter cannot be saved or activated, or null when it can. */
1817
+ function charterProblem(charterText) {
1818
+ const trimmed = charterText.trim();
1819
+ if (trimmed === "") return "empty";
1820
+ if (trimmed.length > 2e4) return "too_long";
1821
+ return null;
1822
+ }
1823
+ /** The permissions the page needs, as BotManor's `@rbac` names them. */
1824
+ const STEWARD_PERMISSIONS = {
1825
+ create: "botmanor-steward:create",
1826
+ update: "botmanor-steward:update",
1827
+ read: "botmanor-steward:read"
1828
+ };
1829
+
1830
+ // src/hooks/useStewardBuilder.ts
1831
+ /**
1832
+ * Steward hooks for AI Studio (BOFF-16146 C5).
1833
+ *
1834
+ * - `useStewardDraft` drives "Build with a prompt": it makes the agent and the
1835
+ * DRAFT Steward from a description, saves the reviewed charter and activates
1836
+ * the Steward when the person says so.
1837
+ * - `useStewardRunImport` reads a finished Steward run and turns it into a
1838
+ * workflow definition (see `steward-crystallise.ts`).
1839
+ *
1840
+ * Both go through the workspace gateway to BotManor's public API. FluidGrids
1841
+ * keeps no Steward state: every call below is a read or write on BotManor, and
1842
+ * each answers FEATURE_DISABLED while `botmanor.stewards` is off.
1843
+ */
1844
+ const PAGE_SIZE = 50;
1845
+ /** A run's steps are read in one page; BotManor records at most this many per read. */
1846
+ const STEPS_PAGE_SIZE = 200;
1847
+ function randomSuffix() {
1848
+ return Math.random().toString(36).slice(2, 8);
1849
+ }
1850
+ function useStewardDraft() {
1851
+ const [phase, setPhase] = useState("idle");
1852
+ const [steward, setSteward] = useState(null);
1853
+ const [error, setError] = useState(null);
1854
+ const agentIdRef = useRef(null);
1855
+ const busyRef = useRef(false);
1856
+ const create = useCallback(async (description) => {
1857
+ const trimmed = description.trim();
1858
+ if (!trimmed || busyRef.current) return;
1859
+ busyRef.current = true;
1860
+ setError(null);
1861
+ setPhase("creating");
1862
+ try {
1863
+ const client = getFluidGridsClient();
1864
+ if (!agentIdRef.current) {
1865
+ const agentId = throwIfResultError(await client.mutate({
1866
+ mutation: CreateStewardDraftAgentDocument,
1867
+ variables: { input: stewardAgentInput(stewardNameOf(trimmed), trimmed, getFluidGridsConfig().workspaceId, randomSuffix()) }
1868
+ })).data?.createBotmanorAgent.id;
1869
+ if (!agentId) throw new Error("The agent was not created");
1870
+ agentIdRef.current = agentId;
1871
+ }
1872
+ const next = throwIfResultError(await client.mutate({
1873
+ mutation: CreateStewardDraftDocument,
1874
+ variables: { input: stewardCreateInput(agentIdRef.current, draftCharterText(trimmed)) }
1875
+ })).data?.createBotmanorSteward;
1876
+ if (!next) throw new Error("The Steward was not created");
1877
+ agentIdRef.current = null;
1878
+ setSteward(next);
1879
+ setPhase("review");
1880
+ } catch (failure) {
1881
+ setError(describeOperationError(failure));
1882
+ setPhase("idle");
1883
+ } finally {
1884
+ busyRef.current = false;
1885
+ }
1886
+ }, []);
1887
+ const saveCharter = useCallback(async (current, charterText) => {
1888
+ const text = charterText.trim();
1889
+ if (charterProblem(text) !== null) throw new Error("The charter is empty or too long");
1890
+ if (text === current.charter.charterText.trim()) return current;
1891
+ const updated = throwIfResultError(await getFluidGridsClient().mutate({
1892
+ mutation: UpdateStewardDraftCharterDocument,
1893
+ variables: {
1894
+ id: current.id,
1895
+ input: { charterText: text }
1896
+ }
1897
+ })).data?.updateBotmanorStewardCharter;
1898
+ if (!updated) throw new Error("The charter was not saved");
1899
+ return updated;
1900
+ }, []);
1901
+ const saveDraft = useCallback(async (charterText) => {
1902
+ if (!steward || busyRef.current) return;
1903
+ busyRef.current = true;
1904
+ setError(null);
1905
+ setPhase("saving");
1906
+ try {
1907
+ setSteward(await saveCharter(steward, charterText));
1908
+ } catch (failure) {
1909
+ setError(describeOperationError(failure));
1910
+ } finally {
1911
+ setPhase("review");
1912
+ busyRef.current = false;
1913
+ }
1914
+ }, [saveCharter, steward]);
1915
+ return {
1916
+ phase,
1917
+ steward,
1918
+ error,
1919
+ create,
1920
+ activate: useCallback(async (charterText) => {
1921
+ if (!steward || busyRef.current) return;
1922
+ busyRef.current = true;
1923
+ setError(null);
1924
+ setPhase("activating");
1925
+ let current = steward;
1926
+ try {
1927
+ current = await saveCharter(steward, charterText);
1928
+ setSteward(current);
1929
+ const active = throwIfResultError(await getFluidGridsClient().mutate({
1930
+ mutation: SetStewardDraftStatusDocument,
1931
+ variables: {
1932
+ id: current.id,
1933
+ status: "ACTIVE"
1934
+ }
1935
+ })).data?.setBotmanorStewardStatus;
1936
+ if (!active) throw new Error("The Steward was not activated");
1937
+ setSteward(active);
1938
+ setPhase("active");
1939
+ } catch (failure) {
1940
+ setError(describeOperationError(failure));
1941
+ setPhase("review");
1942
+ } finally {
1943
+ busyRef.current = false;
1944
+ }
1945
+ }, [saveCharter, steward]),
1946
+ saveDraft,
1947
+ reset: useCallback(() => {
1948
+ agentIdRef.current = null;
1949
+ setSteward(null);
1950
+ setError(null);
1951
+ setPhase("idle");
1952
+ }, [])
1953
+ };
1954
+ }
1955
+ function useStewardRunImport(stewardId) {
1956
+ const stewards = useSdkQuery(StewardsForCrystalliseDocument, {
1957
+ variables: { pagination: { limit: PAGE_SIZE } },
1958
+ fetchPolicy: "cache-and-network"
1959
+ });
1960
+ const runs = useSdkQuery(StewardRunsForCrystalliseDocument, {
1961
+ variables: {
1962
+ stewardId: stewardId ?? "",
1963
+ pagination: { limit: PAGE_SIZE }
1964
+ },
1965
+ fetchPolicy: "cache-and-network",
1966
+ skip: stewardId === null
1967
+ });
1968
+ const [result, setResult] = useState(null);
1969
+ const [building, setBuilding] = useState(false);
1970
+ const [buildError, setBuildError] = useState(null);
1971
+ const buildRef = useRef(0);
1972
+ const build = useCallback(async (runId, options) => {
1973
+ const token = ++buildRef.current;
1974
+ setBuilding(true);
1975
+ setBuildError(null);
1976
+ setResult(null);
1977
+ try {
1978
+ const response = throwIfResultError(await getFluidGridsClient().query({
1979
+ query: StewardRunStepsDocument,
1980
+ variables: {
1981
+ id: runId,
1982
+ pagination: { limit: STEPS_PAGE_SIZE }
1983
+ },
1984
+ fetchPolicy: "network-only"
1985
+ }));
1986
+ if (token !== buildRef.current) return;
1987
+ const run = response.data?.getBotmanorStewardRun;
1988
+ if (!run) throw new Error("The run was not found");
1989
+ setResult(crystalliseRun({
1990
+ id: run.id,
1991
+ status: run.status,
1992
+ dryRun: run.dryRun,
1993
+ steps: run.steps
1994
+ }, options));
1995
+ } catch (failure) {
1996
+ if (token !== buildRef.current) return;
1997
+ setBuildError(describeOperationError(failure));
1998
+ } finally {
1999
+ if (token === buildRef.current) setBuilding(false);
2000
+ }
2001
+ }, []);
2002
+ const clearResult = useCallback(() => {
2003
+ buildRef.current++;
2004
+ setResult(null);
2005
+ setBuildError(null);
2006
+ setBuilding(false);
2007
+ }, []);
2008
+ return {
2009
+ stewards: {
2010
+ items: stewards.data?.listBotmanorStewards ?? [],
2011
+ loading: stewards.loading,
2012
+ error: stewards.error ? describeOperationError(stewards.error) : null
2013
+ },
2014
+ runs: {
2015
+ items: runs.data?.listBotmanorStewardRuns ?? [],
2016
+ loading: runs.loading,
2017
+ error: runs.error ? describeOperationError(runs.error) : null
2018
+ },
2019
+ result,
2020
+ building,
2021
+ buildError,
2022
+ build,
2023
+ clearResult
2024
+ };
2025
+ }
2026
+
2027
+ // src/modules/ai-studio/pages/StewardBuilderPanel.tsx
2028
+ /**
2029
+ * AI Studio, Steward mode (BOFF-16146 C5): "Build with a prompt".
2030
+ *
2031
+ * Describe a job in plain words and get a Steward: a BotManor agent with a
2032
+ * charter, created as a DRAFT. The charter is shown for review and can be
2033
+ * edited; nothing runs until the person activates the Steward. The Steward
2034
+ * lives in BotManor and is made through its public API: FluidGrids runs no
2035
+ * Steward runtime of its own, and a workflow runs the Steward with the
2036
+ * BotManor node's "runSteward" and "awaitStewardRun" operations.
2037
+ */
2038
+ function StewardBuilderPanel() {
2039
+ const tr = useTr();
2040
+ const builder = useStewardDraft();
2041
+ const { allowed: canCreate } = useFluidGridsPermission(STEWARD_PERMISSIONS.create);
2042
+ const { allowed: canUpdate } = useFluidGridsPermission(STEWARD_PERMISSIONS.update);
2043
+ const [description, setDescription] = useState("");
2044
+ const [editedCharter, setEditedCharter] = useState(null);
2045
+ const [confirming, setConfirming] = useState(false);
2046
+ const { steward, phase } = builder;
2047
+ const busy = phase === "creating" || phase === "saving" || phase === "activating";
2048
+ const savedCharter = steward?.charter.charterText ?? "";
2049
+ const charter = editedCharter ?? savedCharter;
2050
+ const problem = charterProblem(charter);
2051
+ const edited = charter.trim() !== savedCharter.trim();
2052
+ const trimmed = description.trim();
2053
+ const name = steward?.agent?.name ?? "";
2054
+ return /* @__PURE__ */ jsxs("div", {
2055
+ className: "min-h-full bg-surface-canvas p-4 sm:p-6",
2056
+ "data-testid": "steward-builder",
2057
+ children: [
2058
+ /* @__PURE__ */ jsxs("header", {
2059
+ className: "mb-6 flex flex-col gap-1",
2060
+ children: [/* @__PURE__ */ jsxs("h1", {
2061
+ className: "flex items-center gap-3 text-2xl font-semibold text-text-primary sm:text-3xl",
2062
+ children: [
2063
+ /* @__PURE__ */ jsx(ShieldCheck, {
2064
+ className: "size-6 text-action-primary-bg",
2065
+ "aria-hidden": true
2066
+ }),
2067
+ tr("fluidgrids.aiStudio.steward.title", "Build a Steward"),
2068
+ /* @__PURE__ */ jsx(Badge, {
2069
+ variant: "outline",
2070
+ children: tr("fluidgrids.aiStudio.beta", "Beta")
2071
+ })
2072
+ ]
2073
+ }), /* @__PURE__ */ jsx("p", {
2074
+ className: "text-sm text-text-secondary",
2075
+ children: tr("fluidgrids.aiStudio.steward.subtitle", "Describe a job. AI Studio drafts a Steward in BotManor, with a charter you review before it can do anything.")
2076
+ })]
2077
+ }),
2078
+ /* @__PURE__ */ jsxs("div", {
2079
+ className: "grid gap-6 lg:grid-cols-[minmax(0,2fr)_minmax(0,3fr)]",
2080
+ children: [/* @__PURE__ */ jsxs(Card, {
2081
+ className: "h-fit",
2082
+ children: [/* @__PURE__ */ jsx(CardHeader, {
2083
+ className: "pb-2",
2084
+ children: /* @__PURE__ */ jsx("h2", {
2085
+ className: "text-base font-semibold text-text-primary",
2086
+ children: tr("fluidgrids.aiStudio.steward.describeTitle", "Describe the job")
2087
+ })
2088
+ }), /* @__PURE__ */ jsxs(CardContent, {
2089
+ className: "flex flex-col gap-4",
2090
+ children: [
2091
+ /* @__PURE__ */ jsxs("div", {
2092
+ className: "flex flex-col gap-1.5",
2093
+ children: [
2094
+ /* @__PURE__ */ jsx(Label, {
2095
+ htmlFor: "steward-description",
2096
+ className: "sr-only",
2097
+ children: tr("fluidgrids.aiStudio.steward.descriptionLabel", "What should the Steward do?")
2098
+ }),
2099
+ /* @__PURE__ */ jsx(Textarea, {
2100
+ id: "steward-description",
2101
+ "data-testid": "steward-description",
2102
+ rows: 7,
2103
+ maxLength: STEWARD_DESCRIPTION_MAX_LENGTH,
2104
+ value: description,
2105
+ disabled: busy || steward !== null,
2106
+ placeholder: tr("fluidgrids.aiStudio.steward.descriptionPlaceholder", "Every morning, read the new emails in the support inbox and draft a reply for each question. Never send anything."),
2107
+ onChange: (event) => setDescription(event.target.value)
2108
+ }),
2109
+ /* @__PURE__ */ jsxs("span", {
2110
+ className: "self-end text-xs text-text-secondary",
2111
+ children: [
2112
+ description.length,
2113
+ "/",
2114
+ STEWARD_DESCRIPTION_MAX_LENGTH
2115
+ ]
2116
+ })
2117
+ ]
2118
+ }),
2119
+ builder.error && phase === "idle" && /* @__PURE__ */ jsx("div", {
2120
+ role: "alert",
2121
+ "data-testid": "steward-error",
2122
+ className: "rounded-md border border-status-error-border bg-status-error-bg-subtle p-3 text-sm text-status-error-text",
2123
+ children: builder.error
2124
+ }),
2125
+ /* @__PURE__ */ jsxs("div", {
2126
+ className: "flex flex-wrap gap-2",
2127
+ children: [/* @__PURE__ */ jsxs(Button, {
2128
+ "data-testid": "steward-create",
2129
+ disabled: !trimmed || busy || steward !== null || !canCreate,
2130
+ title: canCreate ? void 0 : tr("fluidgrids.aiStudio.steward.noPermission", "Your role cannot create Stewards"),
2131
+ onClick: () => void builder.create(description),
2132
+ className: "flex grow gap-2",
2133
+ children: [phase === "creating" ? /* @__PURE__ */ jsx(SpinnerIcon, { className: "size-4 animate-spin" }) : /* @__PURE__ */ jsx(Sparkles, { className: "size-4" }), phase === "creating" ? tr("fluidgrids.aiStudio.steward.creating", "Drafting…") : tr("fluidgrids.aiStudio.steward.create", "Draft Steward")]
2134
+ }), steward && phase !== "active" && /* @__PURE__ */ jsx(Button, {
2135
+ variant: "outline",
2136
+ "data-testid": "steward-start-over",
2137
+ disabled: busy,
2138
+ onClick: () => {
2139
+ builder.reset();
2140
+ setEditedCharter(null);
2141
+ },
2142
+ children: tr("fluidgrids.aiStudio.steward.startOver", "Start over")
2143
+ })]
2144
+ }),
2145
+ !steward && /* @__PURE__ */ jsxs("section", {
2146
+ className: "flex flex-col gap-2",
2147
+ "data-testid": "steward-examples",
2148
+ children: [/* @__PURE__ */ jsxs("h3", {
2149
+ className: "flex items-center gap-2 text-sm font-medium text-text-primary",
2150
+ children: [/* @__PURE__ */ jsx(Lightbulb, {
2151
+ className: "size-4",
2152
+ "aria-hidden": true
2153
+ }), tr("fluidgrids.aiStudio.examplesTitle", "Try an example")]
2154
+ }), /* @__PURE__ */ jsx("div", {
2155
+ className: "flex flex-wrap gap-2",
2156
+ children: STEWARD_EXAMPLES.map((example) => /* @__PURE__ */ jsx(Button, {
2157
+ variant: "outline",
2158
+ size: "sm",
2159
+ "data-testid": `steward-example-${example.id}`,
2160
+ onClick: () => setDescription(tr(example.descriptionKey, example.description)),
2161
+ children: tr(example.labelKey, example.label)
2162
+ }, example.id))
2163
+ })]
2164
+ })
2165
+ ]
2166
+ })]
2167
+ }), /* @__PURE__ */ jsxs(Card, {
2168
+ className: "flex min-w-0 flex-col",
2169
+ "data-testid": "steward-review",
2170
+ children: [/* @__PURE__ */ jsx(CardHeader, {
2171
+ className: "flex flex-row flex-wrap items-center justify-between gap-2 pb-2",
2172
+ children: /* @__PURE__ */ jsxs("div", {
2173
+ className: "flex min-w-0 items-center gap-2",
2174
+ children: [/* @__PURE__ */ jsx(Badge, {
2175
+ variant: "secondary",
2176
+ children: steward ? statusLabel(tr, steward.status) : tr("fluidgrids.aiStudio.draftBadge", "Draft")
2177
+ }), /* @__PURE__ */ jsx("h2", {
2178
+ className: "truncate text-base font-semibold text-text-primary",
2179
+ "data-testid": "steward-name",
2180
+ children: name || tr("fluidgrids.aiStudio.steward.reviewTitle", "Charter review")
2181
+ })]
2182
+ })
2183
+ }), /* @__PURE__ */ jsx(CardContent, {
2184
+ className: "flex flex-col gap-4",
2185
+ children: phase === "creating" ? /* @__PURE__ */ jsxs("div", {
2186
+ className: "flex h-60 flex-col items-center justify-center gap-3 text-center text-sm text-text-secondary",
2187
+ "data-testid": "steward-state-creating",
2188
+ children: [/* @__PURE__ */ jsx(SpinnerIcon, { className: "size-6 animate-spin" }), /* @__PURE__ */ jsx("p", { children: tr("fluidgrids.aiStudio.steward.creatingHint", "Creating the agent and its draft charter in BotManor.") })]
2189
+ }) : !steward ? /* @__PURE__ */ jsx("div", {
2190
+ "data-testid": "steward-state-idle",
2191
+ children: /* @__PURE__ */ jsx(EmptyState, {
2192
+ kind: "first-use",
2193
+ illustration: "assistant",
2194
+ size: "panel",
2195
+ icon: /* @__PURE__ */ jsx(Sparkles, {
2196
+ className: "size-6",
2197
+ "aria-hidden": "true"
2198
+ }),
2199
+ title: tr("fluidgrids.aiStudio.steward.emptyHint", "Your Steward's charter appears here for you to read and edit before it goes live.")
2200
+ })
2201
+ }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
2202
+ /* @__PURE__ */ jsxs("dl", {
2203
+ className: "grid grid-cols-1 gap-2 text-sm sm:grid-cols-2",
2204
+ "data-testid": "steward-settings",
2205
+ children: [
2206
+ /* @__PURE__ */ jsx(Setting, {
2207
+ label: tr("fluidgrids.aiStudio.steward.autonomy", "Autonomy"),
2208
+ value: autonomyLabel(tr, steward.charter.autonomyLevel)
2209
+ }),
2210
+ /* @__PURE__ */ jsx(Setting, {
2211
+ label: tr("fluidgrids.aiStudio.steward.tools", "Tools"),
2212
+ value: steward.charter.allowedToolKeys.length === 0 ? tr("fluidgrids.aiStudio.steward.noTools", "None yet") : String(steward.charter.allowedToolKeys.length)
2213
+ }),
2214
+ /* @__PURE__ */ jsx(Setting, {
2215
+ label: tr("fluidgrids.aiStudio.steward.dryRun", "Dry run by default"),
2216
+ value: steward.charter.dryRunDefault ? tr("fluidgrids.aiStudio.steward.yes", "Yes") : tr("fluidgrids.aiStudio.steward.no", "No")
2217
+ }),
2218
+ /* @__PURE__ */ jsx(Setting, {
2219
+ label: tr("fluidgrids.aiStudio.steward.timezone", "Time zone"),
2220
+ value: steward.charter.timezone
2221
+ })
2222
+ ]
2223
+ }),
2224
+ /* @__PURE__ */ jsxs("div", {
2225
+ className: "flex flex-col gap-1.5",
2226
+ children: [
2227
+ /* @__PURE__ */ jsx(Label, {
2228
+ htmlFor: "steward-charter",
2229
+ children: tr("fluidgrids.aiStudio.steward.charterLabel", "Charter")
2230
+ }),
2231
+ /* @__PURE__ */ jsx(Textarea, {
2232
+ id: "steward-charter",
2233
+ "data-testid": "steward-charter",
2234
+ rows: 12,
2235
+ value: charter,
2236
+ disabled: busy || phase === "active" || !canUpdate,
2237
+ onChange: (event) => setEditedCharter(event.target.value),
2238
+ "aria-invalid": problem !== null
2239
+ }),
2240
+ /* @__PURE__ */ jsxs("span", {
2241
+ className: "flex justify-between text-xs text-text-secondary",
2242
+ children: [/* @__PURE__ */ jsx("span", { children: problem === "empty" ? tr("fluidgrids.aiStudio.steward.charterEmpty", "The charter cannot be empty.") : problem === "too_long" ? tr("fluidgrids.aiStudio.steward.charterTooLong", "The charter is too long.") : "" }), /* @__PURE__ */ jsxs("span", { children: [
2243
+ charter.length,
2244
+ "/",
2245
+ STEWARD_CHARTER_MAX_LENGTH
2246
+ ] })]
2247
+ })
2248
+ ]
2249
+ }),
2250
+ builder.error && /* @__PURE__ */ jsx("div", {
2251
+ role: "alert",
2252
+ "data-testid": "steward-error",
2253
+ className: "rounded-md border border-status-error-border bg-status-error-bg-subtle p-3 text-sm text-status-error-text",
2254
+ children: builder.error
2255
+ }),
2256
+ phase === "active" ? /* @__PURE__ */ jsxs("div", {
2257
+ className: "flex items-start gap-2 rounded-md border border-status-success-border bg-status-success-bg-subtle p-3 text-sm text-status-success-text",
2258
+ "data-testid": "steward-activated",
2259
+ role: "status",
2260
+ children: [/* @__PURE__ */ jsx(CheckCircle2, {
2261
+ className: "mt-0.5 size-4 shrink-0",
2262
+ "aria-hidden": true
2263
+ }), /* @__PURE__ */ jsxs("p", { children: [
2264
+ tr("fluidgrids.aiStudio.steward.activated", "The Steward is active in BotManor. Add its BotManor node to a workflow and use Run Steward with this Steward's ID to start it:"),
2265
+ " ",
2266
+ /* @__PURE__ */ jsx("code", {
2267
+ className: "break-all text-xs",
2268
+ children: steward.id
2269
+ })
2270
+ ] })]
2271
+ }) : /* @__PURE__ */ jsxs("div", {
2272
+ className: "flex flex-wrap items-center gap-2",
2273
+ children: [
2274
+ /* @__PURE__ */ jsxs(Button, {
2275
+ "data-testid": "steward-activate",
2276
+ disabled: busy || problem !== null || !canUpdate,
2277
+ onClick: () => setConfirming(true),
2278
+ className: "flex gap-2",
2279
+ children: [phase === "activating" && /* @__PURE__ */ jsx(SpinnerIcon, { className: "size-4 animate-spin" }), tr("fluidgrids.aiStudio.steward.activate", "Activate")]
2280
+ }),
2281
+ /* @__PURE__ */ jsx(Button, {
2282
+ variant: "outline",
2283
+ "data-testid": "steward-save-draft",
2284
+ disabled: busy || problem !== null || !edited || !canUpdate,
2285
+ onClick: () => void builder.saveDraft(charter),
2286
+ children: phase === "saving" ? tr("fluidgrids.aiStudio.steward.saving", "Saving…") : tr("fluidgrids.aiStudio.steward.saveDraft", "Save charter")
2287
+ }),
2288
+ /* @__PURE__ */ jsx("span", {
2289
+ className: "text-xs text-text-secondary sm:ml-auto",
2290
+ children: tr("fluidgrids.aiStudio.steward.draftNote", "A draft Steward does nothing. It stays in BotManor until you activate it.")
2291
+ })
2292
+ ]
2293
+ })
2294
+ ] })
2295
+ })]
2296
+ })]
2297
+ }),
2298
+ /* @__PURE__ */ jsx(AlertDialog, {
2299
+ open: confirming,
2300
+ onOpenChange: setConfirming,
2301
+ children: /* @__PURE__ */ jsxs(AlertDialogContent, {
2302
+ "data-testid": "steward-confirm",
2303
+ children: [/* @__PURE__ */ jsxs(AlertDialogHeader, { children: [/* @__PURE__ */ jsx(AlertDialogTitle, { children: tr("fluidgrids.aiStudio.steward.confirmTitle", "Activate this Steward?") }), /* @__PURE__ */ jsx(AlertDialogDescription, { children: tr("fluidgrids.aiStudio.steward.confirmBody", "An active Steward can be run by anyone who may run Stewards in this workspace. It asks before it acts and has no tools until you add them in BotManor.") })] }), /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [/* @__PURE__ */ jsx(AlertDialogCancel, { children: tr("fluidgrids.aiStudio.steward.cancel", "Cancel") }), /* @__PURE__ */ jsx(AlertDialogAction, {
2304
+ "data-testid": "steward-confirm-activate",
2305
+ onClick: () => void builder.activate(charter),
2306
+ children: tr("fluidgrids.aiStudio.steward.activate", "Activate")
2307
+ })] })]
2308
+ })
2309
+ })
2310
+ ]
2311
+ });
2312
+ }
2313
+ function Setting({ label, value }) {
2314
+ return /* @__PURE__ */ jsxs("div", {
2315
+ className: "flex flex-col rounded-md border border-border-default bg-surface-sunken p-2",
2316
+ children: [/* @__PURE__ */ jsx("dt", {
2317
+ className: "text-xs text-text-secondary",
2318
+ children: label
2319
+ }), /* @__PURE__ */ jsx("dd", {
2320
+ className: "text-text-primary",
2321
+ children: value
2322
+ })]
2323
+ });
2324
+ }
2325
+ function statusLabel(tr, status) {
2326
+ switch (status) {
2327
+ case "ACTIVE": return tr("fluidgrids.aiStudio.steward.status.active", "Active");
2328
+ case "PAUSED": return tr("fluidgrids.aiStudio.steward.status.paused", "Paused");
2329
+ case "ARCHIVED": return tr("fluidgrids.aiStudio.steward.status.archived", "Archived");
2330
+ default: return tr("fluidgrids.aiStudio.steward.status.draft", "Draft");
2331
+ }
2332
+ }
2333
+ function autonomyLabel(tr, level) {
2334
+ switch (level) {
2335
+ case "OBSERVE": return tr("fluidgrids.aiStudio.steward.autonomyObserve", "Observe only");
2336
+ case "GUIDED": return tr("fluidgrids.aiStudio.steward.autonomyGuided", "Guided");
2337
+ case "TRUSTED": return tr("fluidgrids.aiStudio.steward.autonomyTrusted", "Trusted");
2338
+ default: return tr("fluidgrids.aiStudio.steward.autonomyAsk", "Asks before acting");
2339
+ }
2340
+ }
2341
+
2342
+ // src/modules/ai-studio/lib/ai-studio.ts
2343
+ /** The version every workflow saved from AI Studio starts at. */
2344
+ const AI_STUDIO_DRAFT_VERSION = "v1";
2345
+ const AI_STUDIO_EXAMPLES = [
2346
+ {
2347
+ id: "payment-to-crm",
2348
+ labelKey: "fluidgrids.aiStudio.examples.paymentToCrm.label",
2349
+ label: "Payment to CRM and chat",
2350
+ promptKey: "fluidgrids.aiStudio.examples.paymentToCrm.prompt",
2351
+ prompt: "When a new Stripe payment succeeds, add the customer to HubSpot and post a summary to Slack #sales."
2352
+ },
2353
+ {
2354
+ id: "daily-digest",
2355
+ labelKey: "fluidgrids.aiStudio.examples.dailyDigest.label",
2356
+ label: "Daily order digest",
2357
+ promptKey: "fluidgrids.aiStudio.examples.dailyDigest.prompt",
2358
+ prompt: "Every weekday at 9am, fetch new orders from our API, keep the ones over 500 and post a summary to a webhook. Log the rest."
2359
+ },
2360
+ {
2361
+ id: "webhook-triage",
2362
+ labelKey: "fluidgrids.aiStudio.examples.webhookTriage.label",
2363
+ label: "Triage incoming requests",
2364
+ promptKey: "fluidgrids.aiStudio.examples.webhookTriage.prompt",
2365
+ prompt: "When a webhook receives a support request, check the priority field. Send urgent requests to our escalation API and log everything else."
2366
+ }
2367
+ ];
2368
+ const AI_STUDIO_REFINEMENTS = [
2369
+ {
2370
+ id: "error-handling",
2371
+ labelKey: "fluidgrids.aiStudio.refinements.errorHandling",
2372
+ label: "Add error handling",
2373
+ instruction: "Add error handling: when a step that calls an external service fails, route the failure to a separate branch that logs the error instead of stopping silently."
2374
+ },
2375
+ {
2376
+ id: "notify-on-failure",
2377
+ labelKey: "fluidgrids.aiStudio.refinements.notifyOnFailure",
2378
+ label: "Notify on failure",
2379
+ instruction: "Notify someone when the workflow fails: add a step that sends the error details to a notification webhook."
2380
+ },
2381
+ {
2382
+ id: "log-result",
2383
+ labelKey: "fluidgrids.aiStudio.refinements.logResult",
2384
+ label: "Log the result",
2385
+ instruction: "Add a final step that logs a short summary of what the workflow did."
2386
+ }
2387
+ ];
2388
+ function clamp(text) {
2389
+ return text.length > 4e3 ? text.slice(0, AI_DRAFT_MAX_PROMPT_LENGTH) : text;
2390
+ }
2391
+ /**
2392
+ * The request for a refinement of the current draft: the original request
2393
+ * plus the change. The draft itself goes to the server as
2394
+ * `baseDefinitionJson`, so the model edits it rather than starting over.
2395
+ */
2396
+ function buildRefinementPrompt(originalPrompt, instruction) {
2397
+ return clamp(`${originalPrompt.trim()}\n\nChange: ${instruction.trim()}`);
2398
+ }
2399
+ /**
2400
+ * The request after the user answered some of the model's clarifying
2401
+ * questions. Unanswered questions are left out; null when nothing was
2402
+ * answered, so the caller keeps the button disabled.
2403
+ */
2404
+ function buildAnsweredPrompt(originalPrompt, questions, answers) {
2405
+ const lines = questions.flatMap((question, index) => {
2406
+ const answer = (answers[index] ?? "").trim();
2407
+ return answer === "" ? [] : [`- ${question} ${answer}`];
2408
+ });
2409
+ if (lines.length === 0) return null;
2410
+ return clamp(`${originalPrompt.trim()}\n\nAnswers to your questions:\n${lines.join("\n")}`);
2411
+ }
2412
+ function isRecord(value) {
2413
+ return typeof value === "object" && value !== null && !Array.isArray(value);
2414
+ }
2415
+ /** The draft's nodes as readable steps; entries without an id or type are skipped. */
2416
+ function draftSteps(definitionJson) {
2417
+ const data = isRecord(definitionJson) && isRecord(definitionJson.data) ? definitionJson.data : {};
2418
+ return (Array.isArray(data.nodes) ? data.nodes : []).filter(isRecord).flatMap((node) => {
2419
+ if (typeof node.id !== "string" || typeof node.type !== "string") return [];
2420
+ const nodeData = isRecord(node.data) ? node.data : {};
2421
+ let label = node.id;
2422
+ if (typeof nodeData.label === "string" && nodeData.label.trim() !== "") label = nodeData.label;
2423
+ else if (typeof node.label === "string" && node.label.trim() !== "") label = node.label;
2424
+ return [{
2425
+ id: node.id,
2426
+ label,
2427
+ type: node.type
2428
+ }];
2429
+ });
2430
+ }
2431
+ /**
2432
+ * The `createWorkflowDefinition` input that saves a draft as a new DRAFT
2433
+ * workflow under `key`. Same shape the server writes when a proposal is
2434
+ * applied as a new workflow: the generated definition with its key replaced.
2435
+ * Nothing is activated.
2436
+ */
2437
+ function draftCreateInput(draft, key) {
2438
+ const name = draft.name.trim() || "Generated workflow";
2439
+ const description = draft.description.trim() || name;
2440
+ return {
2441
+ workflowKey: key,
2442
+ version: "v1",
2443
+ name,
2444
+ description,
2445
+ definitionJson: {
2446
+ ...draft.definitionJson,
2447
+ key,
2448
+ name,
2449
+ description
2450
+ }
2451
+ };
2452
+ }
2453
+ /** The page phase for a generation status (the wire enum's string). */
2454
+ function phaseOf(status, working) {
2455
+ if (working || status === "PROCESSING") return "generating";
2456
+ if (status === "COMPLETED") return "ready";
2457
+ if (status === "FAILED") return "failed";
2458
+ if (status === "CANCELLED") return "cancelled";
2459
+ return "idle";
2460
+ }
2461
+
2462
+ // src/modules/ai-studio/pages/StewardRunImportPanel.tsx
2463
+ /**
2464
+ * AI Studio, "From a Steward run" mode (BOFF-16146 C5): crystallise a Steward
2465
+ * run into a workflow.
2466
+ *
2467
+ * Pick a Steward and one of its finished runs. The connector calls it made
2468
+ * become a workflow that makes the same calls in the same order with no model
2469
+ * call, drawn on the read-only canvas for review. The workflow is saved as a
2470
+ * DRAFT only when the person chooses "Edit in builder", and is never
2471
+ * activated. See `steward-crystallise.ts` for exactly what is replayed.
2472
+ */
2473
+ const DEFAULT_NAME = "Replay of a Steward run";
2474
+ function StewardRunImportPanel() {
2475
+ const tr = useTr();
2476
+ const navigate = useNavigate();
2477
+ const { createWorkflow } = useCreateWorkflow();
2478
+ const { allowed: canRead } = useFluidGridsPermission(STEWARD_PERMISSIONS.read);
2479
+ const { allowed: canCreate } = useFluidGridsPermission(FLUIDGRIDS_PERMISSIONS.WORKFLOW_CREATE);
2480
+ const [stewardId, setStewardId] = useState(null);
2481
+ const [runId, setRunId] = useState(null);
2482
+ const [name, setName] = useState("");
2483
+ const [saving, setSaving] = useState(false);
2484
+ const [refusal, setRefusal] = useState(null);
2485
+ const importer = useStewardRunImport(canRead ? stewardId : null);
2486
+ const [previewKey] = useState(() => v4());
2487
+ const { result } = importer;
2488
+ const workflowName = name.trim() || tr("fluidgrids.aiStudio.run.defaultName", DEFAULT_NAME);
2489
+ const definition = result?.ok ? result.definitionJson : null;
2490
+ const report = result?.report ?? null;
2491
+ const steps = useMemo(() => (report?.included ?? []).map((step) => ({
2492
+ ...step,
2493
+ missing: (report?.missing ?? []).filter((entry) => entry.nodeId === step.nodeId).map((entry) => entry.field)
2494
+ })), [report]);
2495
+ const handleBuild = useCallback(() => {
2496
+ if (!runId) return;
2497
+ importer.build(runId, {
2498
+ key: previewKey,
2499
+ name: workflowName
2500
+ });
2501
+ }, [
2502
+ importer,
2503
+ previewKey,
2504
+ runId,
2505
+ workflowName
2506
+ ]);
2507
+ const handleEditInBuilder = useCallback(async () => {
2508
+ if (!definition) return;
2509
+ setSaving(true);
2510
+ let reported = null;
2511
+ try {
2512
+ const created = await createWorkflow(draftCreateInput({
2513
+ name: workflowName,
2514
+ description: String(definition.description ?? ""),
2515
+ definitionJson: definition
2516
+ }, v4()), { onError: (error) => {
2517
+ reported = error;
2518
+ } });
2519
+ if (!created?.workflowKey || !created.version) {
2520
+ setRefusal(classifyCreateRefusal(reported));
2521
+ return;
2522
+ }
2523
+ toast.success(tr("fluidgrids.aiStudio.savedToast", "Draft saved as a new workflow"), { description: tr("fluidgrids.aiStudio.run.savedToastDescription", "Nothing is live yet. Pick a connection for each step, run a test, then activate it.") });
2524
+ navigate(builderPathOf(created, ".."));
2525
+ } finally {
2526
+ setSaving(false);
2527
+ }
2528
+ }, [
2529
+ createWorkflow,
2530
+ definition,
2531
+ navigate,
2532
+ tr,
2533
+ workflowName
2534
+ ]);
2535
+ return /* @__PURE__ */ jsxs("div", {
2536
+ className: "min-h-full bg-surface-canvas p-4 sm:p-6",
2537
+ "data-testid": "steward-run-import",
2538
+ children: [
2539
+ /* @__PURE__ */ jsxs("header", {
2540
+ className: "mb-6 flex flex-col gap-1",
2541
+ children: [
2542
+ /* @__PURE__ */ jsxs("h1", {
2543
+ className: "flex items-center gap-3 text-2xl font-semibold text-text-primary sm:text-3xl",
2544
+ children: [
2545
+ /* @__PURE__ */ jsx(Sparkles, {
2546
+ className: "size-6 text-action-primary-bg",
2547
+ "aria-hidden": true
2548
+ }),
2549
+ tr("fluidgrids.aiStudio.run.title", "Workflow from a Steward run"),
2550
+ /* @__PURE__ */ jsx(Badge, {
2551
+ variant: "outline",
2552
+ children: tr("fluidgrids.aiStudio.beta", "Beta")
2553
+ })
2554
+ ]
2555
+ }),
2556
+ /* @__PURE__ */ jsx("p", {
2557
+ className: "text-sm text-text-secondary",
2558
+ children: tr("fluidgrids.aiStudio.run.subtitle", "Turn a Steward run that worked into a workflow that repeats its connector calls with no model call.")
2559
+ }),
2560
+ /* @__PURE__ */ jsx("p", {
2561
+ className: "text-xs text-text-muted",
2562
+ "data-testid": "steward-run-limits",
2563
+ children: tr("fluidgrids.aiStudio.run.limits", "The workflow repeats the exact connector calls the run made, with the values the run used. It does not look anything up again, so values such as ids found by an earlier step stay fixed, and arguments BotManor hid or cut are left for you to fill in. Desk actions are not repeated here; to replay those with no model call, run the Steward with a playbook that has saved steps.")
2564
+ })
2565
+ ]
2566
+ }),
2567
+ !canRead ? /* @__PURE__ */ jsx("div", {
2568
+ "data-testid": "steward-run-no-access",
2569
+ children: /* @__PURE__ */ jsx(EmptyState, {
2570
+ kind: "no-access",
2571
+ size: "page",
2572
+ title: tr("fluidgrids.aiStudio.run.noAccess", "Your role cannot read Steward runs.")
2573
+ })
2574
+ }) : /* @__PURE__ */ jsxs("div", {
2575
+ className: "grid gap-6 lg:grid-cols-[minmax(0,2fr)_minmax(0,3fr)]",
2576
+ children: [/* @__PURE__ */ jsxs(Card, {
2577
+ className: "h-fit",
2578
+ children: [/* @__PURE__ */ jsx(CardHeader, {
2579
+ className: "pb-2",
2580
+ children: /* @__PURE__ */ jsx("h2", {
2581
+ className: "text-base font-semibold text-text-primary",
2582
+ children: tr("fluidgrids.aiStudio.run.pickTitle", "Choose a run")
2583
+ })
2584
+ }), /* @__PURE__ */ jsxs(CardContent, {
2585
+ className: "flex flex-col gap-4",
2586
+ children: [
2587
+ /* @__PURE__ */ jsxs("div", {
2588
+ className: "flex flex-col gap-1.5",
2589
+ children: [/* @__PURE__ */ jsx(Label, {
2590
+ htmlFor: "steward-run-steward",
2591
+ children: tr("fluidgrids.aiStudio.run.stewardLabel", "Steward")
2592
+ }), importer.stewards.error ? /* @__PURE__ */ jsx(ErrorNote, {
2593
+ testId: "steward-run-stewards-error",
2594
+ message: importer.stewards.error
2595
+ }) : importer.stewards.loading ? /* @__PURE__ */ jsx(Loading, { label: tr("fluidgrids.aiStudio.run.loadingStewards", "Loading Stewards…") }) : importer.stewards.items.length === 0 ? /* @__PURE__ */ jsx("div", {
2596
+ "data-testid": "steward-run-no-stewards",
2597
+ children: /* @__PURE__ */ jsx(EmptyState, {
2598
+ kind: "first-use",
2599
+ size: "inline",
2600
+ icon: null,
2601
+ title: tr("fluidgrids.aiStudio.run.noStewards", "There are no Stewards in this workspace yet. Build one first.")
2602
+ })
2603
+ }) : /* @__PURE__ */ jsxs(Select, {
2604
+ value: stewardId ?? void 0,
2605
+ onValueChange: (value) => {
2606
+ setStewardId(value);
2607
+ setRunId(null);
2608
+ importer.clearResult();
2609
+ },
2610
+ children: [/* @__PURE__ */ jsx(SelectTrigger, {
2611
+ id: "steward-run-steward",
2612
+ "data-testid": "steward-run-steward",
2613
+ children: /* @__PURE__ */ jsx(SelectValue, { placeholder: tr("fluidgrids.aiStudio.run.stewardPlaceholder", "Choose a Steward") })
2614
+ }), /* @__PURE__ */ jsx(SelectContent, { children: importer.stewards.items.map((steward) => /* @__PURE__ */ jsx(SelectItem, {
2615
+ value: steward.id,
2616
+ children: steward.agent?.name ?? steward.id
2617
+ }, steward.id)) })]
2618
+ })]
2619
+ }),
2620
+ stewardId && /* @__PURE__ */ jsxs("div", {
2621
+ className: "flex flex-col gap-1.5",
2622
+ children: [/* @__PURE__ */ jsx(Label, {
2623
+ htmlFor: "steward-run-run",
2624
+ children: tr("fluidgrids.aiStudio.run.runLabel", "Finished run")
2625
+ }), importer.runs.error ? /* @__PURE__ */ jsx(ErrorNote, {
2626
+ testId: "steward-run-runs-error",
2627
+ message: importer.runs.error
2628
+ }) : importer.runs.loading ? /* @__PURE__ */ jsx(Loading, { label: tr("fluidgrids.aiStudio.run.loadingRuns", "Loading runs…") }) : importer.runs.items.length === 0 ? /* @__PURE__ */ jsx("div", {
2629
+ "data-testid": "steward-run-no-runs",
2630
+ children: /* @__PURE__ */ jsx(EmptyState, {
2631
+ kind: "first-use",
2632
+ size: "inline",
2633
+ icon: null,
2634
+ title: tr("fluidgrids.aiStudio.run.noRuns", "This Steward has no finished runs yet.")
2635
+ })
2636
+ }) : /* @__PURE__ */ jsxs(Select, {
2637
+ value: runId ?? void 0,
2638
+ onValueChange: (value) => {
2639
+ setRunId(value);
2640
+ importer.clearResult();
2641
+ },
2642
+ children: [/* @__PURE__ */ jsx(SelectTrigger, {
2643
+ id: "steward-run-run",
2644
+ "data-testid": "steward-run-run",
2645
+ children: /* @__PURE__ */ jsx(SelectValue, { placeholder: tr("fluidgrids.aiStudio.run.runPlaceholder", "Choose a run") })
2646
+ }), /* @__PURE__ */ jsx(SelectContent, { children: importer.runs.items.map((run) => /* @__PURE__ */ jsx(SelectItem, {
2647
+ value: run.id,
2648
+ children: runLabel(tr, run.finishedAt ?? run.createdAt, run.stepCount)
2649
+ }, run.id)) })]
2650
+ })]
2651
+ }),
2652
+ /* @__PURE__ */ jsxs("div", {
2653
+ className: "flex flex-col gap-1.5",
2654
+ children: [/* @__PURE__ */ jsx(Label, {
2655
+ htmlFor: "steward-run-name",
2656
+ children: tr("fluidgrids.aiStudio.run.nameLabel", "Workflow name")
2657
+ }), /* @__PURE__ */ jsx(Input, {
2658
+ id: "steward-run-name",
2659
+ "data-testid": "steward-run-name",
2660
+ value: name,
2661
+ maxLength: 120,
2662
+ placeholder: tr("fluidgrids.aiStudio.run.defaultName", DEFAULT_NAME),
2663
+ onChange: (event) => setName(event.target.value)
2664
+ })]
2665
+ }),
2666
+ /* @__PURE__ */ jsxs(Button, {
2667
+ "data-testid": "steward-run-build",
2668
+ disabled: !runId || importer.building,
2669
+ onClick: handleBuild,
2670
+ className: "flex gap-2",
2671
+ children: [importer.building ? /* @__PURE__ */ jsx(SpinnerIcon, { className: "size-4 animate-spin" }) : /* @__PURE__ */ jsx(Sparkles, { className: "size-4" }), tr("fluidgrids.aiStudio.run.build", "Build workflow")]
2672
+ }),
2673
+ importer.buildError && /* @__PURE__ */ jsx(ErrorNote, {
2674
+ testId: "steward-run-build-error",
2675
+ message: importer.buildError
2676
+ })
2677
+ ]
2678
+ })]
2679
+ }), /* @__PURE__ */ jsxs(Card, {
2680
+ className: "flex min-w-0 flex-col",
2681
+ "data-testid": "steward-run-preview",
2682
+ children: [/* @__PURE__ */ jsxs(CardHeader, {
2683
+ className: "flex flex-row items-center gap-2 pb-2",
2684
+ children: [/* @__PURE__ */ jsx(Badge, {
2685
+ variant: "secondary",
2686
+ children: tr("fluidgrids.aiStudio.draftBadge", "Draft")
2687
+ }), /* @__PURE__ */ jsx("h2", {
2688
+ className: "truncate text-base font-semibold text-text-primary",
2689
+ children: definition ? workflowName : tr("fluidgrids.aiStudio.draftEmpty", "No draft yet")
2690
+ })]
2691
+ }), /* @__PURE__ */ jsxs(CardContent, {
2692
+ className: "flex flex-col gap-4",
2693
+ children: [
2694
+ /* @__PURE__ */ jsx("div", {
2695
+ className: "relative h-[320px] w-full overflow-hidden rounded-lg border border-border-default sm:h-[400px]",
2696
+ children: definition ? /* @__PURE__ */ jsx(DraftCanvas, {
2697
+ generationId: previewKey,
2698
+ name: workflowName,
2699
+ definitionJson: definition
2700
+ }) : result && !result.ok ? /* @__PURE__ */ jsx("div", {
2701
+ role: "alert",
2702
+ "data-testid": "steward-run-refused",
2703
+ children: /* @__PURE__ */ jsx(EmptyState, {
2704
+ kind: "error",
2705
+ size: "panel",
2706
+ icon: /* @__PURE__ */ jsx(TriangleAlert, {
2707
+ className: "size-6 text-status-error-text",
2708
+ "aria-hidden": "true"
2709
+ }),
2710
+ title: refusalText(tr, result.refusal)
2711
+ })
2712
+ }) : /* @__PURE__ */ jsx("div", {
2713
+ "data-testid": "steward-run-state-idle",
2714
+ children: /* @__PURE__ */ jsx(EmptyState, {
2715
+ kind: "first-use",
2716
+ illustration: "assistant",
2717
+ size: "panel",
2718
+ icon: /* @__PURE__ */ jsx(Sparkles, {
2719
+ className: "size-6",
2720
+ "aria-hidden": "true"
2721
+ }),
2722
+ title: tr("fluidgrids.aiStudio.run.emptyHint", "Choose a finished run and build it. The workflow appears here for review.")
2723
+ })
2724
+ })
2725
+ }),
2726
+ report && report.included.length > 0 && /* @__PURE__ */ jsx("ol", {
2727
+ className: "flex flex-col gap-1 text-sm",
2728
+ "data-testid": "steward-run-steps",
2729
+ children: steps.map((step, index) => /* @__PURE__ */ jsxs("li", {
2730
+ className: "flex flex-wrap items-center gap-2 text-text-primary",
2731
+ children: [
2732
+ /* @__PURE__ */ jsx(CheckCircle2, {
2733
+ className: "size-4 shrink-0 text-status-success-text",
2734
+ "aria-hidden": true
2735
+ }),
2736
+ /* @__PURE__ */ jsxs("span", {
2737
+ className: "text-text-secondary",
2738
+ children: [index + 1, "."]
2739
+ }),
2740
+ /* @__PURE__ */ jsx("span", {
2741
+ className: "truncate",
2742
+ children: step.operation
2743
+ }),
2744
+ /* @__PURE__ */ jsx("span", {
2745
+ className: "text-xs text-text-secondary",
2746
+ children: step.nodeType
2747
+ }),
2748
+ step.missing.length > 0 && /* @__PURE__ */ jsx(Badge, {
2749
+ variant: "outline",
2750
+ children: tr("fluidgrids.aiStudio.run.needsValue", "Fill in: {{fields}}", { fields: step.missing.join(", ") })
2751
+ })
2752
+ ]
2753
+ }, step.nodeId))
2754
+ }),
2755
+ report && report.skipped.length > 0 && /* @__PURE__ */ jsxs("div", {
2756
+ className: "rounded-md border border-status-warning-border bg-status-warning-bg-subtle p-3 text-sm text-status-warning-text",
2757
+ "data-testid": "steward-run-skipped",
2758
+ children: [/* @__PURE__ */ jsx("p", {
2759
+ className: "font-medium",
2760
+ children: tr("fluidgrids.aiStudio.run.skippedTitle", "Not replayed")
2761
+ }), /* @__PURE__ */ jsx("ul", {
2762
+ className: "mt-1 flex flex-col gap-0.5 text-xs",
2763
+ children: report.skipped.map((step) => /* @__PURE__ */ jsxs("li", {
2764
+ className: "flex items-center gap-1.5",
2765
+ children: [/* @__PURE__ */ jsx(SkipForward, {
2766
+ className: "size-3 shrink-0",
2767
+ "aria-hidden": true
2768
+ }), /* @__PURE__ */ jsxs("span", { children: [
2769
+ step.toolKey ?? `#${step.seq}`,
2770
+ ": ",
2771
+ skipText(tr, step.reason)
2772
+ ] })]
2773
+ }, step.seq))
2774
+ })]
2775
+ }),
2776
+ /* @__PURE__ */ jsxs("div", {
2777
+ className: "flex flex-wrap items-center gap-2",
2778
+ children: [/* @__PURE__ */ jsxs(Button, {
2779
+ "data-testid": "steward-run-edit-in-builder",
2780
+ disabled: !definition || saving || !canCreate,
2781
+ onClick: () => void handleEditInBuilder(),
2782
+ className: "flex gap-2",
2783
+ children: [saving ? /* @__PURE__ */ jsx(SpinnerIcon, { className: "size-4 animate-spin" }) : /* @__PURE__ */ jsx(Pencil, { className: "size-4" }), tr("fluidgrids.aiStudio.editInBuilder", "Edit in builder")]
2784
+ }), /* @__PURE__ */ jsx("span", {
2785
+ className: "text-xs text-text-secondary sm:ml-auto",
2786
+ children: tr("fluidgrids.aiStudio.run.note", "Steps repeat the arguments the Steward used. Pick a connection for each step in the builder.")
2787
+ })]
2788
+ })
2789
+ ]
2790
+ })]
2791
+ })]
2792
+ }),
2793
+ /* @__PURE__ */ jsx(CreateWorkflowRefusalDialog, {
2794
+ surface: "builder-create",
2795
+ refusal,
2796
+ onClose: () => setRefusal(null),
2797
+ onUpgrade: () => navigate(BILLING_PLANS_PATH)
2798
+ })
2799
+ ]
2800
+ });
2801
+ }
2802
+ function Loading({ label }) {
2803
+ return /* @__PURE__ */ jsxs("div", {
2804
+ className: "flex items-center gap-2 text-sm text-text-secondary",
2805
+ children: [/* @__PURE__ */ jsx(SpinnerIcon, { className: "size-4 animate-spin" }), label]
2806
+ });
2807
+ }
2808
+ function ErrorNote({ message, testId }) {
2809
+ return /* @__PURE__ */ jsx("div", {
2810
+ role: "alert",
2811
+ "data-testid": testId,
2812
+ className: "rounded-md border border-status-error-border bg-status-error-bg-subtle p-3 text-sm text-status-error-text",
2813
+ children: message
2814
+ });
2815
+ }
2816
+ function runLabel(tr, when, steps) {
2817
+ const date = new Date(when);
2818
+ return tr("fluidgrids.aiStudio.run.runOption", "{{when}} ({{count}} steps)", {
2819
+ when: Number.isNaN(date.getTime()) ? when : date.toLocaleString(void 0, {
2820
+ dateStyle: "medium",
2821
+ timeStyle: "short"
2822
+ }),
2823
+ count: steps
2824
+ });
2825
+ }
2826
+ function refusalText(tr, refusal) {
2827
+ switch (refusal) {
2828
+ case "run_not_completed": return tr("fluidgrids.aiStudio.run.refusal.notCompleted", "Only a run that finished successfully can become a workflow.");
2829
+ case "dry_run": return tr("fluidgrids.aiStudio.run.refusal.dryRun", "This was a dry run: it recorded what the Steward would do and did none of it, so there is nothing to replay.");
2830
+ default: return tr("fluidgrids.aiStudio.run.refusal.nothing", "This run made no connector calls a workflow can repeat.");
2831
+ }
2832
+ }
2833
+ function skipText(tr, reason) {
2834
+ switch (reason) {
2835
+ case "not_performed": return tr("fluidgrids.aiStudio.run.skip.notPerformed", "it was not carried out in the run");
2836
+ case "dry_run": return tr("fluidgrids.aiStudio.run.skip.dryRun", "it was a dry run");
2837
+ case "no_node": return tr("fluidgrids.aiStudio.run.skip.noNode", "no workflow node for this connector yet");
2838
+ case "desk_action": return tr("fluidgrids.aiStudio.run.skip.desk", "desk actions are replayed in BotManor from a playbook's saved steps");
2839
+ case "too_many": return tr("fluidgrids.aiStudio.run.skip.tooMany", "the workflow is limited to 100 steps");
2840
+ default: return tr("fluidgrids.aiStudio.run.skip.other", "a workflow cannot repeat this kind of tool");
2841
+ }
2842
+ }
2843
+
2844
+ export { CreateStewardDraftAgentDocument as _, buildRefinementPrompt as a, phaseOf as c, StewardRunStepsDocument as d, StewardRunsForCrystalliseDocument as f, CreateStewardDraftDocument as g, UpdateStewardDraftCharterDocument as h, buildAnsweredPrompt as i, StewardBuilderPanel as l, SetStewardDraftStatusDocument as m, AI_STUDIO_EXAMPLES as n, draftCreateInput as o, StewardsForCrystalliseDocument as p, AI_STUDIO_REFINEMENTS as r, draftSteps as s, StewardRunImportPanel as t, DraftCanvas as u };