titan-agent 7.0.0 → 7.2.0

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 (343) hide show
  1. package/README.md +54 -2
  2. package/dist/agent/agent.js +55 -10
  3. package/dist/agent/agent.js.map +1 -1
  4. package/dist/agent/contextManager.js +1 -1
  5. package/dist/agent/contextManager.js.map +1 -1
  6. package/dist/agent/honestyGuard.js +66 -0
  7. package/dist/agent/honestyGuard.js.map +1 -0
  8. package/dist/agent/selfCritique.js +101 -0
  9. package/dist/agent/selfCritique.js.map +1 -0
  10. package/dist/agent/toolSearch.js +9 -2
  11. package/dist/agent/toolSearch.js.map +1 -1
  12. package/dist/agent/trajectoryLogger.js +19 -2
  13. package/dist/agent/trajectoryLogger.js.map +1 -1
  14. package/dist/analytics/collector.js +1 -1
  15. package/dist/analytics/collector.js.map +1 -1
  16. package/dist/config/schema.js +32 -0
  17. package/dist/config/schema.js.map +1 -1
  18. package/dist/eval/harness.js +4 -1
  19. package/dist/eval/harness.js.map +1 -1
  20. package/dist/gateway/server.js +24 -8
  21. package/dist/gateway/server.js.map +1 -1
  22. package/dist/gateway/slashCommands.js +31 -0
  23. package/dist/gateway/slashCommands.js.map +1 -1
  24. package/dist/mcp/agentTools.js +135 -0
  25. package/dist/mcp/agentTools.js.map +1 -0
  26. package/dist/mcp/server.js +19 -2
  27. package/dist/mcp/server.js.map +1 -1
  28. package/dist/memory/graph.js +2 -0
  29. package/dist/memory/graph.js.map +1 -1
  30. package/dist/providers/errorTaxonomy.js +4 -0
  31. package/dist/providers/errorTaxonomy.js.map +1 -1
  32. package/dist/providers/moa.js +151 -0
  33. package/dist/providers/moa.js.map +1 -0
  34. package/dist/providers/modelCapabilities.js +65 -2
  35. package/dist/providers/modelCapabilities.js.map +1 -1
  36. package/dist/providers/ollama.js +1 -0
  37. package/dist/providers/ollama.js.map +1 -1
  38. package/dist/providers/openai_compat.js +14 -2
  39. package/dist/providers/openai_compat.js.map +1 -1
  40. package/dist/providers/router.js +3 -1
  41. package/dist/providers/router.js.map +1 -1
  42. package/dist/utils/benchMode.js +8 -0
  43. package/dist/utils/benchMode.js.map +1 -0
  44. package/dist/utils/constants.js +1 -1
  45. package/dist/utils/constants.js.map +1 -1
  46. package/package.json +26 -26
  47. package/ui/dist/assets/AboutYouMemory-57X5SqHQ.js +1 -0
  48. package/ui/dist/assets/AuditPanel-AyB8ciLZ.js +1 -0
  49. package/ui/dist/assets/AutonomyPanel-wmVPr-n3.js +1 -0
  50. package/ui/dist/assets/AutopilotPanel-CbLy4lJP.js +1 -0
  51. package/ui/dist/assets/AutoresearchPanel-DxRO1rBF.js +1 -0
  52. package/ui/dist/assets/BackupPanel-BUh9rQ-3.js +1 -0
  53. package/ui/dist/assets/BrowserPanel-OqKwGrIL.js +1 -0
  54. package/ui/dist/assets/CPActivity-DGfS7EY3.js +1 -0
  55. package/ui/dist/assets/CPAgentDetail-p0Kvzhhb.js +1 -0
  56. package/ui/dist/assets/CPAgents-B6wSSQZM.js +1 -0
  57. package/ui/dist/assets/CPApprovals-CYv9Do0i.js +1 -0
  58. package/ui/dist/assets/CPCosts-Dx6Q71rN.js +1 -0
  59. package/ui/dist/assets/CPDashboard-DA8-tE-l.js +1 -0
  60. package/ui/dist/assets/CPFiles-BJ49tzai.js +1 -0
  61. package/ui/dist/assets/CPGoals-h0dKL5V_.js +1 -0
  62. package/ui/dist/assets/CPInbox-CDvefgNH.js +1 -0
  63. package/ui/dist/assets/CPIssueDetail-CnmLzzDD.js +1 -0
  64. package/ui/dist/assets/CPIssues-DknAIMyl.js +1 -0
  65. package/ui/dist/assets/CPLayout-C2nqgkmY.js +2 -0
  66. package/ui/dist/assets/CPOrg-tDbHFphX.js +1 -0
  67. package/ui/dist/assets/CPRuns-UlrIURqG.js +1 -0
  68. package/ui/dist/assets/CPSocial-B-gHgvEw.js +1 -0
  69. package/ui/dist/assets/CPVoice-CJy938ZF.js +1 -0
  70. package/ui/dist/assets/ChannelsPanel-DLbxg1zO.js +1 -0
  71. package/ui/dist/assets/CheckpointsPanel-BB6TT0aE.js +1 -0
  72. package/ui/dist/assets/CommandPostHub-fIslwU_t.js +2 -0
  73. package/ui/dist/assets/ConfirmDialog-6hcNjmAh.js +9 -0
  74. package/ui/dist/assets/CronPanel-DLpw3Y25.js +1 -0
  75. package/ui/dist/assets/DataTable-KVqtDzvP.js +1 -0
  76. package/ui/dist/assets/DreamPanel-lcMXpbEb.js +5 -0
  77. package/ui/dist/assets/EmptyState-D-Dg8B8r.js +1 -0
  78. package/ui/dist/assets/EvalHarnessPanel-BKzRiiQw.js +2 -0
  79. package/ui/dist/assets/EvalPanel-Dtodacmj.js +1 -0
  80. package/ui/dist/assets/FileViewer-DjcVKkO2.js +60 -0
  81. package/ui/dist/assets/FilesPanel-BI90Pplh.js +1 -0
  82. package/ui/dist/assets/FleetPanel-tr0wjAwr.js +1 -0
  83. package/ui/dist/assets/HomelabPanel-m8vMm5rE.js +1 -0
  84. package/ui/dist/assets/InfraView-3WriJnyE.js +2 -0
  85. package/ui/dist/assets/IntegrationsPanel-BmL70fOw.js +1 -0
  86. package/ui/dist/assets/IntelligenceView-BGVxCKD3.js +2 -0
  87. package/ui/dist/assets/LearningPanel-CrYLQ6eV.js +1 -0
  88. package/ui/dist/assets/LiveStudio-CnW3eZYF.js +2 -0
  89. package/ui/dist/assets/LogsPanel-DbShr4Ic.js +1 -0
  90. package/ui/dist/assets/McpPanel-uMYEsPI4.js +1 -0
  91. package/ui/dist/assets/MemoryGraphPanel-C7-Z8f0v.js +1 -0
  92. package/ui/dist/assets/MemoryTaxonomyPanel-KrxN8U1G.js +1 -0
  93. package/ui/dist/assets/MemoryWikiPanel-DI3q6IHC.js +1 -0
  94. package/ui/dist/assets/MeshPanel-D4-g2tlu.js +1 -0
  95. package/ui/dist/assets/MissionCanvas-D8cjakJe.js +61 -0
  96. package/ui/dist/assets/MissionChat-BvqCUf1E.js +3 -0
  97. package/ui/dist/assets/MissionLibrary-CZoJQ9WD.js +1 -0
  98. package/ui/dist/assets/MissionStart-CXCq-_AD.js +1 -0
  99. package/ui/dist/assets/NvidiaPanel-BfI1K5Pg.js +1 -0
  100. package/ui/dist/assets/OrganismPanel-B7Gm9pP-.js +1 -0
  101. package/ui/dist/assets/OverviewPanel-B9tKWRK2.js +1 -0
  102. package/ui/dist/assets/PageHeader-CH85uoZG.js +1 -0
  103. package/ui/dist/assets/PersonaProfilesPanel-BPi8fl-U.js +3 -0
  104. package/ui/dist/assets/PersonasPanel-Dwr7sycT.js +1 -0
  105. package/ui/dist/assets/PhoneDeskPanel-D7qc6wUI.js +1 -0
  106. package/ui/dist/assets/RecipesPanel-DcqPWRSU.js +1 -0
  107. package/ui/dist/assets/SecurityPanel-Bv_B9Ahf.js +1 -0
  108. package/ui/dist/assets/SelfImprovePanel-Ca4rGwEG.js +1 -0
  109. package/ui/dist/assets/SelfProposalsPanel-DteMSASq.js +1 -0
  110. package/ui/dist/assets/SessionsPanel-BdbbKTbL.js +1 -0
  111. package/ui/dist/assets/SessionsTab-BJipiVJs.js +1 -0
  112. package/ui/dist/assets/SettingsPanel-mV7ykOCc.js +1 -0
  113. package/ui/dist/assets/SettingsView-Bu_wYTT5.js +2 -0
  114. package/ui/dist/assets/SkeletonLoader-9H7QWa9E.js +1 -0
  115. package/ui/dist/assets/SkillsPanel-CHwX2kDR.js +1 -0
  116. package/ui/dist/assets/SomaView-Bpsm4ZW7.js +5 -0
  117. package/ui/dist/assets/SomaView-Dghh9om4.css +1 -0
  118. package/ui/dist/assets/StatCard-wmSgMAM3.js +1 -0
  119. package/ui/dist/assets/TeamsPanel-XJiHxdDX.js +1 -0
  120. package/ui/dist/assets/TelemetryPanel-_pmGVxpO.js +1 -0
  121. package/ui/dist/assets/TitanCanvas-Cb7KG80W.css +1 -0
  122. package/ui/dist/assets/TitanCanvas-CmLy7p2N.js +883 -0
  123. package/ui/dist/assets/ToolsView-PHizHZBx.js +2 -0
  124. package/ui/dist/assets/TraceViewer-CYAzIcfB.js +1 -0
  125. package/ui/dist/assets/TracesPanel-CRSN_dzK.js +1 -0
  126. package/ui/dist/assets/TrainingPanel-B9rcuMsV.js +1 -0
  127. package/ui/dist/assets/VoiceOverlay-BL_ns1ZA.js +7 -0
  128. package/ui/dist/assets/VramPanel-BNPQ06_9.js +1 -0
  129. package/ui/dist/assets/WatchView-BgAkNnur.js +13 -0
  130. package/ui/dist/assets/WorkTab-RRpPpEOg.js +1 -0
  131. package/ui/dist/assets/WorkflowBuilderPanel-BPHIH8pf.js +1 -0
  132. package/ui/dist/assets/WorkflowsPanel-DqtmT0NB.js +1 -0
  133. package/ui/dist/assets/approvalHeadline-BRg3ReTi.js +1 -0
  134. package/ui/dist/assets/archive-DcK9HrbE.js +1 -0
  135. package/ui/dist/assets/arrow-left-4c2FnES1.js +1 -0
  136. package/ui/dist/assets/book-open-Ds_yciQm.js +1 -0
  137. package/ui/dist/assets/bot-CWDCc265.js +1 -0
  138. package/ui/dist/assets/chart-column-hhZMdCgB.js +1 -0
  139. package/ui/dist/assets/chevron-right-A_pvnRh_.js +1 -0
  140. package/ui/dist/assets/circle-check-big-C-JUM7wb.js +1 -0
  141. package/ui/dist/assets/circle-stop-yZuG9ZAE.js +1 -0
  142. package/ui/dist/assets/clipboard-list-C2HUEjZc.js +1 -0
  143. package/ui/dist/assets/clock-DSPgndSD.js +1 -0
  144. package/ui/dist/assets/clsx-CjueKrWZ.js +1 -0
  145. package/ui/dist/assets/createLucideIcon-qnlrxww7.js +1 -0
  146. package/ui/dist/assets/database-C1SgHa8T.js +1 -0
  147. package/ui/dist/assets/dollar-sign-D9siqK91.js +1 -0
  148. package/ui/dist/assets/download-CJZWQNfV.js +1 -0
  149. package/ui/dist/assets/external-link-CpQLWKKE.js +1 -0
  150. package/ui/dist/assets/file-text-BbGTi-Po.js +1 -0
  151. package/ui/dist/assets/flask-conical-B1YVft4E.js +1 -0
  152. package/ui/dist/assets/folder-EbR-w2Mq.js +1 -0
  153. package/ui/dist/assets/funnel-D2Dkn8Pf.js +1 -0
  154. package/ui/dist/assets/git-branch-CQ2yNSzU.js +1 -0
  155. package/ui/dist/assets/git-pull-request-BxL5wlGX.js +1 -0
  156. package/ui/dist/assets/index-Cz8190xO.css +2 -0
  157. package/ui/dist/assets/index-WI-E4I3h.js +243 -0
  158. package/ui/dist/assets/jsx-runtime-B15e6lOy.js +1 -0
  159. package/ui/dist/assets/layers-BPu5SRjI.js +1 -0
  160. package/ui/dist/assets/legacy-BIzifT-t.js +3 -0
  161. package/ui/dist/assets/lightbulb-BY7CpMte.js +1 -0
  162. package/ui/dist/assets/link-VDQkrGJw.js +1 -0
  163. package/ui/dist/assets/list-todo-DfnNUV_T.js +1 -0
  164. package/ui/dist/assets/message-square-BpzrINHz.js +1 -0
  165. package/ui/dist/assets/mic-De6oZFaV.js +1 -0
  166. package/ui/dist/assets/missions-y-qg_f9b.js +1 -0
  167. package/ui/dist/assets/network-CM7y1ats.js +1 -0
  168. package/ui/dist/assets/pause-C4TDJSfA.js +1 -0
  169. package/ui/dist/assets/pencil-Dd_vzHE-.js +1 -0
  170. package/ui/dist/assets/play-9WxZWVHA.js +1 -0
  171. package/ui/dist/assets/plug-Dm25Wbrc.js +1 -0
  172. package/ui/dist/assets/plus-CHryCIkk.js +1 -0
  173. package/ui/dist/assets/radio-D-XnoAVu.js +1 -0
  174. package/ui/dist/assets/refresh-cw-Disd5wRB.js +1 -0
  175. package/ui/dist/assets/rotate-ccw-Cw1T2W1T.js +1 -0
  176. package/ui/dist/assets/save-DP7oNar2.js +1 -0
  177. package/ui/dist/assets/search-aNVcX-nv.js +1 -0
  178. package/ui/dist/assets/send-D7iQD57b.js +1 -0
  179. package/ui/dist/assets/server-DFfeYjoM.js +1 -0
  180. package/ui/dist/assets/settings-5NWXzgyY.js +1 -0
  181. package/ui/dist/assets/shared-DLz_Jtg3.js +1 -0
  182. package/ui/dist/assets/shield-check-Cd50jCAn.js +1 -0
  183. package/ui/dist/assets/square-DlcoJ1ZM.js +1 -0
  184. package/ui/dist/assets/terminal-DgFz2Vsf.js +1 -0
  185. package/ui/dist/assets/test-tube-BimtS92_.js +1 -0
  186. package/ui/dist/assets/toggle-right-BMaR-sfT.js +1 -0
  187. package/ui/dist/assets/trash-2-CwUv7ww1.js +1 -0
  188. package/ui/dist/assets/trending-up-Ba9TwEow.js +1 -0
  189. package/ui/dist/assets/trophy-Gfv1QC45.js +1 -0
  190. package/ui/dist/assets/volume-2-BVlfVl2U.js +1 -0
  191. package/ui/dist/assets/wifi-off-CWLeusSV.js +1 -0
  192. package/ui/dist/assets/zoom-out-DeggJ7RM.js +1 -0
  193. package/ui/dist/index.html +4 -2
  194. package/ui/dist/sw.js +1 -1
  195. package/ui/dist/assets/AboutYouMemory-CZKEOd_O.js +0 -11
  196. package/ui/dist/assets/AuditPanel-Bu71N5Er.js +0 -1
  197. package/ui/dist/assets/AutonomyPanel-DB-39dX4.js +0 -11
  198. package/ui/dist/assets/AutopilotPanel-Cj8oKxWv.js +0 -1
  199. package/ui/dist/assets/AutoresearchPanel-3s8pjm6Z.js +0 -6
  200. package/ui/dist/assets/BackupPanel-EUQJMJE7.js +0 -1
  201. package/ui/dist/assets/BrowserPanel-Beo4F5Ar.js +0 -6
  202. package/ui/dist/assets/Button-MdXmb4_n.js +0 -1
  203. package/ui/dist/assets/CPActivity-B1Se9VVc.js +0 -1
  204. package/ui/dist/assets/CPAgentDetail-BYji6tT8.js +0 -1
  205. package/ui/dist/assets/CPAgents-BSUKucTe.js +0 -1
  206. package/ui/dist/assets/CPApprovals-B4v0em6e.js +0 -1
  207. package/ui/dist/assets/CPCosts-9ikh61Kv.js +0 -1
  208. package/ui/dist/assets/CPDashboard-sOok2T5v.js +0 -1
  209. package/ui/dist/assets/CPFiles-DB2nY5JE.js +0 -1
  210. package/ui/dist/assets/CPGoals-8Z1yOY8e.js +0 -1
  211. package/ui/dist/assets/CPInbox-Cq6-UY8F.js +0 -11
  212. package/ui/dist/assets/CPIssueDetail-NAGfmJg8.js +0 -1
  213. package/ui/dist/assets/CPIssues-BzX6Rckx.js +0 -1
  214. package/ui/dist/assets/CPLayout-BcRM6QSg.js +0 -2
  215. package/ui/dist/assets/CPOrg-B7DQ4UQP.js +0 -1
  216. package/ui/dist/assets/CPRuns-D-cpPw_M.js +0 -1
  217. package/ui/dist/assets/CPSocial-DshtmcK0.js +0 -11
  218. package/ui/dist/assets/CPVoice-DfXRnQVU.js +0 -1
  219. package/ui/dist/assets/ChannelsPanel-BnaTOeyf.js +0 -1
  220. package/ui/dist/assets/CheckpointsPanel-C62naE4U.js +0 -1
  221. package/ui/dist/assets/CommandPostHub-B_L1CAss.js +0 -24
  222. package/ui/dist/assets/ConfirmDialog-VErHWAbo.js +0 -1
  223. package/ui/dist/assets/CronPanel-BwMrrZ5d.js +0 -1
  224. package/ui/dist/assets/DataTable-BCqSUuN7.js +0 -1
  225. package/ui/dist/assets/DreamPanel-BNAcCLBB.js +0 -15
  226. package/ui/dist/assets/EmptyState-D9kQf1PX.js +0 -1
  227. package/ui/dist/assets/EvalHarnessPanel-BaMLdBNm.js +0 -2
  228. package/ui/dist/assets/EvalPanel-CW-SSjtg.js +0 -1
  229. package/ui/dist/assets/FileViewer-BL00nsd7.js +0 -61
  230. package/ui/dist/assets/FilesPanel-CeC6YUSd.js +0 -16
  231. package/ui/dist/assets/FleetPanel-EyWF7l3W.js +0 -1
  232. package/ui/dist/assets/HomelabPanel-BRfKRYe7.js +0 -6
  233. package/ui/dist/assets/InfraView-Jmqhg_Yc.js +0 -2
  234. package/ui/dist/assets/InlineEditableField-DgMrLDj1.js +0 -1
  235. package/ui/dist/assets/Input-CBTwa_Iw.js +0 -1
  236. package/ui/dist/assets/IntegrationsPanel-DQL-7Ec6.js +0 -1
  237. package/ui/dist/assets/IntelligenceView-DxD78qfP.js +0 -2
  238. package/ui/dist/assets/LearningPanel-C_JzSbJU.js +0 -1
  239. package/ui/dist/assets/LiveStudio-Db5yeaWo.js +0 -7
  240. package/ui/dist/assets/LogsPanel-CpinKwaZ.js +0 -1
  241. package/ui/dist/assets/McpPanel-D-MqN_f-.js +0 -1
  242. package/ui/dist/assets/MemoryGraphPanel-BnD5jRqf.js +0 -1
  243. package/ui/dist/assets/MemoryTaxonomyPanel-BBI202dd.js +0 -6
  244. package/ui/dist/assets/MemoryWikiPanel-Dn3XZHL0.js +0 -6
  245. package/ui/dist/assets/MeshPanel-C-mRJpr0.js +0 -11
  246. package/ui/dist/assets/MissionCanvas-CbZW83Ch.js +0 -72
  247. package/ui/dist/assets/MissionChat-Bs75jPAD.js +0 -7
  248. package/ui/dist/assets/MissionLibrary-BxQ6SxPe.js +0 -5
  249. package/ui/dist/assets/MissionStart-CBuBPasl.js +0 -1
  250. package/ui/dist/assets/Modal-ybPGvlQs.js +0 -9
  251. package/ui/dist/assets/NvidiaPanel-DdG13OX4.js +0 -1
  252. package/ui/dist/assets/OrganismPanel-xZWUJKyr.js +0 -1
  253. package/ui/dist/assets/OverviewPanel-B45ZYhJV.js +0 -1
  254. package/ui/dist/assets/PageHeader-DdrbS1aq.js +0 -1
  255. package/ui/dist/assets/PersonaProfilesPanel-CKER-EU5.js +0 -8
  256. package/ui/dist/assets/PersonasPanel-CMMQ3nh3.js +0 -1
  257. package/ui/dist/assets/PhoneDeskPanel-Bw_Y-cVE.js +0 -11
  258. package/ui/dist/assets/RecipesPanel-DzMcxpJJ.js +0 -1
  259. package/ui/dist/assets/SecurityPanel-BCq3Fzbr.js +0 -1
  260. package/ui/dist/assets/SelfImprovePanel-YE3hT8jK.js +0 -1
  261. package/ui/dist/assets/SelfProposalsPanel-DXuqBM6p.js +0 -1
  262. package/ui/dist/assets/SessionsPanel-DORz5goR.js +0 -1
  263. package/ui/dist/assets/SessionsTab-qYHDOuC8.js +0 -1
  264. package/ui/dist/assets/SettingsPanel-BbwPu1i7.js +0 -1
  265. package/ui/dist/assets/SettingsView-zgqkDDBJ.js +0 -2
  266. package/ui/dist/assets/SkeletonLoader-r6OGXaU9.js +0 -1
  267. package/ui/dist/assets/SkillsPanel-BjEOBMRo.js +0 -11
  268. package/ui/dist/assets/SomaView-BtCkeWfZ.css +0 -1
  269. package/ui/dist/assets/SomaView-DLzApZVW.js +0 -5
  270. package/ui/dist/assets/StatCard-DLq8aBps.js +0 -1
  271. package/ui/dist/assets/StatusBadge-BqlvIbdj.js +0 -1
  272. package/ui/dist/assets/Tabs-DdUThlp1.js +0 -1
  273. package/ui/dist/assets/TeamsPanel-uIIKoU7I.js +0 -1
  274. package/ui/dist/assets/TelemetryPanel-dVr3yQQr.js +0 -1
  275. package/ui/dist/assets/TitanCanvas-BfitWg9R.css +0 -1
  276. package/ui/dist/assets/TitanCanvas-xHAJqwG2.js +0 -945
  277. package/ui/dist/assets/ToolsView-CG1mZdiy.js +0 -2
  278. package/ui/dist/assets/Tooltip-C2tXJcrN.js +0 -6
  279. package/ui/dist/assets/TraceViewer-BIMD_Osr.js +0 -1
  280. package/ui/dist/assets/TracesPanel-nMUiyMj5.js +0 -1
  281. package/ui/dist/assets/TrainingPanel-CT5R4HWm.js +0 -1
  282. package/ui/dist/assets/VoiceOverlay-Br4QnCtw.js +0 -17
  283. package/ui/dist/assets/VramPanel-CdnJYytg.js +0 -1
  284. package/ui/dist/assets/WatchView-TNU6Ns1Q.js +0 -13
  285. package/ui/dist/assets/WorkTab-wTlX_UKP.js +0 -1
  286. package/ui/dist/assets/WorkflowBuilderPanel-CDpVt5ux.js +0 -6
  287. package/ui/dist/assets/WorkflowsPanel-zsFqsLdn.js +0 -11
  288. package/ui/dist/assets/approvalHeadline-DB9SgR-9.js +0 -1
  289. package/ui/dist/assets/archive-Bh689DNg.js +0 -6
  290. package/ui/dist/assets/arrow-left-WkVYLm80.js +0 -6
  291. package/ui/dist/assets/book-open-ohEXgUsS.js +0 -6
  292. package/ui/dist/assets/bot-DvEcyQcD.js +0 -6
  293. package/ui/dist/assets/chart-column-w3goFd5f.js +0 -6
  294. package/ui/dist/assets/check-CuRYh4Zh.js +0 -6
  295. package/ui/dist/assets/chevron-right-DbLSHmff.js +0 -6
  296. package/ui/dist/assets/circle-check-big-Bkba568b.js +0 -6
  297. package/ui/dist/assets/circle-stop-Bx2ohEg8.js +0 -6
  298. package/ui/dist/assets/clipboard-list-Dj9tORnu.js +0 -6
  299. package/ui/dist/assets/clock-JyQAYy6X.js +0 -6
  300. package/ui/dist/assets/clsx-B-dksMZM.js +0 -1
  301. package/ui/dist/assets/dollar-sign-XxwPAA2a.js +0 -6
  302. package/ui/dist/assets/download-D1izVEOL.js +0 -6
  303. package/ui/dist/assets/external-link-DZ_rZsIt.js +0 -6
  304. package/ui/dist/assets/file-text-Cfawu8Bs.js +0 -6
  305. package/ui/dist/assets/flask-conical-Ql8QxhgY.js +0 -6
  306. package/ui/dist/assets/folder-DAdIw-Pb.js +0 -6
  307. package/ui/dist/assets/funnel-FycfZcXo.js +0 -6
  308. package/ui/dist/assets/git-branch-C2qrhGGu.js +0 -6
  309. package/ui/dist/assets/index-Cml2x9pA.js +0 -507
  310. package/ui/dist/assets/index-yWybhcfI.css +0 -1
  311. package/ui/dist/assets/layers-yzjtGlHB.js +0 -6
  312. package/ui/dist/assets/legacy-D21WSMF1.js +0 -3
  313. package/ui/dist/assets/lightbulb-BZJNK69S.js +0 -6
  314. package/ui/dist/assets/link-CnFkBkaY.js +0 -6
  315. package/ui/dist/assets/list-todo-BlgfQHup.js +0 -6
  316. package/ui/dist/assets/message-square-CRsG9u6_.js +0 -6
  317. package/ui/dist/assets/mic-B32RHc7Y.js +0 -6
  318. package/ui/dist/assets/missions-1iw8Z2_0.js +0 -1
  319. package/ui/dist/assets/network-C9RXQGrV.js +0 -6
  320. package/ui/dist/assets/pause-BT1Bc2q3.js +0 -6
  321. package/ui/dist/assets/pencil-BK5IU6o0.js +0 -6
  322. package/ui/dist/assets/play-Cl1nC_gc.js +0 -6
  323. package/ui/dist/assets/plug-DvcpOalj.js +0 -6
  324. package/ui/dist/assets/plus-Dpo1qfrl.js +0 -6
  325. package/ui/dist/assets/radio-C5c9IyqX.js +0 -6
  326. package/ui/dist/assets/refresh-cw-C-iZkzuS.js +0 -6
  327. package/ui/dist/assets/rotate-ccw-qzrB3SNw.js +0 -6
  328. package/ui/dist/assets/save-DwR9wQVu.js +0 -6
  329. package/ui/dist/assets/search-D10l0m3-.js +0 -6
  330. package/ui/dist/assets/send-DtXGsaFW.js +0 -6
  331. package/ui/dist/assets/server-BzisF3LL.js +0 -6
  332. package/ui/dist/assets/settings-Dbwd1_-c.js +0 -6
  333. package/ui/dist/assets/shield-check-CXlDJyAW.js +0 -6
  334. package/ui/dist/assets/square-BBC-JKzY.js +0 -11
  335. package/ui/dist/assets/terminal-DaBIlWEM.js +0 -6
  336. package/ui/dist/assets/test-tube-CDATRD5t.js +0 -11
  337. package/ui/dist/assets/toggle-right-DTmrC5RD.js +0 -11
  338. package/ui/dist/assets/trash-2-CTeyjxD_.js +0 -6
  339. package/ui/dist/assets/trending-up-CXPRjRV4.js +0 -6
  340. package/ui/dist/assets/trophy-DbVdXRtU.js +0 -6
  341. package/ui/dist/assets/volume-2-DYDBmm3M.js +0 -6
  342. package/ui/dist/assets/wifi-off-BBuIGbiP.js +0 -6
  343. package/ui/dist/assets/zoom-out-D47_pRAO.js +0 -16
