@wrongstack/webui 0.296.4 → 0.298.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (532) hide show
  1. package/dist/assets/AgentRosterView-C8j2NuD1.js +11 -0
  2. package/dist/assets/AnalyticsDashboard-D2_HYmYw.js +1 -0
  3. package/dist/assets/AudienceMemoryPanel-SzXptIQj.js +3 -0
  4. package/dist/assets/{ChangesView-W_UTPolz.js → ChangesView-D31wr7_h.js} +1 -1
  5. package/dist/assets/{ChronicleDashboard-BivxCmdl.js → ChronicleDashboard-B7P4f1hr.js} +1 -1
  6. package/dist/assets/{CodeEditor-NAOGCzZS.js → CodeEditor-BRDwx8Y-.js} +1 -1
  7. package/dist/assets/CodeMap-uabWaeJH.js +1 -0
  8. package/dist/assets/{CronJobsPanel-0virGKLS.js → CronJobsPanel-C9shS0P2.js} +1 -1
  9. package/dist/assets/DeadCodeScanPanel-CHud_Ugp.js +2 -0
  10. package/dist/assets/DebugDashboard-DmqpGXnx.js +1 -0
  11. package/dist/assets/{DesignGalleryView-BSBDNBNf.js → DesignGalleryView-CnAHpKa1.js} +1 -1
  12. package/dist/assets/GoalView-DaptZIKr.js +1 -0
  13. package/dist/assets/KanbanView-DA5Ulb8C.js +3 -0
  14. package/dist/assets/MailboxDetailView-CQtHeWVs.js +1 -0
  15. package/dist/assets/MemoryManager-BWuSS0Pg.js +1 -0
  16. package/dist/assets/{ModelPicker-CJBOoZME.js → ModelPicker-Dt0wCi90.js} +1 -1
  17. package/dist/assets/OfficeMapPanel-CUNRI3X7.js +4 -0
  18. package/dist/assets/{ProcessMonitor-d_5Iwyo7.js → ProcessMonitor-Dq760Vqm.js} +1 -1
  19. package/dist/assets/QueuePanel-ZcJliKcY.js +1 -0
  20. package/dist/assets/{RefreshDebugView-gPMro5jy.js → RefreshDebugView-SivBV0LN.js} +1 -1
  21. package/dist/assets/SageTabs-CGrc4PuM.js +2 -0
  22. package/dist/assets/SddHub-oU47Hv8Y.js +2 -0
  23. package/dist/assets/SessionsDashboard-Dp-Mr844.js +1 -0
  24. package/dist/assets/SetupScreen-BWA_dTU0.js +1 -0
  25. package/dist/assets/SkillDetailView-DmRgd_uu.js +3 -0
  26. package/dist/assets/{SpecsView-Bu8xHf5j.js → SpecsView-CzYtHNbj.js} +1 -1
  27. package/dist/assets/TechStackView-p9PKj9pQ.js +1 -0
  28. package/dist/assets/{TerminalPanel-gA6ThdVE.js → TerminalPanel-BRSYloOD.js} +1 -1
  29. package/dist/assets/{Toaster-DTJHnKyl.js → Toaster-Bd6ckyrP.js} +1 -1
  30. package/dist/assets/{activity-CbbZyUMG.js → activity-Bo6DncWg.js} +1 -1
  31. package/dist/assets/{activity-C4z6-WoZ.js → activity-C34aPcFU.js} +1 -1
  32. package/dist/assets/{activity-B4Ngvkan.js → activity-CBdzUJQ_.js} +1 -1
  33. package/dist/assets/{activity-B8uejnae.js → activity-CLYyxeC6.js} +1 -1
  34. package/dist/assets/{activity-qoJ3grs0.js → activity-Cv_EIWjY.js} +1 -1
  35. package/dist/assets/{activity-B5MvPWYV.js → activity-Wr0_Gb8A.js} +1 -1
  36. package/dist/assets/{activity-D57y5l1T.js → activity-kCY0dGRC.js} +1 -1
  37. package/dist/assets/{button-Bmh1yFe5.js → button-Clh96jMK.js} +1 -1
  38. package/dist/assets/chat-store-CWhuSNod.js +17 -0
  39. package/dist/assets/{codemap-activity-store-CkJTt5go.js → codemap-activity-store-C1XWbXeZ.js} +1 -1
  40. package/dist/assets/codemap-index-store-DDT3gP6t.js +1 -0
  41. package/dist/assets/common-BfVFjVhf.js +1 -0
  42. package/dist/assets/common-C5hY-d_0.js +1 -0
  43. package/dist/assets/{dialog-BLr7olIX.js → dialog-DYJUM0p1.js} +1 -1
  44. package/dist/assets/{empty-state-DoEewhfx.js → empty-state-BV-Y8c35.js} +1 -1
  45. package/dist/assets/{i18n-C2VyJ0Kz.js → i18n-DOuSY1L8.js} +2 -2
  46. package/dist/assets/index-C09Opuro.css +1 -0
  47. package/dist/assets/index-DxZTscTk.js +132 -0
  48. package/dist/assets/{input-BRS2rHSR.js → input-CW-Yw2Wu.js} +1 -1
  49. package/dist/assets/{mailbox-store-BN2cGkN_.js → mailbox-store-_8voaug1.js} +1 -1
  50. package/dist/assets/markdown-sSmz-Ua_.js +44 -0
  51. package/dist/assets/{progress-ring-BEsRLdjq.js → progress-ring-DPV94fM-.js} +1 -1
  52. package/dist/assets/{roster-ws-CVCrt_ih.js → roster-ws-q8Cp6us7.js} +1 -1
  53. package/dist/assets/session-store-D4JWBP5w.js +1 -0
  54. package/dist/assets/settings-B9EPDhAL.js +1 -0
  55. package/dist/assets/{settings-DEmKlLmn.js → settings-BBNOO9wC.js} +1 -1
  56. package/dist/assets/settings-BoXoFVdx.js +1 -0
  57. package/dist/assets/settings-CkXKHC77.js +1 -0
  58. package/dist/assets/settings-DWIDXI2K.js +1 -0
  59. package/dist/assets/settings-r_KOGrbF.js +1 -0
  60. package/dist/assets/settings-tyKsHhya.js +1 -0
  61. package/dist/assets/{shared-DYL4K3aB.js → shared-DidGznBo.js} +1 -1
  62. package/dist/assets/stores-CpZiOiOP.js +7 -0
  63. package/dist/assets/ui-store-C-oyG_br.js +1 -0
  64. package/dist/assets/useWebSocket-BTXT0rOW.js +28 -0
  65. package/dist/assets/{utils-DzRQUvln.js → utils-DxDx8yib.js} +1 -1
  66. package/dist/assets/{vendor-9hC4n4Me.js → vendor-BTDGplXK.js} +28 -28
  67. package/dist/assets/{view-navigation-BSA3_knE.js → view-navigation-BRtuAwZo.js} +1 -1
  68. package/dist/assets/ws-client-DqIqzkfU.js +1 -0
  69. package/dist/components/ChatInput/refine-panel-host.d.ts +9 -1
  70. package/dist/components/DeadCodeScanPanel/DeadCodeScanPanel.d.ts +1 -3
  71. package/dist/components/PanelSuspense.d.ts +8 -0
  72. package/dist/components/SettingsPanel/DisplaySection.d.ts +20 -0
  73. package/dist/components/UpdateBanner.d.ts +8 -0
  74. package/dist/components/ViewRouter.d.ts +12 -0
  75. package/dist/components/WorkbenchTopbar.d.ts +53 -0
  76. package/dist/components/codemap-model.d.ts +2 -0
  77. package/dist/hooks/useViewport.d.ts +38 -0
  78. package/dist/hooks/useWebSocket.d.ts +1 -0
  79. package/dist/hooks/ws-handlers/files-mailbox-handlers.d.ts +2 -1
  80. package/dist/index.html +24 -25
  81. package/dist/index.js +56726 -55208
  82. package/dist/lib/view-navigation.d.ts +1 -1
  83. package/dist/lib/ws-client.d.ts +16 -8
  84. package/dist/providers.json +10 -0
  85. package/dist/stores/chat-store.d.ts +53 -4
  86. package/dist/stores/config-store.d.ts +0 -2
  87. package/dist/stores/local-prefs.d.ts +20 -0
  88. package/dist/stores/session-store.d.ts +14 -0
  89. package/dist/stores/ui-store.d.ts +8 -1
  90. package/dist/types/client-message.d.ts +1 -0
  91. package/dist/types/connections.d.ts +7 -1
  92. package/dist/types/server-message.d.ts +9 -0
  93. package/dist/types/system.d.ts +4 -0
  94. package/package.json +8 -7
  95. package/dist/App.d.ts.map +0 -1
  96. package/dist/assets/AgentRosterView-DTbg5NoZ.js +0 -11
  97. package/dist/assets/AnalyticsDashboard-Xc8aG4ev.js +0 -1
  98. package/dist/assets/AudienceMemoryPanel-C1mj_XOq.js +0 -3
  99. package/dist/assets/CodeMap-BOhBy8OQ.js +0 -1
  100. package/dist/assets/DeadCodeScanPanel-DHsw8Nn4.js +0 -2
  101. package/dist/assets/DebugDashboard-DYEVc0PA.js +0 -1
  102. package/dist/assets/GoalView-C_wodXvj.js +0 -1
  103. package/dist/assets/KanbanView-D7SKeieE.js +0 -3
  104. package/dist/assets/LazyMarkdown-Bt3iw3ZV.js +0 -3
  105. package/dist/assets/MailboxDetailView-BaFQIyhC.js +0 -1
  106. package/dist/assets/MemoryManager-CWkdwf8F.js +0 -1
  107. package/dist/assets/OfficeMapPanel-BopbmfGN.js +0 -4
  108. package/dist/assets/QueuePanel-DlNF8CUn.js +0 -1
  109. package/dist/assets/SageTabs-yP5fr4lP.js +0 -2
  110. package/dist/assets/SddHub-DjeM7IaL.js +0 -2
  111. package/dist/assets/SessionsDashboard-D7b7aEse.js +0 -1
  112. package/dist/assets/SetupScreen-Dsek43zs.js +0 -1
  113. package/dist/assets/SkillDetailView-DxdqTQ5E.js +0 -3
  114. package/dist/assets/TechStackView--7TPHg0R.js +0 -1
  115. package/dist/assets/chat-store-DaSs2P3S.js +0 -13
  116. package/dist/assets/codemap-index-store-8v-MK2XF.js +0 -1
  117. package/dist/assets/common-D8_r1x8x.js +0 -1
  118. package/dist/assets/common-suUxW9sA.js +0 -1
  119. package/dist/assets/index-3CuRO3-V.css +0 -1
  120. package/dist/assets/index-DSXHr5yP.js +0 -131
  121. package/dist/assets/markdown-L6DLSM7f.js +0 -44
  122. package/dist/assets/session-store-w5G2euPs.js +0 -1
  123. package/dist/assets/settings-C5F2tQ7C.js +0 -1
  124. package/dist/assets/settings-Cdk8i_p6.js +0 -1
  125. package/dist/assets/settings-D6wFOw5n.js +0 -1
  126. package/dist/assets/settings-DCEOkxYE.js +0 -1
  127. package/dist/assets/settings-DsflqNn0.js +0 -1
  128. package/dist/assets/settings-skShEZ2B.js +0 -1
  129. package/dist/assets/stores-hEu6z1qz.js +0 -6
  130. package/dist/assets/ui-store-BI3LH2q8.js +0 -1
  131. package/dist/assets/useWebSocket-Ba38Sknk.js +0 -28
  132. package/dist/assets/ws-client-eyEv8wbm.js +0 -1
  133. package/dist/components/AgentOfficeDetails.d.ts.map +0 -1
  134. package/dist/components/AgentOfficeView/model.d.ts.map +0 -1
  135. package/dist/components/AgentOfficeView.d.ts.map +0 -1
  136. package/dist/components/AgentRosterCatalogTab.d.ts.map +0 -1
  137. package/dist/components/AgentRosterChrome.d.ts.map +0 -1
  138. package/dist/components/AgentRosterLiveTab.d.ts.map +0 -1
  139. package/dist/components/AgentRosterSelfLearningTab.d.ts.map +0 -1
  140. package/dist/components/AgentRosterView.d.ts.map +0 -1
  141. package/dist/components/AgentRuntimePolicyEditor.d.ts.map +0 -1
  142. package/dist/components/AgentTranscript.d.ts.map +0 -1
  143. package/dist/components/AgentsMonitor.d.ts.map +0 -1
  144. package/dist/components/AgentsPage/format.d.ts.map +0 -1
  145. package/dist/components/AgentsPage.d.ts.map +0 -1
  146. package/dist/components/AnalyticsDashboard.d.ts.map +0 -1
  147. package/dist/components/AudienceMemoryPanel.d.ts.map +0 -1
  148. package/dist/components/AutonomyPicker.d.ts.map +0 -1
  149. package/dist/components/AvailabilityCalendarEditor.d.ts.map +0 -1
  150. package/dist/components/BoardView.d.ts.map +0 -1
  151. package/dist/components/ChangesView.d.ts.map +0 -1
  152. package/dist/components/ChatInput/code-detect.d.ts.map +0 -1
  153. package/dist/components/ChatInput/draft-token-counter.d.ts.map +0 -1
  154. package/dist/components/ChatInput/file-mention-picker.d.ts.map +0 -1
  155. package/dist/components/ChatInput/image-attach-control.d.ts.map +0 -1
  156. package/dist/components/ChatInput/image-attachments.d.ts.map +0 -1
  157. package/dist/components/ChatInput/queued-messages.d.ts.map +0 -1
  158. package/dist/components/ChatInput/refine-panel-host.d.ts.map +0 -1
  159. package/dist/components/ChatInput/slash-commands.d.ts.map +0 -1
  160. package/dist/components/ChatInput/slash-popup.d.ts.map +0 -1
  161. package/dist/components/ChatInput/slash-routing.d.ts.map +0 -1
  162. package/dist/components/ChatInput/stop-controls.d.ts.map +0 -1
  163. package/dist/components/ChatInput/use-paste-drop.d.ts.map +0 -1
  164. package/dist/components/ChatInput.d.ts.map +0 -1
  165. package/dist/components/ChatView/ThinkingBubble.d.ts.map +0 -1
  166. package/dist/components/ChatView/index.d.ts.map +0 -1
  167. package/dist/components/ChatView/utils.d.ts.map +0 -1
  168. package/dist/components/ChatView.d.ts.map +0 -1
  169. package/dist/components/CheckpointTimeline.d.ts.map +0 -1
  170. package/dist/components/ChipMultiSelect.d.ts.map +0 -1
  171. package/dist/components/ChronicleDashboard.d.ts.map +0 -1
  172. package/dist/components/ChroniclePipelineStrip.d.ts.map +0 -1
  173. package/dist/components/CodeEditor.d.ts.map +0 -1
  174. package/dist/components/CodeMap.d.ts.map +0 -1
  175. package/dist/components/CodeMapActivityDrawer.d.ts.map +0 -1
  176. package/dist/components/CodeMapActivityHelpers.d.ts.map +0 -1
  177. package/dist/components/CodeMapActivityStreamPanel.d.ts.map +0 -1
  178. package/dist/components/CodeMapCanvasSurface.d.ts.map +0 -1
  179. package/dist/components/CodeMapCanvasToolbar.d.ts.map +0 -1
  180. package/dist/components/CodeMapConfig.d.ts.map +0 -1
  181. package/dist/components/CodeMapDirectoryTree.d.ts.map +0 -1
  182. package/dist/components/CodeMapFlowState.d.ts.map +0 -1
  183. package/dist/components/CodeMapHeader.d.ts.map +0 -1
  184. package/dist/components/CodeMapLiveOverlay.d.ts.map +0 -1
  185. package/dist/components/CodeMapRelationInspector.d.ts.map +0 -1
  186. package/dist/components/CodeMapRelations.d.ts.map +0 -1
  187. package/dist/components/CodeMapSearchResults.d.ts.map +0 -1
  188. package/dist/components/CodeMapSelectedNodeSummary.d.ts.map +0 -1
  189. package/dist/components/CodeMapTreeSidebar.d.ts.map +0 -1
  190. package/dist/components/CodeMapVisuals.d.ts.map +0 -1
  191. package/dist/components/CollabPanel.d.ts.map +0 -1
  192. package/dist/components/CommandPalette/export-utils.d.ts.map +0 -1
  193. package/dist/components/CommandPalette/index.d.ts.map +0 -1
  194. package/dist/components/CommandPalette.d.ts.map +0 -1
  195. package/dist/components/ConfirmDialog.d.ts.map +0 -1
  196. package/dist/components/ConfirmModal.d.ts.map +0 -1
  197. package/dist/components/ConnectionBanner.d.ts.map +0 -1
  198. package/dist/components/ContextBar.d.ts.map +0 -1
  199. package/dist/components/ContextBreakdownModal.d.ts.map +0 -1
  200. package/dist/components/ContextDashboard.d.ts.map +0 -1
  201. package/dist/components/ContextMemoryMonitor.d.ts.map +0 -1
  202. package/dist/components/ContextModePicker.d.ts.map +0 -1
  203. package/dist/components/CostChip.d.ts.map +0 -1
  204. package/dist/components/CronJobsPanel.d.ts.map +0 -1
  205. package/dist/components/CronTrigger.d.ts.map +0 -1
  206. package/dist/components/CustomRosterPanel.d.ts.map +0 -1
  207. package/dist/components/DeadCodeScanPanel/DeadCodeScanPanel.d.ts.map +0 -1
  208. package/dist/components/DebugDashboard.d.ts.map +0 -1
  209. package/dist/components/DependencyGraph.d.ts.map +0 -1
  210. package/dist/components/DesignGalleryView.d.ts.map +0 -1
  211. package/dist/components/DiffView.d.ts.map +0 -1
  212. package/dist/components/ErrorBoundary.d.ts.map +0 -1
  213. package/dist/components/FallbackEditor.d.ts.map +0 -1
  214. package/dist/components/FileActivityDrawer.d.ts.map +0 -1
  215. package/dist/components/FileExplorer.d.ts.map +0 -1
  216. package/dist/components/FilePicker.d.ts.map +0 -1
  217. package/dist/components/FileReferenceChip.d.ts.map +0 -1
  218. package/dist/components/FleetMonitor.d.ts.map +0 -1
  219. package/dist/components/FleetPanel.d.ts.map +0 -1
  220. package/dist/components/GoalPanel.d.ts.map +0 -1
  221. package/dist/components/GoalView.d.ts.map +0 -1
  222. package/dist/components/InspectorPanel.d.ts.map +0 -1
  223. package/dist/components/KanbanAgentRunPanel.d.ts.map +0 -1
  224. package/dist/components/KanbanBoardChrome.d.ts.map +0 -1
  225. package/dist/components/KanbanBoardSidebar.d.ts.map +0 -1
  226. package/dist/components/KanbanBoardState.d.ts.map +0 -1
  227. package/dist/components/KanbanBoundaryEditor.d.ts.map +0 -1
  228. package/dist/components/KanbanCleanerAlert.d.ts.map +0 -1
  229. package/dist/components/KanbanColumnView.d.ts.map +0 -1
  230. package/dist/components/KanbanDecompositionPanel.d.ts.map +0 -1
  231. package/dist/components/KanbanQueueHealthBar.d.ts.map +0 -1
  232. package/dist/components/KanbanRunControls.d.ts.map +0 -1
  233. package/dist/components/KanbanTaskActivityRecorder.d.ts.map +0 -1
  234. package/dist/components/KanbanTaskCompletionChecks.d.ts.map +0 -1
  235. package/dist/components/KanbanTaskFields.d.ts.map +0 -1
  236. package/dist/components/KanbanTaskInspector.d.ts.map +0 -1
  237. package/dist/components/KanbanTaskOptions.d.ts.map +0 -1
  238. package/dist/components/KanbanTaskTree.d.ts.map +0 -1
  239. package/dist/components/KanbanVerificationDashboard.d.ts.map +0 -1
  240. package/dist/components/KanbanView.d.ts.map +0 -1
  241. package/dist/components/KanbanViewModeTabs.d.ts.map +0 -1
  242. package/dist/components/MailboxDetailView.d.ts.map +0 -1
  243. package/dist/components/MailboxPanel.d.ts.map +0 -1
  244. package/dist/components/MemoryManager/DeleteMemoryDialog.d.ts.map +0 -1
  245. package/dist/components/MemoryManager/MemoryDetail.d.ts.map +0 -1
  246. package/dist/components/MemoryManager/MemoryDrawer.d.ts.map +0 -1
  247. package/dist/components/MemoryManager/MemoryEditor.d.ts.map +0 -1
  248. package/dist/components/MemoryManager/MemoryFilters.d.ts.map +0 -1
  249. package/dist/components/MemoryManager/MemoryGraph.d.ts.map +0 -1
  250. package/dist/components/MemoryManager/MemoryInjectorTrace.d.ts.map +0 -1
  251. package/dist/components/MemoryManager/MemoryLifecycleTrace.d.ts.map +0 -1
  252. package/dist/components/MemoryManager/MemoryList.d.ts.map +0 -1
  253. package/dist/components/MemoryManager/MemoryManagerEmpty.d.ts.map +0 -1
  254. package/dist/components/MemoryManager/SageTabs.d.ts.map +0 -1
  255. package/dist/components/MemoryManager/index.d.ts.map +0 -1
  256. package/dist/components/MemoryManager/selectors.d.ts.map +0 -1
  257. package/dist/components/MemoryManager/shared.d.ts.map +0 -1
  258. package/dist/components/MessageBubble/AttachmentGallery.d.ts.map +0 -1
  259. package/dist/components/MessageBubble/CopyButton.d.ts.map +0 -1
  260. package/dist/components/MessageBubble/ErrorBody.d.ts.map +0 -1
  261. package/dist/components/MessageBubble/LazyMarkdown.d.ts.map +0 -1
  262. package/dist/components/MessageBubble/StreamingMarkdown.d.ts.map +0 -1
  263. package/dist/components/MessageBubble/ToolInputView.d.ts.map +0 -1
  264. package/dist/components/MessageBubble/ToolLedgerCard.d.ts.map +0 -1
  265. package/dist/components/MessageBubble/index.d.ts.map +0 -1
  266. package/dist/components/MessageBubble/utils.d.ts.map +0 -1
  267. package/dist/components/MessageBubble.d.ts.map +0 -1
  268. package/dist/components/ModePicker.d.ts.map +0 -1
  269. package/dist/components/ModelPickDialog.d.ts.map +0 -1
  270. package/dist/components/ModelPicker.d.ts.map +0 -1
  271. package/dist/components/ModelSelectDialog.d.ts.map +0 -1
  272. package/dist/components/MonacoDiffView.d.ts.map +0 -1
  273. package/dist/components/NextStepsBar.d.ts.map +0 -1
  274. package/dist/components/OfficeMapCanvas/CanvasPanels.d.ts.map +0 -1
  275. package/dist/components/OfficeMapCanvas/Hud.d.ts.map +0 -1
  276. package/dist/components/OfficeMapCanvas/Overlays.d.ts.map +0 -1
  277. package/dist/components/OfficeMapCanvas/SelectedNodeDetailPanel.d.ts.map +0 -1
  278. package/dist/components/OfficeMapCanvas/edges.d.ts.map +0 -1
  279. package/dist/components/OfficeMapCanvas/nodes.d.ts.map +0 -1
  280. package/dist/components/OfficeMapCanvas/resolve.d.ts.map +0 -1
  281. package/dist/components/OfficeMapCanvas/use-recently-finished.d.ts.map +0 -1
  282. package/dist/components/OfficeMapCanvas/utils.d.ts.map +0 -1
  283. package/dist/components/OfficeMapCanvas.d.ts.map +0 -1
  284. package/dist/components/OfficeMapPanel.d.ts.map +0 -1
  285. package/dist/components/OfficeMapSettingsPanel.d.ts.map +0 -1
  286. package/dist/components/PhasePanel.d.ts.map +0 -1
  287. package/dist/components/PlanPanel.d.ts.map +0 -1
  288. package/dist/components/ProcessMonitor.d.ts.map +0 -1
  289. package/dist/components/PromptLibraryModal.d.ts.map +0 -1
  290. package/dist/components/ProviderWaitingRoom.d.ts.map +0 -1
  291. package/dist/components/QueuePanel.d.ts.map +0 -1
  292. package/dist/components/QuickModelSwitcher.d.ts.map +0 -1
  293. package/dist/components/QuickModelSwitcher.filter.d.ts.map +0 -1
  294. package/dist/components/RefinePanel.d.ts.map +0 -1
  295. package/dist/components/RefreshDebugView.d.ts.map +0 -1
  296. package/dist/components/SageMemoryCard.d.ts.map +0 -1
  297. package/dist/components/SddActivityFeed.d.ts.map +0 -1
  298. package/dist/components/SddBoardView.d.ts.map +0 -1
  299. package/dist/components/SddDestroyDialog.d.ts.map +0 -1
  300. package/dist/components/SddFlowGraph.d.ts.map +0 -1
  301. package/dist/components/SddHub.d.ts.map +0 -1
  302. package/dist/components/SddKanbanView.d.ts.map +0 -1
  303. package/dist/components/SddTaskDrawer.d.ts.map +0 -1
  304. package/dist/components/SddWizard.d.ts.map +0 -1
  305. package/dist/components/SearchOverlay.d.ts.map +0 -1
  306. package/dist/components/SendButton.d.ts.map +0 -1
  307. package/dist/components/SessionWatchPanel.d.ts.map +0 -1
  308. package/dist/components/SessionsDashboard.d.ts.map +0 -1
  309. package/dist/components/SettingsPanel/BasicSettingsTabs.d.ts.map +0 -1
  310. package/dist/components/SettingsPanel/BrainSection.d.ts.map +0 -1
  311. package/dist/components/SettingsPanel/ChimeraSettingsPanel.d.ts.map +0 -1
  312. package/dist/components/SettingsPanel/ClearAllowlistDialog.d.ts.map +0 -1
  313. package/dist/components/SettingsPanel/ConnectionsHealthSection.d.ts.map +0 -1
  314. package/dist/components/SettingsPanel/FallbacksSection.d.ts.map +0 -1
  315. package/dist/components/SettingsPanel/FleetSection.d.ts.map +0 -1
  316. package/dist/components/SettingsPanel/IntegrationsSection.d.ts.map +0 -1
  317. package/dist/components/SettingsPanel/MCPSection.d.ts.map +0 -1
  318. package/dist/components/SettingsPanel/ModelSection.d.ts.map +0 -1
  319. package/dist/components/SettingsPanel/OAuthLoginSection.d.ts.map +0 -1
  320. package/dist/components/SettingsPanel/PluginToggleList.d.ts.map +0 -1
  321. package/dist/components/SettingsPanel/PreferenceControls.d.ts.map +0 -1
  322. package/dist/components/SettingsPanel/PreferenceToggle.d.ts.map +0 -1
  323. package/dist/components/SettingsPanel/ProviderModelsPanel.d.ts.map +0 -1
  324. package/dist/components/SettingsPanel/ProviderModelsPanel.filter.d.ts.map +0 -1
  325. package/dist/components/SettingsPanel/ProviderSection.d.ts.map +0 -1
  326. package/dist/components/SettingsPanel/RoutingSection.d.ts.map +0 -1
  327. package/dist/components/SettingsPanel/SecuritySection.d.ts.map +0 -1
  328. package/dist/components/SettingsPanel/ShadowSection.d.ts.map +0 -1
  329. package/dist/components/SettingsPanel/ToolsSection.d.ts.map +0 -1
  330. package/dist/components/SettingsPanel/brain-section-options.d.ts.map +0 -1
  331. package/dist/components/SettingsPanel/index.d.ts.map +0 -1
  332. package/dist/components/SettingsPanel/local-presets.d.ts.map +0 -1
  333. package/dist/components/SettingsPanel/official-servers.d.ts.map +0 -1
  334. package/dist/components/SettingsPanel/settings-panel-reducers.d.ts.map +0 -1
  335. package/dist/components/SettingsPanel/undo-send-decision.d.ts.map +0 -1
  336. package/dist/components/SettingsPanel.d.ts.map +0 -1
  337. package/dist/components/SetupScreen/CustomProviderSection.d.ts.map +0 -1
  338. package/dist/components/SetupScreen/ModelEditor.d.ts.map +0 -1
  339. package/dist/components/SetupScreen/ProviderKeyCard.d.ts.map +0 -1
  340. package/dist/components/SetupScreen/key-operation.d.ts.map +0 -1
  341. package/dist/components/SetupScreen/popular-providers.d.ts.map +0 -1
  342. package/dist/components/SetupScreen/relative-time.d.ts.map +0 -1
  343. package/dist/components/SetupScreen/types.d.ts.map +0 -1
  344. package/dist/components/SetupScreen.d.ts.map +0 -1
  345. package/dist/components/ShortcutsOverlay.d.ts.map +0 -1
  346. package/dist/components/SideEffectTimeline.d.ts.map +0 -1
  347. package/dist/components/SidePanel/AgentsPanel.d.ts.map +0 -1
  348. package/dist/components/SidePanel/ChangesPanel.d.ts.map +0 -1
  349. package/dist/components/SidePanel/DesignStudioPanel.d.ts.map +0 -1
  350. package/dist/components/SidePanel/SessionList.d.ts.map +0 -1
  351. package/dist/components/SidePanel/SessionPanel.d.ts.map +0 -1
  352. package/dist/components/SidePanel/SkillsList.d.ts.map +0 -1
  353. package/dist/components/SidePanel/WorktreesPanel.d.ts.map +0 -1
  354. package/dist/components/SidePanel/index.d.ts.map +0 -1
  355. package/dist/components/SkillDetailView.d.ts.map +0 -1
  356. package/dist/components/SpecsView.d.ts.map +0 -1
  357. package/dist/components/TaskActivityTimeline.d.ts.map +0 -1
  358. package/dist/components/TaskBoard.d.ts.map +0 -1
  359. package/dist/components/TaskCard.d.ts.map +0 -1
  360. package/dist/components/TaskExecutionAttempts.d.ts.map +0 -1
  361. package/dist/components/TaskIntelligencePanel.d.ts.map +0 -1
  362. package/dist/components/TaskRiskPanel.d.ts.map +0 -1
  363. package/dist/components/TaskVerificationSection.d.ts.map +0 -1
  364. package/dist/components/TasksPanel.d.ts.map +0 -1
  365. package/dist/components/TechStackView/DependencyDetail.d.ts.map +0 -1
  366. package/dist/components/TechStackView/DependencyTable.d.ts.map +0 -1
  367. package/dist/components/TechStackView/FindingsPanel.d.ts.map +0 -1
  368. package/dist/components/TechStackView/TechStackToolbar.d.ts.map +0 -1
  369. package/dist/components/TechStackView/index.d.ts.map +0 -1
  370. package/dist/components/TechStackView/shared.d.ts.map +0 -1
  371. package/dist/components/TerminalPanel.d.ts.map +0 -1
  372. package/dist/components/ThemeProvider.d.ts.map +0 -1
  373. package/dist/components/Toaster.d.ts.map +0 -1
  374. package/dist/components/TodosPanel.d.ts.map +0 -1
  375. package/dist/components/ToolGroup.d.ts.map +0 -1
  376. package/dist/components/ToolResult.d.ts.map +0 -1
  377. package/dist/components/VerificationReportPanel.d.ts.map +0 -1
  378. package/dist/components/WatchMessageBubble.d.ts.map +0 -1
  379. package/dist/components/WelcomeScreen.d.ts.map +0 -1
  380. package/dist/components/WorkDashboard.d.ts.map +0 -1
  381. package/dist/components/WorkspaceDock.d.ts.map +0 -1
  382. package/dist/components/WorktreeGraph.d.ts.map +0 -1
  383. package/dist/components/WorktreeLanes.d.ts.map +0 -1
  384. package/dist/components/WorktreeOrphans.d.ts.map +0 -1
  385. package/dist/components/activity-bar/index.d.ts.map +0 -1
  386. package/dist/components/activity-bar/nav.d.ts.map +0 -1
  387. package/dist/components/agent-roster-data.d.ts.map +0 -1
  388. package/dist/components/agents/AgentDetailSection.d.ts.map +0 -1
  389. package/dist/components/agents/AgentRosterCard.d.ts.map +0 -1
  390. package/dist/components/agents/FleetSummaryBar.d.ts.map +0 -1
  391. package/dist/components/codemap-model.d.ts.map +0 -1
  392. package/dist/components/context-editor/ContextWindowEditor.d.ts.map +0 -1
  393. package/dist/components/dashboard-primitives.d.ts.map +0 -1
  394. package/dist/components/index.d.ts.map +0 -1
  395. package/dist/components/monaco-theme.d.ts.map +0 -1
  396. package/dist/components/toaster-helpers.d.ts.map +0 -1
  397. package/dist/components/ui/PickerCardList.d.ts.map +0 -1
  398. package/dist/components/ui/api-key-display.d.ts.map +0 -1
  399. package/dist/components/ui/badge.d.ts.map +0 -1
  400. package/dist/components/ui/button.d.ts.map +0 -1
  401. package/dist/components/ui/concurrency-gauge.d.ts.map +0 -1
  402. package/dist/components/ui/dialog.d.ts.map +0 -1
  403. package/dist/components/ui/dropdown-menu.d.ts.map +0 -1
  404. package/dist/components/ui/empty-state.d.ts.map +0 -1
  405. package/dist/components/ui/event-timeline.d.ts.map +0 -1
  406. package/dist/components/ui/fleet-agent-row.d.ts.map +0 -1
  407. package/dist/components/ui/index.d.ts.map +0 -1
  408. package/dist/components/ui/input.d.ts.map +0 -1
  409. package/dist/components/ui/pagination.d.ts.map +0 -1
  410. package/dist/components/ui/progress-ring.d.ts.map +0 -1
  411. package/dist/components/ui/scroll-area.d.ts.map +0 -1
  412. package/dist/components/ui/sheet.d.ts.map +0 -1
  413. package/dist/components/ui/sparkline.d.ts.map +0 -1
  414. package/dist/components/ui/tabs.d.ts.map +0 -1
  415. package/dist/components/useAgentRosterData.d.ts.map +0 -1
  416. package/dist/components/useKanbanRegistrySessionIds.d.ts.map +0 -1
  417. package/dist/hooks/index.d.ts.map +0 -1
  418. package/dist/hooks/use-ws-handlers.d.ts.map +0 -1
  419. package/dist/hooks/useDesktopBridge.d.ts.map +0 -1
  420. package/dist/hooks/useF5Resilience.d.ts.map +0 -1
  421. package/dist/hooks/useFieldKeyboardNav.d.ts.map +0 -1
  422. package/dist/hooks/useFleetPolling.d.ts.map +0 -1
  423. package/dist/hooks/useGitInfo.d.ts.map +0 -1
  424. package/dist/hooks/useGlobalKeyboardShortcuts.d.ts.map +0 -1
  425. package/dist/hooks/useHorizontalScroll.d.ts.map +0 -1
  426. package/dist/hooks/useKanbanMeta.d.ts.map +0 -1
  427. package/dist/hooks/useMemoryForFile.d.ts.map +0 -1
  428. package/dist/hooks/usePagination.d.ts.map +0 -1
  429. package/dist/hooks/useProviderModels.d.ts.map +0 -1
  430. package/dist/hooks/useScrollPosition.d.ts.map +0 -1
  431. package/dist/hooks/useWebSocket.d.ts.map +0 -1
  432. package/dist/hooks/ws-handlers/chat-handlers.d.ts.map +0 -1
  433. package/dist/hooks/ws-handlers/coordinator-handlers.d.ts.map +0 -1
  434. package/dist/hooks/ws-handlers/files-mailbox-handlers.d.ts.map +0 -1
  435. package/dist/hooks/ws-handlers/fleet-handlers.d.ts.map +0 -1
  436. package/dist/hooks/ws-handlers/misc-handlers.d.ts.map +0 -1
  437. package/dist/hooks/ws-handlers/session-handlers.d.ts.map +0 -1
  438. package/dist/hooks/ws-handlers/techstack-handlers.d.ts.map +0 -1
  439. package/dist/hooks/ws-handlers.d.ts.map +0 -1
  440. package/dist/i18n/index.d.ts.map +0 -1
  441. package/dist/i18n/languages.d.ts.map +0 -1
  442. package/dist/index.css.map +0 -7
  443. package/dist/index.js.map +0 -7
  444. package/dist/lib/accent-colors.d.ts.map +0 -1
  445. package/dist/lib/agent-office.d.ts.map +0 -1
  446. package/dist/lib/agent-status.d.ts.map +0 -1
  447. package/dist/lib/chime.d.ts.map +0 -1
  448. package/dist/lib/color.d.ts.map +0 -1
  449. package/dist/lib/completion.d.ts.map +0 -1
  450. package/dist/lib/core-browser-shim.d.ts.map +0 -1
  451. package/dist/lib/default-prompt-pools.d.ts.map +0 -1
  452. package/dist/lib/desktop-host.d.ts.map +0 -1
  453. package/dist/lib/desktop-shell.d.ts.map +0 -1
  454. package/dist/lib/fallback-ref.d.ts.map +0 -1
  455. package/dist/lib/favicon.d.ts.map +0 -1
  456. package/dist/lib/file-icons.d.ts.map +0 -1
  457. package/dist/lib/goal.d.ts.map +0 -1
  458. package/dist/lib/index.d.ts.map +0 -1
  459. package/dist/lib/kanban-cleaner.d.ts.map +0 -1
  460. package/dist/lib/kanban-metadata.d.ts.map +0 -1
  461. package/dist/lib/kanban-verification.d.ts.map +0 -1
  462. package/dist/lib/model-calendar.d.ts.map +0 -1
  463. package/dist/lib/model-matrix-routes.d.ts.map +0 -1
  464. package/dist/lib/notify.d.ts.map +0 -1
  465. package/dist/lib/plugin-enablement.d.ts.map +0 -1
  466. package/dist/lib/roster-ws.d.ts.map +0 -1
  467. package/dist/lib/sage-block.d.ts.map +0 -1
  468. package/dist/lib/sdd-theme.d.ts.map +0 -1
  469. package/dist/lib/stream-coalescer.d.ts.map +0 -1
  470. package/dist/lib/terminal-dock.d.ts.map +0 -1
  471. package/dist/lib/tool-icon.d.ts.map +0 -1
  472. package/dist/lib/tool-summary.d.ts.map +0 -1
  473. package/dist/lib/utils.d.ts.map +0 -1
  474. package/dist/lib/view-navigation.d.ts.map +0 -1
  475. package/dist/lib/ws-client-actions.d.ts.map +0 -1
  476. package/dist/lib/ws-client-contracts.d.ts.map +0 -1
  477. package/dist/lib/ws-client-helpers.d.ts.map +0 -1
  478. package/dist/lib/ws-client-utils.d.ts.map +0 -1
  479. package/dist/lib/ws-client.d.ts.map +0 -1
  480. package/dist/main.d.ts.map +0 -1
  481. package/dist/protocol-compatibility.d.ts.map +0 -1
  482. package/dist/stores/auto-submit-streak.d.ts.map +0 -1
  483. package/dist/stores/chat-store.d.ts.map +0 -1
  484. package/dist/stores/codemap-activity-store.d.ts.map +0 -1
  485. package/dist/stores/codemap-index-store.d.ts.map +0 -1
  486. package/dist/stores/config-store.d.ts.map +0 -1
  487. package/dist/stores/context-editor-store.d.ts.map +0 -1
  488. package/dist/stores/coordinator-monitor-store.d.ts.map +0 -1
  489. package/dist/stores/cron-store.d.ts.map +0 -1
  490. package/dist/stores/file-reference-store.d.ts.map +0 -1
  491. package/dist/stores/file-store.d.ts.map +0 -1
  492. package/dist/stores/fleet-store.d.ts.map +0 -1
  493. package/dist/stores/git-changes-store.d.ts.map +0 -1
  494. package/dist/stores/git-info-store.d.ts.map +0 -1
  495. package/dist/stores/goal-assess-store.d.ts.map +0 -1
  496. package/dist/stores/goal-run-store.d.ts.map +0 -1
  497. package/dist/stores/goal-state-store.d.ts.map +0 -1
  498. package/dist/stores/goal-store.d.ts.map +0 -1
  499. package/dist/stores/history-store.d.ts.map +0 -1
  500. package/dist/stores/index.d.ts.map +0 -1
  501. package/dist/stores/kanban-store.d.ts.map +0 -1
  502. package/dist/stores/local-prefs.d.ts.map +0 -1
  503. package/dist/stores/mailbox-store.d.ts.map +0 -1
  504. package/dist/stores/memory-injector-store.d.ts.map +0 -1
  505. package/dist/stores/memory-lifecycle-store.d.ts.map +0 -1
  506. package/dist/stores/monitor-store.d.ts.map +0 -1
  507. package/dist/stores/office-map-store.d.ts.map +0 -1
  508. package/dist/stores/provider-status-store.d.ts.map +0 -1
  509. package/dist/stores/sdd-board-store.d.ts.map +0 -1
  510. package/dist/stores/sdd-wizard-store.d.ts.map +0 -1
  511. package/dist/stores/session-store.d.ts.map +0 -1
  512. package/dist/stores/side-effect-store.d.ts.map +0 -1
  513. package/dist/stores/specs-store.d.ts.map +0 -1
  514. package/dist/stores/techstack-store.d.ts.map +0 -1
  515. package/dist/stores/types.d.ts.map +0 -1
  516. package/dist/stores/ui-store.d.ts.map +0 -1
  517. package/dist/stores/viz-store.d.ts.map +0 -1
  518. package/dist/stores/worktree-store.d.ts.map +0 -1
  519. package/dist/types/brain.d.ts.map +0 -1
  520. package/dist/types/chronicle.d.ts.map +0 -1
  521. package/dist/types/client-message.d.ts.map +0 -1
  522. package/dist/types/collab.d.ts.map +0 -1
  523. package/dist/types/connections.d.ts.map +0 -1
  524. package/dist/types/goal-kanban-worktree.d.ts.map +0 -1
  525. package/dist/types/protocol-core.d.ts.map +0 -1
  526. package/dist/types/runtime.d.ts.map +0 -1
  527. package/dist/types/sage.d.ts.map +0 -1
  528. package/dist/types/server-message.d.ts.map +0 -1
  529. package/dist/types/skills-design.d.ts.map +0 -1
  530. package/dist/types/system.d.ts.map +0 -1
  531. package/dist/types.d.ts.map +0 -1
  532. package/dist/types.js.map +0 -7
