@hotmeshio/long-tail 0.8.4 → 0.8.5

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 (190) hide show
  1. package/build/api/escalations/index.d.ts +1 -1
  2. package/build/api/escalations/index.js +2 -1
  3. package/build/api/escalations/resolve.d.ts +28 -0
  4. package/build/api/escalations/resolve.js +98 -0
  5. package/build/lib/db/index.js +12 -1
  6. package/build/lib/db/migrate.js +27 -0
  7. package/build/modules/defaults.d.ts +2 -0
  8. package/build/modules/defaults.js +3 -1
  9. package/build/routes/escalations/resolve.js +18 -0
  10. package/build/sdk/index.d.ts +8 -0
  11. package/build/sdk/index.js +1 -0
  12. package/build/services/escalation/crud.d.ts +36 -0
  13. package/build/services/escalation/crud.js +53 -0
  14. package/build/services/maintenance/index.js +22 -0
  15. package/build/types/maintenance.d.ts +6 -1
  16. package/dashboard/dist/assets/{AdminDashboard-B-JptT54.js → AdminDashboard-RrSvb8d-.js} +2 -2
  17. package/dashboard/dist/assets/{AdminDashboard-B-JptT54.js.map → AdminDashboard-RrSvb8d-.js.map} +1 -1
  18. package/dashboard/dist/assets/{AgentConfigPage-B1Jc6iJk.js → AgentConfigPage-5RMdI0ku.js} +2 -2
  19. package/dashboard/dist/assets/{AgentConfigPage-B1Jc6iJk.js.map → AgentConfigPage-5RMdI0ku.js.map} +1 -1
  20. package/dashboard/dist/assets/{AgentDetailPage-CWpclCOY.js → AgentDetailPage-C_-sIBcr.js} +2 -2
  21. package/dashboard/dist/assets/{AgentDetailPage-CWpclCOY.js.map → AgentDetailPage-C_-sIBcr.js.map} +1 -1
  22. package/dashboard/dist/assets/{AgentsPage-DyAf5GA2.js → AgentsPage-CxNNtSsf.js} +2 -2
  23. package/dashboard/dist/assets/{AgentsPage-DyAf5GA2.js.map → AgentsPage-CxNNtSsf.js.map} +1 -1
  24. package/dashboard/dist/assets/{AvailableEscalationsPage-DDwAgklw.js → AvailableEscalationsPage-BcbhA6NE.js} +2 -2
  25. package/dashboard/dist/assets/{AvailableEscalationsPage-DDwAgklw.js.map → AvailableEscalationsPage-BcbhA6NE.js.map} +1 -1
  26. package/dashboard/dist/assets/{BotPicker-B1RdaNuY.js → BotPicker-BQVz6bye.js} +2 -2
  27. package/dashboard/dist/assets/{BotPicker-B1RdaNuY.js.map → BotPicker-BQVz6bye.js.map} +1 -1
  28. package/dashboard/dist/assets/{CapabilitiesPage-CxHDnyjX.js → CapabilitiesPage-DlZ8SgO3.js} +2 -2
  29. package/dashboard/dist/assets/{CapabilitiesPage-CxHDnyjX.js.map → CapabilitiesPage-DlZ8SgO3.js.map} +1 -1
  30. package/dashboard/dist/assets/{CollapsibleSection-Ds0e8cCO.js → CollapsibleSection-lo8Qx4zb.js} +2 -2
  31. package/dashboard/dist/assets/{CollapsibleSection-Ds0e8cCO.js.map → CollapsibleSection-lo8Qx4zb.js.map} +1 -1
  32. package/dashboard/dist/assets/{CredentialsPage-D8UVO-3A.js → CredentialsPage-DJ9DyXsO.js} +2 -2
  33. package/dashboard/dist/assets/{CredentialsPage-D8UVO-3A.js.map → CredentialsPage-DJ9DyXsO.js.map} +1 -1
  34. package/dashboard/dist/assets/{CronLabel-ZesYXxCH.js → CronLabel-o0dbisw1.js} +2 -2
  35. package/dashboard/dist/assets/{CronLabel-ZesYXxCH.js.map → CronLabel-o0dbisw1.js.map} +1 -1
  36. package/dashboard/dist/assets/{CustomDurationPicker-OKlwH5a_.js → CustomDurationPicker-CGiwKSVJ.js} +2 -2
  37. package/dashboard/dist/assets/{CustomDurationPicker-OKlwH5a_.js.map → CustomDurationPicker-CGiwKSVJ.js.map} +1 -1
  38. package/dashboard/dist/assets/{ElapsedCell-CO8S6vdb.js → ElapsedCell-N22STQcg.js} +2 -2
  39. package/dashboard/dist/assets/{ElapsedCell-CO8S6vdb.js.map → ElapsedCell-N22STQcg.js.map} +1 -1
  40. package/dashboard/dist/assets/EscalationSchemaPage-Zsmewko2.js +9 -0
  41. package/dashboard/dist/assets/EscalationSchemaPage-Zsmewko2.js.map +1 -0
  42. package/dashboard/dist/assets/{EscalationsOverview-DMpRvVql.js → EscalationsOverview-CE2p70Ct.js} +2 -2
  43. package/dashboard/dist/assets/{EscalationsOverview-DMpRvVql.js.map → EscalationsOverview-CE2p70Ct.js.map} +1 -1
  44. package/dashboard/dist/assets/{EventTable-BARJeiS2.js → EventTable-B3Gj7Ayg.js} +2 -2
  45. package/dashboard/dist/assets/{EventTable-BARJeiS2.js.map → EventTable-B3Gj7Ayg.js.map} +1 -1
  46. package/dashboard/dist/assets/{GraphInvokePage-CTuul-av.js → GraphInvokePage-DywWVSdj.js} +2 -2
  47. package/dashboard/dist/assets/{GraphInvokePage-CTuul-av.js.map → GraphInvokePage-DywWVSdj.js.map} +1 -1
  48. package/dashboard/dist/assets/{HomePage-BKFpOaHX.js → HomePage-CxtBiULd.js} +2 -2
  49. package/dashboard/dist/assets/{HomePage-BKFpOaHX.js.map → HomePage-CxtBiULd.js.map} +1 -1
  50. package/dashboard/dist/assets/{ListToolbar-Dz2_neVF.js → ListToolbar-Ok2O0wmC.js} +2 -2
  51. package/dashboard/dist/assets/{ListToolbar-Dz2_neVF.js.map → ListToolbar-Ok2O0wmC.js.map} +1 -1
  52. package/dashboard/dist/assets/{McpOverview-Do-vaEqV.js → McpOverview-CTCYZXIp.js} +2 -2
  53. package/dashboard/dist/assets/{McpOverview-Do-vaEqV.js.map → McpOverview-CTCYZXIp.js.map} +1 -1
  54. package/dashboard/dist/assets/{McpQueryDetailPage-HwDGNSbN.js → McpQueryDetailPage-BOaXf0bZ.js} +2 -2
  55. package/dashboard/dist/assets/{McpQueryDetailPage-HwDGNSbN.js.map → McpQueryDetailPage-BOaXf0bZ.js.map} +1 -1
  56. package/dashboard/dist/assets/{McpQueryPage-DxMUpQ7R.js → McpQueryPage-BbYojoHu.js} +2 -2
  57. package/dashboard/dist/assets/{McpQueryPage-DxMUpQ7R.js.map → McpQueryPage-BbYojoHu.js.map} +1 -1
  58. package/dashboard/dist/assets/{McpRunDetailPage-BzzZIXIk.js → McpRunDetailPage-CXGCVmPq.js} +2 -2
  59. package/dashboard/dist/assets/{McpRunDetailPage-BzzZIXIk.js.map → McpRunDetailPage-CXGCVmPq.js.map} +1 -1
  60. package/dashboard/dist/assets/{McpRunsPage-D3J42d2i.js → McpRunsPage-Df1GqxUg.js} +2 -2
  61. package/dashboard/dist/assets/{McpRunsPage-D3J42d2i.js.map → McpRunsPage-Df1GqxUg.js.map} +1 -1
  62. package/dashboard/dist/assets/OperationsPage-DgZYi-BC.js +2 -0
  63. package/dashboard/dist/assets/OperationsPage-DgZYi-BC.js.map +1 -0
  64. package/dashboard/dist/assets/{OperatorDashboard-BqJn8wEZ.js → OperatorDashboard-DIR7XDeD.js} +2 -2
  65. package/dashboard/dist/assets/{OperatorDashboard-BqJn8wEZ.js.map → OperatorDashboard-DIR7XDeD.js.map} +1 -1
  66. package/dashboard/dist/assets/{ProcessDetailPage-C8sT2xuE.js → ProcessDetailPage-BuSi654J.js} +2 -2
  67. package/dashboard/dist/assets/{ProcessDetailPage-C8sT2xuE.js.map → ProcessDetailPage-BuSi654J.js.map} +1 -1
  68. package/dashboard/dist/assets/{ProcessesListPage-eA8buUgd.js → ProcessesListPage-Dhik7XpW.js} +2 -2
  69. package/dashboard/dist/assets/{ProcessesListPage-eA8buUgd.js.map → ProcessesListPage-Dhik7XpW.js.map} +1 -1
  70. package/dashboard/dist/assets/RoleDetailPage-BfzqQxMU.js +8 -0
  71. package/dashboard/dist/assets/RoleDetailPage-BfzqQxMU.js.map +1 -0
  72. package/dashboard/dist/assets/{RolesPage-BQNQxsMY.js → RolesPage-BRicD5mx.js} +2 -2
  73. package/dashboard/dist/assets/{RolesPage-BQNQxsMY.js.map → RolesPage-BRicD5mx.js.map} +1 -1
  74. package/dashboard/dist/assets/{RunAsSelector-mhusrlYE.js → RunAsSelector-DipyBf_T.js} +2 -2
  75. package/dashboard/dist/assets/{RunAsSelector-mhusrlYE.js.map → RunAsSelector-DipyBf_T.js.map} +1 -1
  76. package/dashboard/dist/assets/{StickyPagination-CqT9Q1I6.js → StickyPagination-CD4W450h.js} +2 -2
  77. package/dashboard/dist/assets/{StickyPagination-CqT9Q1I6.js.map → StickyPagination-CD4W450h.js.map} +1 -1
  78. package/dashboard/dist/assets/{StreamMessageDetail-jOJaoupp.js → StreamMessageDetail-BbDdWDUY.js} +2 -2
  79. package/dashboard/dist/assets/{StreamMessageDetail-jOJaoupp.js.map → StreamMessageDetail-BbDdWDUY.js.map} +1 -1
  80. package/dashboard/dist/assets/{SwimlaneTimeline-BrfmWgAj.js → SwimlaneTimeline-Bktv2vi5.js} +2 -2
  81. package/dashboard/dist/assets/{SwimlaneTimeline-BrfmWgAj.js.map → SwimlaneTimeline-Bktv2vi5.js.map} +1 -1
  82. package/dashboard/dist/assets/{TaskDetailPage-Cus_JHIC.js → TaskDetailPage-pSU3xuG9.js} +2 -2
  83. package/dashboard/dist/assets/{TaskDetailPage-Cus_JHIC.js.map → TaskDetailPage-pSU3xuG9.js.map} +1 -1
  84. package/dashboard/dist/assets/{TasksListPage-B7GK8AoX.js → TasksListPage-M6ok-Nfd.js} +2 -2
  85. package/dashboard/dist/assets/{TasksListPage-B7GK8AoX.js.map → TasksListPage-M6ok-Nfd.js.map} +1 -1
  86. package/dashboard/dist/assets/{TimeAgo-C606LzT3.js → TimeAgo-DVWhRNbi.js} +2 -2
  87. package/dashboard/dist/assets/{TimeAgo-C606LzT3.js.map → TimeAgo-DVWhRNbi.js.map} +1 -1
  88. package/dashboard/dist/assets/{TimestampCell-hfh6zvH-.js → TimestampCell-rG7pmIkW.js} +2 -2
  89. package/dashboard/dist/assets/{TimestampCell-hfh6zvH-.js.map → TimestampCell-rG7pmIkW.js.map} +1 -1
  90. package/dashboard/dist/assets/{ToolTestPanel-CsPsyvQq.js → ToolTestPanel-CLcMA8OE.js} +2 -2
  91. package/dashboard/dist/assets/{ToolTestPanel-CsPsyvQq.js.map → ToolTestPanel-CLcMA8OE.js.map} +1 -1
  92. package/dashboard/dist/assets/{TopicDetailPage-Diz6r7zr.js → TopicDetailPage-C9gvoWYu.js} +2 -2
  93. package/dashboard/dist/assets/{TopicDetailPage-Diz6r7zr.js.map → TopicDetailPage-C9gvoWYu.js.map} +1 -1
  94. package/dashboard/dist/assets/{TopicsPage-B6fn7fFh.js → TopicsPage-CIGi3TdT.js} +2 -2
  95. package/dashboard/dist/assets/{TopicsPage-B6fn7fFh.js.map → TopicsPage-CIGi3TdT.js.map} +1 -1
  96. package/dashboard/dist/assets/{UserName-Cc-5QH5q.js → UserName-CifbOahk.js} +2 -2
  97. package/dashboard/dist/assets/{UserName-Cc-5QH5q.js.map → UserName-CifbOahk.js.map} +1 -1
  98. package/dashboard/dist/assets/{WorkflowExecutionPage-BFq7UdhA.js → WorkflowExecutionPage-BR0oVx_p.js} +2 -2
  99. package/dashboard/dist/assets/{WorkflowExecutionPage-BFq7UdhA.js.map → WorkflowExecutionPage-BR0oVx_p.js.map} +1 -1
  100. package/dashboard/dist/assets/{WorkflowsDashboard-CHCM6hUa.js → WorkflowsDashboard-CSYrYQsO.js} +2 -2
  101. package/dashboard/dist/assets/{WorkflowsDashboard-CHCM6hUa.js.map → WorkflowsDashboard-CSYrYQsO.js.map} +1 -1
  102. package/dashboard/dist/assets/{WorkflowsOverview-WeOvl8-_.js → WorkflowsOverview-CaXWYZuw.js} +2 -2
  103. package/dashboard/dist/assets/{WorkflowsOverview-WeOvl8-_.js.map → WorkflowsOverview-CaXWYZuw.js.map} +1 -1
  104. package/dashboard/dist/assets/{YamlWorkflowDetailPage-6GfhVDpv.js → YamlWorkflowDetailPage-CRBXahFJ.js} +2 -2
  105. package/dashboard/dist/assets/{YamlWorkflowDetailPage-6GfhVDpv.js.map → YamlWorkflowDetailPage-CRBXahFJ.js.map} +1 -1
  106. package/dashboard/dist/assets/{YamlWorkflowsPage-DqcY3ocP.js → YamlWorkflowsPage-D5zc8Lta.js} +2 -2
  107. package/dashboard/dist/assets/{YamlWorkflowsPage-DqcY3ocP.js.map → YamlWorkflowsPage-D5zc8Lta.js.map} +1 -1
  108. package/dashboard/dist/assets/{agents-DlzvjNxE.js → agents-D7vYXeLj.js} +2 -2
  109. package/dashboard/dist/assets/{agents-DlzvjNxE.js.map → agents-D7vYXeLj.js.map} +1 -1
  110. package/dashboard/dist/assets/{bots-CWMN-KUI.js → bots-CKaYN2fL.js} +2 -2
  111. package/dashboard/dist/assets/{bots-CWMN-KUI.js.map → bots-CKaYN2fL.js.map} +1 -1
  112. package/dashboard/dist/assets/{capabilities-_WSZ7cxO.js → capabilities-BknM6oFm.js} +2 -2
  113. package/dashboard/dist/assets/{capabilities-_WSZ7cxO.js.map → capabilities-BknM6oFm.js.map} +1 -1
  114. package/dashboard/dist/assets/{controlplane-_k9nWZy3.js → controlplane-BodNGCr-.js} +2 -2
  115. package/dashboard/dist/assets/{controlplane-_k9nWZy3.js.map → controlplane-BodNGCr-.js.map} +1 -1
  116. package/dashboard/dist/assets/{escalation-CK8ElYzD.js → escalation-CH_XK2XM.js} +2 -2
  117. package/dashboard/dist/assets/{escalation-CK8ElYzD.js.map → escalation-CH_XK2XM.js.map} +1 -1
  118. package/dashboard/dist/assets/{escalation-columns-Dyrf6Tdp.js → escalation-columns-CcbLKRI4.js} +2 -2
  119. package/dashboard/dist/assets/{escalation-columns-Dyrf6Tdp.js.map → escalation-columns-CcbLKRI4.js.map} +1 -1
  120. package/dashboard/dist/assets/index--xNp5rx6.css +1 -0
  121. package/dashboard/dist/assets/{index-uUYXmvFf.js → index-B-LQ8fsJ.js} +2 -2
  122. package/dashboard/dist/assets/{index-uUYXmvFf.js.map → index-B-LQ8fsJ.js.map} +1 -1
  123. package/dashboard/dist/assets/{index-Dd4Si1Rl.js → index-BH67e1Ah.js} +2 -2
  124. package/dashboard/dist/assets/{index-Dd4Si1Rl.js.map → index-BH67e1Ah.js.map} +1 -1
  125. package/dashboard/dist/assets/{index-DwWP-Z_c.js → index-B_aFcGv9.js} +4 -4
  126. package/dashboard/dist/assets/{index-DwWP-Z_c.js.map → index-B_aFcGv9.js.map} +1 -1
  127. package/dashboard/dist/assets/{index-BiApvBEz.js → index-Bwofyfi8.js} +2 -2
  128. package/dashboard/dist/assets/{index-BiApvBEz.js.map → index-Bwofyfi8.js.map} +1 -1
  129. package/dashboard/dist/assets/{index-C3h0qGzG.js → index-C3QKGY5C.js} +2 -2
  130. package/dashboard/dist/assets/{index-C3h0qGzG.js.map → index-C3QKGY5C.js.map} +1 -1
  131. package/dashboard/dist/assets/{index-ZBj6Xgim.js → index-CJpywoA8.js} +2 -2
  132. package/dashboard/dist/assets/{index-ZBj6Xgim.js.map → index-CJpywoA8.js.map} +1 -1
  133. package/dashboard/dist/assets/{index-Ex5tEte8.js → index-CV8soXIM.js} +2 -2
  134. package/dashboard/dist/assets/{index-Ex5tEte8.js.map → index-CV8soXIM.js.map} +1 -1
  135. package/dashboard/dist/assets/{index-C5Yc3TT7.js → index-CdN-Z8-r.js} +2 -2
  136. package/dashboard/dist/assets/{index-C5Yc3TT7.js.map → index-CdN-Z8-r.js.map} +1 -1
  137. package/dashboard/dist/assets/{index-Dc-Ye2wk.js → index-D7NHjvA4.js} +2 -2
  138. package/dashboard/dist/assets/{index-Dc-Ye2wk.js.map → index-D7NHjvA4.js.map} +1 -1
  139. package/dashboard/dist/assets/{index-D8GcHxNJ.js → index-DHhz71yv.js} +2 -2
  140. package/dashboard/dist/assets/{index-D8GcHxNJ.js.map → index-DHhz71yv.js.map} +1 -1
  141. package/dashboard/dist/assets/{index-kKufOPLo.js → index-Gt2Rebs9.js} +2 -2
  142. package/dashboard/dist/assets/{index-kKufOPLo.js.map → index-Gt2Rebs9.js.map} +1 -1
  143. package/dashboard/dist/assets/index-IIq5Tkqs.js +6 -0
  144. package/dashboard/dist/assets/index-IIq5Tkqs.js.map +1 -0
  145. package/dashboard/dist/assets/{index-C7VXLKJs.js → index-_gh2K9DU.js} +2 -2
  146. package/dashboard/dist/assets/{index-C7VXLKJs.js.map → index-_gh2K9DU.js.map} +1 -1
  147. package/dashboard/dist/assets/{knowledge-fYoEF4Lx.js → knowledge-CE6gjN3G.js} +2 -2
  148. package/dashboard/dist/assets/{knowledge-fYoEF4Lx.js.map → knowledge-CE6gjN3G.js.map} +1 -1
  149. package/dashboard/dist/assets/{mcp-1lzlgtS8.js → mcp-B4F-T-7R.js} +2 -2
  150. package/dashboard/dist/assets/{mcp-1lzlgtS8.js.map → mcp-B4F-T-7R.js.map} +1 -1
  151. package/dashboard/dist/assets/{mcp-query-nlrAz7m_.js → mcp-query-CYOarL1K.js} +2 -2
  152. package/dashboard/dist/assets/{mcp-query-nlrAz7m_.js.map → mcp-query-CYOarL1K.js.map} +1 -1
  153. package/dashboard/dist/assets/{pipelines-Ihi7EKXi.js → pipelines-B4gB9qMx.js} +2 -2
  154. package/dashboard/dist/assets/{pipelines-Ihi7EKXi.js.map → pipelines-B4gB9qMx.js.map} +1 -1
  155. package/dashboard/dist/assets/{roles-D4Wn7kE9.js → roles-LZf98ePg.js} +2 -2
  156. package/dashboard/dist/assets/{roles-D4Wn7kE9.js.map → roles-LZf98ePg.js.map} +1 -1
  157. package/dashboard/dist/assets/{tasks-Crk9Y3C4.js → tasks-GG8c_U9w.js} +2 -2
  158. package/dashboard/dist/assets/{tasks-Crk9Y3C4.js.map → tasks-GG8c_U9w.js.map} +1 -1
  159. package/dashboard/dist/assets/{topics-CtfcCyw9.js → topics-C7-6oOgA.js} +2 -2
  160. package/dashboard/dist/assets/{topics-CtfcCyw9.js.map → topics-C7-6oOgA.js.map} +1 -1
  161. package/dashboard/dist/assets/{useEventHooks-Dn_vN2xE.js → useEventHooks-82IiMmOc.js} +2 -2
  162. package/dashboard/dist/assets/{useEventHooks-Dn_vN2xE.js.map → useEventHooks-82IiMmOc.js.map} +1 -1
  163. package/dashboard/dist/assets/{useNamespace-Cfs3vKWk.js → useNamespace-DQEqD2LA.js} +2 -2
  164. package/dashboard/dist/assets/{useNamespace-Cfs3vKWk.js.map → useNamespace-DQEqD2LA.js.map} +1 -1
  165. package/dashboard/dist/assets/{useYamlActivityEvents-ymobxH47.js → useYamlActivityEvents-Bm0-ewLx.js} +2 -2
  166. package/dashboard/dist/assets/{useYamlActivityEvents-ymobxH47.js.map → useYamlActivityEvents-Bm0-ewLx.js.map} +1 -1
  167. package/dashboard/dist/assets/{users-DngGIiC_.js → users-DHx2ium7.js} +2 -2
  168. package/dashboard/dist/assets/{users-DngGIiC_.js.map → users-DHx2ium7.js.map} +1 -1
  169. package/dashboard/dist/assets/{workflows-DuUspMAl.js → workflows-qIbkeQ_5.js} +2 -2
  170. package/dashboard/dist/assets/{workflows-DuUspMAl.js.map → workflows-qIbkeQ_5.js.map} +1 -1
  171. package/dashboard/dist/assets/{yaml-workflows-DXQCiOsP.js → yaml-workflows-FibyeHpo.js} +2 -2
  172. package/dashboard/dist/assets/{yaml-workflows-DXQCiOsP.js.map → yaml-workflows-FibyeHpo.js.map} +1 -1
  173. package/dashboard/dist/index.html +2 -2
  174. package/docs/api/http/escalations.md +20 -0
  175. package/docs/api/sdk/escalations.md +37 -2
  176. package/docs/dashboard.md +1 -1
  177. package/docs/data.md +1 -1
  178. package/docs/hitl-guide.md +112 -3
  179. package/docs/maintenance.md +6 -3
  180. package/docs/oauth-and-delegation.md +1 -1
  181. package/package.json +2 -2
  182. package/dashboard/dist/assets/EscalationSchemaPage-Br5sD8-N.js +0 -9
  183. package/dashboard/dist/assets/EscalationSchemaPage-Br5sD8-N.js.map +0 -1
  184. package/dashboard/dist/assets/OperationsPage-BaM-QDhy.js +0 -2
  185. package/dashboard/dist/assets/OperationsPage-BaM-QDhy.js.map +0 -1
  186. package/dashboard/dist/assets/RoleDetailPage-aR-ror5v.js +0 -11
  187. package/dashboard/dist/assets/RoleDetailPage-aR-ror5v.js.map +0 -1
  188. package/dashboard/dist/assets/index-BdqKh0UK.css +0 -1
  189. package/dashboard/dist/assets/index-OV1JoB_P.js +0 -6
  190. package/dashboard/dist/assets/index-OV1JoB_P.js.map +0 -1