@@ -1 +0,0 @@
1
- import{r as a,t as P,F as B,j as t,P as z,X as R,Q as $,V as _}from"./index-Cml2x9pA.js";import{B as A}from"./Button-MdXmb4_n.js";import"./Input-CBTwa_Iw.js";import{S as D}from"./StatusBadge-BqlvIbdj.js";import{P as M}from"./PageHeader-DdrbS1aq.js";import{E as F}from"./EmptyState-D9kQf1PX.js";import{T as L}from"./Tabs-DdUThlp1.js";import{S as W}from"./SkeletonLoader-r6OGXaU9.js";import{e as H}from"./approvalHeadline-DB9SgR-9.js";import{S as I}from"./shield-check-CXlDJyAW.js";import{C as U}from"./check-CuRYh4Zh.js";import"./clsx-B-dksMZM.js";import"./chevron-right-DbLSHmff.js";function q(r){const o=Math.floor((Date.now()-new Date(r).getTime())/1e3);return o<60?`${o}s`:o<3600?`${Math.floor(o/60)}m`:o<86400?`${Math.floor(o/3600)}h`:`${Math.floor(o/86400)}d`}function K(r){return r==="high"?"text-error bg-error/10 border-error/30":r==="medium"?"text-warn bg-warn/10 border-warn/30":"text-text-muted bg-bg-tertiary border-border"}const Q=[{id:"all",label:"All"},{id:"pending",label:"Pending"},{id:"approved",label:"Approved"},{id:"rejected",label:"Rejected"}];function ne(){const[r,o]=a.useState([]),[m,k]=a.useState(!0),[i,d]=a.useState(null),[l,w]=a.useState("all"),[h,c]=a.useState(null),[b,v]=a.useState({}),[u,j]=a.useState(null),{toast:p}=P(),x=a.useCallback(async()=>{try{const e=await B();o(e),d(null)}catch(e){d(e instanceof Error?e.message:"Failed to load approvals")}k(!1)},[]);a.useEffect(()=>{x()},[x]);const y=async e=>{var s;c(e.id);try{const n=(s=b[e.id])==null?void 0:s.trim();await $(e.id,"user",n||void 0),await x();const f=e.type==="goal_proposal"||e.type==="soma_proposal",T=e.type==="custom"&&e.payload.kind==="driver_blocked";p("success",f?"Work approved — TITAN is starting…":T?"Unblocked — TITAN is resuming…":"Approved"),v(E=>{const N={...E};return delete N[e.id],N}),j(null)}catch(n){d(n instanceof Error?n.message:"Approve failed"),p("error","Approval failed")}c(null)},S=async e=>{c(e.id);try{await _(e.id,"user"),await x(),p("success","Rejected")}catch(s){d(s instanceof Error?s.message:"Reject failed"),p("error","Rejection failed")}c(null)},g=l==="all"?r:r.filter(e=>e.status===l),C=Q.map(e=>({...e,count:e.id==="all"?r.length:r.filter(s=>s.status===e.id).length}));return t.jsxs("div",{className:"space-y-4",children:[t.jsx(M,{title:"Approvals",breadcrumbs:[{label:"Command Post"},{label:"Approvals"}]}),t.jsx(L,{tabs:C,activeTab:l,onChange:w}),m&&t.jsx(W,{variant:"row",count:5}),i&&t.jsx("div",{className:"text-center py-8 text-error text-sm",children:i}),!m&&!i&&g.length===0&&t.jsx(F,{icon:t.jsx(I,{size:32}),title:"No approvals",description:l==="pending"?"No pending approvals.":"No approvals to show."}),!m&&!i&&g.length>0&&t.jsx("div",{className:"divide-y divide-border rounded-xl border border-border bg-bg-secondary overflow-hidden",children:g.map(e=>{const s=H(e);return t.jsxs("div",{className:"flex items-start gap-3 px-4 py-3",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1.5 flex-wrap",children:[t.jsxs("span",{className:`text-[10px] px-1.5 py-0.5 rounded border font-medium uppercase tracking-wide ${K(s.urgency)}`,children:[s.urgency==="high"&&t.jsx(z,{size:10,className:"inline mr-0.5"}),s.kindLabel]}),t.jsx(D,{status:e.status,size:"sm"}),t.jsxs("span",{className:"text-xs text-text-muted",children:["from ",t.jsx("span",{className:"font-medium text-text-secondary",children:e.requestedBy})]})]}),t.jsx("div",{className:"text-sm text-text font-medium leading-snug mb-0.5",children:s.headline}),s.detail&&t.jsx("div",{className:"text-xs text-text-secondary leading-snug",children:s.detail}),e.decidedBy&&t.jsxs("div",{className:"text-[10px] text-text-muted mt-1",children:["Decided by ",e.decidedBy,e.decisionNote?`: ${e.decisionNote}`:""]})]}),t.jsx("span",{className:"text-xs text-text-muted flex-shrink-0 pt-0.5",children:q(e.createdAt)}),e.status==="pending"&&t.jsxs("div",{className:"flex flex-col items-end gap-1 flex-shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[e.type==="custom"&&e.payload.kind==="driver_blocked"&&t.jsx("button",{onClick:()=>j(u===e.id?null:e.id),className:"text-[10px] text-text-muted hover:text-text-secondary px-2 py-1 rounded hover:bg-bg-tertiary transition-colors",children:u===e.id?"Cancel":"Answer"}),t.jsx(A,{size:"sm",variant:"ghost",onClick:()=>y(e),loading:h===e.id,icon:t.jsx(U,{size:14}),children:"Approve"}),t.jsx(A,{size:"sm",variant:"ghost",onClick:()=>S(e),loading:h===e.id,icon:t.jsx(R,{size:14}),children:"Reject"})]}),u===e.id&&t.jsx("input",{type:"text",value:b[e.id]||"",onChange:n=>v(f=>({...f,[e.id]:n.target.value})),placeholder:"Type your answer...",className:"w-64 rounded-md border border-border bg-bg px-3 py-1.5 text-xs text-text outline-none focus:border-accent mt-1",onKeyDown:n=>{n.key==="Enter"&&y(e)},autoFocus:!0})]})]},e.id)})})]})}export{ne as default};
@@ -1 +0,0 @@
1
- import{r as s,a4 as F,j as e,a5 as I,a6 as $}from"./index-Cml2x9pA.js";import{B as u}from"./Button-MdXmb4_n.js";import"./Input-CBTwa_Iw.js";import{S as w}from"./StatusBadge-BqlvIbdj.js";import{P as A}from"./PageHeader-DdrbS1aq.js";import{E as L}from"./EmptyState-D9kQf1PX.js";import{M as W}from"./Modal-ybPGvlQs.js";import{S as M}from"./SkeletonLoader-r6OGXaU9.js";import{P as G}from"./plus-Dpo1qfrl.js";import{D as H}from"./dollar-sign-XxwPAA2a.js";import{T as R}from"./trash-2-CTeyjxD_.js";import"./clsx-B-dksMZM.js";import"./chevron-right-DbLSHmff.js";function q(r){const l=r.limitUsd>0?r.currentSpend/r.limitUsd*100:0;return l>=100?"exceeded":l>=r.warningThresholdPercent?"warning":"healthy"}function ae(){const[r,l]=s.useState([]),[c,C]=s.useState(!0),[n,m]=s.useState(null),[S,a]=s.useState(!1),[k,g]=s.useState(!1),[o,p]=s.useState(""),[i,P]=s.useState("global"),[h,b]=s.useState(""),[j,B]=s.useState("monthly"),[f,v]=s.useState("10"),[y,z]=s.useState("80"),[N,T]=s.useState("warn"),d=s.useCallback(async()=>{try{const t=await F();l(t),m(null)}catch(t){m(t instanceof Error?t.message:"Failed to load budgets")}C(!1)},[]);s.useEffect(()=>{d()},[d]);const D=async()=>{if(o.trim()){g(!0);try{await $({name:o.trim(),scope:{type:i,targetId:h||void 0},period:j,limitUsd:parseFloat(f)||10,warningThresholdPercent:parseInt(y)||80,action:N,enabled:!0}),a(!1),p(""),b(""),v("10"),await d()}catch{}g(!1)}},E=async t=>{try{await I(t),await d()}catch{}};return e.jsxs("div",{className:"space-y-4",children:[e.jsx(A,{title:"Costs & Budgets",breadcrumbs:[{label:"Command Post"},{label:"Costs"}],actions:e.jsx(u,{size:"sm",icon:e.jsx(G,{size:14}),onClick:()=>a(!0),children:"Create Budget"})}),c&&e.jsx(M,{variant:"row",count:4}),n&&e.jsx("div",{className:"text-center py-8 text-error text-sm",children:n}),!c&&!n&&r.length===0&&e.jsx(L,{icon:e.jsx(H,{size:32}),title:"No budgets",description:"Create budget policies to control agent spending.",action:{label:"Create Budget",onClick:()=>a(!0)}}),!c&&!n&&r.length>0&&e.jsx("div",{className:"divide-y divide-border rounded-xl border border-border bg-bg-secondary overflow-hidden",children:r.map(t=>{const U=t.limitUsd>0?t.currentSpend/t.limitUsd*100:0,x=q(t);return e.jsxs("div",{className:"flex items-center gap-4 px-4 py-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-sm font-medium text-text",children:t.name}),e.jsx(w,{status:x,size:"sm"}),!t.enabled&&e.jsx(w,{status:"disabled",size:"sm"})]}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-text-muted",children:[e.jsxs("span",{className:"capitalize",children:[t.scope.type,t.scope.targetId?`: ${t.scope.targetId}`:""]}),e.jsx("span",{className:"capitalize",children:t.period}),e.jsxs("span",{children:["Action: ",t.action]})]})]}),e.jsxs("div",{className:"text-right flex-shrink-0",children:[e.jsxs("div",{className:"text-sm font-medium text-text",children:["$",t.currentSpend.toFixed(2)," / $",t.limitUsd.toFixed(2)]}),e.jsx("div",{className:"w-24 h-1.5 bg-bg-tertiary rounded-full overflow-hidden mt-1",children:e.jsx("div",{className:`h-full rounded-full transition-all ${x==="exceeded"?"bg-error":x==="warning"?"bg-warning":"bg-success"}`,style:{width:`${Math.min(100,U)}%`}})})]}),e.jsx("button",{onClick:()=>E(t.id),className:"p-1.5 rounded-md text-text-muted hover:text-error hover:bg-error/10 transition-colors flex-shrink-0",title:"Delete budget",children:e.jsx(R,{size:14})})]},t.id)})}),e.jsx(W,{open:S,onClose:()=>a(!1),title:"Create Budget Policy",footer:e.jsxs(e.Fragment,{children:[e.jsx(u,{variant:"secondary",size:"sm",onClick:()=>a(!1),children:"Cancel"}),e.jsx(u,{size:"sm",onClick:D,loading:k,disabled:!o.trim(),children:"Create"})]}),children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-text-muted mb-1",children:"Name"}),e.jsx("input",{className:"w-full rounded-lg border border-border bg-bg-tertiary px-3 py-2 text-sm text-text placeholder:text-text-muted focus:outline-none focus:border-accent",placeholder:"Budget name...",value:o,onChange:t=>p(t.target.value),autoFocus:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-text-muted mb-1",children:"Scope"}),e.jsxs("select",{className:"w-full rounded-lg border border-border bg-bg-tertiary px-3 py-2 text-sm text-text focus:outline-none focus:border-accent",value:i,onChange:t=>P(t.target.value),children:[e.jsx("option",{value:"global",children:"Global"}),e.jsx("option",{value:"agent",children:"Agent"}),e.jsx("option",{value:"goal",children:"Goal"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-text-muted mb-1",children:"Period"}),e.jsxs("select",{className:"w-full rounded-lg border border-border bg-bg-tertiary px-3 py-2 text-sm text-text focus:outline-none focus:border-accent",value:j,onChange:t=>B(t.target.value),children:[e.jsx("option",{value:"daily",children:"Daily"}),e.jsx("option",{value:"weekly",children:"Weekly"}),e.jsx("option",{value:"monthly",children:"Monthly"})]})]})]}),i!=="global"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-text-muted mb-1",children:"Target ID"}),e.jsx("input",{className:"w-full rounded-lg border border-border bg-bg-tertiary px-3 py-2 text-sm text-text placeholder:text-text-muted focus:outline-none focus:border-accent",placeholder:`${i} ID...`,value:h,onChange:t=>b(t.target.value)})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-text-muted mb-1",children:"Limit (USD)"}),e.jsx("input",{type:"number",className:"w-full rounded-lg border border-border bg-bg-tertiary px-3 py-2 text-sm text-text focus:outline-none focus:border-accent",value:f,onChange:t=>v(t.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-text-muted mb-1",children:"Warning %"}),e.jsx("input",{type:"number",className:"w-full rounded-lg border border-border bg-bg-tertiary px-3 py-2 text-sm text-text focus:outline-none focus:border-accent",value:y,onChange:t=>z(t.target.value)})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-text-muted mb-1",children:"Action on Threshold"}),e.jsxs("select",{className:"w-full rounded-lg border border-border bg-bg-tertiary px-3 py-2 text-sm text-text focus:outline-none focus:border-accent",value:N,onChange:t=>T(t.target.value),children:[e.jsx("option",{value:"warn",children:"Warn"}),e.jsx("option",{value:"pause",children:"Pause"}),e.jsx("option",{value:"stop",children:"Stop"})]})]})]})})]})}export{ae as default};
@@ -1 +0,0 @@
1
- import{r as p,j as t,t as ae,y as re,z as ne,D as ie,F as oe,U as ce,J as de,A as q,K as X}from"./index-Cml2x9pA.js";import"./Button-MdXmb4_n.js";import"./Input-CBTwa_Iw.js";import{S as xe}from"./StatusBadge-BqlvIbdj.js";import{P as J}from"./PageHeader-DdrbS1aq.js";import{S as me}from"./SkeletonLoader-r6OGXaU9.js";import{R as fe}from"./refresh-cw-C-iZkzuS.js";import{L as K}from"./list-todo-BlgfQHup.js";import{D as he}from"./dollar-sign-XxwPAA2a.js";import"./clsx-B-dksMZM.js";import"./chevron-right-DbLSHmff.js";const Q={idle:"textSecondary",active:"success",paused:"warning",error:"error",stopped:"borderLight"},ge={ceo:"C",manager:"M",engineer:"E",researcher:"R",general:"G"};function be({agents:y,activity:i}){const M=p.useRef(null),v=p.useRef(y),A=p.useRef(i);return v.current=y,A.current=i,p.useEffect(()=>{const f=M.current;if(!f)return;const e=f.getContext("2d");if(!e)return;const C=window.devicePixelRatio||1;let L,$=0;const W=()=>{const o=document.documentElement,m=getComputedStyle(o),n=(s,h,l)=>{const S=s?m.getPropertyValue(s).trim():"";return S||m.getPropertyValue(h).trim()||l};return{bg:n("--theme-bg-base","--color-bg","#09090b"),bgTertiary:n("--theme-bg-grain","--color-bg-tertiary","#27272a"),border:n("--theme-metal-dark","--color-border","#3f3f46"),borderLight:n("--theme-metal","--color-border-light","#52525b"),textMuted:n("--theme-ink-soft","--color-text-muted","#71717a"),textSecondary:n("--theme-paper-fg","--color-text-secondary","#a1a1aa"),accent:n("--theme-accent","--color-accent","#6366f1"),accentLight:n(null,"--color-accent-light","#a5b4fc"),success:n(null,"--color-success","#22c55e"),warning:n(null,"--color-warning","#f59e0b"),error:n(null,"--color-error","#ef4444")}},j=()=>{const o=f.clientWidth,m=f.clientHeight;f.width=o*C,f.height=m*C,e.setTransform(C,0,0,C,0,0)};j(),window.addEventListener("resize",j);const w=()=>{$++;const o=$/15,m=f.clientWidth,n=f.clientHeight,s=v.current,h=A.current,l=W();e.fillStyle=l.bg,e.fillRect(0,0,m,n),e.strokeStyle="#141418",e.lineWidth=.5;for(let a=0;a<m;a+=24)e.beginPath(),e.moveTo(a,n*.72),e.lineTo(a,n),e.stroke();for(let a=n*.72;a<n;a+=24)e.beginPath(),e.moveTo(0,a),e.lineTo(m,a),e.stroke();if(s.length===0){e.fillStyle=l.bgTertiary,e.font="12px -apple-system, BlinkMacSystemFont, sans-serif",e.textAlign="center",e.fillText("No agents registered",m/2,n/2-10),e.font="10px -apple-system, BlinkMacSystemFont, sans-serif",e.fillStyle=l.border,e.fillText("Spawn agents to see them here",m/2,n/2+10),e.textAlign="start",L=requestAnimationFrame(w);return}const S=Math.min(s.length,8),I=Math.min(120,(m-20)/S),ee=(m-I*S)/2+I/2;for(let a=0;a<S;a++){const k=s[a],r=ee+a*I,c=n*.55,g=k.status==="active"?"active":k.status,E=l[Q[g]||Q.idle],d=Math.sin(o*.8+a*1.5)*1.5,F=h.some(x=>x.agentId===k.id&&Date.now()-new Date(x.timestamp).getTime()<3e4),D=Math.min(70,I-10),P=10,z=r-D/2,N=c+16;e.fillStyle=l.border,e.fillRect(z,N,D,P),e.fillStyle=l.borderLight,e.fillRect(z+1,N+1,D-2,P-2),e.fillStyle=l.border,e.fillRect(z+3,N+P,3,14),e.fillRect(z+D-6,N+P,3,14);const H=26,O=18,V=r-H/2,U=N-O;e.fillStyle=l.bgTertiary,e.fillRect(V,U,H,O);const Y=g==="error"?l.error:g==="active"?l.success:l.accent;if(e.fillStyle=Y+"30",e.fillRect(V+2,U+2,H-4,O-4),g==="active"||F){e.fillStyle=Y+"60";const x=2+Math.floor(o%3);for(let b=0;b<x;b++){const T=6+Math.sin(o*2+b+a)*5;e.fillRect(V+3,U+3+b*4,T,1.5)}}e.fillStyle=l.border,e.fillRect(r-2,N-1,4,3),e.fillStyle="#1e1e22",e.fillRect(r-10,c+10+d,20,8),e.fillRect(r-11,c-2+d,3,20),e.fillStyle=l.border,e.fillRect(r-7,c+d,14,12);const u=g==="active"&&F?Math.sin(o*1.5+a)*1.5:0;e.fillStyle=l.borderLight,e.fillRect(r-6,c-10+d+u,12,10);const G=Math.sin(o*.3+a*2)>.95?1:2;if(e.fillStyle=E,g==="stopped"?(e.fillRect(r-4,c-7+d+u,2,1),e.fillRect(r-3,c-6+d+u,2,1),e.fillRect(r+1,c-7+d+u,2,1),e.fillRect(r+2,c-6+d+u,2,1)):(e.fillRect(r-4,c-7+d+u,2,G),e.fillRect(r+2,c-7+d+u,2,G)),e.fillStyle=l.borderLight,e.fillRect(r-1,c-14+d+u,2,4),e.fillStyle=E,e.beginPath(),e.arc(r,c-15+d+u,2,0,Math.PI*2),e.fill(),g==="active"&&(e.globalAlpha=.3+Math.sin(o*3+a)*.2,e.beginPath(),e.arc(r,c-15+d+u,5,0,Math.PI*2),e.fill(),e.globalAlpha=1),g==="active"&&F){const x=Math.sin(o*6+a)*2,b=Math.sin(o*6+a+Math.PI)*2;e.fillStyle=l.border,e.fillRect(r-11,c+3+d+x,4,3),e.fillRect(r+7,c+3+d+b,4,3)}else e.fillStyle=l.border,e.fillRect(r-10,c+5+d,3,6),e.fillRect(r+7,c+5+d,3,6);if(g==="active"&&F){for(let x=0;x<2;x++){const b=o*1.5+x*Math.PI+a,T=14+Math.sin(o+x)*4,se=r+Math.cos(b)*T,le=c-3+Math.sin(b)*T*.4+d;e.globalAlpha=.25+Math.sin(o*2+x)*.15,e.fillStyle=E,e.beginPath(),e.arc(se,le,1,0,Math.PI*2),e.fill()}e.globalAlpha=1}if(g==="error"){for(let x=0;x<3;x++){const b=r+Math.sin(o*4+x*2)*12,T=c-5+Math.cos(o*3+x)*8+d;e.globalAlpha=.4+Math.sin(o+x)*.3,e.fillStyle=l.error,e.fillRect(b-1,T-1,2,2)}e.globalAlpha=1}e.fillStyle=g==="stopped"?l.border:l.textMuted,e.font="9px -apple-system, BlinkMacSystemFont, sans-serif",e.textAlign="center";const _=Math.max(44,D+14);let R=k.name;if(e.measureText(R).width>_){for(;R.length>1&&e.measureText(R+"…").width>_;)R=R.slice(0,-1);R=R.trimEnd()+"…"}e.fillText(R,r,N+P+24);const te=ge[k.role]||"G";e.fillStyle=E+"60",e.font="bold 7px -apple-system, BlinkMacSystemFont, sans-serif",e.fillText(te,r,N+P+33),e.textAlign="start"}if(e.fillStyle=l.bgTertiary,e.font="bold 9px -apple-system, BlinkMacSystemFont, sans-serif",e.textAlign="center",e.fillText("COMMAND POST",m/2,n-6),e.textAlign="start",h.length>0){const a=h[h.length-1];if(Date.now()-new Date(a.timestamp).getTime()<6e4){e.fillStyle=l.accent+"40",e.fillRect(0,0,m,16),e.fillStyle=l.accentLight,e.font="8px -apple-system, BlinkMacSystemFont, sans-serif";const r=a.message.length>60?a.message.slice(0,57)+"...":a.message;e.textAlign="center",e.fillText(r,m/2,11),e.textAlign="start"}}L=requestAnimationFrame(w)};return w(),()=>{cancelAnimationFrame(L),window.removeEventListener("resize",j)}},[]),t.jsx("canvas",{ref:M,className:"w-full rounded-xl border border-border",style:{height:220,imageRendering:"pixelated"}})}function Z(y){const i=Math.floor((Date.now()-new Date(y).getTime())/1e3);return i<60?`${i}s`:i<3600?`${Math.floor(i/60)}m`:i<86400?`${Math.floor(i/3600)}h`:`${Math.floor(i/86400)}d`}function B({icon:y,label:i,value:M,sub:v,color:A}){return t.jsxs("div",{className:"bg-bg-tertiary/50 border border-border rounded-xl p-4",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx(y,{size:14,className:A}),t.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:i})]}),t.jsx("div",{className:"text-2xl font-bold text-text",children:M}),v&&t.jsx("div",{className:"text-[11px] text-text-muted mt-1",children:v})]})}function Pe(){var n;const{toast:y}=ae(),[i,M]=p.useState(null),[v,A]=p.useState([]),[f,e]=p.useState([]),[C,L]=p.useState(0),[$,W]=p.useState(!0),j=p.useCallback(async()=>{try{const[s,h,l,S]=await Promise.all([re(),ne(20),ie(),oe("pending")]);M(s),A(h),e(l),L(S.length)}catch(s){M(h=>(h===null&&y("error",`Couldn't load the dashboard — try again. ${s.message}`),h))}W(!1)},[y]);if(p.useEffect(()=>{j();const s=setInterval(j,15e3);return()=>clearInterval(s)},[j]),$)return t.jsxs("div",{className:"space-y-6",children:[t.jsx(J,{title:"Dashboard",breadcrumbs:[{label:"Command Post"},{label:"Dashboard"}]}),t.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:t.jsx(me,{variant:"metric",count:4})})]});if(!i)return t.jsx("div",{className:"text-center py-12 text-text-muted",children:"Failed to load dashboard"});const w=i.budgetUtilization??0,o=f.filter(s=>s.status==="in_progress").length,m=f.filter(s=>s.status==="blocked").length;return t.jsxs("div",{className:"space-y-6",children:[t.jsx(J,{title:"Dashboard",breadcrumbs:[{label:"Command Post"},{label:"Dashboard"}],actions:t.jsx("button",{onClick:j,className:"p-1.5 text-text-muted hover:text-text rounded-lg hover:bg-bg-tertiary transition-colors",children:t.jsx(fe,{size:16})})}),t.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[t.jsx(B,{icon:ce,label:"Agents Enabled",value:i.totalAgents,sub:`${i.activeAgents} running, ${Math.max(0,i.totalAgents-i.activeAgents)} paused`,color:"text-info"}),t.jsx(B,{icon:K,label:"Tasks In Progress",value:o,sub:`${f.length} open, ${m} blocked`,color:"text-warning"}),t.jsx(B,{icon:he,label:"Budget Used",value:`${Math.round(w)}%`,sub:w>=80?"Nearing limit":"Healthy",color:w>=80?"text-error":"text-success"}),t.jsx(B,{icon:de,label:"Goals",value:((n=i.goalTree)==null?void 0:n.length)??0,sub:"in hierarchy",color:"text-purple"})]}),i.agents.length>0&&t.jsx(be,{agents:i.agents,activity:v}),t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[t.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(q,{size:14,className:"text-accent"}),t.jsx("h3",{className:"text-sm font-semibold text-text",children:"Recent Activity"})]}),t.jsx(X,{to:"/command-post/activity",className:"text-[10px] text-accent hover:text-accent-hover",children:"View all"})]}),t.jsx("div",{className:"max-h-72 overflow-y-auto divide-y divide-border",children:v.length===0?t.jsx("div",{className:"py-8 text-center text-xs text-text-muted",children:"No activity yet"}):[...v].reverse().slice(0,15).map((s,h)=>t.jsxs("div",{className:"flex items-start gap-2 px-4 py-2",children:[t.jsx(q,{size:12,className:"text-text-muted mt-0.5 flex-shrink-0"}),t.jsx("span",{className:"text-[11px] text-text-secondary flex-1",children:s.message}),t.jsx("span",{className:"text-[10px] text-text-muted flex-shrink-0",children:Z(s.timestamp)})]},`${s.timestamp}-${h}`))})]}),t.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl overflow-hidden",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(K,{size:14,className:"text-accent"}),t.jsx("h3",{className:"text-sm font-semibold text-text",children:"Recent Issues"})]}),t.jsx(X,{to:"/command-post/issues",className:"text-[10px] text-accent hover:text-accent-hover",children:"View all"})]}),t.jsx("div",{className:"max-h-72 overflow-y-auto divide-y divide-border",children:f.length===0?t.jsx("div",{className:"py-8 text-center text-xs text-text-muted",children:"No issues yet"}):f.slice(0,10).map(s=>t.jsxs(X,{to:`/command-post/issues/${s.id}`,className:"flex items-center gap-2 px-4 py-2 hover:bg-bg-tertiary transition-colors",children:[t.jsx(xe,{status:s.status,variant:"dot",size:"sm"}),t.jsx("span",{className:"text-[11px] text-text-secondary flex-1 truncate",children:s.title}),s.assigneeAgentId&&t.jsx("span",{className:"text-[10px] text-text-muted",children:s.assigneeAgentId}),t.jsx("span",{className:"text-[10px] text-text-muted flex-shrink-0",children:Z(s.updatedAt)})]},s.id))})]})]})]})}export{Pe as default};
@@ -1 +0,0 @@
1
- import{r as i,j as e,b as f,X as j}from"./index-Cml2x9pA.js";import{P as v}from"./PageHeader-DdrbS1aq.js";import{F as y}from"./folder-DAdIw-Pb.js";import{F as N}from"./flask-conical-Ql8QxhgY.js";import{S as w}from"./search-D10l0m3-.js";import{R as p}from"./refresh-cw-C-iZkzuS.js";import{F as k}from"./file-text-Cfawu8Bs.js";import"./chevron-right-DbLSHmff.js";async function h(t){const a=await f(t);if(!a.ok)throw new Error(`HTTP ${a.status}`);return a.json()}function b(t){return t===void 0?"—":t<1024?`${t}B`:t<1024*1024?`${(t/1024).toFixed(1)}K`:`${(t/1024/1024).toFixed(1)}M`}function g(t){const a=Math.floor((Date.now()-new Date(t).getTime())/1e3);return a<60?`${a}s`:a<3600?`${Math.floor(a/60)}m`:a<86400?`${Math.floor(a/3600)}h`:`${Math.floor(a/86400)}d`}function C({path:t,onClose:a}){const[r,c]=i.useState(null);return i.useEffect(()=>{c(null),h(`/api/files/content?path=${encodeURIComponent(t)}`).then(l=>c(l)).catch(l=>c({error:String(l)}))},[t]),e.jsx("div",{className:"fixed inset-0 z-50 bg-black/60 flex items-center justify-center p-4",onClick:a,children:e.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl w-full max-w-5xl max-h-[90vh] flex flex-col shadow-2xl",onClick:l=>l.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-text truncate",children:t}),r&&"sizeBytes"in r&&e.jsxs("div",{className:"text-xs text-text-muted",children:[b(r.sizeBytes)," · ",r.encoding,r.truncated?" · truncated at 1MB":""]})]}),e.jsx("button",{onClick:a,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted",title:"Close",children:e.jsx(j,{size:18})})]}),e.jsxs("div",{className:"flex-1 overflow-auto p-4",children:[r===null&&e.jsx("div",{className:"text-center py-12 text-text-muted text-sm",children:"Loading…"}),r&&"error"in r&&e.jsx("div",{className:"text-error text-sm py-8 text-center",children:r.error}),r&&"content"in r&&e.jsx("pre",{className:"text-[12px] font-mono leading-snug whitespace-pre-wrap text-text-secondary",children:r.content})]})]})})}function S(){const[t,a]=i.useState([]),[r,c]=i.useState(!0),[l,m]=i.useState(""),[o,n]=i.useState(null),d=i.useCallback(async()=>{c(!0);try{const s=await h("/api/files/edited?limit=300");a(s.files||[])}catch{}c(!1)},[]);i.useEffect(()=>{d()},[d]);const x=l?t.filter(s=>s.path.toLowerCase().includes(l.toLowerCase())):t;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex-1 flex items-center gap-2 px-3 py-1.5 rounded-lg border border-border bg-bg-secondary",children:[e.jsx(w,{size:14,className:"text-text-muted"}),e.jsx("input",{type:"text",placeholder:"Filter by path…",value:l,onChange:s=>m(s.target.value),className:"flex-1 bg-transparent text-sm outline-none"})]}),e.jsxs("button",{onClick:d,className:"px-3 py-1.5 rounded-lg border border-border bg-bg-secondary text-sm hover:bg-bg-tertiary flex items-center gap-1.5",title:"Refresh",children:[e.jsx(p,{size:14,className:r?"animate-spin":""}),r?"Loading":"Refresh"]}),e.jsxs("div",{className:"text-xs text-text-muted",children:[x.length," / ",t.length]})]}),r&&t.length===0&&e.jsx("div",{className:"text-center py-12 text-text-muted text-sm",children:"Loading…"}),!r&&x.length===0&&e.jsx("div",{className:"text-center py-12 text-text-muted text-sm",children:l?"No files match filter":"No file edits recorded yet"}),x.length>0&&e.jsx("div",{className:"divide-y divide-border rounded-xl border border-border bg-bg-secondary overflow-hidden",children:x.map(s=>e.jsxs("button",{onClick:()=>s.readable&&s.exists&&n(s.path),disabled:!s.readable||!s.exists,className:"w-full flex items-start gap-3 px-4 py-2.5 text-left hover:bg-bg-tertiary transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[e.jsx(k,{size:14,className:s.isSelfMod?"text-accent mt-0.5 flex-shrink-0":"text-text-muted mt-0.5 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-mono text-text truncate",children:s.path}),e.jsxs("div",{className:"text-xs text-text-muted mt-0.5 flex items-center gap-2 flex-wrap",children:[s.isSelfMod&&e.jsx("span",{className:"px-1 rounded bg-accent/15 text-accent text-[10px]",children:"self-mod"}),e.jsxs("span",{children:["×",s.writeCount]}),s.tools.length>0&&e.jsx("span",{children:s.tools.join("+")}),s.channels.length>0&&e.jsxs("span",{children:["via ",s.channels.join(", ")]}),!s.exists&&e.jsx("span",{className:"text-warn",children:"deleted"}),e.jsx("span",{children:b(s.sizeBytes)})]})]}),e.jsx("div",{className:"text-xs text-text-muted flex-shrink-0",children:g(s.lastWrittenAt)})]},s.path))}),o&&e.jsx(C,{path:o,onClose:()=>n(null)})]})}function F(){const[t,a]=i.useState([]),[r,c]=i.useState(!0),[l,m]=i.useState(null),o=i.useCallback(async()=>{c(!0);try{const n=await h("/api/research/recent?limit=50");a(n.research||[])}catch{}c(!1)},[]);return i.useEffect(()=>{o()},[o]),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:o,className:"px-3 py-1.5 rounded-lg border border-border bg-bg-secondary text-sm hover:bg-bg-tertiary flex items-center gap-1.5",children:[e.jsx(p,{size:14,className:r?"animate-spin":""}),r?"Loading":"Refresh"]}),e.jsxs("div",{className:"text-xs text-text-muted",children:[t.length," items"]})]}),r&&t.length===0&&e.jsx("div",{className:"text-center py-12 text-text-muted text-sm",children:"Loading…"}),!r&&t.length===0&&e.jsx("div",{className:"text-center py-12 text-text-muted text-sm",children:"No research recorded yet. Complete a goal and results will appear here."}),e.jsx("div",{className:"space-y-2",children:t.map(n=>{var u;const d=l===n.id,x=n.content.slice(0,200),s=n.subtaskTitle?`${n.goalTitle} — ${n.subtaskTitle}`:((u=n.tags)==null?void 0:u.join(" · "))||n.kind;return e.jsxs("div",{className:"rounded-xl border border-border bg-bg-secondary overflow-hidden",children:[e.jsxs("button",{onClick:()=>m(d?null:n.id),className:"w-full text-left px-4 py-3 hover:bg-bg-tertiary transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded bg-bg-tertiary text-text-muted uppercase tracking-wide font-medium",children:n.kind.replace(/_/g," ")}),e.jsx("span",{className:"text-xs text-text-muted",children:g(n.at)})]}),e.jsx("div",{className:"text-sm font-medium text-text truncate",children:s}),!d&&e.jsxs("div",{className:"text-xs text-text-secondary mt-1 line-clamp-2",children:[x,n.content.length>200?"…":""]})]}),d&&e.jsx("div",{className:"px-4 pb-4",children:e.jsx("pre",{className:"text-[12px] font-mono leading-snug whitespace-pre-wrap text-text-secondary",children:n.content})})]},n.id)})})]})}function P(){const[t,a]=i.useState("files");return e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{title:"Files & Research",subtitle:"Files edited by agents and research notes captured during missions",breadcrumbs:[{label:"Admin",href:"/overview"},{label:"Tools"},{label:"Files"}]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>a("files"),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm transition-colors ${t==="files"?"bg-accent/15 text-accent border border-accent/30":"text-text-secondary hover:text-text hover:bg-bg-tertiary border border-transparent"}`,children:[e.jsx(y,{size:14})," Files edited"]}),e.jsxs("button",{onClick:()=>a("research"),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm transition-colors ${t==="research"?"bg-accent/15 text-accent border border-accent/30":"text-text-secondary hover:text-text hover:bg-bg-tertiary border border-transparent"}`,children:[e.jsx(N,{size:14})," Research"]})]}),t==="files"?e.jsx(S,{}):e.jsx(F,{})]})}export{P as default};
@@ -1 +0,0 @@
1
- import{r as i,Y as D,j as e,J as N,$,X as M,b as y}from"./index-Cml2x9pA.js";import{B as j}from"./Button-MdXmb4_n.js";import"./Input-CBTwa_Iw.js";import{S as z}from"./StatusBadge-BqlvIbdj.js";import{P as O}from"./PageHeader-DdrbS1aq.js";import{E as A}from"./EmptyState-D9kQf1PX.js";import{M as F}from"./Modal-ybPGvlQs.js";import{S as L}from"./SkeletonLoader-r6OGXaU9.js";import{P as B}from"./plus-Dpo1qfrl.js";import{C as I}from"./chevron-right-DbLSHmff.js";import{T as J}from"./trash-2-CTeyjxD_.js";import"./clsx-B-dksMZM.js";function U(t){const a=Math.floor((Date.now()-new Date(t).getTime())/1e3);return a<60?`${a}s`:a<3600?`${Math.floor(a/60)}m`:a<86400?`${Math.floor(a/3600)}h`:`${Math.floor(a/86400)}d`}const _=["pending","in_progress","completed","blocked"];function H({node:t,onClose:a,onRefresh:l}){const[d,c]=i.useState(!1),[x,m]=i.useState(!1),r=t.goal,g=async()=>{c(!0);try{await y(`/api/goals/${r.id}`,{method:"DELETE"}),l(),a()}catch{}c(!1)},o=async n=>{m(!0);try{await y(`/api/goals/${r.id}`,{method:"PATCH",body:JSON.stringify({status:n})}),l()}catch{}m(!1)};return e.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"text-lg font-semibold text-text",children:r.title}),r.description&&e.jsx("p",{className:"text-sm text-text-secondary mt-1",children:r.description})]}),e.jsx("button",{onClick:a,className:"p-1 text-text-muted hover:text-text rounded-lg hover:bg-bg-tertiary transition-colors",children:e.jsx(M,{size:16})})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 text-xs",children:[e.jsxs("div",{className:"bg-bg-tertiary/50 rounded-lg px-3 py-2",children:[e.jsx("span",{className:"text-text-muted",children:"Status: "}),e.jsx(z,{status:r.status,size:"sm"})]}),r.progress>0&&e.jsxs("div",{className:"bg-bg-tertiary/50 rounded-lg px-3 py-2",children:[e.jsx("span",{className:"text-text-muted",children:"Progress: "}),e.jsxs("span",{className:"text-text font-medium",children:[Math.round(r.progress),"%"]})]}),t.children.length>0&&e.jsxs("div",{className:"bg-bg-tertiary/50 rounded-lg px-3 py-2",children:[e.jsx("span",{className:"text-text-muted",children:"Sub-goals: "}),e.jsxs("span",{className:"text-text font-medium",children:[t.children.filter(n=>n.goal.status==="completed"||n.goal.status==="done").length,"/",t.children.length," done"]})]}),e.jsxs("div",{className:"bg-bg-tertiary/50 rounded-lg px-3 py-2",children:[e.jsx("span",{className:"text-text-muted",children:"Updated: "}),e.jsxs("span",{className:"text-text font-medium",children:[U(r.updatedAt||r.createdAt||new Date().toISOString())," ago"]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-text-muted mb-2",children:"Change Status"}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:_.map(n=>e.jsx("button",{disabled:x||r.status===n,onClick:()=>o(n),className:`px-3 py-1.5 rounded-lg text-xs font-medium transition-colors ${r.status===n?"bg-accent/20 text-accent border border-accent/30":"bg-bg-tertiary text-text-secondary hover:bg-bg-tertiary/80 border border-border"} disabled:opacity-50`,children:n.replace("_"," ")},n))})]}),e.jsx("div",{className:"pt-2 border-t border-border flex justify-end",children:e.jsxs("button",{onClick:g,disabled:d,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium text-error hover:bg-error/10 transition-colors disabled:opacity-50",children:[e.jsx(J,{size:12}),d?"Deleting...":"Delete Goal"]})})]})}function T({node:t,expanded:a,toggleExpand:l,selectedId:d,onSelect:c}){const x=t.children.length>0,m=a.has(t.goal.id),r=d===t.goal.id,g=t.children.filter(o=>o.goal.status==="completed"||o.goal.status==="done").length;return e.jsxs("div",{children:[e.jsxs("div",{className:`flex items-center gap-2 py-2 px-3 rounded-lg transition-colors cursor-pointer group ${r?"bg-accent/10 border-l-2 border-accent":"hover:bg-bg-tertiary/50"}`,style:{paddingLeft:`${t.depth*24+12}px`},onClick:()=>c(t),children:[x?e.jsx("button",{onClick:o=>{o.stopPropagation(),l(t.goal.id)},className:"p-0.5 rounded hover:bg-bg-tertiary transition-colors",children:m?e.jsx($,{size:14,className:"text-text-muted"}):e.jsx(I,{size:14,className:"text-text-muted"})}):e.jsx("span",{className:"w-[18px] flex-shrink-0"}),e.jsx(N,{size:14,className:r?"text-accent":"text-text-muted"}),e.jsx("span",{className:"text-sm text-text flex-1 truncate",children:t.goal.title}),e.jsx(z,{status:t.goal.status,size:"sm"}),x&&e.jsxs("span",{className:"text-[10px] text-text-muted",children:[g,"/",t.children.length]}),t.goal.progress>0&&e.jsx("div",{className:"w-16 h-1.5 bg-bg-tertiary rounded-full overflow-hidden flex-shrink-0",children:e.jsx("div",{className:"h-full bg-accent rounded-full transition-all",style:{width:`${Math.min(100,t.goal.progress)}%`}})})]}),x&&m&&e.jsx("div",{children:t.children.map(o=>e.jsx(T,{node:o,expanded:a,toggleExpand:l,selectedId:d,onSelect:c},o.goal.id))})]})}function E(t,a){for(const l of t){if(l.goal.id===a)return l;const d=E(l.children,a);if(d)return d}return null}function ae(){const[t,a]=i.useState([]),[l,d]=i.useState(!0),[c,x]=i.useState(null),[m,r]=i.useState(new Set),[g,o]=i.useState(null),[n,u]=i.useState(!1),[p,v]=i.useState(""),[P,S]=i.useState(!1),b=i.useCallback(async()=>{try{const s=await D();a(s),r(new Set(s.map(h=>h.goal.id))),x(null)}catch(s){x(s instanceof Error?s.message:"Failed to load goals")}d(!1)},[]);i.useEffect(()=>{b()},[b]);const C=s=>{r(h=>{const f=new Set(h);return f.has(s)?f.delete(s):f.add(s),f})},G=s=>{o(h=>h===s.goal.id?null:s.goal.id),s.children.length>0&&!m.has(s.goal.id)&&C(s.goal.id)},w=async()=>{if(p.trim()){S(!0);try{await y("/api/command-post/goals",{method:"POST",body:JSON.stringify({title:p.trim()})}),u(!1),v(""),await b()}catch{}S(!1)}},k=g?E(t,g):null;return e.jsxs("div",{className:"space-y-4",children:[e.jsx(O,{title:"Goals",breadcrumbs:[{label:"Command Post"},{label:"Goals"}],actions:e.jsx(j,{size:"sm",icon:e.jsx(B,{size:14}),onClick:()=>u(!0),children:"Create Goal"})}),l&&e.jsx(L,{variant:"row",count:5}),c&&e.jsx("div",{className:"text-center py-8 text-error text-sm",children:c}),!l&&!c&&t.length===0&&e.jsx(A,{icon:e.jsx(N,{size:32}),title:"No goals",description:"Create your first goal to start organizing agent work.",action:{label:"Create Goal",onClick:()=>u(!0)}}),!l&&!c&&t.length>0&&e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"lg:col-span-2 rounded-xl border border-border bg-bg-secondary overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-border flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-text-muted",children:[t.length," top-level goal",t.length!==1?"s":""]}),e.jsx("span",{className:"text-[10px] text-text-muted",children:"Click a goal to view details"})]}),e.jsx("div",{className:"divide-y divide-border",children:t.map(s=>e.jsx(T,{node:s,expanded:m,toggleExpand:C,selectedId:g,onSelect:G},s.goal.id))})]}),e.jsx("div",{className:"lg:col-span-1",children:k?e.jsx(H,{node:k,onClose:()=>o(null),onRefresh:b}):e.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl p-8 text-center",children:[e.jsx(N,{size:24,className:"text-text-muted mx-auto mb-2"}),e.jsx("p",{className:"text-xs text-text-muted",children:"Select a goal to view details"})]})})]}),e.jsx(F,{open:n,onClose:()=>u(!1),title:"Create Goal",footer:e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"secondary",size:"sm",onClick:()=>u(!1),children:"Cancel"}),e.jsx(j,{size:"sm",onClick:w,loading:P,disabled:!p.trim(),children:"Create"})]}),children:e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-text-muted mb-1",children:"Goal Title"}),e.jsx("input",{className:"w-full rounded-lg border border-border bg-bg-tertiary px-3 py-2 text-sm text-text placeholder:text-text-muted focus:outline-none focus:border-accent",placeholder:"Enter goal title...",value:p,onChange:s=>v(s.target.value),onKeyDown:s=>s.key==="Enter"&&w(),autoFocus:!0})]})})]})}export{ae as default};
@@ -1,11 +0,0 @@
1
- import{c as P,r as d,t as D,j as e,bl as G,bN as J,u as Y,F as Z,a0 as ee,a1 as te,D as se,m as re,P as T,X as I,$ as ae,K as E,bO as ne,Q as ie,V as oe,bP as le,b as de}from"./index-Cml2x9pA.js";import{B as m}from"./Button-MdXmb4_n.js";import"./Input-CBTwa_Iw.js";import{P as ce}from"./PageHeader-DdrbS1aq.js";import{E as xe}from"./EmptyState-D9kQf1PX.js";import{T as ue}from"./Tabs-DdUThlp1.js";import{S as pe}from"./SkeletonLoader-r6OGXaU9.js";import{e as he}from"./approvalHeadline-DB9SgR-9.js";import{M as F}from"./message-square-CRsG9u6_.js";import{B as U}from"./bot-DvEcyQcD.js";import{C}from"./clock-JyQAYy6X.js";import{S as me}from"./send-DtXGsaFW.js";import{S as ge}from"./shield-check-CXlDJyAW.js";import{C as B}from"./check-CuRYh4Zh.js";import{F as fe}from"./funnel-FycfZcXo.js";import{S as be,C as ve}from"./square-BBC-JKzY.js";import{R as je}from"./rotate-ccw-qzrB3SNw.js";import"./clsx-B-dksMZM.js";import"./chevron-right-DbLSHmff.js";/**
2
- * @license lucide-react v0.513.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const ye=[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]],ke=P("inbox",ye);/**
7
- * @license lucide-react v0.513.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const we=[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Ne=P("square-check-big",we);function Se(o){return new Date(o).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function ze({approval:o,onReply:l}){const[u,y]=d.useState(""),[f,j]=d.useState(!1),{toast:x}=D(),k=o.thread||[],p=async()=>{if(u.trim()){j(!0);try{await J(o.id,"user",u.trim()),y(""),l==null||l(),x("success","Reply sent")}catch{x("error","Failed to send reply")}j(!1)}};return e.jsxs("div",{className:"space-y-3 mt-3",children:[k.length===0&&e.jsxs("div",{className:"text-xs text-text-muted italic flex items-center gap-1",children:[e.jsx(F,{size:12}),"No replies yet. Start the conversation below."]}),k.map(r=>e.jsxs("div",{className:`flex gap-2 ${r.authorUser?"flex-row":"flex-row-reverse"}`,children:[e.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center flex-shrink-0 ${r.authorUser?"bg-accent/20 text-accent":"bg-warning/20 text-warning"}`,children:r.authorUser?e.jsx(G,{size:12}):e.jsx(U,{size:12})}),e.jsxs("div",{className:`max-w-[80%] rounded-lg px-3 py-2 text-xs ${r.authorUser?"bg-bg-tertiary text-text":"bg-warning/10 text-text border border-warning/20"}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[e.jsx("span",{className:"font-semibold",children:r.authorUser||r.authorAgentId||"Agent"}),e.jsx(C,{size:10,className:"text-text-muted"}),e.jsx("span",{className:"text-text-muted",children:Se(r.createdAt)})]}),e.jsx("div",{className:"whitespace-pre-wrap",children:r.body})]})]},r.id)),e.jsxs("div",{className:"flex items-end gap-2 pt-2",children:[e.jsx("textarea",{value:u,onChange:r=>y(r.target.value),placeholder:"Reply to this agent...",className:"flex-1 min-h-[60px] rounded-lg border border-border bg-bg px-3 py-2 text-xs text-text outline-none focus:border-accent resize-none",onKeyDown:r=>{r.key==="Enter"&&!r.shiftKey&&(r.preventDefault(),p())}}),e.jsx("button",{onClick:p,disabled:f||!u.trim(),className:"h-8 w-8 rounded-lg bg-accent text-white flex items-center justify-center disabled:opacity-40 hover:bg-accent/90 transition-colors",children:e.jsx(me,{size:14})})]})]})}function Ce(o){const l=Math.floor((Date.now()-new Date(o).getTime())/1e3);return l<60?`${l}s`:l<3600?`${Math.floor(l/60)}m`:l<86400?`${Math.floor(l/3600)}h`:`${Math.floor(l/86400)}d`}function Ae(o){return!!o.snoozedUntil&&new Date(o.snoozedUntil)>new Date}function Xe(){const[o,l]=d.useState([]),[u,y]=d.useState(!0),[f,j]=d.useState(null),[x,k]=d.useState("all"),[p,r]=d.useState(null),[q,M]=d.useState(null),[w,S]=d.useState(new Set),[N,L]=d.useState("all"),{toast:c}=D(),V=Y(),h=d.useCallback(async()=>{try{const[t,n,a,b]=await Promise.all([Z("pending"),ee(void 0,50),te(),se({status:"blocked"})]),i=[];t.forEach(s=>{const v=he(s),g=s.type==="custom"&&s.payload.kind==="driver_blocked",R=s.type==="custom"&&s.payload.kind==="self_mod_pr";i.push({id:`approval-${s.id}`,kind:"approval",icon:ge,iconColor:g?"text-error":R?"text-warning":"text-accent",urgency:g||R?"high":"medium",message:`${v.kindLabel}: ${v.headline}`,timestamp:s.createdAt,data:s})}),n.filter(s=>s.status==="failed"||s.status==="error").forEach(s=>i.push({id:`run-${s.id}`,kind:"failed_run",icon:re,iconColor:"text-error",urgency:"high",message:`Run failed: ${s.agentId} — ${s.error??"unknown error"}`,timestamp:s.finishedAt??s.startedAt,data:s})),a.filter(s=>s.status==="error").forEach(s=>i.push({id:`agent-${s.id}`,kind:"error_agent",icon:T,iconColor:"text-error",urgency:"high",message:`Agent error: ${s.name}`,timestamp:s.lastHeartbeat,data:s})),b.forEach(s=>i.push({id:`issue-${s.id}`,kind:"blocked_issue",icon:T,iconColor:"text-warning",urgency:"medium",message:`Blocked: ${s.identifier} — ${s.title}`,timestamp:s.updatedAt,data:s})),i.sort((s,v)=>{const g={high:0,medium:1,low:2};return g[s.urgency]!==g[v.urgency]?g[s.urgency]-g[v.urgency]:new Date(v.timestamp).getTime()-new Date(s.timestamp).getTime()}),l(i),j(null)}catch(t){j(t instanceof Error?t.message:"Failed to load inbox")}y(!1)},[]);d.useEffect(()=>{h()},[h]);const H=async t=>{r(t.id);try{await ie(t.id,"user"),await h();const n=t.type==="goal_proposal"||t.type==="soma_proposal",a=t.type==="custom"&&t.payload.kind==="driver_blocked";c("success",n?"Work approved — TITAN is starting…":a?"Unblocked — TITAN is resuming…":"Approved"),(n||a)&&V("/command-post",{state:{tab:"Work"}})}catch{c("error","Approval failed")}r(null)},O=async t=>{r(t.id);try{await oe(t.id,"user"),await h(),c("success","Rejected")}catch{c("error","Reject failed")}r(null)},K=async(t,n)=>{r(t.id);try{const a=new Date(Date.now()+n*6e4).toISOString();await le(t.id,a),await h(),c("success",`Snoozed for ${n}m`)}catch{c("error","Snooze failed")}r(null)},W=async t=>{r(t.id);try{const n=await de(`/api/command-post/runs/${t.id}/retry`,{method:"POST"});if(!n.ok)throw new Error(`${n.status} ${n.statusText}`);await h(),c("success","Retry queued — TITAN will try again")}catch{c("error","Retry failed")}r(null)},X=t=>{S(n=>{const a=new Set(n);return a.has(t)?a.delete(t):a.add(t),a})},A=async t=>{const n=Array.from(w).map(a=>{var b;return(b=o.find(i=>i.id===a))==null?void 0:b.data}).filter(a=>(a==null?void 0:a.id)!==void 0).map(a=>a.id);if(n.length!==0){r("batch");try{await ne(n,t,"user"),S(new Set),await h(),c("success",`${t==="approve"?"Approved":"Rejected"} ${n.length} item(s)`)}catch{c("error","Batch action failed")}r(null)}},z=o.filter(t=>x==="all"?!0:x==="approvals"?t.kind==="approval":x==="failed_runs"?t.kind==="failed_run":x==="errors"?t.kind==="error_agent"||t.kind==="blocked_issue":!0).filter(t=>N==="all"?!0:t.kind==="approval"?t.data.requestedBy===N:t.kind==="failed_run"?t.data.agentId===N:!0),$=o.filter(t=>t.kind==="approval"),Q=[{id:"all",label:"All",count:o.length},{id:"approvals",label:"Approvals",count:$.length},{id:"failed_runs",label:"Failed Runs",count:o.filter(t=>t.kind==="failed_run").length},{id:"errors",label:"Errors",count:o.filter(t=>t.kind==="error_agent"||t.kind==="blocked_issue").length}],_=Array.from(new Set($.map(t=>t.data.requestedBy))).filter(Boolean);return e.jsxs("div",{className:"space-y-4",children:[e.jsx(ce,{title:"Inbox",breadcrumbs:[{label:"Command Post"},{label:"Inbox"}]}),w.size>0&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-accent/10 border border-accent/20",children:[e.jsxs("span",{className:"text-xs font-medium text-accent",children:[w.size," selected"]}),e.jsx("div",{className:"flex-1"}),e.jsx(m,{size:"sm",variant:"ghost",onClick:()=>A("approve"),loading:p==="batch",icon:e.jsx(B,{size:14}),children:"Approve All"}),e.jsx(m,{size:"sm",variant:"ghost",onClick:()=>A("reject"),loading:p==="batch",icon:e.jsx(I,{size:14}),children:"Reject All"}),e.jsx("button",{onClick:()=>S(new Set),className:"text-xs text-text-muted hover:text-text px-2",children:"Clear"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ue,{tabs:Q,activeTab:x,onChange:k}),e.jsx("div",{className:"flex-1"}),x==="approvals"&&_.length>0&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(fe,{size:12,className:"text-text-muted"}),e.jsxs("select",{value:N,onChange:t=>L(t.target.value),className:"text-xs bg-bg border border-border rounded px-2 py-1 outline-none focus:border-accent",children:[e.jsx("option",{value:"all",children:"All agents"}),_.map(t=>e.jsx("option",{value:t,children:t},t))]})]})]}),u&&e.jsx(pe,{variant:"row",count:5}),f&&e.jsx("div",{className:"text-center py-8 text-error text-sm",children:f}),!u&&!f&&z.length===0&&e.jsx(xe,{icon:e.jsx(ke,{size:32}),title:"Inbox empty",description:"No pending items require your attention."}),!u&&!f&&z.length>0&&e.jsx("div",{className:"space-y-2",children:z.map(t=>{const n=t.icon,a=q===t.id,b=w.has(t.id),i=t.kind==="approval"?t.data:null;return e.jsxs("div",{className:`rounded-xl border overflow-hidden transition-colors ${t.urgency==="high"?"border-error/30 bg-error/5":t.urgency==="medium"?"border-warning/20 bg-warning/[0.03]":"border-border bg-bg-secondary"}`,children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[t.kind==="approval"&&e.jsx("button",{onClick:()=>X(t.id),className:"text-text-muted hover:text-accent transition-colors",children:b?e.jsx(Ne,{size:16,className:"text-accent"}):e.jsx(be,{size:16})}),e.jsx(n,{size:16,className:t.iconColor}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm text-text font-medium truncate",children:t.message}),e.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-text-muted mt-0.5",children:[i&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(U,{size:10}),i.requestedBy]}),i.thread&&i.thread.length>0&&e.jsxs("span",{className:"flex items-center gap-1 text-accent",children:[e.jsx(F,{size:10}),i.thread.length]}),Ae(i)&&e.jsxs("span",{className:"flex items-center gap-1 text-warning",children:[e.jsx(C,{size:10}),"Snoozed"]})]}),e.jsx("span",{children:Ce(t.timestamp)})]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[t.kind==="approval"&&e.jsxs(e.Fragment,{children:[e.jsx(m,{size:"sm",variant:"ghost",onClick:()=>H(t.data),loading:p===t.data.id,icon:e.jsx(B,{size:14}),children:"Approve"}),e.jsx(m,{size:"sm",variant:"ghost",onClick:()=>O(t.data),loading:p===t.data.id,icon:e.jsx(I,{size:14}),children:"Reject"}),e.jsxs("div",{className:"relative group",children:[e.jsx(m,{size:"sm",variant:"ghost",icon:e.jsx(C,{size:14}),children:"Snooze"}),e.jsx("div",{className:"absolute right-0 top-full mt-1 hidden group-hover:flex flex-col gap-1 bg-bg border border-border rounded-lg p-1 shadow-lg z-10",children:[15,60,240,1440].map(s=>e.jsx("button",{onClick:()=>K(t.data,s),className:"text-xs text-left px-2 py-1 rounded hover:bg-bg-tertiary whitespace-nowrap",children:s<60?`${s}m`:s<1440?`${s/60}h`:`${s/1440}d`},s))})]}),e.jsx("button",{onClick:()=>M(a?null:t.id),className:"p-1.5 rounded hover:bg-bg-tertiary text-text-muted",children:a?e.jsx(ve,{size:14}):e.jsx(ae,{size:14})})]}),t.kind==="failed_run"&&e.jsx(m,{size:"sm",variant:"ghost",onClick:()=>W(t.data),loading:p===t.data.id,icon:e.jsx(je,{size:14}),children:"Retry"}),t.kind==="blocked_issue"&&e.jsx(E,{to:`/command-post/issues/${t.data.id}`,children:e.jsx(m,{size:"sm",variant:"ghost",children:"View"})}),t.kind==="error_agent"&&e.jsx(E,{to:`/command-post/agents/${t.data.id}`,children:e.jsx(m,{size:"sm",variant:"ghost",children:"View"})})]})]}),a&&i&&e.jsxs("div",{className:"px-4 pb-4 border-t border-border/50",children:[i.payload&&!!i.payload.shadowVerdict&&e.jsxs("div",{className:"mt-3 p-2 rounded-lg bg-bg-tertiary/50 text-xs",children:[e.jsx("div",{className:"font-medium text-text-muted mb-1",children:"Shadow Rehearsal"}),e.jsx("div",{className:"text-text-secondary",children:(()=>{const s=i.payload.shadowVerdict;return s?e.jsxs("div",{className:"space-y-1",children:[s.estimatedCostUsd?e.jsxs("div",{children:["Cost: $",Number(s.estimatedCostUsd).toFixed(2)]}):null,s.reversibilityScore!==void 0?e.jsxs("div",{children:["Reversibility: ",Number(s.reversibilityScore).toFixed(2)]}):null,s.breakRisks&&Array.isArray(s.breakRisks)&&s.breakRisks.length>0?e.jsxs("div",{className:"text-error",children:["Risks: ",s.breakRisks.join(", ")]}):null]}):null})()})]}),e.jsx(ze,{approval:i,onReply:h})]})]},t.id)})})]})}export{Xe as default};
@@ -1 +0,0 @@
1
- import{q as $,u as B,r,bL as D,b as S,bM as M,j as e,K as L,bd as C}from"./index-Cml2x9pA.js";import{B as c}from"./Button-MdXmb4_n.js";import"./Input-CBTwa_Iw.js";import{S as O}from"./StatusBadge-BqlvIbdj.js";import{P as h}from"./PageHeader-DdrbS1aq.js";import{S as U}from"./SkeletonLoader-r6OGXaU9.js";import{A as K}from"./arrow-left-WkVYLm80.js";import{M as R}from"./message-square-CRsG9u6_.js";import{S as _}from"./send-DtXGsaFW.js";import"./clsx-B-dksMZM.js";import"./chevron-right-DbLSHmff.js";function b(a){const i=Math.floor((Date.now()-new Date(a).getTime())/1e3);return i<60?`${i}s`:i<3600?`${Math.floor(i/60)}m`:i<86400?`${Math.floor(i/3600)}h`:`${Math.floor(i/86400)}d`}const F={critical:"text-error",high:"text-warning",medium:"text-accent",low:"text-text-muted"},q=["backlog","todo","in_progress","in_review","done","blocked","cancelled"];function se(){const{id:a}=$(),i=B(),[s,o]=r.useState(null),[l,k]=r.useState([]),[I,P]=r.useState(!0),[g,f]=r.useState(null),[A,x]=r.useState(!1),[m,u]=r.useState(""),[n,j]=r.useState(""),[E,y]=r.useState(!1),[v,T]=r.useState(""),p=r.useCallback(async()=>{if(a){try{const t=await D(a);o(t),u(t.title);try{const d=await S(`/api/command-post/issues/${a}/comments`);d.ok&&k(await d.json())}catch{}f(null)}catch(t){f(t instanceof Error?t.message:"Failed to load issue")}P(!1)}},[a]);r.useEffect(()=>{p()},[p]),r.useEffect(()=>{s!=null&&s.id&&M(s.id).then(t=>T(t.ancestry)).catch(()=>{})},[s==null?void 0:s.id]);const z=async t=>{if(!(!a||!s))try{const d=await C(a,{status:t});o(d)}catch{}},N=async()=>{if(!(!a||!s||!m.trim()))try{const t=await C(a,{title:m.trim()});o(t),x(!1)}catch{}},w=async()=>{if(!(!a||!n.trim())){y(!0);try{await S(`/api/command-post/issues/${a}/comments`,{method:"POST",body:JSON.stringify({body:n.trim()})}),j(""),await p()}catch{}y(!1)}};return I?e.jsxs("div",{className:"space-y-6",children:[e.jsx(h,{title:"Issue",breadcrumbs:[{label:"Command Post"},{label:"Issues",href:"/command-post/issues"},{label:"..."}]}),e.jsx(U,{variant:"card",count:1})]}):g||!s?e.jsxs("div",{className:"space-y-6",children:[e.jsx(h,{title:"Issue",breadcrumbs:[{label:"Command Post"},{label:"Issues",href:"/command-post/issues"},{label:"Error"}]}),e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-error text-sm mb-4",children:g??"Issue not found"}),e.jsx(c,{variant:"secondary",size:"sm",onClick:()=>i("/command-post/issues"),children:"Back to Issues"})]})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsx(h,{title:s.identifier,breadcrumbs:[{label:"Command Post"},{label:"Issues",href:"/command-post/issues"},{label:s.identifier}],actions:e.jsxs(L,{to:"/command-post/issues",className:"flex items-center gap-1 text-xs text-text-muted hover:text-text",children:[e.jsx(K,{size:14})," Back"]})}),v&&e.jsx("div",{className:"bg-bg-tertiary/30 border border-border rounded-lg px-4 py-3 mb-4",children:e.jsx("pre",{className:"text-xs text-text-secondary whitespace-pre-wrap font-mono leading-relaxed",children:v})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-4",children:[e.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl p-4",children:[A?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{className:"flex-1 rounded-lg border border-border bg-bg-tertiary px-3 py-2 text-base font-semibold text-text focus:outline-none focus:border-accent",value:m,onChange:t=>u(t.target.value),onKeyDown:t=>t.key==="Enter"&&N(),autoFocus:!0}),e.jsx(c,{size:"sm",onClick:N,children:"Save"}),e.jsx(c,{size:"sm",variant:"ghost",onClick:()=>{x(!1),u(s.title)},children:"Cancel"})]}):e.jsx("h2",{className:"text-lg font-semibold text-text cursor-pointer hover:text-accent transition-colors",onClick:()=>x(!0),title:"Click to edit",children:s.title}),s.description&&e.jsx("p",{className:"mt-3 text-sm text-text-secondary whitespace-pre-wrap",children:s.description})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:q.map(t=>e.jsx("button",{onClick:()=>z(t),disabled:s.status===t,className:`px-3 py-1.5 rounded-lg text-xs font-medium transition-colors border ${s.status===t?"border-accent bg-accent/10 text-accent":"border-border bg-bg-tertiary text-text-muted hover:text-text hover:border-border-light"}`,children:t.replace(/_/g," ")},t))}),e.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border",children:[e.jsx(R,{size:14,className:"text-accent"}),e.jsx("h3",{className:"text-sm font-semibold text-text",children:"Comments"}),e.jsxs("span",{className:"text-xs text-text-muted",children:["(",l.length,")"]})]}),l.length===0?e.jsx("div",{className:"py-8 text-center text-xs text-text-muted",children:"No comments yet"}):e.jsx("div",{className:"divide-y divide-border max-h-96 overflow-y-auto",children:l.map(t=>e.jsxs("div",{className:"px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-xs font-medium text-text",children:t.authorAgentId??t.authorUser??"Unknown"}),e.jsxs("span",{className:"text-[10px] text-text-muted",children:[b(t.createdAt)," ago"]})]}),e.jsx("p",{className:"text-sm text-text-secondary whitespace-pre-wrap",children:t.body})]},t.id))}),e.jsxs("div",{className:"border-t border-border px-4 py-3 flex items-center gap-2",children:[e.jsx("input",{className:"flex-1 rounded-lg border border-border bg-bg-tertiary px-3 py-2 text-sm text-text placeholder:text-text-muted focus:outline-none focus:border-accent",placeholder:"Add a comment...",value:n,onChange:t=>j(t.target.value),onKeyDown:t=>t.key==="Enter"&&!t.shiftKey&&w()}),e.jsx(c,{size:"sm",onClick:w,loading:E,disabled:!n.trim(),icon:e.jsx(_,{size:14}),children:"Send"})]})]})]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:"Status"}),e.jsx("div",{className:"mt-1",children:e.jsx(O,{status:s.status})})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:"Priority"}),e.jsx("div",{className:`mt-1 text-sm font-medium capitalize ${F[s.priority]??"text-text"}`,children:s.priority})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:"Assignee"}),e.jsx("div",{className:"mt-1 text-sm text-text-secondary",children:s.assigneeAgentId??"Unassigned"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:"Identifier"}),e.jsx("div",{className:"mt-1 text-sm text-text font-mono",children:s.identifier})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:"Created"}),e.jsxs("div",{className:"mt-1 text-sm text-text-secondary",children:[b(s.createdAt)," ago"]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:"Updated"}),e.jsxs("div",{className:"mt-1 text-sm text-text-secondary",children:[b(s.updatedAt)," ago"]})]})]})})]})]})}export{se as default};
@@ -1 +0,0 @@
1
- import{r as s,D as k,j as e,K as T,O as P}from"./index-Cml2x9pA.js";import{B as u}from"./Button-MdXmb4_n.js";import"./Input-CBTwa_Iw.js";import{S as D}from"./StatusBadge-BqlvIbdj.js";import{P as z}from"./PageHeader-DdrbS1aq.js";import{E}from"./EmptyState-D9kQf1PX.js";import{T as L}from"./Tabs-DdUThlp1.js";import{M}from"./Modal-ybPGvlQs.js";import{S as $}from"./SkeletonLoader-r6OGXaU9.js";import{P as A}from"./plus-Dpo1qfrl.js";import{L as B}from"./list-todo-BlgfQHup.js";import"./clsx-B-dksMZM.js";import"./chevron-right-DbLSHmff.js";function R(a){const r=Math.floor((Date.now()-new Date(a).getTime())/1e3);return r<60?`${r}s`:r<3600?`${Math.floor(r/60)}m`:r<86400?`${Math.floor(r/3600)}h`:`${Math.floor(r/86400)}d`}const _={critical:"text-error",high:"text-warning",medium:"text-accent",low:"text-text-muted"},O=[{id:"all",label:"All"},{id:"backlog",label:"Backlog"},{id:"todo",label:"Todo"},{id:"in_progress",label:"In Progress"},{id:"in_review",label:"In Review"},{id:"done",label:"Done"},{id:"blocked",label:"Blocked"}];function ee(){const[a,r]=s.useState([]),[c,w]=s.useState(!0),[l,m]=s.useState(null),[o,v]=s.useState("all"),[y,i]=s.useState(!1),[n,h]=s.useState(""),[p,b]=s.useState("medium"),[f,g]=s.useState(""),[C,j]=s.useState(!1),d=s.useCallback(async()=>{try{const t=await k();r(t),m(null)}catch(t){m(t instanceof Error?t.message:"Failed to load issues")}w(!1)},[]);s.useEffect(()=>{d()},[d]);const N=async()=>{if(n.trim()){j(!0);try{await P({title:n,description:f,priority:p}),i(!1),h(""),g(""),b("medium"),await d()}catch{}j(!1)}},x=o==="all"?a:a.filter(t=>t.status===o),S=O.map(t=>({...t,count:t.id==="all"?a.length:a.filter(I=>I.status===t.id).length}));return e.jsxs("div",{className:"space-y-4",children:[e.jsx(z,{title:"Issues",breadcrumbs:[{label:"Command Post"},{label:"Issues"}],actions:e.jsx(u,{size:"sm",icon:e.jsx(A,{size:14}),onClick:()=>i(!0),children:"New Issue"})}),e.jsx(L,{tabs:S,activeTab:o,onChange:v}),c&&e.jsx($,{variant:"row",count:6}),l&&e.jsx("div",{className:"text-center py-8 text-error text-sm",children:l}),!c&&!l&&x.length===0&&e.jsx(E,{icon:e.jsx(B,{size:32}),title:"No issues",description:o==="all"?"Create your first issue to get started.":`No ${o.replace(/_/g," ")} issues.`,action:{label:"New Issue",onClick:()=>i(!0)}}),!c&&!l&&x.length>0&&e.jsx("div",{className:"divide-y divide-border rounded-xl border border-border bg-bg-secondary overflow-hidden",children:x.map(t=>e.jsxs(T,{to:`/command-post/issues/${t.id}`,className:"flex items-center gap-3 px-4 py-3 hover:bg-bg-tertiary/50 transition-colors",children:[e.jsx(D,{status:t.status,variant:"dot",size:"sm"}),e.jsx("span",{className:"text-sm text-text flex-1 truncate",children:t.title}),e.jsx("span",{className:`text-xs font-medium uppercase ${_[t.priority]??"text-text-muted"}`,children:t.priority}),t.assigneeAgentId&&e.jsx("span",{className:"text-xs text-text-muted truncate max-w-[100px]",children:t.assigneeAgentId}),e.jsx("span",{className:"text-xs text-text-muted font-mono",children:t.identifier}),e.jsx("span",{className:"text-xs text-text-muted flex-shrink-0",children:R(t.updatedAt)})]},t.id))}),e.jsx(M,{open:y,onClose:()=>i(!1),title:"New Issue",footer:e.jsxs(e.Fragment,{children:[e.jsx(u,{variant:"secondary",size:"sm",onClick:()=>i(!1),children:"Cancel"}),e.jsx(u,{size:"sm",onClick:N,loading:C,disabled:!n.trim(),children:"Create"})]}),children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-text-muted mb-1",children:"Title"}),e.jsx("input",{className:"w-full rounded-lg border border-border bg-bg-tertiary px-3 py-2 text-sm text-text placeholder:text-text-muted focus:outline-none focus:border-accent",placeholder:"Issue title...",value:n,onChange:t=>h(t.target.value),autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-text-muted mb-1",children:"Priority"}),e.jsxs("select",{className:"w-full rounded-lg border border-border bg-bg-tertiary px-3 py-2 text-sm text-text focus:outline-none focus:border-accent",value:p,onChange:t=>b(t.target.value),children:[e.jsx("option",{value:"low",children:"Low"}),e.jsx("option",{value:"medium",children:"Medium"}),e.jsx("option",{value:"high",children:"High"}),e.jsx("option",{value:"critical",children:"Critical"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-text-muted mb-1",children:"Description"}),e.jsx("textarea",{className:"w-full rounded-lg border border-border bg-bg-tertiary px-3 py-2 text-sm text-text placeholder:text-text-muted focus:outline-none focus:border-accent min-h-[80px] resize-y",placeholder:"Describe the issue...",value:f,onChange:t=>g(t.target.value)})]})]})})]})}export{ee as default};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/CommandPostHub-B_L1CAss.js","assets/index-Cml2x9pA.js","assets/index-yWybhcfI.css","assets/Button-MdXmb4_n.js","assets/clsx-B-dksMZM.js","assets/Input-CBTwa_Iw.js","assets/Modal-ybPGvlQs.js","assets/InlineEditableField-DgMrLDj1.js","assets/check-CuRYh4Zh.js","assets/pencil-BK5IU6o0.js","assets/ConfirmDialog-VErHWAbo.js","assets/Tooltip-C2tXJcrN.js","assets/approvalHeadline-DB9SgR-9.js","assets/chevron-right-DbLSHmff.js","assets/bot-DvEcyQcD.js","assets/pause-BT1Bc2q3.js","assets/dollar-sign-XxwPAA2a.js","assets/git-branch-C2qrhGGu.js","assets/chart-column-w3goFd5f.js","assets/clock-JyQAYy6X.js","assets/message-square-CRsG9u6_.js","assets/file-text-Cfawu8Bs.js","assets/terminal-DaBIlWEM.js","assets/refresh-cw-C-iZkzuS.js","assets/circle-stop-Bx2ohEg8.js","assets/send-DtXGsaFW.js","assets/plus-Dpo1qfrl.js","assets/trash-2-CTeyjxD_.js","assets/CPIssues-BzX6Rckx.js","assets/StatusBadge-BqlvIbdj.js","assets/PageHeader-DdrbS1aq.js","assets/EmptyState-D9kQf1PX.js","assets/Tabs-DdUThlp1.js","assets/SkeletonLoader-r6OGXaU9.js","assets/list-todo-BlgfQHup.js","assets/CPIssueDetail-NAGfmJg8.js","assets/arrow-left-WkVYLm80.js","assets/CPAgents-BSUKucTe.js","assets/CPAgentDetail-BYji6tT8.js","assets/circle-check-big-Bkba568b.js","assets/save-DwR9wQVu.js","assets/CPApprovals-B4v0em6e.js","assets/shield-check-CXlDJyAW.js","assets/CPActivity-B1Se9VVc.js","assets/CPGoals-8Z1yOY8e.js","assets/CPRuns-D-cpPw_M.js","assets/play-Cl1nC_gc.js","assets/CPCosts-9ikh61Kv.js","assets/CPOrg-B7DQ4UQP.js","assets/network-C9RXQGrV.js","assets/CPFiles-DB2nY5JE.js","assets/folder-DAdIw-Pb.js","assets/flask-conical-Ql8QxhgY.js","assets/search-D10l0m3-.js"])))=>i.map(i=>d[i]);
2
- import{j as t,r as s,w as _,x as e,N as l,_ as o}from"./index-Cml2x9pA.js";const a=s.lazy(()=>o(()=>import("./CommandPostHub-B_L1CAss.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27]))),i=s.lazy(()=>o(()=>import("./CPIssues-BzX6Rckx.js"),__vite__mapDeps([28,1,2,3,4,5,29,30,13,31,32,6,33,26,34]))),r=s.lazy(()=>o(()=>import("./CPIssueDetail-NAGfmJg8.js"),__vite__mapDeps([35,1,2,3,4,5,29,30,13,33,36,20,25]))),n=s.lazy(()=>o(()=>import("./CPAgents-BSUKucTe.js"),__vite__mapDeps([37,1,2,3,4,5,29,30,13,31,33]))),x=s.lazy(()=>o(()=>import("./CPAgentDetail-BYji6tT8.js"),__vite__mapDeps([38,1,2,3,4,5,29,30,13,31,32,33,36,39,16,19,40]))),m=s.lazy(()=>o(()=>import("./CPApprovals-B4v0em6e.js"),__vite__mapDeps([41,1,2,3,4,5,29,30,13,31,32,33,12,42,8]))),j=s.lazy(()=>o(()=>import("./CPActivity-B1Se9VVc.js"),__vite__mapDeps([43,1,2,3,4,5,30,13,31,32,33,42,16,14]))),p=s.lazy(()=>o(()=>import("./CPGoals-8Z1yOY8e.js"),__vite__mapDeps([44,1,2,3,4,5,29,30,13,31,6,33,26,27]))),u=s.lazy(()=>o(()=>import("./CPRuns-D-cpPw_M.js"),__vite__mapDeps([45,1,2,3,4,5,29,30,13,31,33,46]))),c=s.lazy(()=>o(()=>import("./CPCosts-9ikh61Kv.js"),__vite__mapDeps([47,1,2,3,4,5,29,30,13,31,6,33,26,16,27]))),d=s.lazy(()=>o(()=>import("./CPOrg-B7DQ4UQP.js"),__vite__mapDeps([48,1,2,3,4,5,29,30,13,31,33,10,6,49,27]))),P=s.lazy(()=>o(()=>import("./CPFiles-DB2nY5JE.js"),__vite__mapDeps([50,1,2,30,13,51,52,53,23,21])));function E(){return t.jsx("div",{className:"flex items-center justify-center h-full text-sm",style:{color:"#c4b49a"},children:"Loading..."})}function v(){return t.jsx("div",{className:"h-full overflow-hidden",children:t.jsx("div",{className:"h-full overflow-auto",children:t.jsx(s.Suspense,{fallback:t.jsx(E,{}),children:t.jsxs(_,{children:[t.jsx(e,{index:!0,element:t.jsx(a,{})}),t.jsx(e,{path:"dashboard",element:t.jsx(a,{})}),t.jsx(e,{path:"issues",element:t.jsx(i,{})}),t.jsx(e,{path:"issues/:id",element:t.jsx(r,{})}),t.jsx(e,{path:"agents",element:t.jsx(n,{})}),t.jsx(e,{path:"agents/:id",element:t.jsx(x,{})}),t.jsx(e,{path:"approvals",element:t.jsx(m,{})}),t.jsx(e,{path:"activity",element:t.jsx(j,{})}),t.jsx(e,{path:"goals",element:t.jsx(p,{})}),t.jsx(e,{path:"runs",element:t.jsx(u,{})}),t.jsx(e,{path:"costs",element:t.jsx(c,{})}),t.jsx(e,{path:"org",element:t.jsx(d,{})}),t.jsx(e,{path:"files",element:t.jsx(P,{})}),t.jsx(e,{path:"*",element:t.jsx(l,{to:"/command-post",replace:!0})})]})})})})}export{v as CPLayout,v as default};
@@ -1 +0,0 @@
1
- import{t as j,r as o,a2 as y,a3 as v,j as e}from"./index-Cml2x9pA.js";import"./Button-MdXmb4_n.js";import"./Input-CBTwa_Iw.js";import{S as N}from"./StatusBadge-BqlvIbdj.js";import{P as C}from"./PageHeader-DdrbS1aq.js";import{E as w}from"./EmptyState-D9kQf1PX.js";import{S}from"./SkeletonLoader-r6OGXaU9.js";import{C as k}from"./ConfirmDialog-VErHWAbo.js";import{N as E}from"./network-C9RXQGrV.js";import{T as D}from"./trash-2-CTeyjxD_.js";import"./clsx-B-dksMZM.js";import"./chevron-right-DbLSHmff.js";import"./Modal-ybPGvlQs.js";function O(t){const r=t.split("/");return r[r.length-1]}function u({node:t,depth:r,onDelete:i}){const a=t.role==="Company";return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-start gap-3 py-2",style:{paddingLeft:`${r*32+16}px`},children:[r>0&&e.jsx("div",{className:"flex items-center gap-0 -ml-5",children:e.jsx("div",{className:"w-4 border-t border-border-light"})}),e.jsxs("div",{className:`border rounded-lg p-3 flex-1 max-w-sm transition-colors group ${a?"bg-accent/5 border-accent/20 hover:border-accent/40":"bg-bg-secondary border-border hover:border-border-light"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-text",children:t.name}),e.jsx(N,{status:t.status,size:"sm"})]}),a&&i&&e.jsx("button",{onClick:l=>{l.stopPropagation(),i(t.id,t.name)},className:"opacity-0 group-hover:opacity-100 p-1 rounded hover:bg-error/20 text-text-muted hover:text-error transition-all",title:`Delete ${t.name}`,children:e.jsx(D,{size:14})})]}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-text-muted",children:[a&&e.jsx("span",{className:"text-accent text-[9px] font-medium uppercase tracking-wider",children:"Company"}),!a&&e.jsx("span",{className:"capitalize",children:t.role}),t.title&&e.jsx("span",{children:t.title}),t.model&&e.jsx("span",{children:O(t.model)})]}),a&&t.reports.length>0&&e.jsxs("div",{className:"text-[10px] text-text-muted mt-1",children:[t.reports.length," agent",t.reports.length!==1?"s":""]})]})]}),t.reports.length>0&&e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute border-l border-border-light",style:{left:`${(r+1)*32+16}px`,top:0,height:"100%"}}),t.reports.map(l=>e.jsx(u,{node:l,depth:r+1,onDelete:i},l.id))]})]})}function I(){const{toast:t}=j(),[r,i]=o.useState([]),[a,l]=o.useState(!0),[m,p]=o.useState(null),[h,g]=o.useState(null),[n,x]=o.useState(null),c=o.useCallback(async()=>{try{const s=await y();i(s),p(null)}catch(s){p(s instanceof Error?s.message:"Failed to load org chart")}l(!1)},[]);o.useEffect(()=>{c()},[c]);const b=o.useCallback(async()=>{if(!n)return;const{id:s}=n;x(null),g(s);try{await v(s),t("success","Company deleted."),await c()}catch(d){t("error",`Couldn't delete company — try again. ${d instanceof Error?d.message:"Unknown error"}`)}g(null)},[n,c,t]);return e.jsxs("div",{className:"space-y-4",children:[e.jsx(C,{title:"Organization Chart",breadcrumbs:[{label:"Command Post"},{label:"Org Chart"}]}),a&&e.jsx(S,{variant:"row",count:5}),m&&e.jsxs("div",{className:"rounded-xl border border-error/50 bg-bg-secondary p-6",children:[e.jsx("p",{className:"text-sm font-medium text-error",children:"Failed to load org chart"}),e.jsx("p",{className:"mt-2 text-sm text-text-secondary",children:m}),e.jsx("button",{onClick:c,className:"mt-4 rounded-lg bg-bg-tertiary px-4 py-2 text-sm text-text hover:bg-border transition-colors",children:"Retry"})]}),!a&&!m&&r.length===0&&e.jsx(w,{icon:e.jsx(E,{size:32}),title:"No org structure",description:"Register agents or create companies to see the org chart."}),!a&&!m&&r.length>0&&e.jsxs("div",{className:"rounded-xl border border-border bg-bg-secondary p-4 overflow-x-auto",children:[r.map(s=>e.jsx(u,{node:s,depth:0,onDelete:(d,f)=>x({id:d,name:f})},s.id)),h&&e.jsx("div",{className:"text-xs text-text-muted text-center py-2 animate-pulse",children:"Deleting..."})]}),e.jsx(k,{open:!!n,title:`Delete company "${(n==null?void 0:n.name)||""}"?`,message:"This stops the heartbeat runner and archives all of the company's agents, goals, and issues. This can't be undone.",confirmLabel:"Delete",onConfirm:b,onCancel:()=>x(null)})]})}export{I as default};
@@ -1 +0,0 @@
1
- import{r as a,a0 as h,a1 as f,j as e}from"./index-Cml2x9pA.js";import"./Button-MdXmb4_n.js";import"./Input-CBTwa_Iw.js";import{S as j}from"./StatusBadge-BqlvIbdj.js";import{P as g}from"./PageHeader-DdrbS1aq.js";import{E as y}from"./EmptyState-D9kQf1PX.js";import{S as b}from"./SkeletonLoader-r6OGXaU9.js";import{P as N}from"./play-Cl1nC_gc.js";import"./clsx-B-dksMZM.js";import"./chevron-right-DbLSHmff.js";function v(s){const r=Math.floor((Date.now()-new Date(s).getTime())/1e3);return r<60?`${r}s`:r<3600?`${Math.floor(r/60)}m`:r<86400?`${Math.floor(r/3600)}h`:`${Math.floor(r/86400)}d`}function S(s){return s?s<1e3?`${s}ms`:s<6e4?`${(s/1e3).toFixed(1)}s`:`${(s/6e4).toFixed(1)}m`:"-"}function U(){const[s,r]=a.useState([]),[x,m]=a.useState([]),[n,d]=a.useState(!0),[o,i]=a.useState(null),[l,u]=a.useState(""),c=a.useCallback(async()=>{try{const[t,p]=await Promise.all([h(l||void 0,100),f()]);r(t),m(p),i(null)}catch(t){i(t instanceof Error?t.message:"Failed to load runs")}d(!1)},[l]);return a.useEffect(()=>{d(!0),c()},[c]),e.jsxs("div",{className:"space-y-4",children:[e.jsx(g,{title:"Runs",breadcrumbs:[{label:"Command Post"},{label:"Runs"}],actions:e.jsxs("select",{className:"rounded-lg border border-border bg-bg-tertiary px-3 py-1.5 text-xs text-text focus:outline-none focus:border-accent",value:l,onChange:t=>u(t.target.value),children:[e.jsx("option",{value:"",children:"All agents"}),x.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))]})}),n&&e.jsx(b,{variant:"row",count:8}),o&&e.jsx("div",{className:"text-center py-8 text-error text-sm",children:o}),!n&&!o&&s.length===0&&e.jsx(y,{icon:e.jsx(N,{size:32}),title:"No runs",description:"Agent runs will appear here as they execute."}),!n&&!o&&s.length>0&&e.jsx("div",{className:"bg-bg-secondary border border-border rounded-xl overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border text-left",children:[e.jsx("th",{className:"px-4 py-2.5 text-text-muted font-medium",children:"Agent"}),e.jsx("th",{className:"px-4 py-2.5 text-text-muted font-medium",children:"Source"}),e.jsx("th",{className:"px-4 py-2.5 text-text-muted font-medium",children:"Status"}),e.jsx("th",{className:"px-4 py-2.5 text-text-muted font-medium",children:"Duration"}),e.jsx("th",{className:"px-4 py-2.5 text-text-muted font-medium",children:"Tools"}),e.jsx("th",{className:"px-4 py-2.5 text-text-muted font-medium",children:"Started"})]})}),e.jsx("tbody",{className:"divide-y divide-border",children:s.map(t=>e.jsxs("tr",{className:"hover:bg-bg-tertiary/50 transition-colors",children:[e.jsx("td",{className:"px-4 py-2.5 text-text font-medium",children:t.agentId}),e.jsx("td",{className:"px-4 py-2.5 text-text-secondary capitalize",children:t.source}),e.jsx("td",{className:"px-4 py-2.5",children:e.jsx(j,{status:t.status,size:"sm"})}),e.jsx("td",{className:"px-4 py-2.5 text-text-secondary font-mono",children:S(t.durationMs)}),e.jsx("td",{className:"px-4 py-2.5 text-text-muted",children:t.toolsUsed.length>0?e.jsxs("span",{title:t.toolsUsed.join(", "),children:[t.toolsUsed.length," tool",t.toolsUsed.length!==1?"s":""]}):"-"}),e.jsxs("td",{className:"px-4 py-2.5 text-text-muted",children:[v(t.startedAt)," ago"]})]},t.id))})]})})})]})}export{U as default};
@@ -1,11 +0,0 @@
1
- import{c as v,r as n,bR as A,bS as M,j as e,k as D,l as L,m as q,bT as _,bU as I,bV as O,bW as z}from"./index-Cml2x9pA.js";import{R as b}from"./refresh-cw-C-iZkzuS.js";import{S as G}from"./send-DtXGsaFW.js";import{L as H}from"./lightbulb-BZJNK69S.js";import{C as F}from"./clock-JyQAYy6X.js";import{M as U}from"./message-square-CRsG9u6_.js";/**
2
- * @license lucide-react v0.513.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const V=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],W=v("share-2",V);/**
7
- * @license lucide-react v0.513.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const B=[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]],Q=v("type",B);function N(r){const l=Math.floor((Date.now()-new Date(r).getTime())/1e3);return l<60?`${l}s`:l<3600?`${Math.floor(l/60)}m`:l<86400?`${Math.floor(l/3600)}h`:`${Math.floor(l/86400)}d`}const w={activity:"Activity",spotlight:"Spotlight",stats:"Stats",tips:"Tips",promo:"Promo",usecase:"Use Case",eli5:"ELI5"},x={activity:"var(--color-accent-hover)",spotlight:"var(--color-emerald)",stats:"var(--color-cyan)",tips:"#fbbf24",promo:"#f472b6",usecase:"var(--color-purple-light)",eli5:"#fb923c"};function re(){const[r,l]=n.useState(null),[k,C]=n.useState(!0),[u,i]=n.useState(null),[c,g]=n.useState(""),[y,f]=n.useState(!1),[j,m]=n.useState(null),[p,d]=n.useState(null),o=n.useCallback(async()=>{try{i(null);const t=await A();l(t)}catch(t){i(t instanceof Error?t.message:"Failed to load social state")}finally{C(!1)}},[]),h=n.useCallback(async()=>{try{const a=(await M()).recentTopics;if(a.length===0){m(null);return}const R=a.slice(0,3).map($=>`"${$.content.split(/\s+/).slice(0,6).join(" ")}..."`).join(", ");m(`💡 Recent social posts: ${R}. Consider a follow-up on a related but fresh topic.`)}catch{m(null)}},[]);n.useEffect(()=>{o(),h()},[o,h]);const S=async()=>{if(!r)return;const t=!r.autopilot.enabled;try{await _(t),l(a=>a&&{...a,autopilot:{...a.autopilot,enabled:t}})}catch(a){i(a instanceof Error?a.message:"Toggle failed")}},T=async()=>{if(c.trim()){f(!0);try{const t=await I(c.trim());t.success?(g(""),await o(),await h()):i(t.error||t.skipped||"Post failed")}catch(t){i(t instanceof Error?t.message:"Post failed")}finally{f(!1)}}},P=async t=>{d(t);try{await O(t),await o()}catch(a){i(a instanceof Error?a.message:"Approve failed")}finally{d(null)}},E=async t=>{d(t);try{await z(t),await o()}catch(a){i(a instanceof Error?a.message:"Reject failed")}finally{d(null)}};if(k)return e.jsxs("div",{className:"flex items-center justify-center py-20",children:[e.jsx("div",{className:"w-5 h-5 border-2 border-indigo-500/30 border-t-indigo-500 rounded-full animate-spin"}),e.jsx("span",{className:"ml-3 text-sm text-text-muted",children:"Loading social media…"})]});const s=r==null?void 0:r.autopilot;return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-pink-500/10 border border-pink-500/20",children:e.jsx(W,{className:"h-4 w-4 text-pink-400"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-white",children:"Social Media"}),e.jsx("p",{className:"text-[11px] text-text-muted",children:"Facebook autopilot, drafts, and post history"})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("button",{onClick:o,className:"flex items-center gap-1.5 rounded-lg bg-bg-tertiary px-3 py-1.5 text-[11px] text-text-muted hover:bg-bg-tertiary transition-colors border border-border",children:[e.jsx(b,{className:"h-3 w-3"})," Refresh"]})})]}),u&&e.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-red-500/30 bg-red-500/10 px-4 py-3 text-xs text-red-300",children:[e.jsx(D,{className:"h-4 w-4 shrink-0"}),u]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-3",children:[e.jsxs("div",{className:"rounded-xl border border-border bg-bg-tertiary/30 px-4 py-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-[11px] text-text-muted",children:"Autopilot"}),e.jsx("button",{onClick:S,className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors ${s!=null&&s.enabled?"bg-pink-500":"bg-white/10"}`,children:e.jsx("span",{className:`inline-block h-3.5 w-3.5 rounded-full bg-white transition-transform ${s!=null&&s.enabled?"translate-x-4.5":"translate-x-1"}`})})]}),e.jsx("p",{className:`mt-1 text-sm font-semibold ${s!=null&&s.enabled?"text-pink-400":"text-text-muted"}`,children:s!=null&&s.enabled?"Enabled":"Paused"})]}),e.jsxs("div",{className:"rounded-xl border border-border bg-bg-tertiary/30 px-4 py-3",children:[e.jsx("p",{className:"text-[11px] text-text-muted",children:"Posts Today"}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("p",{className:"text-xl font-bold text-white",children:(s==null?void 0:s.postsToday)??0}),e.jsxs("p",{className:"text-[11px] text-text-muted",children:["/ ",(s==null?void 0:s.maxPostsPerDay)??6]})]})]}),e.jsxs("div",{className:"rounded-xl border border-border bg-bg-tertiary/30 px-4 py-3",children:[e.jsx("p",{className:"text-[11px] text-text-muted",children:"Replies Today"}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("p",{className:"text-xl font-bold text-white",children:(s==null?void 0:s.repliesToday)??0}),e.jsx("p",{className:"text-[11px] text-text-muted",children:"/ 10"})]})]}),e.jsxs("div",{className:"rounded-xl border border-border bg-bg-tertiary/30 px-4 py-3",children:[e.jsx("p",{className:"text-[11px] text-text-muted",children:"Next Type"}),e.jsx("p",{className:"mt-1 text-sm font-semibold",style:{color:x[(s==null?void 0:s.nextContentType)||"activity"]||"#fff"},children:w[(s==null?void 0:s.nextContentType)||"activity"]||(s==null?void 0:s.nextContentType)})]})]}),e.jsxs("div",{className:"rounded-xl border border-border bg-bg-tertiary/30 p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Q,{className:"h-4 w-4 text-pink-400"}),e.jsx("span",{className:"text-sm font-medium text-white",children:"Compose Post"})]}),e.jsx("textarea",{value:c,onChange:t=>g(t.target.value),placeholder:"What's on your mind?",rows:3,className:"w-full rounded-lg border border-border bg-black/20 px-3 py-2 text-sm text-white placeholder:text-text-muted focus:border-pink-500/50 focus:outline-none resize-none"}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:`text-[11px] ${c.length>280?"text-red-400":"text-text-muted"}`,children:[c.length," chars"]}),e.jsxs("button",{onClick:T,disabled:y||!c.trim(),className:"flex items-center gap-1.5 rounded-lg bg-pink-500/20 px-4 py-1.5 text-xs font-medium text-pink-300 hover:bg-pink-500/30 disabled:opacity-40 disabled:cursor-not-allowed transition-colors border border-pink-500/20",children:[y?e.jsx(b,{className:"h-3 w-3 animate-spin"}):e.jsx(G,{className:"h-3 w-3"}),"Post Now"]})]}),j&&e.jsxs("div",{className:"flex items-start gap-2 rounded-lg bg-amber-500/5 border border-amber-500/10 px-3 py-2",children:[e.jsx(H,{className:"h-3.5 w-3.5 text-amber-400 mt-0.5 shrink-0"}),e.jsx("p",{className:"text-[11px] text-amber-200/70 leading-relaxed",children:j})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{className:"h-4 w-4 text-text-muted"}),e.jsx("span",{className:"text-sm font-medium text-white",children:"Draft Queue"}),e.jsxs("span",{className:"text-[11px] text-text-muted ml-1",children:[(r==null?void 0:r.queue.length)??0," pending"]})]}),r!=null&&r.queue&&r.queue.length>0?e.jsx("div",{className:"space-y-2",children:r.queue.map(t=>e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-border bg-bg-secondary/30 px-4 py-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm text-text break-words",children:t.content}),e.jsxs("p",{className:"mt-1 text-[10px] text-text-muted",children:[t.method," · ",N(t.createdAt)," ago"]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsxs("button",{onClick:()=>P(t.id),disabled:p===t.id,className:"flex items-center gap-1 rounded-md bg-emerald-500/10 px-2.5 py-1 text-[11px] text-emerald-300 hover:bg-emerald-500/20 disabled:opacity-40 transition-colors border border-emerald-500/15",children:[p===t.id?e.jsx(b,{className:"h-3 w-3 animate-spin"}):e.jsx(L,{className:"h-3 w-3"}),"Approve"]}),e.jsxs("button",{onClick:()=>E(t.id),disabled:p===t.id,className:"flex items-center gap-1 rounded-md bg-red-500/10 px-2.5 py-1 text-[11px] text-red-300 hover:bg-red-500/20 disabled:opacity-40 transition-colors border border-red-500/15",children:[e.jsx(q,{className:"h-3 w-3"}),"Reject"]})]})]},t.id))}):e.jsx("div",{className:"rounded-lg border border-border bg-bg-secondary/30 px-4 py-6 text-center",children:e.jsx("p",{className:"text-xs text-text-muted",children:"No pending drafts in the queue."})})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(U,{className:"h-4 w-4 text-text-muted"}),e.jsx("span",{className:"text-sm font-medium text-white",children:"Recent Posts"}),e.jsxs("span",{className:"text-[11px] text-text-muted ml-1",children:[(r==null?void 0:r.recentPosts.length)??0," tracked"]})]}),r!=null&&r.recentPosts&&r.recentPosts.length>0?e.jsx("div",{className:"space-y-2",children:r.recentPosts.map((t,a)=>e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-border bg-bg-secondary/30 px-4 py-3",children:[e.jsx("div",{className:"mt-0.5 h-2 w-2 rounded-full shrink-0",style:{backgroundColor:x[t.type]||"#64748b"}}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"text-[10px] font-medium px-1.5 py-0.5 rounded",style:{backgroundColor:(x[t.type]||"#64748b")+"20",color:x[t.type]||"#94a3b8"},children:w[t.type]||t.type}),e.jsxs("span",{className:"text-[10px] text-text-muted",children:[N(t.date)," ago"]})]}),e.jsx("p",{className:"text-sm text-text-secondary break-words",children:t.content||"(content not stored)"}),t.postId&&e.jsxs("p",{className:"mt-1 text-[10px] text-text-muted font-mono",children:["ID: ",t.postId]})]})]},a))}):e.jsx("div",{className:"rounded-lg border border-border bg-bg-secondary/30 px-4 py-6 text-center",children:e.jsx("p",{className:"text-xs text-text-muted",children:"No posts in history yet."})})]})]})}export{re as default};
@@ -1 +0,0 @@
1
- import{t as k,r as c,j as t,b as S}from"./index-Cml2x9pA.js";import"./Button-MdXmb4_n.js";import"./Input-CBTwa_Iw.js";import{P as C}from"./PageHeader-DdrbS1aq.js";import{C as T}from"./circle-stop-Bx2ohEg8.js";import{M as R}from"./mic-B32RHc7Y.js";import{V as j}from"./volume-2-DYDBmm3M.js";import{S as E}from"./send-DtXGsaFW.js";import"./clsx-B-dksMZM.js";import"./chevron-right-DbLSHmff.js";async function U(p,o){const a=await S(p,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(!a.ok)throw new Error(`HTTP ${a.status}`);return a.json()}function F(){const{toast:p}=k(),[o,a]=c.useState(""),[h,u]=c.useState([]),[f,l]=c.useState(!1),[x,v]=c.useState(!0),m=c.useRef(null),i=c.useRef(null);c.useEffect(()=>{const e=window.SpeechRecognition||window.webkitSpeechRecognition;if(e){const s=new e;s.lang="en-US",s.continuous=!1,s.interimResults=!1,s.onresult=r=>{var n,b;const d=((b=(n=r.results[0])==null?void 0:n[0])==null?void 0:b.transcript)||"";a(d),l(!1)},s.onerror=()=>l(!1),s.onend=()=>l(!1),m.current=s}},[]);const g=async()=>{const e=o.trim();if(!e)return;const s={id:`e-${Date.now()}`,question:e,loading:!0,at:new Date().toISOString()};u(r=>[s,...r].slice(0,20)),a("");try{const r=await U("/api/voice/ask",{question:e,voice:"default",speak:x});u(d=>d.map(n=>n.id===s.id?{...n,loading:!1,answer:r.answer,activeDrivers:r.activeDrivers,ttsUrl:r.ttsUrl}:n)),r.ttsUrl&&x&&i.current&&(i.current.src=r.ttsUrl,i.current.play().catch(()=>{}))}catch(r){u(d=>d.map(n=>n.id===s.id?{...n,loading:!1,error:r.message}:n))}},w=()=>{const e=m.current;if(!e){p("warning","Speech recognition is not supported in this browser. Use Chrome.");return}try{e.start(),l(!0)}catch{}},y=()=>{const e=m.current;e&&e.stop(),l(!1)},N=!!(window.SpeechRecognition||window.webkitSpeechRecognition);return t.jsxs("div",{className:"space-y-4 flex flex-col h-[calc(100vh-180px)]",children:[t.jsx(C,{title:"Voice Ask",breadcrumbs:[{label:"Command Post"},{label:"Voice"}]}),t.jsx("audio",{ref:i}),t.jsxs("div",{className:"flex items-center gap-2 bg-bg-secondary border border-border rounded-xl px-3 py-2",children:[N&&(f?t.jsx("button",{onClick:y,className:"p-2 rounded bg-error/20 text-error hover:bg-error/30",title:"Stop listening",children:t.jsx(T,{size:18})}):t.jsx("button",{onClick:w,className:"p-2 rounded hover:bg-bg-tertiary text-text-muted",title:"Voice input (Chrome only)",children:t.jsx(R,{size:18})})),t.jsx("input",{value:o,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),g())},placeholder:f?"Listening…":'Ask TITAN — "What are you working on?" or give it instructions',className:"flex-1 bg-transparent text-sm outline-none"}),t.jsx("button",{onClick:()=>v(e=>!e),className:`p-2 rounded hover:bg-bg-tertiary ${x?"text-accent":"text-text-muted"}`,title:`TTS ${x?"ON":"OFF"}`,children:t.jsx(j,{size:16})}),t.jsxs("button",{onClick:g,disabled:!o.trim(),className:"px-3 py-1.5 rounded bg-accent/20 border border-accent/40 text-accent text-sm hover:bg-accent/30 disabled:opacity-50 flex items-center gap-1",children:[t.jsx(E,{size:14})," Ask"]})]}),t.jsxs("div",{className:"flex-1 overflow-auto space-y-3",children:[h.length===0&&t.jsx("div",{className:"text-center py-12 text-text-muted text-sm",children:'Ask a question to start. TITAN has driver-aware chat, so "what are you doing?" gets a real answer.'}),h.map(e=>t.jsxs("div",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"text-xs text-text-muted mt-1 flex-shrink-0 w-10",children:"You"}),t.jsx("div",{className:"text-sm text-text",children:e.question})]}),t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"text-xs text-accent mt-1 flex-shrink-0 w-10",children:"TITAN"}),t.jsxs("div",{className:"text-sm text-text-secondary flex-1",children:[e.loading&&t.jsx("span",{className:"text-text-muted",children:"thinking…"}),e.error&&t.jsxs("span",{className:"text-error",children:["error: ",e.error]}),e.answer&&t.jsxs("div",{className:"space-y-1",children:[t.jsx("div",{className:"whitespace-pre-wrap",children:e.answer}),t.jsxs("div",{className:"text-[11px] text-text-muted flex items-center gap-2",children:[t.jsxs("span",{children:["drivers: ",e.activeDrivers??"?"]}),e.ttsUrl&&t.jsxs("button",{onClick:()=>{i.current&&(i.current.src=e.ttsUrl,i.current.play().catch(()=>{}))},className:"text-accent hover:underline flex items-center gap-0.5",children:[t.jsx(j,{size:10})," play"]})]})]})]})]})]},e.id))]})]})}export{F as default};
@@ -1 +0,0 @@
1
- import{r as a,j as e,k as $,ar as E,as as D,$ as F,aq as K,E as I,at as R}from"./index-Cml2x9pA.js";import{P as O}from"./PageHeader-DdrbS1aq.js";import{R as W}from"./refresh-cw-C-iZkzuS.js";import{C as _}from"./circle-check-big-Bkba568b.js";import{C as G}from"./chevron-right-DbLSHmff.js";import{S as H}from"./save-DwR9wQVu.js";const L=[{id:"discord",label:"Discord",description:"Discord bot via discord.js",fields:[{key:"token",label:"Bot Token",placeholder:"Bot token from Discord Developer Portal"}]},{id:"telegram",label:"Telegram",description:"Telegram bot via Grammy",fields:[{key:"token",label:"Bot Token",placeholder:"Token from @BotFather"}]},{id:"slack",label:"Slack",description:"Slack workspace via Bolt SDK",fields:[{key:"token",label:"Bot Token",placeholder:"xoxb-..."},{key:"apiKey",label:"Signing Secret",placeholder:"Signing secret from Slack app settings"}]},{id:"whatsapp",label:"WhatsApp",description:"WhatsApp via Twilio",fields:[{key:"token",label:"Auth Token",placeholder:"Twilio auth token"},{key:"apiKey",label:"Account SID",placeholder:"Twilio account SID"}]},{id:"googlechat",label:"Google Chat",description:"Google Chat spaces",fields:[{key:"token",label:"Service Account Key",placeholder:"JSON key path or content"}]},{id:"matrix",label:"Matrix",description:"Matrix protocol (Element, etc.)",fields:[{key:"token",label:"Access Token",placeholder:"Matrix access token"}]},{id:"signal",label:"Signal",description:"Signal messenger",fields:[{key:"token",label:"API Token",placeholder:"Signal API token"}]},{id:"msteams",label:"Microsoft Teams",description:"MS Teams via Bot Framework",fields:[{key:"token",label:"App Password",placeholder:"Bot framework app password"},{key:"apiKey",label:"App ID",placeholder:"Bot framework app ID"}]},{id:"irc",label:"IRC",description:"Internet Relay Chat",fields:[{key:"token",label:"Password",placeholder:"NickServ password (optional)"}]},{id:"mattermost",label:"Mattermost",description:"Self-hosted team chat",fields:[{key:"token",label:"Bot Token",placeholder:"Mattermost bot access token"}]},{id:"lark",label:"Lark",description:"Lark/Feishu messaging",fields:[{key:"token",label:"App Token",placeholder:"Lark app token"},{key:"apiKey",label:"App Secret",placeholder:"Lark app secret"}]},{id:"email_inbound",label:"Email (Inbound)",description:"IMAP email webhook",fields:[{key:"token",label:"IMAP Password",placeholder:"IMAP password or app password"}]},{id:"line",label:"LINE",description:"LINE messaging platform",fields:[{key:"token",label:"Channel Access Token",placeholder:"LINE channel access token"},{key:"apiKey",label:"Channel Secret",placeholder:"LINE channel secret"}]},{id:"zulip",label:"Zulip",description:"Zulip team chat",fields:[{key:"apiKey",label:"API Key",placeholder:"Zulip API key"}]}],Z=[{value:"pairing",label:"Pairing",desc:"User must pair first"},{value:"open",label:"Open",desc:"Anyone can DM"},{value:"closed",label:"Closed",desc:"DMs disabled"}];function q({def:l,config:o,status:b,onSave:f,saving:v}){const[d,k]=a.useState(!1),[x,N]=a.useState(o.enabled),[p,c]=a.useState(""),[m,u]=a.useState(""),[g,w]=a.useState(o.dmPolicy),[y,t]=a.useState(!1),[n,h]=a.useState(!1),[r,i]=a.useState(!1),j=v===l.id,S=(b==null?void 0:b.status)==="connected",A=!!o.token,P=!!o.apiKey,M=()=>{N(!x),i(!0)},B=async()=>{const s={enabled:x,dmPolicy:g};p&&(s.token=p),m&&(s.apiKey=m),await f(l.id,s),c(""),u(""),i(!1)},C=l.fields.find(s=>s.key==="token"),T=l.fields.find(s=>s.key==="apiKey");return e.jsxs("div",{className:"rounded-xl border border-bg-tertiary bg-bg-secondary",children:[e.jsxs("button",{onClick:()=>k(!d),className:"flex w-full items-center justify-between px-4 py-3 text-left",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[d?e.jsx(F,{className:"h-4 w-4 text-text-muted"}):e.jsx(G,{className:"h-4 w-4 text-text-muted"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium text-text",children:l.label}),e.jsx("span",{className:"ml-2 text-xs text-text-muted",children:l.description})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[S&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-success/10 px-2.5 py-0.5 text-xs font-medium text-success",children:[e.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-success"}),"Connected"]}),e.jsx("span",{className:`inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-medium ${o.enabled?"bg-accent/10 text-accent-hover":"bg-border-light/20 text-text-muted"}`,children:o.enabled?"Enabled":"Disabled"})]})]}),d&&e.jsxs("div",{className:"border-t border-bg-tertiary px-4 py-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{className:"text-sm text-text-secondary",children:"Enabled"}),e.jsx("button",{onClick:M,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${x?"bg-accent":"bg-border"}`,children:e.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${x?"translate-x-6":"translate-x-1"}`})})]}),C&&e.jsxs("div",{children:[e.jsxs("label",{className:"mb-1 flex items-center gap-2 text-xs text-text-muted",children:[C.label,A&&e.jsx("span",{className:"rounded bg-success/10 px-1.5 py-0.5 text-[10px] text-success",children:"set"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{id:`channel-${l.id}-token`,name:`channel-${l.id}-token`,type:y?"text":"password",value:p,onChange:s=>{c(s.target.value),i(!0)},placeholder:A?"(configured — enter new value to change)":C.placeholder,className:"w-full rounded-lg border border-border bg-bg px-3 py-2 pr-10 text-sm text-text outline-none focus:border-accent"}),e.jsx("button",{type:"button",onClick:()=>t(!y),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-text-muted hover:text-text-secondary",children:y?e.jsx(K,{className:"h-4 w-4"}):e.jsx(I,{className:"h-4 w-4"})})]})]}),T&&e.jsxs("div",{children:[e.jsxs("label",{className:"mb-1 flex items-center gap-2 text-xs text-text-muted",children:[T.label,P&&e.jsx("span",{className:"rounded bg-success/10 px-1.5 py-0.5 text-[10px] text-success",children:"set"})]}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{id:`channel-${l.id}-api-key`,name:`channel-${l.id}-api-key`,type:n?"text":"password",value:m,onChange:s=>{u(s.target.value),i(!0)},placeholder:P?"(configured — enter new value to change)":T.placeholder,className:"w-full rounded-lg border border-border bg-bg px-3 py-2 pr-10 text-sm text-text outline-none focus:border-accent"}),e.jsx("button",{type:"button",onClick:()=>h(!n),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-text-muted hover:text-text-secondary",children:n?e.jsx(K,{className:"h-4 w-4"}):e.jsx(I,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs text-text-muted",children:"DM Policy"}),e.jsx("div",{className:"flex gap-2",children:Z.map(s=>e.jsx("button",{onClick:()=>{w(s.value),i(!0)},className:`rounded-lg border px-3 py-1.5 text-xs transition-colors ${g===s.value?"border-accent bg-accent/10 text-accent-hover":"border-border text-text-muted hover:border-border-light"}`,title:s.desc,children:s.label},s.value))})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs("button",{onClick:B,disabled:j||!r,className:"flex items-center gap-2 rounded-lg bg-accent px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-accent/80 disabled:opacity-50",children:[e.jsx(H,{className:"h-3.5 w-3.5"}),j?"Saving...":"Save"]})})]})]})}function Y(){const[l,o]=a.useState([]),[b,f]=a.useState({}),[v,d]=a.useState(!0),[k,x]=a.useState(null),[N,p]=a.useState(null),[c,m]=a.useState(null),u=async()=>{try{const[t,n]=await Promise.all([E(),D()]);o(t),f(n)}catch(t){x(t instanceof Error?t.message:"Failed to fetch channels")}finally{d(!1)}};a.useEffect(()=>{u()},[]);const g=(t,n)=>{m({type:t,message:n}),setTimeout(()=>m(null),3e3)},w=async(t,n)=>{var h;p(t);try{await R(t,n);const[r,i]=await Promise.all([E(),D()]);o(r),f(i);const j=((h=L.find(S=>S.id===t))==null?void 0:h.label)??t;g("success",`${j} settings saved (restart gateway to apply)`)}catch(r){g("error",r instanceof Error?r.message:"Failed to save")}finally{p(null)}};if(v)return e.jsx("div",{className:"space-y-2",children:Array.from({length:5}).map((t,n)=>e.jsx("div",{className:"h-14 animate-pulse rounded-xl border border-border bg-bg-secondary"},n))});if(k)return e.jsx("div",{className:"rounded-xl border border-error/50 bg-bg-secondary p-6 text-center text-error",children:k});const y={enabled:!1,allowFrom:[],dmPolicy:"pairing"};return e.jsxs("div",{className:"space-y-6",children:[e.jsx(O,{title:"Channels",subtitle:`Configure messaging channels — ${l.filter(t=>t.status==="connected").length} connected`,breadcrumbs:[{label:"Admin",href:"/overview"},{label:"Tools"},{label:"Channels"}],actions:e.jsxs("button",{onClick:()=>{d(!0),u()},className:"flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs text-text-secondary hover:border-border-light hover:text-text",children:[e.jsx(W,{className:"h-3.5 w-3.5"}),"Refresh"]})}),c&&e.jsxs("div",{className:`flex items-center gap-2 rounded-lg border px-4 py-2 text-sm ${c.type==="success"?"border-success/50 text-success":"border-error/50 text-error"}`,children:[c.type==="success"?e.jsx(_,{className:"h-4 w-4"}):e.jsx($,{className:"h-4 w-4"}),c.message]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-text-muted mb-3",children:"Built-in"}),e.jsxs("div",{className:"rounded-xl border border-bg-tertiary bg-bg-secondary px-4 py-3 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"text-sm font-medium text-text",children:"WebChat"}),e.jsx("span",{className:"text-xs text-text-muted",children:"HTTP/WebSocket — always enabled"})]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-success/10 px-2.5 py-0.5 text-xs font-medium text-success",children:[e.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-success"}),"Connected"]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-text-muted mb-3",children:"Messaging Channels"}),e.jsx("div",{className:"space-y-2",children:L.map(t=>{const n=b[t.id]??y,h=l.find(r=>r.name===t.id||r.type===t.id);return e.jsx(q,{def:t,config:n,status:h,onSave:w,saving:N},t.id)})})]}),e.jsx("p",{className:"text-xs text-text-muted text-center",children:"Channel changes are saved to config. Restart the gateway to connect/disconnect channels."})]})}export{Y as default};
@@ -1 +0,0 @@
1
- import{t as p,r as t,bG as x,j as e,bH as f}from"./index-Cml2x9pA.js";import{P as u}from"./PageHeader-DdrbS1aq.js";import{C as b}from"./ConfirmDialog-VErHWAbo.js";import{R as g}from"./refresh-cw-C-iZkzuS.js";import{S as j}from"./save-DwR9wQVu.js";import{T as C}from"./trash-2-CTeyjxD_.js";import"./chevron-right-DbLSHmff.js";import"./Modal-ybPGvlQs.js";import"./clsx-B-dksMZM.js";import"./Button-MdXmb4_n.js";function E(){const{toast:a}=p(),[l,d]=t.useState([]),[o,c]=t.useState(!0),[i,r]=t.useState(null),n=t.useCallback(async()=>{c(!0);try{const s=await x();d(s.checkpoints||[])}catch(s){a("error",`Couldn't load checkpoints — try again. (${s.message})`)}c(!1)},[a]);t.useEffect(()=>{n()},[n]);const m=async s=>{try{await f(s),await n(),a("success","Checkpoint deleted.")}catch(h){a("error",`Couldn't delete checkpoint — try again. (${h.message})`)}};return e.jsxs("div",{className:"space-y-4",children:[e.jsx(u,{title:"Checkpoints",breadcrumbs:[{label:"Admin",href:"/overview"},{label:"System"},{label:"Checkpoints"}]}),e.jsx("div",{className:"flex gap-2",children:e.jsxs("button",{onClick:n,disabled:o,className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-[#27272a] text-[#a1a1aa] text-sm font-medium hover:bg-[#3f3f46] disabled:opacity-50",children:[e.jsx(g,{className:`w-4 h-4 ${o?"animate-spin":""}`})," Refresh"]})}),e.jsx("div",{className:"space-y-2",children:l.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(j,{className:"w-4 h-4 text-[#6366f1]"}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm text-[#e4e4e7]",children:[s.sessionId.slice(0,16),"..."]}),e.jsx("div",{className:"text-xs text-[#52525b]",children:new Date(s.createdAt).toLocaleString()})]})]}),e.jsx("button",{onClick:()=>r(s.sessionId),className:"p-1.5 rounded-md bg-[#27272a] text-[#a1a1aa] hover:bg-[#3f3f46] hover:text-red-400",children:e.jsx(C,{className:"w-3.5 h-3.5"})})]},s.sessionId))}),e.jsx(b,{open:i!==null,title:"Delete this checkpoint?",message:"This can't be undone. The saved session state will be permanently removed.",confirmLabel:"Delete",onConfirm:async()=>{i&&await m(i),r(null)},onCancel:()=>r(null)})]})}export{E as default};
@@ -1,24 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WorkTab-wTlX_UKP.js","assets/index-Cml2x9pA.js","assets/index-yWybhcfI.css","assets/Modal-ybPGvlQs.js","assets/clsx-B-dksMZM.js","assets/external-link-DZ_rZsIt.js","assets/rotate-ccw-qzrB3SNw.js","assets/plus-Dpo1qfrl.js","assets/play-Cl1nC_gc.js","assets/trash-2-CTeyjxD_.js","assets/pause-BT1Bc2q3.js","assets/SessionsTab-qYHDOuC8.js","assets/CPInbox-Cq6-UY8F.js","assets/Button-MdXmb4_n.js","assets/Input-CBTwa_Iw.js","assets/PageHeader-DdrbS1aq.js","assets/chevron-right-DbLSHmff.js","assets/EmptyState-D9kQf1PX.js","assets/Tabs-DdUThlp1.js","assets/SkeletonLoader-r6OGXaU9.js","assets/approvalHeadline-DB9SgR-9.js","assets/message-square-CRsG9u6_.js","assets/bot-DvEcyQcD.js","assets/clock-JyQAYy6X.js","assets/send-DtXGsaFW.js","assets/shield-check-CXlDJyAW.js","assets/check-CuRYh4Zh.js","assets/funnel-FycfZcXo.js","assets/square-BBC-JKzY.js","assets/CPFiles-DB2nY5JE.js","assets/folder-DAdIw-Pb.js","assets/flask-conical-Ql8QxhgY.js","assets/search-D10l0m3-.js","assets/refresh-cw-C-iZkzuS.js","assets/file-text-Cfawu8Bs.js","assets/TraceViewer-BIMD_Osr.js","assets/trending-up-CXPRjRV4.js","assets/git-branch-C2qrhGGu.js","assets/chart-column-w3goFd5f.js","assets/arrow-left-WkVYLm80.js","assets/CPSocial-DshtmcK0.js","assets/lightbulb-BZJNK69S.js","assets/CPDashboard-sOok2T5v.js","assets/StatusBadge-BqlvIbdj.js","assets/list-todo-BlgfQHup.js","assets/dollar-sign-XxwPAA2a.js","assets/CPGoals-8Z1yOY8e.js","assets/CPAgents-BSUKucTe.js"])))=>i.map(i=>d[i]);
2
- import{c as F,r as s,j as e,aA as ce,l as L,m as R,A as M,P as J,t as A,a0 as te,b9 as ie,W as se,y as de,J as xe,i as ae,U as ue,s as me,_ as D,b as H,a2 as pe,ba as he,F as be,D as ge,a5 as je,bb as ve,bc as ye,a3 as fe,Q as Ne,V as we,O as Ce,bd as I,be as ke,bf as Se,bg as $e,a6 as Te,bh as ze,bi as Ae}from"./index-Cml2x9pA.js";import"./Button-MdXmb4_n.js";import"./Input-CBTwa_Iw.js";import{M as E}from"./Modal-ybPGvlQs.js";import{I as P}from"./InlineEditableField-DgMrLDj1.js";import{C as K}from"./ConfirmDialog-VErHWAbo.js";import{H as De}from"./Tooltip-C2tXJcrN.js";import{e as Pe}from"./approvalHeadline-DB9SgR-9.js";import{C as X}from"./chevron-right-DbLSHmff.js";import{B as _e}from"./bot-DvEcyQcD.js";import{P as Ie}from"./pause-BT1Bc2q3.js";import{D as Q}from"./dollar-sign-XxwPAA2a.js";import{G as re}from"./git-branch-C2qrhGGu.js";import{C as ne}from"./chart-column-w3goFd5f.js";import{C as le}from"./clock-JyQAYy6X.js";import{M as q}from"./message-square-CRsG9u6_.js";import{F as Me}from"./file-text-Cfawu8Bs.js";import{T as Ee}from"./terminal-DaBIlWEM.js";import{R as Le}from"./refresh-cw-C-iZkzuS.js";import{C as Re}from"./circle-stop-Bx2ohEg8.js";import{S as Oe}from"./send-DtXGsaFW.js";import{P as U}from"./plus-Dpo1qfrl.js";import{T as Z}from"./trash-2-CTeyjxD_.js";import"./clsx-B-dksMZM.js";import"./check-CuRYh4Zh.js";import"./pencil-BK5IU6o0.js";/**
3
- * @license lucide-react v0.513.0 - ISC
4
- *
5
- * This source code is licensed under the ISC license.
6
- * See the LICENSE file in the root directory of this source tree.
7
- */const Be=[["path",{d:"M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16",key:"jecpp"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]],O=F("briefcase",Be);/**
8
- * @license lucide-react v0.513.0 - ISC
9
- *
10
- * This source code is licensed under the ISC license.
11
- * See the LICENSE file in the root directory of this source tree.
12
- */const Fe=[["path",{d:"M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z",key:"1b4qmf"}],["path",{d:"M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"i71pzd"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2",key:"10jefs"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"M10 10h4",key:"tcdvrf"}],["path",{d:"M10 14h4",key:"kelpxr"}],["path",{d:"M10 18h4",key:"1ulq68"}]],Y=F("building-2",Fe);/**
13
- * @license lucide-react v0.513.0 - ISC
14
- *
15
- * This source code is licensed under the ISC license.
16
- * See the LICENSE file in the root directory of this source tree.
17
- */const Ue=[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]],Ve=F("mail",Ue);/**
18
- * @license lucide-react v0.513.0 - ISC
19
- *
20
- * This source code is licensed under the ISC license.
21
- * See the LICENSE file in the root directory of this source tree.
22
- */const We=[["path",{d:"m16 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"7g6ntu"}],["path",{d:"m2 16 3-8 3 8c-.87.65-1.92 1-3 1s-2.13-.35-3-1Z",key:"ijws7r"}],["path",{d:"M7 21h10",key:"1b0cd5"}],["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"M3 7h2c2 0 5-1 7-2 2 1 5 2 7 2h2",key:"3gwbw2"}]],oe=F("scale",We);function He(t){switch(t){case"active":return e.jsx(M,{size:12,className:"text-success animate-pulse"});case"paused":return e.jsx(Ie,{size:12,className:"text-warning"});case"error":return e.jsx(J,{size:12,className:"text-error"});default:return e.jsx(_e,{size:12,className:"text-text-muted"})}}function qe(t){switch(t){case"active":return"border-success/30 bg-success/5";case"paused":return"border-warning/30 bg-warning/5";case"error":return"border-error/30 bg-error/5";default:return"border-border bg-bg-secondary"}}function Ge({agents:t,runs:o,collapsed:h=!1,onToggle:i,onAgentClick:m}){const[x,N]=s.useState(null);return h?e.jsxs("div",{className:"w-10 border-l border-border bg-bg-secondary flex flex-col items-center py-3 gap-3 shrink-0",children:[e.jsx("button",{onClick:i,className:"p-1.5 rounded hover:bg-bg-tertiary text-text-muted",children:e.jsx(ce,{size:14})}),t.map(l=>e.jsxs("button",{className:"relative",title:l.name,onClick:()=>m==null?void 0:m(l),children:[e.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[9px] font-bold ${l.status==="error"?"bg-error/20 text-error":l.status==="active"?"bg-success/20 text-success":"bg-bg-tertiary text-text-muted"}`,children:l.name.charAt(0).toUpperCase()}),l.status==="active"&&e.jsx("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-success animate-pulse"})]},l.id))]}):e.jsxs("div",{className:"w-64 border-l border-border bg-bg-secondary flex flex-col h-full shrink-0",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-border",children:[e.jsx("span",{className:"text-xs font-semibold text-text-muted uppercase tracking-wide",children:"Agents"}),e.jsx("button",{onClick:i,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted",children:e.jsx(X,{size:14})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-2 space-y-2",children:[t.length===0&&e.jsx("div",{className:"text-center py-4 text-xs text-text-muted",children:"No agents registered"}),t.map(l=>{var c;const g=x===l.id,y=o.filter(b=>b.agentId===l.id),u=y[0],r=y.filter(b=>b.status==="failed"||b.status==="error").length;return e.jsxs("div",{className:`rounded-lg border p-2 cursor-pointer transition-colors ${qe(l.status)}`,onClick:b=>{b.target.closest(".expand-toggle")?N(g?null:l.id):m==null||m(l)},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-7 h-7 rounded-full flex items-center justify-center text-[10px] font-bold ${l.status==="error"?"bg-error/20 text-error":l.status==="active"?"bg-success/20 text-success":"bg-bg-tertiary text-text-muted"}`,children:l.name.charAt(0).toUpperCase()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-xs font-medium truncate",children:l.name}),e.jsxs("div",{className:"text-[10px] text-text-muted flex items-center gap-1",children:[He(l.status),e.jsx("span",{className:"capitalize",children:l.status}),l.model&&e.jsxs("span",{className:"truncate",children:["· ",l.model.split("/").pop()]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[l.status==="active"&&e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-success animate-pulse"}),e.jsx("button",{className:"expand-toggle p-0.5 rounded hover:bg-bg-tertiary text-text-muted",onClick:b=>{b.stopPropagation(),N(g?null:l.id)},children:e.jsx(X,{size:12,className:`transition-transform ${g?"rotate-90":""}`})})]})]}),g&&e.jsxs("div",{className:"mt-2 space-y-2 border-t border-border/50 pt-2",children:[e.jsxs("div",{className:"text-[10px] text-text-muted space-y-0.5",children:[e.jsxs("div",{children:["Role: ",l.role||"general"]}),e.jsxs("div",{children:["Tasks: ",l.totalTasksCompleted??0," completed"]}),l.totalCostUsd!==void 0&&e.jsxs("div",{children:["Cost: $",l.totalCostUsd.toFixed(2)]}),r>0&&e.jsxs("div",{className:"text-error",children:[r," failed run",r===1?"":"s"]})]}),u&&e.jsxs("div",{className:"text-[10px] bg-bg rounded p-1.5 border border-border",children:[e.jsxs("div",{className:"font-medium text-text-secondary flex items-center gap-1",children:[u.status==="succeeded"?e.jsx(L,{size:10,className:"text-success"}):u.status==="failed"||u.status==="error"?e.jsx(R,{size:10,className:"text-error"}):e.jsx(M,{size:10,className:"text-cyan animate-pulse"}),"Latest run"]}),e.jsxs("div",{className:u.status==="failed"||u.status==="error"?"text-error":"text-success",children:[u.status," · ",((c=u.toolsUsed)==null?void 0:c.length)??0," tools"]}),u.error&&e.jsx("div",{className:"text-error truncate mt-0.5",children:u.error})]})]})]},l.id)})]})]})}function ee(t){const o={active:"bg-success/10 text-success border-success/20",idle:"bg-yellow-500/10 text-yellow-400 border-yellow-500/20",paused:"bg-warning/10 text-warning border-warning/20",error:"bg-error/10 text-error border-error/20",stopped:"bg-zinc-500/10 text-zinc-400 border-zinc-500/20"};return o[t]||o.idle}function W(t){const o=Math.floor((Date.now()-new Date(t).getTime())/1e3);return o<60?`${o}s`:o<3600?`${Math.floor(o/60)}m`:o<86400?`${Math.floor(o/3600)}h`:`${Math.floor(o/86400)}d`}function Je({agent:t,onClose:o}){const{toast:h}=A(),[i,m]=s.useState([]),[x,N]=s.useState([]),[l,g]=s.useState(!0),[y,u]=s.useState(null),r=s.useCallback(async()=>{try{const[a,j]=await Promise.all([te(t.id,10),ie(20,void 0)]);m(a),N(j.traces||[])}catch(a){g(j=>(j&&h("error",`Couldn't load agent activity — try again. ${a.message}`),j))}g(!1)},[t.id,h]);s.useEffect(()=>{r();const a=setInterval(r,1e4);return()=>clearInterval(a)},[r]);const c=i[0],b=i.filter(a=>a.status==="failed"||a.status==="error"),k=i.reduce((a,j)=>a+j.toolsUsed.length,0);return e.jsx(E,{open:!0,onClose:o,size:"lg",title:t.name,children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`w-12 h-12 rounded-xl flex items-center justify-center text-lg font-bold border ${ee(t.status)}`,children:t.name.charAt(0).toUpperCase()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-text",children:t.name}),e.jsx("span",{className:`text-[10px] px-2 py-0.5 rounded-full border capitalize ${ee(t.status)}`,children:t.status})]}),e.jsxs("div",{className:"text-[11px] text-text-muted mt-0.5",children:[t.title||t.role," · ",t.model.split("/").pop()," · heartbeat ",W(t.lastHeartbeat)," ago"]})]})]}),e.jsx("div",{className:"grid grid-cols-4 gap-2",children:[{icon:L,label:"Tasks",value:t.totalTasksCompleted,color:"text-success"},{icon:Q,label:"Cost",value:`$${t.totalCostUsd.toFixed(2)}`,color:"text-warning"},{icon:se,label:"Tools",value:k,color:"text-accent"},{icon:R,label:"Failed",value:b.length,color:b.length>0?"text-error":"text-text-muted"}].map(a=>e.jsxs("div",{className:"bg-bg-secondary border border-border rounded-lg p-2.5 text-center",children:[e.jsx(a.icon,{size:14,className:`mx-auto mb-1 ${a.color}`}),e.jsx("div",{className:"text-sm font-bold text-text",children:a.value}),e.jsx("div",{className:"text-[9px] text-text-muted uppercase tracking-wider",children:a.label})]},a.label))}),t.status==="active"&&c&&c.status==="running"&&e.jsxs("div",{className:"bg-success/5 border border-success/20 rounded-lg p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-success mb-1",children:[e.jsx(M,{size:12,className:"animate-pulse"}),e.jsx("span",{className:"font-medium",children:"Currently working"})]}),e.jsxs("div",{className:"text-[11px] text-text-secondary",children:["Run started ",W(c.startedAt)," ago · ",c.toolsUsed.length," tools used so far"]})]}),t.status==="error"&&(c==null?void 0:c.error)&&e.jsxs("div",{className:"bg-error/5 border border-error/20 rounded-lg p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-error mb-1",children:[e.jsx(J,{size:12}),e.jsx("span",{className:"font-medium",children:"Last error"})]}),e.jsx("div",{className:"text-[11px] text-text-secondary font-mono",children:c.error})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-text-secondary",children:[e.jsx(re,{size:12,className:"text-accent"}),"Recent Runs"]}),e.jsxs("span",{className:"text-[10px] text-text-muted",children:[i.length," total"]})]}),l?e.jsx("div",{className:"space-y-1.5",children:[1,2,3].map(a=>e.jsx("div",{className:"h-10 rounded-lg bg-bg-secondary animate-pulse"},a))}):i.length===0?e.jsx("div",{className:"text-center py-4 text-[11px] text-text-muted",children:"No runs recorded yet"}):e.jsx("div",{className:"space-y-1.5 max-h-48 overflow-y-auto pr-1",children:i.map(a=>e.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-2 rounded-lg bg-bg-secondary border border-border",children:[a.status==="succeeded"?e.jsx(L,{size:12,className:"text-success shrink-0"}):a.status==="failed"||a.status==="error"?e.jsx(R,{size:12,className:"text-error shrink-0"}):e.jsx(Ke,{size:12,className:"text-cyan animate-spin shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"text-[11px] text-text-secondary truncate",children:[a.source," · ",a.toolsUsed.length," tools"]}),e.jsxs("div",{className:"text-[10px] text-text-muted",children:[a.durationMs?`${a.durationMs}ms`:"..."," · ",W(a.startedAt)," ago"]})]}),a.error&&e.jsx("span",{className:"text-[10px] text-error truncate max-w-[120px]",title:a.error,children:a.error})]},a.id))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-text-secondary",children:[e.jsx(ne,{size:12,className:"text-accent"}),"Recent Traces"]}),e.jsxs("span",{className:"text-[10px] text-text-muted",children:[x.length," loaded"]})]}),x.length===0?e.jsx("div",{className:"text-center py-4 text-[11px] text-text-muted",children:"No traces available"}):e.jsx("div",{className:"space-y-1 max-h-40 overflow-y-auto pr-1",children:x.slice(0,10).map(a=>e.jsxs("button",{onClick:()=>u(a),className:"w-full text-left px-2.5 py-2 rounded-lg bg-bg-secondary border border-border hover:bg-bg-secondary/30 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[a.status==="running"?e.jsx(M,{size:12,className:"text-cyan animate-pulse shrink-0"}):a.status==="completed"?e.jsx(L,{size:12,className:"text-success shrink-0"}):e.jsx(R,{size:12,className:"text-error shrink-0"}),e.jsx("span",{className:"text-[11px] text-text-secondary truncate flex-1",children:a.message}),e.jsx("span",{className:"text-[10px] text-text-muted shrink-0",children:a.totalMs?`${a.totalMs}ms`:"..."})]}),e.jsxs("div",{className:"flex gap-2 mt-0.5 text-[10px] text-text-muted ml-5",children:[e.jsxs("span",{children:[a.toolCalls.length," tools"]}),e.jsxs("span",{children:[a.rounds," rounds"]}),a.error&&e.jsx("span",{className:"text-error truncate",children:a.error})]})]},a.traceId))})]}),y&&e.jsx(Qe,{trace:y,onClose:()=>u(null)})]})})}function Ke({size:t,className:o}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",className:`animate-spin ${o||""}`,children:[e.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",fill:"none",strokeDasharray:"31.4 31.4",opacity:"0.3"}),e.jsx("path",{d:"M12 2a10 10 0 0 1 10 10",stroke:"currentColor",strokeWidth:"3",fill:"none"})]})}function Qe({trace:t,onClose:o}){return e.jsx(E,{open:!0,onClose:o,size:"md",title:`Trace ${t.traceId.slice(0,8)}`,children:e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"text-xs text-text-secondary truncate",children:t.message}),e.jsxs("div",{className:"flex gap-3 text-[10px] text-text-muted",children:[e.jsx("span",{className:t.status==="completed"?"text-success":t.status==="failed"?"text-error":"text-cyan",children:t.status}),e.jsxs("span",{children:[t.totalMs,"ms"]}),e.jsxs("span",{children:[t.rounds," rounds"]}),t.model&&e.jsx("span",{children:t.model.split("/").pop()})]}),t.spans.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-text-muted mb-1",children:"Spans"}),e.jsx("div",{className:"space-y-1",children:t.spans.map((h,i)=>e.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx(le,{size:10,className:"text-text-muted shrink-0"}),e.jsx("span",{className:"text-text-secondary font-mono",children:h.name}),e.jsxs("span",{className:"text-text-muted",children:[h.durationMs,"ms"]})]},i))})]}),t.toolCalls.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-text-muted mb-1",children:"Tool Calls"}),e.jsx("div",{className:"space-y-1",children:t.toolCalls.map((h,i)=>e.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx(se,{size:10,className:h.success?"text-success":"text-error"}),e.jsx("span",{className:"text-text-secondary font-mono",children:h.tool}),e.jsxs("span",{className:"text-text-muted",children:[h.durationMs,"ms"]}),e.jsxs("span",{className:"text-text-muted",children:["round ",h.round]})]},i))})]}),t.error&&e.jsxs("div",{className:"bg-error/5 border border-error/20 rounded-lg p-2.5",children:[e.jsx("div",{className:"text-[10px] text-error uppercase tracking-wider mb-1",children:"Error"}),e.jsx("div",{className:"text-[11px] text-text-secondary font-mono",children:t.error})]})]})})}function z({label:t}){return e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-5 h-5 border-2 border-accent/30 border-t-accent rounded-full animate-spin"}),e.jsxs("span",{className:"text-sm text-text-muted",children:["Loading ",t,"…"]})]})})}function B(t){const o=Math.floor((Date.now()-new Date(t).getTime())/1e3);return o<60?`${o}s`:o<3600?`${Math.floor(o/60)}m`:o<86400?`${Math.floor(o/3600)}h`:`${Math.floor(o/86400)}d`}function G({status:t}){const o={active:"bg-success/10 text-success",idle:"bg-warning/10 text-warning",running:"bg-cyan/10 text-cyan",paused:"bg-info/10 text-info",error:"bg-error/10 text-error",stopped:"bg-bg-tertiary text-text-muted",pending:"bg-warning/10 text-warning",approved:"bg-success/10 text-success",rejected:"bg-error/10 text-error",succeeded:"bg-success/10 text-success",failed:"bg-error/10 text-error",backlog:"bg-bg-tertiary text-text-muted",todo:"bg-info/10 text-info",in_progress:"bg-cyan/10 text-cyan",in_review:"bg-purple/10 text-purple-light",done:"bg-success/10 text-success",blocked:"bg-error/10 text-error",cancelled:"bg-bg-tertiary text-text-muted",critical:"bg-error/10 text-error",high:"bg-warning/10 text-warning",medium:"bg-warning/10 text-warning",low:"bg-bg-tertiary text-text-muted"},h=t||"unknown";return e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-medium ${o[h]||"bg-bg-tertiary text-text-muted"}`,children:h.replace("_"," ")})}function _({icon:t,title:o,count:h,action:i,help:m}){return e.jsxs("div",{className:"flex items-center justify-between px-5 py-3 border-b border-border",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t,{size:14,className:"text-accent-light"}),e.jsx("h2",{className:"text-sm font-semibold text-text",children:o}),h!==void 0&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-accent/10 text-accent-light",children:h}),m&&e.jsx(De,{title:m.title,description:m.description})]}),i]})}function Ze({agents:t}){const{toast:o}=A(),[h,i]=s.useState([]),[m,x]=s.useState([]),[N,l]=s.useState(!1),[g,y]=s.useState(""),[u,r]=s.useState(""),[c,b]=s.useState(null),k=s.useCallback(()=>{pe().then(i).catch(()=>{}),he().then(d=>x(d)).catch(()=>{})},[]);s.useEffect(()=>{k()},[k]);const a=async()=>{if(g.trim())try{await ve({name:g.trim(),mission:u.trim()||void 0}),y(""),r(""),l(!1),o("success","Company created."),k()}catch(d){o("error",`Couldn't create company — try again. ${d.message}`)}},j=async(d,p,C)=>{try{await ye(d,{[p]:C}),k()}catch(T){o("error",`Couldn't save company — try again. ${T.message}`)}},n=async()=>{if(c)try{await fe(c.id),b(null),o("success","Company deleted."),k()}catch(d){o("error",`Couldn't delete company — try again. ${d.message}`)}},v=async(d,p,C)=>{try{await ze(d,{[p]:C||void 0}),k()}catch(T){o("error",`Couldn't save agent — try again. ${T.message}`)}},w=["ceo","manager","engineer","researcher","general"];function f(d,p=0){var T;const C=((T=t.find(S=>S.id===d.id))==null?void 0:T.reportsTo)||"";return d.model&&d.model.split("/").pop(),e.jsxs("div",{className:p>0?"ml-6 border-l border-border pl-4":"",children:[e.jsxs("div",{className:"bg-bg-tertiary/30 border border-border rounded-xl p-3.5 mb-2 max-w-lg",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2 gap-2",children:[e.jsx("span",{className:"text-[14px] font-semibold text-text min-w-0",children:e.jsx(P,{value:d.name,onSave:S=>v(d.id,"name",S),placeholder:"Agent name"})}),e.jsx(G,{status:d.status})]}),e.jsxs("div",{className:"grid grid-cols-[72px_1fr] gap-x-3 gap-y-1.5 text-[11px]",children:[e.jsx("span",{className:"text-text-muted",children:"Title"}),e.jsx("span",{className:"text-text-secondary min-w-0",children:e.jsx(P,{value:d.title||"",onSave:S=>v(d.id,"title",S),placeholder:"Add a title",emptyLabel:"—"})}),e.jsx("span",{className:"text-text-muted",children:"Role"}),e.jsx("select",{value:d.role,onChange:S=>v(d.id,"role",S.target.value),className:"bg-bg-tertiary border border-border rounded px-1.5 py-0.5 text-[11px] text-text-secondary capitalize focus:outline-none focus:border-accent/30 justify-self-start",children:w.map(S=>e.jsx("option",{value:S,children:S},S))}),e.jsx("span",{className:"text-text-muted",children:"Reports to"}),e.jsxs("select",{value:C,onChange:S=>v(d.id,"reportsTo",S.target.value),className:"bg-bg-tertiary border border-border rounded px-1.5 py-0.5 text-[11px] text-text-secondary focus:outline-none focus:border-accent/30 justify-self-start",children:[e.jsx("option",{value:"",children:"— nobody"}),t.filter(S=>S.id!==d.id).map(S=>e.jsx("option",{value:S.id,children:S.name},S.id))]}),e.jsx("span",{className:"text-text-muted",children:"Model"}),e.jsx("span",{className:"text-text-secondary min-w-0",children:e.jsx(P,{value:d.model||"",onSave:S=>v(d.id,"model",S),placeholder:"e.g. ollama/qwen3.5:cloud",emptyLabel:"—"})})]})]}),d.reports.map(S=>f(S,p+1))]},d.id)}return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"bg-bg-secondary/50 border border-border rounded-2xl overflow-hidden",children:[e.jsx(_,{icon:Y,title:"Organization Chart",count:t.length}),e.jsx("div",{className:"p-4",children:h.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(Y,{size:24,className:"mx-auto mb-2 text-text/10"}),e.jsx("p",{className:"text-[12px] text-text-muted",children:"No agents in org chart yet"}),e.jsx("p",{className:"text-[10px] text-text-muted mt-1",children:'Spawn agents from the Agents tab, then set "Reports to" on each to build the hierarchy.'})]}):h.map(d=>f(d))})]}),e.jsxs("div",{className:"bg-bg-secondary/50 border border-border rounded-2xl overflow-hidden",children:[e.jsx(_,{icon:O,title:"Companies",count:m.length,action:e.jsxs("button",{onClick:()=>l(!0),className:"flex items-center gap-1 px-2.5 py-1 text-[10px] bg-accent text-text rounded-lg hover:bg-accent-hover",children:[e.jsx(U,{size:10})," New"]})}),N&&e.jsxs("div",{className:"p-4 border-b border-border bg-bg-secondary/30 space-y-2",children:[e.jsx("input",{value:g,onChange:d=>y(d.target.value),placeholder:"Company name...",className:"w-full bg-bg-tertiary border border-border rounded-lg px-3 py-2 text-[13px] text-text placeholder-white/20 focus:outline-none focus:border-accent/30",onKeyDown:d=>d.key==="Enter"&&a()}),e.jsx("input",{value:u,onChange:d=>r(d.target.value),placeholder:"Mission (optional)...",className:"w-full bg-bg-tertiary border border-border rounded-lg px-3 py-2 text-[12px] text-text-secondary placeholder-white/15 focus:outline-none focus:border-accent/30"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:a,className:"px-3 py-1.5 text-[11px] bg-accent text-text rounded-lg",children:"Create"}),e.jsx("button",{onClick:()=>l(!1),className:"px-3 py-1.5 text-[11px] text-text-muted",children:"Cancel"})]})]}),e.jsx("div",{className:"divide-y divide-border/30",children:m.length===0?e.jsx("div",{className:"py-6 text-center text-[12px] text-text-muted",children:'No companies yet — click "+ New" to create one.'}):m.map(d=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 hover:bg-bg-secondary/30 transition-colors",children:[e.jsx(O,{size:14,className:"text-accent-light flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-0.5",children:[e.jsx("div",{className:"text-[13px] text-text font-medium",children:e.jsx(P,{value:d.name,onSave:p=>j(d.id,"name",p),placeholder:"Company name"})}),e.jsx("div",{className:"text-[10px] text-text-muted",children:e.jsx(P,{value:d.mission||"",onSave:p=>j(d.id,"mission",p),placeholder:"Add a mission",emptyLabel:"(no mission — click to add)"})})]}),e.jsx(G,{status:d.status||"active"}),e.jsx("button",{onClick:()=>b({id:d.id,name:d.name}),className:"p-1 rounded text-text-muted hover:text-error hover:bg-error/10 transition-colors",title:"Delete company",children:e.jsx(Z,{size:12})})]},d.id))})]}),e.jsx(K,{open:!!c,title:`Delete company "${(c==null?void 0:c.name)||""}"?`,message:"This removes the company record. Agents and goals linked to it stay; they just lose the company association. This can't be undone.",confirmLabel:"Delete",onConfirm:n,onCancel:()=>b(null)})]})}function Xe({agents:t}){const{toast:o}=A(),[h,i]=s.useState([]),[m,x]=s.useState(""),[N,l]=s.useState(!1),[g,y]=s.useState(""),[u,r]=s.useState("medium"),[c,b]=s.useState(null),[k,a]=s.useState(null),j=s.useCallback(()=>{ge(m?{status:m}:void 0).then(i).catch(p=>{o("error",`Couldn't load issues — try again. ${p.message}`)})},[m,o]);s.useEffect(()=>{j()},[j]);const n=async()=>{if(g.trim())try{await Ce({title:g,priority:u}),y(""),l(!1),o("success","Issue created."),j()}catch(p){o("error",`Couldn't create issue — try again. ${p.message}`)}},v=async(p,C)=>{try{await I(p,{status:C}),j()}catch(T){o("error",`Couldn't update issue status — try again. ${T.message}`)}},w=async(p,C)=>{try{await I(p,{assigneeAgentId:C||void 0}),j()}catch(T){o("error",`Couldn't update assignee — try again. ${T.message}`)}},f=async()=>{if(k)try{await Se(k),a(null),c===k&&b(null),o("success","Issue deleted."),j()}catch(p){o("error",`Couldn't delete issue — try again. ${p.message}`)}},d=["backlog","todo","in_progress","in_review","done","blocked"];return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("button",{onClick:()=>x(""),className:`px-2.5 py-1 text-[10px] rounded-lg transition-colors ${m?"bg-bg-tertiary text-text-muted hover:text-text-secondary":"bg-accent text-text"}`,children:"All"}),d.map(p=>e.jsx("button",{onClick:()=>x(p),className:`px-2.5 py-1 text-[10px] rounded-lg transition-colors ${m===p?"bg-accent text-text":"bg-bg-tertiary text-text-muted hover:text-text-secondary"}`,children:p.replace("_"," ")},p))]}),e.jsxs("button",{onClick:()=>l(!0),className:"flex items-center gap-1 px-3 py-1.5 text-[11px] bg-accent text-text rounded-lg hover:bg-accent-hover",children:[e.jsx(U,{size:12})," New Issue"]})]}),N&&e.jsxs("div",{className:"bg-bg-tertiary/30 border border-border rounded-xl p-4 space-y-3",children:[e.jsx("input",{value:g,onChange:p=>y(p.target.value),placeholder:"Issue title...",className:"w-full bg-bg-tertiary border border-border rounded-lg px-3 py-2 text-[13px] text-text placeholder-white/20 focus:outline-none focus:border-accent/30",onKeyDown:p=>p.key==="Enter"&&n()}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("select",{value:u,onChange:p=>r(p.target.value),className:"bg-bg-tertiary border border-border rounded-lg px-2 py-1.5 text-[11px] text-text-secondary focus:outline-none",children:[e.jsx("option",{value:"low",children:"Low"}),e.jsx("option",{value:"medium",children:"Medium"}),e.jsx("option",{value:"high",children:"High"}),e.jsx("option",{value:"critical",children:"Critical"})]}),e.jsx("button",{onClick:n,className:"px-3 py-1.5 text-[11px] bg-accent text-text rounded-lg",children:"Create"}),e.jsx("button",{onClick:()=>l(!1),className:"px-3 py-1.5 text-[11px] text-text-muted hover:text-text-secondary",children:"Cancel"})]})]}),e.jsxs("div",{className:"bg-bg-secondary/50 border border-border rounded-2xl overflow-hidden",children:[e.jsx(_,{icon:O,title:"Issues",count:h.length}),e.jsx("div",{className:"divide-y divide-border/30",children:h.length===0?e.jsx("div",{className:"py-8 text-center text-[12px] text-text-muted",children:'No issues found — click "+ New Issue" to create one.'}):h.map(p=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 hover:bg-bg-secondary/30 transition-colors",children:[e.jsx("span",{className:"text-[10px] text-text-muted font-mono w-14",children:p.identifier}),e.jsx(G,{status:p.priority||"medium"}),e.jsx("button",{onClick:()=>b(p.id),className:"text-[12px] text-text-secondary flex-1 truncate text-left hover:text-text transition-colors",title:"Open details",children:p.title}),e.jsxs("select",{value:p.assigneeAgentId||"",onChange:C=>w(p.id,C.target.value),onClick:C=>C.stopPropagation(),className:"bg-bg-tertiary border border-border rounded px-1.5 py-0.5 text-[10px] text-text-secondary focus:outline-none max-w-[120px]",title:"Assignee",children:[e.jsx("option",{value:"",children:"unassigned"}),t.map(C=>e.jsx("option",{value:C.id,children:C.name},C.id))]}),e.jsxs("select",{value:p.status,onChange:C=>v(p.id,C.target.value),onClick:C=>C.stopPropagation(),className:"bg-bg-tertiary border border-border rounded px-1.5 py-0.5 text-[10px] text-text-secondary focus:outline-none",children:[d.map(C=>e.jsx("option",{value:C,children:C.replace("_"," ")},C)),e.jsx("option",{value:"cancelled",children:"cancelled"})]}),e.jsx("button",{onClick:()=>a(p.id),className:"p-1 rounded text-text-muted hover:text-error hover:bg-error/10 transition-colors",title:"Delete issue",children:e.jsx(Z,{size:12})})]},p.id))})]}),c&&e.jsx(Ye,{issueId:c,agents:t,onClose:()=>{b(null),j()},onRequestDelete:()=>a(c)}),e.jsx(K,{open:!!k,title:"Delete this issue?",message:"This can't be undone. The issue and all its comments will be removed.",confirmLabel:"Delete",onConfirm:f,onCancel:()=>a(null)})]})}function Ye({issueId:t,agents:o,onClose:h,onRequestDelete:i}){var j;const{toast:m}=A(),[x,N]=s.useState(null),[l,g]=s.useState(""),[y,u]=s.useState(!1),r=s.useCallback(async()=>{try{const n=await ke(t);N(n)}catch(n){m("error",`Couldn't load issue details — try again. ${n.message}`)}},[t,m]);s.useEffect(()=>{r()},[r]);const c=async(n,v)=>{try{await I(t,{[n]:v}),r()}catch(w){m("error",`Couldn't save issue — try again. ${w.message}`)}},b=async n=>{try{await I(t,{priority:n}),r()}catch(v){m("error",`Couldn't update priority — try again. ${v.message}`)}},k=async n=>{try{await I(t,{assigneeAgentId:n||void 0}),r()}catch(v){m("error",`Couldn't update assignee — try again. ${v.message}`)}},a=async()=>{if(l.trim()){u(!0);try{await Ae(t,l.trim(),{user:"board"}),g(""),r()}catch(n){m("error",`Couldn't post comment — try again. ${n.message}`)}finally{u(!1)}}};return e.jsx(E,{open:!0,onClose:h,size:"lg",title:x?`${x.identifier}`:"Loading…",children:x?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-text-muted/70 mb-1",children:"Title"}),e.jsx("div",{className:"text-[14px] text-text",children:e.jsx(P,{value:x.title,onSave:n=>c("title",n),placeholder:"Issue title"})})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider text-text-muted/70 mb-1",children:"Description"}),e.jsx("div",{className:"text-[12px] text-text-secondary whitespace-pre-wrap",children:e.jsx(P,{value:x.description||"",onSave:n=>c("description",n),placeholder:"Add a description…",multiline:!0,emptyLabel:"(none — click to add)"})})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 text-[11px]",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-text-muted/70 uppercase tracking-wider text-[10px] mb-1",children:"Priority"}),e.jsxs("select",{value:x.priority||"medium",onChange:n=>b(n.target.value),className:"bg-bg-tertiary border border-border rounded px-2 py-1 text-text focus:outline-none w-full",children:[e.jsx("option",{value:"low",children:"Low"}),e.jsx("option",{value:"medium",children:"Medium"}),e.jsx("option",{value:"high",children:"High"}),e.jsx("option",{value:"critical",children:"Critical"})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-text-muted/70 uppercase tracking-wider text-[10px] mb-1",children:"Assignee"}),e.jsxs("select",{value:x.assigneeAgentId||"",onChange:n=>k(n.target.value),className:"bg-bg-tertiary border border-border rounded px-2 py-1 text-text focus:outline-none w-full",children:[e.jsx("option",{value:"",children:"unassigned"}),o.map(n=>e.jsx("option",{value:n.id,children:n.name},n.id))]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-text-muted/70 uppercase tracking-wider text-[10px] mb-1",children:"Status"}),e.jsx("div",{className:"text-text capitalize",children:x.status.replace(/_/g," ")})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-[10px] uppercase tracking-wider text-text-muted/70 mb-2",children:["Comments (",((j=x.comments)==null?void 0:j.length)||0,")"]}),e.jsx("div",{className:"space-y-2 max-h-[240px] overflow-y-auto pr-1",children:(x.comments||[]).length===0?e.jsx("div",{className:"text-[11px] text-text-muted italic",children:"No comments yet."}):x.comments.map(n=>e.jsxs("div",{className:"bg-bg-secondary/30 border border-border/50 rounded-lg px-3 py-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-text-muted/70 mb-1",children:[e.jsx("span",{className:"text-text-secondary",children:n.authorAgentId||n.authorUser||"unknown"}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:[B(n.createdAt)," ago"]})]}),e.jsx("div",{className:"text-[12px] text-text whitespace-pre-wrap",children:n.body})]},n.id))}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx("input",{value:l,onChange:n=>g(n.target.value),onKeyDown:n=>{n.key==="Enter"&&!n.shiftKey&&(n.preventDefault(),a())},placeholder:"Add a comment — Enter to post",disabled:y,className:"flex-1 bg-bg-tertiary border border-border rounded px-3 py-1.5 text-[12px] text-text placeholder-white/20 focus:outline-none focus:border-accent/30"}),e.jsx("button",{onClick:a,disabled:y||!l.trim(),className:"px-3 py-1.5 text-[11px] bg-accent text-text rounded hover:bg-accent-hover disabled:opacity-50",children:"Post"})]})]}),e.jsxs("div",{className:"flex justify-between items-center pt-2 border-t border-border",children:[e.jsxs("span",{className:"text-[10px] text-text-muted",children:["Created ",B(x.createdAt)," ago"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:i,className:"px-3 py-1.5 text-[11px] text-error hover:bg-error/10 rounded",children:"Delete issue"}),e.jsx("button",{onClick:h,className:"px-3 py-1.5 text-[11px] text-text-secondary hover:text-text bg-bg-tertiary rounded",children:"Close"})]})]})]}):e.jsx("div",{className:"py-8 text-center text-[12px] text-text-muted",children:"Loading…"})})}function et({budgets:t,onRefresh:o}){const{toast:h}=A(),[i,m]=s.useState(null),[x,N]=s.useState(!1),[l,g]=s.useState(null),y=async()=>{if(l)try{await je(l.id),g(null),h("success","Budget deleted."),o()}catch(u){h("error",`Couldn't delete budget — try again. ${u.message}`)}};return e.jsxs("div",{className:"bg-bg-secondary/50 border border-border rounded-2xl overflow-hidden",children:[e.jsx(_,{icon:Q,title:"Budget Policies",count:t.length,action:e.jsxs("button",{onClick:()=>N(!0),className:"flex items-center gap-1 px-2.5 py-1 text-[10px] bg-accent text-text rounded-lg hover:bg-accent-hover",children:[e.jsx(U,{size:10})," New Budget"]})}),e.jsx("div",{className:"p-4 space-y-3",children:t.length===0?e.jsx("div",{className:"text-center py-6 text-[12px] text-text-muted",children:'No budget policies yet — click "+ New Budget" to set spending limits per agent, goal, or globally.'}):t.map(u=>{const r=u.limitUsd>0?Math.min(100,u.currentSpend/u.limitUsd*100):0,c=r>=100?"bg-error":r>=80?"bg-warning":"bg-success";return e.jsxs("div",{className:"bg-bg-tertiary/30 border border-border rounded-lg p-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-[12px] font-medium text-text",children:u.name}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] text-text-muted capitalize",children:u.scope.type}),e.jsx("span",{className:"text-[10px] text-text-muted",children:u.period}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${u.enabled?"text-success bg-success/10":"text-text-muted bg-bg-tertiary"}`,children:u.enabled?"on":"off"}),e.jsx("button",{onClick:()=>m(u),className:"text-[10px] text-text-muted hover:text-text-secondary px-1",title:"Edit budget",children:"Edit"}),e.jsx("button",{onClick:()=>g(u),className:"p-1 rounded text-text-muted hover:text-error hover:bg-error/10 transition-colors",title:"Delete budget",children:e.jsx(Z,{size:12})})]})]}),e.jsx("div",{className:"h-1.5 bg-bg-tertiary rounded-full overflow-hidden mb-1.5",children:e.jsx("div",{className:`h-full ${c} rounded-full transition-all`,style:{width:`${r}%`}})}),e.jsxs("div",{className:"flex justify-between text-[10px] text-text-muted",children:[e.jsxs("span",{children:["$",u.currentSpend.toFixed(2)," spent"]}),e.jsxs("span",{children:["$",u.limitUsd.toFixed(2)," limit · action: ",u.action]})]})]},u.id)})}),(x||i)&&e.jsx(tt,{existing:i,onClose:()=>{N(!1),m(null)},onSaved:()=>{N(!1),m(null),o()}}),e.jsx(K,{open:!!l,title:`Delete budget "${(l==null?void 0:l.name)||""}"?`,message:"The policy and its spend history are removed. Agents/goals it covered will no longer be budget-enforced unless another policy applies.",confirmLabel:"Delete",onConfirm:y,onCancel:()=>g(null)})]})}function tt({existing:t,onClose:o,onSaved:h}){var T,S;const{toast:i}=A(),m=!!t,[x,N]=s.useState((t==null?void 0:t.name)||""),[l,g]=s.useState((t==null?void 0:t.scope.type)||"global"),[y,u]=s.useState((t==null?void 0:t.scope.targetId)||""),[r,c]=s.useState((t==null?void 0:t.period)||"daily"),[b,k]=s.useState(((T=t==null?void 0:t.limitUsd)==null?void 0:T.toString())||"10"),[a,j]=s.useState(((S=t==null?void 0:t.warningThresholdPercent)==null?void 0:S.toString())||"80"),[n,v]=s.useState((t==null?void 0:t.action)||"warn"),[w,f]=s.useState((t==null?void 0:t.enabled)??!0),[d,p]=s.useState(!1),C=async()=>{if(x.trim()){p(!0);try{const $={name:x.trim(),scope:{type:l,targetId:l==="global"?void 0:y||void 0},period:r,limitUsd:Number(b)||0,warningThresholdPercent:Number(a)||80,action:n,enabled:w};m&&t?await $e(t.id,$):await Te($),i("success",m?"Budget updated.":"Budget created."),h()}catch($){i("error",`Couldn't save budget — try again. ${$.message}`)}finally{p(!1)}}};return e.jsx(E,{open:!0,onClose:o,size:"md",title:m?"Edit Budget Policy":"New Budget Policy",footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:o,className:"px-3 py-1.5 text-[11px] text-text-secondary hover:text-text",children:"Cancel"}),e.jsx("button",{onClick:C,disabled:d||!x.trim(),className:"px-3 py-1.5 text-[11px] bg-accent text-text rounded hover:bg-accent-hover disabled:opacity-50",children:d?"Saving…":m?"Save changes":"Create budget"})]}),children:e.jsxs("div",{className:"space-y-3 text-[12px]",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase tracking-wider text-text-muted",children:"Name"}),e.jsx("input",{value:x,onChange:$=>N($.target.value),placeholder:"e.g. Daily global cap",className:"mt-1 w-full bg-bg-tertiary border border-border rounded px-2 py-1.5 text-text focus:outline-none focus:border-accent/40"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase tracking-wider text-text-muted",children:"Scope"}),e.jsxs("select",{value:l,onChange:$=>g($.target.value),className:"mt-1 w-full bg-bg-tertiary border border-border rounded px-2 py-1.5 text-text focus:outline-none",children:[e.jsx("option",{value:"global",children:"Global (all agents)"}),e.jsx("option",{value:"agent",children:"Per-agent"}),e.jsx("option",{value:"goal",children:"Per-goal"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase tracking-wider text-text-muted",children:"Target ID"}),e.jsx("input",{value:y,onChange:$=>u($.target.value),placeholder:l==="global"?"n/a":l==="agent"?"agent-id":"goal-id",disabled:l==="global",className:"mt-1 w-full bg-bg-tertiary border border-border rounded px-2 py-1.5 text-text focus:outline-none disabled:opacity-40"})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase tracking-wider text-text-muted",children:"Period"}),e.jsxs("select",{value:r,onChange:$=>c($.target.value),className:"mt-1 w-full bg-bg-tertiary border border-border rounded px-2 py-1.5 text-text focus:outline-none",children:[e.jsx("option",{value:"daily",children:"Daily"}),e.jsx("option",{value:"weekly",children:"Weekly"}),e.jsx("option",{value:"monthly",children:"Monthly"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase tracking-wider text-text-muted",children:"Limit (USD)"}),e.jsx("input",{type:"number",step:"0.01",value:b,onChange:$=>k($.target.value),className:"mt-1 w-full bg-bg-tertiary border border-border rounded px-2 py-1.5 text-text focus:outline-none focus:border-accent/40"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase tracking-wider text-text-muted",children:"Warn at %"}),e.jsx("input",{type:"number",min:"1",max:"100",value:a,onChange:$=>j($.target.value),className:"mt-1 w-full bg-bg-tertiary border border-border rounded px-2 py-1.5 text-text focus:outline-none focus:border-accent/40"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase tracking-wider text-text-muted",children:"Action at limit"}),e.jsxs("select",{value:n,onChange:$=>v($.target.value),className:"mt-1 w-full bg-bg-tertiary border border-border rounded px-2 py-1.5 text-text focus:outline-none",children:[e.jsx("option",{value:"warn",children:"Warn only"}),e.jsx("option",{value:"pause",children:"Pause agent"}),e.jsx("option",{value:"stop",children:"Stop agent"})]})]}),e.jsx("div",{className:"flex items-end gap-2",children:e.jsxs("label",{className:"flex items-center gap-2 text-text-secondary cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:w,onChange:$=>f($.target.checked),className:"accent-accent"}),e.jsx("span",{children:"Enabled"})]})})]})]})})}function st({dashboard:t}){const[o,h]=s.useState([]),[i,m]=s.useState(""),[x,N]=s.useState(!1),[l,g]=s.useState(""),[y,u]=s.useState(),r=s.useRef(null),c=s.useRef(null),b=s.useCallback(()=>{var n;const a=t,j=a.agents.map(v=>`${v.name} (${v.status}, ${v.role}, cost=$${v.totalCostUsd.toFixed(2)})`).join("; ")||"none";return`[COMMAND POST] ${a.totalAgents} agents (${a.activeAgents} active), ${a.activeCheckouts} locked tasks, budget ${Math.round(a.budgetUtilization??0)}% used, ${((n=a.goalTree)==null?void 0:n.length)??0} goals. Agents: ${j}. You manage this agent organization. Be concise.
23
-
24
- `},[t]),k=s.useCallback(async()=>{const a=i.trim();if(!a||x)return;m(""),h(w=>[...w,{role:"user",content:a}]),N(!0),g("");const j=new AbortController;r.current=j;let n="",v=y;try{await me(b()+a,y,w=>{w.type==="token"&&(n+=w.data,g(n)),w.type==="done"&&w.sessionId&&(v=w.sessionId)},j.signal),v&&u(v),n&&h(w=>[...w,{role:"assistant",content:n}])}catch(w){w.name!=="AbortError"&&h(f=>[...f,{role:"assistant",content:`Error: ${w.message}`}])}finally{N(!1),g(""),r.current=null}},[i,x,y,b]);return s.useEffect(()=>{c.current&&(c.current.scrollTop=c.current.scrollHeight)},[o,l]),e.jsxs("div",{className:"bg-bg-secondary/50 border border-border rounded-2xl overflow-hidden flex flex-col",style:{height:400},children:[e.jsx(_,{icon:q,title:"Console",action:x?e.jsxs("button",{onClick:()=>{var a;return(a=r.current)==null?void 0:a.abort()},className:"text-[10px] text-error flex items-center gap-1",children:[e.jsx(Re,{size:12}),"Stop"]}):void 0}),e.jsxs("div",{ref:c,className:"flex-1 overflow-y-auto px-4 py-3 space-y-2",children:[o.length===0&&!x&&e.jsxs("div",{className:"text-center py-6",children:[e.jsx("p",{className:"text-[11px] text-text-muted mb-3",children:"Manage your organization through natural language"}),e.jsx("div",{className:"flex flex-wrap justify-center gap-1.5",children:["Status report","Create issue: Research competitors","Spawn a research agent","Set $50/day budget"].map(a=>e.jsx("button",{onClick:()=>m(a),className:"text-[10px] text-text-muted hover:text-text-muted px-2.5 py-1 rounded-full border border-border hover:border-border-light",children:a},a))})]}),o.map((a,j)=>e.jsx("div",{className:`flex ${a.role==="user"?"justify-end":"justify-start"}`,children:e.jsx("div",{className:`max-w-[85%] px-3 py-2 rounded-xl text-[12px] leading-relaxed whitespace-pre-wrap ${a.role==="user"?"bg-accent/80 text-text rounded-br-sm":"bg-bg-tertiary text-text-secondary border border-border rounded-bl-sm"}`,children:a.content})},j)),x&&l&&e.jsx("div",{className:"flex justify-start",children:e.jsxs("div",{className:"max-w-[85%] px-3 py-2 rounded-xl rounded-bl-sm bg-bg-tertiary text-text-secondary border border-border text-[12px] whitespace-pre-wrap",children:[l,e.jsx("span",{className:"inline-block w-1 h-3.5 bg-accent-light ml-0.5 animate-pulse"})]})}),x&&!l&&e.jsx("div",{className:"flex justify-start",children:e.jsx("div",{className:"px-3 py-2 rounded-xl bg-bg-tertiary border border-border",children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-muted/20 animate-bounce"}),e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-muted/20 animate-bounce",style:{animationDelay:"150ms"}}),e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-text-muted/20 animate-bounce",style:{animationDelay:"300ms"}})]})})})]}),e.jsx("div",{className:"px-3 py-2 border-t border-border",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{value:i,onChange:a=>m(a.target.value),onKeyDown:a=>{a.key==="Enter"&&(a.preventDefault(),k())},placeholder:"Tell Command Post what to do...",className:"flex-1 bg-bg-tertiary border border-border rounded-lg px-3 py-2 text-[12px] text-text placeholder-white/20 focus:outline-none focus:border-accent/30"}),e.jsx("button",{onClick:k,disabled:!i.trim()||x,className:"p-2 rounded-lg bg-accent text-text hover:bg-accent-hover disabled:opacity-30",children:e.jsx(Oe,{size:14})})]})})]})}function at({onClose:t,onCreated:o}){const{toast:h}=A(),[i,m]=s.useState(""),[x,N]=s.useState([{role:"pragmatist",model:""},{role:"skeptic",model:""}]),[l,g]=s.useState(2),[y,u]=s.useState("judge"),[r,c]=s.useState(!1),b=()=>{x.length>=5||N([...x,{role:`participant-${x.length+1}`,model:""}])},k=n=>{x.length<=2||N(x.filter((v,w)=>w!==n))},a=(n,v)=>{N(x.map((w,f)=>f===n?{...w,...v}:w))},j=async()=>{if(!(!i.trim()||x.length<2)){c(!0);try{const n=await H("/api/command-post/debates",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({question:i.trim(),participants:x.map(v=>({role:v.role.trim()||"participant",model:v.model.trim()||void 0})),rounds:l,resolution:y})});if(!n.ok)throw new Error(`${n.status} ${n.statusText}`);h("success","Debate finished — transcript saved."),o()}catch(n){h("error",`Debate failed — try again. ${n.message}`)}finally{c(!1)}}};return e.jsx(E,{open:!0,onClose:t,title:"Start a new debate",size:"lg",footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:t,className:"px-3 py-1.5 text-[11px] text-text-secondary hover:text-text",children:"Cancel"}),e.jsx("button",{onClick:j,disabled:r||!i.trim()||x.length<2,className:"px-3 py-1.5 text-[11px] bg-accent text-text rounded hover:bg-accent-hover disabled:opacity-50",children:r?"Running debate…":"Run debate"})]}),children:e.jsxs("div",{className:"space-y-3 text-[12px]",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase tracking-wider text-text-muted",children:"Question"}),e.jsx("textarea",{value:i,onChange:n=>m(n.target.value),placeholder:"e.g. Should we cache the Ollama probe results for 7 days or 30 days?",rows:2,className:"mt-1 w-full bg-bg-tertiary border border-border rounded px-2 py-1.5 text-text focus:outline-none focus:border-accent/40 resize-none"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("label",{className:"text-[10px] uppercase tracking-wider text-text-muted",children:["Participants (",x.length,"/5)"]}),e.jsx("button",{onClick:b,disabled:x.length>=5,className:"text-[10px] text-accent-light/70 hover:text-accent-light disabled:opacity-40",children:"+ Add participant"})]}),e.jsx("div",{className:"space-y-2",children:x.map((n,v)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("input",{value:n.role,onChange:w=>a(v,{role:w.target.value}),placeholder:"role (e.g. pragmatist)",className:"flex-1 bg-bg-tertiary border border-border rounded px-2 py-1 text-text focus:outline-none"}),e.jsx("input",{value:n.model,onChange:w=>a(v,{model:w.target.value}),placeholder:"model (optional — defaults to agent.model)",className:"flex-1 bg-bg-tertiary border border-border rounded px-2 py-1 text-text-secondary focus:outline-none"}),e.jsx("button",{onClick:()=>k(v),disabled:x.length<=2,className:"text-text-muted hover:text-error disabled:opacity-20 px-1",title:"Remove",children:"×"})]},v))})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase tracking-wider text-text-muted",children:"Rounds"}),e.jsx("select",{value:l,onChange:n=>g(Number(n.target.value)),className:"mt-1 w-full bg-bg-tertiary border border-border rounded px-2 py-1.5 text-text focus:outline-none",children:[1,2,3,4].map(n=>e.jsxs("option",{value:n,children:[n," round",n===1?"":"s"]},n))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase tracking-wider text-text-muted",children:"Resolution"}),e.jsxs("select",{value:y,onChange:n=>u(n.target.value),className:"mt-1 w-full bg-bg-tertiary border border-border rounded px-2 py-1.5 text-text focus:outline-none",children:[e.jsx("option",{value:"judge",children:"Judge (LLM picks winner)"}),e.jsx("option",{value:"synthesize",children:"Synthesize (LLM merges)"}),e.jsx("option",{value:"vote",children:"Vote (word-overlap consensus)"})]})]})]}),e.jsx("div",{className:"text-[10px] text-text-muted/70 italic",children:"Runs live — 1-3 minutes depending on model + rounds. Transcript saves automatically."})]})})}function rt(){const{toast:t}=A(),[o,h]=s.useState([]),[i,m]=s.useState("pending"),[x,N]=s.useState(!1),l=s.useCallback(async()=>{N(!0);try{const r=await be(i==="all"?void 0:i);h(r)}catch(r){t("error",`Couldn't load approvals — try again. ${r.message}`)}N(!1)},[i,t]);s.useEffect(()=>{l()},[l]);const g=async r=>{try{await Ne(r,"board"),t("success","Approved.")}catch(c){t("error",`Couldn't approve — try again. ${c.message}`)}l()},y=async r=>{try{await we(r,"board"),t("success","Rejected.")}catch(c){t("error",`Couldn't reject — try again. ${c.message}`)}l()},u=o.filter(r=>i==="all"?!0:r.status===i);return e.jsxs("div",{className:"bg-bg-secondary/50 border border-border rounded-2xl overflow-hidden",children:[e.jsx(_,{icon:ae,title:"Approvals",count:u.length,help:{title:"Approvals",description:"Human-in-the-loop decisions for hiring agents, budget overrides, goal proposals, and self-modification requests."},action:e.jsx("div",{className:"flex items-center gap-2",children:["pending","approved","rejected","all"].map(r=>e.jsx("button",{onClick:()=>m(r),className:`px-2 py-0.5 text-[10px] rounded-md transition-colors ${i===r?"bg-accent text-text":"bg-bg-tertiary text-text-muted hover:text-text"}`,children:r},r))})}),e.jsx("div",{className:"divide-y divide-border/30",children:x?e.jsx("div",{className:"py-8 text-center text-[12px] text-text-muted",children:"Loading..."}):u.length===0?e.jsxs("div",{className:"py-8 text-center text-[12px] text-text-muted",children:["No ",i," approvals."]}):u.map(r=>{var c;return e.jsxs("div",{className:"px-4 py-3 hover:bg-bg-tertiary/30 transition-colors",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{className:"text-[12px] text-text flex-1 truncate pr-2",children:r.type.replace(/_/g," ")}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded-full ${r.status==="pending"?"bg-warning/10 text-warning":r.status==="approved"?"bg-success/10 text-success":"bg-error/10 text-error"}`,children:r.status})]}),e.jsx("div",{className:"text-[10px] text-text-muted mb-2 truncate",children:(c=Pe(r))==null?void 0:c.headline}),r.status==="pending"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>g(r.id),className:"px-2 py-0.5 text-[10px] bg-success text-text rounded hover:bg-success/80",children:"Approve"}),e.jsx("button",{onClick:()=>y(r.id),className:"px-2 py-0.5 text-[10px] bg-error text-text rounded hover:bg-error/80",children:"Reject"})]}),r.decidedBy&&e.jsxs("div",{className:"text-[10px] text-text-muted mt-1",children:["By ",r.decidedBy," ",r.decidedAt?B(r.decidedAt)+" ago":""]})]},r.id)})})]})}function nt(){const{toast:t}=A(),[o,h]=s.useState([]),[i,m]=s.useState(null),[x,N]=s.useState(!1),[l,g]=s.useState(!1),y=s.useCallback(async()=>{N(!0);try{const r=await H("/api/command-post/debates");if(r.ok){const c=await r.json();h((c==null?void 0:c.items)||[])}}catch(r){t("error",`Couldn't load debates — try again. ${r.message}`)}N(!1)},[t]);s.useEffect(()=>{y()},[y]);const u=async r=>{try{const c=await H(`/api/command-post/debates/${r}`);if(c.ok){const b=await c.json();m(b)}}catch(c){t("error",`Couldn't open debate transcript — try again. ${c.message}`)}};if(i){const r=new Map;for(const c of i.turns){const b=r.get(c.round)||[];b.push(c),r.set(c.round,b)}return e.jsxs("div",{className:"space-y-3",children:[e.jsx("button",{onClick:()=>m(null),className:"text-[11px] text-text-muted hover:text-text-secondary",children:"← Back to debates"}),e.jsxs("div",{className:"bg-bg-secondary/50 border border-border rounded-2xl p-4",children:[e.jsx("div",{className:"text-[13px] font-semibold text-text mb-1",children:i.question}),e.jsxs("div",{className:"text-[10px] text-text-muted/70",children:[i.resolution," • ",i.rounds," round",i.rounds===1?"":"s"," • ",(i.durationMs/1e3).toFixed(1),"s"]}),i.winner&&e.jsxs("div",{className:"mt-3 p-3 bg-success/[0.06] border border-success/30 rounded-lg",children:[e.jsxs("div",{className:"text-[11px] text-success/80/80 uppercase tracking-wider",children:["Winner: ",i.winner.role]}),e.jsx("div",{className:"text-[12px] text-text mt-1",children:i.winner.content}),i.winner.justification&&e.jsx("div",{className:"text-[10px] text-text-muted italic mt-2",children:i.winner.justification})]})]}),[...r.entries()].sort((c,b)=>c[0]-b[0]).map(([c,b])=>e.jsxs("div",{className:"bg-bg-secondary/50 border border-border rounded-2xl overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2 border-b border-border/50 text-[11px] font-medium text-text-secondary uppercase tracking-wider",children:["Round ",c]}),e.jsx("div",{className:"divide-y divide-border/30",children:b.map((k,a)=>e.jsxs("div",{className:"px-4 py-3",children:[e.jsx("div",{className:"text-[11px] font-semibold text-accent-light/80 mb-1",children:k.role}),e.jsx("div",{className:"text-[11px] text-text-secondary whitespace-pre-wrap",children:k.content}),e.jsxs("div",{className:"text-[9px] text-text-muted mt-1",children:[k.model.split("/").pop()," • ",k.durationMs,"ms"]})]},a))})]},c))]})}return e.jsxs("div",{className:"bg-bg-secondary/50 border border-border rounded-2xl overflow-hidden",children:[e.jsx(_,{icon:oe,title:"Debates",count:o.length,help:{title:"Debates",description:"Pit two or more agents against each other to explore different sides of a decision. Useful for risk assessment and trade-off analysis."},action:e.jsxs("button",{onClick:()=>g(!0),className:"flex items-center gap-1 px-2.5 py-1 text-[10px] bg-accent text-text rounded-lg hover:bg-accent-hover",children:[e.jsx(U,{size:10})," New Debate"]})}),l&&e.jsx(at,{onClose:()=>g(!1),onCreated:()=>{g(!1),y()}}),e.jsx("div",{className:"divide-y divide-border/30",children:x?e.jsx("div",{className:"py-8 text-center text-[12px] text-text-muted",children:"Loading..."}):o.length===0?e.jsxs("div",{className:"py-8 text-center text-[12px] text-text-muted",children:["No debates yet. Call the ",e.jsx("code",{className:"text-accent-light/70",children:"agent_debate"})," tool to start one."]}):o.map(r=>e.jsxs("button",{onClick:()=>u(r.id),className:"w-full text-left px-4 py-3 hover:bg-bg-tertiary/30 transition-colors",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("div",{className:"text-[12px] text-text flex-1 truncate pr-2",children:r.question}),e.jsxs("span",{className:"text-[10px] text-text-muted whitespace-nowrap",children:[B(r.startedAt)," ago"]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-text-muted",children:[e.jsx("span",{children:r.resolution}),e.jsxs("span",{children:[r.rounds," round",r.rounds===1?"":"s"]}),e.jsxs("span",{children:[(r.durationMs/1e3).toFixed(1),"s"]}),r.winnerRole&&e.jsxs("span",{className:"text-success/80/70",children:["winner: ",r.winnerRole]})]})]},r.id))})]})}const lt=[{label:"Overview",tabs:[{id:"Dashboard",label:"Dashboard",icon:ne}]},{label:"Operations",tabs:[{id:"Social",label:"Social",icon:q},{id:"Inbox",label:"Inbox",icon:Ve},{id:"Goals",label:"Goals",icon:xe},{id:"Work",label:"Work",icon:O},{id:"Sessions",label:"Sessions",icon:le}]},{label:"Governance",tabs:[{id:"Issues",label:"Issues",icon:q},{id:"Approvals",label:"Approvals",icon:ae},{id:"Org Chart",label:"Org Chart",icon:re},{id:"Agents",label:"Agents",icon:ue},{id:"Files",label:"Files",icon:Me},{id:"Debates",label:"Debates",icon:oe},{id:"Costs",label:"Costs",icon:Q}]},{label:"System",tabs:[{id:"Traces",label:"Traces",icon:M},{id:"Console",label:"Console",icon:Ee}]}],ot=s.lazy(()=>D(()=>import("./WorkTab-wTlX_UKP.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]))),ct=s.lazy(()=>D(()=>import("./SessionsTab-qYHDOuC8.js"),__vite__mapDeps([11,1,2,3,4]))),it=s.lazy(()=>D(()=>import("./CPInbox-Cq6-UY8F.js"),__vite__mapDeps([12,1,2,13,4,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,6]))),dt=s.lazy(()=>D(()=>import("./CPFiles-DB2nY5JE.js"),__vite__mapDeps([29,1,2,15,16,30,31,32,33,34]))),xt=s.lazy(()=>D(()=>import("./TraceViewer-BIMD_Osr.js"),__vite__mapDeps([35,1,2,36,37,23,38,32,39]))),ut=s.lazy(()=>D(()=>import("./CPSocial-DshtmcK0.js"),__vite__mapDeps([40,1,2,33,24,41,23,21]))),mt=s.lazy(()=>D(()=>import("./CPDashboard-sOok2T5v.js"),__vite__mapDeps([42,1,2,13,4,14,43,15,16,19,33,44,45]))),pt=s.lazy(()=>D(()=>import("./CPGoals-8Z1yOY8e.js"),__vite__mapDeps([46,1,2,13,4,14,43,15,16,17,3,19,7,9]))),ht=s.lazy(()=>D(()=>import("./CPAgents-BSUKucTe.js"),__vite__mapDeps([47,1,2,13,4,14,43,15,16,17,19])));function Ut(){const[t,o]=s.useState("Dashboard"),[h,i]=s.useState(null),[m,x]=s.useState([]),[N,l]=s.useState(!0),[g,y]=s.useState(null),[u,r]=s.useState([]),[c,b]=s.useState(!1),[k,a]=s.useState(null),j=s.useCallback(async()=>{try{const[f,d]=await Promise.allSettled([de(),te()]);f.status==="fulfilled"&&(i(f.value),r(f.value.recentActivity||[])),d.status==="fulfilled"&&x(d.value),y(null)}catch(f){y(f.message)}l(!1)},[]);if(s.useEffect(()=>{j()},[j]),s.useEffect(()=>{if(!h)return;const f=localStorage.getItem("titan-token"),d=f?`/api/command-post/stream?token=${f}`:"/api/command-post/stream",p=new EventSource(d);let C=0;return p.addEventListener("commandpost:activity",T=>{C=0;try{r(S=>[...S.slice(-49),JSON.parse(T.data)])}catch{}}),p.addEventListener("commandpost:agent:status",T=>{C=0;try{const S=JSON.parse(T.data);i($=>$&&{...$,agents:$.agents.map(V=>V.id===S.agentId?{...V,status:S.status}:V)})}catch{}}),p.onerror=()=>{C++,C>5&&p.close()},()=>p.close()},[h]),s.useEffect(()=>{const f=setInterval(j,3e4);return()=>clearInterval(f)},[j]),N)return e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-5 h-5 border-2 border-accent/30 border-t-accent rounded-full animate-spin"}),e.jsx("span",{className:"text-sm text-text-muted",children:"Loading Command Post..."})]})});if(g)return e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsxs("div",{className:"text-center",children:[e.jsx(J,{className:"mx-auto mb-3 text-warning",size:32}),e.jsx("p",{className:"text-sm text-text-secondary mb-4",children:g}),e.jsx("button",{onClick:j,className:"px-4 py-2 text-sm bg-bg-tertiary rounded-lg hover:bg-border text-text-secondary transition-colors",children:"Retry"})]})});const n=h??{agents:[],totalAgents:0,activeAgents:0,activeCheckouts:0,budgetUtilization:0,recentActivity:[],checkouts:[],budgets:[],goalTree:[],companies:[]},v=lt.flatMap(f=>f.tabs.map(d=>({...d,group:f.label}))),w=()=>{switch(t){case"Dashboard":return e.jsx(s.Suspense,{fallback:e.jsx(z,{label:"dashboard"}),children:e.jsx(mt,{})});case"Social":return e.jsx(s.Suspense,{fallback:e.jsx(z,{label:"social"}),children:e.jsx(ut,{})});case"Inbox":return e.jsx(s.Suspense,{fallback:e.jsx(z,{label:"inbox"}),children:e.jsx(it,{})});case"Goals":return e.jsx(s.Suspense,{fallback:e.jsx(z,{label:"goals"}),children:e.jsx(pt,{})});case"Work":return e.jsx(s.Suspense,{fallback:e.jsx(z,{label:"work"}),children:e.jsx(ot,{})});case"Sessions":return e.jsx(s.Suspense,{fallback:e.jsx(z,{label:"sessions"}),children:e.jsx(ct,{})});case"Issues":return e.jsx(Xe,{agents:n.agents});case"Approvals":return e.jsx(rt,{});case"Org Chart":return e.jsx(Ze,{agents:n.agents});case"Agents":return e.jsx(s.Suspense,{fallback:e.jsx(z,{label:"agents"}),children:e.jsx(ht,{})});case"Files":return e.jsx(s.Suspense,{fallback:e.jsx(z,{label:"files"}),children:e.jsx(dt,{})});case"Debates":return e.jsx(nt,{});case"Costs":return e.jsx(et,{budgets:n.budgets,onRefresh:j});case"Traces":return e.jsx(s.Suspense,{fallback:e.jsx(z,{label:"traces"}),children:e.jsx(xt,{})});case"Console":return e.jsx(st,{dashboard:n});default:return null}};return e.jsxs("div",{className:"h-full flex overflow-hidden",children:[e.jsxs("div",{className:"flex-1 min-w-0 overflow-auto",children:[e.jsx("div",{className:"sticky top-0 z-20 border-b border-border bg-bg/95 backdrop-blur",children:e.jsxs("div",{className:"flex items-center gap-3 px-4 md:px-6 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-sm font-bold text-text",children:"Command Post"}),e.jsx("p",{className:"text-[10px] text-text-muted",children:"Agent governance"})]}),e.jsx("div",{className:"flex-1 min-w-0 overflow-x-auto",children:e.jsx("div",{className:"flex items-center gap-1",children:v.map(f=>{const d=t===f.id;return e.jsxs("button",{onClick:()=>o(f.id),title:`${f.group}: ${f.label}`,className:`shrink-0 flex items-center gap-1.5 px-2.5 py-1.5 rounded-lg text-[12px] transition-all duration-150 ${d?"bg-accent/10 text-accent-light font-medium":"text-text-secondary hover:text-text hover:bg-bg-tertiary/50"}`,children:[e.jsx(f.icon,{size:14,className:d?"text-accent-light":"text-text-muted"}),e.jsx("span",{children:f.label})]},f.id)})})}),e.jsxs("button",{onClick:j,className:"shrink-0 flex items-center justify-center gap-1.5 px-2.5 py-1.5 text-[11px] text-text-muted bg-bg-tertiary/50 border border-border rounded-lg hover:bg-bg-tertiary transition-colors",children:[e.jsx(Le,{size:12,className:N?"animate-spin":""}),"Refresh"]})]})}),e.jsx("div",{className:"max-w-6xl mx-auto px-4 md:px-6 py-4 md:py-6",children:e.jsx(w,{})})]}),e.jsx(Ge,{collapsed:c,onToggle:()=>b(!c),agents:n.agents,runs:m,onAgentClick:f=>a(f)}),k&&e.jsx(Je,{agent:k,onClose:()=>a(null)})]})}export{Ut as default};
@@ -1 +0,0 @@
1
- import{r as f,j as s}from"./index-Cml2x9pA.js";import{M as g}from"./Modal-ybPGvlQs.js";import{B as t}from"./Button-MdXmb4_n.js";function p({open:n,title:i,message:o,confirmLabel:l="Confirm",cancelLabel:d="Cancel",variant:m="danger",onConfirm:c,onCancel:r}){const[e,a]=f.useState(!1),x=async()=>{a(!0);try{await c()}finally{a(!1)}};return s.jsx(g,{open:n,onClose:()=>!e&&r(),title:i,size:"sm",footer:s.jsxs(s.Fragment,{children:[s.jsx(t,{variant:"ghost",size:"sm",onClick:r,disabled:e,children:d}),s.jsx(t,{variant:m==="danger"?"danger":"primary",size:"sm",onClick:x,loading:e,children:l})]}),children:s.jsx("div",{className:"text-sm text-text-secondary leading-relaxed",children:o})})}export{p as C};
@@ -1 +0,0 @@
1
- import{t as f,r,aW as u,j as e,aX as g,aY as p}from"./index-Cml2x9pA.js";import{P as j}from"./PageHeader-DdrbS1aq.js";import{E as C}from"./EmptyState-D9kQf1PX.js";import{C as y}from"./ConfirmDialog-VErHWAbo.js";import{R as N}from"./refresh-cw-C-iZkzuS.js";import{C as m}from"./clock-JyQAYy6X.js";import{T as v,a as w}from"./toggle-right-DTmrC5RD.js";import{T as k}from"./trash-2-CTeyjxD_.js";import"./chevron-right-DbLSHmff.js";import"./Button-MdXmb4_n.js";import"./clsx-B-dksMZM.js";import"./Modal-ybPGvlQs.js";function H(){const{toast:s}=f(),[i,x]=r.useState([]),[o,c]=r.useState(!0),[d,n]=r.useState(null),t=r.useCallback(async()=>{c(!0);try{const a=await u();x(a.jobs||[])}catch(a){s("error",`Couldn't load cron jobs — try again. (${a.message})`)}c(!1)},[s]);r.useEffect(()=>{t()},[t]);const b=async a=>{try{await g(a),await t(),s("success","Cron job updated.")}catch(l){s("error",`Couldn't toggle cron job — try again. (${l.message})`)}},h=async a=>{try{await p(a),await t(),s("success","Cron job deleted.")}catch(l){s("error",`Couldn't delete cron job — try again. (${l.message})`)}};return e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{title:"Cron Scheduler",breadcrumbs:[{label:"Admin",href:"/overview"},{label:"System"},{label:"Cron"}]}),e.jsx("div",{className:"flex gap-2",children:e.jsxs("button",{onClick:t,disabled:o,className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-[#27272a] text-[#a1a1aa] text-sm font-medium hover:bg-[#3f3f46] disabled:opacity-50",children:[e.jsx(N,{className:`w-4 h-4 ${o?"animate-spin":""}`})," Refresh"]})}),e.jsxs("div",{className:"space-y-2",children:[!o&&i.length===0&&e.jsx(C,{icon:e.jsx(m,{className:"w-8 h-8"}),title:"No scheduled jobs yet",description:'Cron jobs run tasks for you on a schedule — like "summarize my inbox every morning at 8". Ask TITAN in chat: "every weekday at 8am, check the news and brief me".'}),i.map(a=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(m,{className:"w-4 h-4 text-[#6366f1]"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-[#e4e4e7]",children:a.name}),e.jsxs("div",{className:"text-xs text-[#52525b]",children:[a.schedule," • ",a.command]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>b(a.id),className:"p-1.5 rounded-md bg-[#27272a] text-[#a1a1aa] hover:bg-[#3f3f46]",children:a.enabled?e.jsx(v,{className:"w-4 h-4 text-emerald-400"}):e.jsx(w,{className:"w-4 h-4 text-[#52525b]"})}),e.jsx("button",{onClick:()=>n(a.id),className:"p-1.5 rounded-md bg-[#27272a] text-[#a1a1aa] hover:bg-[#3f3f46] hover:text-red-400",children:e.jsx(k,{className:"w-3.5 h-3.5"})})]})]},a.id))]}),e.jsx(y,{open:d!==null,title:"Delete cron job?",message:"This can't be undone.",confirmLabel:"Delete",onConfirm:async()=>{const a=d;n(null),a&&await h(a)},onCancel:()=>n(null)})]})}export{H as default};