@hotmeshio/long-tail 0.3.0 → 0.3.2

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 (314) hide show
  1. package/build/api/topics.d.ts +22 -0
  2. package/build/api/topics.js +104 -0
  3. package/build/index.d.ts +3 -1
  4. package/build/index.js +7 -2
  5. package/build/lib/db/schemas/001_schema.sql +3 -3
  6. package/build/lib/db/schemas/006_agent_sub_unique.sql +1 -0
  7. package/build/lib/db/schemas/007_topic_catalog.sql +27 -0
  8. package/build/routes/index.js +2 -0
  9. package/build/routes/topics.d.ts +2 -0
  10. package/build/routes/topics.js +90 -0
  11. package/build/services/topics/index.d.ts +77 -0
  12. package/build/services/topics/index.js +116 -0
  13. package/build/services/topics/sql.d.ts +10 -0
  14. package/build/services/topics/sql.js +80 -0
  15. package/build/services/topics/system-topics.d.ts +11 -0
  16. package/build/services/topics/system-topics.js +270 -0
  17. package/build/start/workers.js +5 -0
  18. package/build/system/mcp-servers/events.js +73 -1
  19. package/build/system/seed/tool-manifests-events.d.ts +75 -0
  20. package/build/system/seed/tool-manifests-events.js +27 -0
  21. package/build/tsconfig.tsbuildinfo +1 -1
  22. package/build/types/index.d.ts +2 -2
  23. package/build/types/startup.d.ts +27 -0
  24. package/dashboard/dist/assets/AdminDashboard-CbeSejVX.js +2 -0
  25. package/dashboard/dist/assets/{AdminDashboard-Bb6zouF5.js.map → AdminDashboard-CbeSejVX.js.map} +1 -1
  26. package/dashboard/dist/assets/AgentConfigPage-CFJNOrlg.js +13 -0
  27. package/dashboard/dist/assets/AgentConfigPage-CFJNOrlg.js.map +1 -0
  28. package/dashboard/dist/assets/AgentDetailPage-Dbx2t-Uk.js +4 -0
  29. package/dashboard/dist/assets/{AgentDetailPage-WwA573u9.js.map → AgentDetailPage-Dbx2t-Uk.js.map} +1 -1
  30. package/dashboard/dist/assets/AgentsPage-Bz61Nl-x.js +2 -0
  31. package/dashboard/dist/assets/{AgentsPage-BZkZ_hXN.js.map → AgentsPage-Bz61Nl-x.js.map} +1 -1
  32. package/dashboard/dist/assets/AvailableEscalationsPage-DdrzePy4.js +2 -0
  33. package/dashboard/dist/assets/{AvailableEscalationsPage-C-Df3ZsZ.js.map → AvailableEscalationsPage-DdrzePy4.js.map} +1 -1
  34. package/dashboard/dist/assets/BotPicker-kKBifD1w.js +2 -0
  35. package/dashboard/dist/assets/{BotPicker-CwfVVWxh.js.map → BotPicker-kKBifD1w.js.map} +1 -1
  36. package/dashboard/dist/assets/CapabilitiesPage-Ch5qY0I7.js +2 -0
  37. package/dashboard/dist/assets/{CapabilitiesPage-DJEQ_5dV.js.map → CapabilitiesPage-Ch5qY0I7.js.map} +1 -1
  38. package/dashboard/dist/assets/CollapsibleSection-kYTBL7dT.js +2 -0
  39. package/dashboard/dist/assets/{CollapsibleSection-DaFQGU6S.js.map → CollapsibleSection-kYTBL7dT.js.map} +1 -1
  40. package/dashboard/dist/assets/ConfirmDeleteModal-CcaAapMl.js +2 -0
  41. package/dashboard/dist/assets/{ConfirmDeleteModal-dOxidrSR.js.map → ConfirmDeleteModal-CcaAapMl.js.map} +1 -1
  42. package/dashboard/dist/assets/CopyableId-B4CL12pv.js +2 -0
  43. package/dashboard/dist/assets/{CopyableId-DmLF-RqZ.js.map → CopyableId-B4CL12pv.js.map} +1 -1
  44. package/dashboard/dist/assets/CredentialsPage-D1VAlwid.js +2 -0
  45. package/dashboard/dist/assets/{CredentialsPage-D-tkqdhu.js.map → CredentialsPage-D1VAlwid.js.map} +1 -1
  46. package/dashboard/dist/assets/CronLabel-DRmO5rH0.js +2 -0
  47. package/dashboard/dist/assets/{CronLabel-C6iCjsXd.js.map → CronLabel-DRmO5rH0.js.map} +1 -1
  48. package/dashboard/dist/assets/CustomDurationPicker-C06QDDir.js +2 -0
  49. package/dashboard/dist/assets/{CustomDurationPicker--wCtBkmT.js.map → CustomDurationPicker-C06QDDir.js.map} +1 -1
  50. package/dashboard/dist/assets/DataTable-J5R6mepB.js +2 -0
  51. package/dashboard/dist/assets/{DataTable-D9yuBv0w.js.map → DataTable-J5R6mepB.js.map} +1 -1
  52. package/dashboard/dist/assets/DropZone-DwNj3GiG.js +2 -0
  53. package/dashboard/dist/assets/{DropZone-2mGyDo1P.js.map → DropZone-DwNj3GiG.js.map} +1 -1
  54. package/dashboard/dist/assets/ElapsedCell-ChyMzl9n.js +2 -0
  55. package/dashboard/dist/assets/{ElapsedCell-DKoH0bqR.js.map → ElapsedCell-ChyMzl9n.js.map} +1 -1
  56. package/dashboard/dist/assets/EmptyState-BXGvOADa.js +2 -0
  57. package/dashboard/dist/assets/{EmptyState-BcsfPq9T.js.map → EmptyState-BXGvOADa.js.map} +1 -1
  58. package/dashboard/dist/assets/EscalationsOverview-DM6zmE4g.js +2 -0
  59. package/dashboard/dist/assets/{EscalationsOverview-C6A4Q9Ne.js.map → EscalationsOverview-DM6zmE4g.js.map} +1 -1
  60. package/dashboard/dist/assets/EventTable-CvJ98E8s.js +2 -0
  61. package/dashboard/dist/assets/{EventTable-DWxH0vMp.js.map → EventTable-CvJ98E8s.js.map} +1 -1
  62. package/dashboard/dist/assets/EventTopicPill-CB_rIGlL.js +2 -0
  63. package/dashboard/dist/assets/{EventTopicPill-BUxxvpNg.js.map → EventTopicPill-CB_rIGlL.js.map} +1 -1
  64. package/dashboard/dist/assets/FilterBar-Bdssa-Xn.js +2 -0
  65. package/dashboard/dist/assets/{FilterBar-Ck4K4rzu.js.map → FilterBar-Bdssa-Xn.js.map} +1 -1
  66. package/dashboard/dist/assets/HomePage-BuZkdXZt.js +2 -0
  67. package/dashboard/dist/assets/{HomePage-Tlu1j8fK.js.map → HomePage-BuZkdXZt.js.map} +1 -1
  68. package/dashboard/dist/assets/ListToolbar-jy8NL6ll.js +2 -0
  69. package/dashboard/dist/assets/{ListToolbar-DuON-br0.js.map → ListToolbar-jy8NL6ll.js.map} +1 -1
  70. package/dashboard/dist/assets/McpOverview-xkaKuHbX.js +2 -0
  71. package/dashboard/dist/assets/{McpOverview-byott48x.js.map → McpOverview-xkaKuHbX.js.map} +1 -1
  72. package/dashboard/dist/assets/McpQueryDetailPage-D5ICn6cR.js +5 -0
  73. package/dashboard/dist/assets/{McpQueryDetailPage-ieZPpcPn.js.map → McpQueryDetailPage-D5ICn6cR.js.map} +1 -1
  74. package/dashboard/dist/assets/McpQueryPage-C46fzfm5.js +2 -0
  75. package/dashboard/dist/assets/{McpQueryPage-BOO0ACYO.js.map → McpQueryPage-C46fzfm5.js.map} +1 -1
  76. package/dashboard/dist/assets/McpRunDetailPage-Znsl4Yc-.js +2 -0
  77. package/dashboard/dist/assets/{McpRunDetailPage-Di8s7-u9.js.map → McpRunDetailPage-Znsl4Yc-.js.map} +1 -1
  78. package/dashboard/dist/assets/McpRunsPage-DT-armx5.js +2 -0
  79. package/dashboard/dist/assets/{McpRunsPage-DdUVqUFi.js.map → McpRunsPage-DT-armx5.js.map} +1 -1
  80. package/dashboard/dist/assets/Modal-C6k6_5KB.js +2 -0
  81. package/dashboard/dist/assets/{Modal-DEODGeqx.js.map → Modal-C6k6_5KB.js.map} +1 -1
  82. package/dashboard/dist/assets/OperatorDashboard-e5N3_dVl.js +2 -0
  83. package/dashboard/dist/assets/{OperatorDashboard-oGmDbNYv.js.map → OperatorDashboard-e5N3_dVl.js.map} +1 -1
  84. package/dashboard/dist/assets/PageHeader-COcgWWf-.js +2 -0
  85. package/dashboard/dist/assets/{PageHeader-DLjHNYHX.js.map → PageHeader-COcgWWf-.js.map} +1 -1
  86. package/dashboard/dist/assets/PageHeaderWithStats-C0PCY3aJ.js +2 -0
  87. package/dashboard/dist/assets/{PageHeaderWithStats-Oljg3n4j.js.map → PageHeaderWithStats-C0PCY3aJ.js.map} +1 -1
  88. package/dashboard/dist/assets/PriorityBadge-BQCsYMpM.js +2 -0
  89. package/dashboard/dist/assets/{PriorityBadge-DfQY9St9.js.map → PriorityBadge-BQCsYMpM.js.map} +1 -1
  90. package/dashboard/dist/assets/ProcessDetailPage-C03LOgI0.js +2 -0
  91. package/dashboard/dist/assets/{ProcessDetailPage-Da-miMYZ.js.map → ProcessDetailPage-C03LOgI0.js.map} +1 -1
  92. package/dashboard/dist/assets/ProcessesListPage-iyPsmlhm.js +2 -0
  93. package/dashboard/dist/assets/{ProcessesListPage-CW-2yFw_.js.map → ProcessesListPage-iyPsmlhm.js.map} +1 -1
  94. package/dashboard/dist/assets/RolePill-CHwys1f9.js +2 -0
  95. package/dashboard/dist/assets/{RolePill-Bp10-WfX.js.map → RolePill-CHwys1f9.js.map} +1 -1
  96. package/dashboard/dist/assets/RolesPage-Bmc3XaUk.js +2 -0
  97. package/dashboard/dist/assets/{RolesPage-Bg_hEu9H.js.map → RolesPage-Bmc3XaUk.js.map} +1 -1
  98. package/dashboard/dist/assets/RowActions-Bs4PF-Gd.js +2 -0
  99. package/dashboard/dist/assets/{RowActions-Dg-Fsm5O.js.map → RowActions-Bs4PF-Gd.js.map} +1 -1
  100. package/dashboard/dist/assets/RunAsSelector-DXzAr2WW.js +2 -0
  101. package/dashboard/dist/assets/{RunAsSelector-hYP59xHH.js.map → RunAsSelector-DXzAr2WW.js.map} +1 -1
  102. package/dashboard/dist/assets/ServerName-BIdLC1Ay.js +2 -0
  103. package/dashboard/dist/assets/{ServerName-C9lUCFYb.js.map → ServerName-BIdLC1Ay.js.map} +1 -1
  104. package/dashboard/dist/assets/StatCard-OKzRSSx4.js +2 -0
  105. package/dashboard/dist/assets/{StatCard-DlgF0CJC.js.map → StatCard-OKzRSSx4.js.map} +1 -1
  106. package/dashboard/dist/assets/StatusBadge-CQlF46RR.js +2 -0
  107. package/dashboard/dist/assets/{StatusBadge-XQlNFwmH.js.map → StatusBadge-CQlF46RR.js.map} +1 -1
  108. package/dashboard/dist/assets/StepIndicator-CP7eycjI.js +2 -0
  109. package/dashboard/dist/assets/{StepIndicator-CuUIGxKk.js.map → StepIndicator-CP7eycjI.js.map} +1 -1
  110. package/dashboard/dist/assets/StickyPagination-CGk8VAKt.js +2 -0
  111. package/dashboard/dist/assets/{StickyPagination-F9FZsRy9.js.map → StickyPagination-CGk8VAKt.js.map} +1 -1
  112. package/dashboard/dist/assets/SwimlaneTimeline-MEUPc3yJ.js +2 -0
  113. package/dashboard/dist/assets/{SwimlaneTimeline-2JHwAM2f.js.map → SwimlaneTimeline-MEUPc3yJ.js.map} +1 -1
  114. package/dashboard/dist/assets/TagInput-BGxXKiWD.js +2 -0
  115. package/dashboard/dist/assets/{TagInput-Dkljw_WI.js.map → TagInput-BGxXKiWD.js.map} +1 -1
  116. package/dashboard/dist/assets/TaskDetailPage-pN5BXzYA.js +2 -0
  117. package/dashboard/dist/assets/TaskDetailPage-pN5BXzYA.js.map +1 -0
  118. package/dashboard/dist/assets/TaskQueuePill-bw8ieKsf.js +2 -0
  119. package/dashboard/dist/assets/{TaskQueuePill-DPwm25Cc.js.map → TaskQueuePill-bw8ieKsf.js.map} +1 -1
  120. package/dashboard/dist/assets/TasksListPage-D1INzcrA.js +2 -0
  121. package/dashboard/dist/assets/{TasksListPage-kCH4r-70.js.map → TasksListPage-D1INzcrA.js.map} +1 -1
  122. package/dashboard/dist/assets/TimeAgo-CywLVIBA.js +2 -0
  123. package/dashboard/dist/assets/{TimeAgo-RPbch7Te.js.map → TimeAgo-CywLVIBA.js.map} +1 -1
  124. package/dashboard/dist/assets/TimestampCell-B4Pc6f3A.js +2 -0
  125. package/dashboard/dist/assets/{TimestampCell-Dgpl-lKv.js.map → TimestampCell-B4Pc6f3A.js.map} +1 -1
  126. package/dashboard/dist/assets/ToolPill-DdLN3JOT.js +2 -0
  127. package/dashboard/dist/assets/{ToolPill-D_DIWFJ5.js.map → ToolPill-DdLN3JOT.js.map} +1 -1
  128. package/dashboard/dist/assets/ToolTestPanel-DusbUka5.js +2 -0
  129. package/dashboard/dist/assets/{ToolTestPanel-D1TWdZQi.js.map → ToolTestPanel-DusbUka5.js.map} +1 -1
  130. package/dashboard/dist/assets/TopicDetailPage-DadwM52Y.js +9 -0
  131. package/dashboard/dist/assets/TopicDetailPage-DadwM52Y.js.map +1 -0
  132. package/dashboard/dist/assets/TopicsPage-DbtrnQON.js +2 -0
  133. package/dashboard/dist/assets/TopicsPage-DbtrnQON.js.map +1 -0
  134. package/dashboard/dist/assets/UserName-CLbusknU.js +2 -0
  135. package/dashboard/dist/assets/{UserName-BXZGXJsU.js.map → UserName-CLbusknU.js.map} +1 -1
  136. package/dashboard/dist/assets/WorkflowExecutionPage-C61R-3Gg.js +2 -0
  137. package/dashboard/dist/assets/{WorkflowExecutionPage-DWlNYb2M.js.map → WorkflowExecutionPage-C61R-3Gg.js.map} +1 -1
  138. package/dashboard/dist/assets/WorkflowPill-7vt2F6wR.js +2 -0
  139. package/dashboard/dist/assets/{WorkflowPill-BbgVTGgI.js.map → WorkflowPill-7vt2F6wR.js.map} +1 -1
  140. package/dashboard/dist/assets/WorkflowsDashboard-BWiUNvyl.js +2 -0
  141. package/dashboard/dist/assets/{WorkflowsDashboard-Dgq8RcD6.js.map → WorkflowsDashboard-BWiUNvyl.js.map} +1 -1
  142. package/dashboard/dist/assets/WorkflowsOverview-DA2ZOs7D.js +2 -0
  143. package/dashboard/dist/assets/{WorkflowsOverview-DnInrUPO.js.map → WorkflowsOverview-DA2ZOs7D.js.map} +1 -1
  144. package/dashboard/dist/assets/YamlWorkflowsPage-CLebf2eL.js +2 -0
  145. package/dashboard/dist/assets/{YamlWorkflowsPage-z1Z9J-mc.js.map → YamlWorkflowsPage-CLebf2eL.js.map} +1 -1
  146. package/dashboard/dist/assets/{agents-C9RLPt1z.js → agents-Dga6NU7U.js} +2 -2
  147. package/dashboard/dist/assets/{agents-C9RLPt1z.js.map → agents-Dga6NU7U.js.map} +1 -1
  148. package/dashboard/dist/assets/{bots-zyUDnQhH.js → bots-CtU4i4OQ.js} +2 -2
  149. package/dashboard/dist/assets/{bots-zyUDnQhH.js.map → bots-CtU4i4OQ.js.map} +1 -1
  150. package/dashboard/dist/assets/{controlplane-v-5KV6pl.js → controlplane-BVoALhbL.js} +2 -2
  151. package/dashboard/dist/assets/{controlplane-v-5KV6pl.js.map → controlplane-BVoALhbL.js.map} +1 -1
  152. package/dashboard/dist/assets/escalation-_N5GfuIi.js +2 -0
  153. package/dashboard/dist/assets/{escalation-BseAikei.js.map → escalation-_N5GfuIi.js.map} +1 -1
  154. package/dashboard/dist/assets/escalation-columns-CoTmTpHp.js +2 -0
  155. package/dashboard/dist/assets/{escalation-columns-Cs2CkkEs.js.map → escalation-columns-CoTmTpHp.js.map} +1 -1
  156. package/dashboard/dist/assets/helpers-Dz2U3Ctb.js +2 -0
  157. package/dashboard/dist/assets/{helpers-DVICI_VA.js.map → helpers-Dz2U3Ctb.js.map} +1 -1
  158. package/dashboard/dist/assets/index-6Kd78p_v.js +2 -0
  159. package/dashboard/dist/assets/{index-BzBZo8Sn.js.map → index-6Kd78p_v.js.map} +1 -1
  160. package/dashboard/dist/assets/index-B9ealjkt.js +6 -0
  161. package/dashboard/dist/assets/{index-CPpNn3z2.js.map → index-B9ealjkt.js.map} +1 -1
  162. package/dashboard/dist/assets/index-BIUHY2Jz.css +1 -0
  163. package/dashboard/dist/assets/index-BWHDW_CF.js +2 -0
  164. package/dashboard/dist/assets/{index-XCEX7Zof.js.map → index-BWHDW_CF.js.map} +1 -1
  165. package/dashboard/dist/assets/index-BYwPVJv0.js +15 -0
  166. package/dashboard/dist/assets/{index-M17tP_HX.js.map → index-BYwPVJv0.js.map} +1 -1
  167. package/dashboard/dist/assets/index-CCOSf1PY.js +281 -0
  168. package/dashboard/dist/assets/index-CCOSf1PY.js.map +1 -0
  169. package/dashboard/dist/assets/index-CS61sh5q.js +2 -0
  170. package/dashboard/dist/assets/{index-BP76o_S8.js.map → index-CS61sh5q.js.map} +1 -1
  171. package/dashboard/dist/assets/index-CtbG3UN-.js +5 -0
  172. package/dashboard/dist/assets/{index-DVFm5329.js.map → index-CtbG3UN-.js.map} +1 -1
  173. package/dashboard/dist/assets/index-DWUunWxh.js +2 -0
  174. package/dashboard/dist/assets/{index-DyqdoZPY.js.map → index-DWUunWxh.js.map} +1 -1
  175. package/dashboard/dist/assets/index-D_H_Prht.js +2 -0
  176. package/dashboard/dist/assets/{index-C0TSBQw8.js.map → index-D_H_Prht.js.map} +1 -1
  177. package/dashboard/dist/assets/index-Dpjguclc.js +2 -0
  178. package/dashboard/dist/assets/{index-DDFK1A8T.js.map → index-Dpjguclc.js.map} +1 -1
  179. package/dashboard/dist/assets/index-QicYdUsl.js +2 -0
  180. package/dashboard/dist/assets/{index-tK8lfgAj.js.map → index-QicYdUsl.js.map} +1 -1
  181. package/dashboard/dist/assets/index-dM-OgCY3.js +2 -0
  182. package/dashboard/dist/assets/{index-D2tDlpuv.js.map → index-dM-OgCY3.js.map} +1 -1
  183. package/dashboard/dist/assets/{knowledge-BhK8xuod.js → knowledge-DJlebU82.js} +2 -2
  184. package/dashboard/dist/assets/{knowledge-BhK8xuod.js.map → knowledge-DJlebU82.js.map} +1 -1
  185. package/dashboard/dist/assets/{mcp-CWFliwjc.js → mcp-CsLJ5SRm.js} +2 -2
  186. package/dashboard/dist/assets/{mcp-CWFliwjc.js.map → mcp-CsLJ5SRm.js.map} +1 -1
  187. package/dashboard/dist/assets/{mcp-query-Dm7_m5Fi.js → mcp-query-WNK1ItRV.js} +2 -2
  188. package/dashboard/dist/assets/{mcp-query-Dm7_m5Fi.js.map → mcp-query-WNK1ItRV.js.map} +1 -1
  189. package/dashboard/dist/assets/{mcp-runs-aBDudwEi.js → mcp-runs-DtTTsuPH.js} +2 -2
  190. package/dashboard/dist/assets/{mcp-runs-aBDudwEi.js.map → mcp-runs-DtTTsuPH.js.map} +1 -1
  191. package/dashboard/dist/assets/namespaces-iRejH3_A.js +2 -0
  192. package/dashboard/dist/assets/{namespaces-C45c4uoO.js.map → namespaces-iRejH3_A.js.map} +1 -1
  193. package/dashboard/dist/assets/{roles-BMAzzeHR.js → roles-3Jm5KtKc.js} +2 -2
  194. package/dashboard/dist/assets/{roles-BMAzzeHR.js.map → roles-3Jm5KtKc.js.map} +1 -1
  195. package/dashboard/dist/assets/settings-DmN2I-c6.js +2 -0
  196. package/dashboard/dist/assets/{settings-D0v7RI3o.js.map → settings-DmN2I-c6.js.map} +1 -1
  197. package/dashboard/dist/assets/{tasks-DwEUQ6my.js → tasks-Cc-QoITQ.js} +2 -2
  198. package/dashboard/dist/assets/{tasks-DwEUQ6my.js.map → tasks-Cc-QoITQ.js.map} +1 -1
  199. package/dashboard/dist/assets/topics-p8anbgi0.js +2 -0
  200. package/dashboard/dist/assets/topics-p8anbgi0.js.map +1 -0
  201. package/dashboard/dist/assets/{useEventHooks-BccPxFR6.js → useEventHooks-VaJ52jMm.js} +2 -2
  202. package/dashboard/dist/assets/{useEventHooks-BccPxFR6.js.map → useEventHooks-VaJ52jMm.js.map} +1 -1
  203. package/dashboard/dist/assets/{useExpandedRows-CkcEntB-.js → useExpandedRows-Cg9iq6Vy.js} +2 -2
  204. package/dashboard/dist/assets/{useExpandedRows-CkcEntB-.js.map → useExpandedRows-Cg9iq6Vy.js.map} +1 -1
  205. package/dashboard/dist/assets/{useFilterParams-DZCAaBC7.js → useFilterParams-CGRYFw_A.js} +2 -2
  206. package/dashboard/dist/assets/{useFilterParams-DZCAaBC7.js.map → useFilterParams-CGRYFw_A.js.map} +1 -1
  207. package/dashboard/dist/assets/{useYamlActivityEvents-BBioXSKA.js → useYamlActivityEvents-BU4Uhksl.js} +2 -2
  208. package/dashboard/dist/assets/{useYamlActivityEvents-BBioXSKA.js.map → useYamlActivityEvents-BU4Uhksl.js.map} +1 -1
  209. package/dashboard/dist/assets/{users-CCHT00of.js → users-oXOlnold.js} +2 -2
  210. package/dashboard/dist/assets/{users-CCHT00of.js.map → users-oXOlnold.js.map} +1 -1
  211. package/dashboard/dist/assets/{vendor-icons-E6836lXZ.js → vendor-icons-CBOM6Es0.js} +100 -95
  212. package/dashboard/dist/assets/vendor-icons-CBOM6Es0.js.map +1 -0
  213. package/dashboard/dist/assets/vendor-query-DLp59M9_.js +35 -0
  214. package/dashboard/dist/assets/vendor-query-DLp59M9_.js.map +1 -0
  215. package/dashboard/dist/assets/vendor-react-Co3Y8ikm.js +26 -0
  216. package/dashboard/dist/assets/vendor-react-Co3Y8ikm.js.map +1 -0
  217. package/dashboard/dist/assets/{workflows-DNZf6Pmq.js → workflows-Yq7cK-vR.js} +2 -2
  218. package/dashboard/dist/assets/{workflows-DNZf6Pmq.js.map → workflows-Yq7cK-vR.js.map} +1 -1
  219. package/dashboard/dist/assets/{yaml-workflows-BKZdGciI.js → yaml-workflows-Ch53yD43.js} +2 -2
  220. package/dashboard/dist/assets/{yaml-workflows-BKZdGciI.js.map → yaml-workflows-Ch53yD43.js.map} +1 -1
  221. package/dashboard/dist/index.html +5 -5
  222. package/docs/agents.md +6 -0
  223. package/docs/api/http/topics.md +164 -0
  224. package/docs/api/sdk/topics.md +204 -0
  225. package/docs/dashboard.md +22 -0
  226. package/docs/events.md +7 -0
  227. package/docs/sdk.md +15 -0
  228. package/docs/topics.md +154 -0
  229. package/package.json +2 -2
  230. package/dashboard/dist/assets/AdminDashboard-Bb6zouF5.js +0 -2
  231. package/dashboard/dist/assets/AgentConfigPage-DqHEK73E.js +0 -13
  232. package/dashboard/dist/assets/AgentConfigPage-DqHEK73E.js.map +0 -1
  233. package/dashboard/dist/assets/AgentDetailPage-WwA573u9.js +0 -4
  234. package/dashboard/dist/assets/AgentsPage-BZkZ_hXN.js +0 -2
  235. package/dashboard/dist/assets/AvailableEscalationsPage-C-Df3ZsZ.js +0 -2
  236. package/dashboard/dist/assets/BotPicker-CwfVVWxh.js +0 -2
  237. package/dashboard/dist/assets/CapabilitiesPage-DJEQ_5dV.js +0 -2
  238. package/dashboard/dist/assets/CollapsibleSection-DaFQGU6S.js +0 -2
  239. package/dashboard/dist/assets/ConfirmDeleteModal-dOxidrSR.js +0 -2
  240. package/dashboard/dist/assets/CopyableId-DmLF-RqZ.js +0 -2
  241. package/dashboard/dist/assets/CredentialsPage-D-tkqdhu.js +0 -2
  242. package/dashboard/dist/assets/CronLabel-C6iCjsXd.js +0 -2
  243. package/dashboard/dist/assets/CustomDurationPicker--wCtBkmT.js +0 -2
  244. package/dashboard/dist/assets/DataTable-D9yuBv0w.js +0 -2
  245. package/dashboard/dist/assets/DropZone-2mGyDo1P.js +0 -2
  246. package/dashboard/dist/assets/ElapsedCell-DKoH0bqR.js +0 -2
  247. package/dashboard/dist/assets/EmptyState-BcsfPq9T.js +0 -2
  248. package/dashboard/dist/assets/EscalationsOverview-C6A4Q9Ne.js +0 -2
  249. package/dashboard/dist/assets/EventTable-DWxH0vMp.js +0 -2
  250. package/dashboard/dist/assets/EventTopicPill-BUxxvpNg.js +0 -2
  251. package/dashboard/dist/assets/FilterBar-Ck4K4rzu.js +0 -2
  252. package/dashboard/dist/assets/HomePage-Tlu1j8fK.js +0 -2
  253. package/dashboard/dist/assets/ListToolbar-DuON-br0.js +0 -2
  254. package/dashboard/dist/assets/McpOverview-byott48x.js +0 -2
  255. package/dashboard/dist/assets/McpQueryDetailPage-ieZPpcPn.js +0 -5
  256. package/dashboard/dist/assets/McpQueryPage-BOO0ACYO.js +0 -2
  257. package/dashboard/dist/assets/McpRunDetailPage-Di8s7-u9.js +0 -2
  258. package/dashboard/dist/assets/McpRunsPage-DdUVqUFi.js +0 -2
  259. package/dashboard/dist/assets/Modal-DEODGeqx.js +0 -2
  260. package/dashboard/dist/assets/OperatorDashboard-oGmDbNYv.js +0 -2
  261. package/dashboard/dist/assets/PageHeader-DLjHNYHX.js +0 -2
  262. package/dashboard/dist/assets/PageHeaderWithStats-Oljg3n4j.js +0 -2
  263. package/dashboard/dist/assets/PriorityBadge-DfQY9St9.js +0 -2
  264. package/dashboard/dist/assets/ProcessDetailPage-Da-miMYZ.js +0 -2
  265. package/dashboard/dist/assets/ProcessesListPage-CW-2yFw_.js +0 -2
  266. package/dashboard/dist/assets/RolePill-Bp10-WfX.js +0 -2
  267. package/dashboard/dist/assets/RolesPage-Bg_hEu9H.js +0 -2
  268. package/dashboard/dist/assets/RowActions-Dg-Fsm5O.js +0 -2
  269. package/dashboard/dist/assets/RunAsSelector-hYP59xHH.js +0 -2
  270. package/dashboard/dist/assets/ServerName-C9lUCFYb.js +0 -2
  271. package/dashboard/dist/assets/StatCard-DlgF0CJC.js +0 -2
  272. package/dashboard/dist/assets/StatusBadge-XQlNFwmH.js +0 -2
  273. package/dashboard/dist/assets/StepIndicator-CuUIGxKk.js +0 -2
  274. package/dashboard/dist/assets/StickyPagination-F9FZsRy9.js +0 -2
  275. package/dashboard/dist/assets/SwimlaneTimeline-2JHwAM2f.js +0 -2
  276. package/dashboard/dist/assets/TagInput-Dkljw_WI.js +0 -2
  277. package/dashboard/dist/assets/TaskDetailPage--9FEVeTB.js +0 -2
  278. package/dashboard/dist/assets/TaskDetailPage--9FEVeTB.js.map +0 -1
  279. package/dashboard/dist/assets/TaskQueuePill-DPwm25Cc.js +0 -2
  280. package/dashboard/dist/assets/TasksListPage-kCH4r-70.js +0 -2
  281. package/dashboard/dist/assets/TimeAgo-RPbch7Te.js +0 -2
  282. package/dashboard/dist/assets/TimestampCell-Dgpl-lKv.js +0 -2
  283. package/dashboard/dist/assets/ToolPill-D_DIWFJ5.js +0 -2
  284. package/dashboard/dist/assets/ToolTestPanel-D1TWdZQi.js +0 -2
  285. package/dashboard/dist/assets/UserName-BXZGXJsU.js +0 -2
  286. package/dashboard/dist/assets/WorkflowExecutionPage-DWlNYb2M.js +0 -2
  287. package/dashboard/dist/assets/WorkflowPill-BbgVTGgI.js +0 -2
  288. package/dashboard/dist/assets/WorkflowsDashboard-Dgq8RcD6.js +0 -2
  289. package/dashboard/dist/assets/WorkflowsOverview-DnInrUPO.js +0 -2
  290. package/dashboard/dist/assets/YamlWorkflowsPage-z1Z9J-mc.js +0 -2
  291. package/dashboard/dist/assets/escalation-BseAikei.js +0 -2
  292. package/dashboard/dist/assets/escalation-columns-Cs2CkkEs.js +0 -2
  293. package/dashboard/dist/assets/helpers-DVICI_VA.js +0 -2
  294. package/dashboard/dist/assets/index-BMIU7Im5.js +0 -63
  295. package/dashboard/dist/assets/index-BMIU7Im5.js.map +0 -1
  296. package/dashboard/dist/assets/index-BP76o_S8.js +0 -2
  297. package/dashboard/dist/assets/index-BciXgS35.css +0 -1
  298. package/dashboard/dist/assets/index-BzBZo8Sn.js +0 -2
  299. package/dashboard/dist/assets/index-C0TSBQw8.js +0 -2
  300. package/dashboard/dist/assets/index-CPpNn3z2.js +0 -6
  301. package/dashboard/dist/assets/index-D2tDlpuv.js +0 -2
  302. package/dashboard/dist/assets/index-DDFK1A8T.js +0 -2
  303. package/dashboard/dist/assets/index-DVFm5329.js +0 -5
  304. package/dashboard/dist/assets/index-DyqdoZPY.js +0 -2
  305. package/dashboard/dist/assets/index-M17tP_HX.js +0 -15
  306. package/dashboard/dist/assets/index-XCEX7Zof.js +0 -2
  307. package/dashboard/dist/assets/index-tK8lfgAj.js +0 -2
  308. package/dashboard/dist/assets/namespaces-C45c4uoO.js +0 -2
  309. package/dashboard/dist/assets/settings-D0v7RI3o.js +0 -2
  310. package/dashboard/dist/assets/vendor-icons-E6836lXZ.js.map +0 -1
  311. package/dashboard/dist/assets/vendor-query-B2UbickB.js +0 -18
  312. package/dashboard/dist/assets/vendor-query-B2UbickB.js.map +0 -1
  313. package/dashboard/dist/assets/vendor-react-CX88sFS5.js +0 -22
  314. package/dashboard/dist/assets/vendor-react-CX88sFS5.js.map +0 -1
