titan-agent 6.1.0-beta.2 → 6.1.0-beta.21

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 (235) hide show
  1. package/LICENSE +1 -29
  2. package/README.md +1 -1
  3. package/dist/agent/agentLessons.js +2 -2
  4. package/dist/agent/agentLessons.js.map +1 -1
  5. package/dist/agent/autoModeClassifier.js +95 -0
  6. package/dist/agent/autoModeClassifier.js.map +1 -0
  7. package/dist/agent/durableJournal.js +2 -2
  8. package/dist/agent/durableJournal.js.map +1 -1
  9. package/dist/agent/goalDriver.js +67 -0
  10. package/dist/agent/goalDriver.js.map +1 -1
  11. package/dist/agent/goalPlanFile.js +3 -3
  12. package/dist/agent/goalPlanFile.js.map +1 -1
  13. package/dist/agent/missionLifecycle.js +2 -2
  14. package/dist/agent/missionLifecycle.js.map +1 -1
  15. package/dist/agent/subAgent.js +41 -0
  16. package/dist/agent/subAgent.js.map +1 -1
  17. package/dist/agent/toolContract.js +49 -0
  18. package/dist/agent/toolContract.js.map +1 -0
  19. package/dist/agent/toolRunner.js +72 -11
  20. package/dist/agent/toolRunner.js.map +1 -1
  21. package/dist/agent/trajectoryRecorder.js +185 -0
  22. package/dist/agent/trajectoryRecorder.js.map +1 -0
  23. package/dist/agent/verification.js +164 -0
  24. package/dist/agent/verification.js.map +1 -0
  25. package/dist/agent/worktreeExecutor.js +207 -0
  26. package/dist/agent/worktreeExecutor.js.map +1 -0
  27. package/dist/config/schema.js +28 -1
  28. package/dist/config/schema.js.map +1 -1
  29. package/dist/gateway/server.js +54 -0
  30. package/dist/gateway/server.js.map +1 -1
  31. package/dist/memory/facade.js +137 -0
  32. package/dist/memory/facade.js.map +1 -0
  33. package/dist/migrations/003-soma-profile-default.js +2 -2
  34. package/dist/migrations/003-soma-profile-default.js.map +1 -1
  35. package/dist/migrations/005-route-redirects.js +3 -1
  36. package/dist/migrations/005-route-redirects.js.map +1 -1
  37. package/dist/migrations/runner.js +2 -2
  38. package/dist/migrations/runner.js.map +1 -1
  39. package/dist/providers/defaultModel.js +14 -0
  40. package/dist/providers/defaultModel.js.map +1 -1
  41. package/dist/providers/router.js +4 -0
  42. package/dist/providers/router.js.map +1 -1
  43. package/dist/providers/stub.js +185 -0
  44. package/dist/providers/stub.js.map +1 -0
  45. package/dist/skills/builtin/backup.js +1 -2
  46. package/dist/skills/builtin/backup.js.map +1 -1
  47. package/dist/skills/builtin/contracts.js +254 -0
  48. package/dist/skills/builtin/contracts.js.map +1 -0
  49. package/dist/skills/builtin/download_image.js +9 -0
  50. package/dist/skills/builtin/download_image.js.map +1 -1
  51. package/dist/skills/builtin/filesystem.js +70 -20
  52. package/dist/skills/builtin/filesystem.js.map +1 -1
  53. package/dist/skills/registry.js +7 -0
  54. package/dist/skills/registry.js.map +1 -1
  55. package/dist/storage/patterns.js +2 -2
  56. package/dist/storage/patterns.js.map +1 -1
  57. package/dist/storage/personalGallery.js +2 -2
  58. package/dist/storage/personalGallery.js.map +1 -1
  59. package/dist/storage/somaProfile.js +2 -2
  60. package/dist/storage/somaProfile.js.map +1 -1
  61. package/dist/utils/constants.js +1 -1
  62. package/dist/utils/constants.js.map +1 -1
  63. package/package.json +2 -2
  64. package/ui/dist/assets/{AuditPanel-DrDvXZ9u.js → AuditPanel-RNrvKmfX.js} +1 -1
  65. package/ui/dist/assets/{AutonomyPanel-BfhW-PRX.js → AutonomyPanel-D0nmt79R.js} +2 -2
  66. package/ui/dist/assets/{AutopilotPanel-C3yQBxAp.js → AutopilotPanel-DlcdfRRy.js} +1 -1
  67. package/ui/dist/assets/{AutoresearchPanel-BgpR3EcK.js → AutoresearchPanel-CXeO6kGK.js} +2 -2
  68. package/ui/dist/assets/BackupPanel-CKb-cDsk.js +1 -0
  69. package/ui/dist/assets/{BrowserPanel-BNaKZOnn.js → BrowserPanel-CDaoF6n5.js} +1 -1
  70. package/ui/dist/assets/CPActivity-BZbeztg1.js +1 -0
  71. package/ui/dist/assets/CPAgentDetail-C9fvLxKi.js +1 -0
  72. package/ui/dist/assets/CPAgents-BsBA9kb2.js +1 -0
  73. package/ui/dist/assets/CPApprovals-Di5itVIK.js +1 -0
  74. package/ui/dist/assets/CPCosts-DmgckHli.js +1 -0
  75. package/ui/dist/assets/CPDashboard-CmSb7woK.js +1 -0
  76. package/ui/dist/assets/{CPFiles-CUpP5I82.js → CPFiles-Dd0NGcpX.js} +1 -1
  77. package/ui/dist/assets/CPGoals-DeILFq0A.js +1 -0
  78. package/ui/dist/assets/{CPInbox-DUW_hntB.js → CPInbox-DAtidZez.js} +2 -2
  79. package/ui/dist/assets/CPIssueDetail-BvwoGI57.js +1 -0
  80. package/ui/dist/assets/CPIssues-CZ1hIKDP.js +1 -0
  81. package/ui/dist/assets/{CPLayout-J0fa-it4.js → CPLayout-luPwhNpA.js} +3 -3
  82. package/ui/dist/assets/CPOrg-BlYp_KP6.js +8 -0
  83. package/ui/dist/assets/CPRuns-D0HMCjIo.js +1 -0
  84. package/ui/dist/assets/{CPSocial-By_FStZ4.js → CPSocial-CZaGi14s.js} +2 -2
  85. package/ui/dist/assets/ChannelsPanel-khiBHwx3.js +1 -0
  86. package/ui/dist/assets/{CheckpointsPanel-DvKUd2VF.js → CheckpointsPanel-n2y3jzzT.js} +1 -1
  87. package/ui/dist/assets/{CommandPostHub-CQqRYBjf.js → CommandPostHub-iWf-zt5p.js} +4 -4
  88. package/ui/dist/assets/{CronPanel-Brmnnu8_.js → CronPanel-BkRJl8u6.js} +1 -1
  89. package/ui/dist/assets/{DataTable-seaktPzB.js → DataTable-DZ2cG3Cv.js} +1 -1
  90. package/ui/dist/assets/{DreamPanel-CO7iSdjn.js → DreamPanel-DF6l0WB-.js} +1 -1
  91. package/ui/dist/assets/{EmptyState-CmK9fywh.js → EmptyState-D7xwm8hA.js} +1 -1
  92. package/ui/dist/assets/{EvalHarnessPanel-2RVBKbym.js → EvalHarnessPanel-BHabu49z.js} +2 -2
  93. package/ui/dist/assets/{EvalPanel-CqAwhFQ5.js → EvalPanel-yAesMLSP.js} +1 -1
  94. package/ui/dist/assets/{FileViewer-D98m-vF5.js → FileViewer-DOWUQccc.js} +52 -14
  95. package/ui/dist/assets/{FilesPanel-dRQM0apb.js → FilesPanel-BjuDhqaX.js} +2 -2
  96. package/ui/dist/assets/FleetPanel-B0ZhS2XX.js +1 -0
  97. package/ui/dist/assets/{HomelabPanel-DjMUrO2B.js → HomelabPanel-D373ddvj.js} +1 -1
  98. package/ui/dist/assets/InfraView-CI99NZbI.js +2 -0
  99. package/ui/dist/assets/InlineEditableField-fDk3eGVo.js +1 -0
  100. package/ui/dist/assets/Input-j10hONMY.js +1 -0
  101. package/ui/dist/assets/IntegrationsPanel-kPa5Qq-f.js +1 -0
  102. package/ui/dist/assets/IntelligenceView-DeKBaAlY.js +2 -0
  103. package/ui/dist/assets/LearningPanel-B8tqHeEZ.js +1 -0
  104. package/ui/dist/assets/{LogsPanel-Bs9IsTCH.js → LogsPanel-sXc__trb.js} +1 -1
  105. package/ui/dist/assets/McpPanel-DEr8pZwB.js +1 -0
  106. package/ui/dist/assets/{MemoryGraphPanel-F1P9COyY.js → MemoryGraphPanel-DZl7USJ6.js} +1 -1
  107. package/ui/dist/assets/MemoryWikiPanel-DTNVWvVT.js +11 -0
  108. package/ui/dist/assets/{MeshPanel-CgIAh5ZX.js → MeshPanel-b77zyQx4.js} +1 -1
  109. package/ui/dist/assets/MissionCanvas-D_quSl5F.js +69 -0
  110. package/ui/dist/assets/MissionChat-rQ5rUPAt.js +7 -0
  111. package/ui/dist/assets/MissionLibrary-Cxw7sLxv.js +5 -0
  112. package/ui/dist/assets/MissionStart-ChMWO1rr.js +1 -0
  113. package/ui/dist/assets/Modal-Dl5b6Yaj.js +1 -0
  114. package/ui/dist/assets/NvidiaPanel-D7qFbbeJ.js +1 -0
  115. package/ui/dist/assets/{OrganismPanel-CNZM3eof.js → OrganismPanel-EiQ9Gfqx.js} +1 -1
  116. package/ui/dist/assets/OverviewPanel-Bectj1Z5.js +1 -0
  117. package/ui/dist/assets/{PageHeader-llOXO43Z.js → PageHeader-CiuoyvDR.js} +1 -1
  118. package/ui/dist/assets/{PersonaProfilesPanel-CfsQTMra.js → PersonaProfilesPanel-BO87DSVG.js} +1 -1
  119. package/ui/dist/assets/{PersonasPanel-DIac_kZ3.js → PersonasPanel-BNogLwM0.js} +1 -1
  120. package/ui/dist/assets/RecipesPanel-DyqfWlaY.js +1 -0
  121. package/ui/dist/assets/{SecurityPanel-_gqMk8hJ.js → SecurityPanel-OMC-Tvbz.js} +1 -1
  122. package/ui/dist/assets/SelfImprovePanel-DXIfG_df.js +1 -0
  123. package/ui/dist/assets/{SelfProposalsPanel-DuA0zsGH.js → SelfProposalsPanel-CmgEz1TQ.js} +2 -2
  124. package/ui/dist/assets/SessionsPanel-gJXosEGf.js +1 -0
  125. package/ui/dist/assets/{SessionsTab-bFYaFvTZ.js → SessionsTab-BOVzzjTO.js} +1 -1
  126. package/ui/dist/assets/SettingsPanel-DifFGEvi.js +1 -0
  127. package/ui/dist/assets/SettingsView-BNpj0iym.js +2 -0
  128. package/ui/dist/assets/SkeletonLoader-CNSsfH3f.js +1 -0
  129. package/ui/dist/assets/{SkillsPanel-D08WcRGp.js → SkillsPanel-6fbRov-m.js} +1 -1
  130. package/ui/dist/assets/{SomaView-CYukE7Fp.js → SomaView-D3boPl5D.js} +1 -1
  131. package/ui/dist/assets/{StatCard-DT4Bx1mY.js → StatCard-2BmOlamJ.js} +1 -1
  132. package/ui/dist/assets/StatusBadge-CdVHF1nG.js +1 -0
  133. package/ui/dist/assets/Tabs-DW9ytf9H.js +1 -0
  134. package/ui/dist/assets/{TeamsPanel-DOBe72TK.js → TeamsPanel-CNaQ8Dbw.js} +1 -1
  135. package/ui/dist/assets/TelemetryPanel-DL81QlAW.js +1 -0
  136. package/ui/dist/assets/TitanCanvas-DLIN_wV3.js +1152 -0
  137. package/ui/dist/assets/ToolsView-BlChEE4n.js +2 -0
  138. package/ui/dist/assets/Tooltip-oR5JnwoN.js +6 -0
  139. package/ui/dist/assets/{TraceViewer-0bCz0x_a.js → TraceViewer-DtJXjCXV.js} +1 -1
  140. package/ui/dist/assets/TrainingPanel-4XMGaRN_.js +1 -0
  141. package/ui/dist/assets/{VoiceOverlay-B08Sw918.js → VoiceOverlay-B3fXJ-EC.js} +1 -1
  142. package/ui/dist/assets/{VramPanel-CJiic8y4.js → VramPanel-HisAYiqI.js} +1 -1
  143. package/ui/dist/assets/{WatchView-CaQMDEAy.js → WatchView-C92y0hU7.js} +1 -1
  144. package/ui/dist/assets/{WorkTab-D5bi2WRi.js → WorkTab-BYAWcvA1.js} +1 -1
  145. package/ui/dist/assets/{WorkflowsPanel-DdY6E93C.js → WorkflowsPanel-D2DiOBLA.js} +1 -1
  146. package/ui/dist/assets/{arrow-left-CHJyrO8S.js → arrow-left-thXQMJQ6.js} +1 -1
  147. package/ui/dist/assets/{briefcase-ROIEmiah.js → briefcase-ByMhDqlL.js} +1 -1
  148. package/ui/dist/assets/{chart-column-wFkjV3Ni.js → chart-column-CYHJVuxN.js} +1 -1
  149. package/ui/dist/assets/{check-BcOm5jPO.js → check-ChWLFWCx.js} +1 -1
  150. package/ui/dist/assets/{chevron-down-CM11GPpR.js → chevron-down-CU_O_5h3.js} +1 -1
  151. package/ui/dist/assets/{chevron-right-aFDDgFsL.js → chevron-right-DAiXsK24.js} +1 -1
  152. package/ui/dist/assets/{chevron-up-D6g7FB6i.js → chevron-up-BudRYwvy.js} +1 -1
  153. package/ui/dist/assets/{circle-check-big-DPz64kZW.js → circle-check-big-gkA-V2JW.js} +1 -1
  154. package/ui/dist/assets/{clock-BbCCaukN.js → clock-qO5kIED9.js} +1 -1
  155. package/ui/dist/assets/clsx-B-dksMZM.js +1 -0
  156. package/ui/dist/assets/{dollar-sign-Dy5-qkg3.js → dollar-sign-1gQNJK3V.js} +1 -1
  157. package/ui/dist/assets/{download-DjheLEns.js → download-DMD1m87c.js} +1 -1
  158. package/ui/dist/assets/{external-link-BgxGF7ZQ.js → external-link-ByafQkZ7.js} +1 -1
  159. package/ui/dist/assets/{folder-DY4eeMdo.js → folder-DeG4RuOD.js} +1 -1
  160. package/ui/dist/assets/{funnel-LWmcwhj-.js → funnel-wE8i5V9Y.js} +1 -1
  161. package/ui/dist/assets/{git-branch-CPZciK10.js → git-branch-BWSuK1LU.js} +1 -1
  162. package/ui/dist/assets/index-B8YEFBRH.js +277 -0
  163. package/ui/dist/assets/index-Cb5bSxRB.css +1 -0
  164. package/ui/dist/assets/{layers-Bn7bgu2Z.js → layers-tN-wIpE0.js} +1 -1
  165. package/ui/dist/assets/{legacy-BVPeht6t.js → legacy-BSZBdyop.js} +2 -2
  166. package/ui/dist/assets/{lightbulb-tzuCyEQk.js → lightbulb-TUHKCda3.js} +1 -1
  167. package/ui/dist/assets/{list-todo-say4NbSw.js → list-todo-DtxcUGz2.js} +1 -1
  168. package/ui/dist/assets/{missions-DbC8UmMc.js → missions-C3EC4uKT.js} +1 -1
  169. package/ui/dist/assets/{network-v9O7MmZT.js → network-ephW7nah.js} +1 -1
  170. package/ui/dist/assets/{pause-CZo33QlA.js → pause-DeggUVZc.js} +1 -1
  171. package/ui/dist/assets/{play-DbCJhc5H.js → play-Dfc0ia6v.js} +1 -1
  172. package/ui/dist/assets/{plug-CtpCZg2z.js → plug-Bl_6i_9u.js} +1 -1
  173. package/ui/dist/assets/{plus-O61rB_YF.js → plus-CQwCh7WY.js} +1 -1
  174. package/ui/dist/assets/{proxy-BAUTNyg6.js → proxy-BjQ4lsww.js} +1 -1
  175. package/ui/dist/assets/{rotate-ccw-n5WkWR51.js → rotate-ccw-CUuN2ebi.js} +1 -1
  176. package/ui/dist/assets/{save-D2Qh8KyN.js → save-PlTUvsN5.js} +1 -1
  177. package/ui/dist/assets/{search-C9SdcZJq.js → search-BHgLDT-j.js} +1 -1
  178. package/ui/dist/assets/{send-DZ_5M5QQ.js → send-pflQNBoT.js} +1 -1
  179. package/ui/dist/assets/{shield-check-DyP5PmaY.js → shield-check-CrD-s89i.js} +1 -1
  180. package/ui/dist/assets/{target-CWfn705s.js → target-D4oh8GME.js} +1 -1
  181. package/ui/dist/assets/{terminal-CdhfA0Kr.js → terminal-BvJZ1R3x.js} +1 -1
  182. package/ui/dist/assets/{toggle-right-CmYQLQRS.js → toggle-right-Dl7x_ed7.js} +1 -1
  183. package/ui/dist/assets/{trash-2-TQcEJEv4.js → trash-2-lPcFwnW5.js} +1 -1
  184. package/ui/dist/assets/{trending-up-Cw22bM4J.js → trending-up-DqUbZfDe.js} +1 -1
  185. package/ui/dist/assets/{trophy-DUF8Bcas.js → trophy-Dv6zFfKM.js} +1 -1
  186. package/ui/dist/assets/{users-BX_ZaByZ.js → users-NPyAWbs5.js} +1 -1
  187. package/ui/dist/assets/{wrench-Cfp7nYhG.js → wrench-BCKgeHj3.js} +1 -1
  188. package/ui/dist/index.html +2 -2
  189. package/ui/dist/sw.js +1 -1
  190. package/ui/dist/assets/BackupPanel-BNxMlNIP.js +0 -1
  191. package/ui/dist/assets/CPActivity-CjIgehOq.js +0 -1
  192. package/ui/dist/assets/CPAgentDetail-oaymYRNI.js +0 -1
  193. package/ui/dist/assets/CPAgents-CWQ6iJfO.js +0 -1
  194. package/ui/dist/assets/CPApprovals-DzATBhtM.js +0 -1
  195. package/ui/dist/assets/CPCosts-xVQR148_.js +0 -1
  196. package/ui/dist/assets/CPDashboard-Dt6Jr7Zw.js +0 -1
  197. package/ui/dist/assets/CPGoals-Bt1a3C9T.js +0 -1
  198. package/ui/dist/assets/CPIssueDetail-DHxqtiuh.js +0 -1
  199. package/ui/dist/assets/CPIssues-D0l3fgUs.js +0 -1
  200. package/ui/dist/assets/CPOrg-DQ3tbYld.js +0 -8
  201. package/ui/dist/assets/CPRuns-0vncicUW.js +0 -1
  202. package/ui/dist/assets/ChannelsPanel-CiJs4gyw.js +0 -1
  203. package/ui/dist/assets/FleetPanel-Bg-f3_ip.js +0 -1
  204. package/ui/dist/assets/InfraView-CHYaZqMK.js +0 -2
  205. package/ui/dist/assets/InlineEditableField-BOLRKQq1.js +0 -1
  206. package/ui/dist/assets/Input-4pNffAw-.js +0 -1
  207. package/ui/dist/assets/IntegrationsPanel-CFucvr-Q.js +0 -1
  208. package/ui/dist/assets/IntelligenceView-Dh-Wuf13.js +0 -2
  209. package/ui/dist/assets/LearningPanel-CtlougkF.js +0 -1
  210. package/ui/dist/assets/McpPanel-BobqpLsh.js +0 -1
  211. package/ui/dist/assets/MemoryWikiPanel-BfYksjoI.js +0 -11
  212. package/ui/dist/assets/MissionCanvas-0V_vtqiu.js +0 -50
  213. package/ui/dist/assets/MissionChat-9hGhc9Zw.js +0 -7
  214. package/ui/dist/assets/MissionLibrary-dFkT8pGp.js +0 -5
  215. package/ui/dist/assets/MissionStart-CZSEie0Q.js +0 -1
  216. package/ui/dist/assets/Modal-V2yNnkKk.js +0 -1
  217. package/ui/dist/assets/NvidiaPanel-qLJysI9M.js +0 -1
  218. package/ui/dist/assets/OverviewPanel-Be6LukJ_.js +0 -1
  219. package/ui/dist/assets/RecipesPanel-DDYOCx3w.js +0 -1
  220. package/ui/dist/assets/SelfImprovePanel-B8o_fO30.js +0 -1
  221. package/ui/dist/assets/SessionsPanel-DeCBkSgY.js +0 -1
  222. package/ui/dist/assets/SettingsPanel-BlsRDAt7.js +0 -1
  223. package/ui/dist/assets/SettingsView-Dsa7Zr4e.js +0 -2
  224. package/ui/dist/assets/SkeletonLoader-BkQoZllJ.js +0 -1
  225. package/ui/dist/assets/StatusBadge-BFEHCdgi.js +0 -1
  226. package/ui/dist/assets/Tabs-g2Gs9sK0.js +0 -1
  227. package/ui/dist/assets/TelemetryPanel-DXAGuV0R.js +0 -1
  228. package/ui/dist/assets/TitanCanvas-DCl3gxSl.js +0 -1072
  229. package/ui/dist/assets/ToolsView-CnUjq0Js.js +0 -2
  230. package/ui/dist/assets/Tooltip-DJ99YlFF.js +0 -6
  231. package/ui/dist/assets/TrainingPanel-BLf_KMaE.js +0 -1
  232. package/ui/dist/assets/eye-off-CYR4nH5I.js +0 -6
  233. package/ui/dist/assets/index-PwwKjgT3.css +0 -1
  234. package/ui/dist/assets/index-slWylU2o.js +0 -244
  235. package/ui/dist/assets/loader-circle-E8aLxmMz.js +0 -6
