@hotmeshio/long-tail 0.7.3 → 0.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (213) hide show
  1. package/build/api/roles.d.ts +4 -0
  2. package/build/api/roles.js +7 -1
  3. package/build/lib/db/schemas/019_role_priority.sql +28 -0
  4. package/build/routes/roles.js +1 -1
  5. package/build/scripts/ortho-populate.d.ts +7 -1
  6. package/build/scripts/ortho-populate.js +21 -6
  7. package/build/services/escalation/facet-sql.d.ts +1 -0
  8. package/build/services/escalation/facet-sql.js +7 -6
  9. package/build/services/escalation/queries.js +27 -5
  10. package/build/services/escalation/sql.d.ts +19 -2
  11. package/build/services/escalation/sql.js +32 -9
  12. package/build/services/escalation/types.d.ts +7 -1
  13. package/build/services/role/index.js +2 -0
  14. package/build/services/role/sql.d.ts +4 -4
  15. package/build/services/role/sql.js +12 -6
  16. package/build/services/role/types.d.ts +14 -0
  17. package/build/system/mcp-servers/admin/schemas.d.ts +6 -0
  18. package/build/system/mcp-servers/admin/schemas.js +3 -0
  19. package/build/system/mcp-servers/admin/users.js +4 -1
  20. package/build/system/seed/tool-manifests-admin.d.ts +152 -0
  21. package/build/system/seed/tool-manifests-admin.js +1 -1
  22. package/dashboard/dist/assets/{AdminDashboard-C9eE1VEp.js → AdminDashboard-Bgomc_jH.js} +2 -2
  23. package/dashboard/dist/assets/{AdminDashboard-C9eE1VEp.js.map → AdminDashboard-Bgomc_jH.js.map} +1 -1
  24. package/dashboard/dist/assets/{AgentConfigPage-Ba8QfXM2.js → AgentConfigPage-C6gDgz21.js} +6 -6
  25. package/dashboard/dist/assets/{AgentConfigPage-Ba8QfXM2.js.map → AgentConfigPage-C6gDgz21.js.map} +1 -1
  26. package/dashboard/dist/assets/{AgentDetailPage-DVmec0CP.js → AgentDetailPage-0rrH5FmV.js} +4 -4
  27. package/dashboard/dist/assets/{AgentDetailPage-DVmec0CP.js.map → AgentDetailPage-0rrH5FmV.js.map} +1 -1
  28. package/dashboard/dist/assets/{AgentsPage-DNiCYMh3.js → AgentsPage-DkIU2zed.js} +2 -2
  29. package/dashboard/dist/assets/{AgentsPage-DNiCYMh3.js.map → AgentsPage-DkIU2zed.js.map} +1 -1
  30. package/dashboard/dist/assets/{AvailableEscalationsPage-gDIF8ocC.js → AvailableEscalationsPage-C9DAtNGp.js} +2 -2
  31. package/dashboard/dist/assets/{AvailableEscalationsPage-gDIF8ocC.js.map → AvailableEscalationsPage-C9DAtNGp.js.map} +1 -1
  32. package/dashboard/dist/assets/{BotPicker-3wBcBavT.js → BotPicker-MnI3OyE7.js} +2 -2
  33. package/dashboard/dist/assets/{BotPicker-3wBcBavT.js.map → BotPicker-MnI3OyE7.js.map} +1 -1
  34. package/dashboard/dist/assets/{CapabilitiesPage-WoPkND2y.js → CapabilitiesPage-Cv_AD_5i.js} +2 -2
  35. package/dashboard/dist/assets/{CapabilitiesPage-WoPkND2y.js.map → CapabilitiesPage-Cv_AD_5i.js.map} +1 -1
  36. package/dashboard/dist/assets/{CollapsibleSection-Cx99mqNN.js → CollapsibleSection-Ne-Q3QFM.js} +2 -2
  37. package/dashboard/dist/assets/{CollapsibleSection-Cx99mqNN.js.map → CollapsibleSection-Ne-Q3QFM.js.map} +1 -1
  38. package/dashboard/dist/assets/{CredentialsPage-DbNaoPbF.js → CredentialsPage-B3Mfwl22.js} +2 -2
  39. package/dashboard/dist/assets/{CredentialsPage-DbNaoPbF.js.map → CredentialsPage-B3Mfwl22.js.map} +1 -1
  40. package/dashboard/dist/assets/{CronLabel-DLW4_Zg4.js → CronLabel-CtjUBRPo.js} +2 -2
  41. package/dashboard/dist/assets/{CronLabel-DLW4_Zg4.js.map → CronLabel-CtjUBRPo.js.map} +1 -1
  42. package/dashboard/dist/assets/{CustomDurationPicker-BRUFjkiu.js → CustomDurationPicker-Cp1fgzPX.js} +2 -2
  43. package/dashboard/dist/assets/{CustomDurationPicker-BRUFjkiu.js.map → CustomDurationPicker-Cp1fgzPX.js.map} +1 -1
  44. package/dashboard/dist/assets/{DropZone-DEX0BBqt.js → DropZone-CZDmNBn-.js} +2 -2
  45. package/dashboard/dist/assets/{DropZone-DEX0BBqt.js.map → DropZone-CZDmNBn-.js.map} +1 -1
  46. package/dashboard/dist/assets/{ElapsedCell-BtmDQaym.js → ElapsedCell-Gr5UlUbn.js} +2 -2
  47. package/dashboard/dist/assets/{ElapsedCell-BtmDQaym.js.map → ElapsedCell-Gr5UlUbn.js.map} +1 -1
  48. package/dashboard/dist/assets/{EscalationSchemaPage-Bm4yBEGN.js → EscalationSchemaPage-C5tuV6SJ.js} +2 -2
  49. package/dashboard/dist/assets/{EscalationSchemaPage-Bm4yBEGN.js.map → EscalationSchemaPage-C5tuV6SJ.js.map} +1 -1
  50. package/dashboard/dist/assets/{EscalationsOverview-B3xZwTQA.js → EscalationsOverview-BIZVnSBF.js} +2 -2
  51. package/dashboard/dist/assets/{EscalationsOverview-B3xZwTQA.js.map → EscalationsOverview-BIZVnSBF.js.map} +1 -1
  52. package/dashboard/dist/assets/{EventTable-Bh9FKXLI.js → EventTable-90aUfsNr.js} +2 -2
  53. package/dashboard/dist/assets/{EventTable-Bh9FKXLI.js.map → EventTable-90aUfsNr.js.map} +1 -1
  54. package/dashboard/dist/assets/{GraphInvokePage-ov_ANlaE.js → GraphInvokePage-Io5ZucT8.js} +2 -2
  55. package/dashboard/dist/assets/{GraphInvokePage-ov_ANlaE.js.map → GraphInvokePage-Io5ZucT8.js.map} +1 -1
  56. package/dashboard/dist/assets/{HomePage-D0DV6izb.js → HomePage-Cu0vUzTF.js} +2 -2
  57. package/dashboard/dist/assets/{HomePage-D0DV6izb.js.map → HomePage-Cu0vUzTF.js.map} +1 -1
  58. package/dashboard/dist/assets/{ListToolbar-FpcvqNkN.js → ListToolbar-CdmIvEIF.js} +2 -2
  59. package/dashboard/dist/assets/{ListToolbar-FpcvqNkN.js.map → ListToolbar-CdmIvEIF.js.map} +1 -1
  60. package/dashboard/dist/assets/{McpOverview-DcuRiAff.js → McpOverview-C-Ypezuv.js} +2 -2
  61. package/dashboard/dist/assets/{McpOverview-DcuRiAff.js.map → McpOverview-C-Ypezuv.js.map} +1 -1
  62. package/dashboard/dist/assets/{McpQueryDetailPage-BcYl67KP.js → McpQueryDetailPage-DdontKcj.js} +2 -2
  63. package/dashboard/dist/assets/{McpQueryDetailPage-BcYl67KP.js.map → McpQueryDetailPage-DdontKcj.js.map} +1 -1
  64. package/dashboard/dist/assets/{McpQueryPage-C3GDzqZM.js → McpQueryPage-D-1TaOGG.js} +2 -2
  65. package/dashboard/dist/assets/{McpQueryPage-C3GDzqZM.js.map → McpQueryPage-D-1TaOGG.js.map} +1 -1
  66. package/dashboard/dist/assets/{McpRunDetailPage-SzOyhDBW.js → McpRunDetailPage-B1sCxKLD.js} +2 -2
  67. package/dashboard/dist/assets/{McpRunDetailPage-SzOyhDBW.js.map → McpRunDetailPage-B1sCxKLD.js.map} +1 -1
  68. package/dashboard/dist/assets/{McpRunsPage-BwgB6mRV.js → McpRunsPage-eWJ7cDa3.js} +2 -2
  69. package/dashboard/dist/assets/{McpRunsPage-BwgB6mRV.js.map → McpRunsPage-eWJ7cDa3.js.map} +1 -1
  70. package/dashboard/dist/assets/{NamespacePill-CwKdoyRM.js → NamespacePill-DlqBTvFR.js} +2 -2
  71. package/dashboard/dist/assets/{NamespacePill-CwKdoyRM.js.map → NamespacePill-DlqBTvFR.js.map} +1 -1
  72. package/dashboard/dist/assets/OperationsPage-C5phWL0O.js +2 -0
  73. package/dashboard/dist/assets/OperationsPage-C5phWL0O.js.map +1 -0
  74. package/dashboard/dist/assets/{OperatorDashboard-DSXh-yYw.js → OperatorDashboard-YP6kP-f_.js} +2 -2
  75. package/dashboard/dist/assets/{OperatorDashboard-DSXh-yYw.js.map → OperatorDashboard-YP6kP-f_.js.map} +1 -1
  76. package/dashboard/dist/assets/{PageHeader-BhaWTWcM.js → PageHeader-CFta2VaS.js} +2 -2
  77. package/dashboard/dist/assets/{PageHeader-BhaWTWcM.js.map → PageHeader-CFta2VaS.js.map} +1 -1
  78. package/dashboard/dist/assets/{PageHeaderWithStats-yex5WmHB.js → PageHeaderWithStats-CcVAji-7.js} +2 -2
  79. package/dashboard/dist/assets/{PageHeaderWithStats-yex5WmHB.js.map → PageHeaderWithStats-CcVAji-7.js.map} +1 -1
  80. package/dashboard/dist/assets/{ProcessDetailPage-iIB1rwEt.js → ProcessDetailPage-C_BXQvBs.js} +2 -2
  81. package/dashboard/dist/assets/{ProcessDetailPage-iIB1rwEt.js.map → ProcessDetailPage-C_BXQvBs.js.map} +1 -1
  82. package/dashboard/dist/assets/{ProcessesListPage-BrqWR2zr.js → ProcessesListPage-BNhFwTLl.js} +2 -2
  83. package/dashboard/dist/assets/{ProcessesListPage-BrqWR2zr.js.map → ProcessesListPage-BNhFwTLl.js.map} +1 -1
  84. package/dashboard/dist/assets/RoleDetailPage-8GLNjj9I.js +11 -0
  85. package/dashboard/dist/assets/RoleDetailPage-8GLNjj9I.js.map +1 -0
  86. package/dashboard/dist/assets/{RolePill-Cl71eDUA.js → RolePill-CXEyPMqb.js} +2 -2
  87. package/dashboard/dist/assets/{RolePill-Cl71eDUA.js.map → RolePill-CXEyPMqb.js.map} +1 -1
  88. package/dashboard/dist/assets/{RolesPage-Bzp9FhAl.js → RolesPage-B59tE2lZ.js} +2 -2
  89. package/dashboard/dist/assets/{RolesPage-Bzp9FhAl.js.map → RolesPage-B59tE2lZ.js.map} +1 -1
  90. package/dashboard/dist/assets/{RunAsSelector-DXbHRxQs.js → RunAsSelector-CokM3Ifp.js} +2 -2
  91. package/dashboard/dist/assets/{RunAsSelector-DXbHRxQs.js.map → RunAsSelector-CokM3Ifp.js.map} +1 -1
  92. package/dashboard/dist/assets/{StickyPagination-D8XuMSWD.js → StickyPagination-_H2j2CAH.js} +2 -2
  93. package/dashboard/dist/assets/{StickyPagination-D8XuMSWD.js.map → StickyPagination-_H2j2CAH.js.map} +1 -1
  94. package/dashboard/dist/assets/{StreamMessageDetail-D5v95pmz.js → StreamMessageDetail-sSfHDYIa.js} +2 -2
  95. package/dashboard/dist/assets/{StreamMessageDetail-D5v95pmz.js.map → StreamMessageDetail-sSfHDYIa.js.map} +1 -1
  96. package/dashboard/dist/assets/{SwimlaneTimeline-CUEf2R5R.js → SwimlaneTimeline-LZWtfBK3.js} +2 -2
  97. package/dashboard/dist/assets/{SwimlaneTimeline-CUEf2R5R.js.map → SwimlaneTimeline-LZWtfBK3.js.map} +1 -1
  98. package/dashboard/dist/assets/{TagInput-B_WQiuer.js → TagInput-CQg-TrV9.js} +2 -2
  99. package/dashboard/dist/assets/{TagInput-B_WQiuer.js.map → TagInput-CQg-TrV9.js.map} +1 -1
  100. package/dashboard/dist/assets/{TaskDetailPage-BJvKNwEe.js → TaskDetailPage-CHBV2V6R.js} +2 -2
  101. package/dashboard/dist/assets/{TaskDetailPage-BJvKNwEe.js.map → TaskDetailPage-CHBV2V6R.js.map} +1 -1
  102. package/dashboard/dist/assets/{TaskQueuePill-Lgn2obNU.js → TaskQueuePill-DyvtL8X4.js} +2 -2
  103. package/dashboard/dist/assets/{TaskQueuePill-Lgn2obNU.js.map → TaskQueuePill-DyvtL8X4.js.map} +1 -1
  104. package/dashboard/dist/assets/{TasksListPage-CM7BWh_h.js → TasksListPage-B71FxvrY.js} +2 -2
  105. package/dashboard/dist/assets/{TasksListPage-CM7BWh_h.js.map → TasksListPage-B71FxvrY.js.map} +1 -1
  106. package/dashboard/dist/assets/{TimeAgo-D1K7xKq5.js → TimeAgo-JgT0U_sd.js} +2 -2
  107. package/dashboard/dist/assets/{TimeAgo-D1K7xKq5.js.map → TimeAgo-JgT0U_sd.js.map} +1 -1
  108. package/dashboard/dist/assets/{TimestampCell-7G0echgP.js → TimestampCell-gEreK8Nn.js} +2 -2
  109. package/dashboard/dist/assets/{TimestampCell-7G0echgP.js.map → TimestampCell-gEreK8Nn.js.map} +1 -1
  110. package/dashboard/dist/assets/{ToolPill-uVqcbHPE.js → ToolPill-miuRcj1Q.js} +2 -2
  111. package/dashboard/dist/assets/{ToolPill-uVqcbHPE.js.map → ToolPill-miuRcj1Q.js.map} +1 -1
  112. package/dashboard/dist/assets/{ToolTestPanel-LxuJvURK.js → ToolTestPanel-ChfHw9Aq.js} +2 -2
  113. package/dashboard/dist/assets/{ToolTestPanel-LxuJvURK.js.map → ToolTestPanel-ChfHw9Aq.js.map} +1 -1
  114. package/dashboard/dist/assets/{TopicDetailPage-JvAX6rrR.js → TopicDetailPage-DigI0HGt.js} +2 -2
  115. package/dashboard/dist/assets/{TopicDetailPage-JvAX6rrR.js.map → TopicDetailPage-DigI0HGt.js.map} +1 -1
  116. package/dashboard/dist/assets/{TopicsPage-tFT2AcTz.js → TopicsPage-BHjlFpPN.js} +2 -2
  117. package/dashboard/dist/assets/{TopicsPage-tFT2AcTz.js.map → TopicsPage-BHjlFpPN.js.map} +1 -1
  118. package/dashboard/dist/assets/{UserName-Djz0nmaZ.js → UserName-uncbaKYf.js} +2 -2
  119. package/dashboard/dist/assets/{UserName-Djz0nmaZ.js.map → UserName-uncbaKYf.js.map} +1 -1
  120. package/dashboard/dist/assets/{WorkflowExecutionPage-f53hilbI.js → WorkflowExecutionPage-DwzLKTkt.js} +2 -2
  121. package/dashboard/dist/assets/{WorkflowExecutionPage-f53hilbI.js.map → WorkflowExecutionPage-DwzLKTkt.js.map} +1 -1
  122. package/dashboard/dist/assets/{WorkflowPill-IDjTRfQ8.js → WorkflowPill-BegV-iRF.js} +2 -2
  123. package/dashboard/dist/assets/{WorkflowPill-IDjTRfQ8.js.map → WorkflowPill-BegV-iRF.js.map} +1 -1
  124. package/dashboard/dist/assets/{WorkflowsDashboard-DM9Xe665.js → WorkflowsDashboard-rpnGhGnl.js} +2 -2
  125. package/dashboard/dist/assets/{WorkflowsDashboard-DM9Xe665.js.map → WorkflowsDashboard-rpnGhGnl.js.map} +1 -1
  126. package/dashboard/dist/assets/{WorkflowsOverview-CUGSrx9N.js → WorkflowsOverview-ihhW8DiS.js} +2 -2
  127. package/dashboard/dist/assets/{WorkflowsOverview-CUGSrx9N.js.map → WorkflowsOverview-ihhW8DiS.js.map} +1 -1
  128. package/dashboard/dist/assets/{YamlWorkflowDetailPage-B1_yqxAw.js → YamlWorkflowDetailPage-C61-8y-E.js} +2 -2
  129. package/dashboard/dist/assets/{YamlWorkflowDetailPage-B1_yqxAw.js.map → YamlWorkflowDetailPage-C61-8y-E.js.map} +1 -1
  130. package/dashboard/dist/assets/{YamlWorkflowsPage-NtGvqiu7.js → YamlWorkflowsPage-CMpgsLEo.js} +2 -2
  131. package/dashboard/dist/assets/{YamlWorkflowsPage-NtGvqiu7.js.map → YamlWorkflowsPage-CMpgsLEo.js.map} +1 -1
  132. package/dashboard/dist/assets/{agents-tML6AjDj.js → agents-27sErp5R.js} +2 -2
  133. package/dashboard/dist/assets/{agents-tML6AjDj.js.map → agents-27sErp5R.js.map} +1 -1
  134. package/dashboard/dist/assets/{bots-Cb0WTwhY.js → bots-CPHuAvjW.js} +2 -2
  135. package/dashboard/dist/assets/{bots-Cb0WTwhY.js.map → bots-CPHuAvjW.js.map} +1 -1
  136. package/dashboard/dist/assets/{capabilities-BGZogsi_.js → capabilities-BBTPqF-V.js} +2 -2
  137. package/dashboard/dist/assets/{capabilities-BGZogsi_.js.map → capabilities-BBTPqF-V.js.map} +1 -1
  138. package/dashboard/dist/assets/{controlplane-B7VJTlZD.js → controlplane-C9j2mwX8.js} +2 -2
  139. package/dashboard/dist/assets/{controlplane-B7VJTlZD.js.map → controlplane-C9j2mwX8.js.map} +1 -1
  140. package/dashboard/dist/assets/{escalation-Bl-SQV_u.js → escalation-CyJ_wz-f.js} +2 -2
  141. package/dashboard/dist/assets/{escalation-Bl-SQV_u.js.map → escalation-CyJ_wz-f.js.map} +1 -1
  142. package/dashboard/dist/assets/{escalation-columns-BlJOswRx.js → escalation-columns-DU4Jyxxo.js} +2 -2
  143. package/dashboard/dist/assets/{escalation-columns-BlJOswRx.js.map → escalation-columns-DU4Jyxxo.js.map} +1 -1
  144. package/dashboard/dist/assets/{index-e97M6GoI.js → index-BBQggGcf.js} +2 -2
  145. package/dashboard/dist/assets/{index-e97M6GoI.js.map → index-BBQggGcf.js.map} +1 -1
  146. package/dashboard/dist/assets/{index-D0-8byNu.js → index-BHS-ubrT.js} +2 -2
  147. package/dashboard/dist/assets/{index-D0-8byNu.js.map → index-BHS-ubrT.js.map} +1 -1
  148. package/dashboard/dist/assets/{index-DcbEIXit.js → index-BVHXREYZ.js} +2 -2
  149. package/dashboard/dist/assets/{index-DcbEIXit.js.map → index-BVHXREYZ.js.map} +1 -1
  150. package/dashboard/dist/assets/{index-Il_g7kw5.js → index-BiLZJ43R.js} +2 -2
  151. package/dashboard/dist/assets/{index-Il_g7kw5.js.map → index-BiLZJ43R.js.map} +1 -1
  152. package/dashboard/dist/assets/{index-Dgw1KKpq.js → index-BoZydcaW.js} +4 -4
  153. package/dashboard/dist/assets/{index-Dgw1KKpq.js.map → index-BoZydcaW.js.map} +1 -1
  154. package/dashboard/dist/assets/{index-CBv3UxF2.js → index-CCHGKErT.js} +2 -2
  155. package/dashboard/dist/assets/{index-CBv3UxF2.js.map → index-CCHGKErT.js.map} +1 -1
  156. package/dashboard/dist/assets/{index-0o71lRuY.js → index-CNprOGuS.js} +2 -2
  157. package/dashboard/dist/assets/{index-0o71lRuY.js.map → index-CNprOGuS.js.map} +1 -1
  158. package/dashboard/dist/assets/{index-Wny0bRgq.css → index-CZ6-l8_0.css} +1 -1
  159. package/dashboard/dist/assets/{index-3A_5CL81.js → index-CgeFUhUr.js} +2 -2
  160. package/dashboard/dist/assets/{index-3A_5CL81.js.map → index-CgeFUhUr.js.map} +1 -1
  161. package/dashboard/dist/assets/{index-TiKh2Ctj.js → index-ChniBGqD.js} +2 -2
  162. package/dashboard/dist/assets/{index-TiKh2Ctj.js.map → index-ChniBGqD.js.map} +1 -1
  163. package/dashboard/dist/assets/{index--WeZDfeN.js → index-CjXzZ19T.js} +2 -2
  164. package/dashboard/dist/assets/{index--WeZDfeN.js.map → index-CjXzZ19T.js.map} +1 -1
  165. package/dashboard/dist/assets/{index-DfDfJivY.js → index-D9pi0fs6.js} +2 -2
  166. package/dashboard/dist/assets/{index-DfDfJivY.js.map → index-D9pi0fs6.js.map} +1 -1
  167. package/dashboard/dist/assets/{index-SCrD3l-K.js → index-DoivEaUZ.js} +2 -2
  168. package/dashboard/dist/assets/{index-SCrD3l-K.js.map → index-DoivEaUZ.js.map} +1 -1
  169. package/dashboard/dist/assets/{index-BorpZbZA.js → index-Dzqt3g-K.js} +2 -2
  170. package/dashboard/dist/assets/{index-BorpZbZA.js.map → index-Dzqt3g-K.js.map} +1 -1
  171. package/dashboard/dist/assets/{knowledge-CDzw4E6q.js → knowledge-BErJA3Je.js} +2 -2
  172. package/dashboard/dist/assets/{knowledge-CDzw4E6q.js.map → knowledge-BErJA3Je.js.map} +1 -1
  173. package/dashboard/dist/assets/{mcp-D_-NQtnG.js → mcp-Cx9L42EN.js} +2 -2
  174. package/dashboard/dist/assets/{mcp-D_-NQtnG.js.map → mcp-Cx9L42EN.js.map} +1 -1
  175. package/dashboard/dist/assets/{mcp-query-BqZXdf9A.js → mcp-query-Cf6kcBoW.js} +2 -2
  176. package/dashboard/dist/assets/{mcp-query-BqZXdf9A.js.map → mcp-query-Cf6kcBoW.js.map} +1 -1
  177. package/dashboard/dist/assets/{pipelines-CNLhgj8b.js → pipelines-CFctrv71.js} +2 -2
  178. package/dashboard/dist/assets/{pipelines-CNLhgj8b.js.map → pipelines-CFctrv71.js.map} +1 -1
  179. package/dashboard/dist/assets/{roles-CFD2eYap.js → roles-CCXZtqDr.js} +2 -2
  180. package/dashboard/dist/assets/roles-CCXZtqDr.js.map +1 -0
  181. package/dashboard/dist/assets/{tasks-DcSvF636.js → tasks-BPNj8ZWL.js} +2 -2
  182. package/dashboard/dist/assets/{tasks-DcSvF636.js.map → tasks-BPNj8ZWL.js.map} +1 -1
  183. package/dashboard/dist/assets/{topics-DI8TFSZv.js → topics-CR4UBuSV.js} +2 -2
  184. package/dashboard/dist/assets/{topics-DI8TFSZv.js.map → topics-CR4UBuSV.js.map} +1 -1
  185. package/dashboard/dist/assets/{useEventHooks-DcIgMDh3.js → useEventHooks-BgdnN8Rj.js} +2 -2
  186. package/dashboard/dist/assets/{useEventHooks-DcIgMDh3.js.map → useEventHooks-BgdnN8Rj.js.map} +1 -1
  187. package/dashboard/dist/assets/{useNamespace-C88ZxGoX.js → useNamespace-BDsKfT0f.js} +2 -2
  188. package/dashboard/dist/assets/{useNamespace-C88ZxGoX.js.map → useNamespace-BDsKfT0f.js.map} +1 -1
  189. package/dashboard/dist/assets/{useYamlActivityEvents-D2-yVjJ7.js → useYamlActivityEvents-CWZwHIlR.js} +2 -2
  190. package/dashboard/dist/assets/{useYamlActivityEvents-D2-yVjJ7.js.map → useYamlActivityEvents-CWZwHIlR.js.map} +1 -1
  191. package/dashboard/dist/assets/{users-C0WV36X8.js → users-BqmKVXR1.js} +2 -2
  192. package/dashboard/dist/assets/{users-C0WV36X8.js.map → users-BqmKVXR1.js.map} +1 -1
  193. package/dashboard/dist/assets/{vendor-icons-CEWCGPeJ.js → vendor-icons-BaQqUm-e.js} +2 -2
  194. package/dashboard/dist/assets/{vendor-icons-CEWCGPeJ.js.map → vendor-icons-BaQqUm-e.js.map} +1 -1
  195. package/dashboard/dist/assets/{workflows-CkPv7xk-.js → workflows-Dps45zjk.js} +2 -2
  196. package/dashboard/dist/assets/{workflows-CkPv7xk-.js.map → workflows-Dps45zjk.js.map} +1 -1
  197. package/dashboard/dist/assets/{yaml-workflows-BjrMQLTK.js → yaml-workflows-DhlTkbvY.js} +2 -2
  198. package/dashboard/dist/assets/{yaml-workflows-BjrMQLTK.js.map → yaml-workflows-DhlTkbvY.js.map} +1 -1
  199. package/dashboard/dist/index.html +3 -3
  200. package/docs/api/http/escalations.md +3 -3
  201. package/docs/api/http/roles.md +6 -0
  202. package/docs/api/mcp/admin.md +2 -0
  203. package/docs/api/sdk/escalations.md +2 -2
  204. package/docs/api/sdk/roles.md +7 -1
  205. package/docs/dashboard.md +5 -4
  206. package/docs/data.md +2 -0
  207. package/docs/operations.md +16 -3
  208. package/package.json +2 -2
  209. package/dashboard/dist/assets/OperationsPage-BCr21p8I.js +0 -2
  210. package/dashboard/dist/assets/OperationsPage-BCr21p8I.js.map +0 -1
  211. package/dashboard/dist/assets/RoleDetailPage-DS37tJhq.js +0 -11
  212. package/dashboard/dist/assets/RoleDetailPage-DS37tJhq.js.map +0 -1
  213. package/dashboard/dist/assets/roles-CFD2eYap.js.map +0 -1