@@ -1,2 +0,0 @@
1
- import{u as o,b as i,c as r,j as u}from"./vendor-query-B2UbickB.js";import{b as n}from"./index-BMIU7Im5.js";import{a1 as c}from"./vendor-icons-E6836lXZ.js";function l(e){return o({queryKey:["agent-subscriptions",e],queryFn:()=>n(`/agents/${e}/subscriptions`),enabled:!!e})}function m(){const e=i();return r({mutationFn:({agentId:s,...t})=>n(`/agents/${s}/subscriptions`,{method:"POST",body:JSON.stringify(t)}),onSuccess:(s,t)=>{e.invalidateQueries({queryKey:["agent-subscriptions",t.agentId]}),e.invalidateQueries({queryKey:["agents"]})}})}function d(){const e=i();return r({mutationFn:({agentId:s,subId:t,...a})=>n(`/agents/${s}/subscriptions/${t}`,{method:"PUT",body:JSON.stringify(a)}),onSuccess:(s,t)=>{e.invalidateQueries({queryKey:["agent-subscriptions",t.agentId]})}})}function g(){const e=i();return r({mutationFn:({agentId:s,subId:t})=>n(`/agents/${s}/subscriptions/${t}`,{method:"DELETE"}),onSuccess:(s,t)=>{e.invalidateQueries({queryKey:["agent-subscriptions",t.agentId]}),e.invalidateQueries({queryKey:["agents"]})}})}function f({cron:e}){return u.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] font-mono text-text-secondary",children:[u.jsx(c,{className:"w-2.5 h-2.5 shrink-0 text-text-quaternary",strokeWidth:1.5}),e]})}export{f as C,m as a,d as b,g as c,l as u};
2
- //# sourceMappingURL=CronLabel-C6iCjsXd.js.map
@@ -1,2 +0,0 @@
1
- import{a as u,j as i}from"./vendor-query-B2UbickB.js";import{u as x}from"./settings-D0v7RI3o.js";import{D as d,f as v}from"./constants-BHkpVaqx.js";function j(){const{data:e}=x();return u.useMemo(()=>{var n;return(((n=e==null?void 0:e.escalation)==null?void 0:n.claimDurations)??d).map(a=>({value:String(a),label:v(a)}))},[e])}const f=[{value:1,label:"minutes"},{value:60,label:"hours"}];function C({onChange:e,compact:r,autoFocus:n,"data-testid":a="custom-duration-input"}){const[l,m]=u.useState(""),[s,c]=u.useState(1);u.useEffect(()=>{const t=parseInt(l);e(t>0?t*s:0)},[l,s,e]);const o=r?"text-xs":"text-sm",p=r?"w-16":"w-20";return i.jsxs("div",{className:"flex items-center gap-2","data-testid":a,children:[i.jsx("input",{type:"number",min:1,max:s===60?24:1440,value:l,onChange:t=>m(t.target.value),placeholder:s===60?"hrs":"min",className:`input ${o} ${p} text-center`,autoFocus:n,"data-testid":`${a}-quantity`}),i.jsx("select",{value:s,onChange:t=>c(parseInt(t.target.value)),className:`select ${o} py-1`,"data-testid":`${a}-unit`,children:f.map(t=>i.jsx("option",{value:t.value,children:t.label},t.value))})]})}export{C,j as u};
2
- //# sourceMappingURL=CustomDurationPicker--wCtBkmT.js.map
@@ -1,2 +0,0 @@
1
- import{j as e}from"./vendor-query-B2UbickB.js";import{E as b}from"./EmptyState-BcsfPq9T.js";function j({active:s,direction:a}){return e.jsx("svg",{className:`w-3 h-3 shrink-0 transition-all duration-150 ${s?"text-accent opacity-100":"opacity-0 group-hover/sorthead:opacity-40 text-text-tertiary"} ${s&&a==="asc"?"rotate-180":""}`,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})}function N({columns:s,data:a,keyFn:l,onRowClick:o,activeRowKey:d,rowClassName:x,isLoading:h,emptyMessage:p="No records found",sort:n,onSort:u,inline:m}){return h?e.jsx("div",{className:"animate-pulse space-y-0",children:Array.from({length:5}).map((r,t)=>e.jsx("div",{className:"h-14 border-b last:border-b-0 px-6 flex items-center",children:e.jsx("div",{className:"h-3 bg-surface-sunken rounded w-full"})},t))}):a.length?e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsx("tr",{className:"border-b",children:s.map(r=>{const t=r.sortable&&u,i=(n==null?void 0:n.sort_by)===r.key;return e.jsx("th",{onClick:t?()=>u(r.key):void 0,className:`${m?"":"sticky top-[2.75rem] z-10 "}bg-surface px-6 py-3 text-left text-[10px] font-semibold uppercase tracking-widest text-text-tertiary whitespace-nowrap ${r.className??""} ${t?"cursor-pointer select-none group/sorthead hover:text-text-secondary transition-colors":""}`,children:e.jsxs("span",{className:"inline-flex items-center gap-1",children:[r.label,t&&e.jsx(j,{active:i,direction:i?n.order:"desc"})]})},r.key)})})}),e.jsx("tbody",{children:a.map((r,t)=>{const i=d!=null&&l(r)===d;return e.jsx("tr",{onClick:o?()=>o(r):void 0,className:`group/row border-b last:border-b-0 transition-colors duration-100 ${o?"cursor-pointer row-hover":""} ${i?"bg-accent/5 border-l-2 border-l-accent":""} ${x?x(r):""}`,children:s.map(c=>e.jsx("td",{className:`px-6 py-2.5 text-sm ${c.className??""}`,children:c.render(r,t)},c.key))},l(r))})})]}):p?e.jsx(b,{title:p}):null}export{N as D};
2
- //# sourceMappingURL=DataTable-D9yuBv0w.js.map
@@ -1,2 +0,0 @@
1
- import{a as n,j as l}from"./vendor-query-B2UbickB.js";import{av as v}from"./vendor-icons-E6836lXZ.js";function D(r,c){const p=c.split(",").map(e=>e.trim());for(const e of p)if(e.startsWith(".")&&r.name.toLowerCase().endsWith(e.toLowerCase())||e===r.type||e.endsWith("/*")&&r.type.startsWith(e.slice(0,-1)))return!0;return!1}function j({onDrop:r,children:c,label:p="Drop files here",accept:e,disabled:i}){const[u,f]=n.useState(!1),s=n.useRef(0),d=n.useCallback(t=>{t.preventDefault(),t.stopPropagation(),s.current++,i||f(!0)},[i]),g=n.useCallback(t=>{t.preventDefault(),t.stopPropagation(),s.current--,s.current<=0&&(s.current=0,f(!1))},[]),x=n.useCallback(t=>{t.preventDefault(),t.stopPropagation()},[]),h=n.useCallback(t=>{if(t.preventDefault(),t.stopPropagation(),s.current=0,f(!1),i)return;const o=Array.from(t.dataTransfer.files);if(console.debug("[DropZone] dropped files:",o.map(a=>({name:a.name,type:a.type,size:a.size}))),e){const a=o.filter(m=>D(m,e));console.debug("[DropZone] after accept filter:",a.length,"of",o.length),a.length?r(a):console.warn("[DropZone] no files matched accept pattern:",e)}else o.length&&r(o)},[r,e,i]);return l.jsxs("div",{className:"relative",onDragEnter:d,onDragLeave:g,onDragOver:x,onDrop:h,children:[c,u&&l.jsx("div",{className:"fixed inset-0 z-50 flex flex-col items-center justify-center transition-opacity pointer-events-none",style:{background:"rgba(var(--color-surface-rgb, 255 255 255) / 0.85)"},children:l.jsxs("div",{className:"flex flex-col items-center gap-2 px-6 py-5 rounded-xl border border-dashed border-text-quaternary/40",children:[l.jsx(v,{className:"w-8 h-8 text-text-tertiary"}),l.jsx("p",{className:"text-xs text-text-secondary",children:p})]})})]})}export{j as D};
2
- //# sourceMappingURL=DropZone-2mGyDo1P.js.map
@@ -1,2 +0,0 @@
1
- import{a as s,j as n}from"./vendor-query-B2UbickB.js";import{y as p,w as f}from"./index-BMIU7Im5.js";function D({startDate:r,endDate:o,isLive:e}){const[l,c]=s.useState(Date.now);s.useEffect(()=>{if(!e)return;const u=setInterval(()=>c(Date.now()),1e3);return()=>clearInterval(u)},[e]);const i=new Date(r).getTime(),m=o?new Date(o).getTime():l,t=Math.max(0,m-i),a=p(t),x=s.useMemo(()=>[{label:"ms",value:String(t)},{label:"sec",value:`${(t/1e3).toFixed(3)}s`},{label:"text",value:a}],[t,a]);return n.jsx(f,{options:x,children:n.jsx("span",{className:`text-xs ${e?"text-status-active":"text-text-tertiary"}`,children:a})})}export{D as E};
2
- //# sourceMappingURL=ElapsedCell-DKoH0bqR.js.map
@@ -1,2 +0,0 @@
1
- import{j as e}from"./vendor-query-B2UbickB.js";function x({title:a="No data",description:t,icon:s}){return e.jsxs("div",{className:"flex flex-col items-center justify-center py-20",children:[s&&e.jsx("div",{className:"w-12 h-12 rounded-full bg-accent/[0.06] flex items-center justify-center mb-4",children:e.jsx(s,{className:"w-5 h-5 text-accent/50"})}),e.jsx("p",{className:"text-sm text-text-secondary",children:a}),t&&e.jsx("p",{className:"text-xs text-text-tertiary mt-1",children:t})]})}export{x as E};
2
- //# sourceMappingURL=EmptyState-BcsfPq9T.js.map
@@ -1,2 +0,0 @@
1
- import{a as m,j as e}from"./vendor-query-B2UbickB.js";import{h as u}from"./index-BMIU7Im5.js";import{e as p}from"./useEventHooks-BccPxFR6.js";import{P as b}from"./PageHeader-DLjHNYHX.js";import{S as n}from"./StatCard-DlgF0CJC.js";import{c as j}from"./vendor-react-CX88sFS5.js";import"./vendor-icons-E6836lXZ.js";const v=[{label:"1h",value:"1h"},{label:"24h",value:"24h"},{label:"7d",value:"7d"},{label:"30d",value:"30d"}];function c({value:i,colorClass:r,onClick:o}){return i===0?e.jsx("span",{className:"text-text-tertiary",children:"0"}):e.jsx("button",{onClick:o,className:`${r} hover:underline tabular-nums font-medium`,children:i})}function $(){var d,x;p();const i=j(),[r,o]=m.useState("24h"),{data:s}=u(r),l=t=>{const h=new URLSearchParams(t).toString();i(`/escalations/available${h?`?${h}`:""}`)},a="pb-2 text-[10px] font-semibold uppercase tracking-widest text-text-tertiary";return e.jsxs("div",{children:[e.jsx(b,{title:"Escalations",docsHash:"#docs:dashboard.md:escalations-overview"}),e.jsx("div",{className:"flex items-center gap-1 mb-6",children:v.map(t=>e.jsx("button",{onClick:()=>o(t.value),className:`px-3 py-1 text-xs rounded-full transition-colors ${r===t.value?"bg-accent text-text-inverse":"text-text-tertiary hover:text-text-primary hover:bg-surface-hover"}`,children:t.label},t.value))}),e.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-8",children:[e.jsx(n,{label:"Open",value:(s==null?void 0:s.pending)??"—",colorClass:"text-status-pending",onClick:()=>l()}),e.jsx(n,{label:"Claimed",value:(s==null?void 0:s.claimed)??"—",colorClass:"text-status-active",onClick:()=>l()}),e.jsx(n,{label:"Created",value:(s==null?void 0:s.created)??"—",onClick:()=>l()}),e.jsx(n,{label:"Resolved",value:(s==null?void 0:s.resolved)??"—",colorClass:"text-status-success",onClick:()=>l()})]}),(((d=s==null?void 0:s.by_role)==null?void 0:d.length)??0)>0&&e.jsx("div",{className:"mb-8",children:e.jsxs("table",{className:"w-full text-left",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-surface-border",children:[e.jsx("th",{className:a,children:"Role"}),e.jsx("th",{className:`${a} text-right w-24`,children:"Pending"}),e.jsx("th",{className:`${a} text-right w-24`,children:"Claimed"})]})}),e.jsx("tbody",{children:s.by_role.map(t=>e.jsxs("tr",{className:"border-b border-surface-border last:border-b-0",children:[e.jsx("td",{className:"py-3 text-sm font-mono text-text-primary",children:e.jsx("button",{onClick:()=>l({role:t.role}),className:"hover:text-accent hover:underline",children:t.role})}),e.jsx("td",{className:"py-3 text-sm text-right",children:e.jsx(c,{value:t.pending,colorClass:"text-status-pending",onClick:()=>l({role:t.role})})}),e.jsx("td",{className:"py-3 text-sm text-right",children:e.jsx(c,{value:t.claimed,colorClass:"text-status-active",onClick:()=>l({role:t.role})})})]},t.role))})]})}),(((x=s==null?void 0:s.by_type)==null?void 0:x.length)??0)>0&&e.jsx("div",{children:e.jsxs("table",{className:"w-full text-left",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-surface-border",children:[e.jsx("th",{className:a,children:"Type"}),e.jsx("th",{className:`${a} text-right w-24`,children:"Pending"}),e.jsx("th",{className:`${a} text-right w-24`,children:"Claimed"}),e.jsx("th",{className:`${a} text-right w-24`,children:"Resolved"})]})}),e.jsx("tbody",{children:s.by_type.map(t=>e.jsxs("tr",{className:"border-b border-surface-border last:border-b-0",children:[e.jsx("td",{className:"py-3 text-sm font-mono text-text-primary",children:e.jsx("button",{onClick:()=>l({type:t.type}),className:"hover:text-accent hover:underline",children:t.type})}),e.jsx("td",{className:"py-3 text-sm text-right",children:e.jsx(c,{value:t.pending,colorClass:"text-status-pending",onClick:()=>l({type:t.type})})}),e.jsx("td",{className:"py-3 text-sm text-right",children:e.jsx(c,{value:t.claimed,colorClass:"text-status-active",onClick:()=>l({type:t.type})})}),e.jsx("td",{className:"py-3 text-sm text-right",children:e.jsx(c,{value:t.resolved,colorClass:"text-status-success",onClick:()=>l({type:t.type})})})]},t.type))})]})}),s&&s.by_role.length===0&&s.by_type.length===0&&e.jsx("div",{className:"py-16 text-center",children:e.jsxs("p",{className:"text-sm text-text-tertiary",children:["No escalation activity in the last ",r]})})]})}export{$ as EscalationsOverview};
2
- //# sourceMappingURL=EscalationsOverview-C6A4Q9Ne.js.map
@@ -1,2 +0,0 @@
1
- import{a as d,j as t}from"./vendor-query-B2UbickB.js";import{F as $,b as g}from"./FilterBar-Ck4K4rzu.js";import{f as T,C as F}from"./index-BMIU7Im5.js";import{E as O}from"./SwimlaneTimeline-2JHwAM2f.js";const y="lt-collapsed-sections";function D(r){try{const n=localStorage.getItem(`${y}:${r}`);return n?new Set(JSON.parse(n)):new Set}catch{return new Set}}function P(r,n){localStorage.setItem(`${y}:${r}`,JSON.stringify([...n]))}function G(r){const[n,l]=d.useState(()=>D(r)),p=d.useCallback(o=>n.has(o),[n]),u=d.useCallback(o=>{l(x=>{const c=new Set(x);return c.has(o)?c.delete(o):c.add(o),P(r,c),c})},[r]);return{isCollapsed:p,toggle:u}}const A=new Set(["activity_task_scheduled","timer_started","child_workflow_execution_started","signal_wait_started"]),L=new Set(["activity_task_completed","activity_task_failed","timer_fired","child_workflow_execution_completed","child_workflow_execution_failed","workflow_execution_signaled"]);function R(r){const n=new Set;for(const l of r)L.has(l.event_type)&&l.attributes.timeline_key&&n.add(l.attributes.timeline_key);return n}function K({events:r,childTasks:n}){const[l,p]=d.useState(""),[u,o]=d.useState(""),[x,c]=d.useState("asc"),[m,f]=d.useState(new Set),b=[...new Set(r.map(e=>e.category))].sort(),w=[...new Set(r.map(e=>e.event_type))].sort(),v=R(r),S=e=>{if(e.duration_ms!==null||!A.has(e.event_type))return!1;const s=e.attributes.timeline_key;return!(s&&v.has(s))};let a=r;l&&(a=a.filter(e=>e.category===l)),u&&(a=a.filter(e=>e.event_type===u)),a=[...a].sort((e,s)=>x==="asc"?e.event_id-s.event_id:s.event_id-e.event_id);const j=e=>{switch(e){case"activity":return"bg-blue-500";case"signal":return"bg-emerald-500";case"timer":return"bg-status-warning";case"child_workflow":return"bg-violet-500";default:return"bg-text-tertiary"}},k=e=>{const s=e.event_type;if(e.attributes.activity_type)return`${s} — ${e.attributes.activity_type}`;if(e.attributes.signal_name)return`${s} — ${e.attributes.signal_name}`;if(e.attributes.child_workflow_id){const i=e.attributes.child_workflow_id,C=i.length>24?`${i.slice(0,24)}...`:i;return`${s} — ${C}`}return s},N=e=>{if(!(n!=null&&n.length))return;const s=e.attributes.activity_type;if(s)return n.find(i=>i.workflow_type===s)},_=e=>{f(s=>{const i=new Set(s);return i.has(e)?i.delete(e):i.add(e),i})},h=a.length>0&&a.every(e=>m.has(e.event_id)),E=()=>{f(h?new Set:new Set(a.map(e=>e.event_id)))};return t.jsxs("div",{children:[t.jsxs("div",{className:"px-6 py-4 border-b border-surface-border flex items-center justify-between flex-wrap gap-3",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary",children:["Events (",a.length,")"]}),a.length>0&&t.jsx("button",{onClick:E,className:"text-[10px] text-accent hover:underline",children:h?"Collapse all":"Expand all"})]}),t.jsxs($,{children:[t.jsx(g,{label:"Category",value:l,onChange:p,options:b.map(e=>({value:e,label:e}))}),t.jsx(g,{label:"Type",value:u,onChange:o,options:w.map(e=>({value:e,label:e}))}),t.jsx("button",{onClick:()=>c(e=>e==="asc"?"desc":"asc"),className:"btn-ghost text-xs",children:x==="asc"?"Oldest first":"Newest first"})]})]}),t.jsx("div",{children:a.length===0?t.jsx("div",{className:"px-6 py-8 text-center",children:t.jsx("p",{className:"text-sm text-text-tertiary",children:"No events match the current filters"})}):a.map(e=>{const s=m.has(e.event_id),i=S(e);return t.jsxs("div",{className:"border-b border-surface-border last:border-b-0",children:[t.jsxs("div",{className:"px-6 py-3 flex items-center gap-4 cursor-pointer hover:bg-surface-hover transition-colors duration-200",onClick:()=>_(e.event_id),children:[t.jsx("span",{className:`text-[10px] text-text-tertiary transition-transform duration-300 ${s?"rotate-90":""}`,children:"▶"}),t.jsx("span",{className:"text-xs font-mono text-text-tertiary w-8 shrink-0",children:e.event_id}),t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${j(e.category)}`}),t.jsx("span",{className:"text-sm text-text-primary flex-1 truncate",children:k(e)}),t.jsx("span",{className:"text-xs font-mono text-text-tertiary shrink-0",children:i?t.jsxs("span",{className:"inline-flex items-center gap-1 text-status-warning",children:[t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-status-warning animate-pulse"}),"Pending"]}):e.duration_ms!==null?T(e.duration_ms):"--"}),t.jsx("time",{className:"text-[10px] font-mono text-text-tertiary shrink-0",children:new Date(e.event_time).toLocaleTimeString()})]}),t.jsx(F,{open:s&&!!e.attributes,children:t.jsx("div",{className:"px-6 pb-4 pl-16",children:t.jsx(O,{event:e,childTask:N(e),pending:i,onClose:()=>_(e.event_id)})})})]},e.event_id)})})]})}export{K as E,G as u};
2
- //# sourceMappingURL=EventTable-DWxH0vMp.js.map
@@ -1,2 +0,0 @@
1
- import{j as e}from"./vendor-query-B2UbickB.js";import{R as a}from"./vendor-icons-E6836lXZ.js";const i={task:"text-blue-400",workflow:"text-accent",escalation:"text-amber-400",activity:"text-cyan-400",knowledge:"text-violet-400",agent:"text-emerald-400",app:"text-rose-400",milestone:"text-violet-400"};function c({topic:t}){const o=t.split(".")[0],s=i[o]??"text-text-quaternary",n=t.split(".").slice(-2).join(".");return e.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] font-mono text-text-secondary",children:[e.jsx(a,{className:`w-2.5 h-2.5 shrink-0 ${s}`,strokeWidth:1.5}),n]})}export{c as E};
2
- //# sourceMappingURL=EventTopicPill-BUxxvpNg.js.map
@@ -1,2 +0,0 @@
1
- import{j as e,a as c}from"./vendor-query-B2UbickB.js";function u({children:a,actions:s}){return e.jsx("div",{className:"sticky top-0 z-20 bg-surface -mx-10 px-10 py-1.5 pb-4 border-b border-surface-border/50",children:e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[a,s&&e.jsx("div",{className:"ml-auto flex items-center gap-2",children:s})]})})}function m({label:a,value:s,onChange:n,options:i,required:x,placeholder:r}){return e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("label",{className:"text-[10px] text-text-tertiary",children:a}),e.jsxs("select",{value:s,onChange:t=>n(t.target.value),className:"select text-[11px] py-1 px-2",children:[!x&&e.jsx("option",{value:"",children:r||"All"}),i.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))]})]})}function d({label:a,value:s,onChange:n,placeholder:i}){const[x,r]=c.useState(s),t=c.useRef(void 0);c.useEffect(()=>{r(s)},[s]);const o=l=>{r(l),clearTimeout(t.current),t.current=setTimeout(()=>n(l),300)};return c.useEffect(()=>()=>clearTimeout(t.current),[]),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("label",{className:"text-[10px] text-text-tertiary whitespace-nowrap",children:a}),e.jsx("input",{type:"text",value:x,onChange:l=>o(l.target.value),placeholder:i,className:"input text-[11px] py-1 px-2 w-48 font-mono"})]})}export{u as F,d as a,m as b};
2
- //# sourceMappingURL=FilterBar-Ck4K4rzu.js.map
@@ -1,2 +0,0 @@
1
- import{a as d,j as e}from"./vendor-query-B2UbickB.js";import{i as Z,q as H,c as N,u as ee,N as se,J as te}from"./index-BMIU7Im5.js";import{b as ae}from"./workflows-DNZf6Pmq.js";import{u as ie}from"./mcp-runs-aBDudwEi.js";import{a as ne}from"./controlplane-v-5KV6pl.js";import{u as re}from"./tasks-DwEUQ6my.js";import{e as oe,b as ce,u as le}from"./useEventHooks-BccPxFR6.js";import{R as B}from"./RolePill-Bp10-WfX.js";import{W as j}from"./WorkflowPill-BbgVTGgI.js";import{L as g}from"./ListToolbar-DuON-br0.js";import{E as de}from"./EventTopicPill-BUxxvpNg.js";import{s as D,a0 as p,L as M,W as Q,C as J,I as O,R as U,B as xe,h as pe}from"./vendor-icons-E6836lXZ.js";import{c as G,f as me}from"./vendor-react-CX88sFS5.js";const ue={completed:"bg-status-success",active:"bg-status-active",running:"bg-status-active",pending:"bg-status-pending",error:"bg-status-error",failed:"bg-status-error"};function V(t){return ue[t]??"bg-text-tertiary"}let he=0;function fe(t=5){const[a,i]=d.useState([]),[n,r]=d.useState(!1),l=d.useRef(null),o=d.useCallback(c=>{var x,f,b;if((x=c.type)!=null&&x.startsWith("mesh."))return;const h=c.activityName||c.workflowName||((f=c.data)==null?void 0:f.domain)||((b=c.workflowId)==null?void 0:b.slice(0,16))||"";i(w=>[{id:++he,type:c.type,timestamp:c.timestamp,label:h,data:c},...w].slice(0,t)),r(!0),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>r(!1),2e3)},[t]);return ee(`${se}.>`,o),{events:a,pulse:n}}function m({icon:t,color:a,docsHash:i,children:n,actions:r}){return e.jsxs("div",{className:"flex items-center justify-between mb-4 pb-2 border-b border-surface-border",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t,{className:`w-4.5 h-4.5 ${a||"text-accent/60"}`,strokeWidth:1.5}),e.jsx("h2",{className:"text-sm font-semibold uppercase tracking-widest text-accent/80",children:n})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[i&&e.jsx("button",{onClick:()=>{window.location.hash=i},className:"text-text-quaternary hover:text-accent transition-colors",title:"Docs",children:e.jsx(xe,{className:"w-2.5 h-2.5",strokeWidth:1.5})}),r]})]})}function u({icon:t,text:a}){return e.jsxs("div",{className:"flex flex-col items-center justify-center py-10 text-center",children:[e.jsx(t,{className:"w-6 h-6 text-text-quaternary/50 mb-2",strokeWidth:1}),e.jsx("p",{className:"text-xs text-text-quaternary",children:a})]})}function je(t,a=37){if(!t||t.length<=a)return t;const i=Math.floor((a-3)/2);return`${t.slice(0,i)}...${t.slice(-i)}`}function C({dot:t,pill:a,id:i,date:n,onClick:r}){return e.jsxs("button",{onClick:r,className:"w-full text-left hover:bg-surface-hover/50 rounded-md px-1 py-1.5 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${t}`}),e.jsx("span",{className:"text-[12px] text-text-primary font-mono truncate max-w-[60%]",children:je(i)}),e.jsx("span",{className:"text-[10px] text-text-quaternary shrink-0 ml-auto whitespace-nowrap",children:e.jsx(N,{date:n})})]}),e.jsx("div",{className:"pl-3.5 flex items-center gap-1 overflow-hidden",children:a})]})}function v({to:t,icon:a,title:i}){const n=G();return e.jsx("button",{onClick:()=>n(t),className:"text-text-quaternary hover:text-accent transition-colors",title:i,children:e.jsx(a,{className:"w-2.5 h-2.5",strokeWidth:1.5})})}function X({appIds:t,selected:a,onSelect:i}){const[n,r]=d.useState(!1),l=d.useRef(null);return d.useEffect(()=>{if(!n)return;const o=c=>{l.current&&!l.current.contains(c.target)&&r(!1)};return document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[n]),t.length<=1?null:e.jsxs("div",{className:"relative mb-3 -mt-2",ref:l,children:[e.jsxs("button",{onClick:()=>r(o=>!o),className:"flex items-center gap-1 px-2 py-0.5 text-[10px] rounded bg-accent/10 text-accent hover:bg-accent/20 transition-colors",children:[a,e.jsx("svg",{className:`w-2.5 h-2.5 transition-transform ${n?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2.5,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),n&&e.jsx("div",{className:"absolute top-full left-0 mt-1 bg-surface-raised border border-surface-border rounded-md shadow-lg z-30 py-1 min-w-[120px]",children:t.map(o=>e.jsx("button",{onClick:()=>{i(o),r(!1)},className:`w-full text-left px-3 py-1.5 text-[11px] transition-colors ${a===o?"text-accent bg-accent/5":"text-text-secondary hover:bg-surface-hover"}`,children:o},o))})]})}function ge({event:t}){const[a,i]=d.useState(!1);return e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>i(!a),className:"w-full text-left px-1 py-2 hover:bg-surface-hover/50 rounded-md transition-colors flex items-center gap-2",children:[e.jsx(pe,{className:`w-2.5 h-2.5 text-text-quaternary shrink-0 transition-transform ${a?"rotate-0":"-rotate-90"}`}),e.jsx(de,{topic:t.type}),e.jsx("span",{className:"text-[11px] text-text-secondary font-mono truncate flex-1",children:t.label||"—"}),e.jsx("span",{className:"text-[10px] text-text-quaternary shrink-0",children:e.jsx(N,{date:t.timestamp,format:"time"})})]}),a&&e.jsx("div",{className:"pl-5 pb-2",children:e.jsx(te,{data:t.data,defaultCollapsed:!1})})]})}function qe(){var F,L,W,I,T;const t=G(),{user:a}=Z(),[i,n]=me(),r=i.get("pipelinenamespace")||"longtail",l=i.get("durablenamespace")||"durable",o=d.useCallback((s,y)=>{n(Y=>{const z=new URLSearchParams(Y);return z.set(s,y),z},{replace:!1})},[n]);oe(),ce(),le();const c=re({limit:5}),h=ae({limit:5,sort_by:"updated_at",order:"desc",namespace:l}),{data:x}=ne(),f=((x==null?void 0:x.apps)??[]).map(s=>s.appId),b=f,w=f,k=ie({limit:5,app_id:r,sort_by:"updated_at",order:"desc"}),_=H({status:"pending",limit:5,sort_by:"updated_at",order:"desc"}),E=H({assigned_to:a==null?void 0:a.userId,status:"pending",limit:5,sort_by:"updated_at",order:"desc"}),{events:P,pulse:K}=fe(),S=((F=c.data)==null?void 0:F.processes)??[],R=((L=h.data)==null?void 0:L.jobs)??[],$=((W=k.data)==null?void 0:W.jobs)??[],q=((I=_.data)==null?void 0:I.escalations)??[],A=((T=E.data)==null?void 0:T.escalations)??[];return e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-light text-text-primary mb-10",children:"Recent Activity"}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-x-14 gap-y-14",children:[e.jsxs("div",{children:[e.jsx(m,{icon:D,color:"text-emerald-400",docsHash:"#docs:dashboard.md:processes-overview",actions:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(g,{onRefresh:()=>c.refetch(),isFetching:c.isFetching,apiPath:"/tasks/processes?limit=5"}),e.jsx(v,{to:"/processes/all",icon:p,title:"All processes"})]}),children:"Certified Processes"}),e.jsx("div",{className:"mb-3 -mt-2",children:e.jsx("span",{className:"px-2 py-0.5 text-[10px] rounded text-text-quaternary uppercase tracking-widest",children:"all namespaces"})}),S.length===0?e.jsx(u,{icon:D,text:"No recent processes"}):e.jsx("div",{className:"space-y-1",children:S.map(s=>e.jsx(C,{dot:(s.task_count??0)>0&&(s.completed??0)>=(s.task_count??0)?"bg-status-success":(s.escalated??0)>0?"border border-status-error":"bg-status-active",pill:e.jsx(e.Fragment,{children:(s.workflow_types??[s.workflow_type]).filter(Boolean).map(y=>e.jsx(j,{type:y,size:"xs"},y))}),id:s.origin_id,date:s.last_activity??s.started_at,onClick:()=>t(`/processes/detail/${s.origin_id}`)},s.origin_id))})]}),e.jsxs("div",{children:[e.jsx(m,{icon:M,color:"text-blue-400",docsHash:"#docs:dashboard.md:durable-executions",actions:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(g,{onRefresh:()=>h.refetch(),isFetching:h.isFetching,apiPath:`/workflow-states/jobs?namespace=${l}&limit=5`}),e.jsx(v,{to:"/workflows/executions",icon:p,title:"All durable executions"})]}),children:"Durable Executions"}),e.jsx(X,{appIds:b,selected:l,onSelect:s=>o("durablenamespace",s)}),R.length===0?e.jsx(u,{icon:M,text:"No recent executions"}):e.jsx("div",{className:"space-y-1",children:R.map(s=>e.jsx(C,{dot:V(s.status),pill:e.jsx(j,{type:s.entity||s.type||"workflow",size:"xs"}),id:s.workflow_id,date:s.updated_at??s.created_at,onClick:()=>t(`/workflows/executions/${s.workflow_id}`)},s.workflow_id))})]}),e.jsxs("div",{children:[e.jsx(m,{icon:Q,color:"text-violet-400",docsHash:"#docs:dashboard.md:mcp-pipeline-tools",actions:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(g,{onRefresh:()=>k.refetch(),isFetching:k.isFetching,apiPath:`/mcp-runs?app_id=${r}&limit=5`}),e.jsx(v,{to:"/mcp/executions",icon:p,title:"All pipeline executions"})]}),children:"Pipeline Executions"}),e.jsx(X,{appIds:w,selected:r,onSelect:s=>o("pipelinenamespace",s)}),$.length===0?e.jsx(u,{icon:Q,text:"No recent pipeline runs"}):e.jsx("div",{className:"space-y-1",children:$.map(s=>e.jsx(C,{dot:V(s.status),pill:e.jsx(j,{type:s.entity||s.workflow_name||"pipeline",variant:"pipeline",size:"xs"}),id:s.workflow_id,date:s.updated_at??s.created_at,onClick:()=>t(`/mcp/executions/${s.workflow_id}?namespace=${r}`)},s.workflow_id))})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-x-14 mt-14",children:[e.jsxs("div",{children:[e.jsx(m,{icon:J,color:"text-amber-400",docsHash:"#docs:dashboard.md:all-escalations",actions:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(g,{onRefresh:()=>_.refetch(),isFetching:_.isFetching,apiPath:"/escalations?status=pending&limit=5&sort_by=priority&order=asc"}),e.jsx(v,{to:"/escalations/available",icon:p,title:"All available escalations"})]}),children:"All Escalations"}),q.length===0?e.jsx(u,{icon:J,text:"No pending escalations"}):e.jsx("div",{className:"space-y-1",children:q.map(s=>e.jsxs("button",{onClick:()=>t(`/escalations/detail/${s.id}`),className:"w-full text-left hover:bg-surface-hover/50 rounded-md px-1 py-1.5 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[e.jsxs("span",{className:"text-[9px] text-text-quaternary font-medium shrink-0",children:["P",s.priority??2]}),e.jsx("span",{className:"text-[12px] text-text-primary truncate flex-1 max-w-[65%]",children:s.description||s.subtype||s.type}),e.jsx("span",{className:"text-[10px] text-text-quaternary shrink-0 ml-auto",children:e.jsx(N,{date:s.updated_at??s.created_at})})]}),e.jsxs("div",{className:"flex items-center gap-2 pl-5",children:[e.jsx(j,{type:s.type||"unknown",size:"xs"}),e.jsx("span",{className:"flex-1"}),e.jsx(B,{role:s.role})]})]},s.id))})]}),e.jsxs("div",{children:[e.jsx(m,{icon:O,color:"text-orange-400",docsHash:"#docs:dashboard.md:escalations-overview",actions:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(g,{onRefresh:()=>E.refetch(),isFetching:E.isFetching,apiPath:`/escalations?assigned_to=${(a==null?void 0:a.userId)??""}&status=pending&limit=5`}),e.jsx(v,{to:"/escalations/queue",icon:p,title:"My escalation queue"})]}),children:"My Escalations"}),A.length===0?e.jsx(u,{icon:O,text:"No assigned escalations"}):e.jsx("div",{className:"space-y-1",children:A.map(s=>e.jsxs("button",{onClick:()=>t(`/escalations/detail/${s.id}`),className:"w-full text-left hover:bg-surface-hover/50 rounded-md px-1 py-1.5 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[e.jsxs("span",{className:"text-[9px] text-text-quaternary font-medium shrink-0",children:["P",s.priority??2]}),e.jsx("span",{className:"text-[12px] text-text-primary truncate flex-1 max-w-[65%]",children:s.description||s.subtype||s.type}),e.jsx("span",{className:"text-[10px] text-text-quaternary shrink-0 ml-auto",children:e.jsx(N,{date:s.updated_at??s.created_at})})]}),e.jsxs("div",{className:"flex items-center gap-2 pl-5",children:[e.jsx(j,{type:s.type||"unknown",size:"xs"}),e.jsx("span",{className:"flex-1"}),e.jsx(B,{role:s.role})]})]},s.id))})]}),e.jsxs("div",{children:[e.jsx(m,{icon:U,color:"text-emerald-400",actions:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full transition-colors duration-500 ${K?"bg-emerald-400":"bg-zinc-600"}`}),e.jsx("button",{onClick:()=>{const s=document.querySelector('[title="Fullscreen"]');s==null||s.click()},className:"text-text-quaternary hover:text-accent transition-colors",title:"View all events",children:e.jsx(p,{className:"w-2.5 h-2.5",strokeWidth:1.5})})]}),children:"Event Stream"}),P.length===0?e.jsx(u,{icon:U,text:"Events appear here in real time"}):e.jsx("div",{className:"divide-y divide-surface-border/20",children:P.map(s=>e.jsx(ge,{event:s},s.id))})]})]})]})}export{qe as HomePage};
2
- //# sourceMappingURL=HomePage-Tlu1j8fK.js.map
@@ -1,2 +0,0 @@
1
- import{a as C,j as s}from"./vendor-query-B2UbickB.js";import{B as j}from"./index-BMIU7Im5.js";import{H as u,ay as $,az as N,am as f}from"./vendor-icons-E6836lXZ.js";function y({onRefresh:m,isFetching:r=!1,apiPath:e}){const[c,l]=C.useState(null),i=(t,n)=>{navigator.clipboard.writeText(t).then(()=>{l(n),setTimeout(()=>l(null),2e3)})},d=()=>{if(!e)return;const t=`${window.location.origin}/api${e}`;i(t,"url")},x=()=>{if(!e)return;const t=`${window.location.origin}/api${e}`,n=j(),p=n?`curl -H "Authorization: Bearer ${n}" "${t}"`:`curl "${t}"`;i(p,"curl")},a="p-1 text-text-quaternary hover:text-accent transition-colors rounded",o="w-2.5 h-2.5";return s.jsxs("div",{className:"flex items-center gap-0.5",children:[e&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:d,className:a,title:"Copy API URL",children:c==="url"?s.jsx(u,{className:`${o} text-status-success`}):s.jsx($,{className:o})}),s.jsx("button",{onClick:x,className:a,title:"Copy curl (includes auth token)",children:c==="curl"?s.jsx(u,{className:`${o} text-status-success`}):s.jsx(N,{className:o})})]}),s.jsx("button",{onClick:m,disabled:r,className:`${a} disabled:opacity-50`,title:"Refresh",children:s.jsx(f,{className:`${o} ${r?"animate-spin":""}`})})]})}export{y as L};
2
- //# sourceMappingURL=ListToolbar-DuON-br0.js.map
@@ -1,2 +0,0 @@
1
- import{a as i,j as e}from"./vendor-query-B2UbickB.js";import{u as _}from"./mcp-CWFliwjc.js";import{u as R}from"./mcp-runs-aBDudwEi.js";import{u as F}from"./yaml-workflows-BKZdGciI.js";import{u as A}from"./namespaces-C45c4uoO.js";import{P as z}from"./PageHeader-DLjHNYHX.js";import{S as b}from"./StatCard-DlgF0CJC.js";import{b as E,c as I}from"./vendor-icons-E6836lXZ.js";import{c as W}from"./vendor-react-CX88sFS5.js";import"./index-BMIU7Im5.js";const $=[{label:"1h",ms:36e5},{label:"24h",ms:864e5},{label:"7d",ms:6048e5},{label:"30d",ms:2592e6}];function O(r){return r<1e3?`${Math.round(r)}ms`:r<6e4?`${(r/1e3).toFixed(1)}s`:r<36e5?`${(r/6e4).toFixed(1)}m`:`${(r/36e5).toFixed(1)}h`}function j({value:r,colorClass:c,onClick:v}){return r===0?e.jsx("span",{className:"text-text-tertiary",children:"0"}):e.jsx("button",{onClick:v,className:`${c} hover:underline tabular-nums font-medium`,children:r})}function X(){const r=W(),[c,v]=i.useState("24h"),[u,T]=i.useState("longtail"),{data:d}=A(),{data:m}=R({limit:500,app_id:u}),{data:N,isLoading:D}=_(),{data:y,isLoading:L}=F({limit:200}),k=i.useMemo(()=>((d==null?void 0:d.namespaces)??[]).map(t=>t.name),[d==null?void 0:d.namespaces]),p=(N==null?void 0:N.servers)??[],h=(y==null?void 0:y.workflows)??[],w=i.useMemo(()=>p.reduce((t,l)=>t+(Array.isArray(l.tool_manifest)?l.tool_manifest.length:0),0),[p]),M=i.useMemo(()=>new Set(h.map(l=>l.app_id)).size,[h]),S=i.useMemo(()=>{const t=$.find(l=>l.label===c);return Date.now()-t.ms},[c]),o=i.useMemo(()=>((m==null?void 0:m.jobs)??[]).filter(t=>new Date(t.created_at).getTime()>=S),[m==null?void 0:m.jobs,S]),C=i.useMemo(()=>{const t=new Map;for(const s of o){const a=t.get(s.entity)??{total:0,running:0,completed:0,failed:0,durations:[]};if(a.total++,s.status==="running"&&a.running++,s.status==="completed"){a.completed++;const g=new Date(s.updated_at).getTime()-new Date(s.created_at).getTime();g>0&&a.durations.push(g)}s.status==="failed"&&a.failed++,t.set(s.entity,a)}const l=[];for(const[s,a]of t)l.push({pipeline:s,...a,avgDuration:a.durations.length>0?a.durations.reduce((g,P)=>g+P,0)/a.durations.length:null});return l.sort((s,a)=>a.total-s.total)},[o]),f=i.useMemo(()=>({total:o.length,running:o.filter(t=>t.status==="running").length,completed:o.filter(t=>t.status==="completed").length,failed:o.filter(t=>t.status==="failed").length}),[o]),n=(t,l)=>{const s=new URLSearchParams;u!=="longtail"&&s.set("namespace",u),t&&s.set("entity",t),l&&s.set("status",l);const a=s.toString();r(`/mcp/executions${a?`?${a}`:""}`)},x="pb-2 text-[10px] font-semibold uppercase tracking-widest text-text-tertiary";return e.jsxs("div",{children:[e.jsx(z,{title:"Discovered"}),e.jsxs("div",{className:"flex items-center gap-4 mb-6",children:[e.jsx("div",{className:"flex items-center gap-1",children:$.map(t=>e.jsx("button",{onClick:()=>v(t.label),className:`px-3 py-1 text-xs rounded-full transition-colors ${c===t.label?"bg-accent text-text-inverse":"text-text-tertiary hover:text-text-primary hover:bg-surface-hover"}`,children:t.label},t.label))}),k.length>1&&e.jsx("select",{value:u,onChange:t=>T(t.target.value),className:"select text-xs py-1 px-2",children:k.map(t=>e.jsx("option",{value:t,children:t},t))})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-8",children:[e.jsx(b,{label:"Total Runs",value:f.total,onClick:()=>n()}),e.jsx(b,{label:"Running",value:f.running,colorClass:"text-status-active",onClick:()=>n(void 0,"running")}),e.jsx(b,{label:"Completed",value:f.completed,colorClass:"text-status-success",onClick:()=>n(void 0,"completed")}),e.jsx(b,{label:"Failed",value:f.failed,colorClass:"text-status-error",onClick:()=>n(void 0,"failed")})]}),C.length>0&&e.jsxs("table",{className:"w-full text-left mb-10",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-surface-border",children:[e.jsx("th",{className:x,children:"Tool"}),e.jsx("th",{className:`${x} text-right w-20`,children:"Total"}),e.jsx("th",{className:`${x} text-right w-20`,children:"Running"}),e.jsx("th",{className:`${x} text-right w-24`,children:"Completed"}),e.jsx("th",{className:`${x} text-right w-20`,children:"Failed"}),e.jsx("th",{className:`${x} text-right w-28`,children:"Avg Duration"})]})}),e.jsx("tbody",{children:C.map(t=>e.jsxs("tr",{className:"border-b border-surface-border last:border-b-0",children:[e.jsx("td",{className:"py-3 text-sm font-mono text-text-primary",children:e.jsx("button",{onClick:()=>n(t.pipeline),className:"hover:text-accent hover:underline",children:t.pipeline})}),e.jsx("td",{className:"py-3 text-sm text-right",children:e.jsx(j,{value:t.total,colorClass:"text-text-secondary",onClick:()=>n(t.pipeline)})}),e.jsx("td",{className:"py-3 text-sm text-right",children:e.jsx(j,{value:t.running,colorClass:"text-status-active",onClick:()=>n(t.pipeline,"running")})}),e.jsx("td",{className:"py-3 text-sm text-right",children:e.jsx(j,{value:t.completed,colorClass:"text-status-success",onClick:()=>n(t.pipeline,"completed")})}),e.jsx("td",{className:"py-3 text-sm text-right",children:e.jsx(j,{value:t.failed,colorClass:"text-status-error",onClick:()=>n(t.pipeline,"failed")})}),e.jsx("td",{className:"py-3 text-sm font-mono text-text-secondary text-right",children:t.avgDuration!==null?O(t.avgDuration):"—"})]},t.pipeline))})]}),C.length===0&&e.jsx("div",{className:"py-12 text-center mb-8",children:e.jsxs("p",{className:"text-sm text-text-tertiary",children:["No MCP tool activity in the last ",c]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("button",{onClick:()=>r("/mcp/servers"),className:"bg-surface-raised border border-surface-border rounded-md p-5 text-left hover:border-accent/40 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx(E,{size:16,className:"text-accent shrink-0"}),e.jsx("span",{className:"text-sm font-medium text-text-primary",children:"Tool Servers"})]}),e.jsxs("p",{className:"text-2xl font-light tabular-nums text-text-primary mb-1",children:[D?"—":p.length,e.jsxs("span",{className:"text-sm text-text-tertiary font-normal ml-2",children:["server",p.length!==1?"s":""," · ",w," tool",w!==1?"s":""]})]}),e.jsx("p",{className:"text-[11px] text-text-tertiary leading-relaxed mt-2",children:"Built-in and external MCP servers. Each server exposes tools that workflows and agents can call."})]}),e.jsxs("button",{onClick:()=>r("/mcp/workflows"),className:"bg-surface-raised border border-surface-border rounded-md p-5 text-left hover:border-accent/40 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx(I,{size:16,className:"text-purple-400 shrink-0"}),e.jsx("span",{className:"text-sm font-medium text-text-primary",children:"Pipeline Registry"})]}),e.jsxs("p",{className:"text-2xl font-light tabular-nums text-text-primary mb-1",children:[L?"—":h.length,e.jsxs("span",{className:"text-sm text-text-tertiary font-normal ml-2",children:["workflow",h.length!==1?"s":""," · ",M," server",M!==1?"s":""]})]}),e.jsx("p",{className:"text-[11px] text-text-tertiary leading-relaxed mt-2",children:"Compiled from discovery runs. Deterministic tool-to-tool pipelines — no LLM, no token costs."})]})]})]})}export{X as McpOverview};
2
- //# sourceMappingURL=McpOverview-byott48x.js.map
@@ -1,5 +0,0 @@
1
- import{j as e,b as pe,c as Qe,u as Pt,a as p}from"./vendor-query-B2UbickB.js";import{P as Ie}from"./PageHeader-DLjHNYHX.js";import{S as ye}from"./StatusBadge-XQlNFwmH.js";import{a as Mt,b as gt,c as $e,d as yt,e as Tt,f as At}from"./mcp-query-Dm7_m5Fi.js";import{b as We,F as Lt,J as U,S as bt,d as It,e as $t,g as Wt}from"./index-BMIU7Im5.js";import{u as Ot,a as Rt,b as Bt,c as Ft}from"./useYamlActivityEvents-BBioXSKA.js";import{W as jt,r as Ve,t as ve,s as Ne,u as vt,v as Et,b as Dt,w as zt,x as qt,y as Yt,z as be,D as Oe,B as dt,H as Ae,J as xt,M as Jt,g as Qt,m as Vt,X as Re,K as Kt,P as Ut,N as Ht,O as Gt,Q as Xt,V as Zt,Y as es,C as Nt}from"./vendor-icons-E6836lXZ.js";import{c as Ke,f as fe,e as Be,L as ke}from"./vendor-react-CX88sFS5.js";import{b as Fe,c as Ce,u as Ue,d as ts,e as ss,f as as,g as rs,h as ns,i as is,j as cs,k as ls,l as os,m as ds,a as xs}from"./yaml-workflows-BKZdGciI.js";import{c as He,d as ms}from"./useEventHooks-BccPxFR6.js";import{T as Ee}from"./TagInput-Dkljw_WI.js";import{C as ps}from"./CollapsibleSection-DaFQGU6S.js";import{u as us,b as hs}from"./mcp-runs-aBDudwEi.js";import{a as Ye}from"./workflows-DNZf6Pmq.js";import{b as Ge}from"./tasks-DwEUQ6my.js";import{T as fs,b as gs,e as Se,m as ys,S as bs}from"./ToolPill-D_DIWFJ5.js";import{R as js}from"./RunAsSelector-hYP59xHH.js";import{C as vs}from"./CopyableId-DmLF-RqZ.js";import{T as Ns}from"./TimeAgo-RPbch7Te.js";import{S as ws}from"./SwimlaneTimeline-2JHwAM2f.js";import"./BotPicker-CwfVVWxh.js";import"./bots-zyUDnQhH.js";function Xe({labels:t,current:a,maxReachable:r,onStepClick:n}){return e.jsx("div",{className:"sticky top-0 z-20 bg-surface/95 backdrop-blur-sm pb-6 pt-1 -mt-1",children:e.jsx("div",{className:"flex items-center gap-3",children:t.map((d,o)=>{const s=o+1,m=s<=r;return e.jsxs("div",{className:"flex items-center gap-2",children:[s>1&&e.jsx("div",{className:`w-8 h-px ${a>=s?"bg-accent":"bg-surface-border"}`}),e.jsx("button",{onClick:()=>m&&n(s),disabled:!m,className:`w-6 h-6 rounded-full text-[11px] font-semibold flex items-center justify-center transition-colors ${a===s?"bg-accent text-text-inverse":m?"bg-accent/20 text-accent cursor-pointer hover:bg-accent/30":"bg-surface-sunken text-text-tertiary cursor-default"}`,children:s}),e.jsx("span",{className:`text-xs ${a===s?"text-text-primary font-medium":"text-text-tertiary"}`,children:d})]},s)})})})}const wt=["builderJobs"];function kt(){const t=pe();return Qe({mutationFn:a=>We("/insight/build-workflow",{method:"POST",body:JSON.stringify({...a,wait:!1})}),onSuccess:()=>{t.invalidateQueries({queryKey:wt,refetchType:"all"}),t.invalidateQueries({queryKey:["jobs"],refetchType:"all"})}})}function ks(){const t=pe();return Qe({mutationFn:a=>We("/insight/build-workflow/refine",{method:"POST",body:JSON.stringify({...a,wait:!1})}),onSuccess:()=>{t.invalidateQueries({queryKey:wt,refetchType:"all"})}})}function Ss(){const t=pe();return Qe({mutationFn:a=>We("/yaml-workflows/direct",{method:"POST",body:JSON.stringify(a)}),onSuccess:()=>{t.invalidateQueries({queryKey:["yamlWorkflows"],refetchType:"all"})}})}function St(t){return Pt({queryKey:["builderResult",t],queryFn:()=>We(`/workflows/${t}/result`),enabled:!!t})}const Cs=[{icon:ve,color:"text-accent",title:"Describe",detail:"Write a prompt. The LLM executes tools dynamically to fulfill your request."},{icon:vt,color:"text-status-warning",title:"Discover",detail:"Review the execution trace — which tools were called, what data flowed between them."},{icon:Ne,color:"text-status-success",title:"Compile",detail:"Successful runs compile into deterministic pipelines. No LLM needed at runtime."}],_s=[{icon:ve,color:"text-accent",title:"Describe",detail:"Specify what tools to use, what inputs to accept, and how data should flow between steps."},{icon:Ne,color:"text-status-warning",title:"Review",detail:"The LLM will create the pipeline (DAG) directly from tool schemas. Review the generated pipeline."},{icon:jt,color:"text-status-success",title:"Deploy & Test",detail:"Deploy, run with sample inputs, and refine until the pipeline works correctly."}],Ps=[{icon:ve,color:"text-accent",title:"Specification",detail:"Describe API endpoints, processes, or paste a spec. The system decomposes it into pipeline tools."},{icon:Ve,color:"text-status-warning",title:"Plan & Build",detail:"Review the decomposition, configure the toolset, then build each tool leaf-first."},{icon:Ne,color:"text-status-success",title:"Deploy & Test",detail:"Deploy the toolset. Test individual tools and the full composition."}];function Ms(){const t=Ke(),[a,r]=p.useState(""),[n,d]=p.useState("discover"),[o,s]=p.useState(!0),m=Mt(),l=gt(),x=kt(),c=Ot(),u=async i=>{i.preventDefault();const b=a.trim();if(b)if(n==="plan"){const y=`plan-${Date.now().toString(36)}`,h=await c.mutateAsync({name:y,specification:b});r(""),t(`/mcp/queries/${h.planner_workflow_id}?mode=plan&set_id=${h.id}`,{replace:!0})}else if(n==="direct"){const y=await x.mutateAsync({prompt:b});r(""),t(`/mcp/queries/${y.workflow_id}?mode=builder`,{replace:!0})}else{const h=await(o?m:l).mutateAsync({prompt:b});r(""),o?t(`/mcp/queries/${h.workflow_id}?step=2`,{replace:!0}):t(`/workflows/executions/${h.workflow_id}`,{replace:!0})}},f=n==="plan"?c:n==="direct"?x:o?m:l,S=n==="plan"?Ps:n==="discover"?Cs:_s;return e.jsxs("div",{children:[e.jsx(Ie,{title:"MCP Tool Designer",docsHash:"#docs:dashboard.md:mcp-tool-designer"}),e.jsx("p",{className:"text-sm text-text-secondary mb-6 leading-relaxed max-w-xl",children:"Create deterministic MCP tools from natural language. Choose how to get there."}),e.jsxs("div",{className:"flex gap-1 mb-6 p-0.5 bg-surface-sunken rounded-lg w-fit",children:[e.jsxs("button",{onClick:()=>d("discover"),className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-md transition-colors ${n==="discover"?"bg-surface text-text-primary shadow-sm":"text-text-tertiary hover:text-text-secondary"}`,children:[e.jsx(jt,{className:"w-3 h-3",strokeWidth:1.5}),"Discover & Compile"]}),e.jsxs("button",{onClick:()=>d("plan"),className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium rounded-md transition-colors ${n==="plan"?"bg-surface text-text-primary shadow-sm":"text-text-tertiary hover:text-text-secondary"}`,children:[e.jsx(Ve,{className:"w-3 h-3",strokeWidth:1.5}),"Build"]})]}),e.jsxs("div",{className:"grid grid-cols-[1fr_240px] gap-6",children:[e.jsxs("form",{onSubmit:u,children:[e.jsxs("div",{className:"rounded-lg border border-surface-border bg-surface-raised overflow-hidden h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-start gap-3 flex-1",children:[e.jsx(ve,{className:"w-4 h-4 text-accent shrink-0 mt-3.5 ml-4",strokeWidth:1.5}),e.jsx("textarea",{ref:i=>{i&&(i.style.height="auto",i.style.height=Math.min(400,Math.max(160,i.scrollHeight))+"px")},value:a,onChange:i=>{r(i.target.value);const b=i.target;b.style.height="auto",b.style.height=Math.min(400,Math.max(160,b.scrollHeight))+"px"},placeholder:n==="plan"?"Describe the tools you want to build — API specs, process descriptions, or a full PRD. The system will decompose, build, and deploy them as a composable toolset...":"Describe what you want to accomplish. The system will discover and execute the right tools...",className:"flex-1 min-h-[160px] pr-4 py-3 bg-transparent text-sm text-text-primary placeholder:text-text-tertiary resize-none focus:outline-none border-none",autoFocus:!0,onKeyDown:i=>{i.key==="Enter"&&(i.metaKey||i.ctrlKey)&&u(i)}})]}),e.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-t border-surface-border bg-surface-sunken/30",children:[n==="plan"?e.jsx("span",{className:"text-[10px] text-text-tertiary",children:"Decomposes into composable pipeline tools — builds leaf-first"}):n==="discover"?e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer select-none group",children:[e.jsx("input",{type:"checkbox",checked:o,onChange:i=>s(i.target.checked),className:"w-3.5 h-3.5 rounded border-border text-accent-primary focus:ring-accent-primary/50 bg-surface-sunken cursor-pointer"}),e.jsx("span",{className:"text-[10px] text-text-secondary group-hover:text-text-primary transition-colors",children:"Force discovery"}),e.jsx("span",{className:"text-[10px] text-text-tertiary",children:o?"— skip compiled pipelines":"— prefer compiled pipelines"})]}):e.jsx("span",{className:"text-[10px] text-text-tertiary",children:"LLM builds pipeline from tool schemas — no execution needed"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-[10px] text-text-tertiary",children:"Cmd+Enter"}),e.jsx("button",{type:"submit",disabled:!a.trim()||f.isPending,className:"px-4 py-1.5 bg-accent text-white text-xs font-medium rounded-md hover:bg-accent/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:f.isPending?"Starting...":n==="plan"?"Plan":n==="discover"?"Discover":"Build"})]})]})]}),f.isError&&e.jsx("p",{className:"mt-2 text-sm text-status-error",children:f.error.message})]}),e.jsx("div",{className:"space-y-4 pt-1",children:S.map(i=>e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx(i.icon,{className:`w-3.5 h-3.5 mt-0.5 shrink-0 ${i.color}`,strokeWidth:1.5}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] font-medium text-text-primary",children:i.title}),e.jsx("p",{className:"text-[10px] text-text-tertiary mt-0.5 leading-relaxed",children:i.detail})]})]},i.title))})]})]})}function le({children:t}){return e.jsx("div",{className:"sticky bg-surface/95 backdrop-blur-sm border-t border-surface-border -mx-10 px-10 pt-3 pb-5 z-20 flex justify-between items-center mt-8",style:{bottom:"calc(var(--feed-height, 0px) - 8px)"},children:t})}const Ts=[{icon:Dt,label:"Discovering MCP servers and tools",key:"discover"},{icon:zt,label:"LLM constructing YAML pipeline",key:"build"},{icon:qt,label:"Validating workflow structure",key:"validate"}];function As({workflowId:t,status:a,builderData:r,onBuilt:n,onNext:d}){var v,k,N,_,L,C;const[o,s]=p.useState(""),[m,l]=p.useState(0),x=kt(),{data:c}=$e(t),u=r==null?void 0:r.clarification_needed,f=(r==null?void 0:r.questions)||[],S=(r==null?void 0:r.tools_identified)||[],i=a==="in_progress",b=a==="completed"&&(r==null?void 0:r.yaml),y=a==="failed"||((v=r==null?void 0:r.title)==null?void 0:v.includes("Failed")),h=(k=c==null?void 0:c.events)==null?void 0:k.find(g=>g.event_type==="workflow_execution_started"),j=Array.isArray((N=h==null?void 0:h.attributes)==null?void 0:N.input)?h.attributes.input[0]:(_=h==null?void 0:h.attributes)==null?void 0:_.input,w=((L=j==null?void 0:j.data)==null?void 0:L.prompt)||((C=j==null?void 0:j.data)==null?void 0:C.question)||null;p.useEffect(()=>{if(!i)return;const I=((c==null?void 0:c.events)||[]).filter(M=>M.event_type==="activity_task_completed"&&!M.is_system).length;I>=2?l(2):I>=1?l(1):l(0)},[i,c==null?void 0:c.events]);const T=async()=>{o.trim()&&(await x.mutateAsync({prompt:(r==null?void 0:r._originalPrompt)||t,answers:o.trim(),prior_questions:f}),n())};return e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-extralight tracking-wide text-accent/75 mb-1",children:"Describe"}),e.jsx("p",{className:"text-base text-text-secondary mb-6",children:u?"The builder identified tools but needs more details before constructing the workflow.":i?"Building your workflow — this typically takes 20-40 seconds.":b?"Pipeline constructed — YAML definition, input schema, and activity manifest generated.":y?"Build failed. Try a more specific prompt or use Discover & Compile mode.":"Workflow build submitted."}),u&&e.jsxs("div",{className:"space-y-4",children:[S.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-text-tertiary mb-2",children:"Tools Identified"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:S.map(g=>e.jsx("span",{className:"px-2 py-0.5 text-xs font-mono bg-accent/10 text-accent rounded",children:g},g))})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-text-tertiary mb-2",children:"Questions"}),e.jsx("div",{className:"space-y-2",children:f.map((g,I)=>e.jsxs("div",{className:"flex items-start gap-2 text-sm text-text-secondary",children:[e.jsx(Et,{className:"w-3.5 h-3.5 text-status-warning shrink-0 mt-0.5",strokeWidth:1.5}),e.jsx("span",{children:g})]},I))})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-widest text-text-tertiary mb-2",children:"Your Answers"}),e.jsx("textarea",{value:o,onChange:g=>s(g.target.value),placeholder:"Answer each question above...",className:"w-full min-h-[120px] px-3 py-2 bg-surface text-sm text-text-primary placeholder:text-text-tertiary rounded-md border border-surface-border resize-none focus:outline-none focus:ring-1 focus:ring-accent",onKeyDown:g=>{g.key==="Enter"&&(g.metaKey||g.ctrlKey)&&T()}}),e.jsx("div",{className:"flex justify-end mt-2",children:e.jsx("button",{onClick:T,disabled:!o.trim()||x.isPending,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium bg-accent/10 text-accent rounded-md hover:bg-accent/20 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:x.isPending?"Submitting...":"Submit Answers & Build"})})]})]}),!u&&e.jsxs("div",{className:"grid grid-cols-[1fr_240px] gap-6",children:[e.jsx("div",{className:"rounded-lg bg-surface-sunken/40 overflow-hidden",children:e.jsxs("div",{className:"flex items-start gap-3 p-4",children:[e.jsx(ve,{className:"w-4 h-4 text-accent shrink-0 mt-0.5",strokeWidth:1.5}),w?e.jsx("p",{className:"text-sm font-mono text-text-secondary leading-relaxed whitespace-pre-wrap",children:w}):e.jsx("p",{className:"text-xs text-text-tertiary italic",children:"Loading prompt..."})]})}),e.jsxs("div",{className:"space-y-3 pt-1",children:[Ts.map((g,I)=>{const M=b||I<m,W=i&&I===m;return e.jsxs("div",{className:"flex items-start gap-2.5",children:[M?e.jsx(Yt,{className:"w-3.5 h-3.5 text-status-success shrink-0 mt-0.5",strokeWidth:1.5}):W?e.jsx(be,{className:"w-3.5 h-3.5 text-accent animate-spin shrink-0 mt-0.5",strokeWidth:1.5}):e.jsx(g.icon,{className:"w-3.5 h-3.5 text-text-tertiary/40 shrink-0 mt-0.5",strokeWidth:1.5}),e.jsxs("div",{children:[e.jsx("p",{className:`text-[11px] font-medium ${M||W?"text-text-primary":"text-text-tertiary/50"}`,children:g.label}),M&&!i&&e.jsx("p",{className:"text-[10px] text-status-success mt-0.5",children:"complete"})]})]},g.key)}),i&&e.jsxs("p",{className:"text-[10px] text-text-tertiary pl-6",children:["Elapsed: ",c!=null&&c.duration_ms?`${(c.duration_ms/1e3).toFixed(0)}s`:"..."]}),b&&r.build_attempts>1&&e.jsxs("p",{className:"text-[10px] text-text-tertiary pl-6",children:["Built in ",r.build_attempts," attempts"]}),y&&e.jsx("p",{className:"text-[10px] text-status-error pl-6",children:(r==null?void 0:r.summary)||"Build failed"})]})]}),e.jsxs(le,{children:[e.jsx("div",{}),b&&e.jsx("button",{onClick:d,className:"btn-primary text-xs",children:"Next: Profile"})]})]})}function oe(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_|_$/g,"")}function Le(t){return t.toLowerCase().replace(/[^a-z0-9]/g,"").replace(/^[0-9]+/,"")}function Ls({builderData:t,resolvedYamlId:a,originalPrompt:r,onBack:n,onCreate:d,onNext:o}){const[s,m]=p.useState(!1),[l,x]=p.useState(oe((t==null?void 0:t.name)||"")),[c,u]=p.useState((t==null?void 0:t.description)||""),[f,S]=p.useState("longtail"),[i,b]=p.useState((t==null?void 0:t.tags)||[]),y=Ss(),h=Fe(),{data:j}=Ce(a||""),w=!!a,T=async()=>{const N=await y.mutateAsync({name:l,description:c,yaml_content:t.yaml,input_schema:t.input_schema,activity_manifest:t.activity_manifest,tags:i,app_id:f});d(N.id)},v=async()=>{a&&(await h.mutateAsync({id:a,name:l,description:c,tags:i}),m(!1))},k=!w||s;return e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-extralight tracking-wide text-accent/75 mb-1",children:"Profile"}),e.jsx("p",{className:"text-base text-text-secondary mb-6",children:"Name the MCP server and tool, add tags for discovery, and describe what this pipeline does."}),r&&e.jsxs("div",{className:"mb-6",children:[e.jsx("label",{className:"block text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:"Original Prompt"}),e.jsx("div",{className:"rounded-md bg-surface-sunken/50 px-4 py-3",children:e.jsx("p",{className:"text-xs font-mono text-text-primary leading-relaxed whitespace-pre-wrap",children:r})})]}),e.jsxs("div",{className:"grid grid-cols-[300px_1fr] gap-4 mb-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:"MCP Server Name"}),k?e.jsx("input",{value:f,onChange:N=>S(Le(N.target.value)),className:"w-full bg-surface-sunken border border-surface-border rounded-md px-3 py-1.5 text-xs font-mono text-text-primary focus:outline-none focus:ring-1 focus:ring-inset focus:ring-accent-primary"}):e.jsx("p",{className:"text-sm text-text-primary py-1.5",children:(j==null?void 0:j.app_id)||f})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:"MCP Tool Name"}),k?e.jsx("input",{value:l,onChange:N=>x(oe(N.target.value)),className:"w-full bg-surface-sunken border border-surface-border rounded-md px-3 py-1.5 text-xs font-mono text-text-primary focus:outline-none focus:ring-1 focus:ring-inset focus:ring-accent-primary"}):e.jsx("p",{className:"text-sm text-text-primary py-1.5",children:(j==null?void 0:j.name)||l})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:"Tags"}),k?e.jsx(Ee,{tags:i,onChange:b,compact:!0}):e.jsx("div",{className:"flex flex-wrap gap-1.5 py-1",children:((j==null?void 0:j.tags)||i).map(N=>e.jsx("span",{className:"px-2 py-0.5 text-sm bg-surface-raised text-text-primary rounded",children:N},N))})]})]}),e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("label",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary",children:"Description"}),w&&!s&&e.jsxs("button",{onClick:()=>m(!0),className:"flex items-center gap-1 text-[10px] text-accent hover:text-accent/80 transition-colors",children:[e.jsx(Oe,{className:"w-3 h-3",strokeWidth:1.5}),"Edit"]})]}),k?e.jsx("textarea",{value:c,onChange:N=>u(N.target.value),className:"w-full flex-1 min-h-[100px] bg-surface-sunken border border-surface-border rounded-md px-3 py-1.5 text-xs font-mono text-text-primary resize-none focus:outline-none focus:ring-1 focus:ring-inset focus:ring-accent-primary"}):e.jsx("p",{className:"text-sm text-text-primary leading-relaxed py-1.5",children:(j==null?void 0:j.description)||c}),s&&e.jsxs("div",{className:"flex justify-end gap-2 mt-2",children:[e.jsx("button",{onClick:()=>m(!1),className:"text-[10px] text-text-tertiary hover:text-text-primary",children:"Cancel"}),e.jsx("button",{onClick:v,disabled:h.isPending,className:"text-[10px] text-accent hover:text-accent/80 font-medium",children:h.isPending?"Saving...":"Save Changes"})]})]})]}),y.isError&&e.jsx("p",{className:"text-xs text-status-error mb-4",children:y.error.message}),e.jsxs(le,{children:[e.jsx("button",{onClick:n,className:"px-3 py-1.5 text-xs text-text-secondary hover:text-text-primary",children:"Back"}),w?e.jsx("button",{onClick:o,className:"btn-primary text-xs",children:"Next: Deploy"}):e.jsx("button",{onClick:T,disabled:y.isPending||!l.trim(),className:"btn-primary text-xs disabled:opacity-50 disabled:cursor-not-allowed",children:y.isPending?"Creating...":"Create & Save"})]})]})}function me({icon:t,label:a,onClick:r,disabled:n}){return e.jsxs("button",{type:"button",onClick:r,disabled:n,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium bg-accent/10 text-accent rounded-md hover:bg-accent/20 transition-colors shrink-0 disabled:opacity-50 disabled:cursor-not-allowed",children:[t&&e.jsx(t,{className:"w-3.5 h-3.5",strokeWidth:1.5}),a]})}const mt={dynamic:{bg:"bg-status-success/10",text:"text-status-success",label:"Dynamic"},fixed:{bg:"bg-surface-sunken",text:"text-text-tertiary",label:"Fixed"},wired:{bg:"bg-blue-500/10",text:"text-blue-500",label:"Wired"}};function Is({classification:t}){const a=mt[t]||mt.fixed;return e.jsx("span",{className:`px-1.5 py-0.5 text-[9px] font-medium rounded ${a.bg} ${a.text}`,children:a.label})}function $s({fields:t,onChange:a,editing:r}){const[n,d]=p.useState(null),o=(c,u)=>{const f=t.map((S,i)=>i===c?{...S,...u}:S);a(f)},s=c=>{const u=t[c],f=u.classification==="dynamic"?"fixed":"dynamic",S={classification:f};f==="fixed"&&u.default===void 0&&(S.default=u.type==="string"?"":u.type==="number"?0:u.type==="boolean"?!1:null),o(c,S)},m=c=>{a(t.filter((u,f)=>f!==c))};if(t.length===0)return e.jsx("div",{className:"py-4 text-center",children:e.jsx("p",{className:"text-xs text-text-tertiary",children:"No input fields detected from the execution."})});const l=t.filter(c=>c.classification==="dynamic"),x=t.filter(c=>c.classification==="fixed");return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-text-tertiary",children:[e.jsxs("span",{children:[l.length," dynamic (user provides)"]}),e.jsxs("span",{children:[x.length," fixed (defaults from execution)"]})]}),l.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] font-semibold uppercase tracking-widest text-status-success/70 mb-2",children:"Dynamic Inputs (required at invocation)"}),e.jsx("div",{className:"space-y-1",children:l.map(c=>{const u=t.indexOf(c),f=n===c.key;return e.jsx(pt,{field:c,editing:r,expanded:f,onToggleExpand:()=>d(f?null:c.key),onToggleClassification:()=>s(u),onUpdate:S=>o(u,S),onRemove:()=>m(u)},c.key)})})]}),x.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[9px] font-semibold uppercase tracking-widest text-text-tertiary mb-2",children:"Fixed Defaults (from execution)"}),e.jsx("div",{className:"space-y-1",children:x.map(c=>{const u=t.indexOf(c),f=n===c.key;return e.jsx(pt,{field:c,editing:r,expanded:f,onToggleExpand:()=>d(f?null:c.key),onToggleClassification:()=>s(u),onUpdate:S=>o(u,S),onRemove:()=>m(u)},c.key)})})]})]})}function pt({field:t,editing:a,expanded:r,onToggleExpand:n,onToggleClassification:d,onUpdate:o,onRemove:s}){return e.jsxs("div",{className:"border border-surface-border rounded-lg overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:n,className:"w-full flex items-center gap-2 px-3 py-2 hover:bg-surface-hover/50 transition-colors",children:[e.jsx("span",{className:"font-mono text-xs text-text-primary",children:t.key}),e.jsx("span",{className:"text-[9px] text-text-tertiary",children:t.type}),e.jsx(Is,{classification:t.classification}),t.default!==void 0&&e.jsxs("span",{className:"text-[9px] font-mono text-text-tertiary truncate max-w-[120px]",children:["= ",JSON.stringify(t.default)]}),e.jsx("span",{className:"text-[9px] text-text-tertiary ml-auto truncate max-w-[150px]",children:t.source_tool}),e.jsx("svg",{className:`w-3 h-3 text-text-tertiary shrink-0 transition-transform ${r?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),r&&e.jsxs("div",{className:"px-3 pb-3 pt-1 border-t border-surface-border/50 space-y-2",children:[e.jsx("p",{className:"text-[10px] text-text-tertiary",children:t.description}),a&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-semibold uppercase tracking-widest text-text-tertiary",children:"Description"}),e.jsx("input",{type:"text",value:t.description,onChange:m=>o({description:m.target.value}),className:"input text-[11px] w-full mt-0.5"})]}),t.classification==="fixed"&&e.jsxs("div",{children:[e.jsx("label",{className:"text-[9px] font-semibold uppercase tracking-widest text-text-tertiary",children:"Default Value"}),e.jsx("input",{type:"text",value:t.default!==void 0?typeof t.default=="string"?t.default:JSON.stringify(t.default):"",onChange:m=>{let l=m.target.value;if(t.type==="number")l=Number(l)||0;else if(t.type==="boolean")l=l==="true";else try{l=JSON.parse(l)}catch{}o({default:l})},className:"input text-[11px] font-mono w-full mt-0.5"})]}),e.jsxs("div",{className:"flex items-center gap-3 pt-1",children:[e.jsx("button",{type:"button",onClick:d,className:"text-[10px] text-accent hover:underline",children:t.classification==="dynamic"?"Make fixed (add default)":"Make dynamic (require input)"}),e.jsx("button",{type:"button",onClick:s,className:"text-[10px] text-status-error hover:underline ml-auto",children:"Remove"})]})]})]})]})}const Te="w-3 h-3",De="p-1 rounded text-text-tertiary hover:text-text-primary hover:bg-surface-raised/60 transition-colors duration-150",ze="p-2 rounded text-text-tertiary hover:text-text-primary hover:bg-surface-raised transition-colors duration-150";function Ws({yamlText:t,configEditing:a,yamlDraft:r,setYamlDraft:n,yamlTextareaRef:d}){const[o,s]=p.useState(!1),[m,l]=p.useState(!1),x=p.useRef(null),c=p.useCallback(()=>{navigator.clipboard.writeText(t).then(()=>{l(!0),setTimeout(()=>l(!1),1500)})},[t]);return e.jsxs("div",{children:[e.jsx("h4",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-2",children:"YAML Definition"}),e.jsxs("div",{ref:x,className:"relative",children:[e.jsxs("div",{className:"absolute top-2 right-2 z-10 flex items-center gap-0.5 bg-surface-sunken/90 rounded backdrop-blur-sm",children:[e.jsx("a",{href:"https://github.com/hotmeshio/sdk-typescript/blob/main/docs/quickstart.md",target:"_blank",rel:"noopener noreferrer",className:De,title:"YAML Guide",children:e.jsx(dt,{className:Te})}),e.jsx("button",{onClick:c,className:De,title:"Copy YAML",children:m?e.jsx(Ae,{className:`${Te} text-status-success`}):e.jsx(xt,{className:Te})}),e.jsx("button",{onClick:()=>s(!0),className:De,title:"Fullscreen",children:e.jsx(Jt,{className:Te})})]}),a?e.jsx("textarea",{ref:d,value:r,onChange:u=>n(u.target.value),className:"w-full p-4 pr-28 bg-surface-sunken rounded-md text-xs font-mono text-text-primary leading-relaxed border border-surface-border focus:border-accent focus:outline-none resize-none overflow-hidden",rows:r.split(`
2
- `).length+1,style:{fieldSizing:"content"},spellCheck:!1}):e.jsx("pre",{className:"p-4 pr-28 bg-surface-sunken rounded-md text-xs font-mono text-text-secondary overflow-x-auto whitespace-pre",children:t})]}),e.jsxs(Lt,{open:o,onClose:()=>s(!1),sourceRef:x,children:[e.jsx("div",{className:"sticky top-0 float-right z-10",children:e.jsxs("div",{className:"flex items-center gap-0.5 bg-surface-sunken/80 rounded-md backdrop-blur-sm",children:[e.jsx("a",{href:"https://github.com/hotmeshio/sdk-typescript/blob/main/docs/quickstart.md",target:"_blank",rel:"noopener noreferrer",className:ze,title:"YAML Guide",children:e.jsx(dt,{className:"w-5 h-5"})}),e.jsx("button",{onClick:c,className:ze,title:"Copy YAML",children:m?e.jsx(Ae,{className:"w-5 h-5 text-status-success"}):e.jsx(xt,{className:"w-5 h-5"})}),e.jsx("button",{onClick:()=>s(!1),className:ze,title:"Close (Esc)",children:e.jsx(Qt,{className:"w-5 h-5"})})]})}),a?e.jsx("textarea",{value:r,onChange:u=>n(u.target.value),className:"w-full min-h-[calc(100vh-80px)] p-6 bg-transparent text-sm font-mono text-text-primary leading-relaxed focus:outline-none resize-none",spellCheck:!1,autoFocus:!0}):e.jsx("pre",{className:"text-sm font-mono text-text-secondary leading-relaxed whitespace-pre",children:t})]})]})}function Os({manifest:t}){return e.jsxs("div",{children:[e.jsx("h4",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-3",children:"Activity Manifest"}),e.jsx("div",{className:"space-y-3",children:t.filter(a=>a.tool_source!=="trigger").map(a=>{const r=a.tool_arguments&&Object.keys(a.tool_arguments).length>0,n=a.input_mappings&&Object.keys(a.input_mappings).length>0;return!r&&!n?null:e.jsxs("div",{className:"bg-surface-sunken rounded-md p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"text-[10px] font-mono text-text-tertiary",children:a.activity_id}),e.jsx("span",{className:"text-xs font-medium text-text-primary",children:a.title}),a.mcp_tool_name&&e.jsx("span",{className:"text-[10px] font-mono px-1.5 py-0.5 rounded bg-surface-raised text-text-secondary",children:a.mcp_tool_name})]}),n&&e.jsxs("div",{className:r?"mb-3":"",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:"Runtime Wiring"}),e.jsx("div",{className:"grid gap-1",children:Object.entries(a.input_mappings).map(([d,o])=>e.jsxs("div",{className:"flex items-baseline gap-2 text-xs",children:[e.jsx("span",{className:"font-mono text-text-secondary shrink-0",children:d}),e.jsx("span",{className:"text-text-tertiary shrink-0",children:"←"}),e.jsx("span",{className:"font-mono text-accent/70",children:typeof o=="object"?JSON.stringify(o):String(o)})]},d))})]}),r&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-0.5",children:"Discovery Reference"}),e.jsx("p",{className:"text-[10px] text-text-tertiary mb-1.5",children:"Values from the original execution, stored for context. Runtime values are determined by the wiring above."}),e.jsx("div",{className:"grid gap-1 opacity-60",children:Object.entries(a.tool_arguments).map(([d,o])=>{const s=typeof o=="string"?o:JSON.stringify(o),m=s.length>120;return e.jsxs("div",{className:"flex items-baseline gap-2 text-xs",children:[e.jsxs("span",{className:"font-mono text-text-secondary shrink-0",children:[d,":"]}),m?e.jsx("pre",{className:"font-mono text-text-tertiary whitespace-pre-wrap break-all flex-1",children:s}):e.jsx("span",{className:"font-mono text-text-tertiary truncate",children:s})]},d)})})]})]},a.activity_id)})})]})}function Rs({wf:t,resolvedInputSchema:a,resolvedOutputSchema:r,resolvedYaml:n,configEditing:d,setConfigEditing:o,canEditConfig:s,yamlDraft:m,setYamlDraft:l,inputSchemaDraft:x,setInputSchemaDraft:c,outputSchemaDraft:u,setOutputSchemaDraft:f,inputFieldMetaDraft:S,setInputFieldMetaDraft:i,onSave:b,onCancel:y,updateMutation:h,yamlTextareaRef:j,isCollapsed:w,onToggle:T,schemasGrid:v,unwrapped:k}){var I;const N=S.length>0,[_,L]=p.useState(!1),C=d?m:n??t.yaml_content,g=e.jsxs("div",{className:"space-y-6",children:[!k&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center gap-3",children:d&&N&&e.jsx("button",{type:"button",onClick:()=>L(!_),className:"text-[10px] text-text-tertiary hover:text-text-primary",children:_?"Visual editor":"Advanced (JSON)"})}),e.jsx("div",{className:"flex items-center gap-3",children:d&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:y,className:"text-[10px] text-text-tertiary hover:text-text-primary",children:"Cancel"}),e.jsx("button",{onClick:b,disabled:h.isPending||m===t.yaml_content&&x===JSON.stringify(t.input_schema,null,2)&&u===JSON.stringify(t.output_schema,null,2),className:"text-[10px] text-accent hover:underline disabled:opacity-40 disabled:no-underline",children:h.isPending?"Saving...":"Save"})]})})]}),k&&d&&N&&e.jsx("div",{children:e.jsx("button",{type:"button",onClick:()=>L(!_),className:"text-[10px] text-text-tertiary hover:text-text-primary",children:_?"Visual editor":"Advanced (JSON)"})}),h.error&&e.jsx("p",{className:"text-xs text-status-error",children:h.error.message}),e.jsxs("div",{className:v?"grid grid-cols-1 lg:grid-cols-2 gap-6":"space-y-6",children:[e.jsx("div",{children:d&&N&&!_?e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-2",children:"Input Schema"}),e.jsx($s,{fields:S,onChange:i,editing:d})]}):d?e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-2",children:"Input Schema"}),e.jsx("textarea",{value:x,onChange:M=>c(M.target.value),className:"w-full p-4 bg-surface-sunken rounded-md text-xs font-mono text-text-primary leading-relaxed border border-surface-border focus:border-accent focus:outline-none resize-none overflow-hidden",rows:Math.max(x.split(`
3
- `).length+1,6),style:{fieldSizing:"content"},spellCheck:!1})]}):e.jsx(U,{data:a??{},label:"Input Schema"})}),e.jsx("div",{children:d?e.jsxs(e.Fragment,{children:[e.jsx("h4",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-2",children:"Output Schema"}),e.jsx("textarea",{value:u,onChange:M=>f(M.target.value),className:"w-full p-4 bg-surface-sunken rounded-md text-xs font-mono text-text-primary leading-relaxed border border-surface-border focus:border-accent focus:outline-none resize-none overflow-hidden",rows:Math.max(u.split(`
4
- `).length+1,6),style:{fieldSizing:"content"},spellCheck:!1})]}):e.jsx(U,{data:r??{},label:"Output Schema"})})]}),e.jsx(Ws,{yamlText:C,configEditing:d,yamlDraft:m,setYamlDraft:l,yamlTextareaRef:j}),((I=t.activity_manifest)==null?void 0:I.length)>0&&e.jsx(Os,{manifest:t.activity_manifest})]});return k?g:e.jsx(ps,{sectionKey:"config",title:"Configuration",isCollapsed:w,onToggle:T,children:g})}const Bs={trigger:{bar:"bg-[#6C47FF]",dot:"bg-[#6C47FF]",hex:"#6C47FF",label:"Trigger"},mcp:{bar:"bg-blue-500",dot:"bg-blue-500",hex:"#3B82F6",label:"MCP"},db:{bar:"bg-blue-500",dot:"bg-blue-500",hex:"#3B82F6",label:"Database"},llm:{bar:"bg-violet-500",dot:"bg-violet-500",hex:"#8B5CF6",label:"LLM"},transform:{bar:"bg-emerald-500",dot:"bg-emerald-500",hex:"#10B981",label:"Transform"},signal:{bar:"bg-amber-500",dot:"bg-amber-500",hex:"#F59E0B",label:"Signal"}};function ut(t){return Bs[t]??{bar:"bg-gray-500",dot:"bg-gray-500",hex:"#6B7280",label:t}}function Je(t){return typeof t=="string"?[...t.matchAll(/\{([\w-]+)\./g)].map(a=>a[1]):Array.isArray(t)?t.flatMap(Je):t&&typeof t=="object"?Object.values(t).flatMap(Je):[]}function Fs(t,a){if(!t)return[];const r=t.indexOf(`${a}:`);if(r===-1)return[];const n=t.slice(r),d=n.indexOf("maps:");if(d===-1)return[];const o=n.slice(d),s=o.match(/\n {6,10}\w+:|^\n {0,8}\w+:/m);return[...(s?o.slice(0,o.indexOf(s[0],1)):o).matchAll(/\{([\w-]+)\./g)].map(l=>l[1])}function Es(t,a){const r=new Set(t.map(d=>d.activity_id)),n=new Map;for(const d of t){const o=d.input_mappings?Object.values(d.input_mappings).flatMap(Je):[],s=Fs(a,d.activity_id),m=new Set([...o,...s]);for(const l of m)if(r.has(l)&&l!==d.activity_id){const x=`${l}->${d.activity_id}`;n.has(x)||n.set(x,{from:l,to:d.activity_id})}}return[...n.values()]}function Ds(t,a){var o;const r=new Map;for(const s of t)r.set(s.activity_id,[]);for(const s of a)(o=r.get(s.to))==null||o.push(s.from);const n=new Map;function d(s,m){if(n.has(s))return n.get(s);if(m.has(s))return 0;m.add(s);const l=r.get(s)??[],x=l.length===0?0:Math.max(...l.map(c=>d(c,m)))+1;return n.set(s,x),x}for(const s of t)d(s.activity_id,new Set);return n}const ge=44,zs=10,qs=24,Ys=14;function Js({manifest:t,selectedId:a,onSelect:r,yaml:n}){const d=p.useRef(null),[o,s]=p.useState(0);p.useEffect(()=>{const b=d.current;if(!b)return;const y=()=>{const j=Ys*parseFloat(getComputedStyle(document.documentElement).fontSize);s(b.clientWidth-j)};y();const h=new ResizeObserver(y);return h.observe(b),()=>h.disconnect()},[]);const{edges:m,layerMap:l,numLayers:x,sortedEntries:c,rowIndex:u}=p.useMemo(()=>{const b=Es(t,n),y=b.length>0?Ds(t,b):new Map(t.map((v,k)=>[v.activity_id,k])),h=Math.max(1,...Array.from(y.values()))+1,j=t.map((v,k)=>({entry:v,origIdx:k}));j.sort((v,k)=>{const N=y.get(v.entry.activity_id)??0,_=y.get(k.entry.activity_id)??0;return N!==_?N-_:v.origIdx-k.origIdx});const w=j.map(v=>v.entry),T=new Map(w.map((v,k)=>[v.activity_id,k]));return{edges:b,layerMap:y,numLayers:h,sortedEntries:w,rowIndex:T}},[t,n]);if(t.length===0)return e.jsx("p",{className:"text-xs text-text-tertiary italic",children:"No activities in manifest"});const f=c.length*ge,S=Math.max(.7/x*100,4),i=[...new Set(t.map(b=>b.tool_source))];return e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-3 mb-3",children:i.map(b=>{const y=ut(b);return e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${y.dot}`}),e.jsx("span",{className:"text-[9px] text-text-tertiary",children:y.label})]},b)})}),e.jsxs("div",{className:"flex",children:[e.jsx("div",{className:"w-56 shrink-0"}),e.jsx("div",{className:"flex-1 relative h-5 border-b border-surface-border",children:Array.from({length:x}).map((b,y)=>e.jsx("span",{className:"absolute text-[9px] font-mono text-text-tertiary bottom-1 -translate-x-1/2",style:{left:`${(y+.5)/x*100}%`},children:y===0?"entry":`step ${y}`},y))})]}),e.jsxs("div",{ref:d,className:"relative",children:[c.map(b=>{const h=(l.get(b.activity_id)??0)/x*100,j=ut(b.tool_source),w=a===b.activity_id;return e.jsxs("div",{className:`flex items-center border-b border-surface-border cursor-pointer transition-colors ${w?"bg-accent/5":"hover:bg-surface-raised/30"}`,style:{height:ge},onClick:()=>r(w?null:b.activity_id),children:[e.jsxs("div",{className:"w-56 shrink-0 pr-4 flex items-center gap-2",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${j.dot}`}),e.jsx("p",{className:"text-xs font-mono text-text-secondary truncate",title:b.title,children:b.title})]}),e.jsxs("div",{className:"flex-1 relative h-full",children:[Array.from({length:x+1}).map((T,v)=>e.jsx("div",{className:"absolute top-0 bottom-0 w-px bg-surface-border opacity-30",style:{left:`${v/x*100}%`}},v)),e.jsx("div",{className:`absolute rounded-sm transition-all ${j.bar} ${w?"ring-2 ring-accent ring-offset-1 ring-offset-surface":"hover:brightness-110"}`,style:{left:`calc(${h}% + 4px)`,width:`calc(${S}% - 8px)`,top:zs,height:qs,minWidth:40},children:e.jsx("span",{className:"absolute inset-0 flex items-center px-2 text-[9px] font-mono text-white truncate",children:b.mcp_tool_name??b.tool_source})})]})]},b.activity_id)}),m.length>0&&o>0&&e.jsxs("svg",{className:"absolute top-0 left-56 pointer-events-none overflow-visible",style:{width:o,height:f},children:[e.jsx("defs",{children:e.jsx("marker",{id:"dag-edge-arrow",viewBox:"0 0 10 8",refX:"10",refY:"4",markerWidth:"6",markerHeight:"5",orient:"auto-start-reverse",children:e.jsx("path",{d:"M0 0 L10 4 L0 8 Z",fill:"#6B7280",opacity:"0.6"})})}),m.map((b,y)=>{const h=u.get(b.from)??0,j=u.get(b.to)??0,w=l.get(b.from)??0,T=l.get(b.to)??0,v=o/x,k=Math.max(v*.7-8,40),N=w*v+4+k,_=h*ge+ge/2,L=T*v+4,C=j*ge+ge/2,g=Math.abs(L-N)*.4;return e.jsx("path",{d:`M${N} ${_} C${N+g} ${_}, ${L-g} ${C}, ${L} ${C}`,fill:"none",stroke:"#6B7280",strokeWidth:1.5,opacity:.4,markerEnd:"url(#dag-edge-arrow)"},y)})]})]})]})}function Qs({activityManifest:t,inputSchema:a,outputSchema:r,yamlContent:n,selectedNodeId:d,onNodeSelect:o,wf:s,configEditing:m,setConfigEditing:l,canEditConfig:x,yamlDraft:c,setYamlDraft:u,inputSchemaDraft:f,setInputSchemaDraft:S,outputSchemaDraft:i,setOutputSchemaDraft:b,inputFieldMetaDraft:y,setInputFieldMetaDraft:h,onSave:j,onCancel:w,updateMutation:T,yamlTextareaRef:v}){const[k,N]=p.useState("design");return p.useEffect(()=>{m&&(N("raw"),o(null))},[m,o]),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1 mb-4",children:[e.jsx("button",{onClick:()=>{N("design")},className:`px-2.5 py-1 text-[10px] font-medium rounded transition-colors ${k==="design"?"bg-accent/10 text-accent":"text-text-tertiary hover:text-text-secondary"}`,children:"Design"}),e.jsx("button",{onClick:()=>{N("raw"),o(null)},className:`px-2.5 py-1 text-[10px] font-medium rounded transition-colors ${k==="raw"?"bg-accent/10 text-accent":"text-text-tertiary hover:text-text-secondary"}`,children:"Raw"})]}),k==="design"?e.jsx(Js,{manifest:t,selectedId:d,onSelect:o,yaml:n}):e.jsx(Rs,{wf:s,resolvedInputSchema:a,resolvedOutputSchema:r,resolvedYaml:n,configEditing:m,setConfigEditing:l,canEditConfig:x,yamlDraft:c,setYamlDraft:u,inputSchemaDraft:f,setInputSchemaDraft:S,outputSchemaDraft:i,setOutputSchemaDraft:b,inputFieldMetaDraft:y,setInputFieldMetaDraft:h,onSave:j,onCancel:w,updateMutation:T,yamlTextareaRef:v,isCollapsed:!1,onToggle:()=>{},schemasGrid:!0,unwrapped:!0})]})}function Vs({entry:t,onClose:a}){var d;const r=t.input_mappings&&Object.keys(t.input_mappings).length>0,n=((d=t.output_fields)==null?void 0:d.length)>0;return e.jsxs("div",{className:"space-y-4 text-xs",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-mono font-medium text-sm text-text-primary truncate",children:t.title}),e.jsx("p",{className:"font-mono text-[10px] text-text-tertiary mt-0.5 truncate",children:t.activity_id})]}),e.jsx("button",{onClick:a,className:"text-text-tertiary hover:text-text-primary text-[10px] shrink-0",children:"Close"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-2",children:[e.jsx(he,{label:"Type",value:t.type}),e.jsx(he,{label:"Source",value:t.tool_source}),t.mcp_tool_name&&e.jsx(he,{label:"Tool",value:t.mcp_tool_name}),t.mcp_server_id&&e.jsx(he,{label:"Server",value:t.mcp_server_id}),t.model&&e.jsx(he,{label:"Model",value:t.model}),t.topic&&e.jsx(he,{label:"Topic",value:t.topic}),t.hook_topic&&e.jsx(he,{label:"Hook",value:t.hook_topic})]}),r&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-1.5",children:"Input Mappings"}),e.jsx("div",{className:"grid gap-1",children:Object.entries(t.input_mappings).map(([o,s])=>e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"font-mono text-text-secondary shrink-0",children:o}),e.jsx("span",{className:"text-text-tertiary shrink-0",children:"←"}),e.jsx("span",{className:"font-mono text-accent/70 truncate",children:typeof s=="object"?JSON.stringify(s):String(s)})]},o))})]}),n&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-1.5",children:"Output Fields"}),e.jsx("p",{className:"font-mono text-text-secondary leading-relaxed",children:t.output_fields.join(", ")})]}),t.prompt_template&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-1.5",children:"Prompt Template"}),e.jsx("pre",{className:"text-[11px] font-mono text-text-secondary whitespace-pre-wrap break-words leading-relaxed max-h-48 overflow-y-auto",children:t.prompt_template})]})]})}function he({label:t,value:a}){return e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary",children:t}),e.jsx("p",{className:"font-mono text-text-primary",children:a})]})}const qe=["draft","active","archived"],Ks={draft:"Draft",active:"Active",archived:"Archived"},Us={draft:{filled:"bg-status-draft border-status-draft",line:"bg-status-draft/30"},active:{filled:"bg-status-success border-status-success",line:"bg-status-success/30"},archived:{filled:"bg-text-tertiary border-text-tertiary",line:"bg-text-tertiary/30"}};function Hs({status:t,sourceWorkflowId:a,contentVersion:r,deployedContentVersion:n,appId:d,appVersion:o,siblingCount:s,onDeploy:m,onArchive:l,onRestore:x,onDelete:c,onRegenerate:u,isPending:f,error:S}){const i=t==="deployed"?"active":t,b=qe.indexOf(i),y=r!=null&&r>(n??0);return e.jsxs("div",{children:[e.jsx(bt,{className:"mb-4",children:"Lifecycle"}),y&&i!=="draft"&&i!=="archived"&&e.jsxs("div",{className:"mb-4 px-3 py-2 rounded-md bg-status-pending/10 border border-status-pending/30",children:[e.jsx("p",{className:"text-[10px] font-semibold text-status-pending mb-1",children:"YAML modified"}),e.jsxs("p",{className:"text-[10px] text-text-secondary leading-relaxed",children:["v",r," edited since deploy (v",n,"). Redeploy to apply changes."]}),e.jsx("button",{onClick:m,disabled:f,className:"mt-1.5 text-[10px] font-medium text-status-pending hover:underline",children:f?"Deploying...":"Deploy now"})]}),e.jsx("div",{className:"space-y-0",children:qe.map((h,j)=>{const w=h===i,T=j<b,v=j>b,k=j===qe.length-1,N=Us[h];return e.jsxs("div",{className:"flex items-stretch gap-3",children:[e.jsxs("div",{className:"flex flex-col items-center w-5 shrink-0",children:[e.jsx("span",{className:`w-3 h-3 rounded-full shrink-0 border-2 transition-colors ${w||T?N.filled:"bg-surface-sunken border-surface-border"}`}),!k&&e.jsx("span",{className:`w-px flex-1 ${T?N.line:"bg-surface-border"}`})]}),e.jsxs("div",{className:`pb-5 ${k?"pb-0":""}`,children:[e.jsx("p",{className:`text-xs font-medium ${w?"text-text-primary":v?"text-text-tertiary":"text-text-secondary"}`,children:Ks[h]}),w&&h==="draft"&&e.jsx("div",{className:"mt-2",children:e.jsx("button",{onClick:m,disabled:f,className:"btn-primary text-[11px] px-3 py-1",children:f?"Deploying...":"Deploy & Activate"})}),w&&h==="active"&&e.jsx("div",{className:"mt-2",children:e.jsx("button",{onClick:l,disabled:f,className:"text-[11px] text-text-tertiary hover:text-status-error",children:"Archive"})}),w&&h==="archived"&&x&&e.jsx("div",{className:"mt-2",children:e.jsx("button",{onClick:x,disabled:f,className:"text-[11px] font-medium text-accent hover:text-accent/80",children:f?"Restoring...":"Restore to Draft"})})]})]},h)})}),d&&e.jsxs("div",{className:"mt-4 pt-4 border-t border-surface-border",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:"App Namespace"}),e.jsx("p",{className:"text-xs font-mono text-text-primary",children:d}),e.jsx("div",{className:"flex items-center gap-3 mt-1.5",children:o!=null&&e.jsxs("span",{className:"text-[10px] text-text-secondary",children:["app v",o," ","→"," ",e.jsxs("span",{className:"text-accent",children:["v",o+1]})," on deploy"]})}),s!=null&&s>1&&e.jsxs("p",{className:"text-[10px] text-text-tertiary mt-1",children:[s," tool",s===1?"":"s"," in this namespace"]})]}),r!=null&&e.jsxs("div",{className:"mt-4 pt-4 border-t border-surface-border",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:"Tool Content"}),e.jsxs("p",{className:"text-xs font-mono text-text-primary",children:["v",r,n!=null&&e.jsxs("span",{className:"text-text-tertiary ml-1.5",children:["(deployed: v",n,")"]})]})]}),(t==="draft"||t==="archived")&&e.jsx("div",{className:"mt-4 pt-4 border-t border-surface-border",children:e.jsxs("button",{onClick:c,disabled:f,className:"inline-flex items-center gap-1.5 text-[11px] text-status-error/70 hover:text-status-error transition-colors hover:underline",children:[e.jsx(Vt,{className:"w-3.5 h-3.5",strokeWidth:1.5}),"Delete Compiled Workflow"]})}),S&&e.jsx("p",{className:"mt-3 text-[11px] text-status-error",children:S})]})}function Gs({versionsData:t,searchParams:a,setSearchParams:r,currentVersion:n,viewingVersion:d}){return e.jsxs("div",{children:[e.jsx(bt,{className:"mb-3",children:"Version History"}),e.jsx("div",{className:"space-y-1",children:t.versions.map(o=>{const s=o.version===n,m=d===o.version;return e.jsxs("button",{type:"button",onClick:()=>{const l=new URLSearchParams(a);s?l.delete("version"):l.set("version",String(o.version)),r(l)},className:`w-full text-left px-2 py-1.5 rounded text-xs transition-colors ${m?"bg-accent/10 text-accent":"text-text-secondary hover:bg-surface-sunken hover:text-text-primary"}`,children:[e.jsxs("span",{className:"font-mono font-medium",children:["v",o.version]}),s&&e.jsx("span",{className:"text-text-tertiary ml-1",children:"(current)"}),o.change_summary&&e.jsx("p",{className:"text-[10px] text-text-tertiary truncate mt-0.5",children:o.change_summary})]},o.version)})})]})}function Xs({feedbackText:t,setFeedbackText:a,dismissing:r,onClose:n,onRegenerate:d,isPending:o}){return e.jsxs("div",{className:"mb-4 p-4 bg-surface-sunken border border-surface-border rounded-lg overflow-hidden transition-all duration-250 ease-in-out",style:{animation:r?void 0:"fadeIn 300ms ease-out both",opacity:r?0:1,maxHeight:r?"0px":"400px",paddingTop:r?"0px":void 0,paddingBottom:r?"0px":void 0,marginBottom:r?"0px":void 0},children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary",children:"What should change?"}),e.jsx("button",{onClick:n,className:"text-text-tertiary hover:text-text-secondary transition-colors",children:e.jsx(Re,{className:"w-3.5 h-3.5"})})]}),e.jsx("textarea",{value:t,onChange:s=>a(s.target.value),placeholder:"E.g.: 'Only url, username, password, and screenshot_dir should be dynamic inputs. The steps array and script are implementation details.'",className:"w-full min-h-[80px] px-3 py-2 bg-surface border border-surface-border rounded-md text-xs text-text-primary placeholder:text-text-tertiary resize-y focus:outline-none focus:ring-1 focus:ring-inset focus:ring-accent-primary"}),e.jsxs("div",{className:"flex items-center justify-between mt-2",children:[e.jsx("p",{className:"text-[10px] text-text-tertiary",children:"This feedback guides the compiler. The current YAML will be replaced."}),e.jsx("button",{onClick:d,disabled:!t.trim()||o,className:"btn-primary text-xs shrink-0 ml-4",children:o?"Recompiling...":"Recompile Pipeline"})]})]})}function Ze({yamlId:t,onAdvance:a,onBack:r,onRegenerate:n,regeneratePending:d}){var Q,te,ue,Pe;const o=pe(),s=p.useRef(null),[m,l]=p.useState(""),[x,c]=p.useState(!1),[u,f]=p.useState(!1),S=()=>{f(!0),setTimeout(()=>{c(!1),f(!1)},250)},{data:i,refetch:b}=Ce(t),{data:y}=Ue(i?{app_id:i.app_id}:{}),h=((Q=y==null?void 0:y.workflows)==null?void 0:Q.length)??0,j=Math.max(...((te=y==null?void 0:y.workflows)==null?void 0:te.map(re=>parseInt(re.app_version||"0",10)))??[0]),{data:w}=ts(t),T=ss(),v=as(),k=rs(),N=ns(),_=is(),L=cs(),C=Fe(),[g,I]=p.useState(""),[M,W]=p.useState(""),[$,F]=p.useState(""),[se,J]=p.useState([]),[ae,z]=p.useState(!1),[B,E]=p.useState(null),O=B!==null&&i!=null&&B!==i.content_version,{data:Y}=ls(t,O?B:null),H=O&&Y?Y.yaml_content:i==null?void 0:i.yaml_content,q=O&&Y?Y.input_schema:i==null?void 0:i.input_schema,G=O&&Y?Y.output_schema:i==null?void 0:i.output_schema;p.useEffect(()=>{i&&(I(i.yaml_content),W(JSON.stringify(i.input_schema,null,2)),F(JSON.stringify(i.output_schema,null,2)),i.input_field_meta&&J(i.input_field_meta))},[i==null?void 0:i.id,i==null?void 0:i.content_version]);const ie=p.useMemo(()=>{const re=new URLSearchParams;return B!==null&&re.set("version",String(B)),re},[B]),de=p.useCallback(re=>{const xe=re.get("version");E(xe?parseInt(xe,10):null)},[]),[ne,X]=p.useState(null),P=O&&Y?Y.activity_manifest:(i==null?void 0:i.activity_manifest)??[],D=p.useMemo(()=>P.find(re=>re.activity_id===ne)??null,[P,ne]),Z=(i==null?void 0:i.status)!=="archived"&&!O,ce=async()=>{if(!i)return;let re,xe;try{re=JSON.parse(M)}catch{}try{xe=JSON.parse($)}catch{}await C.mutateAsync({id:i.id,yaml_content:g,...re?{input_schema:re}:{},...xe?{output_schema:xe}:{}}),z(!1),b()},A=()=>{i&&(I(i.yaml_content),W(JSON.stringify(i.input_schema,null,2)),F(JSON.stringify(i.output_schema,null,2)),z(!1))},R=async()=>{i&&(await T.mutateAsync(i.id),await v.mutateAsync(i.id),o.invalidateQueries({queryKey:["yamlWorkflowForSource"],refetchType:"all"}),o.invalidateQueries({queryKey:["yamlWorkflow"],refetchType:"all"}),b(),a())},K=async()=>{if(n){n(m.trim()),l(""),c(!1);return}try{await L.mutateAsync({id:t,compilation_feedback:m.trim()||void 0}),l(""),c(!1),b()}catch{}};if(!i)return e.jsx("p",{className:"text-sm text-text-secondary animate-pulse",children:"Loading workflow..."});const ee=T.isPending||v.isPending||k.isPending||N.isPending||L.isPending||_.isPending||!!d;return e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[1fr_240px] gap-6",children:[e.jsxs("div",{className:"min-w-0 overflow-hidden",children:[e.jsxs("div",{className:"flex items-start justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-extralight tracking-wide text-accent/75 mb-1",children:"Deploy"}),e.jsx("p",{className:"text-base text-text-secondary",children:"Review and edit the workflow definition. Re/deploy when ready."})]}),e.jsx("div",{className:"flex items-center gap-3 shrink-0",children:ae?e.jsxs(e.Fragment,{children:[e.jsx(me,{icon:Re,label:"Cancel",onClick:()=>{A(),z(!1)}}),e.jsx(me,{icon:Ae,label:C.isPending?"Saving...":"Save",onClick:ce,disabled:C.isPending||g===i.yaml_content&&M===JSON.stringify(i.input_schema,null,2)&&$===JSON.stringify(i.output_schema,null,2)})]}):e.jsxs(e.Fragment,{children:[e.jsx(me,{icon:Kt,label:"Recompile with Feedback",onClick:()=>{c(!x)}}),e.jsx(me,{icon:Oe,label:"Manual Edit",onClick:()=>{z(!0),c(!1)}})]})})]}),x&&e.jsx(Xs,{feedbackText:m,setFeedbackText:l,dismissing:u,onClose:S,onRegenerate:K,isPending:L.isPending}),L.isError&&e.jsx("div",{className:"mb-4 px-3 py-2 bg-status-error/5 border border-status-error/20 rounded-md",children:e.jsx("p",{className:"text-xs text-status-error",children:((ue=L.error)==null?void 0:ue.message)||"Recompilation failed"})}),O&&e.jsxs("div",{className:"mb-4 px-3 py-2 bg-accent-muted/20 border border-accent-muted/40 rounded-md flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-accent",children:["Viewing version ",B]}),e.jsx("button",{onClick:()=>E(null),className:"text-xs text-accent hover:underline",children:"Back to current"})]}),e.jsx(Qs,{yamlContent:H,activityManifest:P,inputSchema:q,outputSchema:G,wf:i,configEditing:ae,setConfigEditing:z,canEditConfig:Z,yamlDraft:g,setYamlDraft:I,inputSchemaDraft:M,setInputSchemaDraft:W,outputSchemaDraft:$,setOutputSchemaDraft:F,inputFieldMetaDraft:se,setInputFieldMetaDraft:J,onSave:ce,onCancel:A,updateMutation:C,yamlTextareaRef:s,selectedNodeId:ne,onNodeSelect:X}),e.jsxs(le,{children:[e.jsx("button",{onClick:r,className:"px-3 py-1.5 text-xs text-text-secondary hover:text-text-primary",children:"Back"}),i.status==="active"?e.jsx("button",{onClick:a,disabled:x,className:"btn-primary text-xs",children:"Next: Test"}):e.jsx("button",{onClick:R,disabled:ee||x,className:"btn-primary text-xs",children:ee?"Deploying...":"Deploy & Activate"})]})]}),e.jsx("div",{className:"space-y-6",children:e.jsx("div",{className:"sticky top-6",children:D?e.jsx(Vs,{entry:D,onClose:()=>X(null)}):e.jsxs(e.Fragment,{children:[e.jsx(Hs,{status:i.status,sourceWorkflowId:i.source_workflow_id,contentVersion:i.content_version,deployedContentVersion:i.deployed_content_version,appId:i.app_id,appVersion:j,siblingCount:h,onDeploy:R,onArchive:()=>k.mutateAsync(t).then(()=>b()),onRestore:()=>N.mutateAsync(t).then(()=>b()),onDelete:async()=>{await _.mutateAsync(t),o.invalidateQueries({queryKey:["yamlWorkflowForSource"],refetchType:"all"}),r()},onRegenerate:K,isPending:ee,error:void 0}),(((Pe=w==null?void 0:w.versions)==null?void 0:Pe.length)??0)>1&&e.jsx(Gs,{versionsData:w,searchParams:ie,setSearchParams:de,currentVersion:i.content_version,viewingVersion:O?B:null})]})})})]})}const ht={mcp:{border:"border-blue-500",text:"text-blue-500",icon:"MCP"},db:{border:"border-blue-500",text:"text-blue-500",icon:"DB"},llm:{border:"border-violet-500",text:"text-violet-500",icon:"LLM"},transform:{border:"border-emerald-500",text:"text-emerald-500",icon:"Map"}};function Zs({steps:t,manifest:a,isComplete:r}){const n=a.filter(s=>s.type==="worker"),d=n.length,o=n.map((s,m)=>{const l=t.find(u=>u.activityId===s.activity_id),x=s.tool_source||"mcp",c=ht[x]||ht.mcp;return{activityId:s.activity_id,title:s.title||s.mcp_tool_name||s.activity_id,toolName:s.mcp_tool_name,toolSource:x,colors:c,stepIndex:m,status:(l==null?void 0:l.status)||"pending",error:l==null?void 0:l.error}});return e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-text-secondary mb-4",children:r?`All ${d} steps completed`:`Running step ${o.filter(s=>s.status==="completed").length+1} of ${d}...`}),e.jsx("div",{className:"space-y-0",children:o.map((s,m)=>{const l=m===o.length-1;return e.jsxs("div",{className:"flex items-stretch gap-3",children:[e.jsxs("div",{className:"flex flex-col items-center w-5 shrink-0",children:[e.jsx("span",{className:`w-3 h-3 rounded-full shrink-0 border-2 transition-colors ${s.status==="completed"?"bg-status-success border-status-success":s.status==="running"?`${s.colors.border} bg-transparent animate-pulse`:s.status==="failed"?"bg-status-error border-status-error":"bg-surface-sunken border-surface-border"}`}),!l&&e.jsx("span",{className:`w-px flex-1 transition-colors ${s.status==="completed"?"bg-status-success/30":"bg-surface-border"}`})]}),e.jsxs("div",{className:`pb-4 ${l?"pb-0":""}`,children:[e.jsx("p",{className:`text-xs font-medium ${s.status==="running"?"text-text-primary":s.status==="completed"?"text-text-secondary":s.status==="failed"?"text-status-error":"text-text-tertiary"}`,children:s.title}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx("span",{className:`text-[9px] font-mono px-1 py-0.5 rounded border ${s.colors.border} ${s.colors.text} bg-transparent`,children:s.colors.icon}),s.toolName&&e.jsx(fs,{name:s.toolName})]}),s.error&&e.jsx("p",{className:"text-[10px] text-status-error mt-1",children:s.error})]})]},s.activityId)})}),r&&e.jsx("p",{className:"text-[10px] text-text-tertiary mt-3 text-center",children:"Closing..."})]})}function ea({sidebarOpen:t,activeJobId:a,activitySteps:r,activityManifest:n,jobComplete:d,invokeJsonMode:o,setInvokeJsonMode:s,invokeJson:m,setInvokeJson:l,invokeFields:x,setInvokeFields:c,executeAs:u,setExecuteAs:f,invokeError:S,invokePending:i,onInvoke:b,onClose:y}){return!t&&!a?e.jsx("div",{className:"text-center py-8",children:e.jsx("p",{className:"text-xs text-text-tertiary",children:'Click "Run Test" to invoke the compiled pipeline'})}):e.jsx("div",{style:{animation:"fadeIn 300ms ease-out both"},children:a?e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-3",children:"Execution"}),e.jsx(Zs,{steps:r,manifest:n??[],isComplete:d})]}):e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary",children:"Test Inputs"}),e.jsx("button",{onClick:()=>{if(!o)l(JSON.stringify(x,null,2));else try{c(JSON.parse(m))}catch{}s(!o)},className:"text-[10px] text-accent hover:underline",children:o?"Form view":"JSON view"})]}),e.jsx(js,{selected:u,onChange:f}),e.jsx("div",{className:"mt-3",children:o?e.jsx("textarea",{value:m,onChange:h=>l(h.target.value),className:"w-full min-h-[200px] px-3 py-2 bg-surface-sunken border border-surface-border rounded-md font-mono text-xs text-text-primary resize-y focus:outline-none focus:ring-1 focus:ring-inset focus:ring-accent-primary"}):e.jsx("div",{className:"space-y-3 max-h-[400px] overflow-y-auto",children:Object.entries(x).map(([h,j])=>e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:h}),typeof j=="boolean"?e.jsxs("select",{value:String(j),onChange:w=>c({...x,[h]:w.target.value==="true"}),className:"w-full bg-surface-sunken border border-surface-border rounded-md px-3 py-1.5 text-xs text-text-primary focus:outline-none focus:ring-1 focus:ring-inset focus:ring-accent-primary",children:[e.jsx("option",{value:"true",children:"true"}),e.jsx("option",{value:"false",children:"false"})]}):typeof j=="object"?e.jsx("textarea",{value:JSON.stringify(j,null,2),onChange:w=>{try{c({...x,[h]:JSON.parse(w.target.value)})}catch{}},className:"w-full min-h-[60px] px-3 py-1.5 bg-surface-sunken border border-surface-border rounded-md font-mono text-xs text-text-primary resize-y focus:outline-none focus:ring-1 focus:ring-inset focus:ring-accent-primary"}):e.jsx("input",{type:typeof j=="number"?"number":"text",value:String(j??""),onChange:w=>c({...x,[h]:typeof j=="number"?Number(w.target.value):w.target.value}),className:"w-full bg-surface-sunken border border-surface-border rounded-md px-3 py-1.5 text-xs text-text-primary focus:outline-none focus:ring-1 focus:ring-inset focus:ring-accent-primary"})]},h))})}),S&&e.jsx("p",{className:"mt-2 text-xs text-status-error",children:S}),e.jsxs("div",{className:"flex justify-end gap-3 mt-4",children:[e.jsx("button",{onClick:y,className:"px-3 py-1.5 text-xs text-text-secondary hover:text-text-primary",children:"Cancel"}),e.jsx("button",{onClick:b,disabled:i,className:"btn-primary text-xs",children:i?"Starting...":"Invoke"})]})]})})}function je({children:t}){return e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-widest text-text-tertiary",children:t}),e.jsx("span",{className:"flex-1 border-b border-surface-border"})]})}function Ct(t){const a=new Date(t.created_at),r=a.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),n=a.toLocaleDateString([],{month:"short",day:"numeric"}),d=t.status==="completed"||Number(t.status)===0?"completed":t.is_live?"running":"failed";return`${n} ${r} — ${d}`}function ta({jobs:t,selectedRunId:a,onSelectRun:r,deterministicInput:n,deterministicOutput:d,inputSchema:o,runLoading:s,selectedRunExecution:m}){return e.jsxs(e.Fragment,{children:[t.length>0&&a&&e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary",children:"Pipeline Run"}),e.jsx("select",{value:a,onChange:l=>r(l.target.value),className:"bg-transparent border-none text-[10px] text-accent hover:text-accent/80 cursor-pointer focus:outline-none p-0 text-right",children:t.map(l=>e.jsx("option",{value:l.workflow_id,children:Ct(l)},l.workflow_id))})]}),e.jsx(je,{children:"Input"}),e.jsx("div",{className:"mb-6",children:n?e.jsx(U,{data:n,defaultMode:"tree"}):a&&o?e.jsx(U,{data:o,defaultMode:"tree"}):e.jsx("p",{className:"text-xs text-text-tertiary italic",children:'No runs yet — click "Run Test" to invoke the pipeline'})}),e.jsx(je,{children:"Output"}),e.jsxs("div",{className:"mb-6",children:[d?e.jsx(U,{data:d,defaultMode:"tree"}):a&&s?e.jsx("p",{className:"text-xs text-text-tertiary animate-pulse",children:"Loading..."}):a&&m?e.jsx(U,{data:m.result??m,defaultMode:"tree"}):a?e.jsx("p",{className:"text-xs text-text-tertiary animate-pulse",children:"Loading..."}):e.jsx("p",{className:"text-xs text-text-tertiary italic",children:"No runs yet"}),(m==null?void 0:m.duration_ms)!=null&&e.jsxs("p",{className:"text-[10px] text-text-tertiary mt-2",children:[(m.duration_ms/1e3).toFixed(1),"s"]})]})]})}function sa({jobs:t,selectedRunId:a,onSelectRun:r,originalEnvelope:n,resolvedPrompt:d,originalOutput:o,originalDurationMs:s,deterministicInput:m,deterministicOutput:l,inputSchema:x,runLoading:c,selectedRunExecution:u}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-8 mb-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary",children:"Original MCP Query"}),e.jsx("p",{className:"text-[10px] text-text-tertiary mt-0.5",children:"Dynamic LLM orchestration"})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary",children:"Compiled Pipeline Run"}),t.length>0&&a&&e.jsx("select",{value:a,onChange:f=>r(f.target.value),className:"mt-0.5 bg-transparent border-none text-[10px] text-accent hover:text-accent/80 cursor-pointer focus:outline-none p-0 text-right direction-rtl",children:t.map(f=>e.jsx("option",{value:f.workflow_id,children:Ct(f)},f.workflow_id))}),!a&&e.jsx("p",{className:"text-[10px] text-text-tertiary mt-0.5",children:"No runs yet"})]})]}),e.jsx(je,{children:"Input"}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8 mb-6",children:[e.jsx("div",{children:n?e.jsx(U,{data:n,defaultMode:"tree"}):d?e.jsx("p",{className:"text-xs text-text-primary leading-relaxed px-3 py-2 bg-surface-sunken rounded-md",children:d}):e.jsx("p",{className:"text-xs text-text-tertiary italic",children:"Loading..."})}),e.jsx("div",{children:m?e.jsx(U,{data:m,defaultMode:"tree"}):a&&x?e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] text-text-tertiary italic mb-1",children:"Stored defaults"}),e.jsx(U,{data:x,defaultMode:"tree"})]}):e.jsx("p",{className:"text-xs text-text-tertiary italic",children:"No runs yet"})})]}),e.jsx(je,{children:"Output"}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8 mb-6",children:[e.jsxs("div",{children:[o?e.jsx(U,{data:o,defaultMode:"tree"}):e.jsx("p",{className:"text-xs text-text-tertiary italic",children:"No output"}),s!=null&&e.jsxs("p",{className:"text-[10px] text-text-tertiary mt-2",children:[(s/1e3).toFixed(1),"s"]})]}),e.jsxs("div",{children:[l?e.jsx(U,{data:l,defaultMode:"tree"}):a&&c?e.jsx("p",{className:"text-xs text-text-tertiary animate-pulse",children:"Loading..."}):a&&u?e.jsx(U,{data:u.result??u,defaultMode:"tree"}):a?e.jsx("p",{className:"text-xs text-text-tertiary animate-pulse",children:"Loading..."}):e.jsx("p",{className:"text-xs text-text-tertiary italic",children:"No runs yet"}),(u==null?void 0:u.duration_ms)!=null&&e.jsxs("p",{className:"text-[10px] text-text-tertiary mt-2",children:[(u.duration_ms/1e3).toFixed(1),"s"]})]})]})]})}function et({yamlId:t,originalWorkflowId:a,originalResult:r,originalPrompt:n,onBack:d,onAdvance:o,builderMode:s}){var de,ne,X;const m=pe(),[l,x]=fe(),{data:c}=Ce(t),{data:u}=us({entity:c==null?void 0:c.graph_topic,app_id:(c==null?void 0:c.app_id)||"longtail",limit:10}),f=l.get("run"),S=P=>{x(D=>{const Z=new URLSearchParams(D);return P?Z.set("run",P):Z.delete("run"),Z},{replace:!0})},[i,b]=p.useState(f),y=P=>{b(P),S(P)},{data:h,isLoading:j}=hs(i??"",(c==null?void 0:c.app_id)||"longtail"),[w,T]=p.useState(!1),[v,k]=p.useState(!1),[N,_]=p.useState({}),[L,C]=p.useState("{}"),[g,I]=p.useState(""),[M,W]=p.useState(null),$=os(),{steps:F,isComplete:se}=Rt(M);p.useEffect(()=>{if(c!=null&&c.input_schema){const P=gs(c.input_schema);_(P),C(JSON.stringify(P,null,2))}},[c==null?void 0:c.id]);const J=(u==null?void 0:u.jobs)??[];p.useEffect(()=>{!i&&!f&&J.length>0&&y(J[0].workflow_id)},[J.length]),p.useEffect(()=>{f&&!i&&b(f)},[f]),p.useEffect(()=>{if(se&&M){const P=M,D=setTimeout(()=>{y(P),W(null),T(!1),m.invalidateQueries({queryKey:["mcpRuns"],refetchType:"all"}),m.invalidateQueries({queryKey:["mcpRunExecution",P],refetchType:"all"})},1200);return()=>clearTimeout(D)}},[se,M]);const ae=async()=>{if(c)try{const P=v?JSON.parse(L):N,D=await $.mutateAsync({id:c.id,data:P,sync:!1,...g?{execute_as:g}:{}});D.job_id&&(W(D.job_id),y(D.job_id))}catch{}},z=()=>{W(null),T(!0)},{data:B}=Ye(s?"":a??""),{data:E}=Ge(s?"":a??""),O=(de=B==null?void 0:B.result)==null?void 0:de.data,Y=p.useMemo(()=>{if(s||!(E!=null&&E.envelope))return null;try{return typeof E.envelope=="string"?JSON.parse(E.envelope):E.envelope}catch{return null}},[s,E==null?void 0:E.envelope]),H=((ne=Y==null?void 0:Y.data)==null?void 0:ne.prompt)??n;if(!c)return e.jsx("p",{className:"text-sm text-text-secondary animate-pulse",children:"Loading..."});const q=s?null:(O==null?void 0:O.result)??(typeof(O==null?void 0:O.summary)=="string"?Se(O.summary):null)??(r==null?void 0:r.result)??(typeof(r==null?void 0:r.summary)=="string"?Se(r.summary):null)??r;let G=null,ie=null;if(h!=null&&h.result){const P=h.result;if(typeof P.response=="string"){const D=P.response.match(/```json\s*([\s\S]*?)```/);if(D)try{G=JSON.parse(D[1].trim())}catch{G=P}else G=Se(P.response)??P}else G=P}if((X=h==null?void 0:h.events)!=null&&X.length){const P=h.events.find(D=>{var Z;return D.event_type==="activity_task_completed"&&D.is_system&&((Z=D.attributes)==null?void 0:Z.result)&&Object.keys(D.attributes.result).length>0});ie=P?P.attributes.result:null}return e.jsxs("div",{children:[e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[1fr_400px] gap-8 min-w-0",children:[e.jsxs("div",{className:"min-w-0 overflow-hidden",children:[e.jsxs("div",{className:"flex items-start justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-extralight tracking-wide text-accent/75 mb-1",children:"Test"}),e.jsx("p",{className:"text-base text-text-secondary",children:s?"Run the pipeline with test inputs and review the results.":"Run the pipeline with test inputs and compare results against the original execution."})]}),e.jsx(me,{icon:Ut,label:"Run Test",onClick:z})]}),s?e.jsx(ta,{jobs:J,selectedRunId:i,onSelectRun:y,deterministicInput:ie,deterministicOutput:G,inputSchema:c.input_schema,runLoading:j,selectedRunExecution:h}):e.jsx(sa,{jobs:J,selectedRunId:i,onSelectRun:y,originalEnvelope:Y,resolvedPrompt:H,originalOutput:q,originalDurationMs:B==null?void 0:B.duration_ms,deterministicInput:ie,deterministicOutput:G,inputSchema:c.input_schema,runLoading:j,selectedRunExecution:h})]}),e.jsx("div",{className:"space-y-6",children:e.jsx("div",{className:"sticky top-6",children:e.jsx(ea,{sidebarOpen:w,activeJobId:M,activitySteps:F,activityManifest:c.activity_manifest,jobComplete:se,invokeJsonMode:v,setInvokeJsonMode:k,invokeJson:L,setInvokeJson:C,invokeFields:N,setInvokeFields:_,executeAs:g,setExecuteAs:I,invokeError:$.isError?$.error.message:void 0,invokePending:$.isPending,onInvoke:ae,onClose:()=>T(!1)})})})]}),e.jsxs(le,{children:[e.jsx("button",{onClick:d,className:"px-3 py-1.5 text-xs text-text-secondary hover:text-text-primary",children:"Back"}),!s&&e.jsx("button",{onClick:o,className:"btn-primary text-xs",children:"Next: Verify"})]})]})}function aa(){var se,J,ae,z,B,E,O,Y,H;const t=Ke(),{workflowId:a}=Be(),[r,n]=fe(),[d,o]=p.useState(null),s=ks();He(a);const{data:m,refetch:l}=St(a),x=(se=m==null?void 0:m.result)==null?void 0:se.data,c=!!(x!=null&&x.yaml),u=!!(x!=null&&x.clarification_needed),f=!m||!c&&!u&&!((J=x==null?void 0:x.title)!=null&&J.includes("Failed")),S=x==null?void 0:x.name,{data:i}=Ue(S?{search:S,limit:1}:{}),b=(z=(ae=i==null?void 0:i.workflows)==null?void 0:ae[0])==null?void 0:z.id,y=d||b||null,{data:h}=Ce(y||""),j=(h==null?void 0:h.status)||"draft",w=j==="deployed"||j==="active",T=["Describe","Profile","Deploy","Test"];let v=1;c&&(v=2),y&&(v=3),w&&(v=4);const k=r.get("step"),[N,_]=p.useState(null),C=N??(k?Math.min(Number(k),v):c?2:1);p.useEffect(()=>{!k&&m&&n({mode:"builder",step:String(C)},{replace:!0})},[m,C]);const g=q=>{q<=v&&(_(q),n({mode:"builder",step:String(q)}))},{data:I}=$e(a),M=(B=I==null?void 0:I.events)==null?void 0:B.find(q=>q.event_type==="workflow_execution_started"),W=Array.isArray((E=M==null?void 0:M.attributes)==null?void 0:E.input)?M.attributes.input[0]:(O=M==null?void 0:M.attributes)==null?void 0:O.input,$=((Y=W==null?void 0:W.data)==null?void 0:Y.prompt)||((H=W==null?void 0:W.data)==null?void 0:H.question)||void 0,F=async q=>{if(!(x!=null&&x.yaml)||!$)return;const G=await s.mutateAsync({prompt:$,prior_yaml:(h==null?void 0:h.yaml_content)||x.yaml,feedback:q,tags:x.tags});t(`/mcp/queries/${G.workflow_id}?mode=builder`,{replace:!0})};return e.jsxs("div",{className:"flex flex-col min-h-[calc(100vh-12rem)]",children:[e.jsx(Ie,{title:"MCP Tool Designer",actions:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-accent/10 text-accent font-medium",children:"Direct Build"}),e.jsx(ye,{status:u?"pending":f?"in_progress":c?"completed":"failed"})]})}),e.jsx(Xe,{labels:T,current:C,maxReachable:v,onStepClick:g}),e.jsxs("div",{className:"flex-1 mt-4",children:[C===1&&e.jsx(As,{workflowId:a,status:u?"clarification":f?"in_progress":c?"completed":"failed",builderData:x,onBuilt:()=>{l(),_(2)},onNext:()=>g(2)}),C===2&&c&&e.jsx(Ls,{builderData:x,resolvedYamlId:y,originalPrompt:$,onBack:()=>g(1),onCreate:q=>{o(q),g(3)},onNext:()=>g(3)}),C===3&&y&&e.jsx(Ze,{yamlId:y,onAdvance:()=>g(4),onBack:()=>g(2),onRegenerate:F,regeneratePending:s.isPending}),C===4&&y&&e.jsx(et,{yamlId:y,originalWorkflowId:a,originalResult:void 0,originalPrompt:$,onBack:()=>g(3),onAdvance:()=>{},builderMode:!0})]})]})}function ra(t){const a="w-4 h-4 shrink-0";return t?t==="active"?e.jsx(Xt,{className:`${a} text-status-success`,strokeWidth:1.5}):t==="deployed"?e.jsx(Zt,{className:`${a} text-accent`,strokeWidth:1.5}):t==="draft"?e.jsx(es,{className:`${a} text-accent/75`,strokeWidth:1.5}):e.jsx(be,{className:`${a} text-accent animate-spin`,strokeWidth:1.5}):e.jsx(be,{className:`${a} text-text-tertiary animate-spin`,strokeWidth:1.5})}function na({plan:t,namespaces:a,yamlStatuses:r,activeWorkflow:n,isAddOpen:d,onSelect:o,onAdd:s}){const m=p.useMemo(()=>{var c;const x={};for(const u of t)(x[c=u.namespace]||(x[c]=[])).push(u);return x},[t]),l=a.length>1;return e.jsxs("nav",{className:"w-56 shrink-0 overflow-y-auto sticky top-0 self-start",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary",children:"Pipeline Tools"}),s&&e.jsx("button",{onClick:s,className:`w-6 h-6 flex items-center justify-center rounded-full border transition-all duration-200 ${d?"bg-accent/20 border-accent/40 text-accent rotate-0":"border-accent/30 text-accent/60 hover:bg-accent/10 hover:border-accent/50 hover:text-accent"}`,title:d?"Cancel":"Add additional tools",children:d?e.jsx(Ht,{className:"w-3 h-3",strokeWidth:2}):e.jsx(Gt,{className:"w-3 h-3",strokeWidth:2})})]}),e.jsx("div",{className:"space-y-0.5",children:a.map(x=>e.jsxs("div",{children:[l&&e.jsx("p",{className:"px-3 pt-3 pb-1 text-[9px] font-semibold uppercase tracking-widest text-text-tertiary",children:x}),(m[x]||[]).map(c=>{const u=n===c.name;return e.jsxs("button",{onClick:()=>o(c.name),className:`w-full flex items-center gap-3 px-3 py-2 rounded-md transition-colors duration-150 ${u?"bg-surface-hover text-text-primary":"text-text-secondary hover:text-text-primary hover:bg-surface-hover"}`,children:[ra(r[c.name]),e.jsxs("div",{className:"min-w-0 text-left",children:[e.jsx("span",{className:"text-sm block truncate",children:c.name}),e.jsx("span",{className:"text-[10px] text-text-tertiary block truncate",children:c.description})]})]},c.name)})]},x))})]})}function ia({yamlId:t,planItem:a,lockedAppId:r,isSaved:n,onSaved:d,onNavigateDeploy:o}){const{data:s}=Ce(t),m=Fe(),[l,x]=p.useState(r||"longtail"),[c,u]=p.useState(""),[f,S]=p.useState(""),[i,b]=p.useState([]),[y,h]=p.useState(null),[j,w]=p.useState(!1);p.useEffect(()=>{if(s&&s.id!==y){x(r||s.app_id||"longtail");const _=oe(a.name);u(s.name!==_&&s.name?oe(s.name):_),S(s.description||a.description||""),b(s.tags||[]),h(s.id),w(!1)}},[s,a,r,y]),p.useEffect(()=>{r&&x(r)},[r]);const T=async()=>{if(!s)return;const _=Le(l),L=oe(c);let C=s.yaml_content||"";const g=C.match(/^\s*-?\s*subscribes:\s*(.+)$/m),I=g?g[1].trim():s.graph_topic;C=C.replace(/^(\s*id:\s*)(.+)$/m,`$1${_}`),C=C.replace(/^(\s*-?\s*subscribes:\s*)(.+)$/m,`$1${L}`),I&&(C=C.replace(new RegExp(`^(\\s*topic:\\s*)${I.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*$`,"gm"),`$1${L}`));const M=Math.random().toString(36).slice(2,6),W=[...C.matchAll(/^ {8}(\w+_[a-z0-9]{4}):\s*$/gm)].map($=>$[1]);for(const $ of W){const F=$.replace(/_[a-z0-9]{4}$/,`_${M}`);$!==F&&(C=C.replace(new RegExp($.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),F))}await m.mutateAsync({id:t,name:L,description:f,tags:i,app_id:_,graph_topic:L,yaml_content:C}),w(!1),d(_)};if(!s)return e.jsx("div",{className:"text-sm text-text-tertiary py-8 text-center",children:"Loading workflow..."});const v=n&&!j,k=!n||j,N=!!r;return e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-extralight tracking-wide text-accent/75 mb-1",children:"Profile"}),e.jsxs("p",{className:"text-base text-text-secondary mb-6",children:["Configure the MCP server and tool identity for ",e.jsx("span",{className:"font-medium text-text-primary",children:a.name}),"."]}),e.jsxs("div",{className:"grid grid-cols-[300px_1fr] gap-4 mb-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:"MCP Server Name"}),k&&!N?e.jsx("input",{value:l,onChange:_=>x(Le(_.target.value)),className:"w-full bg-surface-sunken border border-surface-border rounded-md px-3 py-1.5 text-xs font-mono text-text-primary focus:outline-none focus:ring-1 focus:ring-inset focus:ring-accent-primary",placeholder:"lowercase letters only"}):e.jsx("p",{className:"text-sm font-mono text-text-primary py-1.5",children:s.app_id||l}),N&&k&&e.jsx("p",{className:"text-[10px] text-text-tertiary mt-1",children:"Locked to match other workflows in this set."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:"MCP Tool Name"}),k?e.jsx("input",{value:c,onChange:_=>u(oe(_.target.value)),className:"w-full bg-surface-sunken border border-surface-border rounded-md px-3 py-1.5 text-xs font-mono text-text-primary focus:outline-none focus:ring-1 focus:ring-inset focus:ring-accent-primary",placeholder:"snake_case tool name (e.g. take_screenshot)"}):e.jsx("p",{className:"text-sm font-mono text-text-primary py-1.5",children:s.name||c})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:"Tags"}),k?e.jsx(Ee,{tags:i,onChange:b,compact:!0}):e.jsx("div",{className:"flex flex-wrap gap-1.5 py-1",children:(s.tags||i).map(_=>e.jsx("span",{className:"px-2 py-0.5 text-sm bg-surface-raised text-text-primary rounded",children:_},_))})]})]}),e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("label",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary",children:"Description"}),v&&e.jsxs("button",{onClick:()=>w(!0),className:"flex items-center gap-1 text-[10px] text-accent hover:text-accent/80 transition-colors",children:[e.jsx(Oe,{className:"w-3 h-3",strokeWidth:1.5}),"Edit"]})]}),k?e.jsx("textarea",{value:f,onChange:_=>S(_.target.value),className:"w-full flex-1 min-h-[100px] bg-surface-sunken border border-surface-border rounded-md px-3 py-1.5 text-xs font-mono text-text-primary resize-none focus:outline-none focus:ring-1 focus:ring-inset focus:ring-accent-primary"}):e.jsx("p",{className:"text-sm text-text-primary leading-relaxed py-1.5",children:s.description||f}),j&&e.jsxs("div",{className:"flex justify-end gap-2 mt-2",children:[e.jsx("button",{onClick:()=>w(!1),className:"text-[10px] text-text-tertiary hover:text-text-primary",children:"Cancel"}),e.jsx("button",{onClick:T,disabled:m.isPending,className:"text-[10px] text-accent hover:text-accent/80 font-medium",children:m.isPending?"Saving...":"Save Changes"})]})]})]}),m.isError&&e.jsx("p",{className:"text-xs text-status-error mb-4",children:m.error.message}),e.jsx("div",{className:"flex justify-end",children:v?e.jsx("button",{onClick:o,className:"btn-primary text-xs",children:"Next: Deploy"}):j?null:e.jsx("button",{onClick:T,disabled:m.isPending||!c.trim()||!l.trim(),className:"btn-primary text-xs disabled:opacity-50 disabled:cursor-not-allowed",children:m.isPending?"Saving...":"Save Profile"})})]})}function ca(t){switch(t){case"leaf":return"Leaf";case"composition":return"Composition";case"router":return"Router";default:return t}}function la({specification:t,description:a,plan:r,isPlanning:n,isFailed:d,onContinue:o}){return e.jsxs("div",{className:"space-y-6",children:[t&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:"Specification"}),e.jsx("div",{className:"rounded-md bg-surface-sunken/50 px-4 py-3",children:e.jsx("p",{className:"text-xs font-mono text-text-primary leading-relaxed whitespace-pre-wrap",children:t})})]}),n&&e.jsxs("div",{className:"flex items-center gap-3 py-4",children:[e.jsx(be,{className:"w-4 h-4 text-accent animate-spin"}),e.jsx("span",{className:"text-sm text-text-secondary",children:"Analyzing specification and generating plan..."})]}),d&&e.jsxs("div",{className:"flex items-center gap-3 p-4 rounded-lg border border-status-error/20 bg-status-error/5",children:[e.jsx(Nt,{className:"w-4 h-4 text-status-error"}),e.jsx("span",{className:"text-sm text-status-error",children:"Plan generation failed."})]}),r.length>0&&e.jsxs("div",{children:[a&&e.jsx("p",{className:"text-sm text-text-secondary mb-4 leading-relaxed",children:a}),e.jsxs("label",{className:"block text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-2",children:["Planned Workflows (",r.length,")"]}),e.jsx("div",{className:"space-y-2",children:r.map(s=>e.jsxs("div",{className:"px-3 py-2.5 rounded-md bg-surface-raised/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-medium text-text-primary",children:s.name}),e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-surface-sunken text-text-tertiary",children:ca(s.role)})]}),e.jsx("p",{className:"text-[11px] text-text-secondary mt-1",children:s.description}),s.dependencies.length>0&&e.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[e.jsx(Ve,{className:"w-2.5 h-2.5 text-text-tertiary"}),e.jsx("span",{className:"text-[10px] text-text-tertiary",children:s.dependencies.join(", ")})]})]},s.name))})]}),!n&&!d&&r.length>0&&e.jsx("button",{onClick:o,className:"px-4 py-2 bg-accent text-white text-xs font-medium rounded-md hover:bg-accent/90 transition-colors",children:"Continue to Profile"})]})}function oa({isOpen:t,addSubmitted:a,addSpec:r,setAddSpec:n,planCount:d,isPending:o,isError:s,errorMessage:m,onSubmit:l,onCancel:x,onDismiss:c}){return e.jsx("div",{className:"transition-all duration-300 ease-in-out grid",style:{gridTemplateRows:t?"1fr":"0fr",opacity:t?1:0,marginBottom:t?"24px":"0px"},children:e.jsx("div",{className:"overflow-hidden",children:e.jsx("div",{className:"rounded-lg border border-accent/20 bg-gradient-to-b from-accent/[0.04] to-transparent p-5",children:a?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-3 py-6 justify-center",children:[e.jsx(be,{className:"w-5 h-5 text-accent animate-spin",strokeWidth:1.5}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-text-primary",children:"Building new tools..."}),e.jsx("p",{className:"text-[11px] text-text-tertiary mt-0.5",children:"Watch the sidebar — new tools will appear as they're built."})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-[10px] text-text-tertiary",children:[d," tool",d===1?"":"s"," in set"]}),e.jsx("button",{onClick:c,className:"text-[10px] text-text-tertiary hover:text-text-primary transition-colors",children:"Dismiss"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm font-medium text-text-primary mb-1",children:"Expand this Toolset"}),e.jsx("p",{className:"text-[11px] text-text-tertiary mb-4",children:"Describe additional activities you would like to add."}),e.jsx("textarea",{value:r,onChange:u=>{n(u.target.value);const f=u.target;f.style.height="auto",f.style.height=`${Math.max(100,f.scrollHeight)}px`},placeholder:"What else should this set do?",className:"w-full min-h-[100px] px-3 py-2 bg-surface-sunken border border-surface-border rounded-md text-sm font-mono text-text-primary placeholder:text-text-tertiary/50 focus:outline-none focus:ring-1 focus:ring-inset focus:ring-accent-primary",style:{resize:"none",overflow:"hidden"}}),s&&e.jsx("p",{className:"text-xs text-status-error mt-2",children:m}),e.jsxs("div",{className:"flex items-center justify-between mt-3",children:[e.jsxs("span",{className:"text-[10px] text-text-tertiary",children:[d," tool",d===1?"":"s"," in set"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:x,className:"px-3 py-1.5 text-xs text-text-secondary hover:text-text-primary transition-colors",children:"Cancel"}),e.jsx("button",{onClick:l,disabled:!r.trim()||o,className:"btn-primary text-xs disabled:opacity-50 disabled:cursor-not-allowed",children:o?"Submitting...":"Add to Set"})]})]})]})})})})}const da=["Plan","Profile","Deploy","Test"];function xa(t){return t==="completed"?"completed":t==="failed"?"failed":t==="planning"||t==="building"||t==="deploying"?"in_progress":"pending"}function ma(){var D,Z,ce;const{workflowId:t}=Be(),[a,r]=fe(),n=pe();He(t),ms(t);const d=a.get("set_id")||void 0,{data:o}=St(t),s=(D=o==null?void 0:o.result)==null?void 0:D.data,m=d||(s==null?void 0:s.set_id),{data:l}=Bt(m),x=(l==null?void 0:l.plan)||[],c=(l==null?void 0:l.namespaces)||[],u=(l==null?void 0:l.status)||"planning",f=p.useMemo(()=>m?{set_id:m,limit:50}:{},[m]),{data:S}=Ue(f),i=(S==null?void 0:S.workflows)||[],b=p.useRef(u);p.useEffect(()=>{b.current!==u&&(b.current=u,n.invalidateQueries({queryKey:["yamlWorkflows"]}))},[u,n]);const y=p.useMemo(()=>{const A={},R=new Set;for(const K of x){const ee=i.find(Q=>!R.has(Q.id)&&(Q.name===K.name||Q.graph_topic===K.name));ee&&(A[K.name]=ee,R.add(ee.id))}if(Object.keys(A).length<x.length){const K=i.filter(Q=>!R.has(Q.id)).sort((Q,te)=>(Q.created_at||"").localeCompare(te.created_at||"")),ee=new Map;for(const Q of K){const te=Q.set_build_order??0;ee.has(te)||ee.set(te,[]),ee.get(te).push(Q)}for(const Q of x){if(A[Q.name])continue;const te=ee.get(Q.build_order);if(te!=null&&te.length){const ue=te.shift();A[Q.name]=ue,R.add(ue.id)}}}return A},[x,i]),h=p.useMemo(()=>{const A={};for(const[R,K]of Object.entries(y))A[R]=K.status;return A},[y]),j=p.useMemo(()=>{const A=i.find(R=>R.app_id&&R.app_id!=="longtail");return(A==null?void 0:A.app_id)||null},[i]),w=p.useMemo(()=>{const A=new Set;if(!j)return A;for(const[R,K]of Object.entries(y))K.app_id===j&&A.add(R);return A},[y,j]),T=w.size>0,v=a.get("workflow")||null,k=v&&((Z=y[v])==null?void 0:Z.id)||null,N=x.find(A=>A.name===v)||null,_=u==="planning",L=u==="failed",C=i.some(A=>A.status==="active");let g=1;x.length>0&&(g=2),T&&(g=3),C&&(g=4);const I=Number(a.get("step"))||0,M=I>=1&&I<=4?Math.min(I,g):1,W=i.length,$=x.length,F=i.filter(A=>A.status==="active").length,[se,J]=p.useState(!1),[ae,z]=p.useState(""),B=Ft(),[E,O]=p.useState(!1),Y=p.useRef(u);p.useEffect(()=>{E&&Y.current!=="completed"&&u==="completed"&&(O(!1),J(!1),z("")),Y.current=u},[u,E]);const H=A=>{const R={mode:"plan"};m&&(R.set_id=m),R.step=A.step??String(M),A.workflow!==void 0?A.workflow&&(R.workflow=A.workflow):v&&(R.workflow=v),r(R)},q=A=>{var K;if(A>g)return;const R=(K=x[0])==null?void 0:K.name;A>=2&&!v&&R?H({step:String(A),workflow:R}):H({step:String(A)})},G=A=>{H({workflow:A})},ie=()=>{n.invalidateQueries({queryKey:["yamlWorkflows"]}),n.invalidateQueries({queryKey:["yamlWorkflow"]})},de=()=>{H({step:"3"})},ne=async()=>{!m||!ae.trim()||(await B.mutateAsync({id:m,specification:ae.trim()}),O(!0))},X=()=>{J(!1),z("")},P=()=>{O(!1),J(!1),z("")};return e.jsxs("div",{className:"flex flex-col min-h-[calc(100vh-12rem)]",children:[e.jsx(Ie,{title:"MCP Tool Designer",actions:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-accent/10 text-accent font-medium",children:"Plan"}),$>0&&e.jsxs("span",{className:"text-[10px] text-text-tertiary",children:[W,"/",$," built",F>0&&` | ${F} deployed`]}),e.jsx(ye,{status:xa(u)})]})}),e.jsx(Xe,{labels:da,current:M,maxReachable:g,onStepClick:q}),e.jsxs("div",{className:"flex-1 mt-4",children:[M===1&&e.jsx(la,{specification:l==null?void 0:l.specification,description:l==null?void 0:l.description,plan:x,isPlanning:_,isFailed:L,onContinue:()=>q(2)}),M>=2&&e.jsxs("div",{className:"flex gap-6 max-h-[calc(100vh-220px)]",children:[e.jsx(na,{plan:x,namespaces:c,yamlStatuses:h,activeWorkflow:v,isAddOpen:se,onSelect:G,onAdd:()=>J(!se)}),e.jsxs("div",{className:"flex-1 min-w-0 overflow-y-auto",children:[e.jsx(oa,{isOpen:se,addSubmitted:E,addSpec:ae,setAddSpec:z,planCount:x.length,isPending:B.isPending,isError:B.isError,errorMessage:(ce=B.error)==null?void 0:ce.message,onSubmit:ne,onCancel:X,onDismiss:P}),v?k?M===2&&N?e.jsx(ia,{yamlId:k,planItem:N,lockedAppId:j,isSaved:w.has(v),onSaved:ie,onNavigateDeploy:de}):M===3?e.jsx(Ze,{yamlId:k,onAdvance:()=>q(4),onBack:()=>q(2)},k):M===4?e.jsx(et,{yamlId:k,originalWorkflowId:t,originalResult:void 0,originalPrompt:void 0,onBack:()=>q(3),onAdvance:()=>{},builderMode:!0},`test-${k}`):null:e.jsxs("div",{className:"flex items-center gap-3 py-12 justify-center",children:[e.jsx(be,{className:"w-4 h-4 text-accent animate-spin"}),e.jsxs("span",{className:"text-sm text-text-secondary",children:["Building ",v,"..."]})]}):e.jsx("p",{className:"text-sm text-text-tertiary py-12 text-center",children:"Select a pipeline tool from the sidebar."})]})]})]})]})}function pa(){const[t,a]=fe(),r=p.useRef(void 0);if(r.current===void 0){const l=t.get("step");r.current=l?parseInt(l,10):null}const n=p.useRef(r.current!==null),d=t.get("step"),o=n.current&&d?parseInt(d,10):null,s=p.useCallback(l=>{var x;n.current=l!==null,a(c=>{const u=new URLSearchParams(c);return l===null?u.delete("step"):u.set("step",String(l)),u},{replace:!1}),(x=window.scrollTo)==null||x.call(window,{top:0,behavior:"smooth"})},[a]),m=p.useCallback(l=>{a(x=>{const c=new URLSearchParams(x);return c.set("step",String(l)),c},{replace:!0})},[a]);return[o,s,m]}function ua(){var tt,st,at,rt,nt,it,ct,lt,ot;const{workflowId:t}=Be(),[a,r]=fe(),n=pe(),d=p.useRef(a.get("prompt"));p.useEffect(()=>{a.has("prompt")&&r(V=>{const we=new URLSearchParams(V);return we.delete("prompt"),we},{replace:!0})},[]);const[o,s]=p.useState("longtail"),[m,l]=p.useState(""),[x,c]=p.useState(""),[u,f]=p.useState([]),[S,i]=p.useState(!1),[b,y]=p.useState(""),{data:h}=$e(t),{data:j}=yt(t),{data:w}=Tt(t);He(t);const T=ds(),{data:v}=xs(),{data:k}=Ye(t??""),{data:N}=Ge(t??""),_=p.useMemo(()=>{if(!(N!=null&&N.envelope))return null;try{return typeof N.envelope=="string"?JSON.parse(N.envelope):N.envelope}catch{return null}},[N==null?void 0:N.envelope]),L=(tt=k==null?void 0:k.result)==null?void 0:tt.data,C=ys(h),g=(st=j==null?void 0:j.result)==null?void 0:st.data,I=(g==null?void 0:g.discovery)||{},M=(h==null?void 0:h.events)??[],{data:W}=It(t),$=(at=W==null?void 0:W.escalations)==null?void 0:at.find(V=>V.status==="pending"),F=(rt=W==null?void 0:W.escalations)==null?void 0:rt.find(V=>V.status==="resolved"),se=$||F,J=$t(),ae=Wt(),z=p.useMemo(()=>{if(!(F!=null&&F.resolver_payload))return null;try{return typeof F.resolver_payload=="string"?JSON.parse(F.resolver_payload):F.resolver_payload}catch{return null}},[F==null?void 0:F.resolver_payload]),B=(nt=z==null?void 0:z._lt)==null?void 0:nt.triageWorkflowId,{data:E}=Ye((it=z==null?void 0:z._lt)!=null&&it.triaged?B??"":""),O=(ct=E==null?void 0:E.result)==null?void 0:ct.data,Y=O==null?void 0:O.rerunWorkflowId,H=(lt=j==null?void 0:j.result)==null?void 0:lt.milestones,q=!!(g!=null&&g.rounds_exhausted)||!!(H!=null&&H.some(V=>V.name==="rounds_exhausted")),G=q||!!$,ie=p.useMemo(()=>{var we;const V=(we=_==null?void 0:_.data)==null?void 0:we.prompt;if(V)return V;if(d.current)return d.current;for(const _t of M){const Me=_t.attributes;if(Me.activity_type==="findCompiledWorkflows"&&Array.isArray(Me.input)&&typeof Me.input[0]=="string")return Me.input[0]}},[_,M]),de=p.useMemo(()=>(L==null?void 0:L.result)??(typeof(L==null?void 0:L.summary)=="string"?Se(L.summary):null)??(g==null?void 0:g.result)??(typeof(g==null?void 0:g.summary)=="string"?Se(g.summary):null)??null,[L,g]),ne=ie||(g==null?void 0:g.title),{data:X}=At({prompt:C==="completed"?ne:void 0,resultTitle:g==null?void 0:g.title,resultSummary:g==null?void 0:g.summary}),P=(ot=w==null?void 0:w.workflows)==null?void 0:ot.find(V=>V.status==="active"||V.status==="deployed"||V.status==="draft"),D=p.useMemo(()=>C==="pending"?1:C==="in_progress"?2:g?P?P.status==="draft"||P.status==="deployed"?4:5:2:1,[C,g,P]),[Z,ce,A]=pa(),R=Z??D;p.useEffect(()=>{A(R)},[R,A]);const K=C==="pending"?1:C==="in_progress"||!g||G?2:P?P.status==="draft"?4:P.status==="deployed"?5:6:3,ee=p.useRef(C);p.useEffect(()=>{ee.current==="in_progress"&&C==="completed"&&Z===null&&ce(3),ee.current=C},[C,Z,ce]);const Q=p.useMemo(()=>{const V=[...bs];return(P==null?void 0:P.status)==="active"&&(V[3]="Redeploy"),V},[P==null?void 0:P.status]);X&&!S&&(i(!0),x||c(X.description),u.length===0&&X.tags.length>0&&f(X.tags),!m&&X.tool_name&&l(oe(X.tool_name)));const te=oe(m),ue=p.useMemo(()=>(v==null?void 0:v.app_ids)??[],[v==null?void 0:v.app_ids]),Pe=async()=>{!t||!m.trim()||!o.trim()||(await T.mutateAsync({workflow_id:t,task_queue:"long-tail-system",workflow_name:"mcpQuery",name:m.trim(),description:x.trim()||void 0,app_id:o.trim(),subscribes:te,tags:u,compilation_feedback:b.trim()||void 0}),n.invalidateQueries({queryKey:["yamlWorkflowForSource"],refetchType:"all"}),ce(4))},re=async()=>{if(!$)return;await J.mutateAsync({id:$.id,durationMinutes:30});const V=(g==null?void 0:g.diagnosis)||$.description||"";await ae.mutateAsync({id:$.id,resolverPayload:{_lt:{needsTriage:!0},notes:V}})},xe=(P==null?void 0:P.status)==="active"?5:4;return{workflowId:t,execution:h,status:C,result:g,discovery:I,events:M,originalEnvelope:_,originalPrompt:ie,originalOutput:de,originalExecution:k,compiledYaml:P,step:R,maxReachable:K,stepLabels:Q,setManualStep:ce,compileAppId:o,setCompileAppId:s,compileName:m,setCompileName:l,compileDescription:x,setCompileDescription:c,compileTags:u,setCompileTags:f,compileFeedback:b,setCompileFeedback:y,describeData:X,describePrompt:ne,allAppIds:ue,handleCompile:Pe,createYaml:T,isUncompilable:G,isRoundsExhausted:q,displayEscalation:se,activeEscalation:$,handleRetryTriage:re,claimMutation:J,resolveMutation:ae,rerunWorkflowId:Y,profileNextStep:xe}}function ha({workflowId:t,status:a,discovery:r,execution:n,result:d}){return e.jsx("div",{className:"bg-surface-raised border border-surface-border rounded-md px-6 py-4 mb-6",children:e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-y-3 gap-x-8",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-0.5",children:"Run ID"}),e.jsx(vs,{label:"",value:t??null,href:`/workflows/executions/${t}`})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-0.5",children:"Duration"}),e.jsx("p",{className:"text-xs text-text-primary font-mono",children:(n==null?void 0:n.duration_ms)!=null?`${(n.duration_ms/1e3).toFixed(1)}s`:"—"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-0.5",children:"Started"}),e.jsx("p",{className:"text-xs text-text-primary",children:n!=null&&n.start_time?e.jsx(Ns,{date:n.start_time}):"—"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-0.5",children:"Tool Calls"}),e.jsx("p",{className:"text-xs text-text-primary",children:typeof(d==null?void 0:d.tool_calls_made)=="number"?d.tool_calls_made:"—"})]})]})})}function _e({title:t,subtitle:a,actions:r}){return e.jsxs("div",{className:"flex items-start justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-extralight tracking-wide text-accent/75 mb-1",children:t}),a&&e.jsx("p",{className:"text-base text-text-secondary",children:a})]}),r&&e.jsx("div",{className:"flex items-center gap-3 shrink-0",children:r})]})}function fa({status:t,originalEnvelope:a,originalPrompt:r,originalOutput:n,originalDurationMs:d,resultSummary:o,onNext:s}){return e.jsxs("div",{children:[e.jsx(_e,{title:"Describe",subtitle:"Dynamic LLM-orchestrated execution — the discovery run",icon:ve,iconClass:"text-accent"}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-2",children:"Input"}),a?e.jsx(U,{data:a,defaultMode:"tree"}):r?e.jsx(U,{data:{prompt:r},defaultMode:"tree"}):e.jsx("p",{className:"text-xs text-text-tertiary italic",children:"Loading..."})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-2",children:"Output"}),t!=="completed"&&t!=="failed"?e.jsx("p",{className:"text-sm text-text-secondary animate-pulse",children:"Pending..."}):n?e.jsx(U,{data:n,defaultMode:"tree"}):o?e.jsx(U,{data:{summary:o},defaultMode:"tree"}):e.jsx("p",{className:"text-xs text-text-tertiary italic",children:"No structured output"}),d!=null&&e.jsxs("p",{className:"text-[10px] text-text-tertiary mt-2",children:[(d/1e3).toFixed(1),"s"]})]})]}),e.jsxs(le,{children:[e.jsx("span",{}),e.jsx("button",{onClick:s,disabled:!s,className:"btn-primary text-xs",children:"Next: Timeline"})]})]})}function ga({events:t,onBack:a,onNext:r}){return e.jsxs("div",{children:[e.jsx(_e,{title:"Discover",subtitle:"Activity swimlane showing tool calls and their durations",icon:vt,iconClass:"text-status-warning"}),e.jsx(ws,{events:t}),e.jsxs(le,{children:[e.jsx("button",{onClick:a,className:"px-3 py-1.5 text-xs text-text-secondary hover:text-text-primary",children:"Back"}),e.jsx("button",{onClick:r,disabled:!r,className:"btn-primary text-xs",children:"Next: Compile"})]})]})}function ya({compiledYaml:t,onBack:a,onNext:r}){var S;const n=pe(),d=Fe(),[o,s]=p.useState(!1),[m,l]=p.useState(t.description||""),[x,c]=p.useState(t.tags||[]),u=async()=>{await d.mutateAsync({id:t.id,description:m.trim(),tags:x}),n.invalidateQueries({queryKey:["yamlWorkflowForSource"],refetchType:"all"}),s(!1)},f=()=>{l(t.description||""),c(t.tags||[]),s(!1)};return e.jsxs("div",{children:[e.jsx(_e,{title:"Compile",subtitle:"Compiled deterministic pipeline — name, tags, and deployment target",icon:Ne,iconClass:"text-status-success",actions:o?e.jsxs(e.Fragment,{children:[e.jsx(me,{icon:Re,label:"Cancel",onClick:f}),e.jsx(me,{icon:Ae,label:d.isPending?"Saving...":"Save",onClick:u,disabled:d.isPending})]}):e.jsx(me,{icon:Oe,label:"Edit Profile",onClick:()=>s(!0)})}),e.jsxs("div",{className:"flex gap-6 mb-6",children:[e.jsxs("div",{className:"w-[30%] shrink-0 space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-0.5",children:"Namespace"}),e.jsx("p",{className:"text-sm text-text-primary",children:t.app_id||"—"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-0.5",children:"Tool Name"}),e.jsx("p",{className:"text-sm text-text-primary",children:t.name})]})]}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:"Description"}),o?e.jsx("textarea",{value:m,onChange:i=>l(i.target.value),className:"w-full min-h-[80px] px-3 py-2 bg-surface-sunken border border-surface-border rounded-md text-sm text-text-primary placeholder:text-text-tertiary resize-y focus:outline-none focus:ring-1 focus:ring-inset focus:ring-accent-primary"}):e.jsx("p",{className:"text-sm text-text-secondary leading-relaxed",children:t.description||"—"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:"Tags"}),o?e.jsx(Ee,{tags:x,onChange:c,placeholder:"Add tags..."}):e.jsx("div",{className:"flex gap-1.5 flex-wrap",children:(t.tags||[]).length>0?t.tags.map(i=>e.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-surface-sunken text-text-secondary",children:i},i)):e.jsx("span",{className:"text-[10px] text-text-tertiary",children:"No tags"})})]}),((S=t.activity_manifest)==null?void 0:S.length)>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:"Pipeline"}),e.jsx("div",{className:"flex items-center gap-1 flex-wrap",children:t.activity_manifest.filter(i=>i.tool_source!=="trigger").map((i,b,y)=>e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded bg-surface-sunken font-mono text-text-primary",children:i.mcp_tool_name||i.title}),b<y.length-1&&e.jsx("span",{className:"text-text-tertiary text-[10px]",children:"→"})]},b))})]})]})]}),e.jsxs(le,{children:[e.jsx("button",{onClick:a,className:"px-3 py-1.5 text-xs text-text-secondary hover:text-text-primary",children:"Back"}),t.status!=="active"?e.jsx("button",{onClick:r,className:"btn-primary text-xs",children:"Next: Deploy"}):e.jsx("button",{onClick:r,className:"btn-primary text-xs",children:"Next: Test"})]})]})}function ba({originalPrompt:t,compileAppId:a,setCompileAppId:r,compileName:n,setCompileName:d,compileDescription:o,setCompileDescription:s,compileTags:m,setCompileTags:l,describeData:x,describePrompt:c,allAppIds:u,onCompile:f,isCompiling:S,compileError:i,onBack:b}){const[y,h]=p.useState(null),[j,w]=p.useState(!1),T=p.useRef(null),v=i&&i!==y?i:null;p.useEffect(()=>{v&&T.current&&T.current.scrollIntoView({behavior:"smooth",block:"nearest"})},[v]),p.useEffect(()=>{i&&i!==y&&(h(null),w(!1))},[i]);const k=()=>{w(!0),setTimeout(()=>{h(i),w(!1)},250)};return e.jsxs("div",{children:[e.jsx(_e,{title:"Compile",subtitle:"Define the deterministic workflow tool from this execution",icon:Ne,iconClass:"text-status-success"}),v&&e.jsxs("div",{ref:T,className:"mb-6 rounded-lg border border-status-error/30 bg-status-error/[0.04] px-4 py-3 flex items-start gap-3 overflow-hidden transition-all duration-250 ease-in-out",style:{animation:j?void 0:"fadeIn 300ms ease-out both",opacity:j?0:1,maxHeight:j?"0px":"200px",paddingTop:j?"0px":void 0,paddingBottom:j?"0px":void 0,marginBottom:j?"0px":void 0},children:[e.jsx(Nt,{className:"w-4 h-4 text-status-error shrink-0 mt-0.5",strokeWidth:1.5}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-status-error",children:"Compilation failed"}),e.jsx("p",{className:"text-xs text-text-secondary mt-0.5 leading-relaxed",children:v})]}),e.jsx("button",{onClick:k,className:"text-text-tertiary hover:text-text-secondary transition-colors shrink-0 mt-0.5",children:e.jsx(Re,{className:"w-3.5 h-3.5"})})]}),t&&e.jsxs("div",{className:"mb-6",children:[e.jsx(je,{children:"Original Query"}),e.jsx("p",{className:"text-xs font-mono text-text-primary leading-relaxed bg-surface-sunken rounded-md px-3 py-2",children:t})]}),e.jsx(je,{children:"Workflow Configuration"}),e.jsxs("div",{className:"flex gap-6",children:[e.jsxs("div",{className:"w-[30%] shrink-0 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:"Namespace *"}),e.jsx("input",{type:"text",value:a,onChange:N=>r(Le(N.target.value)),className:"input",placeholder:"e.g. longtail"}),u.length>0&&e.jsx("div",{className:"flex gap-1.5 mt-1.5 flex-wrap",children:u.map(N=>e.jsx("button",{type:"button",onClick:()=>r(N),className:`text-[10px] px-2 py-0.5 rounded-full transition-colors ${a===N?"bg-accent/20 text-accent":"bg-surface-sunken text-text-tertiary hover:text-text-secondary"}`,children:N},N))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:"Tool Name *"}),e.jsx("input",{type:"text",value:n,onChange:N=>d(oe(N.target.value)),className:"input",placeholder:"e.g. auth_screenshot_all_nav_pages"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:"Tags"}),e.jsx(Ee,{tags:m,onChange:l,placeholder:"e.g. browser, screenshots, login"}),e.jsx("p",{className:"text-[10px] text-text-tertiary mt-1",children:"Press Enter or comma to add."})]})]}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("label",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary",children:"Description"}),!o&&!x&&c&&e.jsx("span",{className:"text-[10px] text-accent animate-pulse",children:"Generating..."})]}),e.jsx("textarea",{value:o,onChange:N=>s(N.target.value),placeholder:"Describe what this workflow does as a reusable tool...",className:"flex-1 min-h-[120px] w-full px-3 py-2 bg-surface-sunken border border-surface-border rounded-md text-sm text-text-primary placeholder:text-text-tertiary resize-y focus:outline-none focus:ring-1 focus:ring-inset focus:ring-accent-primary"}),e.jsx("p",{className:"text-[10px] text-text-tertiary mt-1",children:x?"AI-generated. Edit to refine.":"Describe what this workflow does so future queries can find it."})]})]}),e.jsxs(le,{children:[e.jsx("button",{onClick:b,className:"px-3 py-1.5 text-xs text-text-secondary hover:text-text-primary",children:"Back"}),e.jsx("button",{onClick:f,disabled:!n.trim()||!a.trim()||S,className:"btn-primary text-xs",children:S?"Compiling...":"Compile Pipeline"})]})]})}function ja(t){const{compiledYaml:a,isUncompilable:r,onBack:n,onNext:d}=t;return r&&!a?e.jsxs("div",{children:[e.jsx(_e,{title:"Compile",subtitle:"Define the deterministic workflow tool from this execution",icon:Ne,iconClass:"text-status-success"}),e.jsxs("div",{className:"rounded-md bg-status-warning/5 border border-status-warning/20 px-4 py-3 mb-6",children:[e.jsx("p",{className:"text-xs text-status-warning font-medium",children:"Cannot compile this query"}),e.jsx("p",{className:"text-xs text-text-secondary mt-1",children:"This query did not complete successfully. Resolve the escalation before compiling to a deterministic workflow."})]}),e.jsxs(le,{children:[e.jsx("button",{onClick:n,className:"px-3 py-1.5 text-xs text-text-secondary hover:text-text-primary",children:"Back"}),e.jsx("span",{})]})]}):a?e.jsx(ya,{compiledYaml:a,onBack:n,onNext:d}):e.jsx(ba,{originalPrompt:t.originalPrompt,compileAppId:t.compileAppId,setCompileAppId:t.setCompileAppId,compileName:t.compileName,setCompileName:t.setCompileName,compileDescription:t.compileDescription,setCompileDescription:t.setCompileDescription,compileTags:t.compileTags,setCompileTags:t.setCompileTags,describeData:t.describeData,describePrompt:t.describePrompt,allAppIds:t.allAppIds,onCompile:t.onCompile,isCompiling:t.isCompiling,compileError:t.compileError,onBack:n})}const ft=["Discover","Evaluate","Execute"];function va(t){if(!(t!=null&&t.length))return{step:0,label:"Starting...",detail:"Initializing query router",path:null};const a=t.find(n=>n.event_type==="child_workflow_execution_started");if(a){const n=a.attributes.child_workflow_id??"",d=n.includes("mcpDeterministic");return t.some(s=>s.event_type==="child_workflow_execution_completed")?{step:3,label:d?"Deterministic complete":"Dynamic complete",detail:d?"Compiled workflow executed successfully":"Dynamic MCP orchestration completed",path:d?"deterministic":"dynamic",childWorkflowId:n}:{step:3,label:d?"Running deterministic workflow":"Running dynamic MCP query",detail:d?"Executing compiled workflow":"LLM agentic orchestration in progress (30–60s)",path:d?"deterministic":"dynamic",childWorkflowId:n}}const r=t.filter(n=>n.category==="activity").map(n=>n.attributes.activity_type??"");return r.some(n=>n==="extractWorkflowInputs")?{step:2,label:"Extracting inputs...",detail:"Preparing structured inputs for compiled workflow",path:null}:r.some(n=>n==="evaluateWorkflowMatch")?{step:2,label:"Evaluating match...",detail:"LLM judge determining best compiled workflow",path:null}:r.some(n=>n==="findCompiledWorkflows")?{step:1,label:"Searching compiled workflows...",detail:"Full-text + tag discovery of candidates",path:null}:{step:0,label:"Starting...",detail:"Initializing query router",path:null}}function Na({events:t,status:a,verifyRunId:r}){const n=va(t),d=a==="completed"||a==="failed";return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center gap-1",children:ft.map((o,s)=>{const m=s+1,l=n.step>m||d,x=n.step===m&&!d;return e.jsxs("div",{className:"flex items-center gap-1 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[e.jsx("div",{className:`w-5 h-5 rounded-full flex items-center justify-center text-[9px] font-medium shrink-0 transition-colors ${l?"bg-status-success/20 text-status-success":x?"bg-accent/20 text-accent animate-pulse":"bg-surface-sunken text-text-tertiary"}`,children:l?e.jsx("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):m}),e.jsx("span",{className:`text-[10px] font-medium whitespace-nowrap ${l?"text-text-secondary":x?"text-text-primary":"text-text-tertiary"}`,children:o})]}),s<ft.length-1&&e.jsx("div",{className:`h-px flex-1 min-w-4 ${l?"bg-status-success/30":"bg-surface-border"}`})]},o)})}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("p",{className:"text-xs text-text-secondary",children:n.detail}),n.path==="deterministic"&&e.jsx("span",{className:"text-[10px] bg-status-success/10 text-status-success px-2 py-0.5 rounded-full",children:"Deterministic"}),n.path==="dynamic"&&e.jsx("span",{className:"text-[10px] bg-status-pending/10 text-status-pending px-2 py-0.5 rounded-full",children:"Dynamic"})]}),r&&n.step>=1&&e.jsx(ke,{to:`/workflows/executions/${r}`,className:"text-[10px] text-accent hover:underline",children:"View execution tree"})]})}function wa({originalWorkflowId:t,originalPrompt:a,workflowName:r,onBack:n,onGoToDeploy:d}){var L,C;const o=gt(),[s,m]=fe(),[l,x]=p.useState(""),[c,u]=p.useState(!1),f=s.get("verifyRun"),S=g=>{m(I=>{const M=new URLSearchParams(I);return g?M.set("verifyRun",g):M.delete("verifyRun"),M},{replace:!0})},{data:i}=Ge(t??""),b=p.useMemo(()=>{if(!(i!=null&&i.envelope))return null;try{return typeof i.envelope=="string"?JSON.parse(i.envelope):i.envelope}catch{return null}},[i==null?void 0:i.envelope]),y=((L=b==null?void 0:b.data)==null?void 0:L.prompt)??a;y&&!c&&(u(!0),x(y));const{data:h}=$e(f??void 0),{data:j}=yt((h==null?void 0:h.status)==="completed"?f??void 0:void 0),w=h==null?void 0:h.status,T=((C=j==null?void 0:j.result)==null?void 0:C.data)??{},v=T.discovery,k=(v==null?void 0:v.method)==="compiled-workflow",N=f&&w!=="completed"&&w!=="failed",_=async()=>{if(!l.trim())return;const g=await o.mutateAsync({prompt:l.trim()});S(g.workflow_id)};return e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-extralight tracking-wide text-accent/75 mb-1",children:"Verify"}),e.jsxs("p",{className:"text-base text-text-secondary mb-6",children:["Submit the original prompt through the router to verify that",e.jsx("span",{className:"font-mono text-text-primary mx-1",children:r}),"is selected and handles it deterministically."]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8 mb-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:"Query Prompt"}),e.jsx("p",{className:"text-[10px] text-text-tertiary",children:l!==y&&y?e.jsx("button",{onClick:()=>x(y),className:"text-accent hover:underline",children:"Reset to original"}):"Edit and submit to verify"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:"Result"}),!f&&e.jsx("p",{className:"text-[10px] text-text-tertiary italic",children:"Awaiting submission"}),N&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ye,{status:"in_progress"}),e.jsx("span",{className:"text-[10px] text-text-secondary animate-pulse",children:"Routing..."})]}),w==="failed"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ye,{status:"failed"}),e.jsx("span",{className:"text-[10px] text-status-error",children:"Failed"})]}),w==="completed"&&e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(ye,{status:"completed"}),k?e.jsxs("span",{className:"text-[10px] bg-status-success/10 text-status-success px-2 py-0.5 rounded-full",children:["Deterministic (",((v==null?void 0:v.confidence)*100).toFixed(0),"%)"]}):e.jsx("span",{className:"text-[10px] bg-status-pending/10 text-status-pending px-2 py-0.5 rounded-full",children:"Dynamic (no match)"}),(h==null?void 0:h.duration_ms)!=null&&e.jsxs("span",{className:"text-[10px] text-text-tertiary",children:[(h.duration_ms/1e3).toFixed(1),"s"]})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[e.jsxs("div",{children:[e.jsx("textarea",{value:l,onChange:g=>x(g.target.value),className:"w-full min-h-[160px] px-3 py-2 bg-surface-sunken border border-surface-border rounded-md text-sm text-text-primary placeholder:text-text-tertiary resize-y focus:outline-none focus:ring-1 focus:ring-inset focus:ring-accent-primary",placeholder:"Type a natural language query..."}),e.jsx("div",{className:"flex justify-end mt-2",children:e.jsxs("button",{onClick:_,disabled:!l.trim()||o.isPending||!!N,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium bg-accent/10 text-accent rounded-md hover:bg-accent/20 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 12 12",fill:"currentColor",children:e.jsx("path",{d:"M3 1.5v9l7.5-4.5z"})}),o.isPending?"Starting...":N?"Running...":f?"Resubmit":"Submit"]})})]}),e.jsxs("div",{children:[!f&&e.jsx("div",{className:"flex items-center justify-center min-h-[160px] text-xs text-text-tertiary italic",children:"Submit a query to see the result"}),N&&e.jsx("div",{className:"min-h-[160px] flex items-start pt-4",children:e.jsx(Na,{events:h==null?void 0:h.events,status:w,verifyRunId:f})}),w==="completed"&&e.jsxs("div",{className:"space-y-3",children:[typeof T.title=="string"&&e.jsx("p",{className:"text-sm text-text-primary",children:T.title}),T.result!=null&&e.jsx(U,{data:T.result,defaultMode:"tree"}),e.jsxs("div",{className:"flex items-center gap-3 pt-1",children:[e.jsx(ke,{to:`/mcp/queries/${f}`,className:"text-[10px] text-accent hover:underline",children:"View full details"}),e.jsx("button",{onClick:()=>S(null),className:"text-[10px] text-text-tertiary hover:text-text-primary",children:"Clear"})]})]}),w==="failed"&&e.jsx("p",{className:"text-xs text-status-error py-4",children:"Query failed. Try modifying the prompt."})]})]}),e.jsxs(le,{children:[e.jsx("button",{onClick:n,className:"px-3 py-1.5 text-xs text-text-secondary hover:text-text-primary",children:"Back"}),e.jsx("span",{className:"text-[10px] text-text-tertiary",children:"End-to-end verification — modify the prompt and submit to test the full pipeline"})]})]})}function ka({escalation:t,isRoundsExhausted:a,diagnosis:r,onRetryTriage:n,isRetrying:d,rerunWorkflowId:o}){var S;const s=Ke();if(!t&&!a)return null;const m=(t==null?void 0:t.status)==="pending",l=(t==null?void 0:t.status)==="resolved",x=(()=>{if(!(t!=null&&t.resolver_payload))return null;try{return typeof t.resolver_payload=="string"?JSON.parse(t.resolver_payload):t.resolver_payload}catch{return null}})(),c=((S=x==null?void 0:x._lt)==null?void 0:S.triaged)===!0,u=(()=>{if(!(t!=null&&t.escalation_payload))return null;try{return typeof t.escalation_payload=="string"?JSON.parse(t.escalation_payload):t.escalation_payload}catch{return null}})(),f=u==null?void 0:u.diagnosis;return l&&c?e.jsxs("div",{className:"rounded-md mb-4 border border-status-success/30 bg-surface-raised overflow-hidden",children:[e.jsx("div",{className:"px-4 pt-3 pb-2",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("svg",{className:"w-4 h-4 mt-0.5 shrink-0 text-status-success",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M8 1a7 7 0 110 14A7 7 0 018 1zm3.36 4.65a.5.5 0 00-.72 0L7 9.29 5.36 7.65a.5.5 0 10-.72.7l2 2a.5.5 0 00.72 0l4-4a.5.5 0 000-.7z"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-status-success",children:o?"This query succeeded after AI triage":"AI triage resolved this query"}),e.jsx("p",{className:"text-xs text-text-secondary mt-1.5 leading-relaxed",children:o?"The original run hit a wall, but AI triage diagnosed the issue and re-ran the query successfully. The successful run is ready to compile into a deterministic workflow.":"The original run hit a wall. AI triage diagnosed the issue and resolved it."})]})]})}),f&&e.jsxs("div",{className:"px-4 py-2 mx-4 mb-2 rounded bg-surface-sunken",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-1",children:"What went wrong"}),e.jsx("p",{className:"text-xs text-text-secondary leading-relaxed line-clamp-2",children:f})]}),e.jsx("div",{className:"px-4 py-3 border-t border-surface-border bg-surface-sunken/50",children:e.jsxs("div",{className:"flex items-center gap-3",children:[o&&e.jsxs("button",{onClick:()=>s(`/mcp/queries/${o}`),className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium bg-accent text-text-inverse rounded-md hover:bg-accent/90 transition-colors",children:["Continue to successful run",e.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 12 12",fill:"currentColor",children:e.jsx("path",{d:"M4.5 2l4 4-4 4"})})]}),e.jsx("button",{onClick:()=>s("/mcp/queries"),className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-text-secondary border border-surface-border rounded-md hover:bg-surface-sunken transition-colors",children:"Start fresh"}),e.jsx(ke,{to:`/escalations/detail/${t.id}`,className:"text-[10px] text-text-tertiary hover:text-accent hover:underline ml-auto",children:"Details"})]})})]}):l?e.jsx("div",{className:"rounded-md px-4 py-3 mb-4 border bg-surface-raised border-status-success/30",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("svg",{className:"w-4 h-4 mt-0.5 shrink-0 text-status-success",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M8 1a7 7 0 110 14A7 7 0 018 1zm3.36 4.65a.5.5 0 00-.72 0L7 9.29 5.36 7.65a.5.5 0 10-.72.7l2 2a.5.5 0 00.72 0l4-4a.5.5 0 000-.7z"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-status-success",children:"Escalation resolved"}),e.jsx("p",{className:"text-xs text-text-tertiary mt-1",children:"This escalation was resolved manually. You can continue to compile."}),e.jsx("div",{className:"flex items-center gap-3 mt-2",children:t&&e.jsx(ke,{to:`/escalations/detail/${t.id}`,className:"text-[10px] text-accent hover:underline",children:"View escalation"})})]})]})}):e.jsx("div",{className:"rounded-md px-4 py-3 mb-4 border bg-surface-raised border-status-warning/30",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("svg",{className:"w-4 h-4 mt-0.5 shrink-0 text-status-warning",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M8 1a7 7 0 110 14A7 7 0 018 1zm0 3a.75.75 0 00-.75.75v3.5a.75.75 0 001.5 0v-3.5A.75.75 0 008 4zm0 7a.75.75 0 100-1.5.75.75 0 000 1.5z"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-status-warning",children:a?"This query exceeded the maximum tool rounds":"This query has a pending escalation"}),r&&e.jsx("p",{className:"text-xs text-text-secondary mt-1 line-clamp-2",children:r}),e.jsxs("div",{className:"flex items-center gap-3 mt-2",children:[m&&n&&e.jsxs("button",{onClick:n,disabled:d,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium bg-accent text-text-inverse rounded-md hover:bg-accent/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:[e.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 12 12",fill:"currentColor",children:e.jsx("path",{d:"M6 0.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zm2 6l-3 1.75v-3.5l3 1.75z"})}),d?"Sending...":"Retry with AI Triage"]}),t&&e.jsx(ke,{to:`/escalations/detail/${t.id}`,className:"text-[10px] text-accent hover:underline",children:"View escalation"})]})]})]})})}function Ka(){const{workflowId:t}=Be(),[a]=fe();return t==="new"?e.jsx(Ms,{}):a.get("mode")==="plan"?e.jsx(ma,{}):a.get("mode")==="builder"?e.jsx(aa,{}):e.jsx(Sa,{})}function Sa(){var a,r,n,d;const t=ua();return e.jsxs("div",{className:"flex flex-col min-h-[calc(100vh-12rem)]",children:[e.jsx(Ie,{title:"MCP Tool Compiler",actions:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(ye,{status:t.status}),((a=t.discovery)==null?void 0:a.method)==="compiled-workflow"&&e.jsxs("span",{className:"text-xs bg-status-success/10 text-status-success px-2 py-0.5 rounded-full",children:["Deterministic (",(t.discovery.confidence*100).toFixed(0),"% match)"]})]})}),e.jsx(ha,{workflowId:t.workflowId,status:t.status,discovery:t.discovery,execution:t.execution,result:t.result}),e.jsx(ka,{escalation:t.displayEscalation,isRoundsExhausted:t.isRoundsExhausted,diagnosis:(r=t.result)==null?void 0:r.diagnosis,onRetryTriage:t.activeEscalation?t.handleRetryTriage:void 0,isRetrying:t.claimMutation.isPending||t.resolveMutation.isPending,rerunWorkflowId:t.rerunWorkflowId}),e.jsx(Xe,{labels:t.stepLabels,current:t.step,maxReachable:t.maxReachable,onStepClick:o=>t.setManualStep(o)}),e.jsxs("div",{className:"flex-1",children:[t.step===1&&e.jsx(fa,{status:t.status,originalEnvelope:t.originalEnvelope,originalPrompt:t.originalPrompt,originalOutput:t.originalOutput,originalDurationMs:(n=t.originalExecution)==null?void 0:n.duration_ms,resultSummary:(d=t.result)==null?void 0:d.summary,onNext:t.maxReachable>=2?()=>t.setManualStep(2):void 0}),t.step===2&&e.jsx(ga,{events:t.events,onBack:()=>t.setManualStep(1),onNext:t.maxReachable>=3?()=>t.setManualStep(3):void 0}),t.step===3&&e.jsx(ja,{compiledYaml:t.compiledYaml,originalPrompt:t.originalPrompt,compileAppId:t.compileAppId,setCompileAppId:t.setCompileAppId,compileName:t.compileName,setCompileName:t.setCompileName,compileDescription:t.compileDescription,setCompileDescription:t.setCompileDescription,compileTags:t.compileTags,setCompileTags:t.setCompileTags,describeData:t.describeData,describePrompt:t.describePrompt,allAppIds:t.allAppIds,onCompile:t.handleCompile,isCompiling:t.createYaml.isPending,compileError:t.createYaml.isError?t.createYaml.error.message:void 0,isUncompilable:t.isUncompilable,onBack:()=>t.setManualStep(2),onNext:()=>t.setManualStep(t.profileNextStep)}),t.step===4&&t.compiledYaml&&e.jsx(Ze,{yamlId:t.compiledYaml.id,onAdvance:()=>t.setManualStep(5),onBack:()=>t.setManualStep(3)}),t.step===5&&t.compiledYaml&&e.jsx(et,{yamlId:t.compiledYaml.id,originalWorkflowId:t.workflowId,originalResult:t.result,originalPrompt:t.originalPrompt,onBack:()=>t.setManualStep(4),onAdvance:()=>t.setManualStep(6)}),t.step===6&&t.compiledYaml&&e.jsx(wa,{originalWorkflowId:t.workflowId,originalPrompt:t.originalPrompt,workflowName:t.compiledYaml.name,onBack:()=>t.setManualStep(5),onGoToDeploy:()=>t.setManualStep(4)})]})]})}export{Ka as McpQueryDetailPage};
5
- //# sourceMappingURL=McpQueryDetailPage-ieZPpcPn.js.map
@@ -1,2 +0,0 @@
1
- import{j as e}from"./vendor-query-B2UbickB.js";import{P as j}from"./PageHeader-DLjHNYHX.js";import{D as _}from"./DataTable-D9yuBv0w.js";import{F as v,b as f}from"./FilterBar-Ck4K4rzu.js";import{S as N}from"./StickyPagination-F9FZsRy9.js";import{L as P}from"./ListToolbar-DuON-br0.js";import{T as h}from"./TimestampCell-Dgpl-lKv.js";import{E as C}from"./ElapsedCell-DKoH0bqR.js";import{W as $}from"./WorkflowPill-BbgVTGgI.js";import{E as W}from"./EmptyState-BcsfPq9T.js";import{R as c}from"./RowActions-Dg-Fsm5O.js";import{u as S}from"./useFilterParams-DZCAaBC7.js";import{b as q}from"./useEventHooks-BccPxFR6.js";import{u as T}from"./mcp-query-Dm7_m5Fi.js";import{W as y,r as D,s as g,t as k,S as B,u as F}from"./vendor-icons-E6836lXZ.js";import{c as L}from"./vendor-react-CX88sFS5.js";import"./index-BMIU7Im5.js";const M={in_progress:"bg-status-active",completed:"bg-status-success",failed:"bg-status-error"};function p(s){return s.status==="completed"||Number(s.status)===0?"completed":s.is_live?"in_progress":"failed"}function E(s){return[{key:"workflow_id",label:"Workflow ID / Type",render:t=>{const a=p(t),o=M[a]??"bg-status-pending",l=a==="in_progress"?" animate-pulse":"";return e.jsxs("div",{className:"flex items-start gap-2 min-w-0",children:[e.jsx("span",{className:`w-[9px] h-[9px] shrink-0 rounded-full mt-1 ${o}${l}`,title:a}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"font-mono text-xs text-text-primary truncate block",children:t.workflow_id}),e.jsx("div",{className:"mt-0.5",children:e.jsx($,{type:t.entity||"unknown"})})]})]})}},{key:"created_at",label:"Created",render:t=>e.jsx(h,{date:t.created_at}),className:"w-40",sortable:!0},{key:"updated_at",label:"Updated",render:t=>e.jsx(h,{date:t.updated_at}),className:"w-40",sortable:!0},{key:"duration",label:"Duration",render:t=>{const a=p(t);return e.jsx(C,{startDate:t.created_at,endDate:a==="in_progress"?null:t.updated_at,isLive:a==="in_progress"})},className:"w-28"},{key:"actions",label:"",className:"w-28",render:t=>{const o=p(t)==="completed",l=t.entity==="mcpWorkflowBuilder";if(t.entity==="mcpWorkflowPlanner"){const r=t.set_id?`/mcp/queries/${t.workflow_id}?mode=plan&set_id=${t.set_id}`:`/mcp/queries/${t.workflow_id}?mode=plan`;return e.jsxs(c,{children:[e.jsx("button",{onClick:n=>{n.stopPropagation(),s(`${r}&step=1`)},className:"opacity-0 group-hover/row:opacity-100 text-text-tertiary hover:text-accent transition-all",title:"Plan",children:e.jsx(D,{className:"w-3.5 h-3.5",strokeWidth:1.5})}),e.jsx("button",{onClick:n=>{n.stopPropagation(),s(`${r}&step=2`)},className:`opacity-0 group-hover/row:opacity-100 transition-all ${o?"text-text-tertiary hover:text-status-success":"text-text-tertiary/30 cursor-not-allowed"}`,title:o?"Build":"Planning...",disabled:!o,children:e.jsx(g,{className:"w-3.5 h-3.5",strokeWidth:1.5})})]})}return l?e.jsxs(c,{children:[e.jsx("button",{onClick:r=>{r.stopPropagation(),s(`/mcp/queries/${t.workflow_id}?mode=builder&step=1`)},className:"opacity-0 group-hover/row:opacity-100 text-text-tertiary hover:text-accent transition-all",title:"Describe",children:e.jsx(k,{className:"w-3.5 h-3.5",strokeWidth:1.5})}),e.jsx("button",{onClick:r=>{r.stopPropagation(),s(`/mcp/queries/${t.workflow_id}?mode=builder&step=2`)},className:`opacity-0 group-hover/row:opacity-100 transition-all ${o?"text-text-tertiary hover:text-status-success":"text-text-tertiary/30 cursor-not-allowed"}`,title:o?"Profile":"Building...",disabled:!o,children:e.jsx(B,{className:"w-3.5 h-3.5",strokeWidth:1.5})})]}):e.jsxs(c,{children:[e.jsx("button",{onClick:r=>{r.stopPropagation(),s(`/mcp/queries/${t.workflow_id}?step=1`)},className:"opacity-0 group-hover/row:opacity-100 text-text-tertiary hover:text-accent transition-all",title:"Describe",children:e.jsx(k,{className:"w-3.5 h-3.5",strokeWidth:1.5})}),e.jsx("button",{onClick:r=>{r.stopPropagation(),s(`/mcp/queries/${t.workflow_id}?step=2`)},className:"opacity-0 group-hover/row:opacity-100 text-text-tertiary hover:text-status-warning transition-all",title:"Discover",children:e.jsx(F,{className:"w-3.5 h-3.5",strokeWidth:1.5})}),e.jsx("button",{onClick:r=>{r.stopPropagation(),s(`/mcp/queries/${t.workflow_id}?step=3`)},className:`opacity-0 group-hover/row:opacity-100 transition-all ${o?"text-text-tertiary hover:text-status-success":"text-text-tertiary/30 cursor-not-allowed"}`,title:o?"Compile":"Complete discovery first",disabled:!o,children:e.jsx(g,{className:"w-3.5 h-3.5",strokeWidth:1.5})})]})}}]}function se(){const s=L(),t=E(s),{filters:a,setFilter:o,pagination:l,sort:d,setSort:r}=S({filters:{search:"",status:"",type:""},pageSize:20}),{data:n,isLoading:m,refetch:b}=T({limit:l.pageSize,offset:l.offset,search:a.search,status:a.status,entity:a.type||void 0});q();const u=(n==null?void 0:n.jobs)??[],x=(n==null?void 0:n.total)??0;return e.jsxs(e.Fragment,{children:[e.jsx(j,{title:"MCP Tool Designer",docsHash:"#docs:dashboard.md:mcp-tool-designer",actions:e.jsxs("button",{onClick:()=>s("/mcp/queries/new"),className:"btn-primary text-xs inline-flex items-center gap-1.5",children:[e.jsx(y,{className:"w-3.5 h-3.5",strokeWidth:1.5}),"Create New MCP Tool"]})}),e.jsxs(v,{actions:e.jsx(P,{onRefresh:()=>b(),apiPath:`/workflow-states/jobs?entity=${a.type||"mcpQuery,mcpTriage,mcpWorkflowPlanner"}&limit=${l.pageSize}&offset=${l.offset}&sort_by=created_at&order=desc${a.status?`&status=${a.status}`:""}${a.search?`&search=${a.search}`:""}`}),children:[e.jsx(f,{label:"Type",value:a.type,onChange:i=>o("type",i),options:[{value:"mcpQuery",label:"Discovery"},{value:"mcpWorkflowPlanner",label:"Build"},{value:"mcpTriage",label:"Triage"}]}),e.jsx(f,{label:"Status",value:a.status,onChange:i=>o("status",i),options:[{value:"completed",label:"Completed"},{value:"running",label:"Running"},{value:"failed",label:"Failed"}]})]}),e.jsx(_,{columns:t,data:u,keyFn:i=>i.workflow_id,onRowClick:i=>{if(i.entity==="mcpWorkflowPlanner"){const w=i.set_id?`/mcp/queries/${i.workflow_id}?mode=plan&set_id=${i.set_id}`:`/mcp/queries/${i.workflow_id}?mode=plan`;s(w)}else i.entity==="mcpWorkflowBuilder"?s(`/mcp/queries/${i.workflow_id}?mode=builder`):s(`/mcp/queries/${i.workflow_id}`)},isLoading:m,emptyMessage:"",sort:d,onSort:r}),!m&&u.length===0&&e.jsx("div",{className:"cursor-pointer",onClick:()=>s("/mcp/queries/new"),children:e.jsx(W,{icon:y,title:"No tool designs yet",description:"Click to create your first MCP tool"})}),e.jsx(N,{page:l.page,pageSize:l.pageSize,total:x,totalPages:l.totalPages(x),onPageChange:l.setPage})]})}export{se as McpQueryPage};
2
- //# sourceMappingURL=McpQueryPage-BOO0ACYO.js.map
@@ -1,2 +0,0 @@
1
- import{b as P,a as I,j as e}from"./vendor-query-B2UbickB.js";import{b as D}from"./mcp-runs-aBDudwEi.js";import{u as R}from"./settings-D0v7RI3o.js";import{S as K}from"./StatusBadge-XQlNFwmH.js";import{u as U,D as $,c as N,J as w,N as J}from"./index-BMIU7Im5.js";import{P as k}from"./PageHeader-DLjHNYHX.js";import{C as L}from"./CopyableId-DmLF-RqZ.js";import{C as j}from"./CollapsibleSection-DaFQGU6S.js";import{u as M,E as V}from"./EventTable-DWxH0vMp.js";import{L as q}from"./ListToolbar-DuON-br0.js";import{S as B}from"./SwimlaneTimeline-2JHwAM2f.js";import{e as F,f as H}from"./vendor-react-CX88sFS5.js";import"./vendor-icons-E6836lXZ.js";import"./FilterBar-Ck4K4rzu.js";const Q={running:"in_progress",completed:"completed",failed:"failed"};function le(){var g,v;const{jobId:s}=F(),[o]=H(),r=o.get("namespace")||"longtail",h=P(),{data:t,isLoading:S,error:i,refetch:_,isFetching:C}=D(s,r),{data:x}=R(),{isCollapsed:d,toggle:m}=M("mcp-run-detail"),f=((g=x==null?void 0:x.telemetry)==null?void 0:g.traceUrl)??null,E=I.useCallback(c=>{!s||c.workflowId!==s||h.invalidateQueries({queryKey:["mcpRunExecution",s]})},[s,h]);if(U(`${J}.activity.>`,E),S)return e.jsxs("div",{className:"animate-pulse space-y-4",children:[e.jsx("div",{className:"h-8 bg-surface-sunken rounded w-64"}),e.jsx("div",{className:"h-60 bg-surface-sunken rounded"})]});if(i||!t)return e.jsxs("div",{children:[e.jsx(k,{title:"Pipeline Execution"}),e.jsxs("div",{className:"mt-4 text-center py-8",children:[e.jsx("p",{className:"text-sm text-text-primary mb-1",children:(v=i==null?void 0:i.message)!=null&&v.includes("expired")?"Execution data is no longer available":"Unable to load execution"}),e.jsx("p",{className:"text-xs text-text-tertiary",children:(i==null?void 0:i.message)??"The run could not be resolved."})]})]});const{events:u,summary:a}=t,p=u.find(c=>{var y;return c.category==="activity"&&((y=c.attributes.kind)==null?void 0:y.includes("completed"))}),T=(p==null?void 0:p.attributes.result)??null,n=t.result,b=(n==null?void 0:n.data)??n??null;return e.jsxs("div",{children:[e.jsx(k,{title:"Pipeline Execution",actions:e.jsx(q,{onRefresh:()=>_(),isFetching:C,apiPath:`/mcp-runs/${s}/execution?app_id=${r}`})}),e.jsxs("div",{className:"bg-surface-raised border border-surface-border rounded-md p-5 mb-8",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[e.jsx("h2",{className:"text-sm font-mono text-text-primary truncate flex-1",children:t.workflow_id}),e.jsxs("div",{className:"flex items-center gap-4 shrink-0",children:[e.jsx(l,{label:"Tools",value:a.activities.user}),e.jsx(l,{label:"System",value:a.activities.system,muted:!0}),a.child_workflows.total>0&&e.jsx(l,{label:"Children",value:a.child_workflows.total}),a.timers>0&&e.jsx(l,{label:"Timers",value:a.timers}),a.signals>0&&e.jsx(l,{label:"Signals",value:a.signals}),e.jsx(K,{status:Q[t.status]??t.status})]})]}),e.jsxs("div",{className:"grid grid-cols-6 gap-x-6",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-0.5",children:"Server"}),e.jsx("p",{className:"text-xs font-mono text-text-primary truncate",children:r})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-0.5",children:"Tool"}),e.jsx("p",{className:"text-xs font-mono text-text-primary truncate",children:t.workflow_type||"—"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-0.5",children:"Duration"}),e.jsx($,{ms:t.duration_ms,className:"font-mono text-text-primary"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-0.5",children:"Started"}),t.start_time?e.jsx(N,{date:t.start_time,format:"datetime",className:"font-mono text-text-primary"}):e.jsx("span",{className:"text-xs text-text-tertiary",children:"--"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-0.5",children:"Completed"}),t.close_time?e.jsx(N,{date:t.close_time,format:"datetime",className:"font-mono text-text-primary"}):e.jsx("span",{className:"text-xs text-text-tertiary",children:"--"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-widest text-text-tertiary mb-0.5",children:"Trace"}),t.trace_id?e.jsx(L,{label:"",value:t.trace_id,href:f?f.replace("{traceId}",t.trace_id):void 0,external:!0}):e.jsx("span",{className:"text-xs text-text-tertiary",children:"—"})]})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsx(j,{title:"Details",sectionKey:"details",isCollapsed:d("details"),onToggle:m,children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mb-6",children:[e.jsx("div",{children:e.jsx(w,{data:T??{},label:"Input"})}),b!==null&&e.jsx("div",{children:e.jsx(w,{data:b,label:"Result"})})]})}),e.jsx(j,{title:"Execution Timeline",sectionKey:"timeline",isCollapsed:d("timeline"),onToggle:m,children:e.jsx(B,{events:u,outline:!0})}),e.jsx(j,{title:"Events",sectionKey:"events",isCollapsed:d("events"),onToggle:m,children:e.jsx(V,{events:u})})]})]})}function l({label:s,value:o,muted:r}){return e.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[e.jsx("span",{className:"text-text-tertiary",children:s}),e.jsx("span",{className:`font-medium tabular-nums ${r?"text-text-tertiary":"text-text-primary"}`,children:o})]})}export{le as McpRunDetailPage};
2
- //# sourceMappingURL=McpRunDetailPage-Di8s7-u9.js.map
@@ -1,2 +0,0 @@
1
- import{a as m,j as s}from"./vendor-query-B2UbickB.js";import{a as T,u as F}from"./mcp-runs-aBDudwEi.js";import{a as R}from"./yaml-workflows-BKZdGciI.js";import{u as M}from"./namespaces-C45c4uoO.js";import{u as z}from"./useFilterParams-DZCAaBC7.js";import{D as E}from"./DataTable-D9yuBv0w.js";import{W as A}from"./WorkflowPill-BbgVTGgI.js";import{T as b}from"./TimestampCell-Dgpl-lKv.js";import{E as L}from"./ElapsedCell-DKoH0bqR.js";import{P as U}from"./PageHeader-DLjHNYHX.js";import{F as I,b as h}from"./FilterBar-Ck4K4rzu.js";import{S as O}from"./StickyPagination-F9FZsRy9.js";import{L as W}from"./ListToolbar-DuON-br0.js";import{R as q,a as B}from"./RowActions-Dg-Fsm5O.js";import{q as H}from"./vendor-icons-E6836lXZ.js";import{c as G}from"./vendor-react-CX88sFS5.js";import"./index-BMIU7Im5.js";import"./EmptyState-BcsfPq9T.js";const Y={running:"in_progress",completed:"completed",failed:"failed"},J={in_progress:"bg-status-active",completed:"bg-status-success",failed:"bg-status-error"},K={running:"text-status-active",completed:"text-status-success",failed:"text-status-error"};function Q(f,a){return[{key:"workflow_id",label:"Run ID / Tool",render:e=>{const p=J[Y[e.status]??e.status]??"bg-status-pending",n=e.status==="running"?" animate-pulse":"";return s.jsxs("div",{className:"flex items-start gap-2 min-w-0",children:[s.jsx("span",{className:`w-1.5 h-1.5 shrink-0 rounded-full mt-1.5 ${p}${n}`,title:e.status}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("span",{className:"font-mono text-xs text-text-primary truncate block",children:e.workflow_id}),s.jsx("div",{className:"mt-0.5",children:e.entity?s.jsx(A,{type:e.entity,variant:"pipeline",size:"xs"}):s.jsx("span",{className:"text-[10px] text-text-tertiary",children:"—"})})]})]})}},{key:"created_at",label:"Created",sortable:!0,render:e=>s.jsx(b,{date:e.created_at}),className:"w-40"},{key:"updated_at",label:"Updated",sortable:!0,render:e=>s.jsx(b,{date:e.updated_at}),className:"w-40"},{key:"duration",label:"Duration",render:e=>s.jsx(L,{startDate:e.created_at,endDate:e.status==="running"?null:e.updated_at,isLive:e.status==="running"}),className:"w-28"},{key:"actions",label:"",render:e=>s.jsxs(q,{children:[s.jsx(B,{icon:H,title:`Filter by ${e.entity}`,onClick:()=>f(e.entity)}),s.jsx("button",{onClick:p=>{p.stopPropagation(),a(e.status)},className:"opacity-0 group-hover/row:opacity-100 transition-opacity",title:`Filter by ${e.status}`,children:s.jsx("svg",{className:`w-[18px] h-[18px] ${K[e.status]??"text-text-tertiary"} hover:opacity-70`,viewBox:"0 0 24 24",fill:"currentColor",children:s.jsx("circle",{cx:"12",cy:"12",r:"6"})})})]}),className:"w-24 text-right"}]}function xe(){const f=G(),{filters:a,setFilter:e,setFilters:p,pagination:n,sort:g,setSort:v}=z({filters:{search:"",entity:"",status:"",namespace:""}}),[d,j]=m.useState(a.search);m.useEffect(()=>{if(d===a.search)return;const t=setTimeout(()=>e("search",d),300);return()=>clearTimeout(t)},[d,e,a.search]);const{data:r}=R(),{data:l}=M(),x=m.useMemo(()=>{const t=new Set((r==null?void 0:r.app_ids)??[]);for(const o of(l==null?void 0:l.namespaces)??[])t.add(o.name);return[...t].sort()},[r==null?void 0:r.app_ids,l==null?void 0:l.namespaces]),S=x.includes("longtail")?"longtail":x[0]??"",i=a.namespace||S,{data:c}=T(i),{data:u,isLoading:N,refetch:_,isFetching:k}=F({app_id:i,limit:n.pageSize,offset:n.offset,entity:a.entity||void 0,search:a.search||void 0,status:a.status||void 0,sort_by:g.sort_by||void 0,order:g.order||void 0}),y=(u==null?void 0:u.total)??0,C=(u==null?void 0:u.jobs)??[],$=Q(t=>e("entity",t),t=>e("status",t)),w=m.useMemo(()=>{const t=new Set(x);return i&&t.add(i),[...t].sort().map(o=>({value:o,label:o}))},[x,i]),P=m.useMemo(()=>{const t=new Set((c==null?void 0:c.entities)??[]);return a.entity&&!t.has(a.entity)&&t.add(a.entity),[...t].sort().map(o=>({value:o,label:o}))},[c==null?void 0:c.entities,a.entity]);return s.jsxs("div",{children:[s.jsx(U,{title:"Pipeline Executions",docsHash:"#docs:dashboard.md:pipeline-executions"}),s.jsxs(I,{actions:s.jsx(W,{onRefresh:()=>_(),isFetching:k,apiPath:`/mcp-runs?app_id=${i||"longtail"}&limit=${n.pageSize}&offset=${n.offset}${a.entity?`&entity=${a.entity}`:""}${a.status?`&status=${a.status}`:""}${a.search?`&search=${a.search}`:""}`}),children:[s.jsx(h,{label:"Namespace",value:i,onChange:t=>{p({namespace:t,entity:""})},options:w,required:!0}),s.jsx("input",{type:"text",placeholder:"Search run ID...",value:d,onChange:t=>j(t.target.value),className:"input text-[11px] py-1 px-2 w-56"}),s.jsx(h,{label:"Tool",value:a.entity,onChange:t=>e("entity",t),options:P}),s.jsx(h,{label:"Status",value:a.status,onChange:t=>e("status",t),options:[{value:"running",label:"Running"},{value:"completed",label:"Completed"},{value:"failed",label:"Failed"}]})]}),s.jsx(E,{columns:$,data:C,keyFn:t=>t.workflow_id,onRowClick:t=>f(`/mcp/executions/${encodeURIComponent(t.workflow_id)}?namespace=${i}`),isLoading:N,emptyMessage:"No pipeline executions found",sort:g,onSort:v}),s.jsx(O,{page:n.page,totalPages:n.totalPages(y),onPageChange:n.setPage,total:y,pageSize:n.pageSize,onPageSizeChange:n.setPageSize})]})}export{xe as McpRunsPage};
2
- //# sourceMappingURL=McpRunsPage-DdUVqUFi.js.map
@@ -1,2 +0,0 @@
1
- import{a as x,j as e}from"./vendor-query-B2UbickB.js";import{a as c}from"./vendor-react-CX88sFS5.js";function o({open:r,onClose:t,title:a,children:i,maxWidth:n}){return x.useEffect(()=>{if(!r)return;const s=d=>{d.key==="Escape"&&t()};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[r,t]),r?c.createPortal(e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-text-primary/30",onClick:t}),e.jsxs("div",{className:`relative bg-surface-raised border border-surface-border rounded-lg shadow-xl w-full ${n??"max-w-md"} mx-4 max-h-[85vh] flex flex-col`,children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b shrink-0",children:[e.jsx("h2",{className:"text-sm font-medium text-text-primary",children:a}),e.jsx("button",{onClick:t,className:"text-text-tertiary hover:text-text-primary text-lg leading-none",children:"×"})]}),e.jsx("div",{className:"px-6 py-5 overflow-y-auto",children:i})]})]}),document.body):null}export{o as M};
2
- //# sourceMappingURL=Modal-DEODGeqx.js.map