@rubytech/create-maxy-code 0.1.503 → 0.1.504

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 (192) hide show
  1. package/package.json +1 -1
  2. package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +33 -1
  3. package/payload/platform/plugins/admin/skills/whats-new/SKILL.md +6 -0
  4. package/payload/platform/plugins/docs/references/admin-ui.md +32 -0
  5. package/payload/platform/plugins/work/PLUGIN.md +3 -3
  6. package/payload/platform/plugins/work/mcp/dist/__tests__/assignable-admins.test.d.ts +2 -0
  7. package/payload/platform/plugins/work/mcp/dist/__tests__/assignable-admins.test.d.ts.map +1 -0
  8. package/payload/platform/plugins/work/mcp/dist/__tests__/assignable-admins.test.js +55 -0
  9. package/payload/platform/plugins/work/mcp/dist/__tests__/assignable-admins.test.js.map +1 -0
  10. package/payload/platform/plugins/work/mcp/dist/__tests__/work-create-assigned-admin-env.test.js +33 -1
  11. package/payload/platform/plugins/work/mcp/dist/__tests__/work-create-assigned-admin-env.test.js.map +1 -1
  12. package/payload/platform/plugins/work/mcp/dist/__tests__/work-update-assign.test.d.ts +2 -0
  13. package/payload/platform/plugins/work/mcp/dist/__tests__/work-update-assign.test.d.ts.map +1 -0
  14. package/payload/platform/plugins/work/mcp/dist/__tests__/work-update-assign.test.js +73 -0
  15. package/payload/platform/plugins/work/mcp/dist/__tests__/work-update-assign.test.js.map +1 -0
  16. package/payload/platform/plugins/work/mcp/dist/index.js +4 -1
  17. package/payload/platform/plugins/work/mcp/dist/index.js.map +1 -1
  18. package/payload/platform/plugins/work/mcp/dist/lib/assignable-admins.d.ts +13 -0
  19. package/payload/platform/plugins/work/mcp/dist/lib/assignable-admins.d.ts.map +1 -0
  20. package/payload/platform/plugins/work/mcp/dist/lib/assignable-admins.js +66 -0
  21. package/payload/platform/plugins/work/mcp/dist/lib/assignable-admins.js.map +1 -0
  22. package/payload/platform/plugins/work/mcp/dist/tools/work-create.d.ts +8 -0
  23. package/payload/platform/plugins/work/mcp/dist/tools/work-create.d.ts.map +1 -1
  24. package/payload/platform/plugins/work/mcp/dist/tools/work-create.js +31 -13
  25. package/payload/platform/plugins/work/mcp/dist/tools/work-create.js.map +1 -1
  26. package/payload/platform/plugins/work/mcp/dist/tools/work-list.d.ts +4 -0
  27. package/payload/platform/plugins/work/mcp/dist/tools/work-list.d.ts.map +1 -1
  28. package/payload/platform/plugins/work/mcp/dist/tools/work-list.js +3 -2
  29. package/payload/platform/plugins/work/mcp/dist/tools/work-list.js.map +1 -1
  30. package/payload/platform/plugins/work/mcp/dist/tools/work-update.d.ts +7 -0
  31. package/payload/platform/plugins/work/mcp/dist/tools/work-update.d.ts.map +1 -1
  32. package/payload/platform/plugins/work/mcp/dist/tools/work-update.js +31 -0
  33. package/payload/platform/plugins/work/mcp/dist/tools/work-update.js.map +1 -1
  34. package/payload/server/public/activity.html +6 -6
  35. package/payload/server/public/agents.html +18 -0
  36. package/payload/server/public/assets/{AdminLoginScreens-Bv_bKKeL.js → AdminLoginScreens-DWMR4KtI.js} +1 -1
  37. package/payload/server/public/assets/AdminShell-C8hBpL9K.js +2 -0
  38. package/payload/server/public/assets/{activity-DZFYDHNA.js → activity-DH3z4cv3.js} +1 -1
  39. package/payload/server/public/assets/admin-aaGhd2Yh.js +1 -0
  40. package/payload/server/public/assets/agents-SPu-clsf.js +1 -0
  41. package/payload/server/public/assets/{arc-CvlzUHOf.js → arc-DaI5MLTq.js} +1 -1
  42. package/payload/server/public/assets/architecture-YZFGNWBL-DWZIX5aV.js +1 -0
  43. package/payload/server/public/assets/{architectureDiagram-Q4EWVU46-I1Hs0RJA.js → architectureDiagram-Q4EWVU46-CBGVUEN9.js} +1 -1
  44. package/payload/server/public/assets/{blockDiagram-DXYQGD6D-Df5jTGtl.js → blockDiagram-DXYQGD6D-DS6dS4GZ.js} +1 -1
  45. package/payload/server/public/assets/{browser-Bt4-LKLU.js → browser-C_MJYN5k.js} +1 -1
  46. package/payload/server/public/assets/{c4Diagram-AHTNJAMY-B6WY5IDv.js → c4Diagram-AHTNJAMY-hBSBUZPt.js} +1 -1
  47. package/payload/server/public/assets/calendar-DA0h7dqW.js +1 -0
  48. package/payload/server/public/assets/channel-BEokjAeE.js +1 -0
  49. package/payload/server/public/assets/chat-Bg7dlM0I.js +1 -0
  50. package/payload/server/public/assets/chevron-left-BoDA12H8.js +1 -0
  51. package/payload/server/public/assets/chevron-right-DXjrO6qA.js +1 -0
  52. package/payload/server/public/assets/{chunk-2KRD3SAO-BsIIFDkc.js → chunk-2KRD3SAO-B6koUoB7.js} +1 -1
  53. package/payload/server/public/assets/{chunk-336JU56O-j9z1VtyC.js → chunk-336JU56O-BF6BRh8u.js} +2 -2
  54. package/payload/server/public/assets/chunk-426QAEUC-pbQ4PWBU.js +1 -0
  55. package/payload/server/public/assets/{chunk-4BX2VUAB-C9i7prxq.js → chunk-4BX2VUAB-7sO95xR2.js} +1 -1
  56. package/payload/server/public/assets/{chunk-4TB4RGXK-DH0QVGcv.js → chunk-4TB4RGXK-GCTndJYx.js} +1 -1
  57. package/payload/server/public/assets/{chunk-55IACEB6-Dnd_YCPA.js → chunk-55IACEB6-ggIJf_TC.js} +1 -1
  58. package/payload/server/public/assets/{chunk-5FUZZQ4R-D5sSz3yN.js → chunk-5FUZZQ4R-DeGmkimt.js} +1 -1
  59. package/payload/server/public/assets/{chunk-5PVQY5BW-CJrwWjAT.js → chunk-5PVQY5BW-aFIQKk_U.js} +1 -1
  60. package/payload/server/public/assets/{chunk-67CJDMHE-SjP6_hUw.js → chunk-67CJDMHE-LS8rUbii.js} +1 -1
  61. package/payload/server/public/assets/{chunk-7N4EOEYR-fAuhVJD0.js → chunk-7N4EOEYR-JKOVngS0.js} +1 -1
  62. package/payload/server/public/assets/{chunk-AA7GKIK3-DZxa7KVg.js → chunk-AA7GKIK3-CoXnTVK6.js} +1 -1
  63. package/payload/server/public/assets/{chunk-BSJP7CBP-DjeG3eQ-.js → chunk-BSJP7CBP-CcsqObFg.js} +1 -1
  64. package/payload/server/public/assets/{chunk-CIAEETIT-RYQULNJm.js → chunk-CIAEETIT-CpsybR7q.js} +1 -1
  65. package/payload/server/public/assets/{chunk-EDXVE4YY-Cahapnon.js → chunk-EDXVE4YY-BZ2I9PSq.js} +1 -1
  66. package/payload/server/public/assets/{chunk-ENJZ2VHE-1146X1L4.js → chunk-ENJZ2VHE-DbTwt6OZ.js} +1 -1
  67. package/payload/server/public/assets/{chunk-FMBD7UC4-BCFumtcP.js → chunk-FMBD7UC4-D27VnSCa.js} +1 -1
  68. package/payload/server/public/assets/{chunk-FOC6F5B3-CkrtX8Zt.js → chunk-FOC6F5B3-C0tU2UFl.js} +1 -1
  69. package/payload/server/public/assets/{chunk-ICPOFSXX-Ba1y3DaW.js → chunk-ICPOFSXX-UPPu2OIq.js} +1 -1
  70. package/payload/server/public/assets/{chunk-K5T4RW27-CF-PI3uQ.js → chunk-K5T4RW27-DIKxqyYw.js} +1 -1
  71. package/payload/server/public/assets/{chunk-KGLVRYIC-SFFC6ZC-.js → chunk-KGLVRYIC-CiL4YVLo.js} +1 -1
  72. package/payload/server/public/assets/{chunk-LIHQZDEY-DbOLEP4R.js → chunk-LIHQZDEY-ejKezVlD.js} +1 -1
  73. package/payload/server/public/assets/{chunk-ORNJ4GCN-VB963bkN.js → chunk-ORNJ4GCN-Cc0vqc-D.js} +1 -1
  74. package/payload/server/public/assets/{chunk-OYMX7WX6-DWYY1pQa.js → chunk-OYMX7WX6-Drxn1qG0.js} +1 -1
  75. package/payload/server/public/assets/chunk-QZHKN3VN-Dhlh7Pkk.js +1 -0
  76. package/payload/server/public/assets/{chunk-U2HBQHQK-DAH1diYP.js → chunk-U2HBQHQK-DnbQIkRP.js} +1 -1
  77. package/payload/server/public/assets/{chunk-X2U36JSP-Dmw9coXz.js → chunk-X2U36JSP-CauTSVWg.js} +1 -1
  78. package/payload/server/public/assets/{chunk-XPW4576I-DaAUON1-.js → chunk-XPW4576I-DZqqB9Zi.js} +1 -1
  79. package/payload/server/public/assets/{chunk-YZCP3GAM-BUcfkEef.js → chunk-YZCP3GAM-BGHo4Li-.js} +1 -1
  80. package/payload/server/public/assets/{chunk-ZZ45TVLE-BLD-vFRO.js → chunk-ZZ45TVLE-DWGJKPd7.js} +1 -1
  81. package/payload/server/public/assets/classDiagram-6PBFFD2Q-D2z_ZV1x.js +1 -0
  82. package/payload/server/public/assets/classDiagram-v2-HSJHXN6E-BJwJoNEK.js +1 -0
  83. package/payload/server/public/assets/clock-BceBgZP1.js +1 -0
  84. package/payload/server/public/assets/clone-Bn7XXVhr.js +1 -0
  85. package/payload/server/public/assets/{cose-bilkent-S5V4N54A-CoZX0uki.js → cose-bilkent-S5V4N54A-D-95BzXL.js} +1 -1
  86. package/payload/server/public/assets/{dagre-Bmjs8zJA.js → dagre-BZYNBHvT.js} +1 -1
  87. package/payload/server/public/assets/{dagre-KV5264BT-BZCP2wnq.js → dagre-KV5264BT-DyU4HQLQ.js} +1 -1
  88. package/payload/server/public/assets/data-rNLaurgY.js +1 -0
  89. package/payload/server/public/assets/{diagram-5BDNPKRD-8Nt9a4xX.js → diagram-5BDNPKRD-CCttJ9XA.js} +1 -1
  90. package/payload/server/public/assets/{diagram-G4DWMVQ6-vh5tcYqJ.js → diagram-G4DWMVQ6-DvkpgSLO.js} +1 -1
  91. package/payload/server/public/assets/{diagram-MMDJMWI5-DGf--jc8.js → diagram-MMDJMWI5-DHmW5Y9k.js} +1 -1
  92. package/payload/server/public/assets/{diagram-TYMM5635-CsO7TIdw.js → diagram-TYMM5635-C6T4hwzO.js} +1 -1
  93. package/payload/server/public/assets/{dist-cdnE4DqK.js → dist-QvbmK1IP.js} +1 -1
  94. package/payload/server/public/assets/{erDiagram-SMLLAGMA-4a78yV8_.js → erDiagram-SMLLAGMA-5v_o7s3T.js} +1 -1
  95. package/payload/server/public/assets/{file-text-BpLcZKld.js → file-text-RCoSeOpD.js} +1 -1
  96. package/payload/server/public/assets/{flowDiagram-DWJPFMVM-BoQBXs6t.js → flowDiagram-DWJPFMVM-3UhCDsjt.js} +1 -1
  97. package/payload/server/public/assets/{ganttDiagram-T4ZO3ILL-CvzqwCC8.js → ganttDiagram-T4ZO3ILL-F2zgHIIQ.js} +1 -1
  98. package/payload/server/public/assets/gitGraph-7Q5UKJZL-C-FvNTHZ.js +1 -0
  99. package/payload/server/public/assets/{gitGraphDiagram-UUTBAWPF-D_nBxay_.js → gitGraphDiagram-UUTBAWPF-oQc1N3dT.js} +1 -1
  100. package/payload/server/public/assets/{graph-HB0199x-.js → graph-Dm-YZeNP.js} +12 -12
  101. package/payload/server/public/assets/{graph-labels-Bx19ZYvJ.js → graph-labels-DJV0aIG5.js} +1 -1
  102. package/payload/server/public/assets/{graphlib-D0NdsKJI.js → graphlib-DY4-AT2Q.js} +1 -1
  103. package/payload/server/public/assets/info-OMHHGYJF-BjLPgHAC.js +1 -0
  104. package/payload/server/public/assets/infoDiagram-42DDH7IO-CXNKLTui.js +2 -0
  105. package/payload/server/public/assets/{ishikawaDiagram-UXIWVN3A-auW-s0i0.js → ishikawaDiagram-UXIWVN3A-wJhSOkuw.js} +1 -1
  106. package/payload/server/public/assets/{journeyDiagram-VCZTEJTY-3Q6AWK4A.js → journeyDiagram-VCZTEJTY-DgadC6Pz.js} +1 -1
  107. package/payload/server/public/assets/{kanban-definition-6JOO6SKY-B4MPFp98.js → kanban-definition-6JOO6SKY-Bs4nQqXI.js} +1 -1
  108. package/payload/server/public/assets/{line-26MdeG5Z.js → line-Bnmxy1hO.js} +1 -1
  109. package/payload/server/public/assets/{linear-Dq9s_bDO.js → linear-RvwZxFzh.js} +1 -1
  110. package/payload/server/public/assets/{maximize-2-BhR-Ec21.js → maximize-2-DcESsKbu.js} +1 -1
  111. package/payload/server/public/assets/{mermaid-parser.core-vLEpOXgf.js → mermaid-parser.core-DeNV8RtA.js} +2 -2
  112. package/payload/server/public/assets/{mermaid.core-Durk4m6D.js → mermaid.core-BU9IiSCP.js} +3 -3
  113. package/payload/server/public/assets/{mindmap-definition-QFDTVHPH-DOIg-TyG.js → mindmap-definition-QFDTVHPH-D1PMUxxm.js} +1 -1
  114. package/payload/server/public/assets/operator-Dlkw1sXJ.js +1 -0
  115. package/payload/server/public/assets/packet-4T2RLAQJ-BBAZASfb.js +1 -0
  116. package/payload/server/public/assets/page-Dl-mgQUu.js +32 -0
  117. package/payload/server/public/assets/page-DoyJrk8E.js +1 -0
  118. package/payload/server/public/assets/pie-ZZUOXDRM-CCJUnMeG.js +1 -0
  119. package/payload/server/public/assets/{pieDiagram-DEJITSTG-DtgBHZfi.js → pieDiagram-DEJITSTG-BzdNzoKA.js} +1 -1
  120. package/payload/server/public/assets/{public-DZHPsyKX.js → public-C-UHWk_S.js} +1 -1
  121. package/payload/server/public/assets/{quadrantDiagram-34T5L4WZ-BTc5Qn2y.js → quadrantDiagram-34T5L4WZ-oFr1MJRO.js} +1 -1
  122. package/payload/server/public/assets/radar-PYXPWWZC-BsRU8Aep.js +1 -0
  123. package/payload/server/public/assets/{requirementDiagram-MS252O5E-BNgOO5YW.js → requirementDiagram-MS252O5E-C9QBQxDh.js} +1 -1
  124. package/payload/server/public/assets/{rotate-ccw-D9qOBLig.js → rotate-ccw-C1nRSAzP.js} +1 -1
  125. package/payload/server/public/assets/routines-qdAZ0sA4.js +1 -0
  126. package/payload/server/public/assets/{sankeyDiagram-XADWPNL6-MyUATmVt.js → sankeyDiagram-XADWPNL6-c_y3bvVv.js} +1 -1
  127. package/payload/server/public/assets/{sequenceDiagram-FGHM5R23-CBJrF5Vi.js → sequenceDiagram-FGHM5R23-YwlCBPHE.js} +1 -1
  128. package/payload/server/public/assets/skills-B78wr822.js +1 -0
  129. package/payload/server/public/assets/{src-DekKlUCp.js → src-C2WwTWSY.js} +1 -1
  130. package/payload/server/public/assets/{stateDiagram-FHFEXIEX-6wbUjn1Q.js → stateDiagram-FHFEXIEX-BFE3e-FM.js} +1 -1
  131. package/payload/server/public/assets/stateDiagram-v2-QKLJ7IA2-CpjB4ykI.js +1 -0
  132. package/payload/server/public/assets/tasks-DbIsS-vW.js +1 -0
  133. package/payload/server/public/assets/{time-entry-format-RkCW7hKu.js → time-entry-format-BhlltPP8.js} +1 -1
  134. package/payload/server/public/assets/{timeline-definition-GMOUNBTQ-BHjTMCGY.js → timeline-definition-GMOUNBTQ-azqhmRwZ.js} +1 -1
  135. package/payload/server/public/assets/treeView-SZITEDCU-BDzhKA6v.js +1 -0
  136. package/payload/server/public/assets/treemap-W4RFUUIX-epHpdeWa.js +1 -0
  137. package/payload/server/public/assets/{triangle-alert-k8ulav-N.js → triangle-alert-rEVGyIhi.js} +1 -1
  138. package/payload/server/public/assets/{useCopyFeedback-DN1WA5vU.js → useCopyFeedback-DzpXjm9d.js} +1 -1
  139. package/payload/server/public/assets/useSubAccountSwitcher-DVmWZxar.js +9 -0
  140. package/payload/server/public/assets/{useSubAccountSwitcher-fvBunpOC.css → useSubAccountSwitcher-wP8cOzPj.css} +1 -1
  141. package/payload/server/public/assets/{useVoiceRecorder-v--TIxaM.js → useVoiceRecorder-CRRmPjYr.js} +1 -1
  142. package/payload/server/public/assets/{vennDiagram-DHZGUBPP-yo3-cf0U.js → vennDiagram-DHZGUBPP-Da2RfFs8.js} +1 -1
  143. package/payload/server/public/assets/wardley-RL74JXVD-DNSZCrxV.js +1 -0
  144. package/payload/server/public/assets/{wardleyDiagram-NUSXRM2D-DZlyFzrg.js → wardleyDiagram-NUSXRM2D-HdrdBYES.js} +1 -1
  145. package/payload/server/public/assets/{wrench-CKhz8KnQ.js → wrench-oeLti270.js} +1 -1
  146. package/payload/server/public/assets/{xychartDiagram-5P7HB3ND-B5HV5h80.js → xychartDiagram-5P7HB3ND-DMk6rTcQ.js} +1 -1
  147. package/payload/server/public/browser.html +5 -5
  148. package/payload/server/public/calendar.html +8 -8
  149. package/payload/server/public/chat.html +14 -15
  150. package/payload/server/public/data.html +12 -12
  151. package/payload/server/public/graph.html +10 -10
  152. package/payload/server/public/index.html +15 -16
  153. package/payload/server/public/operator.html +15 -16
  154. package/payload/server/public/public.html +14 -15
  155. package/payload/server/public/routines.html +7 -7
  156. package/payload/server/public/skills.html +6 -6
  157. package/payload/server/public/tasks.html +7 -7
  158. package/payload/server/server.js +696 -430
  159. package/payload/server/public/assets/AdminShell-Gq8DU_ig.js +0 -2
  160. package/payload/server/public/assets/admin-DLUOixl6.js +0 -1
  161. package/payload/server/public/assets/architecture-YZFGNWBL-BQc779DH.js +0 -1
  162. package/payload/server/public/assets/bot-CrEhKW1l.js +0 -1
  163. package/payload/server/public/assets/calendar-B8ujkn_K.js +0 -1
  164. package/payload/server/public/assets/channel-AqnC3SHu.js +0 -1
  165. package/payload/server/public/assets/chat-lQXd6gsM.js +0 -1
  166. package/payload/server/public/assets/chevron-left-CQ8rcBoO.js +0 -1
  167. package/payload/server/public/assets/chevron-right-CSRSqblN.js +0 -1
  168. package/payload/server/public/assets/chunk-426QAEUC-CO02gU5d.js +0 -1
  169. package/payload/server/public/assets/chunk-QZHKN3VN-BiFMbK8t.js +0 -1
  170. package/payload/server/public/assets/classDiagram-6PBFFD2Q-BdRqzScB.js +0 -1
  171. package/payload/server/public/assets/classDiagram-v2-HSJHXN6E-ChPLgHbS.js +0 -1
  172. package/payload/server/public/assets/clock-B7Ba8AZL.js +0 -1
  173. package/payload/server/public/assets/clone-TKtrjWBC.js +0 -1
  174. package/payload/server/public/assets/data-BdlGqjKM.js +0 -1
  175. package/payload/server/public/assets/gitGraph-7Q5UKJZL-DfcaTE9L.js +0 -1
  176. package/payload/server/public/assets/info-OMHHGYJF-CD-u6gw9.js +0 -1
  177. package/payload/server/public/assets/infoDiagram-42DDH7IO-C6gPQCvO.js +0 -2
  178. package/payload/server/public/assets/operator-Bf3hP3qo.js +0 -1
  179. package/payload/server/public/assets/packet-4T2RLAQJ-BaLYeIrU.js +0 -1
  180. package/payload/server/public/assets/page-Bs24tO-C.js +0 -32
  181. package/payload/server/public/assets/page-FnCmAeHc.js +0 -1
  182. package/payload/server/public/assets/pie-ZZUOXDRM-CL-XJtk-.js +0 -1
  183. package/payload/server/public/assets/radar-PYXPWWZC-Cn-g6F_h.js +0 -1
  184. package/payload/server/public/assets/routines-lGiYaMiX.js +0 -1
  185. package/payload/server/public/assets/skills-y-h0P9rC.js +0 -1
  186. package/payload/server/public/assets/stateDiagram-v2-QKLJ7IA2-BdMdfBeC.js +0 -1
  187. package/payload/server/public/assets/tasks-Cyc1EfLA.js +0 -1
  188. package/payload/server/public/assets/treeView-SZITEDCU-CmZoOGlC.js +0 -1
  189. package/payload/server/public/assets/treemap-W4RFUUIX-H27WFS-y.js +0 -1
  190. package/payload/server/public/assets/useSubAccountSwitcher-iQGqNJhI.js +0 -9
  191. package/payload/server/public/assets/wardley-RL74JXVD-DNpWIvU4.js +0 -1
  192. /package/payload/server/public/assets/{chunk-CCr-iYLO.js → chunk-CltuBf4Z.js} +0 -0
