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,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SkillsPanel-BlAHFLcQ.js","assets/index-DzwowwSI.js","assets/index-BR0vfkIi.css","assets/PageHeader-CnZtP8ek.js","assets/chevron-right-aQEw2mUW.js","assets/search-0hXTwEZR.js","assets/trash-2-DgWrHVax.js","assets/download-DZRxDn67.js","assets/McpPanel-JKgtIERQ.js","assets/plug-BcXjlPUL.js","assets/terminal-BtiqJ628.js","assets/plus-Csu2v9GN.js","assets/TitanCanvas-BCbWnLMd.js","assets/chevron-up-C5g6pEj8.js","assets/users-dZgv4ePG.js","assets/wrench-CDz3xYve.js","assets/network-DbGDAdrn.js","assets/save-Btx-kpoW.js","assets/rotate-ccw-Co-_W04j.js","assets/send-TEpapzQR.js","assets/VoiceOverlay-D-gc58b0.js","assets/chevron-down-D7OLjvuD.js","assets/folder-DA43TRCm.js","assets/clock-CTsgP_Sn.js","assets/check-Bpm1IONe.js","assets/shield-check-DjBJXZUr.js","assets/external-link-BZ0y_Ahx.js","assets/loader-circle-1YOBsoQp.js","assets/TitanCanvas-BfitWg9R.css","assets/IntegrationsPanel-DsYpAq43.js","assets/circle-check-big-fPhEdP88.js","assets/eye-off-BmJF0YYx.js","assets/ChannelsPanel-DQjQCTK5.js","assets/MeshPanel-BJVGYvwk.js","assets/DataTable-CH7IYJJh.js","assets/EvalHarnessPanel-DnYqredY.js","assets/layers-DsyEyu7z.js","assets/trending-up-MpIrE4j6.js","assets/play-DVY9c5Ck.js"])))=>i.map(i=>d[i]);
2
+ import{r as l,j as e,l as n,_ as t}from"./index-DzwowwSI.js";const o=l.lazy(()=>t(()=>import("./SkillsPanel-BlAHFLcQ.js"),__vite__mapDeps([0,1,2,3,4,5,6,7]))),r=l.lazy(()=>t(()=>import("./McpPanel-JKgtIERQ.js"),__vite__mapDeps([8,1,2,9,10,11,12,13,14,15,16,17,18,5,19,20,4,21,22,23,24,25,26,27,28,6]))),c=l.lazy(()=>t(()=>import("./IntegrationsPanel-DsYpAq43.js"),__vite__mapDeps([29,1,2,9,30,31,12,13,11,14,15,16,10,17,18,5,19,20,4,21,22,23,24,25,26,27,28]))),d=l.lazy(()=>t(()=>import("./ChannelsPanel-DQjQCTK5.js"),__vite__mapDeps([32,1,2,3,4,10,30,21,31,12,13,11,14,15,16,17,18,5,19,20,22,23,24,25,26,27,28]))),x=l.lazy(()=>t(()=>import("./MeshPanel-BJVGYvwk.js"),__vite__mapDeps([33,1,2,34,10,25]))),m=l.lazy(()=>t(()=>import("./EvalHarnessPanel-DnYqredY.js"),__vite__mapDeps([35,1,2,36,12,13,11,14,15,16,10,17,18,5,19,20,4,21,22,23,24,25,26,27,28,37,38,30]))),_=[{id:"skills",label:"Skills"},{id:"mcp",label:"MCP Servers"},{id:"integrations",label:"Integrations"},{id:"channels",label:"Channels"},{id:"mesh",label:"Mesh Network"},{id:"evals",label:"Eval Harness"}];function p(){const[s,i]=l.useState("skills");return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"shrink-0 px-5 pt-4 pb-0",children:[e.jsx("h1",{className:"text-sm font-semibold text-text mb-3",children:"Tools & Connections"}),e.jsx("div",{className:"flex items-center gap-0.5 border-b border-border/50",children:_.map(a=>e.jsxs("button",{onClick:()=>i(a.id),className:n("px-3 py-2 text-xs font-medium transition-colors relative",s===a.id?"text-accent":"text-text-muted hover:text-text-secondary"),children:[a.label,s===a.id&&e.jsx("div",{className:"absolute bottom-0 left-1 right-1 h-[2px] bg-accent rounded-full"})]},a.id))})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto p-5",children:e.jsxs(l.Suspense,{fallback:e.jsx("div",{className:"skeleton-shimmer h-40 rounded-lg"}),children:[s==="skills"&&e.jsx(o,{}),s==="mcp"&&e.jsx(r,{}),s==="integrations"&&e.jsx(c,{}),s==="channels"&&e.jsx(d,{}),s==="mesh"&&e.jsx(x,{}),s==="evals"&&e.jsx(m,{})]})})]})}export{p as default};
@@ -1,4 +1,4 @@
1
- import{c as b,j as e,r as a}from"./index-CahJbWSR.js";/**
1
+ import{c as b,j as e,r as a}from"./index-DzwowwSI.js";/**
2
2
  * @license lucide-react v0.513.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -0,0 +1 @@
1
+ import{r as d,j as e,A as f,h as j,T as y,f as T,w as E,bw as $}from"./index-DzwowwSI.js";import{T as I}from"./trending-up-MpIrE4j6.js";import{W as w}from"./wrench-CDz3xYve.js";import{G as v}from"./git-branch-oHibJqDq.js";import{C as z}from"./clock-CTsgP_Sn.js";import{C as L}from"./chart-column-CdFlBpoP.js";import{S as A}from"./search-0hXTwEZR.js";import{A as F}from"./arrow-left-5chqas7J.js";function R(c){const a=c.toLowerCase();return a.includes("rate limit")||a.includes("too many requests")||a.includes("429")?{category:"Rate Limit",severity:"rate_limit",icon:"⏱️"}:a.includes("timeout")||a.includes("etimedout")||a.includes("econnreset")?{category:"Timeout",severity:"timeout",icon:"⏳"}:a.includes("auth")||a.includes("unauthorized")||a.includes("403")||a.includes("401")?{category:"Auth / Permission",severity:"permanent",icon:"🔒"}:a.includes("not found")||a.includes("404")||a.includes("enoent")?{category:"Not Found",severity:"permanent",icon:"❓"}:a.includes("context")||a.includes("too long")||a.includes("max tokens")?{category:"Context Overflow",severity:"permanent",icon:"📄"}:a.includes("quota")||a.includes("insufficient")||a.includes("exceeded")?{category:"Quota Exceeded",severity:"permanent",icon:"💰"}:a.includes("network")||a.includes("econnrefused")||a.includes("dns")?{category:"Network",severity:"transient",icon:"🌐"}:a.includes("empty")||a.includes("no response")?{category:"Empty Response",severity:"transient",icon:"👻"}:a.includes("format")||a.includes("json")||a.includes("parse")?{category:"Format Error",severity:"transient",icon:"🔧"}:{category:"Unknown",severity:"unknown",icon:"❓"}}const D={transient:"text-warning bg-warning/10 border-warning/20",permanent:"text-error bg-error/10 border-error/20",timeout:"text-cyan bg-cyan/10 border-cyan/20",rate_limit:"text-orange-400 bg-orange-400/10 border-orange-400/20",unknown:"text-text-muted bg-bg-tertiary border-border"};function B({traces:c,stats:a}){const l=d.useMemo(()=>c.filter(s=>s.status==="failed"&&s.error),[c]),x=d.useMemo(()=>{const s=new Map;for(const r of l){if(!r.error)continue;const{category:o,severity:i,icon:u}=R(r.error),p=s.get(o);p?(p.count++,p.examples.length<3&&p.examples.push(r.error)):s.set(o,{count:1,severity:i,icon:u,examples:[r.error]})}return Array.from(s.entries()).sort((r,o)=>o[1].count-r[1].count)},[l]),h=d.useMemo(()=>{const s=new Map;for(const r of c)for(const o of r.toolCalls){const i=s.get(o.tool)||{success:0,fail:0};o.success?i.success++:i.fail++,s.set(o.tool,i)}return Array.from(s.entries()).map(([r,{success:o,fail:i}])=>{const u=o+i;return{tool:r,success:o,fail:i,total:u,rate:u>0?Math.round(i/u*100):0}}).sort((r,o)=>o.fail-r.fail)},[c]),m=c.length,n=m>0?Math.round(l.length/m*100):0;return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[{icon:f,label:"Total",value:m,color:"text-accent"},{icon:j,label:"Failed",value:l.length,color:"text-error"},{icon:I,label:"Fail Rate",value:`${n}%`,color:n>20?"text-error":n>5?"text-warning":"text-success"},{icon:y,label:"Categories",value:x.length,color:"text-orange-400"}].map(s=>e.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(s.icon,{size:14,className:s.color}),e.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:s.label})]}),e.jsx("div",{className:"text-2xl font-bold text-text",children:s.value})]},s.label))}),x.length>0&&e.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 border-b border-border",children:[e.jsx(y,{size:14,className:"text-error"}),e.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"Hermes Error Taxonomy"})]}),e.jsx("div",{className:"divide-y divide-border",children:x.map(([s,r])=>e.jsxs("div",{className:"px-4 py-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm",children:r.icon}),e.jsx("span",{className:"text-[12px] font-medium text-text-secondary",children:s}),e.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded border capitalize ${D[r.severity]}`,children:r.severity})]}),e.jsxs("span",{className:"text-[11px] text-text-muted",children:[r.count," occurrence",r.count===1?"":"s"]})]}),r.examples.length>0&&e.jsx("div",{className:"space-y-0.5 mt-1.5",children:r.examples.map((o,i)=>e.jsx("div",{className:"text-[10px] text-text-muted font-mono truncate pl-5",children:o},i))})]},s))})]}),h.length>0&&e.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5 border-b border-border",children:[e.jsx(w,{size:14,className:"text-accent"}),e.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"Tool Failure Rates"})]}),e.jsx("div",{className:"divide-y divide-border",children:h.slice(0,15).map(s=>{const r=s.total>0?Math.round(s.fail/s.total*100):0;return e.jsxs("div",{className:"px-4 py-2 flex items-center gap-3",children:[e.jsx("span",{className:"text-[11px] text-text-secondary font-mono w-32 truncate",children:s.tool}),e.jsx("div",{className:"flex-1 h-1.5 bg-bg rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full ${r>50?"bg-error":r>10?"bg-warning":"bg-success"}`,style:{width:`${r}%`}})}),e.jsxs("div",{className:"text-[10px] text-text-muted w-20 text-right tabular-nums",children:[s.fail,"/",s.total," (",r,"%)"]})]},s.tool)})})]}),x.length===0&&h.every(s=>s.fail===0)&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-text-muted text-xs",children:[e.jsx(T,{size:24,className:"mb-2 text-success opacity-60"}),"No errors detected in recent traces"]})]})}function Q(){const[c,a]=d.useState([]),[l,x]=d.useState(null),[h,m]=d.useState(!0),[n,s]=d.useState(null),[r,o]=d.useState(""),[i,u]=d.useState("all"),p=async()=>{try{const t=await E(100);a(t.traces||[]),x(t.stats||null)}catch{}m(!1)};d.useEffect(()=>{p();const t=setInterval(p,1e4);return()=>clearInterval(t)},[]);const N=d.useMemo(()=>{let t=c;if(i!=="all"&&(t=t.filter(g=>g.status===i)),r.trim()){const g=r.toLowerCase();t=t.filter(b=>b.message.toLowerCase().includes(g)||b.sessionId.toLowerCase().includes(g)||b.traceId.toLowerCase().includes(g)||b.toolCalls.some(S=>S.tool.toLowerCase().includes(g)))}return t},[c,i,r]),k=c.filter(t=>t.status==="failed"),M=(l==null?void 0:l.avgDurationMs)??0,C=(l==null?void 0:l.topTools)??[];return h?e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"grid grid-cols-4 gap-3",children:[1,2,3,4].map(t=>e.jsx("div",{className:"h-20 rounded-xl bg-bg-secondary animate-pulse"},t))}),e.jsx("div",{className:"space-y-2",children:[1,2,3,4,5].map(t=>e.jsx("div",{className:"h-14 rounded-lg bg-bg-secondary animate-pulse"},t))})]}):n?e.jsx(q,{trace:n,onBack:()=>s(null)}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[{icon:v,label:"Traces",value:(l==null?void 0:l.totalTraces)??0,sub:"in memory",color:"text-accent"},{icon:f,label:"Running",value:(l==null?void 0:l.running)??0,sub:"active now",color:"text-cyan"},{icon:j,label:"Failed",value:k.length,sub:`${c.length>0?Math.round(k.length/c.length*100):0}% rate`,color:"text-error"},{icon:z,label:"Avg Duration",value:`${M}ms`,sub:`${(l==null?void 0:l.avgRounds)??0} avg rounds`,color:"text-warning"}].map(t=>e.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(t.icon,{size:14,className:t.color}),e.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider",children:t.label})]}),e.jsx("div",{className:"text-2xl font-bold text-text",children:t.value}),t.sub&&e.jsx("div",{className:"text-[11px] text-text-muted mt-1",children:t.sub})]},t.label))}),e.jsx(B,{traces:c,stats:l}),C.length>0&&e.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(L,{size:14,className:"text-accent"}),e.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"Top Tools"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:C.slice(0,8).map(t=>e.jsxs("span",{className:"text-[11px] px-2 py-1 rounded-full bg-bg border border-border text-text-secondary",children:[t.tool," ",e.jsxs("span",{className:"text-text-muted",children:["(",t.count,")"]})]},t.tool))})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[e.jsx(A,{size:14,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-text-muted"}),e.jsx("input",{value:r,onChange:t=>o(t.target.value),placeholder:"Search traces, sessions, tools...",className:"w-full bg-bg-secondary border border-border rounded-lg pl-8 pr-3 py-2 text-[12px] text-text placeholder-text-muted focus:outline-none focus:border-accent"})]}),e.jsx("div",{className:"flex gap-1",children:["all","running","completed","failed"].map(t=>e.jsx("button",{onClick:()=>u(t),className:`px-2.5 py-1.5 text-[10px] rounded-lg capitalize transition-colors ${i===t?"bg-accent text-white":"bg-bg-secondary text-text-muted hover:text-text"}`,children:t},t))})]}),e.jsxs("div",{className:"bg-bg-secondary border border-border rounded-2xl overflow-hidden",children:[e.jsx("div",{className:"flex items-center justify-between px-4 py-2.5 border-b border-border",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{size:14,className:"text-accent"}),e.jsx("span",{className:"text-[13px] font-medium text-text-secondary",children:"Execution Traces"}),e.jsx("span",{className:"text-[10px] text-text-muted",children:N.length})]})}),e.jsx("div",{className:"divide-y divide-border max-h-[500px] overflow-y-auto",children:N.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-text-muted text-xs",children:[e.jsx(v,{size:24,className:"mb-2 opacity-40"}),c.length===0?"No traces captured yet":"No traces match your filters"]}):N.map(t=>e.jsxs("button",{onClick:()=>s(t),className:"w-full text-left px-4 py-3 hover:bg-bg-secondary/30 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[t.status==="running"?e.jsx(f,{size:14,className:"text-cyan animate-pulse shrink-0"}):t.status==="completed"?e.jsx(T,{size:14,className:"text-success shrink-0"}):e.jsx(j,{size:14,className:"text-error shrink-0"}),e.jsx("p",{className:"text-[12px] text-text-secondary truncate flex-1",children:t.message}),e.jsx("span",{className:"text-[10px] text-text-muted shrink-0 tabular-nums",children:t.totalMs?`${t.totalMs}ms`:"..."})]}),e.jsxs("div",{className:"flex gap-3 mt-1 text-[10px] text-text-muted ml-6",children:[e.jsxs("span",{children:[t.toolCalls.length," tools"]}),e.jsxs("span",{children:[t.rounds," rounds"]}),t.model&&e.jsx("span",{children:t.model.split("/").pop()}),t.error&&e.jsx("span",{className:"text-error truncate max-w-[200px]",children:t.error})]})]},t.traceId))})]})]})}function q({trace:c,onBack:a}){const[l,x]=d.useState(null),[h,m]=d.useState(!0);d.useEffect(()=>{let s=!0;return $(c.traceId).then(r=>{s&&x(r)}).catch(()=>{s&&x(c)}).finally(()=>{s&&m(!1)}),()=>{s=!1}},[c.traceId,c]);const n=l||c;return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("button",{onClick:a,className:"flex items-center gap-1 text-[11px] text-text-muted hover:text-text transition-colors",children:[e.jsx(F,{size:12})," Back to traces"]}),e.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[n.status==="running"?e.jsx(f,{size:16,className:"text-cyan animate-pulse"}):n.status==="completed"?e.jsx(T,{size:16,className:"text-success"}):e.jsx(j,{size:16,className:"text-error"}),e.jsx("span",{className:`text-xs font-semibold capitalize ${n.status==="completed"?"text-success":n.status==="failed"?"text-error":"text-cyan"}`,children:n.status})]}),e.jsx("p",{className:"text-sm text-text mb-2",children:n.message}),e.jsxs("div",{className:"flex flex-wrap gap-3 text-[11px] text-text-muted",children:[e.jsxs("span",{children:["ID: ",e.jsx("span",{className:"font-mono text-text-secondary",children:n.traceId.slice(0,12)})]}),e.jsxs("span",{children:["Session: ",e.jsx("span",{className:"font-mono text-text-secondary",children:n.sessionId.slice(0,12)})]}),n.totalMs&&e.jsxs("span",{children:[n.totalMs,"ms"]}),e.jsxs("span",{children:[n.rounds," rounds"]}),n.model&&e.jsx("span",{children:n.model}),n.tokens&&e.jsxs("span",{children:[n.tokens.prompt," prompt / ",n.tokens.completion," completion"]})]})]}),n.spans.length>0&&e.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(z,{size:14,className:"text-accent"}),e.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"Timeline"})]}),e.jsx("div",{className:"space-y-2",children:n.spans.map((s,r)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-16 text-[10px] text-text-muted text-right tabular-nums",children:s.durationMs!==void 0?`${s.durationMs}ms`:"..."}),e.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-accent shrink-0"}),e.jsx("span",{className:"text-[11px] text-text-secondary font-mono",children:s.name}),s.data&&Object.keys(s.data).length>0&&e.jsx("span",{className:"text-[10px] text-text-muted truncate max-w-[200px]",children:JSON.stringify(s.data).slice(0,60)})]},r))})]}),n.toolCalls.length>0&&e.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(w,{size:14,className:"text-accent"}),e.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"Tool Calls"})]}),e.jsx("div",{className:"space-y-2",children:n.toolCalls.map((s,r)=>e.jsxs("div",{className:"flex items-center gap-3 px-2.5 py-2 rounded-lg bg-bg border border-border",children:[e.jsx(w,{size:12,className:s.success?"text-success shrink-0":"text-error shrink-0"}),e.jsx("span",{className:"text-[11px] text-text-secondary font-mono",children:s.tool}),e.jsxs("span",{className:"text-[10px] text-text-muted",children:[s.durationMs,"ms"]}),e.jsxs("span",{className:"text-[10px] text-text-muted",children:["round ",s.round]}),!s.success&&e.jsx("span",{className:"text-[10px] text-error ml-auto",children:"failed"})]},r))})]}),n.error&&e.jsxs("div",{className:"bg-error/5 border border-error/20 rounded-xl p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(y,{size:14,className:"text-error"}),e.jsx("span",{className:"text-xs font-semibold text-error",children:"Error"})]}),e.jsx("div",{className:"text-[11px] text-text-secondary font-mono whitespace-pre-wrap",children:n.error})]})]})}export{Q as default};
@@ -0,0 +1 @@
1
+ import{r as a,aX as c,aY as x,j as e}from"./index-DzwowwSI.js";import{P as p}from"./PageHeader-CnZtP8ek.js";import{R as g}from"./terminal-BtiqJ628.js";import{D as b}from"./download-DZRxDn67.js";import{a as f}from"./TitanCanvas-BCbWnLMd.js";import"./chevron-right-aQEw2mUW.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-down-D7OLjvuD.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";function Y(){const[t,d]=a.useState(null),[o,n]=a.useState([]),[i,l]=a.useState(!0),r=a.useCallback(async()=>{l(!0);try{const[s,m]=await Promise.all([c(),x()]);d(s),n(m.runs||[])}catch{}l(!1)},[]);return a.useEffect(()=>{r()},[r]),e.jsxs("div",{className:"space-y-4",children:[e.jsx(p,{title:"Training Dashboard",breadcrumbs:[{label:"Admin",href:"/overview"},{label:"Intelligence"},{label:"Training"}]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:r,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(g,{className:`w-4 h-4 ${i?"animate-spin":""}`})," Refresh"]}),e.jsxs("a",{href:"/api/training/export",download:!0,className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-[#27272a] text-[#a1a1aa] text-sm font-medium hover:bg-[#3f3f46]",children:[e.jsx(b,{className:"w-4 h-4"})," Export"]})]}),t&&e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"p-3 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[e.jsx("div",{className:"text-xs text-[#52525b]",children:"Entries"}),e.jsx("div",{className:"text-lg font-semibold text-[#e4e4e7]",children:t.entries})]}),e.jsxs("div",{className:"p-3 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[e.jsx("div",{className:"text-xs text-[#52525b]",children:"Size (bytes)"}),e.jsx("div",{className:"text-lg font-semibold text-[#e4e4e7]",children:t.sizeBytes})]}),e.jsxs("div",{className:"p-3 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[e.jsx("div",{className:"text-xs text-[#52525b]",children:"Last Capture"}),e.jsx("div",{className:"text-lg font-semibold text-[#e4e4e7]",children:t.lastCapture?new Date(t.lastCapture).toLocaleString():"—"})]})]}),e.jsx("div",{className:"space-y-2",children:o.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(f,{className:`w-4 h-4 ${s.status==="running"?"text-amber-400":s.status==="completed"?"text-emerald-400":"text-red-400"}`}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm text-[#e4e4e7]",children:[s.type," — ",s.id.slice(0,8)]}),e.jsxs("div",{className:"text-xs text-[#52525b]",children:[s.examplesProcessed," examples • ",s.status]})]})]}),e.jsx("div",{className:"text-xs text-[#52525b]",children:new Date(s.startedAt).toLocaleDateString()})]},s.id))})]})}export{Y as default};
@@ -0,0 +1,27 @@
1
+ import{c as de,r as e,j as n,b as le,m as $e,X as De,F as Pe}from"./index-DzwowwSI.js";import{C as Ue}from"./chevron-right-aQEw2mUW.js";import{C as Fe}from"./chevron-down-D7OLjvuD.js";/**
2
+ * @license lucide-react v0.513.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const Be=[["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}],["path",{d:"M18.89 13.23A7.12 7.12 0 0 0 19 12v-2",key:"80xlxr"}],["path",{d:"M5 10v2a7 7 0 0 0 12 5",key:"p2k8kg"}],["path",{d:"M15 9.34V5a3 3 0 0 0-5.68-1.33",key:"1gzdoj"}],["path",{d:"M9 9v3a3 3 0 0 0 5.12 2.12",key:"r2i35w"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]],ze=de("mic-off",Be);/**
7
+ * @license lucide-react v0.513.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const qe=[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]],Je=de("mic",qe);/**
12
+ * @license lucide-react v0.513.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const He=[["path",{d:"M10.1 13.9a14 14 0 0 0 3.732 2.668 1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2 18 18 0 0 1-12.728-5.272",key:"1wngk7"}],["path",{d:"M22 2 2 22",key:"y4kqgn"}],["path",{d:"M4.76 13.582A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 .244.473",key:"10hv5p"}]],Xe=de("phone-off",He);/**
17
+ * @license lucide-react v0.513.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const Qe=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]],Ze=de("volume-2",Qe);function Ge({messages:u=[],isListening:f=!1}){const i=e.useRef(null);return e.useEffect(()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight)},[u.length]),n.jsxs("div",{ref:i,className:"w-full max-w-lg overflow-y-auto rounded-xl backdrop-blur",style:{maxHeight:300,backgroundColor:"rgba(24, 24, 27, 0.5)",padding:"1rem"},children:[u.length===0&&!f&&n.jsx("p",{className:"text-center text-sm text-text-muted",children:"Start speaking to begin the conversation"}),n.jsx("div",{className:"flex flex-col gap-2",children:u.map(s=>n.jsx("div",{className:`flex ${s.role==="user"?"justify-end":"justify-start"}`,children:n.jsx("div",{className:"max-w-[80%] rounded-lg px-3 py-2 text-sm",style:{backgroundColor:s.role==="user"?"var(--color-accent)":"var(--color-bg-tertiary)",color:"var(--color-text)"},children:s.text})},s.id))}),f&&n.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[n.jsx("span",{className:"inline-block h-2 w-2 rounded-full",style:{backgroundColor:"var(--color-accent)",animation:"listeningPulse 1s ease-in-out infinite"}}),n.jsx("span",{className:"text-xs text-text-secondary",children:"Listening..."}),n.jsx("style",{children:`
22
+ @keyframes listeningPulse {
23
+ 0%, 100% { opacity: 1; transform: scale(1); }
24
+ 50% { opacity: 0.4; transform: scale(0.8); }
25
+ }
26
+ `})]})]})}const Ce={default:{name:"Default",description:"F5-TTS base voice",gradient:"radial-gradient(circle at 35% 35%, #c084fc, #a855f7, #7c3aed)",glow:"#a855f7"}},ne=[{gradient:"radial-gradient(circle at 35% 35%, #93c5fd, #3b82f6, #1d4ed8)",glow:"#3b82f6"},{gradient:"radial-gradient(circle at 35% 35%, #fbbf24, #f59e0b, #b45309)",glow:"#f59e0b"},{gradient:"radial-gradient(circle at 35% 35%, #5eead4, #14b8a6, #0f766e)",glow:"#14b8a6"},{gradient:"radial-gradient(circle at 35% 35%, #fda4af, #fb7185, #e11d48)",glow:"#fb7185"},{gradient:"radial-gradient(circle at 35% 35%, #a5b4fc, #818cf8, #4f46e5)",glow:"#818cf8"},{gradient:"radial-gradient(circle at 35% 35%, #fdba74, #f97316, #c2410c)",glow:"#f97316"},{gradient:"radial-gradient(circle at 35% 35%, #86efac, #22c55e, #15803d)",glow:"#22c55e"},{gradient:"radial-gradient(circle at 35% 35%, #67e8f9, #22d3ee, #0891b2)",glow:"#22d3ee"}];function ue(u){return u.map((f,i)=>{const s=Ce[f];if(s)return{id:f,...s};const j=ne[i%ne.length],E=f.charAt(0).toUpperCase()+f.slice(1);return{id:f,name:E,description:"Cloned voice",gradient:j.gradient,glow:j.glow}})}function ie(u){const f=Ce[u];if(f)return{name:f.name,glow:f.glow};const i=ne.findIndex((j,E)=>E===u.length%ne.length),s=ne[i>=0?i:0];return{name:u.charAt(0).toUpperCase()+u.slice(1),glow:s.glow}}function We({currentVoice:u,onSelect:f,onPreview:i}){const[s,j]=e.useState([]),[E,A]=e.useState(!0),[h,V]=e.useState(0),[x,B]=e.useState(!1),[I,R]=e.useState(0),M=e.useRef(0),_=e.useRef(null);e.useEffect(()=>{(async()=>{var l;A(!0);try{const y=await le("/api/voice/voices");if(y.ok){const S=await y.json(),g=(l=S.voices)!=null&&l.length?S.voices:["default"],$=ue(g);if(j($),u){const re=$.findIndex(G=>G.id===u);re>=0&&V(re)}}else j(ue(["default"]))}catch{j(ue(["default"]))}finally{A(!1)}})()},[]);const p=s[h]||s[0],T=e.useCallback(l=>{V(Math.max(0,Math.min(s.length-1,l)))},[s.length]),L=e.useCallback(()=>T(h-1),[h,T]),N=e.useCallback(()=>T(h+1),[h,T]);e.useEffect(()=>{const l=y=>{y.key==="ArrowLeft"&&L(),y.key==="ArrowRight"&&N(),y.key==="Enter"&&f(s[h].id)};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[h,L,N,f,s]);const z=l=>{B(!0),M.current=l.clientX,R(0)},O=l=>{x&&R(l.clientX-M.current)},b=()=>{x&&(B(!1),I>60?L():I<-60&&N(),R(0))};return E||s.length===0?n.jsxs("div",{className:"flex flex-col items-center justify-center h-full select-none",children:[n.jsx("div",{className:"w-8 h-8 border-2 border-accent border-t-transparent rounded-full animate-spin mb-4"}),n.jsx("p",{className:"text-sm text-text-muted",children:"Loading voices..."})]}):n.jsxs("div",{className:"flex flex-col items-center justify-center h-full select-none",children:[n.jsx("h2",{className:"text-xl font-semibold text-text mb-2",children:"Choose a voice"}),n.jsx("p",{className:"text-sm text-text-muted mb-10",children:s.length>1?`${s.length} cloned voices available`:"Swipe or use arrow keys"}),n.jsxs("div",{ref:_,className:"relative flex items-center justify-center w-full",style:{height:280,touchAction:"pan-y"},onPointerDown:z,onPointerMove:O,onPointerUp:b,onPointerLeave:b,children:[h>0&&n.jsx("button",{onClick:L,className:"absolute left-4 z-10 rounded-full p-2 text-text-muted hover:text-text hover:bg-bg-tertiary transition-colors",children:n.jsx($e,{size:28})}),n.jsx("div",{className:"relative",style:{width:220,height:220},children:s.map((l,y)=>{const S=y-h,g=y===h,$=x?I*.3:0;return n.jsxs("div",{className:"absolute inset-0 transition-all",style:{transitionDuration:x?"0ms":"400ms",transitionTimingFunction:"cubic-bezier(0.4, 0, 0.2, 1)",transform:`translateX(${S*260+$}px) scale(${g?1:.7})`,opacity:Math.abs(S)>1?0:g?1:.4,zIndex:g?10:1,pointerEvents:g?"auto":"none"},children:[n.jsx("div",{className:"absolute inset-0 rounded-full blur-2xl transition-opacity duration-500",style:{background:l.glow,opacity:g?.3:0,transform:"scale(1.2)"}}),n.jsx("div",{className:"w-full h-full rounded-full shadow-2xl",style:{background:l.gradient,boxShadow:g?`0 0 60px ${l.glow}40`:"none"}}),n.jsx("div",{className:"absolute rounded-full",style:{top:"12%",left:"18%",width:"35%",height:"35%",background:"radial-gradient(circle, rgba(255,255,255,0.4) 0%, transparent 70%)"}})]},l.id)})}),h<s.length-1&&n.jsx("button",{onClick:N,className:"absolute right-4 z-10 rounded-full p-2 text-text-muted hover:text-text hover:bg-bg-tertiary transition-colors",children:n.jsx(Ue,{size:28})})]}),n.jsxs("div",{className:"mt-8 text-center",children:[n.jsx("h3",{className:"text-2xl font-bold text-text mb-1",children:p.name}),n.jsx("p",{className:"text-sm text-text-secondary",children:p.description})]}),i&&n.jsxs("button",{onClick:()=>i(p.id),className:"mt-4 flex items-center gap-2 rounded-full px-4 py-2 text-xs font-medium text-text-secondary hover:text-text hover:bg-bg-tertiary transition-colors",children:[n.jsx(Ze,{size:14}),"Preview"]}),n.jsx("div",{className:"flex items-center gap-2 mt-6",children:s.map((l,y)=>n.jsx("button",{onClick:()=>T(y),className:"rounded-full transition-all duration-300",style:{width:y===h?10:6,height:y===h?10:6,backgroundColor:y===h?p.glow:"var(--color-border)",boxShadow:y===h?`0 0 8px ${p.glow}80`:"none"}},l.id))}),n.jsxs("button",{onClick:()=>f(p.id),className:"mt-10 w-72 rounded-full py-3.5 text-base font-semibold transition-all duration-200",style:{background:`linear-gradient(135deg, ${p.glow}30, ${p.glow}15)`,border:`1px solid ${p.glow}40`,color:"var(--color-text)"},onMouseEnter:l=>{l.currentTarget.style.background=`linear-gradient(135deg, ${p.glow}50, ${p.glow}25)`,l.currentTarget.style.boxShadow=`0 0 20px ${p.glow}30`},onMouseLeave:l=>{l.currentTarget.style.background=`linear-gradient(135deg, ${p.glow}30, ${p.glow}15)`,l.currentTarget.style.boxShadow="none"},children:["Start with ",p.name]})]})}ue(["default"]);const Ye="/ollama",Ke="kimi-k2.6:cloud";function et(u,f){const i=[];i.push({role:"system",content:f});for(const s of u)s.role==="framework"?i.push({role:"user",content:s.content}):i.push({role:s.role,content:s.content});return i}async function tt(u,f,i,s){var R,M,_,p,T,L,N,z,O;const j=(s==null?void 0:s.model)||Ke,E=et(u,f),A=await fetch(`${Ye}/api/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:j,messages:E,stream:!0}),signal:s!=null&&s.signal?AbortSignal.any([s.signal,AbortSignal.timeout(12e4)]):AbortSignal.timeout(12e4)});if(!A.ok){const b=await A.text().catch(()=>A.statusText);throw new Error(`Ollama error ${A.status}: ${b}`)}if(!A.body)throw new Error("No response body from Ollama");const h=A.body.getReader(),V=new TextDecoder;let x="",B="",I="";try{for(;;){const{done:b,value:l}=await h.read();if(b)break;x+=V.decode(l,{stream:!0});const y=x.split(`
27
+ `);x=y.pop()||"";for(const S of y)if(S.trim())try{const g=JSON.parse(S);if((R=g.message)!=null&&R.thinking&&(I+=g.message.thinking,(M=i.onThinking)==null||M.call(i,g.message.thinking)),(_=g.message)!=null&&_.content&&(B+=g.message.content,i.onToken(g.message.content)),g.done){(p=i.onDone)==null||p.call(i,{totalDuration:g.total_duration||0,promptTokens:g.prompt_eval_count||0,evalTokens:g.eval_count||0});return}}catch{}}if(x+=V.decode(),x.trim())try{const b=JSON.parse(x.trim());if((T=b.message)!=null&&T.content&&i.onToken(b.message.content),(L=b.message)!=null&&L.thinking&&((N=i.onThinking)==null||N.call(i,b.message.thinking)),b.done){(z=i.onDone)==null||z.call(i,{totalDuration:b.total_duration||0,promptTokens:b.prompt_eval_count||0,evalTokens:b.eval_count||0});return}}catch{}(O=i.onDone)==null||O.call(i,{totalDuration:0,promptTokens:0,evalTokens:0})}finally{h.releaseLock()}}let nt=0;const ye=()=>`voice-msg-${Date.now()}-${++nt}`,je=u=>u.replace(/<(?:laugh|chuckle|sigh|cough|sniffle|groan|yawn|gasp)>/gi,"").replace(/\s{2,}/g," ").trim(),Ae=u=>u.replace(/```[\s\S]*?```/g,"").replace(/\*\*(.*?)\*\*/g,"$1").replace(/\*(.*?)\*/g,"$1").replace(/^#+\s+/gm,"").replace(/^[-*]\s+/gm,"").replace(/\n{2,}/g," ").trim(),Se=u=>u.replace(/(?:Let me |I'll |I will |I'm going to )(?:use|call|check|run|invoke|execute|try)(?: the)? \w[\w_]*(?: tool)?(?:\s+(?:to|for|and)\b[^.!?]*)?[.!]?\s*/gi,"").replace(/\b(?:Using|Calling|Running|Checking|Invoking|Executing) (?:the )?\w[\w_]*(?: tool)?(?:\s+(?:to|for)\b[^.!?]*)?[.!]?\s*/gi,"").replace(/\b\w[\w_]*(?:_\w+)+\b/g,"").replace(/\s{2,}/g," ").trim();function rt({onClose:u}){const[f,i]=e.useState(!1),s=localStorage.getItem("titan-voice")||"",[j,E]=e.useState(s?"active":"picking"),[A,h]=e.useState(s),V=e.useRef(s),[x,B]=e.useState(!1),[I,R]=e.useState(!1),[M,_]=e.useState(!1),[p,T]=e.useState(!1),[L,N]=e.useState([]),[z,O]=e.useState(0),[b,l]=e.useState(""),[y,S]=e.useState(null),[g,$]=e.useState(!1),[re,G]=e.useState([]),C=e.useRef(null),W=e.useRef(null),we=e.useRef(null),oe=e.useRef(null),U=e.useRef(null),q=e.useRef(""),se=e.useRef(0);e.useRef(void 0);const J=e.useRef(null),D=e.useRef(null),F=e.useRef(null),Y=e.useRef(null),H=e.useRef(null),ve=e.useRef(0),X=e.useRef(!1),fe=e.useRef(null);e.useRef(typeof navigator<"u"&&/iPad|iPhone|iPod/.test(navigator.userAgent));const ge=e.useCallback(t=>new Promise(async r=>{var o,m;const a=F.current;if(a&&a.state!=="closed")try{a.state==="suspended"&&await a.resume();const w=await(await fetch(t)).arrayBuffer(),v=await a.decodeAudioData(w);try{(o=Y.current)==null||o.stop()}catch{}const k=a.createBufferSource();k.buffer=v,k.connect(a.destination),Y.current=k,k.onended=()=>{URL.revokeObjectURL(t),r()},k.start(0);try{(m=C.current)==null||m.stop()}catch{}console.log("[Voice] Playing via Web Audio API");return}catch(c){console.warn("[Voice] Web Audio failed:",c)}try{const c=D.current||new Audio;D.current=c,c.setAttribute("playsinline",""),c.setAttribute("autoplay",""),J.current=c,c.onplay=()=>{var w;try{(w=C.current)==null||w.stop()}catch{}},c.onended=()=>{URL.revokeObjectURL(t),r()},c.onerror=w=>{console.warn("[Voice] Audio element error:",w),URL.revokeObjectURL(t),r()},c.src=t,await c.play(),console.log("[Voice] Playing via Audio element")}catch(c){console.warn("[Voice] Audio element play failed:",c),URL.revokeObjectURL(t),r()}}),[]),K=e.useRef(!1),me=e.useRef(!1),Q=e.useRef("picking");e.useEffect(()=>{K.current=x},[x]),e.useEffect(()=>{me.current=M},[M]),e.useEffect(()=>{Q.current=j},[j]),e.useEffect(()=>{(async()=>{var t;try{const r=await le("/api/voice/voices");if(r.ok){const a=await r.json();if((t=a.voices)!=null&&t.length){if(G(a.voices),s&&!a.voices.includes(s)){const o=a.voices[0];h(o),V.current=o,localStorage.setItem("titan-voice",o)}}else G(["default"])}}catch{G(["default"])}})()},[]),e.useEffect(()=>{requestAnimationFrame(()=>i(!0))},[]),e.useEffect(()=>()=>{var t,r,a,o;Q.current="picking";try{(t=C.current)==null||t.stop()}catch{}C.current=null,(r=oe.current)==null||r.getTracks().forEach(m=>m.stop()),(a=W.current)==null||a.close(),(o=H.current)==null||o.abort(),U.current&&clearTimeout(U.current),fe.current&&(clearInterval(fe.current),fe.current=null),cancelAnimationFrame(se.current),cancelAnimationFrame(ve.current)},[]),e.useEffect(()=>{if(!g)return;const t=()=>$(!1),r=setTimeout(()=>document.addEventListener("click",t),0);return()=>{clearTimeout(r),document.removeEventListener("click",t)}},[g]);const ee=e.useCallback(async()=>{var t;try{let r=function(){c.getByteFrequencyData(w);let v=0;for(let d=0;d<w.length;d++)v+=w[d];const k=v/w.length/255;O(k),se.current=requestAnimationFrame(r)};if(!((t=navigator.mediaDevices)!=null&&t.getUserMedia)){console.warn("[Voice] getUserMedia not available — may need HTTPS on mobile");return}const a=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}});oe.current=a;let o=W.current;(!o||o.state==="closed")&&(o=new(window.AudioContext||window.webkitAudioContext)),o.state==="suspended"&&await o.resume(),W.current=o;const m=o.createMediaStreamSource(a),c=o.createAnalyser();c.fftSize=256,c.smoothingTimeConstant=.8,m.connect(c),we.current=c;const w=new Uint8Array(c.frequencyBinCount);se.current=requestAnimationFrame(r)}catch(r){console.error("Mic access denied:",r)}},[]),ae=e.useCallback(()=>{var t,r;cancelAnimationFrame(se.current),cancelAnimationFrame(ve.current),(t=oe.current)==null||t.getTracks().forEach(a=>a.stop()),(r=W.current)==null||r.close(),oe.current=null,W.current=null,we.current=null,O(0)},[]),he=e.useCallback(()=>{var a;const t=window.SpeechRecognition||window.webkitSpeechRecognition;if(!t){console.error("Speech recognition not supported");return}try{(a=C.current)==null||a.stop()}catch{}const r=new t;r.continuous=!0,r.interimResults=!0,r.lang="en-US",r.onresult=o=>{if(me.current)return;let m="",c="";for(let w=o.resultIndex;w<o.results.length;w++){const v=o.results[w];v[0].confidence>0&&v[0].confidence<.5||(v.isFinal?c+=v[0].transcript:m+=v[0].transcript)}if(m&&l(m),c){q.current+=c,l(""),U.current&&clearTimeout(U.current);const v=q.current.trim().split(/\s+/).length<10?400:700;U.current=setTimeout(()=>{const k=q.current.trim();k&&(q.current="",Re(k))},v)}},r.onend=()=>{if(!K.current&&!me.current&&Q.current==="active")try{r.start()}catch{}R(!1)},r.onstart=()=>{R(!0)},r.onerror=o=>{console.error("Speech recognition error:",o.error),o.error==="not-allowed"?(S("Mic access denied — check browser permissions"),R(!1)):o.error==="network"?(S("Speech recognition network error"),setTimeout(()=>{if(!K.current&&Q.current==="active")try{r.start()}catch{}},2e3)):o.error==="audio-capture"?(S("Mic not available — is another app using it?"),R(!1)):o.error!=="no-speech"&&console.error("STT error:",o.error)},C.current=r;try{r.start()}catch{}},[]),ce=e.useCallback(()=>{var r;try{(r=Y.current)==null||r.stop()}catch{}Y.current=null;const t=J.current;t&&(t.pause(),t.src="",J.current=null),"speechSynthesis"in window&&window.speechSynthesis.cancel(),_(!1),O(0)},[]);e.useEffect(()=>{if(s&&j==="active"){try{new Audio("data:audio/wav;base64,UklGRiQAAABXQVZFZm10IBAAAAABAAEARKwAAIhYAQACABAAZGF0YQAAAAA=").play().catch(()=>{})}catch{}ee(),he()}},[]),e.useCallback(()=>{const t=[];let r=0,a=!1,o=!1,m=null,c=null;const w=setInterval(()=>{a||O(.3+Math.random()*.4)},100),v=()=>{clearInterval(w),O(0)},k=()=>{if(a){v();return}if(r<t.length){const d=t[r++];ge(d).then(()=>k()).catch(()=>k())}else o?(v(),m&&m()):c=k};return{push(d){if(t.push(d),c){const Z=c;c=null,Z()}},finish(){if(o=!0,c){const d=c;c=null,d()}},start(d){m=d,k()},cancel(){var d;a=!0;try{(d=Y.current)==null||d.stop()}catch{}J.current&&(J.current.pause(),J.current.src=""),v()},get length(){return t.length}}},[]);const Re=e.useCallback(async t=>{var c,w,v,k;if(X.current)return;X.current=!0,ce(),(c=H.current)==null||c.abort(),N(d=>[...d,{id:ye(),role:"user",text:t}]),T(!0),R(!1),S(null);try{(w=C.current)==null||w.stop()}catch{}const r=new AbortController;H.current=r;const a=V.current||"default";let o="",m="";try{const d=L.map(P=>({role:P.role,content:P.text,timestamp:(P.id,Date.now())}));await tt([...d,{role:"user",content:t,timestamp:Date.now()}],"You are TITAN, a helpful AI assistant. Keep responses concise and natural for voice conversation. Use short sentences.",{onToken:P=>{m+=P;const ke=Se(je(Ae(m)));o?N(pe=>pe.map(xe=>xe.id===o?{...xe,text:ke}:xe)):(o=ye(),N(pe=>[...pe,{id:o,role:"assistant",text:ke}])),T(!1)}},{signal:r.signal});const Z=Se(je(Ae(m)));if(!Z){X.current=!1;try{(v=C.current)==null||v.start()}catch{}return}_(!0);const te=await fetch("/api/voice/preview",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:Z.slice(0,500),voice:a}),signal:AbortSignal.timeout(12e4)});if(!te.ok)throw new Error(`F5-TTS error: ${te.status}`);const Ie=await te.blob(),_e=URL.createObjectURL(Ie);await ge(_e),_(!1),O(0),q.current="",setTimeout(()=>{var P;if(X.current=!1,!K.current&&Q.current==="active")try{(P=C.current)==null||P.start()}catch{}},500)}catch(d){if((d==null?void 0:d.name)==="AbortError"&&!H.current)return;const Z=(d==null?void 0:d.name)==="AbortError"?"Request timed out":"Connection error";S(Z),setTimeout(()=>S(null),4e3),console.error("Voice processing error:",d),N(te=>[...te,{id:ye(),role:"assistant",text:"Sorry, something went wrong."}]),T(!1),_(!1),q.current="",X.current=!1;try{(k=C.current)==null||k.start()}catch{}}},[ce,ge,L]),Te=e.useCallback(async t=>{h(t),V.current=t,localStorage.setItem("titan-voice",t);try{await le("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({voice:{ttsVoice:t}})})}catch{}if(E("active"),!F.current||F.current.state==="closed"){const r=window.AudioContext||window.webkitAudioContext;F.current=new r}F.current.state==="suspended"&&F.current.resume().catch(()=>{});try{const r=F.current,a=r.createBuffer(1,1,22050),o=r.createBufferSource();o.buffer=a,o.connect(r.destination),o.start(0)}catch{}D.current||(D.current=new Audio,D.current.preload="auto"),ee(),he()},[ee,he]),Ne=e.useCallback(t=>{h(t),V.current=t,localStorage.setItem("titan-voice",t),$(!1),le("/api/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({voice:{ttsVoice:t}})}).catch(()=>{})},[]),Me=e.useCallback(async t=>{try{const r=await fetch("/api/voice/preview",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:"Hey! I'm TITAN, your AI assistant.",voice:t})});if(!r.ok)return;const a=await r.blob(),o=URL.createObjectURL(a),m=D.current||new Audio,c=()=>{URL.revokeObjectURL(o),m.src=""};m.onended=c,m.onerror=c,m.play()}catch{}},[]),be=e.useCallback(()=>{var t,r;i(!1),Q.current="picking",E("picking"),(t=H.current)==null||t.abort(),H.current=null;try{(r=C.current)==null||r.stop()}catch{}C.current=null,ce(),ae(),U.current&&clearTimeout(U.current),X.current=!1,setTimeout(u,200)},[u,ae,ce]),Le=e.useCallback(()=>{B(t=>{var a,o;const r=!t;if(K.current=r,r){try{(a=C.current)==null||a.stop()}catch{}ae(),R(!1)}else{ee();try{(o=C.current)==null||o.start()}catch{}}return r})},[ee,ae]),Oe=M?"assistant":p?"thinking":I?"user":"idle",Ee=x?"Muted":M?"TITAN is speaking...":p?"Thinking...":I?b?`"${b}"`:"Listening...":"Connected",Ve=M?"var(--color-purple-light)":p?"var(--color-warning)":I?"var(--color-cyan)":"var(--color-text-muted)";return n.jsxs(n.Fragment,{children:[n.jsx("audio",{ref:t=>{t&&!D.current&&(D.current=t)},autoPlay:!0,playsInline:!0,style:{position:"absolute",width:0,height:0,opacity:0}}),n.jsxs("div",{className:"fixed inset-0 z-50 flex flex-col items-center justify-center backdrop-blur-sm transition-all duration-200",style:{backgroundColor:"rgba(9, 9, 11, 0.95)",opacity:f?1:0,transform:f?"scale(1)":"scale(0.95)"},children:[n.jsx("button",{onClick:be,className:"absolute right-6 top-6 rounded-full p-2 transition-colors hover:bg-bg-tertiary z-20 text-text-secondary",children:n.jsx(De,{className:"h-6 w-6"})}),j==="picking"&&n.jsx("div",{className:"w-full h-full",children:n.jsx(We,{currentVoice:A||void 0,onSelect:Te,onPreview:Me})}),j==="active"&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"mb-6 text-center",children:[n.jsx("div",{className:"text-base font-medium mb-0.5 transition-colors duration-500 max-w-md truncate px-4",style:{color:Ve},children:Ee}),y&&n.jsx("div",{className:"text-xs font-medium mt-1 animate-pulse text-error",children:y}),n.jsxs("div",{className:"relative mt-2",children:[n.jsxs("button",{onClick:()=>$(t=>!t),className:"inline-flex items-center gap-1.5 rounded-full px-3 py-1 text-xs font-medium transition-colors hover:bg-bg-tertiary",style:{color:ie(A||"tara").glow},children:[n.jsx("span",{className:"inline-block w-2 h-2 rounded-full",style:{backgroundColor:ie(A||"tara").glow}}),ie(A||"tara").name,n.jsx(Fe,{className:"h-3 w-3"})]}),g&&n.jsx("div",{className:"absolute left-1/2 -translate-x-1/2 mt-1 rounded-xl border border-bg-tertiary bg-bg-secondary/95 backdrop-blur-sm p-1.5 shadow-xl z-30",style:{minWidth:180},children:re.map(t=>{const r=ie(t),a=t===(A||"tara");return n.jsxs("button",{onClick:()=>Ne(t),className:"flex items-center gap-2.5 w-full rounded-lg px-3 py-2 text-left text-sm transition-colors hover:bg-bg-tertiary",style:{color:a?r.glow:"var(--color-text-secondary)"},children:[n.jsx("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{backgroundColor:r.glow,boxShadow:a?`0 0 8px ${r.glow}60`:"none"}}),n.jsx("span",{className:"font-medium",children:r.name}),a&&n.jsx("span",{className:"ml-auto text-xs opacity-60",children:"✓"})]},t)})})]})]}),n.jsx(Pe,{audioLevel:x?0:z,speaker:x?"idle":Oe,size:260}),n.jsx("div",{className:"mt-8 w-full max-w-lg px-4",children:n.jsx(Ge,{messages:L,isListening:I&&!x})}),n.jsxs("div",{className:"absolute bottom-12 flex items-center gap-6",children:[n.jsx("button",{onClick:Le,className:"rounded-full p-4 transition-colors",style:{backgroundColor:x?"var(--color-error)":"var(--color-bg-tertiary)",color:"var(--color-text)"},title:x?"Unmute":"Mute",children:x?n.jsx(ze,{className:"h-6 w-6"}):n.jsx(Je,{className:"h-6 w-6"})}),n.jsx("button",{onClick:be,className:"rounded-full p-4 transition-colors",style:{backgroundColor:"var(--color-error)",color:"var(--color-text)"},title:"End call",children:n.jsx(Xe,{className:"h-6 w-6"})})]})]})]})]})}const ct=Object.freeze(Object.defineProperty({__proto__:null,VoiceOverlay:rt},Symbol.toStringTag,{value:"Module"}));export{Je as M,rt as V,ct as a};
@@ -0,0 +1 @@
1
+ import{r as t,b0 as c,j as e,C as n,M as x}from"./index-DzwowwSI.js";import{P as m}from"./PageHeader-CnZtP8ek.js";import{R as o}from"./terminal-BtiqJ628.js";import"./chevron-right-aQEw2mUW.js";function g(){const[s,r]=t.useState(null),[l,i]=t.useState(!0),d=t.useCallback(async()=>{i(!0);try{const a=await c();r(a)}catch{}i(!1)},[]);return t.useEffect(()=>{d()},[d]),e.jsxs("div",{className:"space-y-4",children:[e.jsx(m,{title:"VRAM Monitor",breadcrumbs:[{label:"Admin",href:"/overview"},{label:"Infra"},{label:"VRAM"}]}),e.jsx("div",{className:"flex gap-2",children:e.jsxs("button",{onClick:d,disabled:l,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(o,{className:`w-4 h-4 ${l?"animate-spin":""}`})," Refresh"]})}),(s==null?void 0:s.gpu)&&e.jsxs("div",{className:"p-3 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(n,{className:"w-4 h-4 text-[#6366f1]"}),e.jsx("span",{className:"text-sm font-medium text-[#e4e4e7]",children:s.gpu.gpuName}),e.jsxs("span",{className:"text-xs text-[#52525b]",children:["(",s.gpu.vendor,")"]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-xs",children:[e.jsxs("div",{className:"p-2 rounded bg-[#27272a]/50",children:[e.jsx("div",{className:"text-[#52525b]",children:"Total"}),e.jsxs("div",{className:"text-[#e4e4e7]",children:[(s.gpu.totalMB/1024).toFixed(1)," GB"]})]}),e.jsxs("div",{className:"p-2 rounded bg-[#27272a]/50",children:[e.jsx("div",{className:"text-[#52525b]",children:"Used"}),e.jsxs("div",{className:"text-[#e4e4e7]",children:[(s.gpu.usedMB/1024).toFixed(1)," GB"]})]}),e.jsxs("div",{className:"p-2 rounded bg-[#27272a]/50",children:[e.jsx("div",{className:"text-[#52525b]",children:"Free"}),e.jsxs("div",{className:"text-[#e4e4e7]",children:[(s.gpu.freeMB/1024).toFixed(1)," GB"]})]})]}),e.jsx("div",{className:"mt-2 h-2 rounded-full bg-[#27272a] overflow-hidden",children:e.jsx("div",{className:"h-full bg-[#6366f1] rounded-full",style:{width:`${s.gpu.usedMB/s.gpu.totalMB*100}%`}})})]}),s&&s.activeLeases.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium text-[#e4e4e7]",children:"Active Leases"}),s.activeLeases.map(a=>e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg bg-[#0a0a0f] border border-[#27272a]",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(x,{className:"w-3.5 h-3.5 text-[#6366f1]"}),e.jsx("span",{className:"text-xs text-[#e4e4e7]",children:a.service})]}),e.jsxs("span",{className:"text-xs text-[#52525b]",children:[(a.reservedMB/1024).toFixed(1)," GB"]})]},a.id))]})]})}export{g as default};
@@ -1,4 +1,4 @@
1
- import{r as d,j as e,X as ee,b as Q,aG as te}from"./index-CahJbWSR.js";import{A as q,m as G}from"./proxy-CzZDfLmm.js";const ne={purpose:"#a78bfa",hunger:"#fbbf24",curiosity:"#22d3ee",safety:"#34d399",social:"#f472b6"},ie={purpose:"Purpose",hunger:"Hunger",curiosity:"Curiosity",safety:"Safety",social:"Social"};function Y(t){return ne[t==null?void 0:t.toLowerCase()]||"#a1a1aa"}const se=new Set(["soma:proposal","turn:pre","tool:call","goal:subtask:ready","initiative:start","initiative:complete","pressure:threshold","goal:completed"]);function J(t,i=Date.now()){let n;if(typeof t=="number"&&!Number.isNaN(t)&&t>0)n=t;else if(typeof t=="string"){const h=Date.parse(t);n=Number.isNaN(h)?i:h}else n=i;const r=Math.max(0,Math.floor((i-n)/1e3));if(r<10)return"just now";if(r<60)return`${r}s ago`;const l=Math.floor(r/60);if(l<60)return`${l}m ago`;const o=Math.floor(l/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}const O=100,re=500;function X(){try{return localStorage.getItem("titan-token")||localStorage.getItem("titan_token")||""}catch{return""}}function ae(){const[t,i]=d.useState([]),[n,r]=d.useState([]),[l,o]=d.useState(!1),[h,y]=d.useState(!1),[s,m]=d.useState(0),[w,g]=d.useState(null),f=d.useRef(null),R=d.useCallback(x=>{if(!Array.isArray(x))return;const j=x.map(a=>{var S;return{id:a.id,label:a.label||ie[(S=a.id)==null?void 0:S.toLowerCase()]||a.id,satisfaction:a.satisfaction??1,setpoint:a.setpoint??.7,pressure:a.pressure??0,weight:a.weight,description:a.description}});i(j)},[]),M=d.useCallback(()=>{f.current&&f.current.close();const x=X(),j=`/api/watch/stream${x?`?token=${encodeURIComponent(x)}`:""}`,a=new EventSource(j);f.current=a;const S=Date.now();a.onopen=()=>{o(!0),y(!1)},a.onerror=()=>{o(!1),Date.now()-S>re&&y(!0)},a.onmessage=H=>{var T,N;try{const c=JSON.parse(H.data);if(c.type==="snapshot"){g({drives:c.drives||[],totalPressure:c.totalPressure||0,dominantDrives:c.dominantDrives||[],timestamp:c.timestamp||Date.now()}),R(c.drives);return}if(c.type==="event"){if(c.topic==="drive:tick"){const A=((T=c.raw)==null?void 0:T.drives)??[];R(A),m(Date.now());return}if(c.topic==="initiative:round"){const A=(N=c.raw)==null?void 0:N.subtaskTitle,F={id:c.id,timestamp:c.timestamp,topic:c.topic,kind:c.kind,icon:c.icon,captionTitan:c.captionTitan,captionControl:c.captionControl,detail:c.detail,raw:c.raw};r(v=>{const p=A?v.filter(b=>{var k;return!(b.topic==="initiative:round"&&((k=b.raw)==null?void 0:k.subtaskTitle)===A)}):v.filter(b=>b.topic!=="initiative:round"),D=[F,...p];return D.length>O&&(D.length=O),D}),m(Date.now());return}const $={id:c.id,timestamp:c.timestamp,topic:c.topic,kind:c.kind,icon:c.icon,captionTitan:c.captionTitan,captionControl:c.captionControl,detail:c.detail,raw:c.raw};r(A=>{const F=[$,...A];return F.length>O&&(F.length=O),F}),m(Date.now())}}catch{}}},[R]),I=d.useCallback(()=>{f.current&&f.current.close(),M()},[M]);return d.useEffect(()=>{const x=X(),j={};x&&(j.Authorization=`Bearer ${x}`),fetch("/api/watch/snapshot",{headers:j}).then(a=>a.status===401?(localStorage.removeItem("titan-token"),localStorage.removeItem("titan_token"),window.location.reload(),null):a.ok?a.json():null).then(a=>{a&&!a.error&&(g(a),R(a.drives))}).catch(()=>{})},[R]),d.useEffect(()=>(M(),()=>{var x;(x=f.current)==null||x.close(),f.current=null}),[M]),{drives:t,events:n,connected:l,reconnecting:h,lastActivity:s,snapshot:w,reconnect:I}}function oe(t){for(const i of t)if(se.has(i.topic))return i;return t[0]||null}function le({events:t,voice:i}){const n=d.useMemo(()=>oe(t),[t]),r=n?i==="titan"?n.captionTitan:n.captionControl:null;return e.jsxs("div",{style:{position:"relative",minHeight:80},children:[e.jsx("div",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:"0.15em",color:"rgba(255, 255, 255, 0.35)",marginBottom:10,fontWeight:600},children:"What I'm doing"}),e.jsx(q,{mode:"wait",initial:!1,children:e.jsx(G.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.3},style:{fontSize:"clamp(18px, 2.4vw, 24px)",fontWeight:500,lineHeight:1.35,color:r?"rgba(255, 255, 255, 0.95)":"rgba(255, 255, 255, 0.45)"},children:r||"Standing by."},(n==null?void 0:n.id)||"idle")}),n&&e.jsxs("div",{style:{display:"flex",gap:12,marginTop:12,fontSize:11,color:"rgba(255, 255, 255, 0.35)",flexWrap:"wrap"},children:[e.jsx("span",{children:J(n.timestamp)}),n.detail&&e.jsxs("span",{children:["· ",n.detail]})]})]})}const ce={drive:"var(--color-purple-light)",soma:"#c084fc",tool:"#60a5fa",goal:"var(--color-emerald)",channel:"#fb7185",agent:"#c084fc",health:"#fbbf24",memory:"#e879f9",system:"#9ca3af"};function de({events:t,voice:i,onEventClick:n}){const[,r]=d.useState(0);d.useEffect(()=>{const o=setInterval(()=>r(h=>h+1),2e4);return()=>clearInterval(o)},[]);const l=d.useMemo(()=>t.slice(0,80),[t]);return l.length===0?e.jsx("div",{style:{color:"rgba(255,255,255,0.35)",fontSize:13,fontStyle:"italic",padding:"24px 16px",textAlign:"center"},children:"Listening for TITAN to do something…"}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4,overflow:"hidden"},children:e.jsx(q,{initial:!1,children:l.map((o,h)=>{const y=i==="titan"?o.captionTitan:o.captionControl,s=ce[o.kind]||"#9ca3af",m=h===0;return e.jsxs(G.div,{initial:{opacity:0,y:-6},animate:{opacity:1,y:0},exit:{opacity:0,y:4},transition:{duration:.35,ease:"easeOut"},onClick:()=>n==null?void 0:n(o),style:{display:"flex",alignItems:"flex-start",gap:12,padding:"10px 12px",borderRadius:10,background:m?`${s}14`:"rgba(255, 255, 255, 0.015)",borderLeft:`2px solid ${s}`,fontSize:13,lineHeight:1.35,transition:"background 0.2s, transform 0.15s",cursor:n?"pointer":"default"},onMouseEnter:w=>{n&&(w.currentTarget.style.background=`${s}22`)},onMouseLeave:w=>{w.currentTarget.style.background=m?`${s}14`:"rgba(255, 255, 255, 0.015)"},title:`Click for details · ${o.topic}`,children:[e.jsx("div",{style:{fontSize:15,flexShrink:0,width:20,textAlign:"center",marginTop:1},children:o.icon}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{color:"rgba(255,255,255,0.92)"},children:y}),o.detail&&e.jsx("div",{style:{color:"rgba(255,255,255,0.45)",fontSize:11,marginTop:2,lineHeight:1.3},children:o.detail})]}),e.jsx("div",{style:{color:"rgba(255,255,255,0.35)",fontSize:11,flexShrink:0,fontVariantNumeric:"tabular-nums",whiteSpace:"nowrap",marginTop:1},children:J(o.timestamp)})]},o.id)})})})}function P(t,i){const n=t.match(/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i);return n?`rgba(${parseInt(n[1],16)}, ${parseInt(n[2],16)}, ${parseInt(n[3],16)}, ${i})`:`rgba(160, 160, 160, ${i})`}function pe({drives:t,excited:i=!1,reducedMotion:n=!1}){const r=d.useRef(null),l=d.useRef(t),o=d.useRef(i),h=d.useRef(null);return d.useEffect(()=>{l.current=t},[t]),d.useEffect(()=>{o.current=i},[i]),d.useEffect(()=>{const y=r.current;if(!y)return;const s=y.getContext("2d",{alpha:!0});if(!s)return;const m=Math.min(window.devicePixelRatio||1,2),w=()=>{const I=y.getBoundingClientRect();y.width=Math.max(2,I.width*m),y.height=Math.max(2,I.height*m),s.setTransform(m,0,0,m,0,0)};w();const g=new ResizeObserver(w);g.observe(y);const f=[],R=60,M=()=>{h.current=requestAnimationFrame(M);const I=y.getBoundingClientRect(),x=I.width,j=I.height;if(x<10||j<10)return;const a=x/2,S=j/2,H=Math.min(x,j)*.11,T=Math.min(x,j)*.34,N=performance.now()/1e3,c=l.current;s.clearRect(0,0,x,j);const $=s.createRadialGradient(a,S,0,a,S,Math.min(x,j)*.55),A=n?.08:.08+.03*Math.sin(N*.5);$.addColorStop(0,`rgba(255, 255, 255, ${A*2})`),$.addColorStop(.3,`rgba(167, 139, 250, ${A})`),$.addColorStop(1,"rgba(167, 139, 250, 0)"),s.fillStyle=$,s.fillRect(0,0,x,j);const F=Math.max(c.length,5);for(let v=0;v<c.length;v++){const p=c[v],D=v/F*Math.PI*2-Math.PI/2,b=a+Math.cos(D)*T,k=S+Math.sin(D)*T,W=Math.min(1,(p.pressure||0)*3),V=n?0:.35+W*1.4,_=n?0:.04+W*.15,z=H*(.75+_*Math.sin(N*V+v*1.3)),C=Y(p.id),E=z*2.8,B=s.createRadialGradient(b,k,0,b,k,E);B.addColorStop(0,P(C,.35)),B.addColorStop(.35,P(C,.18)),B.addColorStop(1,P(C,0)),s.fillStyle=B,s.beginPath(),s.arc(b,k,E,0,Math.PI*2),s.fill();const L=s.createRadialGradient(b-z*.3,k-z*.3,0,b,k,z);L.addColorStop(0,P(C,.95)),L.addColorStop(.55,P(C,.55)),L.addColorStop(1,P(C,.2)),s.fillStyle=L,s.beginPath(),s.arc(b,k,z,0,Math.PI*2),s.fill(),W>.1&&(s.strokeStyle=P(C,.6+.3*Math.sin(N*3+v)),s.lineWidth=1.5,s.beginPath(),s.arc(b,k,z*1.05,0,Math.PI*2),s.stroke()),s.font='600 10px -apple-system, BlinkMacSystemFont, "Inter", system-ui, sans-serif',s.textAlign="center",s.fillStyle="rgba(255,255,255,0.65)",s.fillText(p.label.toUpperCase(),b,k+z+18),s.font="11px -apple-system, system-ui",s.fillStyle="rgba(255,255,255,0.35)",s.fillText(`${Math.round((p.satisfaction||0)*100)}%`,b,k+z+32);const Z=W*.25+(o.current?.03:0);!n&&f.length<R&&Math.random()<Z&&f.push({sourceIdx:v,phase:0,color:C,size:2+Math.random()*2})}if(!n)for(let v=f.length-1;v>=0;v--){const p=f[v];if(p.phase+=.012,p.phase>=1){f.splice(v,1);continue}if(!c[p.sourceIdx]){f.splice(v,1);continue}const b=p.sourceIdx/F*Math.PI*2-Math.PI/2,k=a+Math.cos(b)*T,W=S+Math.sin(b)*T,V=(k+a)/2+Math.sin(b+Math.PI/2)*20,_=(W+S)/2+Math.cos(b+Math.PI/2)*20,z=(1-p.phase)*(1-p.phase)*k+2*(1-p.phase)*p.phase*V+p.phase*p.phase*a,C=(1-p.phase)*(1-p.phase)*W+2*(1-p.phase)*p.phase*_+p.phase*p.phase*S,E=Math.sin(p.phase*Math.PI)*.9;s.fillStyle=P(p.color,E),s.beginPath(),s.arc(z,C,p.size,0,Math.PI*2),s.fill()}if(!n){const p=N%20/20;if(p<.18){const D=H+p*Math.min(x,j)*2.5,b=(1-p/.18)*.18;s.strokeStyle=`rgba(167, 139, 250, ${b})`,s.lineWidth=1.5,s.beginPath(),s.arc(a,S,D,0,Math.PI*2),s.stroke()}}};return h.current=requestAnimationFrame(M),()=>{g.disconnect(),h.current&&cancelAnimationFrame(h.current)}},[n]),e.jsx("canvas",{ref:r,style:{width:"100%",height:"100%",display:"block"},"aria-label":"TITAN organism — 5 drives breathing"})}function he({event:t,voice:i,onClose:n}){return e.jsx(q,{children:t&&e.jsxs(e.Fragment,{children:[e.jsx(G.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.18},onClick:n,style:{position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.55)",backdropFilter:"blur(4px)",WebkitBackdropFilter:"blur(4px)",zIndex:99}},"backdrop"),e.jsx(G.aside,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{duration:.28,ease:[.32,.72,0,1]},style:{position:"fixed",top:0,right:0,bottom:0,width:"min(540px, 100vw)",background:"rgba(10, 12, 20, 0.96)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",borderLeft:"1px solid rgba(167, 139, 250, 0.15)",display:"flex",flexDirection:"column",zIndex:100,color:"#f8f9fc",boxShadow:"-20px 0 60px rgba(0,0,0,0.5)"},role:"dialog","aria-modal":"true",children:e.jsx(ue,{event:t,voice:i,onClose:n})},"panel")]})})}function ue({event:t,voice:i,onClose:n}){const r=i==="titan"?t.captionTitan:t.captionControl,l=t.raw||{};return d.useEffect(()=>{const o=h=>{h.key==="Escape"&&n()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[n]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{padding:"20px 24px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"flex-start",gap:12},children:[e.jsx("div",{style:{fontSize:22,width:36,height:36,borderRadius:10,background:"rgba(255,255,255,0.04)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.icon}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:17,fontWeight:600,lineHeight:1.3,marginBottom:4},children:r}),e.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.35)",display:"flex",gap:10},children:[e.jsx("span",{children:J(t.timestamp)}),e.jsx("span",{style:{opacity:.5},children:"·"}),e.jsx("span",{style:{textTransform:"uppercase",letterSpacing:"0.1em"},children:t.kind}),e.jsx("span",{style:{opacity:.5},children:"·"}),e.jsx("span",{style:{fontFamily:"ui-monospace, monospace",fontSize:10},children:t.topic})]})]}),e.jsx("button",{onClick:n,"aria-label":"Close",style:{background:"transparent",border:0,color:"rgba(255,255,255,0.55)",cursor:"pointer",padding:6,borderRadius:8,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(ee,{size:18})})]}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px",minHeight:0},children:[t.detail&&e.jsx(u,{label:"Detail",children:e.jsx("div",{style:{fontSize:13,color:"rgba(255,255,255,0.75)",lineHeight:1.5},children:t.detail})}),t.kind==="soma"&&e.jsx(ge,{raw:l}),t.kind==="goal"&&e.jsx(fe,{raw:l}),t.kind==="tool"&&e.jsx(xe,{raw:l,topic:t.topic}),t.kind==="channel"&&e.jsx(me,{raw:l,topic:t.topic}),t.kind==="drive"&&e.jsx(be,{raw:l,topic:t.topic}),(t.kind==="system"||t.kind==="agent"||t.kind==="memory"||t.kind==="health")&&e.jsx(ye,{raw:l,topic:t.topic})]}),e.jsx(ve,{label:"Raw event data",raw:l})]})}function u({label:t,children:i}){return e.jsxs("div",{style:{marginBottom:20},children:[e.jsx("div",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:"0.15em",color:"rgba(255,255,255,0.35)",fontWeight:600,marginBottom:8},children:t}),i]})}function ge({raw:t}){const i=t.approvalId,n=t.dominantDrives||[],r=t.shadowVerdict;return e.jsxs(e.Fragment,{children:[e.jsx(u,{label:"What drove this",children:e.jsxs("div",{style:{fontSize:13,color:"rgba(255,255,255,0.75)"},children:[n.length?n.map(l=>l[0].toUpperCase()+l.slice(1)).join(", "):"an unspecified drive"," ","was below its setpoint. Soma filed this proposal autonomously."]})}),i&&e.jsx(u,{label:"Command Post approval",children:e.jsx("code",{style:{fontSize:11,color:"rgba(167, 139, 250, 0.9)"},children:i})}),r&&e.jsx(u,{label:"Shadow rehearsal verdict",children:e.jsx("pre",{style:{fontSize:11,lineHeight:1.4,color:"rgba(255,255,255,0.7)",whiteSpace:"pre-wrap",wordBreak:"break-word",background:"rgba(255,255,255,0.02)",padding:12,borderRadius:8},children:JSON.stringify(r,null,2)})})]})}function fe({raw:t}){const i=t.goalId,[n,r]=d.useState(null),[l,o]=d.useState(!1);if(d.useEffect(()=>{i&&(o(!0),Q(`/api/goals/${i}`).then(s=>s.ok?s.json():null).then(s=>r((s==null?void 0:s.goal)||s||null)).catch(()=>{}).finally(()=>o(!1)))},[i]),!i)return null;if(l)return e.jsx(u,{label:"Goal",children:e.jsx("div",{style:{color:"rgba(255,255,255,0.4)",fontSize:12},children:"Loading…"})});if(!n)return e.jsx(u,{label:"Goal",children:e.jsx("div",{style:{color:"rgba(255,255,255,0.4)",fontSize:12},children:"Goal not found (may have been deleted)."})});const h=n.subtasks||[],y=h.filter(s=>s.status==="done"||s.status==="skipped").length;return e.jsxs(u,{label:"Goal",children:[e.jsx("div",{style:{fontSize:14,fontWeight:600,marginBottom:6},children:String(n.title||"")}),e.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.4)",marginBottom:12},children:[String(n.status||"")," · ",y,"/",h.length," subtasks"]}),h.length>0&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:h.map((s,m)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"8px 10px",borderRadius:8,background:"rgba(255,255,255,0.02)",fontSize:12},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:K(s.status),boxShadow:`0 0 6px ${K(s.status)}`,flexShrink:0}}),e.jsx("span",{style:{flex:1},children:String(s.title||"")}),e.jsx("span",{style:{fontSize:10,color:"rgba(255,255,255,0.35)",textTransform:"uppercase",letterSpacing:"0.1em"},children:String(s.status||"")})]},m))})]})}function K(t){switch(t){case"done":return"var(--color-emerald)";case"running":return"var(--color-cyan)";case"failed":return"var(--color-error)";case"skipped":return"var(--color-text-secondary)";case"pending":return"#fbbf24";default:return"#9ca3af"}}function xe({raw:t,topic:i}){const n=t.tool,r=t.argsPreview,l=t.durationMs,o=t.success;return e.jsxs(e.Fragment,{children:[n&&e.jsx(u,{label:"Tool",children:e.jsx("code",{style:{fontSize:12,color:"rgba(96, 165, 250, 0.9)"},children:n})}),r!==void 0&&e.jsx(u,{label:"Arguments",children:e.jsx("pre",{style:{fontSize:11,lineHeight:1.4,color:"rgba(255,255,255,0.7)",whiteSpace:"pre-wrap",wordBreak:"break-word",background:"rgba(255,255,255,0.02)",padding:12,borderRadius:8,maxHeight:300,overflowY:"auto"},children:typeof r=="string"?r:JSON.stringify(r,null,2)})}),i==="tool:result"&&e.jsx(u,{label:"Result",children:e.jsxs("div",{style:{fontSize:13,color:o?"rgba(52,211,153,0.9)":"rgba(239,68,68,0.9)"},children:[o?"✓ Completed":"✗ Failed",l!==void 0&&e.jsxs("span",{style:{color:"rgba(255,255,255,0.5)",marginLeft:8},children:["in ",l,"ms"]})]})})]})}function me({raw:t,topic:i}){const n=t.sessionId,r=t.channel,l=t.userId,o=t.message,h=t.toolsUsed||[],y=t.model,s=t.durationMs,[m,w]=d.useState(null);return d.useEffect(()=>{n&&Q(`/api/sessions/${n}`).then(g=>g.ok?g.json():null).then(g=>{const f=Array.isArray(g)?g:(g==null?void 0:g.messages)||[];w(f)}).catch(()=>{})},[n]),e.jsxs(e.Fragment,{children:[r&&e.jsx(u,{label:"Channel",children:e.jsxs("div",{style:{fontSize:13},children:[r,l&&e.jsxs("span",{style:{color:"rgba(255,255,255,0.4)"},children:[" · ",l]})]})}),o&&e.jsx(u,{label:i==="turn:pre"?"What they said":"Message",children:e.jsx("div",{style:{fontSize:13,lineHeight:1.5,color:"rgba(255,255,255,0.8)",padding:12,background:"rgba(255,255,255,0.02)",borderRadius:8},children:o})}),i==="turn:post"&&e.jsx(u,{label:"Turn stats",children:e.jsxs("div",{style:{fontSize:12,color:"rgba(255,255,255,0.55)",lineHeight:1.6},children:[s!==void 0&&e.jsxs("div",{children:["Took ",(s/1e3).toFixed(1),"s"]}),y&&e.jsxs("div",{children:["Model: ",y]}),h.length>0&&e.jsxs("div",{children:["Used: ",h.join(", ")]})]})}),m&&m.length>0&&e.jsx(u,{label:"Session messages",children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10,maxHeight:400,overflowY:"auto"},children:m.slice(-8).map((g,f)=>e.jsxs("div",{style:{padding:10,borderRadius:8,background:g.role==="assistant"?"rgba(167, 139, 250, 0.06)":"rgba(255,255,255,0.02)",borderLeft:`2px solid ${g.role==="assistant"?"var(--color-purple-light)":"rgba(255,255,255,0.2)"}`,fontSize:12},children:[e.jsx("div",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:"0.1em",color:"rgba(255,255,255,0.35)",marginBottom:4},children:String(g.role||"?")}),e.jsxs("div",{style:{color:"rgba(255,255,255,0.85)",lineHeight:1.5,whiteSpace:"pre-wrap"},children:[String(g.content||"").slice(0,400),String(g.content||"").length>400&&"…"]})]},f))})})]})}function be({raw:t,topic:i}){const n=t.drives||[],r=t.totalPressure,l=t.dominantDrives||[];return e.jsxs(e.Fragment,{children:[r!==void 0&&e.jsx(u,{label:"Pressure snapshot",children:e.jsxs("div",{style:{fontSize:13,color:"rgba(255,255,255,0.75)"},children:["Total: ",e.jsx("strong",{children:r.toFixed(3)}),l.length>0&&e.jsxs("span",{children:[" · Dominant: ",l.map(o=>o[0].toUpperCase()+o.slice(1)).join(", ")]})]})}),n.length>0&&i==="drive:tick"&&e.jsx(u,{label:"All drives this tick",children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:n.map((o,h)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"8px 10px",borderRadius:8,background:"rgba(255,255,255,0.02)",fontSize:12},children:[e.jsx("span",{style:{flex:1,fontWeight:500},children:String(o.label||o.id)}),e.jsxs("span",{style:{color:"rgba(255,255,255,0.55)",fontVariantNumeric:"tabular-nums"},children:["sat ",(Number(o.satisfaction)*100).toFixed(0),"% · sp ",(Number(o.setpoint)*100).toFixed(0),"%"]}),e.jsx("span",{style:{color:Number(o.pressure)>0?"#fbbf24":"rgba(255,255,255,0.25)",fontVariantNumeric:"tabular-nums",width:50,textAlign:"right"},children:Number(o.pressure).toFixed(2)})]},h))})})]})}function ye({raw:t,topic:i}){if(i==="initiative:round"){const n=t.round,r=t.maxRounds,l=t.subtaskTitle;return e.jsx(u,{label:"What's happening",children:e.jsxs("div",{style:{fontSize:13,color:"rgba(255,255,255,0.8)",lineHeight:1.6},children:["TITAN is reasoning through round ",e.jsx("strong",{children:n})," of ",e.jsx("strong",{children:r}),l&&e.jsxs(e.Fragment,{children:[" on the subtask ",e.jsxs("em",{style:{color:"rgba(167, 139, 250, 0.9)"},children:['"',l,'"']})]}),".",e.jsx("br",{}),e.jsx("br",{}),"Each round is one tool-calling cycle — the agent thinks, picks a tool, runs it, then thinks again with the result. The cycle continues until the subtask is complete or the round budget runs out."]})})}if(i==="initiative:start"){const n=t.subtaskTitle,r=t.goalTitle;return e.jsx(u,{label:"What's happening",children:e.jsxs("div",{style:{fontSize:13,color:"rgba(255,255,255,0.8)",lineHeight:1.6},children:["TITAN picked up a task and started working.",n&&e.jsxs(e.Fragment,{children:[" Subtask: ",e.jsxs("em",{style:{color:"rgba(167, 139, 250, 0.9)"},children:['"',n,'"']}),"."]}),r&&e.jsxs(e.Fragment,{children:[" Part of goal: ",e.jsxs("em",{style:{color:"rgba(52, 211, 153, 0.9)"},children:['"',r,'"']}),"."]})]})})}if(i==="initiative:complete"){const n=t.success,r=t.toolsUsed||[],l=t.summary;return e.jsxs(u,{label:"Result",children:[e.jsxs("div",{style:{fontSize:13,color:"rgba(255,255,255,0.8)",lineHeight:1.6},children:[n===!1?"The task ran but ended without full success.":"Task complete.",r.length>0&&e.jsxs(e.Fragment,{children:[" Tools used: ",r.join(", "),"."]})]}),l&&e.jsx("div",{style:{marginTop:8,padding:10,borderRadius:8,background:"rgba(255,255,255,0.02)",fontSize:12,lineHeight:1.5,color:"rgba(255,255,255,0.7)"},children:l})]})}if(i==="initiative:no_progress"){const n=t.reason;return e.jsx(u,{label:"Why it paused",children:e.jsx("div",{style:{fontSize:13,color:"rgba(251, 191, 36, 0.9)",lineHeight:1.6},children:n||"Ran but couldn't advance."})})}if(i==="dreaming:consolidated")return e.jsx(u,{label:"What's happening",children:e.jsx("div",{style:{fontSize:13,color:"rgba(255,255,255,0.8)",lineHeight:1.6},children:"TITAN periodically consolidates recent memories — merging related facts, pruning stale ones, strengthening frequently-accessed associations. It's how it keeps the memory graph fast without losing useful context."})});if(i==="daemon:started"||i==="daemon:resumed")return e.jsx(u,{label:"What's happening",children:e.jsx("div",{style:{fontSize:13,color:"rgba(255,255,255,0.8)",lineHeight:1.6},children:"TITAN's background daemon came online. All watchers (goals, cron, health, memory, drive ticks, Facebook autopilot) are active."})});if(i==="daemon:paused")return e.jsx(u,{label:"What's happening",children:e.jsx("div",{style:{fontSize:13,color:"rgba(255,255,255,0.8)",lineHeight:1.6},children:"Background work is paused. Chat still works; cron, autopilot, and Soma ticks are halted until resumed."})});if(i.startsWith("health:"))return e.jsx(u,{label:"Health alert",children:e.jsx("div",{style:{fontSize:13,color:"rgba(251, 191, 36, 0.9)",lineHeight:1.6},children:"A subsystem reported a health issue. Check the Console tab for diagnostics."})});if(i==="agent:spawned"||i==="agent:stopped"){const n=t.name,r=t.model;return e.jsx(u,{label:"What's happening",children:e.jsxs("div",{style:{fontSize:13,color:"rgba(255,255,255,0.8)",lineHeight:1.6},children:[i==="agent:spawned"?"Spawned":"Stopped"," sub-agent",n&&e.jsxs(e.Fragment,{children:[" ",e.jsx("strong",{children:n})]}),r&&i==="agent:spawned"&&e.jsxs(e.Fragment,{children:[" running ",r]}),"."]})})}if(i==="agent:task:completed"||i==="agent:task:failed"){const n=t.agentId,r=t.reason,l=t.success;return e.jsx(u,{label:"Sub-agent result",children:e.jsxs("div",{style:{fontSize:13,color:"rgba(255,255,255,0.8)",lineHeight:1.6},children:[n&&e.jsxs(e.Fragment,{children:["Sub-agent ",e.jsx("strong",{children:n})," "]}),i==="agent:task:completed"&&l!==!1?"finished its task successfully.":r?`couldn't complete: ${r}.`:"did not complete its task."]})})}return e.jsx(je,{raw:t})}function je({raw:t}){const i=Object.entries(t||{}).filter(([n])=>n!=="timestamp");return i.length===0?null:e.jsx(u,{label:"Details",children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:i.slice(0,8).map(([n,r])=>e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12,padding:"6px 10px",borderRadius:6,background:"rgba(255,255,255,0.02)",fontSize:11},children:[e.jsx("span",{style:{color:"rgba(255,255,255,0.4)"},children:n}),e.jsx("span",{style:{color:"rgba(255,255,255,0.8)",fontFamily:"ui-monospace, monospace",textAlign:"right",wordBreak:"break-all"},children:Se(r)})]},n))})})}function Se(t){if(t==null)return"—";if(typeof t=="string")return t.length>80?t.slice(0,77)+"…":t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t).slice(0,80)}catch{return"[object]"}}function ve({label:t,raw:i}){const[n,r]=d.useState(!1);return e.jsxs("div",{style:{borderTop:"1px solid rgba(255,255,255,0.06)"},children:[e.jsxs("button",{onClick:()=>r(l=>!l),style:{width:"100%",padding:"14px 24px",background:"transparent",border:0,color:"rgba(255,255,255,0.5)",fontSize:11,textTransform:"uppercase",letterSpacing:"0.15em",fontWeight:600,textAlign:"left",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("span",{children:t}),e.jsx("span",{style:{fontSize:14},children:n?"−":"+"})]}),n&&e.jsx("pre",{style:{margin:0,padding:"0 24px 20px",fontSize:10,lineHeight:1.4,color:"rgba(255,255,255,0.5)",whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:300,overflowY:"auto"},children:JSON.stringify(i,null,2)})]})}function Ie(){var x,j;const[t]=te(),i=t.get("kiosk")==="1",n=t.get("voice")==="control"?"control":"titan",[r,l]=d.useState(n),[o,h]=d.useState(null),{drives:y,events:s,connected:m,reconnecting:w,lastActivity:g}=ae(),f=g>0&&Date.now()-g<1e4,R=typeof window<"u"&&((j=(x=window.matchMedia)==null?void 0:x.call(window,"(prefers-reduced-motion: reduce)"))==null?void 0:j.matches);d.useEffect(()=>{if(!i)return;let a=null;const S=async()=>{try{"wakeLock"in navigator&&(a=await navigator.wakeLock.request("screen"))}catch{}};S();const H=()=>{document.visibilityState==="visible"&&S()};return document.addEventListener("visibilitychange",H),()=>{var T;document.removeEventListener("visibilitychange",H),(T=a==null?void 0:a.release)==null||T.call(a)}},[i]);const M=d.useMemo(()=>m?"live":w?"reconnecting…":"connecting…",[m,w]),I=m?"var(--color-emerald)":w?"#fbbf24":"#6b7280";return e.jsxs("div",{style:{position:i?"fixed":"relative",inset:i?0:void 0,height:"100%",width:"100%",minHeight:i?"100vh":"100%",background:"radial-gradient(ellipse at 20% 30%, rgba(167, 139, 250, 0.06) 0%, transparent 55%), radial-gradient(ellipse at 80% 70%, rgba(34, 211, 238, 0.05) 0%, transparent 55%), radial-gradient(ellipse at 50% 50%, rgba(52, 211, 153, 0.03) 0%, transparent 60%), #05060a",color:"#f8f9fc",overflow:"hidden",fontFamily:'-apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, system-ui, sans-serif',display:"flex",flexDirection:"column",zIndex:i?9999:void 0},children:[e.jsx("div",{"aria-hidden":!0,style:{position:"absolute",inset:0,opacity:.03,pointerEvents:"none",backgroundImage:`url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/></filter><rect width='200' height='200' filter='url(%23n)' opacity='0.8'/></svg>")`}}),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",padding:i?"32px 40px":"20px 24px",minHeight:0,zIndex:1},children:[!i&&e.jsxs("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:16,fontSize:13},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,color:"rgba(255,255,255,0.5)",fontWeight:600,letterSpacing:"0.02em"},children:[e.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:I,boxShadow:`0 0 10px ${I}`,animation:"watch-pulse 2s ease-in-out infinite"}}),e.jsx("span",{children:"TITAN"}),e.jsx("span",{style:{opacity:.4},children:"·"}),e.jsx("span",{children:M})]}),e.jsx("div",{style:{display:"flex",gap:2,background:"rgba(20, 24, 36, 0.6)",border:"1px solid rgba(80, 90, 120, 0.25)",borderRadius:999,padding:2},children:["titan","control"].map(a=>e.jsx("button",{onClick:()=>l(a),style:{background:r===a?"#f8f9fc":"transparent",color:r===a?"#05060a":"rgba(255,255,255,0.55)",border:0,padding:"6px 14px",borderRadius:999,cursor:"pointer",fontSize:11,fontWeight:600,letterSpacing:"0.02em",transition:"all 0.15s",textTransform:"uppercase"},children:a==="titan"?"TITAN":"Mission"},a))})]}),e.jsxs("main",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1.05fr) minmax(0, 1fr)",gridTemplateRows:"auto 1fr",gridTemplateAreas:'"focus activity" "organism activity"',gap:i?28:18,flex:1,minHeight:0},className:"watch-grid",children:[e.jsx(U,{gridArea:"focus",excited:f,children:e.jsx(le,{events:s,voice:r})}),e.jsxs(U,{gridArea:"organism",excited:f,padding:i?24:16,children:[e.jsx("div",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:"0.15em",color:"rgba(255,255,255,0.35)",fontWeight:600,marginBottom:6},children:"How I'm feeling"}),e.jsx("div",{style:{flex:1,minHeight:i?320:220},children:e.jsx(pe,{drives:y,excited:f,reducedMotion:R})}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(90px, 1fr))",gap:8,marginTop:10,fontSize:11},children:y.map(a=>{const S=(a.pressure||0)>.01;return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"6px 10px",borderRadius:8,background:S?"rgba(251, 191, 36, 0.08)":"rgba(255,255,255,0.02)",border:`1px solid ${S?"rgba(251, 191, 36, 0.3)":"rgba(255,255,255,0.04)"}`},title:a.description||`${a.label}: satisfaction ${a.satisfaction.toFixed(2)}, setpoint ${a.setpoint.toFixed(2)}`,children:[e.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:Y(a.id),boxShadow:`0 0 8px ${Y(a.id)}`}}),e.jsx("div",{style:{flex:1,color:"rgba(255,255,255,0.65)",fontWeight:500},children:a.label}),e.jsxs("div",{style:{color:"rgba(255,255,255,0.35)",fontVariantNumeric:"tabular-nums"},children:[Math.round((a.satisfaction||0)*100),"%"]})]},a.id)})})]}),e.jsxs(U,{gridArea:"activity",excited:f,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},children:[e.jsx("div",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:"0.15em",color:"rgba(255,255,255,0.35)",fontWeight:600},children:"Recent activity"}),e.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.35)",fontVariantNumeric:"tabular-nums"},children:[s.length," ",s.length===1?"event":"events"]})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",minHeight:0,maskImage:"linear-gradient(to bottom, transparent 0, black 16px, black calc(100% - 16px), transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, transparent 0, black 16px, black calc(100% - 16px), transparent 100%)",paddingRight:4},children:e.jsx(de,{events:s,voice:r,onEventClick:h})})]})]})]}),e.jsx(he,{event:o,voice:r,onClose:()=>h(null)}),e.jsx("style",{children:`
1
+ import{r as d,j as e,X as ee,b as Q,aT as te}from"./index-DzwowwSI.js";import{A as q,m as V}from"./proxy-DxS2_9D7.js";const ne={purpose:"#a78bfa",hunger:"#fbbf24",curiosity:"#22d3ee",safety:"#34d399",social:"#f472b6"},ie={purpose:"Purpose",hunger:"Hunger",curiosity:"Curiosity",safety:"Safety",social:"Social"};function Y(t){return ne[t==null?void 0:t.toLowerCase()]||"#a1a1aa"}const se=new Set(["soma:proposal","turn:pre","tool:call","goal:subtask:ready","initiative:start","initiative:complete","pressure:threshold","goal:completed"]);function J(t,i=Date.now()){let n;if(typeof t=="number"&&!Number.isNaN(t)&&t>0)n=t;else if(typeof t=="string"){const h=Date.parse(t);n=Number.isNaN(h)?i:h}else n=i;const r=Math.max(0,Math.floor((i-n)/1e3));if(r<10)return"just now";if(r<60)return`${r}s ago`;const l=Math.floor(r/60);if(l<60)return`${l}m ago`;const o=Math.floor(l/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}const O=100,re=500;function X(){try{return localStorage.getItem("titan-token")||localStorage.getItem("titan_token")||""}catch{return""}}function ae(){const[t,i]=d.useState([]),[n,r]=d.useState([]),[l,o]=d.useState(!1),[h,y]=d.useState(!1),[s,m]=d.useState(0),[w,g]=d.useState(null),f=d.useRef(null),R=d.useCallback(x=>{if(!Array.isArray(x))return;const j=x.map(a=>{var S;return{id:a.id,label:a.label||ie[(S=a.id)==null?void 0:S.toLowerCase()]||a.id,satisfaction:a.satisfaction??1,setpoint:a.setpoint??.7,pressure:a.pressure??0,weight:a.weight,description:a.description}});i(j)},[]),M=d.useCallback(()=>{f.current&&f.current.close();const x=X(),j=`/api/watch/stream${x?`?token=${encodeURIComponent(x)}`:""}`,a=new EventSource(j);f.current=a;const S=Date.now();a.onopen=()=>{o(!0),y(!1)},a.onerror=()=>{o(!1),Date.now()-S>re&&y(!0)},a.onmessage=H=>{var T,N;try{const c=JSON.parse(H.data);if(c.type==="snapshot"){g({drives:c.drives||[],totalPressure:c.totalPressure||0,dominantDrives:c.dominantDrives||[],timestamp:c.timestamp||Date.now()}),R(c.drives);return}if(c.type==="event"){if(c.topic==="drive:tick"){const A=((T=c.raw)==null?void 0:T.drives)??[];R(A),m(Date.now());return}if(c.topic==="initiative:round"){const A=(N=c.raw)==null?void 0:N.subtaskTitle,F={id:c.id,timestamp:c.timestamp,topic:c.topic,kind:c.kind,icon:c.icon,captionTitan:c.captionTitan,captionControl:c.captionControl,detail:c.detail,raw:c.raw};r(v=>{const p=A?v.filter(b=>{var k;return!(b.topic==="initiative:round"&&((k=b.raw)==null?void 0:k.subtaskTitle)===A)}):v.filter(b=>b.topic!=="initiative:round"),D=[F,...p];return D.length>O&&(D.length=O),D}),m(Date.now());return}const $={id:c.id,timestamp:c.timestamp,topic:c.topic,kind:c.kind,icon:c.icon,captionTitan:c.captionTitan,captionControl:c.captionControl,detail:c.detail,raw:c.raw};r(A=>{const F=[$,...A];return F.length>O&&(F.length=O),F}),m(Date.now())}}catch{}}},[R]),I=d.useCallback(()=>{f.current&&f.current.close(),M()},[M]);return d.useEffect(()=>{const x=X(),j={};x&&(j.Authorization=`Bearer ${x}`),fetch("/api/watch/snapshot",{headers:j}).then(a=>a.status===401?(localStorage.removeItem("titan-token"),localStorage.removeItem("titan_token"),window.location.reload(),null):a.ok?a.json():null).then(a=>{a&&!a.error&&(g(a),R(a.drives))}).catch(()=>{})},[R]),d.useEffect(()=>(M(),()=>{var x;(x=f.current)==null||x.close(),f.current=null}),[M]),{drives:t,events:n,connected:l,reconnecting:h,lastActivity:s,snapshot:w,reconnect:I}}function oe(t){for(const i of t)if(se.has(i.topic))return i;return t[0]||null}function le({events:t,voice:i}){const n=d.useMemo(()=>oe(t),[t]),r=n?i==="titan"?n.captionTitan:n.captionControl:null;return e.jsxs("div",{style:{position:"relative",minHeight:80},children:[e.jsx("div",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:"0.15em",color:"rgba(255, 255, 255, 0.35)",marginBottom:10,fontWeight:600},children:"What I'm doing"}),e.jsx(q,{mode:"wait",initial:!1,children:e.jsx(V.div,{initial:{opacity:0,y:4},animate:{opacity:1,y:0},exit:{opacity:0,y:-4},transition:{duration:.3},style:{fontSize:"clamp(18px, 2.4vw, 24px)",fontWeight:500,lineHeight:1.35,color:r?"rgba(255, 255, 255, 0.95)":"rgba(255, 255, 255, 0.45)"},children:r||"Standing by."},(n==null?void 0:n.id)||"idle")}),n&&e.jsxs("div",{style:{display:"flex",gap:12,marginTop:12,fontSize:11,color:"rgba(255, 255, 255, 0.35)",flexWrap:"wrap"},children:[e.jsx("span",{children:J(n.timestamp)}),n.detail&&e.jsxs("span",{children:["· ",n.detail]})]})]})}const ce={drive:"var(--color-purple-light)",soma:"#c084fc",tool:"#60a5fa",goal:"var(--color-emerald)",channel:"#fb7185",agent:"#c084fc",health:"#fbbf24",memory:"#e879f9",system:"#9ca3af"};function de({events:t,voice:i,onEventClick:n}){const[,r]=d.useState(0);d.useEffect(()=>{const o=setInterval(()=>r(h=>h+1),2e4);return()=>clearInterval(o)},[]);const l=d.useMemo(()=>t.slice(0,80),[t]);return l.length===0?e.jsx("div",{style:{color:"rgba(255,255,255,0.35)",fontSize:13,fontStyle:"italic",padding:"24px 16px",textAlign:"center"},children:"Listening for TITAN to do something…"}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4,overflow:"hidden"},children:e.jsx(q,{initial:!1,children:l.map((o,h)=>{const y=i==="titan"?o.captionTitan:o.captionControl,s=ce[o.kind]||"#9ca3af",m=h===0;return e.jsxs(V.div,{initial:{opacity:0,y:-6},animate:{opacity:1,y:0},exit:{opacity:0,y:4},transition:{duration:.35,ease:"easeOut"},onClick:()=>n==null?void 0:n(o),style:{display:"flex",alignItems:"flex-start",gap:12,padding:"10px 12px",borderRadius:10,background:m?`${s}14`:"rgba(255, 255, 255, 0.015)",borderLeft:`2px solid ${s}`,fontSize:13,lineHeight:1.35,transition:"background 0.2s, transform 0.15s",cursor:n?"pointer":"default"},onMouseEnter:w=>{n&&(w.currentTarget.style.background=`${s}22`)},onMouseLeave:w=>{w.currentTarget.style.background=m?`${s}14`:"rgba(255, 255, 255, 0.015)"},title:`Click for details · ${o.topic}`,children:[e.jsx("div",{style:{fontSize:15,flexShrink:0,width:20,textAlign:"center",marginTop:1},children:o.icon}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{color:"rgba(255,255,255,0.92)"},children:y}),o.detail&&e.jsx("div",{style:{color:"rgba(255,255,255,0.45)",fontSize:11,marginTop:2,lineHeight:1.3},children:o.detail})]}),e.jsx("div",{style:{color:"rgba(255,255,255,0.35)",fontSize:11,flexShrink:0,fontVariantNumeric:"tabular-nums",whiteSpace:"nowrap",marginTop:1},children:J(o.timestamp)})]},o.id)})})})}function P(t,i){const n=t.match(/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i);return n?`rgba(${parseInt(n[1],16)}, ${parseInt(n[2],16)}, ${parseInt(n[3],16)}, ${i})`:`rgba(160, 160, 160, ${i})`}function pe({drives:t,excited:i=!1,reducedMotion:n=!1}){const r=d.useRef(null),l=d.useRef(t),o=d.useRef(i),h=d.useRef(null);return d.useEffect(()=>{l.current=t},[t]),d.useEffect(()=>{o.current=i},[i]),d.useEffect(()=>{const y=r.current;if(!y)return;const s=y.getContext("2d",{alpha:!0});if(!s)return;const m=Math.min(window.devicePixelRatio||1,2),w=()=>{const I=y.getBoundingClientRect();y.width=Math.max(2,I.width*m),y.height=Math.max(2,I.height*m),s.setTransform(m,0,0,m,0,0)};w();const g=new ResizeObserver(w);g.observe(y);const f=[],R=60,M=()=>{h.current=requestAnimationFrame(M);const I=y.getBoundingClientRect(),x=I.width,j=I.height;if(x<10||j<10)return;const a=x/2,S=j/2,H=Math.min(x,j)*.11,T=Math.min(x,j)*.34,N=performance.now()/1e3,c=l.current;s.clearRect(0,0,x,j);const $=s.createRadialGradient(a,S,0,a,S,Math.min(x,j)*.55),A=n?.08:.08+.03*Math.sin(N*.5);$.addColorStop(0,`rgba(255, 255, 255, ${A*2})`),$.addColorStop(.3,`rgba(167, 139, 250, ${A})`),$.addColorStop(1,"rgba(167, 139, 250, 0)"),s.fillStyle=$,s.fillRect(0,0,x,j);const F=Math.max(c.length,5);for(let v=0;v<c.length;v++){const p=c[v],D=v/F*Math.PI*2-Math.PI/2,b=a+Math.cos(D)*T,k=S+Math.sin(D)*T,W=Math.min(1,(p.pressure||0)*3),G=n?0:.35+W*1.4,_=n?0:.04+W*.15,z=H*(.75+_*Math.sin(N*G+v*1.3)),C=Y(p.id),E=z*2.8,B=s.createRadialGradient(b,k,0,b,k,E);B.addColorStop(0,P(C,.35)),B.addColorStop(.35,P(C,.18)),B.addColorStop(1,P(C,0)),s.fillStyle=B,s.beginPath(),s.arc(b,k,E,0,Math.PI*2),s.fill();const L=s.createRadialGradient(b-z*.3,k-z*.3,0,b,k,z);L.addColorStop(0,P(C,.95)),L.addColorStop(.55,P(C,.55)),L.addColorStop(1,P(C,.2)),s.fillStyle=L,s.beginPath(),s.arc(b,k,z,0,Math.PI*2),s.fill(),W>.1&&(s.strokeStyle=P(C,.6+.3*Math.sin(N*3+v)),s.lineWidth=1.5,s.beginPath(),s.arc(b,k,z*1.05,0,Math.PI*2),s.stroke()),s.font='600 10px -apple-system, BlinkMacSystemFont, "Inter", system-ui, sans-serif',s.textAlign="center",s.fillStyle="rgba(255,255,255,0.65)",s.fillText(p.label.toUpperCase(),b,k+z+18),s.font="11px -apple-system, system-ui",s.fillStyle="rgba(255,255,255,0.35)",s.fillText(`${Math.round((p.satisfaction||0)*100)}%`,b,k+z+32);const Z=W*.25+(o.current?.03:0);!n&&f.length<R&&Math.random()<Z&&f.push({sourceIdx:v,phase:0,color:C,size:2+Math.random()*2})}if(!n)for(let v=f.length-1;v>=0;v--){const p=f[v];if(p.phase+=.012,p.phase>=1){f.splice(v,1);continue}if(!c[p.sourceIdx]){f.splice(v,1);continue}const b=p.sourceIdx/F*Math.PI*2-Math.PI/2,k=a+Math.cos(b)*T,W=S+Math.sin(b)*T,G=(k+a)/2+Math.sin(b+Math.PI/2)*20,_=(W+S)/2+Math.cos(b+Math.PI/2)*20,z=(1-p.phase)*(1-p.phase)*k+2*(1-p.phase)*p.phase*G+p.phase*p.phase*a,C=(1-p.phase)*(1-p.phase)*W+2*(1-p.phase)*p.phase*_+p.phase*p.phase*S,E=Math.sin(p.phase*Math.PI)*.9;s.fillStyle=P(p.color,E),s.beginPath(),s.arc(z,C,p.size,0,Math.PI*2),s.fill()}if(!n){const p=N%20/20;if(p<.18){const D=H+p*Math.min(x,j)*2.5,b=(1-p/.18)*.18;s.strokeStyle=`rgba(167, 139, 250, ${b})`,s.lineWidth=1.5,s.beginPath(),s.arc(a,S,D,0,Math.PI*2),s.stroke()}}};return h.current=requestAnimationFrame(M),()=>{g.disconnect(),h.current&&cancelAnimationFrame(h.current)}},[n]),e.jsx("canvas",{ref:r,style:{width:"100%",height:"100%",display:"block"},"aria-label":"TITAN organism — 5 drives breathing"})}function he({event:t,voice:i,onClose:n}){return e.jsx(q,{children:t&&e.jsxs(e.Fragment,{children:[e.jsx(V.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.18},onClick:n,style:{position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.55)",backdropFilter:"blur(4px)",WebkitBackdropFilter:"blur(4px)",zIndex:99}},"backdrop"),e.jsx(V.aside,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{duration:.28,ease:[.32,.72,0,1]},style:{position:"fixed",top:0,right:0,bottom:0,width:"min(540px, 100vw)",background:"rgba(10, 12, 20, 0.96)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",borderLeft:"1px solid rgba(167, 139, 250, 0.15)",display:"flex",flexDirection:"column",zIndex:100,color:"#f8f9fc",boxShadow:"-20px 0 60px rgba(0,0,0,0.5)"},role:"dialog","aria-modal":"true",children:e.jsx(ue,{event:t,voice:i,onClose:n})},"panel")]})})}function ue({event:t,voice:i,onClose:n}){const r=i==="titan"?t.captionTitan:t.captionControl,l=t.raw||{};return d.useEffect(()=>{const o=h=>{h.key==="Escape"&&n()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[n]),e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{padding:"20px 24px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"flex-start",gap:12},children:[e.jsx("div",{style:{fontSize:22,width:36,height:36,borderRadius:10,background:"rgba(255,255,255,0.04)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.icon}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:17,fontWeight:600,lineHeight:1.3,marginBottom:4},children:r}),e.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.35)",display:"flex",gap:10},children:[e.jsx("span",{children:J(t.timestamp)}),e.jsx("span",{style:{opacity:.5},children:"·"}),e.jsx("span",{style:{textTransform:"uppercase",letterSpacing:"0.1em"},children:t.kind}),e.jsx("span",{style:{opacity:.5},children:"·"}),e.jsx("span",{style:{fontFamily:"ui-monospace, monospace",fontSize:10},children:t.topic})]})]}),e.jsx("button",{onClick:n,"aria-label":"Close",style:{background:"transparent",border:0,color:"rgba(255,255,255,0.55)",cursor:"pointer",padding:6,borderRadius:8,display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(ee,{size:18})})]}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px",minHeight:0},children:[t.detail&&e.jsx(u,{label:"Detail",children:e.jsx("div",{style:{fontSize:13,color:"rgba(255,255,255,0.75)",lineHeight:1.5},children:t.detail})}),t.kind==="soma"&&e.jsx(ge,{raw:l}),t.kind==="goal"&&e.jsx(fe,{raw:l}),t.kind==="tool"&&e.jsx(xe,{raw:l,topic:t.topic}),t.kind==="channel"&&e.jsx(me,{raw:l,topic:t.topic}),t.kind==="drive"&&e.jsx(be,{raw:l,topic:t.topic}),(t.kind==="system"||t.kind==="agent"||t.kind==="memory"||t.kind==="health")&&e.jsx(ye,{raw:l,topic:t.topic})]}),e.jsx(ve,{label:"Raw event data",raw:l})]})}function u({label:t,children:i}){return e.jsxs("div",{style:{marginBottom:20},children:[e.jsx("div",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:"0.15em",color:"rgba(255,255,255,0.35)",fontWeight:600,marginBottom:8},children:t}),i]})}function ge({raw:t}){const i=t.approvalId,n=t.dominantDrives||[],r=t.shadowVerdict;return e.jsxs(e.Fragment,{children:[e.jsx(u,{label:"What drove this",children:e.jsxs("div",{style:{fontSize:13,color:"rgba(255,255,255,0.75)"},children:[n.length?n.map(l=>l[0].toUpperCase()+l.slice(1)).join(", "):"an unspecified drive"," ","was below its setpoint. Soma filed this proposal autonomously."]})}),i&&e.jsx(u,{label:"Command Post approval",children:e.jsx("code",{style:{fontSize:11,color:"rgba(167, 139, 250, 0.9)"},children:i})}),r&&e.jsx(u,{label:"Shadow rehearsal verdict",children:e.jsx("pre",{style:{fontSize:11,lineHeight:1.4,color:"rgba(255,255,255,0.7)",whiteSpace:"pre-wrap",wordBreak:"break-word",background:"rgba(255,255,255,0.02)",padding:12,borderRadius:8},children:JSON.stringify(r,null,2)})})]})}function fe({raw:t}){const i=t.goalId,[n,r]=d.useState(null),[l,o]=d.useState(!1);if(d.useEffect(()=>{i&&(o(!0),Q(`/api/goals/${i}`).then(s=>s.ok?s.json():null).then(s=>r((s==null?void 0:s.goal)||s||null)).catch(()=>{}).finally(()=>o(!1)))},[i]),!i)return null;if(l)return e.jsx(u,{label:"Goal",children:e.jsx("div",{style:{color:"rgba(255,255,255,0.4)",fontSize:12},children:"Loading…"})});if(!n)return e.jsx(u,{label:"Goal",children:e.jsx("div",{style:{color:"rgba(255,255,255,0.4)",fontSize:12},children:"Goal not found (may have been deleted)."})});const h=n.subtasks||[],y=h.filter(s=>s.status==="done"||s.status==="skipped").length;return e.jsxs(u,{label:"Goal",children:[e.jsx("div",{style:{fontSize:14,fontWeight:600,marginBottom:6},children:String(n.title||"")}),e.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.4)",marginBottom:12},children:[String(n.status||"")," · ",y,"/",h.length," subtasks"]}),h.length>0&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:h.map((s,m)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"8px 10px",borderRadius:8,background:"rgba(255,255,255,0.02)",fontSize:12},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:K(s.status),boxShadow:`0 0 6px ${K(s.status)}`,flexShrink:0}}),e.jsx("span",{style:{flex:1},children:String(s.title||"")}),e.jsx("span",{style:{fontSize:10,color:"rgba(255,255,255,0.35)",textTransform:"uppercase",letterSpacing:"0.1em"},children:String(s.status||"")})]},m))})]})}function K(t){switch(t){case"done":return"var(--color-emerald)";case"running":return"var(--color-cyan)";case"failed":return"var(--color-error)";case"skipped":return"var(--color-text-secondary)";case"pending":return"#fbbf24";default:return"#9ca3af"}}function xe({raw:t,topic:i}){const n=t.tool,r=t.argsPreview,l=t.durationMs,o=t.success;return e.jsxs(e.Fragment,{children:[n&&e.jsx(u,{label:"Tool",children:e.jsx("code",{style:{fontSize:12,color:"rgba(96, 165, 250, 0.9)"},children:n})}),r!==void 0&&e.jsx(u,{label:"Arguments",children:e.jsx("pre",{style:{fontSize:11,lineHeight:1.4,color:"rgba(255,255,255,0.7)",whiteSpace:"pre-wrap",wordBreak:"break-word",background:"rgba(255,255,255,0.02)",padding:12,borderRadius:8,maxHeight:300,overflowY:"auto"},children:typeof r=="string"?r:JSON.stringify(r,null,2)})}),i==="tool:result"&&e.jsx(u,{label:"Result",children:e.jsxs("div",{style:{fontSize:13,color:o?"rgba(52,211,153,0.9)":"rgba(239,68,68,0.9)"},children:[o?"✓ Completed":"✗ Failed",l!==void 0&&e.jsxs("span",{style:{color:"rgba(255,255,255,0.5)",marginLeft:8},children:["in ",l,"ms"]})]})})]})}function me({raw:t,topic:i}){const n=t.sessionId,r=t.channel,l=t.userId,o=t.message,h=t.toolsUsed||[],y=t.model,s=t.durationMs,[m,w]=d.useState(null);return d.useEffect(()=>{n&&Q(`/api/sessions/${n}`).then(g=>g.ok?g.json():null).then(g=>{const f=Array.isArray(g)?g:(g==null?void 0:g.messages)||[];w(f)}).catch(()=>{})},[n]),e.jsxs(e.Fragment,{children:[r&&e.jsx(u,{label:"Channel",children:e.jsxs("div",{style:{fontSize:13},children:[r,l&&e.jsxs("span",{style:{color:"rgba(255,255,255,0.4)"},children:[" · ",l]})]})}),o&&e.jsx(u,{label:i==="turn:pre"?"What they said":"Message",children:e.jsx("div",{style:{fontSize:13,lineHeight:1.5,color:"rgba(255,255,255,0.8)",padding:12,background:"rgba(255,255,255,0.02)",borderRadius:8},children:o})}),i==="turn:post"&&e.jsx(u,{label:"Turn stats",children:e.jsxs("div",{style:{fontSize:12,color:"rgba(255,255,255,0.55)",lineHeight:1.6},children:[s!==void 0&&e.jsxs("div",{children:["Took ",(s/1e3).toFixed(1),"s"]}),y&&e.jsxs("div",{children:["Model: ",y]}),h.length>0&&e.jsxs("div",{children:["Used: ",h.join(", ")]})]})}),m&&m.length>0&&e.jsx(u,{label:"Session messages",children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10,maxHeight:400,overflowY:"auto"},children:m.slice(-8).map((g,f)=>e.jsxs("div",{style:{padding:10,borderRadius:8,background:g.role==="assistant"?"rgba(167, 139, 250, 0.06)":"rgba(255,255,255,0.02)",borderLeft:`2px solid ${g.role==="assistant"?"var(--color-purple-light)":"rgba(255,255,255,0.2)"}`,fontSize:12},children:[e.jsx("div",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:"0.1em",color:"rgba(255,255,255,0.35)",marginBottom:4},children:String(g.role||"?")}),e.jsxs("div",{style:{color:"rgba(255,255,255,0.85)",lineHeight:1.5,whiteSpace:"pre-wrap"},children:[String(g.content||"").slice(0,400),String(g.content||"").length>400&&"…"]})]},f))})})]})}function be({raw:t,topic:i}){const n=t.drives||[],r=t.totalPressure,l=t.dominantDrives||[];return e.jsxs(e.Fragment,{children:[r!==void 0&&e.jsx(u,{label:"Pressure snapshot",children:e.jsxs("div",{style:{fontSize:13,color:"rgba(255,255,255,0.75)"},children:["Total: ",e.jsx("strong",{children:r.toFixed(3)}),l.length>0&&e.jsxs("span",{children:[" · Dominant: ",l.map(o=>o[0].toUpperCase()+o.slice(1)).join(", ")]})]})}),n.length>0&&i==="drive:tick"&&e.jsx(u,{label:"All drives this tick",children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:n.map((o,h)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"8px 10px",borderRadius:8,background:"rgba(255,255,255,0.02)",fontSize:12},children:[e.jsx("span",{style:{flex:1,fontWeight:500},children:String(o.label||o.id)}),e.jsxs("span",{style:{color:"rgba(255,255,255,0.55)",fontVariantNumeric:"tabular-nums"},children:["sat ",(Number(o.satisfaction)*100).toFixed(0),"% · sp ",(Number(o.setpoint)*100).toFixed(0),"%"]}),e.jsx("span",{style:{color:Number(o.pressure)>0?"#fbbf24":"rgba(255,255,255,0.25)",fontVariantNumeric:"tabular-nums",width:50,textAlign:"right"},children:Number(o.pressure).toFixed(2)})]},h))})})]})}function ye({raw:t,topic:i}){if(i==="initiative:round"){const n=t.round,r=t.maxRounds,l=t.subtaskTitle;return e.jsx(u,{label:"What's happening",children:e.jsxs("div",{style:{fontSize:13,color:"rgba(255,255,255,0.8)",lineHeight:1.6},children:["TITAN is reasoning through round ",e.jsx("strong",{children:n})," of ",e.jsx("strong",{children:r}),l&&e.jsxs(e.Fragment,{children:[" on the subtask ",e.jsxs("em",{style:{color:"rgba(167, 139, 250, 0.9)"},children:['"',l,'"']})]}),".",e.jsx("br",{}),e.jsx("br",{}),"Each round is one tool-calling cycle — the agent thinks, picks a tool, runs it, then thinks again with the result. The cycle continues until the subtask is complete or the round budget runs out."]})})}if(i==="initiative:start"){const n=t.subtaskTitle,r=t.goalTitle;return e.jsx(u,{label:"What's happening",children:e.jsxs("div",{style:{fontSize:13,color:"rgba(255,255,255,0.8)",lineHeight:1.6},children:["TITAN picked up a task and started working.",n&&e.jsxs(e.Fragment,{children:[" Subtask: ",e.jsxs("em",{style:{color:"rgba(167, 139, 250, 0.9)"},children:['"',n,'"']}),"."]}),r&&e.jsxs(e.Fragment,{children:[" Part of goal: ",e.jsxs("em",{style:{color:"rgba(52, 211, 153, 0.9)"},children:['"',r,'"']}),"."]})]})})}if(i==="initiative:complete"){const n=t.success,r=t.toolsUsed||[],l=t.summary;return e.jsxs(u,{label:"Result",children:[e.jsxs("div",{style:{fontSize:13,color:"rgba(255,255,255,0.8)",lineHeight:1.6},children:[n===!1?"The task ran but ended without full success.":"Task complete.",r.length>0&&e.jsxs(e.Fragment,{children:[" Tools used: ",r.join(", "),"."]})]}),l&&e.jsx("div",{style:{marginTop:8,padding:10,borderRadius:8,background:"rgba(255,255,255,0.02)",fontSize:12,lineHeight:1.5,color:"rgba(255,255,255,0.7)"},children:l})]})}if(i==="initiative:no_progress"){const n=t.reason;return e.jsx(u,{label:"Why it paused",children:e.jsx("div",{style:{fontSize:13,color:"rgba(251, 191, 36, 0.9)",lineHeight:1.6},children:n||"Ran but couldn't advance."})})}if(i==="dreaming:consolidated")return e.jsx(u,{label:"What's happening",children:e.jsx("div",{style:{fontSize:13,color:"rgba(255,255,255,0.8)",lineHeight:1.6},children:"TITAN periodically consolidates recent memories — merging related facts, pruning stale ones, strengthening frequently-accessed associations. It's how it keeps the memory graph fast without losing useful context."})});if(i==="daemon:started"||i==="daemon:resumed")return e.jsx(u,{label:"What's happening",children:e.jsx("div",{style:{fontSize:13,color:"rgba(255,255,255,0.8)",lineHeight:1.6},children:"TITAN's background daemon came online. All watchers (goals, cron, health, memory, drive ticks, Facebook autopilot) are active."})});if(i==="daemon:paused")return e.jsx(u,{label:"What's happening",children:e.jsx("div",{style:{fontSize:13,color:"rgba(255,255,255,0.8)",lineHeight:1.6},children:"Background work is paused. Chat still works; cron, autopilot, and Soma ticks are halted until resumed."})});if(i.startsWith("health:"))return e.jsx(u,{label:"Health alert",children:e.jsx("div",{style:{fontSize:13,color:"rgba(251, 191, 36, 0.9)",lineHeight:1.6},children:"A subsystem reported a health issue. Check the Console tab for diagnostics."})});if(i==="agent:spawned"||i==="agent:stopped"){const n=t.name,r=t.model;return e.jsx(u,{label:"What's happening",children:e.jsxs("div",{style:{fontSize:13,color:"rgba(255,255,255,0.8)",lineHeight:1.6},children:[i==="agent:spawned"?"Spawned":"Stopped"," sub-agent",n&&e.jsxs(e.Fragment,{children:[" ",e.jsx("strong",{children:n})]}),r&&i==="agent:spawned"&&e.jsxs(e.Fragment,{children:[" running ",r]}),"."]})})}if(i==="agent:task:completed"||i==="agent:task:failed"){const n=t.agentId,r=t.reason,l=t.success;return e.jsx(u,{label:"Sub-agent result",children:e.jsxs("div",{style:{fontSize:13,color:"rgba(255,255,255,0.8)",lineHeight:1.6},children:[n&&e.jsxs(e.Fragment,{children:["Sub-agent ",e.jsx("strong",{children:n})," "]}),i==="agent:task:completed"&&l!==!1?"finished its task successfully.":r?`couldn't complete: ${r}.`:"did not complete its task."]})})}return e.jsx(je,{raw:t})}function je({raw:t}){const i=Object.entries(t||{}).filter(([n])=>n!=="timestamp");return i.length===0?null:e.jsx(u,{label:"Details",children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:i.slice(0,8).map(([n,r])=>e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:12,padding:"6px 10px",borderRadius:6,background:"rgba(255,255,255,0.02)",fontSize:11},children:[e.jsx("span",{style:{color:"rgba(255,255,255,0.4)"},children:n}),e.jsx("span",{style:{color:"rgba(255,255,255,0.8)",fontFamily:"ui-monospace, monospace",textAlign:"right",wordBreak:"break-all"},children:Se(r)})]},n))})})}function Se(t){if(t==null)return"—";if(typeof t=="string")return t.length>80?t.slice(0,77)+"…":t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t).slice(0,80)}catch{return"[object]"}}function ve({label:t,raw:i}){const[n,r]=d.useState(!1);return e.jsxs("div",{style:{borderTop:"1px solid rgba(255,255,255,0.06)"},children:[e.jsxs("button",{onClick:()=>r(l=>!l),style:{width:"100%",padding:"14px 24px",background:"transparent",border:0,color:"rgba(255,255,255,0.5)",fontSize:11,textTransform:"uppercase",letterSpacing:"0.15em",fontWeight:600,textAlign:"left",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("span",{children:t}),e.jsx("span",{style:{fontSize:14},children:n?"−":"+"})]}),n&&e.jsx("pre",{style:{margin:0,padding:"0 24px 20px",fontSize:10,lineHeight:1.4,color:"rgba(255,255,255,0.5)",whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:300,overflowY:"auto"},children:JSON.stringify(i,null,2)})]})}function Ie(){var x,j;const[t]=te(),i=t.get("kiosk")==="1",n=t.get("voice")==="control"?"control":"titan",[r,l]=d.useState(n),[o,h]=d.useState(null),{drives:y,events:s,connected:m,reconnecting:w,lastActivity:g}=ae(),f=g>0&&Date.now()-g<1e4,R=typeof window<"u"&&((j=(x=window.matchMedia)==null?void 0:x.call(window,"(prefers-reduced-motion: reduce)"))==null?void 0:j.matches);d.useEffect(()=>{if(!i)return;let a=null;const S=async()=>{try{"wakeLock"in navigator&&(a=await navigator.wakeLock.request("screen"))}catch{}};S();const H=()=>{document.visibilityState==="visible"&&S()};return document.addEventListener("visibilitychange",H),()=>{var T;document.removeEventListener("visibilitychange",H),(T=a==null?void 0:a.release)==null||T.call(a)}},[i]);const M=d.useMemo(()=>m?"live":w?"reconnecting…":"connecting…",[m,w]),I=m?"var(--color-emerald)":w?"#fbbf24":"#6b7280";return e.jsxs("div",{style:{position:i?"fixed":"relative",inset:i?0:void 0,height:"100%",width:"100%",minHeight:i?"100vh":"100%",background:"radial-gradient(ellipse at 20% 30%, rgba(167, 139, 250, 0.06) 0%, transparent 55%), radial-gradient(ellipse at 80% 70%, rgba(34, 211, 238, 0.05) 0%, transparent 55%), radial-gradient(ellipse at 50% 50%, rgba(52, 211, 153, 0.03) 0%, transparent 60%), #05060a",color:"#f8f9fc",overflow:"hidden",fontFamily:'-apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, system-ui, sans-serif',display:"flex",flexDirection:"column",zIndex:i?9999:void 0},children:[e.jsx("div",{"aria-hidden":!0,style:{position:"absolute",inset:0,opacity:.03,pointerEvents:"none",backgroundImage:`url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/></filter><rect width='200' height='200' filter='url(%23n)' opacity='0.8'/></svg>")`}}),e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",padding:i?"32px 40px":"20px 24px",minHeight:0,zIndex:1},children:[!i&&e.jsxs("header",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:16,fontSize:13},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,color:"rgba(255,255,255,0.5)",fontWeight:600,letterSpacing:"0.02em"},children:[e.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:I,boxShadow:`0 0 10px ${I}`,animation:"watch-pulse 2s ease-in-out infinite"}}),e.jsx("span",{children:"TITAN"}),e.jsx("span",{style:{opacity:.4},children:"·"}),e.jsx("span",{children:M})]}),e.jsx("div",{style:{display:"flex",gap:2,background:"rgba(20, 24, 36, 0.6)",border:"1px solid rgba(80, 90, 120, 0.25)",borderRadius:999,padding:2},children:["titan","control"].map(a=>e.jsx("button",{onClick:()=>l(a),style:{background:r===a?"#f8f9fc":"transparent",color:r===a?"#05060a":"rgba(255,255,255,0.55)",border:0,padding:"6px 14px",borderRadius:999,cursor:"pointer",fontSize:11,fontWeight:600,letterSpacing:"0.02em",transition:"all 0.15s",textTransform:"uppercase"},children:a==="titan"?"TITAN":"Mission"},a))})]}),e.jsxs("main",{style:{display:"grid",gridTemplateColumns:"minmax(0, 1.05fr) minmax(0, 1fr)",gridTemplateRows:"auto 1fr",gridTemplateAreas:'"focus activity" "organism activity"',gap:i?28:18,flex:1,minHeight:0},className:"watch-grid",children:[e.jsx(U,{gridArea:"focus",excited:f,children:e.jsx(le,{events:s,voice:r})}),e.jsxs(U,{gridArea:"organism",excited:f,padding:i?24:16,children:[e.jsx("div",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:"0.15em",color:"rgba(255,255,255,0.35)",fontWeight:600,marginBottom:6},children:"How I'm feeling"}),e.jsx("div",{style:{flex:1,minHeight:i?320:220},children:e.jsx(pe,{drives:y,excited:f,reducedMotion:R})}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(90px, 1fr))",gap:8,marginTop:10,fontSize:11},children:y.map(a=>{const S=(a.pressure||0)>.01;return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"6px 10px",borderRadius:8,background:S?"rgba(251, 191, 36, 0.08)":"rgba(255,255,255,0.02)",border:`1px solid ${S?"rgba(251, 191, 36, 0.3)":"rgba(255,255,255,0.04)"}`},title:a.description||`${a.label}: satisfaction ${a.satisfaction.toFixed(2)}, setpoint ${a.setpoint.toFixed(2)}`,children:[e.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:Y(a.id),boxShadow:`0 0 8px ${Y(a.id)}`}}),e.jsx("div",{style:{flex:1,color:"rgba(255,255,255,0.65)",fontWeight:500},children:a.label}),e.jsxs("div",{style:{color:"rgba(255,255,255,0.35)",fontVariantNumeric:"tabular-nums"},children:[Math.round((a.satisfaction||0)*100),"%"]})]},a.id)})})]}),e.jsxs(U,{gridArea:"activity",excited:f,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},children:[e.jsx("div",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:"0.15em",color:"rgba(255,255,255,0.35)",fontWeight:600},children:"Recent activity"}),e.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.35)",fontVariantNumeric:"tabular-nums"},children:[s.length," ",s.length===1?"event":"events"]})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",minHeight:0,maskImage:"linear-gradient(to bottom, transparent 0, black 16px, black calc(100% - 16px), transparent 100%)",WebkitMaskImage:"linear-gradient(to bottom, transparent 0, black 16px, black calc(100% - 16px), transparent 100%)",paddingRight:4},children:e.jsx(de,{events:s,voice:r,onEventClick:h})})]})]})]}),e.jsx(he,{event:o,voice:r,onClose:()=>h(null)}),e.jsx("style",{children:`
2
2
  @keyframes watch-pulse {
3
3
  0%, 100% { opacity: 1; transform: scale(1); }
4
4
  50% { opacity: 0.6; transform: scale(0.85); }
@@ -0,0 +1 @@
1
+ import{r as o,j as e,X as L,b as S,f as J,bn as q}from"./index-DzwowwSI.js";import{A as D,m as $}from"./proxy-DxS2_9D7.js";import{E as K}from"./external-link-BZ0y_Ahx.js";import{R as B}from"./rotate-ccw-Co-_W04j.js";import{P as U}from"./plus-Csu2v9GN.js";import{P as F}from"./play-DVY9c5Ck.js";import{T as M}from"./trash-2-DgWrHVax.js";import{P as _}from"./pause-CYhO_uQo.js";function V({open:a,approval:s,onClose:l}){var N,k,w;const[c,n]=o.useState(null),[p,r]=o.useState(!1),[y,m]=o.useState(!1),u=(N=s==null?void 0:s.payload)==null?void 0:N.goalId;if(o.useEffect(()=>{if(!a||!u){n(null),m(!1);return}let b=!1;const C=async()=>{try{const f=await S(`/api/goals/${u}`);if(!f.ok){b||(m(!0),r(!1));return}const h=await f.json();if(b)return;n(h.goal||h),m(!1),r(!1)}catch{b||(m(!0),r(!1))}};r(!0),C();const d=setInterval(C,5e3);return()=>{b=!0,clearInterval(d)}},[a,u]),o.useEffect(()=>{if(!a)return;const b=C=>{C.key==="Escape"&&l()};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[a,l]),!s)return null;const j=s.title||((k=s.payload)==null?void 0:k.title)||"Approval",x=(w=s.payload)==null?void 0:w.rationale;return e.jsx(D,{children:a&&e.jsxs(e.Fragment,{children:[e.jsx($.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.18},onClick:l,style:{position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.55)",backdropFilter:"blur(4px)",WebkitBackdropFilter:"blur(4px)",zIndex:99}},"backdrop"),e.jsxs($.aside,{initial:{x:"100%"},animate:{x:0},exit:{x:"100%"},transition:{duration:.28,ease:[.32,.72,0,1]},style:{position:"fixed",top:0,right:0,bottom:0,width:"min(540px, 100vw)",background:"rgba(10, 12, 20, 0.96)",backdropFilter:"blur(24px)",WebkitBackdropFilter:"blur(24px)",borderLeft:"1px solid rgba(167, 139, 250, 0.15)",display:"flex",flexDirection:"column",zIndex:100,color:"#f8f9fc",boxShadow:"-20px 0 60px rgba(0,0,0,0.5)"},role:"dialog","aria-modal":"true",children:[e.jsxs("div",{style:{padding:"20px 24px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"flex-start",gap:12},children:[e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:"0.15em",color:"rgba(255,255,255,0.35)",fontWeight:600,marginBottom:6},children:"Proposal"}),e.jsx("div",{style:{fontSize:17,fontWeight:600,lineHeight:1.3,marginBottom:6},children:j}),e.jsx("div",{style:{fontSize:11,color:"rgba(255,255,255,0.35)"},children:e.jsx(G,{status:s.status})})]}),e.jsx("button",{onClick:l,"aria-label":"Close",style:{background:"transparent",border:0,color:"rgba(255,255,255,0.55)",cursor:"pointer",padding:6,borderRadius:8},children:e.jsx(L,{size:18})})]}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px"},children:[x&&e.jsx(z,{label:"Why this",children:e.jsx("div",{style:{fontSize:13,color:"rgba(255,255,255,0.75)",lineHeight:1.5},children:x})}),!u&&s.status==="pending"&&e.jsx(z,{label:"Status",children:e.jsx("div",{style:{fontSize:13,color:"rgba(251, 191, 36, 0.9)"},children:"Waiting for approval. Once approved, a goal will be created and TITAN will start working on it."})}),!u&&s.status==="rejected"&&e.jsx(z,{label:"Status",children:e.jsx("div",{style:{fontSize:13,color:"rgba(255,255,255,0.5)"},children:"Rejected. No work started."})}),u&&e.jsxs(e.Fragment,{children:[p&&!c&&e.jsx(z,{label:"Progress",children:e.jsx("div",{style:{fontSize:13,color:"rgba(255,255,255,0.4)"},children:"Loading goal…"})}),y&&e.jsx(z,{label:"Progress",children:e.jsx("div",{style:{fontSize:13,color:"rgba(255,255,255,0.4)"},children:"Goal linked to this approval wasn't found (may have been deleted)."})}),c&&e.jsx(X,{goal:c})]})]}),e.jsxs("div",{style:{padding:"14px 24px",borderTop:"1px solid rgba(255,255,255,0.06)",display:"flex",gap:10},children:[u&&e.jsxs("a",{href:"/command-post",onClick:b=>{b.preventDefault(),window.location.hash="#watch",l()},style:{display:"inline-flex",alignItems:"center",gap:6,padding:"8px 14px",borderRadius:8,background:"rgba(167, 139, 250, 0.12)",color:"#c4b5fd",fontSize:12,fontWeight:500,textDecoration:"none",cursor:"pointer"},children:[e.jsx(K,{size:12})," Watch live"]}),e.jsx("button",{onClick:l,style:{padding:"8px 14px",borderRadius:8,background:"rgba(255,255,255,0.04)",border:0,color:"rgba(255,255,255,0.55)",fontSize:12,cursor:"pointer"},children:"Close"})]})]},"panel")]})})}function X({goal:a}){const s=a.subtasks||[],l=s.filter(r=>r.status==="done"||r.status==="skipped").length,c=s.filter(r=>r.status==="failed").length,n=s.filter(r=>r.status==="running").length,p=s.length?l/s.length*100:a.progress||0;return e.jsxs(e.Fragment,{children:[e.jsxs(z,{label:"Progress",children:[e.jsxs("div",{style:{marginBottom:10},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:12,marginBottom:6},children:[e.jsxs("span",{style:{color:"rgba(255,255,255,0.6)"},children:[l," / ",s.length," complete"]}),e.jsxs("span",{style:{color:"rgba(255,255,255,0.4)",fontVariantNumeric:"tabular-nums"},children:[p.toFixed(0),"%"]})]}),e.jsx("div",{style:{height:6,borderRadius:3,background:"rgba(255,255,255,0.04)",overflow:"hidden"},children:e.jsx("div",{style:{width:`${p}%`,height:"100%",background:c>0?"linear-gradient(to right, #34d399, #fbbf24)":"var(--color-emerald)",transition:"width 0.5s"}})})]}),e.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.4)",display:"flex",gap:12},children:[e.jsx(G,{status:a.status}),n>0&&e.jsxs("span",{children:["· ",n," running"]}),c>0&&e.jsxs("span",{style:{color:"rgba(239, 68, 68, 0.9)"},children:["· ",c," failed"]})]})]}),s.length>0&&e.jsx(z,{label:"Subtasks",children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:s.map(r=>e.jsx(Y,{goalId:a.id,subtask:r},r.id))})})]})}function Y({goalId:a,subtask:s}){const l=O(s.status),c=s.status==="running",[n,p]=o.useState(!1),r=async()=>{p(!0);try{await S(`/api/goals/${a}/subtasks/${s.id}/retry`,{method:"POST"})}catch(m){alert(`Retry failed: ${m.message}`)}p(!1)},y=async()=>{p(!0);try{await S(`/api/goals/${a}/subtasks/${s.id}/complete`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({result:"Marked complete from Command Post"})})}catch(m){alert(`Mark-done failed: ${m.message}`)}p(!1)};return e.jsxs("div",{style:{padding:"10px 12px",borderRadius:8,background:"rgba(255,255,255,0.02)",borderLeft:`2px solid ${l}`,fontSize:12},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:s.error||s.result?6:0},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:l,boxShadow:`0 0 ${c?10:5}px ${l}`,animation:c?"subtask-pulse 1.4s ease-in-out infinite":"none",flexShrink:0}}),e.jsx("span",{style:{flex:1,color:"rgba(255,255,255,0.85)",lineHeight:1.4},children:s.title}),s.status==="failed"&&e.jsx("button",{onClick:r,disabled:n,title:"Reset + retry",style:{background:"transparent",border:0,padding:4,borderRadius:4,color:"#fbbf24",cursor:"pointer",opacity:n?.4:.8},children:e.jsx(B,{size:12})}),s.status==="pending"&&e.jsx("button",{onClick:y,disabled:n,title:"Mark done",style:{background:"transparent",border:0,padding:4,borderRadius:4,color:"var(--color-emerald)",cursor:"pointer",opacity:n?.4:.8},children:e.jsx(J,{size:12})}),e.jsx("span",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:"0.1em",color:l,fontWeight:600,flexShrink:0},children:s.status})]}),s.error&&e.jsx("div",{style:{fontSize:11,color:"rgba(239, 68, 68, 0.85)",padding:"6px 8px",borderRadius:6,background:"rgba(239, 68, 68, 0.06)",marginLeft:18},children:s.error}),s.result&&s.status==="done"&&e.jsxs("div",{style:{fontSize:11,color:"rgba(255,255,255,0.55)",lineHeight:1.4,marginLeft:18,marginTop:4},children:[s.result.slice(0,240),s.result.length>240?"…":""]}),e.jsx("style",{children:"@keyframes subtask-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }"})]})}function G({status:a}){const s=O(a);return e.jsx("span",{style:{display:"inline-block",padding:"2px 8px",borderRadius:999,background:`${s}15`,color:s,fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.1em"},children:a})}function O(a){switch(a){case"done":case"completed":case"approved":case"active":return"var(--color-emerald)";case"running":return"var(--color-cyan)";case"failed":case"rejected":return"var(--color-error)";case"skipped":return"var(--color-text-secondary)";case"pending":case"paused":return"#fbbf24";default:return"#9ca3af"}}function z({label:a,children:s}){return e.jsxs("div",{style:{marginBottom:20},children:[e.jsx("div",{style:{fontSize:10,textTransform:"uppercase",letterSpacing:"0.15em",color:"rgba(255,255,255,0.35)",fontWeight:600,marginBottom:8},children:a}),s]})}function de(){const[a,s]=o.useState([]),[l,c]=o.useState(!0),[n,p]=o.useState(null),[r,y]=o.useState(null),[m,u]=o.useState(!1),[j,x]=o.useState(null),[N,k]=o.useState(null),{toast:w}=q(),b=async()=>{try{const t=await S("/api/goals");if(t.ok){const i=await t.json();s(i.goals||[])}}catch{}},C=async t=>{k(t.id);const i=t.status==="paused"?"active":"paused";try{await S(`/api/goals/${t.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:i})}),await b()}catch(g){w("error",`Update failed: ${g.message}`)}k(null)},d=async t=>{k(t.id);try{await S(`/api/goals/${t.id}`,{method:"DELETE"}),await b()}catch(i){w("error",`Delete failed: ${i.message}`)}k(null),x(null)},f=async t=>{k(t.id);try{const i=(t.subtasks||[]).filter(g=>g.status==="failed");for(const g of i)await S(`/api/goals/${t.id}/subtasks/${g.id}/retry`,{method:"POST"});t.status!=="active"&&await S(`/api/goals/${t.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:"active"})}),await b()}catch(i){w("error",`Restart failed: ${i.message}`)}k(null)};o.useEffect(()=>{let t=!0;const i=async()=>{try{const v=await S("/api/goals");if(!v.ok)return;const T=await v.json();if(!t)return;s(T.goals||[]),c(!1)}catch{}};i();const g=setInterval(i,1e4);return()=>{t=!1,clearInterval(g)}},[]),o.useEffect(()=>{const t=localStorage.getItem("titan-token")||localStorage.getItem("titan_token")||"",i=`/api/watch/stream${t?`?token=${encodeURIComponent(t)}`:""}`,g=new EventSource(i);return g.onmessage=v=>{try{const T=JSON.parse(v.data);if(T.type!=="event")return;if(T.topic==="initiative:start"||T.topic==="initiative:round"){const I=T.raw||{};y({goalTitle:I.goalTitle||"",subtaskTitle:I.subtaskTitle||"",round:I.round,maxRounds:I.maxRounds})}(T.topic==="initiative:complete"||T.topic==="initiative:no_progress")&&y(null)}catch{}},g.onerror=()=>{},()=>g.close()},[]);const h=o.useMemo(()=>a.filter(t=>t.status==="active").sort((t,i)=>(t.priority||5)-(i.priority||5)),[a]),A=o.useMemo(()=>a.filter(t=>t.status==="paused"),[a]),P=o.useMemo(()=>a.filter(t=>t.status==="completed").sort((t,i)=>(i.completedAt||i.updatedAt||"").localeCompare(t.completedAt||t.updatedAt||"")).slice(0,5),[a]),R=o.useMemo(()=>{const t=[];for(const i of h){const g=new Set((i.subtasks||[]).filter(v=>v.status==="done"||v.status==="skipped").map(v=>v.id));for(const v of i.subtasks||[]){if(v.status!=="pending")continue;(v.dependsOn||[]).every(H=>g.has(H))&&t.push({goal:i,subtask:v})}}return t},[h]),W=o.useMemo(()=>{const t=[];for(const i of a)if(!(i.status!=="active"&&i.status!=="paused"))for(const g of i.subtasks||[])g.status==="failed"&&t.push({goal:i,subtask:g});return t.slice(0,5)},[a]);return l?e.jsx("div",{className:"flex items-center justify-center h-64 text-sm text-text-muted",children:"Loading work…"}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"text-[11px] text-text-muted",children:[a.filter(t=>t.status==="active").length," active · ",a.filter(t=>t.status==="paused").length," paused · ",a.filter(t=>t.status==="completed").length," completed"]}),e.jsxs("button",{onClick:()=>u(!0),className:"flex items-center gap-1.5 px-3 py-1.5 text-[12px] font-medium rounded-lg bg-indigo-600 text-white hover:bg-indigo-500 transition-colors",children:[e.jsx(U,{size:13})," New goal"]})]}),e.jsx(E,{label:"Now",count:r?1:0,children:e.jsx(D,{mode:"wait",children:r?e.jsxs($.div,{initial:{opacity:0,y:-4},animate:{opacity:1,y:0},exit:{opacity:0},transition:{duration:.25},className:"p-4 rounded-xl border border-cyan-500/20 bg-cyan-500/[0.04]",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("span",{className:"w-2.5 h-2.5 rounded-full bg-cyan-400 animate-pulse",style:{boxShadow:"0 0 12px #22d3ee"}}),e.jsx("span",{className:"text-[11px] text-cyan-300 uppercase tracking-wider font-semibold",children:"executing"}),r.round&&r.maxRounds&&e.jsxs("span",{className:"text-[11px] text-text-muted",children:["round ",r.round,"/",r.maxRounds]})]}),e.jsx("div",{className:"text-[15px] font-medium text-white/95 mb-1",children:r.subtaskTitle||"(unnamed subtask)"}),r.goalTitle&&e.jsxs("div",{className:"text-[11px] text-text-muted",children:["in goal: ",r.goalTitle]})]},`${r.goalTitle}-${r.subtaskTitle}`):e.jsxs($.div,{initial:{opacity:0},animate:{opacity:1},className:"p-6 rounded-xl border border-border text-center",children:[e.jsx("div",{className:"text-[13px] text-text-muted",children:"Nothing running right now."}),e.jsx("div",{className:"text-[11px] text-text-muted mt-1",children:R.length>0?`${R.length} task${R.length===1?"":"s"} queued — TITAN will start within 10 seconds`:h.length>0?`${h.length} goal${h.length===1?"":"s"} active — waiting for driver to begin`:"No work in queue. Approve a proposal from the Inbox to get started."})]},"idle")})}),R.length>0&&e.jsx(E,{label:"Up next",count:R.length,children:e.jsx("div",{className:"space-y-2",children:R.slice(0,3).map(({goal:t,subtask:i},g)=>e.jsxs("div",{onClick:()=>p(t),className:"flex items-center gap-3 p-3 rounded-lg bg-bg-secondary/30 border border-border/30 hover:bg-bg-secondary cursor-pointer transition-colors",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400/60"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[13px] text-white/85 truncate",children:i.title}),e.jsx("div",{className:"text-[11px] text-text-muted truncate",children:t.title})]}),g===0&&e.jsx("span",{className:"text-[10px] text-cyan-300/70 uppercase tracking-wider",children:"next"})]},`${t.id}-${i.id}`))})}),e.jsx(E,{label:"Active goals",count:h.length,children:h.length===0?e.jsx("div",{className:"p-6 rounded-xl border border-border text-center text-[12px] text-text-muted",children:"No active goals. TITAN is idle. (Soma may propose one shortly.)"}):e.jsx("div",{className:"space-y-2",children:h.map(t=>e.jsx(Z,{goal:t,busy:N===t.id,onClick:()=>p(t),onPauseToggle:()=>C(t),onDelete:()=>x(t),onRestart:()=>f(t)},t.id))})}),P.length>0&&e.jsx(E,{label:"Recently done",count:P.length,children:e.jsx("div",{className:"space-y-2",children:P.map(t=>e.jsxs("div",{onClick:()=>p(t),className:"flex items-center gap-3 p-3 rounded-lg bg-emerald-500/[0.03] border border-emerald-500/10 hover:bg-emerald-500/[0.06] cursor-pointer",children:[e.jsx("span",{className:"text-emerald-400",children:"✓"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[13px] text-white/85 truncate",children:t.title}),e.jsxs("div",{className:"text-[11px] text-text-muted",children:["completed ",ee(t.completedAt||t.updatedAt)]})]})]},t.id))})}),(A.length>0||W.length>0)&&e.jsx(E,{label:"Needs attention",count:A.length+W.length,children:e.jsxs("div",{className:"space-y-2",children:[A.map(t=>e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-amber-500/[0.03] border border-amber-500/15 hover:bg-amber-500/[0.06]",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400"}),e.jsxs("div",{className:"flex-1 min-w-0 cursor-pointer",onClick:()=>p(t),children:[e.jsx("div",{className:"text-[13px] text-white/85 truncate",children:t.title}),e.jsx("div",{className:"text-[11px] text-text-muted",children:"paused"})]}),e.jsx("button",{onClick:i=>{i.stopPropagation(),C(t)},disabled:N===t.id,title:"Resume",className:"p-1.5 rounded hover:bg-bg-tertiary text-emerald-400/70 hover:text-emerald-400 disabled:opacity-40",children:e.jsx(F,{size:12})}),e.jsx("button",{onClick:i=>{i.stopPropagation(),x(t)},disabled:N===t.id,title:"Delete",className:"p-1.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-red-400 disabled:opacity-40",children:e.jsx(M,{size:12})})]},t.id)),W.map(({goal:t,subtask:i})=>e.jsxs("div",{onClick:()=>p(t),className:"flex items-start gap-3 p-3 rounded-lg bg-red-500/[0.03] border border-red-500/15 hover:bg-red-500/[0.06] cursor-pointer",children:[e.jsx("span",{className:"text-red-400 mt-0.5",children:"✗"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[13px] text-white/85 truncate",children:i.title}),e.jsxs("div",{className:"text-[11px] text-text-muted truncate",children:["in ",t.title]}),i.error&&e.jsx("div",{className:"text-[11px] text-red-300/70 mt-1 truncate",children:i.error})]})]},`${t.id}-${i.id}`))]})}),e.jsx(V,{open:n!==null,approval:n?{id:n.id,title:n.title,status:n.status,payload:{goalId:n.id,title:n.title,description:n.description,rationale:n.description}}:null,onClose:()=>p(null)}),e.jsx(Q,{open:m,onClose:()=>u(!1),onCreated:async()=>{u(!1),await b()}}),e.jsx(D,{children:j&&e.jsx($.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.7)",backdropFilter:"blur(6px)",zIndex:200,display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>x(null),children:e.jsxs($.div,{initial:{scale:.96,y:8},animate:{scale:1,y:0},exit:{scale:.96,y:8},onClick:t=>t.stopPropagation(),style:{background:"rgba(15, 17, 26, 0.98)",border:"1px solid rgba(239, 68, 68, 0.25)",borderRadius:16,padding:24,maxWidth:440,width:"calc(100% - 32px)",color:"#f8f9fc"},children:[e.jsx("div",{className:"text-[16px] font-semibold mb-2",children:"Delete this goal?"}),e.jsx("div",{className:"text-[13px] text-white/55 mb-1",children:j.title}),e.jsxs("div",{className:"text-[11px] text-text-muted mb-5",children:["All ",(j.subtasks||[]).length," subtasks will be removed. Can't undo."]}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{onClick:()=>x(null),className:"px-4 py-2 rounded-lg text-[12px] text-text-secondary hover:bg-bg-tertiary",children:"Cancel"}),e.jsx("button",{onClick:()=>d(j),disabled:N===j.id,className:"px-4 py-2 rounded-lg text-[12px] font-medium bg-red-600 text-white hover:bg-red-500 disabled:opacity-50",children:"Delete goal"})]})]})})})]})}function Q({open:a,onClose:s,onCreated:l}){const[c,n]=o.useState(""),[p,r]=o.useState(""),[y,m]=o.useState([]),[u,j]=o.useState(""),[x,N]=o.useState(!1),[k,w]=o.useState(null);o.useEffect(()=>{a||(n(""),r(""),m([]),j(""),w(null))},[a]),o.useEffect(()=>{if(!a)return;const d=f=>{f.key==="Escape"&&s()};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[a,s]);const b=()=>{const d=u.trim();d&&(m(f=>[...f,d]),j(""))},C=async()=>{if(!c.trim()){w("Title is required");return}N(!0),w(null);try{const d={title:c.trim(),description:p.trim()||c.trim(),subtasks:y.map(h=>({title:h,description:h}))},f=await S("/api/goals",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(d)});if(!f.ok){const h=await f.text().catch(()=>"");throw new Error(h||`HTTP ${f.status}`)}l()}catch(d){w(d.message)}N(!1)};return e.jsx(D,{children:a&&e.jsx($.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.7)",backdropFilter:"blur(6px)",zIndex:200,display:"flex",alignItems:"center",justifyContent:"center",padding:16},onClick:s,children:e.jsxs($.div,{initial:{scale:.96,y:8},animate:{scale:1,y:0},exit:{scale:.96,y:8},onClick:d=>d.stopPropagation(),style:{background:"rgba(15, 17, 26, 0.98)",border:"1px solid rgba(99, 102, 241, 0.25)",borderRadius:16,padding:24,maxWidth:520,width:"100%",color:"#f8f9fc"},children:[e.jsxs("div",{className:"flex items-center justify-between mb-5",children:[e.jsx("h2",{className:"text-[16px] font-semibold",children:"New goal"}),e.jsx("button",{onClick:s,className:"text-white/55 hover:text-text p-1",children:e.jsx(L,{size:18})})]}),e.jsx("label",{className:"text-[10px] uppercase tracking-wider text-text-muted font-semibold block mb-1.5",children:"Title"}),e.jsx("input",{value:c,onChange:d=>n(d.target.value),placeholder:"Build the Polymarket monitor",autoFocus:!0,className:"w-full bg-bg-tertiary border border-border rounded-lg px-3 py-2 text-[14px] text-white/95 placeholder-white/25 focus:outline-none focus:border-indigo-500/50 mb-4"}),e.jsx("label",{className:"text-[10px] uppercase tracking-wider text-text-muted font-semibold block mb-1.5",children:"Description (optional)"}),e.jsx("textarea",{value:p,onChange:d=>r(d.target.value),placeholder:"What should TITAN accomplish? Why?",rows:3,className:"w-full bg-bg-tertiary border border-border rounded-lg px-3 py-2 text-[13px] text-white/85 placeholder-white/25 focus:outline-none focus:border-indigo-500/50 resize-none mb-4"}),e.jsx("label",{className:"text-[10px] uppercase tracking-wider text-text-muted font-semibold block mb-1.5",children:"Subtasks (optional)"}),e.jsx("div",{className:"space-y-1.5 mb-2",children:y.map((d,f)=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-lg bg-bg-tertiary/30 border border-border/50",children:[e.jsxs("span",{className:"text-[11px] text-text-muted tabular-nums",children:[f+1,"."]}),e.jsx("span",{className:"flex-1 text-[12px] text-text",children:d}),e.jsx("button",{onClick:()=>m(h=>h.filter((A,P)=>P!==f)),className:"text-text-muted hover:text-red-400","aria-label":"Remove",children:e.jsx(L,{size:12})})]},f))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:u,onChange:d=>j(d.target.value),onKeyDown:d=>{d.key==="Enter"&&(d.preventDefault(),b())},placeholder:"Add a subtask (press Enter)",className:"flex-1 bg-bg-tertiary border border-border rounded-lg px-3 py-1.5 text-[12px] text-white/85 placeholder-white/25 focus:outline-none focus:border-indigo-500/50"}),e.jsx("button",{onClick:b,disabled:!u.trim(),className:"px-3 rounded-lg text-[12px] bg-bg-tertiary text-text-secondary hover:bg-bg-tertiary disabled:opacity-30",children:"Add"})]}),y.length===0&&e.jsx("p",{className:"text-[10px] text-text-muted italic mt-2",children:"Leaving subtasks empty is fine — TITAN can plan them itself."}),k&&e.jsx("div",{className:"mt-4 p-2 rounded-lg bg-red-500/[0.08] border border-red-500/20 text-[12px] text-red-300",children:k}),e.jsxs("div",{className:"flex gap-2 justify-end mt-6",children:[e.jsx("button",{onClick:s,className:"px-4 py-2 rounded-lg text-[12px] text-text-secondary hover:bg-bg-tertiary",children:"Cancel"}),e.jsx("button",{onClick:C,disabled:x||!c.trim(),className:"px-4 py-2 rounded-lg text-[12px] font-medium bg-indigo-600 text-white hover:bg-indigo-500 disabled:opacity-50",children:x?"Creating…":"Create goal"})]})]})})})}function Z({goal:a,busy:s,onClick:l,onPauseToggle:c,onDelete:n,onRestart:p}){const r=a.subtasks||[],y=r.filter(x=>x.status==="done"||x.status==="skipped").length,m=r.filter(x=>x.status==="running").length,u=r.filter(x=>x.status==="failed").length,j=r.length?y/r.length*100:a.progress||0;return e.jsxs("div",{className:"group p-3 rounded-lg bg-bg-secondary/30 border border-border/50 hover:bg-bg-secondary transition-colors",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 mb-1.5",children:[e.jsx("div",{onClick:l,className:"flex-1 min-w-0 cursor-pointer",children:e.jsx("div",{className:"text-[13px] text-text truncate font-medium",children:a.title})}),e.jsxs("span",{className:"text-[10px] text-text-muted flex-shrink-0 tabular-nums",children:[y,"/",r.length]}),e.jsxs("div",{className:"flex items-center gap-0.5 flex-shrink-0",children:[u>0&&e.jsx("button",{onClick:x=>{x.stopPropagation(),p()},disabled:s,title:`Retry ${u} failed subtask${u===1?"":"s"}`,className:"p-1.5 rounded hover:bg-bg-tertiary text-amber-300/70 hover:text-amber-300 disabled:opacity-40",children:e.jsx(B,{size:12})}),e.jsx("button",{onClick:x=>{x.stopPropagation(),c()},disabled:s,title:a.status==="paused"?"Resume":"Pause",className:"p-1.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text disabled:opacity-40",children:a.status==="paused"?e.jsx(F,{size:12}):e.jsx(_,{size:12})}),e.jsx("button",{onClick:x=>{x.stopPropagation(),n()},disabled:s,title:"Delete",className:"p-1.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-red-400 disabled:opacity-40",children:e.jsx(M,{size:12})})]})]}),e.jsx("div",{className:"h-1 rounded-full bg-bg-tertiary overflow-hidden mb-2 cursor-pointer",onClick:l,children:e.jsx("div",{className:"h-full transition-all duration-500",style:{width:`${j}%`,background:u>0?"linear-gradient(to right, #34d399, #fbbf24)":"var(--color-emerald)"}})}),e.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-text-muted cursor-pointer",onClick:l,children:[m>0&&e.jsxs("span",{className:"text-cyan-300/80",children:["▶ ",m," running"]}),u>0&&e.jsxs("span",{className:"text-red-300/80",children:["✗ ",u," failed"]}),m===0&&u===0&&r.length>0&&e.jsxs("span",{children:[r.length-y," pending"]}),r.length===0&&e.jsx("span",{className:"italic text-text-muted",children:"no subtasks yet"})]})]})}function E({label:a,count:s,children:l}){return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("h3",{className:"text-[11px] uppercase tracking-wider text-text-muted font-semibold",children:a}),s!==void 0&&s>0&&e.jsx("span",{className:"text-[10px] text-text-muted tabular-nums",children:s})]}),l]})}function ee(a){if(!a)return"";const s=Date.parse(a);if(isNaN(s))return"";const l=Math.max(0,Math.floor((Date.now()-s)/1e3));if(l<60)return`${l}s ago`;const c=Math.floor(l/60);if(c<60)return`${c}m ago`;const n=Math.floor(c/60);return n<24?`${n}h ago`:`${Math.floor(n/24)}d ago`}export{de as default};
@@ -1,4 +1,4 @@
1
- import{c as O,r as d,j as e,b as _,Z as $,h as z,f as D,T as B}from"./index-CahJbWSR.js";import{P as Z}from"./PageHeader-BimceqQo.js";import"./Input-GTHp2Rkr.js";import{I as q}from"./InlineEditableField-CnvF-yFR.js";import{R as N,P as J,C as P,d as A}from"./TitanCanvas-C-s0A-lv.js";import{T as E}from"./target-DWcmM_9m.js";import{a as U,C as X}from"./VoiceOverlay-CmNCrLcd.js";import{P as R}from"./play-CcJ9BnCh.js";import{P as I}from"./pause-DCV52koX.js";import{T as F}from"./trash-2-CK7yQ55V.js";import{T as L,a as H}from"./toggle-right-YusFQ69L.js";/**
1
+ import{c as O,r as d,j as e,b as _,Z as $,h as B,f as D,T as z}from"./index-DzwowwSI.js";import{P as Z}from"./PageHeader-CnZtP8ek.js";import"./Input-Bu_b3qmY.js";import{I as q}from"./InlineEditableField-BMQjiE6-.js";import{R as N}from"./terminal-BtiqJ628.js";import{T as P}from"./target-BRW80Xer.js";import{P as J}from"./plus-Csu2v9GN.js";import{C as U}from"./chevron-down-D7OLjvuD.js";import{C as X}from"./chevron-right-aQEw2mUW.js";import{P as R}from"./play-DVY9c5Ck.js";import{P as I}from"./pause-CYhO_uQo.js";import{T as F}from"./trash-2-DgWrHVax.js";import{C as A}from"./clock-CTsgP_Sn.js";import{T as L,a as H}from"./toggle-right-CKtSrl28.js";import{B as E}from"./TitanCanvas-BCbWnLMd.js";import"./loader-circle-1YOBsoQp.js";import"./check-Bpm1IONe.js";import"./chevron-up-C5g6pEj8.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"./folder-DA43TRCm.js";import"./shield-check-DjBJXZUr.js";import"./external-link-BZ0y_Ahx.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 O,r as d,j as e,b as _,Z as $,h as z,f as D,T as B}from"./index-CahJ
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=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],Y=O("timer",V);function M(t){const o=t.split(" ");if(o.length!==5)return t;const[r,c,x,l,n]=o,g={0:"Sun",1:"Mon",2:"Tue",3:"Wed",4:"Thu",5:"Fri",6:"Sat",7:"Sun"};if(x==="*"&&l==="*"){const p=`${c.padStart(2,"0")}:${r.padStart(2,"0")}`;return n==="*"?`Daily at ${p}`:n==="1-5"?`Weekdays at ${p}`:n==="0,6"?`Weekends at ${p}`:`${n.split(",").map(m=>g[m]||m).join(", ")} at ${p}`}return r.startsWith("*/")?`Every ${r.slice(2)} min`:c.startsWith("*/")?`Every ${c.slice(2)} hours`:t}function S(t){const o=Date.now()-new Date(t).getTime(),r=Math.floor(o/6e4);if(r<1)return"just now";if(r<60)return`${r}m ago`;const c=Math.floor(r/60);return c<24?`${c}h ago`:`${Math.floor(c/24)}d ago`}const u=async(t,o)=>{const r=await _(t,{headers:{"Content-Type":"application/json"},...o});if(!r.ok)throw new Error(`API ${r.status}`);return r.json()};function T({icon:t,title:o,count:r,accent:c="var(--color-accent)"}){return e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(t,{className:"w-5 h-5",style:{color:c}}),e.jsx("h2",{className:"text-base font-semibold text-text",children:o}),r!==void 0&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-bg-tertiary text-text-secondary",children:r})]})}function W({status:t}){const o={active:{bg:"#34d39920",text:"var(--color-emerald)"},completed:{bg:"#6366f120",text:"var(--color-accent)"},paused:{bg:"#f59e0b20",text:"var(--color-warning)"},failed:{bg:"#ef444420",text:"var(--color-error)"},pending:{bg:"#52525b20",text:"var(--color-text-secondary)"},running:{bg:"#22d3ee20",text:"var(--color-cyan)"},done:{bg:"#34d39920",text:"var(--color-emerald)"},skipped:{bg:"#52525b20",text:"var(--color-border-light)"},ok:{bg:"#34d39920",text:"var(--color-emerald)"},notable:{bg:"#f59e0b20",text:"var(--color-warning)"},urgent:{bg:"#ef444420",text:"var(--color-error)"}},r=o[t]||o.pending;return e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full font-medium capitalize",style:{backgroundColor:r.bg,color:r.text},children:t})}function ee({status:t}){switch(t){case"done":return e.jsx(D,{className:"w-3.5 h-3.5 text-emerald"});case"failed":return e.jsx(z,{className:"w-3.5 h-3.5 text-error"});case"running":return e.jsx(N,{className:"w-3.5 h-3.5 animate-spin text-cyan"});case"skipped":return e.jsx(I,{className:"w-3.5 h-3.5 text-text-muted"});default:return e.jsx(Q,{className:"w-3.5 h-3.5 text-text-muted"})}}function te({goals:t,onRefresh:o}){const[r,c]=d.useState(new Set),[x,l]=d.useState(!1),[n,g]=d.useState(""),[p,f]=d.useState(""),m=a=>{c(y=>{const b=new Set(y);return b.has(a)?b.delete(a):b.add(a),b})},v=async()=>{n.trim()&&(await u("/api/goals",{method:"POST",body:JSON.stringify({title:n,description:p})}),g(""),f(""),l(!1),o())},h=async a=>{await u(`/api/goals/${a}`,{method:"DELETE"}),o()},s=async(a,y)=>{const b=y==="paused"?"active":"paused";try{await u(`/api/goals/${a}`,{method:"PATCH",body:JSON.stringify({status:b})}),o()}catch(w){alert(`Update failed: ${w.message}`)}},j=async(a,y)=>{try{await u(`/api/goals/${a}/subtasks/${y}/retry`,{method:"POST"}),o()}catch(b){alert(`Retry failed: ${b.message}`)}},k=async(a,y,b)=>{try{await u(`/api/goals/${a}/subtasks/${y}`,{method:"PATCH",body:JSON.stringify({title:b})}),o()}catch(w){alert(`Save failed: ${w.message}`)}},C=async(a,y)=>{await u(`/api/goals/${a}/subtasks/${y}/complete`,{method:"POST",body:JSON.stringify({result:"Completed via dashboard"})}),o()};return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx(T,{icon:E,title:"Active Goals",count:t.length,accent:"#34d399"}),e.jsxs("button",{onClick:()=>l(!x),className:"flex items-center gap-1 text-xs px-3 py-1.5 rounded-lg transition-colors bg-bg-tertiary text-text-secondary",onMouseEnter:a=>{a.currentTarget.style.backgroundColor="#34d39930",a.currentTarget.style.color="var(--color-emerald)"},onMouseLeave:a=>{a.currentTarget.style.backgroundColor="var(--color-bg-tertiary)",a.currentTarget.style.color="var(--color-text-secondary)"},children:[e.jsx(J,{className:"w-3.5 h-3.5"})," New Goal"]})]}),x&&e.jsxs("div",{className:"rounded-lg p-4 mb-4",style:{backgroundColor:"var(--color-bg-secondary)",border:"1px solid #27272a"},children:[e.jsx("input",{id:"workflow-goal-title",name:"workflow-goal-title",type:"text",placeholder:"Goal title...",value:n,onChange:a=>g(a.target.value),className:"w-full px-3 py-2 rounded-lg text-sm mb-2 outline-none",style:{backgroundColor:"var(--color-bg)",border:"1px solid #27272a",color:"var(--color-text)"}}),e.jsx("textarea",{id:"workflow-goal-description",name:"workflow-goal-description",placeholder:"Description (optional)...",value:p,onChange:a=>f(a.target.value),rows:2,className:"w-full px-3 py-2 rounded-lg text-sm mb-3 outline-none resize-none",style:{backgroundColor:"var(--color-bg)",border:"1px solid #27272a",color:"var(--color-text)"}}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:v,className:"text-xs px-4 py-1.5 rounded-lg font-medium transition-opacity hover:opacity-80",style:{backgroundColor:"var(--color-emerald)",color:"var(--color-bg)"},children:"Create"}),e.jsx("button",{onClick:()=>l(!1),className:"text-xs px-4 py-1.5 rounded-lg transition-colors hover:opacity-80 bg-bg-tertiary text-text-secondary",children:"Cancel"})]})]}),t.length===0?e.jsxs("div",{className:"rounded-lg p-6 text-center",style:{backgroundColor:"var(--color-bg-secondary)",border:"1px solid #27272a"},children:[e.jsx(E,{className:"w-8 h-8 mx-auto mb-2 text-text-muted"}),e.jsx("p",{className:"text-sm text-text-muted",children:"No goals yet. Create one to get started."})]}):e.jsx("div",{className:"space-y-2",children:t.map(a=>{const y=r.has(a.id),b=a.subtasks.filter(i=>i.status==="done"||i.status==="skipped").length,w=a.subtasks.length;return e.jsxs("div",{className:"rounded-lg overflow-hidden",style:{backgroundColor:"var(--color-bg-secondary)",border:"1px solid #27272a"},children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 cursor-pointer select-none",onClick:()=>m(a.id),children:[y?e.jsx(U,{className:"w-4 h-4 flex-shrink-0 text-text-muted"}):e.jsx(X,{className:"w-4 h-4 flex-shrink-0 text-text-muted"}),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-medium truncate text-text",children:a.title}),e.jsx(W,{status:a.status})]}),w>0&&e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("div",{className:"flex-1 h-1.5 rounded-full overflow-hidden bg-bg-tertiary",children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${a.progress}%`,backgroundColor:"var(--color-emerald)"}})}),e.jsxs("span",{className:"text-xs flex-shrink-0 text-text-secondary",children:[b,"/",w]})]})]}),a.status!=="completed"&&e.jsx("button",{onClick:i=>{i.stopPropagation(),s(a.id,a.status)},className:"p-1 rounded hover:opacity-80 flex-shrink-0",title:a.status==="paused"?"Resume goal":"Pause goal",children:a.status==="paused"?e.jsx(R,{className:"w-3.5 h-3.5 text-emerald"}):e.jsx(I,{className:"w-3.5 h-3.5",style:{color:"#fbbf24"}})}),e.jsx("button",{onClick:i=>{i.stopPropagation(),h(a.id)},className:"p-1 rounded hover:opacity-80 flex-shrink-0",title:"Delete goal",children:e.jsx(F,{className:"w-3.5 h-3.5 text-text-muted"})})]}),y&&a.subtasks.length>0&&e.jsx("div",{className:"px-4 pb-3 border-t",style:{borderColor:"var(--color-bg-tertiary)"},children:e.jsx("div",{className:"space-y-1.5 mt-2",children:a.subtasks.map(i=>e.jsxs("div",{className:"flex items-center gap-2 py-1 px-2 rounded bg-bg",children:[e.jsx(ee,{status:i.status}),e.jsx("span",{className:"text-xs flex-1 min-w-0",style:{color:i.status==="done"?"var(--color-border-light)":"var(--color-text-secondary)"},children:e.jsx(q,{value:i.title,onSave:G=>k(a.id,i.id,G),placeholder:"Subtask title"})}),i.status==="failed"&&i.error&&e.jsx("span",{className:"text-xs truncate max-w-40 text-error",title:i.error,children:i.error}),i.status==="failed"&&e.jsxs("button",{onClick:()=>j(a.id,i.id),className:"text-xs px-2 py-0.5 rounded transition-colors hover:opacity-80",style:{backgroundColor:"var(--color-bg-tertiary)",color:"#fbbf24"},title:"Reset to pending, clear error, retry",children:[e.jsx(N,{className:"w-3 h-3 inline"})," Retry"]}),i.status==="pending"&&e.jsx("button",{onClick:()=>C(a.id,i.id),className:"text-xs px-2 py-0.5 rounded transition-colors hover:opacity-80",style:{backgroundColor:"var(--color-bg-tertiary)",color:"var(--color-emerald)"},children:"Done"})]},i.id))})})]},a.id)})})]})}function se({jobs:t,onRefresh:o}){const[r,c]=d.useState(!1),[x,l]=d.useState(""),[n,g]=d.useState(""),[p,f]=d.useState(""),m=async()=>{!x.trim()||!n.trim()||!p.trim()||(await u("/api/cron",{method:"POST",body:JSON.stringify({name:x,schedule:n,command:p})}),l(""),g(""),f(""),c(!1),o())},v=async(s,j)=>{await u(`/api/cron/${s}/toggle`,{method:"POST",body:JSON.stringify({enabled:!j})}),o()},h=async s=>{await u(`/api/cron/${s}`,{method:"DELETE"}),o()};return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx(T,{icon:P,title:"Scheduled Tasks",count:t.length,accent:"#22d3ee"}),e.jsxs("button",{onClick:()=>c(!r),className:"flex items-center gap-1 text-xs px-3 py-1.5 rounded-lg transition-colors bg-bg-tertiary text-text-secondary",onMouseEnter:s=>{s.currentTarget.style.backgroundColor="#22d3ee30",s.currentTarget.style.color="var(--color-cyan)"},onMouseLeave:s=>{s.currentTarget.style.backgroundColor="var(--color-bg-tertiary)",s.currentTarget.style.color="var(--color-text-secondary)"},children:[e.jsx(J,{className:"w-3.5 h-3.5"})," New Cron"]})]}),r&&e.jsxs("div",{className:"rounded-lg p-4 mb-4",style:{backgroundColor:"var(--color-bg-secondary)",border:"1px solid #27272a"},children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2 mb-2",children:[e.jsx("input",{id:"workflow-cron-name",name:"workflow-cron-name",type:"text",placeholder:"Job name...",value:x,onChange:s=>l(s.target.value),className:"px-3 py-2 rounded-lg text-sm outline-none",style:{backgroundColor:"var(--color-bg)",border:"1px solid #27272a",color:"var(--color-text)"}}),e.jsx("input",{id:"workflow-cron-schedule",name:"workflow-cron-schedule",type:"text",placeholder:"Schedule (e.g. */5 * * * *)",value:n,onChange:s=>g(s.target.value),className:"px-3 py-2 rounded-lg text-sm outline-none",style:{backgroundColor:"var(--color-bg)",border:"1px solid #27272a",color:"var(--color-text)"}})]}),e.jsx("input",{id:"workflow-cron-command",name:"workflow-cron-command",type:"text",placeholder:"Command to execute...",value:p,onChange:s=>f(s.target.value),className:"w-full px-3 py-2 rounded-lg text-sm mb-3 outline-none",style:{backgroundColor:"var(--color-bg)",border:"1px solid #27272a",color:"var(--color-text)"}}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:m,className:"text-xs px-4 py-1.5 rounded-lg font-medium transition-opacity hover:opacity-80",style:{backgroundColor:"var(--color-cyan)",color:"var(--color-bg)"},children:"Create"}),e.jsx("button",{onClick:()=>c(!1),className:"text-xs px-4 py-1.5 rounded-lg transition-colors hover:opacity-80 bg-bg-tertiary text-text-secondary",children:"Cancel"})]})]}),t.length===0?e.jsxs("div",{className:"rounded-lg p-6 text-center",style:{backgroundColor:"var(--color-bg-secondary)",border:"1px solid #27272a"},children:[e.jsx(P,{className:"w-8 h-8 mx-auto mb-2 text-text-muted"}),e.jsx("p",{className:"text-sm text-text-muted",children:"No scheduled tasks. Create a cron job to automate tasks."})]}):e.jsx("div",{className:"space-y-2",children:t.map(s=>e.jsxs("div",{className:"flex items-center gap-3 rounded-lg px-4 py-3",style:{backgroundColor:"var(--color-bg-secondary)",border:"1px solid #27272a"},children:[e.jsx("button",{onClick:()=>v(s.id,s.enabled),title:s.enabled?"Disable":"Enable",children:s.enabled?e.jsx(L,{className:"w-5 h-5 text-emerald"}):e.jsx(H,{className:"w-5 h-5 text-text-muted"})}),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-medium truncate",style:{color:s.enabled?"var(--color-text)":"var(--color-border-light)"},children:s.name}),e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full",style:{backgroundColor:"var(--color-bg-tertiary)",color:"var(--color-cyan)"},children:M(s.schedule)})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-0.5",children:[e.jsx("span",{className:"text-xs font-mono truncate text-text-muted",children:s.command}),s.last_run&&e.jsxs("span",{className:"text-xs flex-shrink-0 text-text-muted",children:["Last: ",S(s.last_run)]})]})]}),e.jsx("button",{onClick:()=>h(s.id),className:"p-1 rounded hover:opacity-80 flex-shrink-0",title:"Delete",children:e.jsx(F,{className:"w-3.5 h-3.5 text-text-muted"})})]},s.id))})]})}function ae({recipes:t,onRefresh:o}){const[r,c]=d.useState(null),x=async l=>{c(l);try{await u(`/api/recipes/${l}/run`,{method:"POST",body:JSON.stringify({params:{}})}),o()}finally{c(null)}};return e.jsxs("div",{children:[e.jsx(T,{icon:A,title:"Recipes",count:t.length,accent:"#6366f1"}),t.length===0?e.jsxs("div",{className:"rounded-lg p-6 text-center",style:{backgroundColor:"var(--color-bg-secondary)",border:"1px solid #27272a"},children:[e.jsx(A,{className:"w-8 h-8 mx-auto mb-2 text-text-muted"}),e.jsx("p",{className:"text-sm text-text-muted",children:"No recipes available."})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-3",children:t.map(l=>{var n;return e.jsxs("div",{className:"rounded-lg p-4 flex flex-col",style:{backgroundColor:"var(--color-bg-secondary)",border:"1px solid #27272a"},children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"text-sm font-medium truncate text-text",children:l.name}),l.slashCommand&&e.jsxs("span",{className:"text-xs font-mono text-accent",children:["/",l.slashCommand]})]}),e.jsxs("button",{onClick:()=>x(l.id),disabled:r===l.id,className:"flex items-center gap-1 text-xs px-2.5 py-1 rounded-lg transition-opacity hover:opacity-80 flex-shrink-0",style:{backgroundColor:"#6366f130",color:"var(--color-accent)"},children:[r===l.id?e.jsx(N,{className:"w-3 h-3 animate-spin"}):e.jsx(R,{className:"w-3 h-3"}),"Run"]})]}),e.jsx("p",{className:"text-xs flex-1 line-clamp-2 mb-2 text-text-secondary",children:l.description}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{className:"text-xs text-text-muted",children:[l.steps.length," step",l.steps.length!==1?"s":""]}),(n=l.tags)==null?void 0:n.map(g=>e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-bg-tertiary text-text-secondary",children:g},g)),l.lastRunAt&&e.jsxs("span",{className:"text-xs ml-auto text-text-muted",children:["Ran ",S(l.lastRunAt)]})]})]},l.id)})})]})}function re({status:t,history:o,onRefresh:r}){const[c,x]=d.useState(!1),[l,n]=d.useState(!1),g=async()=>{x(!0);try{await u("/api/autopilot/toggle",{method:"POST",body:JSON.stringify({enabled:!(t!=null&&t.enabled)})}),r()}finally{x(!1)}},p=async()=>{n(!0);try{await u("/api/autopilot/run",{method:"POST"}),r()}finally{n(!1)}},f=m=>{switch(m){case"urgent":return e.jsx(B,{className:"w-3.5 h-3.5 text-error"});case"notable":return e.jsx($,{className:"w-3.5 h-3.5 text-warning"});default:return e.jsx(D,{className:"w-3.5 h-3.5 text-emerald"})}};return e.jsxs("div",{children:[e.jsx(T,{icon:$,title:"Autopilot",accent:"#f59e0b"}),e.jsxs("div",{className:"rounded-lg overflow-hidden",style:{backgroundColor:"var(--color-bg-secondary)",border:"1px solid #27272a"},children:[e.jsxs("div",{className:"flex items-center gap-4 px-4 py-3",children:[e.jsx("button",{onClick:g,disabled:c,title:t!=null&&t.enabled?"Disable autopilot":"Enable autopilot",children:t!=null&&t.enabled?e.jsx(L,{className:"w-6 h-6 text-emerald"}):e.jsx(H,{className:"w-6 h-6 text-text-muted"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-text",children:t!=null&&t.enabled?"Active":"Disabled"}),(t==null?void 0:t.isRunning)&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-cyan",children:[e.jsx(N,{className:"w-3 h-3 animate-spin"})," Running..."]})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-0.5",children:[e.jsxs("span",{className:"text-xs text-text-muted",children:[e.jsx(Y,{className:"w-3 h-3 inline mr-1"}),t!=null&&t.schedule?M(t.schedule):"No schedule"]}),e.jsxs("span",{className:"text-xs text-text-muted",children:[(t==null?void 0:t.totalRuns)??0," total runs"]}),(t==null?void 0:t.lastRun)&&e.jsxs("span",{className:"text-xs text-text-muted",children:["Last: ",S(t.lastRun.timestamp)]})]})]}),e.jsxs("button",{onClick:p,disabled:l||(t==null?void 0:t.isRunning),className:"flex items-center gap-1 text-xs px-3 py-1.5 rounded-lg transition-opacity hover:opacity-80",style:{backgroundColor:"#f59e0b30",color:"var(--color-warning)"},children:[l?e.jsx(N,{className:"w-3 h-3 animate-spin"}):e.jsx(R,{className:"w-3 h-3"}),"Run Now"]})]}),o.length>0&&e.jsxs("div",{className:"border-t",style:{borderColor:"var(--color-bg-tertiary)"},children:[e.jsx("div",{className:"px-4 py-2",children:e.jsx("span",{className:"text-xs font-medium text-text-muted",children:"Recent Runs"})}),e.jsx("div",{className:"divide-y",style:{borderColor:"var(--color-bg-tertiary)"},children:o.slice(-5).reverse().map((m,v)=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2",children:[f(m.classification),e.jsx("span",{className:"text-xs flex-1 truncate text-text-secondary",children:m.skipped?`Skipped: ${m.summary}`:m.summary.slice(0,120)}),e.jsx(W,{status:m.classification}),e.jsx("span",{className:"text-xs flex-shrink-0 text-text-muted",children:S(m.timestamp)})]},v))})]})]})]})}function he(){const[t,o]=d.useState([]),[r,c]=d.useState([]),[x,l]=d.useState([]),[n,g]=d.useState(null),[p,f]=d.useState([]),[m,v]=d.useState(!0),h=d.useCallback(async()=>{try{const[s,j,k,C,a]=await Promise.allSettled([u("/api/goals"),u("/api/cron"),u("/api/recipes"),u("/api/autopilot/status"),u("/api/autopilot/history?limit=5")]);s.status==="fulfilled"&&o(s.value.goals||[]),j.status==="fulfilled"&&c(j.value.jobs||[]),k.status==="fulfilled"&&l(k.value.recipes||[]),C.status==="fulfilled"&&g(C.value),a.status==="fulfilled"&&f(Array.isArray(a.value)?a.value:[])}finally{v(!1)}},[]);return d.useEffect(()=>{h();const s=setInterval(h,15e3);return()=>clearInterval(s)},[h]),m?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx(N,{className:"w-6 h-6 animate-spin text-text-muted"})}):e.jsxs("div",{className:"space-y-8",children:[e.jsx(Z,{title:"Workflows",breadcrumbs:[{label:"Admin",href:"/overview"},{label:"Agent"},{label:"Workflows"}],actions:e.jsx("button",{onClick:()=>{v(!0),h()},className:"p-2 rounded-lg transition-colors hover:opacity-80 bg-bg-tertiary",title:"Refresh",children:e.jsx(N,{className:"w-4 h-4 text-text-secondary"})})}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[{label:"Goals",value:t.filter(s=>s.status==="active").length,total:t.length,color:"var(--color-emerald)"},{label:"Cron Jobs",value:r.filter(s=>s.enabled).length,total:r.length,color:"var(--color-cyan)"},{label:"Recipes",value:x.length,color:"var(--color-accent)"},{label:"Autopilot Runs",value:(n==null?void 0:n.totalRuns)??0,color:"var(--color-warning)"}].map(s=>e.jsxs("div",{className:"rounded-lg px-4 py-3",style:{backgroundColor:"var(--color-bg-secondary)",border:"1px solid #27272a"},children:[e.jsx("p",{className:"text-xs mb-1 text-text-muted",children:s.label}),e.jsxs("p",{className:"text-lg font-bold",style:{color:s.color},children:[s.value,s.total!==void 0&&s.total!==s.value&&e.jsxs("span",{className:"text-xs font-normal ml-1 text-text-muted",children:["/ ",s.total]})]})]},s.label))}),e.jsx(te,{goals:t,onRefresh:h}),e.jsx(se,{jobs:r,onRefresh:h}),e.jsx(ae,{recipes:x,onRefresh:h}),e.jsx(re,{status:n,history:p,onRefresh:h})]})}export{he as default};
11
+ */const V=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],Y=O("timer",V);function M(t){const l=t.split(" ");if(l.length!==5)return t;const[r,c,x,o,n]=l,g={0:"Sun",1:"Mon",2:"Tue",3:"Wed",4:"Thu",5:"Fri",6:"Sat",7:"Sun"};if(x==="*"&&o==="*"){const p=`${c.padStart(2,"0")}:${r.padStart(2,"0")}`;return n==="*"?`Daily at ${p}`:n==="1-5"?`Weekdays at ${p}`:n==="0,6"?`Weekends at ${p}`:`${n.split(",").map(m=>g[m]||m).join(", ")} at ${p}`}return r.startsWith("*/")?`Every ${r.slice(2)} min`:c.startsWith("*/")?`Every ${c.slice(2)} hours`:t}function S(t){const l=Date.now()-new Date(t).getTime(),r=Math.floor(l/6e4);if(r<1)return"just now";if(r<60)return`${r}m ago`;const c=Math.floor(r/60);return c<24?`${c}h ago`:`${Math.floor(c/24)}d ago`}const u=async(t,l)=>{const r=await _(t,{headers:{"Content-Type":"application/json"},...l});if(!r.ok)throw new Error(`API ${r.status}`);return r.json()};function T({icon:t,title:l,count:r,accent:c="var(--color-accent)"}){return e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(t,{className:"w-5 h-5",style:{color:c}}),e.jsx("h2",{className:"text-base font-semibold text-text",children:l}),r!==void 0&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full bg-bg-tertiary text-text-secondary",children:r})]})}function W({status:t}){const l={active:{bg:"#34d39920",text:"var(--color-emerald)"},completed:{bg:"#6366f120",text:"var(--color-accent)"},paused:{bg:"#f59e0b20",text:"var(--color-warning)"},failed:{bg:"#ef444420",text:"var(--color-error)"},pending:{bg:"#52525b20",text:"var(--color-text-secondary)"},running:{bg:"#22d3ee20",text:"var(--color-cyan)"},done:{bg:"#34d39920",text:"var(--color-emerald)"},skipped:{bg:"#52525b20",text:"var(--color-border-light)"},ok:{bg:"#34d39920",text:"var(--color-emerald)"},notable:{bg:"#f59e0b20",text:"var(--color-warning)"},urgent:{bg:"#ef444420",text:"var(--color-error)"}},r=l[t]||l.pending;return e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full font-medium capitalize",style:{backgroundColor:r.bg,color:r.text},children:t})}function ee({status:t}){switch(t){case"done":return e.jsx(D,{className:"w-3.5 h-3.5 text-emerald"});case"failed":return e.jsx(B,{className:"w-3.5 h-3.5 text-error"});case"running":return e.jsx(N,{className:"w-3.5 h-3.5 animate-spin text-cyan"});case"skipped":return e.jsx(I,{className:"w-3.5 h-3.5 text-text-muted"});default:return e.jsx(Q,{className:"w-3.5 h-3.5 text-text-muted"})}}function te({goals:t,onRefresh:l}){const[r,c]=d.useState(new Set),[x,o]=d.useState(!1),[n,g]=d.useState(""),[p,f]=d.useState(""),m=a=>{c(y=>{const b=new Set(y);return b.has(a)?b.delete(a):b.add(a),b})},v=async()=>{n.trim()&&(await u("/api/goals",{method:"POST",body:JSON.stringify({title:n,description:p})}),g(""),f(""),o(!1),l())},h=async a=>{await u(`/api/goals/${a}`,{method:"DELETE"}),l()},s=async(a,y)=>{const b=y==="paused"?"active":"paused";try{await u(`/api/goals/${a}`,{method:"PATCH",body:JSON.stringify({status:b})}),l()}catch(w){alert(`Update failed: ${w.message}`)}},j=async(a,y)=>{try{await u(`/api/goals/${a}/subtasks/${y}/retry`,{method:"POST"}),l()}catch(b){alert(`Retry failed: ${b.message}`)}},k=async(a,y,b)=>{try{await u(`/api/goals/${a}/subtasks/${y}`,{method:"PATCH",body:JSON.stringify({title:b})}),l()}catch(w){alert(`Save failed: ${w.message}`)}},C=async(a,y)=>{await u(`/api/goals/${a}/subtasks/${y}/complete`,{method:"POST",body:JSON.stringify({result:"Completed via dashboard"})}),l()};return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx(T,{icon:P,title:"Active Goals",count:t.length,accent:"#34d399"}),e.jsxs("button",{onClick:()=>o(!x),className:"flex items-center gap-1 text-xs px-3 py-1.5 rounded-lg transition-colors bg-bg-tertiary text-text-secondary",onMouseEnter:a=>{a.currentTarget.style.backgroundColor="#34d39930",a.currentTarget.style.color="var(--color-emerald)"},onMouseLeave:a=>{a.currentTarget.style.backgroundColor="var(--color-bg-tertiary)",a.currentTarget.style.color="var(--color-text-secondary)"},children:[e.jsx(J,{className:"w-3.5 h-3.5"})," New Goal"]})]}),x&&e.jsxs("div",{className:"rounded-lg p-4 mb-4",style:{backgroundColor:"var(--color-bg-secondary)",border:"1px solid #27272a"},children:[e.jsx("input",{id:"workflow-goal-title",name:"workflow-goal-title",type:"text",placeholder:"Goal title...",value:n,onChange:a=>g(a.target.value),className:"w-full px-3 py-2 rounded-lg text-sm mb-2 outline-none",style:{backgroundColor:"var(--color-bg)",border:"1px solid #27272a",color:"var(--color-text)"}}),e.jsx("textarea",{id:"workflow-goal-description",name:"workflow-goal-description",placeholder:"Description (optional)...",value:p,onChange:a=>f(a.target.value),rows:2,className:"w-full px-3 py-2 rounded-lg text-sm mb-3 outline-none resize-none",style:{backgroundColor:"var(--color-bg)",border:"1px solid #27272a",color:"var(--color-text)"}}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:v,className:"text-xs px-4 py-1.5 rounded-lg font-medium transition-opacity hover:opacity-80",style:{backgroundColor:"var(--color-emerald)",color:"var(--color-bg)"},children:"Create"}),e.jsx("button",{onClick:()=>o(!1),className:"text-xs px-4 py-1.5 rounded-lg transition-colors hover:opacity-80 bg-bg-tertiary text-text-secondary",children:"Cancel"})]})]}),t.length===0?e.jsxs("div",{className:"rounded-lg p-6 text-center",style:{backgroundColor:"var(--color-bg-secondary)",border:"1px solid #27272a"},children:[e.jsx(P,{className:"w-8 h-8 mx-auto mb-2 text-text-muted"}),e.jsx("p",{className:"text-sm text-text-muted",children:"No goals yet. Create one to get started."})]}):e.jsx("div",{className:"space-y-2",children:t.map(a=>{const y=r.has(a.id),b=a.subtasks.filter(i=>i.status==="done"||i.status==="skipped").length,w=a.subtasks.length;return e.jsxs("div",{className:"rounded-lg overflow-hidden",style:{backgroundColor:"var(--color-bg-secondary)",border:"1px solid #27272a"},children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 cursor-pointer select-none",onClick:()=>m(a.id),children:[y?e.jsx(U,{className:"w-4 h-4 flex-shrink-0 text-text-muted"}):e.jsx(X,{className:"w-4 h-4 flex-shrink-0 text-text-muted"}),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-medium truncate text-text",children:a.title}),e.jsx(W,{status:a.status})]}),w>0&&e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[e.jsx("div",{className:"flex-1 h-1.5 rounded-full overflow-hidden bg-bg-tertiary",children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${a.progress}%`,backgroundColor:"var(--color-emerald)"}})}),e.jsxs("span",{className:"text-xs flex-shrink-0 text-text-secondary",children:[b,"/",w]})]})]}),a.status!=="completed"&&e.jsx("button",{onClick:i=>{i.stopPropagation(),s(a.id,a.status)},className:"p-1 rounded hover:opacity-80 flex-shrink-0",title:a.status==="paused"?"Resume goal":"Pause goal",children:a.status==="paused"?e.jsx(R,{className:"w-3.5 h-3.5 text-emerald"}):e.jsx(I,{className:"w-3.5 h-3.5",style:{color:"#fbbf24"}})}),e.jsx("button",{onClick:i=>{i.stopPropagation(),h(a.id)},className:"p-1 rounded hover:opacity-80 flex-shrink-0",title:"Delete goal",children:e.jsx(F,{className:"w-3.5 h-3.5 text-text-muted"})})]}),y&&a.subtasks.length>0&&e.jsx("div",{className:"px-4 pb-3 border-t",style:{borderColor:"var(--color-bg-tertiary)"},children:e.jsx("div",{className:"space-y-1.5 mt-2",children:a.subtasks.map(i=>e.jsxs("div",{className:"flex items-center gap-2 py-1 px-2 rounded bg-bg",children:[e.jsx(ee,{status:i.status}),e.jsx("span",{className:"text-xs flex-1 min-w-0",style:{color:i.status==="done"?"var(--color-border-light)":"var(--color-text-secondary)"},children:e.jsx(q,{value:i.title,onSave:G=>k(a.id,i.id,G),placeholder:"Subtask title"})}),i.status==="failed"&&i.error&&e.jsx("span",{className:"text-xs truncate max-w-40 text-error",title:i.error,children:i.error}),i.status==="failed"&&e.jsxs("button",{onClick:()=>j(a.id,i.id),className:"text-xs px-2 py-0.5 rounded transition-colors hover:opacity-80",style:{backgroundColor:"var(--color-bg-tertiary)",color:"#fbbf24"},title:"Reset to pending, clear error, retry",children:[e.jsx(N,{className:"w-3 h-3 inline"})," Retry"]}),i.status==="pending"&&e.jsx("button",{onClick:()=>C(a.id,i.id),className:"text-xs px-2 py-0.5 rounded transition-colors hover:opacity-80",style:{backgroundColor:"var(--color-bg-tertiary)",color:"var(--color-emerald)"},children:"Done"})]},i.id))})})]},a.id)})})]})}function se({jobs:t,onRefresh:l}){const[r,c]=d.useState(!1),[x,o]=d.useState(""),[n,g]=d.useState(""),[p,f]=d.useState(""),m=async()=>{!x.trim()||!n.trim()||!p.trim()||(await u("/api/cron",{method:"POST",body:JSON.stringify({name:x,schedule:n,command:p})}),o(""),g(""),f(""),c(!1),l())},v=async(s,j)=>{await u(`/api/cron/${s}/toggle`,{method:"POST",body:JSON.stringify({enabled:!j})}),l()},h=async s=>{await u(`/api/cron/${s}`,{method:"DELETE"}),l()};return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx(T,{icon:A,title:"Scheduled Tasks",count:t.length,accent:"#22d3ee"}),e.jsxs("button",{onClick:()=>c(!r),className:"flex items-center gap-1 text-xs px-3 py-1.5 rounded-lg transition-colors bg-bg-tertiary text-text-secondary",onMouseEnter:s=>{s.currentTarget.style.backgroundColor="#22d3ee30",s.currentTarget.style.color="var(--color-cyan)"},onMouseLeave:s=>{s.currentTarget.style.backgroundColor="var(--color-bg-tertiary)",s.currentTarget.style.color="var(--color-text-secondary)"},children:[e.jsx(J,{className:"w-3.5 h-3.5"})," New Cron"]})]}),r&&e.jsxs("div",{className:"rounded-lg p-4 mb-4",style:{backgroundColor:"var(--color-bg-secondary)",border:"1px solid #27272a"},children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-2 mb-2",children:[e.jsx("input",{id:"workflow-cron-name",name:"workflow-cron-name",type:"text",placeholder:"Job name...",value:x,onChange:s=>o(s.target.value),className:"px-3 py-2 rounded-lg text-sm outline-none",style:{backgroundColor:"var(--color-bg)",border:"1px solid #27272a",color:"var(--color-text)"}}),e.jsx("input",{id:"workflow-cron-schedule",name:"workflow-cron-schedule",type:"text",placeholder:"Schedule (e.g. */5 * * * *)",value:n,onChange:s=>g(s.target.value),className:"px-3 py-2 rounded-lg text-sm outline-none",style:{backgroundColor:"var(--color-bg)",border:"1px solid #27272a",color:"var(--color-text)"}})]}),e.jsx("input",{id:"workflow-cron-command",name:"workflow-cron-command",type:"text",placeholder:"Command to execute...",value:p,onChange:s=>f(s.target.value),className:"w-full px-3 py-2 rounded-lg text-sm mb-3 outline-none",style:{backgroundColor:"var(--color-bg)",border:"1px solid #27272a",color:"var(--color-text)"}}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:m,className:"text-xs px-4 py-1.5 rounded-lg font-medium transition-opacity hover:opacity-80",style:{backgroundColor:"var(--color-cyan)",color:"var(--color-bg)"},children:"Create"}),e.jsx("button",{onClick:()=>c(!1),className:"text-xs px-4 py-1.5 rounded-lg transition-colors hover:opacity-80 bg-bg-tertiary text-text-secondary",children:"Cancel"})]})]}),t.length===0?e.jsxs("div",{className:"rounded-lg p-6 text-center",style:{backgroundColor:"var(--color-bg-secondary)",border:"1px solid #27272a"},children:[e.jsx(A,{className:"w-8 h-8 mx-auto mb-2 text-text-muted"}),e.jsx("p",{className:"text-sm text-text-muted",children:"No scheduled tasks. Create a cron job to automate tasks."})]}):e.jsx("div",{className:"space-y-2",children:t.map(s=>e.jsxs("div",{className:"flex items-center gap-3 rounded-lg px-4 py-3",style:{backgroundColor:"var(--color-bg-secondary)",border:"1px solid #27272a"},children:[e.jsx("button",{onClick:()=>v(s.id,s.enabled),title:s.enabled?"Disable":"Enable",children:s.enabled?e.jsx(L,{className:"w-5 h-5 text-emerald"}):e.jsx(H,{className:"w-5 h-5 text-text-muted"})}),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-medium truncate",style:{color:s.enabled?"var(--color-text)":"var(--color-border-light)"},children:s.name}),e.jsx("span",{className:"text-xs px-2 py-0.5 rounded-full",style:{backgroundColor:"var(--color-bg-tertiary)",color:"var(--color-cyan)"},children:M(s.schedule)})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-0.5",children:[e.jsx("span",{className:"text-xs font-mono truncate text-text-muted",children:s.command}),s.last_run&&e.jsxs("span",{className:"text-xs flex-shrink-0 text-text-muted",children:["Last: ",S(s.last_run)]})]})]}),e.jsx("button",{onClick:()=>h(s.id),className:"p-1 rounded hover:opacity-80 flex-shrink-0",title:"Delete",children:e.jsx(F,{className:"w-3.5 h-3.5 text-text-muted"})})]},s.id))})]})}function ae({recipes:t,onRefresh:l}){const[r,c]=d.useState(null),x=async o=>{c(o);try{await u(`/api/recipes/${o}/run`,{method:"POST",body:JSON.stringify({params:{}})}),l()}finally{c(null)}};return e.jsxs("div",{children:[e.jsx(T,{icon:E,title:"Recipes",count:t.length,accent:"#6366f1"}),t.length===0?e.jsxs("div",{className:"rounded-lg p-6 text-center",style:{backgroundColor:"var(--color-bg-secondary)",border:"1px solid #27272a"},children:[e.jsx(E,{className:"w-8 h-8 mx-auto mb-2 text-text-muted"}),e.jsx("p",{className:"text-sm text-text-muted",children:"No recipes available."})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-3",children:t.map(o=>{var n;return e.jsxs("div",{className:"rounded-lg p-4 flex flex-col",style:{backgroundColor:"var(--color-bg-secondary)",border:"1px solid #27272a"},children:[e.jsxs("div",{className:"flex items-start justify-between gap-2 mb-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"text-sm font-medium truncate text-text",children:o.name}),o.slashCommand&&e.jsxs("span",{className:"text-xs font-mono text-accent",children:["/",o.slashCommand]})]}),e.jsxs("button",{onClick:()=>x(o.id),disabled:r===o.id,className:"flex items-center gap-1 text-xs px-2.5 py-1 rounded-lg transition-opacity hover:opacity-80 flex-shrink-0",style:{backgroundColor:"#6366f130",color:"var(--color-accent)"},children:[r===o.id?e.jsx(N,{className:"w-3 h-3 animate-spin"}):e.jsx(R,{className:"w-3 h-3"}),"Run"]})]}),e.jsx("p",{className:"text-xs flex-1 line-clamp-2 mb-2 text-text-secondary",children:o.description}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("span",{className:"text-xs text-text-muted",children:[o.steps.length," step",o.steps.length!==1?"s":""]}),(n=o.tags)==null?void 0:n.map(g=>e.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-bg-tertiary text-text-secondary",children:g},g)),o.lastRunAt&&e.jsxs("span",{className:"text-xs ml-auto text-text-muted",children:["Ran ",S(o.lastRunAt)]})]})]},o.id)})})]})}function re({status:t,history:l,onRefresh:r}){const[c,x]=d.useState(!1),[o,n]=d.useState(!1),g=async()=>{x(!0);try{await u("/api/autopilot/toggle",{method:"POST",body:JSON.stringify({enabled:!(t!=null&&t.enabled)})}),r()}finally{x(!1)}},p=async()=>{n(!0);try{await u("/api/autopilot/run",{method:"POST"}),r()}finally{n(!1)}},f=m=>{switch(m){case"urgent":return e.jsx(z,{className:"w-3.5 h-3.5 text-error"});case"notable":return e.jsx($,{className:"w-3.5 h-3.5 text-warning"});default:return e.jsx(D,{className:"w-3.5 h-3.5 text-emerald"})}};return e.jsxs("div",{children:[e.jsx(T,{icon:$,title:"Autopilot",accent:"#f59e0b"}),e.jsxs("div",{className:"rounded-lg overflow-hidden",style:{backgroundColor:"var(--color-bg-secondary)",border:"1px solid #27272a"},children:[e.jsxs("div",{className:"flex items-center gap-4 px-4 py-3",children:[e.jsx("button",{onClick:g,disabled:c,title:t!=null&&t.enabled?"Disable autopilot":"Enable autopilot",children:t!=null&&t.enabled?e.jsx(L,{className:"w-6 h-6 text-emerald"}):e.jsx(H,{className:"w-6 h-6 text-text-muted"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-text",children:t!=null&&t.enabled?"Active":"Disabled"}),(t==null?void 0:t.isRunning)&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-cyan",children:[e.jsx(N,{className:"w-3 h-3 animate-spin"})," Running..."]})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-0.5",children:[e.jsxs("span",{className:"text-xs text-text-muted",children:[e.jsx(Y,{className:"w-3 h-3 inline mr-1"}),t!=null&&t.schedule?M(t.schedule):"No schedule"]}),e.jsxs("span",{className:"text-xs text-text-muted",children:[(t==null?void 0:t.totalRuns)??0," total runs"]}),(t==null?void 0:t.lastRun)&&e.jsxs("span",{className:"text-xs text-text-muted",children:["Last: ",S(t.lastRun.timestamp)]})]})]}),e.jsxs("button",{onClick:p,disabled:o||(t==null?void 0:t.isRunning),className:"flex items-center gap-1 text-xs px-3 py-1.5 rounded-lg transition-opacity hover:opacity-80",style:{backgroundColor:"#f59e0b30",color:"var(--color-warning)"},children:[o?e.jsx(N,{className:"w-3 h-3 animate-spin"}):e.jsx(R,{className:"w-3 h-3"}),"Run Now"]})]}),l.length>0&&e.jsxs("div",{className:"border-t",style:{borderColor:"var(--color-bg-tertiary)"},children:[e.jsx("div",{className:"px-4 py-2",children:e.jsx("span",{className:"text-xs font-medium text-text-muted",children:"Recent Runs"})}),e.jsx("div",{className:"divide-y",style:{borderColor:"var(--color-bg-tertiary)"},children:l.slice(-5).reverse().map((m,v)=>e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2",children:[f(m.classification),e.jsx("span",{className:"text-xs flex-1 truncate text-text-secondary",children:m.skipped?`Skipped: ${m.summary}`:m.summary.slice(0,120)}),e.jsx(W,{status:m.classification}),e.jsx("span",{className:"text-xs flex-shrink-0 text-text-muted",children:S(m.timestamp)})]},v))})]})]})]})}function De(){const[t,l]=d.useState([]),[r,c]=d.useState([]),[x,o]=d.useState([]),[n,g]=d.useState(null),[p,f]=d.useState([]),[m,v]=d.useState(!0),h=d.useCallback(async()=>{try{const[s,j,k,C,a]=await Promise.allSettled([u("/api/goals"),u("/api/cron"),u("/api/recipes"),u("/api/autopilot/status"),u("/api/autopilot/history?limit=5")]);s.status==="fulfilled"&&l(s.value.goals||[]),j.status==="fulfilled"&&c(j.value.jobs||[]),k.status==="fulfilled"&&o(k.value.recipes||[]),C.status==="fulfilled"&&g(C.value),a.status==="fulfilled"&&f(Array.isArray(a.value)?a.value:[])}finally{v(!1)}},[]);return d.useEffect(()=>{h();const s=setInterval(h,15e3);return()=>clearInterval(s)},[h]),m?e.jsx("div",{className:"flex items-center justify-center py-20",children:e.jsx(N,{className:"w-6 h-6 animate-spin text-text-muted"})}):e.jsxs("div",{className:"space-y-8",children:[e.jsx(Z,{title:"Workflows",breadcrumbs:[{label:"Admin",href:"/overview"},{label:"Agent"},{label:"Workflows"}],actions:e.jsx("button",{onClick:()=>{v(!0),h()},className:"p-2 rounded-lg transition-colors hover:opacity-80 bg-bg-tertiary",title:"Refresh",children:e.jsx(N,{className:"w-4 h-4 text-text-secondary"})})}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[{label:"Goals",value:t.filter(s=>s.status==="active").length,total:t.length,color:"var(--color-emerald)"},{label:"Cron Jobs",value:r.filter(s=>s.enabled).length,total:r.length,color:"var(--color-cyan)"},{label:"Recipes",value:x.length,color:"var(--color-accent)"},{label:"Autopilot Runs",value:(n==null?void 0:n.totalRuns)??0,color:"var(--color-warning)"}].map(s=>e.jsxs("div",{className:"rounded-lg px-4 py-3",style:{backgroundColor:"var(--color-bg-secondary)",border:"1px solid #27272a"},children:[e.jsx("p",{className:"text-xs mb-1 text-text-muted",children:s.label}),e.jsxs("p",{className:"text-lg font-bold",style:{color:s.color},children:[s.value,s.total!==void 0&&s.total!==s.value&&e.jsxs("span",{className:"text-xs font-normal ml-1 text-text-muted",children:["/ ",s.total]})]})]},s.label))}),e.jsx(te,{goals:t,onRefresh:h}),e.jsx(se,{jobs:r,onRefresh:h}),e.jsx(ae,{recipes:x,onRefresh:h}),e.jsx(re,{status:n,history:p,onRefresh:h})]})}export{De as default};
@@ -0,0 +1 @@
1
+ function g(n){var s,a;const e=n.payload||{},o=e.kind;if(o==="driver_blocked"){const t=e.question||"Specialist needs clarification",i=[];return e.goalTitle&&i.push(`Goal: ${e.goalTitle}`),e.subtaskTitle&&i.push(`Task: ${e.subtaskTitle}`),e.specialist&&i.push(`Agent: ${e.specialist}`),e.attempts&&i.push(`${e.attempts} attempt(s)`),e.lastError&&i.push(`Error: ${String(e.lastError).slice(0,120)}`),{kindLabel:"Driver blocked",headline:t.length>120?t.slice(0,120)+"…":t,detail:i.join(" · ")||void 0,urgency:"high"}}if(o==="self_mod_pr"){const t=n.payload,i=t.initialFileCount,r=t.firstFile,d=t.proposedBy,l=[];return typeof i=="number"&&i>0&&l.push(`${i} file${i===1?"":"s"}`),r&&l.push(r.split("/").slice(-2).join("/")),e.target&&l.push(`→ ${e.target}`),d&&l.push(`by ${d}`),{kindLabel:"Self-mod PR",headline:e.goalTitle?`Code changes for: ${e.goalTitle}`:"Code changes pending review",detail:l.length>0?l.join(" · "):e.suggestedAction,urgency:"medium"}}if(o==="self_repair"){const i=(e.evidence||{}).driveId,r=e.finding||"finding";return{kindLabel:"Self-repair",headline:e.reason||`${r}${i?` (${i})`:""}`,detail:e.suggestedAction,urgency:e.severity||"medium"}}if(o==="canary_regression"){const t=e.regressions||[],i=t.length>0?t.map(r=>`${r.taskId} ${(r.baseline*100).toFixed(0)}%→${(r.current*100).toFixed(0)}%`).join(", "):null;return{kindLabel:"Canary regression",headline:i?`Quality drop on ${t.length} task(s): ${i}`:e.reason||"Model quality regression detected",detail:e.suggestedAction||(e.model?`Model: ${e.model}`:void 0),urgency:"high"}}if(n.type==="goal_proposal"||n.type==="soma_proposal"||o==="goal_proposal")return{kindLabel:n.type==="soma_proposal"?"Soma proposal":"New goal proposal",headline:e.title||e.goalTitle||"Goal proposal",detail:((s=e.description)==null?void 0:s.slice(0,180))||((a=e.rationale)==null?void 0:a.slice(0,180)),urgency:"medium"};if(n.type==="hire_agent")return{kindLabel:"Hire agent",headline:e.name?`Hire "${e.name}" as ${e.role||"agent"}`:"Hire new agent",urgency:"medium"};if(n.type==="budget_override")return{kindLabel:"Budget override",headline:"Agent requesting budget continuation",detail:e.reason,urgency:"medium"};const p=e.question||e.title||e.goalTitle||e.reason||e.finding||e.description||e.rationale||`${n.type.replace(/_/g," ")} from ${n.requestedBy}`;return{kindLabel:(o||n.type).replace(/_/g," "),headline:String(p).slice(0,200),urgency:e.urgency||"low"}}export{g as e};
@@ -1,4 +1,4 @@
1
- import{c as o}from"./index-CahJbWSR.js";/**
1
+ import{c as o}from"./index-DzwowwSI.js";/**
2
2
  * @license lucide-react v0.513.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.