@hotmeshio/long-tail 0.8.2 → 0.8.4

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 (194) hide show
  1. package/build/api/escalations/create.js +19 -60
  2. package/build/api/escalations/resolve.js +12 -4
  3. package/build/api/escalations/single.js +8 -4
  4. package/build/api/roles.d.ts +1 -0
  5. package/build/scripts/twin-farm.d.ts +44 -0
  6. package/build/scripts/twin-farm.js +427 -0
  7. package/build/services/escalation/queries.d.ts +13 -0
  8. package/build/services/escalation/queries.js +27 -0
  9. package/build/services/orchestrator/condition.d.ts +18 -12
  10. package/build/services/orchestrator/condition.js +11 -8
  11. package/build/services/role/index.d.ts +1 -2
  12. package/build/services/role/index.js +1 -2
  13. package/build/services/role/schema-validator.d.ts +9 -0
  14. package/build/services/role/schema-validator.js +42 -0
  15. package/build/services/role/sql.d.ts +1 -1
  16. package/build/services/role/sql.js +2 -2
  17. package/build/services/role/types.d.ts +8 -6
  18. package/build/system/mcp-servers/admin/schemas.js +4 -2
  19. package/build/system/mcp-servers/human-queue-schemas.js +6 -2
  20. package/build/system/mcp-servers/human-queue.js +11 -3
  21. package/build/tsconfig.tsbuildinfo +1 -1
  22. package/build/types/config.d.ts +2 -0
  23. package/build/types/startup.d.ts +5 -1
  24. package/dashboard/dist/assets/{AdminDashboard-Nvja-XIJ.js → AdminDashboard-B-JptT54.js} +2 -2
  25. package/dashboard/dist/assets/{AdminDashboard-Nvja-XIJ.js.map → AdminDashboard-B-JptT54.js.map} +1 -1
  26. package/dashboard/dist/assets/{AgentConfigPage-Sf2god7q.js → AgentConfigPage-B1Jc6iJk.js} +2 -2
  27. package/dashboard/dist/assets/{AgentConfigPage-Sf2god7q.js.map → AgentConfigPage-B1Jc6iJk.js.map} +1 -1
  28. package/dashboard/dist/assets/{AgentDetailPage-DtgDeZJR.js → AgentDetailPage-CWpclCOY.js} +2 -2
  29. package/dashboard/dist/assets/{AgentDetailPage-DtgDeZJR.js.map → AgentDetailPage-CWpclCOY.js.map} +1 -1
  30. package/dashboard/dist/assets/{AgentsPage-C6zqP_xC.js → AgentsPage-DyAf5GA2.js} +2 -2
  31. package/dashboard/dist/assets/{AgentsPage-C6zqP_xC.js.map → AgentsPage-DyAf5GA2.js.map} +1 -1
  32. package/dashboard/dist/assets/{AvailableEscalationsPage-D61kC7Is.js → AvailableEscalationsPage-DDwAgklw.js} +2 -2
  33. package/dashboard/dist/assets/{AvailableEscalationsPage-D61kC7Is.js.map → AvailableEscalationsPage-DDwAgklw.js.map} +1 -1
  34. package/dashboard/dist/assets/{BotPicker-ChgljKHj.js → BotPicker-B1RdaNuY.js} +2 -2
  35. package/dashboard/dist/assets/{BotPicker-ChgljKHj.js.map → BotPicker-B1RdaNuY.js.map} +1 -1
  36. package/dashboard/dist/assets/{CapabilitiesPage-DeybKoZM.js → CapabilitiesPage-CxHDnyjX.js} +2 -2
  37. package/dashboard/dist/assets/{CapabilitiesPage-DeybKoZM.js.map → CapabilitiesPage-CxHDnyjX.js.map} +1 -1
  38. package/dashboard/dist/assets/{CollapsibleSection-BPiTuPBk.js → CollapsibleSection-Ds0e8cCO.js} +2 -2
  39. package/dashboard/dist/assets/{CollapsibleSection-BPiTuPBk.js.map → CollapsibleSection-Ds0e8cCO.js.map} +1 -1
  40. package/dashboard/dist/assets/{CredentialsPage-DXOcPWtd.js → CredentialsPage-D8UVO-3A.js} +2 -2
  41. package/dashboard/dist/assets/{CredentialsPage-DXOcPWtd.js.map → CredentialsPage-D8UVO-3A.js.map} +1 -1
  42. package/dashboard/dist/assets/{CronLabel-D3411N8x.js → CronLabel-ZesYXxCH.js} +2 -2
  43. package/dashboard/dist/assets/{CronLabel-D3411N8x.js.map → CronLabel-ZesYXxCH.js.map} +1 -1
  44. package/dashboard/dist/assets/{CustomDurationPicker-WG2tPSbV.js → CustomDurationPicker-OKlwH5a_.js} +2 -2
  45. package/dashboard/dist/assets/{CustomDurationPicker-WG2tPSbV.js.map → CustomDurationPicker-OKlwH5a_.js.map} +1 -1
  46. package/dashboard/dist/assets/{ElapsedCell-BFWEGSD7.js → ElapsedCell-CO8S6vdb.js} +2 -2
  47. package/dashboard/dist/assets/{ElapsedCell-BFWEGSD7.js.map → ElapsedCell-CO8S6vdb.js.map} +1 -1
  48. package/dashboard/dist/assets/{EscalationSchemaPage-D2Y5Yeqn.js → EscalationSchemaPage-Br5sD8-N.js} +2 -2
  49. package/dashboard/dist/assets/{EscalationSchemaPage-D2Y5Yeqn.js.map → EscalationSchemaPage-Br5sD8-N.js.map} +1 -1
  50. package/dashboard/dist/assets/{EscalationsOverview-VlLcX2YM.js → EscalationsOverview-DMpRvVql.js} +2 -2
  51. package/dashboard/dist/assets/{EscalationsOverview-VlLcX2YM.js.map → EscalationsOverview-DMpRvVql.js.map} +1 -1
  52. package/dashboard/dist/assets/{EventTable-3MJw14jp.js → EventTable-BARJeiS2.js} +2 -2
  53. package/dashboard/dist/assets/{EventTable-3MJw14jp.js.map → EventTable-BARJeiS2.js.map} +1 -1
  54. package/dashboard/dist/assets/{GraphInvokePage-QaUUrPnh.js → GraphInvokePage-CTuul-av.js} +2 -2
  55. package/dashboard/dist/assets/{GraphInvokePage-QaUUrPnh.js.map → GraphInvokePage-CTuul-av.js.map} +1 -1
  56. package/dashboard/dist/assets/{HomePage-Br0A3iOp.js → HomePage-BKFpOaHX.js} +2 -2
  57. package/dashboard/dist/assets/{HomePage-Br0A3iOp.js.map → HomePage-BKFpOaHX.js.map} +1 -1
  58. package/dashboard/dist/assets/{ListToolbar-d4MGQefV.js → ListToolbar-Dz2_neVF.js} +2 -2
  59. package/dashboard/dist/assets/{ListToolbar-d4MGQefV.js.map → ListToolbar-Dz2_neVF.js.map} +1 -1
  60. package/dashboard/dist/assets/{McpOverview-CUzJD5Z5.js → McpOverview-Do-vaEqV.js} +2 -2
  61. package/dashboard/dist/assets/{McpOverview-CUzJD5Z5.js.map → McpOverview-Do-vaEqV.js.map} +1 -1
  62. package/dashboard/dist/assets/{McpQueryDetailPage-pYSZmV3M.js → McpQueryDetailPage-HwDGNSbN.js} +2 -2
  63. package/dashboard/dist/assets/{McpQueryDetailPage-pYSZmV3M.js.map → McpQueryDetailPage-HwDGNSbN.js.map} +1 -1
  64. package/dashboard/dist/assets/{McpQueryPage-CA5C5dss.js → McpQueryPage-DxMUpQ7R.js} +2 -2
  65. package/dashboard/dist/assets/{McpQueryPage-CA5C5dss.js.map → McpQueryPage-DxMUpQ7R.js.map} +1 -1
  66. package/dashboard/dist/assets/{McpRunDetailPage-CrRkXwAe.js → McpRunDetailPage-BzzZIXIk.js} +2 -2
  67. package/dashboard/dist/assets/{McpRunDetailPage-CrRkXwAe.js.map → McpRunDetailPage-BzzZIXIk.js.map} +1 -1
  68. package/dashboard/dist/assets/{McpRunsPage-BqRBDbkn.js → McpRunsPage-D3J42d2i.js} +2 -2
  69. package/dashboard/dist/assets/{McpRunsPage-BqRBDbkn.js.map → McpRunsPage-D3J42d2i.js.map} +1 -1
  70. package/dashboard/dist/assets/OperationsPage-BaM-QDhy.js +2 -0
  71. package/dashboard/dist/assets/{OperationsPage--uVJxzmP.js.map → OperationsPage-BaM-QDhy.js.map} +1 -1
  72. package/dashboard/dist/assets/{OperatorDashboard-D-UMrTqI.js → OperatorDashboard-BqJn8wEZ.js} +2 -2
  73. package/dashboard/dist/assets/{OperatorDashboard-D-UMrTqI.js.map → OperatorDashboard-BqJn8wEZ.js.map} +1 -1
  74. package/dashboard/dist/assets/{ProcessDetailPage-BV6D_wuR.js → ProcessDetailPage-C8sT2xuE.js} +2 -2
  75. package/dashboard/dist/assets/{ProcessDetailPage-BV6D_wuR.js.map → ProcessDetailPage-C8sT2xuE.js.map} +1 -1
  76. package/dashboard/dist/assets/{ProcessesListPage-BAalEHpx.js → ProcessesListPage-eA8buUgd.js} +2 -2
  77. package/dashboard/dist/assets/{ProcessesListPage-BAalEHpx.js.map → ProcessesListPage-eA8buUgd.js.map} +1 -1
  78. package/dashboard/dist/assets/{RoleDetailPage-ClE7rUoo.js → RoleDetailPage-aR-ror5v.js} +2 -2
  79. package/dashboard/dist/assets/{RoleDetailPage-ClE7rUoo.js.map → RoleDetailPage-aR-ror5v.js.map} +1 -1
  80. package/dashboard/dist/assets/{RolesPage-DMsgZioQ.js → RolesPage-BQNQxsMY.js} +2 -2
  81. package/dashboard/dist/assets/{RolesPage-DMsgZioQ.js.map → RolesPage-BQNQxsMY.js.map} +1 -1
  82. package/dashboard/dist/assets/{RunAsSelector-VCnEYIwj.js → RunAsSelector-mhusrlYE.js} +2 -2
  83. package/dashboard/dist/assets/{RunAsSelector-VCnEYIwj.js.map → RunAsSelector-mhusrlYE.js.map} +1 -1
  84. package/dashboard/dist/assets/{StickyPagination-3eCY2-_V.js → StickyPagination-CqT9Q1I6.js} +2 -2
  85. package/dashboard/dist/assets/{StickyPagination-3eCY2-_V.js.map → StickyPagination-CqT9Q1I6.js.map} +1 -1
  86. package/dashboard/dist/assets/{StreamMessageDetail-70kDFH4o.js → StreamMessageDetail-jOJaoupp.js} +2 -2
  87. package/dashboard/dist/assets/{StreamMessageDetail-70kDFH4o.js.map → StreamMessageDetail-jOJaoupp.js.map} +1 -1
  88. package/dashboard/dist/assets/{SwimlaneTimeline-BOXRit6t.js → SwimlaneTimeline-BrfmWgAj.js} +2 -2
  89. package/dashboard/dist/assets/{SwimlaneTimeline-BOXRit6t.js.map → SwimlaneTimeline-BrfmWgAj.js.map} +1 -1
  90. package/dashboard/dist/assets/{TaskDetailPage-YxGQE9Qg.js → TaskDetailPage-Cus_JHIC.js} +2 -2
  91. package/dashboard/dist/assets/{TaskDetailPage-YxGQE9Qg.js.map → TaskDetailPage-Cus_JHIC.js.map} +1 -1
  92. package/dashboard/dist/assets/{TasksListPage-DuLJQN7Q.js → TasksListPage-B7GK8AoX.js} +2 -2
  93. package/dashboard/dist/assets/{TasksListPage-DuLJQN7Q.js.map → TasksListPage-B7GK8AoX.js.map} +1 -1
  94. package/dashboard/dist/assets/{TimeAgo-dnc1ZjKc.js → TimeAgo-C606LzT3.js} +2 -2
  95. package/dashboard/dist/assets/{TimeAgo-dnc1ZjKc.js.map → TimeAgo-C606LzT3.js.map} +1 -1
  96. package/dashboard/dist/assets/{TimestampCell-CDR6cTyq.js → TimestampCell-hfh6zvH-.js} +2 -2
  97. package/dashboard/dist/assets/{TimestampCell-CDR6cTyq.js.map → TimestampCell-hfh6zvH-.js.map} +1 -1
  98. package/dashboard/dist/assets/{ToolTestPanel-CfwGdRdz.js → ToolTestPanel-CsPsyvQq.js} +2 -2
  99. package/dashboard/dist/assets/{ToolTestPanel-CfwGdRdz.js.map → ToolTestPanel-CsPsyvQq.js.map} +1 -1
  100. package/dashboard/dist/assets/{TopicDetailPage-f2qaeGFz.js → TopicDetailPage-Diz6r7zr.js} +2 -2
  101. package/dashboard/dist/assets/{TopicDetailPage-f2qaeGFz.js.map → TopicDetailPage-Diz6r7zr.js.map} +1 -1
  102. package/dashboard/dist/assets/{TopicsPage-CwYdVmyK.js → TopicsPage-B6fn7fFh.js} +2 -2
  103. package/dashboard/dist/assets/{TopicsPage-CwYdVmyK.js.map → TopicsPage-B6fn7fFh.js.map} +1 -1
  104. package/dashboard/dist/assets/{UserName-CRE7EZPU.js → UserName-Cc-5QH5q.js} +2 -2
  105. package/dashboard/dist/assets/{UserName-CRE7EZPU.js.map → UserName-Cc-5QH5q.js.map} +1 -1
  106. package/dashboard/dist/assets/{WorkflowExecutionPage-BjNBu-Zt.js → WorkflowExecutionPage-BFq7UdhA.js} +2 -2
  107. package/dashboard/dist/assets/{WorkflowExecutionPage-BjNBu-Zt.js.map → WorkflowExecutionPage-BFq7UdhA.js.map} +1 -1
  108. package/dashboard/dist/assets/{WorkflowsDashboard-DfpvbzNt.js → WorkflowsDashboard-CHCM6hUa.js} +2 -2
  109. package/dashboard/dist/assets/{WorkflowsDashboard-DfpvbzNt.js.map → WorkflowsDashboard-CHCM6hUa.js.map} +1 -1
  110. package/dashboard/dist/assets/{WorkflowsOverview-BwD2lQwj.js → WorkflowsOverview-WeOvl8-_.js} +2 -2
  111. package/dashboard/dist/assets/{WorkflowsOverview-BwD2lQwj.js.map → WorkflowsOverview-WeOvl8-_.js.map} +1 -1
  112. package/dashboard/dist/assets/{YamlWorkflowDetailPage-BhHb7j2s.js → YamlWorkflowDetailPage-6GfhVDpv.js} +2 -2
  113. package/dashboard/dist/assets/{YamlWorkflowDetailPage-BhHb7j2s.js.map → YamlWorkflowDetailPage-6GfhVDpv.js.map} +1 -1
  114. package/dashboard/dist/assets/{YamlWorkflowsPage-SBRpY2dI.js → YamlWorkflowsPage-DqcY3ocP.js} +2 -2
  115. package/dashboard/dist/assets/{YamlWorkflowsPage-SBRpY2dI.js.map → YamlWorkflowsPage-DqcY3ocP.js.map} +1 -1
  116. package/dashboard/dist/assets/{agents-VbkdqWCr.js → agents-DlzvjNxE.js} +2 -2
  117. package/dashboard/dist/assets/{agents-VbkdqWCr.js.map → agents-DlzvjNxE.js.map} +1 -1
  118. package/dashboard/dist/assets/{bots-CsgYcYU_.js → bots-CWMN-KUI.js} +2 -2
  119. package/dashboard/dist/assets/{bots-CsgYcYU_.js.map → bots-CWMN-KUI.js.map} +1 -1
  120. package/dashboard/dist/assets/{capabilities-CMhFyoDl.js → capabilities-_WSZ7cxO.js} +2 -2
  121. package/dashboard/dist/assets/{capabilities-CMhFyoDl.js.map → capabilities-_WSZ7cxO.js.map} +1 -1
  122. package/dashboard/dist/assets/{controlplane-BstXtPbV.js → controlplane-_k9nWZy3.js} +2 -2
  123. package/dashboard/dist/assets/{controlplane-BstXtPbV.js.map → controlplane-_k9nWZy3.js.map} +1 -1
  124. package/dashboard/dist/assets/{escalation-C0BNAeIG.js → escalation-CK8ElYzD.js} +2 -2
  125. package/dashboard/dist/assets/{escalation-C0BNAeIG.js.map → escalation-CK8ElYzD.js.map} +1 -1
  126. package/dashboard/dist/assets/{escalation-columns-DajPgfuV.js → escalation-columns-Dyrf6Tdp.js} +2 -2
  127. package/dashboard/dist/assets/{escalation-columns-DajPgfuV.js.map → escalation-columns-Dyrf6Tdp.js.map} +1 -1
  128. package/dashboard/dist/assets/{index-BWLVqWLU.js → index-BiApvBEz.js} +2 -2
  129. package/dashboard/dist/assets/{index-BWLVqWLU.js.map → index-BiApvBEz.js.map} +1 -1
  130. package/dashboard/dist/assets/{index-D_6JFBiM.js → index-C3h0qGzG.js} +2 -2
  131. package/dashboard/dist/assets/{index-D_6JFBiM.js.map → index-C3h0qGzG.js.map} +1 -1
  132. package/dashboard/dist/assets/{index-fqU_l4dC.js → index-C5Yc3TT7.js} +2 -2
  133. package/dashboard/dist/assets/{index-fqU_l4dC.js.map → index-C5Yc3TT7.js.map} +1 -1
  134. package/dashboard/dist/assets/{index-Cl1vY8Lg.js → index-C7VXLKJs.js} +2 -2
  135. package/dashboard/dist/assets/{index-Cl1vY8Lg.js.map → index-C7VXLKJs.js.map} +1 -1
  136. package/dashboard/dist/assets/{index-CvFQtPWA.js → index-D8GcHxNJ.js} +2 -2
  137. package/dashboard/dist/assets/{index-CvFQtPWA.js.map → index-D8GcHxNJ.js.map} +1 -1
  138. package/dashboard/dist/assets/{index-CSixdp5W.js → index-Dc-Ye2wk.js} +2 -2
  139. package/dashboard/dist/assets/{index-CSixdp5W.js.map → index-Dc-Ye2wk.js.map} +1 -1
  140. package/dashboard/dist/assets/{index-DWlPFH3T.js → index-Dd4Si1Rl.js} +2 -2
  141. package/dashboard/dist/assets/{index-DWlPFH3T.js.map → index-Dd4Si1Rl.js.map} +1 -1
  142. package/dashboard/dist/assets/{index-C8k3Z2su.js → index-DwWP-Z_c.js} +3 -3
  143. package/dashboard/dist/assets/{index-C8k3Z2su.js.map → index-DwWP-Z_c.js.map} +1 -1
  144. package/dashboard/dist/assets/index-Ex5tEte8.js +5 -0
  145. package/dashboard/dist/assets/index-Ex5tEte8.js.map +1 -0
  146. package/dashboard/dist/assets/index-OV1JoB_P.js +6 -0
  147. package/dashboard/dist/assets/index-OV1JoB_P.js.map +1 -0
  148. package/dashboard/dist/assets/{index-BY5m8rhE.js → index-ZBj6Xgim.js} +2 -2
  149. package/dashboard/dist/assets/{index-BY5m8rhE.js.map → index-ZBj6Xgim.js.map} +1 -1
  150. package/dashboard/dist/assets/{index-CXnSqSFH.js → index-kKufOPLo.js} +2 -2
  151. package/dashboard/dist/assets/{index-CXnSqSFH.js.map → index-kKufOPLo.js.map} +1 -1
  152. package/dashboard/dist/assets/{index-CaSMWhLU.js → index-uUYXmvFf.js} +2 -2
  153. package/dashboard/dist/assets/{index-CaSMWhLU.js.map → index-uUYXmvFf.js.map} +1 -1
  154. package/dashboard/dist/assets/{knowledge-Bskl1MbC.js → knowledge-fYoEF4Lx.js} +2 -2
  155. package/dashboard/dist/assets/{knowledge-Bskl1MbC.js.map → knowledge-fYoEF4Lx.js.map} +1 -1
  156. package/dashboard/dist/assets/{mcp-C_qz25AB.js → mcp-1lzlgtS8.js} +2 -2
  157. package/dashboard/dist/assets/{mcp-C_qz25AB.js.map → mcp-1lzlgtS8.js.map} +1 -1
  158. package/dashboard/dist/assets/{mcp-query-CJx58s1A.js → mcp-query-nlrAz7m_.js} +2 -2
  159. package/dashboard/dist/assets/{mcp-query-CJx58s1A.js.map → mcp-query-nlrAz7m_.js.map} +1 -1
  160. package/dashboard/dist/assets/{pipelines-B6GzpgtG.js → pipelines-Ihi7EKXi.js} +2 -2
  161. package/dashboard/dist/assets/{pipelines-B6GzpgtG.js.map → pipelines-Ihi7EKXi.js.map} +1 -1
  162. package/dashboard/dist/assets/{roles-D8lPvFgG.js → roles-D4Wn7kE9.js} +2 -2
  163. package/dashboard/dist/assets/{roles-D8lPvFgG.js.map → roles-D4Wn7kE9.js.map} +1 -1
  164. package/dashboard/dist/assets/{tasks-BWHakSYf.js → tasks-Crk9Y3C4.js} +2 -2
  165. package/dashboard/dist/assets/{tasks-BWHakSYf.js.map → tasks-Crk9Y3C4.js.map} +1 -1
  166. package/dashboard/dist/assets/{topics-0dXzPX8t.js → topics-CtfcCyw9.js} +2 -2
  167. package/dashboard/dist/assets/{topics-0dXzPX8t.js.map → topics-CtfcCyw9.js.map} +1 -1
  168. package/dashboard/dist/assets/{useEventHooks-Dpixlgp-.js → useEventHooks-Dn_vN2xE.js} +2 -2
  169. package/dashboard/dist/assets/{useEventHooks-Dpixlgp-.js.map → useEventHooks-Dn_vN2xE.js.map} +1 -1
  170. package/dashboard/dist/assets/{useNamespace-DQMc77ok.js → useNamespace-Cfs3vKWk.js} +2 -2
  171. package/dashboard/dist/assets/{useNamespace-DQMc77ok.js.map → useNamespace-Cfs3vKWk.js.map} +1 -1
  172. package/dashboard/dist/assets/{useYamlActivityEvents-DO5bHOVE.js → useYamlActivityEvents-ymobxH47.js} +2 -2
  173. package/dashboard/dist/assets/{useYamlActivityEvents-DO5bHOVE.js.map → useYamlActivityEvents-ymobxH47.js.map} +1 -1
  174. package/dashboard/dist/assets/{users-B_LVbnUk.js → users-DngGIiC_.js} +2 -2
  175. package/dashboard/dist/assets/{users-B_LVbnUk.js.map → users-DngGIiC_.js.map} +1 -1
  176. package/dashboard/dist/assets/{workflows-WmmGDAvo.js → workflows-DuUspMAl.js} +2 -2
  177. package/dashboard/dist/assets/{workflows-WmmGDAvo.js.map → workflows-DuUspMAl.js.map} +1 -1
  178. package/dashboard/dist/assets/{yaml-workflows-BS7KHhU1.js → yaml-workflows-DXQCiOsP.js} +2 -2
  179. package/dashboard/dist/assets/{yaml-workflows-BS7KHhU1.js.map → yaml-workflows-DXQCiOsP.js.map} +1 -1
  180. package/dashboard/dist/index.html +1 -1
  181. package/docs/api/http/escalations.md +8 -4
  182. package/docs/api/http/roles.md +1 -1
  183. package/docs/api/http/workflows.md +1 -1
  184. package/docs/api/sdk/escalations.md +3 -3
  185. package/docs/api/sdk/workflows.md +1 -1
  186. package/docs/dashboard.md +2 -2
  187. package/docs/data.md +1 -1
  188. package/docs/hitl-guide.md +2 -3
  189. package/package.json +2 -1
  190. package/dashboard/dist/assets/OperationsPage--uVJxzmP.js +0 -2
  191. package/dashboard/dist/assets/index-BYf0oNSQ.js +0 -6
  192. package/dashboard/dist/assets/index-BYf0oNSQ.js.map +0 -1
  193. package/dashboard/dist/assets/index-BcaQ_hCz.js +0 -9
  194. package/dashboard/dist/assets/index-BcaQ_hCz.js.map +0 -1