@@ -1,6 +1,6 @@
1
1
  import { type Activity } from '@/stores/ui-store';
2
2
  export type PanelMainView = 'chat' | 'files' | 'skill' | 'officemap' | 'changes' | 'mailbox' | 'design-gallery';
3
- export type MainView = 'goal' | 'kanban' | 'sddhub' | 'settings' | 'memory' | 'roster' | 'codemap' | 'techstack' | 'deadcode' | 'chronicle';
3
+ export type MainView = 'goal' | 'kanban' | 'sddhub' | 'settings' | 'memory' | 'roster' | 'codemap' | 'techstack' | 'chronicle';
4
4
  export type AppView = PanelMainView | MainView | 'sessions' | 'setup' | 'debug' | 'refresh-debug' | 'analytics';
5
5
  export declare const PANEL_VIEW_BY_ACTIVITY: Record<Activity, PanelMainView>;
6
6
  export declare const VIEW_ACTIVITY: Partial<Record<AppView, Activity>>;
@@ -5,6 +5,17 @@ import type { WSSendOptions } from './ws-client-contracts';
5
5
  import { type EventHandler, type WsStatus } from './ws-client-utils';
6
6
  export type { WSSendOptions } from './ws-client-contracts';
7
7
  export type { WsStatus };
8
+ /** Options for `sendMailboxMessage` — a mailbox message of a given intent
9
+ * type (btw, steer, note, …) routed to a target agent/role. Shared by the
10
+ * ws-client method, the `useWebSocket` wrapper, and UI prop contracts. */
11
+ export type WSMailboxSendOptions = {
12
+ type: 'note' | 'ask' | 'assign' | 'steer' | 'btw' | 'broadcast' | 'status' | 'result' | 'review';
13
+ to: string;
14
+ subject: string;
15
+ body: string;
16
+ priority?: 'low' | 'normal' | 'high' | undefined;
17
+ audience?: 'all' | 'leaders' | undefined;
18
+ };
8
19
  declare class WrongStackWebSocketClientBase {
9
20
  private ws;
10
21
  private url;
@@ -19,8 +30,12 @@ declare class WrongStackWebSocketClientBase {
19
30
  * late). */
20
31
  private socketGeneration;
21
32
  private messageQueue;
33
+ private messageQueueChars;
34
+ private readonly messageQueueWeights;
22
35
  private connectionState;
23
36
  private static readonly MAX_QUEUED_MESSAGES;
37
+ /** Count-only limits are ineffective for image/base64 payloads. */
38
+ private static readonly MAX_QUEUED_CHARS;
24
39
  private pendingConfirms;
25
40
  private sessionId;
26
41
  private sessionSwapPending;
@@ -83,14 +98,7 @@ declare class WrongStackWebSocketClientBase {
83
98
  sendMessage(content: string, images?: WSUserMessageImage[]): string;
84
99
  /** Send a mailbox message of the given type (btw, steer, note, etc.)
85
100
  * to a target agent/role. Returns the requestId for response tracking. */
86
- sendMailboxMessage(opts: {
87
- type: 'note' | 'ask' | 'assign' | 'steer' | 'btw' | 'broadcast' | 'status' | 'result' | 'review';
88
- to: string;
89
- subject: string;
90
- body: string;
91
- priority?: 'low' | 'normal' | 'high' | undefined;
92
- audience?: 'all' | 'leaders' | undefined;
93
- }): string;
101
+ sendMailboxMessage(opts: WSMailboxSendOptions): string;
94
102
  sendAbort(): void;
95
103
  getGitInfo(): void;
96
104
  /** Request the working-tree change set (file list for the Changes panel). */
@@ -44,6 +44,16 @@
44
44
  "url": "https://opencode.ai/go?ref=6VZAER87H4"
45
45
  }
46
46
  },