@@ -1 +1 @@
1
- import{o as e}from"./chunk-CCr-iYLO.js";import{K as t,P as n,T as r,U as i,V as a,W as o,n as s,p as c}from"./useSubAccountSwitcher-iQGqNJhI.js";import{C as l,S as u,t as d,x as f}from"./AdminShell-Gq8DU_ig.js";import{t as p}from"./triangle-alert-k8ulav-N.js";var m=o(),h=e(t(),1),g=a(),_=`—`;function v(e){switch(e){case`waiting`:return`Waiting`;case`never-run`:return`Never run`;case`never-succeeded`:return`Never succeeded`;case`failing`:return`Failing`;case`stalled`:return`Stalled`;case`running`:return`Running`;case`ok`:return`Healthy`}}var y={waiting:`Armed and not due yet. It has no start-up run and its first interval has not elapsed, so it has correctly not fired.`,"never-run":`Its interval has elapsed and it still has not fired once. This is not the same as waiting its turn.`,"never-succeeded":`It has fired, and not one run has finished. The work this loop exists to do has never happened.`,failing:`It worked before and is failing now.`,stalled:`It has not started within three of its own intervals. Something is holding it up.`,running:`A run is in progress right now.`,ok:`The last run finished and the next is due within the interval.`},b=new Set([`never-run`,`never-succeeded`,`failing`,`stalled`]),x=10;function S(e){return e===null||!Number.isFinite(e)?_:`${e.toFixed(1)}%`}function C(e){return e<6e4?`${Math.round(e/1e3)}s`:e<36e5?`${Math.round(e/6e4)}m`:`${Math.round(e/36e5)}h`}function w(e,t){if(e===null)return _;let n=t-e;return n<0?`in ${C(-n)}`:n<6e4?`${Math.round(n/1e3)}s ago`:n<36e5?`${Math.round(n/6e4)}m ago`:`${Math.round(n/36e5)}h ago`}function T(e,t){if(e===null)return _;let n=e-t;return n>=0?`in ${C(n)}`:`overdue by ${C(-n)}`}function E({loops:e,nowMs:t=Date.now()}){let[n,r]=(0,h.useState)(!1);if(!e)return(0,g.jsxs)(`section`,{className:`activity-loops`,children:[(0,g.jsx)(`h2`,{className:`activity-loops-heading`,children:`Scheduled work`}),(0,g.jsx)(`p`,{className:`activity-loops-empty`,children:`Scheduled work could not be read from the server.`})]});let i=e.armed-e.rows.length,a=e.rows.filter(e=>b.has(e.state)),o=e.rows.filter(e=>!b.has(e.state)&&typeof e.cpuPct==`number`&&e.cpuPct>=x),s=n?e.rows:[...a,...o];return(0,g.jsxs)(`section`,{className:`activity-loops`,children:[(0,g.jsx)(`h2`,{className:`activity-loops-heading`,children:`Scheduled work`}),(0,g.jsxs)(`p`,{className:`activity-loops-sub`,children:[e.armed,` `,e.armed===1?`loop`:`loops`,` armed`,a.length>0?` · ${a.length} ${a.length===1?`needs`:`need`} attention`:` · all healthy`,o.length>0&&` · ${o.length} using significant processor`,`. `,(0,g.jsx)(`button`,{type:`button`,className:`activity-loops-toggle`,"aria-expanded":n,onClick:()=>r(e=>!e),children:n?`Show less`:`Show all`})]}),typeof e.processPct==`number`&&(0,g.jsxs)(`p`,{className:`activity-loops-cpu`,children:[`Server process at `,e.processPct.toFixed(1),`% of one core`,typeof e.attributedPct==`number`&&(0,g.jsxs)(g.Fragment,{children:[` · these loops explain `,e.attributedPct.toFixed(1),`%`]}),typeof e.unattributedPct==`number`&&e.unattributedPct>=1&&(0,g.jsxs)(g.Fragment,{children:[` · `,(0,g.jsxs)(`strong`,{children:[e.unattributedPct.toFixed(1),`% is not from these loops`]})]})]}),i>0&&(0,g.jsxs)(`p`,{className:`activity-loops-omission`,role:`status`,children:[i,` armed `,i===1?`loop is`:`loops are`,` missing from this list. The server armed `,e.armed,` but sent `,e.rows.length,`.`]}),s.length===0?null:(0,g.jsx)(`div`,{className:`activity-table-scroll`,children:(0,g.jsxs)(`table`,{className:`activity-table`,children:[(0,g.jsx)(`thead`,{children:(0,g.jsxs)(`tr`,{children:[(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Loop`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`State`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Every`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Last run`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Last OK`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Took`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`CPU`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Runs`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Produced`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Next due`})]})}),(0,g.jsx)(`tbody`,{children:s.map(e=>(0,g.jsxs)(`tr`,{className:b.has(e.state)?`activity-loop-row activity-loop-unhealthy`:`activity-loop-row`,children:[(0,g.jsx)(`td`,{className:`activity-td`,children:e.name}),(0,g.jsx)(`td`,{className:`activity-td`,title:y[e.state],children:(0,g.jsxs)(`span`,{className:`activity-state`,children:[(0,g.jsx)(`span`,{className:e.state===`ok`?`activity-state-dot is-healthy`:b.has(e.state)?`activity-state-dot is-unhealthy`:`activity-state-dot`,"aria-hidden":`true`}),v(e.state)]})}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:C(e.intervalMs)}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:w(e.lastStartMs,t)}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:w(e.lastSuccessMs,t)}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:e.lastDurationMs===null?_:`${e.lastDurationMs} ms`}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,title:e.cpuAttributable?e.detached?`Includes the processor time of the separate process this loop starts.`:void 0:`This loop waits on other work while it runs, so the processor time it uses cannot be separated from the rest of the server.`,children:S(e.cpuPct)}),(0,g.jsxs)(`td`,{className:`activity-td activity-num`,children:[e.successCount,`/`,e.runCount]}),(0,g.jsx)(`td`,{className:`activity-td activity-loop-note`,children:(0,g.jsx)(`span`,{className:`activity-loop-note-text`,title:e.lastError??e.lastNote??void 0,children:e.lastError??e.lastNote??_})}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:T(e.nextDueMs,t)})]},e.name))})]})}),(0,g.jsxs)(`dl`,{className:`activity-legend`,children:[(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,children:`Runs`}),(0,g.jsx)(`dd`,{className:`activity-legend-def`,children:`Finished runs out of attempted runs since the server started. 0 out of a large number means it has tried many times and never once finished.`})]}),(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,children:`CPU`}),(0,g.jsx)(`dd`,{className:`activity-legend-def`,children:`Share of one processor core this loop is using, measured between the last two refreshes. It includes any separate process the loop starts, and can pass 100% because those run alongside each other. A dash means it could not be measured: the loop waits on other work while it runs, so its share cannot be separated from the rest of the server.`})]}),(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,children:_}),(0,g.jsx)(`dd`,{className:`activity-legend-def`,children:`Not measured. It does not mean zero.`})]})]})]})}var D=`maxy-admin-session-key`;function O(e){switch(e.costUnavailable){case`metering-failed`:return`Cost could not be calculated: ${e.meteringError??`the transcript could not be read`}`;case`model-not-priced`:return`No published price for this model, so cost cannot be estimated.`;case`no-transcript`:return`This session has no transcript yet, so there is nothing to cost.`;default:return}}var k=[{key:`lastMessageAt`,label:`Last activity`,dir:-1},{key:`activeMsInRange`,label:`Active time`,dir:-1},{key:`costGbp`,label:`Cost`,dir:-1},{key:`accountId`,label:`Account name`,dir:1}],A=[{key:`title`,label:`Session`,help:`The conversation name, or its short id when it has none yet.`},{key:`model`,label:`Model`,help:`The model that answered the most recent turn.`},{key:`status`,label:`Status`,help:`What the process is doing right now.`},{key:`activeMsInRange`,label:`Active`,help:`Time this session spent thinking, writing and running tools inside the selected range. This is worked time, not elapsed time.`},{key:`ageMs`,label:`Age`,help:`How long ago this conversation started. Wall-clock, so it counts every hour nobody was working.`},{key:`lastMessageAt`,label:`Last activity`,help:`The clock time of the most recent message, in your timezone. A date appears once it is not today.`},{key:`turnCount`,label:`Turns`,help:`Messages exchanged. A trailing + means the count is a minimum — the conversation is too long to count exactly.`},{key:`rssKb`,label:`RAM`,help:`Memory held by this session and all its helper processes together.`},{key:`cpuPct`,label:`CPU (avg)`,help:`AVERAGE share of one processor core over the last census interval, up to 60 seconds. It is not a reading of this instant, so a session that answered a turn a minute ago still shows a high figure while sitting quiet now. Can exceed 100% because a session runs many processes at once.`},{key:`tokensInRange`,label:`Tokens`,help:`Total tokens billed inside the selected range, added up across every day in it. A cumulative total, not the size of the conversation the model currently reads back.`},{key:`costGbp`,label:`Cost`,help:`Estimated spend inside the selected range, at published prices for this model.`}],j=[`activeMsInRange`,`lastMessageAt`,`cpuPct`,`tokensInRange`],M={label:`Account`,help:`The business this session belongs to. "untagged" means the session records no account.`};function N(e,t){let n=t?.[e];return n&&n.trim()!==``?n:e.slice(0,8)}var P=`—`;function F(e){if(e===null||!Number.isFinite(e)||e<0)return P;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d ${r%24}h`}function I(e){return e===null||!Number.isFinite(e)?P:`${(e/1024/1024).toFixed(1)} GB`}function L(e,t){if(!e)return P;let n=Date.parse(e);if(!Number.isFinite(n))return P;let r=new Date(n),i=new Date(t),a=`${String(r.getHours()).padStart(2,`0`)}:${String(r.getMinutes()).padStart(2,`0`)}`;return r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()&&r.getDate()===i.getDate()?a:`${r.getDate()} ${r.toLocaleString(`en-GB`,{month:`short`})} ${a}`}function R(e){return e===null||!Number.isFinite(e)?P:`${e.toFixed(1)}%`}function z(e){return e===null||!Number.isFinite(e)?P:e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function B(e){return e===null||!Number.isFinite(e)?P:`£${e.toFixed(2)}`}function V(e){if(e===null||!Number.isFinite(e)||e<0)return P;let t=Math.floor(e/6e4);return`${Math.floor(t/60)}h ${t%60}m`}function H(e,t,n,r){let i=e[n],a=t[n];if(i===null&&a===null)return 0;if(i===null)return 1;if(a===null)return-1;if(n===`lastMessageAt`){let e=Date.parse(String(i)),t=Date.parse(String(a));return!Number.isFinite(e)&&!Number.isFinite(t)?0:Number.isFinite(e)?Number.isFinite(t)?(e-t)*r:-1:1}return typeof i==`number`&&typeof a==`number`?(i-a)*r:String(i).localeCompare(String(a))*r}function U(e){return e.toISOString().slice(0,10)}function W(e){let t=e.getUTCFullYear(),n=e.getUTCMonth();return{from:U(new Date(Date.UTC(t,n,1))),to:U(new Date(Date.UTC(t,n+1,0)))}}function G(e,t){let n=new Date(`${e}T00:00:00.000Z`);return W(new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+t,1)))}function ee(e,t){return{from:U(new Date(t-(e-1)*864e5)),to:U(new Date(t))}}function K(e){return new Date(`${e}T00:00:00.000Z`).toLocaleString(`en-GB`,{month:`long`,year:`numeric`,timeZone:`UTC`})}function q(e){if(e===null)return!1;let t=W(new Date(`${e.from}T00:00:00.000Z`));return t.from===e.from&&t.to===e.to}function J(e,t,n){switch(e){case`title`:return t.title??t.sessionId.slice(0,8);case`model`:return t.model??P;case`status`:return t.status??P;case`activeMsInRange`:return V(t.activeMsInRange);case`ageMs`:return F(t.ageMs);case`lastMessageAt`:return L(t.lastMessageAt,n);case`turnCount`:return t.turnCount===null?P:`${t.turnCount}${t.turnCountCapped?`+`:``}`;case`rssKb`:return I(t.rssKb);case`cpuPct`:return R(t.cpuPct);case`tokensInRange`:return z(t.tokensInRange);case`costGbp`:return B(t.costGbp);default:return P}}function Y({adminFetch:e,cacheKey:t}){let[i,a]=(0,h.useState)(null),[o,c]=(0,h.useState)(null),[l,d]=(0,h.useState)(!1),[m,_]=(0,h.useState)(`lastMessageAt`),[v,y]=(0,h.useState)(-1),[b,x]=(0,h.useState)(()=>W(new Date)),[S,C]=(0,h.useState)(!0),[w,T]=(0,h.useState)(!0),[D,I]=(0,h.useState)(!1),L=(0,h.useCallback)(async(e,n)=>{t&&await s(t,e)&&(console.info(`[admin-ui] activity-card-open account=${e.slice(0,8)} session=${n.slice(0,8)}`),window.location.assign(`/chat?session=${encodeURIComponent(n)}`))},[t]),R=(0,h.useRef)(!1),z=(0,h.useRef)(void 0),B=(0,h.useCallback)(async t=>{if(R.current){z.current=t;return}R.current=!0;try{let n=await e(`/api/admin/activity${t?`?from=${t.from}&to=${t.to}`:``}`);if(n.status===403){c(`This view is available to the house account only.`),d(!0);return}if(!n.ok){c(`The session manager did not answer (status ${n.status}).`),d(!0);return}a(await n.json()),c(null)}catch(e){c(e instanceof Error?e.message:String(e))}finally{d(!0),R.current=!1;let e=z.current;z.current=void 0,e!==void 0&&B(e)}},[e]);(0,h.useEffect)(()=>{B(b);let e=setInterval(()=>void B(b),15e3);return()=>clearInterval(e)},[B,b]);let V=(0,h.useMemo)(()=>i?[...i.rows].sort((e,t)=>H(e,t,m,v)):[],[i,m,v]),U=(0,h.useMemo)(()=>V.filter(e=>e.status===`busy`?S:e.status===`idle`?w:!0),[V,S,w]),Y=V.length-U.length;if(!l)return(0,g.jsxs)(`div`,{className:`activity-loading`,children:[(0,g.jsx)(r,{size:18,className:`spin`}),` Loading…`]});if(o)return(0,g.jsx)(`div`,{className:`activity-empty`,children:o});if(!i)return(0,g.jsx)(`div`,{className:`activity-empty`,children:`No response.`});let{accounts:X,census:Z,censusAgeMs:Q}=i,te=Date.now(),ne=X.onDisk!==null&&X.onDisk>X.valid,$=i.range===void 0?b:i.range;return(0,g.jsxs)(`div`,{className:`activity-body`,children:[(0,g.jsxs)(`div`,{className:`activity-head`,children:[(0,g.jsxs)(`span`,{className:`activity-title`,children:[(0,g.jsx)(n,{size:16}),` Live sessions`]}),(0,g.jsxs)(`span`,{className:`activity-meta`,children:[Y>0?`${U.length} of ${V.length} live · ${Y} hidden`:`${V.length} live`,` · `,X.valid,` accounts`,X.untaggedCount>0?` · ${X.untaggedCount} untagged`:``]})]}),(0,g.jsxs)(`div`,{className:`activity-controls`,children:[(0,g.jsxs)(`div`,{className:`activity-control activity-range`,children:[(0,g.jsx)(f,{variant:`secondary`,size:`sm`,"aria-label":`Previous month`,disabled:!q(b),onClick:()=>x(e=>e&&G(e.from,-1)),children:`‹`}),(0,g.jsx)(`span`,{className:`activity-range-label`,children:b===null?`All time`:q(b)?K(b.from):`${b.from} → ${b.to}`}),(0,g.jsx)(f,{variant:`secondary`,size:`sm`,"aria-label":`Next month`,disabled:!q(b),onClick:()=>x(e=>e&&G(e.from,1)),children:`›`})]}),(0,g.jsxs)(`div`,{className:`activity-control activity-presets`,children:[(0,g.jsx)(f,{variant:`secondary`,size:`sm`,"aria-pressed":b!==null&&q(b)&&b.from===W(new Date).from,onClick:()=>x(W(new Date)),children:`This month`}),(0,g.jsx)(f,{variant:`secondary`,size:`sm`,"aria-pressed":b!==null&&!q(b),onClick:()=>x(ee(7,Date.now())),children:`Last 7 days`}),(0,g.jsx)(f,{variant:`secondary`,size:`sm`,"aria-pressed":b===null,onClick:()=>x(null),children:`All time`})]}),(0,g.jsxs)(`div`,{className:`activity-control`,children:[(0,g.jsx)(`label`,{className:`activity-control-label`,htmlFor:`activity-sort`,children:`Sort by`}),(0,g.jsx)(`span`,{className:`activity-select-wrap`,children:(0,g.jsx)(`select`,{id:`activity-sort`,className:`activity-select`,value:m,onChange:e=>{let t=k.find(t=>t.key===e.target.value);t&&(_(t.key),y(t.dir))},children:k.map(e=>(0,g.jsx)(`option`,{value:e.key,children:e.label},e.key))})})]}),(0,g.jsxs)(`div`,{className:`activity-control activity-visibility`,children:[(0,g.jsx)(u,{checked:S,onChange:C,label:`Busy`}),(0,g.jsx)(u,{checked:w,onChange:T,label:`Idle`})]})]}),(0,g.jsxs)(`div`,{className:`activity-range-note`,children:[$===null?`Active time, tokens and cost cover each conversation’s whole history.`:`Active time, tokens and cost cover ${$.from} to ${$.to} (UTC), inclusive.`,i.fullRangeFallback&&(0,g.jsxs)(`strong`,{className:`activity-range-rejected`,children:[` `,`The range was not accepted, so these are all-time figures.`]})]}),(0,g.jsx)(`div`,{className:`activity-census`,children:Z===null?`No census collected yet, so memory and CPU are unavailable.`:`Memory and CPU measured ${F(Q)} ago, averaged over the minute before that · ${Z.cpuNull} of ${Z.live} without a CPU reading`}),ne&&(0,g.jsxs)(`div`,{className:`activity-warning`,children:[(0,g.jsx)(p,{size:14}),` `,X.onDisk,` account folders on disk but only`,` `,X.valid,` are readable. Sessions belonging to the rest cannot be attributed.`]}),V.length===0?(0,g.jsx)(`div`,{className:`activity-empty`,children:`No sessions are running.`}):U.length===0?(0,g.jsxs)(`div`,{className:`activity-empty`,children:[`All `,V.length,` running sessions are hidden by the Busy and Idle filters.`]}):(0,g.jsx)(`div`,{className:`activity-grid`,children:U.map(e=>{let n=e.accountId!==null&&!!t,r=n?()=>void L(e.accountId,e.sessionId):void 0;return(0,g.jsxs)(`article`,{className:`activity-card${n?` activity-card-clickable`:``}`,"data-testid":`activity-card`,"data-session-id":e.sessionId,role:n?`button`:void 0,tabIndex:n?0:void 0,onClick:r,onKeyDown:n?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r())}:void 0,children:[(0,g.jsx)(`h3`,{className:`activity-card-heading`,title:e.accountId??void 0,children:e.accountId===null?(0,g.jsx)(`span`,{className:`activity-untagged`,title:`This session records no account, so it cannot be attributed to a business.`,children:`untagged`}):N(e.accountId,X.names)}),(0,g.jsx)(`dl`,{className:`activity-card-rows`,children:A.map(t=>(0,g.jsxs)(`div`,{className:`activity-card-row`,children:[(0,g.jsx)(`dt`,{className:`activity-card-label`,"data-testid":`activity-card-label`,title:t.help,children:t.label}),(0,g.jsx)(`dd`,{className:`activity-card-value`,title:t.key===`costGbp`?O(e):void 0,children:J(t.key,e,te)})]},t.key))})]},e.sessionId)})}),V.length>0&&(0,g.jsxs)(`div`,{className:`activity-glossary`,children:[(0,g.jsxs)(`dl`,{className:`activity-legend`,children:[D&&(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,"data-testid":`activity-glossary-term`,children:M.label}),(0,g.jsx)(`dd`,{className:`activity-legend-def`,children:M.help})]},`heading`),(D?A:A.filter(e=>j.includes(e.key))).map(e=>(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,"data-testid":`activity-glossary-term`,children:e.label}),(0,g.jsx)(`dd`,{className:`activity-legend-def`,children:e.help})]},e.key)),(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,children:P}),(0,g.jsxs)(`dd`,{className:`activity-legend-def`,children:[`Not measured. It does not mean zero — a measured zero is written as a figure, so `,(0,g.jsx)(`em`,{children:`0h 0m`}),` and `,(0,g.jsx)(`em`,{children:`£0.00`}),` are real readings. Hover a dashed value for the reason where one exists.`]})]})]}),(0,g.jsx)(f,{variant:`secondary`,size:`sm`,className:`activity-glossary-toggle`,onClick:()=>I(e=>!e),children:D?`Show fewer`:`Explain every figure`})]}),(0,g.jsx)(E,{loops:i?.loops})]})}function X({cacheKey:e}){let{adminFetch:t}=i({initialCacheKey:e,surface:`activity`});return(0,g.jsx)(Y,{adminFetch:t,cacheKey:e})}function Z(){let[e,t]=(0,h.useState)(null),[n,i]=(0,h.useState)(!1),[a,o]=(0,h.useState)(void 0),[s,u]=(0,h.useState)(null),[f,p]=(0,h.useState)(null),[m,_]=(0,h.useState)(null),[v,y]=(0,h.useState)(null);(0,h.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(D)}catch{}if(!n){t(null),i(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async r=>{if(!e){if(r.status===401){try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`;return}if(r.ok)try{let e=await r.json();typeof e.businessName==`string`&&o(e.businessName),e.sessionId!==void 0&&u(e.sessionId??null),p(e.role??null),_(e.userName===void 0?null:e.userName),y(e.avatar??null)}catch{}t(n),i(!0)}}).catch(()=>{e||(t(n),i(!0))}),()=>{e=!0}},[]);let b=(0,h.useCallback)(()=>{try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`},[]),[x,S]=(0,h.useState)(!1),C=(0,h.useCallback)(async()=>{S(!0);try{let e=await l();if(e){try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`}return e}finally{S(!1)}},[]);return n?e?(0,g.jsx)(c,{cacheKey:e,surface:`activity`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=activity`);try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`},children:(0,g.jsx)(d,{cacheKey:e,businessName:a,sessionId:s,onLogout:b,onDisconnect:C,disconnecting:x,userName:m,userAvatar:v,role:f,children:(0,g.jsx)(X,{cacheKey:e})})}):(0,g.jsx)(`div`,{className:`activity-page`,children:(0,g.jsxs)(`div`,{className:`activity-empty`,children:[(0,g.jsx)(`p`,{children:`You are not signed in.`}),(0,g.jsxs)(`p`,{children:[`Open the `,(0,g.jsx)(`a`,{href:`/`,className:`activity-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,g.jsx)(`div`,{className:`activity-page`,children:(0,g.jsxs)(`div`,{className:`activity-loading`,children:[(0,g.jsx)(r,{size:18,className:`spin`}),` Loading…`]})})}(0,m.createRoot)(document.getElementById(`root`)).render((0,g.jsx)(Z,{}));
1
+ import{o as e}from"./chunk-CltuBf4Z.js";import{B as t,F as n,G as r,H as i,N as a,U as o,n as s,p as c}from"./useSubAccountSwitcher-DVmWZxar.js";import{C as l,T as u,t as d,w as f}from"./AdminShell-C8hBpL9K.js";import{t as p}from"./triangle-alert-rEVGyIhi.js";var m=o(),h=e(r(),1),g=t(),_=`—`;function v(e){switch(e){case`waiting`:return`Waiting`;case`never-run`:return`Never run`;case`never-succeeded`:return`Never succeeded`;case`failing`:return`Failing`;case`stalled`:return`Stalled`;case`running`:return`Running`;case`ok`:return`Healthy`}}var y={waiting:`Armed and not due yet. It has no start-up run and its first interval has not elapsed, so it has correctly not fired.`,"never-run":`Its interval has elapsed and it still has not fired once. This is not the same as waiting its turn.`,"never-succeeded":`It has fired, and not one run has finished. The work this loop exists to do has never happened.`,failing:`It worked before and is failing now.`,stalled:`It has not started within three of its own intervals. Something is holding it up.`,running:`A run is in progress right now.`,ok:`The last run finished and the next is due within the interval.`},b=new Set([`never-run`,`never-succeeded`,`failing`,`stalled`]),x=10;function S(e){return e===null||!Number.isFinite(e)?_:`${e.toFixed(1)}%`}function C(e){return e<6e4?`${Math.round(e/1e3)}s`:e<36e5?`${Math.round(e/6e4)}m`:`${Math.round(e/36e5)}h`}function w(e,t){if(e===null)return _;let n=t-e;return n<0?`in ${C(-n)}`:n<6e4?`${Math.round(n/1e3)}s ago`:n<36e5?`${Math.round(n/6e4)}m ago`:`${Math.round(n/36e5)}h ago`}function T(e,t){if(e===null)return _;let n=e-t;return n>=0?`in ${C(n)}`:`overdue by ${C(-n)}`}function E({loops:e,nowMs:t=Date.now()}){let[n,r]=(0,h.useState)(!1);if(!e)return(0,g.jsxs)(`section`,{className:`activity-loops`,children:[(0,g.jsx)(`h2`,{className:`activity-loops-heading`,children:`Scheduled work`}),(0,g.jsx)(`p`,{className:`activity-loops-empty`,children:`Scheduled work could not be read from the server.`})]});let i=e.armed-e.rows.length,a=e.rows.filter(e=>b.has(e.state)),o=e.rows.filter(e=>!b.has(e.state)&&typeof e.cpuPct==`number`&&e.cpuPct>=x),s=n?e.rows:[...a,...o];return(0,g.jsxs)(`section`,{className:`activity-loops`,children:[(0,g.jsx)(`h2`,{className:`activity-loops-heading`,children:`Scheduled work`}),(0,g.jsxs)(`p`,{className:`activity-loops-sub`,children:[e.armed,` `,e.armed===1?`loop`:`loops`,` armed`,a.length>0?` · ${a.length} ${a.length===1?`needs`:`need`} attention`:` · all healthy`,o.length>0&&` · ${o.length} using significant processor`,`. `,(0,g.jsx)(`button`,{type:`button`,className:`activity-loops-toggle`,"aria-expanded":n,onClick:()=>r(e=>!e),children:n?`Show less`:`Show all`})]}),typeof e.processPct==`number`&&(0,g.jsxs)(`p`,{className:`activity-loops-cpu`,children:[`Server process at `,e.processPct.toFixed(1),`% of one core`,typeof e.attributedPct==`number`&&(0,g.jsxs)(g.Fragment,{children:[` · these loops explain `,e.attributedPct.toFixed(1),`%`]}),typeof e.unattributedPct==`number`&&e.unattributedPct>=1&&(0,g.jsxs)(g.Fragment,{children:[` · `,(0,g.jsxs)(`strong`,{children:[e.unattributedPct.toFixed(1),`% is not from these loops`]})]})]}),i>0&&(0,g.jsxs)(`p`,{className:`activity-loops-omission`,role:`status`,children:[i,` armed `,i===1?`loop is`:`loops are`,` missing from this list. The server armed `,e.armed,` but sent `,e.rows.length,`.`]}),s.length===0?null:(0,g.jsx)(`div`,{className:`activity-table-scroll`,children:(0,g.jsxs)(`table`,{className:`activity-table`,children:[(0,g.jsx)(`thead`,{children:(0,g.jsxs)(`tr`,{children:[(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Loop`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`State`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Every`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Last run`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Last OK`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Took`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`CPU`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Runs`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Produced`}),(0,g.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Next due`})]})}),(0,g.jsx)(`tbody`,{children:s.map(e=>(0,g.jsxs)(`tr`,{className:b.has(e.state)?`activity-loop-row activity-loop-unhealthy`:`activity-loop-row`,children:[(0,g.jsx)(`td`,{className:`activity-td`,children:e.name}),(0,g.jsx)(`td`,{className:`activity-td`,title:y[e.state],children:(0,g.jsxs)(`span`,{className:`activity-state`,children:[(0,g.jsx)(`span`,{className:e.state===`ok`?`activity-state-dot is-healthy`:b.has(e.state)?`activity-state-dot is-unhealthy`:`activity-state-dot`,"aria-hidden":`true`}),v(e.state)]})}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:C(e.intervalMs)}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:w(e.lastStartMs,t)}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:w(e.lastSuccessMs,t)}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:e.lastDurationMs===null?_:`${e.lastDurationMs} ms`}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,title:e.cpuAttributable?e.detached?`Includes the processor time of the separate process this loop starts.`:void 0:`This loop waits on other work while it runs, so the processor time it uses cannot be separated from the rest of the server.`,children:S(e.cpuPct)}),(0,g.jsxs)(`td`,{className:`activity-td activity-num`,children:[e.successCount,`/`,e.runCount]}),(0,g.jsx)(`td`,{className:`activity-td activity-loop-note`,children:(0,g.jsx)(`span`,{className:`activity-loop-note-text`,title:e.lastError??e.lastNote??void 0,children:e.lastError??e.lastNote??_})}),(0,g.jsx)(`td`,{className:`activity-td activity-num`,children:T(e.nextDueMs,t)})]},e.name))})]})}),(0,g.jsxs)(`dl`,{className:`activity-legend`,children:[(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,children:`Runs`}),(0,g.jsx)(`dd`,{className:`activity-legend-def`,children:`Finished runs out of attempted runs since the server started. 0 out of a large number means it has tried many times and never once finished.`})]}),(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,children:`CPU`}),(0,g.jsx)(`dd`,{className:`activity-legend-def`,children:`Share of one processor core this loop is using, measured between the last two refreshes. It includes any separate process the loop starts, and can pass 100% because those run alongside each other. A dash means it could not be measured: the loop waits on other work while it runs, so its share cannot be separated from the rest of the server.`})]}),(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,children:_}),(0,g.jsx)(`dd`,{className:`activity-legend-def`,children:`Not measured. It does not mean zero.`})]})]})]})}var D=`maxy-admin-session-key`;function O(e){switch(e.costUnavailable){case`metering-failed`:return`Cost could not be calculated: ${e.meteringError??`the transcript could not be read`}`;case`model-not-priced`:return`No published price for this model, so cost cannot be estimated.`;case`no-transcript`:return`This session has no transcript yet, so there is nothing to cost.`;default:return}}var k=[{key:`lastMessageAt`,label:`Last activity`,dir:-1},{key:`activeMsInRange`,label:`Active time`,dir:-1},{key:`costGbp`,label:`Cost`,dir:-1},{key:`accountId`,label:`Account name`,dir:1}],A=[{key:`title`,label:`Session`,help:`The conversation name, or its short id when it has none yet.`},{key:`model`,label:`Model`,help:`The model that answered the most recent turn.`},{key:`status`,label:`Status`,help:`What the process is doing right now.`},{key:`activeMsInRange`,label:`Active`,help:`Time this session spent thinking, writing and running tools inside the selected range. This is worked time, not elapsed time.`},{key:`ageMs`,label:`Age`,help:`How long ago this conversation started. Wall-clock, so it counts every hour nobody was working.`},{key:`lastMessageAt`,label:`Last activity`,help:`The clock time of the most recent message, in your timezone. A date appears once it is not today.`},{key:`turnCount`,label:`Turns`,help:`Messages exchanged. A trailing + means the count is a minimum — the conversation is too long to count exactly.`},{key:`rssKb`,label:`RAM`,help:`Memory held by this session and all its helper processes together.`},{key:`cpuPct`,label:`CPU (avg)`,help:`AVERAGE share of one processor core over the last census interval, up to 60 seconds. It is not a reading of this instant, so a session that answered a turn a minute ago still shows a high figure while sitting quiet now. Can exceed 100% because a session runs many processes at once.`},{key:`tokensInRange`,label:`Tokens`,help:`Total tokens billed inside the selected range, added up across every day in it. A cumulative total, not the size of the conversation the model currently reads back.`},{key:`costGbp`,label:`Cost`,help:`Estimated spend inside the selected range, at published prices for this model.`}],j=[`activeMsInRange`,`lastMessageAt`,`cpuPct`,`tokensInRange`],M={label:`Account`,help:`The business this session belongs to. "untagged" means the session records no account.`};function N(e,t){let n=t?.[e];return n&&n.trim()!==``?n:e.slice(0,8)}var P=`—`;function F(e){if(e===null||!Number.isFinite(e)||e<0)return P;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d ${r%24}h`}function I(e){return e===null||!Number.isFinite(e)?P:`${(e/1024/1024).toFixed(1)} GB`}function L(e,t){if(!e)return P;let n=Date.parse(e);if(!Number.isFinite(n))return P;let r=new Date(n),i=new Date(t),a=`${String(r.getHours()).padStart(2,`0`)}:${String(r.getMinutes()).padStart(2,`0`)}`;return r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()&&r.getDate()===i.getDate()?a:`${r.getDate()} ${r.toLocaleString(`en-GB`,{month:`short`})} ${a}`}function R(e){return e===null||!Number.isFinite(e)?P:`${e.toFixed(1)}%`}function z(e){return e===null||!Number.isFinite(e)?P:e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function B(e){return e===null||!Number.isFinite(e)?P:`£${e.toFixed(2)}`}function V(e){if(e===null||!Number.isFinite(e)||e<0)return P;let t=Math.floor(e/6e4);return`${Math.floor(t/60)}h ${t%60}m`}function H(e,t,n,r){let i=e[n],a=t[n];if(i===null&&a===null)return 0;if(i===null)return 1;if(a===null)return-1;if(n===`lastMessageAt`){let e=Date.parse(String(i)),t=Date.parse(String(a));return!Number.isFinite(e)&&!Number.isFinite(t)?0:Number.isFinite(e)?Number.isFinite(t)?(e-t)*r:-1:1}return typeof i==`number`&&typeof a==`number`?(i-a)*r:String(i).localeCompare(String(a))*r}function U(e){return e.toISOString().slice(0,10)}function W(e){let t=e.getUTCFullYear(),n=e.getUTCMonth();return{from:U(new Date(Date.UTC(t,n,1))),to:U(new Date(Date.UTC(t,n+1,0)))}}function G(e,t){let n=new Date(`${e}T00:00:00.000Z`);return W(new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+t,1)))}function ee(e,t){return{from:U(new Date(t-(e-1)*864e5)),to:U(new Date(t))}}function K(e){return new Date(`${e}T00:00:00.000Z`).toLocaleString(`en-GB`,{month:`long`,year:`numeric`,timeZone:`UTC`})}function q(e){if(e===null)return!1;let t=W(new Date(`${e.from}T00:00:00.000Z`));return t.from===e.from&&t.to===e.to}function J(e,t,n){switch(e){case`title`:return t.title??t.sessionId.slice(0,8);case`model`:return t.model??P;case`status`:return t.status??P;case`activeMsInRange`:return V(t.activeMsInRange);case`ageMs`:return F(t.ageMs);case`lastMessageAt`:return L(t.lastMessageAt,n);case`turnCount`:return t.turnCount===null?P:`${t.turnCount}${t.turnCountCapped?`+`:``}`;case`rssKb`:return I(t.rssKb);case`cpuPct`:return R(t.cpuPct);case`tokensInRange`:return z(t.tokensInRange);case`costGbp`:return B(t.costGbp);default:return P}}function Y({adminFetch:e,cacheKey:t}){let[r,i]=(0,h.useState)(null),[o,c]=(0,h.useState)(null),[u,d]=(0,h.useState)(!1),[m,_]=(0,h.useState)(`lastMessageAt`),[v,y]=(0,h.useState)(-1),[b,x]=(0,h.useState)(()=>W(new Date)),[S,C]=(0,h.useState)(!0),[w,T]=(0,h.useState)(!0),[D,I]=(0,h.useState)(!1),L=(0,h.useCallback)(async(e,n)=>{t&&await s(t,e)&&(console.info(`[admin-ui] activity-card-open account=${e.slice(0,8)} session=${n.slice(0,8)}`),window.location.assign(`/chat?session=${encodeURIComponent(n)}`))},[t]),R=(0,h.useRef)(!1),z=(0,h.useRef)(void 0),B=(0,h.useCallback)(async t=>{if(R.current){z.current=t;return}R.current=!0;try{let n=await e(`/api/admin/activity${t?`?from=${t.from}&to=${t.to}`:``}`);if(n.status===403){c(`This view is available to the house account only.`),d(!0);return}if(!n.ok){c(`The session manager did not answer (status ${n.status}).`),d(!0);return}i(await n.json()),c(null)}catch(e){c(e instanceof Error?e.message:String(e))}finally{d(!0),R.current=!1;let e=z.current;z.current=void 0,e!==void 0&&B(e)}},[e]);(0,h.useEffect)(()=>{B(b);let e=setInterval(()=>void B(b),15e3);return()=>clearInterval(e)},[B,b]);let V=(0,h.useMemo)(()=>r?[...r.rows].sort((e,t)=>H(e,t,m,v)):[],[r,m,v]),U=(0,h.useMemo)(()=>V.filter(e=>e.status===`busy`?S:e.status===`idle`?w:!0),[V,S,w]),Y=V.length-U.length;if(!u)return(0,g.jsx)(n,{surface:`gate`});if(o)return(0,g.jsx)(`div`,{className:`activity-empty`,children:o});if(!r)return(0,g.jsx)(`div`,{className:`activity-empty`,children:`No response.`});let{accounts:X,census:Z,censusAgeMs:Q}=r,te=Date.now(),ne=X.onDisk!==null&&X.onDisk>X.valid,$=r.range===void 0?b:r.range;return(0,g.jsxs)(`div`,{className:`activity-body`,children:[(0,g.jsxs)(`div`,{className:`activity-head`,children:[(0,g.jsxs)(`span`,{className:`activity-title`,children:[(0,g.jsx)(a,{size:16}),` Live sessions`]}),(0,g.jsxs)(`span`,{className:`activity-meta`,children:[Y>0?`${U.length} of ${V.length} live · ${Y} hidden`:`${V.length} live`,` · `,X.valid,` accounts`,X.untaggedCount>0?` · ${X.untaggedCount} untagged`:``]})]}),(0,g.jsxs)(`div`,{className:`activity-controls`,children:[(0,g.jsxs)(`div`,{className:`activity-control activity-range`,children:[(0,g.jsx)(l,{variant:`secondary`,size:`sm`,"aria-label":`Previous month`,disabled:!q(b),onClick:()=>x(e=>e&&G(e.from,-1)),children:`‹`}),(0,g.jsx)(`span`,{className:`activity-range-label`,children:b===null?`All time`:q(b)?K(b.from):`${b.from} → ${b.to}`}),(0,g.jsx)(l,{variant:`secondary`,size:`sm`,"aria-label":`Next month`,disabled:!q(b),onClick:()=>x(e=>e&&G(e.from,1)),children:`›`})]}),(0,g.jsxs)(`div`,{className:`activity-control activity-presets`,children:[(0,g.jsx)(l,{variant:`secondary`,size:`sm`,"aria-pressed":b!==null&&q(b)&&b.from===W(new Date).from,onClick:()=>x(W(new Date)),children:`This month`}),(0,g.jsx)(l,{variant:`secondary`,size:`sm`,"aria-pressed":b!==null&&!q(b),onClick:()=>x(ee(7,Date.now())),children:`Last 7 days`}),(0,g.jsx)(l,{variant:`secondary`,size:`sm`,"aria-pressed":b===null,onClick:()=>x(null),children:`All time`})]}),(0,g.jsxs)(`div`,{className:`activity-control`,children:[(0,g.jsx)(`label`,{className:`activity-control-label`,htmlFor:`activity-sort`,children:`Sort by`}),(0,g.jsx)(`span`,{className:`activity-select-wrap`,children:(0,g.jsx)(`select`,{id:`activity-sort`,className:`activity-select`,value:m,onChange:e=>{let t=k.find(t=>t.key===e.target.value);t&&(_(t.key),y(t.dir))},children:k.map(e=>(0,g.jsx)(`option`,{value:e.key,children:e.label},e.key))})})]}),(0,g.jsxs)(`div`,{className:`activity-control activity-visibility`,children:[(0,g.jsx)(f,{checked:S,onChange:C,label:`Busy`}),(0,g.jsx)(f,{checked:w,onChange:T,label:`Idle`})]})]}),(0,g.jsxs)(`div`,{className:`activity-range-note`,children:[$===null?`Active time, tokens and cost cover each conversation’s whole history.`:`Active time, tokens and cost cover ${$.from} to ${$.to} (UTC), inclusive.`,r.fullRangeFallback&&(0,g.jsxs)(`strong`,{className:`activity-range-rejected`,children:[` `,`The range was not accepted, so these are all-time figures.`]})]}),(0,g.jsx)(`div`,{className:`activity-census`,children:Z===null?`No census collected yet, so memory and CPU are unavailable.`:`Memory and CPU measured ${F(Q)} ago, averaged over the minute before that · ${Z.cpuNull} of ${Z.live} without a CPU reading`}),ne&&(0,g.jsxs)(`div`,{className:`activity-warning`,children:[(0,g.jsx)(p,{size:14}),` `,X.onDisk,` account folders on disk but only`,` `,X.valid,` are readable. Sessions belonging to the rest cannot be attributed.`]}),V.length===0?(0,g.jsx)(`div`,{className:`activity-empty`,children:`No sessions are running.`}):U.length===0?(0,g.jsxs)(`div`,{className:`activity-empty`,children:[`All `,V.length,` running sessions are hidden by the Busy and Idle filters.`]}):(0,g.jsx)(`div`,{className:`activity-grid`,children:U.map(e=>{let n=e.accountId!==null&&!!t,r=n?()=>void L(e.accountId,e.sessionId):void 0;return(0,g.jsxs)(`article`,{className:`activity-card${n?` activity-card-clickable`:``}`,"data-testid":`activity-card`,"data-session-id":e.sessionId,role:n?`button`:void 0,tabIndex:n?0:void 0,onClick:r,onKeyDown:n?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r())}:void 0,children:[(0,g.jsx)(`h3`,{className:`activity-card-heading`,title:e.accountId??void 0,children:e.accountId===null?(0,g.jsx)(`span`,{className:`activity-untagged`,title:`This session records no account, so it cannot be attributed to a business.`,children:`untagged`}):N(e.accountId,X.names)}),(0,g.jsx)(`dl`,{className:`activity-card-rows`,children:A.map(t=>(0,g.jsxs)(`div`,{className:`activity-card-row`,children:[(0,g.jsx)(`dt`,{className:`activity-card-label`,"data-testid":`activity-card-label`,title:t.help,children:t.label}),(0,g.jsx)(`dd`,{className:`activity-card-value`,title:t.key===`costGbp`?O(e):void 0,children:J(t.key,e,te)})]},t.key))})]},e.sessionId)})}),V.length>0&&(0,g.jsxs)(`div`,{className:`activity-glossary`,children:[(0,g.jsxs)(`dl`,{className:`activity-legend`,children:[D&&(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,"data-testid":`activity-glossary-term`,children:M.label}),(0,g.jsx)(`dd`,{className:`activity-legend-def`,children:M.help})]},`heading`),(D?A:A.filter(e=>j.includes(e.key))).map(e=>(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,"data-testid":`activity-glossary-term`,children:e.label}),(0,g.jsx)(`dd`,{className:`activity-legend-def`,children:e.help})]},e.key)),(0,g.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,g.jsx)(`dt`,{className:`activity-legend-term`,children:P}),(0,g.jsxs)(`dd`,{className:`activity-legend-def`,children:[`Not measured. It does not mean zero — a measured zero is written as a figure, so `,(0,g.jsx)(`em`,{children:`0h 0m`}),` and `,(0,g.jsx)(`em`,{children:`£0.00`}),` are real readings. Hover a dashed value for the reason where one exists.`]})]})]}),(0,g.jsx)(l,{variant:`secondary`,size:`sm`,className:`activity-glossary-toggle`,onClick:()=>I(e=>!e),children:D?`Show fewer`:`Explain every figure`})]}),(0,g.jsx)(E,{loops:r?.loops})]})}function X({cacheKey:e}){let{adminFetch:t}=i({initialCacheKey:e,surface:`activity`});return(0,g.jsx)(Y,{adminFetch:t,cacheKey:e})}function Z(){let[e,t]=(0,h.useState)(null),[r,i]=(0,h.useState)(!1),[a,o]=(0,h.useState)(void 0),[s,l]=(0,h.useState)(null),[f,p]=(0,h.useState)(null),[m,_]=(0,h.useState)(null),[v,y]=(0,h.useState)(null);(0,h.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(D)}catch{}if(!n){t(null),i(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async r=>{if(!e){if(r.status===401){try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`;return}if(r.ok)try{let e=await r.json();typeof e.businessName==`string`&&o(e.businessName),e.sessionId!==void 0&&l(e.sessionId??null),p(e.role??null),_(e.userName===void 0?null:e.userName),y(e.avatar??null)}catch{}t(n),i(!0)}}).catch(()=>{e||(t(n),i(!0))}),()=>{e=!0}},[]);let b=(0,h.useCallback)(()=>{try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`},[]),[x,S]=(0,h.useState)(!1),C=(0,h.useCallback)(async()=>{S(!0);try{let e=await u();if(e){try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`}return e}finally{S(!1)}},[]);return r?e?(0,g.jsx)(c,{cacheKey:e,surface:`activity`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=activity`);try{sessionStorage.removeItem(D)}catch{}window.location.href=`/`},children:(0,g.jsx)(d,{cacheKey:e,businessName:a,sessionId:s,onLogout:b,onDisconnect:C,disconnecting:x,userName:m,userAvatar:v,role:f,children:(0,g.jsx)(X,{cacheKey:e})})}):(0,g.jsx)(`div`,{className:`activity-page`,children:(0,g.jsxs)(`div`,{className:`activity-empty`,children:[(0,g.jsx)(`p`,{children:`You are not signed in.`}),(0,g.jsxs)(`p`,{children:[`Open the `,(0,g.jsx)(`a`,{href:`/`,className:`activity-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,g.jsx)(n,{surface:`gate`})}(0,m.createRoot)(document.getElementById(`root`)).render((0,g.jsx)(Z,{}));
@@ -0,0 +1 @@
1
+ import{o as e}from"./chunk-CltuBf4Z.js";import{B as t,D as n,G as r,U as i,a,l as o,m as s,p as c,s as l,v as u}from"./useSubAccountSwitcher-DVmWZxar.js";import{n as d,t as f}from"./AdminLoginScreens-DWMR4KtI.js";import{s as p}from"./useVoiceRecorder-CRRmPjYr.js";import{a as m,b as h,f as g,t as _,y as v}from"./AdminShell-C8hBpL9K.js";import{a as y,i as b,n as x,r as S}from"./page-DoyJrk8E.js";import{t as C}from"./chevron-left-BoDA12H8.js";import{t as w}from"./chevron-right-DXjrO6qA.js";import{t as T}from"./file-text-RCoSeOpD.js";import"./graph-labels-DJV0aIG5.js";var E=i(),D=e(r(),1),O=t();function k({onOpen:e}){return(0,O.jsx)(`footer`,{className:`admin-footer`,children:(0,O.jsxs)(`div`,{className:`powered-by`,role:`button`,tabIndex:0,onClick:e,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e())},"aria-label":`Powered by Claude Code — show details`,children:[(0,O.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`powered-by-icon`}),(0,O.jsx)(`span`,{children:`Powered by Claude Code`})]})})}function A({sessionId:e,projectDir:t,sessionKey:n,contactName:r,onBack:i}){return(0,O.jsxs)(`div`,{className:`wa-web`,children:[(0,O.jsxs)(`header`,{className:`wa-web-header`,children:[i&&(0,O.jsx)(`button`,{type:`button`,className:`wa-web-back`,onClick:i,"aria-label":`Back`,children:(0,O.jsx)(C,{size:20})}),(0,O.jsx)(`span`,{className:`wa-web-avatar`,"aria-hidden":!0,children:(0,O.jsx)(y,{size:20})}),(0,O.jsx)(`div`,{className:`wa-web-titles`,children:(0,O.jsx)(`span`,{className:`wa-web-name`,children:r})})]}),(0,O.jsx)(`div`,{className:`wa-web-body`,children:(0,O.jsx)(p,{sessionId:e,projectDir:t,sessionKey:n,forceDeliveredOnly:!0})})]})}var j=6e4,M=60*j,N=24*M,P=j,F=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],I=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];function L(e){return e<10?`0${e}`:String(e)}function R(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}function z(e,t){if(!Number.isFinite(e)||e<=0||!Number.isFinite(t))return`—`;let n=t-e;if(n<-P)return`—`;let r=n<0?0:n;if(r<j)return`just now`;if(r<M)return`${Math.floor(r/j)}m`;if(r<N)return`${Math.floor(r/M)}h`;let i=new Date(t),a=new Date(e),o=Math.round((R(i)-R(a))/N);if(o===1)return`yesterday`;if(o>=2&&o<=6)return I[a.getDay()];let s=L(a.getDate()),c=F[a.getMonth()];return a.getFullYear()===i.getFullYear()?`${s} ${c}`:`${s} ${c} ${a.getFullYear()}`}var B={whatsapp:`WhatsApp`,telegram:`Telegram`,webchat:`Web chat`},V=15e3;function H(e){return e<12?`morning`:e<18?`afternoon`:`evening`}function U(e){return e&&e.trim().split(/\s+/)[0]||`there`}function W(e){if(!e)return`everything is running normally.`;let t=e.cpuPct,n=e.memUsedPct;return t!==null&&t>=.98||n!==null&&n>=.98?`system load is critical.`:t!==null&&t>=.9||n!==null&&n>=.9?`system load is high.`:`everything is running normally.`}function G(e){return e==null?`—`:`${Math.round(e*100)}%`}function K(e){return e.operatorName??e.whatsappName??e.senderId??e.title}function q(e,t){if(!e)return!1;let n=Date.parse(e);if(!Number.isFinite(n))return!1;let r=new Date(n),i=new Date(t);return r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()&&r.getDate()===i.getDate()}function J(e){return e?e.replace(/^claude-/,``):null}function Y({cacheKey:e,userName:t,onSelectWhatsappConversation:r}){let i=s(e),[c,d]=(0,D.useState)(null),[f,p]=(0,D.useState)(null),[m,_]=(0,D.useState)(null),[y,b]=(0,D.useState)(null),[x,C]=(0,D.useState)(null),[E,k]=(0,D.useState)(null),[A,j]=(0,D.useState)(null),[M,N]=(0,D.useState)(new Set),P=Date.now(),F=(0,D.useRef)(!1);(0,D.useEffect)(()=>{if(!e)return;let t=!1;async function n(e,n,r){try{let a=await i(e);if(!a.ok)throw Error(`status ${a.status}`);let o=await a.json();t||r(n(o))}catch(t){console.error(`[admin-ui] dashboard-fetch-failed url=${e} reason=${t instanceof Error?t.message:String(t)}`)}}async function r(){if(!F.current){F.current=!0;try{await Promise.all([n(`/api/admin/sidebar-sessions`,e=>e.sessions??[],d),n(`/api/whatsapp-reader/conversations-all`,e=>e.conversations??[],p),n(`/api/admin/system-stats`,e=>e,b),n(`/api/admin/tasks-list`,e=>e,C),n(`/api/admin/sidebar-artefacts`,e=>e.artefacts??[],k),n(`/api/admin/skills`,e=>e.skills??[],j)])}finally{F.current=!1}}}r();let a=setInterval(()=>{document.visibilityState===`visible`&&(console.info(`[admin-ui] dashboard-refresh trigger=poll`),r())},V),o=()=>{document.visibilityState===`visible`&&r()};return document.addEventListener(`visibilitychange`,o),()=>{t=!0,clearInterval(a),document.removeEventListener(`visibilitychange`,o)}},[e,i]);let I=(0,D.useMemo)(()=>(c??[]).filter(e=>!e.isSubagent),[c]),L=(0,D.useMemo)(()=>I.filter(e=>e.live),[I]),R=(0,D.useMemo)(()=>(f??[]).filter(e=>q(e.lastMessageAt,P)).length,[f,P]),Y=x?.open.length??0,X=(0,D.useMemo)(()=>{let e=new Map;for(let t of f??[]){let n=e.get(t.channel)??[];n.push(t),e.set(t.channel,n)}return[...e.entries()].map(([e,t])=>{let n=t.reduce((e,t)=>t.lastMessageAt&&(!e||Date.parse(t.lastMessageAt)>Date.parse(e.lastMessageAt??``))?t:e,null);return{channel:e,count:t.length,preview:n?K(n):``,rows:t}})},[f]),Z=(0,D.useCallback)(async e=>{if(!M.has(e)){N(t=>new Set(t).add(e));try{let t=await i(`/api/admin/session-stop`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e})});if(!t.ok){console.error(`[admin-ui] dashboard-session-stop-failed sessionId=${e} status=${t.status}`);return}console.info(`[admin-ui] dashboard-session-stop sessionId=${e}`),d(t=>(t??[]).map(t=>t.sessionId===e?{...t,live:!1}:t))}catch(t){console.error(`[admin-ui] dashboard-session-stop-failed sessionId=${e} reason=${t instanceof Error?t.message:String(t)}`)}finally{N(t=>{let n=new Set(t);return n.delete(e),n})}}},[i,M]),Q=(0,D.useCallback)(t=>{if(!e||!t.downloadPath){console.error(`[admin-ui] dashboard-artefact-download-blocked id=${t.id} reason=${e?`not-downloadable`:`no-cache-key`}`);return}S(e,t.downloadPath,t.downloadRoot??`data`)},[e]);return(0,O.jsxs)(`div`,{className:`dashboard-home`,children:[(0,O.jsx)(`p`,{className:`dashboard-greeting`,children:`Good ${H(new Date(P).getHours())}, ${U(t)} — ${W(y)}`}),(0,O.jsxs)(`div`,{className:`dashboard-stats`,children:[(0,O.jsxs)(`div`,{className:`admin-stat-card dashboard-stat-card`,children:[(0,O.jsx)(`span`,{className:`dashboard-stat-label`,children:`Live sessions`}),(0,O.jsx)(`span`,{className:`dashboard-stat-value`,children:L.length}),(0,O.jsxs)(`span`,{className:`dashboard-stat-delta`,children:[`of `,I.length,` total`]})]}),(0,O.jsxs)(`div`,{className:`admin-stat-card dashboard-stat-card`,children:[(0,O.jsx)(`span`,{className:`dashboard-stat-label`,children:`Messages today`}),(0,O.jsx)(`span`,{className:`dashboard-stat-value`,children:R})]}),(0,O.jsxs)(`a`,{className:`admin-stat-card dashboard-stat-card dashboard-stat-card--link`,href:`/tasks`,children:[(0,O.jsx)(`span`,{className:`dashboard-stat-label`,children:`Open tasks`}),(0,O.jsx)(`span`,{className:`dashboard-stat-value`,children:Y})]}),(0,O.jsxs)(`div`,{className:`admin-stat-card dashboard-stat-card`,children:[(0,O.jsx)(`span`,{className:`dashboard-stat-label`,children:`Host CPU`}),(0,O.jsx)(`span`,{className:`dashboard-stat-value`,children:G(y?.cpuPct??null)}),(0,O.jsxs)(`span`,{className:`dashboard-stat-delta`,children:[`RAM `,G(y?.memUsedPct??null)]})]})]}),(0,O.jsxs)(`div`,{className:`dashboard-columns`,children:[(0,O.jsxs)(`div`,{className:`dashboard-col`,children:[(0,O.jsx)(`span`,{className:`admin-section-label dashboard-col-label`,children:`Live now`}),L.length===0?(0,O.jsx)(`div`,{className:`admin-card dashboard-empty`,children:`No live sessions right now.`}):L.map(e=>{let t=[e.sessionId.slice(0,8),J(e.model),z(Date.parse(e.startedAt),P)].filter(Boolean).join(` · `);return(0,O.jsxs)(`div`,{className:`admin-card dashboard-live-card`,children:[(0,O.jsx)(`span`,{className:`admin-status-dot is-live`}),(0,O.jsxs)(`div`,{className:`dashboard-live-main`,children:[(0,O.jsx)(`span`,{className:`dashboard-live-name`,children:e.title}),(0,O.jsx)(`span`,{className:`dashboard-live-meta`,children:t})]}),(0,O.jsx)(`a`,{className:`admin-btn-cta dashboard-open-btn`,href:`/chat?session=${encodeURIComponent(e.sessionId)}`,children:`Open`}),(0,O.jsx)(`button`,{type:`button`,className:`dashboard-stop-btn`,"aria-label":`Stop ${e.title}`,disabled:M.has(e.sessionId),onClick:()=>void Z(e.sessionId),children:(0,O.jsx)(u,{size:12})})]},e.sessionId)}),(0,O.jsx)(`span`,{className:`admin-section-label dashboard-col-label`,children:`Recent artefacts`}),(0,O.jsx)(`div`,{className:`admin-card dashboard-artefacts`,children:(E??[]).length===0?(0,O.jsx)(`div`,{className:`dashboard-empty`,children:`No recent artefacts.`}):(E??[]).slice(0,6).map(e=>(0,O.jsxs)(`button`,{type:`button`,className:`admin-row dashboard-artefact-row`,onClick:()=>Q(e),children:[(0,O.jsx)(`span`,{className:`dashboard-artefact-icon`,children:e.kind===`agent-template`?(0,O.jsx)(h,{size:16}):(0,O.jsx)(T,{size:16})}),(0,O.jsx)(`div`,{className:`dashboard-artefact-body`,children:(0,O.jsx)(`span`,{className:`dashboard-artefact-name`,children:e.name})}),(0,O.jsx)(`span`,{className:`dashboard-artefact-time`,children:z(Date.parse(e.updatedAt),P)})]},e.id))}),(0,O.jsx)(`a`,{className:`admin-section-label dashboard-col-label dashboard-skills-label`,href:`/skills`,children:`Skills`}),(0,O.jsx)(`div`,{className:`admin-card dashboard-skills`,children:(A??[]).length===0?(0,O.jsx)(`div`,{className:`dashboard-empty`,children:`No skills yet.`}):(A??[]).map(e=>(0,O.jsxs)(`a`,{className:`admin-row dashboard-skill-row`,href:`/skills`,children:[(0,O.jsx)(`span`,{className:`dashboard-skill-icon`,children:(0,O.jsx)(g,{size:16})}),(0,O.jsxs)(`div`,{className:`dashboard-skill-body`,children:[(0,O.jsx)(`span`,{className:`dashboard-skill-name`,children:e.skill}),(0,O.jsx)(`span`,{className:`dashboard-skill-plugin`,children:e.plugin})]})]},`${e.plugin}/${e.skill}`))})]}),(0,O.jsxs)(`div`,{className:`dashboard-col`,children:[(0,O.jsx)(`span`,{className:`admin-section-label dashboard-col-label`,children:`Channels`}),X.length===0?(0,O.jsx)(`div`,{className:`admin-card dashboard-empty`,children:`No channel activity.`}):X.map(e=>{let t=m===e.channel;return(0,O.jsxs)(`div`,{className:`admin-card dashboard-channel-card`,children:[(0,O.jsxs)(`button`,{type:`button`,className:`dashboard-channel-head`,"aria-expanded":t,onClick:()=>_(t=>t===e.channel?null:e.channel),children:[(0,O.jsx)(`span`,{className:`dashboard-channel-glyph`,children:e.channel===`whatsapp`||e.channel===`telegram`?(0,O.jsx)(o,{channel:e.channel,size:16}):(0,O.jsx)(n,{size:16})}),(0,O.jsx)(`span`,{className:`dashboard-channel-name`,children:B[e.channel]??e.channel}),(0,O.jsx)(`span`,{className:`dashboard-channel-badge`,children:e.count}),(0,O.jsx)(`span`,{className:`dashboard-channel-chevron`,children:t?(0,O.jsx)(v,{size:14}):(0,O.jsx)(w,{size:14})})]}),t?(0,O.jsx)(`div`,{className:`dashboard-channel-convs`,children:e.rows.map(e=>(0,O.jsxs)(`button`,{type:`button`,className:`admin-row dashboard-channel-conv-row`,onClick:()=>r(e),title:e.title,children:[(0,O.jsx)(`span`,{className:`dashboard-channel-conv-name`,children:a(e)}),(0,O.jsx)(`span`,{className:`dashboard-channel-conv-tag`,children:e.isHouse?`House`:`Client`}),e.lastMessageAt&&(0,O.jsx)(`span`,{className:`dashboard-channel-conv-time`,children:z(Date.parse(e.lastMessageAt),P)})]},l(e)))}):e.preview&&(0,O.jsx)(`span`,{className:`dashboard-channel-preview`,children:e.preview})]},e.channel)})]})]})]})}function X(){let e=d(),[t,n]=(0,D.useState)(!1);(0,D.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&n(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let r=(0,D.useCallback)(async()=>{let t=e.claudeInfo!=null;if(n(!0),t){console.info(`[admin-ui] claude-info-open cached=true ms=0`);return}let r=Date.now();try{let t=await fetch(`/api/admin/claude-info`);if(t.ok){let n=await t.json();e.setClaudeInfo(n)}console.info(`[admin-ui] claude-info-open cached=false ms=${Date.now()-r}`)}catch(e){console.error(`[admin-ui] claude-info-fetch-failed ms=${Date.now()-r} error="${e instanceof Error?e.message:String(e)}"`)}},[e]),i=(0,D.useCallback)(({code:t,path:n})=>{console.warn(`[admin-auth] outcome=chat-tab-logout-on-401 code=${t} path=${n}`),e.handleLogout()},[e]);return e.appState===`chat`?(0,O.jsx)(c,{cacheKey:e.cacheKey,onSessionExpired:i,surface:`chat`,children:(0,O.jsx)(_,{cacheKey:e.cacheKey,businessName:e.businessName,sessionId:e.sessionId,onLogout:e.handleLogout,onDisconnect:e.handleDisconnect,disconnecting:e.disconnecting,claudeConnected:e.claudeConnected,onConnectClaude:()=>e.setAppState(`connect-claude`),userName:e.userName,userAvatar:e.userAvatar,role:e.role,footer:(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(k,{onOpen:r}),(0,O.jsx)(m,{show:t,onClose:()=>n(!1),claudeInfo:e.claudeInfo,messages:[],sessionElapsed:0,sessionId:e.sessionId,cacheKey:e.cacheKey})]}),children:t=>(0,O.jsx)(O.Fragment,{children:t.dataOpen&&e.cacheKey?(0,O.jsx)(x,{cacheKey:e.cacheKey}):t.selectedWhatsapp&&e.cacheKey?t.selectedWhatsapp.source===`store`&&t.selectedWhatsapp.remoteJid&&t.selectedWhatsapp.accountId?(0,O.jsx)(b,{accountId:t.selectedWhatsapp.accountId,remoteJid:t.selectedWhatsapp.remoteJid,contactName:a(t.selectedWhatsapp),sessionKey:e.cacheKey,onBack:t.onClearWhatsapp},l(t.selectedWhatsapp)):(0,O.jsx)(A,{sessionId:t.selectedWhatsapp.sessionId,projectDir:t.selectedWhatsapp.projectDir,sessionKey:e.cacheKey,contactName:a(t.selectedWhatsapp),onBack:t.onClearWhatsapp},l(t.selectedWhatsapp)):(0,O.jsx)(Y,{cacheKey:e.cacheKey,userName:e.userName,onSelectWhatsappConversation:t.onSelectWhatsappConversation})})})}):(0,O.jsx)(f,{auth:e})}(0,E.createRoot)(document.getElementById(`root`)).render((0,O.jsx)(X,{}));
@@ -0,0 +1 @@
1
+ import{o as e}from"./chunk-CltuBf4Z.js";import{B as t,F as n,G as r,H as i,T as a,U as o,_ as s,g as c,p as l}from"./useSubAccountSwitcher-DVmWZxar.js";import{T as u,_ as d,b as f,t as p}from"./AdminShell-C8hBpL9K.js";var m=o(),h=e(r(),1),g=t();function _({label:e,body:t}){return(0,g.jsxs)(`div`,{className:`agent-doc`,children:[(0,g.jsx)(`span`,{className:`agent-doc-label`,children:e}),(0,g.jsx)(`pre`,{className:`skill-body`,children:t.trim()||`Empty.`})]})}function v({summary:e,publicBaseUrl:t,adminFetch:n,onClose:r,onDeleted:i}){let[o,l]=(0,h.useState)(null),[u,p]=(0,h.useState)(!0),[m,v]=(0,h.useState)(null),[y,b]=(0,h.useState)(!1),[x,S]=(0,h.useState)(!1);(0,h.useEffect)(()=>{let t=!1;return p(!0),v(null),n(`/api/admin/agents/${encodeURIComponent(e.slug)}`).then(async e=>{if(!t){if(!e.ok)throw Error(`HTTP ${e.status}`);l((await e.json()).agent)}}).catch(e=>{t||v(e instanceof Error?e.message:`Failed to load`)}).finally(()=>{t||p(!1)}),()=>{t=!0}},[n,e.slug]),(0,h.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!x&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[x,r]);let C=(0,h.useCallback)(async()=>{S(!0),v(null);try{let t=await n(`/api/admin/agents/${encodeURIComponent(e.slug)}`,{method:`DELETE`,headers:{"content-type":`application/json`}});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`HTTP ${t.status}`)}i(e)}catch(e){v(e instanceof Error?e.message:`Delete failed`),S(!1),b(!1)}},[n,e,i]);return(0,g.jsx)(`div`,{className:`cal-modal-overlay`,onClick:()=>{x||r()},children:(0,g.jsxs)(`div`,{className:`cal-modal cal-modal-wide`,role:`dialog`,"aria-modal":`true`,"aria-label":`Agent detail`,onClick:e=>e.stopPropagation(),children:[(0,g.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,g.jsxs)(`span`,{className:`cal-modal-kind`,children:[(0,g.jsx)(f,{size:13}),` Agent`]}),(0,g.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:r,"aria-label":`Close`,autoFocus:!0,disabled:x,children:(0,g.jsx)(c,{size:16})})]}),(0,g.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,g.jsx)(`div`,{className:`cal-modal-title`,children:e.displayName}),(0,g.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,g.jsx)(`span`,{className:`agent-status-dot ${e.status}`}),(0,g.jsxs)(`span`,{children:[`/`,e.slug]})]}),u&&(0,g.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,g.jsx)(a,{size:14,className:`spin`}),(0,g.jsx)(`span`,{children:`Loading…`})]}),o&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,g.jsxs)(`span`,{children:[o.status,o.model?` · ${o.model}`:``]})}),(0,g.jsx)(`div`,{className:`cal-modal-row cal-modal-meta`,children:(0,g.jsxs)(`a`,{href:`${t}/${e.slug}`,target:`_blank`,rel:`noopener noreferrer`,className:`cal-link`,children:[(0,g.jsx)(d,{size:13}),` Open agent`]})}),o.present.identity&&(0,g.jsx)(_,{label:`Identity`,body:o.identity}),o.present.soul&&(0,g.jsx)(_,{label:`Soul`,body:o.soul}),o.present.knowledge&&(0,g.jsx)(_,{label:`Knowledge`,body:o.knowledge}),o.present.knowledgeSummary&&(0,g.jsx)(_,{label:`Knowledge summary`,body:o.knowledgeSummary}),o.knowledgeKeywords.length>0&&(0,g.jsxs)(`div`,{className:`skill-refs`,children:[(0,g.jsx)(`span`,{className:`skill-refs-label`,children:`Knowledge keywords`}),o.knowledgeKeywords.map(e=>(0,g.jsx)(`span`,{className:`skill-ref`,children:e},e))]})]})]}),m&&(0,g.jsx)(`div`,{className:`cal-modal-error`,children:m}),(0,g.jsxs)(`div`,{className:`cal-modal-actions`,children:[!y&&(0,g.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:()=>b(!0),disabled:x||u,children:[(0,g.jsx)(s,{size:14}),` Delete`]}),y&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Delete this agent?`}),(0,g.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:C,disabled:x,children:[x?(0,g.jsx)(a,{size:14,className:`spin`}):(0,g.jsx)(s,{size:14}),` Delete`]}),(0,g.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>b(!1),disabled:x,children:`Cancel`})]})]})]})})}var y=`maxy-admin-session-key`;function b(){let[e,t]=(0,h.useState)(null),[r,i]=(0,h.useState)(!1),[a,o]=(0,h.useState)(void 0),[s,c]=(0,h.useState)(null),[d,f]=(0,h.useState)(void 0),[m,_]=(0,h.useState)(null),[v,b]=(0,h.useState)(null);(0,h.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(y)}catch{}if(!n){i(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async r=>{if(!e){if(r.status===401){try{sessionStorage.removeItem(y)}catch{}window.location.href=`/`;return}if(r.ok)try{let e=await r.json();typeof e.businessName==`string`&&o(e.businessName),e.sessionId!==void 0&&c(e.sessionId??null),b(e.role??null),f(e.userName===void 0?null:e.userName),_(e.avatar??null)}catch{}t(n),i(!0)}}).catch(()=>{e||(t(n),i(!0))}),()=>{e=!0}},[]);let S=(0,h.useCallback)(()=>{try{sessionStorage.removeItem(y)}catch{}window.location.href=`/`},[]),[C,w]=(0,h.useState)(!1),T=(0,h.useCallback)(async()=>{w(!0);try{let e=await u();if(e){try{sessionStorage.removeItem(y)}catch{}window.location.href=`/`}return e}finally{w(!1)}},[]);return r?e?(0,g.jsx)(l,{cacheKey:e,surface:`agents`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=agents`);try{sessionStorage.removeItem(y)}catch{}window.location.href=`/`},children:(0,g.jsx)(p,{cacheKey:e,businessName:a,sessionId:s,onLogout:S,onDisconnect:T,disconnecting:C,userName:d,userAvatar:m,role:v,children:(0,g.jsx)(x,{cacheKey:e})})}):(0,g.jsx)(`div`,{className:`cal-page`,children:(0,g.jsxs)(`div`,{className:`cal-empty`,children:[(0,g.jsx)(`p`,{children:`You are not signed in.`}),(0,g.jsxs)(`p`,{children:[`Open the `,(0,g.jsx)(`a`,{href:`/`,className:`cal-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,g.jsx)(n,{surface:`gate`})}function x({cacheKey:e}){let{adminFetch:t,sessionRefetchNonce:r}=i({initialCacheKey:e,surface:`agents`}),[o,s]=(0,h.useState)([]),[c,l]=(0,h.useState)(0),[u,d]=(0,h.useState)(!1),[p,m]=(0,h.useState)(!1),[_,y]=(0,h.useState)(null),[b,x]=(0,h.useState)(null),[S,C]=(0,h.useState)(``);(0,h.useEffect)(()=>{C(window.location.hostname.startsWith(`admin.`)?window.location.origin.replace(`admin.`,`public.`):window.location.origin)},[]);let w=(0,h.useCallback)(()=>{let e=!1;return d(!0),y(null),t(`/api/admin/agents`).then(async t=>{if(e)return;if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();s(Array.isArray(n.agents)?n.agents:[]),l(typeof n.skipped==`number`?n.skipped:0)}).catch(t=>{e||(y(t instanceof Error?t.message:`Failed to load`),s([]))}).finally(()=>{e||(d(!1),m(!0))}),()=>{e=!0}},[t]);(0,h.useEffect)(()=>w(),[w,r]);let T=(0,h.useCallback)(e=>{s(t=>t.filter(t=>t.slug!==e.slug)),x(null),w()},[w]);return p?(0,g.jsxs)(`div`,{className:`cal-page`,children:[(0,g.jsx)(`header`,{className:`cal-header`,children:(0,g.jsxs)(`div`,{className:`cal-nav`,children:[(0,g.jsxs)(`span`,{className:`cal-range-label`,children:[(0,g.jsx)(f,{size:16}),` Agents`]}),u&&(0,g.jsx)(a,{size:16,className:`spin`})]})}),(0,g.jsxs)(`div`,{className:`cal-body`,children:[_&&(0,g.jsxs)(`div`,{className:`cal-error`,children:[`Could not load agents: `,_]}),c>0&&(0,g.jsxs)(`div`,{className:`cal-error`,children:[c,` agent`,c===1?``:`s`,` could not be read (malformed config).`]}),!_&&!u&&o.length===0&&(0,g.jsx)(`div`,{className:`cal-empty`,children:(0,g.jsx)(`p`,{children:`No agents yet. Ask in chat to create one.`})}),o.length>0&&(0,g.jsx)(`div`,{className:`routine-list`,children:o.map(e=>(0,g.jsxs)(`button`,{type:`button`,className:`routine-card`,onClick:()=>x(e),children:[(0,g.jsx)(`span`,{className:`routine-card-title`,children:e.displayName}),(0,g.jsxs)(`span`,{className:`routine-card-sched`,children:[(0,g.jsx)(`span`,{className:`agent-status-dot ${e.status}`}),` /`,e.slug]}),(0,g.jsx)(`span`,{className:`routine-card-meta`,children:e.status})]},e.slug))})]}),b&&(0,g.jsx)(v,{summary:b,publicBaseUrl:S,adminFetch:t,onClose:()=>x(null),onDeleted:T})]}):(0,g.jsx)(n,{surface:`gate`})}(0,m.createRoot)(document.getElementById(`root`)).render((0,g.jsx)(b,{}));
@@ -1 +1 @@
1
- import{n as e,t}from"./path-CoPyR7c2.js";import{a as n,c as r,d as i,f as a,i as o,l as s,m as c,n as l,o as u,p as d,r as f,u as p}from"./dist-cdnE4DqK.js";function m(e){return e.innerRadius}function h(e){return e.outerRadius}function g(e){return e.startAngle}function _(e){return e.endAngle}function v(e){return e&&e.padAngle}function y(e,t,n,r,i,a,o,s){var c=n-e,l=r-t,u=o-i,d=s-a,f=d*c-u*l;if(!(f*f<1e-12))return f=(u*(t-a)-d*(e-i))/f,[e+f*c,t+f*l]}function b(e,t,n,r,i,a,o){var c=e-n,l=t-r,u=(o?a:-a)/d(c*c+l*l),f=u*l,p=-u*c,m=e+f,h=t+p,g=n+f,_=r+p,v=(m+g)/2,y=(h+_)/2,b=g-m,x=_-h,S=b*b+x*x,C=i-a,w=m*_-g*h,T=(x<0?-1:1)*d(s(0,C*C*S-w*w)),E=(w*x-b*T)/S,D=(-w*b-x*T)/S,O=(w*x+b*T)/S,k=(-w*b+x*T)/S,A=E-v,j=D-y,M=O-v,N=k-y;return A*A+j*j>M*M+N*N&&(E=O,D=k),{cx:E,cy:D,x01:-f,y01:-p,x11:E*(i/C-1),y11:D*(i/C-1)}}function x(){var s=m,x=h,S=e(0),C=null,w=g,T=_,E=v,D=null,O=t(k);function k(){var e,t,m=+s.apply(this,arguments),h=+x.apply(this,arguments),g=w.apply(this,arguments)-r,_=T.apply(this,arguments)-r,v=l(_-g),k=_>g;if(D||=e=O(),h<m&&(t=h,h=m,m=t),!(h>1e-12))D.moveTo(0,0);else if(v>c-1e-12)D.moveTo(h*u(g),h*a(g)),D.arc(0,0,h,g,_,!k),m>1e-12&&(D.moveTo(m*u(_),m*a(_)),D.arc(0,0,m,_,g,k));else{var A=g,j=_,M=g,N=_,P=v,F=v,I=E.apply(this,arguments)/2,L=I>1e-12&&(C?+C.apply(this,arguments):d(m*m+h*h)),R=p(l(h-m)/2,+S.apply(this,arguments)),z=R,B=R,V,H;if(L>1e-12){var U=o(L/m*a(I)),W=o(L/h*a(I));(P-=U*2)>1e-12?(U*=k?1:-1,M+=U,N-=U):(P=0,M=N=(g+_)/2),(F-=W*2)>1e-12?(W*=k?1:-1,A+=W,j-=W):(F=0,A=j=(g+_)/2)}var G=h*u(A),K=h*a(A),q=m*u(N),J=m*a(N);if(R>1e-12){var Y=h*u(j),X=h*a(j),Z=m*u(M),Q=m*a(M),$;if(v<i)if($=y(G,K,Z,Q,Y,X,q,J)){var ee=G-$[0],te=K-$[1],ne=Y-$[0],re=X-$[1],ie=1/a(f((ee*ne+te*re)/(d(ee*ee+te*te)*d(ne*ne+re*re)))/2),ae=d($[0]*$[0]+$[1]*$[1]);z=p(R,(m-ae)/(ie-1)),B=p(R,(h-ae)/(ie+1))}else z=B=0}F>1e-12?B>1e-12?(V=b(Z,Q,G,K,h,B,k),H=b(Y,X,q,J,h,B,k),D.moveTo(V.cx+V.x01,V.cy+V.y01),B<R?D.arc(V.cx,V.cy,B,n(V.y01,V.x01),n(H.y01,H.x01),!k):(D.arc(V.cx,V.cy,B,n(V.y01,V.x01),n(V.y11,V.x11),!k),D.arc(0,0,h,n(V.cy+V.y11,V.cx+V.x11),n(H.cy+H.y11,H.cx+H.x11),!k),D.arc(H.cx,H.cy,B,n(H.y11,H.x11),n(H.y01,H.x01),!k))):(D.moveTo(G,K),D.arc(0,0,h,A,j,!k)):D.moveTo(G,K),!(m>1e-12)||!(P>1e-12)?D.lineTo(q,J):z>1e-12?(V=b(q,J,Y,X,m,-z,k),H=b(G,K,Z,Q,m,-z,k),D.lineTo(V.cx+V.x01,V.cy+V.y01),z<R?D.arc(V.cx,V.cy,z,n(V.y01,V.x01),n(H.y01,H.x01),!k):(D.arc(V.cx,V.cy,z,n(V.y01,V.x01),n(V.y11,V.x11),!k),D.arc(0,0,m,n(V.cy+V.y11,V.cx+V.x11),n(H.cy+H.y11,H.cx+H.x11),k),D.arc(H.cx,H.cy,z,n(H.y11,H.x11),n(H.y01,H.x01),!k))):D.arc(0,0,m,N,M,k)}if(D.closePath(),e)return D=null,e+``||null}return k.centroid=function(){var e=(+s.apply(this,arguments)+ +x.apply(this,arguments))/2,t=(+w.apply(this,arguments)+ +T.apply(this,arguments))/2-i/2;return[u(t)*e,a(t)*e]},k.innerRadius=function(t){return arguments.length?(s=typeof t==`function`?t:e(+t),k):s},k.outerRadius=function(t){return arguments.length?(x=typeof t==`function`?t:e(+t),k):x},k.cornerRadius=function(t){return arguments.length?(S=typeof t==`function`?t:e(+t),k):S},k.padRadius=function(t){return arguments.length?(C=t==null?null:typeof t==`function`?t:e(+t),k):C},k.startAngle=function(t){return arguments.length?(w=typeof t==`function`?t:e(+t),k):w},k.endAngle=function(t){return arguments.length?(T=typeof t==`function`?t:e(+t),k):T},k.padAngle=function(t){return arguments.length?(E=typeof t==`function`?t:e(+t),k):E},k.context=function(e){return arguments.length?(D=e??null,k):D},k}export{x as t};
1
+ import{n as e,t}from"./path-CoPyR7c2.js";import{a as n,c as r,d as i,f as a,i as o,l as s,m as c,n as l,o as u,p as d,r as f,u as p}from"./dist-QvbmK1IP.js";function m(e){return e.innerRadius}function h(e){return e.outerRadius}function g(e){return e.startAngle}function _(e){return e.endAngle}function v(e){return e&&e.padAngle}function y(e,t,n,r,i,a,o,s){var c=n-e,l=r-t,u=o-i,d=s-a,f=d*c-u*l;if(!(f*f<1e-12))return f=(u*(t-a)-d*(e-i))/f,[e+f*c,t+f*l]}function b(e,t,n,r,i,a,o){var c=e-n,l=t-r,u=(o?a:-a)/d(c*c+l*l),f=u*l,p=-u*c,m=e+f,h=t+p,g=n+f,_=r+p,v=(m+g)/2,y=(h+_)/2,b=g-m,x=_-h,S=b*b+x*x,C=i-a,w=m*_-g*h,T=(x<0?-1:1)*d(s(0,C*C*S-w*w)),E=(w*x-b*T)/S,D=(-w*b-x*T)/S,O=(w*x+b*T)/S,k=(-w*b+x*T)/S,A=E-v,j=D-y,M=O-v,N=k-y;return A*A+j*j>M*M+N*N&&(E=O,D=k),{cx:E,cy:D,x01:-f,y01:-p,x11:E*(i/C-1),y11:D*(i/C-1)}}function x(){var s=m,x=h,S=e(0),C=null,w=g,T=_,E=v,D=null,O=t(k);function k(){var e,t,m=+s.apply(this,arguments),h=+x.apply(this,arguments),g=w.apply(this,arguments)-r,_=T.apply(this,arguments)-r,v=l(_-g),k=_>g;if(D||=e=O(),h<m&&(t=h,h=m,m=t),!(h>1e-12))D.moveTo(0,0);else if(v>c-1e-12)D.moveTo(h*u(g),h*a(g)),D.arc(0,0,h,g,_,!k),m>1e-12&&(D.moveTo(m*u(_),m*a(_)),D.arc(0,0,m,_,g,k));else{var A=g,j=_,M=g,N=_,P=v,F=v,I=E.apply(this,arguments)/2,L=I>1e-12&&(C?+C.apply(this,arguments):d(m*m+h*h)),R=p(l(h-m)/2,+S.apply(this,arguments)),z=R,B=R,V,H;if(L>1e-12){var U=o(L/m*a(I)),W=o(L/h*a(I));(P-=U*2)>1e-12?(U*=k?1:-1,M+=U,N-=U):(P=0,M=N=(g+_)/2),(F-=W*2)>1e-12?(W*=k?1:-1,A+=W,j-=W):(F=0,A=j=(g+_)/2)}var G=h*u(A),K=h*a(A),q=m*u(N),J=m*a(N);if(R>1e-12){var Y=h*u(j),X=h*a(j),Z=m*u(M),Q=m*a(M),$;if(v<i)if($=y(G,K,Z,Q,Y,X,q,J)){var ee=G-$[0],te=K-$[1],ne=Y-$[0],re=X-$[1],ie=1/a(f((ee*ne+te*re)/(d(ee*ee+te*te)*d(ne*ne+re*re)))/2),ae=d($[0]*$[0]+$[1]*$[1]);z=p(R,(m-ae)/(ie-1)),B=p(R,(h-ae)/(ie+1))}else z=B=0}F>1e-12?B>1e-12?(V=b(Z,Q,G,K,h,B,k),H=b(Y,X,q,J,h,B,k),D.moveTo(V.cx+V.x01,V.cy+V.y01),B<R?D.arc(V.cx,V.cy,B,n(V.y01,V.x01),n(H.y01,H.x01),!k):(D.arc(V.cx,V.cy,B,n(V.y01,V.x01),n(V.y11,V.x11),!k),D.arc(0,0,h,n(V.cy+V.y11,V.cx+V.x11),n(H.cy+H.y11,H.cx+H.x11),!k),D.arc(H.cx,H.cy,B,n(H.y11,H.x11),n(H.y01,H.x01),!k))):(D.moveTo(G,K),D.arc(0,0,h,A,j,!k)):D.moveTo(G,K),!(m>1e-12)||!(P>1e-12)?D.lineTo(q,J):z>1e-12?(V=b(q,J,Y,X,m,-z,k),H=b(G,K,Z,Q,m,-z,k),D.lineTo(V.cx+V.x01,V.cy+V.y01),z<R?D.arc(V.cx,V.cy,z,n(V.y01,V.x01),n(H.y01,H.x01),!k):(D.arc(V.cx,V.cy,z,n(V.y01,V.x01),n(V.y11,V.x11),!k),D.arc(0,0,m,n(V.cy+V.y11,V.cx+V.x11),n(H.cy+H.y11,H.cx+H.x11),k),D.arc(H.cx,H.cy,z,n(H.y11,H.x11),n(H.y01,H.x01),!k))):D.arc(0,0,m,N,M,k)}if(D.closePath(),e)return D=null,e+``||null}return k.centroid=function(){var e=(+s.apply(this,arguments)+ +x.apply(this,arguments))/2,t=(+w.apply(this,arguments)+ +T.apply(this,arguments))/2-i/2;return[u(t)*e,a(t)*e]},k.innerRadius=function(t){return arguments.length?(s=typeof t==`function`?t:e(+t),k):s},k.outerRadius=function(t){return arguments.length?(x=typeof t==`function`?t:e(+t),k):x},k.cornerRadius=function(t){return arguments.length?(S=typeof t==`function`?t:e(+t),k):S},k.padRadius=function(t){return arguments.length?(C=t==null?null:typeof t==`function`?t:e(+t),k):C},k.startAngle=function(t){return arguments.length?(w=typeof t==`function`?t:e(+t),k):w},k.endAngle=function(t){return arguments.length?(T=typeof t==`function`?t:e(+t),k):T},k.padAngle=function(t){return arguments.length?(E=typeof t==`function`?t:e(+t),k):E},k.context=function(e){return arguments.length?(D=e??null,k):D},k}export{x as t};
@@ -0,0 +1 @@
1
+ import"./chunk-K5T4RW27-DIKxqyYw.js";import{n as e}from"./chunk-7N4EOEYR-JKOVngS0.js";export{e as createArchitectureServices};