@@ -1,2 +1,2 @@
1
- import{c as k,u as R,b as O,j as e,a as d}from"./vendor-query-B2UbickB.js";import{P as F}from"./PageHeader-DJo7yMUR.js";import{d as b}from"./index-DwWP-Z_c.js";import{M}from"./Modal-CSrxpXeM.js";import{R as g,C}from"./constants-BHkpVaqx.js";import{as as E,al as T,ad as W,a9 as j,p as I,a6 as D}from"./vendor-icons-DOIDKgo6.js";import"./vendor-react-CXumBFUA.js";function $(){return R({queryKey:["maintenance"],queryFn:()=>b("/config/maintenance")})}function _(){const t=O();return k({mutationFn:r=>b("/config/maintenance",{method:"PUT",body:JSON.stringify(r)}),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenance"]})}})}function q(){return k({mutationFn:t=>b("/dba/prune",{method:"POST",body:JSON.stringify(t)})})}function v({checked:t,onToggle:r,label:a,hint:s,safety:i,value:l,onChange:c}){const n=i==="safe"?W:i==="moderate"?E:T,o=i==="safe"?"text-status-success":i==="moderate"?"text-status-warning":"text-status-error",m=i==="safe"?"Safe":i==="moderate"?"Careful":"Permanent";return e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("label",{className:"flex items-center gap-2.5 cursor-pointer w-80 shrink-0",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:x=>r(x.target.checked),className:"w-4 h-4 rounded border-border accent-accent shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-text-primary",children:a}),e.jsxs("span",{className:`flex items-center gap-0.5 text-[9px] ${o}`,children:[e.jsx(n,{className:"w-3 h-3",strokeWidth:1.5}),m]})]}),e.jsx("p",{className:"text-[10px] text-text-tertiary",children:s})]})]}),e.jsx("select",{value:l,onChange:x=>c(x.target.value),disabled:!t,className:`select text-xs w-36 transition-opacity ${t?"":"opacity-40 cursor-not-allowed"}`,children:g.map(x=>e.jsx("option",{value:x.value,children:x.label},x.value))})]})}function L(){return e.jsxs("div",{className:"flex items-start gap-2 mt-2 px-3 py-2 rounded bg-surface-sunken",children:[e.jsx(j,{className:"w-3.5 h-3.5 text-text-tertiary shrink-0 mt-0.5"}),e.jsx("p",{className:"text-[10px] text-text-tertiary leading-relaxed",children:"Stripping preserves workflow results and timeline data needed for the execution detail view. Transient jobs are internal bookkeeping that accumulates over time."})]})}const f={pruneJobs:!0,expire:"30 days",engineStreams:!0,engineStreamsExpire:"1 day",workerStreams:!0,workerStreamsExpire:"90 days",stripAttributes:!1,pruneTransient:!1};function N(t){return t.pruneJobs||t.engineStreams||t.workerStreams||t.stripAttributes||t.pruneTransient}function P({fields:t,onChange:r}){const a=(s,i)=>r({...t,[s]:i});return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:"Stream Messages"}),e.jsx("p",{className:"text-[10px] text-text-tertiary mb-4",children:"Processed routing messages. Already consumed — safe to remove after a short retention window."}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(v,{checked:t.engineStreams,onToggle:s=>a("engineStreams",s),label:"Engine messages",hint:"Internal orchestration signals",safety:"safe",value:t.engineStreamsExpire,onChange:s=>a("engineStreamsExpire",s)}),e.jsx(v,{checked:t.workerStreams,onToggle:s=>a("workerStreams",s),label:"Worker messages",hint:"Activity dispatch and response payloads",safety:"safe",value:t.workerStreamsExpire,onChange:s=>a("workerStreamsExpire",s)})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:"Completed Workflows"}),e.jsx("p",{className:"text-[10px] text-text-tertiary mb-4",children:"Choose how to handle completed workflow records. Reducing strips step-level detail but keeps the workflow and its results. Deleting removes the record entirely."}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("label",{className:"flex items-start gap-2.5 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"workflow-cleanup",checked:!t.stripAttributes&&!t.pruneJobs,onChange:()=>r({...t,stripAttributes:!1,pruneJobs:!1}),className:"w-4 h-4 mt-0.5 accent-accent shrink-0"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-xs text-text-primary",children:"Keep as-is"}),e.jsx("p",{className:"text-[10px] text-text-tertiary",children:"No changes to completed workflow records."})]})]}),e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsxs("label",{className:"flex items-start gap-2.5 cursor-pointer w-80 shrink-0",children:[e.jsx("input",{type:"radio",name:"workflow-cleanup",checked:t.stripAttributes&&!t.pruneJobs,onChange:()=>r({...t,stripAttributes:!0,pruneJobs:!1}),className:"w-4 h-4 mt-0.5 accent-accent shrink-0"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-text-primary",children:"Reduce completed workflows"}),e.jsxs("span",{className:"flex items-center gap-0.5 text-[9px] text-status-warning",children:[e.jsx(E,{className:"w-3 h-3",strokeWidth:1.5}),"Careful"]})]}),e.jsx("p",{className:"text-[10px] text-text-tertiary",children:"Strips step-level execution detail (activity inputs/outputs, internal state). Workflow results and timeline are preserved."})]})]}),e.jsx("select",{value:t.expire,onChange:s=>a("expire",s.target.value),disabled:!t.stripAttributes||t.pruneJobs,className:`select text-xs w-36 transition-opacity mt-0.5 ${!t.stripAttributes||t.pruneJobs?"opacity-40 cursor-not-allowed":""}`,children:g.map(s=>e.jsx("option",{value:s.value,children:s.label},s.value))})]}),e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsxs("label",{className:"flex items-start gap-2.5 cursor-pointer w-80 shrink-0",children:[e.jsx("input",{type:"radio",name:"workflow-cleanup",checked:t.pruneJobs,onChange:()=>r({...t,pruneJobs:!0,stripAttributes:!1}),className:"w-4 h-4 mt-0.5 accent-accent shrink-0"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-text-primary",children:"Delete completed workflows"}),e.jsxs("span",{className:"flex items-center gap-0.5 text-[9px] text-status-error",children:[e.jsx(T,{className:"w-3 h-3",strokeWidth:1.5}),"Permanent"]})]}),e.jsx("p",{className:"text-[10px] text-text-tertiary",children:"Permanently removes workflow records. Results, timeline, and all execution data are deleted and cannot be recovered."})]})]}),e.jsx("select",{value:t.expire,onChange:s=>a("expire",s.target.value),disabled:!t.pruneJobs,className:`select text-xs w-36 transition-opacity mt-0.5 ${t.pruneJobs?"":"opacity-40 cursor-not-allowed"}`,children:g.map(s=>e.jsx("option",{value:s.value,children:s.label},s.value))})]})]}),e.jsx(L,{})]})]})}function p({label:t,value:r}){return e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-light text-text-primary",children:r.toLocaleString()}),e.jsx("p",{className:"text-[10px] text-text-tertiary",children:t})]})}function U(){const t=q(),[r,a]=d.useState(f),[s,i]=d.useState(null),[l,c]=d.useState(!1),n=()=>{i(null),t.mutate({expire:r.expire,jobs:r.pruneJobs,engineStreams:r.engineStreams,engineStreamsExpire:r.engineStreamsExpire,workerStreams:r.workerStreams,workerStreamsExpire:r.workerStreamsExpire,attributes:r.stripAttributes,pruneTransient:r.pruneTransient},{onSuccess:o=>{i(o),c(!1)}})};return e.jsxs("div",{className:"space-y-8",children:[e.jsx(P,{fields:r,onChange:a}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-surface-border",children:[e.jsx("p",{className:"text-[10px] text-text-tertiary",children:N(r)?"This action permanently deletes data and cannot be undone.":"Select at least one operation to enable pruning."}),e.jsx("button",{onClick:()=>c(!0),disabled:!N(r)||t.isPending,className:"bg-status-error text-white px-4 py-1.5 rounded-md text-xs hover:opacity-90 transition-opacity disabled:opacity-40 shrink-0",children:t.isPending?"Pruning...":"Prune Now"})]}),s&&e.jsxs("div",{className:"bg-surface-sunken rounded-md px-4 py-3",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-2",children:"Results"}),e.jsxs("div",{className:"flex flex-wrap gap-6",children:[s.jobs!=null&&s.jobs>0&&e.jsx(p,{label:"Jobs deleted",value:s.jobs}),s.engineStreams!=null&&s.engineStreams>0&&e.jsx(p,{label:"Engine streams",value:s.engineStreams}),s.workerStreams!=null&&s.workerStreams>0&&e.jsx(p,{label:"Worker streams",value:s.workerStreams}),s.streams!=null&&s.engineStreams==null&&s.streams>0&&e.jsx(p,{label:"Streams",value:s.streams}),s.attributes!=null&&s.attributes>0&&e.jsx(p,{label:"Artifacts stripped",value:s.attributes}),s.transient!=null&&s.transient>0&&e.jsx(p,{label:"Transient deleted",value:s.transient}),s.marked!=null&&s.marked>0&&e.jsx(p,{label:"Marked pruned",value:s.marked}),Object.values(s).every(o=>!o||o===0)&&e.jsx("p",{className:"text-xs text-text-tertiary",children:"Nothing to prune within the selected retention windows."})]})]}),t.error&&e.jsx("p",{className:"text-xs text-status-error",children:t.error.message}),e.jsx(M,{open:l,onClose:()=>c(!1),title:"Confirm Prune",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-text-secondary",children:"This will permanently delete data. This action cannot be undone."}),e.jsxs("ul",{className:"text-xs text-text-secondary space-y-1 list-disc list-inside",children:[r.pruneJobs&&e.jsxs("li",{children:["Delete jobs older than ",r.expire]}),r.engineStreams&&e.jsxs("li",{children:["Delete engine streams older than ",r.engineStreamsExpire]}),r.workerStreams&&e.jsxs("li",{children:["Delete worker streams older than ",r.workerStreamsExpire]}),r.stripAttributes&&e.jsx("li",{children:"Strip execution artifacts from completed jobs"}),r.pruneTransient&&e.jsx("li",{children:"Delete transient (entity-less) jobs"})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[e.jsx("button",{onClick:()=>c(!1),className:"btn-secondary text-xs",children:"Cancel"}),e.jsx("button",{onClick:n,className:"bg-status-error text-white px-3 py-1.5 rounded-md text-xs hover:opacity-90 transition-opacity",disabled:t.isPending,children:t.isPending?"Pruning...":"Confirm Prune"})]})]})})]})}function w(t){var c;if(!((c=t==null?void 0:t.rules)!=null&&c.length))return f;const r=t.rules,a=r.find(n=>n.target==="streams"&&n.action==="delete"),s=r.find(n=>n.target==="jobs"&&n.action==="delete"&&n.hasEntity===!1),i=r.find(n=>n.target==="jobs"&&n.action==="prune"&&n.hasEntity===!0),l=r.find(n=>n.target==="jobs"&&n.action==="delete"&&n.pruned===!0);return{pruneJobs:!!l,expire:(l==null?void 0:l.olderThan)??"180 days",engineStreams:!!a,engineStreamsExpire:(a==null?void 0:a.olderThan)??"1 day",workerStreams:!!a,workerStreamsExpire:(a==null?void 0:a.olderThan)??"90 days",stripAttributes:!!i,pruneTransient:!!s}}function H(t){const r=[];return t.engineStreams&&r.push({target:"streams",action:"delete",olderThan:t.engineStreamsExpire}),t.workerStreams&&t.workerStreamsExpire!==t.engineStreamsExpire&&r.push({target:"streams",action:"delete",olderThan:t.workerStreamsExpire}),t.pruneTransient&&r.push({target:"jobs",action:"delete",olderThan:t.expire,hasEntity:!1}),t.stripAttributes&&r.push({target:"jobs",action:"prune",olderThan:t.expire,hasEntity:!0}),t.pruneJobs&&r.push({target:"jobs",action:"delete",olderThan:t.expire,pruned:!0}),r}function S(t){var r;return((r=C.find(a=>a.value===t))==null?void 0:r.label)??""}function K(){const{data:t,isLoading:r}=$(),a=_(),[s,i]=d.useState(""),[l,c]=d.useState(f),[n,o]=d.useState(""),m=d.useCallback(()=>{t!=null&&t.config&&(i(t.config.schedule),c(w(t.config)),o(JSON.stringify({schedule:t.config.schedule,fields:w(t.config)})))},[t]);d.useEffect(()=>{m()},[m]);const x=JSON.stringify({schedule:s,fields:l}),y=n!==""&&x!==n,h=(t==null?void 0:t.active)??!1,J=()=>{const u=H(l);a.mutate({schedule:s,rules:u},{onSuccess:()=>{o(JSON.stringify({schedule:s,fields:l}))}})},A=()=>{m()};return r?e.jsx("div",{className:"animate-pulse h-40 bg-surface-sunken rounded"}):e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[1fr_auto] gap-10",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-4",children:"Schedule"}),e.jsxs("div",{className:"flex items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] text-text-tertiary mb-1",children:"Cron Expression"}),e.jsx("input",{type:"text",value:s,onChange:u=>i(u.target.value),placeholder:"0 2 * * *",className:"input text-xs font-mono w-48"})]}),e.jsx("div",{children:e.jsxs("div",{className:"flex items-center gap-1.5 h-8",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full dot-ring ${h?"bg-status-success":"bg-text-tertiary"}`}),e.jsx("span",{className:`text-xs ${h?"text-status-success":"text-text-tertiary"}`,children:h?"Active":"Inactive"})]})}),S(s)&&e.jsx("p",{className:"text-xs text-text-tertiary h-8 flex items-center",children:S(s)})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-3",children:C.map(u=>e.jsx("button",{type:"button",onClick:()=>i(u.value),className:`px-2.5 py-1 text-[10px] rounded-full transition-colors ${s===u.value?"bg-accent/10 text-accent font-medium":"bg-surface-sunken text-text-tertiary hover:text-text-secondary"}`,children:u.label},u.value))})]}),e.jsxs("div",{className:"lg:w-72",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-4",children:"How It Works"}),e.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 rounded bg-surface-sunken",children:[e.jsx(j,{className:"w-3.5 h-3.5 text-text-tertiary shrink-0 mt-0.5"}),e.jsx("p",{className:"text-[10px] text-text-tertiary leading-relaxed",children:"Rules execute sequentially on each cron cycle. Engine streams can be pruned aggressively since they only contain internal routing data. Worker streams should be retained longer to preserve execution playback and input enrichment."})]})]})]}),e.jsx(P,{fields:l,onChange:c}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-surface-border",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[y&&e.jsx("button",{onClick:A,className:"text-[10px] text-text-tertiary hover:text-text-primary transition-colors",children:"Revert changes"}),a.error&&e.jsx("p",{className:"text-xs text-status-error",children:a.error.message})]}),e.jsx("button",{onClick:J,disabled:!y||!s.trim()||a.isPending,className:"btn-primary text-xs disabled:opacity-40 shrink-0",children:a.isPending?"Saving...":"Save Schedule"})]})]})}function Q({mode:t,onChange:r}){const a=(s,i,l)=>e.jsxs("button",{onClick:()=>r(s),className:`flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md transition-colors ${t===s?"bg-accent/10 text-accent font-medium":"text-text-tertiary hover:text-text-secondary hover:bg-surface-hover"}`,children:[i,l]});return e.jsxs("div",{className:"flex gap-1 p-0.5 bg-surface-sunken rounded-lg w-fit",children:[a("prune",e.jsx(I,{className:"w-3.5 h-3.5"}),"Prune Now"),a("schedule",e.jsx(D,{className:"w-3.5 h-3.5"}),"Schedule")]})}function ee(){const[t,r]=d.useState("schedule");return e.jsxs("div",{children:[e.jsx(F,{title:"DB Maintenance",docsHash:"#docs:dashboard.md:db-maintenance",actions:e.jsx(Q,{mode:t,onChange:r})}),e.jsxs("div",{className:"flex items-start gap-2 px-4 py-3 mb-8 rounded-md bg-accent/5 border border-accent/10",children:[e.jsx(j,{className:"w-4 h-4 text-accent shrink-0 mt-0.5"}),e.jsx("p",{className:"text-xs text-text-secondary leading-relaxed",children:"Workflow data grows as jobs complete. Operations are ordered safest-first: stream messages are always safe to prune, workflow reduction preserves results, and deletion is permanent."})]}),t==="prune"?e.jsx(U,{}):e.jsx(K,{})]})}export{ee as MaintenancePage};
2
- //# sourceMappingURL=index-D8GcHxNJ.js.map
1
+ import{c as k,u as R,b as O,j as e,a as d}from"./vendor-query-B2UbickB.js";import{P as F}from"./PageHeader-DJo7yMUR.js";import{d as b}from"./index-B_aFcGv9.js";import{M}from"./Modal-CSrxpXeM.js";import{R as g,C}from"./constants-BHkpVaqx.js";import{as as E,al as T,ad as W,a9 as j,p as I,a6 as D}from"./vendor-icons-DOIDKgo6.js";import"./vendor-react-CXumBFUA.js";function $(){return R({queryKey:["maintenance"],queryFn:()=>b("/config/maintenance")})}function _(){const t=O();return k({mutationFn:r=>b("/config/maintenance",{method:"PUT",body:JSON.stringify(r)}),onSuccess:()=>{t.invalidateQueries({queryKey:["maintenance"]})}})}function q(){return k({mutationFn:t=>b("/dba/prune",{method:"POST",body:JSON.stringify(t)})})}function v({checked:t,onToggle:r,label:a,hint:s,safety:i,value:l,onChange:c}){const n=i==="safe"?W:i==="moderate"?E:T,o=i==="safe"?"text-status-success":i==="moderate"?"text-status-warning":"text-status-error",m=i==="safe"?"Safe":i==="moderate"?"Careful":"Permanent";return e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("label",{className:"flex items-center gap-2.5 cursor-pointer w-80 shrink-0",children:[e.jsx("input",{type:"checkbox",checked:t,onChange:x=>r(x.target.checked),className:"w-4 h-4 rounded border-border accent-accent shrink-0"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-text-primary",children:a}),e.jsxs("span",{className:`flex items-center gap-0.5 text-[9px] ${o}`,children:[e.jsx(n,{className:"w-3 h-3",strokeWidth:1.5}),m]})]}),e.jsx("p",{className:"text-[10px] text-text-tertiary",children:s})]})]}),e.jsx("select",{value:l,onChange:x=>c(x.target.value),disabled:!t,className:`select text-xs w-36 transition-opacity ${t?"":"opacity-40 cursor-not-allowed"}`,children:g.map(x=>e.jsx("option",{value:x.value,children:x.label},x.value))})]})}function L(){return e.jsxs("div",{className:"flex items-start gap-2 mt-2 px-3 py-2 rounded bg-surface-sunken",children:[e.jsx(j,{className:"w-3.5 h-3.5 text-text-tertiary shrink-0 mt-0.5"}),e.jsx("p",{className:"text-[10px] text-text-tertiary leading-relaxed",children:"Stripping preserves workflow results and timeline data needed for the execution detail view. Transient jobs are internal bookkeeping that accumulates over time."})]})}const f={pruneJobs:!0,expire:"30 days",engineStreams:!0,engineStreamsExpire:"1 day",workerStreams:!0,workerStreamsExpire:"90 days",stripAttributes:!1,pruneTransient:!1};function N(t){return t.pruneJobs||t.engineStreams||t.workerStreams||t.stripAttributes||t.pruneTransient}function P({fields:t,onChange:r}){const a=(s,i)=>r({...t,[s]:i});return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:"Stream Messages"}),e.jsx("p",{className:"text-[10px] text-text-tertiary mb-4",children:"Processed routing messages. Already consumed — safe to remove after a short retention window."}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(v,{checked:t.engineStreams,onToggle:s=>a("engineStreams",s),label:"Engine messages",hint:"Internal orchestration signals",safety:"safe",value:t.engineStreamsExpire,onChange:s=>a("engineStreamsExpire",s)}),e.jsx(v,{checked:t.workerStreams,onToggle:s=>a("workerStreams",s),label:"Worker messages",hint:"Activity dispatch and response payloads",safety:"safe",value:t.workerStreamsExpire,onChange:s=>a("workerStreamsExpire",s)})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:"Completed Workflows"}),e.jsx("p",{className:"text-[10px] text-text-tertiary mb-4",children:"Choose how to handle completed workflow records. Reducing strips step-level detail but keeps the workflow and its results. Deleting removes the record entirely."}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("label",{className:"flex items-start gap-2.5 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"workflow-cleanup",checked:!t.stripAttributes&&!t.pruneJobs,onChange:()=>r({...t,stripAttributes:!1,pruneJobs:!1}),className:"w-4 h-4 mt-0.5 accent-accent shrink-0"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-xs text-text-primary",children:"Keep as-is"}),e.jsx("p",{className:"text-[10px] text-text-tertiary",children:"No changes to completed workflow records."})]})]}),e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsxs("label",{className:"flex items-start gap-2.5 cursor-pointer w-80 shrink-0",children:[e.jsx("input",{type:"radio",name:"workflow-cleanup",checked:t.stripAttributes&&!t.pruneJobs,onChange:()=>r({...t,stripAttributes:!0,pruneJobs:!1}),className:"w-4 h-4 mt-0.5 accent-accent shrink-0"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-text-primary",children:"Reduce completed workflows"}),e.jsxs("span",{className:"flex items-center gap-0.5 text-[9px] text-status-warning",children:[e.jsx(E,{className:"w-3 h-3",strokeWidth:1.5}),"Careful"]})]}),e.jsx("p",{className:"text-[10px] text-text-tertiary",children:"Strips step-level execution detail (activity inputs/outputs, internal state). Workflow results and timeline are preserved."})]})]}),e.jsx("select",{value:t.expire,onChange:s=>a("expire",s.target.value),disabled:!t.stripAttributes||t.pruneJobs,className:`select text-xs w-36 transition-opacity mt-0.5 ${!t.stripAttributes||t.pruneJobs?"opacity-40 cursor-not-allowed":""}`,children:g.map(s=>e.jsx("option",{value:s.value,children:s.label},s.value))})]}),e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsxs("label",{className:"flex items-start gap-2.5 cursor-pointer w-80 shrink-0",children:[e.jsx("input",{type:"radio",name:"workflow-cleanup",checked:t.pruneJobs,onChange:()=>r({...t,pruneJobs:!0,stripAttributes:!1}),className:"w-4 h-4 mt-0.5 accent-accent shrink-0"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-text-primary",children:"Delete completed workflows"}),e.jsxs("span",{className:"flex items-center gap-0.5 text-[9px] text-status-error",children:[e.jsx(T,{className:"w-3 h-3",strokeWidth:1.5}),"Permanent"]})]}),e.jsx("p",{className:"text-[10px] text-text-tertiary",children:"Permanently removes workflow records. Results, timeline, and all execution data are deleted and cannot be recovered."})]})]}),e.jsx("select",{value:t.expire,onChange:s=>a("expire",s.target.value),disabled:!t.pruneJobs,className:`select text-xs w-36 transition-opacity mt-0.5 ${t.pruneJobs?"":"opacity-40 cursor-not-allowed"}`,children:g.map(s=>e.jsx("option",{value:s.value,children:s.label},s.value))})]})]}),e.jsx(L,{})]})]})}function p({label:t,value:r}){return e.jsxs("div",{children:[e.jsx("p",{className:"text-lg font-light text-text-primary",children:r.toLocaleString()}),e.jsx("p",{className:"text-[10px] text-text-tertiary",children:t})]})}function U(){const t=q(),[r,a]=d.useState(f),[s,i]=d.useState(null),[l,c]=d.useState(!1),n=()=>{i(null),t.mutate({expire:r.expire,jobs:r.pruneJobs,engineStreams:r.engineStreams,engineStreamsExpire:r.engineStreamsExpire,workerStreams:r.workerStreams,workerStreamsExpire:r.workerStreamsExpire,attributes:r.stripAttributes,pruneTransient:r.pruneTransient},{onSuccess:o=>{i(o),c(!1)}})};return e.jsxs("div",{className:"space-y-8",children:[e.jsx(P,{fields:r,onChange:a}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-surface-border",children:[e.jsx("p",{className:"text-[10px] text-text-tertiary",children:N(r)?"This action permanently deletes data and cannot be undone.":"Select at least one operation to enable pruning."}),e.jsx("button",{onClick:()=>c(!0),disabled:!N(r)||t.isPending,className:"bg-status-error text-white px-4 py-1.5 rounded-md text-xs hover:opacity-90 transition-opacity disabled:opacity-40 shrink-0",children:t.isPending?"Pruning...":"Prune Now"})]}),s&&e.jsxs("div",{className:"bg-surface-sunken rounded-md px-4 py-3",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-2",children:"Results"}),e.jsxs("div",{className:"flex flex-wrap gap-6",children:[s.jobs!=null&&s.jobs>0&&e.jsx(p,{label:"Jobs deleted",value:s.jobs}),s.engineStreams!=null&&s.engineStreams>0&&e.jsx(p,{label:"Engine streams",value:s.engineStreams}),s.workerStreams!=null&&s.workerStreams>0&&e.jsx(p,{label:"Worker streams",value:s.workerStreams}),s.streams!=null&&s.engineStreams==null&&s.streams>0&&e.jsx(p,{label:"Streams",value:s.streams}),s.attributes!=null&&s.attributes>0&&e.jsx(p,{label:"Artifacts stripped",value:s.attributes}),s.transient!=null&&s.transient>0&&e.jsx(p,{label:"Transient deleted",value:s.transient}),s.marked!=null&&s.marked>0&&e.jsx(p,{label:"Marked pruned",value:s.marked}),Object.values(s).every(o=>!o||o===0)&&e.jsx("p",{className:"text-xs text-text-tertiary",children:"Nothing to prune within the selected retention windows."})]})]}),t.error&&e.jsx("p",{className:"text-xs text-status-error",children:t.error.message}),e.jsx(M,{open:l,onClose:()=>c(!1),title:"Confirm Prune",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-text-secondary",children:"This will permanently delete data. This action cannot be undone."}),e.jsxs("ul",{className:"text-xs text-text-secondary space-y-1 list-disc list-inside",children:[r.pruneJobs&&e.jsxs("li",{children:["Delete jobs older than ",r.expire]}),r.engineStreams&&e.jsxs("li",{children:["Delete engine streams older than ",r.engineStreamsExpire]}),r.workerStreams&&e.jsxs("li",{children:["Delete worker streams older than ",r.workerStreamsExpire]}),r.stripAttributes&&e.jsx("li",{children:"Strip execution artifacts from completed jobs"}),r.pruneTransient&&e.jsx("li",{children:"Delete transient (entity-less) jobs"})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[e.jsx("button",{onClick:()=>c(!1),className:"btn-secondary text-xs",children:"Cancel"}),e.jsx("button",{onClick:n,className:"bg-status-error text-white px-3 py-1.5 rounded-md text-xs hover:opacity-90 transition-opacity",disabled:t.isPending,children:t.isPending?"Pruning...":"Confirm Prune"})]})]})})]})}function w(t){var c;if(!((c=t==null?void 0:t.rules)!=null&&c.length))return f;const r=t.rules,a=r.find(n=>n.target==="streams"&&n.action==="delete"),s=r.find(n=>n.target==="jobs"&&n.action==="delete"&&n.hasEntity===!1),i=r.find(n=>n.target==="jobs"&&n.action==="prune"&&n.hasEntity===!0),l=r.find(n=>n.target==="jobs"&&n.action==="delete"&&n.pruned===!0);return{pruneJobs:!!l,expire:(l==null?void 0:l.olderThan)??"180 days",engineStreams:!!a,engineStreamsExpire:(a==null?void 0:a.olderThan)??"1 day",workerStreams:!!a,workerStreamsExpire:(a==null?void 0:a.olderThan)??"90 days",stripAttributes:!!i,pruneTransient:!!s}}function H(t){const r=[];return t.engineStreams&&r.push({target:"streams",action:"delete",olderThan:t.engineStreamsExpire}),t.workerStreams&&t.workerStreamsExpire!==t.engineStreamsExpire&&r.push({target:"streams",action:"delete",olderThan:t.workerStreamsExpire}),t.pruneTransient&&r.push({target:"jobs",action:"delete",olderThan:t.expire,hasEntity:!1}),t.stripAttributes&&r.push({target:"jobs",action:"prune",olderThan:t.expire,hasEntity:!0}),t.pruneJobs&&r.push({target:"jobs",action:"delete",olderThan:t.expire,pruned:!0}),r}function S(t){var r;return((r=C.find(a=>a.value===t))==null?void 0:r.label)??""}function K(){const{data:t,isLoading:r}=$(),a=_(),[s,i]=d.useState(""),[l,c]=d.useState(f),[n,o]=d.useState(""),m=d.useCallback(()=>{t!=null&&t.config&&(i(t.config.schedule),c(w(t.config)),o(JSON.stringify({schedule:t.config.schedule,fields:w(t.config)})))},[t]);d.useEffect(()=>{m()},[m]);const x=JSON.stringify({schedule:s,fields:l}),y=n!==""&&x!==n,h=(t==null?void 0:t.active)??!1,J=()=>{const u=H(l);a.mutate({schedule:s,rules:u},{onSuccess:()=>{o(JSON.stringify({schedule:s,fields:l}))}})},A=()=>{m()};return r?e.jsx("div",{className:"animate-pulse h-40 bg-surface-sunken rounded"}):e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[1fr_auto] gap-10",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-4",children:"Schedule"}),e.jsxs("div",{className:"flex items-end gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] text-text-tertiary mb-1",children:"Cron Expression"}),e.jsx("input",{type:"text",value:s,onChange:u=>i(u.target.value),placeholder:"0 2 * * *",className:"input text-xs font-mono w-48"})]}),e.jsx("div",{children:e.jsxs("div",{className:"flex items-center gap-1.5 h-8",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full dot-ring ${h?"bg-status-success":"bg-text-tertiary"}`}),e.jsx("span",{className:`text-xs ${h?"text-status-success":"text-text-tertiary"}`,children:h?"Active":"Inactive"})]})}),S(s)&&e.jsx("p",{className:"text-xs text-text-tertiary h-8 flex items-center",children:S(s)})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-3",children:C.map(u=>e.jsx("button",{type:"button",onClick:()=>i(u.value),className:`px-2.5 py-1 text-[10px] rounded-full transition-colors ${s===u.value?"bg-accent/10 text-accent font-medium":"bg-surface-sunken text-text-tertiary hover:text-text-secondary"}`,children:u.label},u.value))})]}),e.jsxs("div",{className:"lg:w-72",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-4",children:"How It Works"}),e.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 rounded bg-surface-sunken",children:[e.jsx(j,{className:"w-3.5 h-3.5 text-text-tertiary shrink-0 mt-0.5"}),e.jsx("p",{className:"text-[10px] text-text-tertiary leading-relaxed",children:"Rules execute sequentially on each cron cycle. Engine streams can be pruned aggressively since they only contain internal routing data. Worker streams should be retained longer to preserve execution playback and input enrichment."})]})]})]}),e.jsx(P,{fields:l,onChange:c}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-surface-border",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[y&&e.jsx("button",{onClick:A,className:"text-[10px] text-text-tertiary hover:text-text-primary transition-colors",children:"Revert changes"}),a.error&&e.jsx("p",{className:"text-xs text-status-error",children:a.error.message})]}),e.jsx("button",{onClick:J,disabled:!y||!s.trim()||a.isPending,className:"btn-primary text-xs disabled:opacity-40 shrink-0",children:a.isPending?"Saving...":"Save Schedule"})]})]})}function Q({mode:t,onChange:r}){const a=(s,i,l)=>e.jsxs("button",{onClick:()=>r(s),className:`flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md transition-colors ${t===s?"bg-accent/10 text-accent font-medium":"text-text-tertiary hover:text-text-secondary hover:bg-surface-hover"}`,children:[i,l]});return e.jsxs("div",{className:"flex gap-1 p-0.5 bg-surface-sunken rounded-lg w-fit",children:[a("prune",e.jsx(I,{className:"w-3.5 h-3.5"}),"Prune Now"),a("schedule",e.jsx(D,{className:"w-3.5 h-3.5"}),"Schedule")]})}function ee(){const[t,r]=d.useState("schedule");return e.jsxs("div",{children:[e.jsx(F,{title:"DB Maintenance",docsHash:"#docs:dashboard.md:db-maintenance",actions:e.jsx(Q,{mode:t,onChange:r})}),e.jsxs("div",{className:"flex items-start gap-2 px-4 py-3 mb-8 rounded-md bg-accent/5 border border-accent/10",children:[e.jsx(j,{className:"w-4 h-4 text-accent shrink-0 mt-0.5"}),e.jsx("p",{className:"text-xs text-text-secondary leading-relaxed",children:"Workflow data grows as jobs complete. Operations are ordered safest-first: stream messages are always safe to prune, workflow reduction preserves results, and deletion is permanent."})]}),t==="prune"?e.jsx(U,{}):e.jsx(K,{})]})}export{ee as MaintenancePage};
2
+ //# sourceMappingURL=index-DHhz71yv.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-D8GcHxNJ.js","sources":["../../src/api/maintenance.ts","../../src/pages/admin/maintenance/controls.tsx","../../src/pages/admin/maintenance/PruneSection.tsx","../../src/pages/admin/maintenance/ScheduleSection.tsx","../../src/pages/admin/maintenance/MaintenancePage.tsx"],"sourcesContent":["import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';\nimport { apiFetch } from './client';\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport interface MaintenanceRule {\n target: 'streams' | 'jobs';\n action: 'delete' | 'prune';\n olderThan: string;\n hasEntity?: boolean;\n pruned?: boolean;\n}\n\nexport interface MaintenanceConfig {\n schedule: string;\n rules: MaintenanceRule[];\n}\n\nexport interface PruneOptions {\n expire?: string;\n jobs?: boolean;\n streams?: boolean;\n engineStreams?: boolean;\n engineStreamsExpire?: string;\n workerStreams?: boolean;\n workerStreamsExpire?: string;\n attributes?: boolean;\n entities?: string[];\n pruneTransient?: boolean;\n keepHmark?: boolean;\n}\n\nexport interface PruneResult {\n jobs?: number;\n streams?: number;\n engineStreams?: number;\n workerStreams?: number;\n attributes?: number;\n transient?: number;\n marked?: number;\n}\n\n// ── Maintenance config ────────────────────────────────────────────────────────\n\nexport function useMaintenanceConfig() {\n return useQuery<{ config: MaintenanceConfig; active: boolean }>({\n queryKey: ['maintenance'],\n queryFn: () => apiFetch('/config/maintenance'),\n });\n}\n\nexport function useUpdateMaintenanceConfig() {\n const queryClient = useQueryClient();\n return useMutation<\n { config: MaintenanceConfig; restarted: boolean },\n Error,\n MaintenanceConfig\n >({\n mutationFn: (config) =>\n apiFetch('/config/maintenance', {\n method: 'PUT',\n body: JSON.stringify(config),\n }),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: ['maintenance'] });\n },\n });\n}\n\n// ── DBA operations ────────────────────────────────────────────────────────────\n\nexport function usePrune() {\n return useMutation<PruneResult, Error, PruneOptions>({\n mutationFn: (options) =>\n apiFetch('/dba/prune', {\n method: 'POST',\n body: JSON.stringify(options),\n }),\n });\n}\n\nexport function useDeploy() {\n return useMutation<{ ok: boolean }, Error, void>({\n mutationFn: () =>\n apiFetch('/dba/deploy', { method: 'POST' }),\n });\n}\n","import { Info, ShieldCheck, ShieldAlert, ShieldOff } from 'lucide-react';\nimport { RETENTION_PERIOD_OPTIONS } from '../../../lib/constants';\n\n// ── Retention row (checkbox + label + select) ───────────────────────────────\n\nexport function RetentionRow({ checked, onToggle, label, hint, safety, value, onChange }: {\n checked: boolean;\n onToggle: (v: boolean) => void;\n label: string;\n hint: string;\n safety: 'safe' | 'moderate' | 'destructive';\n value: string;\n onChange: (v: string) => void;\n}) {\n const SafetyIcon = safety === 'safe' ? ShieldCheck : safety === 'moderate' ? ShieldAlert : ShieldOff;\n const safetyColor = safety === 'safe' ? 'text-status-success' : safety === 'moderate' ? 'text-status-warning' : 'text-status-error';\n const safetyLabel = safety === 'safe' ? 'Safe' : safety === 'moderate' ? 'Careful' : 'Permanent';\n\n return (\n <div className=\"flex items-center gap-4\">\n <label className=\"flex items-center gap-2.5 cursor-pointer w-80 shrink-0\">\n <input\n type=\"checkbox\"\n checked={checked}\n onChange={(e) => onToggle(e.target.checked)}\n className=\"w-4 h-4 rounded border-border accent-accent shrink-0\"\n />\n <div className=\"flex-1\">\n <div className=\"flex items-center gap-2\">\n <span className=\"text-xs text-text-primary\">{label}</span>\n <span className={`flex items-center gap-0.5 text-[9px] ${safetyColor}`}>\n <SafetyIcon className=\"w-3 h-3\" strokeWidth={1.5} />\n {safetyLabel}\n </span>\n </div>\n <p className=\"text-[10px] text-text-tertiary\">{hint}</p>\n </div>\n </label>\n <select\n value={value}\n onChange={(e) => onChange(e.target.value)}\n disabled={!checked}\n className={`select text-xs w-36 transition-opacity ${!checked ? 'opacity-40 cursor-not-allowed' : ''}`}\n >\n {RETENTION_PERIOD_OPTIONS.map((opt) => (\n <option key={opt.value} value={opt.value}>{opt.label}</option>\n ))}\n </select>\n </div>\n );\n}\n\n// ── Cleanup checkbox ────────────────────────────────────────────────────────\n\nexport function CleanupCheck({ checked, onChange, label, description, safety }: {\n checked: boolean;\n onChange: (v: boolean) => void;\n label: string;\n description: string;\n safety: 'safe' | 'moderate' | 'destructive';\n}) {\n const SafetyIcon = safety === 'safe' ? ShieldCheck : safety === 'moderate' ? ShieldAlert : ShieldOff;\n const safetyColor = safety === 'safe' ? 'text-status-success' : safety === 'moderate' ? 'text-status-warning' : 'text-status-error';\n const safetyLabel = safety === 'safe' ? 'Safe' : safety === 'moderate' ? 'Careful' : 'Permanent';\n\n return (\n <label className=\"flex items-start gap-2.5 cursor-pointer\">\n <input\n type=\"checkbox\"\n checked={checked}\n onChange={(e) => onChange(e.target.checked)}\n className=\"w-4 h-4 mt-0.5 rounded border-border accent-accent shrink-0\"\n />\n <div>\n <div className=\"flex items-center gap-2\">\n <span className=\"text-xs text-text-primary\">{label}</span>\n <span className={`flex items-center gap-0.5 text-[9px] ${safetyColor}`}>\n <SafetyIcon className=\"w-3 h-3\" strokeWidth={1.5} />\n {safetyLabel}\n </span>\n </div>\n <p className=\"text-[10px] text-text-tertiary\">{description}</p>\n </div>\n </label>\n );\n}\n\n// ── Cleanup callout ─────────────────────────────────────────────────────────\n\nexport function CleanupCallout() {\n return (\n <div className=\"flex items-start gap-2 mt-2 px-3 py-2 rounded bg-surface-sunken\">\n <Info className=\"w-3.5 h-3.5 text-text-tertiary shrink-0 mt-0.5\" />\n <p className=\"text-[10px] text-text-tertiary leading-relaxed\">\n Stripping preserves workflow results and timeline data needed for the execution detail view.\n Transient jobs are internal bookkeeping that accumulates over time.\n </p>\n </div>\n );\n}\n\n// ── Prune fields state shape (shared between both panels) ───────────────────\n\nexport interface PruneFields {\n pruneJobs: boolean;\n expire: string;\n engineStreams: boolean;\n engineStreamsExpire: string;\n workerStreams: boolean;\n workerStreamsExpire: string;\n stripAttributes: boolean;\n pruneTransient: boolean;\n}\n\nexport const DEFAULT_PRUNE_FIELDS: PruneFields = {\n pruneJobs: true,\n expire: '30 days',\n engineStreams: true,\n engineStreamsExpire: '1 day',\n workerStreams: true,\n workerStreamsExpire: '90 days',\n stripAttributes: false,\n pruneTransient: false,\n};\n\nexport function hasSelection(f: PruneFields): boolean {\n return f.pruneJobs || f.engineStreams || f.workerStreams || f.stripAttributes || f.pruneTransient;\n}\n\n// ── Prune fields editor (reused by both Prune Now and Schedule) ─────────────\n\nexport function PruneFieldsEditor({ fields, onChange }: {\n fields: PruneFields;\n onChange: (f: PruneFields) => void;\n}) {\n const set = <K extends keyof PruneFields>(key: K, value: PruneFields[K]) =>\n onChange({ ...fields, [key]: value });\n\n return (\n <div className=\"space-y-8\">\n {/* Stream messages — always safe to prune */}\n <div>\n <p className=\"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-1\">\n Stream Messages\n </p>\n <p className=\"text-[10px] text-text-tertiary mb-4\">\n Processed routing messages. Already consumed — safe to remove after a short retention window.\n </p>\n <div className=\"space-y-3\">\n <RetentionRow\n checked={fields.engineStreams} onToggle={(v) => set('engineStreams', v)}\n label=\"Engine messages\" hint=\"Internal orchestration signals\"\n safety=\"safe\"\n value={fields.engineStreamsExpire} onChange={(v) => set('engineStreamsExpire', v)}\n />\n <RetentionRow\n checked={fields.workerStreams} onToggle={(v) => set('workerStreams', v)}\n label=\"Worker messages\" hint=\"Activity dispatch and response payloads\"\n safety=\"safe\"\n value={fields.workerStreamsExpire} onChange={(v) => set('workerStreamsExpire', v)}\n />\n </div>\n </div>\n\n {/* Workflow data — mutually exclusive: reduce OR delete */}\n <div>\n <p className=\"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-1\">\n Completed Workflows\n </p>\n <p className=\"text-[10px] text-text-tertiary mb-4\">\n Choose how to handle completed workflow records. Reducing strips step-level detail\n but keeps the workflow and its results. Deleting removes the record entirely.\n </p>\n <div className=\"space-y-3\">\n <label className=\"flex items-start gap-2.5 cursor-pointer\">\n <input\n type=\"radio\"\n name=\"workflow-cleanup\"\n checked={!fields.stripAttributes && !fields.pruneJobs}\n onChange={() => onChange({ ...fields, stripAttributes: false, pruneJobs: false })}\n className=\"w-4 h-4 mt-0.5 accent-accent shrink-0\"\n />\n <div>\n <span className=\"text-xs text-text-primary\">Keep as-is</span>\n <p className=\"text-[10px] text-text-tertiary\">No changes to completed workflow records.</p>\n </div>\n </label>\n\n <div className=\"flex items-start gap-2.5\">\n <label className=\"flex items-start gap-2.5 cursor-pointer w-80 shrink-0\">\n <input\n type=\"radio\"\n name=\"workflow-cleanup\"\n checked={fields.stripAttributes && !fields.pruneJobs}\n onChange={() => onChange({ ...fields, stripAttributes: true, pruneJobs: false })}\n className=\"w-4 h-4 mt-0.5 accent-accent shrink-0\"\n />\n <div>\n <div className=\"flex items-center gap-2\">\n <span className=\"text-xs text-text-primary\">Reduce completed workflows</span>\n <span className=\"flex items-center gap-0.5 text-[9px] text-status-warning\">\n <ShieldAlert className=\"w-3 h-3\" strokeWidth={1.5} />\n Careful\n </span>\n </div>\n <p className=\"text-[10px] text-text-tertiary\">\n Strips step-level execution detail (activity inputs/outputs, internal state).\n Workflow results and timeline are preserved.\n </p>\n </div>\n </label>\n <select\n value={fields.expire}\n onChange={(e) => set('expire', e.target.value)}\n disabled={!fields.stripAttributes || fields.pruneJobs}\n className={`select text-xs w-36 transition-opacity mt-0.5 ${!fields.stripAttributes || fields.pruneJobs ? 'opacity-40 cursor-not-allowed' : ''}`}\n >\n {RETENTION_PERIOD_OPTIONS.map((opt) => (\n <option key={opt.value} value={opt.value}>{opt.label}</option>\n ))}\n </select>\n </div>\n\n <div className=\"flex items-start gap-2.5\">\n <label className=\"flex items-start gap-2.5 cursor-pointer w-80 shrink-0\">\n <input\n type=\"radio\"\n name=\"workflow-cleanup\"\n checked={fields.pruneJobs}\n onChange={() => onChange({ ...fields, pruneJobs: true, stripAttributes: false })}\n className=\"w-4 h-4 mt-0.5 accent-accent shrink-0\"\n />\n <div>\n <div className=\"flex items-center gap-2\">\n <span className=\"text-xs text-text-primary\">Delete completed workflows</span>\n <span className=\"flex items-center gap-0.5 text-[9px] text-status-error\">\n <ShieldOff className=\"w-3 h-3\" strokeWidth={1.5} />\n Permanent\n </span>\n </div>\n <p className=\"text-[10px] text-text-tertiary\">\n Permanently removes workflow records. Results, timeline, and all\n execution data are deleted and cannot be recovered.\n </p>\n </div>\n </label>\n <select\n value={fields.expire}\n onChange={(e) => set('expire', e.target.value)}\n disabled={!fields.pruneJobs}\n className={`select text-xs w-36 transition-opacity mt-0.5 ${!fields.pruneJobs ? 'opacity-40 cursor-not-allowed' : ''}`}\n >\n {RETENTION_PERIOD_OPTIONS.map((opt) => (\n <option key={opt.value} value={opt.value}>{opt.label}</option>\n ))}\n </select>\n </div>\n </div>\n <CleanupCallout />\n </div>\n </div>\n );\n}\n","import { useState } from 'react';\nimport { usePrune, type PruneResult } from '../../../api/maintenance';\nimport { Modal } from '../../../components/common/modal/Modal';\nimport { PruneFieldsEditor, DEFAULT_PRUNE_FIELDS, hasSelection, type PruneFields } from './controls';\n\nfunction ResultCard({ label, value }: { label: string; value: number }) {\n return (\n <div>\n <p className=\"text-lg font-light text-text-primary\">{value.toLocaleString()}</p>\n <p className=\"text-[10px] text-text-tertiary\">{label}</p>\n </div>\n );\n}\n\nexport function PruneSection() {\n const prune = usePrune();\n const [fields, setFields] = useState<PruneFields>(DEFAULT_PRUNE_FIELDS);\n const [result, setResult] = useState<PruneResult | null>(null);\n const [showConfirm, setShowConfirm] = useState(false);\n\n const handlePrune = () => {\n setResult(null);\n prune.mutate(\n {\n expire: fields.expire,\n jobs: fields.pruneJobs,\n engineStreams: fields.engineStreams,\n engineStreamsExpire: fields.engineStreamsExpire,\n workerStreams: fields.workerStreams,\n workerStreamsExpire: fields.workerStreamsExpire,\n attributes: fields.stripAttributes,\n pruneTransient: fields.pruneTransient,\n },\n {\n onSuccess: (data) => {\n setResult(data);\n setShowConfirm(false);\n },\n },\n );\n };\n\n return (\n <div className=\"space-y-8\">\n <PruneFieldsEditor fields={fields} onChange={setFields} />\n\n {/* Action bar */}\n <div className=\"flex items-center justify-between pt-2 border-t border-surface-border\">\n <p className=\"text-[10px] text-text-tertiary\">\n {!hasSelection(fields)\n ? 'Select at least one operation to enable pruning.'\n : 'This action permanently deletes data and cannot be undone.'}\n </p>\n <button\n onClick={() => setShowConfirm(true)}\n disabled={!hasSelection(fields) || prune.isPending}\n className=\"bg-status-error text-white px-4 py-1.5 rounded-md text-xs hover:opacity-90 transition-opacity disabled:opacity-40 shrink-0\"\n >\n {prune.isPending ? 'Pruning...' : 'Prune Now'}\n </button>\n </div>\n\n {/* Results */}\n {result && (\n <div className=\"bg-surface-sunken rounded-md px-4 py-3\">\n <p className=\"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-2\">\n Results\n </p>\n <div className=\"flex flex-wrap gap-6\">\n {result.jobs != null && result.jobs > 0 && <ResultCard label=\"Jobs deleted\" value={result.jobs} />}\n {result.engineStreams != null && result.engineStreams > 0 && <ResultCard label=\"Engine streams\" value={result.engineStreams} />}\n {result.workerStreams != null && result.workerStreams > 0 && <ResultCard label=\"Worker streams\" value={result.workerStreams} />}\n {result.streams != null && result.engineStreams == null && result.streams > 0 && <ResultCard label=\"Streams\" value={result.streams} />}\n {result.attributes != null && result.attributes > 0 && <ResultCard label=\"Artifacts stripped\" value={result.attributes} />}\n {result.transient != null && result.transient > 0 && <ResultCard label=\"Transient deleted\" value={result.transient} />}\n {result.marked != null && result.marked > 0 && <ResultCard label=\"Marked pruned\" value={result.marked} />}\n {Object.values(result).every((v) => !v || v === 0) && (\n <p className=\"text-xs text-text-tertiary\">Nothing to prune within the selected retention windows.</p>\n )}\n </div>\n </div>\n )}\n\n {prune.error && (\n <p className=\"text-xs text-status-error\">{(prune.error as Error).message}</p>\n )}\n\n {/* Confirm modal */}\n <Modal open={showConfirm} onClose={() => setShowConfirm(false)} title=\"Confirm Prune\">\n <div className=\"space-y-4\">\n <p className=\"text-sm text-text-secondary\">\n This will permanently delete data. This action cannot be undone.\n </p>\n <ul className=\"text-xs text-text-secondary space-y-1 list-disc list-inside\">\n {fields.pruneJobs && <li>Delete jobs older than {fields.expire}</li>}\n {fields.engineStreams && <li>Delete engine streams older than {fields.engineStreamsExpire}</li>}\n {fields.workerStreams && <li>Delete worker streams older than {fields.workerStreamsExpire}</li>}\n {fields.stripAttributes && <li>Strip execution artifacts from completed jobs</li>}\n {fields.pruneTransient && <li>Delete transient (entity-less) jobs</li>}\n </ul>\n <div className=\"flex justify-end gap-3 pt-2\">\n <button onClick={() => setShowConfirm(false)} className=\"btn-secondary text-xs\">Cancel</button>\n <button\n onClick={handlePrune}\n className=\"bg-status-error text-white px-3 py-1.5 rounded-md text-xs hover:opacity-90 transition-opacity\"\n disabled={prune.isPending}\n >\n {prune.isPending ? 'Pruning...' : 'Confirm Prune'}\n </button>\n </div>\n </div>\n </Modal>\n </div>\n );\n}\n","import { useState, useEffect, useCallback } from 'react';\nimport { Info } from 'lucide-react';\nimport {\n useMaintenanceConfig,\n useUpdateMaintenanceConfig,\n type MaintenanceConfig,\n} from '../../../api/maintenance';\nimport { CRON_PRESETS } from '../../../lib/constants';\nimport { PruneFieldsEditor, DEFAULT_PRUNE_FIELDS, type PruneFields } from './controls';\n\n// ── Helpers ─────────────────────────────────────────────────────────────────\n\n/** Convert a MaintenanceConfig (rules array) into PruneFields for the editor. */\nfunction configToFields(config: MaintenanceConfig | undefined): PruneFields {\n if (!config?.rules?.length) return DEFAULT_PRUNE_FIELDS;\n const r = config.rules;\n const streamDelete = r.find((x) => x.target === 'streams' && x.action === 'delete');\n const jobDeleteTransient = r.find((x) => x.target === 'jobs' && x.action === 'delete' && x.hasEntity === false);\n const jobPrune = r.find((x) => x.target === 'jobs' && x.action === 'prune' && x.hasEntity === true);\n const jobDeletePruned = r.find((x) => x.target === 'jobs' && x.action === 'delete' && x.pruned === true);\n return {\n pruneJobs: !!jobDeletePruned,\n expire: jobDeletePruned?.olderThan ?? '180 days',\n engineStreams: !!streamDelete,\n engineStreamsExpire: streamDelete?.olderThan ?? '1 day',\n workerStreams: !!streamDelete,\n workerStreamsExpire: streamDelete?.olderThan ?? '90 days',\n stripAttributes: !!jobPrune,\n pruneTransient: !!jobDeleteTransient,\n };\n}\n\n/** Convert PruneFields back to a MaintenanceConfig rules array. */\nfunction fieldsToRules(f: PruneFields): MaintenanceConfig['rules'] {\n const rules: MaintenanceConfig['rules'] = [];\n if (f.engineStreams) {\n rules.push({ target: 'streams', action: 'delete', olderThan: f.engineStreamsExpire });\n }\n if (f.workerStreams && f.workerStreamsExpire !== f.engineStreamsExpire) {\n rules.push({ target: 'streams', action: 'delete', olderThan: f.workerStreamsExpire });\n }\n if (f.pruneTransient) {\n rules.push({ target: 'jobs', action: 'delete', olderThan: f.expire, hasEntity: false });\n }\n if (f.stripAttributes) {\n rules.push({ target: 'jobs', action: 'prune', olderThan: f.expire, hasEntity: true });\n }\n if (f.pruneJobs) {\n rules.push({ target: 'jobs', action: 'delete', olderThan: f.expire, pruned: true });\n }\n return rules;\n}\n\nfunction describeCron(expr: string): string {\n return CRON_PRESETS.find((p) => p.value === expr)?.label ?? '';\n}\n\n// ── Main ────────────────────────────────────────────────────────────────────\n\nexport function ScheduleSection() {\n const { data, isLoading } = useMaintenanceConfig();\n const updateConfig = useUpdateMaintenanceConfig();\n\n const [schedule, setSchedule] = useState('');\n const [fields, setFields] = useState<PruneFields>(DEFAULT_PRUNE_FIELDS);\n const [savedSnapshot, setSavedSnapshot] = useState('');\n\n // Sync from server config when loaded\n const syncFromServer = useCallback(() => {\n if (!data?.config) return;\n setSchedule(data.config.schedule);\n setFields(configToFields(data.config));\n setSavedSnapshot(JSON.stringify({ schedule: data.config.schedule, fields: configToFields(data.config) }));\n }, [data]);\n\n useEffect(() => { syncFromServer(); }, [syncFromServer]);\n\n const currentSnapshot = JSON.stringify({ schedule, fields });\n const isDirty = savedSnapshot !== '' && currentSnapshot !== savedSnapshot;\n const active = data?.active ?? false;\n\n const handleSave = () => {\n const rules = fieldsToRules(fields);\n updateConfig.mutate(\n { schedule, rules },\n {\n onSuccess: () => {\n setSavedSnapshot(JSON.stringify({ schedule, fields }));\n },\n },\n );\n };\n\n const handleRevert = () => {\n syncFromServer();\n };\n\n if (isLoading) {\n return <div className=\"animate-pulse h-40 bg-surface-sunken rounded\" />;\n }\n\n return (\n <div className=\"space-y-8\">\n {/* Cron schedule + status */}\n <div className=\"grid grid-cols-1 lg:grid-cols-[1fr_auto] gap-10\">\n <div>\n <p className=\"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-4\">\n Schedule\n </p>\n <div className=\"flex items-end gap-4\">\n <div>\n <label className=\"block text-[10px] text-text-tertiary mb-1\">Cron Expression</label>\n <input\n type=\"text\"\n value={schedule}\n onChange={(e) => setSchedule(e.target.value)}\n placeholder=\"0 2 * * *\"\n className=\"input text-xs font-mono w-48\"\n />\n </div>\n <div>\n <div className=\"flex items-center gap-1.5 h-8\">\n <span className={`w-1.5 h-1.5 rounded-full dot-ring ${active ? 'bg-status-success' : 'bg-text-tertiary'}`} />\n <span className={`text-xs ${active ? 'text-status-success' : 'text-text-tertiary'}`}>\n {active ? 'Active' : 'Inactive'}\n </span>\n </div>\n </div>\n {describeCron(schedule) && (\n <p className=\"text-xs text-text-tertiary h-8 flex items-center\">{describeCron(schedule)}</p>\n )}\n </div>\n\n {/* Preset pills */}\n <div className=\"flex flex-wrap gap-1.5 mt-3\">\n {CRON_PRESETS.map((preset) => (\n <button\n key={preset.value}\n type=\"button\"\n onClick={() => setSchedule(preset.value)}\n className={`px-2.5 py-1 text-[10px] rounded-full transition-colors ${\n schedule === preset.value\n ? 'bg-accent/10 text-accent font-medium'\n : 'bg-surface-sunken text-text-tertiary hover:text-text-secondary'\n }`}\n >\n {preset.label}\n </button>\n ))}\n </div>\n </div>\n\n <div className=\"lg:w-72\">\n <p className=\"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-4\">\n How It Works\n </p>\n <div className=\"flex items-start gap-2 px-3 py-2 rounded bg-surface-sunken\">\n <Info className=\"w-3.5 h-3.5 text-text-tertiary shrink-0 mt-0.5\" />\n <p className=\"text-[10px] text-text-tertiary leading-relaxed\">\n Rules execute sequentially on each cron cycle. Engine streams can be pruned aggressively\n since they only contain internal routing data. Worker streams should be retained longer\n to preserve execution playback and input enrichment.\n </p>\n </div>\n </div>\n </div>\n\n {/* Same prune fields as Prune Now */}\n <PruneFieldsEditor fields={fields} onChange={setFields} />\n\n {/* Action bar */}\n <div className=\"flex items-center justify-between pt-2 border-t border-surface-border\">\n <div className=\"flex items-center gap-3\">\n {isDirty && (\n <button\n onClick={handleRevert}\n className=\"text-[10px] text-text-tertiary hover:text-text-primary transition-colors\"\n >\n Revert changes\n </button>\n )}\n {updateConfig.error && (\n <p className=\"text-xs text-status-error\">{(updateConfig.error as Error).message}</p>\n )}\n </div>\n <button\n onClick={handleSave}\n disabled={!isDirty || !schedule.trim() || updateConfig.isPending}\n className=\"btn-primary text-xs disabled:opacity-40 shrink-0\"\n >\n {updateConfig.isPending ? 'Saving...' : 'Save Schedule'}\n </button>\n </div>\n </div>\n );\n}\n","import { useState } from 'react';\nimport { Trash2, Clock, Info } from 'lucide-react';\nimport { PageHeader } from '../../../components/common/layout/PageHeader';\nimport { PruneSection } from './PruneSection';\nimport { ScheduleSection } from './ScheduleSection';\n\ntype Mode = 'prune' | 'schedule';\n\nfunction ModeToggle({ mode, onChange }: { mode: Mode; onChange: (m: Mode) => void }) {\n const btn = (m: Mode, icon: React.ReactNode, label: string) => (\n <button\n onClick={() => onChange(m)}\n className={`flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md transition-colors ${\n mode === m\n ? 'bg-accent/10 text-accent font-medium'\n : 'text-text-tertiary hover:text-text-secondary hover:bg-surface-hover'\n }`}\n >\n {icon}\n {label}\n </button>\n );\n\n return (\n <div className=\"flex gap-1 p-0.5 bg-surface-sunken rounded-lg w-fit\">\n {btn('prune', <Trash2 className=\"w-3.5 h-3.5\" />, 'Prune Now')}\n {btn('schedule', <Clock className=\"w-3.5 h-3.5\" />, 'Schedule')}\n </div>\n );\n}\n\nexport function MaintenancePage() {\n const [mode, setMode] = useState<Mode>('schedule');\n\n return (\n <div>\n <PageHeader\n title=\"DB Maintenance\"\n docsHash=\"#docs:dashboard.md:db-maintenance\"\n actions={<ModeToggle mode={mode} onChange={setMode} />}\n />\n\n <div className=\"flex items-start gap-2 px-4 py-3 mb-8 rounded-md bg-accent/5 border border-accent/10\">\n <Info className=\"w-4 h-4 text-accent shrink-0 mt-0.5\" />\n <p className=\"text-xs text-text-secondary leading-relaxed\">\n Workflow data grows as jobs complete. Operations are ordered safest-first: stream messages are\n always safe to prune, workflow reduction preserves results, and deletion is permanent.\n </p>\n </div>\n\n {mode === 'prune' ? <PruneSection /> : <ScheduleSection />}\n </div>\n );\n}\n"],"names":["useMaintenanceConfig","useQuery","apiFetch","useUpdateMaintenanceConfig","queryClient","useQueryClient","useMutation","config","usePrune","options","RetentionRow","checked","onToggle","label","hint","safety","value","onChange","SafetyIcon","ShieldCheck","ShieldAlert","ShieldOff","safetyColor","safetyLabel","jsxs","jsx","e","RETENTION_PERIOD_OPTIONS","opt","CleanupCallout","Info","DEFAULT_PRUNE_FIELDS","hasSelection","f","PruneFieldsEditor","fields","set","key","v","ResultCard","PruneSection","prune","setFields","useState","result","setResult","showConfirm","setShowConfirm","handlePrune","data","Modal","configToFields","_a","streamDelete","x","jobDeleteTransient","jobPrune","jobDeletePruned","fieldsToRules","rules","describeCron","expr","CRON_PRESETS","p","ScheduleSection","isLoading","updateConfig","schedule","setSchedule","savedSnapshot","setSavedSnapshot","syncFromServer","useCallback","useEffect","currentSnapshot","isDirty","active","handleSave","handleRevert","preset","ModeToggle","mode","btn","m","icon","Trash2","Clock","MaintenancePage","setMode","PageHeader"],"mappings":"2WA4CO,SAASA,GAAuB,CACrC,OAAOC,EAAyD,CAC9D,SAAU,CAAC,aAAa,EACxB,QAAS,IAAMC,EAAS,qBAAqB,CAAA,CAC9C,CACH,CAEO,SAASC,GAA6B,CAC3C,MAAMC,EAAcC,EAAA,EACpB,OAAOC,EAIL,CACA,WAAaC,GACXL,EAAS,sBAAuB,CAC9B,OAAQ,MACR,KAAM,KAAK,UAAUK,CAAM,CAAA,CAC5B,EACH,UAAW,IAAM,CACfH,EAAY,kBAAkB,CAAE,SAAU,CAAC,aAAa,EAAG,CAC7D,CAAA,CACD,CACH,CAIO,SAASI,GAAW,CACzB,OAAOF,EAA8C,CACnD,WAAaG,GACXP,EAAS,aAAc,CACrB,OAAQ,OACR,KAAM,KAAK,UAAUO,CAAO,CAAA,CAC7B,CAAA,CACJ,CACH,CC1EO,SAASC,EAAa,CAAE,QAAAC,EAAS,SAAAC,EAAU,MAAAC,EAAO,KAAAC,EAAM,OAAAC,EAAQ,MAAAC,EAAO,SAAAC,GAQ3E,CACD,MAAMC,EAAaH,IAAW,OAASI,EAAcJ,IAAW,WAAaK,EAAcC,EACrFC,EAAcP,IAAW,OAAS,sBAAwBA,IAAW,WAAa,sBAAwB,oBAC1GQ,EAAcR,IAAW,OAAS,OAASA,IAAW,WAAa,UAAY,YAErF,OACES,EAAAA,KAAC,MAAA,CAAI,UAAU,0BACb,SAAA,CAAAA,EAAAA,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AA,CAAAC,EAAAA,IAACK,EAAA,CAAK,UAAU,qCAAA,CAAsC,EACtDL,EAAAA,IAAC,IAAA,CAAE,UAAU,8CAA8C,SAAA,uLAAA,CAG3D,CAAA,EACF,EAECwD,IAAS,QAAUxD,MAACe,EAAA,CAAA,CAAa,QAAMwB,EAAA,CAAA,CAAgB,CAAA,EAC1D,CAEJ"}
1
+ {"version":3,"file":"index-DHhz71yv.js","sources":["../../src/api/maintenance.ts","../../src/pages/admin/maintenance/controls.tsx","../../src/pages/admin/maintenance/PruneSection.tsx","../../src/pages/admin/maintenance/ScheduleSection.tsx","../../src/pages/admin/maintenance/MaintenancePage.tsx"],"sourcesContent":["import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';\nimport { apiFetch } from './client';\n\n// ── Types ─────────────────────────────────────────────────────────────────────\n\nexport interface MaintenanceRule {\n target: 'streams' | 'jobs';\n action: 'delete' | 'prune';\n olderThan: string;\n hasEntity?: boolean;\n pruned?: boolean;\n}\n\nexport interface MaintenanceConfig {\n schedule: string;\n rules: MaintenanceRule[];\n}\n\nexport interface PruneOptions {\n expire?: string;\n jobs?: boolean;\n streams?: boolean;\n engineStreams?: boolean;\n engineStreamsExpire?: string;\n workerStreams?: boolean;\n workerStreamsExpire?: string;\n attributes?: boolean;\n entities?: string[];\n pruneTransient?: boolean;\n keepHmark?: boolean;\n}\n\nexport interface PruneResult {\n jobs?: number;\n streams?: number;\n engineStreams?: number;\n workerStreams?: number;\n attributes?: number;\n transient?: number;\n marked?: number;\n}\n\n// ── Maintenance config ────────────────────────────────────────────────────────\n\nexport function useMaintenanceConfig() {\n return useQuery<{ config: MaintenanceConfig; active: boolean }>({\n queryKey: ['maintenance'],\n queryFn: () => apiFetch('/config/maintenance'),\n });\n}\n\nexport function useUpdateMaintenanceConfig() {\n const queryClient = useQueryClient();\n return useMutation<\n { config: MaintenanceConfig; restarted: boolean },\n Error,\n MaintenanceConfig\n >({\n mutationFn: (config) =>\n apiFetch('/config/maintenance', {\n method: 'PUT',\n body: JSON.stringify(config),\n }),\n onSuccess: () => {\n queryClient.invalidateQueries({ queryKey: ['maintenance'] });\n },\n });\n}\n\n// ── DBA operations ────────────────────────────────────────────────────────────\n\nexport function usePrune() {\n return useMutation<PruneResult, Error, PruneOptions>({\n mutationFn: (options) =>\n apiFetch('/dba/prune', {\n method: 'POST',\n body: JSON.stringify(options),\n }),\n });\n}\n\nexport function useDeploy() {\n return useMutation<{ ok: boolean }, Error, void>({\n mutationFn: () =>\n apiFetch('/dba/deploy', { method: 'POST' }),\n });\n}\n","import { Info, ShieldCheck, ShieldAlert, ShieldOff } from 'lucide-react';\nimport { RETENTION_PERIOD_OPTIONS } from '../../../lib/constants';\n\n// ── Retention row (checkbox + label + select) ───────────────────────────────\n\nexport function RetentionRow({ checked, onToggle, label, hint, safety, value, onChange }: {\n checked: boolean;\n onToggle: (v: boolean) => void;\n label: string;\n hint: string;\n safety: 'safe' | 'moderate' | 'destructive';\n value: string;\n onChange: (v: string) => void;\n}) {\n const SafetyIcon = safety === 'safe' ? ShieldCheck : safety === 'moderate' ? ShieldAlert : ShieldOff;\n const safetyColor = safety === 'safe' ? 'text-status-success' : safety === 'moderate' ? 'text-status-warning' : 'text-status-error';\n const safetyLabel = safety === 'safe' ? 'Safe' : safety === 'moderate' ? 'Careful' : 'Permanent';\n\n return (\n <div className=\"flex items-center gap-4\">\n <label className=\"flex items-center gap-2.5 cursor-pointer w-80 shrink-0\">\n <input\n type=\"checkbox\"\n checked={checked}\n onChange={(e) => onToggle(e.target.checked)}\n className=\"w-4 h-4 rounded border-border accent-accent shrink-0\"\n />\n <div className=\"flex-1\">\n <div className=\"flex items-center gap-2\">\n <span className=\"text-xs text-text-primary\">{label}</span>\n <span className={`flex items-center gap-0.5 text-[9px] ${safetyColor}`}>\n <SafetyIcon className=\"w-3 h-3\" strokeWidth={1.5} />\n {safetyLabel}\n </span>\n </div>\n <p className=\"text-[10px] text-text-tertiary\">{hint}</p>\n </div>\n </label>\n <select\n value={value}\n onChange={(e) => onChange(e.target.value)}\n disabled={!checked}\n className={`select text-xs w-36 transition-opacity ${!checked ? 'opacity-40 cursor-not-allowed' : ''}`}\n >\n {RETENTION_PERIOD_OPTIONS.map((opt) => (\n <option key={opt.value} value={opt.value}>{opt.label}</option>\n ))}\n </select>\n </div>\n );\n}\n\n// ── Cleanup checkbox ────────────────────────────────────────────────────────\n\nexport function CleanupCheck({ checked, onChange, label, description, safety }: {\n checked: boolean;\n onChange: (v: boolean) => void;\n label: string;\n description: string;\n safety: 'safe' | 'moderate' | 'destructive';\n}) {\n const SafetyIcon = safety === 'safe' ? ShieldCheck : safety === 'moderate' ? ShieldAlert : ShieldOff;\n const safetyColor = safety === 'safe' ? 'text-status-success' : safety === 'moderate' ? 'text-status-warning' : 'text-status-error';\n const safetyLabel = safety === 'safe' ? 'Safe' : safety === 'moderate' ? 'Careful' : 'Permanent';\n\n return (\n <label className=\"flex items-start gap-2.5 cursor-pointer\">\n <input\n type=\"checkbox\"\n checked={checked}\n onChange={(e) => onChange(e.target.checked)}\n className=\"w-4 h-4 mt-0.5 rounded border-border accent-accent shrink-0\"\n />\n <div>\n <div className=\"flex items-center gap-2\">\n <span className=\"text-xs text-text-primary\">{label}</span>\n <span className={`flex items-center gap-0.5 text-[9px] ${safetyColor}`}>\n <SafetyIcon className=\"w-3 h-3\" strokeWidth={1.5} />\n {safetyLabel}\n </span>\n </div>\n <p className=\"text-[10px] text-text-tertiary\">{description}</p>\n </div>\n </label>\n );\n}\n\n// ── Cleanup callout ─────────────────────────────────────────────────────────\n\nexport function CleanupCallout() {\n return (\n <div className=\"flex items-start gap-2 mt-2 px-3 py-2 rounded bg-surface-sunken\">\n <Info className=\"w-3.5 h-3.5 text-text-tertiary shrink-0 mt-0.5\" />\n <p className=\"text-[10px] text-text-tertiary leading-relaxed\">\n Stripping preserves workflow results and timeline data needed for the execution detail view.\n Transient jobs are internal bookkeeping that accumulates over time.\n </p>\n </div>\n );\n}\n\n// ── Prune fields state shape (shared between both panels) ───────────────────\n\nexport interface PruneFields {\n pruneJobs: boolean;\n expire: string;\n engineStreams: boolean;\n engineStreamsExpire: string;\n workerStreams: boolean;\n workerStreamsExpire: string;\n stripAttributes: boolean;\n pruneTransient: boolean;\n}\n\nexport const DEFAULT_PRUNE_FIELDS: PruneFields = {\n pruneJobs: true,\n expire: '30 days',\n engineStreams: true,\n engineStreamsExpire: '1 day',\n workerStreams: true,\n workerStreamsExpire: '90 days',\n stripAttributes: false,\n pruneTransient: false,\n};\n\nexport function hasSelection(f: PruneFields): boolean {\n return f.pruneJobs || f.engineStreams || f.workerStreams || f.stripAttributes || f.pruneTransient;\n}\n\n// ── Prune fields editor (reused by both Prune Now and Schedule) ─────────────\n\nexport function PruneFieldsEditor({ fields, onChange }: {\n fields: PruneFields;\n onChange: (f: PruneFields) => void;\n}) {\n const set = <K extends keyof PruneFields>(key: K, value: PruneFields[K]) =>\n onChange({ ...fields, [key]: value });\n\n return (\n <div className=\"space-y-8\">\n {/* Stream messages — always safe to prune */}\n <div>\n <p className=\"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-1\">\n Stream Messages\n </p>\n <p className=\"text-[10px] text-text-tertiary mb-4\">\n Processed routing messages. Already consumed — safe to remove after a short retention window.\n </p>\n <div className=\"space-y-3\">\n <RetentionRow\n checked={fields.engineStreams} onToggle={(v) => set('engineStreams', v)}\n label=\"Engine messages\" hint=\"Internal orchestration signals\"\n safety=\"safe\"\n value={fields.engineStreamsExpire} onChange={(v) => set('engineStreamsExpire', v)}\n />\n <RetentionRow\n checked={fields.workerStreams} onToggle={(v) => set('workerStreams', v)}\n label=\"Worker messages\" hint=\"Activity dispatch and response payloads\"\n safety=\"safe\"\n value={fields.workerStreamsExpire} onChange={(v) => set('workerStreamsExpire', v)}\n />\n </div>\n </div>\n\n {/* Workflow data — mutually exclusive: reduce OR delete */}\n <div>\n <p className=\"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-1\">\n Completed Workflows\n </p>\n <p className=\"text-[10px] text-text-tertiary mb-4\">\n Choose how to handle completed workflow records. Reducing strips step-level detail\n but keeps the workflow and its results. Deleting removes the record entirely.\n </p>\n <div className=\"space-y-3\">\n <label className=\"flex items-start gap-2.5 cursor-pointer\">\n <input\n type=\"radio\"\n name=\"workflow-cleanup\"\n checked={!fields.stripAttributes && !fields.pruneJobs}\n onChange={() => onChange({ ...fields, stripAttributes: false, pruneJobs: false })}\n className=\"w-4 h-4 mt-0.5 accent-accent shrink-0\"\n />\n <div>\n <span className=\"text-xs text-text-primary\">Keep as-is</span>\n <p className=\"text-[10px] text-text-tertiary\">No changes to completed workflow records.</p>\n </div>\n </label>\n\n <div className=\"flex items-start gap-2.5\">\n <label className=\"flex items-start gap-2.5 cursor-pointer w-80 shrink-0\">\n <input\n type=\"radio\"\n name=\"workflow-cleanup\"\n checked={fields.stripAttributes && !fields.pruneJobs}\n onChange={() => onChange({ ...fields, stripAttributes: true, pruneJobs: false })}\n className=\"w-4 h-4 mt-0.5 accent-accent shrink-0\"\n />\n <div>\n <div className=\"flex items-center gap-2\">\n <span className=\"text-xs text-text-primary\">Reduce completed workflows</span>\n <span className=\"flex items-center gap-0.5 text-[9px] text-status-warning\">\n <ShieldAlert className=\"w-3 h-3\" strokeWidth={1.5} />\n Careful\n </span>\n </div>\n <p className=\"text-[10px] text-text-tertiary\">\n Strips step-level execution detail (activity inputs/outputs, internal state).\n Workflow results and timeline are preserved.\n </p>\n </div>\n </label>\n <select\n value={fields.expire}\n onChange={(e) => set('expire', e.target.value)}\n disabled={!fields.stripAttributes || fields.pruneJobs}\n className={`select text-xs w-36 transition-opacity mt-0.5 ${!fields.stripAttributes || fields.pruneJobs ? 'opacity-40 cursor-not-allowed' : ''}`}\n >\n {RETENTION_PERIOD_OPTIONS.map((opt) => (\n <option key={opt.value} value={opt.value}>{opt.label}</option>\n ))}\n </select>\n </div>\n\n <div className=\"flex items-start gap-2.5\">\n <label className=\"flex items-start gap-2.5 cursor-pointer w-80 shrink-0\">\n <input\n type=\"radio\"\n name=\"workflow-cleanup\"\n checked={fields.pruneJobs}\n onChange={() => onChange({ ...fields, pruneJobs: true, stripAttributes: false })}\n className=\"w-4 h-4 mt-0.5 accent-accent shrink-0\"\n />\n <div>\n <div className=\"flex items-center gap-2\">\n <span className=\"text-xs text-text-primary\">Delete completed workflows</span>\n <span className=\"flex items-center gap-0.5 text-[9px] text-status-error\">\n <ShieldOff className=\"w-3 h-3\" strokeWidth={1.5} />\n Permanent\n </span>\n </div>\n <p className=\"text-[10px] text-text-tertiary\">\n Permanently removes workflow records. Results, timeline, and all\n execution data are deleted and cannot be recovered.\n </p>\n </div>\n </label>\n <select\n value={fields.expire}\n onChange={(e) => set('expire', e.target.value)}\n disabled={!fields.pruneJobs}\n className={`select text-xs w-36 transition-opacity mt-0.5 ${!fields.pruneJobs ? 'opacity-40 cursor-not-allowed' : ''}`}\n >\n {RETENTION_PERIOD_OPTIONS.map((opt) => (\n <option key={opt.value} value={opt.value}>{opt.label}</option>\n ))}\n </select>\n </div>\n </div>\n <CleanupCallout />\n </div>\n </div>\n );\n}\n","import { useState } from 'react';\nimport { usePrune, type PruneResult } from '../../../api/maintenance';\nimport { Modal } from '../../../components/common/modal/Modal';\nimport { PruneFieldsEditor, DEFAULT_PRUNE_FIELDS, hasSelection, type PruneFields } from './controls';\n\nfunction ResultCard({ label, value }: { label: string; value: number }) {\n return (\n <div>\n <p className=\"text-lg font-light text-text-primary\">{value.toLocaleString()}</p>\n <p className=\"text-[10px] text-text-tertiary\">{label}</p>\n </div>\n );\n}\n\nexport function PruneSection() {\n const prune = usePrune();\n const [fields, setFields] = useState<PruneFields>(DEFAULT_PRUNE_FIELDS);\n const [result, setResult] = useState<PruneResult | null>(null);\n const [showConfirm, setShowConfirm] = useState(false);\n\n const handlePrune = () => {\n setResult(null);\n prune.mutate(\n {\n expire: fields.expire,\n jobs: fields.pruneJobs,\n engineStreams: fields.engineStreams,\n engineStreamsExpire: fields.engineStreamsExpire,\n workerStreams: fields.workerStreams,\n workerStreamsExpire: fields.workerStreamsExpire,\n attributes: fields.stripAttributes,\n pruneTransient: fields.pruneTransient,\n },\n {\n onSuccess: (data) => {\n setResult(data);\n setShowConfirm(false);\n },\n },\n );\n };\n\n return (\n <div className=\"space-y-8\">\n <PruneFieldsEditor fields={fields} onChange={setFields} />\n\n {/* Action bar */}\n <div className=\"flex items-center justify-between pt-2 border-t border-surface-border\">\n <p className=\"text-[10px] text-text-tertiary\">\n {!hasSelection(fields)\n ? 'Select at least one operation to enable pruning.'\n : 'This action permanently deletes data and cannot be undone.'}\n </p>\n <button\n onClick={() => setShowConfirm(true)}\n disabled={!hasSelection(fields) || prune.isPending}\n className=\"bg-status-error text-white px-4 py-1.5 rounded-md text-xs hover:opacity-90 transition-opacity disabled:opacity-40 shrink-0\"\n >\n {prune.isPending ? 'Pruning...' : 'Prune Now'}\n </button>\n </div>\n\n {/* Results */}\n {result && (\n <div className=\"bg-surface-sunken rounded-md px-4 py-3\">\n <p className=\"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-2\">\n Results\n </p>\n <div className=\"flex flex-wrap gap-6\">\n {result.jobs != null && result.jobs > 0 && <ResultCard label=\"Jobs deleted\" value={result.jobs} />}\n {result.engineStreams != null && result.engineStreams > 0 && <ResultCard label=\"Engine streams\" value={result.engineStreams} />}\n {result.workerStreams != null && result.workerStreams > 0 && <ResultCard label=\"Worker streams\" value={result.workerStreams} />}\n {result.streams != null && result.engineStreams == null && result.streams > 0 && <ResultCard label=\"Streams\" value={result.streams} />}\n {result.attributes != null && result.attributes > 0 && <ResultCard label=\"Artifacts stripped\" value={result.attributes} />}\n {result.transient != null && result.transient > 0 && <ResultCard label=\"Transient deleted\" value={result.transient} />}\n {result.marked != null && result.marked > 0 && <ResultCard label=\"Marked pruned\" value={result.marked} />}\n {Object.values(result).every((v) => !v || v === 0) && (\n <p className=\"text-xs text-text-tertiary\">Nothing to prune within the selected retention windows.</p>\n )}\n </div>\n </div>\n )}\n\n {prune.error && (\n <p className=\"text-xs text-status-error\">{(prune.error as Error).message}</p>\n )}\n\n {/* Confirm modal */}\n <Modal open={showConfirm} onClose={() => setShowConfirm(false)} title=\"Confirm Prune\">\n <div className=\"space-y-4\">\n <p className=\"text-sm text-text-secondary\">\n This will permanently delete data. This action cannot be undone.\n </p>\n <ul className=\"text-xs text-text-secondary space-y-1 list-disc list-inside\">\n {fields.pruneJobs && <li>Delete jobs older than {fields.expire}</li>}\n {fields.engineStreams && <li>Delete engine streams older than {fields.engineStreamsExpire}</li>}\n {fields.workerStreams && <li>Delete worker streams older than {fields.workerStreamsExpire}</li>}\n {fields.stripAttributes && <li>Strip execution artifacts from completed jobs</li>}\n {fields.pruneTransient && <li>Delete transient (entity-less) jobs</li>}\n </ul>\n <div className=\"flex justify-end gap-3 pt-2\">\n <button onClick={() => setShowConfirm(false)} className=\"btn-secondary text-xs\">Cancel</button>\n <button\n onClick={handlePrune}\n className=\"bg-status-error text-white px-3 py-1.5 rounded-md text-xs hover:opacity-90 transition-opacity\"\n disabled={prune.isPending}\n >\n {prune.isPending ? 'Pruning...' : 'Confirm Prune'}\n </button>\n </div>\n </div>\n </Modal>\n </div>\n );\n}\n","import { useState, useEffect, useCallback } from 'react';\nimport { Info } from 'lucide-react';\nimport {\n useMaintenanceConfig,\n useUpdateMaintenanceConfig,\n type MaintenanceConfig,\n} from '../../../api/maintenance';\nimport { CRON_PRESETS } from '../../../lib/constants';\nimport { PruneFieldsEditor, DEFAULT_PRUNE_FIELDS, type PruneFields } from './controls';\n\n// ── Helpers ─────────────────────────────────────────────────────────────────\n\n/** Convert a MaintenanceConfig (rules array) into PruneFields for the editor. */\nfunction configToFields(config: MaintenanceConfig | undefined): PruneFields {\n if (!config?.rules?.length) return DEFAULT_PRUNE_FIELDS;\n const r = config.rules;\n const streamDelete = r.find((x) => x.target === 'streams' && x.action === 'delete');\n const jobDeleteTransient = r.find((x) => x.target === 'jobs' && x.action === 'delete' && x.hasEntity === false);\n const jobPrune = r.find((x) => x.target === 'jobs' && x.action === 'prune' && x.hasEntity === true);\n const jobDeletePruned = r.find((x) => x.target === 'jobs' && x.action === 'delete' && x.pruned === true);\n return {\n pruneJobs: !!jobDeletePruned,\n expire: jobDeletePruned?.olderThan ?? '180 days',\n engineStreams: !!streamDelete,\n engineStreamsExpire: streamDelete?.olderThan ?? '1 day',\n workerStreams: !!streamDelete,\n workerStreamsExpire: streamDelete?.olderThan ?? '90 days',\n stripAttributes: !!jobPrune,\n pruneTransient: !!jobDeleteTransient,\n };\n}\n\n/** Convert PruneFields back to a MaintenanceConfig rules array. */\nfunction fieldsToRules(f: PruneFields): MaintenanceConfig['rules'] {\n const rules: MaintenanceConfig['rules'] = [];\n if (f.engineStreams) {\n rules.push({ target: 'streams', action: 'delete', olderThan: f.engineStreamsExpire });\n }\n if (f.workerStreams && f.workerStreamsExpire !== f.engineStreamsExpire) {\n rules.push({ target: 'streams', action: 'delete', olderThan: f.workerStreamsExpire });\n }\n if (f.pruneTransient) {\n rules.push({ target: 'jobs', action: 'delete', olderThan: f.expire, hasEntity: false });\n }\n if (f.stripAttributes) {\n rules.push({ target: 'jobs', action: 'prune', olderThan: f.expire, hasEntity: true });\n }\n if (f.pruneJobs) {\n rules.push({ target: 'jobs', action: 'delete', olderThan: f.expire, pruned: true });\n }\n return rules;\n}\n\nfunction describeCron(expr: string): string {\n return CRON_PRESETS.find((p) => p.value === expr)?.label ?? '';\n}\n\n// ── Main ────────────────────────────────────────────────────────────────────\n\nexport function ScheduleSection() {\n const { data, isLoading } = useMaintenanceConfig();\n const updateConfig = useUpdateMaintenanceConfig();\n\n const [schedule, setSchedule] = useState('');\n const [fields, setFields] = useState<PruneFields>(DEFAULT_PRUNE_FIELDS);\n const [savedSnapshot, setSavedSnapshot] = useState('');\n\n // Sync from server config when loaded\n const syncFromServer = useCallback(() => {\n if (!data?.config) return;\n setSchedule(data.config.schedule);\n setFields(configToFields(data.config));\n setSavedSnapshot(JSON.stringify({ schedule: data.config.schedule, fields: configToFields(data.config) }));\n }, [data]);\n\n useEffect(() => { syncFromServer(); }, [syncFromServer]);\n\n const currentSnapshot = JSON.stringify({ schedule, fields });\n const isDirty = savedSnapshot !== '' && currentSnapshot !== savedSnapshot;\n const active = data?.active ?? false;\n\n const handleSave = () => {\n const rules = fieldsToRules(fields);\n updateConfig.mutate(\n { schedule, rules },\n {\n onSuccess: () => {\n setSavedSnapshot(JSON.stringify({ schedule, fields }));\n },\n },\n );\n };\n\n const handleRevert = () => {\n syncFromServer();\n };\n\n if (isLoading) {\n return <div className=\"animate-pulse h-40 bg-surface-sunken rounded\" />;\n }\n\n return (\n <div className=\"space-y-8\">\n {/* Cron schedule + status */}\n <div className=\"grid grid-cols-1 lg:grid-cols-[1fr_auto] gap-10\">\n <div>\n <p className=\"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-4\">\n Schedule\n </p>\n <div className=\"flex items-end gap-4\">\n <div>\n <label className=\"block text-[10px] text-text-tertiary mb-1\">Cron Expression</label>\n <input\n type=\"text\"\n value={schedule}\n onChange={(e) => setSchedule(e.target.value)}\n placeholder=\"0 2 * * *\"\n className=\"input text-xs font-mono w-48\"\n />\n </div>\n <div>\n <div className=\"flex items-center gap-1.5 h-8\">\n <span className={`w-1.5 h-1.5 rounded-full dot-ring ${active ? 'bg-status-success' : 'bg-text-tertiary'}`} />\n <span className={`text-xs ${active ? 'text-status-success' : 'text-text-tertiary'}`}>\n {active ? 'Active' : 'Inactive'}\n </span>\n </div>\n </div>\n {describeCron(schedule) && (\n <p className=\"text-xs text-text-tertiary h-8 flex items-center\">{describeCron(schedule)}</p>\n )}\n </div>\n\n {/* Preset pills */}\n <div className=\"flex flex-wrap gap-1.5 mt-3\">\n {CRON_PRESETS.map((preset) => (\n <button\n key={preset.value}\n type=\"button\"\n onClick={() => setSchedule(preset.value)}\n className={`px-2.5 py-1 text-[10px] rounded-full transition-colors ${\n schedule === preset.value\n ? 'bg-accent/10 text-accent font-medium'\n : 'bg-surface-sunken text-text-tertiary hover:text-text-secondary'\n }`}\n >\n {preset.label}\n </button>\n ))}\n </div>\n </div>\n\n <div className=\"lg:w-72\">\n <p className=\"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-4\">\n How It Works\n </p>\n <div className=\"flex items-start gap-2 px-3 py-2 rounded bg-surface-sunken\">\n <Info className=\"w-3.5 h-3.5 text-text-tertiary shrink-0 mt-0.5\" />\n <p className=\"text-[10px] text-text-tertiary leading-relaxed\">\n Rules execute sequentially on each cron cycle. Engine streams can be pruned aggressively\n since they only contain internal routing data. Worker streams should be retained longer\n to preserve execution playback and input enrichment.\n </p>\n </div>\n </div>\n </div>\n\n {/* Same prune fields as Prune Now */}\n <PruneFieldsEditor fields={fields} onChange={setFields} />\n\n {/* Action bar */}\n <div className=\"flex items-center justify-between pt-2 border-t border-surface-border\">\n <div className=\"flex items-center gap-3\">\n {isDirty && (\n <button\n onClick={handleRevert}\n className=\"text-[10px] text-text-tertiary hover:text-text-primary transition-colors\"\n >\n Revert changes\n </button>\n )}\n {updateConfig.error && (\n <p className=\"text-xs text-status-error\">{(updateConfig.error as Error).message}</p>\n )}\n </div>\n <button\n onClick={handleSave}\n disabled={!isDirty || !schedule.trim() || updateConfig.isPending}\n className=\"btn-primary text-xs disabled:opacity-40 shrink-0\"\n >\n {updateConfig.isPending ? 'Saving...' : 'Save Schedule'}\n </button>\n </div>\n </div>\n );\n}\n","import { useState } from 'react';\nimport { Trash2, Clock, Info } from 'lucide-react';\nimport { PageHeader } from '../../../components/common/layout/PageHeader';\nimport { PruneSection } from './PruneSection';\nimport { ScheduleSection } from './ScheduleSection';\n\ntype Mode = 'prune' | 'schedule';\n\nfunction ModeToggle({ mode, onChange }: { mode: Mode; onChange: (m: Mode) => void }) {\n const btn = (m: Mode, icon: React.ReactNode, label: string) => (\n <button\n onClick={() => onChange(m)}\n className={`flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md transition-colors ${\n mode === m\n ? 'bg-accent/10 text-accent font-medium'\n : 'text-text-tertiary hover:text-text-secondary hover:bg-surface-hover'\n }`}\n >\n {icon}\n {label}\n </button>\n );\n\n return (\n <div className=\"flex gap-1 p-0.5 bg-surface-sunken rounded-lg w-fit\">\n {btn('prune', <Trash2 className=\"w-3.5 h-3.5\" />, 'Prune Now')}\n {btn('schedule', <Clock className=\"w-3.5 h-3.5\" />, 'Schedule')}\n </div>\n );\n}\n\nexport function MaintenancePage() {\n const [mode, setMode] = useState<Mode>('schedule');\n\n return (\n <div>\n <PageHeader\n title=\"DB Maintenance\"\n docsHash=\"#docs:dashboard.md:db-maintenance\"\n actions={<ModeToggle mode={mode} onChange={setMode} />}\n />\n\n <div className=\"flex items-start gap-2 px-4 py-3 mb-8 rounded-md bg-accent/5 border border-accent/10\">\n <Info className=\"w-4 h-4 text-accent shrink-0 mt-0.5\" />\n <p className=\"text-xs text-text-secondary leading-relaxed\">\n Workflow data grows as jobs complete. Operations are ordered safest-first: stream messages are\n always safe to prune, workflow reduction preserves results, and deletion is permanent.\n </p>\n </div>\n\n {mode === 'prune' ? <PruneSection /> : <ScheduleSection />}\n </div>\n );\n}\n"],"names":["useMaintenanceConfig","useQuery","apiFetch","useUpdateMaintenanceConfig","queryClient","useQueryClient","useMutation","config","usePrune","options","RetentionRow","checked","onToggle","label","hint","safety","value","onChange","SafetyIcon","ShieldCheck","ShieldAlert","ShieldOff","safetyColor","safetyLabel","jsxs","jsx","e","RETENTION_PERIOD_OPTIONS","opt","CleanupCallout","Info","DEFAULT_PRUNE_FIELDS","hasSelection","f","PruneFieldsEditor","fields","set","key","v","ResultCard","PruneSection","prune","setFields","useState","result","setResult","showConfirm","setShowConfirm","handlePrune","data","Modal","configToFields","_a","streamDelete","x","jobDeleteTransient","jobPrune","jobDeletePruned","fieldsToRules","rules","describeCron","expr","CRON_PRESETS","p","ScheduleSection","isLoading","updateConfig","schedule","setSchedule","savedSnapshot","setSavedSnapshot","syncFromServer","useCallback","useEffect","currentSnapshot","isDirty","active","handleSave","handleRevert","preset","ModeToggle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spMAl.js";import{D as g}from"./DataTable-ZWgVQg7F.js";import{F as y,b as j}from"./FilterBar-B4Mk2PvT.js";import{R as q,a as u}from"./RowActions-BA9L9djf.js";import{u as C}from"./useFilterParams-x-Dg0Vgz.js";import{P as R}from"./PageHeader-DJo7yMUR.js";import{T as b}from"./TaskQueuePill-D6omQJNY.js";import{W as _}from"./WorkflowPill-BtNBSplz.js";import{ad as v,ai as N,l as I}from"./vendor-icons-DOIDKgo6.js";import{c as P}from"./vendor-react-CXumBFUA.js";import"./index-DwWP-Z_c.js";import"./EmptyState-BcsfPq9T.js";function H(){const r=P(),{data:c,isLoading:m}=h(),{filters:s,setFilter:i}=C({filters:{search:"",queue:""}}),[a,p]=n.useState(s.search);n.useEffect(()=>{if(a===s.search)return;const e=setTimeout(()=>i("search",a),300);return()=>clearTimeout(e)},[a,i,s.search]);const o=c??[],d=n.useMemo(()=>[...new Set(o.map(e=>e.task_queue).filter(Boolean))].sort(),[o]),f=n.useMemo(()=>{let e=o;if(s.search){const l=s.search.toLowerCase();e=e.filter(w=>w.name.toLowerCase().includes(l))}return s.queue&&(e=e.filter(l=>l.task_queue===s.queue)),e},[o,s]),k=[{key:"name",label:"Workflow",render:e=>t.jsx(_,{type:e.name})},{key:"task_queue",label:"Queue",render:e=>t.jsx(b,{queue:e.task_queue}),className:"whitespace-nowrap"},{key:"registered",label:"Status",render:e=>e.registered?t.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium bg-accent/10 text-accent",children:[t.jsx(v,{className:"w-3 h-3"}),"Certified"]}):t.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium bg-surface-sunken text-text-tertiary",children:"Durable"}),className:"whitespace-nowrap"},{key:"actions",label:"",render:e=>t.jsx(q,{children:e.registered?t.jsx(u,{icon:N,title:"View config",onClick:()=>r(`/workflows/registry/${encodeURIComponent(e.name)}`)}):t.jsx(u,{icon:I,title:"Register workflow",onClick:()=>r(`/workflows/registry/new?workflow_type=${encodeURIComponent(e.name)}&task_queue=${encodeURIComponent(e.task_queue)}`)})}),className:"w-16 text-right"}],x=e=>{e.registered?r(`/workflows/registry/${encodeURIComponent(e.name)}`):r(`/workflows/registry/new?workflow_type=${encodeURIComponent(e.name)}&task_queue=${encodeURIComponent(e.task_queue)}`)};return t.jsxs("div",{children:[t.jsx(R,{title:"Workers",docsHash:"#docs:dashboard.md:task-queues"}),t.jsxs(y,{children:[t.jsx("input",{type:"text",placeholder:"Search workers...",value:a,onChange:e=>p(e.target.value),className:"input text-[11px] py-1 px-2 w-56"}),t.jsx(j,{label:"Queue",value:s.queue,onChange:e=>i("queue",e),options:d.map(e=>({value:e,label:e}))})]}),t.jsx(g,{columns:k,data:f,keyFn:e=>e.name,onRowClick:x,isLoading:m,emptyMessage:"No active workers"})]})}export{H as WorkersPage};
2
- //# sourceMappingURL=index-kKufOPLo.js.map
1
+ import{a as n,j as t}from"./vendor-query-B2UbickB.js";import{g as h}from"./workflows-qIbkeQ_5.js";import{D as g}from"./DataTable-ZWgVQg7F.js";import{F as y,b as j}from"./FilterBar-B4Mk2PvT.js";import{R as q,a as u}from"./RowActions-BA9L9djf.js";import{u as C}from"./useFilterParams-x-Dg0Vgz.js";import{P as R}from"./PageHeader-DJo7yMUR.js";import{T as b}from"./TaskQueuePill-D6omQJNY.js";import{W as _}from"./WorkflowPill-BtNBSplz.js";import{ad as v,ai as N,l as I}from"./vendor-icons-DOIDKgo6.js";import{c as P}from"./vendor-react-CXumBFUA.js";import"./index-B_aFcGv9.js";import"./EmptyState-BcsfPq9T.js";function H(){const r=P(),{data:c,isLoading:m}=h(),{filters:s,setFilter:i}=C({filters:{search:"",queue:""}}),[a,p]=n.useState(s.search);n.useEffect(()=>{if(a===s.search)return;const e=setTimeout(()=>i("search",a),300);return()=>clearTimeout(e)},[a,i,s.search]);const o=c??[],d=n.useMemo(()=>[...new Set(o.map(e=>e.task_queue).filter(Boolean))].sort(),[o]),f=n.useMemo(()=>{let e=o;if(s.search){const l=s.search.toLowerCase();e=e.filter(w=>w.name.toLowerCase().includes(l))}return s.queue&&(e=e.filter(l=>l.task_queue===s.queue)),e},[o,s]),k=[{key:"name",label:"Workflow",render:e=>t.jsx(_,{type:e.name})},{key:"task_queue",label:"Queue",render:e=>t.jsx(b,{queue:e.task_queue}),className:"whitespace-nowrap"},{key:"registered",label:"Status",render:e=>e.registered?t.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium bg-accent/10 text-accent",children:[t.jsx(v,{className:"w-3 h-3"}),"Certified"]}):t.jsx("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium bg-surface-sunken text-text-tertiary",children:"Durable"}),className:"whitespace-nowrap"},{key:"actions",label:"",render:e=>t.jsx(q,{children:e.registered?t.jsx(u,{icon:N,title:"View config",onClick:()=>r(`/workflows/registry/${encodeURIComponent(e.name)}`)}):t.jsx(u,{icon:I,title:"Register workflow",onClick:()=>r(`/workflows/registry/new?workflow_type=${encodeURIComponent(e.name)}&task_queue=${encodeURIComponent(e.task_queue)}`)})}),className:"w-16 text-right"}],x=e=>{e.registered?r(`/workflows/registry/${encodeURIComponent(e.name)}`):r(`/workflows/registry/new?workflow_type=${encodeURIComponent(e.name)}&task_queue=${encodeURIComponent(e.task_queue)}`)};return t.jsxs("div",{children:[t.jsx(R,{title:"Workers",docsHash:"#docs:dashboard.md:task-queues"}),t.jsxs(y,{children:[t.jsx("input",{type:"text",placeholder:"Search workers...",value:a,onChange:e=>p(e.target.value),className:"input text-[11px] py-1 px-2 w-56"}),t.jsx(j,{label:"Queue",value:s.queue,onChange:e=>i("queue",e),options:d.map(e=>({value:e,label:e}))})]}),t.jsx(g,{columns:k,data:f,keyFn:e=>e.name,onRowClick:x,isLoading:m,emptyMessage:"No active workers"})]})}export{H as WorkersPage};
2
+ //# sourceMappingURL=index-Gt2Rebs9.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-kKufOPLo.js","sources":["../../src/pages/workflows/workers/WorkersPage.tsx"],"sourcesContent":["import { useState, useEffect, useMemo } from 'react';\nimport { useNavigate } from 'react-router-dom';\nimport { Plus, Eye, ShieldCheck } from 'lucide-react';\nimport { useActiveWorkers } from '../../../api/workflows';\nimport { DataTable, type Column } from '../../../components/common/data/DataTable';\nimport { FilterBar, FilterSelect } from '../../../components/common/data/FilterBar';\nimport { RowAction, RowActionGroup } from '../../../components/common/layout/RowActions';\nimport { useFilterParams } from '../../../hooks/useFilterParams';\nimport type { ActiveWorker } from '../../../api/types';\nimport { PageHeader } from '../../../components/common/layout/PageHeader';\nimport { TaskQueuePill } from '../../../components/common/display/TaskQueuePill';\nimport { WorkflowPill } from '../../../components/common/display/WorkflowPill';\n\n// ── Page ──────────────────────────────────────────────────────────────────────\n\nexport function WorkersPage() {\n const navigate = useNavigate();\n const { data, isLoading } = useActiveWorkers();\n const { filters, setFilter } = useFilterParams({\n filters: { search: '', queue: '' },\n });\n\n const [searchInput, setSearchInput] = useState(filters.search);\n\n useEffect(() => {\n if (searchInput === filters.search) return;\n const timer = setTimeout(() => setFilter('search', searchInput), 300);\n return () => clearTimeout(timer);\n }, [searchInput, setFilter, filters.search]);\n\n const allWorkers = data ?? [];\n\n const queues = useMemo(\n () => [...new Set(allWorkers.map((w) => w.task_queue).filter(Boolean))].sort(),\n [allWorkers],\n );\n\n const workers = useMemo(() => {\n let result = allWorkers;\n if (filters.search) {\n const q = filters.search.toLowerCase();\n result = result.filter((w) => w.name.toLowerCase().includes(q));\n }\n if (filters.queue) result = result.filter((w) => w.task_queue === filters.queue);\n return result;\n }, [allWorkers, filters]);\n\n const columns: Column<ActiveWorker>[] = [\n {\n key: 'name',\n label: 'Workflow',\n render: (row) => <WorkflowPill type={row.name} />,\n },\n {\n key: 'task_queue',\n label: 'Queue',\n render: (row) => <TaskQueuePill queue={row.task_queue} />,\n className: 'whitespace-nowrap',\n },\n {\n key: 'registered',\n label: 'Status',\n render: (row) => row.registered\n ? <span className=\"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium bg-accent/10 text-accent\"><ShieldCheck className=\"w-3 h-3\" />Certified</span>\n : <span className=\"inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium bg-surface-sunken text-text-tertiary\">Durable</span>,\n className: 'whitespace-nowrap',\n },\n {\n key: 'actions',\n label: '',\n render: (row) => (\n <RowActionGroup>\n {row.registered ? (\n <RowAction\n icon={Eye}\n title=\"View config\"\n onClick={() => navigate(`/workflows/registry/${encodeURIComponent(row.name)}`)}\n />\n ) : (\n <RowAction\n icon={Plus}\n title=\"Register workflow\"\n onClick={() => navigate(`/workflows/registry/new?workflow_type=${encodeURIComponent(row.name)}&task_queue=${encodeURIComponent(row.task_queue)}`)}\n />\n )}\n </RowActionGroup>\n ),\n className: 'w-16 text-right',\n },\n ];\n\n const handleRowClick = (row: ActiveWorker) => {\n if (row.registered) {\n navigate(`/workflows/registry/${encodeURIComponent(row.name)}`);\n } else {\n navigate(`/workflows/registry/new?workflow_type=${encodeURIComponent(row.name)}&task_queue=${encodeURIComponent(row.task_queue)}`);\n }\n };\n\n return (\n <div>\n <PageHeader title=\"Workers\" docsHash=\"#docs:dashboard.md:task-queues\" />\n\n <FilterBar>\n <input\n type=\"text\"\n placeholder=\"Search workers...\"\n value={searchInput}\n onChange={(e) => setSearchInput(e.target.value)}\n className=\"input text-[11px] py-1 px-2 w-56\"\n />\n <FilterSelect\n label=\"Queue\"\n value={filters.queue}\n onChange={(v) => setFilter('queue', v)}\n options={queues.map((q) => ({ value: q, label: q }))}\n />\n </FilterBar>\n\n <DataTable\n columns={columns}\n data={workers}\n keyFn={(row) => row.name}\n onRowClick={handleRowClick}\n isLoading={isLoading}\n emptyMessage=\"No active workers\"\n />\n </div>\n );\n}\n"],"names":["WorkersPage","navigate","useNavigate","data","isLoading","useActiveWorkers","filters","setFilter","useFilterParams","searchInput","setSearchInput","useState","useEffect","timer","allWorkers","queues","useMemo","w","workers","result","q","columns","row","WorkflowPill","TaskQueuePill","jsxs","jsx","ShieldCheck","RowActionGroup","RowAction","Eye","Plus","handleRowClick","PageHeader","FilterBar","FilterSelect","v","DataTable"],"mappings":"8lBAeO,SAASA,GAAc,CAC5B,MAAMC,EAAWC,EAAA,EACX,CAAE,KAAAC,EAAM,UAAAC,CAAA,EAAcC,EAAA,EACtB,CAAE,QAAAC,EAAS,UAAAC,CAAA,EAAcC,EAAgB,CAC7C,QAAS,CAAE,OAAQ,GAAI,MAAO,EAAA,CAAG,CAClC,EAEK,CAACC,EAAaC,CAAc,EAAIC,EAAAA,SAASL,EAAQ,MAAM,EAE7DM,EAAAA,UAAU,IAAM,CACd,GAAIH,IAAgBH,EAAQ,OAAQ,OACpC,MAAMO,EAAQ,WAAW,IAAMN,EAAU,SAAUE,CAAW,EAAG,GAAG,EACpE,MAAO,IAAM,aAAaI,CAAK,CACjC,EAAG,CAACJ,EAAaF,EAAWD,EAAQ,MAAM,CAAC,EAE3C,MAAMQ,EAAaX,GAAQ,CAAA,EAErBY,EAASC,EAAAA,QACb,IAAM,CAAC,GAAG,IAAI,IAAIF,EAAW,IAAKG,GAAMA,EAAE,UAAU,EAAE,OAAO,OAAO,CAAC,CAAC,EAAE,KAAA,EACxE,CAACH,CAAU,CAAA,EAGPI,EAAUF,EAAAA,QAAQ,IAAM,CAC5B,IAAIG,EAASL,EACb,GAAIR,EAAQ,OAAQ,CAClB,MAAMc,EAAId,EAAQ,OAAO,YAAA,EACzBa,EAASA,EAAO,OAAQ,GAAM,EAAE,KAAK,YAAA,EAAc,SAASC,CAAC,CAAC,CAChE,CACA,OAAId,EAAQ,QAAOa,EAASA,EAAO,OAAQF,GAAMA,EAAE,aAAeX,EAAQ,KAAK,GACxEa,CACT,EAAG,CAACL,EAAYR,CAAO,CAAC,EAElBe,EAAkC,CACtC,CACE,IAAK,OACL,MAAO,WACP,OAASC,SAASC,EAAA,CAAa,KAAMD,EAAI,IAAA,CAAM,CAAA,EAEjD,CACE,IAAK,aACL,MAAO,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6B,CAAC,EACrC,QAASrB,EAAO,IAAKK,IAAO,CAAE,MAAOA,EAAG,MAAOA,GAAI,CAAA,CAAA,CACrD,EACF,EAEAM,EAAAA,IAACW,EAAA,CACC,QAAAhB,EACA,KAAMH,EACN,MAAQI,GAAQA,EAAI,KACpB,WAAYU,EACZ,UAAA5B,EACA,aAAa,mBAAA,CAAA,CACf,EACF,CAEJ"}
1
+ {"version":3,"file":"index-Gt2Rebs9.js","sources":["../../src/pages/workflows/workers/WorkersPage.tsx"],"sourcesContent":["import { useState, useEffect, useMemo } from 'react';\nimport { useNavigate } from 'react-router-dom';\nimport { Plus, Eye, ShieldCheck } from 'lucide-react';\nimport { useActiveWorkers } from '../../../api/workflows';\nimport { DataTable, type Column } from '../../../components/common/data/DataTable';\nimport { FilterBar, FilterSelect } from '../../../components/common/data/FilterBar';\nimport { RowAction, RowActionGroup } from '../../../components/common/layout/RowActions';\nimport { useFilterParams } from '../../../hooks/useFilterParams';\nimport type { ActiveWorker } from '../../../api/types';\nimport { PageHeader } from '../../../components/common/layout/PageHeader';\nimport { TaskQueuePill } from '../../../components/common/display/TaskQueuePill';\nimport { WorkflowPill } from '../../../components/common/display/WorkflowPill';\n\n// ── Page ──────────────────────────────────────────────────────────────────────\n\nexport function WorkersPage() {\n const navigate = useNavigate();\n const { data, isLoading } = useActiveWorkers();\n const { filters, setFilter } = useFilterParams({\n filters: { search: '', queue: '' },\n });\n\n const [searchInput, setSearchInput] = useState(filters.search);\n\n useEffect(() => {\n if (searchInput === filters.search) return;\n const timer = setTimeout(() => setFilter('search', searchInput), 300);\n return () => clearTimeout(timer);\n }, [searchInput, setFilter, filters.search]);\n\n const allWorkers = data ?? [];\n\n const queues = useMemo(\n () => [...new Set(allWorkers.map((w) => w.task_queue).filter(Boolean))].sort(),\n [allWorkers],\n );\n\n const workers = useMemo(() => {\n let result = allWorkers;\n if (filters.search) {\n const q = filters.search.toLowerCase();\n result = result.filter((w) => w.name.toLowerCase().includes(q));\n }\n if (filters.queue) result = result.filter((w) => w.task_queue === filters.queue);\n return result;\n }, [allWorkers, filters]);\n\n const columns: Column<ActiveWorker>[] = [\n {\n key: 'name',\n label: 'Workflow',\n render: (row) => <WorkflowPill type={row.name} />,\n },\n {\n key: 'task_queue',\n label: 'Queue',\n render: (row) => <TaskQueuePill queue={row.task_queue} />,\n className: 'whitespace-nowrap',\n },\n {\n key: 'registered',\n label: 'Status',\n render: (row) => row.registered\n ? <span className=\"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] font-medium bg-accent/10 text-accent\"><ShieldCheck className=\"w-3 h-3\" />Certified</span>\n : <span className=\"inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium bg-surface-sunken text-text-tertiary\">Durable</span>,\n className: 'whitespace-nowrap',\n },\n {\n key: 'actions',\n label: '',\n render: (row) => (\n <RowActionGroup>\n {row.registered ? (\n <RowAction\n icon={Eye}\n title=\"View config\"\n onClick={() => navigate(`/workflows/registry/${encodeURIComponent(row.name)}`)}\n />\n ) : (\n <RowAction\n icon={Plus}\n title=\"Register workflow\"\n onClick={() => navigate(`/workflows/registry/new?workflow_type=${encodeURIComponent(row.name)}&task_queue=${encodeURIComponent(row.task_queue)}`)}\n />\n )}\n </RowActionGroup>\n ),\n className: 'w-16 text-right',\n },\n ];\n\n const handleRowClick = (row: ActiveWorker) => {\n if (row.registered) {\n navigate(`/workflows/registry/${encodeURIComponent(row.name)}`);\n } else {\n navigate(`/workflows/registry/new?workflow_type=${encodeURIComponent(row.name)}&task_queue=${encodeURIComponent(row.task_queue)}`);\n }\n };\n\n return (\n <div>\n <PageHeader title=\"Workers\" docsHash=\"#docs:dashboard.md:task-queues\" />\n\n <FilterBar>\n <input\n type=\"text\"\n placeholder=\"Search workers...\"\n value={searchInput}\n onChange={(e) => setSearchInput(e.target.value)}\n className=\"input text-[11px] py-1 px-2 w-56\"\n />\n <FilterSelect\n label=\"Queue\"\n value={filters.queue}\n onChange={(v) => setFilter('queue', v)}\n options={queues.map((q) => ({ value: q, label: q }))}\n />\n </FilterBar>\n\n <DataTable\n columns={columns}\n data={workers}\n keyFn={(row) => row.name}\n onRowClick={handleRowClick}\n isLoading={isLoading}\n emptyMessage=\"No active workers\"\n />\n </div>\n );\n}\n"],"names":["WorkersPage","navigate","useNavigate","data","isLoading","useActiveWorkers","filters","setFilter","useFilterParams","searchInput","setSearchInput","useState","useEffect","timer","allWorkers","queues","useMemo","w","workers","result","q","columns","row","WorkflowPill","TaskQueuePill","jsxs","jsx","ShieldCheck","RowActionGroup","RowAction","Eye","Plus","handleRowClick","PageHeader","FilterBar","FilterSelect","v","DataTable"],"mappings":"8lBAeO,SAASA,GAAc,CAC5B,MAAMC,EAAWC,EAAA,EACX,CAAE,KAAAC,EAAM,UAAAC,CAAA,EAAcC,EAAA,EACtB,CAAE,QAAAC,EAAS,UAAAC,CAAA,EAAcC,EAAgB,CAC7C,QAAS,CAAE,OAAQ,GAAI,MAAO,EAAA,CAAG,CAClC,EAEK,CAACC,EAAaC,CAAc,EAAIC,EAAAA,SAASL,EAAQ,MAAM,EAE7DM,EAAAA,UAAU,IAAM,CACd,GAAIH,IAAgBH,EAAQ,OAAQ,OACpC,MAAMO,EAAQ,WAAW,IAAMN,EAAU,SAAUE,CAAW,EAAG,GAAG,EACpE,MAAO,IAAM,aAAaI,CAAK,CACjC,EAAG,CAACJ,EAAaF,EAAWD,EAAQ,MAAM,CAAC,EAE3C,MAAMQ,EAAaX,GAAQ,CAAA,EAErBY,EAASC,EAAAA,QACb,IAAM,CAAC,GAAG,IAAI,IAAIF,EAAW,IAAKG,GAAMA,EAAE,UAAU,EAAE,OAAO,OAAO,CAAC,CAAC,EAAE,KAAA,EACxE,CAACH,CAAU,CAAA,EAGPI,EAAUF,EAAAA,QAAQ,IAAM,CAC5B,IAAIG,EAASL,EACb,GAAIR,EAAQ,OAAQ,CAClB,MAAMc,EAAId,EAAQ,OAAO,YAAA,EACzBa,EAASA,EAAO,OAAQ,GAAM,EAAE,KAAK,YAAA,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A,CAAW,MAAM,UAAU,SAAS,iCAAiC,SAErEC,EAAA,CACC,SAAA,CAAAR,EAAAA,IAAC,QAAA,CACC,KAAK,OACL,YAAY,oBACZ,MAAOjB,EACP,SAAW,GAAMC,EAAe,EAAE,OAAO,KAAK,EAC9C,UAAU,kCAAA,CAAA,EAEZgB,EAAAA,IAACS,EAAA,CACC,MAAM,QACN,MAAO7B,EAAQ,MACf,SAAW8B,GAAM7B,EAAU,QAAS6B,CAAC,EACrC,QAASrB,EAAO,IAAKK,IAAO,CAAE,MAAOA,EAAG,MAAOA,GAAI,CAAA,CAAA,CACrD,EACF,EAEAM,EAAAA,IAACW,EAAA,CACC,QAAAhB,EACA,KAAMH,EACN,MAAQI,GAAQA,EAAI,KACpB,WAAYU,EACZ,UAAA5B,EACA,aAAa,mBAAA,CAAA,CACf,EACF,CAEJ"}
@@ -0,0 +1,6 @@
1
+ import{a as h,j as e,b as lt}from"./vendor-query-B2UbickB.js";import{z as pe,v as ye,b as V,C as ot,J as ae,M as Se,j as ct,A as dt,g as xt,h as ut,B as mt,E as pt,u as ht}from"./index-B_aFcGv9.js";import{u as ft}from"./useCollapsedSections-BU5HULGs.js";import{u as gt,C as jt,a as bt}from"./CustomDurationPicker-CGiwKSVJ.js";import{a as yt}from"./roles-LZf98ePg.js";import{P as vt}from"./PageHeader-DJo7yMUR.js";import{a as Ve,C as je,i as wt}from"./escalation-CH_XK2XM.js";import{L as Nt}from"./ListToolbar-Ok2O0wmC.js";import{u as kt}from"./workflows-qIbkeQ_5.js";import{g as _t}from"./useEventHooks-82IiMmOc.js";import{U as be}from"./UserName-CifbOahk.js";import{S as Me}from"./StatusBadge-DZ9137bI.js";import{R as Ie}from"./RolePill-DHWixsQR.js";import{C as M}from"./CopyableId-blg-gZvT.js";import{U as Ae,a9 as Ct,a7 as Tt,aa as We}from"./vendor-icons-DOIDKgo6.js";import{C as le}from"./CollapsibleSection-lo8Qx4zb.js";import{L as Be,e as Et,c as Rt}from"./vendor-react-CXumBFUA.js";import"./Modal-CSrxpXeM.js";import"./constants-BHkpVaqx.js";import"./users-DHx2ium7.js";const Pe="lt_view_mode";function $t(t){const[a,r]=h.useState(()=>{try{const s=localStorage.getItem(Pe);if(s!==null)return s==="dev"}catch{}return t}),n=h.useCallback(()=>{r(s=>{const l=!s;try{localStorage.setItem(Pe,l?"dev":"user")}catch{}return l})},[]);return{isDevMode:a,toggleMode:n}}const he=4;function Oe({pct:t,place:a,label:r,title:n,emphasis:s}){const l=e.jsx("span",{className:"w-px h-1.5 bg-surface-border","aria-hidden":!0}),c=e.jsx("span",{className:`whitespace-nowrap leading-none ${s?"text-text-secondary":"text-text-tertiary"}`,children:r});return e.jsx("div",{title:n,className:`absolute ${a==="above"?"bottom-0":"top-0"} flex flex-col items-center gap-0.5 -translate-x-1/2 cursor-help`,style:{left:`${t}%`},children:a==="above"?e.jsxs(e.Fragment,{children:[c,l]}):e.jsxs(e.Fragment,{children:[l,c]})})}function St({esc:t,className:a=""}){const r=new Date(t.created_at).getTime(),n=t.claimed_at?new Date(t.claimed_at).getTime():null,s=t.status==="resolved",l=t.status==="cancelled",c=s||l,x=Ve(t),i=!!n&&(x||c),o=s&&t.resolved_at?new Date(t.resolved_at).getTime():l?new Date(t.updated_at).getTime():Date.now(),d=Math.max(o-r,1),p=i&&n?Math.max(n-r,0):d,j=i&&n?Math.max(o-n,0):0,g=Math.min(100,Math.max(0,p/d*100)),u=i?Math.max(0,100-g):0,f=s?"bg-status-success":l?"bg-status-error":"bg-status-active",m=s?"Worked":l?"Open before cancel":"In progress",y=pe(p),b=pe(d),$=s?`Resolved in ${b} total`:l?`Cancelled after ${b}`:`Open ${b} so far (current age)`,C=`Lifecycle: amber = time spent waiting to be claimed, the colored end = ${m.toLowerCase()} after the claim. Top label is time-to-claim, bottom is total time.`;return e.jsxs("div",{className:a,title:C,children:[e.jsx("div",{className:"relative h-3.5 text-[9px] font-mono",children:i&&e.jsx(Oe,{pct:g,place:"above",label:y,title:`Time to claim: ${y} (created → claimed)`})}),e.jsxs("div",{className:"flex w-full rounded-full overflow-hidden bg-surface-sunken cursor-help",style:{height:he},title:C,children:[e.jsx("div",{style:{width:`${g}%`,minWidth:he},className:"bg-status-pending",title:`Waiting ${y} — created → claimed`}),i&&e.jsx("div",{style:{width:`${u}%`,minWidth:he},className:f,title:`${m} ${pe(j)} — claimed → ${s?"resolved":l?"cancelled":"now"}`})]}),e.jsx("div",{className:"relative h-3.5 text-[9px] font-mono",children:e.jsx(Oe,{pct:100,place:"below",emphasis:!0,label:b,title:$})})]})}const Mt=new Set(["__proto__","constructor","prototype"]);function ze(t){const a=[];for(const r of t.split(".")){const n=r.match(/^([^[\]]*)((?:\[\d+\])*)$/);if(!n)throw new Error(`invalid x-lt-bind path segment: "${r}"`);const[,s,l]=n;if(s){if(Mt.has(s))throw new Error(`x-lt-bind path may not target "${s}"`);a.push({key:s})}for(const c of l.match(/\d+/g)??[])a.push({index:Number(c)})}if(a.length===0)throw new Error(`empty x-lt-bind path: "${t}"`);return a}function It(t,a,r){const n=ze(a);let s=t;for(let c=0;c<n.length-1;c++){const x=n[c],i=n[c+1],o="key"in x?x.key:x.index,d="index"in i;(s[o]==null||typeof s[o]!="object")&&(s[o]=d?[]:{}),s=s[o]}const l=n[n.length-1];s["key"in l?l.key:l.index]=r}function At(t,a){let r=t;for(const n of ze(a)){if(r==null||typeof r!="object")return;r=r["key"in n?n.key:n.index]}return r}function qe(t,a){const r=a==null?void 0:a["x-lt-bind"];return typeof r=="string"&&r.length>0?r:t}function Wt(t,a){const r=a==null?void 0:a.properties;if(!r)return{...t};const n={};for(const[s,l]of Object.entries(r))s in t&&It(n,qe(s,l),t[s]);return n}function Pt(t,a){const r=a==null?void 0:a.properties;if(!r)return t?{...t}:{};const n={};for(const[s,l]of Object.entries(r)){const c=At(t,qe(s,l));c!==void 0&&(n[s]=c)}return n}function Ot(t){const{mode:a,activeView:r,onActiveViewChange:n,onClaim:s,claimPending:l,workflowType:c,json:x,onResolve:i,resolvePending:o,resolveError:d,requestTriage:p,triageNotes:j,currentRole:g,escalationTargets:u,onEscalate:f,escalatePending:m,escalateError:y,onRelease:b,releasePending:$,onCancel:C,assignedTo:O,assignedUntil:I,onSubmitAttempt:T}=t,E=gt(),[v,N]=h.useState("30"),[k,R]=h.useState(0),[A,J]=h.useState(""),[B,D]=h.useState(""),L=v==="custom",z=h.useCallback(w=>R(w),[]);if(a==="terminal")return null;const de=()=>{const w=L?k:parseInt(v);!w||w<=0||s(w)},q=()=>{if(J(""),p){const U={_lt:{needsTriage:!0}};j.trim()&&(U.notes=j.trim()),i(U);return}let w;try{w=JSON.parse(x)}catch{J("Invalid JSON");return}const H=w._form_schema,X=H==null?void 0:H.required;if(X!=null&&X.length){const U=X.filter(P=>{const K=w[P];return K==null||typeof K=="string"&&K.trim()===""});if(U.length>0){T==null||T();const P=U.map(ee=>ee.replace(/[_-]/g," ")),K=P.length<=2?P.join(", "):`${P.slice(0,2).join(", ")}...`;J(`Required: ${K}`);return}}const{_form_schema:re,...ie}=w;i(Wt(ie,H))},W=w=>`text-xs transition-colors ${w?"text-accent font-medium":"text-text-tertiary hover:text-accent"}`;return e.jsxs("div",{className:"sticky bottom-0 h-[80px] bg-surface/95 backdrop-blur-sm border-t border-surface-border -mx-10 px-10 pt-3 pb-5 z-10","data-testid":"escalation-action-bar",children:[a==="available"&&e.jsxs("div",{"data-testid":"claim-bar",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-2",children:[E.map(w=>e.jsx("button",{onClick:()=>{N(w.value),R(0)},className:W(!L&&v===w.value),children:w.label},w.value)),e.jsx("button",{onClick:()=>N("custom"),className:W(L),children:"Other"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:C,className:"text-xs text-text-tertiary hover:text-status-error transition-colors",children:"Cancel escalation"}),e.jsx("div",{className:"flex-1"}),L&&e.jsx(jt,{onChange:z,compact:!0,autoFocus:!0}),e.jsx("button",{onClick:de,disabled:l||L&&k<=0,className:"btn-primary text-xs",children:l?"Claiming...":"Claim"})]})]}),a==="claimed_by_other"&&e.jsxs("div",{className:"flex items-center gap-4","data-testid":"claimed-other-bar",children:[e.jsxs("p",{className:"text-sm text-text-secondary",children:["Claimed by ",e.jsx("span",{className:"font-medium text-text-primary",children:O?e.jsx(be,{userId:O}):"unknown"})]}),I&&e.jsx(je,{until:I})]}),a==="claimed_by_me"&&e.jsxs("div",{"data-testid":"action-bar",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-2",children:[e.jsx("button",{onClick:()=>n("resolve"),className:W(r==="resolve"),children:c?"Resolve":"Acknowledge"}),u.length>0&&e.jsx("button",{onClick:()=>n("escalate"),className:W(r==="escalate"),children:"Escalate"}),e.jsx("button",{onClick:()=>n("release"),className:`text-xs transition-colors ${r==="release"?"text-status-error font-medium":"text-text-tertiary hover:text-status-error"}`,children:"Release"}),e.jsx("button",{onClick:C,className:"text-xs transition-colors text-text-tertiary hover:text-status-error",children:"Cancel"})]}),r==="resolve"&&(c?e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"flex-1"}),A&&e.jsx("span",{className:"text-xs text-status-error",children:A}),d&&e.jsx("span",{className:"text-xs text-status-error",children:d.message}),e.jsx("button",{onClick:q,disabled:o,className:"btn-primary text-xs",children:o?"Submitting...":p?"Send to Triage":"Submit"})]}):e.jsxs("div",{className:"flex items-center",children:[e.jsx("span",{className:"text-xs text-text-secondary",children:"Notification — acknowledge to resolve"}),e.jsx("div",{className:"flex-1"}),d&&e.jsx("span",{className:"text-xs text-status-error mr-3",children:d.message}),e.jsx("button",{onClick:()=>i({acknowledged:!0}),disabled:o,className:"btn-primary text-xs",children:o?"Acknowledging...":"Acknowledge"})]})),r==="escalate"&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-xs text-text-secondary",children:["From ",e.jsx("span",{className:"font-medium text-text-primary",children:g})," to"]}),e.jsxs("select",{value:B,onChange:w=>D(w.target.value),className:"select text-xs","data-testid":"escalate-select",children:[e.jsx("option",{value:"",children:"Select role..."}),u.map(w=>e.jsx("option",{value:w,children:w},w))]}),e.jsx("div",{className:"flex-1"}),y&&e.jsx("span",{className:"text-xs text-status-error",children:y.message}),e.jsx("button",{onClick:()=>f(B),disabled:!B||m,className:"btn-primary text-xs",children:m?"Escalating...":"Escalate"})]}),r==="release"&&e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-xs text-text-secondary",children:"Release back to pool?"}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:()=>n("resolve"),className:"btn-secondary text-xs",children:"Back"}),e.jsx("button",{onClick:b,disabled:$,className:"btn-primary text-xs bg-status-error hover:bg-status-error/80",children:$?"Releasing...":"Yes, Release"})]})]})]})}const Dt={1:{pad:"px-3 py-2.5",label:"text-[9px] mb-1.5",value:"text-xs",bg:"bg-surface-sunken/60"},2:{pad:"px-3 py-2",label:"text-[8px] mb-1",value:"text-[11px]",bg:"bg-surface-sunken/30"},3:{pad:"px-2.5 py-1.5",label:"text-[8px] mb-0.5",value:"text-[10px]",bg:"bg-surface-sunken/15"}};function S({label:t,children:a,tier:r=1,className:n=""}){const s=Dt[r];return e.jsxs("div",{className:`flex-1 min-w-0 rounded-lg ${s.bg} ${s.pad} ${n}`,children:[e.jsx("p",{className:`font-semibold uppercase tracking-widest text-text-tertiary leading-none ${s.label}`,children:t}),e.jsx("div",{className:`text-text-secondary leading-tight min-w-0 ${s.value}`,children:a})]})}const De=56;function Lt({value:t}){const[a,r]=h.useState(!1),n=typeof t=="object"?JSON.stringify(t):String(t??"");return n.length<=De?e.jsx("span",{className:"font-mono break-all",title:n,children:n}):e.jsx("button",{onClick:()=>r(s=>!s),title:n,className:"font-mono break-all text-left hover:text-accent transition-colors",children:a?n:`${n.slice(0,De)}…`})}function Ft({esc:t,claimedByMe:a,claimed:r,isTerminal:n,traceUrl:s,isDevMode:l,showDetails:c,onToggleDetails:x}){const{isBuilder:i}=ye(),o=wt(t);return l?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[o&&e.jsx(Tt,{className:"w-5 h-5 text-text-tertiary shrink-0"}),e.jsxs("p",{className:"text-[1.5rem] leading-snug font-light text-text-secondary",children:[t.type,t.subtype?` / ${t.subtype}`:""]})]}),t.description&&e.jsx("p",{className:"text-sm leading-relaxed text-text-tertiary mb-4",children:t.description}),e.jsxs("div",{className:"flex flex-wrap items-end gap-x-6 gap-y-3 mt-4 mb-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] font-semibold uppercase tracking-widest text-text-tertiary mb-1.5",children:"Status"}),e.jsx("span",{className:"mb-1 inline-block",children:e.jsx(Me,{status:t.status})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] font-semibold uppercase tracking-widest text-text-tertiary mb-1.5",children:"Role"}),e.jsx(Ie,{role:t.role,size:"md"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] font-semibold uppercase tracking-widest text-text-tertiary mb-1.5",children:"Created"}),e.jsx("span",{className:"inline-flex items-center mb-1 text-xs text-text-secondary",children:e.jsx(V,{date:t.created_at})})]}),(r||n)&&t.assigned_to&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] font-semibold uppercase tracking-widest text-text-tertiary mb-1.5",children:"Claimed by"}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs font-medium text-text-primary",children:[e.jsx(Ae,{className:"w-3 h-3 shrink-0 text-accent/75"}),e.jsx(be,{userId:t.assigned_to})]})]}),r&&!n&&t.assigned_until&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] font-semibold uppercase tracking-widest text-text-tertiary mb-1.5",children:"Time left"}),e.jsx("span",{className:"inline-flex items-center h-5",children:e.jsx(je,{until:t.assigned_until})})]}),t.resolved_at&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] font-semibold uppercase tracking-widest text-text-tertiary mb-1.5",children:"Resolved"}),e.jsx("span",{className:"inline-flex items-center h-5 text-xs text-text-secondary",children:e.jsx(V,{date:t.resolved_at})})]})]})]}):e.jsxs("div",{className:"-mt-6 mb-2",children:[t.description&&e.jsx("p",{className:"text-2xl font-light text-text-primary leading-relaxed mb-5",children:t.description}),e.jsxs("div",{className:"flex gap-1 items-stretch",children:[e.jsx(S,{label:"Status",children:e.jsx(Me,{status:t.status})}),e.jsx(S,{label:"Assigned to Role",children:e.jsx(Ie,{role:t.role,size:"md"})}),(r||n)&&t.assigned_to&&e.jsx(S,{label:"Claimed By",children:e.jsxs("span",{className:"inline-flex items-center gap-1.5 font-medium text-text-primary",children:[e.jsx(Ae,{className:"w-3 h-3 shrink-0 text-accent/75"}),e.jsx(be,{userId:t.assigned_to})]})}),e.jsx(S,{label:"Created",children:e.jsx(V,{date:t.created_at})}),(r||n)&&t.claimed_at&&e.jsx(S,{label:"Claimed",children:e.jsx(V,{date:t.claimed_at})}),r&&!n&&t.assigned_until&&e.jsx(S,{label:"Time Remaining",children:e.jsx(je,{until:t.assigned_until})}),t.resolved_at&&e.jsx(S,{label:"Completed",children:e.jsx("span",{className:"text-status-success",children:e.jsx(V,{date:t.resolved_at})})}),e.jsxs(S,{label:"Priority",children:["P",t.priority]}),i&&e.jsx("button",{onClick:x,title:c?"Hide details":"Show details",className:"shrink-0 rounded-lg bg-surface-sunken/60 px-3 flex items-center text-text-tertiary/60 hover:text-accent transition-colors",children:e.jsx(Ct,{className:`w-3.5 h-3.5 ${c?"text-accent":""}`})})]}),i&&e.jsxs(ot,{open:c,children:[e.jsxs("div",{className:"flex gap-1 mt-1",children:[e.jsx(S,{tier:2,label:"Escalation ID",children:e.jsx(M,{bare:!0,value:t.id})}),t.task_id&&e.jsx(S,{tier:2,label:"Task ID",children:e.jsx(M,{bare:!0,value:t.task_id,href:`/workflows/tasks/detail/${t.task_id}`})}),t.workflow_type&&e.jsx(S,{tier:2,label:"Workflow Name",children:e.jsx(M,{bare:!0,value:t.workflow_type,href:`/workflows/executions?entity=${encodeURIComponent(t.workflow_type)}`})}),t.workflow_id&&e.jsx(S,{tier:2,label:"Workflow ID",children:e.jsx(M,{bare:!0,value:t.workflow_id,href:`/workflows/executions/${t.workflow_id}`})}),t.task_queue&&e.jsx(S,{tier:2,label:"Task Queue",children:e.jsx(M,{bare:!0,value:t.task_queue,href:`/admin/controlplane?queue=${encodeURIComponent(t.task_queue)}`})}),t.origin_id&&t.origin_id!==t.workflow_id&&e.jsx(S,{tier:2,label:"Origin",children:e.jsx(M,{bare:!0,value:t.origin_id,href:`/processes/detail/${t.origin_id}`})}),t.trace_id&&e.jsx(S,{tier:2,label:"Trace",children:e.jsx(M,{bare:!0,value:t.trace_id,href:s?s.replace("{traceId}",t.trace_id):void 0,external:!0})})]}),t.metadata&&Object.keys(t.metadata).filter(d=>!d.startsWith("_")).length>0&&e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-1 mt-1",children:Object.entries(t.metadata).filter(([d])=>!d.startsWith("_")).map(([d,p])=>e.jsx(S,{tier:3,label:d,children:e.jsx(Lt,{value:p})},d))})]})]})}function Q(t){return t.replace(/`([^`]+)`/g,'<code class="px-1 py-0.5 bg-surface-sunken rounded text-xs font-mono">$1</code>').replace(/\*\*\*(.+?)\*\*\*/g,"<strong><em>$1</em></strong>").replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/\*(.+?)\*/g,"<em>$1</em>").replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<a href="$2" class="text-accent-primary hover:underline" target="_blank" rel="noopener noreferrer">$1</a>')}function fe({content:t,compact:a}){const r=[],n=/^```(\w*)\n([\s\S]*?)^```$/gm;let s=0,l;for(;(l=n.exec(t))!==null;)l.index>s&&r.push({type:"text",text:t.slice(s,l.index)}),r.push({type:"code",lang:l[1],code:l[2].replace(/\n$/,"")}),s=l.index+l[0].length;s<t.length&&r.push({type:"text",text:t.slice(s)});const c=a?{text:"text-xs",heading:"text-xs",list:"text-xs",code:"text-[11px]"}:{text:"text-sm",heading:"text-sm",list:"text-sm",code:"text-xs"},x=[];for(const i of r){if(i.type==="code"){const o=i.code.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");x.push(`<pre class="my-2 p-2.5 bg-surface-sunken rounded-md overflow-x-auto"><code class="${c.code} font-mono text-text-secondary leading-relaxed">${o}</code></pre>`);continue}x.push(...Jt(i.text,c))}return e.jsx("div",{className:"prose-sm",dangerouslySetInnerHTML:{__html:x.join(`
2
+ `)}})}function Jt(t,a){const r=t.split(`
3
+ `),n=[];let s=!1,l=!1,c=[];for(const x of r){const i=x.trim();if(i.startsWith("|")&&i.endsWith("|")){const o=i.slice(1,-1).split("|").map(d=>d.trim());if(o.every(d=>/^[-:]+$/.test(d)))continue;l||(l=!0,c=[]),c.push(o);continue}if(l){l=!1;const[o,...d]=c;n.push('<div class="overflow-x-auto my-2"><table class="text-xs w-full"><thead><tr>');for(const p of o)n.push(`<th class="text-left py-1 px-2 border-b border-border text-text-secondary font-medium">${Q(p)}</th>`);n.push("</tr></thead><tbody>");for(const p of d){n.push("<tr>");for(const j of p)n.push(`<td class="py-1 px-2 border-b border-border/50">${Q(j)}</td>`);n.push("</tr>")}n.push("</tbody></table></div>"),c=[]}if(!i){s&&(n.push("</ul>"),s=!1);continue}if(i.startsWith("### ")){s&&(n.push("</ul>"),s=!1),n.push(`<h4 class="${a.heading} font-semibold text-text-primary mt-3 mb-1">${Q(i.slice(4))}</h4>`);continue}if(i.startsWith("## ")){s&&(n.push("</ul>"),s=!1),n.push(`<h3 class="${a.heading} font-semibold text-text-primary mt-3 mb-1">${Q(i.slice(3))}</h3>`);continue}if(/^[-*_]{3,}$/.test(i)){s&&(n.push("</ul>"),s=!1),n.push('<hr class="border-border my-3" />');continue}if(/^[-*] /.test(i)){s||(n.push('<ul class="space-y-1 my-1">'),s=!0),n.push(`<li class="${a.list} text-text-secondary flex gap-2"><span class="text-text-tertiary shrink-0">-</span><span>${Q(i.slice(2))}</span></li>`);continue}s&&(n.push("</ul>"),s=!1),n.push(`<p class="${a.text} text-text-secondary my-1">${Q(i)}</p>`)}if(l&&c.length){const[x,...i]=c;n.push('<div class="overflow-x-auto my-2"><table class="text-xs w-full"><thead><tr>');for(const o of x)n.push(`<th class="text-left py-1 px-2 border-b border-border text-text-secondary font-medium">${Q(o)}</th>`);n.push("</tr></thead><tbody>");for(const o of i){n.push("<tr>");for(const d of o)n.push(`<td class="py-1 px-2 border-b border-border/50">${Q(d)}</td>`);n.push("</tr>")}n.push("</tbody></table></div>")}return s&&n.push("</ul>"),n}function ge({children:t}){return e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-1.5",children:t})}function Ut({payload:t,isTerminal:a,resolverPayload:r,onRetryTriage:n,isRetrying:s}){const l=t.title,c=t.summary,x=t.diagnosis,i=t.tool_calls_made,o=t.result,d=r==null?void 0:r._lt,p=(d==null?void 0:d.triaged)===!0,j=d==null?void 0:d.triageWorkflowId,g=a&&p,[u,f]=h.useState(!1);return g?e.jsxs("div",{className:"rounded-md border border-status-success/30 bg-surface-raised",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-surface-border",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("svg",{className:"w-4 h-4 text-status-success shrink-0",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M8 1a7 7 0 110 14A7 7 0 018 1zm3.36 4.65a.5.5 0 00-.72 0L7 9.29 5.36 7.65a.5.5 0 10-.72.7l2 2a.5.5 0 00.72 0l4-4a.5.5 0 000-.7z"})}),e.jsx("span",{className:"text-xs font-medium text-status-success",children:"Resolved by AI Triage"})]}),typeof i=="number"&&e.jsxs("span",{className:"text-[10px] font-mono px-2 py-0.5 rounded-full bg-status-success/10 text-status-success",children:[i," tool calls used"]})]}),e.jsxs("div",{className:"px-4 py-4 space-y-4",children:[l&&e.jsx("p",{className:"text-sm font-medium text-text-primary",children:l}),x&&e.jsxs("div",{children:[e.jsx(ge,{children:"Triage diagnosis"}),e.jsx("div",{className:"text-xs text-text-primary leading-relaxed",children:e.jsx(fe,{content:x})})]}),e.jsx("div",{className:"flex items-center gap-3",children:j&&e.jsx(Be,{to:`/workflows/executions/${j}`,className:"text-[10px] text-accent hover:underline",children:"View triage execution"})})]})]}):e.jsxs("div",{className:"rounded-md border border-status-warning/30 bg-surface-raised",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-surface-border",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("svg",{className:"w-4 h-4 text-status-warning shrink-0",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M8 1a7 7 0 110 14A7 7 0 018 1zm0 3a.75.75 0 00-.75.75v3.5a.75.75 0 001.5 0v-3.5A.75.75 0 008 4zm0 7a.75.75 0 100-1.5.75.75 0 000 1.5z"})}),e.jsx("span",{className:"text-xs font-medium text-status-warning",children:"Tool Rounds Exhausted"})]}),typeof i=="number"&&e.jsxs("span",{className:"text-[10px] font-mono px-2 py-0.5 rounded-full bg-status-warning/10 text-status-warning",children:[i," tool calls used"]})]}),e.jsxs("div",{className:"px-4 py-4 space-y-4",children:[l&&e.jsx("p",{className:"text-sm font-medium text-text-primary",children:l}),c&&e.jsxs("div",{children:[e.jsx(ge,{children:"What happened"}),e.jsx("div",{className:"text-xs text-text-secondary leading-relaxed",children:e.jsx(fe,{content:c})})]}),x&&e.jsxs("div",{children:[e.jsx(ge,{children:"What went wrong"}),e.jsx("div",{className:"text-xs text-text-primary leading-relaxed",children:e.jsx(fe,{content:x})})]}),o!=null&&e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>f(!u),className:"flex items-center gap-1 text-[10px] font-semibold uppercase tracking-widest text-text-tertiary hover:text-text-secondary transition-colors",children:[e.jsx("svg",{className:`w-3 h-3 transition-transform ${u?"rotate-90":""}`,viewBox:"0 0 12 12",fill:"currentColor",children:e.jsx("path",{d:"M4.5 2l4 4-4 4"})}),"Partial results"]}),u&&e.jsx("div",{className:"mt-2",children:e.jsx(ae,{data:o,defaultMode:"tree"})})]}),n&&!a&&e.jsx("div",{className:"pt-2",children:e.jsxs("button",{onClick:n,disabled:s,className:"inline-flex items-center gap-2 px-4 py-2 text-xs font-medium bg-accent text-text-inverse rounded-md hover:bg-accent/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 14 14",fill:"currentColor",children:e.jsx("path",{d:"M7 1a6 6 0 100 12A6 6 0 007 1zm2.5 6.5l-3.5 2V5.5l3.5 2z"})}),s?"Sending to triage...":"Retry with AI Triage"]})})]})]})}function Vt({triage:t,payload:a}){const r=t.confidence??0,n=r>=.8?"text-status-success":r>=.5?"text-status-pending":"text-status-error",s=Bt(t.originalData,a);return e.jsxs("div",{className:"space-y-5",children:[t.diagnosis&&e.jsx("p",{className:"text-sm text-text-primary leading-relaxed",children:t.diagnosis}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs text-text-tertiary",children:[t.tool_calls_made!=null&&e.jsxs("span",{children:[t.tool_calls_made," tool call",t.tool_calls_made!==1?"s":""]}),t.tool_calls_made!=null&&e.jsx("span",{className:"text-text-quaternary",children:"·"}),e.jsxs("span",{className:`font-medium ${n}`,children:[Math.round(r*100),"% confidence"]})]}),t.actions_taken&&t.actions_taken.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.actions_taken.map((l,c)=>e.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 text-[11px]
4
+ text-text-secondary`,children:[e.jsx("svg",{className:"w-3 h-3 text-status-success shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}),l]},c))}),t.recommendation&&e.jsx("p",{className:"text-[11px] text-text-tertiary italic",children:t.recommendation}),s.length>0&&e.jsx("div",{className:"space-y-4 pt-2",children:s.map(l=>e.jsx(zt,{diff:l},l.key))})]})}function Bt(t,a){if(!t)return[];const r=[];for(const n of Object.keys(t)){if(n.startsWith("_"))continue;const s=t[n],l=a[n];l!==void 0&&JSON.stringify(s)!==JSON.stringify(l)&&r.push({key:n,label:n.replace(/[_-]/g," "),original:s,corrected:l})}return r}function zt({diff:t}){const a=Le(t.original),r=Le(t.corrected);return a!==null&&r!==null?e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-x-8 gap-y-3",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:[t.label," ",e.jsx("span",{className:"normal-case font-normal",children:"(original)"})]}),e.jsx("p",{className:"text-sm text-text-tertiary leading-relaxed line-through decoration-text-tertiary/30",children:a})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:[t.label," ",e.jsx("span",{className:"normal-case font-normal text-status-success",children:"(corrected)"})]}),e.jsx("p",{className:"text-sm text-text-primary leading-relaxed",children:r})]})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:[t.label," ",e.jsx("span",{className:"normal-case font-normal",children:"(original)"})]}),e.jsx("pre",{className:"text-xs text-text-tertiary font-mono whitespace-pre-wrap leading-relaxed",children:typeof t.original=="object"?JSON.stringify(t.original,null,2):String(t.original)})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:[t.label," ",e.jsx("span",{className:"normal-case font-normal text-status-success",children:"(corrected)"})]}),e.jsx("pre",{className:"text-xs text-text-primary font-mono whitespace-pre-wrap leading-relaxed",children:typeof t.corrected=="object"?JSON.stringify(t.corrected,null,2):String(t.corrected)})]})]})}function Le(t){return t==null?"null":typeof t=="string"?t:typeof t=="number"||typeof t=="boolean"?String(t):null}function Fe({src:t,escalation:a,schema:r,onResolve:n,onEscalate:s,submitAttempted:l}){const c=h.useRef(null),x=h.useRef("");h.useEffect(()=>{try{const o=new URL(t);x.current=o.origin}catch{x.current=""}},[t]);const i=h.useCallback(()=>{const o=c.current;if(!(o!=null&&o.contentWindow)||!x.current)return;const p={type:"lt:init",escalation:{id:a.id,type:a.type,subtype:a.subtype,description:a.description,status:a.status,priority:a.priority,role:a.role,workflow_type:a.workflow_type},schema:r};o.contentWindow.postMessage(p,x.current)},[a,r]);return h.useEffect(()=>{const o=d=>{if(d.origin!==x.current)return;const p=d.data;if(!(!p||typeof p!="object"||typeof p.type!="string"))switch(p.type){case"lt:ready":i();break;case"lt:submit":p.payload&&typeof p.payload=="object"&&n(p.payload);break;case"lt:escalate":typeof p.target=="string"&&p.target&&s(p.target);break;case"lt:resize":{const j=c.current;j&&typeof p.height=="number"&&p.height>0&&(j.style.height=`${Math.min(p.height,2e3)}px`);break}}};return window.addEventListener("message",o),()=>window.removeEventListener("message",o)},[i,n,s]),h.useEffect(()=>{if(!l)return;const o=c.current;o!=null&&o.contentWindow&&x.current&&o.contentWindow.postMessage({type:"lt:validate"},x.current)},[l]),e.jsx("div",{className:"rounded-md border border-surface-border overflow-hidden bg-white",children:e.jsx("iframe",{ref:c,src:t,sandbox:"allow-scripts allow-same-origin allow-forms",className:"w-full border-0",style:{minHeight:"400px"},title:"HITL Viewport",onLoad:i})})}function qt({fieldKey:t,value:a,onChange:r,schema:n}){const s=h.useRef(null),l=(n==null?void 0:n.accept)??void 0,c=t.replace(/[_-]/g," "),x=n==null?void 0:n.description,i=h.useCallback(d=>{var g;const p=(g=d.target.files)==null?void 0:g[0];if(!p)return;const j=new FileReader;j.onload=()=>{typeof j.result=="string"&&r(j.result)},j.readAsDataURL(p)},[r]),o=a.startsWith("data:");return e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary",children:c}),x&&e.jsx("p",{className:"text-[10px] text-text-tertiary mt-0.5",children:x}),e.jsxs("div",{className:"mt-1",children:[e.jsx("input",{ref:s,type:"file",accept:l,onChange:i,className:"hidden"}),e.jsx("button",{type:"button",onClick:()=>{var d;return(d=s.current)==null?void 0:d.click()},className:"btn-secondary text-xs px-3 py-1.5",children:o?"Replace file":"Choose file"}),o&&e.jsx("span",{className:"ml-2 text-xs text-status-success",children:"File attached"})]})]})}function Ht({fieldKey:t,value:a,onChange:r,schema:n}){const s=t.replace(/[_-]/g," "),l=n==null?void 0:n.description,c=(n==null?void 0:n["x-lt-language"])??"",x=h.useCallback(i=>{if(i.key==="Tab"){i.preventDefault();const o=i.currentTarget,d=o.selectionStart,p=o.selectionEnd,j=a.substring(0,d)+" "+a.substring(p);r(j),requestAnimationFrame(()=>{o.selectionStart=o.selectionEnd=d+2})}},[a,r]);return e.jsxs("div",{children:[e.jsxs("label",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary",children:[s,c&&e.jsx("span",{className:"ml-2 text-text-tertiary/60 normal-case font-normal",children:c})]}),l&&e.jsx("p",{className:"text-[10px] text-text-tertiary mt-0.5",children:l}),e.jsx("textarea",{value:a,onChange:i=>r(i.target.value),onKeyDown:x,className:"input w-full mt-1 font-mono text-xs leading-relaxed",rows:10,spellCheck:!1})]})}function Kt({fieldKey:t,value:a,onChange:r,schema:n}){const s=h.useRef(null),[l,c]=h.useState(!1),x=t.replace(/[_-]/g," "),i=n==null?void 0:n.description;h.useEffect(()=>{const u=s.current;if(!u)return;const f=u.getContext("2d");if(f&&(f.lineWidth=2,f.lineCap="round",f.strokeStyle="#1E1535",a&&a.startsWith("data:"))){const m=new Image;m.onload=()=>f.drawImage(m,0,0),m.src=a}},[]);const o=h.useCallback(u=>{const m=s.current.getBoundingClientRect();return"touches"in u?{x:u.touches[0].clientX-m.left,y:u.touches[0].clientY-m.top}:{x:u.clientX-m.left,y:u.clientY-m.top}},[]),d=h.useCallback(u=>{var y;c(!0);const f=(y=s.current)==null?void 0:y.getContext("2d");if(!f)return;const m=o(u);f.beginPath(),f.moveTo(m.x,m.y)},[o]),p=h.useCallback(u=>{var y;if(!l)return;const f=(y=s.current)==null?void 0:y.getContext("2d");if(!f)return;const m=o(u);f.lineTo(m.x,m.y),f.stroke()},[l,o]),j=h.useCallback(()=>{c(!1);const u=s.current;u&&r(u.toDataURL("image/png"))},[r]),g=h.useCallback(()=>{const u=s.current;if(!u)return;const f=u.getContext("2d");f&&(f.clearRect(0,0,u.width,u.height),r(""))},[r]);return e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary",children:x}),i&&e.jsx("p",{className:"text-[10px] text-text-tertiary mt-0.5",children:i}),e.jsx("div",{className:"mt-1 border border-surface-border rounded-md overflow-hidden bg-white",children:e.jsx("canvas",{ref:s,width:400,height:150,className:"w-full cursor-crosshair touch-none",onMouseDown:d,onMouseMove:p,onMouseUp:j,onMouseLeave:j,onTouchStart:d,onTouchMove:p,onTouchEnd:j})}),e.jsx("button",{type:"button",onClick:g,className:"mt-1 text-[10px] text-text-tertiary hover:text-accent transition-colors",children:"Clear"})]})}function Yt({fieldKey:t,value:a,onChange:r,schema:n}){const s=t.replace(/[_-]/g," "),l=n==null?void 0:n.description;return e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary",children:s}),l&&e.jsx("p",{className:"text-[10px] text-text-tertiary mt-0.5",children:l}),e.jsx("textarea",{value:a,onChange:c=>r(c.target.value),className:"input w-full mt-1 text-sm leading-relaxed",rows:8,placeholder:"Supports plain text. Markdown formatting is preserved."})]})}function Qt({fieldKey:t,value:a,onChange:r,schema:n}){const[s,l]=h.useState("write"),c=t.replace(/[_-]/g," "),x=n==null?void 0:n.description;return(n==null?void 0:n.readOnly)===!0?e.jsx(Se,{content:a,className:"my-1"}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary",children:c}),e.jsx("div",{className:"flex items-center gap-0.5",children:["write","preview"].map(o=>e.jsx("button",{type:"button",onClick:()=>l(o),className:`px-2 py-0.5 text-[10px] rounded transition-colors ${s===o?"bg-accent/10 text-accent font-semibold":"text-text-quaternary hover:text-text-secondary"}`,children:o==="write"?"Write":"Preview"},o))})]}),x&&e.jsx("p",{className:"text-[10px] text-text-tertiary mt-0.5",children:x}),s==="write"?e.jsx("textarea",{value:a,onChange:o=>r(o.target.value),className:"input w-full mt-1 text-sm font-mono leading-relaxed",rows:10,placeholder:"Write markdown — headings, lists, tables, code blocks, and links all render."}):e.jsx("div",{className:"mt-1 px-3 py-2 border border-surface-border rounded min-h-[120px]",children:a.trim()?e.jsx(Se,{content:a}):e.jsx("p",{className:"text-xs text-text-quaternary italic",children:"Nothing to preview."})})]})}const Je={"file-upload":qt,"code-editor":Ht,signature:Kt,"rich-text":Yt,markdown:Qt};function He({value:t,onChange:a,disabled:r,submitAttempted:n}){const[s,l]=h.useState({}),[c,x]=h.useState({}),[i,o]=h.useState(null),[d,p]=h.useState(!1),[j,g]=h.useState(new Set);h.useEffect(()=>{try{const v=JSON.parse(t);if(typeof v=="object"&&v!==null&&!Array.isArray(v)){const N={},k={};for(const[R,A]of Object.entries(v))R.startsWith("_")?k[R]=A:N[R]=A;l(N),x(k),o(k._form_schema&&typeof k._form_schema=="object"?k._form_schema:null),p(!1)}}catch{p(!0)}},[t]);const u=h.useCallback(v=>{l(v),a(JSON.stringify({...v,...c},null,2))},[c,a]),f=h.useCallback((v,N)=>{u({...s,[v]:N})},[s,u]),m=h.useCallback(v=>{g(N=>{if(N.has(v))return N;const k=new Set(N);return k.add(v),k})},[]);if(d)return e.jsx("p",{className:"text-xs text-status-error",children:"Unable to parse resolver data as form. Use the JSON editor below."});const y=Object.entries(s);if(y.length===0)return e.jsx("p",{className:"text-xs text-text-tertiary italic",children:"No resolver fields defined."});const b=i==null?void 0:i["x-lt-order"],$=b?[...y].sort((v,N)=>{const k=b.indexOf(v[0]),R=b.indexOf(N[0]);return(k===-1?1/0:k)-(R===-1?1/0:R)}):y,C=new Set((i==null?void 0:i.required)??[]),O=i==null?void 0:i["x-lt-layout"],I=i==null?void 0:i.title,T=i==null?void 0:i.description,E=$.map(([v,N])=>{var L;const k=(L=i==null?void 0:i.properties)==null?void 0:L[v],R=(k==null?void 0:k.readOnly)===!0,A=(k==null?void 0:k["x-lt-span"])??1,J=C.has(v),B=j.has(v)||!!n;let D;if(J&&B&&(N==null||typeof N=="string"&&N.trim()==="")&&(D="Required"),B&&typeof N=="string"&&N.trim()!==""&&k){const z=k.format;z==="email"&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(N)&&(D="Enter a valid email address"),z==="uri"&&!/^https?:\/\/.+/.test(N)&&(D="Enter a valid URL")}return e.jsx("div",{className:O==="two-column"&&A>=2?"col-span-2":"",children:e.jsx(Ke,{fieldKey:v,value:N,onChange:z=>f(v,z),onBlur:()=>m(v),schema:i,isRequired:J,isReadOnly:R,error:D})},v)});return e.jsxs("div",{className:`pb-8 ${r?"opacity-60 pointer-events-none":""}`,children:[I&&e.jsx("h3",{className:"text-lg font-light text-text-primary mb-1",children:I}),T&&e.jsx("p",{className:"text-sm text-text-secondary leading-relaxed mb-6",children:T}),O==="two-column"?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-x-14 gap-y-6",children:E}):e.jsx("div",{className:"space-y-6",children:E})]})}function Ke({fieldKey:t,value:a,onChange:r,onBlur:n,schema:s,isRequired:l,isReadOnly:c,error:x}){var j;const i=t.replace(/[_-]/g," "),o=(j=s==null?void 0:s.properties)==null?void 0:j[t],d=o==null?void 0:o["x-lt-widget"];if(c&&!(d==="markdown"&&typeof a=="string")){const g=a===null?"null":typeof a=="object"?JSON.stringify(a,null,2):String(a);return e.jsxs("div",{children:[e.jsx(F,{isRequired:l,children:i}),e.jsx("p",{className:"text-sm text-text-secondary mt-0.5 whitespace-pre-wrap",children:g})]})}if(d&&d in Je&&typeof a=="string"){const g=Je[d];return e.jsx(g,{fieldKey:t,value:a,onChange:u=>r(u),schema:o})}if(typeof a=="boolean")return e.jsxs("div",{children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:a,onChange:g=>{r(g.target.checked),n==null||n()},className:"w-3.5 h-3.5 rounded accent-accent"}),e.jsxs("span",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-secondary",children:[i,l&&e.jsx("span",{className:"text-status-error ml-0.5",children:"*"})]})]}),e.jsx(Z,{error:x})]});if(typeof a=="number")return e.jsxs("div",{children:[e.jsx(F,{isRequired:l,children:i}),e.jsx("input",{type:"number",value:a,onChange:g=>r(parseFloat(g.target.value)||0),onBlur:n,step:"any",className:te(!!x)}),e.jsx(Z,{error:x})]});if(typeof a=="string"){const g=(o==null?void 0:o.format)==="password",u=o==null?void 0:o.enum,f=o==null?void 0:o.description;if(u!=null&&u.length)return e.jsxs("div",{children:[e.jsx(F,{isRequired:l,children:i}),f&&e.jsx("p",{className:"text-[10px] text-text-tertiary mt-0.5",children:f}),e.jsx("select",{value:a,onChange:b=>r(b.target.value),onBlur:n,className:te(!!x),children:u.map(b=>e.jsx("option",{value:b,children:b},b))}),e.jsx(Z,{error:x})]});if(g)return e.jsxs("div",{children:[e.jsx(F,{isRequired:l,children:i}),f&&e.jsx("p",{className:"text-[10px] text-text-tertiary mt-0.5",children:f}),e.jsx("input",{type:"password",value:a,onChange:b=>r(b.target.value),onBlur:n,className:te(!!x),autoComplete:"off"}),e.jsx(Z,{error:x})]});const m=o==null?void 0:o.format,y={date:"date","date-time":"datetime-local",email:"email",uri:"url"};return m&&m in y?e.jsxs("div",{children:[e.jsx(F,{isRequired:l,children:i}),f&&e.jsx("p",{className:"text-[10px] text-text-tertiary mt-0.5",children:f}),e.jsx("input",{type:y[m],value:a,onChange:b=>r(b.target.value),onBlur:n,className:te(!!x)}),e.jsx(Z,{error:x})]}):m==="textarea"||a.length>80?e.jsxs("div",{children:[e.jsx(F,{isRequired:l,children:i}),f&&e.jsx("p",{className:"text-[10px] text-text-tertiary mt-0.5",children:f}),e.jsx("textarea",{value:a,onChange:b=>r(b.target.value),onBlur:n,className:`${te(!!x)} leading-relaxed`,rows:Math.min(6,Math.max(3,Math.ceil(a.length/60)))}),e.jsx(Z,{error:x})]}):e.jsxs("div",{children:[e.jsx(F,{isRequired:l,children:i}),f&&e.jsx("p",{className:"text-[10px] text-text-tertiary mt-0.5",children:f}),e.jsx("input",{type:"text",value:a,onChange:b=>r(b.target.value),onBlur:n,className:te(!!x)}),e.jsx(Z,{error:x})]})}if(a===null)return e.jsxs("div",{children:[e.jsx(F,{isRequired:l,children:i}),e.jsx("p",{className:"text-xs text-text-tertiary italic mt-1",children:"null"})]});if(Array.isArray(a))return e.jsxs("div",{children:[e.jsx(F,{isRequired:l,children:i}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1",children:a.map((g,u)=>e.jsx("span",{className:"px-2 py-0.5 text-[11px] font-mono bg-surface-sunken rounded text-text-secondary",children:String(g)},u))})]});if(typeof a=="object"){const g=Object.entries(a);return e.jsxs("div",{children:[e.jsx(F,{isRequired:l,children:i}),e.jsx("div",{className:"ml-4 mt-2 pl-4 border-l border-accent-faint space-y-3",children:g.map(([u,f])=>e.jsx(Ke,{fieldKey:u,value:f,onChange:m=>r({...a,[u]:m})},u))})]})}return null}function F({children:t,isRequired:a}){return e.jsxs("label",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-secondary",children:[t,a&&e.jsx("span",{className:"text-status-error ml-0.5",children:"*"})]})}function Z({error:t}){return t?e.jsx("p",{className:"text-[10px] text-status-error mt-1 animate-[field-error-in_0.3s_ease-out]",children:t}):null}function te(t){return t?"input text-sm w-full mt-1 border-status-error/50 focus:border-status-error animate-[field-shake_0.4s_ease-in-out]":"input text-sm w-full mt-1"}function Ue({json:t,onJsonChange:a,requestTriage:r,onRequestTriageChange:n,triageNotes:s,onTriageNotesChange:l,isDevMode:c=!0,disabled:x=!1,submitAttempted:i=!1,showTriage:o=!1}){const[d,p]=h.useState("form"),{visibleJson:j,hiddenFields:g}=h.useMemo(()=>{try{const m=JSON.parse(t);if(typeof m=="object"&&m!==null&&!Array.isArray(m)){const y={},b={};for(const[$,C]of Object.entries(m))$.startsWith("_")?y[$]=C:b[$]=C;return{visibleJson:JSON.stringify(b,null,2),hiddenFields:y}}}catch{}return{visibleJson:t,hiddenFields:{}}},[t]),u=h.useCallback(m=>{try{const y=JSON.parse(m);a(JSON.stringify({...y,...g},null,2))}catch{a(m)}},[g,a]),f=Object.keys(g).length>0;return e.jsxs(e.Fragment,{children:[(o||c)&&e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[o?r?e.jsxs("button",{onClick:()=>n(!1),className:"group flex items-center gap-2 text-left","data-testid":"triage-cancel",children:[e.jsx("span",{className:"flex items-center justify-center w-5 h-5 rounded-full bg-accent/10 text-accent shrink-0",children:e.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})}),e.jsxs("span",{className:"text-xs text-text-secondary group-hover:text-text-primary transition-colors",children:["AI Triage active."," ",e.jsx("span",{className:"text-accent group-hover:underline",children:"Cancel"})]})]}):e.jsxs("button",{onClick:()=>n(!0),className:"group flex items-center gap-2.5 text-left my-4","data-testid":"triage-callout",children:[e.jsx("span",{className:"flex items-center justify-center w-6 h-6 rounded-full bg-accent/10 text-accent shrink-0 animate-[triage-glow_6s_ease-in-out_infinite]",children:e.jsx("svg",{className:"w-3.5 h-3.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9.663 17h4.674M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})})}),e.jsxs("span",{className:"text-[13px] text-text-secondary group-hover:text-text-primary transition-colors",children:["This form doesn't capture the issue?"," ",e.jsx("span",{className:"text-accent group-hover:underline",children:"Request AI Triage"})]})]}):e.jsx("span",{}),c&&!r&&e.jsx("button",{onClick:()=>p(d==="form"?"json":"form"),className:"text-[10px] text-text-tertiary hover:text-accent transition-colors",children:d==="form"?"Raw JSON":"Form"})]}),e.jsxs("div",{className:"relative min-h-[200px]",children:[e.jsx("div",{className:r?"pointer-events-none select-none":"",children:d==="form"?e.jsx(He,{value:t,onChange:a,disabled:x,submitAttempted:i}):e.jsxs("div",{children:[f&&e.jsx("p",{className:"text-[10px] text-text-quaternary mb-2 italic",children:"Form schema hidden. Edit the resolver values below — they will be merged with the schema on submit."}),e.jsx("textarea",{value:j,onChange:m=>u(m.target.value),className:"input-json w-full",rows:Math.max(8,j.split(`
5
+ `).length+2),spellCheck:!1,"data-testid":"resolve-json"})]})}),r&&e.jsxs("div",{className:"absolute inset-0 z-10 flex flex-col bg-surface/90 backdrop-blur-[2px] rounded-md border border-accent/20 p-5","data-testid":"triage-overlay",children:[e.jsx("p",{className:"text-xs text-text-secondary mb-3 leading-relaxed",children:"The resolution form will not be submitted. Describe the issue so AI triage can diagnose and fix it using available tools. The corrected result will come back as a new escalation for your review."}),e.jsx("textarea",{value:s,onChange:m=>l(m.target.value),placeholder:"e.g. Content is in Spanish — needs translation to English before review...",className:"input text-xs w-full flex-1 min-h-[80px] resize-none",autoFocus:!0,"data-testid":"triage-notes"})]})]})]})}function G({children:t}){return e.jsx("span",{className:"text-[9px] font-semibold uppercase tracking-widest text-text-tertiary",children:t})}function oe({children:t}){return e.jsx("p",{className:"text-[12px] text-text-secondary mt-0.5 font-mono",children:t})}function Gt({esc:t}){const{isBuilder:a}=ye();return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-accent/60 mb-3",children:"Classification"}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-x-8 gap-y-4",children:[e.jsxs("div",{children:[e.jsx(G,{children:"Type"}),e.jsx(oe,{children:t.type})]}),t.subtype&&e.jsxs("div",{children:[e.jsx(G,{children:"Subtype"}),e.jsx(oe,{children:t.subtype})]}),e.jsxs("div",{children:[e.jsx(G,{children:"Priority"}),e.jsxs(oe,{children:["P",t.priority]})]}),e.jsxs("div",{children:[e.jsx(G,{children:"Status"}),e.jsx(oe,{children:t.status})]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-accent/60 mb-3",children:"References"}),e.jsxs("div",{className:"flex flex-wrap gap-x-8 gap-y-4",children:[e.jsx(M,{label:"Escalation ID",value:t.id}),t.task_id&&e.jsx(M,{label:"Task ID",value:t.task_id,href:a?`/workflows/tasks/detail/${t.task_id}`:void 0}),t.workflow_type&&e.jsx(M,{label:"Workflow Name",value:t.workflow_type,href:a?`/workflows/executions?entity=${encodeURIComponent(t.workflow_type)}`:void 0}),t.workflow_id&&e.jsx(M,{label:"Workflow ID",value:t.workflow_id,href:a?`/workflows/executions/${t.workflow_id}`:void 0}),t.task_queue&&e.jsx(M,{label:"Task Queue",value:t.task_queue,href:a?`/admin/controlplane?queue=${encodeURIComponent(t.task_queue)}`:void 0}),t.origin_id&&t.origin_id!==t.workflow_id&&e.jsx(M,{label:"Origin ID",value:t.origin_id}),t.parent_id&&e.jsx(M,{label:"Parent ID",value:t.parent_id}),t.trace_id&&e.jsx(M,{label:"Trace ID",value:t.trace_id}),t.span_id&&e.jsx(M,{label:"Span ID",value:t.span_id})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-accent/60 mb-3",children:"Timeline"}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-x-8 gap-y-4",children:[e.jsxs("div",{children:[e.jsx(G,{children:"Created"}),e.jsx("p",{className:"text-[12px] text-text-secondary mt-0.5",children:e.jsx(V,{date:t.created_at})})]}),t.claimed_at&&e.jsxs("div",{children:[e.jsx(G,{children:"Claimed"}),e.jsx("p",{className:"text-[12px] text-text-secondary mt-0.5",children:e.jsx(V,{date:t.claimed_at})})]}),t.resolved_at&&e.jsxs("div",{children:[e.jsx(G,{children:"Resolved"}),e.jsx("p",{className:"text-[12px] text-text-secondary mt-0.5",children:e.jsx(V,{date:t.resolved_at})})]}),e.jsxs("div",{children:[e.jsx(G,{children:"Updated"}),e.jsx("p",{className:"text-[12px] text-text-secondary mt-0.5",children:e.jsx(V,{date:t.updated_at})})]})]})]}),t.metadata&&Object.keys(t.metadata).length>0&&e.jsx("div",{children:e.jsx(ae,{data:t.metadata,label:"Metadata"})})]})}function Xt({isRoundsExhausted:t,payloadObj:a,isTerminal:r,resolverPayload:n,onRetryTriage:s,isRetrying:l}){return e.jsxs(e.Fragment,{children:[t&&a&&e.jsx("div",{className:"mt-8",children:e.jsx(Ut,{payload:a,isTerminal:r,resolverPayload:n,onRetryTriage:s,isRetrying:l})}),(a==null?void 0:a.category)==="missing_credential"&&e.jsxs("div",{className:"mt-8 bg-status-warning/10 border border-status-warning/30 rounded-md px-5 py-4 flex items-start gap-3",children:[e.jsx(We,{size:20,className:"text-status-warning mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-text-primary mb-1",children:"Missing Credential"}),e.jsxs("p",{className:"text-xs text-text-secondary mb-3",children:["This workflow requires a ",e.jsx("span",{className:"font-medium capitalize",children:String(a.provider)})," credential to continue. Register one and then resolve this escalation to retry."]}),e.jsxs(Be,{to:"/credentials",className:"btn-primary text-xs inline-flex items-center gap-1.5",children:[e.jsx(We,{size:12}),"Go to Credentials"]})]})]})]})}function Zt({isCollapsed:t,toggleSection:a,esc:r,escalationPayload:n,resolverPayload:s,triageData:l,payloadObj:c,isTerminal:x,claimedByMe:i,activeView:o,metadataFormSchema:d,json:p,onJsonChange:j,requestTriage:g,onRequestTriageChange:u,triageNotes:f,onTriageNotesChange:m,isDevMode:y,onResolve:b,onEscalate:$,submitAttempted:C,isCertified:O,hasAI:I}){return e.jsxs("div",{className:"mt-8 space-y-6",children:[y&&e.jsx(le,{title:"Escalation Record",sectionKey:"record",isCollapsed:t("record"),onToggle:a,contentClassName:"mt-4 ml-9",children:e.jsx(Gt,{esc:r})}),y&&e.jsx(le,{title:"Input / Output",sectionKey:"context",isCollapsed:t("context"),onToggle:a,contentClassName:"mt-4 ml-9",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[!!r.envelope&&e.jsx("div",{children:e.jsx(ae,{data:r.envelope,label:"Input Envelope"})}),n!=null&&e.jsx("div",{children:e.jsx(ae,{data:n,label:"Escalation Context"})})]}),s!=null&&e.jsx("div",{className:"max-w-xl",children:e.jsx(ae,{data:s,label:"Resolver Payload"})})]})}),y&&l&&c&&e.jsx(le,{title:"AI Triage",sectionKey:"triage",isCollapsed:t("triage"),onToggle:a,contentClassName:"mt-4 ml-9",children:e.jsx(Vt,{triage:l,payload:c})}),!y&&x&&s!=null&&(()=>{const T=typeof s=="object"&&s!==null?s:{},E=d,v=E?{...T,_form_schema:E}:T;return e.jsx("div",{className:"pt-6",children:e.jsx(He,{value:JSON.stringify(v,null,2),onChange:()=>{},disabled:!0})})})(),!x&&(i||!y)&&o==="resolve"&&!!(r.workflow_type||d)&&(()=>{const T=d,E=T==null?void 0:T["x-lt-viewport"],v=(E==null?void 0:E.type)==="iframe"&&!!E.src&&b&&$;return y?e.jsx(le,{title:"Submit Your Resolution",sectionKey:"resolver",isCollapsed:t("resolver"),onToggle:a,contentClassName:"mt-4 ml-9",children:v?e.jsx(Fe,{src:E.src,escalation:r,schema:T,onResolve:b,onEscalate:$}):e.jsx(Ue,{json:p,onJsonChange:j,requestTriage:g,onRequestTriageChange:u,triageNotes:f,onTriageNotesChange:m,isDevMode:y,submitAttempted:C,showTriage:!!O&&!!I})}):e.jsx("div",{className:"pt-6",children:v?e.jsx(Fe,{src:E.src,escalation:r,schema:T,onResolve:b,onEscalate:$}):e.jsx(Ue,{json:p,onJsonChange:j,requestTriage:g,onRequestTriageChange:u,triageNotes:f,onTriageNotesChange:m,isDevMode:y,disabled:!i,submitAttempted:C,showTriage:!!O&&!!I})})})()]})}function ce(t){if(!t)return null;try{return JSON.parse(t)}catch{return t}}function es(t){if(!t)return!1;try{const a=JSON.parse(t);return!!(a&&typeof a=="object"&&a._triage)}catch{return!1}}function vs(){var _e,Ce,Te,Ee;const{id:t}=Et(),{user:a}=ct(),r=Rt(),n=lt(),{data:s,isLoading:l,refetch:c,isFetching:x}=dt(t);_t(t);const i=xt(),o=ut(),d=mt(),p=pt(),[j,g]=h.useState(!1),{data:u}=yt((s==null?void 0:s.role)??""),{data:f}=kt(),{data:m}=ht(),{isBuilder:y}=ye(),{isDevMode:b,toggleMode:$}=$t(!1),C=f==null?void 0:f.find(_=>_.workflow_type===(s==null?void 0:s.workflow_type)),O=((_e=m==null?void 0:m.telemetry)==null?void 0:_e.traceUrl)??null,[I,T]=h.useState("resolve"),[E,v]=h.useState("{}"),{isCollapsed:N,toggle:k,collapse:R,expand:A}=ft("escalation-detail"),[J,B]=h.useState(!1),[D,L]=h.useState(""),[z,de]=h.useState(!1),q=((Ce=s==null?void 0:s.metadata)==null?void 0:Ce.form_schema)??null,W=(s==null?void 0:s.form_schema)??(C==null?void 0:C.resolver_schema)??null,w=q??W,H=h.useRef(!1);h.useEffect(()=>{if(H.current)return;const _=q??(W!=null&&W.properties?W:null);if(_!=null&&_.properties){H.current=!0;const ue=ce(s==null?void 0:s.envelope),me=ue==null?void 0:ue.formDefaults,at=me&&typeof me=="object"?Pt(me,_):{},Re={_form_schema:_};for(const[$e,rt]of Object.entries(_.properties)){const it=rt;Re[$e]=at[$e]??it.default??""}v(JSON.stringify(Re,null,2))}else w&&(H.current=!0,v(JSON.stringify(w,null,2)))},[w,q,W,s==null?void 0:s.envelope]);const X=es(s==null?void 0:s.escalation_payload),re=(s==null?void 0:s.subtype)==="rounds_exhausted",ie=(s==null?void 0:s.subtype)==="wait_for_human";if(h.useEffect(()=>{(X||re)&&R("context"),ie&&q&&(R("context"),A("resolver"))},[X,re,ie,q,R,A]),l)return e.jsxs("div",{className:"animate-pulse space-y-8",children:[e.jsx("div",{className:"h-8 bg-surface-sunken rounded w-64"}),e.jsx("div",{className:"h-32 bg-surface-sunken rounded w-full"})]});if(!s)return e.jsx("p",{className:"text-sm text-text-secondary",children:"Escalation not found."});const U=Ve(s),P=U&&s.assigned_to===(a==null?void 0:a.userId),K=U&&!P,ee=s.status==="resolved"||s.status==="cancelled",se=ce(s.escalation_payload),ve=ce(s.resolver_payload),xe=ce(s.envelope),Ye=!!((Te=xe==null?void 0:xe.metadata)!=null&&Te.certified),Qe=!!((Ee=m==null?void 0:m.ai)!=null&&Ee.enabled),Y=typeof se=="object"&&se!==null&&!Array.isArray(se)?se:null,Ge=Y==null?void 0:Y._triage,Xe=ee?"terminal":P?"claimed_by_me":K?"claimed_by_other":"available",Ze=_=>{i.mutate({id:s.id,durationMinutes:_}),R("context"),R("triage"),A("resolver")},ne=()=>{n.resetQueries({queryKey:["escalations"]}),n.resetQueries({queryKey:["escalationStats"]}),r(-1)},we=async _=>{await o.mutateAsync({id:s.id,resolverPayload:_}),ne()},Ne=async _=>{_&&(await d.mutateAsync({id:s.id,targetRole:_}),ne())},et=async()=>{P||await i.mutateAsync({id:s.id,durationMinutes:30});const _=(Y==null?void 0:Y.diagnosis)||s.description||"";await o.mutateAsync({id:s.id,resolverPayload:{_lt:{needsTriage:!0},notes:_}}),ne()},tt=async()=>{await i.mutateAsync({id:s.id,durationMinutes:0}),ne()},st=async()=>{await p.mutateAsync(s.id),g(!1),ne()},ke=y?e.jsx("button",{onClick:$,className:"text-text-tertiary hover:text-accent transition-colors",title:b?"Switch to user view":"Switch to developer view",children:b?e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M17.25 6.75L22.5 12l-5.25 5.25m-10.5 0L1.5 12l5.25-5.25m7.5-3l-4.5 16.5"})}):e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z"})})}):void 0,nt=e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Nt,{onRefresh:()=>c(),isFetching:x,apiPath:`/escalations/${s.id}`}),ke&&e.jsx("div",{className:"ml-4",children:ke})]});return e.jsxs("div",{className:"min-h-[calc(100vh-9rem)] flex flex-col",children:[e.jsx(vt,{title:"Escalation",actions:nt,center:e.jsx(St,{esc:s,className:"w-[25%] shrink-0"})}),e.jsx(Ft,{esc:s,claimedByMe:P,claimed:U,isTerminal:ee,traceUrl:O,isDevMode:b,showDetails:!N("details"),onToggleDetails:()=>k("details")}),e.jsx(Xt,{isRoundsExhausted:re,payloadObj:Y,isTerminal:ee,resolverPayload:ve,onRetryTriage:et,isRetrying:i.isPending||o.isPending}),e.jsx(Zt,{isCollapsed:N,toggleSection:k,esc:s,escalationPayload:se,resolverPayload:ve,triageData:Ge,payloadObj:Y,isTerminal:ee,claimedByMe:P,activeView:I,metadataFormSchema:q,json:E,onJsonChange:v,requestTriage:J,onRequestTriageChange:B,triageNotes:D,onTriageNotesChange:L,isDevMode:b,onResolve:we,onEscalate:Ne,submitAttempted:z,isCertified:Ye,hasAI:Qe}),e.jsx("div",{className:"flex-1"}),e.jsx(Ot,{mode:Xe,activeView:I,onActiveViewChange:T,onClaim:Ze,claimPending:i.isPending,workflowType:s.workflow_type,json:E,onResolve:we,resolvePending:o.isPending,resolveError:o.error,requestTriage:J,triageNotes:D,currentRole:s.role,escalationTargets:((u==null?void 0:u.targets)??[]).filter(_=>_!==s.role),onEscalate:Ne,escalatePending:d.isPending,escalateError:d.error,onRelease:tt,releasePending:i.isPending,onCancel:()=>g(!0),assignedTo:s.assigned_to,assignedUntil:s.assigned_until,onSubmitAttempt:()=>de(!0)}),e.jsx(bt,{open:j,onClose:()=>g(!1),onConfirm:st,isPending:p.isPending,error:p.error})]})}export{vs as EscalationDetailPage};
6
+ //# sourceMappingURL=index-IIq5Tkqs.js.map