titan-agent 5.4.2 → 5.5.6

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 (302) hide show
  1. package/README.md +1 -1
  2. package/dist/agent/agent.js +9 -5
  3. package/dist/agent/agent.js.map +1 -1
  4. package/dist/agent/agentLoop.js +7 -3
  5. package/dist/agent/agentLoop.js.map +1 -1
  6. package/dist/agent/checkpoint.js +2 -2
  7. package/dist/agent/checkpoint.js.map +1 -1
  8. package/dist/agent/commandPost.js +3 -3
  9. package/dist/agent/commandPost.js.map +1 -1
  10. package/dist/agent/goalProposer.js +2 -2
  11. package/dist/agent/goalProposer.js.map +1 -1
  12. package/dist/agent/goals.js +3 -3
  13. package/dist/agent/goals.js.map +1 -1
  14. package/dist/agent/peerAdvise.js +1 -1
  15. package/dist/agent/peerAdvise.js.map +1 -1
  16. package/dist/agent/planner.js +4 -4
  17. package/dist/agent/planner.js.map +1 -1
  18. package/dist/agent/userProfile.js +2 -2
  19. package/dist/agent/userProfile.js.map +1 -1
  20. package/dist/cli/doctor.js +33 -0
  21. package/dist/cli/doctor.js.map +1 -1
  22. package/dist/cli/onboard.js +4 -4
  23. package/dist/cli/onboard.js.map +1 -1
  24. package/dist/config/config.js +3 -3
  25. package/dist/config/config.js.map +1 -1
  26. package/dist/config/schema.js +8 -1
  27. package/dist/config/schema.js.map +1 -1
  28. package/dist/gateway/routes/adminRouter.js +500 -0
  29. package/dist/gateway/routes/adminRouter.js.map +1 -0
  30. package/dist/gateway/routes/agents.js +231 -0
  31. package/dist/gateway/routes/agents.js.map +1 -0
  32. package/dist/gateway/routes/agentsRouter.js +32 -0
  33. package/dist/gateway/routes/agentsRouter.js.map +1 -0
  34. package/dist/gateway/routes/checkpoints.js +41 -0
  35. package/dist/gateway/routes/checkpoints.js.map +1 -0
  36. package/dist/gateway/routes/commandPost.js +755 -0
  37. package/dist/gateway/routes/commandPost.js.map +1 -0
  38. package/dist/gateway/routes/companies.js +166 -0
  39. package/dist/gateway/routes/companies.js.map +1 -0
  40. package/dist/gateway/routes/files.js +295 -0
  41. package/dist/gateway/routes/files.js.map +1 -0
  42. package/dist/gateway/routes/hardwareRouter.js +151 -0
  43. package/dist/gateway/routes/hardwareRouter.js.map +1 -0
  44. package/dist/gateway/routes/mcpRouter.js +88 -0
  45. package/dist/gateway/routes/mcpRouter.js.map +1 -0
  46. package/dist/gateway/routes/mesh.js +464 -0
  47. package/dist/gateway/routes/mesh.js.map +1 -0
  48. package/dist/gateway/routes/metricsRouter.js +131 -0
  49. package/dist/gateway/routes/metricsRouter.js.map +1 -0
  50. package/dist/gateway/routes/organism.js +82 -0
  51. package/dist/gateway/routes/organism.js.map +1 -0
  52. package/dist/gateway/routes/paperclip.js +101 -0
  53. package/dist/gateway/routes/paperclip.js.map +1 -0
  54. package/dist/gateway/routes/sessions.js +227 -0
  55. package/dist/gateway/routes/sessions.js.map +1 -0
  56. package/dist/gateway/routes/skills.js +295 -0
  57. package/dist/gateway/routes/skills.js.map +1 -0
  58. package/dist/gateway/routes/socialRouter.js +145 -0
  59. package/dist/gateway/routes/socialRouter.js.map +1 -0
  60. package/dist/gateway/routes/systemRouter.js +220 -0
  61. package/dist/gateway/routes/systemRouter.js.map +1 -0
  62. package/dist/gateway/routes/teamsRecipes.js +297 -0
  63. package/dist/gateway/routes/teamsRecipes.js.map +1 -0
  64. package/dist/gateway/routes/tests.js +401 -0
  65. package/dist/gateway/routes/tests.js.map +1 -0
  66. package/dist/gateway/routes/traces.js +33 -0
  67. package/dist/gateway/routes/traces.js.map +1 -0
  68. package/dist/gateway/routes/voiceRouter.js +770 -0
  69. package/dist/gateway/routes/voiceRouter.js.map +1 -0
  70. package/dist/gateway/routes/watchRouter.js +131 -0
  71. package/dist/gateway/routes/watchRouter.js.map +1 -0
  72. package/dist/gateway/server.js +1179 -7379
  73. package/dist/gateway/server.js.map +1 -1
  74. package/dist/mcp/registry.js +2 -2
  75. package/dist/mcp/registry.js.map +1 -1
  76. package/dist/memory/episodic.js +2 -2
  77. package/dist/memory/episodic.js.map +1 -1
  78. package/dist/memory/learning.js +3 -3
  79. package/dist/memory/learning.js.map +1 -1
  80. package/dist/memory/memory.js +3 -3
  81. package/dist/memory/memory.js.map +1 -1
  82. package/dist/organism/drives.js +2 -2
  83. package/dist/organism/drives.js.map +1 -1
  84. package/dist/providers/errorTaxonomy.js +13 -0
  85. package/dist/providers/errorTaxonomy.js.map +1 -1
  86. package/dist/providers/ollama.js +3 -1
  87. package/dist/providers/ollama.js.map +1 -1
  88. package/dist/providers/openai_compat.js +4 -3
  89. package/dist/providers/openai_compat.js.map +1 -1
  90. package/dist/providers/router.js +13 -0
  91. package/dist/providers/router.js.map +1 -1
  92. package/dist/safety/fixOscillation.js +15 -0
  93. package/dist/safety/fixOscillation.js.map +1 -1
  94. package/dist/safety/killSwitch.js +2 -2
  95. package/dist/safety/killSwitch.js.map +1 -1
  96. package/dist/safety/selfRepair.js +7 -3
  97. package/dist/safety/selfRepair.js.map +1 -1
  98. package/dist/skills/builtin/agent_debate.js +2 -2
  99. package/dist/skills/builtin/agent_debate.js.map +1 -1
  100. package/dist/skills/builtin/apply_patch.js +3 -3
  101. package/dist/skills/builtin/apply_patch.js.map +1 -1
  102. package/dist/skills/builtin/shell.js +2 -2
  103. package/dist/skills/builtin/shell.js.map +1 -1
  104. package/dist/skills/builtin/voice_control.js +49 -0
  105. package/dist/skills/builtin/voice_control.js.map +1 -0
  106. package/dist/skills/builtin/widget_gallery.js +6 -1
  107. package/dist/skills/builtin/widget_gallery.js.map +1 -1
  108. package/dist/skills/registry.js +15 -4
  109. package/dist/skills/registry.js.map +1 -1
  110. package/dist/storage/JsonStorage.js +4 -4
  111. package/dist/storage/JsonStorage.js.map +1 -1
  112. package/dist/utils/constants.js +1 -1
  113. package/dist/utils/constants.js.map +1 -1
  114. package/dist/utils/helpers.js +3 -1
  115. package/dist/utils/helpers.js.map +1 -1
  116. package/dist/utils/lifecycle.js +86 -0
  117. package/dist/utils/lifecycle.js.map +1 -0
  118. package/dist/voice/bridge.js +136 -0
  119. package/dist/voice/bridge.js.map +1 -0
  120. package/docs/COO-MASTER-PLAN-2026-05-02.md +474 -0
  121. package/docs/HANDOFF/2026-04-29.md +141 -0
  122. package/docs/HANDOFF-2026-04-30.md +144 -0
  123. package/docs/HANDOFF-2026-05-03.md +114 -0
  124. package/docs/adr/2026-04-29-widget-pipeline-traceability.md +49 -0
  125. package/docs/agent-memory/README.md +45 -0
  126. package/docs/agent-memory/commands.md +100 -0
  127. package/docs/agent-memory/context-tree.md +101 -0
  128. package/docs/agent-memory/current-state.md +54 -0
  129. package/docs/agent-memory/decisions.md +78 -0
  130. package/docs/agent-memory/known-issues.md +76 -0
  131. package/docs/agent-memory/reflections.md +52 -0
  132. package/docs/agent-memory/skills-candidates.md +80 -0
  133. package/docs/superpowers/plans/2026-04-29-comprehensive-audit.md +256 -0
  134. package/docs/superpowers/plans/2026-04-29-comprehensive-test-plan.md +396 -0
  135. package/docs/superpowers/plans/2026-04-29-fix-all-prs.md +251 -0
  136. package/docs/superpowers/plans/2026-04-29-gitnexus-gap-remediation.md +969 -0
  137. package/package.json +5 -2
  138. package/ui/dist/assets/{AuditPanel-CM6Wg9hO.js → AuditPanel-VzSndmDN.js} +2 -2
  139. package/ui/dist/assets/{AutonomyPanel-CESx3ANg.js → AutonomyPanel-BiFouzAV.js} +2 -2
  140. package/ui/dist/assets/AutopilotPanel-fjOfM668.js +1 -0
  141. package/ui/dist/assets/{AutoresearchPanel-DR47NqT5.js → AutoresearchPanel-CVCxzAH3.js} +2 -2
  142. package/ui/dist/assets/BackupPanel-CHVTG--q.js +1 -0
  143. package/ui/dist/assets/{BrowserPanel-C15x9bLn.js → BrowserPanel-D5mvMKFU.js} +2 -2
  144. package/ui/dist/assets/CPActivity-B12mt35m.js +1 -0
  145. package/ui/dist/assets/CPAgentDetail-DsdShc-1.js +1 -0
  146. package/ui/dist/assets/CPAgents-j_7C-oQV.js +1 -0
  147. package/ui/dist/assets/CPApprovals-BShKSX9X.js +1 -0
  148. package/ui/dist/assets/CPCosts-CKPlhBDs.js +1 -0
  149. package/ui/dist/assets/CPDashboard-11c0nkxK.js +1 -0
  150. package/ui/dist/assets/CPFiles-BhLEOnXy.js +1 -0
  151. package/ui/dist/assets/CPGoals-Bi3t1b2P.js +1 -0
  152. package/ui/dist/assets/CPInbox-Bbr7khp6.js +11 -0
  153. package/ui/dist/assets/CPIssueDetail-DSdgNK8r.js +1 -0
  154. package/ui/dist/assets/CPIssues-DDEVKhX6.js +1 -0
  155. package/ui/dist/assets/CPLayout-DgPOfyGv.js +17 -0
  156. package/ui/dist/assets/CPOrg-Df73RrRJ.js +8 -0
  157. package/ui/dist/assets/CPRuns-ByioAz8w.js +1 -0
  158. package/ui/dist/assets/{CPSocial-nb-j7sOE.js → CPSocial-Dlnr_w1X.js} +2 -2
  159. package/ui/dist/assets/ChannelsPanel-DQjQCTK5.js +1 -0
  160. package/ui/dist/assets/CheckpointsPanel-C4vKjlAJ.js +1 -0
  161. package/ui/dist/assets/CommandPostHub-C9pp5Giq.js +24 -0
  162. package/ui/dist/assets/CronPanel-C6bzUfrD.js +1 -0
  163. package/ui/dist/assets/DaemonPanel-BA5Tb_UO.js +1 -0
  164. package/ui/dist/assets/{DataTable-B2Ma8hfi.js → DataTable-CH7IYJJh.js} +1 -1
  165. package/ui/dist/assets/{EmptyState-CcKyk5Yn.js → EmptyState-jU6yNDnF.js} +1 -1
  166. package/ui/dist/assets/{EvalHarnessPanel-BqtMc1ZM.js → EvalHarnessPanel-DnYqredY.js} +2 -2
  167. package/ui/dist/assets/EvalPanel-ChO7CD1r.js +1 -0
  168. package/ui/dist/assets/{FilesPanel-3QKvrWPo.js → FilesPanel-CaUkv2is.js} +2 -2
  169. package/ui/dist/assets/FleetPanel-DC_5uj0N.js +1 -0
  170. package/ui/dist/assets/{HomelabPanel-DhrjTX9m.js → HomelabPanel-CE5PGRpL.js} +2 -2
  171. package/ui/dist/assets/InfraView-C-uSlvb9.js +2 -0
  172. package/ui/dist/assets/InlineEditableField-BMQjiE6-.js +1 -0
  173. package/ui/dist/assets/Input-Bu_b3qmY.js +1 -0
  174. package/ui/dist/assets/IntegrationsPanel-DsYpAq43.js +1 -0
  175. package/ui/dist/assets/IntelligenceView-DUdIO1K7.js +2 -0
  176. package/ui/dist/assets/LearningPanel-UpQZC-mA.js +1 -0
  177. package/ui/dist/assets/LogsPanel-ClXJ4fcr.js +1 -0
  178. package/ui/dist/assets/McpPanel-JKgtIERQ.js +1 -0
  179. package/ui/dist/assets/{MemoryGraphPanel-Bzvjmzvk.js → MemoryGraphPanel-Bo2OrvA6.js} +2 -2
  180. package/ui/dist/assets/MemoryWikiPanel-BqJ1AmYm.js +11 -0
  181. package/ui/dist/assets/{MeshPanel-C3LJSlht.js → MeshPanel-BJVGYvwk.js} +2 -2
  182. package/ui/dist/assets/Modal-CAAooiZU.js +1 -0
  183. package/ui/dist/assets/NvidiaPanel-BtCg3G4w.js +1 -0
  184. package/ui/dist/assets/OrganismPanel-DgrTTzcF.js +1 -0
  185. package/ui/dist/assets/OverviewPanel-rVav1Hox.js +1 -0
  186. package/ui/dist/assets/{PageHeader-BimceqQo.js → PageHeader-CnZtP8ek.js} +1 -1
  187. package/ui/dist/assets/PaperclipPanel-C-FKdhiF.js +1 -0
  188. package/ui/dist/assets/{PersonasPanel-L1j78p6H.js → PersonasPanel-BmlxokfB.js} +1 -1
  189. package/ui/dist/assets/RecipesPanel-BNKKChis.js +1 -0
  190. package/ui/dist/assets/SecurityPanel-I7JRHiNy.js +1 -0
  191. package/ui/dist/assets/SelfImprovePanel-u9h0Lt3p.js +1 -0
  192. package/ui/dist/assets/{SelfProposalsPanel-lNmiDThB.js → SelfProposalsPanel-DKl9iBjM.js} +2 -2
  193. package/ui/dist/assets/SessionsPanel-BhRiWI_g.js +1 -0
  194. package/ui/dist/assets/{SessionsTab-JQbltWww.js → SessionsTab-Bk08wyeY.js} +1 -1
  195. package/ui/dist/assets/SettingsPanel-haLfmG2k.js +1 -0
  196. package/ui/dist/assets/SettingsView--gi3fxI8.js +2 -0
  197. package/ui/dist/assets/{SkeletonLoader-atQtpcF5.js → SkeletonLoader-B5v09EF_.js} +1 -1
  198. package/ui/dist/assets/{SkillsPanel-DlFs2ih7.js → SkillsPanel-BlAHFLcQ.js} +1 -1
  199. package/ui/dist/assets/SomaView-CExtS3zw.js +5 -0
  200. package/ui/dist/assets/{StatCard-DciE_Iqc.js → StatCard-BIsyMybM.js} +1 -1
  201. package/ui/dist/assets/{StatusBadge-BtfSPoW2.js → StatusBadge-D5nU7El8.js} +1 -1
  202. package/ui/dist/assets/Tabs-BBYZrBI8.js +1 -0
  203. package/ui/dist/assets/TeamsPanel-LPXJg823.js +1 -0
  204. package/ui/dist/assets/TelemetryPanel-EqpRBmOI.js +1 -0
  205. package/ui/dist/assets/TitanCanvas-BCbWnLMd.js +985 -0
  206. package/ui/dist/assets/ToolsView-CeP0Zz-N.js +2 -0
  207. package/ui/dist/assets/{Tooltip-70UK0E2I.js → Tooltip-BSO2XVpF.js} +1 -1
  208. package/ui/dist/assets/TraceViewer-BKI7o5B0.js +1 -0
  209. package/ui/dist/assets/TrainingPanel-c-RhjdE1.js +1 -0
  210. package/ui/dist/assets/VoiceOverlay-D-gc58b0.js +27 -0
  211. package/ui/dist/assets/VramPanel-C6xc7zgd.js +1 -0
  212. package/ui/dist/assets/{WatchView-C-sGFpVy.js → WatchView-dqBVCVH0.js} +1 -1
  213. package/ui/dist/assets/WorkTab-CBoLNrTM.js +1 -0
  214. package/ui/dist/assets/{WorkflowsPanel-CvgQU1xI.js → WorkflowsPanel-BAnSTOYe.js} +2 -2
  215. package/ui/dist/assets/approvalHeadline-DB9SgR-9.js +1 -0
  216. package/ui/dist/assets/{arrow-left-DwqHtJiU.js → arrow-left-5chqas7J.js} +1 -1
  217. package/ui/dist/assets/briefcase-D4vLzudp.js +6 -0
  218. package/ui/dist/assets/{chart-column-BtNO6sRy.js → chart-column-CdFlBpoP.js} +1 -1
  219. package/ui/dist/assets/check-Bpm1IONe.js +6 -0
  220. package/ui/dist/assets/chevron-down-D7OLjvuD.js +6 -0
  221. package/ui/dist/assets/chevron-right-aQEw2mUW.js +6 -0
  222. package/ui/dist/assets/chevron-up-C5g6pEj8.js +6 -0
  223. package/ui/dist/assets/{circle-check-big-DZRE_MbN.js → circle-check-big-fPhEdP88.js} +1 -1
  224. package/ui/dist/assets/clock-CTsgP_Sn.js +6 -0
  225. package/ui/dist/assets/{dollar-sign-aVG3a5eL.js → dollar-sign-CudFVYFc.js} +1 -1
  226. package/ui/dist/assets/{download-BxiWJU4G.js → download-DZRxDn67.js} +1 -1
  227. package/ui/dist/assets/external-link-BZ0y_Ahx.js +6 -0
  228. package/ui/dist/assets/{eye-off-CkgfFYhm.js → eye-off-BmJF0YYx.js} +1 -1
  229. package/ui/dist/assets/folder-DA43TRCm.js +11 -0
  230. package/ui/dist/assets/{funnel-PkLdxKyC.js → funnel-J3mULzrz.js} +1 -1
  231. package/ui/dist/assets/{git-branch-BM-Gw95X.js → git-branch-oHibJqDq.js} +1 -1
  232. package/ui/dist/assets/{index-D0RJ8701.css → index-BR0vfkIi.css} +1 -1
  233. package/ui/dist/assets/{index-CahJbWSR.js → index-DzwowwSI.js} +20 -20
  234. package/ui/dist/assets/{layers-BuGf4FIJ.js → layers-DsyEyu7z.js} +1 -1
  235. package/ui/dist/assets/{legacy-CR6o4t-y.js → legacy-8ITl64sV.js} +1 -1
  236. package/ui/dist/assets/{lightbulb-n8gc_XAL.js → lightbulb-C54Ske-p.js} +1 -1
  237. package/ui/dist/assets/list-todo-Cnd4rdoK.js +6 -0
  238. package/ui/dist/assets/loader-circle-1YOBsoQp.js +6 -0
  239. package/ui/dist/assets/network-DbGDAdrn.js +6 -0
  240. package/ui/dist/assets/{pause-DCV52koX.js → pause-CYhO_uQo.js} +1 -1
  241. package/ui/dist/assets/{play-CcJ9BnCh.js → play-DVY9c5Ck.js} +1 -1
  242. package/ui/dist/assets/{plug-CfWBXfCl.js → plug-BcXjlPUL.js} +1 -1
  243. package/ui/dist/assets/plus-Csu2v9GN.js +6 -0
  244. package/ui/dist/assets/{proxy-CzZDfLmm.js → proxy-DxS2_9D7.js} +1 -1
  245. package/ui/dist/assets/rotate-ccw-Co-_W04j.js +6 -0
  246. package/ui/dist/assets/save-Btx-kpoW.js +6 -0
  247. package/ui/dist/assets/search-0hXTwEZR.js +6 -0
  248. package/ui/dist/assets/send-TEpapzQR.js +6 -0
  249. package/ui/dist/assets/shield-check-DjBJXZUr.js +6 -0
  250. package/ui/dist/assets/{square-DJpUhlxi.js → square-OweUvjP-.js} +1 -1
  251. package/ui/dist/assets/{target-DWcmM_9m.js → target-BRW80Xer.js} +1 -1
  252. package/ui/dist/assets/terminal-BtiqJ628.js +16 -0
  253. package/ui/dist/assets/{toggle-right-YusFQ69L.js → toggle-right-CKtSrl28.js} +1 -1
  254. package/ui/dist/assets/{trash-2-CK7yQ55V.js → trash-2-DgWrHVax.js} +1 -1
  255. package/ui/dist/assets/{trending-up-DGjFyubC.js → trending-up-MpIrE4j6.js} +1 -1
  256. package/ui/dist/assets/{trophy-uQv_NgDB.js → trophy-CECuZNhX.js} +1 -1
  257. package/ui/dist/assets/users-dZgv4ePG.js +16 -0
  258. package/ui/dist/assets/wrench-CDz3xYve.js +11 -0
  259. package/ui/dist/index.html +2 -2
  260. package/ui/dist/assets/AutopilotPanel-DtEet1hJ.js +0 -1
  261. package/ui/dist/assets/BackupPanel-BGP8p3l3.js +0 -1
  262. package/ui/dist/assets/CPAgents-DYUtPzSq.js +0 -1
  263. package/ui/dist/assets/CPDashboard-Bf0-SyCh.js +0 -6
  264. package/ui/dist/assets/CPFiles-CxgxjQcO.js +0 -1
  265. package/ui/dist/assets/CPGoals-BsmCMTvT.js +0 -1
  266. package/ui/dist/assets/CPInbox-tMSbmQ9H.js +0 -11
  267. package/ui/dist/assets/ChannelsPanel-DP5C2OKd.js +0 -1
  268. package/ui/dist/assets/CheckpointsPanel-DlranVLZ.js +0 -1
  269. package/ui/dist/assets/CommandPostHub-BgxIa4Ev.js +0 -29
  270. package/ui/dist/assets/CronPanel-LoT5yKwJ.js +0 -1
  271. package/ui/dist/assets/DaemonPanel-DBGMqaE_.js +0 -1
  272. package/ui/dist/assets/EvalPanel-Bc33j0pN.js +0 -1
  273. package/ui/dist/assets/FleetPanel-CSsXuQYj.js +0 -1
  274. package/ui/dist/assets/InfraView-CR6HyrL6.js +0 -2
  275. package/ui/dist/assets/InlineEditableField-CnvF-yFR.js +0 -1
  276. package/ui/dist/assets/Input-GTHp2Rkr.js +0 -1
  277. package/ui/dist/assets/IntegrationsPanel-CymCRE3T.js +0 -1
  278. package/ui/dist/assets/IntelligenceView-C1IHxJRC.js +0 -2
  279. package/ui/dist/assets/LearningPanel-DOCES3lH.js +0 -1
  280. package/ui/dist/assets/LogsPanel-BLnAqEaZ.js +0 -1
  281. package/ui/dist/assets/McpPanel-ChUzmr3z.js +0 -1
  282. package/ui/dist/assets/MemoryWikiPanel-Dwk3Aqwd.js +0 -11
  283. package/ui/dist/assets/NvidiaPanel-CeZK_-CV.js +0 -1
  284. package/ui/dist/assets/OrganismPanel-BB6YOiQV.js +0 -1
  285. package/ui/dist/assets/OverviewPanel-BmtBhQnv.js +0 -1
  286. package/ui/dist/assets/PaperclipPanel-C-brgwA3.js +0 -1
  287. package/ui/dist/assets/RecipesPanel-34lCfynJ.js +0 -1
  288. package/ui/dist/assets/SecurityPanel-CBTPWLj6.js +0 -1
  289. package/ui/dist/assets/SelfImprovePanel-BrPbFHhG.js +0 -1
  290. package/ui/dist/assets/SessionsPanel-DAEYIn83.js +0 -1
  291. package/ui/dist/assets/SettingsPanel-CzRROAYQ.js +0 -1
  292. package/ui/dist/assets/SettingsView-CN7ii2uw.js +0 -2
  293. package/ui/dist/assets/SomaView-Ba642Oqb.js +0 -5
  294. package/ui/dist/assets/TeamsPanel-DKQ5z2Qe.js +0 -1
  295. package/ui/dist/assets/TelemetryPanel-B6KAc55Q.js +0 -1
  296. package/ui/dist/assets/TitanCanvas-C-s0A-lv.js +0 -1092
  297. package/ui/dist/assets/ToolsView-Dei0KMP0.js +0 -2
  298. package/ui/dist/assets/TraceViewer-BniolyBx.js +0 -1
  299. package/ui/dist/assets/TrainingPanel-Bz4CTPGW.js +0 -1
  300. package/ui/dist/assets/VoiceOverlay-CmNCrLcd.js +0 -37
  301. package/ui/dist/assets/VramPanel-Xh_OtRDR.js +0 -1
  302. package/ui/dist/assets/WorkTab-BjLNmgIK.js +0 -1