47
+ {
48
+ "id": "zyloo",
49
+ "name": "Zyloo",
50
+ "family": "openai-compatible",
51
+ "description": "Zyloo API — OpenAI-compatible with a 128-tool limit per request",
52
+ "icon": "🚀",
53
+ "color": "from-accent/12 to-accent/5 border-accent/30 hover:border-accent/50",
54
+ "keyPlaceholder": "zy-...",
55
+ "docsUrl": "https://docs.zyloo.io/"
56
+ },
47
57
  {
48
58
  "id": "openrouter",
49
59
  "name": "OpenRouter (Metered)",
@@ -1,14 +1,55 @@
1
1
  import type { ChatMessage } from './types.js';
2
+ export declare const MAX_CHAT_RETAINED_BYTES: number;
3
+ /**
4
+ * How long a `btw` chip stays visible after entering the "SENT" state
5
+ * (i.e. after the wire-send succeeded at submit time). The chip is removed
6
+ * from the queue automatically after this delay so the user sees the
7
+ * queue → SENT → leave-screen transition instead of the chip getting
8
+ * stuck until the next `run.result` lands. UX spec (2026-08): "shortly
9
+ * after it is processed, the message should leave my screen".
10
+ */
11
+ export declare const BTW_DISPATCH_GRACE_MS = 1800;
12
+ export declare const MAX_CHAT_FIELD_CHARS: number;
13
+ interface ChatRetentionBudget {
14
+ maxMessages?: number;
15
+ maxBytes?: number;
16
+ maxFieldChars?: number;
17
+ }
18
+ export declare function boundChatField(text: string, maxChars?: number): string;
19
+ /** Count limits alone do not protect against giant tool/replay/vision rows. */
20
+ export declare function retainWebChatMessages(messages: readonly ChatMessage[], budget?: ChatRetentionBudget): ChatMessage[];
2
21
  /** Submit mode for a queued/typed message. Drives whether the message
3
22
  * interrupts the running agent (`steer`), rides alongside without
4
23
  * interrupting (`btw`), or is held for after the run completes (`queue`). */
5
24
  export type QueueMode = 'btw' | 'steer' | 'queue';
6
25
  /** One entry in the message queue — the text plus how it was added.
7
- * `addedAt` powers the optional sort-by-newest toggle. */
26
+ * `addedAt` powers the optional sort-by-newest toggle.
27
+ * `itemId` is a monotonic per-store counter stamped by `enqueue`;
28
+ * the dispatched-chip grace-timer map and queue-filter operations
29
+ * key on it instead of `addedAt` so two enqueues sharing the same
30
+ * millisecond cannot cross-cancel each other. */
8
31
  export interface QueuedItem {
9
32
  text: string;
10
33
  mode: QueueMode;
11
34
  addedAt: number;
35
+ itemId: number;
36
+ /** True once a `btw` item has already been wire-sent via the mailbox
37
+ * (immediate mid-run dispatch). The run.result drain must skip re-sending
38
+ * these — they remain in the queue only as a visible "dispatched" chip. */
39
+ alreadyDispatched?: boolean | undefined;
40
+ /** Idempotency latch for the drain path. Set by
41
+ * `addBubbleFor` in chat-handlers.handleRunResult (drain emits
42
+ * a bubble for the popped front chip) and by `dequeueDrainable`
43
+ * (drain emits bubbles for every leading dispatched chip it skips
44
+ * past). The grace timer callback in `enqueue` *reads* this flag
45
+ * to gate bubble emission (`target.bubbleAdded !== true`) — without
46
+ * this gate, a second `run.result` landing inside the grace window
47
+ * would call `addBubbleFor(front)` a second time and emit a duplicate
48
+ * user bubble for the same chip. Reset implicitly on a fresh
49
+ * `enqueue` (the chip is constructed with `bubbleAdded` undefined).
50
+ * The flag is the idempotency latch for the drain path; the timer
51
+ * path reads it but does not write it. */
52
+ bubbleAdded?: boolean | undefined;
12
53
  /** Image attachments riding with the queued message. Kept as full data
13
54
  * URLs so the drain path can rebuild the wire payload + local bubble. */
14
55
  images?: Array<{
@@ -54,6 +95,7 @@ interface ChatState {
54
95
  data: string;
55
96
  mime: string;
56
97
  }>;
98
+ mode: QueueMode;
57
99
  } | null;
58
100
  /** Transient extended-thinking buffer. Populated by provider.thinking_delta
59
101
  * events and shown as a soft, ephemeral bubble below the chat tail while
@@ -83,7 +125,13 @@ interface ChatState {
83
125
  setMessages: (messages: ChatMessage[]) => void;
84
126
  updateMessage: (id: string, updates: Partial<ChatMessage>) => void;
85
127
  appendToMessage: (id: string, text: string) => void;
86
- finalizeMessage: (id: string) => void;
128
+ /** `opts.final` whether this finalize ends the turn. Pass `false` when the
129
+ * message is being closed because a tool call follows: the `<nextsteps>`
130
+ * block is still stripped from the body, but the parsed steps are not
131
+ * persisted, so no suggestion bar appears mid-turn. Defaults to `true`. */
132
+ finalizeMessage: (id: string, opts?: {
133
+ final?: boolean;
134
+ }) => void;
87
135
  setToolResult: (id: string, result: string, ok: boolean) => void;
88
136
  appendToolProgress: (id: string, line: string) => void;
89
137
  appendToolProgressLines: (id: string, lines: string[]) => void;
@@ -101,15 +149,16 @@ interface ChatState {
101
149
  truncateAfter: (id: string) => void;
102
150
  addExecution: (exec: ToolExecution) => void;
103
151
  updateExecution: (id: string, updates: Partial<ToolExecution>) => void;
104
- enqueue: (text: string, mode?: QueueMode, images?: QueuedItem['images']) => void;
152
+ enqueue: (text: string, mode?: QueueMode, images?: QueuedItem['images'], alreadyDispatched?: boolean) => void;
105
153
  dequeue: () => QueuedItem | null;
154
+ dequeueDrainable: () => QueuedItem | null;
106
155
  removeQueued: (idx: number) => void;
107
156
  clearQueue: () => void;
108
157
  setRefining: (v: boolean) => void;
109
158
  setPendingRefinement: (text: string | null, images?: Array<{
110
159
  data: string;
111
160
  mime: string;
112
- }>) => void;
161
+ }>, mode?: QueueMode) => void;
113
162
  removeMessage: (id: string) => void;
114
163
  updateLastUserMessage: (text: string) => void;
115
164
  setRunStart: (s: {
@@ -43,7 +43,6 @@ export declare const useConfigStore: import("zustand").UseBoundStore<Omit<import
43
43
  provider: string;
44
44
  model: string;
45
45
  baseUrl: string | undefined;
46
- apiKey: string | undefined;
47
46
  theme: "dark" | "light" | "system";
48
47
  autoConnect: boolean;
49
48
  soundOnComplete: boolean;
@@ -57,7 +56,6 @@ export declare const useConfigStore: import("zustand").UseBoundStore<Omit<import
57
56
  provider: string;
58
57
  model: string;
59
58
  baseUrl: string | undefined;
60
- apiKey: string | undefined;
61
59
  theme: "dark" | "light" | "system";
62
60
  autoConnect: boolean;
63
61
  soundOnComplete: boolean;
@@ -133,6 +133,26 @@ export interface LocalPrefs {
133
133
  uiLocale: string;
134
134
  /** How Chimera review findings are handled. */
135
135
  chimeraAutoFix: 'off' | 'ask' | 'auto';
136
+ /** When true, the read tool includes codebase-index symbols in its output.
137
+ * Mirrors TUI field 42 (`readSymbols`) persisted as
138
+ * `autonomy.readAdvancedMode`. */
139
+ readSymbols: boolean;
140
+ /** When true, SAGE memory-inject blocks are surfaced in tool results.
141
+ * Mirrors TUI field 43 (`showSageMemoryInject`). */
142
+ showSageMemoryInject: boolean;
143
+ /** Minimum relation strength for SAGE memory injection. Mirrors TUI field
144
+ * 44 (`sageMemoryInjectThreshold`) persisted as
145
+ * `Sage.inject.relationFloor`. */
146
+ sageMemoryInjectThreshold: number;
147
+ /** Pre-refine grace countdown in SECONDS (TUI field 41). 0 = skip the
148
+ * countdown and run the refiner immediately. Presets:
149
+ * 0, 2, 3, 5, 8, 10. Distinct from `enhanceCountdownMs` (a TUI-internal
150
+ * ms value used by the simpleui RefinePanel animation). */
151
+ preRefineSeconds: number;
152
+ /** Minimum number of files before the multi-file diff summary footer
153
+ * renders above the per-file blocks. 0 disables the footer. Mirrors TUI
154
+ * field 21 (`multiDiffSummaryThreshold`). */
155
+ multiDiffSummaryThreshold: number;
136
156
  /** Master enable for `wstack-chimera`. Defaults to true (matches plugin: `cfg.enabled !== false`). */
137
157
  chimeraEnabled: boolean;
138
158
  /** Override provider id for the review subagent. Empty = use session provider. */
@@ -63,6 +63,14 @@ interface SessionState {
63
63
  * F5 because it's in partialize. Used by the resilience verifier view
64
64
  * to confirm the active session round-trips through localStorage. */
65
65
  lastVisitedAt: number;
66
+ /** Current app version string (e.g. "0.7.0") from the boot-time update check. */
67
+ appVersion: string;
68
+ /** Latest published version on npm, when known. */
69
+ latestVersion: string;
70
+ /** True when a newer published version exists than appVersion. */
71
+ updateAvailable: boolean;
72
+ /** Number of tools dropped from provider requests due to maxTools limit (0 = no limit or within limit). */
73
+ droppedTools: number;
66
74
  setSession: (session: SessionInfo | null) => void;
67
75
  updateUsage: (usage: Usage) => void;
68
76
  addCost: (cost: number) => void;
@@ -91,6 +99,12 @@ interface SessionState {
91
99
  }>) => void;
92
100
  setContextModes: (modes: SessionState['contextModes']) => void;
93
101
  setTodos: (todos: SessionState['todos']) => void;
102
+ setUpdateInfo: (info: {
103
+ appVersion: string;
104
+ latestVersion: string;
105
+ updateAvailable: boolean;
106
+ }) => void;
107
+ setDroppedTools: (count: number) => void;
94
108
  }
95
109
  export declare const useSessionStore: import("zustand").UseBoundStore<Omit<import("zustand").StoreApi<SessionState>, "persist" | "setState"> & {
96
110
  setState(partial: Partial<SessionState> | SessionState | ((state: SessionState) => Partial<SessionState> | SessionState), replace?: false | undefined): unknown;
@@ -1,9 +1,10 @@
1
+ import type { QueuedItem, QueueMode } from './chat-store';
1
2
  import type { MailboxMessage } from './mailbox-store';
2
3
  export type Activity = 'chat' | 'agents' | 'files' | 'changes' | 'mailbox' | 'skills' | 'design' | 'worktrees' | 'officemap';
3
4
  /** Map any persisted (possibly legacy) activity value onto the current set. */
4
5
  export declare function coerceActivity(value: unknown): Activity;
5
6
  /** All valid currentView values. Kept in sync with the union on UIState. */
6
- declare const VIEWS: readonly ['chat', 'settings', 'memory', 'roster', 'context', 'goal', 'kanban', 'sddhub', 'files', 'changes', 'sessions', 'setup', 'skill', 'officemap', 'mailbox', 'debug', 'design-gallery', 'refresh-debug', 'analytics', 'codemap', 'techstack', 'deadcode', 'chronicle'];
7
+ declare const VIEWS: readonly ['chat', 'settings', 'memory', 'roster', 'context', 'goal', 'kanban', 'sddhub', 'files', 'changes', 'sessions', 'setup', 'skill', 'officemap', 'mailbox', 'debug', 'design-gallery', 'refresh-debug', 'analytics', 'codemap', 'techstack', 'chronicle', 'deadcode'];
7
8
  type View = (typeof VIEWS)[number];
8
9
  /** Coerce an arbitrary value onto the current view union. Used by migrate
9
10
  * when reading from localStorage so a stale value (e.g. 'context', a view
@@ -172,6 +173,12 @@ interface UIState {
172
173
  provider?: string | undefined;
173
174
  /** Model name running the refinement (e.g. "gpt-4o"). */
174
175
  model?: string | undefined;
176
+ /** Submit behavior to preserve across the refinement approval round-trip. */
177
+ mode?: QueueMode | undefined;
178
+ /** Image attachments from the original submit, preserved so the approval
179
+ * enqueue path can forward them (mirrors the error/no-op paths in
180
+ * misc-handlers that pass refImages to enqueue). */
181
+ images?: QueuedItem['images'];
175
182
  } | null;
176
183
  /** Prompt library modal (browse/search/insert prompts) open state. */
177
184
  promptLibraryOpen: boolean;
@@ -580,6 +580,7 @@ export type WSClientMessageCore = WSUserMessage | WSToolConfirmResult | {
580
580
  type: 'memory.sage.delete';
581
581
  payload: {
582
582
  id: string;
583
+ force?: boolean | undefined;
583
584
  reason?: string | undefined;
584
585
  neverInject?: boolean | undefined;
585
586
  };
@@ -1,6 +1,6 @@
1
1
  export type ConnectionHealthStatus = 'healthy' | 'degraded' | 'offline' | 'unavailable' | 'error';
2
2
  export interface ConnectionHealthService {
3
- id: 'webui' | 'chronicle' | 'codebase-index' | 'sage' | 'kanban' | 'mailbox';
3
+ id: 'webui' | 'chronicle' | 'codebase-index' | 'sage' | 'kanban' | 'mailbox' | 'governance';
4
4
  label: string;
5
5
  status: ConnectionHealthStatus;
6
6
  required: boolean;
@@ -19,6 +19,12 @@ export interface ConnectionHealthService {
19
19
  watchedFiles?: number | undefined;
20
20
  } | undefined;
21
21
  lastError?: string | undefined;
22
+ control?: 'shutdown' | 'none' | undefined;
23
+ advisory?: {
24
+ code: string;
25
+ operatorAction: 'none' | 'observe' | 'investigate';
26
+ executionDisposition: 'continue';
27
+ } | undefined;
22
28
  }
23
29
  export interface ConnectionsHealthReport {
24
30
  checkedAt: number;
@@ -257,6 +257,15 @@ export type WSServerMessage = WSSessionStart | WSSessionEnd | WSTextDelta | WSTh
257
257
  audience?: 'all' | 'leaders' | undefined;
258
258
  error?: string | undefined;
259
259
  };
260
+ } | {
261
+ type: 'mailbox.action_result';
262
+ payload: {
263
+ requestId: string;
264
+ success: boolean;
265
+ action?: 'mark-read' | 'acknowledge' | 'reopen' | 'soft-delete' | undefined;
266
+ mailId?: string | undefined;
267
+ error?: string | undefined;
268
+ };
260
269
  } | {
261
270
  type: 'pong';
262
271
  payload?: Record<string, unknown> | undefined;
@@ -10,6 +10,10 @@ export interface WSDiagGet {
10
10
  count: number;
11
11
  names: string[];
12
12
  };
13
+ /** Provider maxTools limit (0 = no limit). */
14
+ maxTools: number;
15
+ /** Tools dropped from requests because they exceed maxTools. */
16
+ droppedTools: number;
13
17
  features: {
14
18
  memory: boolean;
15
19
  skills: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wrongstack/webui",
3
- "version": "0.296.4",
3
+ "version": "0.298.0",
4
4
  "license": "MIT",
5
5
  "description": "Browser-based WebUI for WrongStack — React + Vite frontend. The WebSocket backend lives in the separate @wrongstack/webui-server package (extracted in PR #018b to remove the CLI -> @wrongstack/webui/server cross-package edge).",
6
6
  "keywords": [
@@ -24,6 +24,7 @@
24
24
  "type": "module",
25
25
  "files": [
26
26
  "dist",
27
+ "!dist/**/*.map",
27
28
  "README.md",
28
29
  "LICENSE"
29
30
  ],
@@ -75,11 +76,11 @@
75
76
  "tailwind-merge": "^3.6.0",
76
77
  "virtua": "^0.49.3",
77
78
  "zustand": "^5.0.14",
78
- "@wrongstack/core": "0.296.4",
79
- "@wrongstack/kanban": "0.296.4",
80
- "@wrongstack/webui-server": "0.296.4",
81
- "@wrongstack/providers": "0.296.4",
82
- "@wrongstack/tools": "0.296.4"
79
+ "@wrongstack/core": "0.298.0",
80
+ "@wrongstack/providers": "0.298.0",
81
+ "@wrongstack/kanban": "0.298.0",
82
+ "@wrongstack/tools": "0.298.0",
83
+ "@wrongstack/webui-server": "0.298.0"
83
84
  },
84
85
  "optionalDependencies": {
85
86
  "node-pty": "1.2.0-beta.14"
@@ -101,7 +102,7 @@
101
102
  "typescript": "^7.0.2",
102
103
  "vite": "^8.1.5",
103
104
  "vitest": "^4.1.10",
104
- "@wrongstack/sdd": "0.296.4"
105
+ "@wrongstack/sdd": "0.298.0"
105
106
  },
106
107
  "scripts": {
107
108
  "dev": "vite",
package/dist/App.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../src/App.tsx"],"names":[],"mappings":"AA26BA,wBAAgB,GAAG,gCAQlB"}
@@ -1,11 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./chat-store-DaSs2P3S.js";import{Ai as n,Ct as r,Ir as i,It as a,Ji as o,Kn as s,Li as c,Si as l,Ut as u,Xi as d,Yi as f,Zt as p,ai as m,at as h,bt as g,cn as _,et as v,gi as y,ii as b,it as x,ot as S,pa as C,qt as w,rr as T,tr as E,xa as D}from"./vendor-9hC4n4Me.js";import{n as O}from"./ui-store-BI3LH2q8.js";import{t as k}from"./ws-client-eyEv8wbm.js";import{t as A}from"./utils-DzRQUvln.js";import{x as j}from"./stores-hEu6z1qz.js";import{n as M}from"./Toaster-DTJHnKyl.js";import{n as N,t as P}from"./ModelPicker-CJBOoZME.js";import{u as F}from"./index-DSXHr5yP.js";import{t as I}from"./roster-ws-CVCrt_ih.js";var L=e(D(),1),R=v(),z=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],B=[[`timeoutMs`,`Total timeout (ms)`],[`idleTimeoutMs`,`Idle timeout (ms)`],[`maxIterations`,`Max iterations`],[`maxToolCalls`,`Max tool calls`],[`maxTokens`,`Max tokens`],[`maxCostUsd`,`Max cost (USD)`]];function V(e){return`${e.provider}/${e.model}`}function H(e){let t=e.indexOf(`/`);return t<0?{provider:``,model:e}:{provider:e.slice(0,t),model:e.slice(t+1)}}function U(e){return Array.isArray(e)?e.join(`, `):``}function W(e){return[...new Set(e.split(/[\n,]+/).map(e=>e.trim()).filter(Boolean))]}function G({initialConfig:e,systemProtected:t,saving:n,onSave:r,onCancel:i}){let[a,o]=(0,L.useState)(()=>structuredClone(e)),s=N(!0),c=a.modelPolicy,l=(0,L.useMemo)(()=>(c?.allowed??[]).map(V),[c?.allowed]),d=(0,L.useMemo)(()=>(c?.fallbacks??[]).map(V),[c?.fallbacks]),f=e=>o(t=>({...t,...e})),p=(e,t)=>{let n=W(t);o(t=>{let r={...t};return n.length?r[e]=n:delete r[e],r})},m=(e,t)=>{o(n=>{let r={...n.budget??{}};t===``?delete r[e]:r[e]=Number(t);let i={...n};return Object.keys(r).length?i.budget=r:delete i.budget,i})},h=e=>{let t=e.map(H),n=new Set(e);o(e=>({...e,modelPolicy:{allowed:t,fallbacks:(e.modelPolicy?.fallbacks??[]).filter(e=>n.has(V(e))),strict:e.modelPolicy?.strict??!0}}))};return(0,R.jsxs)(`div`,{className:`space-y-4 rounded-lg border border-border bg-card/40 p-4`,children:[t&&(0,R.jsxs)(`div`,{className:`flex gap-2 rounded-md border border-amber-500/30 bg-amber-500/5 p-2 text-[11px] text-muted-foreground`,children:[(0,R.jsx)(u,{className:`mt-0.5 h-4 w-4 shrink-0 text-amber-500`}),(0,R.jsx)(`span`,{children:`Protected system agent: required tools and capabilities are retained, minimum budgets are enforced, working hours remain advisory, and emergency model recovery stays enabled so core operations cannot be disabled.`})]}),(0,R.jsxs)(`section`,{className:`space-y-2`,children:[(0,R.jsx)(`h4`,{className:`text-xs font-semibold`,children:`Provider and model policy`}),(0,R.jsx)(P,{candidates:s,provider:a.provider,value:a.model,placeholder:`Use project default model`,resetLabel:`Use project default`,onReset:()=>{o(e=>{let t={...e};return delete t.provider,delete t.model,t})},onPick:(e,t)=>{let n=`${t}/${e}`;f({provider:t,model:e}),c&&!l.includes(n)&&h([...l,n])}}),(0,R.jsxs)(`label`,{className:`flex items-center gap-2 text-[11px]`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:!!c,onChange:e=>{if(e.target.checked){let e=a.provider&&a.model?[{provider:a.provider,model:a.model}]:s[0]?[{provider:s[0].provider,model:s[0].model}]:[];e.length&&f({modelPolicy:{allowed:e,strict:!0}})}else o(e=>{let t={...e};return delete t.modelPolicy,t})}}),`Restrict this agent to an explicit model allowlist`]}),c&&(0,R.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`div`,{className:`space-y-1`,children:[(0,R.jsx)(`span`,{className:`text-[10px] font-medium`,children:`Allowed models`}),(0,R.jsx)(F,{value:l,candidates:s,onChange:h,placeholder:`Add allowed model`,emptyHint:`At least one model is required`})]}),(0,R.jsxs)(`div`,{className:`space-y-1`,children:[(0,R.jsx)(`span`,{className:`text-[10px] font-medium`,children:`Ordered fallback chain`}),(0,R.jsx)(F,{value:d,candidates:s,onChange:e=>{let t=[...new Set([...l,...e])];o(n=>({...n,modelPolicy:{allowed:t.map(H),fallbacks:e.map(H),strict:n.modelPolicy?.strict??!0}}))},placeholder:`Add fallback model`,emptyHint:`No fallback; primary failure stops the task`})]})]})]}),(0,R.jsx)(`section`,{className:`grid gap-3 sm:grid-cols-3`,children:[[`tools`,`Tools`,`read_file, search, bash`],[`skillNames`,`Skills`,`security-check, browser`],[`allowedCapabilities`,`Capabilities`,`fs.read, fs.write`]].map(([e,t,n])=>(0,R.jsxs)(`label`,{className:`space-y-1 text-[10px]`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:t}),(0,R.jsx)(`textarea`,{value:U(a[e]),onChange:t=>p(e,t.target.value),placeholder:n,className:`h-20 w-full resize-y rounded border border-border bg-background p-2 font-mono`})]},e))}),(0,R.jsxs)(`section`,{className:`space-y-2`,children:[(0,R.jsx)(`h4`,{className:`text-xs font-semibold`,children:`Workspace and isolation`}),(0,R.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`label`,{className:`space-y-1 text-[10px]`,children:[(0,R.jsx)(`span`,{children:`Project-relative working directory`}),(0,R.jsx)(`input`,{value:a.cwd??``,onChange:e=>f({cwd:e.target.value||void 0}),placeholder:`packages/webui`,className:`h-8 w-full rounded border border-border bg-background px-2 font-mono`})]}),(0,R.jsxs)(`label`,{className:`space-y-1 text-[10px]`,children:[(0,R.jsx)(`span`,{children:`Git worktree isolation`}),(0,R.jsxs)(`select`,{value:String(a.worktree??`auto`),onChange:e=>f({worktree:e.target.value}),className:`h-8 w-full rounded border border-border bg-background px-2`,children:[(0,R.jsx)(`option`,{value:`auto`,children:`Automatic`}),(0,R.jsx)(`option`,{value:`required`,children:`Required`}),(0,R.jsx)(`option`,{value:`off`,children:`Off`})]})]})]})]}),(0,R.jsxs)(`section`,{className:`space-y-2`,children:[(0,R.jsx)(`h4`,{className:`text-xs font-semibold`,children:`Limits`}),(0,R.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:B.map(([e,t])=>(0,R.jsxs)(`label`,{className:`space-y-1 text-[10px]`,children:[(0,R.jsx)(`span`,{children:t}),(0,R.jsx)(`input`,{type:`number`,min:`0`,step:e===`maxCostUsd`?`0.01`:`1`,value:a.budget?.[e]??``,onChange:t=>m(e,t.target.value),className:`h-8 w-full rounded border border-border bg-background px-2`})]},e))})]}),(0,R.jsxs)(`section`,{className:`space-y-2`,children:[(0,R.jsxs)(`label`,{className:`flex items-center gap-2 text-xs font-semibold`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:!!a.availability,onChange:e=>{e.target.checked?f({availability:{timezone:Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`,days:[1,2,3,4,5],start:`09:00`,end:`18:00`,mode:t?`advisory`:`enforce`}}):o(e=>{let t={...e};return delete t.availability,t})}}),`Working hours`]}),a.availability&&(0,R.jsxs)(`div`,{className:`space-y-2 rounded border border-border p-2`,children:[(0,R.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:z.map((e,t)=>(0,R.jsxs)(`label`,{className:`flex items-center gap-1 text-[10px]`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:a.availability?.days.includes(t)??!1,onChange:e=>{let n=a.availability;if(!n)return;let r=e.target.checked?[...new Set([...n.days,t])].sort():n.days.filter(e=>e!==t);f({availability:{...n,days:r}})}}),e]},e))}),(0,R.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-4`,children:[(0,R.jsx)(`input`,{value:a.availability.timezone,onChange:e=>f({availability:{...a.availability,timezone:e.target.value}}),placeholder:`Europe/Kiev`,className:`h-8 rounded border border-border bg-background px-2 text-[10px]`}),(0,R.jsx)(`input`,{type:`time`,value:a.availability.start,onChange:e=>f({availability:{...a.availability,start:e.target.value}}),className:`h-8 rounded border border-border bg-background px-2 text-[10px]`}),(0,R.jsx)(`input`,{type:`time`,value:a.availability.end,onChange:e=>f({availability:{...a.availability,end:e.target.value}}),className:`h-8 rounded border border-border bg-background px-2 text-[10px]`}),(0,R.jsxs)(`select`,{value:t?`advisory`:a.availability.mode??`enforce`,disabled:t,onChange:e=>f({availability:{...a.availability,mode:e.target.value}}),className:`h-8 rounded border border-border bg-background px-2 text-[10px]`,children:[(0,R.jsx)(`option`,{value:`enforce`,children:`Enforce`}),(0,R.jsx)(`option`,{value:`advisory`,children:`Advisory`})]})]})]})]}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(`button`,{type:`button`,disabled:n||!!(c&&c.allowed.length===0),onClick:()=>r(a),className:`rounded bg-primary px-3 py-1.5 text-xs text-primary-foreground disabled:opacity-50`,children:n?`Saving…`:`Save runtime policy`}),(0,R.jsx)(`button`,{type:`button`,onClick:i,className:`rounded border border-border px-3 py-1.5 text-xs hover:bg-accent`,children:`Cancel`})]})]})}var K=[{id:`live`,icon:(0,R.jsx)(C,{className:`h-4 w-4`}),label:`Live Fleet`},{id:`catalog`,icon:(0,R.jsx)(f,{className:`h-4 w-4`}),label:`Roster Catalog`},{id:`learning`,icon:(0,R.jsx)(d,{className:`h-4 w-4`}),label:`Self-Learning`},{id:`customize`,icon:(0,R.jsx)(w,{className:`h-4 w-4`}),label:`Customization`}],q=[{role:`generic`,name:`Generic Project Agent`,summary:`Flexible template that can be cloned into independently learning project roles.`,tools:0,budget:{maxIterations:2500,maxToolCalls:7500}},{role:`audit-log`,name:`Audit Log`,summary:`Analyzes session logs, event streams, and system traces.`,tools:12,budget:{timeoutMs:108e5,maxIterations:2500,maxToolCalls:7500}},{role:`bug-hunter`,name:`Bug Hunter`,summary:`Scans code for bugs, code smells, and anti-patterns.`,tools:15,budget:{timeoutMs:18e6,maxIterations:4e3,maxToolCalls:1e4}},{role:`refactor-planner`,name:`Refactor Planner`,summary:`Analyzes code structure and produces phased refactoring plans.`,tools:14,budget:{timeoutMs:144e5,maxIterations:3e3,maxToolCalls:9e3}},{role:`security-scanner`,name:`Security Scanner`,summary:`Scans code, configs, and dependencies for security issues.`,tools:18,budget:{timeoutMs:18e6,maxIterations:4e3,maxToolCalls:1e4}},{role:`critic`,name:`Critic`,summary:`Evaluates decisions, plans, and implementations.`,tools:10,budget:{timeoutMs:108e5,maxIterations:2e3,maxToolCalls:5e3}},{role:`shadow-agent`,name:`Shadow Agent`,summary:`Background monitoring agent that watches fleet health.`,tools:8,budget:{timeoutMs:36e6,maxIterations:500,maxToolCalls:2e3}},{role:`executor`,name:`Executor`,summary:`General-purpose task executor for delegated work.`,tools:20,budget:{timeoutMs:72e5,maxIterations:1500,maxToolCalls:4e3}},{role:`chimera`,name:`Chimera`,summary:`Post-session code quality review of changed files.`,tools:10,budget:{timeoutMs:72e5,maxIterations:1e3,maxToolCalls:3e3}},{role:`researcher`,name:`Researcher`,summary:`Web research and data gathering specialist.`,tools:8,budget:{timeoutMs:72e5,maxIterations:1e3,maxToolCalls:3e3}},{role:`tech-stack`,name:`Tech Stack Validator`,summary:`Validates package/library/framework choices.`,tools:9,budget:{timeoutMs:72e5,maxIterations:1e3,maxToolCalls:3e3}},{role:`orchestrator`,name:`Orchestrator`,summary:`Coordinates multi-agent task execution.`,tools:12,budget:{timeoutMs:144e5,maxIterations:3e3,maxToolCalls:8e3}},{role:`supervisor`,name:`Supervisor`,summary:`Oversees subagent execution and handles escalations.`,tools:10,budget:{timeoutMs:144e5,maxIterations:2e3,maxToolCalls:6e3}},{role:`quality-gate`,name:`Quality Gate`,summary:`Enforces quality gates on implementations.`,tools:8,budget:{timeoutMs:72e5,maxIterations:1e3,maxToolCalls:3e3}},{role:`architect`,name:`Architect`,summary:`Makes design and architecture decisions.`,tools:14,budget:{timeoutMs:144e5,maxIterations:3e3,maxToolCalls:8e3}},{role:`prompt-engineer`,name:`Prompt Engineer`,summary:`Designs and optimizes system prompts.`,tools:8,budget:{timeoutMs:72e5,maxIterations:1e3,maxToolCalls:3e3}},{role:`mnemosyne`,name:`Mnemosyne`,summary:`Memory curator — reviews and maintains SAGE integrity.`,tools:6,budget:{timeoutMs:72e5,maxIterations:500,maxToolCalls:2e3}},{role:`autophase`,name:`AutoPhase`,summary:`Manages multi-phase autonomous task execution.`,tools:10,budget:{timeoutMs:144e5,maxIterations:2e3,maxToolCalls:6e3}}];function J({customStats:e,rosterLoading:t,onRefresh:n}){return(0,R.jsx)(`div`,{className:`shrink-0 border-b border-border/70 bg-card/80 px-4 py-2.5`,children:(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 flex-nowrap min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 overflow-hidden`,children:[(0,R.jsx)(`div`,{className:`flex items-center justify-center w-8 h-8 shrink-0 rounded-lg bg-primary/10`,children:(0,R.jsx)(E,{className:`h-4 w-4 text-primary`})}),(0,R.jsxs)(`div`,{className:`min-w-0 overflow-hidden`,children:[(0,R.jsx)(`h1`,{className:`text-sm font-semibold truncate`,children:`Agent Roster`}),(0,R.jsxs)(`p`,{className:`text-[10px] text-muted-foreground truncate`,children:[e.filter(e=>e.exists||e.hasIdentity||e.hasConfig||e.hasKnowledge).length,` `,`customized · `,e.reduce((e,t)=>e+t.entryCount,0),` learned entries`]})]})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[t&&(0,R.jsx)(s,{className:`h-4 w-4 animate-spin text-muted-foreground shrink-0`}),(0,R.jsxs)(`button`,{type:`button`,onClick:n,className:`inline-flex items-center gap-1 rounded border border-border/50 px-2 py-1 text-[10px] hover:bg-accent transition-colors shrink-0 whitespace-nowrap`,title:`Refresh roster data`,children:[(0,R.jsx)(_,{className:`h-3 w-3`}),` Refresh`]})]})]})})}function Y({activeTab:e,onTabChange:t}){return(0,R.jsx)(`div`,{className:`shrink-0 border-b border-border/50 bg-muted/20 px-3 flex gap-0`,children:K.map(n=>(0,R.jsxs)(`button`,{type:`button`,onClick:()=>t(n.id),className:A(`flex items-center gap-1.5 px-3 py-2 text-[10px] font-medium border-b-2 transition-colors`,e===n.id?`border-primary text-primary`:`border-transparent text-muted-foreground hover:text-foreground hover:border-muted-foreground/30`),children:[n.icon,n.label]},n.id))})}function X({customStats:e,onRefresh:r}){let[i,o]=(0,L.useState)(null),[c,l]=(0,L.useState)(null),[u,p]=(0,L.useState)({}),[m,h]=(0,L.useState)(``),[_,v]=(0,L.useState)(null),[y,S]=(0,L.useState)(!1),[C,w]=(0,L.useState)(!1),[T,E]=(0,L.useState)(null),[D,j]=(0,L.useState)(!1),[N,P]=(0,L.useState)(!1),F=(0,L.useMemo)(()=>[...e].sort((e,t)=>e.role.localeCompare(t.role)),[e]),z=(0,L.useMemo)(()=>i?F.find(e=>e.role===i):null,[i,F]),B=(0,L.useCallback)(async e=>{w(!0),l(null);try{let t=await I(`agent-roster.read-learned`,{role:e});l(t.entries??[]),p({})}catch{}w(!1)},[]),V=(0,L.useCallback)(async()=>{if(!i||!c)return;S(!0);let e=c.filter((e,t)=>u[t]!==`drop`).join(`
2
-
3
- ---
4
-
5
- `);try{await I(`agent-roster.update-learned`,{role:i,content:e}),l(null),p({})}catch{}S(!1)},[i,c,u]),H=(0,L.useCallback)(async()=>{if(!(!i||!m.trim())){v(null),S(!0);try{let e=`> Taught ${new Date().toISOString().slice(0,10)}\n\n${m.trim()}`;(await I(`agent-roster.append-learned`,{role:i,content:e})).success?(v({ok:!0,msg:`Saved to learned.md`}),h(``),r()):v({ok:!1,msg:`Save failed`})}catch(e){v({ok:!1,msg:e instanceof Error?e.message:`Failed`})}S(!1)}},[r,i,m]),U=(0,L.useCallback)(async(e,t)=>{S(!0),v(null);try{let n=await I(`agent-roster.update-learning`,{role:e,enabled:t});if(n.error)throw Error(n.error);v({ok:!0,msg:t?`Automatic learning resumed`:`Automatic learning paused`}),r()}catch(e){v({ok:!1,msg:e instanceof Error?e.message:`Policy update failed`})}finally{S(!1)}},[r]),W=(0,L.useCallback)(async e=>{try{let t=await I(`agent-roster.read-consolidated`,{role:e});E(t.isConsolidated?t.content:null)}catch{E(null)}},[]),G=(0,L.useCallback)(async e=>{j(!0),v(null);try{let n=await I(`agent-roster.consolidate`,{role:e});if(n.error)throw Error(n.error);if(n.rawEntryCount===0){v({ok:!1,msg:`No raw entries to optimize yet.`});return}if(n.consolidated){await r(),await W(e),v({ok:!0,msg:`Optimized. Consolidated knowledge updated.`}),M.success(n.model?`Learnings consolidated with ${n.model}.`:`Learnings consolidated.`);return}if(n.emptySynthesis){v({ok:!1,msg:`The model returned an empty result. Nothing was changed — try again.`}),M.error(`Optimization produced an empty result. Try again.`);return}let i=n.instruction;if(!i)throw Error(`No consolidation instruction generated`);let a=t.getState();a.addMessage({role:`user`,content:i}),a.setLoading(!0),k().sendMessage(i);let o=O.getState();o.setSidebarOpen(!1),o.setCurrentView(`chat`),v({ok:!0,msg:`No active model on server — optimization sent to chat agent instead.`}),M.info(`No active model on server. Optimization sent to the chat agent.`)}catch(e){v({ok:!1,msg:e instanceof Error?e.message:`Optimization failed`}),M.error(e instanceof Error?e.message:`Optimization failed`)}finally{j(!1)}},[r,W]),K=(0,L.useCallback)(async e=>{if(e.length!==0){P(!0),v(null);try{let n=[],r=0,a=0,o=``,s=[];for(let t of e)try{let e=await I(`agent-roster.consolidate`,{role:t});e.error?(a++,o=e.error):e.consolidated?n.push(t):e.rawEntryCount===0?r++:e.emptySynthesis?(a++,o=`Model returned an empty result`):e.instruction?s.push({role:t,instruction:e.instruction}):(a++,o=`No consolidation produced`)}catch(e){a++,o=e instanceof Error?e.message:String(e)}if(i&&n.includes(i)&&await W(i),s.length>0){let e=`Optimize the learned data for ${s.length} agent${s.length>1?`s`:``}. For each agent below, read its raw learned entries, synthesize them into a single narrowly-scoped document preserving every fact, and save the result to its consolidated.md file.\n\n`+s.map(e=>`## Agent: ${e.role}\n\n${e.instruction}`).join(`
6
-
7
- ---
8
-
9
- `),n=t.getState();n.addMessage({role:`user`,content:e}),n.setLoading(!0),k().sendMessage(e);let r=O.getState();r.setSidebarOpen(!1),r.setCurrentView(`chat`)}if(n.length===0&&s.length===0){if(a>0){let t=r>0?` ${r} skipped.`:``,n=`Bulk consolidate failed for ${a} of ${e.length} agent${e.length>1?`s`:``}.${o?` Last error: ${o}`:``}${t}`;v({ok:!1,msg:n});return}let t=r>0?`Bulk optimize: ${r} skipped (no entries to optimize).`:`No agents had optimizable entries.`;v({ok:!0,msg:t}),M.info(t,6e3);return}let c=[];n.length>0&&c.push(`${n.length} consolidated`),s.length>0&&c.push(`${s.length} sent to chat`),r>0&&c.push(`${r} skipped`),a>0&&c.push(`${a} failed`);let l=`Bulk optimize: ${c.join(`, `)}.`;v({ok:a===0,msg:l}),n.length>0&&s.length===0?M.success(l,6e3):M.info(l,6e3)}catch(e){v({ok:!1,msg:e instanceof Error?e.message:`Bulk optimization failed`}),M.error(e instanceof Error?e.message:`Bulk optimization failed`)}finally{P(!1)}}},[i,W]);return F.length===0?(0,R.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-muted-foreground`,children:(0,R.jsxs)(`div`,{className:`text-center space-y-3`,children:[(0,R.jsx)(b,{className:`h-10 w-10 mx-auto opacity-30`}),(0,R.jsx)(`p`,{className:`text-sm`,children:`No self-learning data yet`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground/70`,children:`Learning entries appear when agents capture output`})]})}):(0,R.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(0,R.jsxs)(`div`,{className:A(`flex flex-col min-h-0 min-w-0 overflow-hidden border-r border-border/50`,i?`w-80 shrink-0`:`flex-1`),children:[(0,R.jsxs)(`div`,{className:`shrink-0 px-3 py-2 border-b border-border/50`,children:[(0,R.jsxs)(`h3`,{className:`text-xs font-semibold flex items-center gap-1.5`,children:[(0,R.jsx)(b,{className:`h-3.5 w-3.5 text-brand-2`}),`All Roster Agents`]}),(()=>{let e=F.filter(e=>e.needsSummarization);return e.length===0?null:(0,R.jsxs)(`div`,{className:`mt-2 flex flex-col gap-1.5 rounded border border-warning/40 bg-warning/10 px-2 py-1.5`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(x,{className:`h-3 w-3 text-warning shrink-0`}),(0,R.jsxs)(`span`,{className:`text-[10px] text-warning leading-tight`,children:[e.length,` agent`,e.length>1?`s`:``,` need`,e.length===1?`s`:``,` optimization`]}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>{let t=e[0];t&&(o(t.role),l(null),E(null))},className:`ml-auto text-[9px] text-warning underline hover:text-warning/80 shrink-0`,children:`review →`})]}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>K(e.map(e=>e.role)),disabled:N,className:`flex items-center justify-center gap-1 rounded bg-warning/20 border border-warning/40 px-2 py-1 text-[10px] font-medium text-warning hover:bg-warning/30 transition-colors disabled:opacity-50`,children:[N?(0,R.jsx)(s,{className:`h-3 w-3 animate-spin`}):(0,R.jsx)(x,{className:`h-3 w-3`}),N?`Optimizing…`:`Optimize All (${e.length})`]})]})})()]}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-2 space-y-1`,children:F.map(e=>(0,R.jsxs)(`button`,{type:`button`,onClick:()=>{o(e.role),l(null),E(null)},className:A(`w-full text-left rounded-lg border px-3 py-2 transition-colors`,i===e.role?`border-primary/50 bg-primary/[0.06]`:`border-border/60 hover:border-primary/30`,e.needsSummarization&&i!==e.role&&`border-warning/40`),children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,R.jsx)(`span`,{className:`text-xs font-semibold`,children:e.role}),(0,R.jsx)(`span`,{className:A(`text-[9px] tabular-nums`,e.learningEnabled?`text-success`:`text-muted-foreground`),children:e.learningEnabled?`learning`:`paused`})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2 mt-1 text-[9px] text-muted-foreground`,children:[(0,R.jsxs)(`span`,{className:`tabular-nums`,children:[e.entryCount,` entries`]}),e.sessionCaptureCount>0&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,R.jsxs)(`span`,{className:`text-success tabular-nums`,children:[`+`,e.sessionCaptureCount]})]}),e.lastCapture&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,R.jsx)(`span`,{children:new Date(e.lastCapture).toLocaleDateString()})]}),e.needsSummarization&&(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-warning font-medium`,children:[(0,R.jsx)(x,{className:`h-2.5 w-2.5`}),`optimize`]})]})]},e.role))})]}),(0,R.jsxs)(`div`,{className:`flex-1 min-w-0 overflow-y-auto p-4`,children:[!i&&(0,R.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground`,children:`Select an agent to view learning details`}),i&&z&&(0,R.jsxs)(`div`,{className:`space-y-4`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,R.jsx)(`h3`,{className:`text-base font-semibold`,children:i}),(0,R.jsx)(`div`,{className:`flex gap-1`,children:(0,R.jsxs)(`button`,{type:`button`,onClick:()=>U(i,!z.learningEnabled),disabled:y,className:A(`inline-flex items-center gap-1 rounded border px-2 py-1 text-[10px] transition-colors disabled:opacity-50`,z.learningEnabled?`border-success/40 text-success hover:bg-success/10`:`border-border/50 text-muted-foreground hover:bg-accent`),children:[(0,R.jsx)(b,{className:`h-3 w-3`}),` `,z.learningEnabled?`Learning on`:`Learning paused`]})})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-4 gap-2`,children:[(0,R.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,R.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:`Entries`}),(0,R.jsx)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:z.entryCount})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,R.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:`Size`}),(0,R.jsxs)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:[z.totalBytes,`B`]})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,R.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:`Last Capture`}),(0,R.jsx)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:z.lastCapture?new Date(z.lastCapture).toLocaleDateString():`—`})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,R.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:`Lifetime Captures`}),(0,R.jsx)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:z.lifetimeCaptureCount})]})]}),z.needsSummarization&&(0,R.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-warning bg-warning/10 rounded-lg px-3 py-2.5`,children:[(0,R.jsx)(g,{className:`h-4 w-4 shrink-0`}),(0,R.jsxs)(`span`,{className:`flex-1`,children:[`Learned data exceeds soft limit (`,z.totalBytes.toLocaleString(),`B / 8,192B). Optimize to synthesize raw entries into a consolidated document and reduce context volume.`]}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>G(i),disabled:D,className:`inline-flex items-center gap-1 rounded bg-warning/20 text-warning border border-warning/40 px-2.5 py-1 text-[10px] font-medium hover:bg-warning/30 transition-colors disabled:opacity-50 shrink-0`,children:[D?(0,R.jsx)(s,{className:`h-3 w-3 animate-spin`}):(0,R.jsx)(x,{className:`h-3 w-3`}),D?`Optimizing…`:`Optimize Now`]})]}),(0,R.jsxs)(`div`,{className:`space-y-2 border border-border rounded-lg p-3 bg-card`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(a,{className:`h-4 w-4 text-primary`}),(0,R.jsx)(`span`,{className:`text-xs font-semibold`,children:`Optimize Learnings`})]}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>G(i),disabled:D||z.entryCount===0,className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs text-primary-foreground hover:bg-primary/90 transition-colors disabled:opacity-50`,title:z.entryCount===0?`No raw entries to optimize`:`Synthesize raw entries into a consolidated, narrowly-scoped document`,children:[D?(0,R.jsx)(s,{className:`h-3.5 w-3.5 animate-spin`}):(0,R.jsx)(x,{className:`h-3.5 w-3.5`}),D?`Optimizing…`:`Optimize`]})]}),(0,R.jsxs)(`p`,{className:`text-[10px] text-muted-foreground leading-relaxed`,children:[`Synthesizes all `,z.entryCount,` raw entries into a single reviewed document — narrowly scoped to this agent's skills, preserving every fact but reducing context volume. The result replaces raw entries in the agent's prompt.`]}),z.isConsolidated&&z.consolidation&&(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-muted-foreground pt-1 border-t border-border/50`,children:[(0,R.jsx)(n,{className:`h-3 w-3 text-success`}),(0,R.jsxs)(`span`,{children:[`Consolidated`,` `,new Date(z.consolidation.consolidatedAt).toLocaleDateString(),` ·`,` `,z.consolidation.sourceBytes,`B →`,` `,z.consolidation.consolidatedBytes,`B`,z.consolidation.sourceEntryCount<z.entryCount&&(0,R.jsxs)(`span`,{className:`text-warning ml-1`,children:[`· `,z.entryCount-z.consolidation.sourceEntryCount,` `,`new pending`]})]}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>{T===null?W(i):E(null)},className:`ml-auto underline text-primary hover:text-primary/80`,children:T===null?`View`:`Hide`})]}),T!==null&&(0,R.jsxs)(`div`,{className:`mt-2 max-h-72 overflow-y-auto rounded border border-border/50 bg-background/50 p-2`,children:[(0,R.jsxs)(`div`,{className:`text-[10px] text-muted-foreground mb-1 font-medium`,children:[`Consolidated knowledge for `,i]}),(0,R.jsx)(`pre`,{className:`text-[10px] whitespace-pre-wrap font-sans leading-relaxed`,children:T||`(empty)`})]})]}),z.entryCount>0&&(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,R.jsxs)(`button`,{type:`button`,onClick:()=>B(i),disabled:C,className:`inline-flex items-center gap-1 rounded border border-border/50 px-3 py-1.5 text-xs hover:bg-accent transition-colors`,children:[C?(0,R.jsx)(s,{className:`h-3 w-3 animate-spin`}):(0,R.jsx)(f,{className:`h-3 w-3`}),`Review Learned Entries (`,z.entryCount,`)`]})}),c&&(0,R.jsxs)(`div`,{className:`space-y-2 border border-border rounded-lg p-3 bg-card`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,R.jsxs)(`span`,{className:`text-xs font-medium`,children:[c.filter((e,t)=>u[t]!==`drop`).length,`/`,c.length,` kept`]}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:V,disabled:y,className:`inline-flex items-center gap-1 rounded bg-primary px-2 py-1 text-[10px] text-primary-foreground hover:bg-primary/90 transition-colors`,children:y?`Applying…`:`Apply Selection`}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>{l(null),p({})},className:`inline-flex items-center gap-1 rounded border border-border/50 px-2 py-1 text-[10px] hover:bg-accent transition-colors`,children:`Cancel`})]})]}),(0,R.jsx)(`div`,{className:`max-h-72 overflow-y-auto space-y-2`,children:c.map((e,t)=>{let n=u[t]??`keep`,r=e.length>200?e.slice(0,200)+`…`:e;return(0,R.jsx)(`div`,{className:A(`rounded-lg border p-2 transition-colors`,n===`drop`?`border-destructive/40 bg-destructive/5 opacity-60`:`border-border`),children:(0,R.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,R.jsx)(`pre`,{className:`text-[10px] whitespace-pre-wrap flex-1 leading-relaxed font-sans`,children:r}),(0,R.jsxs)(`div`,{className:`flex gap-1 shrink-0`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>p(e=>({...e,[t]:`keep`})),className:A(`px-2 py-1 text-[9px] rounded`,n===`keep`?`bg-success/20 text-success`:`bg-muted text-muted-foreground`),children:`Keep`}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>p(e=>({...e,[t]:`drop`})),className:A(`px-2 py-1 text-[9px] rounded`,n===`drop`?`bg-destructive/20 text-destructive`:`bg-muted text-muted-foreground`),children:`Drop`})]})]})},t)})})]})]}),(0,R.jsxs)(`div`,{className:`space-y-2 pt-4 border-t border-border`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1 text-sm font-medium`,children:[(0,R.jsx)(d,{className:`h-4 w-4 text-brand-2`}),` Teach this agent`]}),(0,R.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Describe a command, pattern, or behavior you want this agent to remember.`}),(0,R.jsx)(`textarea`,{className:`w-full h-20 text-xs p-2 bg-card border border-border rounded resize-y`,value:m,onChange:e=>h(e.target.value),placeholder:`e.g. Always use pnpm for this project`}),(0,R.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:H,disabled:!m.trim()||y,className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs text-primary-foreground hover:bg-primary/90 transition-colors disabled:opacity-50`,children:[(0,R.jsx)(d,{className:`h-3.5 w-3.5`}),` Teach`]}),_&&(0,R.jsx)(`span`,{className:A(`text-xs`,_.ok?`text-success`:`text-destructive`),children:_.msg})]})]})]})]})]})}function ee({customStats:e,catalog:t}){let[n,r]=(0,L.useState)(``),[a,s]=(0,L.useState)(null),l=(0,L.useMemo)(()=>new Set(e.filter(e=>e.exists||e.hasIdentity||e.hasConfig||e.hasKnowledge).map(e=>e.role)),[e]),u=(0,L.useMemo)(()=>{if(!n.trim())return t;let e=n.toLowerCase();return t.filter(t=>t.role.includes(e)||t.name.toLowerCase().includes(e)||t.summary.toLowerCase().includes(e))},[t,n]),d=(0,L.useCallback)(t=>e.find(e=>e.role===t),[e]),f=u;return(0,R.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,R.jsx)(`div`,{className:`shrink-0 px-3 py-2 border-b border-border/50`,children:(0,R.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border border-border/60 bg-background px-3 py-1.5`,children:[(0,R.jsx)(p,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,R.jsx)(`input`,{type:`text`,value:n,onChange:e=>r(e.target.value),placeholder:`Search agents by name, role, or description…`,className:`flex-1 bg-transparent text-xs outline-none placeholder:text-muted-foreground/50`}),n&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>r(``),className:`text-muted-foreground hover:text-foreground`,children:(0,R.jsx)(h,{className:`h-3 w-3`})})]})}),(0,R.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-3`,children:[(0,R.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-2`,children:f.map(e=>{let t=d(e.role),n=l.has(e.role),r=a===e.role;return(0,R.jsxs)(`div`,{className:A(`rounded-lg border bg-card transition-colors`,r?`border-primary/40 ring-1 ring-primary/20`:`border-border/60 hover:border-primary/30`),children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>s(r?null:e.role),className:`w-full text-left p-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,R.jsx)(o,{className:`h-4 w-4 shrink-0 text-primary`}),(0,R.jsx)(`span`,{className:`text-sm font-semibold truncate`,children:e.name}),(0,R.jsxs)(`code`,{className:`text-[9px] text-muted-foreground font-mono shrink-0`,children:[`@`,e.role]})]}),(0,R.jsx)(c,{className:A(`h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform`,r&&`rotate-180`)})]}),(0,R.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-1 leading-relaxed line-clamp-2`,children:e.summary}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5`,children:[(0,R.jsxs)(`span`,{className:`text-[9px] text-muted-foreground tabular-nums`,children:[e.tools,` tools`]}),e.budget.maxIterations&&(0,R.jsxs)(`span`,{className:`text-[9px] text-muted-foreground tabular-nums`,children:[e.budget.maxIterations.toLocaleString(),` max it`]}),n&&(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 rounded bg-brand-2/10 px-1 py-0.5 text-[8px] text-brand-2 font-medium`,children:[(0,R.jsx)(i,{className:`h-2.5 w-2.5`}),` Customized`]}),t?.needsSummarization&&(0,R.jsx)(`span`,{className:`text-[9px] text-warning`,children:`⚠ Needs summary`})]})]}),r&&(0,R.jsxs)(`div`,{className:`border-t border-border/50 px-3 py-2 space-y-2`,children:[(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,R.jsxs)(`div`,{className:`rounded bg-muted/30 p-1.5`,children:[(0,R.jsx)(`span`,{className:`text-[8px] text-muted-foreground uppercase tracking-wider`,children:`Max Iterations`}),(0,R.jsx)(`div`,{className:`text-xs font-mono mt-0.5`,children:e.budget.maxIterations?.toLocaleString()??`—`})]}),(0,R.jsxs)(`div`,{className:`rounded bg-muted/30 p-1.5`,children:[(0,R.jsx)(`span`,{className:`text-[8px] text-muted-foreground uppercase tracking-wider`,children:`Timeout`}),(0,R.jsx)(`div`,{className:`text-xs font-mono mt-0.5`,children:e.budget.timeoutMs?`${Math.round(e.budget.timeoutMs/6e4)}m`:`—`})]}),(0,R.jsxs)(`div`,{className:`rounded bg-muted/30 p-1.5`,children:[(0,R.jsx)(`span`,{className:`text-[8px] text-muted-foreground uppercase tracking-wider`,children:`Max Tool Calls`}),(0,R.jsx)(`div`,{className:`text-xs font-mono mt-0.5`,children:e.budget.maxToolCalls?.toLocaleString()??`—`})]}),(0,R.jsxs)(`div`,{className:`rounded bg-muted/30 p-1.5`,children:[(0,R.jsx)(`span`,{className:`text-[8px] text-muted-foreground uppercase tracking-wider`,children:`Customized`}),(0,R.jsx)(`div`,{className:`text-xs font-mono mt-0.5`,children:n?`Yes`:`No`})]})]}),n&&t&&(0,R.jsxs)(`div`,{className:`rounded bg-accent/30 p-2 space-y-1`,children:[(0,R.jsx)(`span`,{className:`text-[9px] font-medium text-muted-foreground`,children:`Project Customizations`}),(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2 text-[9px]`,children:[t.hasIdentity&&(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,R.jsx)(i,{className:`h-2.5 w-2.5 text-primary`}),` identity.md`]}),t.entryCount>0&&(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,R.jsx)(b,{className:`h-2.5 w-2.5 text-brand-2`}),` `,t.entryCount,` `,`learned entries`]}),t.hasConfig&&(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,R.jsx)(w,{className:`h-2.5 w-2.5 text-muted-foreground`}),` config.json`]}),t.sessionCaptureCount>0&&(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,R.jsx)(C,{className:`h-2.5 w-2.5 text-success`}),` `,t.sessionCaptureCount,` session captures`]})]})]})]})]},e.role)})}),f.length===0&&(0,R.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-40 text-muted-foreground`,children:[(0,R.jsx)(p,{className:`h-8 w-8 mb-2 opacity-30`}),(0,R.jsxs)(`p`,{className:`text-sm`,children:[`No agents match "`,n,`"`]})]})]}),(0,R.jsxs)(`div`,{className:`shrink-0 border-t border-border/50 px-3 py-2 text-[10px] text-muted-foreground flex items-center gap-2`,children:[(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`strong`,{children:t.length}),` roster roles`]}),(0,R.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,R.jsxs)(`span`,{className:`text-brand-2`,children:[(0,R.jsx)(`strong`,{children:l.size}),` customized`]}),(0,R.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`strong`,{children:e.reduce((e,t)=>e+t.entryCount,0)}),` total learned entries`]})]})]})}var Z={running:{led:`bg-success`,badge:`bg-success/12 text-success`,icon:(0,R.jsx)(`span`,{className:`led text-success led-pulse`}),color:`text-success`},completed:{led:`bg-success`,badge:`bg-success/12 text-success`,icon:(0,R.jsx)(n,{className:`h-3.5 w-3.5`}),color:`text-success`},failed:{led:`bg-destructive`,badge:`bg-destructive/15 text-destructive`,icon:(0,R.jsx)(l,{className:`h-3.5 w-3.5`}),color:`text-destructive`},timeout:{led:`bg-warning`,badge:`bg-muted text-muted-foreground`,icon:(0,R.jsx)(y,{className:`h-3.5 w-3.5`}),color:`text-warning`},stopped:{led:`bg-muted-foreground`,badge:`bg-muted text-muted-foreground`,icon:(0,R.jsx)(`span`,{className:`led text-muted-foreground`}),color:`text-muted-foreground`},idle:{led:`bg-muted-foreground`,badge:`bg-muted text-muted-foreground`,icon:(0,R.jsx)(`span`,{className:`led text-muted-foreground`}),color:`text-muted-foreground`}};function Q(e){let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m ${t%60}s`;let r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d`}function $(e){if(e==null||!Number.isFinite(e)||e<=0)return`$0`;if(e<.01){let t=e.toFixed(5);return t===`0.00000`?`$0`:`$`+t.replace(/(\d)0+$/,`$1`).replace(/\.$/,``)}return`$`+e.toFixed(3)}function te({nowTick:e}){let t=j(e=>e.agents),n=j(e=>e.leaderId),[i,a]=(0,L.useState)(null),[s,c]=(0,L.useState)(`all`),l=(0,L.useMemo)(()=>{let e=Array.from(t.values());return e.sort((e,t)=>{let n=e.status===`running`?0:1,r=t.status===`running`?0:1;return n===r?t.startedAt-e.startedAt:n-r}),s===`all`?e:s===`running`?e.filter(e=>e.status===`running`):s===`done`?e.filter(e=>e.status===`completed`):s===`failed`?e.filter(e=>e.status===`failed`||e.status===`timeout`):e},[t,s]),u=(0,L.useMemo)(()=>{let e=0,n=0,r=0;for(let i of t.values())i.status===`running`?e++:i.status===`completed`?n++:(i.status===`failed`||i.status===`timeout`)&&r++;return{running:e,completed:n,failed:r,total:t.size}},[t]),d=j(e=>e.clearFinishedAgents),f=i?l.find(e=>e.id===i):null,p=(0,L.useCallback)(e=>{let t=O.getState();e?(t.setInspectorFocusedAgentId(e),t.setInspectorTab(`agents`)):t.setInspectorTab(`fleet`),t.setInspectorOpen(!0)},[]);return l.length===0?(0,R.jsx)(`div`,{className:`flex flex-1 items-center justify-center text-muted-foreground`,children:(0,R.jsxs)(`div`,{className:`text-center space-y-3`,children:[(0,R.jsx)(o,{className:`h-10 w-10 mx-auto opacity-30`}),(0,R.jsx)(`p`,{className:`text-sm`,children:`No active fleet agents`}),(0,R.jsx)(`p`,{className:`text-xs text-muted-foreground/70`,children:`Agents appear here when subagents spawn`})]})}):(0,R.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(0,R.jsxs)(`div`,{className:A(`flex flex-col min-h-0 min-w-0 overflow-hidden`,f?`w-80 shrink-0 border-r border-border/50`:`flex-1`),children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0 px-3 py-2 border-b border-border/50`,children:[[`all`,`running`,`done`,`failed`].map(e=>(0,R.jsxs)(`button`,{type:`button`,onClick:()=>c(e),className:A(`rounded px-2 py-0.5 text-[10px] font-medium transition-colors`,s===e?`bg-primary/10 text-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),children:[e===`all`&&`All (${u.total})`,e===`running`&&`Running (${u.running})`,e===`done`&&`Done (${u.completed})`,e===`failed`&&`Failed (${u.failed})`]},e)),(0,R.jsx)(`span`,{className:`flex-1`}),u.completed+u.failed>0&&(0,R.jsxs)(`button`,{type:`button`,onClick:d,className:`inline-flex items-center gap-0.5 rounded px-1.5 py-0.5 text-[10px] text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors`,children:[(0,R.jsx)(r,{className:`h-2.5 w-2.5`}),` Clear`]})]}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-2 space-y-1`,children:l.map(e=>(0,R.jsxs)(`button`,{type:`button`,onClick:()=>a(i===e.id?null:e.id),className:A(`w-full text-left rounded-lg border px-3 py-2 transition-colors flex items-center gap-2`,i===e.id?`border-primary/50 bg-primary/[0.06]`:`border-border/60 hover:border-primary/30 hover:bg-primary/[0.03]`),children:[(0,R.jsx)(`span`,{className:A(`led shrink-0`,Z[e.status]?.led??`bg-muted-foreground`,e.status===`running`&&`led-pulse`)}),(0,R.jsx)(`span`,{className:`text-xs font-semibold min-w-0 truncate max-w-[7rem]`,children:e.name}),e.id===n&&(0,R.jsx)(m,{className:`h-3 w-3 shrink-0 text-warning`}),e.model&&(0,R.jsx)(`span`,{className:`text-[9px] text-muted-foreground font-mono truncate max-w-[6rem] shrink-0`,children:e.model}),(0,R.jsxs)(`span`,{className:`text-[9px] text-muted-foreground tabular-nums shrink-0`,children:[e.iteration,`it · `,e.toolCalls,`t`]}),e.status===`running`&&(0,R.jsx)(`span`,{className:`text-[9px] text-primary tabular-nums shrink-0 ml-auto`,children:Q(Date.now()-e.startedAt)}),e.status!==`running`&&(0,R.jsx)(`span`,{className:A(`text-[9px] tabular-nums shrink-0 ml-auto`,Z[e.status]?.color??`text-muted-foreground`),children:e.status}),e.costUsd>0&&(0,R.jsx)(`span`,{className:`text-[9px] text-success tabular-nums font-medium shrink-0`,children:$(e.costUsd)}),e.status===`running`&&e.currentTool&&(0,R.jsxs)(`span`,{className:`text-[9px] text-primary font-mono truncate max-w-[6rem] shrink-0`,children:[`→ `,e.currentTool]})]},e.id))}),(0,R.jsxs)(`div`,{className:`shrink-0 border-t border-border/50 px-3 py-2 flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`font-medium tabular-nums`,children:u.total}),` agents total`,(0,R.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,R.jsx)(`span`,{className:`text-success tabular-nums`,children:u.running}),` running`,(0,R.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,R.jsx)(`span`,{className:`tabular-nums`,children:u.completed}),` done`,u.failed>0&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`text-muted-foreground/50`,children:`·`}),(0,R.jsx)(`span`,{className:`text-destructive tabular-nums`,children:u.failed}),` failed`]}),(0,R.jsx)(`span`,{className:`flex-1`}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>p(),className:`inline-flex items-center gap-1 rounded border border-border/50 px-2 py-1 hover:bg-accent transition-colors`,children:[(0,R.jsx)(T,{className:`h-3 w-3`}),`Fleet Inspector`]})]})]}),f&&(0,R.jsx)(`div`,{className:`flex-1 min-w-0 overflow-y-auto p-4`,children:(0,R.jsx)(ne,{agent:f,nowTick:e})})]})}function ne({agent:e,nowTick:t}){let n=e.status===`running`?Q(t-e.startedAt):e.completedAt?Q(e.completedAt-e.startedAt):`-`,r=Math.min(100,Math.max(0,e.ctxPct)),i=e.currentTool||e.lastTool,a=j(e=>e.leaderId);return(0,R.jsxs)(`div`,{className:`space-y-4`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(`div`,{className:`flex items-center justify-center w-10 h-10 rounded-lg bg-primary/10`,children:(0,R.jsx)(o,{className:`h-5 w-5 text-primary`})}),(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`text-base font-semibold`,children:e.name}),e.id===a&&(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded border border-warning/30 bg-warning/10 px-1.5 py-0.5 text-[9px] font-medium text-warning`,children:[(0,R.jsx)(m,{className:`h-2.5 w-2.5`}),` Leader`]})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:A(`led`,Z[e.status]?.led,e.status===`running`&&`led-pulse`)}),(0,R.jsx)(`span`,{children:e.status}),e.model&&(0,R.jsxs)(`span`,{children:[`· `,e.provider,`/`,e.model]}),(0,R.jsxs)(`span`,{children:[`· `,n]})]})]})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-4 gap-2`,children:[(0,R.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,R.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:`Iterations`}),(0,R.jsx)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:e.iteration})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,R.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:`Tool Calls`}),(0,R.jsx)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:e.toolCalls})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,R.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:`Cost`}),(0,R.jsx)(`div`,{className:`text-lg font-mono font-semibold mt-0.5 text-success`,children:$(e.costUsd)})]}),(0,R.jsxs)(`div`,{className:`rounded-lg border bg-card p-2`,children:[(0,R.jsx)(`span`,{className:`text-[9px] text-muted-foreground uppercase tracking-wider`,children:`Context`}),(0,R.jsxs)(`div`,{className:`text-lg font-mono font-semibold mt-0.5`,children:[r,`%`]})]})]}),e.maxContext>0&&(0,R.jsxs)(`div`,{className:`space-y-1`,children:[(0,R.jsxs)(`div`,{className:`flex justify-between text-[10px]`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground`,children:`Context Window`}),(0,R.jsxs)(`span`,{className:A(`tabular font-medium`,r>=85?`text-destructive`:r>=70?`text-warning`:`text-success`),children:[e.ctxTokens.toLocaleString(),` / `,e.maxContext.toLocaleString(),` tokens`]})]}),(0,R.jsx)(`div`,{className:`h-2 w-full overflow-hidden rounded-full bg-muted`,children:(0,R.jsx)(`div`,{className:A(`h-full rounded-full transition-all`,r>=85?`bg-destructive`:r>=70?`bg-warning`:`bg-primary`),style:{width:`${Math.max(2,r)}%`}})})]}),i&&(0,R.jsxs)(`div`,{className:A(`flex items-center gap-2 rounded-lg border px-3 py-2`,e.status===`running`?`border-primary/30 bg-primary/[0.04]`:`border-border bg-muted/30`),children:[(0,R.jsx)(S,{className:A(`h-4 w-4`,e.status===`running`?`text-primary animate-pulse`:`text-muted-foreground`)}),(0,R.jsx)(`span`,{className:`text-sm font-mono`,children:e.currentTool??e.lastTool}),(0,R.jsx)(`span`,{className:`text-[10px] text-muted-foreground ml-auto`,children:e.currentTool?`Running`:`Last tool`})]}),e.error&&(0,R.jsxs)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/5 p-3`,children:[(0,R.jsx)(`span`,{className:`text-[10px] font-semibold text-destructive uppercase tracking-wider`,children:`Error`}),(0,R.jsx)(`p`,{className:`text-xs text-destructive/90 mt-1`,children:e.error.message})]}),e.toolLog.length>0&&(0,R.jsxs)(`div`,{className:`space-y-1`,children:[(0,R.jsxs)(`span`,{className:`text-[10px] font-semibold text-muted-foreground uppercase tracking-wider`,children:[`Tool Log (`,e.toolLog.length,`)`]}),(0,R.jsx)(`div`,{className:`space-y-0.5`,children:e.toolLog.slice(0,10).map((e,t)=>(0,R.jsxs)(`div`,{className:A(`flex items-center gap-2 rounded px-2 py-1 text-[10px] font-mono`,e.ok?`bg-muted/30`:`bg-destructive/5 border border-destructive/20`),children:[(0,R.jsx)(`span`,{className:A(`led shrink-0`,e.ok?`text-success`:`text-destructive`)}),(0,R.jsx)(`span`,{className:`truncate flex-1`,children:e.name}),(0,R.jsxs)(`span`,{className:`tabular text-muted-foreground`,children:[e.durationMs,`ms`]}),!e.ok&&(0,R.jsx)(`span`,{className:`text-destructive`,children:`✗`})]},`${e.name}-${t}`))})]}),e.budgetWarning&&(0,R.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg bg-warning/10 border border-warning/25 text-xs`,children:[(0,R.jsx)(x,{className:`h-3.5 w-3.5 text-warning shrink-0`}),(0,R.jsxs)(`span`,{className:`text-warning`,children:[`Budget: `,e.budgetWarning.kind,` limit (`,e.budgetWarning.used,`/`,e.budgetWarning.limit,`)`]})]})]})}function re(){let[e,t]=(0,L.useState)([]),[n,r]=(0,L.useState)(q),[i,a]=(0,L.useState)(!1),[o,s]=(0,L.useState)(null),c=(0,L.useCallback)(async()=>{a(!0),s(null);try{let e=await I(`agent-roster.list`,{});e.stats&&t(e.stats),e.catalog?.length&&r(e.catalog)}catch(e){s(e instanceof Error?e.message:`Failed to load roster`)}a(!1)},[]);return(0,L.useEffect)(()=>{c()},[c]),(0,L.useEffect)(()=>{let e=null,t=k().on(`agent-roster.updated`,()=>{e&&clearTimeout(e),e=setTimeout(()=>{e=null,c()},300)});return()=>{e&&clearTimeout(e),t()}},[c]),{customStats:e,catalog:n,rosterLoading:i,rosterError:o,loadRoster:c}}function ie({customStats:e,catalog:n,onRefresh:o}){let[s,c]=(0,L.useState)(null),[l,d]=(0,L.useState)(null),[p,m]=(0,L.useState)(``),[h,g]=(0,L.useState)(null),[_,v]=(0,L.useState)(!1),[y,x]=(0,L.useState)(null),[S,C]=(0,L.useState)(!1),[T,E]=(0,L.useState)({name:``,role:``,baseRole:`generic`,purpose:``,taskTypes:``}),D=(0,L.useMemo)(()=>s?e.find(e=>e.role===s):null,[s,e]),j=(0,L.useMemo)(()=>{let e=n.find(e=>e.role===s);return e?.systemProtected??!e?.custom},[n,s]),M=(0,L.useCallback)(async(e,t)=>{v(!0),x(null),c(e);try{let n=await I(`agent-roster.read-customization`,{role:e});m(t===`config`?`${JSON.stringify(n.config??{},null,2)}\n`:n[t]??``),d(t),g(null)}catch(e){x(e instanceof Error?e.message:`Failed to load customization`)}finally{v(!1)}},[]),N=(0,L.useCallback)(async e=>{v(!0),x(null),c(e);try{let t=await I(`agent-roster.read-customization`,{role:e});g(t.config??{}),d(null)}catch(e){x(e instanceof Error?e.message:`Failed to load runtime policy`)}finally{v(!1)}},[]),P=(0,L.useCallback)(async e=>{if(s){v(!0),x(null);try{await I(`agent-roster.update-config`,{role:s,config:e}),g(null),o()}catch(e){x(e instanceof Error?e.message:`Runtime policy save failed`)}finally{v(!1)}}},[o,s]),F=(0,L.useCallback)(async()=>{if(!(!s||!l)){v(!0);try{let e={identity:`agent-roster.update-identity`,learned:`agent-roster.update-learned`,config:`agent-roster.update-config`},t={role:s};if(l===`config`)try{t.config=JSON.parse(p)}catch{x(`config.json must contain valid JSON`),v(!1);return}else t.content=p;await I(e[l],t),d(null),x(null),o()}catch(e){x(e instanceof Error?e.message:`Save failed`)}v(!1)}},[s,l,p,o]),z=(0,L.useCallback)(async()=>{if(s)try{let e=await I(`agent-roster.llm-improve`,{role:s,prompt:`Improve this agent for optimal project performance`});if(!e.instruction)throw Error(`No improvement instruction generated`);let n=t.getState();n.addMessage({role:`user`,content:e.instruction}),n.setLoading(!0),k().sendMessage(e.instruction);let r=O.getState();r.setSidebarOpen(!1),r.setCurrentView(`chat`)}catch(e){x(e instanceof Error?e.message:`LLM improvement failed`)}},[s]),B=(0,L.useCallback)(async e=>{if(window.confirm(`Reset all project-specific data for agent "${e}"?`))try{await I(`agent-roster.reset`,{role:e}),c(null),o()}catch{}},[o]),V=(0,L.useCallback)(async()=>{let e=T.taskTypes.split(/[\n,]+/).map(e=>e.trim()).filter(Boolean);v(!0),x(null);try{let t=await I(`agent-roster.create`,{name:T.name,role:T.role,baseRole:T.baseRole,purpose:T.purpose,taskTypes:e});C(!1),E({name:``,role:``,baseRole:`generic`,purpose:``,taskTypes:``}),c(t.role),o()}catch(e){x(e instanceof Error?e.message:`Agent creation failed`)}finally{v(!1)}},[T,o]),H=(0,L.useMemo)(()=>[...e].sort((e,t)=>{let n=+!!e.hasIdentity+ +(e.entryCount>0)+ +!!e.hasConfig;return+!!t.hasIdentity+ +(t.entryCount>0)+ +!!t.hasConfig-n}),[e]);return(0,R.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 overflow-hidden`,children:[(0,R.jsxs)(`div`,{className:`w-80 shrink-0 border-r border-border/50 flex flex-col overflow-hidden`,children:[(0,R.jsx)(`div`,{className:`shrink-0 border-b border-border/50 px-3 py-2`,children:(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsxs)(`h3`,{className:`flex items-center gap-1.5 text-xs font-semibold`,children:[(0,R.jsx)(w,{className:`h-3.5 w-3.5`}),`Project Agents`]}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>{C(!0),c(null),g(null),x(null)},className:`rounded border border-primary/40 px-1.5 py-1 text-[9px] text-primary hover:bg-primary/10`,children:`+ Clone`})]})}),(0,R.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-2 space-y-1`,children:[H.map(e=>(0,R.jsxs)(`button`,{type:`button`,onClick:()=>{c(e.role),g(null),d(null)},className:A(`w-full text-left rounded-lg border px-3 py-2 transition-colors`,s===e.role?`border-primary/50 bg-primary/[0.06]`:`border-border/60 hover:border-primary/30`),children:[(0,R.jsx)(`div`,{className:`text-xs font-semibold`,children:e.role}),(0,R.jsxs)(`div`,{className:`flex gap-2 mt-0.5 text-[9px] text-muted-foreground`,children:[e.hasIdentity&&(0,R.jsx)(`span`,{className:`text-primary`,children:`id`}),e.entryCount>0&&(0,R.jsxs)(`span`,{className:`text-brand-2`,children:[e.entryCount,`e`]}),e.hasConfig&&(0,R.jsx)(`span`,{children:`cfg`})]})]},e.role)),H.length===0&&(0,R.jsx)(`div`,{className:`text-[10px] text-muted-foreground text-center py-4`,children:`No customizations yet`})]})]}),(0,R.jsxs)(`div`,{className:`flex-1 min-w-0 overflow-y-auto p-4`,children:[S&&(0,R.jsxs)(`div`,{className:`max-w-2xl space-y-4`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:`text-base font-semibold`,children:`Create or Clone Project Agent`}),(0,R.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Inherit any roster agent as a template, then develop an independent identity, runtime policy and learned history.`})]}),(0,R.jsxs)(`label`,{className:`block space-y-1 text-xs`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:`Clone from roster role`}),(0,R.jsx)(`select`,{value:T.baseRole,onChange:e=>E(t=>({...t,baseRole:e.target.value})),className:`h-9 w-full rounded border border-border bg-card px-2`,children:[...n].sort((e,t)=>e.name.localeCompare(t.name)).map(e=>(0,R.jsxs)(`option`,{value:e.role,children:[e.name,` (`,e.role,`)`]},e.role))}),(0,R.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Prompt, tools, skills and defaults are inherited. Learning and later edits remain isolated to the new agent.`})]}),(0,R.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,R.jsxs)(`label`,{className:`space-y-1 text-xs`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:`Display name`}),(0,R.jsx)(`input`,{value:T.name,onChange:e=>E(t=>({...t,name:e.target.value})),placeholder:`ABC`,className:`h-9 w-full rounded border border-border bg-card px-2`})]}),(0,R.jsxs)(`label`,{className:`space-y-1 text-xs`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:`Role id (optional)`}),(0,R.jsx)(`input`,{value:T.role,onChange:e=>E(t=>({...t,role:e.target.value})),placeholder:`abc (generated from name)`,className:`h-9 w-full rounded border border-border bg-card px-2 font-mono`})]})]}),(0,R.jsxs)(`label`,{className:`block space-y-1 text-xs`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:`Purpose`}),(0,R.jsx)(`textarea`,{value:T.purpose,onChange:e=>E(t=>({...t,purpose:e.target.value})),placeholder:`Own X, Y and Z workflows for this project and verify their results.`,className:`h-24 w-full resize-y rounded border border-border bg-card p-2`})]}),(0,R.jsxs)(`label`,{className:`block space-y-1 text-xs`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:`Task types (comma or one per line)`}),(0,R.jsx)(`textarea`,{value:T.taskTypes,onChange:e=>E(t=>({...t,taskTypes:e.target.value})),placeholder:`X workflow
10
- Y analysis
11
- Z verification`,className:`h-24 w-full resize-y rounded border border-border bg-card p-2`})]}),y&&(0,R.jsx)(`p`,{className:`text-xs text-destructive`,children:y}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:V,disabled:_||!T.name.trim()||T.purpose.trim().length<10||!T.taskTypes.trim(),className:`rounded bg-primary px-3 py-1.5 text-xs text-primary-foreground disabled:opacity-50`,children:_?`Creating…`:`Clone Agent`}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>C(!1),className:`rounded border border-border px-3 py-1.5 text-xs hover:bg-accent`,children:`Cancel`})]})]}),!S&&!s&&(0,R.jsx)(`div`,{className:`flex items-center justify-center h-full text-muted-foreground`,children:`Select an agent to edit customizations`}),!S&&s&&D&&(0,R.jsxs)(`div`,{className:`space-y-4 max-w-2xl`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,R.jsx)(`h3`,{className:`text-base font-semibold`,children:s}),(0,R.jsxs)(`div`,{className:`flex gap-1`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:z,className:`inline-flex items-center gap-1 rounded border border-border/50 px-2 py-1 text-[10px] hover:bg-accent transition-colors`,children:[(0,R.jsx)(a,{className:`h-3 w-3 text-brand-2`}),` LLM Improve`]}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>B(s),className:`inline-flex items-center gap-1 rounded border border-destructive/30 px-2 py-1 text-[10px] text-destructive hover:bg-destructive/10 transition-colors`,children:[(0,R.jsx)(r,{className:`h-3 w-3`}),` Reset`]})]})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[D.hasIdentity&&(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-primary/10 px-2 py-1 text-[10px] text-primary`,children:[(0,R.jsx)(i,{className:`h-3 w-3`}),` identity.md`]}),D.hasConfig&&(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-muted px-2 py-1 text-[10px] text-muted-foreground`,children:[(0,R.jsx)(w,{className:`h-3 w-3`}),` config.json`]}),D.hasKnowledge&&(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-muted px-2 py-1 text-[10px] text-muted-foreground`,children:[(0,R.jsx)(b,{className:`h-3 w-3`}),` knowledge.json`]}),D.entryCount>0&&(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-brand-2/10 px-2 py-1 text-[10px] text-brand-2`,children:[(0,R.jsx)(f,{className:`h-3 w-3`}),` `,D.entryCount,` learned entries`]})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>M(s,`identity`),className:`inline-flex items-center gap-1 rounded border border-border/50 px-3 py-1.5 text-xs hover:bg-accent transition-colors`,children:[(0,R.jsx)(i,{className:`h-3.5 w-3.5`}),` Edit identity.md`]}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>M(s,`learned`),className:`inline-flex items-center gap-1 rounded border border-border/50 px-3 py-1.5 text-xs hover:bg-accent transition-colors`,children:[(0,R.jsx)(f,{className:`h-3.5 w-3.5`}),` Edit learned.md`]}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>N(s),className:`inline-flex items-center gap-1 rounded border border-primary/40 bg-primary/5 px-3 py-1.5 text-xs text-primary hover:bg-primary/10 transition-colors`,children:[(0,R.jsx)(u,{className:`h-3.5 w-3.5`}),` Runtime policy`]}),(0,R.jsxs)(`button`,{type:`button`,onClick:()=>M(s,`config`),className:`inline-flex items-center gap-1 rounded border border-border/50 px-3 py-1.5 text-xs hover:bg-accent transition-colors`,children:[(0,R.jsx)(w,{className:`h-3.5 w-3.5`}),` Edit config.json`]})]}),y&&(0,R.jsx)(`p`,{className:`text-xs text-destructive`,children:y}),h&&(0,R.jsx)(G,{initialConfig:h,systemProtected:j,saving:_,onSave:P,onCancel:()=>g(null)},s),l&&(0,R.jsxs)(`div`,{className:`space-y-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,R.jsxs)(`span`,{className:`text-xs font-medium`,children:[l,`.md / `,l,`.json`]}),(0,R.jsxs)(`div`,{className:`flex gap-1`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:F,disabled:_,className:`inline-flex items-center gap-1 rounded bg-primary px-3 py-1.5 text-xs text-primary-foreground hover:bg-primary/90 transition-colors disabled:opacity-50`,children:_?`Saving…`:`Save`}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>d(null),className:`inline-flex items-center gap-1 rounded border border-border/50 px-3 py-1.5 text-xs hover:bg-accent transition-colors`,children:`Cancel`})]})]}),(0,R.jsx)(`textarea`,{className:`w-full h-48 font-mono text-xs p-2 bg-card border border-border rounded resize-y`,value:p,onChange:e=>m(e.target.value),placeholder:l===`config`?`{ "tools": [...], "budget": {...} }`:`# Project identity for ${s}\n\nDescribe this agent's role…`})]})]})]})]})}function ae({className:e}){let[t,n]=(0,L.useState)(`live`),[r,i]=(0,L.useState)(Date.now()),{customStats:a,catalog:o,rosterLoading:s,rosterError:c,loadRoster:l}=re();return(0,L.useEffect)(()=>{let e=setInterval(()=>{document.hidden||i(Date.now())},2e3);return()=>clearInterval(e)},[]),(0,R.jsxs)(`div`,{className:A(`flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden`,e),children:[(0,R.jsx)(J,{customStats:a,rosterLoading:s,onRefresh:l}),(0,R.jsx)(Y,{activeTab:t,onTabChange:n}),(0,R.jsxs)(`div`,{className:`flex min-h-0 min-w-0 w-full flex-1 overflow-hidden bg-background/50`,children:[c&&(0,R.jsxs)(`div`,{className:`flex items-center justify-center w-full text-destructive text-xs gap-2`,children:[(0,R.jsx)(g,{className:`h-4 w-4`}),c,(0,R.jsx)(`button`,{type:`button`,onClick:l,className:`underline`,children:`Retry`})]}),t===`live`&&(0,R.jsx)(te,{nowTick:r}),t===`catalog`&&(0,R.jsx)(ee,{customStats:a,catalog:o}),t===`learning`&&(0,R.jsx)(X,{customStats:a,onRefresh:l}),t===`customize`&&(0,R.jsx)(ie,{customStats:a,catalog:o,onRefresh:l})]})]})}export{ae as AgentRosterView};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Bi as t,Fn as n,Kn as r,Tt as i,bt as a,et as o,ft as s,ga as c,oi as l,pa as u,ri as d,xa as f,xt as p}from"./vendor-9hC4n4Me.js";import"./i18n-C2VyJ0Kz.js";import{t as m}from"./ws-client-eyEv8wbm.js";import{M as h}from"./stores-hEu6z1qz.js";import{b as g,f as _,p as v}from"./index-DSXHr5yP.js";var y=e(f(),1),b=o();function x(e){let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m ${t%60}s`;let r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d`}function S(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function C(e){return e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function w(e){return new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function T(e){return e.includes(`error`)||e.includes(`fail`)?`text-destructive`:e.includes(`warn`)?`text-warning`:e.includes(`success`)||e.includes(`complete`)?`text-success`:`text-muted-foreground`}function E({icon:e,label:t,value:n,sub:r,color:i=`text-muted-foreground`}){return(0,b.jsxs)(`div`,{className:`flex items-start gap-3 rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsx)(`div`,{className:`mt-0.5 ${i}`,children:e}),(0,b.jsxs)(`div`,{className:`min-w-0`,children:[(0,b.jsx)(`div`,{className:`text-2xl font-semibold tabular-nums text-foreground`,children:n}),(0,b.jsx)(`div`,{className:`mt-0.5 text-xs text-muted-foreground`,children:t}),r?(0,b.jsx)(`div`,{className:`mt-1 text-xs text-muted-foreground/70`,children:r}):null]})]})}function D(){let{t:e}=c(),[o,f]=(0,y.useState)(null),[D,O]=(0,y.useState)([]),[k,A]=(0,y.useState)([]),[j,M]=(0,y.useState)(null),[N,P]=(0,y.useState)(!0),[F,I]=(0,y.useState)(!1),L=(0,y.useRef)(null),R=(0,y.useCallback)(async()=>{try{let e=await fetch(`/api/analytics/summary`);if(e.ok){let t=await e.json();f(t)}}catch{}},[]),z=(0,y.useCallback)(async()=>{try{let e=await fetch(`/api/analytics?limit=50`);if(e.ok){let t=await e.json();O(t.events)}}catch{}},[]),B=(0,y.useCallback)(async()=>{try{let e=await fetch(`/api/sessions`);if(e.ok){let t=await e.json();A(t)}}catch{}},[]),V=(0,y.useCallback)(async()=>{if(!F){I(!0);try{let e=m(h.getState().wsUrl);L.current=e;let t=e.on(`stats.get`,e=>{let n=e.payload;M(n),I(!1),t()});e.getStats({echoToChat:!1}),setTimeout(()=>{I(!1),t()},8e3)}catch{I(!1)}}},[F]);(0,y.useEffect)(()=>{let e=()=>{Promise.all([R(),z(),B(),V()]).finally(()=>P(!1))};e();let t=setInterval(e,1e4);return()=>clearInterval(t)},[R,z,B,V]);let{totalAgents:H,activeAgents:U,totalToolCalls:W,totalIterations:G}=(0,y.useMemo)(()=>{let e=0,t=0,n=0,r=0;for(let i of k)for(let a of i.agents)e++,a.status===`running`&&t++,n+=a.toolCalls,r+=a.iterations;return{totalAgents:e,activeAgents:t,totalToolCalls:n,totalIterations:r}},[k]),K=(0,y.useMemo)(()=>o?Object.entries(o.categoryBreakdown).sort((e,t)=>t[1]-e[1]).slice(0,8):[],[o]),q=(0,y.useMemo)(()=>o?Object.entries(o.eventBreakdown).sort((e,t)=>t[1]-e[1]).slice(0,10):[],[o]),J=(0,y.useMemo)(()=>{if(!o)return 0;let e=0;for(let[t,n]of Object.entries(o.eventBreakdown))t.toLowerCase().includes(`error`)&&(e+=n);return e},[o]),Y=(0,y.useMemo)(()=>{if(!o)return 0;let e=0;for(let[t,n]of Object.entries(o.eventBreakdown))t.toLowerCase().includes(`warn`)&&(e+=n);return e},[o]),X=v((0,y.useMemo)(()=>[...D].reverse(),[D]),20);return N?(0,b.jsx)(`div`,{className:`flex h-full min-h-0 items-center justify-center bg-[hsl(var(--surface-2)/0.45)] p-4`,children:(0,b.jsxs)(`div`,{className:`ws-surface flex items-center gap-2 rounded-xl px-4 py-3 text-sm text-muted-foreground`,children:[(0,b.jsx)(r,{className:`h-4 w-4 animate-spin text-primary`}),e(`activity:analytics.loading`)]})}):(0,b.jsx)(`div`,{ref:g(`analytics`),className:`h-full min-h-0 min-w-0 overflow-y-auto overscroll-contain bg-[hsl(var(--surface-2)/0.45)] p-4 sm:p-6`,children:(0,b.jsxs)(`div`,{className:`mx-auto flex w-full max-w-7xl flex-col gap-5`,children:[(0,b.jsx)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:(0,b.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,b.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,b.jsx)(t,{className:`h-4 w-4 text-primary`}),(0,b.jsx)(`h1`,{className:`truncate text-base font-semibold`,children:e(`activity:analytics.heading`)})]}),(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.autoRefresh`)})]})}),(0,b.jsxs)(`div`,{className:`min-w-0 space-y-5`,children:[(0,b.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3`,children:[(0,b.jsx)(E,{icon:(0,b.jsx)(u,{className:`h-4 w-4`}),label:e(`activity:analytics.liveSessions`),value:k.length,color:`text-primary`}),(0,b.jsx)(E,{icon:(0,b.jsx)(s,{className:`h-4 w-4`}),label:e(`activity:analytics.agents`),value:`${U}/${H}`,sub:U>0?e(`activity:analytics.agentsActive`,{count:U}):void 0,color:`text-success`}),(0,b.jsx)(E,{icon:(0,b.jsx)(n,{className:`h-4 w-4`}),label:e(`activity:analytics.totalEvents`),value:o?.totalEvents??0,sub:e(`activity:analytics.categoriesSub`,{count:o?.uniqueCategories??0}),color:`text-warning`}),(0,b.jsx)(E,{icon:(0,b.jsx)(i,{className:`h-4 w-4`}),label:e(`activity:analytics.toolCalls`),value:W,sub:e(`activity:analytics.iterationsSub`,{count:G}),color:`text-success`}),(0,b.jsx)(E,{icon:(0,b.jsx)(d,{className:`h-4 w-4`}),label:e(`activity:analytics.sessionCost`),value:j?C(j.cost):`—`,sub:j?e(`activity:analytics.tokensSub`,{input:S(j.usage.input),output:S(j.usage.output)}):void 0,color:`text-primary`}),(0,b.jsx)(E,{icon:(0,b.jsx)(l,{className:`h-4 w-4`}),label:e(`activity:analytics.sessionDuration`),value:j?x(j.elapsedMs):`—`,sub:j?e(`activity:analytics.messagesSub`,{count:j.messages}):void 0,color:`text-muted-foreground`})]}),(0,b.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(p,{className:`h-3.5 w-3.5 text-primary`}),e(`activity:analytics.eventsByCategory`)]}),K.length===0?(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.noEvents`)}):(0,b.jsx)(`div`,{className:`space-y-1.5`,children:K.map(([e,t])=>{let n=K[0]?.[1]??1,r=Math.round(t/n*100);return(0,b.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,7rem)_minmax(0,1fr)_2.5rem] items-center gap-2 text-xs`,children:[(0,b.jsx)(`span`,{className:`min-w-0 truncate text-foreground`,children:e}),(0,b.jsx)(`div`,{className:`h-4 overflow-hidden rounded-full bg-muted`,children:(0,b.jsx)(`div`,{className:`h-full rounded-full bg-primary/70 transition-all`,style:{width:`${Math.max(r,4)}%`}})}),(0,b.jsx)(`span`,{className:`text-right tabular-nums text-muted-foreground`,children:t})]},e)})})]}),(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(t,{className:`h-3.5 w-3.5 text-warning`}),e(`activity:analytics.topEvents`)]}),q.length===0?(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.noEvents`)}):(0,b.jsx)(`div`,{className:`space-y-1.5`,children:q.map(([e,t])=>{let n=q[0]?.[1]??1,r=Math.round(t/n*100);return(0,b.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,9rem)_minmax(0,1fr)_2.5rem] items-center gap-2 text-xs`,children:[(0,b.jsx)(`span`,{className:`min-w-0 truncate ${T(e)}`,children:e}),(0,b.jsx)(`div`,{className:`h-4 overflow-hidden rounded-full bg-muted`,children:(0,b.jsx)(`div`,{className:`h-full rounded-full bg-warning/70 transition-all`,style:{width:`${Math.max(r,4)}%`}})}),(0,b.jsx)(`span`,{className:`text-right tabular-nums text-muted-foreground`,children:t})]},e)})})]})]}),(0,b.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(d,{className:`h-3.5 w-3.5 text-primary`}),e(`activity:analytics.activeSessionUsage`)]}),j?(0,b.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 text-xs`,children:[(0,b.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.provider`)}),(0,b.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-foreground`,children:j.provider})]}),(0,b.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.model`)}),(0,b.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-foreground`,children:j.model})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.inputTokens`)}),(0,b.jsx)(`p`,{className:`mt-0.5 tabular-nums text-foreground`,children:S(j.usage.input)})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.outputTokens`)}),(0,b.jsx)(`p`,{className:`mt-0.5 tabular-nums text-foreground`,children:S(j.usage.output)})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.cacheRatio`)}),(0,b.jsxs)(`p`,{className:`mt-0.5 tabular-nums text-foreground`,children:[(j.cache.ratio*100).toFixed(1),`%`]})]}),(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/70 bg-background/50 px-3 py-2`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.filesRead`)}),(0,b.jsx)(`p`,{className:`mt-0.5 tabular-nums text-foreground`,children:j.readFiles})]})]}):(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.noSession`)})]}),(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(a,{className:`h-3.5 w-3.5 text-warning`}),e(`activity:analytics.healthErrors`)]}),(0,b.jsx)(`div`,{className:`space-y-2 text-xs`,children:o?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`flex justify-between`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.errorEvents`)}),(0,b.jsx)(`span`,{className:`tabular-nums text-destructive`,children:J})]}),(0,b.jsxs)(`div`,{className:`flex justify-between`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.warningEvents`)}),(0,b.jsx)(`span`,{className:`tabular-nums text-warning`,children:Y})]}),(0,b.jsxs)(`div`,{className:`flex justify-between`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.cacheHitRate`)}),(0,b.jsx)(`span`,{className:`tabular-nums text-success`,children:j?`${(j.cache.ratio*100).toFixed(1)}%`:`—`})]}),(0,b.jsxs)(`div`,{className:`flex justify-between`,children:[(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:e(`activity:analytics.totalCategories`)}),(0,b.jsx)(`span`,{className:`tabular-nums text-foreground`,children:o.uniqueCategories})]})]}):(0,b.jsx)(`p`,{className:`text-muted-foreground`,children:e(`activity:analytics.waitingData`)})})]})]}),(0,b.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,b.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,b.jsx)(u,{className:`h-3.5 w-3.5 text-primary`}),e(`activity:analytics.recentEvents`)]}),D.length===0?(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`activity:analytics.noRecentEvents`)}):(0,b.jsx)(`div`,{className:`max-h-64 space-y-1 overflow-y-auto`,children:X.pageItems.map((e,t)=>(0,b.jsxs)(`div`,{className:`grid grid-cols-[4rem_minmax(0,7rem)_minmax(0,6rem)_minmax(0,1fr)] items-start gap-2 rounded px-2 py-1 text-xs hover:bg-muted/60`,children:[(0,b.jsx)(`span`,{className:`tabular-nums text-muted-foreground/70`,children:w(e.timestamp)}),(0,b.jsx)(`span`,{className:`min-w-0 truncate ${T(e.event)}`,children:e.event}),(0,b.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,children:e.category}),(0,b.jsx)(`span`,{className:`min-w-0 truncate text-foreground/80`,children:e.label??e.sessionId??``})]},`${e.timestamp}-${t}`))}),(0,b.jsx)(_,{page:X.page,pageSize:X.pageSize,totalItems:X.totalItems,onPageChange:X.setPage,compact:!0,itemLabel:`events`,className:`mt-3 rounded-lg border`})]})]})]})})}export{D as AnalyticsDashboard};
@@ -1,3 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ct as t,Dt as n,Ht as r,Zt as i,at as a,cn as o,et as s,ni as c,pn as l,vt as u,wr as d,xa as f}from"./vendor-9hC4n4Me.js";import{t as p}from"./useWebSocket-Ba38Sknk.js";import{t as m}from"./utils-DzRQUvln.js";import{a as h,i as g,n as _,o as v,r as y,t as b}from"./dialog-BLr7olIX.js";import{t as x}from"./button-Bmh1yFe5.js";import{t as S}from"./input-BRS2rHSR.js";import{f as C,p as w}from"./index-DSXHr5yP.js";import{g as T,i as E,r as D,y as O}from"./shared-DYL4K3aB.js";var k=e(f(),1),A=s();function j(e){if(!Array.isArray(e))return;let t=[...new Set(e.filter(e=>typeof e==`string`).map(e=>e.trim()).filter(Boolean))];return t.length>0?t:void 0}function M(e){if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e,n={roles:j(t.roles),taskTypes:j(t.taskTypes),modes:j(t.modes)};return n.roles||n.taskTypes||n.modes?n:void 0}function N(e){let t=e.trim().replace(/^```(?:json)?\s*/i,``).replace(/\s*```$/,``),n=JSON.parse(t);if(!Array.isArray(n))throw Error(`Input must be a JSON array.`);let r=[],i=0;for(let e of n){if(!e||typeof e!=`object`||Array.isArray(e)){i++;continue}let t=e,n=typeof t.text==`string`?t.text.trim():``,a=M(t.audience);if(!n||!a){i++;continue}let o=typeof t.kind==`string`&&E.some(e=>e===t.kind)?t.kind:void 0,s=j(t.tags);r.push({text:n,audience:a,kind:o,tags:s,importance:typeof t.importance==`number`?t.importance:void 0,confidence:typeof t.confidence==`number`?t.confidence:void 0})}return{entries:r,skipped:i}}function P(e,t){if(!t)return!0;let n=e.audience;return[e.text,e.kind,e.status,...n?.roles??[],...n?.taskTypes??[],...n?.modes??[]].join(` `).toLocaleLowerCase().includes(t.toLocaleLowerCase())}function F(e,t){return[...new Set(e.flatMap(e=>e.audience?.[t]??[]).filter(e=>e.length>0))].sort((e,t)=>e.localeCompare(t))}function I(){let e=p(),[r,s]=(0,k.useState)([]),[f,E]=(0,k.useState)(!0),[D,O]=(0,k.useState)(null),[j,M]=(0,k.useState)(``),[I,z]=(0,k.useState)(!1),[B,V]=(0,k.useState)(!1),[H,U]=(0,k.useState)(null),[W,G]=(0,k.useState)(!1),[K,q]=(0,k.useState)(!1),J=(0,k.useRef)(null),Y=(0,k.useCallback)(()=>{E(!0),O(null),e.listSageMemories({echoToChat:!1})},[e.listSageMemories]);(0,k.useEffect)(()=>{let t=e.client,n=t.on(`memory.sage.list`,e=>{let t=e.payload;t.error?O({tone:`error`,text:t.error}):s(t.memories??[]),E(!1)}),r=t.on(`memory.sage.remember`,e=>{let t=e.payload;if(G(!1),t.error){O({tone:`error`,text:t.error});return}t.memory&&(s(e=>[t.memory,...e.filter(e=>e.id!==t.memory.id)]),z(!1))}),i=t.on(`memory.sage.update`,e=>{let t=e.payload;t.error?O({tone:`error`,text:t.error}):t.memory&&(s(e=>e.map(e=>e.id===t.memory.id?t.memory:e)),t.memory.audience||O({tone:`success`,text:`Audience scope removed. The memory is now general.`}))}),a=t.on(`memory.sage.delete`,e=>{let t=e.payload,n=J.current;t.success&&n?(s(e=>e.filter(e=>e.id!==n)),O({tone:`success`,text:`Audience memory deleted.`}),U(null),q(!1),J.current=null):t.success?Y():(O({tone:`error`,text:t.message??`Could not delete the memory.`}),q(!1),J.current=null)});return Y(),()=>{n(),r(),i(),a()}},[Y,e.client]);let X=(0,k.useMemo)(()=>r.filter(e=>{let t=e.audience;return!!(t&&(t.roles?.length||t.taskTypes?.length||t.modes?.length))}),[r]),Z=j.trim(),Q=(0,k.useMemo)(()=>X.filter(e=>P(e,Z)),[Z,X]),$=w(Q,16,Z),ie=(0,k.useMemo)(()=>F(X,`roles`),[X]),ae=(0,k.useMemo)(()=>F(X,`taskTypes`),[X]),oe=(0,k.useMemo)(()=>F(X,`modes`),[X]),se=t=>{O(null),e.updateSage(t,{audience:void 0},{echoToChat:!1})},ce=()=>{H&&(J.current=H,q(!0),O(null),e.deleteSage(H,`Removed from the audience memory panel.`))},le=async()=>{let e=X.map(e=>({id:e.id,text:e.text,kind:e.kind,status:e.status,audience:e.audience,tags:e.tags,importance:e.importance,confidence:e.confidence}));try{if(!navigator.clipboard)throw Error(`Clipboard access is unavailable.`);await navigator.clipboard.writeText(JSON.stringify(e,null,2)),O({tone:`success`,text:`${e.length} audience memor${e.length===1?`y`:`ies`} copied as JSON.`})}catch(e){O({tone:`error`,text:e instanceof Error?e.message:`Failed to copy JSON to the clipboard.`})}};return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`section`,{className:`flex h-full min-h-0 flex-col bg-card/20`,"aria-labelledby":`audience-memory-title`,children:[(0,A.jsxs)(`div`,{className:`shrink-0 border-b border-border/60 p-3`,children:[(0,A.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,A.jsx)(`div`,{className:`min-w-0`,children:(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-md border border-primary/20 bg-primary/10 text-primary`,children:(0,A.jsx)(n,{className:`size-3.5`})}),(0,A.jsxs)(`div`,{className:`min-w-0`,children:[(0,A.jsx)(`h2`,{id:`audience-memory-title`,className:`truncate text-sm font-semibold`,children:`Audience Memory`}),(0,A.jsx)(`p`,{className:`truncate text-[10px] text-muted-foreground`,children:`Guidance routed to matching agents`})]})]})}),(0,A.jsxs)(x,{variant:`default`,size:`sm`,className:`h-7 shrink-0 gap-1 px-2 text-xs`,onClick:()=>z(!0),children:[(0,A.jsx)(l,{className:`size-3`}),`Add`]})]}),(0,A.jsxs)(`div`,{className:`mt-3 grid grid-cols-4 gap-px overflow-hidden rounded-md border border-border/60 bg-border/60`,children:[(0,A.jsx)(L,{value:X.length,label:`Memories`}),(0,A.jsx)(L,{value:ie.length,label:`Roles`}),(0,A.jsx)(L,{value:ae.length,label:`Tasks`}),(0,A.jsx)(L,{value:oe.length,label:`Modes`})]}),(0,A.jsxs)(`div`,{className:`mt-3 flex items-center gap-1.5`,children:[(0,A.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,A.jsx)(i,{className:`pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,A.jsx)(S,{value:j,onChange:e=>M(e.target.value),placeholder:`Search text, role, task or mode…`,"aria-label":`Search audience memories`,className:`h-8 pl-8 pr-8 text-xs`}),j&&(0,A.jsx)(`button`,{type:`button`,className:`absolute right-2 top-1/2 -translate-y-1/2 rounded-sm p-0.5 text-muted-foreground hover:text-foreground`,onClick:()=>M(``),"aria-label":`Clear audience memory search`,children:(0,A.jsx)(a,{className:`size-3`})})]}),(0,A.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,onClick:Y,"aria-label":`Refresh audience memories`,title:`Refresh`,children:(0,A.jsx)(o,{className:m(`size-3.5`,f&&`animate-spin`)})}),(0,A.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,onClick:()=>V(!0),"aria-label":`Import audience memories`,title:`Import JSON`,children:(0,A.jsx)(u,{className:`size-3.5`})}),(0,A.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0`,onClick:()=>void le(),"aria-label":`Copy audience memories as JSON`,title:`Copy JSON`,disabled:X.length===0,children:(0,A.jsx)(c,{className:`size-3.5`})})]})]}),D&&(0,A.jsxs)(`div`,{role:D.tone===`error`?`alert`:`status`,className:m(`mx-3 mt-3 flex shrink-0 items-start justify-between gap-2 rounded-md border px-2.5 py-2 text-[11px]`,D.tone===`error`?`border-destructive/30 bg-destructive/5 text-destructive`:`border-success/30 bg-success/5 text-success`),children:[(0,A.jsx)(`span`,{children:D.text}),(0,A.jsx)(`button`,{type:`button`,onClick:()=>O(null),className:`shrink-0 rounded-sm opacity-70 hover:opacity-100`,"aria-label":`Dismiss message`,children:(0,A.jsx)(a,{className:`size-3`})})]}),(0,A.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[!f&&X.length>0&&(0,A.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between px-3 pb-1.5 pt-3 text-[10px] text-muted-foreground`,children:[(0,A.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,A.jsx)(d,{className:`size-3`}),Z?`${Q.length} of ${X.length}`:`${X.length} scoped`]}),Z&&(0,A.jsx)(`button`,{type:`button`,className:`hover:text-foreground`,onClick:()=>M(``),children:`Clear filter`})]}),(0,A.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-3`,children:[f?(0,A.jsx)(ee,{}):X.length===0?(0,A.jsx)(te,{onAdd:()=>z(!0)}):Q.length===0?(0,A.jsxs)(`div`,{className:`flex h-full min-h-32 flex-col items-center justify-center px-4 text-center`,children:[(0,A.jsx)(i,{className:`mb-2 size-5 text-muted-foreground/60`}),(0,A.jsx)(`p`,{className:`text-xs font-medium`,children:`No matching memories`}),(0,A.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground`,children:`Try another role, task, mode, or phrase.`}),(0,A.jsx)(x,{variant:`ghost`,size:`sm`,className:`mt-2 h-7 text-xs`,onClick:()=>M(``),children:`Clear search`})]}):(0,A.jsx)(`ul`,{className:`space-y-2`,children:$.pageItems.map(e=>(0,A.jsx)(R,{memory:e,onFilter:M,onClearScope:()=>se(e.id),onDelete:()=>U(e.id)},e.id))}),(0,A.jsx)(C,{page:$.page,pageSize:$.pageSize,totalItems:$.totalItems,onPageChange:$.setPage,compact:!0,itemLabel:`memories`})]})]})]}),(0,A.jsx)(ne,{open:I,busy:W,onOpenChange:e=>{W||z(e)},onCreate:t=>{O(null),G(!0),e.rememberSage({text:t.text,kind:t.kind,audience:{roles:t.roles.length>0?t.roles:void 0,taskTypes:t.taskTypes.length>0?t.taskTypes:void 0,modes:t.modes.length>0?t.modes:void 0}},{echoToChat:!1})}}),(0,A.jsx)(re,{open:B,onOpenChange:V,onImport:t=>{try{let{entries:n,skipped:r}=N(t);if(n.length===0)return O({tone:`error`,text:`No valid audience-scoped memories were found in the JSON.`}),!1;for(let t of n)e.rememberSage(t,{echoToChat:!1});return O({tone:`success`,text:`${n.length} memor${n.length===1?`y`:`ies`} queued for import${r?`; ${r} invalid ${r===1?`entry was`:`entries were`} skipped`:``}.`}),V(!1),!0}catch(e){return O({tone:`error`,text:e instanceof Error?e.message:`Invalid JSON.`}),!1}}}),(0,A.jsx)(b,{open:!!H,onOpenChange:e=>{!e&&!K&&U(null)},children:(0,A.jsxs)(_,{className:`max-w-md`,children:[(0,A.jsxs)(h,{children:[(0,A.jsx)(v,{children:`Delete this audience memory?`}),(0,A.jsx)(y,{children:`This removes the memory from active use. To keep it as general project guidance, cancel and use the un-scope action instead.`})]}),(0,A.jsx)(`div`,{className:`rounded-md border border-border/70 bg-background/45 p-3 text-xs text-muted-foreground`,children:T(r.find(e=>e.id===H)?.text??``,180)}),(0,A.jsxs)(g,{children:[(0,A.jsx)(x,{variant:`outline`,onClick:()=>U(null),disabled:K,children:`Cancel`}),(0,A.jsxs)(x,{variant:`destructive`,onClick:ce,disabled:K,children:[(0,A.jsx)(t,{className:`size-4`}),K?`Deleting…`:`Delete memory`]})]})]})})]})}function L({value:e,label:t}){return(0,A.jsxs)(`div`,{className:`bg-card/95 px-1.5 py-2 text-center`,children:[(0,A.jsx)(`p`,{className:`text-sm font-semibold tabular-nums`,children:e}),(0,A.jsx)(`p`,{className:`truncate text-[9px] uppercase tracking-wide text-muted-foreground`,children:t})]})}function R({memory:e,onFilter:n,onClearScope:i,onDelete:a}){return(0,A.jsxs)(`li`,{className:`group rounded-md border border-border/65 bg-card/55 p-2.5 transition-colors hover:border-border hover:bg-card/85`,children:[(0,A.jsx)(`p`,{className:`break-words text-xs leading-5`,children:e.text}),e.audience&&(0,A.jsx)(z,{audience:e.audience,onFilter:n}),(0,A.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2 border-t border-border/45 pt-2`,children:[(0,A.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-[9px] uppercase tracking-wide text-muted-foreground`,children:[(0,A.jsx)(`span`,{className:`truncate`,children:D[e.kind]??e.kind}),(0,A.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,A.jsx)(`span`,{children:e.status})]}),(0,A.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,A.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-6`,onClick:i,"aria-label":`Remove audience scope from ${T(e.text,42)}`,title:`Make general memory`,children:(0,A.jsx)(r,{className:`size-3`})}),(0,A.jsx)(x,{variant:`ghost`,size:`icon`,className:`size-6 text-destructive hover:text-destructive`,onClick:a,"aria-label":`Delete ${T(e.text,42)}`,title:`Delete`,children:(0,A.jsx)(t,{className:`size-3`})})]})]})]})}function z({audience:e,onFilter:t}){return(0,A.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[...(e.roles??[]).map(e=>({label:`role`,value:e})),...(e.taskTypes??[]).map(e=>({label:`task`,value:e})),...(e.modes??[]).map(e=>({label:`mode`,value:e}))].map(({label:e,value:n})=>(0,A.jsxs)(`button`,{type:`button`,className:`max-w-full truncate rounded border border-primary/15 bg-primary/7 px-1.5 py-0.5 font-mono text-[9px] text-primary/90 transition-colors hover:border-primary/35 hover:bg-primary/12`,onClick:()=>t(n),title:`Filter by ${e}: ${n}`,children:[e,`:`,n]},`${e}:${n}`))})}function ee(){return(0,A.jsx)(`div`,{className:`space-y-2 pt-3`,role:`status`,"aria-label":`Loading audience memories`,children:[0,1,2].map(e=>(0,A.jsxs)(`div`,{className:`animate-pulse rounded-md border border-border/50 p-3`,children:[(0,A.jsx)(`div`,{className:`h-2.5 w-full rounded bg-muted`}),(0,A.jsx)(`div`,{className:`mt-2 h-2.5 w-2/3 rounded bg-muted`}),(0,A.jsx)(`div`,{className:`mt-3 h-4 w-24 rounded bg-muted`})]},e))})}function te({onAdd:e}){return(0,A.jsxs)(`div`,{className:`flex h-full min-h-44 flex-col items-center justify-center px-5 text-center`,children:[(0,A.jsx)(`span`,{className:`mb-3 flex size-10 items-center justify-center rounded-full border border-dashed border-primary/35 bg-primary/5 text-primary`,children:(0,A.jsx)(n,{className:`size-4`})}),(0,A.jsx)(`p`,{className:`text-xs font-medium`,children:`Route guidance to the right agents`}),(0,A.jsx)(`p`,{className:`mt-1 max-w-52 text-[10px] leading-4 text-muted-foreground`,children:`Scope a memory by role, task type, or operating mode. Matching agents receive it automatically.`}),(0,A.jsxs)(x,{variant:`outline`,size:`sm`,className:`mt-3 h-7 gap-1 text-xs`,onClick:e,children:[(0,A.jsx)(l,{className:`size-3`}),`Add scoped memory`]})]})}function ne({open:e,busy:t,onOpenChange:n,onCreate:r}){let[i,a]=(0,k.useState)(``),[o,s]=(0,k.useState)(`workflow`),[c,l]=(0,k.useState)(``),[u,d]=(0,k.useState)(``),[f,p]=(0,k.useState)(``);(0,k.useEffect)(()=>{e||(a(``),s(`workflow`),l(``),d(``),p(``))},[e]);let m=O(c),S=O(u),C=O(f),w=i.trim().length>0&&(m.length>0||S.length>0||C.length>0);return(0,A.jsx)(b,{open:e,onOpenChange:n,children:(0,A.jsxs)(_,{className:`max-w-xl`,children:[(0,A.jsxs)(h,{children:[(0,A.jsx)(v,{children:`Add audience-scoped memory`}),(0,A.jsx)(y,{children:`This guidance is injected only when an agent matches at least one supplied selector.`})]}),(0,A.jsxs)(`div`,{className:`space-y-4`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{htmlFor:`audience-memory-text`,className:`mb-1.5 block text-xs font-medium`,children:`Memory`}),(0,A.jsx)(`textarea`,{id:`audience-memory-text`,value:i,onChange:e=>a(e.target.value),placeholder:`What should matching agents remember?`,rows:4,autoFocus:!0,className:`w-full resize-y rounded-md border border-input bg-background px-3 py-2 text-sm outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring`})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{htmlFor:`audience-memory-kind`,className:`mb-1.5 block text-xs font-medium`,children:`Kind`}),(0,A.jsx)(`select`,{id:`audience-memory-kind`,value:o,onChange:e=>s(e.target.value),className:`h-9 w-full rounded-md border border-input bg-background px-3 text-xs outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:E.map(e=>(0,A.jsx)(`option`,{value:e,children:D[e]??e},e))})]}),(0,A.jsxs)(`fieldset`,{className:`space-y-3 rounded-md border border-border/70 bg-background/35 p-3`,children:[(0,A.jsx)(`legend`,{className:`px-1 text-xs font-medium`,children:`Audience selectors`}),(0,A.jsx)(B,{id:`audience-memory-roles`,label:`Roles`,value:c,onChange:l,placeholder:`reviewer, refactor-planner`}),(0,A.jsx)(B,{id:`audience-memory-task-types`,label:`Task types`,value:u,onChange:d,placeholder:`review, refactor, bugfix`}),(0,A.jsx)(B,{id:`audience-memory-modes`,label:`Modes`,value:f,onChange:p,placeholder:`teach, code-review`}),(0,A.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Comma-separate multiple values. At least one selector is required.`})]})]}),(0,A.jsxs)(g,{children:[(0,A.jsx)(x,{variant:`outline`,onClick:()=>n(!1),disabled:t,children:`Cancel`}),(0,A.jsx)(x,{onClick:()=>r({text:i.trim(),kind:o,roles:m,taskTypes:S,modes:C}),disabled:!w||t,children:t?`Remembering…`:`Remember`})]})]})})}function B({id:e,label:t,value:n,placeholder:r,onChange:i}){return(0,A.jsxs)(`div`,{className:`grid gap-1.5 sm:grid-cols-[6rem_1fr] sm:items-center`,children:[(0,A.jsx)(`label`,{htmlFor:e,className:`text-[11px] font-medium text-muted-foreground`,children:t}),(0,A.jsx)(S,{id:e,value:n,onChange:e=>i(e.target.value),placeholder:r,className:`h-8 font-mono text-xs`})]})}function re({open:e,onOpenChange:t,onImport:n}){let[r,i]=(0,k.useState)(``);return(0,k.useEffect)(()=>{e||i(``)},[e]),(0,A.jsx)(b,{open:e,onOpenChange:t,children:(0,A.jsxs)(_,{className:`max-w-xl`,children:[(0,A.jsxs)(h,{children:[(0,A.jsx)(v,{children:`Import audience memories`}),(0,A.jsxs)(y,{children:[`Paste the JSON produced here or by `,(0,A.jsx)(`code`,{children:`/memory audience export`}),`. Entries without a valid audience selector are skipped.`]})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`label`,{htmlFor:`audience-memory-import`,className:`mb-1.5 block text-xs font-medium`,children:`JSON array`}),(0,A.jsx)(`textarea`,{id:`audience-memory-import`,value:r,onChange:e=>i(e.target.value),placeholder:`[
2
- { "text": "…", "audience": { "roles": ["reviewer"] } }
3
- ]`,rows:10,autoFocus:!0,spellCheck:!1,className:`w-full resize-y rounded-md border border-input bg-background p-3 font-mono text-xs outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring`})]}),(0,A.jsxs)(g,{children:[(0,A.jsx)(x,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,A.jsxs)(x,{onClick:()=>n(r),disabled:!r.trim(),children:[(0,A.jsx)(u,{className:`size-4`}),`Import memories`]})]})]})})}export{I as AudienceMemoryPanel};