@@ -0,0 +1,5 @@
1
+ import{a as m,j as e}from"./vendor-query-B2UbickB.js";import{d as z,h as U,u as H,i as K,b as V}from"./workflows-DuUspMAl.js";import{F as X,b as Y,a as G}from"./FilterBar-B4Mk2PvT.js";import{C as O}from"./ConfirmDeleteModal-D9_1b4MW.js";import{R as D}from"./RolePill-DHWixsQR.js";import{W as Z}from"./WorkflowPill-BtNBSplz.js";import{P as ee}from"./PageHeader-DJo7yMUR.js";import{t as te,ab as I,ad as $,aj as se,P as L,ak as re,al as W,y as ne,U as T,X as oe,i as ae,V as ie,C as le}from"./vendor-icons-DOIDKgo6.js";import{c as Q,e as ce,f as de}from"./vendor-react-CXumBFUA.js";import{u as ue}from"./roles-D4Wn7kE9.js";import{B as me}from"./BotPicker-B1RdaNuY.js";import{N as xe}from"./NamespacePill-SErKwgkb.js";import"./index-DwWP-Z_c.js";import"./Modal-CSrxpXeM.js";import"./bots-CWMN-KUI.js";function pe({tier:t}){return t==="certified"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-medium text-status-success",children:[e.jsx($,{className:"w-3 h-3"}),"Certified"]}):t==="registered"?e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-medium text-text-secondary",children:[e.jsx(ne,{className:"w-3 h-3"}),"Registered"]}):e.jsxs("span",{className:"inline-flex items-center gap-1 text-[10px] font-medium text-text-quaternary",children:[e.jsx(I,{className:"w-3 h-3"}),"Durable"]})}function Ue(){const t=Q(),{data:o,isLoading:u}=z(),x=U(),[c,g]=m.useState(""),[s,k]=m.useState(null),[j,v]=m.useState(null),l=o??[],f=m.useMemo(()=>[...new Set(l.map(a=>a.task_queue).filter(Boolean))].sort(),[l]),i=m.useMemo(()=>{const a=c.toLowerCase().trim();return(s?[s]:f).map(p=>({queue:p,workflows:l.filter(b=>{var h;return b.task_queue===p&&(!a||b.workflow_type.toLowerCase().includes(a)||((h=b.description)==null?void 0:h.toLowerCase().includes(a)))})})).filter(p=>p.workflows.length>0)},[l,f,c,s]),d=m.useMemo(()=>{const a=c.toLowerCase().trim();return s?[]:l.filter(w=>{var p;return!w.task_queue&&(!a||w.workflow_type.toLowerCase().includes(a)||((p=w.description)==null?void 0:p.toLowerCase().includes(a)))})},[l,c,s]),r=a=>{a.registered?t(`/workflows/registry/${encodeURIComponent(a.workflow_type)}`):t(`/workflows/registry/new?workflow_type=${encodeURIComponent(a.workflow_type)}&task_queue=${encodeURIComponent(a.task_queue??"")}`)},C=()=>{j&&x.mutate(j,{onSuccess:()=>v(null)})};return e.jsxs("div",{children:[e.jsx(ee,{title:"Registered Workflows",docsHash:"#docs:dashboard.md:workflow-registry",actions:e.jsx("button",{onClick:()=>t("/workflows/registry/new"),className:"btn-primary text-xs",children:"Register Workflow"})}),!u&&f.length>0&&e.jsxs(X,{children:[e.jsx(Y,{label:"Queue",value:s??"",onChange:a=>k(a||null),options:f.map(a=>({value:a,label:a}))}),e.jsx(G,{label:"Search",value:c,onChange:g,placeholder:`${l.length} workflows…`})]}),u?e.jsx(he,{}):i.length===0&&d.length===0?e.jsx("p",{className:"text-sm text-text-tertiary mt-8",children:c||s?"No workflows match your filter.":"No workflows discovered yet."}):e.jsxs("div",{className:"space-y-10",children:[i.map(({queue:a,workflows:w})=>e.jsxs("div",{children:[e.jsxs("div",{className:"sticky top-[60px] z-10 bg-surface flex items-center gap-2 py-2 mb-2 border-b border-surface-border",children:[e.jsx(te,{className:"w-3 h-3 text-accent",strokeWidth:1.5}),e.jsx("h2",{className:"section-h2",children:a}),e.jsx("span",{className:"text-xs text-text-quaternary",children:w.length})]}),e.jsx(E,{}),e.jsx("div",{className:"divide-y divide-surface-border/30",children:w.map(p=>e.jsx(F,{wf:p,onRowClick:r,onDelete:v,onNavigate:t},p.workflow_type))})]},a)),d.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"sticky top-[60px] z-10 bg-surface flex items-center gap-2 py-2 mb-2 border-b border-surface-border",children:[e.jsx(I,{className:"w-3 h-3 text-text-quaternary",strokeWidth:1.5}),e.jsx("h2",{className:"section-h2",children:"No Queue"}),e.jsx("span",{className:"text-xs text-text-quaternary",children:d.length})]}),e.jsx(E,{}),e.jsx("div",{className:"divide-y divide-surface-border/30",children:d.map(a=>e.jsx(F,{wf:a,onRowClick:r,onDelete:v,onNavigate:t},a.workflow_type))})]})]}),e.jsx(O,{open:!!j,onClose:()=>v(null),onConfirm:C,title:"Unregister Workflow",description:e.jsxs(e.Fragment,{children:["Delete the registration for"," ",e.jsx("span",{className:"font-mono font-medium text-text-primary",children:j}),"? This removes its invocation settings, certification, and interceptor treatment; the workflow keeps running as a plain durable workflow. To demote certified → registered instead, open the workflow and uncheck Certify — that keeps every setting."]}),isPending:x.isPending,error:x.error})]})}const J="grid grid-cols-[minmax(0,1fr)_7rem_13rem_4.5rem] gap-x-6";function E(){return e.jsxs("div",{className:`${J} px-3 pb-2 pt-1`,children:[e.jsx("span",{className:"text-[10px] font-medium text-text-quaternary",children:"Workflow"}),e.jsx("span",{className:"text-[10px] font-medium text-text-quaternary",children:"Tier"}),e.jsx("span",{className:"text-[10px] font-medium text-text-quaternary",children:"Access"}),e.jsx("span",{})]})}function F({wf:t,onRowClick:o,onDelete:u,onNavigate:x}){const c=t.roles??[],g=t.invocation_roles??[];return e.jsxs("div",{role:"button",tabIndex:0,onClick:()=>o(t),onKeyDown:s=>{(s.key==="Enter"||s.key===" ")&&o(t)},className:`group ${J} py-2 px-3 -mx-3 rounded-md cursor-pointer transition-colors items-center`,children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(Z,{type:t.workflow_type,size:"md",variant:t.tier==="certified"?"certified":t.tier==="registered"?"registered":"durable"}),t.description&&e.jsx("p",{className:"flex-1 min-w-0 truncate text-[10px] text-text-tertiary group-hover:text-text-secondary transition-colors",children:t.description})]}),e.jsx("div",{children:e.jsx(pe,{tier:t.tier??"durable"})}),e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 overflow-hidden whitespace-nowrap",children:[c.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{title:"Escalation roles",children:e.jsx($,{className:"w-3 h-3 text-text-quaternary shrink-0"})}),c.map(s=>e.jsx(D,{role:s},`e-${s}`))]}),g.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{title:"Invocation roles",children:e.jsx(se,{className:"w-3 h-3 text-text-quaternary shrink-0"})}),g.map(s=>e.jsx(D,{role:s},`i-${s}`))]}),c.length===0&&g.length===0&&e.jsx("span",{className:"text-xs text-text-quaternary",children:"—"})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[t.invocable&&e.jsx("button",{title:"Invoke workflow",onClick:s=>{s.stopPropagation(),x(`/workflows/start?type=${encodeURIComponent(t.workflow_type)}&mode=now`)},className:"text-text-quaternary hover:text-status-success transition-colors",children:e.jsx(L,{className:"w-3.5 h-3.5"})}),t.tier==="durable"&&e.jsx("button",{title:"Configure workflow",onClick:s=>{s.stopPropagation(),x(`/workflows/registry/new?workflow_type=${encodeURIComponent(t.workflow_type)}&task_queue=${encodeURIComponent(t.task_queue??"")}`)},className:"text-text-quaternary hover:text-status-info transition-colors",children:e.jsx(I,{className:"w-3.5 h-3.5"})}),t.tier==="registered"&&e.jsx("button",{title:"Certify workflow",onClick:s=>{s.stopPropagation(),x(`/workflows/registry/${encodeURIComponent(t.workflow_type)}`)},className:"text-text-quaternary hover:text-status-success transition-colors",children:e.jsx(re,{className:"w-3.5 h-3.5"})}),t.registered&&e.jsx("button",{title:"Unregister workflow",onClick:s=>{s.stopPropagation(),u(t.workflow_type)},className:"text-text-quaternary hover:text-status-warning transition-colors",children:e.jsx(W,{className:"w-3.5 h-3.5"})})]})]})}function he(){return e.jsx("div",{className:"animate-pulse space-y-8 mt-4",children:[1,2].map(t=>e.jsxs("div",{children:[e.jsx("div",{className:"h-4 bg-surface-sunken rounded w-36 mb-4"}),e.jsx("div",{className:"space-y-4",children:[1,2,3].map(o=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"h-3 bg-surface-sunken rounded w-48"}),e.jsx("div",{className:"h-3 bg-surface-sunken rounded w-full"})]},o))})]},t))})}function fe({selected:t,onChange:o,single:u,placeholder:x}){const{data:c}=ue(),g=(c==null?void 0:c.roles)??[],[s,k]=m.useState(!1),j=m.useRef(null);m.useEffect(()=>{const i=d=>{j.current&&!j.current.contains(d.target)&&k(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[]);const v=i=>{u?(o(t.includes(i)?[]:[i]),k(!1)):o(t.includes(i)?t.filter(d=>d!==i):[...t,i])},l=i=>{o(t.filter(d=>d!==i))},f=x??(u?"Select role...":"Add roles...");return e.jsxs("div",{ref:j,className:"relative",children:[e.jsxs("button",{type:"button",onClick:()=>k(!s),className:"flex flex-wrap items-center gap-1.5 w-full min-h-[34px] px-2 py-1.5 bg-surface-sunken border border-surface-border rounded-md text-left cursor-pointer hover:border-accent/40 transition-colors focus:ring-1 focus:ring-accent focus:outline-none",children:[t.length===0&&e.jsx("span",{className:"text-xs text-text-tertiary",children:f}),t.map(i=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-lg bg-accent/[0.08] text-text-secondary text-[11px]",children:[e.jsx(T,{className:"w-2.5 h-2.5 shrink-0 text-accent/75"}),i,e.jsx("span",{role:"button",onClick:d=>{d.stopPropagation(),l(i)},className:"ml-0.5 hover:text-status-error transition-colors",children:e.jsx(oe,{className:"w-2.5 h-2.5"})})]},i)),e.jsx(ae,{className:`w-3.5 h-3.5 ml-auto shrink-0 text-text-tertiary transition-transform ${s?"rotate-180":""}`})]}),s&&e.jsx("div",{className:"absolute z-20 mt-1 w-full bg-white border border-surface-border rounded-md shadow-lg max-h-48 overflow-y-auto",children:g.length===0?e.jsx("p",{className:"px-3 py-2 text-xs text-text-tertiary",children:"No roles defined"}):g.map(i=>{const d=t.includes(i);return e.jsxs("button",{type:"button",onClick:()=>v(i),className:`flex items-center gap-2 w-full px-3 py-1.5 text-left text-xs transition-colors ${d?"bg-accent/[0.06] text-accent":"text-text-primary hover:bg-surface-sunken"}`,children:[e.jsx(T,{className:"w-3 h-3 shrink-0 text-accent/60"}),e.jsx("span",{className:"flex-1",children:i}),d&&e.jsx(ie,{className:"w-3 h-3 shrink-0"})]},i)})})]})}function S(t){return t.split(",").map(o=>o.trim()).filter(Boolean)}const R={workflow_type:"",description:"",task_queue:"",default_role:"reviewer",invocable:!1,roles:"",invocation_roles:"",consumes:"",envelope_schema:"",resolver_schema:"",cron_schedule:"",execute_as:"",certified:!1};function we(t){const o=(t.roles??[]).join(", "),u=(t.consumes??[]).join(", ");return{workflow_type:t.workflow_type,description:t.description??"",task_queue:t.task_queue??"",default_role:t.default_role,invocable:t.invocable,roles:o,invocation_roles:(t.invocation_roles??[]).join(", "),consumes:u,envelope_schema:t.envelope_schema?JSON.stringify(t.envelope_schema,null,2):"",resolver_schema:t.resolver_schema?JSON.stringify(t.resolver_schema,null,2):"",cron_schedule:t.cron_schedule??"",execute_as:t.execute_as??"",certified:t.certified}}function q(t){if(!t.trim())return!0;try{return JSON.parse(t),!0}catch{return!1}}function P({icon:t,color:o,children:u}){return e.jsxs("div",{className:"flex items-center gap-2 mb-4 pb-2 border-b border-surface-border",children:[e.jsx(t,{className:`w-4 h-4 ${o}`,strokeWidth:1.5}),e.jsx("h2",{className:"section-h2",children:u})]})}function _({label:t,hint:o,children:u}){return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"label",children:t}),u,o&&e.jsx("p",{className:"hint",children:o})]})}const ge="input-json w-full";function je(t){return S(t)}function ke(t){return t.join(", ")}const ve=new Set(["mcpQuery","mcpDeterministic","mcpQueryRouter","mcpTriage","mcpTriageRouter","mcpTriageDeterministic","insightQuery"]);function Oe(){const{workflowType:t}=ce(),o=!t,u=Q(),[x]=de(),{data:c,isLoading:g}=H(),s=K(),k=U(),[j,v]=m.useState(!1),l=(c==null?void 0:c.find(n=>n.workflow_type===t))??null,{data:f}=V({limit:500}),i=m.useMemo(()=>{const n=new Set((c??[]).map(N=>N.workflow_type));return[...new Set(((f==null?void 0:f.jobs)??[]).map(N=>N.entity))].filter(N=>!n.has(N)&&!ve.has(N)).sort()},[c,f]),d=m.useMemo(()=>{if(!o)return R;const n=x.get("workflow_type")??"",y=x.get("task_queue")??"";return n||y?{...R,workflow_type:n,task_queue:y}:R},[o,x]),[r,C]=m.useState(d),[a,w]=m.useState(""),[p,b]=m.useState(!1),h=m.useCallback((n,y)=>C(N=>({...N,[n]:y})),[]);m.useEffect(()=>{if(!p){if(o){C(d),b(!0);return}l&&(C(we(l)),b(!0))}},[l,o,p,d]);const M=()=>{if(!r.workflow_type.trim())return;w("");let n=null,y=null;try{r.envelope_schema.trim()&&(n=JSON.parse(r.envelope_schema))}catch{w("Invalid JSON in Envelope Schema");return}try{r.resolver_schema.trim()&&(y=JSON.parse(r.resolver_schema))}catch{w("Invalid JSON in Resolver Schema");return}s.mutate({workflow_type:r.workflow_type.trim(),description:r.description.trim()||null,task_queue:r.task_queue.trim()||null,default_role:r.default_role.trim()||"reviewer",invocable:r.invocable,certified:r.certified,roles:S(r.roles),invocation_roles:S(r.invocation_roles),consumes:S(r.consumes),envelope_schema:n,resolver_schema:y,cron_schedule:r.cron_schedule.trim()||null,execute_as:r.execute_as.trim()||null},{onSuccess:()=>u("/workflows/registry")})};if(g)return e.jsxs("div",{className:"animate-pulse space-y-4",children:[e.jsx("div",{className:"h-8 bg-surface-sunken rounded w-64"}),e.jsx("div",{className:"h-40 bg-surface-sunken rounded"})]});if(!o&&!l)return e.jsx("p",{className:"text-sm text-text-secondary",children:"Config not found."});const A=!!r.workflow_type.trim()&&q(r.envelope_schema)&&q(r.resolver_schema),B=o&&!r.workflow_type&&i.length>0;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-start justify-between mb-8",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-light font-mono text-text-primary",children:o?"New Workflow":(l==null?void 0:l.workflow_type)??""}),l&&e.jsx("div",{className:"flex items-center gap-2 mt-2",children:e.jsx(xe,{namespace:"durable"})})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[e.jsx("button",{onClick:()=>u("/workflows/registry"),className:"btn-ghost text-xs",children:"Cancel"}),e.jsx("button",{onClick:M,disabled:!A||s.isPending,className:"btn-primary text-xs",children:s.isPending?"Saving…":o?"Register":"Save"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-x-14 gap-y-10",children:[e.jsxs("div",{children:[e.jsx(P,{icon:le,color:"text-accent",children:"Identity"}),e.jsxs("div",{className:"space-y-5",children:[e.jsx(_,{label:"Workflow Type",hint:"Register a workflow to configure invocation and HITL escalation routing.",children:B?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-text-secondary",children:"Select a durable workflow to register:"}),e.jsx("div",{className:"grid gap-1",children:i.map(n=>e.jsx("button",{onClick:()=>h("workflow_type",n),className:"flex items-center gap-2 px-3 py-2 text-left text-xs font-mono rounded-md border border-surface-border hover:border-accent/50 hover:bg-accent/[0.04] transition-colors",children:n},n))}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsx("span",{className:"text-[10px] text-text-tertiary",children:"or"}),e.jsx("input",{type:"text",onChange:n=>h("workflow_type",n.target.value),placeholder:"Enter type manually",className:"input font-mono flex-1"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",value:r.workflow_type,onChange:n=>h("workflow_type",n.target.value),disabled:!o,placeholder:"reviewContent",className:"input font-mono w-full"}),o&&r.workflow_type&&i.length>0&&e.jsx("button",{onClick:()=>h("workflow_type",""),className:"text-[10px] text-accent hover:underline mt-1",children:"Choose from durable workflows"})]})}),e.jsx(_,{label:"Description",children:e.jsx("input",{type:"text",value:r.description,onChange:n=>h("description",n.target.value),placeholder:"Describe what this workflow does",className:"input text-xs w-full"})}),e.jsx(_,{label:"Task Queue",hint:"Durable task queue this workflow listens on.",children:e.jsx("input",{type:"text",value:r.task_queue,onChange:n=>h("task_queue",n.target.value),placeholder:"lt-review",className:"input font-mono w-full"})})]})]}),e.jsxs("div",{children:[e.jsx(P,{icon:L,color:"text-accent",children:"Invocation"}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:r.invocable,onChange:n=>h("invocable",n.target.checked),className:"w-4 h-4 rounded border-border accent-accent"}),e.jsx("span",{className:"text-xs text-text-primary font-medium",children:"Invocable"})]}),e.jsx("p",{className:"hint",children:"Allow this workflow to be started from the dashboard or API."})]}),r.invocable?e.jsxs(e.Fragment,{children:[e.jsx(_,{label:"Run As",hint:"Bot identity to run under. Default runs as the invoking user.",children:e.jsx(me,{selected:r.execute_as,onChange:n=>h("execute_as",n)})}),e.jsx(_,{label:"Invocation Roles",hint:"Only users with these roles can start this workflow. Empty = all authenticated users.",children:e.jsx(fe,{selected:je(r.invocation_roles),onChange:n=>h("invocation_roles",ke(n)),placeholder:"Select roles…"})}),e.jsxs(_,{label:"Envelope Schema",hint:e.jsxs(e.Fragment,{children:["Pre-fills the JSON editor when invoking. Include ",e.jsx("code",{className:"font-mono",children:"data"})," (input) and optional ",e.jsx("code",{className:"font-mono",children:"metadata"}),"."]}),children:[e.jsx("textarea",{value:r.envelope_schema,onChange:n=>h("envelope_schema",n.target.value),placeholder:`{
2
+ "data": {},
3
+ "metadata": {}
4
+ }`,className:ge,rows:8,spellCheck:!1}),r.envelope_schema.trim()&&!q(r.envelope_schema)&&e.jsx("p",{className:"text-[10px] text-status-error mt-1",children:"Invalid JSON"})]})]}):e.jsxs("p",{className:"text-[11px] text-text-tertiary py-2",children:["Enable ",e.jsx("span",{className:"font-medium text-text-secondary",children:"Invocable"})," to configure invocation roles and an input template."]})]})]}),l&&e.jsxs("div",{children:[e.jsx(P,{icon:W,color:"text-text-tertiary",children:"Registration"}),e.jsxs("button",{onClick:()=>v(!0),className:"flex items-center gap-1.5 text-[11px] text-status-warning hover:underline",title:"Delete this registration — the workflow returns to plain durable",children:[e.jsx(W,{className:"w-3 h-3"})," Unregister workflow"]})]})]}),(a||s.error)&&e.jsx("p",{className:"text-xs text-status-error mt-8",children:a||s.error.message}),e.jsx(O,{open:j,onClose:()=>v(!1),onConfirm:()=>k.mutate(l.workflow_type,{onSuccess:()=>u("/workflows/registry")}),title:"Unregister Workflow",description:e.jsxs(e.Fragment,{children:["Delete the registration for"," ",e.jsx("span",{className:"font-mono font-medium text-text-primary",children:l==null?void 0:l.workflow_type}),"? This removes its invocation settings, certification, and interceptor treatment; the workflow keeps running as a plain durable workflow. Escalation schemas versioned on roles are untouched."]}),isPending:k.isPending,error:k.error})]})}export{Oe as WorkflowConfigDetailPage,Ue as WorkflowConfigsPage};
5
+ //# sourceMappingURL=index-Ex5tEte8.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-Ex5tEte8.js","sources":["../../src/pages/workflows/registry/WorkflowConfigsPage.tsx","../../src/components/common/form/RolePicker.tsx","../../src/lib/parse.ts","../../src/pages/workflows/registry/config-form-types.ts","../../src/pages/workflows/registry/WorkflowConfigDetailPage.tsx"],"sourcesContent":["import { useState, useMemo } from 'react';\nimport { useNavigate } from 'react-router-dom';\nimport {\n useDiscoveredWorkflows,\n useDeleteWorkflowConfig,\n} from '../../../api/workflows';\nimport {\n Server,\n ShieldCheck, ShieldPlus, ShieldOff, Settings, Wrench, Play, UserCheck,\n} from 'lucide-react';\nimport { FilterBar, FilterSelect, FilterInput } from '../../../components/common/data/FilterBar';\nimport { ConfirmDeleteModal } from '../../../components/common/modal/ConfirmDeleteModal';\nimport { RolePill } from '../../../components/common/display/RolePill';\nimport { WorkflowPill } from '../../../components/common/display/WorkflowPill';\nimport { PageHeader } from '../../../components/common/layout/PageHeader';\nimport type { DiscoveredWorkflow } from '../../../api/types';\n\n// ── Tier badge ─────────────────────────────────────────────────────────────────\n\nfunction TierBadge({ tier }: { tier: string }) {\n if (tier === 'certified')\n return <span className=\"inline-flex items-center gap-1 text-[10px] font-medium text-status-success\"><ShieldCheck className=\"w-3 h-3\" />Certified</span>;\n if (tier === 'registered')\n return <span className=\"inline-flex items-center gap-1 text-[10px] font-medium text-text-secondary\"><Settings className=\"w-3 h-3\" />Registered</span>;\n return <span className=\"inline-flex items-center gap-1 text-[10px] font-medium text-text-quaternary\"><Wrench className=\"w-3 h-3\" />Durable</span>;\n}\n\n// ── Page ──────────────────────────────────────────────────────────────────────\n\nexport function WorkflowConfigsPage() {\n const navigate = useNavigate();\n const { data, isLoading } = useDiscoveredWorkflows();\n const deleteConfig = useDeleteWorkflowConfig();\n\n const [search, setSearch] = useState('');\n const [activeQueue, setActiveQueue] = useState<string | null>(null);\n const [confirmDelete, setConfirmDelete] = useState<string | null>(null);\n\n const allWorkflows: DiscoveredWorkflow[] = data ?? [];\n\n const queues = useMemo(\n () => [...new Set(allWorkflows.map((w) => w.task_queue).filter(Boolean) as string[])].sort(),\n [allWorkflows],\n );\n\n const grouped = useMemo(() => {\n const q = search.toLowerCase().trim();\n const targetQueues = activeQueue ? [activeQueue] : queues;\n return targetQueues\n .map((queue) => ({\n queue,\n workflows: allWorkflows.filter(\n (w) =>\n w.task_queue === queue &&\n (!q ||\n w.workflow_type.toLowerCase().includes(q) ||\n w.description?.toLowerCase().includes(q)),\n ),\n }))\n .filter((g) => g.workflows.length > 0);\n }, [allWorkflows, queues, search, activeQueue]);\n\n // Workflows with no queue\n const ungrouped = useMemo(() => {\n const q = search.toLowerCase().trim();\n if (activeQueue) return [];\n return allWorkflows.filter(\n (w) =>\n !w.task_queue &&\n (!q || w.workflow_type.toLowerCase().includes(q) || w.description?.toLowerCase().includes(q)),\n );\n }, [allWorkflows, search, activeQueue]);\n\n const handleRowClick = (row: DiscoveredWorkflow) => {\n if (row.registered) {\n navigate(`/workflows/registry/${encodeURIComponent(row.workflow_type)}`);\n } else {\n navigate(`/workflows/registry/new?workflow_type=${encodeURIComponent(row.workflow_type)}&task_queue=${encodeURIComponent(row.task_queue ?? '')}`);\n }\n };\n\n const handleDelete = () => {\n if (!confirmDelete) return;\n deleteConfig.mutate(confirmDelete, { onSuccess: () => setConfirmDelete(null) });\n };\n\n return (\n <div>\n <PageHeader\n title=\"Registered Workflows\"\n docsHash=\"#docs:dashboard.md:workflow-registry\"\n actions={\n <button onClick={() => navigate('/workflows/registry/new')} className=\"btn-primary text-xs\">\n Register Workflow\n </button>\n }\n />\n\n {/* Sticky filter bar: queue select + search */}\n {!isLoading && queues.length > 0 && (\n <FilterBar>\n <FilterSelect\n label=\"Queue\"\n value={activeQueue ?? ''}\n onChange={(v) => setActiveQueue(v || null)}\n options={queues.map((q) => ({ value: q, label: q }))}\n />\n <FilterInput\n label=\"Search\"\n value={search}\n onChange={setSearch}\n placeholder={`${allWorkflows.length} workflows…`}\n />\n </FilterBar>\n )}\n\n {/* Content */}\n {isLoading ? (\n <LoadingSkeleton />\n ) : grouped.length === 0 && ungrouped.length === 0 ? (\n <p className=\"text-sm text-text-tertiary mt-8\">\n {search || activeQueue ? 'No workflows match your filter.' : 'No workflows discovered yet.'}\n </p>\n ) : (\n <div className=\"space-y-10\">\n {grouped.map(({ queue, workflows }) => (\n <div key={queue}>\n <div className=\"sticky top-[60px] z-10 bg-surface flex items-center gap-2 py-2 mb-2 border-b border-surface-border\">\n <Server className=\"w-3 h-3 text-accent\" strokeWidth={1.5} />\n <h2 className=\"section-h2\">{queue}</h2>\n <span className=\"text-xs text-text-quaternary\">{workflows.length}</span>\n </div>\n <WorkflowTableHeader />\n <div className=\"divide-y divide-surface-border/30\">\n {workflows.map((wf) => (\n <WorkflowRow\n key={wf.workflow_type}\n wf={wf}\n onRowClick={handleRowClick}\n onDelete={setConfirmDelete}\n onNavigate={navigate}\n />\n ))}\n </div>\n </div>\n ))}\n\n {ungrouped.length > 0 && (\n <div>\n <div className=\"sticky top-[60px] z-10 bg-surface flex items-center gap-2 py-2 mb-2 border-b border-surface-border\">\n <Wrench className=\"w-3 h-3 text-text-quaternary\" strokeWidth={1.5} />\n <h2 className=\"section-h2\">No Queue</h2>\n <span className=\"text-xs text-text-quaternary\">{ungrouped.length}</span>\n </div>\n <WorkflowTableHeader />\n <div className=\"divide-y divide-surface-border/30\">\n {ungrouped.map((wf) => (\n <WorkflowRow\n key={wf.workflow_type}\n wf={wf}\n onRowClick={handleRowClick}\n onDelete={setConfirmDelete}\n onNavigate={navigate}\n />\n ))}\n </div>\n </div>\n )}\n </div>\n )}\n\n <ConfirmDeleteModal\n open={!!confirmDelete}\n onClose={() => setConfirmDelete(null)}\n onConfirm={handleDelete}\n title=\"Unregister Workflow\"\n description={\n <>\n Delete the registration for{' '}\n <span className=\"font-mono font-medium text-text-primary\">{confirmDelete}</span>? This\n removes its invocation settings, certification, and interceptor treatment; the workflow\n keeps running as a plain durable workflow. To demote certified → registered instead,\n open the workflow and uncheck Certify — that keeps every setting.\n </>\n }\n isPending={deleteConfig.isPending}\n error={deleteConfig.error as Error | null}\n />\n </div>\n );\n}\n\n// ── Column layout ─────────────────────────────────────────────────────────────\n// [Workflow 1fr] [Tier 7rem] [Access 13rem] [Actions 4.5rem]\nconst ROW_GRID = 'grid grid-cols-[minmax(0,1fr)_7rem_13rem_4.5rem] gap-x-6';\n\nfunction WorkflowTableHeader() {\n return (\n <div className={`${ROW_GRID} px-3 pb-2 pt-1`}>\n <span className=\"text-[10px] font-medium text-text-quaternary\">Workflow</span>\n <span className=\"text-[10px] font-medium text-text-quaternary\">Tier</span>\n <span className=\"text-[10px] font-medium text-text-quaternary\">Access</span>\n <span />\n </div>\n );\n}\n\n// ── Workflow row ───────────────────────────────────────────────────────────────\n\nfunction WorkflowRow({\n wf,\n onRowClick,\n onDelete,\n onNavigate,\n}: {\n wf: DiscoveredWorkflow;\n onRowClick: (wf: DiscoveredWorkflow) => void;\n onDelete: (type: string) => void;\n onNavigate: (path: string) => void;\n}) {\n const escRoles = wf.roles ?? [];\n const invokeRoles = wf.invocation_roles ?? [];\n\n return (\n <div\n role=\"button\"\n tabIndex={0}\n onClick={() => onRowClick(wf)}\n onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') onRowClick(wf); }}\n className={`group ${ROW_GRID} py-2 px-3 -mx-3 rounded-md cursor-pointer transition-colors items-center`}\n >\n {/* Col 1: Workflow name + description, single line */}\n <div className=\"flex items-center gap-3 min-w-0\">\n <WorkflowPill\n type={wf.workflow_type}\n size=\"md\"\n variant={wf.tier === 'certified' ? 'certified' : wf.tier === 'registered' ? 'registered' : 'durable'}\n />\n {wf.description && (\n <p className=\"flex-1 min-w-0 truncate text-[10px] text-text-tertiary group-hover:text-text-secondary transition-colors\">\n {wf.description}\n </p>\n )}\n </div>\n\n {/* Col 2: Tier */}\n <div>\n <TierBadge tier={wf.tier ?? 'durable'} />\n </div>\n\n {/* Col 3: Access — escalation + invocation roles, single line */}\n <div className=\"flex items-center gap-1.5 min-w-0 overflow-hidden whitespace-nowrap\">\n {escRoles.length > 0 && (\n <>\n <span title=\"Escalation roles\"><ShieldCheck className=\"w-3 h-3 text-text-quaternary shrink-0\" /></span>\n {escRoles.map((r) => <RolePill key={`e-${r}`} role={r} />)}\n </>\n )}\n {invokeRoles.length > 0 && (\n <>\n <span title=\"Invocation roles\"><UserCheck className=\"w-3 h-3 text-text-quaternary shrink-0\" /></span>\n {invokeRoles.map((r) => <RolePill key={`i-${r}`} role={r} />)}\n </>\n )}\n {escRoles.length === 0 && invokeRoles.length === 0 && (\n <span className=\"text-xs text-text-quaternary\">—</span>\n )}\n </div>\n\n {/* Col 4: Actions — revealed on hover */}\n <div className=\"flex items-center justify-end gap-2.5 opacity-0 group-hover:opacity-100 transition-opacity\">\n {wf.invocable && (\n <button\n title=\"Invoke workflow\"\n onClick={(e) => { e.stopPropagation(); onNavigate(`/workflows/start?type=${encodeURIComponent(wf.workflow_type)}&mode=now`); }}\n className=\"text-text-quaternary hover:text-status-success transition-colors\"\n >\n <Play className=\"w-3.5 h-3.5\" />\n </button>\n )}\n {wf.tier === 'durable' && (\n <button\n title=\"Configure workflow\"\n onClick={(e) => { e.stopPropagation(); onNavigate(`/workflows/registry/new?workflow_type=${encodeURIComponent(wf.workflow_type)}&task_queue=${encodeURIComponent(wf.task_queue ?? '')}`); }}\n className=\"text-text-quaternary hover:text-status-info transition-colors\"\n >\n <Wrench className=\"w-3.5 h-3.5\" />\n </button>\n )}\n {wf.tier === 'registered' && (\n <button\n title=\"Certify workflow\"\n onClick={(e) => { e.stopPropagation(); onNavigate(`/workflows/registry/${encodeURIComponent(wf.workflow_type)}`); }}\n className=\"text-text-quaternary hover:text-status-success transition-colors\"\n >\n <ShieldPlus className=\"w-3.5 h-3.5\" />\n </button>\n )}\n {wf.registered && (\n <button\n title=\"Unregister workflow\"\n onClick={(e) => { e.stopPropagation(); onDelete(wf.workflow_type); }}\n className=\"text-text-quaternary hover:text-status-warning transition-colors\"\n >\n <ShieldOff className=\"w-3.5 h-3.5\" />\n </button>\n )}\n </div>\n </div>\n );\n}\n\n// ── Loading skeleton ───────────────────────────────────────────────────────────\n\nfunction LoadingSkeleton() {\n return (\n <div className=\"animate-pulse space-y-8 mt-4\">\n {[1, 2].map((i) => (\n <div key={i}>\n <div className=\"h-4 bg-surface-sunken rounded w-36 mb-4\" />\n <div className=\"space-y-4\">\n {[1, 2, 3].map((j) => (\n <div key={j} className=\"space-y-1.5\">\n <div className=\"h-3 bg-surface-sunken rounded w-48\" />\n <div className=\"h-3 bg-surface-sunken rounded w-full\" />\n </div>\n ))}\n </div>\n </div>\n ))}\n </div>\n );\n}\n","import { useState, useRef, useEffect } from 'react';\nimport { User, X, ChevronDown, Check } from 'lucide-react';\nimport { useRoles } from '../../../api/roles';\n\ninterface RolePickerProps {\n selected: string[];\n onChange: (roles: string[]) => void;\n /** Only allow one selection */\n single?: boolean;\n placeholder?: string;\n}\n\nexport function RolePicker({ selected, onChange, single, placeholder }: RolePickerProps) {\n const { data } = useRoles();\n const allRoles = data?.roles ?? [];\n const [open, setOpen] = useState(false);\n const ref = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const handler = (e: MouseEvent) => {\n if (ref.current && !ref.current.contains(e.target as Node)) setOpen(false);\n };\n document.addEventListener('mousedown', handler);\n return () => document.removeEventListener('mousedown', handler);\n }, []);\n\n const toggle = (role: string) => {\n if (single) {\n onChange(selected.includes(role) ? [] : [role]);\n setOpen(false);\n } else {\n onChange(\n selected.includes(role)\n ? selected.filter((r) => r !== role)\n : [...selected, role],\n );\n }\n };\n\n const remove = (role: string) => {\n onChange(selected.filter((r) => r !== role));\n };\n\n const placeholderText = placeholder ?? (single ? 'Select role...' : 'Add roles...');\n\n return (\n <div ref={ref} className=\"relative\">\n {/* Selected pills + trigger */}\n <button\n type=\"button\"\n onClick={() => setOpen(!open)}\n className=\"flex flex-wrap items-center gap-1.5 w-full min-h-[34px] px-2 py-1.5 bg-surface-sunken border border-surface-border rounded-md text-left cursor-pointer hover:border-accent/40 transition-colors focus:ring-1 focus:ring-accent focus:outline-none\"\n >\n {selected.length === 0 && (\n <span className=\"text-xs text-text-tertiary\">{placeholderText}</span>\n )}\n {selected.map((role) => (\n <span\n key={role}\n className=\"inline-flex items-center gap-1 px-2 py-0.5 rounded-lg bg-accent/[0.08] text-text-secondary text-[11px]\"\n >\n <User className=\"w-2.5 h-2.5 shrink-0 text-accent/75\" />\n {role}\n <span\n role=\"button\"\n onClick={(e) => { e.stopPropagation(); remove(role); }}\n className=\"ml-0.5 hover:text-status-error transition-colors\"\n >\n <X className=\"w-2.5 h-2.5\" />\n </span>\n </span>\n ))}\n <ChevronDown className={`w-3.5 h-3.5 ml-auto shrink-0 text-text-tertiary transition-transform ${open ? 'rotate-180' : ''}`} />\n </button>\n\n {/* Dropdown */}\n {open && (\n <div className=\"absolute z-20 mt-1 w-full bg-white border border-surface-border rounded-md shadow-lg max-h-48 overflow-y-auto\">\n {allRoles.length === 0 ? (\n <p className=\"px-3 py-2 text-xs text-text-tertiary\">No roles defined</p>\n ) : (\n allRoles.map((role) => {\n const isSelected = selected.includes(role);\n return (\n <button\n key={role}\n type=\"button\"\n onClick={() => toggle(role)}\n className={`flex items-center gap-2 w-full px-3 py-1.5 text-left text-xs transition-colors ${\n isSelected\n ? 'bg-accent/[0.06] text-accent'\n : 'text-text-primary hover:bg-surface-sunken'\n }`}\n >\n <User className=\"w-3 h-3 shrink-0 text-accent/60\" />\n <span className=\"flex-1\">{role}</span>\n {isSelected && <Check className=\"w-3 h-3 shrink-0\" />}\n </button>\n );\n })\n )}\n </div>\n )}\n </div>\n );\n}\n","export function splitCsv(s: string): string[] {\n return s\n .split(',')\n .map((v) => v.trim())\n .filter(Boolean);\n}\n\nexport function safeParseJson<T = unknown>(\n json: string,\n): { ok: true; data: T } | { ok: false; error: string } {\n try {\n return { ok: true, data: JSON.parse(json) as T };\n } catch (e: unknown) {\n const message = e instanceof Error ? e.message : 'Invalid JSON';\n return { ok: false, error: message };\n }\n}\n","import type { LTWorkflowConfig } from '../../../api/types';\n\nexport interface ConfigFormState {\n workflow_type: string;\n description: string;\n task_queue: string;\n default_role: string;\n invocable: boolean;\n roles: string;\n invocation_roles: string;\n consumes: string;\n envelope_schema: string;\n resolver_schema: string;\n cron_schedule: string;\n execute_as: string;\n /**\n * Explicit HITL certification, persisted on the registration. Unchecking\n * demotes certified → registered on save and keeps roles/consumes intact.\n */\n certified: boolean;\n}\n\nexport const EMPTY_FORM: ConfigFormState = {\n workflow_type: '',\n description: '',\n task_queue: '',\n default_role: 'reviewer',\n invocable: false,\n roles: '',\n invocation_roles: '',\n consumes: '',\n envelope_schema: '',\n resolver_schema: '',\n cron_schedule: '',\n execute_as: '',\n certified: false,\n};\n\nexport function configToForm(c: LTWorkflowConfig): ConfigFormState {\n const roles = (c.roles ?? []).join(', ');\n const consumes = (c.consumes ?? []).join(', ');\n return {\n workflow_type: c.workflow_type,\n description: c.description ?? '',\n task_queue: c.task_queue ?? '',\n default_role: c.default_role,\n invocable: c.invocable,\n roles,\n invocation_roles: (c.invocation_roles ?? []).join(', '),\n consumes,\n envelope_schema: c.envelope_schema ? JSON.stringify(c.envelope_schema, null, 2) : '',\n resolver_schema: c.resolver_schema ? JSON.stringify(c.resolver_schema, null, 2) : '',\n cron_schedule: c.cron_schedule ?? '',\n execute_as: c.execute_as ?? '',\n certified: c.certified,\n };\n}\n\nexport const STEP_LABELS = ['Identity', 'Invocation', 'Advanced'];\n\nexport function jsonValid(v: string): boolean {\n if (!v.trim()) return true;\n try { JSON.parse(v); return true; } catch { return false; }\n}\n\nexport function isStepValid(step: number, form: ConfigFormState): boolean {\n if (step === 1) return !!form.workflow_type.trim();\n if (step === 2) return jsonValid(form.envelope_schema);\n if (step === 3) return jsonValid(form.resolver_schema);\n return true;\n}\n\nexport const labelCls = 'label';\nexport const hintCls = 'hint';\nexport const jsonCls = 'input-json w-full';\n\nexport const DEFAULT_ENVELOPE = '{\\n \"data\": {},\\n \"metadata\": {}\\n}';\n","import { useState, useEffect, useCallback, useMemo } from 'react';\nimport { useParams, useNavigate, useSearchParams } from 'react-router-dom';\nimport {\n Code2, Play, ShieldOff,\n} from 'lucide-react';\nimport { useWorkflowConfigs, useUpsertWorkflowConfig, useDeleteWorkflowConfig, useJobs } from '../../../api/workflows';\nimport { ConfirmDeleteModal } from '../../../components/common/modal/ConfirmDeleteModal';\nimport { RolePicker } from '../../../components/common/form/RolePicker';\nimport { BotPicker } from '../../../components/common/form/BotPicker';\nimport { NamespacePill } from '../../../components/common/display/NamespacePill';\nimport { splitCsv } from '../../../lib/parse';\nimport { EMPTY_FORM, configToForm, jsonValid } from './config-form-types';\nimport type { ConfigFormState } from './config-form-types';\n\n// ── Local helpers ─────────────────────────────────────────────────────────────\n\nfunction SectionHeader({ icon: Icon, color, children }: { icon: React.ElementType; color: string; children: React.ReactNode }) {\n return (\n <div className=\"flex items-center gap-2 mb-4 pb-2 border-b border-surface-border\">\n <Icon className={`w-4 h-4 ${color}`} strokeWidth={1.5} />\n <h2 className=\"section-h2\">{children}</h2>\n </div>\n );\n}\n\nfunction Field({ label, hint, children }: { label: string; hint?: React.ReactNode; children: React.ReactNode }) {\n return (\n <div className=\"space-y-1.5\">\n <label className=\"label\">{label}</label>\n {children}\n {hint && <p className=\"hint\">{hint}</p>}\n </div>\n );\n}\n\nconst jsonCls = 'input-json w-full';\n\nfunction csvToArray(csv: string): string[] { return splitCsv(csv); }\nfunction arrayToCsv(arr: string[]): string { return arr.join(', '); }\n\nconst SYSTEM_WORKFLOWS = new Set([\n 'mcpQuery', 'mcpDeterministic', 'mcpQueryRouter', 'mcpTriage',\n 'mcpTriageRouter', 'mcpTriageDeterministic', 'insightQuery',\n]);\n\n// ── Page ─────────────────────────────────────────────────────────────────────\n\nexport function WorkflowConfigDetailPage() {\n const { workflowType } = useParams<{ workflowType: string }>();\n const isNew = !workflowType;\n const navigate = useNavigate();\n const [searchParams] = useSearchParams();\n const { data: configs, isLoading } = useWorkflowConfigs();\n const upsert = useUpsertWorkflowConfig();\n const deleteConfig = useDeleteWorkflowConfig();\n const [confirmUnregister, setConfirmUnregister] = useState(false);\n\n const editing = configs?.find((c) => c.workflow_type === workflowType) ?? null;\n\n const { data: jobsData } = useJobs({ limit: 500 });\n const unregisteredTypes = useMemo(() => {\n const registeredSet = new Set((configs ?? []).map((c) => c.workflow_type));\n const allEntities = new Set((jobsData?.jobs ?? []).map((j: any) => j.entity));\n return [...allEntities]\n .filter((e: string) => !registeredSet.has(e) && !SYSTEM_WORKFLOWS.has(e))\n .sort();\n }, [configs, jobsData]);\n\n const prefillForm = useMemo((): ConfigFormState => {\n if (!isNew) return EMPTY_FORM;\n const prefillType = searchParams.get('workflow_type') ?? '';\n const prefillQueue = searchParams.get('task_queue') ?? '';\n return prefillType || prefillQueue\n ? { ...EMPTY_FORM, workflow_type: prefillType, task_queue: prefillQueue }\n : EMPTY_FORM;\n }, [isNew, searchParams]);\n\n const [form, setForm] = useState<ConfigFormState>(prefillForm);\n const [schemaError, setSchemaError] = useState('');\n const [initialized, setInitialized] = useState(false);\n\n const set = useCallback(\n (field: keyof ConfigFormState, value: string | boolean) =>\n setForm((f) => ({ ...f, [field]: value })),\n [],\n );\n\n useEffect(() => {\n if (initialized) return;\n if (isNew) { setForm(prefillForm); setInitialized(true); return; }\n if (editing) { setForm(configToForm(editing)); setInitialized(true); }\n }, [editing, isNew, initialized, prefillForm]);\n\n const handleSave = () => {\n if (!form.workflow_type.trim()) return;\n setSchemaError('');\n\n let envelope_schema: Record<string, unknown> | null = null;\n let resolver_schema: Record<string, unknown> | null = null;\n try {\n if (form.envelope_schema.trim()) envelope_schema = JSON.parse(form.envelope_schema);\n } catch { setSchemaError('Invalid JSON in Envelope Schema'); return; }\n try {\n if (form.resolver_schema.trim()) resolver_schema = JSON.parse(form.resolver_schema);\n } catch { setSchemaError('Invalid JSON in Resolver Schema'); return; }\n\n upsert.mutate(\n {\n workflow_type: form.workflow_type.trim(),\n description: form.description.trim() || null,\n task_queue: form.task_queue.trim() || null,\n default_role: form.default_role.trim() || 'reviewer',\n invocable: form.invocable,\n certified: form.certified,\n roles: splitCsv(form.roles),\n invocation_roles: splitCsv(form.invocation_roles),\n consumes: splitCsv(form.consumes),\n envelope_schema,\n resolver_schema,\n cron_schedule: form.cron_schedule.trim() || null,\n execute_as: form.execute_as.trim() || null,\n },\n { onSuccess: () => navigate('/workflows/registry') },\n );\n };\n\n if (isLoading) {\n return (\n <div className=\"animate-pulse space-y-4\">\n <div className=\"h-8 bg-surface-sunken rounded w-64\" />\n <div className=\"h-40 bg-surface-sunken rounded\" />\n </div>\n );\n }\n if (!isNew && !editing) {\n return <p className=\"text-sm text-text-secondary\">Config not found.</p>;\n }\n\n const canSave = !!form.workflow_type.trim() && jsonValid(form.envelope_schema) && jsonValid(form.resolver_schema);\n const showPickList = isNew && !form.workflow_type && unregisteredTypes.length > 0;\n\n return (\n <div>\n {/* Hero */}\n <div className=\"flex items-start justify-between mb-8\">\n <div>\n <h1 className=\"text-3xl font-light font-mono text-text-primary\">\n {isNew ? 'New Workflow' : editing?.workflow_type ?? ''}\n </h1>\n {editing && (\n <div className=\"flex items-center gap-2 mt-2\">\n <NamespacePill namespace=\"durable\" />\n </div>\n )}\n </div>\n <div className=\"flex items-center gap-3 mt-1\">\n <button onClick={() => navigate('/workflows/registry')} className=\"btn-ghost text-xs\">\n Cancel\n </button>\n <button\n onClick={handleSave}\n disabled={!canSave || upsert.isPending}\n className=\"btn-primary text-xs\"\n >\n {upsert.isPending ? 'Saving…' : isNew ? 'Register' : 'Save'}\n </button>\n </div>\n </div>\n\n {/* Three-column form */}\n <div className=\"grid grid-cols-1 lg:grid-cols-3 gap-x-14 gap-y-10\">\n\n {/* ── Identity ─────────────────────────────────────────────────── */}\n <div>\n <SectionHeader icon={Code2} color=\"text-accent\">Identity</SectionHeader>\n <div className=\"space-y-5\">\n <Field\n label=\"Workflow Type\"\n hint=\"Register a workflow to configure invocation and HITL escalation routing.\"\n >\n {showPickList ? (\n <div className=\"space-y-2\">\n <p className=\"text-xs text-text-secondary\">Select a durable workflow to register:</p>\n <div className=\"grid gap-1\">\n {(unregisteredTypes as string[]).map((type) => (\n <button\n key={type}\n onClick={() => set('workflow_type', type)}\n className=\"flex items-center gap-2 px-3 py-2 text-left text-xs font-mono rounded-md border border-surface-border hover:border-accent/50 hover:bg-accent/[0.04] transition-colors\"\n >\n {type}\n </button>\n ))}\n </div>\n <div className=\"flex items-center gap-2 pt-1\">\n <span className=\"text-[10px] text-text-tertiary\">or</span>\n <input\n type=\"text\"\n onChange={(e) => set('workflow_type', e.target.value)}\n placeholder=\"Enter type manually\"\n className=\"input font-mono flex-1\"\n />\n </div>\n </div>\n ) : (\n <>\n <input\n type=\"text\"\n value={form.workflow_type}\n onChange={(e) => set('workflow_type', e.target.value)}\n disabled={!isNew}\n placeholder=\"reviewContent\"\n className=\"input font-mono w-full\"\n />\n {isNew && form.workflow_type && unregisteredTypes.length > 0 && (\n <button\n onClick={() => set('workflow_type', '')}\n className=\"text-[10px] text-accent hover:underline mt-1\"\n >\n Choose from durable workflows\n </button>\n )}\n </>\n )}\n </Field>\n\n <Field label=\"Description\">\n <input\n type=\"text\"\n value={form.description}\n onChange={(e) => set('description', e.target.value)}\n placeholder=\"Describe what this workflow does\"\n className=\"input text-xs w-full\"\n />\n </Field>\n\n <Field label=\"Task Queue\" hint=\"Durable task queue this workflow listens on.\">\n <input\n type=\"text\"\n value={form.task_queue}\n onChange={(e) => set('task_queue', e.target.value)}\n placeholder=\"lt-review\"\n className=\"input font-mono w-full\"\n />\n </Field>\n </div>\n </div>\n\n {/* ── Invocation ───────────────────────────────────────────────── */}\n <div>\n <SectionHeader icon={Play} color=\"text-accent\">Invocation</SectionHeader>\n <div className=\"space-y-5\">\n <div className=\"space-y-1\">\n <label className=\"flex items-center gap-2 cursor-pointer\">\n <input\n type=\"checkbox\"\n checked={form.invocable}\n onChange={(e) => set('invocable', e.target.checked)}\n className=\"w-4 h-4 rounded border-border accent-accent\"\n />\n <span className=\"text-xs text-text-primary font-medium\">Invocable</span>\n </label>\n <p className=\"hint\">Allow this workflow to be started from the dashboard or API.</p>\n </div>\n\n {form.invocable ? (\n <>\n <Field label=\"Run As\" hint=\"Bot identity to run under. Default runs as the invoking user.\">\n <BotPicker selected={form.execute_as} onChange={(id) => set('execute_as', id)} />\n </Field>\n\n <Field label=\"Invocation Roles\" hint=\"Only users with these roles can start this workflow. Empty = all authenticated users.\">\n <RolePicker\n selected={csvToArray(form.invocation_roles)}\n onChange={(roles) => set('invocation_roles', arrayToCsv(roles))}\n placeholder=\"Select roles…\"\n />\n </Field>\n\n <Field label=\"Envelope Schema\" hint={<>Pre-fills the JSON editor when invoking. Include <code className=\"font-mono\">data</code> (input) and optional <code className=\"font-mono\">metadata</code>.</>}>\n <textarea\n value={form.envelope_schema}\n onChange={(e) => set('envelope_schema', e.target.value)}\n placeholder={'{\\n \"data\": {},\\n \"metadata\": {}\\n}'}\n className={jsonCls}\n rows={8}\n spellCheck={false}\n />\n {form.envelope_schema.trim() && !jsonValid(form.envelope_schema) && (\n <p className=\"text-[10px] text-status-error mt-1\">Invalid JSON</p>\n )}\n </Field>\n </>\n ) : (\n <p className=\"text-[11px] text-text-tertiary py-2\">\n Enable <span className=\"font-medium text-text-secondary\">Invocable</span> to configure invocation roles and an input template.\n </p>\n )}\n </div>\n </div>\n\n {/* Escalation & resolution config is ROLE-owned now — a workflow no longer\n declares a resolver schema or a certification tier here. The escalation\n surface (form_schema + resolver_schema, versioned) lives on the target\n role. This section is intentionally hidden from the workflow view. */}\n {editing && (\n <div>\n <SectionHeader icon={ShieldOff} color=\"text-text-tertiary\">Registration</SectionHeader>\n <button\n onClick={() => setConfirmUnregister(true)}\n className=\"flex items-center gap-1.5 text-[11px] text-status-warning hover:underline\"\n title=\"Delete this registration — the workflow returns to plain durable\"\n >\n <ShieldOff className=\"w-3 h-3\" /> Unregister workflow\n </button>\n </div>\n )}\n </div>\n\n {(schemaError || upsert.error) && (\n <p className=\"text-xs text-status-error mt-8\">\n {schemaError || (upsert.error as Error).message}\n </p>\n )}\n\n <ConfirmDeleteModal\n open={confirmUnregister}\n onClose={() => setConfirmUnregister(false)}\n onConfirm={() =>\n deleteConfig.mutate(editing!.workflow_type, {\n onSuccess: () => navigate('/workflows/registry'),\n })\n }\n title=\"Unregister Workflow\"\n description={\n <>\n Delete the registration for{' '}\n <span className=\"font-mono font-medium text-text-primary\">{editing?.workflow_type}</span>?\n This removes its invocation settings, certification, and interceptor treatment; the\n workflow keeps running as a plain durable workflow. Escalation schemas versioned on\n roles are untouched.\n </>\n }\n isPending={deleteConfig.isPending}\n error={deleteConfig.error as Error | null}\n />\n </div>\n );\n}\n"],"names":["TierBadge","tier","jsxs","jsx","ShieldCheck","Settings","Wrench","WorkflowConfigsPage","navigate","useNavigate","data","isLoading","useDiscoveredWorkflows","deleteConfig","useDeleteWorkflowConfig","search","setSearch","useState","activeQueue","setActiveQueue","confirmDelete","setConfirmDelete","allWorkflows","queues","useMemo","w","grouped","q","queue","_a","g","ungrouped","handleRowClick","row","handleDelete","PageHeader","FilterBar","FilterSelect","v","FilterInput","LoadingSkeleton","workflows","Server","WorkflowTableHeader","wf","WorkflowRow","ConfirmDeleteModal","Fragment","ROW_GRID","onRowClick","onDelete","onNavigate","escRoles","invokeRoles","e","WorkflowPill","r","RolePill","UserCheck","Play","ShieldPlus","ShieldOff","i","j","RolePicker","selected","onChange","single","placeholder","useRoles","allRoles","open","setOpen","ref","useRef","useEffect","handler","toggle","role","remove","placeholderText","User","X","ChevronDown","isSelected","Check","splitCsv","s","EMPTY_FORM","configToForm","c","roles","consumes","jsonValid","SectionHeader","Icon","color","children","Field","label","hint","jsonCls","csvToArray","csv","arrayToCsv","arr","SYSTEM_WORKFLOWS","WorkflowConfigDetailPage","workflowType","useParams","isNew","searchParams","useSearchParams","configs","useWorkflowConfigs","upsert","useUpsertWorkflowConfig","confirmUnregister","setConfirmUnregister","editing","jobsData","useJobs","unregisteredTypes","registeredSet","prefillForm","prefillType","prefillQueue","form","setForm","schemaError","setSchemaError","initialized","setInitialized","set","useCallback","field","value","f","handleSave","envelope_schema","resolver_schema","canSave","showPickList","NamespacePill","Code2","type","BotPicker","id"],"mappings":"8xBAmBA,SAASA,GAAU,CAAE,KAAAC,GAA0B,CAC7C,OAAIA,IAAS,YACJC,EAAAA,KAAC,OAAA,CAAK,UAAU,6EAA6E,SAAA,CAAAC,EAAAA,IAACC,EAAA,CAAY,UAAU,SAAA,CAAU,EAAE,WAAA,EAAS,EAC9IH,IAAS,aACJC,EAAAA,KAAC,OAAA,CAAK,UAAU,6EAA6E,SAAA,CAAAC,EAAAA,IAACE,GAAA,CAAS,UAAU,SAAA,CAAU,EAAE,YAAA,EAAU,EACzIH,EAAAA,KAAC,OAAA,CAAK,UAAU,8EAA8E,SAAA,CAAAC,EAAAA,IAACG,EAAA,CAAO,UAA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0G,EAAS,cAAe,CAC1C,UAAW,IAAM/G,EAAS,qBAAqB,CAAA,CAChD,EAEH,MAAM,sBACN,YACEN,EAAAA,KAAA6C,WAAA,CAAE,SAAA,CAAA,8BAC4B,IAC5B5C,EAAAA,IAAC,OAAA,CAAK,UAAU,0CAA2C,0BAAS,cAAc,EAAO,gMAAA,EAI3F,EAEF,UAAWU,EAAa,UACxB,MAAOA,EAAa,KAAA,CAAA,CACtB,EACF,CAEJ"}
@@ -0,0 +1,6 @@
1
+ import{a as f,j as e,b as it}from"./vendor-query-B2UbickB.js";import{z as pe,v as ye,b as V,C as lt,J as ae,j as ot,A as ct,g as dt,h as xt,B as ut,E as mt,u as pt}from"./index-DwWP-Z_c.js";import{u as ht}from"./useCollapsedSections-BU5HULGs.js";import{u as ft,C as gt,a as jt}from"./CustomDurationPicker-OKlwH5a_.js";import{a as bt}from"./roles-D4Wn7kE9.js";import{P as yt}from"./PageHeader-DJo7yMUR.js";import{a as Ue,C as je,i as vt}from"./escalation-CK8ElYzD.js";import{L as wt}from"./ListToolbar-Dz2_neVF.js";import{u as Nt}from"./workflows-DuUspMAl.js";import{g as kt}from"./useEventHooks-Dn_vN2xE.js";import{U as be}from"./UserName-Cc-5QH5q.js";import{S as Se}from"./StatusBadge-DZ9137bI.js";import{R as Me}from"./RolePill-DHWixsQR.js";import{C as M}from"./CopyableId-blg-gZvT.js";import{U as Ie,a9 as _t,a7 as Ct,aa as Ae}from"./vendor-icons-DOIDKgo6.js";import{C as le}from"./CollapsibleSection-Ds0e8cCO.js";import{L as Ve,e as Tt,c as Et}from"./vendor-react-CXumBFUA.js";import"./Modal-CSrxpXeM.js";import"./constants-BHkpVaqx.js";import"./users-DngGIiC_.js";const Pe="lt_view_mode";function $t(t){const[n,r]=f.useState(()=>{try{const s=localStorage.getItem(Pe);if(s!==null)return s==="dev"}catch{}return t}),a=f.useCallback(()=>{r(s=>{const l=!s;try{localStorage.setItem(Pe,l?"dev":"user")}catch{}return l})},[]);return{isDevMode:n,toggleMode:a}}const he=4;function We({pct:t,place:n,label:r,title:a,emphasis:s}){const l=e.jsx("span",{className:"w-px h-1.5 bg-surface-border","aria-hidden":!0}),d=e.jsx("span",{className:`whitespace-nowrap leading-none ${s?"text-text-secondary":"text-text-tertiary"}`,children:r});return e.jsx("div",{title:a,className:`absolute ${n==="above"?"bottom-0":"top-0"} flex flex-col items-center gap-0.5 -translate-x-1/2 cursor-help`,style:{left:`${t}%`},children:n==="above"?e.jsxs(e.Fragment,{children:[d,l]}):e.jsxs(e.Fragment,{children:[l,d]})})}function Rt({esc:t,className:n=""}){const r=new Date(t.created_at).getTime(),a=t.claimed_at?new Date(t.claimed_at).getTime():null,s=t.status==="resolved",l=t.status==="cancelled",d=s||l,x=Ue(t),i=!!a&&(x||d),o=s&&t.resolved_at?new Date(t.resolved_at).getTime():l?new Date(t.updated_at).getTime():Date.now(),c=Math.max(o-r,1),m=i&&a?Math.max(a-r,0):c,p=i&&a?Math.max(o-a,0):0,b=Math.min(100,Math.max(0,m/c*100)),u=i?Math.max(0,100-b):0,j=s?"bg-status-success":l?"bg-status-error":"bg-status-active",h=s?"Worked":l?"Open before cancel":"In progress",g=pe(m),k=pe(c),R=s?`Resolved in ${k} total`:l?`Cancelled after ${k}`:`Open ${k} so far (current age)`,C=`Lifecycle: amber = time spent waiting to be claimed, the colored end = ${h.toLowerCase()} after the claim. Top label is time-to-claim, bottom is total time.`;return e.jsxs("div",{className:n,title:C,children:[e.jsx("div",{className:"relative h-3.5 text-[9px] font-mono",children:i&&e.jsx(We,{pct:b,place:"above",label:g,title:`Time to claim: ${g} (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:`${b}%`,minWidth:he},className:"bg-status-pending",title:`Waiting ${g} — created → claimed`}),i&&e.jsx("div",{style:{width:`${u}%`,minWidth:he},className:j,title:`${h} ${pe(p)} — claimed → ${s?"resolved":l?"cancelled":"now"}`})]}),e.jsx("div",{className:"relative h-3.5 text-[9px] font-mono",children:e.jsx(We,{pct:100,place:"below",emphasis:!0,label:k,title:R})})]})}const St=new Set(["__proto__","constructor","prototype"]);function Be(t){const n=[];for(const r of t.split(".")){const a=r.match(/^([^[\]]*)((?:\[\d+\])*)$/);if(!a)throw new Error(`invalid x-lt-bind path segment: "${r}"`);const[,s,l]=a;if(s){if(St.has(s))throw new Error(`x-lt-bind path may not target "${s}"`);n.push({key:s})}for(const d of l.match(/\d+/g)??[])n.push({index:Number(d)})}if(n.length===0)throw new Error(`empty x-lt-bind path: "${t}"`);return n}function Mt(t,n,r){const a=Be(n);let s=t;for(let d=0;d<a.length-1;d++){const x=a[d],i=a[d+1],o="key"in x?x.key:x.index,c="index"in i;(s[o]==null||typeof s[o]!="object")&&(s[o]=c?[]:{}),s=s[o]}const l=a[a.length-1];s["key"in l?l.key:l.index]=r}function It(t,n){let r=t;for(const a of Be(n)){if(r==null||typeof r!="object")return;r=r["key"in a?a.key:a.index]}return r}function ze(t,n){const r=n==null?void 0:n["x-lt-bind"];return typeof r=="string"&&r.length>0?r:t}function At(t,n){const r=n==null?void 0:n.properties;if(!r)return{...t};const a={};for(const[s,l]of Object.entries(r))s in t&&Mt(a,ze(s,l),t[s]);return a}function Pt(t,n){const r=n==null?void 0:n.properties;if(!r)return t?{...t}:{};const a={};for(const[s,l]of Object.entries(r)){const d=It(t,ze(s,l));d!==void 0&&(a[s]=d)}return a}function Wt(t){const{mode:n,activeView:r,onActiveViewChange:a,onClaim:s,claimPending:l,workflowType:d,json:x,onResolve:i,resolvePending:o,resolveError:c,requestTriage:m,triageNotes:p,currentRole:b,escalationTargets:u,onEscalate:j,escalatePending:h,escalateError:g,onRelease:k,releasePending:R,onCancel:C,assignedTo:D,assignedUntil:I,onSubmitAttempt:T}=t,E=ft(),[y,w]=f.useState("30"),[N,$]=f.useState(0),[A,J]=f.useState(""),[B,O]=f.useState(""),L=y==="custom",z=f.useCallback(v=>$(v),[]);if(n==="terminal")return null;const de=()=>{const v=L?N:parseInt(y);!v||v<=0||s(v)},H=()=>{if(J(""),m){const U={_lt:{needsTriage:!0}};p.trim()&&(U.notes=p.trim()),i(U);return}let v;try{v=JSON.parse(x)}catch{J("Invalid JSON");return}const K=v._form_schema,X=K==null?void 0:K.required;if(X!=null&&X.length){const U=X.filter(W=>{const q=v[W];return q==null||typeof q=="string"&&q.trim()===""});if(U.length>0){T==null||T();const W=U.map(ee=>ee.replace(/[_-]/g," ")),q=W.length<=2?W.join(", "):`${W.slice(0,2).join(", ")}...`;J(`Required: ${q}`);return}}const{_form_schema:re,...ie}=v;i(At(ie,K))},P=v=>`text-xs transition-colors ${v?"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:[n==="available"&&e.jsxs("div",{"data-testid":"claim-bar",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-2",children:[E.map(v=>e.jsx("button",{onClick:()=>{w(v.value),$(0)},className:P(!L&&y===v.value),children:v.label},v.value)),e.jsx("button",{onClick:()=>w("custom"),className:P(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(gt,{onChange:z,compact:!0,autoFocus:!0}),e.jsx("button",{onClick:de,disabled:l||L&&N<=0,className:"btn-primary text-xs",children:l?"Claiming...":"Claim"})]})]}),n==="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:D?e.jsx(be,{userId:D}):"unknown"})]}),I&&e.jsx(je,{until:I})]}),n==="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:()=>a("resolve"),className:P(r==="resolve"),children:d?"Resolve":"Acknowledge"}),u.length>0&&e.jsx("button",{onClick:()=>a("escalate"),className:P(r==="escalate"),children:"Escalate"}),e.jsx("button",{onClick:()=>a("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"&&(d?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}),c&&e.jsx("span",{className:"text-xs text-status-error",children:c.message}),e.jsx("button",{onClick:H,disabled:o,className:"btn-primary text-xs",children:o?"Submitting...":m?"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"}),c&&e.jsx("span",{className:"text-xs text-status-error mr-3",children:c.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:b})," to"]}),e.jsxs("select",{value:B,onChange:v=>O(v.target.value),className:"select text-xs","data-testid":"escalate-select",children:[e.jsx("option",{value:"",children:"Select role..."}),u.map(v=>e.jsx("option",{value:v,children:v},v))]}),e.jsx("div",{className:"flex-1"}),g&&e.jsx("span",{className:"text-xs text-status-error",children:g.message}),e.jsx("button",{onClick:()=>j(B),disabled:!B||h,className:"btn-primary text-xs",children:h?"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:()=>a("resolve"),className:"btn-secondary text-xs",children:"Back"}),e.jsx("button",{onClick:k,disabled:R,className:"btn-primary text-xs bg-status-error hover:bg-status-error/80",children:R?"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:n,tier:r=1,className:a=""}){const s=Dt[r];return e.jsxs("div",{className:`flex-1 min-w-0 rounded-lg ${s.bg} ${s.pad} ${a}`,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:n})]})}const De=56;function Ot({value:t}){const[n,r]=f.useState(!1),a=typeof t=="object"?JSON.stringify(t):String(t??"");return a.length<=De?e.jsx("span",{className:"font-mono break-all",title:a,children:a}):e.jsx("button",{onClick:()=>r(s=>!s),title:a,className:"font-mono break-all text-left hover:text-accent transition-colors",children:n?a:`${a.slice(0,De)}…`})}function Lt({esc:t,claimedByMe:n,claimed:r,isTerminal:a,traceUrl:s,isDevMode:l,showDetails:d,onToggleDetails:x}){const{isBuilder:i}=ye(),o=vt(t);return l?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[o&&e.jsx(Ct,{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(Se,{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(Me,{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||a)&&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(Ie,{className:"w-3 h-3 shrink-0 text-accent/75"}),e.jsx(be,{userId:t.assigned_to})]})]}),r&&!a&&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(Se,{status:t.status})}),e.jsx(S,{label:"Assigned to Role",children:e.jsx(Me,{role:t.role,size:"md"})}),(r||a)&&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(Ie,{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||a)&&t.claimed_at&&e.jsx(S,{label:"Claimed",children:e.jsx(V,{date:t.claimed_at})}),r&&!a&&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:d?"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(_t,{className:`w-3.5 h-3.5 ${d?"text-accent":""}`})})]}),i&&e.jsxs(lt,{open:d,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(c=>!c.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(([c])=>!c.startsWith("_")).map(([c,m])=>e.jsx(S,{tier:3,label:c,children:e.jsx(Ot,{value:m})},c))})]})]})}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:n}){const r=[],a=/^```(\w*)\n([\s\S]*?)^```$/gm;let s=0,l;for(;(l=a.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 d=n?{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="${d.code} font-mono text-text-secondary leading-relaxed">${o}</code></pre>`);continue}x.push(...Ft(i.text,d))}return e.jsx("div",{className:"prose-sm",dangerouslySetInnerHTML:{__html:x.join(`
2
+ `)}})}function Ft(t,n){const r=t.split(`
3
+ `),a=[];let s=!1,l=!1,d=[];for(const x of r){const i=x.trim();if(i.startsWith("|")&&i.endsWith("|")){const o=i.slice(1,-1).split("|").map(c=>c.trim());if(o.every(c=>/^[-:]+$/.test(c)))continue;l||(l=!0,d=[]),d.push(o);continue}if(l){l=!1;const[o,...c]=d;a.push('<div class="overflow-x-auto my-2"><table class="text-xs w-full"><thead><tr>');for(const m of o)a.push(`<th class="text-left py-1 px-2 border-b border-border text-text-secondary font-medium">${Q(m)}</th>`);a.push("</tr></thead><tbody>");for(const m of c){a.push("<tr>");for(const p of m)a.push(`<td class="py-1 px-2 border-b border-border/50">${Q(p)}</td>`);a.push("</tr>")}a.push("</tbody></table></div>"),d=[]}if(!i){s&&(a.push("</ul>"),s=!1);continue}if(i.startsWith("### ")){s&&(a.push("</ul>"),s=!1),a.push(`<h4 class="${n.heading} font-semibold text-text-primary mt-3 mb-1">${Q(i.slice(4))}</h4>`);continue}if(i.startsWith("## ")){s&&(a.push("</ul>"),s=!1),a.push(`<h3 class="${n.heading} font-semibold text-text-primary mt-3 mb-1">${Q(i.slice(3))}</h3>`);continue}if(/^[-*_]{3,}$/.test(i)){s&&(a.push("</ul>"),s=!1),a.push('<hr class="border-border my-3" />');continue}if(/^[-*] /.test(i)){s||(a.push('<ul class="space-y-1 my-1">'),s=!0),a.push(`<li class="${n.list} text-text-secondary flex gap-2"><span class="text-text-tertiary shrink-0">-</span><span>${Q(i.slice(2))}</span></li>`);continue}s&&(a.push("</ul>"),s=!1),a.push(`<p class="${n.text} text-text-secondary my-1">${Q(i)}</p>`)}if(l&&d.length){const[x,...i]=d;a.push('<div class="overflow-x-auto my-2"><table class="text-xs w-full"><thead><tr>');for(const o of x)a.push(`<th class="text-left py-1 px-2 border-b border-border text-text-secondary font-medium">${Q(o)}</th>`);a.push("</tr></thead><tbody>");for(const o of i){a.push("<tr>");for(const c of o)a.push(`<td class="py-1 px-2 border-b border-border/50">${Q(c)}</td>`);a.push("</tr>")}a.push("</tbody></table></div>")}return s&&a.push("</ul>"),a}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 Jt({payload:t,isTerminal:n,resolverPayload:r,onRetryTriage:a,isRetrying:s}){const l=t.title,d=t.summary,x=t.diagnosis,i=t.tool_calls_made,o=t.result,c=r==null?void 0:r._lt,m=(c==null?void 0:c.triaged)===!0,p=c==null?void 0:c.triageWorkflowId,b=n&&m,[u,j]=f.useState(!1);return b?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:p&&e.jsx(Ve,{to:`/workflows/executions/${p}`,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}),d&&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:d})})]}),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:()=>j(!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"})})]}),a&&!n&&e.jsx("div",{className:"pt-2",children:e.jsxs("button",{onClick:a,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 Ut({triage:t,payload:n}){const r=t.confidence??0,a=r>=.8?"text-status-success":r>=.5?"text-status-pending":"text-status-error",s=Vt(t.originalData,n);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 ${a}`,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,d)=>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]},d))}),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(Bt,{diff:l},l.key))})]})}function Vt(t,n){if(!t)return[];const r=[];for(const a of Object.keys(t)){if(a.startsWith("_"))continue;const s=t[a],l=n[a];l!==void 0&&JSON.stringify(s)!==JSON.stringify(l)&&r.push({key:a,label:a.replace(/[_-]/g," "),original:s,corrected:l})}return r}function Bt({diff:t}){const n=Oe(t.original),r=Oe(t.corrected);return n!==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:n})]}),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 Oe(t){return t==null?"null":typeof t=="string"?t:typeof t=="number"||typeof t=="boolean"?String(t):null}function Le({src:t,escalation:n,schema:r,onResolve:a,onEscalate:s,submitAttempted:l}){const d=f.useRef(null),x=f.useRef("");f.useEffect(()=>{try{const o=new URL(t);x.current=o.origin}catch{x.current=""}},[t]);const i=f.useCallback(()=>{const o=d.current;if(!(o!=null&&o.contentWindow)||!x.current)return;const m={type:"lt:init",escalation:{id:n.id,type:n.type,subtype:n.subtype,description:n.description,status:n.status,priority:n.priority,role:n.role,workflow_type:n.workflow_type},schema:r};o.contentWindow.postMessage(m,x.current)},[n,r]);return f.useEffect(()=>{const o=c=>{if(c.origin!==x.current)return;const m=c.data;if(!(!m||typeof m!="object"||typeof m.type!="string"))switch(m.type){case"lt:ready":i();break;case"lt:submit":m.payload&&typeof m.payload=="object"&&a(m.payload);break;case"lt:escalate":typeof m.target=="string"&&m.target&&s(m.target);break;case"lt:resize":{const p=d.current;p&&typeof m.height=="number"&&m.height>0&&(p.style.height=`${Math.min(m.height,2e3)}px`);break}}};return window.addEventListener("message",o),()=>window.removeEventListener("message",o)},[i,a,s]),f.useEffect(()=>{if(!l)return;const o=d.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:d,src:t,sandbox:"allow-scripts allow-same-origin allow-forms",className:"w-full border-0",style:{minHeight:"400px"},title:"HITL Viewport",onLoad:i})})}function zt({fieldKey:t,value:n,onChange:r,schema:a}){const s=f.useRef(null),l=(a==null?void 0:a.accept)??void 0,d=t.replace(/[_-]/g," "),x=a==null?void 0:a.description,i=f.useCallback(c=>{var b;const m=(b=c.target.files)==null?void 0:b[0];if(!m)return;const p=new FileReader;p.onload=()=>{typeof p.result=="string"&&r(p.result)},p.readAsDataURL(m)},[r]),o=n.startsWith("data:");return e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary",children:d}),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 c;return(c=s.current)==null?void 0:c.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:n,onChange:r,schema:a}){const s=t.replace(/[_-]/g," "),l=a==null?void 0:a.description,d=(a==null?void 0:a["x-lt-language"])??"",x=f.useCallback(i=>{if(i.key==="Tab"){i.preventDefault();const o=i.currentTarget,c=o.selectionStart,m=o.selectionEnd,p=n.substring(0,c)+" "+n.substring(m);r(p),requestAnimationFrame(()=>{o.selectionStart=o.selectionEnd=c+2})}},[n,r]);return e.jsxs("div",{children:[e.jsxs("label",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary",children:[s,d&&e.jsx("span",{className:"ml-2 text-text-tertiary/60 normal-case font-normal",children:d})]}),l&&e.jsx("p",{className:"text-[10px] text-text-tertiary mt-0.5",children:l}),e.jsx("textarea",{value:n,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:n,onChange:r,schema:a}){const s=f.useRef(null),[l,d]=f.useState(!1),x=t.replace(/[_-]/g," "),i=a==null?void 0:a.description;f.useEffect(()=>{const u=s.current;if(!u)return;const j=u.getContext("2d");if(j&&(j.lineWidth=2,j.lineCap="round",j.strokeStyle="#1E1535",n&&n.startsWith("data:"))){const h=new Image;h.onload=()=>j.drawImage(h,0,0),h.src=n}},[]);const o=f.useCallback(u=>{const h=s.current.getBoundingClientRect();return"touches"in u?{x:u.touches[0].clientX-h.left,y:u.touches[0].clientY-h.top}:{x:u.clientX-h.left,y:u.clientY-h.top}},[]),c=f.useCallback(u=>{var g;d(!0);const j=(g=s.current)==null?void 0:g.getContext("2d");if(!j)return;const h=o(u);j.beginPath(),j.moveTo(h.x,h.y)},[o]),m=f.useCallback(u=>{var g;if(!l)return;const j=(g=s.current)==null?void 0:g.getContext("2d");if(!j)return;const h=o(u);j.lineTo(h.x,h.y),j.stroke()},[l,o]),p=f.useCallback(()=>{d(!1);const u=s.current;u&&r(u.toDataURL("image/png"))},[r]),b=f.useCallback(()=>{const u=s.current;if(!u)return;const j=u.getContext("2d");j&&(j.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:c,onMouseMove:m,onMouseUp:p,onMouseLeave:p,onTouchStart:c,onTouchMove:m,onTouchEnd:p})}),e.jsx("button",{type:"button",onClick:b,className:"mt-1 text-[10px] text-text-tertiary hover:text-accent transition-colors",children:"Clear"})]})}function qt({fieldKey:t,value:n,onChange:r,schema:a}){const s=t.replace(/[_-]/g," "),l=a==null?void 0:a.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:n,onChange:d=>r(d.target.value),className:"input w-full mt-1 text-sm leading-relaxed",rows:8,placeholder:"Supports plain text. Markdown formatting is preserved."})]})}const Fe={"file-upload":zt,"code-editor":Ht,signature:Kt,"rich-text":qt};function He({value:t,onChange:n,disabled:r,submitAttempted:a}){const[s,l]=f.useState({}),[d,x]=f.useState({}),[i,o]=f.useState(null),[c,m]=f.useState(!1),[p,b]=f.useState(new Set);f.useEffect(()=>{try{const y=JSON.parse(t);if(typeof y=="object"&&y!==null&&!Array.isArray(y)){const w={},N={};for(const[$,A]of Object.entries(y))$.startsWith("_")?N[$]=A:w[$]=A;l(w),x(N),o(N._form_schema&&typeof N._form_schema=="object"?N._form_schema:null),m(!1)}}catch{m(!0)}},[t]);const u=f.useCallback(y=>{l(y),n(JSON.stringify({...y,...d},null,2))},[d,n]),j=f.useCallback((y,w)=>{u({...s,[y]:w})},[s,u]),h=f.useCallback(y=>{b(w=>{if(w.has(y))return w;const N=new Set(w);return N.add(y),N})},[]);if(c)return e.jsx("p",{className:"text-xs text-status-error",children:"Unable to parse resolver data as form. Use the JSON editor below."});const g=Object.entries(s);if(g.length===0)return e.jsx("p",{className:"text-xs text-text-tertiary italic",children:"No resolver fields defined."});const k=i==null?void 0:i["x-lt-order"],R=k?[...g].sort((y,w)=>{const N=k.indexOf(y[0]),$=k.indexOf(w[0]);return(N===-1?1/0:N)-($===-1?1/0:$)}):g,C=new Set((i==null?void 0:i.required)??[]),D=i==null?void 0:i["x-lt-layout"],I=i==null?void 0:i.title,T=i==null?void 0:i.description,E=R.map(([y,w])=>{var L;const N=(L=i==null?void 0:i.properties)==null?void 0:L[y],$=(N==null?void 0:N.readOnly)===!0,A=(N==null?void 0:N["x-lt-span"])??1,J=C.has(y),B=p.has(y)||!!a;let O;if(J&&B&&(w==null||typeof w=="string"&&w.trim()==="")&&(O="Required"),B&&typeof w=="string"&&w.trim()!==""&&N){const z=N.format;z==="email"&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(w)&&(O="Enter a valid email address"),z==="uri"&&!/^https?:\/\/.+/.test(w)&&(O="Enter a valid URL")}return e.jsx("div",{className:D==="two-column"&&A>=2?"col-span-2":"",children:e.jsx(Ke,{fieldKey:y,value:w,onChange:z=>j(y,z),onBlur:()=>h(y),schema:i,isRequired:J,isReadOnly:$,error:O})},y)});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}),D==="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:n,onChange:r,onBlur:a,schema:s,isRequired:l,isReadOnly:d,error:x}){var m;const i=t.replace(/[_-]/g," "),o=(m=s==null?void 0:s.properties)==null?void 0:m[t];if(d){const p=n===null?"null":typeof n=="object"?JSON.stringify(n,null,2):String(n);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:p})]})}const c=o==null?void 0:o["x-lt-widget"];if(c&&c in Fe&&typeof n=="string"){const p=Fe[c];return e.jsx(p,{fieldKey:t,value:n,onChange:b=>r(b),schema:o})}if(typeof n=="boolean")return e.jsxs("div",{children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:n,onChange:p=>{r(p.target.checked),a==null||a()},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 n=="number")return e.jsxs("div",{children:[e.jsx(F,{isRequired:l,children:i}),e.jsx("input",{type:"number",value:n,onChange:p=>r(parseFloat(p.target.value)||0),onBlur:a,step:"any",className:te(!!x)}),e.jsx(Z,{error:x})]});if(typeof n=="string"){const p=(o==null?void 0:o.format)==="password",b=o==null?void 0:o.enum,u=o==null?void 0:o.description;if(b!=null&&b.length)return e.jsxs("div",{children:[e.jsx(F,{isRequired:l,children:i}),u&&e.jsx("p",{className:"text-[10px] text-text-tertiary mt-0.5",children:u}),e.jsx("select",{value:n,onChange:g=>r(g.target.value),onBlur:a,className:te(!!x),children:b.map(g=>e.jsx("option",{value:g,children:g},g))}),e.jsx(Z,{error:x})]});if(p)return e.jsxs("div",{children:[e.jsx(F,{isRequired:l,children:i}),u&&e.jsx("p",{className:"text-[10px] text-text-tertiary mt-0.5",children:u}),e.jsx("input",{type:"password",value:n,onChange:g=>r(g.target.value),onBlur:a,className:te(!!x),autoComplete:"off"}),e.jsx(Z,{error:x})]});const j=o==null?void 0:o.format,h={date:"date","date-time":"datetime-local",email:"email",uri:"url"};return j&&j in h?e.jsxs("div",{children:[e.jsx(F,{isRequired:l,children:i}),u&&e.jsx("p",{className:"text-[10px] text-text-tertiary mt-0.5",children:u}),e.jsx("input",{type:h[j],value:n,onChange:g=>r(g.target.value),onBlur:a,className:te(!!x)}),e.jsx(Z,{error:x})]}):j==="textarea"||n.length>80?e.jsxs("div",{children:[e.jsx(F,{isRequired:l,children:i}),u&&e.jsx("p",{className:"text-[10px] text-text-tertiary mt-0.5",children:u}),e.jsx("textarea",{value:n,onChange:g=>r(g.target.value),onBlur:a,className:`${te(!!x)} leading-relaxed`,rows:Math.min(6,Math.max(3,Math.ceil(n.length/60)))}),e.jsx(Z,{error:x})]}):e.jsxs("div",{children:[e.jsx(F,{isRequired:l,children:i}),u&&e.jsx("p",{className:"text-[10px] text-text-tertiary mt-0.5",children:u}),e.jsx("input",{type:"text",value:n,onChange:g=>r(g.target.value),onBlur:a,className:te(!!x)}),e.jsx(Z,{error:x})]})}if(n===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(n))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:n.map((p,b)=>e.jsx("span",{className:"px-2 py-0.5 text-[11px] font-mono bg-surface-sunken rounded text-text-secondary",children:String(p)},b))})]});if(typeof n=="object"){const p=Object.entries(n);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:p.map(([b,u])=>e.jsx(Ke,{fieldKey:b,value:u,onChange:j=>r({...n,[b]:j})},b))})]})}return null}function F({children:t,isRequired:n}){return e.jsxs("label",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-secondary",children:[t,n&&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 Je({json:t,onJsonChange:n,requestTriage:r,onRequestTriageChange:a,triageNotes:s,onTriageNotesChange:l,isDevMode:d=!0,disabled:x=!1,submitAttempted:i=!1,showTriage:o=!1}){const[c,m]=f.useState("form"),{visibleJson:p,hiddenFields:b}=f.useMemo(()=>{try{const h=JSON.parse(t);if(typeof h=="object"&&h!==null&&!Array.isArray(h)){const g={},k={};for(const[R,C]of Object.entries(h))R.startsWith("_")?g[R]=C:k[R]=C;return{visibleJson:JSON.stringify(k,null,2),hiddenFields:g}}}catch{}return{visibleJson:t,hiddenFields:{}}},[t]),u=f.useCallback(h=>{try{const g=JSON.parse(h);n(JSON.stringify({...g,...b},null,2))}catch{n(h)}},[b,n]),j=Object.keys(b).length>0;return e.jsxs(e.Fragment,{children:[(o||d)&&e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[o?r?e.jsxs("button",{onClick:()=>a(!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:()=>a(!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",{}),d&&!r&&e.jsx("button",{onClick:()=>m(c==="form"?"json":"form"),className:"text-[10px] text-text-tertiary hover:text-accent transition-colors",children:c==="form"?"Raw JSON":"Form"})]}),e.jsxs("div",{className:"relative min-h-[200px]",children:[e.jsx("div",{className:r?"pointer-events-none select-none":"",children:c==="form"?e.jsx(He,{value:t,onChange:n,disabled:x,submitAttempted:i}):e.jsxs("div",{children:[j&&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:p,onChange:h=>u(h.target.value),className:"input-json w-full",rows:Math.max(8,p.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:h=>l(h.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 Yt({esc:t}){const{isBuilder:n}=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:n?`/workflows/tasks/detail/${t.task_id}`:void 0}),t.workflow_type&&e.jsx(M,{label:"Workflow Name",value:t.workflow_type,href:n?`/workflows/executions?entity=${encodeURIComponent(t.workflow_type)}`:void 0}),t.workflow_id&&e.jsx(M,{label:"Workflow ID",value:t.workflow_id,href:n?`/workflows/executions/${t.workflow_id}`:void 0}),t.task_queue&&e.jsx(M,{label:"Task Queue",value:t.task_queue,href:n?`/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 Qt({isRoundsExhausted:t,payloadObj:n,isTerminal:r,resolverPayload:a,onRetryTriage:s,isRetrying:l}){return e.jsxs(e.Fragment,{children:[t&&n&&e.jsx("div",{className:"mt-8",children:e.jsx(Jt,{payload:n,isTerminal:r,resolverPayload:a,onRetryTriage:s,isRetrying:l})}),(n==null?void 0:n.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(Ae,{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(n.provider)})," credential to continue. Register one and then resolve this escalation to retry."]}),e.jsxs(Ve,{to:"/credentials",className:"btn-primary text-xs inline-flex items-center gap-1.5",children:[e.jsx(Ae,{size:12}),"Go to Credentials"]})]})]})]})}function Gt({isCollapsed:t,toggleSection:n,esc:r,escalationPayload:a,resolverPayload:s,triageData:l,payloadObj:d,isTerminal:x,claimedByMe:i,activeView:o,metadataFormSchema:c,json:m,onJsonChange:p,requestTriage:b,onRequestTriageChange:u,triageNotes:j,onTriageNotesChange:h,isDevMode:g,onResolve:k,onEscalate:R,submitAttempted:C,isCertified:D,hasAI:I}){return e.jsxs("div",{className:"mt-8 space-y-6",children:[g&&e.jsx(le,{title:"Escalation Record",sectionKey:"record",isCollapsed:t("record"),onToggle:n,contentClassName:"mt-4 ml-9",children:e.jsx(Yt,{esc:r})}),g&&e.jsx(le,{title:"Input / Output",sectionKey:"context",isCollapsed:t("context"),onToggle:n,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"})}),a!=null&&e.jsx("div",{children:e.jsx(ae,{data:a,label:"Escalation Context"})})]}),s!=null&&e.jsx("div",{className:"max-w-xl",children:e.jsx(ae,{data:s,label:"Resolver Payload"})})]})}),g&&l&&d&&e.jsx(le,{title:"AI Triage",sectionKey:"triage",isCollapsed:t("triage"),onToggle:n,contentClassName:"mt-4 ml-9",children:e.jsx(Ut,{triage:l,payload:d})}),!g&&x&&s!=null&&(()=>{const T=typeof s=="object"&&s!==null?s:{},E=c,y=E?{...T,_form_schema:E}:T;return e.jsx("div",{className:"pt-6",children:e.jsx(He,{value:JSON.stringify(y,null,2),onChange:()=>{},disabled:!0})})})(),!x&&(i||!g)&&o==="resolve"&&!!(r.workflow_type||c)&&(()=>{const T=c,E=T==null?void 0:T["x-lt-viewport"],y=(E==null?void 0:E.type)==="iframe"&&!!E.src&&k&&R;return g?e.jsx(le,{title:"Submit Your Resolution",sectionKey:"resolver",isCollapsed:t("resolver"),onToggle:n,contentClassName:"mt-4 ml-9",children:y?e.jsx(Le,{src:E.src,escalation:r,schema:T,onResolve:k,onEscalate:R}):e.jsx(Je,{json:m,onJsonChange:p,requestTriage:b,onRequestTriageChange:u,triageNotes:j,onTriageNotesChange:h,isDevMode:g,submitAttempted:C,showTriage:!!D&&!!I})}):e.jsx("div",{className:"pt-6",children:y?e.jsx(Le,{src:E.src,escalation:r,schema:T,onResolve:k,onEscalate:R}):e.jsx(Je,{json:m,onJsonChange:p,requestTriage:b,onRequestTriageChange:u,triageNotes:j,onTriageNotesChange:h,isDevMode:g,disabled:!i,submitAttempted:C,showTriage:!!D&&!!I})})})()]})}function ce(t){if(!t)return null;try{return JSON.parse(t)}catch{return t}}function Xt(t){if(!t)return!1;try{const n=JSON.parse(t);return!!(n&&typeof n=="object"&&n._triage)}catch{return!1}}function bs(){var _e,Ce,Te,Ee;const{id:t}=Tt(),{user:n}=ot(),r=Et(),a=it(),{data:s,isLoading:l,refetch:d,isFetching:x}=ct(t);kt(t);const i=dt(),o=xt(),c=ut(),m=mt(),[p,b]=f.useState(!1),{data:u}=bt((s==null?void 0:s.role)??""),{data:j}=Nt(),{data:h}=pt(),{isBuilder:g}=ye(),{isDevMode:k,toggleMode:R}=$t(!1),C=j==null?void 0:j.find(_=>_.workflow_type===(s==null?void 0:s.workflow_type)),D=((_e=h==null?void 0:h.telemetry)==null?void 0:_e.traceUrl)??null,[I,T]=f.useState("resolve"),[E,y]=f.useState("{}"),{isCollapsed:w,toggle:N,collapse:$,expand:A}=ht("escalation-detail"),[J,B]=f.useState(!1),[O,L]=f.useState(""),[z,de]=f.useState(!1),H=((Ce=s==null?void 0:s.metadata)==null?void 0:Ce.form_schema)??null,P=(s==null?void 0:s.form_schema)??(C==null?void 0:C.resolver_schema)??null,v=H??P,K=f.useRef(!1);f.useEffect(()=>{if(K.current)return;const _=H??(P!=null&&P.properties?P:null);if(_!=null&&_.properties){K.current=!0;const ue=ce(s==null?void 0:s.envelope),me=ue==null?void 0:ue.formDefaults,nt=me&&typeof me=="object"?Pt(me,_):{},$e={_form_schema:_};for(const[Re,at]of Object.entries(_.properties)){const rt=at;$e[Re]=nt[Re]??rt.default??""}y(JSON.stringify($e,null,2))}else v&&(K.current=!0,y(JSON.stringify(v,null,2)))},[v,H,P,s==null?void 0:s.envelope]);const X=Xt(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(f.useEffect(()=>{(X||re)&&$("context"),ie&&H&&($("context"),A("resolver"))},[X,re,ie,H,$,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=Ue(s),W=U&&s.assigned_to===(n==null?void 0:n.userId),q=U&&!W,ee=s.status==="resolved"||s.status==="cancelled",se=ce(s.escalation_payload),ve=ce(s.resolver_payload),xe=ce(s.envelope),qe=!!((Te=xe==null?void 0:xe.metadata)!=null&&Te.certified),Ye=!!((Ee=h==null?void 0:h.ai)!=null&&Ee.enabled),Y=typeof se=="object"&&se!==null&&!Array.isArray(se)?se:null,Qe=Y==null?void 0:Y._triage,Ge=ee?"terminal":W?"claimed_by_me":q?"claimed_by_other":"available",Xe=_=>{i.mutate({id:s.id,durationMinutes:_}),$("context"),$("triage"),A("resolver")},ne=()=>{a.resetQueries({queryKey:["escalations"]}),a.resetQueries({queryKey:["escalationStats"]}),r(-1)},we=async _=>{await o.mutateAsync({id:s.id,resolverPayload:_}),ne()},Ne=async _=>{_&&(await c.mutateAsync({id:s.id,targetRole:_}),ne())},Ze=async()=>{W||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()},et=async()=>{await i.mutateAsync({id:s.id,durationMinutes:0}),ne()},tt=async()=>{await m.mutateAsync(s.id),b(!1),ne()},ke=g?e.jsx("button",{onClick:R,className:"text-text-tertiary hover:text-accent transition-colors",title:k?"Switch to user view":"Switch to developer view",children:k?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,st=e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(wt,{onRefresh:()=>d(),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(yt,{title:"Escalation",actions:st,center:e.jsx(Rt,{esc:s,className:"w-[25%] shrink-0"})}),e.jsx(Lt,{esc:s,claimedByMe:W,claimed:U,isTerminal:ee,traceUrl:D,isDevMode:k,showDetails:!w("details"),onToggleDetails:()=>N("details")}),e.jsx(Qt,{isRoundsExhausted:re,payloadObj:Y,isTerminal:ee,resolverPayload:ve,onRetryTriage:Ze,isRetrying:i.isPending||o.isPending}),e.jsx(Gt,{isCollapsed:w,toggleSection:N,esc:s,escalationPayload:se,resolverPayload:ve,triageData:Qe,payloadObj:Y,isTerminal:ee,claimedByMe:W,activeView:I,metadataFormSchema:H,json:E,onJsonChange:y,requestTriage:J,onRequestTriageChange:B,triageNotes:O,onTriageNotesChange:L,isDevMode:k,onResolve:we,onEscalate:Ne,submitAttempted:z,isCertified:qe,hasAI:Ye}),e.jsx("div",{className:"flex-1"}),e.jsx(Wt,{mode:Ge,activeView:I,onActiveViewChange:T,onClaim:Xe,claimPending:i.isPending,workflowType:s.workflow_type,json:E,onResolve:we,resolvePending:o.isPending,resolveError:o.error,requestTriage:J,triageNotes:O,currentRole:s.role,escalationTargets:((u==null?void 0:u.targets)??[]).filter(_=>_!==s.role),onEscalate:Ne,escalatePending:c.isPending,escalateError:c.error,onRelease:et,releasePending:i.isPending,onCancel:()=>b(!0),assignedTo:s.assigned_to,assignedUntil:s.assigned_until,onSubmitAttempt:()=>de(!0)}),e.jsx(jt,{open:p,onClose:()=>b(!1),onConfirm:tt,isPending:m.isPending,error:m.error})]})}export{bs as EscalationDetailPage};
6
+ //# sourceMappingURL=index-OV1JoB_P.js.map