@@ -0,0 +1,17 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/CommandPostHub-C9pp5Giq.js","assets/index-DzwowwSI.js","assets/index-BR0vfkIi.css","assets/Input-Bu_b3qmY.js","assets/loader-circle-1YOBsoQp.js","assets/Modal-CAAooiZU.js","assets/proxy-DxS2_9D7.js","assets/InlineEditableField-BMQjiE6-.js","assets/check-Bpm1IONe.js","assets/terminal-BtiqJ628.js","assets/Tooltip-BSO2XVpF.js","assets/approvalHeadline-DB9SgR-9.js","assets/chevron-right-aQEw2mUW.js","assets/wrench-CDz3xYve.js","assets/pause-CYhO_uQo.js","assets/dollar-sign-CudFVYFc.js","assets/git-branch-oHibJqDq.js","assets/chart-column-CdFlBpoP.js","assets/clock-CTsgP_Sn.js","assets/users-dZgv4ePG.js","assets/target-BRW80Xer.js","assets/briefcase-D4vLzudp.js","assets/send-TEpapzQR.js","assets/plus-Csu2v9GN.js","assets/trash-2-DgWrHVax.js","assets/CPIssues-DDEVKhX6.js","assets/StatusBadge-D5nU7El8.js","assets/PageHeader-CnZtP8ek.js","assets/EmptyState-jU6yNDnF.js","assets/Tabs-BBYZrBI8.js","assets/SkeletonLoader-B5v09EF_.js","assets/list-todo-Cnd4rdoK.js","assets/CPIssueDetail-DSdgNK8r.js","assets/arrow-left-5chqas7J.js","assets/CPAgents-j_7C-oQV.js","assets/CPAgentDetail-DsdShc-1.js","assets/circle-check-big-fPhEdP88.js","assets/save-Btx-kpoW.js","assets/CPApprovals-BShKSX9X.js","assets/shield-check-DjBJXZUr.js","assets/CPActivity-B12mt35m.js","assets/CPGoals-Bi3t1b2P.js","assets/chevron-down-D7OLjvuD.js","assets/CPRuns-ByioAz8w.js","assets/play-DVY9c5Ck.js","assets/CPCosts-CKPlhBDs.js","assets/CPOrg-Df73RrRJ.js","assets/network-DbGDAdrn.js"])))=>i.map(i=>d[i]);
2
+ import{c,k as _,r as a,j as e,d as j,A as b,L as i,l as p,m as f,n as y,o as s,N as v,_ as o}from"./index-DzwowwSI.js";import{M as g,U as P,F as E}from"./users-dZgv4ePG.js";import{T as C}from"./target-BRW80Xer.js";import{B as N}from"./briefcase-D4vLzudp.js";import{D as A}from"./dollar-sign-CudFVYFc.js";import{G as L}from"./git-branch-oHibJqDq.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 k=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],I=c("layout-dashboard",k);/**
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 z=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]],D=c("panel-left-close",z);/**
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 R=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]],T=c("panel-left",R),h=[{label:"Dashboard",path:"/command-post",icon:I},{label:"Issues",path:"/command-post/issues",icon:g},{label:"Approvals",path:"/command-post/approvals",icon:j},{label:"Agents",path:"/command-post/agents",icon:P},{label:"Goals",path:"/command-post/goals",icon:C},{label:"Work / Runs",path:"/command-post/runs",icon:N},{label:"Activity",path:"/command-post/activity",icon:b},{label:"Costs",path:"/command-post/costs",icon:A},{label:"Org Chart",path:"/command-post/org",icon:L},{label:"Files",path:"/command-post/files",icon:E}];function O(){const r=_(),[u,x]=a.useState(!1),d=t=>t==="/command-post"?r.pathname==="/command-post"||r.pathname==="/command-post/dashboard":r.pathname===t||r.pathname.startsWith(t+"/");return u?e.jsxs("div",{className:"flex flex-col h-full w-[48px] bg-bg-secondary border-r border-border flex-shrink-0",children:[e.jsx("div",{className:"flex items-center justify-center py-3 border-b border-border",children:e.jsx("button",{onClick:()=>x(!1),className:"p-1 rounded text-text-muted hover:text-text hover:bg-bg-tertiary transition-colors",title:"Expand sidebar",children:e.jsx(T,{size:16})})}),e.jsx("nav",{className:"flex-1 flex flex-col items-center gap-1 px-1 py-2",children:h.map(t=>{const n=d(t.path),l=t.icon;return e.jsx(i,{to:t.path,title:t.label,className:p("flex items-center justify-center w-9 h-9 rounded-lg transition-all",n?"bg-accent/15 text-accent":"text-text-secondary hover:text-text hover:bg-bg-tertiary"),children:e.jsx(l,{size:16})},t.path)})})]}):e.jsxs("div",{className:"flex flex-col h-full w-[200px] bg-bg-secondary border-r border-border flex-shrink-0",children:[e.jsxs("div",{className:"px-3 py-3 border-b border-border",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs(i,{to:"/",className:"flex items-center gap-1.5 text-xs text-text-muted hover:text-text transition-colors",children:[e.jsx(f,{size:14}),e.jsx("span",{children:"Back to Chat"})]}),e.jsx("button",{onClick:()=>x(!0),className:"p-1 rounded text-text-muted hover:text-text hover:bg-bg-tertiary transition-colors",title:"Collapse sidebar",children:e.jsx(D,{size:14})})]}),e.jsx("h2",{className:"text-sm font-semibold text-text px-1",children:"Command Post"})]}),e.jsx("nav",{className:"flex-1 overflow-y-auto px-2 py-2 space-y-0.5",children:h.map(t=>{const n=d(t.path),l=t.icon;return e.jsxs(i,{to:t.path,className:p("flex items-center gap-2.5 px-2.5 py-1.5 rounded-lg text-[13px] transition-all",n?"bg-accent/15 text-accent font-medium":"text-text-secondary hover:text-text hover:bg-bg-tertiary"),children:[e.jsx(l,{size:15,className:"flex-shrink-0"}),e.jsx("span",{className:"flex-1",children:t.label})]},t.path)})})]})}const m=a.lazy(()=>o(()=>import("./CommandPostHub-C9pp5Giq.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]))),w=a.lazy(()=>o(()=>import("./CPIssues-DDEVKhX6.js"),__vite__mapDeps([25,1,2,3,4,26,27,12,28,29,5,6,30,23,31]))),V=a.lazy(()=>o(()=>import("./CPIssueDetail-DSdgNK8r.js"),__vite__mapDeps([32,1,2,3,4,26,27,12,30,33,19,22]))),S=a.lazy(()=>o(()=>import("./CPAgents-j_7C-oQV.js"),__vite__mapDeps([34,1,2,3,4,26,27,12,28,30,19]))),M=a.lazy(()=>o(()=>import("./CPAgentDetail-DsdShc-1.js"),__vite__mapDeps([35,1,2,3,4,26,27,12,28,29,30,33,36,15,18,37]))),B=a.lazy(()=>o(()=>import("./CPApprovals-BShKSX9X.js"),__vite__mapDeps([38,1,2,3,4,26,27,12,28,29,30,11,39,8]))),G=a.lazy(()=>o(()=>import("./CPActivity-B12mt35m.js"),__vite__mapDeps([40,1,2,3,4,27,12,28,29,30,13,39,15,20]))),q=a.lazy(()=>o(()=>import("./CPGoals-Bi3t1b2P.js"),__vite__mapDeps([41,1,2,3,4,26,27,12,28,5,6,30,23,20,42,24]))),F=a.lazy(()=>o(()=>import("./CPRuns-ByioAz8w.js"),__vite__mapDeps([43,1,2,3,4,26,27,12,28,30,44]))),U=a.lazy(()=>o(()=>import("./CPCosts-CKPlhBDs.js"),__vite__mapDeps([45,1,2,3,4,26,27,12,28,5,6,30,23,15,24]))),W=a.lazy(()=>o(()=>import("./CPOrg-Df73RrRJ.js"),__vite__mapDeps([46,1,2,3,4,26,27,12,28,30,47,24])));function $(){return e.jsx("div",{className:"flex items-center justify-center h-full text-sm text-text-muted",children:"Loading..."})}function Z(){return e.jsxs("div",{className:"flex h-screen bg-bg",children:[e.jsx(O,{}),e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsx(a.Suspense,{fallback:e.jsx($,{}),children:e.jsxs(y,{children:[e.jsx(s,{index:!0,element:e.jsx(m,{})}),e.jsx(s,{path:"dashboard",element:e.jsx(m,{})}),e.jsx(s,{path:"issues",element:e.jsx(w,{})}),e.jsx(s,{path:"issues/:id",element:e.jsx(V,{})}),e.jsx(s,{path:"agents",element:e.jsx(S,{})}),e.jsx(s,{path:"agents/:id",element:e.jsx(M,{})}),e.jsx(s,{path:"approvals",element:e.jsx(B,{})}),e.jsx(s,{path:"activity",element:e.jsx(G,{})}),e.jsx(s,{path:"goals",element:e.jsx(q,{})}),e.jsx(s,{path:"runs",element:e.jsx(F,{})}),e.jsx(s,{path:"costs",element:e.jsx(U,{})}),e.jsx(s,{path:"org",element:e.jsx(W,{})}),e.jsx(s,{path:"*",element:e.jsx(v,{to:"/command-post",replace:!0})})]})})})]})}export{Z as CPLayout,Z as default};
@@ -0,0 +1,8 @@
1
+ import{r as i,y as u,K as b,j as e}from"./index-DzwowwSI.js";import"./Input-Bu_b3qmY.js";import{S as j}from"./StatusBadge-D5nU7El8.js";import{P as f}from"./PageHeader-CnZtP8ek.js";import{E as v}from"./EmptyState-jU6yNDnF.js";import{S as y}from"./SkeletonLoader-B5v09EF_.js";import{N}from"./network-DbGDAdrn.js";import{T as C}from"./trash-2-DgWrHVax.js";import"./loader-circle-1YOBsoQp.js";import"./chevron-right-aQEw2mUW.js";function w(t){const s=t.split("/");return s[s.length-1]}function x({node:t,depth:s,onDelete:o}){const l=t.role==="Company";return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-start gap-3 py-2",style:{paddingLeft:`${s*32+16}px`},children:[s>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 ${l?"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(j,{status:t.status,size:"sm"})]}),l&&o&&e.jsx("button",{onClick:a=>{a.stopPropagation(),o(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(C,{size:14})})]}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-text-muted",children:[l&&e.jsx("span",{className:"text-accent text-[9px] font-medium uppercase tracking-wider",children:"Company"}),!l&&e.jsx("span",{className:"capitalize",children:t.role}),t.title&&e.jsx("span",{children:t.title}),t.model&&e.jsx("span",{children:w(t.model)})]}),l&&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:`${(s+1)*32+16}px`,top:0,height:"100%"}}),t.reports.map(a=>e.jsx(x,{node:a,depth:s+1,onDelete:o},a.id))]})]})}function A(){const[t,s]=i.useState([]),[o,l]=i.useState(!0),[a,c]=i.useState(null),[p,m]=i.useState(null),n=i.useCallback(async()=>{try{const r=await u();s(r),c(null)}catch(r){c(r instanceof Error?r.message:"Failed to load org chart")}l(!1)},[]);i.useEffect(()=>{n()},[n]);const g=i.useCallback(async(r,h)=>{if(confirm(`Delete company "${h}"?
2
+
3
+ This will:
4
+ • Stop the heartbeat runner
5
+ • Archive all agents
6
+ • Archive all goals and issues
7
+
8
+ This cannot be undone.`)){m(r);try{await b(r),await n()}catch(d){alert(`Failed to delete: ${d instanceof Error?d.message:"Unknown error"}`)}m(null)}},[n]);return e.jsxs("div",{className:"space-y-4",children:[e.jsx(f,{title:"Organization Chart",breadcrumbs:[{label:"Command Post"},{label:"Org Chart"}]}),o&&e.jsx(y,{variant:"row",count:5}),a&&e.jsx("div",{className:"text-center py-8 text-error text-sm",children:a}),!o&&!a&&t.length===0&&e.jsx(v,{icon:e.jsx(N,{size:32}),title:"No org structure",description:"Register agents or create companies to see the org chart."}),!o&&!a&&t.length>0&&e.jsxs("div",{className:"rounded-xl border border-border bg-bg-secondary p-4 overflow-x-auto",children:[t.map(r=>e.jsx(x,{node:r,depth:0,onDelete:g},r.id)),p&&e.jsx("div",{className:"text-xs text-text-muted text-center py-2 animate-pulse",children:"Deleting..."})]})]})}export{A as default};
@@ -0,0 +1 @@
1
+ import{r as a,v as h,bm as f,j as e}from"./index-DzwowwSI.js";import"./Input-Bu_b3qmY.js";import{S as j}from"./StatusBadge-D5nU7El8.js";import{P as g}from"./PageHeader-CnZtP8ek.js";import{E as y}from"./EmptyState-jU6yNDnF.js";import{S as b}from"./SkeletonLoader-B5v09EF_.js";import{P as N}from"./play-DVY9c5Ck.js";import"./loader-circle-1YOBsoQp.js";import"./chevron-right-aQEw2mUW.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 D(){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{D as default};
@@ -1,4 +1,4 @@
1
- import{c as v,r as n,bi as A,bj as M,j as e,e as D,f as L,h as q,bk as _,bl as I,bm as O,bn as z}from"./index-CahJbWSR.js";import{R as b,S as G,C as H,M as F}from"./TitanCanvas-C-s0A-lv.js";import{L as B}from"./lightbulb-n8gc_XAL.js";import"./VoiceOverlay-CmNCrLcd.js";/**
1
+ import{c as v,r as n,bx as $,by as M,j as e,e as D,f as L,h as q,bz as _,bA as I,bB as z,bC as O}from"./index-DzwowwSI.js";import{R as b}from"./terminal-BtiqJ628.js";import{S as G}from"./send-TEpapzQR.js";import{L as H}from"./lightbulb-C54Ske-p.js";import{C as B}from"./clock-CTsgP_Sn.js";import{M as F}from"./users-dZgv4ePG.js";/**
2
2
  * @license lucide-react v0.513.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -8,4 +8,4 @@ import{c as v,r as n,bi as A,bj as M,j as e,e as D,f as L,h as q,bk as _,bl as I
8
8
  *
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
11
- */const V=[["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"}]],W=v("type",V);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 te(){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(U,{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(W,{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(B,{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(H,{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(F,{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{te as default};
11
+ */const V=[["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"}]],W=v("type",V);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 $();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 A=a.slice(0,3).map(R=>`"${R.content.split(/\s+/).slice(0,6).join(" ")}..."`).join(", ");m(`💡 Recent social posts: ${A}. 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 z(t),await o()}catch(a){i(a instanceof Error?a.message:"Approve failed")}finally{d(null)}},E=async t=>{d(t);try{await O(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(U,{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(W,{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(B,{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(F,{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};
@@ -0,0 +1 @@
1
+ import{r as a,j as e,e as $,aC as P,aD as D,aE as F}from"./index-DzwowwSI.js";import{P as R}from"./PageHeader-CnZtP8ek.js";import{R as O}from"./terminal-BtiqJ628.js";import{C as W}from"./circle-check-big-fPhEdP88.js";import{C as _}from"./chevron-down-D7OLjvuD.js";import{C as G}from"./chevron-right-aQEw2mUW.js";import{E as K}from"./eye-off-BmJF0YYx.js";import{E as I}from"./TitanCanvas-BCbWnLMd.js";import{S as H}from"./save-Btx-kpoW.js";import"./chevron-up-C5g6pEj8.js";import"./plus-Csu2v9GN.js";import"./users-dZgv4ePG.js";import"./wrench-CDz3xYve.js";import"./network-DbGDAdrn.js";import"./rotate-ccw-Co-_W04j.js";import"./search-0hXTwEZR.js";import"./send-TEpapzQR.js";import"./VoiceOverlay-D-gc58b0.js";import"./folder-DA43TRCm.js";import"./clock-CTsgP_Sn.js";import"./check-Bpm1IONe.js";import"./shield-check-DjBJXZUr.js";import"./external-link-BZ0y_Ahx.js";import"./loader-circle-1YOBsoQp.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 z({def:l,config:o,status:b,onSave:f,saving:v}){const[d,k]=a.useState(!1),[p,N]=a.useState(o.enabled),[x,i]=a.useState(""),[m,u]=a.useState(""),[g,w]=a.useState(o.dmPolicy),[y,t]=a.useState(!1),[n,h]=a.useState(!1),[r,c]=a.useState(!1),j=v===l.id,C=(b==null?void 0:b.status)==="connected",A=!!o.token,E=!!o.apiKey,M=()=>{N(!p),c(!0)},B=async()=>{const s={enabled:p,dmPolicy:g};x&&(s.token=x),m&&(s.apiKey=m),await f(l.id,s),i(""),u(""),c(!1)},S=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(_,{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:[C&&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 ${p?"bg-accent":"bg-border"}`,children:e.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${p?"translate-x-6":"translate-x-1"}`})})]}),S&&e.jsxs("div",{children:[e.jsxs("label",{className:"mb-1 flex items-center gap-2 text-xs text-text-muted",children:[S.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:x,onChange:s=>{i(s.target.value),c(!0)},placeholder:A?"(configured — enter new value to change)":S.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,E&&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),c(!0)},placeholder:E?"(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),c(!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 ge(){const[l,o]=a.useState([]),[b,f]=a.useState({}),[v,d]=a.useState(!0),[k,p]=a.useState(null),[N,x]=a.useState(null),[i,m]=a.useState(null),u=async()=>{try{const[t,n]=await Promise.all([P(),D()]);o(t),f(n)}catch(t){p(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;x(t);try{await F(t,n);const[r,c]=await Promise.all([P(),D()]);o(r),f(c);const j=((h=L.find(C=>C.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{x(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(R,{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(O,{className:"h-3.5 w-3.5"}),"Refresh"]})}),i&&e.jsxs("div",{className:`flex items-center gap-2 rounded-lg border px-4 py-2 text-sm ${i.type==="success"?"border-success/50 text-success":"border-error/50 text-error"}`,children:[i.type==="success"?e.jsx(W,{className:"h-4 w-4"}):e.jsx($,{className:"h-4 w-4"}),i.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(z,{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{ge as default};
@@ -0,0 +1 @@
1
+ import{r as a,b6 as l,j as e,b7 as d}from"./index-DzwowwSI.js";import{P as m}from"./PageHeader-CnZtP8ek.js";import{R as h}from"./terminal-BtiqJ628.js";import{S as x}from"./save-Btx-kpoW.js";import{T as p}from"./trash-2-DgWrHVax.js";import"./chevron-right-aQEw2mUW.js";function k(){const[c,n]=a.useState([]),[i,r]=a.useState(!0),t=a.useCallback(async()=>{r(!0);try{const s=await l();n(s.checkpoints||[])}catch{}r(!1)},[]);a.useEffect(()=>{t()},[t]);const o=async s=>{if(confirm("Delete this checkpoint?"))try{await d(s),await t()}catch{}};return e.jsxs("div",{className:"space-y-4",children:[e.jsx(m,{title:"Checkpoints",breadcrumbs:[{label:"Admin",href:"/overview"},{label:"System"},{label:"Checkpoints"}]}),e.jsx("div",{className:"flex gap-2",children:e.jsxs("button",{onClick:t,disabled:i,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(h,{className:`w-4 h-4 ${i?"animate-spin":""}`})," Refresh"]})}),e.jsx("div",{className:"space-y-2",children:c.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(x,{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:()=>o(s.sessionId),className:"p-1.5 rounded-md bg-[#27272a] text-[#a1a1aa] hover:bg-[#3f3f46] hover:text-red-400",children:e.jsx(p,{className:"w-3.5 h-3.5"})})]},s.sessionId))})]})}export{k as default};
@@ -0,0 +1,24 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WorkTab-CBoLNrTM.js","assets/index-DzwowwSI.js","assets/index-BR0vfkIi.css","assets/proxy-DxS2_9D7.js","assets/external-link-BZ0y_Ahx.js","assets/rotate-ccw-Co-_W04j.js","assets/plus-Csu2v9GN.js","assets/play-DVY9c5Ck.js","assets/trash-2-DgWrHVax.js","assets/pause-CYhO_uQo.js","assets/SessionsTab-Bk08wyeY.js","assets/CPInbox-Bbr7khp6.js","assets/Input-Bu_b3qmY.js","assets/loader-circle-1YOBsoQp.js","assets/PageHeader-CnZtP8ek.js","assets/chevron-right-aQEw2mUW.js","assets/EmptyState-jU6yNDnF.js","assets/Tabs-BBYZrBI8.js","assets/SkeletonLoader-B5v09EF_.js","assets/approvalHeadline-DB9SgR-9.js","assets/users-dZgv4ePG.js","assets/wrench-CDz3xYve.js","assets/clock-CTsgP_Sn.js","assets/send-TEpapzQR.js","assets/shield-check-DjBJXZUr.js","assets/check-Bpm1IONe.js","assets/funnel-J3mULzrz.js","assets/square-OweUvjP-.js","assets/chevron-up-C5g6pEj8.js","assets/chevron-down-D7OLjvuD.js","assets/CPFiles-BhLEOnXy.js","assets/folder-DA43TRCm.js","assets/search-0hXTwEZR.js","assets/terminal-BtiqJ628.js","assets/TraceViewer-BKI7o5B0.js","assets/trending-up-MpIrE4j6.js","assets/git-branch-oHibJqDq.js","assets/chart-column-CdFlBpoP.js","assets/arrow-left-5chqas7J.js","assets/CPSocial-Dlnr_w1X.js","assets/lightbulb-C54Ske-p.js","assets/CPDashboard-11c0nkxK.js","assets/StatusBadge-D5nU7El8.js","assets/list-todo-Cnd4rdoK.js","assets/dollar-sign-CudFVYFc.js","assets/target-BRW80Xer.js","assets/CPGoals-Bi3t1b2P.js","assets/Modal-CAAooiZU.js","assets/CPAgents-j_7C-oQV.js"])))=>i.map(i=>d[i]);
2
+ import{c as B,r as s,j as e,m as oe,f as E,h as M,A as I,T as G,v as ee,w as ce,x as ie,d as te,s as de,_ as A,b as V,y as xe,z as ue,B as me,D as pe,E as he,I as be,J as ge,K as je,O as ve,P as fe,Q as ye,U as $,V as Ne,Y as we,$ as Ce,a0 as ke,a1 as Se,a2 as ze}from"./index-DzwowwSI.js";import{B as Z}from"./Input-Bu_b3qmY.js";import{M as _}from"./Modal-CAAooiZU.js";import{I as D}from"./InlineEditableField-BMQjiE6-.js";import{H as Te}from"./Tooltip-BSO2XVpF.js";import{e as Ae}from"./approvalHeadline-DB9SgR-9.js";import{C as Y}from"./chevron-right-aQEw2mUW.js";import{B as De,W as se}from"./wrench-CDz3xYve.js";import{P as Pe}from"./pause-CYhO_uQo.js";import{D as K}from"./dollar-sign-CudFVYFc.js";import{G as ae}from"./git-branch-oHibJqDq.js";import{C as re}from"./chart-column-CdFlBpoP.js";import{C as ne}from"./clock-CTsgP_Sn.js";import{M as W,U as _e,F as $e}from"./users-dZgv4ePG.js";import{T as Ie}from"./target-BRW80Xer.js";import{B as L}from"./briefcase-D4vLzudp.js";import{T as Ee,R as Me}from"./terminal-BtiqJ628.js";import{S as Le}from"./send-TEpapzQR.js";import{P as O}from"./plus-Csu2v9GN.js";import{T as J}from"./trash-2-DgWrHVax.js";import"./loader-circle-1YOBsoQp.js";import"./proxy-DxS2_9D7.js";import"./check-Bpm1IONe.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 Re=[["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"}]],H=B("building-2",Re);/**
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 Be=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]],Oe=B("circle-stop",Be);/**
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 Fe=[["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"}]],Ue=B("mail",Fe);/**
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 Ve=[["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"}]],le=B("scale",Ve);function Q({open:t,title:d,message:n,confirmLabel:b="Confirm",cancelLabel:o="Cancel",variant:f="danger",onConfirm:m,onCancel:c}){const[g,p]=s.useState(!1),a=async()=>{p(!0);try{await m()}finally{p(!1)}};return e.jsx(_,{open:t,onClose:()=>!g&&c(),title:d,size:"sm",footer:e.jsxs(e.Fragment,{children:[e.jsx(Z,{variant:"ghost",size:"sm",onClick:c,disabled:g,children:o}),e.jsx(Z,{variant:f==="danger"?"danger":"primary",size:"sm",onClick:a,loading:g,children:b})]}),children:e.jsx("div",{className:"text-sm text-text-secondary leading-relaxed",children:n})})}function We(t){switch(t){case"active":return e.jsx(I,{size:12,className:"text-success animate-pulse"});case"paused":return e.jsx(Pe,{size:12,className:"text-warning"});case"error":return e.jsx(G,{size:12,className:"text-error"});default:return e.jsx(De,{size:12,className:"text-text-muted"})}}function He(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 qe({agents:t,runs:d,collapsed:n=!1,onToggle:b,onAgentClick:o}){const[f,m]=s.useState(null);return n?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:b,className:"p-1.5 rounded hover:bg-bg-tertiary text-text-muted",children:e.jsx(oe,{size:14})}),t.map(c=>e.jsxs("button",{className:"relative",title:c.name,onClick:()=>o==null?void 0:o(c),children:[e.jsx("div",{className:`w-6 h-6 rounded-full flex items-center justify-center text-[9px] font-bold ${c.status==="error"?"bg-error/20 text-error":c.status==="active"?"bg-success/20 text-success":"bg-bg-tertiary text-text-muted"}`,children:c.name.charAt(0).toUpperCase()}),c.status==="active"&&e.jsx("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-success animate-pulse"})]},c.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:b,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted",children:e.jsx(Y,{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(c=>{var y;const g=f===c.id,p=d.filter(j=>j.agentId===c.id),a=p[0],i=p.filter(j=>j.status==="failed"||j.status==="error").length;return e.jsxs("div",{className:`rounded-lg border p-2 cursor-pointer transition-colors ${He(c.status)}`,onClick:j=>{j.target.closest(".expand-toggle")?m(g?null:c.id):o==null||o(c)},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 ${c.status==="error"?"bg-error/20 text-error":c.status==="active"?"bg-success/20 text-success":"bg-bg-tertiary text-text-muted"}`,children:c.name.charAt(0).toUpperCase()}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-xs font-medium truncate",children:c.name}),e.jsxs("div",{className:"text-[10px] text-text-muted flex items-center gap-1",children:[We(c.status),e.jsx("span",{className:"capitalize",children:c.status}),c.model&&e.jsxs("span",{className:"truncate",children:["· ",c.model.split("/").pop()]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[c.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:j=>{j.stopPropagation(),m(g?null:c.id)},children:e.jsx(Y,{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: ",c.role||"general"]}),e.jsxs("div",{children:["Tasks: ",c.totalTasksCompleted??0," completed"]}),c.totalCostUsd!==void 0&&e.jsxs("div",{children:["Cost: $",c.totalCostUsd.toFixed(2)]}),i>0&&e.jsxs("div",{className:"text-error",children:[i," failed run",i===1?"":"s"]})]}),a&&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:[a.status==="succeeded"?e.jsx(E,{size:10,className:"text-success"}):a.status==="failed"||a.status==="error"?e.jsx(M,{size:10,className:"text-error"}):e.jsx(I,{size:10,className:"text-cyan animate-pulse"}),"Latest run"]}),e.jsxs("div",{className:a.status==="failed"||a.status==="error"?"text-error":"text-success",children:[a.status," · ",((y=a.toolsUsed)==null?void 0:y.length)??0," tools"]}),a.error&&e.jsx("div",{className:"text-error truncate mt-0.5",children:a.error})]})]})]},c.id)})]})]})}function X(t){const d={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 d[t]||d.idle}function U(t){const d=Math.floor((Date.now()-new Date(t).getTime())/1e3);return d<60?`${d}s`:d<3600?`${Math.floor(d/60)}m`:d<86400?`${Math.floor(d/3600)}h`:`${Math.floor(d/86400)}d`}function Ge({agent:t,onClose:d}){const[n,b]=s.useState([]),[o,f]=s.useState([]),[m,c]=s.useState(!0),[g,p]=s.useState(null),a=s.useCallback(async()=>{try{const[l,u]=await Promise.all([ee(t.id,10),ce(20,void 0)]);b(l),f(u.traces||[])}catch{}c(!1)},[t.id]);s.useEffect(()=>{a();const l=setInterval(a,1e4);return()=>clearInterval(l)},[a]);const i=n[0],y=n.filter(l=>l.status==="failed"||l.status==="error"),j=n.reduce((l,u)=>l+u.toolsUsed.length,0);return e.jsx(_,{open:!0,onClose:d,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 ${X(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 ${X(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 ",U(t.lastHeartbeat)," ago"]})]})]}),e.jsx("div",{className:"grid grid-cols-4 gap-2",children:[{icon:E,label:"Tasks",value:t.totalTasksCompleted,color:"text-success"},{icon:K,label:"Cost",value:`$${t.totalCostUsd.toFixed(2)}`,color:"text-warning"},{icon:se,label:"Tools",value:j,color:"text-accent"},{icon:M,label:"Failed",value:y.length,color:y.length>0?"text-error":"text-text-muted"}].map(l=>e.jsxs("div",{className:"bg-bg-secondary border border-border rounded-lg p-2.5 text-center",children:[e.jsx(l.icon,{size:14,className:`mx-auto mb-1 ${l.color}`}),e.jsx("div",{className:"text-sm font-bold text-text",children:l.value}),e.jsx("div",{className:"text-[9px] text-text-muted uppercase tracking-wider",children:l.label})]},l.label))}),t.status==="active"&&i&&i.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(I,{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 ",U(i.startedAt)," ago · ",i.toolsUsed.length," tools used so far"]})]}),t.status==="error"&&(i==null?void 0:i.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(G,{size:12}),e.jsx("span",{className:"font-medium",children:"Last error"})]}),e.jsx("div",{className:"text-[11px] text-text-secondary font-mono",children:i.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(ae,{size:12,className:"text-accent"}),"Recent Runs"]}),e.jsxs("span",{className:"text-[10px] text-text-muted",children:[n.length," total"]})]}),m?e.jsx("div",{className:"space-y-1.5",children:[1,2,3].map(l=>e.jsx("div",{className:"h-10 rounded-lg bg-bg-secondary animate-pulse"},l))}):n.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:n.map(l=>e.jsxs("div",{className:"flex items-center gap-2 px-2.5 py-2 rounded-lg bg-bg-secondary border border-border",children:[l.status==="succeeded"?e.jsx(E,{size:12,className:"text-success shrink-0"}):l.status==="failed"||l.status==="error"?e.jsx(M,{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:[l.source," · ",l.toolsUsed.length," tools"]}),e.jsxs("div",{className:"text-[10px] text-text-muted",children:[l.durationMs?`${l.durationMs}ms`:"..."," · ",U(l.startedAt)," ago"]})]}),l.error&&e.jsx("span",{className:"text-[10px] text-error truncate max-w-[120px]",title:l.error,children:l.error})]},l.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(re,{size:12,className:"text-accent"}),"Recent Traces"]}),e.jsxs("span",{className:"text-[10px] text-text-muted",children:[o.length," loaded"]})]}),o.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:o.slice(0,10).map(l=>e.jsxs("button",{onClick:()=>p(l),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:[l.status==="running"?e.jsx(I,{size:12,className:"text-cyan animate-pulse shrink-0"}):l.status==="completed"?e.jsx(E,{size:12,className:"text-success shrink-0"}):e.jsx(M,{size:12,className:"text-error shrink-0"}),e.jsx("span",{className:"text-[11px] text-text-secondary truncate flex-1",children:l.message}),e.jsx("span",{className:"text-[10px] text-text-muted shrink-0",children:l.totalMs?`${l.totalMs}ms`:"..."})]}),e.jsxs("div",{className:"flex gap-2 mt-0.5 text-[10px] text-text-muted ml-5",children:[e.jsxs("span",{children:[l.toolCalls.length," tools"]}),e.jsxs("span",{children:[l.rounds," rounds"]}),l.error&&e.jsx("span",{className:"text-error truncate",children:l.error})]})]},l.traceId))})]}),g&&e.jsx(Je,{trace:g,onClose:()=>p(null)})]})})}function Ke({size:t,className:d}){return e.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",className:`animate-spin ${d||""}`,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 Je({trace:t,onClose:d}){return e.jsx(_,{open:!0,onClose:d,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((n,b)=>e.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx(ne,{size:10,className:"text-text-muted shrink-0"}),e.jsx("span",{className:"text-text-secondary font-mono",children:n.name}),e.jsxs("span",{className:"text-text-muted",children:[n.durationMs,"ms"]})]},b))})]}),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((n,b)=>e.jsxs("div",{className:"flex items-center gap-2 text-[11px]",children:[e.jsx(se,{size:10,className:n.success?"text-success":"text-error"}),e.jsx("span",{className:"text-text-secondary font-mono",children:n.tool}),e.jsxs("span",{className:"text-text-muted",children:[n.durationMs,"ms"]}),e.jsxs("span",{className:"text-text-muted",children:["round ",n.round]})]},b))})]}),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 T({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 R(t){const d=Math.floor((Date.now()-new Date(t).getTime())/1e3);return d<60?`${d}s`:d<3600?`${Math.floor(d/60)}m`:d<86400?`${Math.floor(d/3600)}h`:`${Math.floor(d/86400)}d`}function q({status:t}){const d={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"},n=t||"unknown";return e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-medium ${d[n]||"bg-bg-tertiary text-text-muted"}`,children:n.replace("_"," ")})}function P({icon:t,title:d,count:n,action:b,help:o}){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:d}),n!==void 0&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-accent/10 text-accent-light",children:n}),o&&e.jsx(Te,{title:o.title,description:o.description})]}),b]})}function Qe({agents:t}){const[d,n]=s.useState([]),[b,o]=s.useState([]),[f,m]=s.useState(!1),[c,g]=s.useState(""),[p,a]=s.useState(""),[i,y]=s.useState(null),j=s.useCallback(()=>{xe().then(n).catch(()=>{}),ue().then(x=>o(x)).catch(()=>{})},[]);s.useEffect(()=>{j()},[j]);const l=async()=>{c.trim()&&(await be({name:c.trim(),mission:p.trim()||void 0}),g(""),a(""),m(!1),j())},u=async(x,h,w)=>{try{await ge(x,{[h]:w}),j()}catch(z){alert(`Save failed: ${z.message}`)}},r=async()=>{i&&(await je(i.id),y(null),j())},N=async(x,h,w)=>{try{await Se(x,{[h]:w||void 0}),j()}catch(z){alert(`Save failed: ${z.message}`)}},k=["ceo","manager","engineer","researcher","general"];function v(x,h=0){var z;const w=((z=t.find(C=>C.id===x.id))==null?void 0:z.reportsTo)||"";return x.model&&x.model.split("/").pop(),e.jsxs("div",{className:h>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(D,{value:x.name,onSave:C=>N(x.id,"name",C),placeholder:"Agent name"})}),e.jsx(q,{status:x.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(D,{value:x.title||"",onSave:C=>N(x.id,"title",C),placeholder:"Add a title",emptyLabel:"—"})}),e.jsx("span",{className:"text-text-muted",children:"Role"}),e.jsx("select",{value:x.role,onChange:C=>N(x.id,"role",C.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:k.map(C=>e.jsx("option",{value:C,children:C},C))}),e.jsx("span",{className:"text-text-muted",children:"Reports to"}),e.jsxs("select",{value:w,onChange:C=>N(x.id,"reportsTo",C.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(C=>C.id!==x.id).map(C=>e.jsx("option",{value:C.id,children:C.name},C.id))]}),e.jsx("span",{className:"text-text-muted",children:"Model"}),e.jsx("span",{className:"text-text-secondary min-w-0",children:e.jsx(D,{value:x.model||"",onSave:C=>N(x.id,"model",C),placeholder:"e.g. ollama/qwen3.5:cloud",emptyLabel:"—"})})]})]}),x.reports.map(C=>v(C,h+1))]},x.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(P,{icon:H,title:"Organization Chart",count:t.length}),e.jsx("div",{className:"p-4",children:d.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(H,{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.'})]}):d.map(x=>v(x))})]}),e.jsxs("div",{className:"bg-bg-secondary/50 border border-border rounded-2xl overflow-hidden",children:[e.jsx(P,{icon:L,title:"Companies",count:b.length,action:e.jsxs("button",{onClick:()=>m(!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(O,{size:10})," New"]})}),f&&e.jsxs("div",{className:"p-4 border-b border-border bg-bg-secondary/30 space-y-2",children:[e.jsx("input",{value:c,onChange:x=>g(x.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:x=>x.key==="Enter"&&l()}),e.jsx("input",{value:p,onChange:x=>a(x.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:l,className:"px-3 py-1.5 text-[11px] bg-accent text-text rounded-lg",children:"Create"}),e.jsx("button",{onClick:()=>m(!1),className:"px-3 py-1.5 text-[11px] text-text-muted",children:"Cancel"})]})]}),e.jsx("div",{className:"divide-y divide-border/30",children:b.length===0?e.jsx("div",{className:"py-6 text-center text-[12px] text-text-muted",children:'No companies yet — click "+ New" to create one.'}):b.map(x=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 hover:bg-bg-secondary/30 transition-colors",children:[e.jsx(L,{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(D,{value:x.name,onSave:h=>u(x.id,"name",h),placeholder:"Company name"})}),e.jsx("div",{className:"text-[10px] text-text-muted",children:e.jsx(D,{value:x.mission||"",onSave:h=>u(x.id,"mission",h),placeholder:"Add a mission",emptyLabel:"(no mission — click to add)"})})]}),e.jsx(q,{status:x.status||"active"}),e.jsx("button",{onClick:()=>y({id:x.id,name:x.name}),className:"p-1 rounded text-text-muted hover:text-error hover:bg-error/10 transition-colors",title:"Delete company",children:e.jsx(J,{size:12})})]},x.id))})]}),e.jsx(Q,{open:!!i,title:`Delete company "${(i==null?void 0:i.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:r,onCancel:()=>y(null)})]})}function Ze({agents:t}){const[d,n]=s.useState([]),[b,o]=s.useState(""),[f,m]=s.useState(!1),[c,g]=s.useState(""),[p,a]=s.useState("medium"),[i,y]=s.useState(null),[j,l]=s.useState(null),u=s.useCallback(()=>{pe(b?{status:b}:void 0).then(n).catch(()=>{})},[b]);s.useEffect(()=>{u()},[u]);const r=async()=>{c.trim()&&(await ye({title:c,priority:p}),g(""),m(!1),u())},N=async(h,w)=>{await $(h,{status:w}),u()},k=async(h,w)=>{await $(h,{assigneeAgentId:w||void 0}),u()},v=async()=>{j&&(await we(j),l(null),i===j&&y(null),u())},x=["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:()=>o(""),className:`px-2.5 py-1 text-[10px] rounded-lg transition-colors ${b?"bg-bg-tertiary text-text-muted hover:text-text-secondary":"bg-accent text-text"}`,children:"All"}),x.map(h=>e.jsx("button",{onClick:()=>o(h),className:`px-2.5 py-1 text-[10px] rounded-lg transition-colors ${b===h?"bg-accent text-text":"bg-bg-tertiary text-text-muted hover:text-text-secondary"}`,children:h.replace("_"," ")},h))]}),e.jsxs("button",{onClick:()=>m(!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(O,{size:12})," New Issue"]})]}),f&&e.jsxs("div",{className:"bg-bg-tertiary/30 border border-border rounded-xl p-4 space-y-3",children:[e.jsx("input",{value:c,onChange:h=>g(h.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:h=>h.key==="Enter"&&r()}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("select",{value:p,onChange:h=>a(h.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:r,className:"px-3 py-1.5 text-[11px] bg-accent text-text rounded-lg",children:"Create"}),e.jsx("button",{onClick:()=>m(!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(P,{icon:L,title:"Issues",count:d.length}),e.jsx("div",{className:"divide-y divide-border/30",children:d.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.'}):d.map(h=>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:h.identifier}),e.jsx(q,{status:h.priority||"medium"}),e.jsx("button",{onClick:()=>y(h.id),className:"text-[12px] text-text-secondary flex-1 truncate text-left hover:text-text transition-colors",title:"Open details",children:h.title}),e.jsxs("select",{value:h.assigneeAgentId||"",onChange:w=>k(h.id,w.target.value),onClick:w=>w.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(w=>e.jsx("option",{value:w.id,children:w.name},w.id))]}),e.jsxs("select",{value:h.status,onChange:w=>N(h.id,w.target.value),onClick:w=>w.stopPropagation(),className:"bg-bg-tertiary border border-border rounded px-1.5 py-0.5 text-[10px] text-text-secondary focus:outline-none",children:[x.map(w=>e.jsx("option",{value:w,children:w.replace("_"," ")},w)),e.jsx("option",{value:"cancelled",children:"cancelled"})]}),e.jsx("button",{onClick:()=>l(h.id),className:"p-1 rounded text-text-muted hover:text-error hover:bg-error/10 transition-colors",title:"Delete issue",children:e.jsx(J,{size:12})})]},h.id))})]}),i&&e.jsx(Ye,{issueId:i,agents:t,onClose:()=>{y(null),u()},onRequestDelete:()=>l(i)}),e.jsx(Q,{open:!!j,title:"Delete this issue?",message:"This can't be undone. The issue and all its comments will be removed.",confirmLabel:"Delete",onConfirm:v,onCancel:()=>l(null)})]})}function Ye({issueId:t,agents:d,onClose:n,onRequestDelete:b}){var u;const[o,f]=s.useState(null),[m,c]=s.useState(""),[g,p]=s.useState(!1),a=s.useCallback(async()=>{try{const r=await Ne(t);f(r)}catch{}},[t]);s.useEffect(()=>{a()},[a]);const i=async(r,N)=>{await $(t,{[r]:N}),a()},y=async r=>{await $(t,{priority:r}),a()},j=async r=>{await $(t,{assigneeAgentId:r||void 0}),a()},l=async()=>{if(m.trim()){p(!0);try{await ze(t,m.trim(),{user:"board"}),c(""),a()}finally{p(!1)}}};return e.jsx(_,{open:!0,onClose:n,size:"lg",title:o?`${o.identifier}`:"Loading…",children:o?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(D,{value:o.title,onSave:r=>i("title",r),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(D,{value:o.description||"",onSave:r=>i("description",r),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:o.priority||"medium",onChange:r=>y(r.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:o.assigneeAgentId||"",onChange:r=>j(r.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"}),d.map(r=>e.jsx("option",{value:r.id,children:r.name},r.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:o.status.replace(/_/g," ")})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-[10px] uppercase tracking-wider text-text-muted/70 mb-2",children:["Comments (",((u=o.comments)==null?void 0:u.length)||0,")"]}),e.jsx("div",{className:"space-y-2 max-h-[240px] overflow-y-auto pr-1",children:(o.comments||[]).length===0?e.jsx("div",{className:"text-[11px] text-text-muted italic",children:"No comments yet."}):o.comments.map(r=>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:r.authorAgentId||r.authorUser||"unknown"}),e.jsx("span",{children:"·"}),e.jsxs("span",{children:[R(r.createdAt)," ago"]})]}),e.jsx("div",{className:"text-[12px] text-text whitespace-pre-wrap",children:r.body})]},r.id))}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx("input",{value:m,onChange:r=>c(r.target.value),onKeyDown:r=>{r.key==="Enter"&&!r.shiftKey&&(r.preventDefault(),l())},placeholder:"Add a comment — Enter to post",disabled:g,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:l,disabled:g||!m.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 ",R(o.createdAt)," ago"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:b,className:"px-3 py-1.5 text-[11px] text-error hover:bg-error/10 rounded",children:"Delete issue"}),e.jsx("button",{onClick:n,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 Xe({budgets:t,onRefresh:d}){const[n,b]=s.useState(null),[o,f]=s.useState(!1),[m,c]=s.useState(null),g=async()=>{m&&(await he(m.id),c(null),d())};return e.jsxs("div",{className:"bg-bg-secondary/50 border border-border rounded-2xl overflow-hidden",children:[e.jsx(P,{icon:K,title:"Budget Policies",count:t.length,action:e.jsxs("button",{onClick:()=>f(!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(O,{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(p=>{const a=p.limitUsd>0?Math.min(100,p.currentSpend/p.limitUsd*100):0,i=a>=100?"bg-error":a>=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:p.name}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] text-text-muted capitalize",children:p.scope.type}),e.jsx("span",{className:"text-[10px] text-text-muted",children:p.period}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded ${p.enabled?"text-success bg-success/10":"text-text-muted bg-bg-tertiary"}`,children:p.enabled?"on":"off"}),e.jsx("button",{onClick:()=>b(p),className:"text-[10px] text-text-muted hover:text-text-secondary px-1",title:"Edit budget",children:"Edit"}),e.jsx("button",{onClick:()=>c(p),className:"p-1 rounded text-text-muted hover:text-error hover:bg-error/10 transition-colors",title:"Delete budget",children:e.jsx(J,{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 ${i} rounded-full transition-all`,style:{width:`${a}%`}})}),e.jsxs("div",{className:"flex justify-between text-[10px] text-text-muted",children:[e.jsxs("span",{children:["$",p.currentSpend.toFixed(2)," spent"]}),e.jsxs("span",{children:["$",p.limitUsd.toFixed(2)," limit · action: ",p.action]})]})]},p.id)})}),(o||n)&&e.jsx(et,{existing:n,onClose:()=>{f(!1),b(null)},onSaved:()=>{f(!1),b(null),d()}}),e.jsx(Q,{open:!!m,title:`Delete budget "${(m==null?void 0:m.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:g,onCancel:()=>c(null)})]})}function et({existing:t,onClose:d,onSaved:n}){var z,C;const b=!!t,[o,f]=s.useState((t==null?void 0:t.name)||""),[m,c]=s.useState((t==null?void 0:t.scope.type)||"global"),[g,p]=s.useState((t==null?void 0:t.scope.targetId)||""),[a,i]=s.useState((t==null?void 0:t.period)||"daily"),[y,j]=s.useState(((z=t==null?void 0:t.limitUsd)==null?void 0:z.toString())||"10"),[l,u]=s.useState(((C=t==null?void 0:t.warningThresholdPercent)==null?void 0:C.toString())||"80"),[r,N]=s.useState((t==null?void 0:t.action)||"warn"),[k,v]=s.useState((t==null?void 0:t.enabled)??!0),[x,h]=s.useState(!1),w=async()=>{if(o.trim()){h(!0);try{const S={name:o.trim(),scope:{type:m,targetId:m==="global"?void 0:g||void 0},period:a,limitUsd:Number(y)||0,warningThresholdPercent:Number(l)||80,action:r,enabled:k};b&&t?await Ce(t.id,S):await ke(S),n()}catch(S){alert(`Save failed: ${S.message}`)}finally{h(!1)}}};return e.jsx(_,{open:!0,onClose:d,size:"md",title:b?"Edit Budget Policy":"New Budget Policy",footer:e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:d,className:"px-3 py-1.5 text-[11px] text-text-secondary hover:text-text",children:"Cancel"}),e.jsx("button",{onClick:w,disabled:x||!o.trim(),className:"px-3 py-1.5 text-[11px] bg-accent text-text rounded hover:bg-accent-hover disabled:opacity-50",children:x?"Saving…":b?"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:o,onChange:S=>f(S.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:m,onChange:S=>c(S.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:g,onChange:S=>p(S.target.value),placeholder:m==="global"?"n/a":m==="agent"?"agent-id":"goal-id",disabled:m==="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:a,onChange:S=>i(S.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:y,onChange:S=>j(S.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:l,onChange:S=>u(S.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:r,onChange:S=>N(S.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:k,onChange:S=>v(S.target.checked),className:"accent-accent"}),e.jsx("span",{children:"Enabled"})]})})]})]})})}function tt({dashboard:t}){const[d,n]=s.useState([]),[b,o]=s.useState(""),[f,m]=s.useState(!1),[c,g]=s.useState(""),[p,a]=s.useState(),i=s.useRef(null),y=s.useRef(null),j=s.useCallback(()=>{var N;const u=t,r=u.agents.map(k=>`${k.name} (${k.status}, ${k.role}, cost=$${k.totalCostUsd.toFixed(2)})`).join("; ")||"none";return`[COMMAND POST] ${u.totalAgents} agents (${u.activeAgents} active), ${u.activeCheckouts} locked tasks, budget ${Math.round(u.budgetUtilization??0)}% used, ${((N=u.goalTree)==null?void 0:N.length)??0} goals. Agents: ${r}. You manage this agent organization. Be concise.
23
+
24
+ `},[t]),l=s.useCallback(async()=>{const u=b.trim();if(!u||f)return;o(""),n(v=>[...v,{role:"user",content:u}]),m(!0),g("");const r=new AbortController;i.current=r;let N="",k=p;try{await de(j()+u,p,v=>{v.type==="token"&&(N+=v.data,g(N)),v.type==="done"&&v.sessionId&&(k=v.sessionId)},r.signal),k&&a(k),N&&n(v=>[...v,{role:"assistant",content:N}])}catch(v){v.name!=="AbortError"&&n(x=>[...x,{role:"assistant",content:`Error: ${v.message}`}])}finally{m(!1),g(""),i.current=null}},[b,f,p,j]);return s.useEffect(()=>{y.current&&(y.current.scrollTop=y.current.scrollHeight)},[d,c]),e.jsxs("div",{className:"bg-bg-secondary/50 border border-border rounded-2xl overflow-hidden flex flex-col",style:{height:400},children:[e.jsx(P,{icon:W,title:"Console",action:f?e.jsxs("button",{onClick:()=>{var u;return(u=i.current)==null?void 0:u.abort()},className:"text-[10px] text-error flex items-center gap-1",children:[e.jsx(Oe,{size:12}),"Stop"]}):void 0}),e.jsxs("div",{ref:y,className:"flex-1 overflow-y-auto px-4 py-3 space-y-2",children:[d.length===0&&!f&&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(u=>e.jsx("button",{onClick:()=>o(u),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:u},u))})]}),d.map((u,r)=>e.jsx("div",{className:`flex ${u.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 ${u.role==="user"?"bg-accent/80 text-text rounded-br-sm":"bg-bg-tertiary text-text-secondary border border-border rounded-bl-sm"}`,children:u.content})},r)),f&&c&&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:[c,e.jsx("span",{className:"inline-block w-1 h-3.5 bg-accent-light ml-0.5 animate-pulse"})]})}),f&&!c&&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:b,onChange:u=>o(u.target.value),onKeyDown:u=>{u.key==="Enter"&&(u.preventDefault(),l())},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:l,disabled:!b.trim()||f,className:"p-2 rounded-lg bg-accent text-text hover:bg-accent-hover disabled:opacity-30",children:e.jsx(Le,{size:14})})]})})]})}function st({onClose:t,onCreated:d}){const[n,b]=s.useState(""),[o,f]=s.useState([{role:"pragmatist",model:""},{role:"skeptic",model:""}]),[m,c]=s.useState(2),[g,p]=s.useState("judge"),[a,i]=s.useState(!1),y=()=>{o.length>=5||f([...o,{role:`participant-${o.length+1}`,model:""}])},j=r=>{o.length<=2||f(o.filter((N,k)=>k!==r))},l=(r,N)=>{f(o.map((k,v)=>v===r?{...k,...N}:k))},u=async()=>{if(!(!n.trim()||o.length<2)){i(!0);try{const r=await V("/api/command-post/debates",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({question:n.trim(),participants:o.map(N=>({role:N.role.trim()||"participant",model:N.model.trim()||void 0})),rounds:m,resolution:g})});if(!r.ok)throw new Error(`${r.status} ${r.statusText}`);d()}catch(r){alert(`Debate failed: ${r.message}`)}finally{i(!1)}}};return e.jsx(_,{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:u,disabled:a||!n.trim()||o.length<2,className:"px-3 py-1.5 text-[11px] bg-accent text-text rounded hover:bg-accent-hover disabled:opacity-50",children:a?"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:n,onChange:r=>b(r.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 (",o.length,"/5)"]}),e.jsx("button",{onClick:y,disabled:o.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:o.map((r,N)=>e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx("input",{value:r.role,onChange:k=>l(N,{role:k.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:r.model,onChange:k=>l(N,{model:k.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:()=>j(N),disabled:o.length<=2,className:"text-text-muted hover:text-error disabled:opacity-20 px-1",title:"Remove",children:"×"})]},N))})]}),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:m,onChange:r=>c(Number(r.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(r=>e.jsxs("option",{value:r,children:[r," round",r===1?"":"s"]},r))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] uppercase tracking-wider text-text-muted",children:"Resolution"}),e.jsxs("select",{value:g,onChange:r=>p(r.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 at(){const[t,d]=s.useState([]),[n,b]=s.useState("pending"),[o,f]=s.useState(!1),m=s.useCallback(async()=>{f(!0);try{const a=await me(n==="all"?void 0:n);d(a)}catch{}f(!1)},[n]);s.useEffect(()=>{m()},[m]);const c=async a=>{try{await ve(a,"board")}catch{}m()},g=async a=>{try{await fe(a,"board")}catch{}m()},p=t.filter(a=>n==="all"?!0:a.status===n);return e.jsxs("div",{className:"bg-bg-secondary/50 border border-border rounded-2xl overflow-hidden",children:[e.jsx(P,{icon:te,title:"Approvals",count:p.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(a=>e.jsx("button",{onClick:()=>b(a),className:`px-2 py-0.5 text-[10px] rounded-md transition-colors ${n===a?"bg-accent text-text":"bg-bg-tertiary text-text-muted hover:text-text"}`,children:a},a))})}),e.jsx("div",{className:"divide-y divide-border/30",children:o?e.jsx("div",{className:"py-8 text-center text-[12px] text-text-muted",children:"Loading..."}):p.length===0?e.jsxs("div",{className:"py-8 text-center text-[12px] text-text-muted",children:["No ",n," approvals."]}):p.map(a=>{var i;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:a.type.replace(/_/g," ")}),e.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded-full ${a.status==="pending"?"bg-warning/10 text-warning":a.status==="approved"?"bg-success/10 text-success":"bg-error/10 text-error"}`,children:a.status})]}),e.jsx("div",{className:"text-[10px] text-text-muted mb-2 truncate",children:(i=Ae(a))==null?void 0:i.headline}),a.status==="pending"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>c(a.id),className:"px-2 py-0.5 text-[10px] bg-success text-text rounded hover:bg-success/80",children:"Approve"}),e.jsx("button",{onClick:()=>g(a.id),className:"px-2 py-0.5 text-[10px] bg-error text-text rounded hover:bg-error/80",children:"Reject"})]}),a.decidedBy&&e.jsxs("div",{className:"text-[10px] text-text-muted mt-1",children:["By ",a.decidedBy," ",a.decidedAt?R(a.decidedAt)+" ago":""]})]},a.id)})})]})}function rt(){const[t,d]=s.useState([]),[n,b]=s.useState(null),[o,f]=s.useState(!1),[m,c]=s.useState(!1),g=s.useCallback(async()=>{f(!0);try{const a=await V("/api/command-post/debates");if(a.ok){const i=await a.json();d((i==null?void 0:i.items)||[])}}catch{}f(!1)},[]);s.useEffect(()=>{g()},[g]);const p=async a=>{try{const i=await V(`/api/command-post/debates/${a}`);if(i.ok){const y=await i.json();b(y)}}catch{}};if(n){const a=new Map;for(const i of n.turns){const y=a.get(i.round)||[];y.push(i),a.set(i.round,y)}return e.jsxs("div",{className:"space-y-3",children:[e.jsx("button",{onClick:()=>b(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:n.question}),e.jsxs("div",{className:"text-[10px] text-text-muted/70",children:[n.resolution," • ",n.rounds," round",n.rounds===1?"":"s"," • ",(n.durationMs/1e3).toFixed(1),"s"]}),n.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: ",n.winner.role]}),e.jsx("div",{className:"text-[12px] text-text mt-1",children:n.winner.content}),n.winner.justification&&e.jsx("div",{className:"text-[10px] text-text-muted italic mt-2",children:n.winner.justification})]})]}),[...a.entries()].sort((i,y)=>i[0]-y[0]).map(([i,y])=>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 ",i]}),e.jsx("div",{className:"divide-y divide-border/30",children:y.map((j,l)=>e.jsxs("div",{className:"px-4 py-3",children:[e.jsx("div",{className:"text-[11px] font-semibold text-accent-light/80 mb-1",children:j.role}),e.jsx("div",{className:"text-[11px] text-text-secondary whitespace-pre-wrap",children:j.content}),e.jsxs("div",{className:"text-[9px] text-text-muted mt-1",children:[j.model.split("/").pop()," • ",j.durationMs,"ms"]})]},l))})]},i))]})}return e.jsxs("div",{className:"bg-bg-secondary/50 border border-border rounded-2xl overflow-hidden",children:[e.jsx(P,{icon:le,title:"Debates",count:t.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:()=>c(!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(O,{size:10})," New Debate"]})}),m&&e.jsx(st,{onClose:()=>c(!1),onCreated:()=>{c(!1),g()}}),e.jsx("div",{className:"divide-y divide-border/30",children:o?e.jsx("div",{className:"py-8 text-center text-[12px] text-text-muted",children:"Loading..."}):t.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."]}):t.map(a=>e.jsxs("button",{onClick:()=>p(a.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:a.question}),e.jsxs("span",{className:"text-[10px] text-text-muted whitespace-nowrap",children:[R(a.startedAt)," ago"]})]}),e.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-text-muted",children:[e.jsx("span",{children:a.resolution}),e.jsxs("span",{children:[a.rounds," round",a.rounds===1?"":"s"]}),e.jsxs("span",{children:[(a.durationMs/1e3).toFixed(1),"s"]}),a.winnerRole&&e.jsxs("span",{className:"text-success/80/70",children:["winner: ",a.winnerRole]})]})]},a.id))})]})}const nt=[{label:"Overview",tabs:[{id:"Dashboard",label:"Dashboard",icon:re}]},{label:"Operations",tabs:[{id:"Social",label:"Social",icon:W},{id:"Inbox",label:"Inbox",icon:Ue},{id:"Goals",label:"Goals",icon:Ie},{id:"Work",label:"Work",icon:L},{id:"Sessions",label:"Sessions",icon:ne}]},{label:"Governance",tabs:[{id:"Issues",label:"Issues",icon:W},{id:"Approvals",label:"Approvals",icon:te},{id:"Org Chart",label:"Org Chart",icon:ae},{id:"Agents",label:"Agents",icon:_e},{id:"Files",label:"Files",icon:$e},{id:"Debates",label:"Debates",icon:le},{id:"Costs",label:"Costs",icon:K}]},{label:"System",tabs:[{id:"Traces",label:"Traces",icon:I},{id:"Console",label:"Console",icon:Ee}]}],lt=s.lazy(()=>A(()=>import("./WorkTab-CBoLNrTM.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))),ot=s.lazy(()=>A(()=>import("./SessionsTab-Bk08wyeY.js"),__vite__mapDeps([10,1,2,3]))),ct=s.lazy(()=>A(()=>import("./CPInbox-Bbr7khp6.js"),__vite__mapDeps([11,1,2,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,5]))),it=s.lazy(()=>A(()=>import("./CPFiles-BhLEOnXy.js"),__vite__mapDeps([30,1,2,31,32,33,20]))),dt=s.lazy(()=>A(()=>import("./TraceViewer-BKI7o5B0.js"),__vite__mapDeps([34,1,2,35,21,36,22,37,32,38]))),xt=s.lazy(()=>A(()=>import("./CPSocial-Dlnr_w1X.js"),__vite__mapDeps([39,1,2,33,23,40,22,20]))),ut=s.lazy(()=>A(()=>import("./CPDashboard-11c0nkxK.js"),__vite__mapDeps([41,1,2,12,13,42,14,15,18,33,20,43,44,45]))),mt=s.lazy(()=>A(()=>import("./CPGoals-Bi3t1b2P.js"),__vite__mapDeps([46,1,2,12,13,42,14,15,16,47,3,18,6,45,29,8]))),pt=s.lazy(()=>A(()=>import("./CPAgents-j_7C-oQV.js"),__vite__mapDeps([48,1,2,12,13,42,14,15,16,18,20])));function Rt(){const[t,d]=s.useState("Dashboard"),[n,b]=s.useState(null),[o,f]=s.useState([]),[m,c]=s.useState(!0),[g,p]=s.useState(null),[a,i]=s.useState([]),[y,j]=s.useState(!1),[l,u]=s.useState(null),r=s.useCallback(async()=>{try{const[v,x]=await Promise.allSettled([ie(),ee()]);v.status==="fulfilled"&&(b(v.value),i(v.value.recentActivity||[])),x.status==="fulfilled"&&f(x.value),p(null)}catch(v){p(v.message)}c(!1)},[]);if(s.useEffect(()=>{r()},[r]),s.useEffect(()=>{if(!n)return;const v=localStorage.getItem("titan-token"),x=v?`/api/command-post/stream?token=${v}`:"/api/command-post/stream",h=new EventSource(x);let w=0;return h.addEventListener("commandpost:activity",z=>{w=0;try{i(C=>[...C.slice(-49),JSON.parse(z.data)])}catch{}}),h.addEventListener("commandpost:agent:status",z=>{w=0;try{const C=JSON.parse(z.data);b(S=>S&&{...S,agents:S.agents.map(F=>F.id===C.agentId?{...F,status:C.status}:F)})}catch{}}),h.onerror=()=>{w++,w>5&&h.close()},()=>h.close()},[n]),s.useEffect(()=>{const v=setInterval(r,3e4);return()=>clearInterval(v)},[r]),m)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(G,{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:r,className:"px-4 py-2 text-sm bg-bg-tertiary rounded-lg hover:bg-border text-text-secondary transition-colors",children:"Retry"})]})});const N=n??{agents:[],totalAgents:0,activeAgents:0,activeCheckouts:0,budgetUtilization:0,recentActivity:[],checkouts:[],budgets:[],goalTree:[],companies:[]},k=()=>{switch(t){case"Dashboard":return e.jsx(s.Suspense,{fallback:e.jsx(T,{label:"dashboard"}),children:e.jsx(ut,{})});case"Social":return e.jsx(s.Suspense,{fallback:e.jsx(T,{label:"social"}),children:e.jsx(xt,{})});case"Inbox":return e.jsx(s.Suspense,{fallback:e.jsx(T,{label:"inbox"}),children:e.jsx(ct,{})});case"Goals":return e.jsx(s.Suspense,{fallback:e.jsx(T,{label:"goals"}),children:e.jsx(mt,{})});case"Work":return e.jsx(s.Suspense,{fallback:e.jsx(T,{label:"work"}),children:e.jsx(lt,{})});case"Sessions":return e.jsx(s.Suspense,{fallback:e.jsx(T,{label:"sessions"}),children:e.jsx(ot,{})});case"Issues":return e.jsx(Ze,{agents:N.agents});case"Approvals":return e.jsx(at,{});case"Org Chart":return e.jsx(Qe,{agents:N.agents});case"Agents":return e.jsx(s.Suspense,{fallback:e.jsx(T,{label:"agents"}),children:e.jsx(pt,{})});case"Files":return e.jsx(s.Suspense,{fallback:e.jsx(T,{label:"files"}),children:e.jsx(it,{})});case"Debates":return e.jsx(rt,{});case"Costs":return e.jsx(Xe,{budgets:N.budgets,onRefresh:r});case"Traces":return e.jsx(s.Suspense,{fallback:e.jsx(T,{label:"traces"}),children:e.jsx(dt,{})});case"Console":return e.jsx(tt,{dashboard:N});default:return null}};return e.jsxs("div",{className:"h-full flex overflow-hidden",children:[e.jsxs("div",{className:"w-52 shrink-0 flex flex-col border-r border-border bg-bg-secondary/30",children:[e.jsx("div",{className:"px-4 py-4 border-b border-border",children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-lg bg-accent/10 border border-accent/20",children:e.jsx(H,{size:16,className:"text-accent-light"})}),e.jsxs("div",{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 overflow-y-auto py-2 space-y-4",children:nt.map(v=>e.jsxs("div",{children:[e.jsx("div",{className:"px-3 mb-1 text-[10px] font-semibold text-text-muted uppercase tracking-wider",children:v.label}),e.jsx("div",{className:"px-2 space-y-0.5",children:v.tabs.map(x=>{const h=t===x.id;return e.jsxs("button",{onClick:()=>d(x.id),className:`w-full flex items-center gap-2.5 px-2.5 py-1.5 rounded-lg text-[12px] transition-all duration-150 ${h?"bg-accent/10 text-accent-light font-medium":"text-text-secondary hover:text-text hover:bg-bg-tertiary/50"}`,children:[e.jsx(x.icon,{size:14,className:h?"text-accent-light":"text-text-muted"}),e.jsx("span",{children:x.label})]},x.id)})})]},v.label))}),e.jsx("div",{className:"px-3 py-2 border-t border-border",children:e.jsxs("button",{onClick:r,className:"w-full flex items-center justify-center gap-1.5 px-2 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(Me,{size:12,className:m?"animate-spin":""}),"Refresh"]})})]}),e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsx("div",{className:"max-w-6xl mx-auto px-4 md:px-6 py-4 md:py-6",children:e.jsx(k,{})})}),e.jsx(qe,{collapsed:y,onToggle:()=>j(!y),agents:N.agents,runs:o,onAgentClick:v=>u(v)}),l&&e.jsx(Ge,{agent:l,onClose:()=>u(null)})]})}export{Rt as default};
@@ -0,0 +1 @@
1
+ import{r as t,b3 as d,j as e,b4 as m,b5 as x}from"./index-DzwowwSI.js";import{P as h}from"./PageHeader-CnZtP8ek.js";import{R as b}from"./terminal-BtiqJ628.js";import{C as f}from"./clock-CTsgP_Sn.js";import{T as g,a as p}from"./toggle-right-CKtSrl28.js";import{T as u}from"./trash-2-DgWrHVax.js";import"./chevron-right-aQEw2mUW.js";function k(){const[o,c]=t.useState([]),[r,l]=t.useState(!0),s=t.useCallback(async()=>{l(!0);try{const a=await d();c(a.jobs||[])}catch{}l(!1)},[]);t.useEffect(()=>{s()},[s]);const i=async a=>{try{await m(a),await s()}catch{}},n=async a=>{if(confirm("Delete this cron job?"))try{await x(a),await s()}catch{}};return e.jsxs("div",{className:"space-y-4",children:[e.jsx(h,{title:"Cron Scheduler",breadcrumbs:[{label:"Admin",href:"/overview"},{label:"System"},{label:"Cron"}]}),e.jsx("div",{className:"flex gap-2",children:e.jsxs("button",{onClick:s,disabled:r,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(b,{className:`w-4 h-4 ${r?"animate-spin":""}`})," Refresh"]})}),e.jsx("div",{className:"space-y-2",children:o.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(f,{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:()=>i(a.id),className:"p-1.5 rounded-md bg-[#27272a] text-[#a1a1aa] hover:bg-[#3f3f46]",children:a.enabled?e.jsx(g,{className:"w-4 h-4 text-emerald-400"}):e.jsx(p,{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(u,{className:"w-3.5 h-3.5"})})]})]},a.id))})]})}export{k as default};
@@ -0,0 +1 @@
1
+ import{r as n,j as e,T as x,f as j,A as f,aK as N,aL as y,aM as w}from"./index-DzwowwSI.js";import{E as R}from"./TitanCanvas-BCbWnLMd.js";import{R as S}from"./terminal-BtiqJ628.js";import{P}from"./pause-CYhO_uQo.js";import{P as k}from"./play-DVY9c5Ck.js";import{C as E}from"./clock-CTsgP_Sn.js";import"./chevron-up-C5g6pEj8.js";import"./plus-Csu2v9GN.js";import"./users-dZgv4ePG.js";import"./wrench-CDz3xYve.js";import"./network-DbGDAdrn.js";import"./save-Btx-kpoW.js";import"./rotate-ccw-Co-_W04j.js";import"./search-0hXTwEZR.js";import"./send-TEpapzQR.js";import"./VoiceOverlay-D-gc58b0.js";import"./chevron-right-aQEw2mUW.js";import"./chevron-down-D7OLjvuD.js";import"./folder-DA43TRCm.js";import"./check-Bpm1IONe.js";import"./shield-check-DjBJXZUr.js";import"./external-link-BZ0y_Ahx.js";import"./loader-circle-1YOBsoQp.js";function Z(){const[r,v]=n.useState(null),[p,i]=n.useState(!0),[l,m]=n.useState([]),h=n.useRef(null),s=async()=>{i(!0);try{v(await N())}catch{}i(!1)};n.useEffect(()=>{s();const t=new EventSource("/api/daemon/stream");h.current=t,t.onmessage=d=>{try{const a=JSON.parse(d.data);m(o=>[{event:a.event||"message",data:JSON.stringify(a.data||a,null,0),time:new Date().toLocaleTimeString()},...o].slice(0,50))}catch{}};for(const d of["daemon:started","daemon:stopped","daemon:paused","daemon:resumed","daemon:heartbeat","goal:subtask:ready","health:ollama:down","health:ollama:degraded","cron:stuck"])t.addEventListener(d,a=>{m(o=>[{event:d,data:a.data||"",time:new Date().toLocaleTimeString()},...o].slice(0,50))});const c=setInterval(s,15e3);return()=>{t.close(),clearInterval(c)}},[]);const g=async()=>{await y(),s()},u=async()=>{await w(),s()},b=t=>t<6e4?`${Math.round(t/1e3)}s`:t<36e5?`${Math.round(t/6e4)}m`:`${Math.round(t/36e5)}h ${Math.round(t%36e5/6e4)}m`;return p&&!r?e.jsx("div",{className:"text-[var(--text-muted)]",children:"Loading daemon status..."}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(R,{className:"w-6 h-6 text-[var(--accent)]"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold text-[var(--text)]",children:"Daemon"}),e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:"Persistent background watchers and event loop"})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:s,className:"p-2 rounded-md border border-[var(--border)] text-[var(--text-secondary)] hover:bg-[var(--bg-tertiary)] transition-colors",children:e.jsx(S,{size:14})}),(r==null?void 0:r.running)&&!r.paused&&e.jsxs("button",{onClick:g,className:"flex items-center gap-2 px-3 py-1.5 text-sm rounded-md bg-[var(--warning)]/15 text-[var(--warning)] border border-[var(--warning)]/25 hover:bg-[var(--warning)]/25 transition-colors",children:[e.jsx(P,{size:14})," Pause"]}),(r==null?void 0:r.running)&&r.paused&&e.jsxs("button",{onClick:u,className:"flex items-center gap-2 px-3 py-1.5 text-sm rounded-md bg-[var(--success)]/15 text-[var(--success)] border border-[var(--success)]/25 hover:bg-[var(--success)]/25 transition-colors",children:[e.jsx(k,{size:14})," Resume"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:"Status"}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:r!=null&&r.running?r.paused?e.jsxs(e.Fragment,{children:[e.jsx(x,{size:18,className:"text-[var(--warning)]"}),e.jsx("span",{className:"text-lg font-semibold text-[var(--warning)]",children:"Paused"})]}):e.jsxs(e.Fragment,{children:[e.jsx(j,{size:18,className:"text-[var(--success)]"}),e.jsx("span",{className:"text-lg font-semibold text-[var(--success)]",children:"Running"})]}):e.jsx(e.Fragment,{children:e.jsx("span",{className:"text-lg font-semibold text-[var(--text-muted)]",children:"Stopped"})})})]}),e.jsxs("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:"Uptime"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx(E,{size:18,className:"text-[var(--text-muted)]"}),e.jsx("p",{className:"text-lg font-semibold text-[var(--text)]",children:r?b(r.uptimeMs):"-"})]})]}),e.jsxs("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:"Actions / Hour"}),e.jsxs("p",{className:"text-lg font-semibold text-[var(--text)] mt-1",children:[(r==null?void 0:r.actionsThisHour)??0," ",e.jsxs("span",{className:"text-sm font-normal text-[var(--text-muted)]",children:["/ ",(r==null?void 0:r.maxActionsPerHour)??10]})]})]}),e.jsxs("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg p-4",children:[e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:"Error Rate"}),e.jsxs("p",{className:`text-lg font-semibold mt-1 ${((r==null?void 0:r.errorRatePercent)??0)>30?"text-[var(--error)]":"text-[var(--text)]"}`,children:[(r==null?void 0:r.errorRatePercent)??0,"%"]})]})]}),(r==null?void 0:r.pauseReason)&&e.jsxs("div",{className:"bg-[var(--warning)]/10 border border-[var(--warning)]/25 rounded-lg p-3 flex items-center gap-2",children:[e.jsx(x,{size:16,className:"text-[var(--warning)] flex-shrink-0"}),e.jsx("span",{className:"text-sm text-[var(--warning)]",children:r.pauseReason})]}),e.jsxs("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg p-4",children:[e.jsx("h2",{className:"text-sm font-semibold text-[var(--text)] mb-3",children:"Active Watchers"}),r!=null&&r.activeWatchers&&r.activeWatchers.length>0?e.jsx("div",{className:"flex flex-wrap gap-2",children:r.activeWatchers.map(t=>e.jsxs("span",{className:"flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md bg-[var(--success)]/10 text-[var(--success)] border border-[var(--success)]/20",children:[e.jsx(f,{size:12})," ",t]},t))}):e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:"No active watchers"})]}),e.jsxs("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg p-4",children:[e.jsx("h2",{className:"text-sm font-semibold text-[var(--text)] mb-3",children:"Event Feed"}),l.length>0?e.jsx("div",{className:"space-y-1 max-h-64 overflow-y-auto font-mono text-xs",children:l.map((t,c)=>e.jsxs("div",{className:"flex gap-3 py-1 border-b border-[var(--border)]/50 last:border-0",children:[e.jsx("span",{className:"text-[var(--text-muted)] flex-shrink-0 w-16",children:t.time}),e.jsx("span",{className:"text-[var(--accent)] flex-shrink-0",children:t.event}),e.jsx("span",{className:"text-[var(--text-secondary)] truncate",children:t.data})]},c))}):e.jsx("p",{className:"text-sm text-[var(--text-muted)]",children:"Waiting for events..."})]})]})}export{Z as default};
@@ -1 +1 @@
1
- import{j as e}from"./index-CahJbWSR.js";function i({columns:s,data:d,onRowClick:a,emptyMessage:x="No data available"}){return e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-bg-secondary",children:e.jsxs("table",{className:"w-full text-left text-sm",children:[e.jsx("thead",{children:e.jsx("tr",{className:"bg-bg-tertiary",children:s.map(t=>e.jsx("th",{className:`px-4 py-3 text-sm font-medium text-text-secondary ${t.className??""}`,children:t.header},t.key))})}),e.jsx("tbody",{children:d.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:s.length,className:"px-4 py-12 text-center text-text-muted",children:x})}):d.map((t,n)=>e.jsx("tr",{onClick:()=>a==null?void 0:a(t),className:`border-t border-border transition-colors hover:bg-bg-tertiary/50 ${a?"cursor-pointer":""}`,children:s.map(r=>e.jsx("td",{className:`px-4 py-3 text-text ${r.className??""}`,children:r.render?r.render(t):String(t[r.key]??"")},r.key))},n))})]})})}export{i as D};
1
+ import{j as e}from"./index-DzwowwSI.js";function i({columns:s,data:d,onRowClick:a,emptyMessage:x="No data available"}){return e.jsx("div",{className:"overflow-hidden rounded-xl border border-border bg-bg-secondary",children:e.jsxs("table",{className:"w-full text-left text-sm",children:[e.jsx("thead",{children:e.jsx("tr",{className:"bg-bg-tertiary",children:s.map(t=>e.jsx("th",{className:`px-4 py-3 text-sm font-medium text-text-secondary ${t.className??""}`,children:t.header},t.key))})}),e.jsx("tbody",{children:d.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:s.length,className:"px-4 py-12 text-center text-text-muted",children:x})}):d.map((t,n)=>e.jsx("tr",{onClick:()=>a==null?void 0:a(t),className:`border-t border-border transition-colors hover:bg-bg-tertiary/50 ${a?"cursor-pointer":""}`,children:s.map(r=>e.jsx("td",{className:`px-4 py-3 text-text ${r.className??""}`,children:r.render?r.render(t):String(t[r.key]??"")},r.key))},n))})]})})}export{i as D};
@@ -1 +1 @@
1
- import{j as t}from"./index-CahJbWSR.js";import{B as r}from"./Input-GTHp2Rkr.js";function n({icon:s,title:x,description:m,action:e,className:a}){return t.jsxs("div",{className:`flex flex-col items-center justify-center py-16 text-center ${a??""}`,children:[s&&t.jsx("div",{className:"mb-4 text-text-muted opacity-50",children:s}),t.jsx("h3",{className:"text-sm font-medium text-text-secondary",children:x}),m&&t.jsx("p",{className:"mt-1 max-w-sm text-xs text-text-muted",children:m}),e&&t.jsx(r,{variant:"secondary",size:"sm",onClick:e.onClick,className:"mt-4",children:e.label})]})}export{n as E};
1
+ import{j as t}from"./index-DzwowwSI.js";import{B as r}from"./Input-Bu_b3qmY.js";function n({icon:s,title:x,description:m,action:e,className:a}){return t.jsxs("div",{className:`flex flex-col items-center justify-center py-16 text-center ${a??""}`,children:[s&&t.jsx("div",{className:"mb-4 text-text-muted opacity-50",children:s}),t.jsx("h3",{className:"text-sm font-medium text-text-secondary",children:x}),m&&t.jsx("p",{className:"mt-1 max-w-sm text-xs text-text-muted",children:m}),e&&t.jsx(r,{variant:"secondary",size:"sm",onClick:e.onClick,className:"mt-4",children:e.label})]})}export{n as E};
@@ -1,2 +1,2 @@
1
- import{b as S,r as p,j as e,bq as w,e as $,h as C}from"./index-CahJbWSR.js";import{L as F}from"./layers-BuGf4FIJ.js";import{e as _,R as E,L as M,W as k}from"./TitanCanvas-C-s0A-lv.js";import{T as P}from"./trending-up-DGjFyubC.js";import{P as A}from"./play-CcJ9BnCh.js";import{a as I,C as B}from"./VoiceOverlay-CmNCrLcd.js";import{C as R}from"./circle-check-big-DZRE_MbN.js";const L={"widget-creation":"Widget Creation",safety:"Safety","tool-routing":"Tool Routing","gate-format":"Gate Format",pipeline:"Pipeline Classification",adversarial:"Adversarial","tool-routing-v2":"Tool Routing v2",session:"Session Management","widget-v2":"Widget v2","gate-format-v2":"Gate Format v2",content:"Content Quality"};async function D(){const s=await S("/api/eval/suites");if(!s.ok)throw new Error(`/api/eval/suites failed: ${s.status}`);const i=await s.json();return Array.isArray(i.suites)?i.suites:[]}async function U(s){const i=await S("/api/eval/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({suite:s})});if(!i.ok){const a=await i.text().catch(()=>"");throw new Error(`/api/eval/run failed: ${i.status} ${a.slice(0,200)}`)}return i.json()}function O(s){return s.total?Math.round(s.passed/s.total*100):NaN}function N(s){return Number.isNaN(s)?"slate":s>=100?"emerald":s>=80?"amber":"red"}function W(s){const i=[];for(const a of s.split(`
2
- `)){const n=a.trim();if(!n||n.startsWith("#"))continue;const l=n.match(/^([a-zA-Z_:][a-zA-Z0-9_:]*)(?:\{([^}]*)\})?\s+([0-9eE+\-.NaN]+)/);if(!l)continue;const c={};if(l[2])for(const f of l[2].split(",")){const[u,...x]=f.split("=");if(!u)continue;const g=x.join("=").trim().replace(/^"|"$/g,"");c[u.trim()]=g}const r=Number(l[3]);Number.isNaN(r)||i.push({name:l[1],labels:c,value:r})}return i}async function q(s){const i=await S("/metrics");if(!i.ok)throw new Error(`/metrics failed: ${i.status}`);const a=await i.text(),n=W(a);return s?n.filter(l=>l.name===s||l.name.startsWith(`${s}_`)):n}const y={emerald:"bg-emerald-500/15 text-emerald-300 border-emerald-500/40",amber:"bg-amber-500/15 text-amber-300 border-amber-500/40",red:"bg-red-500/15 text-red-300 border-red-500/40",slate:"bg-slate-500/15 text-slate-300 border-slate-500/40"},J=[{id:"suites",label:"Suites",icon:F},{id:"memory",label:"Memory Regression",icon:_},{id:"redteam",label:"Red Team",icon:w},{id:"trends",label:"Trends",icon:P}];function re(){const[s,i]=p.useState("suites"),[a,n]=p.useState([]),[l,c]=p.useState(!1),[r,f]=p.useState(null),u=p.useCallback(async()=>{c(!0);try{const t=await D();n(m=>{const h=new Map(m.map(b=>[b.name,b]));return t.map(b=>h.get(b)??{name:b,status:"idle"})})}catch(t){console.error("listEvalSuites failed:",t),n([])}finally{c(!1)}},[]);p.useEffect(()=>{u()},[u]);const x=p.useCallback(async t=>{n(m=>m.map(h=>h.name===t?{...h,status:"running",error:void 0}:h));try{const m=await U(t);n(h=>h.map(b=>b.name===t?{...b,status:"done",result:m}:b))}catch(m){n(h=>h.map(b=>b.name===t?{...b,status:"error",error:m.message}:b))}},[]),g=p.useCallback(async()=>{for(const t of a)await x(t.name)},[a,x]),v=a.reduce((t,m)=>{var h,b,T;return{total:t.total+(((h=m.result)==null?void 0:h.total)??0),passed:t.passed+(((b=m.result)==null?void 0:b.passed)??0),failed:t.failed+(((T=m.result)==null?void 0:T.failed)??0)}},{total:0,passed:0,failed:0}),j=O(v),o=N(j),d=a.some(t=>t.status==="running");return e.jsxs("div",{className:"flex h-full flex-col gap-4 p-4 text-slate-200",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Eval Harness"}),e.jsx("div",{className:"flex items-center gap-1 rounded border border-slate-700 bg-slate-800/40 p-0.5",children:J.map(t=>{const m=t.icon,h=t.id===s;return e.jsxs("button",{onClick:()=>i(t.id),className:`flex items-center gap-1.5 rounded px-2.5 py-1 text-xs ${h?"bg-slate-700/80 text-slate-100":"text-slate-400 hover:bg-slate-700/30"}`,children:[e.jsx(m,{className:"h-3 w-3"}),t.label]},t.id)})}),s==="suites"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:u,disabled:l||d,className:"rounded border border-slate-700 bg-slate-800/40 p-1.5 hover:bg-slate-800 disabled:opacity-50",title:"Refresh suite list",children:e.jsx(E,{className:`h-3.5 w-3.5 ${l?"animate-spin":""}`})}),e.jsxs("button",{onClick:g,disabled:a.length===0||d,className:"ml-auto flex items-center gap-1.5 rounded border border-emerald-500/40 bg-emerald-500/10 px-3 py-1.5 text-sm text-emerald-300 hover:bg-emerald-500/20 disabled:opacity-50",children:[d?e.jsx(M,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(A,{className:"h-3.5 w-3.5"}),"Run all suites"]})]})]}),s==="suites"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`flex items-center gap-3 rounded-lg border p-3 text-sm ${y[o]}`,children:[e.jsxs("div",{className:"font-medium",children:["Overall: ",v.passed,"/",v.total," passed",Number.isFinite(j)&&e.jsxs("span",{className:"ml-2 opacity-80",children:["(",j,"%)"]})]}),v.failed>0&&e.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[e.jsx($,{className:"h-3.5 w-3.5"}),v.failed," failure",v.failed===1?"":"s"]})]}),e.jsxs("div",{className:"flex-1 space-y-2 overflow-auto",children:[a.length===0&&!l&&e.jsxs("div",{className:"rounded border border-slate-700 bg-slate-800/30 p-4 text-center text-sm text-slate-400",children:["No eval suites available. Verify ",e.jsx("code",{className:"font-mono text-xs",children:"/api/eval/suites"})," on the gateway."]}),a.map(t=>e.jsx(V,{suite:t,expanded:r===t.name,onToggle:()=>f(m=>m===t.name?null:t.name),onRun:()=>x(t.name)},t.name))]})]}),s==="memory"&&e.jsx(z,{suites:a,onRun:x}),s==="redteam"&&e.jsx(H,{suites:a,onRun:x}),s==="trends"&&e.jsx(K,{})]})}function z({suites:s,onRun:i}){const a=s.flatMap(l=>{var c;return(((c=l.result)==null?void 0:c.results)??[]).filter(r=>/memory|recall|stale|distract|context/i.test(r.name)).map(r=>({suite:l.name,case:r}))});if(a.length===0)return e.jsx("div",{className:"flex flex-1 items-center justify-center rounded border border-dashed border-slate-700 bg-slate-800/20 p-8 text-center",children:e.jsxs("div",{children:[e.jsx(_,{className:"mx-auto mb-2 h-6 w-6 text-slate-500"}),e.jsx("div",{className:"text-sm text-slate-300",children:"No memory regression results yet."}),e.jsxs("div",{className:"mt-1 text-xs text-slate-500",children:["Run a suite that contains memory cases (session, content). Multi-turn fact recall is asserted via tape replay in ",e.jsx("code",{className:"font-mono",children:"tests/eval/memory.test.ts"}),"."]}),e.jsxs("div",{className:"mt-3 flex justify-center gap-2",children:[e.jsx("button",{onClick:()=>i("session"),className:"rounded border border-emerald-500/40 bg-emerald-500/10 px-3 py-1 text-xs text-emerald-300 hover:bg-emerald-500/20",children:"Run session suite"}),e.jsx("button",{onClick:()=>i("content"),className:"rounded border border-emerald-500/40 bg-emerald-500/10 px-3 py-1 text-xs text-emerald-300 hover:bg-emerald-500/20",children:"Run content suite"})]})]})});const n=a.filter(l=>l.case.passed).length;return e.jsxs("div",{className:"flex flex-1 flex-col gap-3 overflow-auto",children:[e.jsx("div",{className:`rounded-lg border p-3 text-sm ${y[N(n/a.length*100)]}`,children:e.jsxs("div",{className:"font-medium",children:["Memory recall: ",n,"/",a.length," cases passed",e.jsxs("span",{className:"ml-2 opacity-80",children:["(",Math.round(n/a.length*100),"%)"]})]})}),e.jsx("div",{className:"space-y-1.5",children:a.map(l=>e.jsxs("div",{className:`rounded p-2 text-xs ${l.case.passed?"bg-slate-800/30":"bg-red-950/30"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[l.case.passed?e.jsx(R,{className:"h-3.5 w-3.5 text-emerald-400"}):e.jsx(C,{className:"h-3.5 w-3.5 text-red-400"}),e.jsx("div",{className:"font-mono text-slate-200",children:l.case.name}),e.jsx("div",{className:"ml-auto text-[10px] text-slate-500",children:l.suite})]}),!l.case.passed&&l.case.errors.length>0&&e.jsx("ul",{className:"mt-1 ml-5 list-disc text-red-300",children:l.case.errors.map((c,r)=>e.jsx("li",{children:c},r))})]},`${l.suite}/${l.case.name}`))})]})}const G=[{id:"ignore-prev",label:"Ignore-previous",pattern:/ignore.*(previous|prior)|disregard|forget/i},{id:"dan",label:"DAN / persona swap",pattern:/\bDAN\b|do anything|jailbreak/i},{id:"prompt-extract",label:"Prompt extraction",pattern:/system prompt|reveal|extract|leak/i},{id:"path-traversal",label:"Path traversal",pattern:/\.\.\/|\/etc\/passwd|path traversal/i},{id:"shell-inject",label:"Shell injection",pattern:/;.*rm|`whoami`|\$\(|\| ?bash/i},{id:"url-scheme",label:"URL scheme abuse",pattern:/file:\/\/|dict:\/\/|gopher:\/\//i},{id:"markdown-js",label:"Markdown JS link",pattern:/\[.*\]\(javascript:/i},{id:"other",label:"Other",pattern:/.*/}];function H({suites:s,onRun:i}){var c;const a=s.find(r=>r.name==="adversarial"),n=((c=a==null?void 0:a.result)==null?void 0:c.results)??[];if(n.length===0)return e.jsx("div",{className:"flex flex-1 items-center justify-center rounded border border-dashed border-slate-700 bg-slate-800/20 p-8 text-center",children:e.jsxs("div",{children:[e.jsx(w,{className:"mx-auto mb-2 h-6 w-6 text-slate-500"}),e.jsx("div",{className:"text-sm text-slate-300",children:"No red-team results yet."}),e.jsx("div",{className:"mt-1 text-xs text-slate-500",children:"Run the adversarial suite to populate this grid."}),e.jsx("button",{onClick:()=>i("adversarial"),className:"mt-3 rounded border border-red-500/40 bg-red-500/10 px-3 py-1 text-xs text-red-300 hover:bg-red-500/20",children:"Run adversarial suite"})]})});const l=G.map(r=>{const f=n.filter(x=>r.pattern.test(x.name)||r.pattern.test(x.content||"")),u=f.filter(x=>x.passed).length;return{vector:r,total:f.length,blocked:u,matched:f}}).filter(r=>r.total>0);return e.jsxs("div",{className:"flex flex-1 flex-col gap-3 overflow-auto",children:[e.jsx("div",{className:"text-xs text-slate-400",children:"Pass = attack BLOCKED (TITAN refused or sanitized). Fail = attack possibly EXPLOITED — investigate the case."}),e.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3",children:l.map(r=>{const f=r.total>0?Math.round(r.blocked/r.total*100):0,u=N(f);return e.jsxs("div",{className:`rounded-lg border p-3 ${y[u]}`,children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(w,{className:"h-3.5 w-3.5"}),r.vector.label]}),e.jsxs("div",{className:"mt-1 text-xs",children:[r.blocked,"/",r.total," blocked (",f,"%)"]}),e.jsxs("div",{className:"mt-2 space-y-1",children:[r.matched.slice(0,4).map(x=>e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[x.passed?e.jsx(R,{className:"h-2.5 w-2.5 text-emerald-400"}):e.jsx(C,{className:"h-2.5 w-2.5 text-red-400"}),e.jsx("span",{className:"font-mono",children:x.name})]},x.name)),r.matched.length>4&&e.jsxs("div",{className:"text-[10px] text-slate-500",children:["+ ",r.matched.length-4," more"]})]})]},r.vector.id)})})]})}function K(){const[s,i]=p.useState([]),[a,n]=p.useState(!1),[l,c]=p.useState(null),[r,f]=p.useState(null),u=p.useCallback(async()=>{n(!0),c(null);try{const o=await q("titan_eval");i(o),f(new Date)}catch(o){c(o.message)}finally{n(!1)}},[]);p.useEffect(()=>{u();const o=setInterval(u,3e4);return()=>clearInterval(o)},[u]);const x=p.useMemo(()=>s.filter(o=>o.name==="titan_eval_pass_rate"&&o.labels.suite).map(o=>({suite:o.labels.suite,rate:o.value})).sort((o,d)=>o.rate-d.rate),[s]),g=p.useMemo(()=>{const o=new Map;for(const d of s){if(!d.labels.suite)continue;const t=o.get(d.labels.suite)??{passed:0,failed:0,timeouts:0,errors:0};d.name==="titan_eval_cases_total"?d.labels.outcome==="passed"?t.passed=d.value:d.labels.outcome==="failed"&&(t.failed=d.value):d.name==="titan_eval_timeout_total"?t.timeouts+=d.value:d.name==="titan_eval_error_total"&&(t.errors+=d.value),o.set(d.labels.suite,t)}return o},[s]),v=p.useMemo(()=>{let o=0,d=0;for(const t of g.values())o+=t.timeouts,d+=t.errors;return{timeouts:o,errors:d}},[g]),j=100;return e.jsxs("div",{className:"flex flex-1 flex-col gap-3 overflow-auto",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-slate-400",children:[e.jsxs("span",{children:["Live from ",e.jsx("code",{className:"font-mono",children:"/metrics"})," (titan_eval_* gauges + counters)."]}),e.jsx("span",{className:"ml-auto",children:r?`updated ${r.toLocaleTimeString()}`:""}),e.jsx("button",{onClick:u,disabled:a,className:"rounded border border-slate-700 bg-slate-800/40 p-1 hover:bg-slate-800 disabled:opacity-50",children:e.jsx(E,{className:`h-3 w-3 ${a?"animate-spin":""}`})})]}),(v.timeouts>0||v.errors>0)&&e.jsxs("div",{className:"flex items-center gap-2 rounded border border-amber-500/40 bg-amber-500/10 p-2 text-xs text-amber-300",children:[e.jsx($,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"font-medium",children:"Operational drift:"}),v.timeouts>0&&e.jsxs("span",{children:[e.jsx("strong",{children:v.timeouts})," timeout",v.timeouts===1?"":"s"]}),v.errors>0&&e.jsxs("span",{children:[e.jsx("strong",{children:v.errors})," error",v.errors===1?"":"s"]}),e.jsx("span",{className:"ml-auto opacity-70",children:"across all suites, lifetime totals from /metrics"})]}),l&&e.jsx("div",{className:"rounded border border-red-500/40 bg-red-500/10 p-2 text-xs text-red-300",children:l}),x.length===0&&!l&&e.jsxs("div",{className:"rounded border border-dashed border-slate-700 bg-slate-800/20 p-6 text-center text-sm text-slate-400",children:["No eval pass-rate metrics yet. Run a suite via the Suites tab to populate ",e.jsx("code",{className:"font-mono",children:"titan_eval_pass_rate"}),"."]}),e.jsx("div",{className:"space-y-1.5",children:x.map(({suite:o,rate:d})=>{const t=g.get(o),m=N(d),h=L[o]??o;return e.jsx("div",{className:`rounded border p-2 text-xs ${y[m]}`,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-32 truncate font-medium text-slate-200",children:h}),e.jsx("div",{className:"relative h-4 flex-1 overflow-hidden rounded bg-slate-800/60",children:e.jsx("div",{className:`h-full ${m==="emerald"?"bg-emerald-500/60":m==="amber"?"bg-amber-500/60":m==="red"?"bg-red-500/60":"bg-slate-500/60"}`,style:{width:`${d/j*100}%`}})}),e.jsxs("div",{className:"w-16 text-right font-mono",children:[d,"%"]}),t&&e.jsxs("div",{className:"w-44 text-right text-[10px] text-slate-500",children:[t.passed,"/",t.passed+t.failed," ever",t.timeouts>0&&e.jsxs("span",{className:"ml-1 text-amber-400",children:["· ",t.timeouts," timeout",t.timeouts===1?"":"s"]}),t.errors>0&&e.jsxs("span",{className:"ml-1 text-red-400",children:["· ",t.errors," error",t.errors===1?"":"s"]})]})]})},o)})})]})}function V({suite:s,expanded:i,onToggle:a,onRun:n}){var f;const l=L[s.name]??s.name,c=s.result?O(s.result):NaN,r=N(c);return e.jsxs("div",{className:`rounded-lg border ${y[r]}`,children:[e.jsxs("div",{className:"flex items-center gap-3 p-3",children:[e.jsx("button",{onClick:a,disabled:!s.result,className:"text-slate-300 disabled:opacity-30","aria-label":i?"Collapse":"Expand",children:i?e.jsx(I,{className:"h-4 w-4"}):e.jsx(B,{className:"h-4 w-4"})}),e.jsx("div",{className:"font-medium text-slate-100",children:l}),e.jsx("div",{className:"text-xs text-slate-400",children:s.result?`${s.result.passed}/${s.result.total} (${c}%)`:s.status==="running"?"running…":s.status==="error"?`error: ${s.error}`:"idle"}),((f=s.result)==null?void 0:f.durationMs)!==void 0&&e.jsxs("div",{className:"text-xs text-slate-500",children:[(s.result.durationMs/1e3).toFixed(1),"s"]}),e.jsxs("button",{onClick:n,disabled:s.status==="running",className:"ml-auto flex items-center gap-1 rounded border border-slate-600 bg-slate-800/60 px-2 py-1 text-xs text-slate-200 hover:bg-slate-800 disabled:opacity-50",children:[s.status==="running"?e.jsx(M,{className:"h-3 w-3 animate-spin"}):e.jsx(A,{className:"h-3 w-3"}),"Run"]})]}),i&&s.result&&e.jsx("div",{className:"space-y-1.5 border-t border-slate-700/40 px-3 py-2",children:s.result.results.map(u=>e.jsx(X,{caseResult:u},u.name))})]})}function X({caseResult:s}){const i=s.expectedToolSequence!==void 0&&JSON.stringify(s.expectedToolSequence)!==JSON.stringify(s.toolsUsed);return e.jsxs("div",{className:`rounded p-2 text-xs ${s.passed?"bg-slate-800/30":"bg-red-950/30"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[s.passed?e.jsx(R,{className:"h-3.5 w-3.5 text-emerald-400"}):e.jsx(C,{className:"h-3.5 w-3.5 text-red-400"}),e.jsx("div",{className:"font-mono text-slate-200",children:s.name}),e.jsxs("div",{className:"ml-auto text-slate-500",children:[s.durationMs,"ms"]})]}),!s.passed&&s.errors.length>0&&e.jsx("ul",{className:"mt-1 ml-5 list-disc text-red-300",children:s.errors.map((a,n)=>e.jsx("li",{children:a},n))}),i&&e.jsxs("div",{className:"mt-2 ml-5 grid grid-cols-2 gap-2 rounded bg-slate-900/40 p-2",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1 text-slate-400",children:[e.jsx(k,{className:"h-3 w-3"})," expected"]}),(s.expectedToolSequence??[]).map((a,n)=>e.jsxs("div",{className:"font-mono text-emerald-300",children:[n+1,". ",a]},n))]}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1 text-slate-400",children:[e.jsx(k,{className:"h-3 w-3"})," actual"]}),s.toolsUsed.length===0&&e.jsx("div",{className:"italic text-slate-500",children:"(no tool calls)"}),s.toolsUsed.map((a,n)=>{var r;const c=((r=s.expectedToolSequence)==null?void 0:r[n])===a;return e.jsxs("div",{className:`font-mono ${c?"text-emerald-300":"text-red-300"}`,children:[n+1,". ",a]},n)})]})]})]})}export{re as default};
1
+ import{b as S,r as p,j as e,bD as w,e as $,h as C}from"./index-DzwowwSI.js";import{L as F}from"./layers-DsyEyu7z.js";import{a as _}from"./TitanCanvas-BCbWnLMd.js";import{T as P}from"./trending-up-MpIrE4j6.js";import{R as E}from"./terminal-BtiqJ628.js";import{L as M}from"./loader-circle-1YOBsoQp.js";import{P as A}from"./play-DVY9c5Ck.js";import{C as I}from"./chevron-down-D7OLjvuD.js";import{C as B}from"./chevron-right-aQEw2mUW.js";import{C as R}from"./circle-check-big-fPhEdP88.js";import{W as k}from"./wrench-CDz3xYve.js";import"./chevron-up-C5g6pEj8.js";import"./plus-Csu2v9GN.js";import"./users-dZgv4ePG.js";import"./network-DbGDAdrn.js";import"./save-Btx-kpoW.js";import"./rotate-ccw-Co-_W04j.js";import"./search-0hXTwEZR.js";import"./send-TEpapzQR.js";import"./VoiceOverlay-D-gc58b0.js";import"./folder-DA43TRCm.js";import"./clock-CTsgP_Sn.js";import"./check-Bpm1IONe.js";import"./shield-check-DjBJXZUr.js";import"./external-link-BZ0y_Ahx.js";const L={"widget-creation":"Widget Creation",safety:"Safety","tool-routing":"Tool Routing","gate-format":"Gate Format",pipeline:"Pipeline Classification",adversarial:"Adversarial","tool-routing-v2":"Tool Routing v2",session:"Session Management","widget-v2":"Widget v2","gate-format-v2":"Gate Format v2",content:"Content Quality"};async function D(){const s=await S("/api/eval/suites");if(!s.ok)throw new Error(`/api/eval/suites failed: ${s.status}`);const i=await s.json();return Array.isArray(i.suites)?i.suites:[]}async function U(s){const i=await S("/api/eval/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({suite:s})});if(!i.ok){const a=await i.text().catch(()=>"");throw new Error(`/api/eval/run failed: ${i.status} ${a.slice(0,200)}`)}return i.json()}function O(s){return s.total?Math.round(s.passed/s.total*100):NaN}function N(s){return Number.isNaN(s)?"slate":s>=100?"emerald":s>=80?"amber":"red"}function W(s){const i=[];for(const a of s.split(`
2
+ `)){const n=a.trim();if(!n||n.startsWith("#"))continue;const l=n.match(/^([a-zA-Z_:][a-zA-Z0-9_:]*)(?:\{([^}]*)\})?\s+([0-9eE+\-.NaN]+)/);if(!l)continue;const c={};if(l[2])for(const b of l[2].split(",")){const[u,...x]=b.split("=");if(!u)continue;const g=x.join("=").trim().replace(/^"|"$/g,"");c[u.trim()]=g}const r=Number(l[3]);Number.isNaN(r)||i.push({name:l[1],labels:c,value:r})}return i}async function q(s){const i=await S("/metrics");if(!i.ok)throw new Error(`/metrics failed: ${i.status}`);const a=await i.text(),n=W(a);return s?n.filter(l=>l.name===s||l.name.startsWith(`${s}_`)):n}const y={emerald:"bg-emerald-500/15 text-emerald-300 border-emerald-500/40",amber:"bg-amber-500/15 text-amber-300 border-amber-500/40",red:"bg-red-500/15 text-red-300 border-red-500/40",slate:"bg-slate-500/15 text-slate-300 border-slate-500/40"},J=[{id:"suites",label:"Suites",icon:F},{id:"memory",label:"Memory Regression",icon:_},{id:"redteam",label:"Red Team",icon:w},{id:"trends",label:"Trends",icon:P}];function ye(){const[s,i]=p.useState("suites"),[a,n]=p.useState([]),[l,c]=p.useState(!1),[r,b]=p.useState(null),u=p.useCallback(async()=>{c(!0);try{const t=await D();n(m=>{const h=new Map(m.map(f=>[f.name,f]));return t.map(f=>h.get(f)??{name:f,status:"idle"})})}catch(t){console.error("listEvalSuites failed:",t),n([])}finally{c(!1)}},[]);p.useEffect(()=>{u()},[u]);const x=p.useCallback(async t=>{n(m=>m.map(h=>h.name===t?{...h,status:"running",error:void 0}:h));try{const m=await U(t);n(h=>h.map(f=>f.name===t?{...f,status:"done",result:m}:f))}catch(m){n(h=>h.map(f=>f.name===t?{...f,status:"error",error:m.message}:f))}},[]),g=p.useCallback(async()=>{for(const t of a)await x(t.name)},[a,x]),v=a.reduce((t,m)=>{var h,f,T;return{total:t.total+(((h=m.result)==null?void 0:h.total)??0),passed:t.passed+(((f=m.result)==null?void 0:f.passed)??0),failed:t.failed+(((T=m.result)==null?void 0:T.failed)??0)}},{total:0,passed:0,failed:0}),j=O(v),o=N(j),d=a.some(t=>t.status==="running");return e.jsxs("div",{className:"flex h-full flex-col gap-4 p-4 text-slate-200",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Eval Harness"}),e.jsx("div",{className:"flex items-center gap-1 rounded border border-slate-700 bg-slate-800/40 p-0.5",children:J.map(t=>{const m=t.icon,h=t.id===s;return e.jsxs("button",{onClick:()=>i(t.id),className:`flex items-center gap-1.5 rounded px-2.5 py-1 text-xs ${h?"bg-slate-700/80 text-slate-100":"text-slate-400 hover:bg-slate-700/30"}`,children:[e.jsx(m,{className:"h-3 w-3"}),t.label]},t.id)})}),s==="suites"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:u,disabled:l||d,className:"rounded border border-slate-700 bg-slate-800/40 p-1.5 hover:bg-slate-800 disabled:opacity-50",title:"Refresh suite list",children:e.jsx(E,{className:`h-3.5 w-3.5 ${l?"animate-spin":""}`})}),e.jsxs("button",{onClick:g,disabled:a.length===0||d,className:"ml-auto flex items-center gap-1.5 rounded border border-emerald-500/40 bg-emerald-500/10 px-3 py-1.5 text-sm text-emerald-300 hover:bg-emerald-500/20 disabled:opacity-50",children:[d?e.jsx(M,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(A,{className:"h-3.5 w-3.5"}),"Run all suites"]})]})]}),s==="suites"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:`flex items-center gap-3 rounded-lg border p-3 text-sm ${y[o]}`,children:[e.jsxs("div",{className:"font-medium",children:["Overall: ",v.passed,"/",v.total," passed",Number.isFinite(j)&&e.jsxs("span",{className:"ml-2 opacity-80",children:["(",j,"%)"]})]}),v.failed>0&&e.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[e.jsx($,{className:"h-3.5 w-3.5"}),v.failed," failure",v.failed===1?"":"s"]})]}),e.jsxs("div",{className:"flex-1 space-y-2 overflow-auto",children:[a.length===0&&!l&&e.jsxs("div",{className:"rounded border border-slate-700 bg-slate-800/30 p-4 text-center text-sm text-slate-400",children:["No eval suites available. Verify ",e.jsx("code",{className:"font-mono text-xs",children:"/api/eval/suites"})," on the gateway."]}),a.map(t=>e.jsx(V,{suite:t,expanded:r===t.name,onToggle:()=>b(m=>m===t.name?null:t.name),onRun:()=>x(t.name)},t.name))]})]}),s==="memory"&&e.jsx(z,{suites:a,onRun:x}),s==="redteam"&&e.jsx(H,{suites:a,onRun:x}),s==="trends"&&e.jsx(K,{})]})}function z({suites:s,onRun:i}){const a=s.flatMap(l=>{var c;return(((c=l.result)==null?void 0:c.results)??[]).filter(r=>/memory|recall|stale|distract|context/i.test(r.name)).map(r=>({suite:l.name,case:r}))});if(a.length===0)return e.jsx("div",{className:"flex flex-1 items-center justify-center rounded border border-dashed border-slate-700 bg-slate-800/20 p-8 text-center",children:e.jsxs("div",{children:[e.jsx(_,{className:"mx-auto mb-2 h-6 w-6 text-slate-500"}),e.jsx("div",{className:"text-sm text-slate-300",children:"No memory regression results yet."}),e.jsxs("div",{className:"mt-1 text-xs text-slate-500",children:["Run a suite that contains memory cases (session, content). Multi-turn fact recall is asserted via tape replay in ",e.jsx("code",{className:"font-mono",children:"tests/eval/memory.test.ts"}),"."]}),e.jsxs("div",{className:"mt-3 flex justify-center gap-2",children:[e.jsx("button",{onClick:()=>i("session"),className:"rounded border border-emerald-500/40 bg-emerald-500/10 px-3 py-1 text-xs text-emerald-300 hover:bg-emerald-500/20",children:"Run session suite"}),e.jsx("button",{onClick:()=>i("content"),className:"rounded border border-emerald-500/40 bg-emerald-500/10 px-3 py-1 text-xs text-emerald-300 hover:bg-emerald-500/20",children:"Run content suite"})]})]})});const n=a.filter(l=>l.case.passed).length;return e.jsxs("div",{className:"flex flex-1 flex-col gap-3 overflow-auto",children:[e.jsx("div",{className:`rounded-lg border p-3 text-sm ${y[N(n/a.length*100)]}`,children:e.jsxs("div",{className:"font-medium",children:["Memory recall: ",n,"/",a.length," cases passed",e.jsxs("span",{className:"ml-2 opacity-80",children:["(",Math.round(n/a.length*100),"%)"]})]})}),e.jsx("div",{className:"space-y-1.5",children:a.map(l=>e.jsxs("div",{className:`rounded p-2 text-xs ${l.case.passed?"bg-slate-800/30":"bg-red-950/30"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[l.case.passed?e.jsx(R,{className:"h-3.5 w-3.5 text-emerald-400"}):e.jsx(C,{className:"h-3.5 w-3.5 text-red-400"}),e.jsx("div",{className:"font-mono text-slate-200",children:l.case.name}),e.jsx("div",{className:"ml-auto text-[10px] text-slate-500",children:l.suite})]}),!l.case.passed&&l.case.errors.length>0&&e.jsx("ul",{className:"mt-1 ml-5 list-disc text-red-300",children:l.case.errors.map((c,r)=>e.jsx("li",{children:c},r))})]},`${l.suite}/${l.case.name}`))})]})}const G=[{id:"ignore-prev",label:"Ignore-previous",pattern:/ignore.*(previous|prior)|disregard|forget/i},{id:"dan",label:"DAN / persona swap",pattern:/\bDAN\b|do anything|jailbreak/i},{id:"prompt-extract",label:"Prompt extraction",pattern:/system prompt|reveal|extract|leak/i},{id:"path-traversal",label:"Path traversal",pattern:/\.\.\/|\/etc\/passwd|path traversal/i},{id:"shell-inject",label:"Shell injection",pattern:/;.*rm|`whoami`|\$\(|\| ?bash/i},{id:"url-scheme",label:"URL scheme abuse",pattern:/file:\/\/|dict:\/\/|gopher:\/\//i},{id:"markdown-js",label:"Markdown JS link",pattern:/\[.*\]\(javascript:/i},{id:"other",label:"Other",pattern:/.*/}];function H({suites:s,onRun:i}){var c;const a=s.find(r=>r.name==="adversarial"),n=((c=a==null?void 0:a.result)==null?void 0:c.results)??[];if(n.length===0)return e.jsx("div",{className:"flex flex-1 items-center justify-center rounded border border-dashed border-slate-700 bg-slate-800/20 p-8 text-center",children:e.jsxs("div",{children:[e.jsx(w,{className:"mx-auto mb-2 h-6 w-6 text-slate-500"}),e.jsx("div",{className:"text-sm text-slate-300",children:"No red-team results yet."}),e.jsx("div",{className:"mt-1 text-xs text-slate-500",children:"Run the adversarial suite to populate this grid."}),e.jsx("button",{onClick:()=>i("adversarial"),className:"mt-3 rounded border border-red-500/40 bg-red-500/10 px-3 py-1 text-xs text-red-300 hover:bg-red-500/20",children:"Run adversarial suite"})]})});const l=G.map(r=>{const b=n.filter(x=>r.pattern.test(x.name)||r.pattern.test(x.content||"")),u=b.filter(x=>x.passed).length;return{vector:r,total:b.length,blocked:u,matched:b}}).filter(r=>r.total>0);return e.jsxs("div",{className:"flex flex-1 flex-col gap-3 overflow-auto",children:[e.jsx("div",{className:"text-xs text-slate-400",children:"Pass = attack BLOCKED (TITAN refused or sanitized). Fail = attack possibly EXPLOITED — investigate the case."}),e.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3",children:l.map(r=>{const b=r.total>0?Math.round(r.blocked/r.total*100):0,u=N(b);return e.jsxs("div",{className:`rounded-lg border p-3 ${y[u]}`,children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-medium",children:[e.jsx(w,{className:"h-3.5 w-3.5"}),r.vector.label]}),e.jsxs("div",{className:"mt-1 text-xs",children:[r.blocked,"/",r.total," blocked (",b,"%)"]}),e.jsxs("div",{className:"mt-2 space-y-1",children:[r.matched.slice(0,4).map(x=>e.jsxs("div",{className:"flex items-center gap-1.5 text-[11px]",children:[x.passed?e.jsx(R,{className:"h-2.5 w-2.5 text-emerald-400"}):e.jsx(C,{className:"h-2.5 w-2.5 text-red-400"}),e.jsx("span",{className:"font-mono",children:x.name})]},x.name)),r.matched.length>4&&e.jsxs("div",{className:"text-[10px] text-slate-500",children:["+ ",r.matched.length-4," more"]})]})]},r.vector.id)})})]})}function K(){const[s,i]=p.useState([]),[a,n]=p.useState(!1),[l,c]=p.useState(null),[r,b]=p.useState(null),u=p.useCallback(async()=>{n(!0),c(null);try{const o=await q("titan_eval");i(o),b(new Date)}catch(o){c(o.message)}finally{n(!1)}},[]);p.useEffect(()=>{u();const o=setInterval(u,3e4);return()=>clearInterval(o)},[u]);const x=p.useMemo(()=>s.filter(o=>o.name==="titan_eval_pass_rate"&&o.labels.suite).map(o=>({suite:o.labels.suite,rate:o.value})).sort((o,d)=>o.rate-d.rate),[s]),g=p.useMemo(()=>{const o=new Map;for(const d of s){if(!d.labels.suite)continue;const t=o.get(d.labels.suite)??{passed:0,failed:0,timeouts:0,errors:0};d.name==="titan_eval_cases_total"?d.labels.outcome==="passed"?t.passed=d.value:d.labels.outcome==="failed"&&(t.failed=d.value):d.name==="titan_eval_timeout_total"?t.timeouts+=d.value:d.name==="titan_eval_error_total"&&(t.errors+=d.value),o.set(d.labels.suite,t)}return o},[s]),v=p.useMemo(()=>{let o=0,d=0;for(const t of g.values())o+=t.timeouts,d+=t.errors;return{timeouts:o,errors:d}},[g]),j=100;return e.jsxs("div",{className:"flex flex-1 flex-col gap-3 overflow-auto",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-slate-400",children:[e.jsxs("span",{children:["Live from ",e.jsx("code",{className:"font-mono",children:"/metrics"})," (titan_eval_* gauges + counters)."]}),e.jsx("span",{className:"ml-auto",children:r?`updated ${r.toLocaleTimeString()}`:""}),e.jsx("button",{onClick:u,disabled:a,className:"rounded border border-slate-700 bg-slate-800/40 p-1 hover:bg-slate-800 disabled:opacity-50",children:e.jsx(E,{className:`h-3 w-3 ${a?"animate-spin":""}`})})]}),(v.timeouts>0||v.errors>0)&&e.jsxs("div",{className:"flex items-center gap-2 rounded border border-amber-500/40 bg-amber-500/10 p-2 text-xs text-amber-300",children:[e.jsx($,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"font-medium",children:"Operational drift:"}),v.timeouts>0&&e.jsxs("span",{children:[e.jsx("strong",{children:v.timeouts})," timeout",v.timeouts===1?"":"s"]}),v.errors>0&&e.jsxs("span",{children:[e.jsx("strong",{children:v.errors})," error",v.errors===1?"":"s"]}),e.jsx("span",{className:"ml-auto opacity-70",children:"across all suites, lifetime totals from /metrics"})]}),l&&e.jsx("div",{className:"rounded border border-red-500/40 bg-red-500/10 p-2 text-xs text-red-300",children:l}),x.length===0&&!l&&e.jsxs("div",{className:"rounded border border-dashed border-slate-700 bg-slate-800/20 p-6 text-center text-sm text-slate-400",children:["No eval pass-rate metrics yet. Run a suite via the Suites tab to populate ",e.jsx("code",{className:"font-mono",children:"titan_eval_pass_rate"}),"."]}),e.jsx("div",{className:"space-y-1.5",children:x.map(({suite:o,rate:d})=>{const t=g.get(o),m=N(d),h=L[o]??o;return e.jsx("div",{className:`rounded border p-2 text-xs ${y[m]}`,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-32 truncate font-medium text-slate-200",children:h}),e.jsx("div",{className:"relative h-4 flex-1 overflow-hidden rounded bg-slate-800/60",children:e.jsx("div",{className:`h-full ${m==="emerald"?"bg-emerald-500/60":m==="amber"?"bg-amber-500/60":m==="red"?"bg-red-500/60":"bg-slate-500/60"}`,style:{width:`${d/j*100}%`}})}),e.jsxs("div",{className:"w-16 text-right font-mono",children:[d,"%"]}),t&&e.jsxs("div",{className:"w-44 text-right text-[10px] text-slate-500",children:[t.passed,"/",t.passed+t.failed," ever",t.timeouts>0&&e.jsxs("span",{className:"ml-1 text-amber-400",children:["· ",t.timeouts," timeout",t.timeouts===1?"":"s"]}),t.errors>0&&e.jsxs("span",{className:"ml-1 text-red-400",children:["· ",t.errors," error",t.errors===1?"":"s"]})]})]})},o)})})]})}function V({suite:s,expanded:i,onToggle:a,onRun:n}){var b;const l=L[s.name]??s.name,c=s.result?O(s.result):NaN,r=N(c);return e.jsxs("div",{className:`rounded-lg border ${y[r]}`,children:[e.jsxs("div",{className:"flex items-center gap-3 p-3",children:[e.jsx("button",{onClick:a,disabled:!s.result,className:"text-slate-300 disabled:opacity-30","aria-label":i?"Collapse":"Expand",children:i?e.jsx(I,{className:"h-4 w-4"}):e.jsx(B,{className:"h-4 w-4"})}),e.jsx("div",{className:"font-medium text-slate-100",children:l}),e.jsx("div",{className:"text-xs text-slate-400",children:s.result?`${s.result.passed}/${s.result.total} (${c}%)`:s.status==="running"?"running…":s.status==="error"?`error: ${s.error}`:"idle"}),((b=s.result)==null?void 0:b.durationMs)!==void 0&&e.jsxs("div",{className:"text-xs text-slate-500",children:[(s.result.durationMs/1e3).toFixed(1),"s"]}),e.jsxs("button",{onClick:n,disabled:s.status==="running",className:"ml-auto flex items-center gap-1 rounded border border-slate-600 bg-slate-800/60 px-2 py-1 text-xs text-slate-200 hover:bg-slate-800 disabled:opacity-50",children:[s.status==="running"?e.jsx(M,{className:"h-3 w-3 animate-spin"}):e.jsx(A,{className:"h-3 w-3"}),"Run"]})]}),i&&s.result&&e.jsx("div",{className:"space-y-1.5 border-t border-slate-700/40 px-3 py-2",children:s.result.results.map(u=>e.jsx(X,{caseResult:u},u.name))})]})}function X({caseResult:s}){const i=s.expectedToolSequence!==void 0&&JSON.stringify(s.expectedToolSequence)!==JSON.stringify(s.toolsUsed);return e.jsxs("div",{className:`rounded p-2 text-xs ${s.passed?"bg-slate-800/30":"bg-red-950/30"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[s.passed?e.jsx(R,{className:"h-3.5 w-3.5 text-emerald-400"}):e.jsx(C,{className:"h-3.5 w-3.5 text-red-400"}),e.jsx("div",{className:"font-mono text-slate-200",children:s.name}),e.jsxs("div",{className:"ml-auto text-slate-500",children:[s.durationMs,"ms"]})]}),!s.passed&&s.errors.length>0&&e.jsx("ul",{className:"mt-1 ml-5 list-disc text-red-300",children:s.errors.map((a,n)=>e.jsx("li",{children:a},n))}),i&&e.jsxs("div",{className:"mt-2 ml-5 grid grid-cols-2 gap-2 rounded bg-slate-900/40 p-2",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1 text-slate-400",children:[e.jsx(k,{className:"h-3 w-3"})," expected"]}),(s.expectedToolSequence??[]).map((a,n)=>e.jsxs("div",{className:"font-mono text-emerald-300",children:[n+1,". ",a]},n))]}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1 flex items-center gap-1 text-slate-400",children:[e.jsx(k,{className:"h-3 w-3"})," actual"]}),s.toolsUsed.length===0&&e.jsx("div",{className:"italic text-slate-500",children:"(no tool calls)"}),s.toolsUsed.map((a,n)=>{var r;const c=((r=s.expectedToolSequence)==null?void 0:r[n])===a;return e.jsxs("div",{className:`font-mono ${c?"text-emerald-300":"text-red-300"}`,children:[n+1,". ",a]},n)})]})]})]})}export{ye as default};
@@ -0,0 +1 @@
1
+ import{r as a,bg as u,bh as j,bi as p,j as e,e as N,T as v,bj as y}from"./index-DzwowwSI.js";import{P as T}from"./PageHeader-CnZtP8ek.js";import{R as w}from"./terminal-BtiqJ628.js";import{P as k}from"./play-DVY9c5Ck.js";import"./chevron-right-aQEw2mUW.js";function E(){const[t,x]=a.useState(null),[r,o]=a.useState([]),[i,b]=a.useState([]),[d,n]=a.useState(!0),[c,m]=a.useState(!1),l=a.useCallback(async()=>{n(!0);try{const[s,h,f]=await Promise.all([u(),j(),p()]);x(s),o(h.tests||[]),b(f.tests||[])}catch{}n(!1)},[]);a.useEffect(()=>{l()},[l]);const g=async()=>{m(!0);try{await y(),await l()}catch{}m(!1)};return e.jsxs("div",{className:"space-y-4",children:[e.jsx(T,{title:"Test Lab",breadcrumbs:[{label:"Admin",href:"/overview"},{label:"Quality"},{label:"Tests"}]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:l,disabled:d,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(w,{className:`w-4 h-4 ${d?"animate-spin":""}`})," Refresh"]}),e.jsxs("button",{onClick:g,disabled:c,className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-[#6366f1] text-white text-sm font-medium hover:bg-[#4f46e5] disabled:opacity-50",children:[e.jsx(k,{className:"w-4 h-4"})," ",c?"Running...":"Run Tests"]})]}),t&&e.jsxs("div",{className:"grid grid-cols-4 gap-2",children:[e.jsxs("div",{className:"p-2 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[e.jsx("div",{className:"text-xs text-[#52525b]",children:"Total"}),e.jsx("div",{className:"text-sm font-semibold text-[#e4e4e7]",children:t.total})]}),e.jsxs("div",{className:"p-2 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[e.jsx("div",{className:"text-xs text-[#52525b]",children:"Passing"}),e.jsx("div",{className:"text-sm font-semibold text-emerald-400",children:t.passing})]}),e.jsxs("div",{className:"p-2 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[e.jsx("div",{className:"text-xs text-[#52525b]",children:"Failing"}),e.jsx("div",{className:"text-sm font-semibold text-red-400",children:t.failing})]}),e.jsxs("div",{className:"p-2 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[e.jsx("div",{className:"text-xs text-[#52525b]",children:"Flaky"}),e.jsx("div",{className:"text-sm font-semibold text-amber-400",children:t.flaky})]})]}),r.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"text-sm font-medium text-[#e4e4e7] flex items-center gap-2",children:[e.jsx(N,{className:"w-4 h-4 text-red-400"})," Failing Tests"]}),r.map(s=>e.jsxs("div",{className:"p-2 rounded-lg bg-red-950/20 border border-red-900/50",children:[e.jsx("div",{className:"text-xs text-[#e4e4e7]",children:s.name}),e.jsxs("div",{className:"text-xs text-[#52525b]",children:[s.suite," • ",s.error.slice(0,60)]})]},s.name))]}),i.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"text-sm font-medium text-[#e4e4e7] flex items-center gap-2",children:[e.jsx(v,{className:"w-4 h-4 text-amber-400"})," Flaky Tests"]}),i.map(s=>e.jsxs("div",{className:"p-2 rounded-lg bg-amber-950/20 border border-amber-900/50",children:[e.jsx("div",{className:"text-xs text-[#e4e4e7]",children:s.name}),e.jsxs("div",{className:"text-xs text-[#52525b]",children:[s.suite," • ",s.passRate.toFixed(1),"% pass rate"]})]},s.name))]})]})}export{E as default};