@@ -59,7 +59,7 @@ exports.ADMIN_TOOLS = [
59
59
  { name: 'list_roles', description: 'List all distinct roles known to the system.', read_safe: true, inputSchema: { type: 'object', properties: {} } },
60
60
  { name: 'create_role', description: 'Create a new role. Lowercase alphanumeric with hyphens/underscores.', read_safe: false, inputSchema: { type: 'object', properties: { role: { type: 'string' } }, required: ['role'] } },
61
61
  { name: 'add_escalation_chain', description: 'Define an escalation path from one role to another.', read_safe: false, inputSchema: { type: 'object', properties: { source_role: { type: 'string' }, target_role: { type: 'string' } }, required: ['source_role', 'target_role'] } },
62
- { name: 'update_role', description: 'Update role metadata with PATCH semantics (omitted fields keep their values): display name, description, form/metadata schemas, properties bag, ops_visible flag, parent role, and the typed operational targets. A schema change snapshots the pair into the version history.', read_safe: false, inputSchema: { type: 'object', properties: { role: { type: 'string' }, title: { type: 'string' }, description: { type: 'string' }, form_schema: { type: 'object' }, metadata_schema: { type: 'object' }, properties: { type: 'object' }, ops_visible: { type: 'boolean' }, parent_role: { type: 'string' }, sla_minutes: { type: 'number' }, target_per_hour: { type: 'number' }, worker_count: { type: 'integer' }, upstream_roles: { type: 'array', items: { type: 'string' } }, change_summary: { type: 'string' } }, required: ['role'] } },
62
+ { name: 'update_role', description: 'Update role metadata with PATCH semantics (omitted fields keep their values): display name, description, form/metadata schemas, properties bag, ops_visible flag, parent role, and the typed operational targets. A schema change snapshots the pair into the version history.', read_safe: false, inputSchema: { type: 'object', properties: { role: { type: 'string' }, title: { type: 'string' }, description: { type: 'string' }, form_schema: { type: 'object' }, metadata_schema: { type: 'object' }, properties: { type: 'object' }, ops_visible: { type: 'boolean' }, parent_role: { type: 'string' }, sla_minutes: { type: 'number' }, target_per_hour: { type: 'number' }, worker_count: { type: 'integer' }, priority_threshold_minutes: { type: 'number' }, priority_facet: { type: 'string' }, upstream_roles: { type: 'array', items: { type: 'string' } }, change_summary: { type: 'string' } }, required: ['role'] } },
63
63
  { name: 'get_role_schema', description: 'Fetch a role\'s form_schema + metadata_schema pair — the live (latest) schema, or an immutable snapshot when a version is given (the version escalations pin via metadata.schema_version).', read_safe: true, inputSchema: { type: 'object', properties: { role: { type: 'string' }, version: { type: 'integer' } }, required: ['role'] } },
64
64
  { name: 'list_role_schema_versions', description: 'List a role\'s schema version history, newest first. Each schema edit creates a new version; fetch a full snapshot with get_role_schema.', read_safe: true, inputSchema: { type: 'object', properties: { role: { type: 'string' } }, required: ['role'] } },
65
65
  { name: 'diagnose_job', description: 'Read-only diagnosis for a single workflow job: status, idle time, stream summary, escalation row, and structured findings with evidence.', read_safe: true, inputSchema: { type: 'object', properties: { workflow_id: { type: 'string' }, app_id: { type: 'string' }, max_events: { type: 'integer' }, include: { type: 'array', items: { type: 'string', enum: ['events', 'streams'] } }, verbosity: { type: 'string', enum: ['summary', 'full'] } }, required: ['workflow_id'] } },
@@ -1,2 +1,2 @@
1
- import{j as o}from"./vendor-query-B2UbickB.js";import{c as n}from"./tasks-DcSvF636.js";import{t as m}from"./index-Dgw1KKpq.js";import{f as c}from"./useEventHooks-DcIgMDh3.js";import{u}from"./mcp-D_-NQtnG.js";import{P as d}from"./PageHeaderWithStats-yex5WmHB.js";import"./vendor-react-CXumBFUA.js";import"./vendor-icons-CEWCGPeJ.js";function j(){var a;c();const{data:s}=n({limit:1}),{data:e}=m({status:"pending",limit:1}),{data:t}=u(),r=((a=t==null?void 0:t.servers)==null?void 0:a.filter(i=>i.status==="connected").length)??0,l=t?`${r}/${t.total}`:"—";return o.jsx("div",{children:o.jsx(d,{title:"Admin",stats:[{label:"Tasks",value:(s==null?void 0:s.total)??"—"},{label:"Pending Escalations",value:(e==null?void 0:e.total)??"—",dotClass:"bg-status-pending"},{label:"MCP Servers",value:l},{label:"System",value:"Healthy",dotClass:"bg-status-success"}]})})}export{j as AdminDashboard};
2
- //# sourceMappingURL=AdminDashboard-C9eE1VEp.js.map
1
+ import{j as o}from"./vendor-query-B2UbickB.js";import{c as n}from"./tasks-BPNj8ZWL.js";import{t as m}from"./index-BoZydcaW.js";import{f as c}from"./useEventHooks-BgdnN8Rj.js";import{u}from"./mcp-Cx9L42EN.js";import{P as d}from"./PageHeaderWithStats-CcVAji-7.js";import"./vendor-react-CXumBFUA.js";import"./vendor-icons-BaQqUm-e.js";function j(){var a;c();const{data:s}=n({limit:1}),{data:e}=m({status:"pending",limit:1}),{data:t}=u(),r=((a=t==null?void 0:t.servers)==null?void 0:a.filter(i=>i.status==="connected").length)??0,l=t?`${r}/${t.total}`:"—";return o.jsx("div",{children:o.jsx(d,{title:"Admin",stats:[{label:"Tasks",value:(s==null?void 0:s.total)??"—"},{label:"Pending Escalations",value:(e==null?void 0:e.total)??"—",dotClass:"bg-status-pending"},{label:"MCP Servers",value:l},{label:"System",value:"Healthy",dotClass:"bg-status-success"}]})})}export{j as AdminDashboard};
2
+ //# sourceMappingURL=AdminDashboard-Bgomc_jH.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AdminDashboard-C9eE1VEp.js","sources":["../../src/pages/admin/AdminDashboard.tsx"],"sourcesContent":["import { useTasks } from '../../api/tasks';\nimport { useEscalations } from '../../api/escalations';\nimport { useEscalationListEvents } from '../../hooks/useEventHooks';\nimport { useMcpServers } from '../../api/mcp';\nimport { PageHeaderWithStats } from '../../components/common/layout/PageHeaderWithStats';\n\nexport function AdminDashboard() {\n useEscalationListEvents();\n const { data: taskData } = useTasks({ limit: 1 });\n const { data: pendingEsc } = useEscalations({ status: 'pending', limit: 1 });\n const { data: mcpData } = useMcpServers();\n\n const connectedServers =\n mcpData?.servers?.filter((s) => s.status === 'connected').length ?? 0;\n const mcpLabel = mcpData ? `${connectedServers}/${mcpData.total}` : '—';\n\n return (\n <div>\n <PageHeaderWithStats\n title=\"Admin\"\n stats={[\n { label: 'Tasks', value: taskData?.total ?? '—' },\n { label: 'Pending Escalations', value: pendingEsc?.total ?? '—', dotClass: 'bg-status-pending' },\n { label: 'MCP Servers', value: mcpLabel },\n { label: 'System', value: 'Healthy', dotClass: 'bg-status-success' },\n ]}\n />\n </div>\n );\n}\n"],"names":["AdminDashboard","useEscalationListEvents","taskData","useTasks","pendingEsc","useEscalations","mcpData","useMcpServers","connectedServers","_a","s","mcpLabel","jsx","PageHeaderWithStats"],"mappings":"4UAMO,SAASA,GAAiB,OAC/BC,EAAA,EACA,KAAM,CAAE,KAAMC,CAAA,EAAaC,EAAS,CAAE,MAAO,EAAG,EAC1C,CAAE,KAAMC,CAAA,EAAeC,EAAe,CAAE,OAAQ,UAAW,MAAO,EAAG,EACrE,CAAE,KAAMC,CAAA,EAAYC,EAAA,EAEpBC,IACJC,EAAAH,GAAA,YAAAA,EAAS,UAAT,YAAAG,EAAkB,OAAQC,GAAMA,EAAE,SAAW,aAAa,SAAU,EAChEC,EAAWL,EAAU,GAAGE,CAAgB,IAAIF,EAAQ,KAAK,GAAK,IAEpE,aACG,MAAA,CACC,SAAAM,EAAAA,IAACC,EAAA,CACC,MAAM,QACN,MAAO,CACL,CAAE,MAAO,QAAS,OAAOX,GAAA,YAAAA,EAAU,QAAS,GAAA,EAC5C,CAAE,MAAO,sBAAuB,OAAOE,GAAA,YAAAA,EAAY,QAAS,IAAK,SAAU,mBAAA,EAC3E,CAAE,MAAO,cAAe,MAAOO,CAAA,EAC/B,CAAE,MAAO,SAAU,MAAO,UAAW,SAAU,mBAAA,CAAoB,CACrE,CAAA,EAEJ,CAEJ"}
1
+ {"version":3,"file":"AdminDashboard-Bgomc_jH.js","sources":["../../src/pages/admin/AdminDashboard.tsx"],"sourcesContent":["import { useTasks } from '../../api/tasks';\nimport { useEscalations } from '../../api/escalations';\nimport { useEscalationListEvents } from '../../hooks/useEventHooks';\nimport { useMcpServers } from '../../api/mcp';\nimport { PageHeaderWithStats } from '../../components/common/layout/PageHeaderWithStats';\n\nexport function AdminDashboard() {\n useEscalationListEvents();\n const { data: taskData } = useTasks({ limit: 1 });\n const { data: pendingEsc } = useEscalations({ status: 'pending', limit: 1 });\n const { data: mcpData } = useMcpServers();\n\n const connectedServers =\n mcpData?.servers?.filter((s) => s.status === 'connected').length ?? 0;\n const mcpLabel = mcpData ? `${connectedServers}/${mcpData.total}` : '—';\n\n return (\n <div>\n <PageHeaderWithStats\n title=\"Admin\"\n stats={[\n { label: 'Tasks', value: taskData?.total ?? '—' },\n { label: 'Pending Escalations', value: pendingEsc?.total ?? '—', dotClass: 'bg-status-pending' },\n { label: 'MCP Servers', value: mcpLabel },\n { label: 'System', value: 'Healthy', dotClass: 'bg-status-success' },\n ]}\n />\n </div>\n );\n}\n"],"names":["AdminDashboard","useEscalationListEvents","taskData","useTasks","pendingEsc","useEscalations","mcpData","useMcpServers","connectedServers","_a","s","mcpLabel","jsx","PageHeaderWithStats"],"mappings":"4UAMO,SAASA,GAAiB,OAC/BC,EAAA,EACA,KAAM,CAAE,KAAMC,CAAA,EAAaC,EAAS,CAAE,MAAO,EAAG,EAC1C,CAAE,KAAMC,CAAA,EAAeC,EAAe,CAAE,OAAQ,UAAW,MAAO,EAAG,EACrE,CAAE,KAAMC,CAAA,EAAYC,EAAA,EAEpBC,IACJC,EAAAH,GAAA,YAAAA,EAAS,UAAT,YAAAG,EAAkB,OAAQC,GAAMA,EAAE,SAAW,aAAa,SAAU,EAChEC,EAAWL,EAAU,GAAGE,CAAgB,IAAIF,EAAQ,KAAK,GAAK,IAEpE,aACG,MAAA,CACC,SAAAM,EAAAA,IAACC,EAAA,CACC,MAAM,QACN,MAAO,CACL,CAAE,MAAO,QAAS,OAAOX,GAAA,YAAAA,EAAU,QAAS,GAAA,EAC5C,CAAE,MAAO,sBAAuB,OAAOE,GAAA,YAAAA,EAAY,QAAS,IAAK,SAAU,mBAAA,EAC3E,CAAE,MAAO,cAAe,MAAOO,CAAA,EAC/B,CAAE,MAAO,SAAU,MAAO,UAAW,SAAU,mBAAA,CAAoB,CACrE,CAAA,EAEJ,CAEJ"}
@@ -1,6 +1,6 @@
1
- import{j as e,a as v}from"./vendor-query-B2UbickB.js";import{a as re,d as le,b as oe}from"./agents-tML6AjDj.js";import{E as ce,C as de,u as pe,a as xe,b as ue,c as me}from"./CronLabel-DLW4_Zg4.js";import{b as he,u as fe}from"./index-Dgw1KKpq.js";import{P as ve}from"./PageHeader-BhaWTWcM.js";import{B as O,e as U,t as be,R as Y,l as M,p as Z,a6 as G,b as V,aP as ee,V as ye}from"./vendor-icons-CEWCGPeJ.js";import{e as ge}from"./knowledge-CDzw4E6q.js";import{R as te}from"./RunAsSelector-DXbHRxQs.js";import{u as je}from"./workflows-CkPv7xk-.js";import{u as we}from"./yaml-workflows-BjrMQLTK.js";import{u as se}from"./capabilities-BGZogsi_.js";import{u as Ne}from"./topics-DI8TFSZv.js";import{W as Q}from"./WorkflowPill-IDjTRfQ8.js";import{e as _e,c as ke,f as Ce}from"./vendor-react-CXumBFUA.js";import"./BotPicker-3wBcBavT.js";import"./bots-Cb0WTwhY.js";const X={name:"",description:"",goals:"",rules:"",user_id:"",knowledge_domain:"",subscriptions:[],schedules:[]},Se={topic:"",filter:"",reaction_type:"durable",workflow_type:"",pipeline_id:"",mcp_prompt:"",server_id:"",tool_name:"",input_mapping:"{}",execute_as:"",enabled:!0},qe={cron:"0 * * * *",reaction_type:"durable",workflow_type:"",pipeline_id:"",server_id:"",tool_name:"",envelope:"{}",execute_as:""};function Re(s,a){var o,x,u;const r=(x=(o=s.behaviors)==null?void 0:o.schedules)!=null&&x.length?s.behaviors.schedules.map(n=>({cron:n.cron||"",reaction_type:n.reaction_type||"durable",workflow_type:n.workflow_type||"",pipeline_id:n.pipeline_id||"",server_id:n.server_id||"",tool_name:n.tool_name||"",envelope:n.envelope?JSON.stringify(n.envelope,null,2):"{}",execute_as:n.execute_as||""})):(u=s.behaviors)!=null&&u.cron?[{cron:s.behaviors.cron,reaction_type:"durable",workflow_type:s.workflow_type??"",pipeline_id:"",server_id:"",tool_name:"",envelope:"{}",execute_as:""}]:[];return{name:s.id,description:s.description??"",goals:s.goals??"",rules:s.rules??"",user_id:s.user_id??"",knowledge_domain:s.knowledge_domain??"",subscriptions:a.map(n=>({id:n.id,topic:n.topic,filter:n.filter?JSON.stringify(n.filter,null,2):"",reaction_type:n.reaction_type,workflow_type:n.workflow_type??"",pipeline_id:n.pipeline_id??"",mcp_prompt:n.mcp_prompt??"",server_id:n.server_id??"",tool_name:n.tool_name??"",input_mapping:JSON.stringify(n.input_mapping??{},null,2),execute_as:n.execute_as??"",enabled:n.enabled})),schedules:r}}function Ae(s){var r;const a={};return s.schedules.length>0&&(a.schedules=s.schedules.map(o=>({cron:o.cron,reaction_type:o.reaction_type||"durable",workflow_type:o.reaction_type==="pipeline"?void 0:o.workflow_type,pipeline_id:o.reaction_type==="pipeline"?o.pipeline_id:void 0,envelope:B(o.envelope)??{},execute_as:o.execute_as||void 0})),a.cron=s.schedules[0].cron),{id:s.name,description:s.description||void 0,goals:s.goals||void 0,rules:s.rules||void 0,user_id:s.user_id||void 0,knowledge_domain:s.knowledge_domain||void 0,behaviors:a,workflow_type:((r=s.schedules[0])==null?void 0:r.workflow_type)||void 0,pipeline_id:void 0}}function Oe(s){return s.subscriptions.map(a=>({id:a.id,topic:a.topic,filter:a.filter?B(a.filter):void 0,reaction_type:a.reaction_type,workflow_type:a.workflow_type||void 0,pipeline_id:a.pipeline_id||void 0,mcp_prompt:a.mcp_prompt||void 0,server_id:a.server_id||void 0,tool_name:a.tool_name||void 0,input_mapping:B(a.input_mapping)??{},execute_as:a.execute_as||void 0,enabled:a.enabled}))}function B(s){if(s.trim())try{return JSON.parse(s)}catch{return}}function Ee(s,a,r,o){let x;try{x=JSON.parse(s)}catch{x={}}const u=o.includes(a),n=r===""||r===void 0||r===null||Array.isArray(r)&&r.length===0||r==="[]";if(!u&&n){const{[a]:p,...c}=x;return JSON.stringify(c,null,2)}let h=r;if(typeof r=="string")try{const p=JSON.parse(r);Array.isArray(p)&&(h=p)}catch{}return JSON.stringify({...x,[a]:h},null,2)}const S="section-header mt-[3em] first:mt-0",P="label",_="hint",R="input",L="input-json w-full";function Pe({form:s,set:a}){return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"border-l-2 border-accent/30 pl-3 py-1 flex items-start justify-between",children:[e.jsx("p",{className:"text-[12px] text-text-secondary italic leading-relaxed",children:"Give your automation a name and describe what it does. The name appears everywhere — in events, logs, and the dashboard."}),e.jsx("button",{onClick:()=>{window.location.hash="#docs:agents.md:identity"},className:"text-text-quaternary hover:text-accent transition-colors shrink-0 ml-3",title:"Docs: Identity",children:e.jsx(O,{className:"w-3 h-3",strokeWidth:1.5})})]}),e.jsxs("div",{children:[e.jsx("label",{className:P,children:"Name *"}),e.jsx("input",{type:"text",value:s.name,onChange:r=>a("name",r.target.value),placeholder:"health-monitor",className:R}),e.jsx("p",{className:_,children:"Lowercase, kebab-case. This appears everywhere."})]}),e.jsxs("div",{children:[e.jsx("label",{className:P,children:"Description"}),e.jsx("input",{type:"text",value:s.description,onChange:r=>a("description",r.target.value),placeholder:"Watches for workflow failures and captures diagnostics",className:R}),e.jsx("p",{className:_,children:"One sentence that explains what this automation does."})]})]})}function $e({form:s,set:a}){return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"border-l-2 border-accent/30 pl-3 py-1 flex items-start justify-between",children:[e.jsx("p",{className:"text-[12px] text-text-secondary italic leading-relaxed",children:"Goals define what drives the automation. Rules define what constrains it."}),e.jsx("button",{onClick:()=>{window.location.hash="#docs:agents.md:motivation"},className:"text-text-quaternary hover:text-accent transition-colors shrink-0 ml-3",title:"Docs: Motivation",children:e.jsx(O,{className:"w-3 h-3",strokeWidth:1.5})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-8",children:[e.jsxs("div",{children:[e.jsx("label",{className:P,children:"Goals"}),e.jsx("textarea",{value:s.goals,onChange:r=>a("goals",r.target.value),placeholder:"Detect failures early, capture diagnostics, alert before cascading",rows:4,className:`${R} resize-none`}),e.jsx("p",{className:_,children:"Primary motivation. What the automation is trying to achieve."})]}),e.jsxs("div",{children:[e.jsx("label",{className:P,children:"Rules"}),e.jsx("textarea",{value:s.rules,onChange:r=>a("rules",r.target.value),placeholder:"Never auto-restart failed workflows. Always escalate to humans.",rows:4,className:`${R} resize-none`}),e.jsx("p",{className:_,children:"Guardrails. What it must never do, even when goals suggest it should."})]})]})]})}function Ie({form:s,set:a}){const{data:r}=ge(),o=(r==null?void 0:r.domains)??[];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"border-l-2 border-accent/30 pl-3 py-1 flex items-start justify-between",children:[e.jsx("p",{className:"text-[12px] text-text-secondary italic leading-relaxed",children:"Assign a knowledge domain — the automation's memory. It stores context here over time."}),e.jsx("button",{onClick:()=>{window.location.hash="#docs:agents.md:knowledge"},className:"text-text-quaternary hover:text-accent transition-colors shrink-0 ml-3",title:"Docs: Knowledge",children:e.jsx(O,{className:"w-3 h-3",strokeWidth:1.5})})]}),e.jsxs("div",{children:[e.jsx("label",{className:P,children:"Knowledge Domain"}),e.jsx("input",{type:"text",value:s.knowledge_domain,onChange:x=>a("knowledge_domain",x.target.value),placeholder:"e.g., system-health, content-review, vendor-data",className:R,list:"domain-suggestions"}),e.jsx("datalist",{id:"domain-suggestions",children:o.map(x=>e.jsx("option",{value:x.domain},x.domain))}),e.jsx("p",{className:_,children:"Choose an existing domain to share memory, or type a new name to create one."})]}),o.length>0&&e.jsxs("div",{children:[e.jsx("label",{className:P,children:"Existing Domains"}),e.jsx("div",{className:"space-y-0.5 mt-2",children:o.map(x=>e.jsxs("button",{type:"button",onClick:()=>a("knowledge_domain",x.domain),className:`w-full flex items-center gap-3 px-3 py-2 rounded-md text-left transition-colors ${s.knowledge_domain===x.domain?"border-l-2 border-l-accent bg-accent/5":"hover:bg-surface-hover border-l-2 border-l-transparent"}`,children:[e.jsx(U,{className:"w-3.5 h-3.5 text-text-quaternary shrink-0",strokeWidth:1.5}),e.jsx("span",{className:"text-sm text-text-primary flex-1",children:x.domain}),e.jsxs("span",{className:"text-[10px] text-text-quaternary",children:[x.count," entries"]}),e.jsx("span",{className:"text-[9px] text-text-quaternary",children:e.jsx(he,{date:x.latest})})]},x.domain))})]})]})}function We({serverId:s,toolName:a,onChange:r}){const{data:o}=se(),x=v.useMemo(()=>{var t;return((t=o==null?void 0:o.categories)==null?void 0:t.flatMap(i=>i.tools))??[]},[o]),[u,n]=v.useState(!1),[h,p]=v.useState(""),c=v.useRef(null),f=v.useRef(null);v.useEffect(()=>{if(!u)return;function t(i){f.current&&!f.current.contains(i.target)&&n(!1)}return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[u]);const l=a?`${a}`:"",d=u?h:l,y=v.useMemo(()=>{const t=(u?h:"").toLowerCase();return t?x.filter(i=>i.name.toLowerCase().includes(t)||i.serverName.toLowerCase().includes(t)||(i.description??"").toLowerCase().includes(t)):x},[x,h,u]),m=a?x.find(t=>t.serverId===s&&t.name===a):void 0;return e.jsxs("div",{ref:f,className:"relative",children:[e.jsx("input",{ref:c,type:"text",value:d,onFocus:()=>{n(!0),p(l)},onChange:t=>{const i=t.target.value;p(i),i||r("",""),u||n(!0)},placeholder:"Search capabilities...",className:"input font-mono text-sm w-full"}),!u&&(m==null?void 0:m.description)&&e.jsx("p",{className:"text-[10px] text-text-tertiary mt-1 italic",children:m.description}),u&&y.length>0&&e.jsx("div",{className:"absolute z-50 left-0 right-0 mt-1 max-h-64 overflow-y-auto rounded-md border border-surface-border bg-surface shadow-lg",children:y.map(t=>e.jsxs("button",{type:"button",onClick:()=>{r(t.serverId,t.name),p(t.name),n(!1)},className:`w-full text-left px-3 py-2 hover:bg-surface-hover transition-colors flex items-center gap-3 ${s===t.serverId&&a===t.name?"bg-accent/5":""}`,children:[e.jsx("span",{className:"text-[11px] font-mono text-text-primary shrink-0",children:t.name}),e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[9px] font-medium shrink-0 bg-accent/10 text-accent",children:[e.jsx(be,{className:"w-2 h-2",strokeWidth:1.5}),t.serverName]}),t.description&&e.jsx("span",{className:"text-[10px] text-text-quaternary truncate",children:t.description})]},`${t.serverId}:${t.name}`))}),u&&y.length===0&&h&&e.jsx("div",{className:"absolute z-50 left-0 right-0 mt-1 rounded-md border border-surface-border bg-surface shadow-lg px-3 py-4 text-center",children:e.jsxs("p",{className:"text-[11px] text-text-quaternary",children:['No capabilities match "',h,'"']})})]})}const Te={durable:"Workflow",pipeline:"Pipeline",capability:"Capability",mcp_query:"MCP Query"},Me=["durable","pipeline","capability","mcp_query"];function ae({reactionType:s,onReactionTypeChange:a,workflowType:r,onWorkflowTypeChange:o,pipelineId:x,onPipelineIdChange:u,serverId:n,toolName:h,onCapabilityChange:p,mcpPrompt:c,onMcpPromptChange:f,availableTypes:l=[...Me]}){const{data:d}=je(),y=(d??[]).filter(i=>i.invocable).map(i=>i.workflow_type),{data:m}=we({status:"active"}),t=((m==null?void 0:m.workflows)??[]).map(i=>({id:i.id,name:i.graph_topic||i.id}));return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex gap-1",children:l.map(i=>{const b=s===i;return e.jsx("button",{type:"button",onClick:()=>a(i),className:`px-3 py-1.5 text-[11px] font-medium rounded-md transition-colors ${b?"bg-accent/10 text-accent":"text-text-tertiary hover:text-text-primary hover:bg-surface-hover"}`,children:Te[i]},i)})}),s==="durable"&&e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Workflow *"}),e.jsxs("select",{value:r,onChange:i=>o(i.target.value),className:"input",children:[e.jsx("option",{value:"",children:"Select workflow..."}),y.map(i=>e.jsx("option",{value:i,children:i},i))]})]}),s==="pipeline"&&e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Pipeline *"}),e.jsxs("select",{value:x,onChange:i=>u(i.target.value),className:"input",children:[e.jsx("option",{value:"",children:"Select pipeline..."}),t.map(i=>e.jsx("option",{value:i.id,children:i.name},i.id))]})]}),s==="capability"&&e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Capability *"}),e.jsx(We,{serverId:n,toolName:h,onChange:p})]}),s==="mcp_query"&&f&&e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Prompt *"}),e.jsx("textarea",{value:c??"",onChange:i=>f(i.target.value),placeholder:"Analyze the error and suggest remediation...",rows:3,className:"input resize-none"})]})]})}const Le={task:"bg-blue-400/15 text-blue-400",workflow:"bg-accent/15 text-accent",escalation:"bg-amber-400/15 text-amber-400",activity:"bg-cyan-400/15 text-cyan-400",knowledge:"bg-violet-400/15 text-violet-400",file:"bg-orange-400/15 text-orange-400",agent:"bg-emerald-400/15 text-emerald-400",app:"bg-rose-400/15 text-rose-400",milestone:"bg-violet-400/15 text-violet-400"};function Je({form:s,set:a}){const{data:r}=Ne({limit:200}),{data:o}=se(),x=(r==null?void 0:r.topics)??[],u=v.useMemo(()=>{var t;return((t=o==null?void 0:o.categories)==null?void 0:t.flatMap(i=>i.tools))??[]},[o]),[n,h]=v.useState(0),p=(t,i,b)=>{const g=[...s.subscriptions];g[t]={...g[t],[i]:b},a("subscriptions",g)},c=()=>{a("subscriptions",[...s.subscriptions,{...Se}]),h(s.subscriptions.length)},f=t=>{a("subscriptions",s.subscriptions.filter((i,b)=>b!==t)),n>=s.subscriptions.length-1&&h(Math.max(0,s.subscriptions.length-2))},l=s.subscriptions,d=l[n],y=t=>t.topic?t.reaction_type==="durable"?!!t.workflow_type:t.reaction_type==="pipeline"?!!t.pipeline_id:t.reaction_type==="mcp_query"?!!t.mcp_prompt:t.reaction_type==="capability"?!!t.server_id&&!!t.tool_name:!1:!1,m=d?x.find(t=>t.topic===d.topic):void 0;return l.length===0?e.jsxs("div",{className:"max-w-xl",children:[e.jsxs("div",{className:"border-l-2 border-accent/30 pl-3 py-1 flex items-start justify-between mb-8",children:[e.jsx("p",{className:"text-[12px] text-text-secondary italic leading-relaxed",children:"Optional. When a matching event is published, the automation runs the configured workflow with the event payload."}),e.jsx("button",{onClick:()=>{window.location.hash="#docs:agents.md:subscriptions"},className:"text-text-quaternary hover:text-accent transition-colors shrink-0 ml-3",title:"Docs: Subscriptions",children:e.jsx(O,{className:"w-3 h-3",strokeWidth:1.5})})]}),e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Y,{className:"w-8 h-8 text-text-quaternary/40 mb-3",strokeWidth:1}),e.jsx("p",{className:"text-sm text-text-tertiary mb-2",children:"No event subscriptions yet"}),e.jsx("p",{className:"text-[11px] text-text-quaternary max-w-sm mb-6",children:"Each subscription listens for a topic pattern and runs a workflow when it matches."}),e.jsxs("button",{onClick:c,className:"flex items-center gap-2 text-xs text-accent hover:text-accent-hover transition-colors",children:[e.jsx(M,{className:"w-3.5 h-3.5"})," Add first subscription"]})]})]}):e.jsxs("div",{children:[e.jsxs("div",{className:"border-l-2 border-accent/30 pl-3 py-1 flex items-start justify-between mb-6",children:[e.jsx("p",{className:"text-[12px] text-text-secondary italic leading-relaxed",children:"Optional. When a matching event is published, the automation runs the configured workflow with the event payload."}),e.jsx("button",{onClick:()=>{window.location.hash="#docs:agents.md:subscriptions"},className:"text-text-quaternary hover:text-accent transition-colors shrink-0 ml-3",title:"Docs: Subscriptions",children:e.jsx(O,{className:"w-3 h-3",strokeWidth:1.5})})]}),e.jsxs("div",{className:"flex gap-8",children:[e.jsxs("div",{className:"w-52 shrink-0 space-y-0.5",children:[l.map((t,i)=>e.jsxs("div",{className:`group/sub flex items-center rounded-md transition-colors ${n===i?"bg-accent/10 text-accent":"text-text-tertiary hover:text-text-primary hover:bg-surface-hover"}`,children:[e.jsxs("button",{onClick:()=>h(i),className:"flex-1 text-left px-3 py-2 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${y(t)?"bg-emerald-400":"bg-zinc-500"}`}),e.jsx("span",{className:"text-[11px] font-mono truncate",children:t.topic||"new subscription"})]}),e.jsxs("span",{className:"text-[9px] text-text-quaternary ml-3",children:["→ ",t.workflow_type||t.tool_name||t.reaction_type]})]}),e.jsx("button",{onClick:b=>{b.stopPropagation(),confirm(`Remove subscription "${t.topic||"new"}"?
1
+ import{j as e,a as v}from"./vendor-query-B2UbickB.js";import{a as re,d as le,b as oe}from"./agents-27sErp5R.js";import{E as ce,C as de,u as pe,a as xe,b as ue,c as me}from"./CronLabel-CtjUBRPo.js";import{b as he,u as fe}from"./index-BoZydcaW.js";import{P as ve}from"./PageHeader-CFta2VaS.js";import{B as A,e as U,t as be,R as Y,l as M,p as Z,a6 as G,b as V,aO as ee,V as ye}from"./vendor-icons-BaQqUm-e.js";import{e as ge}from"./knowledge-BErJA3Je.js";import{R as te}from"./RunAsSelector-CokM3Ifp.js";import{u as je}from"./workflows-Dps45zjk.js";import{u as we}from"./yaml-workflows-DhlTkbvY.js";import{u as se}from"./capabilities-BBTPqF-V.js";import{u as Ne}from"./topics-CR4UBuSV.js";import{W as Q}from"./WorkflowPill-BegV-iRF.js";import{e as _e,c as ke,f as Ce}from"./vendor-react-CXumBFUA.js";import"./BotPicker-MnI3OyE7.js";import"./bots-CPHuAvjW.js";const X={name:"",description:"",goals:"",rules:"",user_id:"",knowledge_domain:"",subscriptions:[],schedules:[]},Se={topic:"",filter:"",reaction_type:"durable",workflow_type:"",pipeline_id:"",mcp_prompt:"",server_id:"",tool_name:"",input_mapping:"{}",execute_as:"",enabled:!0},qe={cron:"0 * * * *",reaction_type:"durable",workflow_type:"",pipeline_id:"",server_id:"",tool_name:"",envelope:"{}",execute_as:""};function Oe(s,a){var o,x,u;const r=(x=(o=s.behaviors)==null?void 0:o.schedules)!=null&&x.length?s.behaviors.schedules.map(n=>({cron:n.cron||"",reaction_type:n.reaction_type||"durable",workflow_type:n.workflow_type||"",pipeline_id:n.pipeline_id||"",server_id:n.server_id||"",tool_name:n.tool_name||"",envelope:n.envelope?JSON.stringify(n.envelope,null,2):"{}",execute_as:n.execute_as||""})):(u=s.behaviors)!=null&&u.cron?[{cron:s.behaviors.cron,reaction_type:"durable",workflow_type:s.workflow_type??"",pipeline_id:"",server_id:"",tool_name:"",envelope:"{}",execute_as:""}]:[];return{name:s.id,description:s.description??"",goals:s.goals??"",rules:s.rules??"",user_id:s.user_id??"",knowledge_domain:s.knowledge_domain??"",subscriptions:a.map(n=>({id:n.id,topic:n.topic,filter:n.filter?JSON.stringify(n.filter,null,2):"",reaction_type:n.reaction_type,workflow_type:n.workflow_type??"",pipeline_id:n.pipeline_id??"",mcp_prompt:n.mcp_prompt??"",server_id:n.server_id??"",tool_name:n.tool_name??"",input_mapping:JSON.stringify(n.input_mapping??{},null,2),execute_as:n.execute_as??"",enabled:n.enabled})),schedules:r}}function Re(s){var r;const a={};return s.schedules.length>0&&(a.schedules=s.schedules.map(o=>({cron:o.cron,reaction_type:o.reaction_type||"durable",workflow_type:o.reaction_type==="pipeline"?void 0:o.workflow_type,pipeline_id:o.reaction_type==="pipeline"?o.pipeline_id:void 0,envelope:B(o.envelope)??{},execute_as:o.execute_as||void 0})),a.cron=s.schedules[0].cron),{id:s.name,description:s.description||void 0,goals:s.goals||void 0,rules:s.rules||void 0,user_id:s.user_id||void 0,knowledge_domain:s.knowledge_domain||void 0,behaviors:a,workflow_type:((r=s.schedules[0])==null?void 0:r.workflow_type)||void 0,pipeline_id:void 0}}function Ae(s){return s.subscriptions.map(a=>({id:a.id,topic:a.topic,filter:a.filter?B(a.filter):void 0,reaction_type:a.reaction_type,workflow_type:a.workflow_type||void 0,pipeline_id:a.pipeline_id||void 0,mcp_prompt:a.mcp_prompt||void 0,server_id:a.server_id||void 0,tool_name:a.tool_name||void 0,input_mapping:B(a.input_mapping)??{},execute_as:a.execute_as||void 0,enabled:a.enabled}))}function B(s){if(s.trim())try{return JSON.parse(s)}catch{return}}function Ee(s,a,r,o){let x;try{x=JSON.parse(s)}catch{x={}}const u=o.includes(a),n=r===""||r===void 0||r===null||Array.isArray(r)&&r.length===0||r==="[]";if(!u&&n){const{[a]:p,...c}=x;return JSON.stringify(c,null,2)}let h=r;if(typeof r=="string")try{const p=JSON.parse(r);Array.isArray(p)&&(h=p)}catch{}return JSON.stringify({...x,[a]:h},null,2)}const S="section-header mt-[3em] first:mt-0",$="label",_="hint",O="input",L="input-json w-full";function $e({form:s,set:a}){return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"border-l-2 border-accent/30 pl-3 py-1 flex items-start justify-between",children:[e.jsx("p",{className:"text-[12px] text-text-secondary italic leading-relaxed",children:"Give your automation a name and describe what it does. The name appears everywhere — in events, logs, and the dashboard."}),e.jsx("button",{onClick:()=>{window.location.hash="#docs:agents.md:identity"},className:"text-text-quaternary hover:text-accent transition-colors shrink-0 ml-3",title:"Docs: Identity",children:e.jsx(A,{className:"w-3 h-3",strokeWidth:1.5})})]}),e.jsxs("div",{children:[e.jsx("label",{className:$,children:"Name *"}),e.jsx("input",{type:"text",value:s.name,onChange:r=>a("name",r.target.value),placeholder:"health-monitor",className:O}),e.jsx("p",{className:_,children:"Lowercase, kebab-case. This appears everywhere."})]}),e.jsxs("div",{children:[e.jsx("label",{className:$,children:"Description"}),e.jsx("input",{type:"text",value:s.description,onChange:r=>a("description",r.target.value),placeholder:"Watches for workflow failures and captures diagnostics",className:O}),e.jsx("p",{className:_,children:"One sentence that explains what this automation does."})]})]})}function Pe({form:s,set:a}){return e.jsxs("div",{className:"space-y-8",children:[e.jsxs("div",{className:"border-l-2 border-accent/30 pl-3 py-1 flex items-start justify-between",children:[e.jsx("p",{className:"text-[12px] text-text-secondary italic leading-relaxed",children:"Goals define what drives the automation. Rules define what constrains it."}),e.jsx("button",{onClick:()=>{window.location.hash="#docs:agents.md:motivation"},className:"text-text-quaternary hover:text-accent transition-colors shrink-0 ml-3",title:"Docs: Motivation",children:e.jsx(A,{className:"w-3 h-3",strokeWidth:1.5})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-8",children:[e.jsxs("div",{children:[e.jsx("label",{className:$,children:"Goals"}),e.jsx("textarea",{value:s.goals,onChange:r=>a("goals",r.target.value),placeholder:"Detect failures early, capture diagnostics, alert before cascading",rows:4,className:`${O} resize-none`}),e.jsx("p",{className:_,children:"Primary motivation. What the automation is trying to achieve."})]}),e.jsxs("div",{children:[e.jsx("label",{className:$,children:"Rules"}),e.jsx("textarea",{value:s.rules,onChange:r=>a("rules",r.target.value),placeholder:"Never auto-restart failed workflows. Always escalate to humans.",rows:4,className:`${O} resize-none`}),e.jsx("p",{className:_,children:"Guardrails. What it must never do, even when goals suggest it should."})]})]})]})}function Ie({form:s,set:a}){const{data:r}=ge(),o=(r==null?void 0:r.domains)??[];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"border-l-2 border-accent/30 pl-3 py-1 flex items-start justify-between",children:[e.jsx("p",{className:"text-[12px] text-text-secondary italic leading-relaxed",children:"Assign a knowledge domain — the automation's memory. It stores context here over time."}),e.jsx("button",{onClick:()=>{window.location.hash="#docs:agents.md:knowledge"},className:"text-text-quaternary hover:text-accent transition-colors shrink-0 ml-3",title:"Docs: Knowledge",children:e.jsx(A,{className:"w-3 h-3",strokeWidth:1.5})})]}),e.jsxs("div",{children:[e.jsx("label",{className:$,children:"Knowledge Domain"}),e.jsx("input",{type:"text",value:s.knowledge_domain,onChange:x=>a("knowledge_domain",x.target.value),placeholder:"e.g., system-health, content-review, vendor-data",className:O,list:"domain-suggestions"}),e.jsx("datalist",{id:"domain-suggestions",children:o.map(x=>e.jsx("option",{value:x.domain},x.domain))}),e.jsx("p",{className:_,children:"Choose an existing domain to share memory, or type a new name to create one."})]}),o.length>0&&e.jsxs("div",{children:[e.jsx("label",{className:$,children:"Existing Domains"}),e.jsx("div",{className:"space-y-0.5 mt-2",children:o.map(x=>e.jsxs("button",{type:"button",onClick:()=>a("knowledge_domain",x.domain),className:`w-full flex items-center gap-3 px-3 py-2 rounded-md text-left transition-colors ${s.knowledge_domain===x.domain?"border-l-2 border-l-accent bg-accent/5":"hover:bg-surface-hover border-l-2 border-l-transparent"}`,children:[e.jsx(U,{className:"w-3.5 h-3.5 text-text-quaternary shrink-0",strokeWidth:1.5}),e.jsx("span",{className:"text-sm text-text-primary flex-1",children:x.domain}),e.jsxs("span",{className:"text-[10px] text-text-quaternary",children:[x.count," entries"]}),e.jsx("span",{className:"text-[9px] text-text-quaternary",children:e.jsx(he,{date:x.latest})})]},x.domain))})]})]})}function We({serverId:s,toolName:a,onChange:r}){const{data:o}=se(),x=v.useMemo(()=>{var t;return((t=o==null?void 0:o.categories)==null?void 0:t.flatMap(i=>i.tools))??[]},[o]),[u,n]=v.useState(!1),[h,p]=v.useState(""),c=v.useRef(null),f=v.useRef(null);v.useEffect(()=>{if(!u)return;function t(i){f.current&&!f.current.contains(i.target)&&n(!1)}return document.addEventListener("mousedown",t),()=>document.removeEventListener("mousedown",t)},[u]);const l=a?`${a}`:"",d=u?h:l,y=v.useMemo(()=>{const t=(u?h:"").toLowerCase();return t?x.filter(i=>i.name.toLowerCase().includes(t)||i.serverName.toLowerCase().includes(t)||(i.description??"").toLowerCase().includes(t)):x},[x,h,u]),m=a?x.find(t=>t.serverId===s&&t.name===a):void 0;return e.jsxs("div",{ref:f,className:"relative",children:[e.jsx("input",{ref:c,type:"text",value:d,onFocus:()=>{n(!0),p(l)},onChange:t=>{const i=t.target.value;p(i),i||r("",""),u||n(!0)},placeholder:"Search capabilities...",className:"input font-mono text-sm w-full"}),!u&&(m==null?void 0:m.description)&&e.jsx("p",{className:"text-[10px] text-text-tertiary mt-1 italic",children:m.description}),u&&y.length>0&&e.jsx("div",{className:"absolute z-50 left-0 right-0 mt-1 max-h-64 overflow-y-auto rounded-md border border-surface-border bg-surface shadow-lg",children:y.map(t=>e.jsxs("button",{type:"button",onClick:()=>{r(t.serverId,t.name),p(t.name),n(!1)},className:`w-full text-left px-3 py-2 hover:bg-surface-hover transition-colors flex items-center gap-3 ${s===t.serverId&&a===t.name?"bg-accent/5":""}`,children:[e.jsx("span",{className:"text-[11px] font-mono text-text-primary shrink-0",children:t.name}),e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[9px] font-medium shrink-0 bg-accent/10 text-accent",children:[e.jsx(be,{className:"w-2 h-2",strokeWidth:1.5}),t.serverName]}),t.description&&e.jsx("span",{className:"text-[10px] text-text-quaternary truncate",children:t.description})]},`${t.serverId}:${t.name}`))}),u&&y.length===0&&h&&e.jsx("div",{className:"absolute z-50 left-0 right-0 mt-1 rounded-md border border-surface-border bg-surface shadow-lg px-3 py-4 text-center",children:e.jsxs("p",{className:"text-[11px] text-text-quaternary",children:['No capabilities match "',h,'"']})})]})}const Te={durable:"Workflow",pipeline:"Pipeline",capability:"Capability",mcp_query:"MCP Query"},Me=["durable","pipeline","capability","mcp_query"];function ae({reactionType:s,onReactionTypeChange:a,workflowType:r,onWorkflowTypeChange:o,pipelineId:x,onPipelineIdChange:u,serverId:n,toolName:h,onCapabilityChange:p,mcpPrompt:c,onMcpPromptChange:f,availableTypes:l=[...Me]}){const{data:d}=je(),y=(d??[]).filter(i=>i.invocable).map(i=>i.workflow_type),{data:m}=we({status:"active"}),t=((m==null?void 0:m.workflows)??[]).map(i=>({id:i.id,name:i.graph_topic||i.id}));return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex gap-1",children:l.map(i=>{const b=s===i;return e.jsx("button",{type:"button",onClick:()=>a(i),className:`px-3 py-1.5 text-[11px] font-medium rounded-md transition-colors ${b?"bg-accent/10 text-accent":"text-text-tertiary hover:text-text-primary hover:bg-surface-hover"}`,children:Te[i]},i)})}),s==="durable"&&e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Workflow *"}),e.jsxs("select",{value:r,onChange:i=>o(i.target.value),className:"input",children:[e.jsx("option",{value:"",children:"Select workflow..."}),y.map(i=>e.jsx("option",{value:i,children:i},i))]})]}),s==="pipeline"&&e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Pipeline *"}),e.jsxs("select",{value:x,onChange:i=>u(i.target.value),className:"input",children:[e.jsx("option",{value:"",children:"Select pipeline..."}),t.map(i=>e.jsx("option",{value:i.id,children:i.name},i.id))]})]}),s==="capability"&&e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Capability *"}),e.jsx(We,{serverId:n,toolName:h,onChange:p})]}),s==="mcp_query"&&f&&e.jsxs("div",{children:[e.jsx("label",{className:"label",children:"Prompt *"}),e.jsx("textarea",{value:c??"",onChange:i=>f(i.target.value),placeholder:"Analyze the error and suggest remediation...",rows:3,className:"input resize-none"})]})]})}const Le={task:"bg-blue-400/15 text-blue-400",workflow:"bg-accent/15 text-accent",escalation:"bg-amber-400/15 text-amber-400",activity:"bg-cyan-400/15 text-cyan-400",knowledge:"bg-violet-400/15 text-violet-400",file:"bg-orange-400/15 text-orange-400",agent:"bg-emerald-400/15 text-emerald-400",app:"bg-rose-400/15 text-rose-400",milestone:"bg-violet-400/15 text-violet-400"};function Je({form:s,set:a}){const{data:r}=Ne({limit:200}),{data:o}=se(),x=(r==null?void 0:r.topics)??[],u=v.useMemo(()=>{var t;return((t=o==null?void 0:o.categories)==null?void 0:t.flatMap(i=>i.tools))??[]},[o]),[n,h]=v.useState(0),p=(t,i,b)=>{const g=[...s.subscriptions];g[t]={...g[t],[i]:b},a("subscriptions",g)},c=()=>{a("subscriptions",[...s.subscriptions,{...Se}]),h(s.subscriptions.length)},f=t=>{a("subscriptions",s.subscriptions.filter((i,b)=>b!==t)),n>=s.subscriptions.length-1&&h(Math.max(0,s.subscriptions.length-2))},l=s.subscriptions,d=l[n],y=t=>t.topic?t.reaction_type==="durable"?!!t.workflow_type:t.reaction_type==="pipeline"?!!t.pipeline_id:t.reaction_type==="mcp_query"?!!t.mcp_prompt:t.reaction_type==="capability"?!!t.server_id&&!!t.tool_name:!1:!1,m=d?x.find(t=>t.topic===d.topic):void 0;return l.length===0?e.jsxs("div",{className:"max-w-xl",children:[e.jsxs("div",{className:"border-l-2 border-accent/30 pl-3 py-1 flex items-start justify-between mb-8",children:[e.jsx("p",{className:"text-[12px] text-text-secondary italic leading-relaxed",children:"Optional. When a matching event is published, the automation runs the configured workflow with the event payload."}),e.jsx("button",{onClick:()=>{window.location.hash="#docs:agents.md:subscriptions"},className:"text-text-quaternary hover:text-accent transition-colors shrink-0 ml-3",title:"Docs: Subscriptions",children:e.jsx(A,{className:"w-3 h-3",strokeWidth:1.5})})]}),e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(Y,{className:"w-8 h-8 text-text-quaternary/40 mb-3",strokeWidth:1}),e.jsx("p",{className:"text-sm text-text-tertiary mb-2",children:"No event subscriptions yet"}),e.jsx("p",{className:"text-[11px] text-text-quaternary max-w-sm mb-6",children:"Each subscription listens for a topic pattern and runs a workflow when it matches."}),e.jsxs("button",{onClick:c,className:"flex items-center gap-2 text-xs text-accent hover:text-accent-hover transition-colors",children:[e.jsx(M,{className:"w-3.5 h-3.5"})," Add first subscription"]})]})]}):e.jsxs("div",{children:[e.jsxs("div",{className:"border-l-2 border-accent/30 pl-3 py-1 flex items-start justify-between mb-6",children:[e.jsx("p",{className:"text-[12px] text-text-secondary italic leading-relaxed",children:"Optional. When a matching event is published, the automation runs the configured workflow with the event payload."}),e.jsx("button",{onClick:()=>{window.location.hash="#docs:agents.md:subscriptions"},className:"text-text-quaternary hover:text-accent transition-colors shrink-0 ml-3",title:"Docs: Subscriptions",children:e.jsx(A,{className:"w-3 h-3",strokeWidth:1.5})})]}),e.jsxs("div",{className:"flex gap-8",children:[e.jsxs("div",{className:"w-52 shrink-0 space-y-0.5",children:[l.map((t,i)=>e.jsxs("div",{className:`group/sub flex items-center rounded-md transition-colors ${n===i?"bg-accent/10 text-accent":"text-text-tertiary hover:text-text-primary hover:bg-surface-hover"}`,children:[e.jsxs("button",{onClick:()=>h(i),className:"flex-1 text-left px-3 py-2 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${y(t)?"bg-emerald-400":"bg-zinc-500"}`}),e.jsx("span",{className:"text-[11px] font-mono truncate",children:t.topic||"new subscription"})]}),e.jsxs("span",{className:"text-[9px] text-text-quaternary ml-3",children:["→ ",t.workflow_type||t.tool_name||t.reaction_type]})]}),e.jsx("button",{onClick:b=>{b.stopPropagation(),confirm(`Remove subscription "${t.topic||"new"}"?
2
2
 
3
- This takes effect when you save.`)&&f(i)},className:"opacity-0 group-hover/sub:opacity-100 px-2 text-text-quaternary hover:text-red-400 transition-all",title:"Remove",children:e.jsx(Z,{className:"w-3 h-3"})})]},i)),e.jsxs("button",{onClick:c,className:"w-full flex items-center gap-1.5 px-3 py-2 text-[11px] text-accent hover:text-accent-hover transition-colors",children:[e.jsx(M,{className:"w-3 h-3"})," Add"]})]}),d&&e.jsxs("div",{className:"flex-1 min-w-0 space-y-12",children:[e.jsxs("div",{children:[e.jsx("label",{className:S,children:"When this event fires"}),e.jsx(ze,{value:d.topic,onChange:t=>p(n,"topic",t),topics:x}),(m==null?void 0:m.payload_schema)&&e.jsxs("div",{className:"mt-3 p-3 rounded-md bg-surface-sunken border border-surface-border",children:[e.jsx("p",{className:"text-[10px] text-text-quaternary mb-1 uppercase tracking-wider font-medium",children:"Payload Schema"}),e.jsx("pre",{className:"text-[11px] font-mono text-text-secondary whitespace-pre-wrap overflow-x-auto max-h-40",children:JSON.stringify(m.payload_schema.properties??m.payload_schema,null,2)}),m.description&&e.jsx("p",{className:"text-[10px] text-text-tertiary mt-2 italic",children:m.description})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:S,children:"Run this reaction"}),e.jsx(ae,{reactionType:d.reaction_type,onReactionTypeChange:t=>p(n,"reaction_type",t),workflowType:d.workflow_type,onWorkflowTypeChange:t=>p(n,"workflow_type",t),pipelineId:d.pipeline_id,onPipelineIdChange:t=>p(n,"pipeline_id",t),serverId:d.server_id,toolName:d.tool_name,onCapabilityChange:(t,i)=>{var A;const b=[...s.subscriptions],g={...b[n],server_id:t,tool_name:i},k=u.find(w=>w.serverId===t&&w.name===i),E=(A=k==null?void 0:k.inputSchema)==null?void 0:A.properties;if(E&&i){const w={};for(const $ of Object.keys(E))$.startsWith("_")||(w[$]=`{event.data.${$}}`);g.input_mapping=JSON.stringify(w,null,2)}b[n]=g,a("subscriptions",b)},mcpPrompt:d.mcp_prompt,onMcpPromptChange:t=>p(n,"mcp_prompt",t)})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[e.jsxs("div",{children:[e.jsx("label",{className:S,children:"As identity"}),e.jsx(te,{selected:d.execute_as,onChange:t=>p(n,"execute_as",t)}),e.jsx("p",{className:_,children:"Identity used when invoking the workflow."})]}),e.jsxs("div",{children:[e.jsx("label",{className:S,children:"But only if"}),e.jsx("input",{type:"text",value:d.filter,onChange:t=>p(n,"filter",t.target.value),placeholder:'{"extension": "png"}',className:`${R} font-mono text-xs`}),e.jsx("p",{className:_,children:"JSON filter against event.data. Click an operator to insert:"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:[{label:"equals",value:'{"key": "val"}'},{label:"not equal",value:'{"key": {"$ne": "val"}}'},{label:"in list",value:'{"key": {"$in": ["a", "b"]}}'},{label:"exists",value:'{"key": {"$exists": true}}'}].map(t=>e.jsx("button",{type:"button",onClick:()=>p(n,"filter",t.value),className:"px-2 py-0.5 text-[10px] font-mono rounded bg-accent/8 text-accent hover:bg-accent/15 transition-colors",children:t.label},t.label))})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:S,children:"With this data"}),d.reaction_type==="capability"&&d.tool_name?e.jsx(Fe,{tool:u.find(t=>t.serverId===d.server_id&&t.name===d.tool_name),value:d.input_mapping,onChange:t=>p(n,"input_mapping",t),eventSchema:m==null?void 0:m.payload_schema}):e.jsxs(e.Fragment,{children:[e.jsx("textarea",{value:d.input_mapping,onChange:t=>p(n,"input_mapping",t.target.value),rows:10,className:L,placeholder:`{
3
+ This takes effect when you save.`)&&f(i)},className:"opacity-0 group-hover/sub:opacity-100 px-2 text-text-quaternary hover:text-red-400 transition-all",title:"Remove",children:e.jsx(Z,{className:"w-3 h-3"})})]},i)),e.jsxs("button",{onClick:c,className:"w-full flex items-center gap-1.5 px-3 py-2 text-[11px] text-accent hover:text-accent-hover transition-colors",children:[e.jsx(M,{className:"w-3 h-3"})," Add"]})]}),d&&e.jsxs("div",{className:"flex-1 min-w-0 space-y-12",children:[e.jsxs("div",{children:[e.jsx("label",{className:S,children:"When this event fires"}),e.jsx(ze,{value:d.topic,onChange:t=>p(n,"topic",t),topics:x}),(m==null?void 0:m.payload_schema)&&e.jsxs("div",{className:"mt-3 p-3 rounded-md bg-surface-sunken border border-surface-border",children:[e.jsx("p",{className:"text-[10px] text-text-quaternary mb-1 uppercase tracking-wider font-medium",children:"Payload Schema"}),e.jsx("pre",{className:"text-[11px] font-mono text-text-secondary whitespace-pre-wrap overflow-x-auto max-h-40",children:JSON.stringify(m.payload_schema.properties??m.payload_schema,null,2)}),m.description&&e.jsx("p",{className:"text-[10px] text-text-tertiary mt-2 italic",children:m.description})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:S,children:"Run this reaction"}),e.jsx(ae,{reactionType:d.reaction_type,onReactionTypeChange:t=>p(n,"reaction_type",t),workflowType:d.workflow_type,onWorkflowTypeChange:t=>p(n,"workflow_type",t),pipelineId:d.pipeline_id,onPipelineIdChange:t=>p(n,"pipeline_id",t),serverId:d.server_id,toolName:d.tool_name,onCapabilityChange:(t,i)=>{var R;const b=[...s.subscriptions],g={...b[n],server_id:t,tool_name:i},k=u.find(w=>w.serverId===t&&w.name===i),E=(R=k==null?void 0:k.inputSchema)==null?void 0:R.properties;if(E&&i){const w={};for(const P of Object.keys(E))P.startsWith("_")||(w[P]=`{event.data.${P}}`);g.input_mapping=JSON.stringify(w,null,2)}b[n]=g,a("subscriptions",b)},mcpPrompt:d.mcp_prompt,onMcpPromptChange:t=>p(n,"mcp_prompt",t)})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-6",children:[e.jsxs("div",{children:[e.jsx("label",{className:S,children:"As identity"}),e.jsx(te,{selected:d.execute_as,onChange:t=>p(n,"execute_as",t)}),e.jsx("p",{className:_,children:"Identity used when invoking the workflow."})]}),e.jsxs("div",{children:[e.jsx("label",{className:S,children:"But only if"}),e.jsx("input",{type:"text",value:d.filter,onChange:t=>p(n,"filter",t.target.value),placeholder:'{"extension": "png"}',className:`${O} font-mono text-xs`}),e.jsx("p",{className:_,children:"JSON filter against event.data. Click an operator to insert:"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:[{label:"equals",value:'{"key": "val"}'},{label:"not equal",value:'{"key": {"$ne": "val"}}'},{label:"in list",value:'{"key": {"$in": ["a", "b"]}}'},{label:"exists",value:'{"key": {"$exists": true}}'}].map(t=>e.jsx("button",{type:"button",onClick:()=>p(n,"filter",t.value),className:"px-2 py-0.5 text-[10px] font-mono rounded bg-accent/8 text-accent hover:bg-accent/15 transition-colors",children:t.label},t.label))})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:S,children:"With this data"}),d.reaction_type==="capability"&&d.tool_name?e.jsx(Fe,{tool:u.find(t=>t.serverId===d.server_id&&t.name===d.tool_name),value:d.input_mapping,onChange:t=>p(n,"input_mapping",t),eventSchema:m==null?void 0:m.payload_schema}):e.jsxs(e.Fragment,{children:[e.jsx("textarea",{value:d.input_mapping,onChange:t=>p(n,"input_mapping",t.target.value),rows:10,className:L,placeholder:`{
4
4
  "data": {
5
5
  "orderId": "{event.data.orderId}",
6
6
  "error": "{event.data.error}"
@@ -8,9 +8,9 @@ This takes effect when you save.`)&&f(i)},className:"opacity-0 group-hover/sub:o
8
8
  }`}),e.jsxs("p",{className:_,children:["Maps event fields to workflow input. ","{event.data.fieldName}"," resolves at runtime."]})]})]})]})]})]})}function Fe({tool:s,value:a,onChange:r,eventSchema:o}){var y,m;const[x,u]=v.useState(!1),n=((y=s==null?void 0:s.inputSchema)==null?void 0:y.properties)??{},h=((m=s==null?void 0:s.inputSchema)==null?void 0:m.required)??[],p=Object.entries(n).filter(([t])=>!t.startsWith("_")),c=v.useMemo(()=>[...p].sort(([t],[i])=>{const b=h.indexOf(t),g=h.indexOf(i);return b!==-1&&g!==-1?b-g:b!==-1?-1:g!==-1?1:t.localeCompare(i)}),[p,h]),f=v.useMemo(()=>{const t=[{value:"{event.type}",label:"event type"},{value:"{event.source}",label:"event source"},{value:"{event.timestamp}",label:"ISO timestamp"},{value:"{event.workflowId}",label:"workflow ID"},{value:"{event.workflowName}",label:"workflow name"}],i=o==null?void 0:o.properties;if(i)for(const[b,g]of Object.entries(i))t.push({value:`{event.data.${b}}`,label:g.description||b});return t},[o]),l=v.useMemo(()=>{try{return JSON.parse(a)}catch{return{}}},[a]),d=(t,i)=>{r(Ee(a,t,i,h))};return c.length===0||x?e.jsxs("div",{children:[c.length>0&&e.jsx("div",{className:"flex justify-end mb-1",children:e.jsx("button",{type:"button",onClick:()=>u(!1),className:"text-[10px] text-accent hover:text-accent-hover transition-colors",children:"Form view"})}),e.jsx("textarea",{value:a,onChange:t=>r(t.target.value),rows:8,className:L,placeholder:`{
9
9
  "domain": "{event.data.name}",
10
10
  "key": "{event.data.path}"
11
- }`}),e.jsxs("p",{className:_,children:["Maps event fields to capability inputs. ","{event.data.fieldName}"," resolves at runtime."]})]}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("p",{className:"text-[11px] text-text-tertiary",children:"Map each input to an event field or enter a static value."}),e.jsx("button",{type:"button",onClick:()=>u(!0),className:"text-[10px] text-text-tertiary hover:text-accent transition-colors",children:"Raw JSON"})]}),e.jsx("div",{className:"space-y-4",children:c.map(([t,i])=>{const b=h.includes(t),g=i.description,k=i.type,E=typeof l[t]=="string"?l[t]:typeof l[t]=="object"?JSON.stringify(l[t]):l[t]!=null?String(l[t]):"";return e.jsxs("div",{className:"bg-surface-sunken/30 rounded-md px-4 py-3",children:[e.jsxs("div",{className:"flex items-baseline gap-2 mb-0.5",children:[e.jsxs("label",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-secondary",children:[t.replace(/[_-]/g," "),b&&e.jsx("span",{className:"text-status-error ml-0.5",children:"*"})]}),k&&e.jsx("span",{className:"text-[9px] text-text-quaternary",children:k})]}),g&&e.jsx("p",{className:"text-[10px] text-text-quaternary mb-2",children:g}),e.jsx(De,{value:E,onChange:A=>d(t,A),suggestions:f,fieldType:k,placeholder:`{event.data.${t}}`})]},t)})})]})}function De({value:s,onChange:a,suggestions:r,fieldType:o,placeholder:x}){const[u,n]=v.useState(!1),[h,p]=v.useState(""),c=v.useRef(null);v.useEffect(()=>{if(!u)return;function l(d){c.current&&!c.current.contains(d.target)&&n(!1)}return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[u]);const f=r.filter(l=>l.value.toLowerCase().includes(h.toLowerCase())||l.label.toLowerCase().includes(h.toLowerCase()));if(o==="object")return e.jsx("textarea",{value:s,onChange:l=>{try{a(JSON.parse(l.target.value))}catch{a(l.target.value)}},rows:3,className:`${L} text-xs`,placeholder:'{ "source": "{event.source}" }'});if(o==="array"){const l=(()=>{try{const d=JSON.parse(s);if(Array.isArray(d))return d.map(String)}catch{}return s?s.split(",").map(d=>d.trim()).filter(Boolean):[]})();return e.jsxs("div",{children:[e.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2 min-h-[28px]",children:l.map((d,y)=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-[11px] font-mono bg-accent/10 text-accent rounded-full",children:[d,e.jsx("button",{type:"button",onClick:()=>{const m=l.filter((t,i)=>i!==y);a(JSON.stringify(m))},className:"text-accent/50 hover:text-accent ml-0.5",children:"×"})]},y))}),e.jsx("input",{type:"text",className:"input font-mono text-xs w-full",placeholder:"Type a value and press Enter",onKeyDown:d=>{if(d.key==="Enter"||d.key===","){d.preventDefault();const y=d.target.value.trim();y&&(a(JSON.stringify([...l,y])),d.target.value="")}}})]})}return e.jsxs("div",{ref:c,className:"relative",children:[e.jsx("input",{type:"text",value:s,onFocus:()=>{n(!0),p("")},onChange:l=>{a(l.target.value),p(l.target.value),u||n(!0)},className:"input font-mono text-xs w-full",placeholder:x}),u&&f.length>0&&e.jsx("div",{className:"absolute z-50 left-0 right-0 mt-1 max-h-48 overflow-y-auto rounded-md border border-surface-border bg-surface shadow-lg",children:f.map(l=>e.jsxs("button",{type:"button",onClick:()=>{a(l.value),n(!1)},className:`w-full text-left px-3 py-1.5 hover:bg-surface-hover transition-colors flex items-center gap-3 ${s===l.value?"bg-accent/5":""}`,children:[e.jsx("span",{className:"text-[11px] font-mono text-accent shrink-0",children:l.value}),e.jsx("span",{className:"text-[10px] text-text-quaternary truncate",children:l.label})]},l.value))})]})}function ze({value:s,onChange:a,topics:r}){const[o,x]=v.useState(!1),[u,n]=v.useState(""),h=v.useRef(null),p=v.useRef(null);v.useEffect(()=>{function l(d){p.current&&!p.current.contains(d.target)&&x(!1)}return o&&document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[o]);const c=o?u:s,f=r.filter(l=>l.topic.toLowerCase().includes((o?u:"").toLowerCase())||(l.description??"").toLowerCase().includes((o?u:"").toLowerCase()));return e.jsxs("div",{ref:p,className:"relative",children:[e.jsx("input",{ref:h,type:"text",value:c,onFocus:()=>{x(!0),n(s)},onChange:l=>{const d=l.target.value;n(d),a(d),o||x(!0)},placeholder:"workflow.failed or app.>",className:`${R} font-mono`}),o&&f.length>0&&e.jsx("div",{className:"absolute z-50 left-0 right-0 mt-1 max-h-64 overflow-y-auto rounded-md border border-surface-border bg-surface shadow-lg",children:f.map(l=>{const d=Le[l.category]??"bg-zinc-400/15 text-zinc-400";return e.jsxs("button",{type:"button",onClick:()=>{a(l.topic),n(l.topic),x(!1)},className:`w-full text-left px-3 py-2 hover:bg-surface-hover transition-colors flex items-center gap-3 ${s===l.topic?"bg-accent/5":""}`,children:[e.jsx("span",{className:"text-[11px] font-mono text-text-primary shrink-0",children:l.topic}),e.jsx("span",{className:`inline-flex items-center px-1.5 py-0.5 rounded text-[9px] font-medium shrink-0 ${d}`,children:l.category}),l.description&&e.jsx("span",{className:"text-[10px] text-text-quaternary truncate",children:l.description})]},l.topic)})})]})}const Be=["*/5 * * * *","*/15 * * * *","0 * * * *","0 */4 * * *","0 7 * * *","0 9 * * 1-5"];function z(s){return{"* * * * *":"Every minute","*/5 * * * *":"Every 5 min","*/15 * * * *":"Every 15 min","0 * * * *":"Hourly","0 */4 * * *":"Every 4 hours","0 7 * * *":"Daily 7 AM UTC","0 9 * * 1-5":"Weekdays 9 AM UTC","0 0 * * 1":"Weekly Monday"}[s]||s}function Ue({form:s,set:a}){const[r,o]=v.useState(0),x=(c,f,l)=>{const d=[...s.schedules];d[c]={...d[c],[f]:l},a("schedules",d)},u=()=>{a("schedules",[...s.schedules,{...qe}]),o(s.schedules.length)},n=c=>{a("schedules",s.schedules.filter((f,l)=>l!==c)),r>=s.schedules.length-1&&o(Math.max(0,s.schedules.length-2))},h=s.schedules,p=h[r];return h.length===0?e.jsxs("div",{children:[e.jsxs("div",{className:"border-l-2 border-accent/30 pl-3 py-1 mb-8 flex items-start justify-between",children:[e.jsx("p",{className:"text-[12px] text-text-secondary italic leading-relaxed",children:"Optional. Each schedule runs a workflow on a cron timer."}),e.jsx("button",{onClick:()=>{window.location.hash="#docs:agents.md:schedule"},className:"text-text-quaternary hover:text-accent transition-colors shrink-0 ml-3",title:"Docs: Schedule",children:e.jsx(O,{className:"w-3 h-3",strokeWidth:1.5})})]}),e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(G,{className:"w-8 h-8 text-text-quaternary/40 mb-3",strokeWidth:1}),e.jsx("p",{className:"text-sm text-text-tertiary mb-2",children:"No schedules"}),e.jsx("p",{className:"text-[11px] text-text-quaternary max-w-sm mb-6",children:"Add a schedule to run a workflow on a recurring cron timer."}),e.jsxs("button",{onClick:u,className:"flex items-center gap-2 text-xs text-accent hover:text-accent-hover transition-colors",children:[e.jsx(M,{className:"w-3.5 h-3.5"})," Add schedule"]})]})]}):e.jsxs("div",{children:[e.jsxs("div",{className:"border-l-2 border-accent/30 pl-3 py-1 mb-6 flex items-start justify-between",children:[e.jsx("p",{className:"text-[12px] text-text-secondary italic leading-relaxed",children:"Each schedule runs a workflow on a timer. An automation can have multiple schedules targeting different workflows."}),e.jsx("button",{onClick:()=>{window.location.hash="#docs:agents.md:schedule"},className:"text-text-quaternary hover:text-accent transition-colors shrink-0 ml-3",title:"Docs: Schedule",children:e.jsx(O,{className:"w-3 h-3",strokeWidth:1.5})})]}),e.jsxs("div",{className:"flex gap-8",children:[e.jsxs("div",{className:"w-48 shrink-0 space-y-0.5",children:[h.map((c,f)=>e.jsxs("div",{className:`group/sched flex items-center rounded-md transition-colors ${r===f?"bg-accent/10 text-accent":"text-text-tertiary hover:text-text-primary hover:bg-surface-hover"}`,children:[e.jsxs("button",{onClick:()=>o(f),className:"flex-1 text-left px-3 py-2 min-w-0",children:[e.jsx("span",{className:"text-[11px] font-mono block",children:c.cron||"new schedule"}),e.jsxs("span",{className:"text-[9px] text-text-quaternary",children:[(c.reaction_type==="pipeline"?c.pipeline_id:c.workflow_type)||"no target"," · ",z(c.cron)]})]}),e.jsx("button",{onClick:l=>{l.stopPropagation(),confirm(`Remove schedule "${c.cron||"new"}"?
11
+ }`}),e.jsxs("p",{className:_,children:["Maps event fields to capability inputs. ","{event.data.fieldName}"," resolves at runtime."]})]}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("p",{className:"text-[11px] text-text-tertiary",children:"Map each input to an event field or enter a static value."}),e.jsx("button",{type:"button",onClick:()=>u(!0),className:"text-[10px] text-text-tertiary hover:text-accent transition-colors",children:"Raw JSON"})]}),e.jsx("div",{className:"space-y-4",children:c.map(([t,i])=>{const b=h.includes(t),g=i.description,k=i.type,E=typeof l[t]=="string"?l[t]:typeof l[t]=="object"?JSON.stringify(l[t]):l[t]!=null?String(l[t]):"";return e.jsxs("div",{className:"bg-surface-sunken/30 rounded-md px-4 py-3",children:[e.jsxs("div",{className:"flex items-baseline gap-2 mb-0.5",children:[e.jsxs("label",{className:"text-[11px] font-semibold uppercase tracking-wider text-text-secondary",children:[t.replace(/[_-]/g," "),b&&e.jsx("span",{className:"text-status-error ml-0.5",children:"*"})]}),k&&e.jsx("span",{className:"text-[9px] text-text-quaternary",children:k})]}),g&&e.jsx("p",{className:"text-[10px] text-text-quaternary mb-2",children:g}),e.jsx(De,{value:E,onChange:R=>d(t,R),suggestions:f,fieldType:k,placeholder:`{event.data.${t}}`})]},t)})})]})}function De({value:s,onChange:a,suggestions:r,fieldType:o,placeholder:x}){const[u,n]=v.useState(!1),[h,p]=v.useState(""),c=v.useRef(null);v.useEffect(()=>{if(!u)return;function l(d){c.current&&!c.current.contains(d.target)&&n(!1)}return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[u]);const f=r.filter(l=>l.value.toLowerCase().includes(h.toLowerCase())||l.label.toLowerCase().includes(h.toLowerCase()));if(o==="object")return e.jsx("textarea",{value:s,onChange:l=>{try{a(JSON.parse(l.target.value))}catch{a(l.target.value)}},rows:3,className:`${L} text-xs`,placeholder:'{ "source": "{event.source}" }'});if(o==="array"){const l=(()=>{try{const d=JSON.parse(s);if(Array.isArray(d))return d.map(String)}catch{}return s?s.split(",").map(d=>d.trim()).filter(Boolean):[]})();return e.jsxs("div",{children:[e.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2 min-h-[28px]",children:l.map((d,y)=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 text-[11px] font-mono bg-accent/10 text-accent rounded-full",children:[d,e.jsx("button",{type:"button",onClick:()=>{const m=l.filter((t,i)=>i!==y);a(JSON.stringify(m))},className:"text-accent/50 hover:text-accent ml-0.5",children:"×"})]},y))}),e.jsx("input",{type:"text",className:"input font-mono text-xs w-full",placeholder:"Type a value and press Enter",onKeyDown:d=>{if(d.key==="Enter"||d.key===","){d.preventDefault();const y=d.target.value.trim();y&&(a(JSON.stringify([...l,y])),d.target.value="")}}})]})}return e.jsxs("div",{ref:c,className:"relative",children:[e.jsx("input",{type:"text",value:s,onFocus:()=>{n(!0),p("")},onChange:l=>{a(l.target.value),p(l.target.value),u||n(!0)},className:"input font-mono text-xs w-full",placeholder:x}),u&&f.length>0&&e.jsx("div",{className:"absolute z-50 left-0 right-0 mt-1 max-h-48 overflow-y-auto rounded-md border border-surface-border bg-surface shadow-lg",children:f.map(l=>e.jsxs("button",{type:"button",onClick:()=>{a(l.value),n(!1)},className:`w-full text-left px-3 py-1.5 hover:bg-surface-hover transition-colors flex items-center gap-3 ${s===l.value?"bg-accent/5":""}`,children:[e.jsx("span",{className:"text-[11px] font-mono text-accent shrink-0",children:l.value}),e.jsx("span",{className:"text-[10px] text-text-quaternary truncate",children:l.label})]},l.value))})]})}function ze({value:s,onChange:a,topics:r}){const[o,x]=v.useState(!1),[u,n]=v.useState(""),h=v.useRef(null),p=v.useRef(null);v.useEffect(()=>{function l(d){p.current&&!p.current.contains(d.target)&&x(!1)}return o&&document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[o]);const c=o?u:s,f=r.filter(l=>l.topic.toLowerCase().includes((o?u:"").toLowerCase())||(l.description??"").toLowerCase().includes((o?u:"").toLowerCase()));return e.jsxs("div",{ref:p,className:"relative",children:[e.jsx("input",{ref:h,type:"text",value:c,onFocus:()=>{x(!0),n(s)},onChange:l=>{const d=l.target.value;n(d),a(d),o||x(!0)},placeholder:"workflow.failed or app.>",className:`${O} font-mono`}),o&&f.length>0&&e.jsx("div",{className:"absolute z-50 left-0 right-0 mt-1 max-h-64 overflow-y-auto rounded-md border border-surface-border bg-surface shadow-lg",children:f.map(l=>{const d=Le[l.category]??"bg-zinc-400/15 text-zinc-400";return e.jsxs("button",{type:"button",onClick:()=>{a(l.topic),n(l.topic),x(!1)},className:`w-full text-left px-3 py-2 hover:bg-surface-hover transition-colors flex items-center gap-3 ${s===l.topic?"bg-accent/5":""}`,children:[e.jsx("span",{className:"text-[11px] font-mono text-text-primary shrink-0",children:l.topic}),e.jsx("span",{className:`inline-flex items-center px-1.5 py-0.5 rounded text-[9px] font-medium shrink-0 ${d}`,children:l.category}),l.description&&e.jsx("span",{className:"text-[10px] text-text-quaternary truncate",children:l.description})]},l.topic)})})]})}const Be=["*/5 * * * *","*/15 * * * *","0 * * * *","0 */4 * * *","0 7 * * *","0 9 * * 1-5"];function z(s){return{"* * * * *":"Every minute","*/5 * * * *":"Every 5 min","*/15 * * * *":"Every 15 min","0 * * * *":"Hourly","0 */4 * * *":"Every 4 hours","0 7 * * *":"Daily 7 AM UTC","0 9 * * 1-5":"Weekdays 9 AM UTC","0 0 * * 1":"Weekly Monday"}[s]||s}function Ue({form:s,set:a}){const[r,o]=v.useState(0),x=(c,f,l)=>{const d=[...s.schedules];d[c]={...d[c],[f]:l},a("schedules",d)},u=()=>{a("schedules",[...s.schedules,{...qe}]),o(s.schedules.length)},n=c=>{a("schedules",s.schedules.filter((f,l)=>l!==c)),r>=s.schedules.length-1&&o(Math.max(0,s.schedules.length-2))},h=s.schedules,p=h[r];return h.length===0?e.jsxs("div",{children:[e.jsxs("div",{className:"border-l-2 border-accent/30 pl-3 py-1 mb-8 flex items-start justify-between",children:[e.jsx("p",{className:"text-[12px] text-text-secondary italic leading-relaxed",children:"Optional. Each schedule runs a workflow on a cron timer."}),e.jsx("button",{onClick:()=>{window.location.hash="#docs:agents.md:schedule"},className:"text-text-quaternary hover:text-accent transition-colors shrink-0 ml-3",title:"Docs: Schedule",children:e.jsx(A,{className:"w-3 h-3",strokeWidth:1.5})})]}),e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[e.jsx(G,{className:"w-8 h-8 text-text-quaternary/40 mb-3",strokeWidth:1}),e.jsx("p",{className:"text-sm text-text-tertiary mb-2",children:"No schedules"}),e.jsx("p",{className:"text-[11px] text-text-quaternary max-w-sm mb-6",children:"Add a schedule to run a workflow on a recurring cron timer."}),e.jsxs("button",{onClick:u,className:"flex items-center gap-2 text-xs text-accent hover:text-accent-hover transition-colors",children:[e.jsx(M,{className:"w-3.5 h-3.5"})," Add schedule"]})]})]}):e.jsxs("div",{children:[e.jsxs("div",{className:"border-l-2 border-accent/30 pl-3 py-1 mb-6 flex items-start justify-between",children:[e.jsx("p",{className:"text-[12px] text-text-secondary italic leading-relaxed",children:"Each schedule runs a workflow on a timer. An automation can have multiple schedules targeting different workflows."}),e.jsx("button",{onClick:()=>{window.location.hash="#docs:agents.md:schedule"},className:"text-text-quaternary hover:text-accent transition-colors shrink-0 ml-3",title:"Docs: Schedule",children:e.jsx(A,{className:"w-3 h-3",strokeWidth:1.5})})]}),e.jsxs("div",{className:"flex gap-8",children:[e.jsxs("div",{className:"w-48 shrink-0 space-y-0.5",children:[h.map((c,f)=>e.jsxs("div",{className:`group/sched flex items-center rounded-md transition-colors ${r===f?"bg-accent/10 text-accent":"text-text-tertiary hover:text-text-primary hover:bg-surface-hover"}`,children:[e.jsxs("button",{onClick:()=>o(f),className:"flex-1 text-left px-3 py-2 min-w-0",children:[e.jsx("span",{className:"text-[11px] font-mono block",children:c.cron||"new schedule"}),e.jsxs("span",{className:"text-[9px] text-text-quaternary",children:[(c.reaction_type==="pipeline"?c.pipeline_id:c.workflow_type)||"no target"," · ",z(c.cron)]})]}),e.jsx("button",{onClick:l=>{l.stopPropagation(),confirm(`Remove schedule "${c.cron||"new"}"?
12
12
 
13
- This takes effect when you save.`)&&n(f)},className:"opacity-0 group-hover/sched:opacity-100 px-2 text-text-quaternary hover:text-red-400 transition-all",title:"Remove",children:e.jsx(Z,{className:"w-3 h-3"})})]},f)),e.jsxs("button",{onClick:u,className:"w-full flex items-center gap-1.5 px-3 py-2 text-[11px] text-accent hover:text-accent-hover transition-colors",children:[e.jsx(M,{className:"w-3 h-3"})," Add"]})]}),p&&e.jsxs("div",{className:"flex-1 min-w-0 space-y-12",children:[e.jsxs("div",{children:[e.jsx("label",{className:S,children:"Run every"}),e.jsx("input",{type:"text",value:p.cron,onChange:c=>x(r,"cron",c.target.value),placeholder:"0 * * * *",className:`${R} font-mono`}),p.cron&&e.jsx("p",{className:"text-[11px] text-accent/80 mt-1",children:z(p.cron)}),e.jsx("div",{className:"flex gap-3 mt-2 overflow-x-auto",children:Be.map(c=>e.jsx("button",{type:"button",onClick:()=>x(r,"cron",c),className:`text-[10px] font-mono whitespace-nowrap transition-colors ${p.cron===c?"text-accent font-medium":"text-accent/50 hover:text-accent"}`,children:z(c)},c))})]}),e.jsxs("div",{children:[e.jsx("label",{className:S,children:"Run this reaction"}),e.jsx(ae,{reactionType:p.reaction_type,onReactionTypeChange:c=>x(r,"reaction_type",c),workflowType:p.workflow_type,onWorkflowTypeChange:c=>x(r,"workflow_type",c),pipelineId:p.pipeline_id,onPipelineIdChange:c=>x(r,"pipeline_id",c),serverId:p.server_id,toolName:p.tool_name,onCapabilityChange:(c,f)=>{x(r,"server_id",c),x(r,"tool_name",f)},availableTypes:["durable","pipeline","capability"]})]}),e.jsxs("div",{children:[e.jsx("label",{className:S,children:"As identity"}),e.jsx(te,{selected:p.execute_as,onChange:c=>x(r,"execute_as",c)}),e.jsx("p",{className:_,children:"Identity used when invoking."})]}),e.jsxs("div",{children:[e.jsx("label",{className:S,children:"With this data"}),e.jsx("textarea",{value:p.envelope,onChange:c=>x(r,"envelope",c.target.value),rows:10,className:L,placeholder:`{
13
+ This takes effect when you save.`)&&n(f)},className:"opacity-0 group-hover/sched:opacity-100 px-2 text-text-quaternary hover:text-red-400 transition-all",title:"Remove",children:e.jsx(Z,{className:"w-3 h-3"})})]},f)),e.jsxs("button",{onClick:u,className:"w-full flex items-center gap-1.5 px-3 py-2 text-[11px] text-accent hover:text-accent-hover transition-colors",children:[e.jsx(M,{className:"w-3 h-3"})," Add"]})]}),p&&e.jsxs("div",{className:"flex-1 min-w-0 space-y-12",children:[e.jsxs("div",{children:[e.jsx("label",{className:S,children:"Run every"}),e.jsx("input",{type:"text",value:p.cron,onChange:c=>x(r,"cron",c.target.value),placeholder:"0 * * * *",className:`${O} font-mono`}),p.cron&&e.jsx("p",{className:"text-[11px] text-accent/80 mt-1",children:z(p.cron)}),e.jsx("div",{className:"flex gap-3 mt-2 overflow-x-auto",children:Be.map(c=>e.jsx("button",{type:"button",onClick:()=>x(r,"cron",c),className:`text-[10px] font-mono whitespace-nowrap transition-colors ${p.cron===c?"text-accent font-medium":"text-accent/50 hover:text-accent"}`,children:z(c)},c))})]}),e.jsxs("div",{children:[e.jsx("label",{className:S,children:"Run this reaction"}),e.jsx(ae,{reactionType:p.reaction_type,onReactionTypeChange:c=>x(r,"reaction_type",c),workflowType:p.workflow_type,onWorkflowTypeChange:c=>x(r,"workflow_type",c),pipelineId:p.pipeline_id,onPipelineIdChange:c=>x(r,"pipeline_id",c),serverId:p.server_id,toolName:p.tool_name,onCapabilityChange:(c,f)=>{x(r,"server_id",c),x(r,"tool_name",f)},availableTypes:["durable","pipeline","capability"]})]}),e.jsxs("div",{children:[e.jsx("label",{className:S,children:"As identity"}),e.jsx(te,{selected:p.execute_as,onChange:c=>x(r,"execute_as",c)}),e.jsx("p",{className:_,children:"Identity used when invoking."})]}),e.jsxs("div",{children:[e.jsx("label",{className:S,children:"With this data"}),e.jsx("textarea",{value:p.envelope,onChange:c=>x(r,"envelope",c.target.value),rows:10,className:L,placeholder:`{
14
14
  "data": { "source": "cron" }
15
- }`}),e.jsx("p",{className:_,children:"Static payload passed to the workflow on each invocation."})]})]})]})]})}function W({icon:s,color:a,title:r,children:o}){return e.jsxs("div",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-1.5 border-b border-surface-border/40",children:[e.jsx(s,{className:`w-3.5 h-3.5 ${a}`,strokeWidth:1.5}),e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-widest text-accent/80",children:r})]}),e.jsx("div",{className:"pl-5.5",children:o})]})}function T({label:s,children:a}){return e.jsxs("div",{className:"flex gap-3 py-0.5",children:[e.jsx("span",{className:"text-[10px] text-text-quaternary w-20 shrink-0",children:s}),e.jsx("span",{className:"text-xs text-text-primary",children:a})]})}function Ye({form:s}){return e.jsxs("div",{children:[e.jsxs(W,{icon:V,color:"text-accent",title:"Identity",children:[e.jsx(T,{label:"Name",children:s.name||"—"}),s.description&&e.jsx(T,{label:"Description",children:s.description})]}),(s.goals||s.rules)&&e.jsxs(W,{icon:ee,color:"text-rose-400",title:"Motivation",children:[s.goals&&e.jsx(T,{label:"Goals",children:s.goals}),s.rules&&e.jsx(T,{label:"Rules",children:s.rules})]}),e.jsx(W,{icon:U,color:"text-emerald-400",title:"Knowledge",children:e.jsx(T,{label:"Domain",children:s.knowledge_domain||"None"})}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-10",children:[e.jsx(W,{icon:Y,color:"text-cyan-400",title:`Subscriptions (${s.subscriptions.length})`,children:s.subscriptions.length===0?e.jsx("span",{className:"text-[11px] text-text-quaternary",children:"None configured"}):e.jsx("div",{className:"divide-y divide-surface-border/30",children:s.subscriptions.map((a,r)=>e.jsxs("div",{className:"flex items-center py-1.5",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(ce,{topic:a.topic||"unset"})}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx("span",{className:"text-text-quaternary text-[10px]",children:"→"}),a.workflow_type?e.jsx(Q,{type:a.workflow_type}):e.jsx("span",{className:"text-[11px] text-text-quaternary",children:a.reaction_type})]})]},r))})}),e.jsx(W,{icon:G,color:"text-amber-400",title:`Schedules (${s.schedules.length})`,children:s.schedules.length===0?e.jsx("span",{className:"text-[11px] text-text-quaternary",children:"None configured"}):e.jsx("div",{className:"divide-y divide-surface-border/30",children:s.schedules.map((a,r)=>e.jsxs("div",{className:"flex items-center py-1.5",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(de,{cron:a.cron})}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx("span",{className:"text-text-quaternary text-[10px]",children:"→"}),a.workflow_type?e.jsx(Q,{type:a.workflow_type}):e.jsx("span",{className:"text-[11px] text-text-quaternary",children:"no workflow"})]})]},r))})})]}),e.jsx("div",{className:"border-l-2 border-emerald-400/30 pl-3 py-2 mt-6",children:e.jsx("p",{className:"text-[11px] text-text-tertiary leading-relaxed",children:"After saving, subscriptions and schedules activate immediately. You can pause the automation anytime."})})]})}const Ge=[{id:1,label:"Identity",icon:V},{id:2,label:"Motivation",icon:ee},{id:3,label:"Knowledge",icon:U},{id:4,label:"Subscriptions",icon:Y},{id:5,label:"Schedules",icon:G},{id:6,label:"Review",icon:ye}];function dt(){var H;const{id:s}=_e(),a=!s,r=ke(),{data:o}=fe(),u=!!((H=o==null?void 0:o.ai)!=null&&H.enabled)?"Agent":"Automation",{data:n,isLoading:h}=re(a?null:s),{data:p}=pe(a?null:s),c=le(),f=oe(),l=xe(),d=ue(),y=me(),[m,t]=v.useState(X),[i,b]=v.useState(!1),[g,k]=v.useState(""),[E,A]=Ce(),w=parseInt(E.get("step")||"1",10),$=v.useCallback(j=>{A(N=>{const q=new URLSearchParams(N);return q.set("step",String(j)),q},{replace:!0})},[A]);v.useEffect(()=>{if(!i){if(a){t(X),b(!0);return}n&&p&&(t(Re(n,p.subscriptions??[])),b(!0))}},[n,p,a,i]);const I=(j,N)=>t(q=>({...q,[j]:N})),ne=async()=>{k("");try{const j=Ae(m);let N=s;a?N=(await c.mutateAsync(j)).id:await f.mutateAsync({id:s,...j});const q=Oe(m),ie=(p==null?void 0:p.subscriptions)??[],J=new Set(ie.map(C=>C.id));for(const C of q)if(C.id&&J.has(C.id)){const{id:F,...D}=C;await d.mutateAsync({agentId:N,subId:F,...D}),J.delete(F)}else{const{id:F,...D}=C;await l.mutateAsync({agentId:N,...D})}for(const C of J)await y.mutateAsync({agentId:N,subId:C});r(`/agents/${N}`)}catch(j){k(j.message)}};if(!a&&h)return e.jsxs("div",{className:"animate-pulse space-y-4",children:[e.jsx("div",{className:"h-8 bg-surface-sunken rounded w-48"}),e.jsx("div",{className:"h-60 bg-surface-sunken rounded"})]});const K=c.isPending||f.isPending;return e.jsxs("div",{children:[e.jsx(ve,{title:a?`New ${u}`:`${u}: ${(n==null?void 0:n.id)??""}`,docsHash:"#docs:agents.md"}),e.jsxs("div",{className:"flex gap-10",children:[e.jsxs("nav",{className:"w-44 shrink-0 sticky top-0 self-start pt-2",children:[e.jsx("div",{className:"space-y-0.5",children:Ge.map(j=>{const N=j.icon,q=w===j.id;return e.jsxs("button",{onClick:()=>$(j.id),className:`w-full flex items-center gap-2.5 px-3 py-2 rounded-md text-left transition-colors ${q?"bg-accent/10 text-accent":"text-text-tertiary hover:text-text-primary hover:bg-surface-hover"}`,children:[e.jsx(N,{className:"w-3.5 h-3.5 shrink-0",strokeWidth:1.5}),e.jsx("span",{className:"text-xs font-medium",children:j.label})]},j.id)})}),e.jsxs("div",{className:"mt-8 pt-4 border-t border-surface-border space-y-2",children:[e.jsx("button",{onClick:ne,disabled:!m.name.trim()||K,className:"w-full btn-primary text-xs disabled:opacity-50",children:K?"Saving...":a?`Create ${u}`:"Save"}),e.jsx("button",{onClick:()=>r(a?"/agents":`/agents/${s}`),className:"w-full btn-ghost text-xs",children:"Cancel"})]}),g&&e.jsx("p",{className:"text-xs text-status-error mt-3",children:g})]}),e.jsxs("div",{className:"flex-1 min-w-0 pt-2",children:[w===1&&e.jsx(Pe,{form:m,set:I}),w===2&&e.jsx($e,{form:m,set:I}),w===3&&e.jsx(Ie,{form:m,set:I}),w===4&&e.jsx(Je,{form:m,set:I}),w===5&&e.jsx(Ue,{form:m,set:I}),w===6&&e.jsx(Ye,{form:m})]})]})]})}export{dt as AgentConfigPage};
16
- //# sourceMappingURL=AgentConfigPage-Ba8QfXM2.js.map
15
+ }`}),e.jsx("p",{className:_,children:"Static payload passed to the workflow on each invocation."})]})]})]})]})}function W({icon:s,color:a,title:r,children:o}){return e.jsxs("div",{className:"mb-10",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2 pb-1.5 border-b border-surface-border/40",children:[e.jsx(s,{className:`w-3.5 h-3.5 ${a}`,strokeWidth:1.5}),e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-widest text-accent/80",children:r})]}),e.jsx("div",{className:"pl-5.5",children:o})]})}function T({label:s,children:a}){return e.jsxs("div",{className:"flex gap-3 py-0.5",children:[e.jsx("span",{className:"text-[10px] text-text-quaternary w-20 shrink-0",children:s}),e.jsx("span",{className:"text-xs text-text-primary",children:a})]})}function Ye({form:s}){return e.jsxs("div",{children:[e.jsxs(W,{icon:V,color:"text-accent",title:"Identity",children:[e.jsx(T,{label:"Name",children:s.name||"—"}),s.description&&e.jsx(T,{label:"Description",children:s.description})]}),(s.goals||s.rules)&&e.jsxs(W,{icon:ee,color:"text-rose-400",title:"Motivation",children:[s.goals&&e.jsx(T,{label:"Goals",children:s.goals}),s.rules&&e.jsx(T,{label:"Rules",children:s.rules})]}),e.jsx(W,{icon:U,color:"text-emerald-400",title:"Knowledge",children:e.jsx(T,{label:"Domain",children:s.knowledge_domain||"None"})}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-10",children:[e.jsx(W,{icon:Y,color:"text-cyan-400",title:`Subscriptions (${s.subscriptions.length})`,children:s.subscriptions.length===0?e.jsx("span",{className:"text-[11px] text-text-quaternary",children:"None configured"}):e.jsx("div",{className:"divide-y divide-surface-border/30",children:s.subscriptions.map((a,r)=>e.jsxs("div",{className:"flex items-center py-1.5",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(ce,{topic:a.topic||"unset"})}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx("span",{className:"text-text-quaternary text-[10px]",children:"→"}),a.workflow_type?e.jsx(Q,{type:a.workflow_type}):e.jsx("span",{className:"text-[11px] text-text-quaternary",children:a.reaction_type})]})]},r))})}),e.jsx(W,{icon:G,color:"text-amber-400",title:`Schedules (${s.schedules.length})`,children:s.schedules.length===0?e.jsx("span",{className:"text-[11px] text-text-quaternary",children:"None configured"}):e.jsx("div",{className:"divide-y divide-surface-border/30",children:s.schedules.map((a,r)=>e.jsxs("div",{className:"flex items-center py-1.5",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(de,{cron:a.cron})}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx("span",{className:"text-text-quaternary text-[10px]",children:"→"}),a.workflow_type?e.jsx(Q,{type:a.workflow_type}):e.jsx("span",{className:"text-[11px] text-text-quaternary",children:"no workflow"})]})]},r))})})]}),e.jsx("div",{className:"border-l-2 border-emerald-400/30 pl-3 py-2 mt-6",children:e.jsx("p",{className:"text-[11px] text-text-tertiary leading-relaxed",children:"After saving, subscriptions and schedules activate immediately. You can pause the automation anytime."})})]})}const Ge=[{id:1,label:"Identity",icon:V},{id:2,label:"Motivation",icon:ee},{id:3,label:"Knowledge",icon:U},{id:4,label:"Subscriptions",icon:Y},{id:5,label:"Schedules",icon:G},{id:6,label:"Review",icon:ye}];function dt(){var H;const{id:s}=_e(),a=!s,r=ke(),{data:o}=fe(),u=!!((H=o==null?void 0:o.ai)!=null&&H.enabled)?"Agent":"Automation",{data:n,isLoading:h}=re(a?null:s),{data:p}=pe(a?null:s),c=le(),f=oe(),l=xe(),d=ue(),y=me(),[m,t]=v.useState(X),[i,b]=v.useState(!1),[g,k]=v.useState(""),[E,R]=Ce(),w=parseInt(E.get("step")||"1",10),P=v.useCallback(j=>{R(N=>{const q=new URLSearchParams(N);return q.set("step",String(j)),q},{replace:!0})},[R]);v.useEffect(()=>{if(!i){if(a){t(X),b(!0);return}n&&p&&(t(Oe(n,p.subscriptions??[])),b(!0))}},[n,p,a,i]);const I=(j,N)=>t(q=>({...q,[j]:N})),ne=async()=>{k("");try{const j=Re(m);let N=s;a?N=(await c.mutateAsync(j)).id:await f.mutateAsync({id:s,...j});const q=Ae(m),ie=(p==null?void 0:p.subscriptions)??[],J=new Set(ie.map(C=>C.id));for(const C of q)if(C.id&&J.has(C.id)){const{id:F,...D}=C;await d.mutateAsync({agentId:N,subId:F,...D}),J.delete(F)}else{const{id:F,...D}=C;await l.mutateAsync({agentId:N,...D})}for(const C of J)await y.mutateAsync({agentId:N,subId:C});r(`/agents/${N}`)}catch(j){k(j.message)}};if(!a&&h)return e.jsxs("div",{className:"animate-pulse space-y-4",children:[e.jsx("div",{className:"h-8 bg-surface-sunken rounded w-48"}),e.jsx("div",{className:"h-60 bg-surface-sunken rounded"})]});const K=c.isPending||f.isPending;return e.jsxs("div",{children:[e.jsx(ve,{title:a?`New ${u}`:`${u}: ${(n==null?void 0:n.id)??""}`,docsHash:"#docs:agents.md"}),e.jsxs("div",{className:"flex gap-10",children:[e.jsxs("nav",{className:"w-44 shrink-0 sticky top-0 self-start pt-2",children:[e.jsx("div",{className:"space-y-0.5",children:Ge.map(j=>{const N=j.icon,q=w===j.id;return e.jsxs("button",{onClick:()=>P(j.id),className:`w-full flex items-center gap-2.5 px-3 py-2 rounded-md text-left transition-colors ${q?"bg-accent/10 text-accent":"text-text-tertiary hover:text-text-primary hover:bg-surface-hover"}`,children:[e.jsx(N,{className:"w-3.5 h-3.5 shrink-0",strokeWidth:1.5}),e.jsx("span",{className:"text-xs font-medium",children:j.label})]},j.id)})}),e.jsxs("div",{className:"mt-8 pt-4 border-t border-surface-border space-y-2",children:[e.jsx("button",{onClick:ne,disabled:!m.name.trim()||K,className:"w-full btn-primary text-xs disabled:opacity-50",children:K?"Saving...":a?`Create ${u}`:"Save"}),e.jsx("button",{onClick:()=>r(a?"/agents":`/agents/${s}`),className:"w-full btn-ghost text-xs",children:"Cancel"})]}),g&&e.jsx("p",{className:"text-xs text-status-error mt-3",children:g})]}),e.jsxs("div",{className:"flex-1 min-w-0 pt-2",children:[w===1&&e.jsx($e,{form:m,set:I}),w===2&&e.jsx(Pe,{form:m,set:I}),w===3&&e.jsx(Ie,{form:m,set:I}),w===4&&e.jsx(Je,{form:m,set:I}),w===5&&e.jsx(Ue,{form:m,set:I}),w===6&&e.jsx(Ye,{form:m})]})]})]})}export{dt as AgentConfigPage};
16
+ //# sourceMappingURL=AgentConfigPage-C6gDgz21.js.map