@@ -1,50 +0,0 @@
1
- import{r as o,j as e,l as me,u as ye,q as ve}from"./index-slWylU2o.js";import{p as J,f as ke,h as we,i as je,g as Ne,a as re,s as Se,b as Ce,d as Me,e as $e}from"./missions-DbC8UmMc.js";import{F as De}from"./FileViewer-D98m-vF5.js";function Oe({member:t,room:a,anchor:s,availableModels:i,onClose:x,onTalkInChat:b}){const h=o.useRef(null),[c,m]=o.useState("main"),[p,y]=o.useState(""),[w,l]=o.useState(!1),[u,d]=o.useState(!1),[j,v]=o.useState(null);o.useEffect(()=>{const k=$=>{$.key==="Escape"&&x()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[x]);const f=320,M=360,N=Te(s,f,M);async function z(){d(!0),v(null);try{await J(a.id,`@${t.name} quick check-in — how's it going? Anything I can clear for you?`),x()}catch(k){v(k.message)}finally{d(!1)}}async function E(k){const $=p.trim();if(!(!$||w)){l(!0),v(null);try{await J(a.id,`@${t.name} ${k}${$}`),y(""),x()}catch(R){v(R.message)}finally{l(!1)}}}async function F(k){d(!0),v(null);try{await je(a.id,t.agentId,k),m("main")}catch($){v($.message)}finally{d(!1)}}async function I(){d(!0),v(null);try{await ke(a.id,t.agentId,!t.paused)}catch(k){v(k.message)}finally{d(!1)}}async function B(){d(!0),v(null);try{await we(a.id,!a.longRunningMode)}catch(k){v(k.message)}finally{d(!1)}}return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-[60]",onClick:x,"aria-hidden":!0}),e.jsxs("div",{ref:h,className:"absolute z-[61] flex flex-col bg-bg-secondary border border-border rounded-2xl shadow-2xl overflow-hidden",style:{left:N.x,top:N.y,width:f,maxHeight:M},onClick:k=>k.stopPropagation(),children:[e.jsx("div",{className:"h-1.5",style:{background:`linear-gradient(90deg, ${t.color}, ${ie(t.color,-25)})`}}),e.jsxs("div",{className:"px-4 pt-3 pb-2 flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-md flex items-center justify-center text-white font-bold text-[14px]",style:{background:`linear-gradient(135deg, ${t.color}, ${ie(t.color,-25)})`},children:t.name[0]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-semibold text-sm",children:t.name}),e.jsxs("div",{className:"text-[11px] text-text-muted",children:[t.role," · ",ze(t)]})]}),e.jsx("button",{onClick:x,className:"w-7 h-7 rounded-full bg-bg-tertiary/60 border border-border text-text-muted hover:text-text flex items-center justify-center text-sm",children:"✕"})]}),t.currentActivity&&e.jsxs("div",{className:"px-4 pb-2 text-[11px] text-text-secondary italic leading-snug border-b border-border/60",children:['"',t.currentActivity,'"']}),j&&e.jsx("div",{className:"px-4 py-2 text-[11px] text-error bg-error/10 border-b border-error/30",children:j}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[c==="main"&&e.jsxs("div",{className:"p-2 grid grid-cols-2 gap-2",children:[e.jsx(H,{icon:"👋",label:"Nudge",hint:"A friendly check-in",onClick:z,disabled:u}),e.jsx(H,{icon:"💬",label:"Talk to them",hint:"Send a message just to them",onClick:()=>{b?(b(t.agentId,`@${t.name} `),x()):m("talk")},disabled:u}),e.jsx(H,{icon:"🧭",label:"Steer",hint:"Redirect them mid-task",onClick:()=>m("steer"),disabled:u}),e.jsx(H,{icon:"🧠",label:"Model",hint:t.modelOverride?Fe(t.modelOverride):"default",onClick:()=>m("model"),disabled:u}),e.jsx(H,{icon:t.paused?"▶":"⏸",label:t.paused?"Resume agent":"Pause agent",hint:t.paused?"Bring them back":"Skip them for now",onClick:I,disabled:u,wide:!1}),e.jsx(H,{icon:"🏃",label:a.longRunningMode?"Marathon ON":"Marathon mode",hint:a.longRunningMode?"running 72h goal":"72h auto-run",onClick:B,disabled:u,active:!!a.longRunningMode})]}),(c==="talk"||c==="steer")&&e.jsxs("div",{className:"p-3 flex flex-col gap-2",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-widest text-text-muted",children:c==="talk"?`Message ${t.name}`:`Steer ${t.name}`}),e.jsx("textarea",{autoFocus:!0,value:p,onChange:k=>y(k.target.value),rows:4,onKeyDown:k=>{k.key==="Enter"&&(k.metaKey||k.ctrlKey)&&(k.preventDefault(),E(c==="steer"?"steer: ":""))},placeholder:c==="steer"?'e.g. "skip the chart, focus on cost comparison"':"Type a private note to them…",className:"bg-bg-tertiary border border-border rounded-lg p-2 text-sm text-text outline-none focus:border-accent resize-none"}),c==="steer"&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:["Slow down","Be thorough","Wrap it up","Skip the chart"].map(k=>e.jsx("button",{onClick:()=>y(k.toLowerCase()),className:"px-2 py-0.5 text-[11px] bg-bg-tertiary border border-border rounded-full text-text-muted hover:text-text",children:k},k))}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("button",{onClick:()=>m("main"),className:"text-xs text-text-muted hover:text-text",children:"← Back"}),e.jsx("button",{onClick:()=>E(c==="steer"?"steer: ":""),disabled:!p.trim()||w,className:"px-3 py-1.5 rounded-lg font-bold text-bg-deep bg-gradient-to-br from-accent to-accent2 disabled:opacity-50 text-xs",children:w?"Sending…":"Send ⌘↵"})]})]}),c==="model"&&e.jsxs("div",{className:"p-3 flex flex-col gap-2",children:[e.jsxs("div",{className:"text-[10px] uppercase tracking-widest text-text-muted",children:[t.name,"'s brain"]}),e.jsx("div",{className:"text-[11px] text-text-secondary leading-snug",children:"Pick a specific model for this agent on this mission. Empty = the role's default."}),t.modelOverride&&e.jsxs("div",{className:"px-2.5 py-1.5 rounded-lg bg-accent/10 border border-accent/40 text-[12px] text-text flex items-center justify-between",children:[e.jsxs("span",{className:"truncate",children:["Now: ",e.jsx("b",{children:t.modelOverride})]}),e.jsx("button",{onClick:()=>F(null),className:"text-[11px] text-text-muted hover:text-text shrink-0",children:"clear"})]}),e.jsx("div",{className:"flex flex-col gap-1 max-h-48 overflow-y-auto",children:i.length===0?e.jsx("div",{className:"text-[11px] text-text-muted italic",children:"No models discovered. /api/models returned empty."}):i.map(k=>{const $=t.modelOverride===k.id;return e.jsxs("button",{onClick:()=>F(k.id),disabled:u,className:`flex items-center justify-between px-2.5 py-1.5 rounded-lg text-[12px] border text-left ${$?"bg-accent/10 border-accent/60 text-text":"bg-bg-tertiary/40 border-border text-text-secondary hover:text-text hover:border-border-light"}`,children:[e.jsx("span",{className:"truncate",children:k.id}),e.jsx("span",{className:"text-[10px] text-text-muted ml-2 shrink-0",children:k.provider})]},k.id)})}),e.jsx("button",{onClick:()=>m("main"),className:"text-xs text-text-muted hover:text-text self-start mt-1",children:"← Back"})]})]})]})]})}function H({icon:t,label:a,hint:s,onClick:i,disabled:x,wide:b,active:h}){return e.jsxs("button",{onClick:i,disabled:x,className:`text-left p-2.5 rounded-xl border transition-colors ${h?"bg-accent/15 border-accent/50 text-text":"bg-bg-tertiary/40 border-border text-text-secondary hover:text-text hover:border-border-light"} ${b?"col-span-2":""} disabled:opacity-50`,children:[e.jsx("div",{className:"text-lg leading-none mb-1",children:t}),e.jsx("div",{className:"text-[12px] font-semibold leading-tight",children:a}),s&&e.jsx("div",{className:"text-[10px] text-text-muted leading-snug mt-0.5 truncate",children:s})]})}function Te({x:t,y:a},s,i){const x=window.innerWidth,b=window.innerHeight;return{x:Math.max(8,Math.min(t,x-s-8)),y:Math.max(8,Math.min(a,b-i-8))}}function ze(t){return t.paused?"paused (by you)":t.state==="working"?"working":t.state==="editing"?"editing":t.state==="blocked"?"needs you":t.state==="done"?"done":"idle"}function Fe(t){return t.length<=24?t:t.slice(0,22)+"…"}function ie(t,a){const s=t.replace("#","");if(s.length!==6)return t;const i=parseInt(s,16);let x=i>>16&255,b=i>>8&255,h=i&255;const c=Math.round(255*(a/100));return x=Math.max(0,Math.min(255,x+c)),b=Math.max(0,Math.min(255,b+c)),h=Math.max(0,Math.min(255,h+c)),"#"+(x<<16|b<<8|h).toString(16).padStart(6,"0")}const Ae=[{cmd:"/slow down",label:"Slow down",hint:"be more careful"},{cmd:"/be thorough",label:"Be thorough",hint:"dig deeper"},{cmd:"/wrap it up",label:"Wrap it up",hint:"finish what you have"},{cmd:"/pause",label:"Pause",hint:"pause the team"}];function Ee(t){try{const a=localStorage.getItem(le(t));return a?JSON.parse(a):{}}catch{return{}}}function Pe(t,a){try{localStorage.setItem(le(t),JSON.stringify(a))}catch{}}function le(t){return`titan-desk:${t}`}function de(t){return`titan-desk-furniture:${t}`}function Re(t){const a={cabinet:[],trash:[],permanentlyHidden:[],cabinetOpen:!1,trashOpen:!1};try{const s=localStorage.getItem(de(t));if(!s)return a;const i=JSON.parse(s);return{cabinet:Array.isArray(i.cabinet)?i.cabinet:[],trash:Array.isArray(i.trash)?i.trash:[],permanentlyHidden:Array.isArray(i.permanentlyHidden)?i.permanentlyHidden:[],cabinetOpen:!!i.cabinetOpen,trashOpen:!!i.trashOpen}}catch{return a}}function Le(t,a){try{localStorage.setItem(de(t),JSON.stringify(a))}catch{}}function yt(){const{id:t}=me(),a=ye(),[s,i]=o.useState(null),[x,b]=o.useState(!0),[h,c]=o.useState(null),[m,p]=o.useState(""),[y,w]=o.useState(!1),[l,u]=o.useState(!1),[d,j]=o.useState({});o.useEffect(()=>{t&&j(Ee(t))},[t]);const v=o.useCallback(n=>{j(n),t&&Pe(t,n)},[t]),[f,M]=o.useState({cabinet:[],trash:[],permanentlyHidden:[],cabinetOpen:!1,trashOpen:!1});o.useEffect(()=>{t&&M(Re(t))},[t]);const N=o.useCallback(n=>{M(n),t&&Le(t,n)},[t]),[z,E]=o.useState([]);o.useEffect(()=>{ve().then(E).catch(()=>E([]))},[]);const[F,I]=o.useState(null),[B,k]=o.useState(null),$=o.useCallback(async n=>{if(t){k({ref:n,loading:!0});try{const r=await Ne(t,n);k({ref:n,loading:!1,file:r})}catch(r){k({ref:n,loading:!1,error:r.message})}}},[t]);o.useEffect(()=>{if(!t)return;let n=!0;return b(!0),re(t).then(({mission:r})=>{n&&(i(r),b(!1))}).catch(r=>{n&&(c(r.message),b(!1))}),()=>{n=!1}},[t]),o.useEffect(()=>t?Se(t,r=>{if(r.kind==="mission_deleted"){a("/mission");return}r.kind!=="hello"&&re(t).then(({mission:g})=>i(g)).catch(()=>{})}):void 0,[t,a]);const R=o.useCallback(async n=>{if(!(!s||!n.trim()||y)){w(!0);try{await J(s.id,n.trim()),p("")}catch(r){c(r.message)}finally{w(!1)}}},[s,y]),Z=o.useCallback(async(n,r)=>{if(s)try{await Ce(s.id,n,r)}catch(g){c(g.message)}},[s]),xe=o.useCallback(async()=>{if(!s)return;const n=s.status==="paused"?"working":"paused";try{await Me(s.id,n)}catch(r){c(r.message)}},[s]),ue=o.useCallback(async()=>{if(!(!s||!window.confirm(`Delete this mission?
2
-
3
- "${s.goal.slice(0,120)}${s.goal.length>120?"…":""}"
4
-
5
- The file is renamed on disk (recoverable manually), but the mission disappears from the UI immediately.`)))try{await $e(s.id),a("/mission")}catch(r){c(r.message)}},[s,a]),Y=o.useMemo(()=>s?[...s.messages].reverse().find(r=>r.kind==="question"&&!r.answer):void 0,[s]),G=o.useMemo(()=>{if(!s)return[];const n=new Map;for(const r of s.messages)if(!(r.kind!=="agent"||!Array.isArray(r.sources)))for(const g of r.sources)(g.type==="file"||g.type==="report")&&n.set(g.ref,{ref:g.ref,description:g.description,type:g.type});return Array.from(n.values())},[s]),W=o.useMemo(()=>{if(!s)return[];const n=[];for(const r of s.team){const g=r.activityLog??[];for(const C of g)n.push({id:`${r.agentId}:${C.at}:${C.icon}`,agentId:r.agentId,agentName:r.name,agentColor:r.color,icon:C.icon,activity:C.activity,detail:C.detail,at:C.at})}return n.sort((r,g)=>r.at<g.at?1:-1),n.slice(0,12)},[s]),X=o.useMemo(()=>{if(!s)return[];const n=new Map;for(const r of s.messages)if(!(r.kind!=="agent"||!Array.isArray(r.sources)))for(const g of r.sources)g.type==="fact"&&n.set(g.ref,{ref:g.ref,description:g.description});return Array.from(n.values()).slice(0,8)},[s]),D=o.useMemo(()=>{if(!s)return[];const n=[];n.push({id:"goal",kind:"goal"}),n.push({id:"document",kind:"document"}),n.push({id:"cost",kind:"cost"}),n.push({id:"clock",kind:"clock"}),n.push({id:"cabinet",kind:"cabinet"}),n.push({id:"trash",kind:"trash"});for(const r of s.team)n.push({id:`agent:${r.agentId}`,kind:"agent",ref:r.agentId});for(const r of G)n.push({id:`file:${r.ref}`,kind:"file",ref:r.ref});for(const r of X)n.push({id:`fact:${r.ref}`,kind:"fact",ref:r.ref});for(const r of W)n.push({id:r.id,kind:"activity",ref:r.id});return Y&&n.push({id:`q:${Y.approvalId}`,kind:"question",ref:Y.approvalId}),n},[s,G,X,W,Y]),V=o.useCallback(n=>f.cabinet.includes(n)||f.trash.includes(n)||f.permanentlyHidden.includes(n),[f]),fe=o.useCallback((n,r)=>r==="cabinet"?(N({...f,cabinet:[...new Set([...f.cabinet,n])],trash:f.trash.filter(g=>g!==n)}),!0):r==="trash"?(N({...f,trash:[...new Set([...f.trash,n])],cabinet:f.cabinet.filter(g=>g!==n)}),!0):!1,[f,N]),Q=o.useCallback(n=>{N({...f,cabinet:f.cabinet.filter(r=>r!==n),trash:f.trash.filter(r=>r!==n)})},[f,N]),ee=o.useCallback(()=>{N({...f,cabinetOpen:!f.cabinetOpen})},[f,N]),te=o.useCallback(()=>{N({...f,trashOpen:!f.trashOpen})},[f,N]),pe=o.useCallback(n=>{N({...f,trash:f.trash.filter(r=>r!==n),permanentlyHidden:[...new Set([...f.permanentlyHidden,n])]})},[f,N]),L=o.useCallback((n,r)=>{const g=typeof window>"u"?1400:window.innerWidth,C=typeof window>"u"?800:window.innerHeight,O=g/2,_=C/2;if(n.kind==="goal")return{x:O-220,y:90,z:5,rotation:-1.2};if(n.kind==="document")return{x:O-240,y:_-220,z:4,rotation:.4};if(n.kind==="cost")return{x:g-130,y:90,z:6,rotation:2};if(n.kind==="clock")return{x:g-280,y:C-240,z:7,rotation:-1.5};if(n.kind==="cabinet")return{x:30,y:C-280,z:3,rotation:0};if(n.kind==="trash")return{x:g-130,y:C-220,z:3,rotation:0};if(n.kind==="question")return{x:O+120,y:200,z:30,rotation:-3};if(n.kind==="agent"){const S=r.filter(T=>T.kind==="agent").findIndex(T=>T.id===n.id),A=S%2,P=Math.floor(S/2);return{x:g-280+A*20,y:200+P*180+A*30,z:10+S,rotation:(S%2===0?-1:1)*(1.5+S*.5)}}if(n.kind==="file"){const S=r.filter(T=>T.kind==="file").findIndex(T=>T.id===n.id),A=S%2,P=Math.floor(S/2);return{x:60+A*30,y:180+P*180+A*25,z:8+S,rotation:(S%2===0?1:-1)*(2+S*.3)}}if(n.kind==="fact"){const S=r.filter(T=>T.kind==="fact").findIndex(T=>T.id===n.id),A=S%3,P=Math.floor(S/3);return{x:O-160+A*100+(P%2===0?0:25),y:C-280+P*80,z:12+S,rotation:(S%2===0?-1:1)*(4+S*.7)}}if(n.kind==="activity"){const S=r.filter(q=>q.kind==="activity").findIndex(q=>q.id===n.id),A=Math.max(4,Math.floor((g-120)/180)),P=S%A,T=Math.floor(S/A);return{x:40+P*180+(T%2===0?0:40),y:C-200-T*110,z:14+S,rotation:(S%2===0?-1:1)*(2+S*.3)}}return{x:100,y:100,z:1,rotation:0}},[]),ae=o.useCallback(n=>d[n.id]??L(n,D),[d,D,L]),K=o.useCallback((n,r)=>{const g={...d,[n]:r};v(g)},[d,v]),ge=o.useCallback(n=>{const r=Math.max(0,...D.map(C=>(d[C.id]??L(C,D)).z)),g=d[n]??L(D.find(C=>C.id===n),D);g.z>=r||K(n,{...g,z:r+1})},[D,d,L,K]),he=o.useCallback(()=>{t&&v({})},[t,v]),be=o.useCallback((n,r,g)=>{N({...f,cabinet:f.cabinet.filter(S=>S!==n),trash:f.trash.filter(S=>S!==n)});const C=Math.max(0,...D.map(S=>(d[S.id]??L(S,D)).z)),O=d[n],_=(O==null?void 0:O.rotation)??Math.random()*6-3;K(n,{x:r-80,y:g-20,z:C+1,rotation:_})},[f,N,D,d,L,K]);if(x)return e.jsx("div",{className:"fixed inset-0 flex items-center justify-center bg-[#3a2a1c] text-[#f3e9d0] text-sm",children:"Setting the desk…"});if(h||!s)return e.jsxs("div",{className:"fixed inset-0 flex items-center justify-center bg-[#3a2a1c] flex-col gap-3",children:[e.jsx("div",{className:"text-[#ffb4a2] text-sm",children:h??"Mission not found."}),e.jsx("button",{onClick:()=>a("/mission"),className:"text-[#f3e9d0] text-sm hover:underline",children:"← Start a new mission"})]});const{working:ne,blocked:se}=ce(s);return e.jsxs("div",{className:"fixed inset-0 overflow-hidden font-sans text-[#f3e9d0]",style:nt,children:[e.jsx("div",{className:"pointer-events-none absolute inset-0",style:st}),e.jsx("div",{className:"pointer-events-none absolute inset-0",style:rt}),e.jsxs("header",{className:"relative z-30 flex items-center justify-between px-5 py-3.5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:()=>a("/mission"),className:"text-[#e7d6a8] hover:text-white text-sm",title:"New mission",children:"←"}),e.jsx("button",{onClick:()=>a("/mission/library"),className:"text-[10px] uppercase tracking-widest text-[#d9c08c] hover:text-white border border-[#8a6a3a]/60 rounded-full px-2 py-0.5",title:"Browse past missions",children:"Library"}),e.jsx("button",{onClick:()=>a("/space/home"),className:"text-[10px] uppercase tracking-widest text-[#d9c08c] hover:text-white border border-[#8a6a3a]/60 rounded-full px-2 py-0.5 inline-flex items-center gap-1",title:"Back to the canvas spaces",children:"🌌 Canvas"}),e.jsxs("div",{className:"font-semibold tracking-tight text-[#f3e9d0]",children:[e.jsx("span",{style:{background:"linear-gradient(90deg,#f3d27a,#d8a85a)",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent"},children:"TITAN"}),e.jsx("span",{className:"text-[#d9c08c] font-normal",children:"  ›  "}),e.jsx("span",{className:"text-[#e7d6a8] font-normal",children:"Desk"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"inline-flex items-center gap-2 px-3 py-1.5 bg-[#2a1d11]/70 border border-[#8a6a3a]/60 rounded-full text-xs",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${se>0?"bg-error animate-pulse":ne>0?"bg-accent animate-pulse":"bg-success"}`}),e.jsx("span",{className:"text-[#e7d6a8]",children:dt(s.status,ne,se)})]}),s.longRunningMode&&e.jsx("div",{className:"inline-flex items-center gap-2 px-3 py-1.5 rounded-full text-xs font-semibold",style:{background:"linear-gradient(90deg, rgba(245,210,122,0.18), rgba(176,138,58,0.18))",border:"1px solid #b08a3a",color:"#ffd86e"},title:"Marathon mode — long-running multi-agent collaboration (72h cap)",children:"🏃 Marathon"}),e.jsx("button",{onClick:he,className:"px-3 py-1.5 text-xs bg-[#2a1d11]/70 border border-[#8a6a3a]/60 rounded-full text-[#e7d6a8] hover:text-white",title:"Reset every item to a sensible starting position",children:"Tidy up"}),e.jsx("button",{onClick:()=>a(`/mission/${s.id}`),className:"px-3 py-1.5 text-xs bg-[#2a1d11]/70 border border-[#8a6a3a]/60 rounded-full text-[#e7d6a8] hover:text-white",title:"Switch to the chat thread view",children:"Chat view"}),e.jsx("button",{onClick:xe,className:"px-3 py-1.5 text-xs bg-[#2a1d11]/70 border border-[#8a6a3a]/60 rounded-full text-[#e7d6a8] hover:text-white",children:s.status==="paused"?"Resume":"Pause"}),e.jsx("button",{onClick:ue,className:"px-3 py-1.5 text-xs bg-[#2a1d11]/70 border border-[#8a6a3a]/60 rounded-full text-[#d9c08c] hover:text-[#ff9c9c] hover:border-[#ff9c9c]/50 transition-colors",title:"Delete this mission",children:"🗑 Delete"}),e.jsx("button",{onClick:()=>u(n=>!n),className:"w-8 h-8 rounded-full bg-[#2a1d11]/70 border border-[#8a6a3a]/60 text-[#e7d6a8] hover:text-white font-semibold text-sm flex items-center justify-center",title:"What's this?",children:"?"})]})]}),e.jsx(ot,{items:D,room:s,poseOf:ae,isHidden:V}),e.jsx("div",{className:"absolute inset-0 z-10 pointer-events-none",children:D.map(n=>{if(V(n.id))return null;const r=ae(n),g=n.kind==="agent",C=n.kind==="file"||n.kind==="fact"||n.kind==="activity";return e.jsx(Be,{pose:r,onGrab:()=>ge(n.id),onPose:O=>K(n.id,O),onClick:g?(O,_)=>I({agentId:n.ref,anchor:{x:O,y:_}}):void 0,onDrop:C?O=>fe(n.id,O):void 0,children:e.jsx(He,{item:n,room:s,openQuestion:Y,fileSources:G,factSources:X,activityStickies:W,furniture:f,onOpenCabinet:ee,onOpenTrash:te,onOpenFile:$,onAnswer:Z})},n.id)})}),f.cabinetOpen&&e.jsx(tt,{itemIds:f.cabinet,items:D,fileSources:G,factSources:X,activityStickies:W,onRestore:Q,onRestoreAt:be,onOpenFile:$,onClose:ee}),f.trashOpen&&e.jsx(at,{itemIds:f.trash,items:D,fileSources:G,factSources:X,activityStickies:W,onRestore:Q,onDeleteForever:pe,onClose:te}),F&&(()=>{const n=s.team.find(g=>g.agentId===F.agentId);if(!n)return null;const r=z.map(g=>({id:g.id,label:g.name,provider:g.provider}));return e.jsx(Oe,{member:n,room:s,anchor:F.anchor,availableModels:r,onClose:()=>I(null)})})(),e.jsxs("footer",{className:"absolute left-0 right-0 bottom-0 z-30 px-5 pb-5 pt-3 flex flex-col gap-2 bg-gradient-to-t from-[#1d130a]/95 to-transparent",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 max-w-5xl mx-auto w-full",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-widest text-[#d9c08c]",children:"quick steer"}),Ae.map(n=>e.jsx("button",{onClick:()=>R(n.cmd),disabled:y,title:n.hint,className:"px-2.5 py-1 text-[11px] text-[#e7d6a8] bg-[#2a1d11]/70 border border-[#8a6a3a]/60 rounded-full hover:text-white disabled:opacity-50",children:n.label},n.cmd))]}),e.jsx("div",{className:"flex items-center gap-3 max-w-5xl mx-auto w-full",children:e.jsxs("form",{onSubmit:n=>{n.preventDefault(),R(m)},className:"flex-1 h-11 flex items-center gap-2.5 px-3.5 bg-[#2a1d11]/80 border border-[#8a6a3a]/60 rounded-full",children:[e.jsx("input",{value:m,onChange:n=>p(n.target.value),placeholder:'Tell the team — "Add a one-line risk note at the top"',className:"flex-1 bg-transparent outline-none text-sm text-[#f3e9d0] placeholder:text-[#d9c08c]/50"}),e.jsx("span",{className:"px-2 py-1 text-[10px] uppercase tracking-widest text-[#d9c08c] border border-[#8a6a3a]/60 rounded",children:"↵"})]})})]}),B&&e.jsx(De,{state:B,onClose:()=>k(null)}),l&&e.jsxs("div",{className:"fixed top-16 right-5 w-80 bg-[#2a1d11]/95 border border-[#8a6a3a]/60 rounded-xl p-4 backdrop-blur-xl shadow-2xl z-40",children:[e.jsx("button",{onClick:()=>u(!1),className:"absolute top-3 right-3 text-[#d9c08c] hover:text-white text-sm",children:"✕"}),e.jsx("h3",{className:"font-semibold text-sm mb-2 text-[#f3e9d0]",children:"The desk"}),e.jsxs("p",{className:"text-xs text-[#e7d6a8] leading-relaxed mb-3",children:["Everything the team produces lands on this desk as a physical object. Drag anything anywhere. ",e.jsx("b",{children:"Tidy up"})," resets the layout if it gets cluttered."]}),e.jsxs("ul",{className:"space-y-2 text-xs text-[#e7d6a8]",children:[e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{children:"📜"}),e.jsxs("span",{children:[e.jsx("b",{className:"text-white",children:"Leather placard"})," — your mission goal."]})]}),e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{children:"📄"}),e.jsxs("span",{children:[e.jsx("b",{className:"text-white",children:"Paper sheets"})," — files the team wrote. Double-click to open."]})]}),e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{children:"👤"}),e.jsxs("span",{children:[e.jsx("b",{className:"text-white",children:"Index cards"})," — each AI helper, showing what they're doing now."]})]}),e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{children:"💡"}),e.jsxs("span",{children:[e.jsx("b",{className:"text-white",children:"Sticky notes"})," — facts the team picked up while working."]})]}),e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{children:"📕"}),e.jsxs("span",{children:[e.jsx("b",{className:"text-white",children:"Pink card"})," — a question waiting on you."]})]})]})]}),e.jsx("style",{children:it})]})}function Be({pose:t,onGrab:a,onPose:s,onClick:i,onDrop:x,children:b}){const[h,c]=o.useState(null),m=h?{x:h.x,y:h.y}:{x:t.x,y:t.y},p=o.useCallback(y=>{if(y.target.closest("[data-no-drag]"))return;y.preventDefault(),a();const l=y.clientX,u=y.clientY,d=t.x,j=t.y;c({dx:0,dy:0,x:d,y:j});const v=M=>{const N=M.clientX-l,z=M.clientY-u;c({dx:N,dy:z,x:d+N,y:j+z})},f=M=>{const N=M.clientX-l,z=M.clientY-u;window.removeEventListener("mousemove",v),window.removeEventListener("mouseup",f);const E=d+N,F=j+z;if(c(null),!(Math.abs(N)>4||Math.abs(z)>4)){i&&i(M.clientX,M.clientY);return}if(x){const B=document.elementsFromPoint(M.clientX,M.clientY);for(const k of B){const $=k.closest("[data-drop-target]");if(!$||$.contains(y.currentTarget))continue;const R=$.getAttribute("data-drop-target");if(R){if(x(R)!==!1)return;break}}}s({...t,x:E,y:F})};window.addEventListener("mousemove",v),window.addEventListener("mouseup",f)},[t,a,s,i,x]);return e.jsx("div",{onMouseDown:p,className:"absolute select-none pointer-events-auto cursor-grab active:cursor-grabbing",style:{left:m.x,top:m.y,zIndex:h?999:t.z,transform:`rotate(${t.rotation}deg) ${h?"scale(1.03)":""}`,transition:h?"transform 80ms ease-out":"transform 200ms ease-out",filter:h?"drop-shadow(0 22px 32px rgba(0,0,0,0.55))":"drop-shadow(0 6px 14px rgba(0,0,0,0.42))",willChange:h?"left, top":void 0},children:b})}function He({item:t,room:a,openQuestion:s,fileSources:i,factSources:x,activityStickies:b,furniture:h,onOpenCabinet:c,onOpenTrash:m,onOpenFile:p,onAnswer:y}){if(t.kind==="goal")return e.jsx(Ie,{goal:a.goal,status:a.status});if(t.kind==="document")return e.jsx(Ye,{room:a});if(t.kind==="cost")return e.jsx(Ge,{room:a});if(t.kind==="clock")return e.jsx(We,{room:a});if(t.kind==="cabinet")return e.jsx(Qe,{count:h.cabinet.length,onOpen:c});if(t.kind==="trash")return e.jsx(et,{count:h.trash.length,onOpen:m});if(t.kind==="agent"){const w=a.team.find(l=>l.agentId===t.ref);return w?e.jsx(Ke,{member:w}):null}if(t.kind==="file"){const w=i.find(l=>l.ref===t.ref);return w?e.jsx(qe,{file:w,onOpen:()=>p(w.ref)}):null}if(t.kind==="fact"){const w=x.find(l=>l.ref===t.ref);return w?e.jsx(Ue,{fact:w}):null}if(t.kind==="activity"){const w=b.find(l=>l.id===t.ref);return w?e.jsx(Je,{sticky:w}):null}return t.kind==="question"&&s?e.jsx(Ve,{msg:s,onAnswer:w=>y(s.approvalId,w)}):null}function Ie({goal:t,status:a}){const s={forming:{text:"forming the team…",dotColor:"#c4a14a",dotGlow:"#c4a14a"},working:{text:"in progress — TITAN",dotColor:"#8ed1ff",dotGlow:"#8ed1ff"},paused:{text:"paused — your call",dotColor:"#d9c08c",dotGlow:"#d9c08c"},blocked:{text:"needs your input",dotColor:"#ff9c9c",dotGlow:"#ff9c9c"},done:{text:"complete · signed off",dotColor:"#22c55e",dotGlow:"#22c55e"},failed:{text:"stopped — see chat",dotColor:"#ef4444",dotGlow:"#ef4444"}},i=s[a]??s.working;return e.jsxs("div",{className:"w-[420px] px-5 py-3.5 text-[#f3e9d0]",style:{background:"linear-gradient(140deg, #6b2c2a 0%, #4a1816 60%, #3b110f 100%)",border:"1px solid #2a0908",borderRadius:10,boxShadow:"inset 0 0 24px rgba(0,0,0,0.5), 0 0 0 4px rgba(0,0,0,0.08)",backgroundBlendMode:"multiply"},children:[e.jsx("div",{className:"text-[10px] uppercase tracking-[0.22em] text-[#d9c08c] mb-1",children:"Your mission"}),e.jsx("div",{className:"text-[15px] leading-snug font-semibold tracking-tight",children:t}),e.jsxs("div",{className:"mt-2 flex items-center gap-2 text-[10px] uppercase tracking-widest text-[#d9c08c]/70",children:[e.jsx("span",{className:`inline-block w-2 h-2 rounded-full ${a==="working"||a==="blocked"||a==="forming"?"animate-pulse":""}`,style:{background:i.dotColor,boxShadow:`0 0 6px ${i.dotGlow}`}}),e.jsx("span",{children:i.text})]})]})}function Ye({room:t}){var m;const a=((m=t.artifact)==null?void 0:m.content)??"",s=o.useRef(a.length),[i,x]=o.useState(!1);o.useEffect(()=>{if(a.length>s.current){x(!0);const p=setTimeout(()=>x(!1),2e3);return s.current=a.length,()=>clearTimeout(p)}s.current=a.length},[a]);const b=o.useMemo(()=>a.split(`
6
- `).filter(y=>y.trim().length>0).slice(0,10),[a]),h=a.trim().split(/\s+/).filter(Boolean).length,c=t.team.some(p=>p.state==="working"||p.state==="editing");return e.jsxs("div",{className:"w-[460px] max-w-[88vw] bg-[#f7f5ee] text-[#1a1f2e] rounded-md p-7 pt-6 relative",style:{fontFamily:'"Iowan Old Style", "Charter", "Georgia", serif',backgroundImage:"repeating-linear-gradient(180deg, transparent 0 26px, #d8d3c2 26px 27px)",backgroundPosition:"0 48px"},children:[e.jsx("h1",{className:"text-[20px] font-semibold tracking-tight leading-tight mb-1",children:xt(t.goal,70)}),e.jsxs("div",{className:"text-[11px] uppercase tracking-widest text-[#8a8472] mb-4 flex items-center gap-2",children:[e.jsxs("span",{children:["Draft · ",h," words · ",ct(t.status)]}),i&&c&&e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#c4a35a] animate-pulse"}),e.jsx("span",{className:"text-[10px] italic",children:"Writing…"})]})]}),b.length>0?e.jsx("div",{className:"text-[13px] leading-[1.55] space-y-3",children:b.map((p,y)=>e.jsxs("p",{children:[p,i&&c&&y===b.length-1&&e.jsx("span",{className:"inline-block w-0.5 h-3.5 bg-[#c4a35a] ml-0.5 align-middle animate-pulse"})]},y))}):e.jsx("div",{className:"text-[12px] italic text-[#8a8472] py-6 text-center",children:"The team is just getting started — your document fills in as they work."})]})}function Ge({room:t}){return e.jsxs("div",{className:"w-[110px] h-[110px] rounded-full flex flex-col items-center justify-center text-[#f3e9d0]",style:{background:"radial-gradient(circle at 35% 30%, #2b1a14 0%, #1a0e08 70%)",boxShadow:"inset 0 0 18px rgba(0,0,0,0.6), 0 0 0 5px #6e4a26, 0 0 0 6px #382213"},title:"Tokens + dollars spent this mission",children:[e.jsx("span",{className:"text-[9px] uppercase tracking-widest text-[#d9c08c]",children:"spent"}),e.jsxs("span",{className:"text-[20px] font-bold tabular-nums",children:["$",t.cost.usd.toFixed(2)]}),e.jsxs("span",{className:"text-[9px] text-[#d9c08c]/80 tabular-nums",children:[(t.cost.tokens/1e3).toFixed(1),"k tok"]})]})}function We({room:t}){const[a,s]=o.useState(()=>new Date);o.useEffect(()=>{const u=setInterval(()=>s(new Date),1e3);return()=>clearInterval(u)},[]);const i=String(a.getHours()).padStart(2,"0"),x=String(a.getMinutes()).padStart(2,"0"),b=String(a.getSeconds()).padStart(2,"0"),h=o.useMemo(()=>{try{const u=new Intl.DateTimeFormat(void 0,{timeZoneName:"short"}).formatToParts(new Date).find(d=>d.type==="timeZoneName");return(u==null?void 0:u.value)??""}catch{return""}},[]),c=o.useMemo(()=>new Date(t.createdAt).getTime(),[t.createdAt]),m=t.status==="paused"||t.status==="done"||t.status==="failed",p=m?Math.max(0,new Date(t.updatedAt).getTime()-c):Math.max(0,a.getTime()-c),y=Xe(p),{working:w,blocked:l}=ce(t);return e.jsxs("div",{className:"w-[260px] p-4 pb-3 text-[#f5d27a]",style:{background:"radial-gradient(ellipse at 30% 25%, #4a2e18 0%, #2a1808 75%, #1a0e04 100%)",borderRadius:14,boxShadow:"0 0 0 3px #b08a3a, 0 0 0 5px #5a3a14, 0 12px 22px rgba(0,0,0,0.5), inset 0 0 16px rgba(0,0,0,0.6)"},children:[e.jsxs("div",{className:"text-[9px] uppercase tracking-[0.28em] text-[#c4a14a] text-center mb-1.5",children:["TITAN",h?" · "+h:""]}),e.jsxs("div",{className:"flex items-baseline justify-center gap-1 mb-1",style:{fontFamily:'"DSEG7 Classic", "Orbitron", "Menlo", monospace',textShadow:"0 0 10px rgba(245,210,122,0.65), 0 0 22px rgba(245,210,122,0.35)"},children:[e.jsx(oe,{value:i}),e.jsx("span",{className:"text-[28px] font-bold opacity-80 -translate-y-0.5 animate-pulse",children:":"}),e.jsx(oe,{value:x}),e.jsx("span",{className:"text-[20px] font-bold opacity-60 -translate-y-0.5",children:":"}),e.jsx("span",{className:"text-[24px] font-bold opacity-80 tabular-nums",children:b})]}),e.jsxs("div",{className:"text-center text-[10px] uppercase tracking-[0.22em] text-[#c4a14a]/85 mb-1.5",style:{fontFamily:"system-ui"},children:["Mission · ",y.hh,":",y.mm,":",y.ss,m&&e.jsxs("span",{className:"ml-1.5 text-[#d9c08c]/70",children:["· ",t.status]})]}),e.jsxs("div",{className:"flex items-center justify-center gap-3 pt-2 border-t border-[#5a3a14]/60",style:{fontFamily:"system-ui"},children:[e.jsx(U,{n:w,label:"working",tone:"accent"}),e.jsx(U,{n:l,label:l===1?"needs you":"need you",tone:"warn"}),e.jsx(U,{n:t.team.length,label:"on team",tone:"muted"})]})]})}function oe({value:t}){return e.jsx("span",{className:"text-[34px] font-bold tabular-nums leading-none",children:t})}function U({n:t,label:a,tone:s}){const i=s==="accent"?"#8ed1ff":s==="warn"?"#ff9c9c":"#c4a14a";return e.jsxs("div",{className:"flex flex-col items-center leading-tight",children:[e.jsx("span",{className:"text-[18px] font-bold tabular-nums",style:{color:i},children:t}),e.jsx("span",{className:"text-[9px] uppercase tracking-widest text-[#c4a14a]/80",children:a})]})}function Xe(t){const a=Math.floor(t/1e3),s=String(Math.floor(a/3600)).padStart(2,"0"),i=String(Math.floor(a%3600/60)).padStart(2,"0"),x=String(a%60).padStart(2,"0");return{hh:s,mm:i,ss:x}}function Ke({member:t}){const a=t.state==="blocked",s=t.state==="working"||t.state==="editing",i=_e(t.color,a),x=s?`${t.agentId.charCodeAt(0)%10*.34}s`:"0s";return e.jsxs("div",{className:"w-[220px] p-3.5 pt-5 text-[#2a2418] relative",style:{background:i,boxShadow:"0 1px 0 rgba(255,255,255,0.55) inset, 0 12px 18px rgba(0,0,0,0.42)",fontFamily:'"Bradley Hand", "Marker Felt", "Comic Sans MS", cursive',animation:s?"stickyBreathe 3.4s ease-in-out infinite":"none",animationDelay:x},children:[e.jsx("div",{className:"absolute -top-1.5 left-1/2 -translate-x-1/2 w-20 h-4 opacity-70 pointer-events-none",style:{background:"linear-gradient(180deg, rgba(255,255,255,0.75), rgba(255,255,255,0.25))",boxShadow:"0 1px 2px rgba(0,0,0,0.15)"}}),e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsx("div",{className:"w-7 h-7 rounded-md flex items-center justify-center text-white font-bold text-[13px]",style:{background:`linear-gradient(135deg, ${t.color}, ${gt(t.color,-25)})`,boxShadow:`0 2px 6px ${t.color}55`,fontFamily:"system-ui"},children:t.name[0]}),e.jsxs("div",{className:"leading-tight",children:[e.jsx("div",{className:"font-semibold text-[15px] text-[#2a2418]",children:t.name}),e.jsx("div",{className:"text-[10px] uppercase tracking-widest text-[#6b5a3a]",style:{fontFamily:"system-ui"},children:t.role})]}),e.jsxs("div",{className:"ml-auto flex items-center gap-1 text-[10px] text-[#6b5a3a]",style:{fontFamily:"system-ui"},children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${ut(t.state)}`,style:{boxShadow:`0 0 6px ${ft(t.state)}`}}),e.jsx("span",{children:pt(t.state)})]})]}),e.jsx("div",{className:"text-[14px] text-[#2a2418] leading-snug min-h-[2.4rem] break-words",children:t.currentActivity??e.jsx("span",{className:"italic text-[#6b5a3a]",children:"standing by"})}),(s||a)&&e.jsx("div",{className:"absolute -inset-1 -z-10 pointer-events-none rounded-[2px] blur-md",style:{background:a?"radial-gradient(circle at 50% 50%, rgba(239,68,68,0.6), transparent 70%)":`radial-gradient(circle at 30% 30%, ${t.color}55, transparent 70%)`,animation:a?"deskAlarm 1.8s ease-in-out infinite":"deskGlow 4.2s ease-in-out infinite"}})]})}function _e(t,a){if(a)return"linear-gradient(165deg, #ffd6d6 0%, #ffbaba 100%), linear-gradient(45deg, transparent 49%, rgba(0,0,0,0.04) 49% 51%, transparent 51%)";const s=t.toLowerCase();return s.includes("6366f1")||s.includes("8b5cf6")?"linear-gradient(160deg, #e7e1ff 0%, #cfc4ff 100%)":s.includes("22c55e")||s.includes("10b981")?"linear-gradient(160deg, #d9f7d9 0%, #b8edb8 100%)":s.includes("f59e0b")||s.includes("eab308")?"linear-gradient(160deg, #fff2a8 0%, #ffe88a 100%)":s.includes("ef4444")||s.includes("f97316")?"linear-gradient(160deg, #ffd6c2 0%, #ffbf9e 100%)":s.includes("06b6d4")||s.includes("0ea5e9")?"linear-gradient(160deg, #cef3f7 0%, #a8e4ec 100%)":"linear-gradient(160deg, #fff2a8 0%, #ffe88a 100%)"}function qe({file:t,onOpen:a}){const s=o.useMemo(()=>{const i=t.ref.lastIndexOf("/");return i>=0?t.ref.slice(i+1):t.ref},[t.ref]);return e.jsxs("div",{onDoubleClick:a,title:"Double-click to open",className:"w-[200px] p-3 text-[#1a1f2e]",style:{background:"linear-gradient(170deg, #fdfbf3 0%, #f1eada 100%)",borderRadius:4,boxShadow:"0 1px 0 rgba(255,255,255,0.6) inset, 0 0 0 1px rgba(0,0,0,0.06)"},children:[e.jsx("div",{className:"absolute top-0 right-0 w-4 h-4",style:{background:"linear-gradient(225deg, #d8cdb3 0%, #f1eada 50%, transparent 50%)",borderBottomLeftRadius:4}}),e.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[e.jsx("span",{className:"text-base leading-none",children:t.type==="report"?"📊":"📄"}),e.jsx("span",{className:"text-[9px] uppercase tracking-widest text-[#8a8472]",children:t.type})]}),e.jsx("div",{className:"font-semibold text-[12px] leading-tight break-words text-[#1a1f2e]",children:s}),t.description&&e.jsx("div",{className:"text-[10px] text-[#5a5240] mt-1 leading-snug line-clamp-2",children:t.description}),e.jsx("button",{"data-no-drag":!0,onClick:a,className:"mt-2 w-full px-2 py-1 text-[10px] font-semibold uppercase tracking-widest bg-[#1a1f2e] text-[#f3e9d0] rounded hover:bg-[#3a3525]",children:"Open ↗"})]})}function Ue({fact:t}){const a=t.description??t.ref;return e.jsxs("div",{className:"w-[160px] p-3 text-[#3a2e10]",style:{background:"linear-gradient(160deg, #fff2a8 0%, #ffe88a 100%)",boxShadow:"0 1px 0 rgba(255,255,255,0.5) inset, 0 8px 14px rgba(0,0,0,0.35)",fontFamily:'"Bradley Hand", "Comic Sans MS", cursive'},children:[e.jsx("div",{className:"absolute -top-2 left-1/2 -translate-x-1/2 w-12 h-3.5 opacity-60",style:{background:"linear-gradient(180deg, rgba(255,255,255,0.65), rgba(255,255,255,0.25))"}}),e.jsx("div",{className:"text-[12px] leading-snug",children:a})]})}function Je({sticky:t}){const a=Ze(t.agentColor);return e.jsxs("div",{className:"w-[170px] p-2.5 text-[#2a2418] relative",title:`${t.agentName} ${t.activity}${t.detail?": "+t.detail:""} · ${new Date(t.at).toLocaleTimeString()}`,style:{background:a,boxShadow:"0 1px 0 rgba(255,255,255,0.55) inset, 0 6px 10px rgba(0,0,0,0.32)",fontFamily:'"Bradley Hand", "Marker Felt", "Comic Sans MS", cursive'},children:[e.jsx("div",{className:"absolute -top-1.5 left-1/2 -translate-x-1/2 w-10 h-3 opacity-60 pointer-events-none",style:{background:"linear-gradient(180deg, rgba(255,255,255,0.7), rgba(255,255,255,0.25))"}}),e.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[e.jsx("span",{className:"text-base leading-none",children:t.icon}),e.jsx("span",{className:"text-[10px] uppercase tracking-widest text-[#6b5a3a] truncate",style:{fontFamily:"system-ui"},children:t.agentName})]}),e.jsx("div",{className:"text-[12px] leading-snug",children:t.activity}),t.detail&&e.jsx("div",{className:"text-[11px] text-[#5a4818] mt-1 leading-snug break-words line-clamp-3",children:t.detail})]})}function Ze(t){const a=t.toLowerCase();return a.includes("6366f1")||a.includes("8b5cf6")?"linear-gradient(160deg, #efeaff 0%, #e0d5ff 100%)":a.includes("22c55e")||a.includes("10b981")||a.includes("4adbb5")?"linear-gradient(160deg, #e7faea 0%, #cef0d4 100%)":a.includes("f59e0b")||a.includes("eab308")||a.includes("ff9a4a")?"linear-gradient(160deg, #fff8c8 0%, #ffefa3 100%)":a.includes("ef4444")||a.includes("f97316")||a.includes("ff5d6c")?"linear-gradient(160deg, #ffe2d4 0%, #ffcfba 100%)":a.includes("06b6d4")||a.includes("0ea5e9")||a.includes("6ea8ff")?"linear-gradient(160deg, #e0f5fa 0%, #c5e9f1 100%)":"linear-gradient(160deg, #fff8c8 0%, #ffefa3 100%)"}function Ve({msg:t,onAnswer:a}){const[s,i]=o.useState(!1),[x,b]=o.useState(""),h=o.useRef(null);return o.useEffect(()=>{s&&h.current&&h.current.focus()},[s]),e.jsxs("div",{className:"w-[280px] p-3.5 rounded-xl text-[#5c1820]",style:{background:"linear-gradient(180deg, #ffe9eb, #ffd0d4)",boxShadow:"0 8px 28px rgba(255,93,108,0.4), 0 0 0 1px rgba(160,41,56,0.18)",animation:"deskFloat 4s ease-in-out infinite"},children:[e.jsx("div",{className:"absolute -top-2 -right-2 w-5 h-5 rounded-full",style:{background:"radial-gradient(circle at 35% 30%, #ffd86e 0%, #b07a1a 70%, #6a4710 100%)",boxShadow:"0 2px 4px rgba(0,0,0,0.5)"}}),e.jsxs("div",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 mb-2 bg-[#5c1820] text-[#ffd0d4] text-[10px] uppercase tracking-widest font-bold rounded-full",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-white animate-pulse"}),t.from.name," asks"]}),e.jsx("div",{className:"text-[13px] leading-snug",children:t.content}),s?e.jsxs("div",{className:"mt-3",children:[e.jsx("textarea",{ref:h,"data-no-drag":!0,value:x,onChange:c=>b(c.target.value),onKeyDown:c=>{if(c.key==="Enter"&&(c.metaKey||c.ctrlKey)){c.preventDefault();const m=x.trim();m&&a(m)}else c.key==="Escape"&&i(!1)},rows:2,placeholder:"Your answer…",className:"w-full bg-white/90 border border-[rgba(160,41,56,0.25)] rounded-lg p-2 text-[12px] text-[#5c1820] outline-none"}),e.jsxs("div",{className:"flex items-center justify-end gap-2 mt-1",children:[e.jsx("button",{"data-no-drag":!0,onClick:()=>i(!1),className:"text-[10px] text-[#5c1820]/70 hover:text-[#5c1820]",children:"cancel"}),e.jsx("button",{"data-no-drag":!0,onClick:()=>{const c=x.trim();c&&a(c)},disabled:!x.trim(),className:"px-2 py-0.5 rounded text-[11px] font-semibold bg-[#1a1f2e] text-[#f3e9d0] disabled:opacity-50",children:"Send"})]})]}):e.jsxs("div",{className:"mt-3 flex flex-wrap gap-1.5",children:[t.quickReplies.map((c,m)=>e.jsx("button",{"data-no-drag":!0,onClick:()=>a(c),className:`px-2.5 py-1 rounded-lg text-[11px] font-semibold border ${m===t.quickReplies.length-1?"bg-[#1a1f2e] text-[#f3e9d0] border-transparent":"bg-white border-[rgba(160,41,56,0.25)] text-[#5c1820]"}`,children:c},c)),e.jsx("button",{"data-no-drag":!0,onClick:()=>i(!0),className:"px-2.5 py-1 rounded-lg text-[11px] font-medium underline underline-offset-2 text-[#5c1820]/80 hover:text-[#5c1820]",children:"or type…"})]})]})}function Qe({count:t,onOpen:a}){return e.jsxs("div",{"data-drop-target":"cabinet",className:"w-[140px] flex flex-col text-[#f5d27a]",title:t>0?`${t} filed — click to open`:"Drop files & notes here",children:[e.jsx("button",{"data-no-drag":!0,onClick:a,className:"text-left flex flex-col gap-1 p-0 bg-transparent border-none",children:[0,1].map(s=>e.jsxs("div",{className:"relative w-full h-[58px] flex items-center justify-center",style:{background:"linear-gradient(180deg, #5a3a18 0%, #3a230b 100%), repeating-linear-gradient(90deg, rgba(255,180,90,0.05) 0px, rgba(60,30,10,0.08) 2px)",border:"1px solid #2a1808",boxShadow:"inset 0 -2px 0 rgba(0,0,0,0.45), 0 1px 0 rgba(255,255,255,0.08) inset"},children:[e.jsx("div",{className:"px-3 py-0.5 text-[10px] uppercase tracking-widest text-[#3a2a10] font-bold",style:{background:"linear-gradient(180deg, #ffd86e 0%, #b07a1a 100%)",borderRadius:2,boxShadow:"0 1px 2px rgba(0,0,0,0.4)"},children:s===0?"Files":"Drafts"}),e.jsx("div",{className:"absolute right-3 w-6 h-1.5 rounded",style:{background:"linear-gradient(180deg, #ffd86e 0%, #8a5810 100%)",boxShadow:"0 1px 2px rgba(0,0,0,0.5)"}})]},s))}),t>0&&e.jsxs("div",{className:"mt-1 text-center text-[10px] uppercase tracking-widest text-[#d9c08c]",children:[t," ",t===1?"item":"items"," inside"]})]})}function et({count:t,onOpen:a}){const s=Math.min(t,6);return e.jsxs("button",{type:"button","data-drop-target":"trash","data-no-drag":!0,onClick:a,className:"relative w-[110px] h-[120px] p-0 bg-transparent border-none cursor-pointer",title:t>0?`${t} tossed — click to open the bin`:"Drop notes here to toss them",children:[e.jsx("div",{className:"absolute inset-x-3 top-3 bottom-12 flex flex-wrap gap-1 items-end justify-center overflow-hidden",children:Array.from({length:s}).map((i,x)=>e.jsx("div",{className:"rounded-full",style:{width:18+x*5%14,height:18+x*7%12,background:"radial-gradient(circle at 35% 30%, #fffaee 0%, #d6cdb1 70%, #a99b71 100%)",boxShadow:"inset -2px -2px 4px rgba(0,0,0,0.18), 0 1px 2px rgba(0,0,0,0.3)",transform:`rotate(${x*37%60-30}deg)`}},x))}),e.jsx("div",{className:"absolute left-2 right-2 bottom-0 h-[80px] overflow-hidden",style:{clipPath:"polygon(8% 0%, 92% 0%, 100% 100%, 0% 100%)",background:"repeating-linear-gradient(90deg, #5a3a18 0px, #5a3a18 2px, #3a230b 2px, #3a230b 4px),repeating-linear-gradient(0deg, transparent 0 6px, rgba(0,0,0,0.25) 6px 7px)",border:"1px solid #2a1808",borderRadius:4,boxShadow:"inset 0 4px 8px rgba(0,0,0,0.5)"}}),e.jsx("div",{className:"absolute left-1 right-1 bottom-[78px] h-2.5 rounded-sm",style:{background:"linear-gradient(180deg, #6b4720 0%, #3a230b 100%)",border:"1px solid #1a0f05",boxShadow:"inset 0 1px 0 rgba(255,255,255,0.1)"}}),t>0&&e.jsxs("div",{className:"absolute -bottom-5 left-1/2 -translate-x-1/2 text-[10px] uppercase tracking-widest text-[#d9c08c] whitespace-nowrap",children:[t," tossed"]})]})}function tt({itemIds:t,items:a,fileSources:s,factSources:i,activityStickies:x,onRestore:b,onRestoreAt:h,onOpenFile:c,onClose:m}){const[p,y]=o.useState(null);o.useEffect(()=>{if(!p)return;const l=d=>{y(j=>j?{...j,x:d.clientX,y:d.clientY}:null)},u=d=>{h(p.itemId,d.clientX,d.clientY),y(null)};return window.addEventListener("mousemove",l),window.addEventListener("mouseup",u),()=>{window.removeEventListener("mousemove",l),window.removeEventListener("mouseup",u)}},[p,h]);function w(l,u,d,j){l.target.closest("[data-no-drag]")||(l.preventDefault(),y({itemId:u,label:d,icon:j,x:l.clientX,y:l.clientY}),m())}return e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-6",onClick:m,children:[e.jsxs("div",{className:"relative w-full max-w-2xl max-h-[80vh] flex flex-col rounded-2xl overflow-hidden text-[#f5d27a]",onClick:l=>l.stopPropagation(),style:{background:"linear-gradient(180deg, #4a2e18 0%, #2a1808 100%)",boxShadow:"0 0 0 3px #b08a3a, 0 30px 60px rgba(0,0,0,0.6)"},children:[e.jsxs("div",{className:"flex items-center gap-3 px-5 py-3 border-b border-[#6e4724]",children:[e.jsx("span",{className:"text-2xl",children:"🗄️"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-sm font-semibold tracking-tight",children:"Filing cabinet"}),e.jsxs("div",{className:"text-[11px] text-[#d9c08c]",children:[t.length," item",t.length===1?"":"s"," filed · drag a row out, or click ",e.jsx("b",{children:"to desk"})]})]}),e.jsx("button",{"data-no-drag":!0,onClick:m,className:"w-8 h-8 rounded-full bg-[#1a0f05] border border-[#6e4724] text-[#d9c08c] hover:text-white flex items-center justify-center",children:"✕"})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 flex flex-col gap-2",children:[t.length===0&&e.jsx("div",{className:"text-center py-12 text-[#d9c08c] italic",children:"Nothing filed yet. Drag a file or sticky note onto the cabinet to file it."}),t.map(l=>{const u=a.find(N=>N.id===l);if(!u)return e.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-[#1a0f05]/40 border border-[#6e4724]/50 rounded-lg text-[#d9c08c]/70",children:[e.jsxs("span",{className:"text-xs italic",children:[l," (no longer in mission)"]}),e.jsx("button",{"data-no-drag":!0,onClick:()=>b(l),className:"text-[11px] hover:text-white",children:"remove"})]},l);const d=u.kind==="file"?s.find(N=>N.ref===u.ref):void 0,j=u.kind==="fact"?i.find(N=>N.ref===u.ref):void 0,v=u.kind==="activity"?x.find(N=>N.id===u.ref):void 0,f=d?d.type==="report"?"📊":"📄":j?"💡":v?v.icon:"📌",M=(d==null?void 0:d.ref)??(j==null?void 0:j.ref)??(v?`${v.agentName} · ${v.activity}`:l);return e.jsxs("div",{onMouseDown:N=>w(N,l,M,f),className:"flex items-center gap-3 px-3 py-2 bg-[#1a0f05]/40 border border-[#6e4724]/50 rounded-lg hover:bg-[#1a0f05]/60 transition-colors cursor-grab active:cursor-grabbing",title:"Drag out to place on the desk, or use the buttons →",children:[e.jsx("span",{className:"text-lg leading-none",children:f}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-xs text-[#f5d27a] truncate",children:M}),((d==null?void 0:d.description)??(j==null?void 0:j.description))&&e.jsx("div",{className:"text-[10px] text-[#d9c08c] truncate",children:(d==null?void 0:d.description)??(j==null?void 0:j.description)})]}),d&&e.jsx("button",{"data-no-drag":!0,onClick:()=>c(d.ref),className:"px-2 py-1 text-[10px] bg-[#6e4724] border border-[#b08a3a] rounded text-[#f5d27a] hover:text-white",children:"Open ↗"}),e.jsx("button",{"data-no-drag":!0,onClick:()=>b(l),className:"px-2 py-1 text-[10px] bg-[#1a0f05] border border-[#6e4724] rounded text-[#d9c08c] hover:text-white",children:"to desk"})]},l)})]})]}),p&&e.jsx("div",{className:"fixed z-[70] pointer-events-none",style:{left:p.x-80,top:p.y-20},children:e.jsxs("div",{className:"px-3 py-2 rounded bg-[#fdfbf3] text-[#1a1f2e] text-xs flex items-center gap-2 shadow-2xl",style:{transform:"rotate(-2deg)"},children:[e.jsx("span",{children:p.icon}),e.jsx("span",{className:"font-semibold truncate max-w-[200px]",children:p.label})]})})]})}function at({itemIds:t,items:a,fileSources:s,factSources:i,activityStickies:x,onRestore:b,onDeleteForever:h,onClose:c}){return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-6",onClick:c,children:e.jsxs("div",{className:"relative w-full max-w-2xl max-h-[80vh] flex flex-col rounded-2xl overflow-hidden text-[#f5d27a]",onClick:m=>m.stopPropagation(),style:{background:"linear-gradient(180deg, #4a2018 0%, #2a0e08 100%)",boxShadow:"0 0 0 3px #c46a52, 0 30px 60px rgba(0,0,0,0.6)"},children:[e.jsxs("div",{className:"flex items-center gap-3 px-5 py-3 border-b border-[#6e3024]",children:[e.jsx("span",{className:"text-2xl",children:"🗑️"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-sm font-semibold tracking-tight",children:"Wastebasket"}),e.jsxs("div",{className:"text-[11px] text-[#e9b09a]",children:[t.length," item",t.length===1?"":"s"," tossed ·",e.jsx("span",{className:"ml-1",children:"restore to desk, or delete forever"})]})]}),e.jsx("button",{onClick:c,className:"w-8 h-8 rounded-full bg-[#1a0a08] border border-[#6e3024] text-[#e9b09a] hover:text-white flex items-center justify-center",children:"✕"})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 flex flex-col gap-2",children:[t.length===0&&e.jsx("div",{className:"text-center py-12 text-[#e9b09a] italic",children:"Nothing in the bin. Drag a file, sticky, or activity onto the wastebasket to toss it."}),t.map(m=>{const p=a.find(v=>v.id===m),y=(p==null?void 0:p.kind)==="file"?s.find(v=>v.ref===p.ref):void 0,w=(p==null?void 0:p.kind)==="fact"?i.find(v=>v.ref===p.ref):void 0,l=(p==null?void 0:p.kind)==="activity"?x.find(v=>v.id===p.ref):void 0,u=y?y.type==="report"?"📊":"📄":w?"💡":l?l.icon:"📌",d=(y==null?void 0:y.ref)??(w==null?void 0:w.ref)??(l?`${l.agentName} · ${l.activity}`:m),j=(y==null?void 0:y.description)??(w==null?void 0:w.description)??(l==null?void 0:l.detail);return e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 bg-[#1a0a08]/60 border border-[#6e3024]/50 rounded-lg hover:bg-[#1a0a08]/80 transition-colors",title:p?"Restore to the desk or delete forever":"This item no longer exists in the mission",children:[e.jsx("span",{className:"text-lg leading-none opacity-70",children:u}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-xs text-[#f5d27a] truncate line-through decoration-[#c46a52]/50",children:d}),j&&e.jsx("div",{className:"text-[10px] text-[#e9b09a]/80 truncate",children:j})]}),e.jsx("button",{"data-no-drag":!0,onClick:()=>b(m),className:"px-2.5 py-1 text-[10px] bg-[#1a0a08] border border-[#6e3024] rounded text-[#e9b09a] hover:text-white hover:border-[#c46a52]",title:"Pull this item back out of the bin and put it on the desk",children:"↩ to desk"}),e.jsx("button",{"data-no-drag":!0,onClick:()=>{window.confirm(`Delete this forever?
7
-
8
- "${d.slice(0,100)}${d.length>100?"…":""}"
9
-
10
- The item will never reappear on the desk again, even after a reload. This is UI-only — the underlying mission file/note isn't deleted on disk.`)&&h(m)},className:"px-2.5 py-1 text-[10px] bg-[#3a0a08] border border-[#c46a52]/60 rounded text-[#ff9c9c] hover:text-white hover:bg-[#5a0e0a] hover:border-[#ff9c9c]",title:"Permanently hide this item — gone for good",children:"✕ Delete forever"})]},m)})]}),t.length>0&&e.jsx("div",{className:"px-5 py-2 border-t border-[#6e3024] text-center text-[10px] text-[#e9b09a]/70 uppercase tracking-widest",children:"tip: drag items onto the wastebasket from the desk · restore is non-destructive"})]})})}const nt={background:["radial-gradient(ellipse 120px 80px at 78% 28%, rgba(40,18,8,0.55) 0%, rgba(40,18,8,0) 70%)","radial-gradient(ellipse 90px 60px at 22% 72%, rgba(40,18,8,0.45) 0%, rgba(40,18,8,0) 75%)","repeating-linear-gradient(92deg, rgba(255,180,90,0.05) 0px, rgba(60,30,10,0.08) 3px, rgba(255,180,90,0.04) 7px, rgba(60,30,10,0.10) 11px, rgba(255,180,90,0.06) 16px)","repeating-linear-gradient(0deg, rgba(0,0,0,0.04) 0px, rgba(0,0,0,0) 2px, rgba(0,0,0,0.03) 4px)","linear-gradient(180deg, #6e4724 0%, #5a3717 50%, #482a13 100%)"].join(",")},st={background:"radial-gradient(ellipse 80% 60% at 20% 0%, rgba(255,220,140,0.18) 0%, rgba(0,0,0,0) 55%)"},rt={background:"radial-gradient(ellipse at 50% 50%, rgba(0,0,0,0) 50%, rgba(0,0,0,0.45) 100%)"},it=`
11
- @keyframes deskGlow {
12
- 0%, 100% { opacity: 0.5; }
13
- 50% { opacity: 0.8; }
14
- }
15
- @keyframes deskAlarm {
16
- 0%, 100% { opacity: 0.5; }
17
- 50% { opacity: 1; }
18
- }
19
- @keyframes deskFloat {
20
- 0%, 100% { transform: translateY(0); }
21
- 50% { transform: translateY(-3px); }
22
- }
23
- /* v6.1.0-alpha.24 — gentle bob on working sticky notes. Lives on an
24
- INNER wrapper so it composes with the parent Draggable's rotation
25
- transform. */
26
- @keyframes stickyBreathe {
27
- 0%, 100% { transform: translateY(0); }
28
- 50% { transform: translateY(-2.5px); }
29
- }
30
- /* Tether-line dash flow — animates stroke-dashoffset to give the
31
- thread a moving-current feel. The dasharray defines the segment
32
- pattern. */
33
- @keyframes tetherFlow {
34
- to { stroke-dashoffset: -20; }
35
- }
36
- /* Dust mote drift — slow vertical drift with a gentle horizontal
37
- wobble. Two duration variants so motes don't tick in unison. */
38
- @keyframes mote1 {
39
- 0% { transform: translate(0, 0) scale(1); opacity: 0; }
40
- 10% { opacity: 0.55; }
41
- 90% { opacity: 0.45; }
42
- 100% { transform: translate(14px, -90vh) scale(1.1); opacity: 0; }
43
- }
44
- @keyframes mote2 {
45
- 0% { transform: translate(0, 0) scale(0.9); opacity: 0; }
46
- 10% { opacity: 0.4; }
47
- 90% { opacity: 0.3; }
48
- 100% { transform: translate(-12px, -90vh) scale(1); opacity: 0; }
49
- }
50
- `;function ot({items:t,room:a,poseOf:s,isHidden:i}){const x=t.find(l=>l.kind==="document"),b=x&&!i(x.id)?s(x):null,h=o.useMemo(()=>{if(!b)return[];const l=[];for(const u of t){if(u.kind!=="agent"||i(u.id))continue;const d=a.team.find(j=>j.agentId===u.ref);d&&(d.paused||d.state!=="working"&&d.state!=="editing"||l.push({item:u,member:d,pose:s(u)}))}return l},[t,a.team,s,i,b]),c=h.length>0,m=220,p=110,y=460,w=260;return e.jsxs(e.Fragment,{children:[b&&h.length>0&&e.jsxs("svg",{className:"absolute inset-0 w-full h-full pointer-events-none",style:{zIndex:5},"aria-hidden":!0,children:[e.jsx("defs",{children:e.jsxs("radialGradient",{id:"tetherNodeGlow",children:[e.jsx("stop",{offset:"0%",stopColor:"#ffd86e",stopOpacity:"0.9"}),e.jsx("stop",{offset:"100%",stopColor:"#ffd86e",stopOpacity:"0"})]})}),h.map(({item:l,member:u,pose:d})=>{const j=d.x+m/2,v=d.y+p/2,f=b.x+y/2,M=b.y+w/2,N=(j+f)/2,z=(v+M)/2-40,E=`M ${j} ${v} Q ${N} ${z}, ${f} ${M}`,F=u.state==="editing"?"rgba(245, 158, 11, 0.55)":u.state==="blocked"?"rgba(239, 68, 68, 0.7)":"rgba(255, 216, 110, 0.55)";return e.jsxs("g",{children:[e.jsx("path",{d:E,fill:"none",stroke:F,strokeWidth:1.4,strokeDasharray:"8 8",style:{animation:"tetherFlow 1.6s linear infinite"}}),e.jsx("circle",{cx:j,cy:v,r:14,fill:"url(#tetherNodeGlow)"})]},l.id)})]}),c&&e.jsx("div",{className:"absolute inset-0 pointer-events-none overflow-hidden",style:{zIndex:6},"aria-hidden":!0,children:lt.map((l,u)=>e.jsx("span",{className:"absolute rounded-full",style:{left:`${l.left}vw`,bottom:`${-5+l.delay%12}vh`,width:l.size,height:l.size,background:"radial-gradient(circle at 35% 30%, rgba(255,250,235,0.85) 0%, rgba(212,196,158,0.4) 60%, rgba(0,0,0,0) 100%)",animation:`${u%2===0?"mote1":"mote2"} ${l.duration}s linear infinite`,animationDelay:`${l.delay}s`,filter:"blur(0.4px)"}},u))})]})}const lt=[{left:6,size:3,duration:28,delay:0},{left:14,size:2,duration:36,delay:3},{left:22,size:4,duration:30,delay:8},{left:30,size:2,duration:40,delay:1},{left:38,size:3,duration:26,delay:5},{left:46,size:3,duration:34,delay:11},{left:54,size:2,duration:38,delay:2},{left:62,size:4,duration:32,delay:7},{left:70,size:3,duration:30,delay:9},{left:78,size:2,duration:36,delay:4},{left:86,size:3,duration:28,delay:12},{left:94,size:4,duration:34,delay:6}];function ce(t){let a=0,s=0;for(const i of t.team)(i.state==="working"||i.state==="editing")&&a++,i.state==="blocked"&&s++;return{working:a,blocked:s}}function dt(t,a,s){return t==="paused"?"Paused":t==="done"?"Done":t==="failed"?"Stopped":s>0?`${a} working · ${s} needs you`:a>0?`${a} working`:t==="forming"?"Forming team…":"Idle"}function ct(t){return t==="paused"?"paused":t==="done"?"done":t==="failed"?"stopped":t==="blocked"?"waiting on you":"auto-saving"}function xt(t,a){return t.length<=a?t:t.slice(0,a-1)+"…"}function ut(t){switch(t){case"working":return"bg-accent animate-pulse";case"editing":return"bg-warning animate-pulse";case"blocked":return"bg-error animate-pulse";case"done":return"bg-success";default:return"bg-text-muted"}}function ft(t){switch(t){case"working":return"#6366f1";case"editing":return"#f59e0b";case"blocked":return"#ef4444";case"done":return"#22c55e";default:return"#71717a"}}function pt(t){return t==="working"?"working":t==="editing"?"editing":t==="blocked"?"needs you":t==="done"?"done":"idle"}function gt(t,a){const s=t.replace("#","");if(s.length!==6)return t;const i=parseInt(s,16);let x=i>>16&255,b=i>>8&255,h=i&255;const c=Math.round(255*(a/100));return x=Math.max(0,Math.min(255,x+c)),b=Math.max(0,Math.min(255,b+c)),h=Math.max(0,Math.min(255,h+c)),"#"+(x<<16|b<<8|h).toString(16).padStart(6,"0")}export{yt as default};
@@ -1,7 +0,0 @@
1
- import{r as o,j as e,R as D,l as z,u as H}from"./index-slWylU2o.js";import{g as q,a as M,s as W,p as G,b as K,d as Y,e as V}from"./missions-DbC8UmMc.js";import{F as Q}from"./FileViewer-D98m-vF5.js";const X=/\bhttps?:\/\/[^\s<>()[\]"']+[^\s<>()[\]"',.!?;:]/gi;function J(t){if(!t)return[];const n=[];let s=0;for(const r of t.matchAll(X))r.index!==void 0&&(r.index>s&&n.push(t.slice(s,r.index)),n.push({url:r[0]}),s=r.index+r[0].length);return s<t.length&&n.push(t.slice(s)),n}function w(t){try{const n=new URL(t),s=n.host.replace(/^www\./,""),r=(n.pathname+n.search+n.hash).replace(/^\//,"");if(r.length===0)return s;const i=`${s}/${r}`;return i.length<=60?i:i.slice(0,57)+"…"}catch{return t.length<=60?t:t.slice(0,57)+"…"}}function Z({text:t,sources:n,onOpenFile:s}){const r=o.useMemo(()=>J(t),[t]),i=o.useMemo(()=>(n??[]).filter(a=>a.type==="url"),[n]),x=o.useMemo(()=>(n??[]).filter(a=>a.type!=="url"),[n]),c=o.useMemo(()=>{const a=new Set;for(const d of r)typeof d!="string"&&a.add(d.url);return a},[r]),p=o.useMemo(()=>i.filter(a=>!c.has(a.ref)),[i,c]);return e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"whitespace-pre-wrap",children:r.map((a,d)=>typeof a=="string"?e.jsx(D.Fragment,{children:a},d):e.jsx("a",{href:a.url,target:"_blank",rel:"noopener noreferrer",onClick:m=>m.stopPropagation(),className:"text-accent hover:text-accent2 underline underline-offset-2 break-all",children:w(a.url)},d))}),(p.length>0||x.length>0)&&e.jsxs("div",{className:"mt-3 pt-2.5 border-t border-border/50",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-widest text-text-muted mb-1.5",children:"Sources"}),p.length>0&&e.jsx("ul",{className:"space-y-1 mb-1.5",children:p.map((a,d)=>e.jsxs("li",{className:"text-[12px] leading-snug",children:[e.jsx("span",{className:"mr-1.5",children:"🔗"}),e.jsx("a",{href:a.ref,target:"_blank",rel:"noopener noreferrer",onClick:m=>m.stopPropagation(),className:"text-accent hover:text-accent2 underline underline-offset-2 break-all",title:a.ref,children:a.description??w(a.ref)}),a.description&&e.jsxs("span",{className:"text-text-muted ml-2 text-[11px]",children:["(",w(a.ref),")"]})]},`u-${d}`))}),x.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5",children:x.map((a,d)=>{const m=a.type==="file"?"📄":a.type==="fact"?"💡":"📊",f=a.ref.length>50?a.ref.slice(0,47)+"…":a.ref;return(a.type==="file"||a.type==="report")&&!!s?e.jsxs("button",{type:"button",onClick:N=>{N.stopPropagation(),s(a.ref,a.type)},className:"inline-flex items-center gap-1.5 px-2 py-0.5 bg-bg-tertiary/60 border border-border rounded-full text-[11px] text-text-secondary hover:bg-accent/15 hover:text-text hover:border-accent/40 transition-colors cursor-pointer",title:`Open ${a.ref}${a.description?" — "+a.description:""}`,children:[m," ",e.jsx("b",{className:"text-text font-medium",children:f}),e.jsx("span",{className:"text-text-muted text-[10px]",children:"↗"})]},`o-${d}`):e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2 py-0.5 bg-bg-tertiary/60 border border-border rounded-full text-[11px] text-text-secondary",title:a.description??a.ref,children:[m," ",e.jsx("b",{className:"text-text font-medium",children:f})]},`o-${d}`)})})]})]})}function me(){const{id:t}=z(),n=H(),[s,r]=o.useState(null),[i,x]=o.useState(!0),[c,p]=o.useState(null),[a,d]=o.useState(""),[m,f]=o.useState(!1),[k,N]=o.useState(!1),[I,C]=o.useState(!1),[R,E]=o.useState(new Set),A=o.useCallback(l=>{E(u=>{const b=new Set(u);return b.has(l)?b.delete(l):b.add(l),b})},[]),S=o.useRef(null),[$,h]=o.useState(null),_=o.useCallback(async l=>{if(t){h({ref:l,loading:!0});try{const u=await q(t,l);h({ref:l,loading:!1,file:u})}catch(u){h({ref:l,loading:!1,error:u.message})}}},[t]),L=o.useCallback(()=>h(null),[]);o.useEffect(()=>{if(!t)return;let l=!0;return x(!0),M(t).then(({mission:u})=>{l&&(r(u),x(!1))}).catch(u=>{l&&(p(u.message),x(!1))}),()=>{l=!1}},[t]),o.useEffect(()=>t?W(t,u=>{if(u.kind==="mission_deleted"){n("/mission");return}u.kind!=="hello"&&M(t).then(({mission:b})=>r(b)).catch(()=>{})}):void 0,[t,n]),o.useEffect(()=>{const l=S.current;if(!l)return;l.scrollHeight-l.scrollTop-l.clientHeight<200&&(l.scrollTop=l.scrollHeight)},[s==null?void 0:s.messages.length]);const U=o.useCallback(async()=>{if(!(!s||!a.trim()||m)){f(!0);try{await G(s.id,a.trim()),d("")}catch(l){p(l.message)}finally{f(!1)}}},[s,a,m]),P=o.useCallback(async(l,u)=>{if(s)try{await K(s.id,l,u)}catch(b){p(b.message)}},[s]),B=o.useCallback(async()=>{if(!s)return;const l=s.status==="paused"?"working":"paused";try{await Y(s.id,l)}catch(u){p(u.message)}},[s]),O=o.useCallback(async()=>{if(!(!s||!window.confirm(`Delete this mission?
2
-
3
- "${s.goal.slice(0,120)}${s.goal.length>120?"…":""}"
4
-
5
- The file is renamed on disk (recoverable manually), but the mission disappears from the UI immediately.`)))try{await V(s.id),n("/mission")}catch(u){p(u.message)}},[s,n]);if(i)return e.jsx("div",{className:"flex items-center justify-center h-full text-[#a89070] text-sm",style:{fontFamily:"'Georgia', serif"},children:"Loading mission…"});if(c||!s)return e.jsxs("div",{className:"flex items-center justify-center h-full flex-col gap-3 text-[#f3e9d0]",style:{fontFamily:"'Georgia', serif"},children:[e.jsx("div",{className:"text-[#c45050] text-sm",children:c??"Mission not found."}),e.jsx("button",{onClick:()=>n("/mission"),className:"text-[#c4a35a] text-sm hover:underline",children:"← Start a new mission"})]});const{working:T,blocked:g}=oe(s);return e.jsxs("div",{className:"h-full w-full flex flex-col text-[#f3e9d0] overflow-hidden",style:{fontFamily:"'Georgia', serif"},children:[e.jsxs("header",{className:"relative z-20 flex items-center gap-4 px-5 py-3",style:{background:"linear-gradient(180deg, rgba(42,26,10,0.92), rgba(56,36,16,0.88))",borderBottom:"1px solid rgba(138,106,58,0.5)",boxShadow:"0 2px 12px rgba(0,0,0,0.3)"},children:[e.jsx("button",{onClick:()=>n("/mission"),className:"text-text-muted hover:text-text text-sm shrink-0",title:"Start a new mission",children:"←"}),e.jsx("button",{onClick:()=>n("/mission/library"),className:"text-[10px] uppercase tracking-widest text-text-muted hover:text-text border border-border rounded-full px-2 py-0.5 shrink-0",title:"Browse past missions",children:"Library"}),e.jsx("button",{onClick:()=>n("/space/home"),className:"text-[10px] uppercase tracking-widest text-text-muted hover:text-text border border-border rounded-full px-2 py-0.5 shrink-0 inline-flex items-center gap-1",title:"Back to the canvas spaces",children:"🌌 Canvas"}),e.jsxs("div",{className:"font-semibold tracking-tight shrink-0",children:[e.jsx("span",{className:"bg-gradient-to-r from-accent to-accent2 bg-clip-text text-transparent",children:"TITAN"}),e.jsx("span",{className:"text-text-muted font-normal",children:"  ›  "}),"Mission"]}),e.jsx(ee,{room:s}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("div",{title:"Team health",className:"inline-flex items-center gap-2 px-3 py-1.5 bg-bg-secondary/60 border border-border rounded-full text-xs text-text-muted",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${g>0?"bg-error animate-pulse":T>0?"bg-accent animate-pulse":"bg-success"}`}),ie(s.status,T,g)]}),g>0&&e.jsxs("div",{className:"inline-flex items-center gap-1 px-2.5 py-1.5 bg-error/15 border border-error/30 rounded-full text-xs text-error",title:"Decisions waiting on you",children:["🔔 ",g]}),e.jsxs("div",{title:"Effort so far",className:"inline-flex items-center gap-2 px-3 py-1.5 bg-bg-secondary/60 border border-border rounded-full text-xs",children:[e.jsx("span",{className:"inline-block w-3 h-4 bg-gradient-radial-flame"}),e.jsxs("span",{className:"text-text font-medium",children:["$",s.cost.usd.toFixed(2)]})]}),e.jsx("button",{onClick:()=>n(`/mission/${s.id}/canvas`),className:"px-3 py-1.5 text-xs bg-bg-secondary/60 border border-border rounded-full text-text-secondary hover:text-text",title:"Switch to the canvas (spatial) view of the same mission",children:"Canvas view"}),e.jsx("button",{onClick:B,className:"px-3 py-1.5 text-xs bg-bg-secondary/60 border border-border rounded-full text-text-secondary hover:text-text",children:s.status==="paused"?"Resume":"Pause"}),e.jsx("button",{onClick:O,className:"px-3 py-1.5 text-xs bg-bg-secondary/60 border border-border rounded-full text-text-muted hover:text-error hover:bg-error/15 hover:border-error/40 transition-colors",title:"Delete this mission",children:"🗑 Delete"}),e.jsx("button",{onClick:()=>C(l=>!l),className:"w-8 h-8 rounded-full bg-bg-secondary/60 border border-border text-text-muted hover:text-text flex items-center justify-center font-semibold text-sm",title:"What's this?",children:"?"})]})]}),e.jsx("main",{ref:S,className:"relative z-10 flex-1 overflow-y-auto",children:e.jsxs("div",{className:"max-w-3xl mx-auto px-4 md:px-6 py-6 flex flex-col gap-3",children:[s.messages.map(l=>e.jsx(te,{msg:l,artifact:s.artifact,artifactExpanded:k,onToggleArtifact:()=>N(u=>!u),onAnswer:P,onOpenFile:_,expanded:R.has(l.id),onToggleExpand:()=>A(l.id)},l.id)),e.jsx(le,{room:s})]})}),e.jsx("footer",{className:"relative z-20 bg-bg/80 backdrop-blur-md border-t border-border",children:e.jsxs("div",{className:"max-w-3xl mx-auto px-4 md:px-6 py-3",children:[e.jsxs("form",{onSubmit:l=>{l.preventDefault(),U()},className:"flex items-center gap-2 bg-bg-secondary/70 border border-border rounded-2xl px-3 py-2",children:[e.jsx("button",{type:"button",title:"Add a teammate (coming soon)",className:"w-9 h-9 rounded-xl bg-bg-tertiary border border-border text-text-muted hover:text-text flex items-center justify-center text-lg font-semibold",disabled:!0,children:"+"}),e.jsx("input",{value:a,onChange:l=>d(l.target.value),placeholder:"Type to the team — or @Sage to talk to one helper",className:"flex-1 bg-transparent outline-none text-text placeholder:text-text-muted/60 text-sm py-2 px-1"}),e.jsxs("button",{type:"button",title:"Voice coming next release",disabled:!0,className:"relative w-9 h-9 rounded-full bg-bg-tertiary border border-border text-text-muted opacity-50 cursor-not-allowed flex items-center justify-center",children:["🎤",e.jsx("span",{className:"absolute -bottom-3.5 left-1/2 -translate-x-1/2 text-[8px] uppercase tracking-widest text-text-muted",children:"soon"})]}),e.jsx("button",{type:"submit",disabled:!a.trim()||m,className:"w-9 h-9 rounded-xl bg-gradient-to-br from-accent to-accent2 text-bg-deep font-bold shadow-[0_0_16px_rgba(99,102,241,0.5)] disabled:opacity-50 disabled:cursor-not-allowed",title:"Send",children:"↑"})]}),e.jsxs("div",{className:"mt-2 flex justify-between items-center text-[11px] text-text-muted",children:[e.jsxs("span",{children:[s.team.map(l=>e.jsx("span",{className:"mr-2",children:e.jsxs("b",{className:"text-text-secondary",children:["@",l.name]})},l.agentId)),"to address one helper"]}),e.jsxs("span",{children:["Press ",e.jsx("b",{className:"text-text-secondary",children:"↵"})," to send"]})]})]})}),$&&e.jsx(Q,{state:$,onClose:L}),I&&e.jsxs("div",{className:"fixed top-16 right-5 w-80 bg-bg-secondary/95 border border-border rounded-xl p-4 backdrop-blur-xl shadow-2xl z-30",children:[e.jsx("button",{onClick:()=>C(!1),className:"absolute top-3 right-3 text-text-muted hover:text-text text-sm",children:"✕"}),e.jsx("h3",{className:"font-semibold text-sm mb-2",children:"What you're looking at"}),e.jsxs("p",{className:"text-xs text-text-secondary leading-relaxed mb-3",children:["It's a group chat with your ",e.jsx("b",{className:"text-text",children:"AI helpers"}),". Each one has a job. You stay in charge."]}),e.jsxs("ul",{className:"space-y-2 text-xs text-text-secondary",children:[e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{children:"💬"}),e.jsxs("span",{children:["Helpers ",e.jsx("b",{className:"text-text",children:"talk in the thread"})," as they work."]})]}),e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{children:"📄"}),e.jsxs("span",{children:["The ",e.jsx("b",{className:"text-text",children:"document card"})," shows what they're building."]})]}),e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{children:"❓"}),e.jsxs("span",{children:["Decisions appear as ",e.jsx("b",{className:"text-text",children:"pink messages with buttons"}),"."]})]}),e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{children:"@"}),e.jsxs("span",{children:["Type ",e.jsx("b",{className:"text-text",children:"@Scout"})," (or any name) to message one helper."]})]}),e.jsxs("li",{className:"flex gap-2",children:[e.jsx("span",{children:"🎤"}),e.jsx("span",{children:e.jsx("b",{className:"text-text",children:"Voice comes next release."})})]})]})]})]})}function ee({room:t}){return e.jsxs("div",{className:"flex-1 flex items-center gap-2 overflow-x-auto min-w-0",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-widest text-text-muted shrink-0",children:"your team"}),t.team.map(n=>e.jsxs("div",{title:`${n.name} · ${n.role}${n.currentActivity?" · "+n.currentActivity:""}`,className:"inline-flex items-center gap-2 px-2.5 py-1 bg-bg-secondary/60 border border-border rounded-full text-xs shrink-0",children:[e.jsx("span",{className:"w-5 h-5 rounded-md flex items-center justify-center text-[10px] font-bold text-bg-deep",style:{background:`linear-gradient(135deg, ${n.color}, ${y(n.color,-25)})`},children:n.name[0]}),e.jsx("span",{className:"text-text-secondary",children:n.name}),e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${de(n.state)}`,style:{boxShadow:`0 0 6px ${ce(n.state)}`}})]},n.agentId))]})}function te({msg:t,artifact:n,artifactExpanded:s,onToggleArtifact:r,onAnswer:i,onOpenFile:x,expanded:c,onToggleExpand:p}){const a=(d,m)=>e.jsx("button",{type:"button",onClick:p,className:"text-left w-full",title:c?"Click to hide details":"Click to see details",children:d},m);return t.kind==="user"?e.jsxs("div",{className:"self-end max-w-[88%] flex flex-col items-end",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1 flex-row-reverse",children:[e.jsx("div",{className:"w-6 h-6 rounded-md bg-white flex items-center justify-center text-bg-deep font-bold text-[11px]",children:"Y"}),e.jsx("span",{className:"text-[11px] font-semibold",children:"You"}),e.jsx("span",{className:"text-[10px] text-text-muted",children:v(t.at)})]}),a(e.jsx("div",{className:"px-3.5 py-2.5 rounded-2xl rounded-br-md text-bg-deep bg-gradient-to-br from-accent to-accent2 shadow-[0_4px_16px_rgba(99,102,241,0.25)] text-sm leading-relaxed cursor-pointer",children:t.content})),c&&e.jsx(j,{msg:t})]}):t.kind==="system"?e.jsxs("div",{className:"self-center flex flex-col items-center max-w-[88%]",children:[a(e.jsxs("div",{className:"text-[12px] text-text-muted bg-bg-secondary/60 border border-border rounded-full px-3 py-1 backdrop-blur-sm cursor-pointer",children:[e.jsx("span",{className:"text-text-secondary font-medium",children:t.tag==="team_formed"?"Team formed":t.tag==="team_expanded"?"Team change":t.tag??"note"})," · ",t.content.replace(/^Team formed —\s*/,"").replace(/\.$/,"")]})),c&&e.jsx(j,{msg:t})]}):t.kind==="artifact_update"?e.jsx(ae,{artifact:n,expanded:s,onToggle:r,latestSummary:t.summary,latestBy:t.by.name,wordCount:t.wordCount}):t.kind==="question"?e.jsxs("div",{className:"max-w-[88%] flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:"w-6 h-6 rounded-md flex items-center justify-center text-bg-deep font-bold text-[11px]",style:{background:`linear-gradient(135deg, ${t.from.color}, ${y(t.from.color,-25)})`},children:t.from.name[0]}),e.jsx("span",{className:"text-[11px] font-semibold",style:{color:t.from.color},children:t.from.name}),e.jsx("span",{className:"text-[11px] text-text-muted",children:t.from.role}),e.jsx("span",{className:"text-[10px] text-text-muted",children:v(t.at)})]}),e.jsxs("span",{className:"self-start inline-flex items-center gap-1 px-2 py-0.5 mb-1.5 bg-error text-white text-[10px] uppercase tracking-widest font-bold rounded-full",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-white animate-pulse"}),"Needs you"]}),e.jsxs("div",{className:"px-3.5 py-2.5 rounded-2xl rounded-bl-md border-l-[3px] text-sm leading-relaxed cursor-pointer",onClick:p,title:c?"Click to hide details":"Click to see details",style:{background:"linear-gradient(180deg, rgba(239,68,68,0.18), rgba(239,68,68,0.06))",borderLeftColor:t.from.color,border:"1px solid rgba(239,68,68,0.35)",borderLeft:`3px solid ${t.from.color}`},children:[t.content,!t.answer&&e.jsxs(e.Fragment,{children:[t.quickReplies.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 mt-3",children:t.quickReplies.map((d,m)=>e.jsx("button",{onClick:f=>{f.stopPropagation(),i(t.approvalId,d)},className:`px-3 py-1.5 rounded-lg text-xs font-semibold border ${m===t.quickReplies.length-1?"bg-gradient-to-br from-accent to-accent2 text-bg-deep border-transparent":"bg-bg-secondary/60 border-error/40 text-text hover:bg-error/15"}`,children:d},d))}),e.jsx(se,{approvalId:t.approvalId,onSubmit:d=>i(t.approvalId,d)})]}),t.answer&&e.jsxs("div",{className:"mt-3 text-[12px] text-text-muted border-t border-border pt-2",children:["You answered: ",e.jsx("span",{className:"text-text",children:t.answer.content})]})]}),c&&e.jsx(j,{msg:t})]}):e.jsxs("div",{className:"max-w-[88%] flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("div",{className:"w-6 h-6 rounded-md flex items-center justify-center text-bg-deep font-bold text-[11px]",style:{background:`linear-gradient(135deg, ${t.from.color}, ${y(t.from.color,-25)})`},children:t.from.name[0]}),e.jsx("span",{className:"text-[11px] font-semibold",style:{color:t.from.color},children:t.from.name}),e.jsx("span",{className:"text-[11px] text-text-muted",children:t.from.role}),e.jsx("span",{className:"text-[10px] text-text-muted",children:v(t.at)}),e.jsx("span",{className:"text-[10px] text-text-muted/60 ml-auto",children:c?"click to hide":"click for details"})]}),a(e.jsxs("div",{className:"px-3.5 py-2.5 rounded-2xl rounded-bl-md bg-bg-secondary/60 border border-border text-sm leading-relaxed backdrop-blur-sm cursor-pointer hover:bg-bg-secondary/80 transition-colors",style:{borderLeft:`3px solid ${t.from.color}`},children:[e.jsx(Z,{text:t.content,sources:t.sources,onOpenFile:x}),t.actions&&t.actions.length>0&&e.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:t.actions.map((d,m)=>e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 bg-bg-tertiary/60 border border-border rounded-full text-[11px] text-text-muted",children:[e.jsx("span",{children:d.name}),d.detail&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-text-muted",children:"·"}),e.jsx("b",{className:"text-text font-medium",children:d.detail})]})]},m))})]})),c&&e.jsx(j,{msg:t})]})}function j({msg:t}){const n=F(t.at),s=[];if(s.push({label:"When",value:n}),s.push({label:"Message id",value:e.jsx("code",{className:"text-text-secondary text-[11px]",children:t.id})}),t.kind==="agent"){s.push({label:"From",value:e.jsxs("span",{children:[e.jsx("b",{children:t.from.name})," · ",t.from.role," ",e.jsxs("span",{className:"text-text-muted",children:["(",t.from.agentId,")"]})]})});const r=t.meta;r!=null&&r.subtaskTitle&&s.push({label:"Working on",value:e.jsxs("i",{children:['"',r.subtaskTitle,'"']})}),r!=null&&r.status&&s.push({label:"Outcome",value:e.jsx(re,{status:r.status})}),r!=null&&r.model&&s.push({label:"Brain",value:e.jsx("code",{className:"text-text-secondary text-[11px]",children:r.model})}),typeof(r==null?void 0:r.durationMs)=="number"&&s.push({label:"Took",value:ne(r.durationMs)}),typeof(r==null?void 0:r.tokensUsed)=="number"&&r.tokensUsed>0&&s.push({label:"Tokens",value:r.tokensUsed.toLocaleString()}),typeof(r==null?void 0:r.costUsd)=="number"&&r.costUsd>0&&s.push({label:"Cost",value:"$"+r.costUsd.toFixed(4)}),t.actions&&t.actions.length>0&&s.push({label:"Used",value:e.jsx("div",{className:"flex flex-wrap gap-1.5",children:t.actions.map((i,x)=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-bg-tertiary/60 border border-border rounded-full text-[11px] text-text-muted",children:[i.name,i.detail&&e.jsxs("span",{children:[e.jsx("span",{className:"text-text-muted/60",children:" · "}),e.jsx("b",{className:"text-text",children:i.detail})]})]},x))})}),r!=null&&r.failureDetail&&s.push({label:"Error detail",value:e.jsxs("code",{className:"block whitespace-pre-wrap bg-bg-tertiary/80 border border-border rounded p-2 text-[11px] text-text-secondary font-mono leading-relaxed max-h-40 overflow-y-auto",children:[r.failureDetail.slice(0,800),r.failureDetail.length>800?`
6
- …`:""]})})}else t.kind==="question"?(s.push({label:"From",value:e.jsxs("span",{children:[e.jsx("b",{children:t.from.name})," · ",t.from.role]})}),s.push({label:"Approval id",value:e.jsx("code",{className:"text-text-secondary text-[11px]",children:t.approvalId})}),t.answer?s.push({label:"Answered",value:e.jsxs("span",{children:[F(t.answer.at),' — "',t.answer.content,'"']})}):s.push({label:"Status",value:e.jsx("span",{className:"text-warning",children:"Waiting for your reply"})}),t.quickReplies.length>0&&s.push({label:"Options",value:t.quickReplies.join(" · ")})):t.kind==="user"?s.push({label:"Length",value:t.content.length+" chars"}):t.kind==="system"&&t.tag&&s.push({label:"Kind",value:e.jsx("code",{className:"text-text-secondary text-[11px]",children:t.tag})});return e.jsxs("div",{className:"mt-2 self-stretch bg-bg-secondary/40 border border-border rounded-lg px-3 py-2.5 backdrop-blur-sm",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-widest text-text-muted mb-1.5",children:"Details"}),e.jsx("dl",{className:"grid grid-cols-[max-content_1fr] gap-x-3 gap-y-1.5 text-[12px]",children:s.map((r,i)=>e.jsxs(D.Fragment,{children:[e.jsx("dt",{className:"text-text-muted",children:r.label}),e.jsx("dd",{className:"text-text-secondary",children:r.value})]},i))})]})}function se({approvalId:t,onSubmit:n}){const[s,r]=o.useState(!1),[i,x]=o.useState(""),c=o.useRef(null);o.useEffect(()=>{s&&c.current&&c.current.focus()},[s]);const p=()=>{const a=i.trim();a&&(n(a),x(""),r(!1))};return s?e.jsxs("div",{className:"mt-3",onClick:a=>a.stopPropagation(),children:[e.jsx("textarea",{ref:c,value:i,onChange:a=>x(a.target.value),onKeyDown:a=>{a.key==="Enter"&&(a.metaKey||a.ctrlKey)?(a.preventDefault(),p()):a.key==="Escape"&&(a.preventDefault(),r(!1))},placeholder:`Tell ${t.slice(0,6)}… anything you want.`,rows:3,className:"w-full bg-bg-secondary/80 border border-border rounded-lg p-2 text-sm text-text placeholder:text-text-muted/60 outline-none focus:border-accent/60 resize-y"}),e.jsxs("div",{className:"flex items-center justify-end gap-2 mt-1.5",children:[e.jsx("span",{className:"mr-auto text-[10px] text-text-muted",children:"⌘+↵ to send · esc to cancel"}),e.jsx("button",{type:"button",onClick:()=>{r(!1),x("")},className:"px-3 py-1 text-[11px] text-text-muted hover:text-text",children:"Cancel"}),e.jsx("button",{type:"button",onClick:p,disabled:!i.trim(),className:"px-3 py-1 text-[11px] font-semibold rounded-md bg-gradient-to-br from-accent to-accent2 text-bg-deep disabled:opacity-50 disabled:cursor-not-allowed",children:"Send answer"})]})]}):e.jsx("button",{type:"button",onClick:a=>{a.stopPropagation(),r(!0)},className:"mt-2 text-[11px] text-text-muted hover:text-text-secondary underline underline-offset-2",children:"or type a custom answer…"})}function re({status:t}){const s={done:"bg-success/15 text-success border-success/30",failed:"bg-error/15 text-error border-error/30",needs_info:"bg-warning/15 text-warning border-warning/30",blocked:"bg-warning/15 text-warning border-warning/30",cancelled:"bg-text-muted/15 text-text-muted border-border"}[t]??"bg-bg-tertiary/60 text-text-secondary border-border";return e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-[11px] font-medium border ${s}`,children:t})}function F(t){try{return new Date(t).toLocaleString([],{weekday:"short",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return t}}function ne(t){if(t<1e3)return`${t}ms`;if(t<6e4)return`${(t/1e3).toFixed(1)}s`;const n=Math.floor(t/6e4),s=Math.round(t%6e4/1e3);return`${n}m ${s}s`}function ae({artifact:t,expanded:n,onToggle:s,latestSummary:r,latestBy:i,wordCount:x}){const c=t.content.split(`
7
- `).filter(Boolean).slice(0,2).join(" ").slice(0,240);return e.jsxs("div",{className:"self-stretch my-1 rounded-xl border border-border bg-bg-secondary/40 overflow-hidden relative",children:[e.jsx("div",{className:"absolute left-0 right-0 top-0 h-[2px] overflow-hidden",children:e.jsx("div",{className:"h-full w-1/3 bg-gradient-to-r from-transparent via-accent to-transparent animate-pulse"})}),e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border",children:[e.jsx("div",{className:"w-7 h-7 rounded-lg bg-bg-tertiary flex items-center justify-center text-sm",children:"📄"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-semibold truncate",children:"Live document"}),e.jsxs("div",{className:"text-[11px] text-text-muted truncate",children:[i," ",r," · ",x," words · updating live"]})]}),e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent animate-pulse"}),e.jsx("button",{onClick:s,className:"px-2.5 py-1 text-[11px] font-semibold bg-bg-tertiary border border-border rounded-md text-text-secondary hover:text-text",children:n?"▴ Collapse":"▾ Open"})]}),n?e.jsx("div",{className:"px-5 py-4 bg-[#f7f5ee] text-[#1a1f2e] font-serif text-sm leading-relaxed whitespace-pre-wrap",children:t.content||e.jsx("span",{className:"text-[#8a8472] italic",children:"empty for now…"})}):e.jsx("div",{className:"px-4 py-3 text-sm text-text-secondary font-serif italic",children:c||e.jsx("span",{className:"text-text-muted not-italic",children:"empty for now…"})})]})}function le({room:t}){const n=t.team.filter(r=>r.state==="working"&&r.currentActivity);if(n.length===0)return null;const s=n[n.length-1];return e.jsxs("div",{className:"self-start flex items-start gap-2 px-3 py-2 bg-bg-secondary/60 border border-border rounded-2xl backdrop-blur-sm max-w-[640px]",title:s.currentActivity??void 0,children:[e.jsx("div",{className:"w-5 h-5 rounded-md flex items-center justify-center text-bg-deep font-bold text-[10px] shrink-0 mt-0.5",style:{background:`linear-gradient(135deg, ${s.color}, ${y(s.color,-25)})`},children:s.name[0]}),e.jsxs("span",{className:"text-xs text-text-muted leading-relaxed break-words flex-1 min-w-0",children:[e.jsx("span",{className:"text-text font-semibold",children:s.name})," ",s.currentActivity??"is working"]}),e.jsxs("span",{className:"inline-flex gap-0.5 ml-1 shrink-0 mt-1.5",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-text-muted animate-bounce [animation-delay:0ms]"}),e.jsx("span",{className:"w-1 h-1 rounded-full bg-text-muted animate-bounce [animation-delay:150ms]"}),e.jsx("span",{className:"w-1 h-1 rounded-full bg-text-muted animate-bounce [animation-delay:300ms]"})]})]})}function oe(t){let n=0,s=0;for(const r of t.team)(r.state==="working"||r.state==="editing")&&n++,r.state==="blocked"&&s++;return{working:n,blocked:s}}function ie(t,n,s){return t==="paused"?"Paused":t==="done"?"Done":t==="failed"?"Failed":s>0?`${n} working · ${s} needs you`:n>0?`${n} working`:t==="forming"?"Forming team…":"Idle"}function v(t){try{return new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}}function de(t){switch(t){case"working":return"bg-accent animate-pulse";case"editing":return"bg-warning animate-pulse";case"blocked":return"bg-error animate-pulse";case"done":return"bg-success";default:return"bg-text-muted"}}function ce(t){switch(t){case"working":return"#6366f1";case"editing":return"#f59e0b";case"blocked":return"#ef4444";case"done":return"#22c55e";default:return"#71717a"}}function y(t,n){const s=t.replace("#","");if(s.length!==6)return t;const r=parseInt(s,16);let i=r>>16&255,x=r>>8&255,c=r&255;const p=Math.round(255*(n/100));return i=Math.max(0,Math.min(255,i+p)),x=Math.max(0,Math.min(255,x+p)),c=Math.max(0,Math.min(255,c+p)),"#"+(i<<16|x<<8|c).toString(16).padStart(6,"0")}export{me as default};
@@ -1,5 +0,0 @@
1
- import{u as y,r as i,j as e}from"./index-slWylU2o.js";import{l as h,e as N}from"./missions-DbC8UmMc.js";function L(){const t=y(),[r,l]=i.useState(null),[c,n]=i.useState(null),[o,d]=i.useState("all"),[x,g]=i.useState("");i.useEffect(()=>{let s=!0;return h().then(({missions:a})=>{s&&l(a)}).catch(a=>{s&&n(a.message)}),()=>{s=!1}},[]);const j=i.useCallback(()=>{l(null),h().then(({missions:s})=>l(s)).catch(s=>n(s.message))},[]),v=i.useCallback(async(s,a)=>{if(window.confirm(`Delete this mission?
2
-
3
- "${a.slice(0,120)}${a.length>120?"…":""}"
4
-
5
- The file is renamed (not destroyed), so the disk record can be recovered manually.`)){l(f=>(f??[]).filter(p=>p.id!==s));try{await N(s)}catch(f){n(f.message),h().then(({missions:p})=>l(p)).catch(()=>{})}}},[]),b=i.useMemo(()=>{if(!r)return[];const s=x.trim().toLowerCase();return r.filter(a=>!(o==="live"&&!["working","blocked","paused","forming"].includes(a.status)||o==="done"&&a.status!=="done"||o==="failed"&&a.status!=="failed"||s&&!a.goal.toLowerCase().includes(s)))},[r,o,x]),u=i.useMemo(()=>{const s={all:0,live:0,done:0,failed:0};for(const a of r??[])s.all++,["working","blocked","paused","forming"].includes(a.status)&&s.live++,a.status==="done"&&s.done++,a.status==="failed"&&s.failed++;return s},[r]);return e.jsxs("div",{className:"h-full w-full flex flex-col text-[#f3e9d0] overflow-hidden",style:{fontFamily:"'Georgia', serif"},children:[e.jsxs("header",{className:"relative z-20 flex items-center gap-4 px-5 py-3",style:{background:"linear-gradient(180deg, rgba(42,26,10,0.92), rgba(56,36,16,0.88))",borderBottom:"1px solid rgba(138,106,58,0.5)",boxShadow:"0 2px 12px rgba(0,0,0,0.3)"},children:[e.jsx("button",{onClick:()=>t("/mission"),className:"text-[#c4a35a] hover:text-[#f3e9d0] text-sm",title:"Start a new mission",children:"←"}),e.jsx("button",{onClick:()=>t("/space/home"),className:"text-[10px] uppercase tracking-widest text-[#c4a35a] hover:text-[#f3e9d0] border border-[#8a6a3a] rounded-full px-2 py-0.5 shrink-0 inline-flex items-center gap-1",title:"Back to the canvas spaces",children:"🌌 Canvas"}),e.jsxs("div",{className:"font-semibold tracking-tight shrink-0 text-[#f3e9d0]",children:[e.jsx("span",{className:"text-[#c4a35a]",children:"TITAN"}),e.jsx("span",{className:"text-[#a89070] font-normal",children:"  ›  "}),"Mission Library"]}),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:j,className:"text-xs text-[#a89070] hover:text-[#f3e9d0] px-3 py-1.5 bg-[#4a3020]/80 border border-[#8a6a3a] rounded-full",title:"Reload",children:"⟳ refresh"}),e.jsx("button",{onClick:()=>t("/mission"),className:"px-3 py-1.5 text-xs bg-gradient-to-br from-[#c4a35a] to-[#8a6a3a] text-[#fdf6e3] rounded-full font-semibold shadow-[0_2px_8px_rgba(0,0,0,0.2)]",children:"+ New mission"})]}),e.jsxs("div",{className:"relative z-10 px-5 py-3 flex items-center gap-3 border-b border-[#8a6a3a]/40",children:[e.jsx(m,{active:o==="all",label:"All",count:u.all,onClick:()=>d("all")}),e.jsx(m,{active:o==="live",label:"In progress",count:u.live,onClick:()=>d("live"),dotClass:"bg-accent"}),e.jsx(m,{active:o==="done",label:"Done",count:u.done,onClick:()=>d("done"),dotClass:"bg-success"}),e.jsx(m,{active:o==="failed",label:"Stopped",count:u.failed,onClick:()=>d("failed"),dotClass:"bg-error"}),e.jsx("div",{className:"flex-1"}),e.jsx("input",{value:x,onChange:s=>g(s.target.value),placeholder:"Search goals…",className:"w-72 bg-bg-secondary/70 border border-border rounded-full px-4 py-1.5 text-sm text-text placeholder:text-text-muted/60 outline-none focus:border-accent/50"})]}),e.jsxs("main",{className:"relative z-10 flex-1 overflow-y-auto",children:[c&&e.jsx("div",{className:"max-w-3xl mx-auto px-5 py-6 text-error",children:c}),r===null&&!c&&e.jsx("div",{className:"max-w-3xl mx-auto px-5 py-6 text-text-muted text-sm",children:"Loading missions…"}),r!==null&&b.length===0&&e.jsx(C,{filter:o,query:x,onStart:()=>t("/mission")}),r!==null&&b.length>0&&e.jsx("ul",{className:"max-w-3xl mx-auto px-5 py-4 flex flex-col gap-2",children:b.map(s=>e.jsx(w,{mission:s,onClick:()=>t(`/mission/${s.id}`),onDelete:()=>v(s.id,s.goal)},s.id))})]})]})}function m({active:t,label:r,count:l,onClick:c,dotClass:n}){return e.jsxs("button",{onClick:c,className:`inline-flex items-center gap-2 px-3 py-1.5 rounded-full text-xs border transition-colors ${t?"bg-bg-secondary border-border-light text-text":"bg-bg-secondary/40 border-border text-text-muted hover:text-text"}`,children:[n&&e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${n}`}),e.jsx("span",{children:r}),e.jsx("span",{className:"text-text-muted/70",children:l})]})}function w({mission:t,onClick:r,onDelete:l}){const c=S(t.updatedAt);return e.jsxs("li",{className:"relative group",children:[e.jsxs("button",{onClick:r,className:"w-full text-left bg-bg-secondary/40 hover:bg-bg-secondary/70 border border-border rounded-xl px-4 py-3 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx(k,{status:t.status}),e.jsx("div",{className:"text-sm font-medium text-text flex-1 truncate",children:t.goal||"(no goal)"}),e.jsx("div",{className:"text-[11px] text-text-muted shrink-0",children:c})]}),e.jsxs("div",{className:"flex items-center gap-3 text-[11px] text-text-muted",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx("span",{children:t.team.length}),e.jsxs("span",{children:["helper",t.team.length===1?"":"s"]})]}),t.team.length>0&&e.jsxs("span",{className:"flex items-center gap-1 truncate max-w-[40%]",children:["· ",t.team.slice(0,4).map(n=>n.name).join(", "),t.team.length>4?`, +${t.team.length-4}`:""]}),t.cost.usd>0&&e.jsxs("span",{children:["· $",t.cost.usd.toFixed(2)," effort"]}),t.playId&&e.jsx("span",{className:"ml-auto text-text-muted/60 text-[10px] uppercase tracking-widest",children:t.playId})]})]}),e.jsx("button",{type:"button",onClick:n=>{n.stopPropagation(),l()},className:"absolute top-2 right-2 w-7 h-7 rounded-full bg-bg-tertiary/60 border border-border text-text-muted hover:text-error hover:bg-error/15 hover:border-error/40 opacity-0 group-hover:opacity-100 transition-opacity flex items-center justify-center text-sm",title:"Delete this mission","aria-label":"Delete mission",children:"🗑"})]})}function k({status:t}){const l={forming:{label:"forming",cls:"bg-bg-tertiary/60 text-text-secondary border-border"},working:{label:"live",cls:"bg-accent/15 text-accent border-accent/30"},blocked:{label:"needs you",cls:"bg-error/15 text-error border-error/30 animate-pulse"},paused:{label:"paused",cls:"bg-warning/15 text-warning border-warning/30"},done:{label:"done",cls:"bg-success/15 text-success border-success/30"},failed:{label:"stopped",cls:"bg-text-muted/15 text-text-muted border-border"}}[t]??{label:t,cls:"bg-bg-tertiary/60 text-text-secondary border-border"};return e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-[10px] font-semibold border uppercase tracking-widest ${l.cls}`,children:l.label})}function C({filter:t,query:r,onStart:l}){return r.trim().length>0?e.jsxs("div",{className:"max-w-md mx-auto px-5 py-12 text-center",children:[e.jsxs("div",{className:"text-text-muted text-sm mb-2",children:['No missions match "',r,'"']}),e.jsx("div",{className:"text-text-muted/70 text-xs",children:"Try a shorter search term, or clear the filter."})]}):t!=="all"?e.jsx("div",{className:"max-w-md mx-auto px-5 py-12 text-center",children:e.jsxs("div",{className:"text-text-muted text-sm",children:["No ",t==="live"?"in-progress":t," missions right now."]})}):e.jsxs("div",{className:"max-w-md mx-auto px-5 py-16 text-center",children:[e.jsx("div",{className:"text-text-secondary text-base mb-2",children:"Nothing here yet."}),e.jsx("div",{className:"text-text-muted text-sm mb-5",children:"Past missions show up here so you can pick them back up anytime."}),e.jsx("button",{onClick:l,className:"px-4 py-2 rounded-xl bg-gradient-to-br from-accent to-accent2 text-bg-deep font-semibold shadow-[0_0_24px_rgba(99,102,241,0.45)]",children:"Start your first mission"})]})}function S(t){try{const r=Date.now()-new Date(t).getTime();return r<6e4?"just now":r<36e5?Math.floor(r/6e4)+"m ago":r<864e5?Math.floor(r/36e5)+"h ago":r<7*864e5?Math.floor(r/864e5)+"d ago":new Date(t).toLocaleDateString()}catch{return""}}export{L as default};
@@ -1 +0,0 @@
1
- import{r as d,u as N,j as e}from"./index-slWylU2o.js";import{c as S}from"./missions-DbC8UmMc.js";const I={id:"hourly",label:"Every hour",cron:"0 * * * *",cadence:"24 runs/day"},f={id:"every4h",label:"Every 4 hours",cron:"0 */4 * * *",cadence:"6 runs/day"},v={id:"every6h",label:"Every 6 hours",cron:"0 */6 * * *",cadence:"4 runs/day"},g={id:"daily7",label:"Daily at 7am",cron:"0 7 * * *",cadence:"once/day"},w={id:"weekly",label:"Weekly (Mon 9am)",cron:"0 9 * * 1",cadence:"once/week"},T={id:"nightly",label:"Nightly at 11pm",cron:"0 23 * * *",cadence:"once/day"},k={id:"twice",label:"Twice daily (7am + 7pm)",cron:"0 7,19 * * *",cadence:"2 runs/day"},C=[{id:"research-digest",icon:"📰",title:"Daily research digest",blurb:"Scout reads the web on your topic and writes a fresh briefing every morning.",goalTemplate:'Research the latest developments on "{{topic}}" and produce a clear HTML briefing (write_file with a .html extension) with 5 highlights, an inline SVG chart of the most important trend, and clickable source links throughout.',suggestedPlayId:"research",fields:[{key:"topic",label:"Your topic",hint:"What you want a fresh briefing on each morning",defaultValue:"AI agents in business",placeholder:"AI agents in business"}],schedules:[g,k,w],whatItDoes:"Each morning at 7am, Scout searches the web for fresh developments on your topic, reads the top 5 sources end-to-end, and writes a one-page briefing. The briefing lands on your desk as a paper sheet, and the chat thread captures every URL Scout looked at so you can dig in further if anything catches your eye.",accent:{from:"#6366f1",to:"#8b5cf6"}},{id:"inbox-triage",icon:"📬",title:"Inbox triage",blurb:"Sage sorts and summarizes incoming email every few hours so nothing rots.",goalTemplate:'Read my inbox and produce a triaged summary: "needs reply within 24h", "informational", "newsletters", and "junk". Cap at 30 messages per run.',suggestedPlayId:"inbox",fields:[],schedules:[f,v,g],whatItDoes:"Sage opens your inbox, classifies up to 30 recent threads into four buckets (urgent / informational / newsletters / junk), and pins the urgent ones to the desk as sticky notes. The full triage lands as a paper sheet you can scan in under a minute.",accent:{from:"#06b6d4",to:"#0ea5e9"}},{id:"code-review",icon:"🔍",title:"Overnight code review",blurb:"Builder reviews your repo changes while you sleep. Wakes you to nothing-pings only.",goalTemplate:"Review the diff in {{repoPath}} since the last review. Flag bugs, regressions, and obvious improvements. Don't nitpick formatting.",suggestedPlayId:"code-review",fields:[{key:"repoPath",label:"Repo path or URL",hint:"Local path on the host, or a GitHub repo URL",defaultValue:"~/Desktop/MyProject",placeholder:"~/projects/repo"}],schedules:[T,k],whatItDoes:"Every night at 11pm, Builder pulls the latest changes from your repo and writes a concise review focused on real defects (logic bugs, regressions, security smells). Formatting nits are skipped. Findings land as a paper sheet; if there's nothing to report, Builder closes silently.",accent:{from:"#22c55e",to:"#10b981"}},{id:"lead-scout",icon:"🎯",title:"Lead scout",blurb:"Scout watches freelance + opportunity boards and surfaces matches for your skills.",goalTemplate:'Scan Upwork, Indeed, and HackerNews "who is hiring" for new postings matching: {{skills}}. Filter to budget >= ${{minBudget}} and remote OK.',suggestedPlayId:"lead-scout",fields:[{key:"skills",label:"Skills to match",hint:"Comma-separated keywords. Scout fuzzy-matches.",defaultValue:"TypeScript, Node.js, AI agents",placeholder:"React, Python, design"},{key:"minBudget",label:"Minimum budget (USD)",hint:"Skip postings paying less.",defaultValue:"500"}],schedules:[f,v,g],whatItDoes:"Every few hours, Scout sweeps the boards you care about for postings that match your skill keywords and budget floor. New matches land as sticky notes; the running log of every posting seen sits as a paper sheet you can browse anytime.",accent:{from:"#f59e0b",to:"#eab308"}},{id:"market-watch",icon:"📈",title:"Market watch",blurb:"Analyst tracks tickers + crypto and writes a brief if anything moves >3%.",goalTemplate:"Check the latest price + 24h move for: {{tickers}}. If any moved more than 3% (up or down) since the last run, produce an HTML brief (write_file with a .html extension) with a sparkline SVG per ticker and a one-paragraph explanation with 2 source links.",suggestedPlayId:"analyst",fields:[{key:"tickers",label:"Tickers / coins",hint:"Comma-separated. Stocks or crypto.",defaultValue:"BTC, ETH, NVDA, AAPL",placeholder:"TSLA, SPY, BTC"}],schedules:[I,f,v],whatItDoes:"Each cycle, Analyst pulls the latest price and 24-hour move for every ticker you listed. If anything jumped or dropped more than 3%, it writes a one-paragraph explanation with 2 source links. Quiet runs close silently — your desk only fills up when something actually moved.",accent:{from:"#ef4444",to:"#f97316"}},{id:"creative-prompts",icon:"🎨",title:"Daily creative prompt",blurb:"Writer hands you a fresh creative writing or music prompt every morning with breakfast.",goalTemplate:"Generate a fresh {{discipline}} prompt for me today. Make it specific enough to start in 5 minutes but open enough to take in any direction. Include a 1-line warm-up exercise.",fields:[{key:"discipline",label:"Discipline",hint:"What kind of prompt you want.",defaultValue:"songwriting",placeholder:"short fiction · songwriting · sketching"}],schedules:[g,w],whatItDoes:"Every morning, Writer hands you one fresh creative prompt tailored to the discipline you chose, with a quick warm-up exercise to get the engine started. The prompt lands as a sticky note on the desk so you can grab it on the way to your studio.",accent:{from:"#ec4899",to:"#8b5cf6"}}];function A(s,i){return s.goalTemplate.replace(/\{\{(\w+)\}\}/g,(n,r)=>{const o=i[r];return o&&o.trim().length>0?o.trim():r})}const E=["Plan my mom's 70th birthday party","Write a thank-you note to my landlord","Summarize this long email I got","Draft the Q1 investor update","Review a code change"];function M(){const[s,i]=d.useState(""),[n,r]=d.useState(!1),[o,h]=d.useState(null),[p,l]=d.useState(null),b=N();async function x(a,u){const m=a.trim();if(!(!m||n)){r(!0),h(null);try{const{mission:c}=await S(m,u);b(`/mission/${c.id}`)}catch(c){h(c.message),r(!1)}}}return e.jsxs("div",{className:"fixed inset-0 flex flex-col items-center text-[#f3e9d0] overflow-y-auto",style:{fontFamily:"'Georgia', serif"},children:[e.jsx("div",{className:"pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_50%_15%,rgba(99,102,241,0.18)_0%,transparent_55%)]"}),e.jsxs("div",{className:"relative z-10 flex flex-col items-center gap-5 w-full max-w-5xl px-6 py-10 md:py-16",children:[e.jsxs("div",{className:"text-[11px] uppercase tracking-[0.3em] text-text-muted flex items-center gap-3",children:[e.jsxs("span",{children:[e.jsx("span",{className:"bg-gradient-to-r from-accent to-accent2 bg-clip-text text-transparent font-bold",children:"TITAN"})," · ","MISSION CHAT"]}),e.jsx("button",{onClick:()=>b("/mission/library"),className:"px-2 py-0.5 text-[10px] tracking-[0.18em] text-text-muted hover:text-text border border-border rounded-full transition-colors",title:"See your past missions",children:"Past missions →"}),e.jsx("button",{onClick:()=>b("/space/home"),className:"px-2 py-0.5 text-[10px] tracking-[0.18em] text-text-muted hover:text-text border border-border rounded-full transition-colors inline-flex items-center gap-1",title:"Back to the canvas spaces",children:"🌌 Canvas"})]}),e.jsx("h1",{className:"text-4xl md:text-5xl font-semibold tracking-tight text-center",children:"What do you want done?"}),e.jsxs("p",{className:"text-text-secondary text-center max-w-xl",children:["Tell me anything — a thank-you note, a birthday plan, a Q1 report. I'll put together a small ",e.jsx("span",{className:"text-text font-medium",children:"team of AI helpers"})," and we'll chat as we go."]}),e.jsxs("form",{onSubmit:a=>{a.preventDefault(),x(s)},className:"w-full max-w-3xl flex items-center gap-3 bg-bg-secondary/80 border border-border rounded-2xl px-4 py-3 backdrop-blur-md shadow-[0_20px_60px_rgba(0,0,0,0.4)]",children:[e.jsx("input",{autoFocus:!0,value:s,onChange:a=>i(a.target.value),placeholder:"Try: Help me write a birthday speech for my mom",className:"flex-1 bg-transparent outline-none text-text placeholder:text-text-muted/60 text-base px-1 py-2",disabled:n}),e.jsxs("button",{type:"button",disabled:!0,title:"Voice is coming next release",className:"relative w-10 h-10 rounded-full bg-bg-tertiary border border-border text-text-muted opacity-50 cursor-not-allowed flex items-center justify-center",children:["🎤",e.jsx("span",{className:"absolute -bottom-4 left-1/2 -translate-x-1/2 text-[9px] uppercase tracking-widest text-text-muted",children:"soon"})]}),e.jsx("button",{type:"submit",disabled:!s.trim()||n,className:"px-4 py-2 rounded-xl font-bold text-bg-deep bg-gradient-to-br from-accent to-accent2 shadow-[0_0_24px_rgba(99,102,241,0.5)] disabled:opacity-50 disabled:cursor-not-allowed",children:n?"Forming…":"Begin"})]}),o&&e.jsx("div",{className:"text-error text-sm bg-error/10 border border-error/30 rounded-lg px-3 py-2",children:o}),e.jsxs("div",{className:"flex flex-wrap gap-2 justify-center max-w-2xl",children:[e.jsx("div",{className:"w-full text-center text-[10px] uppercase tracking-widest text-text-muted mb-1",children:"or one-shot examples"}),E.map(a=>e.jsx("button",{type:"button",onClick:()=>x(a),disabled:n,className:"px-3 py-2 text-xs text-text-secondary bg-bg-secondary/60 border border-border rounded-full hover:text-text hover:border-border-light transition-colors disabled:opacity-50",children:a},a))]}),e.jsxs("div",{className:"w-full mt-10 flex flex-col gap-3",children:[e.jsxs("div",{className:"flex items-baseline justify-between border-b border-border pb-2",children:[e.jsxs("h2",{className:"text-lg font-semibold tracking-tight",children:["Always-on templates",e.jsx("span",{className:"ml-2 text-[10px] uppercase tracking-widest text-text-muted",children:"recurring missions"})]}),e.jsx("span",{className:"text-[11px] text-text-muted",children:"click → 3 steps → launch"})]}),e.jsx("p",{className:"text-text-secondary text-sm max-w-2xl",children:"Pick a starter recipe, customize it, choose how often the team should run it, and TITAN keeps the agents on schedule. Each template walks you through three quick steps."}),e.jsx("div",{className:"grid gap-3 md:grid-cols-2 lg:grid-cols-3 mt-2",children:C.map(a=>e.jsx(L,{template:a,onClick:()=>l(a)},a.id))})]})]}),p&&e.jsx(D,{template:p,onClose:()=>l(null),onLaunch:async(a,u,m)=>{try{const c=JSON.parse(localStorage.getItem("titan-pending-schedules")??"[]");c.push({at:new Date().toISOString(),templateId:p.id,goal:a,scheduleId:u}),localStorage.setItem("titan-pending-schedules",JSON.stringify(c))}catch{}l(null),await x(a,m)}})]})}function L({template:s,onClick:i}){return e.jsxs("button",{type:"button",onClick:i,className:"text-left p-4 bg-bg-secondary/70 border border-border rounded-2xl hover:border-border-light hover:bg-bg-secondary transition-all relative overflow-hidden group",children:[e.jsx("div",{className:"absolute inset-x-0 top-0 h-1 opacity-80 group-hover:h-1.5 transition-all",style:{background:`linear-gradient(90deg, ${s.accent.from}, ${s.accent.to})`}}),e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"text-2xl leading-none",children:s.icon}),e.jsx("span",{className:"font-semibold text-sm text-text",children:s.title})]}),e.jsx("p",{className:"text-xs text-text-secondary leading-snug mb-3",children:s.blurb}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[s.schedules.slice(0,2).map(n=>e.jsx("span",{className:"text-[10px] px-2 py-0.5 rounded-full bg-bg-tertiary/60 border border-border text-text-muted",children:n.label},n.id)),e.jsx("span",{className:"ml-auto text-[10px] uppercase tracking-widest text-text-muted opacity-0 group-hover:opacity-100 transition-opacity",children:"Set up →"})]})]})}function D({template:s,onClose:i,onLaunch:n}){const[r,o]=d.useState(1),[h,p]=d.useState(()=>Object.fromEntries(s.fields.map(t=>[t.key,t.defaultValue]))),[l,b]=d.useState(s.schedules[0]),[x,a]=d.useState(!1),u=A(s,h),m=r!==1||s.fields.every(t=>(h[t.key]??"").trim().length>0);async function c(){if(!x){a(!0);try{await n(u,l.id,s.suggestedPlayId)}finally{a(!1)}}}return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-bg-deep/80 backdrop-blur-sm p-4 md:p-8",onClick:i,children:e.jsxs("div",{className:"relative w-full max-w-2xl bg-bg-secondary border border-border rounded-2xl overflow-hidden flex flex-col shadow-2xl",onClick:t=>t.stopPropagation(),children:[e.jsx("div",{className:"h-1",style:{background:`linear-gradient(90deg, ${s.accent.from}, ${s.accent.to})`}}),e.jsxs("div",{className:"flex items-center gap-3 px-5 py-3 border-b border-border",children:[e.jsx("span",{className:"text-2xl leading-none",children:s.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"font-semibold text-sm truncate",children:s.title}),e.jsxs("div",{className:"text-[11px] text-text-muted",children:["Step ",r," of 3 · ",r===1?"Customize":r===2?"Schedule":"Launch"]})]}),e.jsx("button",{onClick:i,className:"w-8 h-8 rounded-full bg-bg-tertiary border border-border text-text-muted hover:text-text flex items-center justify-center text-sm",title:"Close",children:"✕"})]}),e.jsx("div",{className:"px-5 py-2 flex items-center gap-2 border-b border-border/60",children:[1,2,3].map(t=>e.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${t<=r?"bg-gradient-to-r from-accent to-accent2":"bg-bg-tertiary"}`},t))}),e.jsxs("div",{className:"p-5 max-h-[60vh] overflow-y-auto",children:[r===1&&e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"text-sm text-text-secondary",children:s.blurb}),s.fields.length===0&&e.jsxs("div",{className:"text-sm text-text-muted italic",children:["This template runs as-is — no setup needed. Click ",e.jsx("b",{className:"text-text",children:"Next"})," to pick a schedule."]}),s.fields.map(t=>e.jsxs("label",{className:"flex flex-col gap-1.5",children:[e.jsx("span",{className:"text-xs uppercase tracking-widest text-text-muted",children:t.label}),e.jsx("input",{value:h[t.key]??"",onChange:y=>p(j=>({...j,[t.key]:y.target.value})),placeholder:t.placeholder??t.defaultValue,className:"px-3 py-2 bg-bg-tertiary border border-border rounded-lg text-sm text-text outline-none focus:border-accent"}),t.hint&&e.jsx("span",{className:"text-[11px] text-text-muted",children:t.hint})]},t.key)),e.jsxs("div",{className:"mt-2 px-3 py-2.5 bg-bg-tertiary/50 border border-border/60 rounded-lg",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-widest text-text-muted mb-1",children:"Preview goal"}),e.jsx("div",{className:"text-sm text-text leading-snug",children:u})]})]}),r===2&&e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx("div",{className:"text-sm text-text-secondary",children:"How often should the team run this?"}),s.schedules.map(t=>{const y=t.id===l.id;return e.jsxs("button",{onClick:()=>b(t),className:`flex items-center justify-between p-3 rounded-xl border text-left transition-colors ${y?"bg-accent/10 border-accent/60 text-text":"bg-bg-tertiary/40 border-border text-text-secondary hover:text-text hover:border-border-light"}`,children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-semibold text-sm",children:t.label}),e.jsx("span",{className:"text-[11px] text-text-muted",children:t.cadence})]}),e.jsx("code",{className:"text-[10px] font-mono text-text-muted",children:t.cron})]},t.id)}),e.jsx("div",{className:"text-[11px] text-text-muted italic px-1 pt-1",children:"The auto-fire daemon that re-runs missions on this cadence lands in the next ship. Today the first run starts immediately and the chosen schedule is remembered."})]}),r===3&&e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx("div",{className:"text-sm text-text-secondary",children:"Quick recap before we kick off."}),e.jsxs("div",{className:"rounded-xl border border-border bg-bg-tertiary/40 p-4",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-widest text-text-muted mb-1",children:"What I'll do"}),e.jsx("div",{className:"text-sm text-text leading-relaxed",children:s.whatItDoes})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 text-[12px]",children:[e.jsxs("div",{className:"bg-bg-tertiary/40 border border-border rounded-lg p-3",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-widest text-text-muted mb-1",children:"Goal"}),e.jsx("div",{className:"text-text leading-snug",children:u})]}),e.jsxs("div",{className:"bg-bg-tertiary/40 border border-border rounded-lg p-3",children:[e.jsx("div",{className:"text-[10px] uppercase tracking-widest text-text-muted mb-1",children:"Cadence"}),e.jsx("div",{className:"text-text font-semibold",children:l.label}),e.jsx("div",{className:"text-text-muted text-[11px] mt-0.5",children:l.cadence})]})]})]})]}),e.jsxs("div",{className:"px-5 py-3 border-t border-border flex items-center justify-between bg-bg/40",children:[e.jsx("button",{onClick:()=>r>1?o(t=>t-1):i(),className:"px-4 py-2 text-sm text-text-secondary hover:text-text",children:r>1?"← Back":"Cancel"}),r<3?e.jsx("button",{onClick:()=>o(t=>t+1),disabled:!m,className:"px-5 py-2 rounded-lg font-bold text-bg-deep bg-gradient-to-br from-accent to-accent2 disabled:opacity-50 text-sm",children:"Next →"}):e.jsx("button",{onClick:c,disabled:x,className:"px-5 py-2 rounded-lg font-bold text-bg-deep bg-gradient-to-br from-accent to-accent2 disabled:opacity-50 text-sm",children:x?"Launching…":"Launch first run 🚀"})]})]})})}export{M as default};
@@ -1 +0,0 @@
1
- import{r as d,j as e,m}from"./index-slWylU2o.js";import{A as x,m as n}from"./proxy-BAUTNyg6.js";const b={sm:"max-w-sm",md:"max-w-lg",lg:"max-w-2xl"};function u({open:s,onClose:a,title:i,children:c,footer:r,size:o="md"}){const t=d.useCallback(l=>{l.key==="Escape"&&a()},[a]);return d.useEffect(()=>{if(s)return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[s,t]),e.jsx(x,{children:s&&e.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh]",children:[e.jsx(n.div,{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:a,initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15}}),e.jsxs(n.div,{className:m("relative w-full mx-4 rounded-xl border border-border bg-bg-secondary shadow-2xl",b[o]),initial:{opacity:0,y:-16,scale:.97},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-16,scale:.97},transition:{duration:.2,ease:"easeOut"},children:[i&&e.jsx("div",{className:"border-b border-border px-5 py-4",children:e.jsx("h2",{className:"text-base font-semibold text-text",children:i})}),e.jsx("div",{className:"px-5 py-4",children:c}),r&&e.jsx("div",{className:"flex items-center justify-end gap-2 border-t border-border px-5 py-3",children:r})]})]})})}export{u as M};
@@ -1 +0,0 @@
1
- import{r as c,b as f,j as e,C as U,h as K,Z as O,A as E,f as B,a8 as G,ag as T}from"./index-slWylU2o.js";import{R as D}from"./terminal-CdhfA0Kr.js";import{S as L}from"./save-D2Qh8KyN.js";import{C as V}from"./circle-check-big-DPz64kZW.js";import{E as $}from"./external-link-BgxGF7ZQ.js";import{S as M}from"./search-C9SdcZJq.js";import{E as F}from"./eye-off-CYR4nH5I.js";import{E as H}from"./TitanCanvas-DCl3gxSl.js";import"./chevron-up-D6g7FB6i.js";import"./plus-O61rB_YF.js";import"./users-BX_ZaByZ.js";import"./wrench-Cfp7nYhG.js";import"./network-v9O7MmZT.js";import"./rotate-ccw-n5WkWR51.js";import"./send-DZ_5M5QQ.js";import"./VoiceOverlay-B08Sw918.js";import"./chevron-right-aFDDgFsL.js";import"./chevron-down-CM11GPpR.js";import"./folder-DY4eeMdo.js";import"./clock-BbCCaukN.js";import"./check-BcOm5jPO.js";import"./shield-check-DyP5PmaY.js";import"./loader-circle-E8aLxmMz.js";const _={enabled:!1,apiKey:"",cuopt:{enabled:!1,url:"http://localhost:5000"},asr:{enabled:!1,grpcUrl:"localhost:50051",healthUrl:"http://localhost:9000"},openshell:{enabled:!1,binaryPath:"openshell",policyPath:""}};function y({status:s}){const l={unknown:"bg-border-light",checking:"bg-[#eab308] animate-pulse",healthy:"bg-success",unhealthy:"bg-error"},d={unknown:"Not checked",checking:"Checking...",healthy:"Healthy",unhealthy:"Unreachable"};return e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs text-text-muted",children:[e.jsx("span",{className:`inline-block h-2 w-2 rounded-full ${l[s]}`}),d[s]]})}function v({title:s,description:l,icon:d,enabled:i,onToggle:h,children:p}){return e.jsxs("div",{className:`rounded-xl border bg-bg-secondary transition-colors ${i?"border-[#76b900]/30":"border-bg-tertiary"}`,children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`flex h-9 w-9 items-center justify-center rounded-lg ${i?"bg-nvidia/15":"bg-bg-tertiary"}`,children:e.jsx(d,{className:`h-4.5 w-4.5 ${i?"text-nvidia":"text-text-muted"}`})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium text-text",children:s}),e.jsx("p",{className:"text-xs text-text-muted mt-0.5",children:l})]})]}),e.jsx("button",{onClick:h,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${i?"bg-nvidia":"bg-border"}`,children:e.jsx("span",{className:`inline-block h-4 w-4 rounded-full bg-white transition-transform ${i?"translate-x-6":"translate-x-1"}`})})]}),i&&e.jsx("div",{className:"border-t border-bg-tertiary px-5 py-4 space-y-3",children:p})]})}function u({id:s,label:l,value:d,onChange:i,placeholder:h,type:p="text",secret:x=!1}){const[m,b]=c.useState(!1);return e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs text-text-muted",children:l}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{id:s,name:s,type:x&&!m?"password":p,value:d,onChange:n=>i(n.target.value),placeholder:h,className:"w-full rounded-lg border border-border bg-bg px-3 py-2 pr-10 text-sm text-text outline-none focus:border-[#76b900] transition-colors"}),x&&e.jsx("button",{type:"button",onClick:()=>b(!m),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-text-muted hover:text-text-secondary",children:m?e.jsx(F,{className:"h-4 w-4"}):e.jsx(H,{className:"h-4 w-4"})})]})]})}function ue(){const[s,l]=c.useState(_),[d,i]=c.useState(!0),[h,p]=c.useState(!1),[x,m]=c.useState(null),[b,n]=c.useState({cuopt:"unknown",asr:"unknown",nim:"unknown"}),[g,j]=c.useState(!1),N=c.useCallback((t,a)=>{m({type:t,message:a}),setTimeout(()=>m(null),3e3)},[]);c.useEffect(()=>{(async()=>{var a,o,w,S,k,A,I,C;try{const r=await G();r.nvidia&&(l({enabled:r.nvidia.enabled??!1,apiKey:"",cuopt:{enabled:((a=r.nvidia.cuopt)==null?void 0:a.enabled)??!1,url:((o=r.nvidia.cuopt)==null?void 0:o.url)??"http://localhost:5000"},asr:{enabled:((w=r.nvidia.asr)==null?void 0:w.enabled)??!1,grpcUrl:((S=r.nvidia.asr)==null?void 0:S.grpcUrl)??"localhost:50051",healthUrl:((k=r.nvidia.asr)==null?void 0:k.healthUrl)??"http://localhost:9000"},openshell:{enabled:((A=r.nvidia.openshell)==null?void 0:A.enabled)??!1,binaryPath:((I=r.nvidia.openshell)==null?void 0:I.binaryPath)??"openshell",policyPath:((C=r.nvidia.openshell)==null?void 0:C.policyPath)??""}}),j(r.nvidia.apiKeySet??!1))}catch{}finally{i(!1)}})()},[]);const P=c.useCallback(async()=>{if(s.cuopt.enabled){n(t=>({...t,cuopt:"checking"}));try{const a=await(await f("/api/nvidia/health/cuopt")).json();n(o=>({...o,cuopt:a.healthy?"healthy":"unhealthy"}))}catch{n(t=>({...t,cuopt:"unhealthy"}))}}if(s.asr.enabled){n(t=>({...t,asr:"checking"}));try{const a=await(await f("/api/nvidia/health/asr")).json();n(o=>({...o,asr:a.healthy?"healthy":"unhealthy"}))}catch{n(t=>({...t,asr:"unhealthy"}))}}if(g||s.apiKey){n(t=>({...t,nim:"checking"}));try{const a=await(await f("/api/nvidia/health/nim")).json();n(o=>({...o,nim:a.healthy?"healthy":"unhealthy"}))}catch{n(t=>({...t,nim:"unhealthy"}))}}},[s.cuopt.enabled,s.asr.enabled,g,s.apiKey]),R=async()=>{p(!0);try{const t={nvidia:{enabled:s.enabled,cuopt:s.cuopt,asr:s.asr,openshell:s.openshell}};s.apiKey&&(t.nvidia.apiKey=s.apiKey),await T(t),N("success","NVIDIA configuration saved"),s.apiKey&&(j(!0),l(a=>({...a,apiKey:""})))}catch(t){N("error",t instanceof Error?t.message:"Failed to save")}finally{p(!1)}};return d?e.jsx("div",{className:"space-y-4",children:Array.from({length:4}).map((t,a)=>e.jsx("div",{className:"h-20 animate-pulse rounded-xl border border-border bg-bg-secondary"},a))}):e.jsxs("div",{className:"space-y-6 max-w-3xl",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-xl bg-nvidia/15",children:e.jsx(U,{className:"h-5 w-5 text-nvidia"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-text",children:"NVIDIA"}),e.jsx("p",{className:"text-xs text-text-muted",children:"GPU-accelerated AI services — NIM, cuOpt, Nemotron-ASR, OpenShell"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:P,className:"flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs text-text-secondary hover:bg-bg-tertiary transition-colors",children:[e.jsx(D,{className:"h-3.5 w-3.5"}),"Check Health"]}),e.jsxs("button",{onClick:R,disabled:h,className:"flex items-center gap-2 rounded-lg bg-nvidia px-4 py-1.5 text-xs font-medium text-black transition-colors hover:bg-nvidia/80 disabled:opacity-50",children:[e.jsx(L,{className:"h-3.5 w-3.5"}),h?"Saving...":"Save"]})]})]}),x&&e.jsxs("div",{className:`flex items-center gap-2 rounded-lg border px-4 py-2 text-sm ${x.type==="success"?"border-success/50 text-success":"border-error/50 text-error"}`,children:[x.type==="success"?e.jsx(V,{className:"h-4 w-4"}):e.jsx(K,{className:"h-4 w-4"}),x.message]}),e.jsx("div",{className:`rounded-xl border p-5 transition-colors ${s.enabled?"border-[#76b900]/30 bg-nvidia/5":"border-bg-tertiary bg-bg-secondary"}`,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-medium text-text",children:"Enable NVIDIA Skills"}),e.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["Load NVIDIA GPU-accelerated skills (cuOpt, AI-Q Research, etc.) when TITAN starts. Equivalent to setting ",e.jsx("code",{className:"text-nvidia/70 bg-nvidia/10 px-1 rounded",children:"TITAN_NVIDIA=1"})]})]}),e.jsx("button",{onClick:()=>l(t=>({...t,enabled:!t.enabled})),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${s.enabled?"bg-nvidia":"bg-border"}`,children:e.jsx("span",{className:`inline-block h-4 w-4 rounded-full bg-white transition-transform ${s.enabled?"translate-x-6":"translate-x-1"}`})})]})}),e.jsxs("div",{className:"rounded-xl border border-bg-tertiary bg-bg-secondary p-5 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(O,{className:"h-4 w-4 text-nvidia"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium text-text",children:"NVIDIA NIM API"}),e.jsx("p",{className:"text-xs text-text-muted mt-0.5",children:"Cloud inference for Nemotron 3 Super and other NIM models"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(y,{status:b.nim}),g&&e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-success/10 px-2.5 py-0.5 text-xs font-medium text-success",children:[e.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-success"}),"Key configured"]})]})]}),e.jsx(u,{id:"nvidia-api-key",label:"API Key",value:s.apiKey,onChange:t=>l(a=>({...a,apiKey:t})),placeholder:g?"(configured — enter new key to replace)":"nvapi-...",secret:!0}),e.jsxs("p",{className:"text-[10px] text-text-muted",children:["Get your key at"," ",e.jsxs("a",{href:"https://build.nvidia.com",target:"_blank",rel:"noopener noreferrer",className:"text-nvidia hover:underline inline-flex items-center gap-0.5",children:["build.nvidia.com ",e.jsx($,{className:"h-2.5 w-2.5"})]})]})]}),e.jsxs(v,{title:"cuOpt Optimization",description:"GPU-accelerated routing, scheduling, and mathematical programming (MILP/LP/QP)",icon:E,enabled:s.cuopt.enabled,onToggle:()=>l(t=>({...t,cuopt:{...t.cuopt,enabled:!t.cuopt.enabled}})),children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-xs text-text-muted",children:"Service Status"}),e.jsx(y,{status:b.cuopt})]}),e.jsx(u,{id:"nvidia-cuopt-url",label:"cuOpt Server URL",value:s.cuopt.url,onChange:t=>l(a=>({...a,cuopt:{...a.cuopt,url:t}})),placeholder:"http://localhost:5000"}),e.jsxs("p",{className:"text-[10px] text-text-muted",children:["Start cuOpt: ",e.jsx("code",{className:"bg-bg-tertiary px-1.5 py-0.5 rounded text-text-secondary",children:"docker compose -f docker-compose.nvidia.yml --profile cuopt up -d"})]})]}),e.jsxs(v,{title:"Nemotron-ASR Streaming",description:"NVIDIA speech recognition with 24ms median finalization — replaces faster-whisper for voice chat",icon:M,enabled:s.asr.enabled,onToggle:()=>l(t=>({...t,asr:{...t.asr,enabled:!t.asr.enabled}})),children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-xs text-text-muted",children:"Service Status"}),e.jsx(y,{status:b.asr})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(u,{id:"nvidia-asr-grpc-url",label:"gRPC Address",value:s.asr.grpcUrl,onChange:t=>l(a=>({...a,asr:{...a.asr,grpcUrl:t}})),placeholder:"localhost:50051"}),e.jsx(u,{id:"nvidia-asr-health-url",label:"Health Check URL",value:s.asr.healthUrl,onChange:t=>l(a=>({...a,asr:{...a.asr,healthUrl:t}})),placeholder:"http://localhost:9000"})]}),e.jsxs("p",{className:"text-[10px] text-text-muted",children:["Start ASR: ",e.jsx("code",{className:"bg-bg-tertiary px-1.5 py-0.5 rounded text-text-secondary",children:"docker compose -f docker-compose.nvidia.yml --profile asr up -d"})]}),e.jsxs("p",{className:"text-[10px] text-text-muted",children:["VRAM: ~3-4 GB. Set ",e.jsx("code",{className:"bg-bg-tertiary px-1 rounded text-text-secondary",children:"STT_ENGINE=nemotron-asr"})," in voice agent env."]})]}),e.jsxs(v,{title:"OpenShell Sandbox",description:"NVIDIA secure sandbox runtime for code execution with declarative policy enforcement",icon:B,enabled:s.openshell.enabled,onToggle:()=>l(t=>({...t,openshell:{...t.openshell,enabled:!t.openshell.enabled}})),children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(u,{id:"nvidia-openshell-binary-path",label:"Binary Path",value:s.openshell.binaryPath,onChange:t=>l(a=>({...a,openshell:{...a.openshell,binaryPath:t}})),placeholder:"openshell"}),e.jsx(u,{id:"nvidia-openshell-policy-path",label:"Policy File Path (optional)",value:s.openshell.policyPath,onChange:t=>l(a=>({...a,openshell:{...a.openshell,policyPath:t}})),placeholder:"Auto-detected"})]}),e.jsxs("p",{className:"text-[10px] text-text-muted",children:["When enabled, code execution uses OpenShell instead of Docker. Set ",e.jsx("code",{className:"bg-bg-tertiary px-1 rounded text-text-secondary",children:'sandbox.engine: "openshell"'})," in config."]})]}),e.jsxs("div",{className:"rounded-xl border border-bg-tertiary bg-bg-secondary p-5",children:[e.jsx("h3",{className:"text-sm font-medium text-text mb-3",children:"VRAM Budget (RTX 5090, 32 GB)"}),e.jsxs("div",{className:"space-y-2",children:[[{label:"Nemotron 3 Nano 30B",vram:"~24 GB",note:"Full local inference"},{label:"Nemotron 3 Nano 4B",vram:"~3 GB",note:"Lightweight variant"},{label:"Nemotron-ASR",vram:"~3-4 GB",note:"Speech recognition"},{label:"cuOpt",vram:"~2-4 GB",note:"Optimization solver"}].map(({label:t,vram:a,note:o})=>e.jsxs("div",{className:"flex items-center justify-between py-1.5",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-xs text-text",children:t}),e.jsx("span",{className:"text-[10px] text-text-muted ml-2",children:o})]}),e.jsx("span",{className:"text-xs font-mono text-nvidia",children:a})]},t)),e.jsx("div",{className:"border-t border-bg-tertiary pt-2 mt-2",children:e.jsx("p",{className:"text-[10px] text-text-muted",children:"Recommended: Nano 4B + ASR + cuOpt = ~10 GB, leaving room for other models. Or use NIM cloud API for LLM inference (0 GB local)."})})]})]}),e.jsxs("div",{className:"rounded-xl border border-bg-tertiary bg-bg-secondary p-5",children:[e.jsx("h3",{className:"text-sm font-medium text-text mb-2",children:"Quick Start"}),e.jsxs("div",{className:"space-y-2 text-xs text-text-muted",children:[e.jsx("p",{children:"Start all NVIDIA services:"}),e.jsx("code",{className:"block bg-bg border border-bg-tertiary rounded-lg px-3 py-2 text-text-secondary font-mono text-xs",children:"docker compose -f docker-compose.nvidia.yml --profile all up -d"}),e.jsx("p",{className:"mt-2",children:"Or start individual services:"}),e.jsxs("div",{className:"space-y-1 font-mono text-[10px] text-text-muted",children:[e.jsxs("p",{children:[e.jsx("span",{className:"text-nvidia",children:"cuopt:"})," --profile cuopt"]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-nvidia",children:"asr:"})," --profile asr (includes Riva bridge)"]}),e.jsxs("p",{children:[e.jsx("span",{className:"text-nvidia",children:"voice:"})," --profile voice (ASR + bridge)"]})]})]})]})]})}export{ue as default};
@@ -1 +0,0 @@
1
- import{r as l,j as e,Z as u,A as v,H as x,C as f,aV as h}from"./index-slWylU2o.js";import{S as s}from"./StatCard-DT4Bx1mY.js";import{P as n}from"./PageHeader-llOXO43Z.js";import{S as g}from"./SkeletonLoader-BkQoZllJ.js";import{C as j}from"./clock-BbCCaukN.js";import{M as b}from"./users-BX_ZaByZ.js";import{b as y}from"./TitanCanvas-DCl3gxSl.js";import{L as S}from"./layers-Bn7bgu2Z.js";import"./chevron-right-aFDDgFsL.js";import"./chevron-up-D6g7FB6i.js";import"./plus-O61rB_YF.js";import"./wrench-Cfp7nYhG.js";import"./network-v9O7MmZT.js";import"./terminal-CdhfA0Kr.js";import"./save-D2Qh8KyN.js";import"./rotate-ccw-n5WkWR51.js";import"./search-C9SdcZJq.js";import"./send-DZ_5M5QQ.js";import"./VoiceOverlay-B08Sw918.js";import"./chevron-down-CM11GPpR.js";import"./folder-DY4eeMdo.js";import"./check-BcOm5jPO.js";import"./shield-check-DyP5PmaY.js";import"./external-link-BgxGF7ZQ.js";import"./loader-circle-E8aLxmMz.js";function w(t){const r=Math.floor(t/86400),a=Math.floor(t%86400/3600),i=Math.floor(t%3600/60);return r>0?`${r}d ${a}h ${i}m`:a>0?`${a}h ${i}m`:`${i}m`}function c(t){const r=t/1024/1024;return r>1024?`${(r/1024).toFixed(1)} GB`:`${r.toFixed(0)} MB`}function Q(){const[t,r]=l.useState(null),[a,i]=l.useState(null),[d,p]=l.useState(!0),m=async()=>{try{const o=await h();r(o),i(null)}catch(o){i(o instanceof Error?o.message:"Failed to fetch stats")}finally{p(!1)}};return l.useEffect(()=>{m();const o=setInterval(m,1e4);return()=>clearInterval(o)},[]),d?e.jsxs("div",{className:"space-y-4 md:space-y-6",children:[e.jsx(n,{title:"System Overview",breadcrumbs:[{label:"Admin",href:"/overview"},{label:"Monitoring"},{label:"Overview"}]}),e.jsx("div",{className:"grid grid-cols-2 gap-3 lg:grid-cols-4",children:e.jsx(g,{variant:"metric",count:8})})]}):a?e.jsx("div",{className:"rounded-xl border border-error/50 bg-bg-secondary p-6 text-center text-error",children:a}):t?e.jsxs("div",{className:"space-y-4 md:space-y-6",children:[e.jsx(n,{title:"System Overview",subtitle:"Real-time system health and metrics",breadcrumbs:[{label:"Admin",href:"/overview"},{label:"Monitoring"},{label:"Overview"}]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 lg:grid-cols-4",children:[e.jsx(s,{title:"Uptime",value:w(t.uptime),icon:e.jsx(j,{className:"h-5 w-5"})}),e.jsx(s,{title:"Total Requests",value:t.totalRequests.toLocaleString(),icon:e.jsx(u,{className:"h-5 w-5"})}),e.jsx(s,{title:"Active Agents",value:t.activeAgents,icon:e.jsx(v,{className:"h-5 w-5"})}),e.jsx(s,{title:"Active Sessions",value:t.activeSessions,icon:e.jsx(b,{className:"h-5 w-5"})}),e.jsx(s,{title:"Memory Usage",value:c(t.memoryUsage.heapUsed),icon:e.jsx(x,{className:"h-5 w-5"}),subtitle:`${c(t.memoryUsage.heapTotal)} total`}),e.jsx(s,{title:"Model",value:t.model,icon:e.jsx(f,{className:"h-5 w-5"})}),e.jsx(s,{title:"Provider",value:t.provider,icon:e.jsx(y,{className:"h-5 w-5"})}),e.jsx(s,{title:"Version",value:t.version,icon:e.jsx(S,{className:"h-5 w-5"})})]})]}):null}export{Q as default};
@@ -1 +0,0 @@
1
- import{r as t,b4 as x,j as e,b5 as h,b6 as f}from"./index-slWylU2o.js";import{P as u}from"./PageHeader-llOXO43Z.js";import{R as b}from"./terminal-CdhfA0Kr.js";import{B as g}from"./TitanCanvas-DCl3gxSl.js";import{P as j}from"./play-DbCJhc5H.js";import{T as N}from"./trash-2-TQcEJEv4.js";import"./chevron-right-aFDDgFsL.js";import"./chevron-up-D6g7FB6i.js";import"./plus-O61rB_YF.js";import"./users-BX_ZaByZ.js";import"./wrench-Cfp7nYhG.js";import"./network-v9O7MmZT.js";import"./save-D2Qh8KyN.js";import"./rotate-ccw-n5WkWR51.js";import"./search-C9SdcZJq.js";import"./send-DZ_5M5QQ.js";import"./VoiceOverlay-B08Sw918.js";import"./chevron-down-CM11GPpR.js";import"./folder-DY4eeMdo.js";import"./clock-BbCCaukN.js";import"./check-BcOm5jPO.js";import"./shield-check-DyP5PmaY.js";import"./external-link-BgxGF7ZQ.js";import"./loader-circle-E8aLxmMz.js";function M(){const[o,m]=t.useState([]),[i,r]=t.useState(!0),[n,c]=t.useState(null),a=t.useCallback(async()=>{r(!0);try{const s=await x();m(s.recipes||[])}catch{}r(!1)},[]);t.useEffect(()=>{a()},[a]);const d=async s=>{c(s);try{await h(s)}catch{}c(null)},p=async s=>{if(confirm("Delete this recipe?"))try{await f(s),await a()}catch{}};return e.jsxs("div",{className:"space-y-4",children:[e.jsx(u,{title:"Recipe Kitchen",breadcrumbs:[{label:"Admin",href:"/overview"},{label:"Tools"},{label:"Recipes"}]}),e.jsx("div",{className:"flex gap-2",children:e.jsxs("button",{onClick:a,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(b,{className:`w-4 h-4 ${i?"animate-spin":""}`})," Refresh"]})}),e.jsx("div",{className:"space-y-2",children:o.map(s=>{var l;return 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 min-w-0",children:[e.jsx(g,{className:"w-4 h-4 text-[#6366f1] shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-sm text-[#e4e4e7] truncate",children:s.name}),e.jsx("div",{className:"text-xs text-[#52525b] truncate",children:s.description}),e.jsxs("div",{className:"text-xs text-[#52525b]",children:[s.steps.length," steps • ",(l=s.tags)==null?void 0:l.join(", ")]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsxs("button",{onClick:()=>d(s.id),disabled:n===s.id,className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-md bg-[#6366f1] text-white text-xs hover:bg-[#4f46e5] disabled:opacity-50",children:[e.jsx(j,{className:"w-3.5 h-3.5"})," ",n===s.id?"Running...":"Run"]}),e.jsx("button",{onClick:()=>p(s.id),className:"p-1.5 rounded-md bg-[#27272a] text-[#a1a1aa] hover:bg-[#3f3f46] hover:text-red-400",children:e.jsx(N,{className:"w-3.5 h-3.5"})})]})]},s.id)})})]})}export{M as default};
@@ -1 +0,0 @@
1
- import{r as a,a8 as Je,b as u,j as e,A as he,h as We,C as Ge,Z as be,k as Ve,ag as He}from"./index-slWylU2o.js";import{a as Pe,S as ge,R as Ke}from"./TitanCanvas-DCl3gxSl.js";import{R as k,T as Ue}from"./terminal-CdhfA0Kr.js";import{C as je}from"./circle-check-big-DPz64kZW.js";import{C as Ze}from"./clock-BbCCaukN.js";import{T as ze}from"./trophy-DUF8Bcas.js";import{T as fe}from"./trending-up-Cw22bM4J.js";import{W as Xe,B as Ye}from"./wrench-Cfp7nYhG.js";import{C as I}from"./chevron-down-CM11GPpR.js";import{C as Q}from"./chevron-right-aFDDgFsL.js";import{P as ye}from"./play-DbCJhc5H.js";import{T as et}from"./trash-2-TQcEJEv4.js";import"./chevron-up-D6g7FB6i.js";import"./plus-O61rB_YF.js";import"./users-BX_ZaByZ.js";import"./network-v9O7MmZT.js";import"./save-D2Qh8KyN.js";import"./rotate-ccw-n5WkWR51.js";import"./search-C9SdcZJq.js";import"./send-DZ_5M5QQ.js";import"./VoiceOverlay-B08Sw918.js";import"./folder-DY4eeMdo.js";import"./check-BcOm5jPO.js";import"./shield-check-DyP5PmaY.js";import"./external-link-BgxGF7ZQ.js";import"./loader-circle-E8aLxmMz.js";const D={prompts:"System Prompts","tool-selection":"Tool Selection","response-quality":"Response Quality","error-recovery":"Error Recovery"},J=[{label:"Once daily (2am)",value:["0 2 * * *"]},{label:"Twice daily (2am + 2pm)",value:["0 2 * * *","0 14 * * *"]},{label:"Three times (2am + 10am + 6pm)",value:["0 2 * * *","0 10 * * *","0 18 * * *"]}];function Ne({status:j}){const B={running:"bg-info/10 text-info",completed:"bg-success/10 text-success",failed:"bg-error/10 text-error",training:"bg-warning/10 text-warning",deployed:"bg-purple/10 text-purple"},f={running:"bg-info",completed:"bg-success",failed:"bg-error",training:"bg-warning",deployed:"bg-purple"};return e.jsxs("span",{className:`inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-medium ${B[j]||"bg-border-light/20 text-text-muted"}`,children:[e.jsx("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${f[j]||"bg-border-light"}`}),j]})}function Rt(){var me,pe;const[j,B]=a.useState(null),[f,ve]=a.useState([]),[W,we]=a.useState([]),[h,Se]=a.useState([]),[r,ke]=a.useState(null),[Ce,Re]=a.useState(!0),[C,G]=a.useState(null),[R,V]=a.useState(null),[A,_e]=a.useState(!1),[N,Te]=a.useState(!0),[i,H]=a.useState("tool_router"),[E,Me]=a.useState(!1),[p,v]=a.useState({baseModel:"unsloth/Qwen2.5-32B-bnb-4bit",loraRank:32,learningRate:1e-4,epochs:2,timeBudgetMin:60,maxSeqLength:2048}),[b,$e]=a.useState([]),[x,De]=a.useState(null),[P,K]=a.useState(!1),[U,Z]=a.useState(!1),[z,X]=a.useState(!1),[g,Y]=a.useState([]),[S,Be]=a.useState(!0),[Ae,_]=a.useState(!1),L=a.useRef(null),O=a.useRef(null),ee=a.useRef(null),[F,te]=a.useState(1),[T,se]=a.useState(30),[q,ae]=a.useState(120),[M,re]=a.useState(!1),[$,ne]=a.useState(!1),[le,ie]=a.useState([]),[xe,ce]=a.useState(0),m=a.useCallback((t,s)=>{V({type:t,message:s}),setTimeout(()=>V(null),3e3)},[]),y=a.useCallback(async()=>{try{const s=(await Je()).selfImprove||{};B(s),te(s.runsPerDay||1),se(s.budgetMinutes||30),ae(s.maxDailyBudgetMinutes||120),re(s.autoApply||!1),ne(s.pauseOnWeekends||!1),ie(s.areas||["prompts","tool-selection","response-quality","error-recovery"]);const c=s.schedule||["0 2 * * *"],o=J.findIndex(n=>JSON.stringify(n.value)===JSON.stringify(c));ce(o>=0?o:0);try{const n=await u("/api/self-improve/history");if(n.ok){const d=await n.json();ve(d.sessions||[])}}catch{}try{const n=await u("/api/training/runs");if(n.ok){const d=await n.json();we(d.runs||[])}}catch{}try{const[n,d]=await Promise.all([u("/api/autoresearch/results"),u("/api/autoresearch/performance")]);if(n.ok){const l=await n.json();Se(l.runs||[])}if(d.ok){const l=await d.json();ke(l)}}catch{}try{const[n,d]=await Promise.all([u("/api/autoresearch/results?type=agent"),u("/api/autoresearch/performance?type=agent")]);if(n.ok){const l=await n.json();$e(l.runs||[])}if(d.ok){const l=await d.json();De(l)}}catch{}}catch{}finally{Re(!1)}},[]);a.useEffect(()=>{y()},[y]),a.useEffect(()=>(N&&(L.current=setInterval(y,1e4)),()=>{L.current&&clearInterval(L.current)}),[N,y]),a.useEffect(()=>{const t=new EventSource("/api/training/stream");return ee.current=t,t.onopen=()=>_(!0),t.onerror=()=>_(!1),t.onmessage=s=>{try{const c=JSON.parse(s.data);if(c.type==="connected"){_(!0);return}Y(o=>{const n=[...o,c];return n.length>200?n.slice(-200):n})}catch{}},()=>{t.close(),ee.current=null,_(!1)}},[]),a.useEffect(()=>{O.current&&S&&O.current.scrollIntoView({behavior:"smooth"})},[g,S]);const Ee=a.useCallback(async()=>{try{await u("/api/training/progress",{method:"DELETE"}),Y([])}catch{}},[]),Le=async()=>{var t;try{await He({selfImprove:{runsPerDay:F,budgetMinutes:T,maxDailyBudgetMinutes:q,autoApply:M,pauseOnWeekends:$,areas:le,schedule:((t=J[xe])==null?void 0:t.value)||["0 2 * * *"]}}),m("success","Self-improvement settings saved"),await y()}catch(s){m("error",s instanceof Error?s.message:"Failed to save")}},de=async t=>{G(t);try{(await u("/api/message",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:`Run a self-improvement experiment on ${t} using self_improve_start with area="${t}" and budgetMinutes=${T}`,sessionId:"self-improve"})})).ok?(m("success",`Self-improvement started for ${D[t]||t}`),setTimeout(y,2e3)):m("error","Failed to start self-improvement")}catch(s){m("error",s instanceof Error?s.message:"Failed to start")}finally{G(null)}},Oe=t=>{ie(s=>s.includes(t)?s.filter(c=>c!==t):[...s,t])},Fe=async()=>{K(!0);try{(await u("/api/autoresearch/generate-data",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:i})})).ok?m("success",`Training data generation started for ${i==="main_agent"?"Main Agent":"Tool Router"}`):m("error","Failed to start data generation")}catch(t){m("error",t instanceof Error?t.message:"Failed")}finally{K(!1)}},qe=async()=>{Z(!0);try{(await u("/api/autoresearch/trigger",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:i,config:p})})).ok?m("success",`Training started for ${i==="main_agent"?"Main Agent":"Tool Router"}`):m("error","Failed to start training")}catch(t){m("error",t instanceof Error?t.message:"Failed")}finally{Z(!1)}},Ie=async()=>{X(!0);try{(await u("/api/autoresearch/deploy",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:i})})).ok?m("success",`Model deployed as ${i==="main_agent"?"titan-agent":"titan-qwen"}`):m("error","Failed to deploy model")}catch(t){m("error",t instanceof Error?t.message:"Failed")}finally{X(!1)}};if(Ce)return e.jsx("div",{className:"space-y-4",children:Array.from({length:3}).map((t,s)=>e.jsx("div",{className:"h-20 animate-pulse rounded-xl border border-border bg-bg-secondary"},s))});const w=f.length,oe=w>0?(f.reduce((t,s)=>t+(s.bestScore-s.baselineScore),0)/w).toFixed(1):"0",Qe=w>0?(f.filter(t=>t.bestScore>t.baselineScore).length/w*100).toFixed(0):"0";return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-purple/10",children:e.jsx(Pe,{className:"h-4 w-4 text-purple-light"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-text",children:"Self-Improvement"}),e.jsx("p",{className:"text-xs text-text-muted",children:"Autonomous optimization of prompts, tool selection, and response quality"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>Te(!N),className:`flex items-center gap-1.5 rounded-lg border px-3 py-1.5 text-xs transition-colors ${N?"border-success/30 text-success bg-success/5":"border-border text-text-muted hover:bg-bg-tertiary"}`,children:[e.jsx(he,{className:`h-3.5 w-3.5 ${N?"animate-pulse":""}`}),N?"Live":"Paused"]}),e.jsxs("button",{onClick:y,className:"flex items-center gap-1.5 rounded-lg border border-border px-3 py-1.5 text-xs text-text-secondary transition-colors hover:bg-bg-tertiary",children:[e.jsx(k,{className:"h-3.5 w-3.5"}),"Refresh"]})]})]}),R&&e.jsxs("div",{className:`flex items-center gap-2 rounded-lg border px-4 py-2 text-sm ${R.type==="success"?"border-success/50 text-success":"border-error/50 text-error"}`,children:[R.type==="success"?e.jsx(je,{className:"h-4 w-4"}):e.jsx(We,{className:"h-4 w-4"}),R.message]}),e.jsxs("div",{className:"grid grid-cols-4 gap-3",children:[e.jsxs("div",{className:"rounded-xl border border-bg-tertiary bg-bg-secondary p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Ze,{className:"h-3.5 w-3.5 text-text-muted"}),e.jsx("p",{className:"text-xs text-text-muted",children:"Total Sessions"})]}),e.jsx("p",{className:"text-2xl font-bold text-text",children:w+((r==null?void 0:r.totalRuns)||0)}),r&&r.totalRuns>0&&e.jsxs("p",{className:"text-[10px] text-text-muted mt-0.5",children:[w," self-improve + ",r.totalRuns," autoresearch"]})]}),e.jsxs("div",{className:"rounded-xl border border-bg-tertiary bg-bg-secondary p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(ze,{className:"h-3.5 w-3.5 text-warning"}),e.jsx("p",{className:"text-xs text-text-muted",children:"Best Val Score"})]}),e.jsx("p",{className:"text-2xl font-bold text-warning",children:(r==null?void 0:r.bestScore)||"—"}),r&&r.baseline>0&&(()=>{const t=r.bestScore-r.baseline,s=t>=0?"+":"",c=t>=0?"text-success":"text-error";return e.jsxs("p",{className:`text-[10px] mt-0.5 ${c}`,children:[s,t.toFixed(1)," from ",r.baseline," baseline"]})})()]}),e.jsxs("div",{className:"rounded-xl border border-bg-tertiary bg-bg-secondary p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(fe,{className:"h-3.5 w-3.5 text-success"}),e.jsx("p",{className:"text-xs text-text-muted",children:"Success Rate"})]}),e.jsxs("p",{className:"text-2xl font-bold text-info",children:[Qe,"%"]}),e.jsxs("p",{className:"text-[10px] text-text-muted mt-0.5",children:["avg improvement: ",Number(oe)>=0?"+":"",oe]})]}),e.jsxs("div",{className:"rounded-xl border border-bg-tertiary bg-bg-secondary p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(Ge,{className:"h-3.5 w-3.5 text-purple"}),e.jsx("p",{className:"text-xs text-text-muted",children:"Deployed Model"})]}),e.jsx("p",{className:"text-lg font-bold text-purple",children:"titan-qwen"}),e.jsxs("p",{className:"text-[10px] text-text-muted mt-0.5",children:["Q4_K_M • 19GB • ",(j==null?void 0:j.enabled)!==!1?"🟢 Active":"⚫ Off"]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-text-muted mb-3",children:"Model Training"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 mb-4",children:[e.jsxs("button",{onClick:()=>H("tool_router"),className:`rounded-xl border p-4 text-left transition-all ${i==="tool_router"?"border-purple bg-purple/5 ring-1 ring-purple/20":"border-bg-tertiary bg-bg-secondary hover:border-border"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:`flex h-7 w-7 items-center justify-center rounded-lg ${i==="tool_router"?"bg-purple/20":"bg-bg-tertiary"}`,children:e.jsx(Xe,{className:`h-3.5 w-3.5 ${i==="tool_router"?"text-purple-light":"text-text-muted"}`})}),e.jsx("span",{className:`text-sm font-medium ${i==="tool_router"?"text-text":"text-text-secondary"}`,children:"Tool Router"})]}),e.jsx("p",{className:"text-xs text-text-muted mb-1",children:"titan-qwen"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs text-success font-medium",children:["Score: ",(r==null?void 0:r.bestScore)||"—"]}),e.jsx("span",{className:"text-[10px] text-text-muted",children:"•"}),e.jsx("span",{className:"text-[10px] text-text-muted",children:h.length>0?`${((me=h[h.length-1])==null?void 0:me.num_examples)||0} examples`:"No data"})]}),e.jsx("p",{className:"text-[10px] text-text-muted mt-1",children:"Brain / Tool Selection"})]}),e.jsxs("button",{onClick:()=>H("main_agent"),className:`rounded-xl border p-4 text-left transition-all ${i==="main_agent"?"border-purple bg-purple/5 ring-1 ring-purple/20":"border-bg-tertiary bg-bg-secondary hover:border-border"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("div",{className:`flex h-7 w-7 items-center justify-center rounded-lg ${i==="main_agent"?"bg-purple/20":"bg-bg-tertiary"}`,children:e.jsx(Ye,{className:`h-3.5 w-3.5 ${i==="main_agent"?"text-purple-light":"text-text-muted"}`})}),e.jsx("span",{className:`text-sm font-medium ${i==="main_agent"?"text-text":"text-text-secondary"}`,children:"Main Agent"})]}),e.jsx("p",{className:"text-xs text-text-muted mb-1",children:"titan-agent"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs text-warning font-medium",children:["Score: ",(x==null?void 0:x.bestScore)||"—"]}),e.jsx("span",{className:"text-[10px] text-text-muted",children:"•"}),e.jsx("span",{className:"text-[10px] text-text-muted",children:b.length>0?`${((pe=b[b.length-1])==null?void 0:pe.num_examples)||0} examples`:"No data"})]}),e.jsx("p",{className:"text-[10px] text-text-muted mt-1",children:"Primary LLM / Full Agent"})]})]}),e.jsxs("button",{onClick:()=>Me(!E),className:"flex w-full items-center gap-2 text-xs font-medium uppercase tracking-wider text-text-muted mb-3",children:[E?e.jsx(I,{className:"h-3.5 w-3.5"}):e.jsx(Q,{className:"h-3.5 w-3.5"}),e.jsx(ge,{className:"h-3.5 w-3.5"}),"Training Configuration"]}),E&&e.jsxs("div",{className:"rounded-xl border border-bg-tertiary bg-bg-secondary p-5 space-y-4 mb-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs text-text-muted",children:"Base Model"}),e.jsxs("select",{id:"train-base-model",name:"train-base-model",value:p.baseModel,onChange:t=>v(s=>({...s,baseModel:t.target.value})),className:"w-full rounded-lg border border-border bg-bg px-3 py-2 text-sm text-text outline-none",children:[e.jsx("option",{value:"unsloth/Qwen2.5-32B-bnb-4bit",children:"Qwen 2.5 32B (4-bit)"}),e.jsx("option",{value:"unsloth/Qwen2.5-14B-bnb-4bit",children:"Qwen 2.5 14B (4-bit)"}),e.jsx("option",{value:"unsloth/Qwen2.5-7B-bnb-4bit",children:"Qwen 2.5 7B (4-bit)"})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-xs text-text-muted",children:"LoRA Rank"}),e.jsx("span",{className:"text-sm font-medium text-text",children:p.loraRank})]}),e.jsx("input",{id:"train-lora-rank",name:"train-lora-rank",type:"range",min:4,max:64,step:4,value:p.loraRank,onChange:t=>v(s=>({...s,loraRank:Number(t.target.value)})),className:"w-full accent-purple"}),e.jsxs("div",{className:"flex justify-between text-[10px] text-text-muted mt-1",children:[e.jsx("span",{children:"4"}),e.jsx("span",{children:"32"}),e.jsx("span",{children:"64"})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-xs text-text-muted",children:"Learning Rate"}),e.jsx("span",{className:"text-sm font-medium text-text font-mono",children:p.learningRate.toExponential(0)})]}),e.jsx("input",{id:"train-learning-rate",name:"train-learning-rate",type:"range",min:-5,max:-3,step:.5,value:Math.log10(p.learningRate),onChange:t=>v(s=>({...s,learningRate:Math.pow(10,Number(t.target.value))})),className:"w-full accent-purple"}),e.jsxs("div",{className:"flex justify-between text-[10px] text-text-muted mt-1",children:[e.jsx("span",{children:"1e-5"}),e.jsx("span",{children:"1e-4"}),e.jsx("span",{children:"1e-3"})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-xs text-text-muted",children:"Epochs"}),e.jsx("span",{className:"text-sm font-medium text-text",children:p.epochs})]}),e.jsx("input",{id:"train-epochs",name:"train-epochs",type:"range",min:1,max:10,value:p.epochs,onChange:t=>v(s=>({...s,epochs:Number(t.target.value)})),className:"w-full accent-purple"}),e.jsxs("div",{className:"flex justify-between text-[10px] text-text-muted mt-1",children:[e.jsx("span",{children:"1"}),e.jsx("span",{children:"5"}),e.jsx("span",{children:"10"})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-xs text-text-muted",children:"Time Budget"}),e.jsxs("span",{className:"text-sm font-medium text-text",children:[p.timeBudgetMin," min"]})]}),e.jsx("input",{id:"train-time-budget",name:"train-time-budget",type:"range",min:5,max:120,step:5,value:p.timeBudgetMin,onChange:t=>v(s=>({...s,timeBudgetMin:Number(t.target.value)})),className:"w-full accent-purple"}),e.jsxs("div",{className:"flex justify-between text-[10px] text-text-muted mt-1",children:[e.jsx("span",{children:"5 min"}),e.jsx("span",{children:"60 min"}),e.jsx("span",{children:"120 min"})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-xs text-text-muted",children:"Max Sequence Length"}),e.jsx("span",{className:"text-sm font-medium text-text",children:p.maxSeqLength})]}),e.jsx("input",{id:"train-max-seq-length",name:"train-max-seq-length",type:"range",min:512,max:4096,step:256,value:p.maxSeqLength,onChange:t=>v(s=>({...s,maxSeqLength:Number(t.target.value)})),className:"w-full accent-purple"}),e.jsxs("div",{className:"flex justify-between text-[10px] text-text-muted mt-1",children:[e.jsx("span",{children:"512"}),e.jsx("span",{children:"2048"}),e.jsx("span",{children:"4096"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("button",{onClick:Fe,disabled:P,className:"flex items-center justify-center gap-2 rounded-xl border border-bg-tertiary bg-bg-secondary px-4 py-3 text-xs font-medium text-text transition-colors hover:border-purple/50 hover:bg-bg-secondary disabled:opacity-50",children:[P?e.jsx(k,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(be,{className:"h-3.5 w-3.5 text-warning"}),"Generate Training Data"]}),e.jsxs("button",{onClick:qe,disabled:U,className:"flex items-center justify-center gap-2 rounded-xl bg-purple px-4 py-3 text-xs font-medium text-white transition-colors hover:bg-purple/80 disabled:opacity-50",children:[U?e.jsx(k,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(ye,{className:"h-3.5 w-3.5"}),"Start Training"]}),e.jsxs("button",{onClick:Ie,disabled:z,className:"flex items-center justify-center gap-2 rounded-xl border border-bg-tertiary bg-bg-secondary px-4 py-3 text-xs font-medium text-text transition-colors hover:border-success/50 hover:bg-bg-secondary disabled:opacity-50",children:[z?e.jsx(k,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(je,{className:"h-3.5 w-3.5 text-success"}),"Deploy Best Model"]}),e.jsxs("button",{onClick:()=>de(i==="main_agent"?"agent-benchmark":"tool-benchmark"),disabled:C!==null,className:"flex items-center justify-center gap-2 rounded-xl border border-bg-tertiary bg-bg-secondary px-4 py-3 text-xs font-medium text-text transition-colors hover:border-[#3b82f6]/50 hover:bg-bg-secondary disabled:opacity-50",children:[e.jsx(fe,{className:"h-3.5 w-3.5 text-info"}),"Run Benchmark"]})]})]}),e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>Be(!S),className:"flex w-full items-center gap-2 text-xs font-medium uppercase tracking-wider text-text-muted mb-3",children:[S?e.jsx(I,{className:"h-3.5 w-3.5"}):e.jsx(Q,{className:"h-3.5 w-3.5"}),e.jsx(Ue,{className:"h-3.5 w-3.5"}),"Live Training Activity",e.jsxs("span",{className:"ml-auto flex items-center gap-1.5",children:[Ae?e.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-success",children:[e.jsx(Ke,{className:"h-3 w-3 animate-pulse"})," Connected"]}):e.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-error",children:[e.jsx(Ve,{className:"h-3 w-3"})," Disconnected"]}),g.length>0&&e.jsx("span",{className:"rounded-full bg-purple/20 px-1.5 py-0.5 text-[10px] text-purple-light",children:g.length})]})]}),S&&e.jsxs("div",{className:"rounded-xl border border-bg-tertiary bg-bg overflow-hidden",children:[g.length>0&&(()=>{var c,o,n;const t=[...g].reverse().find(d=>{var l;return((l=d.detail)==null?void 0:l.pct)!==void 0});if(!t||t.type==="complete")return null;const s=((c=t.detail)==null?void 0:c.pct)||0;return e.jsxs("div",{className:"border-b border-bg-tertiary px-4 py-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsx("span",{className:"text-xs text-text-secondary",children:t.message}),e.jsxs("span",{className:"text-xs font-medium text-purple",children:[s,"%"]})]}),e.jsx("div",{className:"h-1.5 w-full rounded-full bg-bg-tertiary overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-gradient-to-r from-purple to-accent transition-all duration-500",style:{width:`${s}%`}})}),((o=t.detail)==null?void 0:o.current)!==void 0&&((n=t.detail)==null?void 0:n.total)!==void 0&&e.jsxs("div",{className:"flex items-center justify-between mt-1",children:[e.jsxs("span",{className:"text-[10px] text-text-muted",children:[t.detail.current," / ",t.detail.total," examples"]}),t.detail.category&&e.jsxs("span",{className:"text-[10px] text-text-muted",children:["Category: ",t.detail.category]})]})]})})(),e.jsxs("div",{className:"max-h-64 overflow-y-auto p-3 font-mono text-[11px] leading-5 scrollbar-thin",children:[g.length===0?e.jsxs("div",{className:"flex items-center justify-center py-8 text-text-muted",children:[e.jsx(he,{className:"h-4 w-4 mr-2"}),e.jsx("span",{children:"No training activity yet. Start training to see live progress."})]}):g.map((t,s)=>{var ue;const c={info:"text-info",progress:"text-purple",success:"text-success",error:"text-error",complete:"text-warning",connected:"text-success"},o={info:"●",progress:"◆",success:"✓",error:"✗",complete:"★",connected:"◉"},n=c[t.type]||"text-text-muted",d=o[t.type]||"·",l=t.timestamp?new Date(t.timestamp).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"}):"";return e.jsxs("div",{className:"flex items-start gap-2 hover:bg-bg-secondary/50 rounded px-1",children:[e.jsx("span",{className:"text-border shrink-0 select-none",children:l}),e.jsx("span",{className:`shrink-0 ${n}`,children:d}),e.jsxs("span",{className:`${t.type==="error"?"text-error":"text-text-secondary"}`,children:[t.message,((ue=t.detail)==null?void 0:ue.category)&&t.type==="progress"&&e.jsxs("span",{className:"text-text-muted",children:[" [",t.detail.category,"]"]})]})]},s)}),e.jsx("div",{ref:O})]}),g.length>0&&e.jsxs("div",{className:"border-t border-bg-tertiary px-3 py-2 flex items-center justify-between",children:[e.jsxs("span",{className:"text-[10px] text-text-muted",children:[g.filter(t=>t.type==="success"||t.type==="progress").length," successes"," · ",g.filter(t=>t.type==="error").length," errors"]}),e.jsxs("button",{onClick:Ee,className:"flex items-center gap-1 text-[10px] text-text-muted hover:text-text-secondary transition-colors",children:[e.jsx(et,{className:"h-3 w-3"}),"Clear"]})]})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-text-muted mb-3",children:"Run Now"}),e.jsx("div",{className:"grid grid-cols-2 gap-3",children:Object.entries(D).map(([t,s])=>e.jsxs("button",{onClick:()=>de(t),disabled:C!==null,className:"flex items-center gap-3 rounded-xl border border-bg-tertiary bg-bg-secondary p-4 text-left transition-colors hover:border-purple/50 hover:bg-bg-secondary disabled:opacity-50",children:[e.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-lg bg-purple/10",children:C===t?e.jsx(k,{className:"h-4 w-4 text-purple-light animate-spin"}):e.jsx(ye,{className:"h-4 w-4 text-purple-light"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-text",children:s}),e.jsx("p",{className:"text-xs text-text-muted",children:C===t?"Running...":"Start experiment"})]})]},t))})]}),e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>_e(!A),className:"flex w-full items-center gap-2 text-xs font-medium uppercase tracking-wider text-text-muted mb-3",children:[A?e.jsx(I,{className:"h-3.5 w-3.5"}):e.jsx(Q,{className:"h-3.5 w-3.5"}),e.jsx(ge,{className:"h-3.5 w-3.5"}),"Schedule Settings"]}),A&&e.jsxs("div",{className:"rounded-xl border border-bg-tertiary bg-bg-secondary p-6 space-y-5",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-xs text-text-muted",children:"Runs per day"}),e.jsx("span",{className:"text-sm font-medium text-text",children:F})]}),e.jsx("input",{id:"schedule-runs-per-day",name:"schedule-runs-per-day",type:"range",min:1,max:12,value:F,onChange:t=>te(Number(t.target.value)),className:"w-full accent-purple"}),e.jsxs("div",{className:"flex justify-between text-[10px] text-text-muted mt-1",children:[e.jsx("span",{children:"1"}),e.jsx("span",{children:"6"}),e.jsx("span",{children:"12"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-xs text-text-muted",children:"Schedule"}),e.jsx("select",{id:"schedule-preset",name:"schedule-preset",value:xe,onChange:t=>ce(Number(t.target.value)),className:"w-full rounded-lg border border-border bg-bg px-3 py-2 text-sm text-text outline-none",children:J.map((t,s)=>e.jsx("option",{value:s,children:t.label},s))})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-xs text-text-muted",children:"Budget per run (minutes)"}),e.jsxs("span",{className:"text-sm font-medium text-text",children:[T," min"]})]}),e.jsx("input",{id:"schedule-budget-minutes",name:"schedule-budget-minutes",type:"range",min:5,max:120,step:5,value:T,onChange:t=>se(Number(t.target.value)),className:"w-full accent-purple"}),e.jsxs("div",{className:"flex justify-between text-[10px] text-text-muted mt-1",children:[e.jsx("span",{children:"5 min"}),e.jsx("span",{children:"60 min"}),e.jsx("span",{children:"120 min"})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-xs text-text-muted",children:"Max daily budget (minutes)"}),e.jsxs("span",{className:"text-sm font-medium text-text",children:[q," min"]})]}),e.jsx("input",{id:"schedule-max-daily-budget",name:"schedule-max-daily-budget",type:"range",min:30,max:480,step:30,value:q,onChange:t=>ae(Number(t.target.value)),className:"w-full accent-purple"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-xs text-text-muted",children:"Improvement areas"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Object.entries(D).map(([t,s])=>e.jsx("button",{onClick:()=>Oe(t),className:`rounded-full px-3 py-1 text-xs font-medium transition-colors ${le.includes(t)?"bg-purple text-white":"bg-bg-tertiary text-text-muted hover:text-text-secondary"}`,children:s},t))})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("label",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-text-muted",children:"Auto-apply improvements"}),e.jsx("button",{onClick:()=>re(!M),className:`relative h-5 w-9 rounded-full transition-colors ${M?"bg-purple":"bg-border"}`,children:e.jsx("span",{className:`absolute top-0.5 left-0.5 h-4 w-4 rounded-full bg-white transition-transform ${M?"translate-x-4":""}`})})]}),e.jsxs("label",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-text-muted",children:"Pause on weekends"}),e.jsx("button",{onClick:()=>ne(!$),className:`relative h-5 w-9 rounded-full transition-colors ${$?"bg-purple":"bg-border"}`,children:e.jsx("span",{className:`absolute top-0.5 left-0.5 h-4 w-4 rounded-full bg-white transition-transform ${$?"translate-x-4":""}`})})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{onClick:Le,className:"flex items-center gap-2 rounded-lg bg-purple px-4 py-2 text-xs font-medium text-white transition-colors hover:bg-purple/80",children:"Save Settings"})})]})]}),f.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-text-muted mb-3",children:"Session History"}),e.jsx("div",{className:"rounded-xl border border-bg-tertiary bg-bg-secondary overflow-hidden",children:e.jsxs("table",{className:"w-full text-left text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-bg-tertiary",children:[e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-text-muted",children:"Date"}),e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-text-muted",children:"Area"}),e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-text-muted",children:"Baseline"}),e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-text-muted",children:"Best"}),e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-text-muted",children:"+Δ"}),e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-text-muted",children:"K/D/C"}),e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-text-muted",children:"Status"})]})}),e.jsx("tbody",{children:f.slice().reverse().slice(0,10).map(t=>{const s=t.bestScore-t.baselineScore;return e.jsxs("tr",{className:"border-b border-bg-tertiary last:border-0",children:[e.jsx("td",{className:"px-4 py-2.5 text-xs text-text-secondary",children:t.startedAt.slice(0,10)}),e.jsx("td",{className:"px-4 py-2.5 text-xs text-text",children:D[t.area]||t.area}),e.jsx("td",{className:"px-4 py-2.5 text-xs text-text-muted",children:t.baselineScore}),e.jsx("td",{className:"px-4 py-2.5 text-xs text-text font-medium",children:t.bestScore}),e.jsxs("td",{className:`px-4 py-2.5 text-xs font-medium ${s>0?"text-success":"text-text-muted"}`,children:[s>0?"+":"",s]}),e.jsxs("td",{className:"px-4 py-2.5 text-xs text-text-muted",children:[t.keeps,"/",t.discards,"/",t.crashes]}),e.jsx("td",{className:"px-4 py-2.5",children:e.jsx(Ne,{status:t.applied?"deployed":t.status})})]},t.id)})})]})})]}),W.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-text-muted mb-3",children:"Model Training"}),e.jsx("div",{className:"space-y-2",children:W.slice().reverse().slice(0,5).map(t=>e.jsxs("div",{className:"flex items-center justify-between rounded-xl border border-bg-tertiary bg-bg-secondary px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(be,{className:"h-4 w-4 text-warning"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-text",children:t.id}),e.jsxs("p",{className:"text-xs text-text-muted",children:[t.baseModel," • ",t.dataPoints," samples • ",t.method]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[t.finalLoss!==void 0&&e.jsxs("span",{className:"text-xs text-text-muted",children:["loss: ",t.finalLoss.toFixed(4)]}),e.jsx(Ne,{status:t.status})]})]},t.id))})]}),h.length>0&&i==="tool_router"&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-text-muted mb-3",children:"Autoresearch Experiments — Tool Router"}),e.jsxs("div",{className:"rounded-xl border border-bg-tertiary bg-bg-secondary overflow-hidden",children:[e.jsxs("div",{className:"p-4 border-b border-bg-tertiary",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-xs text-text-muted",children:"Val Score Over Time"}),e.jsxs("span",{className:"text-xs text-success font-medium",children:["Best: ",(r==null?void 0:r.bestScore)||Math.max(...h.map(t=>t.val_score))]})]}),e.jsx("div",{className:"h-16 flex items-end gap-1",children:h.map((t,s)=>{const c=Math.max(...h.map(l=>l.val_score),100),o=Math.min(...h.map(l=>l.val_score),0),n=c-o||1,d=(t.val_score-o)/n*100;return e.jsx("div",{className:"flex-1 rounded-t transition-all hover:opacity-80",style:{height:`${Math.max(d,4)}%`,backgroundColor:(r==null?void 0:r.baseline)!=null?t.val_score>=r.baseline?"var(--color-success)":"var(--color-error)":"var(--color-purple)"},title:`Run ${s+1}: ${t.val_score} (${new Date(t.timestamp).toLocaleDateString()})`},s)})}),e.jsxs("div",{className:"relative mt-1",children:[e.jsx("div",{className:"border-t border-dashed border-border-light/50 absolute w-full"}),e.jsx("span",{className:"text-[9px] text-text-muted relative -top-2",children:(r==null?void 0:r.baseline)!=null?`baseline: ${r.baseline}`:"baseline: —"})]})]}),e.jsxs("table",{className:"w-full text-left text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-bg-tertiary",children:[e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-text-muted",children:"#"}),e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-text-muted",children:"Date"}),e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-text-muted",children:"Score"}),e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-text-muted",children:"LR"}),e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-text-muted",children:"Rank"}),e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-text-muted",children:"Epochs"}),e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-text-muted",children:"Examples"}),e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-text-muted",children:"Duration"})]})}),e.jsx("tbody",{children:h.slice().reverse().slice(0,20).map((t,s)=>e.jsxs("tr",{className:"border-b border-bg-tertiary last:border-0",children:[e.jsx("td",{className:"px-4 py-2.5 text-xs text-text-muted",children:h.length-s}),e.jsx("td",{className:"px-4 py-2.5 text-xs text-text-secondary",children:new Date(t.timestamp).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}),e.jsx("td",{className:`px-4 py-2.5 text-xs font-bold ${t.val_score>=((r==null?void 0:r.baseline)||78)?"text-success":"text-error"}`,children:t.val_score}),e.jsx("td",{className:"px-4 py-2.5 text-xs text-text-muted font-mono",children:t.hyperparams.lr}),e.jsx("td",{className:"px-4 py-2.5 text-xs text-text-muted",children:t.hyperparams.rank}),e.jsx("td",{className:"px-4 py-2.5 text-xs text-text-muted",children:t.hyperparams.epochs}),e.jsx("td",{className:"px-4 py-2.5 text-xs text-text-muted",children:t.num_examples}),e.jsxs("td",{className:"px-4 py-2.5 text-xs text-text-muted",children:[Math.round(t.training_time_s/60),"m ",Math.round(t.training_time_s%60),"s"]})]},s))})]})]})]}),b.length>0&&i==="main_agent"&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-text-muted mb-3",children:"Autoresearch Experiments — Main Agent"}),e.jsxs("div",{className:"rounded-xl border border-bg-tertiary bg-bg-secondary overflow-hidden",children:[e.jsxs("div",{className:"p-4 border-b border-bg-tertiary",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-xs text-text-muted",children:"Val Score Over Time"}),e.jsxs("span",{className:"text-xs text-warning font-medium",children:["Best: ",(x==null?void 0:x.bestScore)||Math.max(...b.map(t=>t.val_score))]})]}),e.jsx("div",{className:"h-16 flex items-end gap-1",children:b.map((t,s)=>{const c=Math.max(...b.map(l=>l.val_score),100),o=Math.min(...b.map(l=>l.val_score),0),n=c-o||1,d=(t.val_score-o)/n*100;return e.jsx("div",{className:"flex-1 rounded-t transition-all hover:opacity-80",style:{height:`${Math.max(d,4)}%`,backgroundColor:(x==null?void 0:x.baseline)!=null?t.val_score>=x.baseline?"var(--color-warning)":"var(--color-error)":"var(--color-purple)"},title:`Run ${s+1}: ${t.val_score} (${new Date(t.timestamp).toLocaleDateString()})`},s)})}),e.jsxs("div",{className:"relative mt-1",children:[e.jsx("div",{className:"border-t border-dashed border-border-light/50 absolute w-full"}),e.jsx("span",{className:"text-[9px] text-text-muted relative -top-2",children:(x==null?void 0:x.baseline)!=null?`baseline: ${x.baseline}`:"baseline: —"})]})]}),e.jsxs("table",{className:"w-full text-left text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-bg-tertiary",children:[e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-text-muted",children:"#"}),e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-text-muted",children:"Date"}),e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-text-muted",children:"Score"}),e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-text-muted",children:"LR"}),e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-text-muted",children:"Rank"}),e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-text-muted",children:"Epochs"}),e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-text-muted",children:"Examples"}),e.jsx("th",{className:"px-4 py-2.5 text-xs font-medium text-text-muted",children:"Duration"})]})}),e.jsx("tbody",{children:b.slice().reverse().slice(0,20).map((t,s)=>e.jsxs("tr",{className:"border-b border-bg-tertiary last:border-0",children:[e.jsx("td",{className:"px-4 py-2.5 text-xs text-text-muted",children:b.length-s}),e.jsx("td",{className:"px-4 py-2.5 text-xs text-text-secondary",children:new Date(t.timestamp).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}),e.jsx("td",{className:`px-4 py-2.5 text-xs font-bold ${t.val_score>=((x==null?void 0:x.baseline)||70)?"text-warning":"text-error"}`,children:t.val_score}),e.jsx("td",{className:"px-4 py-2.5 text-xs text-text-muted font-mono",children:t.hyperparams.lr}),e.jsx("td",{className:"px-4 py-2.5 text-xs text-text-muted",children:t.hyperparams.rank}),e.jsx("td",{className:"px-4 py-2.5 text-xs text-text-muted",children:t.hyperparams.epochs}),e.jsx("td",{className:"px-4 py-2.5 text-xs text-text-muted",children:t.num_examples}),e.jsxs("td",{className:"px-4 py-2.5 text-xs text-text-muted",children:[Math.round(t.training_time_s/60),"m ",Math.round(t.training_time_s%60),"s"]})]},s))})]})]})]})]})}export{Rt as default};
@@ -1 +0,0 @@
1
- import{r as a,j as s,X as k,aW as C,aX as M,aY as L,aZ as E}from"./index-slWylU2o.js";import{P as D}from"./PageHeader-llOXO43Z.js";import"./Input-4pNffAw-.js";import{D as P}from"./DataTable-seaktPzB.js";import{I as A}from"./InlineEditableField-BOLRKQq1.js";import{S as F}from"./search-C9SdcZJq.js";import{T as I}from"./trash-2-TQcEJEv4.js";import"./chevron-right-aFDDgFsL.js";import"./loader-circle-E8aLxmMz.js";import"./check-BcOm5jPO.js";import"./terminal-CdhfA0Kr.js";function z(){const[p,g]=a.useState([]),[b,f]=a.useState(!0),[c,n]=a.useState(null),[o,y]=a.useState(""),[l,i]=a.useState(null),[m,r]=a.useState([]),[j,x]=a.useState(!1),d=async()=>{try{const e=await C();g(e),n(null)}catch(e){n(e instanceof Error?e.message:"Failed to fetch sessions")}finally{f(!1)}};a.useEffect(()=>{d()},[]);const N=async e=>{i(e.id),x(!0);try{const t=await M(e.id);r(t)}catch{r([])}finally{x(!1)}},w=async e=>{try{await E(e),l===e&&(i(null),r([])),await d()}catch(t){n(t instanceof Error?t.message:"Failed to delete session")}},S=p.filter(e=>{var u,h;if(!o)return!0;const t=o.toLowerCase();return e.id.toLowerCase().includes(t)||((u=e.name)==null?void 0:u.toLowerCase().includes(t))||((h=e.lastMessage)==null?void 0:h.toLowerCase().includes(t))}),v=[{key:"id",header:"ID",render:e=>s.jsxs("span",{className:"font-mono text-xs",children:[e.id.slice(0,12),"..."]})},{key:"name",header:"Name",render:e=>s.jsx("span",{className:"text-sm text-text",children:s.jsx(A,{value:e.name??"",onSave:async t=>{await L(e.id,t),await d()},placeholder:"Session name",emptyLabel:"Untitled",hidePencil:!0})})},{key:"messageCount",header:"Messages"},{key:"lastMessage",header:"Last Message",render:e=>s.jsx("span",{className:"block max-w-xs truncate text-text-secondary",children:e.lastMessage??"-"})},{key:"createdAt",header:"Created",render:e=>s.jsx("span",{children:new Date(e.createdAt).toLocaleString()})},{key:"_actions",header:"",className:"w-16",render:e=>s.jsx("button",{onClick:t=>{t.stopPropagation(),w(e.id)},className:"rounded-md p-1.5 text-error transition-colors hover:bg-bg-tertiary",title:"Delete session",children:s.jsx(I,{className:"h-4 w-4"})})}];return b?s.jsx("div",{className:"h-64 animate-pulse rounded-xl border border-border bg-bg-secondary"}):s.jsxs("div",{className:"flex gap-4",children:[s.jsxs("div",{className:`space-y-4 ${l?"flex-1":"w-full"}`,children:[s.jsx(D,{title:"Sessions",breadcrumbs:[{label:"Admin",href:"/overview"},{label:"Monitoring"},{label:"Sessions"}]}),s.jsxs("div",{className:"relative",children:[s.jsx(F,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-text-muted"}),s.jsx("input",{value:o,onChange:e=>y(e.target.value),placeholder:"Search sessions...",className:"w-full rounded-lg border border-border bg-bg py-2 pl-10 pr-3 text-sm text-text outline-none focus:border-accent"})]}),c&&s.jsx("div",{className:"rounded-lg border border-error/50 bg-bg-secondary px-4 py-2 text-sm text-error",children:c}),s.jsx(P,{columns:v,data:S,onRowClick:N,emptyMessage:"No sessions found"})]}),l&&s.jsxs("div",{className:"w-96 shrink-0 rounded-xl border border-border bg-bg-secondary",children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[s.jsx("h3",{className:"text-sm font-medium text-text",children:"Messages"}),s.jsx("button",{onClick:()=>{i(null),r([])},className:"rounded-md p-1 text-text-muted hover:text-text",children:s.jsx(k,{className:"h-4 w-4"})})]}),s.jsx("div",{className:"max-h-[600px] overflow-y-auto p-4",children:j?s.jsx("div",{className:"space-y-3",children:Array.from({length:3}).map((e,t)=>s.jsx("div",{className:"h-12 animate-pulse rounded-lg bg-bg-tertiary"},t))}):m.length===0?s.jsx("p",{className:"text-center text-sm text-text-muted",children:"No messages"}):s.jsx("div",{className:"space-y-3",children:m.map((e,t)=>s.jsxs("div",{className:`rounded-lg p-3 text-sm ${e.role==="user"?"bg-accent/10 text-text":e.role==="assistant"?"bg-bg-tertiary text-text":"bg-bg text-text-secondary"}`,children:[s.jsx("span",{className:"mb-1 block text-xs font-medium uppercase text-text-muted",children:e.role}),s.jsx("p",{className:"whitespace-pre-wrap",children:e.content})]},t))})})]})]})}export{z as default};